@alphakits/ui 2.0.5 → 2.0.7
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/checkbox/component.js +6 -6
- package/dist/checkbox/component.js.map +1 -1
- package/dist/modal/components/modals/index.module.css +1 -1
- package/dist/modal/components/modals/index.module.css.js +9 -11
- package/dist/modal/components/modals/index.module.css.js.map +1 -1
- package/dist/modal/components/modals/modal.js +17 -17
- package/dist/modal/components/modals/modal.js.map +1 -1
- package/dist/modal/hooks/use-modal.d.ts +1 -1
- package/dist/modal/hooks/use-modal.js +5 -5
- package/dist/modal/hooks/use-modal.js.map +1 -1
- package/dist/modal/types.d.ts +2 -2
- package/dist/sidepanel/component.d.ts +1 -0
- package/dist/sidepanel/component.js +22 -20
- package/dist/sidepanel/component.js.map +1 -1
- package/dist/sidepanel-header/component.d.ts +1 -0
- package/dist/sidepanel-header/component.js +9 -8
- package/dist/sidepanel-header/component.js.map +1 -1
- package/dist/sidepanel-header/index.module.css +1 -1
- package/package.json +1 -1
|
@@ -12,19 +12,19 @@ const P = y(
|
|
|
12
12
|
label: o,
|
|
13
13
|
hint: a,
|
|
14
14
|
size: d = "m",
|
|
15
|
-
align: p = "
|
|
15
|
+
align: p = "start",
|
|
16
16
|
addons: n,
|
|
17
17
|
block: h,
|
|
18
|
-
onChange:
|
|
18
|
+
onChange: t,
|
|
19
19
|
className: u,
|
|
20
20
|
name: N,
|
|
21
|
-
disabled:
|
|
21
|
+
disabled: m,
|
|
22
22
|
dataTestId: b,
|
|
23
23
|
indeterminate: l = !1,
|
|
24
24
|
...k
|
|
25
25
|
}, x) => {
|
|
26
26
|
const i = C(null), [R] = I(i, "keyboard"), g = (f) => {
|
|
27
|
-
|
|
27
|
+
t && t(f, { checked: f.target.checked, name: N });
|
|
28
28
|
};
|
|
29
29
|
return (
|
|
30
30
|
// eslint-disable-next-line jsx-a11y/label-has-associated-control
|
|
@@ -32,7 +32,7 @@ const P = y(
|
|
|
32
32
|
"label",
|
|
33
33
|
{
|
|
34
34
|
className: F(e.component, e[d], e[p], u, {
|
|
35
|
-
[e.disabled]:
|
|
35
|
+
[e.disabled]: m,
|
|
36
36
|
[e.checked]: r,
|
|
37
37
|
[e.indeterminate]: l,
|
|
38
38
|
[e.focused]: R,
|
|
@@ -46,7 +46,7 @@ const P = y(
|
|
|
46
46
|
{
|
|
47
47
|
type: "checkbox",
|
|
48
48
|
onChange: g,
|
|
49
|
-
disabled:
|
|
49
|
+
disabled: m,
|
|
50
50
|
checked: r,
|
|
51
51
|
"data-test-id": b,
|
|
52
52
|
...k
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../src/checkbox/component.tsx"],"sourcesContent":["import React, {\n ChangeEvent, forwardRef, InputHTMLAttributes, ReactNode, useRef,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport CheckmarkS from '@alphakits/icons/dist/CheckmarkS';\nimport MinusM from '@alphakits/icons/dist/MinusM';\nimport cn from 'classnames';\n\nimport { useFocus } from '../hooks/useFocus';\n\nimport styles from './index.module.css';\n\ntype NativeProps = InputHTMLAttributes<HTMLInputElement>;\ntype Align = 'start' | 'center';\n\nexport type CheckboxProps = Omit<NativeProps, 'size' | 'onChange'> & {\n /**\n * Управление состоянием вкл/выкл чекбокса (native prop)\n */\n checked?: boolean;\n\n /**\n * Обработчик переключения чекбокса\n */\n onChange: (\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars */\n event: ChangeEvent<HTMLInputElement>,\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars */\n payload: {\n checked: boolean;\n name?: string;\n },\n ) => void;\n\n /**\n * Текст подписи к чекбоксу\n */\n label?: ReactNode;\n\n /**\n * Текст подсказки снизу\n */\n hint?: ReactNode;\n\n /**\n * Размер компонента\n */\n size?: 's' | 'm';\n\n /**\n * Выравнивание\n */\n align?: Align;\n\n /**\n * Дополнительный слот\n */\n addons?: React.ReactNode;\n\n /**\n * Растягивать ли компонент на всю ширину\n */\n block?: boolean;\n\n /**\n * Идентификатор для систем автоматизированного тестирования\n */\n dataTestId?: string;\n\n /**\n * Управление неопределенным состоянием чекбокса\n */\n indeterminate?: boolean;\n};\n\nexport const Checkbox = forwardRef<HTMLLabelElement, CheckboxProps>(\n (\n {\n checked,\n label,\n hint,\n size = 'm',\n align = '
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../src/checkbox/component.tsx"],"sourcesContent":["import React, {\n ChangeEvent, forwardRef, InputHTMLAttributes, ReactNode, useRef,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport CheckmarkS from '@alphakits/icons/dist/CheckmarkS';\nimport MinusM from '@alphakits/icons/dist/MinusM';\nimport cn from 'classnames';\n\nimport { useFocus } from '../hooks/useFocus';\n\nimport styles from './index.module.css';\n\ntype NativeProps = InputHTMLAttributes<HTMLInputElement>;\ntype Align = 'start' | 'center';\n\nexport type CheckboxProps = Omit<NativeProps, 'size' | 'onChange'> & {\n /**\n * Управление состоянием вкл/выкл чекбокса (native prop)\n */\n checked?: boolean;\n\n /**\n * Обработчик переключения чекбокса\n */\n onChange: (\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars */\n event: ChangeEvent<HTMLInputElement>,\n /* eslint-disable-next-line @typescript-eslint/no-unused-vars */\n payload: {\n checked: boolean;\n name?: string;\n },\n ) => void;\n\n /**\n * Текст подписи к чекбоксу\n */\n label?: ReactNode;\n\n /**\n * Текст подсказки снизу\n */\n hint?: ReactNode;\n\n /**\n * Размер компонента\n */\n size?: 's' | 'm';\n\n /**\n * Выравнивание\n */\n align?: Align;\n\n /**\n * Дополнительный слот\n */\n addons?: React.ReactNode;\n\n /**\n * Растягивать ли компонент на всю ширину\n */\n block?: boolean;\n\n /**\n * Идентификатор для систем автоматизированного тестирования\n */\n dataTestId?: string;\n\n /**\n * Управление неопределенным состоянием чекбокса\n */\n indeterminate?: boolean;\n};\n\nexport const Checkbox = forwardRef<HTMLLabelElement, CheckboxProps>(\n (\n {\n checked,\n label,\n hint,\n size = 'm',\n align = 'start',\n addons,\n block,\n onChange,\n className,\n name,\n disabled,\n dataTestId,\n indeterminate = false,\n ...restProps\n },\n ref,\n ) => {\n const labelRef = useRef<HTMLLabelElement>(null);\n\n const [focused] = useFocus(labelRef, 'keyboard');\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>) => {\n if (onChange) {\n onChange(event, { checked: event.target.checked, name });\n }\n };\n\n return (\n // eslint-disable-next-line jsx-a11y/label-has-associated-control\n <label\n className={ cn(styles.component, styles[size], styles[align], className, {\n [styles.disabled]: disabled,\n [styles.checked]: checked,\n [styles.indeterminate]: indeterminate,\n [styles.focused]: focused,\n [styles.block]: block,\n }) }\n ref={ mergeRefs([labelRef, ref]) }\n >\n <span className={ styles.box }>\n <input\n type=\"checkbox\"\n onChange={ handleChange }\n disabled={ disabled }\n checked={ checked }\n data-test-id={ dataTestId }\n { ...restProps }\n />\n\n { checked && <CheckmarkS /> }\n\n { indeterminate && !checked && (\n <div className={ styles.indeterminateIcon }>\n <MinusM />\n </div>\n ) }\n </span>\n\n { (label || hint) && (\n <span className={ styles.content }>\n { label && <span className={ styles.label }>{ label }</span> }\n { hint && <span className={ styles.hint }>{ hint }</span> }\n </span>\n ) }\n\n { addons && <span className={ styles.addons }>{ addons }</span> }\n </label>\n );\n },\n);\n\n/**\n * Для отображения в сторибуке\n */\nCheckbox.defaultProps = {\n indeterminate: false,\n};\n"],"names":["Checkbox","forwardRef","checked","label","hint","size","align","addons","block","onChange","className","name","disabled","dataTestId","indeterminate","restProps","ref","labelRef","useRef","focused","useFocus","handleChange","event","jsxs","cn","styles","mergeRefs","jsx","CheckmarkS","MinusM"],"mappings":";;;;;;;;AA2EO,MAAMA,IAAWC;AAAA,EACpB,CACI;AAAA,IACI,SAAAC;AAAA,IACA,OAAAC;AAAA,IACA,MAAAC;AAAA,IACA,MAAAC,IAAO;AAAA,IACP,OAAAC,IAAQ;AAAA,IACR,QAAAC;AAAA,IACA,OAAAC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C,MACR,gBAAAmB,EAAC,QAAA,EAAK,WAAYE,EAAO,SACnB,UAAA;AAAA,cAAAtB,KAAS,gBAAAwB,EAAC,QAAA,EAAK,WAAYF,EAAO,OAAU,UAAAtB,GAAO;AAAA,cACnDC,KAAQ,gBAAAuB,EAAC,QAAA,EAAK,WAAYF,EAAO,MAAS,UAAArB,EAAA,CAAM;AAAA,YAAA,GACtD;AAAA,YAGFG,KAAU,gBAAAoB,EAAC,QAAA,EAAK,WAAYF,EAAO,QAAW,UAAAlB,EAAA,CAAQ;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA;AAAA,EAGpE;AACJ;AAKAP,EAAS,eAAe;AAAA,EACpB,eAAe;AACnB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
.container_WE0K{position:fixed;inset:0;display:flex;align-items:center;justify-content:center}.content_p1kc{background:var(--color-bg-primary);box-shadow:0 0 10px #0003}@media print{.content_p1kc{width:100%!important}}.button_js2W{position:absolute!important;top:36px;right:32px;z-index:999}.
|
|
1
|
+
.container_WE0K{position:fixed;inset:0;display:flex;align-items:center;justify-content:center}.content_p1kc{background:var(--color-bg-primary);box-shadow:0 0 10px #0003}@media print{.content_p1kc{width:100%!important}}.button_js2W{position:absolute!important;top:36px;right:32px;z-index:999}.inner_Zsdb{height:100%;box-sizing:border-box;overflow:auto}.right_e065{position:fixed;top:0;right:0;bottom:0;transition:width .2s,opacity .2s,right .2s;transition-delay:width .1s;transition-timing-function:ease-in}.bg_8ZfP{transition:opacity .2s;background:#00000080;position:fixed;display:block;border:0;inset:0}@media screen and (max-width:823px){.right_e065,.center_nguy{max-width:100%!important;inset:0!important}.content_p1kc{width:100%!important;height:100%!important;max-height:100%!important;box-shadow:none!important;margin:0!important;border-radius:0!important}.button_js2W{top:24px!important;right:16px!important}}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import './index.module.css';
|
|
2
|
-
const
|
|
3
|
-
container:
|
|
4
|
-
content:
|
|
2
|
+
const n = "container_WE0K", t = "content_p1kc", o = "button_js2W", c = "inner_Zsdb", e = "right_e065", s = "bg_8ZfP", r = {
|
|
3
|
+
container: n,
|
|
4
|
+
content: t,
|
|
5
5
|
button: o,
|
|
6
|
-
doubleModal: e,
|
|
7
6
|
inner: c,
|
|
8
|
-
right:
|
|
9
|
-
bg:
|
|
7
|
+
right: e,
|
|
8
|
+
bg: s
|
|
10
9
|
};
|
|
11
10
|
export {
|
|
12
|
-
|
|
11
|
+
s as bg,
|
|
13
12
|
o as button,
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
n as container,
|
|
14
|
+
t as content,
|
|
16
15
|
r as default,
|
|
17
|
-
e as doubleModal,
|
|
18
16
|
c as inner,
|
|
19
|
-
|
|
17
|
+
e as right
|
|
20
18
|
};
|
|
21
19
|
//# sourceMappingURL=index.module.css.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.module.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as n, jsxs as u } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import y, { useState as C, useLayoutEffect as d, useCallback as h, useEffect as z } from "react";
|
|
3
|
+
import v from "classnames";
|
|
4
4
|
import { ButtonArrow as x } from "../../../button-arrow/component.js";
|
|
5
5
|
import o from "./index.module.css.js";
|
|
6
6
|
const k = {
|
|
@@ -9,36 +9,36 @@ const k = {
|
|
|
9
9
|
full: "96%"
|
|
10
10
|
}, F = ({
|
|
11
11
|
modal: e,
|
|
12
|
-
t:
|
|
12
|
+
t: b,
|
|
13
13
|
index: l,
|
|
14
14
|
dirtyModals: p,
|
|
15
15
|
closeModal: a,
|
|
16
16
|
currentModalId: r
|
|
17
17
|
}) => {
|
|
18
|
-
const c = -k[e.props.size] - 102, [
|
|
19
|
-
|
|
20
|
-
setTimeout(() =>
|
|
18
|
+
const c = -k[e.props.size] - 102, [w, f] = C(c);
|
|
19
|
+
d(() => {
|
|
20
|
+
setTimeout(() => f(0), 0);
|
|
21
21
|
}, []);
|
|
22
|
-
const
|
|
22
|
+
const m = h(
|
|
23
23
|
(s) => (
|
|
24
24
|
// eslint-disable-next-line no-restricted-globals
|
|
25
|
-
!p[s] || confirm(
|
|
25
|
+
!p[s] || confirm(b("common:exitConfirm"))
|
|
26
26
|
),
|
|
27
27
|
[p]
|
|
28
|
-
), t =
|
|
28
|
+
), t = h((s) => {
|
|
29
29
|
const { id: i } = e;
|
|
30
|
-
|
|
30
|
+
m(s || i) && (f(c), setTimeout(() => {
|
|
31
31
|
e.props.closeCallback && e.props.closeCallback(), a(s || i);
|
|
32
32
|
}, 250));
|
|
33
|
-
}, [a,
|
|
34
|
-
return
|
|
33
|
+
}, [a, m, e, c]);
|
|
34
|
+
return z(() => {
|
|
35
35
|
const s = (i) => {
|
|
36
36
|
(i.key === "27" || i.key === "Escape") && t(r);
|
|
37
37
|
};
|
|
38
38
|
return e.id === r && (window == null || window.addEventListener("keydown", s)), () => {
|
|
39
39
|
window == null || window.removeEventListener("keydown", s);
|
|
40
40
|
};
|
|
41
|
-
}, [t, r, e.id]), /* @__PURE__ */ n(
|
|
41
|
+
}, [t, r, e.id]), /* @__PURE__ */ n(y.Fragment, { children: /* @__PURE__ */ u(
|
|
42
42
|
"div",
|
|
43
43
|
{
|
|
44
44
|
className: o.container,
|
|
@@ -49,18 +49,18 @@ const k = {
|
|
|
49
49
|
/* @__PURE__ */ n(
|
|
50
50
|
"div",
|
|
51
51
|
{
|
|
52
|
-
className:
|
|
52
|
+
className: v(o.right, o.content),
|
|
53
53
|
style: {
|
|
54
54
|
zIndex: 9999999 + l,
|
|
55
55
|
width: k[e.props.size],
|
|
56
|
-
right:
|
|
56
|
+
right: w
|
|
57
57
|
},
|
|
58
58
|
children: /* @__PURE__ */ u("div", { className: o.inner, children: [
|
|
59
59
|
/* @__PURE__ */ n(e.modal, { ...e.props, close: () => t() }),
|
|
60
|
-
/* @__PURE__ */ n(
|
|
60
|
+
e.props.showCloser !== !1 && /* @__PURE__ */ n(
|
|
61
61
|
x,
|
|
62
62
|
{
|
|
63
|
-
className:
|
|
63
|
+
className: o.button,
|
|
64
64
|
size: "s",
|
|
65
65
|
type: "close",
|
|
66
66
|
onClick: () => t()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sources":["../../../../src/modal/components/modals/modal.tsx"],"sourcesContent":["import React, {\n useCallback, useEffect, useLayoutEffect, useState,\n} from 'react';\nimport classNames from 'classnames';\n\nimport { ButtonArrow } from '../../../button-arrow';\nimport { ModalObject, TFunction } from '../../types';\n\nimport { ModalsProps } from '.';\n\nimport styles from './index.module.css';\n\nconst sizes = {\n s: 488,\n m: 888,\n full: '96%',\n};\n\ntype ModalProps = {\n modal: ModalObject;\n index: number;\n t: TFunction;\n} & Pick<ModalsProps, 'dirtyModals' | 'closeModal' | 'currentModalId'>;\n\nexport const Modal = ({\n modal, t, index, dirtyModals, closeModal, currentModalId,\n}: ModalProps) => {\n const modalFullWidth = -sizes[modal.props.size] - 102;\n const [modalPosition, setModalPosition] = useState(modalFullWidth);\n\n useLayoutEffect(() => {\n setTimeout(() => setModalPosition(0), 0);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const confirmClose = useCallback((id: string) =>\n // eslint-disable-next-line no-restricted-globals\n !dirtyModals[id] || confirm(t('common:exitConfirm'))\n // eslint-disable-next-line react-hooks/exhaustive-deps\n , [dirtyModals]);\n\n const handleClose = useCallback((latestId?: string) => {\n const { id } = modal;\n\n if (!confirmClose(latestId || id)) return;\n\n setModalPosition(modalFullWidth);\n\n setTimeout(() => {\n if (modal.props.closeCallback) {\n modal.props.closeCallback();\n }\n closeModal(latestId || id);\n }, 250);\n }, [closeModal, confirmClose, modal, modalFullWidth]);\n\n useEffect(() => {\n const escapeListener = (event: KeyboardEvent) => {\n if (event.key === '27' || event.key === 'Escape') {\n handleClose(currentModalId);\n }\n };\n\n if (modal.id === currentModalId) {\n window?.addEventListener('keydown', escapeListener);\n }\n\n return () => {\n window?.removeEventListener('keydown', escapeListener);\n };\n }, [handleClose, currentModalId, modal.id]);\n\n return (\n <React.Fragment>\n <div\n className={ styles.container }\n style={ {\n zIndex: 9999998 + index,\n } }\n >\n <div\n className={ classNames(styles.right, styles.content) }\n style={ {\n zIndex: 9999999 + index,\n width: sizes[modal.props.size],\n right: modalPosition,\n } }\n >\n <div className={ styles.inner }>\n <modal.modal { ...modal.props } close={ () => handleClose() } />\n\n <ButtonArrow\n
|
|
1
|
+
{"version":3,"file":"modal.js","sources":["../../../../src/modal/components/modals/modal.tsx"],"sourcesContent":["import React, {\n useCallback, useEffect, useLayoutEffect, useState,\n} from 'react';\nimport classNames from 'classnames';\n\nimport { ButtonArrow } from '../../../button-arrow';\nimport { ModalObject, TFunction } from '../../types';\n\nimport { ModalsProps } from '.';\n\nimport styles from './index.module.css';\n\nconst sizes = {\n s: 488,\n m: 888,\n full: '96%',\n};\n\ntype ModalProps = {\n modal: ModalObject;\n index: number;\n t: TFunction;\n} & Pick<ModalsProps, 'dirtyModals' | 'closeModal' | 'currentModalId'>;\n\nexport const Modal = ({\n modal, t, index, dirtyModals, closeModal, currentModalId,\n}: ModalProps) => {\n const modalFullWidth = -sizes[modal.props.size] - 102;\n const [modalPosition, setModalPosition] = useState(modalFullWidth);\n\n useLayoutEffect(() => {\n setTimeout(() => setModalPosition(0), 0);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const confirmClose = useCallback((id: string) =>\n // eslint-disable-next-line no-restricted-globals\n !dirtyModals[id] || confirm(t('common:exitConfirm'))\n // eslint-disable-next-line react-hooks/exhaustive-deps\n , [dirtyModals]);\n\n const handleClose = useCallback((latestId?: string) => {\n const { id } = modal;\n\n if (!confirmClose(latestId || id)) return;\n\n setModalPosition(modalFullWidth);\n\n setTimeout(() => {\n if (modal.props.closeCallback) {\n modal.props.closeCallback();\n }\n closeModal(latestId || id);\n }, 250);\n }, [closeModal, confirmClose, modal, modalFullWidth]);\n\n useEffect(() => {\n const escapeListener = (event: KeyboardEvent) => {\n if (event.key === '27' || event.key === 'Escape') {\n handleClose(currentModalId);\n }\n };\n\n if (modal.id === currentModalId) {\n window?.addEventListener('keydown', escapeListener);\n }\n\n return () => {\n window?.removeEventListener('keydown', escapeListener);\n };\n }, [handleClose, currentModalId, modal.id]);\n\n return (\n <React.Fragment>\n <div\n className={ styles.container }\n style={ {\n zIndex: 9999998 + index,\n } }\n >\n <div\n className={ classNames(styles.right, styles.content) }\n style={ {\n zIndex: 9999999 + index,\n width: sizes[modal.props.size],\n right: modalPosition,\n } }\n >\n <div className={ styles.inner }>\n <modal.modal { ...modal.props } close={ () => handleClose() } />\n\n { modal.props.showCloser !== false && (\n <ButtonArrow\n className={ styles.button }\n size=\"s\"\n type=\"close\"\n onClick={ () => handleClose() }\n />\n ) }\n </div>\n </div>\n\n <button\n className={ styles.bg }\n aria-label=\"close_backdrop\"\n type=\"button\"\n onClick={ () => handleClose() }\n />\n </div>\n\n </React.Fragment>\n );\n};\n"],"names":["sizes","Modal","modal","t","index","dirtyModals","closeModal","currentModalId","modalFullWidth","modalPosition","setModalPosition","useState","useLayoutEffect","confirmClose","useCallback","id","handleClose","latestId","useEffect","escapeListener","event","jsx","React","jsxs","styles","classNames","ButtonArrow"],"mappings":";;;;;AAYA,MAAMA,IAAQ;AAAA,EACV,GAAG;AAAA,EACH,GAAG;AAAA,EACH,MAAM;AACV,GAQaC,IAAQ,CAAC;AAAA,EAClB,OAAAC;AAAA,EAAO,GAAAC;AAAA,EAAG,OAAAC;AAAA,EAAO,aAAAC;AAAA,EAAa,YAAAC;AAAA,EAAY,gBAAAC;AAC9C,MAAkB;AACd,QAAMC,IAAiB,CAACR,EAAME,EAAM,MAAM,IAAI,IAAI,KAC5C,CAACO,GAAeC,CAAgB,IAAIC,EAASH,CA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M,IAAI;AAAA,cAC7B,OAAOO;AAAA,YAAA;AAAA,YAGX,UAAA,gBAAAc,EAAC,OAAA,EAAI,WAAYC,EAAO,OACpB,UAAA;AAAA,cAAA,gBAAAH,EAACnB,EAAM,OAAN,EAAc,GAAGA,EAAM,OAAQ,OAAQ,MAAMc,EAAA,GAAgB;AAAA,cAE5Dd,EAAM,MAAM,eAAe,MACzB,gBAAAmB;AAAA,gBAACK;AAAA,gBAAA;AAAA,kBACG,WAAYF,EAAO;AAAA,kBACnB,MAAK;AAAA,kBACL,MAAK;AAAA,kBACL,SAAU,MAAMR,EAAA;AAAA,gBAAY;AAAA,cAAA;AAAA,YAChC,EAAA,CAER;AAAA,UAAA;AAAA,QAAA;AAAA,QAGJ,gBAAAK;AAAA,UAAC;AAAA,UAAA;AAAA,YACG,WAAYG,EAAO;AAAA,YACnB,cAAW;AAAA,YACX,MAAK;AAAA,YACL,SAAU,MAAMR,EAAA;AAAA,UAAY;AAAA,QAAA;AAAA,MAChC;AAAA,IAAA;AAAA,EAAA,GAGR;AAER;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { ModalObject, ModalSize, OwnModalProps, TFunction } from '../types';
|
|
3
3
|
export declare const useModal: (t: TFunction) => {
|
|
4
|
-
openModal: <T extends unknown>(modal: React.FC<T>, size?: ModalSize,
|
|
4
|
+
openModal: <T extends unknown>(modal: React.FC<T>, size?: ModalSize, showCloser?: boolean) => (props?: OwnModalProps<T>, closeCallback?: () => void) => void;
|
|
5
5
|
modals: ModalObject[];
|
|
6
6
|
setModalDirty: (id: string, isDirty: boolean) => void;
|
|
7
7
|
currentModalId: string;
|
|
@@ -2,7 +2,7 @@ import n, { useEffect as I } from "react";
|
|
|
2
2
|
import { v4 as S } from "uuid";
|
|
3
3
|
import { deletePropertyById as g } from "../utils/delete-property-by-id.js";
|
|
4
4
|
const x = (c) => {
|
|
5
|
-
const [s, l] = n.useState([]), [
|
|
5
|
+
const [s, l] = n.useState([]), [u, M] = n.useState(""), [i, a] = n.useState({}), p = (o) => {
|
|
6
6
|
a((t) => g(t, o)), l((t) => t.filter((e) => e.id !== o));
|
|
7
7
|
}, m = (o) => {
|
|
8
8
|
l((t) => [...t, o]);
|
|
@@ -15,15 +15,15 @@ const x = (c) => {
|
|
|
15
15
|
return I(() => {
|
|
16
16
|
var t;
|
|
17
17
|
const o = (t = [...s].pop()) == null ? void 0 : t.id;
|
|
18
|
-
|
|
18
|
+
M(o || ""), document.body.style.overflow = s.length ? "hidden" : "unset";
|
|
19
19
|
}, [s]), {
|
|
20
|
-
openModal: (o, t = "s", e) => {
|
|
20
|
+
openModal: (o, t = "s", e = !0) => {
|
|
21
21
|
const y = (d, r) => ({
|
|
22
22
|
id: S(),
|
|
23
23
|
modal: o,
|
|
24
24
|
props: {
|
|
25
25
|
size: t,
|
|
26
|
-
|
|
26
|
+
showCloser: e,
|
|
27
27
|
closeCallback: r,
|
|
28
28
|
t: c,
|
|
29
29
|
...d
|
|
@@ -35,7 +35,7 @@ const x = (c) => {
|
|
|
35
35
|
},
|
|
36
36
|
modals: s,
|
|
37
37
|
setModalDirty: f,
|
|
38
|
-
currentModalId:
|
|
38
|
+
currentModalId: u,
|
|
39
39
|
dirtyModals: i,
|
|
40
40
|
closeModal: p
|
|
41
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-modal.js","sources":["../../../src/modal/hooks/use-modal.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { v4 as uuid } from 'uuid';\n\nimport {\n ModalObject, ModalSize, OwnModalProps, TFunction,\n} from '../types';\nimport { deletePropertyById } from '../utils/delete-property-by-id';\n\nexport const useModal = (t: TFunction) => {\n const [modals, setModals] = React.useState<ModalObject[]>([]);\n const [currentModalId, setCurrentModalId] = React.useState<string>('');\n const [dirtyModals, setDirtyModals] = React.useState<Record<string, boolean>>({\n });\n\n const closeModal = (id: string) => {\n setDirtyModals((oldDirtyModals) => deletePropertyById(oldDirtyModals, id));\n setModals((oldModals) => oldModals.filter((modal) => modal.id !== id));\n };\n\n const addModal = (modal: ModalObject) => {\n setModals((oldModals) => [...oldModals, modal]);\n };\n\n const setModalDirty = (id: string, isDirty: boolean) => {\n setDirtyModals((rest) => ({\n ...rest,\n [id]: isDirty,\n }));\n };\n\n useEffect(() => {\n const latestModalId = [...modals].pop()?.id;\n\n setCurrentModalId(latestModalId || '');\n document.body.style.overflow = modals.length ? 'hidden' : 'unset';\n }, [modals]);\n\n const openModal = <T extends unknown>(modal: React.FC<T>, size: ModalSize = 's',
|
|
1
|
+
{"version":3,"file":"use-modal.js","sources":["../../../src/modal/hooks/use-modal.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { v4 as uuid } from 'uuid';\n\nimport {\n ModalObject, ModalSize, OwnModalProps, TFunction,\n} from '../types';\nimport { deletePropertyById } from '../utils/delete-property-by-id';\n\nexport const useModal = (t: TFunction) => {\n const [modals, setModals] = React.useState<ModalObject[]>([]);\n const [currentModalId, setCurrentModalId] = React.useState<string>('');\n const [dirtyModals, setDirtyModals] = React.useState<Record<string, boolean>>({\n });\n\n const closeModal = (id: string) => {\n setDirtyModals((oldDirtyModals) => deletePropertyById(oldDirtyModals, id));\n setModals((oldModals) => oldModals.filter((modal) => modal.id !== id));\n };\n\n const addModal = (modal: ModalObject) => {\n setModals((oldModals) => [...oldModals, modal]);\n };\n\n const setModalDirty = (id: string, isDirty: boolean) => {\n setDirtyModals((rest) => ({\n ...rest,\n [id]: isDirty,\n }));\n };\n\n useEffect(() => {\n const latestModalId = [...modals].pop()?.id;\n\n setCurrentModalId(latestModalId || '');\n document.body.style.overflow = modals.length ? 'hidden' : 'unset';\n }, [modals]);\n\n const openModal = <T extends unknown>(modal: React.FC<T>, size: ModalSize = 's', showCloser = true) => {\n const getModal = (params?: OwnModalProps<T>, closeCallback?: () => void) => {\n const id = uuid();\n\n return {\n id,\n modal,\n props: {\n size,\n showCloser,\n closeCallback,\n t,\n ...params,\n },\n } as unknown as ModalObject;\n };\n\n return (props?: OwnModalProps<T>, closeCallback?: () => void) => {\n addModal(getModal(props, closeCallback));\n };\n };\n\n return {\n openModal, modals, setModalDirty, currentModalId, dirtyModals, closeModal,\n };\n};\n"],"names":["useModal","t","modals","setModals","React","currentModalId","setCurrentModalId","dirtyModals","setDirtyModals","closeModal","id","oldDirtyModals","deletePropertyById","oldModals","modal","addModal","setModalDirty","isDirty","rest","useEffect","latestModalId","_a","size","showCloser","getModal","params","closeCallback","uuid","props"],"mappings":";;;AAQO,MAAMA,IAAW,CAACC,MAAiB;AACtC,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAM,SAAwB,CAAA,CAAE,GACtD,CAACC,GAAgBC,CAAiB,IAAIF,EAAM,SAAiB,EAAE,GAC/D,CAACG,GAAaC,CAAc,IAAIJ,EAAM,SAAkC,CAAA,CAC7E,GAEKK,IAAa,CAACC,MAAe;AAC/B,IAAAF,EAAe,CAACG,MAAmBC,EAAmBD,GAAgBD,CAAE,CAAC,GACzEP,EAAU,CAACU,MAAcA,EAAU,OAAO,CAACC,MAAUA,EAAM,OAAOJ,CAAE,CAAC;AAAA,EACzE,GAEMK,IAAW,CAACD,MAAuB;AACrC,IAAAX,EAAU,CAACU,MAAc,CAAC,GAAGA,GAAWC,CAAK,CAAC;AAAA,EAClD,GAEME,IAAgB,CAACN,GAAYO,MAAqB;AACpD,IAAAT,EAAe,CAACU,OAAU;AAAA,MACtB,GAAGA;AAAA,MACH,CAACR,CAAE,GAAGO;AAAA,IAAA,EACR;AAAA,EACN;AAEA,SAAAE,EAAU,MAAM;;AACZ,UAAMC,KAAgBC,IAAA,CAAC,GAAGnB,CAAM,EAAE,UAAZ,gBAAAmB,EAAmB;AAEzC,IAAAf,EAAkBc,KAAiB,EAAE,GACrC,SAAS,KAAK,MAAM,WAAWlB,EAAO,SAAS,WAAW;AAAA,EAC9D,GAAG,CAACA,CAAM,CAAC,GAwBJ;AAAA,IACH,WAvBc,CAAoBY,GAAoBQ,IAAkB,KAAKC,IAAa,OAAS;AACnG,YAAMC,IAAW,CAACC,GAA2BC,OAGlC;AAAA,QACH,IAHOC,EAAA;AAAA,QAIP,OAAAb;AAAA,QACA,OAAO;AAAA,UACH,MAAAQ;AAAA,UACA,YAAAC;AAAA,UACA,eAAAG;AAAA,UACA,GAAAzB;AAAA,UACA,GAAGwB;AAAA,QAAA;AAAA,MACP;AAIR,aAAO,CAACG,GAA0BF,MAA+B;AAC7D,QAAAX,EAASS,EAASI,GAAOF,CAAa,CAAC;AAAA,MAC3C;AAAA,IACJ;AAAA,IAGe,QAAAxB;AAAA,IAAQ,eAAAc;AAAA,IAAe,gBAAAX;AAAA,IAAgB,aAAAE;AAAA,IAAa,YAAAE;AAAA,EAAA;AAEvE;"}
|
package/dist/modal/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ type ModalProps = {
|
|
|
3
3
|
closeCallback: () => void;
|
|
4
4
|
close: () => void;
|
|
5
5
|
size: ModalSize;
|
|
6
|
-
|
|
6
|
+
showCloser?: boolean;
|
|
7
7
|
t: TFunction;
|
|
8
8
|
} & unknown;
|
|
9
9
|
export type TFunction = (field: string, options?: {
|
|
@@ -19,7 +19,7 @@ export type ModalObject = {
|
|
|
19
19
|
props: ModalProps;
|
|
20
20
|
};
|
|
21
21
|
export type ContextProps = {
|
|
22
|
-
openModal: <T>(modal: React.FC<T>, size?: ModalSize,
|
|
22
|
+
openModal: <T>(modal: React.FC<T>, size?: ModalSize, showCloser?: boolean) => (props?: OwnModalProps<T>, closeCallback?: () => void) => void;
|
|
23
23
|
modals: ModalObject[];
|
|
24
24
|
currentModalId: ModalObject['id'];
|
|
25
25
|
setModalDirty: (id: ModalObject['id'], isDirty: boolean) => void;
|
|
@@ -1,41 +1,43 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { FlexColumns as
|
|
5
|
-
import { SidepanelHeader as
|
|
6
|
-
import { Skeleton as
|
|
1
|
+
import { jsx as e, jsxs as v } from "react/jsx-runtime";
|
|
2
|
+
import N from "react";
|
|
3
|
+
import x from "classnames";
|
|
4
|
+
import { FlexColumns as S } from "../flex-columns/component.js";
|
|
5
|
+
import { SidepanelHeader as g } from "../sidepanel-header/component.js";
|
|
6
|
+
import { Skeleton as y } from "../skeleton/component.js";
|
|
7
7
|
import r from "./index.module.css.js";
|
|
8
|
-
const
|
|
8
|
+
const R = ({
|
|
9
9
|
dataTestId: i,
|
|
10
10
|
title: m,
|
|
11
11
|
loading: t,
|
|
12
12
|
headerRightAddons: a,
|
|
13
13
|
subtitle: l,
|
|
14
14
|
noCloser: s,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
showCloser: n,
|
|
16
|
+
headerBottomAddons: c,
|
|
17
|
+
noStickyFooter: d,
|
|
18
|
+
noStickyHeader: p,
|
|
18
19
|
bottomAddons: o,
|
|
19
|
-
children:
|
|
20
|
-
...
|
|
21
|
-
}) => /* @__PURE__ */ e(
|
|
20
|
+
children: f,
|
|
21
|
+
...h
|
|
22
|
+
}) => /* @__PURE__ */ e(N.Fragment, { children: t ? /* @__PURE__ */ e(S, { className: r.loader, columns: 1, gr: 20, children: new Array(7).fill("").map((j, u) => /* @__PURE__ */ e(y, { animate: !0, visible: !0, className: r.input }, u)) }) : /* @__PURE__ */ v("div", { children: [
|
|
22
23
|
/* @__PURE__ */ e(
|
|
23
|
-
|
|
24
|
+
g,
|
|
24
25
|
{
|
|
25
26
|
title: m,
|
|
26
|
-
className:
|
|
27
|
+
className: p ? void 0 : r.header,
|
|
27
28
|
subtitle: l,
|
|
28
29
|
noCloser: s,
|
|
30
|
+
showCloser: n,
|
|
29
31
|
dataTestId: i,
|
|
30
32
|
rightAddons: a,
|
|
31
|
-
bottomAddons:
|
|
32
|
-
...
|
|
33
|
+
bottomAddons: c,
|
|
34
|
+
...h
|
|
33
35
|
}
|
|
34
36
|
),
|
|
35
|
-
/* @__PURE__ */ e("div", { className: r.content, children:
|
|
36
|
-
o && /* @__PURE__ */ e("div", { className:
|
|
37
|
+
/* @__PURE__ */ e("div", { className: r.content, children: f }),
|
|
38
|
+
o && /* @__PURE__ */ e("div", { className: x(r.footer, { [r.noSticky]: d }), children: o })
|
|
37
39
|
] }) });
|
|
38
40
|
export {
|
|
39
|
-
|
|
41
|
+
R as Sidepanel
|
|
40
42
|
};
|
|
41
43
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../src/sidepanel/component.tsx"],"sourcesContent":["/* eslint-disable react/no-array-index-key */\nimport React from 'react';\nimport classNames from 'classnames';\n\nimport { FlexColumns } from '../flex-columns';\nimport { TFunction } from '../modal';\nimport { SidepanelHeader } from '../sidepanel-header';\nimport { Skeleton } from '../skeleton';\n\nimport styles from './index.module.css';\n\ntype Back = {\n back?: () => void;\n t: TFunction;\n} | {\n back?: never;\n t?: never;\n};\n\nexport type SidepanelProps = {\n title?: string;\n loading?: boolean;\n subtitle?: string;\n headerRightAddons?: React.ReactNode;\n headerBottomAddons?: React.ReactNode;\n bottomAddons?: React.ReactNode;\n dataTestId?: string;\n noCloser?: boolean;\n noStickyFooter?: boolean;\n noStickyHeader?: boolean;\n} & Back;\n\nexport const Sidepanel: React.FC<SidepanelProps> = ({\n dataTestId,\n title,\n loading,\n headerRightAddons,\n subtitle,\n noCloser,\n headerBottomAddons,\n noStickyFooter,\n noStickyHeader,\n bottomAddons,\n children,\n ...props\n}) => (\n <React.Fragment>\n { loading ? (\n <FlexColumns className={ styles.loader } columns={ 1 } gr={ 20 }>\n { new Array(7).fill('').map((_, i) => (\n <Skeleton key={ i } animate={ true } visible={ true } className={ styles.input } />\n )) }\n </FlexColumns>\n ) : (\n <div>\n <SidepanelHeader\n title={ title }\n className={ noStickyHeader ? undefined : styles.header }\n subtitle={ subtitle }\n noCloser={ noCloser }\n dataTestId={ dataTestId }\n rightAddons={ headerRightAddons }\n bottomAddons={ headerBottomAddons }\n { ...props }\n />\n\n <div className={ styles.content }>\n { children }\n </div>\n\n { bottomAddons && (\n <div className={ classNames(styles.footer, { [styles.noSticky]: noStickyFooter }) }>\n { bottomAddons }\n </div>\n ) }\n </div>\n ) }\n </React.Fragment>\n);\n"],"names":["Sidepanel","dataTestId","title","loading","headerRightAddons","subtitle","noCloser","headerBottomAddons","noStickyFooter","noStickyHeader","bottomAddons","children","props","React","FlexColumns","styles","_","i","jsx","Skeleton","SidepanelHeader","classNames"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../src/sidepanel/component.tsx"],"sourcesContent":["/* eslint-disable react/no-array-index-key */\nimport React from 'react';\nimport classNames from 'classnames';\n\nimport { FlexColumns } from '../flex-columns';\nimport { TFunction } from '../modal';\nimport { SidepanelHeader } from '../sidepanel-header';\nimport { Skeleton } from '../skeleton';\n\nimport styles from './index.module.css';\n\ntype Back = {\n back?: () => void;\n t: TFunction;\n} | {\n back?: never;\n t?: never;\n};\n\nexport type SidepanelProps = {\n title?: string;\n loading?: boolean;\n subtitle?: string;\n headerRightAddons?: React.ReactNode;\n headerBottomAddons?: React.ReactNode;\n bottomAddons?: React.ReactNode;\n dataTestId?: string;\n noCloser?: boolean;\n showCloser?: boolean;\n noStickyFooter?: boolean;\n noStickyHeader?: boolean;\n} & Back;\n\nexport const Sidepanel: React.FC<SidepanelProps> = ({\n dataTestId,\n title,\n loading,\n headerRightAddons,\n subtitle,\n noCloser,\n showCloser,\n headerBottomAddons,\n noStickyFooter,\n noStickyHeader,\n bottomAddons,\n children,\n ...props\n}) => (\n <React.Fragment>\n { loading ? (\n <FlexColumns className={ styles.loader } columns={ 1 } gr={ 20 }>\n { new Array(7).fill('').map((_, i) => (\n <Skeleton key={ i } animate={ true } visible={ true } className={ styles.input } />\n )) }\n </FlexColumns>\n ) : (\n <div>\n <SidepanelHeader\n title={ title }\n className={ noStickyHeader ? undefined : styles.header }\n subtitle={ subtitle }\n noCloser={ noCloser }\n showCloser={ showCloser }\n dataTestId={ dataTestId }\n rightAddons={ headerRightAddons }\n bottomAddons={ headerBottomAddons }\n { ...props }\n />\n\n <div className={ styles.content }>\n { children }\n </div>\n\n { bottomAddons && (\n <div className={ classNames(styles.footer, { [styles.noSticky]: noStickyFooter }) }>\n { bottomAddons }\n </div>\n ) }\n </div>\n ) }\n </React.Fragment>\n);\n"],"names":["Sidepanel","dataTestId","title","loading","headerRightAddons","subtitle","noCloser","showCloser","headerBottomAddons","noStickyFooter","noStickyHeader","bottomAddons","children","props","React","FlexColumns","styles","_","i","jsx","Skeleton","SidepanelHeader","classNames"],"mappings":";;;;;;;AAiCO,MAAMA,IAAsC,CAAC;AAAA,EAChD,YAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,mBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACP,wBACKC,EAAM,UAAN,EACK,UAAAX,sBACGY,GAAA,EAAY,WAAYC,EAAO,QAAS,SAAU,GAAI,IAAK,IACtD,UAAA,IAAI,MAAM,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,CAACC,GAAGC,MAC5B,gBAAAC,EAACC,GAAA,EAAmB,SAAU,IAAO,SAAU,IAAO,WAAYJ,EAAO,MAAA,GAAzDE,CAAiE,CACpF,EAAA,CACL,sBAEC,OAAA,EACG,UAAA;AAAA,EAAA,gBAAAC;AAAA,IAACE;AAAA,IAAA;AAAA,MACG,OAAAnB;AAAA,MACA,WAAYQ,IAAiB,SAAYM,EAAO;AAAA,MAChD,UAAAX;AAAA,MACA,UAAAC;AAAA,MACA,YAAAC;AAAA,MACA,YAAAN;AAAA,MACA,aAAcG;AAAA,MACd,cAAeI;AAAA,MACb,GAAGK;AAAA,IAAA;AAAA,EAAA;AAAA,EAGT,gBAAAM,EAAC,OAAA,EAAI,WAAYH,EAAO,SAClB,UAAAJ,GACN;AAAA,EAEED,KACE,gBAAAQ,EAAC,OAAA,EAAI,WAAYG,EAAWN,EAAO,QAAQ,EAAE,CAACA,EAAO,QAAQ,GAAGP,EAAA,CAAgB,GAC1E,UAAAE,EAAA,CACN;AAAA,EAAA,CAER,EAAA,CAER;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsxs as a, jsx as r } from "react/jsx-runtime";
|
|
2
2
|
import p from "classnames";
|
|
3
|
-
import { BackButton as
|
|
4
|
-
import { FlexColumns as
|
|
3
|
+
import { BackButton as g } from "../back-button/component.js";
|
|
4
|
+
import { FlexColumns as w } from "../flex-columns/component.js";
|
|
5
5
|
import { Typography as t } from "../typography/component.js";
|
|
6
6
|
import e from "./index.module.css.js";
|
|
7
|
-
const h = ({ title: m, subtitle: l }) => /* @__PURE__ */ a(
|
|
7
|
+
const h = ({ title: m, subtitle: l }) => /* @__PURE__ */ a(w, { columns: 1, gr: 4, className: e.title, children: [
|
|
8
8
|
/* @__PURE__ */ r(t.Title, { color: "primary", tag: "div", view: "small", weight: "bold", children: m }),
|
|
9
9
|
l && /* @__PURE__ */ r(t.Text, { view: "title", weight: "regular", color: "secondary", children: l })
|
|
10
|
-
] }),
|
|
10
|
+
] }), u = ({
|
|
11
11
|
className: m,
|
|
12
12
|
dataTestId: l,
|
|
13
13
|
title: o,
|
|
@@ -16,7 +16,8 @@ const h = ({ title: m, subtitle: l }) => /* @__PURE__ */ a(g, { columns: 1, gr:
|
|
|
16
16
|
subtitle: c,
|
|
17
17
|
t: d,
|
|
18
18
|
bottomAddons: n,
|
|
19
|
-
noCloser:
|
|
19
|
+
noCloser: f,
|
|
20
|
+
showCloser: v
|
|
20
21
|
}) => /* @__PURE__ */ a(
|
|
21
22
|
"div",
|
|
22
23
|
{
|
|
@@ -24,9 +25,9 @@ const h = ({ title: m, subtitle: l }) => /* @__PURE__ */ a(g, { columns: 1, gr:
|
|
|
24
25
|
className: p(e.wrapper, m),
|
|
25
26
|
children: [
|
|
26
27
|
(i || o || s) && /* @__PURE__ */ a("div", { className: e.heading, children: [
|
|
27
|
-
i && d && /* @__PURE__ */ r(
|
|
28
|
+
i && d && /* @__PURE__ */ r(g, { onClick: i, t: d }),
|
|
28
29
|
!i && o && /* @__PURE__ */ r(h, { title: o, subtitle: c }),
|
|
29
|
-
s && /* @__PURE__ */ r("div", { className: p(e.rightAddons, { [e.noCloser]: !!v }), children: s })
|
|
30
|
+
s && /* @__PURE__ */ r("div", { className: p(e.rightAddons, { [e.noCloser]: !!f || v === !1 }), children: s })
|
|
30
31
|
] }),
|
|
31
32
|
!!i && o && /* @__PURE__ */ r(h, { title: o, subtitle: c }),
|
|
32
33
|
!!n && /* @__PURE__ */ r("div", { className: e.bottomAddons, children: n })
|
|
@@ -34,6 +35,6 @@ const h = ({ title: m, subtitle: l }) => /* @__PURE__ */ a(g, { columns: 1, gr:
|
|
|
34
35
|
}
|
|
35
36
|
);
|
|
36
37
|
export {
|
|
37
|
-
|
|
38
|
+
u as SidepanelHeader
|
|
38
39
|
};
|
|
39
40
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../src/sidepanel-header/component.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\n\nimport { BackButton } from '../back-button';\nimport { FlexColumns } from '../flex-columns';\nimport { TFunction } from '../modal';\nimport { Typography } from '../typography';\n\nimport styles from './index.module.css';\n\ntype Back = {\n back?: () => void;\n t: TFunction;\n} | {\n back?: never;\n t?: never;\n};\n\nexport type SidepanelHeaderProps = {\n /**\n * Кастомный класс\n */\n className?: string;\n\n /**\n * title\n */\n title?: string;\n\n /**\n * rightAddons - слот слева\n */\n rightAddons?: React.ReactNode;\n\n /**\n * bottomAddons - слот внизу\n */\n bottomAddons?: React.ReactNode;\n\n /**\n * Id компонента для тестов\n */\n noCloser?: boolean;\n dataTestId?: string;\n\n subtitle?: string;\n} & Back;\n\nconst Title = ({ title, subtitle }: {title: string; subtitle?: string}) => (\n <FlexColumns columns={ 1 } gr={ 4 } className={ styles.title }>\n\n <Typography.Title color=\"primary\" tag=\"div\" view=\"small\" weight=\"bold\">\n { title }\n </Typography.Title>\n\n { subtitle && (\n <Typography.Text view=\"title\" weight=\"regular\" color=\"secondary\">\n { subtitle }\n </Typography.Text>\n ) }\n\n </FlexColumns>\n);\n\nexport const SidepanelHeader: React.FC<SidepanelHeaderProps> = ({\n className,\n dataTestId,\n title,\n rightAddons,\n back,\n subtitle,\n t,\n bottomAddons,\n noCloser,\n}) => (\n <div\n data-test-id={ dataTestId }\n className={ cn(styles.wrapper, className) }\n >\n { (back || title || rightAddons) && (\n <div className={ styles.heading }>\n { back && t && (\n <BackButton onClick={ back } t={ t } />\n ) }\n\n { !back && title && (\n <Title title={ title } subtitle={ subtitle } />\n ) }\n\n { rightAddons && <div className={ cn(styles.rightAddons, { [styles.noCloser]: !!noCloser }) }>{ rightAddons }</div> }\n </div>\n ) }\n\n { !!back && title && (\n <Title title={ title } subtitle={ subtitle } />\n ) }\n\n { !!bottomAddons && <div className={ styles.bottomAddons }>{ bottomAddons }</div> }\n\n </div>\n);\n"],"names":["Title","title","subtitle","jsxs","FlexColumns","styles","jsx","Typography","SidepanelHeader","className","dataTestId","rightAddons","back","t","bottomAddons","noCloser","cn","BackButton"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../src/sidepanel-header/component.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\n\nimport { BackButton } from '../back-button';\nimport { FlexColumns } from '../flex-columns';\nimport { TFunction } from '../modal';\nimport { Typography } from '../typography';\n\nimport styles from './index.module.css';\n\ntype Back = {\n back?: () => void;\n t: TFunction;\n} | {\n back?: never;\n t?: never;\n};\n\nexport type SidepanelHeaderProps = {\n /**\n * Кастомный класс\n */\n className?: string;\n\n /**\n * title\n */\n title?: string;\n\n /**\n * rightAddons - слот слева\n */\n rightAddons?: React.ReactNode;\n\n /**\n * bottomAddons - слот внизу\n */\n bottomAddons?: React.ReactNode;\n\n /**\n * Id компонента для тестов\n */\n noCloser?: boolean;\n showCloser?: boolean;\n dataTestId?: string;\n\n subtitle?: string;\n} & Back;\n\nconst Title = ({ title, subtitle }: {title: string; subtitle?: string}) => (\n <FlexColumns columns={ 1 } gr={ 4 } className={ styles.title }>\n\n <Typography.Title color=\"primary\" tag=\"div\" view=\"small\" weight=\"bold\">\n { title }\n </Typography.Title>\n\n { subtitle && (\n <Typography.Text view=\"title\" weight=\"regular\" color=\"secondary\">\n { subtitle }\n </Typography.Text>\n ) }\n\n </FlexColumns>\n);\n\nexport const SidepanelHeader: React.FC<SidepanelHeaderProps> = ({\n className,\n dataTestId,\n title,\n rightAddons,\n back,\n subtitle,\n t,\n bottomAddons,\n noCloser,\n showCloser,\n}) => (\n <div\n data-test-id={ dataTestId }\n className={ cn(styles.wrapper, className) }\n >\n { (back || title || rightAddons) && (\n <div className={ styles.heading }>\n { back && t && (\n <BackButton onClick={ back } t={ t } />\n ) }\n\n { !back && title && (\n <Title title={ title } subtitle={ subtitle } />\n ) }\n\n { rightAddons && <div className={ cn(styles.rightAddons, { [styles.noCloser]: !!noCloser || showCloser === false }) }>{ rightAddons }</div> }\n </div>\n ) }\n\n { !!back && title && (\n <Title title={ title } subtitle={ subtitle } />\n ) }\n\n { !!bottomAddons && <div className={ styles.bottomAddons }>{ bottomAddons }</div> }\n\n </div>\n);\n"],"names":["Title","title","subtitle","jsxs","FlexColumns","styles","jsx","Typography","SidepanelHeader","className","dataTestId","rightAddons","back","t","bottomAddons","noCloser","showCloser","cn","BackButton"],"mappings":";;;;;;AAiDA,MAAMA,IAAQ,CAAC,EAAE,OAAAC,GAAO,UAAAC,QACpB,gBAAAC,EAACC,GAAA,EAAY,SAAU,GAAI,IAAK,GAAI,WAAYC,EAAO,OAEnD,UAAA;AAAA,EAAA,gBAAAC,EAACC,EAAW,OAAX,EAAiB,O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var(--color-bg-primary);box-sizing:border-box}.heading_XGDy{display:flex;justify-content:space-between;min-height:48px}.title_jwxc,.bottomAddons_3yzd{padding-bottom:8px;padding-top:8px}.rightAddons_aZFa{margin-right:48px;height:48px;display:flex;align-items:center}.noCloser_O7u0{margin-right:0}@media(max-width:823px){.wrapper_QxqD{padding:16px 16px 12px!important}}
|
|
1
|
+
.wrapper_QxqD{padding:28px 32px 12px;background-color:var(--color-bg-primary);box-sizing:border-box}.heading_XGDy{display:flex;justify-content:space-between;min-height:48px}.title_jwxc,.bottomAddons_3yzd{padding-bottom:8px;padding-top:8px}.rightAddons_aZFa{margin-right:48px;height:48px;display:flex;align-items:center}.noCloser_O7u0{margin-right:0!important}@media(max-width:823px){.wrapper_QxqD{padding:16px 16px 12px!important}}
|