@mamba/keyboard
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -48,3 +48,3 @@ import { GeneralKeyboard } from '../lib/index.js'; | ||
}, | ||
configurable: true, | ||
configurable: false, | ||
enumerable: true, | ||
@@ -54,2 +54,20 @@ }); | ||
/** | ||
* Rewrite driver get/set of keyboard visibility | ||
*/ | ||
Object.defineProperty(driver, 'visibility', { | ||
configurable: false, | ||
get() { | ||
const _keyboard = getKeyboardInstance(); | ||
if (_keyboard) return _keyboard.visibility; | ||
return undefined; | ||
}, | ||
set(value) { | ||
const _keyboard = getKeyboardInstance(); | ||
if (_keyboard) { | ||
_keyboard.visibility = value; | ||
} | ||
}, | ||
}); | ||
/** | ||
* Find the key code of given list and key map | ||
@@ -56,0 +74,0 @@ * @param {string[]} list Key list to find |
@@ -6,2 +6,32 @@ # Change Log | ||
### [1.2.1](https://github.com/stone-payments/pos-mamba-sdk/compare/@mamba/keyboard@1.2.0...@mamba/keyboard@1.2.1) (2022-12-13) | ||
### Features | ||
* 🎸 implement disabled prop ([9801a95](https://github.com/stone-payments/pos-mamba-sdk/commit/9801a95e4f7fa1a31e08ef41ad4561a0e62a32e5)) | ||
* 🎸 implement shouldUpdateKeyboardView ([0b4393f](https://github.com/stone-payments/pos-mamba-sdk/commit/0b4393f98e4662c5223f1b1d3cfe33285aea3c08)) | ||
### Bug Fixes | ||
* 🐛 always reset/unmount when route change ([3f8d407](https://github.com/stone-payments/pos-mamba-sdk/commit/3f8d407cb27dc9a8e33ce0a63c4788a281ae3220)) | ||
* 🐛 dandles keyboard events cleaning and add guards, with render condition property ([a913856](https://github.com/stone-payments/pos-mamba-sdk/commit/a91385609b06d68b26246c6690ee0fc0bdef0cde)) | ||
* 🐛 disable effetcs on multiple inserts ([a46700f](https://github.com/stone-payments/pos-mamba-sdk/commit/a46700f658708a4d1ea2414ad1413f85995c01cb)) | ||
* 🐛 fix autoRender prop ([684c05b](https://github.com/stone-payments/pos-mamba-sdk/commit/684c05b4ca709f9cd0e4f9633e2560393fdbe413)) | ||
* 🐛 fix cursor worker listener callback references ([1087354](https://github.com/stone-payments/pos-mamba-sdk/commit/1087354589deb30b427f53545a91f84b356f6e22)) | ||
* 🐛 fix delete icon displaying as trash bin icon for some reason ([3595515](https://github.com/stone-payments/pos-mamba-sdk/commit/35955157d0a43288f6e905116becd3607821f598)) | ||
* 🐛 fix filter numbers only output ([f656600](https://github.com/stone-payments/pos-mamba-sdk/commit/f656600adb039dd12a542c1f727a210572f2d514)) | ||
* 🐛 fix keyboard core instance of svelte update ([e9053de](https://github.com/stone-payments/pos-mamba-sdk/commit/e9053dede00aa0d365af02f04835cb3aca21e795)) | ||
* 🐛 fix suggestion box and its multiple button inserts ([b16d598](https://github.com/stone-payments/pos-mamba-sdk/commit/b16d59805e9fa4de40473397e030d1c276a7464a)) | ||
* 🐛 fix webpack source map loader order ([c04c8c7](https://github.com/stone-payments/pos-mamba-sdk/commit/c04c8c72ff4b6c522efe775099da31186a7d278a)) | ||
* 🐛 prevents cursor worker work when keyboard is not visible ([4c7b830](https://github.com/stone-payments/pos-mamba-sdk/commit/4c7b830f9ef11ff34a5732d4dde2d24d34d727e8)) | ||
### Performance Improvements | ||
* ⚡️ debounce keyboard render ([0c9dcc4](https://github.com/stone-payments/pos-mamba-sdk/commit/0c9dcc48fd307c25531f1daccd13582f285c43ed)) | ||
## [1.2.0](https://github.com/stone-payments/pos-mamba-sdk/compare/@mamba/keyboard@1.1.3...@mamba/keyboard@1.2.0) (2022-11-15) | ||
@@ -8,0 +38,0 @@ |
@@ -0,2 +1,4 @@ | ||
import { KeyboardVisibility, } from '../types'; | ||
import { greddyBraces } from './regExps'; | ||
import { bindMethods } from '../helpers'; | ||
/** | ||
@@ -19,2 +21,3 @@ * CursorWorker. | ||
this.keyboardInstance = keyboardInstance; | ||
bindMethods(CursorWorker, this); | ||
this.cursorPosition = null; | ||
@@ -150,2 +153,8 @@ this.cursorPositionEnd = null; | ||
const options = this.getOptions(); | ||
if (this.keyboardInstance.isRenderAllowed !== true) | ||
return; | ||
if (options.disabled === true) | ||
return; | ||
if (this.keyboardInstance.visibility === KeyboardVisibility.Hidden) | ||
return; | ||
const isDOMInputType = event.target instanceof HTMLInputElement; | ||
@@ -161,3 +170,3 @@ const isKeyboard = event.target === this.keyboardInstance.keyboardDOM || | ||
*/ | ||
this.setCursorPosition(event.target.selectionStart, event.target.selectionEnd); | ||
this.setCursorPosition(event.target.selectionStart, event.target.selectionEnd, false, event.target); | ||
if (options.debug) { | ||
@@ -194,6 +203,6 @@ console.log('Cursor at: ', this.getCursorPosition(), this.getCursorPositionEnd(), event && event.target.tagName.toLowerCase(), `(${this.keyboardInstance.keyboardDOMClass})`); | ||
*/ | ||
document.addEventListener('keyup', (e) => this.cursorEventHandler(e)); | ||
document.addEventListener('mouseup', (e) => this.cursorEventHandler(e)); | ||
document.addEventListener('select', (e) => this.cursorEventHandler(e)); | ||
document.addEventListener('selectionchange', (e) => this.cursorEventHandler(e)); | ||
document.addEventListener('keyup', this.cursorEventHandler); | ||
document.addEventListener('mouseup', this.cursorEventHandler); | ||
document.addEventListener('select', this.cursorEventHandler); | ||
document.addEventListener('selectionchange', this.cursorEventHandler); | ||
this.setuped = true; | ||
@@ -207,6 +216,6 @@ } | ||
return; | ||
document.removeEventListener('keyup', (e) => this.cursorEventHandler(e)); | ||
document.removeEventListener('mouseup', (e) => this.cursorEventHandler(e)); | ||
document.removeEventListener('select', (e) => this.cursorEventHandler(e)); | ||
document.removeEventListener('selectionchange', (e) => this.cursorEventHandler(e)); | ||
document.removeEventListener('keyup', this.cursorEventHandler); | ||
document.removeEventListener('mouseup', this.cursorEventHandler); | ||
document.removeEventListener('select', this.cursorEventHandler); | ||
document.removeEventListener('selectionchange', this.cursorEventHandler); | ||
this.setuped = false; | ||
@@ -267,4 +276,5 @@ } | ||
const options = this.getOptions(); | ||
if (options.filtersNumbersOnly === true) { | ||
value = Number(value.replace(/\D/g, '')).toString(); | ||
if (options.filtersNumbersOnly === true || | ||
this.keyboardInstance.generalKeyboard.alphanumericEnabled === true) { | ||
value = value.replace(/\D/g, ''); | ||
} | ||
@@ -280,3 +290,4 @@ return value; | ||
* @param cursorPosEnd The cursor's current end position | ||
* @param moveCursor Whether to update mamba-keyboard's cursor | ||
* @param moveCursor Whether to update mamba-keyboard's cursor | ||
* @return Updated input value | ||
*/ | ||
@@ -283,0 +294,0 @@ getUpdatedInput(button, input, moveCursor = false) { |
@@ -18,12 +18,28 @@ import { createKeyboardElement, ClassNames } from '../helpers'; | ||
} | ||
shouldUpdateOrCease() { | ||
const input = this.keyboardInstance.getInput(); | ||
const last = input.slice(-1); | ||
reset() { | ||
this.clearBox(); | ||
this.lastSuggestionList = undefined; | ||
} | ||
/** | ||
* Shows or hides suggestion box on button click. | ||
* @param inputValueCandidate The input value about to show before sending to the DOM input. | ||
* @return Return `true` if button has some suggestions to show | ||
*/ | ||
shouldUpdateOrCease(inputValueCandidate) { | ||
if (!inputValueCandidate) | ||
inputValueCandidate = this.keyboardInstance.getInput(); | ||
const last = inputValueCandidate.slice(-1); | ||
const suggestionFound = DEFAULT_SUGGESTIONS[last]; | ||
if (suggestionFound) { | ||
if (this.lastSuggestionList === suggestionFound) { | ||
this.reset(); | ||
return false; | ||
} | ||
this.lastSuggestionList = suggestionFound; | ||
this.render(suggestionFound.split(' ')); | ||
} | ||
else { | ||
this.clearBox(); | ||
this.reset(); | ||
} | ||
return !!suggestionFound; | ||
} | ||
@@ -56,3 +72,6 @@ /** | ||
suggestionButton.textContent = suggestionValue; | ||
suggestionButton.onclick = (e) => this.onSelect(suggestionValue, e); | ||
suggestionButton.onclick = (e) => { | ||
this.reset(); | ||
this.onSelect(suggestionValue, e); | ||
}; | ||
// Add button to the table cell | ||
@@ -59,0 +78,0 @@ suggestionCell.appendChild(suggestionButton); |
@@ -68,15 +68,19 @@ import { KEYBOARD } from '@mamba/core'; | ||
*/ | ||
this.keyboardInstance.visibility = KeyboardVisibility.Visible; | ||
/** | ||
* If the keepVisible option is on and user hit some button without input focus, we need ensure that virtual input do not update its values back to the DOM input on next update. | ||
*/ | ||
this.updateVirtualInputfromDOMValue(input); | ||
/** | ||
* Add listeners on focused input | ||
*/ | ||
this.addDOMInputEventListeners(input); | ||
/** | ||
* Handle focused input data set | ||
*/ | ||
this.keyboardInstance.handleDOMInputDataset(); | ||
if (this.keyboardInstance.isRenderAllowed === true) { | ||
this.keyboardInstance.visibility = KeyboardVisibility.Visible; | ||
/** | ||
* If the keepVisible option is on and user hit some button without input focus, we need ensure that virtual input do not update its values back to the DOM input on next update. | ||
*/ | ||
this.updateVirtualInputfromDOMValue(input); | ||
/** | ||
* Add listeners on focused input | ||
*/ | ||
this.addDOMInputEventListeners(input); | ||
/** | ||
* Handle focused input data set | ||
*/ | ||
this.keyboardInstance.handleDOMInputDataset(); | ||
return; | ||
} | ||
this.removeDOMInputEventListeners(); | ||
} | ||
@@ -83,0 +87,0 @@ } |
@@ -26,2 +26,3 @@ /* eslint-disable prefer-destructuring */ | ||
this.hiddenKeyboardClass = ClassNames.hiddenKeyboardClassDefault; | ||
this.initialized = false; | ||
this.keyboardType = KeyboardType.Default; | ||
@@ -31,3 +32,3 @@ this.keyboardVisible = KeyboardVisibility.Hidden; | ||
this.defaultLayoutAndName = 'default'; | ||
this.activeTime = 100; | ||
this.activeTime = 150; | ||
this.driverBinded = false; | ||
@@ -178,2 +179,5 @@ this.defaultAllowKeySyntheticEvent = ['{backspace}', '{enter}', '{check}']; | ||
options); | ||
if (this.options.debug) { | ||
console.log(`Initial keyboard options: `, this.options); | ||
} | ||
/** | ||
@@ -230,7 +234,6 @@ * Keep keyboard initial props for reset work | ||
*/ | ||
const { autoRender = true } = this.options; | ||
if (this.keyboardDOM) { | ||
if (!(this.options.autoRender === false) || this.options.keepVisible) { | ||
setTimeout(() => { | ||
this.render(); | ||
}, 1); | ||
if (this.isRenderAllowed && (autoRender || this.options.keepVisible)) { | ||
this.render(); | ||
} | ||
@@ -314,15 +317,27 @@ } | ||
*/ | ||
if (!this.suggestionsBox && keyboardType === KeyboardType.Default) { | ||
this.suggestionsBox = new SuggestionBox({ | ||
getOptions: this.getOptions, | ||
keyboardInstance: this, | ||
onSelect: (button, e) => { | ||
this.handleButtonClicked(button, e); | ||
}, | ||
}); | ||
} | ||
else if (this.suggestionsBox) { | ||
const { enableLayoutSuggestions = true } = keyboardOptions; | ||
if ((keyboardType !== KeyboardType.Default && this.suggestionsBox) || | ||
(this.suggestionsBox && !enableLayoutSuggestions)) { | ||
this.suggestionsBox.destroy(); | ||
this.suggestionsBox = undefined; | ||
} | ||
else if (!this.suggestionsBox && | ||
enableLayoutSuggestions && | ||
keyboardType === KeyboardType.Default) { | ||
if (enableLayoutSuggestions) | ||
this.suggestionsBox = new SuggestionBox({ | ||
getOptions: this.getOptions, | ||
keyboardInstance: this, | ||
onSelect: (button, e) => { | ||
if (button.length === 1) { | ||
this.handleButtonClicked(button, e); | ||
return; | ||
} | ||
const buttonList = button.split(''); | ||
for (let i = 0; i < buttonList.length; i++) { | ||
this.handleButtonClicked(buttonList[i], e, true); | ||
} | ||
}, | ||
}); | ||
} | ||
/** | ||
@@ -376,3 +391,14 @@ * Get keyboard ready | ||
set visibility(value) { | ||
if (this.options.keepVisible === true) { | ||
const allowed = this.isRenderAllowed; | ||
if (this.options.debug) { | ||
if (value === KeyboardVisibility.Visible && !allowed) { | ||
console.info(`Set visibility to "${value}" has no effect with renderCondition \`false\``); | ||
} | ||
} | ||
if (!allowed) | ||
return; | ||
if (value === KeyboardVisibility.Hidden && this.options.keepVisible === true) { | ||
if (this.options.debug) { | ||
console.log(`Cannot set keyboard visibility to ${value} while keepVisible property is "true"`); | ||
} | ||
value = KeyboardVisibility.Visible; | ||
@@ -731,2 +757,3 @@ } | ||
'setKeyboardAsCustomType', | ||
'shouldUpdateKeyboardView', | ||
'destroy', | ||
@@ -740,14 +767,2 @@ ]; | ||
} | ||
/** | ||
* Rewrite driver get/set of keyboard visibility | ||
*/ | ||
Object.defineProperty(driver, 'visibility', { | ||
configurable: true, | ||
get() { | ||
return instance.visibility; | ||
}, | ||
set(value) { | ||
instance.visibility = value; | ||
}, | ||
}); | ||
instance.driverBinded = true; | ||
@@ -768,4 +783,10 @@ } | ||
* @param button The button's layout name. | ||
* @param e Click event | ||
* @param isMultipleInsert If the button comes from a list of multiple words from suggestion box. | ||
*/ | ||
handleButtonClicked(button, e) { | ||
handleButtonClicked(button, e, isMultipleInsert = false) { | ||
if (this.isRenderAllowed !== true) | ||
return; | ||
if (this.options.disabled === true) | ||
return; | ||
const focusedInput = document.activeElement; | ||
@@ -790,6 +811,33 @@ /** | ||
/** | ||
* Defining button type {@link ButtonType} | ||
*/ | ||
const buttonType = getButtonType(button); | ||
/** | ||
* Calculating new input | ||
*/ | ||
const updatedInput = this.cursorWorker.getUpdatedInput(button, this.input.default); | ||
const updatedInput = this.cursorWorker.getUpdatedInput(button, this.input.default, true); | ||
/** | ||
* Call active class handler | ||
*/ | ||
if (!isMultipleInsert) | ||
this.handleActiveButton(e); | ||
/** | ||
* Call suggestion box update if exist | ||
*/ | ||
if ( | ||
// Disallow use of suggestion box when inserting multiple words | ||
!isMultipleInsert && | ||
// Suggestion instance must exist before use | ||
this.suggestionsBox && | ||
// Suggestions to work only when Standard button pressed | ||
buttonType !== ButtonType.Function && | ||
// If user setup the input property element compatible with DOM Input element | ||
(isProperInput(this.options.input || focusedInput) || | ||
// Or it is non DOM Input element, but a `<div>` | ||
isNonInputButProperElement(this.options.input || focusedInput))) { | ||
const hasSuggestion = this.suggestionsBox.shouldUpdateOrCease(updatedInput); | ||
if (hasSuggestion) | ||
return; | ||
} | ||
/** | ||
* Calling onKeyPress | ||
@@ -800,6 +848,2 @@ */ | ||
/** | ||
* Defining button type {@link ButtonType} | ||
*/ | ||
const buttonType = getButtonType(button); | ||
/** | ||
* If key is a function key lie "{alt}". Calling function key press eventd | ||
@@ -828,5 +872,11 @@ */ | ||
/** | ||
* If maxLength and handleMaxLength yield true, halting | ||
*/ | ||
if (this.options.maxLength && this.cursorWorker.handleMaxLength(this.input, updatedInput)) { | ||
return; | ||
} | ||
/** | ||
* Define is pattern and value is valid | ||
*/ | ||
const isValidInputPattern = this.options.inputPattern && this.inputPatternIsValid(updatedInput); | ||
const isValidInputPattern = (this.options.inputPattern && this.inputPatternIsValid(updatedInput)) || true; | ||
if ( | ||
@@ -836,19 +886,10 @@ // If input will change as a result of this button press | ||
// This pertains to the "inputPattern" option: | ||
// If inputPattern isn't set | ||
(!this.options.inputPattern || | ||
// Or, if it is set and if the pattern is valid - we proceed. | ||
isValidInputPattern)) { | ||
// If inputPattern validation passes | ||
isValidInputPattern) { | ||
/** | ||
* If maxLength and handleMaxLength yield true, halting | ||
*/ | ||
if (this.options.maxLength && this.cursorWorker.handleMaxLength(this.input, updatedInput)) { | ||
return; | ||
} | ||
/** | ||
* Updating input | ||
*/ | ||
const newInputValue = this.cursorWorker.getUpdatedInput(button, this.input.default, true); | ||
this.setInput(newInputValue); | ||
this.setInput(updatedInput); | ||
if (this.options.debug) { | ||
console.log('Cursor at: ', this.cursorWorker.getCursorPosition(), this.cursorWorker.getCursorPositionEnd(), `(${this.keyboardDOMClass})`); | ||
console.log('Cursor at: ', this.cursorWorker.getCursorPosition(), this.cursorWorker.getCursorPositionEnd(), `(${this.keyboardDOMClass})`, `New input value: "${updatedInput}"`); | ||
} | ||
@@ -862,21 +903,7 @@ /** | ||
/** | ||
* Call synthetic event handler | ||
* Call synthetic event handler if inputPattern validation passes | ||
*/ | ||
this.shouldDispatchSyntheticKeyEvent(button, buttonOutput, buttonType, isValidInputPattern, e); | ||
/** | ||
* Call suggestion box update if exist | ||
*/ | ||
if (this.suggestionsBox && | ||
// Suggestions to work only when Standard button pressed | ||
buttonType !== ButtonType.Function && | ||
// If user setup the input property element compatible with DOM Input element | ||
(isProperInput(this.options.input || focusedInput) || | ||
// Or it is non DOM Input element, but a `<div>` | ||
isNonInputButProperElement(this.options.input || focusedInput))) { | ||
this.suggestionsBox.shouldUpdateOrCease(); | ||
if (isValidInputPattern) { | ||
this.shouldDispatchSyntheticKeyEvent(button, buttonOutput, buttonType, isValidInputPattern, e, isMultipleInsert); | ||
} | ||
/** | ||
* Call active class handler | ||
*/ | ||
this.handleActiveButton(e); | ||
if (this.options.debug) { | ||
@@ -889,3 +916,7 @@ console.log('Key pressed:', { button, buttonOutput }); | ||
*/ | ||
shouldDispatchSyntheticKeyEvent(button, buttonOutput, buttonType, isValidInputPattern, e) { | ||
shouldDispatchSyntheticKeyEvent(button, buttonOutput, buttonType, isValidInputPattern, e, isMultipleInsert = false) { | ||
if (this.isRenderAllowed !== true) | ||
return; | ||
if (this.options.disabled === true) | ||
return; | ||
const allowKeyPass = Array.isArray(this.options.allowKeySyntheticEvent) && | ||
@@ -912,3 +943,3 @@ this.options.allowKeySyntheticEvent.includes(button); | ||
} | ||
else if (this.options.soundEnabled === true) { | ||
else if (this.options.soundEnabled === true && !isMultipleInsert) { | ||
/** | ||
@@ -945,2 +976,4 @@ * Pontually handle beep sound on key press for manual update mode | ||
handleKeyboardVisibility(visibility = KeyboardVisibility.Visible) { | ||
if (!this.isRenderAllowed) | ||
return; | ||
/** | ||
@@ -1033,3 +1066,3 @@ * Set the instance visibility | ||
*/ | ||
isRenderAllowed() { | ||
get isRenderAllowed() { | ||
if (typeof this.options.renderCondition === 'function') { | ||
@@ -1044,3 +1077,35 @@ return Boolean(this.options.renderCondition()); | ||
/** | ||
* Renders or update the keyboard buttons | ||
* Update keyboard view | ||
*/ | ||
shouldUpdateKeyboardView() { | ||
if (!this.keyboardDOM) | ||
return; | ||
if (typeof this.updateId === 'number') { | ||
clearTimeout(this.updateId); | ||
} | ||
// Wait next tick, for svelte render component | ||
this.updateId = window.setTimeout(() => { | ||
/** | ||
* Change keyboard positon to handle mamba <Button /> sticky at the bottom | ||
*/ | ||
const bottomButton = document.querySelector('.button.at-bottom'); | ||
if (bottomButton) { | ||
this.keyboardDOM.style.marginBottom = `${bottomButton.offsetHeight}px`; | ||
} | ||
else { | ||
this.keyboardDOM.style.marginBottom = ''; | ||
} | ||
}, 10); | ||
} | ||
/** | ||
* Debounce keyboard rendering | ||
*/ | ||
render() { | ||
window.clearTimeout(this.renderDebounceId); | ||
this.renderDebounceId = window.setTimeout(() => { | ||
this.trueRender(); | ||
}, 3); | ||
} | ||
/** | ||
* True renders or update the keyboard buttons | ||
* Can be called direct if `autoRender` is off | ||
@@ -1050,3 +1115,3 @@ * @throws LAYOUT_NOT_FOUND_ERROR - layout not found | ||
*/ | ||
render() { | ||
trueRender() { | ||
/** | ||
@@ -1059,8 +1124,7 @@ * Clear keyboard | ||
*/ | ||
if (!this.isRenderAllowed()) { | ||
if (this.options.debug) { | ||
console.log('Keyboard render not allowed! Check keyboard options.'); | ||
} | ||
if (!this.isRenderAllowed) { | ||
this.cursorWorker.ceaseCursorEventsControl(); | ||
return; | ||
} | ||
this.cursorWorker.setupCursorEventsControl(); | ||
if (this.options.debug) { | ||
@@ -1093,12 +1157,2 @@ console.log(`Rendering/Updating keyboard`); | ||
/** | ||
* Change keyboard positon to handle mamba <Button /> sticky at the bottom | ||
*/ | ||
const bottomButton = document.querySelector('.button.at-bottom'); | ||
if (bottomButton) { | ||
this.keyboardDOM.style.marginBottom = `${bottomButton.offsetHeight}px`; | ||
} | ||
else { | ||
this.keyboardDOM.style.marginBottom = ''; | ||
} | ||
/** | ||
* Create row wrapper | ||
@@ -1204,2 +1258,6 @@ */ | ||
/** | ||
* Update keyboard view if need | ||
*/ | ||
this.shouldUpdateKeyboardView(); | ||
/** | ||
* Calling onRender | ||
@@ -1206,0 +1264,0 @@ */ |
{ | ||
"name": "@mamba/keyboard", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"main": "lib/index.js", | ||
@@ -35,9 +35,9 @@ "types": "types/index.d.ts", | ||
"dependencies": { | ||
"@mamba/core": "1.3.0", | ||
"@mamba/input": "6.2.0", | ||
"@mamba/utils": "5.2.0", | ||
"@mamba/core": "1.3.1", | ||
"@mamba/input": "6.2.1", | ||
"@mamba/utils": "5.2.1", | ||
"@types/lodash": "^4.14.182", | ||
"lodash": "^4.17.21" | ||
}, | ||
"gitHead": "67b6cf759cfba3111ba6ad28918b669bfb96d189" | ||
"gitHead": "6608d60a69529d0c8d8c10bb41afe466102c54c3" | ||
} |
@@ -243,2 +243,14 @@ # Keyboard | ||
/** | ||
* Enabled or disables keyboard events and actions. | ||
* This property do not change keybpard visibility. | ||
*/ | ||
disabled?: boolean; | ||
/** | ||
* Controls keyboard visibility. | ||
* Setting this propertie with `renderCondition: false` has no effect. | ||
*/ | ||
visibility?: KeyboardVisibility | string; | ||
/** | ||
* A prop to ensure characters are always be added/removed at the end of the string. | ||
@@ -647,2 +659,6 @@ */ | ||
### `shouldUpdateKeyboardView(): void` | ||
Atualiza os estilos automáticos do teclado virtual. Normalmente posicionamento na tela. | ||
## Enumeradores | ||
@@ -649,0 +665,0 @@ |
@@ -15,2 +15,3 @@ { | ||
"inlineSources": false, | ||
"sourceRoot": "", | ||
"declaration": true, | ||
@@ -17,0 +18,0 @@ "suppressImplicitAnyIndexErrors": true, |
@@ -120,3 +120,4 @@ import { KeyboardInput, KeyboardOptions, CursorPosition, CursorWorkerParams } from '../types'; | ||
* @param cursorPosEnd The cursor's current end position | ||
* @param moveCursor Whether to update mamba-keyboard's cursor | ||
* @param moveCursor Whether to update mamba-keyboard's cursor | ||
* @return Updated input value | ||
*/ | ||
@@ -123,0 +124,0 @@ getUpdatedInput(button: string, input: string, moveCursor?: boolean): string; |
@@ -9,2 +9,3 @@ import { KeyboardOptions, SuggestionBoxParams, onSuggestionSelect } from '../types'; | ||
suggestionDOMElement: HTMLDivElement; | ||
lastSuggestionList?: string; | ||
onSelect: onSuggestionSelect; | ||
@@ -16,4 +17,10 @@ constructor({ getOptions, keyboardInstance, onSelect }: SuggestionBoxParams); | ||
destroy(): void; | ||
shouldUpdateOrCease(): void; | ||
reset(): void; | ||
/** | ||
* Shows or hides suggestion box on button click. | ||
* @param inputValueCandidate The input value about to show before sending to the DOM input. | ||
* @return Return `true` if button has some suggestions to show | ||
*/ | ||
shouldUpdateOrCease(inputValueCandidate?: string): boolean; | ||
/** | ||
* Remove keyboard suggestion box | ||
@@ -20,0 +27,0 @@ */ |
@@ -33,2 +33,4 @@ import PhysicalKeyboard from './controllers/PhysicalKeyboard'; | ||
driverBinded: boolean; | ||
updateId?: number; | ||
renderDebounceId?: number; | ||
defaultAllowKeySyntheticEvent: string[]; | ||
@@ -190,2 +192,4 @@ internalOnFunctionKeyPress?: (button: string, instance: Keyboard, e?: KeyboardHandlerEvent) => void; | ||
* @param button The button's layout name. | ||
* @param e Click event | ||
* @param isMultipleInsert If the button comes from a list of multiple words from suggestion box. | ||
*/ | ||
@@ -239,5 +243,13 @@ private handleButtonClicked; | ||
*/ | ||
private isRenderAllowed; | ||
get isRenderAllowed(): boolean; | ||
/** | ||
* Renders or update the keyboard buttons | ||
* Update keyboard view | ||
*/ | ||
shouldUpdateKeyboardView(): void; | ||
/** | ||
* Debounce keyboard rendering | ||
*/ | ||
render(): void; | ||
/** | ||
* True renders or update the keyboard buttons | ||
* Can be called direct if `autoRender` is off | ||
@@ -247,5 +259,5 @@ * @throws LAYOUT_NOT_FOUND_ERROR - layout not found | ||
*/ | ||
render(): void; | ||
trueRender(): void; | ||
} | ||
export type { Keyboard }; | ||
export default Keyboard; |
@@ -236,5 +236,11 @@ import type Keyboard from './Keyboard'; | ||
* Can be a Boolean or a function that do something and return a boolean. | ||
* This property change keybpard visibility and stop its events and actions too. | ||
*/ | ||
renderCondition?: boolean | (() => boolean); | ||
/** | ||
* Enabled or disables keyboard events and actions. | ||
* This property do not change keybpard visibility. | ||
*/ | ||
disabled?: boolean; | ||
/** | ||
* A prop to ensure characters are always be added/removed at the end of the string. | ||
@@ -241,0 +247,0 @@ */ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
449868
152
5085
794
0
+ Added@mamba/app@5.2.1(transitive)
+ Added@mamba/button@5.2.1(transitive)
+ Added@mamba/core@1.3.1(transitive)
+ Added@mamba/dialog@4.2.1(transitive)
+ Added@mamba/icon@4.2.1(transitive)
+ Added@mamba/input@6.2.1(transitive)
+ Added@mamba/pos@4.3.1(transitive)
+ Added@mamba/radio@4.2.1(transitive)
+ Added@mamba/sprite@4.2.1(transitive)
+ Added@mamba/styles@4.3.1(transitive)
+ Added@mamba/switch@5.2.1(transitive)
+ Added@mamba/utils@5.2.1(transitive)
- Removed@mamba/app@5.2.0(transitive)
- Removed@mamba/button@5.2.0(transitive)
- Removed@mamba/core@1.3.0(transitive)
- Removed@mamba/dialog@4.2.0(transitive)
- Removed@mamba/icon@4.2.0(transitive)
- Removed@mamba/input@6.2.0(transitive)
- Removed@mamba/pos@4.3.0(transitive)
- Removed@mamba/radio@4.2.0(transitive)
- Removed@mamba/sprite@4.2.0(transitive)
- Removed@mamba/styles@4.3.0(transitive)
- Removed@mamba/switch@5.2.0(transitive)
- Removed@mamba/utils@5.2.0(transitive)
Updated@mamba/core@1.3.1
Updated@mamba/input@6.2.1
Updated@mamba/utils@5.2.1