@zag-js/tabs 0.1.9 → 0.1.12

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Chakra UI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,115 @@
1
- export { connect } from "./tabs.connect";
2
- export { machine } from "./tabs.machine";
3
- export type { UserDefinedContext as Context } from "./tabs.types";
1
+ import { RequiredBy, DirectionProperty, CommonProperties, Context, PropTypes, NormalizeProps } from '@zag-js/types';
2
+ import * as _zag_js_core from '@zag-js/core';
3
+ import { StateMachine } from '@zag-js/core';
4
+
5
+ declare type IntlMessages = {
6
+ tablistLabel?: string;
7
+ deleteLabel?(value: string): string;
8
+ };
9
+ declare type ElementIds = Partial<{
10
+ root: string;
11
+ trigger: string;
12
+ triggerGroup: string;
13
+ contentGroup: string;
14
+ content: string;
15
+ }>;
16
+ declare type PublicContext = DirectionProperty & CommonProperties & {
17
+ /**
18
+ * The ids of the elements in the tabs. Useful for composition.
19
+ */
20
+ ids?: ElementIds;
21
+ /**
22
+ * Specifies the localized strings that identifies the accessibility elements and their states
23
+ */
24
+ messages: IntlMessages;
25
+ /**
26
+ * Whether the keyboard navigation will loop from last tab to first, and vice versa.
27
+ * @default true
28
+ */
29
+ loop: boolean;
30
+ /**
31
+ * Whether the indicator is rendered.
32
+ */
33
+ isIndicatorRendered: boolean;
34
+ /**
35
+ * The selected tab id
36
+ */
37
+ value: string | null;
38
+ /**
39
+ * The orientation of the tabs. Can be `horizontal` or `vertical`
40
+ * - `horizontal`: only left and right arrow key navigation will work.
41
+ * - `vertical`: only up and down arrow key navigation will work.
42
+ *
43
+ * @default "horizontal"
44
+ */
45
+ orientation?: "horizontal" | "vertical";
46
+ /**
47
+ * The activation mode of the tabs. Can be `manual` or `automatic`
48
+ * - `manual`: Tabs are activated when clicked or press `enter` key.
49
+ * - `automatic`: Tabs are activated when receiving focus
50
+ * @default "automatic"
51
+ */
52
+ activationMode?: "manual" | "automatic";
53
+ /**
54
+ * Callback to be called when the selected/active tab changes
55
+ */
56
+ onChange?: (details: {
57
+ value: string | null;
58
+ }) => void;
59
+ /**
60
+ * Callback to be called when the focused tab changes
61
+ */
62
+ onFocus?: (details: {
63
+ value: string | null;
64
+ }) => void;
65
+ /**
66
+ * Callback to be called when a tab's close button is clicked
67
+ */
68
+ onDelete?: (details: {
69
+ value: string;
70
+ }) => void;
71
+ };
72
+ declare type UserDefinedContext = RequiredBy<PublicContext, "id">;
73
+ declare type ComputedContext = Readonly<{
74
+ /**
75
+ * @computed
76
+ * Whether the tab is in the horizontal orientation
77
+ */
78
+ isHorizontal: boolean;
79
+ /**
80
+ * @computed
81
+ * Whether the tab is in the vertical orientation
82
+ */
83
+ isVertical: boolean;
84
+ }>;
85
+ declare type PrivateContext = Context<{}>;
86
+ declare type MachineContext = PublicContext & ComputedContext & PrivateContext;
87
+ declare type MachineState = {
88
+ value: "unknown" | "idle" | "focused";
89
+ };
90
+ declare type State = StateMachine.State<MachineContext, MachineState>;
91
+ declare type Send = StateMachine.Send<StateMachine.AnyEventObject>;
92
+ declare type TabProps = {
93
+ value: string;
94
+ disabled?: boolean;
95
+ };
96
+
97
+ declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
98
+ value: string | null;
99
+ focusedValue: string | null;
100
+ previousValues: string[];
101
+ setValue(value: string): void;
102
+ rootProps: T["element"];
103
+ triggerGroupProps: T["element"];
104
+ getTriggerProps(props: TabProps): T["button"];
105
+ contentGroupProps: T["element"];
106
+ getContentProps({ value }: {
107
+ value: string;
108
+ }): T["element"];
109
+ getDeleteButtonProps({ value, disabled }: TabProps): T["button"];
110
+ indicatorProps: T["element"];
111
+ };
112
+
113
+ declare function machine(ctx: UserDefinedContext): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
114
+
115
+ export { UserDefinedContext as Context, connect, machine };