@midas-ds/components 1.0.2 → 1.1.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 (175) hide show
  1. package/Button-DL6nqUco.js +182 -0
  2. package/CHANGELOG.md +15 -0
  3. package/Checkbox-q0dugR2t.js +402 -0
  4. package/{Collection-B3xUVWPF.js → Collection-KMFfVuzU.js} +179 -152
  5. package/Dialog-D6Bqrpn-.js +1952 -0
  6. package/Disclosure-dAZYXyTH.js +225 -0
  7. package/Disclosure.css +1 -0
  8. package/DragAndDrop-B0T3WgjL.js +40 -0
  9. package/FocusScope-B7CkxXNC.js +513 -0
  10. package/{Form-DXLoQL91.js → Form-BWBjJC6v.js} +79 -81
  11. package/Group-D7_8007y.js +42 -0
  12. package/Heading-RCRHv6hd.js +15 -0
  13. package/{Hidden-BQWDvze4.js → Hidden-CVlUgUJM.js} +1 -1
  14. package/Link-BnQvB-hH.js +75 -0
  15. package/ListBox-DBBiqvcR.js +474 -0
  16. package/ListKeyboardDelegate-gCXy-Xnn.js +172 -0
  17. package/PressResponder-B4g56kDz.js +31 -0
  18. package/README.md +21 -3
  19. package/{RSPContexts-EOiWkKOf.js → RSPContexts-BW2SEIqe.js} +2 -2
  20. package/SelectionManager-BfXUE1qg.js +1031 -0
  21. package/Separator-BBX9m2O2.js +49 -0
  22. package/Tag-DWt0koFj.js +728 -0
  23. package/Text-BCF0xvqL.js +15 -0
  24. package/TextField-CX4eOQf6.js +225 -0
  25. package/TextField.module-DdICj682.js +143 -0
  26. package/{VisuallyHidden-B_XzVvlX.js → VisuallyHidden-Dhr5caPC.js} +1 -1
  27. package/accordion/Accordion.d.ts +8 -8
  28. package/accordion/AccordionItem.d.ts +11 -3
  29. package/accordion/index.d.ts +0 -3
  30. package/{context-ScOIq_Gu.js → context-BpJLnOuu.js} +11 -11
  31. package/global.css +1 -0
  32. package/index-B-jHjTDC.js +120 -0
  33. package/{index-CorR1LBD.js → index-BPdc9gJ8.js} +3 -3
  34. package/{index-Dl1Q-tbj.js → index-KSgQWWiy.js} +5315 -5315
  35. package/index.d.ts +1 -0
  36. package/index.js +105 -112
  37. package/index10.js +1 -1
  38. package/index11.js +1 -1
  39. package/index12.js +1 -1
  40. package/index13.js +1 -1
  41. package/index14.js +1 -1
  42. package/index15.js +2 -2
  43. package/index16.js +2 -2
  44. package/index17.js +1 -1
  45. package/index18.js +1 -1
  46. package/index19.js +2 -2
  47. package/index2.js +1 -1
  48. package/index20.js +2 -2
  49. package/index21.js +1 -1
  50. package/index22.js +1 -1
  51. package/index23.js +1 -1
  52. package/index24.js +1 -1
  53. package/index25.js +2 -2
  54. package/index26.js +2 -2
  55. package/index27.js +2 -2
  56. package/index28.js +1 -1
  57. package/index29.js +2 -8
  58. package/index3.js +2 -4
  59. package/index30.js +17 -16
  60. package/index31.js +3 -3
  61. package/index32.js +3 -3
  62. package/index33.js +2 -2
  63. package/index34.js +3 -3
  64. package/index35.js +1 -1
  65. package/index36.js +2 -2
  66. package/index37.js +2 -2
  67. package/index38.js +2 -2
  68. package/index39.js +2 -2
  69. package/index4.js +1 -1
  70. package/index40.js +19 -12
  71. package/index41.js +61 -14
  72. package/index42.js +44 -22
  73. package/index43.js +13 -11
  74. package/index44.js +25 -4
  75. package/index45.js +16 -51
  76. package/index46.js +19 -16
  77. package/index47.js +49 -27
  78. package/index48.js +5 -18
  79. package/index49.js +25 -21
  80. package/index5.js +1 -1
  81. package/index50.js +16 -47
  82. package/index51.js +7 -3
  83. package/index52.js +18 -18
  84. package/index53.js +16 -16
  85. package/index54.js +6 -4
  86. package/index55.js +8 -21
  87. package/index56.js +13 -16
  88. package/index57.js +6 -8
  89. package/index58.js +6 -9
  90. package/index59.js +17 -13
  91. package/index6.js +1 -1
  92. package/index60.js +20 -7
  93. package/index61.js +59 -7
  94. package/index62.js +13 -17
  95. package/index63.js +9 -20
  96. package/index64.js +40 -48
  97. package/index65.js +85 -15
  98. package/index66.js +74 -11
  99. package/index67.js +23 -62
  100. package/index68.js +64 -80
  101. package/index69.js +68 -62
  102. package/index7.js +1 -1
  103. package/index70.js +138 -22
  104. package/index71.js +66 -65
  105. package/index72.js +40 -78
  106. package/index73.js +75 -133
  107. package/index74.js +69 -68
  108. package/index75.js +96 -34
  109. package/index76.js +258 -65
  110. package/index77.js +715 -63
  111. package/index78.js +478 -93
  112. package/index79.js +303 -263
  113. package/index8.js +1 -1
  114. package/index80.js +343 -678
  115. package/index81.js +242 -481
  116. package/index82.js +1329 -282
  117. package/index83.js +968 -350
  118. package/index84.js +343 -211
  119. package/index85.js +2025 -1288
  120. package/index86.js +2313 -954
  121. package/index87.js +6782 -339
  122. package/index88.js +15 -2103
  123. package/index89.js +12 -2369
  124. package/index9.js +1 -1
  125. package/index90.js +4 -6832
  126. package/index91.js +7 -15
  127. package/link/Link.d.ts +2 -2
  128. package/link-button/LinkButton.d.ts +1 -1
  129. package/package.json +7 -1
  130. package/{react.esm-D8HpDGKP.js → react.esm-sMU8Z7rL.js} +1872 -1872
  131. package/textfield/index.d.ts +0 -2
  132. package/useControlledState-Kv9K2AYu.js +30 -0
  133. package/{useDescription-D4_zk_sA.js → useDescription-B7stiK3j.js} +1 -1
  134. package/useEvent-Xk5kn5Ns.js +21 -0
  135. package/useField-DMzJIIN4.js +67 -0
  136. package/{useFilter-BnJDBCkt.js → useFilter-Bt9dbV1U.js} +1 -1
  137. package/useFocusRing-9PXyKy2A.js +1297 -0
  138. package/{useFocusable-C-N9wcwm.js → useFocusable-CcEBZe40.js} +11 -8
  139. package/{useGridSelectionCheckbox-i1rsjlC-.js → useGridSelectionCheckbox-DYgEnElE.js} +3 -3
  140. package/useHasTabbableChild-D6DwR81L.js +34 -0
  141. package/{useHighlightSelectionDescription-JVx2MW_e.js → useHighlightSelectionDescription-WYAbP4No.js} +19 -19
  142. package/useLabels-9zaZ9oa0.js +17 -0
  143. package/useListState-BfTeKTk5.js +119 -0
  144. package/{useLocalizedStringFormatter-DVCAZqcL.js → useLocalizedStringFormatter-BlCbn-hX.js} +29 -29
  145. package/{useSingleSelectListState-CmX9_L5H.js → useSingleSelectListState-DPkaL0la.js} +5 -5
  146. package/Button-CCevm2s3.js +0 -183
  147. package/Checkbox-CllWDBxF.js +0 -405
  148. package/Dialog-CLTyYwkS.js +0 -1889
  149. package/DragAndDrop-OTN7La7U.js +0 -42
  150. package/FocusScope-BR0SJ-cZ.js +0 -512
  151. package/Group-DPMuN3h8.js +0 -44
  152. package/Label-C18A_4Z5.js +0 -69
  153. package/Link-BU1h3K2a.js +0 -77
  154. package/ListBox-D21tdwTs.js +0 -463
  155. package/ListKeyboardDelegate-DxMjfMsI.js +0 -172
  156. package/PressResponder-DP8ZDNGy.js +0 -31
  157. package/SelectionManager-D4WtKtey.js +0 -988
  158. package/Separator-DLUHK9vv.js +0 -48
  159. package/Tag-CEd6WWSc.js +0 -725
  160. package/Text-DGLaY3HR.js +0 -17
  161. package/TextField-C_hq9WeT.js +0 -226
  162. package/TextField.module-Cwq1FAm7.js +0 -141
  163. package/accordion/AccordionContent.d.ts +0 -3
  164. package/accordion/AccordionTagContext.d.ts +0 -3
  165. package/accordion/AccordionTrigger.d.ts +0 -3
  166. package/index-CEg5vZQH.js +0 -132
  167. package/index-CgfokhRq.js +0 -674
  168. package/index.css +0 -1
  169. package/index92.js +0 -14
  170. package/index93.js +0 -6
  171. package/index94.js +0 -9
  172. package/useControlledState-S_TYcV_c.js +0 -45
  173. package/useFocusRing-D97-G3fT.js +0 -1324
  174. package/useHasTabbableChild-DeuCnGGv.js +0 -34
  175. package/useListState-DSOTbsL3.js +0 -119
@@ -0,0 +1,474 @@
1
+ import { $ as ne, a as re, b as W, e as de, c as le } from "./Collection-KMFfVuzU.js";
2
+ import { o as C, f as ie, k as j, e as E, C as G, G as se, H as ce, I as ue, b as Q, J, q as fe, a as pe, i as R, F as be, c as $e, d as T, B as X, z as ge } from "./useFocusRing-9PXyKy2A.js";
3
+ import { $ as _, a as ve, b as he, c as Y } from "./DragAndDrop-B0T3WgjL.js";
4
+ import { $ as me, a as Pe, b as De, c as xe, d as ye } from "./Separator-BBX9m2O2.js";
5
+ import { $ as Se } from "./Text-BCF0xvqL.js";
6
+ import c, { forwardRef as Z, useContext as h, useMemo as K, useRef as N, useEffect as ee, createContext as oe } from "react";
7
+ import { $ as ke } from "./useListState-BfTeKTk5.js";
8
+ import { $ as Fe } from "./context-BpJLnOuu.js";
9
+ import { $ as He, a as we } from "./ListKeyboardDelegate-gCXy-Xnn.js";
10
+ import { c as Be } from "./useField-DMzJIIN4.js";
11
+ import { d as Ee } from "./SelectionManager-BfXUE1qg.js";
12
+ import { a as Ie } from "./FocusScope-B7CkxXNC.js";
13
+ const q = /* @__PURE__ */ new WeakMap();
14
+ function Me(o) {
15
+ return typeof o == "string" ? o.replace(/\s*/g, "") : "" + o;
16
+ }
17
+ function Ve(o, e) {
18
+ let n = q.get(o);
19
+ if (!n) throw new Error("Unknown list");
20
+ return `${n.id}-option-${Me(e)}`;
21
+ }
22
+ function Ae(o, e, n) {
23
+ let a = C(o, {
24
+ labelable: !0
25
+ }), d = o.selectionBehavior || "toggle", r = o.linkBehavior || (d === "replace" ? "action" : "override");
26
+ d === "toggle" && r === "action" && (r = "override");
27
+ let { listProps: t } = me({
28
+ ...o,
29
+ ref: n,
30
+ selectionManager: e.selectionManager,
31
+ collection: e.collection,
32
+ disabledKeys: e.disabledKeys,
33
+ linkBehavior: r
34
+ }), { focusWithinProps: l } = ie({
35
+ onFocusWithin: o.onFocus,
36
+ onBlurWithin: o.onBlur,
37
+ onFocusWithinChange: o.onFocusChange
38
+ }), i = j(o.id);
39
+ q.set(e, {
40
+ id: i,
41
+ shouldUseVirtualFocus: o.shouldUseVirtualFocus,
42
+ shouldSelectOnPressUp: o.shouldSelectOnPressUp,
43
+ shouldFocusOnHover: o.shouldFocusOnHover,
44
+ isVirtualized: o.isVirtualized,
45
+ onAction: o.onAction,
46
+ linkBehavior: r
47
+ });
48
+ let { labelProps: f, fieldProps: p } = Be({
49
+ ...o,
50
+ id: i,
51
+ // listbox is not an HTML input element so it
52
+ // shouldn't be labeled by a <label> element.
53
+ labelElementType: "span"
54
+ });
55
+ return {
56
+ labelProps: f,
57
+ listBoxProps: E(a, l, e.selectionManager.selectionMode === "multiple" ? {
58
+ "aria-multiselectable": "true"
59
+ } : {}, {
60
+ role: "listbox",
61
+ ...E(p, t)
62
+ })
63
+ };
64
+ }
65
+ function Ce(o, e, n) {
66
+ var a, d;
67
+ let { key: r } = o, t = q.get(e);
68
+ var l;
69
+ let i = (l = o.isDisabled) !== null && l !== void 0 ? l : e.selectionManager.isDisabled(r);
70
+ var f;
71
+ let p = (f = o.isSelected) !== null && f !== void 0 ? f : e.selectionManager.isSelected(r);
72
+ var g;
73
+ let u = (g = o.shouldSelectOnPressUp) !== null && g !== void 0 ? g : t == null ? void 0 : t.shouldSelectOnPressUp;
74
+ var v;
75
+ let S = (v = o.shouldFocusOnHover) !== null && v !== void 0 ? v : t == null ? void 0 : t.shouldFocusOnHover;
76
+ var $;
77
+ let b = ($ = o.shouldUseVirtualFocus) !== null && $ !== void 0 ? $ : t == null ? void 0 : t.shouldUseVirtualFocus;
78
+ var D;
79
+ let x = (D = o.isVirtualized) !== null && D !== void 0 ? D : t == null ? void 0 : t.isVirtualized, F = G(), I = G(), y = {
80
+ role: "option",
81
+ "aria-disabled": i || void 0,
82
+ "aria-selected": e.selectionManager.selectionMode !== "none" ? p : void 0
83
+ };
84
+ se() && ce() || (y["aria-label"] = o["aria-label"], y["aria-labelledby"] = F, y["aria-describedby"] = I);
85
+ let s = e.collection.getItem(r);
86
+ if (x) {
87
+ let P = Number(s == null ? void 0 : s.index);
88
+ y["aria-posinset"] = Number.isNaN(P) ? void 0 : P + 1, y["aria-setsize"] = Pe(e.collection);
89
+ }
90
+ let m = t != null && t.onAction ? () => {
91
+ var P;
92
+ return t == null || (P = t.onAction) === null || P === void 0 ? void 0 : P.call(t, r);
93
+ } : void 0, k = Ve(e, r), { itemProps: H, isPressed: M, isFocused: w, hasAction: U, allowsSelection: V } = Ee({
94
+ selectionManager: e.selectionManager,
95
+ key: r,
96
+ ref: n,
97
+ shouldSelectOnPressUp: u,
98
+ allowsDifferentPressOrigin: u && S,
99
+ isVirtualized: x,
100
+ shouldUseVirtualFocus: b,
101
+ isDisabled: i,
102
+ onAction: m || !(s == null || (a = s.props) === null || a === void 0) && a.onAction ? ue(s == null || (d = s.props) === null || d === void 0 ? void 0 : d.onAction, m) : void 0,
103
+ linkBehavior: t == null ? void 0 : t.linkBehavior,
104
+ id: k
105
+ }), { hoverProps: A } = Q({
106
+ isDisabled: i || !S,
107
+ onHoverStart() {
108
+ J() || (e.selectionManager.setFocused(!0), e.selectionManager.setFocusedKey(r));
109
+ }
110
+ }), B = C(s == null ? void 0 : s.props);
111
+ delete B.id;
112
+ let z = fe(s == null ? void 0 : s.props);
113
+ return {
114
+ optionProps: {
115
+ ...y,
116
+ ...E(B, H, A, z),
117
+ id: k
118
+ },
119
+ labelProps: {
120
+ id: F
121
+ },
122
+ descriptionProps: {
123
+ id: I
124
+ },
125
+ isFocused: w,
126
+ isFocusVisible: w && J(),
127
+ isSelected: p,
128
+ isDisabled: i,
129
+ isPressed: M,
130
+ allowsSelection: V,
131
+ hasAction: U
132
+ };
133
+ }
134
+ function Te(o) {
135
+ let { heading: e, "aria-label": n } = o, a = j();
136
+ return {
137
+ itemProps: {
138
+ role: "presentation"
139
+ },
140
+ headingProps: e ? {
141
+ // Techincally, listbox cannot contain headings according to ARIA.
142
+ // We hide the heading from assistive technology, using role="presentation",
143
+ // and only use it as a visual label for the nested group.
144
+ id: a,
145
+ role: "presentation"
146
+ } : {},
147
+ groupProps: {
148
+ role: "group",
149
+ "aria-label": n,
150
+ "aria-labelledby": e ? a : void 0
151
+ }
152
+ };
153
+ }
154
+ const ae = /* @__PURE__ */ oe(null), L = /* @__PURE__ */ oe(null), eo = /* @__PURE__ */ Z(function(e, n) {
155
+ [e, n] = pe(e, n, ae);
156
+ let a = h(L);
157
+ return a ? /* @__PURE__ */ c.createElement(te, {
158
+ state: a,
159
+ props: e,
160
+ listBoxRef: n
161
+ }) : /* @__PURE__ */ c.createElement(ne, {
162
+ content: /* @__PURE__ */ c.createElement(re, e)
163
+ }, (d) => /* @__PURE__ */ c.createElement(_e, {
164
+ props: e,
165
+ listBoxRef: n,
166
+ collection: d
167
+ }));
168
+ });
169
+ function _e({ props: o, listBoxRef: e, collection: n }) {
170
+ o = {
171
+ ...o,
172
+ collection: n,
173
+ children: null,
174
+ items: null
175
+ };
176
+ let { layoutDelegate: a } = h(W), { filterFn: d, collectionProps: r, collectionRef: t } = h(De) || {};
177
+ e = R(K(() => be(e, t !== void 0 ? t : null), [
178
+ t,
179
+ e
180
+ ]));
181
+ let l = K(() => d ? n.filter(d) : n, [
182
+ n,
183
+ d
184
+ ]), i = ke({
185
+ ...o,
186
+ collection: l,
187
+ layoutDelegate: a
188
+ });
189
+ return /* @__PURE__ */ c.createElement(te, {
190
+ state: i,
191
+ props: {
192
+ ...o,
193
+ ...r
194
+ },
195
+ listBoxRef: e
196
+ });
197
+ }
198
+ function te({ state: o, props: e, listBoxRef: n }) {
199
+ let { dragAndDropHooks: a, layout: d = "stack", orientation: r = "vertical" } = e, { collection: t, selectionManager: l } = o, i = !!(a != null && a.useDraggableCollectionState), f = !!(a != null && a.useDroppableCollectionState), { direction: p } = Fe(), { disabledBehavior: g, disabledKeys: u } = l, v = He({
200
+ usage: "search",
201
+ sensitivity: "base"
202
+ }), { isVirtualized: S, layoutDelegate: $, dropTargetDelegate: b, CollectionRoot: D } = h(W), x = K(() => e.keyboardDelegate || new we({
203
+ collection: t,
204
+ collator: v,
205
+ ref: n,
206
+ disabledKeys: u,
207
+ disabledBehavior: g,
208
+ layout: d,
209
+ orientation: r,
210
+ direction: p,
211
+ layoutDelegate: $
212
+ }), [
213
+ t,
214
+ v,
215
+ n,
216
+ g,
217
+ u,
218
+ r,
219
+ p,
220
+ e.keyboardDelegate,
221
+ d,
222
+ $
223
+ ]), { listBoxProps: F } = Ae({
224
+ ...e,
225
+ shouldSelectOnPressUp: i || e.shouldSelectOnPressUp,
226
+ keyboardDelegate: x,
227
+ isVirtualized: S
228
+ }, o, n), I = N(i), y = N(f);
229
+ ee(() => {
230
+ I.current !== i && console.warn("Drag hooks were provided during one render, but not another. This should be avoided as it may produce unexpected behavior."), y.current !== f && console.warn("Drop hooks were provided during one render, but not another. This should be avoided as it may produce unexpected behavior.");
231
+ }, [
232
+ i,
233
+ f
234
+ ]);
235
+ let s, m, k, H = !1, M = null, w = N(null);
236
+ if (i && a) {
237
+ s = a.useDraggableCollectionState({
238
+ collection: t,
239
+ selectionManager: l,
240
+ preview: a.renderDragPreview ? w : void 0
241
+ }), a.useDraggableCollection({}, s, n);
242
+ let O = a.DragPreview;
243
+ M = a.renderDragPreview ? /* @__PURE__ */ c.createElement(O, {
244
+ ref: w
245
+ }, a.renderDragPreview) : null;
246
+ }
247
+ if (f && a) {
248
+ m = a.useDroppableCollectionState({
249
+ collection: t,
250
+ selectionManager: l
251
+ });
252
+ let O = a.dropTargetDelegate || b || new a.ListDropTargetDelegate(t, n, {
253
+ orientation: r,
254
+ layout: d,
255
+ direction: p
256
+ });
257
+ k = a.useDroppableCollection({
258
+ keyboardDelegate: x,
259
+ dropTargetDelegate: O
260
+ }, m, n), H = m.isDropTarget({
261
+ type: "root"
262
+ });
263
+ }
264
+ let { focusProps: U, isFocused: V, isFocusVisible: A } = $e(), B = {
265
+ isDropTarget: H,
266
+ isEmpty: o.collection.size === 0,
267
+ isFocused: V,
268
+ isFocusVisible: A,
269
+ layout: e.layout || "stack",
270
+ state: o
271
+ }, z = T({
272
+ className: e.className,
273
+ style: e.style,
274
+ defaultClassName: "react-aria-ListBox",
275
+ values: B
276
+ }), P = null;
277
+ return o.collection.size === 0 && e.renderEmptyState && (P = /* @__PURE__ */ c.createElement("div", {
278
+ // eslint-disable-next-line
279
+ role: "option",
280
+ style: {
281
+ display: "contents"
282
+ }
283
+ }, e.renderEmptyState(B))), /* @__PURE__ */ c.createElement(Ie, null, /* @__PURE__ */ c.createElement("div", {
284
+ ...C(e),
285
+ ...E(F, U, k == null ? void 0 : k.collectionProps),
286
+ ...z,
287
+ ref: n,
288
+ slot: e.slot || void 0,
289
+ onScroll: e.onScroll,
290
+ "data-drop-target": H || void 0,
291
+ "data-empty": o.collection.size === 0 || void 0,
292
+ "data-focused": V || void 0,
293
+ "data-focus-visible": A || void 0,
294
+ "data-layout": e.layout || "stack",
295
+ "data-orientation": e.orientation || "vertical"
296
+ }, /* @__PURE__ */ c.createElement(X, {
297
+ values: [
298
+ [
299
+ ae,
300
+ e
301
+ ],
302
+ [
303
+ L,
304
+ o
305
+ ],
306
+ [
307
+ _,
308
+ {
309
+ dragAndDropHooks: a,
310
+ dragState: s,
311
+ dropState: m
312
+ }
313
+ ],
314
+ [
315
+ xe,
316
+ {
317
+ elementType: "div"
318
+ }
319
+ ],
320
+ [
321
+ ve,
322
+ {
323
+ render: Ue
324
+ }
325
+ ],
326
+ [
327
+ de,
328
+ {
329
+ name: "ListBoxSection",
330
+ render: Le
331
+ }
332
+ ]
333
+ ]
334
+ }, /* @__PURE__ */ c.createElement(D, {
335
+ collection: t,
336
+ scrollRef: n,
337
+ persistedKeys: he(l, a, m),
338
+ renderDropIndicator: Y(a, m)
339
+ })), P, M));
340
+ }
341
+ function Le(o, e, n, a = "react-aria-ListBoxSection") {
342
+ let d = h(L), { dragAndDropHooks: r, dropState: t } = h(_), { CollectionBranch: l } = h(W), [i, f] = ge();
343
+ var p;
344
+ let { headingProps: g, groupProps: u } = Te({
345
+ heading: f,
346
+ "aria-label": (p = o["aria-label"]) !== null && p !== void 0 ? p : void 0
347
+ }), v = T({
348
+ defaultClassName: a,
349
+ className: o.className,
350
+ style: o.style,
351
+ values: {}
352
+ });
353
+ return /* @__PURE__ */ c.createElement("section", {
354
+ ...C(o),
355
+ ...u,
356
+ ...v,
357
+ ref: e
358
+ }, /* @__PURE__ */ c.createElement(ye.Provider, {
359
+ value: {
360
+ ...g,
361
+ ref: i
362
+ }
363
+ }, /* @__PURE__ */ c.createElement(l, {
364
+ collection: d.collection,
365
+ parent: n,
366
+ renderDropIndicator: Y(r, t)
367
+ })));
368
+ }
369
+ const oo = /* @__PURE__ */ le("item", function(e, n, a) {
370
+ let d = R(n), r = h(L), { dragAndDropHooks: t, dragState: l, dropState: i } = h(_), { optionProps: f, labelProps: p, descriptionProps: g, ...u } = Ce({
371
+ key: a.key,
372
+ "aria-label": e == null ? void 0 : e["aria-label"]
373
+ }, r, d), { hoverProps: v, isHovered: S } = Q({
374
+ isDisabled: !u.allowsSelection && !u.hasAction,
375
+ onHoverStart: a.props.onHoverStart,
376
+ onHoverChange: a.props.onHoverChange,
377
+ onHoverEnd: a.props.onHoverEnd
378
+ }), $ = null;
379
+ l && t && ($ = t.useDraggableItem({
380
+ key: a.key
381
+ }, l));
382
+ let b = null;
383
+ i && t && (b = t.useDroppableItem({
384
+ target: {
385
+ type: "item",
386
+ key: a.key,
387
+ dropPosition: "on"
388
+ }
389
+ }, i, d));
390
+ let D = l && l.isDragging(a.key), x = T({
391
+ ...e,
392
+ id: void 0,
393
+ children: e.children,
394
+ defaultClassName: "react-aria-ListBoxItem",
395
+ values: {
396
+ ...u,
397
+ isHovered: S,
398
+ selectionMode: r.selectionManager.selectionMode,
399
+ selectionBehavior: r.selectionManager.selectionBehavior,
400
+ allowsDragging: !!l,
401
+ isDragging: D,
402
+ isDropTarget: b == null ? void 0 : b.isDropTarget
403
+ }
404
+ });
405
+ ee(() => {
406
+ a.textValue || console.warn("A `textValue` prop is required for <ListBoxItem> elements with non-plain text children in order to support accessibility features such as type to select.");
407
+ }, [
408
+ a.textValue
409
+ ]);
410
+ let F = e.href ? "a" : "div";
411
+ return /* @__PURE__ */ c.createElement(F, {
412
+ ...E(f, v, $ == null ? void 0 : $.dragProps, b == null ? void 0 : b.dropProps),
413
+ ...x,
414
+ ref: d,
415
+ "data-allows-dragging": !!l || void 0,
416
+ "data-selected": u.isSelected || void 0,
417
+ "data-disabled": u.isDisabled || void 0,
418
+ "data-hovered": S || void 0,
419
+ "data-focused": u.isFocused || void 0,
420
+ "data-focus-visible": u.isFocusVisible || void 0,
421
+ "data-pressed": u.isPressed || void 0,
422
+ "data-dragging": D || void 0,
423
+ "data-drop-target": (b == null ? void 0 : b.isDropTarget) || void 0,
424
+ "data-selection-mode": r.selectionManager.selectionMode === "none" ? void 0 : r.selectionManager.selectionMode
425
+ }, /* @__PURE__ */ c.createElement(X, {
426
+ values: [
427
+ [
428
+ Se,
429
+ {
430
+ slots: {
431
+ label: p,
432
+ description: g
433
+ }
434
+ }
435
+ ]
436
+ ]
437
+ }, x.children));
438
+ });
439
+ function Ue(o, e) {
440
+ e = R(e);
441
+ let { dragAndDropHooks: n, dropState: a } = h(_), { dropIndicatorProps: d, isHidden: r, isDropTarget: t } = n.useDropIndicator(o, a, e);
442
+ return r ? null : /* @__PURE__ */ c.createElement(Oe, {
443
+ ...o,
444
+ dropIndicatorProps: d,
445
+ isDropTarget: t,
446
+ ref: e
447
+ });
448
+ }
449
+ function ze(o, e) {
450
+ let { dropIndicatorProps: n, isDropTarget: a, ...d } = o, r = T({
451
+ ...d,
452
+ defaultClassName: "react-aria-DropIndicator",
453
+ values: {
454
+ isDropTarget: a
455
+ }
456
+ });
457
+ return /* @__PURE__ */ c.createElement("div", {
458
+ ...n,
459
+ ...r,
460
+ // eslint-disable-next-line
461
+ role: "option",
462
+ ref: e,
463
+ "data-drop-target": a || void 0
464
+ });
465
+ }
466
+ const Oe = /* @__PURE__ */ Z(ze);
467
+ export {
468
+ L as $,
469
+ ae as a,
470
+ eo as b,
471
+ oo as c,
472
+ q as d,
473
+ Ve as e
474
+ };
@@ -0,0 +1,172 @@
1
+ import { c as o } from "./SelectionManager-BfXUE1qg.js";
2
+ import { $ as u } from "./context-BpJLnOuu.js";
3
+ function f(r, e) {
4
+ let t = r;
5
+ for (o(t, e) && (t = t.parentElement); t && !o(t, e); ) t = t.parentElement;
6
+ return t || document.scrollingElement || document.documentElement;
7
+ }
8
+ let a = /* @__PURE__ */ new Map();
9
+ function g(r) {
10
+ let { locale: e } = u(), t = e + (r ? Object.entries(r).sort((l, n) => l[0] < n[0] ? -1 : 1).join() : "");
11
+ if (a.has(t)) return a.get(t);
12
+ let i = new Intl.Collator(e, r);
13
+ return a.set(t, i), i;
14
+ }
15
+ class h {
16
+ getItemRect(e) {
17
+ let t = this.ref.current;
18
+ if (!t) return null;
19
+ let i = e != null ? t.querySelector(`[data-key="${CSS.escape(e.toString())}"]`) : null;
20
+ if (!i) return null;
21
+ let l = t.getBoundingClientRect(), n = i.getBoundingClientRect();
22
+ return {
23
+ x: n.left - l.left + t.scrollLeft,
24
+ y: n.top - l.top + t.scrollTop,
25
+ width: n.width,
26
+ height: n.height
27
+ };
28
+ }
29
+ getContentSize() {
30
+ let e = this.ref.current;
31
+ var t, i;
32
+ return {
33
+ width: (t = e == null ? void 0 : e.scrollWidth) !== null && t !== void 0 ? t : 0,
34
+ height: (i = e == null ? void 0 : e.scrollHeight) !== null && i !== void 0 ? i : 0
35
+ };
36
+ }
37
+ getVisibleRect() {
38
+ let e = this.ref.current;
39
+ var t, i, l, n;
40
+ return {
41
+ x: (t = e == null ? void 0 : e.scrollLeft) !== null && t !== void 0 ? t : 0,
42
+ y: (i = e == null ? void 0 : e.scrollTop) !== null && i !== void 0 ? i : 0,
43
+ width: (l = e == null ? void 0 : e.offsetWidth) !== null && l !== void 0 ? l : 0,
44
+ height: (n = e == null ? void 0 : e.offsetHeight) !== null && n !== void 0 ? n : 0
45
+ };
46
+ }
47
+ constructor(e) {
48
+ this.ref = e;
49
+ }
50
+ }
51
+ class y {
52
+ isDisabled(e) {
53
+ var t;
54
+ return this.disabledBehavior === "all" && (((t = e.props) === null || t === void 0 ? void 0 : t.isDisabled) || this.disabledKeys.has(e.key));
55
+ }
56
+ findNextNonDisabled(e, t) {
57
+ let i = e;
58
+ for (; i != null; ) {
59
+ let l = this.collection.getItem(i);
60
+ if ((l == null ? void 0 : l.type) === "item" && !this.isDisabled(l)) return i;
61
+ i = t(i);
62
+ }
63
+ return null;
64
+ }
65
+ getNextKey(e) {
66
+ let t = e;
67
+ return t = this.collection.getKeyAfter(t), this.findNextNonDisabled(t, (i) => this.collection.getKeyAfter(i));
68
+ }
69
+ getPreviousKey(e) {
70
+ let t = e;
71
+ return t = this.collection.getKeyBefore(t), this.findNextNonDisabled(t, (i) => this.collection.getKeyBefore(i));
72
+ }
73
+ findKey(e, t, i) {
74
+ let l = e, n = this.layoutDelegate.getItemRect(l);
75
+ if (!n || l == null) return null;
76
+ let s = n;
77
+ do {
78
+ if (l = t(l), l == null) break;
79
+ n = this.layoutDelegate.getItemRect(l);
80
+ } while (n && i(s, n) && l != null);
81
+ return l;
82
+ }
83
+ isSameRow(e, t) {
84
+ return e.y === t.y || e.x !== t.x;
85
+ }
86
+ isSameColumn(e, t) {
87
+ return e.x === t.x || e.y !== t.y;
88
+ }
89
+ getKeyBelow(e) {
90
+ return this.layout === "grid" && this.orientation === "vertical" ? this.findKey(e, (t) => this.getNextKey(t), this.isSameRow) : this.getNextKey(e);
91
+ }
92
+ getKeyAbove(e) {
93
+ return this.layout === "grid" && this.orientation === "vertical" ? this.findKey(e, (t) => this.getPreviousKey(t), this.isSameRow) : this.getPreviousKey(e);
94
+ }
95
+ getNextColumn(e, t) {
96
+ return t ? this.getPreviousKey(e) : this.getNextKey(e);
97
+ }
98
+ getKeyRightOf(e) {
99
+ let t = this.direction === "ltr" ? "getKeyRightOf" : "getKeyLeftOf";
100
+ return this.layoutDelegate[t] ? (e = this.layoutDelegate[t](e), this.findNextNonDisabled(e, (i) => this.layoutDelegate[t](i))) : this.layout === "grid" ? this.orientation === "vertical" ? this.getNextColumn(e, this.direction === "rtl") : this.findKey(e, (i) => this.getNextColumn(i, this.direction === "rtl"), this.isSameColumn) : this.orientation === "horizontal" ? this.getNextColumn(e, this.direction === "rtl") : null;
101
+ }
102
+ getKeyLeftOf(e) {
103
+ let t = this.direction === "ltr" ? "getKeyLeftOf" : "getKeyRightOf";
104
+ return this.layoutDelegate[t] ? (e = this.layoutDelegate[t](e), this.findNextNonDisabled(e, (i) => this.layoutDelegate[t](i))) : this.layout === "grid" ? this.orientation === "vertical" ? this.getNextColumn(e, this.direction === "ltr") : this.findKey(e, (i) => this.getNextColumn(i, this.direction === "ltr"), this.isSameColumn) : this.orientation === "horizontal" ? this.getNextColumn(e, this.direction === "ltr") : null;
105
+ }
106
+ getFirstKey() {
107
+ let e = this.collection.getFirstKey();
108
+ return this.findNextNonDisabled(e, (t) => this.collection.getKeyAfter(t));
109
+ }
110
+ getLastKey() {
111
+ let e = this.collection.getLastKey();
112
+ return this.findNextNonDisabled(e, (t) => this.collection.getKeyBefore(t));
113
+ }
114
+ getKeyPageAbove(e) {
115
+ let t = this.ref.current, i = this.layoutDelegate.getItemRect(e);
116
+ if (!i) return null;
117
+ if (t && !o(t)) return this.getFirstKey();
118
+ let l = e;
119
+ if (this.orientation === "horizontal") {
120
+ let n = Math.max(0, i.x + i.width - this.layoutDelegate.getVisibleRect().width);
121
+ for (; i && i.x > n && l != null; )
122
+ l = this.getKeyAbove(l), i = l == null ? null : this.layoutDelegate.getItemRect(l);
123
+ } else {
124
+ let n = Math.max(0, i.y + i.height - this.layoutDelegate.getVisibleRect().height);
125
+ for (; i && i.y > n && l != null; )
126
+ l = this.getKeyAbove(l), i = l == null ? null : this.layoutDelegate.getItemRect(l);
127
+ }
128
+ return l ?? this.getFirstKey();
129
+ }
130
+ getKeyPageBelow(e) {
131
+ let t = this.ref.current, i = this.layoutDelegate.getItemRect(e);
132
+ if (!i) return null;
133
+ if (t && !o(t)) return this.getLastKey();
134
+ let l = e;
135
+ if (this.orientation === "horizontal") {
136
+ let n = Math.min(this.layoutDelegate.getContentSize().width, i.y - i.width + this.layoutDelegate.getVisibleRect().width);
137
+ for (; i && i.x < n && l != null; )
138
+ l = this.getKeyBelow(l), i = l == null ? null : this.layoutDelegate.getItemRect(l);
139
+ } else {
140
+ let n = Math.min(this.layoutDelegate.getContentSize().height, i.y - i.height + this.layoutDelegate.getVisibleRect().height);
141
+ for (; i && i.y < n && l != null; )
142
+ l = this.getKeyBelow(l), i = l == null ? null : this.layoutDelegate.getItemRect(l);
143
+ }
144
+ return l ?? this.getLastKey();
145
+ }
146
+ getKeyForSearch(e, t) {
147
+ if (!this.collator) return null;
148
+ let i = this.collection, l = t || this.getFirstKey();
149
+ for (; l != null; ) {
150
+ let n = i.getItem(l);
151
+ if (!n) return null;
152
+ let s = n.textValue.slice(0, e.length);
153
+ if (n.textValue && this.collator.compare(s, e) === 0) return l;
154
+ l = this.getNextKey(l);
155
+ }
156
+ return null;
157
+ }
158
+ constructor(...e) {
159
+ if (e.length === 1) {
160
+ let t = e[0];
161
+ this.collection = t.collection, this.ref = t.ref, this.collator = t.collator, this.disabledKeys = t.disabledKeys || /* @__PURE__ */ new Set(), this.disabledBehavior = t.disabledBehavior || "all", this.orientation = t.orientation || "vertical", this.direction = t.direction, this.layout = t.layout || "stack", this.layoutDelegate = t.layoutDelegate || new h(t.ref);
162
+ } else
163
+ this.collection = e[0], this.disabledKeys = e[1], this.ref = e[2], this.collator = e[3], this.layout = "stack", this.orientation = "vertical", this.disabledBehavior = "all", this.layoutDelegate = new h(this.ref);
164
+ this.layout === "stack" && this.orientation === "vertical" && (this.getKeyLeftOf = void 0, this.getKeyRightOf = void 0);
165
+ }
166
+ }
167
+ export {
168
+ g as $,
169
+ y as a,
170
+ f as b,
171
+ h as c
172
+ };
@@ -0,0 +1,31 @@
1
+ import { h as s, i as c, e as d, j as b } from "./useFocusRing-9PXyKy2A.js";
2
+ import f, { useRef as i, useContext as u, useEffect as $, useMemo as l } from "react";
3
+ const h = /* @__PURE__ */ f.forwardRef(({ children: t, ...a }, r) => {
4
+ let o = i(!1), e = u(s);
5
+ r = c(r || (e == null ? void 0 : e.ref));
6
+ let n = d(e || {}, {
7
+ ...a,
8
+ ref: r,
9
+ register() {
10
+ o.current = !0, e && e.register();
11
+ }
12
+ });
13
+ return b(e, r), $(() => {
14
+ o.current || (console.warn("A PressResponder was rendered without a pressable child. Either call the usePress hook, or wrap your DOM node with <Pressable> component."), o.current = !0);
15
+ }, []), /* @__PURE__ */ f.createElement(s.Provider, {
16
+ value: n
17
+ }, t);
18
+ });
19
+ function m({ children: t }) {
20
+ let a = l(() => ({
21
+ register: () => {
22
+ }
23
+ }), []);
24
+ return /* @__PURE__ */ f.createElement(s.Provider, {
25
+ value: a
26
+ }, t);
27
+ }
28
+ export {
29
+ h as $,
30
+ m as a
31
+ };
package/README.md CHANGED
@@ -1,7 +1,25 @@
1
- # Component Library Midas Design System
1
+ # Midas Design System
2
2
 
3
- Contains all components from @midas-ds.
3
+ React component library implementing Midas Design System (Migrationsverket)
4
+
5
+ -----
6
+
7
+ ## Getting started
8
+
9
+ Add `@midas-ds/components` to your project:
10
+
11
+ ```
12
+ npm install @midas-ds/components
13
+ ```
14
+ And then import the components you need:
4
15
 
5
16
  ```
6
- import {Button, Checkbox} '@midas-ds/components'
17
+ import {Button, Checkbox, etc} from '@midas-ds/components'
7
18
  ```
19
+
20
+ ## Documentation
21
+
22
+ * See the full design system documentation on [Midas](https://designsystem.migrationsverket.se/) (Swedish).
23
+
24
+ * Component API documentation on [Storybook](https://designsystem.migrationsverket.se/storybook/).
25
+