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