@blockle/blocks 0.12.2 → 0.13.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 +4 -5
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +6 -7
- package/dist/momotaro.chunk.d.ts +31 -13
- package/dist/styles/components/display/Divider/Divider.cjs +42 -58
- package/dist/styles/components/display/Divider/Divider.mjs +42 -58
- package/dist/styles/components/form/Button/Button.cjs +4 -4
- package/dist/styles/components/form/Button/Button.mjs +3 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -119,20 +119,20 @@ const Stack = ({
|
|
|
119
119
|
}
|
|
120
120
|
);
|
|
121
121
|
};
|
|
122
|
-
const
|
|
122
|
+
const { Template, Slot } = styles_components_display_Divider_Divider_cjs.createAsChildTemplate("a");
|
|
123
123
|
const Link = react.forwardRef(function Link2({ asChild, className, children, variant, underline, ...restProps }, ref) {
|
|
124
124
|
const linkClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("link", {
|
|
125
125
|
base: true,
|
|
126
126
|
variants: { variant, underline }
|
|
127
127
|
});
|
|
128
128
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
129
|
-
|
|
129
|
+
Template,
|
|
130
130
|
{
|
|
131
131
|
asChild,
|
|
132
132
|
ref,
|
|
133
133
|
className: styles_components_display_Divider_Divider_cjs.classnames(className, linkClassName),
|
|
134
134
|
...restProps,
|
|
135
|
-
children
|
|
135
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Slot, { children })
|
|
136
136
|
}
|
|
137
137
|
);
|
|
138
138
|
});
|
|
@@ -350,9 +350,8 @@ exports.makeTheme = styles_lib_theme_makeTheme_cjs.makeTheme;
|
|
|
350
350
|
exports.vars = styles_lib_theme_vars_css_cjs.vars;
|
|
351
351
|
exports.Box = styles_components_display_Divider_Divider_cjs.Box;
|
|
352
352
|
exports.Divider = styles_components_display_Divider_Divider_cjs.Divider;
|
|
353
|
-
exports.Slot = styles_components_display_Divider_Divider_cjs.Slot;
|
|
354
353
|
exports.classnames = styles_components_display_Divider_Divider_cjs.classnames;
|
|
355
|
-
exports.
|
|
354
|
+
exports.createAsChildTemplate = styles_components_display_Divider_Divider_cjs.createAsChildTemplate;
|
|
356
355
|
exports.useComponentStyleDefaultProps = styles_components_display_Divider_Divider_cjs.useComponentStyleDefaultProps;
|
|
357
356
|
exports.useComponentStyles = styles_components_display_Divider_Divider_cjs.useComponentStyles;
|
|
358
357
|
exports.atoms = styles_lib_css_atoms_sprinkles_css_cjs.atoms;
|
package/dist/index.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { BlocksProvider, BlocksProviderProps, Box, BoxProps, Button, ButtonProps, Checkbox, CheckboxProps, Dialog, DialogProps, Divider, DividerProps, Heading, HeadingProps, Inline, InlineProps, Input, InputProps, Label, LabelProps, Link, LinkProps, Portal, PortalProps, Progress, ProgressProps, Radio, RadioProps, Select, SelectProps, Slider, SliderProps,
|
|
1
|
+
export { BlocksProvider, BlocksProviderProps, Box, BoxProps, Button, ButtonProps, Checkbox, CheckboxProps, Dialog, DialogProps, Divider, DividerProps, Heading, HeadingProps, Inline, InlineProps, Input, InputProps, Label, LabelProps, Link, LinkProps, Portal, PortalProps, Progress, ProgressProps, Radio, RadioProps, Select, SelectProps, Slider, SliderProps, Spinner, SpinnerProps, Stack, StackProps, Switch, SwitchProps, Text, TextProps, ThemeComponentsStyles, ThemeTokens, Tooltip, TooltipProps, atoms, breakpointQuery, classnames, createAsChildTemplate, makeComponentTheme, makeTheme, style, useComponentStyleDefaultProps, useComponentStyles, useIsomorphicLayoutEffect, useKeyboard, usePreventBodyScroll, useRootAriaHidden, vars } from './momotaro.chunk.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { BlocksProvider, BlocksProviderProps, Box, BoxProps, Button, ButtonProps, Checkbox, CheckboxProps, Dialog, DialogProps, Divider, DividerProps, Heading, HeadingProps, Inline, InlineProps, Input, InputProps, Label, LabelProps, Link, LinkProps, Portal, PortalProps, Progress, ProgressProps, Radio, RadioProps, Select, SelectProps, Slider, SliderProps,
|
|
1
|
+
export { BlocksProvider, BlocksProviderProps, Box, BoxProps, Button, ButtonProps, Checkbox, CheckboxProps, Dialog, DialogProps, Divider, DividerProps, Heading, HeadingProps, Inline, InlineProps, Input, InputProps, Label, LabelProps, Link, LinkProps, Portal, PortalProps, Progress, ProgressProps, Radio, RadioProps, Select, SelectProps, Slider, SliderProps, Spinner, SpinnerProps, Stack, StackProps, Switch, SwitchProps, Text, TextProps, ThemeComponentsStyles, ThemeTokens, Tooltip, TooltipProps, atoms, breakpointQuery, classnames, createAsChildTemplate, makeComponentTheme, makeTheme, style, useComponentStyleDefaultProps, useComponentStyles, useIsomorphicLayoutEffect, useKeyboard, usePreventBodyScroll, useRootAriaHidden, vars } from './momotaro.chunk.js';
|
package/dist/index.mjs
CHANGED
|
@@ -5,8 +5,8 @@ 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,
|
|
9
|
-
import { Divider,
|
|
8
|
+
import { useComponentStyles, Box, classnames, createAsChildTemplate, composeRefs, BlocksProviderContext } from "./styles/components/display/Divider/Divider.mjs";
|
|
9
|
+
import { Divider, useComponentStyleDefaultProps } from "./styles/components/display/Divider/Divider.mjs";
|
|
10
10
|
import { atoms } from "./styles/lib/css/atoms/sprinkles.css.mjs";
|
|
11
11
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
12
12
|
import { forwardRef, useState, useRef, useLayoutEffect, useEffect, useCallback, useId, Children, isValidElement, cloneElement, useContext } from "react";
|
|
@@ -121,20 +121,20 @@ const Stack = ({
|
|
|
121
121
|
}
|
|
122
122
|
);
|
|
123
123
|
};
|
|
124
|
-
const
|
|
124
|
+
const { Template, Slot } = createAsChildTemplate("a");
|
|
125
125
|
const Link = forwardRef(function Link2({ asChild, className, children, variant, underline, ...restProps }, ref) {
|
|
126
126
|
const linkClassName = useComponentStyles("link", {
|
|
127
127
|
base: true,
|
|
128
128
|
variants: { variant, underline }
|
|
129
129
|
});
|
|
130
130
|
return /* @__PURE__ */ jsx(
|
|
131
|
-
|
|
131
|
+
Template,
|
|
132
132
|
{
|
|
133
133
|
asChild,
|
|
134
134
|
ref,
|
|
135
135
|
className: classnames(className, linkClassName),
|
|
136
136
|
...restProps,
|
|
137
|
-
children
|
|
137
|
+
children: /* @__PURE__ */ jsx(Slot, { children })
|
|
138
138
|
}
|
|
139
139
|
);
|
|
140
140
|
});
|
|
@@ -362,7 +362,6 @@ export {
|
|
|
362
362
|
Radio,
|
|
363
363
|
Select,
|
|
364
364
|
Slider,
|
|
365
|
-
Slot,
|
|
366
365
|
Spinner,
|
|
367
366
|
Stack,
|
|
368
367
|
Switch,
|
|
@@ -371,7 +370,7 @@ export {
|
|
|
371
370
|
atoms,
|
|
372
371
|
breakpointQuery,
|
|
373
372
|
classnames,
|
|
374
|
-
|
|
373
|
+
createAsChildTemplate,
|
|
375
374
|
makeComponentTheme,
|
|
376
375
|
makeTheme,
|
|
377
376
|
style,
|
package/dist/momotaro.chunk.d.ts
CHANGED
|
@@ -627,7 +627,7 @@ type SpinnerProps = {
|
|
|
627
627
|
} & MarginAtoms;
|
|
628
628
|
declare const Spinner: React.FC<SpinnerProps>;
|
|
629
629
|
|
|
630
|
-
type HTMLElementProps<E extends Element> = Omit<React.HTMLProps<E>, keyof Atoms | '
|
|
630
|
+
type HTMLElementProps<E extends Element> = Omit<React.HTMLProps<E>, keyof Atoms | 'ref'>;
|
|
631
631
|
|
|
632
632
|
type ButtonProps = {
|
|
633
633
|
children: React.ReactNode;
|
|
@@ -642,6 +642,7 @@ type ButtonProps = {
|
|
|
642
642
|
endSlot?: React.ReactNode;
|
|
643
643
|
disabled?: boolean;
|
|
644
644
|
asChild?: boolean;
|
|
645
|
+
popovertarget?: string;
|
|
645
646
|
} & Omit<HTMLElementProps<HTMLButtonElement>, 'size'> & MarginAtoms;
|
|
646
647
|
declare const Button: react.ForwardRefExoticComponent<{
|
|
647
648
|
children: React.ReactNode;
|
|
@@ -656,6 +657,7 @@ declare const Button: react.ForwardRefExoticComponent<{
|
|
|
656
657
|
endSlot?: React.ReactNode;
|
|
657
658
|
disabled?: boolean | undefined;
|
|
658
659
|
asChild?: boolean | undefined;
|
|
660
|
+
popovertarget?: string | undefined;
|
|
659
661
|
} & Omit<HTMLElementProps<HTMLButtonElement>, "size"> & MarginAtoms & react.RefAttributes<HTMLButtonElement>>;
|
|
660
662
|
|
|
661
663
|
type CheckboxProps = {
|
|
@@ -1106,20 +1108,36 @@ type TextProps = {
|
|
|
1106
1108
|
} & TextAtoms & MarginAtoms & PaddingAtoms & HTMLElementProps<HTMLSpanElement>;
|
|
1107
1109
|
declare const Text: React.FC<TextProps>;
|
|
1108
1110
|
|
|
1109
|
-
type
|
|
1111
|
+
type TemplateProps = {
|
|
1112
|
+
asChild?: boolean;
|
|
1113
|
+
children?: React.ReactNode;
|
|
1114
|
+
};
|
|
1110
1115
|
/**
|
|
1111
|
-
*
|
|
1112
|
-
*
|
|
1113
|
-
*
|
|
1114
|
-
*
|
|
1116
|
+
* Create a Template component that can render as a child of another component with asChild prop.
|
|
1117
|
+
*
|
|
1118
|
+
* Example
|
|
1119
|
+
* // Create a Template and Slot components with div as default element
|
|
1120
|
+
* const { Template, Slot } = createAsChildContainer('div');
|
|
1121
|
+
*
|
|
1122
|
+
* const MyComponent = ({ children, asChild, ...restProps }) => {
|
|
1123
|
+
* return (
|
|
1124
|
+
* <Template asChild={asChild} {...restProps}>
|
|
1125
|
+
* <Slot>{childen}</Slot> // Slot is required, will be replaced with children
|
|
1126
|
+
* </Template>
|
|
1127
|
+
* );
|
|
1128
|
+
* }
|
|
1129
|
+
*
|
|
1130
|
+
* <MyComponent className="test">Not a link</MyComponent> // Renders as <div class="test">Not a link</div>
|
|
1131
|
+
* <MyComponent className="test"><a href="#">Link</a></MyComponent> // Renders as <div class="test"><a href="#">Link</a></div>
|
|
1132
|
+
* <MyComponent className="test" asChild><a href="#">Link</a></MyComponent> // Renders as <a href="#" class="test">Link</a>
|
|
1115
1133
|
*/
|
|
1116
|
-
declare function
|
|
1117
|
-
|
|
1118
|
-
|
|
1134
|
+
declare function createAsChildTemplate<T extends keyof HTMLElementTagNameMap>(defaultElement: T): {
|
|
1135
|
+
Template: react.ForwardRefExoticComponent<TemplateProps & HTMLElementProps<HTMLElementTagNameMap[T]> & react.RefAttributes<HTMLElementTagNameMap[T]>>;
|
|
1136
|
+
Slot: react.FC<SlotProps>;
|
|
1137
|
+
};
|
|
1119
1138
|
type SlotProps = {
|
|
1120
|
-
children:
|
|
1139
|
+
children: React.ReactNode;
|
|
1121
1140
|
};
|
|
1122
|
-
declare const Slot: react__default.FC<SlotProps>;
|
|
1123
1141
|
|
|
1124
1142
|
declare function useComponentStyles<T extends keyof ComponentThemesProps>(name: T, props: ComponentThemesProps[T], useDefaultVariants?: boolean): string;
|
|
1125
1143
|
|
|
@@ -1150,9 +1168,9 @@ declare const usePreventBodyScroll: (enabled?: boolean) => void;
|
|
|
1150
1168
|
*/
|
|
1151
1169
|
declare const useRootAriaHidden: (hidden: boolean) => void;
|
|
1152
1170
|
|
|
1153
|
-
type Args = null | undefined | boolean | string;
|
|
1171
|
+
type Args = null | undefined | boolean | string | unknown;
|
|
1154
1172
|
declare const classnames: (...args: Args[]) => string | undefined;
|
|
1155
1173
|
|
|
1156
1174
|
declare const momotaro: Theme;
|
|
1157
1175
|
|
|
1158
|
-
export { BlocksProvider, type BlocksProviderProps, Box, type BoxProps, Button, type ButtonProps, Checkbox, type CheckboxProps, Dialog, type DialogProps, Divider, type DividerProps, Heading, type HeadingProps, Inline, type InlineProps, Input, type InputProps, Label, type LabelProps, Link, type LinkProps, Portal, type PortalProps, Progress, type ProgressProps, Radio, type RadioProps, Select, type SelectProps, Slider, type SliderProps,
|
|
1176
|
+
export { BlocksProvider, type BlocksProviderProps, Box, type BoxProps, Button, type ButtonProps, Checkbox, type CheckboxProps, Dialog, type DialogProps, Divider, type DividerProps, Heading, type HeadingProps, Inline, type InlineProps, Input, type InputProps, Label, type LabelProps, Link, type LinkProps, Portal, type PortalProps, Progress, type ProgressProps, Radio, type RadioProps, Select, type SelectProps, Slider, type SliderProps, Spinner, type SpinnerProps, Stack, type StackProps, Switch, type SwitchProps, Text, type TextProps, type ThemeComponentsStyles, type ThemeTokens, Tooltip, type TooltipProps, atoms, breakpointQuery, classnames, createAsChildTemplate, makeComponentTheme, makeTheme, momotaro, style, useComponentStyleDefaultProps, useComponentStyles, useIsomorphicLayoutEffect, useKeyboard, usePreventBodyScroll, useRootAriaHidden, vars };
|
|
@@ -88,20 +88,6 @@ const classnames = (...args) => {
|
|
|
88
88
|
const className = args.filter((arg) => arg && typeof arg === "string").join(" ");
|
|
89
89
|
return className || void 0;
|
|
90
90
|
};
|
|
91
|
-
function setRef(ref, value) {
|
|
92
|
-
if (typeof ref === "function") {
|
|
93
|
-
ref(value);
|
|
94
|
-
} else if (ref !== null && ref !== void 0) {
|
|
95
|
-
ref.current = value;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
function composeRefs(...refs) {
|
|
99
|
-
return (node) => {
|
|
100
|
-
for (const ref of refs) {
|
|
101
|
-
setRef(ref, node);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
91
|
function mergeProps(slotProps, childProps) {
|
|
106
92
|
const overrideProps = {};
|
|
107
93
|
for (const propName in childProps) {
|
|
@@ -122,82 +108,81 @@ function mergeProps(slotProps, childProps) {
|
|
|
122
108
|
} else if (propName === "style") {
|
|
123
109
|
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
124
110
|
} else if (propName === "className") {
|
|
125
|
-
overrideProps[propName] =
|
|
111
|
+
overrideProps[propName] = classnames(slotPropValue, childPropValue);
|
|
126
112
|
} else {
|
|
127
113
|
overrideProps[propName] = childPropValue;
|
|
128
114
|
}
|
|
129
115
|
}
|
|
130
116
|
return { ...slotProps, ...overrideProps };
|
|
131
117
|
}
|
|
132
|
-
function
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
118
|
+
function setRef(ref, value) {
|
|
119
|
+
if (typeof ref === "function") {
|
|
120
|
+
ref(value);
|
|
121
|
+
} else if (ref !== null && ref !== void 0) {
|
|
122
|
+
ref.current = value;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function composeRefs(...refs) {
|
|
126
|
+
return (node) => {
|
|
127
|
+
for (const ref of refs) {
|
|
128
|
+
setRef(ref, node);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function createAsChildTemplate(defaultElement) {
|
|
133
|
+
const Tag = defaultElement;
|
|
134
|
+
const Template2 = react.forwardRef(function Template22({ asChild, children, ...rootProps }, ref) {
|
|
136
135
|
if (!asChild) {
|
|
137
|
-
|
|
136
|
+
const tagProps = { ref, ...rootProps };
|
|
137
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Tag, { ...tagProps, children });
|
|
138
138
|
}
|
|
139
139
|
const childrenArray = react.Children.toArray(children);
|
|
140
|
-
const
|
|
140
|
+
const slotIndex = childrenArray.findIndex((child) => {
|
|
141
141
|
if (!react.isValidElement(child)) {
|
|
142
142
|
return false;
|
|
143
143
|
}
|
|
144
|
-
return child.type === Slot;
|
|
144
|
+
return child.type === Slot$1;
|
|
145
145
|
});
|
|
146
|
+
const slot = childrenArray[slotIndex];
|
|
146
147
|
if (!slot) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
if (process.env.NODE_ENV === "development") {
|
|
150
|
-
console.warn("Slottable: First child is not a valid React element");
|
|
151
|
-
}
|
|
152
|
-
return null;
|
|
148
|
+
if (process.env.NODE_ENV === "development") {
|
|
149
|
+
console.error("Template: No Slot provided");
|
|
153
150
|
}
|
|
154
|
-
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
return react.cloneElement(
|
|
158
|
-
Slot2,
|
|
159
|
-
{
|
|
160
|
-
...mergeProps(slotProps, Slot2.props),
|
|
161
|
-
ref: composeRefs(ref, Slot2.ref)
|
|
162
|
-
},
|
|
163
|
-
Slot2.props.children
|
|
164
|
-
);
|
|
151
|
+
return null;
|
|
165
152
|
}
|
|
166
153
|
if (!react.isValidElement(slot) || !react.isValidElement(slot.props.children)) {
|
|
167
154
|
return null;
|
|
168
155
|
}
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
return child;
|
|
172
|
-
}
|
|
173
|
-
if (child.type === Slot) {
|
|
174
|
-
return slot.props.children.props.children;
|
|
175
|
-
}
|
|
176
|
-
return child;
|
|
177
|
-
});
|
|
156
|
+
const nextChildren = [...childrenArray];
|
|
157
|
+
nextChildren[slotIndex] = slot.props.children.props.children;
|
|
178
158
|
return react.cloneElement(
|
|
179
159
|
slot.props.children,
|
|
180
160
|
{
|
|
181
|
-
...mergeProps(
|
|
161
|
+
...mergeProps(rootProps, slot.props.children.props),
|
|
182
162
|
ref: composeRefs(ref, slot.props.children.ref)
|
|
183
163
|
},
|
|
184
|
-
|
|
164
|
+
nextChildren
|
|
185
165
|
);
|
|
186
|
-
}
|
|
187
|
-
return
|
|
166
|
+
});
|
|
167
|
+
return {
|
|
168
|
+
Template: Template2,
|
|
169
|
+
Slot: Slot$1
|
|
170
|
+
};
|
|
188
171
|
}
|
|
189
|
-
const Slot = ({ children }) =>
|
|
190
|
-
|
|
172
|
+
const Slot$1 = ({ children }) => {
|
|
173
|
+
return children;
|
|
174
|
+
};
|
|
175
|
+
const { Template, Slot } = createAsChildTemplate("div");
|
|
191
176
|
const Box = react.forwardRef(function Box2({ asChild, className, children, ...restProps }, ref) {
|
|
192
177
|
const [atomsProps, otherProps] = styles_lib_utils_atomProps_cjs.getAtomsAndProps(restProps);
|
|
193
178
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
194
|
-
|
|
179
|
+
Template,
|
|
195
180
|
{
|
|
196
181
|
ref,
|
|
197
182
|
asChild,
|
|
198
183
|
className: classnames(className, styles_lib_css_atoms_sprinkles_css_cjs.atoms(atomsProps)),
|
|
199
184
|
...otherProps,
|
|
200
|
-
children
|
|
185
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Slot, { children })
|
|
201
186
|
}
|
|
202
187
|
);
|
|
203
188
|
});
|
|
@@ -218,10 +203,9 @@ const Divider = ({ className, color, ...restProps }) => {
|
|
|
218
203
|
exports.BlocksProviderContext = BlocksProviderContext;
|
|
219
204
|
exports.Box = Box;
|
|
220
205
|
exports.Divider = Divider;
|
|
221
|
-
exports.Slot = Slot;
|
|
222
206
|
exports.classnames = classnames;
|
|
223
207
|
exports.composeRefs = composeRefs;
|
|
224
|
-
exports.
|
|
208
|
+
exports.createAsChildTemplate = createAsChildTemplate;
|
|
225
209
|
exports.useComponentStyleDefaultProps = useComponentStyleDefaultProps;
|
|
226
210
|
exports.useComponentStyles = useComponentStyles;
|
|
227
211
|
exports.useTheme = useTheme;
|
|
@@ -87,20 +87,6 @@ const classnames = (...args) => {
|
|
|
87
87
|
const className = args.filter((arg) => arg && typeof arg === "string").join(" ");
|
|
88
88
|
return className || void 0;
|
|
89
89
|
};
|
|
90
|
-
function setRef(ref, value) {
|
|
91
|
-
if (typeof ref === "function") {
|
|
92
|
-
ref(value);
|
|
93
|
-
} else if (ref !== null && ref !== void 0) {
|
|
94
|
-
ref.current = value;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function composeRefs(...refs) {
|
|
98
|
-
return (node) => {
|
|
99
|
-
for (const ref of refs) {
|
|
100
|
-
setRef(ref, node);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
90
|
function mergeProps(slotProps, childProps) {
|
|
105
91
|
const overrideProps = {};
|
|
106
92
|
for (const propName in childProps) {
|
|
@@ -121,82 +107,81 @@ function mergeProps(slotProps, childProps) {
|
|
|
121
107
|
} else if (propName === "style") {
|
|
122
108
|
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
123
109
|
} else if (propName === "className") {
|
|
124
|
-
overrideProps[propName] =
|
|
110
|
+
overrideProps[propName] = classnames(slotPropValue, childPropValue);
|
|
125
111
|
} else {
|
|
126
112
|
overrideProps[propName] = childPropValue;
|
|
127
113
|
}
|
|
128
114
|
}
|
|
129
115
|
return { ...slotProps, ...overrideProps };
|
|
130
116
|
}
|
|
131
|
-
function
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
117
|
+
function setRef(ref, value) {
|
|
118
|
+
if (typeof ref === "function") {
|
|
119
|
+
ref(value);
|
|
120
|
+
} else if (ref !== null && ref !== void 0) {
|
|
121
|
+
ref.current = value;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function composeRefs(...refs) {
|
|
125
|
+
return (node) => {
|
|
126
|
+
for (const ref of refs) {
|
|
127
|
+
setRef(ref, node);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function createAsChildTemplate(defaultElement) {
|
|
132
|
+
const Tag = defaultElement;
|
|
133
|
+
const Template2 = forwardRef(function Template22({ asChild, children, ...rootProps }, ref) {
|
|
135
134
|
if (!asChild) {
|
|
136
|
-
|
|
135
|
+
const tagProps = { ref, ...rootProps };
|
|
136
|
+
return /* @__PURE__ */ jsx(Tag, { ...tagProps, children });
|
|
137
137
|
}
|
|
138
138
|
const childrenArray = Children.toArray(children);
|
|
139
|
-
const
|
|
139
|
+
const slotIndex = childrenArray.findIndex((child) => {
|
|
140
140
|
if (!isValidElement(child)) {
|
|
141
141
|
return false;
|
|
142
142
|
}
|
|
143
|
-
return child.type === Slot;
|
|
143
|
+
return child.type === Slot$1;
|
|
144
144
|
});
|
|
145
|
+
const slot = childrenArray[slotIndex];
|
|
145
146
|
if (!slot) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
if (process.env.NODE_ENV === "development") {
|
|
149
|
-
console.warn("Slottable: First child is not a valid React element");
|
|
150
|
-
}
|
|
151
|
-
return null;
|
|
147
|
+
if (process.env.NODE_ENV === "development") {
|
|
148
|
+
console.error("Template: No Slot provided");
|
|
152
149
|
}
|
|
153
|
-
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
return cloneElement(
|
|
157
|
-
Slot2,
|
|
158
|
-
{
|
|
159
|
-
...mergeProps(slotProps, Slot2.props),
|
|
160
|
-
ref: composeRefs(ref, Slot2.ref)
|
|
161
|
-
},
|
|
162
|
-
Slot2.props.children
|
|
163
|
-
);
|
|
150
|
+
return null;
|
|
164
151
|
}
|
|
165
152
|
if (!isValidElement(slot) || !isValidElement(slot.props.children)) {
|
|
166
153
|
return null;
|
|
167
154
|
}
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
return child;
|
|
171
|
-
}
|
|
172
|
-
if (child.type === Slot) {
|
|
173
|
-
return slot.props.children.props.children;
|
|
174
|
-
}
|
|
175
|
-
return child;
|
|
176
|
-
});
|
|
155
|
+
const nextChildren = [...childrenArray];
|
|
156
|
+
nextChildren[slotIndex] = slot.props.children.props.children;
|
|
177
157
|
return cloneElement(
|
|
178
158
|
slot.props.children,
|
|
179
159
|
{
|
|
180
|
-
...mergeProps(
|
|
160
|
+
...mergeProps(rootProps, slot.props.children.props),
|
|
181
161
|
ref: composeRefs(ref, slot.props.children.ref)
|
|
182
162
|
},
|
|
183
|
-
|
|
163
|
+
nextChildren
|
|
184
164
|
);
|
|
185
|
-
}
|
|
186
|
-
return
|
|
165
|
+
});
|
|
166
|
+
return {
|
|
167
|
+
Template: Template2,
|
|
168
|
+
Slot: Slot$1
|
|
169
|
+
};
|
|
187
170
|
}
|
|
188
|
-
const Slot = ({ children }) =>
|
|
189
|
-
|
|
171
|
+
const Slot$1 = ({ children }) => {
|
|
172
|
+
return children;
|
|
173
|
+
};
|
|
174
|
+
const { Template, Slot } = createAsChildTemplate("div");
|
|
190
175
|
const Box = forwardRef(function Box2({ asChild, className, children, ...restProps }, ref) {
|
|
191
176
|
const [atomsProps, otherProps] = getAtomsAndProps(restProps);
|
|
192
177
|
return /* @__PURE__ */ jsx(
|
|
193
|
-
|
|
178
|
+
Template,
|
|
194
179
|
{
|
|
195
180
|
ref,
|
|
196
181
|
asChild,
|
|
197
182
|
className: classnames(className, atoms(atomsProps)),
|
|
198
183
|
...otherProps,
|
|
199
|
-
children
|
|
184
|
+
children: /* @__PURE__ */ jsx(Slot, { children })
|
|
200
185
|
}
|
|
201
186
|
);
|
|
202
187
|
});
|
|
@@ -218,10 +203,9 @@ export {
|
|
|
218
203
|
BlocksProviderContext,
|
|
219
204
|
Box,
|
|
220
205
|
Divider,
|
|
221
|
-
Slot,
|
|
222
206
|
classnames,
|
|
223
207
|
composeRefs,
|
|
224
|
-
|
|
208
|
+
createAsChildTemplate,
|
|
225
209
|
useComponentStyleDefaultProps,
|
|
226
210
|
useComponentStyles,
|
|
227
211
|
useTheme
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const jsxRuntime = require("react/jsx-runtime");
|
|
3
3
|
const react = require("react");
|
|
4
|
-
const styles_lib_utils_atomProps_cjs = require("../../../lib/utils/atom-props.cjs");
|
|
5
4
|
const styles_components_display_Divider_Divider_cjs = require("../../display/Divider/Divider.cjs");
|
|
5
|
+
const styles_lib_utils_atomProps_cjs = require("../../../lib/utils/atom-props.cjs");
|
|
6
6
|
const styles_components_form_Button_Button_css_cjs = require("./Button.css.cjs");
|
|
7
7
|
const styles_lib_css_atoms_sprinkles_css_cjs = require("../../../lib/css/atoms/sprinkles.css.cjs");
|
|
8
8
|
const Spinner = ({ className, size, color, ...restProps }) => {
|
|
9
9
|
const spinnerClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("spinner", { base: true, variants: { size, color } });
|
|
10
10
|
return /* @__PURE__ */ jsxRuntime.jsx(styles_components_display_Divider_Divider_cjs.Box, { color, className: styles_components_display_Divider_Divider_cjs.classnames(spinnerClassName, className), ...restProps });
|
|
11
11
|
};
|
|
12
|
-
const
|
|
12
|
+
const { Template, Slot } = styles_components_display_Divider_Divider_cjs.createAsChildTemplate("button");
|
|
13
13
|
const Button = react.forwardRef(function Button2({
|
|
14
14
|
children,
|
|
15
15
|
className,
|
|
@@ -35,7 +35,7 @@ const Button = react.forwardRef(function Button2({
|
|
|
35
35
|
});
|
|
36
36
|
const [atomsProps, otherProps] = styles_lib_utils_atomProps_cjs.getAtomsAndProps(restProps);
|
|
37
37
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
38
|
-
|
|
38
|
+
Template,
|
|
39
39
|
{
|
|
40
40
|
ref,
|
|
41
41
|
asChild,
|
|
@@ -45,7 +45,7 @@ const Button = react.forwardRef(function Button2({
|
|
|
45
45
|
children: [
|
|
46
46
|
startSlot && /* @__PURE__ */ jsxRuntime.jsx("div", { children: startSlot }),
|
|
47
47
|
loading && /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size }),
|
|
48
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
48
|
+
/* @__PURE__ */ jsxRuntime.jsx(Slot, { children }),
|
|
49
49
|
endSlot && /* @__PURE__ */ jsxRuntime.jsx("div", { children: endSlot })
|
|
50
50
|
]
|
|
51
51
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
|
+
import { useComponentStyles, Box, classnames, createAsChildTemplate } from "../../display/Divider/Divider.mjs";
|
|
3
4
|
import { getAtomsAndProps } from "../../../lib/utils/atom-props.mjs";
|
|
4
|
-
import { useComponentStyles, Box, classnames, createSlottable, Slot } from "../../display/Divider/Divider.mjs";
|
|
5
5
|
import { buttonReset } from "./Button.css.mjs";
|
|
6
6
|
import { atoms } from "../../../lib/css/atoms/sprinkles.css.mjs";
|
|
7
7
|
const Spinner = ({ className, size, color, ...restProps }) => {
|
|
8
8
|
const spinnerClassName = useComponentStyles("spinner", { base: true, variants: { size, color } });
|
|
9
9
|
return /* @__PURE__ */ jsx(Box, { color, className: classnames(spinnerClassName, className), ...restProps });
|
|
10
10
|
};
|
|
11
|
-
const
|
|
11
|
+
const { Template, Slot } = createAsChildTemplate("button");
|
|
12
12
|
const Button = forwardRef(function Button2({
|
|
13
13
|
children,
|
|
14
14
|
className,
|
|
@@ -34,7 +34,7 @@ const Button = forwardRef(function Button2({
|
|
|
34
34
|
});
|
|
35
35
|
const [atomsProps, otherProps] = getAtomsAndProps(restProps);
|
|
36
36
|
return /* @__PURE__ */ jsxs(
|
|
37
|
-
|
|
37
|
+
Template,
|
|
38
38
|
{
|
|
39
39
|
ref,
|
|
40
40
|
asChild,
|