@tamagui/accordion 1.135.4 → 1.135.6

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,294 +1,406 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { Collapsible } from "@tamagui/collapsible";
3
- import { createCollection } from "@tamagui/collection";
4
- import { useComposedRefs } from "@tamagui/compose-refs";
5
- import { isWeb } from "@tamagui/constants";
6
- import { View, createStyledContext, styled } from "@tamagui/core";
7
- import { composeEventHandlers, withStaticProperties } from "@tamagui/helpers";
8
- import { YStack } from "@tamagui/stacks";
9
- import { H1 } from "@tamagui/text";
10
- import { useControllableState } from "@tamagui/use-controllable-state";
11
- import { useDirection } from "@tamagui/use-direction";
12
- import * as React from "react";
13
- var ACCORDION_NAME = "Accordion", ACCORDION_KEYS = [
14
- "Home",
15
- "End",
16
- "ArrowDown",
17
- "ArrowUp",
18
- "ArrowLeft",
19
- "ArrowRight"
20
- ], [Collection, useCollection] = createCollection(ACCORDION_NAME), ACCORDION_CONTEXT = "Accordion", AccordionComponent = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
21
- var { type, ...accordionProps } = props, singleProps = accordionProps, multipleProps = accordionProps;
22
- return /* @__PURE__ */ _jsx(Collection.Provider, {
23
- scope: props.__scopeAccordion || ACCORDION_CONTEXT,
24
- children: type === "multiple" ? /* @__PURE__ */ _jsx(AccordionImplMultiple, {
25
- ...multipleProps,
26
- ref: forwardedRef
27
- }) : /* @__PURE__ */ _jsx(AccordionImplSingle, {
28
- ...singleProps,
29
- ref: forwardedRef
30
- })
31
- });
1
+ "use strict";
2
+
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf,
8
+ __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: !0
13
+ });
14
+ },
15
+ __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
+ value: mod,
29
+ enumerable: !0
30
+ }) : target, mod)),
31
+ __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
+ value: !0
33
+ }), mod);
34
+ var Accordion_exports = {};
35
+ __export(Accordion_exports, {
36
+ Accordion: () => Accordion
32
37
  });
38
+ module.exports = __toCommonJS(Accordion_exports);
39
+ var import_jsx_runtime = require("react/jsx-runtime"),
40
+ import_collapsible = require("@tamagui/collapsible"),
41
+ import_collection = require("@tamagui/collection"),
42
+ import_compose_refs = require("@tamagui/compose-refs"),
43
+ import_constants = require("@tamagui/constants"),
44
+ import_core = require("@tamagui/core"),
45
+ import_helpers = require("@tamagui/helpers"),
46
+ import_stacks = require("@tamagui/stacks"),
47
+ import_text = require("@tamagui/text"),
48
+ import_use_controllable_state = require("@tamagui/use-controllable-state"),
49
+ import_use_direction = require("@tamagui/use-direction"),
50
+ React = __toESM(require("react"), 1),
51
+ ACCORDION_NAME = "Accordion",
52
+ ACCORDION_KEYS = ["Home", "End", "ArrowDown", "ArrowUp", "ArrowLeft", "ArrowRight"],
53
+ [Collection, useCollection] = (0, import_collection.createCollection)(ACCORDION_NAME),
54
+ ACCORDION_CONTEXT = "Accordion",
55
+ AccordionComponent = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
56
+ var {
57
+ type,
58
+ ...accordionProps
59
+ } = props,
60
+ singleProps = accordionProps,
61
+ multipleProps = accordionProps;
62
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Collection.Provider, {
63
+ scope: props.__scopeAccordion || ACCORDION_CONTEXT,
64
+ children: type === "multiple" ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(AccordionImplMultiple, {
65
+ ...multipleProps,
66
+ ref: forwardedRef
67
+ }) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(AccordionImplSingle, {
68
+ ...singleProps,
69
+ ref: forwardedRef
70
+ })
71
+ });
72
+ });
33
73
  AccordionComponent.displayName = ACCORDION_NAME;
34
74
  AccordionComponent.propTypes = {
35
75
  type(props) {
36
76
  var value = props.value || props.defaultValue;
37
- return props.type && ![
38
- "single",
39
- "multiple"
40
- ].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;
77
+ 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;
41
78
  }
42
79
  };
43
- var { Provider: AccordionValueProvider, useStyledContext: useAccordionValueContext } = createStyledContext(), { Provider: AccordionCollapsibleProvider, useStyledContext: useAccordionCollapsibleContext } = createStyledContext(), AccordionImplSingle = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
44
- var { value: valueProp, defaultValue, control, onValueChange = function() {
45
- }, collapsible = !1, ...accordionSingleProps } = props, [value, setValue] = useControllableState({
46
- prop: valueProp,
47
- defaultProp: defaultValue || "",
48
- onChange: onValueChange
49
- });
50
- return /* @__PURE__ */ _jsx(AccordionValueProvider, {
51
- scope: props.__scopeAccordion,
52
- value: value ? [
53
- value
54
- ] : [],
55
- onItemOpen: setValue,
56
- onItemClose: React.useCallback(function() {
57
- return collapsible && setValue("");
58
- }, [
59
- setValue,
60
- collapsible
61
- ]),
62
- children: /* @__PURE__ */ _jsx(AccordionCollapsibleProvider, {
80
+ var {
81
+ Provider: AccordionValueProvider,
82
+ useStyledContext: useAccordionValueContext
83
+ } = (0, import_core.createStyledContext)(),
84
+ {
85
+ Provider: AccordionCollapsibleProvider,
86
+ useStyledContext: useAccordionCollapsibleContext
87
+ } = (0, import_core.createStyledContext)(),
88
+ AccordionImplSingle = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
89
+ var {
90
+ value: valueProp,
91
+ defaultValue,
92
+ control,
93
+ onValueChange = function () {},
94
+ collapsible = !1,
95
+ ...accordionSingleProps
96
+ } = props,
97
+ [value, setValue] = (0, import_use_controllable_state.useControllableState)({
98
+ prop: valueProp,
99
+ defaultProp: defaultValue || "",
100
+ onChange: onValueChange
101
+ });
102
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(AccordionValueProvider, {
63
103
  scope: props.__scopeAccordion,
64
- collapsible,
65
- children: /* @__PURE__ */ _jsx(AccordionImpl, {
66
- ...accordionSingleProps,
67
- ref: forwardedRef
104
+ value: value ? [value] : [],
105
+ onItemOpen: setValue,
106
+ onItemClose: React.useCallback(function () {
107
+ return collapsible && setValue("");
108
+ }, [setValue, collapsible]),
109
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AccordionCollapsibleProvider, {
110
+ scope: props.__scopeAccordion,
111
+ collapsible,
112
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AccordionImpl, {
113
+ ...accordionSingleProps,
114
+ ref: forwardedRef
115
+ })
68
116
  })
69
- })
70
- });
71
- }), AccordionImplMultiple = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
72
- var { value: valueProp, defaultValue, onValueChange = function() {
73
- }, ...accordionMultipleProps } = props, [value, setValue] = useControllableState({
74
- prop: valueProp,
75
- defaultProp: defaultValue || [],
76
- onChange: onValueChange
77
- }), handleItemOpen = React.useCallback(function(itemValue) {
78
- return setValue(function() {
79
- var prevValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
80
- return [
81
- ...prevValue,
82
- itemValue
83
- ];
84
- });
85
- }, [
86
- setValue
87
- ]), handleItemClose = React.useCallback(function(itemValue) {
88
- return setValue(function() {
89
- var prevValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
90
- return prevValue.filter(function(value2) {
91
- return value2 !== itemValue;
92
- });
93
117
  });
94
- }, [
95
- setValue
96
- ]);
97
- return /* @__PURE__ */ _jsx(AccordionValueProvider, {
98
- scope: props.__scopeAccordion,
99
- value: value || [],
100
- onItemOpen: handleItemOpen,
101
- onItemClose: handleItemClose,
102
- children: /* @__PURE__ */ _jsx(AccordionCollapsibleProvider, {
118
+ }),
119
+ AccordionImplMultiple = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
120
+ var {
121
+ value: valueProp,
122
+ defaultValue,
123
+ onValueChange = function () {},
124
+ ...accordionMultipleProps
125
+ } = props,
126
+ [value, setValue] = (0, import_use_controllable_state.useControllableState)({
127
+ prop: valueProp,
128
+ defaultProp: defaultValue || [],
129
+ onChange: onValueChange
130
+ }),
131
+ handleItemOpen = React.useCallback(function (itemValue) {
132
+ return setValue(function () {
133
+ var prevValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
134
+ return [...prevValue, itemValue];
135
+ });
136
+ }, [setValue]),
137
+ handleItemClose = React.useCallback(function (itemValue) {
138
+ return setValue(function () {
139
+ var prevValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
140
+ return prevValue.filter(function (value2) {
141
+ return value2 !== itemValue;
142
+ });
143
+ });
144
+ }, [setValue]);
145
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(AccordionValueProvider, {
103
146
  scope: props.__scopeAccordion,
104
- collapsible: !0,
105
- children: /* @__PURE__ */ _jsx(AccordionImpl, {
106
- ...accordionMultipleProps,
107
- ref: forwardedRef
147
+ value: value || [],
148
+ onItemOpen: handleItemOpen,
149
+ onItemClose: handleItemClose,
150
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AccordionCollapsibleProvider, {
151
+ scope: props.__scopeAccordion,
152
+ collapsible: !0,
153
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AccordionImpl, {
154
+ ...accordionMultipleProps,
155
+ ref: forwardedRef
156
+ })
108
157
  })
109
- })
110
- });
111
- }), { Provider: AccordionImplProvider, useStyledContext: useAccordionContext } = createStyledContext(), AccordionImpl = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
112
- var { __scopeAccordion, disabled, dir, orientation = "vertical", ...accordionProps } = props, accordionRef = React.useRef(null), composedRef = useComposedRefs(accordionRef, forwardedRef), getItems = useCollection(__scopeAccordion || ACCORDION_CONTEXT), direction = useDirection(dir), isDirectionLTR = direction === "ltr", handleKeyDown = composeEventHandlers(props.onKeyDown, function(event) {
113
- var _triggerCollection_clampedIndex_ref_current;
114
- if (ACCORDION_KEYS.includes(event.key)) {
115
- var target = event.target, triggerCollection = getItems().filter(function(item) {
116
- var el = item.ref.current;
117
- return !(el != null && el.disabled);
118
- }), triggerIndex = triggerCollection.findIndex(function(item) {
119
- return item.ref.current === target;
120
- }), triggerCount = triggerCollection.length;
121
- if (triggerIndex !== -1) {
122
- event.preventDefault();
123
- var nextIndex = triggerIndex, homeIndex = 0, endIndex = triggerCount - 1, moveNext = function() {
124
- nextIndex = triggerIndex + 1, nextIndex > endIndex && (nextIndex = homeIndex);
125
- }, movePrev = function() {
126
- nextIndex = triggerIndex - 1, nextIndex < homeIndex && (nextIndex = endIndex);
127
- };
128
- switch (event.key) {
129
- case "Home":
130
- nextIndex = homeIndex;
131
- break;
132
- case "End":
133
- nextIndex = endIndex;
134
- break;
135
- case "ArrowRight":
136
- orientation === "horizontal" && (isDirectionLTR ? moveNext() : movePrev());
137
- break;
138
- case "ArrowDown":
139
- orientation === "vertical" && moveNext();
140
- break;
141
- case "ArrowLeft":
142
- orientation === "horizontal" && (isDirectionLTR ? movePrev() : moveNext());
143
- break;
144
- case "ArrowUp":
145
- orientation === "vertical" && movePrev();
146
- break;
147
- }
148
- var clampedIndex = nextIndex % triggerCount;
149
- (_triggerCollection_clampedIndex_ref_current = triggerCollection[clampedIndex].ref.current) === null || _triggerCollection_clampedIndex_ref_current === void 0 || _triggerCollection_clampedIndex_ref_current.focus();
150
- }
151
- }
152
- });
153
- return /* @__PURE__ */ _jsx(AccordionImplProvider, {
154
- scope: __scopeAccordion,
155
- disabled,
156
- direction: dir,
157
- orientation,
158
- children: /* @__PURE__ */ _jsx(Collection.Slot, {
159
- scope: __scopeAccordion || ACCORDION_CONTEXT,
160
- children: /* @__PURE__ */ _jsx(YStack, {
161
- "data-orientation": orientation,
162
- ref: composedRef,
163
- ...accordionProps,
164
- ...isWeb && {
165
- onKeyDown: handleKeyDown
158
+ });
159
+ }),
160
+ {
161
+ Provider: AccordionImplProvider,
162
+ useStyledContext: useAccordionContext
163
+ } = (0, import_core.createStyledContext)(),
164
+ AccordionImpl = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
165
+ var {
166
+ __scopeAccordion,
167
+ disabled,
168
+ dir,
169
+ orientation = "vertical",
170
+ ...accordionProps
171
+ } = props,
172
+ accordionRef = React.useRef(null),
173
+ composedRef = (0, import_compose_refs.useComposedRefs)(accordionRef, forwardedRef),
174
+ getItems = useCollection(__scopeAccordion || ACCORDION_CONTEXT),
175
+ direction = (0, import_use_direction.useDirection)(dir),
176
+ isDirectionLTR = direction === "ltr",
177
+ handleKeyDown = (0, import_helpers.composeEventHandlers)(props.onKeyDown, function (event) {
178
+ var _triggerCollection_clampedIndex_ref_current;
179
+ if (ACCORDION_KEYS.includes(event.key)) {
180
+ var target = event.target,
181
+ triggerCollection = getItems().filter(function (item) {
182
+ var el = item.ref.current;
183
+ return !el?.disabled;
184
+ }),
185
+ triggerIndex = triggerCollection.findIndex(function (item) {
186
+ return item.ref.current === target;
187
+ }),
188
+ triggerCount = triggerCollection.length;
189
+ if (triggerIndex !== -1) {
190
+ event.preventDefault();
191
+ var nextIndex = triggerIndex,
192
+ homeIndex = 0,
193
+ endIndex = triggerCount - 1,
194
+ moveNext = function () {
195
+ nextIndex = triggerIndex + 1, nextIndex > endIndex && (nextIndex = homeIndex);
196
+ },
197
+ movePrev = function () {
198
+ nextIndex = triggerIndex - 1, nextIndex < homeIndex && (nextIndex = endIndex);
199
+ };
200
+ switch (event.key) {
201
+ case "Home":
202
+ nextIndex = homeIndex;
203
+ break;
204
+ case "End":
205
+ nextIndex = endIndex;
206
+ break;
207
+ case "ArrowRight":
208
+ orientation === "horizontal" && (isDirectionLTR ? moveNext() : movePrev());
209
+ break;
210
+ case "ArrowDown":
211
+ orientation === "vertical" && moveNext();
212
+ break;
213
+ case "ArrowLeft":
214
+ orientation === "horizontal" && (isDirectionLTR ? movePrev() : moveNext());
215
+ break;
216
+ case "ArrowUp":
217
+ orientation === "vertical" && movePrev();
218
+ break;
219
+ }
220
+ var clampedIndex = nextIndex % triggerCount;
221
+ (_triggerCollection_clampedIndex_ref_current = triggerCollection[clampedIndex].ref.current) === null || _triggerCollection_clampedIndex_ref_current === void 0 || _triggerCollection_clampedIndex_ref_current.focus();
222
+ }
166
223
  }
167
- })
168
- })
169
- });
170
- }), ITEM_NAME = "AccordionItem", { Provider: AccordionItemProvider, useStyledContext: useAccordionItemContext } = createStyledContext(), AccordionItem = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
171
- var { __scopeAccordion, value, ...accordionItemProps } = props, accordionContext = useAccordionContext(__scopeAccordion), valueContext = useAccordionValueContext(__scopeAccordion), triggerId = React.useId(), open = value && valueContext.value.includes(value) || !1, disabled = accordionContext.disabled || props.disabled;
172
- return /* @__PURE__ */ _jsx(AccordionItemProvider, {
173
- scope: __scopeAccordion,
174
- open,
175
- disabled,
176
- triggerId,
177
- children: /* @__PURE__ */ _jsx(Collapsible, {
178
- "data-orientation": accordionContext.orientation,
179
- "data-state": open ? "open" : "closed",
180
- __scopeCollapsible: __scopeAccordion || ACCORDION_CONTEXT,
181
- ...accordionItemProps,
182
- ref: forwardedRef,
224
+ });
225
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(AccordionImplProvider, {
226
+ scope: __scopeAccordion,
183
227
  disabled,
228
+ direction: dir,
229
+ orientation,
230
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(Collection.Slot, {
231
+ scope: __scopeAccordion || ACCORDION_CONTEXT,
232
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_stacks.YStack, {
233
+ "data-orientation": orientation,
234
+ ref: composedRef,
235
+ ...accordionProps,
236
+ ...(import_constants.isWeb && {
237
+ onKeyDown: handleKeyDown
238
+ })
239
+ })
240
+ })
241
+ });
242
+ }),
243
+ ITEM_NAME = "AccordionItem",
244
+ {
245
+ Provider: AccordionItemProvider,
246
+ useStyledContext: useAccordionItemContext
247
+ } = (0, import_core.createStyledContext)(),
248
+ AccordionItem = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
249
+ var {
250
+ __scopeAccordion,
251
+ value,
252
+ ...accordionItemProps
253
+ } = props,
254
+ accordionContext = useAccordionContext(__scopeAccordion),
255
+ valueContext = useAccordionValueContext(__scopeAccordion),
256
+ triggerId = React.useId(),
257
+ open = value && valueContext.value.includes(value) || !1,
258
+ disabled = accordionContext.disabled || props.disabled;
259
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(AccordionItemProvider, {
260
+ scope: __scopeAccordion,
184
261
  open,
185
- onOpenChange: function(open2) {
186
- open2 ? valueContext.onItemOpen(value) : valueContext.onItemClose(value);
187
- }
188
- })
262
+ disabled,
263
+ triggerId,
264
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_collapsible.Collapsible, {
265
+ "data-orientation": accordionContext.orientation,
266
+ "data-state": open ? "open" : "closed",
267
+ __scopeCollapsible: __scopeAccordion || ACCORDION_CONTEXT,
268
+ ...accordionItemProps,
269
+ ref: forwardedRef,
270
+ disabled,
271
+ open,
272
+ onOpenChange: function (open2) {
273
+ open2 ? valueContext.onItemOpen(value) : valueContext.onItemClose(value);
274
+ }
275
+ })
276
+ });
189
277
  });
190
- });
191
278
  AccordionItem.displayName = ITEM_NAME;
192
- var HEADER_NAME = "AccordionHeader", AccordionHeader = /* @__PURE__ */ React.forwardRef(function(props, forwardedRef) {
193
- var { __scopeAccordion, ...headerProps } = props, accordionContext = useAccordionContext(__scopeAccordion), itemContext = useAccordionItemContext(__scopeAccordion);
194
- return /* @__PURE__ */ _jsx(H1, {
195
- "data-orientation": accordionContext.orientation,
196
- "data-state": getState(itemContext.open),
197
- "data-disabled": itemContext.disabled ? "" : void 0,
198
- ...headerProps,
199
- ref: forwardedRef
279
+ var HEADER_NAME = "AccordionHeader",
280
+ AccordionHeader = /* @__PURE__ */React.forwardRef(function (props, forwardedRef) {
281
+ var {
282
+ __scopeAccordion,
283
+ ...headerProps
284
+ } = props,
285
+ accordionContext = useAccordionContext(__scopeAccordion),
286
+ itemContext = useAccordionItemContext(__scopeAccordion);
287
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_text.H1, {
288
+ "data-orientation": accordionContext.orientation,
289
+ "data-state": getState(itemContext.open),
290
+ "data-disabled": itemContext.disabled ? "" : void 0,
291
+ ...headerProps,
292
+ ref: forwardedRef
293
+ });
200
294
  });
201
- });
202
295
  AccordionHeader.displayName = HEADER_NAME;
203
- var AccordionTriggerFrame = styled(Collapsible.Trigger, {
204
- variants: {
205
- unstyled: {
206
- false: {
207
- cursor: "pointer",
208
- backgroundColor: "$background",
209
- borderColor: "$borderColor",
210
- borderWidth: 1,
211
- padding: "$true",
212
- hoverStyle: {
213
- backgroundColor: "$backgroundHover"
214
- },
215
- focusStyle: {
216
- backgroundColor: "$backgroundFocus"
217
- },
218
- pressStyle: {
219
- backgroundColor: "$backgroundPress"
296
+ var AccordionTriggerFrame = (0, import_core.styled)(import_collapsible.Collapsible.Trigger, {
297
+ variants: {
298
+ unstyled: {
299
+ false: {
300
+ cursor: "pointer",
301
+ backgroundColor: "$background",
302
+ borderColor: "$borderColor",
303
+ borderWidth: 1,
304
+ padding: "$true",
305
+ hoverStyle: {
306
+ backgroundColor: "$backgroundHover"
307
+ },
308
+ focusStyle: {
309
+ backgroundColor: "$backgroundFocus"
310
+ },
311
+ pressStyle: {
312
+ backgroundColor: "$backgroundPress"
313
+ }
220
314
  }
221
315
  }
316
+ },
317
+ defaultVariants: {
318
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
222
319
  }
223
- },
224
- defaultVariants: {
225
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
226
- }
227
- }), AccordionTrigger = AccordionTriggerFrame.styleable(function(props, forwardedRef) {
228
- var { __scopeAccordion, ...triggerProps } = props, accordionContext = useAccordionContext(__scopeAccordion), itemContext = useAccordionItemContext(__scopeAccordion), collapsibleContext = useAccordionCollapsibleContext(__scopeAccordion);
229
- return /* @__PURE__ */ _jsx(Collection.ItemSlot, {
230
- scope: __scopeAccordion || ACCORDION_CONTEXT,
231
- children: /* @__PURE__ */ _jsx(AccordionTriggerFrame, {
232
- // @ts-ignore
233
- __scopeCollapsible: __scopeAccordion || ACCORDION_CONTEXT,
234
- "aria-disabled": itemContext.open && !collapsibleContext.collapsible || void 0,
235
- "data-orientation": accordionContext.orientation,
236
- id: itemContext.triggerId,
237
- ...triggerProps,
238
- ref: forwardedRef
239
- })
240
- });
241
- }), AccordionContentFrame = styled(Collapsible.Content, {
242
- variants: {
243
- unstyled: {
244
- false: {
245
- padding: "$true",
246
- backgroundColor: "$background"
320
+ }),
321
+ AccordionTrigger = AccordionTriggerFrame.styleable(function (props, forwardedRef) {
322
+ var {
323
+ __scopeAccordion,
324
+ ...triggerProps
325
+ } = props,
326
+ accordionContext = useAccordionContext(__scopeAccordion),
327
+ itemContext = useAccordionItemContext(__scopeAccordion),
328
+ collapsibleContext = useAccordionCollapsibleContext(__scopeAccordion);
329
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(Collection.ItemSlot, {
330
+ scope: __scopeAccordion || ACCORDION_CONTEXT,
331
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(AccordionTriggerFrame, {
332
+ // @ts-ignore
333
+ __scopeCollapsible: __scopeAccordion || ACCORDION_CONTEXT,
334
+ "aria-disabled": itemContext.open && !collapsibleContext.collapsible || void 0,
335
+ "data-orientation": accordionContext.orientation,
336
+ id: itemContext.triggerId,
337
+ ...triggerProps,
338
+ ref: forwardedRef
339
+ })
340
+ });
341
+ }),
342
+ AccordionContentFrame = (0, import_core.styled)(import_collapsible.Collapsible.Content, {
343
+ variants: {
344
+ unstyled: {
345
+ false: {
346
+ padding: "$true",
347
+ backgroundColor: "$background"
348
+ }
247
349
  }
350
+ },
351
+ defaultVariants: {
352
+ unstyled: process.env.TAMAGUI_HEADLESS === "1"
248
353
  }
249
- },
250
- defaultVariants: {
251
- unstyled: process.env.TAMAGUI_HEADLESS === "1"
252
- }
253
- }), AccordionContent = AccordionContentFrame.styleable(function(props, forwardedRef) {
254
- var { __scopeAccordion, ...contentProps } = props, accordionContext = useAccordionContext(__scopeAccordion), itemContext = useAccordionItemContext(__scopeAccordion);
255
- return /* @__PURE__ */ _jsx(AccordionContentFrame, {
256
- role: "region",
257
- "aria-labelledby": itemContext.triggerId,
258
- "data-orientation": accordionContext.orientation,
259
- // @ts-ignore
260
- __scopeCollapsible: __scopeAccordion || ACCORDION_CONTEXT,
261
- ...contentProps,
262
- ref: forwardedRef
263
- });
264
- }), HeightAnimator = View.styleable(function(props, ref) {
265
- var itemContext = useAccordionItemContext(), { children, ...rest } = props, [height, setHeight] = React.useState(0);
266
- return /* @__PURE__ */ _jsx(View, {
267
- ref,
268
- height: itemContext.open ? height : 0,
269
- ...rest,
270
- children: /* @__PURE__ */ _jsx(View, {
271
- position: "absolute",
272
- width: "100%",
273
- onLayout: function(param) {
274
- var { nativeEvent } = param;
275
- nativeEvent.layout.height && setHeight(nativeEvent.layout.height);
276
- },
277
- children
278
- })
354
+ }),
355
+ AccordionContent = AccordionContentFrame.styleable(function (props, forwardedRef) {
356
+ var {
357
+ __scopeAccordion,
358
+ ...contentProps
359
+ } = props,
360
+ accordionContext = useAccordionContext(__scopeAccordion),
361
+ itemContext = useAccordionItemContext(__scopeAccordion);
362
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(AccordionContentFrame, {
363
+ role: "region",
364
+ "aria-labelledby": itemContext.triggerId,
365
+ "data-orientation": accordionContext.orientation,
366
+ // @ts-ignore
367
+ __scopeCollapsible: __scopeAccordion || ACCORDION_CONTEXT,
368
+ ...contentProps,
369
+ ref: forwardedRef
370
+ });
371
+ }),
372
+ HeightAnimator = import_core.View.styleable(function (props, ref) {
373
+ var itemContext = useAccordionItemContext(),
374
+ {
375
+ children,
376
+ ...rest
377
+ } = props,
378
+ [height, setHeight] = React.useState(0);
379
+ return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.View, {
380
+ ref,
381
+ height: itemContext.open ? height : 0,
382
+ ...rest,
383
+ children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.View, {
384
+ position: "absolute",
385
+ width: "100%",
386
+ onLayout: function (param) {
387
+ var {
388
+ nativeEvent
389
+ } = param;
390
+ nativeEvent.layout.height && setHeight(nativeEvent.layout.height);
391
+ },
392
+ children
393
+ })
394
+ });
279
395
  });
280
- });
281
396
  function getState(open) {
282
397
  return open ? "open" : "closed";
283
398
  }
284
- var Accordion = withStaticProperties(AccordionComponent, {
399
+ var Accordion = (0, import_helpers.withStaticProperties)(AccordionComponent, {
285
400
  Trigger: AccordionTrigger,
286
401
  Header: AccordionHeader,
287
402
  Content: AccordionContent,
288
403
  Item: AccordionItem,
289
404
  HeightAnimator
290
405
  });
291
- export {
292
- Accordion
293
- };
294
- //# sourceMappingURL=Accordion.js.map
406
+ //# sourceMappingURL=Accordion.native.js.map