@oscarpalmer/oui 0.39.0 → 0.40.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.
Files changed (182) hide show
  1. package/README.md +1 -1
  2. package/dist/js/color-picker/color-picker.constants.d.mts +2 -0
  3. package/dist/js/color-picker/{constants.color-picker.mjs → color-picker.constants.mjs} +5 -4
  4. package/dist/js/color-picker/{dom.color-picker.d.mts → color-picker.dom.d.mts} +2 -2
  5. package/dist/js/color-picker/{dom.color-picker.mjs → color-picker.dom.mjs} +3 -3
  6. package/dist/js/color-picker/{event.color-picker.d.mts → color-picker.event.d.mts} +2 -2
  7. package/dist/js/color-picker/{event.color-picker.mjs → color-picker.event.mjs} +1 -1
  8. package/dist/js/color-picker/{form.color-picker.d.mts → color-picker.form.d.mts} +2 -2
  9. package/dist/js/color-picker/{form.color-picker.mjs → color-picker.form.mjs} +9 -6
  10. package/dist/js/color-picker/color-picker.misc.d.mts +2 -0
  11. package/dist/js/color-picker/{misc.color-picker.mjs → color-picker.misc.mjs} +1 -1
  12. package/dist/js/color-picker/color-picker.model.d.mts +2 -0
  13. package/dist/js/color-picker/{models.color-picker.mjs → color-picker.model.mjs} +1 -1
  14. package/dist/js/color-picker/{output.color-picker.d.mts → color-picker.output.d.mts} +2 -2
  15. package/dist/js/color-picker/{output.color-picker.mjs → color-picker.output.mjs} +13 -11
  16. package/dist/js/color-picker/color-picker.state.d.mts +8 -0
  17. package/dist/js/color-picker/color-picker.state.mjs +2 -0
  18. package/dist/js/color-picker/index.d.mts +180 -2
  19. package/dist/js/color-picker/index.mjs +59 -57
  20. package/dist/js/color-picker.constants-D1mxw_Le.d.mts +179 -0
  21. package/dist/js/{event.color-picker-BEpq0Adu.mjs → color-picker.event-Cksj5TvS.mjs} +105 -90
  22. package/dist/js/color-picker.misc-CtsXGrOe.d.mts +27 -0
  23. package/dist/js/combobox/combobox.constants.d.mts +2 -0
  24. package/dist/js/combobox/{constants.combobox.mjs → combobox.constants.mjs} +21 -21
  25. package/dist/js/combobox/{dom.combobox.d.mts → combobox.dom.d.mts} +3 -3
  26. package/dist/js/combobox/{dom.combobox.mjs → combobox.dom.mjs} +40 -36
  27. package/dist/js/combobox/{event.combobox.d.mts → combobox.event.d.mts} +3 -3
  28. package/dist/js/combobox/{event.combobox.mjs → combobox.event.mjs} +1 -1
  29. package/dist/js/combobox/combobox.misc.d.mts +2 -0
  30. package/dist/js/combobox/{misc.combobox.mjs → combobox.misc.mjs} +1 -1
  31. package/dist/js/combobox/combobox.model.d.mts +2 -0
  32. package/dist/js/combobox/combobox.state.d.mts +10 -0
  33. package/dist/js/combobox/combobox.state.mjs +2 -0
  34. package/dist/js/combobox/index.d.mts +163 -2
  35. package/dist/js/combobox/index.mjs +53 -52
  36. package/dist/js/combobox.constants-DZVkMP5g.d.mts +19 -0
  37. package/dist/js/combobox.misc-C1tPZZDi.d.mts +22 -0
  38. package/dist/js/combobox.model-oDV06XCN.d.mts +44 -0
  39. package/dist/js/{state.combobox-BWDFHwoi.mjs → combobox.state-BfJ3Hxg8.mjs} +94 -80
  40. package/dist/js/constants.listbox-C5Ap6Ag_.d.mts +9 -0
  41. package/dist/js/dialog/dialog.model.d.mts +2 -0
  42. package/dist/js/dialog/dialog.model.mjs +11 -0
  43. package/dist/js/dialog/index.d.mts +12 -0
  44. package/dist/js/dialog/index.mjs +123 -0
  45. package/dist/js/dialog.model-DX2mndMh.d.mts +45 -0
  46. package/dist/js/floatable/floatable.embedded.d.mts +2 -2
  47. package/dist/js/floatable/floatable.embedded.mjs +64 -92
  48. package/dist/js/floatable/floatable.model.d.mts +2 -0
  49. package/dist/js/floatable/floatable.model.mjs +23 -0
  50. package/dist/js/floatable/floatable.standalone.d.mts +2 -1
  51. package/dist/js/floatable.embedded-MeTyXjFn.d.mts +17 -0
  52. package/dist/js/{floatable.embedded-DQYkXt8X.d.mts → floatable.model-DXsQgoU7.d.mts} +13 -20
  53. package/dist/js/focus-trap/focus-trap.embedded.d.mts +2 -2
  54. package/dist/js/focus-trap/focus-trap.embedded.mjs +113 -135
  55. package/dist/js/focus-trap/focus-trap.model.d.mts +2 -0
  56. package/dist/js/focus-trap/focus-trap.model.mjs +15 -0
  57. package/dist/js/focus-trap/focus-trap.standalone.d.mts +2 -1
  58. package/dist/js/focus-trap.embedded-DIU05m1z.d.mts +13 -0
  59. package/dist/js/{focus-trap.embedded-CjyFQYow.d.mts → focus-trap.model-BeX6UYlw.d.mts} +16 -18
  60. package/dist/js/index.d.mts +26 -14
  61. package/dist/js/index.mjs +18 -17
  62. package/dist/js/internal/attributable.mjs +3 -2
  63. package/dist/js/internal/draggable/draggable.model.d.mts +2 -0
  64. package/dist/js/internal/draggable/draggable.model.mjs +37 -0
  65. package/dist/js/internal/draggable/index.d.mts +13 -0
  66. package/dist/js/internal/{draggable.mjs → draggable/index.mjs} +82 -113
  67. package/dist/js/internal/listbox/listbox.constants.d.mts +1 -1
  68. package/dist/js/internal/listbox/listbox.data.d.mts +1 -1
  69. package/dist/js/internal/listbox/listbox.data.mjs +1 -1
  70. package/dist/js/internal/listbox/listbox.dom.d.mts +1 -1
  71. package/dist/js/internal/listbox/listbox.dom.mjs +1 -1
  72. package/dist/js/internal/listbox/listbox.event.d.mts +1 -1
  73. package/dist/js/internal/listbox/listbox.event.mjs +20 -17
  74. package/dist/js/internal/listbox/listbox.form.d.mts +1 -1
  75. package/dist/js/internal/listbox/listbox.form.mjs +15 -12
  76. package/dist/js/internal/listbox/listbox.misc.d.mts +1 -1
  77. package/dist/js/internal/listbox/listbox.misc.mjs +1 -1
  78. package/dist/js/internal/listbox/listbox.model.d.mts +2 -2
  79. package/dist/js/internal/listbox/listbox.state.d.mts +4 -4
  80. package/dist/js/internal/listbox/listbox.state.mjs +19 -20
  81. package/dist/js/internal/misc.d.mts +1 -0
  82. package/dist/js/internal/misc.mjs +4 -6
  83. package/dist/js/internal/navigable/index.d.mts +6 -0
  84. package/dist/js/internal/navigable/index.mjs +125 -0
  85. package/dist/js/internal/navigable/navigable.model.d.mts +2 -0
  86. package/dist/js/internal/navigable/navigable.model.mjs +18 -0
  87. package/dist/js/l10n/index.d.mts +9 -0
  88. package/dist/js/{l10n.mjs → l10n/index.mjs} +50 -23
  89. package/dist/js/l10n/l10n.model.d.mts +2 -0
  90. package/dist/js/l10n/l10n.model.mjs +9 -0
  91. package/dist/js/l10n.model-D6a9frgl.d.mts +26 -0
  92. package/dist/js/listbox/constants.listbox.d.mts +2 -2
  93. package/dist/js/listbox/constants.listbox.mjs +10 -14
  94. package/dist/js/listbox/event.listbox.d.mts +1 -1
  95. package/dist/js/listbox/event.listbox.mjs +47 -1
  96. package/dist/js/listbox/index.d.mts +6 -4
  97. package/dist/js/listbox/index.mjs +47 -49
  98. package/dist/js/listbox/misc.listbox.d.mts +1 -1
  99. package/dist/js/listbox/misc.listbox.mjs +1 -1
  100. package/dist/js/listbox/state.listbox.d.mts +4 -5
  101. package/dist/js/listbox/state.listbox.mjs +2 -2
  102. package/dist/js/{listbox.data-DQ7-x2uY.mjs → listbox.data-BQyZGKgr.mjs} +87 -70
  103. package/dist/js/{listbox.model-BHPA7GM4.d.mts → listbox.model-CuBOj4qe.d.mts} +12 -8
  104. package/dist/js/menu/index.mjs +167 -0
  105. package/dist/js/menu/menu.model.d.mts +33 -0
  106. package/dist/js/menu/menu.model.mjs +15 -0
  107. package/dist/js/{misc.listbox-DKB-j0UK.mjs → misc.listbox-CjfBUbHD.mjs} +25 -67
  108. package/dist/js/{misc.listbox-mZMuYOxg.d.mts → misc.listbox-CtoGvXQo.d.mts} +2 -2
  109. package/dist/js/movable/movable.embedded.d.mts +2 -2
  110. package/dist/js/movable/movable.embedded.mjs +60 -72
  111. package/dist/js/movable/movable.model.d.mts +2 -0
  112. package/dist/js/movable/movable.model.mjs +12 -0
  113. package/dist/js/movable/movable.standalone.d.mts +2 -1
  114. package/dist/js/movable.embedded-DoyXLegc.d.mts +11 -0
  115. package/dist/js/{draggable-B5-70SZm.d.mts → movable.model-BHaK_mKw.d.mts} +81 -50
  116. package/dist/js/navigable.model-BPOM8DZk.d.mts +44 -0
  117. package/dist/js/popover/index.d.mts +12 -0
  118. package/dist/js/{popover.mjs → popover/index.mjs} +41 -51
  119. package/dist/js/popover/popover.model.d.mts +2 -0
  120. package/dist/js/popover/popover.model.mjs +12 -0
  121. package/dist/js/popover.model-ubKNG612.d.mts +38 -0
  122. package/dist/js/resizable/resizable.embedded.d.mts +2 -2
  123. package/dist/js/resizable/resizable.embedded.mjs +43 -58
  124. package/dist/js/resizable/resizable.model.d.mts +2 -0
  125. package/dist/js/resizable/resizable.model.mjs +21 -0
  126. package/dist/js/resizable/resizable.standalone.d.mts +2 -1
  127. package/dist/js/resizable.embedded-Bf1qBUdt.d.mts +11 -0
  128. package/dist/js/resizable.model-BwzJcTVJ.d.mts +46 -0
  129. package/dist/js/sortable/sortable.embedded.d.mts +2 -2
  130. package/dist/js/sortable/sortable.embedded.mjs +69 -82
  131. package/dist/js/sortable/sortable.model.d.mts +2 -0
  132. package/dist/js/sortable/sortable.model.mjs +24 -0
  133. package/dist/js/sortable/sortable.standalone.d.mts +2 -1
  134. package/dist/js/sortable.embedded-DzBKAwSG.d.mts +11 -0
  135. package/dist/js/{splitter.d.mts → splitter/index.d.mts} +6 -4
  136. package/dist/js/{splitter.mjs → splitter/index.mjs} +90 -128
  137. package/dist/js/splitter/splitter.model.d.mts +2 -0
  138. package/dist/js/splitter/splitter.model.mjs +37 -0
  139. package/dist/js/splitter.model-DOLNjLVS.d.mts +57 -0
  140. package/dist/js/{tabs.d.mts → tabs/index.d.mts} +7 -7
  141. package/dist/js/{tabs.mjs → tabs/index.mjs} +58 -58
  142. package/dist/js/tabs/tabs.model.d.mts +2 -0
  143. package/dist/js/tabs/tabs.model.mjs +18 -0
  144. package/dist/js/tabs.model-DRBX_JtI.d.mts +40 -0
  145. package/dist/js/toolbar/index.mjs +27 -0
  146. package/dist/js/toolbar/toolbar.model.d.mts +11 -0
  147. package/dist/js/toolbar/toolbar.model.mjs +7 -0
  148. package/dist/js/tooltip/index.d.mts +19 -0
  149. package/dist/js/{tooltip.mjs → tooltip/index.mjs} +61 -86
  150. package/dist/js/tooltip/tooltip.model.d.mts +2 -0
  151. package/dist/js/tooltip/tooltip.model.mjs +15 -0
  152. package/dist/js/tooltip.model-DRkY_BsL.d.mts +37 -0
  153. package/package.json +30 -24
  154. package/dist/js/color-picker/constants.color-picker.d.mts +0 -2
  155. package/dist/js/color-picker/misc.color-picker.d.mts +0 -2
  156. package/dist/js/color-picker/models.color-picker.d.mts +0 -2
  157. package/dist/js/color-picker/state.color-picker.d.mts +0 -8
  158. package/dist/js/color-picker/state.color-picker.mjs +0 -2
  159. package/dist/js/combobox/constants.combobox.d.mts +0 -2
  160. package/dist/js/combobox/misc.combobox.d.mts +0 -2
  161. package/dist/js/combobox/models.combobox.d.mts +0 -43
  162. package/dist/js/combobox/state.combobox.d.mts +0 -11
  163. package/dist/js/combobox/state.combobox.mjs +0 -2
  164. package/dist/js/constants.color-picker-B-gFjL8m.d.mts +0 -364
  165. package/dist/js/constants.combobox-8EMRmv09.d.mts +0 -18
  166. package/dist/js/constants.listbox-DGnX32kv.d.mts +0 -8
  167. package/dist/js/dialog.d.mts +0 -47
  168. package/dist/js/dialog.mjs +0 -131
  169. package/dist/js/index-C5D3-oiI.d.mts +0 -177
  170. package/dist/js/internal/draggable.d.mts +0 -2
  171. package/dist/js/internal/navigable.d.mts +0 -36
  172. package/dist/js/internal/navigable.mjs +0 -135
  173. package/dist/js/l10n-Bn-7RcwR.d.mts +0 -20
  174. package/dist/js/l10n.d.mts +0 -2
  175. package/dist/js/menu.mjs +0 -172
  176. package/dist/js/popover.d.mts +0 -38
  177. package/dist/js/resizable.embedded-dvhdfQgt.d.mts +0 -34
  178. package/dist/js/toolbar.mjs +0 -31
  179. package/dist/js/tooltip.d.mts +0 -45
  180. /package/dist/js/combobox/{models.combobox.mjs → combobox.model.mjs} +0 -0
  181. /package/dist/js/{menu.d.mts → menu/index.d.mts} +0 -0
  182. /package/dist/js/{toolbar.d.mts → toolbar/index.d.mts} +0 -0
@@ -1,34 +1,36 @@
1
1
  import { LISTBOX_KEYS_NAVIGATION, LISTBOX_KEYS_SELECTION } from "./listbox.constants.mjs";
2
- import { S as getListboxVisibleOptions } from "../../listbox.data-DQ7-x2uY.mjs";
2
+ import { S as getListboxVisibleOptions } from "../../listbox.data-BQyZGKgr.mjs";
3
3
  import { clamp } from "@oscarpalmer/atoms/number";
4
4
  //#region src/js/internal/listbox/listbox.event.ts
5
5
  function processListboxKeydown(event, state) {
6
- const ignore = state.disabled || state.readonly;
7
- const isSelect = state.type === "select";
6
+ const { component, form } = state;
7
+ const { callbacks, disabled, readonly, type } = component;
8
+ const ignore = disabled || readonly;
9
+ const isSelect = type === "select";
8
10
  let preventDefault = ignore;
9
11
  switch (true) {
10
12
  case event.key === " ":
11
- if (!state.disabled) state.callbacks.keydown.onActivation?.(state);
13
+ if (!disabled) callbacks.keydown.onActivation?.(state);
12
14
  break;
13
15
  case event.key === "Enter":
14
- preventDefault = state.callbacks.keydown.preventActivation?.(state) ?? true;
15
- if (preventDefault) state.callbacks.keydown.onEnter?.(state);
16
- else if (!ignore && state.type === "select") state.callbacks.keydown.onActivation?.(state);
17
- else if (!ignore) state.internals.form?.requestSubmit();
16
+ preventDefault = callbacks.keydown.preventActivation?.(state) ?? true;
17
+ if (preventDefault) callbacks.keydown.onEnter?.(state);
18
+ else if (!ignore && type === "select") callbacks.keydown.onActivation?.(state);
19
+ else if (!ignore) form.internals.form?.requestSubmit();
18
20
  break;
19
21
  case event.key === "Escape":
20
22
  preventDefault = false;
21
- state.callbacks.keydown.onEscape?.(state);
23
+ callbacks.keydown.onEscape?.(state);
22
24
  break;
23
25
  case !isSelect && LISTBOX_KEYS_SELECTION.has(event.key):
24
- if (!ignore) state.callbacks.keydown.onSelection?.(state);
26
+ if (!ignore) callbacks.keydown.onSelection?.(state);
25
27
  break;
26
28
  case LISTBOX_KEYS_NAVIGATION.has(event.key):
27
- if (!state.disabled) onNavigation(event, state);
29
+ if (!disabled) onNavigation(event, state);
28
30
  break;
29
31
  default:
30
32
  preventDefault = false;
31
- if (event.key === "Tab") state.callbacks.keydown.onTab?.(state);
33
+ if (event.key === "Tab") callbacks.keydown.onTab?.(state);
32
34
  }
33
35
  if (preventDefault) {
34
36
  event.preventDefault();
@@ -36,13 +38,14 @@ function processListboxKeydown(event, state) {
36
38
  }
37
39
  }
38
40
  function onNavigation(event, state) {
39
- const skip = state.callbacks.keydown.skipNavigation?.(state) ?? false;
41
+ const { active, autocomplete, callbacks, type } = state.component;
42
+ const skip = callbacks.keydown.skipNavigation?.(state) ?? false;
40
43
  const visible = getListboxVisibleOptions(state);
41
44
  if (visible.length === 0) return;
42
45
  let next;
43
- if (skip || state.active == null) next = state.active ?? visible.at(event.key === "ArrowDown" ? 0 : -1);
46
+ if (skip || active == null) next = active ?? visible.at(event.key === "ArrowDown" ? 0 : -1);
44
47
  else {
45
- const current = visible.findIndex((option) => option.id === state.active?.id);
48
+ const current = visible.findIndex((option) => option.id === active?.id);
46
49
  let index;
47
50
  switch (event.key) {
48
51
  case "ArrowDown":
@@ -55,9 +58,9 @@ function onNavigation(event, state) {
55
58
  if (index != null) next = visible[index];
56
59
  }
57
60
  let preview;
58
- if (state.type === "autocomplete" && (state.autocomplete.both || state.autocomplete.inline)) preview = "set";
61
+ if (type === "autocomplete" && (autocomplete.both || autocomplete.inline)) preview = "set";
59
62
  else preview = "none";
60
- state.callbacks.keydown.onNavigation(preview, state, next ?? state.active ?? visible[0]);
63
+ callbacks.keydown.onNavigation(preview, state, next ?? active ?? visible[0]);
61
64
  }
62
65
  //#endregion
63
66
  export { processListboxKeydown };
@@ -1,4 +1,4 @@
1
- import { l as OuiListboxState } from "../../listbox.model-BHPA7GM4.mjs";
1
+ import { l as OuiListboxState } from "../../listbox.model-CuBOj4qe.mjs";
2
2
  //#region src/js/internal/listbox/listbox.form.d.ts
3
3
  export declare function updateListboxForm<State extends OuiListboxState>(state: State, values: string[], emit?: boolean): void;
4
4
  export declare function updateListboxValidity(state: OuiListboxState): void;
@@ -1,26 +1,29 @@
1
- import { getLocalization, localize } from "../../l10n.mjs";
1
+ import { getLocalization, localize } from "../../l10n/index.mjs";
2
2
  import { dispatch } from "@oscarpalmer/toretto/event";
3
3
  //#region src/js/internal/listbox/listbox.form.ts
4
4
  function updateListboxForm(state, values, emit) {
5
+ const { component, form } = state;
6
+ const { callbacks, host, multiple, name } = component;
5
7
  let value;
6
- if (state.multiple) {
8
+ if (multiple) {
7
9
  const { length } = values;
8
10
  value = new FormData();
9
- for (let index = 0; index < length; index += 1) value.append(state.name, values[index]);
11
+ for (let index = 0; index < length; index += 1) value.append(name, values[index]);
10
12
  } else value = values[0];
11
- state.values.current = values;
12
- state.internals.setFormValue(value, JSON.stringify(values));
13
- state.callbacks.data.onForm(state);
13
+ component.values.current = values;
14
+ form.internals.setFormValue(value, JSON.stringify(values));
15
+ callbacks.data.onForm(state);
14
16
  updateListboxValidity(state);
15
- if (emit ?? true) dispatch(state.host, "oui:change");
17
+ if (emit ?? true) dispatch(host, "oui:change");
16
18
  }
17
19
  function updateListboxValidity(state) {
18
- const { autocomplete, filter, host, internals, listbox, localizations, max, min, multiple, options, required } = state;
20
+ const { component, form } = state;
21
+ const { autocomplete, filter, host, listbox, localizations, max, min, multiple, options, required } = component;
19
22
  if (autocomplete.none && !listbox) {
20
23
  const valueMissing = required && filter.element.value.length === 0;
21
24
  const localization = getLocalization(localizations.global, host, "invalid", localizations.component);
22
- internals.setValidity({ valueMissing }, localize(localization, {}, []));
23
- internals.checkValidity();
25
+ form.internals.setValidity({ valueMissing }, localize(localization, {}, []));
26
+ form.internals.checkValidity();
24
27
  return;
25
28
  }
26
29
  let data = {};
@@ -46,8 +49,8 @@ function updateListboxValidity(state) {
46
49
  }
47
50
  const localization = key == null ? void 0 : getLocalization(localizations.global, host, key, localizations.component);
48
51
  const message = localization == null ? void 0 : localize(localization, data, parameters);
49
- internals.setValidity(error == null ? {} : { [error]: true }, message);
50
- internals.checkValidity();
52
+ form.internals.setValidity(error == null ? {} : { [error]: true }, message);
53
+ form.internals.checkValidity();
51
54
  }
52
55
  //#endregion
53
56
  export { updateListboxForm, updateListboxValidity };
@@ -1,4 +1,4 @@
1
- import { l as OuiListboxState } from "../../listbox.model-BHPA7GM4.mjs";
1
+ import { l as OuiListboxState } from "../../listbox.model-CuBOj4qe.mjs";
2
2
  //#region src/js/internal/listbox/listbox.misc.d.ts
3
3
  export declare function generateListboxIds(prefix: string, select: HTMLSelectElement): void;
4
4
  export declare function getListboxVisibleOptions(state: OuiListboxState): HTMLElement[];
@@ -1,2 +1,2 @@
1
- import { C as setListboxDisabled, D as setListboxReadonly, E as setListboxMultiple, O as setListboxRequired, S as getListboxVisibleOptions, T as setListboxLimit, w as setListboxFilter, x as generateListboxIds } from "../../listbox.data-DQ7-x2uY.mjs";
1
+ import { C as setListboxDisabled, D as setListboxReadonly, E as setListboxMultiple, O as setListboxRequired, S as getListboxVisibleOptions, T as setListboxLimit, w as setListboxFilter, x as generateListboxIds } from "../../listbox.data-BQyZGKgr.mjs";
2
2
  export { generateListboxIds, getListboxVisibleOptions, setListboxDisabled, setListboxFilter, setListboxLimit, setListboxMultiple, setListboxReadonly, setListboxRequired };
@@ -1,2 +1,2 @@
1
- import { a as OuiListboxGroup, c as OuiListboxPreview, d as OuiListboxType, i as OuiListboxCallbacks, l as OuiListboxState, n as OuiListboxAutoComplete, o as OuiListboxLocalizations, r as OuiListboxAutoCompleteType, s as OuiListboxOptions, t as OuiListboxAttributes, u as OuiListboxStates } from "../../listbox.model-BHPA7GM4.mjs";
2
- export { OuiListboxAttributes, OuiListboxAutoComplete, OuiListboxAutoCompleteType, OuiListboxCallbacks, OuiListboxGroup, OuiListboxLocalizations, OuiListboxOptions, OuiListboxPreview, OuiListboxState, OuiListboxStates, OuiListboxType };
1
+ import { a as OuiListboxGroup, c as OuiListboxPreview, d as OuiListboxStateForm, f as OuiListboxType, i as OuiListboxCallbacks, l as OuiListboxState, n as OuiListboxAutoComplete, o as OuiListboxLocalizations, r as OuiListboxAutoCompleteType, s as OuiListboxOptions, t as OuiListboxAttributes, u as OuiListboxStateComponent } from "../../listbox.model-CuBOj4qe.mjs";
2
+ export { OuiListboxAttributes, OuiListboxAutoComplete, OuiListboxAutoCompleteType, OuiListboxCallbacks, OuiListboxGroup, OuiListboxLocalizations, OuiListboxOptions, OuiListboxPreview, OuiListboxState, OuiListboxStateComponent, OuiListboxStateForm, OuiListboxType };
@@ -1,6 +1,6 @@
1
- import { l as OuiListboxState, u as OuiListboxStates } from "../../listbox.model-BHPA7GM4.mjs";
1
+ import { l as OuiListboxState } from "../../listbox.model-CuBOj4qe.mjs";
2
2
  //#region src/js/internal/listbox/listbox.state.d.ts
3
- export declare function attachListbox<State extends OuiListboxState>(state: State, states: OuiListboxStates<State>, onAttach: (state: State) => void): void;
4
- export declare function detachListbox<State extends OuiListboxState>(state: State, states: OuiListboxStates<State>, onDetach: (state: State) => void): void;
5
- export declare function initializeListboxState<State extends OuiListboxState>(state: State, states: OuiListboxStates<State>, onAttach: (state: State) => void): State;
3
+ export declare function attachListbox<State extends OuiListboxState>(state: State, set: Set<State>, onAttach: (state: State) => void): void;
4
+ export declare function detachListbox<State extends OuiListboxState>(state: State, set: Set<State>, onDetach: (state: State) => void): void;
5
+ export declare function initializeListboxState<State extends OuiListboxState>(state: State, set: Set<State>, onAttach: (state: State) => void): State;
6
6
  //#endregion
@@ -1,39 +1,38 @@
1
1
  import { updateListboxForm } from "./listbox.form.mjs";
2
- import { C as setListboxDisabled, D as setListboxReadonly, E as setListboxMultiple, O as setListboxRequired, T as setListboxLimit, b as updateListboxValueLabel, i as filterListboxOptions, v as updateListboxMessage, y as updateListboxPreview } from "../../listbox.data-DQ7-x2uY.mjs";
2
+ import { C as setListboxDisabled, D as setListboxReadonly, E as setListboxMultiple, O as setListboxRequired, T as setListboxLimit, b as updateListboxValueLabel, i as filterListboxOptions, v as updateListboxMessage, y as updateListboxPreview } from "../../listbox.data-BQyZGKgr.mjs";
3
3
  import { getAttribute } from "@oscarpalmer/toretto/attribute";
4
4
  //#region src/js/internal/listbox/listbox.state.ts
5
- function attachListbox(state, states, onAttach) {
6
- const { filter, host, id, label } = state;
5
+ function attachListbox(state, set, onAttach) {
6
+ const { filter, id, label } = state.component;
7
7
  label.element.htmlFor = filter.element.id;
8
8
  label.element.id = `${id}_label`;
9
9
  onAttach(state);
10
- states.map.set(host, state);
11
- states.set.add(state);
10
+ set.add(state);
12
11
  }
13
- function detachListbox(state, states, onDetach) {
14
- const { host, label, select } = state;
15
- const listeners = state.listeners.splice(0);
12
+ function detachListbox(state, set, onDetach) {
13
+ const { label, select } = state.component;
14
+ const listeners = state.component.listeners.splice(0);
16
15
  const { length } = listeners;
17
16
  for (let index = 0; index < length; index += 1) listeners[index]();
18
17
  label.element.htmlFor = select.id;
19
18
  label.element.id = label.id;
20
19
  onDetach(state);
21
- states.map.delete(host);
22
- states.set.delete(state);
20
+ set.delete(state);
23
21
  }
24
- function initializeListboxState(state, states, onAttach) {
25
- attachListbox(state, states, onAttach);
26
- setListboxDisabled(state, state.disabled);
27
- setListboxLimit("max", state, getAttribute(state.host, "max"));
28
- setListboxLimit("min", state, getAttribute(state.host, "min"));
29
- setListboxMultiple(state.host, state.multiple);
30
- setListboxReadonly(state, state.readonly);
31
- setListboxRequired(state, state.required);
22
+ function initializeListboxState(state, set, onAttach) {
23
+ const { component } = state;
24
+ attachListbox(state, set, onAttach);
25
+ setListboxDisabled(state, component.disabled);
26
+ setListboxLimit("max", state, getAttribute(component.host, "max"));
27
+ setListboxLimit("min", state, getAttribute(component.host, "min"));
28
+ setListboxMultiple(component.host, component.multiple);
29
+ setListboxReadonly(state, component.readonly);
30
+ setListboxRequired(state, component.required);
32
31
  filterListboxOptions(state);
33
- updateListboxForm(state, state.values.current, false);
32
+ updateListboxForm(state, component.values.current, false);
34
33
  updateListboxMessage(state);
35
34
  updateListboxValueLabel(state);
36
- if (state.options.selected.length > 0) updateListboxPreview("none", state, state.options.selected[0], false);
35
+ if (component.options.selected.length > 0) updateListboxPreview("none", state, component.options.selected[0], false);
37
36
  return state;
38
37
  }
39
38
  //#endregion
@@ -3,4 +3,5 @@ import { AnyAriaBooleanAttribute } from "@oscarpalmer/toretto/models";
3
3
  export declare function copyValue(value: string, onSuccess?: () => void, onError?: () => void): void;
4
4
  export declare function getAttributeValue<Value>(element: HTMLElement, attribute: string, possible: Set<Value>, defaultValue: Value): Value;
5
5
  export declare function getBooleanAriaValue(element: HTMLElement, attribute: AnyAriaBooleanAttribute): boolean;
6
+ export declare const EXPRESSION_WHITESPACE: RegExp;
6
7
  //#endregion
@@ -1,13 +1,10 @@
1
1
  import { getAria } from "@oscarpalmer/toretto/aria";
2
2
  import { getAttribute } from "@oscarpalmer/toretto/attribute";
3
3
  import { noop } from "@oscarpalmer/atoms/function";
4
+ import { attempt } from "@oscarpalmer/atoms/result";
4
5
  //#region src/js/internal/misc.ts
5
6
  function copyValue(value, onSuccess, onError) {
6
- try {
7
- navigator.clipboard.writeText(value).then(onSuccess ?? noop, onError ?? noop);
8
- } catch {
9
- onError?.();
10
- }
7
+ if (!attempt(() => navigator.clipboard.writeText(value).then(onSuccess ?? noop, onError ?? noop)).ok) onError?.();
11
8
  }
12
9
  function getAttributeValue(element, attribute, possible, defaultValue) {
13
10
  const value = getAttribute(element, attribute);
@@ -17,5 +14,6 @@ function getBooleanAriaValue(element, attribute) {
17
14
  const value = getAria(element, attribute);
18
15
  return value === true || value === "true";
19
16
  }
17
+ const EXPRESSION_WHITESPACE = /\s+/;
20
18
  //#endregion
21
- export { copyValue, getAttributeValue, getBooleanAriaValue };
19
+ export { EXPRESSION_WHITESPACE, copyValue, getAttributeValue, getBooleanAriaValue };
@@ -0,0 +1,6 @@
1
+ import { d as OuiNavigable, h as OuiNavigableOrientation, m as OuiNavigableOptions } from "../../navigable.model-BPOM8DZk.mjs";
2
+ //#region src/js/internal/navigable/index.d.ts
3
+ export declare function getNavigable(element: HTMLElement, options: OuiNavigableOptions): OuiNavigable;
4
+ export declare function getNavigableOrientation(element: HTMLElement, vertical: boolean, aria?: boolean): OuiNavigableOrientation;
5
+ export declare function updateNavigableFocus(navigable: OuiNavigable, focus: boolean, items?: HTMLElement[]): void;
6
+ //#endregion
@@ -0,0 +1,125 @@
1
+ import { NAVIGABLE_KEYS_ABSOLUTE, NAVIGABLE_KEYS_ACTIVATE, NAVIGABLE_KEYS_ALL, NAVIGABLE_KEYS_HORIZONTAL, NAVIGABLE_KEYS_NEXT, NAVIGABLE_ORIENTATIONS, NAVIGABLE_ORIENTATION_HORIZONTAL, NAVIGABLE_ORIENTATION_VERTICAL, NAVIGABLE_SYMBOL } from "./navigable.model.mjs";
2
+ import { getAria, setAria, setRole } from "@oscarpalmer/toretto/aria";
3
+ import { getAttribute } from "@oscarpalmer/toretto/attribute";
4
+ import { on } from "@oscarpalmer/toretto/event";
5
+ import { findAncestor } from "@oscarpalmer/toretto/find";
6
+ import { isHTMLOrSVGElement } from "@oscarpalmer/toretto/is";
7
+ import { filter } from "@oscarpalmer/atoms/array/filter";
8
+ import { clamp } from "@oscarpalmer/atoms/number";
9
+ //#region src/js/internal/navigable/index.ts
10
+ function OuiNavigable(element, options) {
11
+ this[NAVIGABLE_SYMBOL] = {
12
+ element,
13
+ options,
14
+ active: { index: 0 },
15
+ listeners: [
16
+ on(element, "click", (event) => {
17
+ onClick(this, event);
18
+ }, { passive: false }),
19
+ on(element, "focusin", (event) => {
20
+ onFocusin(this, event);
21
+ }),
22
+ on(element, "keydown", (event) => {
23
+ onKeydown(this, event);
24
+ }, { passive: false })
25
+ ],
26
+ orientation: options?.orientation ?? getNavigableOrientation(element, options.vertical)
27
+ };
28
+ setAria(element, "orientation", this[NAVIGABLE_SYMBOL].orientation);
29
+ if (options.role != null) setRole(element, options.role);
30
+ }
31
+ OuiNavigable.prototype.destroy = destroyNavigable;
32
+ OuiNavigable.prototype.navigate = navigateWithNavigable;
33
+ function destroyNavigable() {
34
+ const state = this[NAVIGABLE_SYMBOL];
35
+ const listeners = state.listeners.splice(0);
36
+ for (const listener of listeners) listener();
37
+ state.active.element = void 0;
38
+ state.element = void 0;
39
+ }
40
+ function getItems(container, selector) {
41
+ return filter([...container.querySelectorAll(selector)], isValidItem);
42
+ }
43
+ function getNavigable(element, options) {
44
+ return new OuiNavigable(element, options);
45
+ }
46
+ function getNavigableOrientation(element, vertical, aria) {
47
+ const attribute = aria ?? true ? getAria(element, "orientation") : getAttribute(element, "orientation");
48
+ return NAVIGABLE_ORIENTATIONS.has(attribute) ? attribute : vertical ? NAVIGABLE_ORIENTATION_VERTICAL : NAVIGABLE_ORIENTATION_HORIZONTAL;
49
+ }
50
+ function isValidItem(element) {
51
+ return "disabled" in element ? element.disabled !== true : true;
52
+ }
53
+ function navigateWithNavigable(index, focus) {
54
+ const { element, options } = this[NAVIGABLE_SYMBOL];
55
+ const items = getItems(element, options.selector);
56
+ if (index >= 0 && index < items.length) onNavigate(this, index, items, focus ?? false);
57
+ }
58
+ function onClick(navigable, event) {
59
+ const { active, element, options } = navigable[NAVIGABLE_SYMBOL];
60
+ const item = findAncestor(event, options.selector);
61
+ const items = getItems(element, options.selector);
62
+ const index = items.indexOf(item);
63
+ if (index === -1) return;
64
+ if (index !== active.index) onNavigate(navigable, index, items, false);
65
+ options.onActivate?.(navigable);
66
+ item.focus();
67
+ }
68
+ function onNavigate(navigable, index, items, focus) {
69
+ const { active, options } = navigable[NAVIGABLE_SYMBOL];
70
+ active.element = items[index];
71
+ active.index = index;
72
+ updateNavigableFocus(navigable, focus, items);
73
+ options.onNavigation?.(navigable);
74
+ }
75
+ function onFocusin(navigable, event) {
76
+ const { active, element, options } = navigable[NAVIGABLE_SYMBOL];
77
+ const item = findAncestor(event, options.selector);
78
+ if (!isHTMLOrSVGElement(item) || !isValidItem(item)) return;
79
+ const items = getItems(element, options.selector);
80
+ const index = items.indexOf(item);
81
+ if (index === -1) return;
82
+ active.element = item;
83
+ active.index = index;
84
+ updateNavigableFocus(navigable, false, items);
85
+ }
86
+ function onKeydown(navigable, event) {
87
+ const { active, element, options, orientation } = navigable[NAVIGABLE_SYMBOL];
88
+ const escaped = event.key === "Escape";
89
+ const stopPropagation = options.onShouldDeactivate?.(event, navigable);
90
+ if (escaped || stopPropagation != null) {
91
+ if (escaped || stopPropagation) event.stopPropagation();
92
+ options.onDeactivate?.(event, navigable);
93
+ return;
94
+ }
95
+ if (!NAVIGABLE_KEYS_ALL.has(event.key)) return;
96
+ const mustActivate = NAVIGABLE_KEYS_ACTIVATE.has(event.key);
97
+ const shouldActivate = options.onShouldActivate?.(event, navigable) === true;
98
+ if (mustActivate || shouldActivate || options.onPreventNavigation?.(event, navigable) === true) event.stopPropagation();
99
+ if (mustActivate || shouldActivate) {
100
+ options.onActivate?.(navigable);
101
+ return;
102
+ }
103
+ const items = getItems(element, options.selector);
104
+ const { length } = items;
105
+ if (length === 0) return;
106
+ event.preventDefault();
107
+ let index;
108
+ if (NAVIGABLE_KEYS_ABSOLUTE.has(event.key)) index = event.key === "Home" ? 0 : items.length - 1;
109
+ else if (orientation === (NAVIGABLE_KEYS_HORIZONTAL.has(event.key) ? "horizontal" : "vertical")) {
110
+ if (active.element instanceof HTMLSelectElement) event.preventDefault();
111
+ index = clamp(active.index + (NAVIGABLE_KEYS_NEXT.has(event.key) ? 1 : -1), 0, length - 1, true);
112
+ }
113
+ if (index != null && index !== active.index) onNavigate(navigable, index, items, true);
114
+ }
115
+ function updateNavigableFocus(navigable, focus, items) {
116
+ const { active, element, options } = navigable[NAVIGABLE_SYMBOL];
117
+ const updated = items ?? getItems(element, options.selector);
118
+ const { length } = updated;
119
+ if (length === 0) return;
120
+ for (let index = 0; index < length; index += 1) updated[index].tabIndex = index === active.index ? 0 : -1;
121
+ active.element ??= updated[active.index];
122
+ if (focus) active.element?.focus();
123
+ }
124
+ //#endregion
125
+ export { getNavigable, getNavigableOrientation, updateNavigableFocus };
@@ -0,0 +1,2 @@
1
+ import { a as NAVIGABLE_KEYS_NEXT, c as NAVIGABLE_ORIENTATION_HORIZONTAL, d as OuiNavigable, f as OuiNavigableActive, g as OuiNavigableState, h as OuiNavigableOrientation, i as NAVIGABLE_KEYS_HORIZONTAL, l as NAVIGABLE_ORIENTATION_VERTICAL, m as OuiNavigableOptions, n as NAVIGABLE_KEYS_ACTIVATE, o as NAVIGABLE_KEYS_VERTICAL, p as OuiNavigableCallback, r as NAVIGABLE_KEYS_ALL, s as NAVIGABLE_ORIENTATIONS, t as NAVIGABLE_KEYS_ABSOLUTE, u as NAVIGABLE_SYMBOL } from "../../navigable.model-BPOM8DZk.mjs";
2
+ export { NAVIGABLE_KEYS_ABSOLUTE, NAVIGABLE_KEYS_ACTIVATE, NAVIGABLE_KEYS_ALL, NAVIGABLE_KEYS_HORIZONTAL, NAVIGABLE_KEYS_NEXT, NAVIGABLE_KEYS_VERTICAL, NAVIGABLE_ORIENTATIONS, NAVIGABLE_ORIENTATION_HORIZONTAL, NAVIGABLE_ORIENTATION_VERTICAL, NAVIGABLE_SYMBOL, OuiNavigable, OuiNavigableActive, OuiNavigableCallback, OuiNavigableOptions, OuiNavigableOrientation, OuiNavigableState };
@@ -0,0 +1,18 @@
1
+ //#region src/js/internal/navigable/navigable.model.ts
2
+ const NAVIGABLE_KEYS_ABSOLUTE = /* @__PURE__ */ new Set(["End", "Home"]);
3
+ const NAVIGABLE_KEYS_ACTIVATE = /* @__PURE__ */ new Set(["Enter", " "]);
4
+ const NAVIGABLE_KEYS_HORIZONTAL = /* @__PURE__ */ new Set(["ArrowRight", "ArrowLeft"]);
5
+ const NAVIGABLE_KEYS_VERTICAL = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp"]);
6
+ const NAVIGABLE_KEYS_ALL = /* @__PURE__ */ new Set([
7
+ ...NAVIGABLE_KEYS_ABSOLUTE,
8
+ ...NAVIGABLE_KEYS_ACTIVATE,
9
+ ...NAVIGABLE_KEYS_HORIZONTAL,
10
+ ...NAVIGABLE_KEYS_VERTICAL
11
+ ]);
12
+ const NAVIGABLE_KEYS_NEXT = /* @__PURE__ */ new Set(["ArrowDown", "ArrowRight"]);
13
+ const NAVIGABLE_ORIENTATION_HORIZONTAL = "horizontal";
14
+ const NAVIGABLE_ORIENTATION_VERTICAL = "vertical";
15
+ const NAVIGABLE_ORIENTATIONS = /* @__PURE__ */ new Set([NAVIGABLE_ORIENTATION_HORIZONTAL, NAVIGABLE_ORIENTATION_VERTICAL]);
16
+ const NAVIGABLE_SYMBOL = Symbol("oui-navigable");
17
+ //#endregion
18
+ export { NAVIGABLE_KEYS_ABSOLUTE, NAVIGABLE_KEYS_ACTIVATE, NAVIGABLE_KEYS_ALL, NAVIGABLE_KEYS_HORIZONTAL, NAVIGABLE_KEYS_NEXT, NAVIGABLE_KEYS_VERTICAL, NAVIGABLE_ORIENTATIONS, NAVIGABLE_ORIENTATION_HORIZONTAL, NAVIGABLE_ORIENTATION_VERTICAL, NAVIGABLE_SYMBOL };
@@ -0,0 +1,9 @@
1
+ import { c as OuiLocalizations, s as OuiLocalizationParameters, u as OuiLocalizationsValues } from "../l10n.model-D6a9frgl.mjs";
2
+ import { GenericCallback } from "@oscarpalmer/atoms/models";
3
+ //#region src/js/l10n/index.d.ts
4
+ export declare function createLocalizations<Localizations extends OuiLocalizationsValues>(defaults: Localizations): OuiLocalizations<Localizations>;
5
+ export declare function getLanguage(element: Element): string;
6
+ export declare function getLocalization<Localizations extends OuiLocalizationsValues, Key extends keyof Localizations>(localizations: OuiLocalizations<Localizations>, element: Element, key: Key, value: Record<string, Partial<Localizations>>): Localizations[Key] | GenericCallback;
7
+ export declare function localize<Localizations extends OuiLocalizationsValues, Key extends keyof Localizations, Localization extends Localizations[Key]>(localization: Localization, data: Record<string, unknown>, parameters: OuiLocalizationParameters<Localization>): string;
8
+ export declare function updateLocalizations<Localizations extends OuiLocalizationsValues>(instance: OuiLocalizations<Localizations>, values: Record<string, Partial<Localizations>>, destination: Record<string, Partial<Localizations>>, onAfter?: () => void): void;
9
+ //#endregion
@@ -1,26 +1,44 @@
1
+ import { L10N_MESSAGE_ITEM_CREATE, L10N_MESSAGE_ITEM_UPDATE_KEY, L10N_MESSAGE_ITEM_UPDATE_VALUE, L10N_MESSAGE_OBJECT_CREATE, L10N_MESSAGE_OBJECT_UPDATE, L10N_SYMBOL } from "./l10n.model.mjs";
2
+ import { isPlainObject } from "@oscarpalmer/atoms/is";
1
3
  import { getString } from "@oscarpalmer/atoms/string";
2
- //#region src/js/l10n.ts
3
- var OuiLocalizations = class {
4
- defaults;
5
- keys;
6
- values = {};
7
- constructor(defaults) {
8
- this.defaults = defaults;
9
- this.keys = new Set(Object.keys(defaults));
10
- }
11
- get(element, key, localizations) {
12
- return getLocalization(this, element, key, localizations);
13
- }
14
- set(first, second) {
15
- updateLocalizations(this, typeof first === "string" ? { [first]: second } : first, this.values);
4
+ //#region src/js/l10n/index.ts
5
+ function OuiLocalizations(defaults) {
6
+ this[L10N_SYMBOL] = {
7
+ defaults,
8
+ keys: new Set(Object.keys(defaults)),
9
+ values: {}
10
+ };
11
+ }
12
+ OuiLocalizations.prototype.get = getLocalizationValue;
13
+ OuiLocalizations.prototype.set = setLocalizationValues;
14
+ Object.defineProperties(OuiLocalizations.prototype, {
15
+ defaults: {
16
+ enumerable: true,
17
+ get: getDefaults
18
+ },
19
+ keys: {
20
+ enumerable: true,
21
+ get: getKeys
16
22
  }
17
- };
23
+ });
24
+ function createLocalizations(defaults) {
25
+ if (!isPlainObject(defaults) || Object.keys(defaults).length === 0) throw new Error(L10N_MESSAGE_OBJECT_CREATE);
26
+ if (!Object.values(defaults).every(isValidLocalization)) throw new Error(L10N_MESSAGE_ITEM_CREATE);
27
+ return new OuiLocalizations(defaults);
28
+ }
29
+ function getDefaults() {
30
+ return { ...this[L10N_SYMBOL].defaults };
31
+ }
32
+ function getKeys() {
33
+ return [...this[L10N_SYMBOL].keys];
34
+ }
18
35
  function getLanguage(element) {
19
36
  return (element.closest("[lang]")?.getAttribute("lang") ?? document.documentElement.lang).toLowerCase();
20
37
  }
21
38
  function getLocalization(localizations, element, key, value) {
22
39
  const language = getLanguage(element);
23
- const values = [value, localizations.values];
40
+ const state = localizations[L10N_SYMBOL];
41
+ const values = [value, state.values];
24
42
  const { length } = values;
25
43
  let localization;
26
44
  let shortLanguage;
@@ -33,10 +51,13 @@ function getLocalization(localizations, element, key, value) {
33
51
  localization = value?.[shortLanguage]?.[key];
34
52
  if (localization != null) break;
35
53
  }
36
- return localization ?? localizations.defaults[key];
54
+ return localization ?? state.defaults[key];
37
55
  }
38
- function getLocalizations(defaults) {
39
- return new OuiLocalizations(defaults);
56
+ function getLocalizationValue(element, key, localizations) {
57
+ return getLocalization(this, element, key, localizations);
58
+ }
59
+ function isValidLocalization(value) {
60
+ return typeof value === "string" || typeof value === "function";
40
61
  }
41
62
  function localize(localization, data, parameters) {
42
63
  if (typeof localization === "function") return localization(...parameters);
@@ -50,9 +71,13 @@ function localize(localization, data, parameters) {
50
71
  }
51
72
  return localized;
52
73
  }
74
+ function setLocalizationValues(first, second) {
75
+ updateLocalizations(this, typeof first === "string" ? { [first]: second } : first, this[L10N_SYMBOL].values);
76
+ }
53
77
  function updateLocalizations(instance, values, destination, onAfter) {
54
- if (typeof values !== "object" || values == null) return;
55
- const localizations = destination ?? instance.values;
78
+ if (typeof values !== "object" || values == null) throw new Error(L10N_MESSAGE_OBJECT_UPDATE);
79
+ const state = instance[L10N_SYMBOL];
80
+ const localizations = destination ?? state.values;
56
81
  const languages = Object.keys(values);
57
82
  const languagesLength = languages.length;
58
83
  let updated = false;
@@ -68,7 +93,9 @@ function updateLocalizations(instance, values, destination, onAfter) {
68
93
  const key = keys[keysIndex];
69
94
  const keyValue = languageValue[key];
70
95
  const normalizedKey = key.toLowerCase();
71
- if (instance.keys.has(normalizedKey) && (typeof keyValue === "string" || typeof keyValue === "function")) {
96
+ if (!state.keys.has(normalizedKey)) throw new Error(L10N_MESSAGE_ITEM_UPDATE_KEY);
97
+ if (!isValidLocalization(keyValue)) throw new Error(L10N_MESSAGE_ITEM_UPDATE_VALUE);
98
+ if (state.keys.has(normalizedKey) && isValidLocalization(keyValue)) {
72
99
  updated = true;
73
100
  localizations[normalizedLanguage][normalizedKey] = keyValue;
74
101
  }
@@ -77,4 +104,4 @@ function updateLocalizations(instance, values, destination, onAfter) {
77
104
  if (updated && typeof onAfter === "function") onAfter();
78
105
  }
79
106
  //#endregion
80
- export { OuiLocalizations, getLanguage, getLocalization, getLocalizations, localize, updateLocalizations };
107
+ export { createLocalizations, getLanguage, getLocalization, localize, updateLocalizations };
@@ -0,0 +1,2 @@
1
+ import { a as L10N_MESSAGE_OBJECT_UPDATE, c as OuiLocalizations, i as L10N_MESSAGE_OBJECT_CREATE, l as OuiLocalizationsState, n as L10N_MESSAGE_ITEM_UPDATE_KEY, o as L10N_SYMBOL, r as L10N_MESSAGE_ITEM_UPDATE_VALUE, s as OuiLocalizationParameters, t as L10N_MESSAGE_ITEM_CREATE, u as OuiLocalizationsValues } from "../l10n.model-D6a9frgl.mjs";
2
+ export { L10N_MESSAGE_ITEM_CREATE, L10N_MESSAGE_ITEM_UPDATE_KEY, L10N_MESSAGE_ITEM_UPDATE_VALUE, L10N_MESSAGE_OBJECT_CREATE, L10N_MESSAGE_OBJECT_UPDATE, L10N_SYMBOL, OuiLocalizationParameters, OuiLocalizations, OuiLocalizationsState, OuiLocalizationsValues };
@@ -0,0 +1,9 @@
1
+ //#region src/js/l10n/l10n.model.ts
2
+ const L10N_MESSAGE_ITEM_CREATE = "Localization item must be a string or a function.";
3
+ const L10N_MESSAGE_ITEM_UPDATE_KEY = "Localization item key must be known.";
4
+ const L10N_MESSAGE_ITEM_UPDATE_VALUE = "Localization item value must be a string or a function.";
5
+ const L10N_MESSAGE_OBJECT_CREATE = "Default localizations must be a non-empty plain object.";
6
+ const L10N_MESSAGE_OBJECT_UPDATE = "Localizations update object must be a plain object.";
7
+ const L10N_SYMBOL = Symbol("l10n");
8
+ //#endregion
9
+ export { L10N_MESSAGE_ITEM_CREATE, L10N_MESSAGE_ITEM_UPDATE_KEY, L10N_MESSAGE_ITEM_UPDATE_VALUE, L10N_MESSAGE_OBJECT_CREATE, L10N_MESSAGE_OBJECT_UPDATE, L10N_SYMBOL };
@@ -0,0 +1,26 @@
1
+ import { GenericCallback } from "@oscarpalmer/atoms/models";
2
+ //#region src/js/l10n/l10n.model.d.ts
3
+ type OuiLocalizationParameters<Localization> = Localization extends GenericCallback ? Parameters<Localization> : never;
4
+ type OuiLocalizations<Localizations extends OuiLocalizationsValues> = {
5
+ [L10N_SYMBOL]: OuiLocalizationsState<Localizations>;
6
+ get defaults(): Localizations;
7
+ get keys(): Set<keyof Localizations>;
8
+ get values(): Record<string, Partial<Localizations>>;
9
+ get<Key extends keyof Localizations>(element: Element, key: Key, localizations: Record<string, Partial<Localizations>>): string | GenericCallback;
10
+ set(language: string, localizations: Partial<Localizations>): void;
11
+ set(localizations: Record<string, Partial<Localizations>>): void;
12
+ };
13
+ type OuiLocalizationsState<Localizations extends OuiLocalizationsValues> = {
14
+ readonly defaults: Localizations;
15
+ readonly keys: Set<string>;
16
+ readonly values: Record<string, Partial<Localizations>>;
17
+ };
18
+ type OuiLocalizationsValues = Record<string, string | GenericCallback>;
19
+ declare const L10N_MESSAGE_ITEM_CREATE = "Localization item must be a string or a function.";
20
+ declare const L10N_MESSAGE_ITEM_UPDATE_KEY = "Localization item key must be known.";
21
+ declare const L10N_MESSAGE_ITEM_UPDATE_VALUE = "Localization item value must be a string or a function.";
22
+ declare const L10N_MESSAGE_OBJECT_CREATE = "Default localizations must be a non-empty plain object.";
23
+ declare const L10N_MESSAGE_OBJECT_UPDATE = "Localizations update object must be a plain object.";
24
+ declare const L10N_SYMBOL: unique symbol;
25
+ //#endregion
26
+ export { L10N_MESSAGE_OBJECT_UPDATE as a, OuiLocalizations as c, L10N_MESSAGE_OBJECT_CREATE as i, OuiLocalizationsState as l, L10N_MESSAGE_ITEM_UPDATE_KEY as n, L10N_SYMBOL as o, L10N_MESSAGE_ITEM_UPDATE_VALUE as r, OuiLocalizationParameters as s, L10N_MESSAGE_ITEM_CREATE as t, OuiLocalizationsValues as u };
@@ -1,2 +1,2 @@
1
- import { i as LISTBOX_TAGNAME, n as LISTBOX_MESSAGES, r as LISTBOX_SELECTORS, t as LISTBOX_ATTRIBUTES } from "../constants.listbox-DGnX32kv.mjs";
2
- export { LISTBOX_ATTRIBUTES, LISTBOX_MESSAGES, LISTBOX_SELECTORS, LISTBOX_TAGNAME };
1
+ import { a as listboxSelectors, i as listboxMessages, n as LISTBOX_TAGNAME, r as listboxAttributes, t as LISTBOX_SYMBOL } from "../constants.listbox-C5Ap6Ag_.mjs";
2
+ export { LISTBOX_SYMBOL, LISTBOX_TAGNAME, listboxAttributes, listboxMessages, listboxSelectors };
@@ -1,5 +1,6 @@
1
1
  //#region src/js/listbox/constants.listbox.ts
2
2
  const LISTBOX_TAGNAME = "oui-listbox";
3
+ const LISTBOX_SYMBOL = Symbol(LISTBOX_TAGNAME);
3
4
  const attributeContent = `${LISTBOX_TAGNAME}-content`;
4
5
  const attributeFilter = `${LISTBOX_TAGNAME}-filter`;
5
6
  const attributeFilterInput = `${attributeFilter}-input`;
@@ -10,13 +11,8 @@ const attributeList = `${LISTBOX_TAGNAME}-list`;
10
11
  const attributeListEmpty = `${attributeList}-empty`;
11
12
  const attributeMessage = `${LISTBOX_TAGNAME}-message`;
12
13
  const attributeOption = `${LISTBOX_TAGNAME}-option`;
13
- const attributeOptionActive = `${LISTBOX_TAGNAME}-option-active`;
14
- const messageLabel = `<${LISTBOX_TAGNAME}> must contain a <label> element for the <select> element`;
15
- const messageSelect = `<${LISTBOX_TAGNAME}> must contain a valid <select> element`;
16
- const selectorFilter = `[${attributeFilterInput}]`;
17
- const selectorOption = `[${attributeOption}]`;
18
- const LISTBOX_ATTRIBUTES = {
19
- active: attributeOptionActive,
14
+ const listboxAttributes = {
15
+ active: `${LISTBOX_TAGNAME}-option-active`,
20
16
  content: attributeContent,
21
17
  empty: attributeListEmpty,
22
18
  filter: attributeFilter,
@@ -28,13 +24,13 @@ const LISTBOX_ATTRIBUTES = {
28
24
  message: attributeMessage,
29
25
  option: attributeOption
30
26
  };
31
- const LISTBOX_MESSAGES = {
32
- label: messageLabel,
33
- select: messageSelect
27
+ const listboxMessages = {
28
+ label: `<${LISTBOX_TAGNAME}> must contain a <label> element for the <select> element`,
29
+ select: `<${LISTBOX_TAGNAME}> must contain a valid <select> element`
34
30
  };
35
- const LISTBOX_SELECTORS = {
36
- filter: selectorFilter,
37
- option: selectorOption
31
+ const listboxSelectors = {
32
+ filter: `[${attributeFilterInput}]`,
33
+ option: `[${attributeOption}]`
38
34
  };
39
35
  //#endregion
40
- export { LISTBOX_ATTRIBUTES, LISTBOX_MESSAGES, LISTBOX_SELECTORS, LISTBOX_TAGNAME };
36
+ export { LISTBOX_SYMBOL, LISTBOX_TAGNAME, listboxAttributes, listboxMessages, listboxSelectors };