@alixpartners/ui-components 2.3.2 → 2.4.1

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.
@@ -3,8 +3,8 @@ import { DataAttributes } from '../../types/data-attributes';
3
3
  import { InteractiveEventHandlers } from '../../types/native-events';
4
4
  export type ButtonProps = {
5
5
  type: 'primary' | 'secondary' | 'tertiary';
6
- variant: 'default' | 'danger' | 'cancel';
7
- size: 'sm' | 'md';
6
+ size?: 'sm' | 'md';
7
+ variant?: 'default' | 'danger' | 'cancel';
8
8
  icon?: ApIcon;
9
9
  disabled?: boolean;
10
10
  loading?: boolean;
@@ -12,6 +12,8 @@ export type ButtonProps = {
12
12
  className?: string;
13
13
  iconClassName?: string;
14
14
  tabIndex?: number;
15
+ link?: string;
16
+ linkTarget?: '_self' | '_blank' | '_parent' | '_top';
15
17
  } & DataAttributes & InteractiveEventHandlers;
16
18
  /**
17
19
  * A versatile button component that supports different types, variants, sizes, and states.
@@ -25,7 +27,9 @@ export type ButtonProps = {
25
27
  * @param {boolean} [props.disabled] - Whether the button is disabled (prevents interaction and applies disabled styling)
26
28
  * @param {boolean} [props.loading] - Whether the button is in a loading state (shows loading spinner and prevents interaction)
27
29
  * @param {React.ReactNode} [props.children] - The content to display inside the button (text or other elements)
30
+ * @param {string} [props.link] - Allows a URL to be added to the button for navigation
31
+ * @param {string} [props.linkTarget] - Allows a target for links to be set (default _self)
28
32
  * @param {() => void} [props.onClick] - Callback fired when the button is clicked
29
33
  * @returns {JSX.Element} The rendered Button component
30
34
  */
31
- export default function Button({ type, variant, size, icon, disabled, loading, children, className, iconClassName, tabIndex, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
35
+ export default function Button({ type, variant, size, icon, disabled, loading, children, className, iconClassName, tabIndex, link, linkTarget, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,9 @@
1
- import { jsxs as f, jsx as u } from "react/jsx-runtime";
2
- import { c as a } from "../../clsx-OuTLNxxd.js";
3
- import g from "../Spinner/Spinner.js";
4
- import w from "../Icon/Icon.js";
5
- import '../../assets/Button.css';const x = "Button-module__btn___daEdK", K = "Button-module__loading___QfItr", t = {
6
- btn: x,
1
+ import { jsx as o, jsxs as w } from "react/jsx-runtime";
2
+ import { c as i } from "../../clsx-OuTLNxxd.js";
3
+ import x from "../Spinner/Spinner.js";
4
+ import K from "../Icon/Icon.js";
5
+ import '../../assets/Button.css';const k = "Button-module__btn___daEdK", p = "Button-module__loading___QfItr", t = {
6
+ btn: k,
7
7
  "btn-icon": "Button-module__btn-icon___G7m4S",
8
8
  "btn-icon-sm": "Button-module__btn-icon-sm___w7eg9",
9
9
  "btn-icon-md": "Button-module__btn-icon-md___8Ywy2",
@@ -16,34 +16,41 @@ import '../../assets/Button.css';const x = "Button-module__btn___daEdK", K = "Bu
16
16
  "btn-tertiary": "Button-module__btn-tertiary___G-7lD",
17
17
  "btn-disabled": "Button-module__btn-disabled___eg1uH",
18
18
  "btn-loading": "Button-module__btn-loading___vAg78",
19
- loading: K,
19
+ loading: p,
20
20
  "btn-sm": "Button-module__btn-sm___KNlkv",
21
21
  "btn-md": "Button-module__btn-md___C8vqh",
22
- "btn-text": "Button-module__btn-text___3ccH9"
23
- };
24
- function k({
25
- type: c,
26
- variant: i,
27
- size: o,
28
- icon: l,
29
- disabled: e = !1,
30
- loading: b = !1,
31
- children: d,
32
- className: r,
22
+ "btn-text": "Button-module__btn-text___3ccH9",
23
+ "btn-link": "Button-module__btn-link___5KUtD"
24
+ }, D = ({
25
+ children: e,
26
+ link: l,
27
+ linkTarget: n
28
+ }) => l ? /* @__PURE__ */ o("a", { href: l, target: n, className: t["btn-link"], children: e }) : e;
29
+ function G({
30
+ type: e,
31
+ variant: l = "default",
32
+ size: n = "md",
33
+ icon: d,
34
+ disabled: b = !1,
35
+ loading: a = !1,
36
+ children: m,
37
+ className: c,
33
38
  iconClassName: s,
34
39
  tabIndex: B = 0,
35
- ..._
40
+ link: f = "",
41
+ linkTarget: g = "_self",
42
+ ...u
36
43
  }) {
37
- const y = (n) => {
38
- var m;
39
- (n.key === "Enter" || n.key === " ") && (n.preventDefault(), n.currentTarget.click()), (m = _.onKeyDown) == null || m.call(_, n);
44
+ const y = (_) => {
45
+ var r;
46
+ (_.key === "Enter" || _.key === " ") && (_.preventDefault(), _.currentTarget.click()), (r = u.onKeyDown) == null || r.call(u, _);
40
47
  };
41
- return /* @__PURE__ */ f("button", { tabIndex: e ? -1 : B, type: "button", className: a(t.btn, t[`btn-${c}`], t[`btn-${i}`], t[`btn-${o}`], e && t["btn-disabled"], r), disabled: e || b, onKeyDown: y, ..._, children: [
42
- !!l && !b && /* @__PURE__ */ u(w, { icon: l, className: a(t["btn-icon"], t[`btn-icon-${o}`], s) }),
43
- b && /* @__PURE__ */ u(g, { size: o, color: "white", className: t["loading-spinner"] }),
44
- d && /* @__PURE__ */ u("span", { className: t["btn-text"], children: d })
45
- ] });
48
+ return /* @__PURE__ */ o("button", { tabIndex: b ? -1 : B, type: "button", className: i(t.btn, t[`btn-${e}`], t[`btn-${l}`], t[`btn-${n}`], b && t["btn-disabled"], c), disabled: b || a, onKeyDown: y, ...u, children: /* @__PURE__ */ w(D, { link: f, linkTarget: g, children: [
49
+ !!d && !a && /* @__PURE__ */ o(K, { icon: d, className: i(t["btn-icon"], t[`btn-icon-${n}`], s) }),
50
+ a && /* @__PURE__ */ o(x, { size: n, color: "white", className: t["loading-spinner"] }),
51
+ m && /* @__PURE__ */ o("span", { className: t["btn-text"], children: m })
52
+ ] }) });
46
53
  }
47
54
  export {
48
- k as default
55
+ G as default
49
56
  };
@@ -1,6 +1,6 @@
1
1
  import { jsxs as s, jsx as d } from "react/jsx-runtime";
2
2
  import { c as h } from "../../clsx-OuTLNxxd.js";
3
- import { useState as b, useRef as T, useEffect as v, useCallback as oe } from "react";
3
+ import { useState as b, useRef as T, useEffect as L, useCallback as oe } from "react";
4
4
  import B from "../Icon/Icon.js";
5
5
  import Ce from "../Toggle/Toggle.js";
6
6
  import ne from "../Button/Button.js";
@@ -60,11 +60,11 @@ function Vo({
60
60
  options: F,
61
61
  value: p = [],
62
62
  placeholder: A = "Select options...",
63
- disabled: L = !1,
63
+ disabled: O = !1,
64
64
  required: te = !1,
65
65
  searchable: x = !1,
66
66
  searchPlaceholder: le = "Search options...",
67
- errorMessage: O,
67
+ errorMessage: I,
68
68
  helpText: C,
69
69
  helpLink: W,
70
70
  helpLinkText: q,
@@ -86,23 +86,23 @@ function Vo({
86
86
  caseSensitive: P = !1,
87
87
  ...me
88
88
  }) {
89
- const [i, g] = b(p), [l, f] = b(!1), [Y, _] = b(""), [I, c] = b(-1), [w, u] = b([]), $ = T(null), Z = T(null), we = T(null), z = T(null), [Q, fe] = b(0), [he, De] = b(p.length > 0 ? p.join(", ") : A ?? ""), K = T(p);
90
- v(() => {
89
+ const [i, g] = b(p), [l, f] = b(!1), [Y, _] = b(""), [y, c] = b(-1), [w, u] = b([]), $ = T(null), Z = T(null), we = T(null), z = T(null), [Q, fe] = b(0), [he, De] = b(p.length > 0 ? p.join(", ") : A ?? ""), K = T(p);
90
+ L(() => {
91
91
  JSON.stringify(K.current) !== JSON.stringify(p) && (g(p), K.current = p);
92
- }, [p]), v(() => {
92
+ }, [p]), L(() => {
93
93
  var r;
94
94
  const e = (r = Z.current) == null ? void 0 : r.getBoundingClientRect().width;
95
95
  e && fe(e);
96
- }, [l]), v(() => {
96
+ }, [l]), L(() => {
97
97
  l && u([...i]);
98
98
  }, [l, i]);
99
99
  const X = Y.trim(), a = F.filter((e) => {
100
100
  const r = P ? e.label : e.label.toLowerCase(), n = P ? X : X.toLowerCase();
101
101
  return r.includes(n);
102
102
  });
103
- v(() => {
103
+ L(() => {
104
104
  De(p.length > 0 ? p.join(", ") : A ?? "");
105
- }, [p, A]), v(() => {
105
+ }, [p, A]), L(() => {
106
106
  l && x && z.current && z.current.focus();
107
107
  }, [l, x]);
108
108
  const be = (e) => {
@@ -150,7 +150,7 @@ function Vo({
150
150
  }, [m, t, i, S]), Oe = (e) => {
151
151
  M == null || M(e);
152
152
  };
153
- v(() => {
153
+ L(() => {
154
154
  const e = (r) => {
155
155
  if (l)
156
156
  switch (r.key) {
@@ -161,8 +161,8 @@ function Vo({
161
161
  r.preventDefault(), c((n) => n > 0 ? n - 1 : a.length - 1);
162
162
  break;
163
163
  case "Enter":
164
- if (r.preventDefault(), I >= 0 && I < a.length) {
165
- const n = a[I];
164
+ if (r.preventDefault(), y >= 0 && y < a.length) {
165
+ const n = a[y];
166
166
  G(n);
167
167
  }
168
168
  break;
@@ -172,27 +172,27 @@ function Vo({
172
172
  }
173
173
  };
174
174
  return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
175
- }, [l, I, a, Le, G]);
176
- const V = l ? w : i, y = F.filter((e) => V.includes(e.value)), Ie = !!O, ye = JSON.stringify(w) !== JSON.stringify(i), H = F.filter((e) => !e.disabled), ke = H.length > 0 && H.every((e) => V.includes(e.value)), Te = a.reduce((e, r) => {
175
+ }, [l, y, a, Le, G]);
176
+ const V = l ? w : i, N = F.filter((e) => V.includes(e.value)), Ie = !!I, ye = JSON.stringify(w) !== JSON.stringify(i), H = F.filter((e) => !e.disabled), ke = H.length > 0 && H.every((e) => V.includes(e.value)), Te = a.reduce((e, r) => {
177
177
  const n = r.category || "default";
178
178
  return e[n] || (e[n] = []), e[n].push(r), e;
179
179
  }, {}), Ae = a, {
180
- onBlur: N,
180
+ onBlur: v,
181
181
  ...ee
182
182
  } = me;
183
183
  return /* @__PURE__ */ s("div", { ref: $, className: h(o.root, o.dropdownContainer, se && o["dropdown-container-grouped"], m && o["dropdown-container-multi-select"], de), ...ee, children: [
184
- E && /* @__PURE__ */ s("label", { className: h(o.dropdownLabel, L && o.dropdownLabelDisabled), children: [
184
+ E && /* @__PURE__ */ s("label", { className: h(o.dropdownLabel, O && o.dropdownLabelDisabled), children: [
185
185
  /* @__PURE__ */ d("span", { title: E, className: o["label-text"], children: E }),
186
186
  te && /* @__PURE__ */ d("span", { className: o.required, children: "*" }),
187
187
  D && /* @__PURE__ */ d(Se, { content: D.content, size: D.size, theme: D.theme, tipSide: D.tipSide, tipAlignment: D.tipAlignment, startVisible: D.startVisible, children: /* @__PURE__ */ d(B, { icon: "ap-icon-info", className: o["label-tooltip-icon"] }) })
188
188
  ] }),
189
189
  /* @__PURE__ */ d(Ve, { open: l, onOpenChange: be, children: /* @__PURE__ */ s("div", { className: o.dropdownWrapper, children: [
190
- /* @__PURE__ */ d(Re, { disabled: L, className: h(o["dropdown-menu-trigger"], o.dropdownTrigger, ce, l && o.dropdownTriggerOpen, L && o.dropdownTriggerDisabled, Ie && o.dropdownTriggerError), ref: Z, onBlur: (e) => {
191
- l || N == null || N(e);
190
+ /* @__PURE__ */ d(Re, { disabled: O, className: h(o["dropdown-menu-trigger"], o.dropdownTrigger, ce, l && o.dropdownTriggerOpen, O && o.dropdownTriggerDisabled, Ie && o.dropdownTriggerError), ref: Z, onBlur: (e) => {
191
+ l || v == null || v(e);
192
192
  }, ...ee, children: /* @__PURE__ */ s("div", { className: o.dropdownContent, children: [
193
- !pe && /* @__PURE__ */ d("div", { className: o.dropdownSelectedItems, children: y.length > 0 ? m ? ke && j ? j : y.length === 1 ? ` ${y.length} ${_e}` : ` ${y.length} ${ue}` : (
193
+ !pe && /* @__PURE__ */ d("div", { className: o.dropdownSelectedItems, children: N.length > 0 ? m ? ke && j ? j : N.length === 1 ? ` ${N.length} ${_e}` : ` ${N.length} ${ue}` : (
194
194
  // For single select, show the selected option label
195
- /* @__PURE__ */ d("span", { className: o.selectedOptionLabel, children: y[0].label })
195
+ /* @__PURE__ */ d("span", { className: o.selectedOptionLabel, title: N[0].label, children: N[0].label })
196
196
  ) : /* @__PURE__ */ d("span", { title: he, className: o.placeholder, children: A }) }),
197
197
  /* @__PURE__ */ d("div", { className: o.dropdownActions, children: /* @__PURE__ */ d(B, { icon: "ap-icon-expand-more", className: h(o.dropdownArrow, l && o.dropdownArrowOpen) }) })
198
198
  ] }) }),
@@ -201,7 +201,7 @@ function Vo({
201
201
  zIndex: 9999
202
202
  }, onInteractOutside: (e) => {
203
203
  var n;
204
- e.target === z.current && e.preventDefault(), ((n = $.current) == null ? void 0 : n.contains(e.target)) || N == null || N(e);
204
+ e.target === z.current && e.preventDefault(), ((n = $.current) == null ? void 0 : n.contains(e.target)) || v == null || v(e);
205
205
  }, children: l && /* @__PURE__ */ s("div", { style: {
206
206
  minWidth: Q
207
207
  }, className: h(o.dropdownMenu, ae, U === "right" && o.dropdownMenuRight), children: [
@@ -223,7 +223,7 @@ function Vo({
223
223
  e !== "default" && /* @__PURE__ */ d("div", { className: o.categoryDivider, children: /* @__PURE__ */ d("span", { className: o.categoryLabel, children: e }) }),
224
224
  r.map((n) => {
225
225
  const R = Ae.indexOf(n), k = a.find((xe) => xe.value === n.value);
226
- return /* @__PURE__ */ d("button", { title: (k == null ? void 0 : k.label) || n.label, type: "button", className: h(o.optionItem, V.includes(n.value) && o.optionItemSelected, n.disabled && o.optionItemDisabled, R === I && o.optionItemFocused), onClick: () => G(n), disabled: n.disabled, "data-dropdown-option-item": !0, children: /* @__PURE__ */ s("div", { className: o.optionContent, children: [
226
+ return /* @__PURE__ */ d("button", { title: (k == null ? void 0 : k.label) || n.label, type: "button", className: h(o.optionItem, V.includes(n.value) && o.optionItemSelected, n.disabled && o.optionItemDisabled, R === y && o.optionItemFocused), onClick: () => G(n), disabled: n.disabled, "data-dropdown-option-item": !0, children: /* @__PURE__ */ s("div", { className: o.optionContent, children: [
227
227
  /* @__PURE__ */ d("span", { className: o.optionLabel, children: n.label }),
228
228
  V.includes(n.value) && /* @__PURE__ */ d(B, { icon: "ap-icon-check", className: o.tickIcon })
229
229
  ] }) }, n.value);
@@ -238,9 +238,9 @@ function Vo({
238
238
  ] })
239
239
  ] }) }) })
240
240
  ] }) }),
241
- (O || C || W && q) && /* @__PURE__ */ s("div", { className: o.helpers, children: [
242
- O ? /* @__PURE__ */ d("span", { title: O, className: o.errorMessage, children: O }) : C && /* @__PURE__ */ d("span", { title: C, className: h(o.helpText, L && o.helpTextDisabled), children: C }),
243
- W && q && /* @__PURE__ */ d("a", { href: W, className: h(o.helpLink, L && o.helpLinkDisabled), target: "_blank", rel: "noopener noreferrer", children: q })
241
+ (I || C || W && q) && /* @__PURE__ */ s("div", { className: o.helpers, children: [
242
+ I ? /* @__PURE__ */ d("span", { title: I, className: o.errorMessage, children: I }) : C && /* @__PURE__ */ d("span", { title: C, className: h(o.helpText, O && o.helpTextDisabled), children: C }),
243
+ W && q && /* @__PURE__ */ d("a", { href: W, className: h(o.helpLink, O && o.helpLinkDisabled), target: "_blank", rel: "noopener noreferrer", children: q })
244
244
  ] })
245
245
  ] });
246
246
  }
@@ -91,7 +91,7 @@ declare function FilePickerSingleFileRow({ children }: {
91
91
  /** Renders the reserved space and delete button for single-file mode (for use in composed layout). */
92
92
  declare function FilePickerSingleFileActions(): import("react/jsx-runtime").JSX.Element | null;
93
93
  declare function FilePickerSingleFileDeleteButton(): import("react/jsx-runtime").JSX.Element | null;
94
- declare function FilePickerHelpText(): import("react/jsx-runtime").JSX.Element;
94
+ declare function FilePickerHelpText(): import("react/jsx-runtime").JSX.Element | null;
95
95
  declare function FilePickerUploadedFilesList(): import("react/jsx-runtime").JSX.Element | null;
96
96
  declare const FilePicker: typeof FilePickerRoot & {
97
97
  Label: typeof FilePickerLabel;
@@ -1,53 +1,54 @@
1
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";
2
+ import { createContext as se, useId as re, useRef as oe, useState as M, useCallback as F, useEffect as ce, useContext as ae } from "react";
3
+ import ue from "../Tooltip/Tooltip.js";
4
4
  import D from "../Icon/Icon.js";
5
5
  import x from "../Button/Button.js";
6
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,
7
+ import '../../assets/FilePicker.css';const pe = "FilePicker-module__container___knCCi", me = "FilePicker-module__containerMultiple___Psi5u", de = "FilePicker-module__label___al7Xe", _e = "FilePicker-module__required___41Vjd", Fe = "FilePicker-module__labelTooltipIcon___Cc1QF", Ie = "FilePicker-module__helpers___79-g5", he = "FilePicker-module__helperText___ja9Rr", Le = "FilePicker-module__errorMessage___TvHrL", ge = "FilePicker-module__singleFileHelpLinkContainer___mpjUf", ke = "FilePicker-module__singleFileHelpLinkReservedSpace___r8j2b", fe = "FilePicker-module__helpLink___uu45D", Pe = "FilePicker-module__input___cL1Hs", Ne = "FilePicker-module__singleFileContainer___OFSDt", xe = "FilePicker-module__singleFileInputContainer___MOkES", Ce = "FilePicker-module__inputFileName___sMs7R", Te = "FilePicker-module__inputFileNamePlaceholder___-mkDD", be = "FilePicker-module__inputButton___ghLlD", ye = "FilePicker-module__multipleHelpText___5tnnn", De = "FilePicker-module__multipleInputButton___WCJp9", Be = "FilePicker-module__multipleFilesList___Kim0I", Se = "FilePicker-module__multipleFilesListItem___01PDS", He = "FilePicker-module__multipleFilesListItemContent___pKbho", Me = "FilePicker-module__multipleFilesListItemContentData___5GC-C", ve = "FilePicker-module__multipleFilesListItemIconContainer___7sUL5", we = "FilePicker-module__multipleFilesListItemIcon___nfMX9", Ee = "FilePicker-module__multipleFilesListItemText___nPqrL", ze = "FilePicker-module__multipleFilesListItemName___NjHhX", Re = "FilePicker-module__multipleFilesListItemSize___wc8LJ", je = "FilePicker-module__multipleFilesListItemError___x9qkT", Ke = "FilePicker-module__multipleFilesListItemIconError___0RO46", Ve = "FilePicker-module__multipleFilesListItemIconDelete___9Z9Dl", qe = "FilePicker-module__disabled___szMiq", t = {
8
+ container: pe,
9
+ containerMultiple: me,
10
+ label: de,
11
+ required: _e,
11
12
  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,
13
+ helpers: Ie,
14
+ helperText: he,
15
+ errorMessage: Le,
16
+ singleFileHelpLinkContainer: ge,
17
+ singleFileHelpLinkReservedSpace: ke,
18
+ helpLink: fe,
19
+ input: Pe,
20
+ singleFileContainer: Ne,
21
+ singleFileInputContainer: xe,
22
+ inputFileName: Ce,
23
+ inputFileNamePlaceholder: Te,
24
+ inputButton: be,
25
+ multipleHelpText: ye,
26
+ multipleInputButton: De,
27
+ multipleFilesList: Be,
28
+ multipleFilesListItem: Se,
29
+ multipleFilesListItemContent: He,
30
+ multipleFilesListItemContentData: Me,
30
31
  multipleFilesListItemIconContainer: ve,
31
32
  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);
33
+ multipleFilesListItemText: Ee,
34
+ multipleFilesListItemName: ze,
35
+ multipleFilesListItemSize: Re,
36
+ multipleFilesListItemError: je,
37
+ multipleFilesListItemIconError: Ke,
38
+ multipleFilesListItemIconDelete: Ve,
39
+ disabled: qe
40
+ }, v = se(null);
41
+ function u() {
42
+ const e = ae(v);
42
43
  if (!e)
43
44
  throw new Error("FilePicker compound components must be used within a FilePicker.");
44
45
  return e;
45
46
  }
46
- function qe(e) {
47
+ function $e(e) {
47
48
  const l = e.name.toLowerCase();
48
49
  return l.includes(".") ? l.split(".").pop() ?? "" : "";
49
50
  }
50
- function $e({
51
+ function Oe({
51
52
  type: e = "single",
52
53
  maxFiles: l = 1,
53
54
  fileExtensionsAllowed: s,
@@ -66,16 +67,16 @@ function $e({
66
67
  multipleHelpText: O,
67
68
  multipleButtonHelpText: A,
68
69
  labelTooltip: X,
69
- onUpload: F,
70
+ onUpload: _,
70
71
  onRemoveFile: g,
71
72
  children: k
72
73
  }) {
73
- const B = re(), f = oe(null), [u, P] = v(L ? L.map((n) => ({
74
+ const B = re(), f = oe(null), [p, P] = M(L ? L.map((n) => ({
74
75
  file: n
75
- })) : []), [J, T] = v(!1), b = s.join(", "), S = s.map((n) => `.${n.replace(/^\./, "")}`).join(","), N = _((n) => {
76
+ })) : []), [J, T] = M(!1), b = s.join(", "), S = s.map((n) => `.${n.replace(/^\./, "")}`).join(","), N = F((n) => {
76
77
  const o = r ? r * 1024 * 1024 : Number.POSITIVE_INFINITY, m = new Set(s.map((d) => d.toLowerCase().replace(/^\./, "")));
77
78
  return n.map((d) => {
78
- const le = d.size <= o, ie = m.size === 0 || m.has(qe(d));
79
+ const le = d.size <= o, ie = m.size === 0 || m.has($e(d));
79
80
  let y;
80
81
  const te = r ? `up to ${r}MB` : "";
81
82
  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}.`), {
@@ -83,34 +84,34 @@ function $e({
83
84
  error: y
84
85
  };
85
86
  });
86
- }, [s, b, r]), H = _((n) => {
87
- const o = u.length;
87
+ }, [s, b, r]), H = F((n) => {
88
+ const o = p.length;
88
89
  return T(o + n.length > l), N(n);
89
- }, [l, u.length, N]);
90
+ }, [l, p.length, N]);
90
91
  ce(() => {
91
92
  const n = N(L ?? []);
92
93
  P(n), T(n.length > l);
93
94
  }, [L, l, N]);
94
- const Y = _((n) => (n / 1024).toFixed(2) + " KB", []), G = _(() => {
95
+ const Y = F((n) => (n / 1024).toFixed(2) + " KB", []), G = F(() => {
95
96
  var n;
96
97
  c || (n = f.current) == null || n.click();
97
- }, [c]), Q = _((n) => {
98
+ }, [c]), Q = F((n) => {
98
99
  var o;
99
100
  c || n.key === "Enter" && ((o = f.current) == null || o.click());
100
- }, [c]), W = _((n) => {
101
+ }, [c]), W = F((n) => {
101
102
  if (c) return;
102
103
  const o = n.target.files, m = H(Array.from(o ?? []));
103
104
  if (e === "multiple" && h) {
104
- const d = [...u, ...m];
105
- P(d), F == null || F(d);
105
+ const d = [...p, ...m];
106
+ P(d), _ == null || _(d);
106
107
  } else
107
- P(m), F == null || F(m);
108
+ P(m), _ == null || _(m);
108
109
  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);
110
+ }, [c, e, h, p, H, _]), Z = F((n) => {
111
+ if (c || !p) return;
112
+ const o = p.filter((m) => m.file.name !== n);
112
113
  T(o.length > l), P(o), g == null || g(n);
113
- }, [c, u, l, g]), U = {
114
+ }, [c, p, l, g]), U = {
114
115
  id: B,
115
116
  type: e,
116
117
  maxFiles: l,
@@ -120,7 +121,7 @@ function $e({
120
121
  queueFiles: h,
121
122
  disabled: c,
122
123
  isUploadDisabled: E,
123
- uploadedFiles: u,
124
+ uploadedFiles: p,
124
125
  isMaxFilesExceeded: J,
125
126
  label: z,
126
127
  required: R,
@@ -139,13 +140,13 @@ function $e({
139
140
  handleRemoveFile: Z,
140
141
  displayFileSize: Y
141
142
  }, ee = k != null && (Array.isArray(k) ? k.length > 0 : !0);
142
- return /* @__PURE__ */ a(w.Provider, { value: U, children: [
143
+ return /* @__PURE__ */ a(v.Provider, { value: U, children: [
143
144
  /* @__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
+ /* @__PURE__ */ i("div", { className: C(t.container, e === "multiple" && t.containerMultiple, c && t.disabled), children: ee ? k : /* @__PURE__ */ i(Ae, {}) })
145
146
  ] });
146
147
  }
147
- function Oe() {
148
- const e = p();
148
+ function Ae() {
149
+ const e = u();
149
150
  return /* @__PURE__ */ a(ne, { children: [
150
151
  /* @__PURE__ */ i(I.Label, {}),
151
152
  e.type === "single" && /* @__PURE__ */ i(I.SingleFileRow, { children: /* @__PURE__ */ i(I.BrowseButton, {}) }),
@@ -155,53 +156,53 @@ function Oe() {
155
156
  /* @__PURE__ */ i(I.UploadedFilesList, {})
156
157
  ] });
157
158
  }
158
- function Ae({
159
+ function Xe({
159
160
  children: e
160
161
  }) {
161
- const l = p(), s = e ?? l.label;
162
+ const l = u(), s = e ?? l.label;
162
163
  return /* @__PURE__ */ a("label", { htmlFor: l.id, onClick: (r) => r.preventDefault(), className: C(t.label, l.type === "multiple" && t.labelMultiple), children: [
163
164
  /* @__PURE__ */ i("span", { title: l.label, className: t.labelText, children: s }),
164
165
  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.labelTooltip && /* @__PURE__ */ i(ue, { 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
167
  l.type === "multiple" && l.multipleHelpText && /* @__PURE__ */ i("span", { className: t.multipleHelpText, children: l.multipleHelpText })
167
168
  ] });
168
169
  }
169
- function Xe({
170
+ function Je({
170
171
  children: e,
171
172
  className: l
172
173
  }) {
173
- const s = p();
174
+ const s = u();
174
175
  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
176
  r.preventDefault(), r.stopPropagation(), s.triggerInput();
176
177
  }, children: /* @__PURE__ */ i("span", { children: e ?? "Browse file" }) });
177
178
  }
178
- function Je({
179
+ function Ye({
179
180
  children: e
180
181
  }) {
181
- return p().type !== "single" ? null : /* @__PURE__ */ i("div", { className: t.singleFileContainer, children: e });
182
+ return u().type !== "single" ? null : /* @__PURE__ */ i("div", { className: t.singleFileContainer, children: e });
182
183
  }
183
- function Ye({
184
+ function Ge({
184
185
  children: e
185
186
  }) {
186
- const l = p();
187
+ const l = u();
187
188
  return l.type !== "single" ? null : /* @__PURE__ */ a("div", { tabIndex: l.disabled ? -1 : 0, onClick: l.triggerInput, onKeyDown: l.handleKeyDown, className: t.singleFileInputContainer, children: [
188
189
  /* @__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
190
  e
190
191
  ] });
191
192
  }
192
- function Ge() {
193
- return p().type !== "single" ? null : /* @__PURE__ */ i("span", { className: t.singleFileHelpLinkReservedSpace, children: /* @__PURE__ */ i(M, {}) });
193
+ function Qe() {
194
+ return u().type !== "single" ? null : /* @__PURE__ */ i("span", { className: t.singleFileHelpLinkReservedSpace, children: /* @__PURE__ */ i(w, {}) });
194
195
  }
195
- function M() {
196
- const e = p();
196
+ function w() {
197
+ const e = u();
197
198
  if (e.type !== "single" || e.uploadedFiles.length === 0) return null;
198
199
  const l = e.uploadedFiles[0].file.name;
199
200
  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
  }
201
- function Qe() {
202
+ function We() {
202
203
  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: [
204
+ const e = u(), 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.` : "");
205
+ return e.type === "multiple" && !s ? null : /* @__PURE__ */ a("div", { className: t.helpers, children: [
205
206
  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
207
  e.type === "single" && e.helpLink && e.helpLinkText && /* @__PURE__ */ a("span", { className: t.singleFileHelpLinkContainer, children: [
207
208
  /* @__PURE__ */ i("a", { href: e.helpLink, className: t.helpLink, target: "_blank", rel: "noopener noreferrer", tabIndex: e.disabled ? -1 : 0, children: e.helpLinkText }),
@@ -209,8 +210,8 @@ function Qe() {
209
210
  ] })
210
211
  ] });
211
212
  }
212
- function We() {
213
- const e = p();
213
+ function Ze() {
214
+ const e = u();
214
215
  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
216
  /* @__PURE__ */ i("span", { className: t.multipleFilesListItemIconContainer, children: /* @__PURE__ */ i(D, { icon: "ap-icon-document", className: t.multipleFilesListItemIcon }) }),
216
217
  /* @__PURE__ */ a("div", { className: t.multipleFilesListItemContentData, children: [
@@ -226,17 +227,17 @@ function We() {
226
227
  ] })
227
228
  ] }) }, s)) });
228
229
  }
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
230
+ const I = Object.assign(Oe, {
231
+ Label: Xe,
232
+ BrowseButton: Je,
233
+ HelpText: We,
234
+ UploadedFilesList: Ze,
235
+ SingleFileContainer: Ye,
236
+ SingleFileRow: Ge,
237
+ SingleFileActions: Qe,
238
+ SingleFileDeleteButton: w
238
239
  });
239
240
  export {
240
241
  I as default,
241
- p as useFilePickerContext
242
+ u as useFilePickerContext
242
243
  };