@harborclient/sdk 0.6.6 → 0.6.7
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/components/SegmentedTabs/SegmentedTabPanel.d.ts +21 -0
- package/dist/components/SegmentedTabs/SegmentedTabPanel.d.ts.map +1 -0
- package/dist/components/SegmentedTabs/SegmentedTabPanel.js +15 -0
- package/dist/components/SegmentedTabs/SegmentedTabsContext.d.ts +24 -0
- package/dist/components/SegmentedTabs/SegmentedTabsContext.d.ts.map +1 -0
- package/dist/components/SegmentedTabs/SegmentedTabsContext.js +2 -0
- package/dist/components/SegmentedTabs/SegmentedTabsGroup.d.ts +28 -0
- package/dist/components/SegmentedTabs/SegmentedTabsGroup.d.ts.map +1 -0
- package/dist/components/SegmentedTabs/SegmentedTabsGroup.js +21 -0
- package/dist/components/SegmentedTabs/index.d.ts +5 -67
- package/dist/components/SegmentedTabs/index.d.ts.map +1 -1
- package/dist/components/SegmentedTabs/index.js +4 -33
- package/dist/components/SegmentedTabs/types.d.ts +24 -0
- package/dist/components/SegmentedTabs/types.d.ts.map +1 -0
- package/dist/components/SegmentedTabs/types.js +1 -0
- package/dist/components/classes.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from 'react';
|
|
2
|
+
interface Props<T extends string> {
|
|
3
|
+
/**
|
|
4
|
+
* Tab value that controls visibility of this panel.
|
|
5
|
+
*/
|
|
6
|
+
value: T;
|
|
7
|
+
/**
|
|
8
|
+
* Panel content shown when this tab is selected.
|
|
9
|
+
*/
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Additional CSS classes for the panel container.
|
|
13
|
+
*/
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Renders a WAI-ARIA tab panel linked to the matching tab in the parent group.
|
|
18
|
+
*/
|
|
19
|
+
export declare function SegmentedTabPanel<T extends string>({ value, children, className }: Props<T>): JSX.Element | null;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=SegmentedTabPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedTabPanel.d.ts","sourceRoot":"","sources":["../../../src/components/SegmentedTabs/SegmentedTabPanel.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAG5C,UAAU,KAAK,CAAC,CAAC,SAAS,MAAM;IAC9B;;OAEG;IACH,KAAK,EAAE,CAAC,CAAC;IAET;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;IAEpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,EAClD,KAAK,EACL,QAAQ,EACR,SAAS,EACV,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,GAAG,IAAI,CAkB/B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "@harborclient/sdk/jsx-runtime";
|
|
2
|
+
import { useContext } from '@harborclient/sdk/react';
|
|
3
|
+
import { SegmentedTabsContext } from './SegmentedTabsContext.js';
|
|
4
|
+
/**
|
|
5
|
+
* Renders a WAI-ARIA tab panel linked to the matching tab in the parent group.
|
|
6
|
+
*/
|
|
7
|
+
export function SegmentedTabPanel({ value, children, className }) {
|
|
8
|
+
const context = useContext(SegmentedTabsContext);
|
|
9
|
+
if (!context) {
|
|
10
|
+
throw new Error('SegmentedTabPanel must be used within SegmentedTabsGroup');
|
|
11
|
+
}
|
|
12
|
+
if (context.value !== value)
|
|
13
|
+
return null;
|
|
14
|
+
return (_jsx("div", { role: "tabpanel", id: context.getPanelId(value), "aria-labelledby": context.getTabId(value), className: className, children: children }));
|
|
15
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface SegmentedTabsContextValue {
|
|
2
|
+
/**
|
|
3
|
+
* Currently selected tab value.
|
|
4
|
+
*/
|
|
5
|
+
value: string;
|
|
6
|
+
/**
|
|
7
|
+
* Selects a tab by value.
|
|
8
|
+
*/
|
|
9
|
+
onChange: (value: string) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Accessible name for the tab list.
|
|
12
|
+
*/
|
|
13
|
+
ariaLabel: string;
|
|
14
|
+
/**
|
|
15
|
+
* Stable DOM id for a tab control.
|
|
16
|
+
*/
|
|
17
|
+
getTabId: (value: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Stable DOM id for a tab panel linked to a tab.
|
|
20
|
+
*/
|
|
21
|
+
getPanelId: (value: string) => string;
|
|
22
|
+
}
|
|
23
|
+
export declare const SegmentedTabsContext: import("react").Context<SegmentedTabsContextValue | null>;
|
|
24
|
+
//# sourceMappingURL=SegmentedTabsContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedTabsContext.d.ts","sourceRoot":"","sources":["../../../src/components/SegmentedTabs/SegmentedTabsContext.tsx"],"names":[],"mappings":"AAEA,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAElC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAEpC;;OAEG;IACH,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;CACvC;AAED,eAAO,MAAM,oBAAoB,2DAAwD,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { JSX, ReactNode } from 'react';
|
|
2
|
+
interface Props<T extends string> {
|
|
3
|
+
/**
|
|
4
|
+
* Currently selected tab value.
|
|
5
|
+
*/
|
|
6
|
+
value: T;
|
|
7
|
+
/**
|
|
8
|
+
* Called when the user selects a different tab.
|
|
9
|
+
*
|
|
10
|
+
* @param value - Newly selected tab value.
|
|
11
|
+
*/
|
|
12
|
+
onChange: (value: T) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Accessible name for the tab list.
|
|
15
|
+
*/
|
|
16
|
+
ariaLabel: string;
|
|
17
|
+
/**
|
|
18
|
+
* Tab list and linked tab panels.
|
|
19
|
+
*/
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Provides tab selection state and stable ids for `SegmentedTabs` and
|
|
24
|
+
* `SegmentedTabPanel` children.
|
|
25
|
+
*/
|
|
26
|
+
export declare function SegmentedTabsGroup<T extends string>({ value, onChange, ariaLabel, children }: Props<T>): JSX.Element;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=SegmentedTabsGroup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SegmentedTabsGroup.d.ts","sourceRoot":"","sources":["../../../src/components/SegmentedTabs/SegmentedTabsGroup.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAG5C,UAAU,KAAK,CAAC,CAAC,SAAS,MAAM;IAC9B;;OAEG;IACH,KAAK,EAAE,CAAC,CAAC;IAET;;;;OAIG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAE7B;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,EACnD,KAAK,EACL,QAAQ,EACR,SAAS,EACT,QAAQ,EACT,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,CAmBxB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createElement, useId, useMemo } from '@harborclient/sdk/react';
|
|
2
|
+
import { SegmentedTabsContext } from './SegmentedTabsContext.js';
|
|
3
|
+
/**
|
|
4
|
+
* Provides tab selection state and stable ids for `SegmentedTabs` and
|
|
5
|
+
* `SegmentedTabPanel` children.
|
|
6
|
+
*/
|
|
7
|
+
export function SegmentedTabsGroup({ value, onChange, ariaLabel, children }) {
|
|
8
|
+
const baseId = useId();
|
|
9
|
+
/**
|
|
10
|
+
* Memoizes context so tab ids stay stable across renders while value updates
|
|
11
|
+
* propagate to list and panel children.
|
|
12
|
+
*/
|
|
13
|
+
const contextValue = useMemo(() => ({
|
|
14
|
+
value,
|
|
15
|
+
onChange: (nextValue) => onChange(nextValue),
|
|
16
|
+
ariaLabel,
|
|
17
|
+
getTabId: (tabValue) => `${baseId}-tab-${tabValue}`,
|
|
18
|
+
getPanelId: (tabValue) => `${baseId}-panel-${tabValue}`
|
|
19
|
+
}), [value, onChange, ariaLabel, baseId]);
|
|
20
|
+
return createElement(SegmentedTabsContext.Provider, { value: contextValue }, children);
|
|
21
|
+
}
|
|
@@ -1,69 +1,8 @@
|
|
|
1
|
-
import type { JSX
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
value: T;
|
|
7
|
-
/**
|
|
8
|
-
* Tab label or custom content.
|
|
9
|
-
*/
|
|
10
|
-
label: ReactNode;
|
|
11
|
-
/**
|
|
12
|
-
* When true, the tab is not rendered.
|
|
13
|
-
*/
|
|
14
|
-
hidden?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* When true, the tab button is disabled.
|
|
17
|
-
*/
|
|
18
|
-
disabled?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* When true, renders a small dot indicating the tab has values set.
|
|
21
|
-
*/
|
|
22
|
-
indicator?: boolean;
|
|
23
|
-
}
|
|
24
|
-
interface GroupProps<T extends string> {
|
|
25
|
-
/**
|
|
26
|
-
* Currently selected tab value.
|
|
27
|
-
*/
|
|
28
|
-
value: T;
|
|
29
|
-
/**
|
|
30
|
-
* Called when the user selects a different tab.
|
|
31
|
-
*
|
|
32
|
-
* @param value - Newly selected tab value.
|
|
33
|
-
*/
|
|
34
|
-
onChange: (value: T) => void;
|
|
35
|
-
/**
|
|
36
|
-
* Accessible name for the tab list.
|
|
37
|
-
*/
|
|
38
|
-
ariaLabel: string;
|
|
39
|
-
/**
|
|
40
|
-
* Tab list and linked tab panels.
|
|
41
|
-
*/
|
|
42
|
-
children: ReactNode;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Provides tab selection state and stable ids for `SegmentedTabs` and
|
|
46
|
-
* `SegmentedTabPanel` children.
|
|
47
|
-
*/
|
|
48
|
-
export declare function SegmentedTabsGroup<T extends string>({ value, onChange, ariaLabel, children }: GroupProps<T>): JSX.Element;
|
|
49
|
-
interface PanelProps<T extends string> {
|
|
50
|
-
/**
|
|
51
|
-
* Tab value that controls visibility of this panel.
|
|
52
|
-
*/
|
|
53
|
-
value: T;
|
|
54
|
-
/**
|
|
55
|
-
* Panel content shown when this tab is selected.
|
|
56
|
-
*/
|
|
57
|
-
children: ReactNode;
|
|
58
|
-
/**
|
|
59
|
-
* Additional CSS classes for the panel container.
|
|
60
|
-
*/
|
|
61
|
-
className?: string;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Renders a WAI-ARIA tab panel linked to the matching tab in the parent group.
|
|
65
|
-
*/
|
|
66
|
-
export declare function SegmentedTabPanel<T extends string>({ value, children, className }: PanelProps<T>): JSX.Element | null;
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import type { TabItem } from './types.js';
|
|
3
|
+
export { SegmentedTabsGroup } from './SegmentedTabsGroup.js';
|
|
4
|
+
export { SegmentedTabPanel } from './SegmentedTabPanel.js';
|
|
5
|
+
export type { TabItem } from './types.js';
|
|
67
6
|
interface Props<T extends string> {
|
|
68
7
|
/**
|
|
69
8
|
* Tab definitions to render.
|
|
@@ -103,5 +42,4 @@ interface Props<T extends string> {
|
|
|
103
42
|
* macOS-style segmented tab control with WAI-ARIA tabs or radiogroup semantics.
|
|
104
43
|
*/
|
|
105
44
|
export declare function SegmentedTabs<T extends string>({ tabs, value: valueProp, onChange: onChangeProp, fullWidth, className, pattern, ariaLabel: ariaLabelProp }: Props<T>): JSX.Element;
|
|
106
|
-
export {};
|
|
107
45
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SegmentedTabs/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SegmentedTabs/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAiB,MAAM,OAAO,CAAC;AAIhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,UAAU,KAAK,CAAC,CAAC,SAAS,MAAM;IAC9B;;OAEG;IACH,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAEnB;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,CAAC;IAEV;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAE9B;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,YAAY,CAAC;IAEhC;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,EAC9C,IAAI,EACJ,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,YAAY,EACtB,SAAiB,EACjB,SAAS,EACT,OAAgB,EAChB,SAAS,EAAE,aAAa,EACzB,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,CA+GxB"}
|
|
@@ -1,39 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@harborclient/sdk/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useCallback, useContext, useId, useMemo, useRef } from '@harborclient/sdk/react';
|
|
3
3
|
import { resolveTabListKeyAction } from '../utils.js';
|
|
4
4
|
import { segment, segmentGroup } from '../classes.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* `SegmentedTabPanel` children.
|
|
9
|
-
*/
|
|
10
|
-
export function SegmentedTabsGroup({ value, onChange, ariaLabel, children }) {
|
|
11
|
-
const baseId = useId();
|
|
12
|
-
/**
|
|
13
|
-
* Memoizes context so tab ids stay stable across renders while value updates
|
|
14
|
-
* propagate to list and panel children.
|
|
15
|
-
*/
|
|
16
|
-
const contextValue = useMemo(() => ({
|
|
17
|
-
value,
|
|
18
|
-
onChange: (nextValue) => onChange(nextValue),
|
|
19
|
-
ariaLabel,
|
|
20
|
-
getTabId: (tabValue) => `${baseId}-tab-${tabValue}`,
|
|
21
|
-
getPanelId: (tabValue) => `${baseId}-panel-${tabValue}`
|
|
22
|
-
}), [value, onChange, ariaLabel, baseId]);
|
|
23
|
-
return createElement(SegmentedTabsContext.Provider, { value: contextValue }, children);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Renders a WAI-ARIA tab panel linked to the matching tab in the parent group.
|
|
27
|
-
*/
|
|
28
|
-
export function SegmentedTabPanel({ value, children, className }) {
|
|
29
|
-
const context = useContext(SegmentedTabsContext);
|
|
30
|
-
if (!context) {
|
|
31
|
-
throw new Error('SegmentedTabPanel must be used within SegmentedTabsGroup');
|
|
32
|
-
}
|
|
33
|
-
if (context.value !== value)
|
|
34
|
-
return null;
|
|
35
|
-
return (_jsx("div", { role: "tabpanel", id: context.getPanelId(value), "aria-labelledby": context.getTabId(value), className: className, children: children }));
|
|
36
|
-
}
|
|
5
|
+
import { SegmentedTabsContext } from './SegmentedTabsContext.js';
|
|
6
|
+
export { SegmentedTabsGroup } from './SegmentedTabsGroup.js';
|
|
7
|
+
export { SegmentedTabPanel } from './SegmentedTabPanel.js';
|
|
37
8
|
/**
|
|
38
9
|
* macOS-style segmented tab control with WAI-ARIA tabs or radiogroup semantics.
|
|
39
10
|
*/
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export interface TabItem<T extends string> {
|
|
3
|
+
/**
|
|
4
|
+
* Unique tab identifier.
|
|
5
|
+
*/
|
|
6
|
+
value: T;
|
|
7
|
+
/**
|
|
8
|
+
* Tab label or custom content.
|
|
9
|
+
*/
|
|
10
|
+
label: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* When true, the tab is not rendered.
|
|
13
|
+
*/
|
|
14
|
+
hidden?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* When true, the tab button is disabled.
|
|
17
|
+
*/
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* When true, renders a small dot indicating the tab has values set.
|
|
21
|
+
*/
|
|
22
|
+
indicator?: boolean;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/SegmentedTabs/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,OAAO,CAAC,CAAC,SAAS,MAAM;IACvC;;OAEG;IACH,KAAK,EAAE,CAAC,CAAC;IAET;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;IAEjB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -9,6 +9,6 @@ export const segmentGroup = 'inline-flex p-3 border-b border-separator w-full sh
|
|
|
9
9
|
*/
|
|
10
10
|
export function segment(active) {
|
|
11
11
|
return active
|
|
12
|
-
? 'cursor-pointer rounded-[2.5px] border-none bg-
|
|
12
|
+
? 'cursor-pointer rounded-[2.5px] border-none bg-field px-3 py-1 text-[15px] text-text shadow-sm app-no-drag'
|
|
13
13
|
: 'cursor-pointer rounded-[2.5px] border-none bg-transparent px-3 py-1 text-[15px] text-muted hover:text-text app-no-drag';
|
|
14
14
|
}
|