@sito/dashboard 0.0.78 → 0.0.79
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/Form.cjs +1 -1
- package/dist/Form.js +1 -1
- package/dist/SelectInput-BrKnfhB0.cjs +1 -0
- package/dist/{SelectInput-BTM8ehhB.js → SelectInput-D09muy0T.js} +139 -128
- package/dist/{Table-DHQjfPrt.js → Table-ARgTVSwK.js} +1 -1
- package/dist/{Table-C3ZJ-42T.cjs → Table-CRXmixBI.cjs} +1 -1
- package/dist/Table.cjs +1 -1
- package/dist/Table.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2 -2
- package/package.json +1 -1
- package/dist/SelectInput-CZrWA19u.cjs +0 -1
package/dist/Form.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./SelectInput-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./SelectInput-BrKnfhB0.cjs"),t=require("./FileInput-Cz2R3z3k.cjs");exports.AutocompleteInput=e.AutocompleteInput;exports.CheckInput=e.CheckInput;exports.SelectInput=e.SelectInput;exports.State=e.State;exports.TextInput=e.TextInput;exports.helperTextStateClassName=e.helperTextStateClassName;exports.inputStateClassName=e.inputStateClassName;exports.labelStateClassName=e.labelStateClassName;exports.FileInput=t.FileInput;
|
package/dist/Form.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as e, C as s, S as l, a as p, T as u, h as m, i as n, l as o } from "./SelectInput-
|
|
1
|
+
import { A as e, C as s, S as l, a as p, T as u, h as m, i as n, l as o } from "./SelectInput-D09muy0T.js";
|
|
2
2
|
import { F as r } from "./FileInput-C7ZYKt_i.js";
|
|
3
3
|
export {
|
|
4
4
|
e as AutocompleteInput,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var ne=require("./SelectInput.css");const n=require("react/jsx-runtime"),h=require("./classNames-DHAzUjfZ.cjs"),r=require("react"),Y=require("./Chip-N4r2Xf9l.cjs"),X=require("./IconButton-DVZCHIHB.cjs"),Z=require("./Close-O9P7wJGf.cjs"),ee=r.forwardRef(function(l,N){const{state:C,value:t,onChange:s,options:v=[],name:A="",id:w="",label:b="",containerClassName:I="",inputContainerClassName:k="",helperText:E="",placeholder:R="",multiple:f=!1,required:D=!1,"aria-required":u=!1,...L}=l,O=u===!0||String(u).toLowerCase()==="true",T=!!(D||O),F=f&&Array.isArray(t)&&t.length>0,B=T&&!F,[S,p]=r.useState("");r.useEffect(()=>{if(!f&&t&&!Array.isArray(t)){p(String(t.value??t.name??""));return}p("")},[f,t]);const[c,g]=r.useState(!1),[x,o]=r.useState(-1),m=r.useMemo(()=>v.filter(e=>{const i=String(e.value??e.name).toLowerCase().includes(S?.toLowerCase());return Array.isArray(t)&&t.length?i&&!t.some(y=>y.id===e.id):t&&!Array.isArray(t)?i&&t.id!==e.id:i}),[v,t,S]);r.useEffect(()=>{if(!c||!m.length){o(-1);return}o(0)},[c,m]);const q=r.useRef(null),U=r.useRef(null),[P,V]=r.useState(!1),a=r.useRef(null);r.useEffect(()=>{const e=y=>{q.current&&!q.current.contains(y.target)&&g(!1)},i=y=>{y.key==="Escape"&&g(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",i)}},[]);const d=r.useCallback(e=>{p(e.target.value)},[]),j=r.useCallback(e=>{e?f?(p(""),Array.isArray(t)&&t.length?s([...t,e]):s([e])):(p(String(e.name??e.value??"")),s(e)):s(null),g(!1)},[f,s,t]),_=r.useCallback(e=>{if(!m.length){e.key==="Escape"&&g(!1);return}if(e.key==="ArrowDown"||e.key==="ArrowUp"){if(e.preventDefault(),!c){g(!0),o(0);return}o(i=>{const y=i>=0?i:0;return e.key==="ArrowDown"?(y+1+m.length)%m.length:(y-1+m.length)%m.length});return}if(e.key==="Enter"&&c){e.preventDefault();const i=x>=0?x:0;j(m[i]);return}e.key==="Escape"&&c&&(e.preventDefault(),g(!1))},[j,x,c,m]),W=r.useCallback(e=>{if(!Array.isArray(t)){s(null);return}const i=t.filter((y,Q)=>Q!==e);i.length?s(i):s(null)},[s,t]),J=r.useCallback(()=>{Array.isArray(t)&&s([t[0]])},[s,t]);return r.useLayoutEffect(()=>{const e=a.current?.offsetWidth??0,i=q.current?.offsetWidth??0;V(e>i*.4)},[t]),n.jsxs("div",{className:h.classNames("autocomplete-input-container",I),ref:q,children:[n.jsxs("div",{className:"autocomplete-value-input-container",children:[n.jsx(G,{state:C,name:A,id:w,value:S,onChange:d,placeholder:R,helperText:E,onFocus:()=>g(!0),onKeyDown:_,label:b,containerClassName:h.classNames("autocomplete-text-input",k),required:B,"aria-required":T,ref:N??U,...L,children:!f&&t&&!Array.isArray(t)&&(t.value||t.name)&&n.jsx(X.IconButton,{icon:n.jsx(Z.Close,{}),className:"autocomplete-delete-button",onClick:e=>{j(),e.stopPropagation()}})}),f&&Array.isArray(t)&&t.length?n.jsx("ul",{ref:a,className:"autocomplete-value-container",children:P?n.jsxs(n.Fragment,{children:[n.jsx("li",{children:n.jsx(Y.Chip,{text:t[0]?.value??t[0]?.name,onDelete:e=>{W(0),e.stopPropagation()}})}),t.length>1&&n.jsx("li",{children:n.jsx(Y.Chip,{text:`+${t.length-1}`,onDelete:e=>{J(),e.stopPropagation()}})})]}):t.map((e,i)=>n.jsx("li",{children:n.jsx(Y.Chip,{text:String(e.value??e.name),onDelete:y=>{W(i),y.stopPropagation()}})},e.id??e.value??e.name))}):null]}),c&&n.jsx("ul",{className:"autocomplete-suggestions-container",style:{width:q.current?.offsetWidth},children:m.map(e=>n.jsx("li",{className:h.classNames("autocomplete-suggestion-item",e.id===m[x]?.id?"highlighted":""),onMouseEnter:()=>o(m.findIndex(i=>i.id===e.id)),onClick:i=>{j(e),i.stopPropagation()},children:e.value??e.name},e.id??e.value??e.name))})]})});var M=(l=>(l.error="error",l.good="good",l.default="default",l))(M||{});const H=l=>{switch(l){case"error":return"input-error";case"good":return"input-good";default:return"input-normal"}},K=l=>{switch(l){case"error":return"input-label-error";case"good":return"input-label-good";default:return"input-label-normal"}},$=l=>{switch(l){case"error":return"input-helper-text-error";case"good":return"input-helper-text-good";default:return"input-helper-text-normal"}},te=r.forwardRef(function(l,N){const{checked:C,onChange:t,name:s="",id:v="",label:A="",state:w=M.default,containerClassName:b="",inputClassName:I="",labelClassName:k="",...E}=l;return n.jsxs("label",{className:h.classNames("input-check-container",b),children:[n.jsx("input",{id:v,ref:N,name:s,type:"checkbox",checked:C,onChange:t,className:h.classNames("input-check",H(w),I),...E}),n.jsx("span",{className:h.classNames("input-check-label",K(w),k),children:A})]})}),z=l=>l==null?!1:Array.isArray(l)?l.length>0:`${l}`.length>0,ae=new Set(["date","datetime-local","time","month","week","range","color","file"]),G=r.forwardRef(function(l,N){const{children:C,state:t=M.default,label:s="",containerClassName:v="",inputClassName:A="",labelClassName:w="",helperText:b="",helperTextClassName:I="",value:k,defaultValue:E,onChange:R,onFocus:f,onBlur:D,...u}=l,L=k!==void 0,[O,T]=r.useState(()=>z(E)),F=L?z(k):O,B=ae.has(u.type??""),S=!!u.placeholder||B,p=u["aria-required"]===!0||String(u["aria-required"]).toLowerCase()==="true",c=!!(u.required||p),g=x=>{L||T(x.currentTarget.value.length>0),R?.(x)};return n.jsxs("div",{className:h.classNames("text-input-container",v),children:[n.jsxs("div",{className:"text-input-field",children:[n.jsx("input",{ref:N,defaultValue:E,onChange:g,onFocus:f,onBlur:D,...L?{value:k}:{},className:h.classNames("text-input",H(t),A,F?"has-value":"",u.placeholder?"has-placeholder":"",S?"keep-label-up":""),...u}),!!s&&n.jsxs("label",{htmlFor:u.id,className:h.classNames("text-input-label",K(t),w),children:[s,c?" *":""]}),C]}),!!b&&n.jsx("p",{className:h.classNames("text-input-helper-text",$(t),I),children:b})]})}),se=r.forwardRef(function(l,N){const{value:C,onChange:t,options:s,containerClassName:v="",inputClassName:A="",labelClassName:w="",helperText:b="",helperTextClassName:I="",label:k="",placeholder:E="",name:R="",id:f="",state:D=M.default,native:u=!0,disabled:L,required:O,autoFocus:T,children:F,...B}=l,S=r.useRef(null),[p,c]=r.useState(!1),[g,x]=r.useState(-1),o=r.useMemo(()=>s.findIndex(a=>String(a.id)===String(C??s[0]?.id??"")),[s,C]),m=r.useMemo(()=>o>=0?s[o]:void 0,[s,o]);r.useEffect(()=>{if(!(u||!p)){if(!s.length){x(-1);return}x(o>=0?o:0)}},[u,s.length,o,p]),r.useEffect(()=>{if(u)return;const a=d=>{S.current&&!S.current.contains(d.target)&&c(!1)};return document.addEventListener("mousedown",a),()=>{document.removeEventListener("mousedown",a)}},[u]);const q=r.useCallback(a=>{N&&(typeof N=="function"?N(a):N.current=a)},[N]),U=r.useCallback(a=>{if(!t)return;const d={target:{value:String(a)},currentTarget:{value:String(a)}};t(d)},[t]),P=r.useCallback(a=>{const d=s[a];d&&(U(d.id),c(!1))},[U,s]),V=r.useCallback(a=>{if(s.length){if(a.key==="ArrowDown"||a.key==="ArrowUp"){if(a.preventDefault(),!p){c(!0);const d=o>=0?o:0;x(d);return}x(d=>{const j=d>=0?d:o;return a.key==="ArrowDown"?(j+1+s.length)%s.length:(j-1+s.length)%s.length});return}if(a.key==="Enter"){if(!p){a.preventDefault(),c(!0),x(o>=0?o:0);return}a.preventDefault(),P(g>=0?g:0);return}a.key==="Escape"&&p&&(a.preventDefault(),c(!1))}},[g,s,P,o,p]);return u?n.jsxs("div",{className:h.classNames("select-input-container",v),children:[n.jsx("select",{...B,id:f,ref:q,name:R,value:C,onChange:t,className:h.classNames("select-input",H(D),"peer",A),children:s?.map(a=>n.jsx("option",{value:a.id,children:a.value??a.name??a.id},a.id))}),n.jsx("label",{htmlFor:f,className:h.classNames("select-input-label",K(D),w),children:k}),F,b&&n.jsx("p",{className:h.classNames("select-input-helper-text",$(D),I),children:b})]}):n.jsxs("div",{ref:S,className:h.classNames("select-input-container",v),children:[n.jsx("select",{...B,ref:q,name:R,id:f,value:C,onChange:t,className:"select-input-native-hidden",tabIndex:-1,"aria-hidden":!0,children:s?.map(a=>n.jsx("option",{value:a.id,children:a.value??a.name??a.id},a.id))}),n.jsx(G,{id:f,name:R,state:D,value:String(m?.value??m?.name??""),readOnly:!0,label:k,helperText:b,containerClassName:"select-input-text-container",inputClassName:h.classNames("select-input-text",A),labelClassName:w,helperTextClassName:I,placeholder:E,disabled:L,required:O,autoFocus:T,onClick:()=>c(a=>!a),onKeyDown:V,onFocus:()=>c(!0),role:"combobox","aria-expanded":p,"aria-haspopup":"listbox",children:F}),p&&n.jsx("ul",{className:"select-input-options-container",role:"listbox",children:s.map((a,d)=>{const j=String(a.id)===String(C),_=d===g;return n.jsx("li",{role:"option","aria-selected":j,className:h.classNames("select-input-option-item",_?"highlighted":""),onMouseEnter:()=>x(d),onClick:W=>{P(d),W.stopPropagation()},children:a.value??a.name??a.id},a.id)})})]})});exports.AutocompleteInput=ee;exports.CheckInput=te;exports.SelectInput=se;exports.State=M;exports.TextInput=G;exports.helperTextStateClassName=$;exports.inputStateClassName=H;exports.labelStateClassName=K;
|
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
import "./SelectInput.css";
|
|
2
2
|
import { jsxs as D, jsx as a, Fragment as ae } from "react/jsx-runtime";
|
|
3
3
|
import { c as d } from "./classNames-DDRjbGA1.js";
|
|
4
|
-
import { forwardRef as
|
|
4
|
+
import { forwardRef as j, useState as O, useEffect as K, useMemo as z, useRef as M, useCallback as S, useLayoutEffect as le } from "react";
|
|
5
5
|
import { C as G } from "./Chip-6bEZ7uwv.js";
|
|
6
6
|
import { I as se } from "./IconButton-CqPk_OXG.js";
|
|
7
7
|
import { C as ie } from "./Close-rKC9AcNX.js";
|
|
8
|
-
const
|
|
8
|
+
const ge = j(function(l, C) {
|
|
9
9
|
const {
|
|
10
10
|
state: y,
|
|
11
11
|
value: t,
|
|
12
12
|
onChange: r,
|
|
13
|
-
options:
|
|
13
|
+
options: x = [],
|
|
14
14
|
name: I = "",
|
|
15
|
-
id:
|
|
15
|
+
id: A = "",
|
|
16
16
|
label: v = "",
|
|
17
17
|
containerClassName: E = "",
|
|
18
|
-
inputContainerClassName:
|
|
19
|
-
helperText:
|
|
18
|
+
inputContainerClassName: w = "",
|
|
19
|
+
helperText: L = "",
|
|
20
20
|
placeholder: R = "",
|
|
21
21
|
multiple: m = !1,
|
|
22
|
-
required:
|
|
22
|
+
required: T = !1,
|
|
23
23
|
"aria-required": o = !1,
|
|
24
24
|
...F
|
|
25
|
-
} = l,
|
|
26
|
-
|
|
25
|
+
} = l, U = o === !0 || String(o).toLowerCase() === "true", P = !!(T || U), B = m && Array.isArray(t) && t.length > 0, H = P && !B, [b, h] = O("");
|
|
26
|
+
K(() => {
|
|
27
27
|
if (!m && t && !Array.isArray(t)) {
|
|
28
28
|
h(String(t.value ?? t.name ?? ""));
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
h("");
|
|
32
32
|
}, [m, t]);
|
|
33
|
-
const [u, f] = O(!1), [g, i] = O(-1), p =
|
|
34
|
-
() =>
|
|
35
|
-
const s = String(e.value ?? e.name).toLowerCase().includes(
|
|
33
|
+
const [u, f] = O(!1), [g, i] = O(-1), p = z(
|
|
34
|
+
() => x.filter((e) => {
|
|
35
|
+
const s = String(e.value ?? e.name).toLowerCase().includes(b?.toLowerCase());
|
|
36
36
|
return Array.isArray(t) && t.length ? s && !t.some((N) => N.id === e.id) : t && !Array.isArray(t) ? s && t.id !== e.id : s;
|
|
37
37
|
}),
|
|
38
|
-
[
|
|
38
|
+
[x, t, b]
|
|
39
39
|
);
|
|
40
|
-
|
|
40
|
+
K(() => {
|
|
41
41
|
if (!u || !p.length) {
|
|
42
42
|
i(-1);
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
i(0);
|
|
46
46
|
}, [u, p]);
|
|
47
|
-
const
|
|
48
|
-
|
|
47
|
+
const q = M(null), V = M(null), [W, $] = O(!1), n = M(null);
|
|
48
|
+
K(() => {
|
|
49
49
|
const e = (N) => {
|
|
50
|
-
|
|
50
|
+
q.current && !q.current.contains(N.target) && f(!1);
|
|
51
51
|
}, s = (N) => {
|
|
52
52
|
N.key === "Escape" && f(!1);
|
|
53
53
|
};
|
|
@@ -57,12 +57,12 @@ const fe = $(function(l, C) {
|
|
|
57
57
|
}, []);
|
|
58
58
|
const c = S((e) => {
|
|
59
59
|
h(e.target.value);
|
|
60
|
-
}, []),
|
|
60
|
+
}, []), k = S(
|
|
61
61
|
(e) => {
|
|
62
62
|
e ? m ? (h(""), Array.isArray(t) && t.length ? r([...t, e]) : r([e])) : (h(String(e.name ?? e.value ?? "")), r(e)) : r(null), f(!1);
|
|
63
63
|
},
|
|
64
64
|
[m, r, t]
|
|
65
|
-
),
|
|
65
|
+
), X = S(
|
|
66
66
|
(e) => {
|
|
67
67
|
if (!p.length) {
|
|
68
68
|
e.key === "Escape" && f(!1);
|
|
@@ -82,18 +82,18 @@ const fe = $(function(l, C) {
|
|
|
82
82
|
if (e.key === "Enter" && u) {
|
|
83
83
|
e.preventDefault();
|
|
84
84
|
const s = g >= 0 ? g : 0;
|
|
85
|
-
|
|
85
|
+
k(p[s]);
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
88
|
e.key === "Escape" && u && (e.preventDefault(), f(!1));
|
|
89
89
|
},
|
|
90
90
|
[
|
|
91
|
-
|
|
91
|
+
k,
|
|
92
92
|
g,
|
|
93
93
|
u,
|
|
94
94
|
p
|
|
95
95
|
]
|
|
96
|
-
),
|
|
96
|
+
), _ = S(
|
|
97
97
|
(e) => {
|
|
98
98
|
if (!Array.isArray(t)) {
|
|
99
99
|
r(null);
|
|
@@ -107,13 +107,13 @@ const fe = $(function(l, C) {
|
|
|
107
107
|
Array.isArray(t) && r([t[0]]);
|
|
108
108
|
}, [r, t]);
|
|
109
109
|
return le(() => {
|
|
110
|
-
const e = n.current?.offsetWidth ?? 0, s =
|
|
111
|
-
|
|
110
|
+
const e = n.current?.offsetWidth ?? 0, s = q.current?.offsetWidth ?? 0;
|
|
111
|
+
$(e > s * 0.4);
|
|
112
112
|
}, [t]), /* @__PURE__ */ D(
|
|
113
113
|
"div",
|
|
114
114
|
{
|
|
115
115
|
className: d("autocomplete-input-container", E),
|
|
116
|
-
ref:
|
|
116
|
+
ref: q,
|
|
117
117
|
children: [
|
|
118
118
|
/* @__PURE__ */ D("div", { className: "autocomplete-value-input-container", children: [
|
|
119
119
|
/* @__PURE__ */ a(
|
|
@@ -121,21 +121,21 @@ const fe = $(function(l, C) {
|
|
|
121
121
|
{
|
|
122
122
|
state: y,
|
|
123
123
|
name: I,
|
|
124
|
-
id:
|
|
125
|
-
value:
|
|
124
|
+
id: A,
|
|
125
|
+
value: b,
|
|
126
126
|
onChange: c,
|
|
127
127
|
placeholder: R,
|
|
128
|
-
helperText:
|
|
128
|
+
helperText: L,
|
|
129
129
|
onFocus: () => f(!0),
|
|
130
|
-
onKeyDown:
|
|
130
|
+
onKeyDown: X,
|
|
131
131
|
label: v,
|
|
132
132
|
containerClassName: d(
|
|
133
133
|
"autocomplete-text-input",
|
|
134
|
-
|
|
134
|
+
w
|
|
135
135
|
),
|
|
136
|
-
required:
|
|
137
|
-
"aria-required":
|
|
138
|
-
ref: C ??
|
|
136
|
+
required: H,
|
|
137
|
+
"aria-required": P,
|
|
138
|
+
ref: C ?? V,
|
|
139
139
|
...F,
|
|
140
140
|
children: !m && t && !Array.isArray(t) && (t.value || t.name) && /* @__PURE__ */ a(
|
|
141
141
|
se,
|
|
@@ -143,19 +143,19 @@ const fe = $(function(l, C) {
|
|
|
143
143
|
icon: /* @__PURE__ */ a(ie, {}),
|
|
144
144
|
className: "autocomplete-delete-button",
|
|
145
145
|
onClick: (e) => {
|
|
146
|
-
|
|
146
|
+
k(), e.stopPropagation();
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
)
|
|
150
150
|
}
|
|
151
151
|
),
|
|
152
|
-
m && Array.isArray(t) && t.length ? /* @__PURE__ */ a("ul", { ref: n, className: "autocomplete-value-container", children:
|
|
152
|
+
m && Array.isArray(t) && t.length ? /* @__PURE__ */ a("ul", { ref: n, className: "autocomplete-value-container", children: W ? /* @__PURE__ */ D(ae, { children: [
|
|
153
153
|
/* @__PURE__ */ a("li", { children: /* @__PURE__ */ a(
|
|
154
154
|
G,
|
|
155
155
|
{
|
|
156
156
|
text: t[0]?.value ?? t[0]?.name,
|
|
157
157
|
onDelete: (e) => {
|
|
158
|
-
|
|
158
|
+
_(0), e.stopPropagation();
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
) }),
|
|
@@ -173,7 +173,7 @@ const fe = $(function(l, C) {
|
|
|
173
173
|
{
|
|
174
174
|
text: String(e.value ?? e.name),
|
|
175
175
|
onDelete: (N) => {
|
|
176
|
-
|
|
176
|
+
_(s), N.stopPropagation();
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
) }, e.id ?? e.value ?? e.name)) }) : null
|
|
@@ -182,7 +182,7 @@ const fe = $(function(l, C) {
|
|
|
182
182
|
"ul",
|
|
183
183
|
{
|
|
184
184
|
className: "autocomplete-suggestions-container",
|
|
185
|
-
style: { width:
|
|
185
|
+
style: { width: q.current?.offsetWidth },
|
|
186
186
|
children: p.map((e) => /* @__PURE__ */ a(
|
|
187
187
|
"li",
|
|
188
188
|
{
|
|
@@ -194,7 +194,7 @@ const fe = $(function(l, C) {
|
|
|
194
194
|
p.findIndex((s) => s.id === e.id)
|
|
195
195
|
),
|
|
196
196
|
onClick: (s) => {
|
|
197
|
-
|
|
197
|
+
k(e), s.stopPropagation();
|
|
198
198
|
},
|
|
199
199
|
children: e.value ?? e.name
|
|
200
200
|
},
|
|
@@ -206,8 +206,8 @@ const fe = $(function(l, C) {
|
|
|
206
206
|
}
|
|
207
207
|
);
|
|
208
208
|
});
|
|
209
|
-
var
|
|
210
|
-
const
|
|
209
|
+
var Y = /* @__PURE__ */ ((l) => (l.error = "error", l.good = "good", l.default = "default", l))(Y || {});
|
|
210
|
+
const J = (l) => {
|
|
211
211
|
switch (l) {
|
|
212
212
|
case "error":
|
|
213
213
|
return "input-error";
|
|
@@ -216,7 +216,7 @@ const Q = (l) => {
|
|
|
216
216
|
default:
|
|
217
217
|
return "input-normal";
|
|
218
218
|
}
|
|
219
|
-
},
|
|
219
|
+
}, Q = (l) => {
|
|
220
220
|
switch (l) {
|
|
221
221
|
case "error":
|
|
222
222
|
return "input-label-error";
|
|
@@ -234,24 +234,24 @@ const Q = (l) => {
|
|
|
234
234
|
default:
|
|
235
235
|
return "input-helper-text-normal";
|
|
236
236
|
}
|
|
237
|
-
},
|
|
237
|
+
}, Ce = j(function(l, C) {
|
|
238
238
|
const {
|
|
239
239
|
checked: y,
|
|
240
240
|
onChange: t,
|
|
241
241
|
name: r = "",
|
|
242
|
-
id:
|
|
242
|
+
id: x = "",
|
|
243
243
|
label: I = "",
|
|
244
|
-
state:
|
|
244
|
+
state: A = Y.default,
|
|
245
245
|
containerClassName: v = "",
|
|
246
246
|
inputClassName: E = "",
|
|
247
|
-
labelClassName:
|
|
248
|
-
...
|
|
247
|
+
labelClassName: w = "",
|
|
248
|
+
...L
|
|
249
249
|
} = l;
|
|
250
250
|
return /* @__PURE__ */ D("label", { className: d("input-check-container", v), children: [
|
|
251
251
|
/* @__PURE__ */ a(
|
|
252
252
|
"input",
|
|
253
253
|
{
|
|
254
|
-
id:
|
|
254
|
+
id: x,
|
|
255
255
|
ref: C,
|
|
256
256
|
name: r,
|
|
257
257
|
type: "checkbox",
|
|
@@ -259,10 +259,10 @@ const Q = (l) => {
|
|
|
259
259
|
onChange: t,
|
|
260
260
|
className: d(
|
|
261
261
|
"input-check",
|
|
262
|
-
|
|
262
|
+
J(A),
|
|
263
263
|
E
|
|
264
264
|
),
|
|
265
|
-
...
|
|
265
|
+
...L
|
|
266
266
|
}
|
|
267
267
|
),
|
|
268
268
|
/* @__PURE__ */ a(
|
|
@@ -270,52 +270,63 @@ const Q = (l) => {
|
|
|
270
270
|
{
|
|
271
271
|
className: d(
|
|
272
272
|
"input-check-label",
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
Q(A),
|
|
274
|
+
w
|
|
275
275
|
),
|
|
276
276
|
children: I
|
|
277
277
|
}
|
|
278
278
|
)
|
|
279
279
|
] });
|
|
280
|
-
}), Z = (l) => l == null ? !1 : Array.isArray(l) ? l.length > 0 : `${l}`.length > 0,
|
|
280
|
+
}), Z = (l) => l == null ? !1 : Array.isArray(l) ? l.length > 0 : `${l}`.length > 0, oe = /* @__PURE__ */ new Set([
|
|
281
|
+
"date",
|
|
282
|
+
"datetime-local",
|
|
283
|
+
"time",
|
|
284
|
+
"month",
|
|
285
|
+
"week",
|
|
286
|
+
"range",
|
|
287
|
+
"color",
|
|
288
|
+
"file"
|
|
289
|
+
]), te = j(function(l, C) {
|
|
281
290
|
const {
|
|
282
291
|
children: y,
|
|
283
|
-
state: t =
|
|
292
|
+
state: t = Y.default,
|
|
284
293
|
label: r = "",
|
|
285
|
-
containerClassName:
|
|
294
|
+
containerClassName: x = "",
|
|
286
295
|
inputClassName: I = "",
|
|
287
|
-
labelClassName:
|
|
296
|
+
labelClassName: A = "",
|
|
288
297
|
helperText: v = "",
|
|
289
298
|
helperTextClassName: E = "",
|
|
290
|
-
value:
|
|
291
|
-
defaultValue:
|
|
299
|
+
value: w,
|
|
300
|
+
defaultValue: L,
|
|
292
301
|
onChange: R,
|
|
293
302
|
onFocus: m,
|
|
294
|
-
onBlur:
|
|
303
|
+
onBlur: T,
|
|
295
304
|
...o
|
|
296
|
-
} = l, F =
|
|
297
|
-
() => Z(
|
|
298
|
-
),
|
|
299
|
-
|
|
305
|
+
} = l, F = w !== void 0, [U, P] = O(
|
|
306
|
+
() => Z(L)
|
|
307
|
+
), B = F ? Z(w) : U, H = oe.has(
|
|
308
|
+
o.type ?? ""
|
|
309
|
+
), b = !!o.placeholder || H, h = o["aria-required"] === !0 || String(o["aria-required"]).toLowerCase() === "true", u = !!(o.required || h), f = (g) => {
|
|
310
|
+
F || P(g.currentTarget.value.length > 0), R?.(g);
|
|
300
311
|
};
|
|
301
|
-
return /* @__PURE__ */ D("div", { className: d("text-input-container",
|
|
312
|
+
return /* @__PURE__ */ D("div", { className: d("text-input-container", x), children: [
|
|
302
313
|
/* @__PURE__ */ D("div", { className: "text-input-field", children: [
|
|
303
314
|
/* @__PURE__ */ a(
|
|
304
315
|
"input",
|
|
305
316
|
{
|
|
306
317
|
ref: C,
|
|
307
|
-
defaultValue:
|
|
318
|
+
defaultValue: L,
|
|
308
319
|
onChange: f,
|
|
309
320
|
onFocus: m,
|
|
310
|
-
onBlur:
|
|
311
|
-
...F ? { value:
|
|
321
|
+
onBlur: T,
|
|
322
|
+
...F ? { value: w } : {},
|
|
312
323
|
className: d(
|
|
313
324
|
"text-input",
|
|
314
|
-
|
|
325
|
+
J(t),
|
|
315
326
|
I,
|
|
316
|
-
|
|
327
|
+
B ? "has-value" : "",
|
|
317
328
|
o.placeholder ? "has-placeholder" : "",
|
|
318
|
-
|
|
329
|
+
b ? "keep-label-up" : ""
|
|
319
330
|
),
|
|
320
331
|
...o
|
|
321
332
|
}
|
|
@@ -326,8 +337,8 @@ const Q = (l) => {
|
|
|
326
337
|
htmlFor: o.id,
|
|
327
338
|
className: d(
|
|
328
339
|
"text-input-label",
|
|
329
|
-
|
|
330
|
-
|
|
340
|
+
Q(t),
|
|
341
|
+
A
|
|
331
342
|
),
|
|
332
343
|
children: [
|
|
333
344
|
r,
|
|
@@ -349,37 +360,37 @@ const Q = (l) => {
|
|
|
349
360
|
}
|
|
350
361
|
)
|
|
351
362
|
] });
|
|
352
|
-
}),
|
|
363
|
+
}), ye = j(function(l, C) {
|
|
353
364
|
const {
|
|
354
365
|
value: y,
|
|
355
366
|
onChange: t,
|
|
356
367
|
options: r,
|
|
357
|
-
containerClassName:
|
|
368
|
+
containerClassName: x = "",
|
|
358
369
|
inputClassName: I = "",
|
|
359
|
-
labelClassName:
|
|
370
|
+
labelClassName: A = "",
|
|
360
371
|
helperText: v = "",
|
|
361
372
|
helperTextClassName: E = "",
|
|
362
|
-
label:
|
|
363
|
-
placeholder:
|
|
373
|
+
label: w = "",
|
|
374
|
+
placeholder: L = "",
|
|
364
375
|
name: R = "",
|
|
365
376
|
id: m = "",
|
|
366
|
-
state:
|
|
377
|
+
state: T = Y.default,
|
|
367
378
|
native: o = !0,
|
|
368
379
|
disabled: F,
|
|
369
|
-
required:
|
|
370
|
-
autoFocus:
|
|
371
|
-
children:
|
|
372
|
-
...
|
|
373
|
-
} = l,
|
|
380
|
+
required: U,
|
|
381
|
+
autoFocus: P,
|
|
382
|
+
children: B,
|
|
383
|
+
...H
|
|
384
|
+
} = l, b = M(null), [h, u] = O(!1), [f, g] = O(-1), i = z(
|
|
374
385
|
() => r.findIndex(
|
|
375
386
|
(n) => String(n.id) === String(y ?? r[0]?.id ?? "")
|
|
376
387
|
),
|
|
377
388
|
[r, y]
|
|
378
|
-
), p =
|
|
389
|
+
), p = z(
|
|
379
390
|
() => i >= 0 ? r[i] : void 0,
|
|
380
391
|
[r, i]
|
|
381
392
|
);
|
|
382
|
-
|
|
393
|
+
K(() => {
|
|
383
394
|
if (!(o || !h)) {
|
|
384
395
|
if (!r.length) {
|
|
385
396
|
g(-1);
|
|
@@ -387,21 +398,21 @@ const Q = (l) => {
|
|
|
387
398
|
}
|
|
388
399
|
g(i >= 0 ? i : 0);
|
|
389
400
|
}
|
|
390
|
-
}, [o, r.length, i, h]),
|
|
401
|
+
}, [o, r.length, i, h]), K(() => {
|
|
391
402
|
if (o) return;
|
|
392
403
|
const n = (c) => {
|
|
393
|
-
|
|
404
|
+
b.current && !b.current.contains(c.target) && u(!1);
|
|
394
405
|
};
|
|
395
406
|
return document.addEventListener("mousedown", n), () => {
|
|
396
407
|
document.removeEventListener("mousedown", n);
|
|
397
408
|
};
|
|
398
409
|
}, [o]);
|
|
399
|
-
const
|
|
410
|
+
const q = S(
|
|
400
411
|
(n) => {
|
|
401
412
|
C && (typeof C == "function" ? C(n) : C.current = n);
|
|
402
413
|
},
|
|
403
414
|
[C]
|
|
404
|
-
),
|
|
415
|
+
), V = S(
|
|
405
416
|
(n) => {
|
|
406
417
|
if (!t) return;
|
|
407
418
|
const c = {
|
|
@@ -411,13 +422,13 @@ const Q = (l) => {
|
|
|
411
422
|
t(c);
|
|
412
423
|
},
|
|
413
424
|
[t]
|
|
414
|
-
),
|
|
425
|
+
), W = S(
|
|
415
426
|
(n) => {
|
|
416
427
|
const c = r[n];
|
|
417
|
-
c && (
|
|
428
|
+
c && (V(c.id), u(!1));
|
|
418
429
|
},
|
|
419
|
-
[
|
|
420
|
-
),
|
|
430
|
+
[V, r]
|
|
431
|
+
), $ = S(
|
|
421
432
|
(n) => {
|
|
422
433
|
if (r.length) {
|
|
423
434
|
if (n.key === "ArrowDown" || n.key === "ArrowUp") {
|
|
@@ -428,8 +439,8 @@ const Q = (l) => {
|
|
|
428
439
|
return;
|
|
429
440
|
}
|
|
430
441
|
g((c) => {
|
|
431
|
-
const
|
|
432
|
-
return n.key === "ArrowDown" ? (
|
|
442
|
+
const k = c >= 0 ? c : i;
|
|
443
|
+
return n.key === "ArrowDown" ? (k + 1 + r.length) % r.length : (k - 1 + r.length) % r.length;
|
|
433
444
|
});
|
|
434
445
|
return;
|
|
435
446
|
}
|
|
@@ -438,27 +449,27 @@ const Q = (l) => {
|
|
|
438
449
|
n.preventDefault(), u(!0), g(i >= 0 ? i : 0);
|
|
439
450
|
return;
|
|
440
451
|
}
|
|
441
|
-
n.preventDefault(),
|
|
452
|
+
n.preventDefault(), W(f >= 0 ? f : 0);
|
|
442
453
|
return;
|
|
443
454
|
}
|
|
444
455
|
n.key === "Escape" && h && (n.preventDefault(), u(!1));
|
|
445
456
|
}
|
|
446
457
|
},
|
|
447
|
-
[f, r,
|
|
458
|
+
[f, r, W, i, h]
|
|
448
459
|
);
|
|
449
|
-
return o ? /* @__PURE__ */ D("div", { className: d("select-input-container",
|
|
460
|
+
return o ? /* @__PURE__ */ D("div", { className: d("select-input-container", x), children: [
|
|
450
461
|
/* @__PURE__ */ a(
|
|
451
462
|
"select",
|
|
452
463
|
{
|
|
453
|
-
...
|
|
464
|
+
...H,
|
|
454
465
|
id: m,
|
|
455
|
-
ref:
|
|
466
|
+
ref: q,
|
|
456
467
|
name: R,
|
|
457
468
|
value: y,
|
|
458
469
|
onChange: t,
|
|
459
470
|
className: d(
|
|
460
471
|
"select-input",
|
|
461
|
-
|
|
472
|
+
J(T),
|
|
462
473
|
"peer",
|
|
463
474
|
I
|
|
464
475
|
),
|
|
@@ -471,19 +482,19 @@ const Q = (l) => {
|
|
|
471
482
|
htmlFor: m,
|
|
472
483
|
className: d(
|
|
473
484
|
"select-input-label",
|
|
474
|
-
|
|
475
|
-
|
|
485
|
+
Q(T),
|
|
486
|
+
A
|
|
476
487
|
),
|
|
477
|
-
children:
|
|
488
|
+
children: w
|
|
478
489
|
}
|
|
479
490
|
),
|
|
480
|
-
|
|
491
|
+
B,
|
|
481
492
|
v && /* @__PURE__ */ a(
|
|
482
493
|
"p",
|
|
483
494
|
{
|
|
484
495
|
className: d(
|
|
485
496
|
"select-input-helper-text",
|
|
486
|
-
ee(
|
|
497
|
+
ee(T),
|
|
487
498
|
E
|
|
488
499
|
),
|
|
489
500
|
children: v
|
|
@@ -492,14 +503,14 @@ const Q = (l) => {
|
|
|
492
503
|
] }) : /* @__PURE__ */ D(
|
|
493
504
|
"div",
|
|
494
505
|
{
|
|
495
|
-
ref:
|
|
496
|
-
className: d("select-input-container",
|
|
506
|
+
ref: b,
|
|
507
|
+
className: d("select-input-container", x),
|
|
497
508
|
children: [
|
|
498
509
|
/* @__PURE__ */ a(
|
|
499
510
|
"select",
|
|
500
511
|
{
|
|
501
|
-
...
|
|
502
|
-
ref:
|
|
512
|
+
...H,
|
|
513
|
+
ref: q,
|
|
503
514
|
name: R,
|
|
504
515
|
id: m,
|
|
505
516
|
value: y,
|
|
@@ -515,42 +526,42 @@ const Q = (l) => {
|
|
|
515
526
|
{
|
|
516
527
|
id: m,
|
|
517
528
|
name: R,
|
|
518
|
-
state:
|
|
529
|
+
state: T,
|
|
519
530
|
value: String(p?.value ?? p?.name ?? ""),
|
|
520
531
|
readOnly: !0,
|
|
521
|
-
label:
|
|
532
|
+
label: w,
|
|
522
533
|
helperText: v,
|
|
523
534
|
containerClassName: "select-input-text-container",
|
|
524
535
|
inputClassName: d("select-input-text", I),
|
|
525
|
-
labelClassName:
|
|
536
|
+
labelClassName: A,
|
|
526
537
|
helperTextClassName: E,
|
|
527
|
-
placeholder:
|
|
538
|
+
placeholder: L,
|
|
528
539
|
disabled: F,
|
|
529
|
-
required:
|
|
530
|
-
autoFocus:
|
|
540
|
+
required: U,
|
|
541
|
+
autoFocus: P,
|
|
531
542
|
onClick: () => u((n) => !n),
|
|
532
|
-
onKeyDown:
|
|
543
|
+
onKeyDown: $,
|
|
533
544
|
onFocus: () => u(!0),
|
|
534
545
|
role: "combobox",
|
|
535
546
|
"aria-expanded": h,
|
|
536
547
|
"aria-haspopup": "listbox",
|
|
537
|
-
children:
|
|
548
|
+
children: B
|
|
538
549
|
}
|
|
539
550
|
),
|
|
540
551
|
h && /* @__PURE__ */ a("ul", { className: "select-input-options-container", role: "listbox", children: r.map((n, c) => {
|
|
541
|
-
const
|
|
552
|
+
const k = String(n.id) === String(y);
|
|
542
553
|
return /* @__PURE__ */ a(
|
|
543
554
|
"li",
|
|
544
555
|
{
|
|
545
556
|
role: "option",
|
|
546
|
-
"aria-selected":
|
|
557
|
+
"aria-selected": k,
|
|
547
558
|
className: d(
|
|
548
559
|
"select-input-option-item",
|
|
549
560
|
c === f ? "highlighted" : ""
|
|
550
561
|
),
|
|
551
562
|
onMouseEnter: () => g(c),
|
|
552
|
-
onClick: (
|
|
553
|
-
|
|
563
|
+
onClick: (_) => {
|
|
564
|
+
W(c), _.stopPropagation();
|
|
554
565
|
},
|
|
555
566
|
children: n.value ?? n.name ?? n.id
|
|
556
567
|
},
|
|
@@ -562,12 +573,12 @@ const Q = (l) => {
|
|
|
562
573
|
);
|
|
563
574
|
});
|
|
564
575
|
export {
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
576
|
+
ge as A,
|
|
577
|
+
Ce as C,
|
|
578
|
+
ye as S,
|
|
568
579
|
te as T,
|
|
569
|
-
|
|
580
|
+
Y as a,
|
|
570
581
|
ee as h,
|
|
571
|
-
|
|
572
|
-
|
|
582
|
+
J as i,
|
|
583
|
+
Q as l
|
|
573
584
|
};
|
|
@@ -4,7 +4,7 @@ import { c as O } from "./classNames-DDRjbGA1.js";
|
|
|
4
4
|
import { useState as V, useRef as B, useEffect as j, useMemo as S, useCallback as x, Fragment as ue } from "react";
|
|
5
5
|
import { u as J, a as $, F as pe } from "./FiltersProvider-iOkSYSFZ.js";
|
|
6
6
|
import { E as me, c as ae, C as ie, T as he, a as fe, b as be, B as ge, F as Ne } from "./TableColumns-CIddkosX.js";
|
|
7
|
-
import { C as re, A as Ce, S as te, T as Z } from "./SelectInput-
|
|
7
|
+
import { C as re, A as Ce, S as te, T as Z } from "./SelectInput-D09muy0T.js";
|
|
8
8
|
import { u as D } from "./TableOptionsProvider-Dzq4dOu8.js";
|
|
9
9
|
import { u as _ } from "./TranslationProvider-DNybGe-x.js";
|
|
10
10
|
import { I as U } from "./IconButton-CqPk_OXG.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var Ie=require("./Table.css");const e=require("react/jsx-runtime"),A=require("./classNames-DHAzUjfZ.cjs"),r=require("react"),k=require("./FiltersProvider-CnrF3xWV.cjs"),I=require("./TableColumns-BjTNomZf.cjs"),B=require("./SelectInput-CZrWA19u.cjs"),_=require("./TableOptionsProvider-bPNtpa4V.cjs"),E=require("./TranslationProvider-BmV4WUQy.cjs"),z=require("./IconButton-DVZCHIHB.cjs"),je=require("./Badge-DSSlox-y.cjs"),H=require("./lib.cjs"),J=require("./Button-BxyXUUMe.cjs"),X=require("./Chip-N4r2Xf9l.cjs"),Z=require("./Tooltip-B7LXJBLs.cjs"),ge=require("./query-81BrXp3i.cjs"),Ce=require("./Dropdown-B5wIF6xJ.cjs"),Ne=require("./Loading-C70yH2dC.cjs");function K(s){const{id:t,icon:a,tooltip:n,onClick:l,children:i,hidden:p=!1,disabled:c=!1,showText:u=!1,showTooltips:o=!0,className:m=""}=s;return p?null:e.jsxs("button",{type:"button",id:t,className:A.classNames("action",u?"text-action":"icon-action",m),disabled:c,"aria-label":n,onClick:d=>{d.stopPropagation(),l?.()},"aria-disabled":c,"data-tooltip-id":"tooltip","data-tooltip-content":o?n:"",children:[a," ",u&&n,i]})}function ee(s){const{actions:t=[],className:a="",itemClassName:n="",actionClassName:l="",showTooltips:i=!0,showActionTexts:p=!1}=s;return e.jsx("ul",{className:A.classNames("actions-container",a),children:t.map(c=>e.jsx("li",{className:A.classNames("actions-container-item",n),children:e.jsx(K,{showTooltips:i,showText:p,className:l,...c})},c.id))})}const te=s=>{const{actions:t=[],className:a=""}=s,{t:n}=E.useTranslation(),[l,i]=r.useState(!1),[p,c]=r.useState(null);return e.jsxs("div",{className:A.classNames("actions-dropdown",a),children:[e.jsx(z.IconButton,{icon:e.jsx(I.Ellipsis,{}),onClick:u=>{u.stopPropagation(),c(u.currentTarget),i(o=>!o)},onMouseDown:u=>u.stopPropagation(),className:"actions-dropdown-trigger","aria-label":n("_accessibility:buttons.openActions"),name:n("_accessibility:buttons.openActions"),"data-tooltip-id":"tooltip","data-tooltip-content":n("_accessibility:buttons.openActions")}),e.jsx(Ce.Dropdown,{open:l,onClose:()=>i(!1),anchorEl:p,children:e.jsx(ee,{showActionTexts:!0,actions:t,itemClassName:"w-full",actionClassName:"action-dropdown-item",className:"actions-dropdown-list",showTooltips:!1})})]})};function Q(s,t=[]){return[...s].sort((a,n)=>(n.pos??0)-(a.pos??0)).filter(a=>a.display!=="none"&&!t.includes(a.key))}function se(s){const{t}=E.useTranslation(),{entity:a="",columns:n=[],hasAction:l=!0,onSortCallback:i,selectionState:p,onToggleAllRows:c}=s,u=r.useRef(null);r.useEffect(()=>{u.current&&(u.current.indeterminate=!!(p?.hasSomeSelected&&!p?.allSelected))},[p]);const{onSort:o,sortingOrder:m,sortingBy:d,hiddenColumns:C}=_.useTableOptions(),x=r.useMemo(()=>Q(n,C).map(b=>({id:b.key,label:b.label,renderHead:b.renderHead,className:b.className??"",sortable:b.sortable??!0,sortOptions:b.sortOptions})),[n,a,t,C]);return e.jsx("thead",{className:"table-headers-row",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"table-headers-column table-headers-checkbox",children:c?e.jsx("input",{type:"checkbox",ref:u,checked:p?.allSelected??!1,onChange:c,"aria-label":t("_accessibility:components.table.selectAllRows")}):null}),l&&e.jsx("th",{scope:"col",className:"table-headers-action",children:e.jsx("span",{children:t("_accessibility:labels.actions")})}),x.map(b=>e.jsx("th",{scope:"col",className:A.classNames("table-headers-column",b.className),children:e.jsxs(J.Button,{disabled:!b.sortable,onClick:()=>o(b.id,i),className:"table-headers-cell",children:[b.renderHead?b.renderHead():e.jsx("span",{className:"table-headers-label",children:b.label}),b.sortable&&d===b.id&&e.jsx("span",{children:m===ge.SortOrder.ASC?b.sortOptions?.icons?.asc??e.jsx(I.ChevronUp,{className:b.sortOptions?.icons?.className??"table-headers-sort-indicator"}):b.sortOptions?.icons?.desc??e.jsx(I.ChevronDown,{className:b.sortOptions?.icons?.className??"table-headers-sort-indicator"})})]})},b.id))]})})}function ne(s){const{columns:t}=s,{hiddenColumns:a,toggleColumn:n}=_.useTableOptions(),{t:l}=E.useTranslation(),[i,p]=r.useState(!1),c=r.useRef(null),u=r.useMemo(()=>Q(t.filter(d=>d.hideable!==!1&&d.display!=="none"),[]),[t]),o=r.useCallback(()=>{p(d=>!d)},[]),m=r.useCallback(d=>{n(d)},[n]);return u.length===0?null:e.jsxs("div",{className:"column-visibility-menu",ref:c,children:[e.jsx(z.IconButton,{icon:e.jsx(I.TableColumns,{className:"column-visibility-icon"}),className:"normal column-visibility-trigger","aria-haspopup":"true","aria-expanded":i,onClick:o,children:e.jsx("span",{className:"table-header-sr",children:l("_accessibility:buttons.columns")})}),i&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"column-visibility-backdrop",onClick:()=>p(!1)}),e.jsx("div",{className:"column-visibility-dropdown",role:"menu",children:u.map(d=>e.jsx(B.CheckInput,{checked:!a.includes(d.key),onChange:()=>m(d.key),label:d.label??d.key,containerClassName:"column-visibility-item"},d.key))})]})]})}const le=s=>{const{items:t,text:a,id:n,onClearFilter:l}=s;return e.jsx(X.Chip,{text:`${a}: ${t.map(i=>i.value??i.name).join(", ")}`,onDelete:()=>l(n)})},ae=s=>{const{end:t,start:a,text:n,id:l,onClearFilter:i}=s,p=c=>c!==null&&typeof c<"u"&&c!=="";return e.jsx(X.Chip,{text:`${n}: ${p(a)?a:"♾️"} - ${p(t)?t:"♾️"}`,onDelete:()=>i(l)})},ye=s=>typeof s=="object"&&s!==null&&!Array.isArray(s)&&("start"in s||"end"in s),ie=s=>{const{filtersDefinition:t}=s,a=r.useMemo(()=>{const c={};return t.forEach(u=>{c[u.propertyName]=u.label??u.propertyName}),c},[t]),{filters:n,clearFilters:l}=_.useTableOptions(),i=r.useMemo(()=>Object.keys(n),[n]),p=r.useCallback(c=>{const u=n[c];return ye(u)?e.jsx(ae,{id:c,text:a[c],start:u.start,end:u.end,onClearFilter:l}):Array.isArray(u)?e.jsx(le,{id:c,text:a[c],items:u,onClearFilter:l}):e.jsx(X.Chip,{text:`${a[c]}: ${u?.value??u?.name??u}`,onDelete:()=>l(c)})},[n,a,l]);return e.jsx("ul",{className:"active-filters-main",children:i?.map(c=>e.jsx("li",{children:p(c)},c))})};function ve(s){const{propertyName:t,label:a,placeholder:n,options:l,multiple:i=!0}=s,{currentFilters:p,setCurrentFilters:c}=k.useFilters(),u=r.useMemo(()=>{const m=p[t]?.value;return typeof m>"u"?null:m},[p,t]),o=r.useCallback(m=>{c({type:k.FiltersActions.update,toUpdate:{[t]:{value:m}}})},[t,c]);return e.jsx(B.AutocompleteInput,{value:u,label:a,options:l,multiple:i,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:o,placeholder:n})}const we=s=>{const{propertyName:t,label:a}=s,{currentFilters:n,setCurrentFilters:l}=k.useFilters(),i=r.useMemo(()=>n[t]?.value??"",[n]),p=r.useCallback(c=>{l({type:k.FiltersActions.update,toUpdate:{[t]:{value:c.target.checked}}})},[]);return e.jsx(B.CheckInput,{label:a,checked:i??!1,onChange:p})};function Te(s){const{propertyName:t,options:a,label:n,placeholder:l}=s,{currentFilters:i,setCurrentFilters:p}=k.useFilters(),c=r.useMemo(()=>{const o=i[t]?.value;if(o===null||typeof o>"u")return a[0]?.id??"";if(typeof o=="object"&&!Array.isArray(o)){const m=o;return m.id??m.value??""}return o},[i,a,t]),u=r.useCallback(o=>{const m=a.find(d=>String(d.id)===o.target.value);p({type:k.FiltersActions.update,toUpdate:{[t]:{value:m?.id??o.target.value}}})},[a,t,p]);return e.jsx(B.SelectInput,{value:c,label:n,options:a,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:u,placeholder:l})}const Se=s=>{const{propertyName:t,label:a,placeholder:n}=s,{currentFilters:l,setCurrentFilters:i}=k.useFilters(),p=r.useMemo(()=>l[t]?.value??"",[l]),c=r.useCallback(u=>{i({type:k.FiltersActions.update,toUpdate:{[t]:{value:u.target.value}}})},[]);return e.jsx(B.TextInput,{value:p??"",label:a,onChange:c,containerClassName:"input-widget-container",helperTextClassName:"",placeholder:n})},Y=s=>{const{propertyName:t,label:a,inputType:n}=s,{t:l}=E.useTranslation(),{currentFilters:i,setCurrentFilters:p}=k.useFilters(),c=r.useRef(null),u=r.useRef(null),o=r.useCallback(d=>{p({type:k.FiltersActions.update,toUpdate:{[t]:{value:{end:u?.current?.value??null,start:d.target.value}}}})},[]),m=r.useCallback(d=>{p({type:k.FiltersActions.update,toUpdate:{[t]:{value:{start:c?.current?.value??null,end:d.target.value}}}})},[]);return e.jsxs("div",{className:"range-widget-container",children:[e.jsx("p",{className:"text-input-label input-widget-label input-label-normal",children:a}),e.jsxs("div",{className:"range-widget-row",children:[e.jsx(B.TextInput,{value:i[t]?.value?.start??"",placeholder:l("_accessibility:components.table.filters.range.start"),type:n,ref:c,onChange:o,containerClassName:"input-widget-container",helperTextClassName:""}),e.jsx(B.TextInput,{value:i[t]?.value?.end??"",placeholder:l("_accessibility:components.table.filters.range.end"),type:n,ref:u,onChange:m,containerClassName:"input-widget-container",helperTextClassName:""})]})]})},re=s=>{switch(s.type){case H.FilterTypes.text:return e.jsx(Se,{...s});case H.FilterTypes.number:return e.jsx(Y,{...s,inputType:"number"});case H.FilterTypes.date:return e.jsx(Y,{...s,inputType:"date"});case H.FilterTypes.select:return e.jsx(Te,{...s});case H.FilterTypes.autocomplete:return e.jsx(ve,{...s});case H.FilterTypes.check:return e.jsx(we,{...s})}return e.jsx(e.Fragment,{})},oe=s=>{const{filters:t=[],show:a,handleShow:n}=s,{onFilterApply:l}=_.useTableOptions(),{currentFilters:i,setCurrentFilters:p}=k.useFilters(),{t:c}=E.useTranslation(),u=r.useRef(null);return r.useEffect(()=>{const o=({target:d})=>{u.current&&(d?.closest(".filter-dropdown-trigger")||!a||u.current.contains(d)||n(!1))},m=({code:d})=>{!a||d!=="Escape"||n(!1)};return document.addEventListener("click",o),document.addEventListener("keydown",m),()=>{document.removeEventListener("click",o),document.removeEventListener("keydown",m)}},[n,a]),e.jsx("div",{className:A.classNames("filter-dropdown-backdrop",a?"opened":"closed"),children:e.jsxs("div",{className:"filter-popup",ref:u,children:[e.jsx("div",{className:"filter-title",children:c("_accessibility:buttons.filters")}),e.jsx("ul",{className:"filter-container",children:t.map(o=>e.jsx("li",{className:"filter-container-item",children:re(o)},o.propertyName))}),e.jsx("div",{className:"filter-footer",children:e.jsxs("ul",{className:"filter-buttons-row",children:[e.jsx("li",{children:e.jsx(J.Button,{type:"button",variant:"submit",onClick:()=>p({type:k.FiltersActions.reset,filters:t}),className:"filter-dropdown-button filter-dropdown-cancel",children:c("_accessibility:buttons.clear")})}),e.jsx("li",{children:e.jsx(J.Button,{type:"button",variant:"submit",color:"primary",className:"filter-dropdown-button filter-dropdown-submit",onClick:()=>{n(!1),l(i)},children:c("_accessibility:buttons.applyFilters")})})]})})]})})},ce=()=>{const{t:s}=E.useTranslation(),{total:t,pageSize:a,pageSizes:n,currentPage:l}=_.useTableOptions(),i=(l+1)*a>t?t:(l+1)*a;return e.jsxs("div",{className:"table-navigation-sizes",children:[n[0]<t&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[l*a+1," - ",i," ",s("_accessibility:components.table.of")]})}),e.jsx("p",{children:t})]})};function ke(){const{t:s}=E.useTranslation(),{total:t,pageSize:a,currentPage:n,setCurrentPage:l}=_.useTableOptions(),i=r.useMemo(()=>{const p=Math.ceil(t/a);return Array.from({length:p},(c,u)=>({id:u,value:u+1}))},[t,a]);return e.jsxs("div",{className:"jump-to-page",children:[e.jsx("p",{children:s("_accessibility:components.table.jumpToPage")}),e.jsx(B.SelectInput,{value:n,options:i,inputClassName:"jump-to-page-input",containerClassName:"jump-to-page-input-container",helperTextClassName:"hidden",onChange:p=>l(Number(p.target.value))})]})}const ue=()=>{const{t:s}=E.useTranslation(),{total:t,pageSize:a,currentPage:n,setCurrentPage:l}=_.useTableOptions(),i=Math.ceil(t/a),p=n<i-1;return e.jsxs("div",{className:"table-navigation-pages",children:[e.jsx(z.IconButton,{icon:e.jsx(I.ChevronLeft,{className:"table-navigation-icon"}),className:"table-navigation-buttons",disabled:n===0,"aria-label":s("_accessibility:buttons.previous"),name:s("_accessibility:buttons.previous"),onClick:()=>l(n-1)}),e.jsx(z.IconButton,{icon:e.jsx(I.ChevronRight,{className:"table-navigation-icon"}),disabled:!p,className:"table-navigation-buttons",name:s("_accessibility:buttons.next"),"aria-label":s("_accessibility:buttons.next"),onClick:()=>{p&&l(n+1)}})]})};function de(){const{t:s}=E.useTranslation(),{pageSizes:t,pageSize:a,setPageSize:n}=_.useTableOptions(),l=r.useMemo(()=>t?.map(i=>({id:i,value:i})),[t]);return e.jsxs("div",{className:"page-size",children:[e.jsx("p",{children:s("_accessibility:components.table.pageSizes")}),e.jsx(B.SelectInput,{value:a,options:l,inputClassName:"page-size-input",containerClassName:"page-size-input-container",helperTextClassName:"hidden",onChange:i=>n(Number(i.target.value))})]})}function pe(){return e.jsxs("div",{className:"table-footer",children:[e.jsx(ke,{}),e.jsx(de,{}),e.jsx(ce,{}),e.jsx(ue,{})]})}const Re=s=>s,me=s=>{const{t}=E.useTranslation(),{hiddenColumns:a}=_.useTableOptions(),{columns:n,softDeleteProperty:l="deletedAt",data:i,actions:p,selectedRows:c,expandedRows:u=[],onRowSelectionChange:o,onRowExpand:m}=s,d=r.useMemo(()=>Q(n,a),[n,a]),C=r.useMemo(()=>new Map(u.map(x=>[x.rowId,x])),[u]);return i?.map(x=>{const b=c.has(x.id),y=C.get(x.id),R=!!y,P=d.length+1+(p?1:0);return e.jsxs(r.Fragment,{children:[e.jsxs("tr",{className:A.classNames("table-row",m?"expandable":"",x[l]?"deleted-class":"",b?"selected":"",R?"expanded":""),onClick:()=>m?.(x),children:[e.jsx("td",{className:"table-row-cell table-row-checkbox",children:e.jsx("input",{type:"checkbox",checked:b,onClick:v=>v.stopPropagation(),onChange:()=>o(x),"aria-label":t("_accessibility:components.table.selectRow")})}),p?e.jsx("td",{className:"w-px",children:e.jsx("div",{className:"table-row-cell-action",children:(()=>{const v=p(x).filter(g=>!g.hidden),j=v.filter(g=>g.sticky),w=v.filter(g=>!g.sticky);return e.jsxs(e.Fragment,{children:[j.map(g=>e.jsx(Z.Tooltip,{content:g.tooltip,children:e.jsx(K,{...g,onClick:()=>g.onClick(x),className:"row-table-action"})},g.id)),w.length>0&&e.jsx(te,{actions:w})]})})()})}):null,d?.map((v,j)=>{const w=x[v.key],g=v.renderBody?v.renderBody(w,x):Re(w);return e.jsx("td",{className:A.classNames("table-row-cell",j===0?"basic":"",v.className??""),children:m&&j===0?e.jsxs("div",{className:"table-row-expand-content",children:[e.jsx("span",{className:"table-row-expand-indicator","aria-hidden":!0,"data-state":R?"expanded":"collapsed",children:R?e.jsx(I.ChevronUp,{className:"table-row-expand-chevron"}):e.jsx(I.ChevronDown,{className:"table-row-expand-chevron"})}),e.jsx("div",{className:"table-row-expand-value",children:g})]}):g},v.key)})]}),R&&y?.content!==null&&typeof y?.content<"u"&&e.jsx("tr",{className:"table-row-expanded",children:e.jsx("td",{className:"table-row-expanded-cell",colSpan:P,children:e.jsx("div",{className:A.classNames("table-row-expanded-content",y.isVisible?"open":"closed"),children:e.jsx("div",{className:"table-row-expanded-inner",children:y.content})})})})]},x.id)})};function he(){const{t:s}=E.useTranslation();return e.jsx("div",{className:"table-empty",children:e.jsx("p",{children:s("_accessibility:components.table.empty")})})}const be=s=>{const{columns:t,title:a,isLoading:n,toolbar:l,filterOptions:i,canHideColumns:p=!1,canReset:c=!1}=s,{countOfFilters:u,resetTableOptions:o}=_.useTableOptions(),{t:m}=E.useTranslation(),d=r.useMemo(()=>t?[...t].sort((j,w)=>(w.pos??0)-(j.pos??0)).filter(j=>!!j.filterOptions).map(j=>({...j.filterOptions,label:j.filterOptions?.label??j.label,propertyName:j.key})):[],[t]),[C,x]=r.useState(!1),b=r.useCallback(j=>{i?.dropdown?.setOpened?i.dropdown.setOpened(j??!1):x(j??!1)},[i]),y=r.useMemo(()=>i?.dropdown?.opened??C,[i,C]),R=d.length>0,P=R&&i?.button?.hide!==!0,v=R&&y;return e.jsxs("div",{className:A.classNames("table-header",v?"showing-filters":""),children:[e.jsxs("div",{children:[a&&e.jsx("h1",{className:"table-header-title",children:a}),n?null:e.jsxs("div",{className:"table-header-content",children:[l,p&&t&&e.jsx(ne,{columns:t}),c&&e.jsx(z.IconButton,{icon:e.jsx(I.BarsStaggered,{className:"reset-table-icon"}),className:"normal",onClick:o,children:e.jsx("span",{className:"table-header-sr",children:m("_accessibility:buttons.reset")})}),P&&e.jsxs(z.IconButton,{icon:i?.button?.icon??e.jsx(I.Filters,{className:"filter-dropdown-trigger-icon"}),className:"filter-dropdown-button normal filter-dropdown-trigger","aria-haspopup":"true",onClick:()=>b(!y),"aria-expanded":y,children:[e.jsx(je.Badge,{count:u,className:A.classNames(u>0?"show":"hide")}),e.jsx("span",{className:"table-header-sr",children:m("_accessibility:buttons.filters")}),e.jsx("wbr",{})]})]})]}),R&&e.jsx(oe,{filters:d,show:v,handleShow:b,options:i}),e.jsx(ie,{filtersDefinition:d})]})};function xe({count:s,multiActions:t,onActionClick:a}){const{t:n}=E.useTranslation();return e.jsxs("div",{className:"table-selection-bar",children:[e.jsx("p",{className:"table-selection-bar-count",children:n("_accessibility:components.table.selectedCount",{count:s})}),t.length>0&&e.jsx("div",{className:"table-selection-bar-actions",children:t.map(l=>e.jsx(Z.Tooltip,{content:l.tooltip,children:e.jsx(z.IconButton,{icon:l.icon,className:"multi-table-action",onClick:()=>a(l),disabled:l.disabled,"aria-label":l.tooltip})},l.id))})]})}const G=220;function Fe({data:s,allowMultipleExpandedRows:t,controlledExpandedRowId:a,onExpandedRowChange:n,onRowExpand:l,findRowById:i}){const[p,c]=r.useState(null),[u,o]=r.useState(null),[m,d]=r.useState(null),[C,x]=r.useState(null),[b,y]=r.useState(!1),[R,P]=r.useState(new Set),[v,j]=r.useState([]),w=r.useRef(null),g=r.useRef(null),D=r.useRef(new Map),M=typeof a<"u",O=t&&!M,T=M?a??null:p,L=r.useCallback(()=>{g.current&&(clearTimeout(g.current),g.current=null)},[]),F=r.useCallback(h=>{if(typeof h<"u"){const f=D.current.get(h);if(!f)return;clearTimeout(f),D.current.delete(h);return}D.current.forEach(f=>clearTimeout(f)),D.current.clear()},[]),U=r.useCallback(h=>{F(h),j(f=>f.some(S=>S.rowId===h)?f.map(S=>S.rowId===h?{...S,isVisible:!1}:S):f),D.current.set(h,setTimeout(()=>{j(f=>f.filter(N=>N.rowId!==h)),D.current.delete(h)},G))},[F]),W=r.useCallback((h,f)=>{F(h),j(N=>N.some(q=>q.rowId===h)?N.map(q=>q.rowId===h?{...q,content:f,isVisible:!1}:q):[...N,{rowId:h,content:f,isVisible:!1}]),requestAnimationFrame(()=>{j(N=>N.map(S=>S.rowId===h?{...S,isVisible:!0}:S))})},[F]);r.useEffect(()=>{if(!O)return;const h=new Set(s.map(f=>f.id));P(f=>{const N=new Set;return f.forEach(S=>{if(h.has(S)){N.add(S);return}F(S)}),N}),j(f=>(f.forEach(N=>{h.has(N.rowId)||F(N.rowId)}),f.filter(N=>h.has(N.rowId))))},[s,O,F]),r.useEffect(()=>{if(O)return;if(T===null){o(null),M&&(w.current=null);return}i(T)||(M||c(null),o(null),M&&(w.current=null))},[s,T,i,M,O]),r.useEffect(()=>{if(!O){if(L(),T===null||u===null){if(m===null){y(!1),x(null);return}y(!1),g.current=setTimeout(()=>{d(null),x(null),g.current=null},G);return}if(m===null){d(T),x(u),requestAnimationFrame(()=>y(!0));return}if(m===T){x(u),requestAnimationFrame(()=>y(!0));return}y(!1),g.current=setTimeout(()=>{d(T),x(u),requestAnimationFrame(()=>y(!0)),g.current=null},G)}},[L,u,T,O,m]),r.useEffect(()=>()=>{L(),F()},[L,F]),r.useEffect(()=>{if(!M)return;if(T===null){o(null),w.current=null;return}const h=i(T);if(!h){o(null),w.current=null;return}const f=w.current;o(l?.(h,f)??null),w.current=h},[T,i,M,l]);const fe=r.useCallback(h=>{if(O){if(R.has(h.id)){P($=>{const V=new Set($);return V.delete(h.id),V}),U(h.id),n?.(null,h);return}P($=>{const V=new Set($);return V.add(h.id),V});const q=l?.(h,null)??null;q!==null&&typeof q<"u"?W(h.id,q):(F(h.id),j($=>$.filter(V=>V.rowId!==h.id))),n?.(h,null);return}const f=T===h.id,N=f?h:i(T);if(M){n?.(f?null:h,N);return}if(f){c(null),o(null),n?.(null,h);return}c(h.id),o(l?.(h,N)??null),n?.(h,N)},[T,U,F,W,i,R,M,O,n,l]);return{expandedRowsToRender:r.useMemo(()=>O?v:m===null||C===null||typeof C>"u"?[]:[{rowId:m,content:C,isVisible:b}],[b,O,C,m,v]),onRowExpandChange:fe}}function Ae({actions:s,selectedRowsData:t}){const a=r.useMemo(()=>!s||!t.length?[]:t.reduce((l,i,p)=>{const c=s(i).filter(o=>o.multiple&&!o.hidden);if(p===0)return c;const u=new Map(l.map(o=>[o.id,o]));return c.reduce((o,m)=>{const d=u.get(m.id);return d&&o.push({...d,...m,disabled:m.disabled||d.disabled}),o},[])},[]),[s,t]),n=r.useCallback(l=>{if(t.length){if(l.onMultipleClick){l.onMultipleClick(t);return}t.forEach(i=>l.onClick(i))}},[t]);return{multiActions:a,handleMultipleActionClick:n}}function Ee({data:s,onRowSelect:t,onSelectedRowsChange:a}){const[n,l]=r.useState(new Set),i=r.useMemo(()=>s?.filter(o=>n.has(o.id))??[],[s,n]);r.useEffect(()=>{if(!s?.length){l(new Set);return}l(o=>{const m=new Set,d=new Set(s.map(C=>C.id));return o.forEach(C=>{d.has(C)&&m.add(C)}),m})},[s]),r.useEffect(()=>{a&&a(i)},[i,a]);const p=r.useCallback(o=>{l(m=>{const d=new Set(m);return d.has(o.id)?(d.delete(o.id),t?.(o,!1)):(d.add(o.id),t?.(o,!0)),d})},[t]),c=r.useCallback(()=>{l(o=>{const m=new Set(o),d=s??[],C=d.every(x=>m.has(x.id));return d.forEach(x=>{const b=m.has(x.id);C?b&&(m.delete(x.id),t?.(x,!1)):b||(m.add(x.id),t?.(x,!0))}),m})},[s,t]),u=r.useMemo(()=>{if(!s?.length)return{allSelected:!1,hasSomeSelected:!1};const o=s.every(d=>n.has(d.id)),m=s.some(d=>n.has(d.id));return{allSelected:o,hasSomeSelected:m}},[s,n]);return{selectedRows:n,selectedRowsData:i,selectionState:u,onRowSelectionChange:p,onToggleAllRows:c}}function Me(s){const{data:t,onSort:a,entity:n="",isLoading:l=!1,actions:i,columns:p=[],contentClassName:c="",className:u="",softDeleteProperty:o="deletedAt",onRowSelect:m,onSelectedRowsChange:d,allowMultipleExpandedRows:C=!1,expandedRowId:x,onExpandedRowChange:b,onRowExpand:y,...R}=s,P=r.useMemo(()=>!t?.length,[t]),v=r.useCallback(U=>U===null?null:t.find(W=>W.id===U)??null,[t]),{selectedRows:j,selectedRowsData:w,selectionState:g,onRowSelectionChange:D,onToggleAllRows:M}=Ee({data:t,onRowSelect:m,onSelectedRowsChange:d}),{expandedRowsToRender:O,onRowExpandChange:T}=Fe({data:t,allowMultipleExpandedRows:C,controlledExpandedRowId:x,onExpandedRowChange:b,onRowExpand:y,findRowById:v}),{multiActions:L,handleMultipleActionClick:F}=Ae({actions:i,selectedRowsData:w});return e.jsx(k.FiltersProvider,{children:e.jsxs("div",{className:A.classNames("table-main",u),children:[e.jsx(be,{columns:p,isLoading:l,...R}),l?e.jsx(Ne.Loading,{className:"table-loading"}):e.jsx(e.Fragment,{children:P?e.jsx(he,{}):e.jsxs(e.Fragment,{children:[!!w.length&&e.jsx(xe,{count:w.length,multiActions:L,onActionClick:F}),e.jsx("div",{className:A.classNames("table-body",c),children:e.jsxs("table",{className:"table-content",children:[e.jsx(se,{entity:n,columns:p,onSortCallback:a,hasAction:!!i,selectionState:g,onToggleAllRows:M}),e.jsx("tbody",{children:e.jsx(me,{data:t,actions:i,columns:p,softDeleteProperty:o,selectedRows:j,expandedRows:O,onRowSelectionChange:D,onRowExpand:y?T:void 0})})]})}),e.jsx(pe,{})]})})]})})}exports.Action=K;exports.Actions=ee;exports.ActionsDropdown=te;exports.ActiveFilters=ie;exports.ArrayChip=le;exports.ColumnVisibilityMenu=ne;exports.Columns=se;exports.CountOfTotal=ce;exports.FilterDropdown=oe;exports.Footer=pe;exports.Navigation=ue;exports.PageSize=de;exports.RangeChip=ae;exports.Rows=me;exports.Table=Me;exports.TableEmpty=he;exports.TableHeader=be;exports.TableSelectionBar=xe;exports.renderFilterComponent=re;
|
|
1
|
+
var Ie=require("./Table.css");const e=require("react/jsx-runtime"),A=require("./classNames-DHAzUjfZ.cjs"),r=require("react"),k=require("./FiltersProvider-CnrF3xWV.cjs"),I=require("./TableColumns-BjTNomZf.cjs"),B=require("./SelectInput-BrKnfhB0.cjs"),_=require("./TableOptionsProvider-bPNtpa4V.cjs"),E=require("./TranslationProvider-BmV4WUQy.cjs"),z=require("./IconButton-DVZCHIHB.cjs"),je=require("./Badge-DSSlox-y.cjs"),H=require("./lib.cjs"),J=require("./Button-BxyXUUMe.cjs"),X=require("./Chip-N4r2Xf9l.cjs"),Z=require("./Tooltip-B7LXJBLs.cjs"),ge=require("./query-81BrXp3i.cjs"),Ce=require("./Dropdown-B5wIF6xJ.cjs"),Ne=require("./Loading-C70yH2dC.cjs");function K(s){const{id:t,icon:a,tooltip:n,onClick:l,children:i,hidden:p=!1,disabled:c=!1,showText:u=!1,showTooltips:o=!0,className:m=""}=s;return p?null:e.jsxs("button",{type:"button",id:t,className:A.classNames("action",u?"text-action":"icon-action",m),disabled:c,"aria-label":n,onClick:d=>{d.stopPropagation(),l?.()},"aria-disabled":c,"data-tooltip-id":"tooltip","data-tooltip-content":o?n:"",children:[a," ",u&&n,i]})}function ee(s){const{actions:t=[],className:a="",itemClassName:n="",actionClassName:l="",showTooltips:i=!0,showActionTexts:p=!1}=s;return e.jsx("ul",{className:A.classNames("actions-container",a),children:t.map(c=>e.jsx("li",{className:A.classNames("actions-container-item",n),children:e.jsx(K,{showTooltips:i,showText:p,className:l,...c})},c.id))})}const te=s=>{const{actions:t=[],className:a=""}=s,{t:n}=E.useTranslation(),[l,i]=r.useState(!1),[p,c]=r.useState(null);return e.jsxs("div",{className:A.classNames("actions-dropdown",a),children:[e.jsx(z.IconButton,{icon:e.jsx(I.Ellipsis,{}),onClick:u=>{u.stopPropagation(),c(u.currentTarget),i(o=>!o)},onMouseDown:u=>u.stopPropagation(),className:"actions-dropdown-trigger","aria-label":n("_accessibility:buttons.openActions"),name:n("_accessibility:buttons.openActions"),"data-tooltip-id":"tooltip","data-tooltip-content":n("_accessibility:buttons.openActions")}),e.jsx(Ce.Dropdown,{open:l,onClose:()=>i(!1),anchorEl:p,children:e.jsx(ee,{showActionTexts:!0,actions:t,itemClassName:"w-full",actionClassName:"action-dropdown-item",className:"actions-dropdown-list",showTooltips:!1})})]})};function Q(s,t=[]){return[...s].sort((a,n)=>(n.pos??0)-(a.pos??0)).filter(a=>a.display!=="none"&&!t.includes(a.key))}function se(s){const{t}=E.useTranslation(),{entity:a="",columns:n=[],hasAction:l=!0,onSortCallback:i,selectionState:p,onToggleAllRows:c}=s,u=r.useRef(null);r.useEffect(()=>{u.current&&(u.current.indeterminate=!!(p?.hasSomeSelected&&!p?.allSelected))},[p]);const{onSort:o,sortingOrder:m,sortingBy:d,hiddenColumns:C}=_.useTableOptions(),x=r.useMemo(()=>Q(n,C).map(b=>({id:b.key,label:b.label,renderHead:b.renderHead,className:b.className??"",sortable:b.sortable??!0,sortOptions:b.sortOptions})),[n,a,t,C]);return e.jsx("thead",{className:"table-headers-row",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"table-headers-column table-headers-checkbox",children:c?e.jsx("input",{type:"checkbox",ref:u,checked:p?.allSelected??!1,onChange:c,"aria-label":t("_accessibility:components.table.selectAllRows")}):null}),l&&e.jsx("th",{scope:"col",className:"table-headers-action",children:e.jsx("span",{children:t("_accessibility:labels.actions")})}),x.map(b=>e.jsx("th",{scope:"col",className:A.classNames("table-headers-column",b.className),children:e.jsxs(J.Button,{disabled:!b.sortable,onClick:()=>o(b.id,i),className:"table-headers-cell",children:[b.renderHead?b.renderHead():e.jsx("span",{className:"table-headers-label",children:b.label}),b.sortable&&d===b.id&&e.jsx("span",{children:m===ge.SortOrder.ASC?b.sortOptions?.icons?.asc??e.jsx(I.ChevronUp,{className:b.sortOptions?.icons?.className??"table-headers-sort-indicator"}):b.sortOptions?.icons?.desc??e.jsx(I.ChevronDown,{className:b.sortOptions?.icons?.className??"table-headers-sort-indicator"})})]})},b.id))]})})}function ne(s){const{columns:t}=s,{hiddenColumns:a,toggleColumn:n}=_.useTableOptions(),{t:l}=E.useTranslation(),[i,p]=r.useState(!1),c=r.useRef(null),u=r.useMemo(()=>Q(t.filter(d=>d.hideable!==!1&&d.display!=="none"),[]),[t]),o=r.useCallback(()=>{p(d=>!d)},[]),m=r.useCallback(d=>{n(d)},[n]);return u.length===0?null:e.jsxs("div",{className:"column-visibility-menu",ref:c,children:[e.jsx(z.IconButton,{icon:e.jsx(I.TableColumns,{className:"column-visibility-icon"}),className:"normal column-visibility-trigger","aria-haspopup":"true","aria-expanded":i,onClick:o,children:e.jsx("span",{className:"table-header-sr",children:l("_accessibility:buttons.columns")})}),i&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"column-visibility-backdrop",onClick:()=>p(!1)}),e.jsx("div",{className:"column-visibility-dropdown",role:"menu",children:u.map(d=>e.jsx(B.CheckInput,{checked:!a.includes(d.key),onChange:()=>m(d.key),label:d.label??d.key,containerClassName:"column-visibility-item"},d.key))})]})]})}const le=s=>{const{items:t,text:a,id:n,onClearFilter:l}=s;return e.jsx(X.Chip,{text:`${a}: ${t.map(i=>i.value??i.name).join(", ")}`,onDelete:()=>l(n)})},ae=s=>{const{end:t,start:a,text:n,id:l,onClearFilter:i}=s,p=c=>c!==null&&typeof c<"u"&&c!=="";return e.jsx(X.Chip,{text:`${n}: ${p(a)?a:"♾️"} - ${p(t)?t:"♾️"}`,onDelete:()=>i(l)})},ye=s=>typeof s=="object"&&s!==null&&!Array.isArray(s)&&("start"in s||"end"in s),ie=s=>{const{filtersDefinition:t}=s,a=r.useMemo(()=>{const c={};return t.forEach(u=>{c[u.propertyName]=u.label??u.propertyName}),c},[t]),{filters:n,clearFilters:l}=_.useTableOptions(),i=r.useMemo(()=>Object.keys(n),[n]),p=r.useCallback(c=>{const u=n[c];return ye(u)?e.jsx(ae,{id:c,text:a[c],start:u.start,end:u.end,onClearFilter:l}):Array.isArray(u)?e.jsx(le,{id:c,text:a[c],items:u,onClearFilter:l}):e.jsx(X.Chip,{text:`${a[c]}: ${u?.value??u?.name??u}`,onDelete:()=>l(c)})},[n,a,l]);return e.jsx("ul",{className:"active-filters-main",children:i?.map(c=>e.jsx("li",{children:p(c)},c))})};function ve(s){const{propertyName:t,label:a,placeholder:n,options:l,multiple:i=!0}=s,{currentFilters:p,setCurrentFilters:c}=k.useFilters(),u=r.useMemo(()=>{const m=p[t]?.value;return typeof m>"u"?null:m},[p,t]),o=r.useCallback(m=>{c({type:k.FiltersActions.update,toUpdate:{[t]:{value:m}}})},[t,c]);return e.jsx(B.AutocompleteInput,{value:u,label:a,options:l,multiple:i,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:o,placeholder:n})}const we=s=>{const{propertyName:t,label:a}=s,{currentFilters:n,setCurrentFilters:l}=k.useFilters(),i=r.useMemo(()=>n[t]?.value??"",[n]),p=r.useCallback(c=>{l({type:k.FiltersActions.update,toUpdate:{[t]:{value:c.target.checked}}})},[]);return e.jsx(B.CheckInput,{label:a,checked:i??!1,onChange:p})};function Te(s){const{propertyName:t,options:a,label:n,placeholder:l}=s,{currentFilters:i,setCurrentFilters:p}=k.useFilters(),c=r.useMemo(()=>{const o=i[t]?.value;if(o===null||typeof o>"u")return a[0]?.id??"";if(typeof o=="object"&&!Array.isArray(o)){const m=o;return m.id??m.value??""}return o},[i,a,t]),u=r.useCallback(o=>{const m=a.find(d=>String(d.id)===o.target.value);p({type:k.FiltersActions.update,toUpdate:{[t]:{value:m?.id??o.target.value}}})},[a,t,p]);return e.jsx(B.SelectInput,{value:c,label:n,options:a,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:u,placeholder:l})}const Se=s=>{const{propertyName:t,label:a,placeholder:n}=s,{currentFilters:l,setCurrentFilters:i}=k.useFilters(),p=r.useMemo(()=>l[t]?.value??"",[l]),c=r.useCallback(u=>{i({type:k.FiltersActions.update,toUpdate:{[t]:{value:u.target.value}}})},[]);return e.jsx(B.TextInput,{value:p??"",label:a,onChange:c,containerClassName:"input-widget-container",helperTextClassName:"",placeholder:n})},Y=s=>{const{propertyName:t,label:a,inputType:n}=s,{t:l}=E.useTranslation(),{currentFilters:i,setCurrentFilters:p}=k.useFilters(),c=r.useRef(null),u=r.useRef(null),o=r.useCallback(d=>{p({type:k.FiltersActions.update,toUpdate:{[t]:{value:{end:u?.current?.value??null,start:d.target.value}}}})},[]),m=r.useCallback(d=>{p({type:k.FiltersActions.update,toUpdate:{[t]:{value:{start:c?.current?.value??null,end:d.target.value}}}})},[]);return e.jsxs("div",{className:"range-widget-container",children:[e.jsx("p",{className:"text-input-label input-widget-label input-label-normal",children:a}),e.jsxs("div",{className:"range-widget-row",children:[e.jsx(B.TextInput,{value:i[t]?.value?.start??"",placeholder:l("_accessibility:components.table.filters.range.start"),type:n,ref:c,onChange:o,containerClassName:"input-widget-container",helperTextClassName:""}),e.jsx(B.TextInput,{value:i[t]?.value?.end??"",placeholder:l("_accessibility:components.table.filters.range.end"),type:n,ref:u,onChange:m,containerClassName:"input-widget-container",helperTextClassName:""})]})]})},re=s=>{switch(s.type){case H.FilterTypes.text:return e.jsx(Se,{...s});case H.FilterTypes.number:return e.jsx(Y,{...s,inputType:"number"});case H.FilterTypes.date:return e.jsx(Y,{...s,inputType:"date"});case H.FilterTypes.select:return e.jsx(Te,{...s});case H.FilterTypes.autocomplete:return e.jsx(ve,{...s});case H.FilterTypes.check:return e.jsx(we,{...s})}return e.jsx(e.Fragment,{})},oe=s=>{const{filters:t=[],show:a,handleShow:n}=s,{onFilterApply:l}=_.useTableOptions(),{currentFilters:i,setCurrentFilters:p}=k.useFilters(),{t:c}=E.useTranslation(),u=r.useRef(null);return r.useEffect(()=>{const o=({target:d})=>{u.current&&(d?.closest(".filter-dropdown-trigger")||!a||u.current.contains(d)||n(!1))},m=({code:d})=>{!a||d!=="Escape"||n(!1)};return document.addEventListener("click",o),document.addEventListener("keydown",m),()=>{document.removeEventListener("click",o),document.removeEventListener("keydown",m)}},[n,a]),e.jsx("div",{className:A.classNames("filter-dropdown-backdrop",a?"opened":"closed"),children:e.jsxs("div",{className:"filter-popup",ref:u,children:[e.jsx("div",{className:"filter-title",children:c("_accessibility:buttons.filters")}),e.jsx("ul",{className:"filter-container",children:t.map(o=>e.jsx("li",{className:"filter-container-item",children:re(o)},o.propertyName))}),e.jsx("div",{className:"filter-footer",children:e.jsxs("ul",{className:"filter-buttons-row",children:[e.jsx("li",{children:e.jsx(J.Button,{type:"button",variant:"submit",onClick:()=>p({type:k.FiltersActions.reset,filters:t}),className:"filter-dropdown-button filter-dropdown-cancel",children:c("_accessibility:buttons.clear")})}),e.jsx("li",{children:e.jsx(J.Button,{type:"button",variant:"submit",color:"primary",className:"filter-dropdown-button filter-dropdown-submit",onClick:()=>{n(!1),l(i)},children:c("_accessibility:buttons.applyFilters")})})]})})]})})},ce=()=>{const{t:s}=E.useTranslation(),{total:t,pageSize:a,pageSizes:n,currentPage:l}=_.useTableOptions(),i=(l+1)*a>t?t:(l+1)*a;return e.jsxs("div",{className:"table-navigation-sizes",children:[n[0]<t&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[l*a+1," - ",i," ",s("_accessibility:components.table.of")]})}),e.jsx("p",{children:t})]})};function ke(){const{t:s}=E.useTranslation(),{total:t,pageSize:a,currentPage:n,setCurrentPage:l}=_.useTableOptions(),i=r.useMemo(()=>{const p=Math.ceil(t/a);return Array.from({length:p},(c,u)=>({id:u,value:u+1}))},[t,a]);return e.jsxs("div",{className:"jump-to-page",children:[e.jsx("p",{children:s("_accessibility:components.table.jumpToPage")}),e.jsx(B.SelectInput,{value:n,options:i,inputClassName:"jump-to-page-input",containerClassName:"jump-to-page-input-container",helperTextClassName:"hidden",onChange:p=>l(Number(p.target.value))})]})}const ue=()=>{const{t:s}=E.useTranslation(),{total:t,pageSize:a,currentPage:n,setCurrentPage:l}=_.useTableOptions(),i=Math.ceil(t/a),p=n<i-1;return e.jsxs("div",{className:"table-navigation-pages",children:[e.jsx(z.IconButton,{icon:e.jsx(I.ChevronLeft,{className:"table-navigation-icon"}),className:"table-navigation-buttons",disabled:n===0,"aria-label":s("_accessibility:buttons.previous"),name:s("_accessibility:buttons.previous"),onClick:()=>l(n-1)}),e.jsx(z.IconButton,{icon:e.jsx(I.ChevronRight,{className:"table-navigation-icon"}),disabled:!p,className:"table-navigation-buttons",name:s("_accessibility:buttons.next"),"aria-label":s("_accessibility:buttons.next"),onClick:()=>{p&&l(n+1)}})]})};function de(){const{t:s}=E.useTranslation(),{pageSizes:t,pageSize:a,setPageSize:n}=_.useTableOptions(),l=r.useMemo(()=>t?.map(i=>({id:i,value:i})),[t]);return e.jsxs("div",{className:"page-size",children:[e.jsx("p",{children:s("_accessibility:components.table.pageSizes")}),e.jsx(B.SelectInput,{value:a,options:l,inputClassName:"page-size-input",containerClassName:"page-size-input-container",helperTextClassName:"hidden",onChange:i=>n(Number(i.target.value))})]})}function pe(){return e.jsxs("div",{className:"table-footer",children:[e.jsx(ke,{}),e.jsx(de,{}),e.jsx(ce,{}),e.jsx(ue,{})]})}const Re=s=>s,me=s=>{const{t}=E.useTranslation(),{hiddenColumns:a}=_.useTableOptions(),{columns:n,softDeleteProperty:l="deletedAt",data:i,actions:p,selectedRows:c,expandedRows:u=[],onRowSelectionChange:o,onRowExpand:m}=s,d=r.useMemo(()=>Q(n,a),[n,a]),C=r.useMemo(()=>new Map(u.map(x=>[x.rowId,x])),[u]);return i?.map(x=>{const b=c.has(x.id),y=C.get(x.id),R=!!y,P=d.length+1+(p?1:0);return e.jsxs(r.Fragment,{children:[e.jsxs("tr",{className:A.classNames("table-row",m?"expandable":"",x[l]?"deleted-class":"",b?"selected":"",R?"expanded":""),onClick:()=>m?.(x),children:[e.jsx("td",{className:"table-row-cell table-row-checkbox",children:e.jsx("input",{type:"checkbox",checked:b,onClick:v=>v.stopPropagation(),onChange:()=>o(x),"aria-label":t("_accessibility:components.table.selectRow")})}),p?e.jsx("td",{className:"w-px",children:e.jsx("div",{className:"table-row-cell-action",children:(()=>{const v=p(x).filter(g=>!g.hidden),j=v.filter(g=>g.sticky),w=v.filter(g=>!g.sticky);return e.jsxs(e.Fragment,{children:[j.map(g=>e.jsx(Z.Tooltip,{content:g.tooltip,children:e.jsx(K,{...g,onClick:()=>g.onClick(x),className:"row-table-action"})},g.id)),w.length>0&&e.jsx(te,{actions:w})]})})()})}):null,d?.map((v,j)=>{const w=x[v.key],g=v.renderBody?v.renderBody(w,x):Re(w);return e.jsx("td",{className:A.classNames("table-row-cell",j===0?"basic":"",v.className??""),children:m&&j===0?e.jsxs("div",{className:"table-row-expand-content",children:[e.jsx("span",{className:"table-row-expand-indicator","aria-hidden":!0,"data-state":R?"expanded":"collapsed",children:R?e.jsx(I.ChevronUp,{className:"table-row-expand-chevron"}):e.jsx(I.ChevronDown,{className:"table-row-expand-chevron"})}),e.jsx("div",{className:"table-row-expand-value",children:g})]}):g},v.key)})]}),R&&y?.content!==null&&typeof y?.content<"u"&&e.jsx("tr",{className:"table-row-expanded",children:e.jsx("td",{className:"table-row-expanded-cell",colSpan:P,children:e.jsx("div",{className:A.classNames("table-row-expanded-content",y.isVisible?"open":"closed"),children:e.jsx("div",{className:"table-row-expanded-inner",children:y.content})})})})]},x.id)})};function he(){const{t:s}=E.useTranslation();return e.jsx("div",{className:"table-empty",children:e.jsx("p",{children:s("_accessibility:components.table.empty")})})}const be=s=>{const{columns:t,title:a,isLoading:n,toolbar:l,filterOptions:i,canHideColumns:p=!1,canReset:c=!1}=s,{countOfFilters:u,resetTableOptions:o}=_.useTableOptions(),{t:m}=E.useTranslation(),d=r.useMemo(()=>t?[...t].sort((j,w)=>(w.pos??0)-(j.pos??0)).filter(j=>!!j.filterOptions).map(j=>({...j.filterOptions,label:j.filterOptions?.label??j.label,propertyName:j.key})):[],[t]),[C,x]=r.useState(!1),b=r.useCallback(j=>{i?.dropdown?.setOpened?i.dropdown.setOpened(j??!1):x(j??!1)},[i]),y=r.useMemo(()=>i?.dropdown?.opened??C,[i,C]),R=d.length>0,P=R&&i?.button?.hide!==!0,v=R&&y;return e.jsxs("div",{className:A.classNames("table-header",v?"showing-filters":""),children:[e.jsxs("div",{children:[a&&e.jsx("h1",{className:"table-header-title",children:a}),n?null:e.jsxs("div",{className:"table-header-content",children:[l,p&&t&&e.jsx(ne,{columns:t}),c&&e.jsx(z.IconButton,{icon:e.jsx(I.BarsStaggered,{className:"reset-table-icon"}),className:"normal",onClick:o,children:e.jsx("span",{className:"table-header-sr",children:m("_accessibility:buttons.reset")})}),P&&e.jsxs(z.IconButton,{icon:i?.button?.icon??e.jsx(I.Filters,{className:"filter-dropdown-trigger-icon"}),className:"filter-dropdown-button normal filter-dropdown-trigger","aria-haspopup":"true",onClick:()=>b(!y),"aria-expanded":y,children:[e.jsx(je.Badge,{count:u,className:A.classNames(u>0?"show":"hide")}),e.jsx("span",{className:"table-header-sr",children:m("_accessibility:buttons.filters")}),e.jsx("wbr",{})]})]})]}),R&&e.jsx(oe,{filters:d,show:v,handleShow:b,options:i}),e.jsx(ie,{filtersDefinition:d})]})};function xe({count:s,multiActions:t,onActionClick:a}){const{t:n}=E.useTranslation();return e.jsxs("div",{className:"table-selection-bar",children:[e.jsx("p",{className:"table-selection-bar-count",children:n("_accessibility:components.table.selectedCount",{count:s})}),t.length>0&&e.jsx("div",{className:"table-selection-bar-actions",children:t.map(l=>e.jsx(Z.Tooltip,{content:l.tooltip,children:e.jsx(z.IconButton,{icon:l.icon,className:"multi-table-action",onClick:()=>a(l),disabled:l.disabled,"aria-label":l.tooltip})},l.id))})]})}const G=220;function Fe({data:s,allowMultipleExpandedRows:t,controlledExpandedRowId:a,onExpandedRowChange:n,onRowExpand:l,findRowById:i}){const[p,c]=r.useState(null),[u,o]=r.useState(null),[m,d]=r.useState(null),[C,x]=r.useState(null),[b,y]=r.useState(!1),[R,P]=r.useState(new Set),[v,j]=r.useState([]),w=r.useRef(null),g=r.useRef(null),D=r.useRef(new Map),M=typeof a<"u",O=t&&!M,T=M?a??null:p,L=r.useCallback(()=>{g.current&&(clearTimeout(g.current),g.current=null)},[]),F=r.useCallback(h=>{if(typeof h<"u"){const f=D.current.get(h);if(!f)return;clearTimeout(f),D.current.delete(h);return}D.current.forEach(f=>clearTimeout(f)),D.current.clear()},[]),U=r.useCallback(h=>{F(h),j(f=>f.some(S=>S.rowId===h)?f.map(S=>S.rowId===h?{...S,isVisible:!1}:S):f),D.current.set(h,setTimeout(()=>{j(f=>f.filter(N=>N.rowId!==h)),D.current.delete(h)},G))},[F]),W=r.useCallback((h,f)=>{F(h),j(N=>N.some(q=>q.rowId===h)?N.map(q=>q.rowId===h?{...q,content:f,isVisible:!1}:q):[...N,{rowId:h,content:f,isVisible:!1}]),requestAnimationFrame(()=>{j(N=>N.map(S=>S.rowId===h?{...S,isVisible:!0}:S))})},[F]);r.useEffect(()=>{if(!O)return;const h=new Set(s.map(f=>f.id));P(f=>{const N=new Set;return f.forEach(S=>{if(h.has(S)){N.add(S);return}F(S)}),N}),j(f=>(f.forEach(N=>{h.has(N.rowId)||F(N.rowId)}),f.filter(N=>h.has(N.rowId))))},[s,O,F]),r.useEffect(()=>{if(O)return;if(T===null){o(null),M&&(w.current=null);return}i(T)||(M||c(null),o(null),M&&(w.current=null))},[s,T,i,M,O]),r.useEffect(()=>{if(!O){if(L(),T===null||u===null){if(m===null){y(!1),x(null);return}y(!1),g.current=setTimeout(()=>{d(null),x(null),g.current=null},G);return}if(m===null){d(T),x(u),requestAnimationFrame(()=>y(!0));return}if(m===T){x(u),requestAnimationFrame(()=>y(!0));return}y(!1),g.current=setTimeout(()=>{d(T),x(u),requestAnimationFrame(()=>y(!0)),g.current=null},G)}},[L,u,T,O,m]),r.useEffect(()=>()=>{L(),F()},[L,F]),r.useEffect(()=>{if(!M)return;if(T===null){o(null),w.current=null;return}const h=i(T);if(!h){o(null),w.current=null;return}const f=w.current;o(l?.(h,f)??null),w.current=h},[T,i,M,l]);const fe=r.useCallback(h=>{if(O){if(R.has(h.id)){P($=>{const V=new Set($);return V.delete(h.id),V}),U(h.id),n?.(null,h);return}P($=>{const V=new Set($);return V.add(h.id),V});const q=l?.(h,null)??null;q!==null&&typeof q<"u"?W(h.id,q):(F(h.id),j($=>$.filter(V=>V.rowId!==h.id))),n?.(h,null);return}const f=T===h.id,N=f?h:i(T);if(M){n?.(f?null:h,N);return}if(f){c(null),o(null),n?.(null,h);return}c(h.id),o(l?.(h,N)??null),n?.(h,N)},[T,U,F,W,i,R,M,O,n,l]);return{expandedRowsToRender:r.useMemo(()=>O?v:m===null||C===null||typeof C>"u"?[]:[{rowId:m,content:C,isVisible:b}],[b,O,C,m,v]),onRowExpandChange:fe}}function Ae({actions:s,selectedRowsData:t}){const a=r.useMemo(()=>!s||!t.length?[]:t.reduce((l,i,p)=>{const c=s(i).filter(o=>o.multiple&&!o.hidden);if(p===0)return c;const u=new Map(l.map(o=>[o.id,o]));return c.reduce((o,m)=>{const d=u.get(m.id);return d&&o.push({...d,...m,disabled:m.disabled||d.disabled}),o},[])},[]),[s,t]),n=r.useCallback(l=>{if(t.length){if(l.onMultipleClick){l.onMultipleClick(t);return}t.forEach(i=>l.onClick(i))}},[t]);return{multiActions:a,handleMultipleActionClick:n}}function Ee({data:s,onRowSelect:t,onSelectedRowsChange:a}){const[n,l]=r.useState(new Set),i=r.useMemo(()=>s?.filter(o=>n.has(o.id))??[],[s,n]);r.useEffect(()=>{if(!s?.length){l(new Set);return}l(o=>{const m=new Set,d=new Set(s.map(C=>C.id));return o.forEach(C=>{d.has(C)&&m.add(C)}),m})},[s]),r.useEffect(()=>{a&&a(i)},[i,a]);const p=r.useCallback(o=>{l(m=>{const d=new Set(m);return d.has(o.id)?(d.delete(o.id),t?.(o,!1)):(d.add(o.id),t?.(o,!0)),d})},[t]),c=r.useCallback(()=>{l(o=>{const m=new Set(o),d=s??[],C=d.every(x=>m.has(x.id));return d.forEach(x=>{const b=m.has(x.id);C?b&&(m.delete(x.id),t?.(x,!1)):b||(m.add(x.id),t?.(x,!0))}),m})},[s,t]),u=r.useMemo(()=>{if(!s?.length)return{allSelected:!1,hasSomeSelected:!1};const o=s.every(d=>n.has(d.id)),m=s.some(d=>n.has(d.id));return{allSelected:o,hasSomeSelected:m}},[s,n]);return{selectedRows:n,selectedRowsData:i,selectionState:u,onRowSelectionChange:p,onToggleAllRows:c}}function Me(s){const{data:t,onSort:a,entity:n="",isLoading:l=!1,actions:i,columns:p=[],contentClassName:c="",className:u="",softDeleteProperty:o="deletedAt",onRowSelect:m,onSelectedRowsChange:d,allowMultipleExpandedRows:C=!1,expandedRowId:x,onExpandedRowChange:b,onRowExpand:y,...R}=s,P=r.useMemo(()=>!t?.length,[t]),v=r.useCallback(U=>U===null?null:t.find(W=>W.id===U)??null,[t]),{selectedRows:j,selectedRowsData:w,selectionState:g,onRowSelectionChange:D,onToggleAllRows:M}=Ee({data:t,onRowSelect:m,onSelectedRowsChange:d}),{expandedRowsToRender:O,onRowExpandChange:T}=Fe({data:t,allowMultipleExpandedRows:C,controlledExpandedRowId:x,onExpandedRowChange:b,onRowExpand:y,findRowById:v}),{multiActions:L,handleMultipleActionClick:F}=Ae({actions:i,selectedRowsData:w});return e.jsx(k.FiltersProvider,{children:e.jsxs("div",{className:A.classNames("table-main",u),children:[e.jsx(be,{columns:p,isLoading:l,...R}),l?e.jsx(Ne.Loading,{className:"table-loading"}):e.jsx(e.Fragment,{children:P?e.jsx(he,{}):e.jsxs(e.Fragment,{children:[!!w.length&&e.jsx(xe,{count:w.length,multiActions:L,onActionClick:F}),e.jsx("div",{className:A.classNames("table-body",c),children:e.jsxs("table",{className:"table-content",children:[e.jsx(se,{entity:n,columns:p,onSortCallback:a,hasAction:!!i,selectionState:g,onToggleAllRows:M}),e.jsx("tbody",{children:e.jsx(me,{data:t,actions:i,columns:p,softDeleteProperty:o,selectedRows:j,expandedRows:O,onRowSelectionChange:D,onRowExpand:y?T:void 0})})]})}),e.jsx(pe,{})]})})]})})}exports.Action=K;exports.Actions=ee;exports.ActionsDropdown=te;exports.ActiveFilters=ie;exports.ArrayChip=le;exports.ColumnVisibilityMenu=ne;exports.Columns=se;exports.CountOfTotal=ce;exports.FilterDropdown=oe;exports.Footer=pe;exports.Navigation=ue;exports.PageSize=de;exports.RangeChip=ae;exports.Rows=me;exports.Table=Me;exports.TableEmpty=he;exports.TableHeader=be;exports.TableSelectionBar=xe;exports.renderFilterComponent=re;
|
package/dist/Table.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Table-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Table-CRXmixBI.cjs");exports.ActiveFilters=e.ActiveFilters;exports.ArrayChip=e.ArrayChip;exports.ColumnVisibilityMenu=e.ColumnVisibilityMenu;exports.Columns=e.Columns;exports.CountOfTotal=e.CountOfTotal;exports.FilterDropdown=e.FilterDropdown;exports.Footer=e.Footer;exports.Navigation=e.Navigation;exports.PageSize=e.PageSize;exports.RangeChip=e.RangeChip;exports.Rows=e.Rows;exports.Table=e.Table;exports.TableEmpty=e.TableEmpty;exports.TableHeader=e.TableHeader;exports.TableSelectionBar=e.TableSelectionBar;exports.renderFilterComponent=e.renderFilterComponent;
|
package/dist/Table.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as s, b as o, a as i, C as r, c as t, F as l, d as n, N as C, P as b, R as p, e as T, h as m, T as F, f as d, g, r as u } from "./Table-
|
|
1
|
+
import { A as s, b as o, a as i, C as r, c as t, F as l, d as n, N as C, P as b, R as p, e as T, h as m, T as F, f as d, g, r as u } from "./Table-ARgTVSwK.js";
|
|
2
2
|
export {
|
|
3
3
|
s as ActiveFilters,
|
|
4
4
|
o as ArrayChip,
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var h=require("./index.css");Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./classNames-DHAzUjfZ.cjs"),l=require("./lib.cjs"),a=require("./query-81BrXp3i.cjs"),e=require("./Table-
|
|
1
|
+
var h=require("./index.css");Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./classNames-DHAzUjfZ.cjs"),l=require("./lib.cjs"),a=require("./query-81BrXp3i.cjs"),e=require("./Table-CRXmixBI.cjs"),u=require("./Badge-DSSlox-y.cjs"),p=require("./Button-BxyXUUMe.cjs"),c=require("./Chip-N4r2Xf9l.cjs"),C=require("./Dropdown-B5wIF6xJ.cjs"),t=require("./SelectInput-BrKnfhB0.cjs"),d=require("./FileInput-Cz2R3z3k.cjs"),T=require("./IconButton-DVZCHIHB.cjs"),F=require("./Loading-C70yH2dC.cjs"),r=require("./TableColumns-BjTNomZf.cjs"),b=require("./Close-O9P7wJGf.cjs"),m=require("./File-_Hjw2d3F.cjs"),v=require("./Tooltip-B7LXJBLs.cjs"),o=require("./FiltersProvider-CnrF3xWV.cjs"),i=require("./TableOptionsProvider-bPNtpa4V.cjs"),n=require("./TranslationProvider-BmV4WUQy.cjs");exports.classNames=s.classNames;exports.FilterTypes=l.FilterTypes;exports.SortOrder=a.SortOrder;exports.Action=e.Action;exports.Actions=e.Actions;exports.ActionsDropdown=e.ActionsDropdown;exports.ActiveFilters=e.ActiveFilters;exports.ArrayChip=e.ArrayChip;exports.ColumnVisibilityMenu=e.ColumnVisibilityMenu;exports.Columns=e.Columns;exports.CountOfTotal=e.CountOfTotal;exports.FilterDropdown=e.FilterDropdown;exports.Footer=e.Footer;exports.Navigation=e.Navigation;exports.PageSize=e.PageSize;exports.RangeChip=e.RangeChip;exports.Rows=e.Rows;exports.Table=e.Table;exports.TableEmpty=e.TableEmpty;exports.TableHeader=e.TableHeader;exports.TableSelectionBar=e.TableSelectionBar;exports.renderFilterComponent=e.renderFilterComponent;exports.Badge=u.Badge;exports.Button=p.Button;exports.Chip=c.Chip;exports.Dropdown=C.Dropdown;exports.AutocompleteInput=t.AutocompleteInput;exports.CheckInput=t.CheckInput;exports.SelectInput=t.SelectInput;exports.State=t.State;exports.TextInput=t.TextInput;exports.helperTextStateClassName=t.helperTextStateClassName;exports.inputStateClassName=t.inputStateClassName;exports.labelStateClassName=t.labelStateClassName;exports.FileInput=d.FileInput;exports.IconButton=T.IconButton;exports.Loading=F.Loading;exports.BarsStaggered=r.BarsStaggered;exports.ChevronDown=r.ChevronDown;exports.ChevronLeft=r.ChevronLeft;exports.ChevronRight=r.ChevronRight;exports.ChevronUp=r.ChevronUp;exports.Ellipsis=r.Ellipsis;exports.Filters=r.Filters;exports.TableColumns=r.TableColumns;exports.Close=b.Close;exports.File=m.File;exports.Tooltip=v.Tooltip;exports.FiltersActions=o.FiltersActions;exports.FiltersProvider=o.FiltersProvider;exports.filtersReducer=o.filtersReducer;exports.initializer=o.initializer;exports.useFilters=o.useFilters;exports.TableOptionsProvider=i.TableOptionsProvider;exports.useTableOptions=i.useTableOptions;exports.TranslationProvider=n.TranslationProvider;exports.useTranslation=n.useTranslation;
|
package/dist/index.js
CHANGED
|
@@ -2,12 +2,12 @@ import "./index.css";
|
|
|
2
2
|
import { c as o } from "./classNames-DDRjbGA1.js";
|
|
3
3
|
import { FilterTypes as t } from "./lib.js";
|
|
4
4
|
import { S as p } from "./query-CwuehjY1.js";
|
|
5
|
-
import { i as n, j as m, k as f, A as C, b as u, a as x, C as T, c as F, F as c, d, N as h, P as b, R as S, e as g, h as v, T as A, f as B, g as I, r as N } from "./Table-
|
|
5
|
+
import { i as n, j as m, k as f, A as C, b as u, a as x, C as T, c as F, F as c, d, N as h, P as b, R as S, e as g, h as v, T as A, f as B, g as I, r as N } from "./Table-ARgTVSwK.js";
|
|
6
6
|
import { B as D } from "./Badge-DW9i2Rh6.js";
|
|
7
7
|
import { B as R } from "./Button-C6icqzyN.js";
|
|
8
8
|
import { C as O } from "./Chip-6bEZ7uwv.js";
|
|
9
9
|
import { D as L } from "./Dropdown-dwdbhj_o.js";
|
|
10
|
-
import { A as z, C as j, S as H, a as M, T as U, h as V, i as q, l as G } from "./SelectInput-
|
|
10
|
+
import { A as z, C as j, S as H, a as M, T as U, h as V, i as q, l as G } from "./SelectInput-D09muy0T.js";
|
|
11
11
|
import { F as K } from "./FileInput-C7ZYKt_i.js";
|
|
12
12
|
import { I as W } from "./IconButton-CqPk_OXG.js";
|
|
13
13
|
import { L as Y } from "./Loading-BTwXNOEv.js";
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var se=require("./SelectInput.css");const n=require("react/jsx-runtime"),h=require("./classNames-DHAzUjfZ.cjs"),r=require("react"),_=require("./Chip-N4r2Xf9l.cjs"),Y=require("./IconButton-DVZCHIHB.cjs"),Z=require("./Close-O9P7wJGf.cjs"),ee=r.forwardRef(function(l,C){const{state:N,value:t,onChange:s,options:v=[],name:A="",id:w="",label:b="",containerClassName:I="",inputContainerClassName:k="",helperText:D="",placeholder:R="",multiple:f=!1,required:E=!1,"aria-required":u=!1,...T}=l,O=u===!0||String(u).toLowerCase()==="true",L=!!(E||O),F=f&&Array.isArray(t)&&t.length>0,B=L&&!F,[j,p]=r.useState("");r.useEffect(()=>{if(!f&&t&&!Array.isArray(t)){p(String(t.value??t.name??""));return}p("")},[f,t]);const[c,g]=r.useState(!1),[x,o]=r.useState(-1),m=r.useMemo(()=>v.filter(e=>{const i=String(e.value??e.name).toLowerCase().includes(j?.toLowerCase());return Array.isArray(t)&&t.length?i&&!t.some(y=>y.id===e.id):t&&!Array.isArray(t)?i&&t.id!==e.id:i}),[v,t,j]);r.useEffect(()=>{if(!c||!m.length){o(-1);return}o(0)},[c,m]);const q=r.useRef(null),H=r.useRef(null),[M,W]=r.useState(!1),a=r.useRef(null);r.useEffect(()=>{const e=y=>{q.current&&!q.current.contains(y.target)&&g(!1)},i=y=>{y.key==="Escape"&&g(!1)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",i)}},[]);const d=r.useCallback(e=>{p(e.target.value)},[]),S=r.useCallback(e=>{e?f?(p(""),Array.isArray(t)&&t.length?s([...t,e]):s([e])):(p(String(e.name??e.value??"")),s(e)):s(null),g(!1)},[f,s,t]),$=r.useCallback(e=>{if(!m.length){e.key==="Escape"&&g(!1);return}if(e.key==="ArrowDown"||e.key==="ArrowUp"){if(e.preventDefault(),!c){g(!0),o(0);return}o(i=>{const y=i>=0?i:0;return e.key==="ArrowDown"?(y+1+m.length)%m.length:(y-1+m.length)%m.length});return}if(e.key==="Enter"&&c){e.preventDefault();const i=x>=0?x:0;S(m[i]);return}e.key==="Escape"&&c&&(e.preventDefault(),g(!1))},[S,x,c,m]),K=r.useCallback(e=>{if(!Array.isArray(t)){s(null);return}const i=t.filter((y,X)=>X!==e);i.length?s(i):s(null)},[s,t]),Q=r.useCallback(()=>{Array.isArray(t)&&s([t[0]])},[s,t]);return r.useLayoutEffect(()=>{const e=a.current?.offsetWidth??0,i=q.current?.offsetWidth??0;W(e>i*.4)},[t]),n.jsxs("div",{className:h.classNames("autocomplete-input-container",I),ref:q,children:[n.jsxs("div",{className:"autocomplete-value-input-container",children:[n.jsx(G,{state:N,name:A,id:w,value:j,onChange:d,placeholder:R,helperText:D,onFocus:()=>g(!0),onKeyDown:$,label:b,containerClassName:h.classNames("autocomplete-text-input",k),required:B,"aria-required":L,ref:C??H,...T,children:!f&&t&&!Array.isArray(t)&&(t.value||t.name)&&n.jsx(Y.IconButton,{icon:n.jsx(Z.Close,{}),className:"autocomplete-delete-button",onClick:e=>{S(),e.stopPropagation()}})}),f&&Array.isArray(t)&&t.length?n.jsx("ul",{ref:a,className:"autocomplete-value-container",children:M?n.jsxs(n.Fragment,{children:[n.jsx("li",{children:n.jsx(_.Chip,{text:t[0]?.value??t[0]?.name,onDelete:e=>{K(0),e.stopPropagation()}})}),t.length>1&&n.jsx("li",{children:n.jsx(_.Chip,{text:`+${t.length-1}`,onDelete:e=>{Q(),e.stopPropagation()}})})]}):t.map((e,i)=>n.jsx("li",{children:n.jsx(_.Chip,{text:String(e.value??e.name),onDelete:y=>{K(i),y.stopPropagation()}})},e.id??e.value??e.name))}):null]}),c&&n.jsx("ul",{className:"autocomplete-suggestions-container",style:{width:q.current?.offsetWidth},children:m.map(e=>n.jsx("li",{className:h.classNames("autocomplete-suggestion-item",e.id===m[x]?.id?"highlighted":""),onMouseEnter:()=>o(m.findIndex(i=>i.id===e.id)),onClick:i=>{S(e),i.stopPropagation()},children:e.value??e.name},e.id??e.value??e.name))})]})});var P=(l=>(l.error="error",l.good="good",l.default="default",l))(P||{});const U=l=>{switch(l){case"error":return"input-error";case"good":return"input-good";default:return"input-normal"}},V=l=>{switch(l){case"error":return"input-label-error";case"good":return"input-label-good";default:return"input-label-normal"}},z=l=>{switch(l){case"error":return"input-helper-text-error";case"good":return"input-helper-text-good";default:return"input-helper-text-normal"}},te=r.forwardRef(function(l,C){const{checked:N,onChange:t,name:s="",id:v="",label:A="",state:w=P.default,containerClassName:b="",inputClassName:I="",labelClassName:k="",...D}=l;return n.jsxs("label",{className:h.classNames("input-check-container",b),children:[n.jsx("input",{id:v,ref:C,name:s,type:"checkbox",checked:N,onChange:t,className:h.classNames("input-check",U(w),I),...D}),n.jsx("span",{className:h.classNames("input-check-label",V(w),k),children:A})]})}),J=l=>l==null?!1:Array.isArray(l)?l.length>0:`${l}`.length>0,G=r.forwardRef(function(l,C){const{children:N,state:t=P.default,label:s="",containerClassName:v="",inputClassName:A="",labelClassName:w="",helperText:b="",helperTextClassName:I="",value:k,defaultValue:D,onChange:R,onFocus:f,onBlur:E,...u}=l,T=k!==void 0,[O,L]=r.useState(()=>J(D)),F=T?J(k):O,B=u.type==="date",j=!!u.placeholder||B,p=u["aria-required"]===!0||String(u["aria-required"]).toLowerCase()==="true",c=!!(u.required||p),g=x=>{T||L(x.currentTarget.value.length>0),R?.(x)};return n.jsxs("div",{className:h.classNames("text-input-container",v),children:[n.jsxs("div",{className:"text-input-field",children:[n.jsx("input",{ref:C,defaultValue:D,onChange:g,onFocus:f,onBlur:E,...T?{value:k}:{},className:h.classNames("text-input",U(t),A,F?"has-value":"",u.placeholder?"has-placeholder":"",j?"keep-label-up":""),...u}),!!s&&n.jsxs("label",{htmlFor:u.id,className:h.classNames("text-input-label",V(t),w),children:[s,c?" *":""]}),N]}),!!b&&n.jsx("p",{className:h.classNames("text-input-helper-text",z(t),I),children:b})]})}),ae=r.forwardRef(function(l,C){const{value:N,onChange:t,options:s,containerClassName:v="",inputClassName:A="",labelClassName:w="",helperText:b="",helperTextClassName:I="",label:k="",placeholder:D="",name:R="",id:f="",state:E=P.default,native:u=!0,disabled:T,required:O,autoFocus:L,children:F,...B}=l,j=r.useRef(null),[p,c]=r.useState(!1),[g,x]=r.useState(-1),o=r.useMemo(()=>s.findIndex(a=>String(a.id)===String(N??s[0]?.id??"")),[s,N]),m=r.useMemo(()=>o>=0?s[o]:void 0,[s,o]);r.useEffect(()=>{if(!(u||!p)){if(!s.length){x(-1);return}x(o>=0?o:0)}},[u,s.length,o,p]),r.useEffect(()=>{if(u)return;const a=d=>{j.current&&!j.current.contains(d.target)&&c(!1)};return document.addEventListener("mousedown",a),()=>{document.removeEventListener("mousedown",a)}},[u]);const q=r.useCallback(a=>{C&&(typeof C=="function"?C(a):C.current=a)},[C]),H=r.useCallback(a=>{if(!t)return;const d={target:{value:String(a)},currentTarget:{value:String(a)}};t(d)},[t]),M=r.useCallback(a=>{const d=s[a];d&&(H(d.id),c(!1))},[H,s]),W=r.useCallback(a=>{if(s.length){if(a.key==="ArrowDown"||a.key==="ArrowUp"){if(a.preventDefault(),!p){c(!0);const d=o>=0?o:0;x(d);return}x(d=>{const S=d>=0?d:o;return a.key==="ArrowDown"?(S+1+s.length)%s.length:(S-1+s.length)%s.length});return}if(a.key==="Enter"){if(!p){a.preventDefault(),c(!0),x(o>=0?o:0);return}a.preventDefault(),M(g>=0?g:0);return}a.key==="Escape"&&p&&(a.preventDefault(),c(!1))}},[g,s,M,o,p]);return u?n.jsxs("div",{className:h.classNames("select-input-container",v),children:[n.jsx("select",{...B,id:f,ref:q,name:R,value:N,onChange:t,className:h.classNames("select-input",U(E),"peer",A),children:s?.map(a=>n.jsx("option",{value:a.id,children:a.value??a.name??a.id},a.id))}),n.jsx("label",{htmlFor:f,className:h.classNames("select-input-label",V(E),w),children:k}),F,b&&n.jsx("p",{className:h.classNames("select-input-helper-text",z(E),I),children:b})]}):n.jsxs("div",{ref:j,className:h.classNames("select-input-container",v),children:[n.jsx("select",{...B,ref:q,name:R,id:f,value:N,onChange:t,className:"select-input-native-hidden",tabIndex:-1,"aria-hidden":!0,children:s?.map(a=>n.jsx("option",{value:a.id,children:a.value??a.name??a.id},a.id))}),n.jsx(G,{id:f,name:R,state:E,value:String(m?.value??m?.name??""),readOnly:!0,label:k,helperText:b,containerClassName:"select-input-text-container",inputClassName:h.classNames("select-input-text",A),labelClassName:w,helperTextClassName:I,placeholder:D,disabled:T,required:O,autoFocus:L,onClick:()=>c(a=>!a),onKeyDown:W,onFocus:()=>c(!0),role:"combobox","aria-expanded":p,"aria-haspopup":"listbox",children:F}),p&&n.jsx("ul",{className:"select-input-options-container",role:"listbox",children:s.map((a,d)=>{const S=String(a.id)===String(N),$=d===g;return n.jsx("li",{role:"option","aria-selected":S,className:h.classNames("select-input-option-item",$?"highlighted":""),onMouseEnter:()=>x(d),onClick:K=>{M(d),K.stopPropagation()},children:a.value??a.name??a.id},a.id)})})]})});exports.AutocompleteInput=ee;exports.CheckInput=te;exports.SelectInput=ae;exports.State=P;exports.TextInput=G;exports.helperTextStateClassName=z;exports.inputStateClassName=U;exports.labelStateClassName=V;
|