@stratakit/structures 0.1.0 → 0.2.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.
@@ -0,0 +1,168 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import {
3
+ Collection,
4
+ CollectionItem,
5
+ useCollectionStore
6
+ } from "@ariakit/react/collection";
7
+ import {
8
+ Dialog,
9
+ DialogDisclosure,
10
+ DialogProvider
11
+ } from "@ariakit/react/dialog";
12
+ import { Role } from "@ariakit/react/role";
13
+ import { useStoreState } from "@ariakit/react/store";
14
+ import { Button, Text, VisuallyHidden } from "@stratakit/bricks";
15
+ import { IconButtonPresentation } from "@stratakit/bricks/secret-internals";
16
+ import {
17
+ forwardRef,
18
+ useControlledState
19
+ } from "@stratakit/foundations/secret-internals";
20
+ import cx from "classnames";
21
+ import * as React from "react";
22
+ import { ChevronDown, StatusIcon } from "./~utils.icons.js";
23
+ const ErrorRegionRoot = forwardRef(
24
+ (props, forwardedRef) => {
25
+ const {
26
+ label,
27
+ items,
28
+ open: openProp,
29
+ setOpen: setOpenProp,
30
+ ...rest
31
+ } = props;
32
+ const labelId = React.useId();
33
+ const sectionLabelledBy = props["aria-labelledby"] ?? (props["aria-label"] ? void 0 : labelId);
34
+ const [open, setOpen] = useControlledState(
35
+ false,
36
+ openProp,
37
+ setOpenProp
38
+ );
39
+ const containerRef = React.useRef(null);
40
+ const pulse = () => {
41
+ const el = containerRef.current;
42
+ if (!el) return;
43
+ const id = "--\u{1F95D}error-region-pulse";
44
+ const animations = el.getAnimations({ subtree: true });
45
+ if (animations.find((animation) => animation.id === id)) return;
46
+ el.animate(
47
+ [
48
+ {
49
+ boxShadow: "0 0 0 0 var(--ids-color-border-attention-base)",
50
+ opacity: 1
51
+ },
52
+ {
53
+ boxShadow: "0 0 15px 2px var(--ids-color-border-attention-base)",
54
+ opacity: 0.7,
55
+ offset: 0.5
56
+ },
57
+ {
58
+ boxShadow: "0 0 0 0 var(--ids-color-border-attention-base)",
59
+ opacity: 1
60
+ }
61
+ ],
62
+ {
63
+ id,
64
+ duration: 600,
65
+ easing: "cubic-bezier(0.4, 0, 0.2, 1)",
66
+ pseudoElement: "::before"
67
+ }
68
+ );
69
+ };
70
+ const store = useCollectionStore({
71
+ setItems: (newItems) => {
72
+ const prevItemsSet = new Set(prevItems.map((item) => item.id));
73
+ const addedItems = newItems.filter(
74
+ (item) => !prevItemsSet.has(item.id)
75
+ );
76
+ if (addedItems.length === 0) return;
77
+ pulse();
78
+ setLiveLabel(label);
79
+ }
80
+ });
81
+ const prevItems = useStoreState(store, "items");
82
+ const [liveLabel, setLiveLabel] = React.useState(label);
83
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
84
+ /* @__PURE__ */ jsx(VisuallyHidden, { "aria-live": "polite", "aria-atomic": true, children: liveLabel === label ? liveLabel : void 0 }),
85
+ /* @__PURE__ */ jsx(DialogProvider, { open, setOpen, children: /* @__PURE__ */ jsx(
86
+ Role.section,
87
+ {
88
+ ...rest,
89
+ "aria-labelledby": sectionLabelledBy,
90
+ className: cx("\u{1F95D}-error-region", props.className),
91
+ "data-kiwi-visible": !!label,
92
+ "data-kiwi-expanded": open,
93
+ ref: forwardedRef,
94
+ children: /* @__PURE__ */ jsxs("div", { className: "\u{1F95D}-error-region-container", ref: containerRef, children: [
95
+ /* @__PURE__ */ jsxs(
96
+ DialogDisclosure,
97
+ {
98
+ className: "\u{1F95D}-error-region-header",
99
+ render: /* @__PURE__ */ jsx(Button, { variant: "ghost" }),
100
+ children: [
101
+ /* @__PURE__ */ jsx(StatusIcon, { tone: "attention", className: "\u{1F95D}-error-region-icon" }),
102
+ /* @__PURE__ */ jsx(
103
+ Text,
104
+ {
105
+ render: /* @__PURE__ */ jsx("span", {}),
106
+ id: labelId,
107
+ className: "\u{1F95D}-error-region-label",
108
+ variant: "body-sm",
109
+ children: label
110
+ }
111
+ ),
112
+ /* @__PURE__ */ jsx(IconButtonPresentation, { inert: true, variant: "ghost", children: /* @__PURE__ */ jsx(ChevronDown, {}) })
113
+ ]
114
+ }
115
+ ),
116
+ /* @__PURE__ */ jsx(
117
+ Dialog,
118
+ {
119
+ className: "\u{1F95D}-error-region-dialog",
120
+ portal: false,
121
+ modal: false,
122
+ autoFocusOnShow: false,
123
+ "aria-labelledby": labelId,
124
+ children: /* @__PURE__ */ jsx(
125
+ Collection,
126
+ {
127
+ store,
128
+ className: "\u{1F95D}-error-region-items",
129
+ role: "list",
130
+ children: items
131
+ }
132
+ )
133
+ }
134
+ )
135
+ ] })
136
+ }
137
+ ) })
138
+ ] });
139
+ }
140
+ );
141
+ const ErrorRegionItem = forwardRef(
142
+ (props, forwardedRef) => {
143
+ const generatedId = React.useId();
144
+ const {
145
+ message,
146
+ messageId = `${generatedId}-message`,
147
+ actions,
148
+ ...rest
149
+ } = props;
150
+ return /* @__PURE__ */ jsxs(
151
+ CollectionItem,
152
+ {
153
+ ...rest,
154
+ role: "listitem",
155
+ className: cx("\u{1F95D}-error-region-item", props.className),
156
+ ref: forwardedRef,
157
+ children: [
158
+ /* @__PURE__ */ jsx(Text, { id: messageId, variant: "body-sm", children: message }),
159
+ /* @__PURE__ */ jsx("div", { className: "\u{1F95D}-error-region-item-actions", children: actions })
160
+ ]
161
+ }
162
+ );
163
+ }
164
+ );
165
+ export {
166
+ ErrorRegionItem as Item,
167
+ ErrorRegionRoot as Root
168
+ };
@@ -0,0 +1,172 @@
1
+ import * as React from "react";
2
+ import type { BaseProps } from "@stratakit/foundations/secret-internals";
3
+ interface HtmlTableProps extends BaseProps {
4
+ }
5
+ /**
6
+ * A table is a grid of rows and columns that displays data in a structured format.
7
+ *
8
+ * `Table.HtmlTable` uses native HTML table elements for the table root *and its descendants*.
9
+ *
10
+ * E.g. `<table>`, `<thead>`, `<tbody>`, `<tr>`, `<th>`, and `<td>`.
11
+ *
12
+ * Related: `Table.CustomTable`
13
+ *
14
+ * Example:
15
+ * ```tsx
16
+ * <Table.HtmlTable> // <table>
17
+ * <Table.Caption>Table Caption</Table.Caption> // <caption>
18
+ *
19
+ * <Table.Header> // <thead>
20
+ * <Table.Row> // <tr>
21
+ * <Table.Cell>Header 1</Table.Cell> // <th>
22
+ * <Table.Cell>Header 2</Table.Cell> // <th>
23
+ * </Table.Row>
24
+ * </Table.Header>
25
+ *
26
+ * <Table.Body> // <tbody>
27
+ * <Table.Row> // <tr>
28
+ * <Table.Cell>Cell 1.1</Table.Cell> // <td>
29
+ * <Table.Cell>Cell 1.2</Table.Cell> // <td>
30
+ * </Table.Row>
31
+ * <Table.Row> // <tr>
32
+ * <Table.Cell>Cell 2.1</Table.Cell> // <td>
33
+ * <Table.Cell>Cell 2.2</Table.Cell> // <td>
34
+ * </Table.Row>
35
+ * </Table.Body>
36
+ * </Table.HtmlTable>
37
+ * ```
38
+ */
39
+ declare const HtmlTable: React.ForwardRefExoticComponent<HtmlTableProps & React.RefAttributes<HTMLElement | HTMLTableElement>>;
40
+ interface CustomTableProps extends BaseProps {
41
+ }
42
+ /**
43
+ * A table is a grid of rows and columns that displays data in a structured format.
44
+ *
45
+ * `Table.CustomTable` implements the [WAI-ARIA table pattern](https://www.w3.org/WAI/ARIA/apg/patterns/table/) using
46
+ * divs + appropriate roles for the table root *and its descendants*.
47
+ *
48
+ * E.g. `<div role="table">`, `<div role="row">`, `<div role="columnheader">`, and `<div role="cell">`.
49
+ *
50
+ * Related: `Table.HtmlTable`
51
+ *
52
+ * Example:
53
+ * ```tsx
54
+ * <Table.CustomTable> // <div role="table">
55
+ * <Table.Caption>Table Caption</Table.Caption> // <div role="caption">
56
+ *
57
+ * <Table.Header> // <div role="rowgroup">
58
+ * <Table.Row> // <div role="row">
59
+ * <Table.Cell>Header 1</Table.Cell> // <div role="columnheader">
60
+ * <Table.Cell>Header 2</Table.Cell> // <div role="columnheader">
61
+ * </Table.Row>
62
+ * </Table.Header>
63
+ *
64
+ * <Table.Body>
65
+ * <Table.Row> // <div role="row">
66
+ * <Table.Cell>Cell 1.1</Table.Cell> // <div role="cell">
67
+ * <Table.Cell>Cell 1.2</Table.Cell> // <div role="cell">
68
+ * </Table.Row>
69
+ * <Table.Row> // <div role="row">
70
+ * <Table.Cell>Cell 2.1</Table.Cell> // <div role="cell">
71
+ * <Table.Cell>Cell 2.2</Table.Cell> // <div role="cell">
72
+ * </Table.Row>
73
+ * </Table.Body>
74
+ * </Table.CustomTable>
75
+ * ```
76
+ */
77
+ declare const CustomTable: React.ForwardRefExoticComponent<CustomTableProps & React.RefAttributes<HTMLDivElement | HTMLElement>>;
78
+ interface TableHeaderProps extends BaseProps<"div"> {
79
+ }
80
+ /**
81
+ * `Table.Header` is a column component of cells that labels the columns of a table.
82
+ * `Table.Row` and `Table.Cell` can be nested inside a `Table.Header` to create a header row.
83
+ *
84
+ * If within a `Table.HtmlTable`: it will render a `<thead>` element.
85
+ * If within a `Table.CustomTable`: it will render a `<div role="rowgroup">` element.
86
+ *
87
+ * Example:
88
+ * ```tsx
89
+ * <Table.Header>
90
+ * <Table.Row>
91
+ * <Table.Cell>Header 1</Table.Cell>
92
+ * <Table.Cell>Header 2</Table.Cell>
93
+ * </Table.Row>
94
+ * </Table.Header>
95
+ * ```
96
+ */
97
+ declare const TableHeader: React.ForwardRefExoticComponent<TableHeaderProps & React.RefAttributes<HTMLDivElement | HTMLElement>>;
98
+ interface TableBodyProps extends BaseProps<"div"> {
99
+ }
100
+ /**
101
+ * `Table.Body` is a component that contains the rows of table data.
102
+ * Multiple `Table.Row`s and `Table.Cell`s can be nested inside a `Table.Body` to create a table body.
103
+ *
104
+ * If within a `Table.HtmlTable`: it will render a `<tbody>` element.
105
+ * If within a `Table.CustomTable`: it will render a `<div>` element.
106
+ *
107
+ * Example:
108
+ * ```tsx
109
+ * <Table.Body>
110
+ * <Table.Row>
111
+ * <Table.Cell>Cell 1.1</Table.Cell>
112
+ * <Table.Cell>Cell 1.2</Table.Cell>
113
+ * </Table.Row>
114
+ * <Table.Row>
115
+ * <Table.Cell>Cell 2.1</Table.Cell>
116
+ * <Table.Cell>Cell 2.2</Table.Cell>
117
+ * </Table.Row>
118
+ * </Table.Body>
119
+ * ```
120
+ */
121
+ declare const TableBody: React.ForwardRefExoticComponent<TableBodyProps & React.RefAttributes<HTMLDivElement | HTMLElement>>;
122
+ interface TableRowProps extends BaseProps<"div"> {
123
+ }
124
+ /**
125
+ * `Table.Row` is a component that contains the cells of a table row.
126
+ *
127
+ * If within a `Table.HtmlTable`: it will render a `<tr>` element.
128
+ * If within a `Table.CustomTable`: it will render a `<div role="row">` element.
129
+ *
130
+ * Example:
131
+ * ```tsx
132
+ * <Table.Row>
133
+ * <Table.Cell>Cell 1.1</Table.Cell>
134
+ * <Table.Cell>Cell 1.2</Table.Cell>
135
+ * </Table.Row>
136
+ * ```
137
+ */
138
+ declare const TableRow: React.ForwardRefExoticComponent<TableRowProps & React.RefAttributes<HTMLDivElement | HTMLElement>>;
139
+ interface TableCaptionProps extends BaseProps<"div"> {
140
+ }
141
+ /**
142
+ * `Table.Caption` is a component that contains the caption of a table.
143
+ *
144
+ * If within a `Table.HtmlTable`: it will render a `<caption>` element.
145
+ * If within a `Table.CustomTable`: it will render a `<div role="caption">` element.
146
+ *
147
+ * Example:
148
+ * ```tsx
149
+ * <Table.CustomTable> // Or <Table.HtmlTable>
150
+ * <Table.Caption>Table Caption</Table.Caption>
151
+ * …
152
+ * </Table.CustomTable> // Or </Table.HtmlTable>
153
+ * ```
154
+ */
155
+ declare const TableCaption: React.ForwardRefExoticComponent<TableCaptionProps & React.RefAttributes<HTMLDivElement | HTMLElement>>;
156
+ interface TableCellProps extends BaseProps<"div"> {
157
+ }
158
+ /**
159
+ * `Table.Cell` is a component that contains the data of a table cell.
160
+ *
161
+ * - If within a `Table.HtmlTable`: it will render a `<th>` element if also within a `Table.Header`, or a `<td>` element
162
+ * if also within a `Table.Body`.
163
+ * - If within a `Table.CustomTable`: it will render a `<div role="columnheader">` element if also within a
164
+ * `Table.Header`, or a `<div role="cell">` element if also within a `Table.Body`.
165
+ *
166
+ * Example:
167
+ * ```tsx
168
+ * <Table.Cell>Cell 1.1</Table.Cell>
169
+ * ```
170
+ */
171
+ declare const TableCell: React.ForwardRefExoticComponent<TableCellProps & React.RefAttributes<HTMLDivElement | HTMLElement>>;
172
+ export { HtmlTable, CustomTable, TableHeader as Header, TableBody as Body, TableRow as Row, TableCaption as Caption, TableCell as Cell, };
package/dist/Table.js ADDED
@@ -0,0 +1,144 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Role } from "@ariakit/react/role";
3
+ import { forwardRef } from "@stratakit/foundations/secret-internals";
4
+ import {
5
+ useMergedRefs,
6
+ useSafeContext
7
+ } from "@stratakit/foundations/secret-internals";
8
+ import cx from "classnames";
9
+ import * as React from "react";
10
+ const TableContext = React.createContext(void 0);
11
+ const TableHeaderContext = React.createContext(false);
12
+ const HtmlTable = forwardRef((props, forwardedRef) => {
13
+ const tableContextValue = React.useMemo(
14
+ () => ({ mode: "html" }),
15
+ []
16
+ );
17
+ return /* @__PURE__ */ jsx(TableContext.Provider, { value: tableContextValue, children: /* @__PURE__ */ jsx(
18
+ Role,
19
+ {
20
+ render: /* @__PURE__ */ jsx("table", {}),
21
+ ...props,
22
+ ref: forwardedRef,
23
+ className: cx("\u{1F95D}-table", props.className)
24
+ }
25
+ ) });
26
+ });
27
+ const CustomTable = forwardRef(
28
+ (props, forwardedRef) => {
29
+ const [captionId, setCaptionId] = React.useState();
30
+ const tableContextValue = React.useMemo(
31
+ () => ({ captionId, setCaptionId, mode: "aria" }),
32
+ [captionId]
33
+ );
34
+ return /* @__PURE__ */ jsx(TableContext.Provider, { value: tableContextValue, children: /* @__PURE__ */ jsx(
35
+ Role.div,
36
+ {
37
+ role: "table",
38
+ "aria-labelledby": captionId,
39
+ ...props,
40
+ ref: forwardedRef,
41
+ className: cx("\u{1F95D}-table", props.className)
42
+ }
43
+ ) });
44
+ }
45
+ );
46
+ const TableHeader = forwardRef(
47
+ (props, forwardedRef) => {
48
+ const { mode } = useSafeContext(TableContext);
49
+ const render = mode === "html" ? /* @__PURE__ */ jsx("thead", {}) : void 0;
50
+ const role = mode === "aria" ? "rowgroup" : void 0;
51
+ return /* @__PURE__ */ jsx(TableHeaderContext.Provider, { value: true, children: /* @__PURE__ */ jsx(
52
+ Role.div,
53
+ {
54
+ render,
55
+ role,
56
+ ...props,
57
+ ref: forwardedRef,
58
+ className: cx("\u{1F95D}-table-header", props.className)
59
+ }
60
+ ) });
61
+ }
62
+ );
63
+ const TableBody = forwardRef((props, forwardedRef) => {
64
+ const { mode } = useSafeContext(TableContext);
65
+ const render = mode === "html" ? /* @__PURE__ */ jsx("tbody", {}) : void 0;
66
+ return /* @__PURE__ */ jsx(
67
+ Role.div,
68
+ {
69
+ render,
70
+ role: void 0,
71
+ ...props,
72
+ ref: forwardedRef,
73
+ className: cx("\u{1F95D}-table-body", props.className)
74
+ }
75
+ );
76
+ });
77
+ const TableRow = forwardRef((props, forwardedRef) => {
78
+ const { mode } = useSafeContext(TableContext);
79
+ const render = mode === "html" ? /* @__PURE__ */ jsx("tr", {}) : void 0;
80
+ const role = mode === "aria" ? "row" : void 0;
81
+ return /* @__PURE__ */ jsx(
82
+ Role.div,
83
+ {
84
+ render,
85
+ role,
86
+ ...props,
87
+ ref: forwardedRef,
88
+ className: cx("\u{1F95D}-table-row", props.className)
89
+ }
90
+ );
91
+ });
92
+ const TableCaption = forwardRef(
93
+ (props, forwardedRef) => {
94
+ const fallbackId = React.useId();
95
+ const { id = fallbackId, ...rest } = props;
96
+ const { mode, setCaptionId } = useSafeContext(TableContext);
97
+ const render = mode === "html" ? /* @__PURE__ */ jsx("caption", {}) : void 0;
98
+ const captionIdRef = React.useCallback(
99
+ (element) => {
100
+ setCaptionId?.(element ? id : void 0);
101
+ },
102
+ [id, setCaptionId]
103
+ );
104
+ return /* @__PURE__ */ jsx(
105
+ Role.div,
106
+ {
107
+ render,
108
+ ...rest,
109
+ id,
110
+ ref: useMergedRefs(forwardedRef, captionIdRef),
111
+ className: cx("\u{1F95D}-table-caption", props.className)
112
+ }
113
+ );
114
+ }
115
+ );
116
+ const TableCell = forwardRef((props, forwardedRef) => {
117
+ const isWithinTableHeader = useSafeContext(TableHeaderContext);
118
+ const { mode } = useSafeContext(TableContext);
119
+ const { render, role } = React.useMemo(() => {
120
+ if (mode === "aria") {
121
+ return { role: isWithinTableHeader ? "columnheader" : "cell" };
122
+ }
123
+ return { render: isWithinTableHeader ? /* @__PURE__ */ jsx("th", {}) : /* @__PURE__ */ jsx("td", {}) };
124
+ }, [isWithinTableHeader, mode]);
125
+ return /* @__PURE__ */ jsx(
126
+ Role.div,
127
+ {
128
+ render,
129
+ role,
130
+ ...props,
131
+ ref: forwardedRef,
132
+ className: cx("\u{1F95D}-table-cell", props.className)
133
+ }
134
+ );
135
+ });
136
+ export {
137
+ TableBody as Body,
138
+ TableCaption as Caption,
139
+ TableCell as Cell,
140
+ CustomTable,
141
+ TableHeader as Header,
142
+ HtmlTable,
143
+ TableRow as Row
144
+ };
package/dist/Tabs.d.ts ADDED
@@ -0,0 +1,81 @@
1
+ import * as AkTab from "@ariakit/react/tab";
2
+ import type { BaseProps, FocusableProps } from "@stratakit/foundations/secret-internals";
3
+ interface TabsProps extends Pick<AkTab.TabProviderProps, "defaultSelectedId" | "selectedId" | "setSelectedId" | "selectOnMove" | "children"> {
4
+ }
5
+ /**
6
+ * A set of tabs that can be used to switch between different views.
7
+ *
8
+ * `Tabs` is a compound component with subcomponents exposed for different parts.
9
+ *
10
+ * Example:
11
+ * ```tsx
12
+ * <Tabs.Root>
13
+ * <Tabs.TabList>
14
+ * <Tabs.Tab id="tab-1">Tab 1</Tabs.Tab>
15
+ * <Tabs.Tab id="tab-2">Tab 2</Tabs.Tab>
16
+ * <Tabs.Tab id="tab-3">Tab 3</Tabs.Tab>
17
+ * </Tabs.TabList>
18
+ *
19
+ * <Tabs.TabPanel tabId="tab-1">Tab 1 content</Tabs.TabPanel>
20
+ * <Tabs.TabPanel tabId="tab-2">Tab 2 content</Tabs.TabPanel>
21
+ * <Tabs.TabPanel tabId="tab-3">Tab 3 content</Tabs.TabPanel>
22
+ * </Tabs.Root>
23
+ * ```
24
+ *
25
+ * The tabs and their panels are connected by matching the `id` prop on the `Tabs.Tab` component with
26
+ * the `tabId` prop on the `Tabs.TabPanel` component.
27
+ *
28
+ * The `Tabs` component automatically manages the selected tab state. The initially selected tab can be set using `defaultSelectedId`.
29
+ * To take full control the selected tab state, use the `selectedId` and `setSelectedId` props together.
30
+ *
31
+ * **Note**: `Tabs` should _not_ be used for navigation; it is only intended for switching smaller views within an existing page.
32
+ */
33
+ declare function Tabs(props: TabsProps): import("react/jsx-runtime").JSX.Element;
34
+ declare namespace Tabs {
35
+ var displayName: string;
36
+ }
37
+ interface TabListProps extends BaseProps {
38
+ /** @default "neutral" */
39
+ tone?: "neutral" | "accent";
40
+ }
41
+ /**
42
+ * A simple container for the tab buttons.
43
+ * Should be used as a child of `Tabs.Root` and consist of the individual `Tabs.Tab` components.
44
+ *
45
+ * Example:
46
+ * ```tsx
47
+ * <Tabs.TabList>
48
+ * <Tabs.Tab id="tab-1">Tab 1</Tabs.Tab>
49
+ * <Tabs.Tab id="tab-2">Tab 2</Tabs.Tab>
50
+ * <Tabs.Tab id="tab-3">Tab 3</Tabs.Tab>
51
+ * </Tabs.TabList>
52
+ * ```
53
+ */
54
+ declare const TabList: import("react").ForwardRefExoticComponent<TabListProps & import("react").RefAttributes<HTMLDivElement | HTMLElement>>;
55
+ interface TabProps extends FocusableProps<"button">, Pick<AkTab.TabProps, "id"> {
56
+ }
57
+ /**
58
+ * An individual tab button that switches the selected tab panel when clicked.
59
+ *
60
+ * Should be used as a child of `Tabs.TabList` and be paired with a `Tabs.TabPanel`,
61
+ * connected using an id.
62
+ *
63
+ * Example:
64
+ * ```tsx
65
+ * <Tabs.Tab id="tab-1">Tab 1</Tabs.Tab>
66
+ * ```
67
+ */
68
+ declare const Tab: import("react").ForwardRefExoticComponent<TabProps & import("react").RefAttributes<HTMLElement | HTMLButtonElement>>;
69
+ interface TabPanelProps extends FocusableProps<"div">, Pick<AkTab.TabPanelProps, "tabId" | "unmountOnHide" | "focusable"> {
70
+ }
71
+ /**
72
+ * The actual content of a tab, shown when the tab is selected. Should be used as a child of `Tabs.Root`.
73
+ * The `tabId` prop should match the `id` prop of the corresponding `Tabs.Tab` component.
74
+ *
75
+ * Example:
76
+ * ```tsx
77
+ * <Tabs.TabPanel tabId="tab-1">Tab 1 content</Tabs.TabPanel>
78
+ * ```
79
+ */
80
+ declare const TabPanel: import("react").ForwardRefExoticComponent<TabPanelProps & import("react").RefAttributes<HTMLDivElement | HTMLElement>>;
81
+ export { Tabs as Root, TabList, Tab, TabPanel };
package/dist/Tabs.js ADDED
@@ -0,0 +1,62 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import * as AkTab from "@ariakit/react/tab";
3
+ import { forwardRef } from "@stratakit/foundations/secret-internals";
4
+ import cx from "classnames";
5
+ function Tabs(props) {
6
+ const {
7
+ defaultSelectedId,
8
+ selectedId,
9
+ setSelectedId,
10
+ selectOnMove,
11
+ children
12
+ } = props;
13
+ return /* @__PURE__ */ jsx(
14
+ AkTab.TabProvider,
15
+ {
16
+ defaultSelectedId,
17
+ selectedId,
18
+ setSelectedId,
19
+ selectOnMove,
20
+ children
21
+ }
22
+ );
23
+ }
24
+ const TabList = forwardRef((props, forwardedRef) => {
25
+ const { tone = "neutral", ...rest } = props;
26
+ return /* @__PURE__ */ jsx(
27
+ AkTab.TabList,
28
+ {
29
+ ...rest,
30
+ "data-kiwi-tone": tone,
31
+ className: cx("\u{1F95D}-tab-list", props.className),
32
+ ref: forwardedRef
33
+ }
34
+ );
35
+ });
36
+ const Tab = forwardRef((props, forwardedRef) => {
37
+ return /* @__PURE__ */ jsx(
38
+ AkTab.Tab,
39
+ {
40
+ accessibleWhenDisabled: true,
41
+ ...props,
42
+ className: cx("\u{1F95D}-tab", props.className),
43
+ ref: forwardedRef
44
+ }
45
+ );
46
+ });
47
+ const TabPanel = forwardRef((props, forwardedRef) => {
48
+ return /* @__PURE__ */ jsx(
49
+ AkTab.TabPanel,
50
+ {
51
+ ...props,
52
+ className: cx("\u{1F95D}-tab-panel", props.className),
53
+ ref: forwardedRef
54
+ }
55
+ );
56
+ });
57
+ export {
58
+ Tabs as Root,
59
+ Tab,
60
+ TabList,
61
+ TabPanel
62
+ };
@@ -0,0 +1,36 @@
1
+ import * as React from "react";
2
+ import type { BaseProps } from "@stratakit/foundations/secret-internals";
3
+ interface ToolbarProps extends BaseProps {
4
+ /** Must be set to `"solid"` for now. */
5
+ variant: "solid";
6
+ }
7
+ /**
8
+ * A toolbar for grouping related interactive elements.
9
+ *
10
+ * Follows the [ARIA Toolbar pattern](https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/) for reducing the number of tab stops.
11
+ *
12
+ * Example:
13
+ * ```jsx
14
+ * <Toolbar.Group variant="solid">
15
+ * <Toolbar.Item render={…} />
16
+ * <Toolbar.Item render={…} />
17
+ * <Toolbar.Item render={…} />
18
+ * </Toolbar.Group>
19
+ * ```
20
+ */
21
+ declare const ToolbarGroup: React.ForwardRefExoticComponent<ToolbarProps & React.RefAttributes<HTMLDivElement | HTMLElement>>;
22
+ interface ToolbarItemProps extends Omit<BaseProps<"button">, "render">, Required<Pick<BaseProps, "render">> {
23
+ }
24
+ /**
25
+ * An item within the toolbar.
26
+ * Should be used with the `render` prop.
27
+ *
28
+ * Example:
29
+ * ```jsx
30
+ * <Toolbar.Item
31
+ * render={<IconButton variant="ghost" … />}
32
+ * />
33
+ * ```
34
+ */
35
+ declare const ToolbarItem: React.ForwardRefExoticComponent<ToolbarItemProps & React.RefAttributes<HTMLElement | HTMLButtonElement>>;
36
+ export { ToolbarGroup as Group, ToolbarItem as Item };
@@ -0,0 +1,25 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import * as Toolbar from "@ariakit/react/toolbar";
3
+ import { IconButtonContext } from "@stratakit/bricks/secret-internals";
4
+ import { forwardRef } from "@stratakit/foundations/secret-internals";
5
+ import cx from "classnames";
6
+ import * as React from "react";
7
+ const ToolbarGroup = forwardRef((props, forwardedRef) => {
8
+ return /* @__PURE__ */ jsx(IconButtonContext, { value: React.useMemo(() => ({ iconSize: "large" }), []), children: /* @__PURE__ */ jsx(
9
+ Toolbar.Toolbar,
10
+ {
11
+ ...props,
12
+ className: cx("\u{1F95D}-toolbar", props.className),
13
+ ref: forwardedRef
14
+ }
15
+ ) });
16
+ });
17
+ const ToolbarItem = forwardRef(
18
+ (props, forwardedRef) => {
19
+ return /* @__PURE__ */ jsx(Toolbar.ToolbarItem, { ...props, ref: forwardedRef });
20
+ }
21
+ );
22
+ export {
23
+ ToolbarGroup as Group,
24
+ ToolbarItem as Item
25
+ };