@frontify/guideline-blocks-settings 2.0.2 → 2.0.4
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/Attachments/AttachmentItem.es.js +64 -64
- package/dist/components/Attachments/AttachmentItem.es.js.map +1 -1
- package/dist/components/Attachments/Attachments.es.js +31 -31
- package/dist/components/Attachments/Attachments.es.js.map +1 -1
- package/dist/components/Attachments/AttachmentsButtonTrigger.es.js +13 -13
- package/dist/components/Attachments/AttachmentsButtonTrigger.es.js.map +1 -1
- package/dist/components/BlockInjectButton/BlockInjectButton.es.js +18 -18
- package/dist/components/BlockInjectButton/BlockInjectButton.es.js.map +1 -1
- package/dist/components/BlockItemWrapper/BlockItemWrapper.es.js +29 -29
- package/dist/components/BlockItemWrapper/BlockItemWrapper.es.js.map +1 -1
- package/dist/components/BlockItemWrapper/Toolbar/Toolbar.es.js +10 -10
- package/dist/components/BlockItemWrapper/Toolbar/Toolbar.es.js.map +1 -1
- package/dist/components/BlockItemWrapper/Toolbar/helpers.es.js +10 -10
- package/dist/components/BlockItemWrapper/Toolbar/helpers.es.js.map +1 -1
- package/dist/components/DownloadButton/DownloadButton.es.js +14 -14
- package/dist/components/DownloadButton/DownloadButton.es.js.map +1 -1
- package/dist/components/Link/LinkInput.es.js +15 -15
- package/dist/components/Link/LinkInput.es.js.map +1 -1
- package/dist/components/Link/LinkSelector/DocumentLink.es.js +28 -28
- package/dist/components/Link/LinkSelector/DocumentLink.es.js.map +1 -1
- package/dist/components/Link/LinkSelector/LinkSelector.es.js +26 -29
- package/dist/components/Link/LinkSelector/LinkSelector.es.js.map +1 -1
- package/dist/components/Link/LinkSelector/PageLink.es.js +29 -29
- package/dist/components/Link/LinkSelector/PageLink.es.js.map +1 -1
- package/dist/components/Link/LinkSelector/PageLinks.es.js +9 -9
- package/dist/components/Link/LinkSelector/PageLinks.es.js.map +1 -1
- package/dist/components/Link/LinkSelector/SectionLink.es.js +10 -10
- package/dist/components/Link/LinkSelector/SectionLink.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/EditButtonModal/EditModal.es.js +17 -17
- package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/EditButtonModal/EditModal.es.js.map +1 -1
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/EditModal.es.js +7 -7
- package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/EditModal.es.js.map +1 -1
- package/dist/index.cjs.js +7 -7
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.umd.js +6 -6
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +13 -13
- package/tailwind.config.ts +17 -0
|
@@ -18,15 +18,15 @@ const et = ({
|
|
|
18
18
|
validFileType: h,
|
|
19
19
|
verticalLayout: M
|
|
20
20
|
}) => {
|
|
21
|
-
const [d,
|
|
22
|
-
if (t.preventDefault(),
|
|
21
|
+
const [d, p] = I(!1), [n, b] = I(), g = G(null), [s, i] = I(void 0), y = (t) => {
|
|
22
|
+
if (t.preventDefault(), p(!1), !D(t.dataTransfer.files)) {
|
|
23
23
|
i("Invalid"), setTimeout(() => {
|
|
24
24
|
i(void 0);
|
|
25
25
|
}, 1e3);
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
l?.(t.dataTransfer.files);
|
|
29
|
-
},
|
|
29
|
+
}, D = (t) => {
|
|
30
30
|
if (!h)
|
|
31
31
|
return !0;
|
|
32
32
|
for (let r = 0; r < t.length; r++) {
|
|
@@ -35,14 +35,14 @@ const et = ({
|
|
|
35
35
|
return !1;
|
|
36
36
|
}
|
|
37
37
|
return !0;
|
|
38
|
-
},
|
|
39
|
-
if (!
|
|
38
|
+
}, O = (t) => {
|
|
39
|
+
if (!g.current || a)
|
|
40
40
|
return;
|
|
41
|
-
const { clientX: r, clientY: c } = t, N = r === 0 && c === 0, { left:
|
|
42
|
-
|
|
41
|
+
const { clientX: r, clientY: c } = t, N = r === 0 && c === 0, { left: T, top: z, width: B, height: F } = g.current.getBoundingClientRect(), P = N ? B / 2 : r - T, X = N ? F / 2 : c - z;
|
|
42
|
+
b([P, X]);
|
|
43
43
|
}, x = H((t) => {
|
|
44
|
-
t(),
|
|
45
|
-
}, []),
|
|
44
|
+
t(), b(void 0);
|
|
45
|
+
}, []), R = J(() => {
|
|
46
46
|
const t = [];
|
|
47
47
|
return v && t.push({
|
|
48
48
|
onSelect: () => x(v),
|
|
@@ -57,30 +57,30 @@ const et = ({
|
|
|
57
57
|
return /* @__PURE__ */ o(
|
|
58
58
|
"button",
|
|
59
59
|
{
|
|
60
|
-
ref:
|
|
60
|
+
ref: g,
|
|
61
61
|
"data-test-id": "block-inject-button",
|
|
62
62
|
className: Q([
|
|
63
|
-
"tw-font-
|
|
63
|
+
"tw-font-primary tw-relative tw-text-sm tw-leading-4 tw-border tw-flex tw-items-center tw-justify-center tw-cursor-pointer tw-gap-3 tw-w-full first:tw-rounded-tl last:tw-rounded-br",
|
|
64
64
|
M ? "[&:not(:first-child)]:tw-border-t-0 first:tw-rounded-tr last:tw-rounded-bl" : "[&:not(:first-child)]:tw-border-l-0 first:tw-rounded-bl last:tw-rounded-tr",
|
|
65
65
|
S ? "tw-h-full" : "tw-h-[72px]",
|
|
66
66
|
d && !a ? "tw-border-dashed" : "tw-border-solid",
|
|
67
67
|
n && "tw-bg-blank-state-pressed-inverse",
|
|
68
68
|
d && "tw-bg-blank-state-weak-inverse",
|
|
69
69
|
s ? "!tw-border-red-50 !tw-cursor-not-allowed" : " tw-border-blank-state-line",
|
|
70
|
-
a || n || d || s ? "" : "tw-text-
|
|
70
|
+
a || n || d || s ? "" : "tw-text-secondary hover:tw-text-blank-state-hover hover:tw-bg-blank-state-hover-inverse hover:tw-border-blank-state-line-hover active:tw-text-blank-state-pressed active:tw-bg-blank-state-pressed-inverse active:tw-border-blank-state-line-hover",
|
|
71
71
|
(d || n) && !s ? "[&>*]:tw-pointer-events-none tw-border-blank-state-line-hover" : "tw-bg-blank-state-shaded-inverse tw-text-blank-state-shaded"
|
|
72
72
|
]),
|
|
73
73
|
onDragEnter: l ? (t) => {
|
|
74
|
-
if (
|
|
74
|
+
if (p(!0), h === "Images")
|
|
75
75
|
for (const r of Array.from(t.dataTransfer.items))
|
|
76
76
|
r?.type?.startsWith("image/") ? i(void 0) : i("Invalid");
|
|
77
77
|
} : void 0,
|
|
78
78
|
onDragLeave: l ? () => {
|
|
79
|
-
|
|
79
|
+
p(!1), i(void 0);
|
|
80
80
|
} : void 0,
|
|
81
|
-
onDrop: l ?
|
|
81
|
+
onDrop: l ? y : void 0,
|
|
82
82
|
onClick: (t) => {
|
|
83
|
-
C && !n &&
|
|
83
|
+
C && !n && O(t), E?.();
|
|
84
84
|
},
|
|
85
85
|
children: [
|
|
86
86
|
a ? /* @__PURE__ */ e(K, {}) : s ? /* @__PURE__ */ o("div", { className: " tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium", children: [
|
|
@@ -101,11 +101,11 @@ const et = ({
|
|
|
101
101
|
left: n[0],
|
|
102
102
|
top: n[1]
|
|
103
103
|
},
|
|
104
|
-
children: /* @__PURE__ */ o(k.Root, { open: !0, onOpenChange: (t) => !t &&
|
|
104
|
+
children: /* @__PURE__ */ o(k.Root, { open: !0, onOpenChange: (t) => !t && b(void 0), children: [
|
|
105
105
|
/* @__PURE__ */ e(k.Trigger, { children: /* @__PURE__ */ e("div", {}) }),
|
|
106
106
|
/* @__PURE__ */ e(k.Content, { triggerOffset: "compact", children: /* @__PURE__ */ o(w.Root, { open: !0, children: [
|
|
107
107
|
/* @__PURE__ */ e(w.Trigger, { children: /* @__PURE__ */ e("div", {}) }),
|
|
108
|
-
/* @__PURE__ */ e(w.Content, { triggerOffset: "compact", children:
|
|
108
|
+
/* @__PURE__ */ e(w.Content, { triggerOffset: "compact", children: R.map((t) => /* @__PURE__ */ o(w.Item, { onSelect: t.onSelect, children: [
|
|
109
109
|
t.icon,
|
|
110
110
|
t.title
|
|
111
111
|
] }, t.title)) })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockInjectButton.es.js","sources":["../../../src/components/BlockInjectButton/BlockInjectButton.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type FileExtension, FileExtensionSets } from '@frontify/app-bridge';\nimport { Dropdown, Flyout, LoadingCircle } from '@frontify/fondue/components';\nimport { IconArrowCircleUp, IconImageStack, IconExclamationMarkTriangle } from '@frontify/fondue/icons';\nimport { type DragEventHandler, type MouseEventHandler, useCallback, useMemo, useRef, useState } from 'react';\n\nimport { joinClassNames } from '../../utilities/react/joinClassNames';\n\nimport { type BlockInjectButtonProps } from './types';\n\nexport const BlockInjectButton = ({\n onDrop,\n label,\n icon,\n secondaryLabel,\n isLoading,\n fillParentContainer,\n onAssetChooseClick,\n onUploadClick,\n withMenu = true,\n onClick,\n validFileType,\n verticalLayout,\n}: BlockInjectButtonProps) => {\n const [isDraggingOver, setIsDraggingOver] = useState(false);\n const [menuPosition, setMenuPosition] = useState<[number, number] | undefined>();\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [errorMsg, setErrorMsg] = useState<string | undefined>(undefined);\n\n const handleDrop: DragEventHandler<HTMLButtonElement> = (event) => {\n event.preventDefault();\n setIsDraggingOver(false);\n if (!isValidAsset(event.dataTransfer.files)) {\n setErrorMsg('Invalid');\n setTimeout(() => {\n setErrorMsg(undefined);\n }, 1000);\n return;\n }\n onDrop?.(event.dataTransfer.files);\n };\n\n const isValidAsset = (files: FileList) => {\n if (!validFileType) {\n return true;\n }\n for (let i = 0; i < files.length; i++) {\n const droppedFileExtension = (files[i].name.split('.').pop() ?? '') as FileExtension;\n if (!FileExtensionSets[validFileType].includes(droppedFileExtension)) {\n return false;\n }\n }\n return true;\n };\n\n const openMenu: MouseEventHandler<HTMLButtonElement> = (event) => {\n if (!buttonRef.current || isLoading) {\n return;\n }\n const { clientX, clientY } = event;\n const isKeyboardEvent = clientX === 0 && clientY === 0;\n const { left, top, width, height } = buttonRef.current.getBoundingClientRect();\n const XInsideComponent = !isKeyboardEvent ? clientX - left : width / 2;\n const YInsideComponent = !isKeyboardEvent ? clientY - top : height / 2;\n setMenuPosition([XInsideComponent, YInsideComponent]);\n };\n\n const onItemClick = useCallback((callback: () => unknown) => {\n callback();\n setMenuPosition(undefined);\n }, []);\n\n const menuItems = useMemo(() => {\n const items = [];\n if (onUploadClick) {\n items.push({\n onSelect: () => onItemClick(onUploadClick),\n title: 'Upload asset',\n icon: <IconArrowCircleUp size=\"20\" />,\n });\n }\n if (onAssetChooseClick) {\n items.push({\n onSelect: () => onItemClick(onAssetChooseClick),\n title: 'Browse asset',\n icon: <IconImageStack size=\"20\" />,\n });\n }\n return items;\n }, [onAssetChooseClick, onUploadClick, onItemClick]);\n return (\n <button\n ref={buttonRef}\n data-test-id=\"block-inject-button\"\n className={joinClassNames([\n 'tw-font-body tw-relative tw-text-sm tw-leading-4 tw-border tw-flex tw-items-center tw-justify-center tw-cursor-pointer tw-gap-3 tw-w-full first:tw-rounded-tl last:tw-rounded-br',\n verticalLayout\n ? '[&:not(:first-child)]:tw-border-t-0 first:tw-rounded-tr last:tw-rounded-bl'\n : '[&:not(:first-child)]:tw-border-l-0 first:tw-rounded-bl last:tw-rounded-tr',\n fillParentContainer ? 'tw-h-full' : 'tw-h-[72px]',\n isDraggingOver && !isLoading ? 'tw-border-dashed' : 'tw-border-solid',\n menuPosition && 'tw-bg-blank-state-pressed-inverse',\n isDraggingOver && 'tw-bg-blank-state-weak-inverse',\n errorMsg ? '!tw-border-red-50 !tw-cursor-not-allowed' : ' tw-border-blank-state-line',\n isLoading || menuPosition || isDraggingOver || errorMsg\n ? ''\n : 'tw-text-text-weak hover:tw-text-blank-state-hover hover:tw-bg-blank-state-hover-inverse hover:tw-border-blank-state-line-hover active:tw-text-blank-state-pressed active:tw-bg-blank-state-pressed-inverse active:tw-border-blank-state-line-hover',\n (isDraggingOver || !!menuPosition) && !errorMsg\n ? '[&>*]:tw-pointer-events-none tw-border-blank-state-line-hover'\n : 'tw-bg-blank-state-shaded-inverse tw-text-blank-state-shaded',\n ])}\n onDragEnter={\n onDrop\n ? (event) => {\n setIsDraggingOver(true);\n // is now only used for images, can be adapted if needed\n if (validFileType === 'Images') {\n for (const item of Array.from(event.dataTransfer.items)) {\n if (!item?.type?.startsWith('image/')) {\n setErrorMsg('Invalid');\n } else {\n setErrorMsg(undefined);\n }\n }\n }\n }\n : undefined\n }\n onDragLeave={\n onDrop\n ? () => {\n setIsDraggingOver(false);\n setErrorMsg(undefined);\n }\n : undefined\n }\n onDrop={onDrop ? handleDrop : undefined}\n onClick={(event) => {\n if (withMenu && !menuPosition) {\n openMenu(event);\n }\n onClick?.();\n }}\n >\n {isLoading ? (\n <LoadingCircle />\n ) : errorMsg ? (\n <div className=\" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium\">\n <IconExclamationMarkTriangle size=\"16\" />\n {errorMsg}\n </div>\n ) : (\n <>\n {icon && <div>{icon}</div>}\n {(label || secondaryLabel) && (\n <div className=\"tw-flex tw-flex-col tw-items-start\">\n {label && <div className=\"tw-font-medium\">{label}</div>}\n {secondaryLabel && <div className=\"tw-font-normal\">{secondaryLabel}</div>}\n </div>\n )}\n </>\n )}\n {menuPosition && (\n <div\n className=\"tw-absolute tw-left-0 tw-top-full tw-z-20\"\n style={{\n left: menuPosition[0],\n top: menuPosition[1],\n }}\n >\n <Flyout.Root open onOpenChange={(isOpen) => !isOpen && setMenuPosition(undefined)}>\n <Flyout.Trigger>\n <div />\n </Flyout.Trigger>\n <Flyout.Content triggerOffset=\"compact\">\n <Dropdown.Root open>\n <Dropdown.Trigger>\n <div />\n </Dropdown.Trigger>\n <Dropdown.Content triggerOffset=\"compact\">\n {menuItems.map((item) => (\n <Dropdown.Item key={item.title} onSelect={item.onSelect}>\n {item.icon}\n {item.title}\n </Dropdown.Item>\n ))}\n </Dropdown.Content>\n </Dropdown.Root>\n </Flyout.Content>\n </Flyout.Root>\n </div>\n )}\n </button>\n );\n};\n"],"names":["BlockInjectButton","onDrop","label","icon","secondaryLabel","isLoading","fillParentContainer","onAssetChooseClick","onUploadClick","withMenu","onClick","validFileType","verticalLayout","isDraggingOver","setIsDraggingOver","useState","menuPosition","setMenuPosition","buttonRef","useRef","errorMsg","setErrorMsg","handleDrop","event","isValidAsset","files","i","droppedFileExtension","FileExtensionSets","openMenu","clientX","clientY","isKeyboardEvent","left","top","width","height","XInsideComponent","YInsideComponent","onItemClick","useCallback","callback","menuItems","useMemo","items","jsx","IconArrowCircleUp","IconImageStack","jsxs","joinClassNames","item","LoadingCircle","IconExclamationMarkTriangle","Fragment","Flyout","isOpen","Dropdown"],"mappings":";;;;;;AAWO,MAAMA,KAAoB,CAAC;AAAA,EAC9B,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,SAAAC;AAAA,EACA,eAAAC;AAAA,EACA,gBAAAC;AACJ,MAA8B;AAC1B,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAS,EAAK,GACpD,CAACC,GAAcC,CAAe,IAAIF,EAAA,GAClCG,IAAYC,EAA0B,IAAI,GAC1C,CAACC,GAAUC,CAAW,IAAIN,EAA6B,MAAS,GAEhEO,IAAkD,CAACC,MAAU;AAG/D,QAFAA,EAAM,eAAA,GACNT,EAAkB,EAAK,GACnB,CAACU,EAAaD,EAAM,aAAa,KAAK,GAAG;AACzC,MAAAF,EAAY,SAAS,GACrB,WAAW,MAAM;AACb,QAAAA,EAAY,MAAS;AAAA,MACzB,GAAG,GAAI;AACP;AAAA,IACJ;AACA,IAAApB,IAASsB,EAAM,aAAa,KAAK;AAAA,EACrC,GAEMC,IAAe,CAACC,MAAoB;AACtC,QAAI,CAACd;A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AAU,kBAAkB,UAAA3C,GAAM;AAAA,YAChDE,KAAkB,gBAAAyC,EAAC,OAAA,EAAI,WAAU,kBAAkB,UAAAzC,EAAA,CAAe;AAAA,UAAA,EAAA,CACvE;AAAA,QAAA,GAER;AAAA,QAEHY,KACG,gBAAA6B;AAAA,UAAC;AAAA,UAAA;AAAA,YACG,WAAU;AAAA,YACV,OAAO;AAAA,cACH,MAAM7B,EAAa,CAAC;AAAA,cACpB,KAAKA,EAAa,CAAC;AAAA,YAAA;AAAA,YAGvB,UAAA,gBAAAgC,EAACM,EAAO,MAAP,EAAY,MAAI,IAAC,cAAc,CAACC,MAAW,CAACA,KAAUtC,EAAgB,MAAS,GAC5E,UAAA;AAAA,cAAA,gBAAA4B,EAACS,EAAO,SAAP,EACG,UAAA,gBAAAT,EAAC,SAAI,GACT;AAAA,cACA,gBAAAA,EAACS,EAAO,SAAP,EAAe,eAAc,WAC1B,UAAA,gBAAAN,EAACQ,EAAS,MAAT,EAAc,MAAI,IACf,UAAA;AAAA,gBAAA,gBAAAX,EAACW,EAAS,SAAT,EACG,UAAA,gBAAAX,EAAC,SAAI,GACT;AAAA,kCACCW,EAAS,SAAT,EAAiB,eAAc,WAC3B,UAAAd,EAAU,IAAI,CAACQ,wBACXM,EAAS,MAAT,EAA+B,UAAUN,EAAK,UAC1C,UAAA;AAAA,kBAAAA,EAAK;AAAA,kBACLA,EAAK;AAAA,gBAAA,KAFUA,EAAK,KAGzB,CACH,EAAA,CACL;AAAA,cAAA,EAAA,CACJ,EAAA,CACJ;AAAA,YAAA,EAAA,CACJ;AAAA,UAAA;AAAA,QAAA;AAAA,MACJ;AAAA,IAAA;AAAA,EAAA;AAIhB;"}
|
|
1
|
+
{"version":3,"file":"BlockInjectButton.es.js","sources":["../../../src/components/BlockInjectButton/BlockInjectButton.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type FileExtension, FileExtensionSets } from '@frontify/app-bridge';\nimport { Dropdown, Flyout, LoadingCircle } from '@frontify/fondue/components';\nimport { IconArrowCircleUp, IconImageStack, IconExclamationMarkTriangle } from '@frontify/fondue/icons';\nimport { type DragEventHandler, type MouseEventHandler, useCallback, useMemo, useRef, useState } from 'react';\n\nimport { joinClassNames } from '../../utilities/react/joinClassNames';\n\nimport { type BlockInjectButtonProps } from './types';\n\nexport const BlockInjectButton = ({\n onDrop,\n label,\n icon,\n secondaryLabel,\n isLoading,\n fillParentContainer,\n onAssetChooseClick,\n onUploadClick,\n withMenu = true,\n onClick,\n validFileType,\n verticalLayout,\n}: BlockInjectButtonProps) => {\n const [isDraggingOver, setIsDraggingOver] = useState(false);\n const [menuPosition, setMenuPosition] = useState<[number, number] | undefined>();\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [errorMsg, setErrorMsg] = useState<string | undefined>(undefined);\n\n const handleDrop: DragEventHandler<HTMLButtonElement> = (event) => {\n event.preventDefault();\n setIsDraggingOver(false);\n if (!isValidAsset(event.dataTransfer.files)) {\n setErrorMsg('Invalid');\n setTimeout(() => {\n setErrorMsg(undefined);\n }, 1000);\n return;\n }\n onDrop?.(event.dataTransfer.files);\n };\n\n const isValidAsset = (files: FileList) => {\n if (!validFileType) {\n return true;\n }\n for (let i = 0; i < files.length; i++) {\n const droppedFileExtension = (files[i].name.split('.').pop() ?? '') as FileExtension;\n if (!FileExtensionSets[validFileType].includes(droppedFileExtension)) {\n return false;\n }\n }\n return true;\n };\n\n const openMenu: MouseEventHandler<HTMLButtonElement> = (event) => {\n if (!buttonRef.current || isLoading) {\n return;\n }\n const { clientX, clientY } = event;\n const isKeyboardEvent = clientX === 0 && clientY === 0;\n const { left, top, width, height } = buttonRef.current.getBoundingClientRect();\n const XInsideComponent = !isKeyboardEvent ? clientX - left : width / 2;\n const YInsideComponent = !isKeyboardEvent ? clientY - top : height / 2;\n setMenuPosition([XInsideComponent, YInsideComponent]);\n };\n\n const onItemClick = useCallback((callback: () => unknown) => {\n callback();\n setMenuPosition(undefined);\n }, []);\n\n const menuItems = useMemo(() => {\n const items = [];\n if (onUploadClick) {\n items.push({\n onSelect: () => onItemClick(onUploadClick),\n title: 'Upload asset',\n icon: <IconArrowCircleUp size=\"20\" />,\n });\n }\n if (onAssetChooseClick) {\n items.push({\n onSelect: () => onItemClick(onAssetChooseClick),\n title: 'Browse asset',\n icon: <IconImageStack size=\"20\" />,\n });\n }\n return items;\n }, [onAssetChooseClick, onUploadClick, onItemClick]);\n return (\n <button\n ref={buttonRef}\n data-test-id=\"block-inject-button\"\n className={joinClassNames([\n 'tw-font-primary tw-relative tw-text-sm tw-leading-4 tw-border tw-flex tw-items-center tw-justify-center tw-cursor-pointer tw-gap-3 tw-w-full first:tw-rounded-tl last:tw-rounded-br',\n verticalLayout\n ? '[&:not(:first-child)]:tw-border-t-0 first:tw-rounded-tr last:tw-rounded-bl'\n : '[&:not(:first-child)]:tw-border-l-0 first:tw-rounded-bl last:tw-rounded-tr',\n fillParentContainer ? 'tw-h-full' : 'tw-h-[72px]',\n isDraggingOver && !isLoading ? 'tw-border-dashed' : 'tw-border-solid',\n menuPosition && 'tw-bg-blank-state-pressed-inverse',\n isDraggingOver && 'tw-bg-blank-state-weak-inverse',\n errorMsg ? '!tw-border-red-50 !tw-cursor-not-allowed' : ' tw-border-blank-state-line',\n isLoading || menuPosition || isDraggingOver || errorMsg\n ? ''\n : 'tw-text-secondary hover:tw-text-blank-state-hover hover:tw-bg-blank-state-hover-inverse hover:tw-border-blank-state-line-hover active:tw-text-blank-state-pressed active:tw-bg-blank-state-pressed-inverse active:tw-border-blank-state-line-hover',\n (isDraggingOver || !!menuPosition) && !errorMsg\n ? '[&>*]:tw-pointer-events-none tw-border-blank-state-line-hover'\n : 'tw-bg-blank-state-shaded-inverse tw-text-blank-state-shaded',\n ])}\n onDragEnter={\n onDrop\n ? (event) => {\n setIsDraggingOver(true);\n // is now only used for images, can be adapted if needed\n if (validFileType === 'Images') {\n for (const item of Array.from(event.dataTransfer.items)) {\n if (!item?.type?.startsWith('image/')) {\n setErrorMsg('Invalid');\n } else {\n setErrorMsg(undefined);\n }\n }\n }\n }\n : undefined\n }\n onDragLeave={\n onDrop\n ? () => {\n setIsDraggingOver(false);\n setErrorMsg(undefined);\n }\n : undefined\n }\n onDrop={onDrop ? handleDrop : undefined}\n onClick={(event) => {\n if (withMenu && !menuPosition) {\n openMenu(event);\n }\n onClick?.();\n }}\n >\n {isLoading ? (\n <LoadingCircle />\n ) : errorMsg ? (\n <div className=\" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium\">\n <IconExclamationMarkTriangle size=\"16\" />\n {errorMsg}\n </div>\n ) : (\n <>\n {icon && <div>{icon}</div>}\n {(label || secondaryLabel) && (\n <div className=\"tw-flex tw-flex-col tw-items-start\">\n {label && <div className=\"tw-font-medium\">{label}</div>}\n {secondaryLabel && <div className=\"tw-font-normal\">{secondaryLabel}</div>}\n </div>\n )}\n </>\n )}\n {menuPosition && (\n <div\n className=\"tw-absolute tw-left-0 tw-top-full tw-z-20\"\n style={{\n left: menuPosition[0],\n top: menuPosition[1],\n }}\n >\n <Flyout.Root open onOpenChange={(isOpen) => !isOpen && setMenuPosition(undefined)}>\n <Flyout.Trigger>\n <div />\n </Flyout.Trigger>\n <Flyout.Content triggerOffset=\"compact\">\n <Dropdown.Root open>\n <Dropdown.Trigger>\n <div />\n </Dropdown.Trigger>\n <Dropdown.Content triggerOffset=\"compact\">\n {menuItems.map((item) => (\n <Dropdown.Item key={item.title} onSelect={item.onSelect}>\n {item.icon}\n {item.title}\n </Dropdown.Item>\n ))}\n </Dropdown.Content>\n </Dropdown.Root>\n </Flyout.Content>\n </Flyout.Root>\n </div>\n )}\n </button>\n );\n};\n"],"names":["BlockInjectButton","onDrop","label","icon","secondaryLabel","isLoading","fillParentContainer","onAssetChooseClick","onUploadClick","withMenu","onClick","validFileType","verticalLayout","isDraggingOver","setIsDraggingOver","useState","menuPosition","setMenuPosition","buttonRef","useRef","errorMsg","setErrorMsg","handleDrop","event","isValidAsset","files","i","droppedFileExtension","FileExtensionSets","openMenu","clientX","clientY","isKeyboardEvent","left","top","width","height","XInsideComponent","YInsideComponent","onItemClick","useCallback","callback","menuItems","useMemo","items","jsx","IconArrowCircleUp","IconImageStack","jsxs","joinClassNames","item","LoadingCircle","IconExclamationMarkTriangle","Fragment","Flyout","isOpen","Dropdown"],"mappings":";;;;;;AAWO,MAAMA,KAAoB,CAAC;AAAA,EAC9B,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,SAAAC;AAAA,EACA,eAAAC;AAAA,EACA,gBAAAC;AACJ,MAA8B;AAC1B,QAAM,CAACC,GAAgBC,CAAiB,IAAIC,EAAS,EAAK,GACpD,CAACC,GAAcC,CAAe,IAAIF,EAAA,GAClCG,IAAYC,EAA0B,IAAI,GAC1C,CAACC,GAAUC,CAAW,IAAIN,EAA6B,MAAS,GAEhEO,IAAkD,CAACC,MAAU;AAG/D,QAFAA,EAAM,eAAA,GACNT,EAAkB,EAAK,GACnB,CAACU,EAAaD,EAAM,aAAa,KAAK,GAAG;AACzC,MAAAF,EAAY,SAAS,GACrB,WAAW,MAAM;AACb,QAAAA,EAAY,MAAS;AAAA,MACzB,GAAG,GAAI;AACP;AAAA,IACJ;AACA,IAAApB,IAASsB,EAAM,aAAa,KAAK;AAAA,EACrC,GAEMC,IAAe,CAACC,MAAoB;AACtC,QAAI,CAACd;AACD,aAAO;AAEX,aAASe,IAAI,GAAGA,IAAID,EAAM,QAAQC,KAAK;AACnC,YAAMC,IAAwBF,EAAMC,CAAC,EAAE,KAAK,MAAM,GAAG,EAAE,IAAA,KAAS;AAChE,UAAI,CAACE,EAAkBjB,CAAa,EAAE,SAASgB,CAAoB;AAC/D,eAAO;AAAA,IAEf;AACA,WAAO;AAAA,EACX,GAEME,IAAiD,CAACN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EAAa,CAAC;AAAA,cACpB,KAAKA,EAAa,CAAC;AAAA,YAAA;AAAA,YAGvB,UAAA,gBAAAgC,EAACM,EAAO,MAAP,EAAY,MAAI,IAAC,cAAc,CAACC,MAAW,CAACA,KAAUtC,EAAgB,MAAS,GAC5E,UAAA;AAAA,cAAA,gBAAA4B,EAACS,EAAO,SAAP,EACG,UAAA,gBAAAT,EAAC,SAAI,GACT;AAAA,cACA,gBAAAA,EAACS,EAAO,SAAP,EAAe,eAAc,WAC1B,UAAA,gBAAAN,EAACQ,EAAS,MAAT,EAAc,MAAI,IACf,UAAA;AAAA,gBAAA,gBAAAX,EAACW,EAAS,SAAT,EACG,UAAA,gBAAAX,EAAC,SAAI,GACT;AAAA,kCACCW,EAAS,SAAT,EAAiB,eAAc,WAC3B,UAAAd,EAAU,IAAI,CAACQ,wBACXM,EAAS,MAAT,EAA+B,UAAUN,EAAK,UAC1C,UAAA;AAAA,kBAAAA,EAAK;AAAA,kBACLA,EAAK;AAAA,gBAAA,KAFUA,EAAK,KAGzB,CACH,EAAA,CACL;AAAA,cAAA,EAAA,CACJ,EAAA,CACJ;AAAA,YAAA,EAAA,CACJ;AAAA,UAAA;AAAA,QAAA;AAAA,MACJ;AAAA,IAAA;AAAA,EAAA;AAIhB;"}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { jsx as t, Fragment as
|
|
2
|
-
import { memo as
|
|
1
|
+
import { jsx as t, Fragment as d, jsxs as v } from "react/jsx-runtime";
|
|
2
|
+
import { memo as y, useState as x, useRef as b } from "react";
|
|
3
3
|
import { DragPreviewContextProvider as N } from "./Toolbar/context/DragPreviewContext.es.js";
|
|
4
4
|
import { MultiFlyoutContextProvider as F } from "./Toolbar/context/MultiFlyoutContext.es.js";
|
|
5
5
|
import { DEFAULT_MENU_BUTTON_ID as I } from "./Toolbar/MenuToolbarButton/MenuToolbarButton.es.js";
|
|
6
6
|
import { Toolbar as T } from "./Toolbar/Toolbar.es.js";
|
|
7
|
-
import { joinClassNames as
|
|
8
|
-
const j =
|
|
7
|
+
import { joinClassNames as n } from "../../utilities/react/joinClassNames.es.js";
|
|
8
|
+
const j = y(
|
|
9
9
|
({
|
|
10
|
-
children:
|
|
10
|
+
children: e,
|
|
11
11
|
toolbarItems: a,
|
|
12
|
-
shouldHideWrapper:
|
|
12
|
+
shouldHideWrapper: s,
|
|
13
13
|
shouldHideComponent: w = !1,
|
|
14
|
-
isDragging:
|
|
15
|
-
shouldFillContainer:
|
|
16
|
-
outlineOffset:
|
|
17
|
-
shouldBeShown:
|
|
18
|
-
showAttachments:
|
|
14
|
+
isDragging: c = !1,
|
|
15
|
+
shouldFillContainer: h,
|
|
16
|
+
outlineOffset: o = 0,
|
|
17
|
+
shouldBeShown: i = !1,
|
|
18
|
+
showAttachments: p = !1
|
|
19
19
|
}) => {
|
|
20
|
-
const [
|
|
21
|
-
if (
|
|
22
|
-
return /* @__PURE__ */ t(
|
|
23
|
-
const
|
|
24
|
-
return /* @__PURE__ */ t(N, { isDragPreview:
|
|
20
|
+
const [r, u] = x(i ? [I] : []), m = b(null);
|
|
21
|
+
if (s)
|
|
22
|
+
return /* @__PURE__ */ t(d, { children: e });
|
|
23
|
+
const f = a?.filter((g) => g !== void 0), l = r.length > 0 || i;
|
|
24
|
+
return /* @__PURE__ */ t(N, { isDragPreview: c, children: /* @__PURE__ */ t(F, { openFlyoutIds: r, setOpenFlyoutIds: u, children: /* @__PURE__ */ v(
|
|
25
25
|
"div",
|
|
26
26
|
{
|
|
27
|
-
ref:
|
|
27
|
+
ref: m,
|
|
28
28
|
"data-test-id": "block-item-wrapper",
|
|
29
29
|
style: {
|
|
30
|
-
outlineOffset:
|
|
30
|
+
outlineOffset: o
|
|
31
31
|
},
|
|
32
|
-
className:
|
|
33
|
-
"tw-relative tw-group
|
|
34
|
-
|
|
35
|
-
"hover:tw-outline focus-within:tw-outline",
|
|
36
|
-
l && "tw-outline",
|
|
32
|
+
className: n([
|
|
33
|
+
"tw-relative tw-group",
|
|
34
|
+
h && "tw-flex-1 tw-h-full tw-w-full",
|
|
35
|
+
"hover:tw-outline hover:tw-outline-1 hover:tw-outline-container-highlight-on-highlight-container focus-within:tw-outline focus-within:tw-outline-1 focus-within:tw-outline-container-highlight-on-highlight-container",
|
|
36
|
+
l && "tw-outline tw-outline-1 tw-outline-container-highlight-on-highlight-container",
|
|
37
37
|
w && "tw-opacity-0"
|
|
38
38
|
]),
|
|
39
39
|
children: [
|
|
@@ -41,10 +41,10 @@ const j = x(
|
|
|
41
41
|
"div",
|
|
42
42
|
{
|
|
43
43
|
style: {
|
|
44
|
-
right: -1 -
|
|
45
|
-
bottom: `calc(100% - ${2 +
|
|
44
|
+
right: -1 - o,
|
|
45
|
+
bottom: `calc(100% - ${2 + o}px)`
|
|
46
46
|
},
|
|
47
|
-
className:
|
|
47
|
+
className: n([
|
|
48
48
|
"tw-pointer-events-none tw-absolute tw-bottom-[calc(100%-4px)] tw-right-[-3px] tw-w-full tw-opacity-0 tw-z-[60]",
|
|
49
49
|
"group-hover:tw-opacity-100 group-focus:tw-opacity-100 focus-within:tw-opacity-100",
|
|
50
50
|
"tw-flex tw-justify-end",
|
|
@@ -54,14 +54,14 @@ const j = x(
|
|
|
54
54
|
T,
|
|
55
55
|
{
|
|
56
56
|
attachments: {
|
|
57
|
-
isEnabled:
|
|
57
|
+
isEnabled: p
|
|
58
58
|
},
|
|
59
|
-
items:
|
|
59
|
+
items: f
|
|
60
60
|
}
|
|
61
61
|
)
|
|
62
62
|
}
|
|
63
63
|
),
|
|
64
|
-
|
|
64
|
+
e
|
|
65
65
|
]
|
|
66
66
|
}
|
|
67
67
|
) }) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockItemWrapper.es.js","sources":["../../../src/components/BlockItemWrapper/BlockItemWrapper.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type ReactElement, memo, useRef, useState } from 'react';\n\nimport { joinClassNames } from '../../utilities';\n\nimport { DEFAULT_MENU_BUTTON_ID, Toolbar, type ToolbarItem } from './Toolbar';\nimport { DragPreviewContextProvider } from './Toolbar/context/DragPreviewContext';\nimport { MultiFlyoutContextProvider } from './Toolbar/context/MultiFlyoutContext';\nimport { type BlockItemWrapperProps } from './types';\n\nexport const BlockItemWrapper = memo(\n ({\n children,\n toolbarItems,\n shouldHideWrapper,\n shouldHideComponent = false,\n isDragging = false,\n shouldFillContainer,\n outlineOffset = 0,\n shouldBeShown = false,\n showAttachments = false,\n }: BlockItemWrapperProps): ReactElement => {\n const [openFlyoutIds, setOpenFlyoutIds] = useState<string[]>(shouldBeShown ? [DEFAULT_MENU_BUTTON_ID] : []);\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n if (shouldHideWrapper) {\n return <>{children}</>;\n }\n\n const items = toolbarItems?.filter((item): item is ToolbarItem => item !== undefined);\n\n const shouldToolbarBeVisible = openFlyoutIds.length > 0 || shouldBeShown;\n\n return (\n <DragPreviewContextProvider isDragPreview={isDragging}>\n <MultiFlyoutContextProvider openFlyoutIds={openFlyoutIds} setOpenFlyoutIds={setOpenFlyoutIds}>\n <div\n ref={wrapperRef}\n data-test-id=\"block-item-wrapper\"\n style={{\n outlineOffset,\n }}\n className={joinClassNames([\n 'tw-relative tw-group
|
|
1
|
+
{"version":3,"file":"BlockItemWrapper.es.js","sources":["../../../src/components/BlockItemWrapper/BlockItemWrapper.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type ReactElement, memo, useRef, useState } from 'react';\n\nimport { joinClassNames } from '../../utilities';\n\nimport { DEFAULT_MENU_BUTTON_ID, Toolbar, type ToolbarItem } from './Toolbar';\nimport { DragPreviewContextProvider } from './Toolbar/context/DragPreviewContext';\nimport { MultiFlyoutContextProvider } from './Toolbar/context/MultiFlyoutContext';\nimport { type BlockItemWrapperProps } from './types';\n\nexport const BlockItemWrapper = memo(\n ({\n children,\n toolbarItems,\n shouldHideWrapper,\n shouldHideComponent = false,\n isDragging = false,\n shouldFillContainer,\n outlineOffset = 0,\n shouldBeShown = false,\n showAttachments = false,\n }: BlockItemWrapperProps): ReactElement => {\n const [openFlyoutIds, setOpenFlyoutIds] = useState<string[]>(shouldBeShown ? [DEFAULT_MENU_BUTTON_ID] : []);\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n if (shouldHideWrapper) {\n return <>{children}</>;\n }\n\n const items = toolbarItems?.filter((item): item is ToolbarItem => item !== undefined);\n\n const shouldToolbarBeVisible = openFlyoutIds.length > 0 || shouldBeShown;\n\n return (\n <DragPreviewContextProvider isDragPreview={isDragging}>\n <MultiFlyoutContextProvider openFlyoutIds={openFlyoutIds} setOpenFlyoutIds={setOpenFlyoutIds}>\n <div\n ref={wrapperRef}\n data-test-id=\"block-item-wrapper\"\n style={{\n outlineOffset,\n }}\n className={joinClassNames([\n 'tw-relative tw-group',\n shouldFillContainer && 'tw-flex-1 tw-h-full tw-w-full',\n 'hover:tw-outline hover:tw-outline-1 hover:tw-outline-container-highlight-on-highlight-container focus-within:tw-outline focus-within:tw-outline-1 focus-within:tw-outline-container-highlight-on-highlight-container',\n shouldToolbarBeVisible &&\n 'tw-outline tw-outline-1 tw-outline-container-highlight-on-highlight-container',\n shouldHideComponent && 'tw-opacity-0',\n ])}\n >\n <div\n style={{\n right: -1 - outlineOffset,\n bottom: `calc(100% - ${2 + outlineOffset}px)`,\n }}\n className={joinClassNames([\n 'tw-pointer-events-none tw-absolute tw-bottom-[calc(100%-4px)] tw-right-[-3px] tw-w-full tw-opacity-0 tw-z-[60]',\n 'group-hover:tw-opacity-100 group-focus:tw-opacity-100 focus-within:tw-opacity-100',\n 'tw-flex tw-justify-end',\n shouldToolbarBeVisible && 'tw-opacity-100',\n ])}\n >\n <Toolbar\n attachments={{\n isEnabled: showAttachments,\n }}\n items={items}\n />\n </div>\n {children}\n </div>\n </MultiFlyoutContextProvider>\n </DragPreviewContextProvider>\n );\n },\n);\n\nBlockItemWrapper.displayName = 'BlockItemWrapper';\n"],"names":["BlockItemWrapper","memo","children","toolbarItems","shouldHideWrapper","shouldHideComponent","isDragging","shouldFillContainer","outlineOffset","shouldBeShown","showAttachments","openFlyoutIds","setOpenFlyoutIds","useState","DEFAULT_MENU_BUTTON_ID","wrapperRef","useRef","items","item","shouldToolbarBeVisible","DragPreviewContextProvider","jsx","MultiFlyoutContextProvider","jsxs","joinClassNames","Toolbar"],"mappings":";;;;;;;AAWO,MAAMA,IAAmBC;AAAA,EAC5B,CAAC;AAAA,IACG,UAAAC;AAAA,IACA,cAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,qBAAAC,IAAsB;AAAA,IACtB,YAAAC,IAAa;AAAA,IACb,qBAAAC;AAAA,IACA,eAAAC,IAAgB;AAAA,IAChB,eAAAC,IAAgB;AAAA,IAChB,iBAAAC,IAAkB;AAAA,EAAA,MACqB;AACvC,UAAM,CAACC,GAAeC,CAAgB,IAAIC,EAAmBJ,IAAgB,CAACK,CAAsB,IAAI,EAAE,GACpGC,IAAaC,EAAuB,IAAI;AAE9C,QAAIZ;AACA,oCAAU,UAAAF,GAAS;AAGvB,UAAMe,IAAQd,GAAc,OAAO,CAACe,MAA8BA,MAAS,MAAS,GAE9EC,IAAyBR,EAAc,SAAS,KAAKF;AAE3D,6BACKW,GAAA,EAA2B,eAAed,GACvC,UAAA,gBAAAe,EAACC,GAAA,EAA2B,eAAAX,GAA8B,kBAAAC,GACtD,UAAA,gBAAAW;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,KAAKR;AAAA,QACL,gBAAa;AAAA,QACb,OAAO;AAAA,UACH,eAAAP;AAAA,QAAA;AAAA,QAEJ,WAAWgB,EAAe;AAAA,UACtB;AAAA,UACAjB,KAAuB;AAAA,UACvB;AAAA,UACAY,KACI;AAAA,UACJd,KAAuB;AAAA,QAAA,CAC1B;AAAA,QAED,UAAA;AAAA,UAAA,gBAAAgB;AAAA,YAAC;AAAA,YAAA;AAAA,cACG,OAAO;AAAA,gBACH,OAAO,KAAKb;AAAA,gBACZ,QAAQ,eAAe,IAAIA,CAAa;AAAA,cAAA;AAAA,cAE5C,WAAWgB,EAAe;AAAA,gBACtB;AAAA,gBACA;AAAA,gBACA;AAAA,gBACAL,KAA0B;AAAA,cAAA,CAC7B;AAAA,cAED,UAAA,gBAAAE;AAAA,gBAACI;AAAA,gBAAA;AAAA,kBACG,aAAa;AAAA,oBACT,WAAWf;AAAA,kBAAA;AAAA,kBAEf,OAAAO;AAAA,gBAAA;AAAA,cAAA;AAAA,YACJ;AAAA,UAAA;AAAA,UAEHf;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA,GAET,EAAA,CACJ;AAAA,EAER;AACJ;AAEAF,EAAiB,cAAc;"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as a, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { ToolbarSegment as e } from "./ToolbarSegment.es.js";
|
|
3
|
-
import { AttachmentsToolbarButton as
|
|
3
|
+
import { AttachmentsToolbarButton as n } from "./AttachmentsToolbarButton/AttachmentsToolbarButton.es.js";
|
|
4
4
|
import { ToolbarButton as d } from "./ToolbarButton/ToolbarButton.es.js";
|
|
5
5
|
import { FlyoutToolbarButton as p } from "./FlyoutToolbarButton/FlyoutToolbarButton.es.js";
|
|
6
|
-
import { MenuToolbarButton as
|
|
7
|
-
import { DragHandleToolbarButton as
|
|
8
|
-
const
|
|
6
|
+
import { MenuToolbarButton as i } from "./MenuToolbarButton/MenuToolbarButton.es.js";
|
|
7
|
+
import { DragHandleToolbarButton as s } from "./DragHandleToolbarButton/DragHandleToolbarButton.es.js";
|
|
8
|
+
const y = ({ items: r, attachments: l }) => /* @__PURE__ */ a(
|
|
9
9
|
"div",
|
|
10
10
|
{
|
|
11
11
|
"data-test-id": "block-item-wrapper-toolbar",
|
|
12
|
-
className: "tw-rounded-md tw-bg-
|
|
12
|
+
className: "tw-rounded-md tw-bg-surface tw-border tw-border-line-mid tw-divide-x tw-divide-line-mid tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",
|
|
13
13
|
children: [
|
|
14
|
-
l.isEnabled && /* @__PURE__ */ t(e, { children: /* @__PURE__ */ t(
|
|
14
|
+
l.isEnabled && /* @__PURE__ */ t(e, { children: /* @__PURE__ */ t(n, {}) }),
|
|
15
15
|
r.length > 0 && /* @__PURE__ */ t(e, { children: r.map((o) => {
|
|
16
16
|
switch (o.type) {
|
|
17
17
|
case "dragHandle":
|
|
18
|
-
return /* @__PURE__ */ t(u, { ...o }, o.tooltip + o.type);
|
|
19
|
-
case "menu":
|
|
20
18
|
return /* @__PURE__ */ t(s, { ...o }, o.tooltip + o.type);
|
|
19
|
+
case "menu":
|
|
20
|
+
return /* @__PURE__ */ t(i, { ...o }, o.tooltip + o.type);
|
|
21
21
|
case "flyout":
|
|
22
22
|
return /* @__PURE__ */ t(p, { ...o }, o.tooltip + o.type);
|
|
23
23
|
default:
|
|
@@ -28,6 +28,6 @@ const h = ({ items: r, attachments: l }) => /* @__PURE__ */ n(
|
|
|
28
28
|
}
|
|
29
29
|
);
|
|
30
30
|
export {
|
|
31
|
-
|
|
31
|
+
y as Toolbar
|
|
32
32
|
};
|
|
33
33
|
//# sourceMappingURL=Toolbar.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.es.js","sources":["../../../../src/components/BlockItemWrapper/Toolbar/Toolbar.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { AttachmentsToolbarButton } from './AttachmentsToolbarButton';\nimport { DragHandleToolbarButton } from './DragHandleToolbarButton';\nimport { FlyoutToolbarButton } from './FlyoutToolbarButton';\nimport { MenuToolbarButton } from './MenuToolbarButton';\nimport { ToolbarButton } from './ToolbarButton';\nimport { ToolbarSegment } from './ToolbarSegment';\nimport { type ToolbarProps } from './types';\n\nexport const Toolbar = ({ items, attachments }: ToolbarProps) => (\n <div\n data-test-id=\"block-item-wrapper-toolbar\"\n className=\"tw-rounded-md tw-bg-
|
|
1
|
+
{"version":3,"file":"Toolbar.es.js","sources":["../../../../src/components/BlockItemWrapper/Toolbar/Toolbar.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { AttachmentsToolbarButton } from './AttachmentsToolbarButton';\nimport { DragHandleToolbarButton } from './DragHandleToolbarButton';\nimport { FlyoutToolbarButton } from './FlyoutToolbarButton';\nimport { MenuToolbarButton } from './MenuToolbarButton';\nimport { ToolbarButton } from './ToolbarButton';\nimport { ToolbarSegment } from './ToolbarSegment';\nimport { type ToolbarProps } from './types';\n\nexport const Toolbar = ({ items, attachments }: ToolbarProps) => (\n <div\n data-test-id=\"block-item-wrapper-toolbar\"\n className=\"tw-rounded-md tw-bg-surface tw-border tw-border-line-mid tw-divide-x tw-divide-line-mid tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate\"\n >\n {attachments.isEnabled && (\n <ToolbarSegment>\n <AttachmentsToolbarButton />\n </ToolbarSegment>\n )}\n {items.length > 0 && (\n <ToolbarSegment>\n {items.map((item) => {\n switch (item.type) {\n case 'dragHandle':\n return <DragHandleToolbarButton key={item.tooltip + item.type} {...item} />;\n case 'menu':\n return <MenuToolbarButton key={item.tooltip + item.type} {...item} />;\n case 'flyout':\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands, @typescript-eslint/no-base-to-string\n return <FlyoutToolbarButton key={item.tooltip + item.type} {...item} />;\n default:\n return <ToolbarButton key={item.tooltip + item.type} {...item} />;\n }\n })}\n </ToolbarSegment>\n )}\n </div>\n);\n"],"names":["Toolbar","items","attachments","jsxs","jsx","ToolbarSegment","AttachmentsToolbarButton","item","DragHandleToolbarButton","MenuToolbarButton","FlyoutToolbarButton","ToolbarButton"],"mappings":";;;;;;;AAUO,MAAMA,IAAU,CAAC,EAAE,OAAAC,GAAO,aAAAC,QAC7B,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACG,gBAAa;AAAA,IACb,WAAU;AAAA,IAET,UAAA;AAAA,MAAAD,EAAY,aACT,gBAAAE,EAACC,GAAA,EACG,UAAA,gBAAAD,EAACE,KAAyB,GAC9B;AAAA,MAEHL,EAAM,SAAS,KACZ,gBAAAG,EAACC,KACI,UAAAJ,EAAM,IAAI,CAACM,MAAS;AACjB,gBAAQA,EAAK,MAAA;AAAA,UACT,KAAK;AACD,qCAAQC,GAAA,EAAwD,GAAGD,KAA9BA,EAAK,UAAUA,EAAK,IAAgB;AAAA,UAC7E,KAAK;AACD,qCAAQE,GAAA,EAAkD,GAAGF,KAA9BA,EAAK,UAAUA,EAAK,IAAgB;AAAA,UACvE,KAAK;AAED,qCAAQG,GAAA,EAAoD,GAAGH,KAA9BA,EAAK,UAAUA,EAAK,IAAgB;AAAA,UACzE;AACI,qCAAQI,GAAA,EAA8C,GAAGJ,KAA9BA,EAAK,UAAUA,EAAK,IAAgB;AAAA,QAAA;AAAA,MAE3E,CAAC,EAAA,CACL;AAAA,IAAA;AAAA,EAAA;AAER;"}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { FOCUS_VISIBLE_STYLE as
|
|
1
|
+
import { FOCUS_VISIBLE_STYLE as n } from "@frontify/fondue";
|
|
2
2
|
import { joinClassNames as o } from "../../../utilities/react/joinClassNames.es.js";
|
|
3
|
-
const
|
|
3
|
+
const s = (e, r) => {
|
|
4
4
|
const t = [
|
|
5
|
-
|
|
5
|
+
n,
|
|
6
6
|
"tw-relative tw-inline-flex tw-items-center tw-justify-center",
|
|
7
7
|
"tw-h-6 tw-p-1",
|
|
8
|
-
"tw-rounded",
|
|
9
|
-
"tw-text-
|
|
8
|
+
"tw-rounded-medium",
|
|
9
|
+
"tw-text-x-small tw-font-medium",
|
|
10
10
|
"tw-gap-0.5",
|
|
11
11
|
"focus-visible:tw-z-10"
|
|
12
12
|
];
|
|
13
13
|
return r ? t.push(
|
|
14
|
-
"tw-bg-
|
|
15
|
-
"tw-text-
|
|
14
|
+
"tw-bg-container-secondary-active",
|
|
15
|
+
"tw-text-container-secondary-on-secondary-container",
|
|
16
16
|
e === "grab" ? "tw-cursor-grabbing" : "tw-cursor-pointer"
|
|
17
17
|
) : t.push(
|
|
18
|
-
"hover:tw-bg-
|
|
19
|
-
"tw-text-
|
|
18
|
+
"hover:tw-bg-container-secondary-hover active:tw-bg-container-secondary-active",
|
|
19
|
+
"tw-text-secondary hover:tw-text-container-secondary-on-secondary-container active:tw-text-container-secondary-on-secondary-container",
|
|
20
20
|
e === "grab" ? "!tw-cursor-grab active:tw-cursor-grabbing" : "tw-cursor-pointer"
|
|
21
21
|
), o(t);
|
|
22
22
|
};
|
|
23
23
|
export {
|
|
24
|
-
|
|
24
|
+
s as getToolbarButtonClassNames
|
|
25
25
|
};
|
|
26
26
|
//# sourceMappingURL=helpers.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.es.js","sources":["../../../../src/components/BlockItemWrapper/Toolbar/helpers.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { FOCUS_VISIBLE_STYLE } from '@frontify/fondue';\n\nimport { joinClassNames } from '../../../utilities';\n\nexport const getToolbarButtonClassNames = (cursor: 'grab' | 'pointer', forceActiveStyle?: boolean) => {\n const classNames = [\n FOCUS_VISIBLE_STYLE,\n 'tw-relative tw-inline-flex tw-items-center tw-justify-center',\n 'tw-h-6 tw-p-1',\n 'tw-rounded',\n 'tw-text-
|
|
1
|
+
{"version":3,"file":"helpers.es.js","sources":["../../../../src/components/BlockItemWrapper/Toolbar/helpers.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { FOCUS_VISIBLE_STYLE } from '@frontify/fondue';\n\nimport { joinClassNames } from '../../../utilities';\n\nexport const getToolbarButtonClassNames = (cursor: 'grab' | 'pointer', forceActiveStyle?: boolean) => {\n const classNames = [\n FOCUS_VISIBLE_STYLE,\n 'tw-relative tw-inline-flex tw-items-center tw-justify-center',\n 'tw-h-6 tw-p-1',\n 'tw-rounded-medium',\n 'tw-text-x-small tw-font-medium',\n 'tw-gap-0.5',\n 'focus-visible:tw-z-10',\n ];\n\n if (forceActiveStyle) {\n classNames.push(\n 'tw-bg-container-secondary-active',\n 'tw-text-container-secondary-on-secondary-container',\n cursor === 'grab' ? 'tw-cursor-grabbing' : 'tw-cursor-pointer',\n );\n } else {\n classNames.push(\n 'hover:tw-bg-container-secondary-hover active:tw-bg-container-secondary-active',\n 'tw-text-secondary hover:tw-text-container-secondary-on-secondary-container active:tw-text-container-secondary-on-secondary-container',\n cursor === 'grab' ? '!tw-cursor-grab active:tw-cursor-grabbing' : 'tw-cursor-pointer',\n );\n }\n\n return joinClassNames(classNames);\n};\n"],"names":["getToolbarButtonClassNames","cursor","forceActiveStyle","classNames","FOCUS_VISIBLE_STYLE","joinClassNames"],"mappings":";;AAMO,MAAMA,IAA6B,CAACC,GAA4BC,MAA+B;AAClG,QAAMC,IAAa;AAAA,IACfC;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAGJ,SAAIF,IACAC,EAAW;AAAA,IACP;AAAA,IACA;AAAA,IACAF,MAAW,SAAS,uBAAuB;AAAA,EAAA,IAG/CE,EAAW;AAAA,IACP;AAAA,IACA;AAAA,IACAF,MAAW,SAAS,8CAA8C;AAAA,EAAA,GAInEI,EAAeF,CAAU;AACpC;"}
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as a, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { Tooltip as o } from "@frontify/fondue/components";
|
|
3
3
|
import { IconArrowCircleDown as w } from "@frontify/fondue/icons";
|
|
4
|
-
import { useFocusRing as
|
|
5
|
-
import { joinClassNames as
|
|
6
|
-
const
|
|
7
|
-
const { isFocused:
|
|
8
|
-
return /* @__PURE__ */
|
|
4
|
+
import { useFocusRing as s } from "@react-aria/focus";
|
|
5
|
+
import { joinClassNames as m } from "../../utilities/react/joinClassNames.es.js";
|
|
6
|
+
const g = ({ onDownload: r, ariaLabel: e }) => {
|
|
7
|
+
const { isFocused: n, focusProps: i } = s();
|
|
8
|
+
return /* @__PURE__ */ a(o.Root, { enterDelay: 500, children: [
|
|
9
9
|
/* @__PURE__ */ t(o.Trigger, { asChild: !0, children: /* @__PURE__ */ t(
|
|
10
10
|
"button",
|
|
11
11
|
{
|
|
12
12
|
type: "button",
|
|
13
13
|
tabIndex: 0,
|
|
14
|
-
"aria-label":
|
|
14
|
+
"aria-label": e ?? "Download",
|
|
15
15
|
...i,
|
|
16
|
-
className:
|
|
17
|
-
"tw-outline-none tw-rounded",
|
|
18
|
-
|
|
16
|
+
className: m([
|
|
17
|
+
"tw-outline-none tw-rounded-medium",
|
|
18
|
+
n && "tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none"
|
|
19
19
|
]),
|
|
20
|
-
onClick:
|
|
21
|
-
onPointerDown: (
|
|
20
|
+
onClick: r,
|
|
21
|
+
onPointerDown: (l) => l.preventDefault(),
|
|
22
22
|
"data-test-id": "download-button",
|
|
23
|
-
children: /* @__PURE__ */ t("span", { className: "tw-flex tw-text-
|
|
23
|
+
children: /* @__PURE__ */ t("span", { className: "tw-flex tw-text-x-small tw-font-primary tw-items-center tw-gap-1 tw-rounded-full tw-bg-primary-on-primary hover:tw-bg-primary-on-primary active:tw-bg-primary-on-primary tw-text-primary tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line-mid", children: /* @__PURE__ */ t(w, { size: "16" }) })
|
|
24
24
|
}
|
|
25
25
|
) }),
|
|
26
26
|
/* @__PURE__ */ t(o.Content, { side: "top", children: "Download" })
|
|
27
27
|
] });
|
|
28
28
|
};
|
|
29
29
|
export {
|
|
30
|
-
|
|
30
|
+
g as DownloadButton
|
|
31
31
|
};
|
|
32
32
|
//# sourceMappingURL=DownloadButton.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DownloadButton.es.js","sources":["../../../src/components/DownloadButton/DownloadButton.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { Tooltip } from '@frontify/fondue/components';\nimport { IconArrowCircleDown } from '@frontify/fondue/icons';\nimport { useFocusRing } from '@react-aria/focus';\n\nimport { joinClassNames } from '../../utilities';\n\nimport { type DownloadButtonProps } from './types';\n\nexport const DownloadButton = ({ onDownload, ariaLabel }: DownloadButtonProps) => {\n const { isFocused, focusProps } = useFocusRing();\n\n return (\n <Tooltip.Root enterDelay={500}>\n <Tooltip.Trigger asChild>\n <button\n type=\"button\"\n tabIndex={0}\n aria-label={ariaLabel ?? 'Download'}\n {...focusProps}\n className={joinClassNames([\n 'tw-outline-none tw-rounded',\n isFocused &&\n 'tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none',\n ])}\n onClick={onDownload}\n onPointerDown={(e) => e.preventDefault()}\n data-test-id=\"download-button\"\n >\n <span className=\"tw-flex tw-text-
|
|
1
|
+
{"version":3,"file":"DownloadButton.es.js","sources":["../../../src/components/DownloadButton/DownloadButton.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { Tooltip } from '@frontify/fondue/components';\nimport { IconArrowCircleDown } from '@frontify/fondue/icons';\nimport { useFocusRing } from '@react-aria/focus';\n\nimport { joinClassNames } from '../../utilities';\n\nimport { type DownloadButtonProps } from './types';\n\nexport const DownloadButton = ({ onDownload, ariaLabel }: DownloadButtonProps) => {\n const { isFocused, focusProps } = useFocusRing();\n\n return (\n <Tooltip.Root enterDelay={500}>\n <Tooltip.Trigger asChild>\n <button\n type=\"button\"\n tabIndex={0}\n aria-label={ariaLabel ?? 'Download'}\n {...focusProps}\n className={joinClassNames([\n 'tw-outline-none tw-rounded-medium',\n isFocused &&\n 'tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none',\n ])}\n onClick={onDownload}\n onPointerDown={(e) => e.preventDefault()}\n data-test-id=\"download-button\"\n >\n <span className=\"tw-flex tw-text-x-small tw-font-primary tw-items-center tw-gap-1 tw-rounded-full tw-bg-primary-on-primary hover:tw-bg-primary-on-primary active:tw-bg-primary-on-primary tw-text-primary tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line-mid\">\n <IconArrowCircleDown size=\"16\" />\n </span>\n </button>\n </Tooltip.Trigger>\n <Tooltip.Content side=\"top\">Download</Tooltip.Content>\n </Tooltip.Root>\n );\n};\n"],"names":["DownloadButton","onDownload","ariaLabel","isFocused","focusProps","useFocusRing","jsxs","Tooltip","jsx","joinClassNames","e","IconArrowCircleDown"],"mappings":";;;;;AAUO,MAAMA,IAAiB,CAAC,EAAE,YAAAC,GAAY,WAAAC,QAAqC;AAC9E,QAAM,EAAE,WAAAC,GAAW,YAAAC,EAAA,IAAeC,EAAA;AAElC,SACI,gBAAAC,EAACC,EAAQ,MAAR,EAAa,YAAY,KACtB,UAAA;AAAA,IAAA,gBAAAC,EAACD,EAAQ,SAAR,EAAgB,SAAO,IACpB,UAAA,gBAAAC;AAAA,MAAC;AAAA,MAAA;AAAA,QACG,MAAK;AAAA,QACL,UAAU;AAAA,QACV,cAAYN,KAAa;AAAA,QACxB,GAAGE;AAAA,QACJ,WAAWK,EAAe;AAAA,UACtB;AAAA,UACAN,KACI;AAAA,QAAA,CACP;AAAA,QACD,SAASF;AAAA,QACT,eAAe,CAACS,MAAMA,EAAE,eAAA;AAAA,QACxB,gBAAa;AAAA,QAEb,UAAA,gBAAAF,EAAC,UAAK,WAAU,qQACZ,4BAACG,GAAA,EAAoB,MAAK,MAAK,EAAA,CACnC;AAAA,MAAA;AAAA,IAAA,GAER;AAAA,sBACCJ,EAAQ,SAAR,EAAgB,MAAK,OAAM,UAAA,WAAA,CAAQ;AAAA,EAAA,GACxC;AAER;"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { jsxs as c, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { FormControl as g } from "@frontify/fondue";
|
|
3
|
-
import { TextInput as x, Checkbox as
|
|
3
|
+
import { TextInput as x, Checkbox as D, Label as v } from "@frontify/fondue/components";
|
|
4
4
|
import { isValidUrlOrEmpty as b } from "./utils/url.es.js";
|
|
5
5
|
import { LinkSelector as I } from "./LinkSelector/LinkSelector.es.js";
|
|
6
6
|
const N = ({
|
|
7
7
|
onUrlChange: i,
|
|
8
8
|
onToggleTab: r,
|
|
9
9
|
isValidUrlOrEmpty: l,
|
|
10
|
-
appBridge:
|
|
10
|
+
appBridge: n,
|
|
11
11
|
placeholder: s,
|
|
12
|
-
newTab:
|
|
13
|
-
url:
|
|
12
|
+
newTab: m,
|
|
13
|
+
url: o = "",
|
|
14
14
|
required: d,
|
|
15
|
-
info:
|
|
15
|
+
info: a,
|
|
16
16
|
label: u,
|
|
17
17
|
buttonSize: p,
|
|
18
18
|
hideInternalLinkButton: h
|
|
19
19
|
}) => {
|
|
20
|
-
const w = l ? l(
|
|
20
|
+
const w = l ? l(o) : b(o);
|
|
21
21
|
return /* @__PURE__ */ c("div", { "data-test-id": "link-input", children: [
|
|
22
22
|
/* @__PURE__ */ t(
|
|
23
23
|
g,
|
|
@@ -26,35 +26,35 @@ const N = ({
|
|
|
26
26
|
children: u,
|
|
27
27
|
htmlFor: "url",
|
|
28
28
|
required: d,
|
|
29
|
-
tooltip:
|
|
29
|
+
tooltip: a ? { content: a, position: "top" } : void 0
|
|
30
30
|
},
|
|
31
31
|
children: /* @__PURE__ */ t(
|
|
32
32
|
x,
|
|
33
33
|
{
|
|
34
34
|
"data-test-id": "text-input",
|
|
35
35
|
id: "url",
|
|
36
|
-
value:
|
|
36
|
+
value: o,
|
|
37
37
|
onChange: (e) => i?.(e.target.value),
|
|
38
38
|
placeholder: s ?? "https://example.com"
|
|
39
39
|
}
|
|
40
40
|
)
|
|
41
41
|
}
|
|
42
42
|
),
|
|
43
|
-
!w && /* @__PURE__ */ t("div", { className: "tw-text-
|
|
43
|
+
!w && /* @__PURE__ */ t("div", { className: "tw-text-error tw-mt-1 tw-text-small", children: "Please enter a valid URL." }),
|
|
44
44
|
!h && /* @__PURE__ */ t("div", { className: "tw-mt-3", children: /* @__PURE__ */ t(
|
|
45
45
|
I,
|
|
46
46
|
{
|
|
47
|
-
url:
|
|
47
|
+
url: o,
|
|
48
48
|
onUrlChange: i,
|
|
49
49
|
buttonSize: p ?? "medium",
|
|
50
|
-
getAllDocuments: () =>
|
|
51
|
-
getDocumentPagesByDocumentId: (e) =>
|
|
52
|
-
getDocumentSectionsByDocumentPageId: (e) =>
|
|
50
|
+
getAllDocuments: () => n.getAllDocuments(),
|
|
51
|
+
getDocumentPagesByDocumentId: (e) => n.getDocumentPagesByDocumentId(e),
|
|
52
|
+
getDocumentSectionsByDocumentPageId: (e) => n.getDocumentSectionsByDocumentPageId(e)
|
|
53
53
|
}
|
|
54
54
|
) }),
|
|
55
55
|
/* @__PURE__ */ c("div", { className: "tw-mt-3 tw-flex tw-items-center tw-gap-1.5", children: [
|
|
56
|
-
/* @__PURE__ */ t(
|
|
57
|
-
/* @__PURE__ */ t(
|
|
56
|
+
/* @__PURE__ */ t(D, { id: "new-tab", value: m, onChange: () => r?.(!m) }),
|
|
57
|
+
/* @__PURE__ */ t(v, { id: "new-tab-label", htmlFor: "new-tab", className: "tw-whitespace-nowrap", children: "Open in new tab" })
|
|
58
58
|
] })
|
|
59
59
|
] });
|
|
60
60
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LinkInput.es.js","sources":["../../../src/components/Link/LinkInput.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type AppBridgeBlock } from '@frontify/app-bridge';\nimport { FormControl } from '@frontify/fondue';\nimport { TextInput, Checkbox, Label } from '@frontify/fondue/components';\n\nimport { LinkSelector } from './LinkSelector';\nimport { isValidUrlOrEmpty as internalIsValidUrlOrEmpty } from './utils';\n\ntype LinkInputProps = {\n url?: string;\n info?: string;\n label?: string;\n required?: boolean;\n newTab?: boolean;\n onUrlChange?: (value: string) => void;\n onToggleTab?: (checked: boolean) => void;\n isValidUrlOrEmpty?: (url: string) => boolean;\n appBridge: AppBridgeBlock;\n placeholder?: string;\n buttonSize?: 'small' | 'medium' | 'large';\n hideInternalLinkButton?: boolean;\n};\n\nexport const LinkInput = ({\n onUrlChange,\n onToggleTab,\n isValidUrlOrEmpty,\n appBridge,\n placeholder,\n newTab,\n url = '',\n required,\n info,\n label,\n buttonSize,\n hideInternalLinkButton,\n}: LinkInputProps) => {\n const isUrlValid = isValidUrlOrEmpty ? isValidUrlOrEmpty(url) : internalIsValidUrlOrEmpty(url);\n return (\n <div data-test-id=\"link-input\">\n <FormControl\n label={{\n children: label,\n htmlFor: 'url',\n required,\n tooltip: info ? { content: info, position: 'top' } : undefined,\n }}\n >\n <TextInput\n data-test-id=\"text-input\"\n id=\"url\"\n value={url}\n onChange={(event) => onUrlChange?.(event.target.value)}\n placeholder={placeholder ?? 'https://example.com'}\n />\n </FormControl>\n {!isUrlValid && <div className=\"tw-text-
|
|
1
|
+
{"version":3,"file":"LinkInput.es.js","sources":["../../../src/components/Link/LinkInput.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { type AppBridgeBlock } from '@frontify/app-bridge';\nimport { FormControl } from '@frontify/fondue';\nimport { TextInput, Checkbox, Label } from '@frontify/fondue/components';\n\nimport { LinkSelector } from './LinkSelector';\nimport { isValidUrlOrEmpty as internalIsValidUrlOrEmpty } from './utils';\n\ntype LinkInputProps = {\n url?: string;\n info?: string;\n label?: string;\n required?: boolean;\n newTab?: boolean;\n onUrlChange?: (value: string) => void;\n onToggleTab?: (checked: boolean) => void;\n isValidUrlOrEmpty?: (url: string) => boolean;\n appBridge: AppBridgeBlock;\n placeholder?: string;\n buttonSize?: 'small' | 'medium' | 'large';\n hideInternalLinkButton?: boolean;\n};\n\nexport const LinkInput = ({\n onUrlChange,\n onToggleTab,\n isValidUrlOrEmpty,\n appBridge,\n placeholder,\n newTab,\n url = '',\n required,\n info,\n label,\n buttonSize,\n hideInternalLinkButton,\n}: LinkInputProps) => {\n const isUrlValid = isValidUrlOrEmpty ? isValidUrlOrEmpty(url) : internalIsValidUrlOrEmpty(url);\n return (\n <div data-test-id=\"link-input\">\n <FormControl\n label={{\n children: label,\n htmlFor: 'url',\n required,\n tooltip: info ? { content: info, position: 'top' } : undefined,\n }}\n >\n <TextInput\n data-test-id=\"text-input\"\n id=\"url\"\n value={url}\n onChange={(event) => onUrlChange?.(event.target.value)}\n placeholder={placeholder ?? 'https://example.com'}\n />\n </FormControl>\n {!isUrlValid && <div className=\"tw-text-error tw-mt-1 tw-text-small\">Please enter a valid URL.</div>}\n\n {!hideInternalLinkButton && (\n <div className=\"tw-mt-3\">\n <LinkSelector\n url={url}\n onUrlChange={onUrlChange}\n buttonSize={buttonSize ?? 'medium'}\n getAllDocuments={() => appBridge.getAllDocuments()}\n getDocumentPagesByDocumentId={(documentId) =>\n appBridge.getDocumentPagesByDocumentId(documentId)\n }\n getDocumentSectionsByDocumentPageId={(documentPageId) =>\n appBridge.getDocumentSectionsByDocumentPageId(documentPageId)\n }\n />\n </div>\n )}\n\n <div className=\"tw-mt-3 tw-flex tw-items-center tw-gap-1.5\">\n <Checkbox id=\"new-tab\" value={newTab} onChange={() => onToggleTab?.(!newTab)} />\n <Label id=\"new-tab-label\" htmlFor=\"new-tab\" className=\"tw-whitespace-nowrap\">\n Open in new tab\n </Label>\n </div>\n </div>\n );\n};\n"],"names":["LinkInput","onUrlChange","onToggleTab","isValidUrlOrEmpty","appBridge","placeholder","newTab","url","required","info","label","buttonSize","hideInternalLinkButton","isUrlValid","internalIsValidUrlOrEmpty","jsxs","jsx","FormControl","TextInput","event","LinkSelector","documentId","documentPageId","Checkbox","Label"],"mappings":";;;;;AAwBO,MAAMA,IAAY,CAAC;AAAA,EACtB,aAAAC;AAAA,EACA,aAAAC;AAAA,EAAA,mBACAC;AAAAA,EACA,WA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