@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.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-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",
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-sus-primary-1 text-primary-foreground shadow-xs hover:bg-sus-primary/90",
4980
- cancel: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
4981
- outlineLeave: "border border-[#BB0B0E] bg-background shadow-xs hover:bg-accent hover:text-accent-foreground text-[#BB0B0E]"
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 has-[>svg]:px-3",
4985
- option: "py-5 h-9 px-4 has-[>svg]:px-3",
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: "bg-sus-primary-1 text-white",
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, className, active })),
5023
+ className: cn3(buttonVariants4({ variant, size, active, className })),
5019
5024
  ...props
5020
5025
  }
5021
5026
  );
5022
5027
  }
5023
- function ConfirmDialog({ dialogData, setDialog, onClose }) {
5024
- const handleClose = () => {
5025
- setDialog({ state: false });
5026
- onClose?.();
5027
- };
5028
- const titleColor = {
5029
- default: "text-[#000000]",
5030
- success: "text-[#3f9e33]",
5031
- error: "text-[#c63638]"
5032
- };
5033
- const showCloseBtn = dialogData.showCloseBtn ?? true;
5034
- return /* @__PURE__ */ jsx(Dialog2, { open: dialogData.state, onOpenChange: handleClose, children: /* @__PURE__ */ jsxs(DialogContent2, { children: [
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: cn3(titleColor[dialogData.variant || "default"], "font-bold"), children: dialogData.title || "" }),
5037
- /* @__PURE__ */ jsx(DialogDescription2, { children: dialogData.description || "" })
5052
+ title && /* @__PURE__ */ jsx(DialogTitle2, { className: variantClass(variant), children: title }),
5053
+ description && /* @__PURE__ */ jsx(DialogDescription2, { children: description })
5038
5054
  ] }),
5039
- /* @__PURE__ */ jsxs("div", { className: "w-full flex justify-center py-5 gap-5", children: [
5040
- showCloseBtn && /* @__PURE__ */ jsx(Button4, { variant: "cancel", onClick: handleClose, children: "Close" }),
5041
- dialogData.btn && /* @__PURE__ */ jsx(
5042
- Button4,
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, ConfirmDialog as Dialog, 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, renderContentSlot, selectValueToBoolean, 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 };
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