@sprawlify/primitives 0.0.97 → 0.0.99

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 (231) hide show
  1. package/dist/{aria-hidden-UJAPt1aA.cjs → aria-hidden-BAGrxNHt.cjs} +1 -1
  2. package/dist/{aria-hidden-P3kaF8gG.mjs → aria-hidden-BX4SWNE_.mjs} +1 -1
  3. package/dist/aria-hidden.cjs +2 -2
  4. package/dist/aria-hidden.mjs +2 -2
  5. package/dist/{auto-resize-DzPXdyR-.cjs → auto-resize-B1BDDnp1.cjs} +1 -1
  6. package/dist/{auto-resize-Bjzuo5Lh.mjs → auto-resize-CN2vAzdj.mjs} +1 -1
  7. package/dist/auto-resize.cjs +2 -2
  8. package/dist/auto-resize.mjs +2 -2
  9. package/dist/{collection-DZeodezM.cjs → collection-BBgC8xCb.cjs} +22 -7
  10. package/dist/{collection-CcsrqDFY.mjs → collection-DgzidRvr.mjs} +22 -7
  11. package/dist/collection.cjs +1 -1
  12. package/dist/collection.d.cts +3 -3
  13. package/dist/collection.d.mts +3 -3
  14. package/dist/collection.mjs +1 -1
  15. package/dist/{core-DfVajPnu.mjs → core-BmIEKqtP.mjs} +1 -1
  16. package/dist/{core-BiGlJ-4W.cjs → core-nBg9RC_y.cjs} +1 -1
  17. package/dist/core.cjs +2 -2
  18. package/dist/core.mjs +2 -2
  19. package/dist/{dismissable-DPXx0m0m.cjs → dismissable-ChwcJMHk.cjs} +2 -2
  20. package/dist/{dismissable-BAYaXwxZ.mjs → dismissable-DWfZGIA7.mjs} +2 -2
  21. package/dist/dismissable.cjs +3 -3
  22. package/dist/dismissable.mjs +3 -3
  23. package/dist/{dom-query-6Wt-Tikf.cjs → dom-query-Bd63cRVF.cjs} +26 -6
  24. package/dist/{dom-query-dX8Dakb4.mjs → dom-query-s2ESLR2U.mjs} +15 -7
  25. package/dist/dom-query.cjs +3 -1
  26. package/dist/dom-query.d.cts +7 -1
  27. package/dist/dom-query.d.mts +7 -1
  28. package/dist/dom-query.mjs +2 -2
  29. package/dist/{focus-trap-Cd09JaUn.mjs → focus-trap-DzBvBlTH.mjs} +1 -1
  30. package/dist/{focus-trap-ClCNF7kY.cjs → focus-trap-fucc6OU_.cjs} +1 -1
  31. package/dist/focus-trap.cjs +2 -2
  32. package/dist/focus-trap.mjs +2 -2
  33. package/dist/{focus-visible-CqHoOOjw.cjs → focus-visible-75XTctXf.cjs} +1 -1
  34. package/dist/{focus-visible-CSuBQ5QZ.mjs → focus-visible-D5qBaAOn.mjs} +1 -1
  35. package/dist/focus-visible.cjs +2 -2
  36. package/dist/focus-visible.mjs +2 -2
  37. package/dist/{i18n-utils-Dm8cGCol.cjs → i18n-utils-DB-lUfrr.cjs} +58 -1
  38. package/dist/{i18n-utils-DHGN_KCY.mjs → i18n-utils-oWZyUib_.mjs} +53 -2
  39. package/dist/i18n-utils.cjs +3 -2
  40. package/dist/i18n-utils.d.cts +14 -1
  41. package/dist/i18n-utils.d.mts +14 -1
  42. package/dist/i18n-utils.mjs +3 -3
  43. package/dist/{interact-outside-C-8lOhpV.mjs → interact-outside-2qkUnl4N.mjs} +1 -1
  44. package/dist/{interact-outside-DRaFGdMg.cjs → interact-outside-Cx4J0EBf.cjs} +1 -1
  45. package/dist/interact-outside.cjs +2 -2
  46. package/dist/interact-outside.mjs +2 -2
  47. package/dist/{list-collection-B_8BN0XB.d.cts → list-collection-Cjgbx_9l.d.cts} +1 -1
  48. package/dist/{list-collection-DkRA5LOq.d.mts → list-collection-IF510iNl.d.mts} +1 -1
  49. package/dist/machines/accordion/index.cjs +2 -2
  50. package/dist/machines/accordion/index.mjs +2 -2
  51. package/dist/machines/angle-slider/index.cjs +2 -2
  52. package/dist/machines/angle-slider/index.d.cts +1 -1
  53. package/dist/machines/angle-slider/index.d.mts +1 -1
  54. package/dist/machines/angle-slider/index.mjs +2 -2
  55. package/dist/machines/aspect-ratio/index.cjs +2 -2
  56. package/dist/machines/aspect-ratio/index.mjs +2 -2
  57. package/dist/machines/async-list/index.cjs +2 -2
  58. package/dist/machines/async-list/index.mjs +2 -2
  59. package/dist/machines/avatar/index.cjs +2 -2
  60. package/dist/machines/avatar/index.mjs +2 -2
  61. package/dist/machines/bottom-sheet/index.cjs +7 -7
  62. package/dist/machines/bottom-sheet/index.d.cts +1 -1
  63. package/dist/machines/bottom-sheet/index.d.mts +1 -1
  64. package/dist/machines/bottom-sheet/index.mjs +7 -7
  65. package/dist/machines/carousel/index.cjs +3 -3
  66. package/dist/machines/carousel/index.d.cts +1 -1
  67. package/dist/machines/carousel/index.d.mts +1 -1
  68. package/dist/machines/carousel/index.mjs +3 -3
  69. package/dist/machines/cascade-select/index.cjs +1367 -0
  70. package/dist/machines/cascade-select/index.d.cts +164 -0
  71. package/dist/machines/cascade-select/index.d.mts +164 -0
  72. package/dist/machines/cascade-select/index.mjs +1360 -0
  73. package/dist/machines/checkbox/index.cjs +3 -3
  74. package/dist/machines/checkbox/index.mjs +3 -3
  75. package/dist/machines/clipboard/index.cjs +2 -2
  76. package/dist/machines/clipboard/index.d.cts +1 -1
  77. package/dist/machines/clipboard/index.d.mts +1 -1
  78. package/dist/machines/clipboard/index.mjs +2 -2
  79. package/dist/machines/collapsible/index.cjs +2 -2
  80. package/dist/machines/collapsible/index.d.cts +1 -1
  81. package/dist/machines/collapsible/index.d.mts +1 -1
  82. package/dist/machines/collapsible/index.mjs +2 -2
  83. package/dist/machines/color-picker/index.cjs +5 -5
  84. package/dist/machines/color-picker/index.d.cts +1 -1
  85. package/dist/machines/color-picker/index.d.mts +1 -1
  86. package/dist/machines/color-picker/index.mjs +5 -5
  87. package/dist/machines/combobox/index.cjs +7 -7
  88. package/dist/machines/combobox/index.d.cts +2 -2
  89. package/dist/machines/combobox/index.d.mts +2 -2
  90. package/dist/machines/combobox/index.mjs +7 -7
  91. package/dist/machines/date-picker/index.cjs +52 -16
  92. package/dist/machines/date-picker/index.d.cts +1 -1
  93. package/dist/machines/date-picker/index.d.mts +1 -1
  94. package/dist/machines/date-picker/index.mjs +53 -17
  95. package/dist/machines/dialog/index.cjs +7 -7
  96. package/dist/machines/dialog/index.d.cts +1 -1
  97. package/dist/machines/dialog/index.d.mts +1 -1
  98. package/dist/machines/dialog/index.mjs +7 -7
  99. package/dist/machines/dropdown-menu/index.cjs +5 -5
  100. package/dist/machines/dropdown-menu/index.d.cts +1 -1
  101. package/dist/machines/dropdown-menu/index.d.mts +1 -1
  102. package/dist/machines/dropdown-menu/index.mjs +5 -5
  103. package/dist/machines/editable/index.cjs +3 -3
  104. package/dist/machines/editable/index.d.cts +1 -1
  105. package/dist/machines/editable/index.d.mts +1 -1
  106. package/dist/machines/editable/index.mjs +3 -3
  107. package/dist/machines/file-upload/index.cjs +3 -3
  108. package/dist/machines/file-upload/index.d.cts +1 -1
  109. package/dist/machines/file-upload/index.d.mts +1 -1
  110. package/dist/machines/file-upload/index.mjs +3 -3
  111. package/dist/machines/floating-panel/index.cjs +2 -2
  112. package/dist/machines/floating-panel/index.d.cts +1 -1
  113. package/dist/machines/floating-panel/index.d.mts +1 -1
  114. package/dist/machines/floating-panel/index.mjs +2 -2
  115. package/dist/machines/hover-card/index.cjs +5 -5
  116. package/dist/machines/hover-card/index.d.cts +1 -1
  117. package/dist/machines/hover-card/index.d.mts +1 -1
  118. package/dist/machines/hover-card/index.mjs +5 -5
  119. package/dist/machines/image-cropper/index.cjs +2 -2
  120. package/dist/machines/image-cropper/index.mjs +2 -2
  121. package/dist/machines/listbox/index.cjs +4 -4
  122. package/dist/machines/listbox/index.d.cts +3 -3
  123. package/dist/machines/listbox/index.d.mts +3 -3
  124. package/dist/machines/listbox/index.mjs +4 -4
  125. package/dist/machines/marquee/index.cjs +2 -2
  126. package/dist/machines/marquee/index.d.cts +2 -2
  127. package/dist/machines/marquee/index.d.mts +2 -2
  128. package/dist/machines/marquee/index.mjs +2 -2
  129. package/dist/machines/navigation-menu/index.cjs +4 -4
  130. package/dist/machines/navigation-menu/index.d.cts +1 -1
  131. package/dist/machines/navigation-menu/index.d.mts +1 -1
  132. package/dist/machines/navigation-menu/index.mjs +4 -4
  133. package/dist/machines/number-input/index.cjs +2 -2
  134. package/dist/machines/number-input/index.d.cts +1 -1
  135. package/dist/machines/number-input/index.d.mts +1 -1
  136. package/dist/machines/number-input/index.mjs +2 -2
  137. package/dist/machines/pagination/index.cjs +2 -2
  138. package/dist/machines/pagination/index.mjs +2 -2
  139. package/dist/machines/password-input/index.cjs +2 -2
  140. package/dist/machines/password-input/index.d.cts +1 -1
  141. package/dist/machines/password-input/index.d.mts +1 -1
  142. package/dist/machines/password-input/index.mjs +2 -2
  143. package/dist/machines/pin-input/index.cjs +2 -2
  144. package/dist/machines/pin-input/index.d.cts +1 -1
  145. package/dist/machines/pin-input/index.d.mts +1 -1
  146. package/dist/machines/pin-input/index.mjs +2 -2
  147. package/dist/machines/popover/index.cjs +8 -8
  148. package/dist/machines/popover/index.d.cts +1 -1
  149. package/dist/machines/popover/index.d.mts +1 -1
  150. package/dist/machines/popover/index.mjs +8 -8
  151. package/dist/machines/presence/index.cjs +2 -2
  152. package/dist/machines/presence/index.mjs +2 -2
  153. package/dist/machines/progress/index.cjs +2 -2
  154. package/dist/machines/progress/index.d.cts +1 -1
  155. package/dist/machines/progress/index.d.mts +1 -1
  156. package/dist/machines/progress/index.mjs +2 -2
  157. package/dist/machines/qr-code/index.cjs +2 -2
  158. package/dist/machines/qr-code/index.mjs +2 -2
  159. package/dist/machines/radio-group/index.cjs +3 -3
  160. package/dist/machines/radio-group/index.mjs +3 -3
  161. package/dist/machines/rating-group/index.cjs +2 -2
  162. package/dist/machines/rating-group/index.mjs +2 -2
  163. package/dist/machines/scroll-area/index.cjs +2 -2
  164. package/dist/machines/scroll-area/index.mjs +2 -2
  165. package/dist/machines/select/index.cjs +23 -9
  166. package/dist/machines/select/index.d.cts +3 -2
  167. package/dist/machines/select/index.d.mts +3 -2
  168. package/dist/machines/select/index.mjs +23 -9
  169. package/dist/machines/separator/index.cjs +2 -2
  170. package/dist/machines/separator/index.mjs +2 -2
  171. package/dist/machines/signature-pad/index.cjs +2 -2
  172. package/dist/machines/signature-pad/index.mjs +2 -2
  173. package/dist/machines/slider/index.cjs +2 -2
  174. package/dist/machines/slider/index.d.cts +1 -1
  175. package/dist/machines/slider/index.d.mts +1 -1
  176. package/dist/machines/slider/index.mjs +2 -2
  177. package/dist/machines/splitter/index.cjs +2 -2
  178. package/dist/machines/splitter/index.mjs +2 -2
  179. package/dist/machines/steps/index.cjs +2 -2
  180. package/dist/machines/steps/index.d.cts +1 -1
  181. package/dist/machines/steps/index.d.mts +1 -1
  182. package/dist/machines/steps/index.mjs +2 -2
  183. package/dist/machines/switch/index.cjs +3 -3
  184. package/dist/machines/switch/index.mjs +3 -3
  185. package/dist/machines/tabs/index.cjs +2 -2
  186. package/dist/machines/tabs/index.d.cts +1 -1
  187. package/dist/machines/tabs/index.d.mts +1 -1
  188. package/dist/machines/tabs/index.mjs +2 -2
  189. package/dist/machines/tags-input/index.cjs +4 -4
  190. package/dist/machines/tags-input/index.d.cts +1 -1
  191. package/dist/machines/tags-input/index.d.mts +1 -1
  192. package/dist/machines/tags-input/index.mjs +4 -4
  193. package/dist/machines/timer/index.cjs +2 -2
  194. package/dist/machines/timer/index.d.cts +1 -1
  195. package/dist/machines/timer/index.d.mts +1 -1
  196. package/dist/machines/timer/index.mjs +2 -2
  197. package/dist/machines/toast/index.cjs +4 -4
  198. package/dist/machines/toast/index.d.cts +1 -1
  199. package/dist/machines/toast/index.d.mts +1 -1
  200. package/dist/machines/toast/index.mjs +4 -4
  201. package/dist/machines/toggle/index.cjs +2 -2
  202. package/dist/machines/toggle/index.mjs +2 -2
  203. package/dist/machines/toggle-group/index.cjs +2 -2
  204. package/dist/machines/toggle-group/index.mjs +2 -2
  205. package/dist/machines/tooltip/index.cjs +4 -4
  206. package/dist/machines/tooltip/index.d.cts +1 -1
  207. package/dist/machines/tooltip/index.d.mts +1 -1
  208. package/dist/machines/tooltip/index.mjs +4 -4
  209. package/dist/machines/tour/index.cjs +6 -6
  210. package/dist/machines/tour/index.d.cts +1 -1
  211. package/dist/machines/tour/index.d.mts +1 -1
  212. package/dist/machines/tour/index.mjs +6 -6
  213. package/dist/machines/tree-view/index.cjs +3 -3
  214. package/dist/machines/tree-view/index.d.cts +2 -2
  215. package/dist/machines/tree-view/index.d.mts +2 -2
  216. package/dist/machines/tree-view/index.mjs +3 -3
  217. package/dist/{popper-CfOHZlHP.mjs → popper-3Bdh0pfy.mjs} +1 -1
  218. package/dist/{popper-zq1F_iY8.cjs → popper-Bca_O70s.cjs} +1 -1
  219. package/dist/popper.cjs +2 -2
  220. package/dist/popper.mjs +2 -2
  221. package/dist/{remove-scroll-B8AJyezV.cjs → remove-scroll-D9FAOapi.cjs} +1 -1
  222. package/dist/{remove-scroll-DCUb1JPX.mjs → remove-scroll-HcSiTbd5.mjs} +1 -1
  223. package/dist/{scroll-snap-De0H9CWU.mjs → scroll-snap-DfSwN3As.mjs} +1 -1
  224. package/dist/{scroll-snap-voc0pMJd.cjs → scroll-snap-Dp_2adEa.cjs} +1 -1
  225. package/dist/scroll-snap.cjs +2 -2
  226. package/dist/scroll-snap.mjs +2 -2
  227. package/dist/{selection-DdNvrKbj.d.mts → selection-6urf-c8j.d.mts} +1 -1
  228. package/dist/{selection-Bb_ZSVxe.d.cts → selection-BmS2RDMq.d.cts} +1 -1
  229. package/dist/{tree-collection-DlBCued7.d.mts → tree-collection-Dlf9EUrT.d.mts} +2 -1
  230. package/dist/{tree-collection-DjtppzYh.d.cts → tree-collection-DlqV5kYO.d.cts} +2 -1
  231. package/package.json +11 -1
@@ -0,0 +1,1367 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_create_anatomy = require("../../create-anatomy-BnwEmNnc.cjs");
3
+ const require_dom_query = require("../../dom-query-Bd63cRVF.cjs");
4
+ const require_utils = require("../../utils-ByNiZU8f.cjs");
5
+ const require_collection = require("../../collection-BBgC8xCb.cjs");
6
+ const require_core = require("../../core-nBg9RC_y.cjs");
7
+ require("../../interact-outside-Cx4J0EBf.cjs");
8
+ const require_dismissable = require("../../dismissable-ChwcJMHk.cjs");
9
+ const require_popper = require("../../popper-Bca_O70s.cjs");
10
+ const require_rect_utils = require("../../rect-utils-D3RkAaHK.cjs");
11
+ const require_create_props = require("../../create-props-DP39rHnH.cjs");
12
+ //#region src/machines/cascade-select/cascade-select.anatomy.ts
13
+ const anatomy = require_create_anatomy.createAnatomy("cascade-select").parts("root", "label", "control", "trigger", "indicator", "valueText", "clearTrigger", "positioner", "content", "list", "item", "itemText", "itemIndicator");
14
+ const parts = anatomy.build();
15
+ //#endregion
16
+ //#region src/machines/cascade-select/cascade-select.collection.ts
17
+ const collection = (options) => {
18
+ return new require_collection.TreeCollection(options);
19
+ };
20
+ collection.empty = () => {
21
+ return new require_collection.TreeCollection({ rootNode: {
22
+ value: "ROOT",
23
+ children: []
24
+ } });
25
+ };
26
+ //#endregion
27
+ //#region src/machines/cascade-select/cascade-select.dom.ts
28
+ const dom = require_dom_query.createScope({
29
+ getRootId: (ctx) => ctx.ids?.root ?? `cascade-select:${ctx.id}`,
30
+ getLabelId: (ctx) => ctx.ids?.label ?? `cascade-select:${ctx.id}:label`,
31
+ getControlId: (ctx) => ctx.ids?.control ?? `cascade-select:${ctx.id}:control`,
32
+ getTriggerId: (ctx) => ctx.ids?.trigger ?? `cascade-select:${ctx.id}:trigger`,
33
+ getIndicatorId: (ctx) => ctx.ids?.indicator ?? `cascade-select:${ctx.id}:indicator`,
34
+ getClearTriggerId: (ctx) => ctx.ids?.clearTrigger ?? `cascade-select:${ctx.id}:clear-trigger`,
35
+ getPositionerId: (ctx) => ctx.ids?.positioner ?? `cascade-select:${ctx.id}:positioner`,
36
+ getContentId: (ctx) => ctx.ids?.content ?? `cascade-select:${ctx.id}:content`,
37
+ getHiddenInputId: (ctx) => ctx.ids?.hiddenInput ?? `cascade-select:${ctx.id}:hidden-input`,
38
+ getListId: (ctx, value) => ctx.ids?.list?.(value) ?? `cascade-select:${ctx.id}:list:${value}`,
39
+ getItemId: (ctx, value) => ctx.ids?.item?.(value) ?? `cascade-select:${ctx.id}:item:${value}`,
40
+ getRootEl: (ctx) => dom.getById(ctx, dom.getRootId(ctx)),
41
+ getLabelEl: (ctx) => dom.getById(ctx, dom.getLabelId(ctx)),
42
+ getControlEl: (ctx) => dom.getById(ctx, dom.getControlId(ctx)),
43
+ getTriggerEl: (ctx) => dom.getById(ctx, dom.getTriggerId(ctx)),
44
+ getIndicatorEl: (ctx) => dom.getById(ctx, dom.getIndicatorId(ctx)),
45
+ getClearTriggerEl: (ctx) => dom.getById(ctx, dom.getClearTriggerId(ctx)),
46
+ getPositionerEl: (ctx) => dom.getById(ctx, dom.getPositionerId(ctx)),
47
+ getContentEl: (ctx) => dom.getById(ctx, dom.getContentId(ctx)),
48
+ getHiddenInputEl: (ctx) => dom.getById(ctx, dom.getHiddenInputId(ctx)),
49
+ getListEl: (ctx, value) => dom.getById(ctx, dom.getListId(ctx, value)),
50
+ getListEls: (ctx) => require_dom_query.queryAll(dom.getContentEl(ctx), `[data-part="list"]`),
51
+ getItemEl: (ctx, value) => dom.getById(ctx, dom.getItemId(ctx, value)),
52
+ dispatchInputEvent: (ctx, value) => {
53
+ const inputEl = dom.getHiddenInputEl(ctx);
54
+ if (!inputEl) return;
55
+ require_dom_query.dispatchInputValueEvent(inputEl, { value });
56
+ }
57
+ });
58
+ //#endregion
59
+ //#region src/machines/cascade-select/cascade-select.connect.ts
60
+ function connect(service, normalize) {
61
+ const { send, context, prop, scope, computed, state } = service;
62
+ const collection = prop("collection");
63
+ const value = context.get("value");
64
+ const open = state.hasTag("open");
65
+ const focused = state.matches("focused");
66
+ const highlightedIndexPath = context.get("highlightedIndexPath");
67
+ const highlightedValue = context.get("highlightedValue");
68
+ const currentPlacement = context.get("currentPlacement");
69
+ const disabled = prop("disabled") || context.get("fieldsetDisabled");
70
+ const interactive = computed("isInteractive");
71
+ const valueAsString = computed("valueAsString");
72
+ const highlightedItem = context.get("highlightedItem");
73
+ const selectedItems = context.get("selectedItems");
74
+ const popperStyles = require_popper.getPlacementStyles({
75
+ ...prop("positioning"),
76
+ placement: currentPlacement
77
+ });
78
+ const getItemState = (props) => {
79
+ const { item, indexPath, value: itemValue } = props;
80
+ const depth = indexPath ? indexPath.length : 0;
81
+ const highlighted = itemValue.every((v, i) => v === highlightedValue[i]);
82
+ const selected = value.some((v) => require_utils.isEqual(v, itemValue));
83
+ const highlightedChild = collection.getNodeChildren(collection.at(indexPath))[highlightedIndexPath[depth]];
84
+ const highlightedIndex = highlightedIndexPath[depth];
85
+ return {
86
+ value: itemValue,
87
+ disabled: collection.getNodeDisabled(item),
88
+ highlighted,
89
+ selected,
90
+ hasChildren: collection.isBranchNode(item),
91
+ depth,
92
+ highlightedChild,
93
+ highlightedIndex
94
+ };
95
+ };
96
+ const hasSelectedItems = value.length > 0;
97
+ return {
98
+ collection,
99
+ open,
100
+ focused,
101
+ multiple: !!prop("multiple"),
102
+ disabled,
103
+ value,
104
+ highlightedValue,
105
+ highlightedItem,
106
+ selectedItems,
107
+ hasSelectedItems,
108
+ valueAsString,
109
+ reposition(options = {}) {
110
+ send({
111
+ type: "POSITIONING.SET",
112
+ options
113
+ });
114
+ },
115
+ focus() {
116
+ dom.getTriggerEl(scope)?.focus({ preventScroll: true });
117
+ },
118
+ setOpen(nextOpen) {
119
+ if (nextOpen === open) return;
120
+ send({ type: nextOpen ? "OPEN" : "CLOSE" });
121
+ },
122
+ highlightValue(value) {
123
+ send({
124
+ type: "HIGHLIGHTED_VALUE.SET",
125
+ value
126
+ });
127
+ },
128
+ setValue(value) {
129
+ send({
130
+ type: "VALUE.SET",
131
+ value
132
+ });
133
+ },
134
+ selectValue(value) {
135
+ send({
136
+ type: "ITEM.SELECT",
137
+ value
138
+ });
139
+ },
140
+ clearValue(value) {
141
+ if (value) send({
142
+ type: "ITEM.CLEAR",
143
+ value
144
+ });
145
+ else send({ type: "VALUE.CLEAR" });
146
+ },
147
+ getItemState,
148
+ getRootProps() {
149
+ return normalize.element({
150
+ ...parts.root.attrs,
151
+ id: dom.getRootId(scope),
152
+ dir: prop("dir"),
153
+ "data-disabled": require_dom_query.dataAttr(disabled),
154
+ "data-readonly": require_dom_query.dataAttr(prop("readOnly")),
155
+ "data-invalid": require_dom_query.dataAttr(prop("invalid")),
156
+ "data-state": open ? "open" : "closed"
157
+ });
158
+ },
159
+ getLabelProps() {
160
+ return normalize.label({
161
+ ...parts.label.attrs,
162
+ id: dom.getLabelId(scope),
163
+ dir: prop("dir"),
164
+ htmlFor: dom.getHiddenInputId(scope),
165
+ "data-disabled": require_dom_query.dataAttr(disabled),
166
+ "data-readonly": require_dom_query.dataAttr(prop("readOnly")),
167
+ "data-invalid": require_dom_query.dataAttr(prop("invalid")),
168
+ onClick(event) {
169
+ if (event.defaultPrevented) return;
170
+ if (disabled) return;
171
+ dom.getTriggerEl(scope)?.focus({ preventScroll: true });
172
+ }
173
+ });
174
+ },
175
+ getControlProps() {
176
+ return normalize.element({
177
+ ...parts.control.attrs,
178
+ dir: prop("dir"),
179
+ id: dom.getControlId(scope),
180
+ "data-disabled": require_dom_query.dataAttr(disabled),
181
+ "data-focused": require_dom_query.dataAttr(focused),
182
+ "data-readonly": require_dom_query.dataAttr(prop("readOnly")),
183
+ "data-invalid": require_dom_query.dataAttr(prop("invalid")),
184
+ "data-state": open ? "open" : "closed"
185
+ });
186
+ },
187
+ getTriggerProps() {
188
+ return normalize.button({
189
+ ...parts.trigger.attrs,
190
+ dir: prop("dir"),
191
+ id: dom.getTriggerId(scope),
192
+ type: "button",
193
+ role: "combobox",
194
+ "aria-controls": dom.getContentId(scope),
195
+ "aria-expanded": open,
196
+ "aria-haspopup": "listbox",
197
+ "aria-labelledby": dom.getLabelId(scope),
198
+ "data-state": open ? "open" : "closed",
199
+ "data-disabled": require_dom_query.dataAttr(disabled),
200
+ "data-readonly": require_dom_query.dataAttr(prop("readOnly")),
201
+ "data-invalid": require_dom_query.dataAttr(prop("invalid")),
202
+ "data-focused": require_dom_query.dataAttr(focused),
203
+ "data-placement": currentPlacement,
204
+ disabled,
205
+ onClick(event) {
206
+ if (event.defaultPrevented) return;
207
+ if (!interactive) return;
208
+ send({ type: "TRIGGER.CLICK" });
209
+ },
210
+ onFocus() {
211
+ send({ type: "TRIGGER.FOCUS" });
212
+ },
213
+ onBlur() {
214
+ send({ type: "TRIGGER.BLUR" });
215
+ },
216
+ onKeyDown(event) {
217
+ if (event.defaultPrevented) return;
218
+ if (!interactive) return;
219
+ const exec = {
220
+ ArrowUp() {
221
+ send({ type: "TRIGGER.ARROW_UP" });
222
+ },
223
+ ArrowDown(event) {
224
+ send({ type: event.altKey ? "OPEN" : "TRIGGER.ARROW_DOWN" });
225
+ },
226
+ ArrowLeft() {
227
+ send({ type: "TRIGGER.ARROW_LEFT" });
228
+ },
229
+ ArrowRight() {
230
+ send({ type: "TRIGGER.ARROW_RIGHT" });
231
+ },
232
+ Enter() {
233
+ send({ type: "TRIGGER.ENTER" });
234
+ },
235
+ Space() {
236
+ send({ type: "TRIGGER.ENTER" });
237
+ }
238
+ }[require_dom_query.getEventKey(event, { dir: prop("dir") })];
239
+ if (exec) {
240
+ exec(event);
241
+ event.preventDefault();
242
+ }
243
+ }
244
+ });
245
+ },
246
+ getClearTriggerProps() {
247
+ return normalize.button({
248
+ ...parts.clearTrigger.attrs,
249
+ dir: prop("dir"),
250
+ id: dom.getClearTriggerId(scope),
251
+ type: "button",
252
+ "aria-label": "Clear value",
253
+ hidden: !hasSelectedItems,
254
+ "data-disabled": require_dom_query.dataAttr(disabled),
255
+ "data-readonly": require_dom_query.dataAttr(prop("readOnly")),
256
+ "data-invalid": require_dom_query.dataAttr(prop("invalid")),
257
+ disabled,
258
+ onClick(event) {
259
+ if (event.defaultPrevented) return;
260
+ send({ type: "CLEAR_TRIGGER.CLICK" });
261
+ }
262
+ });
263
+ },
264
+ getPositionerProps() {
265
+ return normalize.element({
266
+ ...parts.positioner.attrs,
267
+ dir: prop("dir"),
268
+ id: dom.getPositionerId(scope),
269
+ style: popperStyles.floating
270
+ });
271
+ },
272
+ getContentProps() {
273
+ const highlightedItemId = highlightedValue ? dom.getItemId(scope, highlightedValue.toString()) : void 0;
274
+ return normalize.element({
275
+ ...parts.content.attrs,
276
+ id: dom.getContentId(scope),
277
+ role: "listbox",
278
+ "aria-labelledby": dom.getLabelId(scope),
279
+ "aria-activedescendant": highlightedItemId,
280
+ "data-activedescendant": highlightedItemId,
281
+ "data-state": open ? "open" : "closed",
282
+ "aria-multiselectable": prop("multiple"),
283
+ "aria-required": prop("required"),
284
+ "aria-readonly": prop("readOnly"),
285
+ hidden: !open,
286
+ tabIndex: 0,
287
+ onKeyDown(event) {
288
+ if (!interactive) return;
289
+ if (!require_dom_query.isSelfTarget(event)) return;
290
+ if (event.key === "Tab") {
291
+ if (!require_dom_query.isValidTabEvent(event)) {
292
+ event.preventDefault();
293
+ return;
294
+ }
295
+ }
296
+ const exec = {
297
+ ArrowDown() {
298
+ send({ type: "CONTENT.ARROW_DOWN" });
299
+ },
300
+ ArrowUp() {
301
+ send({ type: "CONTENT.ARROW_UP" });
302
+ },
303
+ ArrowRight() {
304
+ send({ type: "CONTENT.ARROW_RIGHT" });
305
+ },
306
+ ArrowLeft() {
307
+ send({ type: "CONTENT.ARROW_LEFT" });
308
+ },
309
+ Home() {
310
+ send({ type: "CONTENT.HOME" });
311
+ },
312
+ End() {
313
+ send({ type: "CONTENT.END" });
314
+ },
315
+ Enter() {
316
+ send({ type: "CONTENT.ENTER" });
317
+ },
318
+ " "() {
319
+ send({ type: "CONTENT.ENTER" });
320
+ }
321
+ }[require_dom_query.getEventKey(event, { dir: prop("dir") })];
322
+ if (exec) {
323
+ exec();
324
+ event.preventDefault();
325
+ return;
326
+ }
327
+ if (require_dom_query.isEditableElement(event.target)) return;
328
+ },
329
+ onPointerMove(event) {
330
+ if (!interactive) return;
331
+ send({
332
+ type: "POINTER_MOVE",
333
+ clientX: event.clientX,
334
+ clientY: event.clientY,
335
+ target: event.target
336
+ });
337
+ }
338
+ });
339
+ },
340
+ getListProps(props) {
341
+ const itemState = getItemState(props);
342
+ return normalize.element({
343
+ ...parts.list.attrs,
344
+ id: dom.getListId(scope, itemState.value.toString()),
345
+ dir: prop("dir"),
346
+ "data-depth": itemState.depth,
347
+ "aria-level": itemState.depth,
348
+ role: "group"
349
+ });
350
+ },
351
+ getIndicatorProps() {
352
+ return normalize.element({
353
+ ...parts.indicator.attrs,
354
+ id: dom.getIndicatorId(scope),
355
+ dir: prop("dir"),
356
+ "aria-hidden": true,
357
+ "data-state": open ? "open" : "closed",
358
+ "data-disabled": require_dom_query.dataAttr(disabled),
359
+ "data-readonly": require_dom_query.dataAttr(prop("readOnly")),
360
+ "data-invalid": require_dom_query.dataAttr(prop("invalid"))
361
+ });
362
+ },
363
+ getItemProps(props) {
364
+ const { indexPath } = props;
365
+ const itemState = getItemState(props);
366
+ return normalize.element({
367
+ ...parts.item.attrs,
368
+ id: dom.getItemId(scope, itemState.value.toString()),
369
+ dir: prop("dir"),
370
+ role: "treeitem",
371
+ "aria-haspopup": itemState.hasChildren ? "menu" : void 0,
372
+ "aria-expanded": itemState.hasChildren ? itemState.highlighted : false,
373
+ "aria-controls": itemState.hasChildren ? dom.getListId(scope, itemState.value.toString()) : void 0,
374
+ "aria-owns": itemState.hasChildren ? dom.getListId(scope, itemState.value.toString()) : void 0,
375
+ "aria-disabled": require_dom_query.ariaAttr(itemState.disabled),
376
+ "data-value": itemState.value.toString(),
377
+ "data-disabled": require_dom_query.dataAttr(itemState.disabled),
378
+ "data-highlighted": require_dom_query.dataAttr(itemState.highlighted),
379
+ "data-selected": require_dom_query.dataAttr(itemState.selected),
380
+ "data-depth": itemState.depth,
381
+ "data-state": itemState.selected ? "checked" : "unchecked",
382
+ "data-type": itemState.hasChildren ? "branch" : "leaf",
383
+ "data-index-path": indexPath.toString(),
384
+ onDoubleClick() {
385
+ if (itemState.disabled) return;
386
+ send({ type: "CLOSE" });
387
+ },
388
+ onClick(event) {
389
+ if (event.defaultPrevented) return;
390
+ if (!interactive) return;
391
+ if (itemState.disabled) return;
392
+ send({
393
+ type: "ITEM.CLICK",
394
+ value: itemState.value,
395
+ indexPath
396
+ });
397
+ },
398
+ onPointerEnter(event) {
399
+ if (!interactive) return;
400
+ if (itemState.disabled) return;
401
+ send({
402
+ type: "ITEM.POINTER_ENTER",
403
+ value: itemState.value,
404
+ indexPath,
405
+ clientX: event.clientX,
406
+ clientY: event.clientY
407
+ });
408
+ },
409
+ onPointerLeave(event) {
410
+ if (!interactive) return;
411
+ if (itemState.disabled) return;
412
+ if (event.pointerType !== "mouse") return;
413
+ if (!service.event.previous()?.type.includes("POINTER")) return;
414
+ send({
415
+ type: "ITEM.POINTER_LEAVE",
416
+ value: itemState.value,
417
+ indexPath,
418
+ clientX: event.clientX,
419
+ clientY: event.clientY
420
+ });
421
+ }
422
+ });
423
+ },
424
+ getItemTextProps(props) {
425
+ const { item } = props;
426
+ const itemValue = collection.getNodeValue(item);
427
+ const itemState = getItemState(props);
428
+ return normalize.element({
429
+ dir: prop("dir"),
430
+ ...parts.itemText.attrs,
431
+ "data-value": itemValue,
432
+ "data-highlighted": require_dom_query.dataAttr(itemState.highlighted),
433
+ "data-state": itemState.selected ? "checked" : "unchecked",
434
+ "data-disabled": require_dom_query.dataAttr(itemState.disabled)
435
+ });
436
+ },
437
+ getItemIndicatorProps(props) {
438
+ const { item } = props;
439
+ const itemValue = collection.getNodeValue(item);
440
+ const itemState = getItemState(props);
441
+ return normalize.element({
442
+ ...parts.itemIndicator.attrs,
443
+ dir: prop("dir"),
444
+ "data-value": itemValue,
445
+ "data-highlighted": require_dom_query.dataAttr(itemState.highlighted),
446
+ "data-type": itemState.hasChildren ? "branch" : "leaf",
447
+ "data-state": itemState.selected ? "checked" : "unchecked",
448
+ hidden: !itemState.selected
449
+ });
450
+ },
451
+ getHiddenInputProps() {
452
+ const defaultValue = context.hash("value");
453
+ return normalize.input({
454
+ name: prop("name"),
455
+ form: prop("form"),
456
+ disabled,
457
+ multiple: prop("multiple"),
458
+ required: prop("required"),
459
+ readOnly: prop("readOnly"),
460
+ hidden: true,
461
+ "aria-hidden": true,
462
+ id: dom.getHiddenInputId(scope),
463
+ defaultValue,
464
+ "aria-labelledby": dom.getLabelId(scope)
465
+ });
466
+ }
467
+ };
468
+ }
469
+ //#endregion
470
+ //#region src/machines/cascade-select/cascade-select.utils.ts
471
+ function createGraceArea(exitPoint, triggerRect, targetRect, options = {}) {
472
+ const { padding = 5 } = options;
473
+ const paddedExitPoints = getPaddedExitPoints(exitPoint, require_rect_utils.closestSideToPoint(require_rect_utils.createRect({
474
+ x: triggerRect.left,
475
+ y: triggerRect.top,
476
+ width: triggerRect.width,
477
+ height: triggerRect.height
478
+ }), exitPoint), padding);
479
+ const targetPoints = domRectToPoints(targetRect);
480
+ return getConvexHull([...paddedExitPoints, ...targetPoints]);
481
+ }
482
+ function isPointerInGraceArea(point, graceArea) {
483
+ return require_rect_utils.isPointInPolygon(graceArea, point);
484
+ }
485
+ function getPaddedExitPoints(exitPoint, exitSide, padding) {
486
+ const { x, y } = exitPoint;
487
+ switch (exitSide) {
488
+ case "top": return [require_rect_utils.createPoint(x - padding, y + padding), require_rect_utils.createPoint(x + padding, y + padding)];
489
+ case "bottom": return [require_rect_utils.createPoint(x - padding, y - padding), require_rect_utils.createPoint(x + padding, y - padding)];
490
+ case "left": return [require_rect_utils.createPoint(x + padding, y - padding), require_rect_utils.createPoint(x + padding, y + padding)];
491
+ case "right": return [require_rect_utils.createPoint(x - padding, y - padding), require_rect_utils.createPoint(x - padding, y + padding)];
492
+ default: return [];
493
+ }
494
+ }
495
+ function domRectToPoints(rect) {
496
+ const corners = require_rect_utils.getRectCorners(require_rect_utils.createRect({
497
+ x: rect.left,
498
+ y: rect.top,
499
+ width: rect.width,
500
+ height: rect.height
501
+ }));
502
+ return [
503
+ corners.top,
504
+ corners.right,
505
+ corners.bottom,
506
+ corners.left
507
+ ];
508
+ }
509
+ function getConvexHull(points) {
510
+ if (points.length <= 1) return points.slice();
511
+ const sortedPoints = points.slice().sort((a, b) => {
512
+ if (a.x !== b.x) return a.x - b.x;
513
+ return a.y - b.y;
514
+ });
515
+ const lower = [];
516
+ for (const point of sortedPoints) {
517
+ while (lower.length >= 2 && crossProduct(lower[lower.length - 2], lower[lower.length - 1], point) <= 0) lower.pop();
518
+ lower.push(point);
519
+ }
520
+ const upper = [];
521
+ for (let i = sortedPoints.length - 1; i >= 0; i--) {
522
+ const point = sortedPoints[i];
523
+ while (upper.length >= 2 && crossProduct(upper[upper.length - 2], upper[upper.length - 1], point) <= 0) upper.pop();
524
+ upper.push(point);
525
+ }
526
+ lower.pop();
527
+ upper.pop();
528
+ return lower.concat(upper);
529
+ }
530
+ function crossProduct(o, a, b) {
531
+ return (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
532
+ }
533
+ //#endregion
534
+ //#region src/machines/cascade-select/cascade-select.machine.ts
535
+ const { or, and, not } = require_core.createGuards();
536
+ const machine = require_core.createMachine({
537
+ props({ props }) {
538
+ return {
539
+ closeOnSelect: true,
540
+ loopFocus: false,
541
+ defaultValue: [],
542
+ defaultHighlightedValue: [],
543
+ defaultOpen: false,
544
+ multiple: false,
545
+ highlightTrigger: "click",
546
+ allowParentSelection: false,
547
+ positioning: {
548
+ placement: "bottom-start",
549
+ gutter: 8,
550
+ ...props.positioning
551
+ },
552
+ ...props,
553
+ collection: props.collection ?? collection.empty()
554
+ };
555
+ },
556
+ context({ prop, bindable }) {
557
+ return {
558
+ value: bindable(() => ({
559
+ defaultValue: prop("defaultValue"),
560
+ value: prop("value"),
561
+ isEqual: require_utils.isEqual,
562
+ hash(value) {
563
+ return value.join(", ");
564
+ }
565
+ })),
566
+ highlightedValue: bindable(() => ({
567
+ defaultValue: prop("defaultHighlightedValue"),
568
+ value: prop("highlightedValue"),
569
+ isEqual: require_utils.isEqual
570
+ })),
571
+ valueIndexPath: bindable(() => {
572
+ return { defaultValue: (prop("value") ?? prop("defaultValue") ?? []).map((v) => prop("collection").getIndexPath(v)) };
573
+ }),
574
+ highlightedIndexPath: bindable(() => {
575
+ const value = prop("highlightedValue") ?? prop("defaultHighlightedValue") ?? null;
576
+ return { defaultValue: value ? prop("collection").getIndexPath(value) : [] };
577
+ }),
578
+ highlightedItem: bindable(() => ({ defaultValue: null })),
579
+ selectedItems: bindable(() => ({ defaultValue: [] })),
580
+ currentPlacement: bindable(() => ({ defaultValue: void 0 })),
581
+ fieldsetDisabled: bindable(() => ({ defaultValue: false })),
582
+ graceArea: bindable(() => ({ defaultValue: null })),
583
+ isPointerInTransit: bindable(() => ({ defaultValue: false }))
584
+ };
585
+ },
586
+ computed: {
587
+ isInteractive: ({ prop }) => !(prop("disabled") || prop("readOnly")),
588
+ valueAsString: ({ prop, context }) => {
589
+ const collection = prop("collection");
590
+ const items = context.get("selectedItems");
591
+ const multiple = prop("multiple");
592
+ const formatMultipleMode = (items) => collection.stringifyNode(items.at(-1)) ?? collection.getNodeValue(items.at(-1));
593
+ const formatSingleMode = (items) => {
594
+ return items.map((item) => {
595
+ return collection.stringifyNode(item) ?? collection.getNodeValue(item);
596
+ }).join(" / ");
597
+ };
598
+ const defaultFormatValue = (items) => items.map(multiple ? formatMultipleMode : formatSingleMode).join(", ");
599
+ return (prop("formatValue") ?? defaultFormatValue)(items);
600
+ }
601
+ },
602
+ initialState({ prop }) {
603
+ return prop("open") || prop("defaultOpen") ? "open" : "idle";
604
+ },
605
+ watch({ context, prop, track, action }) {
606
+ track([() => context.get("value")?.toString()], () => {
607
+ action(["syncInputValue", "dispatchChangeEvent"]);
608
+ });
609
+ track([() => prop("open")], () => {
610
+ action(["toggleVisibility"]);
611
+ });
612
+ },
613
+ on: {
614
+ "VALUE.SET": { actions: ["setValue"] },
615
+ "VALUE.CLEAR": { actions: ["clearValue"] },
616
+ "CLEAR_TRIGGER.CLICK": { actions: ["clearValue", "focusTriggerEl"] },
617
+ "HIGHLIGHTED_VALUE.SET": { actions: ["setHighlightedValue"] },
618
+ "ITEM.SELECT": { actions: ["selectItem"] },
619
+ "ITEM.CLEAR": { actions: ["clearItem"] }
620
+ },
621
+ effects: ["trackFormControlState"],
622
+ states: {
623
+ idle: {
624
+ tags: ["closed"],
625
+ on: {
626
+ "CONTROLLED.OPEN": [{
627
+ guard: "isTriggerClickEvent",
628
+ target: "open",
629
+ actions: ["setInitialFocus", "highlightFirstSelectedItem"]
630
+ }, {
631
+ target: "open",
632
+ actions: ["setInitialFocus"]
633
+ }],
634
+ "TRIGGER.CLICK": [{
635
+ guard: "isOpenControlled",
636
+ actions: ["invokeOnOpen"]
637
+ }, {
638
+ target: "open",
639
+ actions: [
640
+ "invokeOnOpen",
641
+ "setInitialFocus",
642
+ "highlightFirstSelectedItem"
643
+ ]
644
+ }],
645
+ "TRIGGER.FOCUS": { target: "focused" },
646
+ OPEN: [{
647
+ guard: "isOpenControlled",
648
+ actions: ["invokeOnOpen"]
649
+ }, {
650
+ target: "open",
651
+ actions: ["setInitialFocus", "invokeOnOpen"]
652
+ }]
653
+ }
654
+ },
655
+ focused: {
656
+ tags: ["closed"],
657
+ on: {
658
+ "CONTROLLED.OPEN": [
659
+ {
660
+ guard: "isTriggerClickEvent",
661
+ target: "open",
662
+ actions: ["setInitialFocus", "highlightFirstSelectedItem"]
663
+ },
664
+ {
665
+ guard: "isTriggerArrowUpEvent",
666
+ target: "open",
667
+ actions: ["setInitialFocus", "highlightLastItem"]
668
+ },
669
+ {
670
+ guard: or("isTriggerArrowDownEvent", "isTriggerEnterEvent", ""),
671
+ target: "open",
672
+ actions: ["setInitialFocus", "highlightFirstItem"]
673
+ },
674
+ {
675
+ target: "open",
676
+ actions: ["setInitialFocus"]
677
+ }
678
+ ],
679
+ OPEN: [{
680
+ guard: "isOpenControlled",
681
+ actions: ["invokeOnOpen"]
682
+ }, {
683
+ target: "open",
684
+ actions: ["setInitialFocus", "invokeOnOpen"]
685
+ }],
686
+ "TRIGGER.BLUR": { target: "idle" },
687
+ "TRIGGER.CLICK": [{
688
+ guard: "isOpenControlled",
689
+ actions: ["invokeOnOpen"]
690
+ }, {
691
+ target: "open",
692
+ actions: [
693
+ "setInitialFocus",
694
+ "invokeOnOpen",
695
+ "highlightFirstSelectedItem"
696
+ ]
697
+ }],
698
+ "TRIGGER.ENTER": [{
699
+ guard: "isOpenControlled",
700
+ actions: ["invokeOnOpen"]
701
+ }, {
702
+ target: "open",
703
+ actions: [
704
+ "setInitialFocus",
705
+ "invokeOnOpen",
706
+ "highlightFirstItem"
707
+ ]
708
+ }],
709
+ "TRIGGER.ARROW_UP": [{
710
+ guard: "isOpenControlled",
711
+ actions: ["invokeOnOpen"]
712
+ }, {
713
+ target: "open",
714
+ actions: [
715
+ "setInitialFocus",
716
+ "invokeOnOpen",
717
+ "highlightLastItem"
718
+ ]
719
+ }],
720
+ "TRIGGER.ARROW_DOWN": [{
721
+ guard: "isOpenControlled",
722
+ actions: ["invokeOnOpen"]
723
+ }, {
724
+ target: "open",
725
+ actions: [
726
+ "setInitialFocus",
727
+ "invokeOnOpen",
728
+ "highlightFirstItem"
729
+ ]
730
+ }],
731
+ "TRIGGER.ARROW_LEFT": [{
732
+ guard: "isOpenControlled",
733
+ actions: ["invokeOnOpen"]
734
+ }, {
735
+ target: "open",
736
+ actions: ["invokeOnOpen"]
737
+ }],
738
+ "TRIGGER.ARROW_RIGHT": [{
739
+ guard: "isOpenControlled",
740
+ actions: ["invokeOnOpen"]
741
+ }, {
742
+ target: "open",
743
+ actions: ["invokeOnOpen", "highlightFirstItem"]
744
+ }]
745
+ }
746
+ },
747
+ open: {
748
+ tags: ["open"],
749
+ exit: ["clearHighlightedValue", "scrollContentToTop"],
750
+ effects: [
751
+ "trackDismissableElement",
752
+ "computePlacement",
753
+ "scrollToHighlightedItems"
754
+ ],
755
+ on: {
756
+ "CONTROLLED.CLOSE": [{
757
+ guard: "restoreFocus",
758
+ target: "focused",
759
+ actions: ["focusTriggerEl"]
760
+ }, { target: "idle" }],
761
+ CLOSE: [
762
+ {
763
+ guard: "isOpenControlled",
764
+ actions: ["invokeOnClose"]
765
+ },
766
+ {
767
+ guard: "restoreFocus",
768
+ target: "focused",
769
+ actions: ["invokeOnClose", "focusTriggerEl"]
770
+ },
771
+ {
772
+ target: "idle",
773
+ actions: ["invokeOnClose"]
774
+ }
775
+ ],
776
+ "TRIGGER.CLICK": [{
777
+ guard: "isOpenControlled",
778
+ actions: ["invokeOnClose"]
779
+ }, {
780
+ target: "focused",
781
+ actions: ["invokeOnClose", "focusTriggerEl"]
782
+ }],
783
+ "ITEM.CLICK": [
784
+ {
785
+ guard: and("canSelectItem", and("shouldCloseOnSelect", not("multiple")), "isOpenControlled"),
786
+ actions: ["selectItem", "invokeOnClose"]
787
+ },
788
+ {
789
+ guard: and("canSelectItem", and("shouldCloseOnSelect", not("multiple"))),
790
+ target: "focused",
791
+ actions: [
792
+ "selectItem",
793
+ "invokeOnClose",
794
+ "focusTriggerEl"
795
+ ]
796
+ },
797
+ {
798
+ guard: "canSelectItem",
799
+ actions: ["selectItem"]
800
+ },
801
+ { actions: ["setHighlightedValue"] }
802
+ ],
803
+ "ITEM.POINTER_ENTER": [{
804
+ guard: "isHoverHighlight",
805
+ actions: ["setHighlightingForHoveredItem"]
806
+ }],
807
+ "ITEM.POINTER_LEAVE": [{
808
+ guard: and("isHoverHighlight", "shouldHighlightOnHover"),
809
+ actions: ["createGraceArea"]
810
+ }],
811
+ POINTER_MOVE: [{
812
+ guard: and("isHoverHighlight", "hasGraceArea", "isPointerOutsideGraceArea", "isPointerNotInAnyItem", "hasHighlightedValue"),
813
+ actions: ["clearGraceArea"]
814
+ }],
815
+ "GRACE_AREA.CLEAR": [{
816
+ guard: "isHoverHighlight",
817
+ actions: ["clearGraceArea"]
818
+ }],
819
+ "CONTENT.HOME": { actions: ["highlightFirstItem"] },
820
+ "CONTENT.END": { actions: ["highlightLastItem"] },
821
+ "CONTENT.ARROW_DOWN": [{
822
+ guard: or(not("hasHighlightedValue"), and("loop", "isHighlightedLastItem")),
823
+ actions: ["highlightFirstItem"]
824
+ }, { actions: ["highlightNextItem"] }],
825
+ "CONTENT.ARROW_UP": [{
826
+ guard: or(not("hasHighlightedValue"), and("loop", "isHighlightedFirstItem")),
827
+ actions: ["highlightLastItem"]
828
+ }, { actions: ["highlightPreviousItem"] }],
829
+ "CONTENT.ARROW_RIGHT": [{
830
+ guard: "canNavigateToChild",
831
+ actions: ["highlightFirstChild"]
832
+ }],
833
+ "CONTENT.ARROW_LEFT": [
834
+ {
835
+ guard: and("isAtRootLevel", "isOpenControlled"),
836
+ actions: ["invokeOnClose", "focusTriggerEl"]
837
+ },
838
+ {
839
+ guard: and("isAtRootLevel", "restoreFocus"),
840
+ target: "focused",
841
+ actions: ["invokeOnClose", "focusTriggerEl"]
842
+ },
843
+ {
844
+ guard: "isAtRootLevel",
845
+ target: "idle",
846
+ actions: ["invokeOnClose"]
847
+ },
848
+ {
849
+ guard: "canNavigateToParent",
850
+ actions: ["highlightParent"]
851
+ }
852
+ ],
853
+ "CONTENT.ENTER": [
854
+ {
855
+ guard: and("canSelectHighlightedItem", and("shouldCloseOnSelectHighlighted", not("multiple")), "isOpenControlled"),
856
+ actions: ["selectHighlightedItem", "invokeOnClose"]
857
+ },
858
+ {
859
+ guard: and("canSelectHighlightedItem", and("shouldCloseOnSelectHighlighted", not("multiple"))),
860
+ target: "focused",
861
+ actions: [
862
+ "selectHighlightedItem",
863
+ "invokeOnClose",
864
+ "focusTriggerEl"
865
+ ]
866
+ },
867
+ {
868
+ guard: "canSelectHighlightedItem",
869
+ actions: ["selectHighlightedItem"]
870
+ }
871
+ ],
872
+ "POSITIONING.SET": { actions: ["reposition"] }
873
+ }
874
+ }
875
+ },
876
+ implementations: {
877
+ guards: {
878
+ restoreFocus: ({ event }) => restoreFocusFn(event),
879
+ multiple: ({ prop }) => !!prop("multiple"),
880
+ loop: ({ prop }) => !!prop("loopFocus"),
881
+ isOpenControlled: ({ prop }) => !!prop("open"),
882
+ isTriggerClickEvent: ({ event }) => event.previousEvent?.type === "TRIGGER.CLICK",
883
+ isTriggerArrowUpEvent: ({ event }) => event.previousEvent?.type === "TRIGGER.ARROW_UP",
884
+ isTriggerArrowDownEvent: ({ event }) => event.previousEvent?.type === "TRIGGER.ARROW_DOWN",
885
+ isTriggerEnterEvent: ({ event }) => event.previousEvent?.type === "TRIGGER.ENTER",
886
+ isTriggerArrowRightEvent: ({ event }) => event.previousEvent?.type === "TRIGGER.ARROW_RIGHT",
887
+ hasHighlightedValue: ({ context }) => context.get("highlightedValue").length > 0,
888
+ isHighlightedFirstItem: ({ context }) => context.get("highlightedIndexPath").at(-1) === 0,
889
+ isHighlightedLastItem: ({ prop, context }) => {
890
+ const path = context.get("highlightedIndexPath");
891
+ const itemIndex = path.at(-1);
892
+ if (!itemIndex && itemIndex !== 0) return false;
893
+ const parentIndexPath = path.slice(0, -1);
894
+ return !prop("collection").at([...parentIndexPath, itemIndex + 1]);
895
+ },
896
+ shouldCloseOnSelect: ({ prop, event }) => {
897
+ const collection = prop("collection");
898
+ const node = collection.at(event.indexPath);
899
+ return prop("closeOnSelect") && node && !collection.isBranchNode(node);
900
+ },
901
+ shouldCloseOnSelectHighlighted: ({ prop, context }) => {
902
+ const collection = prop("collection");
903
+ const node = context.get("highlightedItem");
904
+ return prop("closeOnSelect") && !collection.isBranchNode(node);
905
+ },
906
+ canSelectItem: ({ prop, event }) => {
907
+ const collection = prop("collection");
908
+ const node = collection.at(event.indexPath);
909
+ if (!node) return false;
910
+ return prop("allowParentSelection") || !collection.isBranchNode(node);
911
+ },
912
+ canSelectHighlightedItem: ({ prop, context }) => {
913
+ const collection = prop("collection");
914
+ const node = collection.at(context.get("highlightedIndexPath"));
915
+ if (!node) return false;
916
+ return prop("allowParentSelection") || !collection.isBranchNode(node);
917
+ },
918
+ canNavigateToChild: ({ prop, context }) => {
919
+ const highlightedIndexPath = context.get("highlightedIndexPath");
920
+ if (!highlightedIndexPath.length) return false;
921
+ const collection = prop("collection");
922
+ const node = collection.at(highlightedIndexPath);
923
+ return node && collection.isBranchNode(node);
924
+ },
925
+ canNavigateToParent: ({ context }) => context.get("highlightedIndexPath").length > 1,
926
+ isAtRootLevel: ({ context }) => context.get("highlightedIndexPath").length <= 1,
927
+ isHoverHighlight: ({ prop }) => prop("highlightTrigger") === "hover",
928
+ shouldHighlightOnHover: ({ prop, event }) => {
929
+ const collection = prop("collection");
930
+ const node = collection.at(event.indexPath);
931
+ return node && collection.isBranchNode(node);
932
+ },
933
+ shouldUpdateHighlightedIndexPath: ({ prop, context, event }) => {
934
+ const collection = prop("collection");
935
+ const currentHighlightedIndexPath = context.get("highlightedIndexPath");
936
+ if (!currentHighlightedIndexPath || currentHighlightedIndexPath.length === 0) return false;
937
+ const node = collection.at(event.indexPath);
938
+ if (!node || collection.isBranchNode(node)) return false;
939
+ const indexPath = event.indexPath;
940
+ if (!indexPath) return false;
941
+ const minLength = Math.min(indexPath.length, currentHighlightedIndexPath.length);
942
+ let commonPrefixLength = 0;
943
+ for (let i = 0; i < minLength; i++) if (indexPath[i] === currentHighlightedIndexPath[i]) commonPrefixLength = i + 1;
944
+ else break;
945
+ return commonPrefixLength > 0 && (commonPrefixLength < currentHighlightedIndexPath.length || commonPrefixLength < indexPath.length);
946
+ },
947
+ hasGraceArea: ({ context }) => {
948
+ return context.get("graceArea") != null;
949
+ },
950
+ isPointerOutsideGraceArea: ({ context, event }) => {
951
+ const graceArea = context.get("graceArea");
952
+ if (!graceArea) return false;
953
+ return !isPointerInGraceArea({
954
+ x: event.clientX,
955
+ y: event.clientY
956
+ }, graceArea);
957
+ },
958
+ isPointerNotInAnyItem: ({ event }) => {
959
+ const target = event.target;
960
+ const itemElement = target.closest("[data-part=\"item\"]");
961
+ const contentElement = target.closest("[data-part=\"content\"]");
962
+ return !contentElement || !itemElement && !!contentElement;
963
+ }
964
+ },
965
+ effects: {
966
+ trackFormControlState({ context, scope, prop }) {
967
+ return require_dom_query.trackFormControl(dom.getTriggerEl(scope), {
968
+ onFieldsetDisabledChange(disabled) {
969
+ context.set("fieldsetDisabled", disabled);
970
+ },
971
+ onFormReset() {
972
+ context.set("value", prop("defaultValue") ?? []);
973
+ }
974
+ });
975
+ },
976
+ trackDismissableElement({ scope, send, prop }) {
977
+ const contentEl = () => dom.getContentEl(scope);
978
+ let restoreFocus = true;
979
+ return require_dismissable.trackDismissableElement(contentEl, {
980
+ defer: true,
981
+ exclude: [dom.getTriggerEl(scope), dom.getClearTriggerEl(scope)],
982
+ onFocusOutside: prop("onFocusOutside"),
983
+ onPointerDownOutside: prop("onPointerDownOutside"),
984
+ onInteractOutside(event) {
985
+ prop("onInteractOutside")?.(event);
986
+ restoreFocus = !(event.detail.focusable || event.detail.contextmenu);
987
+ },
988
+ onDismiss() {
989
+ send({
990
+ type: "CLOSE",
991
+ src: "interact-outside",
992
+ restoreFocus
993
+ });
994
+ }
995
+ });
996
+ },
997
+ computePlacement({ context, prop, scope }) {
998
+ const triggerEl = () => dom.getTriggerEl(scope);
999
+ const positionerEl = () => dom.getPositionerEl(scope);
1000
+ return require_popper.getPlacement(triggerEl, positionerEl, {
1001
+ ...prop("positioning"),
1002
+ onComplete(data) {
1003
+ context.set("currentPlacement", data.placement);
1004
+ }
1005
+ });
1006
+ },
1007
+ scrollToHighlightedItems({ context, prop, scope, event }) {
1008
+ let cleanups = [];
1009
+ const exec = (immediate) => {
1010
+ const highlightedValue = context.get("highlightedValue");
1011
+ const highlightedIndexPath = context.get("highlightedIndexPath");
1012
+ if (!highlightedIndexPath.length) return;
1013
+ if (event.current().type.includes("POINTER")) return;
1014
+ dom.getListEls(scope).forEach((listEl, index) => {
1015
+ const itemPath = highlightedIndexPath.slice(0, index + 1);
1016
+ const itemEl = dom.getItemEl(scope, highlightedValue.toString());
1017
+ const scrollToIndexFn = prop("scrollToIndexFn");
1018
+ if (scrollToIndexFn) {
1019
+ const itemIndexInList = itemPath[itemPath.length - 1];
1020
+ scrollToIndexFn({
1021
+ index: itemIndexInList,
1022
+ immediate,
1023
+ depth: index
1024
+ });
1025
+ return;
1026
+ }
1027
+ const raf_cleanup = require_dom_query.raf(() => {
1028
+ require_dom_query.scrollIntoView(itemEl, {
1029
+ rootEl: listEl,
1030
+ block: "nearest"
1031
+ });
1032
+ });
1033
+ cleanups.push(raf_cleanup);
1034
+ });
1035
+ };
1036
+ require_dom_query.raf(() => exec(true));
1037
+ const rafCleanup = require_dom_query.raf(() => exec(true));
1038
+ cleanups.push(rafCleanup);
1039
+ const observerCleanup = require_dom_query.observeAttributes(dom.getContentEl(scope), {
1040
+ attributes: ["data-activedescendant"],
1041
+ callback: () => exec(false)
1042
+ });
1043
+ cleanups.push(observerCleanup);
1044
+ return () => {
1045
+ cleanups.forEach((cleanup) => cleanup());
1046
+ };
1047
+ }
1048
+ },
1049
+ actions: {
1050
+ setValue(params) {
1051
+ set.value(params, params.event.value);
1052
+ },
1053
+ clearValue(params) {
1054
+ set.value(params, []);
1055
+ },
1056
+ setHighlightedValue(params) {
1057
+ const { event } = params;
1058
+ set.highlightedValue(params, event.value);
1059
+ },
1060
+ clearHighlightedValue(params) {
1061
+ set.highlightedValue(params, []);
1062
+ },
1063
+ reposition({ context, prop, scope, event }) {
1064
+ const positionerEl = () => dom.getPositionerEl(scope);
1065
+ require_popper.getPlacement(dom.getTriggerEl(scope), positionerEl, {
1066
+ ...prop("positioning"),
1067
+ ...event.options,
1068
+ defer: true,
1069
+ listeners: false,
1070
+ onComplete(data) {
1071
+ context.set("currentPlacement", data.placement);
1072
+ }
1073
+ });
1074
+ },
1075
+ selectItem(params) {
1076
+ const { context, prop, event } = params;
1077
+ const collection = prop("collection");
1078
+ const multiple = prop("multiple");
1079
+ const value = context.get("value");
1080
+ const itemValue = event.value;
1081
+ const indexPath = event.indexPath ?? collection.getIndexPath(itemValue);
1082
+ const node = collection.at(indexPath);
1083
+ const hasChildren = collection.isBranchNode(node);
1084
+ if (prop("allowParentSelection")) {
1085
+ if (multiple) {
1086
+ const filteredValue = value.filter((v) => {
1087
+ const shortPath = v.length < itemValue.length ? v : itemValue;
1088
+ return !(v.length < itemValue.length ? itemValue : v).slice(0, shortPath.length).every((val, i) => val === shortPath[i]) && !require_utils.isEqual(v, itemValue);
1089
+ });
1090
+ set.value(params, [...filteredValue, itemValue]);
1091
+ } else set.value(params, [itemValue]);
1092
+ if (hasChildren) set.highlightedValue(params, itemValue);
1093
+ } else if (hasChildren) {
1094
+ if (multiple && value.length > 0) set.value(params, [...value.slice(0, -1), itemValue]);
1095
+ else set.value(params, [itemValue]);
1096
+ set.highlightedValue(params, itemValue);
1097
+ } else if (multiple) {
1098
+ const existingIndex = value.findIndex((path) => require_utils.isEqual(path, itemValue));
1099
+ if (existingIndex >= 0) {
1100
+ const newValues = [...value];
1101
+ newValues.splice(existingIndex, 1);
1102
+ set.value(params, newValues);
1103
+ } else set.value(params, [...value, itemValue]);
1104
+ } else set.value(params, [itemValue]);
1105
+ },
1106
+ clearItem(params) {
1107
+ const { context, event } = params;
1108
+ const newValue = context.get("value").filter((v) => !require_utils.isEqual(v, event.value));
1109
+ set.value(params, newValue);
1110
+ },
1111
+ selectHighlightedItem({ context, send }) {
1112
+ const indexPath = context.get("highlightedIndexPath");
1113
+ const value = context.get("highlightedValue");
1114
+ if (value) send({
1115
+ type: "ITEM.SELECT",
1116
+ value,
1117
+ indexPath
1118
+ });
1119
+ },
1120
+ highlightFirstItem(params) {
1121
+ const { context, prop } = params;
1122
+ const collection = prop("collection");
1123
+ const highlightedValue = context.get("highlightedValue");
1124
+ let parentNode;
1125
+ if (!highlightedValue.length) parentNode = collection.rootNode;
1126
+ else {
1127
+ const indexPath = context.get("highlightedIndexPath");
1128
+ parentNode = collection.getParentNode(indexPath) ?? collection.rootNode;
1129
+ }
1130
+ const firstChild = collection.getNodeChildren(parentNode).find((child) => !collection.getNodeDisabled(child));
1131
+ if (!firstChild) return;
1132
+ const firstValue = collection.getNodeValue(firstChild);
1133
+ if (!highlightedValue.length) set.highlightedValue(params, [firstValue]);
1134
+ else {
1135
+ const parentPath = highlightedValue.slice(0, -1);
1136
+ set.highlightedValue(params, [...parentPath, firstValue]);
1137
+ }
1138
+ },
1139
+ highlightLastItem(params) {
1140
+ const { context, prop } = params;
1141
+ const collection = prop("collection");
1142
+ const highlightedValue = context.get("highlightedValue");
1143
+ let parentNode;
1144
+ if (!highlightedValue.length) parentNode = collection.rootNode;
1145
+ else {
1146
+ const indexPath = context.get("highlightedIndexPath");
1147
+ parentNode = collection.getParentNode(indexPath) ?? collection.rootNode;
1148
+ }
1149
+ const lastChild = collection.getNodeChildren(parentNode).findLast((child) => !collection.getNodeDisabled(child));
1150
+ if (!lastChild) return;
1151
+ const lastValue = collection.getNodeValue(lastChild);
1152
+ if (!highlightedValue.length) set.highlightedValue(params, [lastValue]);
1153
+ else {
1154
+ const parentPath = highlightedValue.slice(0, -1);
1155
+ set.highlightedValue(params, [...parentPath, lastValue]);
1156
+ }
1157
+ },
1158
+ highlightNextItem(params) {
1159
+ const { context, prop } = params;
1160
+ const collection = prop("collection");
1161
+ const highlightedValue = context.get("highlightedValue");
1162
+ if (!highlightedValue.length) return;
1163
+ const indexPath = context.get("highlightedIndexPath");
1164
+ const nextSibling = collection.getNextSibling(indexPath);
1165
+ if (!nextSibling) return;
1166
+ const nextValue = collection.getNodeValue(nextSibling);
1167
+ if (highlightedValue.length === 1) set.highlightedValue(params, [nextValue]);
1168
+ else {
1169
+ const parentPath = highlightedValue.slice(0, -1);
1170
+ set.highlightedValue(params, [...parentPath, nextValue]);
1171
+ }
1172
+ },
1173
+ highlightPreviousItem(params) {
1174
+ const { context, prop } = params;
1175
+ const collection = prop("collection");
1176
+ const highlightedValue = context.get("highlightedValue");
1177
+ if (!highlightedValue.length) return;
1178
+ const indexPath = context.get("highlightedIndexPath");
1179
+ const previousSibling = collection.getPreviousSibling(indexPath);
1180
+ if (!previousSibling) return;
1181
+ const prevValue = collection.getNodeValue(previousSibling);
1182
+ if (highlightedValue.length === 1) set.highlightedValue(params, [prevValue]);
1183
+ else {
1184
+ const parentPath = highlightedValue.slice(0, -1);
1185
+ set.highlightedValue(params, [...parentPath, prevValue]);
1186
+ }
1187
+ },
1188
+ highlightFirstChild(params) {
1189
+ const { context, prop } = params;
1190
+ const collection = prop("collection");
1191
+ const highlightedValue = context.get("highlightedValue");
1192
+ if (!highlightedValue.length) return;
1193
+ const indexPath = context.get("highlightedIndexPath");
1194
+ const node = collection.getFirstNode(collection.at(indexPath));
1195
+ if (!node) return;
1196
+ const childValue = collection.getNodeValue(node);
1197
+ set.highlightedValue(params, [...highlightedValue, childValue]);
1198
+ },
1199
+ highlightParent(params) {
1200
+ const { context } = params;
1201
+ const highlightedValue = context.get("highlightedValue");
1202
+ if (!highlightedValue.length) return;
1203
+ const parentPath = highlightedValue.slice(0, -1);
1204
+ set.highlightedValue(params, parentPath);
1205
+ },
1206
+ setInitialFocus({ scope }) {
1207
+ require_dom_query.raf(() => {
1208
+ dom.getContentEl(scope)?.focus({ preventScroll: true });
1209
+ });
1210
+ },
1211
+ focusTriggerEl({ event, scope }) {
1212
+ if (!restoreFocusFn(event)) return;
1213
+ require_dom_query.raf(() => {
1214
+ dom.getTriggerEl(scope)?.focus({ preventScroll: true });
1215
+ });
1216
+ },
1217
+ invokeOnOpen({ prop }) {
1218
+ prop("onOpenChange")?.({ open: true });
1219
+ },
1220
+ invokeOnClose({ prop }) {
1221
+ prop("onOpenChange")?.({ open: false });
1222
+ },
1223
+ toggleVisibility({ send, prop }) {
1224
+ if (prop("open") != null) send({ type: prop("open") ? "CONTROLLED.OPEN" : "CONTROLLED.CLOSE" });
1225
+ },
1226
+ highlightFirstSelectedItem(params) {
1227
+ const { context } = params;
1228
+ const value = context.get("value");
1229
+ if (require_utils.isEmpty(value)) return;
1230
+ const mostRecentSelection = require_utils.last(value);
1231
+ if (mostRecentSelection) set.highlightedValue(params, mostRecentSelection);
1232
+ },
1233
+ createGraceArea({ context, event, scope }) {
1234
+ const value = event.value.toString();
1235
+ const triggerElement = dom.getItemEl(scope, value);
1236
+ if (!triggerElement) return;
1237
+ const exitPoint = {
1238
+ x: event.clientX,
1239
+ y: event.clientY
1240
+ };
1241
+ const triggerRect = triggerElement.getBoundingClientRect();
1242
+ const nextLevelEl = dom.getListEl(scope, value);
1243
+ if (!nextLevelEl) return;
1244
+ const graceArea = createGraceArea(exitPoint, triggerRect, nextLevelEl.getBoundingClientRect());
1245
+ context.set("graceArea", graceArea);
1246
+ setTimeout(() => {
1247
+ context.set("graceArea", null);
1248
+ }, 300);
1249
+ },
1250
+ clearGraceArea({ context }) {
1251
+ context.set("graceArea", null);
1252
+ },
1253
+ setHighlightingForHoveredItem(params) {
1254
+ const { prop, event } = params;
1255
+ const collection = prop("collection");
1256
+ const node = collection.at(event.indexPath);
1257
+ let newHighlightedValue;
1258
+ if (node && collection.isBranchNode(node)) newHighlightedValue = event.value;
1259
+ else newHighlightedValue = event.value.slice(0, -1);
1260
+ set.highlightedValue(params, newHighlightedValue);
1261
+ },
1262
+ syncInputValue({ context, scope }) {
1263
+ const inputEl = dom.getHiddenInputEl(scope);
1264
+ if (!inputEl) return;
1265
+ require_dom_query.setElementValue(inputEl, context.hash("value"));
1266
+ },
1267
+ dispatchChangeEvent({ scope, context }) {
1268
+ require_dom_query.dispatchInputValueEvent(dom.getHiddenInputEl(scope), { value: context.hash("value") });
1269
+ },
1270
+ scrollContentToTop({ scope, prop }) {
1271
+ const scrollToIndexFn = prop("scrollToIndexFn");
1272
+ require_dom_query.raf(() => {
1273
+ (dom.getContentEl(scope)?.querySelectorAll("[data-part=\"list\"]"))?.forEach((listEl, index) => {
1274
+ if (scrollToIndexFn) scrollToIndexFn({
1275
+ index: 0,
1276
+ immediate: true,
1277
+ depth: index
1278
+ });
1279
+ else listEl.scrollTop = 0;
1280
+ });
1281
+ });
1282
+ }
1283
+ }
1284
+ }
1285
+ });
1286
+ const set = {
1287
+ value({ context, prop }, value) {
1288
+ const collection = prop("collection");
1289
+ context.set("value", value);
1290
+ const valueIndexPath = value.map((v) => collection.getIndexPath(v));
1291
+ context.set("valueIndexPath", valueIndexPath);
1292
+ const selectedItems = valueIndexPath.map((indexPath) => {
1293
+ return indexPath.map((_, index) => {
1294
+ const partialPath = indexPath.slice(0, index + 1);
1295
+ return collection.at(partialPath);
1296
+ });
1297
+ });
1298
+ context.set("selectedItems", selectedItems);
1299
+ prop("onValueChange")?.({
1300
+ value,
1301
+ items: selectedItems
1302
+ });
1303
+ },
1304
+ highlightedValue({ context, prop }, value) {
1305
+ const collection = prop("collection");
1306
+ context.set("highlightedValue", value);
1307
+ const highlightedIndexPath = value == null ? [] : collection.getIndexPath(value);
1308
+ context.set("highlightedIndexPath", highlightedIndexPath);
1309
+ const highlightedItem = highlightedIndexPath.map((_, index) => {
1310
+ const partialPath = highlightedIndexPath.slice(0, index + 1);
1311
+ return collection.at(partialPath);
1312
+ });
1313
+ context.set("highlightedItem", highlightedItem);
1314
+ prop("onHighlightChange")?.({
1315
+ value,
1316
+ items: highlightedItem
1317
+ });
1318
+ }
1319
+ };
1320
+ function restoreFocusFn(event) {
1321
+ const v = event.restoreFocus ?? event.previousEvent?.restoreFocus;
1322
+ return v == null || !!v;
1323
+ }
1324
+ //#endregion
1325
+ //#region src/machines/cascade-select/cascade-select.props.ts
1326
+ const props = require_create_props.createProps()([
1327
+ "allowParentSelection",
1328
+ "closeOnSelect",
1329
+ "collection",
1330
+ "defaultOpen",
1331
+ "defaultValue",
1332
+ "defaultHighlightedValue",
1333
+ "dir",
1334
+ "disabled",
1335
+ "formatValue",
1336
+ "form",
1337
+ "getRootNode",
1338
+ "highlightedValue",
1339
+ "highlightTrigger",
1340
+ "id",
1341
+ "ids",
1342
+ "invalid",
1343
+ "loopFocus",
1344
+ "multiple",
1345
+ "name",
1346
+ "onFocusOutside",
1347
+ "onHighlightChange",
1348
+ "onInteractOutside",
1349
+ "onOpenChange",
1350
+ "onPointerDownOutside",
1351
+ "onValueChange",
1352
+ "open",
1353
+ "positioning",
1354
+ "readOnly",
1355
+ "required",
1356
+ "scrollToIndexFn",
1357
+ "value"
1358
+ ]);
1359
+ const splitProps = require_utils.createSplitProps(props);
1360
+ //#endregion
1361
+ exports.anatomy = anatomy;
1362
+ exports.collection = collection;
1363
+ exports.connect = connect;
1364
+ exports.machine = machine;
1365
+ exports.parts = parts;
1366
+ exports.props = props;
1367
+ exports.splitProps = splitProps;