@lion/ui 0.7.7 → 0.7.9
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/accordion/src/LionAccordion.js +22 -16
- package/components/accordion/test/lion-accordion.test.js +75 -24
- package/components/calendar/src/LionCalendar.js +9 -5
- package/components/calendar/test/lion-calendar.test.js +33 -6
- package/components/input-datepicker/src/LionInputDatepicker.js +1 -21
- package/components/input-datepicker/test/lion-input-datepicker.test.js +27 -0
- package/components/validate-messages/translations/cs.js +4 -4
- package/components/validate-messages/translations/es.js +2 -2
- package/components/validate-messages/translations/hu.js +2 -2
- package/components/validate-messages/translations/it.js +2 -2
- package/components/validate-messages/translations/nl.js +2 -2
- package/components/validate-messages/translations/pl.js +2 -2
- package/components/validate-messages/translations/ru.js +2 -2
- package/components/validate-messages/translations/sk.js +2 -2
- package/components/validate-messages/translations/uk.js +2 -2
- package/custom-elements.json +51 -49
- package/dist-types/components/accordion/src/LionAccordion.d.ts +11 -1
- package/dist-types/components/accordion/src/LionAccordion.d.ts.map +1 -1
- package/dist-types/components/calendar/src/LionCalendar.d.ts +1 -0
- package/dist-types/components/calendar/src/LionCalendar.d.ts.map +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/tsconfig.tsbuildinfo +1 -1
- package/docs/components/accordion/api-table.md +6 -4
- package/docs/components/accordion/use-cases.md +43 -4
- package/docs/components/checkbox-group/overview.md +2 -2
- package/docs/components/checkbox-group/use-cases.md +20 -59
- 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/fieldset/use-cases.md +9 -2
- package/docs/components/form/overview.md +3 -3
- package/docs/components/form/use-cases.md +2 -1
- 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-amount/use-cases.md +2 -2
- package/docs/components/input-date/overview.md +3 -3
- package/docs/components/input-date/use-cases.md +3 -1
- package/docs/components/input-datepicker/api-table.md +0 -2
- 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/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/pagination/use-cases.md +3 -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 +1 -1
- package/docs/components/steps/overview.md +6 -2
- package/docs/components/steps/use-cases.md +9 -3
- 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/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/use-cases.md +2 -1
- package/docs/fundamentals/systems/form/validate.md +2 -2
- package/docs/fundamentals/systems/localize/overview.md +4 -4
- package/docs/fundamentals/systems/localize/use-cases.md +3 -1
- 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 +5 -3
- 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 +1 -1
|
@@ -25,15 +25,15 @@ export class LionAccordion extends LitElement {
|
|
|
25
25
|
/**
|
|
26
26
|
* index number of the focused accordion
|
|
27
27
|
*/
|
|
28
|
-
focusedIndex: {
|
|
29
|
-
type: Number,
|
|
30
|
-
},
|
|
28
|
+
focusedIndex: { type: Number },
|
|
31
29
|
/**
|
|
32
30
|
* array of indices of the expanded accordions
|
|
33
31
|
*/
|
|
34
|
-
expanded: {
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
expanded: { type: Array },
|
|
33
|
+
/**
|
|
34
|
+
* exclusive property allows only one accordion slot to be open at a time
|
|
35
|
+
*/
|
|
36
|
+
exclusive: { type: Boolean },
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -101,6 +101,11 @@ export class LionAccordion extends LitElement {
|
|
|
101
101
|
super();
|
|
102
102
|
this.styles = {};
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* @type {boolean}
|
|
106
|
+
*/
|
|
107
|
+
this.exclusive = false;
|
|
108
|
+
|
|
104
109
|
/**
|
|
105
110
|
* @type {StoreEntry[]}
|
|
106
111
|
* @private
|
|
@@ -437,20 +442,21 @@ export class LionAccordion extends LitElement {
|
|
|
437
442
|
}
|
|
438
443
|
|
|
439
444
|
/**
|
|
440
|
-
* @param {number}
|
|
445
|
+
* @param {number} indexClicked
|
|
441
446
|
* @private
|
|
442
447
|
*/
|
|
443
|
-
__toggleExpanded(
|
|
444
|
-
const
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
if (
|
|
448
|
-
|
|
449
|
-
} else {
|
|
450
|
-
|
|
448
|
+
__toggleExpanded(indexClicked) {
|
|
449
|
+
const indexFound = this.expanded.indexOf(indexClicked);
|
|
450
|
+
const expandedNewValues = this.exclusive ? [] : [...this.expanded];
|
|
451
|
+
|
|
452
|
+
if (indexFound === -1) {
|
|
453
|
+
expandedNewValues.push(indexClicked);
|
|
454
|
+
} else if (expandedNewValues.includes(indexFound)) {
|
|
455
|
+
expandedNewValues.splice(indexFound, 1);
|
|
451
456
|
}
|
|
452
457
|
|
|
453
|
-
|
|
458
|
+
// trigger a render
|
|
459
|
+
this.expanded = expandedNewValues;
|
|
454
460
|
}
|
|
455
461
|
|
|
456
462
|
/**
|
|
@@ -33,14 +33,14 @@ function getAccordionChildren(el) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* @param {
|
|
36
|
+
* @param {LionAccordion} el
|
|
37
37
|
*/
|
|
38
38
|
function getInvokers(el) {
|
|
39
39
|
return getAccordionChildren(el).filter(child => child.classList.contains('invoker'));
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* @param {
|
|
43
|
+
* @param {LionAccordion} el
|
|
44
44
|
*/
|
|
45
45
|
function getContents(el) {
|
|
46
46
|
return getAccordionChildren(el).filter(child => child.classList.contains('content'));
|
|
@@ -112,6 +112,51 @@ describe('<lion-accordion>', () => {
|
|
|
112
112
|
expect(invokers[1].firstElementChild).to.have.attribute('expanded');
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
+
it('supports [exclusive] attribute, allowing one collapsible to be open at a time', async () => {
|
|
116
|
+
const el = /** @type {LionAccordion} */ (
|
|
117
|
+
await fixture(html`
|
|
118
|
+
<lion-accordion exclusive>
|
|
119
|
+
<h2 slot="invoker"><button>invoker 1</button></h2>
|
|
120
|
+
<div slot="content">content 1</div>
|
|
121
|
+
<h2 slot="invoker"><button>invoker 2</button></h2>
|
|
122
|
+
<div slot="content">content 2</div>
|
|
123
|
+
<h2 slot="invoker"><button>invoker 3</button></h2>
|
|
124
|
+
<div slot="content">content 3</div>
|
|
125
|
+
</lion-accordion>
|
|
126
|
+
`)
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const invokerButtons = Array.from(getInvokers(el)).map(
|
|
130
|
+
invokerHeadingEl => /** @type {HTMLButtonElement} */ (invokerHeadingEl.firstElementChild),
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
// We open the first... (nothing different from not [exclusive] so far)
|
|
134
|
+
invokerButtons[0].click();
|
|
135
|
+
expect(invokerButtons[0]).to.have.attribute('expanded');
|
|
136
|
+
expect(invokerButtons[1]).to.not.have.attribute('expanded');
|
|
137
|
+
expect(invokerButtons[2]).to.not.have.attribute('expanded');
|
|
138
|
+
|
|
139
|
+
// We click the second...
|
|
140
|
+
invokerButtons[1].click();
|
|
141
|
+
expect(invokerButtons[0]).to.not.have.attribute('expanded');
|
|
142
|
+
expect(invokerButtons[1]).to.have.attribute('expanded');
|
|
143
|
+
expect(invokerButtons[2]).to.not.have.attribute('expanded');
|
|
144
|
+
|
|
145
|
+
// We click the third...
|
|
146
|
+
invokerButtons[2].click();
|
|
147
|
+
expect(invokerButtons[0]).to.not.have.attribute('expanded');
|
|
148
|
+
expect(invokerButtons[1]).to.not.have.attribute('expanded');
|
|
149
|
+
expect(invokerButtons[2]).to.have.attribute('expanded');
|
|
150
|
+
|
|
151
|
+
el.exclusive = false;
|
|
152
|
+
|
|
153
|
+
// We open the first... (behaving as default (not [exclusive]) again)
|
|
154
|
+
invokerButtons[0].click();
|
|
155
|
+
expect(invokerButtons[0]).to.have.attribute('expanded');
|
|
156
|
+
expect(invokerButtons[1]).to.not.have.attribute('expanded');
|
|
157
|
+
expect(invokerButtons[2]).to.have.attribute('expanded');
|
|
158
|
+
});
|
|
159
|
+
|
|
115
160
|
it('sends event "expanded-changed" for every expanded state change', async () => {
|
|
116
161
|
const el = /** @type {LionAccordion} */ (await fixture(basicAccordion));
|
|
117
162
|
const spy = sinon.spy();
|
|
@@ -467,14 +512,16 @@ describe('<lion-accordion>', () => {
|
|
|
467
512
|
|
|
468
513
|
describe('Invokers', () => {
|
|
469
514
|
it('links ids of content items to invoker first child via [aria-controls]', async () => {
|
|
470
|
-
const el =
|
|
471
|
-
|
|
472
|
-
<
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
515
|
+
const el = /** @type {LionAccordion} */ (
|
|
516
|
+
await fixture(html`
|
|
517
|
+
<lion-accordion>
|
|
518
|
+
<h2 id="h1" slot="invoker"><button>invoker 1</button></h2>
|
|
519
|
+
<div id="p1" slot="content">content 1</div>
|
|
520
|
+
<h2 id="h2" slot="invoker"><button>invoker 2</button></h2>
|
|
521
|
+
<div id="p2" slot="content">content 2</div>
|
|
522
|
+
</lion-accordion>
|
|
523
|
+
`)
|
|
524
|
+
);
|
|
478
525
|
const invokers = getInvokers(el);
|
|
479
526
|
const contents = getContents(el);
|
|
480
527
|
expect(invokers[0].firstElementChild?.getAttribute('aria-controls')).to.equal(
|
|
@@ -486,12 +533,14 @@ describe('<lion-accordion>', () => {
|
|
|
486
533
|
});
|
|
487
534
|
|
|
488
535
|
it('adds aria-expanded="false" to invoker when its content is not expanded', async () => {
|
|
489
|
-
const el =
|
|
490
|
-
|
|
491
|
-
<
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
536
|
+
const el = /** @type {LionAccordion} */ (
|
|
537
|
+
await fixture(html`
|
|
538
|
+
<lion-accordion>
|
|
539
|
+
<h2 slot="invoker"><button>invoker</button></h2>
|
|
540
|
+
<div slot="content">content</div>
|
|
541
|
+
</lion-accordion>
|
|
542
|
+
`)
|
|
543
|
+
);
|
|
495
544
|
expect(Array.from(getInvokers(el))[0]?.firstElementChild).to.have.attribute(
|
|
496
545
|
'aria-expanded',
|
|
497
546
|
'false',
|
|
@@ -517,14 +566,16 @@ describe('<lion-accordion>', () => {
|
|
|
517
566
|
|
|
518
567
|
describe('Contents', () => {
|
|
519
568
|
it('adds aria-labelledby referring to invoker ids', async () => {
|
|
520
|
-
const el =
|
|
521
|
-
|
|
522
|
-
<
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
569
|
+
const el = /** @type {LionAccordion} */ (
|
|
570
|
+
await fixture(html`
|
|
571
|
+
<lion-accordion>
|
|
572
|
+
<h2 slot="invoker"><button>invoker 1</button></h2>
|
|
573
|
+
<div slot="content">content 1</div>
|
|
574
|
+
<h2 slot="invoker"><button>invoker 2</button></h2>
|
|
575
|
+
<div slot="content">content 2</div>
|
|
576
|
+
</lion-accordion>
|
|
577
|
+
`)
|
|
578
|
+
);
|
|
528
579
|
const contents = getContents(el);
|
|
529
580
|
const invokers = getInvokers(el);
|
|
530
581
|
expect(contents[0]).to.have.attribute('aria-labelledby', invokers[0].firstElementChild?.id);
|
|
@@ -270,11 +270,6 @@ export class LionCalendar extends LocalizeMixin(LitElement) {
|
|
|
270
270
|
|
|
271
271
|
this.__connectedCallbackDone = true;
|
|
272
272
|
|
|
273
|
-
this.__calculateInitialCentralDate();
|
|
274
|
-
|
|
275
|
-
// setup data for initial render
|
|
276
|
-
this.__data = this.__createData();
|
|
277
|
-
|
|
278
273
|
/**
|
|
279
274
|
* This logic needs to happen on firstUpdated, but every time the DOM node is moved as well
|
|
280
275
|
* since firstUpdated only runs once, this logic is moved here, but after updateComplete
|
|
@@ -305,6 +300,13 @@ export class LionCalendar extends LocalizeMixin(LitElement) {
|
|
|
305
300
|
}
|
|
306
301
|
}
|
|
307
302
|
|
|
303
|
+
firstUpdated() {
|
|
304
|
+
this.__calculateInitialCentralDate();
|
|
305
|
+
|
|
306
|
+
// setup data for initial render
|
|
307
|
+
this.__data = this.__createData();
|
|
308
|
+
}
|
|
309
|
+
|
|
308
310
|
disconnectedCallback() {
|
|
309
311
|
super.disconnectedCallback();
|
|
310
312
|
if (this.__contentWrapperElement) {
|
|
@@ -372,6 +374,8 @@ export class LionCalendar extends LocalizeMixin(LitElement) {
|
|
|
372
374
|
if (this.centralDate === this.__today && this.selectedDate) {
|
|
373
375
|
// initialized with selectedDate only if user didn't provide another one
|
|
374
376
|
this.centralDate = this.selectedDate;
|
|
377
|
+
} else if (!this.__isEnabledDate(this.centralDate)) {
|
|
378
|
+
this.centralDate = this.findNearestEnabledDate(this.centralDate);
|
|
375
379
|
}
|
|
376
380
|
/** @type {Date} */
|
|
377
381
|
this.__initialCentralDate = this.centralDate;
|
|
@@ -465,9 +465,8 @@ describe('<lion-calendar>', () => {
|
|
|
465
465
|
`);
|
|
466
466
|
|
|
467
467
|
clock.restore();
|
|
468
|
-
expect(isSameDate(el.centralDate, new Date('2019/
|
|
469
|
-
expect(isSameDate(elSetting.centralDate, new Date('2019/07/03'))
|
|
470
|
-
.true;
|
|
468
|
+
expect(isSameDate(el.centralDate, new Date('2019/07/03'))).to.be.true;
|
|
469
|
+
expect(isSameDate(elSetting.centralDate, new Date('2019/07/03'))).to.be.true;
|
|
471
470
|
});
|
|
472
471
|
|
|
473
472
|
describe('Normalization', () => {
|
|
@@ -573,7 +572,7 @@ describe('<lion-calendar>', () => {
|
|
|
573
572
|
.disableDates="${/** @param {Date} d */ d => d.getDate() === 15}"
|
|
574
573
|
></lion-calendar>
|
|
575
574
|
`);
|
|
576
|
-
el.focusDate(el.findNearestEnabledDate());
|
|
575
|
+
el.focusDate(el.findNearestEnabledDate(new Date()));
|
|
577
576
|
await el.updateComplete;
|
|
578
577
|
|
|
579
578
|
const elObj = new CalendarObject(el);
|
|
@@ -590,7 +589,7 @@ describe('<lion-calendar>', () => {
|
|
|
590
589
|
.disableDates="${/** @param {Date} d */ d => d.getFullYear() > 1998}"
|
|
591
590
|
></lion-calendar>
|
|
592
591
|
`);
|
|
593
|
-
el.focusDate(el.findNearestEnabledDate());
|
|
592
|
+
el.focusDate(el.findNearestEnabledDate(new Date()));
|
|
594
593
|
await el.updateComplete;
|
|
595
594
|
|
|
596
595
|
expect(el.centralDate.getFullYear()).to.equal(1998);
|
|
@@ -609,7 +608,7 @@ describe('<lion-calendar>', () => {
|
|
|
609
608
|
></lion-calendar>
|
|
610
609
|
`);
|
|
611
610
|
|
|
612
|
-
el.focusDate(el.findNearestEnabledDate());
|
|
611
|
+
el.focusDate(el.findNearestEnabledDate(new Date()));
|
|
613
612
|
await el.updateComplete;
|
|
614
613
|
|
|
615
614
|
expect(el.centralDate.getFullYear()).to.equal(2002);
|
|
@@ -1262,6 +1261,34 @@ describe('<lion-calendar>', () => {
|
|
|
1262
1261
|
|
|
1263
1262
|
clock.restore();
|
|
1264
1263
|
});
|
|
1264
|
+
|
|
1265
|
+
it('is nearest to today if no selected date is available and today is disabled', async () => {
|
|
1266
|
+
const clock = sinon.useFakeTimers({ now: new Date('2000/12/15').getTime() });
|
|
1267
|
+
|
|
1268
|
+
const calWithMin = await fixture(
|
|
1269
|
+
html`<lion-calendar .minDate=${new Date('2000/12/25')}></lion-calendar>`,
|
|
1270
|
+
);
|
|
1271
|
+
const calObjWithMin = new CalendarObject(calWithMin);
|
|
1272
|
+
expect(calObjWithMin.centralDayObj?.monthday).to.equal(25);
|
|
1273
|
+
|
|
1274
|
+
const calWithMax = await fixture(
|
|
1275
|
+
html`<lion-calendar .maxDate=${new Date('2000/12/05')}></lion-calendar>`,
|
|
1276
|
+
);
|
|
1277
|
+
const calObjWithMax = new CalendarObject(calWithMax);
|
|
1278
|
+
expect(calObjWithMax.centralDayObj?.monthday).to.equal(5);
|
|
1279
|
+
|
|
1280
|
+
const calWithDisabled = await fixture(
|
|
1281
|
+
html`<lion-calendar
|
|
1282
|
+
.disableDates=${/** @param {Date} date */ date => date.getDate() === 15}
|
|
1283
|
+
></lion-calendar>`,
|
|
1284
|
+
);
|
|
1285
|
+
await calWithDisabled.updateComplete;
|
|
1286
|
+
|
|
1287
|
+
const calObjWithDisabled = new CalendarObject(calWithDisabled);
|
|
1288
|
+
expect(calObjWithDisabled.centralDayObj?.monthday).to.equal(16);
|
|
1289
|
+
|
|
1290
|
+
clock.restore();
|
|
1291
|
+
});
|
|
1265
1292
|
});
|
|
1266
1293
|
|
|
1267
1294
|
/**
|
|
@@ -102,23 +102,6 @@ export class LionInputDatepicker extends ScopedElementsMixin(
|
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
_inputFormatter = new Intl.DateTimeFormat('en-US', {
|
|
106
|
-
year: 'numeric',
|
|
107
|
-
month: '2-digit',
|
|
108
|
-
day: '2-digit',
|
|
109
|
-
}).formatToParts;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* @param {Date} date
|
|
113
|
-
*/
|
|
114
|
-
// eslint-disable-next-line class-methods-use-this
|
|
115
|
-
_formatDate(date) {
|
|
116
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
117
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
118
|
-
const year = String(date.getFullYear());
|
|
119
|
-
return `${day}/${month}/${year}`;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
105
|
get slots() {
|
|
123
106
|
return {
|
|
124
107
|
...super.slots,
|
|
@@ -370,18 +353,15 @@ export class LionInputDatepicker extends ScopedElementsMixin(
|
|
|
370
353
|
if (this._syncOnUserSelect) {
|
|
371
354
|
// Synchronize new selectedDate value to input
|
|
372
355
|
this._isHandlingUserInput = true;
|
|
356
|
+
this._isHandlingCalendarUserInput = true;
|
|
373
357
|
|
|
374
358
|
if (
|
|
375
359
|
Array.isArray(this.__calendarDisableDates) &&
|
|
376
360
|
this.__calendarDisableDates.includes(selectedDate)
|
|
377
361
|
) {
|
|
378
362
|
// If the selected date is disabled, reset the values
|
|
379
|
-
this.value = '';
|
|
380
|
-
this.formattedValue = '';
|
|
381
363
|
this.modelValue = undefined;
|
|
382
364
|
} else {
|
|
383
|
-
this.formattedValue = this._formatDate(selectedDate);
|
|
384
|
-
this.value = this.formattedValue;
|
|
385
365
|
this.modelValue = selectedDate;
|
|
386
366
|
}
|
|
387
367
|
|
|
@@ -263,6 +263,33 @@ describe('<lion-input-datepicker>', () => {
|
|
|
263
263
|
expect(el.value).to.equal('18/12/2019');
|
|
264
264
|
});
|
|
265
265
|
|
|
266
|
+
describe('localization', () => {
|
|
267
|
+
/** @type {import('@lion/ui/localize.js').LocalizeManager} */ let localizeManager;
|
|
268
|
+
|
|
269
|
+
before(async () => {
|
|
270
|
+
const { getLocalizeManager } = await import('@lion/ui/localize-no-side-effects.js');
|
|
271
|
+
localizeManager = getLocalizeManager();
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('should update formatted value and value in accordance of localization upon model value update', async () => {
|
|
275
|
+
localizeManager.locale = 'nl-NL';
|
|
276
|
+
|
|
277
|
+
const el = await fixture(html`
|
|
278
|
+
<lion-input-datepicker .modelValue="${new Date('2022/12/30')}"></lion-input-datepicker>
|
|
279
|
+
`);
|
|
280
|
+
|
|
281
|
+
await el.updateComplete;
|
|
282
|
+
|
|
283
|
+
expect(el.formattedValue).to.equal('30-12-2022');
|
|
284
|
+
expect(el.value).to.equal('30-12-2022');
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
after(() => {
|
|
288
|
+
// @ts-ignore - using protected method to undo setting explict locale
|
|
289
|
+
localizeManager.locale = localizeManager._fallbackLocale;
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
266
293
|
describe('Validators', () => {
|
|
267
294
|
/**
|
|
268
295
|
* Validators are the Application Developer facing API in <lion-input-datepicker>:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
error: {
|
|
3
3
|
Required: 'Zadejte rovněž {fieldName}.',
|
|
4
|
-
_RequiredUpload: 'Nahrajte {
|
|
5
|
-
_RequiredSelect: 'Vyberte rovněž {
|
|
4
|
+
_RequiredUpload: 'Nahrajte {fieldName}.',
|
|
5
|
+
_RequiredSelect: 'Vyberte rovněž {fieldName}.',
|
|
6
6
|
EqualsLength: 'Zadejte správné {fieldName}, přesně {params} znaků.',
|
|
7
7
|
MinLength: 'Zadejte správné {fieldName} (alespoň {params}).',
|
|
8
8
|
MaxLength: 'Zadejte správné {fieldName} (až {params} znaků).',
|
|
@@ -23,8 +23,8 @@ export default {
|
|
|
23
23
|
},
|
|
24
24
|
warning: {
|
|
25
25
|
Required: 'Zadejte rovněž {fieldName}.',
|
|
26
|
-
_RequiredUpload: 'Nahrajte {
|
|
27
|
-
_RequiredSelect: 'Vyberte rovněž {
|
|
26
|
+
_RequiredUpload: 'Nahrajte {fieldName}.',
|
|
27
|
+
_RequiredSelect: 'Vyberte rovněž {fieldName}.',
|
|
28
28
|
EqualsLength: 'Zadejte správné {fieldName}, přesně {params} znaků.',
|
|
29
29
|
MinLength: 'Zadejte správné {fieldName} (alespoň {params}).',
|
|
30
30
|
MaxLength: 'Zadejte správné {fieldName} (až {params} znaků).',
|
|
@@ -2,7 +2,7 @@ export default {
|
|
|
2
2
|
error: {
|
|
3
3
|
Required: 'Introduzca también un/a {fieldName}.',
|
|
4
4
|
_RequiredUpload: 'Cargue un {fieldName}.',
|
|
5
|
-
_RequiredSelect: 'Seleccione también un/a {
|
|
5
|
+
_RequiredSelect: 'Seleccione también un/a {fieldName}.',
|
|
6
6
|
EqualsLength: 'Introduzca un/a {fieldName} correcto/a de exactamente {params} caracteres.',
|
|
7
7
|
MinLength: 'Introduzca un/a {fieldName} correcto/a (de al menos {params} caracteres).',
|
|
8
8
|
MaxLength: 'Introduzca un/a {fieldName} correcto/a (hasta {params} caracteres).',
|
|
@@ -26,7 +26,7 @@ export default {
|
|
|
26
26
|
warning: {
|
|
27
27
|
Required: 'Introduzca también un/a {fieldName}.',
|
|
28
28
|
_RequiredUpload: 'Cargue un {fieldName}.',
|
|
29
|
-
_RequiredSelect: 'Seleccione también un/a {
|
|
29
|
+
_RequiredSelect: 'Seleccione también un/a {fieldName}.',
|
|
30
30
|
EqualsLength: 'Introduzca un/a {fieldName} correcto/a de exactamente {params} caracteres.',
|
|
31
31
|
MinLength: 'Introduzca un/a {fieldName} correcto/a (de al menos {params} caracteres).',
|
|
32
32
|
MaxLength: 'Introduzca un/a {fieldName} correcto/a (hasta {params} caracteres).',
|
|
@@ -2,7 +2,7 @@ export default {
|
|
|
2
2
|
error: {
|
|
3
3
|
Required: 'Továbbá adjon meg egy {fieldName} értéket.',
|
|
4
4
|
_RequiredUpload: 'Töltsön fel egy {fieldName} elemet.',
|
|
5
|
-
_RequiredSelect: 'Továbbá válasszon ki egy {
|
|
5
|
+
_RequiredSelect: 'Továbbá válasszon ki egy {fieldName} értéket.',
|
|
6
6
|
EqualsLength: 'Adjon meg egy helyes {fieldName} értéket (pontosan {params} karakter).',
|
|
7
7
|
MinLength: 'Adjon meg egy helyes {fieldName} értéket (legalább {params}).',
|
|
8
8
|
MaxLength: 'Adjon meg egy helyes {fieldName} értéket (legfeljebb {params} karakter).',
|
|
@@ -26,7 +26,7 @@ export default {
|
|
|
26
26
|
warning: {
|
|
27
27
|
Required: 'Továbbá adjon meg egy {fieldName} értéket.',
|
|
28
28
|
_RequiredUpload: 'Töltsön fel egy {fieldName} elemet.',
|
|
29
|
-
_RequiredSelect: 'Továbbá válasszon ki egy {
|
|
29
|
+
_RequiredSelect: 'Továbbá válasszon ki egy {fieldName} értéket.',
|
|
30
30
|
EqualsLength: 'Adjon meg egy helyes {fieldName} értéket (pontosan {params} karakter).',
|
|
31
31
|
MinLength: 'Adjon meg egy helyes {fieldName} értéket (legalább {params}).',
|
|
32
32
|
MaxLength: 'Adjon meg egy helyes {fieldName} értéket (legfeljebb {params} karakter).',
|
|
@@ -2,7 +2,7 @@ export default {
|
|
|
2
2
|
error: {
|
|
3
3
|
Required: 'Inserire anche un(a) {fieldName}.',
|
|
4
4
|
_RequiredUpload: 'Caricare un {fieldName}.',
|
|
5
|
-
_RequiredSelect: 'Selezionare anche un(a) {
|
|
5
|
+
_RequiredSelect: 'Selezionare anche un(a) {fieldName}.',
|
|
6
6
|
EqualsLength: 'Inserire un(a) {fieldName} corretto(a) di esattamente {params} caratteri.',
|
|
7
7
|
MinLength: 'Inserire un(a) {fieldName} corretto(a) (almeno {params}).',
|
|
8
8
|
MaxLength: 'Inserire un(a) {fieldName} corretto(a) (fino a {params} caratteri).',
|
|
@@ -26,7 +26,7 @@ export default {
|
|
|
26
26
|
warning: {
|
|
27
27
|
Required: 'Inserire anche un(a) {fieldName}.',
|
|
28
28
|
_RequiredUpload: 'Caricare un {fieldName}.',
|
|
29
|
-
_RequiredSelect: 'Selezionare anche un(a) {
|
|
29
|
+
_RequiredSelect: 'Selezionare anche un(a) {fieldName}.',
|
|
30
30
|
EqualsLength: 'Inserire un(a) {fieldName} corretto(a) di esattamente {params} caratteri.',
|
|
31
31
|
MinLength: 'Inserire un(a) {fieldName} corretto(a) (almeno {params}).',
|
|
32
32
|
MaxLength: 'Inserire un(a) {fieldName} corretto(a) (fino a {params} caratteri).',
|
|
@@ -2,7 +2,7 @@ export default {
|
|
|
2
2
|
error: {
|
|
3
3
|
Required: 'Vul een {fieldName} in.',
|
|
4
4
|
_RequiredUpload: 'Upload een {fieldName}.',
|
|
5
|
-
_RequiredSelect: 'Selecteer een {
|
|
5
|
+
_RequiredSelect: 'Selecteer een {fieldName}.',
|
|
6
6
|
EqualsLength: 'Vul een {fieldName} in gelijk aan {params} karakters.',
|
|
7
7
|
MinLength: 'Vul een {fieldName} in van minimaal {params} karakters.',
|
|
8
8
|
MaxLength: 'Vul een {fieldName} in van maximaal {params} karakters.',
|
|
@@ -25,7 +25,7 @@ export default {
|
|
|
25
25
|
warning: {
|
|
26
26
|
Required: 'Vul een {fieldName} in.',
|
|
27
27
|
_RequiredUpload: 'Upload een {fieldName}.',
|
|
28
|
-
_RequiredSelect: 'Selecteer een {
|
|
28
|
+
_RequiredSelect: 'Selecteer een {fieldName}.',
|
|
29
29
|
EqualsLength: 'Vul een {fieldName} in gelijk aan {params} karakters.',
|
|
30
30
|
MinLength: 'Vul een {fieldName} in van minimaal {params} karakters.',
|
|
31
31
|
MaxLength: 'Vul een {fieldName} in van maximaal {params} karakters.',
|
|
@@ -2,7 +2,7 @@ export default {
|
|
|
2
2
|
error: {
|
|
3
3
|
Required: 'Proszę również podać wartość {fieldName}.',
|
|
4
4
|
_RequiredUpload: 'Prześlij plik {fieldName}.',
|
|
5
|
-
_RequiredSelect: 'Wprowadź prawidłową wartość w polu {
|
|
5
|
+
_RequiredSelect: 'Wprowadź prawidłową wartość w polu {fieldName}.',
|
|
6
6
|
EqualsLength: 'Wprowadź prawidłową wartość w polu {fieldName} (maks. liczba znaków: {params}).',
|
|
7
7
|
MinLength: 'Proszę podać prawidłową wartość {fieldName} (co najmniej {params} znaków).',
|
|
8
8
|
MaxLength: 'Proszę podać prawidłową wartość {fieldName} (maks. {params} znaków).',
|
|
@@ -25,7 +25,7 @@ export default {
|
|
|
25
25
|
warning: {
|
|
26
26
|
Required: 'Proszę również podać wartość {fieldName}.',
|
|
27
27
|
_RequiredUpload: 'Prześlij plik {fieldName}.',
|
|
28
|
-
_RequiredSelect: 'Wprowadź prawidłową wartość w polu {
|
|
28
|
+
_RequiredSelect: 'Wprowadź prawidłową wartość w polu {fieldName}.',
|
|
29
29
|
EqualsLength: 'Wprowadź prawidłową wartość w polu {fieldName} (maks. liczba znaków: {params}).',
|
|
30
30
|
MinLength: 'Proszę podać prawidłową wartość {fieldName} (co najmniej {params} znaków).',
|
|
31
31
|
MaxLength: 'Proszę podać prawidłową wartość {fieldName} (maks. {params} znaków).',
|
|
@@ -2,7 +2,7 @@ export default {
|
|
|
2
2
|
error: {
|
|
3
3
|
Required: 'Введите значение поля {fieldName}.',
|
|
4
4
|
_RequiredUpload: 'Загрузите {fieldName}.',
|
|
5
|
-
_RequiredSelect: 'Также выберите значение поля {
|
|
5
|
+
_RequiredSelect: 'Также выберите значение поля {fieldName}.',
|
|
6
6
|
EqualsLength: 'Введите корректное значение поля {fieldName} — ровно {params} симв.',
|
|
7
7
|
MinLength: 'Введите корректное значение поля {fieldName} (не менее {params}).',
|
|
8
8
|
MaxLength: 'Введите корректное значение поля {fieldName} (до {params} симв.).',
|
|
@@ -26,7 +26,7 @@ export default {
|
|
|
26
26
|
warning: {
|
|
27
27
|
Required: 'Введите значение поля {fieldName}.',
|
|
28
28
|
_RequiredUpload: 'Загрузите {fieldName}.',
|
|
29
|
-
_RequiredSelect: 'Также выберите значение поля {
|
|
29
|
+
_RequiredSelect: 'Также выберите значение поля {fieldName}.',
|
|
30
30
|
EqualsLength: 'Введите корректное значение поля {fieldName} — ровно {paramsn} симв.',
|
|
31
31
|
MinLength: 'Введите корректное значение поля {fieldName} (не менее {params}).',
|
|
32
32
|
MaxLength: 'Введите корректное значение поля {fieldName} (до {params} симв.).',
|
|
@@ -2,7 +2,7 @@ export default {
|
|
|
2
2
|
error: {
|
|
3
3
|
Required: 'Uveďte aj {fieldName}.',
|
|
4
4
|
_RequiredUpload: 'Nahrajte pole {fieldName}.',
|
|
5
|
-
_RequiredSelect: 'Vyberte aj hodnotu v poli {
|
|
5
|
+
_RequiredSelect: 'Vyberte aj hodnotu v poli {fieldName}.',
|
|
6
6
|
EqualsLength: 'Do poľa {fieldName} zadajte platnú hodnotu v dĺžke presne {params} znaky/-ov.',
|
|
7
7
|
MinLength: 'Uveďte správne {fieldName} (najmenej {params}).',
|
|
8
8
|
MaxLength: 'Uveďte správne {fieldName} (maximálne {params} znakov).',
|
|
@@ -24,7 +24,7 @@ export default {
|
|
|
24
24
|
warning: {
|
|
25
25
|
Required: 'Uveďte aj {fieldName}.',
|
|
26
26
|
_RequiredUpload: 'Nahrajte pole {fieldName}.',
|
|
27
|
-
_RequiredSelect: 'Vyberte aj hodnotu v poli {
|
|
27
|
+
_RequiredSelect: 'Vyberte aj hodnotu v poli {fieldName}.',
|
|
28
28
|
EqualsLength: 'Do poľa {fieldName} zadajte platnú hodnotu v dĺžke presne {params} znaky/-ov.',
|
|
29
29
|
MinLength: 'Uveďte správne {fieldName} (najmenej {params}).',
|
|
30
30
|
MaxLength: 'Uveďte správne {fieldName} (maximálne {params} znakov).',
|
|
@@ -2,7 +2,7 @@ export default {
|
|
|
2
2
|
error: {
|
|
3
3
|
Required: 'Уведіть також значення {fieldName}.',
|
|
4
4
|
_RequiredUpload: 'Завантажте {fieldName}.',
|
|
5
|
-
_RequiredSelect: 'Виберіть також {
|
|
5
|
+
_RequiredSelect: 'Виберіть також {fieldName}.',
|
|
6
6
|
EqualsLength:
|
|
7
7
|
'Введіть правильне значення {fieldName}, кількість символів має бути точно {params}.',
|
|
8
8
|
MinLength: 'Уведіть правильне значення {fieldName} (щонайменше {params}).',
|
|
@@ -27,7 +27,7 @@ export default {
|
|
|
27
27
|
warning: {
|
|
28
28
|
Required: 'Уведіть також значення {fieldName}.',
|
|
29
29
|
_RequiredUpload: 'Завантажте {fieldName}.',
|
|
30
|
-
_RequiredSelect: 'Виберіть також {
|
|
30
|
+
_RequiredSelect: 'Виберіть також {fieldName}.',
|
|
31
31
|
EqualsLength:
|
|
32
32
|
'Введіть правильне значення {fieldName}, кількість символів має бути точно {params}.',
|
|
33
33
|
MinLength: 'Уведіть правильне значення {fieldName} (щонайменше {params}).',
|