@hh.ru/magritte-ui-floating-button 3.0.48 → 3.0.49
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/FloatingButton.d.ts +3 -3
- package/FloatingButton.js +101 -43
- package/FloatingButton.js.map +1 -1
- package/FloatingButtonStack.d.ts +2 -2
- package/FloatingButtonStack.js +42 -6
- package/FloatingButtonStack.js.map +1 -1
- package/FloatingButtonStackContext.d.ts +1 -1
- package/FloatingButtonStackContext.js +39 -37
- package/FloatingButtonStackContext.js.map +1 -1
- package/FloatingButtonStackItem.d.ts +2 -2
- package/FloatingButtonStackItem.js +41 -19
- package/FloatingButtonStackItem.js.map +1 -1
- package/FloatingButtonStackItems.js +13 -7
- package/FloatingButtonStackItems.js.map +1 -1
- package/FloatingButtonStackUpButton.d.ts +1 -1
- package/FloatingButtonStackUpButton.js +38 -11
- package/FloatingButtonStackUpButton.js.map +1 -1
- package/floating-button-stack-Bxv4YYAQ.js +5 -0
- package/floating-button-stack-Bxv4YYAQ.js.map +1 -0
- package/index.css +261 -261
- package/index.d.ts +3 -3
- package/index.js +1 -1
- package/index.mock.d.ts +1 -1
- package/index.mock.js +7 -7
- package/index.mock.js.map +1 -1
- package/package.json +7 -7
- package/floating-button-stack-DHEbs91i.js +0 -5
- package/floating-button-stack-DHEbs91i.js.map +0 -1
package/FloatingButton.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { PolymorphicComponentWithRef } from '@hh.ru/magritte-types';
|
|
2
|
-
import type { FloatingButtonProps, FloatingButtonPropsWithStackMode } from '
|
|
3
|
-
export declare const FloatingButtonWithStackMode: PolymorphicComponentWithRef<FloatingButtonPropsWithStackMode,
|
|
4
|
-
export declare const FloatingButton: PolymorphicComponentWithRef<FloatingButtonProps,
|
|
2
|
+
import type { FloatingButtonProps, FloatingButtonPropsWithStackMode } from './types';
|
|
3
|
+
export declare const FloatingButtonWithStackMode: PolymorphicComponentWithRef<FloatingButtonPropsWithStackMode, 'button'>;
|
|
4
|
+
export declare const FloatingButton: PolymorphicComponentWithRef<FloatingButtonProps, 'button'>;
|
package/FloatingButton.js
CHANGED
|
@@ -11,51 +11,109 @@ import { Layer } from '@hh.ru/magritte-ui-layer';
|
|
|
11
11
|
import { Loader } from '@hh.ru/magritte-ui-loader';
|
|
12
12
|
import { Text } from '@hh.ru/magritte-ui-typography';
|
|
13
13
|
|
|
14
|
-
var styles = {"wrapper":"magritte-wrapper___7m9lC_3-0-
|
|
14
|
+
var styles = {"wrapper":"magritte-wrapper___7m9lC_3-0-49","animation-timeout":"magritte-animation-timeout___NL8n0_3-0-49","animationTimeout":"magritte-animation-timeout___NL8n0_3-0-49","button":"magritte-button___nL-Hn_3-0-49","loading":"magritte-loading___C0oPZ_3-0-49","withIconAndLabel":"magritte-withIconAndLabel___Qa-lU_3-0-49","right":"magritte-right___3n0Rz_3-0-49","content":"magritte-content___JNpTZ_3-0-49","left":"magritte-left___GnzU7_3-0-49","center":"magritte-center___MdA40_3-0-49","postfix":"magritte-postfix___r0EZ6_3-0-49","icon":"magritte-icon___VpqJt_3-0-49","textless":"magritte-textless___IbYgp_3-0-49","label":"magritte-label___EPgvj_3-0-49","withPostfix":"magritte-withPostfix___PmQAz_3-0-49","hideLabel":"magritte-hideLabel___K79XM_3-0-49","withLabelOnHover":"magritte-withLabelOnHover___1oktd_3-0-49","loader":"magritte-loader___EPezG_3-0-49","enter-animation":"magritte-enter-animation___2sPz3_3-0-49","enterAnimation":"magritte-enter-animation___2sPz3_3-0-49","enter-animation-active":"magritte-enter-animation-active___Lq9eq_3-0-49","enterAnimationActive":"magritte-enter-animation-active___Lq9eq_3-0-49","exit-animation":"magritte-exit-animation___h2-7a_3-0-49","exitAnimation":"magritte-exit-animation___h2-7a_3-0-49","exit-animation-active":"magritte-exit-animation-active___w0F1a_3-0-49","exitAnimationActive":"magritte-exit-animation-active___w0F1a_3-0-49","button_style-neutral":"magritte-button_style-neutral___bPUwu_3-0-49","buttonStyleNeutral":"magritte-button_style-neutral___bPUwu_3-0-49","stackMode":"magritte-stackMode___RdOTJ_3-0-49","button_style-inverse":"magritte-button_style-inverse___Xgf26_3-0-49","buttonStyleInverse":"magritte-button_style-inverse___Xgf26_3-0-49"};
|
|
15
15
|
|
|
16
|
-
const ALLOWED_BADGE_SIZES = [
|
|
17
|
-
const FloatingButtonComponent = ({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
const ALLOWED_BADGE_SIZES = ["small"];
|
|
17
|
+
const FloatingButtonComponent = ({
|
|
18
|
+
Element = "button",
|
|
19
|
+
style = "neutral",
|
|
20
|
+
disabled,
|
|
21
|
+
borderRadius = "halfHeight",
|
|
22
|
+
icon: IconComponent,
|
|
23
|
+
postfix,
|
|
24
|
+
loading,
|
|
25
|
+
host,
|
|
26
|
+
children,
|
|
27
|
+
className,
|
|
28
|
+
inlineStyle,
|
|
29
|
+
visible,
|
|
30
|
+
labelOnHover: _labelOnHover,
|
|
31
|
+
hideLabel: _hideLabel,
|
|
32
|
+
badge,
|
|
33
|
+
position = "right",
|
|
34
|
+
"data-qa": dataQa = "floating-button",
|
|
35
|
+
stackMode = false,
|
|
36
|
+
...restProps
|
|
37
|
+
}, ref) => {
|
|
38
|
+
const labelOnHover = _labelOnHover && !!IconComponent;
|
|
39
|
+
const hideLabel = _hideLabel && !!IconComponent;
|
|
40
|
+
const isServerEnv = useServerEnv();
|
|
41
|
+
const wrapperRef = useRef(null);
|
|
42
|
+
if (isServerEnv) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const additionalAttributes = {
|
|
46
|
+
"data-qa": dataQa
|
|
47
|
+
};
|
|
48
|
+
if (Element === "button") {
|
|
49
|
+
additionalAttributes.type = "button";
|
|
50
|
+
} else {
|
|
51
|
+
additionalAttributes.role = Element !== "a" ? "button" : void 0;
|
|
52
|
+
additionalAttributes["aria-disabled"] = disabled;
|
|
53
|
+
}
|
|
54
|
+
additionalAttributes.ref = ref;
|
|
55
|
+
let button = /* @__PURE__ */ jsx(
|
|
56
|
+
Element,
|
|
57
|
+
{
|
|
58
|
+
...additionalAttributes,
|
|
59
|
+
...restProps,
|
|
60
|
+
disabled: !!disabled,
|
|
61
|
+
tabIndex: disabled || loading ? -1 : 0,
|
|
62
|
+
className: classnames(styles.button, styles[`button_style-${style}`], {
|
|
63
|
+
[styles.loading]: !!loading,
|
|
64
|
+
[styles.withLabelOnHover]: !!labelOnHover,
|
|
65
|
+
[styles.hideLabel]: !!hideLabel || !children,
|
|
66
|
+
[styles.withPostfix]: !!postfix,
|
|
67
|
+
[styles.textless]: !postfix && (!children || !!hideLabel),
|
|
68
|
+
[styles.withIconAndLabel]: !!IconComponent && !!children && !hideLabel,
|
|
69
|
+
[styles.stackMode]: !!stackMode
|
|
70
|
+
}),
|
|
71
|
+
style: { borderRadius: borderRadius === "halfHeight" ? "9999px" : `${borderRadius}px` },
|
|
72
|
+
children: /* @__PURE__ */ jsxs("span", { className: styles.content, children: [
|
|
73
|
+
IconComponent && /* @__PURE__ */ jsx("span", { className: styles.icon, children: /* @__PURE__ */ jsx(IconComponent, { "data-qa": `${dataQa}-icon` }) }),
|
|
74
|
+
/* @__PURE__ */ jsx("span", { className: styles.label, "data-qa": `${dataQa}-label`, children: /* @__PURE__ */ jsx(Text, { typography: "subtitle-1-semibold", children }) }),
|
|
75
|
+
postfix && /* @__PURE__ */ jsx("span", { className: styles.postfix, "data-qa": `${dataQa}-postfix`, children: /* @__PURE__ */ jsx(Text, { typography: "subtitle-1-semibold", children: postfix }) }),
|
|
76
|
+
loading && /* @__PURE__ */ jsx("span", { className: styles.loader, children: /* @__PURE__ */ jsx(Loader, { size: 24 }) })
|
|
77
|
+
] })
|
|
24
78
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
79
|
+
);
|
|
80
|
+
if (badge && !disabled) {
|
|
81
|
+
button = /* @__PURE__ */ jsx(ComponentWithBadge, { allowedSizes: ALLOWED_BADGE_SIZES, badge, offset: stackMode ? 12 : 4, noClip: true, children: button });
|
|
82
|
+
}
|
|
83
|
+
if (stackMode) {
|
|
84
|
+
return button;
|
|
85
|
+
}
|
|
86
|
+
return createPortal(
|
|
87
|
+
/* @__PURE__ */ jsx(
|
|
88
|
+
CSSTransition,
|
|
89
|
+
{
|
|
90
|
+
appear: true,
|
|
91
|
+
in: !!visible && !isServerEnv,
|
|
92
|
+
nodeRef: wrapperRef,
|
|
93
|
+
classNames: {
|
|
94
|
+
appear: styles.enterAnimation,
|
|
95
|
+
appearActive: styles.enterAnimationActive,
|
|
96
|
+
enter: styles.enterAnimation,
|
|
97
|
+
enterActive: styles.enterAnimationActive,
|
|
98
|
+
exit: styles.exitAnimation,
|
|
99
|
+
exitActive: styles.exitAnimationActive
|
|
100
|
+
},
|
|
101
|
+
timeout: CoreTokens["magritte-semantic-animation-time-s"].duration,
|
|
102
|
+
unmountOnExit: true,
|
|
103
|
+
children: /* @__PURE__ */ jsx(Layer, { layer: "floating-button", children: /* @__PURE__ */ jsx(
|
|
104
|
+
"div",
|
|
105
|
+
{
|
|
106
|
+
className: classnames(styles.wrapper, styles[`${position}`], className),
|
|
107
|
+
ref: wrapperRef,
|
|
108
|
+
style: inlineStyle,
|
|
109
|
+
"data-qa": `${dataQa}-wrapper`,
|
|
110
|
+
children: button
|
|
111
|
+
}
|
|
112
|
+
) })
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
host?.current || document.body
|
|
116
|
+
);
|
|
59
117
|
};
|
|
60
118
|
const FloatingButtonWithStackMode = forwardRef(FloatingButtonComponent);
|
|
61
119
|
const FloatingButton = forwardRef(FloatingButtonComponent);
|
package/FloatingButton.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingButton.js","sources":["src/FloatingButton.tsx"],"sourcesContent":["import { forwardRef, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport { CSSTransition } from 'react-transition-group';\nimport classnames from 'classnames';\n\nimport { useServerEnv } from '@hh.ru/magritte-common-is-server-env';\nimport CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';\nimport type { PolymorphicComponentWithRef, PolymorphicForwardRefRenderFunc } from '@hh.ru/magritte-types';\nimport { BadgeSize, ComponentWithBadge } from '@hh.ru/magritte-ui-badge';\nimport type { FloatingButtonProps, FloatingButtonPropsWithStackMode } from '@hh.ru/magritte-ui-floating-button/types';\nimport { Layer } from '@hh.ru/magritte-ui-layer';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './floating-button.less';\n\nconst ALLOWED_BADGE_SIZES: BadgeSize[] = ['small'];\n\nconst FloatingButtonComponent: PolymorphicForwardRefRenderFunc<FloatingButtonPropsWithStackMode, 'button'> = (\n {\n Element = 'button',\n style = 'neutral',\n disabled,\n borderRadius = 'halfHeight',\n icon: IconComponent,\n postfix,\n loading,\n host,\n children,\n className,\n inlineStyle,\n visible,\n labelOnHover: _labelOnHover,\n hideLabel: _hideLabel,\n badge,\n position = 'right',\n 'data-qa': dataQa = 'floating-button',\n stackMode = false,\n ...restProps\n },\n ref\n) => {\n const labelOnHover = _labelOnHover && !!IconComponent;\n const hideLabel = _hideLabel && !!IconComponent;\n const isServerEnv = useServerEnv();\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n if (isServerEnv) {\n return null;\n }\n\n const additionalAttributes: Record<string, unknown> = {\n 'data-qa': dataQa,\n };\n if (Element === 'button') {\n additionalAttributes.type = 'button';\n } else {\n additionalAttributes.role = Element !== 'a' ? 'button' : undefined;\n additionalAttributes['aria-disabled'] = disabled;\n }\n additionalAttributes.ref = ref;\n\n let button = (\n <Element\n {...additionalAttributes}\n {...restProps}\n disabled={!!disabled}\n tabIndex={disabled || loading ? -1 : 0}\n className={classnames(styles.button, styles[`button_style-${style}`], {\n [styles.loading]: !!loading,\n [styles.withLabelOnHover]: !!labelOnHover,\n [styles.hideLabel]: !!hideLabel || !children,\n [styles.withPostfix]: !!postfix,\n [styles.textless]: !postfix && (!children || !!hideLabel),\n [styles.withIconAndLabel]: !!IconComponent && !!children && !hideLabel,\n [styles.stackMode]: !!stackMode,\n })}\n style={{ borderRadius: borderRadius === 'halfHeight' ? '9999px' : `${borderRadius}px` }}\n >\n <span className={styles.content}>\n {IconComponent && (\n <span className={styles.icon}>\n <IconComponent data-qa={`${dataQa}-icon`} />\n </span>\n )}\n <span className={styles.label} data-qa={`${dataQa}-label`}>\n <Text typography={'subtitle-1-semibold'}>{children}</Text>\n </span>\n {postfix && (\n <span className={styles.postfix} data-qa={`${dataQa}-postfix`}>\n <Text typography={'subtitle-1-semibold'}>{postfix}</Text>\n </span>\n )}\n\n {loading && (\n <span className={styles.loader}>\n <Loader size={24} />\n </span>\n )}\n </span>\n </Element>\n );\n\n if (badge && !disabled) {\n button = (\n <ComponentWithBadge allowedSizes={ALLOWED_BADGE_SIZES} badge={badge} offset={stackMode ? 12 : 4} noClip>\n {button}\n </ComponentWithBadge>\n );\n }\n\n if (stackMode) {\n return button;\n }\n\n return createPortal(\n <CSSTransition\n appear\n in={!!visible && !isServerEnv}\n nodeRef={wrapperRef}\n classNames={{\n appear: styles.enterAnimation,\n appearActive: styles.enterAnimationActive,\n enter: styles.enterAnimation,\n enterActive: styles.enterAnimationActive,\n exit: styles.exitAnimation,\n exitActive: styles.exitAnimationActive,\n }}\n timeout={CoreTokens['magritte-semantic-animation-time-s'].duration}\n unmountOnExit\n >\n <Layer layer=\"floating-button\">\n <div\n className={classnames(styles.wrapper, styles[`${position}`], className)}\n ref={wrapperRef}\n style={inlineStyle}\n data-qa={`${dataQa}-wrapper`}\n >\n {button}\n </div>\n </Layer>\n </CSSTransition>,\n host?.current || document.body\n );\n};\n\nexport const FloatingButtonWithStackMode = forwardRef(FloatingButtonComponent) as PolymorphicComponentWithRef<\n FloatingButtonPropsWithStackMode,\n 'button'\n>;\n\nexport const FloatingButton = forwardRef(FloatingButtonComponent) as PolymorphicComponentWithRef<\n FloatingButtonProps,\n 'button'\n>;\n"],"names":[
|
|
1
|
+
{"version":3,"file":"FloatingButton.js","sources":["src/FloatingButton.tsx"],"sourcesContent":["import { forwardRef, useRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport { CSSTransition } from 'react-transition-group';\nimport classnames from 'classnames';\n\nimport { useServerEnv } from '@hh.ru/magritte-common-is-server-env';\nimport CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';\nimport type { PolymorphicComponentWithRef, PolymorphicForwardRefRenderFunc } from '@hh.ru/magritte-types';\nimport { BadgeSize, ComponentWithBadge } from '@hh.ru/magritte-ui-badge';\nimport type { FloatingButtonProps, FloatingButtonPropsWithStackMode } from '@hh.ru/magritte-ui-floating-button/types';\nimport { Layer } from '@hh.ru/magritte-ui-layer';\nimport { Loader } from '@hh.ru/magritte-ui-loader';\nimport { Text } from '@hh.ru/magritte-ui-typography';\n\nimport styles from './floating-button.less';\n\nconst ALLOWED_BADGE_SIZES: BadgeSize[] = ['small'];\n\nconst FloatingButtonComponent: PolymorphicForwardRefRenderFunc<FloatingButtonPropsWithStackMode, 'button'> = (\n {\n Element = 'button',\n style = 'neutral',\n disabled,\n borderRadius = 'halfHeight',\n icon: IconComponent,\n postfix,\n loading,\n host,\n children,\n className,\n inlineStyle,\n visible,\n labelOnHover: _labelOnHover,\n hideLabel: _hideLabel,\n badge,\n position = 'right',\n 'data-qa': dataQa = 'floating-button',\n stackMode = false,\n ...restProps\n },\n ref\n) => {\n const labelOnHover = _labelOnHover && !!IconComponent;\n const hideLabel = _hideLabel && !!IconComponent;\n const isServerEnv = useServerEnv();\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n if (isServerEnv) {\n return null;\n }\n\n const additionalAttributes: Record<string, unknown> = {\n 'data-qa': dataQa,\n };\n if (Element === 'button') {\n additionalAttributes.type = 'button';\n } else {\n additionalAttributes.role = Element !== 'a' ? 'button' : undefined;\n additionalAttributes['aria-disabled'] = disabled;\n }\n additionalAttributes.ref = ref;\n\n let button = (\n <Element\n {...additionalAttributes}\n {...restProps}\n disabled={!!disabled}\n tabIndex={disabled || loading ? -1 : 0}\n className={classnames(styles.button, styles[`button_style-${style}`], {\n [styles.loading]: !!loading,\n [styles.withLabelOnHover]: !!labelOnHover,\n [styles.hideLabel]: !!hideLabel || !children,\n [styles.withPostfix]: !!postfix,\n [styles.textless]: !postfix && (!children || !!hideLabel),\n [styles.withIconAndLabel]: !!IconComponent && !!children && !hideLabel,\n [styles.stackMode]: !!stackMode,\n })}\n style={{ borderRadius: borderRadius === 'halfHeight' ? '9999px' : `${borderRadius}px` }}\n >\n <span className={styles.content}>\n {IconComponent && (\n <span className={styles.icon}>\n <IconComponent data-qa={`${dataQa}-icon`} />\n </span>\n )}\n <span className={styles.label} data-qa={`${dataQa}-label`}>\n <Text typography={'subtitle-1-semibold'}>{children}</Text>\n </span>\n {postfix && (\n <span className={styles.postfix} data-qa={`${dataQa}-postfix`}>\n <Text typography={'subtitle-1-semibold'}>{postfix}</Text>\n </span>\n )}\n\n {loading && (\n <span className={styles.loader}>\n <Loader size={24} />\n </span>\n )}\n </span>\n </Element>\n );\n\n if (badge && !disabled) {\n button = (\n <ComponentWithBadge allowedSizes={ALLOWED_BADGE_SIZES} badge={badge} offset={stackMode ? 12 : 4} noClip>\n {button}\n </ComponentWithBadge>\n );\n }\n\n if (stackMode) {\n return button;\n }\n\n return createPortal(\n <CSSTransition\n appear\n in={!!visible && !isServerEnv}\n nodeRef={wrapperRef}\n classNames={{\n appear: styles.enterAnimation,\n appearActive: styles.enterAnimationActive,\n enter: styles.enterAnimation,\n enterActive: styles.enterAnimationActive,\n exit: styles.exitAnimation,\n exitActive: styles.exitAnimationActive,\n }}\n timeout={CoreTokens['magritte-semantic-animation-time-s'].duration}\n unmountOnExit\n >\n <Layer layer=\"floating-button\">\n <div\n className={classnames(styles.wrapper, styles[`${position}`], className)}\n ref={wrapperRef}\n style={inlineStyle}\n data-qa={`${dataQa}-wrapper`}\n >\n {button}\n </div>\n </Layer>\n </CSSTransition>,\n host?.current || document.body\n );\n};\n\nexport const FloatingButtonWithStackMode = forwardRef(FloatingButtonComponent) as PolymorphicComponentWithRef<\n FloatingButtonPropsWithStackMode,\n 'button'\n>;\n\nexport const FloatingButton = forwardRef(FloatingButtonComponent) as PolymorphicComponentWithRef<\n FloatingButtonProps,\n 'button'\n>;\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAgBA,MAAM,mBAAA,GAAmC,CAAC,OAAO,CAAA,CAAA;AAEjD,MAAM,0BAAuG,CACzG;AAAA,EACI,OAAU,GAAA,QAAA;AAAA,EACV,KAAQ,GAAA,SAAA;AAAA,EACR,QAAA;AAAA,EACA,YAAe,GAAA,YAAA;AAAA,EACf,IAAM,EAAA,aAAA;AAAA,EACN,OAAA;AAAA,EACA,OAAA;AAAA,EACA,IAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,OAAA;AAAA,EACA,YAAc,EAAA,aAAA;AAAA,EACd,SAAW,EAAA,UAAA;AAAA,EACX,KAAA;AAAA,EACA,QAAW,GAAA,OAAA;AAAA,EACX,WAAW,MAAS,GAAA,iBAAA;AAAA,EACpB,SAAY,GAAA,KAAA;AAAA,EACZ,GAAG,SAAA;AACP,CAAA,EACA,GACC,KAAA;AACD,EAAM,MAAA,YAAA,G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A,QAAQ,CAAE,CAAA,CAAA,EAAG,SAAS,CAAA;AAAA,YACtE,GAAK,EAAA,UAAA;AAAA,YACL,KAAO,EAAA,WAAA;AAAA,YACP,SAAA,EAAS,GAAG,MAAM,CAAA,QAAA,CAAA;AAAA,YAEjB,QAAA,EAAA,MAAA;AAAA,WAAA;AAAA,SAET,EAAA,CAAA;AAAA,OAAA;AAAA,KACJ;AAAA,IACA,IAAA,EAAM,WAAW,QAAS,CAAA,IAAA;AAAA,GAC9B,CAAA;AACJ,CAAA,CAAA;AAEa,MAAA,2BAAA,GAA8B,WAAW,uBAAuB,EAAA;AAKhE,MAAA,cAAA,GAAiB,WAAW,uBAAuB;;;;"}
|
package/FloatingButtonStack.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FloatingButtonStackItem } from '
|
|
2
|
-
import type { FloatingButtonStackProps } from '
|
|
1
|
+
import { FloatingButtonStackItem } from './FloatingButtonStackItem';
|
|
2
|
+
import type { FloatingButtonStackProps } from './types';
|
|
3
3
|
export interface FloatingButtonStackComponents {
|
|
4
4
|
Item: typeof FloatingButtonStackItem;
|
|
5
5
|
}
|
package/FloatingButtonStack.js
CHANGED
|
@@ -9,7 +9,7 @@ import { FloatingButtonStackItem } from './FloatingButtonStackItem.js';
|
|
|
9
9
|
import { FloatingButtonStackItems } from './FloatingButtonStackItems.js';
|
|
10
10
|
import { FloatingButtonStackUpButton } from './FloatingButtonStackUpButton.js';
|
|
11
11
|
import { Layer } from '@hh.ru/magritte-ui-layer';
|
|
12
|
-
import { s as styles } from './floating-button-stack-
|
|
12
|
+
import { s as styles } from './floating-button-stack-Bxv4YYAQ.js';
|
|
13
13
|
import 'react-transition-group';
|
|
14
14
|
import '@hh.ru/magritte-design-tokens/core-tokens';
|
|
15
15
|
import './FloatingButton.js';
|
|
@@ -19,14 +19,50 @@ import '@hh.ru/magritte-ui-typography';
|
|
|
19
19
|
import '@hh.ru/magritte-ui-breakpoint';
|
|
20
20
|
import '@hh.ru/magritte-ui-icon/variants/icon';
|
|
21
21
|
|
|
22
|
-
const FloatingButtonStackComponent = forwardRef(
|
|
22
|
+
const FloatingButtonStackComponent = forwardRef(
|
|
23
|
+
({
|
|
24
|
+
style = "neutral",
|
|
25
|
+
host,
|
|
26
|
+
children,
|
|
27
|
+
className,
|
|
28
|
+
inlineStyle,
|
|
29
|
+
upButtonVisible,
|
|
30
|
+
disabled = false,
|
|
31
|
+
position = "right",
|
|
32
|
+
onUpButtonClick,
|
|
33
|
+
"data-qa": dataQa = "floating-button-stack"
|
|
34
|
+
}, ref) => {
|
|
23
35
|
const isServerEnv = useServerEnv();
|
|
24
36
|
if (isServerEnv) {
|
|
25
|
-
|
|
37
|
+
return null;
|
|
26
38
|
}
|
|
27
|
-
return createPortal(
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
return createPortal(
|
|
40
|
+
/* @__PURE__ */ jsx(Layer, { layer: "floating-button-stack", children: /* @__PURE__ */ jsx(
|
|
41
|
+
"div",
|
|
42
|
+
{
|
|
43
|
+
ref,
|
|
44
|
+
className: classnames(styles.stack, styles[`${position}`], className),
|
|
45
|
+
style: inlineStyle,
|
|
46
|
+
"data-qa": dataQa,
|
|
47
|
+
children: /* @__PURE__ */ jsxs(FloatingButtonStackProvider, { style, disabled, children: [
|
|
48
|
+
/* @__PURE__ */ jsx(
|
|
49
|
+
FloatingButtonStackUpButton,
|
|
50
|
+
{
|
|
51
|
+
upButtonVisible,
|
|
52
|
+
disabled,
|
|
53
|
+
onUpButtonClick,
|
|
54
|
+
"data-qa": dataQa
|
|
55
|
+
}
|
|
56
|
+
),
|
|
57
|
+
/* @__PURE__ */ jsx(FloatingButtonStackItems, { children })
|
|
58
|
+
] })
|
|
59
|
+
}
|
|
60
|
+
) }),
|
|
61
|
+
host?.current || document.body
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
FloatingButtonStackComponent.displayName = "FloatingButtonStack";
|
|
30
66
|
const FloatingButtonStack = FloatingButtonStackComponent;
|
|
31
67
|
FloatingButtonStack.Item = FloatingButtonStackItem;
|
|
32
68
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingButtonStack.js","sources":["src/FloatingButtonStack.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport classnames from 'classnames';\n\nimport { useServerEnv } from '@hh.ru/magritte-common-is-server-env';\nimport { FloatingButtonStackProvider } from '@hh.ru/magritte-ui-floating-button/FloatingButtonStackContext';\nimport { FloatingButtonStackItem } from '@hh.ru/magritte-ui-floating-button/FloatingButtonStackItem';\nimport { FloatingButtonStackItems } from '@hh.ru/magritte-ui-floating-button/FloatingButtonStackItems';\nimport { FloatingButtonStackUpButton } from '@hh.ru/magritte-ui-floating-button/FloatingButtonStackUpButton';\nimport type { FloatingButtonStackProps } from '@hh.ru/magritte-ui-floating-button/types';\nimport { Layer } from '@hh.ru/magritte-ui-layer';\n\nimport styles from './floating-button-stack.less';\n\nexport interface FloatingButtonStackComponents {\n Item: typeof FloatingButtonStackItem;\n}\n\nexport const FloatingButtonStackComponent = forwardRef<HTMLDivElement, FloatingButtonStackProps>(\n (\n {\n style = 'neutral',\n host,\n children,\n className,\n inlineStyle,\n upButtonVisible,\n disabled = false,\n position = 'right',\n onUpButtonClick,\n 'data-qa': dataQa = 'floating-button-stack',\n },\n ref\n ) => {\n const isServerEnv = useServerEnv();\n\n if (isServerEnv) {\n return null;\n }\n\n return createPortal(\n <Layer layer=\"floating-button-stack\">\n <div\n ref={ref}\n className={classnames(styles.stack, styles[`${position}`], className)}\n style={inlineStyle}\n data-qa={dataQa}\n >\n <FloatingButtonStackProvider style={style} disabled={disabled}>\n <FloatingButtonStackUpButton\n upButtonVisible={upButtonVisible}\n disabled={disabled}\n onUpButtonClick={onUpButtonClick}\n data-qa={dataQa}\n />\n <FloatingButtonStackItems>{children}</FloatingButtonStackItems>\n </FloatingButtonStackProvider>\n </div>\n </Layer>,\n host?.current || document.body\n );\n }\n);\n\nFloatingButtonStackComponent.displayName = 'FloatingButtonStack';\n\nconst FloatingButtonStack = FloatingButtonStackComponent as typeof FloatingButtonStackComponent &\n FloatingButtonStackComponents;\n\nFloatingButtonStack.Item = FloatingButtonStackItem;\n\nexport { FloatingButtonStack };\n"],"names":[
|
|
1
|
+
{"version":3,"file":"FloatingButtonStack.js","sources":["src/FloatingButtonStack.tsx"],"sourcesContent":["import { forwardRef } from 'react';\nimport { createPortal } from 'react-dom';\nimport classnames from 'classnames';\n\nimport { useServerEnv } from '@hh.ru/magritte-common-is-server-env';\nimport { FloatingButtonStackProvider } from '@hh.ru/magritte-ui-floating-button/FloatingButtonStackContext';\nimport { FloatingButtonStackItem } from '@hh.ru/magritte-ui-floating-button/FloatingButtonStackItem';\nimport { FloatingButtonStackItems } from '@hh.ru/magritte-ui-floating-button/FloatingButtonStackItems';\nimport { FloatingButtonStackUpButton } from '@hh.ru/magritte-ui-floating-button/FloatingButtonStackUpButton';\nimport type { FloatingButtonStackProps } from '@hh.ru/magritte-ui-floating-button/types';\nimport { Layer } from '@hh.ru/magritte-ui-layer';\n\nimport styles from './floating-button-stack.less';\n\nexport interface FloatingButtonStackComponents {\n Item: typeof FloatingButtonStackItem;\n}\n\nexport const FloatingButtonStackComponent = forwardRef<HTMLDivElement, FloatingButtonStackProps>(\n (\n {\n style = 'neutral',\n host,\n children,\n className,\n inlineStyle,\n upButtonVisible,\n disabled = false,\n position = 'right',\n onUpButtonClick,\n 'data-qa': dataQa = 'floating-button-stack',\n },\n ref\n ) => {\n const isServerEnv = useServerEnv();\n\n if (isServerEnv) {\n return null;\n }\n\n return createPortal(\n <Layer layer=\"floating-button-stack\">\n <div\n ref={ref}\n className={classnames(styles.stack, styles[`${position}`], className)}\n style={inlineStyle}\n data-qa={dataQa}\n >\n <FloatingButtonStackProvider style={style} disabled={disabled}>\n <FloatingButtonStackUpButton\n upButtonVisible={upButtonVisible}\n disabled={disabled}\n onUpButtonClick={onUpButtonClick}\n data-qa={dataQa}\n />\n <FloatingButtonStackItems>{children}</FloatingButtonStackItems>\n </FloatingButtonStackProvider>\n </div>\n </Layer>,\n host?.current || document.body\n );\n }\n);\n\nFloatingButtonStackComponent.displayName = 'FloatingButtonStack';\n\nconst FloatingButtonStack = FloatingButtonStackComponent as typeof FloatingButtonStackComponent &\n FloatingButtonStackComponents;\n\nFloatingButtonStack.Item = FloatingButtonStackItem;\n\nexport { FloatingButtonStack };\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBO,MAAM,4BAA+B,GAAA,UAAA;AAAA,EACxC,CACI;AAAA,IACI,KAAQ,GAAA,SAAA;AAAA,IACR,IAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,eAAA;AAAA,IACA,QAAW,GAAA,KAAA;AAAA,IACX,QAAW,GAAA,OAAA;AAAA,IACX,eAAA;AAAA,IACA,WAAW,MAAS,GAAA,uBAAA;AAAA,KAExB,GACC,KAAA;AACD,IAAA,MAAM,cAAc,YAAa,EAAA,CAAA;AAEjC,IAAA,IAAI,WAAa,EAAA;AACb,MAAO,OAAA,IAAA,CAAA;AAAA,KACX;AAEA,IAAO,OAAA,YAAA;AAAA,sBACH,GAAA,CAAC,KAAM,EAAA,EAAA,KAAA,EAAM,uBACT,EAAA,QAAA,kBAAA,GAAA;AAAA,QAAC,KAAA;AAAA,QAAA;AAAA,UACG,GAAA;AAAA,UACA,SAAA,EAAW,WAAW,MAAO,CAAA,KAAA,EAAO,OAAO,CAAG,EAAA,QAAQ,CAAE,CAAA,CAAA,EAAG,SAAS,CAAA;AAAA,UACpE,KAAO,EAAA,WAAA;AAAA,UACP,SAAS,EAAA,MAAA;AAAA,UAET,QAAA,kBAAA,IAAA,CAAC,2BAA4B,EAAA,EAAA,KAAA,EAAc,QACvC,EAAA,QAAA,EAAA;AAAA,4BAAA,GAAA;AAAA,cAAC,2BAAA;AAAA,cAAA;AAAA,gBACG,eAAA;AAAA,gBACA,QAAA;AAAA,gBACA,eAAA;AAAA,gBACA,SAAS,EAAA,MAAA;AAAA,eAAA;AAAA,aACb;AAAA,4BACA,GAAA,CAAC,4BAA0B,QAAS,EAAA,CAAA;AAAA,WACxC,EAAA,CAAA;AAAA,SAAA;AAAA,OAER,EAAA,CAAA;AAAA,MACA,IAAA,EAAM,WAAW,QAAS,CAAA,IAAA;AAAA,KAC9B,CAAA;AAAA,GACJ;AACJ,EAAA;AAEA,4BAAA,CAA6B,WAAc,GAAA,qBAAA,CAAA;AAE3C,MAAM,mBAAsB,GAAA,6BAAA;AAG5B,mBAAA,CAAoB,IAAO,GAAA,uBAAA;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FC, type PropsWithChildren } from 'react';
|
|
2
|
-
import type { FloatingButtonStyle } from '
|
|
2
|
+
import type { FloatingButtonStyle } from './types';
|
|
3
3
|
type ButtonsSet = Set<string>;
|
|
4
4
|
interface FloatingButtonStackContextProps {
|
|
5
5
|
/** floating кнопки */
|
|
@@ -3,46 +3,48 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { createContext, useContext, useState, useEffect, useCallback, useMemo } from 'react';
|
|
4
4
|
|
|
5
5
|
const FloatingButtonStackContext = createContext({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
visibleButtons: /* @__PURE__ */ new Set(),
|
|
7
|
+
animationsEnabled: false,
|
|
8
|
+
setVisible: () => null
|
|
9
9
|
});
|
|
10
10
|
const useFloatingButtonStack = () => useContext(FloatingButtonStackContext);
|
|
11
11
|
const FloatingButtonStackProvider = ({ style, disabled, children }) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}),
|
|
45
|
-
|
|
12
|
+
const [visibleButtons, setVisibleButtons] = useState(() => /* @__PURE__ */ new Set());
|
|
13
|
+
const [animationsEnabled, setAnimationsEnabled] = useState(false);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (animationsEnabled) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (visibleButtons.size > 0) {
|
|
19
|
+
setAnimationsEnabled(true);
|
|
20
|
+
}
|
|
21
|
+
}, [visibleButtons, animationsEnabled]);
|
|
22
|
+
const setVisible = useCallback((id, visible) => {
|
|
23
|
+
setVisibleButtons((prev) => {
|
|
24
|
+
const has = prev.has(id);
|
|
25
|
+
if (has === visible) {
|
|
26
|
+
return prev;
|
|
27
|
+
}
|
|
28
|
+
const next = new Set(prev);
|
|
29
|
+
if (visible) {
|
|
30
|
+
next.add(id);
|
|
31
|
+
} else {
|
|
32
|
+
next.delete(id);
|
|
33
|
+
}
|
|
34
|
+
return next;
|
|
35
|
+
});
|
|
36
|
+
}, []);
|
|
37
|
+
const contextValue = useMemo(
|
|
38
|
+
() => ({
|
|
39
|
+
style,
|
|
40
|
+
disabled,
|
|
41
|
+
animationsEnabled,
|
|
42
|
+
setVisible,
|
|
43
|
+
visibleButtons
|
|
44
|
+
}),
|
|
45
|
+
[style, disabled, animationsEnabled, setVisible, visibleButtons]
|
|
46
|
+
);
|
|
47
|
+
return /* @__PURE__ */ jsx(FloatingButtonStackContext.Provider, { value: contextValue, children });
|
|
46
48
|
};
|
|
47
49
|
|
|
48
50
|
export { FloatingButtonStackContext, FloatingButtonStackProvider, useFloatingButtonStack };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingButtonStackContext.js","sources":["src/FloatingButtonStackContext.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useState,\n useCallback,\n useMemo,\n useEffect,\n type FC,\n type PropsWithChildren,\n} from 'react';\n\nimport type { FloatingButtonStyle } from '@hh.ru/magritte-ui-floating-button/types';\n\ntype ButtonsSet = Set<string>;\n\ninterface FloatingButtonStackContextProps {\n /** floating кнопки */\n visibleButtons: ButtonsSet;\n /** флаг включения анимаций стака */\n animationsEnabled: boolean;\n /** стиль floating стака */\n style?: FloatingButtonStyle;\n /** флаг активности кропки */\n disabled?: boolean;\n /** callback для переключения видимости */\n setVisible: (id: string, visible: boolean) => void;\n}\n\nexport const FloatingButtonStackContext = createContext<FloatingButtonStackContextProps>({\n visibleButtons: new Set(),\n animationsEnabled: false,\n setVisible: () => null,\n});\n\nexport const useFloatingButtonStack = (): FloatingButtonStackContextProps => useContext(FloatingButtonStackContext);\n\ninterface FloatingButtonStackProviderProps extends PropsWithChildren {\n style?: FloatingButtonStyle;\n disabled?: boolean;\n}\n\nexport const FloatingButtonStackProvider: FC<FloatingButtonStackProviderProps> = ({ style, disabled, children }) => {\n const [visibleButtons, setVisibleButtons] = useState<ButtonsSet>(() => new Set());\n const [animationsEnabled, setAnimationsEnabled] = useState(false);\n\n useEffect(() => {\n if (animationsEnabled) {\n return;\n }\n if (visibleButtons.size > 0) {\n setAnimationsEnabled(true);\n }\n }, [visibleButtons, animationsEnabled]);\n\n const setVisible = useCallback<FloatingButtonStackContextProps['setVisible']>((id, visible) => {\n setVisibleButtons((prev) => {\n const has = prev.has(id);\n if (has === visible) {\n return prev;\n }\n const next = new Set(prev);\n if (visible) {\n next.add(id);\n } else {\n next.delete(id);\n }\n return next;\n });\n }, []);\n\n const contextValue = useMemo(\n () => ({\n style,\n disabled,\n animationsEnabled,\n setVisible,\n visibleButtons,\n }),\n [style, disabled, animationsEnabled, setVisible, visibleButtons]\n );\n\n return <FloatingButtonStackContext.Provider value={contextValue}>{children}</FloatingButtonStackContext.Provider>;\n};\n"],"names":[
|
|
1
|
+
{"version":3,"file":"FloatingButtonStackContext.js","sources":["src/FloatingButtonStackContext.tsx"],"sourcesContent":["import {\n createContext,\n useContext,\n useState,\n useCallback,\n useMemo,\n useEffect,\n type FC,\n type PropsWithChildren,\n} from 'react';\n\nimport type { FloatingButtonStyle } from '@hh.ru/magritte-ui-floating-button/types';\n\ntype ButtonsSet = Set<string>;\n\ninterface FloatingButtonStackContextProps {\n /** floating кнопки */\n visibleButtons: ButtonsSet;\n /** флаг включения анимаций стака */\n animationsEnabled: boolean;\n /** стиль floating стака */\n style?: FloatingButtonStyle;\n /** флаг активности кропки */\n disabled?: boolean;\n /** callback для переключения видимости */\n setVisible: (id: string, visible: boolean) => void;\n}\n\nexport const FloatingButtonStackContext = createContext<FloatingButtonStackContextProps>({\n visibleButtons: new Set(),\n animationsEnabled: false,\n setVisible: () => null,\n});\n\nexport const useFloatingButtonStack = (): FloatingButtonStackContextProps => useContext(FloatingButtonStackContext);\n\ninterface FloatingButtonStackProviderProps extends PropsWithChildren {\n style?: FloatingButtonStyle;\n disabled?: boolean;\n}\n\nexport const FloatingButtonStackProvider: FC<FloatingButtonStackProviderProps> = ({ style, disabled, children }) => {\n const [visibleButtons, setVisibleButtons] = useState<ButtonsSet>(() => new Set());\n const [animationsEnabled, setAnimationsEnabled] = useState(false);\n\n useEffect(() => {\n if (animationsEnabled) {\n return;\n }\n if (visibleButtons.size > 0) {\n setAnimationsEnabled(true);\n }\n }, [visibleButtons, animationsEnabled]);\n\n const setVisible = useCallback<FloatingButtonStackContextProps['setVisible']>((id, visible) => {\n setVisibleButtons((prev) => {\n const has = prev.has(id);\n if (has === visible) {\n return prev;\n }\n const next = new Set(prev);\n if (visible) {\n next.add(id);\n } else {\n next.delete(id);\n }\n return next;\n });\n }, []);\n\n const contextValue = useMemo(\n () => ({\n style,\n disabled,\n animationsEnabled,\n setVisible,\n visibleButtons,\n }),\n [style, disabled, animationsEnabled, setVisible, visibleButtons]\n );\n\n return <Floating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IAAA,CAAK,OAAO,EAAE,CAAA,CAAA;AAAA,OAClB;AACA,MAAO,OAAA,IAAA,CAAA;AAAA,KACV,CAAA,CAAA;AAAA,GACL,EAAG,EAAE,CAAA,CAAA;AAEL,EAAA,MAAM,YAAe,GAAA,OAAA;AAAA,IACjB,OAAO;AAAA,MACH,KAAA;AAAA,MACA,QAAA;AAAA,MACA,iBAAA;AAAA,MACA,UAAA;AAAA,MACA,cAAA;AAAA,KACJ,CAAA;AAAA,IACA,CAAC,KAAA,EAAO,QAAU,EAAA,iBAAA,EAAmB,YAAY,cAAc,CAAA;AAAA,GACnE,CAAA;AAEA,EAAA,2BAAQ,0BAA2B,CAAA,QAAA,EAA3B,EAAoC,KAAA,EAAO,cAAe,QAAS,EAAA,CAAA,CAAA;AAC/E;;;;"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { PolymorphicComponentWithRef } from '@hh.ru/magritte-types';
|
|
2
|
-
import type { FloatingButtonStackItemProps } from '
|
|
3
|
-
export declare const FloatingButtonStackItem: PolymorphicComponentWithRef<FloatingButtonStackItemProps,
|
|
2
|
+
import type { FloatingButtonStackItemProps } from './types';
|
|
3
|
+
export declare const FloatingButtonStackItem: PolymorphicComponentWithRef<FloatingButtonStackItemProps, 'button'>;
|
|
@@ -6,7 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
import CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';
|
|
7
7
|
import { FloatingButtonWithStackMode } from './FloatingButton.js';
|
|
8
8
|
import { useFloatingButtonStack } from './FloatingButtonStackContext.js';
|
|
9
|
-
import { s as styles } from './floating-button-stack-
|
|
9
|
+
import { s as styles } from './floating-button-stack-Bxv4YYAQ.js';
|
|
10
10
|
import 'react-dom';
|
|
11
11
|
import '@hh.ru/magritte-common-is-server-env';
|
|
12
12
|
import '@hh.ru/magritte-ui-badge';
|
|
@@ -14,24 +14,46 @@ import '@hh.ru/magritte-ui-layer';
|
|
|
14
14
|
import '@hh.ru/magritte-ui-loader';
|
|
15
15
|
import '@hh.ru/magritte-ui-typography';
|
|
16
16
|
|
|
17
|
-
const FloatingButtonStackItemComponent = ({ Element =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
17
|
+
const FloatingButtonStackItemComponent = ({ Element = "button", visible = false, ...otherProps }, ref) => {
|
|
18
|
+
const uid = useId();
|
|
19
|
+
const { setVisible, animationsEnabled, style, disabled } = useFloatingButtonStack();
|
|
20
|
+
const nodeRef = useRef(null);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
setVisible(uid, visible);
|
|
23
|
+
}, [uid, setVisible, visible]);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
return () => {
|
|
26
|
+
setVisible(uid, false);
|
|
27
|
+
};
|
|
28
|
+
}, [uid, setVisible]);
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
CSSTransition,
|
|
31
|
+
{
|
|
32
|
+
in: visible,
|
|
33
|
+
enter: animationsEnabled,
|
|
34
|
+
exit: animationsEnabled,
|
|
35
|
+
classNames: {
|
|
36
|
+
enter: styles.enterFloatingButtonAnimation,
|
|
37
|
+
enterActive: styles.enterFloatingButtonAnimationActive,
|
|
38
|
+
exit: styles.exitFloatingButtonAnimation,
|
|
39
|
+
exitActive: styles.exitFloatingButtonAnimationActive
|
|
40
|
+
},
|
|
41
|
+
nodeRef,
|
|
42
|
+
timeout: CoreTokens["magritte-semantic-animation-time-s"].duration,
|
|
43
|
+
unmountOnExit: true,
|
|
44
|
+
children: /* @__PURE__ */ jsx("div", { ref: nodeRef, className: classnames(styles.floatingButtonWrapper), children: /* @__PURE__ */ jsx(
|
|
45
|
+
FloatingButtonWithStackMode,
|
|
46
|
+
{
|
|
47
|
+
Element,
|
|
48
|
+
ref,
|
|
49
|
+
...otherProps,
|
|
50
|
+
style,
|
|
51
|
+
disabled,
|
|
52
|
+
stackMode: true
|
|
53
|
+
}
|
|
54
|
+
) })
|
|
55
|
+
}
|
|
56
|
+
);
|
|
35
57
|
};
|
|
36
58
|
const FloatingButtonStackItem = forwardRef(FloatingButtonStackItemComponent);
|
|
37
59
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FloatingButtonStackItem.js","sources":["src/FloatingButtonStackItem.tsx"],"sourcesContent":["import { useEffect, useId, useRef, forwardRef } from 'react';\nimport { CSSTransition } from 'react-transition-group';\nimport classnames from 'classnames';\n\nimport CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';\nimport type { PolymorphicForwardRefRenderFunc, PolymorphicComponentWithRef } from '@hh.ru/magritte-types';\nimport { FloatingButtonWithStackMode } from '@hh.ru/magritte-ui-floating-button/FloatingButton';\nimport { useFloatingButtonStack } from '@hh.ru/magritte-ui-floating-button/FloatingButtonStackContext';\nimport type { FloatingButtonStackItemProps } from '@hh.ru/magritte-ui-floating-button/types';\n\nimport styles from './floating-button-stack.less';\n\nconst FloatingButtonStackItemComponent: PolymorphicForwardRefRenderFunc<FloatingButtonStackItemProps, 'button'> = (\n { Element = 'button', visible = false, ...otherProps },\n ref\n) => {\n const uid = useId();\n const { setVisible, animationsEnabled, style, disabled } = useFloatingButtonStack();\n const nodeRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n setVisible(uid, visible);\n }, [uid, setVisible, visible]);\n\n useEffect(() => {\n return () => {\n setVisible(uid, false);\n };\n }, [uid, setVisible]);\n\n return (\n <CSSTransition\n in={visible}\n enter={animationsEnabled}\n exit={animationsEnabled}\n classNames={{\n enter: styles.enterFloatingButtonAnimation,\n enterActive: styles.enterFloatingButtonAnimationActive,\n exit: styles.exitFloatingButtonAnimation,\n exitActive: styles.exitFloatingButtonAnimationActive,\n }}\n nodeRef={nodeRef}\n timeout={CoreTokens['magritte-semantic-animation-time-s'].duration}\n unmountOnExit\n >\n <div ref={nodeRef} className={classnames(styles.floatingButtonWrapper)}>\n <FloatingButtonWithStackMode
|
|
1
|
+
{"version":3,"file":"FloatingButtonStackItem.js","sources":["src/FloatingButtonStackItem.tsx"],"sourcesContent":["import { useEffect, useId, useRef, forwardRef } from 'react';\nimport { CSSTransition } from 'react-transition-group';\nimport classnames from 'classnames';\n\nimport CoreTokens from '@hh.ru/magritte-design-tokens/core-tokens';\nimport type { PolymorphicForwardRefRenderFunc, PolymorphicComponentWithRef } from '@hh.ru/magritte-types';\nimport { FloatingButtonWithStackMode } from '@hh.ru/magritte-ui-floating-button/FloatingButton';\nimport { useFloatingButtonStack } from '@hh.ru/magritte-ui-floating-button/FloatingButtonStackContext';\nimport type { FloatingButtonStackItemProps } from '@hh.ru/magritte-ui-floating-button/types';\n\nimport styles from './floating-button-stack.less';\n\nconst FloatingButtonStackItemComponent: PolymorphicForwardRefRenderFunc<FloatingButtonStackItemProps, 'button'> = (\n { Element = 'button', visible = false, ...otherProps },\n ref\n) => {\n const uid = useId();\n const { setVisible, animationsEnabled, style, disabled } = useFloatingButtonStack();\n const nodeRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n setVisible(uid, visible);\n }, [uid, setVisible, visible]);\n\n useEffect(() => {\n return () => {\n setVisible(uid, false);\n };\n }, [uid, setVisible]);\n\n return (\n <CSSTransition\n in={visible}\n enter={animationsEnabled}\n exit={animationsEnabled}\n classNames={{\n enter: styles.enterFloatingButtonAnimation,\n enterActive: styles.enterFloatingButtonAnimationActive,\n exit: styles.exitFloatingButtonAnimation,\n exitActive: styles.exitFloatingButtonAnimationActive,\n }}\n nodeRef={nodeRef}\n timeout={CoreTokens['magritte-semantic-animation-time-s'].duration}\n unmountOnExit\n >\n <div ref={nodeRef} className={classnames(styles.floatingButtonWrapper)}>\n <FloatingButtonWithStackMode<typeof Element>\n Element={Element}\n ref={ref}\n {...otherProps}\n style={style}\n disabled={disabled}\n stackMode\n />\n </div>\n </CSSTransition>\n );\n};\n\nexport const FloatingButtonStackItem = forwardRef(FloatingButtonStackItemComponent) as PolymorphicComponentWithRef<\n FloatingButtonStackItemProps,\n 'button'\n>;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAYA,MAAM,gCAAA,GAA4G,CAC9G,EAAE,OAAU,GAAA,QAAA,EAAU,UAAU,KAAO,EAAA,GAAG,UAAW,EAAA,EACrD,GACC,KAAA;AACD,EAAA,MAAM,MAAM,KAAM,EAAA,CAAA;AAClB,EAAA,MAAM,EAAE,UAAY,EAAA,iBAAA,EAAmB,KAAO,EAAA,QAAA,KAAa,sBAAuB,EAAA,CAAA;AAClF,EAAM,MAAA,OAAA,GAAU,OAAuB,IAAI,CAAA,CAAA;AAE3C,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,UAAA,CAAW,KAAK,OAAO,CAAA,CAAA;AAAA,GACxB,EAAA,CAAC,GAAK,EAAA,UAAA,EAAY,OAAO,CAAC,CAAA,CAAA;AAE7B,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,OAAO,MAAM;AACT,MAAA,UAAA,CAAW,KAAK,KAAK,CAAA,CAAA;AAAA,KACzB,CAAA;AAAA,GACD,EAAA,CAAC,GAAK,EAAA,UAAU,CAAC,CAAA,CAAA;AAEpB,EACI,uBAAA,GAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACG,EAAI,EAAA,OAAA;AAAA,MACJ,KAAO,EAAA,iBAAA;AAAA,MACP,IAAM,EAAA,iBAAA;AAAA,MACN,UAAY,EAAA;AAAA,QACR,OAAO,MAAO,CAAA,4BAAA;AAAA,QACd,aAAa,MAAO,CAAA,kCAAA;AAAA,QACpB,MAAM,MAAO,CAAA,2BAAA;AAAA,QACb,YAAY,MAAO,CAAA,iCAAA;AAAA,OACvB;AAAA,MACA,OAAA;AAAA,MACA,OAAA,EAAS,UAAW,CAAA,oCAAoC,CAAE,CAAA,QAAA;AAAA,MAC1D,aAAa,EAAA,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