@stratakit/structures 0.4.4 → 0.5.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/CHANGELOG.md +46 -0
- package/dist/AccordionItem.d.ts +1 -1
- package/dist/AccordionItem.js +67 -124
- package/dist/Banner.js +146 -117
- package/dist/Chip.js +83 -58
- package/dist/DEV/Banner.js +7 -4
- package/dist/DEV/ErrorRegion.js +5 -4
- package/dist/DEV/NavigationRail.js +52 -20
- package/dist/DEV/Tabs.js +1 -1
- package/dist/DEV/styles.css.js +1 -1
- package/dist/Dialog.js +140 -132
- package/dist/DropdownMenu.js +206 -239
- package/dist/ErrorRegion.d.ts +31 -13
- package/dist/ErrorRegion.js +127 -153
- package/dist/NavigationRail.d.ts +36 -3
- package/dist/NavigationRail.js +215 -169
- package/dist/Table.js +116 -108
- package/dist/Tabs.d.ts +2 -0
- package/dist/Tabs.js +97 -62
- package/dist/Toolbar.js +23 -43
- package/dist/Tree.js +13 -12
- package/dist/TreeItem.js +394 -315
- package/dist/styles.css.js +1 -1
- package/dist/~utils.ListItem.js +21 -34
- package/dist/~utils.icons.js +26 -46
- package/package.json +13 -18
package/dist/Tabs.js
CHANGED
|
@@ -1,94 +1,129 @@
|
|
|
1
|
+
import { c as _c } from "react-compiler-runtime";
|
|
1
2
|
import { jsx } from "react/jsx-runtime";
|
|
2
3
|
import { useStoreState } from "@ariakit/react/store";
|
|
3
4
|
import * as AkTab from "@ariakit/react/tab";
|
|
4
|
-
import {
|
|
5
|
-
forwardRef,
|
|
6
|
-
isBrowser,
|
|
7
|
-
useUnreactiveCallback
|
|
8
|
-
} from "@stratakit/foundations/secret-internals";
|
|
5
|
+
import { forwardRef, isBrowser, useUnreactiveCallback } from "@stratakit/foundations/secret-internals";
|
|
9
6
|
import cx from "classnames";
|
|
10
7
|
const supportsAnchorPositioning = isBrowser && CSS?.supports("anchor-name: --foo");
|
|
11
8
|
const prefersReducedMotion = () => isBrowser && window.matchMedia("(prefers-reduced-motion)").matches;
|
|
12
9
|
function TabsProvider(props) {
|
|
10
|
+
const $ = _c(14);
|
|
13
11
|
const {
|
|
14
12
|
defaultSelectedId,
|
|
15
13
|
selectedId,
|
|
16
14
|
setSelectedId,
|
|
17
|
-
selectOnMove,
|
|
15
|
+
selectOnMove: t0,
|
|
18
16
|
children
|
|
19
17
|
} = props;
|
|
20
|
-
const
|
|
18
|
+
const selectOnMove = t0 === void 0 ? false : t0;
|
|
19
|
+
let t1;
|
|
20
|
+
if ($[0] !== defaultSelectedId) {
|
|
21
|
+
t1 = {
|
|
22
|
+
defaultSelectedId
|
|
23
|
+
};
|
|
24
|
+
$[0] = defaultSelectedId;
|
|
25
|
+
$[1] = t1;
|
|
26
|
+
} else {
|
|
27
|
+
t1 = $[1];
|
|
28
|
+
}
|
|
29
|
+
const store = AkTab.useTabStore(t1);
|
|
21
30
|
const tablist = useStoreState(store, "baseElement");
|
|
22
31
|
const selectedIdFromStore = useStoreState(store, "selectedId");
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
let t2;
|
|
33
|
+
if ($[2] !== selectedIdFromStore || $[3] !== tablist) {
|
|
34
|
+
t2 = (newSelectedId) => {
|
|
35
|
+
if (!supportsAnchorPositioning) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const rootNode = tablist?.getRootNode();
|
|
39
|
+
if (!rootNode || !selectedIdFromStore || !newSelectedId) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const previousTabRect = rootNode.getElementById?.(selectedIdFromStore)?.getBoundingClientRect();
|
|
43
|
+
const nextTabRect = rootNode.getElementById?.(newSelectedId)?.getBoundingClientRect();
|
|
44
|
+
if (!previousTabRect || !nextTabRect) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const deltaX = previousTabRect.left - nextTabRect.left;
|
|
48
|
+
const deltaWidth = previousTabRect.width / nextTabRect.width;
|
|
49
|
+
tablist?.animate([{
|
|
50
|
+
transform: `translateX(${deltaX}px) scaleX(${deltaWidth})`
|
|
51
|
+
}, {
|
|
52
|
+
transform: "none"
|
|
53
|
+
}], {
|
|
38
54
|
pseudoElement: "::after",
|
|
39
55
|
duration: 150,
|
|
40
56
|
easing: "ease-in-out"
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
$[2] = selectedIdFromStore;
|
|
60
|
+
$[3] = tablist;
|
|
61
|
+
$[4] = t2;
|
|
62
|
+
} else {
|
|
63
|
+
t2 = $[4];
|
|
64
|
+
}
|
|
65
|
+
const flipAnimateStripe = t2;
|
|
66
|
+
let t3;
|
|
67
|
+
if ($[5] !== flipAnimateStripe || $[6] !== setSelectedId) {
|
|
68
|
+
t3 = (newSelectedId_0) => {
|
|
69
|
+
if (!prefersReducedMotion()) {
|
|
70
|
+
flipAnimateStripe(newSelectedId_0);
|
|
41
71
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
72
|
+
setSelectedId?.(newSelectedId_0);
|
|
73
|
+
};
|
|
74
|
+
$[5] = flipAnimateStripe;
|
|
75
|
+
$[6] = setSelectedId;
|
|
76
|
+
$[7] = t3;
|
|
77
|
+
} else {
|
|
78
|
+
t3 = $[7];
|
|
79
|
+
}
|
|
80
|
+
const t4 = useUnreactiveCallback(t3);
|
|
81
|
+
let t5;
|
|
82
|
+
if ($[8] !== children || $[9] !== selectOnMove || $[10] !== selectedId || $[11] !== store || $[12] !== t4) {
|
|
83
|
+
t5 = jsx(AkTab.TabProvider, {
|
|
47
84
|
store,
|
|
48
85
|
selectedId,
|
|
49
|
-
setSelectedId:
|
|
50
|
-
(newSelectedId) => {
|
|
51
|
-
if (!prefersReducedMotion()) flipAnimateStripe(newSelectedId);
|
|
52
|
-
setSelectedId?.(newSelectedId);
|
|
53
|
-
}
|
|
54
|
-
),
|
|
86
|
+
setSelectedId: t4,
|
|
55
87
|
selectOnMove,
|
|
56
88
|
children
|
|
57
|
-
}
|
|
58
|
-
|
|
89
|
+
});
|
|
90
|
+
$[8] = children;
|
|
91
|
+
$[9] = selectOnMove;
|
|
92
|
+
$[10] = selectedId;
|
|
93
|
+
$[11] = store;
|
|
94
|
+
$[12] = t4;
|
|
95
|
+
$[13] = t5;
|
|
96
|
+
} else {
|
|
97
|
+
t5 = $[13];
|
|
98
|
+
}
|
|
99
|
+
return t5;
|
|
59
100
|
}
|
|
60
101
|
const TabList = forwardRef((props, forwardedRef) => {
|
|
61
|
-
const {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
);
|
|
102
|
+
const {
|
|
103
|
+
tone = "neutral",
|
|
104
|
+
...rest
|
|
105
|
+
} = props;
|
|
106
|
+
return /* @__PURE__ */ jsx(AkTab.TabList, {
|
|
107
|
+
...rest,
|
|
108
|
+
"data-_sk-tone": tone,
|
|
109
|
+
className: cx("\u{1F95D}TabList", props.className),
|
|
110
|
+
ref: forwardedRef
|
|
111
|
+
});
|
|
71
112
|
});
|
|
72
113
|
const Tab = forwardRef((props, forwardedRef) => {
|
|
73
|
-
return /* @__PURE__ */ jsx(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
ref: forwardedRef
|
|
80
|
-
}
|
|
81
|
-
);
|
|
114
|
+
return /* @__PURE__ */ jsx(AkTab.Tab, {
|
|
115
|
+
accessibleWhenDisabled: true,
|
|
116
|
+
...props,
|
|
117
|
+
className: cx("\u{1F95D}Tab", props.className),
|
|
118
|
+
ref: forwardedRef
|
|
119
|
+
});
|
|
82
120
|
});
|
|
83
121
|
const TabPanel = forwardRef((props, forwardedRef) => {
|
|
84
|
-
return /* @__PURE__ */ jsx(
|
|
85
|
-
|
|
86
|
-
{
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
ref: forwardedRef
|
|
90
|
-
}
|
|
91
|
-
);
|
|
122
|
+
return /* @__PURE__ */ jsx(AkTab.TabPanel, {
|
|
123
|
+
...props,
|
|
124
|
+
className: cx("\u{1F95D}TabPanel", props.className),
|
|
125
|
+
ref: forwardedRef
|
|
126
|
+
});
|
|
92
127
|
});
|
|
93
128
|
export {
|
|
94
129
|
TabsProvider as Provider,
|
package/dist/Toolbar.js
CHANGED
|
@@ -1,53 +1,33 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import * as Toolbar from "@ariakit/react/toolbar";
|
|
4
|
-
import {
|
|
5
|
-
IconButtonContext,
|
|
6
|
-
TooltipContext
|
|
7
|
-
} from "@stratakit/bricks/secret-internals";
|
|
4
|
+
import { IconButtonContext, TooltipContext } from "@stratakit/bricks/secret-internals";
|
|
8
5
|
import { forwardRef } from "@stratakit/foundations/secret-internals";
|
|
9
6
|
import cx from "classnames";
|
|
10
|
-
const ToolbarGroup = forwardRef(
|
|
11
|
-
(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
() => ({
|
|
21
|
-
placement: props.orientation === "vertical" ? "right" : "top"
|
|
22
|
-
}),
|
|
23
|
-
[props.orientation]
|
|
24
|
-
),
|
|
25
|
-
children: /* @__PURE__ */ jsx(
|
|
26
|
-
Toolbar.Toolbar,
|
|
27
|
-
{
|
|
28
|
-
...props,
|
|
29
|
-
className: cx("\u{1F95D}Toolbar", props.className),
|
|
30
|
-
ref: forwardedRef
|
|
31
|
-
}
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
const ToolbarItem = forwardRef(
|
|
40
|
-
(props, forwardedRef) => {
|
|
41
|
-
return /* @__PURE__ */ jsx(
|
|
42
|
-
Toolbar.ToolbarItem,
|
|
43
|
-
{
|
|
7
|
+
const ToolbarGroup = forwardRef((props, forwardedRef) => {
|
|
8
|
+
return /* @__PURE__ */ jsx(IconButtonContext.Provider, {
|
|
9
|
+
value: React.useMemo(() => ({
|
|
10
|
+
iconSize: "large"
|
|
11
|
+
}), []),
|
|
12
|
+
children: /* @__PURE__ */ jsx(TooltipContext.Provider, {
|
|
13
|
+
value: React.useMemo(() => ({
|
|
14
|
+
placement: props.orientation === "vertical" ? "right" : "top"
|
|
15
|
+
}), [props.orientation]),
|
|
16
|
+
children: /* @__PURE__ */ jsx(Toolbar.Toolbar, {
|
|
44
17
|
...props,
|
|
45
|
-
className: cx("\u{1F95D}
|
|
18
|
+
className: cx("\u{1F95D}Toolbar", props.className),
|
|
46
19
|
ref: forwardedRef
|
|
47
|
-
}
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
);
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
const ToolbarItem = forwardRef((props, forwardedRef) => {
|
|
25
|
+
return /* @__PURE__ */ jsx(Toolbar.ToolbarItem, {
|
|
26
|
+
...props,
|
|
27
|
+
className: cx("\u{1F95D}ToolbarItem", props.className),
|
|
28
|
+
ref: forwardedRef
|
|
29
|
+
});
|
|
30
|
+
});
|
|
51
31
|
export {
|
|
52
32
|
ToolbarGroup as Group,
|
|
53
33
|
ToolbarItem as Item
|
package/dist/Tree.js
CHANGED
|
@@ -5,18 +5,19 @@ import { forwardRef } from "@stratakit/foundations/secret-internals";
|
|
|
5
5
|
import cx from "classnames";
|
|
6
6
|
import { Action as TreeItemAction, Root as TreeItemRoot } from "./TreeItem.js";
|
|
7
7
|
const Tree = forwardRef((props, forwardedRef) => {
|
|
8
|
-
const composite = useCompositeStore({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
const composite = useCompositeStore({
|
|
9
|
+
orientation: "vertical"
|
|
10
|
+
});
|
|
11
|
+
return /* @__PURE__ */ jsx(Role.div, {
|
|
12
|
+
role: "tree",
|
|
13
|
+
...props,
|
|
14
|
+
render: /* @__PURE__ */ jsx(Composite, {
|
|
15
|
+
store: composite
|
|
16
|
+
}),
|
|
17
|
+
className: cx("\u{1F95D}Tree", props.className),
|
|
18
|
+
ref: forwardedRef,
|
|
19
|
+
children: props.children
|
|
20
|
+
});
|
|
20
21
|
});
|
|
21
22
|
export {
|
|
22
23
|
TreeItemRoot as Item,
|