@snack-uikit/chips 0.8.5-preview-85c5f47b.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 +483 -0
- package/LICENSE +201 -0
- package/README.md +226 -0
- package/dist/components/ChipAssist/ChipAssist.d.ts +15 -0
- package/dist/components/ChipAssist/ChipAssist.js +31 -0
- package/dist/components/ChipAssist/index.d.ts +1 -0
- package/dist/components/ChipAssist/index.js +1 -0
- package/dist/components/ChipAssist/styles.module.css +159 -0
- package/dist/components/ChipChoice/components/ChipChoiceCustom/ChipChoiceCustom.d.ts +23 -0
- package/dist/components/ChipChoice/components/ChipChoiceCustom/ChipChoiceCustom.js +75 -0
- package/dist/components/ChipChoice/components/ChipChoiceCustom/index.d.ts +1 -0
- package/dist/components/ChipChoice/components/ChipChoiceCustom/index.js +1 -0
- package/dist/components/ChipChoice/components/ChipChoiceCustom/styles.module.css +402 -0
- package/dist/components/ChipChoice/components/ChipChoiceDate.d.ts +12 -0
- package/dist/components/ChipChoice/components/ChipChoiceDate.js +29 -0
- package/dist/components/ChipChoice/components/ChipChoiceDateRange.d.ts +14 -0
- package/dist/components/ChipChoice/components/ChipChoiceDateRange.js +36 -0
- package/dist/components/ChipChoice/components/ChipChoiceMulti.d.ts +14 -0
- package/dist/components/ChipChoice/components/ChipChoiceMulti.js +42 -0
- package/dist/components/ChipChoice/components/ChipChoiceSingle.d.ts +14 -0
- package/dist/components/ChipChoice/components/ChipChoiceSingle.js +34 -0
- package/dist/components/ChipChoice/components/index.d.ts +5 -0
- package/dist/components/ChipChoice/components/index.js +5 -0
- package/dist/components/ChipChoice/constants.d.ts +25 -0
- package/dist/components/ChipChoice/constants.js +28 -0
- package/dist/components/ChipChoice/index.d.ts +17 -0
- package/dist/components/ChipChoice/index.js +17 -0
- package/dist/components/ChipChoice/styles.module.css +199 -0
- package/dist/components/ChipChoice/types.d.ts +27 -0
- package/dist/components/ChipChoice/types.js +1 -0
- package/dist/components/ChipChoice/utils.d.ts +4 -0
- package/dist/components/ChipChoice/utils.js +14 -0
- package/dist/components/ChipChoiceRow/ChipChoiceRow.d.ts +26 -0
- package/dist/components/ChipChoiceRow/ChipChoiceRow.js +45 -0
- package/dist/components/ChipChoiceRow/components/ForwardedChipChoice.d.ts +2 -0
- package/dist/components/ChipChoiceRow/components/ForwardedChipChoice.js +6 -0
- package/dist/components/ChipChoiceRow/components/constants.d.ts +6 -0
- package/dist/components/ChipChoiceRow/components/constants.js +7 -0
- package/dist/components/ChipChoiceRow/components/index.d.ts +1 -0
- package/dist/components/ChipChoiceRow/components/index.js +1 -0
- package/dist/components/ChipChoiceRow/constants.d.ts +15 -0
- package/dist/components/ChipChoiceRow/constants.js +18 -0
- package/dist/components/ChipChoiceRow/index.d.ts +1 -0
- package/dist/components/ChipChoiceRow/index.js +1 -0
- package/dist/components/ChipChoiceRow/styles.module.css +6 -0
- package/dist/components/ChipChoiceRow/types.d.ts +20 -0
- package/dist/components/ChipChoiceRow/types.js +1 -0
- package/dist/components/ChipToggle/ChipToggle.d.ts +17 -0
- package/dist/components/ChipToggle/ChipToggle.js +31 -0
- package/dist/components/ChipToggle/index.d.ts +1 -0
- package/dist/components/ChipToggle/index.js +1 -0
- package/dist/components/ChipToggle/styles.module.css +219 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +4 -0
- package/dist/constants.d.ts +37 -0
- package/dist/constants.js +40 -0
- package/dist/helperComponents/ButtonClearValue/ButtonClearValue.d.ts +11 -0
- package/dist/helperComponents/ButtonClearValue/ButtonClearValue.js +12 -0
- package/dist/helperComponents/ButtonClearValue/index.d.ts +1 -0
- package/dist/helperComponents/ButtonClearValue/index.js +1 -0
- package/dist/helperComponents/ButtonClearValue/styles.module.css +43 -0
- package/dist/helperComponents/index.d.ts +1 -0
- package/dist/helperComponents/index.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/styles.module.css +0 -0
- package/dist/types.d.ts +15 -0
- package/dist/types.js +1 -0
- package/package.json +45 -0
- package/src/components/ChipAssist/ChipAssist.tsx +73 -0
- package/src/components/ChipAssist/index.ts +1 -0
- package/src/components/ChipAssist/styles.module.scss +60 -0
- package/src/components/ChipChoice/components/ChipChoiceCustom/ChipChoiceCustom.tsx +188 -0
- package/src/components/ChipChoice/components/ChipChoiceCustom/index.ts +1 -0
- package/src/components/ChipChoice/components/ChipChoiceCustom/styles.module.scss +90 -0
- package/src/components/ChipChoice/components/ChipChoiceDate.tsx +60 -0
- package/src/components/ChipChoice/components/ChipChoiceDateRange.tsx +69 -0
- package/src/components/ChipChoice/components/ChipChoiceMulti.tsx +87 -0
- package/src/components/ChipChoice/components/ChipChoiceSingle.tsx +77 -0
- package/src/components/ChipChoice/components/index.ts +5 -0
- package/src/components/ChipChoice/constants.ts +32 -0
- package/src/components/ChipChoice/index.ts +39 -0
- package/src/components/ChipChoice/styles.module.scss +90 -0
- package/src/components/ChipChoice/types.ts +33 -0
- package/src/components/ChipChoice/utils.ts +20 -0
- package/src/components/ChipChoiceRow/ChipChoiceRow.tsx +100 -0
- package/src/components/ChipChoiceRow/components/ForwardedChipChoice.tsx +10 -0
- package/src/components/ChipChoiceRow/components/constants.ts +8 -0
- package/src/components/ChipChoiceRow/components/index.ts +1 -0
- package/src/components/ChipChoiceRow/constants.ts +21 -0
- package/src/components/ChipChoiceRow/index.ts +1 -0
- package/src/components/ChipChoiceRow/styles.module.scss +8 -0
- package/src/components/ChipChoiceRow/types.ts +34 -0
- package/src/components/ChipToggle/ChipToggle.tsx +87 -0
- package/src/components/ChipToggle/index.ts +1 -0
- package/src/components/ChipToggle/styles.module.scss +153 -0
- package/src/components/index.ts +4 -0
- package/src/constants.ts +44 -0
- package/src/helperComponents/ButtonClearValue/ButtonClearValue.tsx +39 -0
- package/src/helperComponents/ButtonClearValue/index.ts +1 -0
- package/src/helperComponents/ButtonClearValue/styles.module.scss +50 -0
- package/src/helperComponents/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/styles.module.scss +114 -0
- package/src/types.ts +16 -0
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
.label, .value{
|
|
2
|
+
display:inline-flex;
|
|
3
|
+
align-items:center;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.choiceChip{
|
|
7
|
+
cursor:pointer;
|
|
8
|
+
position:relative;
|
|
9
|
+
display:inline-flex;
|
|
10
|
+
align-items:center;
|
|
11
|
+
box-sizing:border-box;
|
|
12
|
+
width:-moz-max-content;
|
|
13
|
+
width:max-content;
|
|
14
|
+
min-width:-moz-max-content;
|
|
15
|
+
min-width:max-content;
|
|
16
|
+
margin:0;
|
|
17
|
+
padding:0;
|
|
18
|
+
text-decoration:none;
|
|
19
|
+
text-transform:none;
|
|
20
|
+
border-style:solid;
|
|
21
|
+
outline:0;
|
|
22
|
+
outline-offset:0;
|
|
23
|
+
background-color:var(--sys-neutral-background1-level, #f9f9f9);
|
|
24
|
+
border-color:var(--sys-neutral-decor-default, #dedede);
|
|
25
|
+
}
|
|
26
|
+
.choiceChip .spinner{
|
|
27
|
+
display:inline-flex;
|
|
28
|
+
}
|
|
29
|
+
.choiceChip .icon{
|
|
30
|
+
display:inline-flex;
|
|
31
|
+
}
|
|
32
|
+
.choiceChip .icon svg{
|
|
33
|
+
width:var(--dimension-3m, 24px) !important;
|
|
34
|
+
height:var(--dimension-3m, 24px) !important;
|
|
35
|
+
}
|
|
36
|
+
.choiceChip .labelLayout{
|
|
37
|
+
display:inline-flex;
|
|
38
|
+
align-items:center;
|
|
39
|
+
}
|
|
40
|
+
.choiceChip[data-size=xs]{
|
|
41
|
+
height:var(--size-chips-xs, 24px);
|
|
42
|
+
padding-left:var(--space-chips-container-padding-xs, 3px);
|
|
43
|
+
padding-right:var(--space-chips-container-padding-xs, 3px);
|
|
44
|
+
border-radius:var(--radius-chips-xs, 12px);
|
|
45
|
+
border-width:var(--border-width-chips-single, 1px);
|
|
46
|
+
}
|
|
47
|
+
.choiceChip[data-size=xs] .label{
|
|
48
|
+
font-family:var(--light-label-s-font-family, SB Sans Interface);
|
|
49
|
+
font-weight:var(--light-label-s-font-weight, Regular);
|
|
50
|
+
line-height:var(--light-label-s-line-height, 14px);
|
|
51
|
+
font-size:var(--light-label-s-font-size, 11px);
|
|
52
|
+
letter-spacing:var(--light-label-s-letter-spacing, -0.1px);
|
|
53
|
+
paragraph-spacing:var(--light-label-s-paragraph-spacing, 6.05px);
|
|
54
|
+
}
|
|
55
|
+
.choiceChip[data-size=xs] .labelLayout{
|
|
56
|
+
padding-left:var(--space-chips-label-layout-padding-xs, 4px);
|
|
57
|
+
padding-right:var(--space-chips-label-layout-padding-xs, 4px);
|
|
58
|
+
gap:var(--space-chips-label-layout-gap, 2px);
|
|
59
|
+
}
|
|
60
|
+
.choiceChip[data-size=s]{
|
|
61
|
+
height:var(--size-chips-s, 32px);
|
|
62
|
+
padding-left:var(--space-chips-container-padding-s, 3px);
|
|
63
|
+
padding-right:var(--space-chips-container-padding-s, 3px);
|
|
64
|
+
border-radius:var(--radius-chips-s, 16px);
|
|
65
|
+
border-width:var(--border-width-chips-single, 1px);
|
|
66
|
+
}
|
|
67
|
+
.choiceChip[data-size=s] .label{
|
|
68
|
+
font-family:var(--light-label-m-font-family, SB Sans Interface);
|
|
69
|
+
font-weight:var(--light-label-m-font-weight, Regular);
|
|
70
|
+
line-height:var(--light-label-m-line-height, 16px);
|
|
71
|
+
font-size:var(--light-label-m-font-size, 12px);
|
|
72
|
+
letter-spacing:var(--light-label-m-letter-spacing, -0.1px);
|
|
73
|
+
paragraph-spacing:var(--light-label-m-paragraph-spacing, 6.6px);
|
|
74
|
+
}
|
|
75
|
+
.choiceChip[data-size=s] .labelLayout{
|
|
76
|
+
padding-left:var(--space-chips-label-layout-padding-s, 4px);
|
|
77
|
+
padding-right:var(--space-chips-label-layout-padding-s, 4px);
|
|
78
|
+
gap:var(--space-chips-label-layout-gap, 2px);
|
|
79
|
+
}
|
|
80
|
+
.choiceChip[data-size=m]{
|
|
81
|
+
height:var(--size-chips-m, 40px);
|
|
82
|
+
padding-left:var(--space-chips-container-padding-m, 7px);
|
|
83
|
+
padding-right:var(--space-chips-container-padding-m, 7px);
|
|
84
|
+
border-radius:var(--radius-chips-m, 20px);
|
|
85
|
+
border-width:var(--border-width-chips-single, 1px);
|
|
86
|
+
}
|
|
87
|
+
.choiceChip[data-size=m] .label{
|
|
88
|
+
font-family:var(--light-label-m-font-family, SB Sans Interface);
|
|
89
|
+
font-weight:var(--light-label-m-font-weight, Regular);
|
|
90
|
+
line-height:var(--light-label-m-line-height, 16px);
|
|
91
|
+
font-size:var(--light-label-m-font-size, 12px);
|
|
92
|
+
letter-spacing:var(--light-label-m-letter-spacing, -0.1px);
|
|
93
|
+
paragraph-spacing:var(--light-label-m-paragraph-spacing, 6.6px);
|
|
94
|
+
}
|
|
95
|
+
.choiceChip[data-size=m] .labelLayout{
|
|
96
|
+
padding-left:var(--space-chips-label-layout-padding-m, 8px);
|
|
97
|
+
padding-right:var(--space-chips-label-layout-padding-m, 8px);
|
|
98
|
+
gap:var(--space-chips-label-layout-gap, 2px);
|
|
99
|
+
}
|
|
100
|
+
.choiceChip[data-size=l]{
|
|
101
|
+
height:var(--size-chips-l, 48px);
|
|
102
|
+
padding-left:var(--space-chips-container-padding-l, 11px);
|
|
103
|
+
padding-right:var(--space-chips-container-padding-l, 11px);
|
|
104
|
+
border-radius:var(--radius-chips-l, 24px);
|
|
105
|
+
border-width:var(--border-width-chips-single, 1px);
|
|
106
|
+
}
|
|
107
|
+
.choiceChip[data-size=l] .label{
|
|
108
|
+
font-family:var(--light-label-l-font-family, SB Sans Interface);
|
|
109
|
+
font-weight:var(--light-label-l-font-weight, Regular);
|
|
110
|
+
line-height:var(--light-label-l-line-height, 20px);
|
|
111
|
+
font-size:var(--light-label-l-font-size, 14px);
|
|
112
|
+
letter-spacing:var(--light-label-l-letter-spacing, -0.1px);
|
|
113
|
+
paragraph-spacing:var(--light-label-l-paragraph-spacing, 7.7px);
|
|
114
|
+
}
|
|
115
|
+
.choiceChip[data-size=l] .labelLayout{
|
|
116
|
+
padding-left:var(--space-chips-label-layout-padding-l, 12px);
|
|
117
|
+
padding-right:var(--space-chips-label-layout-padding-l, 12px);
|
|
118
|
+
gap:var(--space-chips-label-layout-gap, 2px);
|
|
119
|
+
}
|
|
120
|
+
.choiceChip .label, .choiceChip .value{
|
|
121
|
+
color:var(--sys-neutral-text-support, #565656);
|
|
122
|
+
}
|
|
123
|
+
.choiceChip .icon{
|
|
124
|
+
color:var(--sys-neutral-text-light, #898989);
|
|
125
|
+
}
|
|
126
|
+
.choiceChip[data-size=xs] .value{
|
|
127
|
+
font-family:var(--sans-label-s-font-family, SB Sans Interface);
|
|
128
|
+
font-weight:var(--sans-label-s-font-weight, Semibold);
|
|
129
|
+
line-height:var(--sans-label-s-line-height, 14px);
|
|
130
|
+
font-size:var(--sans-label-s-font-size, 11px);
|
|
131
|
+
letter-spacing:var(--sans-label-s-letter-spacing, -0.1px);
|
|
132
|
+
paragraph-spacing:var(--sans-label-s-paragraph-spacing, 6.05px);
|
|
133
|
+
}
|
|
134
|
+
.choiceChip[data-size=s] .value{
|
|
135
|
+
font-family:var(--sans-label-m-font-family, SB Sans Interface);
|
|
136
|
+
font-weight:var(--sans-label-m-font-weight, Semibold);
|
|
137
|
+
line-height:var(--sans-label-m-line-height, 16px);
|
|
138
|
+
font-size:var(--sans-label-m-font-size, 12px);
|
|
139
|
+
letter-spacing:var(--sans-label-m-letter-spacing, -0.1px);
|
|
140
|
+
paragraph-spacing:var(--sans-label-m-paragraph-spacing, 6.6px);
|
|
141
|
+
}
|
|
142
|
+
.choiceChip[data-size=m] .value{
|
|
143
|
+
font-family:var(--sans-label-m-font-family, SB Sans Interface);
|
|
144
|
+
font-weight:var(--sans-label-m-font-weight, Semibold);
|
|
145
|
+
line-height:var(--sans-label-m-line-height, 16px);
|
|
146
|
+
font-size:var(--sans-label-m-font-size, 12px);
|
|
147
|
+
letter-spacing:var(--sans-label-m-letter-spacing, -0.1px);
|
|
148
|
+
paragraph-spacing:var(--sans-label-m-paragraph-spacing, 6.6px);
|
|
149
|
+
}
|
|
150
|
+
.choiceChip[data-size=l] .value{
|
|
151
|
+
font-family:var(--sans-label-l-font-family, SB Sans Interface);
|
|
152
|
+
font-weight:var(--sans-label-l-font-weight, Semibold);
|
|
153
|
+
line-height:var(--sans-label-l-line-height, 20px);
|
|
154
|
+
font-size:var(--sans-label-l-font-size, 14px);
|
|
155
|
+
letter-spacing:var(--sans-label-l-letter-spacing, -0.1px);
|
|
156
|
+
paragraph-spacing:var(--sans-label-l-paragraph-spacing, 7.7px);
|
|
157
|
+
}
|
|
158
|
+
.choiceChip:hover, .choiceChip:active, .choiceChip:focus-visible{
|
|
159
|
+
background-color:var(--sys-neutral-background2-level, #fdfdfd);
|
|
160
|
+
border-color:var(--sys-neutral-decor-hovered, #d2d2d2);
|
|
161
|
+
}
|
|
162
|
+
.choiceChip:hover .label, .choiceChip:active .label, .choiceChip:focus-visible .label{
|
|
163
|
+
color:var(--sys-neutral-text-support, #565656);
|
|
164
|
+
}
|
|
165
|
+
.choiceChip:hover .value, .choiceChip:active .value, .choiceChip:focus-visible .value{
|
|
166
|
+
color:var(--sys-neutral-text-main, #333333);
|
|
167
|
+
}
|
|
168
|
+
.choiceChip:focus-visible{
|
|
169
|
+
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
170
|
+
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
171
|
+
outline-color:var(--border-state-focus-s-border-color, );
|
|
172
|
+
outline-color:var(--sys-available-complementary, #131313);
|
|
173
|
+
outline-offset:var(--spacing-state-focus-offset, 2px);
|
|
174
|
+
}
|
|
175
|
+
.choiceChip[data-disabled]{
|
|
176
|
+
cursor:not-allowed;
|
|
177
|
+
background-color:var(--sys-neutral-background, #f0f0f0);
|
|
178
|
+
border-color:var(--sys-neutral-decor-disabled, #e7e7e7);
|
|
179
|
+
}
|
|
180
|
+
.choiceChip[data-disabled] .label, .choiceChip[data-disabled] .value{
|
|
181
|
+
color:var(--sys-neutral-text-light, #898989);
|
|
182
|
+
}
|
|
183
|
+
.choiceChip[data-loading]{
|
|
184
|
+
cursor:progress;
|
|
185
|
+
background-color:var(--sys-neutral-background, #f0f0f0);
|
|
186
|
+
border-color:var(--sys-neutral-decor-activated, #b8b8b8);
|
|
187
|
+
}
|
|
188
|
+
.choiceChip[data-loading] true .spinner{
|
|
189
|
+
display:flex;
|
|
190
|
+
align-items:center;
|
|
191
|
+
justify-content:center;
|
|
192
|
+
}
|
|
193
|
+
.choiceChip[data-loading] .label, .choiceChip[data-loading] .value{
|
|
194
|
+
color:var(--sys-neutral-text-support, #565656);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.triggerClassName{
|
|
198
|
+
--offset:calc(var(--border-state-focus-s-border-width, 2px) + var(--space-drop-list-drop-offset, 4px));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.label, .value{
|
|
202
|
+
display:inline-flex;
|
|
203
|
+
align-items:center;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.choiceChip{
|
|
207
|
+
cursor:pointer;
|
|
208
|
+
position:relative;
|
|
209
|
+
display:inline-flex;
|
|
210
|
+
align-items:center;
|
|
211
|
+
box-sizing:border-box;
|
|
212
|
+
width:-moz-max-content;
|
|
213
|
+
width:max-content;
|
|
214
|
+
min-width:-moz-max-content;
|
|
215
|
+
min-width:max-content;
|
|
216
|
+
margin:0;
|
|
217
|
+
padding:0;
|
|
218
|
+
text-decoration:none;
|
|
219
|
+
text-transform:none;
|
|
220
|
+
border-style:solid;
|
|
221
|
+
outline:0;
|
|
222
|
+
outline-offset:0;
|
|
223
|
+
background-color:var(--sys-neutral-background1-level, #f9f9f9);
|
|
224
|
+
border-color:var(--sys-neutral-decor-default, #dedede);
|
|
225
|
+
}
|
|
226
|
+
.choiceChip .spinner{
|
|
227
|
+
display:inline-flex;
|
|
228
|
+
}
|
|
229
|
+
.choiceChip .icon{
|
|
230
|
+
display:inline-flex;
|
|
231
|
+
}
|
|
232
|
+
.choiceChip .icon svg{
|
|
233
|
+
width:var(--dimension-3m, 24px) !important;
|
|
234
|
+
height:var(--dimension-3m, 24px) !important;
|
|
235
|
+
}
|
|
236
|
+
.choiceChip .labelLayout{
|
|
237
|
+
display:inline-flex;
|
|
238
|
+
align-items:center;
|
|
239
|
+
}
|
|
240
|
+
.choiceChip[data-size=xs]{
|
|
241
|
+
height:var(--size-chips-xs, 24px);
|
|
242
|
+
padding-left:var(--space-chips-container-padding-xs, 3px);
|
|
243
|
+
padding-right:var(--space-chips-container-padding-xs, 3px);
|
|
244
|
+
border-radius:var(--radius-chips-xs, 12px);
|
|
245
|
+
border-width:var(--border-width-chips-single, 1px);
|
|
246
|
+
}
|
|
247
|
+
.choiceChip[data-size=xs] .label{
|
|
248
|
+
font-family:var(--light-label-s-font-family, SB Sans Interface);
|
|
249
|
+
font-weight:var(--light-label-s-font-weight, Regular);
|
|
250
|
+
line-height:var(--light-label-s-line-height, 14px);
|
|
251
|
+
font-size:var(--light-label-s-font-size, 11px);
|
|
252
|
+
letter-spacing:var(--light-label-s-letter-spacing, -0.1px);
|
|
253
|
+
paragraph-spacing:var(--light-label-s-paragraph-spacing, 6.05px);
|
|
254
|
+
}
|
|
255
|
+
.choiceChip[data-size=xs] .labelLayout{
|
|
256
|
+
padding-left:var(--space-chips-label-layout-padding-xs, 4px);
|
|
257
|
+
padding-right:var(--space-chips-label-layout-padding-xs, 4px);
|
|
258
|
+
gap:var(--space-chips-label-layout-gap, 2px);
|
|
259
|
+
}
|
|
260
|
+
.choiceChip[data-size=s]{
|
|
261
|
+
height:var(--size-chips-s, 32px);
|
|
262
|
+
padding-left:var(--space-chips-container-padding-s, 3px);
|
|
263
|
+
padding-right:var(--space-chips-container-padding-s, 3px);
|
|
264
|
+
border-radius:var(--radius-chips-s, 16px);
|
|
265
|
+
border-width:var(--border-width-chips-single, 1px);
|
|
266
|
+
}
|
|
267
|
+
.choiceChip[data-size=s] .label{
|
|
268
|
+
font-family:var(--light-label-m-font-family, SB Sans Interface);
|
|
269
|
+
font-weight:var(--light-label-m-font-weight, Regular);
|
|
270
|
+
line-height:var(--light-label-m-line-height, 16px);
|
|
271
|
+
font-size:var(--light-label-m-font-size, 12px);
|
|
272
|
+
letter-spacing:var(--light-label-m-letter-spacing, -0.1px);
|
|
273
|
+
paragraph-spacing:var(--light-label-m-paragraph-spacing, 6.6px);
|
|
274
|
+
}
|
|
275
|
+
.choiceChip[data-size=s] .labelLayout{
|
|
276
|
+
padding-left:var(--space-chips-label-layout-padding-s, 4px);
|
|
277
|
+
padding-right:var(--space-chips-label-layout-padding-s, 4px);
|
|
278
|
+
gap:var(--space-chips-label-layout-gap, 2px);
|
|
279
|
+
}
|
|
280
|
+
.choiceChip[data-size=m]{
|
|
281
|
+
height:var(--size-chips-m, 40px);
|
|
282
|
+
padding-left:var(--space-chips-container-padding-m, 7px);
|
|
283
|
+
padding-right:var(--space-chips-container-padding-m, 7px);
|
|
284
|
+
border-radius:var(--radius-chips-m, 20px);
|
|
285
|
+
border-width:var(--border-width-chips-single, 1px);
|
|
286
|
+
}
|
|
287
|
+
.choiceChip[data-size=m] .label{
|
|
288
|
+
font-family:var(--light-label-m-font-family, SB Sans Interface);
|
|
289
|
+
font-weight:var(--light-label-m-font-weight, Regular);
|
|
290
|
+
line-height:var(--light-label-m-line-height, 16px);
|
|
291
|
+
font-size:var(--light-label-m-font-size, 12px);
|
|
292
|
+
letter-spacing:var(--light-label-m-letter-spacing, -0.1px);
|
|
293
|
+
paragraph-spacing:var(--light-label-m-paragraph-spacing, 6.6px);
|
|
294
|
+
}
|
|
295
|
+
.choiceChip[data-size=m] .labelLayout{
|
|
296
|
+
padding-left:var(--space-chips-label-layout-padding-m, 8px);
|
|
297
|
+
padding-right:var(--space-chips-label-layout-padding-m, 8px);
|
|
298
|
+
gap:var(--space-chips-label-layout-gap, 2px);
|
|
299
|
+
}
|
|
300
|
+
.choiceChip[data-size=l]{
|
|
301
|
+
height:var(--size-chips-l, 48px);
|
|
302
|
+
padding-left:var(--space-chips-container-padding-l, 11px);
|
|
303
|
+
padding-right:var(--space-chips-container-padding-l, 11px);
|
|
304
|
+
border-radius:var(--radius-chips-l, 24px);
|
|
305
|
+
border-width:var(--border-width-chips-single, 1px);
|
|
306
|
+
}
|
|
307
|
+
.choiceChip[data-size=l] .label{
|
|
308
|
+
font-family:var(--light-label-l-font-family, SB Sans Interface);
|
|
309
|
+
font-weight:var(--light-label-l-font-weight, Regular);
|
|
310
|
+
line-height:var(--light-label-l-line-height, 20px);
|
|
311
|
+
font-size:var(--light-label-l-font-size, 14px);
|
|
312
|
+
letter-spacing:var(--light-label-l-letter-spacing, -0.1px);
|
|
313
|
+
paragraph-spacing:var(--light-label-l-paragraph-spacing, 7.7px);
|
|
314
|
+
}
|
|
315
|
+
.choiceChip[data-size=l] .labelLayout{
|
|
316
|
+
padding-left:var(--space-chips-label-layout-padding-l, 12px);
|
|
317
|
+
padding-right:var(--space-chips-label-layout-padding-l, 12px);
|
|
318
|
+
gap:var(--space-chips-label-layout-gap, 2px);
|
|
319
|
+
}
|
|
320
|
+
.choiceChip .label, .choiceChip .value{
|
|
321
|
+
color:var(--sys-neutral-text-support, #565656);
|
|
322
|
+
}
|
|
323
|
+
.choiceChip .icon{
|
|
324
|
+
color:var(--sys-neutral-text-light, #898989);
|
|
325
|
+
}
|
|
326
|
+
.choiceChip[data-size=xs] .value{
|
|
327
|
+
font-family:var(--sans-label-s-font-family, SB Sans Interface);
|
|
328
|
+
font-weight:var(--sans-label-s-font-weight, Semibold);
|
|
329
|
+
line-height:var(--sans-label-s-line-height, 14px);
|
|
330
|
+
font-size:var(--sans-label-s-font-size, 11px);
|
|
331
|
+
letter-spacing:var(--sans-label-s-letter-spacing, -0.1px);
|
|
332
|
+
paragraph-spacing:var(--sans-label-s-paragraph-spacing, 6.05px);
|
|
333
|
+
}
|
|
334
|
+
.choiceChip[data-size=s] .value{
|
|
335
|
+
font-family:var(--sans-label-m-font-family, SB Sans Interface);
|
|
336
|
+
font-weight:var(--sans-label-m-font-weight, Semibold);
|
|
337
|
+
line-height:var(--sans-label-m-line-height, 16px);
|
|
338
|
+
font-size:var(--sans-label-m-font-size, 12px);
|
|
339
|
+
letter-spacing:var(--sans-label-m-letter-spacing, -0.1px);
|
|
340
|
+
paragraph-spacing:var(--sans-label-m-paragraph-spacing, 6.6px);
|
|
341
|
+
}
|
|
342
|
+
.choiceChip[data-size=m] .value{
|
|
343
|
+
font-family:var(--sans-label-m-font-family, SB Sans Interface);
|
|
344
|
+
font-weight:var(--sans-label-m-font-weight, Semibold);
|
|
345
|
+
line-height:var(--sans-label-m-line-height, 16px);
|
|
346
|
+
font-size:var(--sans-label-m-font-size, 12px);
|
|
347
|
+
letter-spacing:var(--sans-label-m-letter-spacing, -0.1px);
|
|
348
|
+
paragraph-spacing:var(--sans-label-m-paragraph-spacing, 6.6px);
|
|
349
|
+
}
|
|
350
|
+
.choiceChip[data-size=l] .value{
|
|
351
|
+
font-family:var(--sans-label-l-font-family, SB Sans Interface);
|
|
352
|
+
font-weight:var(--sans-label-l-font-weight, Semibold);
|
|
353
|
+
line-height:var(--sans-label-l-line-height, 20px);
|
|
354
|
+
font-size:var(--sans-label-l-font-size, 14px);
|
|
355
|
+
letter-spacing:var(--sans-label-l-letter-spacing, -0.1px);
|
|
356
|
+
paragraph-spacing:var(--sans-label-l-paragraph-spacing, 7.7px);
|
|
357
|
+
}
|
|
358
|
+
.choiceChip:hover, .choiceChip:active, .choiceChip:focus-visible{
|
|
359
|
+
background-color:var(--sys-neutral-background2-level, #fdfdfd);
|
|
360
|
+
border-color:var(--sys-neutral-decor-hovered, #d2d2d2);
|
|
361
|
+
}
|
|
362
|
+
.choiceChip:hover .label, .choiceChip:active .label, .choiceChip:focus-visible .label{
|
|
363
|
+
color:var(--sys-neutral-text-support, #565656);
|
|
364
|
+
}
|
|
365
|
+
.choiceChip:hover .value, .choiceChip:active .value, .choiceChip:focus-visible .value{
|
|
366
|
+
color:var(--sys-neutral-text-main, #333333);
|
|
367
|
+
}
|
|
368
|
+
.choiceChip:focus-visible{
|
|
369
|
+
outline-width:var(--border-state-focus-s-border-width, 2px);
|
|
370
|
+
outline-style:var(--border-state-focus-s-border-style, solid);
|
|
371
|
+
outline-color:var(--border-state-focus-s-border-color, );
|
|
372
|
+
outline-color:var(--sys-available-complementary, #131313);
|
|
373
|
+
outline-offset:var(--spacing-state-focus-offset, 2px);
|
|
374
|
+
}
|
|
375
|
+
.choiceChip[data-disabled]{
|
|
376
|
+
cursor:not-allowed;
|
|
377
|
+
background-color:var(--sys-neutral-background, #f0f0f0);
|
|
378
|
+
border-color:var(--sys-neutral-decor-disabled, #e7e7e7);
|
|
379
|
+
}
|
|
380
|
+
.choiceChip[data-disabled] .label, .choiceChip[data-disabled] .value{
|
|
381
|
+
color:var(--sys-neutral-text-light, #898989);
|
|
382
|
+
}
|
|
383
|
+
.choiceChip[data-loading]{
|
|
384
|
+
cursor:progress;
|
|
385
|
+
background-color:var(--sys-neutral-background, #f0f0f0);
|
|
386
|
+
border-color:var(--sys-neutral-decor-activated, #b8b8b8);
|
|
387
|
+
}
|
|
388
|
+
.choiceChip[data-loading]:not([data-label]) .value{
|
|
389
|
+
opacity:var(--opacity-a0, 0);
|
|
390
|
+
}
|
|
391
|
+
.choiceChip[data-loading]:not([data-label]) .spinner{
|
|
392
|
+
display:flex;
|
|
393
|
+
align-items:center;
|
|
394
|
+
justify-content:center;
|
|
395
|
+
}
|
|
396
|
+
.choiceChip[data-loading] .label, .choiceChip[data-loading] .value{
|
|
397
|
+
color:var(--sys-neutral-text-support, #565656);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
.triggerClassName{
|
|
401
|
+
--offset:calc(var(--border-state-focus-s-border-width, 2px) + var(--space-drop-list-drop-offset, 4px));
|
|
402
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ChipChoiceCommonProps } from '../types';
|
|
2
|
+
export type ChipChoiceDateProps = ChipChoiceCommonProps & {
|
|
3
|
+
/** Значение компонента */
|
|
4
|
+
value?: Date;
|
|
5
|
+
/** Значение компонента по-умолчанию */
|
|
6
|
+
defaultValue?: Date;
|
|
7
|
+
/** Колбек смены значения */
|
|
8
|
+
onChange?(value: Date): void;
|
|
9
|
+
/** Колбек формирующий строковое представление выбранного значения. Принимает выбранное значение */
|
|
10
|
+
valueFormatter?(value?: Date): string;
|
|
11
|
+
};
|
|
12
|
+
export declare function ChipChoiceDate({ size, value, defaultValue, onChange, valueFormatter, ...rest }: ChipChoiceDateProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
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 { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { useUncontrolledProp } from 'uncontrollable';
|
|
14
|
+
import { Calendar } from '@snack-uikit/calendar';
|
|
15
|
+
import { DEFAULT_EMPTY_VALUE, Size } from '../../../constants';
|
|
16
|
+
import { CALENDAR_SIZE_MAP } from '../constants';
|
|
17
|
+
import { ChipChoiceCustom } from './ChipChoiceCustom';
|
|
18
|
+
export function ChipChoiceDate(_a) {
|
|
19
|
+
var { size = Size.S, value, defaultValue, onChange, valueFormatter } = _a, rest = __rest(_a, ["size", "value", "defaultValue", "onChange", "valueFormatter"]);
|
|
20
|
+
const [selectedValue, setSelectedValue] = useUncontrolledProp(value, defaultValue, onChange);
|
|
21
|
+
const valueToRender = valueFormatter
|
|
22
|
+
? valueFormatter(selectedValue)
|
|
23
|
+
: (selectedValue && new Date(selectedValue).toLocaleDateString()) || DEFAULT_EMPTY_VALUE;
|
|
24
|
+
const clearValue = () => setSelectedValue(undefined);
|
|
25
|
+
return (_jsx(ChipChoiceCustom, Object.assign({ onClearButtonClick: clearValue, value: selectedValue, valueToRender: valueToRender, size: size }, rest, { children: ({ closeDroplist }) => (_jsx(Calendar, { mode: Calendar.modes.Date, size: CALENDAR_SIZE_MAP[size], value: selectedValue, onChangeValue: value => {
|
|
26
|
+
setSelectedValue(value);
|
|
27
|
+
closeDroplist();
|
|
28
|
+
}, navigationStartRef: element => element === null || element === void 0 ? void 0 : element.focus(), onFocusLeave: closeDroplist })) })));
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChipChoiceCommonProps } from '../types';
|
|
2
|
+
type Range = [Date, Date];
|
|
3
|
+
export type ChipChoiceDateRangeProps = ChipChoiceCommonProps & {
|
|
4
|
+
/** Значение компонента */
|
|
5
|
+
value?: Range;
|
|
6
|
+
/** Значение компонента по умолчанию */
|
|
7
|
+
defaultValue?: Range;
|
|
8
|
+
/** Колбек смены значения */
|
|
9
|
+
onChange?(value: Range): void;
|
|
10
|
+
/** Колбек формирующий строковое представление выбранного значения. Принимает массив выбранных значений */
|
|
11
|
+
valueFormatter?(value?: Range): string;
|
|
12
|
+
};
|
|
13
|
+
export declare function ChipChoiceDateRange({ size, value, defaultValue, onChange, valueFormatter, ...rest }: ChipChoiceDateRangeProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { useUncontrolledProp } from 'uncontrollable';
|
|
14
|
+
import { Calendar } from '@snack-uikit/calendar';
|
|
15
|
+
import { DEFAULT_EMPTY_VALUE, Size } from '../../../constants';
|
|
16
|
+
import { CALENDAR_SIZE_MAP } from '../constants';
|
|
17
|
+
import { ChipChoiceCustom } from './ChipChoiceCustom';
|
|
18
|
+
function defaultRangeFormatter(value) {
|
|
19
|
+
if (!value || !value.length)
|
|
20
|
+
return DEFAULT_EMPTY_VALUE;
|
|
21
|
+
const [from, to] = value;
|
|
22
|
+
return `${from.toLocaleDateString()} ${DEFAULT_EMPTY_VALUE} ${to.toLocaleDateString()}`;
|
|
23
|
+
}
|
|
24
|
+
export function ChipChoiceDateRange(_a) {
|
|
25
|
+
var { size = Size.S, value, defaultValue, onChange, valueFormatter } = _a, rest = __rest(_a, ["size", "value", "defaultValue", "onChange", "valueFormatter"]);
|
|
26
|
+
const [selectedValue, setSelectedValue] = useUncontrolledProp(value, defaultValue, onChange);
|
|
27
|
+
const valueToRender = valueFormatter ? valueFormatter(selectedValue) : defaultRangeFormatter(selectedValue);
|
|
28
|
+
const clearValue = () => setSelectedValue(undefined);
|
|
29
|
+
return (_jsx(ChipChoiceCustom, Object.assign({ value: selectedValue, valueToRender: valueToRender, onClearButtonClick: clearValue, size: size }, rest, { children: ({ closeDroplist }) => (_jsx(Calendar, { mode: Calendar.modes.Range, size: CALENDAR_SIZE_MAP[size], value: selectedValue, onChangeValue: range => {
|
|
30
|
+
setSelectedValue(range);
|
|
31
|
+
closeDroplist();
|
|
32
|
+
},
|
|
33
|
+
// bug with focus
|
|
34
|
+
// navigationStartRef={element => element?.focus()}
|
|
35
|
+
onFocusLeave: closeDroplist })) })));
|
|
36
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChipChoiceCommonProps, FilterOption } from '../types';
|
|
2
|
+
export type ChipChoiceMultiProps = ChipChoiceCommonProps & {
|
|
3
|
+
/** Массив опций */
|
|
4
|
+
options: FilterOption[];
|
|
5
|
+
/** Значение компонента */
|
|
6
|
+
value?: string[];
|
|
7
|
+
/** Значение компонента по умолчанию */
|
|
8
|
+
defaultValue?: string[];
|
|
9
|
+
/** Колбек смены значения */
|
|
10
|
+
onChange?(value: string[]): void;
|
|
11
|
+
/** Колбек формирующий строковое представление выбранного значения. Принимает массив выбранных значений. По умолчанию для отображения используется кол-во выбранных значений. */
|
|
12
|
+
valueFormatter?(options: FilterOption[]): string;
|
|
13
|
+
};
|
|
14
|
+
export declare function ChipChoiceMulti({ value, defaultValue, options, onChange, valueFormatter, size, 'data-test-id': dataTestId, ...rest }: ChipChoiceMultiProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,42 @@
|
|
|
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 { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { createElement as _createElement } from "react";
|
|
14
|
+
import { useMemo } from 'react';
|
|
15
|
+
import { useUncontrolledProp } from 'uncontrollable';
|
|
16
|
+
import { Droplist } from '@snack-uikit/droplist';
|
|
17
|
+
import { Size } from '../../../constants';
|
|
18
|
+
import { defaultMultiValueLabelFormatter, normalizeValueForMultiChoice } from '../utils';
|
|
19
|
+
import { ChipChoiceCustom } from './ChipChoiceCustom';
|
|
20
|
+
export function ChipChoiceMulti(_a) {
|
|
21
|
+
var { value, defaultValue, options, onChange, valueFormatter, size = Size.S, 'data-test-id': dataTestId } = _a, rest = __rest(_a, ["value", "defaultValue", "options", "onChange", "valueFormatter", "size", 'data-test-id']);
|
|
22
|
+
const [selectedValue, setSelectedValue] = useUncontrolledProp(normalizeValueForMultiChoice(options, value), normalizeValueForMultiChoice(options, defaultValue) || [], onChange);
|
|
23
|
+
const selectedOptions = useMemo(() => options.filter(({ value }) => selectedValue === null || selectedValue === void 0 ? void 0 : selectedValue.includes(value)), [options, selectedValue]);
|
|
24
|
+
const valueToRender = valueFormatter
|
|
25
|
+
? valueFormatter(selectedOptions)
|
|
26
|
+
: defaultMultiValueLabelFormatter(selectedOptions, options.length);
|
|
27
|
+
const clearValue = () => setSelectedValue([]);
|
|
28
|
+
return (_jsx(ChipChoiceCustom, Object.assign({ size: size, onClearButtonClick: clearValue, valueToRender: valueToRender, value: selectedValue, "data-test-id": dataTestId }, rest, { children: ({ handleDroplistItemKeyDown }) => options.map((_a) => {
|
|
29
|
+
var { label, value } = _a, rest = __rest(_a, ["label", "value"]);
|
|
30
|
+
const selected = selectedValue || [];
|
|
31
|
+
const checked = selected.includes(value);
|
|
32
|
+
const onChangeHandler = () => {
|
|
33
|
+
if (checked) {
|
|
34
|
+
setSelectedValue(selected.filter(selected => selected !== value));
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
setSelectedValue([...selected, value]);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
return (_createElement(Droplist.ItemMultiple, Object.assign({}, rest, { key: value, option: label, checked: checked, onChange: onChangeHandler, onKeyDown: handleDroplistItemKeyDown, "data-test-id": dataTestId && `${dataTestId}__option` })));
|
|
41
|
+
}) })));
|
|
42
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChipChoiceCommonProps, FilterOption } from '../types';
|
|
2
|
+
export type ChipChoiceSingleProps = ChipChoiceCommonProps & {
|
|
3
|
+
/** Массив опций */
|
|
4
|
+
options: FilterOption[];
|
|
5
|
+
/** Значение компонента */
|
|
6
|
+
value?: string;
|
|
7
|
+
/** Значение компонента по умолчанию */
|
|
8
|
+
defaultValue?: string;
|
|
9
|
+
/** Колбек смены значения */
|
|
10
|
+
onChange?(value: string): void;
|
|
11
|
+
/** Колбек формирующий строковое представление выбранного значения. Принимает выбранное значение. По умолчанию для отображения используется FilterOption.label */
|
|
12
|
+
valueFormatter?(option?: FilterOption): string;
|
|
13
|
+
};
|
|
14
|
+
export declare function ChipChoiceSingle({ value, defaultValue, options, onChange, valueFormatter, size, 'data-test-id': dataTestId, ...rest }: ChipChoiceSingleProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
import { createElement as _createElement } from "react";
|
|
14
|
+
import { useMemo } from 'react';
|
|
15
|
+
import { useUncontrolledProp } from 'uncontrollable';
|
|
16
|
+
import { Droplist } from '@snack-uikit/droplist';
|
|
17
|
+
import { DEFAULT_EMPTY_VALUE, Size } from '../../../constants';
|
|
18
|
+
import { normalizeValueForSingleChoice } from '../utils';
|
|
19
|
+
import { ChipChoiceCustom } from './ChipChoiceCustom';
|
|
20
|
+
export function ChipChoiceSingle(_a) {
|
|
21
|
+
var { value, defaultValue, options, onChange, valueFormatter, size = Size.S, 'data-test-id': dataTestId } = _a, rest = __rest(_a, ["value", "defaultValue", "options", "onChange", "valueFormatter", "size", 'data-test-id']);
|
|
22
|
+
const [selectedValue, setSelectedValue] = useUncontrolledProp(normalizeValueForSingleChoice(options, value), normalizeValueForSingleChoice(options, defaultValue), onChange);
|
|
23
|
+
const selectedOption = useMemo(() => options.find(({ value }) => value === selectedValue), [options, selectedValue]);
|
|
24
|
+
const valueToRender = valueFormatter ? valueFormatter(selectedOption) : (selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.label) || DEFAULT_EMPTY_VALUE;
|
|
25
|
+
const clearValue = () => setSelectedValue(undefined);
|
|
26
|
+
return (_jsx(ChipChoiceCustom, Object.assign({ onClearButtonClick: clearValue, value: selectedValue, valueToRender: valueToRender, "data-test-id": dataTestId, size: size }, rest, { children: ({ handleDroplistItemKeyDown, closeDroplist }) => options.map((_a) => {
|
|
27
|
+
var { label, value } = _a, rest = __rest(_a, ["label", "value"]);
|
|
28
|
+
const onChangeHandler = () => {
|
|
29
|
+
setSelectedValue(value);
|
|
30
|
+
closeDroplist();
|
|
31
|
+
};
|
|
32
|
+
return (_createElement(Droplist.ItemSingle, Object.assign({}, rest, { key: value, option: label, checked: selectedValue === value, onChange: onChangeHandler, onKeyDown: handleDroplistItemKeyDown, "data-test-id": dataTestId && `${dataTestId}__option` })));
|
|
33
|
+
}) })));
|
|
34
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ButtonSize } from '../../constants';
|
|
2
|
+
export declare const BUTTON_CLEAR_VALUE_SIZE_MAP: {
|
|
3
|
+
xs: ButtonSize;
|
|
4
|
+
s: ButtonSize;
|
|
5
|
+
m: ButtonSize;
|
|
6
|
+
l: ButtonSize;
|
|
7
|
+
};
|
|
8
|
+
export declare const CALENDAR_SIZE_MAP: {
|
|
9
|
+
xs: import("@snack-uikit/calendar/dist/constants").Size;
|
|
10
|
+
s: import("@snack-uikit/calendar/dist/constants").Size;
|
|
11
|
+
m: import("@snack-uikit/calendar/dist/constants").Size;
|
|
12
|
+
l: import("@snack-uikit/calendar/dist/constants").Size;
|
|
13
|
+
};
|
|
14
|
+
export declare const DROPLIST_SIZE_MAP: {
|
|
15
|
+
xs: import("@snack-uikit/droplist/dist/constants").Size;
|
|
16
|
+
s: import("@snack-uikit/droplist/dist/constants").Size;
|
|
17
|
+
m: import("@snack-uikit/droplist/dist/constants").Size;
|
|
18
|
+
l: import("@snack-uikit/droplist/dist/constants").Size;
|
|
19
|
+
};
|
|
20
|
+
export declare enum ChipChoiceType {
|
|
21
|
+
Multi = "multi",
|
|
22
|
+
Date = "date",
|
|
23
|
+
DateRange = "date-range",
|
|
24
|
+
Single = "single"
|
|
25
|
+
}
|