@yoobic/yobi 8.2.0-17 → 8.2.0-18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/cjs/design-system.cjs.js +1 -1
  2. package/dist/cjs/{form-choice-helpers-e5394fc2.js → form-choice-helpers-da1c35a3.js} +4 -4
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/yoo-form-choice-button.cjs.entry.js +1 -1
  5. package/dist/cjs/yoo-form-choice-card.cjs.entry.js +1 -1
  6. package/dist/cjs/yoo-form-choice-chat.cjs.entry.js +1 -1
  7. package/dist/cjs/yoo-form-choice-image.cjs.entry.js +1 -1
  8. package/dist/cjs/yoo-form-choice-radio.cjs.entry.js +1 -1
  9. package/dist/cjs/yoo-form-input.cjs.entry.js +27 -23
  10. package/dist/cjs/yoo-form-multi-input.cjs.entry.js +4 -3
  11. package/dist/collection/components/form/form-choice/form-choice-helpers.js +4 -4
  12. package/dist/collection/components/form/form-input/form-input.js +46 -24
  13. package/dist/collection/components/form/form-multi-input/form-multi-input.js +4 -3
  14. package/dist/design-system/design-system.esm.js +1 -1
  15. package/dist/design-system/{form-choice-helpers-62cf0a50.js → form-choice-helpers-7f7bf83b.js} +4 -4
  16. package/dist/design-system/yoo-form-choice-button.entry.js +1 -1
  17. package/dist/design-system/yoo-form-choice-card.entry.js +1 -1
  18. package/dist/design-system/yoo-form-choice-chat.entry.js +1 -1
  19. package/dist/design-system/yoo-form-choice-image.entry.js +1 -1
  20. package/dist/design-system/yoo-form-choice-radio.entry.js +1 -1
  21. package/dist/design-system/yoo-form-input.entry.js +28 -24
  22. package/dist/design-system/yoo-form-multi-input.entry.js +5 -4
  23. package/dist/esm/design-system.js +1 -1
  24. package/dist/esm/{form-choice-helpers-62cf0a50.js → form-choice-helpers-7f7bf83b.js} +4 -4
  25. package/dist/esm/loader.js +1 -1
  26. package/dist/esm/yoo-form-choice-button.entry.js +1 -1
  27. package/dist/esm/yoo-form-choice-card.entry.js +1 -1
  28. package/dist/esm/yoo-form-choice-chat.entry.js +1 -1
  29. package/dist/esm/yoo-form-choice-image.entry.js +1 -1
  30. package/dist/esm/yoo-form-choice-radio.entry.js +1 -1
  31. package/dist/esm/yoo-form-input.entry.js +28 -24
  32. package/dist/esm/yoo-form-multi-input.entry.js +5 -4
  33. package/dist/types/components/form/form-input/form-input.d.ts +1 -1
  34. package/dist/types/components.d.ts +2 -0
  35. package/package.json +1 -1
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-c8609d4f.js');
6
6
  const index$1 = require('./index-88c3cf9c.js');
7
- const formChoiceHelpers = require('./form-choice-helpers-e5394fc2.js');
7
+ const formChoiceHelpers = require('./form-choice-helpers-da1c35a3.js');
8
8
  const readonlyCard = require('./readonly-card-98e9eb94.js');
9
9
  require('./lodash-597bda6d.js');
10
10
  require('./_commonjsHelpers-94df2ea7.js');
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-c8609d4f.js');
6
6
  const index$1 = require('./index-88c3cf9c.js');
7
7
  const commonHelpers = require('./common-helpers-14c8bc18.js');
8
- const formChoiceHelpers = require('./form-choice-helpers-e5394fc2.js');
8
+ const formChoiceHelpers = require('./form-choice-helpers-da1c35a3.js');
9
9
  const readonlyCard = require('./readonly-card-98e9eb94.js');
10
10
  require('./lodash-597bda6d.js');
11
11
  require('./_commonjsHelpers-94df2ea7.js');
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-c8609d4f.js');
6
6
  const index$1 = require('./index-5dbf8f43.js');
7
7
  const index$2 = require('./index-88c3cf9c.js');
8
- const formChoiceHelpers = require('./form-choice-helpers-e5394fc2.js');
8
+ const formChoiceHelpers = require('./form-choice-helpers-da1c35a3.js');
9
9
  const readonlyCard = require('./readonly-card-98e9eb94.js');
10
10
  require('./lodash-597bda6d.js');
11
11
  require('./_commonjsHelpers-94df2ea7.js');
@@ -6,7 +6,7 @@ const index = require('./index-c8609d4f.js');
6
6
  const index$1 = require('./index-88c3cf9c.js');
7
7
  const lodash = require('./lodash-597bda6d.js');
8
8
  const commonHelpers = require('./common-helpers-14c8bc18.js');
9
- const formChoiceHelpers = require('./form-choice-helpers-e5394fc2.js');
9
+ const formChoiceHelpers = require('./form-choice-helpers-da1c35a3.js');
10
10
  require('./_commonjsHelpers-94df2ea7.js');
11
11
  require('./index-5dbf8f43.js');
12
12
  require('./draggable-tags-helpers-bc98fae7.js');
@@ -6,7 +6,7 @@ const index = require('./index-c8609d4f.js');
6
6
  const index$1 = require('./index-88c3cf9c.js');
7
7
  const lodash = require('./lodash-597bda6d.js');
8
8
  const formInputHelpers = require('./form-input-helpers-3c9a5dd1.js');
9
- const formChoiceHelpers = require('./form-choice-helpers-e5394fc2.js');
9
+ const formChoiceHelpers = require('./form-choice-helpers-da1c35a3.js');
10
10
  const readonlyCard = require('./readonly-card-98e9eb94.js');
11
11
  require('./_commonjsHelpers-94df2ea7.js');
12
12
  require('./index-5dbf8f43.js');
@@ -42,6 +42,7 @@ const YooFormInputComponent = class {
42
42
  this.size = 'large';
43
43
  this.initialCheckboxParams = null;
44
44
  this.fireInputChangeEvent = false;
45
+ this.allowDecimals = false;
45
46
  this.checkboxParams = null;
46
47
  this.hostWidth = 0;
47
48
  this.isKeyboardResizeModeInactive = index$1.isKeyboardResizeModeInactive();
@@ -157,6 +158,7 @@ const YooFormInputComponent = class {
157
158
  break;
158
159
  case 'number':
159
160
  this.finalIconPrefix = this.iconPrefix ? this.iconPrefix : 'ranking';
161
+ !this.allowDecimals && this.step == undefined && (this.step = 1);
160
162
  break;
161
163
  case 'password':
162
164
  this.finalIconPrefix = 'password';
@@ -198,7 +200,6 @@ const YooFormInputComponent = class {
198
200
  this.internalPlaceholder = ((_b = this.checkboxParams) === null || _b === void 0 ? void 0 : _b.value) ? null : this.placeholder;
199
201
  this.inputType = this.type;
200
202
  this.setLocalValue(true);
201
- this.inputHasValue = index$1.isPresent(this.value);
202
203
  }
203
204
  disconnectedCallback() {
204
205
  if (index$1.isIOS()) {
@@ -226,30 +227,34 @@ const YooFormInputComponent = class {
226
227
  el.value = this.localValue + '.';
227
228
  }
228
229
  if (!isNumberInput || el.value || ev.data !== '-') {
229
- if (isNumberInput && ['e', '+'].includes(ev.data)) {
230
- el.value = this.value;
231
- }
232
- value = formInputHelpers.convertValueForInputType(el.value, type);
233
- this.wasPreviousKeyPressMinus = ev.data === '-';
234
- this.inputHasValue = value === '' ? false : index$1.isPresent(value);
235
- if (this.maxCharacters) {
236
- if (this.maxCharacters - el.value.length < 0) {
237
- value = value.substring(0, this.maxCharacters);
238
- el.value = value;
239
- this.remainingCharacters = 0;
230
+ if (!(isNumberInput && (el.value.length === 1 && el.value[0] === '-'))) {
231
+ if (isNumberInput && ['e', '+'].includes(ev.data)) {
232
+ el.value = this.value;
240
233
  }
241
- else {
242
- this.remainingCharacters = this.maxCharacters - el.value.length;
234
+ value = formInputHelpers.convertValueForInputType(el.value, type);
235
+ if (this.maxCharacters) {
236
+ if (this.maxCharacters - el.value.length < 0) {
237
+ value = value.substring(0, this.maxCharacters);
238
+ el.value = value;
239
+ this.remainingCharacters = 0;
240
+ }
241
+ else {
242
+ this.remainingCharacters = this.maxCharacters - el.value.length;
243
+ }
243
244
  }
245
+ const skipValueAssignment = !((this.localValue === null && value) || (this.localValue && (!index$1.isNullOrUndefined(value) || value === '')));
246
+ this.emitValueAndSetValidity(value, skipValueAssignment);
247
+ this.localValue = value;
244
248
  }
245
- const skipValueAssignment = !((this.localValue === null && value) || (this.localValue && (!index$1.isNullOrUndefined(value) || value === '')));
246
- this.emitValueAndSetValidity(value, skipValueAssignment);
247
- this.localValue = value;
249
+ }
250
+ if (isNumberInput && (ev.data === '-' || !el.value)) {
251
+ this.wasPreviousKeyPressMinus = ev.data === '-';
248
252
  }
249
253
  }
250
254
  }
251
255
  onKeyPress(ev) {
252
256
  const keycode = ev.keyCode;
257
+ const inputValue = ev.target.value;
253
258
  const BACKSPACE_KEYCODE = 8;
254
259
  if (keycode !== BACKSPACE_KEYCODE && this.maxCharacters && this.remainingCharacters < 1) {
255
260
  ev.preventDefault();
@@ -264,9 +269,9 @@ const YooFormInputComponent = class {
264
269
  if (ev.key === 'Tab') {
265
270
  this.tabPressed.emit(true);
266
271
  }
267
- if (this.type === 'number') {
268
- // prevent decimal point if minimal step is 1
269
- if (this.step && Number.isInteger(this.step) && ev.key === '.') {
272
+ if (this.isNumberInput(this.type)) {
273
+ // prevent decimal point if not allowed
274
+ if (!this.allowDecimals && ev.key === '.') {
270
275
  ev.preventDefault();
271
276
  }
272
277
  const MINUS_KEYCODE = 189;
@@ -276,7 +281,7 @@ const YooFormInputComponent = class {
276
281
  * For example '222-2', as this will return a value of null which leads to validation issues in an
277
282
  * optional field.
278
283
  */
279
- if ((this.inputHasValue || this.wasPreviousKeyPressMinus) && keycode === MINUS_KEYCODE) {
284
+ if ((inputValue || this.wasPreviousKeyPressMinus) && keycode === MINUS_KEYCODE) {
280
285
  ev.preventDefault();
281
286
  }
282
287
  // This only allows the keycodes of numbers 0-9
@@ -328,7 +333,6 @@ const YooFormInputComponent = class {
328
333
  }
329
334
  clearInput() {
330
335
  this.localValue = null;
331
- this.inputHasValue = false;
332
336
  if (this.inputElement) {
333
337
  this.inputElement.value = null;
334
338
  this.updateRemainingCharacters(true);
@@ -342,7 +346,7 @@ const YooFormInputComponent = class {
342
346
  }
343
347
  getPattern() {
344
348
  if (this.isNumberInput(this.inputType)) {
345
- return '[+-]?[0-9]+[,.]?([0-9]+)?';
349
+ return `^([+-]{1})?[0-9]+${this.allowDecimals ? '[,.]?([0-9]+)?' : ''}`;
346
350
  }
347
351
  }
348
352
  isTextInput(inputType) {
@@ -50,13 +50,13 @@ const YooFormMultiInputComponent = class {
50
50
  this.dragAndDropPendingEvent = null;
51
51
  this.dragAndDropPendingEventTimeout = null;
52
52
  this.sortables = [];
53
- this.setValueAndEmitChanges = index$1.debounce((value, skipValueAssignment = false) => {
53
+ this.setValueAndEmitChanges = (value, skipValueAssignment = false) => {
54
54
  if (!skipValueAssignment) {
55
55
  this.value = value;
56
56
  }
57
57
  const finalValue = this.isSimpleArray ? this.value[0] : this.value;
58
58
  formInputHelpers.setValueAndValidateInput(finalValue, this, false, true, true);
59
- }, 500);
59
+ };
60
60
  }
61
61
  async reset(keys) {
62
62
  this.cells = this.getCells();
@@ -422,7 +422,8 @@ const YooFormMultiInputComponent = class {
422
422
  if (this.reverseValueDimensions) {
423
423
  values = this.arrayTransposing(values);
424
424
  }
425
- this.setValueAndEmitChanges(values);
425
+ // use debounce to prevent performance issue while typing
426
+ index$1.debounce(this.setValueAndEmitChanges.bind(this), 500)(values);
426
427
  }
427
428
  onTranslationValueUpdated(ev) {
428
429
  ev.stopPropagation();
@@ -25,11 +25,11 @@ export function onItemSelect(item, choiceElement, preventSetValue = false) {
25
25
  }
26
26
  }
27
27
  export function getColor(value, valuesColor, selection) {
28
- if (valuesColor && value) {
29
- if (!isSelected(value, selection))
30
- return '';
31
- return valuesColor.find(valueColor => valueColor.key === value).value || '';
28
+ var _a;
29
+ if ((valuesColor === null || valuesColor === void 0 ? void 0 : valuesColor.length) && value) {
30
+ return isSelected(value, selection) ? ((_a = valuesColor.find(({ key }) => key === value)) === null || _a === void 0 ? void 0 : _a.value) || '' : '';
32
31
  }
32
+ return '';
33
33
  }
34
34
  export function updateValue(newVal, oldVal, choiceElement, onSelectCall) {
35
35
  if (!isEqual(oldVal, newVal)) {
@@ -1,4 +1,4 @@
1
- import { copyToClipboard, debounce as _debounce, disableKeyboardResize, enableKeyboardResize, extractTextFromStringHTML, isAndroid, isAnimationsDisabled, isHTML, isIOS, isKeyboardResizeModeInactive, isNativeMobile, isNullOrUndefined, isPresent, isSafari, isWeb, resizeObserve, showToast, translate } from '@shared/utils';
1
+ import { copyToClipboard, debounce as _debounce, disableKeyboardResize, enableKeyboardResize, extractTextFromStringHTML, isAndroid, isAnimationsDisabled, isHTML, isIOS, isKeyboardResizeModeInactive, isNativeMobile, isNullOrUndefined, isSafari, isWeb, resizeObserve, showToast, translate } from '@shared/utils';
2
2
  import { Component, Element, Event, h, Host, Method, Prop, State, Watch } from '@stencil/core';
3
3
  import { isFunction, isNumber, isString } from 'lodash-es';
4
4
  import { getAppContext } from '../../../utils/helpers/common-helpers';
@@ -19,6 +19,7 @@ export class YooFormInputComponent {
19
19
  this.size = 'large';
20
20
  this.initialCheckboxParams = null;
21
21
  this.fireInputChangeEvent = false;
22
+ this.allowDecimals = false;
22
23
  this.checkboxParams = null;
23
24
  this.hostWidth = 0;
24
25
  this.isKeyboardResizeModeInactive = isKeyboardResizeModeInactive();
@@ -134,6 +135,7 @@ export class YooFormInputComponent {
134
135
  break;
135
136
  case 'number':
136
137
  this.finalIconPrefix = this.iconPrefix ? this.iconPrefix : 'ranking';
138
+ !this.allowDecimals && this.step == undefined && (this.step = 1);
137
139
  break;
138
140
  case 'password':
139
141
  this.finalIconPrefix = 'password';
@@ -175,7 +177,6 @@ export class YooFormInputComponent {
175
177
  this.internalPlaceholder = ((_b = this.checkboxParams) === null || _b === void 0 ? void 0 : _b.value) ? null : this.placeholder;
176
178
  this.inputType = this.type;
177
179
  this.setLocalValue(true);
178
- this.inputHasValue = isPresent(this.value);
179
180
  }
180
181
  disconnectedCallback() {
181
182
  if (isIOS()) {
@@ -203,30 +204,34 @@ export class YooFormInputComponent {
203
204
  el.value = this.localValue + '.';
204
205
  }
205
206
  if (!isNumberInput || el.value || ev.data !== '-') {
206
- if (isNumberInput && ['e', '+'].includes(ev.data)) {
207
- el.value = this.value;
208
- }
209
- value = convertValueForInputType(el.value, type);
210
- this.wasPreviousKeyPressMinus = ev.data === '-';
211
- this.inputHasValue = value === '' ? false : isPresent(value);
212
- if (this.maxCharacters) {
213
- if (this.maxCharacters - el.value.length < 0) {
214
- value = value.substring(0, this.maxCharacters);
215
- el.value = value;
216
- this.remainingCharacters = 0;
207
+ if (!(isNumberInput && (el.value.length === 1 && el.value[0] === '-'))) {
208
+ if (isNumberInput && ['e', '+'].includes(ev.data)) {
209
+ el.value = this.value;
217
210
  }
218
- else {
219
- this.remainingCharacters = this.maxCharacters - el.value.length;
211
+ value = convertValueForInputType(el.value, type);
212
+ if (this.maxCharacters) {
213
+ if (this.maxCharacters - el.value.length < 0) {
214
+ value = value.substring(0, this.maxCharacters);
215
+ el.value = value;
216
+ this.remainingCharacters = 0;
217
+ }
218
+ else {
219
+ this.remainingCharacters = this.maxCharacters - el.value.length;
220
+ }
220
221
  }
222
+ const skipValueAssignment = !((this.localValue === null && value) || (this.localValue && (!isNullOrUndefined(value) || value === '')));
223
+ this.emitValueAndSetValidity(value, skipValueAssignment);
224
+ this.localValue = value;
221
225
  }
222
- const skipValueAssignment = !((this.localValue === null && value) || (this.localValue && (!isNullOrUndefined(value) || value === '')));
223
- this.emitValueAndSetValidity(value, skipValueAssignment);
224
- this.localValue = value;
226
+ }
227
+ if (isNumberInput && (ev.data === '-' || !el.value)) {
228
+ this.wasPreviousKeyPressMinus = ev.data === '-';
225
229
  }
226
230
  }
227
231
  }
228
232
  onKeyPress(ev) {
229
233
  const keycode = ev.keyCode;
234
+ const inputValue = ev.target.value;
230
235
  const BACKSPACE_KEYCODE = 8;
231
236
  if (keycode !== BACKSPACE_KEYCODE && this.maxCharacters && this.remainingCharacters < 1) {
232
237
  ev.preventDefault();
@@ -241,9 +246,9 @@ export class YooFormInputComponent {
241
246
  if (ev.key === 'Tab') {
242
247
  this.tabPressed.emit(true);
243
248
  }
244
- if (this.type === 'number') {
245
- // prevent decimal point if minimal step is 1
246
- if (this.step && Number.isInteger(this.step) && ev.key === '.') {
249
+ if (this.isNumberInput(this.type)) {
250
+ // prevent decimal point if not allowed
251
+ if (!this.allowDecimals && ev.key === '.') {
247
252
  ev.preventDefault();
248
253
  }
249
254
  const MINUS_KEYCODE = 189;
@@ -253,7 +258,7 @@ export class YooFormInputComponent {
253
258
  * For example '222-2', as this will return a value of null which leads to validation issues in an
254
259
  * optional field.
255
260
  */
256
- if ((this.inputHasValue || this.wasPreviousKeyPressMinus) && keycode === MINUS_KEYCODE) {
261
+ if ((inputValue || this.wasPreviousKeyPressMinus) && keycode === MINUS_KEYCODE) {
257
262
  ev.preventDefault();
258
263
  }
259
264
  // This only allows the keycodes of numbers 0-9
@@ -305,7 +310,6 @@ export class YooFormInputComponent {
305
310
  }
306
311
  clearInput() {
307
312
  this.localValue = null;
308
- this.inputHasValue = false;
309
313
  if (this.inputElement) {
310
314
  this.inputElement.value = null;
311
315
  this.updateRemainingCharacters(true);
@@ -319,7 +323,7 @@ export class YooFormInputComponent {
319
323
  }
320
324
  getPattern() {
321
325
  if (this.isNumberInput(this.inputType)) {
322
- return '[+-]?[0-9]+[,.]?([0-9]+)?';
326
+ return `^([+-]{1})?[0-9]+${this.allowDecimals ? '[,.]?([0-9]+)?' : ''}`;
323
327
  }
324
328
  }
325
329
  isTextInput(inputType) {
@@ -1278,6 +1282,24 @@ export class YooFormInputComponent {
1278
1282
  "attribute": "fire-input-change-event",
1279
1283
  "reflect": false,
1280
1284
  "defaultValue": "false"
1285
+ },
1286
+ "allowDecimals": {
1287
+ "type": "boolean",
1288
+ "mutable": false,
1289
+ "complexType": {
1290
+ "original": "boolean",
1291
+ "resolved": "boolean",
1292
+ "references": {}
1293
+ },
1294
+ "required": false,
1295
+ "optional": false,
1296
+ "docs": {
1297
+ "tags": [],
1298
+ "text": ""
1299
+ },
1300
+ "attribute": "allow-decimals",
1301
+ "reflect": false,
1302
+ "defaultValue": "false"
1281
1303
  }
1282
1304
  }; }
1283
1305
  static get states() { return {
@@ -31,13 +31,13 @@ export class YooFormMultiInputComponent {
31
31
  this.dragAndDropPendingEvent = null;
32
32
  this.dragAndDropPendingEventTimeout = null;
33
33
  this.sortables = [];
34
- this.setValueAndEmitChanges = debounce((value, skipValueAssignment = false) => {
34
+ this.setValueAndEmitChanges = (value, skipValueAssignment = false) => {
35
35
  if (!skipValueAssignment) {
36
36
  this.value = value;
37
37
  }
38
38
  const finalValue = this.isSimpleArray ? this.value[0] : this.value;
39
39
  setValueAndValidateInput(finalValue, this, false, true, true);
40
- }, 500);
40
+ };
41
41
  }
42
42
  async reset(keys) {
43
43
  this.cells = this.getCells();
@@ -403,7 +403,8 @@ export class YooFormMultiInputComponent {
403
403
  if (this.reverseValueDimensions) {
404
404
  values = this.arrayTransposing(values);
405
405
  }
406
- this.setValueAndEmitChanges(values);
406
+ // use debounce to prevent performance issue while typing
407
+ debounce(this.setValueAndEmitChanges.bind(this), 500)(values);
407
408
  }
408
409
  onTranslationValueUpdated(ev) {
409
410
  ev.stopPropagation();