@lion/ui 0.0.4 → 0.0.6
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.
- package/components/calendar/src/LionCalendar.js +10 -4
- package/components/combobox/src/LionCombobox.js +6 -4
- package/components/core/src/DisabledMixin.js +6 -4
- package/components/core/src/DisabledWithTabIndexMixin.js +6 -4
- package/components/core/src/SlotMixin.js +2 -1
- package/components/core/test/SlotMixin.test.js +11 -0
- package/components/core/types/SlotMixinTypes.ts +1 -1
- package/components/form-core/src/FormatMixin.js +10 -8
- package/components/form-core/src/InteractionStateMixin.js +8 -6
- package/components/form-core/src/choice-group/ChoiceInputMixin.js +6 -4
- package/components/form-core/src/utils/SyncUpdatableMixin.js +9 -4
- package/components/form-core/test/utils/SyncUpdatableMixin.test.js +6 -4
- package/components/form-core/test-suites/ValidateMixin.suite.js +1 -1
- package/components/form-core/test-suites/form-group/FormGroupMixin.suite.js +2 -2
- package/components/input/src/LionInput.js +6 -4
- package/components/input-datepicker/src/LionInputDatepicker.js +6 -4
- package/components/input-tel/src/LionInputTel.js +7 -13
- package/components/input-tel/src/PhoneUtilManager.js +9 -5
- package/components/input-tel/src/formatters.js +8 -10
- package/components/input-tel/src/parsers.js +3 -4
- package/components/input-tel/src/preprocessors.js +2 -4
- package/components/input-tel/src/validators.js +4 -6
- package/components/input-tel/test/validators.test.js +8 -5
- package/components/input-tel-dropdown/src/LionInputTelDropdown.js +14 -8
- package/components/listbox/src/LionOption.js +6 -4
- package/components/overlays/src/OverlayMixin.js +6 -5
- package/components/overlays/src/OverlaysManager.js +21 -4
- package/components/overlays/src/globalOverlaysStyle.js +10 -0
- package/components/overlays/test/OverlaysManager.test.js +76 -0
- package/components/overlays/test-suites/OverlayMixin.suite.js +20 -14
- package/components/select-rich/src/LionSelectRich.js +6 -4
- package/components/switch/src/LionSwitchButton.js +6 -7
- package/custom-elements.json +568 -159
- package/dist-types/components/accordion/src/LionAccordion.d.ts +1 -1
- package/dist-types/components/button/src/LionButton.d.ts +1 -1
- package/dist-types/components/calendar/src/LionCalendar.d.ts +6 -4
- package/dist-types/components/calendar/src/LionCalendar.d.ts.map +1 -1
- package/dist-types/components/checkbox-group/src/LionCheckboxGroup.d.ts +1 -1
- package/dist-types/components/checkbox-group/src/LionCheckboxIndeterminate.d.ts +0 -4
- package/dist-types/components/checkbox-group/src/LionCheckboxIndeterminate.d.ts.map +1 -1
- package/dist-types/components/collapsible/src/LionCollapsible.d.ts +1 -1
- package/dist-types/components/combobox/src/LionCombobox.d.ts +5 -3
- package/dist-types/components/combobox/src/LionCombobox.d.ts.map +1 -1
- package/dist-types/components/core/src/DisabledMixin.d.ts.map +1 -1
- package/dist-types/components/core/src/DisabledWithTabIndexMixin.d.ts.map +1 -1
- package/dist-types/components/core/src/SlotMixin.d.ts +1 -1
- package/dist-types/components/core/src/SlotMixin.d.ts.map +1 -1
- package/dist-types/components/core/types/SlotMixinTypes.d.ts +1 -1
- package/dist-types/components/core/types/SlotMixinTypes.d.ts.map +1 -1
- package/dist-types/components/dialog/src/LionDialog.d.ts +1 -1
- package/dist-types/components/fieldset/src/LionFieldset.d.ts +1 -1
- package/dist-types/components/form-core/src/FormatMixin.d.ts.map +1 -1
- package/dist-types/components/form-core/src/InteractionStateMixin.d.ts.map +1 -1
- package/dist-types/components/form-core/src/LionField.d.ts +1 -1
- package/dist-types/components/form-core/src/choice-group/ChoiceInputMixin.d.ts.map +1 -1
- package/dist-types/components/form-core/src/utils/SyncUpdatableMixin.d.ts.map +1 -1
- package/dist-types/components/form-core/src/validate/LionValidationFeedback.d.ts +1 -1
- package/dist-types/components/form-core/test-suites/FormRegistrationMixins.suite.d.ts +1 -1
- package/dist-types/components/form-integrations/test/helpers/umbrella-form.d.ts +1 -1
- package/dist-types/components/helpers/src/SbActionLogger.d.ts +1 -1
- package/dist-types/components/helpers/src/SbLocaleSwitcher.d.ts +1 -1
- package/dist-types/components/icon/src/LionIcon.d.ts +1 -1
- package/dist-types/components/input/src/LionInput.d.ts +5 -3
- package/dist-types/components/input/src/LionInput.d.ts.map +1 -1
- package/dist-types/components/input-datepicker/src/LionCalendarOverlayFrame.d.ts +1 -1
- package/dist-types/components/input-datepicker/src/LionInputDatepicker.d.ts +0 -5
- package/dist-types/components/input-datepicker/src/LionInputDatepicker.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/LionInputTel.d.ts +3 -22
- package/dist-types/components/input-tel/src/LionInputTel.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/PhoneUtilManager.d.ts +8 -4
- package/dist-types/components/input-tel/src/PhoneUtilManager.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/formatters.d.ts +0 -2
- package/dist-types/components/input-tel/src/formatters.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/parsers.d.ts +0 -2
- package/dist-types/components/input-tel/src/parsers.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/preprocessors.d.ts +0 -2
- package/dist-types/components/input-tel/src/preprocessors.d.ts.map +1 -1
- package/dist-types/components/input-tel/src/validators.d.ts +0 -1
- package/dist-types/components/input-tel/src/validators.d.ts.map +1 -1
- package/dist-types/components/input-tel/test/validators.test.d.ts +1 -1
- package/dist-types/components/input-tel/test/validators.test.d.ts.map +1 -1
- package/dist-types/components/input-tel-dropdown/src/LionInputTelDropdown.d.ts +7 -9
- package/dist-types/components/input-tel-dropdown/src/LionInputTelDropdown.d.ts.map +1 -1
- package/dist-types/components/listbox/src/LionListbox.d.ts +1 -1
- package/dist-types/components/listbox/src/LionOption.d.ts +6 -4
- package/dist-types/components/listbox/src/LionOption.d.ts.map +1 -1
- package/dist-types/components/listbox/src/LionOptions.d.ts +1 -1
- package/dist-types/components/overlays/src/OverlayMixin.d.ts.map +1 -1
- package/dist-types/components/overlays/src/OverlaysManager.d.ts +4 -0
- package/dist-types/components/overlays/src/OverlaysManager.d.ts.map +1 -1
- package/dist-types/components/overlays/src/globalOverlaysStyle.d.ts.map +1 -1
- package/dist-types/components/overlays/test/OverlaysManager.test.d.ts.map +1 -1
- package/dist-types/components/overlays/test-suites/OverlayMixin.suite.d.ts.map +1 -1
- package/dist-types/components/pagination/src/LionPagination.d.ts +1 -1
- package/dist-types/components/progress-indicator/src/LionProgressIndicator.d.ts +1 -1
- package/dist-types/components/radio-group/src/LionRadioGroup.d.ts +1 -1
- package/dist-types/components/select-rich/src/LionSelectRich.d.ts +5 -3
- package/dist-types/components/select-rich/src/LionSelectRich.d.ts.map +1 -1
- package/dist-types/components/steps/src/LionStep.d.ts +1 -1
- package/dist-types/components/steps/src/LionSteps.d.ts +1 -1
- package/dist-types/components/switch/src/LionSwitchButton.d.ts +6 -7
- package/dist-types/components/switch/src/LionSwitchButton.d.ts.map +1 -1
- package/dist-types/components/tabs/src/LionTabs.d.ts +1 -1
- package/dist-types/components/tooltip/src/LionTooltip.d.ts +1 -1
- package/dist-types/exports/core.d.ts +0 -1
- package/dist-types/exports/core.d.ts.map +1 -1
- package/dist-types/exports/form-core.d.ts +0 -2
- package/dist-types/exports/form-core.d.ts.map +1 -1
- package/dist-types/exports/input-tel-dropdown.d.ts +0 -2
- package/dist-types/exports/input-tel-dropdown.d.ts.map +1 -1
- package/dist-types/exports/input-tel.d.ts +0 -1
- package/dist-types/exports/input-tel.d.ts.map +1 -1
- package/dist-types/exports/localize.d.ts +0 -3
- package/dist-types/exports/localize.d.ts.map +1 -1
- package/dist-types/exports/overlays.d.ts +0 -4
- package/dist-types/exports/overlays.d.ts.map +1 -1
- package/dist-types/exports/types/core.d.ts +2 -0
- package/dist-types/exports/types/core.d.ts.map +1 -0
- package/dist-types/exports/types/form-core.d.ts +3 -0
- package/dist-types/exports/types/form-core.d.ts.map +1 -0
- package/dist-types/exports/types/input-tel-dropdown.d.ts +3 -0
- package/dist-types/exports/types/input-tel-dropdown.d.ts.map +1 -0
- package/dist-types/exports/types/input-tel.d.ts +2 -0
- package/dist-types/exports/types/input-tel.d.ts.map +1 -0
- package/dist-types/exports/types/localize.d.ts +4 -0
- package/dist-types/exports/types/localize.d.ts.map +1 -0
- package/dist-types/exports/types/overlays.d.ts +5 -0
- package/dist-types/exports/types/overlays.d.ts.map +1 -0
- package/dist-types/tsconfig.tsbuildinfo +1 -1
- package/docs/components/checkbox-group/overview.md +2 -2
- package/docs/components/collapsible/overview.md +1 -1
- package/docs/components/combobox/overview.md +1 -1
- package/docs/components/combobox/use-cases.md +1 -1
- package/docs/components/dialog/overview.md +1 -1
- package/docs/components/fieldset/overview.md +5 -5
- package/docs/components/form/overview.md +3 -3
- package/docs/components/icon/use-cases.md +1 -1
- package/docs/components/input/overview.md +1 -1
- package/docs/components/input-amount/overview.md +3 -3
- package/docs/components/input-date/overview.md +3 -3
- package/docs/components/input-datepicker/overview.md +5 -5
- package/docs/components/input-email/overview.md +2 -2
- package/docs/components/input-iban/overview.md +2 -2
- package/docs/components/input-range/overview.md +2 -2
- package/docs/components/input-stepper/overview.md +1 -1
- package/docs/components/input-tel/overview.md +1 -1
- package/docs/components/input-tel/use-cases.md +6 -6
- package/docs/components/input-tel-dropdown/overview.md +1 -1
- package/docs/components/radio-group/overview.md +3 -3
- package/docs/components/select-rich/use-cases.md +1 -1
- package/docs/components/tabs/examples.md +1 -1
- package/docs/fundamentals/index.md +4 -4
- package/docs/fundamentals/node-tools/providence-analytics/LocalConfiguration.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/QueryResult.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/analyzer.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/dashboard.md +1 -1
- package/docs/fundamentals/node-tools/providence-analytics/overview.md +3 -3
- package/docs/fundamentals/node-tools/publish-docs/overview.md +3 -3
- package/docs/fundamentals/node-tools/rocket-preset-extend-lion-docs/overview.md +2 -2
- package/docs/fundamentals/systems/core/overview.md +1 -1
- package/docs/fundamentals/systems/form/formatting-and-parsing.md +4 -4
- package/docs/fundamentals/systems/form/model-value.md +1 -1
- package/docs/fundamentals/systems/form/overview.md +28 -28
- package/docs/fundamentals/systems/form/validate.md +1 -1
- package/docs/fundamentals/systems/localize/overview.md +4 -4
- package/docs/fundamentals/systems/overlays/configuration.md +2 -2
- package/docs/fundamentals/systems/overlays/overview.md +5 -5
- package/docs/fundamentals/systems/overlays/use-cases.md +2 -2
- package/docs/fundamentals/tools/helpers/overview.md +1 -1
- package/docs/fundamentals/tools/singleton-manager/overview.md +4 -4
- package/docs/guides/how-to/create-a-custom-field.md +5 -5
- package/docs/guides/how-to/extend-a-native-input.md +2 -2
- package/docs/guides/index.md +8 -8
- package/docs/guides/principles/index.md +5 -5
- package/docs/guides/principles/styling.md +1 -1
- package/exports/core.js +0 -2
- package/exports/form-core.js +0 -3
- package/exports/input-tel-dropdown.js +0 -3
- package/exports/input-tel.js +0 -2
- package/exports/localize.js +0 -4
- package/exports/overlays.js +0 -5
- package/exports/types/core.ts +1 -0
- package/exports/types/form-core.ts +2 -0
- package/exports/types/input-tel-dropdown.ts +2 -0
- package/exports/types/input-tel.ts +1 -0
- package/exports/types/localize.ts +3 -0
- package/exports/types/overlays.ts +4 -0
- package/package.json +6 -4
|
@@ -317,11 +317,17 @@ export class LionCalendar extends LocalizeMixin(LitElement) {
|
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
/**
|
|
320
|
-
* @param {string} name
|
|
321
|
-
* @param {
|
|
320
|
+
* @param {string} [name]
|
|
321
|
+
* @param {unknown} [oldValue]
|
|
322
|
+
* @param {import('lit').PropertyDeclaration} [options]
|
|
323
|
+
* @returns {void}
|
|
322
324
|
*/
|
|
323
|
-
requestUpdate(name, oldValue) {
|
|
324
|
-
super.requestUpdate(name, oldValue);
|
|
325
|
+
requestUpdate(name, oldValue, options) {
|
|
326
|
+
super.requestUpdate(name, oldValue, options);
|
|
327
|
+
|
|
328
|
+
if (name === undefined) {
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
325
331
|
|
|
326
332
|
const map = {
|
|
327
333
|
disableDates: () => this.__disableDatesChanged(),
|
|
@@ -378,11 +378,13 @@ export class LionCombobox extends OverlayMixin(LionListbox) {
|
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
/**
|
|
381
|
-
* @param {
|
|
382
|
-
* @param {unknown} oldValue
|
|
381
|
+
* @param {string} [name]
|
|
382
|
+
* @param {unknown} [oldValue]
|
|
383
|
+
* @param {import('lit').PropertyDeclaration} [options]
|
|
384
|
+
* @returns {void}
|
|
383
385
|
*/
|
|
384
|
-
requestUpdate(name, oldValue) {
|
|
385
|
-
super.requestUpdate(name, oldValue);
|
|
386
|
+
requestUpdate(name, oldValue, options) {
|
|
387
|
+
super.requestUpdate(name, oldValue, options);
|
|
386
388
|
if (name === 'disabled' || name === 'readOnly') {
|
|
387
389
|
this.__setComboboxDisabledAndReadOnly();
|
|
388
390
|
}
|
|
@@ -58,11 +58,13 @@ const DisabledMixinImplementation = superclass =>
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
61
|
-
* @param {
|
|
62
|
-
* @param {
|
|
61
|
+
* @param {string} [name]
|
|
62
|
+
* @param {unknown} [oldValue]
|
|
63
|
+
* @param {import('lit').PropertyDeclaration} [options]
|
|
64
|
+
* @returns {void}
|
|
63
65
|
*/
|
|
64
|
-
requestUpdate(name, oldValue) {
|
|
65
|
-
super.requestUpdate(name, oldValue);
|
|
66
|
+
requestUpdate(name, oldValue, options) {
|
|
67
|
+
super.requestUpdate(name, oldValue, options);
|
|
66
68
|
if (name === 'disabled') {
|
|
67
69
|
if (this.__isUserSettingDisabled) {
|
|
68
70
|
this.__restoreDisabledTo = this.disabled;
|
|
@@ -60,11 +60,13 @@ const DisabledWithTabIndexMixinImplementation = superclass =>
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
* @param {
|
|
64
|
-
* @param {
|
|
63
|
+
* @param {string} [name]
|
|
64
|
+
* @param {unknown} [oldValue]
|
|
65
|
+
* @param {import('lit').PropertyDeclaration} [options]
|
|
66
|
+
* @returns {void}
|
|
65
67
|
*/
|
|
66
|
-
requestUpdate(name, oldValue) {
|
|
67
|
-
super.requestUpdate(name, oldValue);
|
|
68
|
+
requestUpdate(name, oldValue, options) {
|
|
69
|
+
super.requestUpdate(name, oldValue, options);
|
|
68
70
|
|
|
69
71
|
if (name === 'disabled') {
|
|
70
72
|
if (this.disabled) {
|
|
@@ -173,7 +173,8 @@ const SlotMixinImplementation = superclass =>
|
|
|
173
173
|
const slotFunctionResult = this.slots[slotName]();
|
|
174
174
|
// Allow to conditionally return a slot
|
|
175
175
|
if (slotFunctionResult === undefined) {
|
|
176
|
-
|
|
176
|
+
// eslint-disable-next-line no-continue
|
|
177
|
+
continue;
|
|
177
178
|
}
|
|
178
179
|
|
|
179
180
|
if (!this.__isConnectedSlotMixin) {
|
|
@@ -81,12 +81,20 @@ describe('SlotMixin', () => {
|
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
it('does not override user provided slots', async () => {
|
|
84
|
+
const shouldReturn = false;
|
|
84
85
|
const tag = defineCE(
|
|
85
86
|
class extends SlotMixin(LitElement) {
|
|
86
87
|
get slots() {
|
|
87
88
|
return {
|
|
88
89
|
...super.slots,
|
|
89
90
|
feedback: () => document.createElement('div'),
|
|
91
|
+
'more-feedback': () => {
|
|
92
|
+
if (shouldReturn) {
|
|
93
|
+
return document.createElement('div');
|
|
94
|
+
}
|
|
95
|
+
return undefined;
|
|
96
|
+
},
|
|
97
|
+
'even-more-feedback': () => document.createElement('div'),
|
|
90
98
|
};
|
|
91
99
|
}
|
|
92
100
|
},
|
|
@@ -94,6 +102,9 @@ describe('SlotMixin', () => {
|
|
|
94
102
|
const el = await fixture(`<${tag}><p slot="feedback">user-content</p></${tag}>`);
|
|
95
103
|
expect(el.children[0].tagName).to.equal('P');
|
|
96
104
|
expect(/** @type HTMLParagraphElement */ (el.children[0]).innerText).to.equal('user-content');
|
|
105
|
+
|
|
106
|
+
expect(el.children[1].tagName).to.equal('DIV');
|
|
107
|
+
expect(/** @type HTMLParagraphElement */ (el.children[1]).slot).to.equal('even-more-feedback');
|
|
97
108
|
});
|
|
98
109
|
|
|
99
110
|
it('does add when user provided slots are not direct children', async () => {
|
|
@@ -60,7 +60,7 @@ export declare class SlotHost {
|
|
|
60
60
|
* };
|
|
61
61
|
* }
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
declare function SlotMixinImplementation<T extends Constructor<LitElement>>(
|
|
64
64
|
superclass: T,
|
|
65
65
|
): T &
|
|
66
66
|
Constructor<SlotHost> &
|
|
@@ -70,19 +70,21 @@ const FormatMixinImplementation = superclass =>
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
* @param {string} name
|
|
74
|
-
* @param {
|
|
73
|
+
* @param {string} [name]
|
|
74
|
+
* @param {unknown} [oldValue]
|
|
75
|
+
* @param {import('lit').PropertyDeclaration} [options]
|
|
76
|
+
* @returns {void}
|
|
75
77
|
*/
|
|
76
|
-
requestUpdate(name,
|
|
77
|
-
super.requestUpdate(name,
|
|
78
|
+
requestUpdate(name, oldValue, options) {
|
|
79
|
+
super.requestUpdate(name, oldValue, options);
|
|
78
80
|
|
|
79
|
-
if (name === 'modelValue' && this.modelValue !==
|
|
80
|
-
this._onModelValueChanged({ modelValue: this.modelValue }, { modelValue:
|
|
81
|
+
if (name === 'modelValue' && this.modelValue !== oldValue) {
|
|
82
|
+
this._onModelValueChanged({ modelValue: this.modelValue }, { modelValue: oldValue });
|
|
81
83
|
}
|
|
82
|
-
if (name === 'serializedValue' && this.serializedValue !==
|
|
84
|
+
if (name === 'serializedValue' && this.serializedValue !== oldValue) {
|
|
83
85
|
this._calculateValues({ source: 'serialized' });
|
|
84
86
|
}
|
|
85
|
-
if (name === 'formattedValue' && this.formattedValue !==
|
|
87
|
+
if (name === 'formattedValue' && this.formattedValue !== oldValue) {
|
|
86
88
|
this._calculateValues({ source: 'formatted' });
|
|
87
89
|
}
|
|
88
90
|
}
|
|
@@ -33,12 +33,14 @@ const InteractionStateMixinImplementation = superclass =>
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* @param {
|
|
37
|
-
* @param {
|
|
36
|
+
* @param {string} [name]
|
|
37
|
+
* @param {unknown} [oldValue]
|
|
38
|
+
* @param {import('lit').PropertyDeclaration} [options]
|
|
39
|
+
* @returns {void}
|
|
38
40
|
*/
|
|
39
|
-
requestUpdate(name,
|
|
40
|
-
super.requestUpdate(name,
|
|
41
|
-
if (name === 'touched' && this.touched !==
|
|
41
|
+
requestUpdate(name, oldValue, options) {
|
|
42
|
+
super.requestUpdate(name, oldValue, options);
|
|
43
|
+
if (name === 'touched' && this.touched !== oldValue) {
|
|
42
44
|
this._onTouchedChanged();
|
|
43
45
|
}
|
|
44
46
|
|
|
@@ -48,7 +50,7 @@ const InteractionStateMixinImplementation = superclass =>
|
|
|
48
50
|
this.filled = !this._isEmpty();
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
if (name === 'dirty' && this.dirty !==
|
|
53
|
+
if (name === 'dirty' && this.dirty !== oldValue) {
|
|
52
54
|
this._onDirtyChanged();
|
|
53
55
|
}
|
|
54
56
|
}
|
|
@@ -52,11 +52,13 @@ const ChoiceInputMixinImplementation = superclass =>
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
|
-
* @param {string} name
|
|
56
|
-
* @param {
|
|
55
|
+
* @param {string} [name]
|
|
56
|
+
* @param {unknown} [oldValue]
|
|
57
|
+
* @param {import('lit').PropertyDeclaration} [options]
|
|
58
|
+
* @returns {void}
|
|
57
59
|
*/
|
|
58
|
-
requestUpdate(name, oldValue) {
|
|
59
|
-
super.requestUpdate(name, oldValue);
|
|
60
|
+
requestUpdate(name, oldValue, options) {
|
|
61
|
+
super.requestUpdate(name, oldValue, options);
|
|
60
62
|
|
|
61
63
|
if (name === 'modelValue') {
|
|
62
64
|
if (this.modelValue.checked !== this.checked) {
|
|
@@ -93,11 +93,16 @@ const SyncUpdatableMixinImplementation = superclass =>
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
/**
|
|
96
|
-
* @param {string} name
|
|
97
|
-
* @param {
|
|
96
|
+
* @param {string} [name]
|
|
97
|
+
* @param {unknown} [oldValue]
|
|
98
|
+
* @param {import('lit').PropertyDeclaration} [options]
|
|
99
|
+
* @returns {void}
|
|
98
100
|
*/
|
|
99
|
-
requestUpdate(name, oldValue) {
|
|
100
|
-
super.requestUpdate(name, oldValue);
|
|
101
|
+
requestUpdate(name, oldValue, options) {
|
|
102
|
+
super.requestUpdate(name, oldValue, options);
|
|
103
|
+
if (name === undefined) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
101
106
|
|
|
102
107
|
this.__SyncUpdatableNamespace = this.__SyncUpdatableNamespace || {};
|
|
103
108
|
const ns = this.__SyncUpdatableNamespace;
|
|
@@ -147,11 +147,13 @@ describe('SyncUpdatableMixin', () => {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
/**
|
|
150
|
-
* @param {string} name
|
|
151
|
-
* @param {
|
|
150
|
+
* @param {string} [name]
|
|
151
|
+
* @param {unknown} [oldValue]
|
|
152
|
+
* @param {import('lit').PropertyDeclaration} [options]
|
|
153
|
+
* @returns {void}
|
|
152
154
|
*/
|
|
153
|
-
requestUpdate(name, oldValue) {
|
|
154
|
-
super.requestUpdate(name, oldValue);
|
|
155
|
+
requestUpdate(name, oldValue, options) {
|
|
156
|
+
super.requestUpdate(name, oldValue, options);
|
|
155
157
|
if (name === 'prop') {
|
|
156
158
|
propChangedCount += 1;
|
|
157
159
|
}
|
|
@@ -64,7 +64,7 @@ export function runValidateMixinSuite(customConfig) {
|
|
|
64
64
|
* - *feedback-node*
|
|
65
65
|
* The 'this._feedbackNode' property (usually a getter) that returns/contains a reference to
|
|
66
66
|
* the output container for validation feedback. Messages will be written to this element
|
|
67
|
-
* based on user
|
|
67
|
+
* based on user-defined or default validity feedback visibility conditions.
|
|
68
68
|
*
|
|
69
69
|
* - *show-{type}-feedback-condition*
|
|
70
70
|
* The 'this.hasErrorVisible value that stores whether the
|
|
@@ -1234,7 +1234,7 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
1234
1234
|
</${tag}>
|
|
1235
1235
|
`)
|
|
1236
1236
|
);
|
|
1237
|
-
const childFieldsetEl = el.querySelector(tagString);
|
|
1237
|
+
const childFieldsetEl = /** @type {FormGroup} */ (el.querySelector(tagString));
|
|
1238
1238
|
const resetGroupSpy = sinon.spy(childFieldsetEl, 'resetGroup');
|
|
1239
1239
|
el.resetGroup();
|
|
1240
1240
|
expect(resetGroupSpy.callCount).to.equal(1);
|
|
@@ -1270,7 +1270,7 @@ export function runFormGroupMixinSuite(cfg = {}) {
|
|
|
1270
1270
|
</${tag}>
|
|
1271
1271
|
`)
|
|
1272
1272
|
);
|
|
1273
|
-
const childFieldsetEl = el.querySelector(tagString);
|
|
1273
|
+
const childFieldsetEl = /** @type {FormGroup} */ (el.querySelector(tagString));
|
|
1274
1274
|
const clearGroupSpy = sinon.spy(childFieldsetEl, 'clearGroup');
|
|
1275
1275
|
el.clearGroup();
|
|
1276
1276
|
expect(clearGroupSpy.callCount).to.equal(1);
|
|
@@ -64,11 +64,13 @@ export class LionInput extends NativeTextFieldMixin(LionField) {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
* @param {
|
|
68
|
-
* @param {
|
|
67
|
+
* @param {string} [name]
|
|
68
|
+
* @param {unknown} [oldValue]
|
|
69
|
+
* @param {import('lit').PropertyDeclaration} [options]
|
|
70
|
+
* @returns {void}
|
|
69
71
|
*/
|
|
70
|
-
requestUpdate(name, oldValue) {
|
|
71
|
-
super.requestUpdate(name, oldValue);
|
|
72
|
+
requestUpdate(name, oldValue, options) {
|
|
73
|
+
super.requestUpdate(name, oldValue, options);
|
|
72
74
|
if (name === 'readOnly') {
|
|
73
75
|
this.__delegateReadOnly();
|
|
74
76
|
}
|
|
@@ -211,11 +211,13 @@ export class LionInputDatepicker extends ScopedElementsMixin(
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
/**
|
|
214
|
-
* @param {
|
|
215
|
-
* @param {
|
|
214
|
+
* @param {string} [name]
|
|
215
|
+
* @param {unknown} [oldValue]
|
|
216
|
+
* @param {import('lit').PropertyDeclaration} [options]
|
|
217
|
+
* @returns {void}
|
|
216
218
|
*/
|
|
217
|
-
requestUpdate(name, oldValue) {
|
|
218
|
-
super.requestUpdate(name, oldValue);
|
|
219
|
+
requestUpdate(name, oldValue, options) {
|
|
220
|
+
super.requestUpdate(name, oldValue, options);
|
|
219
221
|
|
|
220
222
|
if (name === 'disabled' || name === 'readOnly') {
|
|
221
223
|
this.__toggleInvokerDisabled();
|
|
@@ -14,7 +14,7 @@ import { localizeNamespaceLoader } from './localizeNamespaceLoader.js';
|
|
|
14
14
|
* @typedef {import('awesome-phonenumber').PhoneNumberFormat} PhoneNumberFormat
|
|
15
15
|
* @typedef {import('awesome-phonenumber').PhoneNumberTypes} PhoneNumberTypes
|
|
16
16
|
* @typedef {import('../../form-core/types/FormatMixinTypes.js').FormatOptions} FormatOptions
|
|
17
|
-
* @typedef {* & import('awesome-phonenumber')
|
|
17
|
+
* @typedef {* & import('awesome-phonenumber')} AwesomePhoneNumber
|
|
18
18
|
* @typedef {FormatOptions & {regionCode: RegionCode; formatStrategy: PhoneNumberFormat; formatCountryCodeStyle: string;}} FormatOptionsTel
|
|
19
19
|
*/
|
|
20
20
|
|
|
@@ -28,7 +28,6 @@ export class LionInputTel extends LocalizeMixin(LionInput) {
|
|
|
28
28
|
formatCountryCodeStyle: { type: String, attribute: 'format-country-code-style' },
|
|
29
29
|
activeRegion: { type: String },
|
|
30
30
|
_phoneUtil: { type: Object, state: true },
|
|
31
|
-
_needsLightDomRender: { type: Number, state: true },
|
|
32
31
|
};
|
|
33
32
|
|
|
34
33
|
static localizeNamespaces = [
|
|
@@ -72,10 +71,12 @@ export class LionInputTel extends LocalizeMixin(LionInput) {
|
|
|
72
71
|
get activePhoneNumberType() {
|
|
73
72
|
let pn;
|
|
74
73
|
try {
|
|
75
|
-
pn =
|
|
74
|
+
pn =
|
|
75
|
+
this._phoneUtil &&
|
|
76
|
+
this._phoneUtil.parsePhoneNumber(this.modelValue, { regionCode: this.activeRegion });
|
|
76
77
|
// eslint-disable-next-line no-empty
|
|
77
78
|
} catch (_) {}
|
|
78
|
-
return pn?.
|
|
79
|
+
return pn?.type || 'unknown';
|
|
79
80
|
}
|
|
80
81
|
|
|
81
82
|
// @ts-ignore read only
|
|
@@ -169,14 +170,6 @@ export class LionInputTel extends LocalizeMixin(LionInput) {
|
|
|
169
170
|
? /** @type {AwesomePhoneNumber} */ (PhoneUtilManager.PhoneUtil)
|
|
170
171
|
: null;
|
|
171
172
|
|
|
172
|
-
/**
|
|
173
|
-
* Helper that triggers a light dom render aligned with update loop.
|
|
174
|
-
* TODO: combine with render fn of SlotMixin
|
|
175
|
-
* @protected
|
|
176
|
-
* @type {number}
|
|
177
|
-
*/
|
|
178
|
-
this._needsLightDomRender = 0;
|
|
179
|
-
|
|
180
173
|
if (!PhoneUtilManager.isLoaded) {
|
|
181
174
|
PhoneUtilManager.loadComplete.then(() => {
|
|
182
175
|
this._onPhoneNumberUtilReady();
|
|
@@ -325,7 +318,8 @@ export class LionInputTel extends LocalizeMixin(LionInput) {
|
|
|
325
318
|
const value = !(this.modelValue instanceof Unparseable)
|
|
326
319
|
? this.modelValue
|
|
327
320
|
: this.value.match(regex)?.join('');
|
|
328
|
-
const regionDerivedFromValue =
|
|
321
|
+
const regionDerivedFromValue =
|
|
322
|
+
value && this._phoneUtil && this._phoneUtil.parsePhoneNumber(value).regionCode;
|
|
329
323
|
|
|
330
324
|
if (regionDerivedFromValue && this._allowedOrAllRegions.includes(regionDerivedFromValue)) {
|
|
331
325
|
this._setActiveRegion(regionDerivedFromValue);
|
|
@@ -2,21 +2,25 @@
|
|
|
2
2
|
let resolveLoaded;
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* @typedef {* & import('awesome-phonenumber')} AwesomePhoneNumber
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* - Handles lazy loading of the awesome-phonenumber library (relatively large, but way lighter than google-libphonenumber), allowing
|
|
6
10
|
* for quick first paints
|
|
7
11
|
* - Maintains one instance of phoneNumberUtil that can be shared across multiple places
|
|
8
12
|
* - Allows for easy mocking in unit tests
|
|
9
13
|
*/
|
|
10
14
|
export class PhoneUtilManager {
|
|
11
15
|
static async loadLibPhoneNumber() {
|
|
12
|
-
const PhoneUtil = (await import('awesome-phonenumber'))
|
|
13
|
-
this.PhoneUtil = PhoneUtil;
|
|
16
|
+
const PhoneUtil = /** @type {AwesomePhoneNumber} */ (await import('awesome-phonenumber'));
|
|
17
|
+
this.PhoneUtil = { ...PhoneUtil };
|
|
14
18
|
resolveLoaded(undefined);
|
|
15
19
|
return PhoneUtil;
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
/**
|
|
19
|
-
* Check if
|
|
23
|
+
* Check if awesome-phonenumber has been loaded
|
|
20
24
|
*/
|
|
21
25
|
static get isLoaded() {
|
|
22
26
|
return Boolean(this.PhoneUtil);
|
|
@@ -24,7 +28,7 @@ export class PhoneUtilManager {
|
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
/**
|
|
27
|
-
* Wait till
|
|
31
|
+
* Wait till awesome-phonenumber has been loaded
|
|
28
32
|
* @example
|
|
29
33
|
* ```js
|
|
30
34
|
* await PhoneUtilManager.loadComplete;
|
|
@@ -3,7 +3,6 @@ import { PhoneUtilManager } from './PhoneUtilManager.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {import('awesome-phonenumber').PhoneNumberFormat} PhoneNumberFormat
|
|
5
5
|
* @typedef {import('../types/index.js').RegionCode} RegionCode
|
|
6
|
-
* @typedef {* & import('awesome-phonenumber').default} AwesomePhoneNumber
|
|
7
6
|
*/
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -42,33 +41,32 @@ export function formatPhoneNumber(
|
|
|
42
41
|
return modelValue;
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
|
|
46
|
-
const PhoneUtil = /** @type {AwesomePhoneNumber} */ (PhoneUtilManager.PhoneUtil);
|
|
44
|
+
const AwesomePhoneNumber = PhoneUtilManager.PhoneUtil;
|
|
47
45
|
|
|
48
46
|
let pn;
|
|
49
47
|
try {
|
|
50
|
-
pn =
|
|
48
|
+
pn = AwesomePhoneNumber.parsePhoneNumber(modelValue, { regionCode });
|
|
51
49
|
// eslint-disable-next-line no-empty
|
|
52
50
|
} catch (_) {}
|
|
53
51
|
|
|
54
|
-
if (modelValue?.length >= 4 && modelValue?.length <= 16 && pn?.
|
|
52
|
+
if (modelValue?.length >= 4 && modelValue?.length <= 16 && pn?.valid) {
|
|
55
53
|
let formattedValue;
|
|
56
54
|
|
|
57
55
|
switch (formatStrategy) {
|
|
58
56
|
case 'e164':
|
|
59
|
-
formattedValue = pn.
|
|
57
|
+
formattedValue = pn.number.e164; // -> '+46707123456' (default)
|
|
60
58
|
break;
|
|
61
59
|
case 'international':
|
|
62
|
-
formattedValue = pn.
|
|
60
|
+
formattedValue = pn.number.international; // -> '+46 70 712 34 56'
|
|
63
61
|
break;
|
|
64
62
|
case 'national':
|
|
65
|
-
formattedValue = pn.
|
|
63
|
+
formattedValue = pn.number.national; // -> '070-712 34 56'
|
|
66
64
|
break;
|
|
67
65
|
case 'rfc3966':
|
|
68
|
-
formattedValue = pn.
|
|
66
|
+
formattedValue = pn.number.rfc3966; // -> 'tel:+46-70-712-34-56'
|
|
69
67
|
break;
|
|
70
68
|
case 'significant':
|
|
71
|
-
formattedValue = pn.
|
|
69
|
+
formattedValue = pn.number.significant; // -> '707123456'
|
|
72
70
|
break;
|
|
73
71
|
default:
|
|
74
72
|
break;
|
|
@@ -2,7 +2,6 @@ import { PhoneUtilManager } from './PhoneUtilManager.js';
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {import('../types/index.js').RegionCode} RegionCode
|
|
5
|
-
* @typedef {* & import('awesome-phonenumber').default} AwesomePhoneNumber
|
|
6
5
|
*/
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -17,17 +16,17 @@ export function parsePhoneNumber(viewValue, { regionCode }) {
|
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
// eslint-disable-next-line prefer-destructuring
|
|
20
|
-
const
|
|
19
|
+
const AwesomePhoneNumber = PhoneUtilManager.PhoneUtil;
|
|
21
20
|
const regex = /[+0-9]+/gi;
|
|
22
21
|
const strippedViewValue = viewValue.match(regex)?.join('');
|
|
23
22
|
let pn;
|
|
24
23
|
try {
|
|
25
|
-
pn =
|
|
24
|
+
pn = AwesomePhoneNumber.parsePhoneNumber(strippedViewValue, { regionCode });
|
|
26
25
|
// eslint-disable-next-line no-empty
|
|
27
26
|
} catch (_) {}
|
|
28
27
|
|
|
29
28
|
if (pn) {
|
|
30
|
-
return pn.
|
|
29
|
+
return pn.number.e164;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
return viewValue;
|
|
@@ -4,7 +4,6 @@ import { PhoneUtilManager } from './PhoneUtilManager.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {import('../types/index.js').RegionCode} RegionCode
|
|
6
6
|
* @typedef {import('awesome-phonenumber').PhoneNumberFormat} PhoneNumberFormat
|
|
7
|
-
* @typedef {* & import('awesome-phonenumber').default} AwesomePhoneNumber
|
|
8
7
|
*/
|
|
9
8
|
|
|
10
9
|
/**
|
|
@@ -27,9 +26,8 @@ export function liveFormatPhoneNumber(
|
|
|
27
26
|
return undefined;
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const ayt = PhoneNumber.getAsYouType(regionCode);
|
|
29
|
+
const AwesomePhoneNumber = PhoneUtilManager.PhoneUtil;
|
|
30
|
+
const ayt = AwesomePhoneNumber.getAsYouType(regionCode);
|
|
33
31
|
|
|
34
32
|
for (const char of viewValue) {
|
|
35
33
|
if (char !== '') {
|
|
@@ -3,7 +3,6 @@ import { PhoneUtilManager } from './PhoneUtilManager.js';
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {import('../types/index.js').RegionCode} RegionCode
|
|
6
|
-
* @typedef {* & import('awesome-phonenumber').default} AwesomePhoneNumber
|
|
7
6
|
* @typedef {import('../../form-core/types/validate/validate.js').FeedbackMessageData} FeedbackMessageData
|
|
8
7
|
*/
|
|
9
8
|
|
|
@@ -13,22 +12,21 @@ import { PhoneUtilManager } from './PhoneUtilManager.js';
|
|
|
13
12
|
* @returns {false|'invalid-country-code'|'unknown'|'too-long'|'too-short'}
|
|
14
13
|
*/
|
|
15
14
|
function hasFeedback(modelValue, regionCode) {
|
|
16
|
-
|
|
17
|
-
const PhoneNumber = /** @type {AwesomePhoneNumber} */ (PhoneUtilManager.PhoneUtil);
|
|
15
|
+
const AwesomePhoneNumber = PhoneUtilManager.PhoneUtil;
|
|
18
16
|
let invalidCountryCode = false;
|
|
19
17
|
|
|
20
18
|
if (regionCode && modelValue?.length >= 4 && modelValue?.length <= 16) {
|
|
21
19
|
let pn;
|
|
22
20
|
try {
|
|
23
|
-
pn =
|
|
24
|
-
invalidCountryCode = pn.
|
|
21
|
+
pn = AwesomePhoneNumber.parsePhoneNumber(modelValue, { regionCode });
|
|
22
|
+
invalidCountryCode = pn.regionCode !== regionCode;
|
|
25
23
|
if (invalidCountryCode) {
|
|
26
24
|
return 'invalid-country-code';
|
|
27
25
|
}
|
|
28
26
|
// eslint-disable-next-line no-empty
|
|
29
27
|
} catch (_) {}
|
|
30
28
|
// too-short/too-long info seems to be not there (we get 'is-possible'?)
|
|
31
|
-
const enumValue = !pn.
|
|
29
|
+
const enumValue = !pn.valid ? pn.possibility : false;
|
|
32
30
|
if (enumValue === 'is-possible') {
|
|
33
31
|
return 'unknown';
|
|
34
32
|
}
|
|
@@ -4,7 +4,7 @@ import { PhoneNumber, PhoneUtilManager } from '@lion/ui/input-tel.js';
|
|
|
4
4
|
import { mockPhoneUtilManager, restorePhoneUtilManager } from '@lion/ui/input-tel-test-helpers.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @typedef {* & import('awesome-phonenumber')
|
|
7
|
+
* @typedef {* & import('awesome-phonenumber')} AwesomePhoneNumber
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
// For enum output, see: https://www.npmjs.com/package/awesome-phonenumber
|
|
@@ -24,6 +24,7 @@ describe('PhoneNumber validation', () => {
|
|
|
24
24
|
expect(validator.execute('foo', 'NL')).to.equal('unknown');
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
+
// TODO: this changed after awesome-phonenumber v4. Skip for now, look into this later
|
|
27
28
|
it('is invalid when wrong country code is entered, returns "invalid-country-code"', () => {
|
|
28
29
|
const validator = new PhoneNumber();
|
|
29
30
|
// 32 is BE region code
|
|
@@ -47,12 +48,13 @@ describe('PhoneNumber validation', () => {
|
|
|
47
48
|
|
|
48
49
|
it('handles validation via awesome-phonenumber', () => {
|
|
49
50
|
const validator = new PhoneNumber();
|
|
50
|
-
|
|
51
|
+
// @ts-ignore
|
|
52
|
+
const spy = sinon.spy(PhoneUtilManager.PhoneUtil, 'parsePhoneNumber');
|
|
51
53
|
validator.execute('0123456789', 'NL');
|
|
52
54
|
expect(spy).to.have.been.calledOnce;
|
|
53
|
-
expect(spy.lastCall.args[1]).to.
|
|
55
|
+
expect(spy.lastCall.args[1]).to.eql({ regionCode: 'NL' });
|
|
54
56
|
validator.execute('0123456789', 'DE');
|
|
55
|
-
expect(spy.lastCall.args[1]).to.
|
|
57
|
+
expect(spy.lastCall.args[1]).to.eql({ regionCode: 'DE' });
|
|
56
58
|
spy.restore();
|
|
57
59
|
});
|
|
58
60
|
|
|
@@ -75,7 +77,8 @@ describe('PhoneNumber validation', () => {
|
|
|
75
77
|
|
|
76
78
|
it('waits for the lib to be loaded before execution completes when still in async mode', async () => {
|
|
77
79
|
const validator = new PhoneNumber();
|
|
78
|
-
|
|
80
|
+
// @ts-ignore
|
|
81
|
+
const spy = sinon.spy(PhoneUtilManager.PhoneUtil, 'parsePhoneNumber');
|
|
79
82
|
const validationResult = validator.execute('061234', 'NL');
|
|
80
83
|
expect(validationResult).to.be.instanceOf(Promise);
|
|
81
84
|
expect(spy).to.not.have.been.called;
|