@blockle/blocks 0.8.7 → 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.
- package/dist/index.cjs +77 -736
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +56 -714
- package/dist/momotaro.chunk.d.ts +423 -410
- package/dist/reset.css.d.mts +2 -0
- package/dist/reset.css.d.ts +1 -1
- package/dist/styles/components/display/Divider/Divider.cjs +226 -0
- package/dist/styles/components/display/Divider/Divider.mjs +227 -0
- package/dist/styles/components/{Divider → display/Divider}/divider.css.cjs +2 -2
- package/dist/styles/components/{Divider → display/Divider}/divider.css.mjs +2 -2
- package/dist/styles/components/form/Button/Button.cjs +55 -0
- package/dist/styles/components/{Button → form/Button}/Button.css.cjs +2 -2
- package/dist/styles/components/{Button → form/Button}/Button.css.mjs +2 -2
- package/dist/styles/components/form/Button/Button.mjs +56 -0
- package/dist/styles/components/form/Checkbox/Checkbox.cjs +47 -0
- package/dist/styles/components/form/Checkbox/Checkbox.mjs +48 -0
- package/dist/styles/components/{Checkbox → form/Checkbox}/checkbox.css.cjs +2 -2
- package/dist/styles/components/{Checkbox → form/Checkbox}/checkbox.css.mjs +2 -2
- package/dist/styles/components/form/Input/Input.cjs +27 -0
- package/dist/styles/components/form/Input/Input.mjs +28 -0
- package/dist/styles/components/{Input → form/Input}/input.css.cjs +2 -2
- package/dist/styles/components/{Input → form/Input}/input.css.mjs +2 -2
- package/dist/styles/components/form/Radio/Radio.cjs +23 -0
- package/dist/styles/components/form/Radio/Radio.mjs +24 -0
- package/dist/styles/components/{Radio → form/Radio}/radio.css.cjs +2 -2
- package/dist/styles/components/{Radio → form/Radio}/radio.css.mjs +2 -2
- package/dist/styles/components/form/Switch/Switch.cjs +61 -0
- package/dist/styles/components/form/Switch/Switch.mjs +62 -0
- package/dist/styles/components/{Switch → form/Switch}/switch.css.cjs +2 -2
- package/dist/styles/components/{Switch → form/Switch}/switch.css.mjs +2 -2
- package/dist/styles/components/other/BlocksProvider/BlocksProvider.cjs +20 -0
- package/dist/styles/components/other/BlocksProvider/BlocksProvider.mjs +21 -0
- package/dist/styles/components/overlay/Dialog/Dialog.cjs +245 -0
- package/dist/styles/components/overlay/Dialog/Dialog.mjs +246 -0
- package/dist/styles/components/{Dialog → overlay/Dialog}/dialog.css.cjs +4 -3
- package/dist/styles/components/{Dialog → overlay/Dialog}/dialog.css.mjs +4 -3
- package/dist/styles/components/typography/Heading/Heading.cjs +14 -0
- package/dist/styles/components/typography/Heading/Heading.mjs +15 -0
- package/dist/styles/components/{Heading → typography/Heading}/heading.css.cjs +2 -2
- package/dist/styles/components/{Heading → typography/Heading}/heading.css.mjs +2 -2
- package/dist/styles/components/typography/Text/Text.cjs +9 -0
- package/dist/styles/components/typography/Text/Text.mjs +10 -0
- package/dist/styles/components/{Text → typography/Text}/text.css.cjs +2 -2
- package/dist/styles/components/{Text → typography/Text}/text.css.mjs +2 -2
- package/dist/styles/lib/css/atoms/atoms.cjs +1 -0
- package/dist/styles/lib/css/atoms/atoms.mjs +1 -0
- package/dist/styles/lib/css/atoms/sprinkles.css.cjs +2 -6
- package/dist/styles/lib/css/atoms/sprinkles.css.mjs +2 -6
- package/dist/styles/lib/css/layers/layers.css.cjs +1 -1
- package/dist/styles/lib/css/layers/layers.css.mjs +1 -1
- package/dist/styles/lib/theme/vars.css.cjs +1 -1
- package/dist/styles/lib/theme/vars.css.mjs +1 -1
- package/dist/styles/lib/utils/atom-props.cjs +15 -0
- package/dist/styles/lib/utils/atom-props.mjs +16 -0
- package/dist/styles/themes/momotaro/components/button.css.cjs +1 -1
- package/dist/styles/themes/momotaro/components/button.css.mjs +1 -1
- package/dist/styles/themes/momotaro/components/checkbox.css.cjs +1 -1
- package/dist/styles/themes/momotaro/components/checkbox.css.mjs +1 -1
- package/dist/styles/themes/momotaro/components/dialog.css.cjs +1 -1
- package/dist/styles/themes/momotaro/components/dialog.css.mjs +1 -1
- package/dist/styles/themes/momotaro/components/divider.css.cjs +1 -1
- package/dist/styles/themes/momotaro/components/divider.css.mjs +1 -1
- package/dist/styles/themes/momotaro/components/dropdown.css.cjs +54 -0
- package/dist/styles/themes/momotaro/components/dropdown.css.mjs +55 -0
- package/dist/styles/themes/momotaro/components/helpers.css.cjs +1 -1
- package/dist/styles/themes/momotaro/components/helpers.css.mjs +1 -1
- package/dist/styles/themes/momotaro/components/index.cjs +2 -0
- package/dist/styles/themes/momotaro/components/index.mjs +2 -0
- package/dist/styles/themes/momotaro/components/input.css.cjs +1 -1
- package/dist/styles/themes/momotaro/components/input.css.mjs +1 -1
- package/dist/styles/themes/momotaro/components/label.css.cjs +1 -1
- package/dist/styles/themes/momotaro/components/label.css.mjs +1 -1
- package/dist/styles/themes/momotaro/components/link.css.cjs +1 -1
- package/dist/styles/themes/momotaro/components/link.css.mjs +1 -1
- package/dist/styles/themes/momotaro/components/progress.css.cjs +1 -1
- package/dist/styles/themes/momotaro/components/progress.css.mjs +1 -1
- package/dist/styles/themes/momotaro/components/radio.css.cjs +1 -1
- package/dist/styles/themes/momotaro/components/radio.css.mjs +1 -1
- package/dist/styles/themes/momotaro/components/spinner.css.cjs +1 -1
- package/dist/styles/themes/momotaro/components/spinner.css.mjs +1 -1
- package/dist/styles/themes/momotaro/components/switch.css.cjs +1 -1
- package/dist/styles/themes/momotaro/components/switch.css.mjs +1 -1
- package/dist/styles/themes/momotaro/index.cjs +1 -0
- package/dist/styles/themes/momotaro/index.mjs +1 -0
- package/dist/styles/themes/momotaro/momotaro.css.cjs +1 -1
- package/dist/styles/themes/momotaro/momotaro.css.mjs +1 -1
- package/dist/styles/themes/momotaro/tokens.css.cjs +1 -1
- package/dist/styles/themes/momotaro/tokens.css.mjs +1 -1
- package/dist/themes/momotaro.d.mts +1 -0
- package/package.json +47 -37
package/dist/index.mjs
CHANGED
|
@@ -5,583 +5,58 @@ import { style } from "./styles/lib/css/style/style.mjs";
|
|
|
5
5
|
import { makeComponentTheme } from "./styles/lib/theme/makeComponentTheme.mjs";
|
|
6
6
|
import { makeTheme } from "./styles/lib/theme/makeTheme.mjs";
|
|
7
7
|
import { vars } from "./styles/lib/theme/vars.css.mjs";
|
|
8
|
+
import { useComponentStyles, Box, classnames, createSlottable } from "./styles/components/display/Divider/Divider.mjs";
|
|
9
|
+
import { Divider, Slot, useComponentStyleDefaultProps } from "./styles/components/display/Divider/Divider.mjs";
|
|
8
10
|
import { atoms } from "./styles/lib/css/atoms/sprinkles.css.mjs";
|
|
9
|
-
import { jsx
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
return className || void 0;
|
|
24
|
-
};
|
|
25
|
-
const BlocksProviderContext = createContext(null);
|
|
26
|
-
const BlocksProvider = ({
|
|
27
|
-
children,
|
|
28
|
-
theme,
|
|
29
|
-
className,
|
|
30
|
-
...restProps
|
|
31
|
-
}) => {
|
|
32
|
-
return /* @__PURE__ */ jsx(BlocksProviderContext.Provider, { value: theme, children: /* @__PURE__ */ jsx(
|
|
33
|
-
"div",
|
|
34
|
-
{
|
|
35
|
-
className: classnames(theme.vars, 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 (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__ */ jsx(Component, { ref, ...slotProps, children });
|
|
100
|
-
}
|
|
101
|
-
const childrenArray = Children.toArray(children);
|
|
102
|
-
const slot = childrenArray.find((child) => {
|
|
103
|
-
if (!isValidElement(child)) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
return child.type === Slot;
|
|
107
|
-
});
|
|
108
|
-
if (!slot) {
|
|
109
|
-
const Slot2 = childrenArray[0];
|
|
110
|
-
if (!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 (!isValidElement(Slot2)) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
return cloneElement(
|
|
120
|
-
Slot2,
|
|
121
|
-
{
|
|
122
|
-
...mergeProps(slotProps, Slot2.props),
|
|
123
|
-
ref: composeRefs(ref, Slot2.ref)
|
|
124
|
-
},
|
|
125
|
-
Slot2.props.children
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
if (!isValidElement(slot) || !isValidElement(slot.props.children)) {
|
|
129
|
-
return null;
|
|
130
|
-
}
|
|
131
|
-
const newChildren = childrenArray.map((child) => {
|
|
132
|
-
if (!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 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 forwardRef(Slottable2);
|
|
150
|
-
}
|
|
151
|
-
const Slot = ({ children }) => children;
|
|
152
|
-
const Slottable$2 = createSlottable("div");
|
|
153
|
-
const Box = forwardRef(function Box2({ asChild, className, children, ...restProps }, ref) {
|
|
154
|
-
const [atomsProps, otherProps] = getAtomsAndProps(restProps);
|
|
155
|
-
return /* @__PURE__ */ jsx(
|
|
156
|
-
Slottable$2,
|
|
157
|
-
{
|
|
158
|
-
ref,
|
|
159
|
-
asChild,
|
|
160
|
-
className: classnames(className, atoms(atomsProps)),
|
|
161
|
-
...otherProps,
|
|
162
|
-
children
|
|
163
|
-
}
|
|
164
|
-
);
|
|
165
|
-
});
|
|
166
|
-
const useTheme = () => {
|
|
167
|
-
const theme = 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__ */ jsx(Box, { color, className: classnames(spinnerClassName, className), ...restProps });
|
|
248
|
-
};
|
|
249
|
-
const Slottable$1 = createSlottable("button");
|
|
250
|
-
const Button = 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__ */ jsxs(
|
|
275
|
-
Slottable$1,
|
|
276
|
-
{
|
|
277
|
-
ref,
|
|
278
|
-
asChild,
|
|
279
|
-
disabled: disabled || loading,
|
|
280
|
-
className: classnames(buttonReset, buttonClassName, atoms(atomsProps), className),
|
|
281
|
-
...otherProps,
|
|
282
|
-
children: [
|
|
283
|
-
startSlot && /* @__PURE__ */ jsx("div", { children: startSlot }),
|
|
284
|
-
loading && /* @__PURE__ */ jsx(Spinner, { size }),
|
|
285
|
-
/* @__PURE__ */ jsx(Slot, { children }),
|
|
286
|
-
endSlot && /* @__PURE__ */ jsx("div", { children: endSlot })
|
|
287
|
-
]
|
|
288
|
-
}
|
|
289
|
-
);
|
|
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
|
-
});
|
|
305
|
-
return /* @__PURE__ */ jsx(
|
|
306
|
-
Component,
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
import { forwardRef } from "react";
|
|
13
|
+
import { Button, Spinner } from "./styles/components/form/Button/Button.mjs";
|
|
14
|
+
import { Checkbox, Label } from "./styles/components/form/Checkbox/Checkbox.mjs";
|
|
15
|
+
import { Input } from "./styles/components/form/Input/Input.mjs";
|
|
16
|
+
import { Radio } from "./styles/components/form/Radio/Radio.mjs";
|
|
17
|
+
import { Switch } from "./styles/components/form/Switch/Switch.mjs";
|
|
18
|
+
import { BlocksProvider } from "./styles/components/other/BlocksProvider/BlocksProvider.mjs";
|
|
19
|
+
import { Dialog, Portal, useIsomorphicLayoutEffect, useKeyboard, usePreventBodyScroll } from "./styles/components/overlay/Dialog/Dialog.mjs";
|
|
20
|
+
import { Heading } from "./styles/components/typography/Heading/Heading.mjs";
|
|
21
|
+
import { Text } from "./styles/components/typography/Text/Text.mjs";
|
|
22
|
+
const Progress = forwardRef(function Progress2({ value, max = 100, className, ...restProps }, ref) {
|
|
23
|
+
const containerClassName = useComponentStyles(
|
|
24
|
+
"progress",
|
|
307
25
|
{
|
|
308
|
-
|
|
309
|
-
...restProps,
|
|
310
|
-
children
|
|
311
|
-
}
|
|
312
|
-
);
|
|
313
|
-
};
|
|
314
|
-
const Checkbox = 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$12 = /* @__PURE__ */ jsxs("div", { className: classnames(container, containerClassName, className), children: [
|
|
319
|
-
/* @__PURE__ */ jsx("input", { ref, type: "checkbox", name, className: input, ...restProps }),
|
|
320
|
-
/* @__PURE__ */ jsx("div", { className: classnames(icon, iconClassName) })
|
|
321
|
-
] });
|
|
322
|
-
if (!label) {
|
|
323
|
-
return input$12;
|
|
324
|
-
}
|
|
325
|
-
return /* @__PURE__ */ jsxs("label", { className: labelClassName, children: [
|
|
326
|
-
input$12,
|
|
327
|
-
label && /* @__PURE__ */ 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 = (container2) => {
|
|
332
|
-
const focusable = container2.querySelector(focusableSelectors);
|
|
333
|
-
return focusable || null;
|
|
334
|
-
};
|
|
335
|
-
const focusFirstElement = (container2) => {
|
|
336
|
-
const focusable = getFirstFocusableElement(container2);
|
|
337
|
-
if (focusable) {
|
|
338
|
-
focusable.focus();
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
const useFocusLock = ({ ref, active }) => {
|
|
342
|
-
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" ? useEffect : useLayoutEffect;
|
|
358
|
-
const useKeyboard = (key, callback, { enabled = true, type = "keydown" } = {}) => {
|
|
359
|
-
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 = useRef();
|
|
376
|
-
useEffect(
|
|
377
|
-
() => () => {
|
|
378
|
-
if (layerRef.current) {
|
|
379
|
-
layerRef.current.remove();
|
|
380
|
-
}
|
|
26
|
+
base: true
|
|
381
27
|
},
|
|
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 = useRef(null);
|
|
423
|
-
if (isBrowser && active && !target.current) {
|
|
424
|
-
target.current = document.activeElement;
|
|
425
|
-
}
|
|
426
|
-
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] = useState(open);
|
|
437
|
-
const hide = useCallback(() => {
|
|
438
|
-
setVisible(false);
|
|
439
|
-
}, []);
|
|
440
|
-
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 style2 = window.getComputedStyle(element);
|
|
452
|
-
return style2.transitionDuration !== "0s" || style2.animationDuration !== "0s";
|
|
453
|
-
}
|
|
454
|
-
const Portal = ({ children, container: container2 }) => {
|
|
455
|
-
const context = useTheme();
|
|
456
|
-
return createPortal(
|
|
457
|
-
/* @__PURE__ */ jsx(BlocksProvider, { theme: context, children }),
|
|
458
|
-
container2 || document.body
|
|
28
|
+
false
|
|
459
29
|
);
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
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 = useRef(null);
|
|
486
|
-
const dialogRef = useRef(null);
|
|
487
|
-
const layer = useLayer();
|
|
488
|
-
const [visible, hide] = useVisibilityState(open);
|
|
489
|
-
const [enabled, setEnabled] = useState(true);
|
|
490
|
-
const onBackdropClick = useCallback(
|
|
491
|
-
(event) => {
|
|
492
|
-
if (event.target === event.currentTarget) {
|
|
493
|
-
onRequestClose();
|
|
494
|
-
}
|
|
495
|
-
},
|
|
496
|
-
[onRequestClose]
|
|
30
|
+
const barClassName = useComponentStyles(
|
|
31
|
+
"progress",
|
|
32
|
+
{ bar: true, variants: { indeterminate: value === void 0 } },
|
|
33
|
+
false
|
|
497
34
|
);
|
|
498
|
-
|
|
499
|
-
|
|
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 = useCallback(() => {
|
|
522
|
-
if (!open) {
|
|
523
|
-
hide();
|
|
524
|
-
}
|
|
525
|
-
}, [hide, open]);
|
|
526
|
-
useEffect(() => {
|
|
527
|
-
if (open) {
|
|
528
|
-
return;
|
|
529
|
-
}
|
|
530
|
-
if (!hasAnimationDuration(dialogRef.current)) {
|
|
531
|
-
hide();
|
|
532
|
-
}
|
|
533
|
-
}, [open]);
|
|
534
|
-
if (!visible) {
|
|
535
|
-
return null;
|
|
536
|
-
}
|
|
537
|
-
const dataOpen = typeof window === "undefined" && open ? "" : void 0;
|
|
538
|
-
return /* @__PURE__ */ jsx(Portal, { container: layer(), children: /* @__PURE__ */ jsx(DialogContext.Provider, { value: { setEnabled }, children: /* @__PURE__ */ jsx(
|
|
35
|
+
const progress = value === void 0 ? 0 : value / max * 100;
|
|
36
|
+
return /* @__PURE__ */ jsx(
|
|
539
37
|
Box,
|
|
540
38
|
{
|
|
541
|
-
ref
|
|
542
|
-
className: classnames(
|
|
543
|
-
"
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
39
|
+
ref,
|
|
40
|
+
className: classnames(containerClassName, className),
|
|
41
|
+
overflow: "hidden",
|
|
42
|
+
role: "progressbar",
|
|
43
|
+
"aria-valuenow": value,
|
|
44
|
+
"aria-valuemin": 0,
|
|
45
|
+
"aria-valuemax": max,
|
|
46
|
+
...restProps,
|
|
547
47
|
children: /* @__PURE__ */ jsx(
|
|
548
|
-
|
|
48
|
+
Box,
|
|
549
49
|
{
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
"
|
|
554
|
-
|
|
555
|
-
...restProps,
|
|
556
|
-
children
|
|
50
|
+
className: classnames(barClassName),
|
|
51
|
+
backgroundColor: "currentColor",
|
|
52
|
+
width: "full",
|
|
53
|
+
height: "full",
|
|
54
|
+
style: { transform: value === void 0 ? void 0 : `translateX(-${100 - progress}%)` }
|
|
557
55
|
}
|
|
558
56
|
)
|
|
559
57
|
}
|
|
560
|
-
) }) });
|
|
561
|
-
};
|
|
562
|
-
const Divider = ({ className, color, ...restProps }) => {
|
|
563
|
-
const dividerClass = useComponentStyles("divider", { base: true });
|
|
564
|
-
const dividerDefaults = useComponentStyleDefaultProps("divider");
|
|
565
|
-
return /* @__PURE__ */ jsx(
|
|
566
|
-
Box,
|
|
567
|
-
{
|
|
568
|
-
role: "separator",
|
|
569
|
-
width: "full",
|
|
570
|
-
backgroundColor: color ?? dividerDefaults.color,
|
|
571
|
-
className: classnames(className, dividerClass, divider),
|
|
572
|
-
...restProps
|
|
573
|
-
}
|
|
574
58
|
);
|
|
575
|
-
};
|
|
576
|
-
const Heading = ({
|
|
577
|
-
className,
|
|
578
|
-
level = 1,
|
|
579
|
-
children,
|
|
580
|
-
...restProps
|
|
581
|
-
}) => {
|
|
582
|
-
const Tag = `h${level}`;
|
|
583
|
-
return /* @__PURE__ */ jsx(Box, { asChild: true, className: classnames(heading, className), ...restProps, children: /* @__PURE__ */ jsx(Tag, { children }) });
|
|
584
|
-
};
|
|
59
|
+
});
|
|
585
60
|
const justifyContentMap = {
|
|
586
61
|
left: "flex-start",
|
|
587
62
|
right: "flex-end",
|
|
@@ -619,115 +94,23 @@ const Inline = ({
|
|
|
619
94
|
}
|
|
620
95
|
);
|
|
621
96
|
};
|
|
622
|
-
const Input = forwardRef(function Input2({ className, name, type = "text", startSlot, endSlot, label, placeholder, ...restProps }, ref) {
|
|
623
|
-
const id = useId();
|
|
624
|
-
const containerClassName = useComponentStyles("input", { container: true }, false);
|
|
625
|
-
const inputClassName = useComponentStyles("input", { input: true });
|
|
626
|
-
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", className: classnames(containerClassName, className), children: [
|
|
627
|
-
startSlot,
|
|
628
|
-
/* @__PURE__ */ jsx(Box, { asChild: true, width: "full", overflow: "hidden", children: /* @__PURE__ */ jsx(
|
|
629
|
-
"input",
|
|
630
|
-
{
|
|
631
|
-
id,
|
|
632
|
-
ref,
|
|
633
|
-
name,
|
|
634
|
-
type,
|
|
635
|
-
placeholder: placeholder || label,
|
|
636
|
-
className: classnames(input$1, inputClassName),
|
|
637
|
-
...restProps
|
|
638
|
-
}
|
|
639
|
-
) }),
|
|
640
|
-
endSlot
|
|
641
|
-
] }) });
|
|
642
|
-
});
|
|
643
|
-
const Slottable = createSlottable("a");
|
|
644
|
-
const Link = 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__ */ jsx(
|
|
650
|
-
Slottable,
|
|
651
|
-
{
|
|
652
|
-
asChild,
|
|
653
|
-
ref,
|
|
654
|
-
className: classnames(className, linkClassName),
|
|
655
|
-
...restProps,
|
|
656
|
-
children
|
|
657
|
-
}
|
|
658
|
-
);
|
|
659
|
-
});
|
|
660
|
-
const Progress = 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__ */ 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__ */ 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 = 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 input2 = /* @__PURE__ */ jsxs("div", { className: classnames(container$1, containerClassName, className), children: [
|
|
703
|
-
/* @__PURE__ */ jsx("input", { ref, type: "radio", name, className: input$2, ...restProps }),
|
|
704
|
-
/* @__PURE__ */ jsx("div", { className: classnames(icon$1, iconClassName) })
|
|
705
|
-
] });
|
|
706
|
-
if (!label) {
|
|
707
|
-
return input2;
|
|
708
|
-
}
|
|
709
|
-
return /* @__PURE__ */ jsxs("label", { className: labelClassName, children: [
|
|
710
|
-
input2,
|
|
711
|
-
label && /* @__PURE__ */ jsx(Label, { visualOnly: true, children: label })
|
|
712
|
-
] });
|
|
713
|
-
});
|
|
714
97
|
const Stack = ({
|
|
715
98
|
tag: Tag = "div",
|
|
716
99
|
display = "flex",
|
|
717
100
|
children,
|
|
718
|
-
|
|
101
|
+
spacing,
|
|
719
102
|
alignX,
|
|
720
103
|
...restProps
|
|
721
104
|
}) => {
|
|
722
105
|
if (process.env.NODE_ENV === "development" && restProps.start !== void 0 && Tag !== "ol") {
|
|
723
|
-
console.warn('Stack: start prop is only valid
|
|
106
|
+
console.warn('Stack: "start" prop is only valid with tag="ol"');
|
|
724
107
|
}
|
|
725
108
|
return /* @__PURE__ */ jsx(
|
|
726
109
|
Box,
|
|
727
110
|
{
|
|
728
111
|
asChild: true,
|
|
729
112
|
display,
|
|
730
|
-
gap,
|
|
113
|
+
gap: spacing,
|
|
731
114
|
flexDirection: "column",
|
|
732
115
|
alignItems: alignX ? alignItemsMap[alignX] : void 0,
|
|
733
116
|
...restProps,
|
|
@@ -735,63 +118,22 @@ const Stack = ({
|
|
|
735
118
|
}
|
|
736
119
|
);
|
|
737
120
|
};
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
const
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
}, [checked]);
|
|
747
|
-
const toggle = useCallback(() => {
|
|
748
|
-
setIsChecked((checked2) => {
|
|
749
|
-
const newValue = !checked2;
|
|
750
|
-
if (onChange) {
|
|
751
|
-
onChange(newValue);
|
|
752
|
-
}
|
|
753
|
-
return newValue;
|
|
754
|
-
});
|
|
755
|
-
}, [onChange]);
|
|
756
|
-
const onChangeHandler = useCallback(
|
|
757
|
-
(event) => {
|
|
758
|
-
setIsChecked(event.target.checked);
|
|
759
|
-
if (onChange) {
|
|
760
|
-
onChange(event.target.checked);
|
|
761
|
-
}
|
|
762
|
-
},
|
|
763
|
-
[onChange]
|
|
764
|
-
);
|
|
765
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
766
|
-
"div",
|
|
121
|
+
const Slottable = createSlottable("a");
|
|
122
|
+
const Link = forwardRef(function Link2({ asChild, className, children, variant, underline, ...restProps }, ref) {
|
|
123
|
+
const linkClassName = useComponentStyles("link", {
|
|
124
|
+
base: true,
|
|
125
|
+
variants: { variant, underline }
|
|
126
|
+
});
|
|
127
|
+
return /* @__PURE__ */ jsx(
|
|
128
|
+
Slottable,
|
|
767
129
|
{
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
}
|
|
774
|
-
toggle();
|
|
775
|
-
},
|
|
776
|
-
children: [
|
|
777
|
-
/* @__PURE__ */ jsx(
|
|
778
|
-
"input",
|
|
779
|
-
{
|
|
780
|
-
ref,
|
|
781
|
-
type: "checkbox",
|
|
782
|
-
className: input$3,
|
|
783
|
-
checked: isChecked,
|
|
784
|
-
onChange: onChangeHandler,
|
|
785
|
-
...restProps
|
|
786
|
-
}
|
|
787
|
-
),
|
|
788
|
-
/* @__PURE__ */ jsx("div", { className: sliderClassName, "data-checked": isChecked })
|
|
789
|
-
]
|
|
130
|
+
asChild,
|
|
131
|
+
ref,
|
|
132
|
+
className: classnames(className, linkClassName),
|
|
133
|
+
...restProps,
|
|
134
|
+
children
|
|
790
135
|
}
|
|
791
|
-
)
|
|
792
|
-
});
|
|
793
|
-
const Text = forwardRef(function Text2({ tag: Tag = "span", asChild, children, className, ...restProps }, ref) {
|
|
794
|
-
return /* @__PURE__ */ jsx(Box, { ref, asChild: true, className: classnames(text, className), ...restProps, children: asChild ? children : /* @__PURE__ */ jsx(Tag, { children }) });
|
|
136
|
+
);
|
|
795
137
|
});
|
|
796
138
|
export {
|
|
797
139
|
BlocksProvider,
|