@blockle/blocks 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +2 -1
- package/dist/momotaro.chunk.d.ts +275 -267
- package/dist/styles/components/display/Divider/Divider.cjs +3 -3
- package/dist/styles/components/display/Divider/Divider.mjs +3 -3
- package/dist/styles/components/other/BlocksProvider/BlocksProvider.cjs +21 -1
- package/dist/styles/components/other/BlocksProvider/BlocksProvider.mjs +21 -1
- package/dist/styles/components/overlay/Dialog/Dialog.cjs +9 -0
- package/dist/styles/components/overlay/Dialog/Dialog.mjs +12 -3
- package/dist/styles/themes/momotaro/components/dialog.css.cjs +8 -7
- package/dist/styles/themes/momotaro/components/dialog.css.mjs +8 -7
- package/package.json +9 -9
|
@@ -6,11 +6,11 @@ const styles_lib_utils_atomProps_cjs = require("../../../lib/utils/atom-props.cj
|
|
|
6
6
|
const styles_lib_css_atoms_sprinkles_css_cjs = require("../../../lib/css/atoms/sprinkles.css.cjs");
|
|
7
7
|
const BlocksProviderContext = react.createContext(null);
|
|
8
8
|
const useTheme = () => {
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
9
|
+
const context = react.useContext(BlocksProviderContext);
|
|
10
|
+
if (!context) {
|
|
11
11
|
throw new Error("useTheme must be used within a BlocksProvider");
|
|
12
12
|
}
|
|
13
|
-
return theme;
|
|
13
|
+
return context.theme;
|
|
14
14
|
};
|
|
15
15
|
function useComponentStyles(name, props, useDefaultVariants = true) {
|
|
16
16
|
const { components } = useTheme();
|
|
@@ -5,11 +5,11 @@ import { getAtomsAndProps } from "../../../lib/utils/atom-props.mjs";
|
|
|
5
5
|
import { atoms } from "../../../lib/css/atoms/sprinkles.css.mjs";
|
|
6
6
|
const BlocksProviderContext = createContext(null);
|
|
7
7
|
const useTheme = () => {
|
|
8
|
-
const
|
|
9
|
-
if (!
|
|
8
|
+
const context = useContext(BlocksProviderContext);
|
|
9
|
+
if (!context) {
|
|
10
10
|
throw new Error("useTheme must be used within a BlocksProvider");
|
|
11
11
|
}
|
|
12
|
-
return theme;
|
|
12
|
+
return context.theme;
|
|
13
13
|
};
|
|
14
14
|
function useComponentStyles(name, props, useDefaultVariants = true) {
|
|
15
15
|
const { components } = useTheme();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const jsxRuntime = require("react/jsx-runtime");
|
|
3
|
+
const react = require("react");
|
|
3
4
|
const styles_lib_css_atoms_sprinkles_css_cjs = require("../../../lib/css/atoms/sprinkles.css.cjs");
|
|
4
5
|
const styles_components_display_Divider_Divider_cjs = require("../../display/Divider/Divider.cjs");
|
|
5
6
|
const BlocksProvider = ({
|
|
@@ -8,10 +9,29 @@ const BlocksProvider = ({
|
|
|
8
9
|
className,
|
|
9
10
|
...restProps
|
|
10
11
|
}) => {
|
|
11
|
-
|
|
12
|
+
const ref = react.useRef(null);
|
|
13
|
+
const [ariaHidden, setAriaHidden] = react.useState(false);
|
|
14
|
+
const contextValue = react.useMemo(
|
|
15
|
+
() => ({
|
|
16
|
+
theme,
|
|
17
|
+
setAriaHidden
|
|
18
|
+
}),
|
|
19
|
+
[theme, setAriaHidden]
|
|
20
|
+
);
|
|
21
|
+
react.useEffect(() => {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
if (ariaHidden) {
|
|
24
|
+
(_a = ref.current) == null ? void 0 : _a.setAttribute("inert", "");
|
|
25
|
+
} else {
|
|
26
|
+
(_b = ref.current) == null ? void 0 : _b.removeAttribute("inert");
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return /* @__PURE__ */ jsxRuntime.jsx(styles_components_display_Divider_Divider_cjs.BlocksProviderContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
12
30
|
"div",
|
|
13
31
|
{
|
|
32
|
+
ref,
|
|
14
33
|
className: styles_components_display_Divider_Divider_cjs.classnames(theme.vars, styles_lib_css_atoms_sprinkles_css_cjs.atoms({ fontFamily: "primary" }), className),
|
|
34
|
+
"aria-hidden": ariaHidden,
|
|
15
35
|
...restProps,
|
|
16
36
|
children
|
|
17
37
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState, useMemo, useEffect } from "react";
|
|
2
3
|
import { atoms } from "../../../lib/css/atoms/sprinkles.css.mjs";
|
|
3
4
|
import { BlocksProviderContext, classnames } from "../../display/Divider/Divider.mjs";
|
|
4
5
|
const BlocksProvider = ({
|
|
@@ -7,10 +8,29 @@ const BlocksProvider = ({
|
|
|
7
8
|
className,
|
|
8
9
|
...restProps
|
|
9
10
|
}) => {
|
|
10
|
-
|
|
11
|
+
const ref = useRef(null);
|
|
12
|
+
const [ariaHidden, setAriaHidden] = useState(false);
|
|
13
|
+
const contextValue = useMemo(
|
|
14
|
+
() => ({
|
|
15
|
+
theme,
|
|
16
|
+
setAriaHidden
|
|
17
|
+
}),
|
|
18
|
+
[theme, setAriaHidden]
|
|
19
|
+
);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
if (ariaHidden) {
|
|
23
|
+
(_a = ref.current) == null ? void 0 : _a.setAttribute("inert", "");
|
|
24
|
+
} else {
|
|
25
|
+
(_b = ref.current) == null ? void 0 : _b.removeAttribute("inert");
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return /* @__PURE__ */ jsx(BlocksProviderContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
11
29
|
"div",
|
|
12
30
|
{
|
|
31
|
+
ref,
|
|
13
32
|
className: classnames(theme.vars, atoms({ fontFamily: "primary" }), className),
|
|
33
|
+
"aria-hidden": ariaHidden,
|
|
14
34
|
...restProps,
|
|
15
35
|
children
|
|
16
36
|
}
|
|
@@ -118,6 +118,13 @@ const useRestoreFocus = (active) => {
|
|
|
118
118
|
}
|
|
119
119
|
}, [active]);
|
|
120
120
|
};
|
|
121
|
+
const useRootAriaHidden = (hidden) => {
|
|
122
|
+
const context = react.useContext(styles_components_display_Divider_Divider_cjs.BlocksProviderContext);
|
|
123
|
+
if (!context) {
|
|
124
|
+
throw new Error("useRootAriaHidden must be used within a BlocksProvider");
|
|
125
|
+
}
|
|
126
|
+
context.setAriaHidden(hidden);
|
|
127
|
+
};
|
|
121
128
|
const useVisibilityState = (open) => {
|
|
122
129
|
const [visible, setVisible] = react.useState(open);
|
|
123
130
|
const hide = react.useCallback(() => {
|
|
@@ -179,6 +186,7 @@ const Dialog = ({
|
|
|
179
186
|
const isNested = useNestedDialog(visible);
|
|
180
187
|
usePreventBodyScroll(visible && !isNested);
|
|
181
188
|
useKeyboard("Escape", onRequestClose, { enabled: open && enabled });
|
|
189
|
+
useRootAriaHidden(visible);
|
|
182
190
|
useIsomorphicLayoutEffect(() => {
|
|
183
191
|
var _a, _b;
|
|
184
192
|
if (!open) {
|
|
@@ -243,3 +251,4 @@ exports.Portal = Portal;
|
|
|
243
251
|
exports.useIsomorphicLayoutEffect = useIsomorphicLayoutEffect;
|
|
244
252
|
exports.useKeyboard = useKeyboard;
|
|
245
253
|
exports.usePreventBodyScroll = usePreventBodyScroll;
|
|
254
|
+
exports.useRootAriaHidden = useRootAriaHidden;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useLayoutEffect, useRef, useState, useCallback, createContext
|
|
3
|
-
import { useTheme, useComponentStyles, Box, classnames } from "../../display/Divider/Divider.mjs";
|
|
2
|
+
import { useEffect, useLayoutEffect, useRef, useContext, useState, useCallback, createContext } from "react";
|
|
3
|
+
import { useTheme, BlocksProviderContext, useComponentStyles, Box, classnames } from "../../display/Divider/Divider.mjs";
|
|
4
4
|
import { backdrop } from "./dialog.css.mjs";
|
|
5
5
|
import { createPortal } from "react-dom";
|
|
6
6
|
import { BlocksProvider } from "../../other/BlocksProvider/BlocksProvider.mjs";
|
|
@@ -117,6 +117,13 @@ const useRestoreFocus = (active) => {
|
|
|
117
117
|
}
|
|
118
118
|
}, [active]);
|
|
119
119
|
};
|
|
120
|
+
const useRootAriaHidden = (hidden) => {
|
|
121
|
+
const context = useContext(BlocksProviderContext);
|
|
122
|
+
if (!context) {
|
|
123
|
+
throw new Error("useRootAriaHidden must be used within a BlocksProvider");
|
|
124
|
+
}
|
|
125
|
+
context.setAriaHidden(hidden);
|
|
126
|
+
};
|
|
120
127
|
const useVisibilityState = (open) => {
|
|
121
128
|
const [visible, setVisible] = useState(open);
|
|
122
129
|
const hide = useCallback(() => {
|
|
@@ -178,6 +185,7 @@ const Dialog = ({
|
|
|
178
185
|
const isNested = useNestedDialog(visible);
|
|
179
186
|
usePreventBodyScroll(visible && !isNested);
|
|
180
187
|
useKeyboard("Escape", onRequestClose, { enabled: open && enabled });
|
|
188
|
+
useRootAriaHidden(visible);
|
|
181
189
|
useIsomorphicLayoutEffect(() => {
|
|
182
190
|
var _a, _b;
|
|
183
191
|
if (!open) {
|
|
@@ -242,5 +250,6 @@ export {
|
|
|
242
250
|
Portal,
|
|
243
251
|
useIsomorphicLayoutEffect,
|
|
244
252
|
useKeyboard,
|
|
245
|
-
usePreventBodyScroll
|
|
253
|
+
usePreventBodyScroll,
|
|
254
|
+
useRootAriaHidden
|
|
246
255
|
};
|
|
@@ -14,7 +14,8 @@ const dialog = styles_lib_theme_makeComponentTheme_cjs.makeComponentTheme("dialo
|
|
|
14
14
|
borderRadius: "medium",
|
|
15
15
|
boxShadow: "large"
|
|
16
16
|
}), {
|
|
17
|
-
|
|
17
|
+
maxHeight: "90%",
|
|
18
|
+
minWidth: "300px",
|
|
18
19
|
selectors: {
|
|
19
20
|
"&[data-open]": {
|
|
20
21
|
transform: "scale(1)"
|
|
@@ -46,16 +47,16 @@ const dialog = styles_lib_theme_makeComponentTheme_cjs.makeComponentTheme("dialo
|
|
|
46
47
|
variants: {
|
|
47
48
|
size: {
|
|
48
49
|
small: css.style({
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
width: "400px",
|
|
51
|
+
maxWidth: "min(400px, 90%)"
|
|
51
52
|
}, "dialog_variants_size_small"),
|
|
52
53
|
medium: css.style({
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
width: "600px",
|
|
55
|
+
maxWidth: "min(600px, 90%)"
|
|
55
56
|
}, "dialog_variants_size_medium"),
|
|
56
57
|
large: css.style({
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
width: "800px",
|
|
59
|
+
maxWidth: "min(800px, 90%)"
|
|
59
60
|
}, "dialog_variants_size_large")
|
|
60
61
|
}
|
|
61
62
|
},
|
|
@@ -13,7 +13,8 @@ const dialog = makeComponentTheme("dialog", {
|
|
|
13
13
|
borderRadius: "medium",
|
|
14
14
|
boxShadow: "large"
|
|
15
15
|
}), {
|
|
16
|
-
|
|
16
|
+
maxHeight: "90%",
|
|
17
|
+
minWidth: "300px",
|
|
17
18
|
selectors: {
|
|
18
19
|
"&[data-open]": {
|
|
19
20
|
transform: "scale(1)"
|
|
@@ -45,16 +46,16 @@ const dialog = makeComponentTheme("dialog", {
|
|
|
45
46
|
variants: {
|
|
46
47
|
size: {
|
|
47
48
|
small: style({
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
width: "400px",
|
|
50
|
+
maxWidth: "min(400px, 90%)"
|
|
50
51
|
}, "dialog_variants_size_small"),
|
|
51
52
|
medium: style({
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
width: "600px",
|
|
54
|
+
maxWidth: "min(600px, 90%)"
|
|
54
55
|
}, "dialog_variants_size_medium"),
|
|
55
56
|
large: style({
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
width: "800px",
|
|
58
|
+
maxWidth: "min(800px, 90%)"
|
|
58
59
|
}, "dialog_variants_size_large")
|
|
59
60
|
}
|
|
60
61
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blockle/blocks",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Blocks design system",
|
|
5
5
|
"repository": "git@github.com:Blockle/blocks.git",
|
|
6
6
|
"license": "MIT",
|
|
@@ -69,16 +69,16 @@
|
|
|
69
69
|
"@changesets/cli": "^2.27.1",
|
|
70
70
|
"@crackle/cli": "^0.13.0",
|
|
71
71
|
"@crackle/core": "^0.31.0",
|
|
72
|
-
"@storybook/addon-a11y": "^7.6.
|
|
72
|
+
"@storybook/addon-a11y": "^7.6.17",
|
|
73
73
|
"@storybook/addon-coverage": "^1.0.0",
|
|
74
|
-
"@storybook/addon-essentials": "^7.6.
|
|
75
|
-
"@storybook/addon-interactions": "^7.6.
|
|
76
|
-
"@storybook/addon-links": "^7.6.
|
|
74
|
+
"@storybook/addon-essentials": "^7.6.17",
|
|
75
|
+
"@storybook/addon-interactions": "^7.6.17",
|
|
76
|
+
"@storybook/addon-links": "^7.6.17",
|
|
77
77
|
"@storybook/addons": "^7.6.17",
|
|
78
|
-
"@storybook/blocks": "^7.6.
|
|
78
|
+
"@storybook/blocks": "^7.6.17",
|
|
79
79
|
"@storybook/jest": "^0.2.3",
|
|
80
|
-
"@storybook/react": "^7.6.
|
|
81
|
-
"@storybook/react-vite": "^7.6.
|
|
80
|
+
"@storybook/react": "^7.6.17",
|
|
81
|
+
"@storybook/react-vite": "^7.6.17",
|
|
82
82
|
"@storybook/testing-library": "^0.2.2",
|
|
83
83
|
"@testing-library/jest-dom": "^6.2.0",
|
|
84
84
|
"@testing-library/react": "^14.1.2",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"jsdom": "^23.2.0",
|
|
102
102
|
"prettier": "^3.2.4",
|
|
103
103
|
"prop-types": "^15.8.1",
|
|
104
|
-
"storybook": "^7.6.
|
|
104
|
+
"storybook": "^7.6.17",
|
|
105
105
|
"typescript": "^5.3.3",
|
|
106
106
|
"vitest": "^1.2.1"
|
|
107
107
|
},
|