@frontify/guideline-blocks-settings 0.34.12 → 0.34.14

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.
@@ -1,71 +1,74 @@
1
- import { jsx as t, Fragment as y, jsxs as h } from "react/jsx-runtime";
2
- import { useState as x, useRef as g } from "react";
1
+ import { jsx as t, Fragment as v, jsxs as h } from "react/jsx-runtime";
2
+ import { memo as x, useState as g, useRef as N } from "react";
3
3
  import { DragPreviewContextProvider as b } from "./Toolbar/context/DragPreviewContext.es.js";
4
4
  import { MultiFlyoutContextProvider as F } from "./Toolbar/context/MultiFlyoutContext.es.js";
5
- import { DEFAULT_MENU_BUTTON_ID as N } from "./Toolbar/MenuToolbarButton/MenuToolbarButton.es.js";
6
- import { Toolbar as T } from "./Toolbar/Toolbar.es.js";
7
- import { joinClassNames as w } from "../../utilities/react/joinClassNames.es.js";
8
- const k = ({
9
- children: i,
10
- toolbarItems: e,
11
- shouldHideWrapper: a,
12
- shouldHideComponent: n = !1,
13
- isDragging: p = !1,
14
- shouldFillContainer: c,
15
- outlineOffset: o = 2,
16
- shouldBeShown: r = !1,
17
- showAttachments: u = !1
18
- }) => {
19
- const [l, f] = x(r ? [N] : []), m = g(null);
20
- if (a)
21
- return /* @__PURE__ */ t(y, { children: i });
22
- const d = e == null ? void 0 : e.filter((v) => v !== void 0), s = l.length > 0 || r;
23
- return /* @__PURE__ */ t(b, { isDragPreview: p, children: /* @__PURE__ */ t(F, { openFlyoutIds: l, setOpenFlyoutIds: f, children: /* @__PURE__ */ h(
24
- "div",
25
- {
26
- ref: m,
27
- "data-test-id": "block-item-wrapper",
28
- style: {
29
- outlineOffset: o
30
- },
31
- className: w([
32
- "tw-relative tw-group tw-outline-1 tw-outline-box-selected-inverse",
33
- c && "tw-flex-1 tw-h-full tw-w-full",
34
- "hover:tw-outline focus-within:tw-outline",
35
- s && "tw-outline",
36
- n && "tw-opacity-0"
37
- ]),
38
- children: [
39
- /* @__PURE__ */ t(
40
- "div",
41
- {
42
- style: {
43
- right: -1 - o,
44
- bottom: `calc(100% - ${2 + o}px)`
45
- },
46
- className: w([
47
- "tw-pointer-events-none tw-absolute tw-bottom-[calc(100%-4px)] tw-right-[-3px] tw-w-full tw-opacity-0 tw-z-[60]",
48
- "group-hover:tw-opacity-100 group-focus:tw-opacity-100 focus-within:tw-opacity-100",
49
- "tw-flex tw-justify-end",
50
- s && "tw-opacity-100"
51
- ]),
52
- children: /* @__PURE__ */ t(
53
- T,
54
- {
55
- attachments: {
56
- isEnabled: u
57
- },
58
- items: d
59
- }
60
- )
61
- }
62
- ),
63
- i
64
- ]
65
- }
66
- ) }) });
67
- };
5
+ import { DEFAULT_MENU_BUTTON_ID as T } from "./Toolbar/MenuToolbarButton/MenuToolbarButton.es.js";
6
+ import { Toolbar as j } from "./Toolbar/Toolbar.es.js";
7
+ import { joinClassNames as a } from "../../utilities/react/joinClassNames.es.js";
8
+ const D = x(
9
+ ({
10
+ children: r,
11
+ toolbarItems: e,
12
+ shouldHideWrapper: p,
13
+ shouldHideComponent: w = !1,
14
+ isDragging: n = !1,
15
+ shouldFillContainer: c,
16
+ outlineOffset: o = 2,
17
+ shouldBeShown: i = !1,
18
+ showAttachments: m = !1
19
+ }) => {
20
+ const [l, u] = g(i ? [T] : []), f = N(null);
21
+ if (p)
22
+ return /* @__PURE__ */ t(v, { children: r });
23
+ const d = e == null ? void 0 : e.filter((y) => y !== void 0), s = l.length > 0 || i;
24
+ return /* @__PURE__ */ t(b, { isDragPreview: n, children: /* @__PURE__ */ t(F, { openFlyoutIds: l, setOpenFlyoutIds: u, children: /* @__PURE__ */ h(
25
+ "div",
26
+ {
27
+ ref: f,
28
+ "data-test-id": "block-item-wrapper",
29
+ style: {
30
+ outlineOffset: o
31
+ },
32
+ className: a([
33
+ "tw-relative tw-group tw-outline-1 tw-outline-box-selected-inverse",
34
+ c && "tw-flex-1 tw-h-full tw-w-full",
35
+ "hover:tw-outline focus-within:tw-outline",
36
+ s && "tw-outline",
37
+ w && "tw-opacity-0"
38
+ ]),
39
+ children: [
40
+ /* @__PURE__ */ t(
41
+ "div",
42
+ {
43
+ style: {
44
+ right: -1 - o,
45
+ bottom: `calc(100% - ${2 + o}px)`
46
+ },
47
+ className: a([
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
+ "group-hover:tw-opacity-100 group-focus:tw-opacity-100 focus-within:tw-opacity-100",
50
+ "tw-flex tw-justify-end",
51
+ s && "tw-opacity-100"
52
+ ]),
53
+ children: /* @__PURE__ */ t(
54
+ j,
55
+ {
56
+ attachments: {
57
+ isEnabled: m
58
+ },
59
+ items: d
60
+ }
61
+ )
62
+ }
63
+ ),
64
+ r
65
+ ]
66
+ }
67
+ ) }) });
68
+ }
69
+ );
70
+ D.displayName = "BlockItemWrapper";
68
71
  export {
69
- k as BlockItemWrapper
72
+ D as BlockItemWrapper
70
73
  };
71
74
  //# sourceMappingURL=BlockItemWrapper.es.js.map
@@ -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, 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 = ({\n children,\n toolbarItems,\n shouldHideWrapper,\n shouldHideComponent = false,\n isDragging = false,\n shouldFillContainer,\n outlineOffset = 2,\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 // eslint-disable-next-line react/jsx-no-useless-fragment\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 tw-outline-1 tw-outline-box-selected-inverse',\n shouldFillContainer && 'tw-flex-1 tw-h-full tw-w-full',\n 'hover:tw-outline focus-within:tw-outline',\n shouldToolbarBeVisible && 'tw-outline',\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"],"names":["BlockItemWrapper","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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AAAA,gBACA,OAAAO;AAAA,cAAA;AAAA,YACJ;AAAA,UAAA;AAAA,QACJ;AAAA,QACCf;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA,EAET,CAAA,EACJ,CAAA;AAER;"}
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 = 2,\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 // eslint-disable-next-line react/jsx-no-useless-fragment\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 tw-outline-1 tw-outline-box-selected-inverse',\n shouldFillContainer && 'tw-flex-1 tw-h-full tw-w-full',\n 'hover:tw-outline focus-within:tw-outline',\n shouldToolbarBeVisible && 'tw-outline',\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;AACjC,UAAA,CAACC,GAAeC,CAAgB,IAAIC,EAAmBJ,IAAgB,CAACK,CAAsB,IAAI,CAAA,CAAE,GACpGC,IAAaC,EAAuB,IAAI;AAE9C,QAAIZ;AAEA,oCAAU,UAAAF,EAAS,CAAA;AAGvB,UAAMe,IAAQd,K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