@alixpartners/ui-components 2.3.1 → 2.4.0
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 +97 -99
- package/dist/{ap-logos-Cl1TR5nm.js → ap-logos-CwA4O8B7.js} +1 -1
- package/dist/assets/Button.css +1 -1
- package/dist/assets/Creatable.css +1 -1
- package/dist/assets/Dropdown.css +1 -1
- package/dist/assets/FilePicker.css +1 -1
- package/dist/assets/ap-logos-types.d.ts +1 -1
- package/dist/assets/ap-logos.d.ts +1 -1
- package/dist/components/Button/Button.d.ts +7 -3
- package/dist/components/Button/Button.js +35 -28
- package/dist/components/Creatable/Creatable.js +1 -1
- package/dist/components/Dropdown/Dropdown.js +6 -6
- package/dist/components/FilePicker/FilePicker.d.ts +80 -21
- package/dist/components/FilePicker/FilePicker.js +235 -148
- package/dist/components/FilePicker/FilePicker.test.js +153 -6
- package/dist/components/Logo/Logo.js +35 -23
- package/dist/components/Logos/LogosGallery.js +1 -1
- package/dist/components/NavBar/NavBar.js +1 -1
- package/dist/components/SplitButton/SplitButton.js +1 -1
- package/dist/components/TagsFields/TagsFields.js +1 -1
- package/dist/components/Tooltip/Tooltip.js +1 -1
- package/dist/{index-C-3_YVJ1.js → index-D34Qo5Qx.js} +478 -473
- package/dist/{index-C4ffg1vf.js → index-DZ4Gof57.js} +1 -1
- package/dist/{index-D_3jWVyV.js → index-DgdVwltD.js} +1 -1
- package/dist/main.d.ts +2 -2
- package/dist/main.js +42 -41
- package/dist/web.config +8 -8
- package/package.json +87 -87
|
@@ -1,15 +1,47 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { InteractiveEventHandlers } from '../../types/native-events';
|
|
2
3
|
import { InputLabelTooltipProps } from '../Input/Input';
|
|
3
4
|
export type UploadFile = {
|
|
4
5
|
file: File;
|
|
5
6
|
error?: string;
|
|
6
7
|
};
|
|
8
|
+
export type FilePickerContextValue = {
|
|
9
|
+
id: string;
|
|
10
|
+
type: 'single' | 'multiple';
|
|
11
|
+
maxFiles: number;
|
|
12
|
+
fileExtensionsAllowed: string[];
|
|
13
|
+
fileExtensionsAllowedText: string;
|
|
14
|
+
maxSize: number;
|
|
15
|
+
queueFiles: boolean;
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
isUploadDisabled: boolean;
|
|
18
|
+
uploadedFiles: UploadFile[];
|
|
19
|
+
isMaxFilesExceeded: boolean;
|
|
20
|
+
label: string;
|
|
21
|
+
required: boolean;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
errorMessage?: string;
|
|
24
|
+
helpText?: string;
|
|
25
|
+
helpLink?: string;
|
|
26
|
+
helpLinkText?: string;
|
|
27
|
+
multipleHelpText?: string;
|
|
28
|
+
multipleButtonHelpText?: string;
|
|
29
|
+
labelTooltip?: InputLabelTooltipProps;
|
|
30
|
+
accept: string;
|
|
31
|
+
inputRef: React.RefObject<HTMLInputElement | null>;
|
|
32
|
+
triggerInput: () => void;
|
|
33
|
+
handleKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => void;
|
|
34
|
+
handleRemoveFile: (fileName: string) => void;
|
|
35
|
+
displayFileSize: (size: number) => string;
|
|
36
|
+
};
|
|
37
|
+
declare function useFilePickerContext(): FilePickerContextValue;
|
|
7
38
|
type FilePickerProps = {
|
|
8
39
|
type?: 'single' | 'multiple';
|
|
9
40
|
maxFiles?: number;
|
|
10
41
|
fileExtensionsAllowed: string[];
|
|
11
42
|
maxSize: number;
|
|
12
43
|
queueFiles?: boolean;
|
|
44
|
+
isUploadDisabled?: boolean;
|
|
13
45
|
disabled?: boolean;
|
|
14
46
|
value?: File[];
|
|
15
47
|
label: string;
|
|
@@ -19,30 +51,57 @@ type FilePickerProps = {
|
|
|
19
51
|
helpText?: string;
|
|
20
52
|
helpLink?: string;
|
|
21
53
|
helpLinkText?: string;
|
|
54
|
+
multipleHelpText?: string;
|
|
55
|
+
multipleButtonHelpText?: string;
|
|
22
56
|
labelTooltip?: InputLabelTooltipProps;
|
|
23
57
|
onUpload?: (files: UploadFile[]) => void;
|
|
24
58
|
onRemoveFile?: (fileName: string) => void;
|
|
59
|
+
children?: ReactNode;
|
|
25
60
|
} & InteractiveEventHandlers;
|
|
26
61
|
/**
|
|
27
|
-
* FilePicker
|
|
28
|
-
*
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
|
|
62
|
+
* FilePicker root. Use with no children for default layout, or compose with
|
|
63
|
+
* FilePicker.Label, FilePicker.BrowseButton, FilePicker.HelpText, FilePicker.UploadedFilesList, etc.
|
|
64
|
+
*/
|
|
65
|
+
declare function FilePickerRoot({ type, maxFiles, fileExtensionsAllowed, maxSize, queueFiles, disabled, isUploadDisabled, value, label, required, placeholder, errorMessage, helpText, helpLink, helpLinkText, multipleHelpText, multipleButtonHelpText, labelTooltip, onUpload, onRemoveFile, children, }: FilePickerProps): import("react/jsx-runtime").JSX.Element;
|
|
66
|
+
type FilePickerLabelProps = {
|
|
67
|
+
/** Override label text. If not provided, uses FilePicker's label prop. */
|
|
68
|
+
children?: ReactNode;
|
|
69
|
+
};
|
|
70
|
+
declare function FilePickerLabel({ children }: FilePickerLabelProps): import("react/jsx-runtime").JSX.Element;
|
|
71
|
+
type FilePickerBrowseButtonProps = {
|
|
72
|
+
/** Override button content (e.g. "Browse file" or "Browse files (max 5)"). */
|
|
73
|
+
children?: ReactNode;
|
|
74
|
+
className?: string;
|
|
75
|
+
};
|
|
76
|
+
declare function FilePickerBrowseButton({ children, className }: FilePickerBrowseButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
77
|
+
/**
|
|
78
|
+
* Wrapper for single-file mode: groups the input row and optional delete action.
|
|
79
|
+
* Use with FilePicker.SingleFileRow and FilePicker.SingleFileActions as children.
|
|
80
|
+
*/
|
|
81
|
+
declare function FilePickerSingleFileContainer({ children }: {
|
|
82
|
+
children?: ReactNode;
|
|
83
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
84
|
+
/**
|
|
85
|
+
* Single-file mode: shows filename/placeholder and a slot for the browse button.
|
|
86
|
+
* Put FilePicker.BrowseButton (optionally wrapped in Tooltip) as children.
|
|
46
87
|
*/
|
|
47
|
-
|
|
48
|
-
|
|
88
|
+
declare function FilePickerSingleFileRow({ children }: {
|
|
89
|
+
children?: ReactNode;
|
|
90
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
91
|
+
/** Renders the reserved space and delete button for single-file mode (for use in composed layout). */
|
|
92
|
+
declare function FilePickerSingleFileActions(): import("react/jsx-runtime").JSX.Element | null;
|
|
93
|
+
declare function FilePickerSingleFileDeleteButton(): import("react/jsx-runtime").JSX.Element | null;
|
|
94
|
+
declare function FilePickerHelpText(): import("react/jsx-runtime").JSX.Element;
|
|
95
|
+
declare function FilePickerUploadedFilesList(): import("react/jsx-runtime").JSX.Element | null;
|
|
96
|
+
declare const FilePicker: typeof FilePickerRoot & {
|
|
97
|
+
Label: typeof FilePickerLabel;
|
|
98
|
+
BrowseButton: typeof FilePickerBrowseButton;
|
|
99
|
+
HelpText: typeof FilePickerHelpText;
|
|
100
|
+
UploadedFilesList: typeof FilePickerUploadedFilesList;
|
|
101
|
+
SingleFileContainer: typeof FilePickerSingleFileContainer;
|
|
102
|
+
SingleFileRow: typeof FilePickerSingleFileRow;
|
|
103
|
+
SingleFileActions: typeof FilePickerSingleFileActions;
|
|
104
|
+
SingleFileDeleteButton: typeof FilePickerSingleFileDeleteButton;
|
|
105
|
+
};
|
|
106
|
+
export { useFilePickerContext };
|
|
107
|
+
export default FilePicker;
|
|
@@ -1,155 +1,242 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useId as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { c as
|
|
7
|
-
import '../../assets/FilePicker.css';const
|
|
8
|
-
container:
|
|
9
|
-
label:
|
|
10
|
-
required:
|
|
11
|
-
labelTooltipIcon:
|
|
12
|
-
helpers:
|
|
13
|
-
helperText:
|
|
14
|
-
errorMessage:
|
|
15
|
-
singleFileHelpLinkContainer:
|
|
16
|
-
singleFileHelpLinkReservedSpace:
|
|
17
|
-
helpLink:
|
|
18
|
-
input:
|
|
19
|
-
singleFileContainer:
|
|
20
|
-
singleFileInputContainer:
|
|
21
|
-
inputFileName:
|
|
22
|
-
inputFileNamePlaceholder:
|
|
23
|
-
inputButton:
|
|
24
|
-
multipleHelpText:
|
|
25
|
-
multipleInputButton:
|
|
26
|
-
multipleFilesList:
|
|
27
|
-
multipleFilesListItem:
|
|
28
|
-
multipleFilesListItemContent:
|
|
29
|
-
multipleFilesListItemContentData:
|
|
30
|
-
multipleFilesListItemIconContainer:
|
|
31
|
-
multipleFilesListItemIcon:
|
|
32
|
-
multipleFilesListItemText:
|
|
33
|
-
multipleFilesListItemName:
|
|
34
|
-
multipleFilesListItemSize:
|
|
35
|
-
multipleFilesListItemError:
|
|
36
|
-
multipleFilesListItemIconError:
|
|
37
|
-
multipleFilesListItemIconDelete:
|
|
38
|
-
disabled:
|
|
39
|
-
};
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
import { jsxs as a, jsx as i, Fragment as ne } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as se, useId as re, useRef as oe, useState as v, useCallback as _, useEffect as ce, useContext as ae } from "react";
|
|
3
|
+
import pe from "../Tooltip/Tooltip.js";
|
|
4
|
+
import D from "../Icon/Icon.js";
|
|
5
|
+
import x from "../Button/Button.js";
|
|
6
|
+
import { c as C } from "../../clsx-OuTLNxxd.js";
|
|
7
|
+
import '../../assets/FilePicker.css';const ue = "FilePicker-module__container___knCCi", me = "FilePicker-module__label___al7Xe", de = "FilePicker-module__required___41Vjd", Fe = "FilePicker-module__labelTooltipIcon___Cc1QF", _e = "FilePicker-module__helpers___79-g5", Ie = "FilePicker-module__helperText___ja9Rr", he = "FilePicker-module__errorMessage___TvHrL", Le = "FilePicker-module__singleFileHelpLinkContainer___mpjUf", ge = "FilePicker-module__singleFileHelpLinkReservedSpace___r8j2b", ke = "FilePicker-module__helpLink___uu45D", fe = "FilePicker-module__input___cL1Hs", Pe = "FilePicker-module__singleFileContainer___OFSDt", Ne = "FilePicker-module__singleFileInputContainer___MOkES", xe = "FilePicker-module__inputFileName___sMs7R", Ce = "FilePicker-module__inputFileNamePlaceholder___-mkDD", Te = "FilePicker-module__inputButton___ghLlD", be = "FilePicker-module__multipleHelpText___5tnnn", ye = "FilePicker-module__multipleInputButton___WCJp9", De = "FilePicker-module__multipleFilesList___Kim0I", Be = "FilePicker-module__multipleFilesListItem___01PDS", Se = "FilePicker-module__multipleFilesListItemContent___pKbho", He = "FilePicker-module__multipleFilesListItemContentData___5GC-C", ve = "FilePicker-module__multipleFilesListItemIconContainer___7sUL5", we = "FilePicker-module__multipleFilesListItemIcon___nfMX9", Me = "FilePicker-module__multipleFilesListItemText___nPqrL", Ee = "FilePicker-module__multipleFilesListItemName___NjHhX", ze = "FilePicker-module__multipleFilesListItemSize___wc8LJ", Re = "FilePicker-module__multipleFilesListItemError___x9qkT", je = "FilePicker-module__multipleFilesListItemIconError___0RO46", Ke = "FilePicker-module__multipleFilesListItemIconDelete___9Z9Dl", Ve = "FilePicker-module__disabled___szMiq", t = {
|
|
8
|
+
container: ue,
|
|
9
|
+
label: me,
|
|
10
|
+
required: de,
|
|
11
|
+
labelTooltipIcon: Fe,
|
|
12
|
+
helpers: _e,
|
|
13
|
+
helperText: Ie,
|
|
14
|
+
errorMessage: he,
|
|
15
|
+
singleFileHelpLinkContainer: Le,
|
|
16
|
+
singleFileHelpLinkReservedSpace: ge,
|
|
17
|
+
helpLink: ke,
|
|
18
|
+
input: fe,
|
|
19
|
+
singleFileContainer: Pe,
|
|
20
|
+
singleFileInputContainer: Ne,
|
|
21
|
+
inputFileName: xe,
|
|
22
|
+
inputFileNamePlaceholder: Ce,
|
|
23
|
+
inputButton: Te,
|
|
24
|
+
multipleHelpText: be,
|
|
25
|
+
multipleInputButton: ye,
|
|
26
|
+
multipleFilesList: De,
|
|
27
|
+
multipleFilesListItem: Be,
|
|
28
|
+
multipleFilesListItemContent: Se,
|
|
29
|
+
multipleFilesListItemContentData: He,
|
|
30
|
+
multipleFilesListItemIconContainer: ve,
|
|
31
|
+
multipleFilesListItemIcon: we,
|
|
32
|
+
multipleFilesListItemText: Me,
|
|
33
|
+
multipleFilesListItemName: Ee,
|
|
34
|
+
multipleFilesListItemSize: ze,
|
|
35
|
+
multipleFilesListItemError: Re,
|
|
36
|
+
multipleFilesListItemIconError: je,
|
|
37
|
+
multipleFilesListItemIconDelete: Ke,
|
|
38
|
+
disabled: Ve
|
|
39
|
+
}, w = se(null);
|
|
40
|
+
function p() {
|
|
41
|
+
const e = ae(w);
|
|
42
|
+
if (!e)
|
|
43
|
+
throw new Error("FilePicker compound components must be used within a FilePicker.");
|
|
44
|
+
return e;
|
|
45
|
+
}
|
|
46
|
+
function qe(e) {
|
|
47
|
+
const l = e.name.toLowerCase();
|
|
48
|
+
return l.includes(".") ? l.split(".").pop() ?? "" : "";
|
|
49
|
+
}
|
|
50
|
+
function $e({
|
|
51
|
+
type: e = "single",
|
|
52
|
+
maxFiles: l = 1,
|
|
53
|
+
fileExtensionsAllowed: s,
|
|
54
|
+
maxSize: r,
|
|
55
|
+
queueFiles: h = !1,
|
|
56
|
+
disabled: c = !1,
|
|
57
|
+
isUploadDisabled: E = !1,
|
|
58
|
+
value: L,
|
|
59
|
+
label: z,
|
|
60
|
+
required: R = !1,
|
|
61
|
+
placeholder: j,
|
|
62
|
+
errorMessage: K,
|
|
63
|
+
helpText: V,
|
|
64
|
+
helpLink: q,
|
|
65
|
+
helpLinkText: $,
|
|
66
|
+
multipleHelpText: O,
|
|
67
|
+
multipleButtonHelpText: A,
|
|
68
|
+
labelTooltip: X,
|
|
69
|
+
onUpload: F,
|
|
70
|
+
onRemoveFile: g,
|
|
71
|
+
children: k
|
|
58
72
|
}) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}, S = (i) => {
|
|
71
|
-
const m = l.length + i.length > F;
|
|
72
|
-
B(m);
|
|
73
|
-
const g = p ? p * 1024 * 1024 : Number.POSITIVE_INFINITY, b = new Set(L.map((_) => _.toLowerCase().replace(/^\./, "")));
|
|
74
|
-
return i.map((_) => {
|
|
75
|
-
const J = _.size <= g, Y = b.size === 0 || b.has($(_));
|
|
76
|
-
let C;
|
|
77
|
-
const G = p ? `up to ${p}MB` : "";
|
|
78
|
-
return J || (C = `File size is too large. Must be ${G}.`), Y || (C = `The file format is incorrect. Please make sure it is one of the extensions: ${H}.`), {
|
|
79
|
-
file: _,
|
|
80
|
-
error: C
|
|
73
|
+
const B = re(), f = oe(null), [u, P] = v(L ? L.map((n) => ({
|
|
74
|
+
file: n
|
|
75
|
+
})) : []), [J, T] = v(!1), b = s.join(", "), S = s.map((n) => `.${n.replace(/^\./, "")}`).join(","), N = _((n) => {
|
|
76
|
+
const o = r ? r * 1024 * 1024 : Number.POSITIVE_INFINITY, m = new Set(s.map((d) => d.toLowerCase().replace(/^\./, "")));
|
|
77
|
+
return n.map((d) => {
|
|
78
|
+
const le = d.size <= o, ie = m.size === 0 || m.has(qe(d));
|
|
79
|
+
let y;
|
|
80
|
+
const te = r ? `up to ${r}MB` : "";
|
|
81
|
+
return le || (y = `File size is too large. Must be ${te}.`), ie || (y = `The file format is incorrect. Please make sure it is one of the extensions: ${b}.`), {
|
|
82
|
+
file: d,
|
|
83
|
+
error: y
|
|
81
84
|
};
|
|
82
85
|
});
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
86
|
+
}, [s, b, r]), H = _((n) => {
|
|
87
|
+
const o = u.length;
|
|
88
|
+
return T(o + n.length > l), N(n);
|
|
89
|
+
}, [l, u.length, N]);
|
|
90
|
+
ce(() => {
|
|
91
|
+
const n = N(L ?? []);
|
|
92
|
+
P(n), T(n.length > l);
|
|
93
|
+
}, [L, l, N]);
|
|
94
|
+
const Y = _((n) => (n / 1024).toFixed(2) + " KB", []), G = _(() => {
|
|
95
|
+
var n;
|
|
96
|
+
c || (n = f.current) == null || n.click();
|
|
97
|
+
}, [c]), Q = _((n) => {
|
|
98
|
+
var o;
|
|
99
|
+
c || n.key === "Enter" && ((o = f.current) == null || o.click());
|
|
100
|
+
}, [c]), W = _((n) => {
|
|
101
|
+
if (c) return;
|
|
102
|
+
const o = n.target.files, m = H(Array.from(o ?? []));
|
|
103
|
+
if (e === "multiple" && h) {
|
|
104
|
+
const d = [...u, ...m];
|
|
105
|
+
P(d), F == null || F(d);
|
|
106
|
+
} else
|
|
107
|
+
P(m), F == null || F(m);
|
|
108
|
+
n.target.value = "";
|
|
109
|
+
}, [c, e, h, u, H, F]), Z = _((n) => {
|
|
110
|
+
if (c || !u) return;
|
|
111
|
+
const o = u.filter((m) => m.file.name !== n);
|
|
112
|
+
T(o.length > l), P(o), g == null || g(n);
|
|
113
|
+
}, [c, u, l, g]), U = {
|
|
114
|
+
id: B,
|
|
115
|
+
type: e,
|
|
116
|
+
maxFiles: l,
|
|
117
|
+
fileExtensionsAllowed: s,
|
|
118
|
+
fileExtensionsAllowedText: b,
|
|
119
|
+
maxSize: r,
|
|
120
|
+
queueFiles: h,
|
|
121
|
+
disabled: c,
|
|
122
|
+
isUploadDisabled: E,
|
|
123
|
+
uploadedFiles: u,
|
|
124
|
+
isMaxFilesExceeded: J,
|
|
125
|
+
label: z,
|
|
126
|
+
required: R,
|
|
127
|
+
placeholder: j,
|
|
128
|
+
errorMessage: K,
|
|
129
|
+
helpText: V,
|
|
130
|
+
helpLink: q,
|
|
131
|
+
helpLinkText: $,
|
|
132
|
+
multipleHelpText: O,
|
|
133
|
+
multipleButtonHelpText: A,
|
|
134
|
+
labelTooltip: X,
|
|
135
|
+
accept: S,
|
|
136
|
+
inputRef: f,
|
|
137
|
+
triggerInput: G,
|
|
138
|
+
handleKeyDown: Q,
|
|
139
|
+
handleRemoveFile: Z,
|
|
140
|
+
displayFileSize: Y
|
|
141
|
+
}, ee = k != null && (Array.isArray(k) ? k.length > 0 : !0);
|
|
142
|
+
return /* @__PURE__ */ a(w.Provider, { value: U, children: [
|
|
143
|
+
/* @__PURE__ */ i("input", { accept: S, multiple: e === "multiple", ref: f, type: "file", id: B, className: t.input, onChange: W }),
|
|
144
|
+
/* @__PURE__ */ i("div", { className: C(t.container, c && t.disabled), children: ee ? k : /* @__PURE__ */ i(Oe, {}) })
|
|
145
|
+
] });
|
|
146
|
+
}
|
|
147
|
+
function Oe() {
|
|
148
|
+
const e = p();
|
|
149
|
+
return /* @__PURE__ */ a(ne, { children: [
|
|
150
|
+
/* @__PURE__ */ i(I.Label, {}),
|
|
151
|
+
e.type === "single" && /* @__PURE__ */ i(I.SingleFileRow, { children: /* @__PURE__ */ i(I.BrowseButton, {}) }),
|
|
152
|
+
e.type === "single" && e.uploadedFiles.length > 0 && /* @__PURE__ */ i("span", { className: t.singleFileHelpLinkReservedSpace, children: /* @__PURE__ */ i(I.SingleFileDeleteButton, {}) }),
|
|
153
|
+
e.type === "multiple" && /* @__PURE__ */ i(I.BrowseButton, {}),
|
|
154
|
+
/* @__PURE__ */ i(I.HelpText, {}),
|
|
155
|
+
/* @__PURE__ */ i(I.UploadedFilesList, {})
|
|
156
|
+
] });
|
|
157
|
+
}
|
|
158
|
+
function Ae({
|
|
159
|
+
children: e
|
|
160
|
+
}) {
|
|
161
|
+
const l = p(), s = e ?? l.label;
|
|
162
|
+
return /* @__PURE__ */ a("label", { htmlFor: l.id, onClick: (r) => r.preventDefault(), className: C(t.label, l.type === "multiple" && t.labelMultiple), children: [
|
|
163
|
+
/* @__PURE__ */ i("span", { title: l.label, className: t.labelText, children: s }),
|
|
164
|
+
l.required && /* @__PURE__ */ i("span", { "aria-hidden": "true", className: t.required, children: "*" }),
|
|
165
|
+
l.labelTooltip && /* @__PURE__ */ i(pe, { content: l.labelTooltip.content, size: l.labelTooltip.size, theme: l.labelTooltip.theme, tipSide: l.labelTooltip.tipSide, tipAlignment: l.labelTooltip.tipAlignment, startVisible: l.labelTooltip.startVisible, children: /* @__PURE__ */ i(D, { icon: "ap-icon-info", className: t.labelTooltipIcon }) }),
|
|
166
|
+
l.type === "multiple" && l.multipleHelpText && /* @__PURE__ */ i("span", { className: t.multipleHelpText, children: l.multipleHelpText })
|
|
167
|
+
] });
|
|
168
|
+
}
|
|
169
|
+
function Xe({
|
|
170
|
+
children: e,
|
|
171
|
+
className: l
|
|
172
|
+
}) {
|
|
173
|
+
const s = p();
|
|
174
|
+
return s.type === "multiple" ? /* @__PURE__ */ i(x, { type: "secondary", variant: "default", size: "md", icon: "ap-icon-upload", className: C(t.multipleInputButton, l), onClick: s.triggerInput, onKeyDown: s.handleKeyDown, disabled: s.disabled || s.isUploadDisabled, children: /* @__PURE__ */ i("span", { children: e ?? `Browse files ${s.multipleButtonHelpText ?? ""}` }) }) : /* @__PURE__ */ i(x, { type: "tertiary", variant: "default", size: "md", icon: "ap-icon-upload", className: C(t.inputButton, l), tabIndex: -1, disabled: s.disabled || s.isUploadDisabled, onClick: (r) => {
|
|
175
|
+
r.preventDefault(), r.stopPropagation(), s.triggerInput();
|
|
176
|
+
}, children: /* @__PURE__ */ i("span", { children: e ?? "Browse file" }) });
|
|
177
|
+
}
|
|
178
|
+
function Je({
|
|
179
|
+
children: e
|
|
180
|
+
}) {
|
|
181
|
+
return p().type !== "single" ? null : /* @__PURE__ */ i("div", { className: t.singleFileContainer, children: e });
|
|
182
|
+
}
|
|
183
|
+
function Ye({
|
|
184
|
+
children: e
|
|
185
|
+
}) {
|
|
186
|
+
const l = p();
|
|
187
|
+
return l.type !== "single" ? null : /* @__PURE__ */ a("div", { tabIndex: l.disabled ? -1 : 0, onClick: l.triggerInput, onKeyDown: l.handleKeyDown, className: t.singleFileInputContainer, children: [
|
|
188
|
+
/* @__PURE__ */ i("span", { className: t.inputFileName, children: l.uploadedFiles.length > 0 ? /* @__PURE__ */ i("span", { className: t.inputFileNameText, children: l.uploadedFiles[0].file.name }) : /* @__PURE__ */ i("span", { className: t.inputFileNamePlaceholder, children: l.placeholder }) }),
|
|
189
|
+
e
|
|
151
190
|
] });
|
|
152
191
|
}
|
|
192
|
+
function Ge() {
|
|
193
|
+
return p().type !== "single" ? null : /* @__PURE__ */ i("span", { className: t.singleFileHelpLinkReservedSpace, children: /* @__PURE__ */ i(M, {}) });
|
|
194
|
+
}
|
|
195
|
+
function M() {
|
|
196
|
+
const e = p();
|
|
197
|
+
if (e.type !== "single" || e.uploadedFiles.length === 0) return null;
|
|
198
|
+
const l = e.uploadedFiles[0].file.name;
|
|
199
|
+
return /* @__PURE__ */ i(x, { type: "tertiary", variant: "default", size: "md", icon: "ap-icon-delete", className: t.singleFileDeleteButton, onClick: () => e.handleRemoveFile(l), disabled: e.disabled });
|
|
200
|
+
}
|
|
201
|
+
function Qe() {
|
|
202
|
+
var r, h;
|
|
203
|
+
const e = p(), l = e.errorMessage || e.isMaxFilesExceeded || e.type === "single" && ((r = e.uploadedFiles[0]) == null ? void 0 : r.error), s = e.type === "single" ? e.errorMessage || ((h = e.uploadedFiles[0]) == null ? void 0 : h.error) : e.errorMessage || (e.isMaxFilesExceeded ? `You can only upload up to ${e.maxFiles} files.` : "");
|
|
204
|
+
return /* @__PURE__ */ a("div", { className: t.helpers, children: [
|
|
205
|
+
l ? /* @__PURE__ */ i("span", { title: e.errorMessage, className: t.errorMessage, children: s }) : e.helpText && e.type === "single" && /* @__PURE__ */ i("span", { title: e.helpText, className: t.helperText, children: e.helpText }),
|
|
206
|
+
e.type === "single" && e.helpLink && e.helpLinkText && /* @__PURE__ */ a("span", { className: t.singleFileHelpLinkContainer, children: [
|
|
207
|
+
/* @__PURE__ */ i("a", { href: e.helpLink, className: t.helpLink, target: "_blank", rel: "noopener noreferrer", tabIndex: e.disabled ? -1 : 0, children: e.helpLinkText }),
|
|
208
|
+
/* @__PURE__ */ i("span", { className: t.singleFileHelpLinkReservedSpace })
|
|
209
|
+
] })
|
|
210
|
+
] });
|
|
211
|
+
}
|
|
212
|
+
function We() {
|
|
213
|
+
const e = p();
|
|
214
|
+
return e.type !== "multiple" || !e.uploadedFiles.length ? null : /* @__PURE__ */ i("ul", { className: t.multipleFilesList, children: e.uploadedFiles.map((l, s) => /* @__PURE__ */ i("li", { className: t.multipleFilesListItem, children: /* @__PURE__ */ a("div", { className: t.multipleFilesListItemContent, children: [
|
|
215
|
+
/* @__PURE__ */ i("span", { className: t.multipleFilesListItemIconContainer, children: /* @__PURE__ */ i(D, { icon: "ap-icon-document", className: t.multipleFilesListItemIcon }) }),
|
|
216
|
+
/* @__PURE__ */ a("div", { className: t.multipleFilesListItemContentData, children: [
|
|
217
|
+
/* @__PURE__ */ a("div", { className: t.multipleFilesListItemText, children: [
|
|
218
|
+
/* @__PURE__ */ i("span", { className: t.multipleFilesListItemName, children: l.file.name }),
|
|
219
|
+
/* @__PURE__ */ i("span", { className: t.multipleFilesListItemSize, children: e.displayFileSize(l.file.size) }),
|
|
220
|
+
l.error && /* @__PURE__ */ a("span", { className: t.multipleFilesListItemError, children: [
|
|
221
|
+
/* @__PURE__ */ i(D, { icon: "ap-icon-alert", className: t.multipleFilesListItemIconError }),
|
|
222
|
+
l.error
|
|
223
|
+
] })
|
|
224
|
+
] }),
|
|
225
|
+
/* @__PURE__ */ i(x, { type: "tertiary", variant: "default", size: "sm", onClick: () => e.handleRemoveFile(l.file.name), icon: "ap-icon-delete", iconClassName: t.multipleFilesListItemIconDelete, disabled: e.disabled })
|
|
226
|
+
] })
|
|
227
|
+
] }) }, s)) });
|
|
228
|
+
}
|
|
229
|
+
const I = Object.assign($e, {
|
|
230
|
+
Label: Ae,
|
|
231
|
+
BrowseButton: Xe,
|
|
232
|
+
HelpText: Qe,
|
|
233
|
+
UploadedFilesList: We,
|
|
234
|
+
SingleFileContainer: Je,
|
|
235
|
+
SingleFileRow: Ye,
|
|
236
|
+
SingleFileActions: Ge,
|
|
237
|
+
SingleFileDeleteButton: M
|
|
238
|
+
});
|
|
153
239
|
export {
|
|
154
|
-
|
|
240
|
+
I as default,
|
|
241
|
+
p as useFilePickerContext
|
|
155
242
|
};
|