@semcore/select 2.7.12 → 3.0.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.
@@ -2,11 +2,8 @@ import React from 'react';
2
2
  import createComponent, { Component, CONTEXT_COMPONENT, sstyled } from '@semcore/core';
3
3
  import { Box } from '@semcore/flex-box';
4
4
  import Input from '@semcore/input';
5
- import Divider from '@semcore/divider';
6
5
  import SearchM from '@semcore/icon/Search/m';
7
6
  import CloseM from '@semcore/icon/Close/m';
8
- import SearchL from '@semcore/icon/Search/l';
9
- import CloseL from '@semcore/icon/Close/l';
10
7
  import Select from './Select';
11
8
 
12
9
  import style from './style/input-search.shadow.css';
@@ -14,7 +11,6 @@ import style from './style/input-search.shadow.css';
14
11
  const MAP_SIZE_TO_ICON = {
15
12
  m: [SearchM, CloseM],
16
13
  l: [SearchM, CloseM],
17
- xl: [SearchL, CloseL],
18
14
  };
19
15
 
20
16
  class InputSearch extends Component {
@@ -44,22 +40,18 @@ class InputSearch extends Component {
44
40
  const finalSize = size || this.context.size;
45
41
 
46
42
  return sstyled(styles)(
47
- <>
48
- <SInputSearch size={finalSize}>
49
- <Input size={finalSize}>
50
- <Input.Addon tag={MAP_SIZE_TO_ICON[finalSize][0]} />
51
- <Input.Value ref={forwardRef} autoFocus {...this.asProps} />
52
- <Input.Addon
53
- tag={MAP_SIZE_TO_ICON[finalSize][1]}
54
- role="button"
55
- interactive
56
- style={{ visibility: value ? 'visible' : 'hidden' }}
57
- onClick={this.handleClear}
58
- />
59
- </Input>
60
- </SInputSearch>
61
- <Divider />
62
- </>,
43
+ <SInputSearch size={finalSize} use:filled={value}>
44
+ <Input size={finalSize}>
45
+ <Input.Addon tag={MAP_SIZE_TO_ICON[finalSize][0]} />
46
+ <Input.Value ref={forwardRef} autoFocus {...this.asProps} />
47
+ <Input.Addon
48
+ tag={MAP_SIZE_TO_ICON[finalSize][1]}
49
+ role="button"
50
+ interactive
51
+ onClick={this.handleClear}
52
+ />
53
+ </Input>
54
+ </SInputSearch>,
63
55
  );
64
56
  }
65
57
  }
package/src/Select.jsx CHANGED
@@ -34,7 +34,6 @@ class RootSelect extends Component {
34
34
  placeholder: props.multiselect ? 'Select options' : 'Select option',
35
35
  size: 'm',
36
36
  defaultValue: getEmptyValue(props.multiselect),
37
- defaultSelectedOptions: [],
38
37
  defaultVisible: false,
39
38
  });
40
39
 
@@ -46,23 +45,9 @@ class RootSelect extends Component {
46
45
  return {
47
46
  visible: null,
48
47
  value: null,
49
- selectedOptions: null,
50
48
  };
51
49
  }
52
50
 
53
- isFallback() {
54
- const { selectedOptions, defaultSelectedOptions } = this.props;
55
- return selectedOptions !== undefined || defaultSelectedOptions.length !== 0;
56
- }
57
-
58
- fallbackDeprecatedValue(value) {
59
- return this.isFallback() ? this.asProps.selectedOptions.map((o) => o.value) : value;
60
- }
61
-
62
- fallbackDeprecatedLabel(value) {
63
- return this.isFallback() ? this.asProps.selectedOptions.map((o) => o.label || o.value) : value;
64
- }
65
-
66
51
  getTriggerProps() {
67
52
  const {
68
53
  size,
@@ -78,7 +63,7 @@ class RootSelect extends Component {
78
63
  } = this.asProps;
79
64
 
80
65
  return {
81
- empty: isEmptyValue(this.fallbackDeprecatedValue(value)),
66
+ empty: isEmptyValue(value),
82
67
  size,
83
68
  value,
84
69
  name,
@@ -89,13 +74,13 @@ class RootSelect extends Component {
89
74
  disabled,
90
75
  active: visible,
91
76
  onClear: this.handlerClear,
92
- children: this.renderChildrenTrigger(this.fallbackDeprecatedValue(value), options),
77
+ children: this.renderChildrenTrigger(value, options),
93
78
  };
94
79
  }
95
80
 
96
81
  getOptionProps(props) {
97
82
  const { value } = this.asProps;
98
- const selected = isSelectedOption(this.fallbackDeprecatedValue(value), props.value);
83
+ const selected = isSelectedOption(value, props.value);
99
84
  const other = {};
100
85
  this._optionSelected = selected;
101
86
 
@@ -106,9 +91,7 @@ class RootSelect extends Component {
106
91
 
107
92
  return {
108
93
  selected,
109
- onClick: this.isFallback()
110
- ? this.bindHandlerOptionFallbackClick(props)
111
- : this.bindHandlerOptionClick(props.value),
94
+ onClick: this.bindHandlerOptionClick(props.value),
112
95
  ...other,
113
96
  };
114
97
  }
@@ -132,7 +115,6 @@ class RootSelect extends Component {
132
115
 
133
116
  renderChildrenTrigger(value, options) {
134
117
  if (options) {
135
- value = this.fallbackDeprecatedValue(value);
136
118
  return [].concat(value).reduce((acc, value) => {
137
119
  const selectedOption = options.find((o) => isSelectedOption(value, o.value));
138
120
  if (!selectedOption) return acc;
@@ -141,7 +123,6 @@ class RootSelect extends Component {
141
123
  return acc;
142
124
  }, []);
143
125
  }
144
- value = this.fallbackDeprecatedLabel(value);
145
126
  return Array.isArray(value)
146
127
  ? value.reduce((acc, value) => {
147
128
  if (acc.length) acc.push(', ');
@@ -165,28 +146,10 @@ class RootSelect extends Component {
165
146
  if (!multiselect) this.handlers.visible(false);
166
147
  };
167
148
 
168
- bindHandlerOptionFallbackClick = (props) => (e) => {
169
- const { selectedOptions, multiselect } = this.asProps;
170
- let optionProps = [props];
171
- if (multiselect) {
172
- if (isSelectedOption(this.fallbackDeprecatedValue(selectedOptions), props.value)) {
173
- optionProps = selectedOptions.filter((o) => o.value !== props.value);
174
- } else {
175
- optionProps = selectedOptions.concat(props);
176
- }
177
- }
178
- this.handlers.value(optionProps, e);
179
- if (!multiselect) this.handlers.visible(false);
180
- };
181
-
182
149
  handlerClear = (e) => {
183
150
  const { value } = this.asProps;
184
- const emptyValue = getEmptyValue(Array.isArray(this.fallbackDeprecatedValue(value)));
185
- if (this.isFallback()) {
186
- this.handlers.value(Array.isArray(emptyValue) ? emptyValue : [], e);
187
- } else {
188
- this.handlers.value(emptyValue, e);
189
- }
151
+ const emptyValue = getEmptyValue(Array.isArray(value));
152
+ this.handlers.value(emptyValue, e);
190
153
  this.handlers.visible(false);
191
154
  };
192
155
 
@@ -229,13 +192,6 @@ class RootSelect extends Component {
229
192
  Select.Popper.displayName,
230
193
  ]);
231
194
 
232
- logger.warn(
233
- // @ts-ignore
234
- this.isFallback(),
235
- "'selectedOptions'/'defaultSelectedOptions' changed to 'value/defaultValue' and take only values, not objects.",
236
- other['data-ui-name'] || Select.displayName,
237
- );
238
-
239
195
  logger.warn(
240
196
  options && advanceMode,
241
197
  "Don't use at the same time 'options' property and '<Select.Trigger/>/<Select.Popper/>'",
@@ -243,13 +199,17 @@ class RootSelect extends Component {
243
199
  );
244
200
 
245
201
  if (options) {
246
- const Component = multiselect ? Select.OptionCheckbox : Select.Option;
247
202
  return (
248
203
  <Root render={DropdownMenu}>
249
204
  <Select.Trigger {...other} />
250
205
  <Select.Menu>
251
206
  {options.map((option, i) => {
252
- return <Component key={i} {...option} />;
207
+ return (
208
+ <Select.Option key={i} {...option}>
209
+ {multiselect && <Select.Option.Checkbox />}
210
+ {option.children}
211
+ </Select.Option>
212
+ );
253
213
  })}
254
214
  </Select.Menu>
255
215
  </Root>
@@ -297,23 +257,7 @@ function Checkbox(props) {
297
257
  );
298
258
  }
299
259
 
300
- function OptionCheckbox(props) {
301
- const { selected, size, theme, children } = props;
302
-
303
- return (
304
- <DropdownMenu.Item {...props}>
305
- <Checkbox selected={selected} size={size} theme={theme} styles={props.styles} />
306
- {children}
307
- </DropdownMenu.Item>
308
- );
309
- }
310
-
311
- const InputSearchWrapper = function (props) {
312
- logger.warn(
313
- true,
314
- `\'<${props['data-ui-name']}/>\' is deprecated, use the named import \'import { InputSearch }\'`,
315
- props['data-ui-name'] || Select.InputSearch.displayName,
316
- );
260
+ const InputSearchWrapper = function () {
317
261
  return <Root render={InputSearch} />;
318
262
  };
319
263
 
@@ -339,12 +283,6 @@ const Select = createComponent(
339
283
  ],
340
284
  OptionTitle: DropdownMenu.ItemTitle,
341
285
  OptionHint: DropdownMenu.ItemHint,
342
- OptionCheckbox: [
343
- OptionCheckbox,
344
- {
345
- Addon: DropdownMenu.Item.Addon,
346
- },
347
- ],
348
286
  Divider,
349
287
  InputSearch: InputSearchWrapper,
350
288
  Input: InputSearchWrapper,
package/src/index.d.ts CHANGED
@@ -64,17 +64,6 @@ export interface ISelectProps<T extends SelectValue = SelectValue>
64
64
  * Input name
65
65
  */
66
66
  name?: string;
67
-
68
- /**
69
- * The list of options selected by default
70
- * @deprecated v2.0.0 {@link ISelectProps.defaultValue}
71
- */
72
- defaultSelectedOptions?: ISelectOption[];
73
- /**
74
- * List of the selected options
75
- * @deprecated v2.0.0 {@link ISelectProps.value}
76
- */
77
- selectedOptions?: ISelectOption[];
78
67
  }
79
68
 
80
69
  export interface ISelectOption {
@@ -130,11 +119,6 @@ declare const Select: (<T, V extends SelectValue = SelectValue>(
130
119
  };
131
120
  OptionTitle: typeof DropdownMenu.ItemTitle;
132
121
  OptionHint: typeof DropdownMenu.ItemHint;
133
- OptionCheckbox: (<T>(
134
- props: CProps<ISelectOptionCheckboxProps & T, ISelectContext, ISelectHandlers>,
135
- ) => ReturnEl) & {
136
- Addon: typeof DropdownMenu.Item.Addon;
137
- };
138
122
  Divider: typeof Divider;
139
123
  InputSearch: typeof InputSearch;
140
124
  Input: typeof InputSearch;
@@ -1,11 +1,24 @@
1
- SInputSearch[size='m'] {
2
- padding: 8px;
1
+ @import '@semcore/utils/style/var.css';
2
+
3
+ SInputSearch[size] {
4
+ padding: 0;
5
+ }
6
+
7
+ SInputSearch > [data-ui-name='Input']:first-child > [data-ui-name='InputSearch'] ~ div {
8
+ top: -1px;
9
+ left: -1px;
10
+ width: 100%;
11
+ border-radius: var(--rounded-m) var(--rounded-m) 0 0;
12
+ }
13
+
14
+ SInputSearch[size='m'] > [data-ui-name='Input']:first-child {
15
+ height: 32px;
3
16
  }
4
17
 
5
- SInputSearch[size='l'] {
6
- padding: 10px 8px;
18
+ SInputSearch [data-ui-name='Input.Addon']:last-of-type {
19
+ visibility: hidden;
7
20
  }
8
21
 
9
- SInputSearch[size='xl'] {
10
- padding: 12px 12px;
22
+ SInputSearch[filled] [data-ui-name='Input.Addon']:last-of-type {
23
+ visibility: visible;
11
24
  }
@@ -1,6 +1,7 @@
1
1
  @import '@semcore/utils/style/var.css';
2
2
 
3
3
  SOptionCheckbox {
4
+ margin-top: 2px;
4
5
  margin-right: 8px;
5
6
  margin-bottom: auto;
6
7
  position: relative;
@@ -15,10 +16,13 @@ SOptionCheckbox {
15
16
  bottom: 0;
16
17
  background: #fff;
17
18
  border: 1px solid;
18
- border-radius: 2px;
19
- border-color: var(--stone);
19
+ border-radius: var(--rounded-s);
20
+ border-color: var(--gray-200);
20
21
  }
21
22
 
23
+ width: 16px;
24
+ height: 16px;
25
+
22
26
  &::after {
23
27
  content: '';
24
28
  position: absolute;
@@ -27,33 +31,23 @@ SOptionCheckbox {
27
31
  right: 0;
28
32
  bottom: 0;
29
33
  margin: 0 2px;
30
- background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA4IDYiIGZpbGw9IiNmZmYiPgogICAgPHBhdGggZD0iTTc3Ny44ODQsNTkzLjc4MmwtMC42NzktLjY3NWEwLjQsMC40LDAsMCwwLS41NTksMGwtMy41NzMsMy41NTYtMS43Mi0xLjcxM2EwLjQsMC40LDAsMCwwLS41NTgsMGwtMC42NzkuNjc1YTAuMzg0LDAuMzg0LDAsMCwwLS4xMTYuMjcyLDAuNCwwLjQsMCwwLDAsLjExNS4yODRsMi42NzksMi42NjVhMC40LDAuNCwwLDAsMCwuNTU5LDBsNC41MzEtNC41MDhhMC40LDAuNCwwLDAsMCwuMTE2LTAuMjg1QTAuMzgyLDAuMzgyLDAsMCwwLDc3Ny44ODQsNTkzLjc4MloiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC03NzAgLTU5MykiLz4KPC9zdmc+Cgo=');
31
34
  background-repeat: no-repeat;
32
35
  background-position: center center;
36
+ background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAiIGhlaWdodD0iNyIgdmlld0JveD0iMCAwIDEwIDciIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik04LjI1IDFMNCA1LjI1TDEuNzUgMyIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+Cg==');
33
37
  }
34
38
  }
35
39
 
36
- SOptionCheckbox[size='xl'] {
37
- margin-top: 2px;
40
+ SOptionCheckbox[size='l'] {
38
41
  width: 20px;
39
42
  height: 20px;
40
- }
41
-
42
- SOptionCheckbox[size='l'] {
43
- margin-top: 1px;
44
- width: 16px;
45
- height: 16px;
46
- }
47
-
48
- SOptionCheckbox[size='m'] {
49
- margin-top: 2px;
50
- width: 12px;
51
- height: 12px;
43
+ &::after {
44
+ background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iOSIgdmlld0JveD0iMCAwIDEyIDkiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxwYXRoIGQ9Ik0xMSAxLjVMNC43NSA3Ljc1TDEgNCIgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+Cg==');
45
+ }
52
46
  }
53
47
 
54
48
  SOptionCheckbox[checked]:before {
55
- background-color: var(--light-blue);
56
- border-color: var(--light-blue);
49
+ background-color: var(--blue-400);
50
+ border-color: var(--blue-400);
57
51
  }
58
52
 
59
53
  SOptionCheckbox[theme]:before {
@@ -66,9 +60,9 @@ SOptionCheckbox[theme][checked]:before {
66
60
  }
67
61
 
68
62
  SOptionCheckbox[selected] {
69
- background-color: color-mod(var(--light-blue) a(20%));
63
+ background-color: color-mod(var(--blue-100) a(70%));
70
64
 
71
- & :hover {
72
- background-color: color-mod(var(--light-blue) a(20%));
65
+ &:hover {
66
+ background-color: color-mod(var(--blue-100) a(70%));
73
67
  }
74
68
  }