@sito/dashboard 0.0.67 → 0.0.69
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/README.md +7 -0
- package/dist/{Dropdown-CAxauIXt.cjs → Dropdown-CR8mco5s.cjs} +1 -1
- package/dist/{Dropdown-CbaxuMbk.js → Dropdown-D-fYEGo2.js} +13 -14
- package/dist/Dropdown.cjs +1 -1
- package/dist/Dropdown.css +1 -1
- package/dist/Dropdown.js +1 -1
- package/dist/FileInput-CqzVk1gQ.cjs +1 -0
- package/dist/{FileInput-DCR_Pyqe.js → FileInput-Cr4TxWUg.js} +34 -32
- package/dist/FiltersProvider-BoCTMqk8.js +60 -0
- package/dist/FiltersProvider-Bxge43VS.cjs +1 -0
- package/dist/FiltersProvider.cjs +1 -1
- package/dist/FiltersProvider.js +1 -1
- package/dist/Form.cjs +1 -1
- package/dist/Form.js +2 -2
- package/dist/Table-BLhy0EYJ.cjs +1 -0
- package/dist/Table-CeD0yXGZ.js +1113 -0
- package/dist/Table.cjs +1 -1
- package/dist/Table.css +1 -1
- package/dist/Table.js +1 -1
- package/dist/TableOptions.cjs +1 -1
- package/dist/TableOptions.js +1 -1
- package/dist/TableOptionsProvider-BJdeNIQj.cjs +1 -0
- package/dist/TableOptionsProvider-DBr-FW53.js +106 -0
- package/dist/TextInput-C27RFuya.cjs +1 -0
- package/dist/TextInput-DPYxzgm3.js +335 -0
- package/dist/TextInput.css +1 -1
- package/dist/Translation.cjs +1 -1
- package/dist/Translation.js +1 -1
- package/dist/{TranslationProvider-COebIyxr.js → TranslationProvider-BR4s--Vu.js} +2 -2
- package/dist/TranslationProvider-Czr0WIDH.cjs +1 -0
- package/dist/components/Dropdown/Dropdown.d.ts +1 -1
- package/dist/components/Form/FileInput/types.d.ts +1 -1
- package/dist/components/Table/components/types.d.ts +1 -1
- package/dist/components/Table/types.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +7 -7
- package/dist/providers/Translation/TranslationProvider.d.ts +5 -4
- package/package.json +1 -1
- package/dist/FileInput-Ch-GCxrS.cjs +0 -1
- package/dist/FiltersProvider-CY2fsw_F.js +0 -57
- package/dist/FiltersProvider-CYqLFEI9.cjs +0 -1
- package/dist/Table-BtZGG0d7.js +0 -1056
- package/dist/Table-DjIhOMXQ.cjs +0 -1
- package/dist/TableOptionsProvider-BchUDA3B.cjs +0 -1
- package/dist/TableOptionsProvider-BfQS8l1N.js +0 -50
- package/dist/TextInput-BqW5YX-3.js +0 -320
- package/dist/TextInput-CY1fh4mf.cjs +0 -1
- package/dist/TranslationProvider-51Pc9Xrr.cjs +0 -1
- package/dist/components/Actions/Actions.stories.d.ts +0 -20
- package/dist/components/Actions/Actions.test.d.ts +0 -1
- package/dist/components/Actions/ActionsDropdown.stories.d.ts +0 -17
- package/dist/components/Actions/ActionsDropdown.test.d.ts +0 -1
- package/dist/components/Badge/Badge.stories.d.ts +0 -8
- package/dist/components/Button/Button.stories.d.ts +0 -29
- package/dist/components/Chip/Chip.stories.d.ts +0 -9
- package/dist/components/Dropdown/Dropdown.stories.d.ts +0 -8
- package/dist/components/Dropdown/Dropdown.test.d.ts +0 -1
- package/dist/components/Form/AutocompleteInput/AutocompleteInput.stories.d.ts +0 -8
- package/dist/components/Form/CheckInput/CheckInput.stories.d.ts +0 -6
- package/dist/components/Form/FileInput/FileInput.stories.d.ts +0 -7
- package/dist/components/Form/FileInput/FileInput.test.d.ts +0 -1
- package/dist/components/Form/FileInput/utils.test.d.ts +0 -1
- package/dist/components/Form/SelectInput/SelectInput.stories.d.ts +0 -7
- package/dist/components/Form/TextInput/TextInput.stories.d.ts +0 -10
- package/dist/components/Form/TextInput/TextInput.test.d.ts +0 -1
- package/dist/components/Form/utils.test.d.ts +0 -1
- package/dist/components/IconButton/IconButton.stories.d.ts +0 -30
- package/dist/components/Loading/Loading.stories.d.ts +0 -7
- package/dist/components/Table/Table.expandable.test.d.ts +0 -1
- package/dist/components/Table/Table.selection.test.d.ts +0 -1
- package/dist/components/Table/Table.stories.d.ts +0 -18
- package/dist/components/Table/components/Filters/FilterDropdown/FilterDropdown.test.d.ts +0 -1
- package/dist/components/Table/components/TableSelectionBar.test.d.ts +0 -1
- package/dist/components/Table/utils.test.d.ts +0 -1
- package/dist/components/Tooltip/Tooltip.stories.d.ts +0 -6
- package/dist/providers/FiltersProvider/utils.test.d.ts +0 -1
- package/dist/providers/TableOptions/TableOptionsProvider.test.d.ts +0 -1
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ pnpm add @sito/dashboard
|
|
|
25
25
|
### Peer dependency
|
|
26
26
|
|
|
27
27
|
- `react` (`>=18.2 <20`)
|
|
28
|
+
- `react-dom` (`>=18.2 <20`)
|
|
28
29
|
|
|
29
30
|
## Quick Usage
|
|
30
31
|
|
|
@@ -87,6 +88,12 @@ export function UsersTable() {
|
|
|
87
88
|
}
|
|
88
89
|
```
|
|
89
90
|
|
|
91
|
+
## Form Input Notes
|
|
92
|
+
|
|
93
|
+
- `SelectInput` expects `Option` items with an `id` (plus optional `value`/`name`).
|
|
94
|
+
- `CheckInput` is controlled with `checked` (not `value`).
|
|
95
|
+
- `FileInput` `onChange` receives the native input event; read files from `e.currentTarget.files`.
|
|
96
|
+
|
|
90
97
|
## Core `Table` Props
|
|
91
98
|
|
|
92
99
|
| Prop | Type | Required | Description |
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var E=require("./Dropdown.css");const
|
|
1
|
+
var E=require("./Dropdown.css");const g=require("react/jsx-runtime"),u=require("react"),h=require("react-dom"),d=8;function w(s,l){const e=l.getBoundingClientRect(),c=window.innerWidth,o=window.innerHeight;let n=s.bottom+4,r=s.left;return r+e.width>c-d&&(r=s.right-e.width),r<d&&(r=d),n+e.height>o-d&&(n=s.top-e.height-4),n<d&&(n=d),{top:n,left:r}}const v=s=>{const{children:l,open:e,onClose:c,anchorEl:o}=s,n=u.useRef(null);u.useLayoutEffect(()=>{const t=n.current;if(!e||!o||!t)return;const i=o.getBoundingClientRect(),{top:a,left:p}=w(i,t);t.style.top=`${a}px`,t.style.left=`${p}px`},[e,o]),u.useEffect(()=>{if(!e||!o)return;const t=n.current;if(!t)return;const i=()=>{const a=o.getBoundingClientRect(),{top:p,left:m}=w(a,t);t.style.top=`${p}px`,t.style.left=`${m}px`};return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[e,o]);const r=u.useCallback(t=>{const i=n.current;!e||!i||o?.contains(t.target)||i.contains(t.target)||c()},[e,c,o]),f=u.useCallback(t=>{e&&t.key==="Escape"&&c()},[e,c]);return u.useEffect(()=>{if(e)return setTimeout(()=>n.current?.focus(),0),document.addEventListener("mousedown",r),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",f)}},[e,r,f]),e?h.createPortal(g.jsx("div",{ref:n,role:"menu",tabIndex:-1,className:"dropdown-main opened",onClick:t=>t.stopPropagation(),children:l}),document.body):null};exports.Dropdown=v;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import "./Dropdown.css";
|
|
2
|
-
import { jsx as
|
|
2
|
+
import { jsx as h } from "react/jsx-runtime";
|
|
3
3
|
import { useRef as v, useLayoutEffect as y, useEffect as m, useCallback as p } from "react";
|
|
4
4
|
import { createPortal as E } from "react-dom";
|
|
5
|
-
const
|
|
6
|
-
function w(s,
|
|
7
|
-
const e =
|
|
5
|
+
const u = 8;
|
|
6
|
+
function w(s, d) {
|
|
7
|
+
const e = d.getBoundingClientRect(), c = window.innerWidth, o = window.innerHeight;
|
|
8
8
|
let n = s.bottom + 4, r = s.left;
|
|
9
|
-
return r + e.width > c -
|
|
9
|
+
return r + e.width > c - u && (r = s.right - e.width), r < u && (r = u), n + e.height > o - u && (n = s.top - e.height - 4), n < u && (n = u), { top: n, left: r };
|
|
10
10
|
}
|
|
11
11
|
const k = (s) => {
|
|
12
|
-
const { children:
|
|
12
|
+
const { children: d, open: e, onClose: c, anchorEl: o } = s, n = v(null);
|
|
13
13
|
y(() => {
|
|
14
14
|
const t = n.current;
|
|
15
15
|
if (!e || !o || !t) return;
|
|
@@ -20,8 +20,8 @@ const k = (s) => {
|
|
|
20
20
|
const t = n.current;
|
|
21
21
|
if (!t) return;
|
|
22
22
|
const i = () => {
|
|
23
|
-
const f = o.getBoundingClientRect(), { top: a, left:
|
|
24
|
-
t.style.top = `${a}px`, t.style.left = `${
|
|
23
|
+
const f = o.getBoundingClientRect(), { top: a, left: g } = w(f, t);
|
|
24
|
+
t.style.top = `${a}px`, t.style.left = `${g}px`;
|
|
25
25
|
};
|
|
26
26
|
return window.addEventListener("resize", i), () => window.removeEventListener("resize", i);
|
|
27
27
|
}, [e, o]);
|
|
@@ -42,21 +42,20 @@ const k = (s) => {
|
|
|
42
42
|
return setTimeout(() => n.current?.focus(), 0), document.addEventListener("mousedown", r), document.addEventListener("keydown", l), () => {
|
|
43
43
|
document.removeEventListener("mousedown", r), document.removeEventListener("keydown", l);
|
|
44
44
|
};
|
|
45
|
-
}, [e, r, l]), E(
|
|
46
|
-
/* @__PURE__ */
|
|
45
|
+
}, [e, r, l]), e ? E(
|
|
46
|
+
/* @__PURE__ */ h(
|
|
47
47
|
"div",
|
|
48
48
|
{
|
|
49
49
|
ref: n,
|
|
50
50
|
role: "menu",
|
|
51
|
-
"aria-hidden": !e,
|
|
52
51
|
tabIndex: -1,
|
|
53
|
-
className:
|
|
52
|
+
className: "dropdown-main opened",
|
|
54
53
|
onClick: (t) => t.stopPropagation(),
|
|
55
|
-
children:
|
|
54
|
+
children: d
|
|
56
55
|
}
|
|
57
56
|
),
|
|
58
57
|
document.body
|
|
59
|
-
);
|
|
58
|
+
) : null;
|
|
60
59
|
};
|
|
61
60
|
export {
|
|
62
61
|
k as D
|
package/dist/Dropdown.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./Dropdown-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./Dropdown-CR8mco5s.cjs");exports.Dropdown=o.Dropdown;
|
package/dist/Dropdown.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}.dropdown-main{border-radius:var(--radius-lg,.5rem);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-border,#ccc);background-color:var(--color-base-light,#fff);padding:calc(var(--spacing,.25rem) * 2);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);transition:opacity .3s ease-in-out;position:fixed}.dropdown-main.opened{z-index:50;opacity:1}.dropdown-main.closed{pointer-events:none;z-index
|
|
1
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}.dropdown-main{border-radius:var(--radius-lg,.5rem);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-border,#ccc);background-color:var(--color-base-light,#fff);padding:calc(var(--spacing,.25rem) * 2);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow);transition:opacity .3s ease-in-out;position:fixed}.dropdown-main.opened{z-index:50;opacity:1}.dropdown-main.closed{pointer-events:none;z-index:50;opacity:0}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}
|
package/dist/Dropdown.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var D=require("./FileInput.css");const e=require("react/jsx-runtime"),i=require("react"),j=require("./Tooltip-BSKAgRkc.cjs"),T=require("./File-_Hjw2d3F.cjs"),w=require("./Chip-D17UJHW6.cjs"),y=require("./IconButton-CVnmT2E9.cjs"),R=require("./Close-O9P7wJGf.cjs");function N(s,c=25){if(s.length<=c)return s;const a=s.lastIndexOf(".");if(a===-1)return s.slice(0,c-3)+"...";const h=s.slice(0,a),r=s.slice(a),d=c-r.length-3;return h.slice(0,d)+"..."+r}const B=i.forwardRef(function(s,c){const{children:a,label:h,containerClassName:r="",inputClassName:d="",labelClassName:g="",helperText:C="",helperTextClassName:b="",iconClassName:q="",multiple:p=!1,onChange:m,onClear:o,...f}=s,[t,x]=i.useState([]),k=i.useCallback(l=>{if(l.target.files){const n=Array.from(l.target.files);x(u=>p?[...u,...n]:n.slice(0,1))}m?.(l)},[p,m]),v=i.useCallback(l=>{x(n=>{const u=n.filter((A,$)=>$!==l);return u.length===0&&o?.(),u})},[o]),F=i.useCallback(()=>{x([]),o?.()},[o]),I=i.useCallback(l=>{l.currentTarget.value=""},[]);return e.jsxs("div",{className:`file-input-container ${r}`,children:[t.length===0&&e.jsxs("label",{htmlFor:f.id,className:`${g}`,children:[h,e.jsx("input",{type:"file",ref:c,multiple:p,onClick:I,onChange:k,className:`file-input ${d}`,...f}),f.required?" *":""]}),t.length>1&&e.jsx("ul",{className:"file-preview-list",children:t.map((l,n)=>e.jsx("li",{children:e.jsx(j.Tooltip,{content:l.name,children:e.jsx(w.Chip,{text:N(l.name,25),onDelete:()=>v(n)})})},`${l.name}-${l.lastModified}`))}),t.length===1&&e.jsxs("div",{className:"file-preview",children:[e.jsx(T.File,{className:`file-icon ${q}`}),e.jsx(j.Tooltip,{content:t[0]?.name??"",children:e.jsx("span",{className:"file-preview-name",children:N(t[0]?.name??"",25)})}),e.jsx(y.IconButton,{icon:e.jsx(R.Close,{}),onClick:F,type:"button"})]}),a,!!C&&e.jsx("p",{className:`file-input-helper-text ${b}`,children:C})]})});exports.FileInput=B;
|
|
@@ -1,67 +1,69 @@
|
|
|
1
1
|
import "./FileInput.css";
|
|
2
|
-
import { jsxs as
|
|
2
|
+
import { jsxs as C, jsx as l } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef as j, useState as R, useCallback as m } from "react";
|
|
4
|
-
import { T as
|
|
4
|
+
import { T as x } from "./Tooltip-B4E-FRwY.js";
|
|
5
5
|
import { F as q } from "./File-BuJndWMv.js";
|
|
6
6
|
import { C as A } from "./Chip-C5ogKbFn.js";
|
|
7
7
|
import { I as B } from "./IconButton-BpsTEj0z.js";
|
|
8
8
|
import { C as D } from "./Close-rKC9AcNX.js";
|
|
9
|
-
function
|
|
9
|
+
function v(t, s = 25) {
|
|
10
10
|
if (t.length <= s) return t;
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
11
|
+
const a = t.lastIndexOf(".");
|
|
12
|
+
if (a === -1)
|
|
13
13
|
return t.slice(0, s - 3) + "...";
|
|
14
|
-
const p = t.slice(0,
|
|
14
|
+
const p = t.slice(0, a), r = t.slice(a), f = s - r.length - 3;
|
|
15
15
|
return p.slice(0, f) + "..." + r;
|
|
16
16
|
}
|
|
17
17
|
const K = j(function(t, s) {
|
|
18
18
|
const {
|
|
19
|
-
children:
|
|
19
|
+
children: a,
|
|
20
20
|
label: p,
|
|
21
21
|
containerClassName: r = "",
|
|
22
22
|
inputClassName: f = "",
|
|
23
|
-
labelClassName:
|
|
24
|
-
helperText:
|
|
25
|
-
helperTextClassName:
|
|
26
|
-
iconClassName:
|
|
27
|
-
multiple:
|
|
28
|
-
onChange:
|
|
23
|
+
labelClassName: F = "",
|
|
24
|
+
helperText: N = "",
|
|
25
|
+
helperTextClassName: $ = "",
|
|
26
|
+
iconClassName: b = "",
|
|
27
|
+
multiple: d = !1,
|
|
28
|
+
onChange: g,
|
|
29
29
|
onClear: o,
|
|
30
30
|
...h
|
|
31
|
-
} = t, [n,
|
|
31
|
+
} = t, [n, u] = R([]), I = m(
|
|
32
32
|
(e) => {
|
|
33
33
|
if (e.target.files) {
|
|
34
|
-
const
|
|
35
|
-
|
|
34
|
+
const i = Array.from(e.target.files);
|
|
35
|
+
u(
|
|
36
|
+
(c) => d ? [...c, ...i] : i.slice(0, 1)
|
|
37
|
+
);
|
|
36
38
|
}
|
|
37
|
-
|
|
39
|
+
g?.(e);
|
|
38
40
|
},
|
|
39
|
-
[
|
|
41
|
+
[d, g]
|
|
40
42
|
), w = m(
|
|
41
43
|
(e) => {
|
|
42
|
-
|
|
43
|
-
const c =
|
|
44
|
+
u((i) => {
|
|
45
|
+
const c = i.filter((M, y) => y !== e);
|
|
44
46
|
return c.length === 0 && o?.(), c;
|
|
45
47
|
});
|
|
46
48
|
},
|
|
47
49
|
[o]
|
|
48
50
|
), T = m(() => {
|
|
49
|
-
|
|
51
|
+
u([]), o?.();
|
|
50
52
|
}, [o]), k = m(
|
|
51
53
|
(e) => {
|
|
52
54
|
e.currentTarget.value = "";
|
|
53
55
|
},
|
|
54
56
|
[]
|
|
55
57
|
);
|
|
56
|
-
return /* @__PURE__ */
|
|
57
|
-
n.length === 0 && /* @__PURE__ */
|
|
58
|
+
return /* @__PURE__ */ C("div", { className: `file-input-container ${r}`, children: [
|
|
59
|
+
n.length === 0 && /* @__PURE__ */ C("label", { htmlFor: h.id, className: `${F}`, children: [
|
|
58
60
|
p,
|
|
59
61
|
/* @__PURE__ */ l(
|
|
60
62
|
"input",
|
|
61
63
|
{
|
|
62
64
|
type: "file",
|
|
63
65
|
ref: s,
|
|
64
|
-
multiple:
|
|
66
|
+
multiple: d,
|
|
65
67
|
onClick: k,
|
|
66
68
|
onChange: I,
|
|
67
69
|
className: `file-input ${f}`,
|
|
@@ -70,20 +72,20 @@ const K = j(function(t, s) {
|
|
|
70
72
|
),
|
|
71
73
|
h.required ? " *" : ""
|
|
72
74
|
] }),
|
|
73
|
-
n.length > 1 && /* @__PURE__ */ l("ul", { className: "file-preview-list", children: n.map((e,
|
|
75
|
+
n.length > 1 && /* @__PURE__ */ l("ul", { className: "file-preview-list", children: n.map((e, i) => /* @__PURE__ */ l("li", { children: /* @__PURE__ */ l(x, { content: e.name, children: /* @__PURE__ */ l(
|
|
74
76
|
A,
|
|
75
77
|
{
|
|
76
|
-
text:
|
|
77
|
-
onDelete: () => w(
|
|
78
|
+
text: v(e.name, 25),
|
|
79
|
+
onDelete: () => w(i)
|
|
78
80
|
}
|
|
79
81
|
) }) }, `${e.name}-${e.lastModified}`)) }),
|
|
80
|
-
n.length === 1 && /* @__PURE__ */
|
|
81
|
-
/* @__PURE__ */ l(q, { className: `file-icon ${
|
|
82
|
-
/* @__PURE__ */ l(
|
|
82
|
+
n.length === 1 && /* @__PURE__ */ C("div", { className: "file-preview", children: [
|
|
83
|
+
/* @__PURE__ */ l(q, { className: `file-icon ${b}` }),
|
|
84
|
+
/* @__PURE__ */ l(x, { content: n[0]?.name ?? "", children: /* @__PURE__ */ l("span", { className: "file-preview-name", children: v(n[0]?.name ?? "", 25) }) }),
|
|
83
85
|
/* @__PURE__ */ l(B, { icon: /* @__PURE__ */ l(D, {}), onClick: T, type: "button" })
|
|
84
86
|
] }),
|
|
85
|
-
|
|
86
|
-
!!
|
|
87
|
+
a,
|
|
88
|
+
!!N && /* @__PURE__ */ l("p", { className: `file-input-helper-text ${$}`, children: N })
|
|
87
89
|
] });
|
|
88
90
|
});
|
|
89
91
|
export {
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { useReducer as p, useEffect as f, useMemo as l, createContext as m, useContext as v } from "react";
|
|
3
|
+
import { u as x } from "./TableOptionsProvider-DBr-FW53.js";
|
|
4
|
+
var n = /* @__PURE__ */ ((e) => (e[e.update = 0] = "update", e[e.reset = 1] = "reset", e))(n || {});
|
|
5
|
+
const a = (e) => {
|
|
6
|
+
if (e) {
|
|
7
|
+
const t = {};
|
|
8
|
+
return Object.keys(e)?.forEach((r) => {
|
|
9
|
+
t[r] = { value: e[r] };
|
|
10
|
+
}), t;
|
|
11
|
+
}
|
|
12
|
+
return {};
|
|
13
|
+
};
|
|
14
|
+
function h(e, t) {
|
|
15
|
+
const { type: s } = t;
|
|
16
|
+
switch (s) {
|
|
17
|
+
case n.reset:
|
|
18
|
+
return {};
|
|
19
|
+
case n.update: {
|
|
20
|
+
const { toUpdate: r } = t;
|
|
21
|
+
return { ...e, ...r };
|
|
22
|
+
}
|
|
23
|
+
default:
|
|
24
|
+
return e;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const c = m(void 0), w = (e) => {
|
|
28
|
+
const { children: t } = e, { filters: s } = x(), [r, o] = p(
|
|
29
|
+
h,
|
|
30
|
+
a(s)
|
|
31
|
+
);
|
|
32
|
+
f(() => {
|
|
33
|
+
o({ type: n.reset });
|
|
34
|
+
const u = a(s);
|
|
35
|
+
Object.keys(u).length && o({
|
|
36
|
+
type: n.update,
|
|
37
|
+
toUpdate: u
|
|
38
|
+
});
|
|
39
|
+
}, [s]);
|
|
40
|
+
const i = l(
|
|
41
|
+
() => ({
|
|
42
|
+
currentFilters: r,
|
|
43
|
+
setCurrentFilters: o
|
|
44
|
+
}),
|
|
45
|
+
[r]
|
|
46
|
+
);
|
|
47
|
+
return /* @__PURE__ */ d(c.Provider, { value: i, children: t });
|
|
48
|
+
}, j = () => {
|
|
49
|
+
const e = v(c);
|
|
50
|
+
if (!e)
|
|
51
|
+
throw new Error("filtersContext must be used within a Provider");
|
|
52
|
+
return e;
|
|
53
|
+
};
|
|
54
|
+
export {
|
|
55
|
+
w as F,
|
|
56
|
+
n as a,
|
|
57
|
+
h as f,
|
|
58
|
+
a as i,
|
|
59
|
+
j as u
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const p=require("react/jsx-runtime"),i=require("react"),f=require("./TableOptionsProvider-BJdeNIQj.cjs");var n=(e=>(e[e.update=0]="update",e[e.reset=1]="reset",e))(n||{});const o=e=>{if(e){const t={};return Object.keys(e)?.forEach(r=>{t[r]={value:e[r]}}),t}return{}};function a(e,t){const{type:s}=t;switch(s){case n.reset:return{};case n.update:{const{toUpdate:r}=t;return{...e,...r}}default:return e}}const d=i.createContext(void 0),v=e=>{const{children:t}=e,{filters:s}=f.useTableOptions(),[r,u]=i.useReducer(a,o(s));i.useEffect(()=>{u({type:n.reset});const c=o(s);Object.keys(c).length&&u({type:n.update,toUpdate:c})},[s]);const l=i.useMemo(()=>({currentFilters:r,setCurrentFilters:u}),[r]);return p.jsx(d.Provider,{value:l,children:t})},x=()=>{const e=i.useContext(d);if(!e)throw new Error("filtersContext must be used within a Provider");return e};exports.FiltersActions=n;exports.FiltersProvider=v;exports.filtersReducer=a;exports.initializer=o;exports.useFilters=x;
|
package/dist/FiltersProvider.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./FiltersProvider-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./FiltersProvider-Bxge43VS.cjs");exports.FiltersActions=e.FiltersActions;exports.FiltersProvider=e.FiltersProvider;exports.filtersReducer=e.filtersReducer;exports.initializer=e.initializer;exports.useFilters=e.useFilters;
|
package/dist/FiltersProvider.js
CHANGED
package/dist/Form.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./TextInput-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./TextInput-C27RFuya.cjs"),t=require("./FileInput-CqzVk1gQ.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,5 +1,5 @@
|
|
|
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 "./TextInput-
|
|
2
|
-
import { F as r } from "./FileInput-
|
|
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 "./TextInput-DPYxzgm3.js";
|
|
2
|
+
import { F as r } from "./FileInput-Cr4TxWUg.js";
|
|
3
3
|
export {
|
|
4
4
|
e as AutocompleteInput,
|
|
5
5
|
s as CheckInput,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Me=require("./Table.css");const e=require("react/jsx-runtime"),o=require("react"),F=require("./FiltersProvider-Bxge43VS.cjs"),xe=require("./Badge-Z78MlGoQ.cjs"),I=require("./Filters-Dyee8QYH.cjs"),B=require("./lib.cjs"),E=require("./TranslationProvider-Czr0WIDH.cjs"),P=require("./TextInput-C27RFuya.cjs"),q=require("./TableOptionsProvider-BJdeNIQj.cjs"),G=require("./Button-BlYa3uPc.cjs"),J=require("./Chip-D17UJHW6.cjs"),H=require("./IconButton-CVnmT2E9.cjs"),Q=require("./Tooltip-BSKAgRkc.cjs"),fe=require("./query-81BrXp3i.cjs"),je=require("./Dropdown-CR8mco5s.cjs"),ge=require("./Loading-CNECRan-.cjs");function X(n){const{id:t,icon:r,tooltip:s,onClick:l,children:a,hidden:d=!1,disabled:c=!1,showText:u=!1,showTooltips:i=!0,className:p=""}=n;return d?null:e.jsxs("button",{type:"button",id:t,className:`action ${u?"text-action":"icon-action"} ${p}`,disabled:c,"aria-label":s,onClick:m=>{m.stopPropagation(),l?.()},"aria-disabled":c,"data-tooltip-id":"tooltip","data-tooltip-content":i?s:"",children:[r," ",u&&s,a]})}function Y(n){const{actions:t=[],className:r="",itemClassName:s="",actionClassName:l="",showTooltips:a=!0,showActionTexts:d=!1}=n;return e.jsx("ul",{className:`actions-container ${r}`,children:t.map(c=>e.jsx("li",{className:`actions-container-item ${s}`,children:e.jsx(X,{showTooltips:a,showText:d,className:l,...c})},c.id))})}const Z=n=>{const{actions:t=[],className:r=""}=n,{t:s}=E.useTranslation(),[l,a]=o.useState(!1),[d,c]=o.useState(null);return e.jsxs("div",{className:`actions-dropdown ${r}`,children:[e.jsx(H.IconButton,{icon:e.jsx(I.Ellipsis,{}),onClick:u=>{u.stopPropagation(),c(u.currentTarget),a(i=>!i)},onMouseDown:u=>u.stopPropagation(),className:"actions-dropdown-trigger","aria-label":s("_accessibility:buttons.openActions"),name:s("_accessibility:buttons.openActions"),"data-tooltip-id":"tooltip","data-tooltip-content":s("_accessibility:buttons.openActions")}),e.jsx(je.Dropdown,{open:l,onClose:()=>a(!1),anchorEl:d,children:e.jsx(Y,{showActionTexts:!0,actions:t,itemClassName:"w-full",actionClassName:"action-dropdown-item",className:"actions-dropdown-list",showTooltips:!1})})]})};function ee(n){return[...n].sort((t,r)=>(r.pos??0)-(t.pos??0)).filter(t=>t.display!=="none")}function te(n){const{t}=E.useTranslation(),{entity:r="",columns:s=[],hasAction:l=!0,onSortCallback:a,selectionState:d,onToggleAllRows:c}=n,u=o.useRef(null);o.useEffect(()=>{u.current&&(u.current.indeterminate=!!(d?.hasSomeSelected&&!d?.allSelected))},[d]);const{onSort:i,sortingOrder:p,sortingBy:m}=q.useTableOptions(),x=o.useMemo(()=>ee(s).map(h=>({id:h.key,label:h.label,renderHead:h.renderHead,className:h.className??"",sortable:h.sortable??!0,sortOptions:h.sortOptions})),[s,r,t]);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:d?.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(h=>e.jsx("th",{scope:"col",className:`table-headers-column ${h.className}`,children:e.jsxs(G.Button,{disabled:!h.sortable,onClick:()=>i(h.id,a),className:"table-headers-cell",children:[h.renderHead?h.renderHead():e.jsx("span",{className:"table-headers-label",children:h.label}),h.sortable&&m===h.id&&e.jsx("span",{children:p===fe.SortOrder.ASC?h.sortOptions?.icons?.asc??e.jsx(I.ChevronUp,{className:h.sortOptions?.icons?.className??"table-headers-sort-indicator"}):h.sortOptions?.icons?.desc??e.jsx(I.ChevronDown,{className:h.sortOptions?.icons?.className??"table-headers-sort-indicator"})})]})},h.id))]})})}const ne=n=>{const{items:t,text:r,id:s,onClearFilter:l}=n;return e.jsx(J.Chip,{text:`${r}: ${t.map(a=>a.value??a.name).join(", ")}`,onDelete:()=>l(s)})},se=n=>{const{end:t,start:r,text:s,id:l,onClearFilter:a}=n,d=c=>c!==null&&typeof c<"u"&&c!=="";return e.jsx(J.Chip,{text:`${s}: ${d(r)?r:"♾️"} - ${d(t)?t:"♾️"}`,onDelete:()=>a(l)})},Ce=n=>typeof n=="object"&&n!==null&&!Array.isArray(n)&&("start"in n||"end"in n),le=n=>{const{filtersDefinition:t}=n,r=o.useMemo(()=>{const c={};return t.forEach(u=>{c[u.propertyName]=u.label??u.propertyName}),c},[t]),{filters:s,clearFilters:l}=q.useTableOptions(),a=o.useMemo(()=>Object.keys(s),[s]),d=o.useCallback(c=>{const u=s[c];return Ce(u)?e.jsx(se,{id:c,text:r[c],start:u.start,end:u.end,onClearFilter:l}):Array.isArray(u)?e.jsx(ne,{id:c,text:r[c],items:u,onClearFilter:l}):e.jsx(J.Chip,{text:`${r[c]}: ${u?.value??u?.name??u}`,onDelete:()=>l(c)})},[s,r,l]);return e.jsx("ul",{className:"active-filters-main",children:a?.map(c=>e.jsx("li",{children:d(c)},c))})};function Ne(n){const{propertyName:t,label:r,placeholder:s,options:l,multiple:a=!0}=n,{currentFilters:d,setCurrentFilters:c}=F.useFilters(),u=o.useMemo(()=>{const p=d[t]?.value;return typeof p>"u"?null:p},[d,t]),i=o.useCallback(p=>{c({type:F.FiltersActions.update,toUpdate:{[t]:{value:p}}})},[t,c]);return e.jsx(P.AutocompleteInput,{value:u,label:r,options:l,multiple:a,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:i,placeholder:s})}const ye=n=>{const{propertyName:t,label:r}=n,{currentFilters:s,setCurrentFilters:l}=F.useFilters(),a=o.useMemo(()=>s[t]?.value??"",[s]),d=o.useCallback(c=>{l({type:F.FiltersActions.update,toUpdate:{[t]:{value:c.target.checked}}})},[]);return e.jsx(P.CheckInput,{label:r,checked:a??!1,onChange:d})};function we(n){const{propertyName:t,options:r,label:s,placeholder:l}=n,{currentFilters:a,setCurrentFilters:d}=F.useFilters(),c=o.useMemo(()=>{const i=a[t]?.value;if(i===null||typeof i>"u")return r[0]?.id??"";if(typeof i=="object"&&!Array.isArray(i)){const p=i;return p.id??p.value??""}return i},[a,r,t]),u=o.useCallback(i=>{const p=r.find(m=>String(m.id)===i.target.value);d({type:F.FiltersActions.update,toUpdate:{[t]:{value:p?.id??i.target.value}}})},[r,t,d]);return e.jsx(P.SelectInput,{value:c,label:s,options:r,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:u,placeholder:l})}const ve=n=>{const{propertyName:t,label:r,placeholder:s}=n,{currentFilters:l,setCurrentFilters:a}=F.useFilters(),d=o.useMemo(()=>l[t]?.value??"",[l]),c=o.useCallback(u=>{a({type:F.FiltersActions.update,toUpdate:{[t]:{value:u.target.value}}})},[]);return e.jsx(P.TextInput,{value:d??"",label:r,onChange:c,containerClassName:"input-widget-container",helperTextClassName:"",placeholder:s})},K=n=>{const{propertyName:t,label:r,inputType:s}=n,{t:l}=E.useTranslation(),{currentFilters:a,setCurrentFilters:d}=F.useFilters(),c=o.useRef(null),u=o.useRef(null),i=o.useCallback(m=>{d({type:F.FiltersActions.update,toUpdate:{[t]:{value:{end:u?.current?.value??null,start:m.target.value}}}})},[]),p=o.useCallback(m=>{d({type:F.FiltersActions.update,toUpdate:{[t]:{value:{start:c?.current?.value??null,end:m.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:r}),e.jsxs("div",{className:"range-widget-row",children:[e.jsx(P.TextInput,{value:a[t]?.value?.start??"",placeholder:l("_accessibility:components.table.filters.range.start"),type:s,ref:c,onChange:i,containerClassName:"input-widget-container",helperTextClassName:""}),e.jsx(P.TextInput,{value:a[t]?.value?.end??"",placeholder:l("_accessibility:components.table.filters.range.end"),type:s,ref:u,onChange:p,containerClassName:"input-widget-container",helperTextClassName:""})]})]})},ae=n=>{switch(n.type){case B.FilterTypes.text:return e.jsx(ve,{...n});case B.FilterTypes.number:return e.jsx(K,{...n,inputType:"number"});case B.FilterTypes.date:return e.jsx(K,{...n,inputType:"date"});case B.FilterTypes.select:return e.jsx(we,{...n});case B.FilterTypes.autocomplete:return e.jsx(Ne,{...n});case B.FilterTypes.check:return e.jsx(ye,{...n})}return e.jsx(e.Fragment,{})},re=n=>{const{filters:t=[],show:r,handleShow:s}=n,{onFilterApply:l}=q.useTableOptions(),{currentFilters:a,setCurrentFilters:d}=F.useFilters(),{t:c}=E.useTranslation(),u=o.useRef(null);return o.useEffect(()=>{const i=({target:m})=>{u.current&&(m?.closest(".filter-dropdown-trigger")||!r||u.current.contains(m)||s(!1))},p=({code:m})=>{!r||m!=="Escape"||s(!1)};return document.addEventListener("click",i),document.addEventListener("keydown",p),()=>{document.removeEventListener("click",i),document.removeEventListener("keydown",p)}},[s,r]),e.jsx("div",{className:`filter-dropdown-backdrop ${r?"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(i=>e.jsx("li",{className:"filter-container-item",children:ae(i)},i.propertyName))}),e.jsx("div",{className:"filter-footer",children:e.jsxs("ul",{className:"filter-buttons-row",children:[e.jsx("li",{children:e.jsx(G.Button,{type:"button",variant:"submit",onClick:()=>d({type:F.FiltersActions.reset,filters:t}),className:"filter-dropdown-button filter-dropdown-cancel",children:c("_accessibility:buttons.clear")})}),e.jsx("li",{children:e.jsx(G.Button,{type:"button",variant:"submit",color:"primary",className:"filter-dropdown-button filter-dropdown-submit",onClick:()=>{s(!1),l(a)},children:c("_accessibility:buttons.applyFilters")})})]})})]})})},ie=()=>{const{t:n}=E.useTranslation(),{total:t,pageSize:r,pageSizes:s,currentPage:l}=q.useTableOptions(),a=(l+1)*r>t?t:(l+1)*r;return e.jsxs("div",{className:"table-navigation-sizes",children:[s[0]<t&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[l*r+1," - ",a," ",n("_accessibility:components.table.of")]})}),e.jsx("p",{children:t})]})};function Te(){const{t:n}=E.useTranslation(),{total:t,pageSize:r,currentPage:s,setCurrentPage:l}=q.useTableOptions(),a=o.useMemo(()=>{const d=Math.ceil(t/r);return Array.from({length:d},(c,u)=>({id:u,value:u+1}))},[t,r]);return e.jsxs("div",{className:"jump-to-page",children:[e.jsx("p",{children:n("_accessibility:components.table.jumpToPage")}),e.jsx(P.SelectInput,{value:s,options:a,inputClassName:"jump-to-page-input",containerClassName:"jump-to-page-input-container",helperTextClassName:"hidden",onChange:d=>l(Number(d.target.value))})]})}const oe=()=>{const{t:n}=E.useTranslation(),{total:t,pageSize:r,currentPage:s,setCurrentPage:l}=q.useTableOptions(),a=Math.ceil(t/r),d=s<a-1;return e.jsxs("div",{className:"table-navigation-pages",children:[e.jsx(H.IconButton,{icon:e.jsx(I.ChevronLeft,{className:"table-navigation-icon"}),className:"table-navigation-buttons",disabled:s===0,"aria-label":n("_accessibility:buttons.previous"),name:n("_accessibility:buttons.previous"),onClick:()=>l(s-1)}),e.jsx(H.IconButton,{icon:e.jsx(I.ChevronRight,{className:"table-navigation-icon"}),disabled:!d,className:"table-navigation-buttons",name:n("_accessibility:buttons.next"),"aria-label":n("_accessibility:buttons.next"),onClick:()=>{d&&l(s+1)}})]})};function ce(){const{t:n}=E.useTranslation(),{pageSizes:t,pageSize:r,setPageSize:s}=q.useTableOptions(),l=o.useMemo(()=>t?.map(a=>({id:a,value:a})),[t]);return e.jsxs("div",{className:"page-size",children:[e.jsx("p",{children:n("_accessibility:components.table.pageSizes")}),e.jsx(P.SelectInput,{value:r,options:l,inputClassName:"page-size-input",containerClassName:"page-size-input-container",helperTextClassName:"hidden",onChange:a=>s(Number(a.target.value))})]})}function ue(){return e.jsxs("div",{className:"table-footer",children:[e.jsx(Te,{}),e.jsx(ce,{}),e.jsx(ie,{}),e.jsx(oe,{})]})}const Se=n=>n,de=n=>{const{t}=E.useTranslation(),{columns:r,softDeleteProperty:s="deletedAt",data:l,actions:a,selectedRows:d,expandedRows:c=[],onRowSelectionChange:u,onRowExpand:i}=n,p=o.useMemo(()=>ee(r),[r]),m=o.useMemo(()=>new Map(c.map(x=>[x.rowId,x])),[c]);return l?.map(x=>{const h=d.has(x.id),v=m.get(x.id),y=!!v,C=p.length+1+(a?1:0);return e.jsxs(o.Fragment,{children:[e.jsxs("tr",{className:`table-row ${i?"expandable":""} ${x[s]?"deleted-class":""} ${h?"selected":""} ${y?"expanded":""}`,onClick:()=>i?.(x),children:[e.jsx("td",{className:"table-row-cell table-row-checkbox",children:e.jsx("input",{type:"checkbox",checked:h,onClick:N=>N.stopPropagation(),onChange:()=>u(x),"aria-label":t("_accessibility:components.table.selectRow")})}),a?e.jsx("td",{className:"w-px",children:e.jsx("div",{className:"table-row-cell-action",children:(()=>{const N=a(x).filter(j=>!j.hidden),M=N.filter(j=>j.sticky),S=N.filter(j=>!j.sticky);return e.jsxs(e.Fragment,{children:[M.map(j=>e.jsx(Q.Tooltip,{content:j.tooltip,children:e.jsx(X,{...j,onClick:()=>j.onClick(x),className:"row-table-action"})},j.id)),S.length>0&&e.jsx(Z,{actions:S})]})})()})}):null,p?.map((N,M)=>{const S=x[N.key],j=N.renderBody?N.renderBody(S,x):Se(S);return e.jsx("td",{className:`table-row-cell ${M===0?"basic":""} ${N.className??""}`,children:i&&M===0?e.jsxs("div",{className:"table-row-expand-content",children:[e.jsx("span",{className:"table-row-expand-indicator","aria-hidden":!0,"data-state":y?"expanded":"collapsed",children:y?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:j})]}):j},N.key)})]}),y&&v?.content!==null&&typeof v?.content<"u"&&e.jsx("tr",{className:"table-row-expanded",children:e.jsx("td",{className:"table-row-expanded-cell",colSpan:C,children:e.jsx("div",{className:`table-row-expanded-content ${v.isVisible?"open":"closed"}`,children:e.jsx("div",{className:"table-row-expanded-inner",children:v.content})})})})]},x.id)})};function pe(){const{t:n}=E.useTranslation();return e.jsx("div",{className:"table-empty",children:e.jsx("p",{children:n("_accessibility:components.table.empty")})})}const me=n=>{const{columns:t,title:r,isLoading:s,toolbar:l,filterOptions:a}=n,{countOfFilters:d}=q.useTableOptions(),{t:c}=E.useTranslation(),u=o.useMemo(()=>t?[...t].sort((C,N)=>(N.pos??0)-(C.pos??0)).filter(C=>!!C.filterOptions).map(C=>({...C.filterOptions,label:C.filterOptions?.label??C.label,propertyName:C.key})):[],[t]),[i,p]=o.useState(!1),m=o.useCallback(C=>{a?.dropdown?.setOpened?a.dropdown.setOpened(C??!1):p(C??!1)},[a]),x=o.useMemo(()=>a?.dropdown?.opened??i,[a,i]),h=u.length>0,v=h&&a?.button?.hide!==!0,y=h&&x;return e.jsxs("div",{className:`table-header ${y?"showing-filters":""}`,children:[e.jsxs("div",{children:[r&&e.jsx("h1",{className:"table-header-title",children:r}),s?null:e.jsxs("div",{className:"table-header-content",children:[l,v&&e.jsxs(H.IconButton,{icon:a?.button?.icon??e.jsx(I.Filters,{className:"filter-dropdown-trigger-icon"}),className:"filter-dropdown-button normal filter-dropdown-trigger","aria-haspopup":"true",onClick:()=>m(!x),"aria-expanded":x,children:[e.jsx(xe.Badge,{count:d,className:`${d>0?"show":"hide"} `}),e.jsx("span",{className:"table-header-sr",children:c("_accessibility:buttons.filters")}),e.jsx("wbr",{})]})]})]}),h&&e.jsx(re,{filters:u,show:y,handleShow:m,options:a}),e.jsx(le,{filtersDefinition:u})]})};function he({count:n,multiActions:t,onActionClick:r}){const{t:s}=E.useTranslation();return e.jsxs("div",{className:"table-selection-bar",children:[e.jsx("p",{className:"table-selection-bar-count",children:s("_accessibility:components.table.selectedCount",{count:n})}),t.length>0&&e.jsx("div",{className:"table-selection-bar-actions",children:t.map(l=>e.jsx(Q.Tooltip,{content:l.tooltip,children:e.jsx(H.IconButton,{icon:l.icon,className:"multi-table-action",onClick:()=>r(l),disabled:l.disabled,"aria-label":l.tooltip})},l.id))})]})}const W=220;function Fe({data:n,allowMultipleExpandedRows:t,controlledExpandedRowId:r,onExpandedRowChange:s,onRowExpand:l,findRowById:a}){const[d,c]=o.useState(null),[u,i]=o.useState(null),[p,m]=o.useState(null),[x,h]=o.useState(null),[v,y]=o.useState(!1),[C,N]=o.useState(new Set),[M,S]=o.useState([]),j=o.useRef(null),O=o.useRef(null),$=o.useRef(new Map),R=typeof r<"u",k=t&&!R,w=R?r??null:d,V=o.useCallback(()=>{O.current&&(clearTimeout(O.current),O.current=null)},[]),A=o.useCallback(b=>{if(typeof b<"u"){const f=$.current.get(b);if(!f)return;clearTimeout(f),$.current.delete(b);return}$.current.forEach(f=>clearTimeout(f)),$.current.clear()},[]),z=o.useCallback(b=>{A(b),S(f=>f.some(T=>T.rowId===b)?f.map(T=>T.rowId===b?{...T,isVisible:!1}:T):f),$.current.set(b,setTimeout(()=>{S(f=>f.filter(g=>g.rowId!==b)),$.current.delete(b)},W))},[A]),U=o.useCallback((b,f)=>{A(b),S(g=>g.some(_=>_.rowId===b)?g.map(_=>_.rowId===b?{..._,content:f,isVisible:!1}:_):[...g,{rowId:b,content:f,isVisible:!1}]),requestAnimationFrame(()=>{S(g=>g.map(T=>T.rowId===b?{...T,isVisible:!0}:T))})},[A]);o.useEffect(()=>{if(!k)return;const b=new Set(n.map(f=>f.id));N(f=>{const g=new Set;return f.forEach(T=>{if(b.has(T)){g.add(T);return}A(T)}),g}),S(f=>(f.forEach(g=>{b.has(g.rowId)||A(g.rowId)}),f.filter(g=>b.has(g.rowId))))},[n,k,A]),o.useEffect(()=>{if(k)return;if(w===null){i(null),R&&(j.current=null);return}a(w)||(R||c(null),i(null),R&&(j.current=null))},[n,w,a,R,k]),o.useEffect(()=>{if(!k){if(V(),w===null||u===null){if(p===null){y(!1),h(null);return}y(!1),O.current=setTimeout(()=>{m(null),h(null),O.current=null},W);return}if(p===null){m(w),h(u),requestAnimationFrame(()=>y(!0));return}if(p===w){h(u),requestAnimationFrame(()=>y(!0));return}y(!1),O.current=setTimeout(()=>{m(w),h(u),requestAnimationFrame(()=>y(!0)),O.current=null},W)}},[V,u,w,k,p]),o.useEffect(()=>()=>{V(),A()},[V,A]),o.useEffect(()=>{if(!R)return;if(w===null){i(null),j.current=null;return}const b=a(w);if(!b){i(null),j.current=null;return}const f=j.current;i(l?.(b,f)??null),j.current=b},[w,a,R,l]);const be=o.useCallback(b=>{if(k){if(C.has(b.id)){N(L=>{const D=new Set(L);return D.delete(b.id),D}),z(b.id),s?.(null,b);return}N(L=>{const D=new Set(L);return D.add(b.id),D});const _=l?.(b,null)??null;_!==null&&typeof _<"u"?U(b.id,_):(A(b.id),S(L=>L.filter(D=>D.rowId!==b.id))),s?.(b,null);return}const f=w===b.id,g=f?b:a(w);if(R){s?.(f?null:b,g);return}if(f){c(null),i(null),s?.(null,b);return}c(b.id),i(l?.(b,g)??null),s?.(b,g)},[w,z,A,U,a,C,R,k,s,l]);return{expandedRowsToRender:o.useMemo(()=>k?M:p===null||x===null||typeof x>"u"?[]:[{rowId:p,content:x,isVisible:v}],[v,k,x,p,M]),onRowExpandChange:be}}function Ae({actions:n,selectedRowsData:t}){const r=o.useMemo(()=>!n||!t.length?[]:t.reduce((l,a,d)=>{const c=n(a).filter(i=>i.multiple&&!i.hidden);if(d===0)return c;const u=new Map(l.map(i=>[i.id,i]));return c.reduce((i,p)=>{const m=u.get(p.id);return m&&i.push({...m,...p,disabled:p.disabled||m.disabled}),i},[])},[]),[n,t]),s=o.useCallback(l=>{if(t.length){if(l.onMultipleClick){l.onMultipleClick(t);return}t.forEach(a=>l.onClick(a))}},[t]);return{multiActions:r,handleMultipleActionClick:s}}function Re({data:n,onRowSelect:t,onSelectedRowsChange:r}){const[s,l]=o.useState(new Set),a=o.useMemo(()=>n?.filter(i=>s.has(i.id))??[],[n,s]);o.useEffect(()=>{if(!n?.length){l(new Set);return}l(i=>{const p=new Set,m=new Set(n.map(x=>x.id));return i.forEach(x=>{m.has(x)&&p.add(x)}),p})},[n]),o.useEffect(()=>{r&&r(a)},[a,r]);const d=o.useCallback(i=>{l(p=>{const m=new Set(p);return m.has(i.id)?(m.delete(i.id),t?.(i,!1)):(m.add(i.id),t?.(i,!0)),m})},[t]),c=o.useCallback(()=>{l(i=>{const p=new Set(i),m=n??[],x=m.every(h=>p.has(h.id));return m.forEach(h=>{const v=p.has(h.id);x?v&&(p.delete(h.id),t?.(h,!1)):v||(p.add(h.id),t?.(h,!0))}),p})},[n,t]),u=o.useMemo(()=>{if(!n?.length)return{allSelected:!1,hasSomeSelected:!1};const i=n.every(m=>s.has(m.id)),p=n.some(m=>s.has(m.id));return{allSelected:i,hasSomeSelected:p}},[n,s]);return{selectedRows:s,selectedRowsData:a,selectionState:u,onRowSelectionChange:d,onToggleAllRows:c}}function ke(n){const{data:t,onSort:r,entity:s="",isLoading:l=!1,actions:a,columns:d=[],contentClassName:c="",className:u="",softDeleteProperty:i="deletedAt",onRowSelect:p,onSelectedRowsChange:m,allowMultipleExpandedRows:x=!1,expandedRowId:h,onExpandedRowChange:v,onRowExpand:y,...C}=n,N=o.useMemo(()=>!t?.length,[t]),M=o.useCallback(z=>z===null?null:t.find(U=>U.id===z)??null,[t]),{selectedRows:S,selectedRowsData:j,selectionState:O,onRowSelectionChange:$,onToggleAllRows:R}=Re({data:t,onRowSelect:p,onSelectedRowsChange:m}),{expandedRowsToRender:k,onRowExpandChange:w}=Fe({data:t,allowMultipleExpandedRows:x,controlledExpandedRowId:h,onExpandedRowChange:v,onRowExpand:y,findRowById:M}),{multiActions:V,handleMultipleActionClick:A}=Ae({actions:a,selectedRowsData:j});return e.jsx(F.FiltersProvider,{children:e.jsxs("div",{className:`${u} table-main`,children:[e.jsx(me,{columns:d,isLoading:l,...C}),l?e.jsx(ge.Loading,{className:"table-loading"}):e.jsx(e.Fragment,{children:N?e.jsx(pe,{}):e.jsxs(e.Fragment,{children:[!!j.length&&e.jsx(he,{count:j.length,multiActions:V,onActionClick:A}),e.jsx("div",{className:`${c} table-body`,children:e.jsxs("table",{className:"table-content",children:[e.jsx(te,{entity:s,columns:d,onSortCallback:r,hasAction:!!a,selectionState:O,onToggleAllRows:R}),e.jsx("tbody",{children:e.jsx(de,{data:t,actions:a,columns:d,softDeleteProperty:i,selectedRows:S,expandedRows:k,onRowSelectionChange:$,onRowExpand:y?w:void 0})})]})}),e.jsx(ue,{})]})})]})})}exports.Action=X;exports.Actions=Y;exports.ActionsDropdown=Z;exports.ActiveFilters=le;exports.ArrayChip=ne;exports.Columns=te;exports.CountOfTotal=ie;exports.FilterDropdown=re;exports.Footer=ue;exports.Navigation=oe;exports.PageSize=ce;exports.RangeChip=se;exports.Rows=de;exports.Table=ke;exports.TableEmpty=pe;exports.TableHeader=me;exports.TableSelectionBar=he;exports.renderFilterComponent=ae;
|