mirror of
https://github.com/hodgef/simple-keyboard.git
synced 2025-01-19 00:13:00 +08:00
Using display options with layoutCandidates. Fixes #1831
This commit is contained in:
parent
040d4fc40f
commit
5e1df22e59
5
build/components/CandidateBox.d.ts
vendored
5
build/components/CandidateBox.d.ts
vendored
@ -1,12 +1,13 @@
|
||||
import "./css/CandidateBox.css";
|
||||
import Utilities from "../services/Utilities";
|
||||
import { CandidateBoxParams, CandidateBoxRenderParams, CandidateBoxShowParams } from "./../interfaces";
|
||||
import { CandidateBoxParams, CandidateBoxRenderParams, CandidateBoxShowParams, KeyboardOptions } from "./../interfaces";
|
||||
declare class CandidateBox {
|
||||
utilities: Utilities;
|
||||
options: KeyboardOptions;
|
||||
candidateBoxElement: HTMLDivElement;
|
||||
pageIndex: number;
|
||||
pageSize: number;
|
||||
constructor({ utilities }: CandidateBoxParams);
|
||||
constructor({ utilities, options }: CandidateBoxParams);
|
||||
destroy(): void;
|
||||
show({ candidateValue, targetElement, onSelect, }: CandidateBoxShowParams): void;
|
||||
renderPage({ candidateListPages, targetElement, pageIndex, nbPages, onItemSelected, }: CandidateBoxRenderParams): void;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*!
|
||||
*
|
||||
* simple-keyboard v3.4.210
|
||||
* simple-keyboard v3.5.0
|
||||
* https://github.com/hodgef/simple-keyboard
|
||||
*
|
||||
* Copyright (c) Francisco Hodge (https://github.com/hodgef) and project contributors.
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
build/interfaces.d.ts
vendored
1
build/interfaces.d.ts
vendored
@ -17,6 +17,7 @@ export interface KeyboardInput {
|
||||
}
|
||||
export type CandidateBoxParams = {
|
||||
utilities: Utilities;
|
||||
options: KeyboardOptions;
|
||||
};
|
||||
export type CandidateBoxShowParams = {
|
||||
candidateValue: string;
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "simple-keyboard",
|
||||
"version": "3.4.210",
|
||||
"version": "3.5.0",
|
||||
"description": "On-screen Javascript Virtual Keyboard",
|
||||
"main": "build/index.js",
|
||||
"scripts": {
|
||||
|
@ -5,16 +5,19 @@ import {
|
||||
CandidateBoxParams,
|
||||
CandidateBoxRenderParams,
|
||||
CandidateBoxShowParams,
|
||||
KeyboardOptions,
|
||||
} from "./../interfaces";
|
||||
|
||||
class CandidateBox {
|
||||
utilities: Utilities;
|
||||
options: KeyboardOptions;
|
||||
candidateBoxElement!: HTMLDivElement;
|
||||
pageIndex = 0;
|
||||
pageSize;
|
||||
|
||||
constructor({ utilities }: CandidateBoxParams) {
|
||||
constructor({ utilities, options }: CandidateBoxParams) {
|
||||
this.utilities = utilities;
|
||||
this.options = options;
|
||||
Utilities.bindMethods(CandidateBox, this);
|
||||
this.pageSize = this.utilities.getOptions().layoutCandidatesPageSize || 5;
|
||||
}
|
||||
@ -82,7 +85,7 @@ class CandidateBox {
|
||||
};
|
||||
|
||||
candidateListLIElement.className = "hg-candidate-box-list-item";
|
||||
candidateListLIElement.textContent = candidateListItem;
|
||||
candidateListLIElement.textContent = this.options.display?.[candidateListItem] || candidateListItem;
|
||||
candidateListLIElement.onclick = (e = getMouseEvent()) =>
|
||||
onItemSelected(candidateListItem, e);
|
||||
|
||||
|
@ -215,6 +215,7 @@ class SimpleKeyboard {
|
||||
this.candidateBox = this.options.enableLayoutCandidates
|
||||
? new CandidateBox({
|
||||
utilities: this.utilities,
|
||||
options: this.options,
|
||||
})
|
||||
: null;
|
||||
|
||||
@ -878,6 +879,7 @@ class SimpleKeyboard {
|
||||
this.candidateBox.destroy();
|
||||
this.candidateBox = new CandidateBox({
|
||||
utilities: this.utilities,
|
||||
options: this.options,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,8 @@ export interface KeyboardInput {
|
||||
}
|
||||
|
||||
export type CandidateBoxParams = {
|
||||
utilities: Utilities
|
||||
utilities: Utilities,
|
||||
options: KeyboardOptions
|
||||
}
|
||||
|
||||
export type CandidateBoxShowParams = {
|
||||
|
Loading…
Reference in New Issue
Block a user