@zag-js/tabs 1.34.1 → 1.35.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/index.d.mts CHANGED
@@ -1,203 +1,8 @@
1
- import * as _zag_js_anatomy from '@zag-js/anatomy';
2
- import * as _zag_js_core from '@zag-js/core';
3
- import { Machine, EventObject, Service } from '@zag-js/core';
4
- import { PropTypes, RequiredBy, DirectionProperty, CommonProperties, Rect, NormalizeProps } from '@zag-js/types';
5
-
6
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "list" | "trigger" | "content" | "indicator">;
7
-
8
- interface ValueChangeDetails {
9
- value: string;
10
- }
11
- interface FocusChangeDetails {
12
- focusedValue: string;
13
- }
14
- interface NavigateDetails {
15
- value: string;
16
- node: HTMLAnchorElement;
17
- href: string;
18
- }
19
- interface IntlTranslations {
20
- listLabel?: string | undefined;
21
- }
22
- type ElementIds = Partial<{
23
- root: string;
24
- trigger: (value: string) => string;
25
- list: string;
26
- content: (value: string) => string;
27
- indicator: string;
28
- }>;
29
- interface TabsProps extends DirectionProperty, CommonProperties {
30
- /**
31
- * The ids of the elements in the tabs. Useful for composition.
32
- */
33
- ids?: ElementIds | undefined;
34
- /**
35
- * Specifies the localized strings that identifies the accessibility elements and their states
36
- */
37
- translations?: IntlTranslations | undefined;
38
- /**
39
- * Whether the keyboard navigation will loop from last tab to first, and vice versa.
40
- * @default true
41
- */
42
- loopFocus?: boolean | undefined;
43
- /**
44
- * The controlled selected tab value
45
- */
46
- value?: string | null | undefined;
47
- /**
48
- * The initial selected tab value when rendered.
49
- * Use when you don't need to control the selected tab value.
50
- */
51
- defaultValue?: string | null | undefined;
52
- /**
53
- * The orientation of the tabs. Can be `horizontal` or `vertical`
54
- * - `horizontal`: only left and right arrow key navigation will work.
55
- * - `vertical`: only up and down arrow key navigation will work.
56
- *
57
- * @default "horizontal"
58
- */
59
- orientation?: "horizontal" | "vertical" | undefined;
60
- /**
61
- * The activation mode of the tabs. Can be `manual` or `automatic`
62
- * - `manual`: Tabs are activated when clicked or press `enter` key.
63
- * - `automatic`: Tabs are activated when receiving focus
64
- *
65
- * @default "automatic"
66
- */
67
- activationMode?: "manual" | "automatic" | undefined;
68
- /**
69
- * Callback to be called when the selected/active tab changes
70
- */
71
- onValueChange?: ((details: ValueChangeDetails) => void) | undefined;
72
- /**
73
- * Callback to be called when the focused tab changes
74
- */
75
- onFocusChange?: ((details: FocusChangeDetails) => void) | undefined;
76
- /**
77
- * Whether the tab is composite
78
- */
79
- composite?: boolean | undefined;
80
- /**
81
- * Whether the active tab can be deselected when clicking on it.
82
- */
83
- deselectable?: boolean | undefined;
84
- /**
85
- * Function to navigate to the selected tab when clicking on it.
86
- * Useful if tab triggers are anchor elements.
87
- */
88
- navigate?: ((details: NavigateDetails) => void) | null | undefined;
89
- }
90
- type PropsWithDefault = "orientation" | "activationMode" | "loopFocus";
91
- type TabsSchema = {
92
- state: "idle" | "focused";
93
- props: RequiredBy<TabsProps, PropsWithDefault>;
94
- context: {
95
- ssr: boolean;
96
- value: string | null;
97
- focusedValue: string | null;
98
- indicatorRect: Rect | null;
99
- };
100
- refs: {
101
- indicatorCleanup: VoidFunction | null | undefined;
102
- };
103
- computed: {
104
- focused: boolean;
105
- };
106
- action: string;
107
- guard: string;
108
- effect: string;
109
- event: EventObject;
110
- };
111
- type TabsService = Service<TabsSchema>;
112
- type TabsMachine = Machine<TabsSchema>;
113
- interface TriggerProps {
114
- /**
115
- * The value of the tab
116
- */
117
- value: string;
118
- /**
119
- * Whether the tab is disabled
120
- */
121
- disabled?: boolean | undefined;
122
- }
123
- interface TriggerState {
124
- /**
125
- * Whether the tab is selected
126
- */
127
- selected: boolean;
128
- /**
129
- * Whether the tab is focused
130
- */
131
- focused: boolean;
132
- /**
133
- * Whether the tab is disabled
134
- */
135
- disabled: boolean;
136
- }
137
- interface ContentProps {
138
- /**
139
- * The value of the tab
140
- */
141
- value: string;
142
- }
143
- interface TabsApi<T extends PropTypes = PropTypes> {
144
- /**
145
- * The current value of the tabs.
146
- */
147
- value: string | null;
148
- /**
149
- * The value of the tab that is currently focused.
150
- */
151
- focusedValue: string | null;
152
- /**
153
- * Sets the value of the tabs.
154
- */
155
- setValue: (value: string) => void;
156
- /**
157
- * Clears the value of the tabs.
158
- */
159
- clearValue: VoidFunction;
160
- /**
161
- * Sets the indicator rect to the tab with the given value
162
- */
163
- setIndicatorRect: (value: string) => void;
164
- /**
165
- * Synchronizes the tab index of the content element.
166
- * Useful when rendering tabs within a select or combobox
167
- */
168
- syncTabIndex: VoidFunction;
169
- /**
170
- * Set focus on the selected tab trigger
171
- */
172
- focus: VoidFunction;
173
- /**
174
- * Selects the next tab
175
- */
176
- selectNext: (fromValue?: string) => void;
177
- /**
178
- * Selects the previous tab
179
- */
180
- selectPrev: (fromValue?: string) => void;
181
- /**
182
- * Returns the state of the trigger with the given props
183
- */
184
- getTriggerState: (props: TriggerProps) => TriggerState;
185
- getRootProps: () => T["element"];
186
- getListProps: () => T["element"];
187
- getTriggerProps: (props: TriggerProps) => T["button"];
188
- getContentProps: (props: ContentProps) => T["element"];
189
- getIndicatorProps: () => T["element"];
190
- }
191
-
192
- declare function connect<T extends PropTypes>(service: Service<TabsSchema>, normalize: NormalizeProps<T>): TabsApi<T>;
193
-
194
- declare const machine: _zag_js_core.Machine<TabsSchema>;
195
-
196
- declare const props: (keyof TabsProps)[];
197
- declare const splitProps: <Props extends Partial<TabsProps>>(props: Props) => [Partial<TabsProps>, Omit<Props, keyof TabsProps>];
198
- declare const triggerProps: (keyof TriggerProps)[];
199
- declare const splitTriggerProps: <Props extends TriggerProps>(props: Props) => [TriggerProps, Omit<Props, keyof TriggerProps>];
200
- declare const contentProps: "value"[];
201
- declare const splitContentProps: <Props extends ContentProps>(props: Props) => [ContentProps, Omit<Props, "value">];
202
-
203
- 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 TriggerState, type ValueChangeDetails, anatomy, connect, contentProps, machine, props, splitContentProps, splitProps, splitTriggerProps, triggerProps };
1
+ export { anatomy } from './tabs.anatomy.mjs';
2
+ export { connect } from './tabs.connect.mjs';
3
+ export { machine } from './tabs.machine.mjs';
4
+ export { contentProps, props, splitContentProps, splitProps, splitTriggerProps, triggerProps } from './tabs.props.mjs';
5
+ export { TabsApi as Api, ContentProps, ElementIds, FocusChangeDetails, IntlTranslations, TabsMachine as Machine, NavigateDetails, TabsProps as Props, TabsService as Service, TriggerProps, TriggerState, ValueChangeDetails } from './tabs.types.mjs';
6
+ import '@zag-js/anatomy';
7
+ import '@zag-js/core';
8
+ import '@zag-js/types';
package/dist/index.d.ts CHANGED
@@ -1,203 +1,8 @@
1
- import * as _zag_js_anatomy from '@zag-js/anatomy';
2
- import * as _zag_js_core from '@zag-js/core';
3
- import { Machine, EventObject, Service } from '@zag-js/core';
4
- import { PropTypes, RequiredBy, DirectionProperty, CommonProperties, Rect, NormalizeProps } from '@zag-js/types';
5
-
6
- declare const anatomy: _zag_js_anatomy.AnatomyInstance<"root" | "list" | "trigger" | "content" | "indicator">;
7
-
8
- interface ValueChangeDetails {
9
- value: string;
10
- }
11
- interface FocusChangeDetails {
12
- focusedValue: string;
13
- }
14
- interface NavigateDetails {
15
- value: string;
16
- node: HTMLAnchorElement;
17
- href: string;
18
- }
19
- interface IntlTranslations {
20
- listLabel?: string | undefined;
21
- }
22
- type ElementIds = Partial<{
23
- root: string;
24
- trigger: (value: string) => string;
25
- list: string;
26
- content: (value: string) => string;
27
- indicator: string;
28
- }>;
29
- interface TabsProps extends DirectionProperty, CommonProperties {
30
- /**
31
- * The ids of the elements in the tabs. Useful for composition.
32
- */
33
- ids?: ElementIds | undefined;
34
- /**
35
- * Specifies the localized strings that identifies the accessibility elements and their states
36
- */
37
- translations?: IntlTranslations | undefined;
38
- /**
39
- * Whether the keyboard navigation will loop from last tab to first, and vice versa.
40
- * @default true
41
- */
42
- loopFocus?: boolean | undefined;
43
- /**
44
- * The controlled selected tab value
45
- */
46
- value?: string | null | undefined;
47
- /**
48
- * The initial selected tab value when rendered.
49
- * Use when you don't need to control the selected tab value.
50
- */
51
- defaultValue?: string | null | undefined;
52
- /**
53
- * The orientation of the tabs. Can be `horizontal` or `vertical`
54
- * - `horizontal`: only left and right arrow key navigation will work.
55
- * - `vertical`: only up and down arrow key navigation will work.
56
- *
57
- * @default "horizontal"
58
- */
59
- orientation?: "horizontal" | "vertical" | undefined;
60
- /**
61
- * The activation mode of the tabs. Can be `manual` or `automatic`
62
- * - `manual`: Tabs are activated when clicked or press `enter` key.
63
- * - `automatic`: Tabs are activated when receiving focus
64
- *
65
- * @default "automatic"
66
- */
67
- activationMode?: "manual" | "automatic" | undefined;
68
- /**
69
- * Callback to be called when the selected/active tab changes
70
- */
71
- onValueChange?: ((details: ValueChangeDetails) => void) | undefined;
72
- /**
73
- * Callback to be called when the focused tab changes
74
- */
75
- onFocusChange?: ((details: FocusChangeDetails) => void) | undefined;
76
- /**
77
- * Whether the tab is composite
78
- */
79
- composite?: boolean | undefined;
80
- /**
81
- * Whether the active tab can be deselected when clicking on it.
82
- */
83
- deselectable?: boolean | undefined;
84
- /**
85
- * Function to navigate to the selected tab when clicking on it.
86
- * Useful if tab triggers are anchor elements.
87
- */
88
- navigate?: ((details: NavigateDetails) => void) | null | undefined;
89
- }
90
- type PropsWithDefault = "orientation" | "activationMode" | "loopFocus";
91
- type TabsSchema = {
92
- state: "idle" | "focused";
93
- props: RequiredBy<TabsProps, PropsWithDefault>;
94
- context: {
95
- ssr: boolean;
96
- value: string | null;
97
- focusedValue: string | null;
98
- indicatorRect: Rect | null;
99
- };
100
- refs: {
101
- indicatorCleanup: VoidFunction | null | undefined;
102
- };
103
- computed: {
104
- focused: boolean;
105
- };
106
- action: string;
107
- guard: string;
108
- effect: string;
109
- event: EventObject;
110
- };
111
- type TabsService = Service<TabsSchema>;
112
- type TabsMachine = Machine<TabsSchema>;
113
- interface TriggerProps {
114
- /**
115
- * The value of the tab
116
- */
117
- value: string;
118
- /**
119
- * Whether the tab is disabled
120
- */
121
- disabled?: boolean | undefined;
122
- }
123
- interface TriggerState {
124
- /**
125
- * Whether the tab is selected
126
- */
127
- selected: boolean;
128
- /**
129
- * Whether the tab is focused
130
- */
131
- focused: boolean;
132
- /**
133
- * Whether the tab is disabled
134
- */
135
- disabled: boolean;
136
- }
137
- interface ContentProps {
138
- /**
139
- * The value of the tab
140
- */
141
- value: string;
142
- }
143
- interface TabsApi<T extends PropTypes = PropTypes> {
144
- /**
145
- * The current value of the tabs.
146
- */
147
- value: string | null;
148
- /**
149
- * The value of the tab that is currently focused.
150
- */
151
- focusedValue: string | null;
152
- /**
153
- * Sets the value of the tabs.
154
- */
155
- setValue: (value: string) => void;
156
- /**
157
- * Clears the value of the tabs.
158
- */
159
- clearValue: VoidFunction;
160
- /**
161
- * Sets the indicator rect to the tab with the given value
162
- */
163
- setIndicatorRect: (value: string) => void;
164
- /**
165
- * Synchronizes the tab index of the content element.
166
- * Useful when rendering tabs within a select or combobox
167
- */
168
- syncTabIndex: VoidFunction;
169
- /**
170
- * Set focus on the selected tab trigger
171
- */
172
- focus: VoidFunction;
173
- /**
174
- * Selects the next tab
175
- */
176
- selectNext: (fromValue?: string) => void;
177
- /**
178
- * Selects the previous tab
179
- */
180
- selectPrev: (fromValue?: string) => void;
181
- /**
182
- * Returns the state of the trigger with the given props
183
- */
184
- getTriggerState: (props: TriggerProps) => TriggerState;
185
- getRootProps: () => T["element"];
186
- getListProps: () => T["element"];
187
- getTriggerProps: (props: TriggerProps) => T["button"];
188
- getContentProps: (props: ContentProps) => T["element"];
189
- getIndicatorProps: () => T["element"];
190
- }
191
-
192
- declare function connect<T extends PropTypes>(service: Service<TabsSchema>, normalize: NormalizeProps<T>): TabsApi<T>;
193
-
194
- declare const machine: _zag_js_core.Machine<TabsSchema>;
195
-
196
- declare const props: (keyof TabsProps)[];
197
- declare const splitProps: <Props extends Partial<TabsProps>>(props: Props) => [Partial<TabsProps>, Omit<Props, keyof TabsProps>];
198
- declare const triggerProps: (keyof TriggerProps)[];
199
- declare const splitTriggerProps: <Props extends TriggerProps>(props: Props) => [TriggerProps, Omit<Props, keyof TriggerProps>];
200
- declare const contentProps: "value"[];
201
- declare const splitContentProps: <Props extends ContentProps>(props: Props) => [ContentProps, Omit<Props, "value">];
202
-
203
- 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 TriggerState, type ValueChangeDetails, anatomy, connect, contentProps, machine, props, splitContentProps, splitProps, splitTriggerProps, triggerProps };
1
+ export { anatomy } from './tabs.anatomy.js';
2
+ export { connect } from './tabs.connect.js';
3
+ export { machine } from './tabs.machine.js';
4
+ export { contentProps, props, splitContentProps, splitProps, splitTriggerProps, triggerProps } from './tabs.props.js';
5
+ export { TabsApi as Api, ContentProps, ElementIds, FocusChangeDetails, IntlTranslations, TabsMachine as Machine, NavigateDetails, TabsProps as Props, TabsService as Service, TriggerProps, TriggerState, ValueChangeDetails } from './tabs.types.js';
6
+ import '@zag-js/anatomy';
7
+ import '@zag-js/core';
8
+ import '@zag-js/types';