use-wc 1.0.0-pre.32 → 1.0.0-pre.33

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.
@@ -169,14 +169,6 @@
169
169
  "attribute": "month",
170
170
  "reflects": true
171
171
  },
172
- {
173
- "kind": "field",
174
- "name": "locale",
175
- "type": {
176
- "text": "string"
177
- },
178
- "attribute": "locale"
179
- },
180
172
  {
181
173
  "kind": "field",
182
174
  "name": "controls",
@@ -305,13 +297,6 @@
305
297
  "description": "1-12",
306
298
  "fieldName": "month"
307
299
  },
308
- {
309
- "name": "locale",
310
- "type": {
311
- "text": "string"
312
- },
313
- "fieldName": "locale"
314
- },
315
300
  {
316
301
  "name": "controls",
317
302
  "type": {
@@ -381,13 +366,23 @@
381
366
  },
382
367
  "description": "Last date in the visible range. Accepts ISO 8601 date strings or `'max'` to use the same value as `max`",
383
368
  "fieldName": "end"
369
+ },
370
+ {
371
+ "name": "lang",
372
+ "type": {
373
+ "text": "string"
374
+ },
375
+ "fieldName": "lang",
376
+ "inheritedFrom": {
377
+ "name": "UseLocaleElement",
378
+ "module": "src/elements/use-locale-element/use-locale-element.ts"
379
+ }
384
380
  }
385
381
  ],
386
382
  "superclass": {
387
- "name": "LitElement",
388
- "package": "lit"
389
- },
390
- "customElement": true
383
+ "name": "UseLocaleElement",
384
+ "module": "/src/elements/use-locale-element/use-locale-element"
385
+ }
391
386
  }
392
387
  ],
393
388
  "exports": [
@@ -461,15 +456,6 @@
461
456
  },
462
457
  "default": "YYYY-MM-DD",
463
458
  "attribute": "value"
464
- },
465
- {
466
- "kind": "field",
467
- "name": "locale",
468
- "type": {
469
- "text": "string"
470
- },
471
- "default": "User's browser language or 'en-US'",
472
- "attribute": "locale"
473
459
  }
474
460
  ],
475
461
  "attributes": [
@@ -498,17 +484,20 @@
498
484
  "fieldName": "value"
499
485
  },
500
486
  {
501
- "name": "locale",
487
+ "name": "lang",
502
488
  "type": {
503
489
  "text": "string"
504
490
  },
505
- "default": "User's browser language or 'en-US'",
506
- "fieldName": "locale"
491
+ "fieldName": "lang",
492
+ "inheritedFrom": {
493
+ "name": "UseLocaleElement",
494
+ "module": "src/elements/use-locale-element/use-locale-element.ts"
495
+ }
507
496
  }
508
497
  ],
509
498
  "superclass": {
510
- "name": "LitElement",
511
- "package": "lit"
499
+ "name": "UseLocaleElement",
500
+ "module": "/src/elements/use-locale-element/use-locale-element"
512
501
  },
513
502
  "tagName": "use-date-input",
514
503
  "customElement": true
@@ -642,18 +631,6 @@
642
631
  "module": "src/elements/use-calendar-base/use-calendar-base.ts"
643
632
  }
644
633
  },
645
- {
646
- "kind": "field",
647
- "name": "locale",
648
- "type": {
649
- "text": "string"
650
- },
651
- "attribute": "locale",
652
- "inheritedFrom": {
653
- "name": "UseCalendarBase",
654
- "module": "src/elements/use-calendar-base/use-calendar-base.ts"
655
- }
656
- },
657
634
  {
658
635
  "kind": "field",
659
636
  "name": "controls",
@@ -1117,17 +1094,6 @@
1117
1094
  "module": "src/elements/use-calendar-base/use-calendar-base.ts"
1118
1095
  }
1119
1096
  },
1120
- {
1121
- "name": "locale",
1122
- "type": {
1123
- "text": "string"
1124
- },
1125
- "fieldName": "locale",
1126
- "inheritedFrom": {
1127
- "name": "UseCalendarBase",
1128
- "module": "src/elements/use-calendar-base/use-calendar-base.ts"
1129
- }
1130
- },
1131
1097
  {
1132
1098
  "name": "controls",
1133
1099
  "type": {
@@ -1233,6 +1199,17 @@
1233
1199
  "name": "UseCalendarBase",
1234
1200
  "module": "src/elements/use-calendar-base/use-calendar-base.ts"
1235
1201
  }
1202
+ },
1203
+ {
1204
+ "name": "lang",
1205
+ "type": {
1206
+ "text": "string"
1207
+ },
1208
+ "fieldName": "lang",
1209
+ "inheritedFrom": {
1210
+ "name": "UseLocaleElement",
1211
+ "module": "src/elements/use-locale-element/use-locale-element.ts"
1212
+ }
1236
1213
  }
1237
1214
  ]
1238
1215
  }
@@ -1299,15 +1276,6 @@
1299
1276
  },
1300
1277
  "attribute": "readonly"
1301
1278
  },
1302
- {
1303
- "kind": "field",
1304
- "name": "locale",
1305
- "type": {
1306
- "text": "string"
1307
- },
1308
- "default": "User's browser language or 'en-US'",
1309
- "attribute": "locale"
1310
- },
1311
1279
  {
1312
1280
  "kind": "field",
1313
1281
  "name": "hours",
@@ -1386,14 +1354,6 @@
1386
1354
  },
1387
1355
  "fieldName": "readOnly"
1388
1356
  },
1389
- {
1390
- "name": "locale",
1391
- "type": {
1392
- "text": "string"
1393
- },
1394
- "default": "User's browser language or 'en-US'",
1395
- "fieldName": "locale"
1396
- },
1397
1357
  {
1398
1358
  "name": "hours",
1399
1359
  "type": {
@@ -1448,11 +1408,22 @@
1448
1408
  },
1449
1409
  "default": "''",
1450
1410
  "fieldName": "value"
1411
+ },
1412
+ {
1413
+ "name": "lang",
1414
+ "type": {
1415
+ "text": "string"
1416
+ },
1417
+ "fieldName": "lang",
1418
+ "inheritedFrom": {
1419
+ "name": "UseLocaleElement",
1420
+ "module": "src/elements/use-locale-element/use-locale-element.ts"
1421
+ }
1451
1422
  }
1452
1423
  ],
1453
1424
  "superclass": {
1454
- "name": "LitElement",
1455
- "package": "lit"
1425
+ "name": "UseLocaleElement",
1426
+ "module": "/src/elements/use-locale-element/use-locale-element"
1456
1427
  },
1457
1428
  "tagName": "use-datetime-input",
1458
1429
  "customElement": true
@@ -1734,15 +1705,6 @@
1734
1705
  "default": "PT0S",
1735
1706
  "attribute": "value"
1736
1707
  },
1737
- {
1738
- "kind": "field",
1739
- "name": "locale",
1740
- "type": {
1741
- "text": "string"
1742
- },
1743
- "default": "User's browser language or 'en-US'",
1744
- "attribute": "locale"
1745
- },
1746
1708
  {
1747
1709
  "kind": "field",
1748
1710
  "name": "format",
@@ -1842,14 +1804,6 @@
1842
1804
  "default": "PT0S",
1843
1805
  "fieldName": "value"
1844
1806
  },
1845
- {
1846
- "name": "locale",
1847
- "type": {
1848
- "text": "string"
1849
- },
1850
- "default": "User's browser language or 'en-US'",
1851
- "fieldName": "locale"
1852
- },
1853
1807
  {
1854
1808
  "name": "format",
1855
1809
  "type": {
@@ -1857,11 +1811,22 @@
1857
1811
  },
1858
1812
  "default": "\"short\"",
1859
1813
  "fieldName": "format"
1814
+ },
1815
+ {
1816
+ "name": "lang",
1817
+ "type": {
1818
+ "text": "string"
1819
+ },
1820
+ "fieldName": "lang",
1821
+ "inheritedFrom": {
1822
+ "name": "UseLocaleElement",
1823
+ "module": "src/elements/use-locale-element/use-locale-element.ts"
1824
+ }
1860
1825
  }
1861
1826
  ],
1862
1827
  "superclass": {
1863
- "name": "LitElement",
1864
- "package": "lit"
1828
+ "name": "UseLocaleElement",
1829
+ "module": "/src/elements/use-locale-element/use-locale-element"
1865
1830
  },
1866
1831
  "tagName": "use-duration-input",
1867
1832
  "customElement": true
@@ -2604,6 +2569,42 @@
2604
2569
  }
2605
2570
  ]
2606
2571
  },
2572
+ {
2573
+ "kind": "javascript-module",
2574
+ "path": "src/elements/use-locale-element/use-locale-element.ts",
2575
+ "declarations": [
2576
+ {
2577
+ "kind": "class",
2578
+ "description": "",
2579
+ "name": "UseLocaleElement",
2580
+ "members": [],
2581
+ "attributes": [
2582
+ {
2583
+ "name": "lang",
2584
+ "type": {
2585
+ "text": "string"
2586
+ },
2587
+ "fieldName": "lang"
2588
+ }
2589
+ ],
2590
+ "superclass": {
2591
+ "name": "LitElement",
2592
+ "package": "lit"
2593
+ },
2594
+ "customElement": true
2595
+ }
2596
+ ],
2597
+ "exports": [
2598
+ {
2599
+ "kind": "js",
2600
+ "name": "UseLocaleElement",
2601
+ "declaration": {
2602
+ "name": "UseLocaleElement",
2603
+ "module": "src/elements/use-locale-element/use-locale-element.ts"
2604
+ }
2605
+ }
2606
+ ]
2607
+ },
2607
2608
  {
2608
2609
  "kind": "javascript-module",
2609
2610
  "path": "src/elements/use-menu/use-menu.ts",
@@ -2756,15 +2757,6 @@
2756
2757
  "attribute": "year",
2757
2758
  "reflects": true
2758
2759
  },
2759
- {
2760
- "kind": "field",
2761
- "name": "locale",
2762
- "type": {
2763
- "text": "string"
2764
- },
2765
- "description": "BCP 47 locale tag used for month name localisation. Defaults to `navigator.language`.",
2766
- "attribute": "locale"
2767
- },
2768
2760
  {
2769
2761
  "kind": "field",
2770
2762
  "name": "min",
@@ -2859,14 +2851,6 @@
2859
2851
  "description": "Year currently shown in the grid. Defaults to the current year, or the year of the initial value attribute.",
2860
2852
  "fieldName": "year"
2861
2853
  },
2862
- {
2863
- "name": "locale",
2864
- "type": {
2865
- "text": "string"
2866
- },
2867
- "description": "BCP 47 locale tag used for month name localisation. Defaults to `navigator.language`.",
2868
- "fieldName": "locale"
2869
- },
2870
2854
  {
2871
2855
  "name": "min",
2872
2856
  "type": {
@@ -2909,11 +2893,22 @@
2909
2893
  },
2910
2894
  "description": "Selected ISO 8601 year-month (`YYYY-MM`). Empty string means no selection.",
2911
2895
  "fieldName": "value"
2896
+ },
2897
+ {
2898
+ "name": "lang",
2899
+ "type": {
2900
+ "text": "string"
2901
+ },
2902
+ "fieldName": "lang",
2903
+ "inheritedFrom": {
2904
+ "name": "UseLocaleElement",
2905
+ "module": "src/elements/use-locale-element/use-locale-element.ts"
2906
+ }
2912
2907
  }
2913
2908
  ],
2914
2909
  "superclass": {
2915
- "name": "LitElement",
2916
- "package": "lit"
2910
+ "name": "UseLocaleElement",
2911
+ "module": "/src/elements/use-locale-element/use-locale-element"
2917
2912
  },
2918
2913
  "tagName": "use-month-picker",
2919
2914
  "customElement": true
@@ -3348,15 +3343,6 @@
3348
3343
  "default": "00:00:00",
3349
3344
  "attribute": "value"
3350
3345
  },
3351
- {
3352
- "kind": "field",
3353
- "name": "locale",
3354
- "type": {
3355
- "text": "string"
3356
- },
3357
- "default": "User's browser language or 'en-US'",
3358
- "attribute": "locale"
3359
- },
3360
3346
  {
3361
3347
  "kind": "field",
3362
3348
  "name": "format",
@@ -3447,14 +3433,6 @@
3447
3433
  "default": "00:00:00",
3448
3434
  "fieldName": "value"
3449
3435
  },
3450
- {
3451
- "name": "locale",
3452
- "type": {
3453
- "text": "string"
3454
- },
3455
- "default": "User's browser language or 'en-US'",
3456
- "fieldName": "locale"
3457
- },
3458
3436
  {
3459
3437
  "name": "format",
3460
3438
  "type": {
@@ -3462,11 +3440,22 @@
3462
3440
  },
3463
3441
  "default": "\"long\"",
3464
3442
  "fieldName": "format"
3443
+ },
3444
+ {
3445
+ "name": "lang",
3446
+ "type": {
3447
+ "text": "string"
3448
+ },
3449
+ "fieldName": "lang",
3450
+ "inheritedFrom": {
3451
+ "name": "UseLocaleElement",
3452
+ "module": "src/elements/use-locale-element/use-locale-element.ts"
3453
+ }
3465
3454
  }
3466
3455
  ],
3467
3456
  "superclass": {
3468
- "name": "LitElement",
3469
- "package": "lit"
3457
+ "name": "UseLocaleElement",
3458
+ "module": "/src/elements/use-locale-element/use-locale-element"
3470
3459
  },
3471
3460
  "tagName": "use-time-input",
3472
3461
  "customElement": true
@@ -3770,18 +3759,6 @@
3770
3759
  "module": "src/elements/use-calendar-base/use-calendar-base.ts"
3771
3760
  }
3772
3761
  },
3773
- {
3774
- "kind": "field",
3775
- "name": "locale",
3776
- "type": {
3777
- "text": "string"
3778
- },
3779
- "attribute": "locale",
3780
- "inheritedFrom": {
3781
- "name": "UseCalendarBase",
3782
- "module": "src/elements/use-calendar-base/use-calendar-base.ts"
3783
- }
3784
- },
3785
3762
  {
3786
3763
  "kind": "field",
3787
3764
  "name": "controls",
@@ -4245,17 +4222,6 @@
4245
4222
  "module": "src/elements/use-calendar-base/use-calendar-base.ts"
4246
4223
  }
4247
4224
  },
4248
- {
4249
- "name": "locale",
4250
- "type": {
4251
- "text": "string"
4252
- },
4253
- "fieldName": "locale",
4254
- "inheritedFrom": {
4255
- "name": "UseCalendarBase",
4256
- "module": "src/elements/use-calendar-base/use-calendar-base.ts"
4257
- }
4258
- },
4259
4225
  {
4260
4226
  "name": "controls",
4261
4227
  "type": {
@@ -4361,6 +4327,17 @@
4361
4327
  "name": "UseCalendarBase",
4362
4328
  "module": "src/elements/use-calendar-base/use-calendar-base.ts"
4363
4329
  }
4330
+ },
4331
+ {
4332
+ "name": "lang",
4333
+ "type": {
4334
+ "text": "string"
4335
+ },
4336
+ "fieldName": "lang",
4337
+ "inheritedFrom": {
4338
+ "name": "UseLocaleElement",
4339
+ "module": "src/elements/use-locale-element/use-locale-element.ts"
4340
+ }
4364
4341
  }
4365
4342
  ]
4366
4343
  }
package/dist/use-wc.d.mts CHANGED
@@ -80,13 +80,29 @@ declare global {
80
80
  }
81
81
  }
82
82
  //#endregion
83
+ //#region src/elements/use-locale-element/use-locale-element.d.ts
84
+ declare class UseLocaleElement extends LitElement {
85
+ static properties: {
86
+ lang: {
87
+ type: StringConstructor;
88
+ attribute: boolean;
89
+ };
90
+ };
91
+ private _explicitLocale;
92
+ private _unsubscribeLocale;
93
+ get lang(): string;
94
+ set lang(value: string);
95
+ connectedCallback(): void;
96
+ disconnectedCallback(): void;
97
+ }
98
+ //#endregion
83
99
  //#region src/elements/use-date-input/use-date-input.d.ts
84
100
  /**
85
101
  * Displays a date picker using segmented inputs for year, month, and day.
86
102
  *
87
103
  * Uses browser locale for formatting and ARIA labels.
88
104
  */
89
- declare class UseDateInput extends LitElement {
105
+ declare class UseDateInput extends UseLocaleElement {
90
106
  #private;
91
107
  static formAssociated: boolean;
92
108
  static shadowRootOptions: {
@@ -113,8 +129,6 @@ declare class UseDateInput extends LitElement {
113
129
  /** @default YYYY-MM-DD */
114
130
  get value(): string;
115
131
  set value(value: string);
116
- /** @default User's browser language or 'en-US' */
117
- locale: string;
118
132
  render(): TemplateResult$1<1>;
119
133
  static styles: lit.CSSResult;
120
134
  }
@@ -196,7 +210,7 @@ declare global {
196
210
  *
197
211
  * <baseline-status featureId="intl-duration-format"></baseline-status>
198
212
  */
199
- declare class UseDurationInput extends LitElement {
213
+ declare class UseDurationInput extends UseLocaleElement {
200
214
  #private;
201
215
  static formAssociated: boolean;
202
216
  static shadowRootOptions: {
@@ -236,8 +250,6 @@ declare class UseDurationInput extends LitElement {
236
250
  /** @default PT0S */
237
251
  get value(): string;
238
252
  set value(value: string);
239
- /** @default User's browser language or 'en-US' */
240
- locale: string;
241
253
  format: "long" | "short" | "narrow" | "digital";
242
254
  render(): TemplateResult$1<1>[];
243
255
  static styles: lit.CSSResult;
@@ -360,7 +372,7 @@ declare global {
360
372
  *
361
373
  * Allows users to pick time values with proper localization and formatting.
362
374
  */
363
- declare class UseTimeInput extends LitElement {
375
+ declare class UseTimeInput extends UseLocaleElement {
364
376
  #private;
365
377
  static formAssociated: boolean;
366
378
  static shadowRootOptions: {
@@ -395,8 +407,6 @@ declare class UseTimeInput extends LitElement {
395
407
  /** @default 00:00:00 */
396
408
  get value(): string;
397
409
  set value(value: string);
398
- /** @default User's browser language or 'en-US' */
399
- locale: string;
400
410
  format: "long" | "short" | "narrow" | "digital";
401
411
  render(): TemplateResult$1<1>[];
402
412
  static styles: lit.CSSResult;
@@ -723,7 +733,7 @@ type UseCalendarRenderDay = (data: {
723
733
  * @csspart picker-month - An individual month button
724
734
  * @csspart picker-month-current - Applied to the currently selected month button
725
735
  */
726
- declare class UseCalendarBase extends LitElement {
736
+ declare class UseCalendarBase extends UseLocaleElement {
727
737
  #private;
728
738
  static formAssociated: boolean;
729
739
  private gridBody;
@@ -731,7 +741,6 @@ declare class UseCalendarBase extends LitElement {
731
741
  year: number;
732
742
  /** 1-12 */
733
743
  month: number;
734
- locale: string;
735
744
  controls: boolean;
736
745
  navigation: "nowrap" | "off" | "on";
737
746
  get navigationEnabled(): boolean;
@@ -858,7 +867,7 @@ type UseMonthPickerRenderMonth = (data: {
858
867
  * @csspart month-disabled - Applied when this month falls outside min/max
859
868
  * @slot month-{YYYY-MM} - Per-month content that replaces the default month name (e.g. `month-2026-03`)
860
869
  */
861
- declare class UseMonthPicker extends LitElement {
870
+ declare class UseMonthPicker extends UseLocaleElement {
862
871
  #private;
863
872
  static formAssociated: boolean;
864
873
  static shadowRootOptions: {
@@ -873,8 +882,6 @@ declare class UseMonthPicker extends LitElement {
873
882
  /** Year currently shown in the grid. Defaults to the current year, or the year of the initial value attribute. */
874
883
  year: number;
875
884
  constructor();
876
- /** BCP 47 locale tag used for month name localisation. Defaults to `navigator.language`. */
877
- locale: string;
878
885
  /** Minimum selectable year-month in `YYYY-MM` format (inclusive). */
879
886
  min: string;
880
887
  /** Maximum selectable year-month in `YYYY-MM` format (inclusive). */
@@ -914,7 +921,7 @@ declare global {
914
921
  *
915
922
  * The value format is ISO 8601-like: `YYYY-MM-DDTHH:MM:SS.mmm`.
916
923
  */
917
- declare class UseDatetimeInput extends LitElement {
924
+ declare class UseDatetimeInput extends UseLocaleElement {
918
925
  #private;
919
926
  static formAssociated: boolean;
920
927
  static shadowRootOptions: {
@@ -934,8 +941,6 @@ declare class UseDatetimeInput extends LitElement {
934
941
  get disabled(): boolean;
935
942
  set readOnly(flag: boolean);
936
943
  get readOnly(): boolean;
937
- /** @default User's browser language or 'en-US' */
938
- locale: string;
939
944
  hours: boolean;
940
945
  minutes: boolean;
941
946
  seconds: boolean;
package/dist/use-wc.mjs CHANGED
@@ -96,6 +96,66 @@ __decorate([property({ type: Boolean })], UseOption.prototype, "disabled", null)
96
96
  __decorate([property()], UseOption.prototype, "value", null);
97
97
  UseOption = __decorate([customElement("use-option")], UseOption);
98
98
  //#endregion
99
+ //#region src/utils/locale.ts
100
+ const localeChangeSubscribers = /* @__PURE__ */ new Set();
101
+ let observer;
102
+ function getOrCreateObserver() {
103
+ if (!observer) {
104
+ observer = new MutationObserver(() => {
105
+ for (const subscriber of localeChangeSubscribers) subscriber();
106
+ });
107
+ observer.observe(document.documentElement, {
108
+ attributes: true,
109
+ attributeFilter: ["lang"]
110
+ });
111
+ }
112
+ return observer;
113
+ }
114
+ function subscribeToLocaleChanges(callback) {
115
+ getOrCreateObserver();
116
+ localeChangeSubscribers.add(callback);
117
+ return () => {
118
+ localeChangeSubscribers.delete(callback);
119
+ };
120
+ }
121
+ function resolveLocale(element) {
122
+ const ancestor = element.closest("[lang]");
123
+ if (ancestor instanceof HTMLElement) return ancestor.getAttribute("lang") || navigator.language || "en-US";
124
+ return navigator.language || "en-US";
125
+ }
126
+ //#endregion
127
+ //#region src/elements/use-locale-element/use-locale-element.ts
128
+ var UseLocaleElement = class extends LitElement {
129
+ static {
130
+ this.properties = {
131
+ ...LitElement.properties,
132
+ lang: {
133
+ type: String,
134
+ attribute: true
135
+ }
136
+ };
137
+ }
138
+ get lang() {
139
+ return this._explicitLocale ?? resolveLocale(this);
140
+ }
141
+ set lang(value) {
142
+ const previous = this.lang;
143
+ this._explicitLocale = value;
144
+ this.requestUpdate("locale", previous);
145
+ }
146
+ connectedCallback() {
147
+ super.connectedCallback();
148
+ this._unsubscribeLocale = subscribeToLocaleChanges(() => {
149
+ if (this._explicitLocale === void 0) this.requestUpdate("locale");
150
+ });
151
+ }
152
+ disconnectedCallback() {
153
+ super.disconnectedCallback();
154
+ this._unsubscribeLocale?.();
155
+ this._unsubscribeLocale = void 0;
156
+ }
157
+ };
158
+ //#endregion
99
159
  //#region src/utils/date-time-aria-labels.ts
100
160
  const DEFAULT_ARIA_LABELS = {
101
161
  am: "AM",
@@ -219,7 +279,7 @@ function parseISOWeek(week) {
219
279
  }
220
280
  //#endregion
221
281
  //#region src/elements/use-date-input/use-date-input.ts
222
- let UseDateInput = class UseDateInput extends LitElement {
282
+ let UseDateInput = class UseDateInput extends UseLocaleElement {
223
283
  static {
224
284
  this.formAssociated = true;
225
285
  }
@@ -236,7 +296,6 @@ let UseDateInput = class UseDateInput extends LitElement {
236
296
  #formatParts = [];
237
297
  constructor() {
238
298
  super();
239
- this.locale = navigator.language || "en-US";
240
299
  this.#internals = this.attachInternals();
241
300
  this.#formId = this.closest("form")?.id;
242
301
  this.#id = this.hasAttribute("id") ? this.getAttribute("id") : createId();
@@ -269,7 +328,7 @@ let UseDateInput = class UseDateInput extends LitElement {
269
328
  }
270
329
  #initialFormatParts() {
271
330
  try {
272
- const formatter = new Intl.DateTimeFormat(this.locale, {
331
+ const formatter = new Intl.DateTimeFormat(this.lang, {
273
332
  year: "numeric",
274
333
  month: "2-digit",
275
334
  day: "2-digit",
@@ -287,7 +346,7 @@ let UseDateInput = class UseDateInput extends LitElement {
287
346
  this.#formatParts = this.#initialFormatParts();
288
347
  }
289
348
  #initialAriaLabels() {
290
- return getDateTimeAriaLabels(this.locale, { plural: false });
349
+ return getDateTimeAriaLabels(this.lang, { plural: false });
291
350
  }
292
351
  #valueData = {
293
352
  year: "",
@@ -415,10 +474,6 @@ __decorate([property({
415
474
  attribute: "readonly"
416
475
  })], UseDateInput.prototype, "readOnly", null);
417
476
  __decorate([property({ type: String })], UseDateInput.prototype, "value", null);
418
- __decorate([property({
419
- type: String,
420
- attribute: true
421
- })], UseDateInput.prototype, "locale", void 0);
422
477
  UseDateInput = __decorate([customElement("use-date-input")], UseDateInput);
423
478
  //#endregion
424
479
  //#region src/elements/use-dropdown/use-dropdown.ts
@@ -671,7 +726,7 @@ const ISO_DURATION_SEGMENTS = {
671
726
  second: "seconds",
672
727
  millisecond: "milliseconds"
673
728
  };
674
- let UseDurationInput = class UseDurationInput extends LitElement {
729
+ let UseDurationInput = class UseDurationInput extends UseLocaleElement {
675
730
  static {
676
731
  this.formAssociated = true;
677
732
  }
@@ -693,7 +748,6 @@ let UseDurationInput = class UseDurationInput extends LitElement {
693
748
  this.minutes = false;
694
749
  this.seconds = false;
695
750
  this.milliseconds = false;
696
- this.locale = navigator.language || "en-US";
697
751
  this.format = "short";
698
752
  this.#internals = this.attachInternals();
699
753
  this.#formId = this.closest("form")?.id;
@@ -752,7 +806,7 @@ let UseDurationInput = class UseDurationInput extends LitElement {
752
806
  #ariaLabels = DEFAULT_ARIA_LABELS;
753
807
  #initialFormatParts() {
754
808
  try {
755
- return new Intl.DurationFormat(this.locale, { style: this.format }).formatToParts({
809
+ return new Intl.DurationFormat(this.lang, { style: this.format }).formatToParts({
756
810
  years: this.years ? 2 : 0,
757
811
  months: this.months ? 2 : 0,
758
812
  weeks: this.weeks ? 2 : 0,
@@ -797,7 +851,7 @@ let UseDurationInput = class UseDurationInput extends LitElement {
797
851
  if (this.millisecondInput) this.millisecondInput.value = String(this.#valueData.milliseconds ?? 0);
798
852
  }
799
853
  #initialAriaLabels() {
800
- return getDateTimeAriaLabels(this.locale, { plural: true });
854
+ return getDateTimeAriaLabels(this.lang, { plural: true });
801
855
  }
802
856
  render() {
803
857
  return Array.from(this.#groupedParts.entries()).map(([unit, parts]) => {
@@ -898,10 +952,6 @@ __decorate([property({
898
952
  attribute: "readonly"
899
953
  })], UseDurationInput.prototype, "readOnly", null);
900
954
  __decorate([property({ type: String })], UseDurationInput.prototype, "value", null);
901
- __decorate([property({
902
- type: String,
903
- attribute: true
904
- })], UseDurationInput.prototype, "locale", void 0);
905
955
  __decorate([property({
906
956
  type: String,
907
957
  attribute: true
@@ -1335,7 +1385,7 @@ __decorate([query("[part=\"trigger-label\"]", true)], UseSelectInput.prototype,
1335
1385
  UseSelectInput = __decorate([customElement("use-select-input")], UseSelectInput);
1336
1386
  //#endregion
1337
1387
  //#region src/elements/use-time-input/use-time-input.ts
1338
- let UseTimeInput = class UseTimeInput extends LitElement {
1388
+ let UseTimeInput = class UseTimeInput extends UseLocaleElement {
1339
1389
  static {
1340
1390
  this.formAssociated = true;
1341
1391
  }
@@ -1359,7 +1409,6 @@ let UseTimeInput = class UseTimeInput extends LitElement {
1359
1409
  this.seconds = false;
1360
1410
  this.fractionalSeconds = false;
1361
1411
  this.dayPeriod = false;
1362
- this.locale = navigator.language || "en-US";
1363
1412
  this.format = "long";
1364
1413
  this.#internals = this.attachInternals();
1365
1414
  this.#formId = this.closest("form")?.id;
@@ -1462,7 +1511,7 @@ let UseTimeInput = class UseTimeInput extends LitElement {
1462
1511
  }
1463
1512
  #formatParts = [];
1464
1513
  #initializeHourFormat() {
1465
- if (!this.hourFormat) this.hourFormat = new Intl.DateTimeFormat(this.locale, { hour: "numeric" }).resolvedOptions().hour12 ? "12" : "24";
1514
+ if (!this.hourFormat) this.hourFormat = new Intl.DateTimeFormat(this.lang, { hour: "numeric" }).resolvedOptions().hour12 ? "12" : "24";
1466
1515
  }
1467
1516
  #initialFormatParts() {
1468
1517
  try {
@@ -1476,11 +1525,11 @@ let UseTimeInput = class UseTimeInput extends LitElement {
1476
1525
  hour12: this.hourFormat ? this.hourFormat === "12" : void 0,
1477
1526
  timeZone: "UTC"
1478
1527
  };
1479
- const formatter = new Intl.DateTimeFormat(this.locale, options);
1528
+ const formatter = new Intl.DateTimeFormat(this.lang, options);
1480
1529
  const date = new Date(2024, 0, 1, 12, 30, 45);
1481
1530
  const parts = formatter.formatToParts(date);
1482
1531
  this.#maxHours = !!formatter.resolvedOptions().hour12 && this.dayPeriod ? 12 : 23;
1483
- this.#ariaLabels = getDateTimeAriaLabels(this.locale);
1532
+ this.#ariaLabels = getDateTimeAriaLabels(this.lang);
1484
1533
  const [amChar, pmChar] = this.#ariaLabels.dayPeriod.split("/").map((char) => char.toLowerCase().charAt(0));
1485
1534
  this.#amChar = amChar;
1486
1535
  this.#pmChar = pmChar;
@@ -1696,10 +1745,6 @@ __decorate([property({
1696
1745
  type: String,
1697
1746
  attribute: true
1698
1747
  })], UseTimeInput.prototype, "value", null);
1699
- __decorate([property({
1700
- type: String,
1701
- attribute: true
1702
- })], UseTimeInput.prototype, "locale", void 0);
1703
1748
  __decorate([property({
1704
1749
  type: String,
1705
1750
  attribute: true
@@ -2701,7 +2746,7 @@ const INITIAL_TABINDEX_ATTR = "data-usewc-calendar-tabindex";
2701
2746
  * @csspart picker-month - An individual month button
2702
2747
  * @csspart picker-month-current - Applied to the currently selected month button
2703
2748
  */
2704
- var UseCalendarBase = class extends LitElement {
2749
+ var UseCalendarBase = class extends UseLocaleElement {
2705
2750
  static {
2706
2751
  this.formAssociated = true;
2707
2752
  }
@@ -2735,7 +2780,6 @@ var UseCalendarBase = class extends LitElement {
2735
2780
  super();
2736
2781
  this.year = (/* @__PURE__ */ new Date()).getFullYear();
2737
2782
  this.month = (/* @__PURE__ */ new Date()).getMonth() + 1;
2738
- this.locale = navigator.language;
2739
2783
  this.controls = false;
2740
2784
  this.navigation = "on";
2741
2785
  this.hiddenmonths = "";
@@ -2843,7 +2887,7 @@ var UseCalendarBase = class extends LitElement {
2843
2887
  }
2844
2888
  get #previousMonthLabel() {
2845
2889
  const { year, month } = this.#previousMonthData;
2846
- return new Intl.DateTimeFormat(this.locale, {
2890
+ return new Intl.DateTimeFormat(this.lang, {
2847
2891
  month: "long",
2848
2892
  year: "numeric",
2849
2893
  timeZone: "UTC"
@@ -2851,7 +2895,7 @@ var UseCalendarBase = class extends LitElement {
2851
2895
  }
2852
2896
  get #nextMonthLabel() {
2853
2897
  const { year, month } = this.#nextMonthData;
2854
- return new Intl.DateTimeFormat(this.locale, {
2898
+ return new Intl.DateTimeFormat(this.lang, {
2855
2899
  month: "long",
2856
2900
  year: "numeric",
2857
2901
  timeZone: "UTC"
@@ -2867,14 +2911,14 @@ var UseCalendarBase = class extends LitElement {
2867
2911
  };
2868
2912
  }
2869
2913
  get #startDayOffset() {
2870
- return (new Date(this.year, this.month - 1, 1).getDay() - getLocaleFirstDay(this.locale) + 7) % 7;
2914
+ return (new Date(this.year, this.month - 1, 1).getDay() - getLocaleFirstDay(this.lang) + 7) % 7;
2871
2915
  }
2872
2916
  #weekdayNames() {
2873
- return getDayNames(this.locale, "short");
2917
+ return getDayNames(this.lang, "short");
2874
2918
  }
2875
2919
  get #title() {
2876
2920
  try {
2877
- const formatter = new Intl.DateTimeFormat(this.locale, {
2921
+ const formatter = new Intl.DateTimeFormat(this.lang, {
2878
2922
  year: "numeric",
2879
2923
  month: "long",
2880
2924
  day: void 0,
@@ -3174,7 +3218,7 @@ var UseCalendarBase = class extends LitElement {
3174
3218
  }
3175
3219
  };
3176
3220
  #renderPicker() {
3177
- const months = getMonthNames(this.locale, "short");
3221
+ const months = getMonthNames(this.lang, "short");
3178
3222
  const startYear = this.min ? this.#parseDate(this.min)?.getFullYear() ?? 1970 : 1970;
3179
3223
  const endYear = this.max ? this.#parseDate(this.max)?.getFullYear() ?? (/* @__PURE__ */ new Date()).getFullYear() + 100 : (/* @__PURE__ */ new Date()).getFullYear() + 100;
3180
3224
  const years = Array.from({ length: endYear - startYear + 1 }, (_, i) => startYear + i);
@@ -3225,7 +3269,7 @@ var UseCalendarBase = class extends LitElement {
3225
3269
  const endDate = this.#endDate;
3226
3270
  const startDay = startDate && this.#isThisMonth(startDate) ? startDate.getDate() : 1;
3227
3271
  const endDay = endDate && this.#isThisMonth(endDate) ? endDate.getDate() : daysInMonth;
3228
- const localeFirstDay = getLocaleFirstDay(this.locale);
3272
+ const localeFirstDay = getLocaleFirstDay(this.lang);
3229
3273
  const firstDay = startDate && this.#isThisMonth(startDate) ? (startDate.getDay() - localeFirstDay + 7) % 7 : this.#startDayOffset;
3230
3274
  let rowIndex = 1;
3231
3275
  let columnIndex = 1;
@@ -3416,7 +3460,6 @@ __decorate([property({
3416
3460
  attribute: true,
3417
3461
  reflect: true
3418
3462
  })], UseCalendarBase.prototype, "month", void 0);
3419
- __decorate([property({ type: String })], UseCalendarBase.prototype, "locale", void 0);
3420
3463
  __decorate([property({
3421
3464
  type: Boolean,
3422
3465
  attribute: true,
@@ -3599,7 +3642,7 @@ let UseWeekPicker = class UseWeekPicker extends UseCalendarBase {
3599
3642
  UseWeekPicker = __decorate([customElement("use-week-picker")], UseWeekPicker);
3600
3643
  //#endregion
3601
3644
  //#region src/elements/use-month-picker/use-month-picker.ts
3602
- let UseMonthPicker = class UseMonthPicker extends LitElement {
3645
+ let UseMonthPicker = class UseMonthPicker extends UseLocaleElement {
3603
3646
  static {
3604
3647
  this.formAssociated = true;
3605
3648
  }
@@ -3660,7 +3703,6 @@ let UseMonthPicker = class UseMonthPicker extends LitElement {
3660
3703
  constructor() {
3661
3704
  super();
3662
3705
  this.year = (/* @__PURE__ */ new Date()).getFullYear();
3663
- this.locale = navigator.language || "en-US";
3664
3706
  this.min = "";
3665
3707
  this.max = "";
3666
3708
  this.navigation = "on";
@@ -3835,7 +3877,7 @@ let UseMonthPicker = class UseMonthPicker extends LitElement {
3835
3877
  const today = /* @__PURE__ */ new Date();
3836
3878
  const todayYear = today.getFullYear();
3837
3879
  const todayMonth = today.getMonth() + 1;
3838
- const months = getMonthNames(this.locale, "short");
3880
+ const months = getMonthNames(this.lang, "short");
3839
3881
  const minYear = this.#minYear;
3840
3882
  const maxYear = this.#maxYear;
3841
3883
  const prevDisabled = this.disabled || minYear !== null && this.year <= minYear;
@@ -3914,7 +3956,6 @@ __decorate([property({
3914
3956
  type: Number,
3915
3957
  reflect: true
3916
3958
  })], UseMonthPicker.prototype, "year", void 0);
3917
- __decorate([property({ type: String })], UseMonthPicker.prototype, "locale", void 0);
3918
3959
  __decorate([property({ type: String })], UseMonthPicker.prototype, "min", void 0);
3919
3960
  __decorate([property({ type: String })], UseMonthPicker.prototype, "max", void 0);
3920
3961
  __decorate([property({ type: String })], UseMonthPicker.prototype, "navigation", void 0);
@@ -3923,7 +3964,7 @@ __decorate([property({ type: String })], UseMonthPicker.prototype, "value", null
3923
3964
  UseMonthPicker = __decorate([customElement("use-month-picker")], UseMonthPicker);
3924
3965
  //#endregion
3925
3966
  //#region src/elements/use-datetime-input/use-datetime-input.ts
3926
- let UseDatetimeInput = class UseDatetimeInput extends LitElement {
3967
+ let UseDatetimeInput = class UseDatetimeInput extends UseLocaleElement {
3927
3968
  static {
3928
3969
  this.formAssociated = true;
3929
3970
  }
@@ -3937,7 +3978,6 @@ let UseDatetimeInput = class UseDatetimeInput extends LitElement {
3937
3978
  #id;
3938
3979
  constructor() {
3939
3980
  super();
3940
- this.locale = navigator.language || "en-US";
3941
3981
  this.hours = false;
3942
3982
  this.minutes = false;
3943
3983
  this.seconds = false;
@@ -4008,7 +4048,7 @@ let UseDatetimeInput = class UseDatetimeInput extends LitElement {
4008
4048
  value=${this.#dateValue}
4009
4049
  .disabled=${this.disabled}
4010
4050
  .readOnly=${this.readOnly}
4011
- .locale=${this.locale}
4051
+ .lang=${this.lang}
4012
4052
  @input=${this.#handleInput}
4013
4053
  exportparts="segment-input, segment-literal"
4014
4054
  ></use-date-input>
@@ -4017,7 +4057,7 @@ let UseDatetimeInput = class UseDatetimeInput extends LitElement {
4017
4057
  value=${this.#timeValue}
4018
4058
  .disabled=${this.disabled}
4019
4059
  .readOnly=${this.readOnly}
4020
- .locale=${this.locale}
4060
+ .lang=${this.lang}
4021
4061
  .hours=${this.hours}
4022
4062
  .minutes=${this.minutes}
4023
4063
  .seconds=${this.seconds}
@@ -4046,10 +4086,6 @@ __decorate([property({
4046
4086
  type: Boolean,
4047
4087
  attribute: "readonly"
4048
4088
  })], UseDatetimeInput.prototype, "readOnly", null);
4049
- __decorate([property({
4050
- type: String,
4051
- attribute: true
4052
- })], UseDatetimeInput.prototype, "locale", void 0);
4053
4089
  __decorate([property({
4054
4090
  type: Boolean,
4055
4091
  attribute: true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "use-wc",
3
- "version": "1.0.0-pre.32",
3
+ "version": "1.0.0-pre.33",
4
4
  "private": false,
5
5
  "homepage": "https://usewc.com",
6
6
  "bugs": "https://github.com/dang-rabbits/use-wc/issues",
@@ -9,7 +9,7 @@
9
9
  { "name": "disabled", "values": [] },
10
10
  { "name": "readonly", "values": [] },
11
11
  { "name": "value", "values": [] },
12
- { "name": "locale", "values": [] }
12
+ { "name": "lang", "values": [] }
13
13
  ],
14
14
  "references": []
15
15
  },
@@ -25,7 +25,6 @@
25
25
  "attributes": [
26
26
  { "name": "year", "description": "1970-9999", "values": [] },
27
27
  { "name": "month", "description": "1-12", "values": [] },
28
- { "name": "locale", "values": [] },
29
28
  { "name": "controls", "values": [] },
30
29
  {
31
30
  "name": "navigation",
@@ -48,7 +47,8 @@
48
47
  "name": "end",
49
48
  "description": "Last date in the visible range. Accepts ISO 8601 date strings or `'max'` to use the same value as `max`",
50
49
  "values": []
51
- }
50
+ },
51
+ { "name": "lang", "values": [] }
52
52
  ],
53
53
  "references": []
54
54
  },
@@ -58,7 +58,6 @@
58
58
  "attributes": [
59
59
  { "name": "disabled", "values": [] },
60
60
  { "name": "readonly", "values": [] },
61
- { "name": "locale", "values": [] },
62
61
  { "name": "hours", "values": [] },
63
62
  { "name": "minutes", "values": [] },
64
63
  { "name": "seconds", "values": [] },
@@ -68,7 +67,8 @@
68
67
  "name": "hourFormat",
69
68
  "values": [{ "name": "12" }, { "name": "24" }]
70
69
  },
71
- { "name": "value", "values": [] }
70
+ { "name": "value", "values": [] },
71
+ { "name": "lang", "values": [] }
72
72
  ],
73
73
  "references": []
74
74
  },
@@ -96,7 +96,6 @@
96
96
  { "name": "disabled", "values": [] },
97
97
  { "name": "readonly", "values": [] },
98
98
  { "name": "value", "values": [] },
99
- { "name": "locale", "values": [] },
100
99
  {
101
100
  "name": "format",
102
101
  "values": [
@@ -105,7 +104,8 @@
105
104
  { "name": "narrow" },
106
105
  { "name": "digital" }
107
106
  ]
108
- }
107
+ },
108
+ { "name": "lang", "values": [] }
109
109
  ],
110
110
  "references": []
111
111
  },
@@ -207,11 +207,6 @@
207
207
  "description": "Year currently shown in the grid. Defaults to the current year, or the year of the initial value attribute.",
208
208
  "values": []
209
209
  },
210
- {
211
- "name": "locale",
212
- "description": "BCP 47 locale tag used for month name localisation. Defaults to `navigator.language`.",
213
- "values": []
214
- },
215
210
  {
216
211
  "name": "min",
217
212
  "description": "Minimum selectable year-month in `YYYY-MM` format (inclusive).",
@@ -236,7 +231,8 @@
236
231
  "name": "value",
237
232
  "description": "Selected ISO 8601 year-month (`YYYY-MM`). Empty string means no selection.",
238
233
  "values": []
239
- }
234
+ },
235
+ { "name": "lang", "values": [] }
240
236
  ],
241
237
  "references": []
242
238
  },
@@ -282,7 +278,6 @@
282
278
  { "name": "disabled", "values": [] },
283
279
  { "name": "readonly", "values": [] },
284
280
  { "name": "value", "values": [] },
285
- { "name": "locale", "values": [] },
286
281
  {
287
282
  "name": "format",
288
283
  "values": [
@@ -291,7 +286,8 @@
291
286
  { "name": "narrow" },
292
287
  { "name": "digital" }
293
288
  ]
294
- }
289
+ },
290
+ { "name": "lang", "values": [] }
295
291
  ],
296
292
  "references": []
297
293
  },
@@ -322,7 +318,6 @@
322
318
  "attributes": [
323
319
  { "name": "year", "description": "1970-9999", "values": [] },
324
320
  { "name": "month", "description": "1-12", "values": [] },
325
- { "name": "locale", "values": [] },
326
321
  { "name": "controls", "values": [] },
327
322
  {
328
323
  "name": "navigation",
@@ -345,7 +340,8 @@
345
340
  "name": "end",
346
341
  "description": "Last date in the visible range. Accepts ISO 8601 date strings or `'max'` to use the same value as `max`",
347
342
  "values": []
348
- }
343
+ },
344
+ { "name": "lang", "values": [] }
349
345
  ],
350
346
  "references": []
351
347
  },