@frontify/fondue 9.11.0 → 9.12.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/dist/components/ActionMenu/Aria/AriaMenuItem.es.js +23 -21
- package/dist/components/ActionMenu/Aria/AriaMenuItem.es.js.map +1 -1
- package/dist/components/Dropdown/Dropdown.es.js +20 -19
- package/dist/components/Dropdown/Dropdown.es.js.map +1 -1
- package/dist/components/Switch/Switch.es.js +4 -4
- package/dist/components/Switch/Switch.es.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.es.js +18 -17
- package/dist/components/Tooltip/Tooltip.es.js.map +1 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { MenuItem as
|
|
2
|
-
import { Switch as
|
|
3
|
-
import { useFocusRing as
|
|
4
|
-
import { useMenuItem as
|
|
5
|
-
import { mergeProps as
|
|
1
|
+
import { MenuItem as k } from "../../MenuItem/MenuItem.es.js";
|
|
2
|
+
import { Switch as v, SwitchSize as E } from "../../Switch/Switch.es.js";
|
|
3
|
+
import { useFocusRing as V } from "@react-aria/focus";
|
|
4
|
+
import { useMenuItem as A } from "@react-aria/menu";
|
|
5
|
+
import { mergeProps as P } from "@react-aria/utils";
|
|
6
6
|
import { FOCUS_STYLE_INSET as z } from "../../../utilities/focusStyle.es.js";
|
|
7
7
|
import { merge as F } from "../../../utilities/merge.es.js";
|
|
8
|
-
import
|
|
9
|
-
const
|
|
10
|
-
const [o, i] =
|
|
8
|
+
import n, { useRef as R, useState as x } from "react";
|
|
9
|
+
const N = (t) => typeof t.onClick < "u" && typeof t.type > "u", a = (t) => typeof t.onClick < "u" && t.type === "switch", T = (t) => {
|
|
10
|
+
const [o, i] = x(t), s = () => i(!o);
|
|
11
11
|
return {
|
|
12
|
-
switchComponent: /* @__PURE__ */
|
|
13
|
-
size:
|
|
12
|
+
switchComponent: /* @__PURE__ */ n.createElement(v, {
|
|
13
|
+
size: E.Small,
|
|
14
14
|
on: o
|
|
15
15
|
}),
|
|
16
16
|
switchValue: o,
|
|
17
17
|
toggleSwitch: s
|
|
18
18
|
};
|
|
19
|
-
},
|
|
20
|
-
const l =
|
|
19
|
+
}, q = ({ menuItem: t, node: o, state: i, isSelected: s, onClick: e }) => {
|
|
20
|
+
const l = R(null), {
|
|
21
21
|
switchComponent: p = void 0,
|
|
22
22
|
switchValue: f = null,
|
|
23
|
-
toggleSwitch:
|
|
24
|
-
} = a(t) ?
|
|
23
|
+
toggleSwitch: c = null
|
|
24
|
+
} = a(t) ? T(t.initialValue) : {}, { menuItemProps: w } = A({
|
|
25
25
|
...o,
|
|
26
26
|
onAction: () => {
|
|
27
|
-
|
|
27
|
+
N(t) && t.onClick(), a(t) && (c == null || c(), t.onClick(Boolean(!f)));
|
|
28
28
|
},
|
|
29
29
|
isDisabled: (t == null ? void 0 : t.disabled) || !1,
|
|
30
30
|
"aria-label": typeof (t == null ? void 0 : t.title) == "string" ? t == null ? void 0 : t.title : "Menu item"
|
|
31
|
-
}, i, l), { title: d, decorator: h, subtitle: S, size: b, style: C, disabled: r, selectionIndicator: u } = t, { isFocusVisible: y, focusProps:
|
|
32
|
-
return /* @__PURE__ */
|
|
33
|
-
...
|
|
31
|
+
}, i, l), { title: d, decorator: h, subtitle: S, size: b, style: C, disabled: r, selectionIndicator: u } = t, { isFocusVisible: y, focusProps: g } = V();
|
|
32
|
+
return /* @__PURE__ */ n.createElement("li", {
|
|
33
|
+
...P(w, g),
|
|
34
34
|
"data-test-id": "menu-item",
|
|
35
35
|
className: F([
|
|
36
36
|
"tw-relative hover:tw-bg-black-0 tw-list-none tw-outline-none",
|
|
@@ -38,8 +38,10 @@ const x = (t) => typeof t.onClick < "u" && typeof t.type > "u", a = (t) => typeo
|
|
|
38
38
|
y && z
|
|
39
39
|
]),
|
|
40
40
|
ref: l,
|
|
41
|
-
onClick:
|
|
42
|
-
|
|
41
|
+
onClick: (M) => {
|
|
42
|
+
M.stopPropagation(), e && e();
|
|
43
|
+
}
|
|
44
|
+
}, /* @__PURE__ */ n.createElement(k, {
|
|
43
45
|
title: d,
|
|
44
46
|
decorator: h,
|
|
45
47
|
subtitle: S,
|
|
@@ -52,6 +54,6 @@ const x = (t) => typeof t.onClick < "u" && typeof t.type > "u", a = (t) => typeo
|
|
|
52
54
|
}));
|
|
53
55
|
};
|
|
54
56
|
export {
|
|
55
|
-
|
|
57
|
+
q as AriaMenuItem
|
|
56
58
|
};
|
|
57
59
|
//# sourceMappingURL=AriaMenuItem.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AriaMenuItem.es.js","sources":["../../../../src/components/ActionMenu/Aria/AriaMenuItem.tsx"],"sourcesContent":["import { MenuItem } from '@components/MenuItem/MenuItem';\nimport { Switch, SwitchSize } from '@components/Switch';\nimport { useFocusRing } from '@react-aria/focus';\nimport { useMenuItem } from '@react-aria/menu';\nimport { mergeProps } from '@react-aria/utils';\nimport { TreeState } from '@react-stately/tree';\nimport { Node } from '@react-types/shared';\nimport { FOCUS_STYLE_INSET } from '@utilities/focusStyle';\nimport { merge } from '@utilities/merge';\nimport React, { FC, useRef, useState } from 'react';\nimport { MenuItemType } from '../../Dropdown/SelectMenu/SelectMenu';\nimport { ActionMenuItemType, ActionMenuSwitchItemType } from '../ActionMenu/ActionMenu';\n\nexport type AriaOptionProps = {\n menuItem: MenuItemType | ActionMenuItemType | ActionMenuSwitchItemType;\n node: Node<object>;\n isSelected?: boolean;\n state: TreeState<object>;\n onClick?: () => void;\n};\n\nconst isActionMenuItem = (\n menuItem: MenuItemType | ActionMenuItemType | ActionMenuSwitchItemType,\n): menuItem is ActionMenuItemType =>\n typeof (menuItem as ActionMenuItemType).onClick !== 'undefined' && typeof menuItem.type === 'undefined';\nconst isActionMenuSwitchItem = (\n menuItem: MenuItemType | ActionMenuItemType | ActionMenuSwitchItemType,\n): menuItem is ActionMenuSwitchItemType =>\n typeof (menuItem as ActionMenuSwitchItemType).onClick !== 'undefined' && menuItem.type === 'switch';\n\nconst useSwitch = (initialValue: boolean) => {\n const [switchValue, setSwitchValue] = useState<boolean>(initialValue);\n const toggleSwitch = () => setSwitchValue(!switchValue);\n const switchComponent = <Switch size={SwitchSize.Small} on={switchValue} />;\n\n return {\n switchComponent,\n switchValue,\n toggleSwitch,\n };\n};\n\nexport const AriaMenuItem: FC<AriaOptionProps> = ({ menuItem, node, state, isSelected, onClick }) => {\n const ref = useRef<HTMLLIElement | null>(null);\n const {\n switchComponent = undefined,\n switchValue = null,\n toggleSwitch = null,\n } = isActionMenuSwitchItem(menuItem) ? useSwitch(menuItem.initialValue) : {};\n\n const { menuItemProps } = useMenuItem(\n {\n ...node,\n onAction: () => {\n if (isActionMenuItem(menuItem)) {\n menuItem.onClick();\n }\n if (isActionMenuSwitchItem(menuItem)) {\n toggleSwitch?.();\n menuItem.onClick(Boolean(!switchValue));\n }\n },\n isDisabled: menuItem?.disabled || false,\n 'aria-label': typeof menuItem?.title === 'string' ? menuItem?.title : 'Menu item',\n },\n state,\n ref,\n );\n const { title, decorator, subtitle, size, style, disabled, selectionIndicator } = menuItem;\n const { isFocusVisible, focusProps } = useFocusRing();\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions\n <li\n {...mergeProps(menuItemProps, focusProps)}\n data-test-id=\"menu-item\"\n className={merge([\n 'tw-relative hover:tw-bg-black-0 tw-list-none tw-outline-none',\n disabled && 'tw-pointer-events-none tw-top-px',\n isFocusVisible && FOCUS_STYLE_INSET,\n ])}\n ref={ref}\n onClick={onClick}\n >\n <MenuItem\n title={title}\n decorator={decorator}\n subtitle={subtitle}\n size={size}\n style={style}\n disabled={disabled}\n active={isSelected}\n selectionIndicator={selectionIndicator}\n switchComponent={switchComponent}\n />\n </li>\n );\n};\n"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ACA;AAAA,EAAA,GAEC,kBAAA,cAAA,GAAA;AAAA,IACG;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,EACJ,CAAA,CACJ;AAER;"}
|
|
1
|
+
{"version":3,"file":"AriaMenuItem.es.js","sources":["../../../../src/components/ActionMenu/Aria/AriaMenuItem.tsx"],"sourcesContent":["import { MenuItem } from '@components/MenuItem/MenuItem';\nimport { Switch, SwitchSize } from '@components/Switch';\nimport { useFocusRing } from '@react-aria/focus';\nimport { useMenuItem } from '@react-aria/menu';\nimport { mergeProps } from '@react-aria/utils';\nimport { TreeState } from '@react-stately/tree';\nimport { Node } from '@react-types/shared';\nimport { FOCUS_STYLE_INSET } from '@utilities/focusStyle';\nimport { merge } from '@utilities/merge';\nimport React, { FC, useRef, useState } from 'react';\nimport { MenuItemType } from '../../Dropdown/SelectMenu/SelectMenu';\nimport { ActionMenuItemType, ActionMenuSwitchItemType } from '../ActionMenu/ActionMenu';\n\nexport type AriaOptionProps = {\n menuItem: MenuItemType | ActionMenuItemType | ActionMenuSwitchItemType;\n node: Node<object>;\n isSelected?: boolean;\n state: TreeState<object>;\n onClick?: () => void;\n};\n\nconst isActionMenuItem = (\n menuItem: MenuItemType | ActionMenuItemType | ActionMenuSwitchItemType,\n): menuItem is ActionMenuItemType =>\n typeof (menuItem as ActionMenuItemType).onClick !== 'undefined' && typeof menuItem.type === 'undefined';\nconst isActionMenuSwitchItem = (\n menuItem: MenuItemType | ActionMenuItemType | ActionMenuSwitchItemType,\n): menuItem is ActionMenuSwitchItemType =>\n typeof (menuItem as ActionMenuSwitchItemType).onClick !== 'undefined' && menuItem.type === 'switch';\n\nconst useSwitch = (initialValue: boolean) => {\n const [switchValue, setSwitchValue] = useState<boolean>(initialValue);\n const toggleSwitch = () => setSwitchValue(!switchValue);\n const switchComponent = <Switch size={SwitchSize.Small} on={switchValue} />;\n\n return {\n switchComponent,\n switchValue,\n toggleSwitch,\n };\n};\n\nexport const AriaMenuItem: FC<AriaOptionProps> = ({ menuItem, node, state, isSelected, onClick }) => {\n const ref = useRef<HTMLLIElement | null>(null);\n const {\n switchComponent = undefined,\n switchValue = null,\n toggleSwitch = null,\n } = isActionMenuSwitchItem(menuItem) ? useSwitch(menuItem.initialValue) : {};\n\n const { menuItemProps } = useMenuItem(\n {\n ...node,\n onAction: () => {\n if (isActionMenuItem(menuItem)) {\n menuItem.onClick();\n }\n if (isActionMenuSwitchItem(menuItem)) {\n toggleSwitch?.();\n menuItem.onClick(Boolean(!switchValue));\n }\n },\n isDisabled: menuItem?.disabled || false,\n 'aria-label': typeof menuItem?.title === 'string' ? menuItem?.title : 'Menu item',\n },\n state,\n ref,\n );\n const { title, decorator, subtitle, size, style, disabled, selectionIndicator } = menuItem;\n const { isFocusVisible, focusProps } = useFocusRing();\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions\n <li\n {...mergeProps(menuItemProps, focusProps)}\n data-test-id=\"menu-item\"\n className={merge([\n 'tw-relative hover:tw-bg-black-0 tw-list-none tw-outline-none',\n disabled && 'tw-pointer-events-none tw-top-px',\n isFocusVisible && FOCUS_STYLE_INSET,\n ])}\n ref={ref}\n onClick={(event) => {\n event.stopPropagation();\n if (onClick) {\n onClick();\n }\n }}\n >\n <MenuItem\n title={title}\n decorator={decorator}\n subtitle={subtitle}\n size={size}\n style={style}\n disabled={disabled}\n active={isSelected}\n selectionIndicator={selectionIndicator}\n switchComponent={switchComponent}\n />\n </li>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAqBA,MAAM,IAAmB,CACrB,MAEA,OAAQ,EAAgC,UAAY,OAAe,OAAO,EAAS,OAAS,KAC1F,IAAyB,CAC3B,MAEA,OAAQ,EAAsC,UAAY,OAAe,EAAS,SAAS,UAEzF,IAAY,CAAC,MAA0B;AACzC,QAAM,CAAC,GAAa,KAAkB,EAAkB,CAAY,GAC9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@ -9,8 +9,8 @@ import { useFocusRing as ot, FocusScope as rt } from "@react-aria/focus";
|
|
|
9
9
|
import { useOverlay as nt, DismissButton as L } from "@react-aria/overlays";
|
|
10
10
|
import { useSelect as st, HiddenSelect as lt } from "@react-aria/select";
|
|
11
11
|
import { mergeProps as at } from "@react-aria/utils";
|
|
12
|
-
import { useSelectState as
|
|
13
|
-
import { merge as
|
|
12
|
+
import { useSelectState as it } from "@react-stately/select";
|
|
13
|
+
import { merge as mt } from "../../utilities/merge.es.js";
|
|
14
14
|
import { AnimatePresence as pt, motion as ct } from "framer-motion";
|
|
15
15
|
import e, { useRef as d, useEffect as ut } from "react";
|
|
16
16
|
import { useDropdownAutoHeight as ft, DEFAULT_DROPDOWN_MAX_HEIGHT as dt } from "./useDropdownAutoHeight.es.js";
|
|
@@ -18,7 +18,7 @@ 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
|
|
21
|
+
var yt = /* @__PURE__ */ ((t) => (t.Small = "Small", t.Large = "Large", t))(yt || {}), Et = /* @__PURE__ */ ((t) => (t.Start = "Start", t.End = "End", t))(Et || {}), bt = /* @__PURE__ */ ((t) => (t.Top = "Top", t.Bottom = "Bottom", t))(bt || {});
|
|
22
22
|
const xt = (t, s) => K(A(t)).has(s) ? null : t.map(({ menuItems: o }) => o).flat().find(({ id: o }) => o.toString() === (s == null ? void 0 : s.toString())) || null, Gt = ({
|
|
23
23
|
id: t,
|
|
24
24
|
menuBlocks: s,
|
|
@@ -36,26 +36,27 @@ const xt = (t, s) => K(A(t)).has(s) ? null : t.map(({ menuItems: o }) => o).flat
|
|
|
36
36
|
position: O = "Bottom"
|
|
37
37
|
}) => {
|
|
38
38
|
var D;
|
|
39
|
-
const r = o ? xt(s, o) : null, S = J(R, s), n =
|
|
39
|
+
const r = o ? xt(s, o) : null, S = J(R, s), n = it({
|
|
40
40
|
...S,
|
|
41
41
|
defaultSelectedKey: o,
|
|
42
|
-
onSelectionChange: (
|
|
42
|
+
onSelectionChange: (m) => w(m),
|
|
43
43
|
disabledKeys: K(A(s))
|
|
44
|
-
}), l = d(null), { triggerProps: z, valueProps: V, menuProps: _ } = st({ ...S, isDisabled: a }, n, l), { buttonProps: h } = et({ ...z, isDisabled: a }, l), { isOpen:
|
|
44
|
+
}), l = d(null), { triggerProps: z, valueProps: V, menuProps: _ } = st({ ...S, isDisabled: a }, n, l), { buttonProps: h } = et({ ...z, isDisabled: a }, l), { isOpen: i } = n, { isFocusVisible: v, focusProps: W } = ot(), y = d(null), { overlayProps: $ } = nt({ isOpen: i, onClose: () => n.close(), shouldCloseOnBlur: !0, isDismissable: !0 }, y);
|
|
45
45
|
ut(() => {
|
|
46
46
|
n.disabledKeys.has(o) || n.setSelectedKey(o);
|
|
47
47
|
}, [o]);
|
|
48
|
-
const { maxHeight:
|
|
48
|
+
const { maxHeight: E } = ft(l, { isOpen: i, autoResize: u }), G = !u || E !== dt, U = r ? f.Active : f.Default, X = a ? f.Disabled : U, j = r ? Y[r.style || Z.Primary][X] : "tw-text-black-60", b = N ? () => {
|
|
49
49
|
n.setSelectedKey("");
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
} : void 0, x = !!r && !!
|
|
50
|
+
const m = n.collection.getFirstKey();
|
|
51
|
+
m && n.selectionManager.setFocusedKey(m);
|
|
52
|
+
} : void 0, x = !!r && !!b, C = d(null), q = {
|
|
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
58
|
placement: q[`${O}-${H}`],
|
|
59
|
+
strategy: "fixed",
|
|
59
60
|
modifiers: [
|
|
60
61
|
{
|
|
61
62
|
name: "offset",
|
|
@@ -75,9 +76,9 @@ const xt = (t, s) => K(A(t)).has(s) ? null : t.map(({ menuItems: o }) => o).flat
|
|
|
75
76
|
disabled: a,
|
|
76
77
|
buttonProps: h,
|
|
77
78
|
isFocusVisible: !a && v,
|
|
78
|
-
isOpen:
|
|
79
|
+
isOpen: i,
|
|
79
80
|
size: p === "Large" ? M.Large : M.Small,
|
|
80
|
-
onClear:
|
|
81
|
+
onClear: b,
|
|
81
82
|
showClear: x,
|
|
82
83
|
validation: g
|
|
83
84
|
}, /* @__PURE__ */ e.createElement(lt, {
|
|
@@ -88,7 +89,7 @@ const xt = (t, s) => K(A(t)).has(s) ? null : t.map(({ menuItems: o }) => o).flat
|
|
|
88
89
|
id: tt(t),
|
|
89
90
|
ref: l,
|
|
90
91
|
"data-test-id": "dropdown-trigger",
|
|
91
|
-
className:
|
|
92
|
+
className: mt([
|
|
92
93
|
"tw-overflow-hidden tw-flex-auto tw-h-full tw-rounded tw-text-left tw-outline-none",
|
|
93
94
|
p === "Small" ? "tw-py-2 tw-pl-3 tw-min-h-[34px]" : "tw-pl-5 tw-py-4 tw-min-h-[60px]",
|
|
94
95
|
x ? "tw-pr-11" : "tw-pr-7",
|
|
@@ -99,7 +100,7 @@ const xt = (t, s) => K(A(t)).has(s) ? null : t.map(({ menuItems: o }) => o).flat
|
|
|
99
100
|
title: (r == null ? void 0 : r.title) || B,
|
|
100
101
|
decorator: c != null ? c : r == null ? void 0 : r.decorator,
|
|
101
102
|
size: p === "Small" ? T.Small : T.Large
|
|
102
|
-
}))), St(/* @__PURE__ */ e.createElement(pt, null, !a &&
|
|
103
|
+
}))), St(/* @__PURE__ */ e.createElement(pt, null, !a && i && G && /* @__PURE__ */ e.createElement(ct.div, {
|
|
103
104
|
ref: C,
|
|
104
105
|
style: {
|
|
105
106
|
...P.styles.popper,
|
|
@@ -116,8 +117,8 @@ const xt = (t, s) => K(A(t)).has(s) ? null : t.map(({ menuItems: o }) => o).flat
|
|
|
116
117
|
restoreFocus: !0
|
|
117
118
|
}, /* @__PURE__ */ e.createElement("div", {
|
|
118
119
|
...$,
|
|
119
|
-
ref:
|
|
120
|
-
style: u ? { maxHeight:
|
|
120
|
+
ref: y,
|
|
121
|
+
style: u ? { maxHeight: E } : {},
|
|
121
122
|
className: "tw-flex tw-flex-col",
|
|
122
123
|
"data-test-id": "dropdown-menu",
|
|
123
124
|
role: "dialog"
|
|
@@ -138,8 +139,8 @@ const xt = (t, s) => K(A(t)).has(s) ? null : t.map(({ menuItems: o }) => o).flat
|
|
|
138
139
|
};
|
|
139
140
|
export {
|
|
140
141
|
Gt as Dropdown,
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
142
|
+
Et as DropdownAlignment,
|
|
143
|
+
bt as DropdownPosition,
|
|
144
|
+
yt as DropdownSize
|
|
144
145
|
};
|
|
145
146
|
//# 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]);\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 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,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,EAA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,MAAM,MAAM,IAAI,GAAG,UAAU,IAAI;AAAA,EAAA,GAE3D,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;"}
|
|
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]);\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,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,I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AAA,IAC9B,WAAU;AAAA,IACV,KAAI;AAAA,IACJ,SAAS,EAAE,QAAQ,EAAE;AAAA,IACrB,SAAS,EAAE,QAAQ,OAAO;AAAA,IAC1B,YAAY,EAAE,MAAM,CAAC,MAAM,MAAM,MAAM,IAAI,GAAG,UAAU,IAAI;AAAA,EAAA,GAE3D,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;"}
|
|
@@ -7,12 +7,12 @@ import { InputLabel as E } from "../InputLabel/InputLabel.es.js";
|
|
|
7
7
|
var F = /* @__PURE__ */ ((e) => (e.Small = "Small", e.Medium = "Medium", e.Large = "Large", e))(F || {});
|
|
8
8
|
const y = {
|
|
9
9
|
Small: "tw-w-5 tw-h-2",
|
|
10
|
-
Medium: "tw-w-
|
|
11
|
-
Large: "tw-w-
|
|
10
|
+
Medium: "tw-w-7 tw-h-4",
|
|
11
|
+
Large: "tw-w-9 tw-h-5"
|
|
12
12
|
}, N = {
|
|
13
13
|
Small: "tw-w-3 tw-h-3",
|
|
14
|
-
Medium: "tw-w-
|
|
15
|
-
Large: "tw-w-
|
|
14
|
+
Medium: "tw-w-3 tw-h-3",
|
|
15
|
+
Large: "tw-w-4 tw-h-4"
|
|
16
16
|
}, U = ({
|
|
17
17
|
id: e,
|
|
18
18
|
name: b,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.es.js","sources":["../../../src/components/Switch/Switch.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { FC, MouseEvent, useMemo } from 'react';\nimport { merge } from '@utilities/merge';\nimport { useFocusRing } from '@react-aria/focus';\nimport { FOCUS_STYLE } from '@utilities/focusStyle';\nimport { useMemoizedId } from '@hooks/useMemoizedId';\nimport { InputLabel, InputLabelTooltipProps } from '@components/InputLabel/InputLabel';\n\nexport enum SwitchSize {\n Small = 'Small',\n Medium = 'Medium',\n Large = 'Large',\n}\n\nconst lineSizeClasses: Record<SwitchSize, string> = {\n [SwitchSize.Small]: 'tw-w-5 tw-h-2',\n [SwitchSize.Medium]: 'tw-w-
|
|
1
|
+
{"version":3,"file":"Switch.es.js","sources":["../../../src/components/Switch/Switch.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { FC, MouseEvent, useMemo } from 'react';\nimport { merge } from '@utilities/merge';\nimport { useFocusRing } from '@react-aria/focus';\nimport { FOCUS_STYLE } from '@utilities/focusStyle';\nimport { useMemoizedId } from '@hooks/useMemoizedId';\nimport { InputLabel, InputLabelTooltipProps } from '@components/InputLabel/InputLabel';\n\nexport enum SwitchSize {\n Small = 'Small',\n Medium = 'Medium',\n Large = 'Large',\n}\n\nconst lineSizeClasses: Record<SwitchSize, string> = {\n [SwitchSize.Small]: 'tw-w-5 tw-h-2',\n [SwitchSize.Medium]: 'tw-w-7 tw-h-4',\n [SwitchSize.Large]: 'tw-w-9 tw-h-5',\n};\n\nconst dotSizeClasses: Record<SwitchSize, string> = {\n [SwitchSize.Small]: 'tw-w-3 tw-h-3',\n [SwitchSize.Medium]: 'tw-w-3 tw-h-3',\n [SwitchSize.Large]: 'tw-w-4 tw-h-4',\n};\n\nexport type SwitchProps = {\n id?: string;\n on?: boolean;\n disabled?: boolean;\n label?: string;\n name?: string;\n size?: SwitchSize;\n hug?: boolean;\n tooltip?: InputLabelTooltipProps;\n onChange?: (e: MouseEvent) => void;\n};\n\nexport const Switch: FC<SwitchProps> = ({\n id: propId,\n name,\n label,\n disabled,\n onChange,\n size = SwitchSize.Medium,\n on = false,\n hug = false,\n tooltip,\n}) => {\n const id = useMemoizedId(propId);\n const { isFocusVisible, focusProps } = useFocusRing();\n\n const lineClasses = useMemo(() => {\n const baseClasses = 'tw-inline-flex tw-border-0 tw-rounded-full tw-transition-colors tw-shrink-0';\n const sizeClasses = size !== SwitchSize.Small ? 'tw-py-0 tw-px-[0.125rem]' : 'tw-p-0';\n const activatedClasses = on ? 'tw-bg-black-90 hover:tw-bg-black' : 'tw-bg-black-30 hover:tw-bg-black-60';\n const disabledClasses = disabled ? 'tw-bg-black-10 tw-pointer-events-none' : activatedClasses;\n\n return merge([baseClasses, sizeClasses, disabledClasses, lineSizeClasses[size], isFocusVisible && FOCUS_STYLE]);\n }, [on, disabled, size, isFocusVisible]);\n\n const dotClasses = useMemo(() => {\n const baseClasses = 'tw-block tw-self-center tw-bg-white tw-rounded-full tw-transition-transform';\n const disabledClasses = disabled ? 'tw-border tw-border-black-30' : 'tw-border tw-border-black';\n const sizeClasses = size === SwitchSize.Small ? disabledClasses : '';\n const activatedClasses = size === SwitchSize.Small ? 'tw-translate-x-2' : 'tw-translate-x-full';\n const animationClasses = on ? activatedClasses : 'tw-translate-x-0';\n\n return merge([baseClasses, sizeClasses, dotSizeClasses[size], animationClasses]);\n }, [on, disabled, size]);\n\n const containerClasses = useMemo(() => {\n return merge(['tw-gap-2 tw-items-center tw-justify-between', hug ? 'tw-inline-flex' : 'tw-flex']);\n }, [hug]);\n\n return (\n <div className={containerClasses} data-test-id=\"switch-container\">\n {label && (\n <InputLabel clickable={true} htmlFor={id} disabled={disabled} tooltip={tooltip}>\n {label}\n </InputLabel>\n )}\n <button\n {...focusProps}\n id={id}\n disabled={disabled}\n name={name}\n data-test-id=\"switch\"\n className={lineClasses}\n value={on.toString()}\n onClick={onChange}\n type=\"button\"\n >\n <div className={dotClasses} />\n </button>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;AASY,IAAA,sBAAA,MACA,GAAA,QAAA,SACC,EAAA,SAAA,UACD,EAAA,QAAA,SAHA,IAAA,KAAA,CAAA,CAAA;AAMZ,MAAM,IAA8C;AAAA,EAChD,AAAC,OAAmB;AAAA,EACpB,AAAC,QAAoB;AAAA,EACrB,AAAC,OAAmB;AACxB,GAEM,IAA6C;AAAA,EAC/C,AAAC,OAAmB;AAAA,EACpB,AAAC,QAAoB;AAAA,EACrB,AAAC,OAAmB;AACxB,GAca,IAA0B,CAAC;AAAA,EACpC,IAAI;AAAA,EACJ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAO;AAAA,EACP,QAAK;AAAA,EACL,SAAM;AAAA,EACN;AAAA,MACE;AACI,QAAA,IAAK,EAAc,CAAM,GACzB,EAAE,mBAAgB,kBAAe,EAAa,GAE9C,IAAc,EAAQ,MAMjB,EAAM,CALO,+EACA,MAAS,UAAmB,6BAA6B,UAErD,IAAW,0CADV,IAAK,qCAAqC,uCAGV,EAAgB,IAAO,KAAkB,CAAW,CAAC,GAC/G,CAAC,GAAI,GAAU,GAAM,CAAc,CAAC,GAEjC,IAAa,EAAQ,MAAM;AAC7B,UAAM,IAAc,+EAEd,IAAc,MAAS,UADL,IAAW,iCAAiC,8BACF,IAE5D,IAAmB,IADA,MAAS,UAAmB,qBAAqB,wBACzB;AAEjD,WAAO,EAAM,CAAC,GAAa,GAAa,EAAe,IAAO,CAAgB,CAAC;AAAA,EAChF,GAAA,CAAC,GAAI,GAAU,CAAI,CAAC,GAEjB,IAAmB,EAAQ,MACtB,EAAM,CAAC,+CAA+C,IAAM,mBAAmB,SAAS,CAAC,GACjG,CAAC,CAAG,CAAC;AAER,SACK,kBAAA,cAAA,OAAA;AAAA,IAAI,WAAW;AAAA,IAAkB,gBAAa;AAAA,EAAA,GAC1C,KACI,kBAAA,cAAA,GAAA;AAAA,IAAW,WAAW;AAAA,IAAM,SAAS;AAAA,IAAI;AAAA,IAAoB;AAAA,EACzD,GAAA,CACL,GAEH,kBAAA,cAAA,UAAA;AAAA,IACI,GAAG;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA,gBAAa;AAAA,IACb,WAAW;AAAA,IACX,OAAO,EAAG,SAAS;AAAA,IACnB,SAAS;AAAA,IACT,MAAK;AAAA,EAAA,GAEJ,kBAAA,cAAA,OAAA;AAAA,IAAI,WAAW;AAAA,EAAY,CAAA,CAChC,CACJ;AAER;"}
|
|
@@ -2,7 +2,7 @@ import { Button as I, ButtonStyle as _, ButtonSize as P } from "../Button/Button
|
|
|
2
2
|
import { IconSize as $ } from "../../foundation/Icon/IconSize.es.js";
|
|
3
3
|
import { useLink as re } from "@react-aria/link";
|
|
4
4
|
import { FOCUS_VISIBLE_STYLE as oe } from "../../utilities/focusStyle.es.js";
|
|
5
|
-
import { merge as
|
|
5
|
+
import { merge as d } from "../../utilities/merge.es.js";
|
|
6
6
|
import e, { useRef as f, useMemo as ae, useState as V, useCallback as E, cloneElement as x } from "react";
|
|
7
7
|
import { BrightHeader as se, brightHeaderArrowBackgroundColors as B } from "./BrightHeader.es.js";
|
|
8
8
|
import { usePopper as le } from "react-popper";
|
|
@@ -15,7 +15,7 @@ const Y = {
|
|
|
15
15
|
large: "tw-pb-4"
|
|
16
16
|
};
|
|
17
17
|
var ne = /* @__PURE__ */ ((t) => (t.Top = "Top", t.Right = "Right", t.Bottom = "Bottom", t.Left = "Left", t))(ne || {}), we = /* @__PURE__ */ ((t) => (t.Start = "Start", t.Middle = "Middle", t.End = "End", t))(we || {});
|
|
18
|
-
const
|
|
18
|
+
const de = {
|
|
19
19
|
["Top-Start"]: "top-start",
|
|
20
20
|
["Top-End"]: "top-end",
|
|
21
21
|
["Bottom-Start"]: "bottom-start",
|
|
@@ -28,22 +28,22 @@ const me = {
|
|
|
28
28
|
["Right-Middle"]: "right",
|
|
29
29
|
["Bottom-Middle"]: "bottom",
|
|
30
30
|
["Left-Middle"]: "left"
|
|
31
|
-
},
|
|
31
|
+
}, me = (t, a, w) => {
|
|
32
32
|
switch (!0) {
|
|
33
33
|
case t.toString().includes("Top".toLowerCase()):
|
|
34
34
|
return "before:tw-border-t-0 before:tw-border-l-0 tw-bottom-[-6px] before:tw-bg-black-100 before:dark:tw-bg-white";
|
|
35
35
|
case t.toString().includes("Right".toLowerCase()):
|
|
36
|
-
return
|
|
36
|
+
return d([
|
|
37
37
|
"before:tw-border-t-0 before:tw-border-r-0 tw-left-[-6px]",
|
|
38
38
|
a && w === "Start" ? B[a] : "before:tw-bg-black-100 before:dark:tw-bg-white"
|
|
39
39
|
]);
|
|
40
40
|
case t.toString().includes("Bottom".toLowerCase()):
|
|
41
|
-
return
|
|
41
|
+
return d([
|
|
42
42
|
"before:tw-border-b-0 before:tw-border-r-0 tw-top-[-6px]",
|
|
43
43
|
a ? B[a] : "before:tw-bg-black-100 before:dark:tw-bg-white"
|
|
44
44
|
]);
|
|
45
45
|
case t.toString().includes("Left".toLowerCase()):
|
|
46
|
-
return
|
|
46
|
+
return d([
|
|
47
47
|
"before:tw-border-b-0 before:tw-border-l-0 tw-right-[-6px]",
|
|
48
48
|
a && w === "Start" ? B[a] : "before:tw-bg-black-100 before:dark:tw-bg-white"
|
|
49
49
|
]);
|
|
@@ -57,19 +57,20 @@ const me = {
|
|
|
57
57
|
headingIcon: u,
|
|
58
58
|
linkUrl: l,
|
|
59
59
|
linkLabel: S,
|
|
60
|
-
brightHeader:
|
|
60
|
+
brightHeader: m,
|
|
61
61
|
buttons: r,
|
|
62
62
|
children: q,
|
|
63
63
|
position: k = "Bottom",
|
|
64
64
|
alignment: g = "Middle",
|
|
65
65
|
withArrow: b,
|
|
66
66
|
flip: D = !0,
|
|
67
|
-
triggerElement:
|
|
67
|
+
triggerElement: y,
|
|
68
68
|
hoverDelay: G = 200
|
|
69
69
|
}) => {
|
|
70
70
|
var z, T;
|
|
71
|
-
const o = f(null),
|
|
71
|
+
const o = f(null), M = f(null), { linkProps: J } = re({}, M), K = ae(() => l || m || r || w || u, [l, m, r, w, u]), Q = de[`${k}-${g}`], s = f(null), p = f(null), [W, X] = V(null), Z = b ? 10 : 5, i = le(o == null ? void 0 : o.current, s.current, {
|
|
72
72
|
placement: Q,
|
|
73
|
+
strategy: "fixed",
|
|
73
74
|
modifiers: [
|
|
74
75
|
{
|
|
75
76
|
name: "arrow",
|
|
@@ -88,7 +89,7 @@ const me = {
|
|
|
88
89
|
enabled: D
|
|
89
90
|
}
|
|
90
91
|
]
|
|
91
|
-
}), R = (T = (z = i.state) == null ? void 0 : z.placement) != null ? T : k, A =
|
|
92
|
+
}), R = (T = (z = i.state) == null ? void 0 : z.placement) != null ? T : k, A = me(R, m, g), [H, c] = V(!1), h = f(null), U = E(() => {
|
|
92
93
|
h.current && clearTimeout(h.current), c(!0);
|
|
93
94
|
}, [o == null ? void 0 : o.current]), L = E(() => {
|
|
94
95
|
h.current = setTimeout(() => c(!1), G);
|
|
@@ -105,7 +106,7 @@ const me = {
|
|
|
105
106
|
return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("div", {
|
|
106
107
|
...te,
|
|
107
108
|
ref: p
|
|
108
|
-
},
|
|
109
|
+
}, y && x(y, {
|
|
109
110
|
ref: o
|
|
110
111
|
})), ce(/* @__PURE__ */ e.createElement("div", null, H && /* @__PURE__ */ e.createElement("div", {
|
|
111
112
|
ref: s,
|
|
@@ -117,10 +118,10 @@ const me = {
|
|
|
117
118
|
onFocus: () => c(!0),
|
|
118
119
|
onMouseOver: (n) => N(n.nativeEvent),
|
|
119
120
|
onMouseLeave: L
|
|
120
|
-
},
|
|
121
|
-
headerStyle:
|
|
121
|
+
}, m && /* @__PURE__ */ e.createElement(se, {
|
|
122
|
+
headerStyle: m
|
|
122
123
|
}), /* @__PURE__ */ e.createElement("div", {
|
|
123
|
-
className:
|
|
124
|
+
className: d([
|
|
124
125
|
"tw-px-4",
|
|
125
126
|
K ? Y.small : Y.large,
|
|
126
127
|
l ? j.small : j.large
|
|
@@ -138,11 +139,11 @@ const me = {
|
|
|
138
139
|
}, t)), l && /* @__PURE__ */ e.createElement("a", {
|
|
139
140
|
...J,
|
|
140
141
|
"data-test-id": "tooltip-link",
|
|
141
|
-
ref:
|
|
142
|
+
ref: M,
|
|
142
143
|
href: l,
|
|
143
144
|
target: "_blank",
|
|
144
145
|
rel: "noopener noreferrer",
|
|
145
|
-
className:
|
|
146
|
+
className: d([
|
|
146
147
|
"tw-text-xs tw-text-black-40 dark:tw-text-black-80 tw-underline tw-mt-1",
|
|
147
148
|
oe
|
|
148
149
|
]),
|
|
@@ -168,7 +169,7 @@ const me = {
|
|
|
168
169
|
"data-popper-arrow": b,
|
|
169
170
|
ref: X,
|
|
170
171
|
style: i.styles.arrow,
|
|
171
|
-
className:
|
|
172
|
+
className: d([
|
|
172
173
|
b && "tw-popper-arrow tw-absolute tw-w-3 tw-h-3 tw-pointer-events-none before:tw-absolute before:tw-w-3 before:tw-h-3 before:tw-rotate-45 before:tw-border before:tw-border-line",
|
|
173
174
|
b && A
|
|
174
175
|
])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.es.js","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { Button, ButtonSize, ButtonStyle } from '@components/Button/Button';\nimport { IconSize } from '@foundation/Icon/IconSize';\nimport { useLink } from '@react-aria/link';\nimport { FOCUS_VISIBLE_STYLE } from '@utilities/focusStyle';\nimport { merge } from '@utilities/merge';\nimport React, {\n HTMLAttributes,\n PropsWithChildren,\n ReactChild,\n ReactElement,\n ReactNode,\n cloneElement,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { BrightHeader, BrightHeaderStyle, brightHeaderArrowBackgroundColors } from './BrightHeader';\nimport { usePopper } from 'react-popper';\nimport { createPortal } from 'react-dom';\nimport { Placement } from '@popperjs/core';\n\nexport type TooltipButton = {\n label: string;\n action: () => void;\n};\n\nexport type TooltipProps = PropsWithChildren<{\n triggerElement?: ReactElement;\n content: ReactNode;\n tooltipIcon?: ReactElement;\n heading?: ReactNode;\n headingIcon?: ReactElement;\n linkUrl?: string;\n linkLabel?: string;\n brightHeader?: BrightHeaderStyle;\n buttons?: [TooltipButton, TooltipButton] | [TooltipButton];\n children?: ReactChild;\n position?: TooltipPosition;\n alignment?: TooltipAlignment;\n flip?: boolean;\n withArrow?: boolean;\n hoverDelay?: number;\n}>;\n\n/**\n * This is a temporary workaround because for some yet unknown reasons `tailwindcss` in clarify purges the `tw-pb-3.5` and `tw-pt-3.5` class.\n */\nconst paddingsTop = {\n small: 'tw-pt-3.5',\n large: 'tw-pt-4',\n};\n\nconst paddingsBottom = {\n small: 'tw-pb-3.5',\n large: 'tw-pb-4',\n};\n\nexport enum TooltipPosition {\n Top = 'Top',\n Right = 'Right',\n Bottom = 'Bottom',\n Left = 'Left',\n}\n\nexport enum TooltipAlignment {\n Start = 'Start',\n Middle = 'Middle',\n End = 'End',\n}\n\nconst placementMap: Record<`${TooltipPosition}-${TooltipAlignment}`, Placement> = {\n ['Top-Start']: 'top-start',\n ['Top-End']: 'top-end',\n ['Bottom-Start']: 'bottom-start',\n ['Bottom-End']: 'bottom-end',\n ['Left-Start']: 'left-start',\n ['Left-End']: 'left-end',\n ['Right-Start']: 'right-start',\n ['Right-End']: 'right-end',\n ['Top-Middle']: 'top',\n ['Right-Middle']: 'right',\n ['Bottom-Middle']: 'bottom',\n ['Left-Middle']: 'left',\n};\n\nconst getArrowClasses = (currentPlacement: string, brightHeader: BrightHeaderStyle | undefined, alignment: string) => {\n switch (true) {\n case currentPlacement.toString().includes(TooltipPosition.Top.toLowerCase()):\n return 'before:tw-border-t-0 before:tw-border-l-0 tw-bottom-[-6px] before:tw-bg-black-100 before:dark:tw-bg-white';\n case currentPlacement.toString().includes(TooltipPosition.Right.toLowerCase()):\n return merge([\n 'before:tw-border-t-0 before:tw-border-r-0 tw-left-[-6px]',\n brightHeader && alignment === TooltipAlignment.Start\n ? brightHeaderArrowBackgroundColors[brightHeader]\n : 'before:tw-bg-black-100 before:dark:tw-bg-white',\n ]);\n case currentPlacement.toString().includes(TooltipPosition.Bottom.toLowerCase()):\n return merge([\n 'before:tw-border-b-0 before:tw-border-r-0 tw-top-[-6px]',\n brightHeader\n ? brightHeaderArrowBackgroundColors[brightHeader]\n : 'before:tw-bg-black-100 before:dark:tw-bg-white',\n ]);\n case currentPlacement.toString().includes(TooltipPosition.Left.toLowerCase()):\n return merge([\n 'before:tw-border-b-0 before:tw-border-l-0 tw-right-[-6px]',\n brightHeader && alignment === TooltipAlignment.Start\n ? brightHeaderArrowBackgroundColors[brightHeader]\n : 'before:tw-bg-black-100 before:dark:tw-bg-white',\n ]);\n default:\n return 'before:tw-border-b-0 before:tw-border-r-0 tw-top-[-6px] before:tw-bg-black-100 before:dark:tw-bg-white';\n }\n};\n\nexport const Tooltip = ({\n content,\n tooltipIcon,\n heading,\n headingIcon,\n linkUrl,\n linkLabel,\n brightHeader,\n buttons,\n children,\n position = TooltipPosition.Bottom,\n alignment = TooltipAlignment.Middle,\n withArrow,\n flip = true,\n triggerElement,\n hoverDelay = 200,\n}: TooltipProps) => {\n const triggerRefElement = useRef<HTMLElement | HTMLDivElement | HTMLButtonElement | null>(null);\n const linkRef = useRef<HTMLAnchorElement | null>(null);\n const { linkProps } = useLink({}, linkRef);\n const hasLargePaddingTop = useMemo(\n () => linkUrl || brightHeader || buttons || heading || headingIcon,\n [linkUrl, brightHeader, buttons, heading, headingIcon],\n );\n\n const placement = placementMap[`${position}-${alignment}`];\n const tooltipContainerRef = useRef<HTMLDivElement | null>(null);\n const triggerElementContainerRef = useRef<HTMLDivElement | null>(null);\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null);\n\n const tooltipOffset = withArrow ? 10 : 5;\n const popperInstance = usePopper(triggerRefElement?.current, tooltipContainerRef.current, {\n placement,\n modifiers: [\n {\n name: 'arrow',\n options: {\n element: arrowElement,\n },\n },\n {\n name: 'offset',\n options: {\n offset: [0, tooltipOffset],\n },\n },\n {\n name: 'flip',\n enabled: flip,\n },\n ],\n });\n\n const currentPlacement = popperInstance.state?.placement ?? position;\n const arrowStyling = getArrowClasses(currentPlacement, brightHeader, alignment);\n const [isOpen, setIsOpen] = useState(false);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleShowTooltipOnHover = useCallback(() => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n setIsOpen(true);\n }, [triggerRefElement?.current]);\n\n const handleHideTooltipOnHover = useCallback(() => {\n timeoutRef.current = setTimeout(() => setIsOpen(false), hoverDelay);\n }, [triggerRefElement?.current, tooltipContainerRef?.current]);\n\n const checkIfHovered = useCallback(\n (event) => {\n const hoveredElement = event.path ?? event.composedPath?.();\n const hoverSources = [triggerRefElement, triggerElementContainerRef, tooltipContainerRef];\n\n if (hoveredElement && hoverSources.some((el) => hoveredElement.includes(el?.current))) {\n handleShowTooltipOnHover();\n }\n },\n [triggerRefElement?.current, tooltipContainerRef?.current, triggerElementContainerRef?.current],\n );\n\n const hasInteractiveElements = !!(buttons?.length || linkUrl?.length);\n const triggerProps: HTMLAttributes<HTMLElement> = {\n onMouseOver: (event) => checkIfHovered(event.nativeEvent),\n onMouseLeave: handleHideTooltipOnHover,\n onFocus: () => setIsOpen(true),\n onBlur: () => (!hasInteractiveElements ? setIsOpen(false) : null),\n };\n\n return (\n <>\n <div {...triggerProps} ref={triggerElementContainerRef}>\n {triggerElement &&\n cloneElement(triggerElement, {\n ref: triggerRefElement,\n })}\n </div>\n {createPortal(\n <div>\n {isOpen && (\n <div\n ref={tooltipContainerRef}\n className=\"tw-popper-container tw-inline-block tw-max-w-[200px] tw-bg-black-100 dark:tw-bg-white tw-rounded-md tw-shadow-mid tw-text-white dark:tw-text-black-100 tw-z-[120000]\"\n data-test-id=\"tooltip\"\n role=\"tooltip\"\n style={popperInstance.styles.popper}\n {...popperInstance.attributes.popper}\n onFocus={() => setIsOpen(true)}\n onMouseOver={(event) => checkIfHovered(event.nativeEvent)}\n onMouseLeave={handleHideTooltipOnHover}\n >\n {brightHeader && <BrightHeader headerStyle={brightHeader} />}\n <div\n className={merge([\n 'tw-px-4',\n hasLargePaddingTop ? paddingsTop.small : paddingsTop.large,\n linkUrl ? paddingsBottom.small : paddingsBottom.large,\n ])}\n >\n {heading && (\n <h4 className=\"tw-flex tw-text-m tw-font-bold tw-mb-1\">\n {headingIcon && (\n <span className=\"tw-mr-1.5\">\n {cloneElement(headingIcon, { size: IconSize.Size20 })}\n </span>\n )}\n {heading}\n </h4>\n )}\n <div className=\"tw-flex\">\n {tooltipIcon && (\n <span className=\"tw-shrink-0 tw-mr-1\">\n {cloneElement(tooltipIcon, { size: IconSize.Size16 })}\n </span>\n )}\n <p className=\"tw-text-s\">{content}</p>\n </div>\n {linkUrl && (\n <a\n {...linkProps}\n data-test-id=\"tooltip-link\"\n ref={linkRef}\n href={linkUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={merge([\n 'tw-text-xs tw-text-black-40 dark:tw-text-black-80 tw-underline tw-mt-1',\n FOCUS_VISIBLE_STYLE,\n ])}\n onBlur={() => (buttons && buttons.length > 0 ? null : setIsOpen(false))}\n >\n {linkLabel ?? 'Click here to learn more.'}\n </a>\n )}\n {buttons && (\n <div className=\"tw-flex tw-flex-row-reverse tw-gap-x-1 tw-mt-4\">\n {buttons.length > 0 && (\n <div\n onBlur={() => (buttons && buttons.length < 2 ? setIsOpen(false) : null)}\n >\n <Button\n style={ButtonStyle.Primary}\n size={ButtonSize.Small}\n inverted\n onClick={buttons[0].action}\n >\n {buttons[0].label}\n </Button>\n </div>\n )}\n {buttons.length === 2 && (\n <div onBlur={() => setIsOpen(false)}>\n <Button\n style={ButtonStyle.Secondary}\n size={ButtonSize.Small}\n inverted\n onClick={buttons[1].action}\n >\n {buttons[1].label}\n </Button>\n </div>\n )}\n </div>\n )}\n <div\n data-test-id=\"popover-arrow\"\n data-popper-arrow={withArrow}\n ref={setArrowElement}\n style={popperInstance.styles.arrow}\n className={merge([\n withArrow &&\n 'tw-popper-arrow tw-absolute tw-w-3 tw-h-3 tw-pointer-events-none before:tw-absolute before:tw-w-3 before:tw-h-3 before:tw-rotate-45 before:tw-border before:tw-border-line',\n withArrow && arrowStyling,\n ])}\n />\n </div>\n {children}\n </div>\n )}\n </div>,\n document.body,\n )}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAkDA,MAAM,IAAc;AAAA,EAChB,OAAO;AAAA,EACP,OAAO;AACX,GAEM,IAAiB;AAAA,EACnB,OAAO;AAAA,EACP,OAAO;AACX;AAEY,IAAA,uBAAA,MACF,GAAA,MAAA,OACE,EAAA,QAAA,SACC,EAAA,SAAA,UACF,EAAA,OAAA,QAJC,IAAA,MAAA,CAAA,CAAA,GAOA,uBAAA,MACA,GAAA,QAAA,SACC,EAAA,SAAA,UACH,EAAA,MAAA,OAHE,IAAA,MAAA,CAAA,CAAA;AAMZ,MAAM,KAA4E;AAAA,EAC9E,CAAC,cAAc;AAAA,EACf,CAAC,YAAY;AAAA,EACb,CAAC,iBAAiB;AAAA,EAClB,CAAC,eAAe;AAAA,EAChB,CAAC,eAAe;AAAA,EAChB,CAAC,aAAa;AAAA,EACd,CAAC,gBAAgB;AAAA,EACjB,CAAC,cAAc;AAAA,EACf,CAAC,eAAe;AAAA,EAChB,CAAC,iBAAiB;AAAA,EAClB,CAAC,kBAAkB;AAAA,EACnB,CAAC,gBAAgB;AACrB,GAEM,KAAkB,CAAC,GAA0B,GAA6C,MAAsB;AAC1G,UAA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EAAA,GAEpE,gBAAa,2BAClB,GAEH,KACI,kBAAA,cAAA,OAAA;AAAA,IAAI,WAAU;AAAA,EAAA,GACV,EAAQ,SAAS,KACb,kBAAA,cAAA,OAAA;AAAA,IACG,QAAQ,MAAO,KAAW,EAAQ,SAAS,IAAI,EAAU,EAAK,IAAI;AAAA,EAAA,GAEjE,kBAAA,cAAA,GAAA;AAAA,IACG,OAAO,EAAY;AAAA,IACnB,MAAM,EAAW;AAAA,IACjB,UAAQ;AAAA,IACR,SAAS,EAAQ,GAAG;AAAA,EAEnB,GAAA,EAAQ,GAAG,KAChB,CACJ,GAEH,EAAQ,WAAW,KACf,kBAAA,cAAA,OAAA;AAAA,IAAI,QAAQ,MAAM,EAAU,EAAK;AAAA,EAAA,GAC7B,kBAAA,cAAA,GAAA;AAAA,IACG,OAAO,EAAY;AAAA,IACnB,MAAM,EAAW;AAAA,IACjB,UAAQ;AAAA,IACR,SAAS,EAAQ,GAAG;AAAA,EAAA,GAEnB,EAAQ,GAAG,KAChB,CACJ,CAER,GAEH,kBAAA,cAAA,OAAA;AAAA,IACG,gBAAa;AAAA,IACb,qBAAmB;AAAA,IACnB,KAAK;AAAA,IACL,OAAO,EAAe,OAAO;AAAA,IAC7B,WAAW,EAAM;AAAA,MACb,KACI;AAAA,MACJ,KAAa;AAAA,IAAA,CAChB;AAAA,EAAA,CACL,CACJ,GACC,CACL,CAER,GACA,SAAS,IACb,CACJ;AAER;"}
|
|
1
|
+
{"version":3,"file":"Tooltip.es.js","sources":["../../../src/components/Tooltip/Tooltip.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { Button, ButtonSize, ButtonStyle } from '@components/Button/Button';\nimport { IconSize } from '@foundation/Icon/IconSize';\nimport { useLink } from '@react-aria/link';\nimport { FOCUS_VISIBLE_STYLE } from '@utilities/focusStyle';\nimport { merge } from '@utilities/merge';\nimport React, {\n HTMLAttributes,\n PropsWithChildren,\n ReactChild,\n ReactElement,\n ReactNode,\n cloneElement,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from 'react';\nimport { BrightHeader, BrightHeaderStyle, brightHeaderArrowBackgroundColors } from './BrightHeader';\nimport { usePopper } from 'react-popper';\nimport { createPortal } from 'react-dom';\nimport { Placement } from '@popperjs/core';\n\nexport type TooltipButton = {\n label: string;\n action: () => void;\n};\n\nexport type TooltipProps = PropsWithChildren<{\n triggerElement?: ReactElement;\n content: ReactNode;\n tooltipIcon?: ReactElement;\n heading?: ReactNode;\n headingIcon?: ReactElement;\n linkUrl?: string;\n linkLabel?: string;\n brightHeader?: BrightHeaderStyle;\n buttons?: [TooltipButton, TooltipButton] | [TooltipButton];\n children?: ReactChild;\n position?: TooltipPosition;\n alignment?: TooltipAlignment;\n flip?: boolean;\n withArrow?: boolean;\n hoverDelay?: number;\n}>;\n\n/**\n * This is a temporary workaround because for some yet unknown reasons `tailwindcss` in clarify purges the `tw-pb-3.5` and `tw-pt-3.5` class.\n */\nconst paddingsTop = {\n small: 'tw-pt-3.5',\n large: 'tw-pt-4',\n};\n\nconst paddingsBottom = {\n small: 'tw-pb-3.5',\n large: 'tw-pb-4',\n};\n\nexport enum TooltipPosition {\n Top = 'Top',\n Right = 'Right',\n Bottom = 'Bottom',\n Left = 'Left',\n}\n\nexport enum TooltipAlignment {\n Start = 'Start',\n Middle = 'Middle',\n End = 'End',\n}\n\nconst placementMap: Record<`${TooltipPosition}-${TooltipAlignment}`, Placement> = {\n ['Top-Start']: 'top-start',\n ['Top-End']: 'top-end',\n ['Bottom-Start']: 'bottom-start',\n ['Bottom-End']: 'bottom-end',\n ['Left-Start']: 'left-start',\n ['Left-End']: 'left-end',\n ['Right-Start']: 'right-start',\n ['Right-End']: 'right-end',\n ['Top-Middle']: 'top',\n ['Right-Middle']: 'right',\n ['Bottom-Middle']: 'bottom',\n ['Left-Middle']: 'left',\n};\n\nconst getArrowClasses = (currentPlacement: string, brightHeader: BrightHeaderStyle | undefined, alignment: string) => {\n switch (true) {\n case currentPlacement.toString().includes(TooltipPosition.Top.toLowerCase()):\n return 'before:tw-border-t-0 before:tw-border-l-0 tw-bottom-[-6px] before:tw-bg-black-100 before:dark:tw-bg-white';\n case currentPlacement.toString().includes(TooltipPosition.Right.toLowerCase()):\n return merge([\n 'before:tw-border-t-0 before:tw-border-r-0 tw-left-[-6px]',\n brightHeader && alignment === TooltipAlignment.Start\n ? brightHeaderArrowBackgroundColors[brightHeader]\n : 'before:tw-bg-black-100 before:dark:tw-bg-white',\n ]);\n case currentPlacement.toString().includes(TooltipPosition.Bottom.toLowerCase()):\n return merge([\n 'before:tw-border-b-0 before:tw-border-r-0 tw-top-[-6px]',\n brightHeader\n ? brightHeaderArrowBackgroundColors[brightHeader]\n : 'before:tw-bg-black-100 before:dark:tw-bg-white',\n ]);\n case currentPlacement.toString().includes(TooltipPosition.Left.toLowerCase()):\n return merge([\n 'before:tw-border-b-0 before:tw-border-l-0 tw-right-[-6px]',\n brightHeader && alignment === TooltipAlignment.Start\n ? brightHeaderArrowBackgroundColors[brightHeader]\n : 'before:tw-bg-black-100 before:dark:tw-bg-white',\n ]);\n default:\n return 'before:tw-border-b-0 before:tw-border-r-0 tw-top-[-6px] before:tw-bg-black-100 before:dark:tw-bg-white';\n }\n};\n\nexport const Tooltip = ({\n content,\n tooltipIcon,\n heading,\n headingIcon,\n linkUrl,\n linkLabel,\n brightHeader,\n buttons,\n children,\n position = TooltipPosition.Bottom,\n alignment = TooltipAlignment.Middle,\n withArrow,\n flip = true,\n triggerElement,\n hoverDelay = 200,\n}: TooltipProps) => {\n const triggerRefElement = useRef<HTMLElement | HTMLDivElement | HTMLButtonElement | null>(null);\n const linkRef = useRef<HTMLAnchorElement | null>(null);\n const { linkProps } = useLink({}, linkRef);\n const hasLargePaddingTop = useMemo(\n () => linkUrl || brightHeader || buttons || heading || headingIcon,\n [linkUrl, brightHeader, buttons, heading, headingIcon],\n );\n\n const placement = placementMap[`${position}-${alignment}`];\n const tooltipContainerRef = useRef<HTMLDivElement | null>(null);\n const triggerElementContainerRef = useRef<HTMLDivElement | null>(null);\n const [arrowElement, setArrowElement] = useState<HTMLDivElement | null>(null);\n\n const tooltipOffset = withArrow ? 10 : 5;\n const popperInstance = usePopper(triggerRefElement?.current, tooltipContainerRef.current, {\n placement,\n strategy: 'fixed',\n modifiers: [\n {\n name: 'arrow',\n options: {\n element: arrowElement,\n },\n },\n {\n name: 'offset',\n options: {\n offset: [0, tooltipOffset],\n },\n },\n {\n name: 'flip',\n enabled: flip,\n },\n ],\n });\n\n const currentPlacement = popperInstance.state?.placement ?? position;\n const arrowStyling = getArrowClasses(currentPlacement, brightHeader, alignment);\n const [isOpen, setIsOpen] = useState(false);\n const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleShowTooltipOnHover = useCallback(() => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n setIsOpen(true);\n }, [triggerRefElement?.current]);\n\n const handleHideTooltipOnHover = useCallback(() => {\n timeoutRef.current = setTimeout(() => setIsOpen(false), hoverDelay);\n }, [triggerRefElement?.current, tooltipContainerRef?.current]);\n\n const checkIfHovered = useCallback(\n (event) => {\n const hoveredElement = event.path ?? event.composedPath?.();\n const hoverSources = [triggerRefElement, triggerElementContainerRef, tooltipContainerRef];\n\n if (hoveredElement && hoverSources.some((el) => hoveredElement.includes(el?.current))) {\n handleShowTooltipOnHover();\n }\n },\n [triggerRefElement?.current, tooltipContainerRef?.current, triggerElementContainerRef?.current],\n );\n\n const hasInteractiveElements = !!(buttons?.length || linkUrl?.length);\n const triggerProps: HTMLAttributes<HTMLElement> = {\n onMouseOver: (event) => checkIfHovered(event.nativeEvent),\n onMouseLeave: handleHideTooltipOnHover,\n onFocus: () => setIsOpen(true),\n onBlur: () => (!hasInteractiveElements ? setIsOpen(false) : null),\n };\n\n return (\n <>\n <div {...triggerProps} ref={triggerElementContainerRef}>\n {triggerElement &&\n cloneElement(triggerElement, {\n ref: triggerRefElement,\n })}\n </div>\n {createPortal(\n <div>\n {isOpen && (\n <div\n ref={tooltipContainerRef}\n className=\"tw-popper-container tw-inline-block tw-max-w-[200px] tw-bg-black-100 dark:tw-bg-white tw-rounded-md tw-shadow-mid tw-text-white dark:tw-text-black-100 tw-z-[120000]\"\n data-test-id=\"tooltip\"\n role=\"tooltip\"\n style={popperInstance.styles.popper}\n {...popperInstance.attributes.popper}\n onFocus={() => setIsOpen(true)}\n onMouseOver={(event) => checkIfHovered(event.nativeEvent)}\n onMouseLeave={handleHideTooltipOnHover}\n >\n {brightHeader && <BrightHeader headerStyle={brightHeader} />}\n <div\n className={merge([\n 'tw-px-4',\n hasLargePaddingTop ? paddingsTop.small : paddingsTop.large,\n linkUrl ? paddingsBottom.small : paddingsBottom.large,\n ])}\n >\n {heading && (\n <h4 className=\"tw-flex tw-text-m tw-font-bold tw-mb-1\">\n {headingIcon && (\n <span className=\"tw-mr-1.5\">\n {cloneElement(headingIcon, { size: IconSize.Size20 })}\n </span>\n )}\n {heading}\n </h4>\n )}\n <div className=\"tw-flex\">\n {tooltipIcon && (\n <span className=\"tw-shrink-0 tw-mr-1\">\n {cloneElement(tooltipIcon, { size: IconSize.Size16 })}\n </span>\n )}\n <p className=\"tw-text-s\">{content}</p>\n </div>\n {linkUrl && (\n <a\n {...linkProps}\n data-test-id=\"tooltip-link\"\n ref={linkRef}\n href={linkUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className={merge([\n 'tw-text-xs tw-text-black-40 dark:tw-text-black-80 tw-underline tw-mt-1',\n FOCUS_VISIBLE_STYLE,\n ])}\n onBlur={() => (buttons && buttons.length > 0 ? null : setIsOpen(false))}\n >\n {linkLabel ?? 'Click here to learn more.'}\n </a>\n )}\n {buttons && (\n <div className=\"tw-flex tw-flex-row-reverse tw-gap-x-1 tw-mt-4\">\n {buttons.length > 0 && (\n <div\n onBlur={() => (buttons && buttons.length < 2 ? setIsOpen(false) : null)}\n >\n <Button\n style={ButtonStyle.Primary}\n size={ButtonSize.Small}\n inverted\n onClick={buttons[0].action}\n >\n {buttons[0].label}\n </Button>\n </div>\n )}\n {buttons.length === 2 && (\n <div onBlur={() => setIsOpen(false)}>\n <Button\n style={ButtonStyle.Secondary}\n size={ButtonSize.Small}\n inverted\n onClick={buttons[1].action}\n >\n {buttons[1].label}\n </Button>\n </div>\n )}\n </div>\n )}\n <div\n data-test-id=\"popover-arrow\"\n data-popper-arrow={withArrow}\n ref={setArrowElement}\n style={popperInstance.styles.arrow}\n className={merge([\n withArrow &&\n 'tw-popper-arrow tw-absolute tw-w-3 tw-h-3 tw-pointer-events-none before:tw-absolute before:tw-w-3 before:tw-h-3 before:tw-rotate-45 before:tw-border before:tw-border-line',\n withArrow && arrowStyling,\n ])}\n />\n </div>\n {children}\n </div>\n )}\n </div>,\n document.body,\n )}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAkDA,MAAM,IAAc;AAAA,EAChB,OAAO;AAAA,EACP,OAAO;AACX,GAEM,IAAiB;AAAA,EACnB,OAAO;AAAA,EACP,OAAO;AACX;AAEY,IAAA,uBAAA,MACF,GAAA,MAAA,OACE,EAAA,QAAA,SACC,EAAA,SAAA,UACF,EAAA,OAAA,QAJC,IAAA,MAAA,CAAA,CAAA,GAOA,uBAAA,MACA,GAAA,QAAA,SACC,EAAA,SAAA,UACH,EAAA,MAAA,OAHE,IAAA,MAAA,CAAA,CAAA;AAMZ,MAAM,KAA4E;AAAA,EAC9E,CAAC,cAAc;AAAA,EACf,CAAC,YAAY;AAAA,EACb,CAAC,iBAAiB;AAAA,EAClB,CAAC,eAAe;AAAA,EAChB,CAAC,eAAe;AAAA,EAChB,CAAC,aAAa;AAAA,EACd,CAAC,gBAAgB;AAAA,EACjB,CAAC,cAAc;AAAA,EACf,CAAC,eAAe;AAAA,EAChB,CAAC,iBAAiB;AAAA,EAClB,CAAC,kBAAkB;AAAA,EACnB,CAAC,gBAAgB;AACrB,GAEM,KAAkB,CAAC,GAA0B,GAA6C,MAAsB;AAC1G,UAAA;AAAA,SACC,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