@blockle/blocks 0.8.8 → 0.8.9

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 (90) hide show
  1. package/dist/index.cjs +77 -736
  2. package/dist/index.d.mts +1 -0
  3. package/dist/index.mjs +56 -714
  4. package/dist/momotaro.chunk.d.ts +423 -410
  5. package/dist/reset.css.d.mts +2 -0
  6. package/dist/reset.css.d.ts +1 -1
  7. package/dist/styles/components/display/Divider/Divider.cjs +226 -0
  8. package/dist/styles/components/display/Divider/Divider.mjs +227 -0
  9. package/dist/styles/components/{Divider → display/Divider}/divider.css.cjs +2 -2
  10. package/dist/styles/components/{Divider → display/Divider}/divider.css.mjs +2 -2
  11. package/dist/styles/components/form/Button/Button.cjs +55 -0
  12. package/dist/styles/components/{Button → form/Button}/Button.css.cjs +2 -2
  13. package/dist/styles/components/{Button → form/Button}/Button.css.mjs +2 -2
  14. package/dist/styles/components/form/Button/Button.mjs +56 -0
  15. package/dist/styles/components/form/Checkbox/Checkbox.cjs +47 -0
  16. package/dist/styles/components/form/Checkbox/Checkbox.mjs +48 -0
  17. package/dist/styles/components/{Checkbox → form/Checkbox}/checkbox.css.cjs +2 -2
  18. package/dist/styles/components/{Checkbox → form/Checkbox}/checkbox.css.mjs +2 -2
  19. package/dist/styles/components/form/Input/Input.cjs +27 -0
  20. package/dist/styles/components/form/Input/Input.mjs +28 -0
  21. package/dist/styles/components/{Input → form/Input}/input.css.cjs +2 -2
  22. package/dist/styles/components/{Input → form/Input}/input.css.mjs +2 -2
  23. package/dist/styles/components/form/Radio/Radio.cjs +23 -0
  24. package/dist/styles/components/form/Radio/Radio.mjs +24 -0
  25. package/dist/styles/components/{Radio → form/Radio}/radio.css.cjs +2 -2
  26. package/dist/styles/components/{Radio → form/Radio}/radio.css.mjs +2 -2
  27. package/dist/styles/components/form/Switch/Switch.cjs +61 -0
  28. package/dist/styles/components/form/Switch/Switch.mjs +62 -0
  29. package/dist/styles/components/{Switch → form/Switch}/switch.css.cjs +2 -2
  30. package/dist/styles/components/{Switch → form/Switch}/switch.css.mjs +2 -2
  31. package/dist/styles/components/other/BlocksProvider/BlocksProvider.cjs +20 -0
  32. package/dist/styles/components/other/BlocksProvider/BlocksProvider.mjs +21 -0
  33. package/dist/styles/components/overlay/Dialog/Dialog.cjs +245 -0
  34. package/dist/styles/components/overlay/Dialog/Dialog.mjs +246 -0
  35. package/dist/styles/components/{Dialog → overlay/Dialog}/dialog.css.cjs +2 -2
  36. package/dist/styles/components/{Dialog → overlay/Dialog}/dialog.css.mjs +2 -2
  37. package/dist/styles/components/typography/Heading/Heading.cjs +14 -0
  38. package/dist/styles/components/typography/Heading/Heading.mjs +15 -0
  39. package/dist/styles/components/{Heading → typography/Heading}/heading.css.cjs +2 -2
  40. package/dist/styles/components/{Heading → typography/Heading}/heading.css.mjs +2 -2
  41. package/dist/styles/components/typography/Text/Text.cjs +9 -0
  42. package/dist/styles/components/typography/Text/Text.mjs +10 -0
  43. package/dist/styles/components/{Text → typography/Text}/text.css.cjs +2 -2
  44. package/dist/styles/components/{Text → typography/Text}/text.css.mjs +2 -2
  45. package/dist/styles/lib/css/atoms/atoms.cjs +1 -0
  46. package/dist/styles/lib/css/atoms/atoms.mjs +1 -0
  47. package/dist/styles/lib/css/atoms/sprinkles.css.cjs +2 -6
  48. package/dist/styles/lib/css/atoms/sprinkles.css.mjs +2 -6
  49. package/dist/styles/lib/css/layers/layers.css.cjs +1 -1
  50. package/dist/styles/lib/css/layers/layers.css.mjs +1 -1
  51. package/dist/styles/lib/theme/vars.css.cjs +1 -1
  52. package/dist/styles/lib/theme/vars.css.mjs +1 -1
  53. package/dist/styles/lib/utils/atom-props.cjs +15 -0
  54. package/dist/styles/lib/utils/atom-props.mjs +16 -0
  55. package/dist/styles/themes/momotaro/components/button.css.cjs +1 -1
  56. package/dist/styles/themes/momotaro/components/button.css.mjs +1 -1
  57. package/dist/styles/themes/momotaro/components/checkbox.css.cjs +1 -1
  58. package/dist/styles/themes/momotaro/components/checkbox.css.mjs +1 -1
  59. package/dist/styles/themes/momotaro/components/dialog.css.cjs +1 -1
  60. package/dist/styles/themes/momotaro/components/dialog.css.mjs +1 -1
  61. package/dist/styles/themes/momotaro/components/divider.css.cjs +1 -1
  62. package/dist/styles/themes/momotaro/components/divider.css.mjs +1 -1
  63. package/dist/styles/themes/momotaro/components/dropdown.css.cjs +54 -0
  64. package/dist/styles/themes/momotaro/components/dropdown.css.mjs +55 -0
  65. package/dist/styles/themes/momotaro/components/helpers.css.cjs +1 -1
  66. package/dist/styles/themes/momotaro/components/helpers.css.mjs +1 -1
  67. package/dist/styles/themes/momotaro/components/index.cjs +2 -0
  68. package/dist/styles/themes/momotaro/components/index.mjs +2 -0
  69. package/dist/styles/themes/momotaro/components/input.css.cjs +1 -1
  70. package/dist/styles/themes/momotaro/components/input.css.mjs +1 -1
  71. package/dist/styles/themes/momotaro/components/label.css.cjs +1 -1
  72. package/dist/styles/themes/momotaro/components/label.css.mjs +1 -1
  73. package/dist/styles/themes/momotaro/components/link.css.cjs +1 -1
  74. package/dist/styles/themes/momotaro/components/link.css.mjs +1 -1
  75. package/dist/styles/themes/momotaro/components/progress.css.cjs +1 -1
  76. package/dist/styles/themes/momotaro/components/progress.css.mjs +1 -1
  77. package/dist/styles/themes/momotaro/components/radio.css.cjs +1 -1
  78. package/dist/styles/themes/momotaro/components/radio.css.mjs +1 -1
  79. package/dist/styles/themes/momotaro/components/spinner.css.cjs +1 -1
  80. package/dist/styles/themes/momotaro/components/spinner.css.mjs +1 -1
  81. package/dist/styles/themes/momotaro/components/switch.css.cjs +1 -1
  82. package/dist/styles/themes/momotaro/components/switch.css.mjs +1 -1
  83. package/dist/styles/themes/momotaro/index.cjs +1 -0
  84. package/dist/styles/themes/momotaro/index.mjs +1 -0
  85. package/dist/styles/themes/momotaro/momotaro.css.cjs +1 -1
  86. package/dist/styles/themes/momotaro/momotaro.css.mjs +1 -1
  87. package/dist/styles/themes/momotaro/tokens.css.cjs +1 -1
  88. package/dist/styles/themes/momotaro/tokens.css.mjs +1 -1
  89. package/dist/themes/momotaro.d.mts +1 -0
  90. package/package.json +47 -37
package/dist/index.cjs CHANGED
@@ -5,583 +5,57 @@ const styles_lib_css_style_style_cjs = require("./styles/lib/css/style/style.cjs
5
5
  const styles_lib_theme_makeComponentTheme_cjs = require("./styles/lib/theme/makeComponentTheme.cjs");
6
6
  const styles_lib_theme_makeTheme_cjs = require("./styles/lib/theme/makeTheme.cjs");
7
7
  const styles_lib_theme_vars_css_cjs = require("./styles/lib/theme/vars.css.cjs");
8
+ const styles_components_display_Divider_Divider_cjs = require("./styles/components/display/Divider/Divider.cjs");
8
9
  const styles_lib_css_atoms_sprinkles_css_cjs = require("./styles/lib/css/atoms/sprinkles.css.cjs");
9
10
  const jsxRuntime = require("react/jsx-runtime");
10
11
  const react = require("react");
11
- const styles_components_Button_Button_css_cjs = require("./styles/components/Button/Button.css.cjs");
12
- const styles_components_Checkbox_checkbox_css_cjs = require("./styles/components/Checkbox/checkbox.css.cjs");
13
- const styles_components_Dialog_dialog_css_cjs = require("./styles/components/Dialog/dialog.css.cjs");
14
- const reactDom = require("react-dom");
15
- const styles_components_Divider_divider_css_cjs = require("./styles/components/Divider/divider.css.cjs");
16
- const styles_components_Heading_heading_css_cjs = require("./styles/components/Heading/heading.css.cjs");
17
- const styles_components_Input_input_css_cjs = require("./styles/components/Input/input.css.cjs");
18
- const styles_components_Radio_radio_css_cjs = require("./styles/components/Radio/radio.css.cjs");
19
- const styles_components_Switch_switch_css_cjs = require("./styles/components/Switch/switch.css.cjs");
20
- const styles_components_Text_text_css_cjs = require("./styles/components/Text/text.css.cjs");
21
- const classnames = (...args) => {
22
- const className = args.filter((arg) => arg && typeof arg === "string").join(" ");
23
- return className || void 0;
24
- };
25
- const BlocksProviderContext = react.createContext(null);
26
- const BlocksProvider = ({
27
- children,
28
- theme,
29
- className,
30
- ...restProps
31
- }) => {
32
- return /* @__PURE__ */ jsxRuntime.jsx(BlocksProviderContext.Provider, { value: theme, children: /* @__PURE__ */ jsxRuntime.jsx(
33
- "div",
34
- {
35
- className: classnames(theme.vars, styles_lib_css_atoms_sprinkles_css_cjs.atoms({ fontFamily: "primary" }), className),
36
- ...restProps,
37
- children
38
- }
39
- ) });
40
- };
41
- function getAtomsAndProps(props) {
42
- const atomProps = {};
43
- const otherProps = {};
44
- for (const [name, value] of Object.entries(props)) {
45
- if (styles_lib_css_atoms_sprinkles_css_cjs.atoms.properties.has(name)) {
46
- atomProps[name] = value;
47
- } else {
48
- otherProps[name] = value;
49
- }
50
- }
51
- return [atomProps, otherProps];
52
- }
53
- function setRef(ref, value) {
54
- if (typeof ref === "function") {
55
- ref(value);
56
- } else if (ref !== null && ref !== void 0) {
57
- ref.current = value;
58
- }
59
- }
60
- function composeRefs(...refs) {
61
- return (node) => {
62
- for (const ref of refs) {
63
- setRef(ref, node);
64
- }
65
- };
66
- }
67
- function mergeProps(slotProps, childProps) {
68
- const overrideProps = {};
69
- for (const propName in childProps) {
70
- const slotPropValue = slotProps[propName];
71
- const childPropValue = childProps[propName];
72
- if (childPropValue === void 0) {
73
- continue;
74
- }
75
- if (slotPropValue === void 0) {
76
- overrideProps[propName] = childPropValue;
77
- continue;
78
- }
79
- if (typeof slotPropValue === "function" && typeof childPropValue === "function") {
80
- overrideProps[propName] = (...args) => {
81
- childPropValue(...args);
82
- slotPropValue(...args);
83
- };
84
- } else if (propName === "style") {
85
- overrideProps[propName] = { ...slotPropValue, ...childPropValue };
86
- } else if (propName === "className") {
87
- overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
88
- } else {
89
- overrideProps[propName] = childPropValue;
90
- }
91
- }
92
- return { ...slotProps, ...overrideProps };
93
- }
94
- function createSlottable(defaultElement) {
95
- function Slottable2(props, ref) {
96
- const { asChild, children, ...slotProps } = props;
97
- const Component = defaultElement;
98
- if (!asChild) {
99
- return /* @__PURE__ */ jsxRuntime.jsx(Component, { ref, ...slotProps, children });
100
- }
101
- const childrenArray = react.Children.toArray(children);
102
- const slot = childrenArray.find((child) => {
103
- if (!react.isValidElement(child)) {
104
- return false;
105
- }
106
- return child.type === Slot;
107
- });
108
- if (!slot) {
109
- const Slot2 = childrenArray[0];
110
- if (!react.isValidElement(childrenArray[0])) {
111
- if (process.env.NODE_ENV === "development") {
112
- console.warn("Slottable: First child is not a valid React element");
113
- }
114
- return null;
115
- }
116
- if (!react.isValidElement(Slot2)) {
117
- return null;
118
- }
119
- return react.cloneElement(
120
- Slot2,
121
- {
122
- ...mergeProps(slotProps, Slot2.props),
123
- ref: composeRefs(ref, Slot2.ref)
124
- },
125
- Slot2.props.children
126
- );
127
- }
128
- if (!react.isValidElement(slot) || !react.isValidElement(slot.props.children)) {
129
- return null;
130
- }
131
- const newChildren = childrenArray.map((child) => {
132
- if (!react.isValidElement(child)) {
133
- return child;
134
- }
135
- if (child.type === Slot) {
136
- return slot.props.children.props.children;
137
- }
138
- return child;
139
- });
140
- return react.cloneElement(
141
- slot.props.children,
142
- {
143
- ...mergeProps(slotProps, slot.props),
144
- ref: composeRefs(ref, slot.props.children.ref)
145
- },
146
- newChildren
147
- );
148
- }
149
- return react.forwardRef(Slottable2);
150
- }
151
- const Slot = ({ children }) => children;
152
- const Slottable$2 = createSlottable("div");
153
- const Box = react.forwardRef(function Box2({ asChild, className, children, ...restProps }, ref) {
154
- const [atomsProps, otherProps] = getAtomsAndProps(restProps);
155
- return /* @__PURE__ */ jsxRuntime.jsx(
156
- Slottable$2,
12
+ const styles_components_form_Button_Button_cjs = require("./styles/components/form/Button/Button.cjs");
13
+ const styles_components_form_Checkbox_Checkbox_cjs = require("./styles/components/form/Checkbox/Checkbox.cjs");
14
+ const styles_components_form_Input_Input_cjs = require("./styles/components/form/Input/Input.cjs");
15
+ const styles_components_form_Radio_Radio_cjs = require("./styles/components/form/Radio/Radio.cjs");
16
+ const styles_components_form_Switch_Switch_cjs = require("./styles/components/form/Switch/Switch.cjs");
17
+ const styles_components_other_BlocksProvider_BlocksProvider_cjs = require("./styles/components/other/BlocksProvider/BlocksProvider.cjs");
18
+ const styles_components_overlay_Dialog_Dialog_cjs = require("./styles/components/overlay/Dialog/Dialog.cjs");
19
+ const styles_components_typography_Heading_Heading_cjs = require("./styles/components/typography/Heading/Heading.cjs");
20
+ const styles_components_typography_Text_Text_cjs = require("./styles/components/typography/Text/Text.cjs");
21
+ const Progress = react.forwardRef(function Progress2({ value, max = 100, className, ...restProps }, ref) {
22
+ const containerClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles(
23
+ "progress",
157
24
  {
158
- ref,
159
- asChild,
160
- className: classnames(className, styles_lib_css_atoms_sprinkles_css_cjs.atoms(atomsProps)),
161
- ...otherProps,
162
- children
163
- }
25
+ base: true
26
+ },
27
+ false
164
28
  );
165
- });
166
- const useTheme = () => {
167
- const theme = react.useContext(BlocksProviderContext);
168
- if (!theme) {
169
- throw new Error("useTheme must be used within a BlocksProvider");
170
- }
171
- return theme;
172
- };
173
- function useComponentStyles(name, props, useDefaultVariants = true) {
174
- const { components } = useTheme();
175
- const component = components[name];
176
- if (!component) {
177
- console.warn(`Component ${name} is not defined in the theme`);
178
- return "";
179
- }
180
- const classNames = [];
181
- const variants = props.variants ?? {};
182
- const variantsWithDefaults = { ...variants };
183
- for (const key in props) {
184
- const value = props[key];
185
- if (typeof value === "boolean" && value) {
186
- classNames.push(component[key]);
187
- }
188
- }
189
- if (!component.variants) {
190
- return classNames.join(" ");
191
- }
192
- const { defaultVariants } = component;
193
- if (useDefaultVariants && defaultVariants) {
194
- const keys2 = Object.keys(defaultVariants);
195
- for (const key of keys2) {
196
- if (variantsWithDefaults[key] === void 0 && defaultVariants[key]) {
197
- variantsWithDefaults[key] = defaultVariants[key];
198
- }
199
- }
200
- }
201
- const keys = Object.keys(variantsWithDefaults);
202
- const componentVariants = component.variants;
203
- for (const key of keys) {
204
- const value = variantsWithDefaults[key];
205
- if (value === void 0 || componentVariants[key] === void 0) {
206
- continue;
207
- }
208
- if (typeof value === "boolean") {
209
- if (value && componentVariants[key]) {
210
- classNames.push(componentVariants[key]);
211
- }
212
- continue;
213
- }
214
- const variant = componentVariants[key][value];
215
- if (variant) {
216
- classNames.push(variant);
217
- }
218
- }
219
- const { compoundVariants } = component;
220
- if (compoundVariants) {
221
- for (const compoundVariant of compoundVariants) {
222
- const keys2 = Object.keys(compoundVariant.variants);
223
- const matches = keys2.every((key) => {
224
- const value = variantsWithDefaults[key];
225
- if (value === void 0) {
226
- return false;
227
- }
228
- return value === compoundVariant.variants[key];
229
- });
230
- if (matches) {
231
- classNames.push(compoundVariant.style);
232
- }
233
- }
234
- }
235
- return classNames.join(" ");
236
- }
237
- const useComponentStyleDefaultProps = (name) => {
238
- const { components } = useTheme();
239
- const component = components[name];
240
- if (!component) {
241
- return {};
242
- }
243
- return component.defaultVariants ?? {};
244
- };
245
- const Spinner = ({ className, size, color, ...restProps }) => {
246
- const spinnerClassName = useComponentStyles("spinner", { base: true, variants: { size, color } });
247
- return /* @__PURE__ */ jsxRuntime.jsx(Box, { color, className: classnames(spinnerClassName, className), ...restProps });
248
- };
249
- const Slottable$1 = createSlottable("button");
250
- const Button = react.forwardRef(function Button2({
251
- children,
252
- className,
253
- variant,
254
- intent,
255
- size,
256
- startSlot,
257
- endSlot,
258
- loading,
259
- disabled,
260
- asChild,
261
- ...restProps
262
- }, ref) {
263
- const buttonClassName = useComponentStyles("button", {
264
- base: true,
265
- variants: {
266
- variant,
267
- intent,
268
- size,
269
- disabled,
270
- loading
271
- }
272
- });
273
- const [atomsProps, otherProps] = getAtomsAndProps(restProps);
274
- return /* @__PURE__ */ jsxRuntime.jsxs(
275
- Slottable$1,
276
- {
277
- ref,
278
- asChild,
279
- disabled: disabled || loading,
280
- className: classnames(styles_components_Button_Button_css_cjs.buttonReset, buttonClassName, styles_lib_css_atoms_sprinkles_css_cjs.atoms(atomsProps), className),
281
- ...otherProps,
282
- children: [
283
- startSlot && /* @__PURE__ */ jsxRuntime.jsx("div", { children: startSlot }),
284
- loading && /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size }),
285
- /* @__PURE__ */ jsxRuntime.jsx(Slot, { children }),
286
- endSlot && /* @__PURE__ */ jsxRuntime.jsx("div", { children: endSlot })
287
- ]
288
- }
29
+ const barClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles(
30
+ "progress",
31
+ { bar: true, variants: { indeterminate: value === void 0 } },
32
+ false
289
33
  );
290
- });
291
- const Label = ({
292
- visualOnly,
293
- children,
294
- className,
295
- required,
296
- size,
297
- cursor,
298
- ...restProps
299
- }) => {
300
- const Component = visualOnly ? "span" : "label";
301
- const containerClassName = useComponentStyles("label", {
302
- base: true,
303
- variants: { required, size }
304
- });
34
+ const progress = value === void 0 ? 0 : value / max * 100;
305
35
  return /* @__PURE__ */ jsxRuntime.jsx(
306
- Component,
36
+ styles_components_display_Divider_Divider_cjs.Box,
307
37
  {
308
- className: classnames(containerClassName, className, styles_lib_css_atoms_sprinkles_css_cjs.atoms({ cursor })),
38
+ ref,
39
+ className: styles_components_display_Divider_Divider_cjs.classnames(containerClassName, className),
40
+ overflow: "hidden",
41
+ role: "progressbar",
42
+ "aria-valuenow": value,
43
+ "aria-valuemin": 0,
44
+ "aria-valuemax": max,
309
45
  ...restProps,
310
- children
311
- }
312
- );
313
- };
314
- const Checkbox = react.forwardRef(function Checkbox2({ name, label, required, className, ...restProps }, ref) {
315
- const containerClassName = useComponentStyles("checkbox", { base: true }, false);
316
- const iconClassName = useComponentStyles("checkbox", { icon: true }, false);
317
- const labelClassName = useComponentStyles("checkbox", { label: true }, false);
318
- const input = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classnames(styles_components_Checkbox_checkbox_css_cjs.container, containerClassName, className), children: [
319
- /* @__PURE__ */ jsxRuntime.jsx("input", { ref, type: "checkbox", name, className: styles_components_Checkbox_checkbox_css_cjs.input, ...restProps }),
320
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: classnames(styles_components_Checkbox_checkbox_css_cjs.icon, iconClassName) })
321
- ] });
322
- if (!label) {
323
- return input;
324
- }
325
- return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: labelClassName, children: [
326
- input,
327
- label && /* @__PURE__ */ jsxRuntime.jsx(Label, { visualOnly: true, required, children: label })
328
- ] });
329
- });
330
- const focusableSelectors = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
331
- const getFirstFocusableElement = (container) => {
332
- const focusable = container.querySelector(focusableSelectors);
333
- return focusable || null;
334
- };
335
- const focusFirstElement = (container) => {
336
- const focusable = getFirstFocusableElement(container);
337
- if (focusable) {
338
- focusable.focus();
339
- }
340
- };
341
- const useFocusLock = ({ ref, active }) => {
342
- react.useEffect(() => {
343
- if (!active) {
344
- return;
345
- }
346
- const handleFocus = (event) => {
347
- if (ref.current && event.target instanceof HTMLElement && !ref.current.contains(event.target)) {
348
- focusFirstElement(ref.current);
349
- }
350
- };
351
- document.addEventListener("focusin", handleFocus);
352
- return () => {
353
- document.removeEventListener("focusin", handleFocus);
354
- };
355
- }, [active]);
356
- };
357
- const useIsomorphicLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
358
- const useKeyboard = (key, callback, { enabled = true, type = "keydown" } = {}) => {
359
- react.useEffect(() => {
360
- if (!enabled) {
361
- return;
362
- }
363
- function handleKeyDown(event) {
364
- if (event.key === key) {
365
- callback();
366
- }
367
- }
368
- document.addEventListener(type, handleKeyDown);
369
- return () => {
370
- document.removeEventListener(type, handleKeyDown);
371
- };
372
- }, [callback, enabled, key, type]);
373
- };
374
- const useLayer = () => {
375
- const layerRef = react.useRef();
376
- react.useEffect(
377
- () => () => {
378
- if (layerRef.current) {
379
- layerRef.current.remove();
380
- }
381
- },
382
- []
383
- );
384
- return () => {
385
- if (!layerRef.current) {
386
- const div = document.createElement("div");
387
- div.dataset.layer = "blocks";
388
- layerRef.current = div;
389
- document.body.append(layerRef.current);
390
- }
391
- return layerRef.current;
392
- };
393
- };
394
- const usePreventBodyScroll = (enabled = true) => {
395
- useIsomorphicLayoutEffect(() => {
396
- if (!enabled) {
397
- return;
398
- }
399
- const prevOverflow = document.body.style.getPropertyValue("overflow");
400
- const prevScrollTop = document.documentElement.scrollTop;
401
- if (document.body.scrollHeight > window.innerHeight) {
402
- document.body.style.position = "fixed";
403
- document.body.style.overflow = "hidden";
404
- document.body.style.overflowY = "scroll";
405
- document.body.style.width = "100%";
406
- document.body.style.top = `-${prevScrollTop}px`;
407
- } else {
408
- document.body.style.overflow = "hidden";
409
- }
410
- return () => {
411
- document.body.style.position = "";
412
- document.body.style.overflow = prevOverflow;
413
- document.body.style.overflowY = "";
414
- document.body.style.width = "";
415
- document.body.style.top = "";
416
- document.documentElement.scrollTop = prevScrollTop;
417
- };
418
- }, [enabled]);
419
- };
420
- const isBrowser = typeof window !== "undefined";
421
- const useRestoreFocus = (active) => {
422
- const target = react.useRef(null);
423
- if (isBrowser && active && !target.current) {
424
- target.current = document.activeElement;
425
- }
426
- react.useEffect(() => {
427
- if (target.current && !active && target.current instanceof HTMLElement) {
428
- target.current.focus();
429
- }
430
- if (!active) {
431
- target.current = null;
432
- }
433
- }, [active]);
434
- };
435
- const useVisibilityState = (open) => {
436
- const [visible, setVisible] = react.useState(open);
437
- const hide = react.useCallback(() => {
438
- setVisible(false);
439
- }, []);
440
- react.useEffect(() => {
441
- if (open) {
442
- setVisible(true);
443
- }
444
- }, [open]);
445
- return [visible, hide];
446
- };
447
- function hasAnimationDuration(element) {
448
- if (!element) {
449
- return false;
450
- }
451
- const style = window.getComputedStyle(element);
452
- return style.transitionDuration !== "0s" || style.animationDuration !== "0s";
453
- }
454
- const Portal = ({ children, container }) => {
455
- const context = useTheme();
456
- return reactDom.createPortal(
457
- /* @__PURE__ */ jsxRuntime.jsx(BlocksProvider, { theme: context, children }),
458
- container || document.body
459
- );
460
- };
461
- const DialogContext = react.createContext(void 0);
462
- const useNestedDialog = (open) => {
463
- const parentDialog = react.useContext(DialogContext);
464
- react.useEffect(() => {
465
- if (!parentDialog || !open) {
466
- return;
467
- }
468
- parentDialog.setEnabled(false);
469
- return () => {
470
- parentDialog.setEnabled(true);
471
- };
472
- }, [parentDialog, open]);
473
- return !!parentDialog;
474
- };
475
- const Dialog = ({
476
- children,
477
- open,
478
- className,
479
- onRequestClose,
480
- size,
481
- ...restProps
482
- }) => {
483
- const backdropClassName = useComponentStyles("dialog", { backdrop: true }, false);
484
- const dialogClassName = useComponentStyles("dialog", { dialog: true, variants: { size } });
485
- const backdropRef = react.useRef(null);
486
- const dialogRef = react.useRef(null);
487
- const layer = useLayer();
488
- const [visible, hide] = useVisibilityState(open);
489
- const [enabled, setEnabled] = react.useState(true);
490
- const onBackdropClick = react.useCallback(
491
- (event) => {
492
- if (event.target === event.currentTarget) {
493
- onRequestClose();
494
- }
495
- },
496
- [onRequestClose]
497
- );
498
- useFocusLock({ ref: dialogRef, active: open && enabled });
499
- useRestoreFocus(open);
500
- const isNested = useNestedDialog(visible);
501
- usePreventBodyScroll(visible && !isNested);
502
- useKeyboard("Escape", onRequestClose, { enabled: open && enabled });
503
- useIsomorphicLayoutEffect(() => {
504
- var _a, _b;
505
- if (!open) {
506
- (_a = backdropRef.current) == null ? void 0 : _a.removeAttribute("data-open");
507
- (_b = dialogRef.current) == null ? void 0 : _b.removeAttribute("data-open");
508
- return;
509
- }
510
- let timer = requestAnimationFrame(() => {
511
- timer = requestAnimationFrame(() => {
512
- var _a2, _b2;
513
- (_a2 = backdropRef.current) == null ? void 0 : _a2.setAttribute("data-open", "");
514
- (_b2 = dialogRef.current) == null ? void 0 : _b2.setAttribute("data-open", "");
515
- });
516
- });
517
- return () => {
518
- cancelAnimationFrame(timer);
519
- };
520
- }, [open, visible]);
521
- const onAnimationEnd = react.useCallback(() => {
522
- if (!open) {
523
- hide();
524
- }
525
- }, [hide, open]);
526
- react.useEffect(() => {
527
- if (open) {
528
- return;
529
- }
530
- if (!hasAnimationDuration(dialogRef.current)) {
531
- hide();
532
- }
533
- }, [hide, open]);
534
- if (!visible) {
535
- return null;
536
- }
537
- const dataOpen = typeof window === "undefined" && open ? "" : void 0;
538
- return /* @__PURE__ */ jsxRuntime.jsx(Portal, { container: layer(), children: /* @__PURE__ */ jsxRuntime.jsx(DialogContext.Provider, { value: { setEnabled }, children: /* @__PURE__ */ jsxRuntime.jsx(
539
- Box,
540
- {
541
- ref: backdropRef,
542
- className: classnames(styles_components_Dialog_dialog_css_cjs.backdrop, backdropClassName),
543
- "data-open": dataOpen,
544
- onClick: onBackdropClick,
545
- onAnimationEnd,
546
- onTransitionEnd: onAnimationEnd,
547
46
  children: /* @__PURE__ */ jsxRuntime.jsx(
548
- "dialog",
47
+ styles_components_display_Divider_Divider_cjs.Box,
549
48
  {
550
- ref: dialogRef,
551
- "aria-modal": "true",
552
- open: true,
553
- "data-open": dataOpen,
554
- className: classnames(dialogClassName, className),
555
- ...restProps,
556
- children
49
+ className: styles_components_display_Divider_Divider_cjs.classnames(barClassName),
50
+ backgroundColor: "currentColor",
51
+ width: "full",
52
+ height: "full",
53
+ style: { transform: value === void 0 ? void 0 : `translateX(-${100 - progress}%)` }
557
54
  }
558
55
  )
559
56
  }
560
- ) }) });
561
- };
562
- const Divider = ({ className, color, ...restProps }) => {
563
- const dividerClass = useComponentStyles("divider", { base: true });
564
- const dividerDefaults = useComponentStyleDefaultProps("divider");
565
- return /* @__PURE__ */ jsxRuntime.jsx(
566
- Box,
567
- {
568
- role: "separator",
569
- width: "full",
570
- backgroundColor: color ?? dividerDefaults.color,
571
- className: classnames(className, dividerClass, styles_components_Divider_divider_css_cjs.divider),
572
- ...restProps
573
- }
574
57
  );
575
- };
576
- const Heading = ({
577
- className,
578
- level = 1,
579
- children,
580
- ...restProps
581
- }) => {
582
- const Tag = `h${level}`;
583
- return /* @__PURE__ */ jsxRuntime.jsx(Box, { asChild: true, className: classnames(styles_components_Heading_heading_css_cjs.heading, className), ...restProps, children: /* @__PURE__ */ jsxRuntime.jsx(Tag, { children }) });
584
- };
58
+ });
585
59
  const justifyContentMap = {
586
60
  left: "flex-start",
587
61
  right: "flex-end",
@@ -605,7 +79,7 @@ const Inline = ({
605
79
  ...props
606
80
  }) => {
607
81
  return /* @__PURE__ */ jsxRuntime.jsx(
608
- Box,
82
+ styles_components_display_Divider_Divider_cjs.Box,
609
83
  {
610
84
  asChild: true,
611
85
  display,
@@ -619,115 +93,23 @@ const Inline = ({
619
93
  }
620
94
  );
621
95
  };
622
- const Input = react.forwardRef(function Input2({ className, name, type = "text", startSlot, endSlot, label, placeholder, ...restProps }, ref) {
623
- const id = react.useId();
624
- const containerClassName = useComponentStyles("input", { container: true }, false);
625
- const inputClassName = useComponentStyles("input", { input: true });
626
- return /* @__PURE__ */ jsxRuntime.jsx(Box, { children: /* @__PURE__ */ jsxRuntime.jsxs(Box, { display: "flex", alignItems: "center", className: classnames(containerClassName, className), children: [
627
- startSlot,
628
- /* @__PURE__ */ jsxRuntime.jsx(Box, { asChild: true, width: "full", overflow: "hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
629
- "input",
630
- {
631
- id,
632
- ref,
633
- name,
634
- type,
635
- placeholder: placeholder || label,
636
- className: classnames(styles_components_Input_input_css_cjs.input, inputClassName),
637
- ...restProps
638
- }
639
- ) }),
640
- endSlot
641
- ] }) });
642
- });
643
- const Slottable = createSlottable("a");
644
- const Link = react.forwardRef(function Link2({ asChild, className, children, variant, underline, ...restProps }, ref) {
645
- const linkClassName = useComponentStyles("link", {
646
- base: true,
647
- variants: { variant, underline }
648
- });
649
- return /* @__PURE__ */ jsxRuntime.jsx(
650
- Slottable,
651
- {
652
- asChild,
653
- ref,
654
- className: classnames(className, linkClassName),
655
- ...restProps,
656
- children
657
- }
658
- );
659
- });
660
- const Progress = react.forwardRef(function Progress2({ value, max = 100, className, ...restProps }, ref) {
661
- const containerClassName = useComponentStyles(
662
- "progress",
663
- {
664
- base: true
665
- },
666
- false
667
- );
668
- const barClassName = useComponentStyles(
669
- "progress",
670
- { bar: true, variants: { indeterminate: value === void 0 } },
671
- false
672
- );
673
- const progress = value === void 0 ? 0 : value / max * 100;
674
- return /* @__PURE__ */ jsxRuntime.jsx(
675
- Box,
676
- {
677
- ref,
678
- className: classnames(containerClassName, className),
679
- overflow: "hidden",
680
- role: "progressbar",
681
- "aria-valuenow": value,
682
- "aria-valuemin": 0,
683
- "aria-valuemax": max,
684
- ...restProps,
685
- children: /* @__PURE__ */ jsxRuntime.jsx(
686
- Box,
687
- {
688
- className: classnames(barClassName),
689
- backgroundColor: "currentColor",
690
- width: "full",
691
- height: "full",
692
- style: { transform: value === void 0 ? void 0 : `translateX(-${100 - progress}%)` }
693
- }
694
- )
695
- }
696
- );
697
- });
698
- const Radio = react.forwardRef(function Checkbox3({ name, label, className, ...restProps }, ref) {
699
- const containerClassName = useComponentStyles("radio", { base: true }, false);
700
- const iconClassName = useComponentStyles("radio", { icon: true }, false);
701
- const labelClassName = useComponentStyles("checkbox", { label: true }, false);
702
- const input = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classnames(styles_components_Radio_radio_css_cjs.container, containerClassName, className), children: [
703
- /* @__PURE__ */ jsxRuntime.jsx("input", { ref, type: "radio", name, className: styles_components_Radio_radio_css_cjs.input, ...restProps }),
704
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: classnames(styles_components_Radio_radio_css_cjs.icon, iconClassName) })
705
- ] });
706
- if (!label) {
707
- return input;
708
- }
709
- return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: labelClassName, children: [
710
- input,
711
- label && /* @__PURE__ */ jsxRuntime.jsx(Label, { visualOnly: true, children: label })
712
- ] });
713
- });
714
96
  const Stack = ({
715
97
  tag: Tag = "div",
716
98
  display = "flex",
717
99
  children,
718
- gap,
100
+ spacing,
719
101
  alignX,
720
102
  ...restProps
721
103
  }) => {
722
104
  if (process.env.NODE_ENV === "development" && restProps.start !== void 0 && Tag !== "ol") {
723
- console.warn('Stack: start prop is only valid when tag="ol"');
105
+ console.warn('Stack: "start" prop is only valid with tag="ol"');
724
106
  }
725
107
  return /* @__PURE__ */ jsxRuntime.jsx(
726
- Box,
108
+ styles_components_display_Divider_Divider_cjs.Box,
727
109
  {
728
110
  asChild: true,
729
111
  display,
730
- gap,
112
+ gap: spacing,
731
113
  flexDirection: "column",
732
114
  alignItems: alignX ? alignItemsMap[alignX] : void 0,
733
115
  ...restProps,
@@ -735,93 +117,52 @@ const Stack = ({
735
117
  }
736
118
  );
737
119
  };
738
- const Switch = react.forwardRef(function Switch2({ className, checked, onChange, defaultChecked, ...restProps }, ref) {
739
- const [isChecked, setIsChecked] = react.useState(defaultChecked || checked || false);
740
- const baseClassName = useComponentStyles("switch", { base: true });
741
- const sliderClassName = useComponentStyles("switch", { slider: true });
742
- react.useEffect(() => {
743
- if (checked !== void 0) {
744
- setIsChecked(checked);
745
- }
746
- }, [checked]);
747
- const toggle = react.useCallback(() => {
748
- setIsChecked((checked2) => {
749
- const newValue = !checked2;
750
- if (onChange) {
751
- onChange(newValue);
752
- }
753
- return newValue;
754
- });
755
- }, [onChange]);
756
- const onChangeHandler = react.useCallback(
757
- (event) => {
758
- setIsChecked(event.target.checked);
759
- if (onChange) {
760
- onChange(event.target.checked);
761
- }
762
- },
763
- [onChange]
764
- );
765
- return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(
766
- "div",
120
+ const Slottable = styles_components_display_Divider_Divider_cjs.createSlottable("a");
121
+ const Link = react.forwardRef(function Link2({ asChild, className, children, variant, underline, ...restProps }, ref) {
122
+ const linkClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("link", {
123
+ base: true,
124
+ variants: { variant, underline }
125
+ });
126
+ return /* @__PURE__ */ jsxRuntime.jsx(
127
+ Slottable,
767
128
  {
768
- className: classnames(className, styles_components_Switch_switch_css_cjs.container, baseClassName),
769
- "data-checked": isChecked,
770
- onClick: (event) => {
771
- if (event.target.tagName === "INPUT") {
772
- return;
773
- }
774
- toggle();
775
- },
776
- children: [
777
- /* @__PURE__ */ jsxRuntime.jsx(
778
- "input",
779
- {
780
- ref,
781
- type: "checkbox",
782
- className: styles_components_Switch_switch_css_cjs.input,
783
- checked: isChecked,
784
- onChange: onChangeHandler,
785
- ...restProps
786
- }
787
- ),
788
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: sliderClassName, "data-checked": isChecked })
789
- ]
129
+ asChild,
130
+ ref,
131
+ className: styles_components_display_Divider_Divider_cjs.classnames(className, linkClassName),
132
+ ...restProps,
133
+ children
790
134
  }
791
- ) });
792
- });
793
- const Text = react.forwardRef(function Text2({ tag: Tag = "span", asChild, children, className, ...restProps }, ref) {
794
- return /* @__PURE__ */ jsxRuntime.jsx(Box, { ref, asChild: true, className: classnames(styles_components_Text_text_css_cjs.text, className), ...restProps, children: asChild ? children : /* @__PURE__ */ jsxRuntime.jsx(Tag, { children }) });
135
+ );
795
136
  });
796
137
  exports.breakpointQuery = styles_lib_css_atoms_breakpoints_cjs.breakpointQuery;
797
138
  exports.style = styles_lib_css_style_style_cjs.style;
798
139
  exports.makeComponentTheme = styles_lib_theme_makeComponentTheme_cjs.makeComponentTheme;
799
140
  exports.makeTheme = styles_lib_theme_makeTheme_cjs.makeTheme;
800
141
  exports.vars = styles_lib_theme_vars_css_cjs.vars;
142
+ exports.Box = styles_components_display_Divider_Divider_cjs.Box;
143
+ exports.Divider = styles_components_display_Divider_Divider_cjs.Divider;
144
+ exports.Slot = styles_components_display_Divider_Divider_cjs.Slot;
145
+ exports.classnames = styles_components_display_Divider_Divider_cjs.classnames;
146
+ exports.createSlottable = styles_components_display_Divider_Divider_cjs.createSlottable;
147
+ exports.useComponentStyleDefaultProps = styles_components_display_Divider_Divider_cjs.useComponentStyleDefaultProps;
148
+ exports.useComponentStyles = styles_components_display_Divider_Divider_cjs.useComponentStyles;
801
149
  exports.atoms = styles_lib_css_atoms_sprinkles_css_cjs.atoms;
802
- exports.BlocksProvider = BlocksProvider;
803
- exports.Box = Box;
804
- exports.Button = Button;
805
- exports.Checkbox = Checkbox;
806
- exports.Dialog = Dialog;
807
- exports.Divider = Divider;
808
- exports.Heading = Heading;
150
+ exports.Button = styles_components_form_Button_Button_cjs.Button;
151
+ exports.Spinner = styles_components_form_Button_Button_cjs.Spinner;
152
+ exports.Checkbox = styles_components_form_Checkbox_Checkbox_cjs.Checkbox;
153
+ exports.Label = styles_components_form_Checkbox_Checkbox_cjs.Label;
154
+ exports.Input = styles_components_form_Input_Input_cjs.Input;
155
+ exports.Radio = styles_components_form_Radio_Radio_cjs.Radio;
156
+ exports.Switch = styles_components_form_Switch_Switch_cjs.Switch;
157
+ exports.BlocksProvider = styles_components_other_BlocksProvider_BlocksProvider_cjs.BlocksProvider;
158
+ exports.Dialog = styles_components_overlay_Dialog_Dialog_cjs.Dialog;
159
+ exports.Portal = styles_components_overlay_Dialog_Dialog_cjs.Portal;
160
+ exports.useIsomorphicLayoutEffect = styles_components_overlay_Dialog_Dialog_cjs.useIsomorphicLayoutEffect;
161
+ exports.useKeyboard = styles_components_overlay_Dialog_Dialog_cjs.useKeyboard;
162
+ exports.usePreventBodyScroll = styles_components_overlay_Dialog_Dialog_cjs.usePreventBodyScroll;
163
+ exports.Heading = styles_components_typography_Heading_Heading_cjs.Heading;
164
+ exports.Text = styles_components_typography_Text_Text_cjs.Text;
809
165
  exports.Inline = Inline;
810
- exports.Input = Input;
811
- exports.Label = Label;
812
166
  exports.Link = Link;
813
- exports.Portal = Portal;
814
167
  exports.Progress = Progress;
815
- exports.Radio = Radio;
816
- exports.Slot = Slot;
817
- exports.Spinner = Spinner;
818
168
  exports.Stack = Stack;
819
- exports.Switch = Switch;
820
- exports.Text = Text;
821
- exports.classnames = classnames;
822
- exports.createSlottable = createSlottable;
823
- exports.useComponentStyleDefaultProps = useComponentStyleDefaultProps;
824
- exports.useComponentStyles = useComponentStyles;
825
- exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
826
- exports.useKeyboard = useKeyboard;
827
- exports.usePreventBodyScroll = usePreventBodyScroll;