@hh.ru/magritte-ui-action-bar 2.0.0

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/ActionBar.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { ActionBarProps } from './types';
3
+ export declare const ActionBar: FC<ActionBarProps>;
package/ActionBar.js ADDED
@@ -0,0 +1,68 @@
1
+ import './index.css';
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useState, useRef, useEffect } from 'react';
4
+ import classnames from 'classnames';
5
+ import { throttle } from '@hh.ru/magritte-common-func-utils';
6
+ import { shouldShowDividerOrProgress, getScrollableParent } from './utils.js';
7
+ import { ButtonStack } from '@hh.ru/magritte-ui-button-stack';
8
+ import { Divider } from '@hh.ru/magritte-ui-divider';
9
+
10
+ var styles = {"action-bar-fixed":"magritte-action-bar-fixed___Ts-0i_2-0-0","actionBarFixed":"magritte-action-bar-fixed___Ts-0i_2-0-0","action-bar-with-progress-bar":"magritte-action-bar-with-progress-bar___mprqw_2-0-0","actionBarWithProgressBar":"magritte-action-bar-with-progress-bar___mprqw_2-0-0","progress-bar":"magritte-progress-bar___tSTjx_2-0-0","progressBar":"magritte-progress-bar___tSTjx_2-0-0","actions-wrapper_mobile":"magritte-actions-wrapper_mobile___DWgfU_2-0-0","actionsWrapperMobile":"magritte-actions-wrapper_mobile___DWgfU_2-0-0","actions-wrapper_modal":"magritte-actions-wrapper_modal___aQs2b_2-0-0","actionsWrapperModal":"magritte-actions-wrapper_modal___aQs2b_2-0-0","actions-wrapper_page":"magritte-actions-wrapper_page___NuaNO_2-0-0","actionsWrapperPage":"magritte-actions-wrapper_page___NuaNO_2-0-0","actions-stack":"magritte-actions-stack___12VkP_2-0-0","actionsStack":"magritte-actions-stack___12VkP_2-0-0","actions-stack-vertical-on-mobile":"magritte-actions-stack-vertical-on-mobile___82xhC_2-0-0","actionsStackVerticalOnMobile":"magritte-actions-stack-vertical-on-mobile___82xhC_2-0-0","actions-stack-vertical-on-page-xs":"magritte-actions-stack-vertical-on-page-xs___F8kiH_2-0-0","actionsStackVerticalOnPageXs":"magritte-actions-stack-vertical-on-page-xs___F8kiH_2-0-0","actions-stack-horizontal-on-gt-xs":"magritte-actions-stack-horizontal-on-gt-xs___QXT--_2-0-0","actionsStackHorizontalOnGtXs":"magritte-actions-stack-horizontal-on-gt-xs___QXT--_2-0-0"};
11
+
12
+ const SCROLL_HANDLER_THROTTLE_MS = 50;
13
+ const ActionBar = ({ type, showDivider, showProgress = false, primaryActions = [], secondaryActions = [], wrapperRef, }) => {
14
+ const [isScrollEnd, setIsScrollEnd] = useState(false);
15
+ const actionBarRef = useRef(null);
16
+ const { shouldShowProgress, shouldShowDivider } = shouldShowDividerOrProgress({
17
+ type,
18
+ showDivider,
19
+ showProgress,
20
+ isScrollEnd,
21
+ });
22
+ useEffect(() => {
23
+ if (shouldShowProgress || typeof showDivider === 'boolean') {
24
+ return void 0;
25
+ }
26
+ const scrollableParent = getScrollableParent(actionBarRef.current);
27
+ const handleScroll = throttle(() => {
28
+ if (scrollableParent &&
29
+ Math.abs(scrollableParent.scrollHeight - scrollableParent.clientHeight - scrollableParent.scrollTop) < 1) {
30
+ setIsScrollEnd(true);
31
+ }
32
+ else {
33
+ setIsScrollEnd(false);
34
+ }
35
+ }, SCROLL_HANDLER_THROTTLE_MS);
36
+ if (scrollableParent === document.documentElement) {
37
+ window.addEventListener('scroll', handleScroll);
38
+ }
39
+ else if (scrollableParent) {
40
+ scrollableParent.addEventListener('scroll', handleScroll);
41
+ }
42
+ return () => {
43
+ window.removeEventListener('scroll', handleScroll);
44
+ scrollableParent?.removeEventListener('scroll', handleScroll);
45
+ };
46
+ }, [shouldShowProgress, showDivider]);
47
+ useEffect(() => {
48
+ if (wrapperRef && actionBarRef.current) {
49
+ wrapperRef.current = actionBarRef.current.offsetHeight;
50
+ }
51
+ }, [wrapperRef, type, primaryActions, secondaryActions]);
52
+ if (primaryActions.length === 0 && secondaryActions.length === 0) {
53
+ return null;
54
+ }
55
+ return (jsxs("div", { ref: actionBarRef, "data-qa": "action-bar", className: classnames({
56
+ [styles.actionBarFixed]: type === 'page',
57
+ [styles.actionBarWithProgressBar]: shouldShowProgress,
58
+ }), children: [shouldShowDivider && (jsx("div", { "data-qa": "divider", children: jsx(Divider, { mode: "horizontal" }) })), shouldShowProgress && (jsx("div", { "data-qa": "progress-bar", className: styles.progressBar, children: showProgress })), jsxs("div", { "data-qa": "actions-container", className: styles[`actions-wrapper_${type}`], children: [jsx("div", { className: classnames(styles.actionsStack, {
59
+ [styles.actionsStackVerticalOnMobile]: type === 'mobile',
60
+ [styles.actionsStackVerticalOnPageXs]: type === 'page',
61
+ }), children: jsx(ButtonStack, { orientation: "vertical", children: [...primaryActions, ...secondaryActions] }) }), jsxs("div", { className: classnames(styles.actionsStack, {
62
+ [styles.actionsStackHorizontalOnGtXs]: type === 'modal' || type === 'page',
63
+ }), children: [secondaryActions && jsx(ButtonStack, { orientation: "horizontal", children: secondaryActions }), primaryActions && jsx(ButtonStack, { orientation: "horizontal", children: primaryActions })] })] })] }));
64
+ };
65
+ ActionBar.displayName = 'ActionBar';
66
+
67
+ export { ActionBar };
68
+ //# sourceMappingURL=ActionBar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ActionBar.js","sources":["../src/ActionBar.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState, FC } from 'react';\nimport classnames from 'classnames';\n\nimport { throttle } from '@hh.ru/magritte-common-func-utils';\nimport { ActionBarProps } from '@hh.ru/magritte-ui-action-bar/types';\nimport { getScrollableParent, shouldShowDividerOrProgress } from '@hh.ru/magritte-ui-action-bar/utils';\nimport { ButtonStack } from '@hh.ru/magritte-ui-button-stack';\nimport { Divider } from '@hh.ru/magritte-ui-divider';\n\nimport styles from './action-bar.less';\n\nconst SCROLL_HANDLER_THROTTLE_MS = 50;\n\nexport const ActionBar: FC<ActionBarProps> = ({\n type,\n showDivider,\n showProgress = false,\n primaryActions = [],\n secondaryActions = [],\n wrapperRef,\n}) => {\n const [isScrollEnd, setIsScrollEnd] = useState(false);\n const actionBarRef = useRef<HTMLDivElement>(null);\n const { shouldShowProgress, shouldShowDivider } = shouldShowDividerOrProgress({\n type,\n showDivider,\n showProgress,\n isScrollEnd,\n });\n\n useEffect(() => {\n if (shouldShowProgress || typeof showDivider === 'boolean') {\n return void 0;\n }\n const scrollableParent = getScrollableParent(actionBarRef.current);\n const handleScroll = throttle(() => {\n if (\n scrollableParent &&\n Math.abs(scrollableParent.scrollHeight - scrollableParent.clientHeight - scrollableParent.scrollTop) < 1\n ) {\n setIsScrollEnd(true);\n } else {\n setIsScrollEnd(false);\n }\n }, SCROLL_HANDLER_THROTTLE_MS);\n\n if (scrollableParent === document.documentElement) {\n window.addEventListener('scroll', handleScroll);\n } else if (scrollableParent) {\n scrollableParent.addEventListener('scroll', handleScroll);\n }\n\n return () => {\n window.removeEventListener('scroll', handleScroll);\n scrollableParent?.removeEventListener('scroll', handleScroll);\n };\n }, [shouldShowProgress, showDivider]);\n\n useEffect(() => {\n if (wrapperRef && actionBarRef.current) {\n wrapperRef.current = actionBarRef.current.offsetHeight;\n }\n }, [wrapperRef, type, primaryActions, secondaryActions]);\n\n if (primaryActions.length === 0 && secondaryActions.length === 0) {\n return null;\n }\n\n return (\n <div\n ref={actionBarRef}\n data-qa=\"action-bar\"\n className={classnames({\n [styles.actionBarFixed]: type === 'page',\n [styles.actionBarWithProgressBar]: shouldShowProgress,\n })}\n >\n {shouldShowDivider && (\n <div data-qa=\"divider\">\n <Divider mode=\"horizontal\" />\n </div>\n )}\n {shouldShowProgress && (\n <div data-qa=\"progress-bar\" className={styles.progressBar}>\n {showProgress}\n </div>\n )}\n <div data-qa=\"actions-container\" className={styles[`actions-wrapper_${type}`]}>\n {/* Не получилось заюзать useBreakpoint, т.к. он по умолчанию при первичном рендере возвращает isXS = true\n Из-за этого для type=\"page\" на >XS экранах сначала рендерится вертикальный стэк хотя должен быть горизонтальный\n это может быть критично для определения высоты экшен бара */}\n <div\n className={classnames(styles.actionsStack, {\n [styles.actionsStackVerticalOnMobile]: type === 'mobile',\n [styles.actionsStackVerticalOnPageXs]: type === 'page',\n })}\n >\n <ButtonStack orientation=\"vertical\">{[...primaryActions, ...secondaryActions]}</ButtonStack>\n </div>\n <div\n className={classnames(styles.actionsStack, {\n [styles.actionsStackHorizontalOnGtXs]: type === 'modal' || type === 'page',\n })}\n >\n {secondaryActions && <ButtonStack orientation=\"horizontal\">{secondaryActions}</ButtonStack>}\n {primaryActions && <ButtonStack orientation=\"horizontal\">{primaryActions}</ButtonStack>}\n </div>\n </div>\n </div>\n );\n};\n\nActionBar.displayName = 'ActionBar';\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;;AAWA,MAAM,0BAA0B,GAAG,EAAE,CAAC;AAEzB,MAAA,SAAS,GAAuB,CAAC,EAC1C,IAAI,EACJ,WAAW,EACX,YAAY,GAAG,KAAK,EACpB,cAAc,GAAG,EAAE,EACnB,gBAAgB,GAAG,EAAE,EACrB,UAAU,GACb,KAAI;IACD,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;AACtD,IAAA,MAAM,YAAY,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AAClD,IAAA,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,2BAA2B,CAAC;QAC1E,IAAI;QACJ,WAAW;QACX,YAAY;QACZ,WAAW;AACd,KAAA,CAAC,CAAC;IAEH,SAAS,CAAC,MAAK;AACX,QAAA,IAAI,kBAAkB,IAAI,OAAO,WAAW,KAAK,SAAS,EAAE;YACxD,OAAO,KAAK,CAAC,CAAC;AACjB,SAAA;QACD,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;AACnE,QAAA,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAK;AAC/B,YAAA,IACI,gBAAgB;A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,EAAA,QAAA,EAAE,gBAAgB,EAAA,CAAe,EAC1F,cAAc,IAAIA,GAAA,CAAC,WAAW,EAAA,EAAC,WAAW,EAAC,YAAY,EAAA,QAAA,EAAE,cAAc,EAAA,CAAe,CACrF,EAAA,CAAA,CAAA,EAAA,CACJ,CACJ,EAAA,CAAA,EACR;AACN,EAAE;AAEF,SAAS,CAAC,WAAW,GAAG,WAAW;;;;"}
package/index.css ADDED
@@ -0,0 +1,108 @@
1
+ :root{
2
+ --magritte-color-background-primary-v18-1-2:#ffffff;
3
+ }
4
+ .magritte-night-theme{
5
+ --magritte-color-background-primary-v18-1-2:#000000;
6
+ }
7
+ .magritte-action-bar-fixed___Ts-0i_2-0-0{
8
+ background-color:var(--magritte-color-background-primary-v18-1-2);
9
+ position:fixed;
10
+ bottom:0;
11
+ left:0;
12
+ width:100%;
13
+ }
14
+ .magritte-action-bar-with-progress-bar___mprqw_2-0-0{
15
+ border-radius:8px 8px 0 0;
16
+ }
17
+ .magritte-progress-bar___tSTjx_2-0-0{
18
+ padding:4px 4px 0;
19
+ }
20
+ .magritte-actions-wrapper_mobile___DWgfU_2-0-0{
21
+ padding:16px;
22
+ }
23
+ .magritte-actions-wrapper_modal___aQs2b_2-0-0{
24
+ padding:32px;
25
+ }
26
+ .magritte-actions-wrapper_page___NuaNO_2-0-0{
27
+ padding:16px;
28
+ }
29
+ @media (min-width: 1020px){
30
+ body.magritte-old-layout .magritte-actions-wrapper_page___NuaNO_2-0-0{
31
+ padding:16px 68px;
32
+ }
33
+ }
34
+ @media (min-width: 1024px){
35
+ body:not(.magritte-old-layout) .magritte-actions-wrapper_page___NuaNO_2-0-0{
36
+ padding:16px 68px;
37
+ }
38
+ }
39
+ @media (min-width: 1340px){
40
+ body.magritte-old-layout .magritte-actions-wrapper_page___NuaNO_2-0-0{
41
+ padding:16px 76px;
42
+ }
43
+ }
44
+ @media (min-width: 1280px){
45
+ body:not(.magritte-old-layout) .magritte-actions-wrapper_page___NuaNO_2-0-0{
46
+ padding:16px 76px;
47
+ }
48
+ }
49
+ @media (min-width: 1440px){
50
+ body:not(.magritte-old-layout) .magritte-actions-wrapper_page___NuaNO_2-0-0{
51
+ padding:16px 108px;
52
+ }
53
+ }
54
+ @media (min-width: 1920px){
55
+ body:not(.magritte-old-layout) .magritte-actions-wrapper_page___NuaNO_2-0-0{
56
+ padding:16px 252px;
57
+ }
58
+ }
59
+ .magritte-actions-stack___12VkP_2-0-0{
60
+ display:none;
61
+ }
62
+ .magritte-actions-stack-vertical-on-mobile___82xhC_2-0-0{
63
+ display:block;
64
+ }
65
+ @media (min-width: 1020px){
66
+ body.magritte-old-layout .magritte-actions-stack-vertical-on-mobile___82xhC_2-0-0{
67
+ display:none;
68
+ }
69
+ }
70
+ @media (min-width: 1024px){
71
+ body:not(.magritte-old-layout) .magritte-actions-stack-vertical-on-mobile___82xhC_2-0-0{
72
+ display:none;
73
+ }
74
+ }
75
+ .magritte-actions-stack-vertical-on-page-xs___F8kiH_2-0-0{
76
+ display:block;
77
+ }
78
+ @media (min-width: 700px){
79
+ body.magritte-old-layout .magritte-actions-stack-vertical-on-page-xs___F8kiH_2-0-0{
80
+ display:none;
81
+ }
82
+ }
83
+ @media (min-width: 600px){
84
+ body:not(.magritte-old-layout) .magritte-actions-stack-vertical-on-page-xs___F8kiH_2-0-0{
85
+ display:none;
86
+ }
87
+ }
88
+ .magritte-actions-stack-horizontal-on-gt-xs___QXT--_2-0-0{
89
+ display:none;
90
+ }
91
+ @media (min-width: 700px){
92
+ body.magritte-old-layout .magritte-actions-stack-horizontal-on-gt-xs___QXT--_2-0-0{
93
+ display:flex;
94
+ flex-grow:1;
95
+ flex-direction:row;
96
+ justify-content:space-between;
97
+ gap:12px;
98
+ }
99
+ }
100
+ @media (min-width: 600px){
101
+ body:not(.magritte-old-layout) .magritte-actions-stack-horizontal-on-gt-xs___QXT--_2-0-0{
102
+ display:flex;
103
+ flex-grow:1;
104
+ flex-direction:row;
105
+ justify-content:space-between;
106
+ gap:12px;
107
+ }
108
+ }
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './types';
2
+ export * from './ActionBar';
package/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import './index.css';
2
+ export { ActionBar } from './ActionBar.js';
3
+ import 'react/jsx-runtime';
4
+ import 'react';
5
+ import 'classnames';
6
+ import '@hh.ru/magritte-common-func-utils';
7
+ import './utils.js';
8
+ import '@hh.ru/magritte-ui-button-stack';
9
+ import '@hh.ru/magritte-ui-divider';
10
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -0,0 +1,2 @@
1
+ import { FC } from 'react';
2
+ export declare const ActionBar: FC<Record<string, unknown>>;
package/index.mock.js ADDED
@@ -0,0 +1,9 @@
1
+ import './index.css';
2
+ import { mockComponent } from '@hh.ru/magritte-ui-mock-component';
3
+
4
+ const ActionBar = mockComponent('ActionBar', undefined, {
5
+ withChildren: false,
6
+ });
7
+
8
+ export { ActionBar };
9
+ //# sourceMappingURL=index.mock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mock.js","sources":["../src/index.mock.ts"],"sourcesContent":["import { FC } from 'react';\n\nimport { mockComponent } from '@hh.ru/magritte-ui-mock-component';\n\nexport const ActionBar: FC<Record<string, unknown>> = mockComponent('ActionBar', undefined, {\n withChildren: false,\n});\n"],"names":[],"mappings":";;MAIa,SAAS,GAAgC,aAAa,CAAC,WAAW,EAAE,SAAS,EAAE;AACxF,IAAA,YAAY,EAAE,KAAK;AACtB,CAAA;;;;"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@hh.ru/magritte-ui-action-bar",
3
+ "version": "2.0.0",
4
+ "main": "index.js",
5
+ "types": "index.d.ts",
6
+ "sideEffects": [
7
+ "index.css"
8
+ ],
9
+ "scripts": {
10
+ "build": "yarn root:build $(pwd)",
11
+ "build-test-branch": "yarn root:build-test-branch $(pwd)",
12
+ "changelog": "yarn root:changelog $(pwd)",
13
+ "prepack": "yarn root:prepack $(pwd)",
14
+ "postpublish": "yarn root:postpublish $(pwd)",
15
+ "stylelint-test": "yarn root:stylelint-test $(pwd)",
16
+ "eslint-test": "yarn root:eslint-test $(pwd)",
17
+ "ts-config": "yarn root:ts-config $(pwd)",
18
+ "ts-check": "yarn root:ts-check $(pwd)",
19
+ "test": "yarn root:test $(pwd)"
20
+ },
21
+ "dependencies": {
22
+ "@hh.ru/magritte-common-func-utils": "1.3.6",
23
+ "@hh.ru/magritte-ui-button": "4.0.0",
24
+ "@hh.ru/magritte-ui-button-stack": "2.0.7",
25
+ "@hh.ru/magritte-ui-divider": "1.1.25",
26
+ "@hh.ru/magritte-ui-mock-component": "1.0.10"
27
+ },
28
+ "peerDependencies": {
29
+ "classnames": ">=2.3.2",
30
+ "react": ">=18.2.0"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "gitHead": "be4048efc0a1d6bed295e4fda829c6e0bd0f0838"
36
+ }
package/types.d.ts ADDED
@@ -0,0 +1,38 @@
1
+ import { ComponentProps, MutableRefObject, ReactElement, ReactNode } from 'react';
2
+ import { Button } from '@hh.ru/magritte-ui-button';
3
+ export type ActionBarType = 'page' | 'modal' | 'mobile';
4
+ export type NonEmptyArray<T> = [T, ...T[]];
5
+ export type ButtonElement = ReactElement<ComponentProps<typeof Button>>;
6
+ interface BaseActionBarProps {
7
+ /** ActionBar тип */
8
+ type: ActionBarType;
9
+ /** wrapperRef для получения высоты экшен бара */
10
+ wrapperRef?: MutableRefObject<number | undefined>;
11
+ }
12
+ interface ActionBarWithPrimaryProps extends BaseActionBarProps {
13
+ /** Массив с primary кнопками */
14
+ primaryActions: NonEmptyArray<ButtonElement>;
15
+ /** Массив с secondary кнопками */
16
+ secondaryActions?: NonEmptyArray<ButtonElement>;
17
+ }
18
+ interface ActionBarWithSecondaryProps extends BaseActionBarProps {
19
+ primaryActions?: NonEmptyArray<ButtonElement>;
20
+ secondaryActions: NonEmptyArray<ButtonElement>;
21
+ }
22
+ type ActionBarDividerProgressProps = {
23
+ type: Extract<ActionBarType, 'mobile'>;
24
+ /** Показывать ли разделитель */
25
+ showDivider?: boolean;
26
+ /** Показывать ли прогресс бар */
27
+ showProgress?: never;
28
+ } | {
29
+ type: Exclude<ActionBarType, 'mobile'>;
30
+ showDivider?: boolean;
31
+ showProgress?: never;
32
+ } | {
33
+ type: Exclude<ActionBarType, 'mobile'>;
34
+ showDivider?: never;
35
+ showProgress?: ReactNode;
36
+ };
37
+ export type ActionBarProps = (ActionBarWithPrimaryProps | ActionBarWithSecondaryProps) & ActionBarDividerProgressProps;
38
+ export {};
package/types.js ADDED
@@ -0,0 +1,3 @@
1
+ import './index.css';
2
+
3
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
package/utils.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ import { ActionBarType } from './types';
3
+ export declare const getScrollableParent: (node: HTMLElement | null) => HTMLElement | null;
4
+ export declare const shouldShowDividerOrProgress: ({ type, showDivider, showProgress, isScrollEnd, }: {
5
+ type: ActionBarType;
6
+ showDivider: boolean | undefined;
7
+ showProgress: ReactNode | undefined;
8
+ isScrollEnd: boolean;
9
+ }) => {
10
+ shouldShowProgress: boolean;
11
+ shouldShowDivider: boolean;
12
+ };
package/utils.js ADDED
@@ -0,0 +1,29 @@
1
+ import './index.css';
2
+ import React from 'react';
3
+
4
+ const getScrollableParent = (node) => {
5
+ if (node == null) {
6
+ return null;
7
+ }
8
+ if (node.scrollHeight > node.clientHeight) {
9
+ return node;
10
+ }
11
+ return getScrollableParent(node.parentElement);
12
+ };
13
+ const shouldShowDividerOrProgress = ({ type, showDivider, showProgress, isScrollEnd, }) => {
14
+ const shouldShowProgress = type === 'mobile' ? false : React.isValidElement(showProgress);
15
+ if (shouldShowProgress) {
16
+ return {
17
+ shouldShowProgress,
18
+ shouldShowDivider: false,
19
+ };
20
+ }
21
+ const shouldShowDivider = typeof showDivider === 'boolean' ? showDivider : !isScrollEnd;
22
+ return {
23
+ shouldShowProgress: false,
24
+ shouldShowDivider,
25
+ };
26
+ };
27
+
28
+ export { getScrollableParent, shouldShowDividerOrProgress };
29
+ //# sourceMappingURL=utils.js.map
package/utils.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import React, { ReactNode } from 'react';\n\nimport { ActionBarType } from '@hh.ru/magritte-ui-action-bar/types';\n\nexport const getScrollableParent = (node: HTMLElement | null): HTMLElement | null => {\n if (node == null) {\n return null;\n }\n if (node.scrollHeight > node.clientHeight) {\n return node;\n }\n return getScrollableParent(node.parentElement);\n};\n\nexport const shouldShowDividerOrProgress = ({\n type,\n showDivider,\n showProgress,\n isScrollEnd,\n}: {\n type: ActionBarType;\n showDivider: boolean | undefined;\n showProgress: ReactNode | undefined;\n isScrollEnd: boolean;\n}): { shouldShowProgress: boolean; shouldShowDivider: boolean } => {\n const shouldShowProgress = type === 'mobile' ? false : React.isValidElement(showProgress);\n if (shouldShowProgress) {\n return {\n shouldShowProgress,\n shouldShowDivider: false,\n };\n }\n const shouldShowDivider = typeof showDivider === 'boolean' ? showDivider : !isScrollEnd;\n return {\n shouldShowProgress: false,\n shouldShowDivider,\n };\n};\n"],"names":[],"mappings":";;AAIa,MAAA,mBAAmB,GAAG,CAAC,IAAwB,KAAwB;IAChF,IAAI,IAAI,IAAI,IAAI,EAAE;AACd,QAAA,OAAO,IAAI,CAAC;AACf,KAAA;AACD,IAAA,IAAI,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE;AACvC,QAAA,OAAO,IAAI,CAAC;AACf,KAAA;AACD,IAAA,OAAO,mBAAmB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AACnD,EAAE;AAEK,MAAM,2BAA2B,GAAG,CAAC,EACxC,IAAI,EACJ,WAAW,EACX,YAAY,EACZ,WAAW,GAMd,KAAiE;AAC9D,IAAA,MAAM,kBAAkB,GAAG,IAAI,KAAK,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;AAC1F,IAAA,IAAI,kBAAkB,EAAE;QACpB,OAAO;YACH,kBAAkB;AAClB,YAAA,iBAAiB,EAAE,KAAK;SAC3B,CAAC;AACL,KAAA;AACD,IAAA,MAAM,iBAAiB,GAAG,OAAO,WAAW,KAAK,SAAS,GAAG,WAAW,GAAG,CAAC,WAAW,CAAC;IACxF,OAAO;AACH,QAAA,kBAAkB,EAAE,KAAK;QACzB,iBAAiB;KACpB,CAAC;AACN;;;;"}