@lion/ui 0.14.2 → 0.15.0
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/icon/src/icons.js +14 -2
- package/components/icon/test/hammer.svg.js +5 -2
- package/components/icon/test/heart.svg.js +5 -2
- package/components/icon/test/lion-icon.test.js +10 -4
- package/components/input-stepper/src/LionInputStepper.js +10 -10
- package/components/localize/src/getLocalizeManager.js +16 -10
- package/components/localize/test/getLocalizeManager.test.js +15 -7
- package/components/localize/test/side-effect-free-entrypoint.test.js +9 -3
- package/components/overlays/src/singleton.js +14 -4
- package/components/select-rich/src/LionSelectRich.js +4 -2
- package/components/select-rich/test/lion-select-rich.test.js +376 -1
- package/custom-elements.json +55 -13
- package/dist-types/components/icon/src/LionIcon.d.ts +1 -1
- package/dist-types/components/icon/src/LionIcon.d.ts.map +1 -1
- package/dist-types/components/icon/src/icons.d.ts +2 -1
- package/dist-types/components/icon/src/icons.d.ts.map +1 -1
- package/dist-types/components/icon/test/hammer.svg.d.ts +1 -1
- package/dist-types/components/icon/test/hammer.svg.d.ts.map +1 -1
- package/dist-types/components/icon/test/heart.svg.d.ts +1 -1
- package/dist-types/components/icon/test/heart.svg.d.ts.map +1 -1
- package/dist-types/components/input-stepper/src/LionInputStepper.d.ts +4 -4
- package/dist-types/components/input-stepper/src/LionInputStepper.d.ts.map +1 -1
- package/dist-types/components/localize/src/getLocalizeManager.d.ts +2 -58
- package/dist-types/components/localize/src/getLocalizeManager.d.ts.map +1 -1
- package/dist-types/components/localize/test/getLocalizeManager.test.d.ts +4 -1
- package/dist-types/components/localize/test/getLocalizeManager.test.d.ts.map +1 -1
- package/dist-types/components/localize/test/side-effect-free-entrypoint.test.d.ts +4 -0
- package/dist-types/components/localize/test/side-effect-free-entrypoint.test.d.ts.map +1 -1
- package/dist-types/components/overlays/src/singleton.d.ts.map +1 -1
- package/dist-types/components/select-rich/src/LionSelectRich.d.ts.map +1 -1
- package/dist-types/components/select-rich/test/lion-select-rich.test.d.ts.map +1 -1
- 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/form/use-cases.md +2 -2
- 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-file/overview.md +1 -1
- package/docs/components/input-iban/overview.md +2 -2
- package/docs/components/input-range/overview.md +2 -2
- package/docs/components/input-stepper/api-table.md +2 -0
- 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/listbox/use-cases.md +1 -1
- package/docs/components/radio-group/overview.md +3 -3
- package/docs/components/select/use-cases.md +1 -1
- package/docs/components/select-rich/use-cases.md +16 -2
- package/docs/components/tabs/examples.md +1 -1
- package/docs/fundamentals/index.md +4 -4
- 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/rationales/accessibility.md +1 -1
- package/docs/fundamentals/systems/core/SlotMixin.md +1 -1
- 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 +2 -2
- 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/create-a-form.md +4 -4
- 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/package.json +2 -2
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
import { singletonManager } from 'singleton-manager';
|
|
1
|
+
import { singletonManager, lazifyInstantiation } from 'singleton-manager';
|
|
2
2
|
import { IconManager } from './IconManager.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @returns {IconManager}
|
|
6
|
+
*/
|
|
7
|
+
function getIconManager() {
|
|
8
|
+
if (!singletonManager.has('@lion/ui::icons::0.x')) {
|
|
9
|
+
const iconManager = new IconManager();
|
|
10
|
+
singletonManager.set('@lion/ui::icons::0.x', iconManager);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return singletonManager.get('@lion/ui::icons::0.x');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const icons = lazifyInstantiation(getIconManager);
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
export default /** @type {import("lit").TemplateResult} */ (
|
|
3
|
+
tag =>
|
|
4
|
+
tag`<svg focusable="false" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" data-test-id="svg-hammer"><path d="M.476 12.915L6.7 6 9 8.556l-6.223 6.915a1.542 1.542 0 0 1-1.15.529 1.54 1.54 0 0 1-1.15-.53c-.636-.706-.636-1.85 0-2.555zm12.638-9.031L16 6.863 12.866 10 4 .919 9.35 0l1.912 1.972.251-.251c.52-.52 2.4 1.363 1.88 1.882l-.279.28z"></path></svg>`
|
|
5
|
+
);
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
export default /** @type {import("lit").TemplateResult} */ (
|
|
3
|
+
tag =>
|
|
4
|
+
tag`<svg focusable="false" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" data-test-id="svg-heart"><path d="M8.002 14.867a.828.828 0 0 1-.324-.066C7.36 14.665 0 11.466 0 6.153 0 3.592 1.543.825 4.98 1.01c1.465.077 2.437.828 3.018 1.491.581-.667 1.553-1.414 3.023-1.491.107-.008.207-.008.31-.008C13.58 1.001 16 2.614 16 6.153c0 5.313-7.36 8.512-7.671 8.644a.787.787 0 0 1-.327.07z"></path></svg>`
|
|
5
|
+
);
|
|
@@ -183,13 +183,19 @@ describe('lion-icon', () => {
|
|
|
183
183
|
try {
|
|
184
184
|
icons.addIconResolver(
|
|
185
185
|
'foo',
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
() =>
|
|
187
|
+
/** @type {Promise<TemplateResult>} */ (
|
|
188
|
+
// eslint-disable-next-line no-promise-executor-return
|
|
189
|
+
new Promise(resolve => setTimeout(() => resolve(heartSvg)))
|
|
190
|
+
),
|
|
188
191
|
);
|
|
189
192
|
icons.addIconResolver(
|
|
190
193
|
'bar',
|
|
191
|
-
|
|
192
|
-
|
|
194
|
+
() =>
|
|
195
|
+
/** @type {Promise<TemplateResult>} */ (
|
|
196
|
+
// eslint-disable-next-line no-promise-executor-return
|
|
197
|
+
new Promise(resolve => setTimeout(() => resolve(hammerSvg)))
|
|
198
|
+
),
|
|
193
199
|
);
|
|
194
200
|
const el = await fixture(html`<lion-icon icon-id="foo:lorem:ipsum"></lion-icon>`);
|
|
195
201
|
|
|
@@ -94,8 +94,8 @@ export class LionInputStepper extends LocalizeMixin(LionInput) {
|
|
|
94
94
|
step: this.step,
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
-
this.
|
|
98
|
-
this.
|
|
97
|
+
this._increment = this._increment.bind(this);
|
|
98
|
+
this._decrement = this._decrement.bind(this);
|
|
99
99
|
this._onEnterButton = this._onEnterButton.bind(this);
|
|
100
100
|
this._onLeaveButton = this._onLeaveButton.bind(this);
|
|
101
101
|
}
|
|
@@ -192,11 +192,11 @@ export class LionInputStepper extends LocalizeMixin(LionInput) {
|
|
|
192
192
|
*/
|
|
193
193
|
__keyDownHandler(ev) {
|
|
194
194
|
if (ev.key === 'ArrowUp') {
|
|
195
|
-
this.
|
|
195
|
+
this._increment();
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
if (ev.key === 'ArrowDown') {
|
|
199
|
-
this.
|
|
199
|
+
this._decrement();
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
|
|
@@ -262,9 +262,9 @@ export class LionInputStepper extends LocalizeMixin(LionInput) {
|
|
|
262
262
|
|
|
263
263
|
/**
|
|
264
264
|
* Increment the value based on given step or default step value is 1
|
|
265
|
-
* @
|
|
265
|
+
* @protected
|
|
266
266
|
*/
|
|
267
|
-
|
|
267
|
+
_increment() {
|
|
268
268
|
const { step, min, max } = this.values;
|
|
269
269
|
const stepMin = min !== Infinity ? min : 0;
|
|
270
270
|
|
|
@@ -284,9 +284,9 @@ export class LionInputStepper extends LocalizeMixin(LionInput) {
|
|
|
284
284
|
|
|
285
285
|
/**
|
|
286
286
|
* Decrement the value based on given step or default step value is 1
|
|
287
|
-
* @
|
|
287
|
+
* @protected
|
|
288
288
|
*/
|
|
289
|
-
|
|
289
|
+
_decrement() {
|
|
290
290
|
const { step, max, min } = this.values;
|
|
291
291
|
const stepMin = min !== Infinity ? min : 0;
|
|
292
292
|
|
|
@@ -379,7 +379,7 @@ export class LionInputStepper extends LocalizeMixin(LionInput) {
|
|
|
379
379
|
return html`
|
|
380
380
|
<button
|
|
381
381
|
?disabled=${this.disabled || this.readOnly}
|
|
382
|
-
@click=${this.
|
|
382
|
+
@click=${this._decrement}
|
|
383
383
|
@focus=${this._onEnterButton}
|
|
384
384
|
@blur=${this._onLeaveButton}
|
|
385
385
|
type="button"
|
|
@@ -399,7 +399,7 @@ export class LionInputStepper extends LocalizeMixin(LionInput) {
|
|
|
399
399
|
return html`
|
|
400
400
|
<button
|
|
401
401
|
?disabled=${this.disabled || this.readOnly}
|
|
402
|
-
@click=${this.
|
|
402
|
+
@click=${this._increment}
|
|
403
403
|
@focus=${this._onEnterButton}
|
|
404
404
|
@blur=${this._onLeaveButton}
|
|
405
405
|
type="button"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-ignore
|
|
2
|
-
import { singletonManager } from 'singleton-manager';
|
|
2
|
+
import { singletonManager, lazifyInstantiation } from 'singleton-manager';
|
|
3
3
|
import { LocalizeManager } from './LocalizeManager.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -57,18 +57,24 @@ import { LocalizeManager } from './LocalizeManager.js';
|
|
|
57
57
|
* }
|
|
58
58
|
* ```
|
|
59
59
|
*
|
|
60
|
+
* @deprecated Use `localize` directly instead (as this is always side-effect free now)
|
|
61
|
+
*
|
|
60
62
|
* @returns {LocalizeManager}
|
|
61
63
|
*/
|
|
62
|
-
|
|
63
|
-
if (singletonManager.has('@lion/ui::localize::0.x')) {
|
|
64
|
-
|
|
64
|
+
function getLocalizeManager() {
|
|
65
|
+
if (!singletonManager.has('@lion/ui::localize::0.x')) {
|
|
66
|
+
const localizeManager = new LocalizeManager({
|
|
67
|
+
autoLoadOnLocaleChange: true,
|
|
68
|
+
fallbackLocale: 'en-GB',
|
|
69
|
+
});
|
|
70
|
+
singletonManager.set('@lion/ui::localize::0.x', localizeManager);
|
|
65
71
|
}
|
|
66
72
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
fallbackLocale: 'en-GB',
|
|
70
|
-
});
|
|
71
|
-
singletonManager.set('@lion/ui::localize::0.x', localizeManager);
|
|
73
|
+
return singletonManager.get('@lion/ui::localize::0.x');
|
|
74
|
+
}
|
|
72
75
|
|
|
73
|
-
|
|
76
|
+
function getLocalizeManagerLazily() {
|
|
77
|
+
return lazifyInstantiation(getLocalizeManager);
|
|
74
78
|
}
|
|
79
|
+
|
|
80
|
+
export { getLocalizeManagerLazily as getLocalizeManager };
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { expect } from '@open-wc/testing';
|
|
2
|
+
import { getLocalizeManager } from '@lion/ui/localize-no-side-effects.js';
|
|
2
3
|
// @ts-ignore
|
|
3
4
|
import { singletonManager } from 'singleton-manager';
|
|
4
5
|
import { LocalizeManager } from '../src/LocalizeManager.js';
|
|
5
|
-
|
|
6
|
+
|
|
7
|
+
/** @typedef {LocalizeManager & { __instance_for_testing?: LocalizeManager }} LocalizeManagerForTesting */
|
|
6
8
|
|
|
7
9
|
describe('getLocalizeManager', () => {
|
|
8
10
|
beforeEach(() => {
|
|
@@ -12,20 +14,26 @@ describe('getLocalizeManager', () => {
|
|
|
12
14
|
|
|
13
15
|
it('gets a default instance when nothing registered on singletonManager with "@lion/ui::localize::0.x"', () => {
|
|
14
16
|
expect(singletonManager.get('@lion/ui::localize::0.x')).to.be.undefined;
|
|
15
|
-
const localizeManager = getLocalizeManager();
|
|
16
|
-
expect(localizeManager).to.equal(
|
|
17
|
+
const /** @type {LocalizeManagerForTesting} */ localizeManager = getLocalizeManager();
|
|
18
|
+
expect(localizeManager.__instance_for_testing).to.equal(
|
|
19
|
+
singletonManager.get('@lion/ui::localize::0.x'),
|
|
20
|
+
);
|
|
17
21
|
});
|
|
18
22
|
|
|
19
23
|
it('gets the same instance when called multiple times', () => {
|
|
20
|
-
const localizeManager = getLocalizeManager();
|
|
21
|
-
const localizeManagerSecondCall = getLocalizeManager();
|
|
22
|
-
expect(localizeManager).to.
|
|
24
|
+
const /** @type {LocalizeManagerForTesting} */ localizeManager = getLocalizeManager();
|
|
25
|
+
const /** @type {LocalizeManagerForTesting} */ localizeManagerSecondCall = getLocalizeManager();
|
|
26
|
+
expect(localizeManager.__instance_for_testing).not.to.be.undefined;
|
|
27
|
+
expect(localizeManager.__instance_for_testing).to.equal(
|
|
28
|
+
localizeManagerSecondCall.__instance_for_testing,
|
|
29
|
+
);
|
|
23
30
|
});
|
|
24
31
|
|
|
25
32
|
it('gets the instance that was registered on singletonManager with "@lion/ui::localize::0.x"', () => {
|
|
26
33
|
// Set your own for custom behavior or for deduping purposes
|
|
27
34
|
class MyLocalizeManager extends LocalizeManager {}
|
|
28
35
|
singletonManager.set('@lion/ui::localize::0.x', MyLocalizeManager);
|
|
29
|
-
|
|
36
|
+
const /** @type {LocalizeManagerForTesting} */ localizeManager = getLocalizeManager();
|
|
37
|
+
expect(localizeManager.__instance_for_testing).to.equal(MyLocalizeManager);
|
|
30
38
|
});
|
|
31
39
|
});
|
|
@@ -5,6 +5,7 @@ import { singletonManager } from 'singleton-manager';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {import('../types/LocalizeMixinTypes.js').LocalizeMixin} LocalizeMixinHost
|
|
8
|
+
* @typedef {import('../../validate-messages/src/getLocalizedMessage.js').LocalizeManager & { __instance_for_testing?: import('../../validate-messages/src/getLocalizedMessage.js').LocalizeManager, aCallToRegisterLazilyLoadedInstance?: () => void }} LocalizeManagerForTesting
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
describe('Entrypoints localize', () => {
|
|
@@ -24,15 +25,20 @@ describe('Entrypoints localize', () => {
|
|
|
24
25
|
});
|
|
25
26
|
|
|
26
27
|
it('"@lion/ui/localize.js" has side effects (c.q. registers itself on singletonManager)', async () => {
|
|
27
|
-
await import(
|
|
28
|
+
const /** @type {{ localize: LocalizeManagerForTesting }} */ { localize } = await import(
|
|
29
|
+
'@lion/ui/localize.js'
|
|
30
|
+
);
|
|
31
|
+
localize.aCallToRegisterLazilyLoadedInstance?.();
|
|
28
32
|
|
|
29
33
|
expect(singletonManagerSetSpy).to.have.been.calledOnce;
|
|
30
34
|
|
|
31
|
-
const { getLocalizeManager }
|
|
35
|
+
const /** @type {{ getLocalizeManager: () => LocalizeManagerForTesting }} */ {
|
|
36
|
+
getLocalizeManager,
|
|
37
|
+
} = await import('@lion/ui/localize-no-side-effects.js');
|
|
32
38
|
|
|
33
39
|
expect(singletonManagerSetSpy).to.have.been.calledWith(
|
|
34
40
|
'@lion/ui::localize::0.x',
|
|
35
|
-
getLocalizeManager(),
|
|
41
|
+
getLocalizeManager().__instance_for_testing,
|
|
36
42
|
);
|
|
37
43
|
});
|
|
38
44
|
});
|
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import { singletonManager } from 'singleton-manager';
|
|
1
|
+
import { singletonManager, lazifyInstantiation } from 'singleton-manager';
|
|
2
2
|
import { OverlaysManager } from './OverlaysManager.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/**
|
|
5
|
+
* @returns {OverlaysManager}
|
|
6
|
+
*/
|
|
7
|
+
function getOverlaysManager() {
|
|
8
|
+
if (!singletonManager.has('@lion/ui::overlays::0.x')) {
|
|
9
|
+
const overlaysManager = new OverlaysManager();
|
|
10
|
+
singletonManager.set('@lion/ui::overlays::0.x', overlaysManager);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return singletonManager.get('@lion/ui::overlays::0.x');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const overlays = lazifyInstantiation(getOverlaysManager);
|
|
@@ -146,8 +146,10 @@ export class LionSelectRich extends SlotMixin(ScopedElementsMixin(OverlayMixin(L
|
|
|
146
146
|
|
|
147
147
|
connectedCallback() {
|
|
148
148
|
super.connectedCallback();
|
|
149
|
-
this.
|
|
150
|
-
this.
|
|
149
|
+
this.registrationComplete.then(() => {
|
|
150
|
+
this._invokerNode.selectedElement =
|
|
151
|
+
this.formElements[/** @type {number} */ (this.checkedIndex)];
|
|
152
|
+
});
|
|
151
153
|
|
|
152
154
|
this._invokerNode.hostElement = this;
|
|
153
155
|
|