@entropix/react 0.3.0 → 1.0.1
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/accordion.cjs +27 -0
- package/dist/accordion.css +57 -0
- package/dist/accordion.d.cts +30 -0
- package/dist/accordion.d.ts +30 -0
- package/dist/accordion.js +6 -0
- package/dist/button.cjs +15 -0
- package/dist/button.css +113 -0
- package/dist/button.d.cts +25 -0
- package/dist/button.d.ts +25 -0
- package/dist/button.js +6 -0
- package/dist/checkbox.cjs +15 -0
- package/dist/checkbox.css +89 -0
- package/dist/checkbox.d.cts +26 -0
- package/dist/checkbox.d.ts +26 -0
- package/dist/checkbox.js +6 -0
- package/dist/chunk-2MKJZEUK.cjs +4 -0
- package/dist/chunk-34IVVIO3.cjs +119 -0
- package/dist/chunk-36ZHHJYV.js +79 -0
- package/dist/chunk-5DKE5YQD.cjs +10 -0
- package/dist/chunk-664P2RGR.js +108 -0
- package/dist/chunk-6NKHMBF3.cjs +97 -0
- package/dist/chunk-6UAQCHIW.js +8 -0
- package/dist/chunk-7AUIZOEH.cjs +84 -0
- package/dist/chunk-AVCBDUKH.js +3 -0
- package/dist/chunk-B5JZHE4I.cjs +90 -0
- package/dist/chunk-BN57JPKV.js +26 -0
- package/dist/chunk-BY4E26CV.js +114 -0
- package/dist/chunk-CL6JXZIY.js +88 -0
- package/dist/chunk-CTT3LXMZ.js +76 -0
- package/dist/chunk-EASSPJBG.cjs +110 -0
- package/dist/chunk-EWY7MSXF.cjs +94 -0
- package/dist/chunk-FJGLK3I4.js +89 -0
- package/dist/chunk-GTVBKK3W.js +88 -0
- package/dist/chunk-GZXXUFCJ.cjs +15 -0
- package/dist/chunk-IXH7OVN3.cjs +86 -0
- package/dist/chunk-KGIUECLG.cjs +91 -0
- package/dist/chunk-LDOP6DVX.cjs +28 -0
- package/dist/chunk-LJK6KK2H.cjs +43 -0
- package/dist/chunk-OT2HJUCB.js +84 -0
- package/dist/chunk-PILZGMQG.js +87 -0
- package/dist/chunk-PN42JF6U.js +92 -0
- package/dist/chunk-RPIYYBFJ.cjs +90 -0
- package/dist/chunk-S6DVQAH4.cjs +240 -0
- package/dist/chunk-U5CZHO6D.js +13 -0
- package/dist/chunk-UGCCJI2F.js +111 -0
- package/dist/chunk-W6N4D4N4.js +230 -0
- package/dist/chunk-Y2M2LJGJ.js +41 -0
- package/dist/chunk-YJG5KX6O.cjs +81 -0
- package/dist/chunk-ZG4PZBSL.cjs +113 -0
- package/dist/dialog.cjs +39 -0
- package/dist/dialog.css +89 -0
- package/dist/dialog.d.cts +62 -0
- package/dist/dialog.d.ts +62 -0
- package/dist/dialog.js +6 -0
- package/dist/index.cjs +170 -1223
- package/dist/index.css +994 -1015
- package/dist/index.d.cts +17 -477
- package/dist/index.d.ts +17 -477
- package/dist/index.js +19 -1189
- package/dist/input.cjs +15 -0
- package/dist/input.css +135 -0
- package/dist/input.d.cts +37 -0
- package/dist/input.d.ts +37 -0
- package/dist/input.js +6 -0
- package/dist/layout.cjs +25 -0
- package/dist/layout.css +176 -0
- package/dist/layout.d.cts +108 -0
- package/dist/layout.d.ts +108 -0
- package/dist/layout.js +4 -0
- package/dist/menu.cjs +27 -0
- package/dist/menu.css +51 -0
- package/dist/menu.d.cts +31 -0
- package/dist/menu.d.ts +31 -0
- package/dist/menu.js +6 -0
- package/dist/radio.cjs +19 -0
- package/dist/radio.css +93 -0
- package/dist/radio.d.cts +37 -0
- package/dist/radio.d.ts +37 -0
- package/dist/radio.js +6 -0
- package/dist/select.cjs +27 -0
- package/dist/select.css +114 -0
- package/dist/select.d.cts +59 -0
- package/dist/select.d.ts +59 -0
- package/dist/select.js +6 -0
- package/dist/styles/accordion.css +1 -69
- package/dist/styles/button.css +1 -135
- package/dist/styles/checkbox.css +1 -121
- package/dist/styles/dialog.css +1 -104
- package/dist/styles/index.css +1 -16
- package/dist/styles/input.css +1 -178
- package/dist/styles/layout.css +1 -127
- package/dist/styles/menu.css +1 -64
- package/dist/styles/radio.css +1 -130
- package/dist/styles/select.css +1 -150
- package/dist/styles/switch.css +1 -52
- package/dist/styles/tabs.css +1 -86
- package/dist/styles/toggle.css +1 -47
- package/dist/switch.cjs +16 -0
- package/dist/switch.css +89 -0
- package/dist/switch.d.cts +14 -0
- package/dist/switch.d.ts +14 -0
- package/dist/switch.js +7 -0
- package/dist/tabs.cjs +27 -0
- package/dist/tabs.css +69 -0
- package/dist/tabs.d.cts +31 -0
- package/dist/tabs.d.ts +31 -0
- package/dist/tabs.js +6 -0
- package/dist/textarea.cjs +15 -0
- package/dist/textarea.css +135 -0
- package/dist/textarea.d.cts +41 -0
- package/dist/textarea.d.ts +41 -0
- package/dist/textarea.js +6 -0
- package/dist/toggle.cjs +19 -0
- package/dist/toggle.css +41 -0
- package/dist/toggle.d.cts +34 -0
- package/dist/toggle.d.ts +34 -0
- package/dist/toggle.js +6 -0
- package/package.json +135 -4
- package/dist/index.cjs.map +0 -1
- package/dist/index.css.map +0 -1
- package/dist/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,1124 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
export { Input } from './chunk-664P2RGR.js';
|
|
2
|
+
export { Textarea } from './chunk-UGCCJI2F.js';
|
|
3
|
+
import './chunk-AVCBDUKH.js';
|
|
4
|
+
export { Checkbox } from './chunk-CL6JXZIY.js';
|
|
5
|
+
export { RadioGroup, RadioItem } from './chunk-GTVBKK3W.js';
|
|
6
|
+
export { Select, SelectContent, SelectOption, SelectTrigger } from './chunk-BY4E26CV.js';
|
|
7
|
+
export { Container, Divider, Inline, Stack } from './chunk-CTT3LXMZ.js';
|
|
8
|
+
export { Button } from './chunk-OT2HJUCB.js';
|
|
9
|
+
export { Switch } from './chunk-U5CZHO6D.js';
|
|
10
|
+
export { Toggle } from './chunk-PILZGMQG.js';
|
|
11
|
+
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogOverlay, DialogTitle, DialogTrigger, useFocusRestore, useFocusTrap } from './chunk-W6N4D4N4.js';
|
|
12
|
+
export { Tab, TabList, TabPanel, Tabs } from './chunk-36ZHHJYV.js';
|
|
13
|
+
export { Accordion, AccordionItem, AccordionPanel, AccordionTrigger } from './chunk-FJGLK3I4.js';
|
|
14
|
+
export { Menu, MenuContent, MenuItem, MenuTrigger } from './chunk-PN42JF6U.js';
|
|
15
|
+
export { useKeyboardHandler } from './chunk-BN57JPKV.js';
|
|
16
|
+
export { mapAccessibilityToAria } from './chunk-Y2M2LJGJ.js';
|
|
17
|
+
import './chunk-6UAQCHIW.js';
|
|
18
|
+
import { useCallback, useState, useEffect } from 'react';
|
|
5
19
|
|
|
6
|
-
// src/utils/map-accessibility-to-aria.ts
|
|
7
|
-
var ARIA_MAP = {
|
|
8
|
-
role: "role",
|
|
9
|
-
label: "aria-label",
|
|
10
|
-
labelledBy: "aria-labelledby",
|
|
11
|
-
describedBy: "aria-describedby",
|
|
12
|
-
disabled: "aria-disabled",
|
|
13
|
-
expanded: "aria-expanded",
|
|
14
|
-
selected: "aria-selected",
|
|
15
|
-
checked: "aria-checked",
|
|
16
|
-
pressed: "aria-pressed",
|
|
17
|
-
busy: "aria-busy",
|
|
18
|
-
modal: "aria-modal",
|
|
19
|
-
hasPopup: "aria-haspopup",
|
|
20
|
-
controls: "aria-controls",
|
|
21
|
-
owns: "aria-owns",
|
|
22
|
-
live: "aria-live",
|
|
23
|
-
orientation: "aria-orientation",
|
|
24
|
-
tabIndex: "tabIndex",
|
|
25
|
-
hidden: "aria-hidden",
|
|
26
|
-
valueNow: "aria-valuenow",
|
|
27
|
-
valueMin: "aria-valuemin",
|
|
28
|
-
valueMax: "aria-valuemax",
|
|
29
|
-
valueText: "aria-valuetext",
|
|
30
|
-
required: "aria-required",
|
|
31
|
-
invalid: "aria-invalid"
|
|
32
|
-
};
|
|
33
|
-
function mapAccessibilityToAria(props) {
|
|
34
|
-
const result = {};
|
|
35
|
-
for (const [key, attrName] of Object.entries(ARIA_MAP)) {
|
|
36
|
-
const value = props[key];
|
|
37
|
-
if (value !== void 0) {
|
|
38
|
-
result[attrName] = value;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return result;
|
|
42
|
-
}
|
|
43
|
-
function useKeyboardHandler(keyboardConfig, actionMap) {
|
|
44
|
-
const handler = useCallback(
|
|
45
|
-
(event) => {
|
|
46
|
-
if (!keyboardConfig) return;
|
|
47
|
-
const intent = keyboardConfig.getIntent(event.key, {
|
|
48
|
-
shift: event.shiftKey,
|
|
49
|
-
meta: event.metaKey,
|
|
50
|
-
alt: event.altKey
|
|
51
|
-
});
|
|
52
|
-
if (intent && actionMap[intent]) {
|
|
53
|
-
event.preventDefault();
|
|
54
|
-
actionMap[intent]();
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
[keyboardConfig, actionMap]
|
|
58
|
-
);
|
|
59
|
-
if (!keyboardConfig) return void 0;
|
|
60
|
-
return handler;
|
|
61
|
-
}
|
|
62
|
-
var FOCUSABLE_SELECTOR = [
|
|
63
|
-
"a[href]",
|
|
64
|
-
"button:not([disabled])",
|
|
65
|
-
"input:not([disabled])",
|
|
66
|
-
"select:not([disabled])",
|
|
67
|
-
"textarea:not([disabled])",
|
|
68
|
-
'[tabindex]:not([tabindex="-1"])'
|
|
69
|
-
].join(", ");
|
|
70
|
-
function useFocusTrap(containerRef, isActive) {
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (!isActive) return;
|
|
73
|
-
const container = containerRef.current;
|
|
74
|
-
if (!container) return;
|
|
75
|
-
const focusableElements = container.querySelectorAll(FOCUSABLE_SELECTOR);
|
|
76
|
-
if (focusableElements.length > 0) {
|
|
77
|
-
focusableElements[0].focus();
|
|
78
|
-
}
|
|
79
|
-
function handleKeyDown(event) {
|
|
80
|
-
if (event.key !== "Tab") return;
|
|
81
|
-
const focusable = container.querySelectorAll(FOCUSABLE_SELECTOR);
|
|
82
|
-
if (focusable.length === 0) return;
|
|
83
|
-
const first = focusable[0];
|
|
84
|
-
const last = focusable[focusable.length - 1];
|
|
85
|
-
if (event.shiftKey) {
|
|
86
|
-
if (document.activeElement === first) {
|
|
87
|
-
event.preventDefault();
|
|
88
|
-
last.focus();
|
|
89
|
-
}
|
|
90
|
-
} else {
|
|
91
|
-
if (document.activeElement === last) {
|
|
92
|
-
event.preventDefault();
|
|
93
|
-
first.focus();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
container.addEventListener("keydown", handleKeyDown);
|
|
98
|
-
return () => {
|
|
99
|
-
container.removeEventListener("keydown", handleKeyDown);
|
|
100
|
-
};
|
|
101
|
-
}, [isActive, containerRef]);
|
|
102
|
-
}
|
|
103
|
-
function useFocusRestore(isActive) {
|
|
104
|
-
const savedElement = useRef(null);
|
|
105
|
-
useEffect(() => {
|
|
106
|
-
if (isActive) {
|
|
107
|
-
savedElement.current = document.activeElement;
|
|
108
|
-
} else if (savedElement.current) {
|
|
109
|
-
const el = savedElement.current;
|
|
110
|
-
if (el && document.body.contains(el) && typeof el.focus === "function") {
|
|
111
|
-
el.focus();
|
|
112
|
-
}
|
|
113
|
-
savedElement.current = null;
|
|
114
|
-
}
|
|
115
|
-
}, [isActive]);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// src/utils/cn.ts
|
|
119
|
-
function cn(...classes) {
|
|
120
|
-
return classes.filter(Boolean).join(" ");
|
|
121
|
-
}
|
|
122
|
-
var Button = forwardRef(function Button2({
|
|
123
|
-
disabled,
|
|
124
|
-
loading,
|
|
125
|
-
onPress,
|
|
126
|
-
as: Component = "button",
|
|
127
|
-
variant,
|
|
128
|
-
size,
|
|
129
|
-
className,
|
|
130
|
-
style,
|
|
131
|
-
children,
|
|
132
|
-
onClick,
|
|
133
|
-
onKeyDown: externalOnKeyDown,
|
|
134
|
-
...rest
|
|
135
|
-
}, ref) {
|
|
136
|
-
const elementType = typeof Component === "string" ? Component : "div";
|
|
137
|
-
const { isDisabled, isLoading, getButtonProps } = useButton({
|
|
138
|
-
disabled,
|
|
139
|
-
loading,
|
|
140
|
-
onPress,
|
|
141
|
-
elementType
|
|
142
|
-
});
|
|
143
|
-
const propGetterReturn = getButtonProps();
|
|
144
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
145
|
-
const actionMap = useMemo(
|
|
146
|
-
() => ({
|
|
147
|
-
activate: propGetterReturn.onAction ?? (() => {
|
|
148
|
-
})
|
|
149
|
-
}),
|
|
150
|
-
[propGetterReturn.onAction]
|
|
151
|
-
);
|
|
152
|
-
const onKeyDown = useKeyboardHandler(
|
|
153
|
-
propGetterReturn.keyboardConfig,
|
|
154
|
-
actionMap
|
|
155
|
-
);
|
|
156
|
-
const handleClick = useCallback(
|
|
157
|
-
(event) => {
|
|
158
|
-
propGetterReturn.onAction?.();
|
|
159
|
-
onClick?.(event);
|
|
160
|
-
},
|
|
161
|
-
[propGetterReturn.onAction, onClick]
|
|
162
|
-
);
|
|
163
|
-
const handleKeyDown = useCallback(
|
|
164
|
-
(event) => {
|
|
165
|
-
onKeyDown?.(event);
|
|
166
|
-
externalOnKeyDown?.(event);
|
|
167
|
-
},
|
|
168
|
-
[onKeyDown, externalOnKeyDown]
|
|
169
|
-
);
|
|
170
|
-
const dataState = isLoading ? "loading" : isDisabled ? "disabled" : void 0;
|
|
171
|
-
return /* @__PURE__ */ jsx(
|
|
172
|
-
Component,
|
|
173
|
-
{
|
|
174
|
-
ref,
|
|
175
|
-
className: cn(
|
|
176
|
-
"entropix-button",
|
|
177
|
-
variant && `entropix-button--${variant}`,
|
|
178
|
-
size && `entropix-button--${size}`,
|
|
179
|
-
className
|
|
180
|
-
),
|
|
181
|
-
style,
|
|
182
|
-
...ariaProps,
|
|
183
|
-
...rest,
|
|
184
|
-
type: Component === "button" ? "button" : void 0,
|
|
185
|
-
disabled: Component === "button" && isDisabled ? true : void 0,
|
|
186
|
-
onClick: propGetterReturn.onAction || onClick ? handleClick : void 0,
|
|
187
|
-
onKeyDown: onKeyDown || externalOnKeyDown ? handleKeyDown : void 0,
|
|
188
|
-
"data-state": dataState,
|
|
189
|
-
"data-variant": variant,
|
|
190
|
-
"data-size": size,
|
|
191
|
-
children
|
|
192
|
-
}
|
|
193
|
-
);
|
|
194
|
-
});
|
|
195
|
-
var Toggle = forwardRef(
|
|
196
|
-
function Toggle2(props, ref) {
|
|
197
|
-
return /* @__PURE__ */ jsx(ToggleInner, { ...props, ref, role: "checkbox", componentClass: "entropix-toggle" });
|
|
198
|
-
}
|
|
199
|
-
);
|
|
200
|
-
var ToggleInner = forwardRef(
|
|
201
|
-
function ToggleInner2({
|
|
202
|
-
checked,
|
|
203
|
-
defaultChecked,
|
|
204
|
-
onChange,
|
|
205
|
-
disabled,
|
|
206
|
-
label,
|
|
207
|
-
role = "checkbox",
|
|
208
|
-
componentClass = "entropix-toggle",
|
|
209
|
-
className,
|
|
210
|
-
style,
|
|
211
|
-
children,
|
|
212
|
-
onClick,
|
|
213
|
-
onKeyDown: externalOnKeyDown,
|
|
214
|
-
...rest
|
|
215
|
-
}, ref) {
|
|
216
|
-
const { isChecked, isDisabled, getToggleProps } = useToggle({
|
|
217
|
-
checked,
|
|
218
|
-
defaultChecked,
|
|
219
|
-
onChange,
|
|
220
|
-
disabled,
|
|
221
|
-
role
|
|
222
|
-
});
|
|
223
|
-
const propGetterReturn = getToggleProps();
|
|
224
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
225
|
-
if (label && !children) {
|
|
226
|
-
ariaProps["aria-label"] = label;
|
|
227
|
-
}
|
|
228
|
-
const actionMap = useMemo(
|
|
229
|
-
() => ({
|
|
230
|
-
toggle: propGetterReturn.onAction ?? (() => {
|
|
231
|
-
})
|
|
232
|
-
}),
|
|
233
|
-
[propGetterReturn.onAction]
|
|
234
|
-
);
|
|
235
|
-
const onKeyDown = useKeyboardHandler(
|
|
236
|
-
propGetterReturn.keyboardConfig,
|
|
237
|
-
actionMap
|
|
238
|
-
);
|
|
239
|
-
const handleClick = useCallback(
|
|
240
|
-
(event) => {
|
|
241
|
-
propGetterReturn.onAction?.();
|
|
242
|
-
onClick?.(event);
|
|
243
|
-
},
|
|
244
|
-
[propGetterReturn.onAction, onClick]
|
|
245
|
-
);
|
|
246
|
-
const handleKeyDown = useCallback(
|
|
247
|
-
(event) => {
|
|
248
|
-
onKeyDown?.(event);
|
|
249
|
-
externalOnKeyDown?.(event);
|
|
250
|
-
},
|
|
251
|
-
[onKeyDown, externalOnKeyDown]
|
|
252
|
-
);
|
|
253
|
-
return /* @__PURE__ */ jsx(
|
|
254
|
-
"button",
|
|
255
|
-
{
|
|
256
|
-
ref,
|
|
257
|
-
type: "button",
|
|
258
|
-
className: cn(componentClass, className),
|
|
259
|
-
style,
|
|
260
|
-
...ariaProps,
|
|
261
|
-
...rest,
|
|
262
|
-
disabled: isDisabled || void 0,
|
|
263
|
-
onClick: propGetterReturn.onAction || onClick ? handleClick : void 0,
|
|
264
|
-
onKeyDown: onKeyDown || externalOnKeyDown ? handleKeyDown : void 0,
|
|
265
|
-
"data-state": isChecked ? "checked" : "unchecked",
|
|
266
|
-
children
|
|
267
|
-
}
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
);
|
|
271
|
-
var Switch = forwardRef(
|
|
272
|
-
function Switch2(props, ref) {
|
|
273
|
-
return /* @__PURE__ */ jsx(ToggleInner, { ...props, ref, role: "switch", componentClass: "entropix-switch" });
|
|
274
|
-
}
|
|
275
|
-
);
|
|
276
|
-
var DialogContext = createContext(null);
|
|
277
|
-
function useDialogContext() {
|
|
278
|
-
const context = useContext(DialogContext);
|
|
279
|
-
if (!context) {
|
|
280
|
-
throw new Error(
|
|
281
|
-
"Dialog compound components must be used within a <Dialog> provider."
|
|
282
|
-
);
|
|
283
|
-
}
|
|
284
|
-
return context;
|
|
285
|
-
}
|
|
286
|
-
function Dialog({
|
|
287
|
-
children,
|
|
288
|
-
isOpen,
|
|
289
|
-
defaultOpen,
|
|
290
|
-
onOpenChange,
|
|
291
|
-
closeOnOverlayPress,
|
|
292
|
-
closeOnEscape,
|
|
293
|
-
modal,
|
|
294
|
-
role
|
|
295
|
-
}) {
|
|
296
|
-
const dialog = useDialog({
|
|
297
|
-
isOpen,
|
|
298
|
-
defaultOpen,
|
|
299
|
-
onOpenChange,
|
|
300
|
-
closeOnOverlayPress,
|
|
301
|
-
closeOnEscape,
|
|
302
|
-
modal,
|
|
303
|
-
role
|
|
304
|
-
});
|
|
305
|
-
return /* @__PURE__ */ jsx(DialogContext.Provider, { value: dialog, children });
|
|
306
|
-
}
|
|
307
|
-
var DialogTrigger = forwardRef(
|
|
308
|
-
function DialogTrigger2({ children, className, onClick, ...rest }, ref) {
|
|
309
|
-
const { getTriggerProps } = useDialogContext();
|
|
310
|
-
const propGetterReturn = getTriggerProps();
|
|
311
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
312
|
-
const handleClick = useCallback(
|
|
313
|
-
(event) => {
|
|
314
|
-
propGetterReturn.onAction?.();
|
|
315
|
-
onClick?.(event);
|
|
316
|
-
},
|
|
317
|
-
[propGetterReturn.onAction, onClick]
|
|
318
|
-
);
|
|
319
|
-
return /* @__PURE__ */ jsx(
|
|
320
|
-
"button",
|
|
321
|
-
{
|
|
322
|
-
ref,
|
|
323
|
-
type: "button",
|
|
324
|
-
...ariaProps,
|
|
325
|
-
...rest,
|
|
326
|
-
className: cn("entropix-dialog-trigger", className),
|
|
327
|
-
onClick: handleClick,
|
|
328
|
-
children
|
|
329
|
-
}
|
|
330
|
-
);
|
|
331
|
-
}
|
|
332
|
-
);
|
|
333
|
-
var DialogContent = forwardRef(
|
|
334
|
-
function DialogContent2({ children, className, onKeyDown: externalOnKeyDown, ...rest }, ref) {
|
|
335
|
-
const { isOpen, close, ids, focusManagement, getContentProps } = useDialogContext();
|
|
336
|
-
const [mounted, setMounted] = useState(false);
|
|
337
|
-
useEffect(() => {
|
|
338
|
-
setMounted(true);
|
|
339
|
-
}, []);
|
|
340
|
-
const internalRef = useRef(null);
|
|
341
|
-
useFocusTrap(internalRef, isOpen && focusManagement.trapFocus);
|
|
342
|
-
useFocusRestore(isOpen && focusManagement.restoreFocus);
|
|
343
|
-
const propGetterReturn = getContentProps();
|
|
344
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
345
|
-
const actionMap = useMemo(() => ({ dismiss: close }), [close]);
|
|
346
|
-
const onKeyDown = useKeyboardHandler(
|
|
347
|
-
propGetterReturn.keyboardConfig,
|
|
348
|
-
actionMap
|
|
349
|
-
);
|
|
350
|
-
if (!mounted || !isOpen) return null;
|
|
351
|
-
const content = /* @__PURE__ */ jsx(
|
|
352
|
-
"div",
|
|
353
|
-
{
|
|
354
|
-
ref: (node) => {
|
|
355
|
-
internalRef.current = node;
|
|
356
|
-
if (typeof ref === "function") {
|
|
357
|
-
ref(node);
|
|
358
|
-
} else if (ref) {
|
|
359
|
-
ref.current = node;
|
|
360
|
-
}
|
|
361
|
-
},
|
|
362
|
-
id: ids.content,
|
|
363
|
-
...ariaProps,
|
|
364
|
-
...rest,
|
|
365
|
-
className: cn("entropix-dialog-content", className),
|
|
366
|
-
onKeyDown: onKeyDown ? (event) => {
|
|
367
|
-
onKeyDown(event);
|
|
368
|
-
externalOnKeyDown?.(event);
|
|
369
|
-
} : externalOnKeyDown,
|
|
370
|
-
"data-state": isOpen ? "open" : "closed",
|
|
371
|
-
children
|
|
372
|
-
}
|
|
373
|
-
);
|
|
374
|
-
return createPortal(content, document.body);
|
|
375
|
-
}
|
|
376
|
-
);
|
|
377
|
-
var DialogTitle = forwardRef(
|
|
378
|
-
function DialogTitle2({ children, className, ...rest }, ref) {
|
|
379
|
-
const { ids } = useDialogContext();
|
|
380
|
-
return /* @__PURE__ */ jsx("h2", { ref, id: ids.title, ...rest, className: cn("entropix-dialog-title", className), children });
|
|
381
|
-
}
|
|
382
|
-
);
|
|
383
|
-
var DialogDescription = forwardRef(function DialogDescription2({ children, className, ...rest }, ref) {
|
|
384
|
-
const { ids } = useDialogContext();
|
|
385
|
-
return /* @__PURE__ */ jsx("p", { ref, id: ids.description, ...rest, className: cn("entropix-dialog-description", className), children });
|
|
386
|
-
});
|
|
387
|
-
var DialogClose = forwardRef(
|
|
388
|
-
function DialogClose2({ children, className, onClick, ...rest }, ref) {
|
|
389
|
-
const { getCloseProps } = useDialogContext();
|
|
390
|
-
const propGetterReturn = getCloseProps();
|
|
391
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
392
|
-
const handleClick = useCallback(
|
|
393
|
-
(event) => {
|
|
394
|
-
propGetterReturn.onAction?.();
|
|
395
|
-
onClick?.(event);
|
|
396
|
-
},
|
|
397
|
-
[propGetterReturn.onAction, onClick]
|
|
398
|
-
);
|
|
399
|
-
return /* @__PURE__ */ jsx(
|
|
400
|
-
"button",
|
|
401
|
-
{
|
|
402
|
-
ref,
|
|
403
|
-
type: "button",
|
|
404
|
-
...ariaProps,
|
|
405
|
-
...rest,
|
|
406
|
-
className: cn("entropix-dialog-close", className),
|
|
407
|
-
onClick: handleClick,
|
|
408
|
-
children
|
|
409
|
-
}
|
|
410
|
-
);
|
|
411
|
-
}
|
|
412
|
-
);
|
|
413
|
-
var DialogOverlay = forwardRef(
|
|
414
|
-
function DialogOverlay2({ className, onClick, ...rest }, ref) {
|
|
415
|
-
const { isOpen, getOverlayProps } = useDialogContext();
|
|
416
|
-
const propGetterReturn = getOverlayProps();
|
|
417
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
418
|
-
const handleClick = useCallback(
|
|
419
|
-
(event) => {
|
|
420
|
-
propGetterReturn.onAction?.();
|
|
421
|
-
onClick?.(event);
|
|
422
|
-
},
|
|
423
|
-
[propGetterReturn.onAction, onClick]
|
|
424
|
-
);
|
|
425
|
-
if (!isOpen) return null;
|
|
426
|
-
return /* @__PURE__ */ jsx(
|
|
427
|
-
"div",
|
|
428
|
-
{
|
|
429
|
-
ref,
|
|
430
|
-
...ariaProps,
|
|
431
|
-
...rest,
|
|
432
|
-
className: cn("entropix-dialog-overlay", className),
|
|
433
|
-
onClick: propGetterReturn.onAction || onClick ? handleClick : void 0,
|
|
434
|
-
"data-state": isOpen ? "open" : "closed"
|
|
435
|
-
}
|
|
436
|
-
);
|
|
437
|
-
}
|
|
438
|
-
);
|
|
439
|
-
var TabsContext = createContext(null);
|
|
440
|
-
function useTabsContext() {
|
|
441
|
-
const context = useContext(TabsContext);
|
|
442
|
-
if (!context) {
|
|
443
|
-
throw new Error(
|
|
444
|
-
"Tabs compound components must be used within a <Tabs> provider."
|
|
445
|
-
);
|
|
446
|
-
}
|
|
447
|
-
return context;
|
|
448
|
-
}
|
|
449
|
-
function Tabs({
|
|
450
|
-
children,
|
|
451
|
-
className,
|
|
452
|
-
orientation = "horizontal",
|
|
453
|
-
activationMode = "automatic",
|
|
454
|
-
...options
|
|
455
|
-
}) {
|
|
456
|
-
const tabs = useTabs({ ...options, orientation, activationMode });
|
|
457
|
-
return /* @__PURE__ */ jsx(TabsContext.Provider, { value: { ...tabs, orientation, activationMode }, children: /* @__PURE__ */ jsx("div", { className: cn("entropix-tabs", className), "data-orientation": orientation, children }) });
|
|
458
|
-
}
|
|
459
|
-
function TabList({ children, className }) {
|
|
460
|
-
const { getTabListProps } = useTabsContext();
|
|
461
|
-
const propGetterReturn = getTabListProps();
|
|
462
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
463
|
-
return /* @__PURE__ */ jsx("div", { ...ariaProps, className: cn("entropix-tablist", className), children });
|
|
464
|
-
}
|
|
465
|
-
function Tab({ value, children, className }) {
|
|
466
|
-
const { getTabProps, select, selectedKey, orientation } = useTabsContext();
|
|
467
|
-
const propGetterReturn = getTabProps(value);
|
|
468
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
469
|
-
const baseId = ariaProps["aria-controls"] ? String(ariaProps["aria-controls"]).replace(`-panel-${value}`, "") : "";
|
|
470
|
-
const handleClick = useCallback(() => {
|
|
471
|
-
propGetterReturn.onAction?.();
|
|
472
|
-
}, [propGetterReturn.onAction]);
|
|
473
|
-
const onKeyDown = useKeyboardHandler(propGetterReturn.keyboardConfig, {
|
|
474
|
-
activate: () => select(value)
|
|
475
|
-
});
|
|
476
|
-
return /* @__PURE__ */ jsx(
|
|
477
|
-
"button",
|
|
478
|
-
{
|
|
479
|
-
...ariaProps,
|
|
480
|
-
id: `${baseId}-tab-${value}`,
|
|
481
|
-
className: cn("entropix-tab", className),
|
|
482
|
-
onClick: handleClick,
|
|
483
|
-
onKeyDown,
|
|
484
|
-
"data-state": selectedKey === value ? "active" : "inactive",
|
|
485
|
-
"data-orientation": orientation,
|
|
486
|
-
children
|
|
487
|
-
}
|
|
488
|
-
);
|
|
489
|
-
}
|
|
490
|
-
function TabPanel({ value, children, className }) {
|
|
491
|
-
const { getTabPanelProps, selectedKey } = useTabsContext();
|
|
492
|
-
const propGetterReturn = getTabPanelProps(value);
|
|
493
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
494
|
-
const baseId = ariaProps["aria-labelledby"] ? String(ariaProps["aria-labelledby"]).replace(`-tab-${value}`, "") : "";
|
|
495
|
-
if (selectedKey !== value) return null;
|
|
496
|
-
return /* @__PURE__ */ jsx(
|
|
497
|
-
"div",
|
|
498
|
-
{
|
|
499
|
-
...ariaProps,
|
|
500
|
-
id: `${baseId}-panel-${value}`,
|
|
501
|
-
className: cn("entropix-tabpanel", className),
|
|
502
|
-
"data-state": "active",
|
|
503
|
-
children
|
|
504
|
-
}
|
|
505
|
-
);
|
|
506
|
-
}
|
|
507
|
-
var AccordionContext = createContext(null);
|
|
508
|
-
function useAccordionContext() {
|
|
509
|
-
const context = useContext(AccordionContext);
|
|
510
|
-
if (!context) {
|
|
511
|
-
throw new Error(
|
|
512
|
-
"Accordion compound components must be used within an <Accordion> provider."
|
|
513
|
-
);
|
|
514
|
-
}
|
|
515
|
-
return context;
|
|
516
|
-
}
|
|
517
|
-
var AccordionItemContext = createContext(null);
|
|
518
|
-
function useAccordionItemContext() {
|
|
519
|
-
const context = useContext(AccordionItemContext);
|
|
520
|
-
if (context === null) {
|
|
521
|
-
throw new Error(
|
|
522
|
-
"AccordionTrigger and AccordionPanel must be used within an <AccordionItem>."
|
|
523
|
-
);
|
|
524
|
-
}
|
|
525
|
-
return context;
|
|
526
|
-
}
|
|
527
|
-
function Accordion({ children, className, ...options }) {
|
|
528
|
-
const accordion = useAccordion(options);
|
|
529
|
-
return /* @__PURE__ */ jsx(AccordionContext.Provider, { value: accordion, children: /* @__PURE__ */ jsx("div", { className: cn("entropix-accordion", className), children }) });
|
|
530
|
-
}
|
|
531
|
-
function AccordionItem({
|
|
532
|
-
value,
|
|
533
|
-
children,
|
|
534
|
-
className
|
|
535
|
-
}) {
|
|
536
|
-
const { isExpanded } = useAccordionContext();
|
|
537
|
-
return /* @__PURE__ */ jsx(AccordionItemContext.Provider, { value, children: /* @__PURE__ */ jsx(
|
|
538
|
-
"div",
|
|
539
|
-
{
|
|
540
|
-
className: cn("entropix-accordion-item", className),
|
|
541
|
-
"data-state": isExpanded(value) ? "open" : "closed",
|
|
542
|
-
children
|
|
543
|
-
}
|
|
544
|
-
) });
|
|
545
|
-
}
|
|
546
|
-
function AccordionTrigger({
|
|
547
|
-
children,
|
|
548
|
-
className
|
|
549
|
-
}) {
|
|
550
|
-
const itemKey = useAccordionItemContext();
|
|
551
|
-
const { getItemTriggerProps, toggle } = useAccordionContext();
|
|
552
|
-
const propGetterReturn = getItemTriggerProps(itemKey);
|
|
553
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
554
|
-
const triggerId = propGetterReturn.accessibility.controls ? String(propGetterReturn.accessibility.controls).replace("panel-", "trigger-") : void 0;
|
|
555
|
-
const handleClick = useCallback(() => {
|
|
556
|
-
propGetterReturn.onAction?.();
|
|
557
|
-
}, [propGetterReturn.onAction]);
|
|
558
|
-
const onKeyDown = useKeyboardHandler(propGetterReturn.keyboardConfig, {
|
|
559
|
-
activate: () => toggle(itemKey)
|
|
560
|
-
});
|
|
561
|
-
return /* @__PURE__ */ jsx(
|
|
562
|
-
"button",
|
|
563
|
-
{
|
|
564
|
-
...ariaProps,
|
|
565
|
-
id: triggerId,
|
|
566
|
-
className: cn("entropix-accordion-trigger", className),
|
|
567
|
-
onClick: handleClick,
|
|
568
|
-
onKeyDown,
|
|
569
|
-
children
|
|
570
|
-
}
|
|
571
|
-
);
|
|
572
|
-
}
|
|
573
|
-
function AccordionPanel({ children, className }) {
|
|
574
|
-
const itemKey = useAccordionItemContext();
|
|
575
|
-
const { getItemPanelProps, isExpanded } = useAccordionContext();
|
|
576
|
-
const propGetterReturn = getItemPanelProps(itemKey);
|
|
577
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
578
|
-
const panelId = propGetterReturn.accessibility.labelledBy ? String(propGetterReturn.accessibility.labelledBy).replace(
|
|
579
|
-
"trigger-",
|
|
580
|
-
"panel-"
|
|
581
|
-
) : void 0;
|
|
582
|
-
if (!isExpanded(itemKey)) return null;
|
|
583
|
-
return /* @__PURE__ */ jsx("div", { ...ariaProps, id: panelId, className: cn("entropix-accordion-panel", className), "data-state": "open", children });
|
|
584
|
-
}
|
|
585
|
-
var MenuContext = createContext(null);
|
|
586
|
-
function useMenuContext() {
|
|
587
|
-
const context = useContext(MenuContext);
|
|
588
|
-
if (!context) {
|
|
589
|
-
throw new Error(
|
|
590
|
-
"Menu compound components must be used within a <Menu> provider."
|
|
591
|
-
);
|
|
592
|
-
}
|
|
593
|
-
return context;
|
|
594
|
-
}
|
|
595
|
-
function Menu({ children, ...options }) {
|
|
596
|
-
const menu = useMenu(options);
|
|
597
|
-
return /* @__PURE__ */ jsx(MenuContext.Provider, { value: menu, children });
|
|
598
|
-
}
|
|
599
|
-
function MenuTrigger({ children, className }) {
|
|
600
|
-
const { getTriggerProps, toggle, open } = useMenuContext();
|
|
601
|
-
const propGetterReturn = getTriggerProps();
|
|
602
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
603
|
-
const handleClick = useCallback(() => {
|
|
604
|
-
propGetterReturn.onAction?.();
|
|
605
|
-
}, [propGetterReturn.onAction]);
|
|
606
|
-
const onKeyDown = useKeyboardHandler(propGetterReturn.keyboardConfig, {
|
|
607
|
-
activate: toggle,
|
|
608
|
-
moveDown: open,
|
|
609
|
-
moveUp: open
|
|
610
|
-
});
|
|
611
|
-
return /* @__PURE__ */ jsx(
|
|
612
|
-
"button",
|
|
613
|
-
{
|
|
614
|
-
...ariaProps,
|
|
615
|
-
className: cn("entropix-menu-trigger", className),
|
|
616
|
-
onClick: handleClick,
|
|
617
|
-
onKeyDown,
|
|
618
|
-
children
|
|
619
|
-
}
|
|
620
|
-
);
|
|
621
|
-
}
|
|
622
|
-
function MenuContent({ children, className }) {
|
|
623
|
-
const { isOpen, getMenuProps, close } = useMenuContext();
|
|
624
|
-
const propGetterReturn = getMenuProps();
|
|
625
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
626
|
-
const onKeyDown = useKeyboardHandler(propGetterReturn.keyboardConfig, {
|
|
627
|
-
dismiss: close
|
|
628
|
-
});
|
|
629
|
-
if (!isOpen) return null;
|
|
630
|
-
return /* @__PURE__ */ jsx(
|
|
631
|
-
"div",
|
|
632
|
-
{
|
|
633
|
-
...ariaProps,
|
|
634
|
-
className: cn("entropix-menu-content", className),
|
|
635
|
-
onKeyDown,
|
|
636
|
-
"data-state": "open",
|
|
637
|
-
children
|
|
638
|
-
}
|
|
639
|
-
);
|
|
640
|
-
}
|
|
641
|
-
function MenuItem({
|
|
642
|
-
index,
|
|
643
|
-
onSelect,
|
|
644
|
-
disabled,
|
|
645
|
-
children,
|
|
646
|
-
className
|
|
647
|
-
}) {
|
|
648
|
-
const { getItemProps, activeIndex } = useMenuContext();
|
|
649
|
-
const propGetterReturn = getItemProps(index, { onSelect, disabled });
|
|
650
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
651
|
-
const handleClick = useCallback(() => {
|
|
652
|
-
propGetterReturn.onAction?.();
|
|
653
|
-
}, [propGetterReturn.onAction]);
|
|
654
|
-
return /* @__PURE__ */ jsx(
|
|
655
|
-
"div",
|
|
656
|
-
{
|
|
657
|
-
...ariaProps,
|
|
658
|
-
className: cn("entropix-menu-item", className),
|
|
659
|
-
onClick: handleClick,
|
|
660
|
-
"data-state": activeIndex === index ? "active" : "inactive",
|
|
661
|
-
"data-disabled": disabled || void 0,
|
|
662
|
-
children
|
|
663
|
-
}
|
|
664
|
-
);
|
|
665
|
-
}
|
|
666
|
-
var Input = forwardRef(function Input2({
|
|
667
|
-
value,
|
|
668
|
-
defaultValue,
|
|
669
|
-
onChange,
|
|
670
|
-
disabled,
|
|
671
|
-
readOnly,
|
|
672
|
-
required,
|
|
673
|
-
invalid,
|
|
674
|
-
label,
|
|
675
|
-
helperText,
|
|
676
|
-
errorMessage,
|
|
677
|
-
variant = "default",
|
|
678
|
-
size = "md",
|
|
679
|
-
className,
|
|
680
|
-
type,
|
|
681
|
-
placeholder,
|
|
682
|
-
name,
|
|
683
|
-
...rest
|
|
684
|
-
}, ref) {
|
|
685
|
-
const isInvalid = invalid || !!errorMessage;
|
|
686
|
-
const {
|
|
687
|
-
value: inputValue,
|
|
688
|
-
isDisabled,
|
|
689
|
-
isReadOnly,
|
|
690
|
-
isRequired,
|
|
691
|
-
isInvalid: _,
|
|
692
|
-
getInputProps,
|
|
693
|
-
getLabelProps,
|
|
694
|
-
getHelperTextProps,
|
|
695
|
-
getErrorMessageProps
|
|
696
|
-
} = useInput({
|
|
697
|
-
value,
|
|
698
|
-
defaultValue,
|
|
699
|
-
onChange,
|
|
700
|
-
disabled,
|
|
701
|
-
readOnly,
|
|
702
|
-
required,
|
|
703
|
-
invalid: isInvalid,
|
|
704
|
-
type,
|
|
705
|
-
placeholder,
|
|
706
|
-
name
|
|
707
|
-
});
|
|
708
|
-
const propGetterReturn = getInputProps();
|
|
709
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
710
|
-
const labelProps = getLabelProps();
|
|
711
|
-
const helperProps = getHelperTextProps();
|
|
712
|
-
const errorProps = getErrorMessageProps();
|
|
713
|
-
const handleChange = useCallback(
|
|
714
|
-
(event) => {
|
|
715
|
-
onChange?.(event.target.value);
|
|
716
|
-
},
|
|
717
|
-
[onChange]
|
|
718
|
-
);
|
|
719
|
-
const dataState = isInvalid ? "invalid" : isDisabled ? "disabled" : void 0;
|
|
720
|
-
return /* @__PURE__ */ jsxs(
|
|
721
|
-
"div",
|
|
722
|
-
{
|
|
723
|
-
className: cn("entropix-input-wrapper", className),
|
|
724
|
-
"data-state": dataState,
|
|
725
|
-
"data-variant": variant,
|
|
726
|
-
"data-size": size,
|
|
727
|
-
children: [
|
|
728
|
-
label && /* @__PURE__ */ jsxs(
|
|
729
|
-
"label",
|
|
730
|
-
{
|
|
731
|
-
className: "entropix-input-label",
|
|
732
|
-
id: labelProps.id,
|
|
733
|
-
htmlFor: labelProps.htmlFor,
|
|
734
|
-
children: [
|
|
735
|
-
label,
|
|
736
|
-
isRequired && /* @__PURE__ */ jsx("span", { className: "entropix-input-required", children: "*" })
|
|
737
|
-
]
|
|
738
|
-
}
|
|
739
|
-
),
|
|
740
|
-
/* @__PURE__ */ jsx(
|
|
741
|
-
"input",
|
|
742
|
-
{
|
|
743
|
-
ref,
|
|
744
|
-
className: "entropix-input",
|
|
745
|
-
...ariaProps,
|
|
746
|
-
...rest,
|
|
747
|
-
type,
|
|
748
|
-
name,
|
|
749
|
-
placeholder,
|
|
750
|
-
value: inputValue,
|
|
751
|
-
onChange: handleChange,
|
|
752
|
-
disabled: isDisabled || void 0,
|
|
753
|
-
readOnly: isReadOnly || void 0,
|
|
754
|
-
"data-state": dataState,
|
|
755
|
-
"data-variant": variant,
|
|
756
|
-
"data-size": size
|
|
757
|
-
}
|
|
758
|
-
),
|
|
759
|
-
isInvalid && errorMessage ? /* @__PURE__ */ jsx("span", { className: "entropix-input-error", ...errorProps, children: errorMessage }) : helperText ? /* @__PURE__ */ jsx("span", { className: "entropix-input-helper", ...helperProps, children: helperText }) : null
|
|
760
|
-
]
|
|
761
|
-
}
|
|
762
|
-
);
|
|
763
|
-
});
|
|
764
|
-
var Textarea = forwardRef(
|
|
765
|
-
function Textarea2({
|
|
766
|
-
value,
|
|
767
|
-
defaultValue,
|
|
768
|
-
onChange,
|
|
769
|
-
disabled,
|
|
770
|
-
readOnly,
|
|
771
|
-
required,
|
|
772
|
-
invalid,
|
|
773
|
-
label,
|
|
774
|
-
helperText,
|
|
775
|
-
errorMessage,
|
|
776
|
-
variant = "default",
|
|
777
|
-
size = "md",
|
|
778
|
-
rows,
|
|
779
|
-
resize = "vertical",
|
|
780
|
-
className,
|
|
781
|
-
placeholder,
|
|
782
|
-
name,
|
|
783
|
-
style,
|
|
784
|
-
...rest
|
|
785
|
-
}, ref) {
|
|
786
|
-
const isInvalid = invalid || !!errorMessage;
|
|
787
|
-
const {
|
|
788
|
-
value: inputValue,
|
|
789
|
-
isDisabled,
|
|
790
|
-
isReadOnly,
|
|
791
|
-
isRequired,
|
|
792
|
-
getInputProps,
|
|
793
|
-
getLabelProps,
|
|
794
|
-
getHelperTextProps,
|
|
795
|
-
getErrorMessageProps
|
|
796
|
-
} = useInput({
|
|
797
|
-
value,
|
|
798
|
-
defaultValue,
|
|
799
|
-
onChange,
|
|
800
|
-
disabled,
|
|
801
|
-
readOnly,
|
|
802
|
-
required,
|
|
803
|
-
invalid: isInvalid,
|
|
804
|
-
placeholder,
|
|
805
|
-
name
|
|
806
|
-
});
|
|
807
|
-
const propGetterReturn = getInputProps();
|
|
808
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
809
|
-
const labelProps = getLabelProps();
|
|
810
|
-
const helperProps = getHelperTextProps();
|
|
811
|
-
const errorProps = getErrorMessageProps();
|
|
812
|
-
const handleChange = useCallback(
|
|
813
|
-
(event) => {
|
|
814
|
-
onChange?.(event.target.value);
|
|
815
|
-
},
|
|
816
|
-
[onChange]
|
|
817
|
-
);
|
|
818
|
-
const dataState = isInvalid ? "invalid" : isDisabled ? "disabled" : void 0;
|
|
819
|
-
return /* @__PURE__ */ jsxs(
|
|
820
|
-
"div",
|
|
821
|
-
{
|
|
822
|
-
className: cn("entropix-input-wrapper", className),
|
|
823
|
-
"data-state": dataState,
|
|
824
|
-
"data-variant": variant,
|
|
825
|
-
"data-size": size,
|
|
826
|
-
children: [
|
|
827
|
-
label && /* @__PURE__ */ jsxs(
|
|
828
|
-
"label",
|
|
829
|
-
{
|
|
830
|
-
className: "entropix-input-label",
|
|
831
|
-
id: labelProps.id,
|
|
832
|
-
htmlFor: labelProps.htmlFor,
|
|
833
|
-
children: [
|
|
834
|
-
label,
|
|
835
|
-
isRequired && /* @__PURE__ */ jsx("span", { className: "entropix-input-required", children: "*" })
|
|
836
|
-
]
|
|
837
|
-
}
|
|
838
|
-
),
|
|
839
|
-
/* @__PURE__ */ jsx(
|
|
840
|
-
"textarea",
|
|
841
|
-
{
|
|
842
|
-
ref,
|
|
843
|
-
className: "entropix-textarea",
|
|
844
|
-
...ariaProps,
|
|
845
|
-
...rest,
|
|
846
|
-
name,
|
|
847
|
-
placeholder,
|
|
848
|
-
value: inputValue,
|
|
849
|
-
onChange: handleChange,
|
|
850
|
-
disabled: isDisabled || void 0,
|
|
851
|
-
readOnly: isReadOnly || void 0,
|
|
852
|
-
rows,
|
|
853
|
-
style: { ...style, resize },
|
|
854
|
-
"data-state": dataState,
|
|
855
|
-
"data-variant": variant,
|
|
856
|
-
"data-size": size
|
|
857
|
-
}
|
|
858
|
-
),
|
|
859
|
-
isInvalid && errorMessage ? /* @__PURE__ */ jsx("span", { className: "entropix-input-error", ...errorProps, children: errorMessage }) : helperText ? /* @__PURE__ */ jsx("span", { className: "entropix-input-helper", ...helperProps, children: helperText }) : null
|
|
860
|
-
]
|
|
861
|
-
}
|
|
862
|
-
);
|
|
863
|
-
}
|
|
864
|
-
);
|
|
865
|
-
var Checkbox = forwardRef(
|
|
866
|
-
function Checkbox2({
|
|
867
|
-
checked,
|
|
868
|
-
defaultChecked,
|
|
869
|
-
onChange,
|
|
870
|
-
disabled,
|
|
871
|
-
label,
|
|
872
|
-
indeterminate = false,
|
|
873
|
-
className,
|
|
874
|
-
style,
|
|
875
|
-
children,
|
|
876
|
-
onClick,
|
|
877
|
-
onKeyDown: externalOnKeyDown,
|
|
878
|
-
...rest
|
|
879
|
-
}, ref) {
|
|
880
|
-
const { isChecked, isDisabled, getToggleProps } = useToggle({
|
|
881
|
-
checked,
|
|
882
|
-
defaultChecked,
|
|
883
|
-
onChange,
|
|
884
|
-
disabled,
|
|
885
|
-
role: "checkbox"
|
|
886
|
-
});
|
|
887
|
-
const propGetterReturn = getToggleProps();
|
|
888
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
889
|
-
if (indeterminate) {
|
|
890
|
-
ariaProps["aria-checked"] = "mixed";
|
|
891
|
-
}
|
|
892
|
-
if (label && !children) {
|
|
893
|
-
ariaProps["aria-label"] = label;
|
|
894
|
-
}
|
|
895
|
-
const actionMap = useMemo(
|
|
896
|
-
() => ({
|
|
897
|
-
toggle: propGetterReturn.onAction ?? (() => {
|
|
898
|
-
})
|
|
899
|
-
}),
|
|
900
|
-
[propGetterReturn.onAction]
|
|
901
|
-
);
|
|
902
|
-
const onKeyDown = useKeyboardHandler(
|
|
903
|
-
propGetterReturn.keyboardConfig,
|
|
904
|
-
actionMap
|
|
905
|
-
);
|
|
906
|
-
const handleClick = useCallback(
|
|
907
|
-
(event) => {
|
|
908
|
-
propGetterReturn.onAction?.();
|
|
909
|
-
onClick?.(event);
|
|
910
|
-
},
|
|
911
|
-
[propGetterReturn.onAction, onClick]
|
|
912
|
-
);
|
|
913
|
-
const handleKeyDown = useCallback(
|
|
914
|
-
(event) => {
|
|
915
|
-
onKeyDown?.(event);
|
|
916
|
-
externalOnKeyDown?.(event);
|
|
917
|
-
},
|
|
918
|
-
[onKeyDown, externalOnKeyDown]
|
|
919
|
-
);
|
|
920
|
-
const dataState = indeterminate ? "indeterminate" : isChecked ? "checked" : "unchecked";
|
|
921
|
-
return /* @__PURE__ */ jsxs(
|
|
922
|
-
"button",
|
|
923
|
-
{
|
|
924
|
-
ref,
|
|
925
|
-
type: "button",
|
|
926
|
-
className: cn("entropix-checkbox", className),
|
|
927
|
-
style,
|
|
928
|
-
...ariaProps,
|
|
929
|
-
...rest,
|
|
930
|
-
disabled: isDisabled || void 0,
|
|
931
|
-
onClick: propGetterReturn.onAction || onClick ? handleClick : void 0,
|
|
932
|
-
onKeyDown: onKeyDown || externalOnKeyDown ? handleKeyDown : void 0,
|
|
933
|
-
"data-state": dataState,
|
|
934
|
-
children: [
|
|
935
|
-
/* @__PURE__ */ jsx("span", { className: "entropix-checkbox__indicator", "data-state": dataState }),
|
|
936
|
-
(label || children) && /* @__PURE__ */ jsx("span", { className: "entropix-checkbox__label", children: label || children })
|
|
937
|
-
]
|
|
938
|
-
}
|
|
939
|
-
);
|
|
940
|
-
}
|
|
941
|
-
);
|
|
942
|
-
var RadioContext = createContext(null);
|
|
943
|
-
function useRadioContext() {
|
|
944
|
-
const context = useContext(RadioContext);
|
|
945
|
-
if (!context) {
|
|
946
|
-
throw new Error(
|
|
947
|
-
"Radio compound components must be used within a <RadioGroup> provider."
|
|
948
|
-
);
|
|
949
|
-
}
|
|
950
|
-
return context;
|
|
951
|
-
}
|
|
952
|
-
function RadioGroup({
|
|
953
|
-
children,
|
|
954
|
-
label,
|
|
955
|
-
className,
|
|
956
|
-
...options
|
|
957
|
-
}) {
|
|
958
|
-
const radioGroup = useRadioGroup(options);
|
|
959
|
-
const propGetterReturn = radioGroup.getRadioGroupProps();
|
|
960
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
961
|
-
if (label) {
|
|
962
|
-
ariaProps["aria-label"] = label;
|
|
963
|
-
}
|
|
964
|
-
return /* @__PURE__ */ jsx(RadioContext.Provider, { value: radioGroup, children: /* @__PURE__ */ jsx(
|
|
965
|
-
"div",
|
|
966
|
-
{
|
|
967
|
-
...ariaProps,
|
|
968
|
-
className: cn("entropix-radio-group", className),
|
|
969
|
-
"data-orientation": options.orientation ?? "vertical",
|
|
970
|
-
children
|
|
971
|
-
}
|
|
972
|
-
) });
|
|
973
|
-
}
|
|
974
|
-
function RadioItem({
|
|
975
|
-
value,
|
|
976
|
-
disabled,
|
|
977
|
-
label,
|
|
978
|
-
children,
|
|
979
|
-
className
|
|
980
|
-
}) {
|
|
981
|
-
const { getRadioProps, selectedValue } = useRadioContext();
|
|
982
|
-
const propGetterReturn = getRadioProps(value, { disabled });
|
|
983
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
984
|
-
const isChecked = value === selectedValue;
|
|
985
|
-
const actionMap = useMemo(
|
|
986
|
-
() => ({}),
|
|
987
|
-
[]
|
|
988
|
-
);
|
|
989
|
-
const onKeyDown = useKeyboardHandler(
|
|
990
|
-
propGetterReturn.keyboardConfig,
|
|
991
|
-
actionMap
|
|
992
|
-
);
|
|
993
|
-
const handleClick = useCallback(() => {
|
|
994
|
-
propGetterReturn.onAction?.();
|
|
995
|
-
}, [propGetterReturn.onAction]);
|
|
996
|
-
return /* @__PURE__ */ jsxs(
|
|
997
|
-
"button",
|
|
998
|
-
{
|
|
999
|
-
type: "button",
|
|
1000
|
-
...ariaProps,
|
|
1001
|
-
className: cn("entropix-radio-item", className),
|
|
1002
|
-
onClick: handleClick,
|
|
1003
|
-
onKeyDown,
|
|
1004
|
-
"data-state": isChecked ? "checked" : "unchecked",
|
|
1005
|
-
"data-disabled": disabled || void 0,
|
|
1006
|
-
children: [
|
|
1007
|
-
/* @__PURE__ */ jsx(
|
|
1008
|
-
"span",
|
|
1009
|
-
{
|
|
1010
|
-
className: "entropix-radio-item__indicator",
|
|
1011
|
-
"data-state": isChecked ? "checked" : "unchecked"
|
|
1012
|
-
}
|
|
1013
|
-
),
|
|
1014
|
-
(label || children) && /* @__PURE__ */ jsx("span", { className: "entropix-radio-item__label", children: label || children })
|
|
1015
|
-
]
|
|
1016
|
-
}
|
|
1017
|
-
);
|
|
1018
|
-
}
|
|
1019
|
-
var SelectContext = createContext(null);
|
|
1020
|
-
function useSelectContext() {
|
|
1021
|
-
const context = useContext(SelectContext);
|
|
1022
|
-
if (!context) {
|
|
1023
|
-
throw new Error(
|
|
1024
|
-
"Select compound components must be used within a <Select> provider."
|
|
1025
|
-
);
|
|
1026
|
-
}
|
|
1027
|
-
return context;
|
|
1028
|
-
}
|
|
1029
|
-
function Select({ children, label, className, ...options }) {
|
|
1030
|
-
const select = useSelect(options);
|
|
1031
|
-
const labelProps = select.getLabelProps();
|
|
1032
|
-
return /* @__PURE__ */ jsx(SelectContext.Provider, { value: select, children: /* @__PURE__ */ jsxs("div", { className: cn("entropix-select", className), children: [
|
|
1033
|
-
label && /* @__PURE__ */ jsx(
|
|
1034
|
-
"label",
|
|
1035
|
-
{
|
|
1036
|
-
className: "entropix-select-label",
|
|
1037
|
-
id: labelProps.id,
|
|
1038
|
-
htmlFor: labelProps.htmlFor,
|
|
1039
|
-
children: label
|
|
1040
|
-
}
|
|
1041
|
-
),
|
|
1042
|
-
children
|
|
1043
|
-
] }) });
|
|
1044
|
-
}
|
|
1045
|
-
function SelectTrigger({
|
|
1046
|
-
placeholder = "Select...",
|
|
1047
|
-
children,
|
|
1048
|
-
className
|
|
1049
|
-
}) {
|
|
1050
|
-
const { getTriggerProps, toggle, open, selectedValue, isDisabled } = useSelectContext();
|
|
1051
|
-
const propGetterReturn = getTriggerProps();
|
|
1052
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
1053
|
-
const handleClick = useCallback(() => {
|
|
1054
|
-
propGetterReturn.onAction?.();
|
|
1055
|
-
}, [propGetterReturn.onAction]);
|
|
1056
|
-
const onKeyDown = useKeyboardHandler(propGetterReturn.keyboardConfig, {
|
|
1057
|
-
activate: toggle,
|
|
1058
|
-
moveDown: open,
|
|
1059
|
-
moveUp: open
|
|
1060
|
-
});
|
|
1061
|
-
return /* @__PURE__ */ jsxs(
|
|
1062
|
-
"button",
|
|
1063
|
-
{
|
|
1064
|
-
type: "button",
|
|
1065
|
-
...ariaProps,
|
|
1066
|
-
className: cn("entropix-select-trigger", className),
|
|
1067
|
-
onClick: handleClick,
|
|
1068
|
-
onKeyDown,
|
|
1069
|
-
disabled: isDisabled || void 0,
|
|
1070
|
-
children: [
|
|
1071
|
-
/* @__PURE__ */ jsx("span", { className: "entropix-select-trigger__value", children: children ?? (selectedValue || placeholder) }),
|
|
1072
|
-
/* @__PURE__ */ jsx("span", { className: "entropix-select-trigger__chevron", "aria-hidden": "true", children: "\u25BE" })
|
|
1073
|
-
]
|
|
1074
|
-
}
|
|
1075
|
-
);
|
|
1076
|
-
}
|
|
1077
|
-
function SelectContent({ children, className }) {
|
|
1078
|
-
const { isOpen, getListboxProps, close } = useSelectContext();
|
|
1079
|
-
const propGetterReturn = getListboxProps();
|
|
1080
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
1081
|
-
const onKeyDown = useKeyboardHandler(propGetterReturn.keyboardConfig, {
|
|
1082
|
-
dismiss: close
|
|
1083
|
-
});
|
|
1084
|
-
if (!isOpen) return null;
|
|
1085
|
-
return /* @__PURE__ */ jsx(
|
|
1086
|
-
"div",
|
|
1087
|
-
{
|
|
1088
|
-
...ariaProps,
|
|
1089
|
-
className: cn("entropix-select-content", className),
|
|
1090
|
-
onKeyDown,
|
|
1091
|
-
"data-state": "open",
|
|
1092
|
-
children
|
|
1093
|
-
}
|
|
1094
|
-
);
|
|
1095
|
-
}
|
|
1096
|
-
function SelectOption({
|
|
1097
|
-
value,
|
|
1098
|
-
index,
|
|
1099
|
-
disabled,
|
|
1100
|
-
children,
|
|
1101
|
-
className
|
|
1102
|
-
}) {
|
|
1103
|
-
const { getOptionProps, selectedValue } = useSelectContext();
|
|
1104
|
-
const propGetterReturn = getOptionProps(value, index ?? 0, { disabled });
|
|
1105
|
-
const ariaProps = mapAccessibilityToAria(propGetterReturn.accessibility);
|
|
1106
|
-
const isSelected = value === selectedValue;
|
|
1107
|
-
const handleClick = useCallback(() => {
|
|
1108
|
-
propGetterReturn.onAction?.();
|
|
1109
|
-
}, [propGetterReturn.onAction]);
|
|
1110
|
-
return /* @__PURE__ */ jsx(
|
|
1111
|
-
"div",
|
|
1112
|
-
{
|
|
1113
|
-
...ariaProps,
|
|
1114
|
-
className: cn("entropix-select-option", className),
|
|
1115
|
-
onClick: handleClick,
|
|
1116
|
-
"data-state": isSelected ? "selected" : "unselected",
|
|
1117
|
-
"data-disabled": disabled || void 0,
|
|
1118
|
-
children
|
|
1119
|
-
}
|
|
1120
|
-
);
|
|
1121
|
-
}
|
|
1122
20
|
var BREAKPOINTS = {
|
|
1123
21
|
sm: 640,
|
|
1124
22
|
md: 768,
|
|
@@ -1166,75 +64,7 @@ function useMediaQuery(query) {
|
|
|
1166
64
|
function useBreakpointValue(breakpoint) {
|
|
1167
65
|
return useMediaQuery(`(min-width: ${BREAKPOINTS[breakpoint]}px)`);
|
|
1168
66
|
}
|
|
1169
|
-
var Stack = forwardRef(function Stack2({ gap, align, fullWidth, as: Component = "div", className, children, ...rest }, ref) {
|
|
1170
|
-
return /* @__PURE__ */ jsx(
|
|
1171
|
-
Component,
|
|
1172
|
-
{
|
|
1173
|
-
ref,
|
|
1174
|
-
className: cn(
|
|
1175
|
-
"entropix-stack",
|
|
1176
|
-
gap && `entropix-stack--gap-${gap}`,
|
|
1177
|
-
align && `entropix-stack--align-${align}`,
|
|
1178
|
-
fullWidth && "entropix-stack--full-width",
|
|
1179
|
-
className
|
|
1180
|
-
),
|
|
1181
|
-
...rest,
|
|
1182
|
-
children
|
|
1183
|
-
}
|
|
1184
|
-
);
|
|
1185
|
-
});
|
|
1186
|
-
var Inline = forwardRef(function Inline2({ gap, align, justify, wrap, as: Component = "div", className, children, ...rest }, ref) {
|
|
1187
|
-
return /* @__PURE__ */ jsx(
|
|
1188
|
-
Component,
|
|
1189
|
-
{
|
|
1190
|
-
ref,
|
|
1191
|
-
className: cn(
|
|
1192
|
-
"entropix-inline",
|
|
1193
|
-
gap && `entropix-inline--gap-${gap}`,
|
|
1194
|
-
align && `entropix-inline--align-${align}`,
|
|
1195
|
-
justify && `entropix-inline--justify-${justify}`,
|
|
1196
|
-
wrap && "entropix-inline--wrap",
|
|
1197
|
-
className
|
|
1198
|
-
),
|
|
1199
|
-
...rest,
|
|
1200
|
-
children
|
|
1201
|
-
}
|
|
1202
|
-
);
|
|
1203
|
-
});
|
|
1204
|
-
var Container = forwardRef(function Container2({ maxWidth = "lg", center, as: Component = "div", className, children, ...rest }, ref) {
|
|
1205
|
-
return /* @__PURE__ */ jsx(
|
|
1206
|
-
Component,
|
|
1207
|
-
{
|
|
1208
|
-
ref,
|
|
1209
|
-
className: cn(
|
|
1210
|
-
"entropix-container",
|
|
1211
|
-
`entropix-container--${maxWidth}`,
|
|
1212
|
-
center && "entropix-container--center",
|
|
1213
|
-
className
|
|
1214
|
-
),
|
|
1215
|
-
...rest,
|
|
1216
|
-
children
|
|
1217
|
-
}
|
|
1218
|
-
);
|
|
1219
|
-
});
|
|
1220
|
-
var Divider = forwardRef(function Divider2({ orientation = "horizontal", spacing, className, ...rest }, ref) {
|
|
1221
|
-
return /* @__PURE__ */ jsx(
|
|
1222
|
-
"hr",
|
|
1223
|
-
{
|
|
1224
|
-
ref,
|
|
1225
|
-
role: orientation === "vertical" ? "separator" : void 0,
|
|
1226
|
-
"aria-orientation": orientation === "vertical" ? "vertical" : void 0,
|
|
1227
|
-
className: cn(
|
|
1228
|
-
"entropix-divider",
|
|
1229
|
-
orientation === "vertical" && "entropix-divider--vertical",
|
|
1230
|
-
spacing && `entropix-divider--spacing-${spacing}`,
|
|
1231
|
-
className
|
|
1232
|
-
),
|
|
1233
|
-
...rest
|
|
1234
|
-
}
|
|
1235
|
-
);
|
|
1236
|
-
});
|
|
1237
67
|
|
|
1238
|
-
export {
|
|
68
|
+
export { BREAKPOINTS, useBreakpoint, useBreakpointValue, useMediaQuery };
|
|
1239
69
|
//# sourceMappingURL=index.js.map
|
|
1240
70
|
//# sourceMappingURL=index.js.map
|