@helpwave/hightide 0.1.27 → 0.1.28
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/coloring/index.d.mts +2 -0
- package/dist/coloring/index.d.ts +2 -0
- package/dist/coloring/index.js +85 -0
- package/dist/coloring/index.js.map +1 -0
- package/dist/coloring/index.mjs +48 -0
- package/dist/coloring/index.mjs.map +1 -0
- package/dist/components/branding/index.d.mts +3 -0
- package/dist/components/branding/index.d.ts +3 -0
- package/dist/components/branding/index.js +140 -0
- package/dist/components/branding/index.js.map +1 -0
- package/dist/components/branding/index.mjs +104 -0
- package/dist/components/branding/index.mjs.map +1 -0
- package/dist/components/date/index.d.mts +10 -0
- package/dist/components/date/index.d.ts +10 -0
- package/dist/components/date/index.js +1168 -0
- package/dist/components/date/index.js.map +1 -0
- package/dist/components/date/index.mjs +1124 -0
- package/dist/components/date/index.mjs.map +1 -0
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/form/index.d.mts +5 -0
- package/dist/components/form/index.d.ts +5 -0
- package/dist/components/form/index.js +100 -0
- package/dist/components/form/index.js.map +1 -0
- package/dist/components/form/index.mjs +64 -0
- package/dist/components/form/index.mjs.map +1 -0
- package/dist/components/icons-and-geometry/index.d.mts +7 -0
- package/dist/components/icons-and-geometry/index.d.ts +7 -0
- package/dist/components/icons-and-geometry/index.js +3955 -0
- package/dist/components/icons-and-geometry/index.js.map +1 -0
- package/dist/components/icons-and-geometry/index.mjs +3939 -0
- package/dist/components/icons-and-geometry/index.mjs.map +1 -0
- package/dist/components/index.d.mts +83 -0
- package/dist/components/index.d.ts +83 -0
- package/dist/components/index.js +15471 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/index.mjs +15377 -0
- package/dist/components/index.mjs.map +1 -0
- package/dist/components/layout/index.d.mts +18 -0
- package/dist/components/layout/index.d.ts +18 -0
- package/dist/components/layout/index.js +3111 -0
- package/dist/components/layout/index.js.map +1 -0
- package/dist/components/layout/index.mjs +3064 -0
- package/dist/components/layout/index.mjs.map +1 -0
- package/dist/components/loading-states/index.d.mts +12 -0
- package/dist/components/loading-states/index.d.ts +12 -0
- package/dist/components/loading-states/index.js +614 -0
- package/dist/components/loading-states/index.js.map +1 -0
- package/dist/components/loading-states/index.mjs +573 -0
- package/dist/components/loading-states/index.mjs.map +1 -0
- package/dist/components/navigation/index.d.mts +9 -0
- package/dist/components/navigation/index.d.ts +9 -0
- package/dist/components/navigation/index.js +4660 -0
- package/dist/components/navigation/index.js.map +1 -0
- package/dist/components/navigation/index.mjs +4648 -0
- package/dist/components/navigation/index.mjs.map +1 -0
- package/dist/components/properties/index.d.mts +12 -0
- package/dist/components/properties/index.d.ts +12 -0
- package/dist/components/properties/index.js +2983 -0
- package/dist/components/properties/index.js.map +1 -0
- package/dist/components/properties/index.mjs +2951 -0
- package/dist/components/properties/index.mjs.map +1 -0
- package/dist/components/table/index.d.mts +10 -0
- package/dist/components/table/index.d.ts +10 -0
- package/dist/components/table/index.js +2329 -0
- package/dist/components/table/index.js.map +1 -0
- package/dist/components/table/index.mjs +2293 -0
- package/dist/components/table/index.mjs.map +1 -0
- package/dist/components/user-action/index.d.mts +30 -0
- package/dist/components/user-action/index.d.ts +30 -0
- package/dist/components/user-action/index.js +4257 -0
- package/dist/components/user-action/index.js.map +1 -0
- package/dist/components/user-action/index.mjs +4195 -0
- package/dist/components/user-action/index.mjs.map +1 -0
- package/dist/components/user-action/input/index.d.mts +6 -0
- package/dist/components/user-action/input/index.d.ts +6 -0
- package/dist/components/user-action/input/index.js +398 -0
- package/dist/components/user-action/input/index.js.map +1 -0
- package/dist/components/user-action/input/index.mjs +357 -0
- package/dist/components/user-action/input/index.mjs.map +1 -0
- package/dist/components/user-action/select/index.d.mts +4 -0
- package/dist/components/user-action/select/index.d.ts +4 -0
- package/dist/components/user-action/select/index.js +1369 -0
- package/dist/components/user-action/select/index.js.map +1 -0
- package/dist/components/user-action/select/index.mjs +1333 -0
- package/dist/components/user-action/select/index.mjs.map +1 -0
- package/dist/components/utils/index.d.mts +4 -0
- package/dist/components/utils/index.d.ts +4 -0
- package/dist/components/utils/index.js +302 -0
- package/dist/components/utils/index.js.map +1 -0
- package/dist/components/utils/index.mjs +275 -0
- package/dist/components/utils/index.mjs.map +1 -0
- package/dist/hooks/focus/index.d.mts +6 -0
- package/dist/hooks/focus/index.d.ts +6 -0
- package/dist/hooks/focus/index.js +379 -0
- package/dist/hooks/focus/index.js.map +1 -0
- package/dist/hooks/focus/index.mjs +339 -0
- package/dist/hooks/focus/index.mjs.map +1 -0
- package/dist/hooks/index.d.mts +16 -0
- package/dist/hooks/index.d.ts +16 -0
- package/dist/hooks/index.js +844 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/index.mjs +794 -0
- package/dist/hooks/index.mjs.map +1 -0
- package/dist/index.d.mts +110 -0
- package/dist/index.d.ts +110 -0
- package/dist/index.js +16101 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +15941 -0
- package/dist/index.mjs.map +1 -0
- package/dist/localization/defaults/index.d.mts +4 -0
- package/dist/localization/defaults/index.d.ts +4 -0
- package/dist/localization/defaults/index.js +223 -0
- package/dist/localization/defaults/index.js.map +1 -0
- package/dist/localization/defaults/index.mjs +195 -0
- package/dist/localization/defaults/index.mjs.map +1 -0
- package/dist/localization/index.d.mts +7 -0
- package/dist/localization/index.d.ts +7 -0
- package/dist/localization/index.js +415 -0
- package/dist/localization/index.js.map +1 -0
- package/dist/localization/index.mjs +380 -0
- package/dist/localization/index.mjs.map +1 -0
- package/dist/theming/index.d.mts +5 -0
- package/dist/theming/index.d.ts +5 -0
- package/dist/theming/index.js +174 -0
- package/dist/theming/index.js.map +1 -0
- package/dist/theming/index.mjs +145 -0
- package/dist/theming/index.mjs.map +1 -0
- package/dist/utils/index.d.mts +15 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.js +553 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +493 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +25 -24
|
@@ -0,0 +1,2293 @@
|
|
|
1
|
+
// src/components/table/FillerRowElement.tsx
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var FillerRowElement = ({
|
|
5
|
+
className
|
|
6
|
+
}) => {
|
|
7
|
+
return /* @__PURE__ */ jsx("div", { className: clsx("flex flex-row items-center w-1/2 h-4 text-disabled-text font-bold", className), children: "-" });
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// src/components/table/Filter.ts
|
|
11
|
+
var dateRange = (row, columnId, filterValue) => {
|
|
12
|
+
const [min, max] = filterValue;
|
|
13
|
+
const value = row.getValue(columnId);
|
|
14
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
15
|
+
if (isNaN(date.getTime())) return false;
|
|
16
|
+
if (min && date < min) return false;
|
|
17
|
+
if (max && date > max) return false;
|
|
18
|
+
return true;
|
|
19
|
+
};
|
|
20
|
+
var TableFilters = {
|
|
21
|
+
dateRange
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// src/components/table/Table.tsx
|
|
25
|
+
import { useCallback as useCallback6, useEffect as useEffect15, useMemo as useMemo4, useRef as useRef8, useState as useState14 } from "react";
|
|
26
|
+
import clsx9 from "clsx";
|
|
27
|
+
import {
|
|
28
|
+
flexRender,
|
|
29
|
+
getCoreRowModel,
|
|
30
|
+
getFilteredRowModel,
|
|
31
|
+
getPaginationRowModel,
|
|
32
|
+
getSortedRowModel,
|
|
33
|
+
useReactTable
|
|
34
|
+
} from "@tanstack/react-table";
|
|
35
|
+
|
|
36
|
+
// src/utils/array.ts
|
|
37
|
+
var defaultRangeOptions = {
|
|
38
|
+
allowEmptyRange: false,
|
|
39
|
+
stepSize: 1,
|
|
40
|
+
exclusiveStart: false,
|
|
41
|
+
exclusiveEnd: true
|
|
42
|
+
};
|
|
43
|
+
var range = (endOrRange, options) => {
|
|
44
|
+
const { allowEmptyRange, stepSize, exclusiveStart, exclusiveEnd } = { ...defaultRangeOptions, ...options };
|
|
45
|
+
let start = 0;
|
|
46
|
+
let end;
|
|
47
|
+
if (typeof endOrRange === "number") {
|
|
48
|
+
end = endOrRange;
|
|
49
|
+
} else {
|
|
50
|
+
start = endOrRange[0];
|
|
51
|
+
end = endOrRange[1];
|
|
52
|
+
}
|
|
53
|
+
if (!exclusiveEnd) {
|
|
54
|
+
end -= 1;
|
|
55
|
+
}
|
|
56
|
+
if (exclusiveStart) {
|
|
57
|
+
start += 1;
|
|
58
|
+
}
|
|
59
|
+
if (end - 1 < start) {
|
|
60
|
+
if (!allowEmptyRange) {
|
|
61
|
+
console.warn(`range: end (${end}) < start (${start}) should be allowed explicitly, set options.allowEmptyRange to true`);
|
|
62
|
+
}
|
|
63
|
+
return [];
|
|
64
|
+
}
|
|
65
|
+
return Array.from({ length: end - start }, (_, index) => index * stepSize + start);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// src/components/table/Table.tsx
|
|
69
|
+
import { Scrollbars } from "react-custom-scrollbars-2";
|
|
70
|
+
|
|
71
|
+
// src/utils/math.ts
|
|
72
|
+
var clamp = (value, range2 = [0, 1]) => {
|
|
73
|
+
const [min, max] = range2;
|
|
74
|
+
return Math.min(Math.max(value, min), max);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// src/utils/noop.ts
|
|
78
|
+
var noop = () => void 0;
|
|
79
|
+
|
|
80
|
+
// src/components/table/TableCell.tsx
|
|
81
|
+
import { clsx as clsx2 } from "clsx";
|
|
82
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
83
|
+
var TableCell = ({
|
|
84
|
+
children,
|
|
85
|
+
className
|
|
86
|
+
}) => {
|
|
87
|
+
return /* @__PURE__ */ jsx2("span", { className: clsx2("block max-w-full overflow-ellipsis truncate", className), children });
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
// src/hooks/useResizeCallbackWrapper.ts
|
|
91
|
+
import { useEffect } from "react";
|
|
92
|
+
var useResizeCallbackWrapper = (callback) => {
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
window.addEventListener("resize", callback);
|
|
95
|
+
return () => {
|
|
96
|
+
window.removeEventListener("resize", callback);
|
|
97
|
+
};
|
|
98
|
+
}, [callback]);
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
// src/components/table/TableSortButton.tsx
|
|
102
|
+
import { ChevronDown, ChevronsUpDown, ChevronUp } from "lucide-react";
|
|
103
|
+
|
|
104
|
+
// src/components/user-action/Button.tsx
|
|
105
|
+
import { forwardRef } from "react";
|
|
106
|
+
import clsx3 from "clsx";
|
|
107
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
108
|
+
var ButtonColorUtil = {
|
|
109
|
+
solid: ["primary", "secondary", "tertiary", "positive", "warning", "negative", "neutral"],
|
|
110
|
+
text: ["primary", "negative", "neutral"],
|
|
111
|
+
outline: ["primary"]
|
|
112
|
+
};
|
|
113
|
+
var IconButtonUtil = {
|
|
114
|
+
icon: [...ButtonColorUtil.solid, "transparent"]
|
|
115
|
+
};
|
|
116
|
+
var paddingMapping = {
|
|
117
|
+
small: "btn-sm",
|
|
118
|
+
medium: "btn-md",
|
|
119
|
+
large: "btn-lg"
|
|
120
|
+
};
|
|
121
|
+
var iconPaddingMapping = {
|
|
122
|
+
tiny: "icon-btn-xs",
|
|
123
|
+
small: "icon-btn-sm",
|
|
124
|
+
medium: "icon-btn-md",
|
|
125
|
+
large: "icon-btn-lg"
|
|
126
|
+
};
|
|
127
|
+
var ButtonUtil = {
|
|
128
|
+
paddingMapping,
|
|
129
|
+
iconPaddingMapping
|
|
130
|
+
};
|
|
131
|
+
var SolidButton = forwardRef(function SolidButton2({
|
|
132
|
+
children,
|
|
133
|
+
color = "primary",
|
|
134
|
+
size = "medium",
|
|
135
|
+
startIcon,
|
|
136
|
+
endIcon,
|
|
137
|
+
onClick,
|
|
138
|
+
className,
|
|
139
|
+
...restProps
|
|
140
|
+
}, ref) {
|
|
141
|
+
const colorClasses = {
|
|
142
|
+
primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
|
|
143
|
+
secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
|
|
144
|
+
tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
|
|
145
|
+
positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
|
|
146
|
+
warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
|
|
147
|
+
negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
|
|
148
|
+
neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text"
|
|
149
|
+
}[color];
|
|
150
|
+
const iconColorClasses = {
|
|
151
|
+
primary: "not-group-disabled:text-button-solid-primary-icon",
|
|
152
|
+
secondary: "not-group-disabled:text-button-solid-secondary-icon",
|
|
153
|
+
tertiary: "not-group-disabled:text-button-solid-tertiary-icon",
|
|
154
|
+
positive: "not-group-disabled:text-button-solid-positive-icon",
|
|
155
|
+
warning: "not-group-disabled:text-button-solid-warning-icon",
|
|
156
|
+
negative: "not-group-disabled:text-button-solid-negative-icon",
|
|
157
|
+
neutral: "not-group-disabled:text-button-solid-neutral-icon"
|
|
158
|
+
}[color];
|
|
159
|
+
return /* @__PURE__ */ jsxs(
|
|
160
|
+
"button",
|
|
161
|
+
{
|
|
162
|
+
ref,
|
|
163
|
+
onClick,
|
|
164
|
+
className: clsx3(
|
|
165
|
+
"group font-semibold",
|
|
166
|
+
colorClasses,
|
|
167
|
+
"not-disabled:hover:brightness-90",
|
|
168
|
+
"disabled:text-disabled-text disabled:bg-disabled-background",
|
|
169
|
+
ButtonUtil.paddingMapping[size],
|
|
170
|
+
className
|
|
171
|
+
),
|
|
172
|
+
...restProps,
|
|
173
|
+
children: [
|
|
174
|
+
startIcon && /* @__PURE__ */ jsx3(
|
|
175
|
+
"span",
|
|
176
|
+
{
|
|
177
|
+
className: clsx3(
|
|
178
|
+
iconColorClasses,
|
|
179
|
+
"group-disabled:text-disabled-icon"
|
|
180
|
+
),
|
|
181
|
+
children: startIcon
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
children,
|
|
185
|
+
endIcon && /* @__PURE__ */ jsx3(
|
|
186
|
+
"span",
|
|
187
|
+
{
|
|
188
|
+
className: clsx3(
|
|
189
|
+
iconColorClasses,
|
|
190
|
+
"group-disabled:text-disabled-icon"
|
|
191
|
+
),
|
|
192
|
+
children: endIcon
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
});
|
|
199
|
+
var IconButton = forwardRef(function IconButton2({
|
|
200
|
+
children,
|
|
201
|
+
color = "primary",
|
|
202
|
+
size = "medium",
|
|
203
|
+
className,
|
|
204
|
+
...restProps
|
|
205
|
+
}, ref) {
|
|
206
|
+
const colorClasses = {
|
|
207
|
+
primary: "not-disabled:bg-button-solid-primary-background not-disabled:text-button-solid-primary-text",
|
|
208
|
+
secondary: "not-disabled:bg-button-solid-secondary-background not-disabled:text-button-solid-secondary-text",
|
|
209
|
+
tertiary: "not-disabled:bg-button-solid-tertiary-background not-disabled:text-button-solid-tertiary-text",
|
|
210
|
+
positive: "not-disabled:bg-button-solid-positive-background not-disabled:text-button-solid-positive-text",
|
|
211
|
+
warning: "not-disabled:bg-button-solid-warning-background not-disabled:text-button-solid-warning-text",
|
|
212
|
+
negative: "not-disabled:bg-button-solid-negative-background not-disabled:text-button-solid-negative-text",
|
|
213
|
+
neutral: "not-disabled:bg-button-solid-neutral-background not-disabled:text-button-solid-neutral-text",
|
|
214
|
+
transparent: "not-disabled:bg-transparent"
|
|
215
|
+
}[color];
|
|
216
|
+
return /* @__PURE__ */ jsx3(
|
|
217
|
+
"button",
|
|
218
|
+
{
|
|
219
|
+
ref,
|
|
220
|
+
className: clsx3(
|
|
221
|
+
colorClasses,
|
|
222
|
+
"not-disabled:hover:brightness-90",
|
|
223
|
+
"disabled:text-disabled-text",
|
|
224
|
+
{
|
|
225
|
+
"disabled:bg-disabled-background": color !== "transparent",
|
|
226
|
+
"disabled:opacity-70": color === "transparent",
|
|
227
|
+
"not-disabled:hover:bg-button-text-hover-background": color === "transparent"
|
|
228
|
+
},
|
|
229
|
+
ButtonUtil.iconPaddingMapping[size],
|
|
230
|
+
className
|
|
231
|
+
),
|
|
232
|
+
...restProps,
|
|
233
|
+
children
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
// src/components/table/TableSortButton.tsx
|
|
239
|
+
import clsx4 from "clsx";
|
|
240
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
241
|
+
var TableSortButton = ({
|
|
242
|
+
sortDirection,
|
|
243
|
+
invert = false,
|
|
244
|
+
color = "neutral",
|
|
245
|
+
className,
|
|
246
|
+
...buttonProps
|
|
247
|
+
}) => {
|
|
248
|
+
let icon = /* @__PURE__ */ jsx4(ChevronsUpDown, { className: "w-full h-full" });
|
|
249
|
+
if (sortDirection) {
|
|
250
|
+
let usedSortDirection = sortDirection;
|
|
251
|
+
if (invert) {
|
|
252
|
+
usedSortDirection = usedSortDirection === "desc" ? "asc" : "desc";
|
|
253
|
+
}
|
|
254
|
+
icon = usedSortDirection === "asc" ? /* @__PURE__ */ jsx4(ChevronUp, { className: "w-full h-full" }) : /* @__PURE__ */ jsx4(ChevronDown, { className: "w-full h-full" });
|
|
255
|
+
}
|
|
256
|
+
return /* @__PURE__ */ jsx4(
|
|
257
|
+
IconButton,
|
|
258
|
+
{
|
|
259
|
+
size: "tiny",
|
|
260
|
+
color,
|
|
261
|
+
className: clsx4(className),
|
|
262
|
+
...buttonProps,
|
|
263
|
+
children: icon
|
|
264
|
+
}
|
|
265
|
+
);
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
// src/components/user-action/input/Input.tsx
|
|
269
|
+
import { forwardRef as forwardRef2, useEffect as useEffect3, useImperativeHandle, useRef, useState as useState2 } from "react";
|
|
270
|
+
import clsx5 from "clsx";
|
|
271
|
+
|
|
272
|
+
// src/hooks/useDelay.ts
|
|
273
|
+
import { useEffect as useEffect2, useState } from "react";
|
|
274
|
+
var defaultOptions = {
|
|
275
|
+
delay: 3e3,
|
|
276
|
+
disabled: false
|
|
277
|
+
};
|
|
278
|
+
function useDelay(options) {
|
|
279
|
+
const [timer, setTimer] = useState(void 0);
|
|
280
|
+
const { delay, disabled } = {
|
|
281
|
+
...defaultOptions,
|
|
282
|
+
...options
|
|
283
|
+
};
|
|
284
|
+
const clearTimer = () => {
|
|
285
|
+
clearTimeout(timer);
|
|
286
|
+
setTimer(void 0);
|
|
287
|
+
};
|
|
288
|
+
const restartTimer = (onDelayFinish) => {
|
|
289
|
+
if (disabled) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
clearTimeout(timer);
|
|
293
|
+
setTimer(setTimeout(() => {
|
|
294
|
+
onDelayFinish();
|
|
295
|
+
setTimer(void 0);
|
|
296
|
+
}, delay));
|
|
297
|
+
};
|
|
298
|
+
useEffect2(() => {
|
|
299
|
+
return () => {
|
|
300
|
+
clearTimeout(timer);
|
|
301
|
+
};
|
|
302
|
+
}, [timer]);
|
|
303
|
+
useEffect2(() => {
|
|
304
|
+
if (disabled) {
|
|
305
|
+
clearTimeout(timer);
|
|
306
|
+
setTimer(void 0);
|
|
307
|
+
}
|
|
308
|
+
}, [disabled, timer]);
|
|
309
|
+
return { restartTimer, clearTimer, hasActiveTimer: !!timer };
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// src/hooks/focus/useFocusManagement.ts
|
|
313
|
+
import { useCallback } from "react";
|
|
314
|
+
function useFocusManagement() {
|
|
315
|
+
const getFocusableElements = useCallback(() => {
|
|
316
|
+
return Array.from(
|
|
317
|
+
document.querySelectorAll(
|
|
318
|
+
'input, button, select, textarea, a[href], [tabindex]:not([tabindex="-1"])'
|
|
319
|
+
)
|
|
320
|
+
).filter(
|
|
321
|
+
(el) => el instanceof HTMLElement && !el.hasAttribute("disabled") && !el.hasAttribute("hidden") && el.tabIndex !== -1
|
|
322
|
+
);
|
|
323
|
+
}, []);
|
|
324
|
+
const getNextFocusElement = useCallback(() => {
|
|
325
|
+
const elements = getFocusableElements();
|
|
326
|
+
if (elements.length === 0) {
|
|
327
|
+
return void 0;
|
|
328
|
+
}
|
|
329
|
+
let nextElement = elements[0];
|
|
330
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
331
|
+
const currentIndex = elements.indexOf(document.activeElement);
|
|
332
|
+
nextElement = elements[(currentIndex + 1) % elements.length];
|
|
333
|
+
}
|
|
334
|
+
return nextElement;
|
|
335
|
+
}, [getFocusableElements]);
|
|
336
|
+
const focusNext = useCallback(() => {
|
|
337
|
+
const nextElement = getNextFocusElement();
|
|
338
|
+
nextElement?.focus();
|
|
339
|
+
}, [getNextFocusElement]);
|
|
340
|
+
const getPreviousFocusElement = useCallback(() => {
|
|
341
|
+
const elements = getFocusableElements();
|
|
342
|
+
if (elements.length === 0) {
|
|
343
|
+
return void 0;
|
|
344
|
+
}
|
|
345
|
+
let previousElement = elements[0];
|
|
346
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
347
|
+
const currentIndex = elements.indexOf(document.activeElement);
|
|
348
|
+
if (currentIndex === 0) {
|
|
349
|
+
previousElement = elements[elements.length - 1];
|
|
350
|
+
} else {
|
|
351
|
+
previousElement = elements[currentIndex - 1];
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return previousElement;
|
|
355
|
+
}, [getFocusableElements]);
|
|
356
|
+
const focusPrevious = useCallback(() => {
|
|
357
|
+
const previousElement = getPreviousFocusElement();
|
|
358
|
+
if (previousElement) previousElement.focus();
|
|
359
|
+
}, [getPreviousFocusElement]);
|
|
360
|
+
return {
|
|
361
|
+
getFocusableElements,
|
|
362
|
+
getNextFocusElement,
|
|
363
|
+
getPreviousFocusElement,
|
|
364
|
+
focusNext,
|
|
365
|
+
focusPrevious
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// src/components/user-action/input/Input.tsx
|
|
370
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
371
|
+
var defaultEditCompleteOptions = {
|
|
372
|
+
allowEnterComplete: false,
|
|
373
|
+
onBlur: true,
|
|
374
|
+
afterDelay: true,
|
|
375
|
+
delay: 2500
|
|
376
|
+
};
|
|
377
|
+
var Input = forwardRef2(function Input2({
|
|
378
|
+
value,
|
|
379
|
+
onChange,
|
|
380
|
+
onChangeText,
|
|
381
|
+
onEditCompleted,
|
|
382
|
+
editCompleteOptions,
|
|
383
|
+
disabled = false,
|
|
384
|
+
invalid = false,
|
|
385
|
+
defaultStyle = true,
|
|
386
|
+
className,
|
|
387
|
+
...props
|
|
388
|
+
}, forwardedRef) {
|
|
389
|
+
const {
|
|
390
|
+
onBlur: allowEditCompleteOnBlur,
|
|
391
|
+
afterDelay,
|
|
392
|
+
delay,
|
|
393
|
+
allowEnterComplete
|
|
394
|
+
} = { ...defaultEditCompleteOptions, ...editCompleteOptions };
|
|
395
|
+
const {
|
|
396
|
+
restartTimer,
|
|
397
|
+
clearTimer
|
|
398
|
+
} = useDelay({ delay, disabled: !afterDelay });
|
|
399
|
+
const innerRef = useRef(null);
|
|
400
|
+
useImperativeHandle(forwardedRef, () => innerRef.current);
|
|
401
|
+
const { focusNext } = useFocusManagement();
|
|
402
|
+
return /* @__PURE__ */ jsx5(
|
|
403
|
+
"input",
|
|
404
|
+
{
|
|
405
|
+
...props,
|
|
406
|
+
ref: innerRef,
|
|
407
|
+
value,
|
|
408
|
+
disabled,
|
|
409
|
+
className: defaultStyle ? clsx5(
|
|
410
|
+
"px-2.5 py-1.75 rounded-md border-1 text-sm",
|
|
411
|
+
{
|
|
412
|
+
"bg-input-background text-input-text hover:border-primary focus:border-primary": !disabled && !invalid,
|
|
413
|
+
"bg-on-negative text-negative border-negative-border hover:border-negative-border-hover focus-visible:ring-negative-border": !disabled && invalid,
|
|
414
|
+
"bg-disabled-background text-disabled-text border-disabled-border": disabled
|
|
415
|
+
},
|
|
416
|
+
className
|
|
417
|
+
) : className,
|
|
418
|
+
onKeyDown: (event) => {
|
|
419
|
+
props.onKeyDown?.(event);
|
|
420
|
+
if (!allowEnterComplete) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
424
|
+
event.preventDefault();
|
|
425
|
+
innerRef.current?.blur();
|
|
426
|
+
onEditCompleted?.(event.target.value);
|
|
427
|
+
focusNext();
|
|
428
|
+
}
|
|
429
|
+
},
|
|
430
|
+
onBlur: (event) => {
|
|
431
|
+
props.onBlur?.(event);
|
|
432
|
+
if (allowEditCompleteOnBlur) {
|
|
433
|
+
onEditCompleted?.(event.target.value);
|
|
434
|
+
clearTimer();
|
|
435
|
+
}
|
|
436
|
+
},
|
|
437
|
+
onChange: (event) => {
|
|
438
|
+
onChange?.(event);
|
|
439
|
+
const value2 = event.target.value;
|
|
440
|
+
restartTimer(() => {
|
|
441
|
+
innerRef.current?.blur();
|
|
442
|
+
onEditCompleted?.(value2);
|
|
443
|
+
});
|
|
444
|
+
onChangeText?.(value2);
|
|
445
|
+
},
|
|
446
|
+
"aria-invalid": props["aria-invalid"] ?? invalid,
|
|
447
|
+
"aria-disabled": props["aria-disabled"] ?? disabled
|
|
448
|
+
}
|
|
449
|
+
);
|
|
450
|
+
});
|
|
451
|
+
|
|
452
|
+
// src/components/table/TableFilterButton.tsx
|
|
453
|
+
import { FilterIcon } from "lucide-react";
|
|
454
|
+
|
|
455
|
+
// src/components/user-action/Menu.tsx
|
|
456
|
+
import { useEffect as useEffect6, useRef as useRef2, useState as useState4 } from "react";
|
|
457
|
+
import clsx6 from "clsx";
|
|
458
|
+
|
|
459
|
+
// src/hooks/useOutsideClick.ts
|
|
460
|
+
import { useEffect as useEffect4 } from "react";
|
|
461
|
+
var useOutsideClick = (refs, handler) => {
|
|
462
|
+
useEffect4(() => {
|
|
463
|
+
const listener = (event) => {
|
|
464
|
+
if (event.target === null) return;
|
|
465
|
+
if (refs.some((ref) => !ref.current || ref.current.contains(event.target))) {
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
handler();
|
|
469
|
+
};
|
|
470
|
+
document.addEventListener("mousedown", listener);
|
|
471
|
+
document.addEventListener("touchstart", listener);
|
|
472
|
+
return () => {
|
|
473
|
+
document.removeEventListener("mousedown", listener);
|
|
474
|
+
document.removeEventListener("touchstart", listener);
|
|
475
|
+
};
|
|
476
|
+
}, [refs, handler]);
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
// src/hooks/useHoverState.ts
|
|
480
|
+
import { useEffect as useEffect5, useState as useState3 } from "react";
|
|
481
|
+
var defaultUseHoverStateProps = {
|
|
482
|
+
closingDelay: 200,
|
|
483
|
+
isDisabled: false
|
|
484
|
+
};
|
|
485
|
+
var useHoverState = (props = void 0) => {
|
|
486
|
+
const { closingDelay, isDisabled } = { ...defaultUseHoverStateProps, ...props };
|
|
487
|
+
const [isHovered, setIsHovered] = useState3(false);
|
|
488
|
+
const [timer, setTimer] = useState3();
|
|
489
|
+
const onMouseEnter = () => {
|
|
490
|
+
if (isDisabled) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
clearTimeout(timer);
|
|
494
|
+
setIsHovered(true);
|
|
495
|
+
};
|
|
496
|
+
const onMouseLeave = () => {
|
|
497
|
+
if (isDisabled) {
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
setTimer(setTimeout(() => {
|
|
501
|
+
setIsHovered(false);
|
|
502
|
+
}, closingDelay));
|
|
503
|
+
};
|
|
504
|
+
useEffect5(() => {
|
|
505
|
+
if (timer) {
|
|
506
|
+
return () => {
|
|
507
|
+
clearTimeout(timer);
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
});
|
|
511
|
+
useEffect5(() => {
|
|
512
|
+
if (timer) {
|
|
513
|
+
clearTimeout(timer);
|
|
514
|
+
}
|
|
515
|
+
}, [isDisabled]);
|
|
516
|
+
return {
|
|
517
|
+
isHovered,
|
|
518
|
+
setIsHovered,
|
|
519
|
+
handlers: { onMouseEnter, onMouseLeave }
|
|
520
|
+
};
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
// src/utils/bagFunctions.ts
|
|
524
|
+
var resolve = (children, bag) => {
|
|
525
|
+
if (typeof children === "function") {
|
|
526
|
+
return children(bag);
|
|
527
|
+
}
|
|
528
|
+
return children ?? void 0;
|
|
529
|
+
};
|
|
530
|
+
var BagFunctionUtil = {
|
|
531
|
+
resolve
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
// src/hooks/usePopoverPosition.ts
|
|
535
|
+
var defaultPopoverPositionOptions = {
|
|
536
|
+
edgePadding: 16,
|
|
537
|
+
outerGap: 4,
|
|
538
|
+
horizontalAlignment: "leftInside",
|
|
539
|
+
verticalAlignment: "bottomOutside",
|
|
540
|
+
disabled: false
|
|
541
|
+
};
|
|
542
|
+
var usePopoverPosition = (trigger, options) => {
|
|
543
|
+
const {
|
|
544
|
+
edgePadding,
|
|
545
|
+
outerGap,
|
|
546
|
+
verticalAlignment,
|
|
547
|
+
horizontalAlignment,
|
|
548
|
+
disabled
|
|
549
|
+
} = { ...defaultPopoverPositionOptions, ...options };
|
|
550
|
+
if (disabled || !trigger) {
|
|
551
|
+
return {};
|
|
552
|
+
}
|
|
553
|
+
const left = {
|
|
554
|
+
leftOutside: trigger.left - outerGap,
|
|
555
|
+
leftInside: trigger.left,
|
|
556
|
+
rightOutside: trigger.right + outerGap,
|
|
557
|
+
rightInside: trigger.right,
|
|
558
|
+
center: trigger.left + trigger.width / 2
|
|
559
|
+
}[horizontalAlignment];
|
|
560
|
+
const top = {
|
|
561
|
+
topOutside: trigger.top - outerGap,
|
|
562
|
+
topInside: trigger.top,
|
|
563
|
+
bottomOutside: trigger.bottom + outerGap,
|
|
564
|
+
bottomInside: trigger.bottom,
|
|
565
|
+
center: trigger.top + trigger.height / 2
|
|
566
|
+
}[verticalAlignment];
|
|
567
|
+
const translateX = {
|
|
568
|
+
leftOutside: "-100%",
|
|
569
|
+
leftInside: void 0,
|
|
570
|
+
rightOutside: void 0,
|
|
571
|
+
rightInside: "-100%",
|
|
572
|
+
center: "-50%"
|
|
573
|
+
}[horizontalAlignment];
|
|
574
|
+
const translateY = {
|
|
575
|
+
topOutside: "-100%",
|
|
576
|
+
topInside: void 0,
|
|
577
|
+
bottomOutside: void 0,
|
|
578
|
+
bottomInside: "-100%",
|
|
579
|
+
center: "-50%"
|
|
580
|
+
}[verticalAlignment];
|
|
581
|
+
return {
|
|
582
|
+
left: Math.max(left, edgePadding),
|
|
583
|
+
top: Math.max(top, edgePadding),
|
|
584
|
+
translate: [translateX ?? "0", translateY ?? "0"].join(" ")
|
|
585
|
+
};
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
// src/components/user-action/Menu.tsx
|
|
589
|
+
import { createPortal } from "react-dom";
|
|
590
|
+
import { Fragment, jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
591
|
+
function getScrollableParents(element) {
|
|
592
|
+
const scrollables = [];
|
|
593
|
+
let parent = element.parentElement;
|
|
594
|
+
while (parent) {
|
|
595
|
+
scrollables.push(parent);
|
|
596
|
+
parent = parent.parentElement;
|
|
597
|
+
}
|
|
598
|
+
return scrollables;
|
|
599
|
+
}
|
|
600
|
+
var Menu = ({
|
|
601
|
+
trigger,
|
|
602
|
+
children,
|
|
603
|
+
alignmentHorizontal = "leftInside",
|
|
604
|
+
alignmentVertical = "bottomOutside",
|
|
605
|
+
showOnHover = false,
|
|
606
|
+
disabled = false,
|
|
607
|
+
menuClassName = ""
|
|
608
|
+
}) => {
|
|
609
|
+
const { isHovered: isOpen, setIsHovered: setIsOpen } = useHoverState({ isDisabled: !showOnHover || disabled });
|
|
610
|
+
const triggerRef = useRef2(null);
|
|
611
|
+
const menuRef = useRef2(null);
|
|
612
|
+
useOutsideClick([triggerRef, menuRef], () => setIsOpen(false));
|
|
613
|
+
const [isHidden, setIsHidden] = useState4(true);
|
|
614
|
+
const bag = {
|
|
615
|
+
isOpen,
|
|
616
|
+
close: () => setIsOpen(false),
|
|
617
|
+
toggleOpen: () => setIsOpen((prevState) => !prevState),
|
|
618
|
+
disabled
|
|
619
|
+
};
|
|
620
|
+
const menuPosition = usePopoverPosition(
|
|
621
|
+
triggerRef.current?.getBoundingClientRect(),
|
|
622
|
+
{ verticalAlignment: alignmentVertical, horizontalAlignment: alignmentHorizontal, disabled }
|
|
623
|
+
);
|
|
624
|
+
useEffect6(() => {
|
|
625
|
+
if (!isOpen) return;
|
|
626
|
+
const triggerEl = triggerRef.current;
|
|
627
|
+
if (!triggerEl) return;
|
|
628
|
+
const scrollableParents = getScrollableParents(triggerEl);
|
|
629
|
+
const close = () => setIsOpen(false);
|
|
630
|
+
scrollableParents.forEach((parent) => {
|
|
631
|
+
parent.addEventListener("scroll", close);
|
|
632
|
+
});
|
|
633
|
+
window.addEventListener("resize", close);
|
|
634
|
+
return () => {
|
|
635
|
+
scrollableParents.forEach((parent) => {
|
|
636
|
+
parent.removeEventListener("scroll", close);
|
|
637
|
+
});
|
|
638
|
+
window.removeEventListener("resize", close);
|
|
639
|
+
};
|
|
640
|
+
}, [isOpen, setIsOpen]);
|
|
641
|
+
useEffect6(() => {
|
|
642
|
+
if (isOpen) {
|
|
643
|
+
setIsHidden(false);
|
|
644
|
+
}
|
|
645
|
+
}, [isOpen]);
|
|
646
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
647
|
+
trigger(bag, triggerRef),
|
|
648
|
+
createPortal(/* @__PURE__ */ jsx6(
|
|
649
|
+
"div",
|
|
650
|
+
{
|
|
651
|
+
ref: menuRef,
|
|
652
|
+
onClick: (e) => e.stopPropagation(),
|
|
653
|
+
className: clsx6(
|
|
654
|
+
"absolute rounded-md bg-menu-background text-menu-text shadow-around-lg shadow-strong z-[300]",
|
|
655
|
+
{
|
|
656
|
+
"animate-pop-in": isOpen,
|
|
657
|
+
"animate-pop-out": !isOpen,
|
|
658
|
+
"hidden": isHidden
|
|
659
|
+
},
|
|
660
|
+
menuClassName
|
|
661
|
+
),
|
|
662
|
+
onAnimationEnd: () => {
|
|
663
|
+
if (!isOpen) {
|
|
664
|
+
setIsHidden(true);
|
|
665
|
+
}
|
|
666
|
+
},
|
|
667
|
+
style: {
|
|
668
|
+
...menuPosition
|
|
669
|
+
},
|
|
670
|
+
children: BagFunctionUtil.resolve(children, bag)
|
|
671
|
+
}
|
|
672
|
+
), document.body)
|
|
673
|
+
] });
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
// src/localization/LanguageProvider.tsx
|
|
677
|
+
import { createContext, useContext, useEffect as useEffect7, useState as useState6 } from "react";
|
|
678
|
+
|
|
679
|
+
// src/hooks/useLocalStorage.ts
|
|
680
|
+
import { useCallback as useCallback2, useState as useState5 } from "react";
|
|
681
|
+
|
|
682
|
+
// src/localization/util.ts
|
|
683
|
+
var languages = ["en", "de"];
|
|
684
|
+
var languagesLocalNames = {
|
|
685
|
+
en: "English",
|
|
686
|
+
de: "Deutsch"
|
|
687
|
+
};
|
|
688
|
+
var DEFAULT_LANGUAGE = "en";
|
|
689
|
+
var LanguageUtil = {
|
|
690
|
+
languages,
|
|
691
|
+
DEFAULT_LANGUAGE,
|
|
692
|
+
languagesLocalNames
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
// src/localization/LanguageProvider.tsx
|
|
696
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
697
|
+
var LanguageContext = createContext({
|
|
698
|
+
language: LanguageUtil.DEFAULT_LANGUAGE,
|
|
699
|
+
setLanguage: (v) => v
|
|
700
|
+
});
|
|
701
|
+
var useLanguage = () => useContext(LanguageContext);
|
|
702
|
+
|
|
703
|
+
// src/localization/useTranslation.ts
|
|
704
|
+
var TranslationPluralCount = {
|
|
705
|
+
zero: 0,
|
|
706
|
+
one: 1,
|
|
707
|
+
two: 2,
|
|
708
|
+
few: 3,
|
|
709
|
+
many: 11,
|
|
710
|
+
other: -1
|
|
711
|
+
};
|
|
712
|
+
var useTranslation = (translations, overwriteTranslation = {}) => {
|
|
713
|
+
const { language: languageProp, translation: overwrite } = overwriteTranslation;
|
|
714
|
+
const { language: inferredLanguage } = useLanguage();
|
|
715
|
+
const usedLanguage = languageProp ?? inferredLanguage;
|
|
716
|
+
const usedTranslations = [...translations];
|
|
717
|
+
if (overwrite) {
|
|
718
|
+
usedTranslations.push(overwrite);
|
|
719
|
+
}
|
|
720
|
+
return (key, options) => {
|
|
721
|
+
const { count, replacements } = { ...{ count: 0, replacements: {} }, ...options };
|
|
722
|
+
try {
|
|
723
|
+
for (let i = translations.length - 1; i >= 0; i--) {
|
|
724
|
+
const translation = translations[i];
|
|
725
|
+
const localizedTranslation = translation[usedLanguage];
|
|
726
|
+
if (!localizedTranslation) {
|
|
727
|
+
continue;
|
|
728
|
+
}
|
|
729
|
+
const value = localizedTranslation[key];
|
|
730
|
+
if (!value) {
|
|
731
|
+
continue;
|
|
732
|
+
}
|
|
733
|
+
let forProcessing;
|
|
734
|
+
if (typeof value !== "string") {
|
|
735
|
+
if (count === TranslationPluralCount.zero && value?.zero) {
|
|
736
|
+
forProcessing = value.zero;
|
|
737
|
+
} else if (count === TranslationPluralCount.one && value?.one) {
|
|
738
|
+
forProcessing = value.one;
|
|
739
|
+
} else if (count === TranslationPluralCount.two && value?.two) {
|
|
740
|
+
forProcessing = value.two;
|
|
741
|
+
} else if (TranslationPluralCount.few <= count && count < TranslationPluralCount.many && value?.few) {
|
|
742
|
+
forProcessing = value.few;
|
|
743
|
+
} else if (count > TranslationPluralCount.many && value?.many) {
|
|
744
|
+
forProcessing = value.many;
|
|
745
|
+
} else {
|
|
746
|
+
forProcessing = value.other;
|
|
747
|
+
}
|
|
748
|
+
} else {
|
|
749
|
+
forProcessing = value;
|
|
750
|
+
}
|
|
751
|
+
forProcessing = forProcessing.replace(/\{\{(\w+)}}/g, (_, placeholder) => {
|
|
752
|
+
return replacements[placeholder] ?? `{{key:${placeholder}}}`;
|
|
753
|
+
});
|
|
754
|
+
return forProcessing;
|
|
755
|
+
}
|
|
756
|
+
} catch (e) {
|
|
757
|
+
console.error(e);
|
|
758
|
+
}
|
|
759
|
+
return `{{${usedLanguage}:${key}}}`;
|
|
760
|
+
};
|
|
761
|
+
};
|
|
762
|
+
|
|
763
|
+
// src/localization/defaults/form.ts
|
|
764
|
+
var formTranslation = {
|
|
765
|
+
en: {
|
|
766
|
+
add: "Add",
|
|
767
|
+
all: "All",
|
|
768
|
+
apply: "Apply",
|
|
769
|
+
back: "Back",
|
|
770
|
+
cancel: "Cancel",
|
|
771
|
+
change: "Change",
|
|
772
|
+
clear: "Clear",
|
|
773
|
+
click: "Click",
|
|
774
|
+
clickToCopy: "Click to Copy",
|
|
775
|
+
close: "Close",
|
|
776
|
+
confirm: "Confirm",
|
|
777
|
+
copy: "Copy",
|
|
778
|
+
copied: "Copied",
|
|
779
|
+
create: "Create",
|
|
780
|
+
decline: "Decline",
|
|
781
|
+
delete: "Delete",
|
|
782
|
+
discard: "Discard",
|
|
783
|
+
discardChanges: "Discard Changes",
|
|
784
|
+
done: "Done",
|
|
785
|
+
edit: "Edit",
|
|
786
|
+
enterText: "Enter text here",
|
|
787
|
+
error: "Error",
|
|
788
|
+
exit: "Exit",
|
|
789
|
+
fieldRequiredError: "This field is required.",
|
|
790
|
+
invalidEmailError: "Please enter a valid email address.",
|
|
791
|
+
less: "Less",
|
|
792
|
+
loading: "Loading",
|
|
793
|
+
maxLengthError: "Maximum length exceeded.",
|
|
794
|
+
minLengthError: "Minimum length not met.",
|
|
795
|
+
more: "More",
|
|
796
|
+
next: "Next",
|
|
797
|
+
no: "No",
|
|
798
|
+
none: "None",
|
|
799
|
+
nothingFound: "Nothing found",
|
|
800
|
+
of: "of",
|
|
801
|
+
optional: "Optional",
|
|
802
|
+
pleaseWait: "Please wait...",
|
|
803
|
+
previous: "Previous",
|
|
804
|
+
remove: "Remove",
|
|
805
|
+
required: "Required",
|
|
806
|
+
reset: "Reset",
|
|
807
|
+
save: "Save",
|
|
808
|
+
saved: "Saved",
|
|
809
|
+
search: "Search",
|
|
810
|
+
select: "Select",
|
|
811
|
+
selectOption: "Select an option",
|
|
812
|
+
show: "Show",
|
|
813
|
+
showMore: "Show more",
|
|
814
|
+
showLess: "Show less",
|
|
815
|
+
submit: "Submit",
|
|
816
|
+
success: "Success",
|
|
817
|
+
update: "Update",
|
|
818
|
+
unsavedChanges: "Unsaved Changes",
|
|
819
|
+
unsavedChangesSaveQuestion: "Do you want to save your changes?",
|
|
820
|
+
yes: "Yes"
|
|
821
|
+
},
|
|
822
|
+
de: {
|
|
823
|
+
add: "Hinzuf\xFCgen",
|
|
824
|
+
all: "Alle",
|
|
825
|
+
apply: "Anwenden",
|
|
826
|
+
back: "Zur\xFCck",
|
|
827
|
+
cancel: "Abbrechen",
|
|
828
|
+
change: "\xC4ndern",
|
|
829
|
+
clear: "L\xF6schen",
|
|
830
|
+
click: "Klicken",
|
|
831
|
+
clickToCopy: "Zum kopieren klicken",
|
|
832
|
+
close: "Schlie\xDFen",
|
|
833
|
+
confirm: "Best\xE4tigen",
|
|
834
|
+
copy: "Kopieren",
|
|
835
|
+
copied: "Kopiert",
|
|
836
|
+
create: "Erstellen",
|
|
837
|
+
decline: "Ablehnen",
|
|
838
|
+
delete: "L\xF6schen",
|
|
839
|
+
discard: "Verwerfen",
|
|
840
|
+
discardChanges: "\xC4nderungen Verwerfen",
|
|
841
|
+
done: "Fertig",
|
|
842
|
+
edit: "Bearbeiten",
|
|
843
|
+
enterText: "Text hier eingeben",
|
|
844
|
+
error: "Fehler",
|
|
845
|
+
exit: "Beenden",
|
|
846
|
+
fieldRequiredError: "Dieses Feld ist erforderlich.",
|
|
847
|
+
invalidEmailError: "Bitte geben Sie eine g\xFCltige E-Mail-Adresse ein.",
|
|
848
|
+
less: "Weniger",
|
|
849
|
+
loading: "L\xE4dt",
|
|
850
|
+
maxLengthError: "Maximale L\xE4nge \xFCberschritten.",
|
|
851
|
+
minLengthError: "Mindestl\xE4nge nicht erreicht.",
|
|
852
|
+
more: "Mehr",
|
|
853
|
+
next: "Weiter",
|
|
854
|
+
no: "Nein",
|
|
855
|
+
none: "Nichts",
|
|
856
|
+
nothingFound: "Nichts gefunden",
|
|
857
|
+
of: "von",
|
|
858
|
+
optional: "Optional",
|
|
859
|
+
pleaseWait: "Bitte warten...",
|
|
860
|
+
previous: "Vorherige",
|
|
861
|
+
remove: "Entfernen",
|
|
862
|
+
required: "Erforderlich",
|
|
863
|
+
reset: "Zur\xFCcksetzen",
|
|
864
|
+
save: "Speichern",
|
|
865
|
+
saved: "Gespeichert",
|
|
866
|
+
search: "Suche",
|
|
867
|
+
select: "Select",
|
|
868
|
+
selectOption: "Option ausw\xE4hlen",
|
|
869
|
+
show: "Anzeigen",
|
|
870
|
+
showMore: "Mehr anzeigen",
|
|
871
|
+
showLess: "Weniger anzeigen",
|
|
872
|
+
submit: "Abschicken",
|
|
873
|
+
success: "Erfolg",
|
|
874
|
+
update: "Update",
|
|
875
|
+
unsavedChanges: "Ungespeicherte \xC4nderungen",
|
|
876
|
+
unsavedChangesSaveQuestion: "M\xF6chtest du die \xC4nderungen speichern?",
|
|
877
|
+
yes: "Ja"
|
|
878
|
+
}
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
// src/components/table/TableFilterButton.tsx
|
|
882
|
+
import { useEffect as useEffect8, useState as useState7 } from "react";
|
|
883
|
+
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
884
|
+
var defaultTableFilterTranslation = {
|
|
885
|
+
en: {
|
|
886
|
+
filter: "Filter",
|
|
887
|
+
min: "Min",
|
|
888
|
+
max: "Max",
|
|
889
|
+
startDate: "Start",
|
|
890
|
+
endDate: "End",
|
|
891
|
+
text: "Text..."
|
|
892
|
+
},
|
|
893
|
+
de: {
|
|
894
|
+
filter: "Filter",
|
|
895
|
+
min: "Min",
|
|
896
|
+
max: "Max",
|
|
897
|
+
startDate: "Start",
|
|
898
|
+
endDate: "Ende",
|
|
899
|
+
text: "Text..."
|
|
900
|
+
}
|
|
901
|
+
};
|
|
902
|
+
var TableFilterButton = ({
|
|
903
|
+
filterType,
|
|
904
|
+
column
|
|
905
|
+
}) => {
|
|
906
|
+
const translation = useTranslation([formTranslation, defaultTableFilterTranslation]);
|
|
907
|
+
const columnFilterValue = column.getFilterValue();
|
|
908
|
+
const [filterValue, setFilterValue] = useState7(columnFilterValue);
|
|
909
|
+
const hasFilter = !!filterValue;
|
|
910
|
+
useEffect8(() => {
|
|
911
|
+
setFilterValue(columnFilterValue);
|
|
912
|
+
}, [columnFilterValue]);
|
|
913
|
+
return /* @__PURE__ */ jsx8(
|
|
914
|
+
Menu,
|
|
915
|
+
{
|
|
916
|
+
trigger: ({ toggleOpen }, ref) => /* @__PURE__ */ jsxs3("div", { ref, className: "relative", children: [
|
|
917
|
+
/* @__PURE__ */ jsx8(IconButton, { color: "neutral", size: "tiny", onClick: toggleOpen, children: /* @__PURE__ */ jsx8(FilterIcon, {}) }),
|
|
918
|
+
hasFilter && /* @__PURE__ */ jsx8(
|
|
919
|
+
"div",
|
|
920
|
+
{
|
|
921
|
+
className: "absolute top-0.5 right-0.5 w-2 h-2 rounded-full bg-primary pointer-events-none",
|
|
922
|
+
"aria-hidden": true
|
|
923
|
+
}
|
|
924
|
+
)
|
|
925
|
+
] }),
|
|
926
|
+
children: ({ close }) => /* @__PURE__ */ jsxs3("div", { className: "flex-col-1 p-2 items-start font-normal text-menu-text", children: [
|
|
927
|
+
/* @__PURE__ */ jsx8("h4", { className: "typography-label-md-semibold", children: translation("filter") }),
|
|
928
|
+
filterType === "text" && /* @__PURE__ */ jsx8(
|
|
929
|
+
Input,
|
|
930
|
+
{
|
|
931
|
+
value: filterValue ?? "",
|
|
932
|
+
autoFocus: true,
|
|
933
|
+
placeholder: translation("text"),
|
|
934
|
+
onChangeText: setFilterValue,
|
|
935
|
+
className: "h-10"
|
|
936
|
+
}
|
|
937
|
+
),
|
|
938
|
+
filterType === "range" && /* @__PURE__ */ jsxs3("div", { className: "flex-row-2 items-center", children: [
|
|
939
|
+
/* @__PURE__ */ jsx8(
|
|
940
|
+
Input,
|
|
941
|
+
{
|
|
942
|
+
value: filterValue?.[0] ?? "",
|
|
943
|
+
type: "number",
|
|
944
|
+
placeholder: translation("min"),
|
|
945
|
+
onChangeText: (text) => {
|
|
946
|
+
const num = Number(text);
|
|
947
|
+
setFilterValue((old) => [num, old?.[1]]);
|
|
948
|
+
},
|
|
949
|
+
className: "h-10 input-indicator-hidden w-40"
|
|
950
|
+
}
|
|
951
|
+
),
|
|
952
|
+
/* @__PURE__ */ jsx8("span", { className: "font-bold", children: "-" }),
|
|
953
|
+
/* @__PURE__ */ jsx8(
|
|
954
|
+
Input,
|
|
955
|
+
{
|
|
956
|
+
value: filterValue?.[1] ?? "",
|
|
957
|
+
type: "number",
|
|
958
|
+
placeholder: translation("max"),
|
|
959
|
+
onChangeText: (text) => {
|
|
960
|
+
const num = Number(text);
|
|
961
|
+
setFilterValue((old) => [old?.[0], num]);
|
|
962
|
+
},
|
|
963
|
+
className: "h-10 input-indicator-hidden w-40"
|
|
964
|
+
}
|
|
965
|
+
)
|
|
966
|
+
] }),
|
|
967
|
+
filterType === "dateRange" && /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
968
|
+
/* @__PURE__ */ jsx8(
|
|
969
|
+
Input,
|
|
970
|
+
{
|
|
971
|
+
value: filterValue?.[0] ? filterValue?.[0].toISOString().slice(0, 16) : "",
|
|
972
|
+
type: "datetime-local",
|
|
973
|
+
placeholder: translation("startDate"),
|
|
974
|
+
onChangeText: (text) => {
|
|
975
|
+
const value = new Date(text);
|
|
976
|
+
setFilterValue((old) => [value, old?.[1]]);
|
|
977
|
+
},
|
|
978
|
+
className: "h-10 w-50"
|
|
979
|
+
}
|
|
980
|
+
),
|
|
981
|
+
/* @__PURE__ */ jsx8(
|
|
982
|
+
Input,
|
|
983
|
+
{
|
|
984
|
+
value: filterValue?.[1] ? filterValue?.[1].toISOString().slice(0, 16) : "",
|
|
985
|
+
type: "datetime-local",
|
|
986
|
+
placeholder: translation("endDate"),
|
|
987
|
+
onChangeText: (text) => {
|
|
988
|
+
const value = new Date(text);
|
|
989
|
+
setFilterValue((old) => [old?.[0], value]);
|
|
990
|
+
},
|
|
991
|
+
className: "h-10 w-50"
|
|
992
|
+
}
|
|
993
|
+
)
|
|
994
|
+
] }),
|
|
995
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex-row-2 justify-end w-full", children: [
|
|
996
|
+
hasFilter && /* @__PURE__ */ jsx8(SolidButton, { color: "negative", size: "small", onClick: () => {
|
|
997
|
+
column.setFilterValue(void 0);
|
|
998
|
+
close();
|
|
999
|
+
}, children: translation("remove") }),
|
|
1000
|
+
/* @__PURE__ */ jsx8(SolidButton, { size: "small", onClick: () => {
|
|
1001
|
+
column.setFilterValue(filterValue);
|
|
1002
|
+
close();
|
|
1003
|
+
}, children: translation("apply") })
|
|
1004
|
+
] })
|
|
1005
|
+
] })
|
|
1006
|
+
}
|
|
1007
|
+
);
|
|
1008
|
+
};
|
|
1009
|
+
|
|
1010
|
+
// src/components/navigation/Pagination.tsx
|
|
1011
|
+
import { ChevronFirst, ChevronLast, ChevronLeft, ChevronRight } from "lucide-react";
|
|
1012
|
+
import clsx7 from "clsx";
|
|
1013
|
+
import { useEffect as useEffect9, useState as useState8 } from "react";
|
|
1014
|
+
import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1015
|
+
var Pagination = ({
|
|
1016
|
+
overwriteTranslation,
|
|
1017
|
+
pageIndex,
|
|
1018
|
+
pageCount,
|
|
1019
|
+
onPageChanged,
|
|
1020
|
+
className,
|
|
1021
|
+
style
|
|
1022
|
+
}) => {
|
|
1023
|
+
const translation = useTranslation([formTranslation], overwriteTranslation);
|
|
1024
|
+
const [value, setValue] = useState8((pageIndex + 1).toString());
|
|
1025
|
+
const noPages = pageCount === 0;
|
|
1026
|
+
const onFirstPage = pageIndex === 0 && !noPages;
|
|
1027
|
+
const onLastPage = pageIndex === pageCount - 1;
|
|
1028
|
+
useEffect9(() => {
|
|
1029
|
+
if (noPages) {
|
|
1030
|
+
setValue("0");
|
|
1031
|
+
} else {
|
|
1032
|
+
setValue((pageIndex + 1).toString());
|
|
1033
|
+
}
|
|
1034
|
+
}, [pageIndex, noPages]);
|
|
1035
|
+
const changePage = (page) => {
|
|
1036
|
+
onPageChanged(page);
|
|
1037
|
+
};
|
|
1038
|
+
return /* @__PURE__ */ jsxs4("div", { className: clsx7("flex-row-1", className), style, children: [
|
|
1039
|
+
/* @__PURE__ */ jsx9(IconButton, { color: "transparent", onClick: () => changePage(0), disabled: onFirstPage || noPages, children: /* @__PURE__ */ jsx9(ChevronFirst, {}) }),
|
|
1040
|
+
/* @__PURE__ */ jsx9(IconButton, { color: "transparent", onClick: () => changePage(pageIndex - 1), disabled: onFirstPage || noPages, children: /* @__PURE__ */ jsx9(ChevronLeft, {}) }),
|
|
1041
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex-row-2 min-w-56 items-center justify-center mx-2 text-center", children: [
|
|
1042
|
+
/* @__PURE__ */ jsx9(
|
|
1043
|
+
Input,
|
|
1044
|
+
{
|
|
1045
|
+
value,
|
|
1046
|
+
className: clsx7(
|
|
1047
|
+
"w-full text-center font-bold input-indicator-hidden h-10"
|
|
1048
|
+
),
|
|
1049
|
+
type: "number",
|
|
1050
|
+
min: 1,
|
|
1051
|
+
max: pageCount,
|
|
1052
|
+
disabled: noPages,
|
|
1053
|
+
onChangeText: (value2) => {
|
|
1054
|
+
if (value2) {
|
|
1055
|
+
setValue(clamp(Number(value2), [1, pageCount]).toString());
|
|
1056
|
+
} else {
|
|
1057
|
+
setValue(value2);
|
|
1058
|
+
}
|
|
1059
|
+
},
|
|
1060
|
+
onEditCompleted: (value2) => {
|
|
1061
|
+
changePage(clamp(Number(value2) - 1, [0, pageCount - 1]));
|
|
1062
|
+
},
|
|
1063
|
+
editCompleteOptions: { delay: 800 }
|
|
1064
|
+
}
|
|
1065
|
+
),
|
|
1066
|
+
/* @__PURE__ */ jsx9("span", { className: "select-none w-10", children: translation("of") }),
|
|
1067
|
+
/* @__PURE__ */ jsx9(
|
|
1068
|
+
"span",
|
|
1069
|
+
{
|
|
1070
|
+
className: "flex-row-2 flex-1 items-center justify-center select-none h-10 bg-input-background text-input-text rounded-md font-bold",
|
|
1071
|
+
children: pageCount
|
|
1072
|
+
}
|
|
1073
|
+
)
|
|
1074
|
+
] }),
|
|
1075
|
+
/* @__PURE__ */ jsx9(IconButton, { color: "transparent", onClick: () => changePage(pageIndex + 1), disabled: onLastPage || noPages, children: /* @__PURE__ */ jsx9(ChevronRight, {}) }),
|
|
1076
|
+
/* @__PURE__ */ jsx9(IconButton, { color: "transparent", onClick: () => changePage(pageCount - 1), disabled: onLastPage || noPages, children: /* @__PURE__ */ jsx9(ChevronLast, {}) })
|
|
1077
|
+
] });
|
|
1078
|
+
};
|
|
1079
|
+
|
|
1080
|
+
// src/components/user-action/Checkbox.tsx
|
|
1081
|
+
import { useEffect as useEffect14, useState as useState13 } from "react";
|
|
1082
|
+
import { Check, Minus } from "lucide-react";
|
|
1083
|
+
import clsx8 from "clsx";
|
|
1084
|
+
|
|
1085
|
+
// node_modules/@radix-ui/react-checkbox/dist/index.mjs
|
|
1086
|
+
import * as React11 from "react";
|
|
1087
|
+
|
|
1088
|
+
// node_modules/@radix-ui/react-compose-refs/dist/index.mjs
|
|
1089
|
+
import * as React2 from "react";
|
|
1090
|
+
function setRef(ref, value) {
|
|
1091
|
+
if (typeof ref === "function") {
|
|
1092
|
+
return ref(value);
|
|
1093
|
+
} else if (ref !== null && ref !== void 0) {
|
|
1094
|
+
ref.current = value;
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
function composeRefs(...refs) {
|
|
1098
|
+
return (node) => {
|
|
1099
|
+
let hasCleanup = false;
|
|
1100
|
+
const cleanups = refs.map((ref) => {
|
|
1101
|
+
const cleanup = setRef(ref, node);
|
|
1102
|
+
if (!hasCleanup && typeof cleanup == "function") {
|
|
1103
|
+
hasCleanup = true;
|
|
1104
|
+
}
|
|
1105
|
+
return cleanup;
|
|
1106
|
+
});
|
|
1107
|
+
if (hasCleanup) {
|
|
1108
|
+
return () => {
|
|
1109
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
1110
|
+
const cleanup = cleanups[i];
|
|
1111
|
+
if (typeof cleanup == "function") {
|
|
1112
|
+
cleanup();
|
|
1113
|
+
} else {
|
|
1114
|
+
setRef(refs[i], null);
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
function useComposedRefs(...refs) {
|
|
1122
|
+
return React2.useCallback(composeRefs(...refs), refs);
|
|
1123
|
+
}
|
|
1124
|
+
|
|
1125
|
+
// node_modules/@radix-ui/react-context/dist/index.mjs
|
|
1126
|
+
import * as React3 from "react";
|
|
1127
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
1128
|
+
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
1129
|
+
let defaultContexts = [];
|
|
1130
|
+
function createContext3(rootComponentName, defaultContext) {
|
|
1131
|
+
const BaseContext = React3.createContext(defaultContext);
|
|
1132
|
+
const index = defaultContexts.length;
|
|
1133
|
+
defaultContexts = [...defaultContexts, defaultContext];
|
|
1134
|
+
const Provider = (props) => {
|
|
1135
|
+
const { scope, children, ...context } = props;
|
|
1136
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
1137
|
+
const value = React3.useMemo(() => context, Object.values(context));
|
|
1138
|
+
return /* @__PURE__ */ jsx10(Context.Provider, { value, children });
|
|
1139
|
+
};
|
|
1140
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
1141
|
+
function useContext22(consumerName, scope) {
|
|
1142
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
1143
|
+
const context = React3.useContext(Context);
|
|
1144
|
+
if (context) return context;
|
|
1145
|
+
if (defaultContext !== void 0) return defaultContext;
|
|
1146
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
1147
|
+
}
|
|
1148
|
+
return [Provider, useContext22];
|
|
1149
|
+
}
|
|
1150
|
+
const createScope = () => {
|
|
1151
|
+
const scopeContexts = defaultContexts.map((defaultContext) => {
|
|
1152
|
+
return React3.createContext(defaultContext);
|
|
1153
|
+
});
|
|
1154
|
+
return function useScope(scope) {
|
|
1155
|
+
const contexts = scope?.[scopeName] || scopeContexts;
|
|
1156
|
+
return React3.useMemo(
|
|
1157
|
+
() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
|
|
1158
|
+
[scope, contexts]
|
|
1159
|
+
);
|
|
1160
|
+
};
|
|
1161
|
+
};
|
|
1162
|
+
createScope.scopeName = scopeName;
|
|
1163
|
+
return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
|
|
1164
|
+
}
|
|
1165
|
+
function composeContextScopes(...scopes) {
|
|
1166
|
+
const baseScope = scopes[0];
|
|
1167
|
+
if (scopes.length === 1) return baseScope;
|
|
1168
|
+
const createScope = () => {
|
|
1169
|
+
const scopeHooks = scopes.map((createScope2) => ({
|
|
1170
|
+
useScope: createScope2(),
|
|
1171
|
+
scopeName: createScope2.scopeName
|
|
1172
|
+
}));
|
|
1173
|
+
return function useComposedScopes(overrideScopes) {
|
|
1174
|
+
const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
|
|
1175
|
+
const scopeProps = useScope(overrideScopes);
|
|
1176
|
+
const currentScope = scopeProps[`__scope${scopeName}`];
|
|
1177
|
+
return { ...nextScopes2, ...currentScope };
|
|
1178
|
+
}, {});
|
|
1179
|
+
return React3.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
|
|
1180
|
+
};
|
|
1181
|
+
};
|
|
1182
|
+
createScope.scopeName = baseScope.scopeName;
|
|
1183
|
+
return createScope;
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
// node_modules/@radix-ui/primitive/dist/index.mjs
|
|
1187
|
+
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
1188
|
+
return function handleEvent(event) {
|
|
1189
|
+
originalEventHandler?.(event);
|
|
1190
|
+
if (checkForDefaultPrevented === false || !event.defaultPrevented) {
|
|
1191
|
+
return ourEventHandler?.(event);
|
|
1192
|
+
}
|
|
1193
|
+
};
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
// node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
|
|
1197
|
+
import * as React5 from "react";
|
|
1198
|
+
|
|
1199
|
+
// node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs
|
|
1200
|
+
import * as React4 from "react";
|
|
1201
|
+
var useLayoutEffect2 = globalThis?.document ? React4.useLayoutEffect : () => {
|
|
1202
|
+
};
|
|
1203
|
+
|
|
1204
|
+
// node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
|
|
1205
|
+
import * as React22 from "react";
|
|
1206
|
+
var useInsertionEffect = React5[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
|
|
1207
|
+
function useControllableState({
|
|
1208
|
+
prop,
|
|
1209
|
+
defaultProp,
|
|
1210
|
+
onChange = () => {
|
|
1211
|
+
},
|
|
1212
|
+
caller
|
|
1213
|
+
}) {
|
|
1214
|
+
const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
|
|
1215
|
+
defaultProp,
|
|
1216
|
+
onChange
|
|
1217
|
+
});
|
|
1218
|
+
const isControlled = prop !== void 0;
|
|
1219
|
+
const value = isControlled ? prop : uncontrolledProp;
|
|
1220
|
+
if (true) {
|
|
1221
|
+
const isControlledRef = React5.useRef(prop !== void 0);
|
|
1222
|
+
React5.useEffect(() => {
|
|
1223
|
+
const wasControlled = isControlledRef.current;
|
|
1224
|
+
if (wasControlled !== isControlled) {
|
|
1225
|
+
const from = wasControlled ? "controlled" : "uncontrolled";
|
|
1226
|
+
const to = isControlled ? "controlled" : "uncontrolled";
|
|
1227
|
+
console.warn(
|
|
1228
|
+
`${caller} is changing from ${from} to ${to}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
|
|
1229
|
+
);
|
|
1230
|
+
}
|
|
1231
|
+
isControlledRef.current = isControlled;
|
|
1232
|
+
}, [isControlled, caller]);
|
|
1233
|
+
}
|
|
1234
|
+
const setValue = React5.useCallback(
|
|
1235
|
+
(nextValue) => {
|
|
1236
|
+
if (isControlled) {
|
|
1237
|
+
const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
|
|
1238
|
+
if (value2 !== prop) {
|
|
1239
|
+
onChangeRef.current?.(value2);
|
|
1240
|
+
}
|
|
1241
|
+
} else {
|
|
1242
|
+
setUncontrolledProp(nextValue);
|
|
1243
|
+
}
|
|
1244
|
+
},
|
|
1245
|
+
[isControlled, prop, setUncontrolledProp, onChangeRef]
|
|
1246
|
+
);
|
|
1247
|
+
return [value, setValue];
|
|
1248
|
+
}
|
|
1249
|
+
function useUncontrolledState({
|
|
1250
|
+
defaultProp,
|
|
1251
|
+
onChange
|
|
1252
|
+
}) {
|
|
1253
|
+
const [value, setValue] = React5.useState(defaultProp);
|
|
1254
|
+
const prevValueRef = React5.useRef(value);
|
|
1255
|
+
const onChangeRef = React5.useRef(onChange);
|
|
1256
|
+
useInsertionEffect(() => {
|
|
1257
|
+
onChangeRef.current = onChange;
|
|
1258
|
+
}, [onChange]);
|
|
1259
|
+
React5.useEffect(() => {
|
|
1260
|
+
if (prevValueRef.current !== value) {
|
|
1261
|
+
onChangeRef.current?.(value);
|
|
1262
|
+
prevValueRef.current = value;
|
|
1263
|
+
}
|
|
1264
|
+
}, [value, prevValueRef]);
|
|
1265
|
+
return [value, setValue, onChangeRef];
|
|
1266
|
+
}
|
|
1267
|
+
function isFunction(value) {
|
|
1268
|
+
return typeof value === "function";
|
|
1269
|
+
}
|
|
1270
|
+
var SYNC_STATE = Symbol("RADIX:SYNC_STATE");
|
|
1271
|
+
|
|
1272
|
+
// node_modules/@radix-ui/react-use-previous/dist/index.mjs
|
|
1273
|
+
import * as React6 from "react";
|
|
1274
|
+
function usePrevious(value) {
|
|
1275
|
+
const ref = React6.useRef({ value, previous: value });
|
|
1276
|
+
return React6.useMemo(() => {
|
|
1277
|
+
if (ref.current.value !== value) {
|
|
1278
|
+
ref.current.previous = ref.current.value;
|
|
1279
|
+
ref.current.value = value;
|
|
1280
|
+
}
|
|
1281
|
+
return ref.current.previous;
|
|
1282
|
+
}, [value]);
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
// node_modules/@radix-ui/react-use-size/dist/index.mjs
|
|
1286
|
+
import * as React7 from "react";
|
|
1287
|
+
function useSize(element) {
|
|
1288
|
+
const [size, setSize] = React7.useState(void 0);
|
|
1289
|
+
useLayoutEffect2(() => {
|
|
1290
|
+
if (element) {
|
|
1291
|
+
setSize({ width: element.offsetWidth, height: element.offsetHeight });
|
|
1292
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
1293
|
+
if (!Array.isArray(entries)) {
|
|
1294
|
+
return;
|
|
1295
|
+
}
|
|
1296
|
+
if (!entries.length) {
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
const entry = entries[0];
|
|
1300
|
+
let width;
|
|
1301
|
+
let height;
|
|
1302
|
+
if ("borderBoxSize" in entry) {
|
|
1303
|
+
const borderSizeEntry = entry["borderBoxSize"];
|
|
1304
|
+
const borderSize = Array.isArray(borderSizeEntry) ? borderSizeEntry[0] : borderSizeEntry;
|
|
1305
|
+
width = borderSize["inlineSize"];
|
|
1306
|
+
height = borderSize["blockSize"];
|
|
1307
|
+
} else {
|
|
1308
|
+
width = element.offsetWidth;
|
|
1309
|
+
height = element.offsetHeight;
|
|
1310
|
+
}
|
|
1311
|
+
setSize({ width, height });
|
|
1312
|
+
});
|
|
1313
|
+
resizeObserver.observe(element, { box: "border-box" });
|
|
1314
|
+
return () => resizeObserver.unobserve(element);
|
|
1315
|
+
} else {
|
|
1316
|
+
setSize(void 0);
|
|
1317
|
+
}
|
|
1318
|
+
}, [element]);
|
|
1319
|
+
return size;
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
// node_modules/@radix-ui/react-presence/dist/index.mjs
|
|
1323
|
+
import * as React23 from "react";
|
|
1324
|
+
import * as React8 from "react";
|
|
1325
|
+
function useStateMachine(initialState, machine) {
|
|
1326
|
+
return React8.useReducer((state, event) => {
|
|
1327
|
+
const nextState = machine[state][event];
|
|
1328
|
+
return nextState ?? state;
|
|
1329
|
+
}, initialState);
|
|
1330
|
+
}
|
|
1331
|
+
var Presence = (props) => {
|
|
1332
|
+
const { present, children } = props;
|
|
1333
|
+
const presence = usePresence(present);
|
|
1334
|
+
const child = typeof children === "function" ? children({ present: presence.isPresent }) : React23.Children.only(children);
|
|
1335
|
+
const ref = useComposedRefs(presence.ref, getElementRef(child));
|
|
1336
|
+
const forceMount = typeof children === "function";
|
|
1337
|
+
return forceMount || presence.isPresent ? React23.cloneElement(child, { ref }) : null;
|
|
1338
|
+
};
|
|
1339
|
+
Presence.displayName = "Presence";
|
|
1340
|
+
function usePresence(present) {
|
|
1341
|
+
const [node, setNode] = React23.useState();
|
|
1342
|
+
const stylesRef = React23.useRef(null);
|
|
1343
|
+
const prevPresentRef = React23.useRef(present);
|
|
1344
|
+
const prevAnimationNameRef = React23.useRef("none");
|
|
1345
|
+
const initialState = present ? "mounted" : "unmounted";
|
|
1346
|
+
const [state, send] = useStateMachine(initialState, {
|
|
1347
|
+
mounted: {
|
|
1348
|
+
UNMOUNT: "unmounted",
|
|
1349
|
+
ANIMATION_OUT: "unmountSuspended"
|
|
1350
|
+
},
|
|
1351
|
+
unmountSuspended: {
|
|
1352
|
+
MOUNT: "mounted",
|
|
1353
|
+
ANIMATION_END: "unmounted"
|
|
1354
|
+
},
|
|
1355
|
+
unmounted: {
|
|
1356
|
+
MOUNT: "mounted"
|
|
1357
|
+
}
|
|
1358
|
+
});
|
|
1359
|
+
React23.useEffect(() => {
|
|
1360
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
1361
|
+
prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
|
|
1362
|
+
}, [state]);
|
|
1363
|
+
useLayoutEffect2(() => {
|
|
1364
|
+
const styles = stylesRef.current;
|
|
1365
|
+
const wasPresent = prevPresentRef.current;
|
|
1366
|
+
const hasPresentChanged = wasPresent !== present;
|
|
1367
|
+
if (hasPresentChanged) {
|
|
1368
|
+
const prevAnimationName = prevAnimationNameRef.current;
|
|
1369
|
+
const currentAnimationName = getAnimationName(styles);
|
|
1370
|
+
if (present) {
|
|
1371
|
+
send("MOUNT");
|
|
1372
|
+
} else if (currentAnimationName === "none" || styles?.display === "none") {
|
|
1373
|
+
send("UNMOUNT");
|
|
1374
|
+
} else {
|
|
1375
|
+
const isAnimating = prevAnimationName !== currentAnimationName;
|
|
1376
|
+
if (wasPresent && isAnimating) {
|
|
1377
|
+
send("ANIMATION_OUT");
|
|
1378
|
+
} else {
|
|
1379
|
+
send("UNMOUNT");
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
prevPresentRef.current = present;
|
|
1383
|
+
}
|
|
1384
|
+
}, [present, send]);
|
|
1385
|
+
useLayoutEffect2(() => {
|
|
1386
|
+
if (node) {
|
|
1387
|
+
let timeoutId;
|
|
1388
|
+
const ownerWindow = node.ownerDocument.defaultView ?? window;
|
|
1389
|
+
const handleAnimationEnd = (event) => {
|
|
1390
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
1391
|
+
const isCurrentAnimation = currentAnimationName.includes(event.animationName);
|
|
1392
|
+
if (event.target === node && isCurrentAnimation) {
|
|
1393
|
+
send("ANIMATION_END");
|
|
1394
|
+
if (!prevPresentRef.current) {
|
|
1395
|
+
const currentFillMode = node.style.animationFillMode;
|
|
1396
|
+
node.style.animationFillMode = "forwards";
|
|
1397
|
+
timeoutId = ownerWindow.setTimeout(() => {
|
|
1398
|
+
if (node.style.animationFillMode === "forwards") {
|
|
1399
|
+
node.style.animationFillMode = currentFillMode;
|
|
1400
|
+
}
|
|
1401
|
+
});
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
};
|
|
1405
|
+
const handleAnimationStart = (event) => {
|
|
1406
|
+
if (event.target === node) {
|
|
1407
|
+
prevAnimationNameRef.current = getAnimationName(stylesRef.current);
|
|
1408
|
+
}
|
|
1409
|
+
};
|
|
1410
|
+
node.addEventListener("animationstart", handleAnimationStart);
|
|
1411
|
+
node.addEventListener("animationcancel", handleAnimationEnd);
|
|
1412
|
+
node.addEventListener("animationend", handleAnimationEnd);
|
|
1413
|
+
return () => {
|
|
1414
|
+
ownerWindow.clearTimeout(timeoutId);
|
|
1415
|
+
node.removeEventListener("animationstart", handleAnimationStart);
|
|
1416
|
+
node.removeEventListener("animationcancel", handleAnimationEnd);
|
|
1417
|
+
node.removeEventListener("animationend", handleAnimationEnd);
|
|
1418
|
+
};
|
|
1419
|
+
} else {
|
|
1420
|
+
send("ANIMATION_END");
|
|
1421
|
+
}
|
|
1422
|
+
}, [node, send]);
|
|
1423
|
+
return {
|
|
1424
|
+
isPresent: ["mounted", "unmountSuspended"].includes(state),
|
|
1425
|
+
ref: React23.useCallback((node2) => {
|
|
1426
|
+
stylesRef.current = node2 ? getComputedStyle(node2) : null;
|
|
1427
|
+
setNode(node2);
|
|
1428
|
+
}, [])
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
function getAnimationName(styles) {
|
|
1432
|
+
return styles?.animationName || "none";
|
|
1433
|
+
}
|
|
1434
|
+
function getElementRef(element) {
|
|
1435
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
1436
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
1437
|
+
if (mayWarn) {
|
|
1438
|
+
return element.ref;
|
|
1439
|
+
}
|
|
1440
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
1441
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
1442
|
+
if (mayWarn) {
|
|
1443
|
+
return element.props.ref;
|
|
1444
|
+
}
|
|
1445
|
+
return element.props.ref || element.ref;
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1448
|
+
// node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
1449
|
+
import * as React10 from "react";
|
|
1450
|
+
import * as ReactDOM from "react-dom";
|
|
1451
|
+
|
|
1452
|
+
// node_modules/@radix-ui/react-slot/dist/index.mjs
|
|
1453
|
+
import * as React9 from "react";
|
|
1454
|
+
import { Fragment as Fragment22, jsx as jsx11 } from "react/jsx-runtime";
|
|
1455
|
+
// @__NO_SIDE_EFFECTS__
|
|
1456
|
+
function createSlot(ownerName) {
|
|
1457
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
1458
|
+
const Slot2 = React9.forwardRef((props, forwardedRef) => {
|
|
1459
|
+
const { children, ...slotProps } = props;
|
|
1460
|
+
const childrenArray = React9.Children.toArray(children);
|
|
1461
|
+
const slottable = childrenArray.find(isSlottable);
|
|
1462
|
+
if (slottable) {
|
|
1463
|
+
const newElement = slottable.props.children;
|
|
1464
|
+
const newChildren = childrenArray.map((child) => {
|
|
1465
|
+
if (child === slottable) {
|
|
1466
|
+
if (React9.Children.count(newElement) > 1) return React9.Children.only(null);
|
|
1467
|
+
return React9.isValidElement(newElement) ? newElement.props.children : null;
|
|
1468
|
+
} else {
|
|
1469
|
+
return child;
|
|
1470
|
+
}
|
|
1471
|
+
});
|
|
1472
|
+
return /* @__PURE__ */ jsx11(SlotClone, { ...slotProps, ref: forwardedRef, children: React9.isValidElement(newElement) ? React9.cloneElement(newElement, void 0, newChildren) : null });
|
|
1473
|
+
}
|
|
1474
|
+
return /* @__PURE__ */ jsx11(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
1475
|
+
});
|
|
1476
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
1477
|
+
return Slot2;
|
|
1478
|
+
}
|
|
1479
|
+
// @__NO_SIDE_EFFECTS__
|
|
1480
|
+
function createSlotClone(ownerName) {
|
|
1481
|
+
const SlotClone = React9.forwardRef((props, forwardedRef) => {
|
|
1482
|
+
const { children, ...slotProps } = props;
|
|
1483
|
+
if (React9.isValidElement(children)) {
|
|
1484
|
+
const childrenRef = getElementRef2(children);
|
|
1485
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
1486
|
+
if (children.type !== React9.Fragment) {
|
|
1487
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
1488
|
+
}
|
|
1489
|
+
return React9.cloneElement(children, props2);
|
|
1490
|
+
}
|
|
1491
|
+
return React9.Children.count(children) > 1 ? React9.Children.only(null) : null;
|
|
1492
|
+
});
|
|
1493
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
1494
|
+
return SlotClone;
|
|
1495
|
+
}
|
|
1496
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
1497
|
+
function isSlottable(child) {
|
|
1498
|
+
return React9.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
1499
|
+
}
|
|
1500
|
+
function mergeProps(slotProps, childProps) {
|
|
1501
|
+
const overrideProps = { ...childProps };
|
|
1502
|
+
for (const propName in childProps) {
|
|
1503
|
+
const slotPropValue = slotProps[propName];
|
|
1504
|
+
const childPropValue = childProps[propName];
|
|
1505
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
1506
|
+
if (isHandler) {
|
|
1507
|
+
if (slotPropValue && childPropValue) {
|
|
1508
|
+
overrideProps[propName] = (...args) => {
|
|
1509
|
+
const result = childPropValue(...args);
|
|
1510
|
+
slotPropValue(...args);
|
|
1511
|
+
return result;
|
|
1512
|
+
};
|
|
1513
|
+
} else if (slotPropValue) {
|
|
1514
|
+
overrideProps[propName] = slotPropValue;
|
|
1515
|
+
}
|
|
1516
|
+
} else if (propName === "style") {
|
|
1517
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
1518
|
+
} else if (propName === "className") {
|
|
1519
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
return { ...slotProps, ...overrideProps };
|
|
1523
|
+
}
|
|
1524
|
+
function getElementRef2(element) {
|
|
1525
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
1526
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
1527
|
+
if (mayWarn) {
|
|
1528
|
+
return element.ref;
|
|
1529
|
+
}
|
|
1530
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
1531
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
1532
|
+
if (mayWarn) {
|
|
1533
|
+
return element.props.ref;
|
|
1534
|
+
}
|
|
1535
|
+
return element.props.ref || element.ref;
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
// node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
1539
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1540
|
+
var NODES = [
|
|
1541
|
+
"a",
|
|
1542
|
+
"button",
|
|
1543
|
+
"div",
|
|
1544
|
+
"form",
|
|
1545
|
+
"h2",
|
|
1546
|
+
"h3",
|
|
1547
|
+
"img",
|
|
1548
|
+
"input",
|
|
1549
|
+
"label",
|
|
1550
|
+
"li",
|
|
1551
|
+
"nav",
|
|
1552
|
+
"ol",
|
|
1553
|
+
"p",
|
|
1554
|
+
"select",
|
|
1555
|
+
"span",
|
|
1556
|
+
"svg",
|
|
1557
|
+
"ul"
|
|
1558
|
+
];
|
|
1559
|
+
var Primitive = NODES.reduce((primitive, node) => {
|
|
1560
|
+
const Slot = createSlot(`Primitive.${node}`);
|
|
1561
|
+
const Node = React10.forwardRef((props, forwardedRef) => {
|
|
1562
|
+
const { asChild, ...primitiveProps } = props;
|
|
1563
|
+
const Comp = asChild ? Slot : node;
|
|
1564
|
+
if (typeof window !== "undefined") {
|
|
1565
|
+
window[Symbol.for("radix-ui")] = true;
|
|
1566
|
+
}
|
|
1567
|
+
return /* @__PURE__ */ jsx12(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
1568
|
+
});
|
|
1569
|
+
Node.displayName = `Primitive.${node}`;
|
|
1570
|
+
return { ...primitive, [node]: Node };
|
|
1571
|
+
}, {});
|
|
1572
|
+
|
|
1573
|
+
// node_modules/@radix-ui/react-checkbox/dist/index.mjs
|
|
1574
|
+
import { Fragment as Fragment4, jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1575
|
+
var CHECKBOX_NAME = "Checkbox";
|
|
1576
|
+
var [createCheckboxContext, createCheckboxScope] = createContextScope(CHECKBOX_NAME);
|
|
1577
|
+
var [CheckboxProviderImpl, useCheckboxContext] = createCheckboxContext(CHECKBOX_NAME);
|
|
1578
|
+
function CheckboxProvider(props) {
|
|
1579
|
+
const {
|
|
1580
|
+
__scopeCheckbox,
|
|
1581
|
+
checked: checkedProp,
|
|
1582
|
+
children,
|
|
1583
|
+
defaultChecked,
|
|
1584
|
+
disabled,
|
|
1585
|
+
form,
|
|
1586
|
+
name,
|
|
1587
|
+
onCheckedChange,
|
|
1588
|
+
required,
|
|
1589
|
+
value = "on",
|
|
1590
|
+
// @ts-expect-error
|
|
1591
|
+
internal_do_not_use_render
|
|
1592
|
+
} = props;
|
|
1593
|
+
const [checked, setChecked] = useControllableState({
|
|
1594
|
+
prop: checkedProp,
|
|
1595
|
+
defaultProp: defaultChecked ?? false,
|
|
1596
|
+
onChange: onCheckedChange,
|
|
1597
|
+
caller: CHECKBOX_NAME
|
|
1598
|
+
});
|
|
1599
|
+
const [control, setControl] = React11.useState(null);
|
|
1600
|
+
const [bubbleInput, setBubbleInput] = React11.useState(null);
|
|
1601
|
+
const hasConsumerStoppedPropagationRef = React11.useRef(false);
|
|
1602
|
+
const isFormControl = control ? !!form || !!control.closest("form") : (
|
|
1603
|
+
// We set this to true by default so that events bubble to forms without JS (SSR)
|
|
1604
|
+
true
|
|
1605
|
+
);
|
|
1606
|
+
const context = {
|
|
1607
|
+
checked,
|
|
1608
|
+
disabled,
|
|
1609
|
+
setChecked,
|
|
1610
|
+
control,
|
|
1611
|
+
setControl,
|
|
1612
|
+
name,
|
|
1613
|
+
form,
|
|
1614
|
+
value,
|
|
1615
|
+
hasConsumerStoppedPropagationRef,
|
|
1616
|
+
required,
|
|
1617
|
+
defaultChecked: isIndeterminate(defaultChecked) ? false : defaultChecked,
|
|
1618
|
+
isFormControl,
|
|
1619
|
+
bubbleInput,
|
|
1620
|
+
setBubbleInput
|
|
1621
|
+
};
|
|
1622
|
+
return /* @__PURE__ */ jsx13(
|
|
1623
|
+
CheckboxProviderImpl,
|
|
1624
|
+
{
|
|
1625
|
+
scope: __scopeCheckbox,
|
|
1626
|
+
...context,
|
|
1627
|
+
children: isFunction2(internal_do_not_use_render) ? internal_do_not_use_render(context) : children
|
|
1628
|
+
}
|
|
1629
|
+
);
|
|
1630
|
+
}
|
|
1631
|
+
var TRIGGER_NAME = "CheckboxTrigger";
|
|
1632
|
+
var CheckboxTrigger = React11.forwardRef(
|
|
1633
|
+
({ __scopeCheckbox, onKeyDown, onClick, ...checkboxProps }, forwardedRef) => {
|
|
1634
|
+
const {
|
|
1635
|
+
control,
|
|
1636
|
+
value,
|
|
1637
|
+
disabled,
|
|
1638
|
+
checked,
|
|
1639
|
+
required,
|
|
1640
|
+
setControl,
|
|
1641
|
+
setChecked,
|
|
1642
|
+
hasConsumerStoppedPropagationRef,
|
|
1643
|
+
isFormControl,
|
|
1644
|
+
bubbleInput
|
|
1645
|
+
} = useCheckboxContext(TRIGGER_NAME, __scopeCheckbox);
|
|
1646
|
+
const composedRefs = useComposedRefs(forwardedRef, setControl);
|
|
1647
|
+
const initialCheckedStateRef = React11.useRef(checked);
|
|
1648
|
+
React11.useEffect(() => {
|
|
1649
|
+
const form = control?.form;
|
|
1650
|
+
if (form) {
|
|
1651
|
+
const reset = () => setChecked(initialCheckedStateRef.current);
|
|
1652
|
+
form.addEventListener("reset", reset);
|
|
1653
|
+
return () => form.removeEventListener("reset", reset);
|
|
1654
|
+
}
|
|
1655
|
+
}, [control, setChecked]);
|
|
1656
|
+
return /* @__PURE__ */ jsx13(
|
|
1657
|
+
Primitive.button,
|
|
1658
|
+
{
|
|
1659
|
+
type: "button",
|
|
1660
|
+
role: "checkbox",
|
|
1661
|
+
"aria-checked": isIndeterminate(checked) ? "mixed" : checked,
|
|
1662
|
+
"aria-required": required,
|
|
1663
|
+
"data-state": getState(checked),
|
|
1664
|
+
"data-disabled": disabled ? "" : void 0,
|
|
1665
|
+
disabled,
|
|
1666
|
+
value,
|
|
1667
|
+
...checkboxProps,
|
|
1668
|
+
ref: composedRefs,
|
|
1669
|
+
onKeyDown: composeEventHandlers(onKeyDown, (event) => {
|
|
1670
|
+
if (event.key === "Enter") event.preventDefault();
|
|
1671
|
+
}),
|
|
1672
|
+
onClick: composeEventHandlers(onClick, (event) => {
|
|
1673
|
+
setChecked((prevChecked) => isIndeterminate(prevChecked) ? true : !prevChecked);
|
|
1674
|
+
if (bubbleInput && isFormControl) {
|
|
1675
|
+
hasConsumerStoppedPropagationRef.current = event.isPropagationStopped();
|
|
1676
|
+
if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation();
|
|
1677
|
+
}
|
|
1678
|
+
})
|
|
1679
|
+
}
|
|
1680
|
+
);
|
|
1681
|
+
}
|
|
1682
|
+
);
|
|
1683
|
+
CheckboxTrigger.displayName = TRIGGER_NAME;
|
|
1684
|
+
var Checkbox = React11.forwardRef(
|
|
1685
|
+
(props, forwardedRef) => {
|
|
1686
|
+
const {
|
|
1687
|
+
__scopeCheckbox,
|
|
1688
|
+
name,
|
|
1689
|
+
checked,
|
|
1690
|
+
defaultChecked,
|
|
1691
|
+
required,
|
|
1692
|
+
disabled,
|
|
1693
|
+
value,
|
|
1694
|
+
onCheckedChange,
|
|
1695
|
+
form,
|
|
1696
|
+
...checkboxProps
|
|
1697
|
+
} = props;
|
|
1698
|
+
return /* @__PURE__ */ jsx13(
|
|
1699
|
+
CheckboxProvider,
|
|
1700
|
+
{
|
|
1701
|
+
__scopeCheckbox,
|
|
1702
|
+
checked,
|
|
1703
|
+
defaultChecked,
|
|
1704
|
+
disabled,
|
|
1705
|
+
required,
|
|
1706
|
+
onCheckedChange,
|
|
1707
|
+
name,
|
|
1708
|
+
form,
|
|
1709
|
+
value,
|
|
1710
|
+
internal_do_not_use_render: ({ isFormControl }) => /* @__PURE__ */ jsxs5(Fragment4, { children: [
|
|
1711
|
+
/* @__PURE__ */ jsx13(
|
|
1712
|
+
CheckboxTrigger,
|
|
1713
|
+
{
|
|
1714
|
+
...checkboxProps,
|
|
1715
|
+
ref: forwardedRef,
|
|
1716
|
+
__scopeCheckbox
|
|
1717
|
+
}
|
|
1718
|
+
),
|
|
1719
|
+
isFormControl && /* @__PURE__ */ jsx13(
|
|
1720
|
+
CheckboxBubbleInput,
|
|
1721
|
+
{
|
|
1722
|
+
__scopeCheckbox
|
|
1723
|
+
}
|
|
1724
|
+
)
|
|
1725
|
+
] })
|
|
1726
|
+
}
|
|
1727
|
+
);
|
|
1728
|
+
}
|
|
1729
|
+
);
|
|
1730
|
+
Checkbox.displayName = CHECKBOX_NAME;
|
|
1731
|
+
var INDICATOR_NAME = "CheckboxIndicator";
|
|
1732
|
+
var CheckboxIndicator = React11.forwardRef(
|
|
1733
|
+
(props, forwardedRef) => {
|
|
1734
|
+
const { __scopeCheckbox, forceMount, ...indicatorProps } = props;
|
|
1735
|
+
const context = useCheckboxContext(INDICATOR_NAME, __scopeCheckbox);
|
|
1736
|
+
return /* @__PURE__ */ jsx13(
|
|
1737
|
+
Presence,
|
|
1738
|
+
{
|
|
1739
|
+
present: forceMount || isIndeterminate(context.checked) || context.checked === true,
|
|
1740
|
+
children: /* @__PURE__ */ jsx13(
|
|
1741
|
+
Primitive.span,
|
|
1742
|
+
{
|
|
1743
|
+
"data-state": getState(context.checked),
|
|
1744
|
+
"data-disabled": context.disabled ? "" : void 0,
|
|
1745
|
+
...indicatorProps,
|
|
1746
|
+
ref: forwardedRef,
|
|
1747
|
+
style: { pointerEvents: "none", ...props.style }
|
|
1748
|
+
}
|
|
1749
|
+
)
|
|
1750
|
+
}
|
|
1751
|
+
);
|
|
1752
|
+
}
|
|
1753
|
+
);
|
|
1754
|
+
CheckboxIndicator.displayName = INDICATOR_NAME;
|
|
1755
|
+
var BUBBLE_INPUT_NAME = "CheckboxBubbleInput";
|
|
1756
|
+
var CheckboxBubbleInput = React11.forwardRef(
|
|
1757
|
+
({ __scopeCheckbox, ...props }, forwardedRef) => {
|
|
1758
|
+
const {
|
|
1759
|
+
control,
|
|
1760
|
+
hasConsumerStoppedPropagationRef,
|
|
1761
|
+
checked,
|
|
1762
|
+
defaultChecked,
|
|
1763
|
+
required,
|
|
1764
|
+
disabled,
|
|
1765
|
+
name,
|
|
1766
|
+
value,
|
|
1767
|
+
form,
|
|
1768
|
+
bubbleInput,
|
|
1769
|
+
setBubbleInput
|
|
1770
|
+
} = useCheckboxContext(BUBBLE_INPUT_NAME, __scopeCheckbox);
|
|
1771
|
+
const composedRefs = useComposedRefs(forwardedRef, setBubbleInput);
|
|
1772
|
+
const prevChecked = usePrevious(checked);
|
|
1773
|
+
const controlSize = useSize(control);
|
|
1774
|
+
React11.useEffect(() => {
|
|
1775
|
+
const input = bubbleInput;
|
|
1776
|
+
if (!input) return;
|
|
1777
|
+
const inputProto = window.HTMLInputElement.prototype;
|
|
1778
|
+
const descriptor = Object.getOwnPropertyDescriptor(
|
|
1779
|
+
inputProto,
|
|
1780
|
+
"checked"
|
|
1781
|
+
);
|
|
1782
|
+
const setChecked = descriptor.set;
|
|
1783
|
+
const bubbles = !hasConsumerStoppedPropagationRef.current;
|
|
1784
|
+
if (prevChecked !== checked && setChecked) {
|
|
1785
|
+
const event = new Event("click", { bubbles });
|
|
1786
|
+
input.indeterminate = isIndeterminate(checked);
|
|
1787
|
+
setChecked.call(input, isIndeterminate(checked) ? false : checked);
|
|
1788
|
+
input.dispatchEvent(event);
|
|
1789
|
+
}
|
|
1790
|
+
}, [bubbleInput, prevChecked, checked, hasConsumerStoppedPropagationRef]);
|
|
1791
|
+
const defaultCheckedRef = React11.useRef(isIndeterminate(checked) ? false : checked);
|
|
1792
|
+
return /* @__PURE__ */ jsx13(
|
|
1793
|
+
Primitive.input,
|
|
1794
|
+
{
|
|
1795
|
+
type: "checkbox",
|
|
1796
|
+
"aria-hidden": true,
|
|
1797
|
+
defaultChecked: defaultChecked ?? defaultCheckedRef.current,
|
|
1798
|
+
required,
|
|
1799
|
+
disabled,
|
|
1800
|
+
name,
|
|
1801
|
+
value,
|
|
1802
|
+
form,
|
|
1803
|
+
...props,
|
|
1804
|
+
tabIndex: -1,
|
|
1805
|
+
ref: composedRefs,
|
|
1806
|
+
style: {
|
|
1807
|
+
...props.style,
|
|
1808
|
+
...controlSize,
|
|
1809
|
+
position: "absolute",
|
|
1810
|
+
pointerEvents: "none",
|
|
1811
|
+
opacity: 0,
|
|
1812
|
+
margin: 0,
|
|
1813
|
+
// We transform because the input is absolutely positioned but we have
|
|
1814
|
+
// rendered it **after** the button. This pulls it back to sit on top
|
|
1815
|
+
// of the button.
|
|
1816
|
+
transform: "translateX(-100%)"
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
);
|
|
1820
|
+
}
|
|
1821
|
+
);
|
|
1822
|
+
CheckboxBubbleInput.displayName = BUBBLE_INPUT_NAME;
|
|
1823
|
+
function isFunction2(value) {
|
|
1824
|
+
return typeof value === "function";
|
|
1825
|
+
}
|
|
1826
|
+
function isIndeterminate(checked) {
|
|
1827
|
+
return checked === "indeterminate";
|
|
1828
|
+
}
|
|
1829
|
+
function getState(checked) {
|
|
1830
|
+
return isIndeterminate(checked) ? "indeterminate" : checked ? "checked" : "unchecked";
|
|
1831
|
+
}
|
|
1832
|
+
|
|
1833
|
+
// src/components/user-action/Checkbox.tsx
|
|
1834
|
+
import { jsx as jsx14, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1835
|
+
var checkboxSizeMapping = {
|
|
1836
|
+
sm: "size-5 border-1",
|
|
1837
|
+
md: "size-6 border-1",
|
|
1838
|
+
lg: "size-8 border-2"
|
|
1839
|
+
};
|
|
1840
|
+
var checkboxIconSizeMapping = {
|
|
1841
|
+
sm: "size-4 stroke-3",
|
|
1842
|
+
md: "size-5 stroke-3",
|
|
1843
|
+
lg: "size-7 stroke-3"
|
|
1844
|
+
};
|
|
1845
|
+
var Checkbox2 = ({
|
|
1846
|
+
disabled,
|
|
1847
|
+
checked = false,
|
|
1848
|
+
indeterminate = false,
|
|
1849
|
+
onChange,
|
|
1850
|
+
size = "md",
|
|
1851
|
+
className = "",
|
|
1852
|
+
...props
|
|
1853
|
+
}) => {
|
|
1854
|
+
const usedSizeClass = checkboxSizeMapping[size];
|
|
1855
|
+
const innerIconSize = checkboxIconSizeMapping[size];
|
|
1856
|
+
return /* @__PURE__ */ jsx14(
|
|
1857
|
+
Checkbox,
|
|
1858
|
+
{
|
|
1859
|
+
...props,
|
|
1860
|
+
disabled,
|
|
1861
|
+
checked: indeterminate ? "indeterminate" : checked,
|
|
1862
|
+
onCheckedChange: onChange,
|
|
1863
|
+
className: clsx8(
|
|
1864
|
+
usedSizeClass,
|
|
1865
|
+
`flex-col-0 items-center justify-center rounded outline-none`,
|
|
1866
|
+
{
|
|
1867
|
+
"text-disabled-text border-disabled-outline bg-disabled-background cursor-not-allowed": disabled,
|
|
1868
|
+
"hover:border-primary": !disabled,
|
|
1869
|
+
"bg-input-background": !disabled && !checked,
|
|
1870
|
+
"bg-primary/30 border-primary text-primary": !disabled && (checked || indeterminate)
|
|
1871
|
+
},
|
|
1872
|
+
className
|
|
1873
|
+
),
|
|
1874
|
+
children: /* @__PURE__ */ jsxs6(CheckboxIndicator, { children: [
|
|
1875
|
+
!checked && !indeterminate && /* @__PURE__ */ jsx14("div", { className: clsx8("bg-input-background", innerIconSize) }),
|
|
1876
|
+
checked && !indeterminate && /* @__PURE__ */ jsx14(Check, { className: innerIconSize }),
|
|
1877
|
+
indeterminate && /* @__PURE__ */ jsx14(Minus, { className: innerIconSize })
|
|
1878
|
+
] })
|
|
1879
|
+
}
|
|
1880
|
+
);
|
|
1881
|
+
};
|
|
1882
|
+
|
|
1883
|
+
// src/components/table/Table.tsx
|
|
1884
|
+
import { jsx as jsx15, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1885
|
+
var Table = ({
|
|
1886
|
+
data,
|
|
1887
|
+
fillerRow,
|
|
1888
|
+
initialState,
|
|
1889
|
+
onRowClick = noop,
|
|
1890
|
+
className,
|
|
1891
|
+
tableClassName,
|
|
1892
|
+
defaultColumn,
|
|
1893
|
+
state,
|
|
1894
|
+
columns,
|
|
1895
|
+
...tableOptions
|
|
1896
|
+
}) => {
|
|
1897
|
+
const ref = useRef8(null);
|
|
1898
|
+
const tableRef = useRef8(null);
|
|
1899
|
+
const [columnSizing, setColumnSizing] = useState14(columns.reduce((previousValue, currentValue) => {
|
|
1900
|
+
return {
|
|
1901
|
+
...previousValue,
|
|
1902
|
+
[currentValue.id]: currentValue.minSize ?? defaultColumn.minSize
|
|
1903
|
+
};
|
|
1904
|
+
}, {}));
|
|
1905
|
+
const [columnSizingInfo, setColumnSizingInfo] = useState14();
|
|
1906
|
+
const [pagination, setPagination] = useState14({
|
|
1907
|
+
pageSize: 10,
|
|
1908
|
+
pageIndex: 0,
|
|
1909
|
+
...initialState?.pagination
|
|
1910
|
+
});
|
|
1911
|
+
const [columnFilters, setColumnFilters] = useState14(initialState?.columnFilters);
|
|
1912
|
+
const computedColumnMinWidths = useMemo4(() => {
|
|
1913
|
+
return columns.reduce((previousValue, column) => {
|
|
1914
|
+
return {
|
|
1915
|
+
...previousValue,
|
|
1916
|
+
// every column is at least 12px wide
|
|
1917
|
+
[column.id]: column.minSize ?? defaultColumn?.minSize ?? 12
|
|
1918
|
+
};
|
|
1919
|
+
}, {});
|
|
1920
|
+
}, [columns, defaultColumn]);
|
|
1921
|
+
const computedColumnMaxWidths = useMemo4(() => {
|
|
1922
|
+
return columns.reduce((previousValue, column) => {
|
|
1923
|
+
return {
|
|
1924
|
+
...previousValue,
|
|
1925
|
+
[column.id]: column.maxSize ?? defaultColumn?.maxSize
|
|
1926
|
+
};
|
|
1927
|
+
}, {});
|
|
1928
|
+
}, [columns, defaultColumn]);
|
|
1929
|
+
const tableMinWidth = useMemo4(() => {
|
|
1930
|
+
return columns.reduce((sum, column) => {
|
|
1931
|
+
return sum + computedColumnMinWidths[column.id];
|
|
1932
|
+
}, 0);
|
|
1933
|
+
}, [columns, computedColumnMinWidths]);
|
|
1934
|
+
const updateColumnSizes = useMemo4(() => {
|
|
1935
|
+
return (previous) => {
|
|
1936
|
+
const updateSizing = {
|
|
1937
|
+
...columnSizing,
|
|
1938
|
+
...previous
|
|
1939
|
+
};
|
|
1940
|
+
const containerWidth = ref.current.offsetWidth;
|
|
1941
|
+
columns.forEach((column) => {
|
|
1942
|
+
updateSizing[column.id] = clamp(updateSizing[column.id], [computedColumnMinWidths[column.id], computedColumnMaxWidths[column.id] ?? containerWidth]);
|
|
1943
|
+
});
|
|
1944
|
+
const width = columns.reduce((previousValue, currentValue) => previousValue + updateSizing[currentValue.id], 0);
|
|
1945
|
+
if (width > containerWidth) {
|
|
1946
|
+
if (tableMinWidth >= containerWidth) {
|
|
1947
|
+
return columns.reduce((previousValue, currentValue) => ({
|
|
1948
|
+
...previousValue,
|
|
1949
|
+
[currentValue.id]: computedColumnMinWidths[currentValue.id]
|
|
1950
|
+
}), {});
|
|
1951
|
+
}
|
|
1952
|
+
let reduceableColumns = columns.map((value) => value.id).filter((id) => updateSizing[id] - computedColumnMinWidths[id] > 0);
|
|
1953
|
+
let spaceToReduce = width - containerWidth;
|
|
1954
|
+
while (spaceToReduce > 0 && reduceableColumns.length > 0) {
|
|
1955
|
+
let maxReduceAmount = reduceableColumns.reduce((previousValue, id) => Math.max(previousValue, updateSizing[id] - computedColumnMinWidths[id]), 0);
|
|
1956
|
+
if (maxReduceAmount * reduceableColumns.length > spaceToReduce) {
|
|
1957
|
+
maxReduceAmount = spaceToReduce / reduceableColumns.length;
|
|
1958
|
+
}
|
|
1959
|
+
reduceableColumns.forEach((id) => {
|
|
1960
|
+
updateSizing[id] -= maxReduceAmount;
|
|
1961
|
+
});
|
|
1962
|
+
spaceToReduce -= maxReduceAmount * reduceableColumns.length;
|
|
1963
|
+
reduceableColumns = reduceableColumns.filter((id) => updateSizing[id] - computedColumnMinWidths[id] > 0);
|
|
1964
|
+
}
|
|
1965
|
+
} else if (width <= containerWidth) {
|
|
1966
|
+
let distributableWidth = containerWidth - width;
|
|
1967
|
+
const violatingColumns = columns.filter((value) => computedColumnMaxWidths[value.id] && updateSizing[value.id] > computedColumnMaxWidths[value.id]);
|
|
1968
|
+
const violationColumnsAmount = violatingColumns.reduce(
|
|
1969
|
+
(previousValue, column) => previousValue + updateSizing[column.id] - computedColumnMaxWidths[column.id],
|
|
1970
|
+
0
|
|
1971
|
+
);
|
|
1972
|
+
distributableWidth += violationColumnsAmount;
|
|
1973
|
+
let enlargeableColumns = columns.filter((col) => !computedColumnMaxWidths[col.id] || updateSizing[col.id] < computedColumnMaxWidths[col.id]).map((value) => value.id);
|
|
1974
|
+
while (distributableWidth > 0 && enlargeableColumns.length > 0) {
|
|
1975
|
+
let minEnlargeableAmount = enlargeableColumns.reduce((previousValue, id) => Math.min(previousValue, computedColumnMaxWidths[id] ? computedColumnMaxWidths[id] - updateSizing[id] : distributableWidth), distributableWidth);
|
|
1976
|
+
if (minEnlargeableAmount * enlargeableColumns.length > distributableWidth) {
|
|
1977
|
+
minEnlargeableAmount = distributableWidth / enlargeableColumns.length;
|
|
1978
|
+
}
|
|
1979
|
+
enlargeableColumns.forEach((id) => {
|
|
1980
|
+
updateSizing[id] += minEnlargeableAmount;
|
|
1981
|
+
});
|
|
1982
|
+
distributableWidth -= minEnlargeableAmount * enlargeableColumns.length;
|
|
1983
|
+
enlargeableColumns = enlargeableColumns.filter((id) => !computedColumnMaxWidths[id] || updateSizing[id] < computedColumnMaxWidths[id]);
|
|
1984
|
+
}
|
|
1985
|
+
if (distributableWidth > 0) {
|
|
1986
|
+
updateSizing[columns[columns.length - 1].id] += distributableWidth;
|
|
1987
|
+
}
|
|
1988
|
+
}
|
|
1989
|
+
return updateSizing;
|
|
1990
|
+
};
|
|
1991
|
+
}, [columns, computedColumnMaxWidths, computedColumnMinWidths, tableMinWidth]);
|
|
1992
|
+
const table = useReactTable({
|
|
1993
|
+
data,
|
|
1994
|
+
getCoreRowModel: getCoreRowModel(),
|
|
1995
|
+
getFilteredRowModel: getFilteredRowModel(),
|
|
1996
|
+
getSortedRowModel: getSortedRowModel(),
|
|
1997
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
1998
|
+
initialState,
|
|
1999
|
+
defaultColumn: {
|
|
2000
|
+
minSize: 60,
|
|
2001
|
+
maxSize: 700,
|
|
2002
|
+
cell: ({ cell }) => {
|
|
2003
|
+
return /* @__PURE__ */ jsx15(TableCell, { children: cell.getValue() });
|
|
2004
|
+
},
|
|
2005
|
+
...defaultColumn
|
|
2006
|
+
},
|
|
2007
|
+
columns,
|
|
2008
|
+
state: {
|
|
2009
|
+
columnSizing,
|
|
2010
|
+
columnSizingInfo,
|
|
2011
|
+
pagination,
|
|
2012
|
+
columnFilters,
|
|
2013
|
+
...state
|
|
2014
|
+
},
|
|
2015
|
+
filterFns: {
|
|
2016
|
+
...tableOptions?.filterFns,
|
|
2017
|
+
dateRange: TableFilters.dateRange
|
|
2018
|
+
},
|
|
2019
|
+
onColumnSizingInfoChange: (updaterOrValue) => {
|
|
2020
|
+
setColumnSizingInfo(updaterOrValue);
|
|
2021
|
+
if (tableOptions.onColumnSizingInfoChange) {
|
|
2022
|
+
tableOptions?.onColumnSizingInfoChange(updaterOrValue);
|
|
2023
|
+
}
|
|
2024
|
+
},
|
|
2025
|
+
onColumnSizingChange: (updaterOrValue) => {
|
|
2026
|
+
setColumnSizing((previous) => {
|
|
2027
|
+
const newSizing = typeof updaterOrValue === "function" ? updaterOrValue(previous) : updaterOrValue;
|
|
2028
|
+
return updateColumnSizes(newSizing);
|
|
2029
|
+
});
|
|
2030
|
+
if (tableOptions.onColumnSizingChange) {
|
|
2031
|
+
tableOptions.onColumnSizingChange(updaterOrValue);
|
|
2032
|
+
}
|
|
2033
|
+
},
|
|
2034
|
+
onPaginationChange: (updaterOrValue) => {
|
|
2035
|
+
setPagination(updaterOrValue);
|
|
2036
|
+
if (tableOptions.onPaginationChange) {
|
|
2037
|
+
tableOptions.onPaginationChange(updaterOrValue);
|
|
2038
|
+
}
|
|
2039
|
+
},
|
|
2040
|
+
onColumnFiltersChange: (updaterOrValue) => {
|
|
2041
|
+
setColumnFilters(updaterOrValue);
|
|
2042
|
+
table.toggleAllRowsSelected(false);
|
|
2043
|
+
if (tableOptions.onColumnFiltersChange) {
|
|
2044
|
+
tableOptions.onColumnFiltersChange(updaterOrValue);
|
|
2045
|
+
}
|
|
2046
|
+
},
|
|
2047
|
+
autoResetPageIndex: false,
|
|
2048
|
+
columnResizeMode: "onChange",
|
|
2049
|
+
...tableOptions
|
|
2050
|
+
});
|
|
2051
|
+
const [hasInitializedSizing, setHasInitializedSizing] = useState14(false);
|
|
2052
|
+
useEffect15(() => {
|
|
2053
|
+
if (!hasInitializedSizing && ref.current) {
|
|
2054
|
+
setHasInitializedSizing(true);
|
|
2055
|
+
table.setColumnSizing(updateColumnSizes(columnSizing));
|
|
2056
|
+
}
|
|
2057
|
+
}, [columnSizing, hasInitializedSizing]);
|
|
2058
|
+
useResizeCallbackWrapper(useCallback6(() => {
|
|
2059
|
+
table.setColumnSizing(updateColumnSizes);
|
|
2060
|
+
}, [updateColumnSizes]));
|
|
2061
|
+
const pageCount = table.getPageCount();
|
|
2062
|
+
useEffect15(() => {
|
|
2063
|
+
const totalPages = pageCount;
|
|
2064
|
+
if (totalPages === 0) {
|
|
2065
|
+
if (pagination.pageIndex !== 0) {
|
|
2066
|
+
table.setPagination((prevState) => ({
|
|
2067
|
+
...prevState,
|
|
2068
|
+
pageIndex: 0
|
|
2069
|
+
}));
|
|
2070
|
+
}
|
|
2071
|
+
} else if (pagination.pageIndex >= totalPages) {
|
|
2072
|
+
table.setPagination((prev) => ({
|
|
2073
|
+
...prev,
|
|
2074
|
+
pageIndex: totalPages - 1
|
|
2075
|
+
}));
|
|
2076
|
+
}
|
|
2077
|
+
}, [data, pageCount, pagination.pageSize, pagination.pageIndex]);
|
|
2078
|
+
const columnSizeVars = useMemo4(() => {
|
|
2079
|
+
const headers = table.getFlatHeaders();
|
|
2080
|
+
const colSizes = {};
|
|
2081
|
+
for (let i = 0; i < headers.length; i++) {
|
|
2082
|
+
const header = headers[i];
|
|
2083
|
+
colSizes[`--header-${header.id}-size`] = Math.floor(header.getSize());
|
|
2084
|
+
colSizes[`--col-${header.column.id}-size`] = Math.floor(header.column.getSize());
|
|
2085
|
+
}
|
|
2086
|
+
return colSizes;
|
|
2087
|
+
}, [table.getState().columnSizingInfo, table.getState().columnSizing]);
|
|
2088
|
+
return /* @__PURE__ */ jsxs7("div", { ref, className: clsx9("flex-col-4", className), children: [
|
|
2089
|
+
/* @__PURE__ */ jsx15(
|
|
2090
|
+
Scrollbars,
|
|
2091
|
+
{
|
|
2092
|
+
autoHeight: true,
|
|
2093
|
+
autoHeightMax: tableRef.current?.offsetHeight ? tableRef.current?.offsetHeight + 2 : void 0,
|
|
2094
|
+
autoHide: true,
|
|
2095
|
+
children: /* @__PURE__ */ jsxs7(
|
|
2096
|
+
"table",
|
|
2097
|
+
{
|
|
2098
|
+
ref: tableRef,
|
|
2099
|
+
className: clsx9(tableClassName),
|
|
2100
|
+
style: {
|
|
2101
|
+
...columnSizeVars,
|
|
2102
|
+
width: Math.floor(Math.max(table.getTotalSize() - columns.length, ref.current?.offsetWidth ?? table.getTotalSize()))
|
|
2103
|
+
},
|
|
2104
|
+
children: [
|
|
2105
|
+
table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx15("colgroup", { children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx15(
|
|
2106
|
+
"col",
|
|
2107
|
+
{
|
|
2108
|
+
style: {
|
|
2109
|
+
width: `calc(var(--header-${header?.id}-size) * 1px)`,
|
|
2110
|
+
minWidth: header.column.columnDef.minSize,
|
|
2111
|
+
maxWidth: header.column.columnDef.maxSize
|
|
2112
|
+
}
|
|
2113
|
+
},
|
|
2114
|
+
header.id
|
|
2115
|
+
)) }, headerGroup.id)),
|
|
2116
|
+
/* @__PURE__ */ jsx15("thead", { children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx15("tr", { className: table.options.meta?.headerRowClassName, children: headerGroup.headers.map((header) => {
|
|
2117
|
+
return /* @__PURE__ */ jsxs7(
|
|
2118
|
+
"th",
|
|
2119
|
+
{
|
|
2120
|
+
colSpan: header.colSpan,
|
|
2121
|
+
className: clsx9("relative group", header.column.columnDef.meta?.className),
|
|
2122
|
+
children: [
|
|
2123
|
+
/* @__PURE__ */ jsx15("div", { className: "flex-row-2 w-full", children: header.isPlaceholder ? null : /* @__PURE__ */ jsxs7("div", { className: "flex-row-1 items-center", children: [
|
|
2124
|
+
header.column.getCanSort() && /* @__PURE__ */ jsx15(
|
|
2125
|
+
TableSortButton,
|
|
2126
|
+
{
|
|
2127
|
+
sortDirection: header.column.getIsSorted(),
|
|
2128
|
+
onClick: () => header.column.toggleSorting()
|
|
2129
|
+
}
|
|
2130
|
+
),
|
|
2131
|
+
header.column.getCanFilter() && header.column.columnDef.meta?.filterType ? /* @__PURE__ */ jsx15(
|
|
2132
|
+
TableFilterButton,
|
|
2133
|
+
{
|
|
2134
|
+
column: header.column,
|
|
2135
|
+
filterType: header.column.columnDef.meta.filterType
|
|
2136
|
+
}
|
|
2137
|
+
) : null,
|
|
2138
|
+
flexRender(
|
|
2139
|
+
header.column.columnDef.header,
|
|
2140
|
+
header.getContext()
|
|
2141
|
+
)
|
|
2142
|
+
] }) }),
|
|
2143
|
+
header.column.getCanResize() && /* @__PURE__ */ jsx15(
|
|
2144
|
+
"div",
|
|
2145
|
+
{
|
|
2146
|
+
onMouseDown: header.getResizeHandler(),
|
|
2147
|
+
onTouchStart: header.getResizeHandler(),
|
|
2148
|
+
onDoubleClick: () => {
|
|
2149
|
+
header.column.resetSize();
|
|
2150
|
+
},
|
|
2151
|
+
className: "table-resize-indicator w-2 rounded bg-primary cursor-col-resize select-none touch-none opacity-0 group-hover:opacity-100 transition-opacity",
|
|
2152
|
+
style: {
|
|
2153
|
+
opacity: !columnSizingInfo?.columnSizingStart ? void 0 : columnSizingInfo?.columnSizingStart?.findIndex(([id, _]) => id === header.column.id) !== -1 ? 1 : columnSizingInfo?.columnSizingStart?.length !== 0 ? 0 : void 0
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
)
|
|
2157
|
+
]
|
|
2158
|
+
},
|
|
2159
|
+
header.id
|
|
2160
|
+
);
|
|
2161
|
+
}) }, headerGroup.id)) }),
|
|
2162
|
+
/* @__PURE__ */ jsxs7("tbody", { children: [
|
|
2163
|
+
table.getRowModel().rows.map((row) => {
|
|
2164
|
+
return /* @__PURE__ */ jsx15("tr", { onClick: () => onRowClick(row, table), className: table.options.meta?.bodyRowClassName, children: row.getVisibleCells().map((cell) => {
|
|
2165
|
+
return /* @__PURE__ */ jsx15("td", { children: flexRender(
|
|
2166
|
+
cell.column.columnDef.cell,
|
|
2167
|
+
cell.getContext()
|
|
2168
|
+
) }, cell.id);
|
|
2169
|
+
}) }, row.id);
|
|
2170
|
+
}),
|
|
2171
|
+
range(table.getState().pagination.pageSize - table.getRowModel().rows.length, { allowEmptyRange: true }).map((row, index) => {
|
|
2172
|
+
return /* @__PURE__ */ jsx15("tr", { children: columns.map((column) => {
|
|
2173
|
+
return /* @__PURE__ */ jsx15("td", { children: fillerRow ? fillerRow(column.id, table) : /* @__PURE__ */ jsx15(FillerRowElement, {}) }, column.id);
|
|
2174
|
+
}) }, "filler-row-" + index);
|
|
2175
|
+
})
|
|
2176
|
+
] })
|
|
2177
|
+
]
|
|
2178
|
+
}
|
|
2179
|
+
)
|
|
2180
|
+
}
|
|
2181
|
+
),
|
|
2182
|
+
/* @__PURE__ */ jsx15("div", { className: "flex-row-2 justify-center", children: /* @__PURE__ */ jsx15(
|
|
2183
|
+
Pagination,
|
|
2184
|
+
{
|
|
2185
|
+
pageIndex: table.getState().pagination.pageIndex,
|
|
2186
|
+
pageCount: table.getPageCount(),
|
|
2187
|
+
onPageChanged: (page) => table.setPageIndex(page)
|
|
2188
|
+
}
|
|
2189
|
+
) })
|
|
2190
|
+
] });
|
|
2191
|
+
};
|
|
2192
|
+
var TableUncontrolled = ({ data, ...props }) => {
|
|
2193
|
+
const [usedDate, setUsedData] = useState14(data);
|
|
2194
|
+
useEffect15(() => {
|
|
2195
|
+
setUsedData(data);
|
|
2196
|
+
}, [data]);
|
|
2197
|
+
return /* @__PURE__ */ jsx15(
|
|
2198
|
+
Table,
|
|
2199
|
+
{
|
|
2200
|
+
...props,
|
|
2201
|
+
data: usedDate
|
|
2202
|
+
}
|
|
2203
|
+
);
|
|
2204
|
+
};
|
|
2205
|
+
var TableWithSelection = ({
|
|
2206
|
+
columns,
|
|
2207
|
+
state,
|
|
2208
|
+
fillerRow,
|
|
2209
|
+
rowSelection,
|
|
2210
|
+
disableClickRowClickSelection = false,
|
|
2211
|
+
selectionRowId = "selection",
|
|
2212
|
+
onRowClick = noop,
|
|
2213
|
+
meta,
|
|
2214
|
+
...props
|
|
2215
|
+
}) => {
|
|
2216
|
+
const columnsWithSelection = useMemo4(() => {
|
|
2217
|
+
return [
|
|
2218
|
+
{
|
|
2219
|
+
id: selectionRowId,
|
|
2220
|
+
header: ({ table }) => {
|
|
2221
|
+
return /* @__PURE__ */ jsx15(
|
|
2222
|
+
Checkbox2,
|
|
2223
|
+
{
|
|
2224
|
+
checked: table.getIsAllRowsSelected(),
|
|
2225
|
+
indeterminate: table.getIsSomeRowsSelected(),
|
|
2226
|
+
onChange: (value) => {
|
|
2227
|
+
const newValue = !!value;
|
|
2228
|
+
table.toggleAllRowsSelected(newValue);
|
|
2229
|
+
}
|
|
2230
|
+
}
|
|
2231
|
+
);
|
|
2232
|
+
},
|
|
2233
|
+
cell: ({ row }) => {
|
|
2234
|
+
return /* @__PURE__ */ jsx15(
|
|
2235
|
+
Checkbox2,
|
|
2236
|
+
{
|
|
2237
|
+
disabled: !row.getCanSelect(),
|
|
2238
|
+
checked: row.getIsSelected(),
|
|
2239
|
+
onChange: row.getToggleSelectedHandler()
|
|
2240
|
+
}
|
|
2241
|
+
);
|
|
2242
|
+
},
|
|
2243
|
+
size: 60,
|
|
2244
|
+
minSize: 60,
|
|
2245
|
+
maxSize: 60,
|
|
2246
|
+
enableResizing: false,
|
|
2247
|
+
enableSorting: false
|
|
2248
|
+
},
|
|
2249
|
+
...columns
|
|
2250
|
+
];
|
|
2251
|
+
}, [columns, selectionRowId]);
|
|
2252
|
+
return /* @__PURE__ */ jsx15(
|
|
2253
|
+
Table,
|
|
2254
|
+
{
|
|
2255
|
+
columns: columnsWithSelection,
|
|
2256
|
+
fillerRow: (columnId, table) => {
|
|
2257
|
+
if (columnId === selectionRowId) {
|
|
2258
|
+
return /* @__PURE__ */ jsx15(Checkbox2, { checked: false, disabled: true, className: "max-w-6" });
|
|
2259
|
+
}
|
|
2260
|
+
return fillerRow ? fillerRow(columnId, table) : /* @__PURE__ */ jsx15(FillerRowElement, {});
|
|
2261
|
+
},
|
|
2262
|
+
state: {
|
|
2263
|
+
rowSelection,
|
|
2264
|
+
...state
|
|
2265
|
+
},
|
|
2266
|
+
onRowClick: (row, table) => {
|
|
2267
|
+
if (!disableClickRowClickSelection) {
|
|
2268
|
+
row.toggleSelected();
|
|
2269
|
+
}
|
|
2270
|
+
onRowClick(row, table);
|
|
2271
|
+
},
|
|
2272
|
+
meta: {
|
|
2273
|
+
...meta,
|
|
2274
|
+
bodyRowClassName: clsx9(
|
|
2275
|
+
{ "cursor-pointer": !disableClickRowClickSelection },
|
|
2276
|
+
meta?.bodyRowClassName
|
|
2277
|
+
)
|
|
2278
|
+
},
|
|
2279
|
+
...props
|
|
2280
|
+
}
|
|
2281
|
+
);
|
|
2282
|
+
};
|
|
2283
|
+
export {
|
|
2284
|
+
FillerRowElement,
|
|
2285
|
+
Table,
|
|
2286
|
+
TableCell,
|
|
2287
|
+
TableFilterButton,
|
|
2288
|
+
TableFilters,
|
|
2289
|
+
TableSortButton,
|
|
2290
|
+
TableUncontrolled,
|
|
2291
|
+
TableWithSelection
|
|
2292
|
+
};
|
|
2293
|
+
//# sourceMappingURL=index.mjs.map
|