@tedi-design-system/react 18.1.0-rc.16 → 18.1.0-rc.17
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/_virtual/index.cjs10.js +1 -1
- package/_virtual/index.cjs11.js +1 -1
- package/_virtual/index.cjs12.js +1 -1
- package/_virtual/index.cjs5.js +1 -1
- package/_virtual/index.cjs6.js +1 -1
- package/_virtual/index.cjs7.js +1 -1
- package/_virtual/index.cjs8.js +1 -1
- package/_virtual/index.cjs9.js +1 -1
- package/_virtual/index.es10.js +1 -1
- package/_virtual/index.es11.js +1 -1
- package/_virtual/index.es12.js +1 -1
- package/_virtual/index.es5.js +1 -1
- package/_virtual/index.es6.js +1 -1
- package/_virtual/index.es7.js +1 -1
- package/_virtual/index.es8.js +1 -1
- package/_virtual/index.es9.js +1 -1
- package/bundle-stats.html +1 -1
- package/external/@mui/system/colorManipulator.cjs.js +1 -1
- package/external/@mui/system/colorManipulator.es.js +2 -2
- package/external/@mui/system/createStyled.cjs.js +1 -1
- package/external/@mui/system/createStyled.es.js +6 -6
- package/external/@mui/system/useThemeWithoutDefault.cjs.js +1 -1
- package/external/@mui/system/useThemeWithoutDefault.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.cjs.js +1 -1
- package/external/hoist-non-react-statics/external/react-is/index.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.development.es.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.cjs.js +1 -1
- package/external/prop-types/external/react-is/cjs/react-is.production.min.es.js +1 -1
- package/external/prop-types/external/react-is/index.cjs.js +1 -1
- package/external/prop-types/external/react-is/index.es.js +1 -1
- package/index.css +1 -1
- package/package.json +1 -1
- package/src/community/components/form/file-upload/file-upload.d.ts +3 -0
- package/src/tedi/components/form/file-upload/file-upload.cjs.js +1 -1
- package/src/tedi/components/form/file-upload/file-upload.d.ts +4 -1
- package/src/tedi/components/form/file-upload/file-upload.es.js +138 -119
- package/src/tedi/components/form/file-upload/file-upload.module.scss.cjs.js +1 -1
- package/src/tedi/components/form/file-upload/file-upload.module.scss.es.js +1 -1
- package/src/tedi/components/tags/tag/tag.cjs.js +1 -1
- package/src/tedi/components/tags/tag/tag.d.ts +9 -0
- package/src/tedi/components/tags/tag/tag.es.js +18 -17
- package/src/tedi/helpers/hooks/use-file-upload.cjs.js +1 -1
- package/src/tedi/helpers/hooks/use-file-upload.es.js +71 -66
- package/src/tedi/providers/label-provider/labels-map.cjs.js +1 -1
- package/src/tedi/providers/label-provider/labels-map.d.ts +14 -0
- package/src/tedi/providers/label-provider/labels-map.es.js +14 -0
package/package.json
CHANGED
|
@@ -12,6 +12,9 @@ export interface RejectedFile {
|
|
|
12
12
|
type: FileRejectionType;
|
|
13
13
|
file: File;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use FileUpload from `@tedi-design-system/react/tedi` instead.
|
|
17
|
+
*/
|
|
15
18
|
export interface FileUploadProps extends FormLabelProps {
|
|
16
19
|
/**
|
|
17
20
|
* Additional classes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("../../../../../external/classnames/index.cjs.js"),p=require("react"),de=require("../../../helpers/hooks/use-file-upload.cjs.js"),oe=require("../../base/typography/text/text.cjs.js"),S=require("../../buttons/button/button.cjs.js"),re=require("../../buttons/closing-button/closing-button.cjs.js"),ce=require("../form-label/form-label.cjs.js"),ue=require("../../misc/separator/separator.cjs.js"),fe=require("../../tags/tag/tag.cjs.js"),z=require("../feedback-text/feedback-text.cjs.js"),g=require("../input-group/input-group.cjs.js"),a=require("./file-upload.module.scss.cjs.js"),pe=require("../../../providers/label-provider/use-labels.cjs.js"),M=require("../../../helpers/hooks/use-breakpoint.cjs.js"),me=require("../../layout/grid/row.cjs.js"),O=require("../../layout/grid/col.cjs.js"),A=P=>{var U;const{getLabel:n}=pe.useLabels(),{id:V,name:$,label:v,accept:y,multiple:F,onChange:m,className:D,wrapperClassName:W,defaultFiles:H,onDelete:J,hasClearButton:K=!0,files:c,readOnly:x,disabled:s=!1,maxSize:Q,validateIndividually:X=!1,size:u="default",helper:i,...Y}=P,{innerFiles:_,uploadErrorHelper:t,onFileChange:Z,onFileRemove:E,handleClear:G,announcement:ee}=de.useFileUpload({accept:y,maxSize:Q,multiple:F,validateIndividually:X,defaultFiles:H,onChange:m,onDelete:J,files:c}),le=M.default(),ae=p.useId(),d=(U=g.useOptionalInputGroup)==null?void 0:U.call(g),te=d==null?void 0:d.hasExternalLabel,f=V??(d==null?void 0:d.inputId)??ae,q=p.useRef(null),N=p.useRef(null),ie=j.default(a.default["tedi-file-upload"],{[a.default["tedi-file-upload--disabled"]]:s},D),B=(t==null?void 0:t.type)==="error",h=i??(B?void 0:t),b=B?t:void 0,C=h?(i==null?void 0:i.id)??`${f}-helper`:void 0,L=b?`${f}-error`:void 0,k=[C,L].filter(Boolean).join(" ")||void 0,o=p.useMemo(()=>c&&m?c:_,[c,_,m]),R=()=>{var l;return(l=N.current)==null?void 0:l.focus()},se=l=>{E(l),R()},I=()=>{G(),R()},ne=(l,r)=>{const w=l.isValid===!1;return e.jsx("li",{children:e.jsxs(fe.Tag,{role:"presentation",color:w?"danger":"primary",onClose:!l.isLoading&&!s&&!x?()=>se(l):void 0,isLoading:l.isLoading,closeButtonProps:{title:`${n("remove")} ${l.name}`},children:[l.name,w&&e.jsxs("span",{className:"sr-only",children:[" (",n("file-upload.failed"),")"]})]})},l.id??r)},T=()=>{if(o.length>1)return e.jsx("ul",{className:a.default["tedi-file-upload__items"],children:o.map((l,r)=>ne(l,r))});if(o.length===1){const l=o[0],r=l.isValid===!1;return e.jsxs(oe.Text,{className:j.default(a.default["tedi-file-upload__items"],a.default["tedi-file-upload__items--truncate"]),children:[l.name,r&&e.jsxs("span",{className:"sr-only",children:[" (",n("file-upload.failed"),")"]})]})}return null};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:a.default["tedi-file-upload__label-wrapper"],children:!te&&v&&e.jsx(ce.FormLabel,{id:f,label:v??"",...Y,renderWithoutLabel:x,className:a.default["tedi-file-upload__label"],size:u})}),e.jsx("div",{role:"status","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:ee}),x?T():e.jsx("div",{className:j.default(a.default["tedi-file-upload__container"],{[a.default["tedi-file-upload--disabled"]]:s,[a.default["tedi-file-upload--error"]]:((t==null?void 0:t.type)||(i==null?void 0:i.type))==="error",[a.default["tedi-file-upload--valid"]]:((t==null?void 0:t.type)||(i==null?void 0:i.type))==="valid"},{[a.default[`tedi-file-upload__container--${u}`]]:u},W),children:e.jsx("div",{className:a.default["tedi-file-upload__content"],children:e.jsxs(me.Row,{children:[e.jsx(O.Col,{className:"display-flex",children:T()}),e.jsx(O.Col,{xs:12,md:"auto",children:e.jsxs("div",{className:ie,children:[e.jsx("input",{ref:q,id:f,type:"file",name:$,accept:y,onChange:Z,multiple:F,disabled:s,"aria-invalid":!!t&&t.type==="error","aria-describedby":k}),K&&o.length>0&&!s&&e.jsxs(e.Fragment,{children:[M.isBreakpointBelow(le,"md")?e.jsx(S.Button,{visualType:"neutral",iconLeft:"close",disabled:s,onClick:I,className:a.default["tedi-file-upload__button"],children:n("clear")}):e.jsx(re.ClosingButton,{onClick:I,iconSize:18,title:n("clear")}),e.jsx(ue.Separator,{axis:"vertical",height:1.5,spacing:.5,color:"primary"})]}),e.jsx(S.Button,{ref:N,visualType:"neutral",iconLeft:"file_upload",disabled:s,onClick:()=>{var l;return(l=q.current)==null?void 0:l.click()},className:a.default["tedi-file-upload__button"],size:u,"aria-describedby":k,children:n("file-upload.add")})]})})]})})}),h&&e.jsx(z.FeedbackText,{...h,id:C}),b&&e.jsx(z.FeedbackText,{...b,id:L})]})};A.displayName="FileUpload";exports.FileUpload=A;
|
|
@@ -84,5 +84,8 @@ export interface FileUploadProps extends Omit<FormLabelProps, 'id' | 'label'> {
|
|
|
84
84
|
*/
|
|
85
85
|
size?: 'small' | 'default';
|
|
86
86
|
}
|
|
87
|
-
export declare const FileUpload:
|
|
87
|
+
export declare const FileUpload: {
|
|
88
|
+
(props: FileUploadProps): JSX.Element;
|
|
89
|
+
displayName: string;
|
|
90
|
+
};
|
|
88
91
|
export default FileUpload;
|
|
@@ -1,159 +1,178 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { useFileUpload as
|
|
5
|
-
import { Text as
|
|
6
|
-
import { Button as
|
|
7
|
-
import { ClosingButton as
|
|
8
|
-
import { FormLabel as
|
|
9
|
-
import { Separator as
|
|
10
|
-
import { Tag as
|
|
11
|
-
import { FeedbackText as
|
|
12
|
-
import { useOptionalInputGroup as
|
|
13
|
-
import
|
|
14
|
-
import { useLabels as
|
|
15
|
-
import
|
|
16
|
-
import { Row as
|
|
17
|
-
import { Col as
|
|
18
|
-
const
|
|
19
|
-
var
|
|
20
|
-
const { getLabel:
|
|
21
|
-
id:
|
|
22
|
-
name:
|
|
23
|
-
label:
|
|
24
|
-
accept:
|
|
25
|
-
multiple:
|
|
26
|
-
onChange:
|
|
27
|
-
className:
|
|
28
|
-
wrapperClassName:
|
|
29
|
-
defaultFiles:
|
|
30
|
-
onDelete:
|
|
31
|
-
hasClearButton:
|
|
32
|
-
files:
|
|
33
|
-
readOnly:
|
|
34
|
-
disabled:
|
|
35
|
-
maxSize:
|
|
36
|
-
validateIndividually:
|
|
37
|
-
size:
|
|
38
|
-
helper:
|
|
39
|
-
...
|
|
40
|
-
} =
|
|
41
|
-
accept:
|
|
42
|
-
maxSize:
|
|
43
|
-
multiple:
|
|
44
|
-
validateIndividually:
|
|
45
|
-
defaultFiles:
|
|
46
|
-
onChange:
|
|
47
|
-
onDelete:
|
|
48
|
-
files:
|
|
49
|
-
}),
|
|
50
|
-
|
|
51
|
-
return
|
|
52
|
-
|
|
1
|
+
import { jsxs as t, Fragment as z, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import y from "../../../../../external/classnames/index.es.js";
|
|
3
|
+
import f from "react";
|
|
4
|
+
import { useFileUpload as ne } from "../../../helpers/hooks/use-file-upload.es.js";
|
|
5
|
+
import { Text as se } from "../../base/typography/text/text.es.js";
|
|
6
|
+
import { Button as S } from "../../buttons/button/button.es.js";
|
|
7
|
+
import { ClosingButton as re } from "../../buttons/closing-button/closing-button.es.js";
|
|
8
|
+
import { FormLabel as de } from "../form-label/form-label.es.js";
|
|
9
|
+
import { Separator as ce } from "../../misc/separator/separator.es.js";
|
|
10
|
+
import { Tag as me } from "../../tags/tag/tag.es.js";
|
|
11
|
+
import { FeedbackText as A } from "../feedback-text/feedback-text.es.js";
|
|
12
|
+
import { useOptionalInputGroup as pe } from "../input-group/input-group.es.js";
|
|
13
|
+
import l from "./file-upload.module.scss.es.js";
|
|
14
|
+
import { useLabels as ue } from "../../../providers/label-provider/use-labels.es.js";
|
|
15
|
+
import fe, { isBreakpointBelow as he } from "../../../helpers/hooks/use-breakpoint.es.js";
|
|
16
|
+
import { Row as ve } from "../../layout/grid/row.es.js";
|
|
17
|
+
import { Col as M } from "../../layout/grid/col.es.js";
|
|
18
|
+
const be = (O) => {
|
|
19
|
+
var $;
|
|
20
|
+
const { getLabel: s } = ue(), {
|
|
21
|
+
id: V,
|
|
22
|
+
name: D,
|
|
23
|
+
label: g,
|
|
24
|
+
accept: F,
|
|
25
|
+
multiple: N,
|
|
26
|
+
onChange: h,
|
|
27
|
+
className: P,
|
|
28
|
+
wrapperClassName: W,
|
|
29
|
+
defaultFiles: q,
|
|
30
|
+
onDelete: H,
|
|
31
|
+
hasClearButton: J = !0,
|
|
32
|
+
files: m,
|
|
33
|
+
readOnly: v,
|
|
34
|
+
disabled: n = !1,
|
|
35
|
+
maxSize: K,
|
|
36
|
+
validateIndividually: Q = !1,
|
|
37
|
+
size: p = "default",
|
|
38
|
+
helper: o,
|
|
39
|
+
...X
|
|
40
|
+
} = O, { innerFiles: B, uploadErrorHelper: a, onFileChange: Y, onFileRemove: Z, handleClear: E, announcement: G } = ne({
|
|
41
|
+
accept: F,
|
|
42
|
+
maxSize: K,
|
|
43
|
+
multiple: N,
|
|
44
|
+
validateIndividually: Q,
|
|
45
|
+
defaultFiles: q,
|
|
46
|
+
onChange: h,
|
|
47
|
+
onDelete: H,
|
|
48
|
+
files: m
|
|
49
|
+
}), ee = fe(), ie = f.useId(), r = ($ = pe) == null ? void 0 : $(), le = r == null ? void 0 : r.hasExternalLabel, u = V ?? (r == null ? void 0 : r.inputId) ?? ie, C = f.useRef(null), L = f.useRef(null), ae = y(l["tedi-file-upload"], { [l["tedi-file-upload--disabled"]]: n }, P), x = (a == null ? void 0 : a.type) === "error", b = o ?? (x ? void 0 : a), _ = x ? a : void 0, k = b ? (o == null ? void 0 : o.id) ?? `${u}-helper` : void 0, I = _ ? `${u}-error` : void 0, R = [k, I].filter(Boolean).join(" ") || void 0, d = f.useMemo(() => m && h ? m : B, [m, B, h]), w = () => {
|
|
50
|
+
var e;
|
|
51
|
+
return (e = L.current) == null ? void 0 : e.focus();
|
|
52
|
+
}, oe = (e) => {
|
|
53
|
+
Z(e), w();
|
|
54
|
+
}, T = () => {
|
|
55
|
+
E(), w();
|
|
56
|
+
}, te = (e, c) => {
|
|
57
|
+
const j = e.isValid === !1;
|
|
58
|
+
return /* @__PURE__ */ i("li", { children: /* @__PURE__ */ t(
|
|
59
|
+
me,
|
|
53
60
|
{
|
|
54
|
-
|
|
55
|
-
|
|
61
|
+
role: "presentation",
|
|
62
|
+
color: j ? "danger" : "primary",
|
|
63
|
+
onClose: !e.isLoading && !n && !v ? () => oe(e) : void 0,
|
|
56
64
|
isLoading: e.isLoading,
|
|
57
|
-
"
|
|
58
|
-
children:
|
|
65
|
+
closeButtonProps: { title: `${s("remove")} ${e.name}` },
|
|
66
|
+
children: [
|
|
67
|
+
e.name,
|
|
68
|
+
j && /* @__PURE__ */ t("span", { className: "sr-only", children: [
|
|
69
|
+
" (",
|
|
70
|
+
s("file-upload.failed"),
|
|
71
|
+
")"
|
|
72
|
+
] })
|
|
73
|
+
]
|
|
59
74
|
}
|
|
60
|
-
) },
|
|
61
|
-
},
|
|
62
|
-
if (
|
|
63
|
-
return /* @__PURE__ */
|
|
64
|
-
if (
|
|
65
|
-
const e =
|
|
66
|
-
return /* @__PURE__ */ l
|
|
67
|
-
|
|
68
|
-
{
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
);
|
|
75
|
+
) }, e.id ?? c);
|
|
76
|
+
}, U = () => {
|
|
77
|
+
if (d.length > 1)
|
|
78
|
+
return /* @__PURE__ */ i("ul", { className: l["tedi-file-upload__items"], children: d.map((e, c) => te(e, c)) });
|
|
79
|
+
if (d.length === 1) {
|
|
80
|
+
const e = d[0], c = e.isValid === !1;
|
|
81
|
+
return /* @__PURE__ */ t(se, { className: y(l["tedi-file-upload__items"], l["tedi-file-upload__items--truncate"]), children: [
|
|
82
|
+
e.name,
|
|
83
|
+
c && /* @__PURE__ */ t("span", { className: "sr-only", children: [
|
|
84
|
+
" (",
|
|
85
|
+
s("file-upload.failed"),
|
|
86
|
+
")"
|
|
87
|
+
] })
|
|
88
|
+
] });
|
|
74
89
|
}
|
|
75
90
|
return null;
|
|
76
91
|
};
|
|
77
|
-
return /* @__PURE__ */
|
|
78
|
-
/* @__PURE__ */
|
|
79
|
-
|
|
92
|
+
return /* @__PURE__ */ t(z, { children: [
|
|
93
|
+
/* @__PURE__ */ i("div", { className: l["tedi-file-upload__label-wrapper"], children: !le && g && /* @__PURE__ */ i(
|
|
94
|
+
de,
|
|
80
95
|
{
|
|
81
|
-
id:
|
|
82
|
-
label:
|
|
83
|
-
...
|
|
84
|
-
renderWithoutLabel:
|
|
85
|
-
className:
|
|
86
|
-
size:
|
|
96
|
+
id: u,
|
|
97
|
+
label: g ?? "",
|
|
98
|
+
...X,
|
|
99
|
+
renderWithoutLabel: v,
|
|
100
|
+
className: l["tedi-file-upload__label"],
|
|
101
|
+
size: p
|
|
87
102
|
}
|
|
88
103
|
) }),
|
|
89
|
-
/* @__PURE__ */
|
|
90
|
-
|
|
104
|
+
/* @__PURE__ */ i("div", { role: "status", "aria-live": "polite", "aria-atomic": "true", className: "sr-only", children: G }),
|
|
105
|
+
v ? U() : /* @__PURE__ */ i(
|
|
91
106
|
"div",
|
|
92
107
|
{
|
|
93
|
-
className:
|
|
94
|
-
|
|
108
|
+
className: y(
|
|
109
|
+
l["tedi-file-upload__container"],
|
|
95
110
|
{
|
|
96
|
-
[
|
|
97
|
-
[
|
|
98
|
-
[
|
|
111
|
+
[l["tedi-file-upload--disabled"]]: n,
|
|
112
|
+
[l["tedi-file-upload--error"]]: ((a == null ? void 0 : a.type) || (o == null ? void 0 : o.type)) === "error",
|
|
113
|
+
[l["tedi-file-upload--valid"]]: ((a == null ? void 0 : a.type) || (o == null ? void 0 : o.type)) === "valid"
|
|
99
114
|
},
|
|
100
|
-
{ [
|
|
101
|
-
|
|
115
|
+
{ [l[`tedi-file-upload__container--${p}`]]: p },
|
|
116
|
+
W
|
|
102
117
|
),
|
|
103
|
-
children: /* @__PURE__ */
|
|
104
|
-
/* @__PURE__ */
|
|
105
|
-
/* @__PURE__ */
|
|
106
|
-
/* @__PURE__ */
|
|
118
|
+
children: /* @__PURE__ */ i("div", { className: l["tedi-file-upload__content"], children: /* @__PURE__ */ t(ve, { children: [
|
|
119
|
+
/* @__PURE__ */ i(M, { className: "display-flex", children: U() }),
|
|
120
|
+
/* @__PURE__ */ i(M, { xs: 12, md: "auto", children: /* @__PURE__ */ t("div", { className: ae, children: [
|
|
121
|
+
/* @__PURE__ */ i(
|
|
107
122
|
"input",
|
|
108
123
|
{
|
|
109
|
-
ref:
|
|
110
|
-
id:
|
|
124
|
+
ref: C,
|
|
125
|
+
id: u,
|
|
111
126
|
type: "file",
|
|
112
|
-
name:
|
|
113
|
-
accept:
|
|
114
|
-
onChange:
|
|
115
|
-
multiple:
|
|
116
|
-
disabled:
|
|
117
|
-
"aria-invalid": !!
|
|
118
|
-
"aria-describedby":
|
|
127
|
+
name: D,
|
|
128
|
+
accept: F,
|
|
129
|
+
onChange: Y,
|
|
130
|
+
multiple: N,
|
|
131
|
+
disabled: n,
|
|
132
|
+
"aria-invalid": !!a && a.type === "error",
|
|
133
|
+
"aria-describedby": R
|
|
119
134
|
}
|
|
120
135
|
),
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
136
|
+
J && d.length > 0 && !n && /* @__PURE__ */ t(z, { children: [
|
|
137
|
+
he(ee, "md") ? /* @__PURE__ */ i(
|
|
138
|
+
S,
|
|
124
139
|
{
|
|
125
140
|
visualType: "neutral",
|
|
126
141
|
iconLeft: "close",
|
|
127
|
-
disabled:
|
|
128
|
-
onClick:
|
|
129
|
-
className:
|
|
130
|
-
children:
|
|
142
|
+
disabled: n,
|
|
143
|
+
onClick: T,
|
|
144
|
+
className: l["tedi-file-upload__button"],
|
|
145
|
+
children: s("clear")
|
|
131
146
|
}
|
|
132
|
-
) : /* @__PURE__ */
|
|
133
|
-
/* @__PURE__ */
|
|
147
|
+
) : /* @__PURE__ */ i(re, { onClick: T, iconSize: 18, title: s("clear") }),
|
|
148
|
+
/* @__PURE__ */ i(ce, { axis: "vertical", height: 1.5, spacing: 0.5, color: "primary" })
|
|
134
149
|
] }),
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
|
|
150
|
+
/* @__PURE__ */ i(
|
|
151
|
+
S,
|
|
137
152
|
{
|
|
153
|
+
ref: L,
|
|
138
154
|
visualType: "neutral",
|
|
139
155
|
iconLeft: "file_upload",
|
|
140
|
-
disabled:
|
|
156
|
+
disabled: n,
|
|
141
157
|
onClick: () => {
|
|
142
158
|
var e;
|
|
143
|
-
return (e =
|
|
159
|
+
return (e = C.current) == null ? void 0 : e.click();
|
|
144
160
|
},
|
|
145
|
-
className:
|
|
146
|
-
size:
|
|
147
|
-
|
|
161
|
+
className: l["tedi-file-upload__button"],
|
|
162
|
+
size: p,
|
|
163
|
+
"aria-describedby": R,
|
|
164
|
+
children: s("file-upload.add")
|
|
148
165
|
}
|
|
149
166
|
)
|
|
150
167
|
] }) })
|
|
151
168
|
] }) })
|
|
152
169
|
}
|
|
153
170
|
),
|
|
154
|
-
|
|
171
|
+
b && /* @__PURE__ */ i(A, { ...b, id: k }),
|
|
172
|
+
_ && /* @__PURE__ */ i(A, { ..._, id: I })
|
|
155
173
|
] });
|
|
156
174
|
};
|
|
175
|
+
be.displayName = "FileUpload";
|
|
157
176
|
export {
|
|
158
|
-
|
|
177
|
+
be as FileUpload
|
|
159
178
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e={"tedi-file-upload":"tedi-file-upload-115f37c2","tedi-file-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e={"tedi-file-upload":"tedi-file-upload-115f37c2","tedi-file-upload__button":"tedi-file-upload__button-f37449e6","tedi-file-upload__items":"tedi-file-upload__items-c73c19e5","tedi-file-upload__container":"tedi-file-upload__container-6b0f28a8","tedi-file-upload__container--default":"tedi-file-upload__container--default-56af0d96","tedi-file-upload__container--small":"tedi-file-upload__container--small-4d5cd36e","tedi-file-upload--disabled":"tedi-file-upload--disabled-88f4fdcd","tedi-file-upload--error":"tedi-file-upload--error-388cda6f","tedi-file-upload--valid":"tedi-file-upload--valid-28d5eb71","tedi-file-upload__content":"tedi-file-upload__content-8b6bf324","tedi-file-upload__items--truncate":"tedi-file-upload__items--truncate-5c249a01","tedi-file-upload__tag--truncate":"tedi-file-upload__tag--truncate-4c99cb2b"};exports.default=e;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const e = {
|
|
2
2
|
"tedi-file-upload": "tedi-file-upload-115f37c2",
|
|
3
|
+
"tedi-file-upload__button": "tedi-file-upload__button-f37449e6",
|
|
3
4
|
"tedi-file-upload__items": "tedi-file-upload__items-c73c19e5",
|
|
4
5
|
"tedi-file-upload__container": "tedi-file-upload__container-6b0f28a8",
|
|
5
6
|
"tedi-file-upload__container--default": "tedi-file-upload__container--default-56af0d96",
|
|
6
|
-
"tedi-file-upload__button": "tedi-file-upload__button-f37449e6",
|
|
7
7
|
"tedi-file-upload__container--small": "tedi-file-upload__container--small-4d5cd36e",
|
|
8
8
|
"tedi-file-upload--disabled": "tedi-file-upload--disabled-88f4fdcd",
|
|
9
9
|
"tedi-file-upload--error": "tedi-file-upload--error-388cda6f",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),f=require("../../../../../external/classnames/index.cjs.js"),m=require("../../base/icon/icon.cjs.js"),_=require("../../buttons/closing-button/closing-button.cjs.js"),j=require("../../loaders/spinner/spinner.cjs.js"),x=require("../../misc/ellipsis/ellipsis.cjs.js"),e=require("./tag.module.scss.cjs.js"),q=require("../../../helpers/hooks/use-breakpoint-props.cjs.js"),v=l=>{const{getCurrentBreakpointProps:n}=q.useBreakpointProps(l.defaultServerBreakpoint),{children:o,className:c,onClose:s,closeButtonProps:d,isLoading:i=!1,color:a="primary",ellipsis:r=!1,role:u="status",...p}=n(l),g=f.default(e.default["tedi-tag"],a&&e.default[`tedi-tag--color-${a}`],s&&!i&&e.default["tedi-tag__close"],r!==!1&&e.default["tedi-tag--ellipsis"],c);return t.jsxs("div",{className:g,role:u,"aria-live":i?"polite":void 0,...p,children:[a==="danger"&&t.jsx("div",{className:e.default["tedi-tag__icon-wrapper"],children:t.jsx(m.Icon,{name:"info",color:"danger",size:16,className:e.default["tedi-tag__icon--error"]})}),t.jsx("div",{className:e.default["tedi-tag__content"],children:r!==!1?t.jsx(x.Ellipsis,{position:r==="start"?"start":"end",lineClamp:1,children:o}):o}),i&&!s&&t.jsx("div",{className:e.default["tedi-tag__icon-wrapper"],children:t.jsx(j.Spinner,{className:e.default["tedi-tag__loader"]})}),!i&&s&&t.jsx(_.ClosingButton,{iconSize:18,...d,onClick:s})]})};exports.Tag=v;
|
|
@@ -47,6 +47,15 @@ export interface TagProps extends BreakpointSupport<TagBreakpointProps> {
|
|
|
47
47
|
* @default false
|
|
48
48
|
*/
|
|
49
49
|
isLoading?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Overrides the Tag's implicit live-region role. Tags default to `role="status"`
|
|
52
|
+
* so they are announced by assistive tech. When a Tag is rendered as static
|
|
53
|
+
* content inside a list — and additions/removals are announced elsewhere — pass
|
|
54
|
+
* e.g. `role="presentation"` so it is not read as a live status, which otherwise
|
|
55
|
+
* makes some screen readers (e.g. JAWS) announce the content twice on focus.
|
|
56
|
+
* @default 'status'
|
|
57
|
+
*/
|
|
58
|
+
role?: React.AriaRole;
|
|
50
59
|
}
|
|
51
60
|
export declare const Tag: (props: TagProps) => JSX.Element;
|
|
52
61
|
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { Icon as
|
|
4
|
-
import { ClosingButton as
|
|
5
|
-
import { Spinner as
|
|
6
|
-
import { Ellipsis as
|
|
1
|
+
import { jsxs as f, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import _ from "../../../../../external/classnames/index.es.js";
|
|
3
|
+
import { Icon as N } from "../../base/icon/icon.es.js";
|
|
4
|
+
import { ClosingButton as u } from "../../buttons/closing-button/closing-button.es.js";
|
|
5
|
+
import { Spinner as v } from "../../loaders/spinner/spinner.es.js";
|
|
6
|
+
import { Ellipsis as B } from "../../misc/ellipsis/ellipsis.es.js";
|
|
7
7
|
import e from "./tag.module.scss.es.js";
|
|
8
|
-
import { useBreakpointProps as
|
|
9
|
-
const
|
|
10
|
-
const { getCurrentBreakpointProps: n } =
|
|
8
|
+
import { useBreakpointProps as h } from "../../../helpers/hooks/use-breakpoint-props.es.js";
|
|
9
|
+
const z = (a) => {
|
|
10
|
+
const { getCurrentBreakpointProps: n } = h(a.defaultServerBreakpoint), {
|
|
11
11
|
children: l,
|
|
12
12
|
className: c,
|
|
13
13
|
onClose: o,
|
|
@@ -15,21 +15,22 @@ const y = (a) => {
|
|
|
15
15
|
isLoading: t = !1,
|
|
16
16
|
color: r = "primary",
|
|
17
17
|
ellipsis: s = !1,
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
role: d = "status",
|
|
19
|
+
...p
|
|
20
|
+
} = n(a), g = _(
|
|
20
21
|
e["tedi-tag"],
|
|
21
22
|
r && e[`tedi-tag--color-${r}`],
|
|
22
23
|
o && !t && e["tedi-tag__close"],
|
|
23
24
|
s !== !1 && e["tedi-tag--ellipsis"],
|
|
24
25
|
c
|
|
25
26
|
);
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
-
r === "danger" && /* @__PURE__ */ i("div", { className: e["tedi-tag__icon-wrapper"], children: /* @__PURE__ */ i(
|
|
28
|
-
/* @__PURE__ */ i("div", { className: e["tedi-tag__content"], children: s !== !1 ? /* @__PURE__ */ i(
|
|
29
|
-
t && !o && /* @__PURE__ */ i("div", { className: e["tedi-tag__icon-wrapper"], children: /* @__PURE__ */ i(
|
|
30
|
-
!t && o && /* @__PURE__ */ i(
|
|
27
|
+
return /* @__PURE__ */ f("div", { className: g, role: d, "aria-live": t ? "polite" : void 0, ...p, children: [
|
|
28
|
+
r === "danger" && /* @__PURE__ */ i("div", { className: e["tedi-tag__icon-wrapper"], children: /* @__PURE__ */ i(N, { name: "info", color: "danger", size: 16, className: e["tedi-tag__icon--error"] }) }),
|
|
29
|
+
/* @__PURE__ */ i("div", { className: e["tedi-tag__content"], children: s !== !1 ? /* @__PURE__ */ i(B, { position: s === "start" ? "start" : "end", lineClamp: 1, children: l }) : l }),
|
|
30
|
+
t && !o && /* @__PURE__ */ i("div", { className: e["tedi-tag__icon-wrapper"], children: /* @__PURE__ */ i(v, { className: e["tedi-tag__loader"] }) }),
|
|
31
|
+
!t && o && /* @__PURE__ */ i(u, { iconSize: 18, ...m, onClick: o })
|
|
31
32
|
] });
|
|
32
33
|
};
|
|
33
34
|
export {
|
|
34
|
-
|
|
35
|
+
z as Tag
|
|
35
36
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),z=require("../../providers/label-provider/use-labels.cjs.js"),j=({accept:F,maxSize:s},o)=>{if(!F&&!s)return;const u=[F&&`${o("file-upload.accept")} ${F.replaceAll(",",", ")}`,s&&`${o("file-upload.max-size")} ${s}MB`].filter(Boolean).join(". ");return u.length?{text:u}:void 0},I=()=>`${Date.now()}-${Math.random().toString(36).slice(2)}`,O=100,_=F=>{const{getLabel:s}=z.useLabels(),{accept:o,maxSize:u,multiple:w=!1,validateIndividually:b=!1,defaultFiles:L=[],onChange:c,onDelete:f,files:R,announcementTimeout:S=5e3}=F,h=R!==void 0,[A,x]=a.useState(L),p=h?R:A,[C,y]=a.useState(j({accept:o,maxSize:u},s)),[H,M]=a.useState(""),v=a.useRef(!0),g=a.useRef(),T=a.useRef();a.useEffect(()=>()=>{v.current=!1,g.current&&clearTimeout(g.current),T.current&&clearTimeout(T.current)},[]);const E=a.useCallback(t=>{!t||!v.current||(M(""),g.current&&clearTimeout(g.current),T.current&&clearTimeout(T.current),g.current=setTimeout(()=>{v.current&&(M(t),T.current=setTimeout(()=>{v.current&&M("")},S))},O))},[S]),d=a.useRef(null),N=t=>{var n;if(!o)return!0;const l=o.split(",").map(e=>e.trim().toLowerCase()),r=t.name.includes(".")?`.${(n=t.name.split(".").pop())==null?void 0:n.toLowerCase()}`:"",i=t.type.toLowerCase();return l.includes(r)||l.includes(i)},U=t=>{const l=t.reduce((r,{type:i,file:n})=>(r[i].push(n.name),r),{extension:[],size:[]});return Object.entries(l).filter(([r,i])=>i.length).map(([r,i])=>{const n=i.map(e=>`'${e}'`).join(", ");return s(`file-upload.${r}-rejected`,n)}).join(". ")};return{innerFiles:p,uploadErrorHelper:C,onFileChange:t=>{if(t.target.files){const l=Array.from(t.target.files),r=[],i=l.map(e=>{const m=N(e),$=!u||e.size<=u*1024**2;m||r.push({type:"extension",file:e}),$||r.push({type:"size",file:e});const V=new File([e],e.name,{type:e.type,lastModified:e.lastModified});return Object.assign(V,{id:I(),isLoading:!1,isValid:m&&$})});let n=[];if(!w&&i.length>0)i[0].isValid&&(n=[i[0]]);else if(b)n=[...p,...i];else{const e=i.filter(m=>m.isValid);e.length>0&&(n=[...p,...e])}if(n.length>0&&(h||x(n),c==null||c(n)),r.length){const e=U(r);y({type:"error",text:e}),E(e)}else if(y(j({accept:o,maxSize:u},s)),n.length>0){const e=n.filter(m=>!p.includes(m)).length;E(s("file-upload.success-added",e.toString()))}t.target.value="",d.current&&(d.current.value="")}},onFileRemove:t=>{const l=p.filter(r=>r!==t);h||x(l),f==null||f(t),c==null||c(l),l.length===0&&y(j({accept:o,maxSize:u},s)),E(s("file-upload.removed",t.name??"")),d.current&&(d.current.value="")},handleClear:()=>{const t=[...p];return t.forEach(l=>f==null?void 0:f(l)),h||x([]),c==null||c([]),y(j({accept:o,maxSize:u},s)),E(s("file-upload.cleared")),d.current&&(d.current.value=""),t},fileInputRef:d,announcement:H}};exports.useFileUpload=_;
|