@sustaina/shared-ui 1.9.3 → 1.9.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/dist/index.d.mts +24 -20
- package/dist/index.d.ts +24 -20
- package/dist/index.js +36 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3,9 +3,9 @@ import clsx2, { clsx } from 'clsx';
|
|
|
3
3
|
import { twMerge } from 'tailwind-merge';
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import * as React6 from 'react';
|
|
6
|
-
import React6__default, { forwardRef, useRef, useMemo, useCallback,
|
|
6
|
+
import React6__default, { forwardRef, useRef, useMemo, useCallback, useEffect, createElement, isValidElement, useState } from 'react';
|
|
7
7
|
import { format, isValid, parseISO, isAfter, compareAsc, parse } from 'date-fns';
|
|
8
|
-
import { CircleX, CircleHelp, Undo, Redo, Bold, Italic, Underline, Strikethrough, Code, Pilcrow, Heading1, Heading2, Heading3, List as List$1, ListOrdered, Quote, CodeSquare, Link, Link2Off, Image, AlignLeft, AlignCenter, AlignRight, XIcon, ChevronRight, CheckIcon, Triangle, CalendarIcon, X, Search, ChevronUp, ChevronDown, Plus, ChevronLeft, CircleUserRound,
|
|
8
|
+
import { CircleX, CircleHelp, Undo, Redo, Bold, Italic, Underline, Strikethrough, Code, Pilcrow, Heading1, Heading2, Heading3, List as List$1, ListOrdered, Quote, CodeSquare, Link, Link2Off, Image, AlignLeft, AlignCenter, AlignRight, Bug, XIcon, ChevronRight, CheckIcon, Triangle, CalendarIcon, X, Search, ChevronUp, ChevronDown, Plus, ChevronLeft, CircleUserRound, GripVertical, Info, CircleMinus, Minus } from 'lucide-react';
|
|
9
9
|
import { createPortal } from 'react-dom';
|
|
10
10
|
import * as SelectPrimitive from '@radix-ui/react-select';
|
|
11
11
|
import { useForm, FormProvider, Controller, useFormContext, useFormState, useFieldArray, useWatch } from 'react-hook-form';
|
|
@@ -14,7 +14,7 @@ import * as LabelPrimitive from '@radix-ui/react-label';
|
|
|
14
14
|
import { cva } from 'class-variance-authority';
|
|
15
15
|
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
16
16
|
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
17
|
-
import {
|
|
17
|
+
import { useReactTable, getCoreRowModel, getGroupedRowModel, getExpandedRowModel, getSortedRowModel, getFilteredRowModel, flexRender, reSplitAlphaNumeric } from '@tanstack/react-table';
|
|
18
18
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
19
19
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
20
20
|
import { SortableContext, verticalListSortingStrategy, useSortable } from '@dnd-kit/sortable';
|
|
@@ -3678,7 +3678,7 @@ var StatusContentSlot = ({
|
|
|
3678
3678
|
content
|
|
3679
3679
|
] });
|
|
3680
3680
|
};
|
|
3681
|
-
var StatusContentSlot_default = StatusContentSlot;
|
|
3681
|
+
var StatusContentSlot_default = React6__default.memo(StatusContentSlot);
|
|
3682
3682
|
var stateOptions = [
|
|
3683
3683
|
"columnFilters",
|
|
3684
3684
|
"globalFilter",
|
|
@@ -3895,6 +3895,7 @@ var DataTable = ({
|
|
|
3895
3895
|
rowSelection,
|
|
3896
3896
|
rowExpansion,
|
|
3897
3897
|
scrollFetch,
|
|
3898
|
+
activeStatusContent,
|
|
3898
3899
|
statusContent,
|
|
3899
3900
|
rowIdKey,
|
|
3900
3901
|
childrenKey,
|
|
@@ -4010,6 +4011,31 @@ var DataTable = ({
|
|
|
4010
4011
|
);
|
|
4011
4012
|
return { isSomeColumnsFilterable: isSomeColumnsFilterable2, filterableColumns: mergedColumns };
|
|
4012
4013
|
}, [centerVisibleLeafColumns, leftVisibleLeftColumns, rightVisibleLeafColumns]);
|
|
4014
|
+
const autoStatusKey = useMemo(() => {
|
|
4015
|
+
if (isInitialLoading) return "initialLoading";
|
|
4016
|
+
if (isTableEmpty) return "emptyData";
|
|
4017
|
+
if (isTableEmptyAfterFiltering) return "emptyFilteredData";
|
|
4018
|
+
if (scrollFetch?.enabled && !isFiltering && !isInitialLoading) {
|
|
4019
|
+
if (scrollFetch.isFetchingMore) return "fetchingMore";
|
|
4020
|
+
if (scrollFetch.hasMore === false && !scrollFetch.isFetchingMore) return "noMoreData";
|
|
4021
|
+
}
|
|
4022
|
+
return null;
|
|
4023
|
+
}, [
|
|
4024
|
+
isInitialLoading,
|
|
4025
|
+
isFiltering,
|
|
4026
|
+
isTableEmpty,
|
|
4027
|
+
isTableEmptyAfterFiltering,
|
|
4028
|
+
scrollFetch?.enabled,
|
|
4029
|
+
scrollFetch?.hasMore,
|
|
4030
|
+
scrollFetch?.isFetchingMore
|
|
4031
|
+
]);
|
|
4032
|
+
const activeStatusContentComputed = useMemo(() => {
|
|
4033
|
+
if (!activeStatusContent) return autoStatusKey;
|
|
4034
|
+
if (typeof activeStatusContent === "function") {
|
|
4035
|
+
return activeStatusContent({ defaultComputedValue: autoStatusKey });
|
|
4036
|
+
}
|
|
4037
|
+
return activeStatusContent;
|
|
4038
|
+
}, [activeStatusContent, autoStatusKey]);
|
|
4013
4039
|
const fetchMoreOnScrollReached = useCallback(
|
|
4014
4040
|
(containerRefElement) => {
|
|
4015
4041
|
if (!scrollFetch?.enabled || !containerRefElement || scrollFetch?.isFetchingMore || !scrollFetch?.hasMore || !scrollFetch?.fetchMore) {
|
|
@@ -4058,7 +4084,7 @@ var DataTable = ({
|
|
|
4058
4084
|
),
|
|
4059
4085
|
onScroll: (e) => fetchMoreOnScrollReached(e.currentTarget),
|
|
4060
4086
|
children: [
|
|
4061
|
-
|
|
4087
|
+
activeStatusContentComputed === "initialLoading" ? /* @__PURE__ */ jsx(
|
|
4062
4088
|
StatusContentSlot_default,
|
|
4063
4089
|
{
|
|
4064
4090
|
content: statusContent?.initialLoading?.content ?? "Loading...",
|
|
@@ -4069,7 +4095,7 @@ var DataTable = ({
|
|
|
4069
4095
|
},
|
|
4070
4096
|
defaultIcon: /* @__PURE__ */ jsx(Spinner, { size: 48 })
|
|
4071
4097
|
}
|
|
4072
|
-
) :
|
|
4098
|
+
) : activeStatusContentComputed === "emptyData" ? /* @__PURE__ */ jsx(
|
|
4073
4099
|
StatusContentSlot_default,
|
|
4074
4100
|
{
|
|
4075
4101
|
content: statusContent?.emptyData?.content ?? "There's nothing here yet.",
|
|
@@ -4218,7 +4244,7 @@ var DataTable = ({
|
|
|
4218
4244
|
);
|
|
4219
4245
|
}) })
|
|
4220
4246
|
] }),
|
|
4221
|
-
|
|
4247
|
+
activeStatusContentComputed === "emptyFilteredData" && /* @__PURE__ */ jsx(
|
|
4222
4248
|
StatusContentSlot_default,
|
|
4223
4249
|
{
|
|
4224
4250
|
content: statusContent?.emptyFilteredData?.content ?? "No records found. Please try a different search.",
|
|
@@ -4230,7 +4256,7 @@ var DataTable = ({
|
|
|
4230
4256
|
defaultIcon: /* @__PURE__ */ jsx(empty_data_default, { className: "text-[128px]" })
|
|
4231
4257
|
}
|
|
4232
4258
|
),
|
|
4233
|
-
|
|
4259
|
+
activeStatusContentComputed === "fetchingMore" && /* @__PURE__ */ jsx(
|
|
4234
4260
|
StatusContentSlot_default,
|
|
4235
4261
|
{
|
|
4236
4262
|
content: statusContent?.fetchingMore?.content ?? "Loading more...",
|
|
@@ -4240,7 +4266,7 @@ var DataTable = ({
|
|
|
4240
4266
|
}
|
|
4241
4267
|
}
|
|
4242
4268
|
),
|
|
4243
|
-
|
|
4269
|
+
activeStatusContentComputed === "noMoreData" && /* @__PURE__ */ jsx(
|
|
4244
4270
|
StatusContentSlot_default,
|
|
4245
4271
|
{
|
|
4246
4272
|
content: statusContent?.noMoreData?.content,
|
|
@@ -4257,7 +4283,7 @@ var DataTable = ({
|
|
|
4257
4283
|
}
|
|
4258
4284
|
);
|
|
4259
4285
|
};
|
|
4260
|
-
var DataTable_default = DataTable;
|
|
4286
|
+
var DataTable_default = React6__default.memo(DataTable);
|
|
4261
4287
|
function Dialog(props) {
|
|
4262
4288
|
return /* @__PURE__ */ jsx(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
|
|
4263
4289
|
}
|
|
@@ -4773,7 +4799,7 @@ var GridSettingsModal = ({
|
|
|
4773
4799
|
}
|
|
4774
4800
|
}
|
|
4775
4801
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(Dialog, { open: isOpen, onOpenChange: (open) => !open && onClose(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "sm:max-w-xl border-0 p-0 overflow-hidden", children: [
|
|
4776
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-col
|
|
4802
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
|
|
4777
4803
|
/* @__PURE__ */ jsxs(
|
|
4778
4804
|
"div",
|
|
4779
4805
|
{
|
|
@@ -4808,7 +4834,7 @@ var GridSettingsModal = ({
|
|
|
4808
4834
|
)
|
|
4809
4835
|
] }),
|
|
4810
4836
|
/* @__PURE__ */ jsx(Form, { ...form, children: /* @__PURE__ */ jsxs("form", { onSubmit: form.handleSubmit(onSubmit), className: "mt-6 flex flex-col justify-between", children: [
|
|
4811
|
-
/* @__PURE__ */ jsx("div", { className: "px-16 my-10", children: /* @__PURE__ */ jsxs("div", { className: "space-y-3 max-h-60
|
|
4837
|
+
/* @__PURE__ */ jsx("div", { className: "px-16 my-10", children: /* @__PURE__ */ jsxs("div", { className: "space-y-3 max-h-60 pr-4", children: [
|
|
4812
4838
|
/* @__PURE__ */ jsx(
|
|
4813
4839
|
SortableRow,
|
|
4814
4840
|
{
|
|
@@ -4866,7 +4892,7 @@ var GridSettingsModal = ({
|
|
|
4866
4892
|
}
|
|
4867
4893
|
) })
|
|
4868
4894
|
] }) }),
|
|
4869
|
-
/* @__PURE__ */ jsx(DialogFooter, { className: "-mx-6 mt-6 px-6", children: /* @__PURE__ */ jsxs("div", { className: "flex justify-between w-full
|
|
4895
|
+
/* @__PURE__ */ jsx(DialogFooter, { className: "-mx-6 mt-6 px-6", children: /* @__PURE__ */ jsxs("div", { className: "flex px-4 justify-between w-full", children: [
|
|
4870
4896
|
/* @__PURE__ */ jsx(
|
|
4871
4897
|
Button,
|
|
4872
4898
|
{
|