@zag-js/tabs 2.0.0-next.0 → 2.0.0-next.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 +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/tabs.connect.js +7 -3
- package/dist/tabs.connect.mjs +7 -3
- package/dist/tabs.types.d.mts +11 -1
- package/dist/tabs.types.d.ts +11 -1
- package/package.json +10 -7
package/dist/index.d.mts
CHANGED
|
@@ -2,7 +2,7 @@ export { anatomy } from './tabs.anatomy.mjs';
|
|
|
2
2
|
export { connect } from './tabs.connect.mjs';
|
|
3
3
|
export { machine } from './tabs.machine.mjs';
|
|
4
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';
|
|
5
|
+
export { TabsApi as Api, ContentProps, ContentState, ElementIds, FocusChangeDetails, IntlTranslations, TabsMachine as Machine, NavigateDetails, TabsProps as Props, TabsService as Service, TriggerProps, TriggerState, ValueChangeDetails } from './tabs.types.mjs';
|
|
6
6
|
import '@zag-js/anatomy';
|
|
7
7
|
import '@zag-js/core';
|
|
8
8
|
import '@zag-js/types';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { anatomy } from './tabs.anatomy.js';
|
|
|
2
2
|
export { connect } from './tabs.connect.js';
|
|
3
3
|
export { machine } from './tabs.machine.js';
|
|
4
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';
|
|
5
|
+
export { TabsApi as Api, ContentProps, ContentState, ElementIds, FocusChangeDetails, IntlTranslations, TabsMachine as Machine, NavigateDetails, TabsProps as Props, TabsService as Service, TriggerProps, TriggerState, ValueChangeDetails } from './tabs.types.js';
|
|
6
6
|
import '@zag-js/anatomy';
|
|
7
7
|
import '@zag-js/core';
|
|
8
8
|
import '@zag-js/types';
|
package/dist/tabs.connect.js
CHANGED
|
@@ -51,6 +51,9 @@ function connect(service, normalize) {
|
|
|
51
51
|
disabled: !!props.disabled
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
+
function getContentState(props) {
|
|
55
|
+
return { selected: context.get("value") === props.value };
|
|
56
|
+
}
|
|
54
57
|
return {
|
|
55
58
|
value: context.get("value"),
|
|
56
59
|
focusedValue: context.get("focusedValue"),
|
|
@@ -179,9 +182,10 @@ function connect(service, normalize) {
|
|
|
179
182
|
}
|
|
180
183
|
});
|
|
181
184
|
},
|
|
185
|
+
getContentState,
|
|
182
186
|
getContentProps(props) {
|
|
183
187
|
const { value } = props;
|
|
184
|
-
const
|
|
188
|
+
const contentState = getContentState(props);
|
|
185
189
|
return normalize.element({
|
|
186
190
|
...import_tabs.parts.content.attrs(scope.id),
|
|
187
191
|
dir: prop("dir"),
|
|
@@ -189,9 +193,9 @@ function connect(service, normalize) {
|
|
|
189
193
|
tabIndex: !virtualFocus ? 0 : -1,
|
|
190
194
|
"aria-labelledby": dom.getTriggerId(scope, value),
|
|
191
195
|
role: "tabpanel",
|
|
192
|
-
"data-selected": (0, import_dom_query.dataAttr)(selected),
|
|
196
|
+
"data-selected": (0, import_dom_query.dataAttr)(contentState.selected),
|
|
193
197
|
"data-orientation": prop("orientation"),
|
|
194
|
-
hidden: !selected
|
|
198
|
+
hidden: !contentState.selected
|
|
195
199
|
});
|
|
196
200
|
},
|
|
197
201
|
getIndicatorProps() {
|
package/dist/tabs.connect.mjs
CHANGED
|
@@ -25,6 +25,9 @@ function connect(service, normalize) {
|
|
|
25
25
|
disabled: !!props.disabled
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
function getContentState(props) {
|
|
29
|
+
return { selected: context.get("value") === props.value };
|
|
30
|
+
}
|
|
28
31
|
return {
|
|
29
32
|
value: context.get("value"),
|
|
30
33
|
focusedValue: context.get("focusedValue"),
|
|
@@ -153,9 +156,10 @@ function connect(service, normalize) {
|
|
|
153
156
|
}
|
|
154
157
|
});
|
|
155
158
|
},
|
|
159
|
+
getContentState,
|
|
156
160
|
getContentProps(props) {
|
|
157
161
|
const { value } = props;
|
|
158
|
-
const
|
|
162
|
+
const contentState = getContentState(props);
|
|
159
163
|
return normalize.element({
|
|
160
164
|
...parts.content.attrs(scope.id),
|
|
161
165
|
dir: prop("dir"),
|
|
@@ -163,9 +167,9 @@ function connect(service, normalize) {
|
|
|
163
167
|
tabIndex: !virtualFocus ? 0 : -1,
|
|
164
168
|
"aria-labelledby": dom.getTriggerId(scope, value),
|
|
165
169
|
role: "tabpanel",
|
|
166
|
-
"data-selected": dataAttr(selected),
|
|
170
|
+
"data-selected": dataAttr(contentState.selected),
|
|
167
171
|
"data-orientation": prop("orientation"),
|
|
168
|
-
hidden: !selected
|
|
172
|
+
hidden: !contentState.selected
|
|
169
173
|
});
|
|
170
174
|
},
|
|
171
175
|
getIndicatorProps() {
|
package/dist/tabs.types.d.mts
CHANGED
|
@@ -144,6 +144,12 @@ interface ContentProps {
|
|
|
144
144
|
*/
|
|
145
145
|
value: string;
|
|
146
146
|
}
|
|
147
|
+
interface ContentState {
|
|
148
|
+
/**
|
|
149
|
+
* Whether the tab content is selected
|
|
150
|
+
*/
|
|
151
|
+
selected: boolean;
|
|
152
|
+
}
|
|
147
153
|
interface TabsApi<T extends PropTypes = PropTypes> {
|
|
148
154
|
/**
|
|
149
155
|
* The current value of the tabs.
|
|
@@ -189,8 +195,12 @@ interface TabsApi<T extends PropTypes = PropTypes> {
|
|
|
189
195
|
getRootProps: () => T["element"];
|
|
190
196
|
getListProps: () => T["element"];
|
|
191
197
|
getTriggerProps: (props: TriggerProps) => T["button"];
|
|
198
|
+
/**
|
|
199
|
+
* Returns the state of the content with the given props
|
|
200
|
+
*/
|
|
201
|
+
getContentState: (props: ContentProps) => ContentState;
|
|
192
202
|
getContentProps: (props: ContentProps) => T["element"];
|
|
193
203
|
getIndicatorProps: () => T["element"];
|
|
194
204
|
}
|
|
195
205
|
|
|
196
|
-
export type { ContentProps, ElementIds, FocusChangeDetails, IntlTranslations, NavigateDetails, TabsApi, TabsMachine, TabsProps, TabsSchema, TabsService, TriggerProps, TriggerState, ValueChangeDetails };
|
|
206
|
+
export type { ContentProps, ContentState, ElementIds, FocusChangeDetails, IntlTranslations, NavigateDetails, TabsApi, TabsMachine, TabsProps, TabsSchema, TabsService, TriggerProps, TriggerState, ValueChangeDetails };
|
package/dist/tabs.types.d.ts
CHANGED
|
@@ -144,6 +144,12 @@ interface ContentProps {
|
|
|
144
144
|
*/
|
|
145
145
|
value: string;
|
|
146
146
|
}
|
|
147
|
+
interface ContentState {
|
|
148
|
+
/**
|
|
149
|
+
* Whether the tab content is selected
|
|
150
|
+
*/
|
|
151
|
+
selected: boolean;
|
|
152
|
+
}
|
|
147
153
|
interface TabsApi<T extends PropTypes = PropTypes> {
|
|
148
154
|
/**
|
|
149
155
|
* The current value of the tabs.
|
|
@@ -189,8 +195,12 @@ interface TabsApi<T extends PropTypes = PropTypes> {
|
|
|
189
195
|
getRootProps: () => T["element"];
|
|
190
196
|
getListProps: () => T["element"];
|
|
191
197
|
getTriggerProps: (props: TriggerProps) => T["button"];
|
|
198
|
+
/**
|
|
199
|
+
* Returns the state of the content with the given props
|
|
200
|
+
*/
|
|
201
|
+
getContentState: (props: ContentProps) => ContentState;
|
|
192
202
|
getContentProps: (props: ContentProps) => T["element"];
|
|
193
203
|
getIndicatorProps: () => T["element"];
|
|
194
204
|
}
|
|
195
205
|
|
|
196
|
-
export type { ContentProps, ElementIds, FocusChangeDetails, IntlTranslations, NavigateDetails, TabsApi, TabsMachine, TabsProps, TabsSchema, TabsService, TriggerProps, TriggerState, ValueChangeDetails };
|
|
206
|
+
export type { ContentProps, ContentState, ElementIds, FocusChangeDetails, IntlTranslations, NavigateDetails, TabsApi, TabsMachine, TabsProps, TabsSchema, TabsService, TriggerProps, TriggerState, ValueChangeDetails };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/tabs",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.1",
|
|
4
4
|
"description": "Core logic for the tabs widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
"author": "Segun Adebayo <sage@adebayosegun.com>",
|
|
15
15
|
"homepage": "https://github.com/chakra-ui/zag#readme",
|
|
16
16
|
"license": "MIT",
|
|
17
|
-
"repository":
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/chakra-ui/zag/tree/main/packages/tabs"
|
|
20
|
+
},
|
|
18
21
|
"sideEffects": false,
|
|
19
22
|
"files": [
|
|
20
23
|
"dist"
|
|
@@ -26,11 +29,11 @@
|
|
|
26
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
27
30
|
},
|
|
28
31
|
"dependencies": {
|
|
29
|
-
"@zag-js/anatomy": "2.0.0-next.
|
|
30
|
-
"@zag-js/
|
|
31
|
-
"@zag-js/
|
|
32
|
-
"@zag-js/
|
|
33
|
-
"@zag-js/
|
|
32
|
+
"@zag-js/anatomy": "2.0.0-next.1",
|
|
33
|
+
"@zag-js/utils": "2.0.0-next.1",
|
|
34
|
+
"@zag-js/types": "2.0.0-next.1",
|
|
35
|
+
"@zag-js/dom-query": "2.0.0-next.1",
|
|
36
|
+
"@zag-js/core": "2.0.0-next.1"
|
|
34
37
|
},
|
|
35
38
|
"devDependencies": {
|
|
36
39
|
"clean-package": "2.2.0"
|