@xsolla/xui-b2b-collapsible 0.147.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/web/index.js ADDED
@@ -0,0 +1,573 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.tsx
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Collapsible: () => Collapsible
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/Collapsible.tsx
38
+ var import_react3 = require("react");
39
+
40
+ // ../../foundation/primitives-web/src/Box.tsx
41
+ var import_react2 = __toESM(require("react"));
42
+ var import_styled_components = __toESM(require("styled-components"));
43
+
44
+ // ../../foundation/primitives-web/src/filterDOMProps.ts
45
+ var import_react = __toESM(require("react"));
46
+
47
+ // ../../../node_modules/@emotion/memoize/dist/memoize.esm.js
48
+ function memoize(fn) {
49
+ var cache = {};
50
+ return function(arg) {
51
+ if (cache[arg] === void 0) cache[arg] = fn(arg);
52
+ return cache[arg];
53
+ };
54
+ }
55
+ var memoize_esm_default = memoize;
56
+
57
+ // ../../../node_modules/@emotion/is-prop-valid/dist/is-prop-valid.esm.js
58
+ var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|inert|itemProp|itemScope|itemType|itemID|itemRef|on|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/;
59
+ var index = memoize_esm_default(
60
+ function(prop) {
61
+ return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111 && prop.charCodeAt(1) === 110 && prop.charCodeAt(2) < 91;
62
+ }
63
+ /* Z+1 */
64
+ );
65
+ var is_prop_valid_esm_default = index;
66
+
67
+ // ../../foundation/primitives-web/src/filterDOMProps.ts
68
+ var ADDITIONAL_BLOCKED_PROPS = /* @__PURE__ */ new Set([
69
+ // RN-only event handlers (pass isPropValid's on* pattern)
70
+ "onPress",
71
+ "onChangeText",
72
+ "onLayout",
73
+ "onMoveShouldSetResponder",
74
+ "onResponderGrant",
75
+ "onResponderMove",
76
+ "onResponderRelease",
77
+ "onResponderTerminate",
78
+ // SVG attributes that pass isPropValid
79
+ "strokeWidth",
80
+ // CSS properties that pass isPropValid but are used as component props
81
+ "overflow",
82
+ "cursor",
83
+ "fontSize",
84
+ "fontWeight",
85
+ "fontFamily",
86
+ "textDecoration"
87
+ ]);
88
+ function shouldForwardProp(key) {
89
+ if (ADDITIONAL_BLOCKED_PROPS.has(key)) return false;
90
+ return is_prop_valid_esm_default(key);
91
+ }
92
+ function createFilteredElement(defaultTag) {
93
+ const Component = import_react.default.forwardRef(
94
+ ({ children, elementType, ...props }, ref) => {
95
+ const Tag = elementType || defaultTag;
96
+ const htmlProps = {};
97
+ for (const key of Object.keys(props)) {
98
+ if (shouldForwardProp(key)) {
99
+ htmlProps[key] = props[key];
100
+ }
101
+ }
102
+ return import_react.default.createElement(
103
+ Tag,
104
+ { ref, ...htmlProps },
105
+ children
106
+ );
107
+ }
108
+ );
109
+ Component.displayName = `Filtered(${defaultTag})`;
110
+ return Component;
111
+ }
112
+
113
+ // ../../foundation/primitives-web/src/Box.tsx
114
+ var import_jsx_runtime = require("react/jsx-runtime");
115
+ var FilteredDiv = createFilteredElement("div");
116
+ var StyledBox = (0, import_styled_components.default)(FilteredDiv)`
117
+ display: flex;
118
+ box-sizing: border-box;
119
+ background-color: ${(props) => props.backgroundColor || "transparent"};
120
+ border-color: ${(props) => props.borderColor || "transparent"};
121
+ border-width: ${(props) => typeof props.borderWidth === "number" ? `${props.borderWidth}px` : props.borderWidth || 0};
122
+
123
+ ${(props) => props.borderBottomWidth !== void 0 && `
124
+ border-bottom-width: ${typeof props.borderBottomWidth === "number" ? `${props.borderBottomWidth}px` : props.borderBottomWidth};
125
+ border-bottom-color: ${props.borderBottomColor || props.borderColor || "transparent"};
126
+ border-bottom-style: solid;
127
+ `}
128
+ ${(props) => props.borderTopWidth !== void 0 && `
129
+ border-top-width: ${typeof props.borderTopWidth === "number" ? `${props.borderTopWidth}px` : props.borderTopWidth};
130
+ border-top-color: ${props.borderTopColor || props.borderColor || "transparent"};
131
+ border-top-style: solid;
132
+ `}
133
+ ${(props) => props.borderLeftWidth !== void 0 && `
134
+ border-left-width: ${typeof props.borderLeftWidth === "number" ? `${props.borderLeftWidth}px` : props.borderLeftWidth};
135
+ border-left-color: ${props.borderLeftColor || props.borderColor || "transparent"};
136
+ border-left-style: solid;
137
+ `}
138
+ ${(props) => props.borderRightWidth !== void 0 && `
139
+ border-right-width: ${typeof props.borderRightWidth === "number" ? `${props.borderRightWidth}px` : props.borderRightWidth};
140
+ border-right-color: ${props.borderRightColor || props.borderColor || "transparent"};
141
+ border-right-style: solid;
142
+ `}
143
+
144
+ border-style: ${(props) => props.borderStyle || (props.borderWidth || props.borderBottomWidth || props.borderTopWidth || props.borderLeftWidth || props.borderRightWidth ? "solid" : "none")};
145
+ border-radius: ${(props) => typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius || 0};
146
+ height: ${(props) => typeof props.height === "number" ? `${props.height}px` : props.height || "auto"};
147
+ width: ${(props) => typeof props.width === "number" ? `${props.width}px` : props.width || "auto"};
148
+ min-width: ${(props) => typeof props.minWidth === "number" ? `${props.minWidth}px` : props.minWidth || "auto"};
149
+ min-height: ${(props) => typeof props.minHeight === "number" ? `${props.minHeight}px` : props.minHeight || "auto"};
150
+ max-width: ${(props) => typeof props.maxWidth === "number" ? `${props.maxWidth}px` : props.maxWidth || "none"};
151
+ max-height: ${(props) => typeof props.maxHeight === "number" ? `${props.maxHeight}px` : props.maxHeight || "none"};
152
+
153
+ padding: ${(props) => typeof props.padding === "number" ? `${props.padding}px` : props.padding || 0};
154
+ ${(props) => props.paddingHorizontal && `
155
+ padding-left: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
156
+ padding-right: ${typeof props.paddingHorizontal === "number" ? `${props.paddingHorizontal}px` : props.paddingHorizontal};
157
+ `}
158
+ ${(props) => props.paddingVertical && `
159
+ padding-top: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
160
+ padding-bottom: ${typeof props.paddingVertical === "number" ? `${props.paddingVertical}px` : props.paddingVertical};
161
+ `}
162
+ ${(props) => props.paddingTop !== void 0 && `padding-top: ${typeof props.paddingTop === "number" ? `${props.paddingTop}px` : props.paddingTop};`}
163
+ ${(props) => props.paddingBottom !== void 0 && `padding-bottom: ${typeof props.paddingBottom === "number" ? `${props.paddingBottom}px` : props.paddingBottom};`}
164
+ ${(props) => props.paddingLeft !== void 0 && `padding-left: ${typeof props.paddingLeft === "number" ? `${props.paddingLeft}px` : props.paddingLeft};`}
165
+ ${(props) => props.paddingRight !== void 0 && `padding-right: ${typeof props.paddingRight === "number" ? `${props.paddingRight}px` : props.paddingRight};`}
166
+
167
+ margin: ${(props) => typeof props.margin === "number" ? `${props.margin}px` : props.margin || 0};
168
+ ${(props) => props.marginTop !== void 0 && `margin-top: ${typeof props.marginTop === "number" ? `${props.marginTop}px` : props.marginTop};`}
169
+ ${(props) => props.marginBottom !== void 0 && `margin-bottom: ${typeof props.marginBottom === "number" ? `${props.marginBottom}px` : props.marginBottom};`}
170
+ ${(props) => props.marginLeft !== void 0 && `margin-left: ${typeof props.marginLeft === "number" ? `${props.marginLeft}px` : props.marginLeft};`}
171
+ ${(props) => props.marginRight !== void 0 && `margin-right: ${typeof props.marginRight === "number" ? `${props.marginRight}px` : props.marginRight};`}
172
+
173
+ flex-direction: ${(props) => props.flexDirection || "column"};
174
+ flex-wrap: ${(props) => props.flexWrap || "nowrap"};
175
+ align-items: ${(props) => props.alignItems || "stretch"};
176
+ justify-content: ${(props) => props.justifyContent || "flex-start"};
177
+ cursor: ${(props) => props.cursor ? props.cursor : props.onClick || props.onPress ? "pointer" : "inherit"};
178
+ position: ${(props) => props.position || "static"};
179
+ top: ${(props) => typeof props.top === "number" ? `${props.top}px` : props.top};
180
+ bottom: ${(props) => typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom};
181
+ left: ${(props) => typeof props.left === "number" ? `${props.left}px` : props.left};
182
+ right: ${(props) => typeof props.right === "number" ? `${props.right}px` : props.right};
183
+ flex: ${(props) => props.flex};
184
+ flex-shrink: ${(props) => props.flexShrink ?? 1};
185
+ gap: ${(props) => typeof props.gap === "number" ? `${props.gap}px` : props.gap || 0};
186
+ align-self: ${(props) => props.alignSelf || "auto"};
187
+ overflow: ${(props) => props.overflow || "visible"};
188
+ overflow-x: ${(props) => props.overflowX || "visible"};
189
+ overflow-y: ${(props) => props.overflowY || "visible"};
190
+ z-index: ${(props) => props.zIndex};
191
+ opacity: ${(props) => props.disabled ? 0.5 : 1};
192
+ pointer-events: ${(props) => props.disabled ? "none" : "auto"};
193
+
194
+ &:hover {
195
+ ${(props) => props.hoverStyle?.backgroundColor && `background-color: ${props.hoverStyle.backgroundColor};`}
196
+ ${(props) => props.hoverStyle?.borderColor && `border-color: ${props.hoverStyle.borderColor};`}
197
+ }
198
+
199
+ &:active {
200
+ ${(props) => props.pressStyle?.backgroundColor && `background-color: ${props.pressStyle.backgroundColor};`}
201
+ }
202
+ `;
203
+ var Box = import_react2.default.forwardRef(
204
+ ({
205
+ children,
206
+ onPress,
207
+ onKeyDown,
208
+ onKeyUp,
209
+ role,
210
+ "aria-label": ariaLabel,
211
+ "aria-labelledby": ariaLabelledBy,
212
+ "aria-current": ariaCurrent,
213
+ "aria-disabled": ariaDisabled,
214
+ "aria-live": ariaLive,
215
+ "aria-busy": ariaBusy,
216
+ "aria-describedby": ariaDescribedBy,
217
+ "aria-expanded": ariaExpanded,
218
+ "aria-haspopup": ariaHasPopup,
219
+ "aria-pressed": ariaPressed,
220
+ "aria-controls": ariaControls,
221
+ tabIndex,
222
+ as,
223
+ src,
224
+ alt,
225
+ type,
226
+ disabled,
227
+ id,
228
+ testID,
229
+ "data-testid": dataTestId,
230
+ ...props
231
+ }, ref) => {
232
+ if (as === "img" && src) {
233
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
234
+ "img",
235
+ {
236
+ src,
237
+ alt: alt || "",
238
+ style: {
239
+ display: "block",
240
+ objectFit: "cover",
241
+ width: typeof props.width === "number" ? `${props.width}px` : props.width,
242
+ height: typeof props.height === "number" ? `${props.height}px` : props.height,
243
+ borderRadius: typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius,
244
+ position: props.position,
245
+ top: typeof props.top === "number" ? `${props.top}px` : props.top,
246
+ left: typeof props.left === "number" ? `${props.left}px` : props.left,
247
+ right: typeof props.right === "number" ? `${props.right}px` : props.right,
248
+ bottom: typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom
249
+ }
250
+ }
251
+ );
252
+ }
253
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
254
+ StyledBox,
255
+ {
256
+ ref,
257
+ elementType: as,
258
+ id,
259
+ type: as === "button" ? type || "button" : void 0,
260
+ disabled: as === "button" ? disabled : void 0,
261
+ onClick: onPress,
262
+ onKeyDown,
263
+ onKeyUp,
264
+ role,
265
+ "aria-label": ariaLabel,
266
+ "aria-labelledby": ariaLabelledBy,
267
+ "aria-current": ariaCurrent,
268
+ "aria-disabled": ariaDisabled,
269
+ "aria-busy": ariaBusy,
270
+ "aria-describedby": ariaDescribedBy,
271
+ "aria-expanded": ariaExpanded,
272
+ "aria-haspopup": ariaHasPopup,
273
+ "aria-pressed": ariaPressed,
274
+ "aria-controls": ariaControls,
275
+ "aria-live": ariaLive,
276
+ tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
277
+ "data-testid": dataTestId || testID,
278
+ ...props,
279
+ children
280
+ }
281
+ );
282
+ }
283
+ );
284
+ Box.displayName = "Box";
285
+
286
+ // ../../foundation/primitives-web/src/Text.tsx
287
+ var import_styled_components2 = __toESM(require("styled-components"));
288
+ var import_jsx_runtime2 = require("react/jsx-runtime");
289
+ var FilteredSpan = createFilteredElement("span");
290
+ var StyledText = (0, import_styled_components2.default)(FilteredSpan)`
291
+ color: ${(props) => props.color || "inherit"};
292
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
293
+ font-weight: ${(props) => props.fontWeight || "normal"};
294
+ font-family: ${(props) => props.fontFamily || '"Aktiv Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'};
295
+ line-height: ${(props) => typeof props.lineHeight === "number" ? `${props.lineHeight}px` : props.lineHeight || "inherit"};
296
+ white-space: ${(props) => props.whiteSpace || "normal"};
297
+ text-align: ${(props) => props.textAlign || "inherit"};
298
+ text-decoration: ${(props) => props.textDecoration || "none"};
299
+ `;
300
+ var Text = ({
301
+ style,
302
+ className,
303
+ id,
304
+ role,
305
+ numberOfLines: _numberOfLines,
306
+ ...props
307
+ }) => {
308
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
309
+ StyledText,
310
+ {
311
+ ...props,
312
+ style,
313
+ className,
314
+ id,
315
+ role
316
+ }
317
+ );
318
+ };
319
+
320
+ // ../../foundation/primitives-web/src/Icon.tsx
321
+ var import_styled_components3 = __toESM(require("styled-components"));
322
+ var import_jsx_runtime3 = require("react/jsx-runtime");
323
+ var FilteredDiv2 = createFilteredElement("div");
324
+ var StyledIcon = (0, import_styled_components3.default)(FilteredDiv2)`
325
+ display: flex;
326
+ align-items: center;
327
+ justify-content: center;
328
+ width: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
329
+ height: ${(props) => typeof props.size === "number" ? `${props.size}px` : props.size || "24px"};
330
+ color: ${(props) => props.color || "currentColor"};
331
+
332
+ svg {
333
+ width: 100%;
334
+ height: 100%;
335
+ fill: none;
336
+ stroke: currentColor;
337
+ }
338
+ `;
339
+ var Icon = ({ children, ...props }) => {
340
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(StyledIcon, { ...props, children });
341
+ };
342
+
343
+ // src/Collapsible.tsx
344
+ var import_xui_core = require("@xsolla/xui-core");
345
+ var import_xui_icons_base = require("@xsolla/xui-icons-base");
346
+ var import_jsx_runtime4 = require("react/jsx-runtime");
347
+ var PANEL_TRANSITION = "grid-template-rows 280ms cubic-bezier(0.4, 0, 0.2, 1)";
348
+ var CHEVRON_TRANSITION = "transform 280ms cubic-bezier(0.4, 0, 0.2, 1)";
349
+ var Collapsible = (0, import_react3.forwardRef)(
350
+ ({
351
+ title,
352
+ caption: captionProp,
353
+ icon,
354
+ trailing: trailingProp,
355
+ view = "without-surface",
356
+ open: openProp,
357
+ defaultOpen = false,
358
+ onOpenChange,
359
+ children,
360
+ className,
361
+ "aria-label": ariaLabel,
362
+ themeMode,
363
+ themeProductContext,
364
+ // deprecated aliases
365
+ onChange,
366
+ statusIcon,
367
+ description,
368
+ ...rest
369
+ }, ref) => {
370
+ const caption = captionProp ?? description;
371
+ const trailing = trailingProp ?? statusIcon;
372
+ const resolvedOnOpenChange = onOpenChange ?? onChange;
373
+ const panelIdRef = (0, import_react3.useRef)();
374
+ if (!panelIdRef.current) {
375
+ panelIdRef.current = `collapsible-panel-${Math.random().toString(36).slice(2, 10)}`;
376
+ }
377
+ const panelId = panelIdRef.current;
378
+ const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
379
+ const sizing = theme.sizing.collapsibleB2b();
380
+ const isControlled = openProp !== void 0;
381
+ const [openState, setOpenState] = (0, import_react3.useState)(defaultOpen);
382
+ const open = isControlled ? openProp : openState;
383
+ const handleToggle = (0, import_react3.useCallback)(() => {
384
+ const next = !open;
385
+ if (!isControlled) setOpenState(next);
386
+ resolvedOnOpenChange?.(next);
387
+ }, [open, isControlled, resolvedOnOpenChange]);
388
+ const handleKeyDown = (0, import_react3.useCallback)(
389
+ (e) => {
390
+ if (e.key === "Enter") {
391
+ e.preventDefault();
392
+ handleToggle();
393
+ } else if (e.key === " ") {
394
+ e.preventDefault();
395
+ }
396
+ },
397
+ [handleToggle]
398
+ );
399
+ const handleKeyUp = (0, import_react3.useCallback)(
400
+ (e) => {
401
+ if (e.key === " ") {
402
+ e.preventDefault();
403
+ handleToggle();
404
+ }
405
+ },
406
+ [handleToggle]
407
+ );
408
+ const isWhite = view === "white-surface";
409
+ const isGrey = view === "grey-surface";
410
+ const isWithout = view === "without-surface";
411
+ const rootStyle = {
412
+ boxSizing: "border-box",
413
+ display: "flex",
414
+ flexDirection: "column",
415
+ overflow: "hidden",
416
+ backgroundColor: isWhite ? theme.colors.background.primary : isGrey ? theme.colors.overlay.mono : void 0,
417
+ borderRadius: !isWithout ? sizing.surfaceRadius : void 0,
418
+ borderBottom: isWithout ? `1px solid ${theme.colors.border.secondary}` : void 0
419
+ };
420
+ const cellStyle = {
421
+ boxSizing: "border-box",
422
+ display: "flex",
423
+ flexDirection: "row",
424
+ alignItems: "center",
425
+ gap: sizing.triggerGap,
426
+ width: "100%",
427
+ minHeight: isWithout ? sizing.triggerMinHeight : void 0,
428
+ padding: !isWithout ? sizing.triggerPadding : 0,
429
+ backgroundColor: isWhite ? theme.colors.background.primary : isGrey ? theme.colors.overlay.mono : void 0,
430
+ borderRadius: !isWithout ? open ? `${sizing.cellRadius}px ${sizing.cellRadius}px 0 0` : sizing.cellRadius : void 0,
431
+ borderBottom: open ? `1px solid ${theme.colors.border.secondary}` : void 0
432
+ };
433
+ const panelGridStyle = {
434
+ display: "grid",
435
+ gridTemplateRows: open ? "1fr" : "0fr",
436
+ transition: PANEL_TRANSITION,
437
+ width: "100%"
438
+ };
439
+ const panelInnerStyle = {
440
+ overflow: "hidden"
441
+ };
442
+ const panelContentStyle = {
443
+ boxSizing: "border-box",
444
+ width: "100%",
445
+ padding: sizing.panelPadding
446
+ };
447
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
448
+ Box,
449
+ {
450
+ ref,
451
+ "data-testid": "collapsible",
452
+ "data-open": open,
453
+ className,
454
+ width: "100%",
455
+ style: rootStyle,
456
+ ...rest,
457
+ children: [
458
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
459
+ "div",
460
+ {
461
+ role: "button",
462
+ tabIndex: 0,
463
+ "aria-expanded": open,
464
+ "aria-controls": panelId,
465
+ "aria-label": ariaLabel ?? (typeof title === "string" ? title : void 0),
466
+ onClick: handleToggle,
467
+ onKeyDown: handleKeyDown,
468
+ onKeyUp: handleKeyUp,
469
+ style: { boxSizing: "border-box", width: "100%", cursor: "pointer" },
470
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: cellStyle, children: [
471
+ icon && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
472
+ "div",
473
+ {
474
+ onClick: (e) => e.stopPropagation(),
475
+ onKeyDown: (e) => e.stopPropagation(),
476
+ onKeyUp: (e) => e.stopPropagation(),
477
+ style: { flexShrink: 0, display: "flex", alignItems: "center" },
478
+ children: icon
479
+ }
480
+ ),
481
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
482
+ "div",
483
+ {
484
+ style: {
485
+ flex: 1,
486
+ display: "flex",
487
+ flexDirection: "column",
488
+ alignItems: "flex-start",
489
+ gap: sizing.textGap,
490
+ minWidth: 0
491
+ },
492
+ children: [
493
+ typeof title === "string" || typeof title === "number" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
494
+ Text,
495
+ {
496
+ color: theme.colors.content.primary,
497
+ fontSize: sizing.titleFontSize,
498
+ lineHeight: sizing.titleLineHeight,
499
+ fontWeight: "500",
500
+ children: title
501
+ }
502
+ ) : title,
503
+ caption !== void 0 && (typeof caption === "string" || typeof caption === "number" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
504
+ Text,
505
+ {
506
+ color: theme.colors.content.tertiary,
507
+ fontSize: sizing.captionFontSize,
508
+ lineHeight: sizing.captionLineHeight,
509
+ fontWeight: "400",
510
+ children: caption
511
+ }
512
+ ) : caption)
513
+ ]
514
+ }
515
+ ),
516
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
517
+ "div",
518
+ {
519
+ style: {
520
+ display: "flex",
521
+ flexDirection: "row",
522
+ alignItems: "center",
523
+ gap: sizing.trailingGap,
524
+ flexShrink: 0
525
+ },
526
+ children: [
527
+ trailing && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
528
+ "div",
529
+ {
530
+ onClick: (e) => e.stopPropagation(),
531
+ onKeyDown: (e) => e.stopPropagation(),
532
+ onKeyUp: (e) => e.stopPropagation(),
533
+ style: { display: "flex", alignItems: "center" },
534
+ children: trailing
535
+ }
536
+ ),
537
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
538
+ "div",
539
+ {
540
+ style: {
541
+ transform: open ? "rotate(180deg)" : "rotate(0deg)",
542
+ transition: CHEVRON_TRANSITION,
543
+ display: "flex",
544
+ alignItems: "center"
545
+ },
546
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
547
+ Icon,
548
+ {
549
+ color: theme.colors.content.primary,
550
+ size: sizing.chevronSize,
551
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_xui_icons_base.ChevronDown, {})
552
+ }
553
+ )
554
+ }
555
+ )
556
+ ]
557
+ }
558
+ )
559
+ ] })
560
+ }
561
+ ),
562
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { id: panelId, style: panelGridStyle, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: panelInnerStyle, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: panelContentStyle, children }) }) })
563
+ ]
564
+ }
565
+ );
566
+ }
567
+ );
568
+ Collapsible.displayName = "Collapsible";
569
+ // Annotate the CommonJS export names for ESM import in node:
570
+ 0 && (module.exports = {
571
+ Collapsible
572
+ });
573
+ //# sourceMappingURL=index.js.map