@homecode/ui 4.19.8 → 4.20.0-beta-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/esm/index.js +1 -0
- package/dist/esm/src/components/Autocomplete/Autocomplete.js +3 -1
- package/dist/esm/src/components/Draggable/Draggable.js +1 -1
- package/dist/esm/src/components/Draggable/Draggable.styl.js +2 -2
- package/dist/esm/src/components/Input/Input.js +150 -200
- package/dist/esm/src/components/Input/Input.styl.js +2 -2
- package/dist/esm/src/components/InputFile/InputFile.js +2 -1
- package/dist/esm/src/components/Notifications/Notifications.js +7 -7
- package/dist/esm/src/components/Popup/Popup.js +28 -31
- package/dist/esm/src/components/Router/Link/Link.js +4 -3
- package/dist/esm/src/components/Router/Route.js +3 -1
- package/dist/esm/src/components/Router/Router.js +4 -2
- package/dist/esm/src/components/Select/Select.js +4 -4
- package/dist/esm/src/components/Select/Select2.js +305 -0
- package/dist/esm/src/hooks/useThrottle.js +28 -0
- package/dist/esm/src/services/i18n.js +13 -7
- package/dist/esm/types/src/components/Icon/Icon.d.ts +2 -0
- package/dist/esm/types/src/components/Input/Input.d.ts +1 -42
- package/dist/esm/types/src/components/Lazy/Lazy.d.ts +1 -0
- package/dist/esm/types/src/components/Notifications/Notifications.d.ts +5 -1
- package/dist/esm/types/src/components/Popup/Popup.d.ts +8 -1
- package/dist/esm/types/src/components/Router/Link/Link.d.ts +2 -1
- package/dist/esm/types/src/components/Router/Route.d.ts +4 -4
- package/dist/esm/types/src/components/Select/Select.d.ts +1 -2
- package/dist/esm/types/src/components/Select/Select.helpers.d.ts +1 -1
- package/dist/esm/types/src/components/Select/Select.types.d.ts +5 -3
- package/dist/esm/types/src/components/Select/Select2.d.ts +2 -0
- package/dist/esm/types/src/components/index.d.ts +1 -0
- package/dist/esm/types/src/hooks/useThrottle.d.ts +5 -0
- package/dist/esm/types/src/services/i18n.d.ts +14 -4
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -28,6 +28,7 @@ export { PopupMenu } from './src/components/PopupMenu/PopupMenu.js';
|
|
|
28
28
|
export { Router, RouterContext, RouterStore } from './src/components/Router/Router.js';
|
|
29
29
|
export { RequiredStar } from './src/components/RequiredStar/RequiredStar.js';
|
|
30
30
|
export { Select, SelectHelpers } from './src/components/Select/Select.js';
|
|
31
|
+
export { Select2 } from './src/components/Select/Select2.js';
|
|
31
32
|
export { Scroll } from './src/components/Scroll/Scroll.js';
|
|
32
33
|
export { Shimmer } from './src/components/Shimmer/Shimmer.js';
|
|
33
34
|
export { Spinner } from './src/components/Spinner/Spinner.js';
|
|
@@ -45,7 +45,8 @@ import '../Portal/Portal.js';
|
|
|
45
45
|
import '../Paranja/Paranja.styl.js';
|
|
46
46
|
import '../LightBox/LightBox.styl.js';
|
|
47
47
|
import { Menu } from '../Menu/Menu.js';
|
|
48
|
-
import '../Notifications/
|
|
48
|
+
import '../Notifications/store.js';
|
|
49
|
+
import '../Notifications/Notifications.styl.js';
|
|
49
50
|
import '../PopupMenu/PopupMenu.styl.js';
|
|
50
51
|
import '../Router/Router.js';
|
|
51
52
|
import '../Table/Table.styl.js';
|
|
@@ -63,6 +64,7 @@ function Autocomplete(props) {
|
|
|
63
64
|
const [isLoading, setIsLoading] = useState(false);
|
|
64
65
|
const [isFocused, setIsFocused] = useState(false);
|
|
65
66
|
const currentRequest = useRef('');
|
|
67
|
+
// @ts-ignore
|
|
66
68
|
const inputRef = useRef(null);
|
|
67
69
|
const isOpen = options.length > 0;
|
|
68
70
|
const classes = cn(S.root, className);
|
|
@@ -129,7 +129,7 @@ class Draggable extends Component {
|
|
|
129
129
|
render() {
|
|
130
130
|
const { items, className, itemClassName, renderItem, children } = this.props;
|
|
131
131
|
const { draggingId, underId, underOffset } = this.store;
|
|
132
|
-
return (jsxs("div", { className: cn(S.root, draggingId && S.
|
|
132
|
+
return (jsxs("div", { className: cn(S.root, draggingId && S.isDragging, className), children: [items.map((id, index) => (jsx("div", { "data-id": id, className: cn(S.item, itemClassName, id === draggingId && S.active), onPointerDown: this.onPointerDown, children: jsx("div", { className: S.inner, style: underId === id ? { transform: underOffset } : null, children: renderItem(id, index, id === draggingId) }) }, id))), children] }));
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".Draggable_root__S1BgI{display:flex;flex-wrap:wrap;position:relative;touch-action:none}.Draggable_item__Z1pXk{display:flex}.Draggable_inner__c4syM{height:100%;transition:transform .2s ease-out;width:100%}.
|
|
4
|
-
var S = {"root":"Draggable_root__S1BgI","item":"Draggable_item__Z1pXk","inner":"Draggable_inner__c4syM","
|
|
3
|
+
var css_248z = ".Draggable_root__S1BgI{display:flex;flex-wrap:wrap;position:relative;touch-action:none}.Draggable_item__Z1pXk{display:flex}.Draggable_inner__c4syM{height:100%;transition:transform .2s ease-out;width:100%}.Draggable_isDragging__YTPu5 .Draggable_inner__c4syM{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.Draggable_isDragging__YTPu5 .Draggable_active__XcFM3{pointer-events:none}.Draggable_isDragging__YTPu5 .Draggable_active__XcFM3 .Draggable_inner__c4syM{transition-duration:0s;z-index:1}";
|
|
4
|
+
var S = {"root":"Draggable_root__S1BgI","item":"Draggable_item__Z1pXk","inner":"Draggable_inner__c4syM","isDragging":"Draggable_isDragging__YTPu5","active":"Draggable_active__XcFM3"};
|
|
5
5
|
styleInject(css_248z);
|
|
6
6
|
|
|
7
7
|
export { S as default };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useRef, useState, useMemo, useEffect, createElement } from 'react';
|
|
3
3
|
import cn from 'classnames';
|
|
4
|
-
import { createStore } from 'justorm/react';
|
|
5
4
|
import omit from 'lodash.omit';
|
|
6
5
|
import { Label } from '../Label/Label.js';
|
|
7
6
|
import { RequiredStar } from '../RequiredStar/RequiredStar.js';
|
|
@@ -26,6 +25,7 @@ import '../Portal/Portal.js';
|
|
|
26
25
|
import '../Paranja/Paranja.styl.js';
|
|
27
26
|
import '../Popup/Popup.styl.js';
|
|
28
27
|
import '../Select/Select.styl.js';
|
|
28
|
+
import 'justorm/react';
|
|
29
29
|
import '../Checkbox/Checkbox.styl.js';
|
|
30
30
|
import '../Container/Container.styl.js';
|
|
31
31
|
import '../DatePicker/DatePicker.styl.js';
|
|
@@ -43,7 +43,8 @@ import '../InputFile/InputFile.styl.js';
|
|
|
43
43
|
import '../InputFile/Item/Item.styl.js';
|
|
44
44
|
import '../LightBox/LightBox.styl.js';
|
|
45
45
|
import '../Menu/Menu.js';
|
|
46
|
-
import '../Notifications/
|
|
46
|
+
import '../Notifications/store.js';
|
|
47
|
+
import '../Notifications/Notifications.styl.js';
|
|
47
48
|
import '../PopupMenu/PopupMenu.styl.js';
|
|
48
49
|
import '../Router/Router.js';
|
|
49
50
|
import '../Table/Table.styl.js';
|
|
@@ -59,216 +60,154 @@ const TEXTAREA_SCROLL_TOP_OFFSET = {
|
|
|
59
60
|
m: 40,
|
|
60
61
|
l: 50,
|
|
61
62
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
prevLabelText = '';
|
|
67
|
-
store;
|
|
68
|
-
uid = generateUID();
|
|
69
|
-
static defaultProps = {
|
|
70
|
-
type: 'text',
|
|
71
|
-
size: 'm',
|
|
72
|
-
variant: 'default',
|
|
73
|
-
};
|
|
74
|
-
constructor(props) {
|
|
75
|
-
super(props);
|
|
76
|
-
const inputValue = props.value ?? props.defaultValue ?? '';
|
|
77
|
-
const hasValue = this.hasValue(inputValue);
|
|
78
|
-
this.store = createStore(this, {
|
|
79
|
-
isFocused: false,
|
|
80
|
-
isLabelOnTop: this.isLabelOnTop(hasValue),
|
|
81
|
-
inputValue,
|
|
82
|
-
hasValue,
|
|
83
|
-
labelClipPath: '',
|
|
84
|
-
autoComplete: null,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
componentDidMount() {
|
|
88
|
-
document.addEventListener('keyup', this.onDocKeyUp, true);
|
|
89
|
-
if (this.isTextArea()) {
|
|
90
|
-
this.inputRef.current.innerText = this.store.inputValue;
|
|
91
|
-
document.addEventListener('paste', this.onTextareaPaste, true);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
componentDidUpdate(prevProps) {
|
|
95
|
-
const { value } = this.props;
|
|
96
|
-
this.updateSelection();
|
|
97
|
-
this.updateAutoComplete();
|
|
98
|
-
if (value !== prevProps.value && value !== this.store.inputValue) {
|
|
99
|
-
this.store.inputValue = value;
|
|
100
|
-
// @ts-ignore
|
|
101
|
-
if (this.isTextArea())
|
|
102
|
-
this.inputRef.current.innerText = value;
|
|
103
|
-
this.updateHasValue();
|
|
104
|
-
this.updateLabelPosition();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
updateAutoComplete() {
|
|
108
|
-
const form = this.inputRef.current?.closest('form');
|
|
63
|
+
const Input = (props) => {
|
|
64
|
+
const { type = 'text', size = 'm', variant = 'default', value, defaultValue = '', onChange, onFocus, onBlur, onClear, onInput, changeOnEnd, checkAutofill, hasClear, required, hideRequiredStar, disabled, error, label, placeholder, addonLeft, addonRight, forceLabelOnTop, scrollProps, step = 1, round, className, } = props;
|
|
65
|
+
const updateAutoComplete = () => {
|
|
66
|
+
const form = inputRef.current?.closest('form');
|
|
109
67
|
const val = form?.getAttribute('autocomplete');
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
updateSelection() {
|
|
114
|
-
const { type } =
|
|
115
|
-
const
|
|
116
|
-
const elem = this.inputRef.current;
|
|
68
|
+
if (autoComplete !== val)
|
|
69
|
+
setAutoComplete(val);
|
|
70
|
+
};
|
|
71
|
+
const updateSelection = () => {
|
|
72
|
+
const { type } = props;
|
|
73
|
+
const elem = inputRef.current;
|
|
117
74
|
if (!isFocused || !elem || type !== 'text')
|
|
118
75
|
return;
|
|
119
|
-
elem.selectionStart =
|
|
120
|
-
elem.selectionEnd =
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
getValue(val =
|
|
139
|
-
const { type } = this.props;
|
|
76
|
+
elem.selectionStart = cursorPos.current;
|
|
77
|
+
elem.selectionEnd = cursorPos.current;
|
|
78
|
+
};
|
|
79
|
+
const inputRef = useRef(null);
|
|
80
|
+
const isFocusedRef = useRef(false);
|
|
81
|
+
const [isFocused, _setIsFocused] = useState(false);
|
|
82
|
+
const setIsFocused = (val) => {
|
|
83
|
+
isFocusedRef.current = val;
|
|
84
|
+
_setIsFocused(val);
|
|
85
|
+
};
|
|
86
|
+
const [inputValue, setInputValue] = useState((value ?? defaultValue ?? ''));
|
|
87
|
+
const [labelClipPath, setLabelClipPath] = useState('');
|
|
88
|
+
const [autoComplete, setAutoComplete] = useState('');
|
|
89
|
+
const uid = generateUID();
|
|
90
|
+
const isTextArea = type === 'textarea';
|
|
91
|
+
const isNumber = type === 'number';
|
|
92
|
+
const hasValue = isNumber || Boolean(value || inputValue || defaultValue);
|
|
93
|
+
const isLabelOnTop = forceLabelOnTop || Boolean(addonLeft) || hasValue || isFocused;
|
|
94
|
+
const cursorPos = useRef(0);
|
|
95
|
+
const getValue = (val = inputValue) => {
|
|
140
96
|
if (type === 'number') {
|
|
141
97
|
if (val)
|
|
142
98
|
return parseFloat(val);
|
|
143
99
|
return 0;
|
|
144
100
|
}
|
|
145
|
-
if (
|
|
146
|
-
return
|
|
101
|
+
if (isTextArea)
|
|
102
|
+
return inputRef.current.innerText.replace(/\n/g, '');
|
|
147
103
|
return val;
|
|
148
|
-
}
|
|
149
|
-
onTextareaPaste = e => {
|
|
150
|
-
if (!
|
|
104
|
+
};
|
|
105
|
+
const onTextareaPaste = e => {
|
|
106
|
+
if (!isFocusedRef.current)
|
|
151
107
|
return;
|
|
152
108
|
e.preventDefault();
|
|
153
109
|
e.stopPropagation();
|
|
154
|
-
|
|
110
|
+
pasteToTextarea(e.clipboardData.getData('text/plain'));
|
|
111
|
+
};
|
|
112
|
+
const setTextareaValue = (value) => {
|
|
113
|
+
// @ts-ignore
|
|
114
|
+
if (inputRef.current)
|
|
115
|
+
inputRef.current.innerText = value;
|
|
155
116
|
};
|
|
156
|
-
pasteToTextarea = debounce((text) => {
|
|
157
|
-
console.log('onTextareaPaste');
|
|
117
|
+
const pasteToTextarea = debounce((text) => {
|
|
158
118
|
const sel = window.getSelection();
|
|
159
|
-
const textarea =
|
|
119
|
+
const textarea = inputRef.current;
|
|
160
120
|
const prevText = textarea.innerText;
|
|
161
|
-
|
|
162
|
-
const startPos = sel.extentOffset;
|
|
121
|
+
const startPos = sel.getRangeAt(0).startOffset;
|
|
163
122
|
const nextText = prevText.substring(0, startPos) + text + prevText.substring(startPos);
|
|
164
123
|
textarea.innerText = nextText;
|
|
165
|
-
|
|
124
|
+
onChangeValue(nextText);
|
|
125
|
+
setTimeout(() => {
|
|
126
|
+
try {
|
|
127
|
+
window
|
|
128
|
+
.getSelection()
|
|
129
|
+
.setPosition(textarea.firstChild, startPos + text.length);
|
|
130
|
+
}
|
|
131
|
+
catch (e) { }
|
|
132
|
+
}, 100);
|
|
166
133
|
}, 100);
|
|
167
|
-
onClearPress = e => {
|
|
168
|
-
const { onChange, onClear } = this.props;
|
|
169
|
-
this.isTextArea();
|
|
134
|
+
const onClearPress = e => {
|
|
170
135
|
e.preventDefault();
|
|
171
136
|
e.stopPropagation();
|
|
172
137
|
onClear?.();
|
|
173
|
-
if (
|
|
174
|
-
|
|
138
|
+
if (isTextArea) {
|
|
139
|
+
inputRef.current.innerText = '';
|
|
175
140
|
}
|
|
176
141
|
if (onChange) {
|
|
177
|
-
|
|
142
|
+
onChangeValue('');
|
|
178
143
|
}
|
|
179
144
|
else {
|
|
180
|
-
if (!
|
|
181
|
-
|
|
145
|
+
if (!isTextArea) {
|
|
146
|
+
inputRef.current.value = '';
|
|
182
147
|
}
|
|
183
148
|
}
|
|
184
|
-
|
|
149
|
+
inputRef.current?.focus();
|
|
185
150
|
};
|
|
186
|
-
onDocKeyUp = (e) => {
|
|
187
|
-
const { changeOnEnd } =
|
|
188
|
-
const { isFocused } = this.store;
|
|
151
|
+
const onDocKeyUp = (e) => {
|
|
152
|
+
const { changeOnEnd } = props;
|
|
189
153
|
if (changeOnEnd && e.key === 'Enter') {
|
|
190
154
|
e.preventDefault();
|
|
191
155
|
e.stopPropagation();
|
|
192
|
-
|
|
156
|
+
onTypingEnd();
|
|
193
157
|
}
|
|
194
158
|
if (isFocused && e.key === 'Escape') {
|
|
195
159
|
e.preventDefault();
|
|
196
160
|
e.stopPropagation();
|
|
197
|
-
|
|
161
|
+
inputRef.current?.blur();
|
|
198
162
|
}
|
|
199
163
|
};
|
|
200
|
-
handleChange = (e) => {
|
|
201
|
-
const
|
|
202
|
-
|
|
164
|
+
const handleChange = (e) => {
|
|
165
|
+
const val = getValue(e.target.value);
|
|
166
|
+
onChangeValue(val, e);
|
|
203
167
|
};
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (!isNumber)
|
|
208
|
-
this.cursorPos = this.inputRef.current.selectionStart;
|
|
209
|
-
if (changeOnEnd) {
|
|
210
|
-
this.store.inputValue = value;
|
|
211
|
-
this.updateHasValue();
|
|
212
|
-
}
|
|
213
|
-
else if (onChange) {
|
|
214
|
-
onChange(e, value);
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
this.store.inputValue = value;
|
|
168
|
+
const onChangeValue = (value, e) => {
|
|
169
|
+
if (!isNumber && inputRef.current) {
|
|
170
|
+
cursorPos.current = inputRef.current.selectionStart;
|
|
218
171
|
}
|
|
172
|
+
setInputValue(value);
|
|
173
|
+
onChange?.(e, value);
|
|
219
174
|
};
|
|
220
|
-
onNumberWheel = delta => {
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
this.onChange(value);
|
|
175
|
+
const onNumberWheel = delta => {
|
|
176
|
+
const value = getValue() + step * delta;
|
|
177
|
+
onChangeValue(value);
|
|
224
178
|
onChange?.(null, value);
|
|
225
179
|
};
|
|
226
|
-
onTextAreaInput = e => {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
this.updateHasValue();
|
|
230
|
-
this.handleChange(e);
|
|
180
|
+
const onTextAreaInput = e => {
|
|
181
|
+
setInputValue(e.target.innerText);
|
|
182
|
+
handleChange(e);
|
|
231
183
|
onInput?.(e);
|
|
232
184
|
};
|
|
233
|
-
onLabelClipPathChange = (clipPath) => (
|
|
234
|
-
onTypingEnd = () => {
|
|
235
|
-
|
|
236
|
-
onChange?.(null, this.getValue());
|
|
185
|
+
const onLabelClipPathChange = (clipPath) => setLabelClipPath(clipPath);
|
|
186
|
+
const onTypingEnd = () => {
|
|
187
|
+
onChange?.(null, getValue());
|
|
237
188
|
};
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
this.store.isFocused = true;
|
|
241
|
-
this.updateLabelPosition();
|
|
189
|
+
const handleFocus = e => {
|
|
190
|
+
setIsFocused(true);
|
|
242
191
|
onFocus?.(e);
|
|
243
192
|
};
|
|
244
|
-
|
|
245
|
-
if (
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
// @ts-ignore
|
|
252
|
-
const val = this.getValue(e?.target?.value);
|
|
253
|
-
const { onBlur, onChange, value, checkAutofill } = this.props;
|
|
254
|
-
this.store.isFocused = false;
|
|
255
|
-
this.updateLabelPosition();
|
|
256
|
-
// some browsers not fire `onchange` after autofill
|
|
193
|
+
const handleBlur = e => {
|
|
194
|
+
if (changeOnEnd)
|
|
195
|
+
onTypingEnd();
|
|
196
|
+
const val = getValue(e?.target?.value);
|
|
197
|
+
setIsFocused(false);
|
|
257
198
|
if (checkAutofill && onChange && !value && val)
|
|
258
199
|
onChange(null, val);
|
|
259
200
|
if (onBlur)
|
|
260
201
|
onBlur(e);
|
|
261
202
|
};
|
|
262
|
-
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
const props = {
|
|
266
|
-
...omit(rest, [
|
|
203
|
+
const controlProps = useMemo(() => {
|
|
204
|
+
const controlProps = {
|
|
205
|
+
...omit(props, [
|
|
267
206
|
'className',
|
|
268
207
|
'clear',
|
|
269
208
|
'onClear',
|
|
270
209
|
'hasClear',
|
|
271
|
-
|
|
210
|
+
'placeholder',
|
|
272
211
|
'hideRequiredStar',
|
|
273
212
|
'size',
|
|
274
213
|
'error',
|
|
@@ -280,31 +219,30 @@ class Input extends Component {
|
|
|
280
219
|
'scrollProps',
|
|
281
220
|
]),
|
|
282
221
|
value: inputValue,
|
|
283
|
-
...controlProps,
|
|
284
|
-
onChange:
|
|
285
|
-
onFocus:
|
|
286
|
-
onBlur:
|
|
222
|
+
...props.controlProps,
|
|
223
|
+
onChange: handleChange,
|
|
224
|
+
onFocus: handleFocus,
|
|
225
|
+
onBlur: handleBlur,
|
|
287
226
|
};
|
|
288
|
-
if (
|
|
289
|
-
|
|
290
|
-
|
|
227
|
+
if (isTextArea) {
|
|
228
|
+
controlProps.contentEditable = true;
|
|
229
|
+
controlProps.onInput = onTextAreaInput;
|
|
291
230
|
}
|
|
292
|
-
if (placeholder && !
|
|
293
|
-
|
|
231
|
+
if (placeholder && !inputValue && (!label || isLabelOnTop)) {
|
|
232
|
+
controlProps.placeholder = placeholder;
|
|
294
233
|
}
|
|
295
234
|
if (!autoComplete) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
delete
|
|
235
|
+
controlProps.suppressHydrationWarning = true;
|
|
236
|
+
controlProps.autoComplete = uid;
|
|
237
|
+
delete controlProps.name;
|
|
299
238
|
}
|
|
300
|
-
if (
|
|
301
|
-
|
|
302
|
-
return
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
if (
|
|
306
|
-
const { size
|
|
307
|
-
const { labelClipPath } = this.store;
|
|
239
|
+
if (controlProps.value === undefined)
|
|
240
|
+
controlProps.value = ' ';
|
|
241
|
+
return controlProps;
|
|
242
|
+
}, [value, isLabelOnTop, inputValue]);
|
|
243
|
+
const wrapControl = control => {
|
|
244
|
+
if (isTextArea) {
|
|
245
|
+
const { size } = props;
|
|
308
246
|
return (createElement(Scroll, { y: true, size: size, fadeSize: "s", className: cn(S.scroller, S.controlWrapper, scrollProps?.className), offset: {
|
|
309
247
|
y: { before: TEXTAREA_SCROLL_TOP_OFFSET[size], after: 20 },
|
|
310
248
|
}, ...scrollProps, innerProps: {
|
|
@@ -313,36 +251,48 @@ class Input extends Component {
|
|
|
313
251
|
}, key: "scroller" }, control));
|
|
314
252
|
}
|
|
315
253
|
return jsx("div", { className: S.controlWrapper, children: control });
|
|
316
|
-
}
|
|
317
|
-
renderAddon(type) {
|
|
254
|
+
};
|
|
255
|
+
const renderAddon = (type) => {
|
|
318
256
|
const name = `addon${capitalize(type)}`;
|
|
319
|
-
const content =
|
|
257
|
+
const content = props[name];
|
|
320
258
|
if (!content)
|
|
321
259
|
return null;
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
className: cn(S[name], this.props[`${name}ClassName`]),
|
|
260
|
+
const addonProps = {
|
|
261
|
+
className: cn(S[name], props[`${name}ClassName`]),
|
|
325
262
|
key: name,
|
|
326
263
|
};
|
|
327
264
|
const isString = typeof content === 'string';
|
|
328
265
|
const elem = isString ? jsx("span", { children: content }) : content;
|
|
329
266
|
// @ts-ignore
|
|
330
267
|
if (isString)
|
|
331
|
-
|
|
332
|
-
return jsx("div", { ...
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
268
|
+
addonProps.title = content;
|
|
269
|
+
return jsx("div", { ...addonProps, children: elem });
|
|
270
|
+
};
|
|
271
|
+
useEffect(() => {
|
|
272
|
+
document.addEventListener('keydown', onDocKeyUp);
|
|
273
|
+
if (isTextArea) {
|
|
274
|
+
inputRef.current.addEventListener('paste', onTextareaPaste);
|
|
275
|
+
}
|
|
276
|
+
return () => {
|
|
277
|
+
document.removeEventListener('keydown', onDocKeyUp);
|
|
278
|
+
inputRef.current?.removeEventListener('paste', onTextareaPaste);
|
|
279
|
+
};
|
|
280
|
+
}, [isTextArea]);
|
|
281
|
+
useEffect(() => {
|
|
282
|
+
updateSelection();
|
|
283
|
+
updateAutoComplete();
|
|
284
|
+
if (value !== inputValue) {
|
|
285
|
+
setInputValue(value);
|
|
286
|
+
// setTextareaValue(String(value));
|
|
287
|
+
}
|
|
288
|
+
}, [value]);
|
|
289
|
+
useEffect(() => {
|
|
290
|
+
if (isTextArea)
|
|
291
|
+
setTextareaValue(String(value));
|
|
292
|
+
}, []);
|
|
293
|
+
const Control = isTextArea ? 'span' : 'input';
|
|
294
|
+
const classes = cn(S.root, isTextArea && S.isTextArea, S[`size-${size}`], S[`variant-${variant}`], isFocused && S.isFocused, error && S.hasError, hasClear && S.hasClear, disabled && S.isDisabled, round && S.round, className);
|
|
295
|
+
return (jsxs("div", { className: classes, title: String(value), children: [jsxs("label", { className: S.main, children: [jsx("div", { className: S.border, suppressHydrationWarning: true, style: { clipPath: labelClipPath } }, "border"), renderAddon('left'), wrapControl(jsxs(Fragment, { children: [createElement(Control, { ...controlProps, className: cn(S.control, controlProps?.className), ref: inputRef, key: "control" }), isTextArea && controlProps.placeholder && !controlProps.value && (jsx("span", { className: S.placeholder, spellCheck: false, children: controlProps.placeholder }))] })), isNumber && (jsxs("div", { className: S.numberArrows, children: [jsx(Button, { variant: "clear", onClick: () => onNumberWheel(1), tabIndex: -1, children: jsx(Icon, { type: "chevronUp", size: size }) }), jsx(Button, { variant: "clear", onClick: () => onNumberWheel(-1), tabIndex: -1, children: jsx(Icon, { type: "chevronDown", size: size }) })] })), jsx(Label, { className: cn(S.label, addonRight && S.hasAddonRight), size: size, isOnTop: isLabelOnTop, isError: Boolean(error), onClipPathChange: onLabelClipPathChange, children: label }, "label"), renderAddon('right'), required && !hideRequiredStar && (jsx(RequiredStar, { size: size }, "required-star"))] }, "main"), hasClear && !disabled && hasValue && (jsx(Button, { className: S.clearButton, variant: "clear", size: size, square: true, onClick: onClearPress, title: "", children: jsx(Icon, { className: S.clearIcon, size: size, type: "close" }) }, "clear")), !disabled && typeof error === 'string' && (jsx(AssistiveText, { variant: "danger", size: size, children: error }, "assistive-text"))] }));
|
|
296
|
+
};
|
|
347
297
|
|
|
348
298
|
export { Input };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styleInject from '../../../node_modules/style-inject/dist/style-inject.es.js';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".Input_root__kj4vQ{color:var(--accent-color);position:relative}.Input_root__kj4vQ.Input_isTextArea__1a6n1{max-height:10em}.Input_main__M6Qxb,.Input_root__kj4vQ{width:100%}.Input_controlWrapper__WgrZL,.Input_root__kj4vQ{max-width:100%}.Input_main__M6Qxb{border-radius:inherit;display:flex;max-width:100%;position:relative}.Input_isTextArea__1a6n1 .Input_main__M6Qxb{height:auto;max-height:inherit!important}.Input_size-s__-U0r-.Input_isTextArea__1a6n1 .Input_main__M6Qxb{padding-right:5px!important}.Input_size-m__jTEMl.Input_isTextArea__1a6n1 .Input_main__M6Qxb{padding-right:7px!important}.Input_size-l__BR-zg.Input_isTextArea__1a6n1 .Input_main__M6Qxb{padding-right:11px!important}.Input_border__01i-B{background-color:var(--accent-color-alpha-100);border-radius:inherit;bottom:0;left:0;pointer-events:none;position:absolute;right:0;top:0;transition:.15s ease-out;transition-property:box-shadow,border-color,background-color;z-index:0}.Input_root__kj4vQ:hover .Input_border__01i-B{background-color:var(--active-color-alpha-100)}.Input_variant-clean__yjtdm .Input_border__01i-B{background-color:transparent}.Input_isFocused__9jtFN.Input_variant-clean__yjtdm .Input_border__01i-B{background-color:var(--active-color-alpha-300)}.Input_variant-default__frNbg .Input_border__01i-B{background-color:var(--accent-color-alpha-100)}.Input_isFocused__9jtFN.Input_variant-default__frNbg .Input_border__01i-B{background-color:var(--active-color-alpha-300)}.Input_variant-outlined__qKjnJ .Input_border__01i-B{background-color:transparent;box-shadow:inset 0 0 0 2px var(--accent-color)}.Input_isFocused__9jtFN.Input_variant-outlined__qKjnJ .Input_border__01i-B{background-color:var(--active-color-alpha-300);box-shadow:inset 0 0 0 2px var(--active-color)}.Input_hasError__5iS2M .Input_variant-outlined__qKjnJ .Input_border__01i-B,.Input_hasError__5iS2M:hover .Input_variant-outlined__qKjnJ .Input_border__01i-B{box-shadow:inset 0 0 0 2px var(--danger-color)}.Input_isDisabled__e7J10.Input_variant-outlined__qKjnJ .Input_border__01i-B{box-shadow:none}.Input_size-s__-U0r-{font-size:16px}.Input_size-s__-U0r- .Input_main__M6Qxb{border-radius:4px;font-size:16px;min-height:30px;min-width:30px;padding:0 14px}.Input_round__yJr-2.Input_size-s__-U0r- .Input_main__M6Qxb{border-radius:15px}.Input_size-m__jTEMl{font-size:20px}.Input_size-m__jTEMl .Input_main__M6Qxb{border-radius:6px;font-size:20px;min-height:40px;min-width:40px;padding:0 16px}.Input_round__yJr-2.Input_size-m__jTEMl .Input_main__M6Qxb{border-radius:20px}.Input_size-l__BR-zg{font-size:24px}.Input_size-l__BR-zg .Input_main__M6Qxb{border-radius:8px;font-size:24px;min-height:50px;min-width:50px;padding:0 18px}.Input_round__yJr-2.Input_size-l__BR-zg .Input_main__M6Qxb{border-radius:25px}.
|
|
4
|
-
var S = {"root":"Input_root__kj4vQ","isTextArea":"Input_isTextArea__1a6n1","main":"Input_main__M6Qxb","controlWrapper":"Input_controlWrapper__WgrZL","size-s":"Input_size-s__-U0r-","size-m":"Input_size-m__jTEMl","size-l":"Input_size-l__BR-zg","border":"Input_border__01i-B","variant-clean":"Input_variant-clean__yjtdm","isFocused":"Input_isFocused__9jtFN","variant-default":"Input_variant-default__frNbg","variant-outlined":"Input_variant-outlined__qKjnJ","hasError":"Input_hasError__5iS2M","isDisabled":"Input_isDisabled__e7J10","round":"Input_round__yJr-2","control":"Input_control__wZcMD","addonLeft":"Input_addonLeft__i1c70","addonRight":"Input_addonRight__A9Iht","labelGap":"Input_labelGap__T6fAj","label":"Input_label__FT90l","hasAddonRight":"Input_hasAddonRight__ckzfA","scroller":"Input_scroller__OBm8M","
|
|
3
|
+
var css_248z = ".Input_root__kj4vQ{color:var(--accent-color);position:relative}.Input_root__kj4vQ.Input_isTextArea__1a6n1{max-height:10em}.Input_main__M6Qxb,.Input_root__kj4vQ{width:100%}.Input_controlWrapper__WgrZL,.Input_root__kj4vQ{max-width:100%}.Input_main__M6Qxb{border-radius:inherit;display:flex;max-width:100%;position:relative}.Input_isTextArea__1a6n1 .Input_main__M6Qxb{height:auto;max-height:inherit!important}.Input_size-s__-U0r-.Input_isTextArea__1a6n1 .Input_main__M6Qxb{padding-right:5px!important}.Input_size-m__jTEMl.Input_isTextArea__1a6n1 .Input_main__M6Qxb{padding-right:7px!important}.Input_size-l__BR-zg.Input_isTextArea__1a6n1 .Input_main__M6Qxb{padding-right:11px!important}.Input_border__01i-B{background-color:var(--accent-color-alpha-100);border-radius:inherit;bottom:0;left:0;pointer-events:none;position:absolute;right:0;top:0;transition:.15s ease-out;transition-property:box-shadow,border-color,background-color;z-index:0}.Input_root__kj4vQ:hover .Input_border__01i-B{background-color:var(--active-color-alpha-100)}.Input_variant-clean__yjtdm .Input_border__01i-B{background-color:transparent}.Input_isFocused__9jtFN.Input_variant-clean__yjtdm .Input_border__01i-B{background-color:var(--active-color-alpha-300)}.Input_variant-default__frNbg .Input_border__01i-B{background-color:var(--accent-color-alpha-100)}.Input_isFocused__9jtFN.Input_variant-default__frNbg .Input_border__01i-B{background-color:var(--active-color-alpha-300)}.Input_variant-outlined__qKjnJ .Input_border__01i-B{background-color:transparent;box-shadow:inset 0 0 0 2px var(--accent-color)}.Input_isFocused__9jtFN.Input_variant-outlined__qKjnJ .Input_border__01i-B{background-color:var(--active-color-alpha-300);box-shadow:inset 0 0 0 2px var(--active-color)}.Input_hasError__5iS2M .Input_variant-outlined__qKjnJ .Input_border__01i-B,.Input_hasError__5iS2M:hover .Input_variant-outlined__qKjnJ .Input_border__01i-B{box-shadow:inset 0 0 0 2px var(--danger-color)}.Input_isDisabled__e7J10.Input_variant-outlined__qKjnJ .Input_border__01i-B{box-shadow:none}.Input_size-s__-U0r-{font-size:16px}.Input_size-s__-U0r- .Input_main__M6Qxb{border-radius:4px;font-size:16px;min-height:30px;min-width:30px;padding:0 14px}.Input_round__yJr-2.Input_size-s__-U0r- .Input_main__M6Qxb{border-radius:15px}.Input_size-m__jTEMl{font-size:20px}.Input_size-m__jTEMl .Input_main__M6Qxb{border-radius:6px;font-size:20px;min-height:40px;min-width:40px;padding:0 16px}.Input_round__yJr-2.Input_size-m__jTEMl .Input_main__M6Qxb{border-radius:20px}.Input_size-l__BR-zg{font-size:24px}.Input_size-l__BR-zg .Input_main__M6Qxb{border-radius:8px;font-size:24px;min-height:50px;min-width:50px;padding:0 18px}.Input_round__yJr-2.Input_size-l__BR-zg .Input_main__M6Qxb{border-radius:25px}.Input_isDisabled__e7J10{color:var(--accent-color-alpha-500);opacity:.4}.Input_addonLeft__i1c70,.Input_addonRight__A9Iht,.Input_control__wZcMD{font-size:inherit;font-weight:400}.Input_labelGap__T6fAj{opacity:0;pointer-events:none;position:absolute}.Input_label__FT90l.Input_hasAddonRight__ckzfA{padding-right:2em}.Input_isTextArea__1a6n1 .Input_label__FT90l{max-height:40px}.Input_scroller__OBm8M{max-height:100%;width:100%}.Input_controlWrapper__WgrZL{flex:1}.Input_control__wZcMD{-webkit-appearance:none;-moz-appearance:none;appearance:none;background:none;box-shadow:none;box-shadow:inset 0 0 0 2px none;color:inherit;display:inline-flex;filter:none;flex-grow:1;height:100%;min-width:30px;position:relative;text-overflow:ellipsis;transition:border-color .15s ease-in-out 0s;width:100%}.Input_control__wZcMD:-internal-autofill-selected,.Input_control__wZcMD:-webkit-autofill{animation-fill-mode:both;animation-name:Input_clearBg__jqI1h}.Input_size-s__-U0r-.Input_hasClear__5Y3nU .Input_control__wZcMD{padding-right:20px}.Input_size-m__jTEMl.Input_hasClear__5Y3nU .Input_control__wZcMD{padding-right:24px}.Input_size-l__BR-zg.Input_hasClear__5Y3nU .Input_control__wZcMD{padding-right:28px}.Input_control__wZcMD::-moz-placeholder{color:var(--accent-color-alpha-500)}.Input_control__wZcMD::placeholder{color:var(--accent-color-alpha-500)}.Input_control__wZcMD::-moz-selection{background-color:var(--active-color-alpha-300)}.Input_control__wZcMD::selection{background-color:var(--active-color-alpha-300)}.Input_isTextArea__1a6n1 .Input_control__wZcMD{display:block;height:100%;min-height:100%;width:100%}.Input_isTextArea__1a6n1 .Input_control__wZcMD:hover{cursor:text}.Input_isTextArea__1a6n1 .Input_control__wZcMD:after{content:\"\";display:block}.Input_control__wZcMD[type=number]{-moz-appearance:textfield;margin-right:14px}.Input_control__wZcMD[type=number]::-webkit-inner-spin-button,.Input_control__wZcMD[type=number]::-webkit-outer-spin-button{-webkit-appearance:none}.Input_numberArrows__8jveR{display:flex;flex-direction:column;height:100%;position:absolute;right:0}.Input_numberArrows__8jveR>button{background-color:transparent!important;height:50%;max-height:none;min-height:0;min-height:auto;opacity:.5;padding-left:0;padding-right:0;transition:opacity .1s ease-out;width:50%}.Input_numberArrows__8jveR>button:hover{opacity:1}.Input_size-s__-U0r- .Input_numberArrows__8jveR>button{min-width:24px}.Input_size-m__jTEMl .Input_numberArrows__8jveR>button{min-width:32px}.Input_size-l__BR-zg .Input_numberArrows__8jveR>button{min-width:40px}.Input_numberArrows__8jveR>button>svg{transform:scale(.8)}.Input_numberArrows__8jveR>button:first-child>svg{margin-bottom:-5%}.Input_numberArrows__8jveR>button:last-child>svg{margin-top:-5%}.Input_isTextArea__1a6n1 .Input_control__wZcMD,.Input_isTextArea__1a6n1 .Input_placeholder__DRYLA{padding-left:0!important}.Input_size-s__-U0r-.Input_isTextArea__1a6n1 .Input_control__wZcMD,.Input_size-s__-U0r-.Input_isTextArea__1a6n1 .Input_placeholder__DRYLA{padding:8px 16px 0 14px}.Input_size-s__-U0r-.Input_isTextArea__1a6n1 .Input_control__wZcMD:after,.Input_size-s__-U0r-.Input_isTextArea__1a6n1 .Input_placeholder__DRYLA:after{height:8px}.Input_size-m__jTEMl.Input_isTextArea__1a6n1 .Input_control__wZcMD,.Input_size-m__jTEMl.Input_isTextArea__1a6n1 .Input_placeholder__DRYLA{padding:10px 20px 0 16px}.Input_size-m__jTEMl.Input_isTextArea__1a6n1 .Input_control__wZcMD:after,.Input_size-m__jTEMl.Input_isTextArea__1a6n1 .Input_placeholder__DRYLA:after{height:10px}.Input_size-l__BR-zg.Input_isTextArea__1a6n1 .Input_control__wZcMD,.Input_size-l__BR-zg.Input_isTextArea__1a6n1 .Input_placeholder__DRYLA{padding:12px 24px 0 18px}.Input_size-l__BR-zg.Input_isTextArea__1a6n1 .Input_control__wZcMD:after,.Input_size-l__BR-zg.Input_isTextArea__1a6n1 .Input_placeholder__DRYLA:after{height:12px}.Input_placeholder__DRYLA{display:inline-block;left:0;max-width:100%;opacity:.4;overflow:hidden;padding:inherit;pointer-events:none;position:absolute;text-overflow:ellipsis;top:0;white-space:nowrap}.Input_addonLeft__i1c70,.Input_addonRight__A9Iht{align-items:center;display:inline-flex;flex-shrink:0;min-width:0;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:1}.Input_addonLeft__i1c70>span,.Input_addonRight__A9Iht>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.Input_size-s__-U0r- .Input_addonLeft__i1c70{margin-right:calc(var(--indent-s)/2)}.Input_size-m__jTEMl .Input_addonLeft__i1c70{margin-right:calc(var(--indent-m)/2)}.Input_size-l__BR-zg .Input_addonLeft__i1c70{margin-right:calc(var(--indent-l)/2)}.Input_size-s__-U0r- .Input_addonRight__A9Iht{margin-left:calc(var(--indent-s)/2)}.Input_size-m__jTEMl .Input_addonRight__A9Iht{margin-left:calc(var(--indent-m)/2)}.Input_size-l__BR-zg .Input_addonRight__A9Iht{margin-left:calc(var(--indent-l)/2)}.Input_requiredStar__6MeQ4{background-color:var(--warning-color);border-radius:50%;height:8px;opacity:.8;pointer-events:none;position:absolute;width:8px}.Input_isDisabled__e7J10 .Input_requiredStar__6MeQ4{display:none}.Input_size-s__-U0r- .Input_requiredStar__6MeQ4{right:4px;top:4px}.Input_size-m__jTEMl .Input_requiredStar__6MeQ4{right:6px;top:6px}.Input_size-l__BR-zg .Input_requiredStar__6MeQ4{right:8px;top:8px}.Input_isDisabled__e7J10{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.Input_clearButton__0E-9L{border-bottom-left-radius:0;border-top-left-radius:0;bottom:1px;height:auto;position:absolute;right:0;top:0;z-index:1}.Input_clearButton__0E-9L:hover{background-color:var(--accent-color-alpha-0)!important}.Input_clearIcon__Gi1Nc{flex-shrink:0;opacity:.3;transition:opacity .2s ease-out}.Input_clearButton__0E-9L:hover .Input_clearIcon__Gi1Nc{opacity:.8}.Input_size-s__-U0r- .Input_clearIcon__Gi1Nc{height:10px;width:10px}.Input_size-m__jTEMl .Input_clearIcon__Gi1Nc{height:12px;width:12px}.Input_size-l__BR-zg .Input_clearIcon__Gi1Nc{height:14px;width:14px}.Input_size-xl__o-R-1 .Input_clearIcon__Gi1Nc{height:16px;width:16px}";
|
|
4
|
+
var S = {"root":"Input_root__kj4vQ","isTextArea":"Input_isTextArea__1a6n1","main":"Input_main__M6Qxb","controlWrapper":"Input_controlWrapper__WgrZL","size-s":"Input_size-s__-U0r-","size-m":"Input_size-m__jTEMl","size-l":"Input_size-l__BR-zg","border":"Input_border__01i-B","variant-clean":"Input_variant-clean__yjtdm","isFocused":"Input_isFocused__9jtFN","variant-default":"Input_variant-default__frNbg","variant-outlined":"Input_variant-outlined__qKjnJ","hasError":"Input_hasError__5iS2M","isDisabled":"Input_isDisabled__e7J10","round":"Input_round__yJr-2","control":"Input_control__wZcMD","addonLeft":"Input_addonLeft__i1c70","addonRight":"Input_addonRight__A9Iht","labelGap":"Input_labelGap__T6fAj","label":"Input_label__FT90l","hasAddonRight":"Input_hasAddonRight__ckzfA","scroller":"Input_scroller__OBm8M","clearBg":"Input_clearBg__jqI1h","hasClear":"Input_hasClear__5Y3nU","numberArrows":"Input_numberArrows__8jveR","placeholder":"Input_placeholder__DRYLA","requiredStar":"Input_requiredStar__6MeQ4","clearButton":"Input_clearButton__0E-9L","clearIcon":"Input_clearIcon__Gi1Nc","size-xl":"Input_size-xl__o-R-1"};
|
|
5
5
|
styleInject(css_248z);
|
|
6
6
|
|
|
7
7
|
export { S as default };
|
|
@@ -43,7 +43,8 @@ import '../Gallery/Gallery.styl.js';
|
|
|
43
43
|
import '../Heading/Heading.js';
|
|
44
44
|
import '../LightBox/LightBox.styl.js';
|
|
45
45
|
import '../Menu/Menu.js';
|
|
46
|
-
import '../Notifications/
|
|
46
|
+
import '../Notifications/store.js';
|
|
47
|
+
import '../Notifications/Notifications.styl.js';
|
|
47
48
|
import '../PopupMenu/PopupMenu.styl.js';
|
|
48
49
|
import '../Router/Router.js';
|
|
49
50
|
import '../Table/Table.styl.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createElement, Component } from 'react';
|
|
2
2
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
3
|
import cn from 'classnames';
|
|
4
|
-
import {
|
|
4
|
+
import { useStore } from 'justorm/react';
|
|
5
5
|
import { Icon } from '../Icon/Icon.js';
|
|
6
6
|
import { Button } from '../Button/Button.js';
|
|
7
7
|
import { Scroll } from '../Scroll/Scroll.js';
|
|
@@ -54,14 +54,14 @@ class Item extends Component {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
const NotificationsStore = STORE;
|
|
57
|
-
const Notifications =
|
|
58
|
-
notifications
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
const Notifications = function Notifications(props) {
|
|
58
|
+
const { notifications } = useStore({
|
|
59
|
+
notifications: ['items', 'data'],
|
|
60
|
+
});
|
|
61
61
|
const { items, data, pause, unpause, close } = notifications;
|
|
62
62
|
const api = { pause, unpause, close };
|
|
63
63
|
const classes = cn(S.root, items.length === 0 && S.empty);
|
|
64
|
-
return (jsx(Scroll, { ...
|
|
65
|
-
}
|
|
64
|
+
return (jsx(Scroll, { ...props, y: true, size: "s", className: classes, innerClassName: S.inner, offset: { y: { before: 22, after: 22 } }, children: items.map(id => (createElement(Item, { ...data[id], ...api, id: id, key: id }))) }));
|
|
65
|
+
};
|
|
66
66
|
|
|
67
67
|
export { Notifications, NotificationsStore };
|