@snack-uikit/fields 0.14.2 → 0.15.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/CHANGELOG.md +16 -0
- package/README.md +15 -14
- package/dist/components/FieldDecorator/Header.js +1 -1
- package/dist/components/FieldDecorator/styles.module.css +7 -1
- package/dist/components/FieldSelect/FieldSelect.d.ts +1 -7
- package/dist/components/FieldSelect/FieldSelect.js +9 -21
- package/dist/components/FieldSelect/FieldSelectMultiple.d.ts +17 -0
- package/dist/components/FieldSelect/FieldSelectMultiple.js +118 -0
- package/dist/components/FieldSelect/FieldSelectSingle.d.ts +9 -28
- package/dist/components/FieldSelect/FieldSelectSingle.js +69 -55
- package/dist/components/FieldSelect/hooks.d.ts +30 -0
- package/dist/components/FieldSelect/hooks.js +72 -0
- package/dist/components/FieldSelect/index.d.ts +2 -1
- package/dist/components/FieldSelect/index.js +1 -1
- package/dist/components/FieldSelect/styles.module.css +129 -27
- package/dist/components/FieldSelect/types.d.ts +42 -37
- package/dist/components/FieldSelect/utils.d.ts +19 -0
- package/dist/components/FieldSelect/utils.js +112 -0
- package/dist/helperComponents/FieldContainerPrivate/styles.module.css +30 -6
- package/package.json +5 -3
- package/src/components/FieldDecorator/Header.tsx +6 -1
- package/src/components/FieldDecorator/styles.module.scss +38 -30
- package/src/components/FieldSelect/FieldSelect.tsx +13 -21
- package/src/components/FieldSelect/FieldSelectMultiple.tsx +255 -0
- package/src/components/FieldSelect/FieldSelectSingle.tsx +159 -99
- package/src/components/FieldSelect/hooks.ts +125 -0
- package/src/components/FieldSelect/index.ts +12 -1
- package/src/components/FieldSelect/styles.module.scss +71 -31
- package/src/components/FieldSelect/types.ts +55 -40
- package/src/components/FieldSelect/utils.ts +163 -0
- package/src/helperComponents/FieldContainerPrivate/FieldContainerPrivate.tsx +2 -0
- package/src/helperComponents/FieldContainerPrivate/styles.module.scss +32 -11
- package/dist/components/FieldSelect/FieldSelectBase.d.ts +0 -31
- package/dist/components/FieldSelect/FieldSelectBase.js +0 -51
- package/dist/components/FieldSelect/FieldSelectMulti.d.ts +0 -37
- package/dist/components/FieldSelect/FieldSelectMulti.js +0 -89
- package/dist/components/FieldSelect/constants.d.ts +0 -7
- package/dist/components/FieldSelect/constants.js +0 -6
- package/dist/components/FieldSelect/helpers/getArrowIcon.d.ts +0 -8
- package/dist/components/FieldSelect/helpers/getArrowIcon.js +0 -8
- package/dist/components/FieldSelect/helpers/getDisplayedValue.d.ts +0 -10
- package/dist/components/FieldSelect/helpers/getDisplayedValue.js +0 -12
- package/dist/components/FieldSelect/helpers/index.d.ts +0 -2
- package/dist/components/FieldSelect/helpers/index.js +0 -2
- package/dist/components/FieldSelect/hooks/index.d.ts +0 -3
- package/dist/components/FieldSelect/hooks/index.js +0 -3
- package/dist/components/FieldSelect/hooks/useFilteredOptions.d.ts +0 -7
- package/dist/components/FieldSelect/hooks/useFilteredOptions.js +0 -6
- package/dist/components/FieldSelect/hooks/useList.d.ts +0 -37
- package/dist/components/FieldSelect/hooks/useList.js +0 -52
- package/dist/components/FieldSelect/hooks/useListNavigation.d.ts +0 -26
- package/dist/components/FieldSelect/hooks/useListNavigation.js +0 -48
- package/src/components/FieldSelect/FieldSelectBase.tsx +0 -222
- package/src/components/FieldSelect/FieldSelectMulti.tsx +0 -163
- package/src/components/FieldSelect/constants.ts +0 -9
- package/src/components/FieldSelect/helpers/getArrowIcon.ts +0 -9
- package/src/components/FieldSelect/helpers/getDisplayedValue.ts +0 -25
- package/src/components/FieldSelect/helpers/index.ts +0 -2
- package/src/components/FieldSelect/hooks/index.ts +0 -3
- package/src/components/FieldSelect/hooks/useFilteredOptions.ts +0 -23
- package/src/components/FieldSelect/hooks/useList.ts +0 -87
- package/src/components/FieldSelect/hooks/useListNavigation.ts +0 -81
|
@@ -3,66 +3,137 @@
|
|
|
3
3
|
width:100%;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
.
|
|
7
|
-
|
|
6
|
+
.contentWrapper{
|
|
7
|
+
display:flex;
|
|
8
|
+
flex-wrap:wrap;
|
|
9
|
+
width:100%;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
.
|
|
11
|
-
|
|
12
|
+
.tagContainer{
|
|
13
|
+
height:auto !important;
|
|
12
14
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
.tagContainer[data-size=s]{
|
|
16
|
+
border-radius:var(--radius-fields-s, 12px);
|
|
17
|
+
border-width:var(--border-width-fields-single, 2px);
|
|
18
|
+
padding-left:var(--space-fields-single-line-container-s-left, 6px);
|
|
19
|
+
gap:var(--space-fields-single-line-container-s-gap, 4px);
|
|
20
|
+
padding-right:var(--space-fields-single-line-container-s-right, 6px);
|
|
21
|
+
min-height:var(--size-fields-s, 32px);
|
|
22
|
+
padding-top:var(--space-fields-select-multiple-s-vertical-padding, 2px);
|
|
23
|
+
padding-bottom:var(--space-fields-select-multiple-s-vertical-padding, 2px);
|
|
16
24
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
.tagContainer[data-size=s] .contentWrapper{
|
|
26
|
+
gap:var(--space-fields-single-line-container-s-gap, 4px);
|
|
27
|
+
}
|
|
28
|
+
.tagContainer[data-size=m]{
|
|
29
|
+
border-radius:var(--radius-fields-m, 14px);
|
|
30
|
+
border-width:var(--border-width-fields-single, 2px);
|
|
31
|
+
padding-left:var(--space-fields-single-line-container-m-left, 8px);
|
|
32
|
+
gap:var(--space-fields-single-line-container-m-gap, 4px);
|
|
33
|
+
padding-right:var(--space-fields-single-line-container-m-right, 8px);
|
|
34
|
+
padding-top:var(--space-fields-select-multiple-m-vertical-padding, 6px);
|
|
35
|
+
padding-bottom:var(--space-fields-select-multiple-m-vertical-padding, 6px);
|
|
36
|
+
min-height:var(--size-fields-m, 40px);
|
|
37
|
+
}
|
|
38
|
+
.tagContainer[data-size=m] .contentWrapper{
|
|
39
|
+
gap:var(--space-fields-single-line-container-m-gap, 4px);
|
|
40
|
+
}
|
|
41
|
+
.tagContainer[data-size=l]{
|
|
42
|
+
border-radius:var(--radius-fields-l, 16px);
|
|
43
|
+
border-width:var(--border-width-fields-single, 2px);
|
|
44
|
+
padding-left:var(--space-fields-single-line-container-l-left, 10px);
|
|
45
|
+
gap:var(--space-fields-single-line-container-l-gap, 8px);
|
|
46
|
+
padding-right:var(--space-fields-single-line-container-l-right, 10px);
|
|
47
|
+
min-height:var(--size-fields-l, 48px);
|
|
48
|
+
padding-top:var(--space-fields-select-multiple-l-vertical-padding, 6px);
|
|
49
|
+
padding-bottom:var(--space-fields-select-multiple-l-vertical-padding, 6px);
|
|
50
|
+
}
|
|
51
|
+
.tagContainer[data-size=l] .contentWrapper{
|
|
52
|
+
gap:var(--space-fields-single-line-container-l-gap, 8px);
|
|
31
53
|
}
|
|
32
54
|
|
|
33
55
|
.container{
|
|
56
|
+
position:relative;
|
|
34
57
|
flex:1 1 0;
|
|
35
58
|
}
|
|
59
|
+
.container[data-size=s] .inputPlug{
|
|
60
|
+
font-family:var(--sans-body-s-font-family, SB Sans Interface);
|
|
61
|
+
font-weight:var(--sans-body-s-font-weight, Regular);
|
|
62
|
+
line-height:var(--sans-body-s-line-height, 16px);
|
|
63
|
+
font-size:var(--sans-body-s-font-size, 12px);
|
|
64
|
+
letter-spacing:var(--sans-body-s-letter-spacing, 0.1px);
|
|
65
|
+
paragraph-spacing:var(--sans-body-s-paragraph-spacing, 6.6px);
|
|
66
|
+
}
|
|
36
67
|
.container[data-size=s] .arrowIcon{
|
|
37
68
|
width:var(--size-icon-container-xs, 16px) !important;
|
|
38
69
|
height:var(--size-icon-container-xs, 16px) !important;
|
|
39
70
|
color:var(--sys-neutral-text-light, #868892);
|
|
40
71
|
}
|
|
41
72
|
.container[data-size=s][data-variant=single-line-container] .displayValue{
|
|
42
|
-
width:calc(100% - (
|
|
43
|
-
|
|
73
|
+
width:calc(100% - (
|
|
74
|
+
var(--space-fields-single-line-container-s-right, 6px) +
|
|
75
|
+
var(--space-fields-single-line-container-s-gap, 4px) +
|
|
76
|
+
calc(var(var(--space-fields-postfix-gap, 4px)) + var(--size-icon-container-xs, 16px) * 2)
|
|
77
|
+
));
|
|
78
|
+
margin-right:calc(
|
|
79
|
+
var(--space-fields-single-line-container-s-right, 6px) +
|
|
80
|
+
var(--space-fields-single-line-container-s-gap, 4px) +
|
|
81
|
+
calc(var(var(--space-fields-postfix-gap, 4px)) + var(--size-icon-container-xs, 16px) * 2)
|
|
82
|
+
);
|
|
44
83
|
padding-left:var(--space-fields-single-line-container-s-left, 6px);
|
|
45
84
|
border-radius:var(--radius-fields-s, 12px);
|
|
46
85
|
}
|
|
86
|
+
.container[data-size=m] .inputPlug{
|
|
87
|
+
font-family:var(--sans-body-m-font-family, SB Sans Interface);
|
|
88
|
+
font-weight:var(--sans-body-m-font-weight, Regular);
|
|
89
|
+
line-height:var(--sans-body-m-line-height, 20px);
|
|
90
|
+
font-size:var(--sans-body-m-font-size, 14px);
|
|
91
|
+
letter-spacing:var(--sans-body-m-letter-spacing, 0.1px);
|
|
92
|
+
paragraph-spacing:var(--sans-body-m-paragraph-spacing, 7.7px);
|
|
93
|
+
}
|
|
47
94
|
.container[data-size=m] .arrowIcon{
|
|
48
95
|
width:var(--size-icon-container-s, 24px) !important;
|
|
49
96
|
height:var(--size-icon-container-s, 24px) !important;
|
|
50
97
|
color:var(--sys-neutral-text-light, #868892);
|
|
51
98
|
}
|
|
52
99
|
.container[data-size=m][data-variant=single-line-container] .displayValue{
|
|
53
|
-
width:calc(100% - (
|
|
54
|
-
|
|
100
|
+
width:calc(100% - (
|
|
101
|
+
var(--space-fields-single-line-container-m-right, 8px) +
|
|
102
|
+
var(--space-fields-single-line-container-m-gap, 4px) +
|
|
103
|
+
calc(var(var(--space-fields-postfix-gap, 4px)) + var(--size-icon-container-s, 24px) * 2)
|
|
104
|
+
));
|
|
105
|
+
margin-right:calc(
|
|
106
|
+
var(--space-fields-single-line-container-m-right, 8px) +
|
|
107
|
+
var(--space-fields-single-line-container-m-gap, 4px) +
|
|
108
|
+
calc(var(var(--space-fields-postfix-gap, 4px)) + var(--size-icon-container-s, 24px) * 2)
|
|
109
|
+
);
|
|
55
110
|
padding-left:var(--space-fields-single-line-container-m-left, 8px);
|
|
56
111
|
border-radius:var(--radius-fields-m, 14px);
|
|
57
112
|
}
|
|
113
|
+
.container[data-size=l] .inputPlug{
|
|
114
|
+
font-family:var(--sans-body-l-font-family, SB Sans Interface);
|
|
115
|
+
font-weight:var(--sans-body-l-font-weight, Regular);
|
|
116
|
+
line-height:var(--sans-body-l-line-height, 24px);
|
|
117
|
+
font-size:var(--sans-body-l-font-size, 16px);
|
|
118
|
+
letter-spacing:var(--sans-body-l-letter-spacing, 0.1px);
|
|
119
|
+
paragraph-spacing:var(--sans-body-l-paragraph-spacing, 8.8px);
|
|
120
|
+
}
|
|
58
121
|
.container[data-size=l] .arrowIcon{
|
|
59
122
|
width:var(--size-icon-container-s, 24px) !important;
|
|
60
123
|
height:var(--size-icon-container-s, 24px) !important;
|
|
61
124
|
color:var(--sys-neutral-text-light, #868892);
|
|
62
125
|
}
|
|
63
126
|
.container[data-size=l][data-variant=single-line-container] .displayValue{
|
|
64
|
-
width:calc(100% - (
|
|
65
|
-
|
|
127
|
+
width:calc(100% - (
|
|
128
|
+
var(--space-fields-single-line-container-l-right, 10px) +
|
|
129
|
+
var(--space-fields-single-line-container-l-gap, 8px) +
|
|
130
|
+
calc(var(var(--space-fields-postfix-gap, 4px)) + var(--size-icon-container-s, 24px) * 2)
|
|
131
|
+
));
|
|
132
|
+
margin-right:calc(
|
|
133
|
+
var(--space-fields-single-line-container-l-right, 10px) +
|
|
134
|
+
var(--space-fields-single-line-container-l-gap, 8px) +
|
|
135
|
+
calc(var(var(--space-fields-postfix-gap, 4px)) + var(--size-icon-container-s, 24px) * 2)
|
|
136
|
+
);
|
|
66
137
|
padding-left:var(--space-fields-single-line-container-l-left, 10px);
|
|
67
138
|
border-radius:var(--radius-fields-l, 16px);
|
|
68
139
|
}
|
|
@@ -71,4 +142,35 @@
|
|
|
71
142
|
}
|
|
72
143
|
.container[data-disabled] .arrowIcon, .container[data-readonly] .arrowIcon{
|
|
73
144
|
color:var(--sys-neutral-text-disabled, #b3b6bf);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.inputPlug{
|
|
148
|
+
content:"";
|
|
149
|
+
position:absolute;
|
|
150
|
+
top:0;
|
|
151
|
+
left:0;
|
|
152
|
+
overflow:hidden;
|
|
153
|
+
width:-moz-fit-content;
|
|
154
|
+
width:fit-content;
|
|
155
|
+
max-width:100%;
|
|
156
|
+
height:0;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.inputWrapper{
|
|
160
|
+
position:relative;
|
|
161
|
+
display:inline-flex;
|
|
162
|
+
flex:1;
|
|
163
|
+
min-width:4px;
|
|
164
|
+
color:transparent;
|
|
165
|
+
}
|
|
166
|
+
.inputWrapper[data-searchable=false]{
|
|
167
|
+
width:0;
|
|
168
|
+
min-width:0;
|
|
169
|
+
max-width:0;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.postfix{
|
|
173
|
+
display:inline-flex;
|
|
174
|
+
flex-shrink:0;
|
|
175
|
+
gap:var(--space-fields-postfix-gap, 4px);
|
|
74
176
|
}
|
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
|
-
import { ItemSingleProps } from '@snack-uikit/droplist';
|
|
3
2
|
import { InputPrivateProps } from '@snack-uikit/input-private';
|
|
3
|
+
import { AccordionItemProps, BaseItemProps, GroupItemProps, ListProps, NextListItemProps, SelectionMultipleState, SelectionSingleState } from '@snack-uikit/list';
|
|
4
4
|
import { WithSupportProps } from '@snack-uikit/utils';
|
|
5
5
|
import { FieldDecoratorProps } from '../FieldDecorator';
|
|
6
|
-
export type
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
export type OptionProps = BaseOptionProps | AccordionOptionProps | GroupOptionProps | NestListOptionProps;
|
|
7
|
+
export type OptionWithoutGroup = BaseOptionProps | AccordionOptionProps | NestListOptionProps;
|
|
8
|
+
export type BaseOptionProps = Pick<BaseItemProps, 'beforeContent' | 'afterContent' | 'disabled'> & BaseItemProps['content'] & {
|
|
9
|
+
value: string | number;
|
|
9
10
|
};
|
|
10
|
-
export type
|
|
11
|
-
|
|
11
|
+
export type AccordionOptionProps = Pick<AccordionItemProps, 'type'> & BaseOptionProps & {
|
|
12
|
+
options: OptionProps[];
|
|
12
13
|
};
|
|
13
|
-
type
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
options:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
export type GroupOptionProps = Omit<GroupItemProps, 'items' | 'id'> & {
|
|
15
|
+
options: OptionProps[];
|
|
16
|
+
};
|
|
17
|
+
export type NestListOptionProps = Pick<NextListItemProps, 'type'> & BaseOptionProps & {
|
|
18
|
+
options: OptionProps[];
|
|
19
|
+
};
|
|
20
|
+
export type InputProps = Pick<InputPrivateProps, 'id' | 'name' | 'placeholder' | 'disabled' | 'readonly' | 'onFocus' | 'onBlur' | 'onKeyDown'>;
|
|
21
|
+
export type WrapperProps = Pick<FieldDecoratorProps, 'className' | 'label' | 'labelTooltip' | 'required' | 'hint' | 'showHintIcon' | 'size' | 'validationState' | 'labelTooltipPlacement'>;
|
|
22
|
+
export type SearchState = {
|
|
23
|
+
value?: string;
|
|
24
|
+
defaultValue?: string;
|
|
25
|
+
onChange?(value: string): void;
|
|
26
|
+
};
|
|
27
|
+
export type FieldSelectPrivateProps = InputProps & WrapperProps & {
|
|
28
|
+
options: OptionProps[];
|
|
29
|
+
loading?: boolean;
|
|
30
|
+
};
|
|
31
|
+
type FiledSelectCommonProps = WithSupportProps<{
|
|
32
|
+
options: OptionProps[];
|
|
23
33
|
searchable?: boolean;
|
|
24
34
|
/** Отображение кнопки Копировать для поля (актуально только для `readonly = true`) */
|
|
25
35
|
showCopyButton?: boolean;
|
|
@@ -28,27 +38,22 @@ type FieldSelectOwnProps = {
|
|
|
28
38
|
* @default true
|
|
29
39
|
*/
|
|
30
40
|
showClearButton?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Является ли поле доступным только для чтения
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
readonly?: boolean;
|
|
31
46
|
/** Иконка-префикс для поля */
|
|
32
47
|
prefixIcon?: ReactElement;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
export type
|
|
39
|
-
type
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
type MultiModeProps = {
|
|
46
|
-
/** <br> - массив для multi mode */
|
|
47
|
-
value?: Option['value'][];
|
|
48
|
-
onChange?(value: Option['value'][]): void;
|
|
49
|
-
/** Колбек формирования текста */
|
|
50
|
-
getSelectedItemsText?(amount: number): string;
|
|
51
|
-
};
|
|
52
|
-
export type FieldSelectSingleProps = WithSupportProps<FieldSelectBaseProps & SingleModeProps>;
|
|
53
|
-
export type FieldSelectMultiProps = WithSupportProps<FieldSelectBaseProps & MultiModeProps>;
|
|
48
|
+
footer?: ListProps['footer'];
|
|
49
|
+
search?: SearchState;
|
|
50
|
+
autocomplete?: boolean;
|
|
51
|
+
}>;
|
|
52
|
+
export type FieldSelectSingleProps = FieldSelectPrivateProps & Omit<SelectionSingleState, 'mode'> & WrapperProps & FiledSelectCommonProps;
|
|
53
|
+
export type FieldSelectMultipleProps = FieldSelectPrivateProps & Omit<SelectionMultipleState, 'mode'> & FiledSelectCommonProps;
|
|
54
|
+
export type FieldSelectProps = (FieldSelectSingleProps & {
|
|
55
|
+
selection?: 'single';
|
|
56
|
+
}) | (FieldSelectMultipleProps & {
|
|
57
|
+
selection: 'multiple';
|
|
58
|
+
});
|
|
54
59
|
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Size } from '@snack-uikit/input-private';
|
|
2
|
+
import { ItemProps } from '@snack-uikit/list';
|
|
3
|
+
import { AccordionOptionProps, BaseOptionProps, FieldSelectMultipleProps, FieldSelectSingleProps, GroupOptionProps, NestListOptionProps, OptionProps, OptionWithoutGroup } from './types';
|
|
4
|
+
export declare function isBaseOptionProps(option: any): option is BaseOptionProps;
|
|
5
|
+
export declare function isAccordionOptionProps(option: any): option is AccordionOptionProps;
|
|
6
|
+
export declare function isNextListOptionProps(option: any): option is NestListOptionProps;
|
|
7
|
+
export declare function isGroupOptionProps(option: any): option is GroupOptionProps;
|
|
8
|
+
export declare function transformOptionsToItems(options: OptionProps[]): ItemProps[];
|
|
9
|
+
export declare function extractSelectedOptions(options: OptionProps[], value: string | number | undefined): OptionWithoutGroup | undefined;
|
|
10
|
+
export declare function extractSelectedMultipleOptions(options: OptionProps[], value?: (string | number | undefined)[]): OptionWithoutGroup[] | undefined;
|
|
11
|
+
export declare function isFieldSelectMultipleProps(props: any): props is FieldSelectMultipleProps;
|
|
12
|
+
export declare function isFieldSelectSingleProps(props: any): props is FieldSelectSingleProps;
|
|
13
|
+
export declare function getArrowIcon({ size, open }: {
|
|
14
|
+
size: Size;
|
|
15
|
+
open: boolean;
|
|
16
|
+
}): {
|
|
17
|
+
ArrowIcon: ({ size, ...props }: import("@snack-uikit/icons/dist/components/interface-icons/chevronUp").ISvgIconProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
arrowIconSize: 16 | 24;
|
|
19
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { ChevronDownSVG, ChevronUpSVG } from '@snack-uikit/icons';
|
|
13
|
+
import { ICON_SIZE, SIZE } from '@snack-uikit/input-private';
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
export function isBaseOptionProps(option) {
|
|
16
|
+
return !('options' in option);
|
|
17
|
+
}
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
export function isAccordionOptionProps(option) {
|
|
20
|
+
return 'options' in option && option['type'] === 'collapse';
|
|
21
|
+
}
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
export function isNextListOptionProps(option) {
|
|
24
|
+
return 'options' in option && option['type'] === 'next-list';
|
|
25
|
+
}
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
export function isGroupOptionProps(option) {
|
|
28
|
+
return 'options' in option && option['type'] === undefined;
|
|
29
|
+
}
|
|
30
|
+
export function transformOptionsToItems(options) {
|
|
31
|
+
return options.map(option => {
|
|
32
|
+
if (isAccordionOptionProps(option) || isNextListOptionProps(option)) {
|
|
33
|
+
const { description, option: contentOption, caption, options, value } = option, rest = __rest(option, ["description", "option", "caption", "options", "value"]);
|
|
34
|
+
return Object.assign(Object.assign({ 'data-test-id': 'field-select__list-option-' + option.value }, rest), { id: value, content: { option: contentOption, caption, description }, items: transformOptionsToItems(options) });
|
|
35
|
+
}
|
|
36
|
+
if (isGroupOptionProps(option)) {
|
|
37
|
+
const { options } = option, rest = __rest(option, ["options"]);
|
|
38
|
+
return Object.assign(Object.assign({}, rest), { items: transformOptionsToItems(options) });
|
|
39
|
+
}
|
|
40
|
+
const _a = option, { description, option: contentOption, caption, value } = _a, rest = __rest(_a, ["description", "option", "caption", "value"]);
|
|
41
|
+
return Object.assign(Object.assign({ 'data-test-id': 'field-select__list-option-' + option.value }, rest), { id: value, content: { option: contentOption, caption, description } });
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export function extractSelectedOptions(options, value) {
|
|
45
|
+
for (let i = 0; i < options.length; i++) {
|
|
46
|
+
const option = options[i];
|
|
47
|
+
if (isAccordionOptionProps(option) || isNextListOptionProps(option)) {
|
|
48
|
+
const { value: optionValue } = option;
|
|
49
|
+
if (optionValue === value) {
|
|
50
|
+
return option;
|
|
51
|
+
}
|
|
52
|
+
const selectedOptionFromNestedOptions = extractSelectedOptions(option.options, value);
|
|
53
|
+
if (selectedOptionFromNestedOptions) {
|
|
54
|
+
return selectedOptionFromNestedOptions;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (isGroupOptionProps(option)) {
|
|
58
|
+
const selectedOptionFromNestedOptions = extractSelectedOptions(option.options, value);
|
|
59
|
+
if (selectedOptionFromNestedOptions) {
|
|
60
|
+
return selectedOptionFromNestedOptions;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (isBaseOptionProps(option)) {
|
|
64
|
+
if (option.value === value) {
|
|
65
|
+
return option;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
export function extractSelectedMultipleOptions(options, value) {
|
|
72
|
+
let selectedOptions = [];
|
|
73
|
+
for (let i = 0; i < options.length; i++) {
|
|
74
|
+
const option = options[i];
|
|
75
|
+
if (isAccordionOptionProps(option) || isNextListOptionProps(option)) {
|
|
76
|
+
const { value: optionValue } = option;
|
|
77
|
+
if (value === null || value === void 0 ? void 0 : value.includes(optionValue)) {
|
|
78
|
+
selectedOptions.push(option);
|
|
79
|
+
}
|
|
80
|
+
const selectedOptionFromNestedOptions = extractSelectedMultipleOptions(option.options, value);
|
|
81
|
+
if (selectedOptionFromNestedOptions) {
|
|
82
|
+
selectedOptions = selectedOptions.concat(selectedOptionFromNestedOptions);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (isGroupOptionProps(option)) {
|
|
86
|
+
const selectedOptionFromNestedOptions = extractSelectedMultipleOptions(option.options, value);
|
|
87
|
+
if (selectedOptionFromNestedOptions) {
|
|
88
|
+
selectedOptions = selectedOptions.concat(selectedOptionFromNestedOptions);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (isBaseOptionProps(option)) {
|
|
92
|
+
if (value === null || value === void 0 ? void 0 : value.includes(option.value)) {
|
|
93
|
+
selectedOptions.push(option);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return selectedOptions.length ? selectedOptions : undefined;
|
|
98
|
+
}
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
100
|
+
export function isFieldSelectMultipleProps(props) {
|
|
101
|
+
return 'selection' in props && props['selection'] === 'multiple';
|
|
102
|
+
}
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
|
+
export function isFieldSelectSingleProps(props) {
|
|
105
|
+
return ('selection' in props && props['selection'] === 'single') || props['selection'] === undefined;
|
|
106
|
+
}
|
|
107
|
+
export function getArrowIcon({ size, open }) {
|
|
108
|
+
return {
|
|
109
|
+
ArrowIcon: open ? ChevronUpSVG : ChevronDownSVG,
|
|
110
|
+
arrowIconSize: size === SIZE.S ? ICON_SIZE.Xs : ICON_SIZE.S,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
border-radius:var(--radius-fields-s, 12px);
|
|
11
11
|
border-width:var(--border-width-fields-single, 2px);
|
|
12
12
|
}
|
|
13
|
-
.container[data-size=s],
|
|
13
|
+
.container[data-size=s],
|
|
14
|
+
.container[data-size=s] input,
|
|
15
|
+
.container[data-size=s] select,
|
|
16
|
+
.container[data-size=s] textarea,
|
|
17
|
+
.container[data-size=s] span{
|
|
14
18
|
font-family:var(--sans-body-s-font-family, SB Sans Interface);
|
|
15
19
|
font-weight:var(--sans-body-s-font-weight, Regular);
|
|
16
20
|
line-height:var(--sans-body-s-line-height, 16px);
|
|
@@ -39,7 +43,11 @@
|
|
|
39
43
|
border-radius:var(--radius-fields-m, 14px);
|
|
40
44
|
border-width:var(--border-width-fields-single, 2px);
|
|
41
45
|
}
|
|
42
|
-
.container[data-size=m],
|
|
46
|
+
.container[data-size=m],
|
|
47
|
+
.container[data-size=m] input,
|
|
48
|
+
.container[data-size=m] select,
|
|
49
|
+
.container[data-size=m] textarea,
|
|
50
|
+
.container[data-size=m] span{
|
|
43
51
|
font-family:var(--sans-body-m-font-family, SB Sans Interface);
|
|
44
52
|
font-weight:var(--sans-body-m-font-weight, Regular);
|
|
45
53
|
line-height:var(--sans-body-m-line-height, 20px);
|
|
@@ -68,7 +76,11 @@
|
|
|
68
76
|
border-radius:var(--radius-fields-l, 16px);
|
|
69
77
|
border-width:var(--border-width-fields-single, 2px);
|
|
70
78
|
}
|
|
71
|
-
.container[data-size=l],
|
|
79
|
+
.container[data-size=l],
|
|
80
|
+
.container[data-size=l] input,
|
|
81
|
+
.container[data-size=l] select,
|
|
82
|
+
.container[data-size=l] textarea,
|
|
83
|
+
.container[data-size=l] span{
|
|
72
84
|
font-family:var(--sans-body-l-font-family, SB Sans Interface);
|
|
73
85
|
font-weight:var(--sans-body-l-font-weight, Regular);
|
|
74
86
|
line-height:var(--sans-body-l-line-height, 24px);
|
|
@@ -157,10 +169,18 @@
|
|
|
157
169
|
border-color:var(--sys-green-accent-default, #57b762);
|
|
158
170
|
outline-color:var(--sys-green-decor-activated, #a8d1a2);
|
|
159
171
|
}
|
|
160
|
-
.container[data-selectable],
|
|
172
|
+
.container[data-selectable],
|
|
173
|
+
.container[data-selectable] input,
|
|
174
|
+
.container[data-selectable] select,
|
|
175
|
+
.container[data-selectable] textarea,
|
|
176
|
+
.container[data-selectable] span{
|
|
161
177
|
cursor:pointer;
|
|
162
178
|
}
|
|
163
|
-
.container[data-readonly],
|
|
179
|
+
.container[data-readonly],
|
|
180
|
+
.container[data-readonly] input,
|
|
181
|
+
.container[data-readonly] select,
|
|
182
|
+
.container[data-readonly] textarea,
|
|
183
|
+
.container[data-readonly] span{
|
|
164
184
|
cursor:default;
|
|
165
185
|
}
|
|
166
186
|
.container[data-readonly], .container[data-readonly]:hover{
|
|
@@ -175,7 +195,11 @@
|
|
|
175
195
|
border-color:var(--sys-neutral-decor-disabled, #e8eaf1);
|
|
176
196
|
outline-color:var(--sys-primary-decor-activated, #c5b2f1);
|
|
177
197
|
}
|
|
178
|
-
.container[data-disabled],
|
|
198
|
+
.container[data-disabled],
|
|
199
|
+
.container[data-disabled] input,
|
|
200
|
+
.container[data-disabled] select,
|
|
201
|
+
.container[data-disabled] textarea,
|
|
202
|
+
.container[data-disabled] span{
|
|
179
203
|
cursor:not-allowed;
|
|
180
204
|
}
|
|
181
205
|
.container[data-disabled], .container[data-disabled]:focus-within, .container[data-disabled][data-focused], .container[data-disabled]:hover{
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"title": "Fields",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.15.0",
|
|
8
8
|
"sideEffects": [
|
|
9
9
|
"*.css",
|
|
10
10
|
"*.woff",
|
|
@@ -34,11 +34,13 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@snack-uikit/button": "0.16.1",
|
|
36
36
|
"@snack-uikit/calendar": "0.7.6",
|
|
37
|
-
"@snack-uikit/droplist": "0.13.
|
|
37
|
+
"@snack-uikit/droplist": "0.13.7",
|
|
38
38
|
"@snack-uikit/icons": "0.20.1",
|
|
39
39
|
"@snack-uikit/input-private": "3.1.1",
|
|
40
|
+
"@snack-uikit/list": "0.4.0",
|
|
40
41
|
"@snack-uikit/scroll": "0.5.2",
|
|
41
42
|
"@snack-uikit/slider": "0.1.3",
|
|
43
|
+
"@snack-uikit/tag": "0.8.0",
|
|
42
44
|
"@snack-uikit/tooltip": "0.12.0",
|
|
43
45
|
"@snack-uikit/truncate-string": "0.4.8",
|
|
44
46
|
"@snack-uikit/utils": "3.2.0",
|
|
@@ -54,5 +56,5 @@
|
|
|
54
56
|
"peerDependencies": {
|
|
55
57
|
"@snack-uikit/locale": "*"
|
|
56
58
|
},
|
|
57
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "ee199e2cdca1d24db821533512263dfe06365159"
|
|
58
60
|
}
|
|
@@ -41,7 +41,12 @@ export function Header({
|
|
|
41
41
|
</label>
|
|
42
42
|
{required && <span data-test-id='field-decorator__required-sign'>*</span>}
|
|
43
43
|
{labelTooltip && (
|
|
44
|
-
<Tooltip
|
|
44
|
+
<Tooltip
|
|
45
|
+
tip={labelTooltip}
|
|
46
|
+
placement={labelTooltipPlacement}
|
|
47
|
+
data-test-id='field-decorator__label-tooltip'
|
|
48
|
+
triggerClassName={styles.labelTooltipTrigger}
|
|
49
|
+
>
|
|
45
50
|
<QuestionSVG size={16} className={styles.icon} data-test-id='field-decorator__label-tooltip-trigger' />
|
|
46
51
|
</Tooltip>
|
|
47
52
|
)}
|