@sustaina/shared-ui 1.1.5
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/README.md +107 -0
- package/dist/index.css +64 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +457 -0
- package/dist/index.d.ts +457 -0
- package/dist/index.js +4897 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4842 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +123 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,4842 @@
|
|
|
1
|
+
import * as React3 from 'react';
|
|
2
|
+
import React3__default, { createContext, isValidElement, useState, useEffect, useId, useContext, useRef, useCallback, useMemo, createElement } from 'react';
|
|
3
|
+
import { Controller, useFormContext, useForm, FormProvider, get, set, appendErrors, useFormState } from 'react-hook-form';
|
|
4
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
|
+
import clsx3, { clsx } from 'clsx';
|
|
6
|
+
import { twMerge } from 'tailwind-merge';
|
|
7
|
+
import { create } from 'zustand';
|
|
8
|
+
import { reSplitAlphaNumeric, useReactTable, getCoreRowModel, getGroupedRowModel, getExpandedRowModel, getSortedRowModel, getFilteredRowModel, flexRender } from '@tanstack/react-table';
|
|
9
|
+
import { CircleHelp, Triangle, X, Plus, Search, Bug, XIcon, GripVertical, Info, CircleMinus, CalendarIcon, Minus, ChevronDownIcon, CheckIcon, ChevronLeft, ChevronRight, Tag, ChevronUpIcon } from 'lucide-react';
|
|
10
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
11
|
+
import { cva } from 'class-variance-authority';
|
|
12
|
+
import * as LabelPrimitive2 from '@radix-ui/react-label';
|
|
13
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
14
|
+
import { SortableContext, verticalListSortingStrategy, arrayMove, useSortable } from '@dnd-kit/sortable';
|
|
15
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
16
|
+
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
17
|
+
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
18
|
+
import { useSensors, useSensor, PointerSensor, DndContext, closestCenter } from '@dnd-kit/core';
|
|
19
|
+
import { z } from 'zod';
|
|
20
|
+
import { createPortal } from 'react-dom';
|
|
21
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
22
|
+
|
|
23
|
+
// src/components/form/form-controls/use-form-field.ts
|
|
24
|
+
var FormFieldContext = createContext({});
|
|
25
|
+
function FormField(props) {
|
|
26
|
+
return /* @__PURE__ */ jsx(FormFieldContext, { value: { name: props.name }, children: /* @__PURE__ */ jsx(Controller, { ...props }) });
|
|
27
|
+
}
|
|
28
|
+
var FormItemContext = createContext({});
|
|
29
|
+
function FormItem({ children, ...props }) {
|
|
30
|
+
const formItemId = useId();
|
|
31
|
+
return /* @__PURE__ */ jsx(FormItemContext, { value: { id: formItemId }, children: /* @__PURE__ */ jsx("div", { ...props, children }) });
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/components/form/form-controls/use-form-field.ts
|
|
35
|
+
function useFormField(options) {
|
|
36
|
+
const { name: formFieldName } = useContext(FormFieldContext);
|
|
37
|
+
const { id: formItemId } = useContext(FormItemContext);
|
|
38
|
+
const formContext = useFormContext();
|
|
39
|
+
if ((!formFieldName || !formItemId || !formContext) && options?.skipValidationIfNoContext) {
|
|
40
|
+
return {
|
|
41
|
+
prefixId: void 0,
|
|
42
|
+
name: void 0,
|
|
43
|
+
formItemId: void 0,
|
|
44
|
+
formLabelId: void 0,
|
|
45
|
+
formErrorMessageId: void 0,
|
|
46
|
+
isDirty: false,
|
|
47
|
+
invalid: false,
|
|
48
|
+
isTouched: false,
|
|
49
|
+
isValidating: false,
|
|
50
|
+
error: void 0
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (!formFieldName) {
|
|
54
|
+
throw new Error(
|
|
55
|
+
"useFormField must be used inside a <FormField> component. Ensure that <FormField> wraps the component using useFormField."
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
if (!formItemId) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
"useFormField must be used inside a <FormItem> component. Ensure that <FormItem> wraps the component using useFormField."
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
if (!formContext) {
|
|
64
|
+
throw new Error("useFormField must be used inside a <Form> component.");
|
|
65
|
+
}
|
|
66
|
+
const fieldState = formContext?.getFieldState?.(formFieldName, formContext?.formState);
|
|
67
|
+
const prefixId = formItemId?.concat(formFieldName);
|
|
68
|
+
return {
|
|
69
|
+
prefixId,
|
|
70
|
+
name: formFieldName,
|
|
71
|
+
formItemId: prefixId ? `${prefixId}-form-item` : void 0,
|
|
72
|
+
formLabelId: prefixId ? `${prefixId}-form-label` : void 0,
|
|
73
|
+
formErrorMessageId: prefixId ? `${prefixId}-form-error-message` : void 0,
|
|
74
|
+
...fieldState
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function cn(...args) {
|
|
78
|
+
return twMerge(clsx(args));
|
|
79
|
+
}
|
|
80
|
+
function FormErrorMessage({ className, errorClassName, ...props }) {
|
|
81
|
+
const { formErrorMessageId, invalid, error } = useFormField();
|
|
82
|
+
if (!invalid) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
return /* @__PURE__ */ jsx(
|
|
86
|
+
"p",
|
|
87
|
+
{
|
|
88
|
+
id: formErrorMessageId,
|
|
89
|
+
className: cn(
|
|
90
|
+
"text-sm font-medium text-destructive text-red-600 flex items-center gap-1 mt-2 ml-1",
|
|
91
|
+
className,
|
|
92
|
+
{
|
|
93
|
+
"text-red-600": invalid,
|
|
94
|
+
[errorClassName ?? ""]: invalid
|
|
95
|
+
}
|
|
96
|
+
),
|
|
97
|
+
"aria-invalid": invalid,
|
|
98
|
+
"aria-errormessage": error?.message,
|
|
99
|
+
...props,
|
|
100
|
+
children: error?.message
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
function FormLabel({ children, className, errorClassName, required, ...props }) {
|
|
105
|
+
const { formItemId, formLabelId, invalid } = useFormField();
|
|
106
|
+
return /* @__PURE__ */ jsxs(
|
|
107
|
+
"label",
|
|
108
|
+
{
|
|
109
|
+
id: formLabelId,
|
|
110
|
+
htmlFor: formItemId,
|
|
111
|
+
className: cn("block mb-2", className, {
|
|
112
|
+
"text-destructive text-red-600": invalid,
|
|
113
|
+
[errorClassName ?? ""]: invalid
|
|
114
|
+
}),
|
|
115
|
+
"aria-label": formLabelId,
|
|
116
|
+
"aria-invalid": invalid,
|
|
117
|
+
...props,
|
|
118
|
+
children: [
|
|
119
|
+
children,
|
|
120
|
+
required && /* @__PURE__ */ jsx("span", { className: "text-red-600 ml-1", children: "*" })
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// src/utils/getColumnIdFromTable.ts
|
|
127
|
+
function getColumnIdFromTable(table) {
|
|
128
|
+
const allColumns = table.getAllColumns();
|
|
129
|
+
const availableColumns = allColumns.map((col) => ({ id: col.id }));
|
|
130
|
+
const currentColumns = allColumns.filter((col) => col.getIsVisible()).map((col) => ({ id: col.id }));
|
|
131
|
+
return { availableColumns, currentColumns };
|
|
132
|
+
}
|
|
133
|
+
var useGridSettingsStore = create(
|
|
134
|
+
(set) => ({
|
|
135
|
+
availableColumns: [],
|
|
136
|
+
currentColumns: [],
|
|
137
|
+
payload: {
|
|
138
|
+
ordering: [],
|
|
139
|
+
visibility: {},
|
|
140
|
+
pinning: { left: [] }
|
|
141
|
+
},
|
|
142
|
+
setAvailableColumns: (cols) => set({ availableColumns: cols }),
|
|
143
|
+
setCurrentColumns: (cols) => set({ currentColumns: cols }),
|
|
144
|
+
setPayload: (payload) => set({ payload }),
|
|
145
|
+
reset: () => set({
|
|
146
|
+
availableColumns: [],
|
|
147
|
+
currentColumns: [],
|
|
148
|
+
payload: { ordering: [], visibility: {}, pinning: { left: [] } }
|
|
149
|
+
}),
|
|
150
|
+
extractColumns: (table) => {
|
|
151
|
+
const availableColumns = table.getAllColumns().map((col) => ({ id: col.id }));
|
|
152
|
+
const currentColumns = table.getVisibleLeafColumns().map((col) => ({ id: col.id }));
|
|
153
|
+
return { availableColumns, currentColumns };
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
);
|
|
157
|
+
function TextInput({ className, ...props }) {
|
|
158
|
+
return /* @__PURE__ */ jsx("input", { type: "text", className: cn("input", className), ...props });
|
|
159
|
+
}
|
|
160
|
+
function NumberInput({ className, ...props }) {
|
|
161
|
+
return /* @__PURE__ */ jsx("input", { type: "number", className: cn("input", className), ...props });
|
|
162
|
+
}
|
|
163
|
+
function compareAlphanumeric(aStr, bStr) {
|
|
164
|
+
const a = aStr.split(reSplitAlphaNumeric).filter(Boolean);
|
|
165
|
+
const b = bStr.split(reSplitAlphaNumeric).filter(Boolean);
|
|
166
|
+
while (a.length && b.length) {
|
|
167
|
+
const aa = a.shift();
|
|
168
|
+
const bb = b.shift();
|
|
169
|
+
const an = parseInt(aa, 10);
|
|
170
|
+
const bn = parseInt(bb, 10);
|
|
171
|
+
const combo = [an, bn].sort();
|
|
172
|
+
if (isNaN(combo[0])) {
|
|
173
|
+
if (aa > bb) {
|
|
174
|
+
return 1;
|
|
175
|
+
}
|
|
176
|
+
if (bb > aa) {
|
|
177
|
+
return -1;
|
|
178
|
+
}
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (isNaN(combo[1])) {
|
|
182
|
+
return isNaN(an) ? -1 : 1;
|
|
183
|
+
}
|
|
184
|
+
if (an > bn) {
|
|
185
|
+
return 1;
|
|
186
|
+
}
|
|
187
|
+
if (bn > an) {
|
|
188
|
+
return -1;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return a.length - b.length;
|
|
192
|
+
}
|
|
193
|
+
function cn2(...inputs) {
|
|
194
|
+
return twMerge(clsx(inputs));
|
|
195
|
+
}
|
|
196
|
+
function booleanToSelectValue(value, options) {
|
|
197
|
+
if (value === true) return "true";
|
|
198
|
+
if (value === false) return "false";
|
|
199
|
+
return options?.fallbackUndefinedValue ?? "";
|
|
200
|
+
}
|
|
201
|
+
function selectValueToBoolean(value) {
|
|
202
|
+
if (value === "true") return true;
|
|
203
|
+
if (value === "false") return false;
|
|
204
|
+
return void 0;
|
|
205
|
+
}
|
|
206
|
+
function renderContentSlot(slot, defaultWrapperProps) {
|
|
207
|
+
const { content, wrapperProps = {} } = slot;
|
|
208
|
+
const mergedProps = {
|
|
209
|
+
...defaultWrapperProps,
|
|
210
|
+
...wrapperProps,
|
|
211
|
+
className: cn2(defaultWrapperProps?.className, wrapperProps?.className)
|
|
212
|
+
};
|
|
213
|
+
if (!content) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
return /* @__PURE__ */ jsx("div", { ...mergedProps, children: content });
|
|
217
|
+
}
|
|
218
|
+
var useHover = () => {
|
|
219
|
+
const [hovering, setHovering] = useState(false);
|
|
220
|
+
const prevRef = useRef(null);
|
|
221
|
+
const onMouseEnter = useCallback(() => setHovering(true), []);
|
|
222
|
+
const onMouseLeave = useCallback(() => setHovering(false), []);
|
|
223
|
+
const nodeRefCallback = useCallback(
|
|
224
|
+
(node) => {
|
|
225
|
+
if (prevRef.current) {
|
|
226
|
+
prevRef.current.removeEventListener("mouseenter", onMouseEnter);
|
|
227
|
+
prevRef.current.removeEventListener("mouseleave", onMouseLeave);
|
|
228
|
+
}
|
|
229
|
+
if (node?.nodeType === Node.ELEMENT_NODE) {
|
|
230
|
+
node.addEventListener("mouseenter", onMouseEnter);
|
|
231
|
+
node.addEventListener("mouseleave", onMouseLeave);
|
|
232
|
+
}
|
|
233
|
+
prevRef.current = node;
|
|
234
|
+
},
|
|
235
|
+
[onMouseEnter, onMouseLeave]
|
|
236
|
+
);
|
|
237
|
+
return {
|
|
238
|
+
ref: nodeRefCallback,
|
|
239
|
+
hovering
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
var useHover_default = useHover;
|
|
243
|
+
var useIntersectionObserver = ({
|
|
244
|
+
threshold = 0,
|
|
245
|
+
root = null,
|
|
246
|
+
rootMargin = "0%",
|
|
247
|
+
freezeOnceVisible = false,
|
|
248
|
+
initialIsIntersecting = false,
|
|
249
|
+
onChange
|
|
250
|
+
} = {}) => {
|
|
251
|
+
const [ref, setRef] = useState(null);
|
|
252
|
+
const [state, setState] = useState(() => ({
|
|
253
|
+
isIntersecting: initialIsIntersecting,
|
|
254
|
+
entry: void 0
|
|
255
|
+
}));
|
|
256
|
+
const callbackRef = useRef(null);
|
|
257
|
+
callbackRef.current = onChange;
|
|
258
|
+
const frozen = state.entry?.isIntersecting && freezeOnceVisible;
|
|
259
|
+
useEffect(() => {
|
|
260
|
+
if (!ref) return;
|
|
261
|
+
if (!("IntersectionObserver" in window)) return;
|
|
262
|
+
if (frozen) return;
|
|
263
|
+
const observer = new IntersectionObserver(
|
|
264
|
+
(entries) => {
|
|
265
|
+
const thresholds = Array.isArray(observer.thresholds) ? observer.thresholds : [observer.thresholds];
|
|
266
|
+
entries.forEach((entry) => {
|
|
267
|
+
const isIntersecting = entry.isIntersecting && thresholds.some((threshold2) => entry.intersectionRatio >= threshold2);
|
|
268
|
+
setState({ isIntersecting, entry });
|
|
269
|
+
if (callbackRef.current) {
|
|
270
|
+
callbackRef.current(isIntersecting, entry);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
},
|
|
274
|
+
{ threshold, root, rootMargin }
|
|
275
|
+
);
|
|
276
|
+
observer.observe(ref);
|
|
277
|
+
return () => {
|
|
278
|
+
observer.disconnect();
|
|
279
|
+
};
|
|
280
|
+
}, [
|
|
281
|
+
ref,
|
|
282
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
283
|
+
JSON.stringify(threshold),
|
|
284
|
+
root,
|
|
285
|
+
rootMargin,
|
|
286
|
+
frozen,
|
|
287
|
+
freezeOnceVisible
|
|
288
|
+
]);
|
|
289
|
+
const prevRef = useRef(null);
|
|
290
|
+
useEffect(() => {
|
|
291
|
+
if (!ref && state.entry?.target && !freezeOnceVisible && !frozen && prevRef.current !== state.entry.target) {
|
|
292
|
+
prevRef.current = state.entry.target;
|
|
293
|
+
setState({ isIntersecting: initialIsIntersecting, entry: void 0 });
|
|
294
|
+
}
|
|
295
|
+
}, [ref, state.entry, freezeOnceVisible, frozen, initialIsIntersecting]);
|
|
296
|
+
const result = [setRef, !!state.isIntersecting, state.entry];
|
|
297
|
+
result.ref = result[0];
|
|
298
|
+
result.isIntersecting = result[1];
|
|
299
|
+
result.entry = result[2];
|
|
300
|
+
return result;
|
|
301
|
+
};
|
|
302
|
+
var useIntersectionObserver_default = useIntersectionObserver;
|
|
303
|
+
var isValidMediaQueryString = (query) => {
|
|
304
|
+
return query !== "not all";
|
|
305
|
+
};
|
|
306
|
+
var useMediaQuery = ({ query }) => {
|
|
307
|
+
const [matches, setMatches] = useState(false);
|
|
308
|
+
useEffect(() => {
|
|
309
|
+
if (typeof window === "undefined") {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
const mql = window.matchMedia(query);
|
|
313
|
+
if (!isValidMediaQueryString(mql.media)) {
|
|
314
|
+
throw new Error(`${query}: invalid media query string.`);
|
|
315
|
+
}
|
|
316
|
+
const detectMediaChange = (event) => {
|
|
317
|
+
setMatches(event.matches);
|
|
318
|
+
};
|
|
319
|
+
setMatches(mql.matches);
|
|
320
|
+
mql.addEventListener("change", detectMediaChange);
|
|
321
|
+
return () => {
|
|
322
|
+
mql.removeEventListener("change", detectMediaChange);
|
|
323
|
+
};
|
|
324
|
+
}, [query]);
|
|
325
|
+
return matches;
|
|
326
|
+
};
|
|
327
|
+
var useMediaQuery_default = useMediaQuery;
|
|
328
|
+
|
|
329
|
+
// src/hooks/useScreenSize/useScreenSize.ts
|
|
330
|
+
var useScreenSize = (breakpoints) => {
|
|
331
|
+
const isMobile = useMediaQuery_default({ query: breakpoints?.mobile ?? "(max-width: 767px)" });
|
|
332
|
+
const isTablet = useMediaQuery_default({
|
|
333
|
+
query: breakpoints?.tablet ?? "(min-width: 768px) and (max-width: 1023px)"
|
|
334
|
+
});
|
|
335
|
+
const isDesktop = useMediaQuery_default({ query: breakpoints?.desktop ?? "(min-width: 1024px)" });
|
|
336
|
+
return { isMobile, isTablet, isDesktop };
|
|
337
|
+
};
|
|
338
|
+
var useScreenSize_default = useScreenSize;
|
|
339
|
+
|
|
340
|
+
// src/utils/common.ts
|
|
341
|
+
function isDefined(value) {
|
|
342
|
+
return value !== null && value !== void 0;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// src/utils/filters.ts
|
|
346
|
+
function stripNullishObject(value) {
|
|
347
|
+
if (!isDefined(value)) {
|
|
348
|
+
return {};
|
|
349
|
+
}
|
|
350
|
+
try {
|
|
351
|
+
return Object.fromEntries(Object.entries(value).filter(([, propValue]) => isDefined(propValue)));
|
|
352
|
+
} catch {
|
|
353
|
+
return {};
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
var HeaderCell = ({ rootClassName, labelClassName, context, label, sorterProps }) => {
|
|
357
|
+
const { ref, hovering } = useHover_default();
|
|
358
|
+
const showSorter = sorterProps?.show ?? context.column.getCanSort();
|
|
359
|
+
return /* @__PURE__ */ jsxs(
|
|
360
|
+
"div",
|
|
361
|
+
{
|
|
362
|
+
ref,
|
|
363
|
+
className: cn(
|
|
364
|
+
"flex items-center gap-2",
|
|
365
|
+
{
|
|
366
|
+
"cursor-pointer": context?.column?.getCanSort()
|
|
367
|
+
},
|
|
368
|
+
rootClassName
|
|
369
|
+
),
|
|
370
|
+
...stripNullishObject({
|
|
371
|
+
onClick: (event) => {
|
|
372
|
+
event.preventDefault();
|
|
373
|
+
if (context?.column?.getCanSort()) {
|
|
374
|
+
context?.column?.toggleSorting();
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}),
|
|
378
|
+
children: [
|
|
379
|
+
/* @__PURE__ */ jsx("span", { className: cn("inline-block font-bold", labelClassName), children: label }),
|
|
380
|
+
showSorter && /* @__PURE__ */ jsxs(
|
|
381
|
+
"div",
|
|
382
|
+
{
|
|
383
|
+
className: "flex flex-col",
|
|
384
|
+
title: context.column.getCanSort() ? context.column.getNextSortingOrder() === "asc" ? "Sort ascending" : context.column.getNextSortingOrder() === "desc" ? "Sort descending" : "Clear sort" : void 0,
|
|
385
|
+
children: [
|
|
386
|
+
/* @__PURE__ */ jsx(
|
|
387
|
+
Triangle,
|
|
388
|
+
{
|
|
389
|
+
className: cn("fill-gray-300 stroke-0", {
|
|
390
|
+
"fill-[#41875c]": context?.column?.getIsSorted() === "asc",
|
|
391
|
+
"fill-[#41875c]/45": context?.column?.getNextSortingOrder() === "asc" && hovering
|
|
392
|
+
}),
|
|
393
|
+
size: 12
|
|
394
|
+
}
|
|
395
|
+
),
|
|
396
|
+
/* @__PURE__ */ jsx(
|
|
397
|
+
Triangle,
|
|
398
|
+
{
|
|
399
|
+
className: cn("rotate-180 fill-gray-300 stroke-0", {
|
|
400
|
+
"fill-[#41875c]": context?.column?.getIsSorted() === "desc",
|
|
401
|
+
"fill-[#41875c]/45": context?.column?.getNextSortingOrder() === "desc" && hovering
|
|
402
|
+
}),
|
|
403
|
+
size: 12
|
|
404
|
+
}
|
|
405
|
+
)
|
|
406
|
+
]
|
|
407
|
+
}
|
|
408
|
+
)
|
|
409
|
+
]
|
|
410
|
+
}
|
|
411
|
+
);
|
|
412
|
+
};
|
|
413
|
+
var HeaderCell_default = HeaderCell;
|
|
414
|
+
function TableContainer({ className, children, ...props }) {
|
|
415
|
+
return /* @__PURE__ */ jsx(
|
|
416
|
+
"div",
|
|
417
|
+
{
|
|
418
|
+
"data-slot": "table-container",
|
|
419
|
+
className: cn("relative w-full overflow-x-auto", className),
|
|
420
|
+
...props,
|
|
421
|
+
children
|
|
422
|
+
}
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
function Table({ className, ...props }) {
|
|
426
|
+
return /* @__PURE__ */ jsx(
|
|
427
|
+
"table",
|
|
428
|
+
{
|
|
429
|
+
"data-slot": "table",
|
|
430
|
+
className: cn("w-full caption-bottom text-sm border-separate border-spacing-0", className),
|
|
431
|
+
...props
|
|
432
|
+
}
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
function TableHeader({ className, ...props }) {
|
|
436
|
+
return /* @__PURE__ */ jsx(
|
|
437
|
+
"thead",
|
|
438
|
+
{
|
|
439
|
+
"data-slot": "table-header",
|
|
440
|
+
className: cn("[&_tr]:border-b bg-[#f7f4f4]", className),
|
|
441
|
+
...props
|
|
442
|
+
}
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
function TableBody({ className, ...props }) {
|
|
446
|
+
return /* @__PURE__ */ jsx("tbody", { "data-slot": "table-body", className: cn("[&_tr:last-child]:border-0", className), ...props });
|
|
447
|
+
}
|
|
448
|
+
function TableRow({ className, ...props }) {
|
|
449
|
+
return /* @__PURE__ */ jsx(
|
|
450
|
+
"tr",
|
|
451
|
+
{
|
|
452
|
+
"data-slot": "table-row",
|
|
453
|
+
className: cn("data-[state=selected]:bg-[#dfeae3]", className),
|
|
454
|
+
...props
|
|
455
|
+
}
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
function TableHead({ className, ...props }) {
|
|
459
|
+
return /* @__PURE__ */ jsx(
|
|
460
|
+
"th",
|
|
461
|
+
{
|
|
462
|
+
"data-slot": "table-head",
|
|
463
|
+
className: cn(
|
|
464
|
+
"text-foreground h-9 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px] hover:bg-gray-200 bg-[#f7f4f4] truncate",
|
|
465
|
+
className
|
|
466
|
+
),
|
|
467
|
+
...props
|
|
468
|
+
}
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
function TableCell({ className, ...props }) {
|
|
472
|
+
return /* @__PURE__ */ jsx(
|
|
473
|
+
"td",
|
|
474
|
+
{
|
|
475
|
+
"data-slot": "table-cell",
|
|
476
|
+
className: cn(
|
|
477
|
+
"p-2 h-10 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px] border-b truncate",
|
|
478
|
+
className
|
|
479
|
+
),
|
|
480
|
+
...props
|
|
481
|
+
}
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
var ColumnResizer = ({ header, className, style }) => {
|
|
485
|
+
if (!header.column.getCanResize()) {
|
|
486
|
+
return null;
|
|
487
|
+
}
|
|
488
|
+
const resizeHandler = header.getResizeHandler();
|
|
489
|
+
return /* @__PURE__ */ jsx(
|
|
490
|
+
"div",
|
|
491
|
+
{
|
|
492
|
+
className: cn(
|
|
493
|
+
"absolute top-0 right-0 h-full w-1 select-none touch-none cursor-col-resize hover:bg-[#41875c]/45 active:bg-[#41875c]",
|
|
494
|
+
className
|
|
495
|
+
),
|
|
496
|
+
onDoubleClick: () => header.column.resetSize(),
|
|
497
|
+
onTouchStart: resizeHandler,
|
|
498
|
+
onMouseDown: resizeHandler,
|
|
499
|
+
style
|
|
500
|
+
}
|
|
501
|
+
);
|
|
502
|
+
};
|
|
503
|
+
var ColumnResizer_default = ColumnResizer;
|
|
504
|
+
var stateOptions = [
|
|
505
|
+
"columnFilters",
|
|
506
|
+
"globalFilter",
|
|
507
|
+
"sorting",
|
|
508
|
+
"pagination",
|
|
509
|
+
"columnVisibility",
|
|
510
|
+
"columnOrder",
|
|
511
|
+
"rowSelection",
|
|
512
|
+
"expanded",
|
|
513
|
+
"grouping",
|
|
514
|
+
"columnPinning",
|
|
515
|
+
"columnSizing",
|
|
516
|
+
"columnSizingInfo",
|
|
517
|
+
"rowPinning"
|
|
518
|
+
];
|
|
519
|
+
var modelOptions = [
|
|
520
|
+
"getRowModel",
|
|
521
|
+
"getGroupedRowModel",
|
|
522
|
+
"getPaginationRowModel",
|
|
523
|
+
"getCoreRowModel",
|
|
524
|
+
"getFilteredRowModel",
|
|
525
|
+
"getFilteredSelectedRowModel",
|
|
526
|
+
"getSortedRowModel",
|
|
527
|
+
"getPreExpandedRowModel",
|
|
528
|
+
"getGroupedSelectedRowModel",
|
|
529
|
+
"getPrePaginationRowModel",
|
|
530
|
+
"getPreSelectedRowModel",
|
|
531
|
+
"getPreSortedRowModel",
|
|
532
|
+
"getSelectedRowModel",
|
|
533
|
+
"getExpandedRowModel",
|
|
534
|
+
"getIsAllColumnsVisible",
|
|
535
|
+
"getIsSomeColumnsPinned",
|
|
536
|
+
"getIsSomeColumnsVisible",
|
|
537
|
+
"getHeaderGroups",
|
|
538
|
+
"getFlatHeaders",
|
|
539
|
+
"getLeafHeaders",
|
|
540
|
+
"getLeftFlatHeaders",
|
|
541
|
+
"getCenterLeafHeaders",
|
|
542
|
+
"getRightFlatHeaders",
|
|
543
|
+
"getAllColumns",
|
|
544
|
+
"getAllFlatColumns",
|
|
545
|
+
"getAllLeafColumns",
|
|
546
|
+
"getLeftLeafColumns",
|
|
547
|
+
"getCenterLeafColumns",
|
|
548
|
+
"getRightLeafColumns",
|
|
549
|
+
"getVisibleFlatColumns",
|
|
550
|
+
"getVisibleLeafColumns",
|
|
551
|
+
"getLeftVisibleLeafColumns",
|
|
552
|
+
"getRightVisibleLeafColumns",
|
|
553
|
+
"getCenterVisibleLeafColumns"
|
|
554
|
+
];
|
|
555
|
+
var DataTableDevTool = ({ table }) => {
|
|
556
|
+
const [open, setOpen] = useState(false);
|
|
557
|
+
const [visibleStates, setVisibleStates] = useState([]);
|
|
558
|
+
const [visibleModels, setVisibleModels] = useState([]);
|
|
559
|
+
const tableState = table.getState();
|
|
560
|
+
const toggleValue = (arr, value) => arr.includes(value) ? arr.filter((v) => v !== value) : [...arr, value];
|
|
561
|
+
const getCircularReplacer = () => {
|
|
562
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
563
|
+
return (_key, value) => {
|
|
564
|
+
if (typeof value === "object" && value !== null) {
|
|
565
|
+
if (seen.has(value)) return "[Circular]";
|
|
566
|
+
seen.add(value);
|
|
567
|
+
}
|
|
568
|
+
return value;
|
|
569
|
+
};
|
|
570
|
+
};
|
|
571
|
+
const renderStateValue = (key) => {
|
|
572
|
+
const value = tableState[key];
|
|
573
|
+
if (value == null) return null;
|
|
574
|
+
return /* @__PURE__ */ jsxs("div", { className: "mt-4", children: [
|
|
575
|
+
/* @__PURE__ */ jsx("div", { className: "font-bold capitalize", children: key }),
|
|
576
|
+
/* @__PURE__ */ jsx("pre", { className: "bg-gray-100 text-xs p-2 rounded overflow-x-auto whitespace-pre-wrap", children: JSON.stringify(value, null, 2) })
|
|
577
|
+
] }, key);
|
|
578
|
+
};
|
|
579
|
+
const renderModelValue = (key) => {
|
|
580
|
+
let value;
|
|
581
|
+
try {
|
|
582
|
+
value = table[key]();
|
|
583
|
+
} catch {
|
|
584
|
+
value = void 0;
|
|
585
|
+
}
|
|
586
|
+
if (value == null) return null;
|
|
587
|
+
let jsonString = "";
|
|
588
|
+
try {
|
|
589
|
+
jsonString = JSON.stringify(value, getCircularReplacer(), 2);
|
|
590
|
+
} catch {
|
|
591
|
+
jsonString = "[Cannot stringify]";
|
|
592
|
+
}
|
|
593
|
+
return /* @__PURE__ */ jsxs("div", { className: "mt-4", children: [
|
|
594
|
+
/* @__PURE__ */ jsx("div", { className: "font-bold capitalize", children: key }),
|
|
595
|
+
/* @__PURE__ */ jsx("pre", { className: "bg-gray-100 text-xs p-2 rounded overflow-x-auto whitespace-pre-wrap", children: jsonString })
|
|
596
|
+
] }, key);
|
|
597
|
+
};
|
|
598
|
+
if (process.env.NODE_ENV === "production") return null;
|
|
599
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
600
|
+
/* @__PURE__ */ jsx(
|
|
601
|
+
"button",
|
|
602
|
+
{
|
|
603
|
+
onClick: () => setOpen(true),
|
|
604
|
+
className: "fixed bottom-6 right-6 z-50 rounded-full bg-white border shadow p-3",
|
|
605
|
+
"aria-label": "Open debug panel",
|
|
606
|
+
children: /* @__PURE__ */ jsx(Bug, { className: "w-5 h-5" })
|
|
607
|
+
}
|
|
608
|
+
),
|
|
609
|
+
open && /* @__PURE__ */ jsxs("aside", { className: "fixed top-0 right-0 h-full w-[420px] bg-white shadow-lg border-l border-gray-200 z-50 flex flex-col", children: [
|
|
610
|
+
/* @__PURE__ */ jsxs("header", { className: "flex items-center justify-between p-4 border-b border-gray-200", children: [
|
|
611
|
+
/* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold", children: "Debug Table State & Models" }),
|
|
612
|
+
/* @__PURE__ */ jsx("button", { onClick: () => setOpen(false), className: "text-xl font-bold", "aria-label": "Close", children: "\xD7" })
|
|
613
|
+
] }),
|
|
614
|
+
/* @__PURE__ */ jsxs("main", { className: "overflow-auto p-4 flex-grow space-y-4", children: [
|
|
615
|
+
/* @__PURE__ */ jsxs("section", { className: "max-h-80 overflow-y-auto overflow-x-hidden", children: [
|
|
616
|
+
/* @__PURE__ */ jsxs("fieldset", { children: [
|
|
617
|
+
/* @__PURE__ */ jsx("legend", { className: "block text-sm font-medium mb-1", children: "Show Table State" }),
|
|
618
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1", children: stateOptions.map((stateKey) => /* @__PURE__ */ jsxs(
|
|
619
|
+
"label",
|
|
620
|
+
{
|
|
621
|
+
className: "flex items-center gap-2 cursor-pointer hover:bg-gray-50 p-1 rounded",
|
|
622
|
+
children: [
|
|
623
|
+
/* @__PURE__ */ jsx(
|
|
624
|
+
"input",
|
|
625
|
+
{
|
|
626
|
+
type: "checkbox",
|
|
627
|
+
className: "accent-blue-500",
|
|
628
|
+
checked: visibleStates.includes(stateKey),
|
|
629
|
+
onChange: () => setVisibleStates(toggleValue(visibleStates, stateKey))
|
|
630
|
+
}
|
|
631
|
+
),
|
|
632
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: stateKey })
|
|
633
|
+
]
|
|
634
|
+
},
|
|
635
|
+
stateKey
|
|
636
|
+
)) })
|
|
637
|
+
] }),
|
|
638
|
+
/* @__PURE__ */ jsxs("fieldset", { children: [
|
|
639
|
+
/* @__PURE__ */ jsx("legend", { className: "block text-sm font-medium mb-1", children: "Show Table Models" }),
|
|
640
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1", children: modelOptions.map((modelKey) => /* @__PURE__ */ jsxs(
|
|
641
|
+
"label",
|
|
642
|
+
{
|
|
643
|
+
className: "flex items-center gap-2 cursor-pointer hover:bg-gray-50 p-1 rounded",
|
|
644
|
+
children: [
|
|
645
|
+
/* @__PURE__ */ jsx(
|
|
646
|
+
"input",
|
|
647
|
+
{
|
|
648
|
+
type: "checkbox",
|
|
649
|
+
className: "accent-green-500",
|
|
650
|
+
checked: visibleModels.includes(modelKey),
|
|
651
|
+
onChange: () => setVisibleModels(toggleValue(visibleModels, modelKey))
|
|
652
|
+
}
|
|
653
|
+
),
|
|
654
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: modelKey })
|
|
655
|
+
]
|
|
656
|
+
},
|
|
657
|
+
modelKey
|
|
658
|
+
)) })
|
|
659
|
+
] })
|
|
660
|
+
] }),
|
|
661
|
+
/* @__PURE__ */ jsx("hr", { className: "my-2 border-gray-300" }),
|
|
662
|
+
visibleStates.map(renderStateValue),
|
|
663
|
+
visibleModels.map(renderModelValue)
|
|
664
|
+
] })
|
|
665
|
+
] })
|
|
666
|
+
] });
|
|
667
|
+
};
|
|
668
|
+
var DataTableDevTool_default = DataTableDevTool;
|
|
669
|
+
|
|
670
|
+
// src/components/data-table/helpers.ts
|
|
671
|
+
function getColumnPinningStyles(column) {
|
|
672
|
+
const isPinned = column.getIsPinned();
|
|
673
|
+
const isLastLeftPinnedColumn = isPinned === "left" && column.getIsLastColumn("left");
|
|
674
|
+
const isFirstRightPinnedColumn = isPinned === "right" && column.getIsFirstColumn("right");
|
|
675
|
+
const classes = cn(
|
|
676
|
+
isPinned ? "sticky" : "relative",
|
|
677
|
+
isPinned ? "z-[1]" : "z-0",
|
|
678
|
+
isLastLeftPinnedColumn && "shadow-[inset_-1px_0_0_0_black]",
|
|
679
|
+
isFirstRightPinnedColumn && "shadow-[inset_1px_0_0_0_black]"
|
|
680
|
+
);
|
|
681
|
+
const style = {
|
|
682
|
+
left: isPinned === "left" ? column.getStart("left") : void 0,
|
|
683
|
+
right: isPinned === "right" ? column.getAfter("right") : void 0
|
|
684
|
+
};
|
|
685
|
+
return { classes, style };
|
|
686
|
+
}
|
|
687
|
+
var fallbackData = [];
|
|
688
|
+
var DataTable = ({
|
|
689
|
+
tableRef,
|
|
690
|
+
isInitialLoading,
|
|
691
|
+
columns,
|
|
692
|
+
data,
|
|
693
|
+
filters,
|
|
694
|
+
sorting,
|
|
695
|
+
columnOrder,
|
|
696
|
+
columnVisibility,
|
|
697
|
+
columnPinning,
|
|
698
|
+
columnGrouping,
|
|
699
|
+
columnResizing,
|
|
700
|
+
rowSelection,
|
|
701
|
+
rowExpansion,
|
|
702
|
+
scrollFetch,
|
|
703
|
+
statusContent,
|
|
704
|
+
rowIdKey,
|
|
705
|
+
childrenKey,
|
|
706
|
+
onRowClick,
|
|
707
|
+
debug,
|
|
708
|
+
components
|
|
709
|
+
}) => {
|
|
710
|
+
const table = useReactTable({
|
|
711
|
+
// required properties
|
|
712
|
+
columns,
|
|
713
|
+
data: data || fallbackData,
|
|
714
|
+
getCoreRowModel: getCoreRowModel(),
|
|
715
|
+
// optional properties
|
|
716
|
+
...stripNullishObject({
|
|
717
|
+
// state for filters, sorting, pinning, row selection, etc.
|
|
718
|
+
initialState: stripNullishObject({
|
|
719
|
+
columnFilters: filters?.enabled && (filters?.column?.enabled ?? true) ? filters?.column?.initialState : void 0,
|
|
720
|
+
globalFilter: filters?.enabled ? filters?.global?.initialState : void 0,
|
|
721
|
+
sorting: sorting?.enabled ? sorting?.initialState : void 0,
|
|
722
|
+
columnOrder: columnOrder?.enabled ? columnOrder?.initialState : void 0,
|
|
723
|
+
columnVisibility: columnVisibility?.enabled ? columnVisibility?.initialState : void 0,
|
|
724
|
+
columnPinning: columnPinning?.enabled ? columnPinning?.initialState : void 0,
|
|
725
|
+
rowSelection: rowSelection?.enabled ? rowSelection?.initialState : void 0,
|
|
726
|
+
expanded: rowExpansion?.enabled ? rowExpansion?.initialState : void 0,
|
|
727
|
+
grouping: columnGrouping?.enabled ? columnGrouping?.initialState : void 0
|
|
728
|
+
}),
|
|
729
|
+
state: stripNullishObject({
|
|
730
|
+
columnFilters: filters?.enabled && (filters?.column?.enabled ?? true) ? filters?.column?.state : void 0,
|
|
731
|
+
globalFilter: filters?.enabled ? filters?.global?.state : void 0,
|
|
732
|
+
sorting: sorting?.enabled ? sorting?.state : void 0,
|
|
733
|
+
columnOrder: columnOrder?.enabled ? columnOrder?.state : void 0,
|
|
734
|
+
columnVisibility: columnVisibility?.enabled ? columnVisibility?.state : void 0,
|
|
735
|
+
columnPinning: columnPinning?.enabled ? columnPinning?.state : void 0,
|
|
736
|
+
rowSelection: rowSelection?.enabled ? rowSelection?.state : void 0,
|
|
737
|
+
expanded: rowExpansion?.enabled ? rowExpansion?.state : void 0,
|
|
738
|
+
grouping: columnGrouping?.enabled ? columnGrouping?.state : void 0
|
|
739
|
+
}),
|
|
740
|
+
// common
|
|
741
|
+
getRowId: rowIdKey,
|
|
742
|
+
getSubRows: childrenKey,
|
|
743
|
+
// shared configs filters column and global
|
|
744
|
+
enableFilters: filters?.enabled ?? false,
|
|
745
|
+
filterFromLeafRows: filters?.enabled && (filters?.filterFromLeafRows ?? false),
|
|
746
|
+
manualFiltering: filters?.enabled && (filters?.manual ?? false),
|
|
747
|
+
maxLeafRowFilterDepth: filters?.enabled ? filters?.maxDepth : void 0,
|
|
748
|
+
// column filters
|
|
749
|
+
getFilteredRowModel: !filters?.manual && filters?.enabled ? getFilteredRowModel() : void 0,
|
|
750
|
+
enableColumnFilters: filters?.enabled && (filters?.column?.enabled ?? true),
|
|
751
|
+
onColumnFiltersChange: filters?.enabled && (filters?.column?.enabled ?? true) ? filters?.column?.onFilterChange : void 0,
|
|
752
|
+
// global filters
|
|
753
|
+
enableGlobalFilter: filters?.enabled && (filters?.global?.enabled ?? true),
|
|
754
|
+
globalFilterFn: filters?.enabled && (filters?.global?.enabled ?? true) ? filters?.global?.filterFn : void 0,
|
|
755
|
+
onGlobalFilterChange: filters?.enabled && (filters?.global?.enabled ?? true) ? filters?.global?.onFilterChange : void 0,
|
|
756
|
+
getColumnCanGlobalFilter: filters?.enabled && (filters?.global?.enabled ?? true) ? filters?.global?.canColumnFilterable ?? (() => true) : void 0,
|
|
757
|
+
// sorting
|
|
758
|
+
getSortedRowModel: !sorting?.manual && sorting?.enabled ? getSortedRowModel() : void 0,
|
|
759
|
+
manualSorting: sorting?.enabled && (sorting?.manual ?? false),
|
|
760
|
+
enableSorting: sorting?.enabled ?? false,
|
|
761
|
+
// default behavior: column with type number is sort by desc and string sort by asc first, we fix force always asc
|
|
762
|
+
sortDescFirst: sorting?.enabled ? sorting?.sortDescFirst ?? false : false,
|
|
763
|
+
onSortingChange: sorting?.enabled ? sorting?.onSortingChange : void 0,
|
|
764
|
+
// ordering
|
|
765
|
+
onColumnOrderChange: columnOrder?.enabled ? columnOrder?.onOrderChange : void 0,
|
|
766
|
+
// visibility
|
|
767
|
+
onColumnVisibilityChange: columnVisibility?.enabled ? columnVisibility?.onVisibilityChange : void 0,
|
|
768
|
+
// pinning
|
|
769
|
+
enableColumnPinning: columnPinning?.enabled ?? false,
|
|
770
|
+
onColumnPinningChange: columnPinning?.enabled ? columnPinning?.onPinningChange : void 0,
|
|
771
|
+
// row selection
|
|
772
|
+
enableRowSelection: rowSelection?.enabled ? rowSelection?.canRowSelectable : false,
|
|
773
|
+
enableMultiRowSelection: rowSelection?.enabled ? rowSelection?.multiSelect ?? true : true,
|
|
774
|
+
onRowSelectionChange: rowSelection?.enabled ? rowSelection?.onSelectionChange : void 0,
|
|
775
|
+
// row expanded
|
|
776
|
+
getExpandedRowModel: (
|
|
777
|
+
// when grouping is use then we should open this
|
|
778
|
+
!rowExpansion?.manual && rowExpansion?.enabled ? getExpandedRowModel() : void 0
|
|
779
|
+
),
|
|
780
|
+
manualExpanding: rowExpansion?.enabled && (rowExpansion?.manual ?? false),
|
|
781
|
+
enableExpanding: rowExpansion?.enabled ?? false,
|
|
782
|
+
getIsRowExpanded: rowExpansion?.enabled ? rowExpansion?.isRowExpanded : void 0,
|
|
783
|
+
getRowCanExpand: rowExpansion?.enabled ? rowExpansion?.canRowExpand : void 0,
|
|
784
|
+
onExpandedChange: rowExpansion?.enabled ? rowExpansion?.onExpandedChange : void 0,
|
|
785
|
+
// grouping
|
|
786
|
+
getGroupedRowModel: !columnGrouping?.manual && columnGrouping?.enabled ? getGroupedRowModel() : void 0,
|
|
787
|
+
enableGrouping: columnGrouping?.enabled ?? false,
|
|
788
|
+
manualGrouping: columnGrouping?.enabled && (columnGrouping?.manual ?? false),
|
|
789
|
+
groupedColumnMode: columnGrouping?.enabled ? columnGrouping?.groupedMode ?? false : false,
|
|
790
|
+
aggregationFns: columnGrouping?.enabled ? columnGrouping?.customAggregationFns : void 0,
|
|
791
|
+
onGroupingChange: columnGrouping?.enabled ? columnGrouping?.onGroupingChange : void 0,
|
|
792
|
+
// column sizing
|
|
793
|
+
enableColumnResizing: columnResizing?.enabled ?? false,
|
|
794
|
+
columnResizeMode: columnResizing?.enabled ? columnResizing?.resizeMode ?? "onChange" : "onChange"
|
|
795
|
+
})
|
|
796
|
+
});
|
|
797
|
+
if (isDefined(tableRef) && !isDefined(tableRef?.current)) {
|
|
798
|
+
tableRef.current = table;
|
|
799
|
+
}
|
|
800
|
+
const tableContainerRef = useRef(null);
|
|
801
|
+
const isTableEmpty = table.getCoreRowModel().rows.length === 0;
|
|
802
|
+
const isTableEmptyAfterFiltering = table.getRowModel().rows.length === 0;
|
|
803
|
+
const isFiltering = table.getState().columnFilters.length > 0 || !!table.getState().globalFilter;
|
|
804
|
+
const leftVisibleLeftColumns = table.getLeftVisibleLeafColumns();
|
|
805
|
+
const centerVisibleLeafColumns = table.getCenterVisibleLeafColumns();
|
|
806
|
+
const rightVisibleLeafColumns = table.getRightVisibleLeafColumns();
|
|
807
|
+
const { isSomeColumnsFilterable, filterableColumns } = useMemo(() => {
|
|
808
|
+
const mergedColumns = [
|
|
809
|
+
...leftVisibleLeftColumns,
|
|
810
|
+
...centerVisibleLeafColumns,
|
|
811
|
+
...rightVisibleLeafColumns
|
|
812
|
+
];
|
|
813
|
+
const isSomeColumnsFilterable2 = mergedColumns.some(
|
|
814
|
+
(column) => column.getCanFilter() && column.columnDef.meta?.renderColumnFilter
|
|
815
|
+
);
|
|
816
|
+
return { isSomeColumnsFilterable: isSomeColumnsFilterable2, filterableColumns: mergedColumns };
|
|
817
|
+
}, [centerVisibleLeafColumns, leftVisibleLeftColumns, rightVisibleLeafColumns]);
|
|
818
|
+
const fetchMoreOnScrollReached = useCallback(
|
|
819
|
+
(containerRefElement) => {
|
|
820
|
+
if (!scrollFetch?.enabled) {
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
if (containerRefElement) {
|
|
824
|
+
const { scrollHeight, scrollTop, clientHeight } = containerRefElement;
|
|
825
|
+
const threshold = 1.5;
|
|
826
|
+
if (scrollHeight - scrollTop - clientHeight < clientHeight * threshold && !scrollFetch?.isFetchingMore && scrollFetch?.hasMore && scrollFetch?.fetchMore) {
|
|
827
|
+
scrollFetch.fetchMore();
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
},
|
|
831
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
832
|
+
[scrollFetch?.enabled, scrollFetch?.isFetchingMore, scrollFetch?.hasMore, scrollFetch?.fetchMore]
|
|
833
|
+
);
|
|
834
|
+
useEffect(() => {
|
|
835
|
+
fetchMoreOnScrollReached(tableContainerRef.current);
|
|
836
|
+
}, [fetchMoreOnScrollReached]);
|
|
837
|
+
return /* @__PURE__ */ jsxs(
|
|
838
|
+
TableContainer,
|
|
839
|
+
{
|
|
840
|
+
ref: tableContainerRef,
|
|
841
|
+
...components?.containerProps,
|
|
842
|
+
className: cn(
|
|
843
|
+
"relative w-full overflow-auto h-full max-h-dvh max-w-full bg-white",
|
|
844
|
+
components?.containerProps?.className
|
|
845
|
+
),
|
|
846
|
+
onScroll: (e2) => fetchMoreOnScrollReached(e2.currentTarget),
|
|
847
|
+
children: [
|
|
848
|
+
isInitialLoading ? /* @__PURE__ */ jsx(Fragment, { children: renderContentSlot(statusContent?.initialLoading || { content: "Loading..." }, {
|
|
849
|
+
className: "flex flex-col h-full items-center justify-center text-sm py-4"
|
|
850
|
+
}) }) : isTableEmpty ? /* @__PURE__ */ jsx(Fragment, { children: renderContentSlot(statusContent?.emptyData || { content: "There's nothing here yet." }, {
|
|
851
|
+
className: "flex flex-col h-full items-center justify-center text-sm py-4"
|
|
852
|
+
}) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
853
|
+
/* @__PURE__ */ jsxs(Table, { ...components?.tableProps, children: [
|
|
854
|
+
/* @__PURE__ */ jsxs(
|
|
855
|
+
TableHeader,
|
|
856
|
+
{
|
|
857
|
+
className: cn("sticky top-0 z-10", components?.tableHeaderProps?.className),
|
|
858
|
+
...components?.tableHeaderProps,
|
|
859
|
+
children: [
|
|
860
|
+
table.getHeaderGroups().map((headerGroup) => {
|
|
861
|
+
return /* @__PURE__ */ jsx(TableRow, { children: headerGroup.headers.map((header) => {
|
|
862
|
+
const { classes, style } = getColumnPinningStyles(header.column);
|
|
863
|
+
const useColumnSizing = header.column.columnDef?.meta?.useColumnSizing ?? columnResizing?.enabled ?? false;
|
|
864
|
+
return /* @__PURE__ */ jsxs(
|
|
865
|
+
TableHead,
|
|
866
|
+
{
|
|
867
|
+
colSpan: header.colSpan,
|
|
868
|
+
...header.column.columnDef?.meta?.headerProps,
|
|
869
|
+
className: cn(classes, header.column.columnDef?.meta?.headerProps?.className),
|
|
870
|
+
style: {
|
|
871
|
+
...style,
|
|
872
|
+
width: useColumnSizing ? header.column.getSize() : void 0,
|
|
873
|
+
minWidth: useColumnSizing ? header.column.columnDef.minSize : void 0,
|
|
874
|
+
maxWidth: useColumnSizing ? header.column.columnDef.maxSize : void 0,
|
|
875
|
+
...header.column.columnDef?.meta?.headerProps?.style
|
|
876
|
+
},
|
|
877
|
+
children: [
|
|
878
|
+
header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()),
|
|
879
|
+
/* @__PURE__ */ jsx(ColumnResizer_default, { header, ...components?.columnResizerProps })
|
|
880
|
+
]
|
|
881
|
+
},
|
|
882
|
+
header.id
|
|
883
|
+
);
|
|
884
|
+
}) }, headerGroup.id);
|
|
885
|
+
}),
|
|
886
|
+
isSomeColumnsFilterable && /* @__PURE__ */ jsx(TableRow, { children: filterableColumns.map((column) => {
|
|
887
|
+
const { classes, style } = getColumnPinningStyles(column);
|
|
888
|
+
const useColumnSizing = column.columnDef.meta?.useColumnSizing ?? columnResizing?.enabled ?? false;
|
|
889
|
+
return /* @__PURE__ */ jsx(
|
|
890
|
+
TableCell,
|
|
891
|
+
{
|
|
892
|
+
...column.columnDef?.meta?.cellProps,
|
|
893
|
+
className: cn(
|
|
894
|
+
"bg-white border-b",
|
|
895
|
+
classes,
|
|
896
|
+
column.columnDef?.meta?.cellProps?.className
|
|
897
|
+
),
|
|
898
|
+
style: {
|
|
899
|
+
// TODO: should we separate styles for filter or use same columns styles
|
|
900
|
+
...style,
|
|
901
|
+
width: useColumnSizing ? column.getSize() : void 0,
|
|
902
|
+
minWidth: useColumnSizing ? column.columnDef.minSize : void 0,
|
|
903
|
+
maxWidth: useColumnSizing ? column.columnDef.maxSize : void 0,
|
|
904
|
+
...column.columnDef?.meta?.cellProps?.style
|
|
905
|
+
},
|
|
906
|
+
children: column.getCanFilter() && column.columnDef.meta?.renderColumnFilter?.({
|
|
907
|
+
column,
|
|
908
|
+
table
|
|
909
|
+
})
|
|
910
|
+
},
|
|
911
|
+
column.id
|
|
912
|
+
);
|
|
913
|
+
}) })
|
|
914
|
+
]
|
|
915
|
+
}
|
|
916
|
+
),
|
|
917
|
+
/* @__PURE__ */ jsx(TableBody, { ...components?.tableBodyProps, children: table.getRowModel().rows.map((row) => {
|
|
918
|
+
const tableDataRowProps = typeof components?.tableDataRowProps === "function" ? components.tableDataRowProps({ row, table }) || {} : components?.tableDataRowProps || {};
|
|
919
|
+
return /* @__PURE__ */ createElement(
|
|
920
|
+
TableRow,
|
|
921
|
+
{
|
|
922
|
+
...tableDataRowProps,
|
|
923
|
+
key: row.id,
|
|
924
|
+
className: cn("group", tableDataRowProps?.className),
|
|
925
|
+
"data-state": row.getIsSelected() ? "selected" : "non-selected",
|
|
926
|
+
onClick: (event) => {
|
|
927
|
+
if (typeof onRowClick === "function") {
|
|
928
|
+
onRowClick(row.original, { event, row, table });
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
},
|
|
932
|
+
row.getVisibleCells().map((cell) => {
|
|
933
|
+
const { classes, style } = getColumnPinningStyles(cell.column);
|
|
934
|
+
const useColumnSizing = cell.column.columnDef.meta?.useColumnSizing ?? columnResizing?.enabled ?? false;
|
|
935
|
+
return /* @__PURE__ */ jsx(
|
|
936
|
+
TableCell,
|
|
937
|
+
{
|
|
938
|
+
...cell.column.columnDef?.meta?.cellProps,
|
|
939
|
+
className: cn(
|
|
940
|
+
{
|
|
941
|
+
"bg-[#dfeae3]": row.getIsSelected(),
|
|
942
|
+
"bg-white group-hover:bg-[#eff5f1]": !row.getIsSelected()
|
|
943
|
+
},
|
|
944
|
+
classes,
|
|
945
|
+
cell.column.columnDef?.meta?.cellProps?.className
|
|
946
|
+
),
|
|
947
|
+
style: {
|
|
948
|
+
...style,
|
|
949
|
+
width: useColumnSizing ? cell.column.getSize() : void 0,
|
|
950
|
+
minWidth: useColumnSizing ? cell.column.columnDef.minSize : void 0,
|
|
951
|
+
maxWidth: useColumnSizing ? cell.column.columnDef.maxSize : void 0,
|
|
952
|
+
...cell.column.columnDef?.meta?.cellProps?.style
|
|
953
|
+
},
|
|
954
|
+
children: flexRender(cell.column.columnDef.cell, cell.getContext())
|
|
955
|
+
},
|
|
956
|
+
cell.id
|
|
957
|
+
);
|
|
958
|
+
})
|
|
959
|
+
);
|
|
960
|
+
}) })
|
|
961
|
+
] }),
|
|
962
|
+
isTableEmptyAfterFiltering && /* @__PURE__ */ jsx(Fragment, { children: renderContentSlot(
|
|
963
|
+
statusContent?.emptyFilteredData || {
|
|
964
|
+
content: "No records found. Please try a different search."
|
|
965
|
+
},
|
|
966
|
+
{
|
|
967
|
+
className: "flex flex-col h-[calc(100%-76px)] items-center justify-center text-sm py-4"
|
|
968
|
+
}
|
|
969
|
+
) }),
|
|
970
|
+
scrollFetch?.enabled && !isFiltering && !isInitialLoading && scrollFetch?.isFetchingMore && /* @__PURE__ */ jsx(Fragment, { children: renderContentSlot(statusContent?.fetchingMore || { content: "Loading more..." }, {
|
|
971
|
+
className: "flex items-center justify-center text-sm py-4"
|
|
972
|
+
}) }),
|
|
973
|
+
scrollFetch?.enabled && !isFiltering && !isInitialLoading && !scrollFetch?.hasMore && !scrollFetch?.isFetchingMore && /* @__PURE__ */ jsx(Fragment, { children: renderContentSlot(statusContent?.noMoreData || { content: null }, {
|
|
974
|
+
className: "flex items-center justify-center text-sm py-4"
|
|
975
|
+
}) })
|
|
976
|
+
] }),
|
|
977
|
+
debug && /* @__PURE__ */ jsx(DataTableDevTool_default, { table })
|
|
978
|
+
]
|
|
979
|
+
}
|
|
980
|
+
);
|
|
981
|
+
};
|
|
982
|
+
var DataTable_default = DataTable;
|
|
983
|
+
var buttonVariants = cva(
|
|
984
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive cursor-pointer",
|
|
985
|
+
{
|
|
986
|
+
variants: {
|
|
987
|
+
variant: {
|
|
988
|
+
default: "bg-sus-primary-1 text-primary-foreground shadow-xs hover:bg-sus-primary/90",
|
|
989
|
+
destructive: "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
990
|
+
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
991
|
+
secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
|
992
|
+
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
993
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
994
|
+
cancel: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
995
|
+
defaultSelect: "bg-primary text-primary-foreground shadow-xs hover:bg-sus-primary/90 py-2",
|
|
996
|
+
defaultOutline: "border bg-background py-2 shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50"
|
|
997
|
+
},
|
|
998
|
+
size: {
|
|
999
|
+
default: "h-9 px-4 has-[>svg]:px-3",
|
|
1000
|
+
option: "py-5 h-9 px-4 has-[>svg]:px-3",
|
|
1001
|
+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
1002
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
1003
|
+
icon: "size-9",
|
|
1004
|
+
"icon-xs": "size-5",
|
|
1005
|
+
"icon-sm": "size-[22px]",
|
|
1006
|
+
"icon-md": "size-7",
|
|
1007
|
+
"icon-lg": "size-10"
|
|
1008
|
+
},
|
|
1009
|
+
active: {
|
|
1010
|
+
true: "bg-sus-primary-1 text-white",
|
|
1011
|
+
false: ""
|
|
1012
|
+
}
|
|
1013
|
+
},
|
|
1014
|
+
defaultVariants: {
|
|
1015
|
+
variant: "default",
|
|
1016
|
+
size: "default"
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
);
|
|
1020
|
+
function Button({
|
|
1021
|
+
className,
|
|
1022
|
+
variant,
|
|
1023
|
+
size,
|
|
1024
|
+
active,
|
|
1025
|
+
asChild = false,
|
|
1026
|
+
...props
|
|
1027
|
+
}) {
|
|
1028
|
+
const Comp = asChild ? Slot : "button";
|
|
1029
|
+
return /* @__PURE__ */ jsx(
|
|
1030
|
+
Comp,
|
|
1031
|
+
{
|
|
1032
|
+
"data-slot": "button",
|
|
1033
|
+
className: cn(buttonVariants({ variant, size, className, active })),
|
|
1034
|
+
...props
|
|
1035
|
+
}
|
|
1036
|
+
);
|
|
1037
|
+
}
|
|
1038
|
+
var s = (e2, s2, o3) => {
|
|
1039
|
+
if (e2 && "reportValidity" in e2) {
|
|
1040
|
+
const r2 = get(o3, s2);
|
|
1041
|
+
e2.setCustomValidity(r2 && r2.message || ""), e2.reportValidity();
|
|
1042
|
+
}
|
|
1043
|
+
};
|
|
1044
|
+
var o = (t3, e2) => {
|
|
1045
|
+
for (const o3 in e2.fields) {
|
|
1046
|
+
const r2 = e2.fields[o3];
|
|
1047
|
+
r2 && r2.ref && "reportValidity" in r2.ref ? s(r2.ref, o3, t3) : r2.refs && r2.refs.forEach((e3) => s(e3, o3, t3));
|
|
1048
|
+
}
|
|
1049
|
+
};
|
|
1050
|
+
var r = (s2, r2) => {
|
|
1051
|
+
r2.shouldUseNativeValidation && o(s2, r2);
|
|
1052
|
+
const f = {};
|
|
1053
|
+
for (const o3 in s2) {
|
|
1054
|
+
const n2 = get(r2.fields, o3), a = Object.assign(s2[o3] || {}, { ref: n2 && n2.ref });
|
|
1055
|
+
if (i(r2.names || Object.keys(s2), o3)) {
|
|
1056
|
+
const s3 = Object.assign({}, get(f, o3));
|
|
1057
|
+
set(s3, "root", a), set(f, o3, s3);
|
|
1058
|
+
} else set(f, o3, a);
|
|
1059
|
+
}
|
|
1060
|
+
return f;
|
|
1061
|
+
};
|
|
1062
|
+
var i = (t3, e2) => t3.some((t4) => t4.startsWith(e2 + "."));
|
|
1063
|
+
var n = function(r2, e2) {
|
|
1064
|
+
for (var n2 = {}; r2.length; ) {
|
|
1065
|
+
var t3 = r2[0], s2 = t3.code, i2 = t3.message, a = t3.path.join(".");
|
|
1066
|
+
if (!n2[a]) if ("unionErrors" in t3) {
|
|
1067
|
+
var u = t3.unionErrors[0].errors[0];
|
|
1068
|
+
n2[a] = { message: u.message, type: u.code };
|
|
1069
|
+
} else n2[a] = { message: i2, type: s2 };
|
|
1070
|
+
if ("unionErrors" in t3 && t3.unionErrors.forEach(function(e3) {
|
|
1071
|
+
return e3.errors.forEach(function(e4) {
|
|
1072
|
+
return r2.push(e4);
|
|
1073
|
+
});
|
|
1074
|
+
}), e2) {
|
|
1075
|
+
var c = n2[a].types, f = c && c[t3.code];
|
|
1076
|
+
n2[a] = appendErrors(a, e2, n2, s2, f ? [].concat(f, t3.message) : t3.message);
|
|
1077
|
+
}
|
|
1078
|
+
r2.shift();
|
|
1079
|
+
}
|
|
1080
|
+
return n2;
|
|
1081
|
+
};
|
|
1082
|
+
var t2 = function(o3, t3, s2) {
|
|
1083
|
+
return void 0 === s2 && (s2 = {}), function(i2, a, u) {
|
|
1084
|
+
try {
|
|
1085
|
+
return Promise.resolve(function(e2, n2) {
|
|
1086
|
+
try {
|
|
1087
|
+
var a2 = Promise.resolve(o3["sync" === s2.mode ? "parse" : "parseAsync"](i2, t3)).then(function(e3) {
|
|
1088
|
+
return u.shouldUseNativeValidation && o({}, u), { errors: {}, values: s2.raw ? i2 : e3 };
|
|
1089
|
+
});
|
|
1090
|
+
} catch (r2) {
|
|
1091
|
+
return n2(r2);
|
|
1092
|
+
}
|
|
1093
|
+
return a2 && a2.then ? a2.then(void 0, n2) : a2;
|
|
1094
|
+
}(0, function(r2) {
|
|
1095
|
+
if (function(r3) {
|
|
1096
|
+
return Array.isArray(null == r3 ? void 0 : r3.errors);
|
|
1097
|
+
}(r2)) return { values: {}, errors: r(n(r2.errors, !u.shouldUseNativeValidation && "all" === u.criteriaMode), u) };
|
|
1098
|
+
throw r2;
|
|
1099
|
+
}));
|
|
1100
|
+
} catch (r2) {
|
|
1101
|
+
return Promise.reject(r2);
|
|
1102
|
+
}
|
|
1103
|
+
};
|
|
1104
|
+
};
|
|
1105
|
+
var Form = FormProvider;
|
|
1106
|
+
var FormFieldContext2 = React3.createContext({});
|
|
1107
|
+
var FormField2 = ({
|
|
1108
|
+
...props
|
|
1109
|
+
}) => {
|
|
1110
|
+
return /* @__PURE__ */ jsx(FormFieldContext2.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx(Controller, { ...props }) });
|
|
1111
|
+
};
|
|
1112
|
+
var useFormField2 = () => {
|
|
1113
|
+
const fieldContext = React3.useContext(FormFieldContext2);
|
|
1114
|
+
const itemContext = React3.useContext(FormItemContext2);
|
|
1115
|
+
const { getFieldState } = useFormContext();
|
|
1116
|
+
const formState = useFormState({ name: fieldContext.name });
|
|
1117
|
+
const fieldState = getFieldState(fieldContext.name, formState);
|
|
1118
|
+
if (!fieldContext) {
|
|
1119
|
+
throw new Error("useFormField should be used within <FormField>");
|
|
1120
|
+
}
|
|
1121
|
+
const { id } = itemContext;
|
|
1122
|
+
return {
|
|
1123
|
+
id,
|
|
1124
|
+
name: fieldContext.name,
|
|
1125
|
+
formItemId: `${id}-form-item`,
|
|
1126
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
1127
|
+
formMessageId: `${id}-form-item-message`,
|
|
1128
|
+
...fieldState
|
|
1129
|
+
};
|
|
1130
|
+
};
|
|
1131
|
+
var FormItemContext2 = React3.createContext({});
|
|
1132
|
+
function FormItem2({ className, ...props }) {
|
|
1133
|
+
const id = React3.useId();
|
|
1134
|
+
return /* @__PURE__ */ jsx(FormItemContext2.Provider, { value: { id }, children: /* @__PURE__ */ jsx("div", { "data-slot": "form-item", className: cn("grid gap-2", className), ...props }) });
|
|
1135
|
+
}
|
|
1136
|
+
function FormControl({ ...props }) {
|
|
1137
|
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField2();
|
|
1138
|
+
return /* @__PURE__ */ jsx(
|
|
1139
|
+
Slot,
|
|
1140
|
+
{
|
|
1141
|
+
"data-slot": "form-control",
|
|
1142
|
+
id: formItemId,
|
|
1143
|
+
"aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
|
|
1144
|
+
"aria-invalid": !!error,
|
|
1145
|
+
...props
|
|
1146
|
+
}
|
|
1147
|
+
);
|
|
1148
|
+
}
|
|
1149
|
+
function FormMessage({ className, ...props }) {
|
|
1150
|
+
const { error, formMessageId } = useFormField2();
|
|
1151
|
+
const body = error ? String(error?.message ?? "") : props.children;
|
|
1152
|
+
if (!body) {
|
|
1153
|
+
return null;
|
|
1154
|
+
}
|
|
1155
|
+
return /* @__PURE__ */ jsx(
|
|
1156
|
+
"p",
|
|
1157
|
+
{
|
|
1158
|
+
"data-slot": "form-message",
|
|
1159
|
+
id: formMessageId,
|
|
1160
|
+
className: cn("text-destructive text-xs", className),
|
|
1161
|
+
...props,
|
|
1162
|
+
children: body
|
|
1163
|
+
}
|
|
1164
|
+
);
|
|
1165
|
+
}
|
|
1166
|
+
function Dialog({ ...props }) {
|
|
1167
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
|
|
1168
|
+
}
|
|
1169
|
+
function DialogPortal({ ...props }) {
|
|
1170
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
|
|
1171
|
+
}
|
|
1172
|
+
function DialogClose({ ...props }) {
|
|
1173
|
+
return /* @__PURE__ */ jsx(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
|
|
1174
|
+
}
|
|
1175
|
+
function DialogOverlay({ className, ...props }) {
|
|
1176
|
+
return /* @__PURE__ */ jsx(
|
|
1177
|
+
DialogPrimitive.Overlay,
|
|
1178
|
+
{
|
|
1179
|
+
"data-slot": "dialog-overlay",
|
|
1180
|
+
className: cn(
|
|
1181
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
1182
|
+
className
|
|
1183
|
+
),
|
|
1184
|
+
...props
|
|
1185
|
+
}
|
|
1186
|
+
);
|
|
1187
|
+
}
|
|
1188
|
+
function DialogContent({
|
|
1189
|
+
className,
|
|
1190
|
+
children,
|
|
1191
|
+
showCloseButton = true,
|
|
1192
|
+
...props
|
|
1193
|
+
}) {
|
|
1194
|
+
return /* @__PURE__ */ jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [
|
|
1195
|
+
/* @__PURE__ */ jsx(DialogOverlay, {}),
|
|
1196
|
+
/* @__PURE__ */ jsxs(
|
|
1197
|
+
DialogPrimitive.Content,
|
|
1198
|
+
{
|
|
1199
|
+
"data-slot": "dialog-content",
|
|
1200
|
+
className: cn(
|
|
1201
|
+
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",
|
|
1202
|
+
className
|
|
1203
|
+
),
|
|
1204
|
+
...props,
|
|
1205
|
+
children: [
|
|
1206
|
+
children,
|
|
1207
|
+
showCloseButton && /* @__PURE__ */ jsxs(
|
|
1208
|
+
DialogPrimitive.Close,
|
|
1209
|
+
{
|
|
1210
|
+
"data-slot": "dialog-close",
|
|
1211
|
+
className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
1212
|
+
children: [
|
|
1213
|
+
/* @__PURE__ */ jsx(XIcon, {}),
|
|
1214
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
|
|
1215
|
+
]
|
|
1216
|
+
}
|
|
1217
|
+
)
|
|
1218
|
+
]
|
|
1219
|
+
}
|
|
1220
|
+
)
|
|
1221
|
+
] });
|
|
1222
|
+
}
|
|
1223
|
+
function DialogHeader({ className, ...props }) {
|
|
1224
|
+
return /* @__PURE__ */ jsx(
|
|
1225
|
+
"div",
|
|
1226
|
+
{
|
|
1227
|
+
"data-slot": "dialog-header",
|
|
1228
|
+
className: cn("flex flex-col gap-2 text-center sm:text-left", className),
|
|
1229
|
+
...props
|
|
1230
|
+
}
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1233
|
+
function DialogFooter({ className, ...props }) {
|
|
1234
|
+
return /* @__PURE__ */ jsx(
|
|
1235
|
+
"div",
|
|
1236
|
+
{
|
|
1237
|
+
"data-slot": "dialog-footer",
|
|
1238
|
+
className: cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end", className),
|
|
1239
|
+
...props
|
|
1240
|
+
}
|
|
1241
|
+
);
|
|
1242
|
+
}
|
|
1243
|
+
function DialogTitle({ className, ...props }) {
|
|
1244
|
+
return /* @__PURE__ */ jsx(
|
|
1245
|
+
DialogPrimitive.Title,
|
|
1246
|
+
{
|
|
1247
|
+
"data-slot": "dialog-title",
|
|
1248
|
+
className: cn("text-lg leading-none font-semibold", className),
|
|
1249
|
+
...props
|
|
1250
|
+
}
|
|
1251
|
+
);
|
|
1252
|
+
}
|
|
1253
|
+
function DialogDescription({
|
|
1254
|
+
className,
|
|
1255
|
+
...props
|
|
1256
|
+
}) {
|
|
1257
|
+
return /* @__PURE__ */ jsx(
|
|
1258
|
+
DialogPrimitive.Description,
|
|
1259
|
+
{
|
|
1260
|
+
"data-slot": "dialog-description",
|
|
1261
|
+
className: cn("text-muted-foreground text-sm", className),
|
|
1262
|
+
...props
|
|
1263
|
+
}
|
|
1264
|
+
);
|
|
1265
|
+
}
|
|
1266
|
+
function Select({ ...props }) {
|
|
1267
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Root, { "data-slot": "select", ...props });
|
|
1268
|
+
}
|
|
1269
|
+
function SelectValue({ ...props }) {
|
|
1270
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Value, { "data-slot": "select-value", ...props });
|
|
1271
|
+
}
|
|
1272
|
+
function SelectTrigger({
|
|
1273
|
+
className,
|
|
1274
|
+
size = "default",
|
|
1275
|
+
children,
|
|
1276
|
+
...props
|
|
1277
|
+
}) {
|
|
1278
|
+
return /* @__PURE__ */ jsxs(
|
|
1279
|
+
SelectPrimitive.Trigger,
|
|
1280
|
+
{
|
|
1281
|
+
"data-slot": "select-trigger",
|
|
1282
|
+
"data-size": size,
|
|
1283
|
+
className: cn(
|
|
1284
|
+
"border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
1285
|
+
className
|
|
1286
|
+
),
|
|
1287
|
+
...props,
|
|
1288
|
+
children: [
|
|
1289
|
+
children,
|
|
1290
|
+
/* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4 opacity-50" }) })
|
|
1291
|
+
]
|
|
1292
|
+
}
|
|
1293
|
+
);
|
|
1294
|
+
}
|
|
1295
|
+
function SelectContent({
|
|
1296
|
+
className,
|
|
1297
|
+
children,
|
|
1298
|
+
position = "popper",
|
|
1299
|
+
...props
|
|
1300
|
+
}) {
|
|
1301
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
|
|
1302
|
+
SelectPrimitive.Content,
|
|
1303
|
+
{
|
|
1304
|
+
"data-slot": "select-content",
|
|
1305
|
+
className: cn(
|
|
1306
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
|
|
1307
|
+
position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
1308
|
+
className
|
|
1309
|
+
),
|
|
1310
|
+
position,
|
|
1311
|
+
...props,
|
|
1312
|
+
children: [
|
|
1313
|
+
/* @__PURE__ */ jsx(SelectScrollUpButton, {}),
|
|
1314
|
+
/* @__PURE__ */ jsx(
|
|
1315
|
+
SelectPrimitive.Viewport,
|
|
1316
|
+
{
|
|
1317
|
+
className: cn(
|
|
1318
|
+
"p-1",
|
|
1319
|
+
position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
|
|
1320
|
+
),
|
|
1321
|
+
children
|
|
1322
|
+
}
|
|
1323
|
+
),
|
|
1324
|
+
/* @__PURE__ */ jsx(SelectScrollDownButton, {})
|
|
1325
|
+
]
|
|
1326
|
+
}
|
|
1327
|
+
) });
|
|
1328
|
+
}
|
|
1329
|
+
function SelectItem({
|
|
1330
|
+
className,
|
|
1331
|
+
children,
|
|
1332
|
+
...props
|
|
1333
|
+
}) {
|
|
1334
|
+
return /* @__PURE__ */ jsxs(
|
|
1335
|
+
SelectPrimitive.Item,
|
|
1336
|
+
{
|
|
1337
|
+
"data-slot": "select-item",
|
|
1338
|
+
className: cn(
|
|
1339
|
+
"focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
|
1340
|
+
className
|
|
1341
|
+
),
|
|
1342
|
+
...props,
|
|
1343
|
+
children: [
|
|
1344
|
+
/* @__PURE__ */ jsx("span", { className: "absolute right-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4" }) }) }),
|
|
1345
|
+
/* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children })
|
|
1346
|
+
]
|
|
1347
|
+
}
|
|
1348
|
+
);
|
|
1349
|
+
}
|
|
1350
|
+
function SelectScrollUpButton({
|
|
1351
|
+
className,
|
|
1352
|
+
...props
|
|
1353
|
+
}) {
|
|
1354
|
+
return /* @__PURE__ */ jsx(
|
|
1355
|
+
SelectPrimitive.ScrollUpButton,
|
|
1356
|
+
{
|
|
1357
|
+
"data-slot": "select-scroll-up-button",
|
|
1358
|
+
className: cn("flex cursor-default items-center justify-center py-1", className),
|
|
1359
|
+
...props,
|
|
1360
|
+
children: /* @__PURE__ */ jsx(ChevronUpIcon, { className: "size-4" })
|
|
1361
|
+
}
|
|
1362
|
+
);
|
|
1363
|
+
}
|
|
1364
|
+
function SelectScrollDownButton({
|
|
1365
|
+
className,
|
|
1366
|
+
...props
|
|
1367
|
+
}) {
|
|
1368
|
+
return /* @__PURE__ */ jsx(
|
|
1369
|
+
SelectPrimitive.ScrollDownButton,
|
|
1370
|
+
{
|
|
1371
|
+
"data-slot": "select-scroll-down-button",
|
|
1372
|
+
className: cn("flex cursor-default items-center justify-center py-1", className),
|
|
1373
|
+
...props,
|
|
1374
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4" })
|
|
1375
|
+
}
|
|
1376
|
+
);
|
|
1377
|
+
}
|
|
1378
|
+
function TooltipProvider({
|
|
1379
|
+
delayDuration = 0,
|
|
1380
|
+
...props
|
|
1381
|
+
}) {
|
|
1382
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Provider, { "data-slot": "tooltip-provider", delayDuration, ...props });
|
|
1383
|
+
}
|
|
1384
|
+
function Tooltip({ ...props }) {
|
|
1385
|
+
return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props }) });
|
|
1386
|
+
}
|
|
1387
|
+
function TooltipTrigger({ ...props }) {
|
|
1388
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
1389
|
+
}
|
|
1390
|
+
function TooltipContent({
|
|
1391
|
+
className,
|
|
1392
|
+
arrowClassName,
|
|
1393
|
+
sideOffset = 0,
|
|
1394
|
+
children,
|
|
1395
|
+
...props
|
|
1396
|
+
}) {
|
|
1397
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
|
|
1398
|
+
TooltipPrimitive.Content,
|
|
1399
|
+
{
|
|
1400
|
+
"data-slot": "tooltip-content",
|
|
1401
|
+
sideOffset,
|
|
1402
|
+
className: cn(
|
|
1403
|
+
"bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",
|
|
1404
|
+
className
|
|
1405
|
+
),
|
|
1406
|
+
...props,
|
|
1407
|
+
children: [
|
|
1408
|
+
children,
|
|
1409
|
+
/* @__PURE__ */ jsx(
|
|
1410
|
+
TooltipPrimitive.Arrow,
|
|
1411
|
+
{
|
|
1412
|
+
className: cn(
|
|
1413
|
+
"bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]",
|
|
1414
|
+
arrowClassName
|
|
1415
|
+
)
|
|
1416
|
+
}
|
|
1417
|
+
)
|
|
1418
|
+
]
|
|
1419
|
+
}
|
|
1420
|
+
) });
|
|
1421
|
+
}
|
|
1422
|
+
function SortableRow({
|
|
1423
|
+
itemId,
|
|
1424
|
+
index,
|
|
1425
|
+
control,
|
|
1426
|
+
availableColumns,
|
|
1427
|
+
currentColumns,
|
|
1428
|
+
disableDrag = false,
|
|
1429
|
+
disableEdit = false,
|
|
1430
|
+
hideFormMessage,
|
|
1431
|
+
removeColumn
|
|
1432
|
+
}) {
|
|
1433
|
+
const { attributes, listeners, setNodeRef, transform, transition } = useSortable({
|
|
1434
|
+
id: itemId,
|
|
1435
|
+
disabled: disableDrag
|
|
1436
|
+
});
|
|
1437
|
+
const style = {
|
|
1438
|
+
transform: CSS.Transform.toString(transform),
|
|
1439
|
+
transition
|
|
1440
|
+
};
|
|
1441
|
+
const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
1442
|
+
const options = availableColumns.map((col) => ({
|
|
1443
|
+
id: col.id,
|
|
1444
|
+
label: capitalize(col.id)
|
|
1445
|
+
}));
|
|
1446
|
+
return /* @__PURE__ */ jsx("div", { ref: setNodeRef, style, className: "flex items-center rounded-md bg-white", children: /* @__PURE__ */ jsx(
|
|
1447
|
+
FormField2,
|
|
1448
|
+
{
|
|
1449
|
+
control,
|
|
1450
|
+
name: `columns.${index}.id`,
|
|
1451
|
+
render: ({ field }) => /* @__PURE__ */ jsxs(FormItem2, { className: "flex-1", children: [
|
|
1452
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
1453
|
+
/* @__PURE__ */ jsx(
|
|
1454
|
+
GripVertical,
|
|
1455
|
+
{
|
|
1456
|
+
className: cn(
|
|
1457
|
+
"h-5 w-5 text-[#B9B9B9] focus:outline-none cursor-grab",
|
|
1458
|
+
index == 0 && "opacity-0 pointer-events-none"
|
|
1459
|
+
),
|
|
1460
|
+
...attributes,
|
|
1461
|
+
...listeners
|
|
1462
|
+
}
|
|
1463
|
+
),
|
|
1464
|
+
/* @__PURE__ */ jsxs(
|
|
1465
|
+
Select,
|
|
1466
|
+
{
|
|
1467
|
+
value: field.value,
|
|
1468
|
+
onValueChange: (val) => {
|
|
1469
|
+
field.onChange(val);
|
|
1470
|
+
},
|
|
1471
|
+
disabled: disableEdit || index == 0,
|
|
1472
|
+
children: [
|
|
1473
|
+
/* @__PURE__ */ jsx(FormControl, { children: /* @__PURE__ */ jsx(
|
|
1474
|
+
SelectTrigger,
|
|
1475
|
+
{
|
|
1476
|
+
className: cn(
|
|
1477
|
+
"w-full border-[#DDDDDD] data-[disabled]:opacity-100 aria-invalid:border-[#BB0B0E]",
|
|
1478
|
+
index == 0 ? "text-[#8B8B8B] bg-[#EAEAEA] cursor-not-allowed" : ""
|
|
1479
|
+
),
|
|
1480
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Choose column..." })
|
|
1481
|
+
}
|
|
1482
|
+
) }),
|
|
1483
|
+
/* @__PURE__ */ jsx(SelectContent, { children: options.filter((i2) => i2.id === field.value || !currentColumns?.some((c) => c.id === i2.id)).sort(
|
|
1484
|
+
(a, b) => a.id === field.value ? -1 : b.id === field.value ? 1 : 0
|
|
1485
|
+
).map((opt) => /* @__PURE__ */ jsx(
|
|
1486
|
+
SelectItem,
|
|
1487
|
+
{
|
|
1488
|
+
value: opt.id,
|
|
1489
|
+
className: cn(
|
|
1490
|
+
"focus:bg-[#e8edea]",
|
|
1491
|
+
opt.id === field.value ? "font-bold bg-[#dae5de] focus:bg-[#dae5de]" : ""
|
|
1492
|
+
),
|
|
1493
|
+
children: opt.label
|
|
1494
|
+
},
|
|
1495
|
+
opt.id
|
|
1496
|
+
)) })
|
|
1497
|
+
]
|
|
1498
|
+
}
|
|
1499
|
+
),
|
|
1500
|
+
index == 0 ? /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
1501
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsx(Info, { className: "h-5 w-5", stroke: "white", fill: "#8B8B8B" }) }),
|
|
1502
|
+
/* @__PURE__ */ jsx(
|
|
1503
|
+
TooltipContent,
|
|
1504
|
+
{
|
|
1505
|
+
align: "start",
|
|
1506
|
+
alignOffset: 10,
|
|
1507
|
+
className: "bg-[#8B8B8B] rounded-none",
|
|
1508
|
+
arrowClassName: "!hidden",
|
|
1509
|
+
children: /* @__PURE__ */ jsx("p", { children: "Column cannot be removed." })
|
|
1510
|
+
}
|
|
1511
|
+
)
|
|
1512
|
+
] }) }) : /* @__PURE__ */ jsx(
|
|
1513
|
+
CircleMinus,
|
|
1514
|
+
{
|
|
1515
|
+
onClick: () => index > 0 && removeColumn(index),
|
|
1516
|
+
className: "h-5 w-5 cursor-pointer",
|
|
1517
|
+
stroke: "white",
|
|
1518
|
+
fill: "#C32A2C"
|
|
1519
|
+
}
|
|
1520
|
+
)
|
|
1521
|
+
] }),
|
|
1522
|
+
/* @__PURE__ */ jsx(FormMessage, { className: cn("pl-6 text-[#BB0B0E]", hideFormMessage && "hidden") })
|
|
1523
|
+
] })
|
|
1524
|
+
}
|
|
1525
|
+
) });
|
|
1526
|
+
}
|
|
1527
|
+
var buttonVariants2 = cva(
|
|
1528
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive cursor-pointer",
|
|
1529
|
+
{
|
|
1530
|
+
variants: {
|
|
1531
|
+
variant: {
|
|
1532
|
+
default: "bg-primary text-primary-foreground shadow-xs hover:bg-sus-primary/90",
|
|
1533
|
+
destructive: "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
1534
|
+
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
|
|
1535
|
+
secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
|
1536
|
+
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
1537
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
1538
|
+
},
|
|
1539
|
+
size: {
|
|
1540
|
+
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
1541
|
+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
1542
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
1543
|
+
icon: "size-9",
|
|
1544
|
+
"icon-xs": "size-5",
|
|
1545
|
+
"icon-sm": "size-[22px]",
|
|
1546
|
+
"icon-md": "size-7",
|
|
1547
|
+
"icon-lg": "size-10"
|
|
1548
|
+
},
|
|
1549
|
+
active: {
|
|
1550
|
+
true: "bg-sus-primary-1 text-white",
|
|
1551
|
+
// <-- Active state style
|
|
1552
|
+
false: ""
|
|
1553
|
+
}
|
|
1554
|
+
},
|
|
1555
|
+
defaultVariants: {
|
|
1556
|
+
variant: "default",
|
|
1557
|
+
size: "default"
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
);
|
|
1561
|
+
function Button2({
|
|
1562
|
+
className,
|
|
1563
|
+
variant,
|
|
1564
|
+
size,
|
|
1565
|
+
active,
|
|
1566
|
+
asChild = false,
|
|
1567
|
+
...props
|
|
1568
|
+
}) {
|
|
1569
|
+
const Comp = asChild ? Slot : "button";
|
|
1570
|
+
return /* @__PURE__ */ jsx(
|
|
1571
|
+
Comp,
|
|
1572
|
+
{
|
|
1573
|
+
"data-slot": "button",
|
|
1574
|
+
className: cn(buttonVariants2({ variant, size, className, active })),
|
|
1575
|
+
...props
|
|
1576
|
+
}
|
|
1577
|
+
);
|
|
1578
|
+
}
|
|
1579
|
+
var ColumnSchema = z.object({
|
|
1580
|
+
id: z.string().nonempty("This field is required")
|
|
1581
|
+
});
|
|
1582
|
+
var GridSettingsSchema = z.object({
|
|
1583
|
+
columns: z.array(ColumnSchema).min(1, "At least one column is required")
|
|
1584
|
+
});
|
|
1585
|
+
var GridSettingsModal = ({
|
|
1586
|
+
isOpen = false,
|
|
1587
|
+
headerClassname,
|
|
1588
|
+
descriptionClassname,
|
|
1589
|
+
addButtonClassname,
|
|
1590
|
+
saveButtonClassname,
|
|
1591
|
+
availableColumns,
|
|
1592
|
+
currentColumns,
|
|
1593
|
+
limit = availableColumns.length,
|
|
1594
|
+
onClose,
|
|
1595
|
+
onSaveColumns
|
|
1596
|
+
}) => {
|
|
1597
|
+
const [hideFormMessage, setHideFormMessage] = useState(false);
|
|
1598
|
+
const form = useForm({
|
|
1599
|
+
resolver: t2(GridSettingsSchema),
|
|
1600
|
+
defaultValues: { columns: currentColumns },
|
|
1601
|
+
mode: "onChange"
|
|
1602
|
+
});
|
|
1603
|
+
useEffect(() => {
|
|
1604
|
+
if (isOpen) {
|
|
1605
|
+
form.reset({ columns: currentColumns });
|
|
1606
|
+
}
|
|
1607
|
+
}, [isOpen, currentColumns, form]);
|
|
1608
|
+
const columns = form.watch("columns");
|
|
1609
|
+
const onSubmit = (data) => {
|
|
1610
|
+
const ordering = data.columns.map((i2) => i2.id);
|
|
1611
|
+
const visibility = Object.fromEntries(
|
|
1612
|
+
availableColumns.map((col) => [col.id, data.columns.some((c) => c.id === col.id)])
|
|
1613
|
+
);
|
|
1614
|
+
const pinning = { left: [data.columns[0].id] };
|
|
1615
|
+
if (onSaveColumns) {
|
|
1616
|
+
onSaveColumns({ ordering, visibility, pinning });
|
|
1617
|
+
}
|
|
1618
|
+
};
|
|
1619
|
+
const addColumn = async () => {
|
|
1620
|
+
const isValid2 = await form.trigger("columns");
|
|
1621
|
+
if (!isValid2) {
|
|
1622
|
+
return;
|
|
1623
|
+
}
|
|
1624
|
+
form.setValue("columns", [...columns, { id: "" }], { shouldValidate: false });
|
|
1625
|
+
};
|
|
1626
|
+
const removeColumn = (index) => {
|
|
1627
|
+
const newCols = [...columns];
|
|
1628
|
+
newCols.splice(index, 1);
|
|
1629
|
+
form.setValue("columns", newCols);
|
|
1630
|
+
};
|
|
1631
|
+
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } }));
|
|
1632
|
+
const handleDragEnd = (event) => {
|
|
1633
|
+
const { active, over } = event;
|
|
1634
|
+
if (!over || active.id === over.id) return;
|
|
1635
|
+
const oldIndex = columns.findIndex((c) => c.id === active.id);
|
|
1636
|
+
const newIndex = columns.findIndex((c) => c.id === over.id);
|
|
1637
|
+
if (newIndex === 0) return;
|
|
1638
|
+
const reordered = arrayMove(columns, oldIndex, newIndex);
|
|
1639
|
+
form.setValue("columns", reordered, { shouldValidate: true });
|
|
1640
|
+
};
|
|
1641
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-xl p-0 border-0", showCloseButton: false, children: [
|
|
1642
|
+
/* @__PURE__ */ jsx(DialogClose, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
1643
|
+
"button",
|
|
1644
|
+
{
|
|
1645
|
+
type: "button",
|
|
1646
|
+
"aria-label": "Close",
|
|
1647
|
+
className: "absolute top-4 right-4",
|
|
1648
|
+
style: {
|
|
1649
|
+
background: "none",
|
|
1650
|
+
border: "none",
|
|
1651
|
+
padding: 0,
|
|
1652
|
+
cursor: "pointer"
|
|
1653
|
+
},
|
|
1654
|
+
children: /* @__PURE__ */ jsx(X, { className: "w-6 h-6 text-white" })
|
|
1655
|
+
}
|
|
1656
|
+
) }),
|
|
1657
|
+
/* @__PURE__ */ jsxs(DialogHeader, { className: cn("bg-[#82B495] text-white h-25 rounded-t-lg", headerClassname), children: [
|
|
1658
|
+
/* @__PURE__ */ jsx(DialogTitle, { className: "text-2xl p-4", children: "Grid Settings" }),
|
|
1659
|
+
/* @__PURE__ */ jsx(
|
|
1660
|
+
DialogDescription,
|
|
1661
|
+
{
|
|
1662
|
+
className: cn("bg-[#8B8B8B] text-white px-4 py-2.5", descriptionClassname),
|
|
1663
|
+
children: "Add or remove columns. To change the column order, drag and drop a field."
|
|
1664
|
+
}
|
|
1665
|
+
)
|
|
1666
|
+
] }),
|
|
1667
|
+
/* @__PURE__ */ jsx(Form, { ...form, children: /* @__PURE__ */ jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "flex flex-col justify-between", children: [
|
|
1668
|
+
/* @__PURE__ */ jsx("div", { className: "px-16 my-10", children: /* @__PURE__ */ jsxs("div", { className: "space-y-3 max-h-60 overflow-y-auto pr-4", children: [
|
|
1669
|
+
/* @__PURE__ */ jsx(
|
|
1670
|
+
SortableRow,
|
|
1671
|
+
{
|
|
1672
|
+
itemId: columns[0]?.id,
|
|
1673
|
+
index: 0,
|
|
1674
|
+
control: form.control,
|
|
1675
|
+
availableColumns,
|
|
1676
|
+
currentColumns: columns,
|
|
1677
|
+
disableDrag: true,
|
|
1678
|
+
disableEdit: true,
|
|
1679
|
+
removeColumn
|
|
1680
|
+
}
|
|
1681
|
+
),
|
|
1682
|
+
/* @__PURE__ */ jsx(
|
|
1683
|
+
DndContext,
|
|
1684
|
+
{
|
|
1685
|
+
sensors,
|
|
1686
|
+
collisionDetection: closestCenter,
|
|
1687
|
+
onDragStart: () => setHideFormMessage(true),
|
|
1688
|
+
onDragEnd: (event) => {
|
|
1689
|
+
setHideFormMessage(false);
|
|
1690
|
+
handleDragEnd(event);
|
|
1691
|
+
},
|
|
1692
|
+
children: /* @__PURE__ */ jsx(
|
|
1693
|
+
SortableContext,
|
|
1694
|
+
{
|
|
1695
|
+
items: columns?.slice(1).map((c) => c.id),
|
|
1696
|
+
strategy: verticalListSortingStrategy,
|
|
1697
|
+
children: columns?.slice(1).map((item, index) => /* @__PURE__ */ jsx(
|
|
1698
|
+
SortableRow,
|
|
1699
|
+
{
|
|
1700
|
+
itemId: item.id,
|
|
1701
|
+
index: index + 1,
|
|
1702
|
+
control: form.control,
|
|
1703
|
+
availableColumns,
|
|
1704
|
+
currentColumns: columns,
|
|
1705
|
+
hideFormMessage,
|
|
1706
|
+
removeColumn
|
|
1707
|
+
},
|
|
1708
|
+
item.id + index
|
|
1709
|
+
))
|
|
1710
|
+
}
|
|
1711
|
+
)
|
|
1712
|
+
}
|
|
1713
|
+
),
|
|
1714
|
+
/* @__PURE__ */ jsx("div", { className: "px-6", children: /* @__PURE__ */ jsxs(
|
|
1715
|
+
Button2,
|
|
1716
|
+
{
|
|
1717
|
+
type: "button",
|
|
1718
|
+
className: cn("bg-[#41875C99] text-white w-full rounded-t-lg", addButtonClassname),
|
|
1719
|
+
onClick: addColumn,
|
|
1720
|
+
disabled: columns.length >= limit,
|
|
1721
|
+
children: [
|
|
1722
|
+
/* @__PURE__ */ jsx(Plus, { className: "h-4 w-4 mr-1" }),
|
|
1723
|
+
" Add column"
|
|
1724
|
+
]
|
|
1725
|
+
}
|
|
1726
|
+
) })
|
|
1727
|
+
] }) }),
|
|
1728
|
+
/* @__PURE__ */ jsx(DialogFooter, { className: "w-full px-6", children: /* @__PURE__ */ jsxs("div", { className: "flex justify-between w-full py-4 border-t-1 border-[#B9B9B9]", children: [
|
|
1729
|
+
/* @__PURE__ */ jsx(
|
|
1730
|
+
Button2,
|
|
1731
|
+
{
|
|
1732
|
+
type: "button",
|
|
1733
|
+
variant: "outline",
|
|
1734
|
+
onClick: onClose,
|
|
1735
|
+
className: "w-18 text-[#8B8B8B] border-[#B9B9B9]",
|
|
1736
|
+
children: "Cancel"
|
|
1737
|
+
}
|
|
1738
|
+
),
|
|
1739
|
+
/* @__PURE__ */ jsx(
|
|
1740
|
+
Button2,
|
|
1741
|
+
{
|
|
1742
|
+
type: "submit",
|
|
1743
|
+
className: cn("w-18 bg-[#379A2A] text-white", saveButtonClassname),
|
|
1744
|
+
children: "Save"
|
|
1745
|
+
}
|
|
1746
|
+
)
|
|
1747
|
+
] }) })
|
|
1748
|
+
] }) })
|
|
1749
|
+
] }) }) });
|
|
1750
|
+
};
|
|
1751
|
+
var GridSettingsModal_default = GridSettingsModal;
|
|
1752
|
+
var InfoIcon = (props) => {
|
|
1753
|
+
return /* @__PURE__ */ jsxs(
|
|
1754
|
+
"svg",
|
|
1755
|
+
{
|
|
1756
|
+
width: "24",
|
|
1757
|
+
height: "26",
|
|
1758
|
+
viewBox: "0 0 14 13",
|
|
1759
|
+
fill: "none",
|
|
1760
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1761
|
+
...props,
|
|
1762
|
+
children: [
|
|
1763
|
+
/* @__PURE__ */ jsx("circle", { cx: "6.98438", cy: "6.63281", r: "6.25", fill: "white" }),
|
|
1764
|
+
/* @__PURE__ */ jsx(
|
|
1765
|
+
"path",
|
|
1766
|
+
{
|
|
1767
|
+
d: "M5.98811 3.39501C5.98811 4.01786 6.44715 4.40642 6.99953 4.40642C7.5519 4.40642 7.98047 4.04833 7.98047 3.39501C7.98047 2.74168 7.5519 2.41406 6.99953 2.41406C6.44715 2.41406 5.98811 2.76073 5.98811 3.39501ZM6.13096 10.8521H7.86809V5.02928H6.13096V10.8521Z",
|
|
1768
|
+
fill: "#231F20"
|
|
1769
|
+
}
|
|
1770
|
+
)
|
|
1771
|
+
]
|
|
1772
|
+
}
|
|
1773
|
+
);
|
|
1774
|
+
};
|
|
1775
|
+
var InfoIcon_default = React3__default.memo(InfoIcon);
|
|
1776
|
+
function TooltipProvider2({
|
|
1777
|
+
delayDuration = 0,
|
|
1778
|
+
...props
|
|
1779
|
+
}) {
|
|
1780
|
+
return /* @__PURE__ */ jsx(
|
|
1781
|
+
TooltipPrimitive.Provider,
|
|
1782
|
+
{
|
|
1783
|
+
"data-slot": "tooltip-provider",
|
|
1784
|
+
delayDuration,
|
|
1785
|
+
...props
|
|
1786
|
+
}
|
|
1787
|
+
);
|
|
1788
|
+
}
|
|
1789
|
+
function Tooltip2({
|
|
1790
|
+
...props
|
|
1791
|
+
}) {
|
|
1792
|
+
return /* @__PURE__ */ jsx(TooltipProvider2, { children: /* @__PURE__ */ jsx(TooltipPrimitive.Root, { "data-slot": "tooltip", ...props }) });
|
|
1793
|
+
}
|
|
1794
|
+
function TooltipTrigger2({
|
|
1795
|
+
...props
|
|
1796
|
+
}) {
|
|
1797
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Trigger, { "data-slot": "tooltip-trigger", ...props });
|
|
1798
|
+
}
|
|
1799
|
+
function TooltipArrow(props) {
|
|
1800
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Arrow, { ...props });
|
|
1801
|
+
}
|
|
1802
|
+
function TooltipContent2({
|
|
1803
|
+
className,
|
|
1804
|
+
sideOffset = 0,
|
|
1805
|
+
children,
|
|
1806
|
+
...props
|
|
1807
|
+
}) {
|
|
1808
|
+
return /* @__PURE__ */ jsx(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
1809
|
+
TooltipPrimitive.Content,
|
|
1810
|
+
{
|
|
1811
|
+
"data-slot": "tooltip-content",
|
|
1812
|
+
sideOffset,
|
|
1813
|
+
className: cn(
|
|
1814
|
+
"relative bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md rounded-tl-none px-3 py-1.5 text-xs text-balance",
|
|
1815
|
+
className
|
|
1816
|
+
),
|
|
1817
|
+
...props,
|
|
1818
|
+
children
|
|
1819
|
+
}
|
|
1820
|
+
) });
|
|
1821
|
+
}
|
|
1822
|
+
var Navbar = ({
|
|
1823
|
+
className,
|
|
1824
|
+
title,
|
|
1825
|
+
subTitle,
|
|
1826
|
+
headImageURL = "",
|
|
1827
|
+
headImageURLClassName,
|
|
1828
|
+
tooltipTitle,
|
|
1829
|
+
tooltipIcon,
|
|
1830
|
+
tooltipdescription = [],
|
|
1831
|
+
mainButtonText,
|
|
1832
|
+
mainButtonClassName,
|
|
1833
|
+
mainButtonDisable = false,
|
|
1834
|
+
subButtonText,
|
|
1835
|
+
subButtonClassName,
|
|
1836
|
+
subButtonDisable = false,
|
|
1837
|
+
onMainButtonClick,
|
|
1838
|
+
onSubButtonClick,
|
|
1839
|
+
searchButton
|
|
1840
|
+
}) => {
|
|
1841
|
+
const { isMobile, isTablet, isDesktop } = useScreenSize_default();
|
|
1842
|
+
const Icon3 = CircleHelp;
|
|
1843
|
+
return /* @__PURE__ */ jsxs(
|
|
1844
|
+
"nav",
|
|
1845
|
+
{
|
|
1846
|
+
className: cn(
|
|
1847
|
+
"py-5 px-8 w-full h-[5.3rem] bg-sus-primary-1 flex items-center justify-between",
|
|
1848
|
+
className
|
|
1849
|
+
),
|
|
1850
|
+
children: [
|
|
1851
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5", children: [
|
|
1852
|
+
headImageURL !== "" ? /* @__PURE__ */ jsx("img", { src: headImageURL, alt: "", className: cn("w-full h-full", headImageURLClassName) }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
1853
|
+
isValidElement(title) ? title : /* @__PURE__ */ jsx("h1", { className: "text-white text-4xl font-bold", children: title }),
|
|
1854
|
+
isValidElement(subTitle) ? subTitle : /* @__PURE__ */ jsx("h1", { className: "text-white text-xl font-bold", children: subTitle })
|
|
1855
|
+
] }),
|
|
1856
|
+
tooltipTitle && /* @__PURE__ */ jsxs(Tooltip2, { children: [
|
|
1857
|
+
/* @__PURE__ */ jsx(TooltipTrigger2, { asChild: true, children: /* @__PURE__ */ jsx("button", { className: "text-white hover:opacity-80 ", children: /* @__PURE__ */ jsx(InfoIcon_default, { className: "w-4" }) }) }),
|
|
1858
|
+
/* @__PURE__ */ jsxs(
|
|
1859
|
+
TooltipContent2,
|
|
1860
|
+
{
|
|
1861
|
+
forceMount: true,
|
|
1862
|
+
side: isDesktop ? "right" : "bottom",
|
|
1863
|
+
sideOffset: 8,
|
|
1864
|
+
align: "start",
|
|
1865
|
+
avoidCollisions: false,
|
|
1866
|
+
className: cn(
|
|
1867
|
+
"bg-background text-foreground border border-black md:w-[350px] lg:w-[420px]",
|
|
1868
|
+
"transition-all duration-150 ease-out origin-top",
|
|
1869
|
+
"data-[state=closed]:opacity-0 data-[state=open]:opacity-100",
|
|
1870
|
+
"data-[state=closed]:scale-95 data-[state=open]:scale-100",
|
|
1871
|
+
{ "mt-5": isDesktop }
|
|
1872
|
+
),
|
|
1873
|
+
children: [
|
|
1874
|
+
/* @__PURE__ */ jsxs(
|
|
1875
|
+
"div",
|
|
1876
|
+
{
|
|
1877
|
+
role: "tooltip",
|
|
1878
|
+
"aria-label": tooltipTitle,
|
|
1879
|
+
className: cn("flex flex-col gap-4 max-w-sm text-sm text-gray-700", className),
|
|
1880
|
+
children: [
|
|
1881
|
+
tooltipTitle && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
1882
|
+
isValidElement(tooltipIcon) ? tooltipIcon : /* @__PURE__ */ jsx(Icon3, { size: 32, "aria-hidden": "true" }),
|
|
1883
|
+
/* @__PURE__ */ jsx("h3", { className: "text-xl font-bold", children: tooltipTitle })
|
|
1884
|
+
] }),
|
|
1885
|
+
isValidElement(tooltipdescription) ? tooltipdescription : ""
|
|
1886
|
+
]
|
|
1887
|
+
}
|
|
1888
|
+
),
|
|
1889
|
+
/* @__PURE__ */ jsx(TooltipArrow, { className: "-my-px border-none fill-white", asChild: true, children: /* @__PURE__ */ jsxs(
|
|
1890
|
+
"svg",
|
|
1891
|
+
{
|
|
1892
|
+
width: isDesktop ? 35 : 33,
|
|
1893
|
+
height: 35,
|
|
1894
|
+
viewBox: "0 0 40 35",
|
|
1895
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1896
|
+
className: cn({
|
|
1897
|
+
"rotate-90 visible": isTablet || isMobile,
|
|
1898
|
+
"": isDesktop
|
|
1899
|
+
}),
|
|
1900
|
+
children: [
|
|
1901
|
+
/* @__PURE__ */ jsx("path", { d: "M0 0 L40 0 L0 35 Z", fill: "white" }),
|
|
1902
|
+
isDesktop ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1903
|
+
/* @__PURE__ */ jsx("line", { x1: "0", y1: "40", x2: "0", y2: "0", stroke: "black", strokeWidth: "2.5" }),
|
|
1904
|
+
/* @__PURE__ */ jsx("line", { x1: "40", y1: "0", x2: "0", y2: "35", stroke: "black", strokeWidth: "1" })
|
|
1905
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1906
|
+
/* @__PURE__ */ jsx("line", { x1: "40", y1: "0", x2: "0", y2: "0", stroke: "black", strokeWidth: "2" }),
|
|
1907
|
+
/* @__PURE__ */ jsx("line", { x1: "40", y1: "0", x2: "0", y2: "35", stroke: "black", strokeWidth: "1" })
|
|
1908
|
+
] })
|
|
1909
|
+
]
|
|
1910
|
+
}
|
|
1911
|
+
) })
|
|
1912
|
+
]
|
|
1913
|
+
}
|
|
1914
|
+
)
|
|
1915
|
+
] })
|
|
1916
|
+
] }),
|
|
1917
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
1918
|
+
mainButtonText && /* @__PURE__ */ jsx(
|
|
1919
|
+
Button,
|
|
1920
|
+
{
|
|
1921
|
+
disabled: mainButtonDisable,
|
|
1922
|
+
className: cn("bg-sus-secondary-1 hover:bg-sus-secondary-hover", mainButtonClassName),
|
|
1923
|
+
size: "lg",
|
|
1924
|
+
onClick: onMainButtonClick,
|
|
1925
|
+
children: mainButtonText
|
|
1926
|
+
}
|
|
1927
|
+
),
|
|
1928
|
+
subButtonText && /* @__PURE__ */ jsx(
|
|
1929
|
+
Button,
|
|
1930
|
+
{
|
|
1931
|
+
disabled: subButtonDisable,
|
|
1932
|
+
className: cn("bg-sus-primary-2 hover:bg-sus-primary-2-hover", subButtonClassName),
|
|
1933
|
+
size: "lg",
|
|
1934
|
+
onClick: onSubButtonClick,
|
|
1935
|
+
children: subButtonText
|
|
1936
|
+
}
|
|
1937
|
+
),
|
|
1938
|
+
isValidElement(searchButton) ? /* @__PURE__ */ jsx("div", { role: "separator", className: "ml-1 w-[1px] h-10 bg-white" }) : "",
|
|
1939
|
+
isValidElement(searchButton) ? searchButton : ""
|
|
1940
|
+
] })
|
|
1941
|
+
]
|
|
1942
|
+
}
|
|
1943
|
+
);
|
|
1944
|
+
};
|
|
1945
|
+
var navbar_default = React3__default.memo(Navbar);
|
|
1946
|
+
var ExpandCollapse = ({ title, children, portalId }) => {
|
|
1947
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
1948
|
+
const Panel = /* @__PURE__ */ jsx(
|
|
1949
|
+
"div",
|
|
1950
|
+
{
|
|
1951
|
+
className: clsx3(
|
|
1952
|
+
"overflow-hidden transition-all duration-500 ease-in-out bg-white border-b shadow-md w-full",
|
|
1953
|
+
isOpen ? "max-h-[700px] opacity-100" : "max-h-0 opacity-0"
|
|
1954
|
+
),
|
|
1955
|
+
children: /* @__PURE__ */ jsxs("div", { className: "relative p-6", children: [
|
|
1956
|
+
/* @__PURE__ */ jsx(
|
|
1957
|
+
"button",
|
|
1958
|
+
{
|
|
1959
|
+
onClick: () => setIsOpen(false),
|
|
1960
|
+
className: "absolute top-2 right-2 text-gray-500 hover:text-gray-700",
|
|
1961
|
+
children: /* @__PURE__ */ jsx(X, { className: "w-5 h-5" })
|
|
1962
|
+
}
|
|
1963
|
+
),
|
|
1964
|
+
children
|
|
1965
|
+
] })
|
|
1966
|
+
}
|
|
1967
|
+
);
|
|
1968
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1969
|
+
/* @__PURE__ */ jsx(
|
|
1970
|
+
"button",
|
|
1971
|
+
{
|
|
1972
|
+
onClick: () => setIsOpen(!isOpen),
|
|
1973
|
+
className: "px-4 py-2 text-sm text-gray-700 hover:text-black",
|
|
1974
|
+
children: title
|
|
1975
|
+
}
|
|
1976
|
+
),
|
|
1977
|
+
portalId && typeof document !== "undefined" ? document.getElementById(portalId) ? createPortal(Panel, document.getElementById(portalId)) : null : Panel
|
|
1978
|
+
] });
|
|
1979
|
+
};
|
|
1980
|
+
var ExpandCollapse_default = ExpandCollapse;
|
|
1981
|
+
|
|
1982
|
+
// src/components/advanceSearch/operatorMap.ts
|
|
1983
|
+
var OPERATOR_MAP = {
|
|
1984
|
+
text: [
|
|
1985
|
+
"contains",
|
|
1986
|
+
"equals",
|
|
1987
|
+
"beginsWith",
|
|
1988
|
+
"endsWith",
|
|
1989
|
+
"notEquals",
|
|
1990
|
+
"notBeginsWith",
|
|
1991
|
+
"notEndsWith",
|
|
1992
|
+
"notContains"
|
|
1993
|
+
],
|
|
1994
|
+
number: ["equals", "notEquals", "gt", "gte", "lt", "lte"],
|
|
1995
|
+
date: ["on", "after", "before", "between"],
|
|
1996
|
+
datetime: ["on", "after", "before", "between"],
|
|
1997
|
+
checkbox: ["is", "isNot"],
|
|
1998
|
+
dropdown: ["is", "isNot"],
|
|
1999
|
+
lookup: ["containsAny", "containsOnly", "containsAll", "notContains"]
|
|
2000
|
+
};
|
|
2001
|
+
|
|
2002
|
+
// src/components/advanceSearch/hooks/useAdvanceSearch.ts
|
|
2003
|
+
function findField(fields, name) {
|
|
2004
|
+
return fields.find((f) => f.name === name);
|
|
2005
|
+
}
|
|
2006
|
+
function getFieldType(fields, name) {
|
|
2007
|
+
return findField(fields, name)?.type ?? "text";
|
|
2008
|
+
}
|
|
2009
|
+
function firstOperatorFor(fields, fieldName) {
|
|
2010
|
+
const t3 = getFieldType(fields, fieldName);
|
|
2011
|
+
return OPERATOR_MAP[t3][0];
|
|
2012
|
+
}
|
|
2013
|
+
function makeNewRow(fields) {
|
|
2014
|
+
const first = fields[0];
|
|
2015
|
+
const op = OPERATOR_MAP[first.type][0];
|
|
2016
|
+
if (op === "between") {
|
|
2017
|
+
return {
|
|
2018
|
+
id: crypto.randomUUID(),
|
|
2019
|
+
fieldName: first.name,
|
|
2020
|
+
operator: "between",
|
|
2021
|
+
value: "",
|
|
2022
|
+
value2: ""
|
|
2023
|
+
};
|
|
2024
|
+
}
|
|
2025
|
+
return { id: crypto.randomUUID(), fieldName: first.name, operator: op, value: "" };
|
|
2026
|
+
}
|
|
2027
|
+
function useAdvanceSearch({ fields, limitRows }) {
|
|
2028
|
+
const [rows, setRows] = useState([makeNewRow(fields)]);
|
|
2029
|
+
const updateRows = useCallback((next) => {
|
|
2030
|
+
setRows(next);
|
|
2031
|
+
}, []);
|
|
2032
|
+
const operatorsForField = useCallback(
|
|
2033
|
+
(fieldName) => {
|
|
2034
|
+
const t3 = getFieldType(fields, fieldName);
|
|
2035
|
+
return OPERATOR_MAP[t3];
|
|
2036
|
+
},
|
|
2037
|
+
[fields]
|
|
2038
|
+
);
|
|
2039
|
+
const addRow = useCallback(() => {
|
|
2040
|
+
if (!limitRows || rows.length < limitRows) {
|
|
2041
|
+
updateRows([...rows, makeNewRow(fields)]);
|
|
2042
|
+
}
|
|
2043
|
+
}, [rows, fields, updateRows, limitRows]);
|
|
2044
|
+
const removeRow = useCallback(
|
|
2045
|
+
(id) => {
|
|
2046
|
+
if (rows.length === 1) return;
|
|
2047
|
+
updateRows(rows.filter((r2) => r2.id !== id));
|
|
2048
|
+
},
|
|
2049
|
+
[rows, updateRows]
|
|
2050
|
+
);
|
|
2051
|
+
const clearRow = useCallback(
|
|
2052
|
+
(id) => {
|
|
2053
|
+
updateRows(
|
|
2054
|
+
rows.map((r2) => {
|
|
2055
|
+
if (r2.id !== id) return r2;
|
|
2056
|
+
const nextOp = firstOperatorFor(fields, r2.fieldName);
|
|
2057
|
+
return nextOp === "between" ? { id: r2.id, fieldName: r2.fieldName, operator: "between", value: "", value2: "" } : { id: r2.id, fieldName: r2.fieldName, operator: nextOp, value: "" };
|
|
2058
|
+
})
|
|
2059
|
+
);
|
|
2060
|
+
},
|
|
2061
|
+
[rows, fields, updateRows]
|
|
2062
|
+
);
|
|
2063
|
+
const clearAllRow = useCallback(() => {
|
|
2064
|
+
updateRows([makeNewRow(fields)]);
|
|
2065
|
+
}, [fields, updateRows]);
|
|
2066
|
+
const changeField = useCallback(
|
|
2067
|
+
(id, fieldName) => {
|
|
2068
|
+
const nextOp = firstOperatorFor(fields, fieldName);
|
|
2069
|
+
updateRows(
|
|
2070
|
+
rows.map((r2) => {
|
|
2071
|
+
if (r2.id !== id) return r2;
|
|
2072
|
+
return nextOp === "between" ? { id: r2.id, fieldName, operator: "between", value: "", value2: "" } : { id: r2.id, fieldName, operator: nextOp, value: "" };
|
|
2073
|
+
})
|
|
2074
|
+
);
|
|
2075
|
+
},
|
|
2076
|
+
[rows, fields, updateRows]
|
|
2077
|
+
);
|
|
2078
|
+
const changeOperator = useCallback(
|
|
2079
|
+
(id, operator) => {
|
|
2080
|
+
updateRows(
|
|
2081
|
+
rows.map((r2) => {
|
|
2082
|
+
if (r2.id !== id) return r2;
|
|
2083
|
+
if (operator === "between") {
|
|
2084
|
+
return { id: r2.id, fieldName: r2.fieldName, operator, value: "", value2: "" };
|
|
2085
|
+
}
|
|
2086
|
+
return { id: r2.id, fieldName: r2.fieldName, operator, value: "" };
|
|
2087
|
+
})
|
|
2088
|
+
);
|
|
2089
|
+
},
|
|
2090
|
+
[rows, updateRows]
|
|
2091
|
+
);
|
|
2092
|
+
const changeValue = useCallback(
|
|
2093
|
+
(id, which, val) => {
|
|
2094
|
+
updateRows(
|
|
2095
|
+
rows.map((r2) => {
|
|
2096
|
+
if (r2.id !== id) return r2;
|
|
2097
|
+
if (which === "value2" && r2.operator !== "between") return r2;
|
|
2098
|
+
return { ...r2, [which]: val };
|
|
2099
|
+
})
|
|
2100
|
+
);
|
|
2101
|
+
},
|
|
2102
|
+
[rows, updateRows]
|
|
2103
|
+
);
|
|
2104
|
+
const fieldOptions = useMemo(
|
|
2105
|
+
() => fields.map((f) => ({
|
|
2106
|
+
value: f.name,
|
|
2107
|
+
label: f.label ?? f.name
|
|
2108
|
+
})),
|
|
2109
|
+
[fields]
|
|
2110
|
+
);
|
|
2111
|
+
const rowToFilter = (row) => {
|
|
2112
|
+
switch (row.operator) {
|
|
2113
|
+
case "between":
|
|
2114
|
+
return {
|
|
2115
|
+
[row.fieldName]: {
|
|
2116
|
+
gte: row.value,
|
|
2117
|
+
lte: row.value2
|
|
2118
|
+
}
|
|
2119
|
+
};
|
|
2120
|
+
case "contains":
|
|
2121
|
+
return { [row.fieldName]: { contains: row.value } };
|
|
2122
|
+
case "beginsWith":
|
|
2123
|
+
return { [row.fieldName]: { startsWith: row.value } };
|
|
2124
|
+
case "endsWith":
|
|
2125
|
+
return { [row.fieldName]: { endsWith: row.value } };
|
|
2126
|
+
case "notEquals":
|
|
2127
|
+
return { [row.fieldName]: { not: row.value } };
|
|
2128
|
+
case "gt":
|
|
2129
|
+
return { [row.fieldName]: { gt: row.value } };
|
|
2130
|
+
case "gte":
|
|
2131
|
+
return { [row.fieldName]: { gte: row.value } };
|
|
2132
|
+
case "lt":
|
|
2133
|
+
return { [row.fieldName]: { lt: row.value } };
|
|
2134
|
+
case "lte":
|
|
2135
|
+
return { [row.fieldName]: { lte: row.value } };
|
|
2136
|
+
case "is":
|
|
2137
|
+
return { [row.fieldName]: row.value };
|
|
2138
|
+
case "isNot":
|
|
2139
|
+
return { [row.fieldName]: { not: row.value } };
|
|
2140
|
+
case "notContains":
|
|
2141
|
+
return { [row.fieldName]: { not: { contains: row.value } } };
|
|
2142
|
+
case "notBeginsWith":
|
|
2143
|
+
return { [row.fieldName]: { not: { startsWith: row.value } } };
|
|
2144
|
+
case "notEndsWith":
|
|
2145
|
+
return { [row.fieldName]: { not: { endsWith: row.value } } };
|
|
2146
|
+
case "containsAny":
|
|
2147
|
+
return { [row.fieldName]: { hasSome: row.value.split(",") } };
|
|
2148
|
+
case "containsAll":
|
|
2149
|
+
return { [row.fieldName]: { hasEvery: row.value.split(",") } };
|
|
2150
|
+
case "containsOnly":
|
|
2151
|
+
return { [row.fieldName]: { equals: row.value.split(",") } };
|
|
2152
|
+
default:
|
|
2153
|
+
return { [row.fieldName]: row.value };
|
|
2154
|
+
}
|
|
2155
|
+
};
|
|
2156
|
+
const buildParam = useMemo(() => {
|
|
2157
|
+
const andConditions = rows.map((r2) => r2.value ? rowToFilter(r2) : null).filter(Boolean);
|
|
2158
|
+
return { AND: andConditions };
|
|
2159
|
+
}, [rows]);
|
|
2160
|
+
return {
|
|
2161
|
+
rows,
|
|
2162
|
+
addRow,
|
|
2163
|
+
removeRow,
|
|
2164
|
+
clearRow,
|
|
2165
|
+
clearAllRow,
|
|
2166
|
+
changeField,
|
|
2167
|
+
changeOperator,
|
|
2168
|
+
changeValue,
|
|
2169
|
+
operatorsForField,
|
|
2170
|
+
fieldOptions,
|
|
2171
|
+
param: buildParam
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
// src/components/advanceSearch/types.ts
|
|
2176
|
+
var OPERATOR_LABEL = {
|
|
2177
|
+
contains: "Contains",
|
|
2178
|
+
equals: "Equals",
|
|
2179
|
+
beginsWith: "Begins with",
|
|
2180
|
+
endsWith: "Ends with",
|
|
2181
|
+
notEquals: "Not equals",
|
|
2182
|
+
notBeginsWith: "Not begins with",
|
|
2183
|
+
notEndsWith: "Not ends with",
|
|
2184
|
+
notContains: "Not contains",
|
|
2185
|
+
gt: "Greater than",
|
|
2186
|
+
gte: "Greater or equal",
|
|
2187
|
+
lt: "Less than",
|
|
2188
|
+
lte: "Less or equal",
|
|
2189
|
+
on: "On",
|
|
2190
|
+
after: "After",
|
|
2191
|
+
before: "Before",
|
|
2192
|
+
between: "Between",
|
|
2193
|
+
is: "Is",
|
|
2194
|
+
isNot: "Is not",
|
|
2195
|
+
containsAny: "Contains at least one of",
|
|
2196
|
+
containsOnly: "Contains only",
|
|
2197
|
+
containsAll: "Contains all of"
|
|
2198
|
+
};
|
|
2199
|
+
function Select2({ ...props }) {
|
|
2200
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Root, { "data-slot": "select", ...props });
|
|
2201
|
+
}
|
|
2202
|
+
function SelectValue2({ ...props }) {
|
|
2203
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Value, { "data-slot": "select-value", ...props });
|
|
2204
|
+
}
|
|
2205
|
+
function SelectTrigger2({
|
|
2206
|
+
className,
|
|
2207
|
+
size = "default",
|
|
2208
|
+
children,
|
|
2209
|
+
...props
|
|
2210
|
+
}) {
|
|
2211
|
+
return /* @__PURE__ */ jsxs(
|
|
2212
|
+
SelectPrimitive.Trigger,
|
|
2213
|
+
{
|
|
2214
|
+
"data-slot": "select-trigger",
|
|
2215
|
+
"data-size": size,
|
|
2216
|
+
className: cn2(
|
|
2217
|
+
"border-input data-[placeholder]:text-gray-00 [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:hover:bg-input/50 flex w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
2218
|
+
className
|
|
2219
|
+
),
|
|
2220
|
+
...props,
|
|
2221
|
+
children: [
|
|
2222
|
+
children,
|
|
2223
|
+
/* @__PURE__ */ jsx(SelectPrimitive.Icon, { asChild: true, children: /* @__PURE__ */ jsx(Triangle, { className: "size-2 opacity-60 fill-current", style: { transform: "rotate(180deg)" } }) })
|
|
2224
|
+
]
|
|
2225
|
+
}
|
|
2226
|
+
);
|
|
2227
|
+
}
|
|
2228
|
+
function SelectContent2({
|
|
2229
|
+
className,
|
|
2230
|
+
children,
|
|
2231
|
+
position = "popper",
|
|
2232
|
+
...props
|
|
2233
|
+
}) {
|
|
2234
|
+
return /* @__PURE__ */ jsx(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs(
|
|
2235
|
+
SelectPrimitive.Content,
|
|
2236
|
+
{
|
|
2237
|
+
"data-slot": "select-content",
|
|
2238
|
+
className: cn2(
|
|
2239
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border shadow-md",
|
|
2240
|
+
position === "popper" && "data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",
|
|
2241
|
+
className
|
|
2242
|
+
),
|
|
2243
|
+
position,
|
|
2244
|
+
...props,
|
|
2245
|
+
children: [
|
|
2246
|
+
/* @__PURE__ */ jsx(SelectScrollUpButton2, {}),
|
|
2247
|
+
/* @__PURE__ */ jsx(
|
|
2248
|
+
SelectPrimitive.Viewport,
|
|
2249
|
+
{
|
|
2250
|
+
className: cn2(
|
|
2251
|
+
"p-1",
|
|
2252
|
+
position === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
|
|
2253
|
+
),
|
|
2254
|
+
children
|
|
2255
|
+
}
|
|
2256
|
+
),
|
|
2257
|
+
/* @__PURE__ */ jsx(SelectScrollDownButton2, {})
|
|
2258
|
+
]
|
|
2259
|
+
}
|
|
2260
|
+
) });
|
|
2261
|
+
}
|
|
2262
|
+
function SelectItem2({
|
|
2263
|
+
className,
|
|
2264
|
+
children,
|
|
2265
|
+
...props
|
|
2266
|
+
}) {
|
|
2267
|
+
return /* @__PURE__ */ jsxs(
|
|
2268
|
+
SelectPrimitive.Item,
|
|
2269
|
+
{
|
|
2270
|
+
"data-slot": "select-item",
|
|
2271
|
+
className: cn2(
|
|
2272
|
+
"focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",
|
|
2273
|
+
className
|
|
2274
|
+
),
|
|
2275
|
+
...props,
|
|
2276
|
+
children: [
|
|
2277
|
+
/* @__PURE__ */ jsx("span", { className: "absolute right-2 flex size-3.5 items-center justify-center", children: /* @__PURE__ */ jsx(SelectPrimitive.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-2" }) }) }),
|
|
2278
|
+
/* @__PURE__ */ jsx(SelectPrimitive.ItemText, { children })
|
|
2279
|
+
]
|
|
2280
|
+
}
|
|
2281
|
+
);
|
|
2282
|
+
}
|
|
2283
|
+
function SelectScrollUpButton2({
|
|
2284
|
+
className,
|
|
2285
|
+
...props
|
|
2286
|
+
}) {
|
|
2287
|
+
return /* @__PURE__ */ jsx(
|
|
2288
|
+
SelectPrimitive.ScrollUpButton,
|
|
2289
|
+
{
|
|
2290
|
+
"data-slot": "select-scroll-up-button",
|
|
2291
|
+
className: cn2("flex cursor-default items-center justify-center py-1", className),
|
|
2292
|
+
...props,
|
|
2293
|
+
children: /* @__PURE__ */ jsx(Triangle, { className: "size-2 fill-current", style: { transform: "rotate(0deg)" } })
|
|
2294
|
+
}
|
|
2295
|
+
);
|
|
2296
|
+
}
|
|
2297
|
+
function SelectScrollDownButton2({
|
|
2298
|
+
className,
|
|
2299
|
+
...props
|
|
2300
|
+
}) {
|
|
2301
|
+
return /* @__PURE__ */ jsx(
|
|
2302
|
+
SelectPrimitive.ScrollDownButton,
|
|
2303
|
+
{
|
|
2304
|
+
"data-slot": "select-scroll-down-button",
|
|
2305
|
+
className: cn2("flex cursor-default items-center justify-center py-1", className),
|
|
2306
|
+
...props,
|
|
2307
|
+
children: /* @__PURE__ */ jsx(Triangle, { className: "size-2 fill-current", style: { transform: "rotate(180deg)" } })
|
|
2308
|
+
}
|
|
2309
|
+
);
|
|
2310
|
+
}
|
|
2311
|
+
function Input({ className, type, ...props }) {
|
|
2312
|
+
return /* @__PURE__ */ jsx(
|
|
2313
|
+
"input",
|
|
2314
|
+
{
|
|
2315
|
+
type,
|
|
2316
|
+
"data-slot": "input",
|
|
2317
|
+
className: cn2(
|
|
2318
|
+
"file:text-foreground placeholder:text-gray-400 selection:bg-primary selection:text-primary-foreground border-input flex h-9 w-full min-w-0 rounded-md border bg-white px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
2319
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
2320
|
+
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
2321
|
+
className
|
|
2322
|
+
),
|
|
2323
|
+
...props
|
|
2324
|
+
}
|
|
2325
|
+
);
|
|
2326
|
+
}
|
|
2327
|
+
function Popover({ ...props }) {
|
|
2328
|
+
return /* @__PURE__ */ jsx(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
|
|
2329
|
+
}
|
|
2330
|
+
function PopoverTrigger({ ...props }) {
|
|
2331
|
+
return /* @__PURE__ */ jsx(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
|
|
2332
|
+
}
|
|
2333
|
+
function PopoverContent({
|
|
2334
|
+
className,
|
|
2335
|
+
align = "center",
|
|
2336
|
+
sideOffset = 4,
|
|
2337
|
+
children,
|
|
2338
|
+
...props
|
|
2339
|
+
}) {
|
|
2340
|
+
return /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
2341
|
+
PopoverPrimitive.Content,
|
|
2342
|
+
{
|
|
2343
|
+
align,
|
|
2344
|
+
sideOffset,
|
|
2345
|
+
className: cn2(
|
|
2346
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) border p-4 shadow-md outline-hidden",
|
|
2347
|
+
className
|
|
2348
|
+
),
|
|
2349
|
+
...props,
|
|
2350
|
+
children
|
|
2351
|
+
}
|
|
2352
|
+
) });
|
|
2353
|
+
}
|
|
2354
|
+
var buttonVariants3 = cva(
|
|
2355
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive cursor-pointer",
|
|
2356
|
+
{
|
|
2357
|
+
variants: {
|
|
2358
|
+
variant: {
|
|
2359
|
+
default: "bg-sus-primary-1 text-primary-foreground shadow-xs hover:bg-sus-primary/90",
|
|
2360
|
+
destructive: "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",
|
|
2361
|
+
outline: "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
|
|
2362
|
+
secondary: "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
|
|
2363
|
+
ghost: "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
|
|
2364
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
2365
|
+
cancel: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
|
|
2366
|
+
defaultSelect: "bg-primary text-primary-foreground shadow-xs hover:bg-sus-primary/90 py-2",
|
|
2367
|
+
defaultOutline: "border bg-background py-2 shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50"
|
|
2368
|
+
},
|
|
2369
|
+
size: {
|
|
2370
|
+
default: "h-9 px-4 has-[>svg]:px-3",
|
|
2371
|
+
option: "py-5 h-9 px-4 has-[>svg]:px-3",
|
|
2372
|
+
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
2373
|
+
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
2374
|
+
icon: "size-9",
|
|
2375
|
+
"icon-xs": "size-5",
|
|
2376
|
+
"icon-sm": "size-[22px]",
|
|
2377
|
+
"icon-md": "size-7",
|
|
2378
|
+
"icon-lg": "size-10"
|
|
2379
|
+
},
|
|
2380
|
+
active: {
|
|
2381
|
+
true: "bg-sus-primary-1 text-white",
|
|
2382
|
+
false: ""
|
|
2383
|
+
}
|
|
2384
|
+
},
|
|
2385
|
+
defaultVariants: {
|
|
2386
|
+
variant: "default",
|
|
2387
|
+
size: "default"
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
);
|
|
2391
|
+
function Button3({
|
|
2392
|
+
className,
|
|
2393
|
+
variant,
|
|
2394
|
+
size,
|
|
2395
|
+
active,
|
|
2396
|
+
asChild = false,
|
|
2397
|
+
...props
|
|
2398
|
+
}) {
|
|
2399
|
+
const Comp = asChild ? Slot : "button";
|
|
2400
|
+
return /* @__PURE__ */ jsx(
|
|
2401
|
+
Comp,
|
|
2402
|
+
{
|
|
2403
|
+
"data-slot": "button",
|
|
2404
|
+
className: cn2(buttonVariants3({ variant, size, className, active })),
|
|
2405
|
+
...props
|
|
2406
|
+
}
|
|
2407
|
+
);
|
|
2408
|
+
}
|
|
2409
|
+
var ClearButton = ({
|
|
2410
|
+
onClick,
|
|
2411
|
+
title = "Clear",
|
|
2412
|
+
ariaLabel = "Clear row",
|
|
2413
|
+
className = ""
|
|
2414
|
+
}) => {
|
|
2415
|
+
return /* @__PURE__ */ jsx(
|
|
2416
|
+
"span",
|
|
2417
|
+
{
|
|
2418
|
+
role: "button",
|
|
2419
|
+
onClick,
|
|
2420
|
+
className: `clear-button ${className}`,
|
|
2421
|
+
"aria-label": ariaLabel,
|
|
2422
|
+
title,
|
|
2423
|
+
children: /* @__PURE__ */ jsx(X, { className: "icon" })
|
|
2424
|
+
}
|
|
2425
|
+
);
|
|
2426
|
+
};
|
|
2427
|
+
var isSameDay = (a, b) => a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
2428
|
+
var startOfDay = (d) => {
|
|
2429
|
+
const x = new Date(d);
|
|
2430
|
+
x.setHours(0, 0, 0, 0);
|
|
2431
|
+
return x;
|
|
2432
|
+
};
|
|
2433
|
+
var clampToDay = (d) => d ? startOfDay(d) : void 0;
|
|
2434
|
+
var addMonths = (date, n2) => {
|
|
2435
|
+
const d = new Date(date);
|
|
2436
|
+
d.setMonth(d.getMonth() + n2);
|
|
2437
|
+
return d;
|
|
2438
|
+
};
|
|
2439
|
+
var daysInMonth = (year, monthIndex) => new Date(year, monthIndex + 1, 0).getDate();
|
|
2440
|
+
function buildCalendarGrid(displayed, weekStartsOnMonday = true) {
|
|
2441
|
+
const year = displayed.getFullYear();
|
|
2442
|
+
const month = displayed.getMonth();
|
|
2443
|
+
const firstOfMonth = new Date(year, month, 1);
|
|
2444
|
+
const firstWeekday = firstOfMonth.getDay();
|
|
2445
|
+
const offset = weekStartsOnMonday ? firstWeekday === 0 ? 6 : firstWeekday - 1 : firstWeekday;
|
|
2446
|
+
const totalDays = daysInMonth(year, month);
|
|
2447
|
+
const prevMonth = addMonths(firstOfMonth, -1);
|
|
2448
|
+
const prevMonthDays = daysInMonth(prevMonth.getFullYear(), prevMonth.getMonth());
|
|
2449
|
+
const grid = [];
|
|
2450
|
+
for (let i2 = offset - 1; i2 >= 0; i2--) {
|
|
2451
|
+
const d = new Date(prevMonth.getFullYear(), prevMonth.getMonth(), prevMonthDays - i2);
|
|
2452
|
+
grid.push({ date: d, inCurrentMonth: false });
|
|
2453
|
+
}
|
|
2454
|
+
for (let d = 1; d <= totalDays; d++) {
|
|
2455
|
+
grid.push({ date: new Date(year, month, d), inCurrentMonth: true });
|
|
2456
|
+
}
|
|
2457
|
+
while (grid.length < 42) {
|
|
2458
|
+
const last = grid[grid.length - 1].date;
|
|
2459
|
+
const next = new Date(last);
|
|
2460
|
+
next.setDate(last.getDate() + 1);
|
|
2461
|
+
grid.push({ date: next, inCurrentMonth: false });
|
|
2462
|
+
}
|
|
2463
|
+
const rows = [];
|
|
2464
|
+
for (let r2 = 0; r2 < 6; r2++) rows.push(grid.slice(r2 * 7, r2 * 7 + 7));
|
|
2465
|
+
return rows;
|
|
2466
|
+
}
|
|
2467
|
+
function DatePicker({
|
|
2468
|
+
selectedDate,
|
|
2469
|
+
onDateSelect,
|
|
2470
|
+
callbacks,
|
|
2471
|
+
onMonthBackward,
|
|
2472
|
+
onMonthForward,
|
|
2473
|
+
variant,
|
|
2474
|
+
minDate,
|
|
2475
|
+
maxDate,
|
|
2476
|
+
disabledDates,
|
|
2477
|
+
className,
|
|
2478
|
+
...props
|
|
2479
|
+
}) {
|
|
2480
|
+
const today = React3.useMemo(() => startOfDay(/* @__PURE__ */ new Date()), []);
|
|
2481
|
+
const [displayed, setDisplayed] = React3.useState(
|
|
2482
|
+
selectedDate ? new Date(selectedDate) : /* @__PURE__ */ new Date()
|
|
2483
|
+
);
|
|
2484
|
+
minDate = clampToDay(minDate);
|
|
2485
|
+
maxDate = clampToDay(maxDate);
|
|
2486
|
+
const disabledSet = React3.useMemo(() => {
|
|
2487
|
+
const s2 = /* @__PURE__ */ new Set();
|
|
2488
|
+
disabledDates?.forEach((d) => s2.add(startOfDay(d).toISOString()));
|
|
2489
|
+
return s2;
|
|
2490
|
+
}, [disabledDates]);
|
|
2491
|
+
const displayYear = displayed.getFullYear();
|
|
2492
|
+
const displayMonth = displayed.getMonth();
|
|
2493
|
+
const monthLabel = callbacks?.monthLabel?.(displayYear, displayMonth) ?? new Intl.DateTimeFormat(void 0, { month: "short" }).format(displayed);
|
|
2494
|
+
const yearLabel = callbacks?.yearLabel?.(displayYear) ?? String(displayYear);
|
|
2495
|
+
const weekdays = React3.useMemo(() => {
|
|
2496
|
+
const labels = [];
|
|
2497
|
+
for (let i2 = 0; i2 < 7; i2++) {
|
|
2498
|
+
const idx = i2;
|
|
2499
|
+
const fallback = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"][idx];
|
|
2500
|
+
labels.push(callbacks?.weekdayLabel?.(idx) ?? fallback);
|
|
2501
|
+
}
|
|
2502
|
+
return labels;
|
|
2503
|
+
}, [callbacks]);
|
|
2504
|
+
const grid = React3.useMemo(() => buildCalendarGrid(displayed, true), [displayed]);
|
|
2505
|
+
const isDateDisabled = (date) => {
|
|
2506
|
+
const d = startOfDay(date);
|
|
2507
|
+
if (minDate && d < minDate) return true;
|
|
2508
|
+
if (maxDate && d > maxDate) return true;
|
|
2509
|
+
if (disabledSet.has(d.toISOString())) return true;
|
|
2510
|
+
return false;
|
|
2511
|
+
};
|
|
2512
|
+
return /* @__PURE__ */ jsxs("div", { className: cn2("min-w-[260px] w-[300px] p-3", className), ...props, children: [
|
|
2513
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-2", children: [
|
|
2514
|
+
/* @__PURE__ */ jsx(
|
|
2515
|
+
"button",
|
|
2516
|
+
{
|
|
2517
|
+
onClick: () => {
|
|
2518
|
+
setDisplayed(addMonths(displayed, -1));
|
|
2519
|
+
onMonthBackward?.();
|
|
2520
|
+
},
|
|
2521
|
+
className: cn2(
|
|
2522
|
+
buttonVariants3({ variant: variant?.chevrons ?? "outline" }),
|
|
2523
|
+
"inline-flex h-8 w-8 items-center justify-center p-0"
|
|
2524
|
+
),
|
|
2525
|
+
"aria-label": "Previous month",
|
|
2526
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4 opacity-70" })
|
|
2527
|
+
}
|
|
2528
|
+
),
|
|
2529
|
+
/* @__PURE__ */ jsxs("div", { className: "text-sm font-medium select-none", children: [
|
|
2530
|
+
monthLabel,
|
|
2531
|
+
" ",
|
|
2532
|
+
yearLabel
|
|
2533
|
+
] }),
|
|
2534
|
+
/* @__PURE__ */ jsx(
|
|
2535
|
+
"button",
|
|
2536
|
+
{
|
|
2537
|
+
onClick: () => {
|
|
2538
|
+
setDisplayed(addMonths(displayed, 1));
|
|
2539
|
+
onMonthForward?.();
|
|
2540
|
+
},
|
|
2541
|
+
className: cn2(
|
|
2542
|
+
buttonVariants3({ variant: variant?.chevrons ?? "outline" }),
|
|
2543
|
+
"inline-flex h-8 w-8 items-center justify-center p-0"
|
|
2544
|
+
),
|
|
2545
|
+
"aria-label": "Next month",
|
|
2546
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-70" })
|
|
2547
|
+
}
|
|
2548
|
+
)
|
|
2549
|
+
] }),
|
|
2550
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-7 text-[11px] text-muted-foreground mb-1", children: weekdays.map((w, i2) => /* @__PURE__ */ jsx("div", { className: "text-center py-1", children: w }, i2)) }),
|
|
2551
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-7 gap-1", children: grid.map(
|
|
2552
|
+
(row, r2) => row.map(({ date, inCurrentMonth }, c) => {
|
|
2553
|
+
const selected = selectedDate && isSameDay(date, selectedDate);
|
|
2554
|
+
const isToday = isSameDay(date, today);
|
|
2555
|
+
const disabled = isDateDisabled(date);
|
|
2556
|
+
let variantName = variant?.day?.main ?? "ghost";
|
|
2557
|
+
if (!inCurrentMonth) variantName = variant?.day?.outside ?? "ghost";
|
|
2558
|
+
if (isToday && !selected) variantName = variant?.day?.today ?? variantName;
|
|
2559
|
+
if (selected) variantName = variant?.day?.selected ?? "default";
|
|
2560
|
+
const label = callbacks?.dayLabel?.(date) ?? date.getDate();
|
|
2561
|
+
return /* @__PURE__ */ jsx(
|
|
2562
|
+
"button",
|
|
2563
|
+
{
|
|
2564
|
+
onClick: () => !disabled && onDateSelect?.(date),
|
|
2565
|
+
disabled: disabled || !inCurrentMonth,
|
|
2566
|
+
className: cn2(
|
|
2567
|
+
buttonVariants3({ variant: variantName }),
|
|
2568
|
+
"h-9 w-full p-0 text-sm font-normal",
|
|
2569
|
+
!inCurrentMonth && "opacity-50",
|
|
2570
|
+
selected && "aria-selected:opacity-100"
|
|
2571
|
+
),
|
|
2572
|
+
"aria-selected": selected,
|
|
2573
|
+
"aria-label": date.toDateString(),
|
|
2574
|
+
children: label
|
|
2575
|
+
},
|
|
2576
|
+
`${r2}-${c}`
|
|
2577
|
+
);
|
|
2578
|
+
})
|
|
2579
|
+
) })
|
|
2580
|
+
] });
|
|
2581
|
+
}
|
|
2582
|
+
var TagsInput = ({ value = [], onChange, onClear, error }) => {
|
|
2583
|
+
const [inputValue, setInputValue] = useState("");
|
|
2584
|
+
const addTag = (val) => {
|
|
2585
|
+
const trimmed = val.trim();
|
|
2586
|
+
if (!trimmed) return;
|
|
2587
|
+
if (value.includes(trimmed)) return;
|
|
2588
|
+
onChange([...value, trimmed]);
|
|
2589
|
+
setInputValue("");
|
|
2590
|
+
};
|
|
2591
|
+
const removeTag = (index) => {
|
|
2592
|
+
const newTags = value.filter((_, i2) => i2 !== index);
|
|
2593
|
+
onChange(newTags);
|
|
2594
|
+
};
|
|
2595
|
+
const handleKeyDown = (e2) => {
|
|
2596
|
+
if (e2.key === "Enter" || e2.key === ",") {
|
|
2597
|
+
e2.preventDefault();
|
|
2598
|
+
addTag(inputValue);
|
|
2599
|
+
}
|
|
2600
|
+
if (e2.key === "Backspace" && !inputValue) {
|
|
2601
|
+
removeTag(value.length - 1);
|
|
2602
|
+
}
|
|
2603
|
+
};
|
|
2604
|
+
return /* @__PURE__ */ jsxs(
|
|
2605
|
+
"div",
|
|
2606
|
+
{
|
|
2607
|
+
className: `flex items-center border rounded-md px-2 py-1 w-full min-h-[36px] focus-within:ring-2
|
|
2608
|
+
${error ? "border-red-500 focus-within:ring-red-500" : "border-gray-300 focus-within:ring-sus-green-1"}`,
|
|
2609
|
+
children: [
|
|
2610
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2 flex-1 items-center", children: [
|
|
2611
|
+
value.map((tag, i2) => /* @__PURE__ */ jsxs(
|
|
2612
|
+
"span",
|
|
2613
|
+
{
|
|
2614
|
+
className: "flex items-center gap-1 border border-[#41875C] bg-[#f7fcf9] px-2 py-0.5 rounded-2xl text-sm text-black",
|
|
2615
|
+
children: [
|
|
2616
|
+
/* @__PURE__ */ jsx(Tag, { className: "w-3 h-3 transform scale-x-[-1]" }),
|
|
2617
|
+
tag,
|
|
2618
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => removeTag(i2), className: "hover:text-red-500", children: /* @__PURE__ */ jsx(X, { className: "w-3 h-3" }) })
|
|
2619
|
+
]
|
|
2620
|
+
},
|
|
2621
|
+
i2
|
|
2622
|
+
)),
|
|
2623
|
+
/* @__PURE__ */ jsx(
|
|
2624
|
+
"input",
|
|
2625
|
+
{
|
|
2626
|
+
type: "text",
|
|
2627
|
+
value: inputValue,
|
|
2628
|
+
onChange: (e2) => setInputValue(e2.target.value),
|
|
2629
|
+
onKeyDown: handleKeyDown,
|
|
2630
|
+
className: "flex-1 border-none outline-none text-sm text-gray-400 placeholder:text-gray-400 border-1"
|
|
2631
|
+
}
|
|
2632
|
+
)
|
|
2633
|
+
] }),
|
|
2634
|
+
/* @__PURE__ */ jsx(Search, { className: "w-4 h-4 text-gray-400 mx-2" }),
|
|
2635
|
+
/* @__PURE__ */ jsx("span", { className: "right-2", children: /* @__PURE__ */ jsx(ClearButton, { onClick: onClear }) })
|
|
2636
|
+
]
|
|
2637
|
+
}
|
|
2638
|
+
);
|
|
2639
|
+
};
|
|
2640
|
+
var millisecondsInWeek = 6048e5;
|
|
2641
|
+
var millisecondsInDay = 864e5;
|
|
2642
|
+
var millisecondsInMinute = 6e4;
|
|
2643
|
+
var millisecondsInHour = 36e5;
|
|
2644
|
+
var constructFromSymbol = Symbol.for("constructDateFrom");
|
|
2645
|
+
|
|
2646
|
+
// node_modules/date-fns/constructFrom.js
|
|
2647
|
+
function constructFrom(date, value) {
|
|
2648
|
+
if (typeof date === "function") return date(value);
|
|
2649
|
+
if (date && typeof date === "object" && constructFromSymbol in date)
|
|
2650
|
+
return date[constructFromSymbol](value);
|
|
2651
|
+
if (date instanceof Date) return new date.constructor(value);
|
|
2652
|
+
return new Date(value);
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
// node_modules/date-fns/toDate.js
|
|
2656
|
+
function toDate(argument, context) {
|
|
2657
|
+
return constructFrom(context || argument, argument);
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
// node_modules/date-fns/_lib/defaultOptions.js
|
|
2661
|
+
var defaultOptions = {};
|
|
2662
|
+
function getDefaultOptions() {
|
|
2663
|
+
return defaultOptions;
|
|
2664
|
+
}
|
|
2665
|
+
|
|
2666
|
+
// node_modules/date-fns/startOfWeek.js
|
|
2667
|
+
function startOfWeek(date, options) {
|
|
2668
|
+
const defaultOptions2 = getDefaultOptions();
|
|
2669
|
+
const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
|
|
2670
|
+
const _date = toDate(date, options?.in);
|
|
2671
|
+
const day = _date.getDay();
|
|
2672
|
+
const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
|
|
2673
|
+
_date.setDate(_date.getDate() - diff);
|
|
2674
|
+
_date.setHours(0, 0, 0, 0);
|
|
2675
|
+
return _date;
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
// node_modules/date-fns/startOfISOWeek.js
|
|
2679
|
+
function startOfISOWeek(date, options) {
|
|
2680
|
+
return startOfWeek(date, { ...options, weekStartsOn: 1 });
|
|
2681
|
+
}
|
|
2682
|
+
|
|
2683
|
+
// node_modules/date-fns/getISOWeekYear.js
|
|
2684
|
+
function getISOWeekYear(date, options) {
|
|
2685
|
+
const _date = toDate(date, options?.in);
|
|
2686
|
+
const year = _date.getFullYear();
|
|
2687
|
+
const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
|
|
2688
|
+
fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
|
|
2689
|
+
fourthOfJanuaryOfNextYear.setHours(0, 0, 0, 0);
|
|
2690
|
+
const startOfNextYear = startOfISOWeek(fourthOfJanuaryOfNextYear);
|
|
2691
|
+
const fourthOfJanuaryOfThisYear = constructFrom(_date, 0);
|
|
2692
|
+
fourthOfJanuaryOfThisYear.setFullYear(year, 0, 4);
|
|
2693
|
+
fourthOfJanuaryOfThisYear.setHours(0, 0, 0, 0);
|
|
2694
|
+
const startOfThisYear = startOfISOWeek(fourthOfJanuaryOfThisYear);
|
|
2695
|
+
if (_date.getTime() >= startOfNextYear.getTime()) {
|
|
2696
|
+
return year + 1;
|
|
2697
|
+
} else if (_date.getTime() >= startOfThisYear.getTime()) {
|
|
2698
|
+
return year;
|
|
2699
|
+
} else {
|
|
2700
|
+
return year - 1;
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
|
|
2704
|
+
// node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js
|
|
2705
|
+
function getTimezoneOffsetInMilliseconds(date) {
|
|
2706
|
+
const _date = toDate(date);
|
|
2707
|
+
const utcDate = new Date(
|
|
2708
|
+
Date.UTC(
|
|
2709
|
+
_date.getFullYear(),
|
|
2710
|
+
_date.getMonth(),
|
|
2711
|
+
_date.getDate(),
|
|
2712
|
+
_date.getHours(),
|
|
2713
|
+
_date.getMinutes(),
|
|
2714
|
+
_date.getSeconds(),
|
|
2715
|
+
_date.getMilliseconds()
|
|
2716
|
+
)
|
|
2717
|
+
);
|
|
2718
|
+
utcDate.setUTCFullYear(_date.getFullYear());
|
|
2719
|
+
return +date - +utcDate;
|
|
2720
|
+
}
|
|
2721
|
+
|
|
2722
|
+
// node_modules/date-fns/_lib/normalizeDates.js
|
|
2723
|
+
function normalizeDates(context, ...dates) {
|
|
2724
|
+
const normalize = constructFrom.bind(
|
|
2725
|
+
null,
|
|
2726
|
+
dates.find((date) => typeof date === "object")
|
|
2727
|
+
);
|
|
2728
|
+
return dates.map(normalize);
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
// node_modules/date-fns/startOfDay.js
|
|
2732
|
+
function startOfDay2(date, options) {
|
|
2733
|
+
const _date = toDate(date, options?.in);
|
|
2734
|
+
_date.setHours(0, 0, 0, 0);
|
|
2735
|
+
return _date;
|
|
2736
|
+
}
|
|
2737
|
+
|
|
2738
|
+
// node_modules/date-fns/differenceInCalendarDays.js
|
|
2739
|
+
function differenceInCalendarDays(laterDate, earlierDate, options) {
|
|
2740
|
+
const [laterDate_, earlierDate_] = normalizeDates(
|
|
2741
|
+
options?.in,
|
|
2742
|
+
laterDate,
|
|
2743
|
+
earlierDate
|
|
2744
|
+
);
|
|
2745
|
+
const laterStartOfDay = startOfDay2(laterDate_);
|
|
2746
|
+
const earlierStartOfDay = startOfDay2(earlierDate_);
|
|
2747
|
+
const laterTimestamp = +laterStartOfDay - getTimezoneOffsetInMilliseconds(laterStartOfDay);
|
|
2748
|
+
const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
|
|
2749
|
+
return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
|
|
2750
|
+
}
|
|
2751
|
+
|
|
2752
|
+
// node_modules/date-fns/startOfISOWeekYear.js
|
|
2753
|
+
function startOfISOWeekYear(date, options) {
|
|
2754
|
+
const year = getISOWeekYear(date, options);
|
|
2755
|
+
const fourthOfJanuary = constructFrom(date, 0);
|
|
2756
|
+
fourthOfJanuary.setFullYear(year, 0, 4);
|
|
2757
|
+
fourthOfJanuary.setHours(0, 0, 0, 0);
|
|
2758
|
+
return startOfISOWeek(fourthOfJanuary);
|
|
2759
|
+
}
|
|
2760
|
+
|
|
2761
|
+
// node_modules/date-fns/isDate.js
|
|
2762
|
+
function isDate(value) {
|
|
2763
|
+
return value instanceof Date || typeof value === "object" && Object.prototype.toString.call(value) === "[object Date]";
|
|
2764
|
+
}
|
|
2765
|
+
|
|
2766
|
+
// node_modules/date-fns/isValid.js
|
|
2767
|
+
function isValid(date) {
|
|
2768
|
+
return !(!isDate(date) && typeof date !== "number" || isNaN(+toDate(date)));
|
|
2769
|
+
}
|
|
2770
|
+
|
|
2771
|
+
// node_modules/date-fns/startOfYear.js
|
|
2772
|
+
function startOfYear(date, options) {
|
|
2773
|
+
const date_ = toDate(date, options?.in);
|
|
2774
|
+
date_.setFullYear(date_.getFullYear(), 0, 1);
|
|
2775
|
+
date_.setHours(0, 0, 0, 0);
|
|
2776
|
+
return date_;
|
|
2777
|
+
}
|
|
2778
|
+
|
|
2779
|
+
// node_modules/date-fns/locale/en-US/_lib/formatDistance.js
|
|
2780
|
+
var formatDistanceLocale = {
|
|
2781
|
+
lessThanXSeconds: {
|
|
2782
|
+
one: "less than a second",
|
|
2783
|
+
other: "less than {{count}} seconds"
|
|
2784
|
+
},
|
|
2785
|
+
xSeconds: {
|
|
2786
|
+
one: "1 second",
|
|
2787
|
+
other: "{{count}} seconds"
|
|
2788
|
+
},
|
|
2789
|
+
halfAMinute: "half a minute",
|
|
2790
|
+
lessThanXMinutes: {
|
|
2791
|
+
one: "less than a minute",
|
|
2792
|
+
other: "less than {{count}} minutes"
|
|
2793
|
+
},
|
|
2794
|
+
xMinutes: {
|
|
2795
|
+
one: "1 minute",
|
|
2796
|
+
other: "{{count}} minutes"
|
|
2797
|
+
},
|
|
2798
|
+
aboutXHours: {
|
|
2799
|
+
one: "about 1 hour",
|
|
2800
|
+
other: "about {{count}} hours"
|
|
2801
|
+
},
|
|
2802
|
+
xHours: {
|
|
2803
|
+
one: "1 hour",
|
|
2804
|
+
other: "{{count}} hours"
|
|
2805
|
+
},
|
|
2806
|
+
xDays: {
|
|
2807
|
+
one: "1 day",
|
|
2808
|
+
other: "{{count}} days"
|
|
2809
|
+
},
|
|
2810
|
+
aboutXWeeks: {
|
|
2811
|
+
one: "about 1 week",
|
|
2812
|
+
other: "about {{count}} weeks"
|
|
2813
|
+
},
|
|
2814
|
+
xWeeks: {
|
|
2815
|
+
one: "1 week",
|
|
2816
|
+
other: "{{count}} weeks"
|
|
2817
|
+
},
|
|
2818
|
+
aboutXMonths: {
|
|
2819
|
+
one: "about 1 month",
|
|
2820
|
+
other: "about {{count}} months"
|
|
2821
|
+
},
|
|
2822
|
+
xMonths: {
|
|
2823
|
+
one: "1 month",
|
|
2824
|
+
other: "{{count}} months"
|
|
2825
|
+
},
|
|
2826
|
+
aboutXYears: {
|
|
2827
|
+
one: "about 1 year",
|
|
2828
|
+
other: "about {{count}} years"
|
|
2829
|
+
},
|
|
2830
|
+
xYears: {
|
|
2831
|
+
one: "1 year",
|
|
2832
|
+
other: "{{count}} years"
|
|
2833
|
+
},
|
|
2834
|
+
overXYears: {
|
|
2835
|
+
one: "over 1 year",
|
|
2836
|
+
other: "over {{count}} years"
|
|
2837
|
+
},
|
|
2838
|
+
almostXYears: {
|
|
2839
|
+
one: "almost 1 year",
|
|
2840
|
+
other: "almost {{count}} years"
|
|
2841
|
+
}
|
|
2842
|
+
};
|
|
2843
|
+
var formatDistance = (token, count, options) => {
|
|
2844
|
+
let result;
|
|
2845
|
+
const tokenValue = formatDistanceLocale[token];
|
|
2846
|
+
if (typeof tokenValue === "string") {
|
|
2847
|
+
result = tokenValue;
|
|
2848
|
+
} else if (count === 1) {
|
|
2849
|
+
result = tokenValue.one;
|
|
2850
|
+
} else {
|
|
2851
|
+
result = tokenValue.other.replace("{{count}}", count.toString());
|
|
2852
|
+
}
|
|
2853
|
+
if (options?.addSuffix) {
|
|
2854
|
+
if (options.comparison && options.comparison > 0) {
|
|
2855
|
+
return "in " + result;
|
|
2856
|
+
} else {
|
|
2857
|
+
return result + " ago";
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
return result;
|
|
2861
|
+
};
|
|
2862
|
+
|
|
2863
|
+
// node_modules/date-fns/locale/_lib/buildFormatLongFn.js
|
|
2864
|
+
function buildFormatLongFn(args) {
|
|
2865
|
+
return (options = {}) => {
|
|
2866
|
+
const width = options.width ? String(options.width) : args.defaultWidth;
|
|
2867
|
+
const format2 = args.formats[width] || args.formats[args.defaultWidth];
|
|
2868
|
+
return format2;
|
|
2869
|
+
};
|
|
2870
|
+
}
|
|
2871
|
+
|
|
2872
|
+
// node_modules/date-fns/locale/en-US/_lib/formatLong.js
|
|
2873
|
+
var dateFormats = {
|
|
2874
|
+
full: "EEEE, MMMM do, y",
|
|
2875
|
+
long: "MMMM do, y",
|
|
2876
|
+
medium: "MMM d, y",
|
|
2877
|
+
short: "MM/dd/yyyy"
|
|
2878
|
+
};
|
|
2879
|
+
var timeFormats = {
|
|
2880
|
+
full: "h:mm:ss a zzzz",
|
|
2881
|
+
long: "h:mm:ss a z",
|
|
2882
|
+
medium: "h:mm:ss a",
|
|
2883
|
+
short: "h:mm a"
|
|
2884
|
+
};
|
|
2885
|
+
var dateTimeFormats = {
|
|
2886
|
+
full: "{{date}} 'at' {{time}}",
|
|
2887
|
+
long: "{{date}} 'at' {{time}}",
|
|
2888
|
+
medium: "{{date}}, {{time}}",
|
|
2889
|
+
short: "{{date}}, {{time}}"
|
|
2890
|
+
};
|
|
2891
|
+
var formatLong = {
|
|
2892
|
+
date: buildFormatLongFn({
|
|
2893
|
+
formats: dateFormats,
|
|
2894
|
+
defaultWidth: "full"
|
|
2895
|
+
}),
|
|
2896
|
+
time: buildFormatLongFn({
|
|
2897
|
+
formats: timeFormats,
|
|
2898
|
+
defaultWidth: "full"
|
|
2899
|
+
}),
|
|
2900
|
+
dateTime: buildFormatLongFn({
|
|
2901
|
+
formats: dateTimeFormats,
|
|
2902
|
+
defaultWidth: "full"
|
|
2903
|
+
})
|
|
2904
|
+
};
|
|
2905
|
+
|
|
2906
|
+
// node_modules/date-fns/locale/en-US/_lib/formatRelative.js
|
|
2907
|
+
var formatRelativeLocale = {
|
|
2908
|
+
lastWeek: "'last' eeee 'at' p",
|
|
2909
|
+
yesterday: "'yesterday at' p",
|
|
2910
|
+
today: "'today at' p",
|
|
2911
|
+
tomorrow: "'tomorrow at' p",
|
|
2912
|
+
nextWeek: "eeee 'at' p",
|
|
2913
|
+
other: "P"
|
|
2914
|
+
};
|
|
2915
|
+
var formatRelative = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
|
|
2916
|
+
|
|
2917
|
+
// node_modules/date-fns/locale/_lib/buildLocalizeFn.js
|
|
2918
|
+
function buildLocalizeFn(args) {
|
|
2919
|
+
return (value, options) => {
|
|
2920
|
+
const context = options?.context ? String(options.context) : "standalone";
|
|
2921
|
+
let valuesArray;
|
|
2922
|
+
if (context === "formatting" && args.formattingValues) {
|
|
2923
|
+
const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
|
|
2924
|
+
const width = options?.width ? String(options.width) : defaultWidth;
|
|
2925
|
+
valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
|
|
2926
|
+
} else {
|
|
2927
|
+
const defaultWidth = args.defaultWidth;
|
|
2928
|
+
const width = options?.width ? String(options.width) : args.defaultWidth;
|
|
2929
|
+
valuesArray = args.values[width] || args.values[defaultWidth];
|
|
2930
|
+
}
|
|
2931
|
+
const index = args.argumentCallback ? args.argumentCallback(value) : value;
|
|
2932
|
+
return valuesArray[index];
|
|
2933
|
+
};
|
|
2934
|
+
}
|
|
2935
|
+
|
|
2936
|
+
// node_modules/date-fns/locale/en-US/_lib/localize.js
|
|
2937
|
+
var eraValues = {
|
|
2938
|
+
narrow: ["B", "A"],
|
|
2939
|
+
abbreviated: ["BC", "AD"],
|
|
2940
|
+
wide: ["Before Christ", "Anno Domini"]
|
|
2941
|
+
};
|
|
2942
|
+
var quarterValues = {
|
|
2943
|
+
narrow: ["1", "2", "3", "4"],
|
|
2944
|
+
abbreviated: ["Q1", "Q2", "Q3", "Q4"],
|
|
2945
|
+
wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
|
|
2946
|
+
};
|
|
2947
|
+
var monthValues = {
|
|
2948
|
+
narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
|
|
2949
|
+
abbreviated: [
|
|
2950
|
+
"Jan",
|
|
2951
|
+
"Feb",
|
|
2952
|
+
"Mar",
|
|
2953
|
+
"Apr",
|
|
2954
|
+
"May",
|
|
2955
|
+
"Jun",
|
|
2956
|
+
"Jul",
|
|
2957
|
+
"Aug",
|
|
2958
|
+
"Sep",
|
|
2959
|
+
"Oct",
|
|
2960
|
+
"Nov",
|
|
2961
|
+
"Dec"
|
|
2962
|
+
],
|
|
2963
|
+
wide: [
|
|
2964
|
+
"January",
|
|
2965
|
+
"February",
|
|
2966
|
+
"March",
|
|
2967
|
+
"April",
|
|
2968
|
+
"May",
|
|
2969
|
+
"June",
|
|
2970
|
+
"July",
|
|
2971
|
+
"August",
|
|
2972
|
+
"September",
|
|
2973
|
+
"October",
|
|
2974
|
+
"November",
|
|
2975
|
+
"December"
|
|
2976
|
+
]
|
|
2977
|
+
};
|
|
2978
|
+
var dayValues = {
|
|
2979
|
+
narrow: ["S", "M", "T", "W", "T", "F", "S"],
|
|
2980
|
+
short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
|
|
2981
|
+
abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
2982
|
+
wide: [
|
|
2983
|
+
"Sunday",
|
|
2984
|
+
"Monday",
|
|
2985
|
+
"Tuesday",
|
|
2986
|
+
"Wednesday",
|
|
2987
|
+
"Thursday",
|
|
2988
|
+
"Friday",
|
|
2989
|
+
"Saturday"
|
|
2990
|
+
]
|
|
2991
|
+
};
|
|
2992
|
+
var dayPeriodValues = {
|
|
2993
|
+
narrow: {
|
|
2994
|
+
am: "a",
|
|
2995
|
+
pm: "p",
|
|
2996
|
+
midnight: "mi",
|
|
2997
|
+
noon: "n",
|
|
2998
|
+
morning: "morning",
|
|
2999
|
+
afternoon: "afternoon",
|
|
3000
|
+
evening: "evening",
|
|
3001
|
+
night: "night"
|
|
3002
|
+
},
|
|
3003
|
+
abbreviated: {
|
|
3004
|
+
am: "AM",
|
|
3005
|
+
pm: "PM",
|
|
3006
|
+
midnight: "midnight",
|
|
3007
|
+
noon: "noon",
|
|
3008
|
+
morning: "morning",
|
|
3009
|
+
afternoon: "afternoon",
|
|
3010
|
+
evening: "evening",
|
|
3011
|
+
night: "night"
|
|
3012
|
+
},
|
|
3013
|
+
wide: {
|
|
3014
|
+
am: "a.m.",
|
|
3015
|
+
pm: "p.m.",
|
|
3016
|
+
midnight: "midnight",
|
|
3017
|
+
noon: "noon",
|
|
3018
|
+
morning: "morning",
|
|
3019
|
+
afternoon: "afternoon",
|
|
3020
|
+
evening: "evening",
|
|
3021
|
+
night: "night"
|
|
3022
|
+
}
|
|
3023
|
+
};
|
|
3024
|
+
var formattingDayPeriodValues = {
|
|
3025
|
+
narrow: {
|
|
3026
|
+
am: "a",
|
|
3027
|
+
pm: "p",
|
|
3028
|
+
midnight: "mi",
|
|
3029
|
+
noon: "n",
|
|
3030
|
+
morning: "in the morning",
|
|
3031
|
+
afternoon: "in the afternoon",
|
|
3032
|
+
evening: "in the evening",
|
|
3033
|
+
night: "at night"
|
|
3034
|
+
},
|
|
3035
|
+
abbreviated: {
|
|
3036
|
+
am: "AM",
|
|
3037
|
+
pm: "PM",
|
|
3038
|
+
midnight: "midnight",
|
|
3039
|
+
noon: "noon",
|
|
3040
|
+
morning: "in the morning",
|
|
3041
|
+
afternoon: "in the afternoon",
|
|
3042
|
+
evening: "in the evening",
|
|
3043
|
+
night: "at night"
|
|
3044
|
+
},
|
|
3045
|
+
wide: {
|
|
3046
|
+
am: "a.m.",
|
|
3047
|
+
pm: "p.m.",
|
|
3048
|
+
midnight: "midnight",
|
|
3049
|
+
noon: "noon",
|
|
3050
|
+
morning: "in the morning",
|
|
3051
|
+
afternoon: "in the afternoon",
|
|
3052
|
+
evening: "in the evening",
|
|
3053
|
+
night: "at night"
|
|
3054
|
+
}
|
|
3055
|
+
};
|
|
3056
|
+
var ordinalNumber = (dirtyNumber, _options) => {
|
|
3057
|
+
const number = Number(dirtyNumber);
|
|
3058
|
+
const rem100 = number % 100;
|
|
3059
|
+
if (rem100 > 20 || rem100 < 10) {
|
|
3060
|
+
switch (rem100 % 10) {
|
|
3061
|
+
case 1:
|
|
3062
|
+
return number + "st";
|
|
3063
|
+
case 2:
|
|
3064
|
+
return number + "nd";
|
|
3065
|
+
case 3:
|
|
3066
|
+
return number + "rd";
|
|
3067
|
+
}
|
|
3068
|
+
}
|
|
3069
|
+
return number + "th";
|
|
3070
|
+
};
|
|
3071
|
+
var localize = {
|
|
3072
|
+
ordinalNumber,
|
|
3073
|
+
era: buildLocalizeFn({
|
|
3074
|
+
values: eraValues,
|
|
3075
|
+
defaultWidth: "wide"
|
|
3076
|
+
}),
|
|
3077
|
+
quarter: buildLocalizeFn({
|
|
3078
|
+
values: quarterValues,
|
|
3079
|
+
defaultWidth: "wide",
|
|
3080
|
+
argumentCallback: (quarter) => quarter - 1
|
|
3081
|
+
}),
|
|
3082
|
+
month: buildLocalizeFn({
|
|
3083
|
+
values: monthValues,
|
|
3084
|
+
defaultWidth: "wide"
|
|
3085
|
+
}),
|
|
3086
|
+
day: buildLocalizeFn({
|
|
3087
|
+
values: dayValues,
|
|
3088
|
+
defaultWidth: "wide"
|
|
3089
|
+
}),
|
|
3090
|
+
dayPeriod: buildLocalizeFn({
|
|
3091
|
+
values: dayPeriodValues,
|
|
3092
|
+
defaultWidth: "wide",
|
|
3093
|
+
formattingValues: formattingDayPeriodValues,
|
|
3094
|
+
defaultFormattingWidth: "wide"
|
|
3095
|
+
})
|
|
3096
|
+
};
|
|
3097
|
+
|
|
3098
|
+
// node_modules/date-fns/locale/_lib/buildMatchFn.js
|
|
3099
|
+
function buildMatchFn(args) {
|
|
3100
|
+
return (string, options = {}) => {
|
|
3101
|
+
const width = options.width;
|
|
3102
|
+
const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
|
|
3103
|
+
const matchResult = string.match(matchPattern);
|
|
3104
|
+
if (!matchResult) {
|
|
3105
|
+
return null;
|
|
3106
|
+
}
|
|
3107
|
+
const matchedString = matchResult[0];
|
|
3108
|
+
const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
|
|
3109
|
+
const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
|
|
3110
|
+
// [TODO] -- I challenge you to fix the type
|
|
3111
|
+
findKey(parsePatterns, (pattern) => pattern.test(matchedString))
|
|
3112
|
+
);
|
|
3113
|
+
let value;
|
|
3114
|
+
value = args.valueCallback ? args.valueCallback(key) : key;
|
|
3115
|
+
value = options.valueCallback ? (
|
|
3116
|
+
// [TODO] -- I challenge you to fix the type
|
|
3117
|
+
options.valueCallback(value)
|
|
3118
|
+
) : value;
|
|
3119
|
+
const rest = string.slice(matchedString.length);
|
|
3120
|
+
return { value, rest };
|
|
3121
|
+
};
|
|
3122
|
+
}
|
|
3123
|
+
function findKey(object, predicate) {
|
|
3124
|
+
for (const key in object) {
|
|
3125
|
+
if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
|
|
3126
|
+
return key;
|
|
3127
|
+
}
|
|
3128
|
+
}
|
|
3129
|
+
return void 0;
|
|
3130
|
+
}
|
|
3131
|
+
function findIndex(array, predicate) {
|
|
3132
|
+
for (let key = 0; key < array.length; key++) {
|
|
3133
|
+
if (predicate(array[key])) {
|
|
3134
|
+
return key;
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
return void 0;
|
|
3138
|
+
}
|
|
3139
|
+
|
|
3140
|
+
// node_modules/date-fns/locale/_lib/buildMatchPatternFn.js
|
|
3141
|
+
function buildMatchPatternFn(args) {
|
|
3142
|
+
return (string, options = {}) => {
|
|
3143
|
+
const matchResult = string.match(args.matchPattern);
|
|
3144
|
+
if (!matchResult) return null;
|
|
3145
|
+
const matchedString = matchResult[0];
|
|
3146
|
+
const parseResult = string.match(args.parsePattern);
|
|
3147
|
+
if (!parseResult) return null;
|
|
3148
|
+
let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
|
|
3149
|
+
value = options.valueCallback ? options.valueCallback(value) : value;
|
|
3150
|
+
const rest = string.slice(matchedString.length);
|
|
3151
|
+
return { value, rest };
|
|
3152
|
+
};
|
|
3153
|
+
}
|
|
3154
|
+
|
|
3155
|
+
// node_modules/date-fns/locale/en-US/_lib/match.js
|
|
3156
|
+
var matchOrdinalNumberPattern = /^(\d+)(th|st|nd|rd)?/i;
|
|
3157
|
+
var parseOrdinalNumberPattern = /\d+/i;
|
|
3158
|
+
var matchEraPatterns = {
|
|
3159
|
+
narrow: /^(b|a)/i,
|
|
3160
|
+
abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
|
|
3161
|
+
wide: /^(before christ|before common era|anno domini|common era)/i
|
|
3162
|
+
};
|
|
3163
|
+
var parseEraPatterns = {
|
|
3164
|
+
any: [/^b/i, /^(a|c)/i]
|
|
3165
|
+
};
|
|
3166
|
+
var matchQuarterPatterns = {
|
|
3167
|
+
narrow: /^[1234]/i,
|
|
3168
|
+
abbreviated: /^q[1234]/i,
|
|
3169
|
+
wide: /^[1234](th|st|nd|rd)? quarter/i
|
|
3170
|
+
};
|
|
3171
|
+
var parseQuarterPatterns = {
|
|
3172
|
+
any: [/1/i, /2/i, /3/i, /4/i]
|
|
3173
|
+
};
|
|
3174
|
+
var matchMonthPatterns = {
|
|
3175
|
+
narrow: /^[jfmasond]/i,
|
|
3176
|
+
abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
|
|
3177
|
+
wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
|
|
3178
|
+
};
|
|
3179
|
+
var parseMonthPatterns = {
|
|
3180
|
+
narrow: [
|
|
3181
|
+
/^j/i,
|
|
3182
|
+
/^f/i,
|
|
3183
|
+
/^m/i,
|
|
3184
|
+
/^a/i,
|
|
3185
|
+
/^m/i,
|
|
3186
|
+
/^j/i,
|
|
3187
|
+
/^j/i,
|
|
3188
|
+
/^a/i,
|
|
3189
|
+
/^s/i,
|
|
3190
|
+
/^o/i,
|
|
3191
|
+
/^n/i,
|
|
3192
|
+
/^d/i
|
|
3193
|
+
],
|
|
3194
|
+
any: [
|
|
3195
|
+
/^ja/i,
|
|
3196
|
+
/^f/i,
|
|
3197
|
+
/^mar/i,
|
|
3198
|
+
/^ap/i,
|
|
3199
|
+
/^may/i,
|
|
3200
|
+
/^jun/i,
|
|
3201
|
+
/^jul/i,
|
|
3202
|
+
/^au/i,
|
|
3203
|
+
/^s/i,
|
|
3204
|
+
/^o/i,
|
|
3205
|
+
/^n/i,
|
|
3206
|
+
/^d/i
|
|
3207
|
+
]
|
|
3208
|
+
};
|
|
3209
|
+
var matchDayPatterns = {
|
|
3210
|
+
narrow: /^[smtwf]/i,
|
|
3211
|
+
short: /^(su|mo|tu|we|th|fr|sa)/i,
|
|
3212
|
+
abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
|
|
3213
|
+
wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
|
|
3214
|
+
};
|
|
3215
|
+
var parseDayPatterns = {
|
|
3216
|
+
narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
|
|
3217
|
+
any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
|
|
3218
|
+
};
|
|
3219
|
+
var matchDayPeriodPatterns = {
|
|
3220
|
+
narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
|
|
3221
|
+
any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
|
|
3222
|
+
};
|
|
3223
|
+
var parseDayPeriodPatterns = {
|
|
3224
|
+
any: {
|
|
3225
|
+
am: /^a/i,
|
|
3226
|
+
pm: /^p/i,
|
|
3227
|
+
midnight: /^mi/i,
|
|
3228
|
+
noon: /^no/i,
|
|
3229
|
+
morning: /morning/i,
|
|
3230
|
+
afternoon: /afternoon/i,
|
|
3231
|
+
evening: /evening/i,
|
|
3232
|
+
night: /night/i
|
|
3233
|
+
}
|
|
3234
|
+
};
|
|
3235
|
+
var match = {
|
|
3236
|
+
ordinalNumber: buildMatchPatternFn({
|
|
3237
|
+
matchPattern: matchOrdinalNumberPattern,
|
|
3238
|
+
parsePattern: parseOrdinalNumberPattern,
|
|
3239
|
+
valueCallback: (value) => parseInt(value, 10)
|
|
3240
|
+
}),
|
|
3241
|
+
era: buildMatchFn({
|
|
3242
|
+
matchPatterns: matchEraPatterns,
|
|
3243
|
+
defaultMatchWidth: "wide",
|
|
3244
|
+
parsePatterns: parseEraPatterns,
|
|
3245
|
+
defaultParseWidth: "any"
|
|
3246
|
+
}),
|
|
3247
|
+
quarter: buildMatchFn({
|
|
3248
|
+
matchPatterns: matchQuarterPatterns,
|
|
3249
|
+
defaultMatchWidth: "wide",
|
|
3250
|
+
parsePatterns: parseQuarterPatterns,
|
|
3251
|
+
defaultParseWidth: "any",
|
|
3252
|
+
valueCallback: (index) => index + 1
|
|
3253
|
+
}),
|
|
3254
|
+
month: buildMatchFn({
|
|
3255
|
+
matchPatterns: matchMonthPatterns,
|
|
3256
|
+
defaultMatchWidth: "wide",
|
|
3257
|
+
parsePatterns: parseMonthPatterns,
|
|
3258
|
+
defaultParseWidth: "any"
|
|
3259
|
+
}),
|
|
3260
|
+
day: buildMatchFn({
|
|
3261
|
+
matchPatterns: matchDayPatterns,
|
|
3262
|
+
defaultMatchWidth: "wide",
|
|
3263
|
+
parsePatterns: parseDayPatterns,
|
|
3264
|
+
defaultParseWidth: "any"
|
|
3265
|
+
}),
|
|
3266
|
+
dayPeriod: buildMatchFn({
|
|
3267
|
+
matchPatterns: matchDayPeriodPatterns,
|
|
3268
|
+
defaultMatchWidth: "any",
|
|
3269
|
+
parsePatterns: parseDayPeriodPatterns,
|
|
3270
|
+
defaultParseWidth: "any"
|
|
3271
|
+
})
|
|
3272
|
+
};
|
|
3273
|
+
|
|
3274
|
+
// node_modules/date-fns/locale/en-US.js
|
|
3275
|
+
var enUS = {
|
|
3276
|
+
code: "en-US",
|
|
3277
|
+
formatDistance,
|
|
3278
|
+
formatLong,
|
|
3279
|
+
formatRelative,
|
|
3280
|
+
localize,
|
|
3281
|
+
match,
|
|
3282
|
+
options: {
|
|
3283
|
+
weekStartsOn: 0,
|
|
3284
|
+
firstWeekContainsDate: 1
|
|
3285
|
+
}
|
|
3286
|
+
};
|
|
3287
|
+
|
|
3288
|
+
// node_modules/date-fns/getDayOfYear.js
|
|
3289
|
+
function getDayOfYear(date, options) {
|
|
3290
|
+
const _date = toDate(date, options?.in);
|
|
3291
|
+
const diff = differenceInCalendarDays(_date, startOfYear(_date));
|
|
3292
|
+
const dayOfYear = diff + 1;
|
|
3293
|
+
return dayOfYear;
|
|
3294
|
+
}
|
|
3295
|
+
|
|
3296
|
+
// node_modules/date-fns/getISOWeek.js
|
|
3297
|
+
function getISOWeek(date, options) {
|
|
3298
|
+
const _date = toDate(date, options?.in);
|
|
3299
|
+
const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
|
|
3300
|
+
return Math.round(diff / millisecondsInWeek) + 1;
|
|
3301
|
+
}
|
|
3302
|
+
|
|
3303
|
+
// node_modules/date-fns/getWeekYear.js
|
|
3304
|
+
function getWeekYear(date, options) {
|
|
3305
|
+
const _date = toDate(date, options?.in);
|
|
3306
|
+
const year = _date.getFullYear();
|
|
3307
|
+
const defaultOptions2 = getDefaultOptions();
|
|
3308
|
+
const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
|
|
3309
|
+
const firstWeekOfNextYear = constructFrom(options?.in || date, 0);
|
|
3310
|
+
firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
|
|
3311
|
+
firstWeekOfNextYear.setHours(0, 0, 0, 0);
|
|
3312
|
+
const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
|
|
3313
|
+
const firstWeekOfThisYear = constructFrom(options?.in || date, 0);
|
|
3314
|
+
firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
|
|
3315
|
+
firstWeekOfThisYear.setHours(0, 0, 0, 0);
|
|
3316
|
+
const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
|
|
3317
|
+
if (+_date >= +startOfNextYear) {
|
|
3318
|
+
return year + 1;
|
|
3319
|
+
} else if (+_date >= +startOfThisYear) {
|
|
3320
|
+
return year;
|
|
3321
|
+
} else {
|
|
3322
|
+
return year - 1;
|
|
3323
|
+
}
|
|
3324
|
+
}
|
|
3325
|
+
|
|
3326
|
+
// node_modules/date-fns/startOfWeekYear.js
|
|
3327
|
+
function startOfWeekYear(date, options) {
|
|
3328
|
+
const defaultOptions2 = getDefaultOptions();
|
|
3329
|
+
const firstWeekContainsDate = options?.firstWeekContainsDate ?? options?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
|
|
3330
|
+
const year = getWeekYear(date, options);
|
|
3331
|
+
const firstWeek = constructFrom(options?.in || date, 0);
|
|
3332
|
+
firstWeek.setFullYear(year, 0, firstWeekContainsDate);
|
|
3333
|
+
firstWeek.setHours(0, 0, 0, 0);
|
|
3334
|
+
const _date = startOfWeek(firstWeek, options);
|
|
3335
|
+
return _date;
|
|
3336
|
+
}
|
|
3337
|
+
|
|
3338
|
+
// node_modules/date-fns/getWeek.js
|
|
3339
|
+
function getWeek(date, options) {
|
|
3340
|
+
const _date = toDate(date, options?.in);
|
|
3341
|
+
const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
|
|
3342
|
+
return Math.round(diff / millisecondsInWeek) + 1;
|
|
3343
|
+
}
|
|
3344
|
+
|
|
3345
|
+
// node_modules/date-fns/_lib/addLeadingZeros.js
|
|
3346
|
+
function addLeadingZeros(number, targetLength) {
|
|
3347
|
+
const sign = number < 0 ? "-" : "";
|
|
3348
|
+
const output = Math.abs(number).toString().padStart(targetLength, "0");
|
|
3349
|
+
return sign + output;
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3352
|
+
// node_modules/date-fns/_lib/format/lightFormatters.js
|
|
3353
|
+
var lightFormatters = {
|
|
3354
|
+
// Year
|
|
3355
|
+
y(date, token) {
|
|
3356
|
+
const signedYear = date.getFullYear();
|
|
3357
|
+
const year = signedYear > 0 ? signedYear : 1 - signedYear;
|
|
3358
|
+
return addLeadingZeros(token === "yy" ? year % 100 : year, token.length);
|
|
3359
|
+
},
|
|
3360
|
+
// Month
|
|
3361
|
+
M(date, token) {
|
|
3362
|
+
const month = date.getMonth();
|
|
3363
|
+
return token === "M" ? String(month + 1) : addLeadingZeros(month + 1, 2);
|
|
3364
|
+
},
|
|
3365
|
+
// Day of the month
|
|
3366
|
+
d(date, token) {
|
|
3367
|
+
return addLeadingZeros(date.getDate(), token.length);
|
|
3368
|
+
},
|
|
3369
|
+
// AM or PM
|
|
3370
|
+
a(date, token) {
|
|
3371
|
+
const dayPeriodEnumValue = date.getHours() / 12 >= 1 ? "pm" : "am";
|
|
3372
|
+
switch (token) {
|
|
3373
|
+
case "a":
|
|
3374
|
+
case "aa":
|
|
3375
|
+
return dayPeriodEnumValue.toUpperCase();
|
|
3376
|
+
case "aaa":
|
|
3377
|
+
return dayPeriodEnumValue;
|
|
3378
|
+
case "aaaaa":
|
|
3379
|
+
return dayPeriodEnumValue[0];
|
|
3380
|
+
case "aaaa":
|
|
3381
|
+
default:
|
|
3382
|
+
return dayPeriodEnumValue === "am" ? "a.m." : "p.m.";
|
|
3383
|
+
}
|
|
3384
|
+
},
|
|
3385
|
+
// Hour [1-12]
|
|
3386
|
+
h(date, token) {
|
|
3387
|
+
return addLeadingZeros(date.getHours() % 12 || 12, token.length);
|
|
3388
|
+
},
|
|
3389
|
+
// Hour [0-23]
|
|
3390
|
+
H(date, token) {
|
|
3391
|
+
return addLeadingZeros(date.getHours(), token.length);
|
|
3392
|
+
},
|
|
3393
|
+
// Minute
|
|
3394
|
+
m(date, token) {
|
|
3395
|
+
return addLeadingZeros(date.getMinutes(), token.length);
|
|
3396
|
+
},
|
|
3397
|
+
// Second
|
|
3398
|
+
s(date, token) {
|
|
3399
|
+
return addLeadingZeros(date.getSeconds(), token.length);
|
|
3400
|
+
},
|
|
3401
|
+
// Fraction of second
|
|
3402
|
+
S(date, token) {
|
|
3403
|
+
const numberOfDigits = token.length;
|
|
3404
|
+
const milliseconds = date.getMilliseconds();
|
|
3405
|
+
const fractionalSeconds = Math.trunc(
|
|
3406
|
+
milliseconds * Math.pow(10, numberOfDigits - 3)
|
|
3407
|
+
);
|
|
3408
|
+
return addLeadingZeros(fractionalSeconds, token.length);
|
|
3409
|
+
}
|
|
3410
|
+
};
|
|
3411
|
+
|
|
3412
|
+
// node_modules/date-fns/_lib/format/formatters.js
|
|
3413
|
+
var dayPeriodEnum = {
|
|
3414
|
+
midnight: "midnight",
|
|
3415
|
+
noon: "noon",
|
|
3416
|
+
morning: "morning",
|
|
3417
|
+
afternoon: "afternoon",
|
|
3418
|
+
evening: "evening",
|
|
3419
|
+
night: "night"
|
|
3420
|
+
};
|
|
3421
|
+
var formatters = {
|
|
3422
|
+
// Era
|
|
3423
|
+
G: function(date, token, localize2) {
|
|
3424
|
+
const era = date.getFullYear() > 0 ? 1 : 0;
|
|
3425
|
+
switch (token) {
|
|
3426
|
+
// AD, BC
|
|
3427
|
+
case "G":
|
|
3428
|
+
case "GG":
|
|
3429
|
+
case "GGG":
|
|
3430
|
+
return localize2.era(era, { width: "abbreviated" });
|
|
3431
|
+
// A, B
|
|
3432
|
+
case "GGGGG":
|
|
3433
|
+
return localize2.era(era, { width: "narrow" });
|
|
3434
|
+
// Anno Domini, Before Christ
|
|
3435
|
+
case "GGGG":
|
|
3436
|
+
default:
|
|
3437
|
+
return localize2.era(era, { width: "wide" });
|
|
3438
|
+
}
|
|
3439
|
+
},
|
|
3440
|
+
// Year
|
|
3441
|
+
y: function(date, token, localize2) {
|
|
3442
|
+
if (token === "yo") {
|
|
3443
|
+
const signedYear = date.getFullYear();
|
|
3444
|
+
const year = signedYear > 0 ? signedYear : 1 - signedYear;
|
|
3445
|
+
return localize2.ordinalNumber(year, { unit: "year" });
|
|
3446
|
+
}
|
|
3447
|
+
return lightFormatters.y(date, token);
|
|
3448
|
+
},
|
|
3449
|
+
// Local week-numbering year
|
|
3450
|
+
Y: function(date, token, localize2, options) {
|
|
3451
|
+
const signedWeekYear = getWeekYear(date, options);
|
|
3452
|
+
const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
|
|
3453
|
+
if (token === "YY") {
|
|
3454
|
+
const twoDigitYear = weekYear % 100;
|
|
3455
|
+
return addLeadingZeros(twoDigitYear, 2);
|
|
3456
|
+
}
|
|
3457
|
+
if (token === "Yo") {
|
|
3458
|
+
return localize2.ordinalNumber(weekYear, { unit: "year" });
|
|
3459
|
+
}
|
|
3460
|
+
return addLeadingZeros(weekYear, token.length);
|
|
3461
|
+
},
|
|
3462
|
+
// ISO week-numbering year
|
|
3463
|
+
R: function(date, token) {
|
|
3464
|
+
const isoWeekYear = getISOWeekYear(date);
|
|
3465
|
+
return addLeadingZeros(isoWeekYear, token.length);
|
|
3466
|
+
},
|
|
3467
|
+
// Extended year. This is a single number designating the year of this calendar system.
|
|
3468
|
+
// The main difference between `y` and `u` localizers are B.C. years:
|
|
3469
|
+
// | Year | `y` | `u` |
|
|
3470
|
+
// |------|-----|-----|
|
|
3471
|
+
// | AC 1 | 1 | 1 |
|
|
3472
|
+
// | BC 1 | 1 | 0 |
|
|
3473
|
+
// | BC 2 | 2 | -1 |
|
|
3474
|
+
// Also `yy` always returns the last two digits of a year,
|
|
3475
|
+
// while `uu` pads single digit years to 2 characters and returns other years unchanged.
|
|
3476
|
+
u: function(date, token) {
|
|
3477
|
+
const year = date.getFullYear();
|
|
3478
|
+
return addLeadingZeros(year, token.length);
|
|
3479
|
+
},
|
|
3480
|
+
// Quarter
|
|
3481
|
+
Q: function(date, token, localize2) {
|
|
3482
|
+
const quarter = Math.ceil((date.getMonth() + 1) / 3);
|
|
3483
|
+
switch (token) {
|
|
3484
|
+
// 1, 2, 3, 4
|
|
3485
|
+
case "Q":
|
|
3486
|
+
return String(quarter);
|
|
3487
|
+
// 01, 02, 03, 04
|
|
3488
|
+
case "QQ":
|
|
3489
|
+
return addLeadingZeros(quarter, 2);
|
|
3490
|
+
// 1st, 2nd, 3rd, 4th
|
|
3491
|
+
case "Qo":
|
|
3492
|
+
return localize2.ordinalNumber(quarter, { unit: "quarter" });
|
|
3493
|
+
// Q1, Q2, Q3, Q4
|
|
3494
|
+
case "QQQ":
|
|
3495
|
+
return localize2.quarter(quarter, {
|
|
3496
|
+
width: "abbreviated",
|
|
3497
|
+
context: "formatting"
|
|
3498
|
+
});
|
|
3499
|
+
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
|
|
3500
|
+
case "QQQQQ":
|
|
3501
|
+
return localize2.quarter(quarter, {
|
|
3502
|
+
width: "narrow",
|
|
3503
|
+
context: "formatting"
|
|
3504
|
+
});
|
|
3505
|
+
// 1st quarter, 2nd quarter, ...
|
|
3506
|
+
case "QQQQ":
|
|
3507
|
+
default:
|
|
3508
|
+
return localize2.quarter(quarter, {
|
|
3509
|
+
width: "wide",
|
|
3510
|
+
context: "formatting"
|
|
3511
|
+
});
|
|
3512
|
+
}
|
|
3513
|
+
},
|
|
3514
|
+
// Stand-alone quarter
|
|
3515
|
+
q: function(date, token, localize2) {
|
|
3516
|
+
const quarter = Math.ceil((date.getMonth() + 1) / 3);
|
|
3517
|
+
switch (token) {
|
|
3518
|
+
// 1, 2, 3, 4
|
|
3519
|
+
case "q":
|
|
3520
|
+
return String(quarter);
|
|
3521
|
+
// 01, 02, 03, 04
|
|
3522
|
+
case "qq":
|
|
3523
|
+
return addLeadingZeros(quarter, 2);
|
|
3524
|
+
// 1st, 2nd, 3rd, 4th
|
|
3525
|
+
case "qo":
|
|
3526
|
+
return localize2.ordinalNumber(quarter, { unit: "quarter" });
|
|
3527
|
+
// Q1, Q2, Q3, Q4
|
|
3528
|
+
case "qqq":
|
|
3529
|
+
return localize2.quarter(quarter, {
|
|
3530
|
+
width: "abbreviated",
|
|
3531
|
+
context: "standalone"
|
|
3532
|
+
});
|
|
3533
|
+
// 1, 2, 3, 4 (narrow quarter; could be not numerical)
|
|
3534
|
+
case "qqqqq":
|
|
3535
|
+
return localize2.quarter(quarter, {
|
|
3536
|
+
width: "narrow",
|
|
3537
|
+
context: "standalone"
|
|
3538
|
+
});
|
|
3539
|
+
// 1st quarter, 2nd quarter, ...
|
|
3540
|
+
case "qqqq":
|
|
3541
|
+
default:
|
|
3542
|
+
return localize2.quarter(quarter, {
|
|
3543
|
+
width: "wide",
|
|
3544
|
+
context: "standalone"
|
|
3545
|
+
});
|
|
3546
|
+
}
|
|
3547
|
+
},
|
|
3548
|
+
// Month
|
|
3549
|
+
M: function(date, token, localize2) {
|
|
3550
|
+
const month = date.getMonth();
|
|
3551
|
+
switch (token) {
|
|
3552
|
+
case "M":
|
|
3553
|
+
case "MM":
|
|
3554
|
+
return lightFormatters.M(date, token);
|
|
3555
|
+
// 1st, 2nd, ..., 12th
|
|
3556
|
+
case "Mo":
|
|
3557
|
+
return localize2.ordinalNumber(month + 1, { unit: "month" });
|
|
3558
|
+
// Jan, Feb, ..., Dec
|
|
3559
|
+
case "MMM":
|
|
3560
|
+
return localize2.month(month, {
|
|
3561
|
+
width: "abbreviated",
|
|
3562
|
+
context: "formatting"
|
|
3563
|
+
});
|
|
3564
|
+
// J, F, ..., D
|
|
3565
|
+
case "MMMMM":
|
|
3566
|
+
return localize2.month(month, {
|
|
3567
|
+
width: "narrow",
|
|
3568
|
+
context: "formatting"
|
|
3569
|
+
});
|
|
3570
|
+
// January, February, ..., December
|
|
3571
|
+
case "MMMM":
|
|
3572
|
+
default:
|
|
3573
|
+
return localize2.month(month, { width: "wide", context: "formatting" });
|
|
3574
|
+
}
|
|
3575
|
+
},
|
|
3576
|
+
// Stand-alone month
|
|
3577
|
+
L: function(date, token, localize2) {
|
|
3578
|
+
const month = date.getMonth();
|
|
3579
|
+
switch (token) {
|
|
3580
|
+
// 1, 2, ..., 12
|
|
3581
|
+
case "L":
|
|
3582
|
+
return String(month + 1);
|
|
3583
|
+
// 01, 02, ..., 12
|
|
3584
|
+
case "LL":
|
|
3585
|
+
return addLeadingZeros(month + 1, 2);
|
|
3586
|
+
// 1st, 2nd, ..., 12th
|
|
3587
|
+
case "Lo":
|
|
3588
|
+
return localize2.ordinalNumber(month + 1, { unit: "month" });
|
|
3589
|
+
// Jan, Feb, ..., Dec
|
|
3590
|
+
case "LLL":
|
|
3591
|
+
return localize2.month(month, {
|
|
3592
|
+
width: "abbreviated",
|
|
3593
|
+
context: "standalone"
|
|
3594
|
+
});
|
|
3595
|
+
// J, F, ..., D
|
|
3596
|
+
case "LLLLL":
|
|
3597
|
+
return localize2.month(month, {
|
|
3598
|
+
width: "narrow",
|
|
3599
|
+
context: "standalone"
|
|
3600
|
+
});
|
|
3601
|
+
// January, February, ..., December
|
|
3602
|
+
case "LLLL":
|
|
3603
|
+
default:
|
|
3604
|
+
return localize2.month(month, { width: "wide", context: "standalone" });
|
|
3605
|
+
}
|
|
3606
|
+
},
|
|
3607
|
+
// Local week of year
|
|
3608
|
+
w: function(date, token, localize2, options) {
|
|
3609
|
+
const week = getWeek(date, options);
|
|
3610
|
+
if (token === "wo") {
|
|
3611
|
+
return localize2.ordinalNumber(week, { unit: "week" });
|
|
3612
|
+
}
|
|
3613
|
+
return addLeadingZeros(week, token.length);
|
|
3614
|
+
},
|
|
3615
|
+
// ISO week of year
|
|
3616
|
+
I: function(date, token, localize2) {
|
|
3617
|
+
const isoWeek = getISOWeek(date);
|
|
3618
|
+
if (token === "Io") {
|
|
3619
|
+
return localize2.ordinalNumber(isoWeek, { unit: "week" });
|
|
3620
|
+
}
|
|
3621
|
+
return addLeadingZeros(isoWeek, token.length);
|
|
3622
|
+
},
|
|
3623
|
+
// Day of the month
|
|
3624
|
+
d: function(date, token, localize2) {
|
|
3625
|
+
if (token === "do") {
|
|
3626
|
+
return localize2.ordinalNumber(date.getDate(), { unit: "date" });
|
|
3627
|
+
}
|
|
3628
|
+
return lightFormatters.d(date, token);
|
|
3629
|
+
},
|
|
3630
|
+
// Day of year
|
|
3631
|
+
D: function(date, token, localize2) {
|
|
3632
|
+
const dayOfYear = getDayOfYear(date);
|
|
3633
|
+
if (token === "Do") {
|
|
3634
|
+
return localize2.ordinalNumber(dayOfYear, { unit: "dayOfYear" });
|
|
3635
|
+
}
|
|
3636
|
+
return addLeadingZeros(dayOfYear, token.length);
|
|
3637
|
+
},
|
|
3638
|
+
// Day of week
|
|
3639
|
+
E: function(date, token, localize2) {
|
|
3640
|
+
const dayOfWeek = date.getDay();
|
|
3641
|
+
switch (token) {
|
|
3642
|
+
// Tue
|
|
3643
|
+
case "E":
|
|
3644
|
+
case "EE":
|
|
3645
|
+
case "EEE":
|
|
3646
|
+
return localize2.day(dayOfWeek, {
|
|
3647
|
+
width: "abbreviated",
|
|
3648
|
+
context: "formatting"
|
|
3649
|
+
});
|
|
3650
|
+
// T
|
|
3651
|
+
case "EEEEE":
|
|
3652
|
+
return localize2.day(dayOfWeek, {
|
|
3653
|
+
width: "narrow",
|
|
3654
|
+
context: "formatting"
|
|
3655
|
+
});
|
|
3656
|
+
// Tu
|
|
3657
|
+
case "EEEEEE":
|
|
3658
|
+
return localize2.day(dayOfWeek, {
|
|
3659
|
+
width: "short",
|
|
3660
|
+
context: "formatting"
|
|
3661
|
+
});
|
|
3662
|
+
// Tuesday
|
|
3663
|
+
case "EEEE":
|
|
3664
|
+
default:
|
|
3665
|
+
return localize2.day(dayOfWeek, {
|
|
3666
|
+
width: "wide",
|
|
3667
|
+
context: "formatting"
|
|
3668
|
+
});
|
|
3669
|
+
}
|
|
3670
|
+
},
|
|
3671
|
+
// Local day of week
|
|
3672
|
+
e: function(date, token, localize2, options) {
|
|
3673
|
+
const dayOfWeek = date.getDay();
|
|
3674
|
+
const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
|
|
3675
|
+
switch (token) {
|
|
3676
|
+
// Numerical value (Nth day of week with current locale or weekStartsOn)
|
|
3677
|
+
case "e":
|
|
3678
|
+
return String(localDayOfWeek);
|
|
3679
|
+
// Padded numerical value
|
|
3680
|
+
case "ee":
|
|
3681
|
+
return addLeadingZeros(localDayOfWeek, 2);
|
|
3682
|
+
// 1st, 2nd, ..., 7th
|
|
3683
|
+
case "eo":
|
|
3684
|
+
return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
|
|
3685
|
+
case "eee":
|
|
3686
|
+
return localize2.day(dayOfWeek, {
|
|
3687
|
+
width: "abbreviated",
|
|
3688
|
+
context: "formatting"
|
|
3689
|
+
});
|
|
3690
|
+
// T
|
|
3691
|
+
case "eeeee":
|
|
3692
|
+
return localize2.day(dayOfWeek, {
|
|
3693
|
+
width: "narrow",
|
|
3694
|
+
context: "formatting"
|
|
3695
|
+
});
|
|
3696
|
+
// Tu
|
|
3697
|
+
case "eeeeee":
|
|
3698
|
+
return localize2.day(dayOfWeek, {
|
|
3699
|
+
width: "short",
|
|
3700
|
+
context: "formatting"
|
|
3701
|
+
});
|
|
3702
|
+
// Tuesday
|
|
3703
|
+
case "eeee":
|
|
3704
|
+
default:
|
|
3705
|
+
return localize2.day(dayOfWeek, {
|
|
3706
|
+
width: "wide",
|
|
3707
|
+
context: "formatting"
|
|
3708
|
+
});
|
|
3709
|
+
}
|
|
3710
|
+
},
|
|
3711
|
+
// Stand-alone local day of week
|
|
3712
|
+
c: function(date, token, localize2, options) {
|
|
3713
|
+
const dayOfWeek = date.getDay();
|
|
3714
|
+
const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
|
|
3715
|
+
switch (token) {
|
|
3716
|
+
// Numerical value (same as in `e`)
|
|
3717
|
+
case "c":
|
|
3718
|
+
return String(localDayOfWeek);
|
|
3719
|
+
// Padded numerical value
|
|
3720
|
+
case "cc":
|
|
3721
|
+
return addLeadingZeros(localDayOfWeek, token.length);
|
|
3722
|
+
// 1st, 2nd, ..., 7th
|
|
3723
|
+
case "co":
|
|
3724
|
+
return localize2.ordinalNumber(localDayOfWeek, { unit: "day" });
|
|
3725
|
+
case "ccc":
|
|
3726
|
+
return localize2.day(dayOfWeek, {
|
|
3727
|
+
width: "abbreviated",
|
|
3728
|
+
context: "standalone"
|
|
3729
|
+
});
|
|
3730
|
+
// T
|
|
3731
|
+
case "ccccc":
|
|
3732
|
+
return localize2.day(dayOfWeek, {
|
|
3733
|
+
width: "narrow",
|
|
3734
|
+
context: "standalone"
|
|
3735
|
+
});
|
|
3736
|
+
// Tu
|
|
3737
|
+
case "cccccc":
|
|
3738
|
+
return localize2.day(dayOfWeek, {
|
|
3739
|
+
width: "short",
|
|
3740
|
+
context: "standalone"
|
|
3741
|
+
});
|
|
3742
|
+
// Tuesday
|
|
3743
|
+
case "cccc":
|
|
3744
|
+
default:
|
|
3745
|
+
return localize2.day(dayOfWeek, {
|
|
3746
|
+
width: "wide",
|
|
3747
|
+
context: "standalone"
|
|
3748
|
+
});
|
|
3749
|
+
}
|
|
3750
|
+
},
|
|
3751
|
+
// ISO day of week
|
|
3752
|
+
i: function(date, token, localize2) {
|
|
3753
|
+
const dayOfWeek = date.getDay();
|
|
3754
|
+
const isoDayOfWeek = dayOfWeek === 0 ? 7 : dayOfWeek;
|
|
3755
|
+
switch (token) {
|
|
3756
|
+
// 2
|
|
3757
|
+
case "i":
|
|
3758
|
+
return String(isoDayOfWeek);
|
|
3759
|
+
// 02
|
|
3760
|
+
case "ii":
|
|
3761
|
+
return addLeadingZeros(isoDayOfWeek, token.length);
|
|
3762
|
+
// 2nd
|
|
3763
|
+
case "io":
|
|
3764
|
+
return localize2.ordinalNumber(isoDayOfWeek, { unit: "day" });
|
|
3765
|
+
// Tue
|
|
3766
|
+
case "iii":
|
|
3767
|
+
return localize2.day(dayOfWeek, {
|
|
3768
|
+
width: "abbreviated",
|
|
3769
|
+
context: "formatting"
|
|
3770
|
+
});
|
|
3771
|
+
// T
|
|
3772
|
+
case "iiiii":
|
|
3773
|
+
return localize2.day(dayOfWeek, {
|
|
3774
|
+
width: "narrow",
|
|
3775
|
+
context: "formatting"
|
|
3776
|
+
});
|
|
3777
|
+
// Tu
|
|
3778
|
+
case "iiiiii":
|
|
3779
|
+
return localize2.day(dayOfWeek, {
|
|
3780
|
+
width: "short",
|
|
3781
|
+
context: "formatting"
|
|
3782
|
+
});
|
|
3783
|
+
// Tuesday
|
|
3784
|
+
case "iiii":
|
|
3785
|
+
default:
|
|
3786
|
+
return localize2.day(dayOfWeek, {
|
|
3787
|
+
width: "wide",
|
|
3788
|
+
context: "formatting"
|
|
3789
|
+
});
|
|
3790
|
+
}
|
|
3791
|
+
},
|
|
3792
|
+
// AM or PM
|
|
3793
|
+
a: function(date, token, localize2) {
|
|
3794
|
+
const hours = date.getHours();
|
|
3795
|
+
const dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
|
|
3796
|
+
switch (token) {
|
|
3797
|
+
case "a":
|
|
3798
|
+
case "aa":
|
|
3799
|
+
return localize2.dayPeriod(dayPeriodEnumValue, {
|
|
3800
|
+
width: "abbreviated",
|
|
3801
|
+
context: "formatting"
|
|
3802
|
+
});
|
|
3803
|
+
case "aaa":
|
|
3804
|
+
return localize2.dayPeriod(dayPeriodEnumValue, {
|
|
3805
|
+
width: "abbreviated",
|
|
3806
|
+
context: "formatting"
|
|
3807
|
+
}).toLowerCase();
|
|
3808
|
+
case "aaaaa":
|
|
3809
|
+
return localize2.dayPeriod(dayPeriodEnumValue, {
|
|
3810
|
+
width: "narrow",
|
|
3811
|
+
context: "formatting"
|
|
3812
|
+
});
|
|
3813
|
+
case "aaaa":
|
|
3814
|
+
default:
|
|
3815
|
+
return localize2.dayPeriod(dayPeriodEnumValue, {
|
|
3816
|
+
width: "wide",
|
|
3817
|
+
context: "formatting"
|
|
3818
|
+
});
|
|
3819
|
+
}
|
|
3820
|
+
},
|
|
3821
|
+
// AM, PM, midnight, noon
|
|
3822
|
+
b: function(date, token, localize2) {
|
|
3823
|
+
const hours = date.getHours();
|
|
3824
|
+
let dayPeriodEnumValue;
|
|
3825
|
+
if (hours === 12) {
|
|
3826
|
+
dayPeriodEnumValue = dayPeriodEnum.noon;
|
|
3827
|
+
} else if (hours === 0) {
|
|
3828
|
+
dayPeriodEnumValue = dayPeriodEnum.midnight;
|
|
3829
|
+
} else {
|
|
3830
|
+
dayPeriodEnumValue = hours / 12 >= 1 ? "pm" : "am";
|
|
3831
|
+
}
|
|
3832
|
+
switch (token) {
|
|
3833
|
+
case "b":
|
|
3834
|
+
case "bb":
|
|
3835
|
+
return localize2.dayPeriod(dayPeriodEnumValue, {
|
|
3836
|
+
width: "abbreviated",
|
|
3837
|
+
context: "formatting"
|
|
3838
|
+
});
|
|
3839
|
+
case "bbb":
|
|
3840
|
+
return localize2.dayPeriod(dayPeriodEnumValue, {
|
|
3841
|
+
width: "abbreviated",
|
|
3842
|
+
context: "formatting"
|
|
3843
|
+
}).toLowerCase();
|
|
3844
|
+
case "bbbbb":
|
|
3845
|
+
return localize2.dayPeriod(dayPeriodEnumValue, {
|
|
3846
|
+
width: "narrow",
|
|
3847
|
+
context: "formatting"
|
|
3848
|
+
});
|
|
3849
|
+
case "bbbb":
|
|
3850
|
+
default:
|
|
3851
|
+
return localize2.dayPeriod(dayPeriodEnumValue, {
|
|
3852
|
+
width: "wide",
|
|
3853
|
+
context: "formatting"
|
|
3854
|
+
});
|
|
3855
|
+
}
|
|
3856
|
+
},
|
|
3857
|
+
// in the morning, in the afternoon, in the evening, at night
|
|
3858
|
+
B: function(date, token, localize2) {
|
|
3859
|
+
const hours = date.getHours();
|
|
3860
|
+
let dayPeriodEnumValue;
|
|
3861
|
+
if (hours >= 17) {
|
|
3862
|
+
dayPeriodEnumValue = dayPeriodEnum.evening;
|
|
3863
|
+
} else if (hours >= 12) {
|
|
3864
|
+
dayPeriodEnumValue = dayPeriodEnum.afternoon;
|
|
3865
|
+
} else if (hours >= 4) {
|
|
3866
|
+
dayPeriodEnumValue = dayPeriodEnum.morning;
|
|
3867
|
+
} else {
|
|
3868
|
+
dayPeriodEnumValue = dayPeriodEnum.night;
|
|
3869
|
+
}
|
|
3870
|
+
switch (token) {
|
|
3871
|
+
case "B":
|
|
3872
|
+
case "BB":
|
|
3873
|
+
case "BBB":
|
|
3874
|
+
return localize2.dayPeriod(dayPeriodEnumValue, {
|
|
3875
|
+
width: "abbreviated",
|
|
3876
|
+
context: "formatting"
|
|
3877
|
+
});
|
|
3878
|
+
case "BBBBB":
|
|
3879
|
+
return localize2.dayPeriod(dayPeriodEnumValue, {
|
|
3880
|
+
width: "narrow",
|
|
3881
|
+
context: "formatting"
|
|
3882
|
+
});
|
|
3883
|
+
case "BBBB":
|
|
3884
|
+
default:
|
|
3885
|
+
return localize2.dayPeriod(dayPeriodEnumValue, {
|
|
3886
|
+
width: "wide",
|
|
3887
|
+
context: "formatting"
|
|
3888
|
+
});
|
|
3889
|
+
}
|
|
3890
|
+
},
|
|
3891
|
+
// Hour [1-12]
|
|
3892
|
+
h: function(date, token, localize2) {
|
|
3893
|
+
if (token === "ho") {
|
|
3894
|
+
let hours = date.getHours() % 12;
|
|
3895
|
+
if (hours === 0) hours = 12;
|
|
3896
|
+
return localize2.ordinalNumber(hours, { unit: "hour" });
|
|
3897
|
+
}
|
|
3898
|
+
return lightFormatters.h(date, token);
|
|
3899
|
+
},
|
|
3900
|
+
// Hour [0-23]
|
|
3901
|
+
H: function(date, token, localize2) {
|
|
3902
|
+
if (token === "Ho") {
|
|
3903
|
+
return localize2.ordinalNumber(date.getHours(), { unit: "hour" });
|
|
3904
|
+
}
|
|
3905
|
+
return lightFormatters.H(date, token);
|
|
3906
|
+
},
|
|
3907
|
+
// Hour [0-11]
|
|
3908
|
+
K: function(date, token, localize2) {
|
|
3909
|
+
const hours = date.getHours() % 12;
|
|
3910
|
+
if (token === "Ko") {
|
|
3911
|
+
return localize2.ordinalNumber(hours, { unit: "hour" });
|
|
3912
|
+
}
|
|
3913
|
+
return addLeadingZeros(hours, token.length);
|
|
3914
|
+
},
|
|
3915
|
+
// Hour [1-24]
|
|
3916
|
+
k: function(date, token, localize2) {
|
|
3917
|
+
let hours = date.getHours();
|
|
3918
|
+
if (hours === 0) hours = 24;
|
|
3919
|
+
if (token === "ko") {
|
|
3920
|
+
return localize2.ordinalNumber(hours, { unit: "hour" });
|
|
3921
|
+
}
|
|
3922
|
+
return addLeadingZeros(hours, token.length);
|
|
3923
|
+
},
|
|
3924
|
+
// Minute
|
|
3925
|
+
m: function(date, token, localize2) {
|
|
3926
|
+
if (token === "mo") {
|
|
3927
|
+
return localize2.ordinalNumber(date.getMinutes(), { unit: "minute" });
|
|
3928
|
+
}
|
|
3929
|
+
return lightFormatters.m(date, token);
|
|
3930
|
+
},
|
|
3931
|
+
// Second
|
|
3932
|
+
s: function(date, token, localize2) {
|
|
3933
|
+
if (token === "so") {
|
|
3934
|
+
return localize2.ordinalNumber(date.getSeconds(), { unit: "second" });
|
|
3935
|
+
}
|
|
3936
|
+
return lightFormatters.s(date, token);
|
|
3937
|
+
},
|
|
3938
|
+
// Fraction of second
|
|
3939
|
+
S: function(date, token) {
|
|
3940
|
+
return lightFormatters.S(date, token);
|
|
3941
|
+
},
|
|
3942
|
+
// Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
|
|
3943
|
+
X: function(date, token, _localize) {
|
|
3944
|
+
const timezoneOffset = date.getTimezoneOffset();
|
|
3945
|
+
if (timezoneOffset === 0) {
|
|
3946
|
+
return "Z";
|
|
3947
|
+
}
|
|
3948
|
+
switch (token) {
|
|
3949
|
+
// Hours and optional minutes
|
|
3950
|
+
case "X":
|
|
3951
|
+
return formatTimezoneWithOptionalMinutes(timezoneOffset);
|
|
3952
|
+
// Hours, minutes and optional seconds without `:` delimiter
|
|
3953
|
+
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
|
3954
|
+
// so this token always has the same output as `XX`
|
|
3955
|
+
case "XXXX":
|
|
3956
|
+
case "XX":
|
|
3957
|
+
return formatTimezone(timezoneOffset);
|
|
3958
|
+
// Hours, minutes and optional seconds with `:` delimiter
|
|
3959
|
+
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
|
3960
|
+
// so this token always has the same output as `XXX`
|
|
3961
|
+
case "XXXXX":
|
|
3962
|
+
case "XXX":
|
|
3963
|
+
// Hours and minutes with `:` delimiter
|
|
3964
|
+
default:
|
|
3965
|
+
return formatTimezone(timezoneOffset, ":");
|
|
3966
|
+
}
|
|
3967
|
+
},
|
|
3968
|
+
// Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
|
|
3969
|
+
x: function(date, token, _localize) {
|
|
3970
|
+
const timezoneOffset = date.getTimezoneOffset();
|
|
3971
|
+
switch (token) {
|
|
3972
|
+
// Hours and optional minutes
|
|
3973
|
+
case "x":
|
|
3974
|
+
return formatTimezoneWithOptionalMinutes(timezoneOffset);
|
|
3975
|
+
// Hours, minutes and optional seconds without `:` delimiter
|
|
3976
|
+
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
|
3977
|
+
// so this token always has the same output as `xx`
|
|
3978
|
+
case "xxxx":
|
|
3979
|
+
case "xx":
|
|
3980
|
+
return formatTimezone(timezoneOffset);
|
|
3981
|
+
// Hours, minutes and optional seconds with `:` delimiter
|
|
3982
|
+
// Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
|
|
3983
|
+
// so this token always has the same output as `xxx`
|
|
3984
|
+
case "xxxxx":
|
|
3985
|
+
case "xxx":
|
|
3986
|
+
// Hours and minutes with `:` delimiter
|
|
3987
|
+
default:
|
|
3988
|
+
return formatTimezone(timezoneOffset, ":");
|
|
3989
|
+
}
|
|
3990
|
+
},
|
|
3991
|
+
// Timezone (GMT)
|
|
3992
|
+
O: function(date, token, _localize) {
|
|
3993
|
+
const timezoneOffset = date.getTimezoneOffset();
|
|
3994
|
+
switch (token) {
|
|
3995
|
+
// Short
|
|
3996
|
+
case "O":
|
|
3997
|
+
case "OO":
|
|
3998
|
+
case "OOO":
|
|
3999
|
+
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
|
|
4000
|
+
// Long
|
|
4001
|
+
case "OOOO":
|
|
4002
|
+
default:
|
|
4003
|
+
return "GMT" + formatTimezone(timezoneOffset, ":");
|
|
4004
|
+
}
|
|
4005
|
+
},
|
|
4006
|
+
// Timezone (specific non-location)
|
|
4007
|
+
z: function(date, token, _localize) {
|
|
4008
|
+
const timezoneOffset = date.getTimezoneOffset();
|
|
4009
|
+
switch (token) {
|
|
4010
|
+
// Short
|
|
4011
|
+
case "z":
|
|
4012
|
+
case "zz":
|
|
4013
|
+
case "zzz":
|
|
4014
|
+
return "GMT" + formatTimezoneShort(timezoneOffset, ":");
|
|
4015
|
+
// Long
|
|
4016
|
+
case "zzzz":
|
|
4017
|
+
default:
|
|
4018
|
+
return "GMT" + formatTimezone(timezoneOffset, ":");
|
|
4019
|
+
}
|
|
4020
|
+
},
|
|
4021
|
+
// Seconds timestamp
|
|
4022
|
+
t: function(date, token, _localize) {
|
|
4023
|
+
const timestamp = Math.trunc(+date / 1e3);
|
|
4024
|
+
return addLeadingZeros(timestamp, token.length);
|
|
4025
|
+
},
|
|
4026
|
+
// Milliseconds timestamp
|
|
4027
|
+
T: function(date, token, _localize) {
|
|
4028
|
+
return addLeadingZeros(+date, token.length);
|
|
4029
|
+
}
|
|
4030
|
+
};
|
|
4031
|
+
function formatTimezoneShort(offset, delimiter = "") {
|
|
4032
|
+
const sign = offset > 0 ? "-" : "+";
|
|
4033
|
+
const absOffset = Math.abs(offset);
|
|
4034
|
+
const hours = Math.trunc(absOffset / 60);
|
|
4035
|
+
const minutes = absOffset % 60;
|
|
4036
|
+
if (minutes === 0) {
|
|
4037
|
+
return sign + String(hours);
|
|
4038
|
+
}
|
|
4039
|
+
return sign + String(hours) + delimiter + addLeadingZeros(minutes, 2);
|
|
4040
|
+
}
|
|
4041
|
+
function formatTimezoneWithOptionalMinutes(offset, delimiter) {
|
|
4042
|
+
if (offset % 60 === 0) {
|
|
4043
|
+
const sign = offset > 0 ? "-" : "+";
|
|
4044
|
+
return sign + addLeadingZeros(Math.abs(offset) / 60, 2);
|
|
4045
|
+
}
|
|
4046
|
+
return formatTimezone(offset, delimiter);
|
|
4047
|
+
}
|
|
4048
|
+
function formatTimezone(offset, delimiter = "") {
|
|
4049
|
+
const sign = offset > 0 ? "-" : "+";
|
|
4050
|
+
const absOffset = Math.abs(offset);
|
|
4051
|
+
const hours = addLeadingZeros(Math.trunc(absOffset / 60), 2);
|
|
4052
|
+
const minutes = addLeadingZeros(absOffset % 60, 2);
|
|
4053
|
+
return sign + hours + delimiter + minutes;
|
|
4054
|
+
}
|
|
4055
|
+
|
|
4056
|
+
// node_modules/date-fns/_lib/format/longFormatters.js
|
|
4057
|
+
var dateLongFormatter = (pattern, formatLong2) => {
|
|
4058
|
+
switch (pattern) {
|
|
4059
|
+
case "P":
|
|
4060
|
+
return formatLong2.date({ width: "short" });
|
|
4061
|
+
case "PP":
|
|
4062
|
+
return formatLong2.date({ width: "medium" });
|
|
4063
|
+
case "PPP":
|
|
4064
|
+
return formatLong2.date({ width: "long" });
|
|
4065
|
+
case "PPPP":
|
|
4066
|
+
default:
|
|
4067
|
+
return formatLong2.date({ width: "full" });
|
|
4068
|
+
}
|
|
4069
|
+
};
|
|
4070
|
+
var timeLongFormatter = (pattern, formatLong2) => {
|
|
4071
|
+
switch (pattern) {
|
|
4072
|
+
case "p":
|
|
4073
|
+
return formatLong2.time({ width: "short" });
|
|
4074
|
+
case "pp":
|
|
4075
|
+
return formatLong2.time({ width: "medium" });
|
|
4076
|
+
case "ppp":
|
|
4077
|
+
return formatLong2.time({ width: "long" });
|
|
4078
|
+
case "pppp":
|
|
4079
|
+
default:
|
|
4080
|
+
return formatLong2.time({ width: "full" });
|
|
4081
|
+
}
|
|
4082
|
+
};
|
|
4083
|
+
var dateTimeLongFormatter = (pattern, formatLong2) => {
|
|
4084
|
+
const matchResult = pattern.match(/(P+)(p+)?/) || [];
|
|
4085
|
+
const datePattern = matchResult[1];
|
|
4086
|
+
const timePattern = matchResult[2];
|
|
4087
|
+
if (!timePattern) {
|
|
4088
|
+
return dateLongFormatter(pattern, formatLong2);
|
|
4089
|
+
}
|
|
4090
|
+
let dateTimeFormat;
|
|
4091
|
+
switch (datePattern) {
|
|
4092
|
+
case "P":
|
|
4093
|
+
dateTimeFormat = formatLong2.dateTime({ width: "short" });
|
|
4094
|
+
break;
|
|
4095
|
+
case "PP":
|
|
4096
|
+
dateTimeFormat = formatLong2.dateTime({ width: "medium" });
|
|
4097
|
+
break;
|
|
4098
|
+
case "PPP":
|
|
4099
|
+
dateTimeFormat = formatLong2.dateTime({ width: "long" });
|
|
4100
|
+
break;
|
|
4101
|
+
case "PPPP":
|
|
4102
|
+
default:
|
|
4103
|
+
dateTimeFormat = formatLong2.dateTime({ width: "full" });
|
|
4104
|
+
break;
|
|
4105
|
+
}
|
|
4106
|
+
return dateTimeFormat.replace("{{date}}", dateLongFormatter(datePattern, formatLong2)).replace("{{time}}", timeLongFormatter(timePattern, formatLong2));
|
|
4107
|
+
};
|
|
4108
|
+
var longFormatters = {
|
|
4109
|
+
p: timeLongFormatter,
|
|
4110
|
+
P: dateTimeLongFormatter
|
|
4111
|
+
};
|
|
4112
|
+
|
|
4113
|
+
// node_modules/date-fns/_lib/protectedTokens.js
|
|
4114
|
+
var dayOfYearTokenRE = /^D+$/;
|
|
4115
|
+
var weekYearTokenRE = /^Y+$/;
|
|
4116
|
+
var throwTokens = ["D", "DD", "YY", "YYYY"];
|
|
4117
|
+
function isProtectedDayOfYearToken(token) {
|
|
4118
|
+
return dayOfYearTokenRE.test(token);
|
|
4119
|
+
}
|
|
4120
|
+
function isProtectedWeekYearToken(token) {
|
|
4121
|
+
return weekYearTokenRE.test(token);
|
|
4122
|
+
}
|
|
4123
|
+
function warnOrThrowProtectedError(token, format2, input) {
|
|
4124
|
+
const _message = message(token, format2, input);
|
|
4125
|
+
console.warn(_message);
|
|
4126
|
+
if (throwTokens.includes(token)) throw new RangeError(_message);
|
|
4127
|
+
}
|
|
4128
|
+
function message(token, format2, input) {
|
|
4129
|
+
const subject = token[0] === "Y" ? "years" : "days of the month";
|
|
4130
|
+
return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format2}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
|
|
4131
|
+
}
|
|
4132
|
+
|
|
4133
|
+
// node_modules/date-fns/format.js
|
|
4134
|
+
var formattingTokensRegExp = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g;
|
|
4135
|
+
var longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
|
|
4136
|
+
var escapedStringRegExp = /^'([^]*?)'?$/;
|
|
4137
|
+
var doubleQuoteRegExp = /''/g;
|
|
4138
|
+
var unescapedLatinCharacterRegExp = /[a-zA-Z]/;
|
|
4139
|
+
function format(date, formatStr, options) {
|
|
4140
|
+
const defaultOptions2 = getDefaultOptions();
|
|
4141
|
+
const locale = defaultOptions2.locale ?? enUS;
|
|
4142
|
+
const firstWeekContainsDate = defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
|
|
4143
|
+
const weekStartsOn = defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
|
|
4144
|
+
const originalDate = toDate(date, options?.in);
|
|
4145
|
+
if (!isValid(originalDate)) {
|
|
4146
|
+
throw new RangeError("Invalid time value");
|
|
4147
|
+
}
|
|
4148
|
+
let parts = formatStr.match(longFormattingTokensRegExp).map((substring) => {
|
|
4149
|
+
const firstCharacter = substring[0];
|
|
4150
|
+
if (firstCharacter === "p" || firstCharacter === "P") {
|
|
4151
|
+
const longFormatter = longFormatters[firstCharacter];
|
|
4152
|
+
return longFormatter(substring, locale.formatLong);
|
|
4153
|
+
}
|
|
4154
|
+
return substring;
|
|
4155
|
+
}).join("").match(formattingTokensRegExp).map((substring) => {
|
|
4156
|
+
if (substring === "''") {
|
|
4157
|
+
return { isToken: false, value: "'" };
|
|
4158
|
+
}
|
|
4159
|
+
const firstCharacter = substring[0];
|
|
4160
|
+
if (firstCharacter === "'") {
|
|
4161
|
+
return { isToken: false, value: cleanEscapedString(substring) };
|
|
4162
|
+
}
|
|
4163
|
+
if (formatters[firstCharacter]) {
|
|
4164
|
+
return { isToken: true, value: substring };
|
|
4165
|
+
}
|
|
4166
|
+
if (firstCharacter.match(unescapedLatinCharacterRegExp)) {
|
|
4167
|
+
throw new RangeError(
|
|
4168
|
+
"Format string contains an unescaped latin alphabet character `" + firstCharacter + "`"
|
|
4169
|
+
);
|
|
4170
|
+
}
|
|
4171
|
+
return { isToken: false, value: substring };
|
|
4172
|
+
});
|
|
4173
|
+
if (locale.localize.preprocessor) {
|
|
4174
|
+
parts = locale.localize.preprocessor(originalDate, parts);
|
|
4175
|
+
}
|
|
4176
|
+
const formatterOptions = {
|
|
4177
|
+
firstWeekContainsDate,
|
|
4178
|
+
weekStartsOn,
|
|
4179
|
+
locale
|
|
4180
|
+
};
|
|
4181
|
+
return parts.map((part) => {
|
|
4182
|
+
if (!part.isToken) return part.value;
|
|
4183
|
+
const token = part.value;
|
|
4184
|
+
if (isProtectedWeekYearToken(token) || isProtectedDayOfYearToken(token)) {
|
|
4185
|
+
warnOrThrowProtectedError(token, formatStr, String(date));
|
|
4186
|
+
}
|
|
4187
|
+
const formatter = formatters[token[0]];
|
|
4188
|
+
return formatter(originalDate, token, locale.localize, formatterOptions);
|
|
4189
|
+
}).join("");
|
|
4190
|
+
}
|
|
4191
|
+
function cleanEscapedString(input) {
|
|
4192
|
+
const matched = input.match(escapedStringRegExp);
|
|
4193
|
+
if (!matched) {
|
|
4194
|
+
return input;
|
|
4195
|
+
}
|
|
4196
|
+
return matched[1].replace(doubleQuoteRegExp, "'");
|
|
4197
|
+
}
|
|
4198
|
+
|
|
4199
|
+
// node_modules/date-fns/parseISO.js
|
|
4200
|
+
function parseISO(argument, options) {
|
|
4201
|
+
const invalidDate = () => constructFrom(options?.in, NaN);
|
|
4202
|
+
const additionalDigits = 2;
|
|
4203
|
+
const dateStrings = splitDateString(argument);
|
|
4204
|
+
let date;
|
|
4205
|
+
if (dateStrings.date) {
|
|
4206
|
+
const parseYearResult = parseYear(dateStrings.date, additionalDigits);
|
|
4207
|
+
date = parseDate(parseYearResult.restDateString, parseYearResult.year);
|
|
4208
|
+
}
|
|
4209
|
+
if (!date || isNaN(+date)) return invalidDate();
|
|
4210
|
+
const timestamp = +date;
|
|
4211
|
+
let time = 0;
|
|
4212
|
+
let offset;
|
|
4213
|
+
if (dateStrings.time) {
|
|
4214
|
+
time = parseTime(dateStrings.time);
|
|
4215
|
+
if (isNaN(time)) return invalidDate();
|
|
4216
|
+
}
|
|
4217
|
+
if (dateStrings.timezone) {
|
|
4218
|
+
offset = parseTimezone(dateStrings.timezone);
|
|
4219
|
+
if (isNaN(offset)) return invalidDate();
|
|
4220
|
+
} else {
|
|
4221
|
+
const tmpDate = new Date(timestamp + time);
|
|
4222
|
+
const result = toDate(0, options?.in);
|
|
4223
|
+
result.setFullYear(
|
|
4224
|
+
tmpDate.getUTCFullYear(),
|
|
4225
|
+
tmpDate.getUTCMonth(),
|
|
4226
|
+
tmpDate.getUTCDate()
|
|
4227
|
+
);
|
|
4228
|
+
result.setHours(
|
|
4229
|
+
tmpDate.getUTCHours(),
|
|
4230
|
+
tmpDate.getUTCMinutes(),
|
|
4231
|
+
tmpDate.getUTCSeconds(),
|
|
4232
|
+
tmpDate.getUTCMilliseconds()
|
|
4233
|
+
);
|
|
4234
|
+
return result;
|
|
4235
|
+
}
|
|
4236
|
+
return toDate(timestamp + time + offset, options?.in);
|
|
4237
|
+
}
|
|
4238
|
+
var patterns = {
|
|
4239
|
+
dateTimeDelimiter: /[T ]/,
|
|
4240
|
+
timeZoneDelimiter: /[Z ]/i,
|
|
4241
|
+
timezone: /([Z+-].*)$/
|
|
4242
|
+
};
|
|
4243
|
+
var dateRegex = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
|
|
4244
|
+
var timeRegex = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
|
|
4245
|
+
var timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
|
|
4246
|
+
function splitDateString(dateString) {
|
|
4247
|
+
const dateStrings = {};
|
|
4248
|
+
const array = dateString.split(patterns.dateTimeDelimiter);
|
|
4249
|
+
let timeString;
|
|
4250
|
+
if (array.length > 2) {
|
|
4251
|
+
return dateStrings;
|
|
4252
|
+
}
|
|
4253
|
+
if (/:/.test(array[0])) {
|
|
4254
|
+
timeString = array[0];
|
|
4255
|
+
} else {
|
|
4256
|
+
dateStrings.date = array[0];
|
|
4257
|
+
timeString = array[1];
|
|
4258
|
+
if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
|
|
4259
|
+
dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
|
|
4260
|
+
timeString = dateString.substr(
|
|
4261
|
+
dateStrings.date.length,
|
|
4262
|
+
dateString.length
|
|
4263
|
+
);
|
|
4264
|
+
}
|
|
4265
|
+
}
|
|
4266
|
+
if (timeString) {
|
|
4267
|
+
const token = patterns.timezone.exec(timeString);
|
|
4268
|
+
if (token) {
|
|
4269
|
+
dateStrings.time = timeString.replace(token[1], "");
|
|
4270
|
+
dateStrings.timezone = token[1];
|
|
4271
|
+
} else {
|
|
4272
|
+
dateStrings.time = timeString;
|
|
4273
|
+
}
|
|
4274
|
+
}
|
|
4275
|
+
return dateStrings;
|
|
4276
|
+
}
|
|
4277
|
+
function parseYear(dateString, additionalDigits) {
|
|
4278
|
+
const regex = new RegExp(
|
|
4279
|
+
"^(?:(\\d{4}|[+-]\\d{" + (4 + additionalDigits) + "})|(\\d{2}|[+-]\\d{" + (2 + additionalDigits) + "})$)"
|
|
4280
|
+
);
|
|
4281
|
+
const captures = dateString.match(regex);
|
|
4282
|
+
if (!captures) return { year: NaN, restDateString: "" };
|
|
4283
|
+
const year = captures[1] ? parseInt(captures[1]) : null;
|
|
4284
|
+
const century = captures[2] ? parseInt(captures[2]) : null;
|
|
4285
|
+
return {
|
|
4286
|
+
year: century === null ? year : century * 100,
|
|
4287
|
+
restDateString: dateString.slice((captures[1] || captures[2]).length)
|
|
4288
|
+
};
|
|
4289
|
+
}
|
|
4290
|
+
function parseDate(dateString, year) {
|
|
4291
|
+
if (year === null) return /* @__PURE__ */ new Date(NaN);
|
|
4292
|
+
const captures = dateString.match(dateRegex);
|
|
4293
|
+
if (!captures) return /* @__PURE__ */ new Date(NaN);
|
|
4294
|
+
const isWeekDate = !!captures[4];
|
|
4295
|
+
const dayOfYear = parseDateUnit(captures[1]);
|
|
4296
|
+
const month = parseDateUnit(captures[2]) - 1;
|
|
4297
|
+
const day = parseDateUnit(captures[3]);
|
|
4298
|
+
const week = parseDateUnit(captures[4]);
|
|
4299
|
+
const dayOfWeek = parseDateUnit(captures[5]) - 1;
|
|
4300
|
+
if (isWeekDate) {
|
|
4301
|
+
if (!validateWeekDate(year, week, dayOfWeek)) {
|
|
4302
|
+
return /* @__PURE__ */ new Date(NaN);
|
|
4303
|
+
}
|
|
4304
|
+
return dayOfISOWeekYear(year, week, dayOfWeek);
|
|
4305
|
+
} else {
|
|
4306
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
4307
|
+
if (!validateDate(year, month, day) || !validateDayOfYearDate(year, dayOfYear)) {
|
|
4308
|
+
return /* @__PURE__ */ new Date(NaN);
|
|
4309
|
+
}
|
|
4310
|
+
date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
|
|
4311
|
+
return date;
|
|
4312
|
+
}
|
|
4313
|
+
}
|
|
4314
|
+
function parseDateUnit(value) {
|
|
4315
|
+
return value ? parseInt(value) : 1;
|
|
4316
|
+
}
|
|
4317
|
+
function parseTime(timeString) {
|
|
4318
|
+
const captures = timeString.match(timeRegex);
|
|
4319
|
+
if (!captures) return NaN;
|
|
4320
|
+
const hours = parseTimeUnit(captures[1]);
|
|
4321
|
+
const minutes = parseTimeUnit(captures[2]);
|
|
4322
|
+
const seconds = parseTimeUnit(captures[3]);
|
|
4323
|
+
if (!validateTime(hours, minutes, seconds)) {
|
|
4324
|
+
return NaN;
|
|
4325
|
+
}
|
|
4326
|
+
return hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1e3;
|
|
4327
|
+
}
|
|
4328
|
+
function parseTimeUnit(value) {
|
|
4329
|
+
return value && parseFloat(value.replace(",", ".")) || 0;
|
|
4330
|
+
}
|
|
4331
|
+
function parseTimezone(timezoneString) {
|
|
4332
|
+
if (timezoneString === "Z") return 0;
|
|
4333
|
+
const captures = timezoneString.match(timezoneRegex);
|
|
4334
|
+
if (!captures) return 0;
|
|
4335
|
+
const sign = captures[1] === "+" ? -1 : 1;
|
|
4336
|
+
const hours = parseInt(captures[2]);
|
|
4337
|
+
const minutes = captures[3] && parseInt(captures[3]) || 0;
|
|
4338
|
+
if (!validateTimezone(hours, minutes)) {
|
|
4339
|
+
return NaN;
|
|
4340
|
+
}
|
|
4341
|
+
return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
|
|
4342
|
+
}
|
|
4343
|
+
function dayOfISOWeekYear(isoWeekYear, week, day) {
|
|
4344
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
4345
|
+
date.setUTCFullYear(isoWeekYear, 0, 4);
|
|
4346
|
+
const fourthOfJanuaryDay = date.getUTCDay() || 7;
|
|
4347
|
+
const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
|
|
4348
|
+
date.setUTCDate(date.getUTCDate() + diff);
|
|
4349
|
+
return date;
|
|
4350
|
+
}
|
|
4351
|
+
var daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
4352
|
+
function isLeapYearIndex(year) {
|
|
4353
|
+
return year % 400 === 0 || year % 4 === 0 && year % 100 !== 0;
|
|
4354
|
+
}
|
|
4355
|
+
function validateDate(year, month, date) {
|
|
4356
|
+
return month >= 0 && month <= 11 && date >= 1 && date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28));
|
|
4357
|
+
}
|
|
4358
|
+
function validateDayOfYearDate(year, dayOfYear) {
|
|
4359
|
+
return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
|
|
4360
|
+
}
|
|
4361
|
+
function validateWeekDate(_year, week, day) {
|
|
4362
|
+
return week >= 1 && week <= 53 && day >= 0 && day <= 6;
|
|
4363
|
+
}
|
|
4364
|
+
function validateTime(hours, minutes, seconds) {
|
|
4365
|
+
if (hours === 24) {
|
|
4366
|
+
return minutes === 0 && seconds === 0;
|
|
4367
|
+
}
|
|
4368
|
+
return seconds >= 0 && seconds < 60 && minutes >= 0 && minutes < 60 && hours >= 0 && hours < 25;
|
|
4369
|
+
}
|
|
4370
|
+
function validateTimezone(_hours, minutes) {
|
|
4371
|
+
return minutes >= 0 && minutes <= 59;
|
|
4372
|
+
}
|
|
4373
|
+
function Label4({ className, ...props }) {
|
|
4374
|
+
return /* @__PURE__ */ jsx(
|
|
4375
|
+
LabelPrimitive2.Root,
|
|
4376
|
+
{
|
|
4377
|
+
"data-slot": "label",
|
|
4378
|
+
className: cn2(
|
|
4379
|
+
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
4380
|
+
className
|
|
4381
|
+
),
|
|
4382
|
+
...props
|
|
4383
|
+
}
|
|
4384
|
+
);
|
|
4385
|
+
}
|
|
4386
|
+
var Form2 = FormProvider;
|
|
4387
|
+
var FormFieldContext3 = React3.createContext({});
|
|
4388
|
+
var FormField3 = ({
|
|
4389
|
+
...props
|
|
4390
|
+
}) => {
|
|
4391
|
+
return /* @__PURE__ */ jsx(FormFieldContext3.Provider, { value: { name: props.name }, children: /* @__PURE__ */ jsx(Controller, { ...props }) });
|
|
4392
|
+
};
|
|
4393
|
+
var useFormField3 = () => {
|
|
4394
|
+
const fieldContext = React3.useContext(FormFieldContext3);
|
|
4395
|
+
const itemContext = React3.useContext(FormItemContext3);
|
|
4396
|
+
const { getFieldState } = useFormContext();
|
|
4397
|
+
const formState = useFormState({ name: fieldContext.name });
|
|
4398
|
+
const fieldState = getFieldState(fieldContext.name, formState);
|
|
4399
|
+
if (!fieldContext) {
|
|
4400
|
+
throw new Error("useFormField should be used within <FormField>");
|
|
4401
|
+
}
|
|
4402
|
+
const { id } = itemContext;
|
|
4403
|
+
return {
|
|
4404
|
+
id,
|
|
4405
|
+
name: fieldContext.name,
|
|
4406
|
+
formItemId: `${id}-form-item`,
|
|
4407
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
4408
|
+
formMessageId: `${id}-form-item-message`,
|
|
4409
|
+
...fieldState
|
|
4410
|
+
};
|
|
4411
|
+
};
|
|
4412
|
+
var FormItemContext3 = React3.createContext({});
|
|
4413
|
+
function FormItem3({ className, ...props }) {
|
|
4414
|
+
const id = React3.useId();
|
|
4415
|
+
return /* @__PURE__ */ jsx(FormItemContext3.Provider, { value: { id }, children: /* @__PURE__ */ jsx("div", { "data-slot": "form-item", className: cn2("grid gap-2", className), ...props }) });
|
|
4416
|
+
}
|
|
4417
|
+
function FormControl2({ ...props }) {
|
|
4418
|
+
const { error, formItemId, formDescriptionId, formMessageId } = useFormField3();
|
|
4419
|
+
return /* @__PURE__ */ jsx(
|
|
4420
|
+
Slot,
|
|
4421
|
+
{
|
|
4422
|
+
"data-slot": "form-control",
|
|
4423
|
+
id: formItemId,
|
|
4424
|
+
"aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
|
|
4425
|
+
"aria-invalid": !!error,
|
|
4426
|
+
...props
|
|
4427
|
+
}
|
|
4428
|
+
);
|
|
4429
|
+
}
|
|
4430
|
+
var AdvanceSearchRow = ({
|
|
4431
|
+
row,
|
|
4432
|
+
isFirst,
|
|
4433
|
+
fields,
|
|
4434
|
+
fieldOptions,
|
|
4435
|
+
operators,
|
|
4436
|
+
onChangeField,
|
|
4437
|
+
onChangeOperator,
|
|
4438
|
+
onAdd,
|
|
4439
|
+
onRemove,
|
|
4440
|
+
onClear
|
|
4441
|
+
}) => {
|
|
4442
|
+
const form = useFormContext();
|
|
4443
|
+
const { control } = form;
|
|
4444
|
+
const fieldSchema = fields.find((f) => f.name === row.fieldName);
|
|
4445
|
+
const fieldType = fieldSchema?.type ?? "text";
|
|
4446
|
+
React3__default.useEffect(() => {
|
|
4447
|
+
if (operators && operators.length > 0 && !operators.includes(row.operator)) {
|
|
4448
|
+
onChangeOperator(operators[0]);
|
|
4449
|
+
}
|
|
4450
|
+
}, [operators, row.operator, onChangeOperator]);
|
|
4451
|
+
const isBetween = row.operator === "between";
|
|
4452
|
+
const isCheckbox = fieldType === "checkbox";
|
|
4453
|
+
const isDropdown = fieldType === "dropdown";
|
|
4454
|
+
const isLookup = fieldType === "lookup";
|
|
4455
|
+
const isNumber = fieldType === "number";
|
|
4456
|
+
const isDate2 = fieldType === "date" || fieldType === "datetime";
|
|
4457
|
+
const [openDateValue1, setOpenDateValue1] = React3__default.useState(false);
|
|
4458
|
+
const [openDateValue2, setOpenDateValue2] = React3__default.useState(false);
|
|
4459
|
+
const toDateFromISO = (v) => {
|
|
4460
|
+
if (!v) return void 0;
|
|
4461
|
+
try {
|
|
4462
|
+
const d = parseISO(v);
|
|
4463
|
+
return isValid(d) ? d : void 0;
|
|
4464
|
+
} catch {
|
|
4465
|
+
return void 0;
|
|
4466
|
+
}
|
|
4467
|
+
};
|
|
4468
|
+
const getOpeatorLabel = (operator) => {
|
|
4469
|
+
return OPERATOR_LABEL[operator] ?? operator;
|
|
4470
|
+
};
|
|
4471
|
+
const capitalizeFirst = (str) => {
|
|
4472
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
4473
|
+
};
|
|
4474
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-3 md:flex-row md:items-center md:space-x-1 md:space-y-0 w-full mb-6", children: [
|
|
4475
|
+
/* @__PURE__ */ jsx("div", { className: "w-full md:w-1/8", children: /* @__PURE__ */ jsxs(Select2, { value: row.fieldName, onValueChange: (value) => onChangeField(value), children: [
|
|
4476
|
+
/* @__PURE__ */ jsx(SelectTrigger2, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue2, { placeholder: row.fieldName }) }),
|
|
4477
|
+
/* @__PURE__ */ jsx(SelectContent2, { children: fieldOptions.map((f) => /* @__PURE__ */ jsx(SelectItem2, { value: f.value, children: capitalizeFirst(f.label) }, f.value)) })
|
|
4478
|
+
] }) }),
|
|
4479
|
+
/* @__PURE__ */ jsx("div", { className: "w-full md:w-1/8", children: /* @__PURE__ */ jsxs(Select2, { value: row.operator, onValueChange: (value) => onChangeOperator(value), children: [
|
|
4480
|
+
/* @__PURE__ */ jsx(SelectTrigger2, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue2, { placeholder: row.operator }) }),
|
|
4481
|
+
/* @__PURE__ */ jsx(SelectContent2, { children: operators.map((op) => /* @__PURE__ */ jsx(SelectItem2, { value: op, children: getOpeatorLabel(op) }, op)) })
|
|
4482
|
+
] }) }),
|
|
4483
|
+
/* @__PURE__ */ jsx("div", { className: "w-full md:flex-1", children: !isBetween ? /* @__PURE__ */ jsx(
|
|
4484
|
+
FormField3,
|
|
4485
|
+
{
|
|
4486
|
+
control,
|
|
4487
|
+
name: `value_${row.id}`,
|
|
4488
|
+
rules: { required: "This field is required." },
|
|
4489
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsx(FormItem3, { children: isCheckbox ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
4490
|
+
/* @__PURE__ */ jsxs(Select2, { value: field.value ?? "", onValueChange: (value) => field.onChange(value), children: [
|
|
4491
|
+
/* @__PURE__ */ jsx(FormControl2, { children: /* @__PURE__ */ jsx(SelectTrigger2, { className: "w-full pr-8", children: /* @__PURE__ */ jsx(SelectValue2, { placeholder: "" }) }) }),
|
|
4492
|
+
/* @__PURE__ */ jsxs(SelectContent2, { children: [
|
|
4493
|
+
/* @__PURE__ */ jsx(SelectItem2, { value: "true", children: "true" }),
|
|
4494
|
+
/* @__PURE__ */ jsx(SelectItem2, { value: "false", children: "false" })
|
|
4495
|
+
] })
|
|
4496
|
+
] }),
|
|
4497
|
+
/* @__PURE__ */ jsx("span", { className: "absolute right-3 top-2.5 flex justify-center items-center space-x-1", children: /* @__PURE__ */ jsx(ClearButton, { onClick: onClear }) }),
|
|
4498
|
+
fieldState.error && !field.value && /* @__PURE__ */ jsx("span", { className: "absolute top-10 text-red-600 text-xs", children: "This field is required." })
|
|
4499
|
+
] }) : isDropdown && fieldSchema && "options" in fieldSchema ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
4500
|
+
/* @__PURE__ */ jsxs(Select2, { value: field.value ?? "", onValueChange: (value) => field.onChange(value), children: [
|
|
4501
|
+
/* @__PURE__ */ jsx(FormControl2, { children: /* @__PURE__ */ jsx(SelectTrigger2, { className: "w-full pr-8", children: /* @__PURE__ */ jsx(SelectValue2, { placeholder: "" }) }) }),
|
|
4502
|
+
/* @__PURE__ */ jsx(SelectContent2, { children: fieldSchema.options.map((opt) => /* @__PURE__ */ jsx(SelectItem2, { value: opt.value, children: opt.label }, opt.value)) })
|
|
4503
|
+
] }),
|
|
4504
|
+
/* @__PURE__ */ jsx("span", { className: "absolute right-3 top-2.5 flex justify-center items-center space-x-1", children: /* @__PURE__ */ jsx(ClearButton, { onClick: onClear }) }),
|
|
4505
|
+
fieldState.error && !field.value && /* @__PURE__ */ jsx("span", { className: "absolute top-10 text-red-600 text-xs", children: "This field is required." })
|
|
4506
|
+
] }) : isDate2 ? /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
4507
|
+
/* @__PURE__ */ jsxs(Popover, { open: openDateValue1, onOpenChange: setOpenDateValue1, children: [
|
|
4508
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(FormControl2, { children: /* @__PURE__ */ jsxs(
|
|
4509
|
+
Button3,
|
|
4510
|
+
{
|
|
4511
|
+
type: "button",
|
|
4512
|
+
variant: "outline",
|
|
4513
|
+
className: cn2(
|
|
4514
|
+
"w-full justify-start text-left font-normal",
|
|
4515
|
+
!field.value && "text-muted-foreground"
|
|
4516
|
+
),
|
|
4517
|
+
onClick: () => setOpenDateValue1((v) => !v),
|
|
4518
|
+
children: [
|
|
4519
|
+
field.value ? format(toDateFromISO(field.value), "dd/MM/yyyy") : "DD/MM/YYYY",
|
|
4520
|
+
/* @__PURE__ */ jsxs("span", { className: "absolute right-3 top-2.5 flex justify-center items-center space-x-1", children: [
|
|
4521
|
+
/* @__PURE__ */ jsx(CalendarIcon, { className: "w-4 h-4 text-[#c0c0c0]" }),
|
|
4522
|
+
/* @__PURE__ */ jsx(ClearButton, { onClick: onClear })
|
|
4523
|
+
] })
|
|
4524
|
+
]
|
|
4525
|
+
}
|
|
4526
|
+
) }) }),
|
|
4527
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsx(
|
|
4528
|
+
DatePicker,
|
|
4529
|
+
{
|
|
4530
|
+
variant: { day: { selected: "outline" } },
|
|
4531
|
+
selectedDate: toDateFromISO(field.value),
|
|
4532
|
+
onDateSelect: (d) => {
|
|
4533
|
+
field.onChange(d ? format(d, "yyyy-MM-dd") : void 0);
|
|
4534
|
+
if (d) setOpenDateValue1(false);
|
|
4535
|
+
}
|
|
4536
|
+
}
|
|
4537
|
+
) })
|
|
4538
|
+
] }),
|
|
4539
|
+
fieldState.error && !field.value && /* @__PURE__ */ jsx("span", { className: "absolute left-0 top-10 text-red-600 text-xs", children: "This field is required." })
|
|
4540
|
+
] }) : isNumber ? /* @__PURE__ */ jsxs("div", { className: "relative flex items-center", children: [
|
|
4541
|
+
/* @__PURE__ */ jsx(FormControl2, { children: /* @__PURE__ */ jsx(
|
|
4542
|
+
Input,
|
|
4543
|
+
{
|
|
4544
|
+
...field,
|
|
4545
|
+
type: "number",
|
|
4546
|
+
value: field.value ?? "",
|
|
4547
|
+
autoComplete: "off",
|
|
4548
|
+
inputMode: "numeric",
|
|
4549
|
+
className: "focus-visible:ring-0 focus-visible:ring-offset-0 focus:outline-none focus:border-sus-green-1 pr-8"
|
|
4550
|
+
}
|
|
4551
|
+
) }),
|
|
4552
|
+
/* @__PURE__ */ jsx("span", { className: "absolute right-3 top-2.5 flex justify-center items-center space-x-1", children: /* @__PURE__ */ jsx(ClearButton, { onClick: onClear }) }),
|
|
4553
|
+
fieldState.error && !field.value && /* @__PURE__ */ jsx("span", { className: "absolute top-10 text-red-600 text-xs", children: "This field is required." })
|
|
4554
|
+
] }) : isLookup ? /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
4555
|
+
/* @__PURE__ */ jsx(FormControl2, { children: /* @__PURE__ */ jsx(
|
|
4556
|
+
TagsInput,
|
|
4557
|
+
{
|
|
4558
|
+
value: Array.isArray(field.value) ? field.value : [],
|
|
4559
|
+
onChange: field.onChange,
|
|
4560
|
+
onClear,
|
|
4561
|
+
error: !!fieldState.error
|
|
4562
|
+
}
|
|
4563
|
+
) }),
|
|
4564
|
+
fieldState.error && (!field.value || field.value.length === 0) && /* @__PURE__ */ jsx("span", { className: "absolute top-10 text-red-600 text-xs", children: "This field is required." })
|
|
4565
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "relative flex items-center", children: [
|
|
4566
|
+
/* @__PURE__ */ jsx(FormControl2, { children: /* @__PURE__ */ jsx(
|
|
4567
|
+
Input,
|
|
4568
|
+
{
|
|
4569
|
+
...field,
|
|
4570
|
+
value: field.value ?? "",
|
|
4571
|
+
autoComplete: "off",
|
|
4572
|
+
inputMode: "text",
|
|
4573
|
+
className: "focus-visible:ring-0 focus-visible:ring-offset-0 focus:outline-none focus:border-sus-green-1"
|
|
4574
|
+
}
|
|
4575
|
+
) }),
|
|
4576
|
+
/* @__PURE__ */ jsxs("span", { className: "absolute right-3 top-2.5 flex justify-center items-center space-x-1", children: [
|
|
4577
|
+
/* @__PURE__ */ jsx(Search, { className: "w-4 h-4 text-[#c0c0c0]" }),
|
|
4578
|
+
/* @__PURE__ */ jsx(ClearButton, { onClick: onClear })
|
|
4579
|
+
] }),
|
|
4580
|
+
fieldState.error && !field.value && /* @__PURE__ */ jsx("span", { className: "absolute top-10 text-red-600 text-xs", children: "This field is required." })
|
|
4581
|
+
] }) })
|
|
4582
|
+
}
|
|
4583
|
+
) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col md:flex-row md:items-center md:space-x-2 md:space-y-0 space-y-3", children: [
|
|
4584
|
+
/* @__PURE__ */ jsx(
|
|
4585
|
+
FormField3,
|
|
4586
|
+
{
|
|
4587
|
+
control,
|
|
4588
|
+
name: `value_${row.id}`,
|
|
4589
|
+
rules: { required: "This field is required." },
|
|
4590
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsx(FormItem3, { className: "relative w-full md:w-1/2", children: /* @__PURE__ */ jsxs(Popover, { open: openDateValue1, onOpenChange: setOpenDateValue1, children: [
|
|
4591
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(FormControl2, { children: /* @__PURE__ */ jsxs(
|
|
4592
|
+
Button3,
|
|
4593
|
+
{
|
|
4594
|
+
type: "button",
|
|
4595
|
+
variant: "outline",
|
|
4596
|
+
className: cn2(
|
|
4597
|
+
"w-full justify-start text-left font-normal",
|
|
4598
|
+
!field.value && "text-muted-foreground"
|
|
4599
|
+
),
|
|
4600
|
+
onClick: () => setOpenDateValue1((v) => !v),
|
|
4601
|
+
children: [
|
|
4602
|
+
field.value ? format(toDateFromISO(field.value), "dd/MM/yyyy") : "DD/MM/YYYY",
|
|
4603
|
+
/* @__PURE__ */ jsxs("span", { className: "absolute right-3 top-2.5 flex justify-center items-center space-x-1", children: [
|
|
4604
|
+
/* @__PURE__ */ jsx(CalendarIcon, { className: "w-4 h-4 text-[#c0c0c0]" }),
|
|
4605
|
+
/* @__PURE__ */ jsx(ClearButton, { onClick: onClear })
|
|
4606
|
+
] }),
|
|
4607
|
+
fieldState.error && !field.value && /* @__PURE__ */ jsx("span", { className: "absolute left-0 top-10 text-red-600 text-xs", children: "This field is required." })
|
|
4608
|
+
]
|
|
4609
|
+
}
|
|
4610
|
+
) }) }),
|
|
4611
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsx(
|
|
4612
|
+
DatePicker,
|
|
4613
|
+
{
|
|
4614
|
+
selectedDate: toDateFromISO(field.value),
|
|
4615
|
+
onDateSelect: (d) => {
|
|
4616
|
+
field.onChange(d ? format(d, "yyyy-MM-dd") : void 0);
|
|
4617
|
+
if (d) setOpenDateValue1(false);
|
|
4618
|
+
}
|
|
4619
|
+
}
|
|
4620
|
+
) })
|
|
4621
|
+
] }) })
|
|
4622
|
+
}
|
|
4623
|
+
),
|
|
4624
|
+
/* @__PURE__ */ jsx("span", { className: "text-black font-bold text-center", children: "To" }),
|
|
4625
|
+
/* @__PURE__ */ jsx(
|
|
4626
|
+
FormField3,
|
|
4627
|
+
{
|
|
4628
|
+
control,
|
|
4629
|
+
name: `value2_${row.id}`,
|
|
4630
|
+
rules: { required: "This field is required." },
|
|
4631
|
+
render: ({ field, fieldState }) => /* @__PURE__ */ jsx(FormItem3, { className: "relative w-full md:w-1/2", children: /* @__PURE__ */ jsxs(Popover, { open: openDateValue2, onOpenChange: setOpenDateValue2, children: [
|
|
4632
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(FormControl2, { children: /* @__PURE__ */ jsxs(
|
|
4633
|
+
Button3,
|
|
4634
|
+
{
|
|
4635
|
+
type: "button",
|
|
4636
|
+
variant: "outline",
|
|
4637
|
+
className: cn2(
|
|
4638
|
+
"w-full justify-start text-left font-normal",
|
|
4639
|
+
!field.value && "text-muted-foreground"
|
|
4640
|
+
),
|
|
4641
|
+
onClick: () => setOpenDateValue2((v) => !v),
|
|
4642
|
+
children: [
|
|
4643
|
+
field.value ? format(toDateFromISO(field.value), "dd/MM/yyyy") : "DD/MM/YYYY",
|
|
4644
|
+
/* @__PURE__ */ jsxs("span", { className: "absolute right-3 top-2.5 flex justify-center items-center space-x-1", children: [
|
|
4645
|
+
/* @__PURE__ */ jsx(CalendarIcon, { className: "w-4 h-4 text-[#c0c0c0]" }),
|
|
4646
|
+
/* @__PURE__ */ jsx(ClearButton, { onClick: onClear })
|
|
4647
|
+
] }),
|
|
4648
|
+
fieldState.error && !field.value && /* @__PURE__ */ jsx("span", { className: "absolute left-0 top-10 text-red-600 text-xs", children: "This field is required." })
|
|
4649
|
+
]
|
|
4650
|
+
}
|
|
4651
|
+
) }) }),
|
|
4652
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "w-auto p-0", align: "start", children: /* @__PURE__ */ jsx(
|
|
4653
|
+
DatePicker,
|
|
4654
|
+
{
|
|
4655
|
+
selectedDate: toDateFromISO(field.value),
|
|
4656
|
+
onDateSelect: (d) => {
|
|
4657
|
+
field.onChange(d ? format(d, "yyyy-MM-dd") : void 0);
|
|
4658
|
+
if (d) setOpenDateValue2(false);
|
|
4659
|
+
}
|
|
4660
|
+
}
|
|
4661
|
+
) })
|
|
4662
|
+
] }) })
|
|
4663
|
+
}
|
|
4664
|
+
)
|
|
4665
|
+
] }) }),
|
|
4666
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-center", children: isFirst ? /* @__PURE__ */ jsx(
|
|
4667
|
+
Button3,
|
|
4668
|
+
{
|
|
4669
|
+
type: "button",
|
|
4670
|
+
onClick: onAdd,
|
|
4671
|
+
className: "circle-btn bg-[#41875C] border border-[#41875C] text-white hover:bg-[#3a6f4e] transition duration-150",
|
|
4672
|
+
"aria-label": "Add row",
|
|
4673
|
+
title: "Add condition",
|
|
4674
|
+
children: /* @__PURE__ */ jsx(Plus, { className: "w-3 h-3 stroke-[2]" })
|
|
4675
|
+
}
|
|
4676
|
+
) : /* @__PURE__ */ jsx(
|
|
4677
|
+
Button3,
|
|
4678
|
+
{
|
|
4679
|
+
type: "button",
|
|
4680
|
+
onClick: onRemove,
|
|
4681
|
+
className: "circle-btn bg-white border-2 border-[#82b495] text-[#82b495] hover:bg-[#82b495] hover:text-white transition duration-150",
|
|
4682
|
+
"aria-label": "Remove row",
|
|
4683
|
+
title: "Remove condition",
|
|
4684
|
+
children: /* @__PURE__ */ jsx(Minus, { className: "w-3 h-3 stroke-[2]" })
|
|
4685
|
+
}
|
|
4686
|
+
) })
|
|
4687
|
+
] });
|
|
4688
|
+
};
|
|
4689
|
+
var AdvanceSearch = ({
|
|
4690
|
+
fields,
|
|
4691
|
+
portalId,
|
|
4692
|
+
iconColor = "#ffffff",
|
|
4693
|
+
limitRows = 4,
|
|
4694
|
+
onSearch
|
|
4695
|
+
}) => {
|
|
4696
|
+
const fieldsData = useMemo(() => fields || [], [fields]);
|
|
4697
|
+
const {
|
|
4698
|
+
rows,
|
|
4699
|
+
addRow,
|
|
4700
|
+
removeRow,
|
|
4701
|
+
clearRow,
|
|
4702
|
+
clearAllRow,
|
|
4703
|
+
changeField,
|
|
4704
|
+
changeOperator,
|
|
4705
|
+
operatorsForField,
|
|
4706
|
+
fieldOptions
|
|
4707
|
+
} = useAdvanceSearch({ fields: fieldsData, limitRows });
|
|
4708
|
+
const form = useForm({
|
|
4709
|
+
mode: "onSubmit",
|
|
4710
|
+
reValidateMode: "onSubmit",
|
|
4711
|
+
defaultValues: {}
|
|
4712
|
+
});
|
|
4713
|
+
const { handleSubmit, unregister, resetField, getValues, setValue } = form;
|
|
4714
|
+
const onSubmit = useCallback(() => {
|
|
4715
|
+
const currentValues = getValues();
|
|
4716
|
+
const param = {
|
|
4717
|
+
AND: rows.map((r2) => {
|
|
4718
|
+
const val1 = currentValues[`value_${r2.id}`];
|
|
4719
|
+
const val2 = currentValues[`value2_${r2.id}`];
|
|
4720
|
+
if (r2.operator === "between") {
|
|
4721
|
+
if (!val1 || !val2) return null;
|
|
4722
|
+
return {
|
|
4723
|
+
[r2.fieldName]: {
|
|
4724
|
+
gte: val1,
|
|
4725
|
+
lte: val2
|
|
4726
|
+
}
|
|
4727
|
+
};
|
|
4728
|
+
}
|
|
4729
|
+
if (!val1) return null;
|
|
4730
|
+
switch (r2.operator) {
|
|
4731
|
+
case "contains":
|
|
4732
|
+
return { [r2.fieldName]: { contains: val1 } };
|
|
4733
|
+
case "beginsWith":
|
|
4734
|
+
return { [r2.fieldName]: { startsWith: val1 } };
|
|
4735
|
+
case "endsWith":
|
|
4736
|
+
return { [r2.fieldName]: { endsWith: val1 } };
|
|
4737
|
+
case "notEquals":
|
|
4738
|
+
return { [r2.fieldName]: { not: val1 } };
|
|
4739
|
+
case "gt":
|
|
4740
|
+
return { [r2.fieldName]: { gt: val1 } };
|
|
4741
|
+
case "gte":
|
|
4742
|
+
return { [r2.fieldName]: { gte: val1 } };
|
|
4743
|
+
case "lt":
|
|
4744
|
+
return { [r2.fieldName]: { lt: val1 } };
|
|
4745
|
+
case "lte":
|
|
4746
|
+
return { [r2.fieldName]: { lte: val1 } };
|
|
4747
|
+
case "is":
|
|
4748
|
+
return { [r2.fieldName]: val1 };
|
|
4749
|
+
case "isNot":
|
|
4750
|
+
return { [r2.fieldName]: { not: val1 } };
|
|
4751
|
+
case "notContains":
|
|
4752
|
+
return { [r2.fieldName]: { not: { contains: val1 } } };
|
|
4753
|
+
case "notBeginsWith":
|
|
4754
|
+
return { [r2.fieldName]: { not: { startsWith: val1 } } };
|
|
4755
|
+
case "notEndsWith":
|
|
4756
|
+
return { [r2.fieldName]: { not: { endsWith: val1 } } };
|
|
4757
|
+
case "containsAny":
|
|
4758
|
+
return { [r2.fieldName]: { hasSome: String(val1).split(",") } };
|
|
4759
|
+
case "containsAll":
|
|
4760
|
+
return { [r2.fieldName]: { hasEvery: String(val1).split(",") } };
|
|
4761
|
+
case "containsOnly":
|
|
4762
|
+
return { [r2.fieldName]: { equals: String(val1).split(",") } };
|
|
4763
|
+
default:
|
|
4764
|
+
return { [r2.fieldName]: val1 };
|
|
4765
|
+
}
|
|
4766
|
+
}).filter(Boolean)
|
|
4767
|
+
};
|
|
4768
|
+
if (onSearch) {
|
|
4769
|
+
onSearch(param);
|
|
4770
|
+
}
|
|
4771
|
+
}, [getValues, rows, onSearch]);
|
|
4772
|
+
return /* @__PURE__ */ jsx(
|
|
4773
|
+
ExpandCollapse_default,
|
|
4774
|
+
{
|
|
4775
|
+
title: /* @__PURE__ */ jsx(Search, { className: "w-5 h-5", style: { color: iconColor } }),
|
|
4776
|
+
portalId,
|
|
4777
|
+
children: /* @__PURE__ */ jsx(Form2, { ...form, children: /* @__PURE__ */ jsx("form", { onSubmit: handleSubmit(onSubmit), className: "w-[70%] flex justify-center mx-auto", children: /* @__PURE__ */ jsxs("div", { className: "rounded w-full md:w-3/4", children: [
|
|
4778
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-between items-center mb-2", children: /* @__PURE__ */ jsx(Label4, { className: "font-bold text-black", children: "Select field" }) }),
|
|
4779
|
+
rows.map((row, idx) => /* @__PURE__ */ jsx(
|
|
4780
|
+
AdvanceSearchRow,
|
|
4781
|
+
{
|
|
4782
|
+
row,
|
|
4783
|
+
isFirst: idx === 0,
|
|
4784
|
+
fields: fieldsData,
|
|
4785
|
+
fieldOptions,
|
|
4786
|
+
operators: operatorsForField(row.fieldName),
|
|
4787
|
+
onChangeField: (f) => {
|
|
4788
|
+
changeField(row.id, f);
|
|
4789
|
+
setValue(`value_${row.id}`, void 0);
|
|
4790
|
+
setValue(`value2_${row.id}`, void 0);
|
|
4791
|
+
},
|
|
4792
|
+
onChangeOperator: (op) => {
|
|
4793
|
+
changeOperator(row.id, op);
|
|
4794
|
+
setValue(`value_${row.id}`, void 0);
|
|
4795
|
+
setValue(`value2_${row.id}`, void 0);
|
|
4796
|
+
},
|
|
4797
|
+
onAdd: addRow,
|
|
4798
|
+
onRemove: () => {
|
|
4799
|
+
removeRow(row.id);
|
|
4800
|
+
unregister(`value_${row.id}`);
|
|
4801
|
+
unregister(`value2_${row.id}`);
|
|
4802
|
+
},
|
|
4803
|
+
onClear: () => {
|
|
4804
|
+
clearRow(row.id);
|
|
4805
|
+
resetField(`value_${row.id}`);
|
|
4806
|
+
resetField(`value2_${row.id}`);
|
|
4807
|
+
}
|
|
4808
|
+
},
|
|
4809
|
+
row.id
|
|
4810
|
+
)),
|
|
4811
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col-reverse md:flex-row md:justify-end gap-2 mt-4 pr-7", children: [
|
|
4812
|
+
/* @__PURE__ */ jsx(
|
|
4813
|
+
Button3,
|
|
4814
|
+
{
|
|
4815
|
+
type: "button",
|
|
4816
|
+
className: "w-full md:w-auto md:min-w-[100px] bg-[#8b8b8b]",
|
|
4817
|
+
onClick: () => {
|
|
4818
|
+
clearAllRow();
|
|
4819
|
+
Object.keys(getValues()).forEach((k) => resetField(k));
|
|
4820
|
+
},
|
|
4821
|
+
children: "Clear Search"
|
|
4822
|
+
}
|
|
4823
|
+
),
|
|
4824
|
+
/* @__PURE__ */ jsx(
|
|
4825
|
+
Button3,
|
|
4826
|
+
{
|
|
4827
|
+
type: "submit",
|
|
4828
|
+
className: "w-full md:w-auto md:min-w-[100px] bg-[#379a2a] hover:bg-[#3a6f4e]",
|
|
4829
|
+
onClick: onSubmit,
|
|
4830
|
+
children: "Search"
|
|
4831
|
+
}
|
|
4832
|
+
)
|
|
4833
|
+
] })
|
|
4834
|
+
] }) }) })
|
|
4835
|
+
}
|
|
4836
|
+
);
|
|
4837
|
+
};
|
|
4838
|
+
var AdvanceSearch_default = AdvanceSearch;
|
|
4839
|
+
|
|
4840
|
+
export { AdvanceSearch_default as AdvanceSearch, Button, DataTable_default as DataTable, FormErrorMessage, FormField, FormFieldContext, FormItem, FormItemContext, FormLabel, GridSettingsModal_default as GridSettingsModal, HeaderCell_default as HeaderCell, navbar_default as Navbar, NumberInput, TextInput, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, renderContentSlot, selectValueToBoolean, useFormField, useGridSettingsStore, useHover_default as useHover, useIntersectionObserver_default as useIntersectionObserver, useMediaQuery_default as useMediaQuery, useScreenSize_default as useScreenSize };
|
|
4841
|
+
//# sourceMappingURL=index.mjs.map
|
|
4842
|
+
//# sourceMappingURL=index.mjs.map
|