@frontify/fondue 12.0.8 → 12.0.10
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/ActionMenu/ActionMenu.es.js.map +1 -1
- package/dist/components/ActionMenu/Aria/AriaMenuItem.es.js +32 -35
- package/dist/components/ActionMenu/Aria/AriaMenuItem.es.js.map +1 -1
- package/dist/components/LinkChooser/LinkChooser.es.js.map +1 -1
- package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/EditLinkModal/EditModal.es.js +8 -8
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +24 -0
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/packages/components/style.css +1 -1
- package/dist/packages/tokens/tailwind.config.js +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionMenu.es.js","sources":["../../../../src/components/ActionMenu/ActionMenu/ActionMenu.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useMenu } from '@react-aria/menu';\nimport { useTreeState } from '@react-stately/tree';\nimport { type FocusStrategy } from '@react-types/shared';\nimport { type ReactElement, useRef } from 'react';\n\nimport { AriaList } from '@components/ActionMenu/Aria/AriaList';\nimport { AriaMenuItem } from '@components/ActionMenu/Aria/AriaMenuItem';\nimport { AriaSection } from '@components/ActionMenu/Aria/AriaSection';\nimport { getDisabledItemIds, getKeyItemRecord, getMenuItems, mapToAriaProps } from '@components/ActionMenu/Aria/helper';\nimport { type MenuItemType } from '@components/Dropdown/SelectMenu/SelectMenu';\n\nexport type ActionMenuItemType = MenuItemType & { onClick: () => void };\nexport type ActionMenuSwitchItemType = MenuItemType & {\n onClick: (switchValue: boolean) => void;\n type: 'switch';\n initialValue: boolean;\n};\n\nexport type ActionMenuBlock = {\n id: string;\n menuItems: (ActionMenuItemType | ActionMenuSwitchItemType)[];\n ariaLabel?: string;\n};\n\nexport type ActionMenuProps = {\n ariaLabel?: string;\n menuBlocks: ActionMenuBlock[];\n focus?: FocusStrategy;\n border?: boolean;\n scrollable?: boolean;\n onClick?: () => void;\n};\n\nexport const ActionMenu = ({\n menuBlocks,\n ariaLabel = 'Action Menu',\n focus,\n border = true,\n scrollable = false,\n onClick,\n}: ActionMenuProps): ReactElement<ActionMenuProps> => {\n const items = getMenuItems(menuBlocks);\n const keyItemRecord = getKeyItemRecord(items);\n const props = mapToAriaProps(ariaLabel, menuBlocks);\n const state = useTreeState({\n ...props,\n selectionMode: 'none',\n disabledKeys: getDisabledItemIds(items),\n });\n const menuRef = useRef<HTMLUListElement | null>(null);\n const { menuProps } = useMenu({ ...props, autoFocus: focus }, state, menuRef);\n\n return (\n <AriaList ariaProps={{ ...menuProps }} ref={menuRef} border={border} scrollable={scrollable}>\n {[...state.collection].map((section) => {\n const { key: sectionKey, 'aria-label': sectionAriaLabel } = section;\n\n return (\n <AriaSection key={sectionKey} ariaLabel={sectionAriaLabel}>\n {[...section.childNodes].map((item) => (\n <AriaMenuItem\n key={item.key}\n menuItem={keyItemRecord[item.key as string]}\n state={state}\n node={item}\n onClick={onClick}\n />\n ))}\n </AriaSection>\n );\n })}\n </AriaList>\n );\n};\nActionMenu.displayName = 'FondueActionMenu';\n"],"names":["ActionMenu","menuBlocks","ariaLabel","focus","border","scrollable","onClick","items","getMenuItems","keyItemRecord","getKeyItemRecord","props","mapToAriaProps","state","useTreeState","getDisabledItemIds","menuRef","useRef","menuProps","useMenu","AriaList","section","sectionKey","sectionAriaLabel","jsx","AriaSection","item","AriaMenuItem"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"ActionMenu.es.js","sources":["../../../../src/components/ActionMenu/ActionMenu/ActionMenu.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useMenu } from '@react-aria/menu';\nimport { useTreeState } from '@react-stately/tree';\nimport { type FocusStrategy } from '@react-types/shared';\nimport { type ReactElement, useRef } from 'react';\n\nimport { AriaList } from '@components/ActionMenu/Aria/AriaList';\nimport { AriaMenuItem } from '@components/ActionMenu/Aria/AriaMenuItem';\nimport { AriaSection } from '@components/ActionMenu/Aria/AriaSection';\nimport { getDisabledItemIds, getKeyItemRecord, getMenuItems, mapToAriaProps } from '@components/ActionMenu/Aria/helper';\nimport { type MenuItemType } from '@components/Dropdown/SelectMenu/SelectMenu';\n\nexport type ActionMenuItemType = MenuItemType & { onClick: () => void };\nexport type ActionMenuSwitchItemType = MenuItemType & {\n onClick: (switchValue: boolean) => void;\n type: 'switch';\n initialValue: boolean;\n};\n\nexport type ActionMenuBlock = {\n id: string;\n menuItems: (ActionMenuItemType | ActionMenuSwitchItemType)[];\n ariaLabel?: string;\n};\n\nexport type ActionMenuProps = {\n ariaLabel?: string;\n menuBlocks: ActionMenuBlock[];\n focus?: FocusStrategy;\n border?: boolean;\n scrollable?: boolean;\n /**\n * @deprecated Use the onClick method available on each `menuItem` in the `menuBlocks` instead.\n * @example\n * <ActionMenu\n menuBlocks={[\n {\n id: 'menu-block-1',\n menuItems: [\n {\n id: 'menu-item-1',\n label: 'Item 1',\n onClick: () => console.log('Item 1 clicked');\n },\n ],\n },\n ]}\n />\n * */\n onClick?: () => void;\n};\n\nexport const ActionMenu = ({\n menuBlocks,\n ariaLabel = 'Action Menu',\n focus,\n border = true,\n scrollable = false,\n onClick,\n}: ActionMenuProps): ReactElement<ActionMenuProps> => {\n const items = getMenuItems(menuBlocks);\n const keyItemRecord = getKeyItemRecord(items);\n const props = mapToAriaProps(ariaLabel, menuBlocks);\n const state = useTreeState({\n ...props,\n selectionMode: 'none',\n disabledKeys: getDisabledItemIds(items),\n });\n const menuRef = useRef<HTMLUListElement | null>(null);\n const { menuProps } = useMenu({ ...props, autoFocus: focus }, state, menuRef);\n\n return (\n <AriaList ariaProps={{ ...menuProps }} ref={menuRef} border={border} scrollable={scrollable}>\n {[...state.collection].map((section) => {\n const { key: sectionKey, 'aria-label': sectionAriaLabel } = section;\n\n return (\n <AriaSection key={sectionKey} ariaLabel={sectionAriaLabel}>\n {[...section.childNodes].map((item) => (\n <AriaMenuItem\n key={item.key}\n menuItem={keyItemRecord[item.key as string]}\n state={state}\n node={item}\n onClick={onClick}\n />\n ))}\n </AriaSection>\n );\n })}\n </AriaList>\n );\n};\nActionMenu.displayName = 'FondueActionMenu';\n"],"names":["ActionMenu","menuBlocks","ariaLabel","focus","border","scrollable","onClick","items","getMenuItems","keyItemRecord","getKeyItemRecord","props","mapToAriaProps","state","useTreeState","getDisabledItemIds","menuRef","useRef","menuProps","useMenu","AriaList","section","sectionKey","sectionAriaLabel","jsx","AriaSection","item","AriaMenuItem"],"mappings":";;;;;;;;AAqDO,MAAMA,IAAa,CAAC;AAAA,EACvB,YAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,OAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,YAAAC,IAAa;AAAA,EACb,SAAAC;AACJ,MAAsD;AAC5C,QAAAC,IAAQC,EAAaP,CAAU,GAC/BQ,IAAgBC,EAAiBH,CAAK,GACtCI,IAAQC,EAAeV,GAAWD,CAAU,GAC5CY,IAAQC,EAAa;AAAA,IACvB,GAAGH;AAAA,IACH,eAAe;AAAA,IACf,cAAcI,EAAmBR,CAAK;AAAA,EAAA,CACzC,GACKS,IAAUC,EAAgC,IAAI,GAC9C,EAAE,WAAAC,EAAU,IAAIC,EAAQ,EAAE,GAAGR,GAAO,WAAWR,EAAS,GAAAU,GAAOG,CAAO;AAE5E,2BACKI,GAAS,EAAA,WAAW,EAAE,GAAGF,EAAA,GAAa,KAAKF,GAAS,QAAAZ,GAAgB,YAAAC,GAChE,WAAC,GAAGQ,EAAM,UAAU,EAAE,IAAI,CAACQ,MAAY;AACpC,UAAM,EAAE,KAAKC,GAAY,cAAcC,MAAqBF;AAGxD,WAAA,gBAAAG,EAACC,GAA6B,EAAA,WAAWF,GACpC,UAAA,CAAC,GAAGF,EAAQ,UAAU,EAAE,IAAI,CAACK,MAC1B,gBAAAF;AAAA,MAACG;AAAA,MAAA;AAAA,QAEG,UAAUlB,EAAciB,EAAK,GAAa;AAAA,QAC1C,OAAAb;AAAA,QACA,MAAMa;AAAA,QACN,SAAApB;AAAA,MAAA;AAAA,MAJKoB,EAAK;AAAA,IAAA,CAMjB,KATaJ,CAUlB;AAAA,EAEP,CAAA,EACL,CAAA;AAER;AACAtB,EAAW,cAAc;"}
|
|
@@ -1,69 +1,66 @@
|
|
|
1
1
|
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { useFocusRing as
|
|
3
|
-
import { useMenuItem as
|
|
2
|
+
import { useFocusRing as C } from "@react-aria/focus";
|
|
3
|
+
import { useMenuItem as A } from "@react-aria/menu";
|
|
4
4
|
import { mergeProps as x } from "@react-aria/utils";
|
|
5
|
-
import { useRef as F, useState as d, useEffect as
|
|
6
|
-
import { MenuItem as
|
|
7
|
-
import { FOCUS_STYLE_INSET as
|
|
8
|
-
import { merge as
|
|
9
|
-
import { Switch as
|
|
10
|
-
const z = (
|
|
11
|
-
const [
|
|
5
|
+
import { useRef as F, useState as d, useEffect as j } from "react";
|
|
6
|
+
import { MenuItem as E } from "../../MenuItem/MenuItem.es.js";
|
|
7
|
+
import { FOCUS_STYLE_INSET as N } from "../../../utilities/focusStyle.es.js";
|
|
8
|
+
import { merge as O } from "../../../utilities/merge.es.js";
|
|
9
|
+
import { Switch as P } from "../../Switch/Switch.es.js";
|
|
10
|
+
const z = (t) => typeof t.onClick < "u" && typeof t.type > "u", n = (t) => typeof t.onClick < "u" && t.type === "switch", R = (t, e) => {
|
|
11
|
+
const [o, l] = d(e ?? !1), [i, s] = d({
|
|
12
12
|
switchComponent: void 0,
|
|
13
13
|
switchValue: null,
|
|
14
14
|
toggleSwitch: null
|
|
15
15
|
});
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
switchComponent: /* @__PURE__ */ r(
|
|
19
|
-
switchValue:
|
|
20
|
-
toggleSwitch: () => l(!
|
|
16
|
+
return j(() => {
|
|
17
|
+
t && s({
|
|
18
|
+
switchComponent: /* @__PURE__ */ r(P, { size: "small", mode: o ? "on" : "off" }),
|
|
19
|
+
switchValue: o,
|
|
20
|
+
toggleSwitch: () => l(!o)
|
|
21
21
|
});
|
|
22
|
-
}, [
|
|
23
|
-
}, T = ({ menuItem:
|
|
24
|
-
const s = F(null), a =
|
|
22
|
+
}, [t, o]), i;
|
|
23
|
+
}, T = ({ menuItem: t, node: e, state: o, isSelected: l, onClick: i }) => {
|
|
24
|
+
const s = F(null), a = n(t) ? t.initialValue : !1, {
|
|
25
25
|
switchComponent: f = void 0,
|
|
26
26
|
switchValue: w = null,
|
|
27
|
-
toggleSwitch:
|
|
28
|
-
} = R(
|
|
27
|
+
toggleSwitch: c = null
|
|
28
|
+
} = R(n(t), a), { menuItemProps: h } = A(
|
|
29
29
|
{
|
|
30
30
|
...e,
|
|
31
31
|
onAction: () => {
|
|
32
|
-
z(
|
|
32
|
+
z(t) && t.onClick(), n(t) && (c == null || c(), t.onClick(!w));
|
|
33
33
|
},
|
|
34
|
-
isDisabled: (
|
|
35
|
-
"aria-label": typeof (
|
|
34
|
+
isDisabled: (t == null ? void 0 : t.disabled) || !1,
|
|
35
|
+
"aria-label": typeof (t == null ? void 0 : t.title) == "string" ? t == null ? void 0 : t.title : "Menu item"
|
|
36
36
|
},
|
|
37
|
-
|
|
37
|
+
o,
|
|
38
38
|
s
|
|
39
|
-
), { title: u, decorator: b, subtitle:
|
|
39
|
+
), { title: u, decorator: b, subtitle: S, size: g, style: y, disabled: p, selectionIndicator: v } = t, { isFocusVisible: M, focusProps: V } = C();
|
|
40
40
|
return (
|
|
41
41
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions
|
|
42
42
|
/* @__PURE__ */ r(
|
|
43
43
|
"li",
|
|
44
44
|
{
|
|
45
|
-
...x(h,
|
|
45
|
+
...x(h, V, { onClick: () => i == null ? void 0 : i() }),
|
|
46
46
|
"data-test-id": "menu-item",
|
|
47
|
-
className:
|
|
47
|
+
className: O([
|
|
48
48
|
"tw-relative hover:tw-bg-box-neutral-hover tw-list-none tw-outline-none",
|
|
49
49
|
p && "tw-pointer-events-none tw-top-px",
|
|
50
|
-
|
|
50
|
+
M && N
|
|
51
51
|
]),
|
|
52
52
|
ref: s,
|
|
53
|
-
onClick: (V) => {
|
|
54
|
-
V.stopPropagation(), i && i();
|
|
55
|
-
},
|
|
56
53
|
children: /* @__PURE__ */ r(
|
|
57
|
-
|
|
54
|
+
E,
|
|
58
55
|
{
|
|
59
56
|
title: u,
|
|
60
57
|
decorator: b,
|
|
61
|
-
subtitle:
|
|
62
|
-
size:
|
|
63
|
-
style:
|
|
58
|
+
subtitle: S,
|
|
59
|
+
size: g,
|
|
60
|
+
style: y,
|
|
64
61
|
disabled: p,
|
|
65
62
|
active: l,
|
|
66
|
-
selectionIndicator:
|
|
63
|
+
selectionIndicator: v,
|
|
67
64
|
switchComponent: f
|
|
68
65
|
}
|
|
69
66
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AriaMenuItem.es.js","sources":["../../../../src/components/ActionMenu/Aria/AriaMenuItem.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useFocusRing } from '@react-aria/focus';\nimport { useMenuItem } from '@react-aria/menu';\nimport { mergeProps } from '@react-aria/utils';\nimport { type TreeState } from '@react-stately/tree';\nimport { type Node } from '@react-types/shared';\nimport { type ReactElement, useEffect, useRef, useState } from 'react';\n\nimport { type ActionMenuItemType, type ActionMenuSwitchItemType } from '@components/ActionMenu';\nimport { type MenuItemType } from '@components/Dropdown';\nimport { MenuItem } from '@components/MenuItem/MenuItem';\nimport { Switch } from '@components/Switch';\nimport { FOCUS_STYLE_INSET } from '@utilities/focusStyle';\nimport { merge } from '@utilities/merge';\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\ninterface SwitchObject {\n switchComponent: ReactElement | undefined;\n switchValue: boolean | null;\n toggleSwitch: VoidFunction | null;\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 = (isSwitch: boolean, initialValue: boolean) => {\n const [switchValue, setSwitchValue] = useState<boolean>(initialValue ?? false);\n const [switchObject, setSwitchObject] = useState<SwitchObject>({\n switchComponent: undefined,\n switchValue: null,\n toggleSwitch: null,\n });\n\n useEffect(() => {\n if (isSwitch) {\n const toggleSwitch = () => setSwitchValue(!switchValue);\n const switchComponent = <Switch size=\"small\" mode={switchValue ? 'on' : 'off'} />;\n\n setSwitchObject({\n switchComponent,\n switchValue,\n toggleSwitch,\n });\n }\n }, [isSwitch, switchValue]);\n\n return switchObject;\n};\n\nexport const AriaMenuItem = ({ menuItem, node, state, isSelected, onClick }: AriaOptionProps): ReactElement => {\n const ref = useRef<HTMLLIElement | null>(null);\n const initialValue = isActionMenuSwitchItem(menuItem) ? menuItem.initialValue : false;\n const {\n switchComponent = undefined,\n switchValue = null,\n toggleSwitch = null,\n } = useSwitch(isActionMenuSwitchItem(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-box-neutral-hover 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
|
|
1
|
+
{"version":3,"file":"AriaMenuItem.es.js","sources":["../../../../src/components/ActionMenu/Aria/AriaMenuItem.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useFocusRing } from '@react-aria/focus';\nimport { useMenuItem } from '@react-aria/menu';\nimport { mergeProps } from '@react-aria/utils';\nimport { type TreeState } from '@react-stately/tree';\nimport { type Node } from '@react-types/shared';\nimport { type ReactElement, useEffect, useRef, useState } from 'react';\n\nimport { type ActionMenuItemType, type ActionMenuSwitchItemType } from '@components/ActionMenu';\nimport { type MenuItemType } from '@components/Dropdown';\nimport { MenuItem } from '@components/MenuItem/MenuItem';\nimport { Switch } from '@components/Switch';\nimport { FOCUS_STYLE_INSET } from '@utilities/focusStyle';\nimport { merge } from '@utilities/merge';\n\nexport type AriaOptionProps = {\n menuItem: MenuItemType | ActionMenuItemType | ActionMenuSwitchItemType;\n node: Node<object>;\n isSelected?: boolean;\n state: TreeState<object>;\n /**\n * @deprecated Use `menuItem.onClick` instead\n * */\n onClick?: () => void;\n};\n\ninterface SwitchObject {\n switchComponent: ReactElement | undefined;\n switchValue: boolean | null;\n toggleSwitch: VoidFunction | null;\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 = (isSwitch: boolean, initialValue: boolean) => {\n const [switchValue, setSwitchValue] = useState<boolean>(initialValue ?? false);\n const [switchObject, setSwitchObject] = useState<SwitchObject>({\n switchComponent: undefined,\n switchValue: null,\n toggleSwitch: null,\n });\n\n useEffect(() => {\n if (isSwitch) {\n const toggleSwitch = () => setSwitchValue(!switchValue);\n const switchComponent = <Switch size=\"small\" mode={switchValue ? 'on' : 'off'} />;\n\n setSwitchObject({\n switchComponent,\n switchValue,\n toggleSwitch,\n });\n }\n }, [isSwitch, switchValue]);\n\n return switchObject;\n};\n\nexport const AriaMenuItem = ({ menuItem, node, state, isSelected, onClick }: AriaOptionProps): ReactElement => {\n const ref = useRef<HTMLLIElement | null>(null);\n const initialValue = isActionMenuSwitchItem(menuItem) ? menuItem.initialValue : false;\n const {\n switchComponent = undefined,\n switchValue = null,\n toggleSwitch = null,\n } = useSwitch(isActionMenuSwitchItem(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, { onClick: () => onClick?.() })}\n data-test-id=\"menu-item\"\n className={merge([\n 'tw-relative hover:tw-bg-box-neutral-hover 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 >\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};\nAriaMenuItem.displayName = 'FondueAriaMenuItem';\n"],"names":["isActionMenuItem","menuItem","isActionMenuSwitchItem","useSwitch","isSwitch","initialValue","switchValue","setSwitchValue","useState","switchObject","setSwitchObject","useEffect","Switch","AriaMenuItem","node","state","isSelected","onClick","ref","useRef","switchComponent","toggleSwitch","menuItemProps","useMenuItem","title","decorator","subtitle","size","style","disabled","selectionIndicator","isFocusVisible","focusProps","useFocusRing","jsx","mergeProps","merge","FOCUS_STYLE_INSET","MenuItem"],"mappings":";;;;;;;;;AAiCA,MAAMA,IAAmB,CACrBC,MAEA,OAAQA,EAAgC,UAAY,OAAe,OAAOA,EAAS,OAAS,KAC1FC,IAAyB,CAC3BD,MAEA,OAAQA,EAAsC,UAAY,OAAeA,EAAS,SAAS,UAEzFE,IAAY,CAACC,GAAmBC,MAA0B;AAC5D,QAAM,CAACC,GAAaC,CAAc,IAAIC,EAAkBH,KAAgB,EAAK,GACvE,CAACI,GAAcC,CAAe,IAAIF,EAAuB;AAAA,IAC3D,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,cAAc;AAAA,EAAA,CACjB;AAED,SAAAG,EAAU,MAAM;AACZ,IAAIP,KAIgBM,EAAA;AAAA,MACZ,mCAHqBE,GAAO,EAAA,MAAK,SAAQ,MAAMN,IAAc,OAAO,MAAO,CAAA;AAAA,MAI3E,aAAAA;AAAA,MACA,cANiB,MAAMC,EAAe,CAACD,CAAW;AAAA,IAMlD,CACH;AAAA,EACL,GACD,CAACF,GAAUE,CAAW,CAAC,G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,OAAAd;AAAA,YACA,WAAAC;AAAA,YACA,UAAAC;AAAA,YACA,MAAAC;AAAA,YACA,OAAAC;AAAA,YACA,UAAAC;AAAA,YACA,QAAQb;AAAA,YACR,oBAAAc;AAAA,YACA,iBAAAV;AAAA,UAAA;AAAA,QACJ;AAAA,MAAA;AAAA,IACJ;AAAA;AAER;AACAP,EAAa,cAAc;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkChooser.es.js","sources":["../../../src/components/LinkChooser/LinkChooser.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useComboBox } from '@react-aria/combobox';\nimport { DismissButton } from '@react-aria/overlays';\nimport { scrollIntoView } from '@react-aria/utils';\nimport { useComboBoxState } from '@react-stately/combobox';\nimport { useMachine } from '@xstate/react';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { type Key, type MouseEvent, type ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { mapToAriaProps } from '@components/ActionMenu/Aria/helper';\nimport { Checkbox, CheckboxState } from '@components/Checkbox/Checkbox';\nimport IconArrowOutExternal from '@foundation/Icon/Generated/IconArrowOutExternal';\nimport IconBuildingBlock from '@foundation/Icon/Generated/IconBuildingBlock';\nimport IconDocument from '@foundation/Icon/Generated/IconDocument';\nimport IconDocumentStack from '@foundation/Icon/Generated/IconDocumentStack';\nimport IconLayersSingle from '@foundation/Icon/Generated/IconLayersSingle';\nimport IconLink from '@foundation/Icon/Generated/IconLink';\nimport { useDropdownAutoHeight } from '@hooks/useDropdownAutoHeight';\nimport { Validation } from '@utilities/validation';\n\nimport { NavigationMenu } from './NavigationMenu';\nimport { Popover } from './Popover';\nimport { SearchInput } from './SearchInput';\nimport { SearchResultsList } from './SearchResultsList';\nimport { defaultSection } from './sections';\nimport { linkChooserMachine } from './state/machine';\nimport { LinkChooserState } from './state/types';\nimport { IconName, type LinkChooserProps, type SearchMenuBlock } from './types';\nimport { decoratedResults, doesContainSubstring, findSection, getDefaultData } from './utils/helpers';\nimport { closeBoxState, isLoaded, openBoxState, queryMatchesSelection, shouldGoBack } from './utils/state';\nimport { createCustomLink } from './utils/transformers';\nimport { useManualComboBoxEventHandlers } from './utils/useManualComboBoxHandlers';\n\nexport const IconOptions: Record<IconName | string, ReactElement> = {\n [IconName.Document]: <IconDocument />,\n [IconName.Library]: <IconDocumentStack />,\n [IconName.Link]: <IconLink />,\n [IconName.External]: <IconArrowOutExternal />,\n [IconName.Template]: <IconLayersSingle />,\n [IconName.Block]: <IconBuildingBlock />,\n};\n\nexport const DEFAULT_ICON = IconName.Link;\nexport const CUSTOM_LINK_ID = 'custom-link';\nexport const MAX_STORED_ITEMS = 5;\nexport const QUERIES_STORAGE_KEY = 'queries';\n\nexport const LinkChooser = ({\n getGlobalByQuery = getDefaultData,\n openPreview = window.open,\n clipboardOptions = navigator.clipboard,\n selectedResult = null,\n openInNewTab = false,\n ariaLabel = 'Menu',\n extraSections = [],\n label,\n placeholder,\n onOpenInNewTabChange,\n onLinkChange,\n disabled,\n clearable,\n required,\n validation = Validation.Default,\n 'data-test-id': dataTestId = 'link-chooser',\n}: LinkChooserProps): ReactElement => {\n const [{ context, matches, value }, send, service] = useMachine(() =>\n linkChooserMachine.withContext({\n searchResults: [],\n selectedResult,\n query: '',\n interruptedFetch: false,\n getExtraResultsByQuery: null,\n currentSectionId: defaultSection.id,\n extraSections,\n clipboardOptions,\n openPreview,\n getGlobalByQuery,\n onLinkChange,\n }),\n );\n\n const [searchInput, setSearchInput] = useState(selectedResult?.title);\n const isDefault = !shouldGoBack(matches);\n const searchResultMenuBlocks = useMemo(\n () =>\n [\n !isDefault && { id: 'menu-top', menuItems: [findSection(extraSections, context.currentSectionId)] },\n {\n id: 'search',\n menuItems: decoratedResults(context.searchResults),\n },\n isDefault && { id: 'menu-bottom', menuItems: extraSections.map(({ id, title }) => ({ id, title })) },\n ].filter(Boolean),\n [isDefault, extraSections, context.currentSectionId, context.searchResults],\n ) as SearchMenuBlock[];\n\n const props = mapToAriaProps(ariaLabel, searchResultMenuBlocks);\n\n const triggerRef = useRef<HTMLDivElement | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n const listBoxRef = useRef<HTMLUListElement | null>(null);\n const popoverRef = useRef<HTMLDivElement | null>(null);\n\n const handleSelectionChange = (key: Key) => {\n const foundItem = context.searchResults.find((item) => item.id === key);\n if (foundItem) {\n setSearchInput(foundItem.title);\n send({ type: 'SET_SELECTED_SEARCH_RESULT', data: { selectedResult: foundItem } });\n }\n closeBoxState(state);\n setSelectedKey(key);\n };\n\n const handleInputChange = useCallback(\n (query: string) => {\n setSearchInput(query);\n send({ type: 'TYPING', data: { query } });\n },\n [send],\n );\n\n const [selectedKey, setSelectedKey] = useState<Key | undefined>(context.selectedResult?.id);\n\n const state = useComboBoxState({\n ...props,\n defaultFilter: (textValue, inputValue) => doesContainSubstring(textValue, inputValue, extraSections),\n inputValue: searchInput,\n onInputChange: handleInputChange,\n onSelectionChange: handleSelectionChange,\n menuTrigger: 'manual',\n shouldCloseOnBlur: false,\n allowsEmptyCollection: true,\n selectedKey,\n });\n\n const { inputProps, listBoxProps, labelProps } = useComboBox(\n {\n ...props,\n inputRef,\n listBoxRef,\n popoverRef,\n isRequired: required,\n placeholder,\n },\n state,\n );\n\n const handleClearClick = useCallback(() => {\n state.setInputValue('');\n setSelectedKey('');\n send({ type: 'CLEARING', data: { query: '' } });\n }, [send, state]);\n\n const handleDropdownOpen = () => {\n send('OPEN_DROPDOWN');\n openBoxState(state);\n };\n\n const handleWrapperClick = () => {\n if (document.activeElement !== inputRef.current) {\n inputRef.current?.focus();\n }\n handleDropdownOpen();\n };\n\n const handleWrapperMouseDown = (event: MouseEvent<HTMLDivElement>) => {\n if (matches(LinkChooserState.Focused) && event.target !== inputRef.current) {\n event.preventDefault();\n }\n };\n\n const handleDropdownClose = () => {\n let selectedResult = null;\n if (context.query) {\n if (queryMatchesSelection(context.selectedResult, context.query)) {\n selectedResult = context.selectedResult;\n } else {\n selectedResult = createCustomLink(state.inputValue);\n }\n }\n send({ type: 'CLOSE_DROPDOWN', data: { selectedResult } });\n if (selectedResult && selectedKey !== selectedResult.id) {\n setSelectedKey(selectedResult.id);\n }\n closeBoxState(state);\n };\n\n const manualInputProps = useManualComboBoxEventHandlers(\n { inputProps, inputRef, popoverRef, state },\n {\n onOpen: handleDropdownOpen,\n onClose: handleDropdownClose,\n onNavigate: (id) => {\n if (isDefault) {\n send({\n type: 'SELECT_EXTRA_SECTION',\n data: {\n getExtraResultsByQuery: findSection(extraSections, id)?.getResults || null,\n currentSectionId: id.toString(),\n },\n });\n } else {\n send({\n type: 'BACK_TO_DEFAULT',\n data: { getExtraResultsByQuery: null },\n });\n }\n },\n onSelect: handleSelectionChange,\n },\n );\n\n useEffect(() => {\n if (isLoaded(matches) && context.interruptedFetch) {\n send({ type: 'TYPING', data: { query: context.query } });\n }\n }, [context.interruptedFetch, context.query, matches, send, value]);\n\n const { maxHeight } = useDropdownAutoHeight(inputRef, {\n isOpen: matches(LinkChooserState.Focused),\n autoResize: true,\n });\n\n const {\n isOpen,\n selectionManager: { focusedKey },\n } = state;\n\n useEffect(() => {\n if (focusedKey && popoverRef.current && isOpen) {\n const dropdownItem = popoverRef.current.querySelector(`[data-key=\"${focusedKey}\"]`);\n if (dropdownItem) {\n scrollIntoView(popoverRef.current, dropdownItem as HTMLElement);\n }\n }\n }, [focusedKey, isOpen]);\n\n const [flyoutWidth, setFlyoutWidth] = useState(0);\n\n const calcFlyoutWidth = () => {\n setFlyoutWidth(triggerRef.current?.getBoundingClientRect().width || 0);\n };\n\n useEffect(() => {\n calcFlyoutWidth();\n window.addEventListener('resize', calcFlyoutWidth, false);\n }, []);\n\n return (\n <div data-test-id={dataTestId} ref={triggerRef} className=\"tw-w-full tw-font-sans tw-text-s\">\n {!!label && (\n <label\n {...labelProps}\n data-test-id={`${dataTestId}-label`}\n className=\"tw-text-black-80 tw-mb-1 tw-flex tw-align-items-center\"\n >\n {label}\n {required && (\n <span\n data-test-id={`${dataTestId}-label-required`}\n className=\"tw-h-4 tw-text-m tw-text-red-60 dark:tw-text-red-50 tw-ml-1\"\n >\n *\n </span>\n )}\n </label>\n )}\n <SearchInput\n ariaProps={manualInputProps}\n selectedResult={context.selectedResult}\n ref={inputRef}\n disabled={disabled}\n decorator={IconOptions[context.selectedResult?.icon || DEFAULT_ICON]}\n clearable={clearable}\n onClear={handleClearClick}\n machineService={service}\n validation={validation}\n onClick={handleWrapperClick}\n onMouseDown={handleWrapperMouseDown}\n />\n <AnimatePresence>\n {matches(LinkChooserState.Focused) && (\n <motion.div\n style={{\n width: flyoutWidth,\n }}\n className=\"tw-absolute tw-left-auto tw-w-full tw-overflow-hidden tw-p-0 tw-shadow-mid tw-list-none tw-m-0 tw-mt-2 tw-z-20\"\n key=\"content\"\n initial={{ height: 0 }}\n animate={{ height: 'auto' }}\n exit={{ height: 0 }}\n transition={{ ease: [0.04, 0.62, 0.23, 0.98], duration: 0.5 }}\n data-test-id={`${dataTestId}-dropdown`}\n >\n <DismissButton onDismiss={handleDropdownClose} />\n <Popover\n popoverRef={popoverRef}\n isOpen={matches(LinkChooserState.Focused)}\n onClose={handleDropdownClose}\n maxHeight={maxHeight}\n >\n <SearchResultsList\n {...listBoxProps}\n listBoxRef={listBoxRef}\n state={state}\n menuBlocks={searchResultMenuBlocks}\n border={false}\n machineService={service}\n />\n <div data-test-id={`${dataTestId}-action-menu`} className=\"tw-border-t tw-border-black-10\">\n <NavigationMenu machineService={service} state={state} />\n </div>\n </Popover>\n <DismissButton onDismiss={handleDropdownClose} />\n </motion.div>\n )}\n </AnimatePresence>\n <div className=\"tw-my-2\" data-test-id={`${dataTestId}-new-tab`}>\n <Checkbox\n value=\"new-tab\"\n disabled={disabled}\n state={openInNewTab ? CheckboxState.Checked : CheckboxState.Unchecked}\n onChange={onOpenInNewTabChange}\n label=\"Open in New Tab\"\n />\n </div>\n </div>\n );\n};\n"],"names":["IconOptions","IconName","IconDocument","IconDocumentStack","IconLink","IconArrowOutExternal","IconLayersSingle","IconBuildingBlock","DEFAULT_ICON","CUSTOM_LINK_ID","MAX_STORED_ITEMS","QUERIES_STORAGE_KEY","LinkChooser","getGlobalByQuery","getDefaultData","openPreview","clipboardOptions","selectedResult","openInNewTab","ariaLabel","extraSections","label","placeholder","onOpenInNewTabChange","onLinkChange","disabled","clearable","required","validation","Validation","dataTestId","context","matches","value","send","service","useMachine","linkChooserMachine","defaultSection","searchInput","setSearchInput","useState","isDefault","shouldGoBack","searchResultMenuBlocks","useMemo","findSection","decoratedResults","id","title","props","mapToAriaProps","triggerRef","useRef","inputRef","listBoxRef","popoverRef","handleSelectionChange","key","foundItem","item","closeBoxState","state","setSelectedKey","handleInputChange","useCallback","query","selectedKey","_a","useComboBoxState","textValue","inputValue","doesContainSubstring","inputProps","listBoxProps","labelProps","useComboBox","handleClearClick","handleDropdownOpen","openBoxState","handleWrapperClick","handleWrapperMouseDown","event","LinkChooserState","handleDropdownClose","queryMatchesSelection","createCustomLink","manualInputProps","useManualComboBoxEventHandlers","useEffect","isLoaded","maxHeight","useDropdownAutoHeight","isOpen","focusedKey","dropdownItem","scrollIntoView","flyoutWidth","setFlyoutWidth","calcFlyoutWidth","jsxs","jsx","SearchInput","_b","AnimatePresence","motion","DismissButton","Popover","SearchResultsList","NavigationMenu","Checkbox","CheckboxState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCO,MAAMA,KAAuD;AAAA,EAChE,CAACC,EAAS,QAAQ,qBAAIC,IAAa,CAAA,CAAA;AAAA,EACnC,CAACD,EAAS,OAAO,qBAAIE,IAAkB,CAAA,CAAA;AAAA,EACvC,CAACF,EAAS,IAAI,qBAAIG,IAAS,CAAA,CAAA;AAAA,EAC3B,CAACH,EAAS,QAAQ,qBAAII,IAAqB,CAAA,CAAA;AAAA,EAC3C,CAACJ,EAAS,QAAQ,qBAAIK,IAAiB,CAAA,CAAA;AAAA,EACvC,CAACL,EAAS,KAAK,qBAA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,WAAWtB,EAAqB,CAAA;AAAA,UAC/C,gBAAAgB;AAAA,YAACO;AAAA,YAAA;AAAA,cACG,YAAAnD;AAAA,cACA,QAAQxB,EAAQmD,EAAiB,OAAO;AAAA,cACxC,SAASC;AAAA,cACT,WAAAO;AAAA,cAEA,UAAA;AAAA,gBAAA,gBAAAU;AAAA,kBAACO;AAAA,kBAAA;AAAA,oBACI,GAAGlC;AAAA,oBACJ,YAAAnB;AAAA,oBACA,OAAAO;AAAA,oBACA,YAAYlB;AAAA,oBACZ,QAAQ;AAAA,oBACR,gBAAgBT;AAAA,kBAAA;AAAA,gBACpB;AAAA,gBACC,gBAAAkE,EAAA,OAAA,EAAI,gBAAc,GAAGvE,CAAU,gBAAgB,WAAU,kCACtD,UAAC,gBAAAuE,EAAAQ,IAAA,EAAe,gBAAgB1E,GAAS,OAAA2B,EAAc,CAAA,GAC3D;AAAA,cAAA;AAAA,YAAA;AAAA,UACJ;AAAA,UACA,gBAAAuC,EAACK,GAAc,EAAA,WAAWtB,EAAqB,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MA1B3C;AAAA,IAAA,GA6BhB;AAAA,sBACC,OAAI,EAAA,WAAU,WAAU,gBAAc,GAAGtD,CAAU,YAChD,UAAA,gBAAAuE;AAAA,MAACS;AAAA,MAAA;AAAA,QACG,OAAM;AAAA,QACN,UAAArF;AAAA,QACA,OAAOP,IAAe6F,EAAc,UAAUA,EAAc;AAAA,QAC5D,UAAUxF;AAAA,QACV,OAAM;AAAA,MAAA;AAAA,IAAA,GAEd;AAAA,EACJ,EAAA,CAAA;AAER;"}
|
|
1
|
+
{"version":3,"file":"LinkChooser.es.js","sources":["../../../src/components/LinkChooser/LinkChooser.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { useComboBox } from '@react-aria/combobox';\nimport { DismissButton } from '@react-aria/overlays';\nimport { scrollIntoView } from '@react-aria/utils';\nimport { useComboBoxState } from '@react-stately/combobox';\nimport { useMachine } from '@xstate/react';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport { type Key, type MouseEvent, type ReactElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';\n\nimport { mapToAriaProps } from '@components/ActionMenu/Aria/helper';\nimport { Checkbox, CheckboxState } from '@components/Checkbox/Checkbox';\nimport IconArrowOutExternal from '@foundation/Icon/Generated/IconArrowOutExternal';\nimport IconBuildingBlock from '@foundation/Icon/Generated/IconBuildingBlock';\nimport IconDocument from '@foundation/Icon/Generated/IconDocument';\nimport IconDocumentStack from '@foundation/Icon/Generated/IconDocumentStack';\nimport IconLayersSingle from '@foundation/Icon/Generated/IconLayersSingle';\nimport IconLink from '@foundation/Icon/Generated/IconLink';\nimport { useDropdownAutoHeight } from '@hooks/useDropdownAutoHeight';\nimport { Validation } from '@utilities/validation';\n\nimport { NavigationMenu } from './NavigationMenu';\nimport { Popover } from './Popover';\nimport { SearchInput } from './SearchInput';\nimport { SearchResultsList } from './SearchResultsList';\nimport { defaultSection } from './sections';\nimport { linkChooserMachine } from './state/machine';\nimport { LinkChooserState } from './state/types';\nimport { IconName, type LinkChooserProps, type SearchMenuBlock } from './types';\nimport { decoratedResults, doesContainSubstring, findSection, getDefaultData } from './utils/helpers';\nimport { closeBoxState, isLoaded, openBoxState, queryMatchesSelection, shouldGoBack } from './utils/state';\nimport { createCustomLink } from './utils/transformers';\nimport { useManualComboBoxEventHandlers } from './utils/useManualComboBoxHandlers';\n\nexport const IconOptions: Record<IconName | string, ReactElement> = {\n [IconName.Document]: <IconDocument />,\n [IconName.Library]: <IconDocumentStack />,\n [IconName.Link]: <IconLink />,\n [IconName.External]: <IconArrowOutExternal />,\n [IconName.Template]: <IconLayersSingle />,\n [IconName.Block]: <IconBuildingBlock />,\n};\n\nexport const DEFAULT_ICON = IconName.Link;\nexport const CUSTOM_LINK_ID = 'custom-link';\nexport const MAX_STORED_ITEMS = 5;\nexport const QUERIES_STORAGE_KEY = 'queries';\n\n/**\n * @deprecated Please use the new LinkInput component from `@frontify/guideline-block-settings`.\n */\nexport const LinkChooser = ({\n getGlobalByQuery = getDefaultData,\n openPreview = window.open,\n clipboardOptions = navigator.clipboard,\n selectedResult = null,\n openInNewTab = false,\n ariaLabel = 'Menu',\n extraSections = [],\n label,\n placeholder,\n onOpenInNewTabChange,\n onLinkChange,\n disabled,\n clearable,\n required,\n validation = Validation.Default,\n 'data-test-id': dataTestId = 'link-chooser',\n}: LinkChooserProps): ReactElement => {\n const [{ context, matches, value }, send, service] = useMachine(() =>\n linkChooserMachine.withContext({\n searchResults: [],\n selectedResult,\n query: '',\n interruptedFetch: false,\n getExtraResultsByQuery: null,\n currentSectionId: defaultSection.id,\n extraSections,\n clipboardOptions,\n openPreview,\n getGlobalByQuery,\n onLinkChange,\n }),\n );\n\n const [searchInput, setSearchInput] = useState(selectedResult?.title);\n const isDefault = !shouldGoBack(matches);\n const searchResultMenuBlocks = useMemo(\n () =>\n [\n !isDefault && { id: 'menu-top', menuItems: [findSection(extraSections, context.currentSectionId)] },\n {\n id: 'search',\n menuItems: decoratedResults(context.searchResults),\n },\n isDefault && { id: 'menu-bottom', menuItems: extraSections.map(({ id, title }) => ({ id, title })) },\n ].filter(Boolean),\n [isDefault, extraSections, context.currentSectionId, context.searchResults],\n ) as SearchMenuBlock[];\n\n const props = mapToAriaProps(ariaLabel, searchResultMenuBlocks);\n\n const triggerRef = useRef<HTMLDivElement | null>(null);\n const inputRef = useRef<HTMLInputElement | null>(null);\n const listBoxRef = useRef<HTMLUListElement | null>(null);\n const popoverRef = useRef<HTMLDivElement | null>(null);\n\n const handleSelectionChange = (key: Key) => {\n const foundItem = context.searchResults.find((item) => item.id === key);\n if (foundItem) {\n setSearchInput(foundItem.title);\n send({ type: 'SET_SELECTED_SEARCH_RESULT', data: { selectedResult: foundItem } });\n }\n closeBoxState(state);\n setSelectedKey(key);\n };\n\n const handleInputChange = useCallback(\n (query: string) => {\n setSearchInput(query);\n send({ type: 'TYPING', data: { query } });\n },\n [send],\n );\n\n const [selectedKey, setSelectedKey] = useState<Key | undefined>(context.selectedResult?.id);\n\n const state = useComboBoxState({\n ...props,\n defaultFilter: (textValue, inputValue) => doesContainSubstring(textValue, inputValue, extraSections),\n inputValue: searchInput,\n onInputChange: handleInputChange,\n onSelectionChange: handleSelectionChange,\n menuTrigger: 'manual',\n shouldCloseOnBlur: false,\n allowsEmptyCollection: true,\n selectedKey,\n });\n\n const { inputProps, listBoxProps, labelProps } = useComboBox(\n {\n ...props,\n inputRef,\n listBoxRef,\n popoverRef,\n isRequired: required,\n placeholder,\n },\n state,\n );\n\n const handleClearClick = useCallback(() => {\n state.setInputValue('');\n setSelectedKey('');\n send({ type: 'CLEARING', data: { query: '' } });\n }, [send, state]);\n\n const handleDropdownOpen = () => {\n send('OPEN_DROPDOWN');\n openBoxState(state);\n };\n\n const handleWrapperClick = () => {\n if (document.activeElement !== inputRef.current) {\n inputRef.current?.focus();\n }\n handleDropdownOpen();\n };\n\n const handleWrapperMouseDown = (event: MouseEvent<HTMLDivElement>) => {\n if (matches(LinkChooserState.Focused) && event.target !== inputRef.current) {\n event.preventDefault();\n }\n };\n\n const handleDropdownClose = () => {\n let selectedResult = null;\n if (context.query) {\n if (queryMatchesSelection(context.selectedResult, context.query)) {\n selectedResult = context.selectedResult;\n } else {\n selectedResult = createCustomLink(state.inputValue);\n }\n }\n send({ type: 'CLOSE_DROPDOWN', data: { selectedResult } });\n if (selectedResult && selectedKey !== selectedResult.id) {\n setSelectedKey(selectedResult.id);\n }\n closeBoxState(state);\n };\n\n const manualInputProps = useManualComboBoxEventHandlers(\n { inputProps, inputRef, popoverRef, state },\n {\n onOpen: handleDropdownOpen,\n onClose: handleDropdownClose,\n onNavigate: (id) => {\n if (isDefault) {\n send({\n type: 'SELECT_EXTRA_SECTION',\n data: {\n getExtraResultsByQuery: findSection(extraSections, id)?.getResults || null,\n currentSectionId: id.toString(),\n },\n });\n } else {\n send({\n type: 'BACK_TO_DEFAULT',\n data: { getExtraResultsByQuery: null },\n });\n }\n },\n onSelect: handleSelectionChange,\n },\n );\n\n useEffect(() => {\n if (isLoaded(matches) && context.interruptedFetch) {\n send({ type: 'TYPING', data: { query: context.query } });\n }\n }, [context.interruptedFetch, context.query, matches, send, value]);\n\n const { maxHeight } = useDropdownAutoHeight(inputRef, {\n isOpen: matches(LinkChooserState.Focused),\n autoResize: true,\n });\n\n const {\n isOpen,\n selectionManager: { focusedKey },\n } = state;\n\n useEffect(() => {\n if (focusedKey && popoverRef.current && isOpen) {\n const dropdownItem = popoverRef.current.querySelector(`[data-key=\"${focusedKey}\"]`);\n if (dropdownItem) {\n scrollIntoView(popoverRef.current, dropdownItem as HTMLElement);\n }\n }\n }, [focusedKey, isOpen]);\n\n const [flyoutWidth, setFlyoutWidth] = useState(0);\n\n const calcFlyoutWidth = () => {\n setFlyoutWidth(triggerRef.current?.getBoundingClientRect().width || 0);\n };\n\n useEffect(() => {\n calcFlyoutWidth();\n window.addEventListener('resize', calcFlyoutWidth, false);\n }, []);\n\n return (\n <div data-test-id={dataTestId} ref={triggerRef} className=\"tw-w-full tw-font-sans tw-text-s\">\n {!!label && (\n <label\n {...labelProps}\n data-test-id={`${dataTestId}-label`}\n className=\"tw-text-black-80 tw-mb-1 tw-flex tw-align-items-center\"\n >\n {label}\n {required && (\n <span\n data-test-id={`${dataTestId}-label-required`}\n className=\"tw-h-4 tw-text-m tw-text-red-60 dark:tw-text-red-50 tw-ml-1\"\n >\n *\n </span>\n )}\n </label>\n )}\n <SearchInput\n ariaProps={manualInputProps}\n selectedResult={context.selectedResult}\n ref={inputRef}\n disabled={disabled}\n decorator={IconOptions[context.selectedResult?.icon || DEFAULT_ICON]}\n clearable={clearable}\n onClear={handleClearClick}\n machineService={service}\n validation={validation}\n onClick={handleWrapperClick}\n onMouseDown={handleWrapperMouseDown}\n />\n <AnimatePresence>\n {matches(LinkChooserState.Focused) && (\n <motion.div\n style={{\n width: flyoutWidth,\n }}\n className=\"tw-absolute tw-left-auto tw-w-full tw-overflow-hidden tw-p-0 tw-shadow-mid tw-list-none tw-m-0 tw-mt-2 tw-z-20\"\n key=\"content\"\n initial={{ height: 0 }}\n animate={{ height: 'auto' }}\n exit={{ height: 0 }}\n transition={{ ease: [0.04, 0.62, 0.23, 0.98], duration: 0.5 }}\n data-test-id={`${dataTestId}-dropdown`}\n >\n <DismissButton onDismiss={handleDropdownClose} />\n <Popover\n popoverRef={popoverRef}\n isOpen={matches(LinkChooserState.Focused)}\n onClose={handleDropdownClose}\n maxHeight={maxHeight}\n >\n <SearchResultsList\n {...listBoxProps}\n listBoxRef={listBoxRef}\n state={state}\n menuBlocks={searchResultMenuBlocks}\n border={false}\n machineService={service}\n />\n <div data-test-id={`${dataTestId}-action-menu`} className=\"tw-border-t tw-border-black-10\">\n <NavigationMenu machineService={service} state={state} />\n </div>\n </Popover>\n <DismissButton onDismiss={handleDropdownClose} />\n </motion.div>\n )}\n </AnimatePresence>\n <div className=\"tw-my-2\" data-test-id={`${dataTestId}-new-tab`}>\n <Checkbox\n value=\"new-tab\"\n disabled={disabled}\n state={openInNewTab ? CheckboxState.Checked : CheckboxState.Unchecked}\n onChange={onOpenInNewTabChange}\n label=\"Open in New Tab\"\n />\n </div>\n </div>\n );\n};\n"],"names":["IconOptions","IconName","IconDocument","IconDocumentStack","IconLink","IconArrowOutExternal","IconLayersSingle","IconBuildingBlock","DEFAULT_ICON","CUSTOM_LINK_ID","MAX_STORED_ITEMS","QUERIES_STORAGE_KEY","LinkChooser","getGlobalByQuery","getDefaultData","openPreview","clipboardOptions","selectedResult","openInNewTab","ariaLabel","extraSections","label","placeholder","onOpenInNewTabChange","onLinkChange","disabled","clearable","required","validation","Validation","dataTestId","context","matches","value","send","service","useMachine","linkChooserMachine","defaultSection","searchInput","setSearchInput","useState","isDefault","shouldGoBack","searchResultMenuBlocks","useMemo","findSection","decoratedResults","id","title","props","mapToAriaProps","triggerRef","useRef","inputRef","listBoxRef","popoverRef","handleSelectionChange","key","foundItem","item","closeBoxState","state","setSelectedKey","handleInputChange","useCallback","query","selectedKey","_a","useComboBoxState","textValue","inputValue","doesContainSubstring","inputProps","listBoxProps","labelProps","useComboBox","handleClearClick","handleDropdownOpen","openBoxState","handleWrapperClick","handleWrapperMouseDown","event","LinkChooserState","handleDropdownClose","queryMatchesSelection","createCustomLink","manualInputProps","useManualComboBoxEventHandlers","useEffect","isLoaded","maxHeight","useDropdownAutoHeight","isOpen","focusedKey","dropdownItem","scrollIntoView","flyoutWidth","setFlyoutWidth","calcFlyoutWidth","jsxs","jsx","SearchInput","_b","AnimatePresence","motion","DismissButton","Popover","SearchResultsList","NavigationMenu","Checkbox","CheckboxState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCO,MAAMA,KAAuD;AAAA,EAChE,CAACC,EAAS,QAAQ,qBAAIC,IAAa,CAAA,CAAA;AAAA,EACnC,CAACD,EAAS,OAAO,qBAAIE,IAAkB,CAAA,CAAA;AAAA,EACvC,CAACF,EAAS,IAAI,qBAAIG,IAAS,CAAA,CAAA;AAAA,EAC3B,CAACH,EAAS,QAAQ,qBAAII,IAAqB,CAAA,CAAA;AAAA,EAC3C,CAACJ,EAAS,QAAQ,qBAAIK,IAAiB,CAAA,CAAA;AAAA,EACvC,CAACL,EAAS,KAAK,qBAAIM,IAAkB,CAAA,CAAA;AACzC,GAEaC,KAAeP,EAAS,MACxBQ,KAAiB,eACjBC,KAAmB,GACnBC,KAAsB,WAKtBC,KAAc,CAAC;AAAA,EACxB,kBAAAC,IAAmBC;AAAA,EACnB,aAAAC,IAAc,OAAO;AAAA,EACrB,kBAAAC,IAAmB,UAAU;AAAA,EAC7B,gBAAAC,IAAiB;AAAA,EACjB,cAAAC,IAAe;AAAA,EACf,WAAAC,IAAY;AAAA,EACZ,eAAAC,IAAgB,CAAC;AAAA,EACjB,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAA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,WAAU,kCACtD,UAAC,gBAAAuE,EAAAQ,IAAA,EAAe,gBAAgB1E,GAAS,OAAA2B,EAAc,CAAA,GAC3D;AAAA,cAAA;AAAA,YAAA;AAAA,UACJ;AAAA,UACA,gBAAAuC,EAACK,GAAc,EAAA,WAAWtB,EAAqB,CAAA;AAAA,QAAA;AAAA,MAAA;AAAA,MA1B3C;AAAA,IAAA,GA6BhB;AAAA,sBACC,OAAI,EAAA,WAAU,WAAU,gBAAc,GAAGtD,CAAU,YAChD,UAAA,gBAAAuE;AAAA,MAACS;AAAA,MAAA;AAAA,QACG,OAAM;AAAA,QACN,UAAArF;AAAA,QACA,OAAOP,IAAe6F,EAAc,UAAUA,EAAc;AAAA,QAC5D,UAAUxF;AAAA,QACV,OAAM;AAAA,MAAA;AAAA,IAAA,GAEd;AAAA,EACJ,EAAA,CAAA;AAER;"}
|
package/dist/components/RichTextEditor/Plugins/LinkPlugin/FloatingLink/EditLinkModal/EditModal.es.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
2
2
|
import { useLinkOpenButtonState as s } from "@udecode/plate-link";
|
|
3
|
-
import d from "
|
|
4
|
-
import l from "../../../../../../foundation/Icon/Generated/
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
3
|
+
import { getUrlFromLinkOrLegacyLink as d } from "../../utils/getUrl.es.js";
|
|
4
|
+
import l from "../../../../../../foundation/Icon/Generated/IconPen16.es.js";
|
|
5
|
+
import m from "../../../../../../foundation/Icon/Generated/IconTrashBin16.es.js";
|
|
6
|
+
import { LINK_PLUGIN as p } from "../../id.es.js";
|
|
7
7
|
import { FloatingModalWrapper as c } from "../../../../components/FloatingModal/FloatingModal.es.js";
|
|
8
8
|
import { useRichTextEditorContext as w } from "../../../../context/RichTextEditorContext.es.js";
|
|
9
9
|
const I = ({ editButtonProps: o, unlinkButtonProps: r }) => {
|
|
10
|
-
const { element: e } = s(), { styles: i } = w(), a = e ?
|
|
10
|
+
const { element: e } = s(), { styles: i } = w(), a = e ? d(e) : "";
|
|
11
11
|
return /* @__PURE__ */ t(c, { "data-test-id": "floating-link-edit", padding: "16px", minWidth: "400px", children: /* @__PURE__ */ n("span", { "data-test-id": "preview-link-flyout", className: "tw-flex tw-justify-between", children: [
|
|
12
|
-
/* @__PURE__ */ t("span", { style: i[
|
|
12
|
+
/* @__PURE__ */ t("span", { style: i[p], className: "tw-pointer-events-none", children: a }),
|
|
13
13
|
/* @__PURE__ */ n("span", { className: "tw-flex tw-gap-2", children: [
|
|
14
14
|
/* @__PURE__ */ t(
|
|
15
15
|
"button",
|
|
@@ -18,7 +18,7 @@ const I = ({ editButtonProps: o, unlinkButtonProps: r }) => {
|
|
|
18
18
|
"data-test-id": "edit-link-button",
|
|
19
19
|
className: "tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",
|
|
20
20
|
...o,
|
|
21
|
-
children: /* @__PURE__ */ t(
|
|
21
|
+
children: /* @__PURE__ */ t(l, {})
|
|
22
22
|
}
|
|
23
23
|
),
|
|
24
24
|
/* @__PURE__ */ t(
|
|
@@ -28,7 +28,7 @@ const I = ({ editButtonProps: o, unlinkButtonProps: r }) => {
|
|
|
28
28
|
"data-test-id": "remove-link-button",
|
|
29
29
|
className: "tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",
|
|
30
30
|
...r,
|
|
31
|
-
children: /* @__PURE__ */ t(
|
|
31
|
+
children: /* @__PURE__ */ t(m, {})
|
|
32
32
|
}
|
|
33
33
|
)
|
|
34
34
|
] })
|