@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,16 @@
|
|
|
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/typography/Heading/heading.css.ts", "@blockle/blocks-react");
|
|
5
|
+
const heading = style({
|
|
6
|
+
"@layer": {
|
|
7
|
+
[blocksLayer]: {
|
|
8
|
+
margin: 0,
|
|
9
|
+
padding: 0
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
endFileScope();
|
|
14
|
+
export {
|
|
15
|
+
heading
|
|
16
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Heading, HeadingProps } from './Heading';
|
|
3
|
+
declare const _default: Meta<typeof Heading>;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const Default: StoryObj<HeadingProps>;
|
|
6
|
+
export declare const All: {
|
|
7
|
+
render: import('@storybook/core/csf').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, {
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
className?: string;
|
|
10
|
+
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
11
|
+
} & import('@blockle/blocks-core').TextSprinkles & import('@blockle/blocks-core').MarginSprinkles & import('@blockle/blocks-core').PaddingSprinkles & import('@blockle/blocks-core').HTMLElementProps<HTMLHeadingElement>>;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Heading, type HeadingProps } from './Heading';
|
|
@@ -0,0 +1,21 @@
|
|
|
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 text_css = require("./text.css.cjs");
|
|
6
|
+
const Box = require("../../layout/Box/Box.cjs");
|
|
7
|
+
const Text = ({
|
|
8
|
+
asChild,
|
|
9
|
+
children,
|
|
10
|
+
className,
|
|
11
|
+
ref,
|
|
12
|
+
tag,
|
|
13
|
+
...restProps
|
|
14
|
+
}) => {
|
|
15
|
+
const Component = tag ?? "span";
|
|
16
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Box.Box, { asChild: true, className: blocksCore.classnames(text_css.text, className), ...restProps, children: asChild ? children : (
|
|
17
|
+
// biome-ignore lint/suspicious/noExplicitAny: Safe to assert ref as React.RefObject<any>
|
|
18
|
+
/* @__PURE__ */ jsxRuntime.jsx(Component, { ref, children })
|
|
19
|
+
) });
|
|
20
|
+
};
|
|
21
|
+
exports.Text = Text;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { HTMLElementProps, MarginSprinkles, PaddingSprinkles, TextSprinkles } from '@blockle/blocks-core';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
type Tags = 'del' | 'em' | 'ins' | 'label' | 'p' | 's' | 'small' | 'span' | 'strong' | 'sub' | 'sup';
|
|
4
|
+
export type TextProps<Tag extends Tags = 'span'> = {
|
|
5
|
+
asChild?: boolean;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
ref?: React.Ref<HTMLElementTagNameMap[Tag]>;
|
|
8
|
+
tag?: Tag;
|
|
9
|
+
} & TextSprinkles & MarginSprinkles & PaddingSprinkles & HTMLElementProps<HTMLSpanElement>;
|
|
10
|
+
export declare const Text: <T extends Tags = "span">({ asChild, children, className, ref, tag, ...restProps }: TextProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { classnames } from "@blockle/blocks-core";
|
|
3
|
+
import { text } from "./text.css.js";
|
|
4
|
+
import { Box } from "../../layout/Box/Box.js";
|
|
5
|
+
const Text = ({
|
|
6
|
+
asChild,
|
|
7
|
+
children,
|
|
8
|
+
className,
|
|
9
|
+
ref,
|
|
10
|
+
tag,
|
|
11
|
+
...restProps
|
|
12
|
+
}) => {
|
|
13
|
+
const Component = tag ?? "span";
|
|
14
|
+
return /* @__PURE__ */ jsx(Box, { asChild: true, className: classnames(text, className), ...restProps, children: asChild ? children : (
|
|
15
|
+
// biome-ignore lint/suspicious/noExplicitAny: Safe to assert ref as React.RefObject<any>
|
|
16
|
+
/* @__PURE__ */ jsx(Component, { ref, children })
|
|
17
|
+
) });
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
Text
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Text, type TextProps } from './Text';
|
|
@@ -0,0 +1,16 @@
|
|
|
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/typography/Text/text.css.ts", "@blockle/blocks-react");
|
|
7
|
+
const text = css.style({
|
|
8
|
+
"@layer": {
|
|
9
|
+
[blocksCore.blocksLayer]: {
|
|
10
|
+
margin: 0,
|
|
11
|
+
padding: 0
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
fileScope.endFileScope();
|
|
16
|
+
exports.text = text;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const text: string;
|
|
@@ -0,0 +1,16 @@
|
|
|
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/typography/Text/text.css.ts", "@blockle/blocks-react");
|
|
5
|
+
const text = style({
|
|
6
|
+
"@layer": {
|
|
7
|
+
[blocksLayer]: {
|
|
8
|
+
margin: 0,
|
|
9
|
+
padding: 0
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
endFileScope();
|
|
14
|
+
export {
|
|
15
|
+
text
|
|
16
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const react = require("react");
|
|
4
|
+
const useClickOutside = (ref, onClickOutside, { enabled = true } = {}) => {
|
|
5
|
+
react.useEffect(() => {
|
|
6
|
+
if (!enabled) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const listener = (event) => {
|
|
10
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
11
|
+
onClickOutside();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const rafId = requestAnimationFrame(() => {
|
|
15
|
+
document.addEventListener("click", listener);
|
|
16
|
+
});
|
|
17
|
+
return () => {
|
|
18
|
+
cancelAnimationFrame(rafId);
|
|
19
|
+
document.removeEventListener("click", listener);
|
|
20
|
+
};
|
|
21
|
+
}, [ref, onClickOutside, enabled]);
|
|
22
|
+
};
|
|
23
|
+
exports.useClickOutside = useClickOutside;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
type UseClickOutsideOptions = {
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const useClickOutside: (ref: React.RefObject<HTMLElement | null>, onClickOutside: () => void, { enabled }?: UseClickOutsideOptions) => void;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
const useClickOutside = (ref, onClickOutside, { enabled = true } = {}) => {
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
if (!enabled) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const listener = (event) => {
|
|
8
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
9
|
+
onClickOutside();
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const rafId = requestAnimationFrame(() => {
|
|
13
|
+
document.addEventListener("click", listener);
|
|
14
|
+
});
|
|
15
|
+
return () => {
|
|
16
|
+
cancelAnimationFrame(rafId);
|
|
17
|
+
document.removeEventListener("click", listener);
|
|
18
|
+
};
|
|
19
|
+
}, [ref, onClickOutside, enabled]);
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
useClickOutside
|
|
23
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const useTheme = require("../useTheme/useTheme.cjs");
|
|
4
|
+
const useComponentStyleDefaultProps = (name) => {
|
|
5
|
+
const { components } = useTheme.useTheme();
|
|
6
|
+
const component = components[name];
|
|
7
|
+
if (!component) {
|
|
8
|
+
return {};
|
|
9
|
+
}
|
|
10
|
+
return component.defaultVariants ?? {};
|
|
11
|
+
};
|
|
12
|
+
exports.useComponentStyleDefaultProps = useComponentStyleDefaultProps;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RecordLike, ThemeComponentsStyles } from '@blockle/blocks-core';
|
|
2
|
+
type ThemeComponentsStylesRequired = Required<ThemeComponentsStyles>;
|
|
3
|
+
type Components = {
|
|
4
|
+
[K in keyof ThemeComponentsStylesRequired]: ThemeComponentsStylesRequired[K] extends RecordLike ? Required<ThemeComponentsStylesRequired[K]>['defaultVariants'] extends RecordLike ? ThemeComponentsStylesRequired[K]['defaultVariants'] extends undefined ? never : Exclude<ThemeComponentsStylesRequired[K]['defaultVariants'], undefined> : never : never;
|
|
5
|
+
};
|
|
6
|
+
export declare const useComponentStyleDefaultProps: <T extends keyof ThemeComponentsStyles>(name: T) => Components[T];
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useTheme } from "../useTheme/useTheme.js";
|
|
2
|
+
const useComponentStyleDefaultProps = (name) => {
|
|
3
|
+
const { components } = useTheme();
|
|
4
|
+
const component = components[name];
|
|
5
|
+
if (!component) {
|
|
6
|
+
return {};
|
|
7
|
+
}
|
|
8
|
+
return component.defaultVariants ?? {};
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
useComponentStyleDefaultProps
|
|
12
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const useTheme = require("../useTheme/useTheme.cjs");
|
|
5
|
+
function useComponentStyles(name, props, useDefaultVariants = true) {
|
|
6
|
+
const { components } = useTheme.useTheme();
|
|
7
|
+
const component = components[name];
|
|
8
|
+
if (!component) {
|
|
9
|
+
console.warn(`Component ${name} is not defined in the theme`);
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
12
|
+
const classNames = [];
|
|
13
|
+
const variants = props.variants ?? {};
|
|
14
|
+
const variantsWithDefaults = { ...variants };
|
|
15
|
+
for (const key in props) {
|
|
16
|
+
const value = props[key];
|
|
17
|
+
if (typeof value === "boolean" && value) {
|
|
18
|
+
classNames.push(
|
|
19
|
+
// biome-ignore lint/suspicious/noExplicitAny: type assertion
|
|
20
|
+
component[key]
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (!component.variants) {
|
|
25
|
+
return classNames.join(" ");
|
|
26
|
+
}
|
|
27
|
+
const { defaultVariants } = component;
|
|
28
|
+
if (useDefaultVariants && defaultVariants) {
|
|
29
|
+
const keys2 = Object.keys(defaultVariants);
|
|
30
|
+
for (const key of keys2) {
|
|
31
|
+
if (variantsWithDefaults[key] === void 0 && defaultVariants[key]) {
|
|
32
|
+
variantsWithDefaults[key] = defaultVariants[key];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const keys = Object.keys(variantsWithDefaults);
|
|
37
|
+
const componentVariants = component.variants;
|
|
38
|
+
for (const key of keys) {
|
|
39
|
+
const value = variantsWithDefaults[key];
|
|
40
|
+
if (value === void 0 || componentVariants[key] === void 0) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (typeof value === "boolean") {
|
|
44
|
+
if (value && componentVariants[key]) {
|
|
45
|
+
classNames.push(componentVariants[key]);
|
|
46
|
+
}
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const variant = componentVariants[key][value];
|
|
50
|
+
if (variant) {
|
|
51
|
+
classNames.push(variant);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const { compoundVariants } = component;
|
|
55
|
+
if (compoundVariants) {
|
|
56
|
+
for (const compoundVariant of compoundVariants) {
|
|
57
|
+
const keys2 = Object.keys(
|
|
58
|
+
compoundVariant.variants
|
|
59
|
+
);
|
|
60
|
+
const matches = keys2.every((key) => {
|
|
61
|
+
const value = variantsWithDefaults[key];
|
|
62
|
+
if (value === void 0) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return value === compoundVariant.variants[key];
|
|
66
|
+
});
|
|
67
|
+
if (matches) {
|
|
68
|
+
classNames.push(compoundVariant.style);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return classNames.join(" ");
|
|
73
|
+
}
|
|
74
|
+
exports.useComponentStyles = useComponentStyles;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useTheme } from "../useTheme/useTheme.js";
|
|
3
|
+
function useComponentStyles(name, props, useDefaultVariants = true) {
|
|
4
|
+
const { components } = useTheme();
|
|
5
|
+
const component = components[name];
|
|
6
|
+
if (!component) {
|
|
7
|
+
console.warn(`Component ${name} is not defined in the theme`);
|
|
8
|
+
return "";
|
|
9
|
+
}
|
|
10
|
+
const classNames = [];
|
|
11
|
+
const variants = props.variants ?? {};
|
|
12
|
+
const variantsWithDefaults = { ...variants };
|
|
13
|
+
for (const key in props) {
|
|
14
|
+
const value = props[key];
|
|
15
|
+
if (typeof value === "boolean" && value) {
|
|
16
|
+
classNames.push(
|
|
17
|
+
// biome-ignore lint/suspicious/noExplicitAny: type assertion
|
|
18
|
+
component[key]
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (!component.variants) {
|
|
23
|
+
return classNames.join(" ");
|
|
24
|
+
}
|
|
25
|
+
const { defaultVariants } = component;
|
|
26
|
+
if (useDefaultVariants && defaultVariants) {
|
|
27
|
+
const keys2 = Object.keys(defaultVariants);
|
|
28
|
+
for (const key of keys2) {
|
|
29
|
+
if (variantsWithDefaults[key] === void 0 && defaultVariants[key]) {
|
|
30
|
+
variantsWithDefaults[key] = defaultVariants[key];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const keys = Object.keys(variantsWithDefaults);
|
|
35
|
+
const componentVariants = component.variants;
|
|
36
|
+
for (const key of keys) {
|
|
37
|
+
const value = variantsWithDefaults[key];
|
|
38
|
+
if (value === void 0 || componentVariants[key] === void 0) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (typeof value === "boolean") {
|
|
42
|
+
if (value && componentVariants[key]) {
|
|
43
|
+
classNames.push(componentVariants[key]);
|
|
44
|
+
}
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const variant = componentVariants[key][value];
|
|
48
|
+
if (variant) {
|
|
49
|
+
classNames.push(variant);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const { compoundVariants } = component;
|
|
53
|
+
if (compoundVariants) {
|
|
54
|
+
for (const compoundVariant of compoundVariants) {
|
|
55
|
+
const keys2 = Object.keys(
|
|
56
|
+
compoundVariant.variants
|
|
57
|
+
);
|
|
58
|
+
const matches = keys2.every((key) => {
|
|
59
|
+
const value = variantsWithDefaults[key];
|
|
60
|
+
if (value === void 0) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
return value === compoundVariant.variants[key];
|
|
64
|
+
});
|
|
65
|
+
if (matches) {
|
|
66
|
+
classNames.push(compoundVariant.style);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return classNames.join(" ");
|
|
71
|
+
}
|
|
72
|
+
export {
|
|
73
|
+
useComponentStyles
|
|
74
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useControlledValue } from './useControlledValue';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const react = require("react");
|
|
5
|
+
function useControlledValue({
|
|
6
|
+
defaultValue,
|
|
7
|
+
value,
|
|
8
|
+
onChange,
|
|
9
|
+
transformValue
|
|
10
|
+
}) {
|
|
11
|
+
const [internValue, setInternValue] = react.useState(defaultValue);
|
|
12
|
+
const currentValue = (onChange ? value : internValue) ?? defaultValue;
|
|
13
|
+
const setValue = react.useCallback(
|
|
14
|
+
function setValue2(value2) {
|
|
15
|
+
const nextValue = transformValue ? transformValue(value2) : value2;
|
|
16
|
+
if (onChange) {
|
|
17
|
+
onChange(nextValue);
|
|
18
|
+
} else {
|
|
19
|
+
setInternValue(nextValue);
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
[onChange, transformValue]
|
|
23
|
+
);
|
|
24
|
+
if (process.env.NODE_ENV !== "production") {
|
|
25
|
+
react.useEffect(() => {
|
|
26
|
+
if (onChange && value === void 0) {
|
|
27
|
+
console.error("Slider is in controlled mode but no value is provided");
|
|
28
|
+
}
|
|
29
|
+
}, []);
|
|
30
|
+
}
|
|
31
|
+
return [currentValue, setValue];
|
|
32
|
+
}
|
|
33
|
+
exports.useControlledValue = useControlledValue;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type ControlledValue<T> = {
|
|
2
|
+
value?: T;
|
|
3
|
+
defaultValue: T;
|
|
4
|
+
onChange?: (value: T) => void;
|
|
5
|
+
transformValue?: (value: T) => T;
|
|
6
|
+
};
|
|
7
|
+
export declare function useControlledValue<T>({ defaultValue, value, onChange, transformValue, }: ControlledValue<T>): [T, (value: T) => void];
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState, useCallback, useEffect } from "react";
|
|
3
|
+
function useControlledValue({
|
|
4
|
+
defaultValue,
|
|
5
|
+
value,
|
|
6
|
+
onChange,
|
|
7
|
+
transformValue
|
|
8
|
+
}) {
|
|
9
|
+
const [internValue, setInternValue] = useState(defaultValue);
|
|
10
|
+
const currentValue = (onChange ? value : internValue) ?? defaultValue;
|
|
11
|
+
const setValue = useCallback(
|
|
12
|
+
function setValue2(value2) {
|
|
13
|
+
const nextValue = transformValue ? transformValue(value2) : value2;
|
|
14
|
+
if (onChange) {
|
|
15
|
+
onChange(nextValue);
|
|
16
|
+
} else {
|
|
17
|
+
setInternValue(nextValue);
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
[onChange, transformValue]
|
|
21
|
+
);
|
|
22
|
+
if (process.env.NODE_ENV !== "production") {
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (onChange && value === void 0) {
|
|
25
|
+
console.error("Slider is in controlled mode but no value is provided");
|
|
26
|
+
}
|
|
27
|
+
}, []);
|
|
28
|
+
}
|
|
29
|
+
return [currentValue, setValue];
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
useControlledValue
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const useIsomorphicLayoutEffect = typeof window === "undefined" ? react.useEffect : react.useLayoutEffect;
|
|
6
|
+
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useKeyboard } from './useKeyboard';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const useKeyboard = (key, callback, { enabled = true, type = "keydown" } = {}) => {
|
|
6
|
+
react.useEffect(() => {
|
|
7
|
+
if (!enabled) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
function handleKeyDown(event) {
|
|
11
|
+
if (event.key === key) {
|
|
12
|
+
callback(event);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
document.addEventListener(type, handleKeyDown);
|
|
16
|
+
return () => {
|
|
17
|
+
document.removeEventListener(type, handleKeyDown);
|
|
18
|
+
};
|
|
19
|
+
}, [callback, enabled, key, type]);
|
|
20
|
+
};
|
|
21
|
+
exports.useKeyboard = useKeyboard;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
const useKeyboard = (key, callback, { enabled = true, type = "keydown" } = {}) => {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
if (!enabled) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
function handleKeyDown(event) {
|
|
9
|
+
if (event.key === key) {
|
|
10
|
+
callback(event);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
document.addEventListener(type, handleKeyDown);
|
|
14
|
+
return () => {
|
|
15
|
+
document.removeEventListener(type, handleKeyDown);
|
|
16
|
+
};
|
|
17
|
+
}, [callback, enabled, key, type]);
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
useKeyboard
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useLayer } from './useLayer';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const react = require("react");
|
|
5
|
+
const useLayer = () => {
|
|
6
|
+
const layerRef = react.useRef(null);
|
|
7
|
+
react.useEffect(
|
|
8
|
+
() => () => {
|
|
9
|
+
if (layerRef.current) {
|
|
10
|
+
layerRef.current.remove();
|
|
11
|
+
layerRef.current = null;
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
[]
|
|
15
|
+
);
|
|
16
|
+
function getLayer() {
|
|
17
|
+
if (!layerRef.current) {
|
|
18
|
+
const div = document.createElement("div");
|
|
19
|
+
div.dataset.layer = "blocks";
|
|
20
|
+
layerRef.current = div;
|
|
21
|
+
document.body.append(layerRef.current);
|
|
22
|
+
}
|
|
23
|
+
return layerRef.current;
|
|
24
|
+
}
|
|
25
|
+
return getLayer;
|
|
26
|
+
};
|
|
27
|
+
exports.useLayer = useLayer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useLayer: () => (() => HTMLDivElement);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRef, useEffect } from "react";
|
|
3
|
+
const useLayer = () => {
|
|
4
|
+
const layerRef = useRef(null);
|
|
5
|
+
useEffect(
|
|
6
|
+
() => () => {
|
|
7
|
+
if (layerRef.current) {
|
|
8
|
+
layerRef.current.remove();
|
|
9
|
+
layerRef.current = null;
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
[]
|
|
13
|
+
);
|
|
14
|
+
function getLayer() {
|
|
15
|
+
if (!layerRef.current) {
|
|
16
|
+
const div = document.createElement("div");
|
|
17
|
+
div.dataset.layer = "blocks";
|
|
18
|
+
layerRef.current = div;
|
|
19
|
+
document.body.append(layerRef.current);
|
|
20
|
+
}
|
|
21
|
+
return layerRef.current;
|
|
22
|
+
}
|
|
23
|
+
return getLayer;
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
useLayer
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { usePreventBodyScroll } from './usePreventBodyScroll';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
+
const useIsomorphicLayoutEffect = require("../useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.cjs");
|
|
5
|
+
const usePreventBodyScroll = (enabled = true) => {
|
|
6
|
+
useIsomorphicLayoutEffect.useIsomorphicLayoutEffect(() => {
|
|
7
|
+
if (!enabled) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const prevOverflow = document.body.style.getPropertyValue("overflow");
|
|
11
|
+
const prevScrollTop = document.documentElement.scrollTop;
|
|
12
|
+
if (document.body.scrollHeight > window.innerHeight) {
|
|
13
|
+
document.body.style.position = "fixed";
|
|
14
|
+
document.body.style.overflow = "hidden";
|
|
15
|
+
document.body.style.overflowY = "scroll";
|
|
16
|
+
document.body.style.width = "100%";
|
|
17
|
+
document.body.style.top = `-${prevScrollTop}px`;
|
|
18
|
+
} else {
|
|
19
|
+
document.body.style.overflow = "hidden";
|
|
20
|
+
}
|
|
21
|
+
return () => {
|
|
22
|
+
document.body.style.position = "";
|
|
23
|
+
document.body.style.overflow = prevOverflow;
|
|
24
|
+
document.body.style.overflowY = "";
|
|
25
|
+
document.body.style.width = "";
|
|
26
|
+
document.body.style.top = "";
|
|
27
|
+
document.documentElement.scrollTop = prevScrollTop;
|
|
28
|
+
};
|
|
29
|
+
}, [enabled]);
|
|
30
|
+
};
|
|
31
|
+
exports.usePreventBodyScroll = usePreventBodyScroll;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const usePreventBodyScroll: (enabled?: boolean) => void;
|