@sustaina/shared-ui 1.22.0 → 1.23.1
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.js +36 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -18,7 +18,7 @@ import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
|
|
|
18
18
|
import { reSplitAlphaNumeric, useReactTable, getCoreRowModel, getGroupedRowModel, getExpandedRowModel, getSortedRowModel, getFilteredRowModel, flexRender } from '@tanstack/react-table';
|
|
19
19
|
import * as SheetPrimitive from '@radix-ui/react-dialog';
|
|
20
20
|
import i18n from 'i18next';
|
|
21
|
-
import { initReactI18next
|
|
21
|
+
import { initReactI18next } from 'react-i18next';
|
|
22
22
|
import { create } from 'zustand';
|
|
23
23
|
import StarterKit from '@tiptap/starter-kit';
|
|
24
24
|
import { ReactNodeViewRenderer, NodeViewWrapper, useEditor, EditorContent } from '@tiptap/react';
|
|
@@ -608,6 +608,7 @@ var ExpandCollapse = ({ title, children, portalId }) => {
|
|
|
608
608
|
{
|
|
609
609
|
onClick: () => setIsOpen(false),
|
|
610
610
|
className: "absolute top-2 right-2 text-gray-500 hover:text-gray-700",
|
|
611
|
+
"data-testid": "advsearch-icon-close",
|
|
611
612
|
children: /* @__PURE__ */ jsx(X, { className: "w-5 h-5" })
|
|
612
613
|
}
|
|
613
614
|
),
|
|
@@ -621,6 +622,7 @@ var ExpandCollapse = ({ title, children, portalId }) => {
|
|
|
621
622
|
{
|
|
622
623
|
onClick: () => setIsOpen(!isOpen),
|
|
623
624
|
className: "px-4 py-2 text-sm text-gray-700 hover:text-black",
|
|
625
|
+
"data-testid": "advsearch-icon-search",
|
|
624
626
|
children: title
|
|
625
627
|
}
|
|
626
628
|
),
|
|
@@ -974,7 +976,14 @@ function SelectScrollDownButton({
|
|
|
974
976
|
);
|
|
975
977
|
}
|
|
976
978
|
var FieldSelect = ({ row, fieldOptions, onChangeField }) => /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(Select, { value: row.fieldName, onValueChange: (value) => onChangeField(value), children: [
|
|
977
|
-
/* @__PURE__ */ jsx(
|
|
979
|
+
/* @__PURE__ */ jsx(
|
|
980
|
+
SelectTrigger,
|
|
981
|
+
{
|
|
982
|
+
className: "w-full justify-between rounded-md bg-white px-4 text-sm font-medium text-gray-700 shadow-none focus:ring-0",
|
|
983
|
+
"data-testid": "advsearch-dropdown-selectfield",
|
|
984
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select field" })
|
|
985
|
+
}
|
|
986
|
+
),
|
|
978
987
|
/* @__PURE__ */ jsx(SelectContent, { className: "w-full min-w-[unset]", children: fieldOptions.map((f) => /* @__PURE__ */ jsx(SelectItem, { value: f.value, children: f.label }, f.value)) })
|
|
979
988
|
] }) });
|
|
980
989
|
|
|
@@ -1016,6 +1025,7 @@ var OperatorSelect = ({ row, operators, onChangeOperator, error }) => {
|
|
|
1016
1025
|
{
|
|
1017
1026
|
"aria-invalid": error ? "true" : "false",
|
|
1018
1027
|
className: `w-full justify-between rounded-md bg-white px-4 text-sm font-medium text-gray-700 shadow-none focus:ring-0 ${error ? "border border-red-500" : ""}`,
|
|
1028
|
+
"data-testid": "advsearch-dropdown-cond",
|
|
1019
1029
|
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select operator" })
|
|
1020
1030
|
}
|
|
1021
1031
|
),
|
|
@@ -1386,7 +1396,8 @@ var ConditionTextInput = ({ row, control, onClear }) => /* @__PURE__ */ jsx(
|
|
|
1386
1396
|
value: field.value ?? "",
|
|
1387
1397
|
autoComplete: "off",
|
|
1388
1398
|
inputMode: "text",
|
|
1389
|
-
className: "w-full h-9 rounded-md bg-white pr-8 text-sm text-gray-700 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0"
|
|
1399
|
+
className: "w-full h-9 rounded-md bg-white pr-8 text-sm text-gray-700 shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",
|
|
1400
|
+
"data-testid": "advsearch-input-value"
|
|
1390
1401
|
}
|
|
1391
1402
|
) }),
|
|
1392
1403
|
/* @__PURE__ */ jsx("span", { className: "absolute inset-y-0 right-3 flex items-center", children: field.value && /* @__PURE__ */ jsx(ClearButton, { onClick: handleClear }) }),
|
|
@@ -1962,7 +1973,8 @@ var ConditionDateInput = ({
|
|
|
1962
1973
|
clearAriaLabel: buildClearLabel(options?.isEnd),
|
|
1963
1974
|
invalid: Boolean(fieldState.error),
|
|
1964
1975
|
displayFormatter: (d) => formatISODate(d, shortDateFormat),
|
|
1965
|
-
wrapperClassName: "min-w-0"
|
|
1976
|
+
wrapperClassName: "min-w-0",
|
|
1977
|
+
"data-testid": "advsearch-date-value"
|
|
1966
1978
|
}
|
|
1967
1979
|
) }),
|
|
1968
1980
|
/* @__PURE__ */ jsx(FormMessage, { className: "absolute left-0 top-full mt-1 text-xs text-red-600" })
|
|
@@ -2430,6 +2442,7 @@ var ConditionDropdownInput = ({ row, control, fieldSchema, onClear }) => /* @__P
|
|
|
2430
2442
|
"w-full justify-between rounded-md bg-white px-4 text-sm font-medium text-gray-700 shadow-none focus:ring-0",
|
|
2431
2443
|
hasValue ? "pr-8" : "pr-4"
|
|
2432
2444
|
),
|
|
2445
|
+
"data-testid": "advsearch-dropdown-value",
|
|
2433
2446
|
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select value" })
|
|
2434
2447
|
}
|
|
2435
2448
|
) }),
|
|
@@ -2805,7 +2818,8 @@ var ConditionLookupInput = ({
|
|
|
2805
2818
|
suggestionDebounce: fieldSchema?.suggestionDebounce,
|
|
2806
2819
|
noOptionsMessage: fieldSchema?.noOptionsMessage,
|
|
2807
2820
|
loadingMessage: fieldSchema?.loadingMessage,
|
|
2808
|
-
dropdownPortalId
|
|
2821
|
+
dropdownPortalId,
|
|
2822
|
+
"data-testid": "advsearch-lookup-list"
|
|
2809
2823
|
}
|
|
2810
2824
|
) }),
|
|
2811
2825
|
/* @__PURE__ */ jsx(FormMessage, { className: "absolute left-0 top-full mt-1 text-xs text-red-600" })
|
|
@@ -2940,6 +2954,7 @@ var AddRemoveButtons = ({ isFirst, onAdd, onRemove, disableAdd }) => /* @__PURE_
|
|
|
2940
2954
|
className: `circle-btn border transition-colors ${disableAdd ? "cursor-not-allowed border-[#5a5a5a] bg-[#5a5a5a] text-[#e1e1e1]" : "border-[#379a2a] bg-[#379a2a] text-white"}`,
|
|
2941
2955
|
"aria-label": "Add row",
|
|
2942
2956
|
title: disableAdd ? "Cannot add more rows" : "Add condition",
|
|
2957
|
+
"data-testid": "advsearch-btn-add",
|
|
2943
2958
|
children: /* @__PURE__ */ jsx(Plus, { className: "h-3 w-3 stroke-[2]" })
|
|
2944
2959
|
}
|
|
2945
2960
|
) : /* @__PURE__ */ jsx(
|
|
@@ -2951,6 +2966,7 @@ var AddRemoveButtons = ({ isFirst, onAdd, onRemove, disableAdd }) => /* @__PURE_
|
|
|
2951
2966
|
className: "circle-btn border border-[#379a2a] bg-white text-[#379a2a]",
|
|
2952
2967
|
"aria-label": "Remove row",
|
|
2953
2968
|
title: "Remove condition",
|
|
2969
|
+
"data-testid": "advsearch-btn-remove",
|
|
2954
2970
|
children: /* @__PURE__ */ jsx(Minus, { className: "h-3 w-3 stroke-[2]" })
|
|
2955
2971
|
}
|
|
2956
2972
|
) });
|
|
@@ -3585,6 +3601,7 @@ var AdvanceSearch = ({
|
|
|
3585
3601
|
Object.keys(getValues()).forEach((k) => resetField(k));
|
|
3586
3602
|
if (onClear) onClear();
|
|
3587
3603
|
},
|
|
3604
|
+
"data-testid": "advsearch-btn-clear",
|
|
3588
3605
|
children: "Clear Search"
|
|
3589
3606
|
}
|
|
3590
3607
|
),
|
|
@@ -3593,6 +3610,7 @@ var AdvanceSearch = ({
|
|
|
3593
3610
|
{
|
|
3594
3611
|
type: "submit",
|
|
3595
3612
|
className: "w-full bg-[#379a2a] text-white hover:bg-[#2f7c21] md:w-auto md:min-w-[120px]",
|
|
3613
|
+
"data-testid": "advsearch-btn-search",
|
|
3596
3614
|
children: "Search"
|
|
3597
3615
|
}
|
|
3598
3616
|
)
|
|
@@ -3851,6 +3869,7 @@ var HeaderCell = ({
|
|
|
3851
3869
|
rootClassName
|
|
3852
3870
|
),
|
|
3853
3871
|
onClick: (event) => {
|
|
3872
|
+
if (!showSorter) return;
|
|
3854
3873
|
event.preventDefault();
|
|
3855
3874
|
if (context?.column?.getCanSort()) {
|
|
3856
3875
|
context?.column?.toggleSorting();
|
|
@@ -3878,8 +3897,8 @@ var HeaderCell = ({
|
|
|
3878
3897
|
ChevronUp,
|
|
3879
3898
|
{
|
|
3880
3899
|
className: cn("stroke-[#BBBBBB]", {
|
|
3881
|
-
"stroke-
|
|
3882
|
-
"stroke-
|
|
3900
|
+
"stroke-sus-gray-5": context?.column?.getIsSorted() === "asc",
|
|
3901
|
+
"stroke-sus-gray-5/45": context?.column?.getNextSortingOrder() === "asc" && hovering
|
|
3883
3902
|
}),
|
|
3884
3903
|
size: 16,
|
|
3885
3904
|
strokeWidth: 3
|
|
@@ -3889,8 +3908,8 @@ var HeaderCell = ({
|
|
|
3889
3908
|
ChevronDown,
|
|
3890
3909
|
{
|
|
3891
3910
|
className: cn("stroke-[#BBBBBB]", {
|
|
3892
|
-
"stroke-
|
|
3893
|
-
"stroke-
|
|
3911
|
+
"stroke-sus-gray-5": context?.column?.getIsSorted() === "desc",
|
|
3912
|
+
"stroke-sus-gray-5/45": context?.column?.getNextSortingOrder() === "desc" && hovering
|
|
3894
3913
|
}),
|
|
3895
3914
|
size: 16,
|
|
3896
3915
|
strokeWidth: 3
|
|
@@ -5051,17 +5070,17 @@ var defaultResource = {
|
|
|
5051
5070
|
};
|
|
5052
5071
|
|
|
5053
5072
|
// src/components/dialog-alert/locale/i18n.ts
|
|
5054
|
-
i18n.
|
|
5073
|
+
var instance = i18n.createInstance({
|
|
5055
5074
|
resources: defaultResource,
|
|
5056
5075
|
lng: "sharedui",
|
|
5057
5076
|
fallbackLng: "sharedui",
|
|
5058
5077
|
defaultNS: "translation",
|
|
5059
5078
|
interpolation: {
|
|
5060
5079
|
escapeValue: false
|
|
5061
|
-
// react already safes from xss
|
|
5062
5080
|
}
|
|
5063
|
-
});
|
|
5064
|
-
|
|
5081
|
+
}).use(initReactI18next);
|
|
5082
|
+
instance.init();
|
|
5083
|
+
var i18n_default = instance;
|
|
5065
5084
|
var titleColorVariant = {
|
|
5066
5085
|
default: "",
|
|
5067
5086
|
success: "text-green-600",
|
|
@@ -5077,7 +5096,7 @@ function DialogAlert({
|
|
|
5077
5096
|
description,
|
|
5078
5097
|
variant = "default",
|
|
5079
5098
|
confirmText,
|
|
5080
|
-
cancelText = "cancel",
|
|
5099
|
+
cancelText = i18nPrefix + "cancel",
|
|
5081
5100
|
onConfirm,
|
|
5082
5101
|
onCancel,
|
|
5083
5102
|
showCancel = true,
|
|
@@ -5086,7 +5105,6 @@ function DialogAlert({
|
|
|
5086
5105
|
persistent = false
|
|
5087
5106
|
}) {
|
|
5088
5107
|
const alignClass = align === "start" ? "justify-start" : align === "end" ? "justify-end" : "justify-center";
|
|
5089
|
-
const { t } = useTranslation();
|
|
5090
5108
|
const handleCancel = useCallback(() => {
|
|
5091
5109
|
onCancel?.();
|
|
5092
5110
|
onOpenChange(false);
|
|
@@ -5098,13 +5116,13 @@ function DialogAlert({
|
|
|
5098
5116
|
return /* @__PURE__ */ jsx(Dialog2, { open, onOpenChange: persistent ? () => {
|
|
5099
5117
|
} : onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent2, { className: "max-w-md", showCloseButton: !persistent, children: [
|
|
5100
5118
|
/* @__PURE__ */ jsxs(DialogHeader2, { children: [
|
|
5101
|
-
title && /* @__PURE__ */ jsx(DialogTitle2, { className: titleColorVariant[variant], children: t(title) }),
|
|
5102
|
-
description && /* @__PURE__ */ jsx(DialogDescription2, { children: t(description) })
|
|
5119
|
+
title && /* @__PURE__ */ jsx(DialogTitle2, { className: titleColorVariant[variant], children: i18n_default.t(title) }),
|
|
5120
|
+
description && /* @__PURE__ */ jsx(DialogDescription2, { children: i18n_default.t(description) })
|
|
5103
5121
|
] }),
|
|
5104
5122
|
outlet && outlet,
|
|
5105
5123
|
/* @__PURE__ */ jsxs("div", { className: `flex gap-3 mt-3 ${alignClass}`, children: [
|
|
5106
|
-
showCancel && /* @__PURE__ */ jsx(Button2, { variant: "cancel", onClick: handleCancel, children: t(cancelText) }),
|
|
5107
|
-
confirmText && /* @__PURE__ */ jsx(Button2, { variant, onClick: handleConfirm, children: t(confirmText) })
|
|
5124
|
+
showCancel && /* @__PURE__ */ jsx(Button2, { variant: "cancel", onClick: handleCancel, children: i18n_default.t(cancelText) }),
|
|
5125
|
+
confirmText && /* @__PURE__ */ jsx(Button2, { variant, onClick: handleConfirm, children: i18n_default.t(confirmText) })
|
|
5108
5126
|
] })
|
|
5109
5127
|
] }) });
|
|
5110
5128
|
}
|