@blockle/blocks-react 1.0.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/README.md +25 -0
- package/dist/components/accessibility/VisuallyHidden/VisuallyHidden.cjs +20 -0
- package/dist/components/accessibility/VisuallyHidden/VisuallyHidden.d.ts +6 -0
- package/dist/components/accessibility/VisuallyHidden/VisuallyHidden.js +20 -0
- package/dist/components/accessibility/VisuallyHidden/VisuallyHidden.spec.d.ts +1 -0
- package/dist/components/accessibility/VisuallyHidden/VisuallyHidden.stories.d.ts +6 -0
- package/dist/components/accessibility/VisuallyHidden/index.d.ts +1 -0
- package/dist/components/accessibility/VisuallyHidden/visually-hidden.css.cjs +16 -0
- package/dist/components/accessibility/VisuallyHidden/visually-hidden.css.d.ts +1 -0
- package/dist/components/accessibility/VisuallyHidden/visually-hidden.css.js +16 -0
- package/dist/components/display/Divider/Divider.cjs +28 -0
- package/dist/components/display/Divider/Divider.d.ts +7 -0
- package/dist/components/display/Divider/Divider.js +28 -0
- package/dist/components/display/Divider/Divider.spec.d.ts +1 -0
- package/dist/components/display/Divider/Divider.stories.d.ts +6 -0
- package/dist/components/display/Divider/divider.css.cjs +16 -0
- package/dist/components/display/Divider/divider.css.d.ts +1 -0
- package/dist/components/display/Divider/divider.css.js +16 -0
- package/dist/components/display/Divider/index.d.ts +1 -0
- package/dist/components/feedback/Progress/Progress.cjs +55 -0
- package/dist/components/feedback/Progress/Progress.d.ts +16 -0
- package/dist/components/feedback/Progress/Progress.js +55 -0
- package/dist/components/feedback/Progress/Progress.stories.d.ts +5 -0
- package/dist/components/feedback/Progress/index.d.ts +1 -0
- package/dist/components/feedback/Spinner/Spinner.cjs +27 -0
- package/dist/components/feedback/Spinner/Spinner.d.ts +10 -0
- package/dist/components/feedback/Spinner/Spinner.js +27 -0
- package/dist/components/feedback/Spinner/Spinner.stories.d.ts +5 -0
- package/dist/components/feedback/Spinner/index.d.ts +1 -0
- package/dist/components/form/Button/Button.cjs +58 -0
- package/dist/components/form/Button/Button.css.cjs +16 -0
- package/dist/components/form/Button/Button.css.d.ts +1 -0
- package/dist/components/form/Button/Button.css.js +16 -0
- package/dist/components/form/Button/Button.d.ts +21 -0
- package/dist/components/form/Button/Button.js +58 -0
- package/dist/components/form/Button/Button.spec.d.ts +1 -0
- package/dist/components/form/Button/Button.stories.d.ts +7 -0
- package/dist/components/form/Button/index.d.ts +1 -0
- package/dist/components/form/Checkbox/Checkbox.cjs +80 -0
- package/dist/components/form/Checkbox/Checkbox.d.ts +9 -0
- package/dist/components/form/Checkbox/Checkbox.js +80 -0
- package/dist/components/form/Checkbox/Checkbox.spec.d.ts +1 -0
- package/dist/components/form/Checkbox/Checkbox.stories.d.ts +5 -0
- package/dist/components/form/Checkbox/checkbox.css.cjs +32 -0
- package/dist/components/form/Checkbox/checkbox.css.d.ts +3 -0
- package/dist/components/form/Checkbox/checkbox.css.js +32 -0
- package/dist/components/form/Checkbox/index.d.ts +1 -0
- package/dist/components/form/Input/Input.cjs +52 -0
- package/dist/components/form/Input/Input.d.ts +10 -0
- package/dist/components/form/Input/Input.js +52 -0
- package/dist/components/form/Input/Input.spec.d.ts +1 -0
- package/dist/components/form/Input/Input.stories.d.ts +5 -0
- package/dist/components/form/Input/index.d.ts +1 -0
- package/dist/components/form/Input/input.css.cjs +21 -0
- package/dist/components/form/Input/input.css.d.ts +1 -0
- package/dist/components/form/Input/input.css.js +21 -0
- package/dist/components/form/Label/Label.cjs +34 -0
- package/dist/components/form/Label/Label.d.ts +18 -0
- package/dist/components/form/Label/Label.js +34 -0
- package/dist/components/form/Label/Label.spec.d.ts +1 -0
- package/dist/components/form/Label/Label.stories.d.ts +6 -0
- package/dist/components/form/Label/index.d.ts +1 -0
- package/dist/components/form/Radio/Radio.cjs +50 -0
- package/dist/components/form/Radio/Radio.d.ts +8 -0
- package/dist/components/form/Radio/Radio.js +50 -0
- package/dist/components/form/Radio/Radio.spec.d.ts +1 -0
- package/dist/components/form/Radio/Radio.stories.d.ts +6 -0
- package/dist/components/form/Radio/RadioGroup.d.ts +8 -0
- package/dist/components/form/Radio/index.d.ts +2 -0
- package/dist/components/form/Radio/radio.css.cjs +32 -0
- package/dist/components/form/Radio/radio.css.d.ts +3 -0
- package/dist/components/form/Radio/radio.css.js +32 -0
- package/dist/components/form/Select/Select.cjs +73 -0
- package/dist/components/form/Select/Select.d.ts +11 -0
- package/dist/components/form/Select/Select.js +73 -0
- package/dist/components/form/Select/Select.stories.d.ts +5 -0
- package/dist/components/form/Select/index.d.ts +1 -0
- package/dist/components/form/Select/select.css.cjs +38 -0
- package/dist/components/form/Select/select.css.d.ts +3 -0
- package/dist/components/form/Select/select.css.js +38 -0
- package/dist/components/form/Slider/Slider.cjs +139 -0
- package/dist/components/form/Slider/Slider.d.ts +22 -0
- package/dist/components/form/Slider/Slider.js +139 -0
- package/dist/components/form/Slider/Slider.spec.d.ts +1 -0
- package/dist/components/form/Slider/Slider.stories.d.ts +7 -0
- package/dist/components/form/Slider/index.d.ts +1 -0
- package/dist/components/form/Slider/slider.css.cjs +75 -0
- package/dist/components/form/Slider/slider.css.d.ts +5 -0
- package/dist/components/form/Slider/slider.css.js +75 -0
- package/dist/components/form/Slider/usePointerProgress.cjs +46 -0
- package/dist/components/form/Slider/usePointerProgress.d.ts +11 -0
- package/dist/components/form/Slider/usePointerProgress.js +46 -0
- package/dist/components/form/Switch/Switch.cjs +73 -0
- package/dist/components/form/Switch/Switch.d.ts +6 -0
- package/dist/components/form/Switch/Switch.js +73 -0
- package/dist/components/form/Switch/Switch.stories.d.ts +5 -0
- package/dist/components/form/Switch/index.d.ts +1 -0
- package/dist/components/form/Switch/switch.css.cjs +27 -0
- package/dist/components/form/Switch/switch.css.d.ts +2 -0
- package/dist/components/form/Switch/switch.css.js +27 -0
- package/dist/components/layout/Box/Box.cjs +26 -0
- package/dist/components/layout/Box/Box.d.ts +10 -0
- package/dist/components/layout/Box/Box.js +26 -0
- package/dist/components/layout/Box/Box.spec.d.ts +1 -0
- package/dist/components/layout/Box/Box.stories.d.ts +6 -0
- package/dist/components/layout/Box/index.d.ts +1 -0
- package/dist/components/layout/Inline/Inline.cjs +30 -0
- package/dist/components/layout/Inline/Inline.d.ts +12 -0
- package/dist/components/layout/Inline/Inline.js +30 -0
- package/dist/components/layout/Inline/Inline.stories.d.ts +6 -0
- package/dist/components/layout/Inline/index.d.ts +1 -0
- package/dist/components/layout/Stack/Stack.cjs +27 -0
- package/dist/components/layout/Stack/Stack.d.ts +16 -0
- package/dist/components/layout/Stack/Stack.js +27 -0
- package/dist/components/layout/Stack/Stack.stories.d.ts +6 -0
- package/dist/components/layout/Stack/index.d.ts +1 -0
- package/dist/components/navigation/Link/Link.cjs +33 -0
- package/dist/components/navigation/Link/Link.d.ts +11 -0
- package/dist/components/navigation/Link/Link.js +33 -0
- package/dist/components/navigation/Link/Link.stories.d.ts +6 -0
- package/dist/components/navigation/Link/Link.test.d.ts +1 -0
- package/dist/components/navigation/Link/index.d.ts +1 -0
- package/dist/components/overlay/Dialog/Dialog.cjs +81 -0
- package/dist/components/overlay/Dialog/Dialog.d.ts +12 -0
- package/dist/components/overlay/Dialog/Dialog.js +81 -0
- package/dist/components/overlay/Dialog/Dialog.stories.d.ts +7 -0
- package/dist/components/overlay/Dialog/Dialog.test.d.ts +1 -0
- package/dist/components/overlay/Dialog/dialog.css.cjs +22 -0
- package/dist/components/overlay/Dialog/dialog.css.d.ts +1 -0
- package/dist/components/overlay/Dialog/dialog.css.js +22 -0
- package/dist/components/overlay/Dialog/dialogHelper.cjs +21 -0
- package/dist/components/overlay/Dialog/dialogHelper.d.ts +6 -0
- package/dist/components/overlay/Dialog/dialogHelper.js +21 -0
- package/dist/components/overlay/Dialog/index.d.ts +1 -0
- package/dist/components/overlay/Popover/Popover.cjs +112 -0
- package/dist/components/overlay/Popover/Popover.d.ts +12 -0
- package/dist/components/overlay/Popover/Popover.js +112 -0
- package/dist/components/overlay/Popover/Popover.stories.d.ts +5 -0
- package/dist/components/overlay/Popover/index.d.ts +1 -0
- package/dist/components/overlay/Popover/popover-utils.cjs +62 -0
- package/dist/components/overlay/Popover/popover-utils.d.ts +2 -0
- package/dist/components/overlay/Popover/popover-utils.js +62 -0
- package/dist/components/overlay/Portal/Portal.cjs +15 -0
- package/dist/components/overlay/Portal/Portal.d.ts +5 -0
- package/dist/components/overlay/Portal/Portal.js +15 -0
- package/dist/components/overlay/Portal/index.d.ts +1 -0
- package/dist/components/overlay/Tooltip/Tooltip.cjs +73 -0
- package/dist/components/overlay/Tooltip/Tooltip.d.ts +12 -0
- package/dist/components/overlay/Tooltip/Tooltip.js +73 -0
- package/dist/components/overlay/Tooltip/Tooltip.stories.d.ts +5 -0
- package/dist/components/overlay/Tooltip/index.d.ts +1 -0
- package/dist/components/providers/BlocksProvider/BlocksProvider.cjs +35 -0
- package/dist/components/providers/BlocksProvider/BlocksProvider.d.ts +9 -0
- package/dist/components/providers/BlocksProvider/BlocksProvider.js +35 -0
- package/dist/components/providers/BlocksProvider/BlocksProvider.test.d.ts +1 -0
- package/dist/components/providers/BlocksProvider/context.cjs +5 -0
- package/dist/components/providers/BlocksProvider/context.d.ts +5 -0
- package/dist/components/providers/BlocksProvider/context.js +5 -0
- package/dist/components/providers/BlocksProvider/index.d.ts +2 -0
- package/dist/components/typography/Heading/Heading.cjs +24 -0
- package/dist/components/typography/Heading/Heading.d.ts +7 -0
- package/dist/components/typography/Heading/Heading.js +24 -0
- package/dist/components/typography/Heading/Heading.test.d.ts +1 -0
- package/dist/components/typography/Heading/heading.css.cjs +16 -0
- package/dist/components/typography/Heading/heading.css.d.ts +1 -0
- package/dist/components/typography/Heading/heading.css.js +16 -0
- package/dist/components/typography/Heading/heading.stories.d.ts +12 -0
- package/dist/components/typography/Heading/index.d.ts +1 -0
- package/dist/components/typography/Text/Text.cjs +21 -0
- package/dist/components/typography/Text/Text.d.ts +11 -0
- package/dist/components/typography/Text/Text.js +21 -0
- package/dist/components/typography/Text/Text.stories.d.ts +5 -0
- package/dist/components/typography/Text/Text.test.d.ts +1 -0
- package/dist/components/typography/Text/index.d.ts +1 -0
- package/dist/components/typography/Text/text.css.cjs +16 -0
- package/dist/components/typography/Text/text.css.d.ts +1 -0
- package/dist/components/typography/Text/text.css.js +16 -0
- package/dist/hooks/useClickOutside/useClickOutside.cjs +23 -0
- package/dist/hooks/useClickOutside/useClickOutside.d.ts +6 -0
- package/dist/hooks/useClickOutside/useClickOutside.js +23 -0
- package/dist/hooks/useComponentStyles/index.d.ts +2 -0
- package/dist/hooks/useComponentStyles/useComponentStyleDefaultProps.cjs +12 -0
- package/dist/hooks/useComponentStyles/useComponentStyleDefaultProps.d.ts +7 -0
- package/dist/hooks/useComponentStyles/useComponentStyleDefaultProps.js +12 -0
- package/dist/hooks/useComponentStyles/useComponentStyles.cjs +74 -0
- package/dist/hooks/useComponentStyles/useComponentStyles.d.ts +2 -0
- package/dist/hooks/useComponentStyles/useComponentStyles.js +74 -0
- package/dist/hooks/useControlledValue/index.d.ts +1 -0
- package/dist/hooks/useControlledValue/useControlledValue.cjs +33 -0
- package/dist/hooks/useControlledValue/useControlledValue.d.ts +8 -0
- package/dist/hooks/useControlledValue/useControlledValue.js +33 -0
- package/dist/hooks/useIsomorphicLayoutEffect/index.d.ts +1 -0
- package/dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs +6 -0
- package/dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.ts +5 -0
- package/dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +6 -0
- package/dist/hooks/useKeyboard/index.d.ts +1 -0
- package/dist/hooks/useKeyboard/useKeyboard.cjs +21 -0
- package/dist/hooks/useKeyboard/useKeyboard.d.ts +6 -0
- package/dist/hooks/useKeyboard/useKeyboard.js +21 -0
- package/dist/hooks/useLayer/index.d.ts +1 -0
- package/dist/hooks/useLayer/useLayer.cjs +27 -0
- package/dist/hooks/useLayer/useLayer.d.ts +1 -0
- package/dist/hooks/useLayer/useLayer.js +27 -0
- package/dist/hooks/usePreventBodyScroll/index.d.ts +1 -0
- package/dist/hooks/usePreventBodyScroll/usePreventBodyScroll.cjs +31 -0
- package/dist/hooks/usePreventBodyScroll/usePreventBodyScroll.d.ts +1 -0
- package/dist/hooks/usePreventBodyScroll/usePreventBodyScroll.js +31 -0
- package/dist/hooks/useRestoreFocus/index.d.ts +1 -0
- package/dist/hooks/useRestoreFocus/useRestoreFocus.cjs +19 -0
- package/dist/hooks/useRestoreFocus/useRestoreFocus.d.ts +4 -0
- package/dist/hooks/useRestoreFocus/useRestoreFocus.js +19 -0
- package/dist/hooks/useTheme/index.d.ts +1 -0
- package/dist/hooks/useTheme/useTheme.cjs +13 -0
- package/dist/hooks/useTheme/useTheme.d.ts +2 -0
- package/dist/hooks/useTheme/useTheme.js +13 -0
- package/dist/hooks/useVisibilityState/index.d.ts +1 -0
- package/dist/hooks/useVisibilityState/useVisibilityState.cjs +17 -0
- package/dist/hooks/useVisibilityState/useVisibilityState.d.ts +3 -0
- package/dist/hooks/useVisibilityState/useVisibilityState.js +17 -0
- package/dist/index.cjs +58 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +58 -0
- package/package.json +47 -0
|
@@ -0,0 +1,75 @@
|
|
|
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.blocksLayer]: {
|
|
10
|
+
position: "relative",
|
|
11
|
+
writingMode: "horizontal-tb"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
const containerVertical = css.style({
|
|
16
|
+
"@layer": {
|
|
17
|
+
[blocksCore.blocksLayer]: {
|
|
18
|
+
writingMode: "vertical-lr"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const track = css.style({
|
|
23
|
+
"@layer": {
|
|
24
|
+
[blocksCore.blocksLayer]: {
|
|
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.blocksLayer]: {
|
|
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.blocksLayer]: {
|
|
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;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
|
|
2
|
+
import { blocksLayer } from "@blockle/blocks-core";
|
|
3
|
+
import { style } from "@vanilla-extract/css";
|
|
4
|
+
setFileScope("src/components/form/Slider/slider.css.ts", "@blockle/blocks-react");
|
|
5
|
+
const container = style({
|
|
6
|
+
"@layer": {
|
|
7
|
+
[blocksLayer]: {
|
|
8
|
+
position: "relative",
|
|
9
|
+
writingMode: "horizontal-tb"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
const containerVertical = style({
|
|
14
|
+
"@layer": {
|
|
15
|
+
[blocksLayer]: {
|
|
16
|
+
writingMode: "vertical-lr"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
const track = style({
|
|
21
|
+
"@layer": {
|
|
22
|
+
[blocksLayer]: {
|
|
23
|
+
cursor: "pointer",
|
|
24
|
+
position: "absolute",
|
|
25
|
+
inlineSize: "100%",
|
|
26
|
+
insetBlockStart: "50%",
|
|
27
|
+
transform: "translateY(-50%)",
|
|
28
|
+
selectors: {
|
|
29
|
+
[`${containerVertical} &`]: {
|
|
30
|
+
transform: "translateX(-50%)"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const filledTrack = style({
|
|
37
|
+
"@layer": {
|
|
38
|
+
[blocksLayer]: {
|
|
39
|
+
position: "absolute",
|
|
40
|
+
blockSize: "100%",
|
|
41
|
+
borderRadius: "inherit",
|
|
42
|
+
selectors: {
|
|
43
|
+
[`${containerVertical} &`]: {
|
|
44
|
+
insetInlineEnd: "0%"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
const thumb = style({
|
|
51
|
+
"@layer": {
|
|
52
|
+
[blocksLayer]: {
|
|
53
|
+
cursor: "pointer",
|
|
54
|
+
position: "absolute",
|
|
55
|
+
blockSize: "100%",
|
|
56
|
+
insetBlockStart: "50%",
|
|
57
|
+
transform: "translate(-50%, -50%)",
|
|
58
|
+
touchAction: "none",
|
|
59
|
+
border: "none",
|
|
60
|
+
selectors: {
|
|
61
|
+
[`${containerVertical} &`]: {
|
|
62
|
+
transform: "translate(-50%, 50%)"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
endFileScope();
|
|
69
|
+
export {
|
|
70
|
+
container,
|
|
71
|
+
containerVertical,
|
|
72
|
+
filledTrack,
|
|
73
|
+
thumb,
|
|
74
|
+
track
|
|
75
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
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;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type PointerProgressOptions<T extends React.RefObject<HTMLElement | null>> = {
|
|
2
|
+
container: T;
|
|
3
|
+
orientation: 'horizontal' | 'vertical';
|
|
4
|
+
onChange(progress: number): void;
|
|
5
|
+
};
|
|
6
|
+
export declare function getProgress(event: PointerEvent, rect: DOMRect): [x: number, y: number];
|
|
7
|
+
/**
|
|
8
|
+
* Utility hook to track pointer events and calculate progress based on the pointer position.
|
|
9
|
+
*/
|
|
10
|
+
export declare function usePointerProgress<T extends React.RefObject<HTMLElement | null>>({ container, orientation, onChange }: PointerProgressOptions<T>): void;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
function getProgress(event, rect) {
|
|
3
|
+
const { clientX, clientY } = event;
|
|
4
|
+
const { width, height, left, top } = rect;
|
|
5
|
+
const x = (clientX - left) / width;
|
|
6
|
+
const y = (clientY - top) / height;
|
|
7
|
+
return [x, y];
|
|
8
|
+
}
|
|
9
|
+
function usePointerProgress({ container, orientation, onChange }) {
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const element = container.current;
|
|
12
|
+
function pointerdown(event) {
|
|
13
|
+
event.preventDefault();
|
|
14
|
+
event.stopPropagation();
|
|
15
|
+
if (!element) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const containerRect = element.getBoundingClientRect();
|
|
19
|
+
const axisIndex = orientation === "horizontal" ? 0 : 1;
|
|
20
|
+
const progress = getProgress(event, containerRect);
|
|
21
|
+
onChange(progress[axisIndex]);
|
|
22
|
+
const pointermove = (event2) => {
|
|
23
|
+
event2.preventDefault();
|
|
24
|
+
const progress2 = getProgress(event2, containerRect);
|
|
25
|
+
onChange(progress2[axisIndex]);
|
|
26
|
+
};
|
|
27
|
+
const pointerup = () => {
|
|
28
|
+
document.removeEventListener("pointermove", pointermove);
|
|
29
|
+
document.removeEventListener("pointerup", pointerup);
|
|
30
|
+
};
|
|
31
|
+
document.addEventListener("pointermove", pointermove);
|
|
32
|
+
document.addEventListener("pointerup", pointerup);
|
|
33
|
+
}
|
|
34
|
+
if (!element) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
element.addEventListener("pointerdown", pointerdown);
|
|
38
|
+
return () => {
|
|
39
|
+
element.removeEventListener("pointerdown", pointerdown);
|
|
40
|
+
};
|
|
41
|
+
}, [container, onChange, orientation]);
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
getProgress,
|
|
45
|
+
usePointerProgress
|
|
46
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
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;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { HTMLElementProps } from '@blockle/blocks-core';
|
|
2
|
+
export type SwitchProps = {
|
|
3
|
+
onChange?: (value: boolean) => void;
|
|
4
|
+
ref?: React.Ref<HTMLInputElement>;
|
|
5
|
+
} & Omit<HTMLElementProps<HTMLInputElement>, 'onChange'>;
|
|
6
|
+
export declare const Switch: React.FC<SwitchProps>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { classnames } from "@blockle/blocks-core";
|
|
4
|
+
import { useState, useEffect, useCallback } from "react";
|
|
5
|
+
import { input, container } from "./switch.css.js";
|
|
6
|
+
import { useComponentStyles } from "../../../hooks/useComponentStyles/useComponentStyles.js";
|
|
7
|
+
const Switch = ({
|
|
8
|
+
checked,
|
|
9
|
+
className,
|
|
10
|
+
defaultChecked,
|
|
11
|
+
onChange,
|
|
12
|
+
ref,
|
|
13
|
+
...restProps
|
|
14
|
+
}) => {
|
|
15
|
+
const [isChecked, setIsChecked] = useState(
|
|
16
|
+
defaultChecked || checked || false
|
|
17
|
+
);
|
|
18
|
+
const baseClassName = useComponentStyles("switch", { base: true });
|
|
19
|
+
const sliderClassName = useComponentStyles("switch", { slider: true }, false);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (checked !== void 0) {
|
|
22
|
+
setIsChecked(checked);
|
|
23
|
+
}
|
|
24
|
+
}, [checked]);
|
|
25
|
+
const toggle = useCallback(() => {
|
|
26
|
+
setIsChecked((checked2) => {
|
|
27
|
+
const newValue = !checked2;
|
|
28
|
+
if (onChange) {
|
|
29
|
+
onChange(newValue);
|
|
30
|
+
}
|
|
31
|
+
return newValue;
|
|
32
|
+
});
|
|
33
|
+
}, [onChange]);
|
|
34
|
+
const onChangeHandler = useCallback(
|
|
35
|
+
(event) => {
|
|
36
|
+
setIsChecked(event.target.checked);
|
|
37
|
+
if (onChange) {
|
|
38
|
+
onChange(event.target.checked);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
[onChange]
|
|
42
|
+
);
|
|
43
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
className: classnames(className, container, baseClassName),
|
|
47
|
+
"data-checked": isChecked,
|
|
48
|
+
onClick: (event) => {
|
|
49
|
+
if (event.target.tagName === "INPUT") {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
toggle();
|
|
53
|
+
},
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ jsx(
|
|
56
|
+
"input",
|
|
57
|
+
{
|
|
58
|
+
ref,
|
|
59
|
+
type: "checkbox",
|
|
60
|
+
className: input,
|
|
61
|
+
checked: isChecked,
|
|
62
|
+
onChange: onChangeHandler,
|
|
63
|
+
...restProps
|
|
64
|
+
}
|
|
65
|
+
),
|
|
66
|
+
/* @__PURE__ */ jsx("div", { className: sliderClassName, "data-checked": isChecked })
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
) });
|
|
70
|
+
};
|
|
71
|
+
export {
|
|
72
|
+
Switch
|
|
73
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Switch, type SwitchProps } from './Switch';
|
|
@@ -0,0 +1,27 @@
|
|
|
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.blocksLayer]: {
|
|
10
|
+
cursor: "pointer",
|
|
11
|
+
userSelect: "none",
|
|
12
|
+
position: "relative"
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
const input = css.style({
|
|
17
|
+
"@layer": {
|
|
18
|
+
[blocksCore.blocksLayer]: {
|
|
19
|
+
opacity: 0,
|
|
20
|
+
maxBlockSize: 0,
|
|
21
|
+
maxInlineSize: 0
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
fileScope.endFileScope();
|
|
26
|
+
exports.container = container;
|
|
27
|
+
exports.input = input;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
|
|
2
|
+
import { blocksLayer } from "@blockle/blocks-core";
|
|
3
|
+
import { style } from "@vanilla-extract/css";
|
|
4
|
+
setFileScope("src/components/form/Switch/switch.css.ts", "@blockle/blocks-react");
|
|
5
|
+
const container = style({
|
|
6
|
+
"@layer": {
|
|
7
|
+
[blocksLayer]: {
|
|
8
|
+
cursor: "pointer",
|
|
9
|
+
userSelect: "none",
|
|
10
|
+
position: "relative"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
const input = style({
|
|
15
|
+
"@layer": {
|
|
16
|
+
[blocksLayer]: {
|
|
17
|
+
opacity: 0,
|
|
18
|
+
maxBlockSize: 0,
|
|
19
|
+
maxInlineSize: 0
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
endFileScope();
|
|
24
|
+
export {
|
|
25
|
+
container,
|
|
26
|
+
input
|
|
27
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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.sprinkles(atomsProps)),
|
|
21
|
+
...otherProps,
|
|
22
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Slot, { children })
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
exports.Box = Box;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HTMLElementProps, Sprinkles } from '@blockle/blocks-core';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
export type BoxProps = {
|
|
4
|
+
asChild?: boolean;
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
} & Sprinkles & HTMLElementProps<HTMLDivElement>;
|
|
10
|
+
export declare const Box: React.FC<BoxProps>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getAtomsAndProps, classnames, sprinkles } from "@blockle/blocks-core";
|
|
3
|
+
import { createSlottable } from "@blockle/blocks-react-slot";
|
|
4
|
+
const [Template, Slot] = createSlottable("div");
|
|
5
|
+
const Box = ({
|
|
6
|
+
asChild,
|
|
7
|
+
className,
|
|
8
|
+
children,
|
|
9
|
+
ref,
|
|
10
|
+
...restProps
|
|
11
|
+
}) => {
|
|
12
|
+
const [atomsProps, otherProps] = getAtomsAndProps(restProps);
|
|
13
|
+
return /* @__PURE__ */ jsx(
|
|
14
|
+
Template,
|
|
15
|
+
{
|
|
16
|
+
ref,
|
|
17
|
+
asChild,
|
|
18
|
+
className: classnames(className, sprinkles(atomsProps)),
|
|
19
|
+
...otherProps,
|
|
20
|
+
children: /* @__PURE__ */ jsx(Slot, { children })
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
export {
|
|
25
|
+
Box
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Box, type BoxProps } from './Box';
|
|
@@ -0,0 +1,30 @@
|
|
|
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;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AlignItemsMap, JustifyContentMap, MarginSprinkles, PaddingSprinkles, ResponsiveDisplayFlex, Sprinkles } from '@blockle/blocks-core';
|
|
2
|
+
export type InlineProps = {
|
|
3
|
+
alignX?: keyof JustifyContentMap;
|
|
4
|
+
alignY?: keyof AlignItemsMap;
|
|
5
|
+
tag?: 'div' | 'ul' | 'ol' | 'nav';
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
display?: ResponsiveDisplayFlex;
|
|
9
|
+
spacing: Sprinkles['gap'];
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
} & MarginSprinkles & PaddingSprinkles;
|
|
12
|
+
export declare const Inline: React.FC<InlineProps>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { alignItemsMap, justifyContentMap } from "@blockle/blocks-core";
|
|
3
|
+
import { Box } from "../Box/Box.js";
|
|
4
|
+
const Inline = ({
|
|
5
|
+
alignX,
|
|
6
|
+
alignY,
|
|
7
|
+
tag: Tag = "div",
|
|
8
|
+
children,
|
|
9
|
+
display = "flex",
|
|
10
|
+
spacing,
|
|
11
|
+
...props
|
|
12
|
+
}) => {
|
|
13
|
+
return /* @__PURE__ */ jsx(
|
|
14
|
+
Box,
|
|
15
|
+
{
|
|
16
|
+
asChild: true,
|
|
17
|
+
display,
|
|
18
|
+
gap: spacing,
|
|
19
|
+
flexDirection: "row",
|
|
20
|
+
justifyContent: alignX ? justifyContentMap[alignX] : void 0,
|
|
21
|
+
alignItems: alignY ? alignItemsMap[alignY] : void 0,
|
|
22
|
+
flexWrap: "wrap",
|
|
23
|
+
...props,
|
|
24
|
+
children: /* @__PURE__ */ jsx(Tag, { children })
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
Inline
|
|
30
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Inline, InlineProps } from './Inline';
|
|
3
|
+
declare const _default: Meta<typeof Inline>;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Default: StoryObj<InlineProps>;
|
|
6
|
+
export declare const List: StoryObj<InlineProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Inline, type InlineProps } from './Inline';
|