@blockle/blocks 0.19.0 → 0.20.0-alpha1

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 (283) hide show
  1. package/dist/components/accessibility/VisuallyHidden/VisuallyHidden.cjs +19 -0
  2. package/dist/components/accessibility/VisuallyHidden/VisuallyHidden.mjs +20 -0
  3. package/dist/components/accessibility/VisuallyHidden/index.cjs +1 -0
  4. package/dist/components/accessibility/VisuallyHidden/index.mjs +1 -0
  5. package/dist/{styles/components/Accessibility → components/accessibility}/VisuallyHidden/visually-hidden.css.cjs +1 -1
  6. package/dist/{styles/components/Accessibility → components/accessibility}/VisuallyHidden/visually-hidden.css.mjs +1 -1
  7. package/dist/components/display/Divider/Divider.cjs +25 -0
  8. package/dist/components/display/Divider/Divider.mjs +26 -0
  9. package/dist/{styles/components → components}/display/Divider/divider.css.cjs +2 -2
  10. package/dist/components/display/Divider/index.cjs +1 -0
  11. package/dist/components/display/Divider/index.mjs +1 -0
  12. package/dist/components/feedback/Progress/Progress.cjs +53 -0
  13. package/dist/components/feedback/Progress/Progress.mjs +54 -0
  14. package/dist/components/feedback/Progress/index.cjs +1 -0
  15. package/dist/components/feedback/Progress/index.mjs +1 -0
  16. package/dist/components/feedback/Spinner/Spinner.cjs +25 -0
  17. package/dist/components/feedback/Spinner/Spinner.mjs +26 -0
  18. package/dist/components/feedback/Spinner/index.cjs +1 -0
  19. package/dist/components/feedback/Spinner/index.mjs +1 -0
  20. package/dist/components/form/Button/Button.cjs +58 -0
  21. package/dist/{styles/components → components}/form/Button/Button.css.cjs +2 -2
  22. package/dist/{styles/components → components}/form/Button/Button.mjs +13 -11
  23. package/dist/components/form/Button/index.cjs +1 -0
  24. package/dist/components/form/Button/index.mjs +1 -0
  25. package/dist/components/form/Checkbox/Checkbox.cjs +78 -0
  26. package/dist/components/form/Checkbox/Checkbox.mjs +79 -0
  27. package/dist/{styles/components → components}/form/Checkbox/checkbox.css.cjs +3 -3
  28. package/dist/components/form/Checkbox/index.cjs +1 -0
  29. package/dist/components/form/Checkbox/index.mjs +1 -0
  30. package/dist/components/form/Input/Input.cjs +50 -0
  31. package/dist/components/form/Input/Input.mjs +51 -0
  32. package/dist/components/form/Input/index.cjs +1 -0
  33. package/dist/components/form/Input/index.mjs +1 -0
  34. package/dist/{styles/components → components}/form/Input/input.css.cjs +2 -2
  35. package/dist/components/form/Label/Label.cjs +29 -0
  36. package/dist/components/form/Label/Label.mjs +30 -0
  37. package/dist/components/form/Label/index.cjs +1 -0
  38. package/dist/components/form/Label/index.mjs +1 -0
  39. package/dist/components/form/Radio/Radio.cjs +47 -0
  40. package/dist/components/form/Radio/Radio.mjs +48 -0
  41. package/dist/components/form/Radio/RadioGroup.cjs +1 -0
  42. package/dist/components/form/Radio/RadioGroup.mjs +1 -0
  43. package/dist/components/form/Radio/index.cjs +1 -0
  44. package/dist/components/form/Radio/index.mjs +1 -0
  45. package/dist/{styles/components → components}/form/Radio/radio.css.cjs +3 -3
  46. package/dist/components/form/Select/Select.cjs +64 -0
  47. package/dist/{styles/components → components}/form/Select/Select.mjs +23 -6
  48. package/dist/components/form/Select/index.cjs +1 -0
  49. package/dist/components/form/Select/index.mjs +1 -0
  50. package/dist/{styles/components → components}/form/Select/select.css.cjs +4 -4
  51. package/dist/components/form/Slider/Slider.cjs +139 -0
  52. package/dist/components/form/Slider/Slider.mjs +142 -0
  53. package/dist/components/form/Slider/index.cjs +1 -0
  54. package/dist/components/form/Slider/index.mjs +1 -0
  55. package/dist/{styles/components → components}/form/Slider/slider.css.cjs +6 -6
  56. package/dist/components/form/Slider/usePointerProgress.cjs +44 -0
  57. package/dist/components/form/Slider/usePointerProgress.mjs +45 -0
  58. package/dist/{styles/components → components}/form/Switch/Switch.cjs +10 -8
  59. package/dist/{styles/components → components}/form/Switch/Switch.mjs +9 -5
  60. package/dist/components/form/Switch/index.cjs +1 -0
  61. package/dist/components/form/Switch/index.mjs +1 -0
  62. package/dist/{styles/components → components}/form/Switch/switch.css.cjs +3 -3
  63. package/dist/components/layout/Box/Box.cjs +27 -0
  64. package/dist/components/layout/Box/Box.mjs +28 -0
  65. package/dist/components/layout/Box/index.cjs +1 -0
  66. package/dist/components/layout/Box/index.mjs +1 -0
  67. package/dist/components/layout/Inline/Inline.cjs +29 -0
  68. package/dist/components/layout/Inline/Inline.mjs +30 -0
  69. package/dist/components/layout/Inline/index.cjs +1 -0
  70. package/dist/components/layout/Inline/index.mjs +1 -0
  71. package/dist/components/layout/Stack/Stack.cjs +29 -0
  72. package/dist/components/layout/Stack/Stack.mjs +30 -0
  73. package/dist/components/layout/Stack/index.cjs +1 -0
  74. package/dist/components/layout/Stack/index.mjs +1 -0
  75. package/dist/components/navigation/Link/Link.cjs +31 -0
  76. package/dist/components/navigation/Link/Link.mjs +32 -0
  77. package/dist/components/navigation/Link/index.cjs +1 -0
  78. package/dist/components/navigation/Link/index.mjs +1 -0
  79. package/dist/components/other/BlocksProvider/BlocksProvider.cjs +36 -0
  80. package/dist/components/other/BlocksProvider/BlocksProvider.mjs +39 -0
  81. package/dist/components/other/BlocksProvider/context.cjs +4 -0
  82. package/dist/components/other/BlocksProvider/context.mjs +7 -0
  83. package/dist/components/other/BlocksProvider/index.cjs +1 -0
  84. package/dist/components/other/BlocksProvider/index.mjs +1 -0
  85. package/dist/components/other/Portal/Portal.cjs +7 -0
  86. package/dist/components/other/Portal/Portal.mjs +8 -0
  87. package/dist/components/other/Portal/index.cjs +1 -0
  88. package/dist/components/other/Portal/index.mjs +1 -0
  89. package/dist/components/overlay/Dialog/Dialog.cjs +77 -0
  90. package/dist/components/overlay/Dialog/Dialog.mjs +80 -0
  91. package/dist/{styles/components → components}/overlay/Dialog/dialog.css.cjs +2 -2
  92. package/dist/components/overlay/Dialog/dialogHelper.cjs +20 -0
  93. package/dist/components/overlay/Dialog/dialogHelper.mjs +21 -0
  94. package/dist/components/overlay/Dialog/index.cjs +1 -0
  95. package/dist/components/overlay/Dialog/index.mjs +1 -0
  96. package/dist/components/overlay/Popover/Popover.cjs +111 -0
  97. package/dist/components/overlay/Popover/Popover.mjs +112 -0
  98. package/dist/components/overlay/Popover/popover-utils.cjs +61 -0
  99. package/dist/components/overlay/Popover/popover-utils.mjs +62 -0
  100. package/dist/components/overlay/Tooltip/Tooltip.cjs +71 -0
  101. package/dist/components/overlay/Tooltip/Tooltip.mjs +74 -0
  102. package/dist/components/overlay/Tooltip/index.cjs +1 -0
  103. package/dist/components/overlay/Tooltip/index.mjs +1 -0
  104. package/dist/components/typography/Heading/Heading.cjs +23 -0
  105. package/dist/components/typography/Heading/Heading.mjs +24 -0
  106. package/dist/{styles/components → components}/typography/Heading/heading.css.cjs +2 -2
  107. package/dist/components/typography/Heading/index.cjs +1 -0
  108. package/dist/components/typography/Heading/index.mjs +1 -0
  109. package/dist/components/typography/Text/Text.cjs +20 -0
  110. package/dist/{styles/components → components}/typography/Text/Text.mjs +2 -2
  111. package/dist/components/typography/Text/index.cjs +1 -0
  112. package/dist/components/typography/Text/index.mjs +1 -0
  113. package/dist/{styles/components → components}/typography/Text/text.css.cjs +2 -2
  114. package/dist/hooks/useClickOutside/useClickOutside.cjs +22 -0
  115. package/dist/hooks/useClickOutside/useClickOutside.mjs +23 -0
  116. package/dist/hooks/useControlledValue/useControlledValue.cjs +31 -0
  117. package/dist/hooks/useControlledValue/useControlledValue.mjs +32 -0
  118. package/dist/hooks/useIsomorphicLayoutEffect/index.cjs +1 -0
  119. package/dist/hooks/useIsomorphicLayoutEffect/index.mjs +1 -0
  120. package/dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs +4 -0
  121. package/dist/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.mjs +7 -0
  122. package/dist/hooks/useKeyboard/index.cjs +1 -0
  123. package/dist/hooks/useKeyboard/index.mjs +1 -0
  124. package/dist/hooks/useKeyboard/useKeyboard.cjs +19 -0
  125. package/dist/hooks/useKeyboard/useKeyboard.mjs +22 -0
  126. package/dist/hooks/useLayer/index.cjs +1 -0
  127. package/dist/hooks/useLayer/index.mjs +1 -0
  128. package/dist/hooks/useLayer/useLayer.cjs +25 -0
  129. package/dist/hooks/useLayer/useLayer.mjs +26 -0
  130. package/dist/hooks/usePreventBodyScroll/index.cjs +1 -0
  131. package/dist/hooks/usePreventBodyScroll/index.mjs +1 -0
  132. package/dist/hooks/usePreventBodyScroll/usePreventBodyScroll.cjs +29 -0
  133. package/dist/hooks/usePreventBodyScroll/usePreventBodyScroll.mjs +30 -0
  134. package/dist/hooks/useRestoreFocus/index.cjs +1 -0
  135. package/dist/hooks/useRestoreFocus/index.mjs +1 -0
  136. package/dist/hooks/useRestoreFocus/useRestoreFocus.cjs +17 -0
  137. package/dist/hooks/useRestoreFocus/useRestoreFocus.mjs +18 -0
  138. package/dist/hooks/useRootAriaHidden/index.cjs +1 -0
  139. package/dist/hooks/useRootAriaHidden/index.mjs +1 -0
  140. package/dist/hooks/useRootAriaHidden/useRootAriaHidden.cjs +11 -0
  141. package/dist/hooks/useRootAriaHidden/useRootAriaHidden.mjs +12 -0
  142. package/dist/hooks/useVisibilityState/index.cjs +1 -0
  143. package/dist/hooks/useVisibilityState/index.mjs +1 -0
  144. package/dist/hooks/useVisibilityState/useVisibilityState.cjs +15 -0
  145. package/dist/hooks/useVisibilityState/useVisibilityState.mjs +16 -0
  146. package/dist/index.cjs +71 -444
  147. package/dist/index.d.mts +1 -1
  148. package/dist/index.d.ts +1 -1
  149. package/dist/index.mjs +37 -415
  150. package/dist/lib/asChildRenderer/createAsChildTemplate.cjs +72 -0
  151. package/dist/lib/asChildRenderer/createAsChildTemplate.mjs +73 -0
  152. package/dist/{styles/lib → lib}/css/atoms/atomicProperties.cjs +28 -22
  153. package/dist/{styles/lib → lib}/css/atoms/atomicProperties.mjs +7 -1
  154. package/dist/{styles/lib → lib}/css/atoms/sprinkles.css.cjs +8 -8
  155. package/dist/lib/css/flexbox/flexbox.cjs +16 -0
  156. package/dist/lib/css/flexbox/flexbox.mjs +17 -0
  157. package/dist/{styles/lib → lib}/css/style/style.cjs +3 -3
  158. package/dist/lib/react/mergeProps.cjs +42 -0
  159. package/dist/lib/react/mergeProps.mjs +43 -0
  160. package/dist/lib/react/refs.cjs +16 -0
  161. package/dist/lib/react/refs.mjs +17 -0
  162. package/dist/lib/theme/makeTheme.cjs +12 -0
  163. package/dist/lib/theme/store/theme.cjs +92 -0
  164. package/dist/lib/theme/store/theme.mjs +93 -0
  165. package/dist/lib/theme/vars.css.cjs +9 -0
  166. package/dist/{styles/lib → lib}/utils/atom-props.cjs +2 -2
  167. package/dist/lib/utils/classnames.cjs +6 -0
  168. package/dist/lib/utils/classnames.mjs +7 -0
  169. package/dist/lib/utils/dom.cjs +12 -0
  170. package/dist/lib/utils/dom.mjs +13 -0
  171. package/dist/lib/utils/math.cjs +12 -0
  172. package/dist/lib/utils/math.mjs +13 -0
  173. package/dist/momotaro.chunk.d.ts +40 -56
  174. package/dist/reset.cjs +2 -2
  175. package/dist/reset.mjs +2 -2
  176. package/dist/{styles/themes → themes}/momotaro/components/button.css.cjs +23 -23
  177. package/dist/themes/momotaro/components/checkbox.css.cjs +59 -0
  178. package/dist/{styles/themes → themes}/momotaro/components/dialog.css.cjs +4 -4
  179. package/dist/{styles/themes → themes}/momotaro/components/divider.css.cjs +2 -2
  180. package/dist/{styles/themes → themes}/momotaro/components/helpers.css.cjs +3 -3
  181. package/dist/themes/momotaro/components/index.cjs +34 -0
  182. package/dist/{styles/themes → themes}/momotaro/components/input.css.cjs +9 -9
  183. package/dist/{styles/themes → themes}/momotaro/components/label.css.cjs +7 -7
  184. package/dist/{styles/themes → themes}/momotaro/components/link.css.cjs +7 -7
  185. package/dist/{styles/themes → themes}/momotaro/components/popover.css.cjs +4 -4
  186. package/dist/{styles/themes → themes}/momotaro/components/progress.css.cjs +7 -7
  187. package/dist/themes/momotaro/components/radio.css.cjs +60 -0
  188. package/dist/themes/momotaro/components/select.css.cjs +44 -0
  189. package/dist/themes/momotaro/components/slider.css.cjs +89 -0
  190. package/dist/{styles/themes → themes}/momotaro/components/spinner.css.cjs +2 -2
  191. package/dist/{styles/themes → themes}/momotaro/components/switch.css.cjs +10 -10
  192. package/dist/{styles/themes → themes}/momotaro/components/tooltip.css.cjs +6 -6
  193. package/dist/themes/momotaro/momotaro.css.cjs +13 -0
  194. package/dist/{styles/themes → themes}/momotaro/tokens.css.cjs +11 -11
  195. package/dist/themes/momotaro.cjs +2 -2
  196. package/dist/themes/momotaro.mjs +1 -1
  197. package/package.json +5 -15
  198. package/dist/styles/components/Accessibility/VisuallyHidden/VisuallyHidden.cjs +0 -16
  199. package/dist/styles/components/Accessibility/VisuallyHidden/VisuallyHidden.mjs +0 -17
  200. package/dist/styles/components/display/Divider/Divider.cjs +0 -239
  201. package/dist/styles/components/display/Divider/Divider.mjs +0 -240
  202. package/dist/styles/components/form/Button/Button.cjs +0 -56
  203. package/dist/styles/components/form/Checkbox/Checkbox.cjs +0 -84
  204. package/dist/styles/components/form/Checkbox/Checkbox.mjs +0 -85
  205. package/dist/styles/components/form/Input/Input.cjs +0 -37
  206. package/dist/styles/components/form/Input/Input.mjs +0 -38
  207. package/dist/styles/components/form/Radio/Radio.cjs +0 -23
  208. package/dist/styles/components/form/Radio/Radio.mjs +0 -24
  209. package/dist/styles/components/form/Select/Select.cjs +0 -47
  210. package/dist/styles/components/form/Slider/Slider.cjs +0 -205
  211. package/dist/styles/components/form/Slider/Slider.mjs +0 -206
  212. package/dist/styles/components/other/BlocksProvider/BlocksProvider.cjs +0 -41
  213. package/dist/styles/components/other/BlocksProvider/BlocksProvider.mjs +0 -42
  214. package/dist/styles/components/overlay/Dialog/Dialog.cjs +0 -172
  215. package/dist/styles/components/overlay/Dialog/Dialog.mjs +0 -173
  216. package/dist/styles/components/typography/Heading/Heading.cjs +0 -15
  217. package/dist/styles/components/typography/Heading/Heading.mjs +0 -16
  218. package/dist/styles/components/typography/Text/Text.cjs +0 -20
  219. package/dist/styles/lib/theme/makeTheme.cjs +0 -12
  220. package/dist/styles/lib/theme/vars.css.cjs +0 -9
  221. package/dist/styles/themes/momotaro/components/checkbox.css.cjs +0 -59
  222. package/dist/styles/themes/momotaro/components/index.cjs +0 -34
  223. package/dist/styles/themes/momotaro/components/radio.css.cjs +0 -60
  224. package/dist/styles/themes/momotaro/components/select.css.cjs +0 -44
  225. package/dist/styles/themes/momotaro/components/slider.css.cjs +0 -89
  226. package/dist/styles/themes/momotaro/momotaro.css.cjs +0 -13
  227. /package/dist/{styles/components → components}/display/Divider/divider.css.mjs +0 -0
  228. /package/dist/{styles/components → components}/form/Button/Button.css.mjs +0 -0
  229. /package/dist/{styles/components → components}/form/Checkbox/checkbox.css.mjs +0 -0
  230. /package/dist/{styles/components → components}/form/Input/input.css.mjs +0 -0
  231. /package/dist/{styles/components → components}/form/Radio/radio.css.mjs +0 -0
  232. /package/dist/{styles/components → components}/form/Select/select.css.mjs +0 -0
  233. /package/dist/{styles/components → components}/form/Slider/slider.css.mjs +0 -0
  234. /package/dist/{styles/components → components}/form/Switch/switch.css.mjs +0 -0
  235. /package/dist/{styles/components → components}/overlay/Dialog/dialog.css.mjs +0 -0
  236. /package/dist/{styles/components → components}/typography/Heading/heading.css.mjs +0 -0
  237. /package/dist/{styles/components → components}/typography/Text/text.css.mjs +0 -0
  238. /package/dist/{styles/lib → lib}/css/atoms/atoms.cjs +0 -0
  239. /package/dist/{styles/lib → lib}/css/atoms/atoms.mjs +0 -0
  240. /package/dist/{styles/lib → lib}/css/atoms/breakpoints.cjs +0 -0
  241. /package/dist/{styles/lib → lib}/css/atoms/breakpoints.mjs +0 -0
  242. /package/dist/{styles/lib → lib}/css/atoms/index.cjs +0 -0
  243. /package/dist/{styles/lib → lib}/css/atoms/index.mjs +0 -0
  244. /package/dist/{styles/lib → lib}/css/atoms/sprinkles.css.mjs +0 -0
  245. /package/dist/{styles/lib → lib}/css/layers/layers.css.cjs +0 -0
  246. /package/dist/{styles/lib → lib}/css/layers/layers.css.mjs +0 -0
  247. /package/dist/{styles/lib → lib}/css/reset/reset.css.cjs +0 -0
  248. /package/dist/{styles/lib → lib}/css/reset/reset.css.mjs +0 -0
  249. /package/dist/{styles/lib → lib}/css/style/style.mjs +0 -0
  250. /package/dist/{styles/lib → lib}/css/utils/cssUtils.cjs +0 -0
  251. /package/dist/{styles/lib → lib}/css/utils/cssUtils.mjs +0 -0
  252. /package/dist/{styles/lib → lib}/theme/makeComponentTheme.cjs +0 -0
  253. /package/dist/{styles/lib → lib}/theme/makeComponentTheme.mjs +0 -0
  254. /package/dist/{styles/lib → lib}/theme/makeTheme.mjs +0 -0
  255. /package/dist/{styles/lib → lib}/theme/makeVanillaTheme.cjs +0 -0
  256. /package/dist/{styles/lib → lib}/theme/makeVanillaTheme.mjs +0 -0
  257. /package/dist/{styles/lib → lib}/theme/tokens.cjs +0 -0
  258. /package/dist/{styles/lib → lib}/theme/tokens.mjs +0 -0
  259. /package/dist/{styles/lib → lib}/theme/vars.css.mjs +0 -0
  260. /package/dist/{styles/lib → lib}/utils/atom-props.mjs +0 -0
  261. /package/dist/{styles/themes → themes}/momotaro/components/button.css.mjs +0 -0
  262. /package/dist/{styles/themes → themes}/momotaro/components/checkbox.css.mjs +0 -0
  263. /package/dist/{styles/themes → themes}/momotaro/components/dialog.css.mjs +0 -0
  264. /package/dist/{styles/themes → themes}/momotaro/components/divider.css.mjs +0 -0
  265. /package/dist/{styles/themes → themes}/momotaro/components/helpers.css.mjs +0 -0
  266. /package/dist/{styles/themes → themes}/momotaro/components/index.mjs +0 -0
  267. /package/dist/{styles/themes → themes}/momotaro/components/input.css.mjs +0 -0
  268. /package/dist/{styles/themes → themes}/momotaro/components/label.css.mjs +0 -0
  269. /package/dist/{styles/themes → themes}/momotaro/components/link.css.mjs +0 -0
  270. /package/dist/{styles/themes → themes}/momotaro/components/popover.css.mjs +0 -0
  271. /package/dist/{styles/themes → themes}/momotaro/components/progress.css.mjs +0 -0
  272. /package/dist/{styles/themes → themes}/momotaro/components/radio.css.mjs +0 -0
  273. /package/dist/{styles/themes → themes}/momotaro/components/select.css.mjs +0 -0
  274. /package/dist/{styles/themes → themes}/momotaro/components/slider.css.mjs +0 -0
  275. /package/dist/{styles/themes → themes}/momotaro/components/spinner.css.mjs +0 -0
  276. /package/dist/{styles/themes → themes}/momotaro/components/switch.css.mjs +0 -0
  277. /package/dist/{styles/themes → themes}/momotaro/components/tooltip.css.mjs +0 -0
  278. /package/dist/{styles/themes → themes}/momotaro/components/transitions.cjs +0 -0
  279. /package/dist/{styles/themes → themes}/momotaro/components/transitions.mjs +0 -0
  280. /package/dist/{styles/themes → themes}/momotaro/index.cjs +0 -0
  281. /package/dist/{styles/themes → themes}/momotaro/index.mjs +0 -0
  282. /package/dist/{styles/themes → themes}/momotaro/momotaro.css.mjs +0 -0
  283. /package/dist/{styles/themes → themes}/momotaro/tokens.css.mjs +0 -0
@@ -1,17 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { visuallyHidden } from "./visually-hidden.css.mjs";
3
- const classnames = (...args) => {
4
- const className = args.filter((arg) => arg && typeof arg === "string").join(" ");
5
- return className || void 0;
6
- };
7
- const VisuallyHidden = ({
8
- children,
9
- className,
10
- ...restProps
11
- }) => {
12
- return /* @__PURE__ */ jsx("span", { className: classnames(visuallyHidden, className), ...restProps, children });
13
- };
14
- export {
15
- VisuallyHidden,
16
- classnames
17
- };
@@ -1,239 +0,0 @@
1
- "use strict";
2
- const jsxRuntime = require("react/jsx-runtime");
3
- const styles_components_Accessibility_VisuallyHidden_VisuallyHidden_cjs = require("../../Accessibility/VisuallyHidden/VisuallyHidden.cjs");
4
- const styles_components_display_Divider_divider_css_cjs = require("./divider.css.cjs");
5
- const react = require("react");
6
- const styles_lib_utils_atomProps_cjs = require("../../../lib/utils/atom-props.cjs");
7
- const styles_lib_css_atoms_sprinkles_css_cjs = require("../../../lib/css/atoms/sprinkles.css.cjs");
8
- const BlocksProviderContext = react.createContext(null);
9
- const useTheme = () => {
10
- const context = react.useContext(BlocksProviderContext);
11
- if (!context) {
12
- throw new Error("useTheme must be used within a BlocksProvider");
13
- }
14
- return context.theme;
15
- };
16
- function useComponentStyles(name, props, useDefaultVariants = true) {
17
- const { components } = useTheme();
18
- const component = components[name];
19
- if (!component) {
20
- console.warn(`Component ${name} is not defined in the theme`);
21
- return "";
22
- }
23
- const classNames = [];
24
- const variants = props.variants ?? {};
25
- const variantsWithDefaults = { ...variants };
26
- for (const key in props) {
27
- const value = props[key];
28
- if (typeof value === "boolean" && value) {
29
- classNames.push(component[key]);
30
- }
31
- }
32
- if (!component.variants) {
33
- return classNames.join(" ");
34
- }
35
- const { defaultVariants } = component;
36
- if (useDefaultVariants && defaultVariants) {
37
- const keys2 = Object.keys(defaultVariants);
38
- for (const key of keys2) {
39
- if (variantsWithDefaults[key] === void 0 && defaultVariants[key]) {
40
- variantsWithDefaults[key] = defaultVariants[key];
41
- }
42
- }
43
- }
44
- const keys = Object.keys(variantsWithDefaults);
45
- const componentVariants = component.variants;
46
- for (const key of keys) {
47
- const value = variantsWithDefaults[key];
48
- if (value === void 0 || componentVariants[key] === void 0) {
49
- continue;
50
- }
51
- if (typeof value === "boolean") {
52
- if (value && componentVariants[key]) {
53
- classNames.push(componentVariants[key]);
54
- }
55
- continue;
56
- }
57
- const variant = componentVariants[key][value];
58
- if (variant) {
59
- classNames.push(variant);
60
- }
61
- }
62
- const { compoundVariants } = component;
63
- if (compoundVariants) {
64
- for (const compoundVariant of compoundVariants) {
65
- const keys2 = Object.keys(compoundVariant.variants);
66
- const matches = keys2.every((key) => {
67
- const value = variantsWithDefaults[key];
68
- if (value === void 0) {
69
- return false;
70
- }
71
- return value === compoundVariant.variants[key];
72
- });
73
- if (matches) {
74
- classNames.push(compoundVariant.style);
75
- }
76
- }
77
- }
78
- return classNames.join(" ");
79
- }
80
- const useComponentStyleDefaultProps = (name) => {
81
- const { components } = useTheme();
82
- const component = components[name];
83
- if (!component) {
84
- return {};
85
- }
86
- return component.defaultVariants ?? {};
87
- };
88
- function setRef(ref, value) {
89
- if (typeof ref === "function") {
90
- ref(value);
91
- } else if (ref !== null && ref !== void 0) {
92
- ref.current = value;
93
- }
94
- }
95
- function composeRefs(...refs) {
96
- return (node) => {
97
- for (const ref of refs) {
98
- setRef(ref, node);
99
- }
100
- };
101
- }
102
- function mergeProps(slotProps, childProps) {
103
- const overrideProps = {};
104
- for (const propName in childProps) {
105
- const slotPropValue = slotProps[propName];
106
- const childPropValue = childProps[propName];
107
- if (childPropValue === void 0) {
108
- continue;
109
- }
110
- if (slotPropValue === void 0) {
111
- overrideProps[propName] = childPropValue;
112
- continue;
113
- }
114
- if (typeof slotPropValue === "function" && typeof childPropValue === "function") {
115
- overrideProps[propName] = (...args) => {
116
- childPropValue(...args);
117
- slotPropValue(...args);
118
- };
119
- } else
120
- switch (propName) {
121
- case "style": {
122
- overrideProps[propName] = { ...slotPropValue, ...childPropValue };
123
- break;
124
- }
125
- case "className": {
126
- overrideProps[propName] = styles_components_Accessibility_VisuallyHidden_VisuallyHidden_cjs.classnames(slotPropValue, childPropValue);
127
- break;
128
- }
129
- case "ref": {
130
- overrideProps[propName] = composeRefs(slotPropValue, childPropValue);
131
- break;
132
- }
133
- default: {
134
- overrideProps[propName] = childPropValue;
135
- }
136
- }
137
- }
138
- return { ...slotProps, ...overrideProps };
139
- }
140
- function createAsChildTemplate(defaultElement) {
141
- const Tag = defaultElement;
142
- const Template2 = ({
143
- asChild,
144
- children,
145
- ref,
146
- ...rootProps
147
- }) => {
148
- if (!asChild) {
149
- const tagProps = { ref, ...rootProps };
150
- return /* @__PURE__ */ jsxRuntime.jsx(Tag, { ...tagProps, children });
151
- }
152
- const childrenArray = react.Children.toArray(children);
153
- const slotIndex = childrenArray.findIndex((child) => {
154
- if (!react.isValidElement(child)) {
155
- return false;
156
- }
157
- return child.type === Slot$1;
158
- });
159
- const slot = childrenArray[slotIndex];
160
- if (!slot) {
161
- if (process.env.NODE_ENV !== "production") {
162
- console.error("Template: No Slot provided");
163
- }
164
- return null;
165
- }
166
- if (!isValidElementWithChildren(slot)) {
167
- return null;
168
- }
169
- if (!react.isValidElement(slot.props.children)) {
170
- if (process.env.NODE_ENV !== "production") {
171
- if (react.Children.toArray(slot.props.children).length === 0) {
172
- console.error("When using asChild, at least one child is required");
173
- } else {
174
- console.error("When using asChild, only one child is allowed");
175
- }
176
- }
177
- return null;
178
- }
179
- if (!isValidElementWithChildren(slot.props.children)) {
180
- return null;
181
- }
182
- const nextChildren = [...childrenArray];
183
- if (nextChildren.length === 1 && !slot.props.children.props.children) {
184
- return react.cloneElement(slot.props.children, mergeProps(rootProps, slot.props.children.props));
185
- }
186
- nextChildren[slotIndex] = slot.props.children.props.children;
187
- return react.cloneElement(
188
- slot.props.children,
189
- mergeProps(rootProps, slot.props.children.props),
190
- nextChildren
191
- );
192
- };
193
- return {
194
- Template: Template2,
195
- Slot: Slot$1
196
- };
197
- }
198
- function isValidElementWithChildren(child) {
199
- return react.isValidElement(child) && !!child.props;
200
- }
201
- const Slot$1 = ({ children }) => {
202
- return children;
203
- };
204
- const { Template, Slot } = createAsChildTemplate("div");
205
- const Box = ({ asChild, className, children, ref, ...restProps }) => {
206
- const [atomsProps, otherProps] = styles_lib_utils_atomProps_cjs.getAtomsAndProps(restProps);
207
- return /* @__PURE__ */ jsxRuntime.jsx(
208
- Template,
209
- {
210
- ref,
211
- asChild,
212
- className: styles_components_Accessibility_VisuallyHidden_VisuallyHidden_cjs.classnames(className, styles_lib_css_atoms_sprinkles_css_cjs.atoms(atomsProps)),
213
- ...otherProps,
214
- children: /* @__PURE__ */ jsxRuntime.jsx(Slot, { children })
215
- }
216
- );
217
- };
218
- const Divider = ({ className, color, ...restProps }) => {
219
- const dividerClass = useComponentStyles("divider", { base: true });
220
- const dividerDefaults = useComponentStyleDefaultProps("divider");
221
- return /* @__PURE__ */ jsxRuntime.jsx(
222
- Box,
223
- {
224
- role: "separator",
225
- inlineSize: "full",
226
- backgroundColor: color ?? dividerDefaults.color,
227
- className: styles_components_Accessibility_VisuallyHidden_VisuallyHidden_cjs.classnames(className, dividerClass, styles_components_display_Divider_divider_css_cjs.divider),
228
- ...restProps
229
- }
230
- );
231
- };
232
- exports.BlocksProviderContext = BlocksProviderContext;
233
- exports.Box = Box;
234
- exports.Divider = Divider;
235
- exports.composeRefs = composeRefs;
236
- exports.createAsChildTemplate = createAsChildTemplate;
237
- exports.useComponentStyleDefaultProps = useComponentStyleDefaultProps;
238
- exports.useComponentStyles = useComponentStyles;
239
- exports.useTheme = useTheme;
@@ -1,240 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { classnames } from "../../Accessibility/VisuallyHidden/VisuallyHidden.mjs";
3
- import { divider } from "./divider.css.mjs";
4
- import { createContext, useContext, Children, isValidElement, cloneElement } from "react";
5
- import { getAtomsAndProps } from "../../../lib/utils/atom-props.mjs";
6
- import { atoms } from "../../../lib/css/atoms/sprinkles.css.mjs";
7
- const BlocksProviderContext = createContext(null);
8
- const useTheme = () => {
9
- const context = useContext(BlocksProviderContext);
10
- if (!context) {
11
- throw new Error("useTheme must be used within a BlocksProvider");
12
- }
13
- return context.theme;
14
- };
15
- function useComponentStyles(name, props, useDefaultVariants = true) {
16
- const { components } = useTheme();
17
- const component = components[name];
18
- if (!component) {
19
- console.warn(`Component ${name} is not defined in the theme`);
20
- return "";
21
- }
22
- const classNames = [];
23
- const variants = props.variants ?? {};
24
- const variantsWithDefaults = { ...variants };
25
- for (const key in props) {
26
- const value = props[key];
27
- if (typeof value === "boolean" && value) {
28
- classNames.push(component[key]);
29
- }
30
- }
31
- if (!component.variants) {
32
- return classNames.join(" ");
33
- }
34
- const { defaultVariants } = component;
35
- if (useDefaultVariants && defaultVariants) {
36
- const keys2 = Object.keys(defaultVariants);
37
- for (const key of keys2) {
38
- if (variantsWithDefaults[key] === void 0 && defaultVariants[key]) {
39
- variantsWithDefaults[key] = defaultVariants[key];
40
- }
41
- }
42
- }
43
- const keys = Object.keys(variantsWithDefaults);
44
- const componentVariants = component.variants;
45
- for (const key of keys) {
46
- const value = variantsWithDefaults[key];
47
- if (value === void 0 || componentVariants[key] === void 0) {
48
- continue;
49
- }
50
- if (typeof value === "boolean") {
51
- if (value && componentVariants[key]) {
52
- classNames.push(componentVariants[key]);
53
- }
54
- continue;
55
- }
56
- const variant = componentVariants[key][value];
57
- if (variant) {
58
- classNames.push(variant);
59
- }
60
- }
61
- const { compoundVariants } = component;
62
- if (compoundVariants) {
63
- for (const compoundVariant of compoundVariants) {
64
- const keys2 = Object.keys(compoundVariant.variants);
65
- const matches = keys2.every((key) => {
66
- const value = variantsWithDefaults[key];
67
- if (value === void 0) {
68
- return false;
69
- }
70
- return value === compoundVariant.variants[key];
71
- });
72
- if (matches) {
73
- classNames.push(compoundVariant.style);
74
- }
75
- }
76
- }
77
- return classNames.join(" ");
78
- }
79
- const useComponentStyleDefaultProps = (name) => {
80
- const { components } = useTheme();
81
- const component = components[name];
82
- if (!component) {
83
- return {};
84
- }
85
- return component.defaultVariants ?? {};
86
- };
87
- function setRef(ref, value) {
88
- if (typeof ref === "function") {
89
- ref(value);
90
- } else if (ref !== null && ref !== void 0) {
91
- ref.current = value;
92
- }
93
- }
94
- function composeRefs(...refs) {
95
- return (node) => {
96
- for (const ref of refs) {
97
- setRef(ref, node);
98
- }
99
- };
100
- }
101
- function mergeProps(slotProps, childProps) {
102
- const overrideProps = {};
103
- for (const propName in childProps) {
104
- const slotPropValue = slotProps[propName];
105
- const childPropValue = childProps[propName];
106
- if (childPropValue === void 0) {
107
- continue;
108
- }
109
- if (slotPropValue === void 0) {
110
- overrideProps[propName] = childPropValue;
111
- continue;
112
- }
113
- if (typeof slotPropValue === "function" && typeof childPropValue === "function") {
114
- overrideProps[propName] = (...args) => {
115
- childPropValue(...args);
116
- slotPropValue(...args);
117
- };
118
- } else
119
- switch (propName) {
120
- case "style": {
121
- overrideProps[propName] = { ...slotPropValue, ...childPropValue };
122
- break;
123
- }
124
- case "className": {
125
- overrideProps[propName] = classnames(slotPropValue, childPropValue);
126
- break;
127
- }
128
- case "ref": {
129
- overrideProps[propName] = composeRefs(slotPropValue, childPropValue);
130
- break;
131
- }
132
- default: {
133
- overrideProps[propName] = childPropValue;
134
- }
135
- }
136
- }
137
- return { ...slotProps, ...overrideProps };
138
- }
139
- function createAsChildTemplate(defaultElement) {
140
- const Tag = defaultElement;
141
- const Template2 = ({
142
- asChild,
143
- children,
144
- ref,
145
- ...rootProps
146
- }) => {
147
- if (!asChild) {
148
- const tagProps = { ref, ...rootProps };
149
- return /* @__PURE__ */ jsx(Tag, { ...tagProps, children });
150
- }
151
- const childrenArray = Children.toArray(children);
152
- const slotIndex = childrenArray.findIndex((child) => {
153
- if (!isValidElement(child)) {
154
- return false;
155
- }
156
- return child.type === Slot$1;
157
- });
158
- const slot = childrenArray[slotIndex];
159
- if (!slot) {
160
- if (process.env.NODE_ENV !== "production") {
161
- console.error("Template: No Slot provided");
162
- }
163
- return null;
164
- }
165
- if (!isValidElementWithChildren(slot)) {
166
- return null;
167
- }
168
- if (!isValidElement(slot.props.children)) {
169
- if (process.env.NODE_ENV !== "production") {
170
- if (Children.toArray(slot.props.children).length === 0) {
171
- console.error("When using asChild, at least one child is required");
172
- } else {
173
- console.error("When using asChild, only one child is allowed");
174
- }
175
- }
176
- return null;
177
- }
178
- if (!isValidElementWithChildren(slot.props.children)) {
179
- return null;
180
- }
181
- const nextChildren = [...childrenArray];
182
- if (nextChildren.length === 1 && !slot.props.children.props.children) {
183
- return cloneElement(slot.props.children, mergeProps(rootProps, slot.props.children.props));
184
- }
185
- nextChildren[slotIndex] = slot.props.children.props.children;
186
- return cloneElement(
187
- slot.props.children,
188
- mergeProps(rootProps, slot.props.children.props),
189
- nextChildren
190
- );
191
- };
192
- return {
193
- Template: Template2,
194
- Slot: Slot$1
195
- };
196
- }
197
- function isValidElementWithChildren(child) {
198
- return isValidElement(child) && !!child.props;
199
- }
200
- const Slot$1 = ({ children }) => {
201
- return children;
202
- };
203
- const { Template, Slot } = createAsChildTemplate("div");
204
- const Box = ({ asChild, className, children, ref, ...restProps }) => {
205
- const [atomsProps, otherProps] = getAtomsAndProps(restProps);
206
- return /* @__PURE__ */ jsx(
207
- Template,
208
- {
209
- ref,
210
- asChild,
211
- className: classnames(className, atoms(atomsProps)),
212
- ...otherProps,
213
- children: /* @__PURE__ */ jsx(Slot, { children })
214
- }
215
- );
216
- };
217
- const Divider = ({ className, color, ...restProps }) => {
218
- const dividerClass = useComponentStyles("divider", { base: true });
219
- const dividerDefaults = useComponentStyleDefaultProps("divider");
220
- return /* @__PURE__ */ jsx(
221
- Box,
222
- {
223
- role: "separator",
224
- inlineSize: "full",
225
- backgroundColor: color ?? dividerDefaults.color,
226
- className: classnames(className, dividerClass, divider),
227
- ...restProps
228
- }
229
- );
230
- };
231
- export {
232
- BlocksProviderContext,
233
- Box,
234
- Divider,
235
- composeRefs,
236
- createAsChildTemplate,
237
- useComponentStyleDefaultProps,
238
- useComponentStyles,
239
- useTheme
240
- };
@@ -1,56 +0,0 @@
1
- "use strict";
2
- const jsxRuntime = require("react/jsx-runtime");
3
- const styles_components_display_Divider_Divider_cjs = require("../../display/Divider/Divider.cjs");
4
- const styles_lib_utils_atomProps_cjs = require("../../../lib/utils/atom-props.cjs");
5
- const styles_components_Accessibility_VisuallyHidden_VisuallyHidden_cjs = require("../../Accessibility/VisuallyHidden/VisuallyHidden.cjs");
6
- const styles_components_form_Button_Button_css_cjs = require("./Button.css.cjs");
7
- const styles_lib_css_atoms_sprinkles_css_cjs = require("../../../lib/css/atoms/sprinkles.css.cjs");
8
- const Spinner = ({ className, size, color, ...restProps }) => {
9
- const spinnerClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("spinner", { base: true, variants: { size, color } });
10
- return /* @__PURE__ */ jsxRuntime.jsx(styles_components_display_Divider_Divider_cjs.Box, { color, className: styles_components_Accessibility_VisuallyHidden_VisuallyHidden_cjs.classnames(spinnerClassName, className), ...restProps });
11
- };
12
- const { Template, Slot } = styles_components_display_Divider_Divider_cjs.createAsChildTemplate("button");
13
- const Button = ({
14
- asChild,
15
- children,
16
- className,
17
- disabled,
18
- endSlot,
19
- intent,
20
- loading,
21
- ref,
22
- size,
23
- startSlot,
24
- variant,
25
- ...restProps
26
- }) => {
27
- const buttonClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("button", {
28
- base: true,
29
- variants: {
30
- variant,
31
- intent,
32
- size,
33
- disabled,
34
- loading
35
- }
36
- });
37
- const [atomsProps, otherProps] = styles_lib_utils_atomProps_cjs.getAtomsAndProps(restProps);
38
- return /* @__PURE__ */ jsxRuntime.jsxs(
39
- Template,
40
- {
41
- ref,
42
- asChild,
43
- disabled: disabled || loading,
44
- className: styles_components_Accessibility_VisuallyHidden_VisuallyHidden_cjs.classnames(styles_components_form_Button_Button_css_cjs.buttonReset, buttonClassName, styles_lib_css_atoms_sprinkles_css_cjs.atoms(atomsProps), className),
45
- ...otherProps,
46
- children: [
47
- startSlot && /* @__PURE__ */ jsxRuntime.jsx("div", { children: startSlot }),
48
- loading && /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size }),
49
- /* @__PURE__ */ jsxRuntime.jsx(Slot, { children }),
50
- endSlot && /* @__PURE__ */ jsxRuntime.jsx("div", { children: endSlot })
51
- ]
52
- }
53
- );
54
- };
55
- exports.Button = Button;
56
- exports.Spinner = Spinner;
@@ -1,84 +0,0 @@
1
- "use strict";
2
- const jsxRuntime = require("react/jsx-runtime");
3
- const react = require("react");
4
- const styles_components_Accessibility_VisuallyHidden_VisuallyHidden_cjs = require("../../Accessibility/VisuallyHidden/VisuallyHidden.cjs");
5
- const styles_components_display_Divider_Divider_cjs = require("../../display/Divider/Divider.cjs");
6
- const styles_lib_css_atoms_sprinkles_css_cjs = require("../../../lib/css/atoms/sprinkles.css.cjs");
7
- const styles_components_form_Checkbox_checkbox_css_cjs = require("./checkbox.css.cjs");
8
- const Label = ({
9
- asSpan,
10
- children,
11
- className,
12
- required,
13
- size,
14
- cursor,
15
- ...restProps
16
- }) => {
17
- const Component = asSpan ? "span" : "label";
18
- const containerClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("label", {
19
- base: true,
20
- variants: { required, size }
21
- });
22
- return /* @__PURE__ */ jsxRuntime.jsx(
23
- Component,
24
- {
25
- className: styles_components_Accessibility_VisuallyHidden_VisuallyHidden_cjs.classnames(containerClassName, className, styles_lib_css_atoms_sprinkles_css_cjs.atoms({ cursor })),
26
- ...restProps,
27
- children
28
- }
29
- );
30
- };
31
- const Checkbox = ({
32
- children,
33
- className,
34
- id,
35
- name,
36
- ref,
37
- required,
38
- ...restProps
39
- }) => {
40
- const containerClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("checkbox", { base: true }, false);
41
- const iconClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("checkbox", { icon: true }, false);
42
- const labelClassName = styles_components_display_Divider_Divider_cjs.useComponentStyles("checkbox", { label: true }, false);
43
- const reactId = react.useId();
44
- const inputId = id || reactId;
45
- const input = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles_components_Accessibility_VisuallyHidden_VisuallyHidden_cjs.classnames(styles_components_form_Checkbox_checkbox_css_cjs.container, containerClassName, className), children: [
46
- /* @__PURE__ */ jsxRuntime.jsx(
47
- "input",
48
- {
49
- ref,
50
- type: "checkbox",
51
- name,
52
- id: inputId,
53
- className: styles_components_form_Checkbox_checkbox_css_cjs.input,
54
- ...restProps
55
- }
56
- ),
57
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: styles_components_Accessibility_VisuallyHidden_VisuallyHidden_cjs.classnames(styles_components_form_Checkbox_checkbox_css_cjs.icon, iconClassName), "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(DefaultIcon, {}) })
58
- ] });
59
- if (!children) {
60
- return input;
61
- }
62
- return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: labelClassName, children: [
63
- input,
64
- children && /* @__PURE__ */ jsxRuntime.jsx(Label, { required, htmlFor: inputId, children })
65
- ] });
66
- };
67
- const DefaultIcon = () => {
68
- return (
69
- // TOOD - replace with actual icon component renderer
70
- /* @__PURE__ */ jsxRuntime.jsx(
71
- "svg",
72
- {
73
- viewBox: "0 0 24 24",
74
- fill: "none",
75
- strokeWidth: "1.5",
76
- stroke: "currentColor",
77
- style: { width: "1rem", height: "1rem", display: "block" },
78
- children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m4.5 12.75 6 6 9-13.5" })
79
- }
80
- )
81
- );
82
- };
83
- exports.Checkbox = Checkbox;
84
- exports.Label = Label;