@zag-js/tabs 0.82.2 → 1.0.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.d.mts +48 -26
- package/dist/index.d.ts +48 -26
- package/dist/index.js +340 -337
- package/dist/index.mjs +343 -340
- package/package.json +15 -10
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
-
import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, NormalizeProps } from '@zag-js/types';
|
|
3
2
|
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
-
import { Machine,
|
|
3
|
+
import { Service, Machine, EventObject } from '@zag-js/core';
|
|
4
|
+
import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
|
|
5
5
|
|
|
6
6
|
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "list" | "trigger" | "content" | "indicator">;
|
|
7
7
|
|
|
@@ -25,7 +25,7 @@ type ElementIds = Partial<{
|
|
|
25
25
|
content: string;
|
|
26
26
|
indicator: string;
|
|
27
27
|
}>;
|
|
28
|
-
interface
|
|
28
|
+
interface TabsProps extends DirectionProperty, CommonProperties {
|
|
29
29
|
/**
|
|
30
30
|
* The ids of the elements in the tabs. Useful for composition.
|
|
31
31
|
*/
|
|
@@ -38,11 +38,16 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
38
38
|
* Whether the keyboard navigation will loop from last tab to first, and vice versa.
|
|
39
39
|
* @default true
|
|
40
40
|
*/
|
|
41
|
-
loopFocus
|
|
41
|
+
loopFocus?: boolean | undefined;
|
|
42
42
|
/**
|
|
43
|
-
* The selected tab
|
|
43
|
+
* The controlled selected tab value
|
|
44
44
|
*/
|
|
45
|
-
value
|
|
45
|
+
value?: string | null | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* The initial selected tab value when rendered.
|
|
48
|
+
* Use when you don't need to control the selected tab value.
|
|
49
|
+
*/
|
|
50
|
+
defaultValue?: string | null | undefined;
|
|
46
51
|
/**
|
|
47
52
|
* The orientation of the tabs. Can be `horizontal` or `vertical`
|
|
48
53
|
* - `horizontal`: only left and right arrow key navigation will work.
|
|
@@ -70,7 +75,7 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
70
75
|
/**
|
|
71
76
|
* Whether the tab is composite
|
|
72
77
|
*/
|
|
73
|
-
composite
|
|
78
|
+
composite?: boolean | undefined;
|
|
74
79
|
/**
|
|
75
80
|
* Whether the active tab can be deselected when clicking on it.
|
|
76
81
|
*/
|
|
@@ -79,20 +84,37 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
79
84
|
* Function to navigate to the selected tab when clicking on it.
|
|
80
85
|
* Useful if tab triggers are anchor elements.
|
|
81
86
|
*/
|
|
82
|
-
navigate
|
|
83
|
-
}
|
|
84
|
-
type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
85
|
-
type ComputedContext = Readonly<{}>;
|
|
86
|
-
interface PrivateContext {
|
|
87
|
-
}
|
|
88
|
-
interface MachineContext extends PublicContext, ComputedContext, PrivateContext {
|
|
89
|
-
}
|
|
90
|
-
interface MachineState {
|
|
91
|
-
value: "idle" | "focused";
|
|
87
|
+
navigate?: ((details: NavigateDetails) => void) | undefined;
|
|
92
88
|
}
|
|
93
|
-
type
|
|
94
|
-
type
|
|
95
|
-
|
|
89
|
+
type PropsWithDefault = "orientation" | "activationMode" | "loopFocus";
|
|
90
|
+
type TabsSchema = {
|
|
91
|
+
state: "idle" | "focused";
|
|
92
|
+
props: RequiredBy<TabsProps, PropsWithDefault>;
|
|
93
|
+
context: {
|
|
94
|
+
ssr: boolean;
|
|
95
|
+
value: string | null;
|
|
96
|
+
focusedValue: string | null;
|
|
97
|
+
indicatorTransition: boolean;
|
|
98
|
+
indicatorRect: {
|
|
99
|
+
left: string;
|
|
100
|
+
top: string;
|
|
101
|
+
width: string;
|
|
102
|
+
height: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
refs: {
|
|
106
|
+
indicatorCleanup: VoidFunction | null | undefined;
|
|
107
|
+
};
|
|
108
|
+
computed: {
|
|
109
|
+
focused: boolean;
|
|
110
|
+
};
|
|
111
|
+
action: string;
|
|
112
|
+
guard: string;
|
|
113
|
+
effect: string;
|
|
114
|
+
event: EventObject;
|
|
115
|
+
};
|
|
116
|
+
type TabsService = Service<TabsSchema>;
|
|
117
|
+
type TabsMachine = Machine<TabsSchema>;
|
|
96
118
|
interface TriggerProps {
|
|
97
119
|
/**
|
|
98
120
|
* The value of the tab
|
|
@@ -123,7 +145,7 @@ interface ContentProps {
|
|
|
123
145
|
*/
|
|
124
146
|
value: string;
|
|
125
147
|
}
|
|
126
|
-
interface
|
|
148
|
+
interface TabsApi<T extends PropTypes = PropTypes> {
|
|
127
149
|
/**
|
|
128
150
|
* The current value of the tabs.
|
|
129
151
|
*/
|
|
@@ -172,15 +194,15 @@ interface MachineApi<T extends PropTypes = PropTypes> {
|
|
|
172
194
|
getIndicatorProps(): T["element"];
|
|
173
195
|
}
|
|
174
196
|
|
|
175
|
-
declare function connect<T extends PropTypes>(
|
|
197
|
+
declare function connect<T extends PropTypes>(service: Service<TabsSchema>, normalize: NormalizeProps<T>): TabsApi<T>;
|
|
176
198
|
|
|
177
|
-
declare
|
|
199
|
+
declare const machine: _zag_js_core.Machine<TabsSchema>;
|
|
178
200
|
|
|
179
|
-
declare const props: (
|
|
180
|
-
declare const splitProps: <Props extends Partial<
|
|
201
|
+
declare const props: (keyof TabsProps)[];
|
|
202
|
+
declare const splitProps: <Props extends Partial<TabsProps>>(props: Props) => [Partial<TabsProps>, Omit<Props, keyof TabsProps>];
|
|
181
203
|
declare const triggerProps: (keyof TriggerProps)[];
|
|
182
204
|
declare const splitTriggerProps: <Props extends TriggerProps>(props: Props) => [TriggerProps, Omit<Props, keyof TriggerProps>];
|
|
183
205
|
declare const contentProps: "value"[];
|
|
184
206
|
declare const splitContentProps: <Props extends ContentProps>(props: Props) => [ContentProps, Omit<Props, "value">];
|
|
185
207
|
|
|
186
|
-
export { type
|
|
208
|
+
export { type TabsApi as Api, type ContentProps, type ElementIds, type FocusChangeDetails, type IntlTranslations, type TabsMachine as Machine, type NavigateDetails, type TabsProps as Props, type TabsService as Service, type TriggerProps, type ValueChangeDetails, anatomy, connect, contentProps, machine, props, splitContentProps, splitProps, splitTriggerProps, triggerProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _zag_js_anatomy from '@zag-js/anatomy';
|
|
2
|
-
import { RequiredBy, PropTypes, DirectionProperty, CommonProperties, NormalizeProps } from '@zag-js/types';
|
|
3
2
|
import * as _zag_js_core from '@zag-js/core';
|
|
4
|
-
import { Machine,
|
|
3
|
+
import { Service, Machine, EventObject } from '@zag-js/core';
|
|
4
|
+
import { DirectionProperty, CommonProperties, PropTypes, RequiredBy, NormalizeProps } from '@zag-js/types';
|
|
5
5
|
|
|
6
6
|
declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "list" | "trigger" | "content" | "indicator">;
|
|
7
7
|
|
|
@@ -25,7 +25,7 @@ type ElementIds = Partial<{
|
|
|
25
25
|
content: string;
|
|
26
26
|
indicator: string;
|
|
27
27
|
}>;
|
|
28
|
-
interface
|
|
28
|
+
interface TabsProps extends DirectionProperty, CommonProperties {
|
|
29
29
|
/**
|
|
30
30
|
* The ids of the elements in the tabs. Useful for composition.
|
|
31
31
|
*/
|
|
@@ -38,11 +38,16 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
38
38
|
* Whether the keyboard navigation will loop from last tab to first, and vice versa.
|
|
39
39
|
* @default true
|
|
40
40
|
*/
|
|
41
|
-
loopFocus
|
|
41
|
+
loopFocus?: boolean | undefined;
|
|
42
42
|
/**
|
|
43
|
-
* The selected tab
|
|
43
|
+
* The controlled selected tab value
|
|
44
44
|
*/
|
|
45
|
-
value
|
|
45
|
+
value?: string | null | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* The initial selected tab value when rendered.
|
|
48
|
+
* Use when you don't need to control the selected tab value.
|
|
49
|
+
*/
|
|
50
|
+
defaultValue?: string | null | undefined;
|
|
46
51
|
/**
|
|
47
52
|
* The orientation of the tabs. Can be `horizontal` or `vertical`
|
|
48
53
|
* - `horizontal`: only left and right arrow key navigation will work.
|
|
@@ -70,7 +75,7 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
70
75
|
/**
|
|
71
76
|
* Whether the tab is composite
|
|
72
77
|
*/
|
|
73
|
-
composite
|
|
78
|
+
composite?: boolean | undefined;
|
|
74
79
|
/**
|
|
75
80
|
* Whether the active tab can be deselected when clicking on it.
|
|
76
81
|
*/
|
|
@@ -79,20 +84,37 @@ interface PublicContext extends DirectionProperty, CommonProperties {
|
|
|
79
84
|
* Function to navigate to the selected tab when clicking on it.
|
|
80
85
|
* Useful if tab triggers are anchor elements.
|
|
81
86
|
*/
|
|
82
|
-
navigate
|
|
83
|
-
}
|
|
84
|
-
type UserDefinedContext = RequiredBy<PublicContext, "id">;
|
|
85
|
-
type ComputedContext = Readonly<{}>;
|
|
86
|
-
interface PrivateContext {
|
|
87
|
-
}
|
|
88
|
-
interface MachineContext extends PublicContext, ComputedContext, PrivateContext {
|
|
89
|
-
}
|
|
90
|
-
interface MachineState {
|
|
91
|
-
value: "idle" | "focused";
|
|
87
|
+
navigate?: ((details: NavigateDetails) => void) | undefined;
|
|
92
88
|
}
|
|
93
|
-
type
|
|
94
|
-
type
|
|
95
|
-
|
|
89
|
+
type PropsWithDefault = "orientation" | "activationMode" | "loopFocus";
|
|
90
|
+
type TabsSchema = {
|
|
91
|
+
state: "idle" | "focused";
|
|
92
|
+
props: RequiredBy<TabsProps, PropsWithDefault>;
|
|
93
|
+
context: {
|
|
94
|
+
ssr: boolean;
|
|
95
|
+
value: string | null;
|
|
96
|
+
focusedValue: string | null;
|
|
97
|
+
indicatorTransition: boolean;
|
|
98
|
+
indicatorRect: {
|
|
99
|
+
left: string;
|
|
100
|
+
top: string;
|
|
101
|
+
width: string;
|
|
102
|
+
height: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
refs: {
|
|
106
|
+
indicatorCleanup: VoidFunction | null | undefined;
|
|
107
|
+
};
|
|
108
|
+
computed: {
|
|
109
|
+
focused: boolean;
|
|
110
|
+
};
|
|
111
|
+
action: string;
|
|
112
|
+
guard: string;
|
|
113
|
+
effect: string;
|
|
114
|
+
event: EventObject;
|
|
115
|
+
};
|
|
116
|
+
type TabsService = Service<TabsSchema>;
|
|
117
|
+
type TabsMachine = Machine<TabsSchema>;
|
|
96
118
|
interface TriggerProps {
|
|
97
119
|
/**
|
|
98
120
|
* The value of the tab
|
|
@@ -123,7 +145,7 @@ interface ContentProps {
|
|
|
123
145
|
*/
|
|
124
146
|
value: string;
|
|
125
147
|
}
|
|
126
|
-
interface
|
|
148
|
+
interface TabsApi<T extends PropTypes = PropTypes> {
|
|
127
149
|
/**
|
|
128
150
|
* The current value of the tabs.
|
|
129
151
|
*/
|
|
@@ -172,15 +194,15 @@ interface MachineApi<T extends PropTypes = PropTypes> {
|
|
|
172
194
|
getIndicatorProps(): T["element"];
|
|
173
195
|
}
|
|
174
196
|
|
|
175
|
-
declare function connect<T extends PropTypes>(
|
|
197
|
+
declare function connect<T extends PropTypes>(service: Service<TabsSchema>, normalize: NormalizeProps<T>): TabsApi<T>;
|
|
176
198
|
|
|
177
|
-
declare
|
|
199
|
+
declare const machine: _zag_js_core.Machine<TabsSchema>;
|
|
178
200
|
|
|
179
|
-
declare const props: (
|
|
180
|
-
declare const splitProps: <Props extends Partial<
|
|
201
|
+
declare const props: (keyof TabsProps)[];
|
|
202
|
+
declare const splitProps: <Props extends Partial<TabsProps>>(props: Props) => [Partial<TabsProps>, Omit<Props, keyof TabsProps>];
|
|
181
203
|
declare const triggerProps: (keyof TriggerProps)[];
|
|
182
204
|
declare const splitTriggerProps: <Props extends TriggerProps>(props: Props) => [TriggerProps, Omit<Props, keyof TriggerProps>];
|
|
183
205
|
declare const contentProps: "value"[];
|
|
184
206
|
declare const splitContentProps: <Props extends ContentProps>(props: Props) => [ContentProps, Omit<Props, "value">];
|
|
185
207
|
|
|
186
|
-
export { type
|
|
208
|
+
export { type TabsApi as Api, type ContentProps, type ElementIds, type FocusChangeDetails, type IntlTranslations, type TabsMachine as Machine, type NavigateDetails, type TabsProps as Props, type TabsService as Service, type TriggerProps, type ValueChangeDetails, anatomy, connect, contentProps, machine, props, splitContentProps, splitProps, splitTriggerProps, triggerProps };
|