@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.d.mts
CHANGED
|
@@ -369,22 +369,29 @@ interface AdvanceSearchProps {
|
|
|
369
369
|
|
|
370
370
|
declare const AdvanceSearch: React__default.FC<AdvanceSearchProps>;
|
|
371
371
|
|
|
372
|
-
type
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
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,
|
|
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
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
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,
|
|
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-
|
|
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-
|
|
5009
|
-
|
|
5010
|
-
|
|
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
|
|
5014
|
-
option: "py-5 h-9 px-4
|
|
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: "
|
|
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,
|
|
5052
|
+
className: cn3(buttonVariants4({ variant, size, active, className })),
|
|
5048
5053
|
...props
|
|
5049
5054
|
}
|
|
5050
5055
|
);
|
|
5051
5056
|
}
|
|
5052
|
-
function
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
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:
|
|
5066
|
-
/* @__PURE__ */ jsxRuntime.jsx(DialogDescription2, { children:
|
|
5081
|
+
title && /* @__PURE__ */ jsxRuntime.jsx(DialogTitle2, { className: variantClass(variant), children: title }),
|
|
5082
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(DialogDescription2, { children: description })
|
|
5067
5083
|
] }),
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
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.
|
|
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;
|