@frontify/fondue 12.0.0-beta.192 → 12.0.0-beta.194
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/Button/Button.d.ts +1 -0
- package/dist/components/Button/Button.es.js +49 -48
- package/dist/components/Button/Button.es.js.map +1 -1
- package/dist/components/Tree/TreeItem/TreeItem.es.js +64 -57
- package/dist/components/Tree/TreeItem/TreeItem.es.js.map +1 -1
- package/dist/components/Tree/types.d.ts +1 -0
- package/dist/index.cjs.js +4 -4
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.umd.js +4 -4
- package/dist/index.umd.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utilities/dnd/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -21,5 +21,6 @@ export type ButtonProps = {
|
|
|
21
21
|
solid?: boolean;
|
|
22
22
|
/** @deprecated inverted can be done by wrapping the component in a className="tw-dark" */
|
|
23
23
|
inverted?: boolean;
|
|
24
|
+
'data-test-id'?: string;
|
|
24
25
|
};
|
|
25
26
|
export declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<HTMLButtonElement | null>>;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import l, { forwardRef as
|
|
2
|
-
import { useButton as
|
|
1
|
+
import l, { forwardRef as P, cloneElement as T } from "react";
|
|
2
|
+
import { useButton as O } from "@react-aria/button";
|
|
3
3
|
import { merge as r } from "../../utilities/merge.es.js";
|
|
4
|
-
import { useForwardedRef as
|
|
5
|
-
import { ButtonStyle as o, ButtonEmphasis as u, ButtonType as
|
|
6
|
-
import { UpdatedButtonStyle as
|
|
7
|
-
import { ButtonCommonClasses as
|
|
8
|
-
import { FOCUS_VISIBLE_STYLE as
|
|
9
|
-
import { buttonTypeMap as
|
|
10
|
-
import { useFocusRing as
|
|
11
|
-
const
|
|
12
|
-
type: B =
|
|
4
|
+
import { useForwardedRef as U } from "../../utilities/useForwardedRef.es.js";
|
|
5
|
+
import { ButtonStyle as o, ButtonEmphasis as u, ButtonType as V, ButtonSize as _, ButtonRounding as k } from "./ButtonTypes.es.js";
|
|
6
|
+
import { UpdatedButtonStyle as st } from "./ButtonTypes.es.js";
|
|
7
|
+
import { ButtonCommonClasses as z, ButtonRoundingClasses as W, ButtonSizeClasses as d, IconSpacingClasses as Y, ButtonStyleClasses as $, ButtonDisabledClasses as j } from "./ButtonClasses.es.js";
|
|
8
|
+
import { FOCUS_VISIBLE_STYLE as q } from "../../utilities/focusStyle.es.js";
|
|
9
|
+
import { buttonTypeMap as v, buttonIconSizeMap as A } from "./mappings.es.js";
|
|
10
|
+
import { useFocusRing as G } from "@react-aria/focus";
|
|
11
|
+
const H = ({
|
|
12
|
+
type: B = V.Button,
|
|
13
13
|
style: t = o.Default,
|
|
14
|
-
size: e =
|
|
15
|
-
rounding: b =
|
|
16
|
-
emphasis:
|
|
14
|
+
size: e = _.Medium,
|
|
15
|
+
rounding: b = k.Medium,
|
|
16
|
+
emphasis: a = u.Strong,
|
|
17
17
|
hideLabel: m = !1,
|
|
18
|
-
disabled:
|
|
19
|
-
icon:
|
|
18
|
+
disabled: n = !1,
|
|
19
|
+
icon: i,
|
|
20
20
|
children: s,
|
|
21
21
|
onClick: p,
|
|
22
22
|
hugWidth: S = !0,
|
|
@@ -24,58 +24,59 @@ const G = ({
|
|
|
24
24
|
"aria-describedby": C,
|
|
25
25
|
formId: g,
|
|
26
26
|
solid: E,
|
|
27
|
-
inverted: w
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
inverted: w,
|
|
28
|
+
"data-test-id": D = "button"
|
|
29
|
+
}, R) => {
|
|
30
|
+
t === o.Primary ? (t = o.Default, a = u.Strong) : t === o.Secondary && (t = o.Default, a = u.Default), E === !1 && (a = u.Weak);
|
|
31
|
+
const c = U(R), { buttonProps: F } = O(
|
|
32
|
+
{ onPress: () => p && p(), isDisabled: n, type: v[B] },
|
|
32
33
|
c
|
|
33
|
-
), { isFocusVisible:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
), { isFocusVisible: N, focusProps: x } = G(), f = (M) => n ? j : `${$[a][t][M]}`, I = r([
|
|
35
|
+
f("button"),
|
|
36
|
+
z,
|
|
37
|
+
W[b],
|
|
38
|
+
i && !s || m ? d[e].iconOnly : d[e].default,
|
|
38
39
|
!S && "tw-w-full"
|
|
39
40
|
]);
|
|
40
41
|
return /* @__PURE__ */ l.createElement(
|
|
41
42
|
"button",
|
|
42
43
|
{
|
|
44
|
+
"data-test-id": D,
|
|
43
45
|
"aria-label": y,
|
|
44
|
-
"aria-disabled":
|
|
46
|
+
"aria-disabled": n,
|
|
45
47
|
"aria-describedby": C,
|
|
46
48
|
ref: c,
|
|
47
|
-
className: r([
|
|
48
|
-
disabled:
|
|
49
|
-
"data-test-id": "button",
|
|
49
|
+
className: r([I, w && "tw-dark", N && q]),
|
|
50
|
+
disabled: n,
|
|
50
51
|
form: g,
|
|
51
|
-
...
|
|
52
|
-
...
|
|
52
|
+
...F,
|
|
53
|
+
...x
|
|
53
54
|
},
|
|
54
|
-
|
|
55
|
+
i && /* @__PURE__ */ l.createElement(
|
|
55
56
|
"span",
|
|
56
57
|
{
|
|
57
58
|
"data-test-id": "button-icon",
|
|
58
|
-
className: r([s && !m ?
|
|
59
|
+
className: r([s && !m ? Y[e] : "", f("icon")])
|
|
59
60
|
},
|
|
60
|
-
|
|
61
|
+
T(i, { size: A[e] })
|
|
61
62
|
),
|
|
62
|
-
s && /* @__PURE__ */ l.createElement("span", { "data-test-id": "button-text", className: r([
|
|
63
|
+
s && /* @__PURE__ */ l.createElement("span", { "data-test-id": "button-text", className: r([f("text"), m && "tw-sr-only"]) }, s)
|
|
63
64
|
);
|
|
64
|
-
},
|
|
65
|
-
|
|
65
|
+
}, J = P(H);
|
|
66
|
+
J.displayName = "FondueButton";
|
|
66
67
|
export {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
J as Button,
|
|
69
|
+
z as ButtonCommonClasses,
|
|
70
|
+
j as ButtonDisabledClasses,
|
|
70
71
|
u as ButtonEmphasis,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
k as ButtonRounding,
|
|
73
|
+
W as ButtonRoundingClasses,
|
|
74
|
+
_ as ButtonSize,
|
|
74
75
|
d as ButtonSizeClasses,
|
|
75
76
|
o as ButtonStyle,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
$ as ButtonStyleClasses,
|
|
78
|
+
V as ButtonType,
|
|
79
|
+
Y as IconSpacingClasses,
|
|
80
|
+
st as UpdatedButtonStyle
|
|
80
81
|
};
|
|
81
82
|
//# sourceMappingURL=Button.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.es.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { ForwardRefRenderFunction, MouseEvent, ReactElement, ReactNode, cloneElement, forwardRef } from 'react';\n\nimport { useButton } from '@react-aria/button';\nimport { merge } from '@utilities/merge';\nimport { useForwardedRef } from '@utilities/useForwardedRef';\nimport {\n ButtonElements,\n ButtonEmphasis,\n ButtonRounding,\n ButtonSize,\n ButtonStyle,\n ButtonType,\n UpdatedButtonStyle,\n} from './ButtonTypes';\nimport {\n ButtonCommonClasses,\n ButtonDisabledClasses,\n ButtonRoundingClasses,\n ButtonSizeClasses,\n ButtonStyleClasses,\n IconSpacingClasses,\n} from './ButtonClasses';\nimport { FOCUS_VISIBLE_STYLE } from '@utilities/focusStyle';\nimport { buttonIconSizeMap, buttonTypeMap } from '@components/Button/mappings';\nimport { useFocusRing } from '@react-aria/focus';\n\n// To be NON-Breaking but import should be done through index.ts\nexport * from './ButtonClasses';\nexport * from './ButtonTypes';\n\nexport type ButtonProps = {\n type?: ButtonType;\n style?: ButtonStyle;\n emphasis?: ButtonEmphasis;\n hideLabel?: boolean;\n size?: ButtonSize;\n rounding?: ButtonRounding;\n disabled?: boolean;\n icon?: ReactElement;\n children?: ReactNode;\n onClick?: (event?: MouseEvent<HTMLButtonElement>) => void;\n hugWidth?: boolean;\n 'aria-label'?: string;\n 'aria-describedby'?: string;\n formId?: string;\n /** @deprecated use emphasis with ButtonEmphasis.Weak */\n solid?: boolean;\n /** @deprecated inverted can be done by wrapping the component in a className=\"tw-dark\" */\n inverted?: boolean;\n};\n\nconst ButtonComponent: ForwardRefRenderFunction<HTMLButtonElement | null, ButtonProps> = (\n {\n type = ButtonType.Button,\n style = ButtonStyle.Default,\n size = ButtonSize.Medium,\n rounding = ButtonRounding.Medium,\n emphasis = ButtonEmphasis.Strong,\n hideLabel = false,\n disabled = false,\n icon,\n children,\n onClick,\n hugWidth = true,\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedBy,\n formId,\n solid,\n inverted,\n },\n externalRef,\n) => {\n // Map Style Primary, Secondary to style and emphasis\n // Primary and Secondary can be omitted from the style type\n if (style === ButtonStyle.Primary) {\n style = ButtonStyle.Default;\n emphasis = ButtonEmphasis.Strong;\n } else if (style === ButtonStyle.Secondary) {\n style = ButtonStyle.Default;\n emphasis = ButtonEmphasis.Default;\n }\n\n // Rewrite Solid to property emphasis\n if (solid === false) {\n emphasis = ButtonEmphasis.Weak;\n }\n\n const ref = useForwardedRef<HTMLButtonElement | null>(externalRef);\n const { buttonProps } = useButton(\n { onPress: () => onClick && onClick(), isDisabled: disabled, type: buttonTypeMap[type] },\n ref,\n );\n const { isFocusVisible, focusProps } = useFocusRing();\n\n const getStyles = (kind: keyof ButtonElements) =>\n !disabled\n ? `${ButtonStyleClasses[emphasis][style as unknown as UpdatedButtonStyle][kind]}`\n : ButtonDisabledClasses;\n\n const buttonClassName = merge([\n getStyles('button'),\n ButtonCommonClasses,\n ButtonRoundingClasses[rounding],\n (icon && !children) || hideLabel ? ButtonSizeClasses[size].iconOnly : ButtonSizeClasses[size].default,\n !hugWidth && 'tw-w-full',\n ]);\n\n return (\n <button\n aria-label={ariaLabel}\n aria-disabled={disabled}\n aria-describedby={ariaDescribedBy}\n ref={ref}\n className={merge([buttonClassName, inverted && 'tw-dark', isFocusVisible && FOCUS_VISIBLE_STYLE])}\n disabled={disabled}\n
|
|
1
|
+
{"version":3,"file":"Button.es.js","sources":["../../../src/components/Button/Button.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { ForwardRefRenderFunction, MouseEvent, ReactElement, ReactNode, cloneElement, forwardRef } from 'react';\n\nimport { useButton } from '@react-aria/button';\nimport { merge } from '@utilities/merge';\nimport { useForwardedRef } from '@utilities/useForwardedRef';\nimport {\n ButtonElements,\n ButtonEmphasis,\n ButtonRounding,\n ButtonSize,\n ButtonStyle,\n ButtonType,\n UpdatedButtonStyle,\n} from './ButtonTypes';\nimport {\n ButtonCommonClasses,\n ButtonDisabledClasses,\n ButtonRoundingClasses,\n ButtonSizeClasses,\n ButtonStyleClasses,\n IconSpacingClasses,\n} from './ButtonClasses';\nimport { FOCUS_VISIBLE_STYLE } from '@utilities/focusStyle';\nimport { buttonIconSizeMap, buttonTypeMap } from '@components/Button/mappings';\nimport { useFocusRing } from '@react-aria/focus';\n\n// To be NON-Breaking but import should be done through index.ts\nexport * from './ButtonClasses';\nexport * from './ButtonTypes';\n\nexport type ButtonProps = {\n type?: ButtonType;\n style?: ButtonStyle;\n emphasis?: ButtonEmphasis;\n hideLabel?: boolean;\n size?: ButtonSize;\n rounding?: ButtonRounding;\n disabled?: boolean;\n icon?: ReactElement;\n children?: ReactNode;\n onClick?: (event?: MouseEvent<HTMLButtonElement>) => void;\n hugWidth?: boolean;\n 'aria-label'?: string;\n 'aria-describedby'?: string;\n formId?: string;\n /** @deprecated use emphasis with ButtonEmphasis.Weak */\n solid?: boolean;\n /** @deprecated inverted can be done by wrapping the component in a className=\"tw-dark\" */\n inverted?: boolean;\n 'data-test-id'?: string;\n};\n\nconst ButtonComponent: ForwardRefRenderFunction<HTMLButtonElement | null, ButtonProps> = (\n {\n type = ButtonType.Button,\n style = ButtonStyle.Default,\n size = ButtonSize.Medium,\n rounding = ButtonRounding.Medium,\n emphasis = ButtonEmphasis.Strong,\n hideLabel = false,\n disabled = false,\n icon,\n children,\n onClick,\n hugWidth = true,\n 'aria-label': ariaLabel,\n 'aria-describedby': ariaDescribedBy,\n formId,\n solid,\n inverted,\n 'data-test-id': dataTestId = 'button',\n },\n externalRef,\n) => {\n // Map Style Primary, Secondary to style and emphasis\n // Primary and Secondary can be omitted from the style type\n if (style === ButtonStyle.Primary) {\n style = ButtonStyle.Default;\n emphasis = ButtonEmphasis.Strong;\n } else if (style === ButtonStyle.Secondary) {\n style = ButtonStyle.Default;\n emphasis = ButtonEmphasis.Default;\n }\n\n // Rewrite Solid to property emphasis\n if (solid === false) {\n emphasis = ButtonEmphasis.Weak;\n }\n\n const ref = useForwardedRef<HTMLButtonElement | null>(externalRef);\n const { buttonProps } = useButton(\n { onPress: () => onClick && onClick(), isDisabled: disabled, type: buttonTypeMap[type] },\n ref,\n );\n const { isFocusVisible, focusProps } = useFocusRing();\n\n const getStyles = (kind: keyof ButtonElements) =>\n !disabled\n ? `${ButtonStyleClasses[emphasis][style as unknown as UpdatedButtonStyle][kind]}`\n : ButtonDisabledClasses;\n\n const buttonClassName = merge([\n getStyles('button'),\n ButtonCommonClasses,\n ButtonRoundingClasses[rounding],\n (icon && !children) || hideLabel ? ButtonSizeClasses[size].iconOnly : ButtonSizeClasses[size].default,\n !hugWidth && 'tw-w-full',\n ]);\n\n return (\n <button\n data-test-id={dataTestId}\n aria-label={ariaLabel}\n aria-disabled={disabled}\n aria-describedby={ariaDescribedBy}\n ref={ref}\n className={merge([buttonClassName, inverted && 'tw-dark', isFocusVisible && FOCUS_VISIBLE_STYLE])}\n disabled={disabled}\n form={formId}\n {...buttonProps}\n {...focusProps}\n >\n {icon && (\n <span\n data-test-id=\"button-icon\"\n className={merge([children && !hideLabel ? IconSpacingClasses[size] : '', getStyles('icon')])}\n >\n {cloneElement(icon, { size: buttonIconSizeMap[size] })}\n </span>\n )}\n {children && (\n <span data-test-id=\"button-text\" className={merge([getStyles('text'), hideLabel && 'tw-sr-only'])}>\n {children}\n </span>\n )}\n </button>\n );\n};\n\nexport const Button = forwardRef(ButtonComponent);\nButton.displayName = 'FondueButton';\n"],"names":["ButtonComponent","type","ButtonType","style","ButtonStyle","size","ButtonSize","rounding","ButtonRounding","emphasis","ButtonEmphasis","hideLabel","disabled","icon","children","onClick","hugWidth","ariaLabel","ariaDescribedBy","formId","solid","inverted","dataTestId","externalRef","ref","useForwardedRef","buttonProps","useButton","buttonTypeMap","isFocusVisible","focusProps","useFocusRing","getStyles","kind","ButtonDisabledClasses","ButtonStyleClasses","buttonClassName","merge","ButtonCommonClasses","ButtonRoundingClasses","ButtonSizeClasses","React","FOCUS_VISIBLE_STYLE","IconSpacingClasses","cloneElement","buttonIconSizeMap","Button","forwardRef"],"mappings":";;;;;;;;;;AAsDA,MAAMA,IAAmF,CACrF;AAAA,EACI,MAAAC,IAAOC,EAAW;AAAA,EAClB,OAAAC,IAAQC,EAAY;AAAA,EACpB,MAAAC,IAAOC,EAAW;AAAA,EAClB,UAAAC,IAAWC,EAAe;AAAA,EAC1B,UAAAC,IAAWC,EAAe;AAAA,EAC1B,WAAAC,IAAY;AAAA,EACZ,UAAAC,IAAW;AAAA,EACX,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,cAAcC;AAAA,EACd,oBAAoBC;AAAA,EACpB,QAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,gBAAgBC,IAAa;AACjC,GACAC,MACC;AAGG,EAAApB,MAAUC,EAAY,WACtBD,IAAQC,EAAY,SACpBK,IAAWC,EAAe,UACnBP,MAAUC,EAAY,cAC7BD,IAAQC,EAAY,SACpBK,IAAWC,EAAe,UAI1BU,MAAU,OACVX,IAAWC,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M,CAACL,EAAU,MAAM,GAAGrB,KAAa,YAAY,CAAC,KAC3FG,CACL;AAAA,EAAA;AAIhB,GAEagC,IAASC,EAAW/C,CAAe;AAChD8C,EAAO,cAAc;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import g, { useMemo as h, useCallback as X, Children as Z, useLayoutEffect as Ot } from "react";
|
|
2
2
|
import { motion as Rt } from "framer-motion";
|
|
3
3
|
import { useSortable as Mt } from "@dnd-kit/sortable";
|
|
4
4
|
import { useDndContext as kt, useDndMonitor as Wt } from "@dnd-kit/core";
|
|
@@ -11,15 +11,15 @@ import { INDENTATION_WIDTH as tt, ROOT_ID as Ut } from "../Tree.es.js";
|
|
|
11
11
|
import { removeFragmentsAndEnrichChildren as $t } from "../utils/removeFragmentsAndEnrichChildren.es.js";
|
|
12
12
|
import Kt from "../../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/noop.es.js";
|
|
13
13
|
import { getItemPositionInParent as et } from "../helpers/getItemPositionInParent.es.js";
|
|
14
|
-
const Vt = ({ isSorting:
|
|
15
|
-
id:
|
|
14
|
+
const Vt = ({ isSorting: r, wasDragging: C }) => !(r || C), Yt = ({
|
|
15
|
+
id: r,
|
|
16
16
|
type: C,
|
|
17
17
|
label: f,
|
|
18
18
|
onDrop: S,
|
|
19
19
|
accepts: nt,
|
|
20
20
|
children: x,
|
|
21
|
-
parentId:
|
|
22
|
-
level:
|
|
21
|
+
parentId: c,
|
|
22
|
+
level: u = 0,
|
|
23
23
|
contentComponent: N,
|
|
24
24
|
draggable: at = !0,
|
|
25
25
|
"data-test-id": rt = "fondue-tree-item"
|
|
@@ -28,66 +28,72 @@ const Vt = ({ isSorting: a, wasDragging: C }) => !(a || C), Yt = ({
|
|
|
28
28
|
const {
|
|
29
29
|
onExpand: st,
|
|
30
30
|
onSelect: L,
|
|
31
|
-
treeState:
|
|
31
|
+
treeState: o,
|
|
32
32
|
registerOverlay: O,
|
|
33
33
|
registerNodeChildren: R,
|
|
34
34
|
unregisterNodeChildren: P,
|
|
35
35
|
draggable: dt
|
|
36
|
-
} = Bt(), { active:
|
|
36
|
+
} = Bt(), { active: s, over: d } = kt(), M = dt && at, n = (s == null ? void 0 : s.id) === r, ot = o.nodes.findIndex(({ props: e }) => e.id === (s == null ? void 0 : s.id)), it = o.nodes.findIndex(({ props: e }) => e.id === (d == null ? void 0 : d.id)), y = ot < it, v = !y, t = h(() => n ? o.projection : null, [n, o.projection]), p = h(() => o.nodes.find(({ props: e }) => e.id === (t == null ? void 0 : t.parentId)), [t == null ? void 0 : t.parentId, o.nodes]), b = h(() => {
|
|
37
37
|
var e;
|
|
38
|
-
return t !== null &&
|
|
39
|
-
}, [t,
|
|
40
|
-
let D =
|
|
38
|
+
return t !== null && d !== null && t.depth > ((e = d.data.current) == null ? void 0 : e.level);
|
|
39
|
+
}, [t, d]), T = n && !b && s.data.current && ((H = d == null ? void 0 : d.data.current) == null ? void 0 : H.accepts) !== void 0 && d.data.current.accepts.includes(s.data.current.type);
|
|
40
|
+
let D = y && n && b && s.data.current && ((U = d == null ? void 0 : d.data.current) == null ? void 0 : U.accepts) !== void 0 && (t == null ? void 0 : t.depth) !== (t == null ? void 0 : t.minDepth) && d.data.current.accepts.includes(`${s.data.current.type}-within`), m = v && n && b && s.data.current && t && (p == null ? void 0 : p.props.accepts) && p.props.accepts.includes(`${s.data.current.type}-within`);
|
|
41
41
|
const ct = (e) => {
|
|
42
42
|
var $, K, V, Y, q, z, G, J, Q;
|
|
43
|
-
const { over:
|
|
44
|
-
if (!(I.id === (
|
|
43
|
+
const { over: i, active: I } = e;
|
|
44
|
+
if (!(I.id === (i == null ? void 0 : i.id) && (t == null ? void 0 : t.depth) === (t == null ? void 0 : t.minDepth)) && (v && (D = !1), y && (m = !1), n && i && (T || D || m))) {
|
|
45
45
|
const At = et(
|
|
46
|
-
{ id:
|
|
47
|
-
|
|
46
|
+
{ id: i.id, parentId: (K = ($ = i.data) == null ? void 0 : $.current) == null ? void 0 : K.parentId },
|
|
47
|
+
o.nodes
|
|
48
48
|
), Lt = et(
|
|
49
49
|
{ id: I.id, parentId: (Y = (V = I.data) == null ? void 0 : V.current) == null ? void 0 : Y.parentId },
|
|
50
|
-
|
|
50
|
+
o.nodes
|
|
51
51
|
);
|
|
52
52
|
let A = null;
|
|
53
|
-
T ? A = "after" : (D ||
|
|
53
|
+
T ? A = "after" : (D || m) && (A = "within"), S == null || S(
|
|
54
54
|
{
|
|
55
|
-
id:
|
|
56
|
-
type:
|
|
57
|
-
sort: At + 1
|
|
55
|
+
id: m ? ((q = t == null ? void 0 : t.parentId) == null ? void 0 : q.toString()) ?? "ID not found" : i.id.toString(),
|
|
56
|
+
type: m ? p == null ? void 0 : p.props.type : (G = (z = i == null ? void 0 : i.data) == null ? void 0 : z.current) == null ? void 0 : G.type,
|
|
57
|
+
sort: At + 1,
|
|
58
|
+
parentId: (t == null ? void 0 : t.parentId) ?? ""
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: I.id.toString(),
|
|
62
|
+
type: (Q = (J = I.data) == null ? void 0 : J.current) == null ? void 0 : Q.type,
|
|
63
|
+
sort: Lt + 1,
|
|
64
|
+
parentId: c ?? ""
|
|
58
65
|
},
|
|
59
|
-
{ id: I.id.toString(), type: (Q = (J = I.data) == null ? void 0 : J.current) == null ? void 0 : Q.type, sort: Lt + 1 },
|
|
60
66
|
A,
|
|
61
|
-
|
|
67
|
+
v ? "up" : "down"
|
|
62
68
|
);
|
|
63
69
|
}
|
|
64
70
|
}, lt = X(
|
|
65
71
|
(e) => {
|
|
66
|
-
e.active.id ===
|
|
72
|
+
e.active.id === r && O({ contentComponent: N, children: x, id: r, label: f, level: u });
|
|
67
73
|
},
|
|
68
|
-
[x, N,
|
|
74
|
+
[x, N, r, f, u, O]
|
|
69
75
|
);
|
|
70
76
|
Wt({
|
|
71
77
|
onDragEnd: ct,
|
|
72
78
|
onDragStart: lt
|
|
73
79
|
});
|
|
74
|
-
const
|
|
75
|
-
() => $t(x, { parentId:
|
|
76
|
-
[x,
|
|
77
|
-
), ut = h(() =>
|
|
78
|
-
id:
|
|
80
|
+
const w = o.selectedIds.has(r), E = o.expandedIds.has(r), k = c === Ut, W = c && (s == null ? void 0 : s.id) === c, _ = k || c && o.expandedIds.has(c), B = k || c && o.nodes.some((e) => e.props.id === c), F = Z.count(x) > 0, l = h(
|
|
81
|
+
() => $t(x, { parentId: r, level: u + 1 }),
|
|
82
|
+
[x, r, u]
|
|
83
|
+
), ut = h(() => l.map((e) => e.props.id), [l]), { attributes: pt, listeners: mt, transform: a, setDraggableNodeRef: wt, setDroppableNodeRef: gt, setActivatorNodeRef: ht } = Mt({
|
|
84
|
+
id: r,
|
|
79
85
|
disabled: !M,
|
|
80
|
-
data: { type: C, accepts: nt, parentId:
|
|
86
|
+
data: { type: C, accepts: nt, parentId: c, level: u },
|
|
81
87
|
animateLayoutChanges: Vt,
|
|
82
88
|
transition: null
|
|
83
89
|
});
|
|
84
90
|
Ot(() => {
|
|
85
|
-
if (Z.count(
|
|
91
|
+
if (Z.count(l) !== 0) {
|
|
86
92
|
if (!B || !_ || n || W) {
|
|
87
|
-
P(
|
|
93
|
+
P(l);
|
|
88
94
|
return;
|
|
89
95
|
}
|
|
90
|
-
E ? R({ id:
|
|
96
|
+
E ? R({ id: l[0].props.parentId, children: l }) : P(l);
|
|
91
97
|
}
|
|
92
98
|
}, [
|
|
93
99
|
n,
|
|
@@ -95,56 +101,57 @@ const Vt = ({ isSorting: a, wasDragging: C }) => !(a || C), Yt = ({
|
|
|
95
101
|
W,
|
|
96
102
|
_,
|
|
97
103
|
B,
|
|
98
|
-
|
|
104
|
+
l,
|
|
99
105
|
R,
|
|
100
106
|
P
|
|
101
107
|
]);
|
|
102
108
|
const ft = X(
|
|
103
109
|
(e) => {
|
|
104
|
-
e.stopPropagation(), L(
|
|
110
|
+
e.stopPropagation(), L(r);
|
|
105
111
|
},
|
|
106
|
-
[
|
|
112
|
+
[r, L]
|
|
107
113
|
), xt = (e) => {
|
|
108
|
-
e.stopPropagation(), st(
|
|
114
|
+
e.stopPropagation(), st(r);
|
|
109
115
|
}, bt = h(
|
|
110
116
|
() => j([
|
|
111
117
|
_t,
|
|
112
|
-
!n && !
|
|
118
|
+
!n && !w && "focus-within:tw-bg-box-neutral",
|
|
113
119
|
"tw-outline-none tw-ring-inset tw-group tw-px-2.5 tw-no-underline tw-leading-5 tw-h-10",
|
|
114
|
-
|
|
120
|
+
w && !(a != null && a.y) ? "tw-font-medium tw-bg-box-neutral-strong tw-text-box-neutral-strong-inverse hover:tw-bg-box-neutral-strong-hover" : "hover:tw-bg-box-neutral tw-text-text",
|
|
121
|
+
a != null && a.y ? "tw-bg-box-neutral-strong-inverse tw-text-text tw-font-normal" : ""
|
|
115
122
|
]),
|
|
116
|
-
[n,
|
|
123
|
+
[n, w, a]
|
|
117
124
|
), It = j([
|
|
118
125
|
"tw-flex tw-items-center tw-h-10 tw-leading-5 tw-width-full",
|
|
119
126
|
n && "tw-border-box-selected-strong tw-border-dashed tw-border-2 tw-bg-box-selected-hover",
|
|
120
|
-
n && (b && !(
|
|
121
|
-
]),
|
|
122
|
-
paddingLeft:
|
|
127
|
+
n && (b && !(y && D || v && m) || !b && !T) && "tw-bg-box-negative-hover tw-border-box-negative-strong-hover tw-border-dashed tw-border-2"
|
|
128
|
+
]), yt = t != null && t.depth ? t.depth * tt : void 0, vt = n ? 0 : u * tt, Dt = {
|
|
129
|
+
paddingLeft: yt ?? vt
|
|
123
130
|
}, Et = !n, Ct = E && !n, St = M && !n, Nt = f !== void 0 && !n, Pt = F && !n, Tt = {
|
|
124
|
-
x:
|
|
125
|
-
y:
|
|
131
|
+
x: a == null ? void 0 : a.x,
|
|
132
|
+
y: a == null ? void 0 : a.y
|
|
126
133
|
};
|
|
127
|
-
return /* @__PURE__ */
|
|
134
|
+
return /* @__PURE__ */ g.createElement(
|
|
128
135
|
"li",
|
|
129
136
|
{
|
|
130
|
-
key:
|
|
137
|
+
key: r,
|
|
131
138
|
tabIndex: 0,
|
|
132
139
|
role: "treeitem",
|
|
133
140
|
style: Dt,
|
|
134
|
-
id:
|
|
141
|
+
id: r.toString(),
|
|
135
142
|
"aria-label": f,
|
|
136
|
-
"aria-level":
|
|
143
|
+
"aria-level": u,
|
|
137
144
|
onClick: ft,
|
|
138
145
|
className: bt,
|
|
139
|
-
ref:
|
|
146
|
+
ref: gt,
|
|
140
147
|
"data-test-id": rt,
|
|
141
|
-
"aria-selected":
|
|
148
|
+
"aria-selected": w,
|
|
142
149
|
"aria-expanded": E,
|
|
143
150
|
"data-has-children": F,
|
|
144
151
|
"aria-owns": ut.join(" "),
|
|
145
152
|
onKeyDown: Kt
|
|
146
153
|
},
|
|
147
|
-
/* @__PURE__ */
|
|
154
|
+
/* @__PURE__ */ g.createElement(
|
|
148
155
|
Rt.div,
|
|
149
156
|
{
|
|
150
157
|
transition: {
|
|
@@ -152,21 +159,21 @@ const Vt = ({ isSorting: a, wasDragging: C }) => !(a || C), Yt = ({
|
|
|
152
159
|
delay: 0,
|
|
153
160
|
duration: 0
|
|
154
161
|
},
|
|
155
|
-
ref:
|
|
162
|
+
ref: wt,
|
|
156
163
|
className: It,
|
|
157
|
-
animate:
|
|
164
|
+
animate: a ? Tt : void 0
|
|
158
165
|
},
|
|
159
|
-
St ? /* @__PURE__ */
|
|
160
|
-
/* @__PURE__ */
|
|
166
|
+
St ? /* @__PURE__ */ g.createElement(Ft, { ref: ht, active: w, ...mt, ...pt }) : /* @__PURE__ */ g.createElement("div", { className: "tw-w-5 tw-ml-2 tw-min-w-[20px]" }),
|
|
167
|
+
/* @__PURE__ */ g.createElement(
|
|
161
168
|
Ht,
|
|
162
169
|
{
|
|
163
170
|
onClick: xt,
|
|
164
171
|
expanded: Ct,
|
|
165
172
|
disabled: !Pt,
|
|
166
|
-
active:
|
|
173
|
+
active: a != null && a.y ? !1 : w
|
|
167
174
|
}
|
|
168
175
|
),
|
|
169
|
-
Nt ? /* @__PURE__ */
|
|
176
|
+
Nt ? /* @__PURE__ */ g.createElement("span", { className: "first:tw-ml-3.5 tw-w-full tw-h-full tw-flex tw-items-center" }, f) : null,
|
|
170
177
|
Et && N
|
|
171
178
|
)
|
|
172
179
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TreeItem.es.js","sources":["../../../../src/components/Tree/TreeItem/TreeItem.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { Children, MouseEvent, useCallback, useLayoutEffect, useMemo } from 'react';\nimport { motion } from 'framer-motion';\nimport { AnimateLayoutChanges, useSortable } from '@dnd-kit/sortable';\nimport { useDndContext, useDndMonitor } from '@dnd-kit/core';\nimport { noop } from 'lodash-es';\n\nimport { merge } from '@utilities/merge';\nimport { FOCUS_VISIBLE_STYLE } from '@utilities/focusStyle';\n\nimport type { CollisionPosition, TreeDragEndEvent, TreeDragStartEvent, TreeItemProps } from '@components/Tree/types';\nimport { useTreeContext } from '@components/Tree/TreeContext';\n\nimport { DragHandle } from './DragHandle';\nimport { removeFragmentsAndEnrichChildren } from '../utils';\nimport { ExpandButton } from './ExpandButton';\nimport { INDENTATION_WIDTH, ROOT_ID } from '../Tree';\nimport { getItemPositionInParent } from '../helpers';\n\nconst animateLayoutChanges: AnimateLayoutChanges = ({ isSorting, wasDragging }) =>\n isSorting || wasDragging ? false : true;\n\nexport const TreeItem = ({\n id,\n type,\n label,\n onDrop,\n accepts,\n children,\n parentId,\n level = 0,\n contentComponent,\n draggable: itemDraggable = true,\n 'data-test-id': dataTestId = 'fondue-tree-item',\n}: TreeItemProps) => {\n const {\n onExpand,\n onSelect,\n treeState,\n registerOverlay,\n registerNodeChildren,\n unregisterNodeChildren,\n draggable: treeDraggable,\n } = useTreeContext();\n\n const { active, over } = useDndContext();\n\n const draggable = treeDraggable && itemDraggable;\n\n const isActive = active?.id === id;\n\n const activeIndex = treeState.nodes.findIndex(({ props }) => props.id === active?.id);\n const overIndex = treeState.nodes.findIndex(({ props }) => props.id === over?.id);\n\n const movingDown = activeIndex < overIndex;\n const movingUp = !movingDown;\n\n const projection = useMemo(() => {\n return isActive ? treeState.projection : null;\n }, [isActive, treeState.projection]);\n\n const projectionNode = useMemo(() => {\n return treeState.nodes.find(({ props }) => props.id === projection?.parentId);\n }, [projection?.parentId, treeState.nodes]);\n\n const isWithin = useMemo(() => {\n return projection !== null && over !== null && projection.depth > over.data.current?.level;\n }, [projection, over]);\n\n const canDrop =\n isActive &&\n !isWithin &&\n active.data.current &&\n over?.data.current?.accepts !== undefined &&\n over.data.current.accepts.includes(active.data.current.type);\n\n // Moving down the tree\n let canDropWithinMovingDown =\n movingDown &&\n isActive &&\n isWithin &&\n active.data.current &&\n over?.data.current?.accepts !== undefined &&\n projection?.depth !== projection?.minDepth &&\n over.data.current.accepts.includes(`${active.data.current.type}-within`);\n\n // Moving up the tree\n let canDropWithinMovingUp =\n movingUp &&\n isActive &&\n isWithin &&\n active.data.current &&\n projection &&\n projectionNode?.props.accepts &&\n projectionNode.props.accepts.includes(`${active.data.current.type}-within`);\n\n const handleItemDragEnd = (event: TreeDragEndEvent) => {\n const { over, active } = event;\n\n if (active.id === over?.id && projection?.depth === projection?.minDepth) {\n return;\n }\n\n if (movingUp) {\n canDropWithinMovingDown = false;\n }\n\n if (movingDown) {\n canDropWithinMovingUp = false;\n }\n\n if (isActive && over && (canDrop || canDropWithinMovingDown || canDropWithinMovingUp)) {\n const sortOver = getItemPositionInParent(\n { id: over.id, parentId: over.data?.current?.parentId },\n treeState.nodes,\n );\n\n const sortActive = getItemPositionInParent(\n { id: active.id, parentId: active.data?.current?.parentId },\n treeState.nodes,\n );\n\n let position: CollisionPosition = null;\n if (canDrop) {\n position = 'after';\n } else if (canDropWithinMovingDown || canDropWithinMovingUp) {\n position = 'within';\n }\n\n onDrop?.(\n {\n id: canDropWithinMovingUp ? projection?.parentId?.toString() ?? 'ID not found' : over.id.toString(),\n type: canDropWithinMovingUp ? projectionNode?.props.type : over?.data?.current?.type,\n sort: sortOver + 1,\n },\n { id: active.id.toString(), type: active.data?.current?.type, sort: sortActive + 1 },\n position,\n movingUp ? 'up' : 'down',\n );\n }\n };\n\n const handleItemDragStart = useCallback(\n (event: TreeDragStartEvent) => {\n if (event.active.id !== id) {\n return;\n }\n\n registerOverlay({ contentComponent, children, id, label, level });\n },\n [children, contentComponent, id, label, level, registerOverlay],\n );\n\n useDndMonitor({\n onDragEnd: handleItemDragEnd,\n onDragStart: handleItemDragStart,\n });\n\n const isSelected = treeState.selectedIds.has(id);\n const isExpanded = treeState.expandedIds.has(id);\n\n const isParentRoot = parentId === ROOT_ID;\n const isParentActive = parentId && active?.id === parentId;\n const isParentExpanded = isParentRoot || (parentId && treeState.expandedIds.has(parentId));\n const isAncestorMounted = isParentRoot || (parentId && treeState.nodes.some((node) => node.props.id === parentId));\n\n const hasChildren = Children.count(children) > 0;\n\n const enrichedChildren = useMemo(\n () => removeFragmentsAndEnrichChildren(children, { parentId: id, level: level + 1 }),\n [children, id, level],\n );\n\n const childrenIds = useMemo(() => enrichedChildren.map((child) => child.props.id), [enrichedChildren]);\n\n const { attributes, listeners, transform, setDraggableNodeRef, setDroppableNodeRef, setActivatorNodeRef } =\n useSortable({\n id,\n disabled: !draggable,\n data: { type, accepts, parentId, level },\n animateLayoutChanges,\n transition: null,\n });\n\n useLayoutEffect(() => {\n if (Children.count(enrichedChildren) === 0) {\n return;\n }\n\n if (!isAncestorMounted || !isParentExpanded || isActive || isParentActive) {\n unregisterNodeChildren(enrichedChildren);\n return;\n }\n\n if (isExpanded) {\n registerNodeChildren({ id: enrichedChildren[0].props.parentId, children: enrichedChildren });\n } else {\n unregisterNodeChildren(enrichedChildren);\n }\n }, [\n isActive,\n isExpanded,\n isParentActive,\n isParentExpanded,\n isAncestorMounted,\n enrichedChildren,\n registerNodeChildren,\n unregisterNodeChildren,\n ]);\n\n const handleSelect = useCallback(\n (event: MouseEvent<HTMLElement, globalThis.MouseEvent>) => {\n event.stopPropagation();\n\n onSelect(id);\n },\n [id, onSelect],\n );\n\n const handleExpand = (event: MouseEvent<HTMLButtonElement, globalThis.MouseEvent>) => {\n event.stopPropagation();\n\n onExpand(id);\n };\n\n const liClassName = useMemo(\n () =>\n merge([\n FOCUS_VISIBLE_STYLE,\n !isActive && !isSelected && 'focus-within:tw-bg-box-neutral',\n 'tw-outline-none tw-ring-inset tw-group tw-px-2.5 tw-no-underline tw-leading-5 tw-h-10',\n isSelected\n ? 'tw-font-medium tw-bg-box-neutral-strong tw-text-box-neutral-strong-inverse hover:tw-bg-box-neutral-strong-hover'\n : 'hover:tw-bg-box-neutral tw-text-text',\n ]),\n [isActive, isSelected],\n );\n\n const containerClassName = merge([\n 'tw-flex tw-items-center tw-h-10 tw-leading-5 tw-width-full',\n isActive && 'tw-border-box-selected-strong tw-border-dashed tw-border-2 tw-bg-box-selected-hover',\n isActive &&\n ((isWithin && !((movingDown && canDropWithinMovingDown) || (movingUp && canDropWithinMovingUp))) ||\n (!isWithin && !canDrop)) &&\n 'tw-bg-box-negative-hover tw-border-box-negative-strong-hover tw-border-dashed tw-border-2',\n ]);\n\n const depthPadding = projection?.depth ? projection.depth * INDENTATION_WIDTH : undefined;\n const levelPadding = isActive ? 0 : level * INDENTATION_WIDTH;\n\n const liStyle = {\n paddingLeft: depthPadding ?? levelPadding,\n };\n\n const showContent = !isActive;\n const showChildren = isExpanded && !isActive;\n const showDragHandle = draggable && !isActive;\n const showLabel = label !== undefined && !isActive;\n const showExpandButton = hasChildren && !isActive;\n\n const animate = {\n x: transform?.x,\n y: transform?.y,\n };\n\n return (\n <li\n key={id}\n tabIndex={0}\n role=\"treeitem\"\n style={liStyle}\n id={id.toString()}\n aria-label={label}\n aria-level={level}\n onClick={handleSelect}\n className={liClassName}\n ref={setDroppableNodeRef}\n data-test-id={dataTestId}\n aria-selected={isSelected}\n aria-expanded={isExpanded}\n data-has-children={hasChildren}\n aria-owns={childrenIds.join(' ')}\n onKeyDown={noop}\n >\n <motion.div\n transition={{\n bounce: 0,\n delay: 0,\n duration: 0,\n }}\n ref={setDraggableNodeRef}\n className={containerClassName}\n animate={transform ? animate : undefined}\n >\n {showDragHandle ? (\n <DragHandle ref={setActivatorNodeRef} active={isSelected} {...listeners} {...attributes} />\n ) : (\n <div className=\"tw-w-5 tw-ml-2 tw-min-w-[20px]\" />\n )}\n\n <ExpandButton\n onClick={handleExpand}\n expanded={showChildren}\n disabled={!showExpandButton}\n active={isSelected}\n />\n\n {showLabel ? (\n <span className=\"first:tw-ml-3.5 tw-w-full tw-h-full tw-flex tw-items-center\">{label}</span>\n ) : null}\n\n {showContent && contentComponent}\n </motion.div>\n </li>\n );\n};\n\nTreeItem.displayName = 'FondueTreeItem';\n"],"names":["animateLayoutChanges","isSorting","wasDragging","TreeItem","id","type","label","onDrop","accepts","children","parentId","level","contentComponent","itemDraggable","dataTestId","onExpand","onSelect","treeState","registerOverlay","registerNodeChildren","unregisterNodeChildren","treeDraggable","useTreeContext","active","over","useDndContext","draggable","isActive","activeIndex","props","overIndex","movingDown","movingUp","projection","useMemo","projectionNode","isWithin","_a","canDrop","canDropWithinMovingDown","_b","canDropWithinMovingUp","handleItemDragEnd","event","sortOver","getItemPositionInParent","sortActive","position","_e","handleItemDragStart","useCallback","useDndMonitor","isSelected","isExpanded","isParentRoot","ROOT_ID","isParentActive","isParentExpanded","isAncestorMounted","node","hasChildren","Children","enrichedChildren","removeFragmentsAndEnrichChildren","childrenIds","child","attributes","listeners","transform","setDraggableNodeRef","setDroppableNodeRef","setActivatorNodeRef","useSortable","useLayoutEffect","handleSelect","handleExpand","liClassName","merge","FOCUS_VISIBLE_STYLE","containerClassName","depthPadding","INDENTATION_WIDTH","levelPadding","liStyle","showContent","showChildren","showDragHandle","showLabel","showExpandButton","animate","React","noop","motion","DragHandle","ExpandButton"],"mappings":";;;;;;;;;;;;;AAoBA,MAAMA,KAA6C,CAAC,EAAE,WAAAC,GAAW,aAAAC,QAC7D,EAAAD,KAAaC,IAEJC,KAAW,CAAC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,YAAY;AAAA,UACR,QAAQ;AAAA,UACR,OAAO;AAAA,UACP,UAAU;AAAA,QACd;AAAA,QACA,KAAKvB;AAAA,QACL,WAAWU;AAAA,QACX,SAASX,IAAYqB,KAAU;AAAA,MAAA;AAAA,MAE9BH,KACG,gBAAAI,EAAA,cAACG,IAAW,EAAA,KAAKtB,IAAqB,QAAQnB,GAAa,GAAGe,IAAY,GAAGD,GAAY,CAAA,IAExF,gBAAAwB,EAAA,cAAA,OAAA,EAAI,WAAU,kCAAiC;AAAA,MAGpD,gBAAAA,EAAA;AAAA,QAACI;AAAA,QAAA;AAAA,UACG,SAASnB;AAAA,UACT,UAAUU;AAAA,UACV,UAAU,CAACG;AAAA,UACX,QAAQpC;AAAA,QAAA;AAAA,MACZ;AAAA,MAECmC,KACI,gBAAAG,EAAA,cAAA,QAAA,EAAK,WAAU,8DAAA,GAA+DpF,CAAM,IACrF;AAAA,MAEH8E,MAAexE;AAAA,IACpB;AAAA,EAAA;AAGZ;AAEAT,GAAS,cAAc;"}
|
|
1
|
+
{"version":3,"file":"TreeItem.es.js","sources":["../../../../src/components/Tree/TreeItem/TreeItem.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport React, { Children, MouseEvent, useCallback, useLayoutEffect, useMemo } from 'react';\nimport { motion } from 'framer-motion';\nimport { AnimateLayoutChanges, useSortable } from '@dnd-kit/sortable';\nimport { useDndContext, useDndMonitor } from '@dnd-kit/core';\nimport { noop } from 'lodash-es';\n\nimport { merge } from '@utilities/merge';\nimport { FOCUS_VISIBLE_STYLE } from '@utilities/focusStyle';\n\nimport type { CollisionPosition, TreeDragEndEvent, TreeDragStartEvent, TreeItemProps } from '@components/Tree/types';\nimport { useTreeContext } from '@components/Tree/TreeContext';\n\nimport { DragHandle } from './DragHandle';\nimport { removeFragmentsAndEnrichChildren } from '../utils';\nimport { ExpandButton } from './ExpandButton';\nimport { INDENTATION_WIDTH, ROOT_ID } from '../Tree';\nimport { getItemPositionInParent } from '../helpers';\n\nconst animateLayoutChanges: AnimateLayoutChanges = ({ isSorting, wasDragging }) =>\n isSorting || wasDragging ? false : true;\n\nexport const TreeItem = ({\n id,\n type,\n label,\n onDrop,\n accepts,\n children,\n parentId,\n level = 0,\n contentComponent,\n draggable: itemDraggable = true,\n 'data-test-id': dataTestId = 'fondue-tree-item',\n}: TreeItemProps) => {\n const {\n onExpand,\n onSelect,\n treeState,\n registerOverlay,\n registerNodeChildren,\n unregisterNodeChildren,\n draggable: treeDraggable,\n } = useTreeContext();\n\n const { active, over } = useDndContext();\n\n const draggable = treeDraggable && itemDraggable;\n\n const isActive = active?.id === id;\n\n const activeIndex = treeState.nodes.findIndex(({ props }) => props.id === active?.id);\n const overIndex = treeState.nodes.findIndex(({ props }) => props.id === over?.id);\n\n const movingDown = activeIndex < overIndex;\n const movingUp = !movingDown;\n\n const projection = useMemo(() => {\n return isActive ? treeState.projection : null;\n }, [isActive, treeState.projection]);\n\n const projectionNode = useMemo(() => {\n return treeState.nodes.find(({ props }) => props.id === projection?.parentId);\n }, [projection?.parentId, treeState.nodes]);\n\n const isWithin = useMemo(() => {\n return projection !== null && over !== null && projection.depth > over.data.current?.level;\n }, [projection, over]);\n\n const canDrop =\n isActive &&\n !isWithin &&\n active.data.current &&\n over?.data.current?.accepts !== undefined &&\n over.data.current.accepts.includes(active.data.current.type);\n\n // Moving down the tree\n let canDropWithinMovingDown =\n movingDown &&\n isActive &&\n isWithin &&\n active.data.current &&\n over?.data.current?.accepts !== undefined &&\n projection?.depth !== projection?.minDepth &&\n over.data.current.accepts.includes(`${active.data.current.type}-within`);\n\n // Moving up the tree\n let canDropWithinMovingUp =\n movingUp &&\n isActive &&\n isWithin &&\n active.data.current &&\n projection &&\n projectionNode?.props.accepts &&\n projectionNode.props.accepts.includes(`${active.data.current.type}-within`);\n\n const handleItemDragEnd = (event: TreeDragEndEvent) => {\n const { over, active } = event;\n\n if (active.id === over?.id && projection?.depth === projection?.minDepth) {\n return;\n }\n\n if (movingUp) {\n canDropWithinMovingDown = false;\n }\n\n if (movingDown) {\n canDropWithinMovingUp = false;\n }\n\n if (isActive && over && (canDrop || canDropWithinMovingDown || canDropWithinMovingUp)) {\n const sortOver = getItemPositionInParent(\n { id: over.id, parentId: over.data?.current?.parentId },\n treeState.nodes,\n );\n\n const sortActive = getItemPositionInParent(\n { id: active.id, parentId: active.data?.current?.parentId },\n treeState.nodes,\n );\n\n let position: CollisionPosition = null;\n if (canDrop) {\n position = 'after';\n } else if (canDropWithinMovingDown || canDropWithinMovingUp) {\n position = 'within';\n }\n\n onDrop?.(\n {\n id: canDropWithinMovingUp ? projection?.parentId?.toString() ?? 'ID not found' : over.id.toString(),\n type: canDropWithinMovingUp ? projectionNode?.props.type : over?.data?.current?.type,\n sort: sortOver + 1,\n parentId: projection?.parentId ?? '',\n },\n {\n id: active.id.toString(),\n type: active.data?.current?.type,\n sort: sortActive + 1,\n parentId: parentId ?? '',\n },\n position,\n movingUp ? 'up' : 'down',\n );\n }\n };\n\n const handleItemDragStart = useCallback(\n (event: TreeDragStartEvent) => {\n if (event.active.id !== id) {\n return;\n }\n\n registerOverlay({ contentComponent, children, id, label, level });\n },\n [children, contentComponent, id, label, level, registerOverlay],\n );\n\n useDndMonitor({\n onDragEnd: handleItemDragEnd,\n onDragStart: handleItemDragStart,\n });\n\n const isSelected = treeState.selectedIds.has(id);\n const isExpanded = treeState.expandedIds.has(id);\n\n const isParentRoot = parentId === ROOT_ID;\n const isParentActive = parentId && active?.id === parentId;\n const isParentExpanded = isParentRoot || (parentId && treeState.expandedIds.has(parentId));\n const isAncestorMounted = isParentRoot || (parentId && treeState.nodes.some((node) => node.props.id === parentId));\n\n const hasChildren = Children.count(children) > 0;\n\n const enrichedChildren = useMemo(\n () => removeFragmentsAndEnrichChildren(children, { parentId: id, level: level + 1 }),\n [children, id, level],\n );\n\n const childrenIds = useMemo(() => enrichedChildren.map((child) => child.props.id), [enrichedChildren]);\n\n const { attributes, listeners, transform, setDraggableNodeRef, setDroppableNodeRef, setActivatorNodeRef } =\n useSortable({\n id,\n disabled: !draggable,\n data: { type, accepts, parentId, level },\n animateLayoutChanges,\n transition: null,\n });\n\n useLayoutEffect(() => {\n if (Children.count(enrichedChildren) === 0) {\n return;\n }\n\n if (!isAncestorMounted || !isParentExpanded || isActive || isParentActive) {\n unregisterNodeChildren(enrichedChildren);\n return;\n }\n\n if (isExpanded) {\n registerNodeChildren({ id: enrichedChildren[0].props.parentId, children: enrichedChildren });\n } else {\n unregisterNodeChildren(enrichedChildren);\n }\n }, [\n isActive,\n isExpanded,\n isParentActive,\n isParentExpanded,\n isAncestorMounted,\n enrichedChildren,\n registerNodeChildren,\n unregisterNodeChildren,\n ]);\n\n const handleSelect = useCallback(\n (event: MouseEvent<HTMLElement, globalThis.MouseEvent>) => {\n event.stopPropagation();\n\n onSelect(id);\n },\n [id, onSelect],\n );\n\n const handleExpand = (event: MouseEvent<HTMLButtonElement, globalThis.MouseEvent>) => {\n event.stopPropagation();\n\n onExpand(id);\n };\n\n const liClassName = useMemo(\n () =>\n merge([\n FOCUS_VISIBLE_STYLE,\n !isActive && !isSelected && 'focus-within:tw-bg-box-neutral',\n 'tw-outline-none tw-ring-inset tw-group tw-px-2.5 tw-no-underline tw-leading-5 tw-h-10',\n isSelected && !transform?.y\n ? 'tw-font-medium tw-bg-box-neutral-strong tw-text-box-neutral-strong-inverse hover:tw-bg-box-neutral-strong-hover'\n : 'hover:tw-bg-box-neutral tw-text-text',\n transform?.y ? 'tw-bg-box-neutral-strong-inverse tw-text-text tw-font-normal' : '',\n ]),\n [isActive, isSelected, transform],\n );\n\n const containerClassName = merge([\n 'tw-flex tw-items-center tw-h-10 tw-leading-5 tw-width-full',\n isActive && 'tw-border-box-selected-strong tw-border-dashed tw-border-2 tw-bg-box-selected-hover',\n isActive &&\n ((isWithin && !((movingDown && canDropWithinMovingDown) || (movingUp && canDropWithinMovingUp))) ||\n (!isWithin && !canDrop)) &&\n 'tw-bg-box-negative-hover tw-border-box-negative-strong-hover tw-border-dashed tw-border-2',\n ]);\n\n const depthPadding = projection?.depth ? projection.depth * INDENTATION_WIDTH : undefined;\n const levelPadding = isActive ? 0 : level * INDENTATION_WIDTH;\n\n const liStyle = {\n paddingLeft: depthPadding ?? levelPadding,\n };\n\n const showContent = !isActive;\n const showChildren = isExpanded && !isActive;\n const showDragHandle = draggable && !isActive;\n const showLabel = label !== undefined && !isActive;\n const showExpandButton = hasChildren && !isActive;\n\n const animate = {\n x: transform?.x,\n y: transform?.y,\n };\n\n return (\n <li\n key={id}\n tabIndex={0}\n role=\"treeitem\"\n style={liStyle}\n id={id.toString()}\n aria-label={label}\n aria-level={level}\n onClick={handleSelect}\n className={liClassName}\n ref={setDroppableNodeRef}\n data-test-id={dataTestId}\n aria-selected={isSelected}\n aria-expanded={isExpanded}\n data-has-children={hasChildren}\n aria-owns={childrenIds.join(' ')}\n onKeyDown={noop}\n >\n <motion.div\n transition={{\n bounce: 0,\n delay: 0,\n duration: 0,\n }}\n ref={setDraggableNodeRef}\n className={containerClassName}\n animate={transform ? animate : undefined}\n >\n {showDragHandle ? (\n <DragHandle ref={setActivatorNodeRef} active={isSelected} {...listeners} {...attributes} />\n ) : (\n <div className=\"tw-w-5 tw-ml-2 tw-min-w-[20px]\" />\n )}\n\n <ExpandButton\n onClick={handleExpand}\n expanded={showChildren}\n disabled={!showExpandButton}\n active={transform?.y ? false : isSelected}\n />\n\n {showLabel ? (\n <span className=\"first:tw-ml-3.5 tw-w-full tw-h-full tw-flex tw-items-center\">{label}</span>\n ) : null}\n\n {showContent && contentComponent}\n </motion.div>\n </li>\n );\n};\n\nTreeItem.displayName = 'FondueTreeItem';\n"],"names":["animateLayoutChanges","isSorting","wasDragging","TreeItem","id","type","label","onDrop","accepts","children","parentId","level","contentComponent","itemDraggable","dataTestId","onExpand","onSelect","treeState","registerOverlay","registerNodeChildren","unregisterNodeChildren","treeDraggable","useTreeContext","active","over","useDndContext","draggable","isActive","activeIndex","props","overIndex","movingDown","movingUp","projection","useMemo","projectionNode","isWithin","_a","canDrop","canDropWithinMovingDown","_b","canDropWithinMovingUp","handleItemDragEnd","event","sortOver","getItemPositionInParent","sortActive","position","_e","handleItemDragStart","useCallback","useDndMonitor","isSelected","isExpanded","isParentRoot","ROOT_ID","isParentActive","isParentExpanded","isAncestorMounted","node","hasChildren","Children","enrichedChildren","removeFragmentsAndEnrichChildren","childrenIds","child","attributes","listeners","transform","setDraggableNodeRef","setDroppableNodeRef","setActivatorNodeRef","useSortable","useLayoutEffect","handleSelect","handleExpand","liClassName","merge","FOCUS_VISIBLE_STYLE","containerClassName","depthPadding","INDENTATION_WIDTH","levelPadding","liStyle","showContent","showChildren","showDragHandle","showLabel","showExpandButton","animate","React","noop","motion","DragHandle","ExpandButton"],"mappings":";;;;;;;;;;;;;AAoBA,MAAMA,KAA6C,CAAC,EAAE,WAAAC,GAAW,aAAAC,QAC7D,EAAAD,KAAaC,IAEJC,KAAW,CAAC;AAAA,EACrB,IAAAC;AAAA,EACA,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,kBAAAC;AAAA,EACA,WAAWC,KAAgB;AAAA,EAC3B,gBAAgBC,KAAa;AACjC,MAAqB;;AACX,QAAA;AAAA,IACF,UAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,wBAAAC;AAAA,IACA,WAAWC;AAAA,MACXC,GAAe,GAEb,EAAE,QAAAC,GAAQ,MAAAC,EAAK,IAAIC,GAAc,GAEjCC,IAAYL,MAAiBR,IAE7Bc,KAAWJ,KAAA,gBAAAA,EAAQ,QAAOnB,GAE1BwB,KAAcX,EAAU,MAAM,UAAU,CAAC,EAAE,OAAAY,EAAY,MAAAA,EAAM,QAAON,KAAA,gBAAAA,EAAQ,GAAE,GAC9E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