@trsys-tech/matrix-library 1.0.0-canary.6 → 1.0.0-canary.9
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/calendar.es.js +3 -2
- package/dist/calendar.es.js.map +1 -1
- package/dist/components/badge/Badge.d.ts +1 -1
- package/dist/components/button/Button.d.ts +1 -1
- package/dist/components/chip/Chip.d.ts +1 -1
- package/dist/components/confirm/Confirm.d.ts.map +1 -1
- package/dist/components/data-grid/DataGrid.d.ts +130 -0
- package/dist/components/data-grid/DataGrid.d.ts.map +1 -1
- package/dist/components/date-picker/DesktopDatePicker.d.ts.map +1 -1
- package/dist/components/date-picker/DesktopDateRangePicker.d.ts.map +1 -1
- package/dist/components/date-picker/DesktopTimePicker.d.ts.map +1 -1
- package/dist/components/date-picker/MobileDatePicker.d.ts.map +1 -1
- package/dist/components/date-picker/MobileDateRangePicker.d.ts.map +1 -1
- package/dist/components/date-picker/MobileTimePicker.d.ts.map +1 -1
- package/dist/components/date-picker/TimePickerContent.d.ts.map +1 -1
- package/dist/components/date-picker/calendar.d.ts.map +1 -1
- package/dist/components/duration/Duration.d.ts +1 -1
- package/dist/components/form-date-picker/FormDatePicker.d.ts +1 -0
- package/dist/components/form-date-picker/FormDatePicker.d.ts.map +1 -1
- package/dist/components/icon-botton/IconButton.d.ts +1 -1
- package/dist/components/label/Label.d.ts +1 -1
- package/dist/components/label/Label.d.ts.map +1 -1
- package/dist/components/multi-select/MultiSelect.d.ts +1 -1
- package/dist/components/multi-select/MultiSelect.d.ts.map +1 -1
- package/dist/components/progress/Progress.d.ts +1 -1
- package/dist/components/rating/Rating.d.ts +1 -1
- package/dist/components/sheet/Sheet.d.ts +1 -1
- package/dist/components/sidebar/Sidebar.d.ts +1 -1
- package/dist/components/switch/Switch.d.ts +1 -1
- package/dist/components/text-field/TextField.d.ts +1 -1
- package/dist/components/toast/toast-components.d.ts +1 -1
- package/dist/confirm.es.js +35 -23
- package/dist/confirm.es.js.map +1 -1
- package/dist/datagrid.es.js +129 -116
- package/dist/datagrid.es.js.map +1 -1
- package/dist/desktopdatepicker.es.js +5 -4
- package/dist/desktopdatepicker.es.js.map +1 -1
- package/dist/desktopdaterangepicker.es.js +5 -4
- package/dist/desktopdaterangepicker.es.js.map +1 -1
- package/dist/desktoptimepicker.es.js +5 -4
- package/dist/desktoptimepicker.es.js.map +1 -1
- package/dist/drawer.es.js +1 -1
- package/dist/drawer.es.js.map +1 -1
- package/dist/formdatepicker.es.js +22 -13
- package/dist/formdatepicker.es.js.map +1 -1
- package/dist/mobiledatepicker.es.js +9 -8
- package/dist/mobiledatepicker.es.js.map +1 -1
- package/dist/mobiledaterangepicker.es.js +3 -2
- package/dist/mobiledaterangepicker.es.js.map +1 -1
- package/dist/mobiletimepicker.es.js +9 -8
- package/dist/mobiletimepicker.es.js.map +1 -1
- package/dist/multiselect.es.js +1 -0
- package/dist/multiselect.es.js.map +1 -1
- package/dist/timepickercontent.es.js +5 -4
- package/dist/timepickercontent.es.js.map +1 -1
- package/package.json +1 -1
package/dist/confirm.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirm.es.js","sources":["../src/components/confirm/Confirm.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport React, { useCallback, useEffect } from \"react\";\r\nimport { Modal, ModalFooter } from \"../modal/Modal\";\r\nimport { Button } from \"../button/Button\";\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nlet confirmId = 0;\r\n\r\ntype ConfirmOptions = {\r\n title: string;\r\n description: string;\r\n confirmationText?: string;\r\n cancelationText?: string;\r\n modalProps?: React.ComponentProps<typeof Modal>;\r\n hideCancelButton?: boolean;\r\n buttonOrder?: (\"confirm\" | \"cancel\")[];\r\n confirmButtonProps?: React.ComponentProps<typeof Button>;\r\n cancelButtonProps?: React.ComponentProps<typeof Button>;\r\n descriptionProps?: React.ComponentProps<\"p\">;\r\n};\r\ntype ConfirmState = { resolve: (value: unknown) => void; reject: (reason?: any) => void; parentId: ParentId } | null;\r\ntype ParentId = string;\r\n\r\ntype ConfirmContext = {\r\n confirmBase: (parentId: ParentId, options: ConfirmOptions) => Promise<unknown>;\r\n closeOnParentUnmount: (parentId: ParentId) => void;\r\n} | null;\r\nconst ConfirmContext = React.createContext<ConfirmContext>(null);\r\n\r\n/**\r\n * ConfirmProvider\r\n */\r\ntype ConfirmProviderProps = {\r\n children: React.ReactNode;\r\n};\r\nconst ConfirmProvider: React.FC<ConfirmProviderProps> = ({ children }) => {\r\n const [state, setState] = React.useState<ConfirmState>(null);\r\n const [options, setOptions] = React.useState<ConfirmOptions>({\r\n buttonOrder: [\"cancel\", \"confirm\"],\r\n description: \"\",\r\n title: \"Are you sure?\",\r\n });\r\n const [key, setKey] = React.useState(0);\r\n\r\n const confirmBase = useCallback((parentId: ParentId, options: ConfirmOptions) => {\r\n return new Promise((resolve, reject) => {\r\n setKey(key => key + 1);\r\n setOptions(options);\r\n setState({ resolve, reject, parentId });\r\n });\r\n }, []);\r\n\r\n const closeOnParentUnmount = useCallback((parentId: ParentId) => {\r\n setState(state => {\r\n if (state?.parentId === parentId) {\r\n return null;\r\n } else {\r\n return state;\r\n }\r\n });\r\n }, []);\r\n\r\n const handleClose = useCallback(() => {\r\n setState(state => {\r\n state?.reject();\r\n return null;\r\n });\r\n }, []);\r\n\r\n const handleConfirm = useCallback(() => {\r\n setState(state => {\r\n state?.resolve(null);\r\n return null;\r\n });\r\n }, []);\r\n\r\n return (\r\n <ConfirmContext.Provider value={{ confirmBase, closeOnParentUnmount }}>\r\n {children}\r\n <ConfirmModal key={key} open={state !== null} options={options} onCancel={handleClose} onConfirm={handleConfirm} />\r\n </ConfirmContext.Provider>\r\n );\r\n};\r\n\r\nconst useConfirmId = () => {\r\n const id = React.useMemo(() => {\r\n return confirmId++;\r\n }, []);\r\n\r\n return `confirm-${id}`;\r\n};\r\n\r\nconst useConfirm = () => {\r\n const parentId = useConfirmId();\r\n const context = React.useContext(ConfirmContext);\r\n if (!context) {\r\n throw new Error(\"useConfirm must be used within a ConfirmProvider\");\r\n }\r\n\r\n const { confirmBase, closeOnParentUnmount } = context;\r\n\r\n const confirm = useCallback(\r\n (options: ConfirmOptions) => {\r\n return confirmBase(parentId, options);\r\n },\r\n [parentId, confirmBase],\r\n );\r\n\r\n useEffect(() => {\r\n return () => {\r\n closeOnParentUnmount(parentId);\r\n };\r\n }, [parentId, closeOnParentUnmount]);\r\n\r\n return confirm;\r\n};\r\n\r\ntype ConfirmModalProps = {\r\n open: boolean;\r\n onCancel?: () => void;\r\n onConfirm: () => void;\r\n options: ConfirmOptions;\r\n};\r\n\r\nconst ConfirmModal: React.FC<ConfirmModalProps> = ({ onConfirm, open, options, onCancel }) => {\r\n const {\r\n buttonOrder = [\"cancel\", \"confirm\"],\r\n description,\r\n title,\r\n cancelationText,\r\n confirmationText,\r\n hideCancelButton,\r\n modalProps,\r\n cancelButtonProps,\r\n confirmButtonProps,\r\n descriptionProps,\r\n } = options;\r\n\r\n const actions = React.useMemo(\r\n () =>\r\n buttonOrder.map(action => {\r\n const { className: confirmClassName, ...restConfirmButtonProps } = confirmButtonProps ?? {};\r\n const { className: cancelClassName, ...restCancelButtonProps } = cancelButtonProps ?? {};\r\n if (action === \"confirm\") {\r\n return (\r\n <Button\r\n key=\"confirm-button\"\r\n onClick={onConfirm}\r\n variant=\"primary\"\r\n className={cn(\"mtx-w-28\", confirmClassName)}\r\n {...restConfirmButtonProps}\r\n >\r\n {confirmationText || \"Confirm\"}\r\n </Button>\r\n );\r\n }\r\n if (action === \"cancel\" && !hideCancelButton) {\r\n return (\r\n <Button
|
|
1
|
+
{"version":3,"file":"confirm.es.js","sources":["../src/components/confirm/Confirm.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport React, { useCallback, useEffect } from \"react\";\r\nimport { Modal, ModalFooter } from \"../modal/Modal\";\r\nimport { Button } from \"../button/Button\";\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nlet confirmId = 0;\r\n\r\ntype ConfirmOptions = {\r\n title: string;\r\n description: string;\r\n confirmationText?: string;\r\n cancelationText?: string;\r\n modalProps?: React.ComponentProps<typeof Modal>;\r\n hideCancelButton?: boolean;\r\n buttonOrder?: (\"confirm\" | \"cancel\")[];\r\n confirmButtonProps?: React.ComponentProps<typeof Button>;\r\n cancelButtonProps?: React.ComponentProps<typeof Button>;\r\n descriptionProps?: React.ComponentProps<\"p\">;\r\n};\r\ntype ConfirmState = { resolve: (value: unknown) => void; reject: (reason?: any) => void; parentId: ParentId } | null;\r\ntype ParentId = string;\r\n\r\ntype ConfirmContext = {\r\n confirmBase: (parentId: ParentId, options: ConfirmOptions) => Promise<unknown>;\r\n closeOnParentUnmount: (parentId: ParentId) => void;\r\n} | null;\r\nconst ConfirmContext = React.createContext<ConfirmContext>(null);\r\n\r\n/**\r\n * ConfirmProvider\r\n */\r\ntype ConfirmProviderProps = {\r\n children: React.ReactNode;\r\n};\r\nconst ConfirmProvider: React.FC<ConfirmProviderProps> = ({ children }) => {\r\n const [state, setState] = React.useState<ConfirmState>(null);\r\n const [options, setOptions] = React.useState<ConfirmOptions>({\r\n buttonOrder: [\"cancel\", \"confirm\"],\r\n description: \"\",\r\n title: \"Are you sure?\",\r\n });\r\n const [key, setKey] = React.useState(0);\r\n\r\n const confirmBase = useCallback((parentId: ParentId, options: ConfirmOptions) => {\r\n return new Promise((resolve, reject) => {\r\n setKey(key => key + 1);\r\n setOptions(options);\r\n setState({ resolve, reject, parentId });\r\n });\r\n }, []);\r\n\r\n const closeOnParentUnmount = useCallback((parentId: ParentId) => {\r\n setState(state => {\r\n if (state?.parentId === parentId) {\r\n return null;\r\n } else {\r\n return state;\r\n }\r\n });\r\n }, []);\r\n\r\n const handleClose = useCallback(() => {\r\n setState(state => {\r\n state?.reject();\r\n return null;\r\n });\r\n }, []);\r\n\r\n const handleConfirm = useCallback(() => {\r\n setState(state => {\r\n state?.resolve(null);\r\n return null;\r\n });\r\n }, []);\r\n\r\n return (\r\n <ConfirmContext.Provider value={{ confirmBase, closeOnParentUnmount }}>\r\n {children}\r\n <ConfirmModal key={key} open={state !== null} options={options} onCancel={handleClose} onConfirm={handleConfirm} />\r\n </ConfirmContext.Provider>\r\n );\r\n};\r\n\r\nconst useConfirmId = () => {\r\n const id = React.useMemo(() => {\r\n return confirmId++;\r\n }, []);\r\n\r\n return `confirm-${id}`;\r\n};\r\n\r\nconst useConfirm = () => {\r\n const parentId = useConfirmId();\r\n const context = React.useContext(ConfirmContext);\r\n if (!context) {\r\n throw new Error(\"useConfirm must be used within a ConfirmProvider\");\r\n }\r\n\r\n const { confirmBase, closeOnParentUnmount } = context;\r\n\r\n const confirm = useCallback(\r\n (options: ConfirmOptions) => {\r\n return confirmBase(parentId, options);\r\n },\r\n [parentId, confirmBase],\r\n );\r\n\r\n useEffect(() => {\r\n return () => {\r\n closeOnParentUnmount(parentId);\r\n };\r\n }, [parentId, closeOnParentUnmount]);\r\n\r\n return confirm;\r\n};\r\n\r\ntype ConfirmModalProps = {\r\n open: boolean;\r\n onCancel?: () => void;\r\n onConfirm: () => void;\r\n options: ConfirmOptions;\r\n};\r\n\r\nconst ConfirmModal: React.FC<ConfirmModalProps> = ({ onConfirm, open, options, onCancel }) => {\r\n const {\r\n buttonOrder = [\"cancel\", \"confirm\"],\r\n description,\r\n title,\r\n cancelationText,\r\n confirmationText,\r\n hideCancelButton,\r\n modalProps,\r\n cancelButtonProps,\r\n confirmButtonProps,\r\n descriptionProps,\r\n } = options;\r\n\r\n const actions = React.useMemo(\r\n () =>\r\n buttonOrder.map(action => {\r\n const { className: confirmClassName, ...restConfirmButtonProps } = confirmButtonProps ?? {};\r\n const { className: cancelClassName, ...restCancelButtonProps } = cancelButtonProps ?? {};\r\n if (action === \"confirm\") {\r\n return (\r\n <Button\r\n key=\"confirm-button\"\r\n type=\"button\"\r\n onClick={onConfirm}\r\n variant=\"primary\"\r\n className={cn(\"mtx-w-28\", confirmClassName)}\r\n {...restConfirmButtonProps}\r\n >\r\n {confirmationText || \"Confirm\"}\r\n </Button>\r\n );\r\n }\r\n if (action === \"cancel\" && !hideCancelButton) {\r\n return (\r\n <Button\r\n key=\"cancel-button\"\r\n onClick={onCancel}\r\n variant=\"text\"\r\n className={cn(\"mtx-w-28\", cancelClassName)}\r\n {...restCancelButtonProps}\r\n type=\"button\"\r\n >\r\n {cancelationText || \"Cancel\"}\r\n </Button>\r\n );\r\n }\r\n }),\r\n [hideCancelButton, buttonOrder, confirmationText, cancelationText, confirmButtonProps, cancelButtonProps, onConfirm, onCancel],\r\n );\r\n\r\n return (\r\n <Modal open={open} onOpenChange={onCancel} title={title} role=\"alertdialog\" {...modalProps}>\r\n <p {...descriptionProps}>{description}</p>\r\n <ModalFooter>{actions}</ModalFooter>\r\n </Modal>\r\n );\r\n};\r\n\r\nexport { ConfirmProvider, useConfirm };\r\n"],"names":["confirmId","ConfirmContext","React","ConfirmProvider","children","state","setState","options","setOptions","key","setKey","confirmBase","useCallback","parentId","resolve","reject","closeOnParentUnmount","handleClose","handleConfirm","jsxs","jsx","ConfirmModal","useConfirmId","useConfirm","context","confirm","useEffect","onConfirm","open","onCancel","buttonOrder","description","title","cancelationText","confirmationText","hideCancelButton","modalProps","cancelButtonProps","confirmButtonProps","descriptionProps","actions","action","confirmClassName","restConfirmButtonProps","cancelClassName","restCancelButtonProps","Button","cn","Modal","ModalFooter"],"mappings":";;;;;AAOA,IAAIA,IAAY;AAqBhB,MAAMC,IAAiBC,EAAM,cAA8B,IAAI,GAQzDC,IAAkD,CAAC,EAAE,UAAAC,QAAe;AACxE,QAAM,CAACC,GAAOC,CAAQ,IAAIJ,EAAM,SAAuB,IAAI,GACrD,CAACK,GAASC,CAAU,IAAIN,EAAM,SAAyB;AAAA,IAC3D,aAAa,CAAC,UAAU,SAAS;AAAA,IACjC,aAAa;AAAA,IACb,OAAO;AAAA,EAAA,CACR,GACK,CAACO,GAAKC,CAAM,IAAIR,EAAM,SAAS,CAAC,GAEhCS,IAAcC,EAAY,CAACC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KAAM,MAAApB,GAAY,cAAcC,GAAU,OAAAG,GAAc,MAAK,eAAe,GAAGI,GAC9E,UAAA;AAAA,IAAA,gBAAAhB,EAAC,KAAA,EAAG,GAAGmB,GAAmB,UAAAR,EAAA,CAAY;AAAA,IACtC,gBAAAX,EAAC6B,KAAa,UAAAT,EAAA,CAAQ;AAAA,EAAA,GACxB;AAEJ;"}
|
package/dist/datagrid.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as o, jsxs as z } from "react/jsx-runtime";
|
|
2
|
-
import t, { forwardRef as H, useMemo as
|
|
2
|
+
import t, { forwardRef as H, useMemo as A } from "react";
|
|
3
3
|
import { AgGridReact as L } from "ag-grid-react";
|
|
4
4
|
import { themeQuartz as M, ModuleRegistry as B, AllCommunityModule as Q } from "ag-grid-community";
|
|
5
|
-
import { Trashcan as O, ElipsisVertical as q, Snowflake as $, Print as j, Refresh as _, CircleXmark as U, Magnifier as
|
|
6
|
-
import { cn as
|
|
5
|
+
import { Trashcan as O, ElipsisVertical as q, Snowflake as $, Print as j, Refresh as _, CircleXmark as U, Magnifier as G } from "@trsys-tech/matrix-icons";
|
|
6
|
+
import { cn as C } from "./utils.es.js";
|
|
7
7
|
import { printHtml as V } from "./printhtml.es.js";
|
|
8
8
|
import { TextField as W } from "./textfield.es.js";
|
|
9
|
-
import { Button as
|
|
9
|
+
import { Button as N } from "./button.es.js";
|
|
10
10
|
import { IconButton as D } from "./iconbutton.es.js";
|
|
11
11
|
import { Popover as X, PopoverTrigger as J, PopoverContent as K } from "./popover.es.js";
|
|
12
12
|
B.registerModules([Q]);
|
|
@@ -20,202 +20,215 @@ const Y = M.withParams({
|
|
|
20
20
|
accentColor: "oklch(var(--mtx-primary-300))",
|
|
21
21
|
foregroundColor: "oklch(var(--mtx-text-500))",
|
|
22
22
|
cellTextColor: "oklch(var(--mtx-text-500))"
|
|
23
|
-
}),
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
23
|
+
}), w = t.createContext(null), mt = () => {
|
|
24
|
+
const i = t.useContext(w);
|
|
25
|
+
if (!i)
|
|
26
26
|
throw new Error("useDataGrid should be used within <DataGrid>");
|
|
27
|
-
return
|
|
28
|
-
}, ut = ({ children:
|
|
29
|
-
const s = t.useId(), [
|
|
27
|
+
return i;
|
|
28
|
+
}, ut = ({ children: i }) => {
|
|
29
|
+
const s = t.useId(), [a, r] = t.useState(null), [n, c] = t.useState([]), [l, m] = t.useState(0), [x, d] = t.useState(/* @__PURE__ */ new Set()), [e, u] = t.useState(""), [h, p] = t.useState(!1);
|
|
30
30
|
return /* @__PURE__ */ o(
|
|
31
|
-
|
|
31
|
+
w.Provider,
|
|
32
32
|
{
|
|
33
33
|
value: {
|
|
34
|
-
api:
|
|
35
|
-
setApi:
|
|
36
|
-
rowData:
|
|
34
|
+
api: a,
|
|
35
|
+
setApi: r,
|
|
36
|
+
rowData: n,
|
|
37
37
|
setRowData: c,
|
|
38
38
|
gridId: s,
|
|
39
39
|
quickFilterText: e,
|
|
40
|
-
setQuickFilterText:
|
|
40
|
+
setQuickFilterText: u,
|
|
41
41
|
actionbarExists: h,
|
|
42
|
-
setActionbarExists:
|
|
43
|
-
actionbarHeight:
|
|
42
|
+
setActionbarExists: p,
|
|
43
|
+
actionbarHeight: l,
|
|
44
44
|
setActionbarHeight: m,
|
|
45
|
-
pinnedRowIds:
|
|
46
|
-
setPinnedRowIds:
|
|
45
|
+
pinnedRowIds: x,
|
|
46
|
+
setPinnedRowIds: d
|
|
47
47
|
},
|
|
48
|
-
children:
|
|
48
|
+
children: i
|
|
49
49
|
}
|
|
50
50
|
);
|
|
51
51
|
}, Z = H(
|
|
52
|
-
({ theme:
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
52
|
+
({ theme: i, onGridReady: s, quickFilterText: a, rowData: r, containerStyle: n, getRowId: c, ...l }, m) => {
|
|
53
|
+
const x = t.useContext(w);
|
|
54
|
+
if (!x)
|
|
55
55
|
throw new Error("DataGridContent should be used within <DataGrid>");
|
|
56
|
-
const { rowData:
|
|
56
|
+
const { rowData: d, setRowData: e, actionbarExists: u, setApi: h, setQuickFilterText: p, quickFilterText: R, gridId: b, actionbarHeight: f, pinnedRowIds: g } = x, S = A(() => Y.withParams({
|
|
57
57
|
headerHeight: 40,
|
|
58
|
-
wrapperBorderRadius:
|
|
59
|
-
}), [
|
|
58
|
+
wrapperBorderRadius: u ? "0px 0px 8px 8px" : "8px"
|
|
59
|
+
}), [u]), P = (v) => {
|
|
60
60
|
h(v.api), s?.(v);
|
|
61
61
|
};
|
|
62
62
|
t.useEffect(() => {
|
|
63
|
-
e(
|
|
64
|
-
}, [
|
|
65
|
-
|
|
66
|
-
}, [
|
|
67
|
-
const { finalRowData: F, finalPinnedTopRowData: I } =
|
|
68
|
-
if (!
|
|
69
|
-
return { finalRowData:
|
|
70
|
-
const v = [],
|
|
71
|
-
return
|
|
72
|
-
const
|
|
73
|
-
T !== void 0 &&
|
|
74
|
-
}), { finalRowData:
|
|
75
|
-
}, [
|
|
63
|
+
e(r);
|
|
64
|
+
}, [r, e]), t.useEffect(() => {
|
|
65
|
+
a !== void 0 && p(a ?? "");
|
|
66
|
+
}, [a, p]);
|
|
67
|
+
const { finalRowData: F, finalPinnedTopRowData: I } = A(() => {
|
|
68
|
+
if (!d || g.size === 0)
|
|
69
|
+
return { finalRowData: d, finalPinnedTopRowData: [] };
|
|
70
|
+
const v = [], k = [];
|
|
71
|
+
return d.forEach((E) => {
|
|
72
|
+
const y = c ? c({ data: E, level: 0 }) : E.id, T = y != null ? String(y) : void 0;
|
|
73
|
+
T !== void 0 && g.has(T) ? v.push(E) : k.push(E);
|
|
74
|
+
}), { finalRowData: k, finalPinnedTopRowData: v };
|
|
75
|
+
}, [d, g, c]);
|
|
76
76
|
return /* @__PURE__ */ o(
|
|
77
77
|
L,
|
|
78
78
|
{
|
|
79
|
-
gridId:
|
|
80
|
-
theme:
|
|
79
|
+
gridId: b,
|
|
80
|
+
theme: i ?? S,
|
|
81
81
|
rowData: F,
|
|
82
82
|
pinnedTopRowData: I,
|
|
83
83
|
quickFilterText: R,
|
|
84
|
-
onGridReady:
|
|
85
|
-
containerStyle: { height: `calc(100% - ${
|
|
84
|
+
onGridReady: P,
|
|
85
|
+
containerStyle: { height: `calc(100% - ${f}px)`, ...n },
|
|
86
86
|
getRowId: c,
|
|
87
|
-
...
|
|
87
|
+
...l,
|
|
88
88
|
ref: m
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
92
|
);
|
|
93
93
|
Z.displayName = "DataGridContent";
|
|
94
|
-
const xt = ({ className:
|
|
95
|
-
const
|
|
96
|
-
if (!
|
|
94
|
+
const xt = ({ className: i, ...s }) => {
|
|
95
|
+
const a = t.useContext(w);
|
|
96
|
+
if (!a)
|
|
97
97
|
throw new Error("DataGridActionBar should be used within <DataGrid>");
|
|
98
|
-
const
|
|
99
|
-
return t.useEffect(() => (
|
|
100
|
-
|
|
98
|
+
const r = t.useRef(null), { setActionbarExists: n, setActionbarHeight: c } = a, { children: l } = s;
|
|
99
|
+
return t.useEffect(() => (n(!0), () => n(!1)), [n]), t.useEffect(() => {
|
|
100
|
+
r.current && c(r.current.clientHeight);
|
|
101
101
|
}, [c]), /* @__PURE__ */ o(
|
|
102
102
|
"div",
|
|
103
103
|
{
|
|
104
|
-
className:
|
|
104
|
+
className: C(
|
|
105
105
|
"mtx-relative mtx-flex mtx-items-center mtx-p-2 mtx-h-12 mtx-w-full mtx-bg-gray-0 mtx-border mtx-border-gray-200 mtx-border-b-0 -mtx-mb-[1px] mtx-z-10 mtx-rounded-t-[8px]",
|
|
106
|
-
|
|
106
|
+
i
|
|
107
107
|
),
|
|
108
|
-
ref:
|
|
109
|
-
children:
|
|
108
|
+
ref: r,
|
|
109
|
+
children: l
|
|
110
110
|
}
|
|
111
111
|
);
|
|
112
|
-
}, ht = ({
|
|
113
|
-
|
|
112
|
+
}, ht = ({
|
|
113
|
+
defaultOpen: i = !1,
|
|
114
|
+
defaultOpenAutoFocus: s = !0,
|
|
115
|
+
className: a,
|
|
116
|
+
...r
|
|
117
|
+
}) => {
|
|
118
|
+
const n = t.useContext(w);
|
|
114
119
|
if (!n)
|
|
115
120
|
throw new Error("SearchAction should be used within <DataGrid>");
|
|
116
|
-
const { quickFilterText:
|
|
117
|
-
n.setQuickFilterText(""),
|
|
118
|
-
},
|
|
119
|
-
|
|
121
|
+
const { quickFilterText: c, setQuickFilterText: l } = n, [m, x] = t.useState(i), [d, e] = t.useState(!1), u = t.useRef(null), h = t.useRef(!0), p = () => {
|
|
122
|
+
n.setQuickFilterText(""), u.current && u.current.focus();
|
|
123
|
+
}, R = () => {
|
|
124
|
+
x(!0);
|
|
120
125
|
};
|
|
121
126
|
t.useEffect(() => {
|
|
122
|
-
|
|
123
|
-
}, [
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
+
m && u?.current && (s || !h.current) && u.current.focus(), h.current = !1;
|
|
128
|
+
}, [m, s]);
|
|
129
|
+
const b = () => {
|
|
130
|
+
e(!0), n.setQuickFilterText(""), setTimeout(() => {
|
|
131
|
+
x(!1), e(!1);
|
|
127
132
|
}, 200);
|
|
128
133
|
};
|
|
129
|
-
return /* @__PURE__ */ o("div", { className:
|
|
134
|
+
return /* @__PURE__ */ o("div", { className: C("mtx-max-w-60", a), ...r, children: m || d ? /* @__PURE__ */ o(
|
|
130
135
|
W,
|
|
131
136
|
{
|
|
132
|
-
ref:
|
|
133
|
-
className:
|
|
137
|
+
ref: u,
|
|
138
|
+
className: C(
|
|
134
139
|
"mtx-relative mtx-h-7.5",
|
|
135
|
-
|
|
136
|
-
|
|
140
|
+
m && !d ? "mtx-animate-input-open" : "",
|
|
141
|
+
d && "mtx-animate-input-close"
|
|
137
142
|
),
|
|
138
|
-
onChange: (
|
|
139
|
-
value:
|
|
140
|
-
startAdornment: /* @__PURE__ */ o(D, { variant: "toolbar", className: "mtx-p-0.5 mtx-h-6 mtx-w-6 mtx-border-none mtx-mx-1", onClick:
|
|
141
|
-
endAdornment:
|
|
143
|
+
onChange: (f) => l(f.target.value),
|
|
144
|
+
value: c,
|
|
145
|
+
startAdornment: /* @__PURE__ */ o(D, { variant: "toolbar", type: "button", className: "mtx-p-0.5 mtx-h-6 mtx-w-6 mtx-border-none mtx-mx-1", onClick: b, children: /* @__PURE__ */ o(G, { className: "mtx-w-5 mtx-h-5" }) }),
|
|
146
|
+
endAdornment: c && /* @__PURE__ */ o(D, { variant: "toolbar", type: "button", className: "mtx-p-0.5 mtx-w-6 mtx-h-6 mtx-border-none mtx-mx-1", onClick: p, children: /* @__PURE__ */ o(U, { className: "mtx-w-5 mtx-h-5" }) })
|
|
142
147
|
}
|
|
143
|
-
) : /* @__PURE__ */ o(D, { variant: "toolbar", className: "mtx-p-0.5 mtx-w-6 mtx-h-6 mtx-m-1", onClick:
|
|
144
|
-
},
|
|
145
|
-
|
|
148
|
+
) : /* @__PURE__ */ o(D, { variant: "toolbar", type: "button", className: "mtx-p-0.5 mtx-w-6 mtx-h-6 mtx-m-1", onClick: R, children: /* @__PURE__ */ o(G, { className: "mtx-w-5 mtx-h-5" }) }) });
|
|
149
|
+
}, pt = ({
|
|
150
|
+
freezeText: i,
|
|
151
|
+
unFreezeText: s,
|
|
152
|
+
onClick: a,
|
|
153
|
+
disabled: r,
|
|
154
|
+
...n
|
|
155
|
+
}) => {
|
|
156
|
+
const c = t.useContext(w);
|
|
146
157
|
if (!c)
|
|
147
158
|
throw new Error("FreezeAction should be used within <DataGrid>");
|
|
148
|
-
const [
|
|
159
|
+
const [l, m] = t.useState(0), [x, d] = t.useState(0), { api: e, pinnedRowIds: u, setPinnedRowIds: h } = c, p = () => {
|
|
149
160
|
if (!e) return;
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}), h(
|
|
161
|
+
const f = e.getSelectedNodes();
|
|
162
|
+
if (f.length > 0) {
|
|
163
|
+
const g = new Set(u);
|
|
164
|
+
f.forEach((S) => {
|
|
165
|
+
S.id !== void 0 && g.add(S.id);
|
|
166
|
+
}), h(g), e.deselectAll();
|
|
156
167
|
}
|
|
157
168
|
}, R = () => {
|
|
158
169
|
h(/* @__PURE__ */ new Set());
|
|
159
|
-
},
|
|
160
|
-
e && (e.getPinnedTopRowCount() > 0 ? R() :
|
|
170
|
+
}, b = (f) => {
|
|
171
|
+
e && (e.getPinnedTopRowCount() > 0 ? R() : p()), a?.(f);
|
|
161
172
|
};
|
|
162
173
|
return t.useEffect(() => (e?.addEventListener("pinnedRowDataChanged", () => {
|
|
163
174
|
m(e.getPinnedTopRowCount());
|
|
164
175
|
}), e?.addEventListener("selectionChanged", () => {
|
|
165
|
-
|
|
176
|
+
d(e.getSelectedNodes().length);
|
|
166
177
|
}), () => {
|
|
167
178
|
e?.isDestroyed() || (e?.removeEventListener("pinnedRowDataChanged", () => {
|
|
168
179
|
m(e.getPinnedTopRowCount());
|
|
169
180
|
}), e?.removeEventListener("selectionChanged", () => {
|
|
170
|
-
|
|
181
|
+
d(e.getSelectedNodes().length);
|
|
171
182
|
}));
|
|
172
183
|
}), [e]), /* @__PURE__ */ o(
|
|
173
|
-
|
|
184
|
+
N,
|
|
174
185
|
{
|
|
175
186
|
variant: "text",
|
|
176
|
-
onClick:
|
|
187
|
+
onClick: b,
|
|
177
188
|
startIcon: /* @__PURE__ */ o($, { className: "mtx-w-4.5 mtx-h-4.5" }),
|
|
178
|
-
disabled: !
|
|
179
|
-
|
|
180
|
-
|
|
189
|
+
disabled: !l && !x || r,
|
|
190
|
+
type: "button",
|
|
191
|
+
...n,
|
|
192
|
+
children: l ? s ?? "Unfreeze" : i ?? "Freeze"
|
|
181
193
|
}
|
|
182
194
|
);
|
|
183
|
-
},
|
|
184
|
-
const
|
|
185
|
-
if (!
|
|
195
|
+
}, ft = ({ children: i, className: s, onClick: a, ...r }) => {
|
|
196
|
+
const n = t.useContext(w);
|
|
197
|
+
if (!n)
|
|
186
198
|
throw new Error("PrintAction should be used within <DataGrid>");
|
|
187
|
-
const c = (
|
|
188
|
-
|
|
189
|
-
const m = document.querySelector("[grid-id='" +
|
|
199
|
+
const c = (l) => {
|
|
200
|
+
n.api && (n.api.setGridOption("domLayout", "print"), setTimeout(() => {
|
|
201
|
+
const m = document.querySelector("[grid-id='" + n.gridId + "']"), d = `<html>
|
|
190
202
|
${document.head.innerHTML}
|
|
191
203
|
${m.outerHTML}
|
|
192
204
|
</html>`;
|
|
193
|
-
V(
|
|
194
|
-
})),
|
|
205
|
+
V(d), n?.api?.setGridOption("domLayout", void 0);
|
|
206
|
+
})), a?.(l);
|
|
195
207
|
};
|
|
196
|
-
return /* @__PURE__ */ o(D, { variant: "toolbar", className:
|
|
197
|
-
}, wt = ({ className:
|
|
198
|
-
if (!t.useContext(
|
|
208
|
+
return /* @__PURE__ */ o(D, { variant: "toolbar", type: "button", className: C("mtx-p-0.5 mtx-w-6 mtx-h-6", s), onClick: c, ...r, children: i ?? /* @__PURE__ */ o(j, { className: "mtx-w-5 mtx-h-5" }) });
|
|
209
|
+
}, wt = ({ className: i, onRefresh: s, children: a, loading: r, ...n }) => {
|
|
210
|
+
if (!t.useContext(w))
|
|
199
211
|
throw new Error("RefreshAction should be used within <DataGrid>");
|
|
200
|
-
const
|
|
212
|
+
const l = () => {
|
|
201
213
|
s();
|
|
202
214
|
};
|
|
203
215
|
return /* @__PURE__ */ o(
|
|
204
216
|
D,
|
|
205
217
|
{
|
|
206
|
-
className:
|
|
218
|
+
className: C("mtx-p-0.5 mtx-w-6 mtx-h-6", r && "disabled:mtx-bg-transparent", i),
|
|
207
219
|
variant: "toolbar",
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
220
|
+
type: "button",
|
|
221
|
+
onClick: l,
|
|
222
|
+
disabled: r,
|
|
223
|
+
...n,
|
|
224
|
+
children: a ?? /* @__PURE__ */ o(_, { className: C("mtx-w-4.5 mtx-h-4.5", r && "mtx-animate-spin") })
|
|
212
225
|
}
|
|
213
226
|
);
|
|
214
|
-
}, gt = ({ onDelete:
|
|
215
|
-
|
|
216
|
-
}, startIcon: /* @__PURE__ */ o(O, { className: "mtx-w-4.5 mtx-h-4.5" }), ...
|
|
227
|
+
}, gt = ({ onDelete: i, children: s, ...a }) => /* @__PURE__ */ o(N, { variant: "danger", type: "button", onClick: () => {
|
|
228
|
+
i();
|
|
229
|
+
}, startIcon: /* @__PURE__ */ o(O, { className: "mtx-w-4.5 mtx-h-4.5" }), ...a, children: s }), Ct = ({ children: i, slotProps: s, className: a, ...r }) => /* @__PURE__ */ z(X, { ...s?.popoverProps ?? {}, children: [
|
|
217
230
|
/* @__PURE__ */ o(J, { ...s?.triggerProps ?? {}, children: /* @__PURE__ */ o(q, { className: "mtx-w-4.5 mtx-h-4.5 mtx-text-primary" }) }),
|
|
218
|
-
/* @__PURE__ */ o(K, { align: "end", className:
|
|
231
|
+
/* @__PURE__ */ o(K, { align: "end", className: C("mtx-w-40", a), ...r, children: i })
|
|
219
232
|
] });
|
|
220
233
|
export {
|
|
221
234
|
ut as DataGrid,
|
|
@@ -223,8 +236,8 @@ export {
|
|
|
223
236
|
Z as DataGridContent,
|
|
224
237
|
gt as DeleteAction,
|
|
225
238
|
Ct as ExtraActions,
|
|
226
|
-
|
|
227
|
-
|
|
239
|
+
pt as FreezeAction,
|
|
240
|
+
ft as PrintAction,
|
|
228
241
|
wt as RefreshAction,
|
|
229
242
|
ht as SearchAction,
|
|
230
243
|
Y as dataGridDefaultTheme,
|
package/dist/datagrid.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datagrid.es.js","sources":["../src/components/data-grid/DataGrid.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport React, { forwardRef, HTMLAttributes, useMemo } from \"react\";\r\nimport { AgGridReact, AgGridReactProps } from \"ag-grid-react\";\r\nimport { GridApi, GridReadyEvent, themeQuartz, AllCommunityModule, ModuleRegistry, Theme } from \"ag-grid-community\";\r\nimport { CircleXmark, ElipsisVertical, Magnifier, Print, Refresh, Snowflake, Trashcan } from \"@trsys-tech/matrix-icons\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\nimport { printHtml } from \"../../lib/printHtml\";\r\nimport { TextField } from \"../text-field/TextField\";\r\nimport { Button, ButtonProps } from \"../button/Button\";\r\nimport { IconButton, IconButtonProps } from \"../icon-botton/IconButton\";\r\nimport { Popover, PopoverContent, PopoverContentProps, PopoverProps, PopoverTrigger, PopoverTriggerProps } from \"../popover/Popover\";\r\n\r\n// Register all Community features\r\n// Todo: Register only the required features\r\nModuleRegistry.registerModules([AllCommunityModule]);\r\n\r\nconst dataGridDefaultTheme = themeQuartz.withParams({\r\n fontFamily: \"DMSans\",\r\n fontSize: \"12px\",\r\n headerFontSize: \"12px\",\r\n headerFontWeight: 700,\r\n headerBackgroundColor: \"oklch(var(--mtx-primary-50))\",\r\n backgroundColor: \"oklch(var(--mtx-gray-0))\",\r\n accentColor: \"oklch(var(--mtx-primary-300))\",\r\n foregroundColor: \"oklch(var(--mtx-text-500))\",\r\n cellTextColor: \"oklch(var(--mtx-text-500))\",\r\n});\r\n\r\ntype DataGridContext = {\r\n api: GridApi | null;\r\n setApi: (value: GridApi) => void;\r\n rowData: any[] | null | undefined;\r\n setRowData: (value: any[] | null | undefined) => void;\r\n gridId: string;\r\n quickFilterText: string;\r\n setQuickFilterText: (value: string) => void;\r\n actionbarExists: boolean;\r\n setActionbarExists: (value: boolean) => void;\r\n actionbarHeight: number;\r\n setActionbarHeight: (value: number) => void;\r\n pinnedRowIds: Set<string>;\r\n setPinnedRowIds: (value: Set<string>) => void;\r\n};\r\n\r\nconst DataGridContext = React.createContext<DataGridContext | null>(null);\r\n\r\nconst useDataGrid = () => {\r\n const context = React.useContext(DataGridContext);\r\n\r\n if (!context) {\r\n throw new Error(\"useDataGrid should be used within <DataGrid>\");\r\n }\r\n\r\n return context;\r\n};\r\n\r\ntype DataGridProps = {\r\n children: React.ReactNode;\r\n};\r\n\r\nconst DataGrid: React.FC<DataGridProps> = ({ children }) => {\r\n const gridId = React.useId();\r\n const [api, setApi] = React.useState<GridApi | null>(null);\r\n const [rowData, setRowData] = React.useState<any[] | null | undefined>([]);\r\n const [actionbarHeight, setActionbarHeight] = React.useState(0);\r\n const [pinnedRowIds, setPinnedRowIds] = React.useState<Set<string>>(new Set());\r\n\r\n const [quickFilterText, setQuickFilterText] = React.useState(\"\");\r\n const [actionbarExists, setActionbarExists] = React.useState(false);\r\n return (\r\n <DataGridContext.Provider\r\n value={{\r\n api,\r\n setApi,\r\n rowData,\r\n setRowData,\r\n gridId,\r\n quickFilterText,\r\n setQuickFilterText,\r\n actionbarExists,\r\n setActionbarExists,\r\n actionbarHeight,\r\n setActionbarHeight,\r\n pinnedRowIds,\r\n setPinnedRowIds,\r\n }}\r\n >\r\n {children}\r\n </DataGridContext.Provider>\r\n );\r\n};\r\n\r\ntype DataGridContentProps = Omit<AgGridReactProps, \"theme\"> & {\r\n theme?: Theme;\r\n};\r\n\r\nconst DataGridContent = forwardRef<AgGridReact, DataGridContentProps>(\r\n ({ theme: propTheme, onGridReady, quickFilterText: quickFilterTextProps, rowData: rowDataProps, containerStyle, getRowId, ...props }, ref) => {\r\n const context = React.useContext(DataGridContext);\r\n\r\n if (!context) {\r\n throw new Error(\"DataGridContent should be used within <DataGrid>\");\r\n }\r\n const { rowData, setRowData, actionbarExists, setApi, setQuickFilterText, quickFilterText, gridId, actionbarHeight, pinnedRowIds } = context;\r\n\r\n const theme = useMemo(() => {\r\n return dataGridDefaultTheme.withParams({\r\n headerHeight: 40,\r\n wrapperBorderRadius: actionbarExists ? \"0px 0px 8px 8px\" : \"8px\",\r\n });\r\n }, [actionbarExists]);\r\n\r\n const handleGridReady = (e: GridReadyEvent) => {\r\n setApi(e.api);\r\n onGridReady?.(e);\r\n };\r\n\r\n React.useEffect(() => {\r\n setRowData(rowDataProps);\r\n }, [rowDataProps, setRowData]);\r\n\r\n React.useEffect(() => {\r\n if (quickFilterTextProps !== undefined) {\r\n setQuickFilterText(quickFilterTextProps ?? \"\");\r\n }\r\n }, [quickFilterTextProps, setQuickFilterText]);\r\n\r\n const { finalRowData, finalPinnedTopRowData } = useMemo(() => {\r\n if (!rowData || pinnedRowIds.size === 0) {\r\n return { finalRowData: rowData, finalPinnedTopRowData: [] };\r\n }\r\n\r\n const pinned: any[] = [];\r\n const unpinned: any[] = [];\r\n\r\n rowData.forEach(data => {\r\n const id = getRowId ? getRowId({ data, level: 0 } as any) : (data as any).id;\r\n const stringId = id !== undefined && id !== null ? String(id) : undefined;\r\n\r\n if (stringId !== undefined && pinnedRowIds.has(stringId)) {\r\n pinned.push(data);\r\n } else {\r\n unpinned.push(data);\r\n }\r\n });\r\n\r\n return { finalRowData: unpinned, finalPinnedTopRowData: pinned };\r\n }, [rowData, pinnedRowIds, getRowId]);\r\n\r\n return (\r\n <AgGridReact\r\n gridId={gridId}\r\n theme={propTheme ?? theme}\r\n rowData={finalRowData}\r\n pinnedTopRowData={finalPinnedTopRowData}\r\n quickFilterText={quickFilterText}\r\n onGridReady={handleGridReady}\r\n containerStyle={{ height: `calc(100% - ${actionbarHeight}px)`, ...containerStyle }}\r\n getRowId={getRowId}\r\n {...props}\r\n ref={ref}\r\n />\r\n );\r\n },\r\n);\r\n\r\nDataGridContent.displayName = \"DataGridContent\";\r\n\r\ntype DatagridActionBarProps = HTMLAttributes<HTMLDivElement> & {};\r\n\r\nconst DataGridActionBar: React.FC<DatagridActionBarProps> = ({ className, ...props }) => {\r\n const context = React.useContext(DataGridContext);\r\n\r\n if (!context) {\r\n throw new Error(\"DataGridActionBar should be used within <DataGrid>\");\r\n }\r\n const ref = React.useRef<HTMLDivElement | null>(null);\r\n const { setActionbarExists, setActionbarHeight } = context;\r\n const { children } = props;\r\n\r\n React.useEffect(() => {\r\n setActionbarExists(true);\r\n return () => setActionbarExists(false);\r\n }, [setActionbarExists]);\r\n\r\n React.useEffect(() => {\r\n if (ref.current) {\r\n setActionbarHeight(ref.current.clientHeight);\r\n }\r\n }, [setActionbarHeight]);\r\n\r\n return (\r\n <div\r\n className={cn(\r\n \"mtx-relative mtx-flex mtx-items-center mtx-p-2 mtx-h-12 mtx-w-full mtx-bg-gray-0 mtx-border mtx-border-gray-200 mtx-border-b-0 -mtx-mb-[1px] mtx-z-10 mtx-rounded-t-[8px]\",\r\n className,\r\n )}\r\n ref={ref}\r\n >\r\n {children}\r\n </div>\r\n );\r\n};\r\n\r\ntype SearchActionProps = HTMLAttributes<HTMLDivElement> & {\r\n defaultOpen?: boolean;\r\n};\r\n\r\nconst SearchAction: React.FC<SearchActionProps> = ({ defaultOpen = false, className, ...props }) => {\r\n const context = React.useContext(DataGridContext);\r\n\r\n if (!context) {\r\n throw new Error(\"SearchAction should be used within <DataGrid>\");\r\n }\r\n\r\n const { quickFilterText, setQuickFilterText } = context;\r\n\r\n const [isSearchInputOpen, setIsSearchInputOpen] = React.useState(defaultOpen);\r\n const [isClosing, setIsClosing] = React.useState(false);\r\n const inputRef = React.useRef<HTMLInputElement | null>(null);\r\n\r\n const handleClear = () => {\r\n context.setQuickFilterText(\"\");\r\n if (inputRef.current) {\r\n inputRef.current.focus();\r\n }\r\n };\r\n\r\n const handleOpen = () => {\r\n setIsSearchInputOpen(true);\r\n };\r\n\r\n React.useEffect(() => {\r\n if (isSearchInputOpen && inputRef?.current) {\r\n inputRef.current.focus();\r\n }\r\n }, [isSearchInputOpen]);\r\n\r\n const handleClose = () => {\r\n setIsClosing(true);\r\n context.setQuickFilterText(\"\");\r\n setTimeout(() => {\r\n setIsSearchInputOpen(false);\r\n setIsClosing(false);\r\n }, 200);\r\n };\r\n\r\n return (\r\n <div className={cn(\"mtx-max-w-60\", className)} {...props}>\r\n {isSearchInputOpen || isClosing ? (\r\n <TextField\r\n ref={inputRef}\r\n className={cn(\r\n \"mtx-relative mtx-h-7.5\",\r\n isSearchInputOpen && !isClosing ? \"mtx-animate-input-open\" : \"\",\r\n isClosing && \"mtx-animate-input-close\",\r\n )}\r\n onChange={e => setQuickFilterText(e.target.value)}\r\n value={quickFilterText}\r\n startAdornment={\r\n <IconButton variant=\"toolbar\" className=\"mtx-p-0.5 mtx-h-6 mtx-w-6 mtx-border-none mtx-mx-1\" onClick={handleClose}>\r\n <Magnifier className=\"mtx-w-5 mtx-h-5\" />\r\n </IconButton>\r\n }\r\n endAdornment={\r\n quickFilterText && (\r\n <IconButton variant=\"toolbar\" className=\"mtx-p-0.5 mtx-w-6 mtx-h-6 mtx-border-none mtx-mx-1\" onClick={handleClear}>\r\n <CircleXmark className=\"mtx-w-5 mtx-h-5\" />\r\n </IconButton>\r\n )\r\n }\r\n />\r\n ) : (\r\n <IconButton variant=\"toolbar\" className=\"mtx-p-0.5 mtx-w-6 mtx-h-6 mtx-m-1\" onClick={handleOpen}>\r\n <Magnifier className=\"mtx-w-5 mtx-h-5\" />\r\n </IconButton>\r\n )}\r\n </div>\r\n );\r\n};\r\n\r\ntype FreezeActionProps = ButtonProps & {\r\n freezeText?: string;\r\n unFreezeText?: string;\r\n};\r\n\r\nconst FreezeAction: React.FC<FreezeActionProps> = ({ freezeText, unFreezeText, onClick, disabled, ...props }) => {\r\n const context = React.useContext(DataGridContext);\r\n\r\n if (!context) {\r\n throw new Error(\"FreezeAction should be used within <DataGrid>\");\r\n }\r\n\r\n const [pinnedRowCount, setPinnedRowCount] = React.useState(0);\r\n const [selectedRowsCount, setSelectedRowsCount] = React.useState(0);\r\n\r\n const { api, pinnedRowIds, setPinnedRowIds } = context;\r\n\r\n const freezeRows = () => {\r\n if (!api) return;\r\n\r\n // Get currently selected rows\r\n const selectedRows = api.getSelectedNodes();\r\n\r\n if (selectedRows.length > 0) {\r\n const newPinnedIds = new Set(pinnedRowIds);\r\n selectedRows.forEach(row => {\r\n if (row.id !== undefined) {\r\n newPinnedIds.add(row.id);\r\n }\r\n });\r\n setPinnedRowIds(newPinnedIds);\r\n api.deselectAll();\r\n }\r\n };\r\n\r\n const unfreezeRows = () => {\r\n setPinnedRowIds(new Set());\r\n };\r\n\r\n const handleFreezing = (e: React.MouseEvent<HTMLButtonElement>) => {\r\n if (api) {\r\n const pinnedRowsCount = api.getPinnedTopRowCount();\r\n if (pinnedRowsCount > 0) {\r\n unfreezeRows();\r\n } else {\r\n freezeRows();\r\n }\r\n }\r\n onClick?.(e);\r\n };\r\n\r\n React.useEffect(() => {\r\n api?.addEventListener(\"pinnedRowDataChanged\", () => {\r\n setPinnedRowCount(api.getPinnedTopRowCount());\r\n });\r\n\r\n api?.addEventListener(\"selectionChanged\", () => {\r\n setSelectedRowsCount(api.getSelectedNodes().length);\r\n });\r\n\r\n return () => {\r\n if (api?.isDestroyed()) return;\r\n api?.removeEventListener(\"pinnedRowDataChanged\", () => {\r\n setPinnedRowCount(api.getPinnedTopRowCount());\r\n });\r\n\r\n api?.removeEventListener(\"selectionChanged\", () => {\r\n setSelectedRowsCount(api.getSelectedNodes().length);\r\n });\r\n };\r\n }, [api]);\r\n\r\n return (\r\n <Button\r\n variant=\"text\"\r\n onClick={handleFreezing}\r\n startIcon={<Snowflake className=\"mtx-w-4.5 mtx-h-4.5\" />}\r\n disabled={(!pinnedRowCount && !selectedRowsCount) || disabled}\r\n {...props}\r\n >\r\n {pinnedRowCount ? (unFreezeText ?? \"Unfreeze\") : (freezeText ?? \"Freeze\")}\r\n </Button>\r\n );\r\n};\r\n\r\ntype PrintActionProps = IconButtonProps & {};\r\n\r\nconst PrintAction: React.FC<PrintActionProps> = ({ children, className, onClick, ...props }) => {\r\n const context = React.useContext(DataGridContext);\r\n\r\n if (!context) {\r\n throw new Error(\"PrintAction should be used within <DataGrid>\");\r\n }\r\n\r\n const handlePrint = (e: React.MouseEvent<HTMLButtonElement>) => {\r\n if (context.api) {\r\n context.api.setGridOption(\"domLayout\", \"print\");\r\n\r\n setTimeout(() => {\r\n const element = document.querySelector(\"[grid-id='\" + context.gridId + \"']\") as HTMLElement;\r\n const header = document.head;\r\n const html = `<html>\r\n ${header.innerHTML}\r\n ${element.outerHTML}\r\n </html>`;\r\n printHtml(html);\r\n context?.api?.setGridOption(\"domLayout\", undefined);\r\n });\r\n }\r\n onClick?.(e);\r\n };\r\n\r\n return (\r\n <IconButton variant=\"toolbar\" className={cn(\"mtx-p-0.5 mtx-w-6 mtx-h-6\", className)} onClick={handlePrint} {...props}>\r\n {children ?? <Print className=\"mtx-w-5 mtx-h-5\" />}\r\n </IconButton>\r\n );\r\n};\r\n\r\ntype RefreshActionProps = Omit<IconButtonProps, \"onClick\"> & {\r\n onRefresh: () => void;\r\n};\r\n\r\nconst RefreshAction: React.FC<RefreshActionProps> = ({ className, onRefresh, children, loading, ...props }) => {\r\n const context = React.useContext(DataGridContext);\r\n\r\n if (!context) {\r\n throw new Error(\"RefreshAction should be used within <DataGrid>\");\r\n }\r\n\r\n const handleRefresh = () => {\r\n onRefresh();\r\n };\r\n\r\n return (\r\n <IconButton\r\n className={cn(\"mtx-p-0.5 mtx-w-6 mtx-h-6\", loading && \"disabled:mtx-bg-transparent\", className)}\r\n variant=\"toolbar\"\r\n onClick={handleRefresh}\r\n disabled={loading}\r\n {...props}\r\n >\r\n {children ?? <Refresh className={cn(\"mtx-w-4.5 mtx-h-4.5\", loading && \"mtx-animate-spin\")} />}\r\n </IconButton>\r\n );\r\n};\r\n\r\ntype DeleteActionProps = Omit<ButtonProps, \"onClick\"> & {\r\n onDelete: () => void;\r\n};\r\n\r\nconst DeleteAction: React.FC<DeleteActionProps> = ({ onDelete, children, ...props }) => {\r\n const handleDelete = () => {\r\n onDelete();\r\n };\r\n\r\n return (\r\n <Button variant=\"danger\" onClick={handleDelete} startIcon={<Trashcan className=\"mtx-w-4.5 mtx-h-4.5\" />} {...props}>\r\n {children}\r\n </Button>\r\n );\r\n};\r\n\r\ntype ExtraActionsProps = PopoverContentProps & {\r\n children: React.ReactNode;\r\n slotProps?: {\r\n triggerProps?: PopoverTriggerProps;\r\n popoverProps?: PopoverProps;\r\n };\r\n};\r\n\r\nconst ExtraActions: React.FC<ExtraActionsProps> = ({ children, slotProps, className, ...props }) => {\r\n return (\r\n <Popover {...(slotProps?.popoverProps ?? {})}>\r\n <PopoverTrigger {...(slotProps?.triggerProps ?? {})}>\r\n <ElipsisVertical className=\"mtx-w-4.5 mtx-h-4.5 mtx-text-primary\" />\r\n </PopoverTrigger>\r\n <PopoverContent align=\"end\" className={cn(\"mtx-w-40\", className)} {...props}>\r\n {children}\r\n </PopoverContent>\r\n </Popover>\r\n );\r\n};\r\n\r\nexport {\r\n DataGrid,\r\n DataGridContent,\r\n DataGridActionBar,\r\n SearchAction,\r\n FreezeAction,\r\n PrintAction,\r\n RefreshAction,\r\n ExtraActions,\r\n DeleteAction,\r\n type DataGridProps,\r\n type DataGridContentProps,\r\n type DatagridActionBarProps,\r\n type SearchActionProps,\r\n type FreezeActionProps,\r\n type RefreshActionProps,\r\n type ExtraActionsProps,\r\n type DeleteActionProps,\r\n useDataGrid,\r\n dataGridDefaultTheme,\r\n};\r\n"],"names":["ModuleRegistry","AllCommunityModule","dataGridDefaultTheme","themeQuartz","DataGridContext","React","useDataGrid","context","DataGrid","children","gridId","api","setApi","rowData","setRowData","actionbarHeight","setActionbarHeight","pinnedRowIds","setPinnedRowIds","quickFilterText","setQuickFilterText","actionbarExists","setActionbarExists","jsx","DataGridContent","forwardRef","propTheme","onGridReady","quickFilterTextProps","rowDataProps","containerStyle","getRowId","props","ref","theme","useMemo","handleGridReady","e","finalRowData","finalPinnedTopRowData","pinned","unpinned","data","id","stringId","AgGridReact","DataGridActionBar","className","cn","SearchAction","defaultOpen","isSearchInputOpen","setIsSearchInputOpen","isClosing","setIsClosing","inputRef","handleClear","handleOpen","handleClose","TextField","IconButton","Magnifier","CircleXmark","FreezeAction","freezeText","unFreezeText","onClick","disabled","pinnedRowCount","setPinnedRowCount","selectedRowsCount","setSelectedRowsCount","freezeRows","selectedRows","newPinnedIds","row","unfreezeRows","handleFreezing","Button","Snowflake","PrintAction","handlePrint","element","html","printHtml","Print","RefreshAction","onRefresh","loading","handleRefresh","Refresh","DeleteAction","onDelete","Trashcan","ExtraActions","slotProps","Popover","PopoverTrigger","ElipsisVertical","PopoverContent"],"mappings":";;;;;;;;;;;AAgBAA,EAAe,gBAAgB,CAACC,CAAkB,CAAC;AAEnD,MAAMC,IAAuBC,EAAY,WAAW;AAAA,EAClD,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,eAAe;AACjB,CAAC,GAkBKC,IAAkBC,EAAM,cAAsC,IAAI,GAElEC,KAAc,MAAM;AACxB,QAAMC,IAAUF,EAAM,WAAWD,CAAe;AAEhD,MAAI,CAACG;AACH,UAAM,IAAI,MAAM,8CAA8C;AAGhE,SAAOA;AACT,GAMMC,KAAoC,CAAC,EAAE,UAAAC,QAAe;AAC1D,QAAMC,IAASL,EAAM,MAAA,GACf,CAACM,GAAKC,CAAM,IAAIP,EAAM,SAAyB,IAAI,GACnD,CAACQ,GAASC,CAAU,IAAIT,EAAM,SAAmC,CAAA,CAAE,GACnE,CAACU,GAAiBC,CAAkB,IAAIX,EAAM,SAAS,CAAC,GACxD,CAACY,GAAcC,CAAe,IAAIb,EAAM,SAAsB,oBAAI,KAAK,GAEvE,CAACc,GAAiBC,CAAkB,IAAIf,EAAM,SAAS,EAAE,GACzD,CAACgB,GAAiBC,CAAkB,IAAIjB,EAAM,SAAS,EAAK;AAClE,SACE,gBAAAkB;AAAA,IAACnB,EAAgB;AAAA,IAAhB;AAAA,MACC,OAAO;AAAA,QACL,KAAAO;AAAA,QACA,QAAAC;AAAA,QACA,SAAAC;AAAA,QACA,YAAAC;AAAA,QACA,QAAAJ;AAAA,QACA,iBAAAS;AAAA,QACA,oBAAAC;AAAA,QACA,iBAAAC;AAAA,QACA,oBAAAC;AAAA,QACA,iBAAAP;AAAA,QACA,oBAAAC;AAAA,QACA,cAAAC;AAAA,QACA,iBAAAC;AAAA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GACH,GAYEqF,KAA4C,CAAC,EAAE,UAAArF,GAAU,WAAAsF,GAAW,WAAAhD,GAAW,GAAGf,0BAEnFgE,GAAA,EAAS,GAAID,GAAW,gBAAgB,CAAA,GACvC,UAAA;AAAA,EAAA,gBAAAxE,EAAC0E,GAAA,EAAgB,GAAIF,GAAW,gBAAgB,CAAA,GAC9C,UAAA,gBAAAxE,EAAC2E,GAAA,EAAgB,WAAU,uCAAA,CAAuC,EAAA,CACpE;AAAA,EACA,gBAAA3E,EAAC4E,GAAA,EAAe,OAAM,OAAM,WAAWnD,EAAG,YAAYD,CAAS,GAAI,GAAGf,GACnE,UAAAvB,EAAA,CACH;AAAA,GACF;"}
|
|
1
|
+
{"version":3,"file":"datagrid.es.js","sources":["../src/components/data-grid/DataGrid.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport React, { forwardRef, HTMLAttributes, useMemo } from \"react\";\r\nimport { AgGridReact, AgGridReactProps } from \"ag-grid-react\";\r\nimport { GridApi, GridReadyEvent, themeQuartz, AllCommunityModule, ModuleRegistry, Theme } from \"ag-grid-community\";\r\nimport { CircleXmark, ElipsisVertical, Magnifier, Print, Refresh, Snowflake, Trashcan } from \"@trsys-tech/matrix-icons\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\nimport { printHtml } from \"../../lib/printHtml\";\r\nimport { TextField } from \"../text-field/TextField\";\r\nimport { Button, ButtonProps } from \"../button/Button\";\r\nimport { IconButton, IconButtonProps } from \"../icon-botton/IconButton\";\r\nimport { Popover, PopoverContent, PopoverContentProps, PopoverProps, PopoverTrigger, PopoverTriggerProps } from \"../popover/Popover\";\r\n\r\n// Register all Community features\r\n// Todo: Register only the required features\r\nModuleRegistry.registerModules([AllCommunityModule]);\r\n\r\n/**\r\n * Default ag-Grid theme used by DataGrid.\r\n */\r\nconst dataGridDefaultTheme = themeQuartz.withParams({\r\n fontFamily: \"DMSans\",\r\n fontSize: \"12px\",\r\n headerFontSize: \"12px\",\r\n headerFontWeight: 700,\r\n headerBackgroundColor: \"oklch(var(--mtx-primary-50))\",\r\n backgroundColor: \"oklch(var(--mtx-gray-0))\",\r\n accentColor: \"oklch(var(--mtx-primary-300))\",\r\n foregroundColor: \"oklch(var(--mtx-text-500))\",\r\n cellTextColor: \"oklch(var(--mtx-text-500))\",\r\n});\r\n\r\n/**\r\n * Shared DataGrid state exposed through context.\r\n */\r\ntype DataGridContext = {\r\n api: GridApi | null;\r\n setApi: (value: GridApi) => void;\r\n rowData: any[] | null | undefined;\r\n setRowData: (value: any[] | null | undefined) => void;\r\n gridId: string;\r\n quickFilterText: string;\r\n setQuickFilterText: (value: string) => void;\r\n actionbarExists: boolean;\r\n setActionbarExists: (value: boolean) => void;\r\n actionbarHeight: number;\r\n setActionbarHeight: (value: number) => void;\r\n pinnedRowIds: Set<string>;\r\n setPinnedRowIds: (value: Set<string>) => void;\r\n};\r\n\r\nconst DataGridContext = React.createContext<DataGridContext | null>(null);\r\n\r\n/**\r\n * Returns the current DataGrid context.\r\n */\r\nconst useDataGrid = () => {\r\n const context = React.useContext(DataGridContext);\r\n\r\n if (!context) {\r\n throw new Error(\"useDataGrid should be used within <DataGrid>\");\r\n }\r\n\r\n return context;\r\n};\r\n\r\n/**\r\n * Props for the root DataGrid provider.\r\n */\r\ntype DataGridProps = {\r\n /** Content rendered inside the provider. */\r\n children: React.ReactNode;\r\n};\r\n\r\n/**\r\n * DataGrid provider.\r\n * Provides shared state for the grid shell, content, and toolbar actions.\r\n * @param {DataGridProps} props - DataGrid props.\r\n * @param {React.ReactNode} children - Content rendered inside the provider.\r\n * @returns {React.ReactElement}\r\n */\r\nconst DataGrid: React.FC<DataGridProps> = ({ children }) => {\r\n const gridId = React.useId();\r\n const [api, setApi] = React.useState<GridApi | null>(null);\r\n const [rowData, setRowData] = React.useState<any[] | null | undefined>([]);\r\n const [actionbarHeight, setActionbarHeight] = React.useState(0);\r\n const [pinnedRowIds, setPinnedRowIds] = React.useState<Set<string>>(new Set());\r\n\r\n const [quickFilterText, setQuickFilterText] = React.useState(\"\");\r\n const [actionbarExists, setActionbarExists] = React.useState(false);\r\n return (\r\n <DataGridContext.Provider\r\n value={{\r\n api,\r\n setApi,\r\n rowData,\r\n setRowData,\r\n gridId,\r\n quickFilterText,\r\n setQuickFilterText,\r\n actionbarExists,\r\n setActionbarExists,\r\n actionbarHeight,\r\n setActionbarHeight,\r\n pinnedRowIds,\r\n setPinnedRowIds,\r\n }}\r\n >\r\n {children}\r\n </DataGridContext.Provider>\r\n );\r\n};\r\n\r\n/**\r\n * Props for the Ag Grid content wrapper.\r\n */\r\ntype DataGridContentProps = Omit<AgGridReactProps, \"theme\"> & {\r\n /** Optional theme override forwarded to ag-Grid. */\r\n theme?: Theme;\r\n};\r\n\r\n/**\r\n * DataGridContent component.\r\n * Connects ag-Grid to the shared DataGrid context and keeps pinned rows separate from the main row set.\r\n * @param {DataGridContentProps} props - Ag Grid props.\r\n * @param {Theme} [theme] - Optional ag-Grid theme override.\r\n * @param {GridReadyEvent} [onGridReady] - Called when the grid becomes ready.\r\n * @param {any[] | null | undefined} [rowData] - Row data rendered by the grid.\r\n * @param {string} [quickFilterText] - Quick filter text synced from the search action.\r\n * @param {React.CSSProperties} [containerStyle] - Inline styles applied to the grid container.\r\n * @param {Function} [getRowId] - Resolves the row id used to keep pinned rows stable.\r\n * @param {React.ForwardedRef<AgGridReact>} ref - Grid ref.\r\n * @returns {React.ReactElement}\r\n */\r\nconst DataGridContent = forwardRef<AgGridReact, DataGridContentProps>(\r\n ({ theme: propTheme, onGridReady, quickFilterText: quickFilterTextProps, rowData: rowDataProps, containerStyle, getRowId, ...props }, ref) => {\r\n const context = React.useContext(DataGridContext);\r\n\r\n if (!context) {\r\n throw new Error(\"DataGridContent should be used within <DataGrid>\");\r\n }\r\n const { rowData, setRowData, actionbarExists, setApi, setQuickFilterText, quickFilterText, gridId, actionbarHeight, pinnedRowIds } = context;\r\n\r\n const theme = useMemo(() => {\r\n return dataGridDefaultTheme.withParams({\r\n headerHeight: 40,\r\n wrapperBorderRadius: actionbarExists ? \"0px 0px 8px 8px\" : \"8px\",\r\n });\r\n }, [actionbarExists]);\r\n\r\n const handleGridReady = (e: GridReadyEvent) => {\r\n setApi(e.api);\r\n onGridReady?.(e);\r\n };\r\n\r\n React.useEffect(() => {\r\n setRowData(rowDataProps);\r\n }, [rowDataProps, setRowData]);\r\n\r\n React.useEffect(() => {\r\n if (quickFilterTextProps !== undefined) {\r\n setQuickFilterText(quickFilterTextProps ?? \"\");\r\n }\r\n }, [quickFilterTextProps, setQuickFilterText]);\r\n\r\n const { finalRowData, finalPinnedTopRowData } = useMemo(() => {\r\n if (!rowData || pinnedRowIds.size === 0) {\r\n return { finalRowData: rowData, finalPinnedTopRowData: [] };\r\n }\r\n\r\n const pinned: any[] = [];\r\n const unpinned: any[] = [];\r\n\r\n rowData.forEach(data => {\r\n const id = getRowId ? getRowId({ data, level: 0 } as any) : (data as any).id;\r\n const stringId = id !== undefined && id !== null ? String(id) : undefined;\r\n\r\n if (stringId !== undefined && pinnedRowIds.has(stringId)) {\r\n pinned.push(data);\r\n } else {\r\n unpinned.push(data);\r\n }\r\n });\r\n\r\n return { finalRowData: unpinned, finalPinnedTopRowData: pinned };\r\n }, [rowData, pinnedRowIds, getRowId]);\r\n\r\n return (\r\n <AgGridReact\r\n gridId={gridId}\r\n theme={propTheme ?? theme}\r\n rowData={finalRowData}\r\n pinnedTopRowData={finalPinnedTopRowData}\r\n quickFilterText={quickFilterText}\r\n onGridReady={handleGridReady}\r\n containerStyle={{ height: `calc(100% - ${actionbarHeight}px)`, ...containerStyle }}\r\n getRowId={getRowId}\r\n {...props}\r\n ref={ref}\r\n />\r\n );\r\n },\r\n);\r\n\r\nDataGridContent.displayName = \"DataGridContent\";\r\n\r\n/**\r\n * Props for the DataGrid action bar container.\r\n */\r\ntype DatagridActionBarProps = HTMLAttributes<HTMLDivElement> & {};\r\n\r\n/**\r\n * DataGrid action bar.\r\n * Marks the grid as having a toolbar so the grid can adjust border radius and height.\r\n * @param {DatagridActionBarProps} props - Action bar props.\r\n * @param {React.ReactNode} children - Action bar content.\r\n * @param {string} className - Additional classes applied to the action bar.\r\n * @returns {React.ReactElement}\r\n */\r\nconst DataGridActionBar: React.FC<DatagridActionBarProps> = ({ className, ...props }) => {\r\n const context = React.useContext(DataGridContext);\r\n\r\n if (!context) {\r\n throw new Error(\"DataGridActionBar should be used within <DataGrid>\");\r\n }\r\n const ref = React.useRef<HTMLDivElement | null>(null);\r\n const { setActionbarExists, setActionbarHeight } = context;\r\n const { children } = props;\r\n\r\n React.useEffect(() => {\r\n setActionbarExists(true);\r\n return () => setActionbarExists(false);\r\n }, [setActionbarExists]);\r\n\r\n React.useEffect(() => {\r\n if (ref.current) {\r\n setActionbarHeight(ref.current.clientHeight);\r\n }\r\n }, [setActionbarHeight]);\r\n\r\n return (\r\n <div\r\n className={cn(\r\n \"mtx-relative mtx-flex mtx-items-center mtx-p-2 mtx-h-12 mtx-w-full mtx-bg-gray-0 mtx-border mtx-border-gray-200 mtx-border-b-0 -mtx-mb-[1px] mtx-z-10 mtx-rounded-t-[8px]\",\r\n className,\r\n )}\r\n ref={ref}\r\n >\r\n {children}\r\n </div>\r\n );\r\n};\r\n\r\n/**\r\n * Props for SearchAction.\r\n */\r\ntype SearchActionProps = HTMLAttributes<HTMLDivElement> & {\r\n /** Opens the search input immediately on mount. */\r\n defaultOpen?: boolean;\r\n /** Focuses the input the first time it opens. */\r\n defaultOpenAutoFocus?: boolean;\r\n};\r\n\r\n/**\r\n * Search action.\r\n * Toggles the quick filter input and manages its open/close focus behavior.\r\n * @param {SearchActionProps} props - Search action props.\r\n * @param {boolean} [defaultOpen] - Opens the search input immediately on mount.\r\n * @param {boolean} [defaultOpenAutoFocus] - Focuses the input the first time it opens.\r\n * @param {React.ReactNode} children - Optional wrapper content.\r\n * @param {string} className - Additional wrapper classes.\r\n * @returns {React.ReactElement}\r\n */\r\nconst SearchAction: React.FC<SearchActionProps> = ({\r\n defaultOpen = false,\r\n defaultOpenAutoFocus = true,\r\n className,\r\n ...props\r\n}: SearchActionProps): React.ReactElement => {\r\n const context = React.useContext(DataGridContext);\r\n\r\n if (!context) {\r\n throw new Error(\"SearchAction should be used within <DataGrid>\");\r\n }\r\n\r\n const { quickFilterText, setQuickFilterText } = context;\r\n\r\n const [isSearchInputOpen, setIsSearchInputOpen] = React.useState(defaultOpen);\r\n const [isClosing, setIsClosing] = React.useState(false);\r\n const inputRef = React.useRef<HTMLInputElement | null>(null);\r\n const isFirstRender = React.useRef(true);\r\n\r\n const handleClear = () => {\r\n context.setQuickFilterText(\"\");\r\n if (inputRef.current) {\r\n inputRef.current.focus();\r\n }\r\n };\r\n\r\n const handleOpen = () => {\r\n setIsSearchInputOpen(true);\r\n };\r\n\r\n React.useEffect(() => {\r\n if (isSearchInputOpen && inputRef?.current && (defaultOpenAutoFocus || !isFirstRender.current)) {\r\n inputRef.current.focus();\r\n }\r\n isFirstRender.current = false;\r\n }, [isSearchInputOpen, defaultOpenAutoFocus]);\r\n\r\n const handleClose = () => {\r\n setIsClosing(true);\r\n context.setQuickFilterText(\"\");\r\n setTimeout(() => {\r\n setIsSearchInputOpen(false);\r\n setIsClosing(false);\r\n }, 200);\r\n };\r\n\r\n return (\r\n <div className={cn(\"mtx-max-w-60\", className)} {...props}>\r\n {isSearchInputOpen || isClosing ? (\r\n <TextField\r\n ref={inputRef}\r\n className={cn(\r\n \"mtx-relative mtx-h-7.5\",\r\n isSearchInputOpen && !isClosing ? \"mtx-animate-input-open\" : \"\",\r\n isClosing && \"mtx-animate-input-close\",\r\n )}\r\n onChange={e => setQuickFilterText(e.target.value)}\r\n value={quickFilterText}\r\n startAdornment={\r\n <IconButton variant=\"toolbar\" type=\"button\" className=\"mtx-p-0.5 mtx-h-6 mtx-w-6 mtx-border-none mtx-mx-1\" onClick={handleClose}>\r\n <Magnifier className=\"mtx-w-5 mtx-h-5\" />\r\n </IconButton>\r\n }\r\n endAdornment={\r\n quickFilterText && (\r\n <IconButton variant=\"toolbar\" type=\"button\" className=\"mtx-p-0.5 mtx-w-6 mtx-h-6 mtx-border-none mtx-mx-1\" onClick={handleClear}>\r\n <CircleXmark className=\"mtx-w-5 mtx-h-5\" />\r\n </IconButton>\r\n )\r\n }\r\n />\r\n ) : (\r\n <IconButton variant=\"toolbar\" type=\"button\" className=\"mtx-p-0.5 mtx-w-6 mtx-h-6 mtx-m-1\" onClick={handleOpen}>\r\n <Magnifier className=\"mtx-w-5 mtx-h-5\" />\r\n </IconButton>\r\n )}\r\n </div>\r\n );\r\n};\r\n\r\n/**\r\n * Props for FreezeAction.\r\n */\r\ntype FreezeActionProps = ButtonProps & {\r\n /** Label shown when rows can be frozen. */\r\n freezeText?: string;\r\n /** Label shown when rows are already frozen. */\r\n unFreezeText?: string;\r\n};\r\n\r\n/**\r\n * Freeze action.\r\n * Pins the current selection when rows are selected, or clears pinned rows when the grid is already frozen.\r\n * @param {FreezeActionProps} props - Freeze action props.\r\n * @param {boolean} [disabled] - Disables the action button.\r\n * @param {React.MouseEventHandler<HTMLButtonElement>} [onClick] - Called after the freeze toggle runs.\r\n * @returns {React.ReactElement}\r\n */\r\nconst FreezeAction: React.FC<FreezeActionProps> = ({\r\n freezeText,\r\n unFreezeText,\r\n onClick,\r\n disabled,\r\n ...props\r\n}: FreezeActionProps): React.ReactElement => {\r\n const context = React.useContext(DataGridContext);\r\n\r\n if (!context) {\r\n throw new Error(\"FreezeAction should be used within <DataGrid>\");\r\n }\r\n\r\n const [pinnedRowCount, setPinnedRowCount] = React.useState(0);\r\n const [selectedRowsCount, setSelectedRowsCount] = React.useState(0);\r\n\r\n const { api, pinnedRowIds, setPinnedRowIds } = context;\r\n\r\n const freezeRows = () => {\r\n if (!api) return;\r\n\r\n // Get currently selected rows\r\n const selectedRows = api.getSelectedNodes();\r\n\r\n if (selectedRows.length > 0) {\r\n const newPinnedIds = new Set(pinnedRowIds);\r\n selectedRows.forEach(row => {\r\n if (row.id !== undefined) {\r\n newPinnedIds.add(row.id);\r\n }\r\n });\r\n setPinnedRowIds(newPinnedIds);\r\n api.deselectAll();\r\n }\r\n };\r\n\r\n const unfreezeRows = () => {\r\n setPinnedRowIds(new Set());\r\n };\r\n\r\n const handleFreezing = (e: React.MouseEvent<HTMLButtonElement>) => {\r\n if (api) {\r\n const pinnedRowsCount = api.getPinnedTopRowCount();\r\n if (pinnedRowsCount > 0) {\r\n unfreezeRows();\r\n } else {\r\n freezeRows();\r\n }\r\n }\r\n onClick?.(e);\r\n };\r\n\r\n React.useEffect(() => {\r\n api?.addEventListener(\"pinnedRowDataChanged\", () => {\r\n setPinnedRowCount(api.getPinnedTopRowCount());\r\n });\r\n\r\n api?.addEventListener(\"selectionChanged\", () => {\r\n setSelectedRowsCount(api.getSelectedNodes().length);\r\n });\r\n\r\n return () => {\r\n if (api?.isDestroyed()) return;\r\n api?.removeEventListener(\"pinnedRowDataChanged\", () => {\r\n setPinnedRowCount(api.getPinnedTopRowCount());\r\n });\r\n\r\n api?.removeEventListener(\"selectionChanged\", () => {\r\n setSelectedRowsCount(api.getSelectedNodes().length);\r\n });\r\n };\r\n }, [api]);\r\n\r\n return (\r\n <Button\r\n variant=\"text\"\r\n onClick={handleFreezing}\r\n startIcon={<Snowflake className=\"mtx-w-4.5 mtx-h-4.5\" />}\r\n disabled={(!pinnedRowCount && !selectedRowsCount) || disabled}\r\n type=\"button\"\r\n {...props}\r\n >\r\n {pinnedRowCount ? (unFreezeText ?? \"Unfreeze\") : (freezeText ?? \"Freeze\")}\r\n </Button>\r\n );\r\n};\r\n\r\n/**\r\n * Props for PrintAction.\r\n */\r\ntype PrintActionProps = IconButtonProps & {};\r\n\r\n/**\r\n * Print action.\r\n * Switches the grid to print layout, captures the rendered markup, and opens the browser print flow.\r\n * @param {PrintActionProps} props - Print action props.\r\n * @param {React.ReactNode} [children] - Custom icon content rendered in the button.\r\n * @param {string} [className] - Additional button classes.\r\n * @param {React.MouseEventHandler<HTMLButtonElement>} [onClick] - Called after printing is triggered.\r\n * @returns {React.ReactElement}\r\n */\r\nconst PrintAction: React.FC<PrintActionProps> = ({ children, className, onClick, ...props }) => {\r\n const context = React.useContext(DataGridContext);\r\n\r\n if (!context) {\r\n throw new Error(\"PrintAction should be used within <DataGrid>\");\r\n }\r\n\r\n const handlePrint = (e: React.MouseEvent<HTMLButtonElement>) => {\r\n if (context.api) {\r\n context.api.setGridOption(\"domLayout\", \"print\");\r\n\r\n setTimeout(() => {\r\n const element = document.querySelector(\"[grid-id='\" + context.gridId + \"']\") as HTMLElement;\r\n const header = document.head;\r\n const html = `<html>\r\n ${header.innerHTML}\r\n ${element.outerHTML}\r\n </html>`;\r\n printHtml(html);\r\n context?.api?.setGridOption(\"domLayout\", undefined);\r\n });\r\n }\r\n onClick?.(e);\r\n };\r\n\r\n return (\r\n <IconButton variant=\"toolbar\" type=\"button\" className={cn(\"mtx-p-0.5 mtx-w-6 mtx-h-6\", className)} onClick={handlePrint} {...props}>\r\n {children ?? <Print className=\"mtx-w-5 mtx-h-5\" />}\r\n </IconButton>\r\n );\r\n};\r\n\r\n/**\r\n * Props for RefreshAction.\r\n */\r\ntype RefreshActionProps = Omit<IconButtonProps, \"onClick\"> & {\r\n /** Callback invoked when the refresh action is clicked. */\r\n onRefresh: () => void;\r\n};\r\n\r\n/**\r\n * Refresh action.\r\n * Calls the provided refresh callback and reflects the loading state in the toolbar button.\r\n * @param {RefreshActionProps} props - Refresh action props.\r\n * @param {() => void} onRefresh - Called when the button is clicked.\r\n * @param {boolean} [loading] - Shows the loading spinner and disables the button.\r\n * @param {React.ReactNode} [children] - Custom icon content rendered in the button.\r\n * @param {string} [className] - Additional button classes.\r\n * @returns {React.ReactElement}\r\n */\r\nconst RefreshAction: React.FC<RefreshActionProps> = ({ className, onRefresh, children, loading, ...props }) => {\r\n const context = React.useContext(DataGridContext);\r\n\r\n if (!context) {\r\n throw new Error(\"RefreshAction should be used within <DataGrid>\");\r\n }\r\n\r\n const handleRefresh = () => {\r\n onRefresh();\r\n };\r\n\r\n return (\r\n <IconButton\r\n className={cn(\"mtx-p-0.5 mtx-w-6 mtx-h-6\", loading && \"disabled:mtx-bg-transparent\", className)}\r\n variant=\"toolbar\"\r\n type=\"button\"\r\n onClick={handleRefresh}\r\n disabled={loading}\r\n {...props}\r\n >\r\n {children ?? <Refresh className={cn(\"mtx-w-4.5 mtx-h-4.5\", loading && \"mtx-animate-spin\")} />}\r\n </IconButton>\r\n );\r\n};\r\n\r\n/**\r\n * Props for DeleteAction.\r\n */\r\ntype DeleteActionProps = Omit<ButtonProps, \"onClick\"> & {\r\n /** Callback invoked when the delete action is clicked. */\r\n onDelete: () => void;\r\n};\r\n\r\n/**\r\n * Delete action.\r\n * Renders a danger button with the delete icon and delegates the click to the provided handler.\r\n * @param {DeleteActionProps} props - Delete action props.\r\n * @param {() => void} onDelete - Called when the button is clicked.\r\n * @param {React.ReactNode} [children] - Button label or custom content.\r\n * @returns {React.ReactElement}\r\n */\r\nconst DeleteAction: React.FC<DeleteActionProps> = ({ onDelete, children, ...props }) => {\r\n const handleDelete = () => {\r\n onDelete();\r\n };\r\n\r\n return (\r\n <Button variant=\"danger\" type=\"button\" onClick={handleDelete} startIcon={<Trashcan className=\"mtx-w-4.5 mtx-h-4.5\" />} {...props}>\r\n {children}\r\n </Button>\r\n );\r\n};\r\n\r\n/**\r\n * Props for ExtraActions.\r\n */\r\ntype ExtraActionsProps = PopoverContentProps & {\r\n /** Menu items rendered inside the popover. */\r\n children: React.ReactNode;\r\n /** Props forwarded to the popover trigger and popover root. */\r\n slotProps?: {\r\n triggerProps?: PopoverTriggerProps;\r\n popoverProps?: PopoverProps;\r\n };\r\n};\r\n\r\n/**\r\n * Extra actions menu.\r\n * Wraps overflow actions in a popover anchored to the vertical ellipsis trigger.\r\n * @param {ExtraActionsProps} props - Extra actions props.\r\n * @param {React.ReactNode} children - Menu items rendered inside the popover.\r\n * @param {{ triggerProps?: PopoverTriggerProps; popoverProps?: PopoverProps; }} [slotProps] - Props forwarded to the trigger and popover root.\r\n * @param {string} [className] - Additional popover content classes.\r\n * @returns {React.ReactElement}\r\n */\r\nconst ExtraActions: React.FC<ExtraActionsProps> = ({ children, slotProps, className, ...props }) => {\r\n return (\r\n <Popover {...(slotProps?.popoverProps ?? {})}>\r\n <PopoverTrigger {...(slotProps?.triggerProps ?? {})}>\r\n <ElipsisVertical className=\"mtx-w-4.5 mtx-h-4.5 mtx-text-primary\" />\r\n </PopoverTrigger>\r\n <PopoverContent align=\"end\" className={cn(\"mtx-w-40\", className)} {...props}>\r\n {children}\r\n </PopoverContent>\r\n </Popover>\r\n );\r\n};\r\n\r\nexport {\r\n DataGrid,\r\n DataGridContent,\r\n DataGridActionBar,\r\n SearchAction,\r\n FreezeAction,\r\n PrintAction,\r\n RefreshAction,\r\n ExtraActions,\r\n DeleteAction,\r\n type DataGridProps,\r\n type DataGridContentProps,\r\n type DatagridActionBarProps,\r\n type SearchActionProps,\r\n type FreezeActionProps,\r\n type RefreshActionProps,\r\n type ExtraActionsProps,\r\n type DeleteActionProps,\r\n useDataGrid,\r\n dataGridDefaultTheme,\r\n};\r\n"],"names":["ModuleRegistry","AllCommunityModule","dataGridDefaultTheme","themeQuartz","DataGridContext","React","useDataGrid","context","DataGrid","children","gridId","api","setApi","rowData","setRowData","actionbarHeight","setActionbarHeight","pinnedRowIds","setPinnedRowIds","quickFilterText","setQuickFilterText","actionbarExists","setActionbarExists","jsx","DataGridContent","forwardRef","propTheme","onGridReady","quickFilterTextProps","rowDataProps","containerStyle","getRowId","props","ref","theme","useMemo","handleGridReady","e","finalRowData","finalPinnedTopRowData","pinned","unpinned","data","id","stringId","AgGridReact","DataGridActionBar","className","cn","SearchAction","defaultOpen","defaultOpenAutoFocus","isSearchInputOpen","setIsSearchInputOpen","isClosing","setIsClosing","inputRef","isFirstRender","handleClear","handleOpen","handleClose","TextField","IconButton","Magnifier","CircleXmark","FreezeAction","freezeText","unFreezeText","onClick","disabled","pinnedRowCount","setPinnedRowCount","selectedRowsCount","setSelectedRowsCount","freezeRows","selectedRows","newPinnedIds","row","unfreezeRows","handleFreezing","Button","Snowflake","PrintAction","handlePrint","element","html","printHtml","Print","RefreshAction","onRefresh","loading","handleRefresh","Refresh","DeleteAction","onDelete","Trashcan","ExtraActions","slotProps","Popover","PopoverTrigger","ElipsisVertical","PopoverContent"],"mappings":";;;;;;;;;;;AAgBAA,EAAe,gBAAgB,CAACC,CAAkB,CAAC;AAKnD,MAAMC,IAAuBC,EAAY,WAAW;AAAA,EAClD,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,kBAAkB;AAAA,EAClB,uBAAuB;AAAA,EACvB,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,iBAAiB;AAAA,EACjB,eAAe;AACjB,CAAC,GAqBKC,IAAkBC,EAAM,cAAsC,IAAI,GAKlEC,KAAc,MAAM;AACxB,QAAMC,IAAUF,EAAM,WAAWD,CAAe;AAEhD,MAAI,CAACG;AACH,UAAM,IAAI,MAAM,8CAA8C;AAGhE,SAAOA;AACT,GAiBMC,KAAoC,CAAC,EAAE,UAAAC,QAAe;AAC1D,QAAMC,IAASL,EAAM,MAAA,GACf,CAACM,GAAKC,CAAM,IAAIP,EAAM,SAAyB,IAAI,GACnD,CAACQ,GAASC,CAAU,IAAIT,EAAM,SAAmC,CAAA,CAAE,GACnE,CAACU,GAAiBC,CAAkB,IAAIX,EAAM,SAAS,CAAC,GACxD,CAACY,GAAcC,CAAe,IAAIb,EAAM,SAAsB,oBAAI,KAAK,GAEvE,CAACc,GAAiBC,CAAkB,IAAIf,EAAM,SAAS,EAAE,GACzD,CAACgB,GAAiBC,CAAkB,IAAIjB,EAAM,SAAS,EAAK;AAClE,SACE,gBAAAkB;AAAA,IAACnB,EAAgB;AAAA,IAAhB;AAAA,MACC,OAAO;AAAA,QACL,KAAAO;AAAA,QACA,QAAAC;AAAA,QACA,SAAAC;AAAA,QACA,YAAAC;AAAA,QACA,QAAAJ;AAAA,QACA,iBAAAS;AAAA,QACA,oB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A,MACT,UAAUD;AAAA,MACT,GAAG1D;AAAA,MAEH,UAAAvB,uBAAamF,GAAA,EAAQ,WAAW5C,EAAG,uBAAuB0C,KAAW,kBAAkB,EAAA,CAAG;AAAA,IAAA;AAAA,EAAA;AAGjG,GAkBMG,KAA4C,CAAC,EAAE,UAAAC,GAAU,UAAArF,GAAU,GAAGuB,0BAMvEgD,GAAA,EAAO,SAAQ,UAAS,MAAK,UAAS,SALpB,MAAM;AACzB,EAAAc,EAAA;AACF,GAGgE,WAAW,gBAAAvE,EAACwE,KAAS,WAAU,sBAAA,CAAsB,GAAK,GAAG/D,GACxH,UAAAvB,GACH,GA0BEuF,KAA4C,CAAC,EAAE,UAAAvF,GAAU,WAAAwF,GAAW,WAAAlD,GAAW,GAAGf,0BAEnFkE,GAAA,EAAS,GAAID,GAAW,gBAAgB,CAAA,GACvC,UAAA;AAAA,EAAA,gBAAA1E,EAAC4E,GAAA,EAAgB,GAAIF,GAAW,gBAAgB,CAAA,GAC9C,UAAA,gBAAA1E,EAAC6E,GAAA,EAAgB,WAAU,uCAAA,CAAuC,EAAA,CACpE;AAAA,EACA,gBAAA7E,EAAC8E,GAAA,EAAe,OAAM,OAAM,WAAWrD,EAAG,YAAYD,CAAS,GAAI,GAAGf,GACnE,UAAAvB,EAAA,CACH;AAAA,GACF;"}
|
|
@@ -14,8 +14,8 @@ const I = ({
|
|
|
14
14
|
calendarClassName: d,
|
|
15
15
|
closeOnSelect: s = !0,
|
|
16
16
|
onDayClick: i,
|
|
17
|
-
disabled:
|
|
18
|
-
...
|
|
17
|
+
disabled: p,
|
|
18
|
+
...l
|
|
19
19
|
}) => {
|
|
20
20
|
const [c, a] = h.useState(!1), u = (f, y, b) => {
|
|
21
21
|
i?.(f, y, b), s && a(!1);
|
|
@@ -31,7 +31,8 @@ const I = ({
|
|
|
31
31
|
),
|
|
32
32
|
"data-placeholder": t ? void 0 : "",
|
|
33
33
|
"aria-label": t ? `Selected date: ${m(t, r ?? "yyyy/MM/dd")}` : "Pick a date",
|
|
34
|
-
disabled:
|
|
34
|
+
disabled: p,
|
|
35
|
+
type: "button",
|
|
35
36
|
children: [
|
|
36
37
|
t ? m(t, r ?? "yyyy/MM/dd") : /* @__PURE__ */ e("span", { children: n ?? "Pick a date" }),
|
|
37
38
|
/* @__PURE__ */ e(g, { className: "mtx-mr-2 mtx-ms-auto" })
|
|
@@ -44,7 +45,7 @@ const I = ({
|
|
|
44
45
|
defaultMonth: t,
|
|
45
46
|
startMonth: new Date(2e3, 0, 1),
|
|
46
47
|
endMonth: new Date((/* @__PURE__ */ new Date()).getFullYear() + 2, 11, 31),
|
|
47
|
-
...
|
|
48
|
+
...l,
|
|
48
49
|
mode: "single",
|
|
49
50
|
selected: t,
|
|
50
51
|
captionLayout: "dropdown-years",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desktopdatepicker.es.js","sources":["../src/components/date-picker/DesktopDatePicker.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport { format } from \"date-fns\";\r\nimport { Calendar as CalendarIcon } from \"@trsys-tech/matrix-icons\";\r\nimport { PropsBase, PropsSingle, DayEventHandler } from \"react-day-picker\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\nimport { Calendar } from \"./calendar\";\r\nimport { Button } from \"../button/Button\";\r\nimport { Popover, PopoverContent, PopoverTrigger } from \"../popover/Popover\";\r\n\r\ntype DesktopDatePickerProps = PropsBase &\r\n Omit<PropsSingle, \"mode\"> & {\r\n formatStr?: string;\r\n placeholder?: string;\r\n calendarClassName?: string;\r\n selected?: Date;\r\n required?: boolean;\r\n closeOnSelect?: boolean;\r\n disabled?: boolean;\r\n };\r\n\r\nconst DesktopDatePicker: React.FC<DesktopDatePickerProps> = ({\r\n formatStr,\r\n selected,\r\n placeholder,\r\n className,\r\n calendarClassName,\r\n closeOnSelect = true,\r\n onDayClick,\r\n disabled,\r\n ...props\r\n}) => {\r\n const [isOpen, setIsOpen] = React.useState(false);\r\n\r\n const handleDayClick: DayEventHandler<React.MouseEvent<Element, MouseEvent>> = (date, modifiers, e) => {\r\n onDayClick?.(date, modifiers, e);\r\n if (closeOnSelect) setIsOpen(false);\r\n };\r\n\r\n return (\r\n <Popover open={isOpen} onOpenChange={setIsOpen}>\r\n <PopoverTrigger asChild>\r\n <Button\r\n variant=\"text\"\r\n className={cn(\r\n \"mtx-flex mtx-h-8 mtx-w-full mtx-items-center mtx-justify-between mtx-whitespace-nowrap mtx-rounded-sm mtx-border mtx-border-input mtx-bg-transparent mtx-ps-3 mtx-pe-1 mtx-py-1.5 mtx-text-xs mtx-ring-offset-background data-[placeholder]:mtx-text-muted-foreground hover:mtx-border hover:mtx-border-primary hover:mtx-bg-transparent focus:mtx-border focus:mtx-border-primary focus:mtx-outline-none focus:mtx-ring focus:mtx-ring-primary-100 disabled:mtx-cursor-not-allowed disabled:mtx-bg-gray-100 disabled:mtx-text-text-300 disabled:mtx-border-gray-100 [&>span]:mtx-line-clamp-1 [&_svg]:disabled:mtx-text-text-300\",\r\n className,\r\n )}\r\n data-placeholder={!selected ? \"\" : undefined}\r\n aria-label={selected ? `Selected date: ${format(selected, formatStr ?? \"yyyy/MM/dd\")}` : \"Pick a date\"}\r\n disabled={disabled}\r\n >\r\n {selected ? format(selected, formatStr ?? \"yyyy/MM/dd\") : <span>{placeholder ?? \"Pick a date\"}</span>}\r\n <CalendarIcon className=\"mtx-mr-2 mtx-ms-auto\" />\r\n </Button>\r\n </PopoverTrigger>\r\n <PopoverContent className=\"mtx-w-auto mtx-p-0\">\r\n <Calendar\r\n defaultMonth={selected}\r\n startMonth={new Date(2000, 0, 1)}\r\n endMonth={new Date(new Date().getFullYear() + 2, 11, 31)}\r\n {...props}\r\n mode=\"single\"\r\n selected={selected}\r\n captionLayout=\"dropdown-years\"\r\n className={calendarClassName}\r\n onDayClick={handleDayClick}\r\n />\r\n </PopoverContent>\r\n </Popover>\r\n );\r\n};\r\n\r\nexport { DesktopDatePicker, type DesktopDatePickerProps };\r\n"],"names":["DesktopDatePicker","formatStr","selected","placeholder","className","calendarClassName","closeOnSelect","onDayClick","disabled","props","isOpen","setIsOpen","React","handleDayClick","date","modifiers","e","jsxs","Popover","jsx","PopoverTrigger","Button","cn","format","CalendarIcon","PopoverContent","Calendar"],"mappings":";;;;;;;;AAuBA,MAAMA,IAAsD,CAAC;AAAA,EAC3D,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,eAAAC,IAAgB;AAAA,EAChB,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,MAAM;AACJ,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAM,SAAS,EAAK,GAE1CC,IAAyE,CAACC,GAAMC,GAAWC,MAAM;AACrG,IAAAT,IAAaO,GAAMC,GAAWC,CAAC,GAC3BV,OAAyB,EAAK;AAAA,EACpC;AAEA,SACE,gBAAAW,EAACC,GAAA,EAAQ,MAAMR,GAAQ,cAAcC,GACnC,UAAA;AAAA,IAAA,gBAAAQ,EAACC,GAAA,EAAe,SAAO,IACrB,UAAA,gBAAAH;AAAA,MAACI;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,WAAWC;AAAA,UACT;AAAA,UACAlB;AAAA,QAAA;AAAA,QAEF,oBAAmBF,IAAgB,SAAL;AAAA,QAC9B,cAAYA,IAAW,kBAAkBqB,EAAOrB,GAAUD,KAAa,YAAY,CAAC,KAAK;AAAA,QACzF,UAAAO;AAAA,
|
|
1
|
+
{"version":3,"file":"desktopdatepicker.es.js","sources":["../src/components/date-picker/DesktopDatePicker.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport * as React from \"react\";\r\nimport { format } from \"date-fns\";\r\nimport { Calendar as CalendarIcon } from \"@trsys-tech/matrix-icons\";\r\nimport { PropsBase, PropsSingle, DayEventHandler } from \"react-day-picker\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\nimport { Calendar } from \"./calendar\";\r\nimport { Button } from \"../button/Button\";\r\nimport { Popover, PopoverContent, PopoverTrigger } from \"../popover/Popover\";\r\n\r\ntype DesktopDatePickerProps = PropsBase &\r\n Omit<PropsSingle, \"mode\"> & {\r\n formatStr?: string;\r\n placeholder?: string;\r\n calendarClassName?: string;\r\n selected?: Date;\r\n required?: boolean;\r\n closeOnSelect?: boolean;\r\n disabled?: boolean;\r\n };\r\n\r\nconst DesktopDatePicker: React.FC<DesktopDatePickerProps> = ({\r\n formatStr,\r\n selected,\r\n placeholder,\r\n className,\r\n calendarClassName,\r\n closeOnSelect = true,\r\n onDayClick,\r\n disabled,\r\n ...props\r\n}) => {\r\n const [isOpen, setIsOpen] = React.useState(false);\r\n\r\n const handleDayClick: DayEventHandler<React.MouseEvent<Element, MouseEvent>> = (date, modifiers, e) => {\r\n onDayClick?.(date, modifiers, e);\r\n if (closeOnSelect) setIsOpen(false);\r\n };\r\n\r\n return (\r\n <Popover open={isOpen} onOpenChange={setIsOpen}>\r\n <PopoverTrigger asChild>\r\n <Button\r\n variant=\"text\"\r\n className={cn(\r\n \"mtx-flex mtx-h-8 mtx-w-full mtx-items-center mtx-justify-between mtx-whitespace-nowrap mtx-rounded-sm mtx-border mtx-border-input mtx-bg-transparent mtx-ps-3 mtx-pe-1 mtx-py-1.5 mtx-text-xs mtx-ring-offset-background data-[placeholder]:mtx-text-muted-foreground hover:mtx-border hover:mtx-border-primary hover:mtx-bg-transparent focus:mtx-border focus:mtx-border-primary focus:mtx-outline-none focus:mtx-ring focus:mtx-ring-primary-100 disabled:mtx-cursor-not-allowed disabled:mtx-bg-gray-100 disabled:mtx-text-text-300 disabled:mtx-border-gray-100 [&>span]:mtx-line-clamp-1 [&_svg]:disabled:mtx-text-text-300\",\r\n className,\r\n )}\r\n data-placeholder={!selected ? \"\" : undefined}\r\n aria-label={selected ? `Selected date: ${format(selected, formatStr ?? \"yyyy/MM/dd\")}` : \"Pick a date\"}\r\n disabled={disabled}\r\n type=\"button\"\r\n >\r\n {selected ? format(selected, formatStr ?? \"yyyy/MM/dd\") : <span>{placeholder ?? \"Pick a date\"}</span>}\r\n <CalendarIcon className=\"mtx-mr-2 mtx-ms-auto\" />\r\n </Button>\r\n </PopoverTrigger>\r\n <PopoverContent className=\"mtx-w-auto mtx-p-0\">\r\n <Calendar\r\n defaultMonth={selected}\r\n startMonth={new Date(2000, 0, 1)}\r\n endMonth={new Date(new Date().getFullYear() + 2, 11, 31)}\r\n {...props}\r\n mode=\"single\"\r\n selected={selected}\r\n captionLayout=\"dropdown-years\"\r\n className={calendarClassName}\r\n onDayClick={handleDayClick}\r\n />\r\n </PopoverContent>\r\n </Popover>\r\n );\r\n};\r\n\r\nexport { DesktopDatePicker, type DesktopDatePickerProps };\r\n"],"names":["DesktopDatePicker","formatStr","selected","placeholder","className","calendarClassName","closeOnSelect","onDayClick","disabled","props","isOpen","setIsOpen","React","handleDayClick","date","modifiers","e","jsxs","Popover","jsx","PopoverTrigger","Button","cn","format","CalendarIcon","PopoverContent","Calendar"],"mappings":";;;;;;;;AAuBA,MAAMA,IAAsD,CAAC;AAAA,EAC3D,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC;AAAA,EACA,WAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,eAAAC,IAAgB;AAAA,EAChB,YAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,MAAM;AACJ,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAM,SAAS,EAAK,GAE1CC,IAAyE,CAACC,GAAMC,GAAWC,MAAM;AACrG,IAAAT,IAAaO,GAAMC,GAAWC,CAAC,GAC3BV,OAAyB,EAAK;AAAA,EACpC;AAEA,SACE,gBAAAW,EAACC,GAAA,EAAQ,MAAMR,GAAQ,cAAcC,GACnC,UAAA;AAAA,IAAA,gBAAAQ,EAACC,GAAA,EAAe,SAAO,IACrB,UAAA,gBAAAH;AAAA,MAACI;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,WAAWC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