@tamagui/accordion 1.88.13 → 1.89.0-1706308641099

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.
@@ -0,0 +1,318 @@
1
+ import { Collapsible } from "@tamagui/collapsible";
2
+ import { createCollection } from "@tamagui/collection";
3
+ import { useComposedRefs } from "@tamagui/compose-refs";
4
+ import { isWeb } from "@tamagui/constants";
5
+ import { composeEventHandlers, withStaticProperties } from "@tamagui/helpers";
6
+ import { YStack } from "@tamagui/stacks";
7
+ import { H1 } from "@tamagui/text";
8
+ import { useControllableState } from "@tamagui/use-controllable-state";
9
+ import { useDirection } from "@tamagui/use-direction";
10
+ import { createStyledContext, styled } from "@tamagui/web";
11
+ import * as React from "react";
12
+ import { jsx } from "react/jsx-runtime";
13
+ const ACCORDION_NAME = "Accordion",
14
+ ACCORDION_KEYS = ["Home", "End", "ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"],
15
+ [Collection, useCollection] = createCollection(ACCORDION_NAME),
16
+ ACCORDION_CONTEXT = "Accordion",
17
+ AccordionComponent = React.forwardRef((props, forwardedRef) => {
18
+ const {
19
+ type,
20
+ ...accordionProps
21
+ } = props,
22
+ singleProps = accordionProps,
23
+ multipleProps = accordionProps;
24
+ return /* @__PURE__ */jsx(Collection.Provider, {
25
+ __scopeCollection: props.__scopeAccordion || ACCORDION_CONTEXT,
26
+ children: type === "multiple" ? /* @__PURE__ */jsx(AccordionImplMultiple, {
27
+ ...multipleProps,
28
+ ref: forwardedRef
29
+ }) : /* @__PURE__ */jsx(AccordionImplSingle, {
30
+ ...singleProps,
31
+ ref: forwardedRef
32
+ })
33
+ });
34
+ });
35
+ AccordionComponent.displayName = ACCORDION_NAME;
36
+ AccordionComponent.propTypes = {
37
+ type(props) {
38
+ const value = props.value || props.defaultValue;
39
+ return props.type && !["single", "multiple"].includes(props.type) ? new Error("Invalid prop `type` supplied to `Accordion`. Expected one of `single | multiple`.") : props.type === "multiple" && typeof value == "string" ? new Error("Invalid prop `type` supplied to `Accordion`. Expected `single` when `defaultValue` or `value` is type `string`.") : props.type === "single" && Array.isArray(value) ? new Error("Invalid prop `type` supplied to `Accordion`. Expected `multiple` when `defaultValue` or `value` is type `string[]`.") : null;
40
+ }
41
+ };
42
+ const {
43
+ Provider: AccordionValueProvider,
44
+ useStyledContext: useAccordionValueContext
45
+ } = createStyledContext(),
46
+ {
47
+ Provider: AccordionCollapsibleProvider,
48
+ useStyledContext: useAccordionCollapsibleContext
49
+ } = createStyledContext(),
50
+ AccordionImplSingle = React.forwardRef((props, forwardedRef) => {
51
+ const {
52
+ value: valueProp,
53
+ defaultValue,
54
+ control,
55
+ onValueChange = () => {},
56
+ collapsible = !1,
57
+ ...accordionSingleProps
58
+ } = props,
59
+ [value, setValue] = useControllableState({
60
+ prop: valueProp,
61
+ defaultProp: defaultValue || "",
62
+ onChange: onValueChange
63
+ });
64
+ return /* @__PURE__ */jsx(AccordionValueProvider, {
65
+ scope: props.__scopeAccordion,
66
+ value: value ? [value] : [],
67
+ onItemOpen: setValue,
68
+ onItemClose: React.useCallback(() => collapsible && setValue(""), [setValue, collapsible]),
69
+ children: /* @__PURE__ */jsx(AccordionCollapsibleProvider, {
70
+ scope: props.__scopeAccordion,
71
+ collapsible,
72
+ children: /* @__PURE__ */jsx(AccordionImpl, {
73
+ ...accordionSingleProps,
74
+ ref: forwardedRef
75
+ })
76
+ })
77
+ });
78
+ }),
79
+ AccordionImplMultiple = React.forwardRef((props, forwardedRef) => {
80
+ const {
81
+ value: valueProp,
82
+ defaultValue,
83
+ onValueChange = () => {},
84
+ ...accordionMultipleProps
85
+ } = props,
86
+ [value, setValue] = useControllableState({
87
+ prop: valueProp,
88
+ defaultProp: defaultValue || [],
89
+ onChange: onValueChange
90
+ }),
91
+ handleItemOpen = React.useCallback(itemValue => setValue((prevValue = []) => [...prevValue, itemValue]), [setValue]),
92
+ handleItemClose = React.useCallback(itemValue => setValue((prevValue = []) => prevValue.filter(value2 => value2 !== itemValue)), [setValue]);
93
+ return /* @__PURE__ */jsx(AccordionValueProvider, {
94
+ scope: props.__scopeAccordion,
95
+ value: value || [],
96
+ onItemOpen: handleItemOpen,
97
+ onItemClose: handleItemClose,
98
+ children: /* @__PURE__ */jsx(AccordionCollapsibleProvider, {
99
+ scope: props.__scopeAccordion,
100
+ collapsible: !0,
101
+ children: /* @__PURE__ */jsx(AccordionImpl, {
102
+ ...accordionMultipleProps,
103
+ ref: forwardedRef
104
+ })
105
+ })
106
+ });
107
+ }),
108
+ {
109
+ Provider: AccordionImplProvider,
110
+ useStyledContext: useAccordionContext
111
+ } = createStyledContext(),
112
+ AccordionImpl = React.forwardRef((props, forwardedRef) => {
113
+ const {
114
+ __scopeAccordion,
115
+ disabled,
116
+ dir,
117
+ orientation = "vertical",
118
+ ...accordionProps
119
+ } = props,
120
+ accordionRef = React.useRef(null),
121
+ composedRef = useComposedRefs(accordionRef, forwardedRef),
122
+ getItems = useCollection(__scopeAccordion || ACCORDION_CONTEXT),
123
+ isDirectionLTR = useDirection(dir) === "ltr",
124
+ handleKeyDown = composeEventHandlers(props.onKeyDown, event => {
125
+ if (!ACCORDION_KEYS.includes(event.key)) return;
126
+ const target = event.target,
127
+ triggerCollection = getItems().filter(item => !item.ref.current?.disabled),
128
+ triggerIndex = triggerCollection.findIndex(item => item.ref.current === target),
129
+ triggerCount = triggerCollection.length;
130
+ if (triggerIndex === -1) return;
131
+ event.preventDefault();
132
+ let nextIndex = triggerIndex;
133
+ const homeIndex = 0,
134
+ endIndex = triggerCount - 1,
135
+ moveNext = () => {
136
+ nextIndex = triggerIndex + 1, nextIndex > endIndex && (nextIndex = homeIndex);
137
+ },
138
+ movePrev = () => {
139
+ nextIndex = triggerIndex - 1, nextIndex < homeIndex && (nextIndex = endIndex);
140
+ };
141
+ switch (event.key) {
142
+ case "Home":
143
+ nextIndex = homeIndex;
144
+ break;
145
+ case "End":
146
+ nextIndex = endIndex;
147
+ break;
148
+ case "ArrowRight":
149
+ orientation === "horizontal" && (isDirectionLTR ? moveNext() : movePrev());
150
+ break;
151
+ case "ArrowDown":
152
+ orientation === "vertical" && moveNext();
153
+ break;
154
+ case "ArrowLeft":
155
+ orientation === "horizontal" && (isDirectionLTR ? movePrev() : moveNext());
156
+ break;
157
+ case "ArrowUp":
158
+ orientation === "vertical" && movePrev();
159
+ break;
160
+ }
161
+ const clampedIndex = nextIndex % triggerCount;
162
+ triggerCollection[clampedIndex].ref.current?.focus();
163
+ });
164
+ return /* @__PURE__ */jsx(AccordionImplProvider, {
165
+ scope: __scopeAccordion,
166
+ disabled,
167
+ direction: dir,
168
+ orientation,
169
+ children: /* @__PURE__ */jsx(Collection.Slot, {
170
+ __scopeCollection: __scopeAccordion || ACCORDION_CONTEXT,
171
+ children: /* @__PURE__ */jsx(YStack, {
172
+ "data-orientation": orientation,
173
+ ref: composedRef,
174
+ ...accordionProps,
175
+ ...(isWeb && {
176
+ onKeyDown: handleKeyDown
177
+ })
178
+ })
179
+ })
180
+ });
181
+ }),
182
+ ITEM_NAME = "AccordionItem",
183
+ {
184
+ Provider: AccordionItemProvider,
185
+ useStyledContext: useAccordionItemContext
186
+ } = createStyledContext(),
187
+ AccordionItem = React.forwardRef((props, forwardedRef) => {
188
+ const {
189
+ __scopeAccordion,
190
+ value,
191
+ ...accordionItemProps
192
+ } = props,
193
+ accordionContext = useAccordionContext(__scopeAccordion),
194
+ valueContext = useAccordionValueContext(__scopeAccordion),
195
+ triggerId = React.useId(),
196
+ open = value && valueContext.value.includes(value) || !1,
197
+ disabled = accordionContext.disabled || props.disabled;
198
+ return /* @__PURE__ */jsx(AccordionItemProvider, {
199
+ scope: __scopeAccordion,
200
+ open,
201
+ disabled,
202
+ triggerId,
203
+ children: /* @__PURE__ */jsx(Collapsible, {
204
+ "data-orientation": accordionContext.orientation,
205
+ "data-state": open ? "open" : "closed",
206
+ __scopeCollapsible: __scopeAccordion || ACCORDION_CONTEXT,
207
+ ...accordionItemProps,
208
+ ref: forwardedRef,
209
+ disabled,
210
+ open,
211
+ onOpenChange: open2 => {
212
+ open2 ? valueContext.onItemOpen(value) : valueContext.onItemClose(value);
213
+ }
214
+ })
215
+ });
216
+ });
217
+ AccordionItem.displayName = ITEM_NAME;
218
+ const HEADER_NAME = "AccordionHeader",
219
+ AccordionHeader = React.forwardRef((props, forwardedRef) => {
220
+ const {
221
+ __scopeAccordion,
222
+ ...headerProps
223
+ } = props,
224
+ accordionContext = useAccordionContext(__scopeAccordion),
225
+ itemContext = useAccordionItemContext(__scopeAccordion);
226
+ return /* @__PURE__ */jsx(H1, {
227
+ "data-orientation": accordionContext.orientation,
228
+ "data-state": getState(itemContext.open),
229
+ "data-disabled": itemContext.disabled ? "" : void 0,
230
+ ...headerProps,
231
+ ref: forwardedRef
232
+ });
233
+ });
234
+ AccordionHeader.displayName = HEADER_NAME;
235
+ const AccordionTriggerFrame = styled(Collapsible.Trigger, {
236
+ variants: {
237
+ unstyled: {
238
+ false: {
239
+ cursor: "pointer",
240
+ backgroundColor: "$background",
241
+ borderColor: "$borderColor",
242
+ borderWidth: 1,
243
+ padding: "$true",
244
+ hoverStyle: {
245
+ backgroundColor: "$backgroundHover"
246
+ },
247
+ focusStyle: {
248
+ backgroundColor: "$backgroundFocus"
249
+ },
250
+ pressStyle: {
251
+ backgroundColor: "$backgroundPress"
252
+ }
253
+ }
254
+ }
255
+ },
256
+ defaultVariants: {
257
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
258
+ }
259
+ }),
260
+ AccordionTrigger = AccordionTriggerFrame.styleable(function (props, forwardedRef) {
261
+ const {
262
+ __scopeAccordion,
263
+ ...triggerProps
264
+ } = props,
265
+ accordionContext = useAccordionContext(__scopeAccordion),
266
+ itemContext = useAccordionItemContext(__scopeAccordion),
267
+ collapsibleContext = useAccordionCollapsibleContext(__scopeAccordion);
268
+ return /* @__PURE__ */jsx(Collection.ItemSlot, {
269
+ __scopeCollection: __scopeAccordion || ACCORDION_CONTEXT,
270
+ children: /* @__PURE__ */jsx(AccordionTriggerFrame, {
271
+ __scopeCollapsible: __scopeAccordion || ACCORDION_CONTEXT,
272
+ "aria-disabled": itemContext.open && !collapsibleContext.collapsible || void 0,
273
+ "data-orientation": accordionContext.orientation,
274
+ id: itemContext.triggerId,
275
+ ...triggerProps,
276
+ ref: forwardedRef
277
+ })
278
+ });
279
+ }),
280
+ AccordionContentFrame = styled(Collapsible.Content, {
281
+ variants: {
282
+ unstyled: {
283
+ false: {
284
+ padding: "$true",
285
+ backgroundColor: "$background"
286
+ }
287
+ }
288
+ },
289
+ defaultVariants: {
290
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
291
+ }
292
+ }),
293
+ AccordionContent = AccordionContentFrame.styleable(function (props, forwardedRef) {
294
+ const {
295
+ __scopeAccordion,
296
+ ...contentProps
297
+ } = props,
298
+ accordionContext = useAccordionContext(__scopeAccordion),
299
+ itemContext = useAccordionItemContext(__scopeAccordion);
300
+ return /* @__PURE__ */jsx(AccordionContentFrame, {
301
+ role: "region",
302
+ "aria-labelledby": itemContext.triggerId,
303
+ "data-orientation": accordionContext.orientation,
304
+ __scopeCollapsible: __scopeAccordion || ACCORDION_CONTEXT,
305
+ ...contentProps,
306
+ ref: forwardedRef
307
+ });
308
+ });
309
+ function getState(open) {
310
+ return open ? "open" : "closed";
311
+ }
312
+ const Accordion = withStaticProperties(AccordionComponent, {
313
+ Trigger: AccordionTrigger,
314
+ Header: AccordionHeader,
315
+ Content: AccordionContent,
316
+ Item: AccordionItem
317
+ });
318
+ export { Accordion };
@@ -0,0 +1 @@
1
+ export * from "./Accordion.mjs";
@@ -0,0 +1,318 @@
1
+ import { Collapsible } from "@tamagui/collapsible";
2
+ import { createCollection } from "@tamagui/collection";
3
+ import { useComposedRefs } from "@tamagui/compose-refs";
4
+ import { isWeb } from "@tamagui/constants";
5
+ import { composeEventHandlers, withStaticProperties } from "@tamagui/helpers";
6
+ import { YStack } from "@tamagui/stacks";
7
+ import { H1 } from "@tamagui/text";
8
+ import { useControllableState } from "@tamagui/use-controllable-state";
9
+ import { useDirection } from "@tamagui/use-direction";
10
+ import { createStyledContext, styled } from "@tamagui/web";
11
+ import * as React from "react";
12
+ import { jsx } from "react/jsx-runtime";
13
+ const ACCORDION_NAME = "Accordion",
14
+ ACCORDION_KEYS = ["Home", "End", "ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"],
15
+ [Collection, useCollection] = createCollection(ACCORDION_NAME),
16
+ ACCORDION_CONTEXT = "Accordion",
17
+ AccordionComponent = React.forwardRef((props, forwardedRef) => {
18
+ const {
19
+ type,
20
+ ...accordionProps
21
+ } = props,
22
+ singleProps = accordionProps,
23
+ multipleProps = accordionProps;
24
+ return /* @__PURE__ */jsx(Collection.Provider, {
25
+ __scopeCollection: props.__scopeAccordion || ACCORDION_CONTEXT,
26
+ children: type === "multiple" ? /* @__PURE__ */jsx(AccordionImplMultiple, {
27
+ ...multipleProps,
28
+ ref: forwardedRef
29
+ }) : /* @__PURE__ */jsx(AccordionImplSingle, {
30
+ ...singleProps,
31
+ ref: forwardedRef
32
+ })
33
+ });
34
+ });
35
+ AccordionComponent.displayName = ACCORDION_NAME;
36
+ AccordionComponent.propTypes = {
37
+ type(props) {
38
+ const value = props.value || props.defaultValue;
39
+ return props.type && !["single", "multiple"].includes(props.type) ? new Error("Invalid prop `type` supplied to `Accordion`. Expected one of `single | multiple`.") : props.type === "multiple" && typeof value == "string" ? new Error("Invalid prop `type` supplied to `Accordion`. Expected `single` when `defaultValue` or `value` is type `string`.") : props.type === "single" && Array.isArray(value) ? new Error("Invalid prop `type` supplied to `Accordion`. Expected `multiple` when `defaultValue` or `value` is type `string[]`.") : null;
40
+ }
41
+ };
42
+ const {
43
+ Provider: AccordionValueProvider,
44
+ useStyledContext: useAccordionValueContext
45
+ } = createStyledContext(),
46
+ {
47
+ Provider: AccordionCollapsibleProvider,
48
+ useStyledContext: useAccordionCollapsibleContext
49
+ } = createStyledContext(),
50
+ AccordionImplSingle = React.forwardRef((props, forwardedRef) => {
51
+ const {
52
+ value: valueProp,
53
+ defaultValue,
54
+ control,
55
+ onValueChange = () => {},
56
+ collapsible = !1,
57
+ ...accordionSingleProps
58
+ } = props,
59
+ [value, setValue] = useControllableState({
60
+ prop: valueProp,
61
+ defaultProp: defaultValue || "",
62
+ onChange: onValueChange
63
+ });
64
+ return /* @__PURE__ */jsx(AccordionValueProvider, {
65
+ scope: props.__scopeAccordion,
66
+ value: value ? [value] : [],
67
+ onItemOpen: setValue,
68
+ onItemClose: React.useCallback(() => collapsible && setValue(""), [setValue, collapsible]),
69
+ children: /* @__PURE__ */jsx(AccordionCollapsibleProvider, {
70
+ scope: props.__scopeAccordion,
71
+ collapsible,
72
+ children: /* @__PURE__ */jsx(AccordionImpl, {
73
+ ...accordionSingleProps,
74
+ ref: forwardedRef
75
+ })
76
+ })
77
+ });
78
+ }),
79
+ AccordionImplMultiple = React.forwardRef((props, forwardedRef) => {
80
+ const {
81
+ value: valueProp,
82
+ defaultValue,
83
+ onValueChange = () => {},
84
+ ...accordionMultipleProps
85
+ } = props,
86
+ [value, setValue] = useControllableState({
87
+ prop: valueProp,
88
+ defaultProp: defaultValue || [],
89
+ onChange: onValueChange
90
+ }),
91
+ handleItemOpen = React.useCallback(itemValue => setValue((prevValue = []) => [...prevValue, itemValue]), [setValue]),
92
+ handleItemClose = React.useCallback(itemValue => setValue((prevValue = []) => prevValue.filter(value2 => value2 !== itemValue)), [setValue]);
93
+ return /* @__PURE__ */jsx(AccordionValueProvider, {
94
+ scope: props.__scopeAccordion,
95
+ value: value || [],
96
+ onItemOpen: handleItemOpen,
97
+ onItemClose: handleItemClose,
98
+ children: /* @__PURE__ */jsx(AccordionCollapsibleProvider, {
99
+ scope: props.__scopeAccordion,
100
+ collapsible: !0,
101
+ children: /* @__PURE__ */jsx(AccordionImpl, {
102
+ ...accordionMultipleProps,
103
+ ref: forwardedRef
104
+ })
105
+ })
106
+ });
107
+ }),
108
+ {
109
+ Provider: AccordionImplProvider,
110
+ useStyledContext: useAccordionContext
111
+ } = createStyledContext(),
112
+ AccordionImpl = React.forwardRef((props, forwardedRef) => {
113
+ const {
114
+ __scopeAccordion,
115
+ disabled,
116
+ dir,
117
+ orientation = "vertical",
118
+ ...accordionProps
119
+ } = props,
120
+ accordionRef = React.useRef(null),
121
+ composedRef = useComposedRefs(accordionRef, forwardedRef),
122
+ getItems = useCollection(__scopeAccordion || ACCORDION_CONTEXT),
123
+ isDirectionLTR = useDirection(dir) === "ltr",
124
+ handleKeyDown = composeEventHandlers(props.onKeyDown, event => {
125
+ if (!ACCORDION_KEYS.includes(event.key)) return;
126
+ const target = event.target,
127
+ triggerCollection = getItems().filter(item => !item.ref.current?.disabled),
128
+ triggerIndex = triggerCollection.findIndex(item => item.ref.current === target),
129
+ triggerCount = triggerCollection.length;
130
+ if (triggerIndex === -1) return;
131
+ event.preventDefault();
132
+ let nextIndex = triggerIndex;
133
+ const homeIndex = 0,
134
+ endIndex = triggerCount - 1,
135
+ moveNext = () => {
136
+ nextIndex = triggerIndex + 1, nextIndex > endIndex && (nextIndex = homeIndex);
137
+ },
138
+ movePrev = () => {
139
+ nextIndex = triggerIndex - 1, nextIndex < homeIndex && (nextIndex = endIndex);
140
+ };
141
+ switch (event.key) {
142
+ case "Home":
143
+ nextIndex = homeIndex;
144
+ break;
145
+ case "End":
146
+ nextIndex = endIndex;
147
+ break;
148
+ case "ArrowRight":
149
+ orientation === "horizontal" && (isDirectionLTR ? moveNext() : movePrev());
150
+ break;
151
+ case "ArrowDown":
152
+ orientation === "vertical" && moveNext();
153
+ break;
154
+ case "ArrowLeft":
155
+ orientation === "horizontal" && (isDirectionLTR ? movePrev() : moveNext());
156
+ break;
157
+ case "ArrowUp":
158
+ orientation === "vertical" && movePrev();
159
+ break;
160
+ }
161
+ const clampedIndex = nextIndex % triggerCount;
162
+ triggerCollection[clampedIndex].ref.current?.focus();
163
+ });
164
+ return /* @__PURE__ */jsx(AccordionImplProvider, {
165
+ scope: __scopeAccordion,
166
+ disabled,
167
+ direction: dir,
168
+ orientation,
169
+ children: /* @__PURE__ */jsx(Collection.Slot, {
170
+ __scopeCollection: __scopeAccordion || ACCORDION_CONTEXT,
171
+ children: /* @__PURE__ */jsx(YStack, {
172
+ "data-orientation": orientation,
173
+ ref: composedRef,
174
+ ...accordionProps,
175
+ ...(isWeb && {
176
+ onKeyDown: handleKeyDown
177
+ })
178
+ })
179
+ })
180
+ });
181
+ }),
182
+ ITEM_NAME = "AccordionItem",
183
+ {
184
+ Provider: AccordionItemProvider,
185
+ useStyledContext: useAccordionItemContext
186
+ } = createStyledContext(),
187
+ AccordionItem = React.forwardRef((props, forwardedRef) => {
188
+ const {
189
+ __scopeAccordion,
190
+ value,
191
+ ...accordionItemProps
192
+ } = props,
193
+ accordionContext = useAccordionContext(__scopeAccordion),
194
+ valueContext = useAccordionValueContext(__scopeAccordion),
195
+ triggerId = React.useId(),
196
+ open = value && valueContext.value.includes(value) || !1,
197
+ disabled = accordionContext.disabled || props.disabled;
198
+ return /* @__PURE__ */jsx(AccordionItemProvider, {
199
+ scope: __scopeAccordion,
200
+ open,
201
+ disabled,
202
+ triggerId,
203
+ children: /* @__PURE__ */jsx(Collapsible, {
204
+ "data-orientation": accordionContext.orientation,
205
+ "data-state": open ? "open" : "closed",
206
+ __scopeCollapsible: __scopeAccordion || ACCORDION_CONTEXT,
207
+ ...accordionItemProps,
208
+ ref: forwardedRef,
209
+ disabled,
210
+ open,
211
+ onOpenChange: open2 => {
212
+ open2 ? valueContext.onItemOpen(value) : valueContext.onItemClose(value);
213
+ }
214
+ })
215
+ });
216
+ });
217
+ AccordionItem.displayName = ITEM_NAME;
218
+ const HEADER_NAME = "AccordionHeader",
219
+ AccordionHeader = React.forwardRef((props, forwardedRef) => {
220
+ const {
221
+ __scopeAccordion,
222
+ ...headerProps
223
+ } = props,
224
+ accordionContext = useAccordionContext(__scopeAccordion),
225
+ itemContext = useAccordionItemContext(__scopeAccordion);
226
+ return /* @__PURE__ */jsx(H1, {
227
+ "data-orientation": accordionContext.orientation,
228
+ "data-state": getState(itemContext.open),
229
+ "data-disabled": itemContext.disabled ? "" : void 0,
230
+ ...headerProps,
231
+ ref: forwardedRef
232
+ });
233
+ });
234
+ AccordionHeader.displayName = HEADER_NAME;
235
+ const AccordionTriggerFrame = styled(Collapsible.Trigger, {
236
+ variants: {
237
+ unstyled: {
238
+ false: {
239
+ cursor: "pointer",
240
+ backgroundColor: "$background",
241
+ borderColor: "$borderColor",
242
+ borderWidth: 1,
243
+ padding: "$true",
244
+ hoverStyle: {
245
+ backgroundColor: "$backgroundHover"
246
+ },
247
+ focusStyle: {
248
+ backgroundColor: "$backgroundFocus"
249
+ },
250
+ pressStyle: {
251
+ backgroundColor: "$backgroundPress"
252
+ }
253
+ }
254
+ }
255
+ },
256
+ defaultVariants: {
257
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
258
+ }
259
+ }),
260
+ AccordionTrigger = AccordionTriggerFrame.styleable(function (props, forwardedRef) {
261
+ const {
262
+ __scopeAccordion,
263
+ ...triggerProps
264
+ } = props,
265
+ accordionContext = useAccordionContext(__scopeAccordion),
266
+ itemContext = useAccordionItemContext(__scopeAccordion),
267
+ collapsibleContext = useAccordionCollapsibleContext(__scopeAccordion);
268
+ return /* @__PURE__ */jsx(Collection.ItemSlot, {
269
+ __scopeCollection: __scopeAccordion || ACCORDION_CONTEXT,
270
+ children: /* @__PURE__ */jsx(AccordionTriggerFrame, {
271
+ __scopeCollapsible: __scopeAccordion || ACCORDION_CONTEXT,
272
+ "aria-disabled": itemContext.open && !collapsibleContext.collapsible || void 0,
273
+ "data-orientation": accordionContext.orientation,
274
+ id: itemContext.triggerId,
275
+ ...triggerProps,
276
+ ref: forwardedRef
277
+ })
278
+ });
279
+ }),
280
+ AccordionContentFrame = styled(Collapsible.Content, {
281
+ variants: {
282
+ unstyled: {
283
+ false: {
284
+ padding: "$true",
285
+ backgroundColor: "$background"
286
+ }
287
+ }
288
+ },
289
+ defaultVariants: {
290
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
291
+ }
292
+ }),
293
+ AccordionContent = AccordionContentFrame.styleable(function (props, forwardedRef) {
294
+ const {
295
+ __scopeAccordion,
296
+ ...contentProps
297
+ } = props,
298
+ accordionContext = useAccordionContext(__scopeAccordion),
299
+ itemContext = useAccordionItemContext(__scopeAccordion);
300
+ return /* @__PURE__ */jsx(AccordionContentFrame, {
301
+ role: "region",
302
+ "aria-labelledby": itemContext.triggerId,
303
+ "data-orientation": accordionContext.orientation,
304
+ __scopeCollapsible: __scopeAccordion || ACCORDION_CONTEXT,
305
+ ...contentProps,
306
+ ref: forwardedRef
307
+ });
308
+ });
309
+ function getState(open) {
310
+ return open ? "open" : "closed";
311
+ }
312
+ const Accordion = withStaticProperties(AccordionComponent, {
313
+ Trigger: AccordionTrigger,
314
+ Header: AccordionHeader,
315
+ Content: AccordionContent,
316
+ Item: AccordionItem
317
+ });
318
+ export { Accordion };
@@ -0,0 +1 @@
1
+ export * from "./Accordion.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/accordion",
3
- "version": "1.88.13",
3
+ "version": "1.89.0-1706308641099",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -22,21 +22,21 @@
22
22
  "lint:fix": "../../node_modules/.bin/biome check --apply-unsafe src"
23
23
  },
24
24
  "dependencies": {
25
- "@tamagui/collapsible": "1.88.13",
26
- "@tamagui/collection": "1.88.13",
27
- "@tamagui/compose-refs": "1.88.13",
28
- "@tamagui/constants": "1.88.13",
29
- "@tamagui/core": "1.88.13",
30
- "@tamagui/create-context": "1.88.13",
31
- "@tamagui/polyfill-dev": "1.88.13",
32
- "@tamagui/stacks": "1.88.13",
33
- "@tamagui/use-controllable-state": "1.88.13"
25
+ "@tamagui/collapsible": "1.89.0-1706308641099",
26
+ "@tamagui/collection": "1.89.0-1706308641099",
27
+ "@tamagui/compose-refs": "1.89.0-1706308641099",
28
+ "@tamagui/constants": "1.89.0-1706308641099",
29
+ "@tamagui/core": "1.89.0-1706308641099",
30
+ "@tamagui/create-context": "1.89.0-1706308641099",
31
+ "@tamagui/polyfill-dev": "1.89.0-1706308641099",
32
+ "@tamagui/stacks": "1.89.0-1706308641099",
33
+ "@tamagui/use-controllable-state": "1.89.0-1706308641099"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": "*"
37
37
  },
38
38
  "devDependencies": {
39
- "@tamagui/build": "1.88.13",
39
+ "@tamagui/build": "1.89.0-1706308641099",
40
40
  "react": "^18.2.0"
41
41
  },
42
42
  "publishConfig": {