qaema-ui 0.0.23 → 0.0.25
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/assets/svg/RiyalGreen.svg.js +4 -0
- package/dist/assets/svg/RiyalGrey.svg.js +4 -0
- package/dist/components/DropDown.d.ts +1 -0
- package/dist/components/DropDown.js +40 -38
- package/dist/components/DropDownWithTable/DropDownWithTable.d.ts +3 -0
- package/dist/components/DropDownWithTable/DropDownWithTable.js +184 -0
- package/dist/components/DropDownWithTable/DropDownWithTable.types.d.ts +28 -0
- package/dist/components/DropDownWithTable/Table/Table.d.ts +3 -0
- package/dist/components/DropDownWithTable/Table/Table.js +169 -0
- package/dist/components/DropDownWithTable/Table/Table.styles.d.ts +58 -0
- package/dist/components/DropDownWithTable/Table/Table.styles.js +285 -0
- package/dist/components/DropDownWithTable/Table/Table.types.d.ts +73 -0
- package/dist/components/DropDownWithTable/Table/components/CellComponents.d.ts +116 -0
- package/dist/components/DropDownWithTable/Table/components/CellComponents.js +118 -0
- package/dist/components/DropDownWithTable/Table/components/TableHead.d.ts +14 -0
- package/dist/components/DropDownWithTable/Table/components/TableHead.js +58 -0
- package/dist/components/NextActionBox.d.ts +13 -0
- package/dist/components/TotalsSummary.d.ts +13 -0
- package/dist/components/TotalsSummary.js +94 -0
- package/dist/components/index.d.ts +6 -0
- package/dist/index.js +141 -137
- package/dist/node_modules/react-bootstrap/esm/Spinner.js +26 -0
- package/dist/styles/Dropdown.styles.js +5 -5
- package/package.json +1 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const e = "data:image/svg+xml,%3csvg%20width='18'%20height='20'%20viewBox='0%200%2018%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_7331_6281)'%3e%3cpath%20d='M11.2023%2017.7177C10.8811%2018.4258%2010.6687%2019.1942%2010.5874%2020L17.3848%2018.5635C17.706%2017.8556%2017.9181%2017.0871%2017.9996%2016.2812L11.2023%2017.7177Z'%20fill='%231DBA63'/%3e%3cpath%20d='M17.3851%2014.2599C17.7063%2013.552%2017.9187%2012.7835%2018%2011.9777L12.7051%2013.0972V10.945L17.385%209.9563C17.7062%209.2484%2017.9185%208.47985%2017.9998%207.67405L12.7049%208.79265V1.0527C11.8936%201.50558%2011.173%202.10842%2010.5873%202.81951V9.24028L8.46968%209.68776V0C7.65833%200.452726%206.93778%201.05572%206.35206%201.76681V10.1351L1.61387%2011.136C1.29267%2011.8439%201.08019%2012.6125%200.998683%2013.4183L6.35206%2012.2873V14.9976L0.61487%2016.2096C0.293664%2016.9175%200.0813422%2017.6861%200%2018.4919L6.00523%2017.2232C6.49408%2017.1221%206.91425%2016.8347%207.18741%2016.4393L8.28874%2014.8161V14.8158C8.40306%2014.6478%208.46968%2014.4454%208.46968%2014.2273V11.8398L10.5873%2011.3923V15.6967L17.385%2014.2596L17.3851%2014.2599Z'%20fill='%231DBA63'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_7331_6281'%3e%3crect%20width='18'%20height='20'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";
|
|
2
|
+
export {
|
|
3
|
+
e as default
|
|
4
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const e = "data:image/svg+xml,%3csvg%20width='18'%20height='21'%20viewBox='0%200%2018%2021'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_7331_6256)'%3e%3cpath%20d='M11.2023%2018.7177C10.8811%2019.4258%2010.6687%2020.1942%2010.5874%2021L17.3848%2019.5635C17.706%2018.8556%2017.9181%2018.0871%2017.9996%2017.2812L11.2023%2018.7177Z'%20fill='%236D798A'/%3e%3cpath%20d='M17.3851%2015.2599C17.7063%2014.552%2017.9187%2013.7835%2018%2012.9777L12.7051%2014.0972V11.945L17.385%2010.9563C17.7062%2010.2484%2017.9185%209.47985%2017.9998%208.67405L12.7049%209.79265V2.0527C11.8936%202.50558%2011.173%203.10842%2010.5873%203.81951V10.2403L8.46968%2010.6878V1C7.65833%201.45273%206.93778%202.05572%206.35206%202.76681V11.1351L1.61387%2012.136C1.29267%2012.8439%201.08019%2013.6125%200.998683%2014.4183L6.35206%2013.2873V15.9976L0.61487%2017.2096C0.293664%2017.9175%200.0813422%2018.6861%200%2019.4919L6.00523%2018.2232C6.49408%2018.1221%206.91425%2017.8347%207.18741%2017.4393L8.28874%2015.8161V15.8158C8.40306%2015.6478%208.46968%2015.4454%208.46968%2015.2273V12.8398L10.5873%2012.3923V16.6967L17.385%2015.2596L17.3851%2015.2599Z'%20fill='%236D798A'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_7331_6256'%3e%3crect%20width='18'%20height='20'%20fill='white'%20transform='translate(0%201)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e";
|
|
2
|
+
export {
|
|
3
|
+
e as default
|
|
4
|
+
};
|
|
@@ -26,6 +26,7 @@ export type DropDownProps = {
|
|
|
26
26
|
isInteractive?: boolean;
|
|
27
27
|
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;
|
|
28
28
|
variant?: 'light-primary' | 'default';
|
|
29
|
+
endIcon?: React.ReactNode;
|
|
29
30
|
};
|
|
30
31
|
declare const DropDown: React.FC<DropDownProps>;
|
|
31
32
|
export default DropDown;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { j as r } from "../_virtual/jsx-runtime.js";
|
|
2
|
-
import { useRef as g, useState as w, useCallback as
|
|
3
|
-
import { FaTimes as L, FaAngleDown as
|
|
4
|
-
import { ImCheckboxChecked as
|
|
5
|
-
import { useTheme as
|
|
6
|
-
import
|
|
7
|
-
import { useQaemaCoreTranslation as
|
|
8
|
-
import { StyledDropDownContainer as
|
|
9
|
-
import { HelperTextWrapper as
|
|
10
|
-
import
|
|
11
|
-
import
|
|
2
|
+
import { useRef as g, useState as w, useCallback as _, useEffect as C } from "react";
|
|
3
|
+
import { FaTimes as L, FaAngleDown as ee } from "../node_modules/react-icons/fa/index.js";
|
|
4
|
+
import { ImCheckboxChecked as re, ImCheckboxUnchecked as ne } from "../node_modules/react-icons/im/index.js";
|
|
5
|
+
import { useTheme as le } from "styled-components";
|
|
6
|
+
import te from "../hooks/useZIndex.js";
|
|
7
|
+
import { useQaemaCoreTranslation as ae } from "../i18n/i18n.js";
|
|
8
|
+
import { StyledDropDownContainer as se, StyledlabelContainer as oe, StyledDropDown as ce, StyledDropDownToggle as ue, StyledDropDownTitle as de, IconsContainer as ie, StyledDropDownMenu as fe, SearchContainer as he, StyledOptionsContainer as ve, StyledDropItem as W, SelectedTagsContainer as xe, SelectedTag as je } from "../styles/Dropdown.styles.js";
|
|
9
|
+
import { HelperTextWrapper as pe } from "./PhoneInputField.js";
|
|
10
|
+
import Se from "./SearchBar.js";
|
|
11
|
+
import me from "./Spinner.js";
|
|
12
12
|
import z from "./Typography.js";
|
|
13
|
-
const
|
|
13
|
+
const Le = (f) => {
|
|
14
14
|
const {
|
|
15
15
|
label: b,
|
|
16
16
|
options: m,
|
|
@@ -31,25 +31,26 @@ const Ee = (f) => {
|
|
|
31
31
|
multiSelect: c = !1,
|
|
32
32
|
isLoading: B = !1,
|
|
33
33
|
currentSelectedOptions: y = [],
|
|
34
|
-
isInteractive: I = !1
|
|
35
|
-
|
|
34
|
+
isInteractive: I = !1,
|
|
35
|
+
endIcon: Q
|
|
36
|
+
} = f, u = g(null), p = g(null), d = le(), { t: T } = ae(), U = g(null), [a, v] = w(y), [i, k] = w(!1), [Z, q] = w(0), O = N ?? /* @__PURE__ */ r.jsx(r.Fragment, {}), G = te("dropdown"), S = _(() => {
|
|
36
37
|
var e, n;
|
|
37
|
-
(e = u == null ? void 0 : u.current) != null && e.offsetWidth && p.current &&
|
|
38
|
+
(e = u == null ? void 0 : u.current) != null && e.offsetWidth && p.current && q(((n = u.current) == null ? void 0 : n.offsetWidth) / 16);
|
|
38
39
|
}, []);
|
|
39
40
|
C(() => (i && (S(), window.addEventListener("resize", S)), () => window.removeEventListener("resize", S)), [i, S]), C(() => {
|
|
40
41
|
v(y);
|
|
41
42
|
}, [y]);
|
|
42
|
-
const
|
|
43
|
+
const J = (e, n, l, t = "default") => l ? d.colors.grey.n400 : e ? d.colors.state.error.n450 : n ? d.colors.primary.dark.n600 : t === "light-primary" ? d.colors.primary.purple.n450 : d.colors.grey.n300, $ = (e) => a.some((n) => typeof n.value == "object" && typeof e.value == "object" ? n.value[h] === e.value[h] : n.value === e.value), K = (e) => {
|
|
43
44
|
if (c) {
|
|
44
45
|
const n = $(e);
|
|
45
46
|
let l;
|
|
46
47
|
n ? l = a.filter((t) => typeof t.value == "object" && typeof e.value == "object" ? t.value[h] !== e.value[h] : t.value !== e.value) : l = [...a, e], v(l), j(l.map((t) => t.value));
|
|
47
48
|
} else
|
|
48
49
|
v([e]), j(e.value);
|
|
49
|
-
},
|
|
50
|
+
}, V = (e) => {
|
|
50
51
|
const n = a.filter((l) => typeof l.value == "object" && typeof e.value == "object" ? l.value[h] !== e.value[h] : l.value !== e.value);
|
|
51
52
|
v(n), j(n.map((l) => l.value));
|
|
52
|
-
},
|
|
53
|
+
}, X = () => {
|
|
53
54
|
var e;
|
|
54
55
|
return a.length === 0 ? F : c ? `${a.length} ${T("SELECTED")}` : (e = a[0]) == null ? void 0 : e.label;
|
|
55
56
|
};
|
|
@@ -61,14 +62,14 @@ const Ee = (f) => {
|
|
|
61
62
|
document.removeEventListener("mousedown", e);
|
|
62
63
|
};
|
|
63
64
|
}, [i, o]);
|
|
64
|
-
const
|
|
65
|
-
return /* @__PURE__ */ r.jsxs(
|
|
66
|
-
b && /* @__PURE__ */ r.jsxs(
|
|
65
|
+
const Y = () => I || (s == null ? void 0 : s.length) === 0 ? null : /* @__PURE__ */ r.jsx(pe, { error: s, children: s });
|
|
66
|
+
return /* @__PURE__ */ r.jsxs(se, { children: [
|
|
67
|
+
b && /* @__PURE__ */ r.jsxs(oe, { children: [
|
|
67
68
|
/* @__PURE__ */ r.jsx("label", { children: b }),
|
|
68
69
|
H && /* @__PURE__ */ r.jsx("span", { children: T("OPTIONAL") })
|
|
69
70
|
] }),
|
|
70
71
|
/* @__PURE__ */ r.jsxs(
|
|
71
|
-
|
|
72
|
+
ce,
|
|
72
73
|
{
|
|
73
74
|
show: i,
|
|
74
75
|
onToggle: () => {
|
|
@@ -77,7 +78,7 @@ const Ee = (f) => {
|
|
|
77
78
|
placement: "bottom-start",
|
|
78
79
|
autoClose: c ? "outside" : !0,
|
|
79
80
|
children: [
|
|
80
|
-
/* @__PURE__ */ r.jsx(
|
|
81
|
+
/* @__PURE__ */ r.jsx(ue, { disabled: x, ref: u, $valid: !s, $variant: f.variant || "default", children: /* @__PURE__ */ r.jsx(de, { $valid: !s, $isInteractive: I, children: /* @__PURE__ */ r.jsxs("div", { className: "title-container", children: [
|
|
81
82
|
/* @__PURE__ */ r.jsxs("div", { className: "heading-container", children: [
|
|
82
83
|
M && typeof O == "function" && /* @__PURE__ */ r.jsx(O, {}),
|
|
83
84
|
/* @__PURE__ */ r.jsx(
|
|
@@ -85,12 +86,13 @@ const Ee = (f) => {
|
|
|
85
86
|
{
|
|
86
87
|
component: "span",
|
|
87
88
|
variant: "mdText",
|
|
88
|
-
color:
|
|
89
|
-
children:
|
|
89
|
+
color: J(s, a.length > 0, x, f.variant || "default"),
|
|
90
|
+
children: X()
|
|
90
91
|
}
|
|
91
92
|
)
|
|
92
93
|
] }),
|
|
93
|
-
/* @__PURE__ */ r.jsxs(
|
|
94
|
+
/* @__PURE__ */ r.jsxs(ie, { children: [
|
|
95
|
+
Q,
|
|
94
96
|
!c && a.length > 0 && !x && /* @__PURE__ */ r.jsx(
|
|
95
97
|
L,
|
|
96
98
|
{
|
|
@@ -100,15 +102,15 @@ const Ee = (f) => {
|
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
),
|
|
103
|
-
!x && /* @__PURE__ */ r.jsx(
|
|
105
|
+
!x && /* @__PURE__ */ r.jsx(ee, {})
|
|
104
106
|
] })
|
|
105
107
|
] }) }) }),
|
|
106
|
-
i && /* @__PURE__ */ r.jsxs(
|
|
107
|
-
P && /* @__PURE__ */ r.jsx(
|
|
108
|
+
i && /* @__PURE__ */ r.jsxs(fe, { ref: p, $menuWidth: Z, $zIndex: G, children: [
|
|
109
|
+
P && /* @__PURE__ */ r.jsx(he, { children: /* @__PURE__ */ r.jsx(Se, { placeholder: A, onSearch: R }) }),
|
|
108
110
|
/* @__PURE__ */ r.jsxs(
|
|
109
|
-
|
|
111
|
+
ve,
|
|
110
112
|
{
|
|
111
|
-
ref:
|
|
113
|
+
ref: U,
|
|
112
114
|
onScroll: (e) => {
|
|
113
115
|
var n;
|
|
114
116
|
(n = f.onScroll) == null || n.call(f, e);
|
|
@@ -120,10 +122,10 @@ const Ee = (f) => {
|
|
|
120
122
|
return /* @__PURE__ */ r.jsxs(
|
|
121
123
|
W,
|
|
122
124
|
{
|
|
123
|
-
onClick: () =>
|
|
125
|
+
onClick: () => K(e),
|
|
124
126
|
$selected: n,
|
|
125
127
|
children: [
|
|
126
|
-
c && (n ? /* @__PURE__ */ r.jsx(
|
|
128
|
+
c && (n ? /* @__PURE__ */ r.jsx(re, { color: d.colors.primary.purple.n500 }) : /* @__PURE__ */ r.jsx(ne, { color: d.colors.primary.purple.n450 })),
|
|
127
129
|
" ",
|
|
128
130
|
/* @__PURE__ */ r.jsx(z, { variant: "smText", children: e == null ? void 0 : e.label })
|
|
129
131
|
]
|
|
@@ -131,7 +133,7 @@ const Ee = (f) => {
|
|
|
131
133
|
typeof (e == null ? void 0 : e.value) == "object" && (e == null ? void 0 : e.value) !== null ? (t = (l = e == null ? void 0 : e.value) == null ? void 0 : l[D]) == null ? void 0 : t.toString() : (E = e == null ? void 0 : e.value) == null ? void 0 : E.toString()
|
|
132
134
|
);
|
|
133
135
|
}),
|
|
134
|
-
B && /* @__PURE__ */ r.jsx(W, { $selected: !1, children: /* @__PURE__ */ r.jsx(
|
|
136
|
+
B && /* @__PURE__ */ r.jsx(W, { $selected: !1, children: /* @__PURE__ */ r.jsx(me, {}) })
|
|
135
137
|
]
|
|
136
138
|
}
|
|
137
139
|
)
|
|
@@ -139,22 +141,22 @@ const Ee = (f) => {
|
|
|
139
141
|
]
|
|
140
142
|
}
|
|
141
143
|
),
|
|
142
|
-
c && a.length > 0 && /* @__PURE__ */ r.jsx(
|
|
144
|
+
c && a.length > 0 && /* @__PURE__ */ r.jsx(xe, { children: a.map((e) => {
|
|
143
145
|
var n, l, t;
|
|
144
146
|
return /* @__PURE__ */ r.jsxs(
|
|
145
|
-
|
|
147
|
+
je,
|
|
146
148
|
{
|
|
147
149
|
children: [
|
|
148
150
|
e.label,
|
|
149
|
-
/* @__PURE__ */ r.jsx(L, { onClick: () =>
|
|
151
|
+
/* @__PURE__ */ r.jsx(L, { onClick: () => V(e) })
|
|
150
152
|
]
|
|
151
153
|
},
|
|
152
154
|
typeof (e == null ? void 0 : e.value) == "object" ? (l = (n = e == null ? void 0 : e.value) == null ? void 0 : n[D]) == null ? void 0 : l.toString() : (t = e == null ? void 0 : e.value) == null ? void 0 : t.toString()
|
|
153
155
|
);
|
|
154
156
|
}) }),
|
|
155
|
-
|
|
157
|
+
Y()
|
|
156
158
|
] });
|
|
157
159
|
};
|
|
158
160
|
export {
|
|
159
|
-
|
|
161
|
+
Le as default
|
|
160
162
|
};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { j as t } from "../../_virtual/jsx-runtime.js";
|
|
2
|
+
import { useRef as g, useState as v, useCallback as ne, useEffect as D } from "react";
|
|
3
|
+
import { createPortal as re } from "react-dom";
|
|
4
|
+
import { FaTimes as k, FaAngleDown as oe } from "../../node_modules/react-icons/fa/index.js";
|
|
5
|
+
import { useTheme as le } from "styled-components";
|
|
6
|
+
import { HelperTextWrapper as ie } from "../PhoneInputField.js";
|
|
7
|
+
import se from "../SearchBar.js";
|
|
8
|
+
import ae from "../Typography.js";
|
|
9
|
+
import ce from "../../hooks/useZIndex.js";
|
|
10
|
+
import { useQaemaCoreTranslation as de } from "../../i18n/i18n.js";
|
|
11
|
+
import { StyledDropDownContainer as ue, StyledlabelContainer as fe, StyledDropDown as me, StyledDropDownToggle as he, StyledDropDownTitle as pe, IconsContainer as xe, StyledDropDownMenu as Se, SearchContainer as je, StyledOptionsContainer as we, StyledDropItem as ye, SelectedTagsContainer as ge, SelectedTag as ve } from "../../styles/Dropdown.styles.js";
|
|
12
|
+
import Ce from "./Table/Table.js";
|
|
13
|
+
import be from "../../node_modules/react-bootstrap/esm/Spinner.js";
|
|
14
|
+
const He = (d) => {
|
|
15
|
+
const {
|
|
16
|
+
label: T,
|
|
17
|
+
options: P,
|
|
18
|
+
placeholder: R = "Select Something",
|
|
19
|
+
optional: W = !1,
|
|
20
|
+
error: s = "",
|
|
21
|
+
disabled: S = !1,
|
|
22
|
+
selectIdentifier: j,
|
|
23
|
+
keyIdentifier: r = "id",
|
|
24
|
+
selectCallBack: w,
|
|
25
|
+
showLeadIcon: z,
|
|
26
|
+
icon: F,
|
|
27
|
+
allowSearch: H,
|
|
28
|
+
searchHandler: M,
|
|
29
|
+
searchPlaceholder: B,
|
|
30
|
+
onToggle: i,
|
|
31
|
+
multiSelect: f = !1,
|
|
32
|
+
isLoading: N = !1,
|
|
33
|
+
currentSelectedOptions: h = [],
|
|
34
|
+
isInteractive: I = !1,
|
|
35
|
+
//Table related props
|
|
36
|
+
columns: A,
|
|
37
|
+
isTableHeadVisible: V = !1,
|
|
38
|
+
getDisplayValue: y,
|
|
39
|
+
isRowDisabled: Q
|
|
40
|
+
} = d, p = le(), { t: E } = de(), C = g(null), a = g(null), X = g(null), Y = g(d.currentSelectedOptions !== void 0), [u, b] = v(!1), [Z, q] = v(0), [L, G] = v({ top: 0, left: 0 }), [l, x] = v(h), $ = F ?? /* @__PURE__ */ t.jsx(t.Fragment, {}), J = ce("dropdown"), m = ne(() => {
|
|
41
|
+
if (a != null && a.current) {
|
|
42
|
+
const e = a.current.getBoundingClientRect();
|
|
43
|
+
q(a.current.offsetWidth / 16), G({
|
|
44
|
+
top: e.bottom + window.scrollY,
|
|
45
|
+
left: e.left + window.scrollX
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}, []);
|
|
49
|
+
D(() => (u && (m(), window.addEventListener("resize", m), window.addEventListener("scroll", m, !0)), () => {
|
|
50
|
+
window.removeEventListener("resize", m), window.removeEventListener("scroll", m, !0);
|
|
51
|
+
}), [u, m]), D(() => {
|
|
52
|
+
if (!Y.current) return;
|
|
53
|
+
(h.length !== l.length || h.some((n, o) => {
|
|
54
|
+
var c;
|
|
55
|
+
return n[r] !== ((c = l[o]) == null ? void 0 : c[r]);
|
|
56
|
+
})) && x(h);
|
|
57
|
+
}, [h]);
|
|
58
|
+
const K = (e, n, o, c = "default") => o ? p.colors.grey.n400 : e ? p.colors.state.error.n450 : n ? p.colors.primary.dark.n600 : c === "light-primary" ? p.colors.primary.purple.n450 : p.colors.grey.n300, O = (e) => l.some((n) => typeof n == "object" && typeof e == "object" ? n[r] === e[r] : n.value === e.value), U = (e) => {
|
|
59
|
+
if (f) {
|
|
60
|
+
const n = O(e);
|
|
61
|
+
let o;
|
|
62
|
+
n ? o = l.filter((c) => typeof c == "object" && typeof e == "object" ? c[r] !== e[r] : c.value !== e.value) : o = [...l, e], x(o), w(o);
|
|
63
|
+
} else
|
|
64
|
+
x([e]), w(e), b(!1), i == null || i(!1);
|
|
65
|
+
}, _ = (e) => {
|
|
66
|
+
const n = l.filter((o) => typeof o == "object" && typeof e == "object" ? o[r] !== e[r] : o.value !== e.value);
|
|
67
|
+
x(n), w(n);
|
|
68
|
+
}, ee = (e) => {
|
|
69
|
+
if (e.length === 0) return R;
|
|
70
|
+
if (!f) {
|
|
71
|
+
const n = e[0];
|
|
72
|
+
if (y)
|
|
73
|
+
return y(n);
|
|
74
|
+
if (j)
|
|
75
|
+
return String(n == null ? void 0 : n[j]);
|
|
76
|
+
if (r)
|
|
77
|
+
return String(n == null ? void 0 : n[r]);
|
|
78
|
+
}
|
|
79
|
+
return `${e.length} ${E("SELECTED")}`;
|
|
80
|
+
};
|
|
81
|
+
D(() => {
|
|
82
|
+
const e = (n) => {
|
|
83
|
+
C.current && a.current && !C.current.contains(n.target) && !a.current.contains(n.target) && (b(!1), i == null || i(!1));
|
|
84
|
+
};
|
|
85
|
+
return u && document.addEventListener("mousedown", e), () => {
|
|
86
|
+
document.removeEventListener("mousedown", e);
|
|
87
|
+
};
|
|
88
|
+
}, [u, i]);
|
|
89
|
+
const te = () => I || (s == null ? void 0 : s.length) === 0 ? null : /* @__PURE__ */ t.jsx(ie, { error: s, children: s });
|
|
90
|
+
return /* @__PURE__ */ t.jsxs(ue, { children: [
|
|
91
|
+
T && /* @__PURE__ */ t.jsxs(fe, { children: [
|
|
92
|
+
/* @__PURE__ */ t.jsx("label", { children: T }),
|
|
93
|
+
W && /* @__PURE__ */ t.jsx("span", { children: E("OPTIONAL") })
|
|
94
|
+
] }),
|
|
95
|
+
/* @__PURE__ */ t.jsxs(
|
|
96
|
+
me,
|
|
97
|
+
{
|
|
98
|
+
show: u,
|
|
99
|
+
onToggle: () => {
|
|
100
|
+
i == null || i(!u), b((e) => !e);
|
|
101
|
+
},
|
|
102
|
+
placement: "bottom-start",
|
|
103
|
+
autoClose: f ? "outside" : !0,
|
|
104
|
+
children: [
|
|
105
|
+
/* @__PURE__ */ t.jsx(he, { disabled: S, ref: a, $valid: !s, $variant: d.variant || "default", children: /* @__PURE__ */ t.jsx(pe, { $valid: !s, $isInteractive: I, children: /* @__PURE__ */ t.jsxs("div", { className: "title-container", children: [
|
|
106
|
+
/* @__PURE__ */ t.jsxs("div", { className: "heading-container", children: [
|
|
107
|
+
z && typeof $ == "function" && /* @__PURE__ */ t.jsx($, {}),
|
|
108
|
+
/* @__PURE__ */ t.jsx(
|
|
109
|
+
ae,
|
|
110
|
+
{
|
|
111
|
+
component: "span",
|
|
112
|
+
variant: "mdText",
|
|
113
|
+
color: K(s, l.length > 0, S, d.variant || "default"),
|
|
114
|
+
children: ee(l)
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
] }),
|
|
118
|
+
/* @__PURE__ */ t.jsxs(xe, { children: [
|
|
119
|
+
!f && l.length > 0 && !S && /* @__PURE__ */ t.jsx(
|
|
120
|
+
k,
|
|
121
|
+
{
|
|
122
|
+
style: { cursor: "pointer", marginLeft: "0.5rem" },
|
|
123
|
+
onClick: (e) => {
|
|
124
|
+
e.stopPropagation(), x([]), w(f ? [] : null);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
!S && /* @__PURE__ */ t.jsx(oe, {})
|
|
129
|
+
] })
|
|
130
|
+
] }) }) }),
|
|
131
|
+
u && re(
|
|
132
|
+
/* @__PURE__ */ t.jsxs(
|
|
133
|
+
Se,
|
|
134
|
+
{
|
|
135
|
+
ref: C,
|
|
136
|
+
$menuWidth: Z,
|
|
137
|
+
$zIndex: J,
|
|
138
|
+
style: {
|
|
139
|
+
position: "fixed",
|
|
140
|
+
top: `${L.top}px`,
|
|
141
|
+
left: `${L.left}px`
|
|
142
|
+
},
|
|
143
|
+
children: [
|
|
144
|
+
H && /* @__PURE__ */ t.jsx(je, { children: /* @__PURE__ */ t.jsx(se, { placeholder: B, onSearch: M }) }),
|
|
145
|
+
/* @__PURE__ */ t.jsx(
|
|
146
|
+
we,
|
|
147
|
+
{
|
|
148
|
+
ref: X,
|
|
149
|
+
onScroll: (e) => {
|
|
150
|
+
var n;
|
|
151
|
+
(n = d.onScroll) == null || n.call(d, e);
|
|
152
|
+
},
|
|
153
|
+
children: N ? /* @__PURE__ */ t.jsx(ye, { $selected: !1, children: /* @__PURE__ */ t.jsx(be, {}) }) : /* @__PURE__ */ t.jsx(
|
|
154
|
+
Ce,
|
|
155
|
+
{
|
|
156
|
+
keyField: r,
|
|
157
|
+
data: P,
|
|
158
|
+
columns: A,
|
|
159
|
+
onRowClick: (e) => U(e),
|
|
160
|
+
isRowSelected: (e) => O(e),
|
|
161
|
+
isTableHeadVisible: V,
|
|
162
|
+
isRowDisabled: Q
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
)
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
),
|
|
170
|
+
document.body
|
|
171
|
+
)
|
|
172
|
+
]
|
|
173
|
+
}
|
|
174
|
+
),
|
|
175
|
+
f && l.length > 0 && /* @__PURE__ */ t.jsx(ge, { children: l.map((e) => /* @__PURE__ */ t.jsxs(ve, { children: [
|
|
176
|
+
y ? y(e) : String(j ? e[j] : e[r]),
|
|
177
|
+
/* @__PURE__ */ t.jsx(k, { onClick: () => _(e) })
|
|
178
|
+
] }, String(e[r]))) }),
|
|
179
|
+
te()
|
|
180
|
+
] });
|
|
181
|
+
};
|
|
182
|
+
export {
|
|
183
|
+
He as default
|
|
184
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TableColumn } from './Table/Table.types';
|
|
2
|
+
export interface DropDownWithTableProps<T extends Record<string, unknown>> {
|
|
3
|
+
label?: string;
|
|
4
|
+
options: T[];
|
|
5
|
+
placeholder: string;
|
|
6
|
+
optional?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
error?: string;
|
|
9
|
+
selectIdentifier?: string;
|
|
10
|
+
keyIdentifier?: string;
|
|
11
|
+
showLeadIcon: boolean;
|
|
12
|
+
icon?: React.FC;
|
|
13
|
+
selectCallBack: (value: T | T[] | null) => void;
|
|
14
|
+
allowSearch: boolean;
|
|
15
|
+
searchPlaceholder?: string;
|
|
16
|
+
searchHandler?: (value: string) => void;
|
|
17
|
+
onToggle?: (show: boolean) => void;
|
|
18
|
+
multiSelect?: boolean;
|
|
19
|
+
isLoading?: boolean;
|
|
20
|
+
currentSelectedOptions?: Array<T>;
|
|
21
|
+
isInteractive?: boolean;
|
|
22
|
+
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;
|
|
23
|
+
variant?: 'light-primary' | 'default';
|
|
24
|
+
columns: TableColumn<T>[];
|
|
25
|
+
isTableHeadVisible?: boolean;
|
|
26
|
+
getDisplayValue?: (option: T) => string;
|
|
27
|
+
isRowDisabled?: (row: T) => boolean;
|
|
28
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { TableProps } from './Table.types';
|
|
2
|
+
declare function Table<T extends Record<string, unknown>>({ columns, data, keyField, selectable, onRowSelect, rowActions, stickyHeader, loading, emptyStateMessage, pagination, onRowClick, rowClassName, isRowDisabled, breakpoint, alignHeader, isTableHeadVisible, isRowSelected: externalIsRowSelected, }: Readonly<TableProps<T>>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export default Table;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { j as t } from "../../../_virtual/jsx-runtime.js";
|
|
2
|
+
import { useState as v, useEffect as L, useMemo as N } from "react";
|
|
3
|
+
import { useTranslation as Q } from "react-i18next";
|
|
4
|
+
import U from "../../Spinner.js";
|
|
5
|
+
import X from "../../Pagination.js";
|
|
6
|
+
import Y from "../../Typography.js";
|
|
7
|
+
import O, { CheckboxCell as Z } from "./components/CellComponents.js";
|
|
8
|
+
import z from "./components/TableHead.js";
|
|
9
|
+
import { TableContainer as H, LoadingOverlay as D, TablesWrapper as k, DataScrollBox as F, StyledTable as R, TableBody as W, EmptyState as w, TableRow as y, TableCellContainer as b, ActionsTable as ee, TableFooter as te } from "./Table.styles.js";
|
|
10
|
+
function me({
|
|
11
|
+
columns: T,
|
|
12
|
+
data: i,
|
|
13
|
+
keyField: r,
|
|
14
|
+
selectable: u = !1,
|
|
15
|
+
onRowSelect: m,
|
|
16
|
+
rowActions: x,
|
|
17
|
+
stickyHeader: $ = !1,
|
|
18
|
+
loading: f = !1,
|
|
19
|
+
emptyStateMessage: I,
|
|
20
|
+
pagination: n,
|
|
21
|
+
onRowClick: a,
|
|
22
|
+
rowClassName: j,
|
|
23
|
+
isRowDisabled: d,
|
|
24
|
+
breakpoint: _ = "md",
|
|
25
|
+
alignHeader: C = "start",
|
|
26
|
+
// Dropdown related props
|
|
27
|
+
isTableHeadVisible: K = !1,
|
|
28
|
+
isRowSelected: S
|
|
29
|
+
}) {
|
|
30
|
+
const [h, p] = v([]), [B, g] = v(_), [M, A] = v(null), { t: V } = Q();
|
|
31
|
+
L(() => {
|
|
32
|
+
const e = () => {
|
|
33
|
+
A(null);
|
|
34
|
+
};
|
|
35
|
+
return document.addEventListener("click", e), () => {
|
|
36
|
+
document.removeEventListener("click", e);
|
|
37
|
+
};
|
|
38
|
+
}, []), L(() => {
|
|
39
|
+
const e = () => {
|
|
40
|
+
const l = window.innerWidth;
|
|
41
|
+
l < 576 ? g("sm") : l < 992 ? g("md") : g("lg");
|
|
42
|
+
};
|
|
43
|
+
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
44
|
+
}, []);
|
|
45
|
+
const P = N(() => T.filter((e) => typeof e.hidden == "function" ? !e.hidden(B) : !e.hidden), [T, B]), q = () => {
|
|
46
|
+
h.length === i.length ? p([]) : p([...i]), m && m(h.length === i.length ? [] : [...i]);
|
|
47
|
+
}, G = (e) => {
|
|
48
|
+
const l = h.filter((s) => e[r] === s[r]);
|
|
49
|
+
return l && l.length > 0;
|
|
50
|
+
}, J = (e) => {
|
|
51
|
+
const l = h.some((o) => o[r] === e[r]);
|
|
52
|
+
let s;
|
|
53
|
+
l ? s = h.filter((o) => o[r] !== e[r]) : s = [...h, e], p(s), m && m(s);
|
|
54
|
+
};
|
|
55
|
+
return /* @__PURE__ */ t.jsxs(H, { children: [
|
|
56
|
+
f && /* @__PURE__ */ t.jsx(D, { children: /* @__PURE__ */ t.jsx(U, { size: "3rem" }) }),
|
|
57
|
+
/* @__PURE__ */ t.jsxs(k, { children: [
|
|
58
|
+
/* @__PURE__ */ t.jsx(F, { children: /* @__PURE__ */ t.jsxs(R, { children: [
|
|
59
|
+
K && /* @__PURE__ */ t.jsx(
|
|
60
|
+
z,
|
|
61
|
+
{
|
|
62
|
+
data: i,
|
|
63
|
+
handleSelectAll: q,
|
|
64
|
+
selectedRows: h,
|
|
65
|
+
visibleColumns: P,
|
|
66
|
+
alignHeader: C,
|
|
67
|
+
rowActions: void 0,
|
|
68
|
+
stickyHeader: $,
|
|
69
|
+
selectable: u,
|
|
70
|
+
loading: f
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
/* @__PURE__ */ t.jsx(W, { children: i.length === 0 ? /* @__PURE__ */ t.jsx("tr", { children: /* @__PURE__ */ t.jsx("td", { colSpan: (u ? 1 : 0) + P.length, children: /* @__PURE__ */ t.jsx(w, { children: /* @__PURE__ */ t.jsx(Y, { variant: "mdText", children: I ?? V("NO_DATA_AVAILABLE") }) }) }) }) : i.map((e, l) => {
|
|
74
|
+
const s = (d == null ? void 0 : d(e)) ?? !1, o = S ? S(e) : h.some((c) => c[r] === e[r]), E = e[r];
|
|
75
|
+
return /* @__PURE__ */ t.jsxs(
|
|
76
|
+
y,
|
|
77
|
+
{
|
|
78
|
+
$selected: o,
|
|
79
|
+
$disabled: s,
|
|
80
|
+
$clickable: !!a && !s,
|
|
81
|
+
onClick: () => !s && (a == null ? void 0 : a(e)),
|
|
82
|
+
className: (j == null ? void 0 : j(e, l)) ?? "",
|
|
83
|
+
children: [
|
|
84
|
+
u && /* @__PURE__ */ t.jsx(b, { $align: "center", $isFirstColumn: !0, children: /* @__PURE__ */ t.jsx(
|
|
85
|
+
Z,
|
|
86
|
+
{
|
|
87
|
+
checkBoxOptions: {
|
|
88
|
+
checked: G(e),
|
|
89
|
+
$variant: "primary",
|
|
90
|
+
$disabled: s,
|
|
91
|
+
$size: "sm",
|
|
92
|
+
onChange: () => !s && J(e)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
) }),
|
|
96
|
+
P.map((c) => /* @__PURE__ */ t.jsx(b, { $align: c.align, children: /* @__PURE__ */ t.jsx(
|
|
97
|
+
O,
|
|
98
|
+
{
|
|
99
|
+
column: c,
|
|
100
|
+
row: e,
|
|
101
|
+
type: c.cellType ?? "text",
|
|
102
|
+
align: c.align,
|
|
103
|
+
width: c.width ?? "",
|
|
104
|
+
minWidth: c.minWidth ?? "",
|
|
105
|
+
maxWidth: c.maxWidth ?? ""
|
|
106
|
+
}
|
|
107
|
+
) }, `${E}-${c.id}`))
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
E
|
|
111
|
+
);
|
|
112
|
+
}) })
|
|
113
|
+
] }) }),
|
|
114
|
+
x && x.length > 0 && /* @__PURE__ */ t.jsxs(ee, { children: [
|
|
115
|
+
/* @__PURE__ */ t.jsx(
|
|
116
|
+
z,
|
|
117
|
+
{
|
|
118
|
+
data: i,
|
|
119
|
+
handleSelectAll: () => {
|
|
120
|
+
},
|
|
121
|
+
selectedRows: h,
|
|
122
|
+
visibleColumns: [],
|
|
123
|
+
alignHeader: C,
|
|
124
|
+
rowActions: x,
|
|
125
|
+
stickyHeader: $,
|
|
126
|
+
selectable: !1,
|
|
127
|
+
loading: f
|
|
128
|
+
}
|
|
129
|
+
),
|
|
130
|
+
/* @__PURE__ */ t.jsx(W, { children: i.length === 0 ? /* @__PURE__ */ t.jsx("tr", { children: /* @__PURE__ */ t.jsx("td", { children: /* @__PURE__ */ t.jsx("div", { style: { height: "3.5rem" } }) }) }) : i.map((e) => {
|
|
131
|
+
const l = (d == null ? void 0 : d(e)) ?? !1;
|
|
132
|
+
return /* @__PURE__ */ t.jsx(y, { $disabled: l, children: /* @__PURE__ */ t.jsx(b, { $align: "center", $isActionCell: !0, children: /* @__PURE__ */ t.jsx(
|
|
133
|
+
O,
|
|
134
|
+
{
|
|
135
|
+
row: e,
|
|
136
|
+
type: "icon",
|
|
137
|
+
iconOptions: {
|
|
138
|
+
keyField: r,
|
|
139
|
+
rowActions: x,
|
|
140
|
+
activeDropdown: M,
|
|
141
|
+
setActiveDropdown: A
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
) }) }, `action-${e[r]}`);
|
|
145
|
+
}) })
|
|
146
|
+
] })
|
|
147
|
+
] }),
|
|
148
|
+
n && n.enabled && /* @__PURE__ */ t.jsx(te, { children: /* @__PURE__ */ t.jsx(
|
|
149
|
+
X,
|
|
150
|
+
{
|
|
151
|
+
currentPage: n.currentPage,
|
|
152
|
+
totalPages: n.totalPages,
|
|
153
|
+
onChange: n.onPageChange,
|
|
154
|
+
disabled: f,
|
|
155
|
+
hidePrevButton: n.hidePrevButton,
|
|
156
|
+
hideNextButton: n.hideNextButton,
|
|
157
|
+
siblingCount: n.siblingCount,
|
|
158
|
+
boundaryCount: n.boundaryCount,
|
|
159
|
+
itemsPerPage: n.pageSize,
|
|
160
|
+
totalItems: n.totalItems,
|
|
161
|
+
itemsPerPageOptions: n.itemsPerPageOptions,
|
|
162
|
+
onItemsPerPageChange: n.onItemsPerPageChange
|
|
163
|
+
}
|
|
164
|
+
) })
|
|
165
|
+
] });
|
|
166
|
+
}
|
|
167
|
+
export {
|
|
168
|
+
me as default
|
|
169
|
+
};
|