@zag-js/tabs 1.46.0 → 1.48.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.
@@ -1,63 +1,35 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/tabs.props.ts
21
- var tabs_props_exports = {};
22
- __export(tabs_props_exports, {
23
- contentProps: () => contentProps,
24
- props: () => props,
25
- splitContentProps: () => splitContentProps,
26
- splitProps: () => splitProps,
27
- splitTriggerProps: () => splitTriggerProps,
28
- triggerProps: () => triggerProps
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
29
4
  });
30
- module.exports = __toCommonJS(tabs_props_exports);
31
- var import_types = require("@zag-js/types");
32
- var import_utils = require("@zag-js/utils");
33
- var props = (0, import_types.createProps)()([
34
- "activationMode",
35
- "composite",
36
- "deselectable",
37
- "dir",
38
- "getRootNode",
39
- "id",
40
- "ids",
41
- "loopFocus",
42
- "navigate",
43
- "onFocusChange",
44
- "onValueChange",
45
- "orientation",
46
- "translations",
47
- "value",
48
- "defaultValue"
5
+ let _zag_js_utils = require("@zag-js/utils");
6
+ let _zag_js_types = require("@zag-js/types");
7
+ // src/tabs.props.ts
8
+ const props = (0, _zag_js_types.createProps)()([
9
+ "activationMode",
10
+ "composite",
11
+ "deselectable",
12
+ "dir",
13
+ "getRootNode",
14
+ "id",
15
+ "ids",
16
+ "loopFocus",
17
+ "navigate",
18
+ "onFocusChange",
19
+ "onValueChange",
20
+ "orientation",
21
+ "translations",
22
+ "value",
23
+ "defaultValue"
49
24
  ]);
50
- var splitProps = (0, import_utils.createSplitProps)(props);
51
- var triggerProps = (0, import_types.createProps)()(["disabled", "value"]);
52
- var splitTriggerProps = (0, import_utils.createSplitProps)(triggerProps);
53
- var contentProps = (0, import_types.createProps)()(["value"]);
54
- var splitContentProps = (0, import_utils.createSplitProps)(contentProps);
55
- // Annotate the CommonJS export names for ESM import in node:
56
- 0 && (module.exports = {
57
- contentProps,
58
- props,
59
- splitContentProps,
60
- splitProps,
61
- splitTriggerProps,
62
- triggerProps
63
- });
25
+ const splitProps = (0, _zag_js_utils.createSplitProps)(props);
26
+ const triggerProps = (0, _zag_js_types.createProps)()(["disabled", "value"]);
27
+ const splitTriggerProps = (0, _zag_js_utils.createSplitProps)(triggerProps);
28
+ const contentProps = (0, _zag_js_types.createProps)()(["value"]);
29
+ const splitContentProps = (0, _zag_js_utils.createSplitProps)(contentProps);
30
+ exports.contentProps = contentProps;
31
+ exports.props = props;
32
+ exports.splitContentProps = splitContentProps;
33
+ exports.splitProps = splitProps;
34
+ exports.splitTriggerProps = splitTriggerProps;
35
+ exports.triggerProps = triggerProps;
@@ -1,33 +1,26 @@
1
- // src/tabs.props.ts
2
- import { createProps } from "@zag-js/types";
3
1
  import { createSplitProps } from "@zag-js/utils";
4
- var props = createProps()([
5
- "activationMode",
6
- "composite",
7
- "deselectable",
8
- "dir",
9
- "getRootNode",
10
- "id",
11
- "ids",
12
- "loopFocus",
13
- "navigate",
14
- "onFocusChange",
15
- "onValueChange",
16
- "orientation",
17
- "translations",
18
- "value",
19
- "defaultValue"
2
+ import { createProps } from "@zag-js/types";
3
+ // src/tabs.props.ts
4
+ const props = createProps()([
5
+ "activationMode",
6
+ "composite",
7
+ "deselectable",
8
+ "dir",
9
+ "getRootNode",
10
+ "id",
11
+ "ids",
12
+ "loopFocus",
13
+ "navigate",
14
+ "onFocusChange",
15
+ "onValueChange",
16
+ "orientation",
17
+ "translations",
18
+ "value",
19
+ "defaultValue"
20
20
  ]);
21
- var splitProps = createSplitProps(props);
22
- var triggerProps = createProps()(["disabled", "value"]);
23
- var splitTriggerProps = createSplitProps(triggerProps);
24
- var contentProps = createProps()(["value"]);
25
- var splitContentProps = createSplitProps(contentProps);
26
- export {
27
- contentProps,
28
- props,
29
- splitContentProps,
30
- splitProps,
31
- splitTriggerProps,
32
- triggerProps
33
- };
21
+ const splitProps = createSplitProps(props);
22
+ const triggerProps = createProps()(["disabled", "value"]);
23
+ const splitTriggerProps = createSplitProps(triggerProps);
24
+ const contentProps = createProps()(["value"]);
25
+ const splitContentProps = createSplitProps(contentProps);
26
+ export { contentProps, props, splitContentProps, splitProps, splitTriggerProps, triggerProps };
@@ -1,192 +1,192 @@
1
- import { Machine, EventObject, Service } from '@zag-js/core';
2
- import { PropTypes, RequiredBy, DirectionProperty, CommonProperties, Rect } from '@zag-js/types';
3
-
4
- interface ValueChangeDetails {
5
- value: string;
1
+ import { AnimationFrame } from "@zag-js/dom-query";
2
+ import { EventObject, Machine, Service } from "@zag-js/core";
3
+ import { CommonProperties, DirectionProperty, PropTypes, Rect, RequiredBy } from "@zag-js/types";
4
+ export interface ValueChangeDetails {
5
+ value: string;
6
6
  }
7
- interface FocusChangeDetails {
8
- focusedValue: string;
7
+ export interface FocusChangeDetails {
8
+ focusedValue: string;
9
9
  }
10
- interface NavigateDetails {
11
- value: string;
12
- node: HTMLAnchorElement;
13
- href: string;
10
+ export interface NavigateDetails {
11
+ value: string;
12
+ node: HTMLAnchorElement;
13
+ href: string;
14
14
  }
15
- interface IntlTranslations {
16
- listLabel?: string | undefined;
15
+ export interface IntlTranslations {
16
+ listLabel?: string | undefined;
17
17
  }
18
- interface ElementIds {
19
- root?: string | undefined;
20
- trigger?: ((value: string) => string) | undefined;
21
- list?: string | undefined;
22
- content?: ((value: string) => string) | undefined;
23
- indicator?: string | undefined;
18
+ export interface ElementIds {
19
+ root?: string | undefined;
20
+ trigger?: ((value: string) => string) | undefined;
21
+ list?: string | undefined;
22
+ content?: ((value: string) => string) | undefined;
23
+ indicator?: string | undefined;
24
24
  }
25
- interface TabsProps extends DirectionProperty, CommonProperties {
26
- /**
27
- * The ids of the elements in the tabs. Useful for composition.
28
- */
29
- ids?: ElementIds | undefined;
30
- /**
31
- * Specifies the localized strings that identifies the accessibility elements and their states
32
- */
33
- translations?: IntlTranslations | undefined;
34
- /**
35
- * Whether the keyboard navigation will loop from last tab to first, and vice versa.
36
- * @default true
37
- */
38
- loopFocus?: boolean | undefined;
39
- /**
40
- * The controlled selected tab value
41
- */
42
- value?: string | null | undefined;
43
- /**
44
- * The initial selected tab value when rendered.
45
- * Use when you don't need to control the selected tab value.
46
- */
47
- defaultValue?: string | null | undefined;
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 | undefined;
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) | null | undefined;
25
+ export interface TabsProps extends DirectionProperty, CommonProperties {
26
+ /**
27
+ * The ids of the elements in the tabs. Useful for composition.
28
+ */
29
+ ids?: ElementIds | undefined;
30
+ /**
31
+ * Specifies the localized strings that identifies the accessibility elements and their states
32
+ */
33
+ translations?: IntlTranslations | undefined;
34
+ /**
35
+ * Whether the keyboard navigation will loop from last tab to first, and vice versa.
36
+ * @default true
37
+ */
38
+ loopFocus?: boolean | undefined;
39
+ /**
40
+ * The controlled selected tab value
41
+ */
42
+ value?: string | null | undefined;
43
+ /**
44
+ * The initial selected tab value when rendered.
45
+ * Use when you don't need to control the selected tab value.
46
+ */
47
+ defaultValue?: string | null | undefined;
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 | undefined;
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) | null | undefined;
85
85
  }
86
86
  type PropsWithDefault = "orientation" | "activationMode" | "loopFocus";
87
- type TabsSchema = {
88
- state: "idle" | "focused";
89
- props: RequiredBy<TabsProps, PropsWithDefault>;
90
- context: {
91
- ssr: boolean;
92
- value: string | null;
93
- focusedValue: string | null;
94
- indicatorRect: Rect | null;
95
- animateIndicator: boolean;
96
- };
97
- refs: {
98
- indicatorCleanup: VoidFunction | null | undefined;
99
- prevValue: string | null;
100
- };
101
- computed: {
102
- focused: boolean;
103
- };
104
- action: string;
105
- guard: string;
106
- effect: string;
107
- event: EventObject & {
108
- src?: "keyboard" | "selectNext" | "selectPrev" | undefined;
109
- };
87
+ export type TabsSchema = {
88
+ state: "idle" | "focused";
89
+ props: RequiredBy<TabsProps, PropsWithDefault>;
90
+ context: {
91
+ ssr: boolean;
92
+ value: string | null;
93
+ focusedValue: string | null;
94
+ indicatorRect: Rect | null;
95
+ animateIndicator: boolean;
96
+ };
97
+ refs: {
98
+ indicatorCleanup: VoidFunction | null | undefined;
99
+ prevValue: string | null;
100
+ focusFrame: AnimationFrame;
101
+ };
102
+ computed: {
103
+ focused: boolean;
104
+ };
105
+ action: string;
106
+ guard: string;
107
+ effect: string;
108
+ event: EventObject & {
109
+ src?: "keyboard" | "selectNext" | "selectPrev" | undefined;
110
+ };
110
111
  };
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;
112
+ export type TabsService = Service<TabsSchema>;
113
+ export type TabsMachine = Machine<TabsSchema>;
114
+ export interface TriggerProps {
115
+ /**
116
+ * The value of the tab
117
+ */
118
+ value: string;
119
+ /**
120
+ * Whether the tab is disabled
121
+ */
122
+ disabled?: boolean | undefined;
122
123
  }
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;
124
+ export interface TriggerState {
125
+ /**
126
+ * Whether the tab is selected
127
+ */
128
+ selected: boolean;
129
+ /**
130
+ * Whether the tab is focused
131
+ */
132
+ focused: boolean;
133
+ /**
134
+ * Whether the tab is disabled
135
+ */
136
+ disabled: boolean;
136
137
  }
137
- interface ContentProps {
138
- /**
139
- * The value of the tab
140
- */
141
- value: string;
138
+ export interface ContentProps {
139
+ /**
140
+ * The value of the tab
141
+ */
142
+ value: string;
142
143
  }
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"];
144
+ export interface TabsApi<T extends PropTypes = PropTypes> {
145
+ /**
146
+ * The current value of the tabs.
147
+ */
148
+ value: string | null;
149
+ /**
150
+ * The value of the tab that is currently focused.
151
+ */
152
+ focusedValue: string | null;
153
+ /**
154
+ * Sets the value of the tabs.
155
+ */
156
+ setValue: (value: string) => void;
157
+ /**
158
+ * Clears the value of the tabs.
159
+ */
160
+ clearValue: VoidFunction;
161
+ /**
162
+ * Sets the indicator rect to the tab with the given value
163
+ */
164
+ setIndicatorRect: (value: string) => void;
165
+ /**
166
+ * Synchronizes the tab index of the content element.
167
+ * Useful when rendering tabs within a select or combobox
168
+ */
169
+ syncTabIndex: VoidFunction;
170
+ /**
171
+ * Set focus on the selected tab trigger
172
+ */
173
+ focus: VoidFunction;
174
+ /**
175
+ * Selects the next tab
176
+ */
177
+ selectNext: (fromValue?: string) => void;
178
+ /**
179
+ * Selects the previous tab
180
+ */
181
+ selectPrev: (fromValue?: string) => void;
182
+ /**
183
+ * Returns the state of the trigger with the given props
184
+ */
185
+ getTriggerState: (props: TriggerProps) => TriggerState;
186
+ getRootProps: () => T["element"];
187
+ getListProps: () => T["element"];
188
+ getTriggerProps: (props: TriggerProps) => T["button"];
189
+ getContentProps: (props: ContentProps) => T["element"];
190
+ getIndicatorProps: () => T["element"];
190
191
  }
191
-
192
- export type { ContentProps, ElementIds, FocusChangeDetails, IntlTranslations, NavigateDetails, TabsApi, TabsMachine, TabsProps, TabsSchema, TabsService, TriggerProps, TriggerState, ValueChangeDetails };
192
+ export {};