@blockle/blocks 0.8.7 → 0.8.9

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.
Files changed (90) hide show
  1. package/dist/index.cjs +77 -736
  2. package/dist/index.d.mts +1 -0
  3. package/dist/index.mjs +56 -714
  4. package/dist/momotaro.chunk.d.ts +423 -410
  5. package/dist/reset.css.d.mts +2 -0
  6. package/dist/reset.css.d.ts +1 -1
  7. package/dist/styles/components/display/Divider/Divider.cjs +226 -0
  8. package/dist/styles/components/display/Divider/Divider.mjs +227 -0
  9. package/dist/styles/components/{Divider → display/Divider}/divider.css.cjs +2 -2
  10. package/dist/styles/components/{Divider → display/Divider}/divider.css.mjs +2 -2
  11. package/dist/styles/components/form/Button/Button.cjs +55 -0
  12. package/dist/styles/components/{Button → form/Button}/Button.css.cjs +2 -2
  13. package/dist/styles/components/{Button → form/Button}/Button.css.mjs +2 -2
  14. package/dist/styles/components/form/Button/Button.mjs +56 -0
  15. package/dist/styles/components/form/Checkbox/Checkbox.cjs +47 -0
  16. package/dist/styles/components/form/Checkbox/Checkbox.mjs +48 -0
  17. package/dist/styles/components/{Checkbox → form/Checkbox}/checkbox.css.cjs +2 -2
  18. package/dist/styles/components/{Checkbox → form/Checkbox}/checkbox.css.mjs +2 -2
  19. package/dist/styles/components/form/Input/Input.cjs +27 -0
  20. package/dist/styles/components/form/Input/Input.mjs +28 -0
  21. package/dist/styles/components/{Input → form/Input}/input.css.cjs +2 -2
  22. package/dist/styles/components/{Input → form/Input}/input.css.mjs +2 -2
  23. package/dist/styles/components/form/Radio/Radio.cjs +23 -0
  24. package/dist/styles/components/form/Radio/Radio.mjs +24 -0
  25. package/dist/styles/components/{Radio → form/Radio}/radio.css.cjs +2 -2
  26. package/dist/styles/components/{Radio → form/Radio}/radio.css.mjs +2 -2
  27. package/dist/styles/components/form/Switch/Switch.cjs +61 -0
  28. package/dist/styles/components/form/Switch/Switch.mjs +62 -0
  29. package/dist/styles/components/{Switch → form/Switch}/switch.css.cjs +2 -2
  30. package/dist/styles/components/{Switch → form/Switch}/switch.css.mjs +2 -2
  31. package/dist/styles/components/other/BlocksProvider/BlocksProvider.cjs +20 -0
  32. package/dist/styles/components/other/BlocksProvider/BlocksProvider.mjs +21 -0
  33. package/dist/styles/components/overlay/Dialog/Dialog.cjs +245 -0
  34. package/dist/styles/components/overlay/Dialog/Dialog.mjs +246 -0
  35. package/dist/styles/components/{Dialog → overlay/Dialog}/dialog.css.cjs +4 -3
  36. package/dist/styles/components/{Dialog → overlay/Dialog}/dialog.css.mjs +4 -3
  37. package/dist/styles/components/typography/Heading/Heading.cjs +14 -0
  38. package/dist/styles/components/typography/Heading/Heading.mjs +15 -0
  39. package/dist/styles/components/{Heading → typography/Heading}/heading.css.cjs +2 -2
  40. package/dist/styles/components/{Heading → typography/Heading}/heading.css.mjs +2 -2
  41. package/dist/styles/components/typography/Text/Text.cjs +9 -0
  42. package/dist/styles/components/typography/Text/Text.mjs +10 -0
  43. package/dist/styles/components/{Text → typography/Text}/text.css.cjs +2 -2
  44. package/dist/styles/components/{Text → typography/Text}/text.css.mjs +2 -2
  45. package/dist/styles/lib/css/atoms/atoms.cjs +1 -0
  46. package/dist/styles/lib/css/atoms/atoms.mjs +1 -0
  47. package/dist/styles/lib/css/atoms/sprinkles.css.cjs +2 -6
  48. package/dist/styles/lib/css/atoms/sprinkles.css.mjs +2 -6
  49. package/dist/styles/lib/css/layers/layers.css.cjs +1 -1
  50. package/dist/styles/lib/css/layers/layers.css.mjs +1 -1
  51. package/dist/styles/lib/theme/vars.css.cjs +1 -1
  52. package/dist/styles/lib/theme/vars.css.mjs +1 -1
  53. package/dist/styles/lib/utils/atom-props.cjs +15 -0
  54. package/dist/styles/lib/utils/atom-props.mjs +16 -0
  55. package/dist/styles/themes/momotaro/components/button.css.cjs +1 -1
  56. package/dist/styles/themes/momotaro/components/button.css.mjs +1 -1
  57. package/dist/styles/themes/momotaro/components/checkbox.css.cjs +1 -1
  58. package/dist/styles/themes/momotaro/components/checkbox.css.mjs +1 -1
  59. package/dist/styles/themes/momotaro/components/dialog.css.cjs +1 -1
  60. package/dist/styles/themes/momotaro/components/dialog.css.mjs +1 -1
  61. package/dist/styles/themes/momotaro/components/divider.css.cjs +1 -1
  62. package/dist/styles/themes/momotaro/components/divider.css.mjs +1 -1
  63. package/dist/styles/themes/momotaro/components/dropdown.css.cjs +54 -0
  64. package/dist/styles/themes/momotaro/components/dropdown.css.mjs +55 -0
  65. package/dist/styles/themes/momotaro/components/helpers.css.cjs +1 -1
  66. package/dist/styles/themes/momotaro/components/helpers.css.mjs +1 -1
  67. package/dist/styles/themes/momotaro/components/index.cjs +2 -0
  68. package/dist/styles/themes/momotaro/components/index.mjs +2 -0
  69. package/dist/styles/themes/momotaro/components/input.css.cjs +1 -1
  70. package/dist/styles/themes/momotaro/components/input.css.mjs +1 -1
  71. package/dist/styles/themes/momotaro/components/label.css.cjs +1 -1
  72. package/dist/styles/themes/momotaro/components/label.css.mjs +1 -1
  73. package/dist/styles/themes/momotaro/components/link.css.cjs +1 -1
  74. package/dist/styles/themes/momotaro/components/link.css.mjs +1 -1
  75. package/dist/styles/themes/momotaro/components/progress.css.cjs +1 -1
  76. package/dist/styles/themes/momotaro/components/progress.css.mjs +1 -1
  77. package/dist/styles/themes/momotaro/components/radio.css.cjs +1 -1
  78. package/dist/styles/themes/momotaro/components/radio.css.mjs +1 -1
  79. package/dist/styles/themes/momotaro/components/spinner.css.cjs +1 -1
  80. package/dist/styles/themes/momotaro/components/spinner.css.mjs +1 -1
  81. package/dist/styles/themes/momotaro/components/switch.css.cjs +1 -1
  82. package/dist/styles/themes/momotaro/components/switch.css.mjs +1 -1
  83. package/dist/styles/themes/momotaro/index.cjs +1 -0
  84. package/dist/styles/themes/momotaro/index.mjs +1 -0
  85. package/dist/styles/themes/momotaro/momotaro.css.cjs +1 -1
  86. package/dist/styles/themes/momotaro/momotaro.css.mjs +1 -1
  87. package/dist/styles/themes/momotaro/tokens.css.cjs +1 -1
  88. package/dist/styles/themes/momotaro/tokens.css.mjs +1 -1
  89. package/dist/themes/momotaro.d.mts +1 -0
  90. package/package.json +47 -37
@@ -0,0 +1,48 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { useComponentStyles, classnames } from "../../display/Divider/Divider.mjs";
4
+ import { atoms } from "../../../lib/css/atoms/sprinkles.css.mjs";
5
+ import { container, input, icon } from "./checkbox.css.mjs";
6
+ const Label = ({
7
+ asSpan,
8
+ children,
9
+ className,
10
+ required,
11
+ size,
12
+ cursor,
13
+ ...restProps
14
+ }) => {
15
+ const Component = asSpan ? "span" : "label";
16
+ const containerClassName = useComponentStyles("label", {
17
+ base: true,
18
+ variants: { required, size }
19
+ });
20
+ return /* @__PURE__ */ jsx(
21
+ Component,
22
+ {
23
+ className: classnames(containerClassName, className, atoms({ cursor })),
24
+ ...restProps,
25
+ children
26
+ }
27
+ );
28
+ };
29
+ const Checkbox = forwardRef(function Checkbox2({ name, label, required, className, ...restProps }, ref) {
30
+ const containerClassName = useComponentStyles("checkbox", { base: true }, false);
31
+ const iconClassName = useComponentStyles("checkbox", { icon: true }, false);
32
+ const labelClassName = useComponentStyles("checkbox", { label: true }, false);
33
+ const input$1 = /* @__PURE__ */ jsxs("div", { className: classnames(container, containerClassName, className), children: [
34
+ /* @__PURE__ */ jsx("input", { ref, type: "checkbox", name, className: input, ...restProps }),
35
+ /* @__PURE__ */ jsx("div", { className: classnames(icon, iconClassName) })
36
+ ] });
37
+ if (!label) {
38
+ return input$1;
39
+ }
40
+ return /* @__PURE__ */ jsxs("label", { className: labelClassName, children: [
41
+ input$1,
42
+ label && /* @__PURE__ */ jsx(Label, { asSpan: true, required, children: label })
43
+ ] });
44
+ });
45
+ export {
46
+ Checkbox,
47
+ Label
48
+ };
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  const fileScope = require("@vanilla-extract/css/fileScope");
3
3
  const css = require("@vanilla-extract/css");
4
- const styles_lib_css_layers_layers_css_cjs = require("../../lib/css/layers/layers.css.cjs");
5
- fileScope.setFileScope("src/components/Checkbox/checkbox.css.ts?used", "blocks");
4
+ const styles_lib_css_layers_layers_css_cjs = require("../../../lib/css/layers/layers.css.cjs");
5
+ fileScope.setFileScope("src/components/form/Checkbox/checkbox.css.ts", "blocks");
6
6
  const container = css.style({
7
7
  "@layer": {
8
8
  [styles_lib_css_layers_layers_css_cjs.blocksLayer]: {
@@ -1,7 +1,7 @@
1
1
  import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
2
2
  import { style } from "@vanilla-extract/css";
3
- import { blocksLayer } from "../../lib/css/layers/layers.css.mjs";
4
- setFileScope("src/components/Checkbox/checkbox.css.ts?used", "blocks");
3
+ import { blocksLayer } from "../../../lib/css/layers/layers.css.mjs";
4
+ setFileScope("src/components/form/Checkbox/checkbox.css.ts", "blocks");
5
5
  const container = style({
6
6
  "@layer": {
7
7
  [blocksLayer]: {
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ const jsxRuntime = require("react/jsx-runtime");
3
+ const react = require("react");
4
+ const styles_components_display_Divider_Divider_cjs = require("../../display/Divider/Divider.cjs");
5
+ const styles_components_form_Input_input_css_cjs = require("./input.css.cjs");
6
+ const Input = react.forwardRef(function Input2({ className, name, type = "text", startSlot, endSlot, label, placeholder, ...restProps }, ref) {
7
+ const id = react.useId();
8
+ const containerClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("input", { container: true }, false);
9
+ const inputClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("input", { input: true });
10
+ return /* @__PURE__ */ jsxRuntime.jsx(styles_components_display_Divider_Divider_cjs.Box, { children: /* @__PURE__ */ jsxRuntime.jsxs(styles_components_display_Divider_Divider_cjs.Box, { display: "flex", alignItems: "center", className: styles_components_display_Divider_Divider_cjs.classnames(containerClassName, className), children: [
11
+ startSlot,
12
+ /* @__PURE__ */ jsxRuntime.jsx(styles_components_display_Divider_Divider_cjs.Box, { asChild: true, width: "full", overflow: "hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
13
+ "input",
14
+ {
15
+ id,
16
+ ref,
17
+ name,
18
+ type,
19
+ placeholder: placeholder || label,
20
+ className: styles_components_display_Divider_Divider_cjs.classnames(styles_components_form_Input_input_css_cjs.input, inputClassName),
21
+ ...restProps
22
+ }
23
+ ) }),
24
+ endSlot
25
+ ] }) });
26
+ });
27
+ exports.Input = Input;
@@ -0,0 +1,28 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useId } from "react";
3
+ import { useComponentStyles, Box, classnames } from "../../display/Divider/Divider.mjs";
4
+ import { input } from "./input.css.mjs";
5
+ const Input = forwardRef(function Input2({ className, name, type = "text", startSlot, endSlot, label, placeholder, ...restProps }, ref) {
6
+ const id = useId();
7
+ const containerClassName = useComponentStyles("input", { container: true }, false);
8
+ const inputClassName = useComponentStyles("input", { input: true });
9
+ return /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Box, { display: "flex", alignItems: "center", className: classnames(containerClassName, className), children: [
10
+ startSlot,
11
+ /* @__PURE__ */ jsx(Box, { asChild: true, width: "full", overflow: "hidden", children: /* @__PURE__ */ jsx(
12
+ "input",
13
+ {
14
+ id,
15
+ ref,
16
+ name,
17
+ type,
18
+ placeholder: placeholder || label,
19
+ className: classnames(input, inputClassName),
20
+ ...restProps
21
+ }
22
+ ) }),
23
+ endSlot
24
+ ] }) });
25
+ });
26
+ export {
27
+ Input
28
+ };
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  const fileScope = require("@vanilla-extract/css/fileScope");
3
3
  const css = require("@vanilla-extract/css");
4
- const styles_lib_css_layers_layers_css_cjs = require("../../lib/css/layers/layers.css.cjs");
5
- fileScope.setFileScope("src/components/Input/input.css.ts?used", "blocks");
4
+ const styles_lib_css_layers_layers_css_cjs = require("../../../lib/css/layers/layers.css.cjs");
5
+ fileScope.setFileScope("src/components/form/Input/input.css.ts", "blocks");
6
6
  const input = css.style({
7
7
  "@layer": {
8
8
  [styles_lib_css_layers_layers_css_cjs.blocksLayer]: {
@@ -1,7 +1,7 @@
1
1
  import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
2
2
  import { style } from "@vanilla-extract/css";
3
- import { blocksLayer } from "../../lib/css/layers/layers.css.mjs";
4
- setFileScope("src/components/Input/input.css.ts?used", "blocks");
3
+ import { blocksLayer } from "../../../lib/css/layers/layers.css.mjs";
4
+ setFileScope("src/components/form/Input/input.css.ts", "blocks");
5
5
  const input = style({
6
6
  "@layer": {
7
7
  [blocksLayer]: {
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ const jsxRuntime = require("react/jsx-runtime");
3
+ const react = require("react");
4
+ const styles_components_display_Divider_Divider_cjs = require("../../display/Divider/Divider.cjs");
5
+ const styles_components_form_Radio_radio_css_cjs = require("./radio.css.cjs");
6
+ const styles_components_form_Checkbox_Checkbox_cjs = require("../Checkbox/Checkbox.cjs");
7
+ const Radio = react.forwardRef(function Checkbox({ name, children, className, ...restProps }, ref) {
8
+ const containerClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("radio", { base: true }, false);
9
+ const iconClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("radio", { icon: true }, false);
10
+ const labelClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("checkbox", { label: true }, false);
11
+ const input = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_components_display_Divider_Divider_cjs.classnames(styles_components_form_Radio_radio_css_cjs.container, containerClassName, className), children: [
12
+ /* @__PURE__ */ jsxRuntime.jsx("input", { ref, type: "radio", name, className: styles_components_form_Radio_radio_css_cjs.input, ...restProps }),
13
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_components_display_Divider_Divider_cjs.classnames(styles_components_form_Radio_radio_css_cjs.icon, iconClassName) })
14
+ ] });
15
+ if (!children) {
16
+ return input;
17
+ }
18
+ return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: labelClassName, children: [
19
+ input,
20
+ /* @__PURE__ */ jsxRuntime.jsx(styles_components_form_Checkbox_Checkbox_cjs.Label, { asSpan: true, children })
21
+ ] });
22
+ });
23
+ exports.Radio = Radio;
@@ -0,0 +1,24 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { useComponentStyles, classnames } from "../../display/Divider/Divider.mjs";
4
+ import { container, input, icon } from "./radio.css.mjs";
5
+ import { Label } from "../Checkbox/Checkbox.mjs";
6
+ const Radio = forwardRef(function Checkbox({ name, children, className, ...restProps }, ref) {
7
+ const containerClassName = useComponentStyles("radio", { base: true }, false);
8
+ const iconClassName = useComponentStyles("radio", { icon: true }, false);
9
+ const labelClassName = useComponentStyles("checkbox", { label: true }, false);
10
+ const input$1 = /* @__PURE__ */ jsxs("div", { className: classnames(container, containerClassName, className), children: [
11
+ /* @__PURE__ */ jsx("input", { ref, type: "radio", name, className: input, ...restProps }),
12
+ /* @__PURE__ */ jsx("div", { className: classnames(icon, iconClassName) })
13
+ ] });
14
+ if (!children) {
15
+ return input$1;
16
+ }
17
+ return /* @__PURE__ */ jsxs("label", { className: labelClassName, children: [
18
+ input$1,
19
+ /* @__PURE__ */ jsx(Label, { asSpan: true, children })
20
+ ] });
21
+ });
22
+ export {
23
+ Radio
24
+ };
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  const fileScope = require("@vanilla-extract/css/fileScope");
3
3
  const css = require("@vanilla-extract/css");
4
- const styles_lib_css_layers_layers_css_cjs = require("../../lib/css/layers/layers.css.cjs");
5
- fileScope.setFileScope("src/components/Radio/radio.css.ts?used", "blocks");
4
+ const styles_lib_css_layers_layers_css_cjs = require("../../../lib/css/layers/layers.css.cjs");
5
+ fileScope.setFileScope("src/components/form/Radio/radio.css.ts", "blocks");
6
6
  const container = css.style({
7
7
  "@layer": {
8
8
  [styles_lib_css_layers_layers_css_cjs.blocksLayer]: {
@@ -1,7 +1,7 @@
1
1
  import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
2
2
  import { style } from "@vanilla-extract/css";
3
- import { blocksLayer } from "../../lib/css/layers/layers.css.mjs";
4
- setFileScope("src/components/Radio/radio.css.ts?used", "blocks");
3
+ import { blocksLayer } from "../../../lib/css/layers/layers.css.mjs";
4
+ setFileScope("src/components/form/Radio/radio.css.ts", "blocks");
5
5
  const container = style({
6
6
  "@layer": {
7
7
  [blocksLayer]: {
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ const jsxRuntime = require("react/jsx-runtime");
3
+ const react = require("react");
4
+ const styles_components_display_Divider_Divider_cjs = require("../../display/Divider/Divider.cjs");
5
+ const styles_components_form_Switch_switch_css_cjs = require("./switch.css.cjs");
6
+ const Switch = react.forwardRef(function Switch2({ className, checked, onChange, defaultChecked, ...restProps }, ref) {
7
+ const [isChecked, setIsChecked] = react.useState(defaultChecked || checked || false);
8
+ const baseClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("switch", { base: true });
9
+ const sliderClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("switch", { slider: true }, false);
10
+ react.useEffect(() => {
11
+ if (checked !== void 0) {
12
+ setIsChecked(checked);
13
+ }
14
+ }, [checked]);
15
+ const toggle = react.useCallback(() => {
16
+ setIsChecked((checked2) => {
17
+ const newValue = !checked2;
18
+ if (onChange) {
19
+ onChange(newValue);
20
+ }
21
+ return newValue;
22
+ });
23
+ }, [onChange]);
24
+ const onChangeHandler = react.useCallback(
25
+ (event) => {
26
+ setIsChecked(event.target.checked);
27
+ if (onChange) {
28
+ onChange(event.target.checked);
29
+ }
30
+ },
31
+ [onChange]
32
+ );
33
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(
34
+ "div",
35
+ {
36
+ className: styles_components_display_Divider_Divider_cjs.classnames(className, styles_components_form_Switch_switch_css_cjs.container, baseClassName),
37
+ "data-checked": isChecked,
38
+ onClick: (event) => {
39
+ if (event.target.tagName === "INPUT") {
40
+ return;
41
+ }
42
+ toggle();
43
+ },
44
+ children: [
45
+ /* @__PURE__ */ jsxRuntime.jsx(
46
+ "input",
47
+ {
48
+ ref,
49
+ type: "checkbox",
50
+ className: styles_components_form_Switch_switch_css_cjs.input,
51
+ checked: isChecked,
52
+ onChange: onChangeHandler,
53
+ ...restProps
54
+ }
55
+ ),
56
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: sliderClassName, "data-checked": isChecked })
57
+ ]
58
+ }
59
+ ) });
60
+ });
61
+ exports.Switch = Switch;
@@ -0,0 +1,62 @@
1
+ import { jsx, Fragment, jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useState, useEffect, useCallback } from "react";
3
+ import { useComponentStyles, classnames } from "../../display/Divider/Divider.mjs";
4
+ import { container, input } from "./switch.css.mjs";
5
+ const Switch = forwardRef(function Switch2({ className, checked, onChange, defaultChecked, ...restProps }, ref) {
6
+ const [isChecked, setIsChecked] = useState(defaultChecked || checked || false);
7
+ const baseClassName = useComponentStyles("switch", { base: true });
8
+ const sliderClassName = useComponentStyles("switch", { slider: true }, false);
9
+ useEffect(() => {
10
+ if (checked !== void 0) {
11
+ setIsChecked(checked);
12
+ }
13
+ }, [checked]);
14
+ const toggle = useCallback(() => {
15
+ setIsChecked((checked2) => {
16
+ const newValue = !checked2;
17
+ if (onChange) {
18
+ onChange(newValue);
19
+ }
20
+ return newValue;
21
+ });
22
+ }, [onChange]);
23
+ const onChangeHandler = useCallback(
24
+ (event) => {
25
+ setIsChecked(event.target.checked);
26
+ if (onChange) {
27
+ onChange(event.target.checked);
28
+ }
29
+ },
30
+ [onChange]
31
+ );
32
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
33
+ "div",
34
+ {
35
+ className: classnames(className, container, baseClassName),
36
+ "data-checked": isChecked,
37
+ onClick: (event) => {
38
+ if (event.target.tagName === "INPUT") {
39
+ return;
40
+ }
41
+ toggle();
42
+ },
43
+ children: [
44
+ /* @__PURE__ */ jsx(
45
+ "input",
46
+ {
47
+ ref,
48
+ type: "checkbox",
49
+ className: input,
50
+ checked: isChecked,
51
+ onChange: onChangeHandler,
52
+ ...restProps
53
+ }
54
+ ),
55
+ /* @__PURE__ */ jsx("div", { className: sliderClassName, "data-checked": isChecked })
56
+ ]
57
+ }
58
+ ) });
59
+ });
60
+ export {
61
+ Switch
62
+ };
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  const fileScope = require("@vanilla-extract/css/fileScope");
3
3
  const css = require("@vanilla-extract/css");
4
- const styles_lib_css_layers_layers_css_cjs = require("../../lib/css/layers/layers.css.cjs");
5
- fileScope.setFileScope("src/components/Switch/switch.css.ts?used", "blocks");
4
+ const styles_lib_css_layers_layers_css_cjs = require("../../../lib/css/layers/layers.css.cjs");
5
+ fileScope.setFileScope("src/components/form/Switch/switch.css.ts", "blocks");
6
6
  const container = css.style({
7
7
  "@layer": {
8
8
  [styles_lib_css_layers_layers_css_cjs.blocksLayer]: {
@@ -1,7 +1,7 @@
1
1
  import { setFileScope, endFileScope } from "@vanilla-extract/css/fileScope";
2
2
  import { style } from "@vanilla-extract/css";
3
- import { blocksLayer } from "../../lib/css/layers/layers.css.mjs";
4
- setFileScope("src/components/Switch/switch.css.ts?used", "blocks");
3
+ import { blocksLayer } from "../../../lib/css/layers/layers.css.mjs";
4
+ setFileScope("src/components/form/Switch/switch.css.ts", "blocks");
5
5
  const container = style({
6
6
  "@layer": {
7
7
  [blocksLayer]: {
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ const jsxRuntime = require("react/jsx-runtime");
3
+ const styles_lib_css_atoms_sprinkles_css_cjs = require("../../../lib/css/atoms/sprinkles.css.cjs");
4
+ const styles_components_display_Divider_Divider_cjs = require("../../display/Divider/Divider.cjs");
5
+ const BlocksProvider = ({
6
+ children,
7
+ theme,
8
+ className,
9
+ ...restProps
10
+ }) => {
11
+ return /* @__PURE__ */ jsxRuntime.jsx(styles_components_display_Divider_Divider_cjs.BlocksProviderContext.Provider, { value: theme, children: /* @__PURE__ */ jsxRuntime.jsx(
12
+ "div",
13
+ {
14
+ className: styles_components_display_Divider_Divider_cjs.classnames(theme.vars, styles_lib_css_atoms_sprinkles_css_cjs.atoms({ fontFamily: "primary" }), className),
15
+ ...restProps,
16
+ children
17
+ }
18
+ ) });
19
+ };
20
+ exports.BlocksProvider = BlocksProvider;
@@ -0,0 +1,21 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { atoms } from "../../../lib/css/atoms/sprinkles.css.mjs";
3
+ import { BlocksProviderContext, classnames } from "../../display/Divider/Divider.mjs";
4
+ const BlocksProvider = ({
5
+ children,
6
+ theme,
7
+ className,
8
+ ...restProps
9
+ }) => {
10
+ return /* @__PURE__ */ jsx(BlocksProviderContext.Provider, { value: theme, children: /* @__PURE__ */ jsx(
11
+ "div",
12
+ {
13
+ className: classnames(theme.vars, atoms({ fontFamily: "primary" }), className),
14
+ ...restProps,
15
+ children
16
+ }
17
+ ) });
18
+ };
19
+ export {
20
+ BlocksProvider
21
+ };
@@ -0,0 +1,245 @@
1
+ "use strict";
2
+ const jsxRuntime = require("react/jsx-runtime");
3
+ const react = require("react");
4
+ const styles_components_display_Divider_Divider_cjs = require("../../display/Divider/Divider.cjs");
5
+ const styles_components_overlay_Dialog_dialog_css_cjs = require("./dialog.css.cjs");
6
+ const reactDom = require("react-dom");
7
+ const styles_components_other_BlocksProvider_BlocksProvider_cjs = require("../../other/BlocksProvider/BlocksProvider.cjs");
8
+ const Portal = ({ children, container }) => {
9
+ const context = styles_components_display_Divider_Divider_cjs.useTheme();
10
+ return reactDom.createPortal(
11
+ /* @__PURE__ */ jsxRuntime.jsx(styles_components_other_BlocksProvider_BlocksProvider_cjs.BlocksProvider, { theme: context, children }),
12
+ container || document.body
13
+ );
14
+ };
15
+ const focusableSelectors = 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
16
+ const getFirstFocusableElement = (container) => {
17
+ const focusable = container.querySelector(focusableSelectors);
18
+ return focusable || null;
19
+ };
20
+ const focusFirstElement = (container) => {
21
+ const focusable = getFirstFocusableElement(container);
22
+ if (focusable) {
23
+ focusable.focus();
24
+ }
25
+ };
26
+ const useFocusLock = ({ ref, active }) => {
27
+ react.useEffect(() => {
28
+ if (!active) {
29
+ return;
30
+ }
31
+ const handleFocus = (event) => {
32
+ if (ref.current && event.target instanceof HTMLElement && !ref.current.contains(event.target)) {
33
+ focusFirstElement(ref.current);
34
+ }
35
+ };
36
+ document.addEventListener("focusin", handleFocus);
37
+ return () => {
38
+ document.removeEventListener("focusin", handleFocus);
39
+ };
40
+ }, [active, ref]);
41
+ };
42
+ const useIsomorphicLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
43
+ const useKeyboard = (key, callback, { enabled = true, type = "keydown" } = {}) => {
44
+ react.useEffect(() => {
45
+ if (!enabled) {
46
+ return;
47
+ }
48
+ function handleKeyDown(event) {
49
+ if (event.key === key) {
50
+ callback();
51
+ }
52
+ }
53
+ document.addEventListener(type, handleKeyDown);
54
+ return () => {
55
+ document.removeEventListener(type, handleKeyDown);
56
+ };
57
+ }, [callback, enabled, key, type]);
58
+ };
59
+ const useLayer = () => {
60
+ const layerRef = react.useRef();
61
+ react.useEffect(
62
+ () => () => {
63
+ if (layerRef.current) {
64
+ layerRef.current.remove();
65
+ layerRef.current = void 0;
66
+ }
67
+ },
68
+ []
69
+ );
70
+ return () => {
71
+ if (!layerRef.current) {
72
+ const div = document.createElement("div");
73
+ div.dataset.layer = "blocks";
74
+ layerRef.current = div;
75
+ document.body.append(layerRef.current);
76
+ }
77
+ return layerRef.current;
78
+ };
79
+ };
80
+ const usePreventBodyScroll = (enabled = true) => {
81
+ useIsomorphicLayoutEffect(() => {
82
+ if (!enabled) {
83
+ return;
84
+ }
85
+ const prevOverflow = document.body.style.getPropertyValue("overflow");
86
+ const prevScrollTop = document.documentElement.scrollTop;
87
+ if (document.body.scrollHeight > window.innerHeight) {
88
+ document.body.style.position = "fixed";
89
+ document.body.style.overflow = "hidden";
90
+ document.body.style.overflowY = "scroll";
91
+ document.body.style.width = "100%";
92
+ document.body.style.top = `-${prevScrollTop}px`;
93
+ } else {
94
+ document.body.style.overflow = "hidden";
95
+ }
96
+ return () => {
97
+ document.body.style.position = "";
98
+ document.body.style.overflow = prevOverflow;
99
+ document.body.style.overflowY = "";
100
+ document.body.style.width = "";
101
+ document.body.style.top = "";
102
+ document.documentElement.scrollTop = prevScrollTop;
103
+ };
104
+ }, [enabled]);
105
+ };
106
+ const isBrowser = typeof window !== "undefined";
107
+ const useRestoreFocus = (active) => {
108
+ const target = react.useRef(null);
109
+ if (isBrowser && active && !target.current) {
110
+ target.current = document.activeElement;
111
+ }
112
+ react.useEffect(() => {
113
+ if (target.current && !active && target.current instanceof HTMLElement) {
114
+ target.current.focus();
115
+ }
116
+ if (!active) {
117
+ target.current = null;
118
+ }
119
+ }, [active]);
120
+ };
121
+ const useVisibilityState = (open) => {
122
+ const [visible, setVisible] = react.useState(open);
123
+ const hide = react.useCallback(() => {
124
+ setVisible(false);
125
+ }, []);
126
+ react.useEffect(() => {
127
+ if (open) {
128
+ setVisible(true);
129
+ }
130
+ }, [open]);
131
+ return [visible, hide];
132
+ };
133
+ function hasAnimationDuration(element) {
134
+ if (!element) {
135
+ return false;
136
+ }
137
+ const style = window.getComputedStyle(element);
138
+ return style.transitionDuration !== "0s" || style.animationDuration !== "0s";
139
+ }
140
+ const DialogContext = react.createContext(void 0);
141
+ const useNestedDialog = (open) => {
142
+ const parentDialog = react.useContext(DialogContext);
143
+ react.useEffect(() => {
144
+ if (!parentDialog || !open) {
145
+ return;
146
+ }
147
+ parentDialog.setEnabled(false);
148
+ return () => {
149
+ parentDialog.setEnabled(true);
150
+ };
151
+ }, [parentDialog, open]);
152
+ return !!parentDialog;
153
+ };
154
+ const Dialog = ({
155
+ children,
156
+ open,
157
+ className,
158
+ onRequestClose,
159
+ size,
160
+ ...restProps
161
+ }) => {
162
+ const backdropClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("dialog", { backdrop: true }, false);
163
+ const dialogClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("dialog", { dialog: true, variants: { size } });
164
+ const backdropRef = react.useRef(null);
165
+ const dialogRef = react.useRef(null);
166
+ const layer = useLayer();
167
+ const [visible, hide] = useVisibilityState(open);
168
+ const [enabled, setEnabled] = react.useState(true);
169
+ const onBackdropClick = react.useCallback(
170
+ (event) => {
171
+ if (event.target === event.currentTarget) {
172
+ onRequestClose();
173
+ }
174
+ },
175
+ [onRequestClose]
176
+ );
177
+ useFocusLock({ ref: dialogRef, active: open && enabled });
178
+ useRestoreFocus(open);
179
+ const isNested = useNestedDialog(visible);
180
+ usePreventBodyScroll(visible && !isNested);
181
+ useKeyboard("Escape", onRequestClose, { enabled: open && enabled });
182
+ useIsomorphicLayoutEffect(() => {
183
+ var _a, _b;
184
+ if (!open) {
185
+ (_a = backdropRef.current) == null ? void 0 : _a.removeAttribute("data-open");
186
+ (_b = dialogRef.current) == null ? void 0 : _b.removeAttribute("data-open");
187
+ return;
188
+ }
189
+ let timer = requestAnimationFrame(() => {
190
+ timer = requestAnimationFrame(() => {
191
+ var _a2, _b2;
192
+ (_a2 = backdropRef.current) == null ? void 0 : _a2.setAttribute("data-open", "");
193
+ (_b2 = dialogRef.current) == null ? void 0 : _b2.setAttribute("data-open", "");
194
+ });
195
+ });
196
+ return () => {
197
+ cancelAnimationFrame(timer);
198
+ };
199
+ }, [open, visible]);
200
+ const onAnimationEnd = react.useCallback(() => {
201
+ if (!open) {
202
+ hide();
203
+ }
204
+ }, [hide, open]);
205
+ react.useEffect(() => {
206
+ if (open) {
207
+ return;
208
+ }
209
+ if (!hasAnimationDuration(dialogRef.current)) {
210
+ hide();
211
+ }
212
+ }, [hide, open]);
213
+ if (!visible) {
214
+ return null;
215
+ }
216
+ const dataOpen = typeof window === "undefined" && open ? "" : void 0;
217
+ return /* @__PURE__ */ jsxRuntime.jsx(Portal, { container: layer(), children: /* @__PURE__ */ jsxRuntime.jsx(DialogContext.Provider, { value: { setEnabled }, children: /* @__PURE__ */ jsxRuntime.jsx(
218
+ styles_components_display_Divider_Divider_cjs.Box,
219
+ {
220
+ ref: backdropRef,
221
+ className: styles_components_display_Divider_Divider_cjs.classnames(styles_components_overlay_Dialog_dialog_css_cjs.backdrop, backdropClassName),
222
+ "data-open": dataOpen,
223
+ onClick: onBackdropClick,
224
+ onAnimationEnd,
225
+ onTransitionEnd: onAnimationEnd,
226
+ children: /* @__PURE__ */ jsxRuntime.jsx(
227
+ "dialog",
228
+ {
229
+ ref: dialogRef,
230
+ "aria-modal": "true",
231
+ open: true,
232
+ "data-open": dataOpen,
233
+ className: styles_components_display_Divider_Divider_cjs.classnames(dialogClassName, className),
234
+ ...restProps,
235
+ children
236
+ }
237
+ )
238
+ }
239
+ ) }) });
240
+ };
241
+ exports.Dialog = Dialog;
242
+ exports.Portal = Portal;
243
+ exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
244
+ exports.useKeyboard = useKeyboard;
245
+ exports.usePreventBodyScroll = usePreventBodyScroll;