@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 CHANGED
@@ -369,22 +369,29 @@ interface AdvanceSearchProps {
369
369
 
370
370
  declare const AdvanceSearch: React__default.FC<AdvanceSearchProps>;
371
371
 
372
- type ConfirmDialogProps = {
373
- dialogData: {
374
- state: boolean;
375
- title?: string;
376
- description?: string;
377
- btn?: string;
378
- variantBtn?: string;
379
- btnState?: boolean;
380
- onClickBtn?: () => void;
381
- variant?: "default" | "success" | "error";
382
- showCloseBtn?: boolean;
383
- };
384
- setDialog: (data: any) => void;
385
- onClose?: () => void;
372
+ type DialogVariant = "default" | "success" | "error" | "warning";
373
+ interface DialogAlertProps {
374
+ open: boolean;
375
+ onOpenChange: (state: boolean) => void;
376
+ title?: string;
377
+ description?: string;
378
+ variant?: DialogVariant;
379
+ confirmText?: string;
380
+ cancelText?: string;
381
+ onConfirm?: () => void;
382
+ onCancel?: () => void;
383
+ showCancel?: boolean;
384
+ align?: "start" | "center" | "end";
385
+ outlet?: React__default.ReactNode | null;
386
+ }
387
+ declare function DialogAlert({ open, onOpenChange, title, description, variant, confirmText, cancelText, onConfirm, onCancel, showCancel, align, outlet }: DialogAlertProps): react_jsx_runtime.JSX.Element;
388
+
389
+ declare function isDefined(value: any): boolean;
390
+ declare function isEmptyObject(value: any): boolean;
391
+
392
+ declare function stripNullishObject<T extends Record<string, any>>(value: Partial<T>): {
393
+ [k: string]: any;
386
394
  };
387
- declare function ConfirmDialog({ dialogData, setDialog, onClose }: ConfirmDialogProps): react_jsx_runtime.JSX.Element;
388
395
 
389
396
  /**
390
397
  * Utility function to intelligently combine class names using `clsx`
@@ -489,4 +496,4 @@ type Breakpoints = {
489
496
  };
490
497
  declare const useScreenSize: (breakpoints?: Breakpoints) => UseScreenSizeResult;
491
498
 
492
- export { AdvanceSearch, type Breakpoints, Button, type Column, type ContentSlot, DataTable, type DataTableChildrenKeyHandler, type DataTableColumnFilter, type DataTableColumnFilterProps, type DataTableColumnGrouping, type DataTableColumnOrdering, type DataTableColumnPinning, type DataTableColumnSorting, type DataTableColumnVisibility, type DataTableComponentProps, type DataTableFilterConfig, type DataTableFilters, type DataTableGlobalFilter, type DataTableHeaderCell, type DataTableProps, type DataTableRenderHeaderHandler, type DataTableRenderHeaderProps, type DataTableRenderRowHandler, type DataTableRenderRowProps, type DataTableRowCell, type DataTableRowClickHandler, type DataTableRowClickMode, type DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, ConfirmDialog as Dialog, type FieldSchema, FormErrorMessage, type FormErrorMessageProps, FormField, FormFieldContext, type FormFieldContextValue, type FormFieldProps, FormItem, FormItemContext, type FormItemContextValue, type FormItemProps, FormLabel, type FormLabelProps, type GridPayload, GridSettingsModal, type GridSettingsModalProps, HeaderCell, type HeaderCellProps, _default as Navbar, type NavbarProps, NumberInput, type NumberInputProps, PreventPageLeave, type RowClickType, type SorterProps, TextInput, type TextInputProps, type UseFormFieldOptions, type UseFormFieldReturn, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, renderContentSlot, selectValueToBoolean, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize };
499
+ export { AdvanceSearch, type Breakpoints, Button, type Column, type ContentSlot, DataTable, type DataTableChildrenKeyHandler, type DataTableColumnFilter, type DataTableColumnFilterProps, type DataTableColumnGrouping, type DataTableColumnOrdering, type DataTableColumnPinning, type DataTableColumnSorting, type DataTableColumnVisibility, type DataTableComponentProps, type DataTableFilterConfig, type DataTableFilters, type DataTableGlobalFilter, type DataTableHeaderCell, type DataTableProps, type DataTableRenderHeaderHandler, type DataTableRenderHeaderProps, type DataTableRenderRowHandler, type DataTableRenderRowProps, type DataTableRowCell, type DataTableRowClickHandler, type DataTableRowClickMode, type DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, DialogAlert, type DialogAlertProps, type DialogVariant, type FieldSchema, FormErrorMessage, type FormErrorMessageProps, FormField, FormFieldContext, type FormFieldContextValue, type FormFieldProps, FormItem, FormItemContext, type FormItemContextValue, type FormItemProps, FormLabel, type FormLabelProps, type GridPayload, GridSettingsModal, type GridSettingsModalProps, HeaderCell, type HeaderCellProps, _default as Navbar, type NavbarProps, NumberInput, type NumberInputProps, PreventPageLeave, type RowClickType, type SorterProps, TextInput, type TextInputProps, type UseFormFieldOptions, type UseFormFieldReturn, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, isDefined, isEmptyObject, renderContentSlot, selectValueToBoolean, stripNullishObject, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize };
package/dist/index.d.ts CHANGED
@@ -369,22 +369,29 @@ interface AdvanceSearchProps {
369
369
 
370
370
  declare const AdvanceSearch: React__default.FC<AdvanceSearchProps>;
371
371
 
372
- type ConfirmDialogProps = {
373
- dialogData: {
374
- state: boolean;
375
- title?: string;
376
- description?: string;
377
- btn?: string;
378
- variantBtn?: string;
379
- btnState?: boolean;
380
- onClickBtn?: () => void;
381
- variant?: "default" | "success" | "error";
382
- showCloseBtn?: boolean;
383
- };
384
- setDialog: (data: any) => void;
385
- onClose?: () => void;
372
+ type DialogVariant = "default" | "success" | "error" | "warning";
373
+ interface DialogAlertProps {
374
+ open: boolean;
375
+ onOpenChange: (state: boolean) => void;
376
+ title?: string;
377
+ description?: string;
378
+ variant?: DialogVariant;
379
+ confirmText?: string;
380
+ cancelText?: string;
381
+ onConfirm?: () => void;
382
+ onCancel?: () => void;
383
+ showCancel?: boolean;
384
+ align?: "start" | "center" | "end";
385
+ outlet?: React__default.ReactNode | null;
386
+ }
387
+ declare function DialogAlert({ open, onOpenChange, title, description, variant, confirmText, cancelText, onConfirm, onCancel, showCancel, align, outlet }: DialogAlertProps): react_jsx_runtime.JSX.Element;
388
+
389
+ declare function isDefined(value: any): boolean;
390
+ declare function isEmptyObject(value: any): boolean;
391
+
392
+ declare function stripNullishObject<T extends Record<string, any>>(value: Partial<T>): {
393
+ [k: string]: any;
386
394
  };
387
- declare function ConfirmDialog({ dialogData, setDialog, onClose }: ConfirmDialogProps): react_jsx_runtime.JSX.Element;
388
395
 
389
396
  /**
390
397
  * Utility function to intelligently combine class names using `clsx`
@@ -489,4 +496,4 @@ type Breakpoints = {
489
496
  };
490
497
  declare const useScreenSize: (breakpoints?: Breakpoints) => UseScreenSizeResult;
491
498
 
492
- export { AdvanceSearch, type Breakpoints, Button, type Column, type ContentSlot, DataTable, type DataTableChildrenKeyHandler, type DataTableColumnFilter, type DataTableColumnFilterProps, type DataTableColumnGrouping, type DataTableColumnOrdering, type DataTableColumnPinning, type DataTableColumnSorting, type DataTableColumnVisibility, type DataTableComponentProps, type DataTableFilterConfig, type DataTableFilters, type DataTableGlobalFilter, type DataTableHeaderCell, type DataTableProps, type DataTableRenderHeaderHandler, type DataTableRenderHeaderProps, type DataTableRenderRowHandler, type DataTableRenderRowProps, type DataTableRowCell, type DataTableRowClickHandler, type DataTableRowClickMode, type DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, ConfirmDialog as Dialog, type FieldSchema, FormErrorMessage, type FormErrorMessageProps, FormField, FormFieldContext, type FormFieldContextValue, type FormFieldProps, FormItem, FormItemContext, type FormItemContextValue, type FormItemProps, FormLabel, type FormLabelProps, type GridPayload, GridSettingsModal, type GridSettingsModalProps, HeaderCell, type HeaderCellProps, _default as Navbar, type NavbarProps, NumberInput, type NumberInputProps, PreventPageLeave, type RowClickType, type SorterProps, TextInput, type TextInputProps, type UseFormFieldOptions, type UseFormFieldReturn, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, renderContentSlot, selectValueToBoolean, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize };
499
+ export { AdvanceSearch, type Breakpoints, Button, type Column, type ContentSlot, DataTable, type DataTableChildrenKeyHandler, type DataTableColumnFilter, type DataTableColumnFilterProps, type DataTableColumnGrouping, type DataTableColumnOrdering, type DataTableColumnPinning, type DataTableColumnSorting, type DataTableColumnVisibility, type DataTableComponentProps, type DataTableFilterConfig, type DataTableFilters, type DataTableGlobalFilter, type DataTableHeaderCell, type DataTableProps, type DataTableRenderHeaderHandler, type DataTableRenderHeaderProps, type DataTableRenderRowHandler, type DataTableRenderRowProps, type DataTableRowCell, type DataTableRowClickHandler, type DataTableRowClickMode, type DataTableRowExpansion, type DataTableRowIdKeyHandler, type DataTableRowSelection, type DataTableScrollFetch, type DataTableStatusContent, type DatatableColumnResizing, DialogAlert, type DialogAlertProps, type DialogVariant, type FieldSchema, FormErrorMessage, type FormErrorMessageProps, FormField, FormFieldContext, type FormFieldContextValue, type FormFieldProps, FormItem, FormItemContext, type FormItemContextValue, type FormItemProps, FormLabel, type FormLabelProps, type GridPayload, GridSettingsModal, type GridSettingsModalProps, HeaderCell, type HeaderCellProps, _default as Navbar, type NavbarProps, NumberInput, type NumberInputProps, PreventPageLeave, type RowClickType, type SorterProps, TextInput, type TextInputProps, type UseFormFieldOptions, type UseFormFieldReturn, type UseHoverResult, type UseMediaQueryOptions, type UseMediaQueryResult, type UsePreventPageLeaveOptions, type UseScreenSizeResult, booleanToSelectValue, buttonVariants, cn, compareAlphanumeric, getColumnIdFromTable, isDefined, isEmptyObject, renderContentSlot, selectValueToBoolean, stripNullishObject, useFormField, useGridSettingsStore, useHover, useIntersectionObserver, useMediaQuery, usePreventPageLeave, usePreventPageLeaveStore, useScreenSize };
package/dist/index.js CHANGED
@@ -152,6 +152,26 @@ function FormLabel({ children, className, errorClassName, required, ...props })
152
152
  );
153
153
  }
154
154
 
155
+ // src/utils/common.ts
156
+ function isDefined(value) {
157
+ return value !== null && value !== void 0;
158
+ }
159
+ function isEmptyObject(value) {
160
+ return !!value && Object.keys(value).length === 0 && value.constructor === Object;
161
+ }
162
+
163
+ // src/utils/filters.ts
164
+ function stripNullishObject(value) {
165
+ if (!isDefined(value)) {
166
+ return {};
167
+ }
168
+ try {
169
+ return Object.fromEntries(Object.entries(value).filter(([, propValue]) => isDefined(propValue)));
170
+ } catch {
171
+ return {};
172
+ }
173
+ }
174
+
155
175
  // src/utils/getColumnIdFromTable.ts
156
176
  function getColumnIdFromTable(table) {
157
177
  const allColumns = table.getAllColumns();
@@ -365,23 +385,6 @@ var useScreenSize = (breakpoints) => {
365
385
  return { isMobile, isTablet, isDesktop };
366
386
  };
367
387
  var useScreenSize_default = useScreenSize;
368
-
369
- // src/utils/common.ts
370
- function isDefined(value) {
371
- return value !== null && value !== void 0;
372
- }
373
-
374
- // src/utils/filters.ts
375
- function stripNullishObject(value) {
376
- if (!isDefined(value)) {
377
- return {};
378
- }
379
- try {
380
- return Object.fromEntries(Object.entries(value).filter(([, propValue]) => isDefined(propValue)));
381
- } catch {
382
- return {};
383
- }
384
- }
385
388
  var HeaderCell = ({ rootClassName, labelClassName, context, label, sorterProps }) => {
386
389
  const { ref, hovering } = useHover_default();
387
390
  const showSorter = sorterProps?.show ?? context.column.getCanSort();
@@ -4945,7 +4948,7 @@ function DialogContent2({
4945
4948
  {
4946
4949
  "data-slot": "dialog-content",
4947
4950
  className: cn3(
4948
- "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",
4951
+ "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",
4949
4952
  className
4950
4953
  ),
4951
4954
  ...props,
@@ -5005,13 +5008,15 @@ var buttonVariants4 = classVarianceAuthority.cva(
5005
5008
  {
5006
5009
  variants: {
5007
5010
  variant: {
5008
- default: "bg-sus-primary-1 text-primary-foreground shadow-xs hover:bg-sus-primary/90",
5009
- cancel: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
5010
- outlineLeave: "border border-[#BB0B0E] bg-background shadow-xs hover:bg-accent hover:text-accent-foreground text-[#BB0B0E]"
5011
+ default: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50",
5012
+ success: "bg-sus-primary-1 text-primary-foreground shadow-xs hover:bg-sus-primary/90",
5013
+ error: "border border-[#BB0B0E] bg-background shadow-xs hover:bg-accent hover:text-accent-foreground text-[#BB0B0E]",
5014
+ warning: "bg-yellow-500 text-black shadow-xs hover:bg-yellow-600 dark:hover:bg-yellow-400",
5015
+ cancel: "border bg-[#8B8B8B] text-white shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:hover:bg-input/50"
5011
5016
  },
5012
5017
  size: {
5013
- default: "h-9 px-4 has-[>svg]:px-3",
5014
- option: "py-5 h-9 px-4 has-[>svg]:px-3",
5018
+ default: "h-9 px-4 has-[>svg]:px-3",
5019
+ option: "py-5 h-9 px-4 has-[>svg]:px-3",
5015
5020
  sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
5016
5021
  lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
5017
5022
  icon: "size-9",
@@ -5021,7 +5026,7 @@ var buttonVariants4 = classVarianceAuthority.cva(
5021
5026
  "icon-lg": "size-10"
5022
5027
  },
5023
5028
  active: {
5024
- true: "bg-sus-primary-1 text-white",
5029
+ true: "opacity-90 ring-2 ring-offset-1 ring-ring",
5025
5030
  false: ""
5026
5031
  }
5027
5032
  },
@@ -5044,46 +5049,62 @@ function Button4({
5044
5049
  Comp,
5045
5050
  {
5046
5051
  "data-slot": "button",
5047
- className: cn3(buttonVariants4({ variant, size, className, active })),
5052
+ className: cn3(buttonVariants4({ variant, size, active, className })),
5048
5053
  ...props
5049
5054
  }
5050
5055
  );
5051
5056
  }
5052
- function ConfirmDialog({ dialogData, setDialog, onClose }) {
5053
- const handleClose = () => {
5054
- setDialog({ state: false });
5055
- onClose?.();
5056
- };
5057
- const titleColor = {
5058
- default: "text-[#000000]",
5059
- success: "text-[#3f9e33]",
5060
- error: "text-[#c63638]"
5061
- };
5062
- const showCloseBtn = dialogData.showCloseBtn ?? true;
5063
- return /* @__PURE__ */ jsxRuntime.jsx(Dialog2, { open: dialogData.state, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent2, { children: [
5057
+ function DialogAlert({
5058
+ open,
5059
+ onOpenChange,
5060
+ title,
5061
+ description,
5062
+ variant = "default",
5063
+ confirmText,
5064
+ cancelText = "Cancel",
5065
+ onConfirm,
5066
+ onCancel,
5067
+ showCancel = true,
5068
+ align = "center",
5069
+ outlet
5070
+ }) {
5071
+ const alignClass = align === "start" ? "justify-start" : align === "end" ? "justify-end" : "justify-center";
5072
+ const handleCancel = React4.useCallback(() => {
5073
+ onCancel?.();
5074
+ onOpenChange(false);
5075
+ }, [onCancel, onOpenChange]);
5076
+ const handleConfirm = React4.useCallback(() => {
5077
+ onConfirm?.();
5078
+ }, [onConfirm]);
5079
+ return /* @__PURE__ */ jsxRuntime.jsx(Dialog2, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent2, { className: "max-w-md", children: [
5064
5080
  /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader2, { children: [
5065
- /* @__PURE__ */ jsxRuntime.jsx(DialogTitle2, { className: cn3(titleColor[dialogData.variant || "default"], "font-bold"), children: dialogData.title || "" }),
5066
- /* @__PURE__ */ jsxRuntime.jsx(DialogDescription2, { children: dialogData.description || "" })
5081
+ title && /* @__PURE__ */ jsxRuntime.jsx(DialogTitle2, { className: variantClass(variant), children: title }),
5082
+ description && /* @__PURE__ */ jsxRuntime.jsx(DialogDescription2, { children: description })
5067
5083
  ] }),
5068
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full flex justify-center py-5 gap-5", children: [
5069
- showCloseBtn && /* @__PURE__ */ jsxRuntime.jsx(Button4, { variant: "cancel", onClick: handleClose, children: "Close" }),
5070
- dialogData.btn && /* @__PURE__ */ jsxRuntime.jsx(
5071
- Button4,
5072
- {
5073
- variant: dialogData.variantBtn || "default",
5074
- disabled: dialogData.btnState === false,
5075
- onClick: dialogData.onClickBtn,
5076
- children: dialogData.btn
5077
- }
5078
- )
5084
+ outlet && outlet,
5085
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex gap-3 mt-3 ${alignClass}`, children: [
5086
+ showCancel && /* @__PURE__ */ jsxRuntime.jsx(Button4, { variant: "cancel", onClick: handleCancel, children: cancelText }),
5087
+ confirmText && /* @__PURE__ */ jsxRuntime.jsx(Button4, { variant, onClick: handleConfirm, children: confirmText })
5079
5088
  ] })
5080
5089
  ] }) });
5081
5090
  }
5091
+ function variantClass(variant) {
5092
+ switch (variant) {
5093
+ case "success":
5094
+ return "text-green-600";
5095
+ case "error":
5096
+ return "text-red-600";
5097
+ case "warning":
5098
+ return "text-yellow-600";
5099
+ default:
5100
+ return "";
5101
+ }
5102
+ }
5082
5103
 
5083
5104
  exports.AdvanceSearch = AdvanceSearch_default;
5084
5105
  exports.Button = Button;
5085
5106
  exports.DataTable = DataTable_default;
5086
- exports.Dialog = ConfirmDialog;
5107
+ exports.DialogAlert = DialogAlert;
5087
5108
  exports.FormErrorMessage = FormErrorMessage;
5088
5109
  exports.FormField = FormField;
5089
5110
  exports.FormFieldContext = FormFieldContext;
@@ -5101,8 +5122,11 @@ exports.buttonVariants = buttonVariants;
5101
5122
  exports.cn = cn;
5102
5123
  exports.compareAlphanumeric = compareAlphanumeric;
5103
5124
  exports.getColumnIdFromTable = getColumnIdFromTable;
5125
+ exports.isDefined = isDefined;
5126
+ exports.isEmptyObject = isEmptyObject;
5104
5127
  exports.renderContentSlot = renderContentSlot;
5105
5128
  exports.selectValueToBoolean = selectValueToBoolean;
5129
+ exports.stripNullishObject = stripNullishObject;
5106
5130
  exports.useFormField = useFormField;
5107
5131
  exports.useGridSettingsStore = useGridSettingsStore;
5108
5132
  exports.useHover = useHover_default;