@phillips/seldon 1.31.2 → 1.33.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.
- package/dist/assets/lock.svg.js +4 -0
- package/dist/assets/minus.svg.js +4 -0
- package/dist/assets/plus.svg.js +4 -0
- package/dist/components/Accordion/Accordion.d.ts +26 -0
- package/dist/components/Accordion/Accordion.js +21 -0
- package/dist/components/Accordion/AccordionItem.d.ts +37 -0
- package/dist/components/Accordion/AccordionItem.js +114 -0
- package/dist/components/Accordion/index.d.ts +2 -0
- package/dist/components/Accordion/types.d.ts +44 -0
- package/dist/components/Button/Button.d.ts +1 -1
- package/dist/components/Button/Button.js +39 -34
- package/dist/components/Drawer/Drawer.d.ts +23 -0
- package/dist/components/Drawer/Drawer.js +46 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +44 -38
- package/dist/node_modules/@radix-ui/primitive/dist/index.js +9 -0
- package/dist/node_modules/@radix-ui/react-accordion/dist/index.js +237 -0
- package/dist/node_modules/@radix-ui/react-collapsible/dist/index.js +119 -0
- package/dist/node_modules/@radix-ui/react-collection/dist/index.js +48 -0
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +14 -0
- package/dist/node_modules/@radix-ui/react-context/dist/index.js +67 -0
- package/dist/node_modules/@radix-ui/react-dialog/dist/index.js +260 -0
- package/dist/node_modules/@radix-ui/react-direction/dist/index.js +10 -0
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +128 -0
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +18 -0
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +137 -0
- package/dist/node_modules/@radix-ui/react-id/dist/index.js +13 -0
- package/dist/node_modules/@radix-ui/react-portal/dist/index.js +16 -0
- package/dist/node_modules/@radix-ui/react-presence/dist/index.js +69 -0
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +35 -0
- package/dist/node_modules/@radix-ui/react-slot/dist/index.js +48 -0
- package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +13 -0
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +32 -0
- package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +14 -0
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +6 -0
- package/dist/node_modules/aria-hidden/dist/es2015/index.js +52 -0
- package/dist/node_modules/get-nonce/dist/es2015/index.js +7 -0
- package/dist/node_modules/react-modal/lib/components/Modal.js +6 -6
- package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js +11 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +112 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +31 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +16 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +62 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js +5 -0
- package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js +7 -0
- package/dist/node_modules/react-remove-scroll/node_modules/tslib/tslib.es6.js +27 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +71 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +7 -0
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +25 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/component.js +11 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/hook.js +15 -0
- package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js +30 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js +6 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +26 -0
- package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js +25 -0
- package/dist/node_modules/use-sidecar/dist/es2015/exports.js +18 -0
- package/dist/node_modules/use-sidecar/dist/es2015/medium.js +67 -0
- package/dist/node_modules/use-sidecar/node_modules/tslib/tslib.es6.js +21 -0
- package/dist/scss/_vars.scss +2 -0
- package/dist/scss/components/Accordion/_accordion.scss +104 -0
- package/dist/scss/components/Drawer/_drawer.scss +66 -0
- package/dist/scss/components/Subscribe/_subscribe.scss +1 -0
- package/dist/scss/styles.scss +2 -0
- package/package.json +8 -6
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import s from "react";
|
|
2
|
+
import { createContextScope as W } from "../../react-context/dist/index.js";
|
|
3
|
+
import { createCollection as X } from "../../react-collection/dist/index.js";
|
|
4
|
+
import { useComposedRefs as Z } from "../../react-compose-refs/dist/index.js";
|
|
5
|
+
import { composeEventHandlers as $ } from "../../primitive/dist/index.js";
|
|
6
|
+
import { useControllableState as M } from "../../react-use-controllable-state/dist/index.js";
|
|
7
|
+
import { Primitive as V } from "../../react-primitive/dist/index.js";
|
|
8
|
+
import { createCollapsibleScope as H, Root as oo, Trigger as eo, Content as ro } from "../../react-collapsible/dist/index.js";
|
|
9
|
+
import { useId as to } from "../../react-id/dist/index.js";
|
|
10
|
+
import { useDirection as no } from "../../react-direction/dist/index.js";
|
|
11
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
12
|
+
var f = "Accordion", co = ["Home", "End", "ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"], [y, io, ao] = X(f), [b, No] = W(f, [
|
|
13
|
+
ao,
|
|
14
|
+
H
|
|
15
|
+
]), E = H(), K = s.forwardRef(
|
|
16
|
+
(e, c) => {
|
|
17
|
+
const { type: o, ...t } = e, i = t, r = t;
|
|
18
|
+
return /* @__PURE__ */ n(y.Provider, { scope: e.__scopeAccordion, children: o === "multiple" ? /* @__PURE__ */ n(fo, { ...r, ref: c }) : /* @__PURE__ */ n(po, { ...i, ref: c }) });
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
K.displayName = f;
|
|
22
|
+
var [L, lo] = b(f), [z, so] = b(
|
|
23
|
+
f,
|
|
24
|
+
{ collapsible: !1 }
|
|
25
|
+
), po = s.forwardRef(
|
|
26
|
+
(e, c) => {
|
|
27
|
+
const {
|
|
28
|
+
value: o,
|
|
29
|
+
defaultValue: t,
|
|
30
|
+
onValueChange: i = () => {
|
|
31
|
+
},
|
|
32
|
+
collapsible: r = !1,
|
|
33
|
+
...a
|
|
34
|
+
} = e, [l, d] = M({
|
|
35
|
+
prop: o,
|
|
36
|
+
defaultProp: t,
|
|
37
|
+
onChange: i
|
|
38
|
+
});
|
|
39
|
+
return /* @__PURE__ */ n(
|
|
40
|
+
L,
|
|
41
|
+
{
|
|
42
|
+
scope: e.__scopeAccordion,
|
|
43
|
+
value: l ? [l] : [],
|
|
44
|
+
onItemOpen: d,
|
|
45
|
+
onItemClose: s.useCallback(() => r && d(""), [r, d]),
|
|
46
|
+
children: /* @__PURE__ */ n(z, { scope: e.__scopeAccordion, collapsible: r, children: /* @__PURE__ */ n(G, { ...a, ref: c }) })
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
), fo = s.forwardRef((e, c) => {
|
|
51
|
+
const {
|
|
52
|
+
value: o,
|
|
53
|
+
defaultValue: t,
|
|
54
|
+
onValueChange: i = () => {
|
|
55
|
+
},
|
|
56
|
+
...r
|
|
57
|
+
} = e, [a = [], l] = M({
|
|
58
|
+
prop: o,
|
|
59
|
+
defaultProp: t,
|
|
60
|
+
onChange: i
|
|
61
|
+
}), d = s.useCallback(
|
|
62
|
+
(v) => l((u = []) => [...u, v]),
|
|
63
|
+
[l]
|
|
64
|
+
), m = s.useCallback(
|
|
65
|
+
(v) => l((u = []) => u.filter((h) => h !== v)),
|
|
66
|
+
[l]
|
|
67
|
+
);
|
|
68
|
+
return /* @__PURE__ */ n(
|
|
69
|
+
L,
|
|
70
|
+
{
|
|
71
|
+
scope: e.__scopeAccordion,
|
|
72
|
+
value: a,
|
|
73
|
+
onItemOpen: d,
|
|
74
|
+
onItemClose: m,
|
|
75
|
+
children: /* @__PURE__ */ n(z, { scope: e.__scopeAccordion, collapsible: !0, children: /* @__PURE__ */ n(G, { ...r, ref: c }) })
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}), [uo, I] = b(f), G = s.forwardRef(
|
|
79
|
+
(e, c) => {
|
|
80
|
+
const { __scopeAccordion: o, disabled: t, dir: i, orientation: r = "vertical", ...a } = e, l = s.useRef(null), d = Z(l, c), m = io(o), u = no(i) === "ltr", h = $(e.onKeyDown, (A) => {
|
|
81
|
+
var O;
|
|
82
|
+
if (!co.includes(A.key)) return;
|
|
83
|
+
const J = A.target, x = m().filter((N) => {
|
|
84
|
+
var T;
|
|
85
|
+
return !((T = N.ref.current) != null && T.disabled);
|
|
86
|
+
}), C = x.findIndex((N) => N.ref.current === J), D = x.length;
|
|
87
|
+
if (C === -1) return;
|
|
88
|
+
A.preventDefault();
|
|
89
|
+
let p = C;
|
|
90
|
+
const _ = 0, w = D - 1, R = () => {
|
|
91
|
+
p = C + 1, p > w && (p = _);
|
|
92
|
+
}, P = () => {
|
|
93
|
+
p = C - 1, p < _ && (p = w);
|
|
94
|
+
};
|
|
95
|
+
switch (A.key) {
|
|
96
|
+
case "Home":
|
|
97
|
+
p = _;
|
|
98
|
+
break;
|
|
99
|
+
case "End":
|
|
100
|
+
p = w;
|
|
101
|
+
break;
|
|
102
|
+
case "ArrowRight":
|
|
103
|
+
r === "horizontal" && (u ? R() : P());
|
|
104
|
+
break;
|
|
105
|
+
case "ArrowDown":
|
|
106
|
+
r === "vertical" && R();
|
|
107
|
+
break;
|
|
108
|
+
case "ArrowLeft":
|
|
109
|
+
r === "horizontal" && (u ? P() : R());
|
|
110
|
+
break;
|
|
111
|
+
case "ArrowUp":
|
|
112
|
+
r === "vertical" && P();
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
const Q = p % D;
|
|
116
|
+
(O = x[Q].ref.current) == null || O.focus();
|
|
117
|
+
});
|
|
118
|
+
return /* @__PURE__ */ n(
|
|
119
|
+
uo,
|
|
120
|
+
{
|
|
121
|
+
scope: o,
|
|
122
|
+
disabled: t,
|
|
123
|
+
direction: i,
|
|
124
|
+
orientation: r,
|
|
125
|
+
children: /* @__PURE__ */ n(y.Slot, { scope: o, children: /* @__PURE__ */ n(
|
|
126
|
+
V.div,
|
|
127
|
+
{
|
|
128
|
+
...a,
|
|
129
|
+
"data-orientation": r,
|
|
130
|
+
ref: d,
|
|
131
|
+
onKeyDown: t ? void 0 : h
|
|
132
|
+
}
|
|
133
|
+
) })
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
), g = "AccordionItem", [mo, k] = b(g), U = s.forwardRef(
|
|
138
|
+
(e, c) => {
|
|
139
|
+
const { __scopeAccordion: o, value: t, ...i } = e, r = I(g, o), a = lo(g, o), l = E(o), d = to(), m = t && a.value.includes(t) || !1, v = r.disabled || e.disabled;
|
|
140
|
+
return /* @__PURE__ */ n(
|
|
141
|
+
mo,
|
|
142
|
+
{
|
|
143
|
+
scope: o,
|
|
144
|
+
open: m,
|
|
145
|
+
disabled: v,
|
|
146
|
+
triggerId: d,
|
|
147
|
+
children: /* @__PURE__ */ n(
|
|
148
|
+
oo,
|
|
149
|
+
{
|
|
150
|
+
"data-orientation": r.orientation,
|
|
151
|
+
"data-state": F(m),
|
|
152
|
+
...l,
|
|
153
|
+
...i,
|
|
154
|
+
ref: c,
|
|
155
|
+
disabled: v,
|
|
156
|
+
open: m,
|
|
157
|
+
onOpenChange: (u) => {
|
|
158
|
+
u ? a.onItemOpen(t) : a.onItemClose(t);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
U.displayName = g;
|
|
167
|
+
var j = "AccordionHeader", vo = s.forwardRef(
|
|
168
|
+
(e, c) => {
|
|
169
|
+
const { __scopeAccordion: o, ...t } = e, i = I(f, o), r = k(j, o);
|
|
170
|
+
return /* @__PURE__ */ n(
|
|
171
|
+
V.h3,
|
|
172
|
+
{
|
|
173
|
+
"data-orientation": i.orientation,
|
|
174
|
+
"data-state": F(r.open),
|
|
175
|
+
"data-disabled": r.disabled ? "" : void 0,
|
|
176
|
+
...t,
|
|
177
|
+
ref: c
|
|
178
|
+
}
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
vo.displayName = j;
|
|
183
|
+
var S = "AccordionTrigger", Y = s.forwardRef(
|
|
184
|
+
(e, c) => {
|
|
185
|
+
const { __scopeAccordion: o, ...t } = e, i = I(f, o), r = k(S, o), a = so(S, o), l = E(o);
|
|
186
|
+
return /* @__PURE__ */ n(y.ItemSlot, { scope: o, children: /* @__PURE__ */ n(
|
|
187
|
+
eo,
|
|
188
|
+
{
|
|
189
|
+
"aria-disabled": r.open && !a.collapsible || void 0,
|
|
190
|
+
"data-orientation": i.orientation,
|
|
191
|
+
id: r.triggerId,
|
|
192
|
+
...l,
|
|
193
|
+
...t,
|
|
194
|
+
ref: c
|
|
195
|
+
}
|
|
196
|
+
) });
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
Y.displayName = S;
|
|
200
|
+
var q = "AccordionContent", B = s.forwardRef(
|
|
201
|
+
(e, c) => {
|
|
202
|
+
const { __scopeAccordion: o, ...t } = e, i = I(f, o), r = k(q, o), a = E(o);
|
|
203
|
+
return /* @__PURE__ */ n(
|
|
204
|
+
ro,
|
|
205
|
+
{
|
|
206
|
+
role: "region",
|
|
207
|
+
"aria-labelledby": r.triggerId,
|
|
208
|
+
"data-orientation": i.orientation,
|
|
209
|
+
...a,
|
|
210
|
+
...t,
|
|
211
|
+
ref: c,
|
|
212
|
+
style: {
|
|
213
|
+
"--radix-accordion-content-height": "var(--radix-collapsible-content-height)",
|
|
214
|
+
"--radix-accordion-content-width": "var(--radix-collapsible-content-width)",
|
|
215
|
+
...e.style
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
);
|
|
221
|
+
B.displayName = q;
|
|
222
|
+
function F(e) {
|
|
223
|
+
return e ? "open" : "closed";
|
|
224
|
+
}
|
|
225
|
+
var So = K, yo = U, Eo = Y, ko = B;
|
|
226
|
+
export {
|
|
227
|
+
K as Accordion,
|
|
228
|
+
B as AccordionContent,
|
|
229
|
+
vo as AccordionHeader,
|
|
230
|
+
U as AccordionItem,
|
|
231
|
+
Y as AccordionTrigger,
|
|
232
|
+
ko as Content,
|
|
233
|
+
yo as Item,
|
|
234
|
+
So as Root,
|
|
235
|
+
Eo as Trigger,
|
|
236
|
+
No as createAccordionScope
|
|
237
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import * as o from "react";
|
|
2
|
+
import { composeEventHandlers as T } from "../../primitive/dist/index.js";
|
|
3
|
+
import { createContextScope as S } from "../../react-context/dist/index.js";
|
|
4
|
+
import { useControllableState as D } from "../../react-use-controllable-state/dist/index.js";
|
|
5
|
+
import { useLayoutEffect as L } from "../../react-use-layout-effect/dist/index.js";
|
|
6
|
+
import { useComposedRefs as M } from "../../react-compose-refs/dist/index.js";
|
|
7
|
+
import { Primitive as b } from "../../react-primitive/dist/index.js";
|
|
8
|
+
import { Presence as k } from "../../react-presence/dist/index.js";
|
|
9
|
+
import { useId as F } from "../../react-id/dist/index.js";
|
|
10
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
11
|
+
var v = "Collapsible", [B, W] = S(v), [G, g] = B(v), w = o.forwardRef(
|
|
12
|
+
(e, a) => {
|
|
13
|
+
const {
|
|
14
|
+
__scopeCollapsible: i,
|
|
15
|
+
open: r,
|
|
16
|
+
defaultOpen: t,
|
|
17
|
+
disabled: l,
|
|
18
|
+
onOpenChange: s,
|
|
19
|
+
...u
|
|
20
|
+
} = e, [d = !1, p] = D({
|
|
21
|
+
prop: r,
|
|
22
|
+
defaultProp: t,
|
|
23
|
+
onChange: s
|
|
24
|
+
});
|
|
25
|
+
return /* @__PURE__ */ c(
|
|
26
|
+
G,
|
|
27
|
+
{
|
|
28
|
+
scope: i,
|
|
29
|
+
disabled: l,
|
|
30
|
+
contentId: F(),
|
|
31
|
+
open: d,
|
|
32
|
+
onOpenToggle: o.useCallback(() => p((m) => !m), [p]),
|
|
33
|
+
children: /* @__PURE__ */ c(
|
|
34
|
+
b.div,
|
|
35
|
+
{
|
|
36
|
+
"data-state": h(d),
|
|
37
|
+
"data-disabled": l ? "" : void 0,
|
|
38
|
+
...u,
|
|
39
|
+
ref: a
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
w.displayName = v;
|
|
47
|
+
var A = "CollapsibleTrigger", I = o.forwardRef(
|
|
48
|
+
(e, a) => {
|
|
49
|
+
const { __scopeCollapsible: i, ...r } = e, t = g(A, i);
|
|
50
|
+
return /* @__PURE__ */ c(
|
|
51
|
+
b.button,
|
|
52
|
+
{
|
|
53
|
+
type: "button",
|
|
54
|
+
"aria-controls": t.contentId,
|
|
55
|
+
"aria-expanded": t.open || !1,
|
|
56
|
+
"data-state": h(t.open),
|
|
57
|
+
"data-disabled": t.disabled ? "" : void 0,
|
|
58
|
+
disabled: t.disabled,
|
|
59
|
+
...r,
|
|
60
|
+
ref: a,
|
|
61
|
+
onClick: T(e.onClick, t.onOpenToggle)
|
|
62
|
+
}
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
I.displayName = A;
|
|
67
|
+
var R = "CollapsibleContent", O = o.forwardRef(
|
|
68
|
+
(e, a) => {
|
|
69
|
+
const { forceMount: i, ...r } = e, t = g(R, e.__scopeCollapsible);
|
|
70
|
+
return /* @__PURE__ */ c(k, { present: i || t.open, children: ({ present: l }) => /* @__PURE__ */ c($, { ...r, ref: a, present: l }) });
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
O.displayName = R;
|
|
74
|
+
var $ = o.forwardRef((e, a) => {
|
|
75
|
+
const { __scopeCollapsible: i, present: r, children: t, ...l } = e, s = g(R, i), [u, d] = o.useState(r), p = o.useRef(null), m = M(a, p), y = o.useRef(0), x = y.current, N = o.useRef(0), P = N.current, C = s.open || u, _ = o.useRef(C), f = o.useRef();
|
|
76
|
+
return o.useEffect(() => {
|
|
77
|
+
const n = requestAnimationFrame(() => _.current = !1);
|
|
78
|
+
return () => cancelAnimationFrame(n);
|
|
79
|
+
}, []), L(() => {
|
|
80
|
+
const n = p.current;
|
|
81
|
+
if (n) {
|
|
82
|
+
f.current = f.current || {
|
|
83
|
+
transitionDuration: n.style.transitionDuration,
|
|
84
|
+
animationName: n.style.animationName
|
|
85
|
+
}, n.style.transitionDuration = "0s", n.style.animationName = "none";
|
|
86
|
+
const E = n.getBoundingClientRect();
|
|
87
|
+
y.current = E.height, N.current = E.width, _.current || (n.style.transitionDuration = f.current.transitionDuration, n.style.animationName = f.current.animationName), d(r);
|
|
88
|
+
}
|
|
89
|
+
}, [s.open, r]), /* @__PURE__ */ c(
|
|
90
|
+
b.div,
|
|
91
|
+
{
|
|
92
|
+
"data-state": h(s.open),
|
|
93
|
+
"data-disabled": s.disabled ? "" : void 0,
|
|
94
|
+
id: s.contentId,
|
|
95
|
+
hidden: !C,
|
|
96
|
+
...l,
|
|
97
|
+
ref: m,
|
|
98
|
+
style: {
|
|
99
|
+
"--radix-collapsible-content-height": x ? `${x}px` : void 0,
|
|
100
|
+
"--radix-collapsible-content-width": P ? `${P}px` : void 0,
|
|
101
|
+
...e.style
|
|
102
|
+
},
|
|
103
|
+
children: C && t
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
});
|
|
107
|
+
function h(e) {
|
|
108
|
+
return e ? "open" : "closed";
|
|
109
|
+
}
|
|
110
|
+
var X = w, Y = I, Z = O;
|
|
111
|
+
export {
|
|
112
|
+
w as Collapsible,
|
|
113
|
+
O as CollapsibleContent,
|
|
114
|
+
I as CollapsibleTrigger,
|
|
115
|
+
Z as Content,
|
|
116
|
+
X as Root,
|
|
117
|
+
Y as Trigger,
|
|
118
|
+
W as createCollapsibleScope
|
|
119
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import n from "react";
|
|
2
|
+
import { createContextScope as O } from "../../react-context/dist/index.js";
|
|
3
|
+
import { useComposedRefs as S } from "../../react-compose-refs/dist/index.js";
|
|
4
|
+
import { Slot as x } from "../../react-slot/dist/index.js";
|
|
5
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
6
|
+
function h(s) {
|
|
7
|
+
const f = s + "CollectionProvider", [A, N] = O(f), [_, m] = A(
|
|
8
|
+
f,
|
|
9
|
+
{ collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
|
|
10
|
+
), u = (c) => {
|
|
11
|
+
const { scope: e, children: l } = c, o = n.useRef(null), t = n.useRef(/* @__PURE__ */ new Map()).current;
|
|
12
|
+
return /* @__PURE__ */ d(_, { scope: e, itemMap: t, collectionRef: o, children: l });
|
|
13
|
+
};
|
|
14
|
+
u.displayName = f;
|
|
15
|
+
const a = s + "CollectionSlot", p = n.forwardRef(
|
|
16
|
+
(c, e) => {
|
|
17
|
+
const { scope: l, children: o } = c, t = m(a, l), r = S(e, t.collectionRef);
|
|
18
|
+
return /* @__PURE__ */ d(x, { ref: r, children: o });
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
p.displayName = a;
|
|
22
|
+
const C = s + "CollectionItemSlot", R = "data-radix-collection-item", M = n.forwardRef(
|
|
23
|
+
(c, e) => {
|
|
24
|
+
const { scope: l, children: o, ...t } = c, r = n.useRef(null), I = S(e, r), i = m(C, l);
|
|
25
|
+
return n.useEffect(() => (i.itemMap.set(r, { ref: r, ...t }), () => void i.itemMap.delete(r))), /* @__PURE__ */ d(x, { [R]: "", ref: I, children: o });
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
M.displayName = C;
|
|
29
|
+
function E(c) {
|
|
30
|
+
const e = m(s + "CollectionConsumer", c);
|
|
31
|
+
return n.useCallback(() => {
|
|
32
|
+
const o = e.collectionRef.current;
|
|
33
|
+
if (!o) return [];
|
|
34
|
+
const t = Array.from(o.querySelectorAll(`[${R}]`));
|
|
35
|
+
return Array.from(e.itemMap.values()).sort(
|
|
36
|
+
(i, T) => t.indexOf(i.ref.current) - t.indexOf(T.ref.current)
|
|
37
|
+
);
|
|
38
|
+
}, [e.collectionRef, e.itemMap]);
|
|
39
|
+
}
|
|
40
|
+
return [
|
|
41
|
+
{ Provider: u, Slot: p, ItemSlot: M },
|
|
42
|
+
E,
|
|
43
|
+
N
|
|
44
|
+
];
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
h as createCollection
|
|
48
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
function c(o, n) {
|
|
3
|
+
typeof o == "function" ? o(n) : o != null && (o.current = n);
|
|
4
|
+
}
|
|
5
|
+
function u(...o) {
|
|
6
|
+
return (n) => o.forEach((t) => c(t, n));
|
|
7
|
+
}
|
|
8
|
+
function i(...o) {
|
|
9
|
+
return e.useCallback(u(...o), o);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
u as composeRefs,
|
|
13
|
+
i as useComposedRefs
|
|
14
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as u from "react";
|
|
2
|
+
import { jsx as C } from "react/jsx-runtime";
|
|
3
|
+
function $(e, c) {
|
|
4
|
+
const o = u.createContext(c);
|
|
5
|
+
function a(r) {
|
|
6
|
+
const { children: t, ...n } = r, s = u.useMemo(() => n, Object.values(n));
|
|
7
|
+
return /* @__PURE__ */ C(o.Provider, { value: s, children: t });
|
|
8
|
+
}
|
|
9
|
+
function i(r) {
|
|
10
|
+
const t = u.useContext(o);
|
|
11
|
+
if (t) return t;
|
|
12
|
+
if (c !== void 0) return c;
|
|
13
|
+
throw new Error(`\`${r}\` must be used within \`${e}\``);
|
|
14
|
+
}
|
|
15
|
+
return a.displayName = e + "Provider", [a, i];
|
|
16
|
+
}
|
|
17
|
+
function w(e, c = []) {
|
|
18
|
+
let o = [];
|
|
19
|
+
function a(r, t) {
|
|
20
|
+
const n = u.createContext(t), s = o.length;
|
|
21
|
+
o = [...o, t];
|
|
22
|
+
function m(d) {
|
|
23
|
+
const { scope: x, children: p, ...f } = d, S = (x == null ? void 0 : x[e][s]) || n, h = u.useMemo(() => f, Object.values(f));
|
|
24
|
+
return /* @__PURE__ */ C(S.Provider, { value: h, children: p });
|
|
25
|
+
}
|
|
26
|
+
function v(d, x) {
|
|
27
|
+
const p = (x == null ? void 0 : x[e][s]) || n, f = u.useContext(p);
|
|
28
|
+
if (f) return f;
|
|
29
|
+
if (t !== void 0) return t;
|
|
30
|
+
throw new Error(`\`${d}\` must be used within \`${r}\``);
|
|
31
|
+
}
|
|
32
|
+
return m.displayName = r + "Provider", [m, v];
|
|
33
|
+
}
|
|
34
|
+
const i = () => {
|
|
35
|
+
const r = o.map((t) => u.createContext(t));
|
|
36
|
+
return function(n) {
|
|
37
|
+
const s = (n == null ? void 0 : n[e]) || r;
|
|
38
|
+
return u.useMemo(
|
|
39
|
+
() => ({ [`__scope${e}`]: { ...n, [e]: s } }),
|
|
40
|
+
[n, s]
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
return i.scopeName = e, [a, P(i, ...c)];
|
|
45
|
+
}
|
|
46
|
+
function P(...e) {
|
|
47
|
+
const c = e[0];
|
|
48
|
+
if (e.length === 1) return c;
|
|
49
|
+
const o = () => {
|
|
50
|
+
const a = e.map((i) => ({
|
|
51
|
+
useScope: i(),
|
|
52
|
+
scopeName: i.scopeName
|
|
53
|
+
}));
|
|
54
|
+
return function(r) {
|
|
55
|
+
const t = a.reduce((n, { useScope: s, scopeName: m }) => {
|
|
56
|
+
const d = s(r)[`__scope${m}`];
|
|
57
|
+
return { ...n, ...d };
|
|
58
|
+
}, {});
|
|
59
|
+
return u.useMemo(() => ({ [`__scope${c.scopeName}`]: t }), [t]);
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
return o.scopeName = c.scopeName, o;
|
|
63
|
+
}
|
|
64
|
+
export {
|
|
65
|
+
$ as createContext,
|
|
66
|
+
w as createContextScope
|
|
67
|
+
};
|