@sustaina/shared-ui 1.5.0 → 1.6.0
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 +23 -16
- package/dist/index.d.ts +23 -16
- package/dist/index.js +75 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -51
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -123,6 +123,26 @@ function FormLabel({ children, className, errorClassName, required, ...props })
|
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
// src/utils/common.ts
|
|
127
|
+
function isDefined(value) {
|
|
128
|
+
return value !== null && value !== void 0;
|
|
129
|
+
}
|
|
130
|
+
function isEmptyObject(value) {
|
|
131
|
+
return !!value && Object.keys(value).length === 0 && value.constructor === Object;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// src/utils/filters.ts
|
|
135
|
+
function stripNullishObject(value) {
|
|
136
|
+
if (!isDefined(value)) {
|
|
137
|
+
return {};
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
return Object.fromEntries(Object.entries(value).filter(([, propValue]) => isDefined(propValue)));
|
|
141
|
+
} catch {
|
|
142
|
+
return {};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
126
146
|
// src/utils/getColumnIdFromTable.ts
|
|
127
147
|
function getColumnIdFromTable(table) {
|
|
128
148
|
const allColumns = table.getAllColumns();
|
|
@@ -336,23 +356,6 @@ var useScreenSize = (breakpoints) => {
|
|
|
336
356
|
return { isMobile, isTablet, isDesktop };
|
|
337
357
|
};
|
|
338
358
|
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
359
|
var HeaderCell = ({ rootClassName, labelClassName, context, label, sorterProps }) => {
|
|
357
360
|
const { ref, hovering } = useHover_default();
|
|
358
361
|
const showSorter = sorterProps?.show ?? context.column.getCanSort();
|
|
@@ -4916,7 +4919,7 @@ function DialogContent2({
|
|
|
4916
4919
|
{
|
|
4917
4920
|
"data-slot": "dialog-content",
|
|
4918
4921
|
className: cn3(
|
|
4919
|
-
"bg-
|
|
4922
|
+
"bg-white 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",
|
|
4920
4923
|
className
|
|
4921
4924
|
),
|
|
4922
4925
|
...props,
|
|
@@ -4976,13 +4979,15 @@ var buttonVariants4 = cva(
|
|
|
4976
4979
|
{
|
|
4977
4980
|
variants: {
|
|
4978
4981
|
variant: {
|
|
4979
|
-
default: "bg-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
+
default: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
|
|
4983
|
+
success: "bg-sus-primary-1 text-primary-foreground shadow-xs hover:bg-sus-primary/90",
|
|
4984
|
+
error: "border border-[#BB0B0E] bg-background shadow-xs hover:bg-accent hover:text-accent-foreground text-[#BB0B0E]",
|
|
4985
|
+
warning: "bg-yellow-500 text-black shadow-xs hover:bg-yellow-600 dark:hover:bg-yellow-400",
|
|
4986
|
+
cancel: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50"
|
|
4982
4987
|
},
|
|
4983
4988
|
size: {
|
|
4984
|
-
default: "h-9 px-4
|
|
4985
|
-
option: "py-5 h-9 px-4
|
|
4989
|
+
default: "h-9 px-4 has-[>svg]:px-3",
|
|
4990
|
+
option: "py-5 h-9 px-4 has-[>svg]:px-3",
|
|
4986
4991
|
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
4987
4992
|
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
4988
4993
|
icon: "size-9",
|
|
@@ -4992,7 +4997,7 @@ var buttonVariants4 = cva(
|
|
|
4992
4997
|
"icon-lg": "size-10"
|
|
4993
4998
|
},
|
|
4994
4999
|
active: {
|
|
4995
|
-
true: "
|
|
5000
|
+
true: "opacity-90 ring-2 ring-offset-1 ring-ring",
|
|
4996
5001
|
false: ""
|
|
4997
5002
|
}
|
|
4998
5003
|
},
|
|
@@ -5015,42 +5020,58 @@ function Button4({
|
|
|
5015
5020
|
Comp,
|
|
5016
5021
|
{
|
|
5017
5022
|
"data-slot": "button",
|
|
5018
|
-
className: cn3(buttonVariants4({ variant, size,
|
|
5023
|
+
className: cn3(buttonVariants4({ variant, size, active, className })),
|
|
5019
5024
|
...props
|
|
5020
5025
|
}
|
|
5021
5026
|
);
|
|
5022
5027
|
}
|
|
5023
|
-
function
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5028
|
+
function DialogAlert({
|
|
5029
|
+
open,
|
|
5030
|
+
onOpenChange,
|
|
5031
|
+
title,
|
|
5032
|
+
description,
|
|
5033
|
+
variant = "default",
|
|
5034
|
+
confirmText,
|
|
5035
|
+
cancelText = "Cancel",
|
|
5036
|
+
onConfirm,
|
|
5037
|
+
onCancel,
|
|
5038
|
+
showCancel = true,
|
|
5039
|
+
align = "center",
|
|
5040
|
+
outlet
|
|
5041
|
+
}) {
|
|
5042
|
+
const alignClass = align === "start" ? "justify-start" : align === "end" ? "justify-end" : "justify-center";
|
|
5043
|
+
const handleCancel = useCallback(() => {
|
|
5044
|
+
onCancel?.();
|
|
5045
|
+
onOpenChange(false);
|
|
5046
|
+
}, [onCancel, onOpenChange]);
|
|
5047
|
+
const handleConfirm = useCallback(() => {
|
|
5048
|
+
onConfirm?.();
|
|
5049
|
+
}, [onConfirm]);
|
|
5050
|
+
return /* @__PURE__ */ jsx(Dialog2, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent2, { className: "max-w-md", children: [
|
|
5035
5051
|
/* @__PURE__ */ jsxs(DialogHeader2, { children: [
|
|
5036
|
-
/* @__PURE__ */ jsx(DialogTitle2, { className:
|
|
5037
|
-
/* @__PURE__ */ jsx(DialogDescription2, { children:
|
|
5052
|
+
title && /* @__PURE__ */ jsx(DialogTitle2, { className: variantClass(variant), children: title }),
|
|
5053
|
+
description && /* @__PURE__ */ jsx(DialogDescription2, { children: description })
|
|
5038
5054
|
] }),
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
{
|
|
5044
|
-
variant: dialogData.variantBtn || "default",
|
|
5045
|
-
disabled: dialogData.btnState === false,
|
|
5046
|
-
onClick: dialogData.onClickBtn,
|
|
5047
|
-
children: dialogData.btn
|
|
5048
|
-
}
|
|
5049
|
-
)
|
|
5055
|
+
outlet && outlet,
|
|
5056
|
+
/* @__PURE__ */ jsxs("div", { className: `flex gap-3 mt-3 ${alignClass}`, children: [
|
|
5057
|
+
showCancel && /* @__PURE__ */ jsx(Button4, { variant: "cancel", onClick: handleCancel, children: cancelText }),
|
|
5058
|
+
confirmText && /* @__PURE__ */ jsx(Button4, { variant, onClick: handleConfirm, children: confirmText })
|
|
5050
5059
|
] })
|
|
5051
5060
|
] }) });
|
|
5052
5061
|
}
|
|
5062
|
+
function variantClass(variant) {
|
|
5063
|
+
switch (variant) {
|
|
5064
|
+
case "success":
|
|
5065
|
+
return "text-green-600";
|
|
5066
|
+
case "error":
|
|
5067
|
+
return "text-red-600";
|
|
5068
|
+
case "warning":
|
|
5069
|
+
return "text-yellow-600";
|
|
5070
|
+
default:
|
|
5071
|
+
return "";
|
|
5072
|
+
}
|
|
5073
|
+
}
|
|
5053
5074
|
|
|
5054
|
-
export { AdvanceSearch_default as AdvanceSearch, Button, DataTable_default as DataTable,
|
|
5075
|
+
export { AdvanceSearch_default as AdvanceSearch, Button, DataTable_default as DataTable, DialogAlert, FormErrorMessage, FormField, FormFieldContext, FormItem, FormItemContext, FormLabel, GridSettingsModal_default as GridSettingsModal, HeaderCell_default as HeaderCell, navbar_default as Navbar, NumberInput, PreventPageLeave_default as PreventPageLeave, TextInput, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, isDefined, isEmptyObject, renderContentSlot, selectValueToBoolean, stripNullishObject, useFormField, useGridSettingsStore, useHover_default as useHover, useIntersectionObserver_default as useIntersectionObserver, useMediaQuery_default as useMediaQuery, usePreventPageLeave_default as usePreventPageLeave, usePreventPageLeaveStore_default as usePreventPageLeaveStore, useScreenSize_default as useScreenSize };
|
|
5055
5076
|
//# sourceMappingURL=index.mjs.map
|
|
5056
5077
|
//# sourceMappingURL=index.mjs.map
|