@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.d.cts
CHANGED
|
@@ -961,7 +961,25 @@ type DataTableExpandable<T> = {
|
|
|
961
961
|
type Column<T> = {
|
|
962
962
|
key: string;
|
|
963
963
|
header: ReactNode;
|
|
964
|
-
/**
|
|
964
|
+
/**
|
|
965
|
+
* Table column width: `48px`, `18%`, or `minmax(12rem, 1fr)` for a floor
|
|
966
|
+
* that can still grow into whatever the other columns leave over.
|
|
967
|
+
*
|
|
968
|
+
* `minmax(min, max)` is translated rather than passed straight through: this
|
|
969
|
+
* is a real `<table>`/`<colgroup>`, and `minmax()` is a CSS Grid function
|
|
970
|
+
* that is not a legal `width` value outside a grid — the browser drops the
|
|
971
|
+
* whole declaration and the column gets no floor at all. `min` becomes the
|
|
972
|
+
* `<col>`'s `min-width`, and `max` becomes its `width` unless `max` is `1fr`
|
|
973
|
+
* (or any other flex unit), in which case no `width` is set and the column
|
|
974
|
+
* takes its share of whatever `table-layout: fixed` has left over, the same
|
|
975
|
+
* way a grid track's `1fr` would.
|
|
976
|
+
*
|
|
977
|
+
* `overflow-x-auto` on the table's own scroll container is what makes the
|
|
978
|
+
* floor mean something: once every column's minimum no longer fits, the
|
|
979
|
+
* table grows past its container and scrolls instead of every column
|
|
980
|
+
* shrinking under its `min-width` and the header text — deliberately not
|
|
981
|
+
* truncated, see the `<th>` render below — overlapping the column beside it.
|
|
982
|
+
*/
|
|
965
983
|
width?: string;
|
|
966
984
|
minWidth?: number;
|
|
967
985
|
maxWidth?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -961,7 +961,25 @@ type DataTableExpandable<T> = {
|
|
|
961
961
|
type Column<T> = {
|
|
962
962
|
key: string;
|
|
963
963
|
header: ReactNode;
|
|
964
|
-
/**
|
|
964
|
+
/**
|
|
965
|
+
* Table column width: `48px`, `18%`, or `minmax(12rem, 1fr)` for a floor
|
|
966
|
+
* that can still grow into whatever the other columns leave over.
|
|
967
|
+
*
|
|
968
|
+
* `minmax(min, max)` is translated rather than passed straight through: this
|
|
969
|
+
* is a real `<table>`/`<colgroup>`, and `minmax()` is a CSS Grid function
|
|
970
|
+
* that is not a legal `width` value outside a grid — the browser drops the
|
|
971
|
+
* whole declaration and the column gets no floor at all. `min` becomes the
|
|
972
|
+
* `<col>`'s `min-width`, and `max` becomes its `width` unless `max` is `1fr`
|
|
973
|
+
* (or any other flex unit), in which case no `width` is set and the column
|
|
974
|
+
* takes its share of whatever `table-layout: fixed` has left over, the same
|
|
975
|
+
* way a grid track's `1fr` would.
|
|
976
|
+
*
|
|
977
|
+
* `overflow-x-auto` on the table's own scroll container is what makes the
|
|
978
|
+
* floor mean something: once every column's minimum no longer fits, the
|
|
979
|
+
* table grows past its container and scrolls instead of every column
|
|
980
|
+
* shrinking under its `min-width` and the header text — deliberately not
|
|
981
|
+
* truncated, see the `<th>` render below — overlapping the column beside it.
|
|
982
|
+
*/
|
|
965
983
|
width?: string;
|
|
966
984
|
minWidth?: number;
|
|
967
985
|
maxWidth?: number;
|
package/dist/index.js
CHANGED
|
@@ -3786,6 +3786,32 @@ function SortIndicator({ order }) {
|
|
|
3786
3786
|
}
|
|
3787
3787
|
);
|
|
3788
3788
|
}
|
|
3789
|
+
function parseMinMaxWidth(width) {
|
|
3790
|
+
if (!width) return null;
|
|
3791
|
+
const match = /^minmax\(\s*([^,]+?)\s*,\s*([^)]+?)\s*\)$/.exec(width.trim());
|
|
3792
|
+
return match ? { min: match[1], max: match[2] } : null;
|
|
3793
|
+
}
|
|
3794
|
+
function isFlexUnit(value) {
|
|
3795
|
+
return /^[\d.]*fr$/.test(value.trim());
|
|
3796
|
+
}
|
|
3797
|
+
function colWidthStyle(col) {
|
|
3798
|
+
const parsed = parseMinMaxWidth(col.width);
|
|
3799
|
+
if (!parsed) {
|
|
3800
|
+
return {
|
|
3801
|
+
width: col.width ?? (col.minWidth != null ? `${col.minWidth}px` : void 0),
|
|
3802
|
+
minWidth: col.minWidth,
|
|
3803
|
+
maxWidth: col.maxWidth
|
|
3804
|
+
};
|
|
3805
|
+
}
|
|
3806
|
+
return {
|
|
3807
|
+
width: isFlexUnit(parsed.max) ? void 0 : parsed.max,
|
|
3808
|
+
// An explicit numeric `minWidth`/`maxWidth` alongside a `minmax()` string
|
|
3809
|
+
// is not a combination any caller uses today; the string wins because it
|
|
3810
|
+
// is the more specific of the two.
|
|
3811
|
+
minWidth: parsed.min,
|
|
3812
|
+
maxWidth: isFlexUnit(parsed.max) ? col.maxWidth : void 0
|
|
3813
|
+
};
|
|
3814
|
+
}
|
|
3789
3815
|
function DataTable({
|
|
3790
3816
|
columns,
|
|
3791
3817
|
data,
|
|
@@ -3932,17 +3958,7 @@ function DataTable({
|
|
|
3932
3958
|
children: [
|
|
3933
3959
|
tableLayout === "fixed" && !isEmpty && /* @__PURE__ */ jsxs31("colgroup", { children: [
|
|
3934
3960
|
hasExpand ? /* @__PURE__ */ jsx50("col", { style: { width: 40 } }) : null,
|
|
3935
|
-
columns.map((col) => /* @__PURE__ */ jsx50(
|
|
3936
|
-
"col",
|
|
3937
|
-
{
|
|
3938
|
-
style: {
|
|
3939
|
-
width: col.width ?? (col.minWidth != null ? `${col.minWidth}px` : void 0),
|
|
3940
|
-
minWidth: col.minWidth,
|
|
3941
|
-
maxWidth: col.maxWidth
|
|
3942
|
-
}
|
|
3943
|
-
},
|
|
3944
|
-
col.key
|
|
3945
|
-
)),
|
|
3961
|
+
columns.map((col) => /* @__PURE__ */ jsx50("col", { style: colWidthStyle(col) }, col.key)),
|
|
3946
3962
|
hasAction ? /* @__PURE__ */ jsx50("col", { style: { width: 0 } }) : null
|
|
3947
3963
|
] }),
|
|
3948
3964
|
/* @__PURE__ */ jsx50(
|