@payglocal_ui/flux-ui 0.3.1 → 0.3.2
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/dist/index.cjs +27 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +27 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/data-table-column-width.test.tsx +77 -0
- package/src/data-table.tsx +65 -9
package/dist/index.cjs
CHANGED
|
@@ -4070,6 +4070,32 @@ function SortIndicator({ order }) {
|
|
|
4070
4070
|
}
|
|
4071
4071
|
);
|
|
4072
4072
|
}
|
|
4073
|
+
function parseMinMaxWidth(width) {
|
|
4074
|
+
if (!width) return null;
|
|
4075
|
+
const match = /^minmax\(\s*([^,]+?)\s*,\s*([^)]+?)\s*\)$/.exec(width.trim());
|
|
4076
|
+
return match ? { min: match[1], max: match[2] } : null;
|
|
4077
|
+
}
|
|
4078
|
+
function isFlexUnit(value) {
|
|
4079
|
+
return /^[\d.]*fr$/.test(value.trim());
|
|
4080
|
+
}
|
|
4081
|
+
function colWidthStyle(col) {
|
|
4082
|
+
const parsed = parseMinMaxWidth(col.width);
|
|
4083
|
+
if (!parsed) {
|
|
4084
|
+
return {
|
|
4085
|
+
width: col.width ?? (col.minWidth != null ? `${col.minWidth}px` : void 0),
|
|
4086
|
+
minWidth: col.minWidth,
|
|
4087
|
+
maxWidth: col.maxWidth
|
|
4088
|
+
};
|
|
4089
|
+
}
|
|
4090
|
+
return {
|
|
4091
|
+
width: isFlexUnit(parsed.max) ? void 0 : parsed.max,
|
|
4092
|
+
// An explicit numeric `minWidth`/`maxWidth` alongside a `minmax()` string
|
|
4093
|
+
// is not a combination any caller uses today; the string wins because it
|
|
4094
|
+
// is the more specific of the two.
|
|
4095
|
+
minWidth: parsed.min,
|
|
4096
|
+
maxWidth: isFlexUnit(parsed.max) ? col.maxWidth : void 0
|
|
4097
|
+
};
|
|
4098
|
+
}
|
|
4073
4099
|
function DataTable({
|
|
4074
4100
|
columns,
|
|
4075
4101
|
data,
|
|
@@ -4216,17 +4242,7 @@ function DataTable({
|
|
|
4216
4242
|
children: [
|
|
4217
4243
|
tableLayout === "fixed" && !isEmpty && /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)("colgroup", { children: [
|
|
4218
4244
|
hasExpand ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { style: { width: 40 } }) : null,
|
|
4219
|
-
columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|
|
4220
|
-
"col",
|
|
4221
|
-
{
|
|
4222
|
-
style: {
|
|
4223
|
-
width: col.width ?? (col.minWidth != null ? `${col.minWidth}px` : void 0),
|
|
4224
|
-
minWidth: col.minWidth,
|
|
4225
|
-
maxWidth: col.maxWidth
|
|
4226
|
-
}
|
|
4227
|
-
},
|
|
4228
|
-
col.key
|
|
4229
|
-
)),
|
|
4245
|
+
columns.map((col) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { style: colWidthStyle(col) }, col.key)),
|
|
4230
4246
|
hasAction ? /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("col", { style: { width: 0 } }) : null
|
|
4231
4247
|
] }),
|
|
4232
4248
|
/* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
|