@blockle/blocks 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +93 -41
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +91 -39
- package/dist/momotaro.chunk.d.ts +292 -232
- package/dist/styles/components/Input/input.css.cjs +14 -0
- package/dist/styles/components/Input/input.css.mjs +15 -0
- package/dist/styles/lib/css/atoms/atomicProperties.cjs +19 -17
- package/dist/styles/lib/css/atoms/atomicProperties.mjs +3 -1
- package/dist/styles/lib/theme/makeComponentTheme.cjs +5 -0
- package/dist/styles/lib/theme/makeComponentTheme.mjs +6 -0
- package/dist/styles/lib/theme/makeTheme.cjs +12 -0
- package/dist/styles/lib/{css/theme → theme}/makeTheme.mjs +3 -2
- package/dist/styles/lib/theme/vars.css.cjs +9 -0
- package/dist/styles/lib/{css/theme → theme}/vars.css.mjs +1 -1
- package/dist/styles/themes/momotaro/components/button.css.cjs +35 -26
- package/dist/styles/themes/momotaro/components/button.css.mjs +28 -19
- package/dist/styles/themes/momotaro/components/dialog.css.cjs +25 -6
- package/dist/styles/themes/momotaro/components/dialog.css.mjs +24 -5
- package/dist/styles/themes/momotaro/components/divider.css.cjs +2 -2
- package/dist/styles/themes/momotaro/components/divider.css.mjs +1 -1
- package/dist/styles/themes/momotaro/components/helpers.css.cjs +8 -6
- package/dist/styles/themes/momotaro/components/helpers.css.mjs +6 -4
- package/dist/styles/themes/momotaro/components/index.cjs +5 -3
- package/dist/styles/themes/momotaro/components/index.mjs +5 -3
- package/dist/styles/themes/momotaro/components/input.css.cjs +40 -0
- package/dist/styles/themes/momotaro/components/input.css.mjs +41 -0
- package/dist/styles/themes/momotaro/components/link.css.cjs +6 -6
- package/dist/styles/themes/momotaro/components/link.css.mjs +5 -5
- package/dist/styles/themes/momotaro/components/spinner.css.cjs +2 -2
- package/dist/styles/themes/momotaro/components/spinner.css.mjs +1 -1
- package/dist/styles/themes/momotaro/momotaro.css.cjs +2 -2
- package/dist/styles/themes/momotaro/momotaro.css.mjs +1 -1
- package/dist/styles/themes/momotaro/tokens.css.cjs +4 -4
- package/dist/styles/themes/momotaro/tokens.css.mjs +4 -4
- package/package.json +1 -1
- package/dist/styles/lib/css/theme/makeComponentTheme.cjs +0 -3
- package/dist/styles/lib/css/theme/makeComponentTheme.mjs +0 -4
- package/dist/styles/lib/css/theme/makeTheme.cjs +0 -11
- package/dist/styles/lib/css/theme/vars.css.cjs +0 -9
- /package/dist/styles/lib/{css/theme → theme}/makeVanillaTheme.cjs +0 -0
- /package/dist/styles/lib/{css/theme → theme}/makeVanillaTheme.mjs +0 -0
- /package/dist/styles/lib/{css/theme → theme}/tokens.cjs +0 -0
- /package/dist/styles/lib/{css/theme → theme}/tokens.mjs +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const styles_lib_css_atoms_breakpoints_cjs = require("./styles/lib/css/atoms/breakpoints.cjs");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const styles_lib_theme_makeComponentTheme_cjs = require("./styles/lib/theme/makeComponentTheme.cjs");
|
|
5
|
+
const styles_lib_theme_makeTheme_cjs = require("./styles/lib/theme/makeTheme.cjs");
|
|
6
|
+
const styles_lib_theme_vars_css_cjs = require("./styles/lib/theme/vars.css.cjs");
|
|
7
7
|
const styles_lib_css_atoms_sprinkles_css_cjs = require("./styles/lib/css/atoms/sprinkles.css.cjs");
|
|
8
8
|
const react = require("react");
|
|
9
9
|
const jsxRuntime = require("react/jsx-runtime");
|
|
@@ -11,13 +11,26 @@ const styles_components_Button_Button_css_cjs = require("./styles/components/But
|
|
|
11
11
|
const styles_components_Divider_divider_css_cjs = require("./styles/components/Divider/divider.css.cjs");
|
|
12
12
|
const styles_components_Dialog_dialog_css_cjs = require("./styles/components/Dialog/dialog.css.cjs");
|
|
13
13
|
const reactDom = require("react-dom");
|
|
14
|
+
const styles_components_Input_input_css_cjs = require("./styles/components/Input/input.css.cjs");
|
|
14
15
|
const classnames = (...args) => {
|
|
15
16
|
const className = args.filter((arg) => arg && typeof arg === "string").join(" ");
|
|
16
17
|
return className || void 0;
|
|
17
18
|
};
|
|
18
19
|
const BlocksProviderContext = react.createContext(null);
|
|
19
|
-
const BlocksProvider = ({
|
|
20
|
-
|
|
20
|
+
const BlocksProvider = ({
|
|
21
|
+
children,
|
|
22
|
+
theme,
|
|
23
|
+
className,
|
|
24
|
+
...restProps
|
|
25
|
+
}) => {
|
|
26
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BlocksProviderContext.Provider, { value: theme, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
className: classnames(theme.vars, styles_lib_css_atoms_sprinkles_css_cjs.atoms({ fontFamily: "primary" }), className),
|
|
30
|
+
...restProps,
|
|
31
|
+
children
|
|
32
|
+
}
|
|
33
|
+
) });
|
|
21
34
|
};
|
|
22
35
|
const defaultElement$1 = "div";
|
|
23
36
|
const Box = react.forwardRef(function Box2({ className, as, ...restProps }, ref) {
|
|
@@ -40,41 +53,41 @@ const useTheme = () => {
|
|
|
40
53
|
}
|
|
41
54
|
return theme;
|
|
42
55
|
};
|
|
43
|
-
|
|
44
|
-
function useComponentStyles(name, props) {
|
|
56
|
+
function useComponentStyles(name, props, useDefaultVariants = true) {
|
|
45
57
|
const { components } = useTheme();
|
|
46
58
|
const component = components[name];
|
|
47
59
|
if (!component) {
|
|
48
|
-
console.
|
|
60
|
+
console.warn(`Component ${name} is not defined in the theme`);
|
|
49
61
|
return "";
|
|
50
62
|
}
|
|
51
63
|
const classNames = [];
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
64
|
+
const variants = props.variants ?? {};
|
|
65
|
+
const variantsWithDefaults = { ...variants };
|
|
66
|
+
for (const key in props) {
|
|
67
|
+
const value = props[key];
|
|
68
|
+
if (typeof value === "boolean" && value) {
|
|
69
|
+
classNames.push(component[key]);
|
|
59
70
|
}
|
|
60
71
|
}
|
|
61
|
-
if (propsWithDefaults.base && component.base) {
|
|
62
|
-
classNames.push(component.base);
|
|
63
|
-
}
|
|
64
72
|
if (!component.variants) {
|
|
65
73
|
return classNames.join(" ");
|
|
66
74
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
if (useDefaultVariants && component.defaultVariants) {
|
|
76
|
+
const keys2 = Object.keys(component.defaultVariants);
|
|
77
|
+
for (const key of keys2) {
|
|
78
|
+
if (variantsWithDefaults[key] === void 0) {
|
|
79
|
+
variantsWithDefaults[key] = component.defaultVariants[key];
|
|
80
|
+
}
|
|
72
81
|
}
|
|
73
|
-
|
|
82
|
+
}
|
|
83
|
+
const keys = Object.keys(variantsWithDefaults);
|
|
84
|
+
for (const key of keys) {
|
|
85
|
+
const value = variantsWithDefaults[key];
|
|
86
|
+
if (value === void 0) {
|
|
74
87
|
continue;
|
|
75
88
|
}
|
|
76
89
|
if (typeof value === "boolean") {
|
|
77
|
-
if (value) {
|
|
90
|
+
if (value && component.variants[key]) {
|
|
78
91
|
classNames.push(component.variants[key]);
|
|
79
92
|
}
|
|
80
93
|
continue;
|
|
@@ -88,7 +101,7 @@ function useComponentStyles(name, props) {
|
|
|
88
101
|
for (const compoundVariant of component.compoundVariants) {
|
|
89
102
|
const keys2 = Object.keys(compoundVariant.variants);
|
|
90
103
|
const matches = keys2.every((key) => {
|
|
91
|
-
const value =
|
|
104
|
+
const value = variantsWithDefaults[key];
|
|
92
105
|
if (value === void 0) {
|
|
93
106
|
return false;
|
|
94
107
|
}
|
|
@@ -104,10 +117,13 @@ function useComponentStyles(name, props) {
|
|
|
104
117
|
const useComponentStyleDefaultProps = (name) => {
|
|
105
118
|
const { components } = useTheme();
|
|
106
119
|
const component = components[name];
|
|
107
|
-
|
|
120
|
+
if (!component) {
|
|
121
|
+
return {};
|
|
122
|
+
}
|
|
123
|
+
return component.defaultVariants ?? {};
|
|
108
124
|
};
|
|
109
125
|
const Spinner = ({ className, size, color, ...restProps }) => {
|
|
110
|
-
const spinnerClassName = useComponentStyles("spinner", { base: true, size, color });
|
|
126
|
+
const spinnerClassName = useComponentStyles("spinner", { base: true, variants: { size, color } });
|
|
111
127
|
return /* @__PURE__ */ jsxRuntime.jsx(Box, { color, className: classnames(spinnerClassName, className), ...restProps });
|
|
112
128
|
};
|
|
113
129
|
const Button = react.forwardRef(function Button2({
|
|
@@ -127,11 +143,18 @@ const Button = react.forwardRef(function Button2({
|
|
|
127
143
|
const isLinkVariant = variant === "link";
|
|
128
144
|
const buttonClassName = useComponentStyles("button", {
|
|
129
145
|
base: true,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
146
|
+
variants: {
|
|
147
|
+
variant: isLinkVariant ? "solid" : variant,
|
|
148
|
+
intent,
|
|
149
|
+
size,
|
|
150
|
+
disabled,
|
|
151
|
+
loading
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
const linkClassName = useComponentStyles("link", {
|
|
155
|
+
base: true,
|
|
156
|
+
variants: { variant: "primary" }
|
|
133
157
|
});
|
|
134
|
-
const linkClassName = useComponentStyles("link", { base: true, variant: "primary" });
|
|
135
158
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
136
159
|
Box,
|
|
137
160
|
{
|
|
@@ -272,10 +295,13 @@ const Text = ({
|
|
|
272
295
|
const defaultElement = "a";
|
|
273
296
|
const Link = react.forwardRef(function Link2({ as, className, variant, underline, ...restProps }, ref) {
|
|
274
297
|
const Component = as || defaultElement;
|
|
275
|
-
const linkClassName = useComponentStyles("link", {
|
|
298
|
+
const linkClassName = useComponentStyles("link", {
|
|
299
|
+
base: true,
|
|
300
|
+
variants: { variant, underline }
|
|
301
|
+
});
|
|
276
302
|
return /* @__PURE__ */ jsxRuntime.jsx(Box, { ref, as: Component, className: classnames(className, linkClassName), ...restProps });
|
|
277
303
|
});
|
|
278
|
-
const Divider = ({ className, color }) => {
|
|
304
|
+
const Divider = ({ className, color, ...restProps }) => {
|
|
279
305
|
const dividerClass = useComponentStyles("divider", { base: true });
|
|
280
306
|
const dividerDefaults = useComponentStyleDefaultProps("divider");
|
|
281
307
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -284,7 +310,8 @@ const Divider = ({ className, color }) => {
|
|
|
284
310
|
role: "separator",
|
|
285
311
|
width: "full",
|
|
286
312
|
backgroundColor: color ?? dividerDefaults.color,
|
|
287
|
-
className: classnames(className, dividerClass, styles_components_Divider_divider_css_cjs.divider)
|
|
313
|
+
className: classnames(className, dividerClass, styles_components_Divider_divider_css_cjs.divider),
|
|
314
|
+
...restProps
|
|
288
315
|
}
|
|
289
316
|
);
|
|
290
317
|
};
|
|
@@ -391,7 +418,7 @@ const Portal = ({ children, container }) => {
|
|
|
391
418
|
container || document.body
|
|
392
419
|
);
|
|
393
420
|
};
|
|
394
|
-
const Dialog = ({ children, open, className, onRequestClose }) => {
|
|
421
|
+
const Dialog = ({ children, open, className, onRequestClose, size }) => {
|
|
395
422
|
const dialogRef = react.useRef(null);
|
|
396
423
|
const layer = useLayer();
|
|
397
424
|
const [visible, hide] = useVisibilityState(open);
|
|
@@ -428,8 +455,8 @@ const Dialog = ({ children, open, className, onRequestClose }) => {
|
|
|
428
455
|
document.removeEventListener("keydown", handleKeyDown);
|
|
429
456
|
};
|
|
430
457
|
}, [open, enabled]);
|
|
431
|
-
const backdropClassName = useComponentStyles("dialog", { backdrop: true });
|
|
432
|
-
const dialogClassName = useComponentStyles("dialog", { base: true });
|
|
458
|
+
const backdropClassName = useComponentStyles("dialog", { backdrop: true }, false);
|
|
459
|
+
const dialogClassName = useComponentStyles("dialog", { base: true, variants: { size } });
|
|
433
460
|
if (!visible) {
|
|
434
461
|
return null;
|
|
435
462
|
}
|
|
@@ -459,10 +486,34 @@ const Dialog = ({ children, open, className, onRequestClose }) => {
|
|
|
459
486
|
}
|
|
460
487
|
) }) });
|
|
461
488
|
};
|
|
489
|
+
const Input = react.forwardRef(function Input2({ className, name, type = "text", startSlot, endSlot, label, placeholder, ...restProps }, ref) {
|
|
490
|
+
const id = react.useId();
|
|
491
|
+
const containerClassName = useComponentStyles("input", { container: true }, false);
|
|
492
|
+
const inputClassName = useComponentStyles("input", { input: true });
|
|
493
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Box, { children: /* @__PURE__ */ jsxRuntime.jsxs(Box, { display: "flex", alignItems: "center", className: classnames(containerClassName, className), children: [
|
|
494
|
+
startSlot,
|
|
495
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
496
|
+
Box,
|
|
497
|
+
{
|
|
498
|
+
as: "input",
|
|
499
|
+
id,
|
|
500
|
+
ref,
|
|
501
|
+
name,
|
|
502
|
+
type,
|
|
503
|
+
placeholder: placeholder || label,
|
|
504
|
+
width: "full",
|
|
505
|
+
overflow: "hidden",
|
|
506
|
+
className: classnames(styles_components_Input_input_css_cjs.input, inputClassName),
|
|
507
|
+
...restProps
|
|
508
|
+
}
|
|
509
|
+
),
|
|
510
|
+
endSlot
|
|
511
|
+
] }) });
|
|
512
|
+
});
|
|
462
513
|
exports.breakpointQuery = styles_lib_css_atoms_breakpoints_cjs.breakpointQuery;
|
|
463
|
-
exports.makeComponentTheme =
|
|
464
|
-
exports.makeTheme =
|
|
465
|
-
exports.vars =
|
|
514
|
+
exports.makeComponentTheme = styles_lib_theme_makeComponentTheme_cjs.makeComponentTheme;
|
|
515
|
+
exports.makeTheme = styles_lib_theme_makeTheme_cjs.makeTheme;
|
|
516
|
+
exports.vars = styles_lib_theme_vars_css_cjs.vars;
|
|
466
517
|
exports.atoms = styles_lib_css_atoms_sprinkles_css_cjs.atoms;
|
|
467
518
|
exports.BlocksProvider = BlocksProvider;
|
|
468
519
|
exports.Box = Box;
|
|
@@ -471,6 +522,7 @@ exports.Dialog = Dialog;
|
|
|
471
522
|
exports.Divider = Divider;
|
|
472
523
|
exports.Heading = Heading;
|
|
473
524
|
exports.Inline = Inline;
|
|
525
|
+
exports.Input = Input;
|
|
474
526
|
exports.Link = Link;
|
|
475
527
|
exports.Spinner = Spinner;
|
|
476
528
|
exports.Stack = Stack;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { BlocksProvider, BlocksProviderProps,
|
|
1
|
+
export { BlocksProvider, BlocksProviderProps, Box, BoxProps, Button, ButtonProps, Dialog, DialogProps, Divider, DividerProps, Heading, HeadingProps, Inline, InlineProps, Input, InputProps, Link, LinkProps, Spinner, SpinnerProps, Stack, StackProps, Text, TextProps, ThemeComponentsStyles, ThemeTokens, atoms, breakpointQuery, classnames, makeComponentTheme, makeTheme, useComponentStyleDefaultProps, useComponentStyles, vars } from './momotaro.chunk.js';
|
package/dist/index.mjs
CHANGED
|
@@ -1,23 +1,36 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { breakpointQuery } from "./styles/lib/css/atoms/breakpoints.mjs";
|
|
4
|
-
import { makeComponentTheme } from "./styles/lib/
|
|
5
|
-
import { makeTheme } from "./styles/lib/
|
|
6
|
-
import { vars } from "./styles/lib/
|
|
4
|
+
import { makeComponentTheme } from "./styles/lib/theme/makeComponentTheme.mjs";
|
|
5
|
+
import { makeTheme } from "./styles/lib/theme/makeTheme.mjs";
|
|
6
|
+
import { vars } from "./styles/lib/theme/vars.css.mjs";
|
|
7
7
|
import { atoms } from "./styles/lib/css/atoms/sprinkles.css.mjs";
|
|
8
|
-
import { createContext, forwardRef, useContext, useRef, useEffect, useState, useCallback, useLayoutEffect } from "react";
|
|
8
|
+
import { createContext, forwardRef, useContext, useRef, useEffect, useState, useCallback, useLayoutEffect, useId } from "react";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import { buttonReset } from "./styles/components/Button/Button.css.mjs";
|
|
11
11
|
import { divider } from "./styles/components/Divider/divider.css.mjs";
|
|
12
12
|
import { backdropLeaveAnimation, backdropLeave, backdrop, dialogLeave, dialog } from "./styles/components/Dialog/dialog.css.mjs";
|
|
13
13
|
import { createPortal } from "react-dom";
|
|
14
|
+
import { input } from "./styles/components/Input/input.css.mjs";
|
|
14
15
|
const classnames = (...args) => {
|
|
15
16
|
const className = args.filter((arg) => arg && typeof arg === "string").join(" ");
|
|
16
17
|
return className || void 0;
|
|
17
18
|
};
|
|
18
19
|
const BlocksProviderContext = createContext(null);
|
|
19
|
-
const BlocksProvider = ({
|
|
20
|
-
|
|
20
|
+
const BlocksProvider = ({
|
|
21
|
+
children,
|
|
22
|
+
theme,
|
|
23
|
+
className,
|
|
24
|
+
...restProps
|
|
25
|
+
}) => {
|
|
26
|
+
return /* @__PURE__ */ jsx(BlocksProviderContext.Provider, { value: theme, children: /* @__PURE__ */ jsx(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
className: classnames(theme.vars, atoms({ fontFamily: "primary" }), className),
|
|
30
|
+
...restProps,
|
|
31
|
+
children
|
|
32
|
+
}
|
|
33
|
+
) });
|
|
21
34
|
};
|
|
22
35
|
const defaultElement$1 = "div";
|
|
23
36
|
const Box = forwardRef(function Box2({ className, as, ...restProps }, ref) {
|
|
@@ -40,41 +53,41 @@ const useTheme = () => {
|
|
|
40
53
|
}
|
|
41
54
|
return theme;
|
|
42
55
|
};
|
|
43
|
-
|
|
44
|
-
function useComponentStyles(name, props) {
|
|
56
|
+
function useComponentStyles(name, props, useDefaultVariants = true) {
|
|
45
57
|
const { components } = useTheme();
|
|
46
58
|
const component = components[name];
|
|
47
59
|
if (!component) {
|
|
48
|
-
console.
|
|
60
|
+
console.warn(`Component ${name} is not defined in the theme`);
|
|
49
61
|
return "";
|
|
50
62
|
}
|
|
51
63
|
const classNames = [];
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
64
|
+
const variants = props.variants ?? {};
|
|
65
|
+
const variantsWithDefaults = { ...variants };
|
|
66
|
+
for (const key in props) {
|
|
67
|
+
const value = props[key];
|
|
68
|
+
if (typeof value === "boolean" && value) {
|
|
69
|
+
classNames.push(component[key]);
|
|
59
70
|
}
|
|
60
71
|
}
|
|
61
|
-
if (propsWithDefaults.base && component.base) {
|
|
62
|
-
classNames.push(component.base);
|
|
63
|
-
}
|
|
64
72
|
if (!component.variants) {
|
|
65
73
|
return classNames.join(" ");
|
|
66
74
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
75
|
+
if (useDefaultVariants && component.defaultVariants) {
|
|
76
|
+
const keys2 = Object.keys(component.defaultVariants);
|
|
77
|
+
for (const key of keys2) {
|
|
78
|
+
if (variantsWithDefaults[key] === void 0) {
|
|
79
|
+
variantsWithDefaults[key] = component.defaultVariants[key];
|
|
80
|
+
}
|
|
72
81
|
}
|
|
73
|
-
|
|
82
|
+
}
|
|
83
|
+
const keys = Object.keys(variantsWithDefaults);
|
|
84
|
+
for (const key of keys) {
|
|
85
|
+
const value = variantsWithDefaults[key];
|
|
86
|
+
if (value === void 0) {
|
|
74
87
|
continue;
|
|
75
88
|
}
|
|
76
89
|
if (typeof value === "boolean") {
|
|
77
|
-
if (value) {
|
|
90
|
+
if (value && component.variants[key]) {
|
|
78
91
|
classNames.push(component.variants[key]);
|
|
79
92
|
}
|
|
80
93
|
continue;
|
|
@@ -88,7 +101,7 @@ function useComponentStyles(name, props) {
|
|
|
88
101
|
for (const compoundVariant of component.compoundVariants) {
|
|
89
102
|
const keys2 = Object.keys(compoundVariant.variants);
|
|
90
103
|
const matches = keys2.every((key) => {
|
|
91
|
-
const value =
|
|
104
|
+
const value = variantsWithDefaults[key];
|
|
92
105
|
if (value === void 0) {
|
|
93
106
|
return false;
|
|
94
107
|
}
|
|
@@ -104,10 +117,13 @@ function useComponentStyles(name, props) {
|
|
|
104
117
|
const useComponentStyleDefaultProps = (name) => {
|
|
105
118
|
const { components } = useTheme();
|
|
106
119
|
const component = components[name];
|
|
107
|
-
|
|
120
|
+
if (!component) {
|
|
121
|
+
return {};
|
|
122
|
+
}
|
|
123
|
+
return component.defaultVariants ?? {};
|
|
108
124
|
};
|
|
109
125
|
const Spinner = ({ className, size, color, ...restProps }) => {
|
|
110
|
-
const spinnerClassName = useComponentStyles("spinner", { base: true, size, color });
|
|
126
|
+
const spinnerClassName = useComponentStyles("spinner", { base: true, variants: { size, color } });
|
|
111
127
|
return /* @__PURE__ */ jsx(Box, { color, className: classnames(spinnerClassName, className), ...restProps });
|
|
112
128
|
};
|
|
113
129
|
const Button = forwardRef(function Button2({
|
|
@@ -127,11 +143,18 @@ const Button = forwardRef(function Button2({
|
|
|
127
143
|
const isLinkVariant = variant === "link";
|
|
128
144
|
const buttonClassName = useComponentStyles("button", {
|
|
129
145
|
base: true,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
146
|
+
variants: {
|
|
147
|
+
variant: isLinkVariant ? "solid" : variant,
|
|
148
|
+
intent,
|
|
149
|
+
size,
|
|
150
|
+
disabled,
|
|
151
|
+
loading
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
const linkClassName = useComponentStyles("link", {
|
|
155
|
+
base: true,
|
|
156
|
+
variants: { variant: "primary" }
|
|
133
157
|
});
|
|
134
|
-
const linkClassName = useComponentStyles("link", { base: true, variant: "primary" });
|
|
135
158
|
return /* @__PURE__ */ jsxs(
|
|
136
159
|
Box,
|
|
137
160
|
{
|
|
@@ -272,10 +295,13 @@ const Text = ({
|
|
|
272
295
|
const defaultElement = "a";
|
|
273
296
|
const Link = forwardRef(function Link2({ as, className, variant, underline, ...restProps }, ref) {
|
|
274
297
|
const Component = as || defaultElement;
|
|
275
|
-
const linkClassName = useComponentStyles("link", {
|
|
298
|
+
const linkClassName = useComponentStyles("link", {
|
|
299
|
+
base: true,
|
|
300
|
+
variants: { variant, underline }
|
|
301
|
+
});
|
|
276
302
|
return /* @__PURE__ */ jsx(Box, { ref, as: Component, className: classnames(className, linkClassName), ...restProps });
|
|
277
303
|
});
|
|
278
|
-
const Divider = ({ className, color }) => {
|
|
304
|
+
const Divider = ({ className, color, ...restProps }) => {
|
|
279
305
|
const dividerClass = useComponentStyles("divider", { base: true });
|
|
280
306
|
const dividerDefaults = useComponentStyleDefaultProps("divider");
|
|
281
307
|
return /* @__PURE__ */ jsx(
|
|
@@ -284,7 +310,8 @@ const Divider = ({ className, color }) => {
|
|
|
284
310
|
role: "separator",
|
|
285
311
|
width: "full",
|
|
286
312
|
backgroundColor: color ?? dividerDefaults.color,
|
|
287
|
-
className: classnames(className, dividerClass, divider)
|
|
313
|
+
className: classnames(className, dividerClass, divider),
|
|
314
|
+
...restProps
|
|
288
315
|
}
|
|
289
316
|
);
|
|
290
317
|
};
|
|
@@ -391,7 +418,7 @@ const Portal = ({ children, container }) => {
|
|
|
391
418
|
container || document.body
|
|
392
419
|
);
|
|
393
420
|
};
|
|
394
|
-
const Dialog = ({ children, open, className, onRequestClose }) => {
|
|
421
|
+
const Dialog = ({ children, open, className, onRequestClose, size }) => {
|
|
395
422
|
const dialogRef = useRef(null);
|
|
396
423
|
const layer = useLayer();
|
|
397
424
|
const [visible, hide] = useVisibilityState(open);
|
|
@@ -428,8 +455,8 @@ const Dialog = ({ children, open, className, onRequestClose }) => {
|
|
|
428
455
|
document.removeEventListener("keydown", handleKeyDown);
|
|
429
456
|
};
|
|
430
457
|
}, [open, enabled]);
|
|
431
|
-
const backdropClassName = useComponentStyles("dialog", { backdrop: true });
|
|
432
|
-
const dialogClassName = useComponentStyles("dialog", { base: true });
|
|
458
|
+
const backdropClassName = useComponentStyles("dialog", { backdrop: true }, false);
|
|
459
|
+
const dialogClassName = useComponentStyles("dialog", { base: true, variants: { size } });
|
|
433
460
|
if (!visible) {
|
|
434
461
|
return null;
|
|
435
462
|
}
|
|
@@ -459,6 +486,30 @@ const Dialog = ({ children, open, className, onRequestClose }) => {
|
|
|
459
486
|
}
|
|
460
487
|
) }) });
|
|
461
488
|
};
|
|
489
|
+
const Input = forwardRef(function Input2({ className, name, type = "text", startSlot, endSlot, label, placeholder, ...restProps }, ref) {
|
|
490
|
+
const id = useId();
|
|
491
|
+
const containerClassName = useComponentStyles("input", { container: true }, false);
|
|
492
|
+
const inputClassName = useComponentStyles("input", { input: true });
|
|
493
|
+
return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", className: classnames(containerClassName, className), children: [
|
|
494
|
+
startSlot,
|
|
495
|
+
/* @__PURE__ */ jsx(
|
|
496
|
+
Box,
|
|
497
|
+
{
|
|
498
|
+
as: "input",
|
|
499
|
+
id,
|
|
500
|
+
ref,
|
|
501
|
+
name,
|
|
502
|
+
type,
|
|
503
|
+
placeholder: placeholder || label,
|
|
504
|
+
width: "full",
|
|
505
|
+
overflow: "hidden",
|
|
506
|
+
className: classnames(input, inputClassName),
|
|
507
|
+
...restProps
|
|
508
|
+
}
|
|
509
|
+
),
|
|
510
|
+
endSlot
|
|
511
|
+
] }) });
|
|
512
|
+
});
|
|
462
513
|
export {
|
|
463
514
|
BlocksProvider,
|
|
464
515
|
Box,
|
|
@@ -467,6 +518,7 @@ export {
|
|
|
467
518
|
Divider,
|
|
468
519
|
Heading,
|
|
469
520
|
Inline,
|
|
521
|
+
Input,
|
|
470
522
|
Link,
|
|
471
523
|
Spinner,
|
|
472
524
|
Stack,
|