@trsys-tech/matrix-library 0.4.5 → 0.4.6
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/combobox.es.js +75 -53
- package/dist/combobox.es.js.map +1 -1
- package/dist/components/combobox/Combobox.d.ts +6 -1
- package/dist/components/combobox/Combobox.d.ts.map +1 -1
- package/dist/components/data-grid/DataGrid.d.ts +2 -2
- package/dist/components/data-grid/DataGrid.d.ts.map +1 -1
- package/dist/components/form-combobox/FormCombobox.d.ts +1 -0
- package/dist/components/form-combobox/FormCombobox.d.ts.map +1 -1
- package/dist/datagrid.es.js +106 -106
- package/dist/datagrid.es.js.map +1 -1
- package/dist/formcombobox.es.js +42 -40
- package/dist/formcombobox.es.js.map +1 -1
- package/package.json +1 -1
package/dist/combobox.es.js
CHANGED
|
@@ -1,63 +1,71 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as n, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import a, { useRef as K, useEffect as R } from "react";
|
|
3
3
|
import { cn as h } from "./utils.es.js";
|
|
4
|
-
import { Button as
|
|
5
|
-
import { ChevronDown as
|
|
6
|
-
import { Popover as
|
|
7
|
-
import { Command as
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
import { Button as _ } from "./button.es.js";
|
|
5
|
+
import { ChevronDown as A, XMark as O, Check as T } from "@trsys-tech/matrix-icons";
|
|
6
|
+
import { Popover as z, PopoverTrigger as G, PopoverContent as M } from "./popover.es.js";
|
|
7
|
+
import { Command as X, CommandInput as q, CommandList as H, CommandEmpty as J, CommandItem as v, CommandGroup as Q } from "./command.es.js";
|
|
8
|
+
import { IconButton as U } from "./iconbutton.es.js";
|
|
9
|
+
const ae = ({
|
|
10
|
+
onValueChange: t,
|
|
11
|
+
options: i,
|
|
12
|
+
value: u,
|
|
13
|
+
className: w,
|
|
14
|
+
clearable: x = !1,
|
|
15
|
+
closeOnSelect: s = !0,
|
|
16
|
+
loading: d,
|
|
17
|
+
disabled: y,
|
|
18
|
+
placeholder: C = "Select an option",
|
|
19
|
+
searchText: g = "Search...",
|
|
20
|
+
noResultsText: k = "No results found",
|
|
21
|
+
loadingText: N = "Loading...",
|
|
22
|
+
emptyOptionsText: P = "No Items",
|
|
23
|
+
showSearchInput: p = !0,
|
|
22
24
|
...L
|
|
23
25
|
}) => {
|
|
24
|
-
const [
|
|
26
|
+
const [m, l] = a.useState(!1), f = K(null), [r, c] = a.useState(u), D = a.useCallback(
|
|
25
27
|
(e) => {
|
|
26
|
-
e.key === "Enter" ?
|
|
28
|
+
e.key === "Enter" ? l(!0) : e.key === "Backspace" && !e.currentTarget.value && (c(r), t?.(r), s && l(!1));
|
|
27
29
|
},
|
|
28
|
-
[r,
|
|
29
|
-
),
|
|
30
|
+
[r, t, s]
|
|
31
|
+
), E = a.useCallback(
|
|
30
32
|
(e) => {
|
|
31
|
-
|
|
33
|
+
c(e), t?.(e), s && l(!1);
|
|
32
34
|
},
|
|
33
|
-
[
|
|
34
|
-
),
|
|
35
|
+
[t, s]
|
|
36
|
+
), I = a.useCallback(
|
|
35
37
|
(e) => {
|
|
36
|
-
|
|
38
|
+
e.stopPropagation(), c(void 0), t?.(void 0);
|
|
37
39
|
},
|
|
38
|
-
[
|
|
40
|
+
[t]
|
|
41
|
+
), S = a.useCallback((e, B, F = [""]) => F.join("").toLocaleLowerCase().includes(B.toLocaleLowerCase()) ? 1 : 0, []), j = a.useCallback(
|
|
42
|
+
(e) => {
|
|
43
|
+
p || (e.preventDefault(), f.current?.focus());
|
|
44
|
+
},
|
|
45
|
+
[p]
|
|
39
46
|
);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}, [
|
|
47
|
+
R(() => {
|
|
48
|
+
c(u);
|
|
49
|
+
}, [u]);
|
|
43
50
|
const b = r === void 0 || r === "";
|
|
44
|
-
return /* @__PURE__ */
|
|
45
|
-
/* @__PURE__ */
|
|
46
|
-
|
|
51
|
+
return /* @__PURE__ */ n(z, { open: m, onOpenChange: l, children: [
|
|
52
|
+
/* @__PURE__ */ o(G, { asChild: !0, children: /* @__PURE__ */ n(
|
|
53
|
+
_,
|
|
47
54
|
{
|
|
48
55
|
variant: "text",
|
|
49
56
|
role: "combobox",
|
|
50
|
-
"
|
|
57
|
+
type: "button",
|
|
58
|
+
"aria-expanded": m,
|
|
51
59
|
className: h(
|
|
52
60
|
"group flex h-8 w-full items-center justify-between whitespace-nowrap overflow-hidden rounded-sm border border-input bg-transparent px-3 py-1.5 text-sm ring-offset-background data-[placeholder]:text-muted-foreground hover:border hover:border-primary hover:bg-transparent focus:border focus:border-primary focus:outline-none focus:ring focus:ring-primary-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-text-300 disabled:border-gray-100 [&_svg]:disabled:text-text-300",
|
|
53
|
-
|
|
61
|
+
w
|
|
54
62
|
),
|
|
55
63
|
"data-value": r,
|
|
56
64
|
"data-placeholder": b ? "" : void 0,
|
|
57
|
-
loading:
|
|
58
|
-
disabled:
|
|
59
|
-
endIcon: /* @__PURE__ */
|
|
60
|
-
|
|
65
|
+
loading: d,
|
|
66
|
+
disabled: y,
|
|
67
|
+
endIcon: /* @__PURE__ */ o(
|
|
68
|
+
A,
|
|
61
69
|
{
|
|
62
70
|
role: "button",
|
|
63
71
|
"aria-label": "Expand dropdown",
|
|
@@ -65,30 +73,44 @@ const $ = ({
|
|
|
65
73
|
}
|
|
66
74
|
),
|
|
67
75
|
...L,
|
|
68
|
-
children:
|
|
76
|
+
children: [
|
|
77
|
+
/* @__PURE__ */ o("span", { className: "text-start text-ellipsis whitespace-nowrap overflow-hidden flex-1 max-w-[calc(100%-24px)]", children: b ? d ? N : C : i.find((e) => e.value === r)?.label }),
|
|
78
|
+
x && r !== void 0 ? /* @__PURE__ */ o(
|
|
79
|
+
U,
|
|
80
|
+
{
|
|
81
|
+
onClick: I,
|
|
82
|
+
className: "p-0 [&>svg]:h-4.5 [&>svg]:w-4.5",
|
|
83
|
+
type: "button",
|
|
84
|
+
size: "sm",
|
|
85
|
+
variant: "toolbar",
|
|
86
|
+
"aria-label": "Clear selection",
|
|
87
|
+
children: /* @__PURE__ */ o(O, {})
|
|
88
|
+
}
|
|
89
|
+
) : null
|
|
90
|
+
]
|
|
69
91
|
}
|
|
70
92
|
) }),
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
-
|
|
93
|
+
/* @__PURE__ */ o(M, { className: "w-auto p-0", align: "start", onEscapeKeyDown: () => l(!1), onOpenAutoFocus: j, children: /* @__PURE__ */ n(
|
|
94
|
+
X,
|
|
73
95
|
{
|
|
74
96
|
className: "w-[--radix-popper-anchor-width] focus-visible:outline-none",
|
|
75
|
-
filter:
|
|
97
|
+
filter: S,
|
|
76
98
|
defaultValue: r !== void 0 ? String(r) : void 0,
|
|
77
99
|
ref: f,
|
|
78
100
|
children: [
|
|
79
|
-
|
|
80
|
-
/* @__PURE__ */
|
|
81
|
-
!
|
|
82
|
-
!
|
|
83
|
-
/* @__PURE__ */
|
|
101
|
+
p && /* @__PURE__ */ o(q, { placeholder: g, onKeyDown: D }),
|
|
102
|
+
/* @__PURE__ */ n(H, { children: [
|
|
103
|
+
!d && /* @__PURE__ */ o(J, { children: k }),
|
|
104
|
+
!d && !i.length ? /* @__PURE__ */ o(v, { value: "8fdcaeb67c8ad943c80fe54c3b1059b700d9254389a38a4a1fc39a6eee7564623", disabled: !0, children: P }) : null,
|
|
105
|
+
/* @__PURE__ */ o(Q, { children: i.map((e) => /* @__PURE__ */ n(
|
|
84
106
|
v,
|
|
85
107
|
{
|
|
86
108
|
value: e.value,
|
|
87
109
|
keywords: [e.label],
|
|
88
|
-
onSelect:
|
|
110
|
+
onSelect: E,
|
|
89
111
|
children: [
|
|
90
112
|
e.label,
|
|
91
|
-
/* @__PURE__ */
|
|
113
|
+
/* @__PURE__ */ o(T, { className: h("ml-auto", r === e.value ? "opacity-100" : "opacity-0") })
|
|
92
114
|
]
|
|
93
115
|
},
|
|
94
116
|
String(e.value)
|
|
@@ -100,6 +122,6 @@ const $ = ({
|
|
|
100
122
|
] });
|
|
101
123
|
};
|
|
102
124
|
export {
|
|
103
|
-
|
|
125
|
+
ae as Combobox
|
|
104
126
|
};
|
|
105
127
|
//# sourceMappingURL=combobox.es.js.map
|
package/dist/combobox.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combobox.es.js","sources":["../src/components/combobox/Combobox.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport React, { useEffect, useRef } from \"react\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\nimport { Button } from \"../button/Button\";\r\nimport { Check, ChevronDown } from \"@trsys-tech/matrix-icons\";\r\nimport { Popover, PopoverContent, PopoverTrigger } from \"../popover/Popover\";\r\nimport { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from \"../command/Command\";\r\n\r\ntype ComboboxProps<T extends string | number> = React.HTMLAttributes<HTMLButtonElement> & {\r\n /**\r\n * The options to display in the combobox.\r\n * Each option should have a label and a value.\r\n * The label is what is displayed in the combobox.\r\n * The value is what is returned when the option is selected.\r\n */\r\n options: { label: string; value: T }[];\r\n\r\n /**\r\n * The value of the combobox.\r\n */\r\n value?: T;\r\n\r\n /**\r\n * A function that is called when the value of the combobox changes.\r\n */\r\n onValueChange?: (value: T) => void;\r\n\r\n /**\r\n * Placeholder text to be displayed when no values are selected.\r\n * @default \"Select an option\"\r\n */\r\n placeholder?: string;\r\n\r\n /**\r\n * The modality of the popover. When set to true, interaction with outside elements\r\n * will be disabled and only popover content will be visible to screen readers.\r\n * Optional\r\n * @default false\r\n */\r\n modalPopover?: boolean;\r\n\r\n /**\r\n * The text to display in the search input.\r\n * @default \"Search...\"\r\n */\r\n searchText?: string;\r\n\r\n /**\r\n * The text to display when no results are found.\r\n * @default \"No results found\"\r\n */\r\n noResultsText?: string;\r\n\r\n /**\r\n * Whether the popover should close when an option is selected.\r\n * @default true\r\n */\r\n closeOnSelect?: boolean;\r\n\r\n /**\r\n * Whether the combobox is loading.\r\n * @default false\r\n */\r\n loading?: boolean;\r\n\r\n /**\r\n * Whether the combobox is disabled.\r\n * @default false\r\n */\r\n disabled?: boolean;\r\n\r\n /**\r\n * The text to display when the combobox is loading.\r\n * @default \"Loading...\"\r\n */\r\n loadingText?: string;\r\n\r\n /**\r\n * The text to display when there are no options.\r\n * @default \"No Items\"\r\n */\r\n emptyOptionsText?: string;\r\n\r\n /**\r\n * Whether to show the search input.\r\n * @default true\r\n */\r\n showSearchInput?: boolean;\r\n};\r\n\r\nconst Combobox = <T extends string | number>({\r\n onValueChange,\r\n options,\r\n value,\r\n className,\r\n closeOnSelect = true,\r\n loading,\r\n disabled,\r\n placeholder = \"Select an option\",\r\n searchText = \"Search...\",\r\n noResultsText = \"No results found\",\r\n loadingText = \"Loading...\",\r\n emptyOptionsText = \"No Items\",\r\n showSearchInput = true,\r\n ...props\r\n}: ComboboxProps<T>) => {\r\n const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);\r\n const commandRef = useRef<HTMLDivElement>(null);\r\n\r\n const [currentSelectedValue, setCurrentSelectedValue] = React.useState<T | undefined>(value);\r\n\r\n const handleInputKeyDown = React.useCallback(\r\n (event: React.KeyboardEvent<HTMLInputElement>) => {\r\n if (event.key === \"Enter\") {\r\n setIsPopoverOpen(true);\r\n } else if (event.key === \"Backspace\" && !event.currentTarget.value) {\r\n setCurrentSelectedValue(currentSelectedValue);\r\n onValueChange?.(currentSelectedValue!);\r\n if (closeOnSelect) setIsPopoverOpen(false);\r\n }\r\n },\r\n [currentSelectedValue, onValueChange, closeOnSelect],\r\n );\r\n\r\n const handleSelect = React.useCallback(\r\n (currentValue: T) => {\r\n setCurrentSelectedValue(currentValue);\r\n onValueChange?.(currentValue);\r\n if (closeOnSelect) setIsPopoverOpen(false);\r\n },\r\n [onValueChange, closeOnSelect],\r\n );\r\n\r\n const handleFilter = React.useCallback((value: string, search: string, keywords: string[] = [\"\"]) => {\r\n return keywords.join(\"\").toLocaleLowerCase().includes(search.toLocaleLowerCase()) ? 1 : 0;\r\n }, []);\r\n\r\n // when search input is not shown, we need to focus on the command manually to enable keyboard navigation\r\n const handleOpenAutoFocus = React.useCallback(\r\n (e: Event) => {\r\n if (!showSearchInput) {\r\n e.preventDefault();\r\n commandRef.current?.focus();\r\n }\r\n },\r\n [showSearchInput],\r\n );\r\n\r\n useEffect(() => {\r\n setCurrentSelectedValue(value);\r\n }, [value]);\r\n\r\n const showPlaceholder = currentSelectedValue === undefined || currentSelectedValue === \"\";\r\n\r\n return (\r\n <Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen}>\r\n <PopoverTrigger asChild>\r\n <Button\r\n variant=\"text\"\r\n role=\"combobox\"\r\n aria-expanded={isPopoverOpen}\r\n className={cn(\r\n \"group flex h-8 w-full items-center justify-between whitespace-nowrap overflow-hidden rounded-sm border border-input bg-transparent px-3 py-1.5 text-sm ring-offset-background data-[placeholder]:text-muted-foreground hover:border hover:border-primary hover:bg-transparent focus:border focus:border-primary focus:outline-none focus:ring focus:ring-primary-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-text-300 disabled:border-gray-100 [&_svg]:disabled:text-text-300\",\r\n className,\r\n )}\r\n data-value={currentSelectedValue}\r\n data-placeholder={showPlaceholder ? \"\" : undefined}\r\n loading={loading}\r\n disabled={disabled}\r\n endIcon={\r\n <ChevronDown\r\n role=\"button\"\r\n aria-label=\"Expand dropdown\"\r\n className=\"!h-4.5 !w-4.5 cursor-pointer group-data-[state=open]:rotate-180 transition-transform ms-auto\"\r\n />\r\n }\r\n {...props}\r\n >\r\n <span className=\"text-start text-ellipsis whitespace-nowrap overflow-hidden flex-1 max-w-[calc(100%-24px)]\">\r\n {!showPlaceholder ? options.find(option => option.value === currentSelectedValue)?.label : loading ? loadingText : placeholder}\r\n </span>\r\n </Button>\r\n </PopoverTrigger>\r\n <PopoverContent className=\"w-auto p-0\" align=\"start\" onEscapeKeyDown={() => setIsPopoverOpen(false)} onOpenAutoFocus={handleOpenAutoFocus}>\r\n <Command\r\n className=\"w-[--radix-popper-anchor-width] focus-visible:outline-none\"\r\n filter={handleFilter}\r\n defaultValue={currentSelectedValue !== undefined ? String(currentSelectedValue) : undefined} // highlight selected value on open\r\n ref={commandRef}\r\n >\r\n {showSearchInput && <CommandInput placeholder={searchText} onKeyDown={handleInputKeyDown} />}\r\n <CommandList>\r\n {!loading && <CommandEmpty>{noResultsText}</CommandEmpty>}\r\n {!loading && !options.length ? (\r\n <CommandItem value=\"8fdcaeb67c8ad943c80fe54c3b1059b700d9254389a38a4a1fc39a6eee7564623\" disabled>\r\n {emptyOptionsText}\r\n </CommandItem>\r\n ) : null}\r\n <CommandGroup>\r\n {options.map(option => (\r\n <CommandItem\r\n key={String(option.value)}\r\n value={option.value}\r\n keywords={[option.label]}\r\n onSelect={handleSelect as React.ComponentProps<typeof CommandItem>[\"onSelect\"]}\r\n >\r\n {option.label}\r\n <Check className={cn(\"ml-auto\", currentSelectedValue === option.value ? \"opacity-100\" : \"opacity-0\")} />\r\n </CommandItem>\r\n ))}\r\n </CommandGroup>\r\n </CommandList>\r\n </Command>\r\n </PopoverContent>\r\n </Popover>\r\n );\r\n};\r\nexport { Combobox, type ComboboxProps };\r\n"],"names":["Combobox","onValueChange","options","value","className","closeOnSelect","loading","disabled","placeholder","searchText","noResultsText","loadingText","emptyOptionsText","showSearchInput","props","isPopoverOpen","setIsPopoverOpen","React","commandRef","useRef","currentSelectedValue","setCurrentSelectedValue","handleInputKeyDown","event","handleSelect","currentValue","handleFilter","search","keywords","handleOpenAutoFocus","useEffect","showPlaceholder","jsxs","Popover","jsx","PopoverTrigger","Button","cn","ChevronDown","option","PopoverContent","Command","CommandInput","CommandList","CommandEmpty","CommandItem","CommandGroup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AoB;AAAA,4BACzFqB,GACE,EAAA,UAAA;AAAA,YAAC,CAAArC,KAAY,gBAAA4B,EAAAU,GAAA,EAAc,UAAclC,EAAA,CAAA;AAAA,YACzC,CAACJ,KAAW,CAACJ,EAAQ,SACpB,gBAAAgC,EAACW,GAAY,EAAA,OAAM,qEAAoE,UAAQ,IAC5F,UAAAjC,EAAA,CACH,IACE;AAAA,YACH,gBAAAsB,EAAAY,GAAA,EACE,UAAQ5C,EAAA,IAAI,CACXqC,MAAA,gBAAAP;AAAA,cAACa;AAAA,cAAA;AAAA,gBAEC,OAAON,EAAO;AAAA,gBACd,UAAU,CAACA,EAAO,KAAK;AAAA,gBACvB,UAAUf;AAAA,gBAET,UAAA;AAAA,kBAAOe,EAAA;AAAA,kBACR,gBAAAL,EAACa,GAAM,EAAA,WAAWV,EAAG,WAAWjB,MAAyBmB,EAAO,QAAQ,gBAAgB,WAAW,EAAG,CAAA;AAAA,gBAAA;AAAA,cAAA;AAAA,cANjG,OAAOA,EAAO,KAAK;AAAA,YAAA,CAQ3B,EACH,CAAA;AAAA,UAAA,EACF,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,EAEJ,CAAA;AAAA,EAAA,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"combobox.es.js","sources":["../src/components/combobox/Combobox.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport React, { useEffect, useRef } from \"react\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\nimport { Button } from \"../button/Button\";\r\nimport { Check, ChevronDown, XMark } from \"@trsys-tech/matrix-icons\";\r\nimport { Popover, PopoverContent, PopoverTrigger } from \"../popover/Popover\";\r\nimport { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from \"../command/Command\";\r\nimport { IconButton } from \"../icon-botton/IconButton\";\r\n\r\ntype ComboboxProps<T extends string | number> = React.HTMLAttributes<HTMLButtonElement> & {\r\n /**\r\n * The options to display in the combobox.\r\n * Each option should have a label and a value.\r\n * The label is what is displayed in the combobox.\r\n * The value is what is returned when the option is selected.\r\n */\r\n options: { label: string; value: T }[];\r\n\r\n /**\r\n * The value of the combobox.\r\n */\r\n value?: T;\r\n\r\n /**\r\n * A function that is called when the value of the combobox changes.\r\n */\r\n onValueChange?: (value: T) => void;\r\n\r\n /**\r\n * Placeholder text to be displayed when no values are selected.\r\n * @default \"Select an option\"\r\n */\r\n placeholder?: string;\r\n\r\n /**\r\n * The modality of the popover. When set to true, interaction with outside elements\r\n * will be disabled and only popover content will be visible to screen readers.\r\n * Optional\r\n * @default false\r\n */\r\n modalPopover?: boolean;\r\n\r\n /**\r\n * The text to display in the search input.\r\n * @default \"Search...\"\r\n */\r\n searchText?: string;\r\n\r\n /**\r\n * The text to display when no results are found.\r\n * @default \"No results found\"\r\n */\r\n noResultsText?: string;\r\n\r\n /**\r\n * Whether the popover should close when an option is selected.\r\n * @default true\r\n */\r\n closeOnSelect?: boolean;\r\n\r\n /**\r\n * Whether the combobox is loading.\r\n * @default false\r\n */\r\n loading?: boolean;\r\n\r\n /**\r\n * Whether the combobox is disabled.\r\n * @default false\r\n */\r\n disabled?: boolean;\r\n\r\n /**\r\n * The text to display when the combobox is loading.\r\n * @default \"Loading...\"\r\n */\r\n loadingText?: string;\r\n\r\n /**\r\n * The text to display when there are no options.\r\n * @default \"No Items\"\r\n */\r\n emptyOptionsText?: string;\r\n\r\n /**\r\n * Whether to show the search input.\r\n * @default true\r\n */\r\n showSearchInput?: boolean;\r\n\r\n /**\r\n * Whether to show the clear button.\r\n * @default false\r\n */\r\n clearable?: boolean;\r\n};\r\n\r\nconst Combobox = <T extends string | number>({\r\n onValueChange,\r\n options,\r\n value,\r\n className,\r\n clearable = false,\r\n closeOnSelect = true,\r\n loading,\r\n disabled,\r\n placeholder = \"Select an option\",\r\n searchText = \"Search...\",\r\n noResultsText = \"No results found\",\r\n loadingText = \"Loading...\",\r\n emptyOptionsText = \"No Items\",\r\n showSearchInput = true,\r\n ...props\r\n}: ComboboxProps<T>) => {\r\n const [isPopoverOpen, setIsPopoverOpen] = React.useState(false);\r\n const commandRef = useRef<HTMLDivElement>(null);\r\n\r\n const [currentSelectedValue, setCurrentSelectedValue] = React.useState<T | undefined>(value);\r\n\r\n const handleInputKeyDown = React.useCallback(\r\n (event: React.KeyboardEvent<HTMLInputElement>) => {\r\n if (event.key === \"Enter\") {\r\n setIsPopoverOpen(true);\r\n } else if (event.key === \"Backspace\" && !event.currentTarget.value) {\r\n setCurrentSelectedValue(currentSelectedValue);\r\n onValueChange?.(currentSelectedValue!);\r\n if (closeOnSelect) setIsPopoverOpen(false);\r\n }\r\n },\r\n [currentSelectedValue, onValueChange, closeOnSelect],\r\n );\r\n\r\n const handleSelect = React.useCallback(\r\n (currentValue: T) => {\r\n setCurrentSelectedValue(currentValue);\r\n onValueChange?.(currentValue);\r\n if (closeOnSelect) setIsPopoverOpen(false);\r\n },\r\n [onValueChange, closeOnSelect],\r\n );\r\n\r\n const handleClear = React.useCallback(\r\n (e: React.MouseEvent) => {\r\n e.stopPropagation();\r\n setCurrentSelectedValue(undefined);\r\n onValueChange?.(undefined as unknown as T);\r\n },\r\n [onValueChange],\r\n );\r\n\r\n const handleFilter = React.useCallback((value: string, search: string, keywords: string[] = [\"\"]) => {\r\n return keywords.join(\"\").toLocaleLowerCase().includes(search.toLocaleLowerCase()) ? 1 : 0;\r\n }, []);\r\n\r\n // when search input is not shown, we need to focus on the command manually to enable keyboard navigation\r\n const handleOpenAutoFocus = React.useCallback(\r\n (e: Event) => {\r\n if (!showSearchInput) {\r\n e.preventDefault();\r\n commandRef.current?.focus();\r\n }\r\n },\r\n [showSearchInput],\r\n );\r\n\r\n useEffect(() => {\r\n setCurrentSelectedValue(value);\r\n }, [value]);\r\n\r\n const showPlaceholder = currentSelectedValue === undefined || currentSelectedValue === \"\";\r\n\r\n return (\r\n <Popover open={isPopoverOpen} onOpenChange={setIsPopoverOpen}>\r\n <PopoverTrigger asChild>\r\n <Button\r\n variant=\"text\"\r\n role=\"combobox\"\r\n type=\"button\"\r\n aria-expanded={isPopoverOpen}\r\n className={cn(\r\n \"group flex h-8 w-full items-center justify-between whitespace-nowrap overflow-hidden rounded-sm border border-input bg-transparent px-3 py-1.5 text-sm ring-offset-background data-[placeholder]:text-muted-foreground hover:border hover:border-primary hover:bg-transparent focus:border focus:border-primary focus:outline-none focus:ring focus:ring-primary-100 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-text-300 disabled:border-gray-100 [&_svg]:disabled:text-text-300\",\r\n className,\r\n )}\r\n data-value={currentSelectedValue}\r\n data-placeholder={showPlaceholder ? \"\" : undefined}\r\n loading={loading}\r\n disabled={disabled}\r\n endIcon={\r\n <ChevronDown\r\n role=\"button\"\r\n aria-label=\"Expand dropdown\"\r\n className=\"!h-4.5 !w-4.5 cursor-pointer group-data-[state=open]:rotate-180 transition-transform ms-auto\"\r\n />\r\n }\r\n {...props}\r\n >\r\n <span className=\"text-start text-ellipsis whitespace-nowrap overflow-hidden flex-1 max-w-[calc(100%-24px)]\">\r\n {!showPlaceholder ? options.find(option => option.value === currentSelectedValue)?.label : loading ? loadingText : placeholder}\r\n </span>\r\n {clearable && currentSelectedValue !== undefined ? (\r\n <IconButton\r\n onClick={handleClear}\r\n className=\"p-0 [&>svg]:h-4.5 [&>svg]:w-4.5\"\r\n type=\"button\"\r\n size=\"sm\"\r\n variant=\"toolbar\"\r\n aria-label=\"Clear selection\"\r\n >\r\n <XMark />\r\n </IconButton>\r\n ) : null}\r\n </Button>\r\n </PopoverTrigger>\r\n <PopoverContent className=\"w-auto p-0\" align=\"start\" onEscapeKeyDown={() => setIsPopoverOpen(false)} onOpenAutoFocus={handleOpenAutoFocus}>\r\n <Command\r\n className=\"w-[--radix-popper-anchor-width] focus-visible:outline-none\"\r\n filter={handleFilter}\r\n defaultValue={currentSelectedValue !== undefined ? String(currentSelectedValue) : undefined} // highlight selected value on open\r\n ref={commandRef}\r\n >\r\n {showSearchInput && <CommandInput placeholder={searchText} onKeyDown={handleInputKeyDown} />}\r\n <CommandList>\r\n {!loading && <CommandEmpty>{noResultsText}</CommandEmpty>}\r\n {!loading && !options.length ? (\r\n <CommandItem value=\"8fdcaeb67c8ad943c80fe54c3b1059b700d9254389a38a4a1fc39a6eee7564623\" disabled>\r\n {emptyOptionsText}\r\n </CommandItem>\r\n ) : null}\r\n <CommandGroup>\r\n {options.map(option => (\r\n <CommandItem\r\n key={String(option.value)}\r\n value={option.value}\r\n keywords={[option.label]}\r\n onSelect={handleSelect as React.ComponentProps<typeof CommandItem>[\"onSelect\"]}\r\n >\r\n {option.label}\r\n <Check className={cn(\"ml-auto\", currentSelectedValue === option.value ? \"opacity-100\" : \"opacity-0\")} />\r\n </CommandItem>\r\n ))}\r\n </CommandGroup>\r\n </CommandList>\r\n </Command>\r\n </PopoverContent>\r\n </Popover>\r\n );\r\n};\r\nexport { Combobox, type ComboboxProps };\r\n"],"names":["Combobox","onValueChange","options","value","className","clearable","closeOnSelect","loading","disabled","placeholder","searchText","noResultsText","loadingText","emptyOptionsText","showSearchInput","props","isPopoverOpen","setIsPopoverOpen","React","commandRef","useRef","currentSelectedValue","setCurrentSelectedValue","handleInputKeyDown","event","handleSelect","currentValue","handleClear","handleFilter","search","keywords","handleOpenAutoFocus","useEffect","showPlaceholder","jsxs","Popover","jsx","PopoverTrigger","Button","cn","ChevronDown","option","IconButton","XMark","PopoverContent","Command","CommandInput","CommandList","CommandEmpty","CommandItem","CommandGroup","Check"],"mappings":";;;;;;;;AAmGA,MAAMA,KAAW,CAA4B;AAAA,EAC3C,eAAAC;AAAA,EACA,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,eAAAC,IAAgB;AAAA,EAChB,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,YAAAC,IAAa;AAAA,EACb,eAAAC,IAAgB;AAAA,EAChB,aAAAC,IAAc;AAAA,EACd,kBAAAC,IAAmB;AAAA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,CAAoB,IAAI;AAAA,QAClF,KAAKF;AAAA,QAEJ,UAAA;AAAA,UAAAL,KAAoB,gBAAAsB,EAAAU,GAAA,EAAa,aAAapC,GAAY,WAAWa,GAAoB;AAAA,4BACzFwB,GACE,EAAA,UAAA;AAAA,YAAC,CAAAxC,KAAY,gBAAA6B,EAAAY,GAAA,EAAc,UAAcrC,EAAA,CAAA;AAAA,YACzC,CAACJ,KAAW,CAACL,EAAQ,SACpB,gBAAAkC,EAACa,GAAY,EAAA,OAAM,qEAAoE,UAAQ,IAC5F,UAAApC,EAAA,CACH,IACE;AAAA,YACH,gBAAAuB,EAAAc,GAAA,EACE,UAAQhD,EAAA,IAAI,CACXuC,MAAA,gBAAAP;AAAA,cAACe;AAAA,cAAA;AAAA,gBAEC,OAAOR,EAAO;AAAA,gBACd,UAAU,CAACA,EAAO,KAAK;AAAA,gBACvB,UAAUhB;AAAA,gBAET,UAAA;AAAA,kBAAOgB,EAAA;AAAA,kBACR,gBAAAL,EAACe,GAAM,EAAA,WAAWZ,EAAG,WAAWlB,MAAyBoB,EAAO,QAAQ,gBAAgB,WAAW,EAAG,CAAA;AAAA,gBAAA;AAAA,cAAA;AAAA,cANjG,OAAOA,EAAO,KAAK;AAAA,YAAA,CAQ3B,EACH,CAAA;AAAA,UAAA,EACF,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,EAEJ,CAAA;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -70,7 +70,12 @@ type ComboboxProps<T extends string | number> = React.HTMLAttributes<HTMLButtonE
|
|
|
70
70
|
* @default true
|
|
71
71
|
*/
|
|
72
72
|
showSearchInput?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Whether to show the clear button.
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
clearable?: boolean;
|
|
73
78
|
};
|
|
74
|
-
declare const Combobox: <T extends string | number>({ onValueChange, options, value, className, closeOnSelect, loading, disabled, placeholder, searchText, noResultsText, loadingText, emptyOptionsText, showSearchInput, ...props }: ComboboxProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
79
|
+
declare const Combobox: <T extends string | number>({ onValueChange, options, value, className, clearable, closeOnSelect, loading, disabled, placeholder, searchText, noResultsText, loadingText, emptyOptionsText, showSearchInput, ...props }: ComboboxProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
75
80
|
export { Combobox, type ComboboxProps };
|
|
76
81
|
//# sourceMappingURL=Combobox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Combobox.d.ts","sourceRoot":"","sources":["../../../src/components/combobox/Combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Combobox.d.ts","sourceRoot":"","sources":["../../../src/components/combobox/Combobox.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA4B,MAAM,OAAO,CAAC;AASjD,KAAK,aAAa,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,iBAAiB,CAAC,GAAG;IACxF;;;;;OAKG;IACH,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,CAAC,CAAA;KAAE,EAAE,CAAC;IAEvC;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,CAAC;IAEV;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAEnC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAE1B;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,QAAA,MAAM,QAAQ,GAAI,CAAC,SAAS,MAAM,GAAG,MAAM,+LAgBxC,aAAa,CAAC,CAAC,CAAC,4CAqIlB,CAAC;AACF,OAAO,EAAE,QAAQ,EAAE,KAAK,aAAa,EAAE,CAAC"}
|
|
@@ -27,7 +27,7 @@ type DataGridContentProps = AgGridReactProps & {};
|
|
|
27
27
|
declare const DataGridContent: React.FC<DataGridContentProps>;
|
|
28
28
|
type DatagridActionBarProps = HTMLAttributes<HTMLDivElement> & {};
|
|
29
29
|
declare const DataGridActionBar: React.FC<DatagridActionBarProps>;
|
|
30
|
-
type SearchActionProps = {
|
|
30
|
+
type SearchActionProps = HTMLAttributes<HTMLDivElement> & {
|
|
31
31
|
defaultOpen?: boolean;
|
|
32
32
|
};
|
|
33
33
|
declare const SearchAction: React.FC<SearchActionProps>;
|
|
@@ -39,7 +39,7 @@ declare const FreezeAction: React.FC<FreezeActionProps>;
|
|
|
39
39
|
type PrintActionProps = IconButtonProps & {};
|
|
40
40
|
declare const PrintAction: React.FC<PrintActionProps>;
|
|
41
41
|
type RefreshActionProps = Omit<IconButtonProps, "onClick"> & {
|
|
42
|
-
|
|
42
|
+
onRefresh: () => void;
|
|
43
43
|
};
|
|
44
44
|
declare const RefreshAction: React.FC<RefreshActionProps>;
|
|
45
45
|
type DeleteActionProps = Omit<ButtonProps, "onClick"> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataGrid.d.ts","sourceRoot":"","sources":["../../../src/components/data-grid/DataGrid.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EA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G,eAAe,GAAG,SAAS,GAAG,aAAa,GAAG,kBAAkB,GAAG,aAAa,GAAG,UAAU,GAAG,iBAAiB,CACxI,CAAC;KACH,CAAC;CACH,CAAC;AAEJ,QAAA,MAAM,YAAY,GAAI,YAAY,SAAS,WAAW,EAAE,KAAK,SAAS,SAAS,CAAC,YAAY,CAAC,mCACpF,iBAAiB,CAAC,YAAY,EAAE,KAAK,CAAC,4CA4D9C,CAAC;AACF,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,CAAC"}
|
package/dist/datagrid.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as r, jsxs as N } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import t from "react";
|
|
3
3
|
import { AgGridReact as A } from "ag-grid-react";
|
|
4
4
|
import { themeQuartz as T } from "ag-grid-community";
|
|
5
5
|
import { Magnifier as G, CircleXmark as k, Snowflake as F, Print as P, Refresh as z, Trashcan as I, ElipsisVertical as y } from "@trsys-tech/matrix-icons";
|
|
@@ -7,198 +7,198 @@ import { cn as w } from "./utils.es.js";
|
|
|
7
7
|
import { printHtml as H } from "./printhtml.es.js";
|
|
8
8
|
import { TextField as O } from "./textfield.es.js";
|
|
9
9
|
import { Button as E } from "./button.es.js";
|
|
10
|
-
import { IconButton as
|
|
10
|
+
import { IconButton as D } from "./iconbutton.es.js";
|
|
11
11
|
import { Popover as L, PopoverTrigger as Q, PopoverContent as B } from "./popover.es.js";
|
|
12
12
|
const M = T.withParams({
|
|
13
13
|
fontFamily: "DMSans",
|
|
14
14
|
fontSize: "12px",
|
|
15
15
|
headerFontSize: "12px",
|
|
16
16
|
headerFontWeight: 700
|
|
17
|
-
}), m =
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
17
|
+
}), m = t.createContext(null), Z = () => {
|
|
18
|
+
const o = t.useContext(m);
|
|
19
|
+
if (!o)
|
|
20
20
|
throw new Error("useDataGrid should be used within <DataGrid>");
|
|
21
|
-
return
|
|
22
|
-
}, ee = ({ children:
|
|
23
|
-
const
|
|
21
|
+
return o;
|
|
22
|
+
}, ee = ({ children: o }) => {
|
|
23
|
+
const s = t.useId(), [a, n] = t.useState(null), [i, d] = t.useState([]), [c, l] = t.useState(0), [u, h] = t.useState(""), [e, p] = t.useState(!1);
|
|
24
24
|
return /* @__PURE__ */ r(
|
|
25
25
|
m.Provider,
|
|
26
26
|
{
|
|
27
27
|
value: {
|
|
28
28
|
api: a,
|
|
29
|
-
setApi:
|
|
30
|
-
rowData:
|
|
29
|
+
setApi: n,
|
|
30
|
+
rowData: i,
|
|
31
31
|
setRowData: d,
|
|
32
|
-
gridId:
|
|
33
|
-
quickFilterText:
|
|
32
|
+
gridId: s,
|
|
33
|
+
quickFilterText: u,
|
|
34
34
|
setQuickFilterText: h,
|
|
35
|
-
actionbarExists:
|
|
35
|
+
actionbarExists: e,
|
|
36
36
|
setActionbarExists: p,
|
|
37
37
|
actionbarHeight: c,
|
|
38
|
-
setActionbarHeight:
|
|
38
|
+
setActionbarHeight: l
|
|
39
39
|
},
|
|
40
|
-
children:
|
|
40
|
+
children: o
|
|
41
41
|
}
|
|
42
42
|
);
|
|
43
43
|
}, te = ({
|
|
44
|
-
theme:
|
|
45
|
-
onGridReady:
|
|
44
|
+
theme: o,
|
|
45
|
+
onGridReady: s,
|
|
46
46
|
quickFilterText: a,
|
|
47
|
-
rowData:
|
|
48
|
-
containerStyle:
|
|
47
|
+
rowData: n,
|
|
48
|
+
containerStyle: i,
|
|
49
49
|
...d
|
|
50
50
|
}) => {
|
|
51
|
-
const c =
|
|
51
|
+
const c = t.useContext(m);
|
|
52
52
|
if (!c)
|
|
53
53
|
throw new Error("DataGridContent should be used within <DataGrid>");
|
|
54
|
-
const { rowData:
|
|
54
|
+
const { rowData: l, setRowData: u, actionbarExists: h, setApi: e, setQuickFilterText: p, quickFilterText: x, gridId: g, actionbarHeight: C } = c, f = M.withParams({
|
|
55
55
|
headerHeight: 40,
|
|
56
56
|
wrapperBorderRadius: h ? "0px 0px 8px 8px" : "8px"
|
|
57
|
-
}), v = (
|
|
58
|
-
|
|
57
|
+
}), v = (R) => {
|
|
58
|
+
e(R.api), s?.(R);
|
|
59
59
|
};
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
}, [
|
|
60
|
+
return t.useEffect(() => {
|
|
61
|
+
u(n);
|
|
62
|
+
}, [n, u]), t.useEffect(() => {
|
|
63
63
|
a !== void 0 && p(a ?? "");
|
|
64
64
|
}, [a, p]), /* @__PURE__ */ r(
|
|
65
65
|
A,
|
|
66
66
|
{
|
|
67
|
-
gridId:
|
|
68
|
-
theme:
|
|
69
|
-
rowData:
|
|
67
|
+
gridId: g,
|
|
68
|
+
theme: o ?? f,
|
|
69
|
+
rowData: l,
|
|
70
70
|
quickFilterText: x,
|
|
71
71
|
onGridReady: v,
|
|
72
|
-
containerStyle: { height: `calc(100% - ${
|
|
72
|
+
containerStyle: { height: `calc(100% - ${C}px)`, ...i },
|
|
73
73
|
...d
|
|
74
74
|
}
|
|
75
75
|
);
|
|
76
|
-
}, ne = ({ className:
|
|
77
|
-
const a =
|
|
76
|
+
}, ne = ({ className: o, ...s }) => {
|
|
77
|
+
const a = t.useContext(m);
|
|
78
78
|
if (!a)
|
|
79
79
|
throw new Error("DataGridActionBar should be used within <DataGrid>");
|
|
80
|
-
const
|
|
81
|
-
return
|
|
82
|
-
|
|
80
|
+
const n = t.useRef(null), { setActionbarExists: i, setActionbarHeight: d } = a, { children: c } = s;
|
|
81
|
+
return t.useEffect(() => (i(!0), () => i(!1)), [i]), t.useEffect(() => {
|
|
82
|
+
n.current && d(n.current.clientHeight);
|
|
83
83
|
}, [d]), /* @__PURE__ */ r(
|
|
84
84
|
"div",
|
|
85
85
|
{
|
|
86
86
|
className: w(
|
|
87
87
|
"relative flex items-center p-2 h-12 w-full bg-gray-0 border border-gray-200 border-b-0 -mb-[1px] z-10 rounded-t-[8px]",
|
|
88
|
-
|
|
88
|
+
o
|
|
89
89
|
),
|
|
90
|
-
ref:
|
|
90
|
+
ref: n,
|
|
91
91
|
children: c
|
|
92
92
|
}
|
|
93
93
|
);
|
|
94
|
-
}, re = ({ defaultOpen:
|
|
95
|
-
const
|
|
96
|
-
if (!
|
|
94
|
+
}, re = ({ defaultOpen: o = !1, className: s, ...a }) => {
|
|
95
|
+
const n = t.useContext(m);
|
|
96
|
+
if (!n)
|
|
97
97
|
throw new Error("SearchAction should be used within <DataGrid>");
|
|
98
|
-
const { quickFilterText:
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
|
|
98
|
+
const { quickFilterText: i, setQuickFilterText: d } = n, [c, l] = t.useState(o), [u, h] = t.useState(!1), e = t.useRef(null), p = () => {
|
|
99
|
+
n.setQuickFilterText(""), e.current && e.current.focus();
|
|
100
|
+
}, x = () => {
|
|
101
|
+
l(!0);
|
|
102
102
|
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}, [
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
t.useEffect(() => {
|
|
104
|
+
c && e?.current && e.current.focus();
|
|
105
|
+
}, [c]);
|
|
106
|
+
const g = () => {
|
|
107
|
+
h(!0), n.setQuickFilterText(""), setTimeout(() => {
|
|
108
|
+
l(!1), h(!1);
|
|
109
109
|
}, 200);
|
|
110
110
|
};
|
|
111
|
-
return /* @__PURE__ */ r("div", { className: "max-w-60", children:
|
|
111
|
+
return /* @__PURE__ */ r("div", { className: w("max-w-60", s), ...a, children: c || u ? /* @__PURE__ */ r(
|
|
112
112
|
O,
|
|
113
113
|
{
|
|
114
|
-
ref:
|
|
115
|
-
className: w("relative h-7.5",
|
|
116
|
-
onChange: (
|
|
117
|
-
value:
|
|
118
|
-
startAdornment: /* @__PURE__ */ r(
|
|
119
|
-
endAdornment:
|
|
114
|
+
ref: e,
|
|
115
|
+
className: w("relative h-7.5", c && !u ? "animate-input-open" : "", u && "animate-input-close"),
|
|
116
|
+
onChange: (C) => d(C.target.value),
|
|
117
|
+
value: i,
|
|
118
|
+
startAdornment: /* @__PURE__ */ r(D, { variant: "toolbar", className: "p-0.5 h-6 w-6 border-none mx-1", onClick: g, children: /* @__PURE__ */ r(G, { className: "w-5 h-5" }) }),
|
|
119
|
+
endAdornment: i && /* @__PURE__ */ r(D, { variant: "toolbar", className: "p-0.5 w-6 h-6 border-none mx-1", onClick: p, children: /* @__PURE__ */ r(k, { className: "w-5 h-5" }) })
|
|
120
120
|
}
|
|
121
|
-
) : /* @__PURE__ */ r(
|
|
122
|
-
}, oe = ({ freezeText:
|
|
123
|
-
const d =
|
|
121
|
+
) : /* @__PURE__ */ r(D, { variant: "toolbar", className: "p-0.5 w-6 h-6 m-1", onClick: x, children: /* @__PURE__ */ r(G, { className: "w-5 h-5" }) }) });
|
|
122
|
+
}, oe = ({ freezeText: o, unFreezeText: s, onClick: a, disabled: n, ...i }) => {
|
|
123
|
+
const d = t.useContext(m);
|
|
124
124
|
if (!d)
|
|
125
125
|
throw new Error("FreezeAction should be used within <DataGrid>");
|
|
126
|
-
const [c,
|
|
127
|
-
if (!
|
|
128
|
-
const f =
|
|
126
|
+
const [c, l] = t.useState(0), [u, h] = t.useState(0), { api: e, rowData: p } = d, x = () => {
|
|
127
|
+
if (!e) return;
|
|
128
|
+
const f = e.getSelectedNodes();
|
|
129
129
|
if (f.length > 0) {
|
|
130
|
-
|
|
130
|
+
e.setGridOption(
|
|
131
131
|
"pinnedTopRowData",
|
|
132
|
-
f.map((
|
|
132
|
+
f.map((b) => b.data)
|
|
133
133
|
);
|
|
134
|
-
const
|
|
135
|
-
|
|
134
|
+
const R = e.getRenderedNodes().filter((b) => !f.some((S) => S.id === b.id));
|
|
135
|
+
e.setGridOption(
|
|
136
136
|
"rowData",
|
|
137
|
-
|
|
137
|
+
R.map((b) => b.data)
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
},
|
|
143
|
-
|
|
140
|
+
}, g = () => {
|
|
141
|
+
e && (e.setGridOption("pinnedTopRowData", []), e.setGridOption("rowData", p));
|
|
142
|
+
}, C = (f) => {
|
|
143
|
+
e && (e.getPinnedTopRowCount() > 0 ? g() : x()), a?.(f);
|
|
144
144
|
};
|
|
145
|
-
return
|
|
146
|
-
|
|
147
|
-
}),
|
|
148
|
-
h(
|
|
145
|
+
return t.useEffect(() => (e?.addEventListener("pinnedRowDataChanged", () => {
|
|
146
|
+
l(e.getPinnedTopRowCount());
|
|
147
|
+
}), e?.addEventListener("selectionChanged", () => {
|
|
148
|
+
h(e.getSelectedNodes().length);
|
|
149
149
|
}), () => {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}),
|
|
153
|
-
h(
|
|
150
|
+
e?.removeEventListener("pinnedRowDataChanged", () => {
|
|
151
|
+
l(e.getPinnedTopRowCount());
|
|
152
|
+
}), e?.removeEventListener("selectionChanged", () => {
|
|
153
|
+
h(e.getSelectedNodes().length);
|
|
154
154
|
});
|
|
155
|
-
}), [
|
|
155
|
+
}), [e]), /* @__PURE__ */ r(
|
|
156
156
|
E,
|
|
157
157
|
{
|
|
158
158
|
variant: "text",
|
|
159
|
-
onClick:
|
|
159
|
+
onClick: C,
|
|
160
160
|
startIcon: /* @__PURE__ */ r(F, { className: "w-4.5 h-4.5" }),
|
|
161
|
-
disabled: !c && !
|
|
162
|
-
...
|
|
163
|
-
children: c ?
|
|
161
|
+
disabled: !c && !u || n,
|
|
162
|
+
...i,
|
|
163
|
+
children: c ? s ?? "Unfreeze" : o ?? "Freeze"
|
|
164
164
|
}
|
|
165
165
|
);
|
|
166
|
-
}, ae = ({ children:
|
|
167
|
-
const
|
|
168
|
-
if (!
|
|
166
|
+
}, ae = ({ children: o, className: s, onClick: a, ...n }) => {
|
|
167
|
+
const i = t.useContext(m);
|
|
168
|
+
if (!i)
|
|
169
169
|
throw new Error("PrintAction should be used within <DataGrid>");
|
|
170
170
|
const d = (c) => {
|
|
171
|
-
|
|
172
|
-
const
|
|
171
|
+
i.api && (i.api.setGridOption("domLayout", "print"), setTimeout(() => {
|
|
172
|
+
const l = document.querySelector("[grid-id='" + i.gridId + "']"), h = `<html>
|
|
173
173
|
${document.head.innerHTML}
|
|
174
|
-
${
|
|
174
|
+
${l.outerHTML}
|
|
175
175
|
</html>`;
|
|
176
|
-
H(h),
|
|
176
|
+
H(h), i?.api?.setGridOption("domLayout", void 0);
|
|
177
177
|
})), a?.(c);
|
|
178
178
|
};
|
|
179
|
-
return /* @__PURE__ */ r(
|
|
180
|
-
}, ie = ({ className:
|
|
181
|
-
if (!
|
|
179
|
+
return /* @__PURE__ */ r(D, { variant: "toolbar", className: w("p-0.5 w-6 h-6", s), onClick: d, ...n, children: o ?? /* @__PURE__ */ r(P, { className: "w-5 h-5" }) });
|
|
180
|
+
}, ie = ({ className: o, onRefresh: s, children: a, loading: n, ...i }) => {
|
|
181
|
+
if (!t.useContext(m))
|
|
182
182
|
throw new Error("RefreshAction should be used within <DataGrid>");
|
|
183
183
|
const c = () => {
|
|
184
|
-
|
|
184
|
+
s();
|
|
185
185
|
};
|
|
186
186
|
return /* @__PURE__ */ r(
|
|
187
|
-
|
|
187
|
+
D,
|
|
188
188
|
{
|
|
189
|
-
className: w("p-0.5 w-6 h-6",
|
|
189
|
+
className: w("p-0.5 w-6 h-6", n && "disabled:bg-transparent", o),
|
|
190
190
|
variant: "toolbar",
|
|
191
191
|
onClick: c,
|
|
192
|
-
disabled:
|
|
193
|
-
...
|
|
194
|
-
children: a ?? /* @__PURE__ */ r(z, { className: w("w-4.5 h-4.5",
|
|
192
|
+
disabled: n,
|
|
193
|
+
...i,
|
|
194
|
+
children: a ?? /* @__PURE__ */ r(z, { className: w("w-4.5 h-4.5", n && "animate-spin") })
|
|
195
195
|
}
|
|
196
196
|
);
|
|
197
|
-
}, se = ({ onDelete:
|
|
198
|
-
|
|
199
|
-
}, startIcon: /* @__PURE__ */ r(I, { className: "w-4.5 h-4.5" }), ...a, children:
|
|
200
|
-
/* @__PURE__ */ r(Q, { ...
|
|
201
|
-
/* @__PURE__ */ r(B, { align: "end", className: w("w-40", a), ...
|
|
197
|
+
}, se = ({ onDelete: o, children: s, ...a }) => /* @__PURE__ */ r(E, { variant: "danger", onClick: () => {
|
|
198
|
+
o();
|
|
199
|
+
}, startIcon: /* @__PURE__ */ r(I, { className: "w-4.5 h-4.5" }), ...a, children: s }), ce = ({ children: o, slotProps: s, className: a, ...n }) => /* @__PURE__ */ N(L, { ...s?.popoverProps ?? {}, children: [
|
|
200
|
+
/* @__PURE__ */ r(Q, { ...s?.triggerProps ?? {}, children: /* @__PURE__ */ r(y, { className: "w-4.5 h-4.5 text-primary" }) }),
|
|
201
|
+
/* @__PURE__ */ r(B, { align: "end", className: w("w-40", a), ...n, children: o })
|
|
202
202
|
] });
|
|
203
203
|
export {
|
|
204
204
|
ee as DataGrid,
|
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, { HTMLAttributes } from \"react\";\r\nimport { AgGridReact, AgGridReactProps } from \"ag-grid-react\";\r\nimport { GridApi, GridReadyEvent, themeQuartz } 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\nconst appTheme = themeQuartz.withParams({\r\n fontFamily: \"DMSans\",\r\n fontSize: \"12px\",\r\n headerFontSize: \"12px\",\r\n headerFontWeight: 700,\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};\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\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 }}\r\n >\r\n {children}\r\n </DataGridContext.Provider>\r\n );\r\n};\r\n\r\ntype DataGridContentProps = AgGridReactProps & {};\r\n\r\nconst DataGridContent: React.FC<DataGridContentProps> = ({\r\n theme: propTheme,\r\n onGridReady,\r\n quickFilterText: quickFilterTextProps,\r\n rowData: rowDataProps,\r\n containerStyle,\r\n ...props\r\n}) => {\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 } = context;\r\n\r\n const theme = appTheme.withParams({\r\n headerHeight: 40,\r\n wrapperBorderRadius: actionbarExists ? \"0px 0px 8px 8px\" : \"8px\",\r\n });\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 return (\r\n <AgGridReact\r\n gridId={gridId}\r\n theme={propTheme ?? theme}\r\n rowData={rowData}\r\n quickFilterText={quickFilterText}\r\n onGridReady={handleGridReady}\r\n containerStyle={{ height: `calc(100% - ${actionbarHeight}px)`, ...containerStyle }}\r\n {...props}\r\n />\r\n );\r\n};\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 \"relative flex items-center p-2 h-12 w-full bg-gray-0 border border-gray-200 border-b-0 -mb-[1px] z-10 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 = {\r\n defaultOpen?: boolean;\r\n};\r\n\r\nconst SearchAction: React.FC<SearchActionProps> = ({ defaultOpen = false }) => {\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=\"max-w-60\">\r\n {isSearchInputOpen || isClosing ? (\r\n <TextField\r\n ref={inputRef}\r\n className={cn(\"relative h-7.5\", isSearchInputOpen && !isClosing ? \"animate-input-open\" : \"\", isClosing && \"animate-input-close\")}\r\n onChange={e => setQuickFilterText(e.target.value)}\r\n value={quickFilterText}\r\n startAdornment={\r\n <IconButton variant=\"toolbar\" className=\"p-0.5 h-6 w-6 border-none mx-1\" onClick={handleClose}>\r\n <Magnifier className=\"w-5 h-5\" />\r\n </IconButton>\r\n }\r\n endAdornment={\r\n quickFilterText && (\r\n <IconButton variant=\"toolbar\" className=\"p-0.5 w-6 h-6 border-none mx-1\" onClick={handleClear}>\r\n <CircleXmark className=\"w-5 h-5\" />\r\n </IconButton>\r\n )\r\n }\r\n />\r\n ) : (\r\n <IconButton variant=\"toolbar\" className=\"p-0.5 w-6 h-6 m-1\" onClick={handleOpen}>\r\n <Magnifier className=\"w-5 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, rowData } = 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 // Pin the selected rows\r\n api.setGridOption(\r\n \"pinnedTopRowData\",\r\n selectedRows.map(row => row.data),\r\n );\r\n\r\n // Get current row data\r\n const allData = api.getRenderedNodes();\r\n // Filter out pinned rows from the main data\r\n const updatedNodes = allData.filter(row => !selectedRows.some(pinnedRow => pinnedRow.id === row.id));\r\n\r\n // Update the grid with the filtered data\r\n api.setGridOption(\r\n \"rowData\",\r\n updatedNodes.map(node => node.data),\r\n );\r\n }\r\n };\r\n\r\n const unfreezeRows = () => {\r\n if (!api) return;\r\n api.setGridOption(\"pinnedTopRowData\", []);\r\n api.setGridOption(\"rowData\", rowData);\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 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=\"w-4.5 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(\"p-0.5 w-6 h-6\", className)} onClick={handlePrint} {...props}>\r\n {children ?? <Print className=\"w-5 h-5\" />}\r\n </IconButton>\r\n );\r\n};\r\n\r\ntype RefreshActionProps = Omit<IconButtonProps, \"onClick\"> & {\r\n refreshRowData: () => void;\r\n};\r\n\r\nconst RefreshAction: React.FC<RefreshActionProps> = ({ className, refreshRowData, 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 refreshRowData();\r\n };\r\n\r\n return (\r\n <IconButton\r\n className={cn(\"p-0.5 w-6 h-6\", loading && \"disabled: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(\"w-4.5 h-4.5\", loading && \"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=\"w-4.5 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=\"w-4.5 h-4.5 text-primary\" />\r\n </PopoverTrigger>\r\n <PopoverContent align=\"end\" className={cn(\"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};\r\n"],"names":["appTheme","themeQuartz","DataGridContext","React","useDataGrid","context","DataGrid","children","gridId","api","setApi","rowData","setRowData","actionbarHeight","setActionbarHeight","quickFilterText","setQuickFilterText","actionbarExists","setActionbarExists","jsx","DataGridContent","propTheme","onGridReady","quickFilterTextProps","rowDataProps","containerStyle","props","theme","handleGridReady","e","AgGridReact","DataGridActionBar","className","ref","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","row","updatedNodes","pinnedRow","node","unfreezeRows","handleFreezing","Button","Snowflake","PrintAction","handlePrint","element","html","printHtml","Print","RefreshAction","refreshRowData","loading","handleRefresh","Refresh","DeleteAction","onDelete","Trashcan","ExtraActions","slotProps","Popover","PopoverTrigger","ElipsisVertical","PopoverContent"],"mappings":";;;;;;;;;;;AAcA,MAAMA,IAAWC,EAAY,WAAW;AAAA,EACtC,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,kBAAkB;AACpB,CAAC,GAgBKC,IAAkBC,EAAM,cAAsC,IAAI,GAElEC,IAAc,MAAM;AAClB,QAAAC,IAAUF,EAAM,WAAWD,CAAe;AAEhD,MAAI,CAACG;AACG,UAAA,IAAI,MAAM,8CAA8C;AAGzD,SAAAA;AACT,GAMMC,KAAoC,CAAC,EAAE,UAAAC,QAAe;AACpD,QAAAC,IAASL,EAAM,MAAM,GACrB,CAACM,GAAKC,CAAM,IAAIP,EAAM,SAAyB,IAAI,GACnD,CAACQ,GAASC,CAAU,IAAIT,EAAM,SAAmC,CAAA,CAAE,GACnE,CAACU,GAAiBC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,EAAG,QAAQF,CAAS,GAAI,GAAGN,GAC/D,UAAAnB,EACH,CAAA;AAAA,GACF;"}
|
|
1
|
+
{"version":3,"file":"datagrid.es.js","sources":["../src/components/data-grid/DataGrid.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport React, { HTMLAttributes } from \"react\";\r\nimport { AgGridReact, AgGridReactProps } from \"ag-grid-react\";\r\nimport { GridApi, GridReadyEvent, themeQuartz } 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\nconst appTheme = themeQuartz.withParams({\r\n fontFamily: \"DMSans\",\r\n fontSize: \"12px\",\r\n headerFontSize: \"12px\",\r\n headerFontWeight: 700,\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};\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\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 }}\r\n >\r\n {children}\r\n </DataGridContext.Provider>\r\n );\r\n};\r\n\r\ntype DataGridContentProps = AgGridReactProps & {};\r\n\r\nconst DataGridContent: React.FC<DataGridContentProps> = ({\r\n theme: propTheme,\r\n onGridReady,\r\n quickFilterText: quickFilterTextProps,\r\n rowData: rowDataProps,\r\n containerStyle,\r\n ...props\r\n}) => {\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 } = context;\r\n\r\n const theme = appTheme.withParams({\r\n headerHeight: 40,\r\n wrapperBorderRadius: actionbarExists ? \"0px 0px 8px 8px\" : \"8px\",\r\n });\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 return (\r\n <AgGridReact\r\n gridId={gridId}\r\n theme={propTheme ?? theme}\r\n rowData={rowData}\r\n quickFilterText={quickFilterText}\r\n onGridReady={handleGridReady}\r\n containerStyle={{ height: `calc(100% - ${actionbarHeight}px)`, ...containerStyle }}\r\n {...props}\r\n />\r\n );\r\n};\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 \"relative flex items-center p-2 h-12 w-full bg-gray-0 border border-gray-200 border-b-0 -mb-[1px] z-10 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(\"max-w-60\", className)} {...props}>\r\n {isSearchInputOpen || isClosing ? (\r\n <TextField\r\n ref={inputRef}\r\n className={cn(\"relative h-7.5\", isSearchInputOpen && !isClosing ? \"animate-input-open\" : \"\", isClosing && \"animate-input-close\")}\r\n onChange={e => setQuickFilterText(e.target.value)}\r\n value={quickFilterText}\r\n startAdornment={\r\n <IconButton variant=\"toolbar\" className=\"p-0.5 h-6 w-6 border-none mx-1\" onClick={handleClose}>\r\n <Magnifier className=\"w-5 h-5\" />\r\n </IconButton>\r\n }\r\n endAdornment={\r\n quickFilterText && (\r\n <IconButton variant=\"toolbar\" className=\"p-0.5 w-6 h-6 border-none mx-1\" onClick={handleClear}>\r\n <CircleXmark className=\"w-5 h-5\" />\r\n </IconButton>\r\n )\r\n }\r\n />\r\n ) : (\r\n <IconButton variant=\"toolbar\" className=\"p-0.5 w-6 h-6 m-1\" onClick={handleOpen}>\r\n <Magnifier className=\"w-5 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, rowData } = 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 // Pin the selected rows\r\n api.setGridOption(\r\n \"pinnedTopRowData\",\r\n selectedRows.map(row => row.data),\r\n );\r\n\r\n // Get current row data\r\n const allData = api.getRenderedNodes();\r\n // Filter out pinned rows from the main data\r\n const updatedNodes = allData.filter(row => !selectedRows.some(pinnedRow => pinnedRow.id === row.id));\r\n\r\n // Update the grid with the filtered data\r\n api.setGridOption(\r\n \"rowData\",\r\n updatedNodes.map(node => node.data),\r\n );\r\n }\r\n };\r\n\r\n const unfreezeRows = () => {\r\n if (!api) return;\r\n api.setGridOption(\"pinnedTopRowData\", []);\r\n api.setGridOption(\"rowData\", rowData);\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 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=\"w-4.5 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(\"p-0.5 w-6 h-6\", className)} onClick={handlePrint} {...props}>\r\n {children ?? <Print className=\"w-5 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(\"p-0.5 w-6 h-6\", loading && \"disabled: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(\"w-4.5 h-4.5\", loading && \"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=\"w-4.5 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=\"w-4.5 h-4.5 text-primary\" />\r\n </PopoverTrigger>\r\n <PopoverContent align=\"end\" className={cn(\"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};\r\n"],"names":["appTheme","themeQuartz","DataGridContext","React","useDataGrid","context","DataGrid","children","gridId","api","setApi","rowData","setRowData","actionbarHeight","setActionbarHeight","quickFilterText","setQuickFilterText","actionbarExists","setActionbarExists","jsx","DataGridContent","propTheme","onGridReady","quickFilterTextProps","rowDataProps","containerStyle","props","theme","handleGridReady","e","AgGridReact","DataGridActionBar","className","ref","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","row","updatedNodes","pinnedRow","node","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":";;;;;;;;;;;AAcA,MAAMA,IAAWC,EAAY,WAAW;AAAA,EACtC,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,kBAAkB;AACpB,CAAC,GAgBKC,IAAkBC,EAAM,cAAsC,IAAI,GAElEC,IAAc,MAAM;AAClB,QAAAC,IAAUF,EAAM,WAAWD,CAAe;AAEhD,MAAI,CAACG;AACG,UAAA,IAAI,MAAM,8CAA8C;AAGzD,SAAAA;AACT,GAMMC,KAAoC,CAAC,EAAE,UAAAC,QAAe;AACpD,QAAAC,IAASL,EAAM,MAAM,GACrB,CAACM,GAAKC,CAAM,IAAIP,EAAM,SAAyB,IAAI,GACnD,CAACQ,GAASC,CAAU,IAAIT,EAAM,SAAmC,CAAA,CAAE,GACnE,CAACU,GAAiBC,CAAkB,IAAIX,EAAM,SAAS,CAAC,GAExD,CAACY,GAAiBC,CAAkB,IAAIb,EAAM,SAAS,EAAE,GACzD,CAACc,GAAiBC,CAAkB,IAAIf,EAAM,SAAS,EAAK;AAEhE,SAAA,gBAAAgB;AAAA,IAACjB,EAAgB;AAAA,IAAhB;AAAA,MACC,OAAO;AAAA,QACL,KAAAO;AAAA,QACA,QAAAC;AAAA,QACA,SAAAC;AAAA,QACA,YAAAC;AAAA,QACA,QAAAJ;AAAA,QACA,iBAAAO;AAAA,QACA,oBAAAC;AAAA,QACA,iBAAAC;AAAA,QACA,oBAAAC;AAAA,QACA,iBAAAL;AAAA,QACA,oBAAAC;AAAA,MACF;A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xD;AAAA,IAAC2B;AAAA,IAAA;AAAA,MACC,WAAWZ,EAAG,iBAAiB0C,KAAW,2BAA2B5C,CAAS;AAAA,MAC9E,SAAQ;AAAA,MACR,SAAS6C;AAAA,MACT,UAAUD;AAAA,MACT,GAAGlD;AAAA,MAEH,UAAAnB,uBAAauE,GAAQ,EAAA,WAAW5C,EAAG,eAAe0C,KAAW,cAAc,EAAG,CAAA;AAAA,IAAA;AAAA,EACjF;AAEJ,GAMMG,KAA4C,CAAC,EAAE,UAAAC,GAAU,UAAAzE,GAAU,GAAGmB,QAMvE,gBAAAP,EAAA+C,GAAA,EAAO,SAAQ,UAAS,SALN,MAAM;AAChB,EAAAc,EAAA;AACX,GAGkD,WAAY,gBAAA7D,EAAA8D,GAAA,EAAS,WAAU,cAAA,CAAc,GAAK,GAAGvD,GAClG,UAAAnB,GACH,GAYE2E,KAA4C,CAAC,EAAE,UAAA3E,GAAU,WAAA4E,GAAW,WAAAnD,GAAW,GAAGN,0BAEnF0D,GAAS,EAAA,GAAID,GAAW,gBAAgB,CACvC,GAAA,UAAA;AAAA,EAAC,gBAAAhE,EAAAkE,GAAA,EAAgB,GAAIF,GAAW,gBAAgB,IAC9C,UAAC,gBAAAhE,EAAAmE,GAAA,EAAgB,WAAU,2BAAA,CAA2B,EACxD,CAAA;AAAA,EACA,gBAAAnE,EAACoE,GAAe,EAAA,OAAM,OAAM,WAAWrD,EAAG,QAAQF,CAAS,GAAI,GAAGN,GAC/D,UAAAnB,EACH,CAAA;AAAA,GACF;"}
|
package/dist/formcombobox.es.js
CHANGED
|
@@ -1,61 +1,63 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { FormField as
|
|
3
|
-
import { Combobox as
|
|
4
|
-
const
|
|
1
|
+
import { jsx as e, jsxs as a } from "react/jsx-runtime";
|
|
2
|
+
import { FormField as I, FormItem as j, FormLabel as v, FormControl as y, FormMessage as L } from "./form.es.js";
|
|
3
|
+
import { Combobox as M } from "./combobox.es.js";
|
|
4
|
+
const q = (s) => {
|
|
5
5
|
const {
|
|
6
|
-
name:
|
|
6
|
+
name: n,
|
|
7
7
|
control: t,
|
|
8
|
-
|
|
8
|
+
clearable: m = !1,
|
|
9
|
+
defaultValue: d,
|
|
9
10
|
disabled: r,
|
|
10
|
-
readOnly:
|
|
11
|
-
rules:
|
|
12
|
-
shouldUnregister:
|
|
13
|
-
label:
|
|
14
|
-
options:
|
|
15
|
-
loading:
|
|
16
|
-
loadingText:
|
|
17
|
-
emptyOptionsText:
|
|
18
|
-
showSearchInput:
|
|
11
|
+
readOnly: i,
|
|
12
|
+
rules: p,
|
|
13
|
+
shouldUnregister: b,
|
|
14
|
+
label: c,
|
|
15
|
+
options: u,
|
|
16
|
+
loading: h,
|
|
17
|
+
loadingText: x,
|
|
18
|
+
emptyOptionsText: g,
|
|
19
|
+
showSearchInput: f,
|
|
19
20
|
placeholder: F,
|
|
20
|
-
slotProps:
|
|
21
|
-
required:
|
|
22
|
-
...
|
|
23
|
-
} =
|
|
24
|
-
return /* @__PURE__ */
|
|
25
|
-
|
|
21
|
+
slotProps: o,
|
|
22
|
+
required: C,
|
|
23
|
+
...P
|
|
24
|
+
} = s;
|
|
25
|
+
return /* @__PURE__ */ e(
|
|
26
|
+
I,
|
|
26
27
|
{
|
|
27
28
|
control: t,
|
|
28
|
-
name:
|
|
29
|
-
defaultValue:
|
|
29
|
+
name: n,
|
|
30
|
+
defaultValue: d,
|
|
30
31
|
disabled: r,
|
|
31
|
-
rules:
|
|
32
|
-
shouldUnregister:
|
|
33
|
-
render: ({ field: l }) => /* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
rules: p,
|
|
33
|
+
shouldUnregister: b,
|
|
34
|
+
render: ({ field: l }) => /* @__PURE__ */ a(j, { ...P, children: [
|
|
35
|
+
/* @__PURE__ */ a(v, { ...o?.formLabelProps ?? {}, children: [
|
|
36
|
+
c,
|
|
37
|
+
C && /* @__PURE__ */ e("span", { className: "text-danger text-sm leading-4", children: "*" })
|
|
37
38
|
] }),
|
|
38
|
-
/* @__PURE__ */
|
|
39
|
-
|
|
39
|
+
/* @__PURE__ */ e(y, { children: /* @__PURE__ */ e(
|
|
40
|
+
M,
|
|
40
41
|
{
|
|
41
|
-
options:
|
|
42
|
+
options: u,
|
|
42
43
|
value: l.value,
|
|
43
44
|
onValueChange: l.onChange,
|
|
44
|
-
loading:
|
|
45
|
-
loadingText:
|
|
46
|
-
emptyOptionsText:
|
|
45
|
+
loading: h,
|
|
46
|
+
loadingText: x,
|
|
47
|
+
emptyOptionsText: g,
|
|
47
48
|
placeholder: F,
|
|
48
|
-
disabled: r ||
|
|
49
|
-
showSearchInput:
|
|
50
|
-
|
|
49
|
+
disabled: r || i,
|
|
50
|
+
showSearchInput: f,
|
|
51
|
+
clearable: m,
|
|
52
|
+
...o?.comboboxProps ?? {}
|
|
51
53
|
}
|
|
52
54
|
) }),
|
|
53
|
-
/* @__PURE__ */
|
|
55
|
+
/* @__PURE__ */ e(L, { ...o?.formMessageProps ?? {} })
|
|
54
56
|
] })
|
|
55
57
|
}
|
|
56
58
|
);
|
|
57
59
|
};
|
|
58
60
|
export {
|
|
59
|
-
|
|
61
|
+
q as FormCombobox
|
|
60
62
|
};
|
|
61
63
|
//# sourceMappingURL=formcombobox.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"formcombobox.es.js","sources":["../src/components/form-combobox/FormCombobox.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport { ControllerProps, FieldPath, FieldValues } from \"react-hook-form\";\r\n\r\nimport { FormControl, FormField, FormItem, FormLabel, FormMessage } from \"../form/Form\";\r\nimport { Combobox } from \"../combobox/Combobox\";\r\n\r\ntype FormComboboxProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = Omit<\r\n ControllerProps<TFieldValues, TName>,\r\n \"render\"\r\n> &\r\n React.ComponentProps<typeof FormItem> & {\r\n label: string;\r\n options: { value: string | number; label: string }[];\r\n loading?: boolean;\r\n loadingText?: string;\r\n emptyOptionsText?: string;\r\n showSearchInput?: boolean;\r\n placeholder?: string;\r\n required?: boolean;\r\n readOnly?: boolean;\r\n slotProps?: {\r\n formLabelProps?: React.HTMLAttributes<HTMLLabelElement> & React.RefAttributes<HTMLLabelElement>;\r\n formMessageProps?: React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>;\r\n comboboxProps?: Omit<\r\n React.ComponentPropsWithoutRef<typeof Combobox>,\r\n \"options\" | \"value\" | \"onValueChange\" | \"loading\" | \"loadingText\" | \"emptyOptionsText\" | \"placeholder\" | \"disabled\" | \"showSearchInput\"\r\n >;\r\n };\r\n };\r\n\r\nconst FormCombobox = <TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(\r\n props: FormComboboxProps<TFieldValues, TName>,\r\n) => {\r\n const {\r\n name,\r\n control,\r\n defaultValue,\r\n disabled,\r\n readOnly,\r\n rules,\r\n shouldUnregister,\r\n label,\r\n options,\r\n loading,\r\n loadingText,\r\n emptyOptionsText,\r\n showSearchInput,\r\n placeholder,\r\n slotProps,\r\n required,\r\n ...formItemProps\r\n } = props;\r\n\r\n return (\r\n <FormField\r\n control={control}\r\n name={name}\r\n defaultValue={defaultValue}\r\n disabled={disabled}\r\n rules={rules}\r\n shouldUnregister={shouldUnregister}\r\n render={({ field }) => {\r\n return (\r\n <FormItem {...formItemProps}>\r\n <FormLabel {...(slotProps?.formLabelProps ?? {})}>\r\n {label}\r\n {required && <span className=\"text-danger text-sm leading-4\">*</span>}\r\n </FormLabel>\r\n <FormControl>\r\n <Combobox\r\n options={options}\r\n value={field.value}\r\n onValueChange={field.onChange}\r\n loading={loading}\r\n loadingText={loadingText}\r\n emptyOptionsText={emptyOptionsText}\r\n placeholder={placeholder}\r\n disabled={disabled || readOnly}\r\n showSearchInput={showSearchInput}\r\n {...(slotProps?.comboboxProps ?? {})}\r\n />\r\n </FormControl>\r\n\r\n <FormMessage {...(slotProps?.formMessageProps ?? {})} />\r\n </FormItem>\r\n );\r\n }}\r\n />\r\n );\r\n};\r\nexport { FormCombobox, type FormComboboxProps };\r\n"],"names":["FormCombobox","props","name","control","defaultValue","disabled","readOnly","rules","shouldUnregister","label","options","loading","loadingText","emptyOptionsText","showSearchInput","placeholder","slotProps","required","formItemProps","jsx","FormField","field","jsxs","FormItem","FormLabel","FormControl","Combobox","FormMessage"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"formcombobox.es.js","sources":["../src/components/form-combobox/FormCombobox.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport { ControllerProps, FieldPath, FieldValues } from \"react-hook-form\";\r\n\r\nimport { FormControl, FormField, FormItem, FormLabel, FormMessage } from \"../form/Form\";\r\nimport { Combobox } from \"../combobox/Combobox\";\r\n\r\ntype FormComboboxProps<TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = Omit<\r\n ControllerProps<TFieldValues, TName>,\r\n \"render\"\r\n> &\r\n React.ComponentProps<typeof FormItem> & {\r\n label: string;\r\n options: { value: string | number; label: string }[];\r\n loading?: boolean;\r\n loadingText?: string;\r\n emptyOptionsText?: string;\r\n showSearchInput?: boolean;\r\n clearable?: boolean;\r\n placeholder?: string;\r\n required?: boolean;\r\n readOnly?: boolean;\r\n slotProps?: {\r\n formLabelProps?: React.HTMLAttributes<HTMLLabelElement> & React.RefAttributes<HTMLLabelElement>;\r\n formMessageProps?: React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>;\r\n comboboxProps?: Omit<\r\n React.ComponentPropsWithoutRef<typeof Combobox>,\r\n \"options\" | \"value\" | \"onValueChange\" | \"loading\" | \"loadingText\" | \"emptyOptionsText\" | \"placeholder\" | \"disabled\" | \"showSearchInput\"\r\n >;\r\n };\r\n };\r\n\r\nconst FormCombobox = <TFieldValues extends FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(\r\n props: FormComboboxProps<TFieldValues, TName>,\r\n) => {\r\n const {\r\n name,\r\n control,\r\n clearable = false,\r\n defaultValue,\r\n disabled,\r\n readOnly,\r\n rules,\r\n shouldUnregister,\r\n label,\r\n options,\r\n loading,\r\n loadingText,\r\n emptyOptionsText,\r\n showSearchInput,\r\n placeholder,\r\n slotProps,\r\n required,\r\n ...formItemProps\r\n } = props;\r\n\r\n return (\r\n <FormField\r\n control={control}\r\n name={name}\r\n defaultValue={defaultValue}\r\n disabled={disabled}\r\n rules={rules}\r\n shouldUnregister={shouldUnregister}\r\n render={({ field }) => {\r\n return (\r\n <FormItem {...formItemProps}>\r\n <FormLabel {...(slotProps?.formLabelProps ?? {})}>\r\n {label}\r\n {required && <span className=\"text-danger text-sm leading-4\">*</span>}\r\n </FormLabel>\r\n <FormControl>\r\n <Combobox\r\n options={options}\r\n value={field.value}\r\n onValueChange={field.onChange}\r\n loading={loading}\r\n loadingText={loadingText}\r\n emptyOptionsText={emptyOptionsText}\r\n placeholder={placeholder}\r\n disabled={disabled || readOnly}\r\n showSearchInput={showSearchInput}\r\n clearable={clearable}\r\n {...(slotProps?.comboboxProps ?? {})}\r\n />\r\n </FormControl>\r\n\r\n <FormMessage {...(slotProps?.formMessageProps ?? {})} />\r\n </FormItem>\r\n );\r\n }}\r\n />\r\n );\r\n};\r\nexport { FormCombobox, type FormComboboxProps };\r\n"],"names":["FormCombobox","props","name","control","clearable","defaultValue","disabled","readOnly","rules","shouldUnregister","label","options","loading","loadingText","emptyOptionsText","showSearchInput","placeholder","slotProps","required","formItemProps","jsx","FormField","field","jsxs","FormItem","FormLabel","FormControl","Combobox","FormMessage"],"mappings":";;;AAgCM,MAAAA,IAAe,CACnBC,MACG;AACG,QAAA;AAAA,IACJ,MAAAC;AAAA,IACA,SAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,cAAAC;AAAA,IACA,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,k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