@blockle/blocks 0.2.3 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +136 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +138 -6
- package/dist/momotaro.chunk.d.ts +160 -45
- package/dist/reset.css.cjs +0 -1
- package/dist/reset.css.mjs +0 -1
- package/dist/styles/components/Button/Button.css.cjs +15 -0
- package/dist/styles/components/Button/Button.css.mjs +16 -0
- package/dist/styles/lib/css/atoms/index.cjs +1 -0
- package/dist/styles/lib/css/atoms/index.mjs +1 -0
- package/dist/styles/lib/css/layers/layers.css.cjs +7 -0
- package/dist/styles/lib/css/layers/layers.css.mjs +8 -0
- package/dist/styles/lib/css/reset/reset.css.cjs +0 -36
- package/dist/styles/lib/css/reset/reset.css.mjs +1 -36
- package/dist/styles/lib/css/theme/makeVanillaTheme.cjs +5 -2
- package/dist/styles/lib/css/theme/makeVanillaTheme.mjs +5 -2
- package/dist/styles/lib/css/theme/tokens.cjs +5 -2
- package/dist/styles/lib/css/theme/tokens.mjs +5 -2
- package/dist/styles/themes/momotaro/components/button.css.cjs +85 -25
- package/dist/styles/themes/momotaro/components/button.css.mjs +85 -25
- package/dist/styles/themes/momotaro/components/helpers.css.cjs +26 -0
- package/dist/styles/themes/momotaro/components/helpers.css.mjs +27 -0
- package/dist/styles/themes/momotaro/components/index.cjs +5 -1
- package/dist/styles/themes/momotaro/components/index.mjs +5 -1
- package/dist/styles/themes/momotaro/components/link.css.cjs +47 -0
- package/dist/styles/themes/momotaro/components/link.css.mjs +48 -0
- package/dist/styles/themes/momotaro/components/spinner.css.cjs +44 -0
- package/dist/styles/themes/momotaro/components/spinner.css.mjs +45 -0
- package/dist/styles/themes/momotaro/tokens.cjs +5 -2
- package/dist/styles/themes/momotaro/tokens.mjs +5 -2
- package/package.json +31 -2
package/dist/index.cjs
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
3
|
+
const styles_lib_css_theme_vars_css_cjs = require("./styles/lib/css/theme/vars.css.cjs");
|
|
4
|
+
const styles_lib_css_atoms_breakpoints_cjs = require("./styles/lib/css/atoms/breakpoints.cjs");
|
|
4
5
|
const styles_lib_css_atoms_sprinkles_css_cjs = require("./styles/lib/css/atoms/sprinkles.css.cjs");
|
|
6
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
7
|
const react = require("react");
|
|
6
|
-
const
|
|
8
|
+
const styles_components_Button_Button_css_cjs = require("./styles/components/Button/Button.css.cjs");
|
|
7
9
|
const classnames = (...args) => {
|
|
8
10
|
const className = args.filter((arg) => arg && typeof arg === "string").join(" ");
|
|
9
11
|
return className || void 0;
|
|
10
12
|
};
|
|
13
|
+
const BlocksProviderContext = react.createContext(null);
|
|
11
14
|
const BlocksProvider = ({ children, theme }) => {
|
|
12
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classnames(theme.vars, styles_lib_css_atoms_sprinkles_css_cjs.atoms({ fontFamily: "standard" })), children });
|
|
15
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BlocksProviderContext.Provider, { value: theme, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: classnames(theme.vars, styles_lib_css_atoms_sprinkles_css_cjs.atoms({ fontFamily: "standard" })), children }) });
|
|
13
16
|
};
|
|
14
|
-
const defaultElement = "div";
|
|
17
|
+
const defaultElement$1 = "div";
|
|
15
18
|
const Box = react.forwardRef(function Box2({ className, as, ...restProps }, ref) {
|
|
16
|
-
const Component = as || defaultElement;
|
|
19
|
+
const Component = as || defaultElement$1;
|
|
17
20
|
const atomProps = {};
|
|
18
21
|
const otherProps = {};
|
|
19
22
|
for (const [name, value] of Object.entries(restProps)) {
|
|
@@ -25,6 +28,123 @@ const Box = react.forwardRef(function Box2({ className, as, ...restProps }, ref)
|
|
|
25
28
|
}
|
|
26
29
|
return /* @__PURE__ */ jsxRuntime.jsx(Component, { ref, className: classnames(className, styles_lib_css_atoms_sprinkles_css_cjs.atoms(atomProps)), ...otherProps });
|
|
27
30
|
});
|
|
31
|
+
const useTheme = () => {
|
|
32
|
+
const theme = react.useContext(BlocksProviderContext);
|
|
33
|
+
if (!theme) {
|
|
34
|
+
throw new Error("useTheme must be used within a BlocksProvider");
|
|
35
|
+
}
|
|
36
|
+
return theme;
|
|
37
|
+
};
|
|
38
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
39
|
+
function useComponentStyles(name, props) {
|
|
40
|
+
const { components } = useTheme();
|
|
41
|
+
const component = components[name];
|
|
42
|
+
if (!component) {
|
|
43
|
+
console.info(`Component ${name} is not defined in the theme`);
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
const classNames = [];
|
|
47
|
+
const propsWithDefaults = { ...props };
|
|
48
|
+
if (component.defaultVariants) {
|
|
49
|
+
const keys2 = Object.keys(component.defaultVariants);
|
|
50
|
+
for (const key of keys2) {
|
|
51
|
+
if (propsWithDefaults[key] === void 0) {
|
|
52
|
+
propsWithDefaults[key] = component.defaultVariants[key];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (propsWithDefaults.base && component.base) {
|
|
57
|
+
classNames.push(component.base);
|
|
58
|
+
}
|
|
59
|
+
if (!component.variants) {
|
|
60
|
+
return classNames.join(" ");
|
|
61
|
+
}
|
|
62
|
+
const keys = Object.keys(propsWithDefaults);
|
|
63
|
+
for (const key of keys) {
|
|
64
|
+
const value = propsWithDefaults[key];
|
|
65
|
+
if (key === "base" || value === void 0) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (!hasOwnProperty.call(component.variants, key)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (typeof value === "boolean") {
|
|
72
|
+
if (value) {
|
|
73
|
+
classNames.push(component.variants[key]);
|
|
74
|
+
}
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const variant = component.variants[key][value];
|
|
78
|
+
if (variant) {
|
|
79
|
+
classNames.push(variant);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (component.compoundVariants) {
|
|
83
|
+
for (const compoundVariant of component.compoundVariants) {
|
|
84
|
+
const keys2 = Object.keys(compoundVariant.variants);
|
|
85
|
+
const matches = keys2.every((key) => {
|
|
86
|
+
const value = propsWithDefaults[key];
|
|
87
|
+
if (value === void 0) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return value === compoundVariant.variants[key];
|
|
91
|
+
});
|
|
92
|
+
if (matches) {
|
|
93
|
+
classNames.push(compoundVariant.style);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return classNames.join(" ");
|
|
98
|
+
}
|
|
99
|
+
const Spinner = ({ className, size, color, ...restProps }) => {
|
|
100
|
+
const spinnerClassName = useComponentStyles("spinner", { base: true, size, color });
|
|
101
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Box, { color, className: classnames(spinnerClassName, className), ...restProps });
|
|
102
|
+
};
|
|
103
|
+
const Button = react.forwardRef(function Button2({
|
|
104
|
+
children,
|
|
105
|
+
className,
|
|
106
|
+
type = "button",
|
|
107
|
+
variant,
|
|
108
|
+
intent,
|
|
109
|
+
size,
|
|
110
|
+
width,
|
|
111
|
+
startSlot,
|
|
112
|
+
endSlot,
|
|
113
|
+
loading,
|
|
114
|
+
disabled,
|
|
115
|
+
...restProps
|
|
116
|
+
}, ref) {
|
|
117
|
+
const isLinkVariant = variant === "link";
|
|
118
|
+
const buttonClassName = useComponentStyles("button", {
|
|
119
|
+
base: true,
|
|
120
|
+
variant: isLinkVariant ? "solid" : variant,
|
|
121
|
+
intent,
|
|
122
|
+
size
|
|
123
|
+
});
|
|
124
|
+
const linkClassName = useComponentStyles("link", { base: true, variant: "primary" });
|
|
125
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
126
|
+
Box,
|
|
127
|
+
{
|
|
128
|
+
ref,
|
|
129
|
+
as: "button",
|
|
130
|
+
className: classnames(
|
|
131
|
+
styles_components_Button_Button_css_cjs.buttonReset,
|
|
132
|
+
isLinkVariant ? linkClassName : buttonClassName,
|
|
133
|
+
className
|
|
134
|
+
),
|
|
135
|
+
width,
|
|
136
|
+
type,
|
|
137
|
+
disabled: disabled || loading,
|
|
138
|
+
...restProps,
|
|
139
|
+
children: [
|
|
140
|
+
startSlot && /* @__PURE__ */ jsxRuntime.jsx(Box, { paddingRight: "medium", children: startSlot }),
|
|
141
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size, marginRight: "medium" }),
|
|
142
|
+
children,
|
|
143
|
+
endSlot && /* @__PURE__ */ jsxRuntime.jsx(Box, { paddingLeft: "medium", children: endSlot })
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
});
|
|
28
148
|
const Heading = ({
|
|
29
149
|
className,
|
|
30
150
|
level = 1,
|
|
@@ -139,12 +259,22 @@ const Text = ({
|
|
|
139
259
|
}
|
|
140
260
|
);
|
|
141
261
|
};
|
|
142
|
-
|
|
262
|
+
const defaultElement = "a";
|
|
263
|
+
const Link = react.forwardRef(function Link2({ as, className, variant, underline, ...restProps }, ref) {
|
|
264
|
+
const Component = as || defaultElement;
|
|
265
|
+
const linkClassName = useComponentStyles("link", { base: true, variant, underline });
|
|
266
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Box, { ref, as: Component, className: classnames(className, linkClassName), ...restProps });
|
|
267
|
+
});
|
|
143
268
|
exports.vars = styles_lib_css_theme_vars_css_cjs.vars;
|
|
269
|
+
exports.breakpointQuery = styles_lib_css_atoms_breakpoints_cjs.breakpointQuery;
|
|
270
|
+
exports.atoms = styles_lib_css_atoms_sprinkles_css_cjs.atoms;
|
|
144
271
|
exports.BlocksProvider = BlocksProvider;
|
|
145
272
|
exports.Box = Box;
|
|
273
|
+
exports.Button = Button;
|
|
146
274
|
exports.Heading = Heading;
|
|
147
275
|
exports.Inline = Inline;
|
|
276
|
+
exports.Link = Link;
|
|
277
|
+
exports.Spinner = Spinner;
|
|
148
278
|
exports.Stack = Stack;
|
|
149
279
|
exports.Text = Text;
|
|
150
280
|
exports.classnames = classnames;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { BlocksProvider, BlocksProviderProps, Box, BoxProps, Heading, HeadingProps, Inline, InlineProps, Stack, StackProps, Text, TextProps, atoms, classnames, vars } from './momotaro.chunk.js';
|
|
1
|
+
export { BlocksProvider, BlocksProviderProps, Box, BoxProps, Button, ButtonProps, Heading, HeadingProps, Inline, InlineProps, Link, LinkProps, Spinner, SpinnerProps, Stack, StackProps, Text, TextProps, atoms, breakpointQuery, classnames, vars } from './momotaro.chunk.js';
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { forwardRef } from "react";
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
4
3
|
import { vars } from "./styles/lib/css/theme/vars.css.mjs";
|
|
4
|
+
import { breakpointQuery } from "./styles/lib/css/atoms/breakpoints.mjs";
|
|
5
|
+
import { atoms } from "./styles/lib/css/atoms/sprinkles.css.mjs";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { createContext, forwardRef, useContext } from "react";
|
|
8
|
+
import { buttonReset } from "./styles/components/Button/Button.css.mjs";
|
|
5
9
|
const classnames = (...args) => {
|
|
6
10
|
const className = args.filter((arg) => arg && typeof arg === "string").join(" ");
|
|
7
11
|
return className || void 0;
|
|
8
12
|
};
|
|
13
|
+
const BlocksProviderContext = createContext(null);
|
|
9
14
|
const BlocksProvider = ({ children, theme }) => {
|
|
10
|
-
return /* @__PURE__ */ jsx("div", { className: classnames(theme.vars, atoms({ fontFamily: "standard" })), children });
|
|
15
|
+
return /* @__PURE__ */ jsx(BlocksProviderContext.Provider, { value: theme, children: /* @__PURE__ */ jsx("div", { className: classnames(theme.vars, atoms({ fontFamily: "standard" })), children }) });
|
|
11
16
|
};
|
|
12
|
-
const defaultElement = "div";
|
|
17
|
+
const defaultElement$1 = "div";
|
|
13
18
|
const Box = forwardRef(function Box2({ className, as, ...restProps }, ref) {
|
|
14
|
-
const Component = as || defaultElement;
|
|
19
|
+
const Component = as || defaultElement$1;
|
|
15
20
|
const atomProps = {};
|
|
16
21
|
const otherProps = {};
|
|
17
22
|
for (const [name, value] of Object.entries(restProps)) {
|
|
@@ -23,6 +28,123 @@ const Box = forwardRef(function Box2({ className, as, ...restProps }, ref) {
|
|
|
23
28
|
}
|
|
24
29
|
return /* @__PURE__ */ jsx(Component, { ref, className: classnames(className, atoms(atomProps)), ...otherProps });
|
|
25
30
|
});
|
|
31
|
+
const useTheme = () => {
|
|
32
|
+
const theme = useContext(BlocksProviderContext);
|
|
33
|
+
if (!theme) {
|
|
34
|
+
throw new Error("useTheme must be used within a BlocksProvider");
|
|
35
|
+
}
|
|
36
|
+
return theme;
|
|
37
|
+
};
|
|
38
|
+
const hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
39
|
+
function useComponentStyles(name, props) {
|
|
40
|
+
const { components } = useTheme();
|
|
41
|
+
const component = components[name];
|
|
42
|
+
if (!component) {
|
|
43
|
+
console.info(`Component ${name} is not defined in the theme`);
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
const classNames = [];
|
|
47
|
+
const propsWithDefaults = { ...props };
|
|
48
|
+
if (component.defaultVariants) {
|
|
49
|
+
const keys2 = Object.keys(component.defaultVariants);
|
|
50
|
+
for (const key of keys2) {
|
|
51
|
+
if (propsWithDefaults[key] === void 0) {
|
|
52
|
+
propsWithDefaults[key] = component.defaultVariants[key];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
if (propsWithDefaults.base && component.base) {
|
|
57
|
+
classNames.push(component.base);
|
|
58
|
+
}
|
|
59
|
+
if (!component.variants) {
|
|
60
|
+
return classNames.join(" ");
|
|
61
|
+
}
|
|
62
|
+
const keys = Object.keys(propsWithDefaults);
|
|
63
|
+
for (const key of keys) {
|
|
64
|
+
const value = propsWithDefaults[key];
|
|
65
|
+
if (key === "base" || value === void 0) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (!hasOwnProperty.call(component.variants, key)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (typeof value === "boolean") {
|
|
72
|
+
if (value) {
|
|
73
|
+
classNames.push(component.variants[key]);
|
|
74
|
+
}
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const variant = component.variants[key][value];
|
|
78
|
+
if (variant) {
|
|
79
|
+
classNames.push(variant);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (component.compoundVariants) {
|
|
83
|
+
for (const compoundVariant of component.compoundVariants) {
|
|
84
|
+
const keys2 = Object.keys(compoundVariant.variants);
|
|
85
|
+
const matches = keys2.every((key) => {
|
|
86
|
+
const value = propsWithDefaults[key];
|
|
87
|
+
if (value === void 0) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
return value === compoundVariant.variants[key];
|
|
91
|
+
});
|
|
92
|
+
if (matches) {
|
|
93
|
+
classNames.push(compoundVariant.style);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return classNames.join(" ");
|
|
98
|
+
}
|
|
99
|
+
const Spinner = ({ className, size, color, ...restProps }) => {
|
|
100
|
+
const spinnerClassName = useComponentStyles("spinner", { base: true, size, color });
|
|
101
|
+
return /* @__PURE__ */ jsx(Box, { color, className: classnames(spinnerClassName, className), ...restProps });
|
|
102
|
+
};
|
|
103
|
+
const Button = forwardRef(function Button2({
|
|
104
|
+
children,
|
|
105
|
+
className,
|
|
106
|
+
type = "button",
|
|
107
|
+
variant,
|
|
108
|
+
intent,
|
|
109
|
+
size,
|
|
110
|
+
width,
|
|
111
|
+
startSlot,
|
|
112
|
+
endSlot,
|
|
113
|
+
loading,
|
|
114
|
+
disabled,
|
|
115
|
+
...restProps
|
|
116
|
+
}, ref) {
|
|
117
|
+
const isLinkVariant = variant === "link";
|
|
118
|
+
const buttonClassName = useComponentStyles("button", {
|
|
119
|
+
base: true,
|
|
120
|
+
variant: isLinkVariant ? "solid" : variant,
|
|
121
|
+
intent,
|
|
122
|
+
size
|
|
123
|
+
});
|
|
124
|
+
const linkClassName = useComponentStyles("link", { base: true, variant: "primary" });
|
|
125
|
+
return /* @__PURE__ */ jsxs(
|
|
126
|
+
Box,
|
|
127
|
+
{
|
|
128
|
+
ref,
|
|
129
|
+
as: "button",
|
|
130
|
+
className: classnames(
|
|
131
|
+
buttonReset,
|
|
132
|
+
isLinkVariant ? linkClassName : buttonClassName,
|
|
133
|
+
className
|
|
134
|
+
),
|
|
135
|
+
width,
|
|
136
|
+
type,
|
|
137
|
+
disabled: disabled || loading,
|
|
138
|
+
...restProps,
|
|
139
|
+
children: [
|
|
140
|
+
startSlot && /* @__PURE__ */ jsx(Box, { paddingRight: "medium", children: startSlot }),
|
|
141
|
+
loading && /* @__PURE__ */ jsx(Spinner, { size, marginRight: "medium" }),
|
|
142
|
+
children,
|
|
143
|
+
endSlot && /* @__PURE__ */ jsx(Box, { paddingLeft: "medium", children: endSlot })
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
});
|
|
26
148
|
const Heading = ({
|
|
27
149
|
className,
|
|
28
150
|
level = 1,
|
|
@@ -137,14 +259,24 @@ const Text = ({
|
|
|
137
259
|
}
|
|
138
260
|
);
|
|
139
261
|
};
|
|
262
|
+
const defaultElement = "a";
|
|
263
|
+
const Link = forwardRef(function Link2({ as, className, variant, underline, ...restProps }, ref) {
|
|
264
|
+
const Component = as || defaultElement;
|
|
265
|
+
const linkClassName = useComponentStyles("link", { base: true, variant, underline });
|
|
266
|
+
return /* @__PURE__ */ jsx(Box, { ref, as: Component, className: classnames(className, linkClassName), ...restProps });
|
|
267
|
+
});
|
|
140
268
|
export {
|
|
141
269
|
BlocksProvider,
|
|
142
270
|
Box,
|
|
271
|
+
Button,
|
|
143
272
|
Heading,
|
|
144
273
|
Inline,
|
|
274
|
+
Link,
|
|
275
|
+
Spinner,
|
|
145
276
|
Stack,
|
|
146
277
|
Text,
|
|
147
278
|
atoms,
|
|
279
|
+
breakpointQuery,
|
|
148
280
|
classnames,
|
|
149
281
|
vars
|
|
150
282
|
};
|