@alphakits/ui 2.0.12 → 2.1.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/dist/badge/component.d.ts +1 -1
- package/dist/box/component.d.ts +2 -2
- package/dist/calendar/typings.d.ts +42 -0
- package/dist/calendar/use-calendar.d.ts +2 -40
- package/dist/calendar/use-calendar.js +1 -1
- package/dist/calendar/use-calendar.js.map +1 -1
- package/dist/calendar-input/component.d.ts +1 -1
- package/dist/checkbox/component.js +12 -15
- package/dist/checkbox/component.js.map +1 -1
- package/dist/checkbox-lists/component.d.ts +2 -2
- package/dist/collapsable-row/addons.d.ts +3 -3
- package/dist/copy-button/component.d.ts +2 -1
- package/dist/date-switcher/component.d.ts +2 -2
- package/dist/flex/component.d.ts +2 -2
- package/dist/footer/component.js +32 -38
- package/dist/footer/component.js.map +1 -1
- package/dist/footer/index.module.css +1 -1
- package/dist/footer/index.module.css.js +16 -14
- package/dist/footer/index.module.css.js.map +1 -1
- package/dist/form/component.d.ts +2 -2
- package/dist/form/templates/base-form/index.d.ts +1 -1
- package/dist/form/templates/rest-form/form.d.ts +2 -1
- package/dist/form/templates/rest-form/index.d.ts +2 -2
- package/dist/form/templates/rest-form/index.js.map +1 -1
- package/dist/grid/component.d.ts +20 -5
- package/dist/grid/component.js +49 -7
- package/dist/grid/component.js.map +1 -1
- package/dist/grid/index.js +4 -2
- package/dist/grid/index.module.css +1 -0
- package/dist/grid/index.module.css.js +11 -0
- package/dist/grid/{row/index.module.css.js.map → index.module.css.js.map} +1 -1
- package/dist/hooks/useClickOutside/index.d.ts +1 -1
- package/dist/hooks/useClickOutside/index.js.map +1 -1
- package/dist/hooks/useFocus/index.d.ts +1 -1
- package/dist/hooks/useFocus/index.js.map +1 -1
- package/dist/hooks/usePrevious/index.js +3 -3
- package/dist/hooks/usePrevious/index.js.map +1 -1
- package/dist/image/use-image-render-component.d.ts +1 -1
- package/dist/image-gallery/component.d.ts +2 -2
- package/dist/index.js +254 -252
- package/dist/input/component.js +56 -60
- package/dist/input/component.js.map +1 -1
- package/dist/input/index.module.css +1 -1
- package/dist/input-autocomplete/autocomplete-field/index.d.ts +2 -1
- package/dist/input-autocomplete/autocomplete-field/index.js.map +1 -1
- package/dist/input-autocomplete/component.d.ts +3 -3
- package/dist/input-ghost/component.d.ts +1 -1
- package/dist/masked-input/component.d.ts +1 -1
- package/dist/menu/component.d.ts +3 -2
- package/dist/menu/component.js.map +1 -1
- package/dist/menu/hooks/use-menu.d.ts +1 -1
- package/dist/menu/hooks/use-menu.js +6 -6
- package/dist/menu/hooks/use-menu.js.map +1 -1
- package/dist/modal/components/modals/modal.d.ts +2 -1
- package/dist/notification/component.js +33 -37
- package/dist/notification/component.js.map +1 -1
- package/dist/notification/utils/index.d.ts +1 -1
- package/dist/notification/utils/index.js.map +1 -1
- package/dist/page-loading/component.d.ts +2 -2
- package/dist/picker-button/component.d.ts +1 -1
- package/dist/picker-button/field/Component.d.ts +2 -1
- package/dist/portal/utils.d.ts +1 -1
- package/dist/portal/utils.js.map +1 -1
- package/dist/radio-groups/component.d.ts +2 -2
- package/dist/select/components/arrow/component.d.ts +2 -1
- package/dist/select/components/base-select/component.js +262 -259
- package/dist/select/components/base-select/component.js.map +1 -1
- package/dist/select/components/checkmark/component.d.ts +2 -1
- package/dist/select/components/field/component.d.ts +2 -1
- package/dist/select/components/field/component.js.map +1 -1
- package/dist/select/components/native-select/component.js.map +1 -1
- package/dist/select/components/optgroup/component.d.ts +2 -1
- package/dist/select/components/select-search/index.d.ts +1 -1
- package/dist/select/components/virtual-options-list/component.d.ts +2 -1
- package/dist/select/presets/use-lazy-loading/index.d.ts +4 -4
- package/dist/select/presets/use-lazy-loading/index.js +20 -20
- package/dist/select/presets/use-lazy-loading/index.js.map +1 -1
- package/dist/select/presets/use-select-with-loading/hook.d.ts +3 -2
- package/dist/select/presets/use-select-with-loading/hook.js +7 -7
- package/dist/select/presets/use-select-with-loading/hook.js.map +1 -1
- package/dist/select/typings.d.ts +1 -1
- package/dist/select/utils.d.ts +2 -2
- package/dist/select/utils.js +17 -15
- package/dist/select/utils.js.map +1 -1
- package/dist/sidepanel/component.d.ts +1 -0
- package/dist/sidepanel/component.js.map +1 -1
- package/dist/space/Item.d.ts +1 -1
- package/dist/status/component.d.ts +2 -1
- package/dist/status/component.js.map +1 -1
- package/dist/switch/component.d.ts +1 -1
- package/dist/table/components/cells/index.d.ts +2 -1
- package/dist/table/components/empty-list/index.d.ts +2 -2
- package/dist/table/components/error/index.d.ts +2 -2
- package/dist/table/components/loading/index.d.ts +1 -1
- package/dist/table/components/table-header/index.d.ts +1 -1
- package/dist/table/components/table-header/index.js.map +1 -1
- package/dist/table/table.d.ts +2 -2
- package/dist/table/table.js.map +1 -1
- package/dist/table/utils/get-tags.d.ts +3 -2
- package/dist/table/utils/get-tags.js.map +1 -1
- package/dist/table/utils/prepare-rows.d.ts +2 -1
- package/dist/table/utils/prepare-rows.js.map +1 -1
- package/dist/textarea/component.js +68 -75
- package/dist/textarea/component.js.map +1 -1
- package/dist/theme-provider/component.d.ts +1 -0
- package/dist/theme-provider/component.js.map +1 -1
- package/dist/toast/component.d.ts +1 -1
- package/dist/toast-notifier/component.js +39 -40
- package/dist/toast-notifier/component.js.map +1 -1
- package/dist/tooltip/component.d.ts +2 -2
- package/dist/tooltip/component.js +4 -4
- package/dist/tooltip/component.js.map +1 -1
- package/dist/tooltip/node-resolver.d.ts +26 -0
- package/dist/tooltip/node-resolver.js +14 -0
- package/dist/tooltip/node-resolver.js.map +1 -0
- package/dist/typography/title/component.d.ts +2 -2
- package/dist/with-suffix/component.d.ts +1 -1
- package/package.json +8 -12
- package/dist/calendar/typings.js +0 -2
- package/dist/calendar/typings.js.map +0 -1
- package/dist/grid/col/component.d.ts +0 -52
- package/dist/grid/col/component.js +0 -39
- package/dist/grid/col/component.js.map +0 -1
- package/dist/grid/col/index.d.ts +0 -1
- package/dist/grid/col/index.js +0 -5
- package/dist/grid/col/index.js.map +0 -1
- package/dist/grid/col/index.module.css +0 -1
- package/dist/grid/col/index.module.css.js +0 -519
- package/dist/grid/col/index.module.css.js.map +0 -1
- package/dist/grid/gutters.module.css +0 -1
- package/dist/grid/gutters.module.css.js +0 -50
- package/dist/grid/gutters.module.css.js.map +0 -1
- package/dist/grid/row/component.d.ts +0 -41
- package/dist/grid/row/component.js +0 -43
- package/dist/grid/row/component.js.map +0 -1
- package/dist/grid/row/index.d.ts +0 -1
- package/dist/grid/row/index.js +0 -5
- package/dist/grid/row/index.js.map +0 -1
- package/dist/grid/row/index.module.css +0 -1
- package/dist/grid/row/index.module.css.js +0 -25
- package/dist/grid/typings.d.ts +0 -15
- package/dist/grid/typings.js +0 -2
- package/dist/grid/typings.js.map +0 -1
- package/dist/grid/utils/index.d.ts +0 -2
- package/dist/grid/utils/index.js +0 -31
- package/dist/grid/utils/index.js.map +0 -1
- package/dist/select/typings.js +0 -2
- package/dist/select/typings.js.map +0 -1
package/dist/input/component.js
CHANGED
|
@@ -1,143 +1,139 @@
|
|
|
1
1
|
import { jsx as a, jsxs as et } from "react/jsx-runtime";
|
|
2
|
-
import st, { useRef as ot, useState as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { Button as
|
|
2
|
+
import st, { useRef as ot, useState as F, useCallback as l, Fragment as at } from "react";
|
|
3
|
+
import nt from "react-merge-refs";
|
|
4
|
+
import I from "classnames";
|
|
5
|
+
import { Button as rt } from "../button/component.js";
|
|
6
6
|
import { FormControl as it } from "../form-control/component.js";
|
|
7
7
|
import { useFocus as ct } from "../hooks/useFocus/index.js";
|
|
8
8
|
import s from "./index.module.css.js";
|
|
9
|
-
const
|
|
9
|
+
const Vt = st.forwardRef(
|
|
10
10
|
({
|
|
11
|
-
size:
|
|
11
|
+
size: k = "m",
|
|
12
12
|
type: v = "text",
|
|
13
13
|
block: C = !1,
|
|
14
14
|
bottomAddons: j,
|
|
15
15
|
dataTestId: w,
|
|
16
|
-
clear:
|
|
17
|
-
disabled:
|
|
16
|
+
clear: S = !1,
|
|
17
|
+
disabled: n,
|
|
18
18
|
error: u,
|
|
19
|
-
success:
|
|
20
|
-
required:
|
|
19
|
+
success: N,
|
|
20
|
+
required: y,
|
|
21
21
|
hint: A,
|
|
22
22
|
className: L,
|
|
23
|
-
fieldClassName:
|
|
24
|
-
inputClassName:
|
|
25
|
-
labelClassName:
|
|
26
|
-
addonsClassName:
|
|
27
|
-
focusedClassName:
|
|
28
|
-
filledClassName:
|
|
29
|
-
label:
|
|
30
|
-
maxLength:
|
|
31
|
-
leftAddons:
|
|
23
|
+
fieldClassName: q,
|
|
24
|
+
inputClassName: z,
|
|
25
|
+
labelClassName: D,
|
|
26
|
+
addonsClassName: E,
|
|
27
|
+
focusedClassName: G,
|
|
28
|
+
filledClassName: H,
|
|
29
|
+
label: r,
|
|
30
|
+
maxLength: J = 100,
|
|
31
|
+
leftAddons: K,
|
|
32
32
|
onFocus: m,
|
|
33
33
|
onBlur: p,
|
|
34
34
|
onChange: d,
|
|
35
35
|
onClear: h,
|
|
36
|
-
onClick:
|
|
37
|
-
onMouseDown:
|
|
36
|
+
onClick: M,
|
|
37
|
+
onMouseDown: P,
|
|
38
38
|
onMouseUp: Q,
|
|
39
|
-
rightAddons:
|
|
39
|
+
rightAddons: R,
|
|
40
40
|
value: g,
|
|
41
41
|
defaultValue: T,
|
|
42
42
|
wrapperRef: U,
|
|
43
43
|
readOnly: i,
|
|
44
44
|
...W
|
|
45
45
|
}, X) => {
|
|
46
|
-
const e = g === void 0, c = ot(null), [Y] = ct(c, "keyboard"), [o,
|
|
46
|
+
const e = g === void 0, c = ot(null), [Y] = ct(c, "keyboard"), [o, b] = F(!1), [x, B] = F(T || ""), V = !!(e ? x : g), f = S && V && !n && !i, Z = l(
|
|
47
47
|
(t) => {
|
|
48
|
-
i ||
|
|
48
|
+
i || b(!0), m && m(t);
|
|
49
49
|
},
|
|
50
50
|
[m, i]
|
|
51
|
-
), _ =
|
|
51
|
+
), _ = l(
|
|
52
52
|
(t) => {
|
|
53
|
-
|
|
53
|
+
b(!1), p && p(t);
|
|
54
54
|
},
|
|
55
55
|
[p]
|
|
56
|
-
), $ =
|
|
56
|
+
), $ = l(
|
|
57
57
|
(t) => {
|
|
58
|
-
d && d(t, { value: t.target.value }), e &&
|
|
58
|
+
d && d(t, { value: t.target.value }), e && B(t.target.value);
|
|
59
59
|
},
|
|
60
60
|
[d, e]
|
|
61
|
-
), O =
|
|
61
|
+
), O = l(
|
|
62
62
|
(t) => {
|
|
63
|
-
|
|
63
|
+
f && (e && B(""), h && h(t), c.current && !o && c.current.focus());
|
|
64
64
|
},
|
|
65
|
-
[
|
|
66
|
-
), tt = () => (
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
[f, o, h, e]
|
|
66
|
+
), tt = () => (f || R || N) && /* @__PURE__ */ et(at, { children: [
|
|
67
|
+
f && /* @__PURE__ */ a(
|
|
68
|
+
rt,
|
|
69
69
|
{
|
|
70
70
|
type: "button",
|
|
71
71
|
view: "ghost",
|
|
72
|
-
disabled:
|
|
72
|
+
disabled: n,
|
|
73
73
|
"aria-label": "Очистить",
|
|
74
74
|
className: s.clearButton,
|
|
75
75
|
onClick: O,
|
|
76
76
|
children: /* @__PURE__ */ a("span", { className: s.clearIcon })
|
|
77
77
|
}
|
|
78
78
|
),
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
N && !u && /* @__PURE__ */ a("span", { className: s.successIcon }),
|
|
80
|
+
R
|
|
81
81
|
] });
|
|
82
82
|
return /* @__PURE__ */ a(
|
|
83
83
|
it,
|
|
84
84
|
{
|
|
85
85
|
ref: U,
|
|
86
|
-
className:
|
|
87
|
-
fieldClassName:
|
|
86
|
+
className: I(L, o && G, V && H),
|
|
87
|
+
fieldClassName: I(q, {
|
|
88
88
|
[s.focusVisible]: Y
|
|
89
89
|
}),
|
|
90
|
-
labelClassName:
|
|
91
|
-
addonsClassName:
|
|
92
|
-
size:
|
|
90
|
+
labelClassName: D,
|
|
91
|
+
addonsClassName: E,
|
|
92
|
+
size: k,
|
|
93
93
|
block: C,
|
|
94
|
-
required:
|
|
95
|
-
disabled:
|
|
94
|
+
required: y,
|
|
95
|
+
disabled: n,
|
|
96
96
|
filled: V || o,
|
|
97
97
|
focused: o,
|
|
98
98
|
error: u,
|
|
99
|
-
label:
|
|
99
|
+
label: r,
|
|
100
100
|
hint: A,
|
|
101
|
-
leftAddons:
|
|
101
|
+
leftAddons: K,
|
|
102
102
|
rightAddons: tt(),
|
|
103
103
|
bottomAddons: j,
|
|
104
|
-
onClick:
|
|
105
|
-
onMouseDown:
|
|
104
|
+
onClick: M,
|
|
105
|
+
onMouseDown: P,
|
|
106
106
|
onMouseUp: Q,
|
|
107
107
|
children: /* @__PURE__ */ a(
|
|
108
108
|
"input",
|
|
109
109
|
{
|
|
110
110
|
...W,
|
|
111
|
-
className:
|
|
111
|
+
className: I(
|
|
112
112
|
s.input,
|
|
113
113
|
{
|
|
114
|
-
[s.hasLabel]:
|
|
114
|
+
[s.hasLabel]: r
|
|
115
115
|
},
|
|
116
|
-
|
|
116
|
+
z
|
|
117
117
|
),
|
|
118
|
-
disabled:
|
|
118
|
+
disabled: n,
|
|
119
119
|
onBlur: _,
|
|
120
120
|
onFocus: Z,
|
|
121
121
|
onChange: $,
|
|
122
|
-
maxLength:
|
|
123
|
-
ref:
|
|
122
|
+
maxLength: J,
|
|
123
|
+
ref: nt([X, c]),
|
|
124
124
|
type: v,
|
|
125
125
|
value: e ? x : g,
|
|
126
126
|
readOnly: i,
|
|
127
127
|
"data-test-id": w,
|
|
128
128
|
"data-error": !!u,
|
|
129
|
-
"aria-label": typeof
|
|
129
|
+
"aria-label": typeof r == "string" ? r : void 0
|
|
130
130
|
}
|
|
131
131
|
)
|
|
132
132
|
}
|
|
133
133
|
);
|
|
134
134
|
}
|
|
135
135
|
);
|
|
136
|
-
lt.defaultProps = {
|
|
137
|
-
type: "text",
|
|
138
|
-
block: !1
|
|
139
|
-
};
|
|
140
136
|
export {
|
|
141
|
-
|
|
137
|
+
Vt as Input
|
|
142
138
|
};
|
|
143
139
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../src/input/component.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n Fragment,\n InputHTMLAttributes,\n MouseEvent,\n useCallback,\n useRef,\n useState,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport cn from 'classnames';\n\nimport { Button } from '../button';\nimport { FormControl } from '../form-control';\nimport { useFocus } from '../hooks/useFocus';\n\nimport styles from './index.module.css';\n\nexport type InputProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'size' | 'type' | 'value' | 'defaultValue' | 'onChange' | 'onClick' | 'onMouseDown'\n> & {\n /**\n * Значение поля ввода\n */\n value?: string;\n\n /**\n * Начальное значение поля\n */\n defaultValue?: string;\n\n /**\n * Растягивает компонент на ширину контейнера\n */\n block?: boolean;\n\n /**\n * required - индикатор * лейбла для обязательного заполнения поля\n */\n required?: boolean;\n\n /**\n * Крестик для очистки поля\n */\n clear?: boolean;\n\n /**\n * Размер компонента\n */\n size?: 's' | 'm' | 'l';\n\n /**\n * Отображение ошибки\n */\n error?: string | boolean;\n\n /**\n * Отображение иконки успеха\n */\n success?: boolean;\n\n /**\n * Текст подсказки\n */\n hint?: string;\n\n /**\n * Лейбл компонента\n */\n label?: React.ReactNode;\n\n /**\n * Атрибут type\n */\n type?: 'number' | 'card' | 'email' | 'money' | 'password' | 'tel' | 'text';\n\n /**\n * Ref для обертки input\n */\n wrapperRef?: React.Ref<HTMLDivElement>;\n\n /**\n * Слот слева\n */\n leftAddons?: React.ReactNode;\n\n /**\n * Слот справа\n */\n rightAddons?: React.ReactNode;\n\n /**\n * Слот под инпутом\n */\n bottomAddons?: React.ReactNode;\n\n /**\n * Дополнительный класс\n */\n className?: string;\n\n /**\n * Дополнительный класс для поля\n */\n fieldClassName?: string;\n\n /**\n * Дополнительный класс инпута\n */\n inputClassName?: string;\n\n /**\n * Дополнительный класс для лейбла\n */\n labelClassName?: string;\n\n /**\n * Дополнительный класс для аддонов\n */\n addonsClassName?: string;\n\n /**\n * Класс, который будет установлен при фокусе\n */\n focusedClassName?: string;\n\n /**\n * Класс, который будет установлен, если в поле есть значение\n */\n filledClassName?: string;\n\n /**\n * Обработчик поля ввода\n */\n onChange?: (event: ChangeEvent<HTMLInputElement>, payload: { value: string }) => void;\n\n /**\n * Обработчик нажатия на кнопку очистки\n */\n onClear?: (event: MouseEvent<HTMLButtonElement>) => void;\n\n /**\n * Обработчик клика по полю\n */\n onClick?: (event: MouseEvent<HTMLDivElement>) => void;\n\n /**\n * Обработчик MouseDown по полю\n */\n onMouseDown?: (event: MouseEvent<HTMLDivElement>) => void;\n\n /**\n * Обработчик MouseUp по полю\n */\n onMouseUp?: (event: MouseEvent<HTMLDivElement>) => void;\n\n /**\n * Идентификатор для систем автоматизированного тестирования\n */\n dataTestId?: string;\n};\n\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(\n (\n {\n size = 'm',\n type = 'text',\n block = false,\n bottomAddons,\n dataTestId,\n clear = false,\n disabled,\n error,\n success,\n required,\n hint,\n className,\n fieldClassName,\n inputClassName,\n labelClassName,\n addonsClassName,\n focusedClassName,\n filledClassName,\n label,\n maxLength = 100,\n leftAddons,\n onFocus,\n onBlur,\n onChange,\n onClear,\n onClick,\n onMouseDown,\n onMouseUp,\n rightAddons,\n value,\n defaultValue,\n wrapperRef,\n readOnly,\n ...restProps\n },\n ref,\n ) => {\n const uncontrolled = value === undefined;\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const [focusVisible] = useFocus(inputRef, 'keyboard');\n\n const [focused, setFocused] = useState(false);\n const [stateValue, setStateValue] = useState(defaultValue || '');\n\n const filled = Boolean(uncontrolled ? stateValue : value);\n // отображаем крестик только для заполненного и активного инпута\n const clearButtonVisible = clear && filled && !disabled && !readOnly;\n\n const handleInputFocus = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n if (!readOnly) {\n setFocused(true);\n }\n\n if (onFocus) {\n onFocus(event);\n }\n },\n [onFocus, readOnly],\n );\n\n const handleInputBlur = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n setFocused(false);\n\n if (onBlur) {\n onBlur(event);\n }\n },\n [onBlur],\n );\n\n const handleInputChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n if (onChange) {\n onChange(event, { value: event.target.value });\n }\n\n if (uncontrolled) {\n setStateValue(event.target.value);\n }\n },\n [onChange, uncontrolled],\n );\n\n const handleClear = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n if (!clearButtonVisible) return;\n\n if (uncontrolled) {\n setStateValue('');\n }\n\n if (onClear) {\n onClear(event);\n }\n\n if (inputRef.current && !focused) {\n inputRef.current.focus();\n }\n },\n [clearButtonVisible, focused, onClear, uncontrolled],\n );\n\n const renderRightAddons = () => {\n const addonsVisible = clearButtonVisible || rightAddons || success;\n\n return (\n addonsVisible && (\n <Fragment>\n { clearButtonVisible && (\n <Button\n type=\"button\"\n view=\"ghost\"\n disabled={ disabled }\n aria-label=\"Очистить\"\n className={ styles.clearButton }\n onClick={ handleClear }\n >\n <span className={ styles.clearIcon } />\n </Button>\n ) }\n { success && !error && <span className={ styles.successIcon } /> }\n { rightAddons }\n </Fragment>\n )\n );\n };\n\n return (\n <FormControl\n ref={ wrapperRef }\n className={ cn(className, focused && focusedClassName, filled && filledClassName) }\n fieldClassName={ cn(fieldClassName, {\n [styles.focusVisible]: focusVisible,\n }) }\n labelClassName={ labelClassName }\n addonsClassName={ addonsClassName }\n size={ size }\n block={ block }\n required={ required }\n disabled={ disabled }\n filled={ filled || focused }\n focused={ focused }\n error={ error }\n label={ label }\n hint={ hint }\n leftAddons={ leftAddons }\n rightAddons={ renderRightAddons() }\n bottomAddons={ bottomAddons }\n onClick={ onClick }\n onMouseDown={ onMouseDown }\n onMouseUp={ onMouseUp }\n >\n <input\n { ...restProps }\n className={ cn(\n styles.input,\n {\n [styles.hasLabel]: label,\n },\n inputClassName,\n ) }\n disabled={ disabled }\n onBlur={ handleInputBlur }\n onFocus={ handleInputFocus }\n onChange={ handleInputChange }\n maxLength={ maxLength }\n ref={ mergeRefs([ref, inputRef]) }\n type={ type }\n value={ uncontrolled ? stateValue : value }\n readOnly={ readOnly }\n data-test-id={ dataTestId }\n data-error={ !!error }\n aria-label={ typeof label === 'string' ? label : undefined }\n />\n </FormControl>\n );\n },\n);\n\n/**\n * Для отображения в сторибуке\n */\nInput.defaultProps = {\n type: 'text',\n block: false,\n};\n"],"names":["Input","React","size","type","block","bottomAddons","dataTestId","clear","disabled","error","success","required","hint","className","fieldClassName","inputClassName","labelClassName","addonsClassName","focusedClassName","filledClassName","label","maxLength","leftAddons","onFocus","onBlur","onChange","onClear","onClick","onMouseDown","onMouseUp","rightAddons","value","defaultValue","wrapperRef","readOnly","restProps","ref","uncontrolled","inputRef","useRef","focusVisible","useFocus","focused","setFocused","useState","stateValue","setStateValue","filled","clearButtonVisible","handleInputFocus","useCallback","event","handleInputBlur","handleInputChange","handleClear","renderRightAddons","Fragment","jsx","Button","styles","FormControl","cn","mergeRefs"],"mappings":";;;;;;;;AAmKO,MAAMA,KAAQC,GAAM;AAAA,EACvB,CACI;AAAA,IACI,MAAAC,IAAO;AAAA,IACP,MAAAC,IAAO;AAAA,IACP,OAAAC,IAAQ;AAAA,IACR,cAAAC;AAAA,IACA,YAAAC;AAAA,IACA,OAAAC,IAAQ;AAAA,IACR,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAAAC;AAAA,IACA,UAAAC;AAAA,IACA,MAAAC;AAAA,IACA,WAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,kBAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,YAAAC;AAAA,IACA,SAAAC;AAAA,IACA,QAAAC;AAA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AA,YACA,QAAS4C;AAAA,YACT,SAAUH;AAAA,YACV,UAAWI;AAAA,YACX,WAAAhC;AAAA,YACA,KAAMyC,GAAU,CAAC1B,GAAKE,CAAQ,CAAC;AAAA,YAC/B,MAAAnC;AAAA,YACA,OAAQkC,IAAeQ,IAAad;AAAA,YACpC,UAAAG;AAAA,YACA,gBAAe5B;AAAA,YACf,cAAa,CAAC,CAACG;AAAA,YACf,cAAa,OAAOW,KAAU,WAAWA,IAAQ;AAAA,UAAA;AAAA,QAAA;AAAA,MACrD;AAAA,IAAA;AAAA,EAGZ;AACJ;AAKApB,GAAM,eAAe;AAAA,EACjB,MAAM;AAAA,EACN,OAAO;AACX;"}
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../src/input/component.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n Fragment,\n InputHTMLAttributes,\n MouseEvent,\n useCallback,\n useRef,\n useState,\n} from 'react';\nimport mergeRefs from 'react-merge-refs';\nimport cn from 'classnames';\n\nimport { Button } from '../button';\nimport { FormControl } from '../form-control';\nimport { useFocus } from '../hooks/useFocus';\n\nimport styles from './index.module.css';\n\nexport type InputProps = Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'size' | 'type' | 'value' | 'defaultValue' | 'onChange' | 'onClick' | 'onMouseDown'\n> & {\n /**\n * Значение поля ввода\n */\n value?: string;\n\n /**\n * Начальное значение поля\n */\n defaultValue?: string;\n\n /**\n * Растягивает компонент на ширину контейнера\n */\n block?: boolean;\n\n /**\n * required - индикатор * лейбла для обязательного заполнения поля\n */\n required?: boolean;\n\n /**\n * Крестик для очистки поля\n */\n clear?: boolean;\n\n /**\n * Размер компонента\n */\n size?: 's' | 'm' | 'l';\n\n /**\n * Отображение ошибки\n */\n error?: string | boolean;\n\n /**\n * Отображение иконки успеха\n */\n success?: boolean;\n\n /**\n * Текст подсказки\n */\n hint?: string;\n\n /**\n * Лейбл компонента\n */\n label?: React.ReactNode;\n\n /**\n * Атрибут type\n */\n type?: 'number' | 'card' | 'email' | 'money' | 'password' | 'tel' | 'text';\n\n /**\n * Ref для обертки input\n */\n wrapperRef?: React.Ref<HTMLDivElement>;\n\n /**\n * Слот слева\n */\n leftAddons?: React.ReactNode;\n\n /**\n * Слот справа\n */\n rightAddons?: React.ReactNode;\n\n /**\n * Слот под инпутом\n */\n bottomAddons?: React.ReactNode;\n\n /**\n * Дополнительный класс\n */\n className?: string;\n\n /**\n * Дополнительный класс для поля\n */\n fieldClassName?: string;\n\n /**\n * Дополнительный класс инпута\n */\n inputClassName?: string;\n\n /**\n * Дополнительный класс для лейбла\n */\n labelClassName?: string;\n\n /**\n * Дополнительный класс для аддонов\n */\n addonsClassName?: string;\n\n /**\n * Класс, который будет установлен при фокусе\n */\n focusedClassName?: string;\n\n /**\n * Класс, который будет установлен, если в поле есть значение\n */\n filledClassName?: string;\n\n /**\n * Обработчик поля ввода\n */\n onChange?: (event: ChangeEvent<HTMLInputElement>, payload: { value: string }) => void;\n\n /**\n * Обработчик нажатия на кнопку очистки\n */\n onClear?: (event: MouseEvent<HTMLButtonElement>) => void;\n\n /**\n * Обработчик клика по полю\n */\n onClick?: (event: MouseEvent<HTMLDivElement>) => void;\n\n /**\n * Обработчик MouseDown по полю\n */\n onMouseDown?: (event: MouseEvent<HTMLDivElement>) => void;\n\n /**\n * Обработчик MouseUp по полю\n */\n onMouseUp?: (event: MouseEvent<HTMLDivElement>) => void;\n\n /**\n * Идентификатор для систем автоматизированного тестирования\n */\n dataTestId?: string;\n};\n\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(\n (\n {\n size = 'm',\n type = 'text',\n block = false,\n bottomAddons,\n dataTestId,\n clear = false,\n disabled,\n error,\n success,\n required,\n hint,\n className,\n fieldClassName,\n inputClassName,\n labelClassName,\n addonsClassName,\n focusedClassName,\n filledClassName,\n label,\n maxLength = 100,\n leftAddons,\n onFocus,\n onBlur,\n onChange,\n onClear,\n onClick,\n onMouseDown,\n onMouseUp,\n rightAddons,\n value,\n defaultValue,\n wrapperRef,\n readOnly,\n ...restProps\n },\n ref,\n ) => {\n const uncontrolled = value === undefined;\n\n const inputRef = useRef<HTMLInputElement>(null);\n\n const [focusVisible] = useFocus(inputRef, 'keyboard');\n\n const [focused, setFocused] = useState(false);\n const [stateValue, setStateValue] = useState(defaultValue || '');\n\n const filled = Boolean(uncontrolled ? stateValue : value);\n // отображаем крестик только для заполненного и активного инпута\n const clearButtonVisible = clear && filled && !disabled && !readOnly;\n\n const handleInputFocus = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n if (!readOnly) {\n setFocused(true);\n }\n\n if (onFocus) {\n onFocus(event);\n }\n },\n [onFocus, readOnly],\n );\n\n const handleInputBlur = useCallback(\n (event: React.FocusEvent<HTMLInputElement>) => {\n setFocused(false);\n\n if (onBlur) {\n onBlur(event);\n }\n },\n [onBlur],\n );\n\n const handleInputChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n if (onChange) {\n onChange(event, { value: event.target.value });\n }\n\n if (uncontrolled) {\n setStateValue(event.target.value);\n }\n },\n [onChange, uncontrolled],\n );\n\n const handleClear = useCallback(\n (event: MouseEvent<HTMLButtonElement>) => {\n if (!clearButtonVisible) return;\n\n if (uncontrolled) {\n setStateValue('');\n }\n\n if (onClear) {\n onClear(event);\n }\n\n if (inputRef.current && !focused) {\n inputRef.current.focus();\n }\n },\n [clearButtonVisible, focused, onClear, uncontrolled],\n );\n\n const renderRightAddons = () => {\n const addonsVisible = clearButtonVisible || rightAddons || success;\n\n return (\n addonsVisible && (\n <Fragment>\n { clearButtonVisible && (\n <Button\n type=\"button\"\n view=\"ghost\"\n disabled={ disabled }\n aria-label=\"Очистить\"\n className={ styles.clearButton }\n onClick={ handleClear }\n >\n <span className={ styles.clearIcon } />\n </Button>\n ) }\n { success && !error && <span className={ styles.successIcon } /> }\n { rightAddons }\n </Fragment>\n )\n );\n };\n\n return (\n <FormControl\n ref={ wrapperRef }\n className={ cn(className, focused && focusedClassName, filled && filledClassName) }\n fieldClassName={ cn(fieldClassName, {\n [styles.focusVisible]: focusVisible,\n }) }\n labelClassName={ labelClassName }\n addonsClassName={ addonsClassName }\n size={ size }\n block={ block }\n required={ required }\n disabled={ disabled }\n filled={ filled || focused }\n focused={ focused }\n error={ error }\n label={ label }\n hint={ hint }\n leftAddons={ leftAddons }\n rightAddons={ renderRightAddons() }\n bottomAddons={ bottomAddons }\n onClick={ onClick }\n onMouseDown={ onMouseDown }\n onMouseUp={ onMouseUp }\n >\n <input\n { ...restProps }\n className={ cn(\n styles.input,\n {\n [styles.hasLabel]: label,\n },\n inputClassName,\n ) }\n disabled={ disabled }\n onBlur={ handleInputBlur }\n onFocus={ handleInputFocus }\n onChange={ handleInputChange }\n maxLength={ maxLength }\n ref={ mergeRefs([ref, inputRef]) }\n type={ type }\n value={ uncontrolled ? stateValue : value }\n readOnly={ readOnly }\n data-test-id={ dataTestId }\n data-error={ !!error }\n aria-label={ typeof label === 'string' ? label : undefined }\n />\n </FormControl>\n );\n },\n);\n\n"],"names":["Input","React","size","type","block","bottomAddons","dataTestId","clear","disabled","error","success","required","hint","className","fieldClassName","inputClassName","labelClassName","addonsClassName","focusedClassName","filledClassName","label","maxLength","leftAddons","onFocus","onBlur","onChange","onClear","onClick","onMouseDown","onMouseUp","rightAddons","value","defaultValue","wrapperRef","readOnly","restProps","ref","uncontrolled","inputRef","useRef","focusVisible","useFocus","focused","setFocused","useState","stateValue","setStateValue","filled","clearButtonVisible","handleInputFocus","useCallback","event","handleInputBlur","handleInputChange","handleClear","renderRightAddons","Fragment","jsx","Button","styles","FormControl","cn","mergeRefs"],"mappings":";;;;;;;;AAmKO,MAAMA,KAAQC,GAAM;AAAA,EACvB,CACI;AAAA,IACI,MAAAC,IAAO;AAAA,IACP,MAAAC,IAAO;AAAA,IACP,OAAAC,IAAQ;AAAA,IACR,cAAAC;AAAA,IACA,YAAAC;AAAA,IACA,OAAAC,IAAQ;AAAA,IACR,UAAAC;AAAA,IACA,OAAAC;AAAA,IACA,SAA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AAA,QACA,SAAAsB;AAAA,QACA,aAAAC;AAAA,QACA,WAAAC;AAAA,QAEA,UAAA,gBAAA4B;AAAA,UAAC;AAAA,UAAA;AAAA,YACK,GAAGtB;AAAA,YACL,WAAY0B;AAAA,cACRF,EAAO;AAAA,cACP;AAAA,gBACI,CAACA,EAAO,QAAQ,GAAGvC;AAAA,cAAA;AAAA,cAEvBL;AAAA,YAAA;AAAA,YAEJ,UAAAP;AAAA,YACA,QAAS4C;AAAA,YACT,SAAUH;AAAA,YACV,UAAWI;AAAA,YACX,WAAAhC;AAAA,YACA,KAAMyC,GAAU,CAAC1B,GAAKE,CAAQ,CAAC;AAAA,YAC/B,MAAAnC;AAAA,YACA,OAAQkC,IAAeQ,IAAad;AAAA,YACpC,UAAAG;AAAA,YACA,gBAAe5B;AAAA,YACf,cAAa,CAAC,CAACG;AAAA,YACf,cAAa,OAAOW,KAAU,WAAWA,IAAQ;AAAA,UAAA;AAAA,QAAA;AAAA,MACrD;AAAA,IAAA;AAAA,EAGZ;AACJ;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--text-primary-color: var(--color-text-primary);--text-secondary-color: var(--color-text-secondary);--text-tertiary-color: var(--color-text-tertiary);--border-radius: 4px;--focus-color: var(--color-border-link);--font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, sans-serif;--disabled-cursor: not-allowed;--arrow-transform: rotate(180deg)}:root{--input-clear-icon: url(https://alfabank.st/icons/glyph_cross-circle_m.svg);--input-color: var(--color-text-primary);--input-placeholder-color: var(--color-text-secondary);--input-focus-placeholder-color: var(--color-text-tertiary);--input-with-label-placeholder-color: var(--color-text-tertiary);--input-error-icon-display: flex;--input-success-icon-display: flex;--input-error-icon: url(https://alfabank.st/icons/icon_error_s_color.svg);--input-success-icon: url(https://alfabank.st/icons/icon_ok_s_color.svg);--input-disabled-color: var(--color-text-secondary);--input-read-only-color: var(--color-text-secondary)}.input_XkSq{font-size:16px!important;line-height:20px;font-weight:400;font-family:var(--font-family);position:relative;display:block;width:100%;height:100%;color:var(--input-color);background:none;border:none;margin:0;outline:none;text-overflow:ellipsis;box-sizing:border-box;-webkit-appearance:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.input_XkSq::placeholder{transition:opacity .2s ease,color .2s ease;color:var(--input-placeholder-color)}.hasLabel_3lW-::placeholder{opacity:0;color:var(--input-with-label-placeholder-color)}.block_Lq9-{width:100%}.clearIcon_951a{width:24px;height:24px;background-repeat:no-repeat;background-position:50% 50%;display:block;background-image:var(--input-clear-icon);opacity:.3;transition:opacity .2s ease}.clearIcon_951a:hover{opacity:.6}.clearIcon_951a:active{opacity:1}.errorIcon_Z4ac{width:24px;height:24px;background-repeat:no-repeat;background-position:50% 50%;display:var(--input-error-icon-display);background-image:url(https://alfabank.st/icons/icon_error_s_color.svg)}.successIcon_yfoM{width:24px;height:24px;background-repeat:no-repeat;background-position:50% 50%;display:var(--input-success-icon-display);background-image:url(https://alfabank.st/icons/icon_ok_s_color.svg)}.input_XkSq:disabled{cursor:var(--disabled-cursor);color:var(--input-disabled-color)}.input_XkSq:focus.hasLabel_3lW-::placeholder{opacity:1}.input_XkSq:focus::placeholder{color:var(--input-focus-placeholder-color)}.focusVisible_3hin{outline:2px solid var(--focus-color);outline-offset:2px}.input_XkSq:read-only{cursor:var(--disabled-cursor);color:var(--input-read-only-color)}.input_XkSq:read-only:focus::placeholder{color:var(--input-placeholder-color)}.hasLabel_3lW-:read-only:focus::placeholder{opacity:0}.input_XkSq::-ms-clear{display:none;width:0;height:0}.input_XkSq:-webkit-autofill,.input_XkSq:-webkit-autofill:hover,.input_XkSq:-webkit-autofill:focus,.input_XkSq:-webkit-autofill:active{-webkit-transition:background-color 999999s ease-in-out 0s;transition:background-color 999999s ease-in-out 0s;-webkit-box-shadow:0 0 0 30px #ffffff00 inset!important}
|
|
1
|
+
:root{--text-primary-color: var(--color-text-primary);--text-secondary-color: var(--color-text-secondary);--text-tertiary-color: var(--color-text-tertiary);--border-radius: 4px;--focus-color: var(--color-border-link);--font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, sans-serif;--disabled-cursor: not-allowed;--arrow-transform: rotate(180deg)}:root{--input-clear-icon: url(https://alfabank.st/icons/glyph_cross-circle_m.svg);--input-color: var(--color-text-primary);--input-placeholder-color: color-mix(in srgb, var(--color-text-secondary) 35%, transparent);--input-focus-placeholder-color: color-mix(in srgb, var(--color-text-tertiary) 35%, transparent);--input-with-label-placeholder-color: color-mix(in srgb, var(--color-text-tertiary) 35%, transparent);--input-error-icon-display: flex;--input-success-icon-display: flex;--input-error-icon: url(https://alfabank.st/icons/icon_error_s_color.svg);--input-success-icon: url(https://alfabank.st/icons/icon_ok_s_color.svg);--input-disabled-color: var(--color-text-secondary);--input-read-only-color: var(--color-text-secondary)}.input_XkSq{font-size:16px!important;line-height:20px;font-weight:400;font-family:var(--font-family);position:relative;display:block;width:100%;height:100%;color:var(--input-color);background:none;border:none;margin:0;outline:none;text-overflow:ellipsis;box-sizing:border-box;-webkit-appearance:none;-webkit-tap-highlight-color:rgba(0,0,0,0)}.input_XkSq::placeholder{transition:opacity .2s ease,color .2s ease;color:var(--input-placeholder-color)}.hasLabel_3lW-::placeholder{opacity:0;color:var(--input-with-label-placeholder-color)}.block_Lq9-{width:100%}.clearIcon_951a{width:24px;height:24px;background-repeat:no-repeat;background-position:50% 50%;display:block;background-image:var(--input-clear-icon);opacity:.3;transition:opacity .2s ease}.clearIcon_951a:hover{opacity:.6}.clearIcon_951a:active{opacity:1}.errorIcon_Z4ac{width:24px;height:24px;background-repeat:no-repeat;background-position:50% 50%;display:var(--input-error-icon-display);background-image:url(https://alfabank.st/icons/icon_error_s_color.svg)}.successIcon_yfoM{width:24px;height:24px;background-repeat:no-repeat;background-position:50% 50%;display:var(--input-success-icon-display);background-image:url(https://alfabank.st/icons/icon_ok_s_color.svg)}.input_XkSq:disabled{cursor:var(--disabled-cursor);color:var(--input-disabled-color)}.input_XkSq:focus.hasLabel_3lW-::placeholder{opacity:1}.input_XkSq:focus::placeholder{color:var(--input-focus-placeholder-color)}.focusVisible_3hin{outline:2px solid var(--focus-color);outline-offset:2px}.input_XkSq:read-only{cursor:var(--disabled-cursor);color:var(--input-read-only-color)}.input_XkSq:read-only:focus::placeholder{color:var(--input-placeholder-color)}.hasLabel_3lW-:read-only:focus::placeholder{opacity:0}.input_XkSq::-ms-clear{display:none;width:0;height:0}.input_XkSq:-webkit-autofill,.input_XkSq:-webkit-autofill:hover,.input_XkSq:-webkit-autofill:focus,.input_XkSq:-webkit-autofill:active{-webkit-transition:background-color 999999s ease-in-out 0s;transition:background-color 999999s ease-in-out 0s;-webkit-box-shadow:0 0 0 30px #ffffff00 inset!important}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
1
2
|
import { SelectFieldProps } from '../../select';
|
|
2
3
|
import { InputAutocompleteProps } from '../component';
|
|
3
4
|
export type AutocompleteFieldProps = SelectFieldProps & Pick<InputAutocompleteProps, 'Input' | 'inputProps' | 'value' | 'onInput' | 'readOnly'>;
|
|
4
|
-
export declare const AutocompleteField: ({ label, placeholder, Arrow, Input, value, error, success, hint, disabled, readOnly, onInput, inputProps, innerProps, }: AutocompleteFieldProps) => JSX.Element;
|
|
5
|
+
export declare const AutocompleteField: ({ label, placeholder, Arrow, Input, value, error, success, hint, disabled, readOnly, onInput, inputProps, innerProps, }: AutocompleteFieldProps) => React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/input-autocomplete/autocomplete-field/index.tsx"],"sourcesContent":["import React, { useCallback, useRef } from 'react';\nimport cn from 'classnames';\nimport { Input as DefaultInput } from '../../input';\nimport { SelectFieldProps } from '../../select';\nimport mergeRefs from 'react-merge-refs';\nimport { InputAutocompleteProps } from '../component';\n\nimport styles from './index.module.css';\n\nexport type AutocompleteFieldProps = SelectFieldProps &\n Pick<InputAutocompleteProps, 'Input' | 'inputProps' | 'value' | 'onInput' | 'readOnly'>;\n\nexport const AutocompleteField = ({\n label,\n placeholder,\n Arrow,\n Input = DefaultInput,\n value,\n error,\n success,\n hint,\n disabled,\n readOnly,\n onInput,\n inputProps = {},\n innerProps,\n}: AutocompleteFieldProps) => {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const { onClick, onFocus } = innerProps;\n\n const inputDisabled = disabled || readOnly;\n\n const handleClick = useCallback(\n event => {\n if (onClick) onClick(event);\n\n if (inputRef.current) {\n inputRef.current.focus();\n }\n },\n [onClick],\n );\n return (\n <Input\n {...inputProps}\n {...innerProps}\n // eslint-disable-next-line @typescript-eslint/ban-ts-ignore\n // @ts-ignore\n wrapperRef={mergeRefs([innerProps.ref, inputProps.wrapperRef])}\n // eslint-disable-next-line @typescript-eslint/ban-ts-ignore\n // @ts-ignore\n ref={mergeRefs([inputRef, inputProps.ref])}\n disabled={disabled}\n readOnly={readOnly}\n block={true}\n label={label}\n placeholder={placeholder}\n error={error}\n success={success}\n hint={hint}\n onChange={onInput}\n onClick={inputDisabled ? undefined : handleClick}\n onFocus={inputDisabled ? undefined : onFocus}\n autoComplete='off'\n value={value}\n rightAddons={\n (Arrow || inputProps.rightAddons) && (\n <React.Fragment>\n {inputProps.rightAddons}\n {Arrow && (\n <span\n className={cn(styles.arrow, {\n [styles.error]: error,\n })}\n >\n {Arrow}\n </span>\n )}\n </React.Fragment>\n )\n }\n />\n );\n};\n"],"names":["AutocompleteField","label","placeholder","Arrow","Input","DefaultInput","value","error","success","hint","disabled","readOnly","onInput","inputProps","innerProps","inputRef","useRef","onClick","onFocus","inputDisabled","handleClick","useCallback","event","jsx","mergeRefs","jsxs","React","cn","styles"],"mappings":";;;;;;AAYO,MAAMA,IAAoB,CAAC;AAAA,EAC9B,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,OAAAC;AAAA,EAAA,OACAC,IAAQC;AAAAA,EACR,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,YAAAC,IAAa,CAAA;AAAA,EACb,YAAAC;AACJ,MAA8B;AAC1B,QAAMC,IAAWC,EAAyB,IAAI,GAExC,EAAE,SAAAC,GAAS,SAAAC,EAAA,IAAYJ,GAEvBK,IAAgBT,KAAYC,GAE5BS,IAAcC;AAAA,IAChB,
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/input-autocomplete/autocomplete-field/index.tsx"],"sourcesContent":["import React, { useCallback, useRef } from 'react';\nimport cn from 'classnames';\nimport { Input as DefaultInput } from '../../input';\nimport { SelectFieldProps } from '../../select';\nimport mergeRefs from 'react-merge-refs';\nimport { InputAutocompleteProps } from '../component';\n\nimport styles from './index.module.css';\n\nexport type AutocompleteFieldProps = SelectFieldProps &\n Pick<InputAutocompleteProps, 'Input' | 'inputProps' | 'value' | 'onInput' | 'readOnly'>;\n\nexport const AutocompleteField = ({\n label,\n placeholder,\n Arrow,\n Input = DefaultInput,\n value,\n error,\n success,\n hint,\n disabled,\n readOnly,\n onInput,\n inputProps = {},\n innerProps,\n}: AutocompleteFieldProps) => {\n const inputRef = useRef<HTMLInputElement>(null);\n\n const { onClick, onFocus } = innerProps;\n\n const inputDisabled = disabled || readOnly;\n\n const handleClick = useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\n if (onClick) onClick(event);\n\n if (inputRef.current) {\n inputRef.current.focus();\n }\n },\n [onClick],\n );\n return (\n <Input\n {...inputProps}\n {...innerProps}\n // eslint-disable-next-line @typescript-eslint/ban-ts-ignore\n // @ts-ignore\n wrapperRef={mergeRefs([innerProps.ref, inputProps.wrapperRef])}\n // eslint-disable-next-line @typescript-eslint/ban-ts-ignore\n // @ts-ignore\n ref={mergeRefs([inputRef, inputProps.ref])}\n disabled={disabled}\n readOnly={readOnly}\n block={true}\n label={label}\n placeholder={placeholder}\n error={error}\n success={success}\n hint={hint}\n onChange={onInput}\n onClick={inputDisabled ? undefined : handleClick}\n onFocus={inputDisabled ? undefined : onFocus}\n autoComplete='off'\n value={value}\n rightAddons={\n (Arrow || inputProps.rightAddons) && (\n <React.Fragment>\n {inputProps.rightAddons}\n {Arrow && (\n <span\n className={cn(styles.arrow, {\n [styles.error]: error,\n })}\n >\n {Arrow}\n </span>\n )}\n </React.Fragment>\n )\n }\n />\n );\n};\n"],"names":["AutocompleteField","label","placeholder","Arrow","Input","DefaultInput","value","error","success","hint","disabled","readOnly","onInput","inputProps","innerProps","inputRef","useRef","onClick","onFocus","inputDisabled","handleClick","useCallback","event","jsx","mergeRefs","jsxs","React","cn","styles"],"mappings":";;;;;;AAYO,MAAMA,IAAoB,CAAC;AAAA,EAC9B,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,OAAAC;AAAA,EAAA,OACAC,IAAQC;AAAAA,EACR,OAAAC;AAAA,EACA,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,YAAAC,IAAa,CAAA;AAAA,EACb,YAAAC;AACJ,MAA8B;AAC1B,QAAMC,IAAWC,EAAyB,IAAI,GAExC,EAAE,SAAAC,GAAS,SAAAC,EAAA,IAAYJ,GAEvBK,IAAgBT,KAAYC,GAE5BS,IAAcC;AAAA,IAChB,CAACC,MAA4C;AACzC,MAAIL,OAAiBK,CAAK,GAEtBP,EAAS,WACTA,EAAS,QAAQ,MAAA;AAAA,IAEzB;AAAA,IACA,CAACE,CAAO;AAAA,EAAA;AAEZ,SACI,gBAAAM;AAAA,IAACnB;AAAAA,IAAA;AAAA,MACI,GAAGS;AAAA,MACH,GAAGC;AAAA,MAGJ,YAAYU,EAAU,CAACV,EAAW,KAAKD,EAAW,UAAU,CAAC;AAAA,MAG7D,KAAKW,EAAU,CAACT,GAAUF,EAAW,GAAG,CAAC;AAAA,MACzC,UAAAH;AAAA,MACA,UAAAC;AAAA,MACA,OAAO;AAAA,MACP,OAAAV;AAAA,MACA,aAAAC;AAAA,MACA,OAAAK;AAAA,MACA,SAAAC;AAAA,MACA,MAAAC;AAAA,MACA,UAAUG;AAAA,MACV,SAASO,IAAgB,SAAYC;AAAA,MACrC,SAASD,IAAgB,SAAYD;AAAA,MACrC,cAAa;AAAA,MACb,OAAAZ;AAAA,MACA,cACKH,KAASU,EAAW,gBACjB,gBAAAY,EAACC,EAAM,UAAN,EACI,UAAA;AAAA,QAAAb,EAAW;AAAA,QACXV,KACG,gBAAAoB;AAAA,UAAC;AAAA,UAAA;AAAA,YACG,WAAWI,EAAGC,EAAO,OAAO;AAAA,cACxB,CAACA,EAAO,KAAK,GAAGrB;AAAA,YAAA,CACnB;AAAA,YAEA,UAAAJ;AAAA,UAAA;AAAA,QAAA;AAAA,MACL,EAAA,CAER;AAAA,IAAA;AAAA,EAAA;AAKpB;"}
|
|
@@ -31,7 +31,7 @@ export type InputAutocompleteProps = Omit<BaseSelectProps, 'Field' | 'nativeSele
|
|
|
31
31
|
*/
|
|
32
32
|
updatePopover?: BaseSelectProps['updatePopover'];
|
|
33
33
|
};
|
|
34
|
-
export declare const InputAutocomplete: React.ForwardRefExoticComponent<Omit<BaseSelectProps, "
|
|
34
|
+
export declare const InputAutocomplete: React.ForwardRefExoticComponent<Omit<BaseSelectProps, "Field" | "nativeSelect"> & {
|
|
35
35
|
/**
|
|
36
36
|
* Компонент ввода значения
|
|
37
37
|
*/
|
|
@@ -60,7 +60,7 @@ export declare const InputAutocomplete: React.ForwardRefExoticComponent<Omit<Bas
|
|
|
60
60
|
addonsClassName?: string | undefined;
|
|
61
61
|
focusedClassName?: string | undefined;
|
|
62
62
|
filledClassName?: string | undefined;
|
|
63
|
-
onChange?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
|
|
63
|
+
onChange?: ((event: React.ChangeEvent<HTMLInputElement, Element>, payload: {
|
|
64
64
|
value: string;
|
|
65
65
|
}) => void) | undefined;
|
|
66
66
|
onClear?: ((event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void) | undefined;
|
|
@@ -97,7 +97,7 @@ export declare const InputAutocomplete: React.ForwardRefExoticComponent<Omit<Bas
|
|
|
97
97
|
addonsClassName?: string | undefined;
|
|
98
98
|
focusedClassName?: string | undefined;
|
|
99
99
|
filledClassName?: string | undefined;
|
|
100
|
-
onChange?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
|
|
100
|
+
onChange?: ((event: React.ChangeEvent<HTMLInputElement, Element>, payload: {
|
|
101
101
|
value: string;
|
|
102
102
|
}) => void) | undefined;
|
|
103
103
|
onClear?: ((event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void) | undefined;
|
|
@@ -7,4 +7,4 @@ export interface InputGhostProps {
|
|
|
7
7
|
block?: boolean;
|
|
8
8
|
size?: 's' | 'm';
|
|
9
9
|
}
|
|
10
|
-
export declare const InputGhost: ({ value, onChange, placeholder, leftAddons, block, size, }: InputGhostProps) => JSX.Element;
|
|
10
|
+
export declare const InputGhost: ({ value, onChange, placeholder, leftAddons, block, size, }: InputGhostProps) => React.JSX.Element;
|
|
@@ -39,7 +39,7 @@ export declare const MaskedInput: React.ForwardRefExoticComponent<Omit<React.Inp
|
|
|
39
39
|
addonsClassName?: string | undefined;
|
|
40
40
|
focusedClassName?: string | undefined;
|
|
41
41
|
filledClassName?: string | undefined;
|
|
42
|
-
onChange?: ((event: React.ChangeEvent<HTMLInputElement>, payload: {
|
|
42
|
+
onChange?: ((event: React.ChangeEvent<HTMLInputElement, Element>, payload: {
|
|
43
43
|
value: string;
|
|
44
44
|
}) => void) | undefined;
|
|
45
45
|
onClear?: ((event: React.MouseEvent<HTMLButtonElement, globalThis.MouseEvent>) => void) | undefined;
|
package/dist/menu/component.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
1
|
+
import { default as React, ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { TFunction } from '../modal';
|
|
3
3
|
import { OptionShape } from '../select';
|
|
4
4
|
export type MenuElement = {
|
|
5
5
|
path: string;
|
|
6
6
|
element: React.ReactNode;
|
|
7
|
-
icon?:
|
|
7
|
+
icon?: ReactElement;
|
|
8
8
|
title?: string;
|
|
9
9
|
};
|
|
10
10
|
export type MenuProps = {
|
|
@@ -20,5 +20,6 @@ export type MenuProps = {
|
|
|
20
20
|
profileOnClick?: () => void;
|
|
21
21
|
navigate: (path: string) => void;
|
|
22
22
|
t: TFunction;
|
|
23
|
+
children?: ReactNode;
|
|
23
24
|
};
|
|
24
25
|
export declare const Menu: React.FC<MenuProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sources":["../../src/menu/component.tsx"],"sourcesContent":["import React from 'react';\nimport cn from 'classnames';\n\nimport { TFunction } from '../modal';\nimport { OptionShape } from '../select';\n\nimport { useMenu } from './hooks/use-menu';\nimport {\n ContentHeader,\n MenuAvatar,\n MenuBackButton,\n MenuButtonsList,\n UserButton,\n} from './components';\n\nimport styles from './index.module.css';\n\nexport type MenuElement = {\n path: string;\n element: React.ReactNode;\n icon?:
|
|
1
|
+
{"version":3,"file":"component.js","sources":["../../src/menu/component.tsx"],"sourcesContent":["import React, { ReactElement, ReactNode } from 'react';\nimport cn from 'classnames';\n\nimport { TFunction } from '../modal';\nimport { OptionShape } from '../select';\n\nimport { useMenu } from './hooks/use-menu';\nimport {\n ContentHeader,\n MenuAvatar,\n MenuBackButton,\n MenuButtonsList,\n UserButton,\n} from './components';\n\nimport styles from './index.module.css';\n\nexport type MenuElement = {\n path: string;\n element: React.ReactNode;\n icon?: ReactElement;\n title?: string;\n};\n\nexport type MenuProps = {\n pathname: string;\n routes: MenuElement[];\n showBackButton?: boolean;\n\n userName: string;\n userImage: string;\n userDialogOptions: OptionShape[];\n\n profileTitle: string;\n profileImage: string;\n Link: unknown;\n profileOnClick?: () => void;\n\n navigate: (path: string) => void;\n t: TFunction;\n\n children?: ReactNode;\n};\n\nexport const Menu: React.FC<MenuProps> = ({\n pathname,\n children,\n routes,\n showBackButton,\n userName,\n userImage,\n userDialogOptions,\n profileTitle,\n profileImage,\n Link,\n profileOnClick,\n navigate,\n t,\n}) => {\n const {\n staticMenu, setStaticMenu, showMenu, ref,\n } = useMenu();\n\n const showLabels = staticMenu || showMenu;\n\n const currentPath = `/${pathname.split('/').slice(-1)[0]}`;\n\n const onBackClick = () => navigate('/app/calendar');\n\n const menuStyles = cn(styles.left_menu, {\n [styles.menu_static]: staticMenu,\n [styles.hidden_menu_opened]: showMenu,\n });\n\n const contentWrapperStyles = cn(styles.content_wrapper, {\n [styles.content_offseted]: staticMenu,\n [styles.calendar_view]: pathname.startsWith('/app/calendar'),\n });\n\n return (\n <div className={ cn(styles.layout_wrapper) }>\n <div ref={ ref } className={ menuStyles }>\n <MenuAvatar\n title={ profileTitle }\n showTitle={ showLabels }\n image={ profileImage }\n onClick={ profileOnClick }\n />\n\n { showBackButton && <MenuBackButton showTitle={ showLabels } onClick={ onBackClick } /> }\n\n <MenuButtonsList\n routes={ routes }\n showLabels={ showLabels }\n currentPath={ currentPath }\n Link={ Link }\n t={ t }\n />\n </div>\n\n <div className={ contentWrapperStyles }>\n <div className={ styles.content_header }>\n <ContentHeader\n onClick={ () => setStaticMenu(!staticMenu) }\n title={ t(`menu.${currentPath}`) }\n />\n\n <UserButton photo={ userImage } fullName={ userName } options={ userDialogOptions } />\n </div>\n\n { children }\n </div>\n </div>\n );\n};\n"],"names":["Menu","pathname","children","routes","showBackButton","userName","userImage","userDialogOptions","profileTitle","profileImage","Link","profileOnClick","navigate","t","staticMenu","setStaticMenu","showMenu","ref","useMenu","showLabels","currentPath","onBackClick","menuStyles","cn","styles","contentWrapperStyles","jsxs","jsx","MenuAvatar","MenuBackButton","MenuButtonsList","ContentHeader","UserButton"],"mappings":";;;;;;;;;AA4CO,MAAMA,IAA4B,CAAC;AAAA,EACtC,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,UAAAC;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AAa,EAAC,OAAA,EAAI,WAAYD,GACb,UAAA;AAAA,MAAA,gBAAAC,EAAC,OAAA,EAAI,WAAYF,EAAO,gBACpB,UAAA;AAAA,QAAA,gBAAAG;AAAA,UAACI;AAAA,UAAA;AAAA,YACG,SAAU,MAAMhB,EAAc,CAACD,CAAU;AAAA,YACzC,OAAQD,EAAE,QAAQO,CAAW,EAAE;AAAA,UAAA;AAAA,QAAA;AAAA,0BAGlCY,GAAA,EAAW,OAAQ1B,GAAY,UAAWD,GAAW,SAAUE,EAAA,CAAoB;AAAA,MAAA,GACxF;AAAA,MAEEL;AAAA,IAAA,EAAA,CACN;AAAA,EAAA,GACJ;AAER;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare const useMenu: () => {
|
|
3
|
-
ref: import('react').RefObject<HTMLDivElement>;
|
|
3
|
+
ref: import('react').RefObject<HTMLDivElement | null>;
|
|
4
4
|
staticMenu: boolean;
|
|
5
5
|
showMenu: boolean;
|
|
6
6
|
setStaticMenu: import('react').Dispatch<import('react').SetStateAction<boolean>>;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { useState as
|
|
1
|
+
import { useState as i, useRef as m, useCallback as a, useEffect as l } from "react";
|
|
2
2
|
const d = () => {
|
|
3
|
-
const [e, f] =
|
|
4
|
-
e ||
|
|
3
|
+
const [e, f] = i(!0), [n, o] = i(!1), t = m(void 0), s = m(null), c = a(() => {
|
|
4
|
+
e || o(!0);
|
|
5
5
|
}, [e]), u = a(() => {
|
|
6
6
|
t.current && clearTimeout(t.current), t.current = setTimeout(c, 600);
|
|
7
7
|
}, [c]);
|
|
8
8
|
return l(() => {
|
|
9
|
-
const r =
|
|
9
|
+
const r = s.current;
|
|
10
10
|
if (!(e || !r))
|
|
11
11
|
return r.addEventListener("mousemove", u), r.addEventListener("mouseleave", () => {
|
|
12
|
-
clearTimeout(t.current),
|
|
12
|
+
clearTimeout(t.current), o(!1);
|
|
13
13
|
}), () => {
|
|
14
14
|
r.removeEventListener("mousemove", u), clearTimeout(t.current);
|
|
15
15
|
};
|
|
16
16
|
}, [e, n, u]), {
|
|
17
|
-
ref:
|
|
17
|
+
ref: s,
|
|
18
18
|
staticMenu: e,
|
|
19
19
|
showMenu: n,
|
|
20
20
|
setStaticMenu: f
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-menu.js","sources":["../../../src/menu/hooks/use-menu.ts"],"sourcesContent":["import {\n useCallback, useEffect, useRef, useState,\n} from 'react';\n\nexport const useMenu = () => {\n const [staticMenu, setStaticMenu] = useState(true);\n const [showMenu, setShowMenu] = useState(false);\n\n const timer = useRef<any>();\n const ref = useRef<HTMLDivElement>(null);\n\n const mouseStopped = useCallback(() => {\n if (!staticMenu) {\n setShowMenu(true);\n }\n }, [staticMenu]);\n\n const timeout = useCallback(() => {\n if (timer.current) {\n clearTimeout(timer.current);\n }\n timer.current = setTimeout(mouseStopped, 600);\n }, [mouseStopped]);\n\n useEffect(() => {\n const menuRef = ref.current;\n\n if (staticMenu || !menuRef) return;\n\n menuRef.addEventListener('mousemove', timeout);\n menuRef.addEventListener('mouseleave', () => {\n clearTimeout(timer.current);\n setShowMenu(false);\n });\n\n // eslint-disable-next-line consistent-return\n return () => {\n menuRef.removeEventListener('mousemove', timeout);\n clearTimeout(timer.current);\n };\n }, [staticMenu, showMenu, timeout]);\n\n return {\n ref,\n staticMenu,\n showMenu,\n setStaticMenu,\n };\n};\n"],"names":["useMenu","staticMenu","setStaticMenu","useState","showMenu","setShowMenu","timer","useRef","ref","mouseStopped","useCallback","timeout","useEffect","menuRef"],"mappings":";AAIO,MAAMA,IAAU,MAAM;AACzB,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAS,EAAI,GAC3C,CAACC,GAAUC,CAAW,IAAIF,EAAS,EAAK,GAExCG,IAAQC,
|
|
1
|
+
{"version":3,"file":"use-menu.js","sources":["../../../src/menu/hooks/use-menu.ts"],"sourcesContent":["import {\n useCallback, useEffect, useRef, useState,\n} from 'react';\n\nexport const useMenu = () => {\n const [staticMenu, setStaticMenu] = useState(true);\n const [showMenu, setShowMenu] = useState(false);\n\n const timer = useRef<any>(undefined);\n const ref = useRef<HTMLDivElement>(null);\n\n const mouseStopped = useCallback(() => {\n if (!staticMenu) {\n setShowMenu(true);\n }\n }, [staticMenu]);\n\n const timeout = useCallback(() => {\n if (timer.current) {\n clearTimeout(timer.current);\n }\n timer.current = setTimeout(mouseStopped, 600);\n }, [mouseStopped]);\n\n useEffect(() => {\n const menuRef = ref.current;\n\n if (staticMenu || !menuRef) return;\n\n menuRef.addEventListener('mousemove', timeout);\n menuRef.addEventListener('mouseleave', () => {\n clearTimeout(timer.current);\n setShowMenu(false);\n });\n\n // eslint-disable-next-line consistent-return\n return () => {\n menuRef.removeEventListener('mousemove', timeout);\n clearTimeout(timer.current);\n };\n }, [staticMenu, showMenu, timeout]);\n\n return {\n ref,\n staticMenu,\n showMenu,\n setStaticMenu,\n };\n};\n"],"names":["useMenu","staticMenu","setStaticMenu","useState","showMenu","setShowMenu","timer","useRef","ref","mouseStopped","useCallback","timeout","useEffect","menuRef"],"mappings":";AAIO,MAAMA,IAAU,MAAM;AACzB,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAAS,EAAI,GAC3C,CAACC,GAAUC,CAAW,IAAIF,EAAS,EAAK,GAExCG,IAAQC,EAAY,MAAS,GAC7BC,IAAMD,EAAuB,IAAI,GAEjCE,IAAeC,EAAY,MAAM;AACnC,IAAKT,KACDI,EAAY,EAAI;AAAA,EAExB,GAAG,CAACJ,CAAU,CAAC,GAETU,IAAUD,EAAY,MAAM;AAC9B,IAAIJ,EAAM,WACN,aAAaA,EAAM,OAAO,GAE9BA,EAAM,UAAU,WAAWG,GAAc,GAAG;AAAA,EAChD,GAAG,CAACA,CAAY,CAAC;AAEjB,SAAAG,EAAU,MAAM;AACZ,UAAMC,IAAUL,EAAI;AAEpB,QAAI,EAAAP,KAAc,CAACY;AAEnB,aAAAA,EAAQ,iBAAiB,aAAaF,CAAO,GAC7CE,EAAQ,iBAAiB,cAAc,MAAM;AACzC,qBAAaP,EAAM,OAAO,GAC1BD,EAAY,EAAK;AAAA,MACrB,CAAC,GAGM,MAAM;AACT,QAAAQ,EAAQ,oBAAoB,aAAaF,CAAO,GAChD,aAAaL,EAAM,OAAO;AAAA,MAC9B;AAAA,EACJ,GAAG,CAACL,GAAYG,GAAUO,CAAO,CAAC,GAE3B;AAAA,IACH,KAAAH;AAAA,IACA,YAAAP;AAAA,IACA,UAAAG;AAAA,IACA,eAAAF;AAAA,EAAA;AAER;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
1
2
|
import { ModalObject, TFunction } from '../../types';
|
|
2
3
|
import { ModalsProps } from '.';
|
|
3
4
|
type ModalProps = {
|
|
@@ -5,5 +6,5 @@ type ModalProps = {
|
|
|
5
6
|
index: number;
|
|
6
7
|
t: TFunction;
|
|
7
8
|
} & Pick<ModalsProps, 'dirtyModals' | 'closeModal' | 'currentModalId'>;
|
|
8
|
-
export declare const Modal: ({ modal, t, index, dirtyModals, closeModal, currentModalId, }: ModalProps) => JSX.Element;
|
|
9
|
+
export declare const Modal: ({ modal, t, index, dirtyModals, closeModal, currentModalId, }: ModalProps) => React.JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -5,29 +5,29 @@ import { useSwipeable as M, LEFT as U, RIGHT as V, UP as $ } from "react-swipeab
|
|
|
5
5
|
import q from "classnames";
|
|
6
6
|
import { Portal as z } from "../portal/component.js";
|
|
7
7
|
import { ToastPlate as B } from "../toast-plate/component.js";
|
|
8
|
-
import { useClickOutside as
|
|
9
|
-
import
|
|
10
|
-
const
|
|
8
|
+
import { useClickOutside as J } from "./utils/index.js";
|
|
9
|
+
import i from "./index.module.css.js";
|
|
10
|
+
const K = `.${i.notificationComponent}`, v = F(
|
|
11
11
|
({
|
|
12
12
|
className: g,
|
|
13
13
|
children: h,
|
|
14
14
|
visible: e,
|
|
15
15
|
offset: N = 108,
|
|
16
|
-
hasCloser:
|
|
16
|
+
hasCloser: S = !0,
|
|
17
17
|
autoCloseDelay: p = 5e3,
|
|
18
18
|
onClose: n,
|
|
19
|
-
onCloseTimeout:
|
|
20
|
-
onMouseEnter:
|
|
19
|
+
onCloseTimeout: c,
|
|
20
|
+
onMouseEnter: a,
|
|
21
21
|
onMouseLeave: f,
|
|
22
22
|
onClickOutside: m,
|
|
23
|
-
style:
|
|
23
|
+
style: P,
|
|
24
24
|
...k
|
|
25
25
|
}, x) => {
|
|
26
|
-
const d = u(null), T = u(0), w = u(0), [
|
|
26
|
+
const d = u(null), T = u(0), w = u(0), [A, C] = G(!1), s = r(() => {
|
|
27
27
|
T.current = window.setTimeout(() => {
|
|
28
|
-
|
|
28
|
+
c && c();
|
|
29
29
|
}, p);
|
|
30
|
-
}, [p,
|
|
30
|
+
}, [p, c]), o = r(() => {
|
|
31
31
|
clearTimeout(T.current);
|
|
32
32
|
}, []);
|
|
33
33
|
R(
|
|
@@ -35,28 +35,28 @@ const J = `.${s.notificationComponent}`, K = F(
|
|
|
35
35
|
clearTimeout(w.current);
|
|
36
36
|
},
|
|
37
37
|
[]
|
|
38
|
-
), R(() => (e &&
|
|
38
|
+
), R(() => (e && s(), () => {
|
|
39
39
|
o();
|
|
40
|
-
}), [
|
|
41
|
-
const
|
|
40
|
+
}), [s, o, e]);
|
|
41
|
+
const E = r(
|
|
42
42
|
(t) => {
|
|
43
|
-
o(),
|
|
43
|
+
o(), a && a(t);
|
|
44
44
|
},
|
|
45
|
-
[
|
|
46
|
-
),
|
|
45
|
+
[a, o]
|
|
46
|
+
), H = r(
|
|
47
47
|
(t) => {
|
|
48
|
-
o(),
|
|
48
|
+
o(), s(), f && f(t);
|
|
49
49
|
},
|
|
50
|
-
[f,
|
|
51
|
-
),
|
|
50
|
+
[f, s, o]
|
|
51
|
+
), I = r(
|
|
52
52
|
(t) => {
|
|
53
|
-
const
|
|
54
|
-
m && e && !
|
|
53
|
+
const y = !!t.target.closest(K);
|
|
54
|
+
m && e && !y && m(t);
|
|
55
55
|
},
|
|
56
56
|
[m, e]
|
|
57
57
|
);
|
|
58
|
-
|
|
59
|
-
const
|
|
58
|
+
J(d, I);
|
|
59
|
+
const j = M({
|
|
60
60
|
onSwiped: ({ dir: t }) => {
|
|
61
61
|
n && [U, V, $].includes(t) && (C(!0), w.current = window.setTimeout(() => {
|
|
62
62
|
C(!1), n();
|
|
@@ -65,27 +65,27 @@ const J = `.${s.notificationComponent}`, K = F(
|
|
|
65
65
|
delta: 100,
|
|
66
66
|
trackMouse: !0
|
|
67
67
|
});
|
|
68
|
-
return /* @__PURE__ */ l(z, { children: /* @__PURE__ */ l("div", { ...
|
|
68
|
+
return /* @__PURE__ */ l(z, { children: /* @__PURE__ */ l("div", { ...j, children: /* @__PURE__ */ l(
|
|
69
69
|
B,
|
|
70
70
|
{
|
|
71
71
|
className: q(
|
|
72
|
-
|
|
72
|
+
i.notificationComponent,
|
|
73
73
|
{
|
|
74
|
-
[
|
|
75
|
-
[
|
|
74
|
+
[i.isVisible]: e,
|
|
75
|
+
[i.isClosing]: A
|
|
76
76
|
},
|
|
77
77
|
g
|
|
78
78
|
),
|
|
79
|
-
contentClassName:
|
|
79
|
+
contentClassName: i.toastContent,
|
|
80
80
|
style: {
|
|
81
81
|
top: N,
|
|
82
|
-
...
|
|
82
|
+
...P
|
|
83
83
|
},
|
|
84
|
-
onMouseEnter:
|
|
85
|
-
onMouseLeave:
|
|
84
|
+
onMouseEnter: E,
|
|
85
|
+
onMouseLeave: H,
|
|
86
86
|
ref: L([x, d]),
|
|
87
87
|
role: e ? "alert" : void 0,
|
|
88
|
-
hasCloser:
|
|
88
|
+
hasCloser: S,
|
|
89
89
|
onClose: n,
|
|
90
90
|
...k,
|
|
91
91
|
children: h
|
|
@@ -93,11 +93,7 @@ const J = `.${s.notificationComponent}`, K = F(
|
|
|
93
93
|
) }) });
|
|
94
94
|
}
|
|
95
95
|
);
|
|
96
|
-
K.defaultProps = {
|
|
97
|
-
autoCloseDelay: 5e3,
|
|
98
|
-
offset: 108
|
|
99
|
-
};
|
|
100
96
|
export {
|
|
101
|
-
|
|
97
|
+
v as Notification
|
|
102
98
|
};
|
|
103
99
|
//# sourceMappingURL=component.js.map
|