@alfalab/core-components-select 10.3.0 → 10.4.3
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/CHANGELOG.md +39 -0
- package/dist/Component.d.ts +1 -1
- package/dist/Component.js +1 -1
- package/dist/components/arrow/Component.js +1 -1
- package/dist/components/arrow/index.css +3 -3
- package/dist/components/base-select/Component.js +24 -23
- package/dist/components/base-select/index.css +7 -7
- package/dist/components/base-select/index.js +1 -1
- package/dist/components/checkmark/Component.js +2 -2
- package/dist/components/checkmark/index.css +7 -7
- package/dist/components/field/Component.d.ts +1 -1
- package/dist/components/field/Component.js +3 -3
- package/dist/components/field/index.css +9 -9
- package/dist/components/field/index.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/native-select/Component.js +1 -1
- package/dist/components/native-select/index.js +1 -1
- package/dist/components/optgroup/Component.js +1 -1
- package/dist/components/optgroup/index.css +6 -6
- package/dist/components/option/Component.js +2 -2
- package/dist/components/option/index.css +20 -20
- package/dist/components/option/index.js +1 -1
- package/dist/components/options-list/Component.js +13 -8
- package/dist/components/options-list/index.css +9 -5
- package/dist/components/options-list/index.js +1 -0
- package/dist/components/virtual-options-list/Component.d.ts +1 -1
- package/dist/components/virtual-options-list/Component.js +22 -18
- package/dist/components/virtual-options-list/index.css +15 -12
- package/dist/components/virtual-options-list/index.js +1 -0
- package/dist/cssm/Component.d.ts +1 -1
- package/dist/cssm/components/base-select/Component.js +22 -21
- package/dist/cssm/components/checkmark/Component.js +1 -1
- package/dist/cssm/components/field/Component.d.ts +1 -1
- package/dist/cssm/components/field/Component.js +1 -1
- package/dist/cssm/components/options-list/Component.js +12 -7
- package/dist/cssm/components/options-list/index.js +1 -0
- package/dist/cssm/components/options-list/index.module.css +4 -0
- package/dist/cssm/components/virtual-options-list/Component.d.ts +1 -1
- package/dist/cssm/components/virtual-options-list/Component.js +21 -17
- package/dist/cssm/components/virtual-options-list/index.js +1 -0
- package/dist/cssm/components/virtual-options-list/index.module.css +4 -1
- package/dist/cssm/hook-3b9bd559.d.ts +12 -0
- package/dist/cssm/hook-3b9bd559.js +147 -0
- package/dist/cssm/hook-f5b8fe4f.d.ts +61 -0
- package/dist/cssm/index.js +7 -1
- package/dist/cssm/intersection-observer-8c55e13a.d.ts +1 -0
- package/dist/cssm/intersection-observer-8c55e13a.js +893 -0
- package/dist/cssm/presets/index.d.ts +1 -0
- package/dist/cssm/presets/index.js +29 -1
- package/dist/cssm/presets/useLazyLoading/hook.js +1 -892
- package/dist/cssm/presets/useSelectWithApply/hook.d.ts +0 -0
- package/dist/cssm/presets/useSelectWithApply/hook.js +46 -0
- package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
- package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/Component.js +45 -0
- package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
- package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/index.js +45 -0
- package/dist/cssm/presets/useSelectWithApply/options-list-with-apply/index.module.css +38 -0
- package/dist/cssm/typings.d.ts +39 -6
- package/dist/esm/Component.d.ts +1 -1
- package/dist/esm/Component.js +1 -1
- package/dist/esm/components/arrow/Component.js +1 -1
- package/dist/esm/components/arrow/index.css +3 -3
- package/dist/esm/components/base-select/Component.js +24 -23
- package/dist/esm/components/base-select/index.css +7 -7
- package/dist/esm/components/base-select/index.js +1 -1
- package/dist/esm/components/checkmark/Component.js +2 -2
- package/dist/esm/components/checkmark/index.css +7 -7
- package/dist/esm/components/field/Component.d.ts +1 -1
- package/dist/esm/components/field/Component.js +3 -3
- package/dist/esm/components/field/index.css +9 -9
- package/dist/esm/components/field/index.js +1 -1
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/components/native-select/Component.js +1 -1
- package/dist/esm/components/native-select/index.js +1 -1
- package/dist/esm/components/optgroup/Component.js +1 -1
- package/dist/esm/components/optgroup/index.css +6 -6
- package/dist/esm/components/option/Component.js +2 -2
- package/dist/esm/components/option/index.css +20 -20
- package/dist/esm/components/option/index.js +1 -1
- package/dist/esm/components/options-list/Component.js +14 -9
- package/dist/esm/components/options-list/index.css +9 -5
- package/dist/esm/components/options-list/index.js +1 -0
- package/dist/esm/components/virtual-options-list/Component.d.ts +1 -1
- package/dist/esm/components/virtual-options-list/Component.js +22 -18
- package/dist/esm/components/virtual-options-list/index.css +15 -12
- package/dist/esm/components/virtual-options-list/index.js +1 -0
- package/dist/esm/hook-ad760b61.d.ts +12 -0
- package/dist/esm/hook-ad760b61.js +131 -0
- package/dist/esm/hook-f5b8fe4f.d.ts +61 -0
- package/dist/esm/index.js +4 -1
- package/dist/esm/intersection-observer-e5cee21e.d.ts +1 -0
- package/dist/esm/intersection-observer-e5cee21e.js +891 -0
- package/dist/esm/presets/index.d.ts +1 -0
- package/dist/esm/presets/index.js +20 -1
- package/dist/esm/presets/useLazyLoading/hook.js +3 -894
- package/dist/esm/presets/useLazyLoading/index.css +2 -2
- package/dist/esm/presets/useSelectWithApply/hook.d.ts +0 -0
- package/dist/esm/presets/useSelectWithApply/hook.js +26 -0
- package/dist/esm/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
- package/dist/esm/presets/useSelectWithApply/options-list-with-apply/Component.js +26 -0
- package/dist/esm/presets/useSelectWithApply/options-list-with-apply/index.css +39 -0
- package/dist/esm/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
- package/dist/esm/presets/useSelectWithApply/options-list-with-apply/index.js +26 -0
- package/dist/esm/presets/useSelectWithLoading/hook.js +2 -2
- package/dist/esm/presets/useSelectWithLoading/index.css +2 -2
- package/dist/esm/{tslib.es6-5a8a0ede.d.ts → tslib.es6-877b9695.d.ts} +0 -0
- package/dist/esm/{tslib.es6-5a8a0ede.js → tslib.es6-877b9695.js} +0 -0
- package/dist/esm/typings.d.ts +39 -6
- package/dist/hook-b5dec5da.d.ts +12 -0
- package/dist/hook-b5dec5da.js +140 -0
- package/dist/hook-f5b8fe4f.d.ts +61 -0
- package/dist/index.js +6 -1
- package/dist/intersection-observer-cb877b82.d.ts +1 -0
- package/dist/intersection-observer-cb877b82.js +893 -0
- package/dist/modern/Component.d.ts +1 -1
- package/dist/modern/components/arrow/Component.js +1 -1
- package/dist/modern/components/arrow/index.css +3 -3
- package/dist/modern/components/base-select/Component.js +18 -15
- package/dist/modern/components/base-select/index.css +7 -7
- package/dist/modern/components/checkmark/Component.js +2 -2
- package/dist/modern/components/checkmark/index.css +7 -7
- package/dist/modern/components/field/Component.d.ts +1 -1
- package/dist/modern/components/field/Component.js +2 -2
- package/dist/modern/components/field/index.css +9 -9
- package/dist/modern/components/optgroup/Component.js +1 -1
- package/dist/modern/components/optgroup/index.css +6 -6
- package/dist/modern/components/option/Component.js +1 -1
- package/dist/modern/components/option/index.css +20 -20
- package/dist/modern/components/options-list/Component.js +11 -7
- package/dist/modern/components/options-list/index.css +9 -5
- package/dist/modern/components/virtual-options-list/Component.d.ts +1 -1
- package/dist/modern/components/virtual-options-list/Component.js +20 -17
- package/dist/modern/components/virtual-options-list/index.css +15 -12
- package/dist/modern/hook-2c7fd2b8.d.ts +12 -0
- package/dist/modern/hook-2c7fd2b8.js +132 -0
- package/dist/modern/hook-f5b8fe4f.d.ts +61 -0
- package/dist/modern/index.js +3 -0
- package/dist/modern/intersection-observer-e5cee21e.d.ts +1 -0
- package/dist/modern/intersection-observer-e5cee21e.js +891 -0
- package/dist/modern/presets/index.d.ts +1 -0
- package/dist/modern/presets/index.js +19 -0
- package/dist/modern/presets/useLazyLoading/hook.js +2 -893
- package/dist/modern/presets/useLazyLoading/index.css +2 -2
- package/dist/modern/presets/useSelectWithApply/hook.d.ts +0 -0
- package/dist/modern/presets/useSelectWithApply/hook.js +25 -0
- package/dist/modern/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
- package/dist/modern/presets/useSelectWithApply/options-list-with-apply/Component.js +25 -0
- package/dist/modern/presets/useSelectWithApply/options-list-with-apply/index.css +39 -0
- package/dist/modern/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
- package/dist/modern/presets/useSelectWithApply/options-list-with-apply/index.js +25 -0
- package/dist/modern/presets/useSelectWithLoading/hook.js +1 -1
- package/dist/modern/presets/useSelectWithLoading/index.css +2 -2
- package/dist/modern/typings.d.ts +39 -6
- package/dist/presets/index.d.ts +1 -0
- package/dist/presets/index.js +22 -1
- package/dist/presets/useLazyLoading/hook.js +3 -894
- package/dist/presets/useLazyLoading/index.css +2 -2
- package/dist/presets/useSelectWithApply/hook.d.ts +0 -0
- package/dist/presets/useSelectWithApply/hook.js +35 -0
- package/dist/presets/useSelectWithApply/options-list-with-apply/Component.d.ts +0 -0
- package/dist/presets/useSelectWithApply/options-list-with-apply/Component.js +34 -0
- package/dist/presets/useSelectWithApply/options-list-with-apply/index.css +39 -0
- package/dist/presets/useSelectWithApply/options-list-with-apply/index.d.ts +1 -0
- package/dist/presets/useSelectWithApply/options-list-with-apply/index.js +34 -0
- package/dist/presets/useSelectWithLoading/hook.js +2 -2
- package/dist/presets/useSelectWithLoading/index.css +2 -2
- package/dist/{tslib.es6-f6070e97.d.ts → tslib.es6-4db16fbd.d.ts} +0 -0
- package/dist/{tslib.es6-f6070e97.js → tslib.es6-4db16fbd.js} +0 -0
- package/dist/typings.d.ts +39 -6
- package/package.json +4 -3
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import '../../tslib.es6-877b9695.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'classnames';
|
|
4
|
+
import '@alfalab/hooks';
|
|
5
|
+
import '@alfalab/core-components-form-control/dist/esm';
|
|
6
|
+
import '../../utils.js';
|
|
7
|
+
import '../../components/field/Component.js';
|
|
8
|
+
import '@alfalab/icons-glyph/ChevronDownMIcon';
|
|
9
|
+
import '../../components/arrow/Component.js';
|
|
10
|
+
import 'react-merge-refs';
|
|
11
|
+
import '../../components/optgroup/Component.js';
|
|
12
|
+
import '../../components/options-list/Component.js';
|
|
13
|
+
import '@alfalab/core-components-checkbox/dist/esm';
|
|
14
|
+
import '../../components/checkmark/Component.js';
|
|
15
|
+
import '../../components/option/Component.js';
|
|
16
|
+
import 'resize-observer';
|
|
17
|
+
import '@alfalab/core-components-popover/dist/esm';
|
|
18
|
+
import 'downshift';
|
|
19
|
+
import '../../components/native-select/Component.js';
|
|
20
|
+
import '../../components/base-select/Component.js';
|
|
21
|
+
import '../../Component.js';
|
|
22
|
+
import 'react-virtual';
|
|
23
|
+
import '@alfalab/core-components-skeleton/dist/esm';
|
|
24
|
+
import '../../intersection-observer-e5cee21e.js';
|
|
25
|
+
import '@alfalab/core-components-button/dist/esm';
|
|
26
|
+
export { S as SELECT_ALL_KEY, u as useSelectWithApply } from '../../hook-ad760b61.js';
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import '../../../tslib.es6-877b9695.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'classnames';
|
|
4
|
+
import '@alfalab/hooks';
|
|
5
|
+
import '@alfalab/core-components-form-control/dist/esm';
|
|
6
|
+
import '../../../utils.js';
|
|
7
|
+
import '../../../components/field/Component.js';
|
|
8
|
+
import '@alfalab/icons-glyph/ChevronDownMIcon';
|
|
9
|
+
import '../../../components/arrow/Component.js';
|
|
10
|
+
import 'react-merge-refs';
|
|
11
|
+
import '../../../components/optgroup/Component.js';
|
|
12
|
+
import '../../../components/options-list/Component.js';
|
|
13
|
+
import '@alfalab/core-components-checkbox/dist/esm';
|
|
14
|
+
import '../../../components/checkmark/Component.js';
|
|
15
|
+
import '../../../components/option/Component.js';
|
|
16
|
+
import 'resize-observer';
|
|
17
|
+
import '@alfalab/core-components-popover/dist/esm';
|
|
18
|
+
import 'downshift';
|
|
19
|
+
import '../../../components/native-select/Component.js';
|
|
20
|
+
import '../../../components/base-select/Component.js';
|
|
21
|
+
import '../../../Component.js';
|
|
22
|
+
import 'react-virtual';
|
|
23
|
+
import '@alfalab/core-components-skeleton/dist/esm';
|
|
24
|
+
import '../../../intersection-observer-e5cee21e.js';
|
|
25
|
+
import '@alfalab/core-components-button/dist/esm';
|
|
26
|
+
export { O as OptionsListWithApply } from '../../../hook-ad760b61.js';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* hash: 1atkm */
|
|
2
|
+
:root {
|
|
3
|
+
--color-light-bg-primary: #fff;
|
|
4
|
+
--color-light-border-secondary: #e7e9eb;
|
|
5
|
+
}
|
|
6
|
+
:root {
|
|
7
|
+
|
|
8
|
+
/* Hard */
|
|
9
|
+
|
|
10
|
+
/* Up */
|
|
11
|
+
|
|
12
|
+
/* Hard up */
|
|
13
|
+
}
|
|
14
|
+
:root {
|
|
15
|
+
--gap-xs: 8px;
|
|
16
|
+
--gap-s: 12px;
|
|
17
|
+
--gap-m: 16px;
|
|
18
|
+
}
|
|
19
|
+
:root {
|
|
20
|
+
|
|
21
|
+
/* options list */
|
|
22
|
+
|
|
23
|
+
/* option */
|
|
24
|
+
|
|
25
|
+
/* checkmark */
|
|
26
|
+
|
|
27
|
+
/* optgroup */
|
|
28
|
+
}
|
|
29
|
+
.select__footer_1cfix {
|
|
30
|
+
background: var(--color-light-bg-primary);
|
|
31
|
+
padding: var(--gap-s) var(--gap-s) var(--gap-m);
|
|
32
|
+
outline: none
|
|
33
|
+
}
|
|
34
|
+
.select__footer_1cfix > * + * {
|
|
35
|
+
margin-left: var(--gap-xs);
|
|
36
|
+
}
|
|
37
|
+
.select__withBorder_1cfix {
|
|
38
|
+
box-shadow: inset 0 1px 0 var(--color-light-border-secondary);
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../../../hook-ad760b61";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import '../../../tslib.es6-877b9695.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import 'classnames';
|
|
4
|
+
import '@alfalab/hooks';
|
|
5
|
+
import '@alfalab/core-components-form-control/dist/esm';
|
|
6
|
+
import '../../../utils.js';
|
|
7
|
+
import '../../../components/field/Component.js';
|
|
8
|
+
import '@alfalab/icons-glyph/ChevronDownMIcon';
|
|
9
|
+
import '../../../components/arrow/Component.js';
|
|
10
|
+
import 'react-merge-refs';
|
|
11
|
+
import '../../../components/optgroup/Component.js';
|
|
12
|
+
import '../../../components/options-list/Component.js';
|
|
13
|
+
import '@alfalab/core-components-checkbox/dist/esm';
|
|
14
|
+
import '../../../components/checkmark/Component.js';
|
|
15
|
+
import '../../../components/option/Component.js';
|
|
16
|
+
import 'resize-observer';
|
|
17
|
+
import '@alfalab/core-components-popover/dist/esm';
|
|
18
|
+
import 'downshift';
|
|
19
|
+
import '../../../components/native-select/Component.js';
|
|
20
|
+
import '../../../components/base-select/Component.js';
|
|
21
|
+
import '../../../Component.js';
|
|
22
|
+
import 'react-virtual';
|
|
23
|
+
import '@alfalab/core-components-skeleton/dist/esm';
|
|
24
|
+
import '../../../intersection-observer-e5cee21e.js';
|
|
25
|
+
import '@alfalab/core-components-button/dist/esm';
|
|
26
|
+
export { O as OptionsListWithApply } from '../../../hook-ad760b61.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as __assign } from '../../tslib.es6-
|
|
1
|
+
import { a as __assign } from '../../tslib.es6-877b9695.js';
|
|
2
2
|
import React, { useCallback } from 'react';
|
|
3
3
|
import 'classnames';
|
|
4
4
|
import '@alfalab/core-components-checkbox/dist/esm';
|
|
@@ -6,7 +6,7 @@ import '../../components/checkmark/Component.js';
|
|
|
6
6
|
import { Option } from '../../components/option/Component.js';
|
|
7
7
|
import { Skeleton } from '@alfalab/core-components-skeleton/dist/esm';
|
|
8
8
|
|
|
9
|
-
var styles = {"skeleton":"
|
|
9
|
+
var styles = {"skeleton":"select__skeleton_r7heg"};
|
|
10
10
|
require('./index.css')
|
|
11
11
|
|
|
12
12
|
function useSelectWithLoading(_a) {
|
|
File without changes
|
|
File without changes
|
package/dist/esm/typings.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ReactNode, FC, RefAttributes, AriaAttributes, FocusEvent, MouseEvent, ReactElement } from 'react';
|
|
3
2
|
import { PopoverProps } from "@alfalab/core-components-popover";
|
|
4
3
|
import { InputProps } from "@alfalab/core-components-input";
|
|
@@ -51,6 +50,10 @@ type BaseSelectProps = {
|
|
|
51
50
|
* Дополнительный класс для пункта меню
|
|
52
51
|
*/
|
|
53
52
|
optionClassName?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Дополнительный класс для поповера
|
|
55
|
+
*/
|
|
56
|
+
popperClassName?: string;
|
|
54
57
|
/**
|
|
55
58
|
* Список вариантов выбора
|
|
56
59
|
*/
|
|
@@ -194,6 +197,7 @@ type BaseSelectProps = {
|
|
|
194
197
|
onChange?: (payload: {
|
|
195
198
|
selected: OptionShape | null;
|
|
196
199
|
selectedMultiple: OptionShape[];
|
|
200
|
+
initiator: OptionShape | null;
|
|
197
201
|
name?: string;
|
|
198
202
|
}) => void;
|
|
199
203
|
/**
|
|
@@ -245,6 +249,14 @@ type FieldProps = {
|
|
|
245
249
|
* Список выбранных пунктов
|
|
246
250
|
*/
|
|
247
251
|
selectedMultiple?: OptionShape[];
|
|
252
|
+
/**
|
|
253
|
+
* Метод для ручной установки выбранных пунктов
|
|
254
|
+
*/
|
|
255
|
+
setSelectedItems: (selected: OptionShape[]) => void;
|
|
256
|
+
/**
|
|
257
|
+
* Метод переключающий видимость выпадающего списка
|
|
258
|
+
*/
|
|
259
|
+
toggleMenu: () => void;
|
|
248
260
|
/**
|
|
249
261
|
* Флаг, можно ли выбрать несколько значений
|
|
250
262
|
*/
|
|
@@ -322,10 +334,31 @@ type OptionsListProps = {
|
|
|
322
334
|
/**
|
|
323
335
|
* Компонент пункта меню
|
|
324
336
|
*/
|
|
325
|
-
Option:
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
337
|
+
Option: FC<OptionProps>;
|
|
338
|
+
/**
|
|
339
|
+
* Функция для получения пропсов для ячейки
|
|
340
|
+
*/
|
|
341
|
+
getOptionProps: (option: OptionShape, index: number) => OptionProps;
|
|
342
|
+
/**
|
|
343
|
+
* Список выбранных пунктов
|
|
344
|
+
*/
|
|
345
|
+
selectedItems?: OptionShape[];
|
|
346
|
+
/**
|
|
347
|
+
* Метод для ручной установки выбранных пунктов
|
|
348
|
+
*/
|
|
349
|
+
setSelectedItems: (selected: OptionShape[]) => void;
|
|
350
|
+
/**
|
|
351
|
+
* Метод переключающий видимость выпадающего списка
|
|
352
|
+
*/
|
|
353
|
+
toggleMenu: () => void;
|
|
354
|
+
/**
|
|
355
|
+
* Контент шапки
|
|
356
|
+
*/
|
|
357
|
+
header?: ReactNode;
|
|
358
|
+
/**
|
|
359
|
+
* Контент футера
|
|
360
|
+
*/
|
|
361
|
+
footer?: ReactNode;
|
|
329
362
|
/**
|
|
330
363
|
* Список вариантов выбора
|
|
331
364
|
*/
|
|
@@ -399,7 +432,7 @@ type OptionProps = {
|
|
|
399
432
|
*/
|
|
400
433
|
option: OptionShape;
|
|
401
434
|
/**
|
|
402
|
-
*
|
|
435
|
+
* Индекс пункта
|
|
403
436
|
*/
|
|
404
437
|
index: number;
|
|
405
438
|
/**
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { OptionShape, OptionsListProps } from "./typings";
|
|
4
|
+
declare const OptionsListWithApply: React.ForwardRefExoticComponent<OptionsListProps & {
|
|
5
|
+
showClear?: boolean | undefined;
|
|
6
|
+
onApply?: (() => void) | undefined;
|
|
7
|
+
onClear?: (() => void) | undefined;
|
|
8
|
+
onClose?: (() => void) | undefined;
|
|
9
|
+
selectedDraft?: OptionShape[] | undefined;
|
|
10
|
+
OptionsList?: React.FC<OptionsListProps & React.RefAttributes<unknown>> | undefined;
|
|
11
|
+
} & React.RefAttributes<unknown>>;
|
|
12
|
+
export { OptionsListWithApply };
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tslib_es6 = require('./tslib.es6-4db16fbd.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var cn = require('classnames');
|
|
6
|
+
require('@alfalab/hooks');
|
|
7
|
+
require('@alfalab/core-components-form-control');
|
|
8
|
+
var utils = require('./utils.js');
|
|
9
|
+
require('@alfalab/icons-glyph/ChevronDownMIcon');
|
|
10
|
+
var components_optionsList_Component = require('./components/options-list/Component.js');
|
|
11
|
+
require('@alfalab/core-components-checkbox');
|
|
12
|
+
require('./components/base-select/Component.js');
|
|
13
|
+
require('./Component.js');
|
|
14
|
+
require('react-virtual');
|
|
15
|
+
require('@alfalab/core-components-skeleton');
|
|
16
|
+
require('./intersection-observer-cb877b82.js');
|
|
17
|
+
var coreComponentsButton = require('@alfalab/core-components-button');
|
|
18
|
+
|
|
19
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
20
|
+
|
|
21
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
22
|
+
var cn__default = /*#__PURE__*/_interopDefaultLegacy(cn);
|
|
23
|
+
|
|
24
|
+
var styles = {"footer":"select__footer_1cfix","withBorder":"select__withBorder_1cfix"};
|
|
25
|
+
require('./presets/useSelectWithApply/options-list-with-apply/index.css')
|
|
26
|
+
|
|
27
|
+
var OptionsListWithApply = React.forwardRef(function (_a, ref) {
|
|
28
|
+
var _b;
|
|
29
|
+
var toggleMenu = _a.toggleMenu, _c = _a.OptionsList, OptionsList = _c === void 0 ? components_optionsList_Component.OptionsList : _c, defaultGetOptionProps = _a.getOptionProps, _d = _a.showClear, showClear = _d === void 0 ? true : _d, _e = _a.selectedDraft, selectedDraft = _e === void 0 ? [] : _e, _f = _a.flatOptions, flatOptions = _f === void 0 ? [] : _f, _g = _a.onApply, onApply = _g === void 0 ? function () { return null; } : _g, _h = _a.onClear, onClear = _h === void 0 ? function () { return null; } : _h, _j = _a.onClose, onClose = _j === void 0 ? function () { return null; } : _j, _k = _a.visibleOptions, visibleOptions = _k === void 0 ? 5 : _k, restProps = tslib_es6.__rest(_a, ["toggleMenu", "OptionsList", "getOptionProps", "showClear", "selectedDraft", "flatOptions", "onApply", "onClear", "onClose", "visibleOptions"]);
|
|
30
|
+
var footerRef = React.useRef(null);
|
|
31
|
+
var getOptionProps = React.useCallback(function (option, index) {
|
|
32
|
+
var optionProps = defaultGetOptionProps(option, index);
|
|
33
|
+
var selected = option.key === SELECT_ALL_KEY
|
|
34
|
+
? selectedDraft.length === flatOptions.length - 1
|
|
35
|
+
: selectedDraft.includes(option);
|
|
36
|
+
return tslib_es6.__assign(tslib_es6.__assign({}, optionProps), { selected: selected });
|
|
37
|
+
}, [defaultGetOptionProps, flatOptions.length, selectedDraft]);
|
|
38
|
+
var handleApply = React.useCallback(function () {
|
|
39
|
+
onApply();
|
|
40
|
+
toggleMenu();
|
|
41
|
+
}, [onApply, toggleMenu]);
|
|
42
|
+
var handleClear = React.useCallback(function () {
|
|
43
|
+
onClear();
|
|
44
|
+
toggleMenu();
|
|
45
|
+
}, [onClear, toggleMenu]);
|
|
46
|
+
React.useEffect(function () {
|
|
47
|
+
var activeElement = document.activeElement;
|
|
48
|
+
setTimeout(function () {
|
|
49
|
+
if (footerRef.current) {
|
|
50
|
+
footerRef.current.focus();
|
|
51
|
+
}
|
|
52
|
+
}, 0);
|
|
53
|
+
return function () {
|
|
54
|
+
onClose();
|
|
55
|
+
if (activeElement) {
|
|
56
|
+
activeElement.focus();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
|
+
}, []);
|
|
61
|
+
return (React__default['default'].createElement(OptionsList, tslib_es6.__assign({}, restProps, { ref: ref, visibleOptions: visibleOptions, toggleMenu: toggleMenu, flatOptions: flatOptions, getOptionProps: getOptionProps, footer: React__default['default'].createElement("div", {
|
|
62
|
+
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
63
|
+
tabIndex: 0, className: cn__default['default'](styles.footer, (_b = {},
|
|
64
|
+
_b[styles.withBorder] = visibleOptions && flatOptions.length > visibleOptions,
|
|
65
|
+
_b)), ref: footerRef },
|
|
66
|
+
React__default['default'].createElement(coreComponentsButton.Button, { size: 'xxs', view: 'primary', onClick: handleApply }, "\u041F\u0440\u0438\u043C\u0435\u043D\u0438\u0442\u044C"),
|
|
67
|
+
showClear && (React__default['default'].createElement(coreComponentsButton.Button, { size: 'xxs', view: 'secondary', onClick: handleClear }, "\u0421\u0431\u0440\u043E\u0441\u0438\u0442\u044C"))) })));
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
var SELECT_ALL_KEY = 'select_all';
|
|
71
|
+
var selectAllOption = { key: SELECT_ALL_KEY, content: 'Выбрать все' };
|
|
72
|
+
function useSelectWithApply(_a) {
|
|
73
|
+
var options = _a.options, selected = _a.selected, _b = _a.onChange, onChange = _b === void 0 ? function () { return null; } : _b, OptionsList = _a.OptionsList, _c = _a.showClear, showClear = _c === void 0 ? true : _c, _d = _a.showSelectAll, showSelectAll = _d === void 0 ? false : _d;
|
|
74
|
+
var _e = React.useMemo(function () { return utils.processOptions(options, selected); }, [
|
|
75
|
+
options,
|
|
76
|
+
selected,
|
|
77
|
+
]), flatOptions = _e.flatOptions, selectedOptions = _e.selectedOptions;
|
|
78
|
+
var _f = React.useState(selectedOptions), selectedDraft = _f[0], setSelectedDraft = _f[1];
|
|
79
|
+
var selectedOptionsRef = React.useRef(selectedOptions);
|
|
80
|
+
var handleApply = React.useCallback(function () {
|
|
81
|
+
onChange({
|
|
82
|
+
selected: selectedDraft[0],
|
|
83
|
+
selectedMultiple: selectedDraft,
|
|
84
|
+
initiator: null,
|
|
85
|
+
});
|
|
86
|
+
}, [onChange, selectedDraft]);
|
|
87
|
+
var handleClear = React.useCallback(function () {
|
|
88
|
+
setSelectedDraft([]);
|
|
89
|
+
onChange({
|
|
90
|
+
selected: null,
|
|
91
|
+
selectedMultiple: [],
|
|
92
|
+
initiator: null,
|
|
93
|
+
});
|
|
94
|
+
}, [onChange]);
|
|
95
|
+
var handleChange = React.useCallback(function (_a) {
|
|
96
|
+
var initiator = _a.initiator, restArgs = tslib_es6.__rest(_a, ["initiator"]);
|
|
97
|
+
if (!initiator) {
|
|
98
|
+
onChange(tslib_es6.__assign({ initiator: null }, restArgs));
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
var initiatorSelected = selectedDraft.includes(initiator) ||
|
|
102
|
+
(initiator.key === SELECT_ALL_KEY && selectedDraft.length === flatOptions.length);
|
|
103
|
+
if (initiator.key === SELECT_ALL_KEY) {
|
|
104
|
+
setSelectedDraft(initiatorSelected ? [] : flatOptions);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
setSelectedDraft(initiatorSelected
|
|
108
|
+
? selectedDraft.filter(function (o) { return o !== initiator; })
|
|
109
|
+
: selectedDraft.concat(initiator));
|
|
110
|
+
}
|
|
111
|
+
}, [flatOptions, onChange, selectedDraft]);
|
|
112
|
+
var handleClose = React.useCallback(function () {
|
|
113
|
+
setSelectedDraft(selectedOptionsRef.current);
|
|
114
|
+
}, []);
|
|
115
|
+
React.useEffect(function () {
|
|
116
|
+
setSelectedDraft(selectedOptions);
|
|
117
|
+
selectedOptionsRef.current = selectedOptions;
|
|
118
|
+
}, [selectedOptions]);
|
|
119
|
+
var memoizedOptions = React.useMemo(function () { return (showSelectAll ? tslib_es6.__spreadArrays([selectAllOption], options) : options); }, [options, showSelectAll]);
|
|
120
|
+
return {
|
|
121
|
+
OptionsList: OptionsListWithApply,
|
|
122
|
+
optionsListProps: {
|
|
123
|
+
OptionsList: OptionsList,
|
|
124
|
+
showClear: showClear && (selectedDraft.length > 0 || selectedOptions.length > 0),
|
|
125
|
+
onClear: handleClear,
|
|
126
|
+
onApply: handleApply,
|
|
127
|
+
onClose: handleClose,
|
|
128
|
+
selectedDraft: selectedDraft,
|
|
129
|
+
},
|
|
130
|
+
allowUnselect: true,
|
|
131
|
+
multiple: true,
|
|
132
|
+
options: memoizedOptions,
|
|
133
|
+
onChange: handleChange,
|
|
134
|
+
selected: selected,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
exports.OptionsListWithApply = OptionsListWithApply;
|
|
139
|
+
exports.SELECT_ALL_KEY = SELECT_ALL_KEY;
|
|
140
|
+
exports.useSelectWithApply = useSelectWithApply;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { OptionShape, BaseSelectProps } from "./index";
|
|
3
|
+
type useSelectWithApplyProps = {
|
|
4
|
+
/**
|
|
5
|
+
* Список выбранных пунктов
|
|
6
|
+
*/
|
|
7
|
+
selected: BaseSelectProps['selected'];
|
|
8
|
+
/**
|
|
9
|
+
* Список вариантов выбора
|
|
10
|
+
*/
|
|
11
|
+
options: BaseSelectProps['options'];
|
|
12
|
+
/**
|
|
13
|
+
* Обработчик выбора
|
|
14
|
+
*/
|
|
15
|
+
onChange: BaseSelectProps['onChange'];
|
|
16
|
+
/**
|
|
17
|
+
* Компонент выпадающего меню
|
|
18
|
+
*/
|
|
19
|
+
OptionsList?: BaseSelectProps['OptionsList'];
|
|
20
|
+
/**
|
|
21
|
+
* Показывать кнопку очистки
|
|
22
|
+
*/
|
|
23
|
+
showClear?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Показывать пункт "Выбрать все"
|
|
26
|
+
*/
|
|
27
|
+
showSelectAll?: boolean;
|
|
28
|
+
};
|
|
29
|
+
declare const SELECT_ALL_KEY = "select_all";
|
|
30
|
+
declare function useSelectWithApply({ options, selected, onChange, OptionsList, showClear, showSelectAll, }: useSelectWithApplyProps): {
|
|
31
|
+
OptionsList: import("react").ForwardRefExoticComponent<import("./index").OptionsListProps & {
|
|
32
|
+
showClear?: boolean | undefined;
|
|
33
|
+
onApply?: (() => void) | undefined;
|
|
34
|
+
onClear?: (() => void) | undefined;
|
|
35
|
+
onClose?: (() => void) | undefined;
|
|
36
|
+
selectedDraft?: OptionShape[] | undefined;
|
|
37
|
+
OptionsList?: import("react").FC<import("./index").OptionsListProps & import("react").RefAttributes<unknown>> | undefined;
|
|
38
|
+
} & import("react").RefAttributes<unknown>>;
|
|
39
|
+
optionsListProps: {
|
|
40
|
+
OptionsList: import("react").FC<import("./index").OptionsListProps> | undefined;
|
|
41
|
+
showClear: boolean;
|
|
42
|
+
onClear: () => void;
|
|
43
|
+
onApply: () => void;
|
|
44
|
+
onClose: () => void;
|
|
45
|
+
selectedDraft: OptionShape[];
|
|
46
|
+
};
|
|
47
|
+
allowUnselect: boolean;
|
|
48
|
+
multiple: boolean;
|
|
49
|
+
options: (OptionShape | import("./index").GroupShape | {
|
|
50
|
+
key: string;
|
|
51
|
+
content: string;
|
|
52
|
+
})[];
|
|
53
|
+
onChange: (payload: {
|
|
54
|
+
selected: OptionShape | null;
|
|
55
|
+
selectedMultiple: OptionShape[];
|
|
56
|
+
initiator: OptionShape | null;
|
|
57
|
+
name?: string | undefined;
|
|
58
|
+
}) => void;
|
|
59
|
+
selected: string | OptionShape | (string | OptionShape)[] | null | undefined;
|
|
60
|
+
};
|
|
61
|
+
export { SELECT_ALL_KEY, useSelectWithApply };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
require('./tslib.es6-
|
|
5
|
+
require('./tslib.es6-4db16fbd.js');
|
|
6
6
|
require('react');
|
|
7
7
|
require('classnames');
|
|
8
8
|
require('@alfalab/hooks');
|
|
@@ -27,7 +27,10 @@ require('react-virtual');
|
|
|
27
27
|
var components_virtualOptionsList_Component = require('./components/virtual-options-list/Component.js');
|
|
28
28
|
require('@alfalab/core-components-skeleton');
|
|
29
29
|
var presets_useSelectWithLoading_hook = require('./presets/useSelectWithLoading/hook.js');
|
|
30
|
+
require('./intersection-observer-cb877b82.js');
|
|
30
31
|
var presets_useLazyLoading_hook = require('./presets/useLazyLoading/hook.js');
|
|
32
|
+
require('@alfalab/core-components-button');
|
|
33
|
+
var presets_useSelectWithApply_optionsListWithApply_Component = require('./hook-b5dec5da.js');
|
|
31
34
|
|
|
32
35
|
|
|
33
36
|
|
|
@@ -48,3 +51,5 @@ exports.Select = Component.Select;
|
|
|
48
51
|
exports.VirtualOptionsList = components_virtualOptionsList_Component.VirtualOptionsList;
|
|
49
52
|
exports.useSelectWithLoading = presets_useSelectWithLoading_hook.useSelectWithLoading;
|
|
50
53
|
exports.useLazyLoading = presets_useLazyLoading_hook.useLazyLoading;
|
|
54
|
+
exports.SELECT_ALL_KEY = presets_useSelectWithApply_optionsListWithApply_Component.SELECT_ALL_KEY;
|
|
55
|
+
exports.useSelectWithApply = presets_useSelectWithApply_optionsListWithApply_Component.useSelectWithApply;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|