@blockle/blocks-react 1.1.2 → 1.3.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/components/accessibility/VisuallyHidden/VisuallyHidden.stories.d.ts +1 -1
- package/dist/components/display/Divider/Divider.js +2 -2
- package/dist/components/display/Divider/Divider.stories.d.ts +1 -1
- package/dist/components/feedback/Progress/Progress.stories.d.ts +1 -1
- package/dist/components/feedback/Spinner/Spinner.js +1 -0
- package/dist/components/feedback/Spinner/Spinner.stories.d.ts +1 -1
- package/dist/components/feedback/Spinner/Spinner.test.d.ts +1 -0
- package/dist/components/form/Button/Button.js +2 -2
- package/dist/components/form/Button/Button.stories.d.ts +1 -1
- package/dist/components/form/Checkbox/Checkbox.js +1 -1
- package/dist/components/form/Checkbox/Checkbox.stories.d.ts +1 -1
- package/dist/components/form/Input/Input.js +2 -2
- package/dist/components/form/Input/Input.stories.d.ts +1 -1
- package/dist/components/form/Label/Label.stories.d.ts +1 -1
- package/dist/components/form/Radio/Radio.js +1 -1
- package/dist/components/form/Radio/Radio.stories.d.ts +1 -1
- package/dist/components/form/Radio/RadioGroup.test.d.ts +1 -0
- package/dist/components/form/Select/Select.js +1 -1
- package/dist/components/form/Select/Select.stories.d.ts +1 -1
- package/dist/components/form/Slider/Slider.d.ts +0 -1
- package/dist/components/form/Slider/Slider.js +3 -4
- package/dist/components/form/Slider/Slider.stories.d.ts +1 -1
- package/dist/components/form/Switch/Switch.js +1 -1
- package/dist/components/form/Switch/Switch.stories.d.ts +1 -1
- package/dist/components/layout/Box/Box.stories.d.ts +1 -1
- package/dist/components/layout/Inline/Inline.stories.d.ts +1 -1
- package/dist/components/layout/Stack/Stack.stories.d.ts +1 -1
- package/dist/components/navigation/Link/Link.stories.d.ts +1 -1
- package/dist/components/overlay/Dialog/Dialog.js +5 -5
- package/dist/components/overlay/Dialog/Dialog.stories.d.ts +1 -1
- package/dist/components/overlay/Popover/Popover.js +2 -2
- package/dist/components/overlay/Popover/Popover.stories.d.ts +1 -1
- package/dist/components/overlay/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/overlay/Tooltip/Tooltip.stories.d.ts +1 -1
- package/dist/components/typography/Heading/Heading.js +1 -1
- package/dist/components/typography/Heading/heading.stories.d.ts +1 -1
- package/dist/components/typography/Text/Text.js +1 -1
- package/dist/components/typography/Text/Text.stories.d.ts +1 -1
- package/dist/hooks/useControlledValue/useControlledValue.d.ts +5 -0
- package/dist/hooks/useControlledValue/useControlledValue.js +7 -11
- package/dist/hooks/useControlledValue/useControlledValue.test.d.ts +1 -0
- package/dist/index.d.ts +28 -27
- package/package.json +8 -14
- package/dist/components/accessibility/VisuallyHidden/VisuallyHidden.cjs +0 -20
- package/dist/components/accessibility/VisuallyHidden/index.d.ts +0 -1
- package/dist/components/accessibility/VisuallyHidden/visually-hidden.css.cjs +0 -16
- package/dist/components/display/Divider/Divider.cjs +0 -28
- package/dist/components/display/Divider/divider.css.cjs +0 -16
- package/dist/components/display/Divider/index.d.ts +0 -1
- package/dist/components/feedback/Progress/Progress.cjs +0 -55
- package/dist/components/feedback/Progress/index.d.ts +0 -1
- package/dist/components/feedback/Spinner/Spinner.cjs +0 -27
- package/dist/components/feedback/Spinner/index.d.ts +0 -1
- package/dist/components/form/Button/Button.cjs +0 -58
- package/dist/components/form/Button/Button.css.cjs +0 -16
- package/dist/components/form/Button/index.d.ts +0 -1
- package/dist/components/form/Checkbox/Checkbox.cjs +0 -80
- package/dist/components/form/Checkbox/checkbox.css.cjs +0 -32
- package/dist/components/form/Checkbox/index.d.ts +0 -1
- package/dist/components/form/Input/Input.cjs +0 -52
- package/dist/components/form/Input/index.d.ts +0 -1
- package/dist/components/form/Input/input.css.cjs +0 -21
- package/dist/components/form/Label/Label.cjs +0 -30
- package/dist/components/form/Label/index.d.ts +0 -1
- package/dist/components/form/Radio/Radio.cjs +0 -50
- package/dist/components/form/Radio/index.d.ts +0 -2
- package/dist/components/form/Radio/radio.css.cjs +0 -32
- package/dist/components/form/Select/Select.cjs +0 -73
- package/dist/components/form/Select/index.d.ts +0 -1
- package/dist/components/form/Select/select.css.cjs +0 -38
- package/dist/components/form/Slider/Slider.cjs +0 -139
- package/dist/components/form/Slider/index.d.ts +0 -1
- package/dist/components/form/Slider/slider.css.cjs +0 -75
- package/dist/components/form/Slider/usePointerProgress.cjs +0 -46
- package/dist/components/form/Switch/Switch.cjs +0 -73
- package/dist/components/form/Switch/index.d.ts +0 -1
- package/dist/components/form/Switch/switch.css.cjs +0 -27
- package/dist/components/layout/Box/Box.cjs +0 -26
- package/dist/components/layout/Box/index.d.ts +0 -1
- package/dist/components/layout/Inline/Inline.cjs +0 -30
- package/dist/components/layout/Inline/index.d.ts +0 -1
- package/dist/components/layout/Stack/Stack.cjs +0 -27
- package/dist/components/layout/Stack/index.d.ts +0 -1
- package/dist/components/navigation/Link/Link.cjs +0 -33
- package/dist/components/navigation/Link/index.d.ts +0 -1
- package/dist/components/overlay/Dialog/Dialog.cjs +0 -82
- package/dist/components/overlay/Dialog/dialog.css.cjs +0 -22
- package/dist/components/overlay/Dialog/dialogHelper.cjs +0 -21
- package/dist/components/overlay/Dialog/index.d.ts +0 -1
- package/dist/components/overlay/Popover/Popover.cjs +0 -106
- package/dist/components/overlay/Popover/index.d.ts +0 -1
- package/dist/components/overlay/Popover/popover-utils.cjs +0 -57
- package/dist/components/overlay/Portal/Portal.cjs +0 -15
- package/dist/components/overlay/Portal/index.d.ts +0 -1
- package/dist/components/overlay/Tooltip/Tooltip.cjs +0 -73
- package/dist/components/overlay/Tooltip/index.d.ts +0 -1
- package/dist/components/providers/BlocksProvider/BlocksProvider.cjs +0 -35
- package/dist/components/providers/BlocksProvider/context.cjs +0 -5
- package/dist/components/providers/BlocksProvider/index.d.ts +0 -2
- package/dist/components/typography/Heading/Heading.cjs +0 -24
- package/dist/components/typography/Heading/heading.css.cjs +0 -16
- package/dist/components/typography/Heading/index.d.ts +0 -1
- package/dist/components/typography/Text/Text.cjs +0 -21
- package/dist/components/typography/Text/index.d.ts +0 -1
- package/dist/components/typography/Text/text.css.cjs +0 -16
- package/dist/hooks/useClickOutside/useClickOutside.cjs +0 -23
- package/dist/hooks/useComponentStyles/index.d.ts +0 -2
- package/dist/hooks/useComponentStyles/useComponentStyleDefaultProps.cjs +0 -12
- package/dist/hooks/useComponentStyles/useComponentStyles.cjs +0 -74
- package/dist/hooks/useControlledValue/index.d.ts +0 -1
- package/dist/hooks/useControlledValue/useControlledValue.cjs +0 -33
- package/dist/hooks/useIsomorphicLayoutEffect/index.d.ts +0 -1
- package/dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs +0 -6
- package/dist/hooks/useKeyboard/index.d.ts +0 -1
- package/dist/hooks/useKeyboard/useKeyboard.cjs +0 -21
- package/dist/hooks/useLayer/index.d.ts +0 -1
- package/dist/hooks/usePreventBodyScroll/index.d.ts +0 -1
- package/dist/hooks/usePreventBodyScroll/usePreventBodyScroll.cjs +0 -31
- package/dist/hooks/useRestoreFocus/index.d.ts +0 -1
- package/dist/hooks/useRestoreFocus/useRestoreFocus.cjs +0 -19
- package/dist/hooks/useTheme/index.d.ts +0 -1
- package/dist/hooks/useTheme/useTheme.cjs +0 -13
- package/dist/hooks/useVisibilityState/index.d.ts +0 -1
- package/dist/index.cjs +0 -58
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
-
const blocksCore = require("@blockle/blocks-core");
|
|
6
|
-
const react = require("react");
|
|
7
|
-
const useControlledValue = require("../../../hooks/useControlledValue/useControlledValue.cjs");
|
|
8
|
-
const slider_css = require("./slider.css.cjs");
|
|
9
|
-
const usePointerProgress = require("./usePointerProgress.cjs");
|
|
10
|
-
const useComponentStyles = require("../../../hooks/useComponentStyles/useComponentStyles.cjs");
|
|
11
|
-
const usableKeys = /* @__PURE__ */ new Set([
|
|
12
|
-
"ArrowLeft",
|
|
13
|
-
"ArrowRight",
|
|
14
|
-
"ArrowUp",
|
|
15
|
-
"ArrowDown",
|
|
16
|
-
"Home",
|
|
17
|
-
"End",
|
|
18
|
-
"PageUp",
|
|
19
|
-
"PageDown",
|
|
20
|
-
"Home",
|
|
21
|
-
"End"
|
|
22
|
-
]);
|
|
23
|
-
const Slider = ({
|
|
24
|
-
min = 0,
|
|
25
|
-
max = 100,
|
|
26
|
-
step = 0.01,
|
|
27
|
-
orientation = "horizontal",
|
|
28
|
-
defaultValue = 0,
|
|
29
|
-
onChange,
|
|
30
|
-
value,
|
|
31
|
-
name,
|
|
32
|
-
size,
|
|
33
|
-
colorScheme,
|
|
34
|
-
disabled,
|
|
35
|
-
precision = 2,
|
|
36
|
-
...restProps
|
|
37
|
-
}) => {
|
|
38
|
-
const baseClass = useComponentStyles.useComponentStyles("slider", {
|
|
39
|
-
base: true,
|
|
40
|
-
variants: { size, colorScheme, disabled }
|
|
41
|
-
});
|
|
42
|
-
const trackClass = useComponentStyles.useComponentStyles("slider", { track: true }, false);
|
|
43
|
-
const filledTrackClass = useComponentStyles.useComponentStyles(
|
|
44
|
-
"slider",
|
|
45
|
-
{ filledTrack: true },
|
|
46
|
-
false
|
|
47
|
-
);
|
|
48
|
-
const thumbClass = useComponentStyles.useComponentStyles("slider", { thumb: true }, false);
|
|
49
|
-
const containerRef = react.useRef(null);
|
|
50
|
-
const [currentValue, setValue] = useControlledValue.useControlledValue({
|
|
51
|
-
defaultValue,
|
|
52
|
-
value,
|
|
53
|
-
onChange,
|
|
54
|
-
transformValue: (value2) => blocksCore.roundToPrecision(blocksCore.getBoundValue(value2, min, max, step), precision)
|
|
55
|
-
});
|
|
56
|
-
usePointerProgress.usePointerProgress({
|
|
57
|
-
container: containerRef,
|
|
58
|
-
orientation,
|
|
59
|
-
onChange(progress) {
|
|
60
|
-
if (orientation === "vertical") {
|
|
61
|
-
progress = 1 - progress;
|
|
62
|
-
}
|
|
63
|
-
setValue(max * progress);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
const onKeyDown = react.useCallback(
|
|
67
|
-
(event) => {
|
|
68
|
-
if (!usableKeys.has(event.key)) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
event.preventDefault();
|
|
72
|
-
event.stopPropagation();
|
|
73
|
-
const specialKey = ["PageUp", "PageDown"];
|
|
74
|
-
const stepModifier = event.shiftKey || specialKey.includes(event.key) ? (max - min) / 10 : step;
|
|
75
|
-
if (event.key === "ArrowLeft" || event.key === "ArrowDown" || event.key === "PageDown") {
|
|
76
|
-
return setValue(currentValue - stepModifier);
|
|
77
|
-
}
|
|
78
|
-
if (event.key === "ArrowRight" || event.key === "ArrowUp" || event.key === "PageUp") {
|
|
79
|
-
return setValue(currentValue + stepModifier);
|
|
80
|
-
}
|
|
81
|
-
if (event.key === "Home") {
|
|
82
|
-
return setValue(min);
|
|
83
|
-
}
|
|
84
|
-
if (event.key === "End") {
|
|
85
|
-
return setValue(max);
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
[max, min, step, setValue, currentValue]
|
|
89
|
-
);
|
|
90
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
91
|
-
"div",
|
|
92
|
-
{
|
|
93
|
-
ref: containerRef,
|
|
94
|
-
className: blocksCore.classnames(
|
|
95
|
-
slider_css.container,
|
|
96
|
-
orientation === "vertical" ? slider_css.containerVertical : "",
|
|
97
|
-
baseClass
|
|
98
|
-
),
|
|
99
|
-
children: [
|
|
100
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: blocksCore.classnames(slider_css.track, trackClass), children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
101
|
-
"div",
|
|
102
|
-
{
|
|
103
|
-
className: blocksCore.classnames(slider_css.filledTrack, filledTrackClass),
|
|
104
|
-
style: {
|
|
105
|
-
inlineSize: `${currentValue / max * 100}%`
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
) }),
|
|
109
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
110
|
-
"button",
|
|
111
|
-
{
|
|
112
|
-
type: "button",
|
|
113
|
-
className: blocksCore.classnames(slider_css.thumb, thumbClass),
|
|
114
|
-
role: "slider",
|
|
115
|
-
"aria-valuemin": min,
|
|
116
|
-
"aria-valuemax": max,
|
|
117
|
-
"aria-valuenow": currentValue,
|
|
118
|
-
"aria-orientation": orientation,
|
|
119
|
-
style: {
|
|
120
|
-
[orientation === "horizontal" ? "insetInlineStart" : "insetInlineEnd"]: `${currentValue / max * 100}%`
|
|
121
|
-
},
|
|
122
|
-
onKeyDown,
|
|
123
|
-
...restProps
|
|
124
|
-
}
|
|
125
|
-
),
|
|
126
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
127
|
-
"input",
|
|
128
|
-
{
|
|
129
|
-
type: "hidden",
|
|
130
|
-
disabled,
|
|
131
|
-
name,
|
|
132
|
-
value: currentValue
|
|
133
|
-
}
|
|
134
|
-
)
|
|
135
|
-
]
|
|
136
|
-
}
|
|
137
|
-
);
|
|
138
|
-
};
|
|
139
|
-
exports.Slider = Slider;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Slider, type SliderProps } from './Slider';
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const fileScope = require("@vanilla-extract/css/fileScope");
|
|
4
|
-
const blocksCore = require("@blockle/blocks-core");
|
|
5
|
-
const css = require("@vanilla-extract/css");
|
|
6
|
-
fileScope.setFileScope("src/components/form/Slider/slider.css.ts", "@blockle/blocks-react");
|
|
7
|
-
const container = css.style({
|
|
8
|
-
"@layer": {
|
|
9
|
-
[blocksCore.blocksLayerComponent]: {
|
|
10
|
-
position: "relative",
|
|
11
|
-
writingMode: "horizontal-tb"
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
|
-
const containerVertical = css.style({
|
|
16
|
-
"@layer": {
|
|
17
|
-
[blocksCore.blocksLayerComponent]: {
|
|
18
|
-
writingMode: "vertical-lr"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const track = css.style({
|
|
23
|
-
"@layer": {
|
|
24
|
-
[blocksCore.blocksLayerComponent]: {
|
|
25
|
-
cursor: "pointer",
|
|
26
|
-
position: "absolute",
|
|
27
|
-
inlineSize: "100%",
|
|
28
|
-
insetBlockStart: "50%",
|
|
29
|
-
transform: "translateY(-50%)",
|
|
30
|
-
selectors: {
|
|
31
|
-
[`${containerVertical} &`]: {
|
|
32
|
-
transform: "translateX(-50%)"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
const filledTrack = css.style({
|
|
39
|
-
"@layer": {
|
|
40
|
-
[blocksCore.blocksLayerComponent]: {
|
|
41
|
-
position: "absolute",
|
|
42
|
-
blockSize: "100%",
|
|
43
|
-
borderRadius: "inherit",
|
|
44
|
-
selectors: {
|
|
45
|
-
[`${containerVertical} &`]: {
|
|
46
|
-
insetInlineEnd: "0%"
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
const thumb = css.style({
|
|
53
|
-
"@layer": {
|
|
54
|
-
[blocksCore.blocksLayerComponent]: {
|
|
55
|
-
cursor: "pointer",
|
|
56
|
-
position: "absolute",
|
|
57
|
-
blockSize: "100%",
|
|
58
|
-
insetBlockStart: "50%",
|
|
59
|
-
transform: "translate(-50%, -50%)",
|
|
60
|
-
touchAction: "none",
|
|
61
|
-
border: "none",
|
|
62
|
-
selectors: {
|
|
63
|
-
[`${containerVertical} &`]: {
|
|
64
|
-
transform: "translate(-50%, 50%)"
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
fileScope.endFileScope();
|
|
71
|
-
exports.container = container;
|
|
72
|
-
exports.containerVertical = containerVertical;
|
|
73
|
-
exports.filledTrack = filledTrack;
|
|
74
|
-
exports.thumb = thumb;
|
|
75
|
-
exports.track = track;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const react = require("react");
|
|
4
|
-
function getProgress(event, rect) {
|
|
5
|
-
const { clientX, clientY } = event;
|
|
6
|
-
const { width, height, left, top } = rect;
|
|
7
|
-
const x = (clientX - left) / width;
|
|
8
|
-
const y = (clientY - top) / height;
|
|
9
|
-
return [x, y];
|
|
10
|
-
}
|
|
11
|
-
function usePointerProgress({ container, orientation, onChange }) {
|
|
12
|
-
react.useEffect(() => {
|
|
13
|
-
const element = container.current;
|
|
14
|
-
function pointerdown(event) {
|
|
15
|
-
event.preventDefault();
|
|
16
|
-
event.stopPropagation();
|
|
17
|
-
if (!element) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const containerRect = element.getBoundingClientRect();
|
|
21
|
-
const axisIndex = orientation === "horizontal" ? 0 : 1;
|
|
22
|
-
const progress = getProgress(event, containerRect);
|
|
23
|
-
onChange(progress[axisIndex]);
|
|
24
|
-
const pointermove = (event2) => {
|
|
25
|
-
event2.preventDefault();
|
|
26
|
-
const progress2 = getProgress(event2, containerRect);
|
|
27
|
-
onChange(progress2[axisIndex]);
|
|
28
|
-
};
|
|
29
|
-
const pointerup = () => {
|
|
30
|
-
document.removeEventListener("pointermove", pointermove);
|
|
31
|
-
document.removeEventListener("pointerup", pointerup);
|
|
32
|
-
};
|
|
33
|
-
document.addEventListener("pointermove", pointermove);
|
|
34
|
-
document.addEventListener("pointerup", pointerup);
|
|
35
|
-
}
|
|
36
|
-
if (!element) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
element.addEventListener("pointerdown", pointerdown);
|
|
40
|
-
return () => {
|
|
41
|
-
element.removeEventListener("pointerdown", pointerdown);
|
|
42
|
-
};
|
|
43
|
-
}, [container, onChange, orientation]);
|
|
44
|
-
}
|
|
45
|
-
exports.getProgress = getProgress;
|
|
46
|
-
exports.usePointerProgress = usePointerProgress;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
-
const blocksCore = require("@blockle/blocks-core");
|
|
6
|
-
const react = require("react");
|
|
7
|
-
const switch_css = require("./switch.css.cjs");
|
|
8
|
-
const useComponentStyles = require("../../../hooks/useComponentStyles/useComponentStyles.cjs");
|
|
9
|
-
const Switch = ({
|
|
10
|
-
checked,
|
|
11
|
-
className,
|
|
12
|
-
defaultChecked,
|
|
13
|
-
onChange,
|
|
14
|
-
ref,
|
|
15
|
-
...restProps
|
|
16
|
-
}) => {
|
|
17
|
-
const [isChecked, setIsChecked] = react.useState(
|
|
18
|
-
defaultChecked || checked || false
|
|
19
|
-
);
|
|
20
|
-
const baseClassName = useComponentStyles.useComponentStyles("switch", { base: true });
|
|
21
|
-
const sliderClassName = useComponentStyles.useComponentStyles("switch", { slider: true }, false);
|
|
22
|
-
react.useEffect(() => {
|
|
23
|
-
if (checked !== void 0) {
|
|
24
|
-
setIsChecked(checked);
|
|
25
|
-
}
|
|
26
|
-
}, [checked]);
|
|
27
|
-
const toggle = react.useCallback(() => {
|
|
28
|
-
setIsChecked((checked2) => {
|
|
29
|
-
const newValue = !checked2;
|
|
30
|
-
if (onChange) {
|
|
31
|
-
onChange(newValue);
|
|
32
|
-
}
|
|
33
|
-
return newValue;
|
|
34
|
-
});
|
|
35
|
-
}, [onChange]);
|
|
36
|
-
const onChangeHandler = react.useCallback(
|
|
37
|
-
(event) => {
|
|
38
|
-
setIsChecked(event.target.checked);
|
|
39
|
-
if (onChange) {
|
|
40
|
-
onChange(event.target.checked);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
[onChange]
|
|
44
|
-
);
|
|
45
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
46
|
-
"div",
|
|
47
|
-
{
|
|
48
|
-
className: blocksCore.classnames(className, switch_css.container, baseClassName),
|
|
49
|
-
"data-checked": isChecked,
|
|
50
|
-
onClick: (event) => {
|
|
51
|
-
if (event.target.tagName === "INPUT") {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
toggle();
|
|
55
|
-
},
|
|
56
|
-
children: [
|
|
57
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
58
|
-
"input",
|
|
59
|
-
{
|
|
60
|
-
ref,
|
|
61
|
-
type: "checkbox",
|
|
62
|
-
className: switch_css.input,
|
|
63
|
-
checked: isChecked,
|
|
64
|
-
onChange: onChangeHandler,
|
|
65
|
-
...restProps
|
|
66
|
-
}
|
|
67
|
-
),
|
|
68
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: sliderClassName, "data-checked": isChecked })
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
) });
|
|
72
|
-
};
|
|
73
|
-
exports.Switch = Switch;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Switch, type SwitchProps } from './Switch';
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const fileScope = require("@vanilla-extract/css/fileScope");
|
|
4
|
-
const blocksCore = require("@blockle/blocks-core");
|
|
5
|
-
const css = require("@vanilla-extract/css");
|
|
6
|
-
fileScope.setFileScope("src/components/form/Switch/switch.css.ts", "@blockle/blocks-react");
|
|
7
|
-
const container = css.style({
|
|
8
|
-
"@layer": {
|
|
9
|
-
[blocksCore.blocksLayerComponent]: {
|
|
10
|
-
cursor: "pointer",
|
|
11
|
-
userSelect: "none",
|
|
12
|
-
position: "relative"
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
const input = css.style({
|
|
17
|
-
"@layer": {
|
|
18
|
-
[blocksCore.blocksLayerComponent]: {
|
|
19
|
-
opacity: 0,
|
|
20
|
-
maxBlockSize: 0,
|
|
21
|
-
maxInlineSize: 0
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
fileScope.endFileScope();
|
|
26
|
-
exports.container = container;
|
|
27
|
-
exports.input = input;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const blocksCore = require("@blockle/blocks-core");
|
|
5
|
-
const blocksReactSlot = require("@blockle/blocks-react-slot");
|
|
6
|
-
const [Template, Slot] = blocksReactSlot.createSlottable("div");
|
|
7
|
-
const Box = ({
|
|
8
|
-
asChild,
|
|
9
|
-
className,
|
|
10
|
-
children,
|
|
11
|
-
ref,
|
|
12
|
-
...restProps
|
|
13
|
-
}) => {
|
|
14
|
-
const [atomsProps, otherProps] = blocksCore.getAtomsAndProps(restProps);
|
|
15
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
16
|
-
Template,
|
|
17
|
-
{
|
|
18
|
-
ref,
|
|
19
|
-
asChild,
|
|
20
|
-
className: blocksCore.classnames(className, blocksCore.atoms(atomsProps)),
|
|
21
|
-
...otherProps,
|
|
22
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Slot, { children })
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
};
|
|
26
|
-
exports.Box = Box;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Box, type BoxProps } from './Box';
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const blocksCore = require("@blockle/blocks-core");
|
|
5
|
-
const Box = require("../Box/Box.cjs");
|
|
6
|
-
const Inline = ({
|
|
7
|
-
alignX,
|
|
8
|
-
alignY,
|
|
9
|
-
tag: Tag = "div",
|
|
10
|
-
children,
|
|
11
|
-
display = "flex",
|
|
12
|
-
spacing,
|
|
13
|
-
...props
|
|
14
|
-
}) => {
|
|
15
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
16
|
-
Box.Box,
|
|
17
|
-
{
|
|
18
|
-
asChild: true,
|
|
19
|
-
display,
|
|
20
|
-
gap: spacing,
|
|
21
|
-
flexDirection: "row",
|
|
22
|
-
justifyContent: alignX ? blocksCore.justifyContentMap[alignX] : void 0,
|
|
23
|
-
alignItems: alignY ? blocksCore.alignItemsMap[alignY] : void 0,
|
|
24
|
-
flexWrap: "wrap",
|
|
25
|
-
...props,
|
|
26
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Tag, { children })
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
exports.Inline = Inline;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Inline, type InlineProps } from './Inline';
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const blocksCore = require("@blockle/blocks-core");
|
|
5
|
-
const Box = require("../Box/Box.cjs");
|
|
6
|
-
const Stack = ({
|
|
7
|
-
tag: Tag = "div",
|
|
8
|
-
display = "flex",
|
|
9
|
-
children,
|
|
10
|
-
spacing,
|
|
11
|
-
alignX,
|
|
12
|
-
...restProps
|
|
13
|
-
}) => {
|
|
14
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
15
|
-
Box.Box,
|
|
16
|
-
{
|
|
17
|
-
asChild: true,
|
|
18
|
-
display,
|
|
19
|
-
gap: spacing,
|
|
20
|
-
flexDirection: "column",
|
|
21
|
-
alignItems: alignX ? blocksCore.alignItemsMap[alignX] : void 0,
|
|
22
|
-
...restProps,
|
|
23
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Tag, { children })
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
};
|
|
27
|
-
exports.Stack = Stack;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Stack, type StackProps } from './Stack';
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
-
const blocksCore = require("@blockle/blocks-core");
|
|
6
|
-
const blocksReactSlot = require("@blockle/blocks-react-slot");
|
|
7
|
-
const useComponentStyles = require("../../../hooks/useComponentStyles/useComponentStyles.cjs");
|
|
8
|
-
const [Template, Slot] = blocksReactSlot.createSlottable("a");
|
|
9
|
-
const Link = ({
|
|
10
|
-
asChild,
|
|
11
|
-
children,
|
|
12
|
-
className,
|
|
13
|
-
ref,
|
|
14
|
-
underline,
|
|
15
|
-
variant,
|
|
16
|
-
...restProps
|
|
17
|
-
}) => {
|
|
18
|
-
const linkClassName = useComponentStyles.useComponentStyles("link", {
|
|
19
|
-
base: true,
|
|
20
|
-
variants: { variant, underline }
|
|
21
|
-
});
|
|
22
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
23
|
-
Template,
|
|
24
|
-
{
|
|
25
|
-
asChild,
|
|
26
|
-
ref,
|
|
27
|
-
className: blocksCore.classnames(className, linkClassName),
|
|
28
|
-
...restProps,
|
|
29
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Slot, { children })
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
exports.Link = Link;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Link, type LinkProps } from './Link';
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
-
const blocksCore = require("@blockle/blocks-core");
|
|
6
|
-
const react = require("react");
|
|
7
|
-
const useClickOutside = require("../../../hooks/useClickOutside/useClickOutside.cjs");
|
|
8
|
-
const dialog_css = require("./dialog.css.cjs");
|
|
9
|
-
const dialogHelper = require("./dialogHelper.cjs");
|
|
10
|
-
const useComponentStyles = require("../../../hooks/useComponentStyles/useComponentStyles.cjs");
|
|
11
|
-
const useRestoreFocus = require("../../../hooks/useRestoreFocus/useRestoreFocus.cjs");
|
|
12
|
-
const usePreventBodyScroll = require("../../../hooks/usePreventBodyScroll/usePreventBodyScroll.cjs");
|
|
13
|
-
const useKeyboard = require("../../../hooks/useKeyboard/useKeyboard.cjs");
|
|
14
|
-
const useIsomorphicLayoutEffect = require("../../../hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs");
|
|
15
|
-
const Dialog = ({
|
|
16
|
-
children,
|
|
17
|
-
open,
|
|
18
|
-
className,
|
|
19
|
-
onRequestClose,
|
|
20
|
-
size,
|
|
21
|
-
...restProps
|
|
22
|
-
}) => {
|
|
23
|
-
const dialogRef = react.useRef(null);
|
|
24
|
-
const dialogClassName = useComponentStyles.useComponentStyles("dialog", {
|
|
25
|
-
dialog: true,
|
|
26
|
-
variants: { size }
|
|
27
|
-
});
|
|
28
|
-
const [enabled, setEnabled] = react.useState(true);
|
|
29
|
-
const [visible, setVisible] = react.useState(open);
|
|
30
|
-
useRestoreFocus.useRestoreFocus(open);
|
|
31
|
-
const isNested = dialogHelper.useNestedDialog(open);
|
|
32
|
-
usePreventBodyScroll.usePreventBodyScroll(open && !isNested);
|
|
33
|
-
const onEscape = react.useCallback(
|
|
34
|
-
(event) => {
|
|
35
|
-
event.preventDefault();
|
|
36
|
-
onRequestClose();
|
|
37
|
-
},
|
|
38
|
-
[onRequestClose]
|
|
39
|
-
);
|
|
40
|
-
useKeyboard.useKeyboard("Escape", onEscape, { enabled: open && enabled });
|
|
41
|
-
useClickOutside.useClickOutside(dialogRef, onRequestClose, { enabled: open && enabled });
|
|
42
|
-
useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
43
|
-
var _a;
|
|
44
|
-
if (open && visible) {
|
|
45
|
-
if (!dialogRef.current || !dialogRef.current.showModal) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
dialogRef.current.showModal();
|
|
49
|
-
} else if (open) {
|
|
50
|
-
setVisible(true);
|
|
51
|
-
} else {
|
|
52
|
-
if (!blocksCore.hasAnimationDuration(dialogRef.current)) {
|
|
53
|
-
setVisible(false);
|
|
54
|
-
}
|
|
55
|
-
if ((_a = dialogRef.current) == null ? void 0 : _a.close) {
|
|
56
|
-
dialogRef.current.close();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}, [open, visible]);
|
|
60
|
-
const onAnimationEnd = react.useCallback(() => {
|
|
61
|
-
if (!open) {
|
|
62
|
-
setVisible(false);
|
|
63
|
-
}
|
|
64
|
-
}, [open]);
|
|
65
|
-
if (!visible) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
const dataOpen = typeof window === "undefined" && open ? true : void 0;
|
|
69
|
-
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(dialogHelper.DialogContext.Provider, { value: { setEnabled }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
70
|
-
"dialog",
|
|
71
|
-
{
|
|
72
|
-
ref: dialogRef,
|
|
73
|
-
open: dataOpen,
|
|
74
|
-
className: blocksCore.classnames(dialog_css.dialog, dialogClassName, className),
|
|
75
|
-
onAnimationEnd,
|
|
76
|
-
onTransitionEnd: onAnimationEnd,
|
|
77
|
-
...restProps,
|
|
78
|
-
children
|
|
79
|
-
}
|
|
80
|
-
) }) });
|
|
81
|
-
};
|
|
82
|
-
exports.Dialog = Dialog;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const fileScope = require("@vanilla-extract/css/fileScope");
|
|
4
|
-
const blocksCore = require("@blockle/blocks-core");
|
|
5
|
-
const css = require("@vanilla-extract/css");
|
|
6
|
-
fileScope.setFileScope("src/components/overlay/Dialog/dialog.css.ts", "@blockle/blocks-react");
|
|
7
|
-
const dialog = css.style({
|
|
8
|
-
"@layer": {
|
|
9
|
-
[blocksCore.blocksLayerComponent]: {
|
|
10
|
-
position: "fixed",
|
|
11
|
-
inset: 0,
|
|
12
|
-
border: "none",
|
|
13
|
-
"::backdrop": {
|
|
14
|
-
// Remove pointer event to prevent clicks on the backdrop
|
|
15
|
-
// and make it easier to check if the click was outside the dialog
|
|
16
|
-
pointerEvents: "none"
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
fileScope.endFileScope();
|
|
22
|
-
exports.dialog = dialog;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const react = require("react");
|
|
4
|
-
const DialogContext = react.createContext(
|
|
5
|
-
void 0
|
|
6
|
-
);
|
|
7
|
-
const useNestedDialog = (open) => {
|
|
8
|
-
const parentDialog = react.useContext(DialogContext);
|
|
9
|
-
react.useEffect(() => {
|
|
10
|
-
if (!parentDialog || !open) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
parentDialog.setEnabled(false);
|
|
14
|
-
return () => {
|
|
15
|
-
parentDialog.setEnabled(true);
|
|
16
|
-
};
|
|
17
|
-
}, [parentDialog, open]);
|
|
18
|
-
return !!parentDialog;
|
|
19
|
-
};
|
|
20
|
-
exports.DialogContext = DialogContext;
|
|
21
|
-
exports.useNestedDialog = useNestedDialog;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Dialog, type DialogProps } from './Dialog';
|