@alixpartners/ui-components 2.0.0-beta.9 → 2.0.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.
- package/README.md +2 -2
- package/dist/ap-logos-Cl1TR5nm.js +4 -0
- package/dist/assets/Banner.css +1 -1
- package/dist/assets/Button.css +1 -1
- package/dist/assets/Checkbox.css +1 -1
- package/dist/assets/Dialog.css +1 -1
- package/dist/assets/DragAndDrop.css +1 -1
- package/dist/assets/Dropdown.css +1 -1
- package/dist/assets/Input.css +1 -1
- package/dist/assets/LogosGallery.css +1 -0
- package/dist/assets/NavBar.css +1 -1
- package/dist/assets/SplitButton.css +1 -1
- package/dist/assets/TabNavigation.css +1 -1
- package/dist/assets/Tag.css +1 -1
- package/dist/assets/Textarea.css +1 -1
- package/dist/assets/Toast.css +1 -1
- package/dist/assets/ap-icons-types.d.ts +1 -1
- package/dist/assets/ap-icons.d.ts +1 -1
- package/dist/assets/ap-logos-types.d.ts +1 -0
- package/dist/assets/ap-logos.d.ts +1 -0
- package/dist/assets/main.css +1 -1
- package/dist/components/Button/Button.d.ts +11 -12
- package/dist/components/Button/Button.js +15 -14
- package/dist/components/Creatable/Creatable.d.ts +3 -1
- package/dist/components/Creatable/Creatable.js +26 -25
- package/dist/components/Dialog/Dialog.d.ts +15 -4
- package/dist/components/Dialog/Dialog.js +58 -42
- package/dist/components/DragAndDrop/DragAndDrop.d.ts +4 -1
- package/dist/components/DragAndDrop/DragAndDrop.js +82 -72
- package/dist/components/Dropdown/Dropdown.d.ts +8 -1
- package/dist/components/Dropdown/Dropdown.js +354 -320
- package/dist/components/Icons/IconsGallery.js +1 -1
- package/dist/components/Input/Input.d.ts +23 -22
- package/dist/components/Input/Input.js +62 -60
- package/dist/components/Logo/Logo.d.ts +8 -0
- package/dist/components/Logo/Logo.js +57 -0
- package/dist/components/Logos/LogosGallery.d.ts +1 -0
- package/dist/components/Logos/LogosGallery.js +16 -0
- package/dist/components/NavBar/NavBar.d.ts +13 -5
- package/dist/components/NavBar/NavBar.js +246 -230
- package/dist/components/SplitButton/SplitButton.js +20 -18
- package/dist/components/Tab/Tab.js +19 -19
- package/dist/components/TabNavigation/TabNavigation.js +11 -10
- package/dist/components/Tag/Tag.js +8 -8
- package/dist/components/Textarea/Textarea.d.ts +2 -2
- package/dist/components/Toast/Toast.js +2 -2
- package/dist/components/Toast/Toast.test.js +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +1 -1
- package/dist/components/Tooltip/Tooltip.js +12 -10
- package/dist/main.d.ts +5 -3
- package/dist/main.js +29 -25
- package/dist/storybook-docs-page.d.ts +4 -1
- package/package.json +1 -1
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { ApIcon } from '../../assets/ap-icons-types';
|
|
2
2
|
import { DataAttributes } from '../../types/data-attributes';
|
|
3
3
|
import { InteractiveEventHandlers } from '../../types/native-events';
|
|
4
|
+
export type ButtonProps = {
|
|
5
|
+
type: 'primary' | 'secondary' | 'tertiary';
|
|
6
|
+
variant: 'default' | 'danger' | 'cancel';
|
|
7
|
+
size: 'sm' | 'md';
|
|
8
|
+
icon?: ApIcon;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
loading?: boolean;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
className?: string;
|
|
13
|
+
iconClassName?: string;
|
|
14
|
+
} & DataAttributes & InteractiveEventHandlers;
|
|
4
15
|
/**
|
|
5
16
|
* A versatile button component that supports different types, variants, sizes, and states.
|
|
6
17
|
* Used for user interactions and form submissions throughout the application.
|
|
@@ -16,16 +27,4 @@ import { InteractiveEventHandlers } from '../../types/native-events';
|
|
|
16
27
|
* @param {() => void} [props.onClick] - Callback fired when the button is clicked
|
|
17
28
|
* @returns {JSX.Element} The rendered Button component
|
|
18
29
|
*/
|
|
19
|
-
type ButtonProps = {
|
|
20
|
-
type: 'primary' | 'secondary' | 'tertiary';
|
|
21
|
-
variant: 'default' | 'danger' | 'cancel';
|
|
22
|
-
size: 'sm' | 'md';
|
|
23
|
-
icon?: ApIcon;
|
|
24
|
-
disabled?: boolean;
|
|
25
|
-
loading?: boolean;
|
|
26
|
-
children?: React.ReactNode;
|
|
27
|
-
className?: string;
|
|
28
|
-
iconClassName?: string;
|
|
29
|
-
} & DataAttributes & InteractiveEventHandlers;
|
|
30
30
|
export default function Button({ type, variant, size, icon, disabled, loading, children, className, iconClassName, ...props }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
31
|
-
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsxs as y, jsx as b } from "react/jsx-runtime";
|
|
2
|
-
import { c as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
2
|
+
import { c as a } from "../../clsx-OuTLNxxd.js";
|
|
3
|
+
import f from "../Spinner/Spinner.js";
|
|
4
|
+
import g from "../Icon/Icon.js";
|
|
5
|
+
import '../../assets/Button.css';const w = "Button-module__btn___daEdK", x = "Button-module__loading___QfItr", t = {
|
|
6
|
+
btn: w,
|
|
6
7
|
"btn-icon": "Button-module__btn-icon___G7m4S",
|
|
7
8
|
"btn-icon-sm": "Button-module__btn-icon-sm___w7eg9",
|
|
8
9
|
"btn-icon-md": "Button-module__btn-icon-md___8Ywy2",
|
|
@@ -15,12 +16,12 @@ import '../../assets/Button.css';const f = "Button-module__btn___daEdK", w = "Bu
|
|
|
15
16
|
"btn-tertiary": "Button-module__btn-tertiary___G-7lD",
|
|
16
17
|
"btn-disabled": "Button-module__btn-disabled___eg1uH",
|
|
17
18
|
"btn-loading": "Button-module__btn-loading___vAg78",
|
|
18
|
-
loading:
|
|
19
|
+
loading: x,
|
|
19
20
|
"btn-sm": "Button-module__btn-sm___KNlkv",
|
|
20
21
|
"btn-md": "Button-module__btn-md___C8vqh",
|
|
21
22
|
"btn-text": "Button-module__btn-text___3ccH9"
|
|
22
23
|
};
|
|
23
|
-
function
|
|
24
|
+
function h({
|
|
24
25
|
type: c,
|
|
25
26
|
variant: i,
|
|
26
27
|
size: o,
|
|
@@ -28,20 +29,20 @@ function D({
|
|
|
28
29
|
disabled: u = !1,
|
|
29
30
|
loading: e = !1,
|
|
30
31
|
children: d,
|
|
31
|
-
className:
|
|
32
|
-
iconClassName:
|
|
32
|
+
className: r,
|
|
33
|
+
iconClassName: s,
|
|
33
34
|
..._
|
|
34
35
|
}) {
|
|
35
36
|
const B = (n) => {
|
|
36
|
-
var
|
|
37
|
-
(n.key === "Enter" || n.key === " ") && (n.preventDefault(), n.currentTarget.click()), (
|
|
37
|
+
var m;
|
|
38
|
+
(n.key === "Enter" || n.key === " ") && (n.preventDefault(), n.currentTarget.click()), (m = _.onKeyDown) == null || m.call(_, n);
|
|
38
39
|
};
|
|
39
|
-
return /* @__PURE__ */ y("button", { type: "button", className:
|
|
40
|
-
!!l && !e && /* @__PURE__ */ b(
|
|
41
|
-
e && /* @__PURE__ */ b(
|
|
40
|
+
return /* @__PURE__ */ y("button", { type: "button", className: a(t.btn, t[`btn-${c}`], t[`btn-${i}`], t[`btn-${o}`], u && t["btn-disabled"], r), disabled: u || e, onKeyDown: B, ..._, children: [
|
|
41
|
+
!!l && !e && /* @__PURE__ */ b(g, { icon: l, className: a(t["btn-icon"], t[`btn-icon-${o}`], s) }),
|
|
42
|
+
e && /* @__PURE__ */ b(f, { size: o, color: "white", className: t["loading-spinner"] }),
|
|
42
43
|
d && /* @__PURE__ */ b("span", { className: t["btn-text"], children: d })
|
|
43
44
|
] });
|
|
44
45
|
}
|
|
45
46
|
export {
|
|
46
|
-
|
|
47
|
+
h as default
|
|
47
48
|
};
|
|
@@ -12,6 +12,7 @@ type CreatableProps = {
|
|
|
12
12
|
helpLink?: string;
|
|
13
13
|
helpLinkText?: string;
|
|
14
14
|
disabled?: boolean;
|
|
15
|
+
caseSensitive?: boolean;
|
|
15
16
|
errorMessage?: string;
|
|
16
17
|
onChange?: (selectedValues: string[]) => void;
|
|
17
18
|
} & DataAttributes & InteractiveEventHandlers;
|
|
@@ -31,10 +32,11 @@ type CreatableProps = {
|
|
|
31
32
|
* @param {[string]} [props.helpLink] - Optional URL for help link displayed with helper text
|
|
32
33
|
* @param {[string]} [props.helpLinkText] - Optional help link label to display when `helpLink` is provided
|
|
33
34
|
* @param {[boolean]} [props.disabled] - Whether the field is disabled
|
|
35
|
+
* @param {[boolean]} [props.caseSensitive] - Whether to perform case-sensitive matching when checking for existing options in creatable mode (defaults to false)
|
|
34
36
|
* @param {[string]} [props.errorMessage] - Optional error message displayed below the field
|
|
35
37
|
* @param {(selectedValues: string[]) => void} [props.onChange] - Callback fired when selection changes
|
|
36
38
|
* @param {DataAttributes} [props.data-*] - Additional `data-` attributes forwarded to the root element
|
|
37
39
|
* @returns {JSX.Element} The rendered Creatable component
|
|
38
40
|
*/
|
|
39
|
-
export default function Creatable({ className, label, required, multiSelect, value, helpText, helpLink, helpLinkText, disabled, errorMessage, onChange, onClick, onDoubleClick, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, onMouseOver, onMouseOut, onMouseMove, onKeyDown, onKeyUp, onFocus, onBlur, ...props }: CreatableProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export default function Creatable({ className, label, required, multiSelect, value, helpText, helpLink, helpLinkText, disabled, caseSensitive, errorMessage, onChange, onClick, onDoubleClick, onMouseDown, onMouseUp, onMouseEnter, onMouseLeave, onMouseOver, onMouseOut, onMouseMove, onKeyDown, onKeyUp, onFocus, onBlur, ...props }: CreatableProps): import("react/jsx-runtime").JSX.Element;
|
|
40
42
|
export {};
|
|
@@ -1,34 +1,35 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
function
|
|
4
|
-
className:
|
|
5
|
-
label:
|
|
6
|
-
required:
|
|
7
|
-
multiSelect:
|
|
1
|
+
import { jsx as y } from "react/jsx-runtime";
|
|
2
|
+
import z from "../Dropdown/Dropdown.js";
|
|
3
|
+
function E({
|
|
4
|
+
className: e,
|
|
5
|
+
label: r,
|
|
6
|
+
required: a = !1,
|
|
7
|
+
multiSelect: t = !1,
|
|
8
8
|
value: o,
|
|
9
9
|
helpText: f,
|
|
10
10
|
helpLink: l,
|
|
11
11
|
helpLinkText: s,
|
|
12
12
|
disabled: i,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
caseSensitive: m = !1,
|
|
14
|
+
errorMessage: n,
|
|
15
|
+
onChange: p,
|
|
16
|
+
onClick: u,
|
|
17
|
+
onDoubleClick: b,
|
|
18
|
+
onMouseDown: d,
|
|
19
|
+
onMouseUp: x,
|
|
20
|
+
onMouseEnter: C,
|
|
21
|
+
onMouseLeave: c,
|
|
22
|
+
onMouseOver: j,
|
|
23
|
+
onMouseOut: w,
|
|
24
|
+
onMouseMove: D,
|
|
25
|
+
onKeyDown: g,
|
|
26
|
+
onKeyUp: h,
|
|
27
|
+
onFocus: k,
|
|
28
|
+
onBlur: q,
|
|
29
|
+
...v
|
|
29
30
|
}) {
|
|
30
|
-
return /* @__PURE__ */
|
|
31
|
+
return /* @__PURE__ */ y(z, { className: e, label: r, required: a, isCreatable: !0, multiSelect: t, value: o, helpText: f, helpLink: l, helpLinkText: s, disabled: i, caseSensitive: m, errorMessage: n, onChange: p, onClick: u, onDoubleClick: b, onMouseDown: d, onMouseUp: x, onMouseEnter: C, onMouseLeave: c, onMouseOver: j, onMouseOut: w, onMouseMove: D, onKeyDown: g, onKeyUp: h, onFocus: k, onBlur: q, ...v });
|
|
31
32
|
}
|
|
32
33
|
export {
|
|
33
|
-
|
|
34
|
+
E as default
|
|
34
35
|
};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { DataAttributes } from '../../types/data-attributes';
|
|
2
|
+
import { ApIcon } from '../../assets/ap-icons-types';
|
|
2
3
|
/**
|
|
3
4
|
* Dialog component that displays modal content with customizable actions and optional illustration.
|
|
4
5
|
* Provides a native HTML dialog element with backdrop support, confirmation/cancellation actions, and accessibility features.
|
|
5
6
|
*
|
|
6
7
|
* @param {object} props - Dialog component props
|
|
7
|
-
* @param {React.ReactNode} props.children - The trigger element that opens the dialog when clicked
|
|
8
|
+
* @param {React.ReactNode} [props.children] - The trigger element that opens the dialog when clicked (optional when using isOpen prop)
|
|
9
|
+
* @param {boolean} [props.isOpen] - Controls whether the dialog is displayed. When provided, the dialog becomes controlled and children trigger is optional
|
|
8
10
|
* @param {() => void} [props.onClose] - Callback fired when the dialog is closed (shows close button when provided)
|
|
9
11
|
* @param {string} props.title - The title text displayed at the top of the dialog
|
|
10
12
|
* @param {string} props.description - The description text displayed below the title
|
|
@@ -17,15 +19,24 @@ import { DataAttributes } from '../../types/data-attributes';
|
|
|
17
19
|
*/
|
|
18
20
|
type DialogProps = {
|
|
19
21
|
className?: string;
|
|
20
|
-
children
|
|
22
|
+
children?: React.ReactNode;
|
|
23
|
+
isOpen?: boolean;
|
|
21
24
|
onClose?: () => void;
|
|
22
25
|
title: string;
|
|
23
|
-
description:
|
|
26
|
+
description: React.ReactNode;
|
|
24
27
|
illustrationSrc?: string;
|
|
25
28
|
confirmButtonText?: string;
|
|
26
29
|
cancelButtonText?: string;
|
|
30
|
+
confirmButtonType?: 'primary' | 'secondary' | 'tertiary';
|
|
31
|
+
cancelButtonType?: 'primary' | 'secondary' | 'tertiary';
|
|
32
|
+
confirmButtonVariant?: 'default' | 'danger' | 'cancel';
|
|
33
|
+
cancelButtonVariant?: 'default' | 'danger' | 'cancel';
|
|
34
|
+
confirmButtonSize?: 'sm' | 'md';
|
|
35
|
+
cancelButtonSize?: 'sm' | 'md';
|
|
36
|
+
confirmButtonIcon?: ApIcon;
|
|
37
|
+
cancelButtonIcon?: ApIcon;
|
|
27
38
|
onConfirm?: () => void;
|
|
28
39
|
onCancel?: () => void;
|
|
29
40
|
} & DataAttributes;
|
|
30
|
-
export default function Dialog({ children, onClose, title, description, illustrationSrc, confirmButtonText, cancelButtonText, onConfirm, onCancel, className, ...props }: DialogProps): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export default function Dialog({ children, isOpen, onClose, title, description, illustrationSrc, confirmButtonText, cancelButtonText, confirmButtonType, cancelButtonType, confirmButtonVariant, cancelButtonVariant, confirmButtonSize, cancelButtonSize, confirmButtonIcon, cancelButtonIcon, onConfirm, onCancel, className, ...props }: DialogProps): import("react/jsx-runtime").JSX.Element;
|
|
31
42
|
export {};
|
|
@@ -1,57 +1,73 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
import { jsxs as c, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as h, useEffect as I } from "react";
|
|
3
|
+
import f from "../Button/Button.js";
|
|
4
|
+
import H from "../Icon/Icon.js";
|
|
5
|
+
import '../../assets/Dialog.css';const J = "Dialog-module__dialog___r4ljx", a = {
|
|
6
|
+
dialog: J,
|
|
6
7
|
"dialog-illustration": "Dialog-module__dialog-illustration___IHiQl",
|
|
7
8
|
"dialog-content": "Dialog-module__dialog-content___3hOGc",
|
|
8
|
-
"dialog-close-button-container": "Dialog-module__dialog-close-button-container___35uPS",
|
|
9
9
|
"dialog-title": "Dialog-module__dialog-title___KACAJ",
|
|
10
10
|
"dialog-description": "Dialog-module__dialog-description___hL8fm",
|
|
11
|
-
"dialog-buttons": "Dialog-module__dialog-buttons___x-v2M"
|
|
11
|
+
"dialog-buttons": "Dialog-module__dialog-buttons___x-v2M",
|
|
12
|
+
"dialog-close-button": "Dialog-module__dialog-close-button___-PzEz",
|
|
13
|
+
"dialog-close-button-icon": "Dialog-module__dialog-close-button-icon___BeGg2"
|
|
12
14
|
};
|
|
13
|
-
function
|
|
14
|
-
children:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
function q({
|
|
16
|
+
children: g,
|
|
17
|
+
isOpen: d,
|
|
18
|
+
onClose: l,
|
|
19
|
+
title: v,
|
|
20
|
+
description: b,
|
|
18
21
|
illustrationSrc: s,
|
|
19
|
-
confirmButtonText:
|
|
20
|
-
cancelButtonText:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
confirmButtonText: _,
|
|
23
|
+
cancelButtonText: u,
|
|
24
|
+
confirmButtonType: D = "primary",
|
|
25
|
+
cancelButtonType: p = "primary",
|
|
26
|
+
confirmButtonVariant: N = "default",
|
|
27
|
+
cancelButtonVariant: k = "cancel",
|
|
28
|
+
confirmButtonSize: y = "md",
|
|
29
|
+
cancelButtonSize: z = "md",
|
|
30
|
+
confirmButtonIcon: j,
|
|
31
|
+
cancelButtonIcon: x,
|
|
32
|
+
onConfirm: e,
|
|
33
|
+
onCancel: r,
|
|
34
|
+
className: M,
|
|
35
|
+
...R
|
|
25
36
|
}) {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
const w = h(null), t = h(null);
|
|
38
|
+
I(() => {
|
|
39
|
+
var i, m;
|
|
40
|
+
d !== void 0 && (d ? (i = t.current) == null || i.showModal() : (m = t.current) == null || m.close());
|
|
41
|
+
}, [d]);
|
|
42
|
+
const A = () => {
|
|
43
|
+
var i;
|
|
44
|
+
(i = t.current) == null || i.showModal();
|
|
45
|
+
}, n = () => {
|
|
46
|
+
var i;
|
|
47
|
+
l == null || l(), d === void 0 && ((i = t.current) == null || i.close());
|
|
48
|
+
}, E = () => {
|
|
49
|
+
var i;
|
|
50
|
+
e == null || e(), d === void 0 && ((i = t.current) == null || i.close(), l == null || l());
|
|
51
|
+
}, G = () => {
|
|
52
|
+
var i;
|
|
53
|
+
r == null || r(), d === void 0 && ((i = t.current) == null || i.close(), l == null || l());
|
|
38
54
|
};
|
|
39
|
-
return /* @__PURE__ */
|
|
40
|
-
/* @__PURE__ */
|
|
41
|
-
/* @__PURE__ */
|
|
42
|
-
/* @__PURE__ */
|
|
43
|
-
s && /* @__PURE__ */
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
-
/* @__PURE__ */
|
|
46
|
-
/* @__PURE__ */
|
|
55
|
+
return /* @__PURE__ */ c("div", { className: M, ...R, children: [
|
|
56
|
+
g && /* @__PURE__ */ o("div", { ref: w, onClick: A, children: g }),
|
|
57
|
+
/* @__PURE__ */ c("dialog", { className: a.dialog, ref: t, onClose: n, children: [
|
|
58
|
+
l && /* @__PURE__ */ o("button", { className: a["dialog-close-button"], onClick: n, children: /* @__PURE__ */ o(H, { className: a["dialog-close-button-icon"], icon: "ap-icon-close" }) }),
|
|
59
|
+
s && /* @__PURE__ */ o("div", { className: a["dialog-illustration"], children: /* @__PURE__ */ o("img", { src: s, alt: "Dialog illustration" }) }),
|
|
60
|
+
/* @__PURE__ */ c("div", { className: a["dialog-content"], children: [
|
|
61
|
+
/* @__PURE__ */ o("h2", { className: a["dialog-title"], children: v }),
|
|
62
|
+
/* @__PURE__ */ o("div", { className: a["dialog-description"], children: b })
|
|
47
63
|
] }),
|
|
48
|
-
/* @__PURE__ */
|
|
49
|
-
|
|
50
|
-
|
|
64
|
+
/* @__PURE__ */ c("div", { className: a["dialog-buttons"], children: [
|
|
65
|
+
u && /* @__PURE__ */ o(f, { type: p, variant: k, size: z, onClick: G, icon: x, children: u }),
|
|
66
|
+
_ && /* @__PURE__ */ o(f, { type: D, variant: N, size: y, onClick: E, icon: j, children: _ })
|
|
51
67
|
] })
|
|
52
68
|
] })
|
|
53
69
|
] });
|
|
54
70
|
}
|
|
55
71
|
export {
|
|
56
|
-
|
|
72
|
+
q as default
|
|
57
73
|
};
|
|
@@ -13,7 +13,9 @@ type DragAndDropProps = {
|
|
|
13
13
|
fileExtensionsAllowed: string[];
|
|
14
14
|
maxSize: number;
|
|
15
15
|
maxFiles?: number;
|
|
16
|
+
value?: File | File[];
|
|
16
17
|
onUpload?: (files: UploadFile[]) => void;
|
|
18
|
+
onRemoveFile?: (fileName: string) => void;
|
|
17
19
|
queueFiles?: boolean;
|
|
18
20
|
} & DataAttributes & DraggableEventHandlers;
|
|
19
21
|
/**
|
|
@@ -28,9 +30,10 @@ type DragAndDropProps = {
|
|
|
28
30
|
* @param {string[]} props.fileExtensionsAllowed - Allowed file extensions (e.g. ['pdf','png'])
|
|
29
31
|
* @param {number} props.maxSize - Maximum file size in MB
|
|
30
32
|
* @param {number} [props.maxFiles] - Maximum number of files when type is 'multiple'
|
|
33
|
+
* @param {File | File[]} [props.value] - Controlled value for the component; accepts a single File or array of Files
|
|
31
34
|
* @param {(files: UploadFile[]) => void} [props.onUpload] - Callback fired with validated files upon selection or drop
|
|
32
35
|
* @param {boolean} [props.queueFiles] - When true, newly selected files are appended to the existing list
|
|
33
36
|
* @returns {JSX.Element} The rendered DragAndDrop component
|
|
34
37
|
*/
|
|
35
|
-
export default function DragAndDrop({ label, type, disabled, required, fileExtensionsAllowed, maxSize, maxFiles, onUpload, queueFiles, className, ...props }: DragAndDropProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export default function DragAndDrop({ label, type, disabled, required, fileExtensionsAllowed, maxSize, maxFiles, value, onUpload, onRemoveFile, queueFiles, className, ...props }: DragAndDropProps): import("react/jsx-runtime").JSX.Element;
|
|
36
39
|
export {};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useId as
|
|
3
|
-
import
|
|
4
|
-
import { c as
|
|
5
|
-
import
|
|
6
|
-
import '../../assets/DragAndDrop.css';const
|
|
1
|
+
import { jsxs as l, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useId as J, useRef as w, useState as K, useCallback as M } from "react";
|
|
3
|
+
import j from "../Button/Button.js";
|
|
4
|
+
import { c as R } from "../../clsx-OuTLNxxd.js";
|
|
5
|
+
import q from "../Icon/Icon.js";
|
|
6
|
+
import '../../assets/DragAndDrop.css';const X = "DragAndDrop-module__disabled___h47do", U = "DragAndDrop-module__required___z3cHB", ee = "DragAndDrop-module__active___ZMuEx", a = {
|
|
7
7
|
"drag-and-drop-container": "DragAndDrop-module__drag-and-drop-container___WHqGh",
|
|
8
|
-
disabled:
|
|
9
|
-
required:
|
|
8
|
+
disabled: X,
|
|
9
|
+
required: U,
|
|
10
10
|
"drag-and-drop-space-text-message": "DragAndDrop-module__drag-and-drop-space-text-message___fL-Ac",
|
|
11
11
|
"drag-and-drop-space-text-constraints": "DragAndDrop-module__drag-and-drop-space-text-constraints___YrL7J",
|
|
12
12
|
"drag-and-drop-space": "DragAndDrop-module__drag-and-drop-space___09a0I",
|
|
13
|
-
active:
|
|
13
|
+
active: ee,
|
|
14
14
|
"drag-and-drop-space-text": "DragAndDrop-module__drag-and-drop-space-text___-8rqC",
|
|
15
15
|
"drag-and-drop-files-list": "DragAndDrop-module__drag-and-drop-files-list___7WNCk",
|
|
16
16
|
"drag-and-drop-files-list-item": "DragAndDrop-module__drag-and-drop-files-list-item___vQO6M",
|
|
@@ -22,91 +22,101 @@ import '../../assets/DragAndDrop.css';const W = "DragAndDrop-module__disabled___
|
|
|
22
22
|
"drag-and-drop-files-list-item-name": "DragAndDrop-module__drag-and-drop-files-list-item-name___M7OAd",
|
|
23
23
|
"drag-and-drop-files-list-item-size": "DragAndDrop-module__drag-and-drop-files-list-item-size___aaovj",
|
|
24
24
|
"drag-and-drop-files-list-item-error": "DragAndDrop-module__drag-and-drop-files-list-item-error___yR0DY",
|
|
25
|
-
"drag-and-drop-files-list-item-icon-error": "DragAndDrop-module__drag-and-drop-files-list-item-icon-error___17EE-"
|
|
25
|
+
"drag-and-drop-files-list-item-icon-error": "DragAndDrop-module__drag-and-drop-files-list-item-icon-error___17EE-",
|
|
26
|
+
"drag-and-drop-files-list-item-icon-delete": "DragAndDrop-module__drag-and-drop-files-list-item-icon-delete___Z1l-B"
|
|
26
27
|
};
|
|
27
|
-
function
|
|
28
|
-
label:
|
|
29
|
-
type:
|
|
30
|
-
disabled:
|
|
31
|
-
required:
|
|
28
|
+
function ne({
|
|
29
|
+
label: k,
|
|
30
|
+
type: c = "single",
|
|
31
|
+
disabled: z,
|
|
32
|
+
required: E,
|
|
32
33
|
fileExtensionsAllowed: p,
|
|
33
|
-
maxSize:
|
|
34
|
-
maxFiles:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
maxSize: g,
|
|
35
|
+
maxFiles: m = Number.POSITIVE_INFINITY,
|
|
36
|
+
value: f,
|
|
37
|
+
onUpload: t,
|
|
38
|
+
onRemoveFile: N,
|
|
39
|
+
queueFiles: D,
|
|
40
|
+
className: P,
|
|
41
|
+
...s
|
|
39
42
|
}) {
|
|
40
|
-
const
|
|
43
|
+
const B = J(), O = w(null), h = w(null), [A, x] = K([]), v = f !== void 0, C = p.join(", "), I = g ? `up to ${g}MB` : "", Y = p.map((e) => `.${e.replace(/^\./, "")}`).join(","), $ = () => {
|
|
41
44
|
var e;
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
let
|
|
47
|
-
return
|
|
48
|
-
file:
|
|
49
|
-
error:
|
|
45
|
+
u() || (e = O.current) == null || e.click();
|
|
46
|
+
}, y = M((e) => {
|
|
47
|
+
const i = g ? g * 1024 * 1024 : Number.POSITIVE_INFINITY, r = new Set(p.map((_) => _.toLowerCase().replace(/^\./, ""))), o = e.map((_) => {
|
|
48
|
+
const L = _.size <= i, T = _.name.toLowerCase(), F = T.includes(".") ? T.split(".").pop() ?? "" : "", G = r.size === 0 || r.has(F);
|
|
49
|
+
let b;
|
|
50
|
+
return L || (b = `File size is too large. Must be ${I}.`), G || (b = `The file format is incorrect. Please make sure it is one of the extensions: ${C}.`), {
|
|
51
|
+
file: _,
|
|
52
|
+
error: b
|
|
50
53
|
};
|
|
51
54
|
});
|
|
52
|
-
return
|
|
53
|
-
},
|
|
55
|
+
return c === "single" ? o.slice(0, 1) : m && m > 0 ? o.slice(0, m) : o;
|
|
56
|
+
}, [g, p, I, C, c, m]), d = v ? (() => {
|
|
57
|
+
const e = Array.isArray(f) ? f : f ? [f] : [];
|
|
58
|
+
return y(e);
|
|
59
|
+
})() : A, S = (e) => (e / 1024).toFixed(2) + " KB", u = M(() => z || (d == null ? void 0 : d.length) >= m || c === "single" && (d == null ? void 0 : d.length) > 0, [z, d, m, c]), H = (e) => {
|
|
54
60
|
if (!e.target.files) return;
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
},
|
|
64
|
-
var
|
|
65
|
-
e.preventDefault(), (
|
|
66
|
-
},
|
|
67
|
-
var
|
|
61
|
+
const i = Array.from(e.target.files), r = y(i);
|
|
62
|
+
v ? t == null || t(r) : (x((o) => D ? [...o, ...r] : r), D ? t == null || t([...A, ...r]) : t == null || t(r)), e.target.value = "";
|
|
63
|
+
}, Q = (e) => {
|
|
64
|
+
if (!v) {
|
|
65
|
+
const i = A.filter((r) => r.file.name !== e);
|
|
66
|
+
x(i);
|
|
67
|
+
}
|
|
68
|
+
N == null || N(e);
|
|
69
|
+
}, V = (e) => {
|
|
70
|
+
var i, r;
|
|
71
|
+
u() || (e.preventDefault(), (i = h.current) == null || i.classList.add(a.active), (r = s.onDragOver) == null || r.call(s, e));
|
|
72
|
+
}, W = (e) => {
|
|
73
|
+
var i, r;
|
|
74
|
+
e.preventDefault(), (i = h.current) == null || i.classList.remove(a.active), (r = s.onDragLeave) == null || r.call(s, e);
|
|
75
|
+
}, Z = (e) => {
|
|
76
|
+
var o, _;
|
|
77
|
+
if (u()) return;
|
|
68
78
|
e.preventDefault();
|
|
69
|
-
const
|
|
70
|
-
|
|
79
|
+
const i = Array.from(e.dataTransfer.files), r = y(i);
|
|
80
|
+
v ? t == null || t(r) : (x((L) => D ? [...L, ...r] : r), D ? t == null || t([...A, ...r]) : t == null || t(r)), e.dataTransfer.clearData(), (o = h.current) == null || o.classList.remove(a.active), (_ = s.onDrop) == null || _.call(s, e);
|
|
71
81
|
};
|
|
72
|
-
return /* @__PURE__ */
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
82
|
+
return /* @__PURE__ */ l("div", { className: R(a["drag-and-drop-container"], u() && a.disabled, P), ...s, children: [
|
|
83
|
+
k && /* @__PURE__ */ l("label", { htmlFor: B, children: [
|
|
84
|
+
k,
|
|
85
|
+
E && /* @__PURE__ */ n("span", { "aria-hidden": "true", className: a.required, children: "*" })
|
|
76
86
|
] }),
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
/* @__PURE__ */
|
|
79
|
-
/* @__PURE__ */
|
|
87
|
+
/* @__PURE__ */ l("div", { ref: h, className: a["drag-and-drop-space"], onDragOver: V, onDragLeave: W, onDrop: Z, ...s, children: [
|
|
88
|
+
/* @__PURE__ */ n(j, { type: "secondary", variant: "default", size: "sm", disabled: u(), onClick: $, children: c === "single" ? "Browse file" : "Browse files" }),
|
|
89
|
+
/* @__PURE__ */ n("input", { id: B, ref: O, type: "file", style: {
|
|
80
90
|
display: "none"
|
|
81
|
-
}, multiple:
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
/* @__PURE__ */
|
|
91
|
+
}, multiple: c === "multiple", accept: Y, onChange: H }),
|
|
92
|
+
/* @__PURE__ */ l("div", { className: a["drag-and-drop-space-text"], children: [
|
|
93
|
+
/* @__PURE__ */ n("span", { className: a["drag-and-drop-space-text-message"], children: c === "single" ? "or drag your file" : "or drag multiple files" }),
|
|
94
|
+
/* @__PURE__ */ l("span", { className: a["drag-and-drop-space-text-constraints"], children: [
|
|
85
95
|
" ",
|
|
86
|
-
|
|
96
|
+
C,
|
|
87
97
|
" ",
|
|
88
|
-
|
|
98
|
+
c === "single" ? "file" : "files",
|
|
89
99
|
" ",
|
|
90
|
-
|
|
100
|
+
I
|
|
91
101
|
] })
|
|
92
102
|
] })
|
|
93
103
|
] }),
|
|
94
|
-
(
|
|
95
|
-
/* @__PURE__ */
|
|
96
|
-
/* @__PURE__ */
|
|
97
|
-
/* @__PURE__ */
|
|
98
|
-
/* @__PURE__ */
|
|
99
|
-
/* @__PURE__ */
|
|
100
|
-
e.error && /* @__PURE__ */
|
|
101
|
-
/* @__PURE__ */
|
|
104
|
+
(d == null ? void 0 : d.length) > 0 && /* @__PURE__ */ n("ul", { className: a["drag-and-drop-files-list"], children: d == null ? void 0 : d.map((e, i) => /* @__PURE__ */ n("li", { className: a["drag-and-drop-files-list-item"], children: /* @__PURE__ */ l("div", { className: a["drag-and-drop-files-list-item-content"], children: [
|
|
105
|
+
/* @__PURE__ */ n("span", { className: a["drag-and-drop-files-list-item-icon-container"], children: /* @__PURE__ */ n(q, { icon: "ap-icon-document", className: a["drag-and-drop-files-list-item-icon"] }) }),
|
|
106
|
+
/* @__PURE__ */ l("div", { className: a["drag-and-drop-files-list-item-content-data"], children: [
|
|
107
|
+
/* @__PURE__ */ l("div", { className: a["drag-and-drop-files-list-item-text"], children: [
|
|
108
|
+
/* @__PURE__ */ n("span", { className: a["drag-and-drop-files-list-item-name"], children: e.file.name }),
|
|
109
|
+
/* @__PURE__ */ n("span", { className: a["drag-and-drop-files-list-item-size"], children: S(e.file.size) }),
|
|
110
|
+
e.error && /* @__PURE__ */ l("span", { className: a["drag-and-drop-files-list-item-error"], children: [
|
|
111
|
+
/* @__PURE__ */ n(q, { icon: "ap-icon-alert", className: a["drag-and-drop-files-list-item-icon-error"] }),
|
|
102
112
|
e.error
|
|
103
113
|
] })
|
|
104
114
|
] }),
|
|
105
|
-
/* @__PURE__ */
|
|
115
|
+
/* @__PURE__ */ n(j, { type: "tertiary", variant: "default", size: "sm", onClick: () => Q(e.file.name), icon: "ap-icon-delete", iconClassName: a["drag-and-drop-files-list-item-icon-delete"] })
|
|
106
116
|
] })
|
|
107
|
-
] }) },
|
|
117
|
+
] }) }, i)) })
|
|
108
118
|
] });
|
|
109
119
|
}
|
|
110
120
|
export {
|
|
111
|
-
|
|
121
|
+
ne as default
|
|
112
122
|
};
|
|
@@ -35,6 +35,11 @@ type DropdownProps = {
|
|
|
35
35
|
hideSelectedItems?: boolean;
|
|
36
36
|
labelTooltip?: LabelTooltipProps;
|
|
37
37
|
isTagsFields?: boolean;
|
|
38
|
+
unselect?: boolean;
|
|
39
|
+
selectedOptionLabel?: string;
|
|
40
|
+
selectedOptionsLabel?: string;
|
|
41
|
+
allOptionsSelectedLabel?: string;
|
|
42
|
+
caseSensitive?: boolean;
|
|
38
43
|
} & DataAttributes & InteractiveEventHandlers;
|
|
39
44
|
/**
|
|
40
45
|
* A flexible dropdown component that supports single and multi-select functionality with search, categorization, and keyboard navigation.
|
|
@@ -64,7 +69,9 @@ type DropdownProps = {
|
|
|
64
69
|
* @param {boolean} [props.hideSelectedItems] - Whether to hide the selected items in the dropdown trigger (defaults to false)
|
|
65
70
|
* @param {LabelTooltipProps} [props.labelTooltip] - Tooltip to display next to the label
|
|
66
71
|
* @param {boolean} [props.isTagsFields] - Whether to use creatable-style UI without creation functionality (defaults to false)
|
|
72
|
+
* @param {boolean} [props.unselect] - Whether single select dropdown allows deselection of selected items (defaults to false)
|
|
73
|
+
* @param {boolean} [props.caseSensitive] - Whether to perform case-sensitive matching when checking for existing options in creatable mode (defaults to false)
|
|
67
74
|
* @returns {JSX.Element} The rendered Dropdown component
|
|
68
75
|
*/
|
|
69
|
-
export default function Dropdown({ className, label, options, value, placeholder, disabled, required, searchable, searchPlaceholder, errorMessage, helpText, helpLink, helpLinkText, onChange, onSearch, multiSelect, grouped, align, onToggleChange, toggleLabel, isCreatable, dropdownTriggerClassName, dropdownMenuClassName, hideSelectedItems, labelTooltip, isTagsFields, ...props }: DropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
76
|
+
export default function Dropdown({ className, label, options, value, placeholder, disabled, required, searchable, searchPlaceholder, errorMessage, helpText, helpLink, helpLinkText, onChange, onSearch, multiSelect, grouped, align, onToggleChange, toggleLabel, isCreatable, dropdownTriggerClassName, dropdownMenuClassName, hideSelectedItems, labelTooltip, isTagsFields, unselect, selectedOptionLabel, selectedOptionsLabel, allOptionsSelectedLabel, caseSensitive, ...props }: DropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
70
77
|
export {};
|