@pibit.ai/cure-design-system 0.3.45 → 0.3.50
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/applications/loading-indicator/index.d.ts +2 -0
- package/dist/applications/loading-indicator/index.d.ts.map +1 -0
- package/dist/applications/loading-indicator/loading-indicator.d.ts +1 -2
- package/dist/applications/loading-indicator/loading-indicator.d.ts.map +1 -1
- package/dist/assets/icons/filtered-view.svg.js +4 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +188 -168
- package/dist/patterns/table/TableWrapper.d.ts.map +1 -1
- package/dist/patterns/table/TableWrapper.js +447 -447
- package/dist/patterns/table/TableZoomControl.d.ts +2 -2
- package/dist/patterns/table/TableZoomControl.d.ts.map +1 -1
- package/dist/patterns/table/TableZoomControl.js +124 -46
- package/dist/patterns/table/index.d.ts +2 -2
- package/dist/patterns/table/index.d.ts.map +1 -1
- package/dist/patterns/table/storyHelpers/mockTableViewsApi.d.ts +25 -0
- package/dist/patterns/table/storyHelpers/mockTableViewsApi.d.ts.map +1 -0
- package/dist/patterns/table/tableZoomLayout.d.ts +6 -0
- package/dist/patterns/table/tableZoomLayout.d.ts.map +1 -1
- package/dist/patterns/table/tableZoomLayout.js +39 -33
- package/dist/patterns/table/toolbar/SummaryFooter.d.ts +10 -3
- package/dist/patterns/table/toolbar/SummaryFooter.d.ts.map +1 -1
- package/dist/patterns/table/toolbar/SummaryFooter.js +61 -71
- package/dist/patterns/table/toolbar/TableToolbar.d.ts +8 -0
- package/dist/patterns/table/toolbar/TableToolbar.d.ts.map +1 -1
- package/dist/patterns/table/toolbar/TableToolbar.js +200 -159
- package/dist/patterns/table/toolbar/TableViewDirtyActions.d.ts +7 -0
- package/dist/patterns/table/toolbar/TableViewDirtyActions.d.ts.map +1 -0
- package/dist/patterns/table/toolbar/TableViewDirtyActions.js +39 -0
- package/dist/patterns/table/toolbar/TableViewsDropdown.d.ts +8 -0
- package/dist/patterns/table/toolbar/TableViewsDropdown.d.ts.map +1 -0
- package/dist/patterns/table/toolbar/TableViewsDropdown.js +171 -0
- package/dist/patterns/table/toolbar/index.d.ts +4 -0
- package/dist/patterns/table/toolbar/index.d.ts.map +1 -1
- package/dist/patterns/table/toolbar/tableViewSnapshot.d.ts +18 -0
- package/dist/patterns/table/toolbar/tableViewSnapshot.d.ts.map +1 -0
- package/dist/patterns/table/toolbar/tableViewSnapshot.js +168 -0
- package/dist/patterns/table/toolbar/tableViewSnapshot.test.d.ts +2 -0
- package/dist/patterns/table/toolbar/tableViewSnapshot.test.d.ts.map +1 -0
- package/dist/patterns/table/toolbar/tableViewTypes.d.ts +73 -0
- package/dist/patterns/table/toolbar/tableViewTypes.d.ts.map +1 -0
- package/dist/patterns/table/toolbar/tableViewTypes.js +4 -0
- package/dist/patterns/table/types.d.ts +24 -1
- package/dist/patterns/table/types.d.ts.map +1 -1
- package/dist/patterns/table/useFitTableToViewport.d.ts +15 -0
- package/dist/patterns/table/useFitTableToViewport.d.ts.map +1 -0
- package/dist/patterns/table/useFitTableToViewport.js +47 -0
- package/dist/patterns/table/useTableZoomState.d.ts +20 -0
- package/dist/patterns/table/useTableZoomState.d.ts.map +1 -0
- package/dist/patterns/table/useTableZoomState.js +30 -0
- package/dist/patterns/table-component/TableComponent.d.ts.map +1 -1
- package/dist/patterns/table-component/TableComponent.js +385 -384
- package/dist/patterns/table-component/types.d.ts +2 -0
- package/dist/patterns/table-component/types.d.ts.map +1 -1
- package/dist/primitives/input/hint-text.d.ts +1 -2
- package/dist/primitives/input/hint-text.d.ts.map +1 -1
- package/dist/primitives/input/index.d.ts +3 -1
- package/dist/primitives/input/index.d.ts.map +1 -1
- package/dist/primitives/input/input.js +7 -7
- package/dist/primitives/input/label.d.ts +1 -2
- package/dist/primitives/input/label.d.ts.map +1 -1
- package/dist/primitives/select/index.d.ts +1 -0
- package/dist/primitives/select/index.d.ts.map +1 -1
- package/dist/primitives/select/select-item.d.ts +1 -2
- package/dist/primitives/select/select-item.d.ts.map +1 -1
- package/dist/styles/components.css +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { jsx as t, jsxs as l, Fragment as f } from "react/jsx-runtime";
|
|
2
|
+
import { useState as x } from "react";
|
|
3
|
+
import { ChevronDown as y, Check as b, DotsVertical as k, Edit03 as v, Share07 as D, Eye as N, Trash01 as S } from "@untitledui/icons";
|
|
4
|
+
import V from "../../../assets/icons/filtered-view.svg.js";
|
|
5
|
+
import { cx as p } from "../../../utils/cn.js";
|
|
6
|
+
import { DEFAULT_TABLE_VIEW_ID as C } from "./tableViewTypes.js";
|
|
7
|
+
import { Dropdown as h } from "../../../primitives/dropdown/dropdown.js";
|
|
8
|
+
import { Button as w } from "../../../primitives/button/button.js";
|
|
9
|
+
const m = ({ icon: e, label: r, danger: o, onClick: n }) => /* @__PURE__ */ l(
|
|
10
|
+
"button",
|
|
11
|
+
{
|
|
12
|
+
type: "button",
|
|
13
|
+
onClick: n,
|
|
14
|
+
className: p(
|
|
15
|
+
"flex w-full items-center gap-2 rounded-md px-2 py-2 text-left text-xs font-medium outline-none",
|
|
16
|
+
o ? "cursor-pointer text-error-primary hover:bg-error-primary" : "cursor-pointer text-secondary hover:bg-primary_hover"
|
|
17
|
+
),
|
|
18
|
+
children: [
|
|
19
|
+
/* @__PURE__ */ t(
|
|
20
|
+
e,
|
|
21
|
+
{
|
|
22
|
+
size: 16,
|
|
23
|
+
className: p("shrink-0", o ? "text-error-primary" : "text-fg-quaternary")
|
|
24
|
+
}
|
|
25
|
+
),
|
|
26
|
+
/* @__PURE__ */ t("span", { className: "flex-1 truncate", children: r })
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
function O({
|
|
31
|
+
view: e,
|
|
32
|
+
config: r,
|
|
33
|
+
onCloseParent: o,
|
|
34
|
+
onOpenChange: n
|
|
35
|
+
}) {
|
|
36
|
+
const [s, i] = x(!1), a = (c) => {
|
|
37
|
+
i(c), n == null || n(c);
|
|
38
|
+
}, d = (c) => () => {
|
|
39
|
+
c == null || c(e.id), a(!1), o();
|
|
40
|
+
};
|
|
41
|
+
return /* @__PURE__ */ l(h.Root, { isOpen: s, onOpenChange: a, children: [
|
|
42
|
+
/* @__PURE__ */ t(
|
|
43
|
+
w,
|
|
44
|
+
{
|
|
45
|
+
size: "xs",
|
|
46
|
+
color: "tertiary",
|
|
47
|
+
"aria-label": `Actions for ${e.name}`,
|
|
48
|
+
className: p(
|
|
49
|
+
"opacity-0 group-hover:opacity-100 data-pressed:opacity-100",
|
|
50
|
+
s && "bg-primary_hover opacity-100"
|
|
51
|
+
),
|
|
52
|
+
iconLeading: /* @__PURE__ */ t(k, { size: 16 })
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
/* @__PURE__ */ l(h.Popover, { placement: "right top", className: "w-52 p-1", children: [
|
|
56
|
+
r.onRename && /* @__PURE__ */ t(m, { icon: v, label: "Rename", onClick: d(r.onRename) }),
|
|
57
|
+
r.onShare && /* @__PURE__ */ t(m, { icon: D, label: "Share View", onClick: d(r.onShare) }),
|
|
58
|
+
r.onMakeDefault && !e.isDefault && /* @__PURE__ */ t(m, { icon: N, label: "Make Default View", onClick: d(r.onMakeDefault) }),
|
|
59
|
+
r.onDelete && /* @__PURE__ */ l(f, { children: [
|
|
60
|
+
/* @__PURE__ */ t("div", { className: "my-1 h-px w-full bg-border-secondary" }),
|
|
61
|
+
/* @__PURE__ */ t(m, { icon: S, label: "Delete View", danger: !0, onClick: d(r.onDelete) })
|
|
62
|
+
] })
|
|
63
|
+
] })
|
|
64
|
+
] });
|
|
65
|
+
}
|
|
66
|
+
function u({
|
|
67
|
+
view: e,
|
|
68
|
+
selected: r,
|
|
69
|
+
config: o,
|
|
70
|
+
onClose: n,
|
|
71
|
+
onSelect: s
|
|
72
|
+
}) {
|
|
73
|
+
const [i, a] = x(!1), d = e.kind === "owned" && !!(o.onRename || o.onShare || o.onMakeDefault || o.onDelete);
|
|
74
|
+
return /* @__PURE__ */ l(
|
|
75
|
+
"div",
|
|
76
|
+
{
|
|
77
|
+
className: p(
|
|
78
|
+
"group flex items-center gap-1 rounded-md px-1",
|
|
79
|
+
r ? "bg-utility-brand-25" : i ? "bg-primary_hover" : "hover:bg-primary_hover"
|
|
80
|
+
),
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ l(
|
|
83
|
+
"button",
|
|
84
|
+
{
|
|
85
|
+
type: "button",
|
|
86
|
+
className: "flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-2 text-left text-xs font-medium text-secondary outline-none",
|
|
87
|
+
onClick: () => {
|
|
88
|
+
s ? s() : o.onSelect(e.id), n();
|
|
89
|
+
},
|
|
90
|
+
children: [
|
|
91
|
+
/* @__PURE__ */ t("span", { className: "min-w-0 flex-1 truncate", children: e.name }),
|
|
92
|
+
r && /* @__PURE__ */ t(b, { size: 16, className: "shrink-0 text-brand-600" })
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
d && /* @__PURE__ */ t(
|
|
97
|
+
O,
|
|
98
|
+
{
|
|
99
|
+
view: e,
|
|
100
|
+
config: o,
|
|
101
|
+
onCloseParent: n,
|
|
102
|
+
onOpenChange: a
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
const A = ({ config: e, isDisabled: r }) => {
|
|
110
|
+
const [o, n] = x(!1), s = e.items.filter((a) => a.kind === "owned"), i = e.items.filter((a) => a.kind === "shared");
|
|
111
|
+
return /* @__PURE__ */ t("div", { className: "relative z-50 shrink-0", children: /* @__PURE__ */ l(h.Root, { isOpen: o, onOpenChange: n, children: [
|
|
112
|
+
/* @__PURE__ */ t(
|
|
113
|
+
w,
|
|
114
|
+
{
|
|
115
|
+
size: "xs",
|
|
116
|
+
color: "secondary",
|
|
117
|
+
"aria-label": "Table views",
|
|
118
|
+
title: "Table views",
|
|
119
|
+
isDisabled: r,
|
|
120
|
+
iconLeading: /* @__PURE__ */ t("img", { src: V, alt: "", className: "h-4 w-4" }),
|
|
121
|
+
iconTrailing: /* @__PURE__ */ t(y, { size: 16 })
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ t(h.Popover, { className: "z-50 w-56 p-1.5", children: /* @__PURE__ */ l("div", { className: "flex flex-col gap-1", children: [
|
|
125
|
+
e.onSelectInitial && /* @__PURE__ */ t(
|
|
126
|
+
u,
|
|
127
|
+
{
|
|
128
|
+
view: {
|
|
129
|
+
id: C,
|
|
130
|
+
name: "System View",
|
|
131
|
+
kind: "default"
|
|
132
|
+
},
|
|
133
|
+
selected: e.selectedId === void 0,
|
|
134
|
+
config: e,
|
|
135
|
+
onClose: () => n(!1),
|
|
136
|
+
onSelect: e.onSelectInitial
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
s.map((a) => /* @__PURE__ */ t(
|
|
140
|
+
u,
|
|
141
|
+
{
|
|
142
|
+
view: a,
|
|
143
|
+
selected: e.selectedId === a.id,
|
|
144
|
+
config: e,
|
|
145
|
+
onClose: () => n(!1)
|
|
146
|
+
},
|
|
147
|
+
a.id
|
|
148
|
+
)),
|
|
149
|
+
i.length > 0 && /* @__PURE__ */ l(f, { children: [
|
|
150
|
+
/* @__PURE__ */ t("div", { className: "px-2.5 pb-1 pt-2 text-[10px] font-semibold tracking-wide text-tertiary uppercase", children: "Shared with me" }),
|
|
151
|
+
i.map((a) => /* @__PURE__ */ t(
|
|
152
|
+
u,
|
|
153
|
+
{
|
|
154
|
+
view: a,
|
|
155
|
+
selected: e.selectedId === a.id,
|
|
156
|
+
config: e,
|
|
157
|
+
onClose: () => n(!1)
|
|
158
|
+
},
|
|
159
|
+
a.id
|
|
160
|
+
))
|
|
161
|
+
] })
|
|
162
|
+
] }) })
|
|
163
|
+
] }) });
|
|
164
|
+
};
|
|
165
|
+
function B(e) {
|
|
166
|
+
return e.some((r) => r.kind === "owned" || r.kind === "shared");
|
|
167
|
+
}
|
|
168
|
+
export {
|
|
169
|
+
A as TableViewsDropdown,
|
|
170
|
+
B as hasSavedOrSharedViews
|
|
171
|
+
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export { TableToolbar, pickCoreToolbarProps } from './TableToolbar';
|
|
2
2
|
export type { TableToolbarProps, SortToolConfig, FilterToolConfig, SearchToolConfig, RowHeightToolConfig, HideFieldsToolConfig, AlignToolConfig, GroupByToolConfig, SummaryToolConfig, UndoRedoToolConfig, } from './TableToolbar';
|
|
3
|
+
export { TableViewsDropdown, hasSavedOrSharedViews } from './TableViewsDropdown';
|
|
4
|
+
export { TableViewDirtyActions } from './TableViewDirtyActions';
|
|
5
|
+
export { DEFAULT_TABLE_VIEW_ID, type TableViewKind, type TableViewDirtyAction, type TableViewSnapshot, type TableViewSharee, type TableSavedViewRecord, type TableViewsByTableName, type TableViewListItem, type TableViewsConfig, type SaveTableViewRequest, } from './tableViewTypes';
|
|
6
|
+
export { getInitialTableViewSnapshot, toTableViewSnapshot, normalizeTableViewSnapshot, isTableViewDirty, applyTableViewSnapshot, snapshotFromViewRecord, parseTableSavedViewRecord, } from './tableViewSnapshot';
|
|
3
7
|
export { RowHeightDropdown } from './RowHeightDropdown';
|
|
4
8
|
export type { RowHeightOption } from './RowHeightDropdown';
|
|
5
9
|
export { ROW_HEIGHT_CLASS } from './tableToolbarHelpers';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/patterns/table/toolbar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACpE,YAAY,EACV,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,gBA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';
|
|
3
|
+
export type TableViewSnapshotSources = TableUndoSnapshotSources & {
|
|
4
|
+
zoom?: number;
|
|
5
|
+
onZoomChange?: (zoom: number) => void;
|
|
6
|
+
};
|
|
7
|
+
/** Initial, unsaved table state used before a persisted view is selected. */
|
|
8
|
+
export declare function getInitialTableViewSnapshot(columnOrder?: readonly string[]): TableViewSnapshot;
|
|
9
|
+
export declare function toTableViewSnapshot(sources: TableViewSnapshotSources): TableViewSnapshot;
|
|
10
|
+
export declare function normalizeTableViewSnapshot(snapshot: TableViewSnapshot): TableViewSnapshot;
|
|
11
|
+
export declare function isTableViewDirty(current: TableViewSnapshot, saved: TableViewSnapshot): boolean;
|
|
12
|
+
export declare function applyTableViewSnapshot(snapshot: TableViewSnapshot, sources: TableViewSnapshotSources): void;
|
|
13
|
+
/**
|
|
14
|
+
* Accepts either nested `snapshot` or the flattened API shape, including `Zoom`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function snapshotFromViewRecord(view: TableSavedViewRecord | Record<string, unknown>): TableViewSnapshot;
|
|
17
|
+
export declare function parseTableSavedViewRecord(view: Record<string, unknown>): TableSavedViewRecord;
|
|
18
|
+
//# sourceMappingURL=tableViewSnapshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableViewSnapshot.d.ts","sourceRoot":"","sources":["../../../../src/patterns/table/toolbar/tableViewSnapshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAKpF,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAKhF,MAAM,MAAM,wBAAwB,GAAG,wBAAwB,GAAG;IAChE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACvC,CAAC;AA6DF,6EAA6E;AAC7E,wBAAgB,2BAA2B,CACzC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,GAC9B,iBAAiB,CAYnB;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,wBAAwB,GAChC,iBAAiB,CAuBnB;AAED,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,iBAAiB,GAC1B,iBAAiB,CAcnB;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,iBAAiB,GACvB,OAAO,CA0BT;AAmBD,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,wBAAwB,GAChC,IAAI,CAKN;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnD,iBAAiB,CA6BnB;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,oBAAoB,CAatB"}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { applyTableUndoSnapshot as f, captureTableUndoSnapshot as h } from "../tableUndoRedo.js";
|
|
2
|
+
const A = /* @__PURE__ */ new Set(["left", "center", "right"]), w = /* @__PURE__ */ new Set(["small", "medium", "large", "xl"]);
|
|
3
|
+
function l(o) {
|
|
4
|
+
return typeof o == "object" && o !== null && !Array.isArray(o);
|
|
5
|
+
}
|
|
6
|
+
function u(o) {
|
|
7
|
+
return (o ?? []).filter((n) => n.field !== "" && n.direction !== "").map((n) => ({ field: n.field, direction: n.direction }));
|
|
8
|
+
}
|
|
9
|
+
function g(o) {
|
|
10
|
+
return (o ?? []).map((n) => ({ ...n }));
|
|
11
|
+
}
|
|
12
|
+
function y(o) {
|
|
13
|
+
const n = {};
|
|
14
|
+
if (!o) return n;
|
|
15
|
+
for (const [r, e] of Object.entries(o))
|
|
16
|
+
A.has(e) && (n[r] = e);
|
|
17
|
+
return n;
|
|
18
|
+
}
|
|
19
|
+
function c(o) {
|
|
20
|
+
return Object.fromEntries(
|
|
21
|
+
Object.entries(o).sort(([n], [r]) => n.localeCompare(r))
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
function C(o) {
|
|
25
|
+
if (!l(o)) return {};
|
|
26
|
+
const n = {};
|
|
27
|
+
for (const [r, e] of Object.entries(o))
|
|
28
|
+
(e === "left" || e === "center" || e === "right") && (n[r] = e);
|
|
29
|
+
return n;
|
|
30
|
+
}
|
|
31
|
+
function t(o) {
|
|
32
|
+
return typeof o == "number" && Number.isFinite(o) ? o : void 0;
|
|
33
|
+
}
|
|
34
|
+
function S(o) {
|
|
35
|
+
return typeof o == "string" && w.has(o) ? o : void 0;
|
|
36
|
+
}
|
|
37
|
+
function p(o) {
|
|
38
|
+
return l(o) ? { ...o } : {};
|
|
39
|
+
}
|
|
40
|
+
function H(o) {
|
|
41
|
+
return {
|
|
42
|
+
sorts: [],
|
|
43
|
+
filterConditions: [],
|
|
44
|
+
hiddenColumns: [],
|
|
45
|
+
columnOrder: o ? [...o] : void 0,
|
|
46
|
+
columnAlignments: {},
|
|
47
|
+
groupBy: null,
|
|
48
|
+
showSummary: !1,
|
|
49
|
+
summaryAggregations: {},
|
|
50
|
+
rowHeight: "small"
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function z(o) {
|
|
54
|
+
var d, a;
|
|
55
|
+
const n = h(o), r = {};
|
|
56
|
+
(d = n.columnAlignments) == null || d.forEach((i, m) => {
|
|
57
|
+
r[m] = i;
|
|
58
|
+
});
|
|
59
|
+
const e = {};
|
|
60
|
+
return (a = n.summaryAggregations) == null || a.forEach((i, m) => {
|
|
61
|
+
e[m] = i;
|
|
62
|
+
}), {
|
|
63
|
+
sorts: u(n.sorts),
|
|
64
|
+
filterConditions: g(n.filterConditions),
|
|
65
|
+
hiddenColumns: [...n.hiddenColumns ?? []].sort(),
|
|
66
|
+
columnOrder: n.columnOrder ? [...n.columnOrder] : void 0,
|
|
67
|
+
columnAlignments: r,
|
|
68
|
+
groupBy: n.groupBy ?? null,
|
|
69
|
+
showSummary: n.showSummary ?? !1,
|
|
70
|
+
summaryAggregations: e,
|
|
71
|
+
rowHeight: n.rowHeight ?? "small",
|
|
72
|
+
zoom: o.zoom
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function s(o) {
|
|
76
|
+
return {
|
|
77
|
+
sorts: u(o.sorts),
|
|
78
|
+
filterConditions: g(o.filterConditions),
|
|
79
|
+
hiddenColumns: [...o.hiddenColumns ?? []].sort(),
|
|
80
|
+
columnOrder: o.columnOrder ? [...o.columnOrder] : void 0,
|
|
81
|
+
columnAlignments: c(y(o.columnAlignments)),
|
|
82
|
+
groupBy: o.groupBy ?? null,
|
|
83
|
+
showSummary: !!o.showSummary,
|
|
84
|
+
summaryAggregations: c(o.summaryAggregations ?? {}),
|
|
85
|
+
rowHeight: o.rowHeight ?? "small",
|
|
86
|
+
zoom: o.zoom,
|
|
87
|
+
layout_key: o.layout_key
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function _(o, n) {
|
|
91
|
+
const r = s(o), e = s(n);
|
|
92
|
+
return JSON.stringify({
|
|
93
|
+
sorts: r.sorts,
|
|
94
|
+
filterConditions: r.filterConditions,
|
|
95
|
+
hiddenColumns: r.hiddenColumns,
|
|
96
|
+
columnOrder: r.columnOrder,
|
|
97
|
+
columnAlignments: r.columnAlignments,
|
|
98
|
+
groupBy: r.groupBy,
|
|
99
|
+
showSummary: r.showSummary,
|
|
100
|
+
summaryAggregations: r.summaryAggregations,
|
|
101
|
+
rowHeight: r.rowHeight,
|
|
102
|
+
zoom: r.zoom
|
|
103
|
+
}) !== JSON.stringify({
|
|
104
|
+
sorts: e.sorts,
|
|
105
|
+
filterConditions: e.filterConditions,
|
|
106
|
+
hiddenColumns: e.hiddenColumns,
|
|
107
|
+
columnOrder: e.columnOrder,
|
|
108
|
+
columnAlignments: e.columnAlignments,
|
|
109
|
+
groupBy: e.groupBy,
|
|
110
|
+
showSummary: e.showSummary,
|
|
111
|
+
summaryAggregations: e.summaryAggregations,
|
|
112
|
+
rowHeight: e.rowHeight,
|
|
113
|
+
zoom: e.zoom
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function O(o) {
|
|
117
|
+
const n = y(o.columnAlignments);
|
|
118
|
+
return {
|
|
119
|
+
hiddenColumns: new Set(o.hiddenColumns ?? []),
|
|
120
|
+
columnOrder: o.columnOrder ? [...o.columnOrder] : void 0,
|
|
121
|
+
columnAlignments: new Map(Object.entries(n)),
|
|
122
|
+
groupBy: o.groupBy ?? null,
|
|
123
|
+
showSummary: o.showSummary ?? !1,
|
|
124
|
+
summaryAggregations: o.summaryAggregations ? new Map(Object.entries(o.summaryAggregations)) : /* @__PURE__ */ new Map(),
|
|
125
|
+
rowHeight: o.rowHeight ?? "small",
|
|
126
|
+
sorts: u(o.sorts),
|
|
127
|
+
filterConditions: g(o.filterConditions)
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function k(o, n) {
|
|
131
|
+
f(O(o), n), o.zoom != null && n.onZoomChange && n.onZoomChange(o.zoom);
|
|
132
|
+
}
|
|
133
|
+
function b(o) {
|
|
134
|
+
const n = o, r = l(n.snapshot) ? n.snapshot : n, e = t(r.zoom) ?? t(r.Zoom) ?? t(n.zoom) ?? t(n.Zoom);
|
|
135
|
+
return s({
|
|
136
|
+
layout_key: typeof r.layout_key == "string" ? r.layout_key : typeof n.layout_key == "string" ? n.layout_key : void 0,
|
|
137
|
+
sorts: Array.isArray(r.sorts) ? r.sorts : [],
|
|
138
|
+
filterConditions: Array.isArray(r.filterConditions) ? r.filterConditions : [],
|
|
139
|
+
hiddenColumns: Array.isArray(r.hiddenColumns) ? r.hiddenColumns : [],
|
|
140
|
+
columnOrder: Array.isArray(r.columnOrder) ? r.columnOrder : void 0,
|
|
141
|
+
columnAlignments: C(r.columnAlignments),
|
|
142
|
+
groupBy: r.groupBy === void 0 ? null : r.groupBy,
|
|
143
|
+
showSummary: !!r.showSummary,
|
|
144
|
+
summaryAggregations: p(r.summaryAggregations),
|
|
145
|
+
rowHeight: S(r.rowHeight),
|
|
146
|
+
zoom: e
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
function T(o) {
|
|
150
|
+
const n = b(o), r = o.kind === "shared" ? "shared" : "owned";
|
|
151
|
+
return {
|
|
152
|
+
...n,
|
|
153
|
+
id: String(o.id ?? ""),
|
|
154
|
+
name: String(o.name ?? "Untitled view"),
|
|
155
|
+
kind: r,
|
|
156
|
+
owner_id: typeof o.owner_id == "string" ? o.owner_id : void 0,
|
|
157
|
+
shared_with: Array.isArray(o.shared_with) ? o.shared_with : void 0
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
export {
|
|
161
|
+
k as applyTableViewSnapshot,
|
|
162
|
+
H as getInitialTableViewSnapshot,
|
|
163
|
+
_ as isTableViewDirty,
|
|
164
|
+
s as normalizeTableViewSnapshot,
|
|
165
|
+
T as parseTableSavedViewRecord,
|
|
166
|
+
b as snapshotFromViewRecord,
|
|
167
|
+
z as toTableViewSnapshot
|
|
168
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableViewSnapshot.test.d.ts","sourceRoot":"","sources":["../../../../src/patterns/table/toolbar/tableViewSnapshot.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { LegacyFilterCondition, LegacySort } from './legacyToolbarTypes';
|
|
2
|
+
import { RowHeightOption } from './RowHeightDropdown';
|
|
3
|
+
import { AggregationType, CellAlignment } from './tableToolbarHelpers';
|
|
4
|
+
/** Synthetic, non-persisted item used to restore the initial table state. */
|
|
5
|
+
export declare const DEFAULT_TABLE_VIEW_ID = "default";
|
|
6
|
+
export type TableViewKind = "default" | "owned" | "shared";
|
|
7
|
+
/** Which dirty chrome the toolbar should render. Computed by the consumer. */
|
|
8
|
+
export type TableViewDirtyAction = "none" | "save" | "update";
|
|
9
|
+
/**
|
|
10
|
+
* JSON-serializable toolbar snapshot stored on a saved view.
|
|
11
|
+
* Matches the flattened view payload (sorts / filters / hide / …) used by
|
|
12
|
+
* submission-overview table views. Search is intentionally omitted.
|
|
13
|
+
*/
|
|
14
|
+
export type TableViewSnapshot = {
|
|
15
|
+
layout_key?: string;
|
|
16
|
+
sorts?: LegacySort[];
|
|
17
|
+
filterConditions?: LegacyFilterCondition[];
|
|
18
|
+
hiddenColumns?: string[];
|
|
19
|
+
columnOrder?: string[];
|
|
20
|
+
columnAlignments?: Record<string, CellAlignment>;
|
|
21
|
+
groupBy?: string | null;
|
|
22
|
+
showSummary?: boolean;
|
|
23
|
+
summaryAggregations?: Record<string, AggregationType>;
|
|
24
|
+
rowHeight?: RowHeightOption;
|
|
25
|
+
/** Serialized as `Zoom` on some payloads. */
|
|
26
|
+
zoom?: number;
|
|
27
|
+
};
|
|
28
|
+
export type TableViewSharee = {
|
|
29
|
+
id: string;
|
|
30
|
+
kind: "user" | "team";
|
|
31
|
+
name?: string;
|
|
32
|
+
};
|
|
33
|
+
export type TableSavedViewRecord = TableViewSnapshot & {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
kind: "owned" | "shared";
|
|
37
|
+
owner_id?: string;
|
|
38
|
+
shared_with?: TableViewSharee[];
|
|
39
|
+
};
|
|
40
|
+
export type TableViewsByTableName = Record<string, {
|
|
41
|
+
views: TableSavedViewRecord[];
|
|
42
|
+
}>;
|
|
43
|
+
export type TableViewListItem = {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
kind: TableViewKind;
|
|
47
|
+
isDefault?: boolean;
|
|
48
|
+
};
|
|
49
|
+
export type TableViewsConfig = {
|
|
50
|
+
items: TableViewListItem[];
|
|
51
|
+
/** Undefined when the table is showing its unsaved, initial state. */
|
|
52
|
+
selectedId?: string;
|
|
53
|
+
dirtyAction: TableViewDirtyAction;
|
|
54
|
+
onSelect: (id: string) => void;
|
|
55
|
+
/** Restores the consumer-managed, unsaved initial table state. It is never persisted. */
|
|
56
|
+
onSelectInitial?: () => void;
|
|
57
|
+
initialViewLabel?: string;
|
|
58
|
+
onSaveClick: () => void;
|
|
59
|
+
onRevertClick?: () => void;
|
|
60
|
+
onUpdateClick?: () => void;
|
|
61
|
+
onRename?: (id: string) => void;
|
|
62
|
+
onShare?: (id: string) => void;
|
|
63
|
+
onMakeDefault?: (id: string) => void;
|
|
64
|
+
onDelete?: (id: string) => void;
|
|
65
|
+
};
|
|
66
|
+
export type SaveTableViewRequest = TableViewSnapshot & {
|
|
67
|
+
layout_key: string;
|
|
68
|
+
tableName: string;
|
|
69
|
+
name: string;
|
|
70
|
+
shareUserIds: string[];
|
|
71
|
+
shareTeamIds: string[];
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=tableViewTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tableViewTypes.d.ts","sourceRoot":"","sources":["../../../../src/patterns/table/toolbar/tableViewTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE5E,6EAA6E;AAC7E,eAAO,MAAM,qBAAqB,YAAY,CAAC;AAE/C,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE3D,8EAA8E;AAC9E,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE9D;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,gBAAgB,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAC3C,aAAa,CAAC,EAAE,M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AAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,yFAAyF;IACzF,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;IAC7B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,EAAE,MAAM,IAAI,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,aAAa,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,GAAG;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { TablePaginationConfig } from './TablePagination';
|
|
3
3
|
import { UndoRedoToolConfig } from './toolbar/TableToolbar';
|
|
4
|
+
import { TableViewsConfig } from './toolbar/tableViewTypes';
|
|
4
5
|
import { LegacyFilterToolConfig, LegacySortToolConfig } from './toolbar/legacyToolbarTypes';
|
|
5
6
|
import { AlignToolConfig, GroupByToolConfig, HideFieldsToolConfig, RowHeightToolConfig, SearchToolConfig, SummaryToolConfig, CellAlignment, ColumnMenuAction, ColumnMenuCapabilities, RowActionsConfig, RowGroup, SummaryFooterRowProps } from './toolbar';
|
|
6
7
|
import { TableCellRangeRect, TableCellSelection } from './cellRangeSelection';
|
|
@@ -52,11 +53,27 @@ export type TableWrapperPaginationConfig = TablePaginationConfig;
|
|
|
52
53
|
*
|
|
53
54
|
* The object may be a fresh literal on every render; `TableWrapper` keys its internal
|
|
54
55
|
* config off the four values below, not the object identity, so an inline literal will not
|
|
55
|
-
* reset a zoom level the user has set.
|
|
56
|
+
* reset a zoom level the user has set. The last chosen zoom is remembered across remounts
|
|
57
|
+
* (for example entering edit mode) using an explicit `persistKey`.
|
|
58
|
+
* The zoom menu always offers Actual Size at 100% (when that value is inside the configured
|
|
59
|
+
* range) and Fit Whole Table, which remasures after the first snap so a single click
|
|
60
|
+
* reaches the largest allowed slider stop that actually fits.
|
|
56
61
|
*/
|
|
57
62
|
export type TableZoomConfig = {
|
|
58
63
|
/** Initial zoom percentage. Defaults to 100. */
|
|
59
64
|
defaultZoom?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Controlled zoom percentage. Pair with `onZoomChange`. When omitted, the table keeps
|
|
67
|
+
* the value internally and restores it after remount via `persistKey`.
|
|
68
|
+
*/
|
|
69
|
+
value?: number;
|
|
70
|
+
/** Fired whenever the user changes zoom (slider, Actual Size, or Fit Whole Table). */
|
|
71
|
+
onZoomChange?: (zoom: number) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Stable id used to remember this table's zoom across remounts (for example edit mode).
|
|
74
|
+
* Use a different key for every independently zoomable table.
|
|
75
|
+
*/
|
|
76
|
+
persistKey?: string;
|
|
60
77
|
/**
|
|
61
78
|
* Lowest allowed zoom percentage. Defaults to 60, and is the real limit — zooming out
|
|
62
79
|
* past the point where the grid fits is allowed, so on a table that already fills its
|
|
@@ -87,6 +104,10 @@ export type TableWrapperToolbarConfig = {
|
|
|
87
104
|
filterContent?: ReactNode;
|
|
88
105
|
/** Consumer-owned undo/redo state — renders toolbar buttons and keyboard shortcuts when provided. */
|
|
89
106
|
undoRedo?: UndoRedoToolConfig;
|
|
107
|
+
/**
|
|
108
|
+
* Saved-view chrome. Consumer owns list/dirty/API; TableWrapper only forwards this to TableToolbar.
|
|
109
|
+
*/
|
|
110
|
+
views?: TableViewsConfig;
|
|
90
111
|
};
|
|
91
112
|
/** Controlled selection value for TableWrapper (`"all"` = every row in the current body). */
|
|
92
113
|
export type TableWrapperSelectedKeys = "all" | ReadonlySet<string>;
|
|
@@ -153,6 +174,8 @@ export type TableWrapperProps = {
|
|
|
153
174
|
showEditActions?: boolean;
|
|
154
175
|
searchCollapsible?: boolean;
|
|
155
176
|
disableExtendedTools?: boolean;
|
|
177
|
+
/** When false, the toolbar shows only Sort, Filter, Hide Fields, Align, and Zoom. */
|
|
178
|
+
isEditMode?: boolean;
|
|
156
179
|
isEditable?: boolean;
|
|
157
180
|
rowHeightClass?: string;
|
|
158
181
|
groupedData?: RowGroup<Record<string, unknown>>[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/patterns/table/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,gBAAgB,EAChB,QAAQ,EACR,qBAAqB,EACtB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EACV,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,YAAY,EACV,cAAc,EACd,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,sBAAsB,CAAC;AAE9B,0EAA0E;AAC1E,MAAM,MAAM,oBAAoB,GAC5B,QA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AG,IAAI,CAAC;KAC5B,KAAK,IAAI,CAAC;IACX,gCAAgC,CAAC,EAAE,CACjC,MAAM,EAAE,qBAAqB,KAC1B,SAAS,CAAC;IACf;;;;;OAKG;IACH,aAAa,CAAC,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC1C,qBAAqB,CAAC,EAAE,CAAC,SAAS,EAAE,kBAAkB,GAAG,IAAI,KAAK,IAAI,CAAC;IACvE,8EAA8E;IAC9E,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE;QACtB,SAAS,EAAE,kBAAkB,CAAC;QAC9B,IAAI,EAAE,kBAAkB,CAAC;QACzB,KAAK,EAAE,cAAc,CAAC;KACvB,KAAK,IAAI,CAAC;IACX,+EAA+E;IAC/E,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE;QACvB,SAAS,EAAE,kBAAkB,CAAC;QAC9B,IAAI,EAAE,kBAAkB,CAAC;QACzB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,cAAc,CAAC;KACvB,KAAK,IAAI,CAAC;IACX,0FAA0F;IAC1F,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE;QACvB,SAAS,EAAE,kBAAkB,CAAC;QAC9B,IAAI,EAAE,kBAAkB,CAAC;QACzB,KAAK,EAAE,aAAa,CAAC;KACtB,KAAK,IAAI,CAAC;CACZ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Dispatch, RefObject, SetStateAction } from 'react';
|
|
2
|
+
type ZoomRange = {
|
|
3
|
+
minZoom: number;
|
|
4
|
+
maxZoom: number;
|
|
5
|
+
step: number;
|
|
6
|
+
};
|
|
7
|
+
/** Applies Fit Whole Table until the measured painted table fits its scroll viewport. */
|
|
8
|
+
export declare const useFitTableToViewport: ({ containerRef, zoomConfig, zoomPercent, setZoomPercent, }: {
|
|
9
|
+
containerRef: RefObject<HTMLElement | null>;
|
|
10
|
+
zoomConfig: ZoomRange | null;
|
|
11
|
+
zoomPercent: number;
|
|
12
|
+
setZoomPercent: Dispatch<SetStateAction<number>>;
|
|
13
|
+
}) => () => void;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=useFitTableToViewport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFitTableToViewport.d.ts","sourceRoot":"","sources":["../../../src/patterns/table/useFitTableToViewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;AAGf,KAAK,SAAS,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpE,yFAAyF;AACzF,eAAO,MAAM,qBAAqB,GAAI,4DAKnC;IACD,YAAY,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC5C,UAAU,EAAE,SAAS,GAAG,IAAI,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC;CAClD,eAmDA,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { useRef as d, useCallback as b, useLayoutEffect as p } from "react";
|
|
2
|
+
import { computeFitTableZoom as a, SCROLL_EPSILON_PX as h } from "./tableZoomLayout.js";
|
|
3
|
+
const x = ({
|
|
4
|
+
containerRef: l,
|
|
5
|
+
zoomConfig: e,
|
|
6
|
+
zoomPercent: u,
|
|
7
|
+
setZoomPercent: i
|
|
8
|
+
}) => {
|
|
9
|
+
const s = d(!1), n = b(() => {
|
|
10
|
+
const t = l.current, r = t == null ? void 0 : t.querySelector("table");
|
|
11
|
+
!t || !r || !e || (s.current = !0, i(
|
|
12
|
+
a(
|
|
13
|
+
t.clientWidth,
|
|
14
|
+
r.getBoundingClientRect().width,
|
|
15
|
+
u,
|
|
16
|
+
e.minZoom,
|
|
17
|
+
e.maxZoom,
|
|
18
|
+
e.step
|
|
19
|
+
)
|
|
20
|
+
));
|
|
21
|
+
}, [l, i, e, u]);
|
|
22
|
+
return p(() => {
|
|
23
|
+
if (!s.current || !e) return;
|
|
24
|
+
const t = l.current, r = t == null ? void 0 : t.querySelector("table");
|
|
25
|
+
if (!t || !r) return;
|
|
26
|
+
if (r.getBoundingClientRect().width <= t.clientWidth + h) {
|
|
27
|
+
s.current = !1;
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const c = a(
|
|
31
|
+
t.clientWidth,
|
|
32
|
+
r.getBoundingClientRect().width,
|
|
33
|
+
u,
|
|
34
|
+
e.minZoom,
|
|
35
|
+
e.maxZoom,
|
|
36
|
+
e.step
|
|
37
|
+
);
|
|
38
|
+
if (c >= u) {
|
|
39
|
+
s.current = !1;
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
i(c);
|
|
43
|
+
}, [l, i, e, u]), n;
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
x as useFitTableToViewport
|
|
47
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { SetStateAction } from 'react';
|
|
2
|
+
import { TableZoomConfig } from './types';
|
|
3
|
+
/** Clears remembered zoom. Tests use this so cases do not leak into each other. */
|
|
4
|
+
export declare const clearPersistedTableZoom: (key?: string) => void;
|
|
5
|
+
/**
|
|
6
|
+
* Zoom percentage for TableWrapper / TableComponent. Remounts (edit mode swapping the
|
|
7
|
+
* table instance) restore the last value for an explicit `persistKey`, unless the consumer
|
|
8
|
+
* is controlling `value`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const useTableZoomState: (zoom: TableZoomConfig | undefined) => {
|
|
11
|
+
zoomConfig: {
|
|
12
|
+
minZoom: number;
|
|
13
|
+
maxZoom: number;
|
|
14
|
+
step: number;
|
|
15
|
+
defaultZoom: number;
|
|
16
|
+
} | null;
|
|
17
|
+
zoomPercent: number;
|
|
18
|
+
setZoomPercent: (next: SetStateAction<number>) => void;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=useTableZoomState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTableZoomState.d.ts","sourceRoot":"","sources":["../../../src/patterns/table/useTableZoomState.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;AAQf,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAI/C,mFAAmF;AACnF,eAAO,MAAM,uBAAuB,GAAI,MAAM,MAAM,SAGnD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,eAAe,GAAG,SAAS;;;;;;;;2BAoCxD,cAAc,CAAC,MAAM,CAAC;CAahC,CAAC"}
|