@frontify/fondue 12.0.0-beta.13 → 12.0.0-beta.16
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/dist/components/DatePicker/DatePickerTrigger.es.js +17 -16
- package/dist/components/DatePicker/DatePickerTrigger.es.js.map +1 -1
- package/dist/components/Dropdown/Dropdown.es.js +41 -40
- package/dist/components/Dropdown/Dropdown.es.js.map +1 -1
- package/dist/components/LoadingBar/LoadingBar.d.ts +24 -0
- package/dist/components/LoadingBar/LoadingBar.es.js +50 -0
- package/dist/components/LoadingBar/LoadingBar.es.js.map +1 -0
- package/dist/components/LoadingBar/index.d.ts +1 -0
- package/dist/components/OverflowMenu/OverflowMenu.d.ts +6 -0
- package/dist/components/OverflowMenu/OverflowMenu.es.js +1721 -0
- package/dist/components/OverflowMenu/OverflowMenu.es.js.map +1 -0
- package/dist/components/OverflowMenu/OverflowMenuItem.d.ts +11 -0
- package/dist/components/OverflowMenu/OverflowMenuItem.es.js +1763 -0
- package/dist/components/OverflowMenu/OverflowMenuItem.es.js.map +1 -0
- package/dist/components/OverflowMenu/index.d.ts +1 -0
- package/dist/components/OverflowMenu/useOverflowMenuKeyboardNavigation.d.ts +1 -0
- package/dist/components/OverflowMenu/useOverflowMenuKeyboardNavigation.es.js +29 -0
- package/dist/components/OverflowMenu/useOverflowMenuKeyboardNavigation.es.js.map +1 -0
- package/dist/components/RichTextEditor/Plugins/GeneratePlugins.d.ts +3 -3
- package/dist/components/RichTextEditor/Plugins/GeneratePlugins.es.js +12 -16
- package/dist/components/RichTextEditor/Plugins/GeneratePlugins.es.js.map +1 -1
- package/dist/components/RichTextEditor/Plugins/LinkPlugin/LinkMarkupElement/LinkMarkupElementNode.es.js.map +1 -1
- package/dist/components/RichTextEditor/RichTextEditor.es.js +19 -19
- package/dist/components/RichTextEditor/RichTextEditor.es.js.map +1 -1
- package/dist/components/RichTextEditor/Toolbar/index.d.ts +1 -1
- package/dist/components/RichTextEditor/Toolbar/index.es.js +19 -18
- package/dist/components/RichTextEditor/Toolbar/index.es.js.map +1 -1
- package/dist/components/RichTextEditor/Toolbar/types.d.ts +0 -2
- package/dist/components/RichTextEditor/context/RichTextEditorContext.d.ts +1 -1
- package/dist/components/RichTextEditor/context/RichTextEditorContext.es.js +16 -17
- package/dist/components/RichTextEditor/context/RichTextEditorContext.es.js.map +1 -1
- package/dist/components/RichTextEditor/serializer/utils/serializeLeafToHtml.d.ts +1 -2
- package/dist/components/RichTextEditor/serializer/utils/serializeLeafToHtml.es.js.map +1 -1
- package/dist/components/RichTextEditor/serializer/utils/serializeNodeToHtmlRecursive.d.ts +1 -2
- package/dist/components/RichTextEditor/serializer/utils/serializeNodeToHtmlRecursive.es.js +23 -19
- package/dist/components/RichTextEditor/serializer/utils/serializeNodeToHtmlRecursive.es.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts +2 -1
- package/dist/components/Tooltip/Tooltip.es.js +97 -92
- package/dist/components/Tooltip/Tooltip.es.js.map +1 -1
- package/dist/components/Tree/Node.d.ts +4 -2
- package/dist/components/Tree/Node.es.js +105 -99
- package/dist/components/Tree/Node.es.js.map +1 -1
- package/dist/components/Tree/Tree.d.ts +2 -0
- package/dist/components/Tree/Tree.es.js +39 -35
- package/dist/components/Tree/Tree.es.js.map +1 -1
- package/dist/components/index.d.ts +2 -0
- package/dist/index.cjs.js +4 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +3608 -3600
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +4 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/dnd/DndWrapper.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TextInput as c } from "../TextInput/TextInput.es.js";
|
|
2
|
-
import
|
|
2
|
+
import n from "../../foundation/Icon/Generated/IconCalendar.es.js";
|
|
3
3
|
import "../../foundation/Icon/Generated/IconAdobeCreativeCloud.es.js";
|
|
4
4
|
import "../../foundation/Icon/Generated/IconAdobeCreativeCloud12.es.js";
|
|
5
5
|
import "../../foundation/Icon/Generated/IconAdobeCreativeCloud16.es.js";
|
|
@@ -292,7 +292,7 @@ import "../../foundation/Icon/Generated/IconCardLayoutSmall16.es.js";
|
|
|
292
292
|
import "../../foundation/Icon/Generated/IconCardLayoutSmall20.es.js";
|
|
293
293
|
import "../../foundation/Icon/Generated/IconCardLayoutSmall24.es.js";
|
|
294
294
|
import "../../foundation/Icon/Generated/IconCardLayoutSmall32.es.js";
|
|
295
|
-
import
|
|
295
|
+
import l from "../../foundation/Icon/Generated/IconCaretDown.es.js";
|
|
296
296
|
import "../../foundation/Icon/Generated/IconCaretDown12.es.js";
|
|
297
297
|
import "../../foundation/Icon/Generated/IconCaretDown16.es.js";
|
|
298
298
|
import "../../foundation/Icon/Generated/IconCaretDown20.es.js";
|
|
@@ -1661,29 +1661,30 @@ import "../../foundation/Icon/Generated/IconWorkflowShapes24.es.js";
|
|
|
1661
1661
|
import "../../foundation/Icon/Generated/IconWorkflowShapes32.es.js";
|
|
1662
1662
|
import t, { forwardRef as f } from "react";
|
|
1663
1663
|
import "../../foundation/Icon/IconsMap.es.js";
|
|
1664
|
-
import { IconSize as
|
|
1665
|
-
import { merge as
|
|
1666
|
-
const
|
|
1667
|
-
onClick:
|
|
1664
|
+
import { IconSize as i } from "../../foundation/Icon/IconSize.es.js";
|
|
1665
|
+
import { merge as s } from "../../utilities/merge.es.js";
|
|
1666
|
+
const w = f(({ value: r, onClick: o, isClearable: m, placeHolder: p, isCalendarOpen: e }, a) => /* @__PURE__ */ t.createElement("div", {
|
|
1667
|
+
onClick: o,
|
|
1668
1668
|
ref: a,
|
|
1669
1669
|
"aria-hidden": "true"
|
|
1670
1670
|
}, /* @__PURE__ */ t.createElement("div", {
|
|
1671
|
-
className:
|
|
1672
|
-
"tw-absolute tw-top-2 tw-text-black-60 tw-
|
|
1673
|
-
r === "" ? "tw-right-4" : "tw-right-8"
|
|
1671
|
+
className: s([
|
|
1672
|
+
"tw-absolute tw-top-2 tw-text-black-60 tw-z-10",
|
|
1673
|
+
r === "" || !m ? "tw-right-4" : "tw-right-8"
|
|
1674
1674
|
])
|
|
1675
1675
|
}, e ? /* @__PURE__ */ t.createElement(d, {
|
|
1676
|
-
size:
|
|
1677
|
-
}) : /* @__PURE__ */ t.createElement(
|
|
1678
|
-
size:
|
|
1676
|
+
size: i.Size20
|
|
1677
|
+
}) : /* @__PURE__ */ t.createElement(l, {
|
|
1678
|
+
size: i.Size20
|
|
1679
1679
|
})), /* @__PURE__ */ t.createElement(c, {
|
|
1680
|
-
decorator: /* @__PURE__ */ t.createElement(
|
|
1680
|
+
decorator: /* @__PURE__ */ t.createElement(n, null),
|
|
1681
1681
|
placeholder: p,
|
|
1682
1682
|
value: r,
|
|
1683
|
-
clearable: m
|
|
1683
|
+
clearable: m,
|
|
1684
|
+
onEnterPressed: o
|
|
1684
1685
|
})));
|
|
1685
|
-
|
|
1686
|
+
w.displayName = "DatePickerTrigger";
|
|
1686
1687
|
export {
|
|
1687
|
-
|
|
1688
|
+
w as DatePickerTrigger
|
|
1688
1689
|
};
|
|
1689
1690
|
//# sourceMappingURL=DatePickerTrigger.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePickerTrigger.es.js","sources":["../../../src/components/DatePicker/DatePickerTrigger.tsx"],"sourcesContent":["import { TextInput } from '@components/TextInput';\nimport IconCalendar from '@foundation/Icon/Generated/IconCalendar';\nimport { IconCaretDown, IconCaretUp, IconSize } from '@foundation/Icon/index';\nimport { merge } from '@utilities/merge';\nimport React, { PropsWithChildren, forwardRef } from 'react';\n\ntype DatePickerTriggerProps = PropsWithChildren<{\n placeHolder?: string;\n value?: string;\n isClearable?: boolean;\n isCalendarOpen?: boolean;\n onClick?: () => void;\n}>;\n\nexport const DatePickerTrigger = forwardRef<HTMLDivElement, DatePickerTriggerProps>(\n ({ value, onClick, isClearable, placeHolder, isCalendarOpen }, ref) => (\n <div onClick={onClick} ref={ref} aria-hidden=\"true\">\n <div\n className={merge([\n 'tw-absolute tw-top-2 tw-text-black-60 tw-
|
|
1
|
+
{"version":3,"file":"DatePickerTrigger.es.js","sources":["../../../src/components/DatePicker/DatePickerTrigger.tsx"],"sourcesContent":["import { TextInput } from '@components/TextInput';\nimport IconCalendar from '@foundation/Icon/Generated/IconCalendar';\nimport { IconCaretDown, IconCaretUp, IconSize } from '@foundation/Icon/index';\nimport { merge } from '@utilities/merge';\nimport React, { PropsWithChildren, forwardRef } from 'react';\n\ntype DatePickerTriggerProps = PropsWithChildren<{\n placeHolder?: string;\n value?: string;\n isClearable?: boolean;\n isCalendarOpen?: boolean;\n onClick?: () => void;\n}>;\n\nexport const DatePickerTrigger = forwardRef<HTMLDivElement, DatePickerTriggerProps>(\n ({ value, onClick, isClearable, placeHolder, isCalendarOpen }, ref) => (\n <div onClick={onClick} ref={ref} aria-hidden=\"true\">\n <div\n className={merge([\n 'tw-absolute tw-top-2 tw-text-black-60 tw-z-10',\n value === '' || !isClearable ? 'tw-right-4' : 'tw-right-8',\n ])}\n >\n {isCalendarOpen ? <IconCaretUp size={IconSize.Size20} /> : <IconCaretDown size={IconSize.Size20} />}\n </div>\n <TextInput\n decorator={<IconCalendar />}\n placeholder={placeHolder}\n value={value}\n clearable={isClearable}\n onEnterPressed={onClick}\n />\n </div>\n ),\n);\n\nDatePickerTrigger.displayName = 'DatePickerTrigger';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAca,MAAA,IAAoB,EAC7B,CAAC,EAAE,UAAO,YAAS,gBAAa,gBAAa,qBAAkB,MAC1D,kBAAA,cAAA,OAAA;AAAA,EAAI;AAAA,EAAkB;AAAA,EAAU,eAAY;AAAA,GACxC,kBAAA,cAAA,OAAA;AAAA,EACG,WAAW,EAAM;AAAA,IACb;AAAA,IACA,MAAU,MAAM,CAAC,IAAc,eAAe;AAAA,EAAA,CACjD;AAAA,GAEA,IAAkB,kBAAA,cAAA,GAAA;AAAA,EAAY,MAAM,EAAS;AAAA,CAAQ,IAAM,kBAAA,cAAA,GAAA;AAAA,EAAc,MAAM,EAAS;AAAA,CAAQ,CACrG,GACC,kBAAA,cAAA,GAAA;AAAA,EACG,2CAAY,GAAa,IAAA;AAAA,EACzB,aAAa;AAAA,EACb;AAAA,EACA,WAAW;AAAA,EACX,gBAAgB;AAAA,CACpB,CACJ,CAER;AAEA,EAAkB,cAAc;"}
|
|
@@ -6,56 +6,56 @@ import { Trigger as I, TriggerSize as M } from "../Trigger/Trigger.es.js";
|
|
|
6
6
|
import { useMemoizedId as tt } from "../../hooks/useMemoizedId.es.js";
|
|
7
7
|
import { useButton as et } from "@react-aria/button";
|
|
8
8
|
import { useFocusRing as ot, FocusScope as rt } from "@react-aria/focus";
|
|
9
|
-
import { useOverlay as
|
|
10
|
-
import { useSelect as
|
|
9
|
+
import { useOverlay as st, DismissButton as L } from "@react-aria/overlays";
|
|
10
|
+
import { useSelect as nt, HiddenSelect as lt } from "@react-aria/select";
|
|
11
11
|
import { mergeProps as at } from "@react-aria/utils";
|
|
12
12
|
import { useSelectState as it } from "@react-stately/select";
|
|
13
13
|
import { merge as mt } from "../../utilities/merge.es.js";
|
|
14
|
-
import { AnimatePresence as pt, motion as
|
|
15
|
-
import e, { useRef as d, useEffect as
|
|
14
|
+
import { AnimatePresence as pt, motion as ut } from "framer-motion";
|
|
15
|
+
import e, { useRef as d, useEffect as ct } from "react";
|
|
16
16
|
import { useDropdownAutoHeight as ft, DEFAULT_DROPDOWN_MAX_HEIGHT as dt } from "./useDropdownAutoHeight.es.js";
|
|
17
17
|
import { Validation as F } from "../../utilities/validation.es.js";
|
|
18
18
|
import { LoadingCircle as wt, LoadingCircleSize as gt } from "../LoadingCircle/LoadingCircle.es.js";
|
|
19
19
|
import { createPortal as St } from "react-dom";
|
|
20
20
|
import { usePopper as ht } from "react-popper";
|
|
21
|
-
var
|
|
22
|
-
const xt = (t,
|
|
21
|
+
var bt = /* @__PURE__ */ ((t) => (t.Small = "Small", t.Large = "Large", t))(bt || {}), yt = /* @__PURE__ */ ((t) => (t.Start = "Start", t.End = "End", t))(yt || {}), Et = /* @__PURE__ */ ((t) => (t.Top = "Top", t.Bottom = "Bottom", t))(Et || {});
|
|
22
|
+
const xt = (t, n) => K(A(t)).has(n) ? null : t.map(({ menuItems: s }) => s).flat().find(({ id: s }) => s.toString() === (n == null ? void 0 : n.toString())) || null, Ut = ({
|
|
23
23
|
id: t,
|
|
24
|
-
menuBlocks:
|
|
24
|
+
menuBlocks: n,
|
|
25
25
|
onChange: w,
|
|
26
|
-
activeItemId:
|
|
26
|
+
activeItemId: s,
|
|
27
27
|
placeholder: B = "Select item",
|
|
28
28
|
size: p = "Small",
|
|
29
29
|
disabled: a = !1,
|
|
30
30
|
clearable: N = !1,
|
|
31
31
|
ariaLabel: R = "Dropdown",
|
|
32
|
-
decorator:
|
|
33
|
-
autoResize:
|
|
32
|
+
decorator: u,
|
|
33
|
+
autoResize: c = !0,
|
|
34
34
|
validation: g = F.Default,
|
|
35
35
|
alignment: H = "Start",
|
|
36
36
|
position: O = "Bottom"
|
|
37
37
|
}) => {
|
|
38
38
|
var D;
|
|
39
|
-
const
|
|
39
|
+
const o = s ? xt(n, s) : null, S = J(R, n), r = it({
|
|
40
40
|
...S,
|
|
41
|
-
defaultSelectedKey:
|
|
41
|
+
defaultSelectedKey: s,
|
|
42
42
|
onSelectionChange: (m) => w(m),
|
|
43
|
-
disabledKeys: K(A(
|
|
44
|
-
}), l = d(null), { triggerProps: z, valueProps: V, menuProps: _ } =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}, [
|
|
48
|
-
const { maxHeight:
|
|
49
|
-
|
|
50
|
-
const m =
|
|
51
|
-
m &&
|
|
52
|
-
} : void 0, x = !!
|
|
43
|
+
disabledKeys: K(A(n))
|
|
44
|
+
}), l = d(null), { triggerProps: z, valueProps: V, menuProps: _ } = nt({ ...S, isDisabled: a }, r, l), { buttonProps: h } = et({ ...z, isDisabled: a }, l), { isOpen: i } = r, { isFocusVisible: W, focusProps: $ } = ot(), b = d(null), { overlayProps: G } = st({ isOpen: i, onClose: () => r.close(), shouldCloseOnBlur: !0, isDismissable: !0 }, b);
|
|
45
|
+
ct(() => {
|
|
46
|
+
r.disabledKeys.has(s) || r.setSelectedKey(s);
|
|
47
|
+
}, [s, r]);
|
|
48
|
+
const { maxHeight: y } = ft(l, { isOpen: i, autoResize: c }), U = !c || y !== dt, X = o ? f.Active : f.Default, j = a ? f.Disabled : X, q = o ? Y[o.style || Z.Primary][j] : "tw-text-black-60", E = N ? () => {
|
|
49
|
+
r.setSelectedKey("");
|
|
50
|
+
const m = r.collection.getFirstKey();
|
|
51
|
+
m && r.selectionManager.setFocusedKey(m);
|
|
52
|
+
} : void 0, x = !!o && !!E, C = d(null), v = {
|
|
53
53
|
["Top-Start"]: "top-start",
|
|
54
54
|
["Top-End"]: "top-end",
|
|
55
55
|
["Bottom-Start"]: "bottom-start",
|
|
56
56
|
["Bottom-End"]: "bottom-end"
|
|
57
57
|
}, P = ht(l == null ? void 0 : l.current, C.current, {
|
|
58
|
-
placement:
|
|
58
|
+
placement: v[`${O}-${H}`],
|
|
59
59
|
strategy: "fixed",
|
|
60
60
|
modifiers: [
|
|
61
61
|
{
|
|
@@ -75,17 +75,17 @@ const xt = (t, s) => K(A(t)).has(s) ? null : t.map(({ menuItems: r }) => r).flat
|
|
|
75
75
|
}, /* @__PURE__ */ e.createElement(I, {
|
|
76
76
|
disabled: a,
|
|
77
77
|
buttonProps: h,
|
|
78
|
-
isFocusVisible: !a &&
|
|
78
|
+
isFocusVisible: !a && W,
|
|
79
79
|
isOpen: i,
|
|
80
80
|
size: p === "Large" ? M.Large : M.Small,
|
|
81
|
-
onClear:
|
|
81
|
+
onClear: E,
|
|
82
82
|
showClear: x,
|
|
83
83
|
validation: g
|
|
84
84
|
}, /* @__PURE__ */ e.createElement(lt, {
|
|
85
|
-
state:
|
|
85
|
+
state: r,
|
|
86
86
|
triggerRef: l
|
|
87
87
|
}), /* @__PURE__ */ e.createElement("button", {
|
|
88
|
-
...at(h,
|
|
88
|
+
...at(h, $),
|
|
89
89
|
id: tt(t),
|
|
90
90
|
ref: l,
|
|
91
91
|
"data-test-id": "dropdown-trigger",
|
|
@@ -93,14 +93,15 @@ const xt = (t, s) => K(A(t)).has(s) ? null : t.map(({ menuItems: r }) => r).flat
|
|
|
93
93
|
"tw-overflow-hidden tw-flex-auto tw-h-full tw-rounded tw-text-left tw-outline-none",
|
|
94
94
|
p === "Small" ? "tw-py-2 tw-pl-3 tw-min-h-[34px]" : "tw-pl-5 tw-py-4 tw-min-h-[60px]",
|
|
95
95
|
x ? "tw-pr-11" : "tw-pr-7",
|
|
96
|
-
|
|
96
|
+
q
|
|
97
97
|
])
|
|
98
98
|
}, /* @__PURE__ */ e.createElement(k, {
|
|
99
99
|
ariaProps: V,
|
|
100
|
-
title: (
|
|
101
|
-
decorator:
|
|
100
|
+
title: (o == null ? void 0 : o.title) || B,
|
|
101
|
+
decorator: u != null ? u : o == null ? void 0 : o.decorator,
|
|
102
|
+
subtitle: o == null ? void 0 : o.subtitle,
|
|
102
103
|
size: p === "Small" ? T.Small : T.Large
|
|
103
|
-
}))), St(/* @__PURE__ */ e.createElement(pt, null, !a && i &&
|
|
104
|
+
}))), St(/* @__PURE__ */ e.createElement(pt, null, !a && i && U && /* @__PURE__ */ e.createElement(ut.div, {
|
|
104
105
|
ref: C,
|
|
105
106
|
style: {
|
|
106
107
|
...P.styles.popper,
|
|
@@ -116,9 +117,9 @@ const xt = (t, s) => K(A(t)).has(s) ? null : t.map(({ menuItems: r }) => r).flat
|
|
|
116
117
|
}, /* @__PURE__ */ e.createElement(rt, {
|
|
117
118
|
restoreFocus: !0
|
|
118
119
|
}, /* @__PURE__ */ e.createElement("div", {
|
|
119
|
-
|
|
120
|
-
ref:
|
|
121
|
-
style:
|
|
120
|
+
...G,
|
|
121
|
+
ref: b,
|
|
122
|
+
style: c ? { maxHeight: y } : {},
|
|
122
123
|
className: "tw-flex tw-flex-col",
|
|
123
124
|
"data-test-id": "dropdown-menu",
|
|
124
125
|
role: "dialog"
|
|
@@ -126,8 +127,8 @@ const xt = (t, s) => K(A(t)).has(s) ? null : t.map(({ menuItems: r }) => r).flat
|
|
|
126
127
|
onDismiss: () => close()
|
|
127
128
|
}), /* @__PURE__ */ e.createElement(Q, {
|
|
128
129
|
ariaProps: _,
|
|
129
|
-
state:
|
|
130
|
-
menuBlocks:
|
|
130
|
+
state: r,
|
|
131
|
+
menuBlocks: n,
|
|
131
132
|
scrollable: !0
|
|
132
133
|
}), /* @__PURE__ */ e.createElement(L, {
|
|
133
134
|
onDismiss: () => close()
|
|
@@ -138,9 +139,9 @@ const xt = (t, s) => K(A(t)).has(s) ? null : t.map(({ menuItems: r }) => r).flat
|
|
|
138
139
|
})));
|
|
139
140
|
};
|
|
140
141
|
export {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
Ut as Dropdown,
|
|
143
|
+
yt as DropdownAlignment,
|
|
144
|
+
Et as DropdownPosition,
|
|
145
|
+
bt as DropdownSize
|
|
145
146
|
};
|
|
146
147
|
//# sourceMappingURL=Dropdown.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.es.js","sources":["../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { getDisabledItemIds, getMenuItems, mapToAriaProps } from '@components/ActionMenu/Aria/helper';\nimport { MenuBlock, MenuItemType, SelectMenu } from '@components/Dropdown/SelectMenu/SelectMenu';\nimport { MenuItemStyle, MenuItemTextColorState, menuItemTextColorRecord } from '@components/MenuItem';\nimport { MenuItemContent, MenuItemContentSize } from '@components/MenuItem/MenuItemContent';\nimport { Trigger, TriggerSize } from '@components/Trigger/Trigger';\nimport { useMemoizedId } from '@hooks/useMemoizedId';\nimport { useButton } from '@react-aria/button';\nimport { FocusScope, useFocusRing } from '@react-aria/focus';\nimport { DismissButton, useOverlay } from '@react-aria/overlays';\nimport { HiddenSelect, useSelect } from '@react-aria/select';\nimport { mergeProps } from '@react-aria/utils';\nimport { useSelectState } from '@react-stately/select';\nimport { merge } from '@utilities/merge';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport React, { FC, ReactElement, useEffect, useRef } from 'react';\nimport { DEFAULT_DROPDOWN_MAX_HEIGHT, useDropdownAutoHeight } from './useDropdownAutoHeight';\nimport { Validation } from '@utilities/validation';\nimport { LoadingCircle, LoadingCircleSize } from '@components/LoadingCircle';\nimport { createPortal } from 'react-dom';\nimport { usePopper } from 'react-popper';\nimport { VariationPlacement } from '@popperjs/core';\n\nexport enum DropdownSize {\n Small = 'Small',\n Large = 'Large',\n}\n\nexport enum DropdownAlignment {\n Start = 'Start',\n End = 'End',\n}\n\nexport enum DropdownPosition {\n Top = 'Top',\n Bottom = 'Bottom',\n}\n\nexport type DropdownProps = {\n id?: string;\n menuBlocks: MenuBlock[];\n onChange: (id?: string | number) => void;\n activeItemId?: string | number;\n placeholder?: string;\n size?: DropdownSize;\n disabled?: boolean;\n clearable?: boolean;\n ariaLabel?: string;\n decorator?: ReactElement;\n autoResize?: boolean;\n validation?: Validation;\n alignment?: DropdownAlignment;\n position?: DropdownPosition;\n};\n\nconst getActiveItem = (blocks: MenuBlock[], activeId: string | number): MenuItemType | null => {\n const disabledItems = getDisabledItemIds(getMenuItems(blocks));\n if (disabledItems.has(activeId)) {\n return null;\n }\n\n return (\n blocks\n .map(({ menuItems }) => menuItems)\n .flat()\n .find(({ id }) => id.toString() === activeId?.toString()) || null\n );\n};\n\nexport const Dropdown: FC<DropdownProps> = ({\n id: propId,\n menuBlocks,\n onChange,\n activeItemId,\n placeholder = 'Select item',\n size = DropdownSize.Small,\n disabled = false,\n clearable = false,\n ariaLabel = 'Dropdown',\n decorator,\n autoResize = true,\n validation = Validation.Default,\n alignment = DropdownAlignment.Start,\n position = DropdownPosition.Bottom,\n}) => {\n const activeItem = !!activeItemId ? getActiveItem(menuBlocks, activeItemId) : null;\n const props = mapToAriaProps(ariaLabel, menuBlocks);\n const state = useSelectState({\n ...props,\n defaultSelectedKey: activeItemId,\n onSelectionChange: (key) => onChange(key),\n disabledKeys: getDisabledItemIds(getMenuItems(menuBlocks)),\n });\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n\n const { triggerProps, valueProps, menuProps } = useSelect({ ...props, isDisabled: disabled }, state, triggerRef);\n\n const { buttonProps } = useButton({ ...triggerProps, isDisabled: disabled }, triggerRef);\n const { isOpen } = state;\n const { isFocusVisible, focusProps } = useFocusRing();\n const overlayRef = useRef<HTMLDivElement | null>(null);\n const { overlayProps } = useOverlay(\n { isOpen, onClose: () => state.close(), shouldCloseOnBlur: true, isDismissable: true },\n overlayRef,\n );\n\n useEffect(() => {\n if (state.disabledKeys.has(activeItemId as string)) {\n return;\n }\n\n state.setSelectedKey(activeItemId as string);\n }, [activeItemId, state]);\n\n const { maxHeight } = useDropdownAutoHeight(triggerRef, { isOpen, autoResize });\n\n const heightIsReady = !autoResize || maxHeight !== DEFAULT_DROPDOWN_MAX_HEIGHT;\n\n const enabledTextColorState = activeItem ? MenuItemTextColorState.Active : MenuItemTextColorState.Default;\n const textState = disabled ? MenuItemTextColorState.Disabled : enabledTextColorState;\n\n const textColorClass = activeItem\n ? menuItemTextColorRecord[activeItem.style || MenuItemStyle.Primary][textState]\n : 'tw-text-black-60';\n\n const onClear = clearable\n ? () => {\n state.setSelectedKey('');\n const first = state.collection.getFirstKey();\n if (first) {\n state.selectionManager.setFocusedKey(first);\n }\n }\n : undefined;\n\n const showClear = !!activeItem && !!onClear;\n const dropdownRef = useRef<HTMLDivElement | null>(null);\n\n const placementMap: Record<string, VariationPlacement> = {\n ['Top-Start']: 'top-start',\n ['Top-End']: 'top-end',\n ['Bottom-Start']: 'bottom-start',\n ['Bottom-End']: 'bottom-end',\n };\n const popperInstance = usePopper(triggerRef?.current, dropdownRef.current, {\n placement: placementMap[`${position}-${alignment}`],\n strategy: 'fixed',\n modifiers: [\n {\n name: 'offset',\n options: {\n offset: [0, 8],\n },\n },\n {\n name: 'flip',\n enabled: false,\n },\n ],\n });\n\n return (\n <div className=\"tw-relative tw-w-full tw-font-sans tw-text-s\">\n <Trigger\n disabled={disabled}\n buttonProps={buttonProps}\n isFocusVisible={!disabled && isFocusVisible}\n isOpen={isOpen}\n size={size === DropdownSize.Large ? TriggerSize.Large : TriggerSize.Small}\n onClear={onClear}\n showClear={showClear}\n validation={validation}\n >\n <HiddenSelect state={state} triggerRef={triggerRef} />\n <button\n {...mergeProps(buttonProps, focusProps)}\n id={useMemoizedId(propId)}\n ref={triggerRef}\n data-test-id=\"dropdown-trigger\"\n className={merge([\n 'tw-overflow-hidden tw-flex-auto tw-h-full tw-rounded tw-text-left tw-outline-none',\n size === DropdownSize.Small\n ? 'tw-py-2 tw-pl-3 tw-min-h-[34px]'\n : 'tw-pl-5 tw-py-4 tw-min-h-[60px]',\n showClear ? 'tw-pr-11' : 'tw-pr-7',\n textColorClass,\n ])}\n >\n <MenuItemContent\n ariaProps={valueProps}\n title={activeItem?.title || placeholder}\n decorator={decorator ?? activeItem?.decorator}\n size={size === DropdownSize.Small ? MenuItemContentSize.Small : MenuItemContentSize.Large}\n />\n </button>\n </Trigger>\n {createPortal(\n <AnimatePresence>\n {!disabled && isOpen && heightIsReady && (\n <motion.div\n ref={dropdownRef}\n style={{\n ...popperInstance.styles.popper,\n width: triggerRef.current?.getBoundingClientRect().width,\n minWidth: 'fit-content',\n }}\n {...popperInstance.attributes.popper}\n className=\"tw-absolute tw-p-0 tw-shadow-mid tw-list-none tw-m-0 tw-z-[120000] tw-min-w-full tw-overflow-hidden\"\n key=\"content\"\n initial={{ height: 0 }}\n animate={{ height: 'auto' }}\n transition={{ ease: [0.04, 0.62, 0.23, 0.98], duration: 0.5 }}\n >\n <FocusScope restoreFocus>\n <div\n {...overlayProps}\n ref={overlayRef}\n style={autoResize ? { maxHeight } : {}}\n className=\"tw-flex tw-flex-col\"\n data-test-id=\"dropdown-menu\"\n role=\"dialog\"\n >\n <DismissButton onDismiss={() => close()} />\n <SelectMenu\n ariaProps={menuProps}\n state={state}\n menuBlocks={menuBlocks}\n scrollable\n />\n <DismissButton onDismiss={() => close()} />\n </div>\n </FocusScope>\n </motion.div>\n )}\n </AnimatePresence>,\n document.body,\n )}\n {validation === Validation.Loading && (\n <span className=\"tw-absolute tw-top-[-0.55rem] tw-right-[-0.55rem] tw-bg-white tw-rounded-full tw-p-[2px] tw-border tw-border-black-10\">\n <LoadingCircle size={LoadingCircleSize.ExtraSmall} />\n </span>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAwBY,IAAA,uBAAA,MACA,GA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,MAAK;AAAA,EAAA,GAEJ,kBAAA,cAAA,GAAA;AAAA,IAAc,WAAW,MAAM,MAAM;AAAA,EAAA,CAAG,GACxC,kBAAA,cAAA,GAAA;AAAA,IACG,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA,YAAU;AAAA,EAAA,CACd,GACC,kBAAA,cAAA,GAAA;AAAA,IAAc,WAAW,MAAM,MAAM;AAAA,EAAG,CAAA,CAC7C,CACJ,CACJ,CAER,GACA,SAAS,IACb,GACC,MAAe,EAAW,WACtB,kBAAA,cAAA,QAAA;AAAA,IAAK,WAAU;AAAA,EAAA,GACX,kBAAA,cAAA,IAAA;AAAA,IAAc,MAAM,GAAkB;AAAA,EAAY,CAAA,CACvD,CAER;AAER;"}
|
|
1
|
+
{"version":3,"file":"Dropdown.es.js","sources":["../../../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { getDisabledItemIds, getMenuItems, mapToAriaProps } from '@components/ActionMenu/Aria/helper';\nimport { MenuBlock, MenuItemType, SelectMenu } from '@components/Dropdown/SelectMenu/SelectMenu';\nimport { MenuItemStyle, MenuItemTextColorState, menuItemTextColorRecord } from '@components/MenuItem';\nimport { MenuItemContent, MenuItemContentSize } from '@components/MenuItem/MenuItemContent';\nimport { Trigger, TriggerSize } from '@components/Trigger/Trigger';\nimport { useMemoizedId } from '@hooks/useMemoizedId';\nimport { useButton } from '@react-aria/button';\nimport { FocusScope, useFocusRing } from '@react-aria/focus';\nimport { DismissButton, useOverlay } from '@react-aria/overlays';\nimport { HiddenSelect, useSelect } from '@react-aria/select';\nimport { mergeProps } from '@react-aria/utils';\nimport { useSelectState } from '@react-stately/select';\nimport { merge } from '@utilities/merge';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport React, { FC, ReactElement, useEffect, useRef } from 'react';\nimport { DEFAULT_DROPDOWN_MAX_HEIGHT, useDropdownAutoHeight } from './useDropdownAutoHeight';\nimport { Validation } from '@utilities/validation';\nimport { LoadingCircle, LoadingCircleSize } from '@components/LoadingCircle';\nimport { createPortal } from 'react-dom';\nimport { usePopper } from 'react-popper';\nimport { VariationPlacement } from '@popperjs/core';\n\nexport enum DropdownSize {\n Small = 'Small',\n Large = 'Large',\n}\n\nexport enum DropdownAlignment {\n Start = 'Start',\n End = 'End',\n}\n\nexport enum DropdownPosition {\n Top = 'Top',\n Bottom = 'Bottom',\n}\n\nexport type DropdownProps = {\n id?: string;\n menuBlocks: MenuBlock[];\n onChange: (id?: string | number) => void;\n activeItemId?: string | number;\n placeholder?: string;\n size?: DropdownSize;\n disabled?: boolean;\n clearable?: boolean;\n ariaLabel?: string;\n decorator?: ReactElement;\n autoResize?: boolean;\n validation?: Validation;\n alignment?: DropdownAlignment;\n position?: DropdownPosition;\n};\n\nconst getActiveItem = (blocks: MenuBlock[], activeId: string | number): MenuItemType | null => {\n const disabledItems = getDisabledItemIds(getMenuItems(blocks));\n if (disabledItems.has(activeId)) {\n return null;\n }\n\n return (\n blocks\n .map(({ menuItems }) => menuItems)\n .flat()\n .find(({ id }) => id.toString() === activeId?.toString()) || null\n );\n};\n\nexport const Dropdown: FC<DropdownProps> = ({\n id: propId,\n menuBlocks,\n onChange,\n activeItemId,\n placeholder = 'Select item',\n size = DropdownSize.Small,\n disabled = false,\n clearable = false,\n ariaLabel = 'Dropdown',\n decorator,\n autoResize = true,\n validation = Validation.Default,\n alignment = DropdownAlignment.Start,\n position = DropdownPosition.Bottom,\n}) => {\n const activeItem = !!activeItemId ? getActiveItem(menuBlocks, activeItemId) : null;\n const props = mapToAriaProps(ariaLabel, menuBlocks);\n const state = useSelectState({\n ...props,\n defaultSelectedKey: activeItemId,\n onSelectionChange: (key) => onChange(key),\n disabledKeys: getDisabledItemIds(getMenuItems(menuBlocks)),\n });\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n\n const { triggerProps, valueProps, menuProps } = useSelect({ ...props, isDisabled: disabled }, state, triggerRef);\n\n const { buttonProps } = useButton({ ...triggerProps, isDisabled: disabled }, triggerRef);\n const { isOpen } = state;\n const { isFocusVisible, focusProps } = useFocusRing();\n const overlayRef = useRef<HTMLDivElement | null>(null);\n const { overlayProps } = useOverlay(\n { isOpen, onClose: () => state.close(), shouldCloseOnBlur: true, isDismissable: true },\n overlayRef,\n );\n\n useEffect(() => {\n if (state.disabledKeys.has(activeItemId as string)) {\n return;\n }\n\n state.setSelectedKey(activeItemId as string);\n }, [activeItemId, state]);\n\n const { maxHeight } = useDropdownAutoHeight(triggerRef, { isOpen, autoResize });\n\n const heightIsReady = !autoResize || maxHeight !== DEFAULT_DROPDOWN_MAX_HEIGHT;\n\n const enabledTextColorState = activeItem ? MenuItemTextColorState.Active : MenuItemTextColorState.Default;\n const textState = disabled ? MenuItemTextColorState.Disabled : enabledTextColorState;\n\n const textColorClass = activeItem\n ? menuItemTextColorRecord[activeItem.style || MenuItemStyle.Primary][textState]\n : 'tw-text-black-60';\n\n const onClear = clearable\n ? () => {\n state.setSelectedKey('');\n const first = state.collection.getFirstKey();\n if (first) {\n state.selectionManager.setFocusedKey(first);\n }\n }\n : undefined;\n\n const showClear = !!activeItem && !!onClear;\n const dropdownRef = useRef<HTMLDivElement | null>(null);\n\n const placementMap: Record<string, VariationPlacement> = {\n ['Top-Start']: 'top-start',\n ['Top-End']: 'top-end',\n ['Bottom-Start']: 'bottom-start',\n ['Bottom-End']: 'bottom-end',\n };\n const popperInstance = usePopper(triggerRef?.current, dropdownRef.current, {\n placement: placementMap[`${position}-${alignment}`],\n strategy: 'fixed',\n modifiers: [\n {\n name: 'offset',\n options: {\n offset: [0, 8],\n },\n },\n {\n name: 'flip',\n enabled: false,\n },\n ],\n });\n\n return (\n <div className=\"tw-relative tw-w-full tw-font-sans tw-text-s\">\n <Trigger\n disabled={disabled}\n buttonProps={buttonProps}\n isFocusVisible={!disabled && isFocusVisible}\n isOpen={isOpen}\n size={size === DropdownSize.Large ? TriggerSize.Large : TriggerSize.Small}\n onClear={onClear}\n showClear={showClear}\n validation={validation}\n >\n <HiddenSelect state={state} triggerRef={triggerRef} />\n <button\n {...mergeProps(buttonProps, focusProps)}\n id={useMemoizedId(propId)}\n ref={triggerRef}\n data-test-id=\"dropdown-trigger\"\n className={merge([\n 'tw-overflow-hidden tw-flex-auto tw-h-full tw-rounded tw-text-left tw-outline-none',\n size === DropdownSize.Small\n ? 'tw-py-2 tw-pl-3 tw-min-h-[34px]'\n : 'tw-pl-5 tw-py-4 tw-min-h-[60px]',\n showClear ? 'tw-pr-11' : 'tw-pr-7',\n textColorClass,\n ])}\n >\n <MenuItemContent\n ariaProps={valueProps}\n title={activeItem?.title || placeholder}\n decorator={decorator ?? activeItem?.decorator}\n subtitle={activeItem?.subtitle}\n size={size === DropdownSize.Small ? MenuItemContentSize.Small : MenuItemContentSize.Large}\n />\n </button>\n </Trigger>\n {createPortal(\n <AnimatePresence>\n {!disabled && isOpen && heightIsReady && (\n <motion.div\n ref={dropdownRef}\n style={{\n ...popperInstance.styles.popper,\n width: triggerRef.current?.getBoundingClientRect().width,\n minWidth: 'fit-content',\n }}\n {...popperInstance.attributes.popper}\n className=\"tw-absolute tw-p-0 tw-shadow-mid tw-list-none tw-m-0 tw-z-[120000] tw-min-w-full tw-overflow-hidden\"\n key=\"content\"\n initial={{ height: 0 }}\n animate={{ height: 'auto' }}\n transition={{ ease: [0.04, 0.62, 0.23, 0.98], duration: 0.5 }}\n >\n <FocusScope restoreFocus>\n <div\n {...overlayProps}\n ref={overlayRef}\n style={autoResize ? { maxHeight } : {}}\n className=\"tw-flex tw-flex-col\"\n data-test-id=\"dropdown-menu\"\n role=\"dialog\"\n >\n <DismissButton onDismiss={() => close()} />\n <SelectMenu\n ariaProps={menuProps}\n state={state}\n menuBlocks={menuBlocks}\n scrollable\n />\n <DismissButton onDismiss={() => close()} />\n </div>\n </FocusScope>\n </motion.div>\n )}\n </AnimatePresence>,\n document.body,\n )}\n {validation === Validation.Loading && (\n <span className=\"tw-absolute tw-top-[-0.55rem] tw-right-[-0.55rem] tw-bg-white tw-rounded-full tw-p-[2px] tw-border tw-border-black-10\">\n <LoadingCircle size={LoadingCircleSize.ExtraSmall} />\n </span>\n )}\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAwBY,IAAA,uBAAA,MACA,GAAA,QAAA,SACA,EAAA,QAAA,SAFA,IAAA,MAAA,CAAA,CAAA,GAKA,uBAAA,MACA,GAAA,QAAA,SACF,EAAA,MAAA,OAFE,IAAA,MAAA,CAAA,CAAA,GAKA,uBAAA,MACF,GAAA,MAAA,OACG,EAAA,SAAA,UAFD,IAAA,MAAA,CAAA,CAAA;AAsBZ,MAAM,KAAgB,CAAC,GAAqB,MAEpC,AADkB,EAAmB,EAAa,CAAM,CAAC,EAC3C,IAAI,CAAQ,IACnB,OAIP,EACK,IAAI,CAAC,EAAE,mBAAgB,CAAS,EAChC,OACA,KAAK,CAAC,EAAE,YAAS,EAAG,SAAA,MAAe,wBAAU,WAAU,KAAK,MAI5D,KAA8B,CAAC;AAAA,EACxC,IAAI;AAAA,EACJ;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAc;AAAA,EACd,UAAO;AAAA,EACP,cAAW;AAAA,EACX,eAAY;AAAA,EACZ,eAAY;AAAA,EACZ;AAAA,EACA,gBAAa;AAAA,EACb,gBAAa,EAAW;AAAA,EACxB,eAAY;AAAA,EACZ,cAAW;AAAA,MACT;;AACF,QAAM,IAAa,AAAE,IAAe,GAAc,GAAY,CAAY,IAAI,MACxE,IAAQ,EAAe,GAAW,CAAU,GAC5C,IAAQ,GAAe;AAAA,IACzB,GAAG;AAAA,IACH,oBAAoB;AAAA,IACpB,mBAAmB,CAAC,MAAQ,EAAS,CAAG;AAAA,IACxC,cAAc,EAAmB,EAAa,CAAU,CAAC;AAAA,EAAA,CAC5D,GACK,IAAa,EAAiC,IAAI,GAElD,EAAE,iBAAc,eAAY,iBAAc,GAAU,EAAE,GAAG,GAAO,YAAY,EAAA,GAAY,GAAO,CAAU,GAE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3D,kBAAA,cAAA,IAAA;AAAA,IAAW,cAAY;AAAA,EAAA,GACnB,kBAAA,cAAA,OAAA;AAAA,IACI,GAAG;AAAA,IACJ,KAAK;AAAA,IACL,OAAO,IAAa,EAAE,aAAA,IAAc,CAAC;AAAA,IACrC,WAAU;AAAA,IACV,gBAAa;AAAA,IACb,MAAK;AAAA,EAAA,GAEJ,kBAAA,cAAA,GAAA;AAAA,IAAc,WAAW,MAAM,MAAM;AAAA,EAAA,CAAG,GACxC,kBAAA,cAAA,GAAA;AAAA,IACG,WAAW;AAAA,IACX;AAAA,IACA;AAAA,IACA,YAAU;AAAA,EAAA,CACd,GACC,kBAAA,cAAA,GAAA;AAAA,IAAc,WAAW,MAAM,MAAM;AAAA,EAAG,CAAA,CAC7C,CACJ,CACJ,CAER,GACA,SAAS,IACb,GACC,MAAe,EAAW,WACtB,kBAAA,cAAA,QAAA;AAAA,IAAK,WAAU;AAAA,EAAA,GACX,kBAAA,cAAA,IAAA;AAAA,IAAc,MAAM,GAAkB;AAAA,EAAY,CAAA,CACvD,CAER;AAER;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare enum LoadingBarSize {
|
|
3
|
+
Small = "Small",
|
|
4
|
+
Medium = "Medium",
|
|
5
|
+
Large = "Large",
|
|
6
|
+
XLarge = "XLarge"
|
|
7
|
+
}
|
|
8
|
+
export declare enum LoadingBarState {
|
|
9
|
+
'Progress' = "Progress",
|
|
10
|
+
'Success' = "Success",
|
|
11
|
+
'Error' = "Error"
|
|
12
|
+
}
|
|
13
|
+
export declare type LoadingBarProps = {
|
|
14
|
+
percentage?: number;
|
|
15
|
+
size?: LoadingBarSize;
|
|
16
|
+
state?: LoadingBarState;
|
|
17
|
+
rounded?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare const loadingBarSizeClasses: Record<LoadingBarSize, string>;
|
|
20
|
+
export declare const loadingBarStateClasses: Record<LoadingBarState, {
|
|
21
|
+
outer: string;
|
|
22
|
+
inner: string;
|
|
23
|
+
}>;
|
|
24
|
+
export declare const LoadingBar: ({ percentage, size, state, rounded, }: LoadingBarProps) => JSX.Element;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import r from "react";
|
|
2
|
+
import { merge as s } from "../../utilities/merge.es.js";
|
|
3
|
+
var l = /* @__PURE__ */ ((e) => (e.Small = "Small", e.Medium = "Medium", e.Large = "Large", e.XLarge = "XLarge", e))(l || {}), n = /* @__PURE__ */ ((e) => (e.Progress = "Progress", e.Success = "Success", e.Error = "Error", e))(n || {});
|
|
4
|
+
const w = {
|
|
5
|
+
Small: "tw-h-1",
|
|
6
|
+
Medium: "tw-h-2",
|
|
7
|
+
Large: "tw-h-3",
|
|
8
|
+
XLarge: "tw-h-4"
|
|
9
|
+
}, o = {
|
|
10
|
+
Error: {
|
|
11
|
+
outer: "tw-bg-box-negative",
|
|
12
|
+
inner: "tw-bg-text-negative"
|
|
13
|
+
},
|
|
14
|
+
Success: {
|
|
15
|
+
outer: "tw-bg-box-positive",
|
|
16
|
+
inner: "tw-bg-text-positive"
|
|
17
|
+
},
|
|
18
|
+
Progress: {
|
|
19
|
+
outer: "tw-bg-box-selected",
|
|
20
|
+
inner: "tw-bg-text-interactive"
|
|
21
|
+
}
|
|
22
|
+
}, d = ({
|
|
23
|
+
percentage: e = 0,
|
|
24
|
+
size: a = "Medium",
|
|
25
|
+
state: t = "Progress",
|
|
26
|
+
rounded: i = !1
|
|
27
|
+
}) => /* @__PURE__ */ r.createElement("div", {
|
|
28
|
+
className: s([
|
|
29
|
+
"tw-overflow-hidden tw-w-full tw-relative",
|
|
30
|
+
w[a],
|
|
31
|
+
i && "tw-rounded",
|
|
32
|
+
o[t].outer
|
|
33
|
+
]),
|
|
34
|
+
"data-test-id": "loading-bar-outer"
|
|
35
|
+
}, /* @__PURE__ */ r.createElement("div", {
|
|
36
|
+
className: s([
|
|
37
|
+
"tw-left-0 tw-top-0 tw-h-full tw-absolute tw-transition-width",
|
|
38
|
+
o[t].inner
|
|
39
|
+
]),
|
|
40
|
+
style: { width: `${e}%` },
|
|
41
|
+
"data-test-id": "loading-bar-inner"
|
|
42
|
+
}));
|
|
43
|
+
export {
|
|
44
|
+
d as LoadingBar,
|
|
45
|
+
l as LoadingBarSize,
|
|
46
|
+
n as LoadingBarState,
|
|
47
|
+
w as loadingBarSizeClasses,
|
|
48
|
+
o as loadingBarStateClasses
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=LoadingBar.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoadingBar.es.js","sources":["../../../src/components/LoadingBar/LoadingBar.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React from 'react';\nimport { merge } from '@utilities/merge';\n\nexport enum LoadingBarSize {\n Small = 'Small',\n Medium = 'Medium',\n Large = 'Large',\n XLarge = 'XLarge',\n}\n\nexport enum LoadingBarState {\n 'Progress' = 'Progress',\n 'Success' = 'Success',\n 'Error' = 'Error',\n}\n\nexport type LoadingBarProps = {\n percentage?: number;\n size?: LoadingBarSize;\n state?: LoadingBarState;\n rounded?: boolean;\n};\n\nexport const loadingBarSizeClasses: Record<LoadingBarSize, string> = {\n [LoadingBarSize.Small]: 'tw-h-1',\n [LoadingBarSize.Medium]: 'tw-h-2',\n [LoadingBarSize.Large]: 'tw-h-3',\n [LoadingBarSize.XLarge]: 'tw-h-4',\n};\n\nexport const loadingBarStateClasses: Record<LoadingBarState, { outer: string; inner: string }> = {\n [LoadingBarState.Error]: {\n outer: 'tw-bg-box-negative',\n inner: 'tw-bg-text-negative',\n },\n [LoadingBarState.Success]: {\n outer: 'tw-bg-box-positive',\n inner: 'tw-bg-text-positive',\n },\n [LoadingBarState.Progress]: {\n outer: 'tw-bg-box-selected',\n inner: 'tw-bg-text-interactive',\n },\n};\n\nexport const LoadingBar = ({\n percentage = 0,\n size = LoadingBarSize.Medium,\n state = LoadingBarState.Progress,\n rounded = false,\n}: LoadingBarProps) => (\n <div\n className={merge([\n 'tw-overflow-hidden tw-w-full tw-relative',\n loadingBarSizeClasses[size],\n rounded && 'tw-rounded',\n loadingBarStateClasses[state].outer,\n ])}\n data-test-id=\"loading-bar-outer\"\n >\n <div\n className={merge([\n 'tw-left-0 tw-top-0 tw-h-full tw-absolute tw-transition-width',\n loadingBarStateClasses[state].inner,\n ])}\n style={{ width: `${percentage}%` }}\n data-test-id=\"loading-bar-inner\"\n />\n </div>\n);\n"],"names":[],"mappings":";;AAKY,IAAA,sBAAA,MACA,GAAA,QAAA,SACC,EAAA,SAAA,UACD,EAAA,QAAA,SACC,EAAA,SAAA,UAJD,IAAA,KAAA,CAAA,CAAA,GAOA,sBAAA,MACK,GAAA,WAAA,YACD,EAAA,UAAA,WACF,EAAA,QAAA,SAHF,IAAA,KAAA,CAAA,CAAA;AAaL,MAAM,IAAwD;AAAA,EACjE,AAAC,OAAuB;AAAA,EACxB,AAAC,QAAwB;AAAA,EACzB,AAAC,OAAuB;AAAA,EACxB,AAAC,QAAwB;AAC7B,GAEa,IAAoF;AAAA,EAC7F,AAAC,OAAwB;AAAA,IACrB,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACA,AAAC,SAA0B;AAAA,IACvB,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AAAA,EACA,AAAC,UAA2B;AAAA,IACxB,OAAO;AAAA,IACP,OAAO;AAAA,EACX;AACJ,GAEa,IAAa,CAAC;AAAA,EACvB,gBAAa;AAAA,EACb,UAAO;AAAA,EACP,WAAQ;AAAA,EACR,aAAU;AAAA,MAET,kBAAA,cAAA,OAAA;AAAA,EACG,WAAW,EAAM;AAAA,IACb;AAAA,IACA,EAAsB;AAAA,IACtB,KAAW;AAAA,IACX,EAAuB,GAAO;AAAA,EAAA,CACjC;AAAA,EACD,gBAAa;AAAA,GAEZ,kBAAA,cAAA,OAAA;AAAA,EACG,WAAW,EAAM;AAAA,IACb;AAAA,IACA,EAAuB,GAAO;AAAA,EAAA,CACjC;AAAA,EACD,OAAO,EAAE,OAAO,GAAG,KAAc;AAAA,EACjC,gBAAa;AAAA,CACjB,CACJ;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LoadingBar';
|