@xsolla/xui-table 0.151.0-pr273.1778117489

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,785 @@
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
+ Table: () => Table
34
+ });
35
+ module.exports = __toCommonJS(index_exports);
36
+
37
+ // src/Table.tsx
38
+ var import_react3 = __toESM(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
+ onError,
226
+ onLoad,
227
+ type,
228
+ disabled,
229
+ id,
230
+ testID,
231
+ "data-testid": dataTestId,
232
+ ...props
233
+ }, ref) => {
234
+ if (as === "img" && src) {
235
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
236
+ "img",
237
+ {
238
+ src,
239
+ alt: alt || "",
240
+ onError,
241
+ onLoad,
242
+ style: {
243
+ display: "block",
244
+ objectFit: "cover",
245
+ width: typeof props.width === "number" ? `${props.width}px` : props.width,
246
+ height: typeof props.height === "number" ? `${props.height}px` : props.height,
247
+ borderRadius: typeof props.borderRadius === "number" ? `${props.borderRadius}px` : props.borderRadius,
248
+ position: props.position,
249
+ top: typeof props.top === "number" ? `${props.top}px` : props.top,
250
+ left: typeof props.left === "number" ? `${props.left}px` : props.left,
251
+ right: typeof props.right === "number" ? `${props.right}px` : props.right,
252
+ bottom: typeof props.bottom === "number" ? `${props.bottom}px` : props.bottom
253
+ }
254
+ }
255
+ );
256
+ }
257
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
258
+ StyledBox,
259
+ {
260
+ ref,
261
+ elementType: as,
262
+ id,
263
+ type: as === "button" ? type || "button" : void 0,
264
+ disabled: as === "button" ? disabled : void 0,
265
+ onClick: onPress,
266
+ onKeyDown,
267
+ onKeyUp,
268
+ role,
269
+ "aria-label": ariaLabel,
270
+ "aria-labelledby": ariaLabelledBy,
271
+ "aria-current": ariaCurrent,
272
+ "aria-disabled": ariaDisabled,
273
+ "aria-busy": ariaBusy,
274
+ "aria-describedby": ariaDescribedBy,
275
+ "aria-expanded": ariaExpanded,
276
+ "aria-haspopup": ariaHasPopup,
277
+ "aria-pressed": ariaPressed,
278
+ "aria-controls": ariaControls,
279
+ "aria-live": ariaLive,
280
+ tabIndex: tabIndex !== void 0 ? tabIndex : void 0,
281
+ "data-testid": dataTestId || testID,
282
+ ...props,
283
+ children
284
+ }
285
+ );
286
+ }
287
+ );
288
+ Box.displayName = "Box";
289
+
290
+ // ../../foundation/primitives-web/src/Text.tsx
291
+ var import_styled_components2 = __toESM(require("styled-components"));
292
+ var import_jsx_runtime2 = require("react/jsx-runtime");
293
+ var FilteredSpan = createFilteredElement("span");
294
+ var StyledText = (0, import_styled_components2.default)(FilteredSpan)`
295
+ color: ${(props) => props.color || "inherit"};
296
+ font-size: ${(props) => typeof props.fontSize === "number" ? `${props.fontSize}px` : props.fontSize || "inherit"};
297
+ font-weight: ${(props) => props.fontWeight || "normal"};
298
+ font-family: ${(props) => props.fontFamily || '"Aktiv Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'};
299
+ line-height: ${(props) => typeof props.lineHeight === "number" ? `${props.lineHeight}px` : props.lineHeight || "inherit"};
300
+ white-space: ${(props) => props.whiteSpace || "normal"};
301
+ text-align: ${(props) => props.textAlign || "inherit"};
302
+ text-decoration: ${(props) => props.textDecoration || "none"};
303
+ `;
304
+ var Text = ({
305
+ style,
306
+ className,
307
+ id,
308
+ role,
309
+ numberOfLines: _numberOfLines,
310
+ ...props
311
+ }) => {
312
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
313
+ StyledText,
314
+ {
315
+ ...props,
316
+ style,
317
+ className,
318
+ id,
319
+ role
320
+ }
321
+ );
322
+ };
323
+
324
+ // src/Table.tsx
325
+ var import_xui_core = require("@xsolla/xui-core");
326
+ var import_xui_icons_base = require("@xsolla/xui-icons-base");
327
+ var import_jsx_runtime3 = require("react/jsx-runtime");
328
+ var TableRowGroupContext = (0, import_react3.createContext)("body");
329
+ var RowRevealContext = (0, import_react3.createContext)({
330
+ revealed: true
331
+ });
332
+ var useHoverCapable = () => {
333
+ const [hoverCapable, setHoverCapable] = (0, import_react3.useState)(true);
334
+ (0, import_react3.useEffect)(() => {
335
+ if (import_xui_core.isNative) return;
336
+ if (typeof window === "undefined" || !window.matchMedia) return;
337
+ const mq = window.matchMedia("(hover: hover)");
338
+ setHoverCapable(mq.matches);
339
+ const onChange = (e) => setHoverCapable(e.matches);
340
+ mq.addEventListener?.("change", onChange);
341
+ return () => mq.removeEventListener?.("change", onChange);
342
+ }, []);
343
+ return hoverCapable;
344
+ };
345
+ var Divider = ({ color }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
346
+ Box,
347
+ {
348
+ width: "100%",
349
+ height: 1,
350
+ backgroundColor: color,
351
+ style: { flexShrink: 0 }
352
+ }
353
+ );
354
+ var TableRoot = (0, import_react3.forwardRef)(
355
+ ({ children, themeMode, themeProductContext }, ref) => {
356
+ const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
357
+ const sizing = theme.sizing.table;
358
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
359
+ Box,
360
+ {
361
+ ref,
362
+ flexDirection: "column",
363
+ alignItems: "stretch",
364
+ gap: sizing.containerGap,
365
+ paddingVertical: sizing.containerPaddingVertical,
366
+ backgroundColor: theme.colors.background.primary,
367
+ borderRadius: sizing.containerRadius,
368
+ width: "100%",
369
+ role: "table",
370
+ style: {
371
+ color: theme.colors.content.primary,
372
+ overflow: "clip"
373
+ },
374
+ children
375
+ }
376
+ );
377
+ }
378
+ );
379
+ TableRoot.displayName = "Table";
380
+ var TableCaption = (0, import_react3.forwardRef)(
381
+ ({ children, themeMode, themeProductContext, style, ...props }, ref) => {
382
+ const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
383
+ const sizing = theme.sizing.table;
384
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
385
+ Box,
386
+ {
387
+ ref,
388
+ flexDirection: "row",
389
+ alignItems: "center",
390
+ paddingHorizontal: sizing.headerRowPaddingHorizontal,
391
+ width: "100%",
392
+ ...props,
393
+ style,
394
+ children: typeof children === "string" || typeof children === "number" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
395
+ Text,
396
+ {
397
+ fontSize: sizing.captionFontSize,
398
+ lineHeight: sizing.captionLineHeight,
399
+ color: theme.colors.content.secondary,
400
+ children
401
+ }
402
+ ) : children
403
+ }
404
+ );
405
+ }
406
+ );
407
+ TableCaption.displayName = "Table.Caption";
408
+ var TableHeader = (0, import_react3.forwardRef)(
409
+ ({ children, themeMode, themeProductContext, style, ...props }, ref) => {
410
+ const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
411
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TableRowGroupContext.Provider, { value: "header", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
412
+ Box,
413
+ {
414
+ ref,
415
+ flexDirection: "column",
416
+ alignItems: "stretch",
417
+ width: "100%",
418
+ role: "rowgroup",
419
+ ...props,
420
+ style: {
421
+ position: "sticky",
422
+ top: 0,
423
+ zIndex: 1,
424
+ backgroundColor: theme.colors.background.primary,
425
+ ...style
426
+ },
427
+ children: [
428
+ children,
429
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Divider, { color: theme.colors.border.secondary })
430
+ ]
431
+ }
432
+ ) });
433
+ }
434
+ );
435
+ TableHeader.displayName = "Table.Header";
436
+ var TableBody = (0, import_react3.forwardRef)(
437
+ ({ children, style, minRows, themeMode, themeProductContext, ...props }, ref) => {
438
+ const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
439
+ const sizing = theme.sizing.table;
440
+ const DIVIDER_HEIGHT = 1;
441
+ const computedMinHeight = minRows ? minRows * sizing.rowHeight + (minRows - 1) * DIVIDER_HEIGHT : void 0;
442
+ let renderedChildren = children;
443
+ if (minRows) {
444
+ const childArray = import_react3.default.Children.toArray(children);
445
+ const hasOnlyRowChildren = childArray.length > 0 && childArray.every((c) => import_react3.default.isValidElement(c) && c.type === TableRow);
446
+ const realRowCount = hasOnlyRowChildren ? childArray.length : 0;
447
+ const placeholderCount = hasOnlyRowChildren ? Math.max(0, minRows - realRowCount) : 0;
448
+ if (placeholderCount > 0) {
449
+ const patchedRows = childArray.map((child, i) => {
450
+ if (!import_react3.default.isValidElement(child)) return child;
451
+ const isLastRealRow = i === realRowCount - 1;
452
+ return import_react3.default.cloneElement(child, {
453
+ hideDivider: isLastRealRow ? false : child.props.hideDivider
454
+ });
455
+ });
456
+ const placeholders = Array.from({ length: placeholderCount }).map(
457
+ (_, i) => {
458
+ const isLast = i === placeholderCount - 1;
459
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
460
+ Box,
461
+ {
462
+ "aria-hidden": true,
463
+ style: {
464
+ height: isLast ? sizing.rowHeight : sizing.rowHeight + DIVIDER_HEIGHT,
465
+ flexShrink: 0
466
+ }
467
+ },
468
+ `__table-body-placeholder-${i}`
469
+ );
470
+ }
471
+ );
472
+ renderedChildren = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
473
+ patchedRows,
474
+ placeholders
475
+ ] });
476
+ }
477
+ }
478
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TableRowGroupContext.Provider, { value: "body", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
479
+ Box,
480
+ {
481
+ ref,
482
+ flexDirection: "column",
483
+ alignItems: "stretch",
484
+ width: "100%",
485
+ role: "rowgroup",
486
+ ...props,
487
+ style: {
488
+ ...computedMinHeight !== void 0 && {
489
+ minHeight: computedMinHeight
490
+ },
491
+ ...style
492
+ },
493
+ children: renderedChildren
494
+ }
495
+ ) });
496
+ }
497
+ );
498
+ TableBody.displayName = "Table.Body";
499
+ var TableRow = (0, import_react3.forwardRef)(
500
+ ({
501
+ children,
502
+ hoverable: hoverableProp,
503
+ selected,
504
+ hideDivider: hideDividerProp,
505
+ onPress,
506
+ themeMode,
507
+ themeProductContext,
508
+ style,
509
+ onMouseEnter,
510
+ onMouseLeave,
511
+ onFocus,
512
+ onBlur,
513
+ ...props
514
+ }, ref) => {
515
+ const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
516
+ const sizing = theme.sizing.table;
517
+ const rowGroup = (0, import_react3.useContext)(TableRowGroupContext);
518
+ const hoverCapable = useHoverCapable();
519
+ const isHeaderRow = rowGroup === "header";
520
+ const hoverable = hoverableProp ?? !isHeaderRow;
521
+ const hideDivider = hideDividerProp ?? isHeaderRow;
522
+ const [hovered, setHovered] = (0, import_react3.useState)(false);
523
+ const [focusedWithin, setFocusedWithin] = (0, import_react3.useState)(false);
524
+ const revealed = hoverCapable ? hovered || focusedWithin : true;
525
+ const handleMouseEnter = (0, import_react3.useCallback)(
526
+ (e) => {
527
+ setHovered(true);
528
+ onMouseEnter?.(e);
529
+ },
530
+ [onMouseEnter]
531
+ );
532
+ const handleMouseLeave = (0, import_react3.useCallback)(
533
+ (e) => {
534
+ setHovered(false);
535
+ onMouseLeave?.(e);
536
+ },
537
+ [onMouseLeave]
538
+ );
539
+ const handleFocus = (0, import_react3.useCallback)(
540
+ (e) => {
541
+ setFocusedWithin(true);
542
+ onFocus?.(e);
543
+ },
544
+ [onFocus]
545
+ );
546
+ const handleBlur = (0, import_react3.useCallback)(
547
+ (e) => {
548
+ if (e.relatedTarget instanceof Node && e.currentTarget.contains(e.relatedTarget)) {
549
+ onBlur?.(e);
550
+ return;
551
+ }
552
+ setFocusedWithin(false);
553
+ onBlur?.(e);
554
+ },
555
+ [onBlur]
556
+ );
557
+ const baseBg = selected ? theme.colors.background.secondary : theme.colors.background.primary;
558
+ const rowHeight = isHeaderRow ? sizing.headerRowHeight : sizing.rowHeight;
559
+ const rowPaddingHorizontal = isHeaderRow ? sizing.headerRowPaddingHorizontal : sizing.rowPaddingHorizontal;
560
+ const ctxValue = (0, import_react3.useMemo)(() => ({ revealed }), [revealed]);
561
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(RowRevealContext.Provider, { value: ctxValue, children: [
562
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
563
+ Box,
564
+ {
565
+ ref,
566
+ flexDirection: "row",
567
+ alignItems: "center",
568
+ height: rowHeight,
569
+ paddingHorizontal: rowPaddingHorizontal,
570
+ width: "100%",
571
+ gap: sizing.cellGap,
572
+ backgroundColor: baseBg,
573
+ cursor: onPress ? "pointer" : void 0,
574
+ hoverStyle: hoverable ? { backgroundColor: theme.colors.background.secondary } : void 0,
575
+ onPress,
576
+ role: "row",
577
+ "aria-selected": selected || void 0,
578
+ onMouseEnter: handleMouseEnter,
579
+ onMouseLeave: handleMouseLeave,
580
+ onFocus: handleFocus,
581
+ onBlur: handleBlur,
582
+ ...props,
583
+ style,
584
+ children
585
+ }
586
+ ),
587
+ !hideDivider && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Divider, { color: theme.colors.border.secondary })
588
+ ] });
589
+ }
590
+ );
591
+ TableRow.displayName = "Table.Row";
592
+ var positionToFlex = (position) => {
593
+ switch (position) {
594
+ case "left":
595
+ return { flexShrink: 0 };
596
+ case "right":
597
+ return { flexShrink: 0, marginLeft: "auto" };
598
+ default:
599
+ return {};
600
+ }
601
+ };
602
+ var alignToJustify = (align) => {
603
+ switch (align) {
604
+ case "right":
605
+ return "flex-end";
606
+ case "center":
607
+ return "center";
608
+ default:
609
+ return "flex-start";
610
+ }
611
+ };
612
+ var TableCell = (0, import_react3.forwardRef)(
613
+ ({
614
+ children,
615
+ align = "left",
616
+ position = "default",
617
+ width,
618
+ grow,
619
+ revealOnHover,
620
+ themeMode,
621
+ themeProductContext,
622
+ style,
623
+ ...props
624
+ }, ref) => {
625
+ const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
626
+ const sizing = theme.sizing.table;
627
+ const { revealed } = (0, import_react3.useContext)(RowRevealContext);
628
+ const positionStyle = (0, import_react3.useMemo)(() => positionToFlex(position), [position]);
629
+ const revealStyle = revealOnHover && !revealed ? { opacity: 0, pointerEvents: "none" } : revealOnHover ? { opacity: 1, transition: "opacity 0.15s ease" } : {};
630
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
631
+ Box,
632
+ {
633
+ ref,
634
+ flexDirection: "row",
635
+ alignItems: "center",
636
+ justifyContent: alignToJustify(align),
637
+ gap: 8,
638
+ height: "100%",
639
+ width,
640
+ role: "cell",
641
+ ...props,
642
+ style: {
643
+ flex: width != null ? "0 0 auto" : grow ?? 1,
644
+ minWidth: 0,
645
+ ...positionStyle,
646
+ ...revealStyle,
647
+ ...style
648
+ },
649
+ children: typeof children === "string" || typeof children === "number" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
650
+ Text,
651
+ {
652
+ fontSize: sizing.cellFontSize,
653
+ lineHeight: sizing.cellLineHeight,
654
+ color: theme.colors.content.primary,
655
+ style: {
656
+ overflow: "hidden",
657
+ textOverflow: "ellipsis",
658
+ whiteSpace: "nowrap",
659
+ maxWidth: "100%"
660
+ },
661
+ children
662
+ }
663
+ ) : children
664
+ }
665
+ );
666
+ }
667
+ );
668
+ TableCell.displayName = "Table.Cell";
669
+ var SortIcon = ({ direction, color, size }) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
670
+ Box,
671
+ {
672
+ style: {
673
+ flexShrink: 0,
674
+ opacity: direction === "none" ? 0.4 : 1,
675
+ transition: "opacity 0.15s ease"
676
+ },
677
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_xui_icons_base.Sort, { variant: "line", size, color, "aria-hidden": true })
678
+ }
679
+ );
680
+ var TableHead = (0, import_react3.forwardRef)(
681
+ ({
682
+ children,
683
+ align = "left",
684
+ position = "default",
685
+ width,
686
+ grow,
687
+ sort,
688
+ onSortToggle,
689
+ themeMode,
690
+ themeProductContext,
691
+ style,
692
+ ...props
693
+ }, ref) => {
694
+ const { theme } = (0, import_xui_core.useResolvedTheme)({ themeMode, themeProductContext });
695
+ const sizing = theme.sizing.table;
696
+ const positionStyle = (0, import_react3.useMemo)(() => positionToFlex(position), [position]);
697
+ const sortable = sort != null;
698
+ const ariaSort = sortable ? sort : void 0;
699
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
700
+ Box,
701
+ {
702
+ ref,
703
+ flexDirection: "row",
704
+ alignItems: "center",
705
+ justifyContent: alignToJustify(align),
706
+ gap: sizing.headerCellGap,
707
+ height: "100%",
708
+ width,
709
+ role: "columnheader",
710
+ "aria-sort": ariaSort,
711
+ cursor: sortable ? "pointer" : void 0,
712
+ onPress: sortable ? onSortToggle : void 0,
713
+ ...props,
714
+ style: {
715
+ flex: width != null ? "0 0 auto" : grow ?? 1,
716
+ minWidth: 0,
717
+ ...positionStyle,
718
+ ...style
719
+ },
720
+ children: [
721
+ sortable && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
722
+ SortIcon,
723
+ {
724
+ direction: sort,
725
+ color: theme.colors.content.secondary,
726
+ size: sizing.headerCellFontSize + 2
727
+ }
728
+ ),
729
+ typeof children === "string" || typeof children === "number" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
730
+ Text,
731
+ {
732
+ fontSize: sizing.headerCellFontSize,
733
+ lineHeight: sizing.headerCellLineHeight,
734
+ color: theme.colors.content.secondary,
735
+ fontWeight: "500",
736
+ style: {
737
+ overflow: "hidden",
738
+ textOverflow: "ellipsis",
739
+ whiteSpace: "nowrap"
740
+ },
741
+ children
742
+ }
743
+ ) : children
744
+ ]
745
+ }
746
+ );
747
+ }
748
+ );
749
+ TableHead.displayName = "Table.Head";
750
+ var TableFooter = (0, import_react3.forwardRef)(
751
+ ({ children, style, ...props }, ref) => {
752
+ const { theme } = (0, import_xui_core.useResolvedTheme)();
753
+ const sizing = theme.sizing.table;
754
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
755
+ Box,
756
+ {
757
+ ref,
758
+ flexDirection: "row",
759
+ alignItems: "center",
760
+ justifyContent: "center",
761
+ gap: sizing.paginationGap,
762
+ paddingHorizontal: sizing.paginationPaddingHorizontal,
763
+ width: "100%",
764
+ ...props,
765
+ style,
766
+ children
767
+ }
768
+ );
769
+ }
770
+ );
771
+ TableFooter.displayName = "Table.Footer";
772
+ var Table = Object.assign(TableRoot, {
773
+ Caption: TableCaption,
774
+ Header: TableHeader,
775
+ Body: TableBody,
776
+ Footer: TableFooter,
777
+ Row: TableRow,
778
+ Head: TableHead,
779
+ Cell: TableCell
780
+ });
781
+ // Annotate the CommonJS export names for ESM import in node:
782
+ 0 && (module.exports = {
783
+ Table
784
+ });
785
+ //# sourceMappingURL=index.js.map