@manakind/ui-core 0.35.0 → 0.36.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/dist/tabs/index.d.ts +1 -1
- package/dist/tabs/index.d.ts.map +1 -1
- package/dist/tabs/index.js.map +1 -1
- package/dist/tabs/tabs.css +24 -4
- package/dist/tabs/tabs.d.ts +42 -13
- package/dist/tabs/tabs.d.ts.map +1 -1
- package/dist/tabs/tabs.js +37 -10
- package/dist/tabs/tabs.js.map +1 -1
- package/package.json +2 -2
package/dist/tabs/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { TabsContentProps, TabsListProps, TabsProps, TabsTriggerProps } from './tabs';
|
|
1
|
+
export type { TabsContentProps, TabsListAppearance, TabsListProps, TabsProps, TabsTriggerProps, } from './tabs';
|
|
2
2
|
export { Tabs, TabsContent, TabsList, TabsTrigger } from './tabs';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/tabs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tabs/index.ts"],"names":[],"mappings":"AAAA,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tabs/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,SAAS,EACT,gBAAgB,GACjB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC"}
|
package/dist/tabs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tabs/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tabs/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC","sourcesContent":["export type {\n TabsContentProps,\n TabsListAppearance,\n TabsListProps,\n TabsProps,\n TabsTriggerProps,\n} from './tabs';\nexport { Tabs, TabsContent, TabsList, TabsTrigger } from './tabs';\n"]}
|
package/dist/tabs/tabs.css
CHANGED
|
@@ -94,10 +94,6 @@
|
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
/*
|
|
98
|
-
* `nowrap` triggers cannot shrink below their label, so five of them used
|
|
99
|
-
* to widen the whole page on a phone. The list scrolls them instead.
|
|
100
|
-
*/
|
|
101
97
|
/*
|
|
102
98
|
* `nowrap` triggers cannot shrink below their label, so five of them used
|
|
103
99
|
* to widen the whole page on a phone. The scroller scrolls them instead.
|
|
@@ -205,5 +201,29 @@
|
|
|
205
201
|
padding-inline-start: var(--ds-tabs-content-padding-block);
|
|
206
202
|
}
|
|
207
203
|
}
|
|
204
|
+
|
|
205
|
+
/*
|
|
206
|
+
* A plain list: no track, and every trigger its own shape. It wraps rather
|
|
207
|
+
* than scrolling, so there is no scroller to clip the focus ring and no
|
|
208
|
+
* `nowrap` that would need one; a trigger's label wraps as any text does.
|
|
209
|
+
*
|
|
210
|
+
* Declared last, with the list's two classes, so it outranks the segmented
|
|
211
|
+
* corners above, the vertical ones included, on specificity and on order.
|
|
212
|
+
*/
|
|
213
|
+
& .ds-tabs__list.ds-tabs__list--plain {
|
|
214
|
+
flex-wrap: wrap;
|
|
215
|
+
gap: var(--ds-layout-gap);
|
|
216
|
+
min-inline-size: 0;
|
|
217
|
+
padding: 0;
|
|
218
|
+
border-radius: 0;
|
|
219
|
+
background-color: transparent;
|
|
220
|
+
|
|
221
|
+
& .ds-tabs__trigger {
|
|
222
|
+
flex-shrink: 1;
|
|
223
|
+
min-inline-size: 0;
|
|
224
|
+
border-radius: var(--ds-tabs-list-radius);
|
|
225
|
+
white-space: normal;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
208
228
|
}
|
|
209
229
|
}
|
package/dist/tabs/tabs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Tabs as ArkTabs } from '@ark-ui/react/tabs';
|
|
2
|
-
import type
|
|
2
|
+
import { type ComponentProps } from 'react';
|
|
3
3
|
import './tabs.css';
|
|
4
4
|
export type TabsProps = ComponentProps<typeof ArkTabs.Root>;
|
|
5
5
|
/**
|
|
@@ -27,13 +27,33 @@ export type TabsProps = ComponentProps<typeof ArkTabs.Root>;
|
|
|
27
27
|
* then move focus without switching panels until Enter or Space.
|
|
28
28
|
*/
|
|
29
29
|
export declare function Tabs({ className, children, ...props }: TabsProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* `fitted` shares the width of one row, and a `plain` row wraps, so the two
|
|
32
|
+
* cannot be combined: the pairing is a compile error rather than a
|
|
33
|
+
* convention, as Badge's `BadgeLook` is.
|
|
34
|
+
*/
|
|
35
|
+
type TabsListLook = {
|
|
31
36
|
/**
|
|
32
|
-
*
|
|
33
|
-
*
|
|
37
|
+
* `segmented` (default) sets the triggers on a track and scrolls them
|
|
38
|
+
* sideways when they outgrow the list. `plain` drops the track and its
|
|
39
|
+
* padding: every trigger takes the list's radius as its own shape, the
|
|
40
|
+
* triggers sit `--ds-layout-gap` apart, and a row that outgrows the list
|
|
41
|
+
* wraps onto a new line instead of scrolling. For triggers that carry
|
|
42
|
+
* their own look, such as a row of avatars or category badges.
|
|
43
|
+
*/
|
|
44
|
+
appearance?: 'segmented';
|
|
45
|
+
/**
|
|
46
|
+
* Distribute triggers evenly across the full width instead of sizing
|
|
47
|
+
* them to their content. Matches the segmented-control look.
|
|
34
48
|
*/
|
|
35
49
|
fitted?: boolean;
|
|
36
|
-
}
|
|
50
|
+
} | {
|
|
51
|
+
appearance: 'plain';
|
|
52
|
+
fitted?: never;
|
|
53
|
+
};
|
|
54
|
+
export type TabsListProps = ComponentProps<typeof ArkTabs.List> & TabsListLook;
|
|
55
|
+
/** `segmented` sets the triggers on a track; `plain` lets each stand alone and wraps the row. */
|
|
56
|
+
export type TabsListAppearance = NonNullable<TabsListProps['appearance']>;
|
|
37
57
|
/**
|
|
38
58
|
* Container for the tab triggers. Renders with `role="tablist"`.
|
|
39
59
|
*
|
|
@@ -41,16 +61,24 @@ export interface TabsListProps extends ComponentProps<typeof ArkTabs.List> {
|
|
|
41
61
|
* more than one tablist — screen reader users otherwise get several
|
|
42
62
|
* indistinguishable "tab list" landmarks.
|
|
43
63
|
*
|
|
44
|
-
* When the triggers need more room than
|
|
45
|
-
* sideways inside its own box instead of widening the page. Focusing
|
|
46
|
-
* trigger, by Tab or by arrow key, brings it into view.
|
|
64
|
+
* When the triggers need more room than a segmented list has, the list
|
|
65
|
+
* scrolls sideways inside its own box instead of widening the page. Focusing
|
|
66
|
+
* a trigger, by Tab or by arrow key, brings it into view. A `plain` list
|
|
67
|
+
* wraps instead, so it neither scrolls nor needs the elements below.
|
|
68
|
+
*
|
|
69
|
+
* The two elements around a segmented list exist for the focus ring, which
|
|
70
|
+
* reaches past the list's edge. The scroller is that much larger than the
|
|
71
|
+
* list, so scrolling does not clip the ring; the frame keeps the scroller's
|
|
72
|
+
* extra size from widening whatever the tabs sit in. `tabs.css` has the
|
|
73
|
+
* arithmetic.
|
|
47
74
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
75
|
+
* Ark makes the selected trigger the list's one tab stop. While no tab is
|
|
76
|
+
* selected (a controlled `value` of `null`) it leaves none, so the list
|
|
77
|
+
* itself takes the stop and hands focus to its first enabled trigger, as the
|
|
78
|
+
* selected one would have had it; once focus is inside, the list steps out of
|
|
79
|
+
* the tab order again, so Tab and Shift+Tab leave the row in one press.
|
|
52
80
|
*/
|
|
53
|
-
export declare function TabsList({ fitted, className, children, ...props }: TabsListProps): import("react/jsx-runtime").JSX.Element;
|
|
81
|
+
export declare function TabsList({ fitted, appearance, className, children, onFocus, onBlur, ...props }: TabsListProps): import("react/jsx-runtime").JSX.Element;
|
|
54
82
|
export type TabsTriggerProps = ComponentProps<typeof ArkTabs.Trigger>;
|
|
55
83
|
/**
|
|
56
84
|
* A single tab. `value` must match the `value` of its {@link TabsContent}.
|
|
@@ -61,4 +89,5 @@ export declare function TabsTrigger({ className, children, ...props }: TabsTrigg
|
|
|
61
89
|
export type TabsContentProps = ComponentProps<typeof ArkTabs.Content>;
|
|
62
90
|
/** Panel for one tab. `value` must match its {@link TabsTrigger}. */
|
|
63
91
|
export declare function TabsContent({ className, children, ...props }: TabsContentProps): import("react/jsx-runtime").JSX.Element;
|
|
92
|
+
export {};
|
|
64
93
|
//# sourceMappingURL=tabs.d.ts.map
|
package/dist/tabs/tabs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/tabs/tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,OAAO,
|
|
1
|
+
{"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../src/tabs/tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,OAAO,EAAkB,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,KAAK,cAAc,EAA6B,MAAM,OAAO,CAAC;AACvE,OAAO,YAAY,CAAC;AAGpB,MAAM,MAAM,SAAS,GAAG,cAAc,CAAC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,IAAI,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,SAAS,2CAMhE;AAED;;;;GAIG;AACH,KAAK,YAAY,GACb;IACE;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GACD;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG,cAAc,CAAC,OAAO,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC;AAE/E,iGAAiG;AACjG,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,QAAQ,CAAC,EACvB,MAAc,EACd,UAAwB,EACxB,SAAS,EACT,QAAQ,EACR,OAAO,EACP,MAAM,EACN,GAAG,KAAK,EACT,EAAE,aAAa,2CAuCf;AAED,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtE;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,2CAM9E;AAED,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;AAEtE,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,gBAAgB,2CAM9E"}
|
package/dist/tabs/tabs.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Tabs as ArkTabs } from '@ark-ui/react/tabs';
|
|
2
|
+
import { Tabs as ArkTabs, useTabsContext } from '@ark-ui/react/tabs';
|
|
3
|
+
import { useState } from 'react';
|
|
3
4
|
import './tabs.css';
|
|
4
5
|
import { cx } from '../cx';
|
|
5
6
|
/**
|
|
@@ -36,17 +37,43 @@ export function Tabs({ className, children, ...props }) {
|
|
|
36
37
|
* more than one tablist — screen reader users otherwise get several
|
|
37
38
|
* indistinguishable "tab list" landmarks.
|
|
38
39
|
*
|
|
39
|
-
* When the triggers need more room than
|
|
40
|
-
* sideways inside its own box instead of widening the page. Focusing
|
|
41
|
-
* trigger, by Tab or by arrow key, brings it into view.
|
|
40
|
+
* When the triggers need more room than a segmented list has, the list
|
|
41
|
+
* scrolls sideways inside its own box instead of widening the page. Focusing
|
|
42
|
+
* a trigger, by Tab or by arrow key, brings it into view. A `plain` list
|
|
43
|
+
* wraps instead, so it neither scrolls nor needs the elements below.
|
|
42
44
|
*
|
|
43
|
-
* The two elements around
|
|
44
|
-
* past the list's edge. The scroller is that much larger than the
|
|
45
|
-
* scrolling does not clip the ring; the frame keeps the scroller's
|
|
46
|
-
* from widening whatever the tabs sit in. `tabs.css` has the
|
|
45
|
+
* The two elements around a segmented list exist for the focus ring, which
|
|
46
|
+
* reaches past the list's edge. The scroller is that much larger than the
|
|
47
|
+
* list, so scrolling does not clip the ring; the frame keeps the scroller's
|
|
48
|
+
* extra size from widening whatever the tabs sit in. `tabs.css` has the
|
|
49
|
+
* arithmetic.
|
|
50
|
+
*
|
|
51
|
+
* Ark makes the selected trigger the list's one tab stop. While no tab is
|
|
52
|
+
* selected (a controlled `value` of `null`) it leaves none, so the list
|
|
53
|
+
* itself takes the stop and hands focus to its first enabled trigger, as the
|
|
54
|
+
* selected one would have had it; once focus is inside, the list steps out of
|
|
55
|
+
* the tab order again, so Tab and Shift+Tab leave the row in one press.
|
|
47
56
|
*/
|
|
48
|
-
export function TabsList({ fitted = false, className, children, ...props }) {
|
|
49
|
-
|
|
57
|
+
export function TabsList({ fitted = false, appearance = 'segmented', className, children, onFocus, onBlur, ...props }) {
|
|
58
|
+
const { value } = useTabsContext();
|
|
59
|
+
const [focusWithin, setFocusWithin] = useState(false);
|
|
60
|
+
const tabIndex = value == null && !focusWithin ? 0 : undefined;
|
|
61
|
+
const handleFocus = (event) => {
|
|
62
|
+
onFocus?.(event);
|
|
63
|
+
setFocusWithin(true);
|
|
64
|
+
if (event.target !== event.currentTarget)
|
|
65
|
+
return;
|
|
66
|
+
event.currentTarget.querySelector('[role="tab"]:not([disabled])')?.focus();
|
|
67
|
+
};
|
|
68
|
+
const handleBlur = (event) => {
|
|
69
|
+
onBlur?.(event);
|
|
70
|
+
if (!event.currentTarget.contains(event.relatedTarget))
|
|
71
|
+
setFocusWithin(false);
|
|
72
|
+
};
|
|
73
|
+
const list = (_jsx(ArkTabs.List, { className: cx('ds-tabs__list', fitted && 'ds-tabs__list--fitted', appearance === 'plain' && 'ds-tabs__list--plain', className), tabIndex: tabIndex, onFocus: handleFocus, onBlur: handleBlur, ...props, children: children }));
|
|
74
|
+
if (appearance === 'plain')
|
|
75
|
+
return list;
|
|
76
|
+
return (_jsx("div", { className: "ds-tabs__frame", children: _jsx("div", { className: "ds-tabs__scroller", children: list }) }));
|
|
50
77
|
}
|
|
51
78
|
/**
|
|
52
79
|
* A single tab. `value` must match the `value` of its {@link TabsContent}.
|
package/dist/tabs/tabs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../src/tabs/tabs.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../src/tabs/tabs.tsx"],"names":[],"mappings":"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","sourcesContent":["import { Tabs as ArkTabs, useTabsContext } from '@ark-ui/react/tabs';\nimport { type ComponentProps, type FocusEvent, useState } from 'react';\nimport './tabs.css';\nimport { cx } from '../cx';\n\nexport type TabsProps = ComponentProps<typeof ArkTabs.Root>;\n\n/**\n * Tabbed disclosure built on Ark UI.\n *\n * Ark supplies the behaviour that is easy to get wrong by hand: roving\n * tabindex, arrow-key navigation, `aria-controls`/`aria-labelledby` wiring\n * between triggers and panels, and activation mode. This wrapper contributes\n * only `ds-` class names and the `--ds-tabs-*` token bindings.\n *\n * Use as a compound component:\n *\n * ```tsx\n * <Tabs defaultValue=\"weekly\">\n * <TabsList aria-label=\"Goal timeframe\">\n * <TabsTrigger value=\"weekly\">Weekly</TabsTrigger>\n * <TabsTrigger value=\"quarterly\">Quarterly</TabsTrigger>\n * </TabsList>\n * <TabsContent value=\"weekly\">…</TabsContent>\n * <TabsContent value=\"quarterly\">…</TabsContent>\n * </Tabs>\n * ```\n *\n * Pass `activationMode=\"manual\"` when panel content is expensive — arrow keys\n * then move focus without switching panels until Enter or Space.\n */\nexport function Tabs({ className, children, ...props }: TabsProps) {\n return (\n <ArkTabs.Root className={cx('ds-tabs', className)} {...props}>\n {children}\n </ArkTabs.Root>\n );\n}\n\n/**\n * `fitted` shares the width of one row, and a `plain` row wraps, so the two\n * cannot be combined: the pairing is a compile error rather than a\n * convention, as Badge's `BadgeLook` is.\n */\ntype TabsListLook =\n | {\n /**\n * `segmented` (default) sets the triggers on a track and scrolls them\n * sideways when they outgrow the list. `plain` drops the track and its\n * padding: every trigger takes the list's radius as its own shape, the\n * triggers sit `--ds-layout-gap` apart, and a row that outgrows the list\n * wraps onto a new line instead of scrolling. For triggers that carry\n * their own look, such as a row of avatars or category badges.\n */\n appearance?: 'segmented';\n /**\n * Distribute triggers evenly across the full width instead of sizing\n * them to their content. Matches the segmented-control look.\n */\n fitted?: boolean;\n }\n | { appearance: 'plain'; fitted?: never };\n\nexport type TabsListProps = ComponentProps<typeof ArkTabs.List> & TabsListLook;\n\n/** `segmented` sets the triggers on a track; `plain` lets each stand alone and wraps the row. */\nexport type TabsListAppearance = NonNullable<TabsListProps['appearance']>;\n\n/**\n * Container for the tab triggers. Renders with `role=\"tablist\"`.\n *\n * Always give this an `aria-label` (or `aria-labelledby`) when the page has\n * more than one tablist — screen reader users otherwise get several\n * indistinguishable \"tab list\" landmarks.\n *\n * When the triggers need more room than a segmented list has, the list\n * scrolls sideways inside its own box instead of widening the page. Focusing\n * a trigger, by Tab or by arrow key, brings it into view. A `plain` list\n * wraps instead, so it neither scrolls nor needs the elements below.\n *\n * The two elements around a segmented list exist for the focus ring, which\n * reaches past the list's edge. The scroller is that much larger than the\n * list, so scrolling does not clip the ring; the frame keeps the scroller's\n * extra size from widening whatever the tabs sit in. `tabs.css` has the\n * arithmetic.\n *\n * Ark makes the selected trigger the list's one tab stop. While no tab is\n * selected (a controlled `value` of `null`) it leaves none, so the list\n * itself takes the stop and hands focus to its first enabled trigger, as the\n * selected one would have had it; once focus is inside, the list steps out of\n * the tab order again, so Tab and Shift+Tab leave the row in one press.\n */\nexport function TabsList({\n fitted = false,\n appearance = 'segmented',\n className,\n children,\n onFocus,\n onBlur,\n ...props\n}: TabsListProps) {\n const { value } = useTabsContext();\n const [focusWithin, setFocusWithin] = useState(false);\n const tabIndex = value == null && !focusWithin ? 0 : undefined;\n\n const handleFocus = (event: FocusEvent<HTMLDivElement>) => {\n onFocus?.(event);\n setFocusWithin(true);\n if (event.target !== event.currentTarget) return;\n event.currentTarget.querySelector<HTMLElement>('[role=\"tab\"]:not([disabled])')?.focus();\n };\n const handleBlur = (event: FocusEvent<HTMLDivElement>) => {\n onBlur?.(event);\n if (!event.currentTarget.contains(event.relatedTarget)) setFocusWithin(false);\n };\n\n const list = (\n <ArkTabs.List\n className={cx(\n 'ds-tabs__list',\n fitted && 'ds-tabs__list--fitted',\n appearance === 'plain' && 'ds-tabs__list--plain',\n className,\n )}\n tabIndex={tabIndex}\n onFocus={handleFocus}\n onBlur={handleBlur}\n {...props}\n >\n {children}\n </ArkTabs.List>\n );\n\n if (appearance === 'plain') return list;\n return (\n <div className=\"ds-tabs__frame\">\n <div className=\"ds-tabs__scroller\">{list}</div>\n </div>\n );\n}\n\nexport type TabsTriggerProps = ComponentProps<typeof ArkTabs.Trigger>;\n\n/**\n * A single tab. `value` must match the `value` of its {@link TabsContent}.\n *\n * Disabled triggers are skipped by arrow-key navigation, which Ark handles.\n */\nexport function TabsTrigger({ className, children, ...props }: TabsTriggerProps) {\n return (\n <ArkTabs.Trigger className={cx('ds-tabs__trigger', className)} {...props}>\n {children}\n </ArkTabs.Trigger>\n );\n}\n\nexport type TabsContentProps = ComponentProps<typeof ArkTabs.Content>;\n\n/** Panel for one tab. `value` must match its {@link TabsTrigger}. */\nexport function TabsContent({ className, children, ...props }: TabsContentProps) {\n return (\n <ArkTabs.Content className={cx('ds-tabs__content', className)} {...props}>\n {children}\n </ArkTabs.Content>\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@manakind/ui-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -412,7 +412,7 @@
|
|
|
412
412
|
},
|
|
413
413
|
"devDependencies": {
|
|
414
414
|
"@manakind/ds-config": "*",
|
|
415
|
-
"@manakind/manuia-tokens": "0.
|
|
415
|
+
"@manakind/manuia-tokens": "0.34.0",
|
|
416
416
|
"@testing-library/jest-dom": "^6.9.1",
|
|
417
417
|
"@testing-library/react": "^16.3.2",
|
|
418
418
|
"@testing-library/user-event": "^14.6.1",
|