@rescui/select 0.14.4-RUI-285-Support-blur-for-glow-hover-6f393bc1.1 → 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/lib/select.d.ts CHANGED
@@ -12,6 +12,7 @@ export interface SelectProps {
12
12
  * Additional class name
13
13
  */
14
14
  className?: string;
15
+ id?: string;
15
16
  /**
16
17
  * Array of options or option groups
17
18
  */
@@ -60,6 +61,11 @@ export interface SelectProps {
60
61
  * Error state flag or React.ReactNode (use with forms)
61
62
  */
62
63
  error?: boolean | React.ReactNode;
64
+ /**
65
+ * If `true`, there will be reserved a space for a 1-line error message. Subsequent lines will be placed below normally.
66
+ * If `false`, there will be no reservation.
67
+ */
68
+ reserveErrorLine?: boolean;
63
69
  /**
64
70
  * Label element upper then Select element (use with forms)
65
71
  */
@@ -72,7 +78,6 @@ export interface SelectProps {
72
78
  * Note element below then Select element (use with forms)
73
79
  */
74
80
  note?: React.ReactNode;
75
- id?: string;
76
81
  /**
77
82
  * Text to display when there are no options
78
83
  */
package/lib/select.js CHANGED
@@ -6,10 +6,12 @@ import cn from 'classnames';
6
6
  import scrollIntoView from 'scroll-into-view-if-needed';
7
7
  import { Dropdown } from '@rescui/dropdown';
8
8
  import { Menu, MenuItem, Divider, GroupHeader } from '@rescui/menu';
9
+ import { ErrorMessage } from '@rescui/form-field';
9
10
  import { useThemeWithUndefined } from '@rescui/ui-contexts';
10
11
  import SelectTrigger from './parts/trigger.js';
11
12
  import FormTriggerWrapper from './parts/form-trigger-wrapper.js';
12
13
  import { useObservableForceRerender } from './parts/use-observable-force-rerender.js';
14
+ import { useBackwardCompatibleId } from './parts/use-backward-compatible-id.js';
13
15
  import { optionType, optionsGroupType, noOptionsMessageConfigType } from './common-prop-types.js';
14
16
  import { useStrongMemo, getDefaultCursorIndex, isGroupsEmpty, getMovedCursorIndex, shouldOpenSelect, isIndexMatchCursor, withoutGroupsLabel, getPlainOptionsFromGroups, getEmptyMessage, OptionGroupTypes, getOptionValue, convertToOptionGroupsIfNeeded, escapeRegex, getTextFromNodes, calculateMaxHeight } from './utils.js';
15
17
  import { ARROW_DOWN, ARROW_UP, ENTER, SPACE, TAB, ESCAPE, BACKSPACE } from './key-codes.js';
@@ -94,6 +96,7 @@ const Select = _ref2 => {
94
96
  mode = 'classic',
95
97
  theme: themeFromProps,
96
98
  className = null,
99
+ id,
97
100
  value = undefined,
98
101
  onChange,
99
102
  placeholder,
@@ -102,8 +105,10 @@ const Select = _ref2 => {
102
105
  isDisabled = false,
103
106
  isSearchable = false,
104
107
  noOptionsMessage,
108
+ error,
105
109
  placement = 'bottom',
106
- boldLabel,
110
+ boldLabel = true,
111
+ reserveErrorLine = false,
107
112
  ...restProps
108
113
  } = _ref2;
109
114
  const [triggerFormWrapperRef, setTriggerFormWrapperRef] = useState(null);
@@ -292,6 +297,8 @@ const Select = _ref2 => {
292
297
  const actualSize = sizeFromCss || size;
293
298
  const maxHeight = calculateMaxHeight(actualSize);
294
299
  const withGroupsLabel = !withoutGroupsLabel(filteredGroups);
300
+ const uniqueId = `select-${useBackwardCompatibleId()}`;
301
+ const errorId = `${id ? id : uniqueId}-error`;
295
302
  return /*#__PURE__*/React.createElement(Dropdown, {
296
303
  theme: theme,
297
304
  onRequestClose: handleClose,
@@ -311,13 +318,20 @@ const Select = _ref2 => {
311
318
  return /*#__PURE__*/React.createElement(FormTriggerWrapper, {
312
319
  ref: setTriggerFormWrapperRef,
313
320
  className: cn(className, SIZE_STYLES[size]),
321
+ id: id,
322
+ errorId: errorId,
314
323
  theme: theme,
315
324
  size: size,
316
- error: restProps.error,
325
+ disabled: isDisabled,
326
+ error: error,
327
+ reserveErrorLine: reserveErrorLine,
317
328
  label: restProps.label,
318
329
  note: restProps.note,
319
330
  onKeyDown: handleTriggerKeyDown,
320
- boldLabel: boldLabel
331
+ boldLabel: boldLabel,
332
+ role: "listbox",
333
+ "aria-errormessage": error ? errorId : undefined,
334
+ "aria-invalid": Boolean(error)
321
335
  }, /*#__PURE__*/React.createElement("div", {
322
336
  ref: observableRef,
323
337
  className: styles.observable
@@ -341,8 +355,7 @@ const Select = _ref2 => {
341
355
  onSearchChange: handleSearchInputChange,
342
356
  onClick: handleClick,
343
357
  onClearClick: handleClearClick,
344
- error: Boolean(restProps.error),
345
- id: restProps.id,
358
+ error: Boolean(error),
346
359
  "data-target": "trigger"
347
360
  }));
348
361
  },
@@ -379,7 +392,7 @@ Select.propTypes = {
379
392
  isSearchable: PropTypes.bool,
380
393
  isDisabled: PropTypes.bool,
381
394
  isLoading: PropTypes.bool,
382
- error: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
395
+ error: ErrorMessage.propTypes.children,
383
396
  label: PropTypes.node,
384
397
  id: PropTypes.string,
385
398
  note: PropTypes.node,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rescui/select",
3
- "version": "0.14.4-RUI-285-Support-blur-for-glow-hover-6f393bc1.1+6f393bc1",
3
+ "version": "0.15.0",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "author": "JetBrains",
@@ -16,10 +16,11 @@
16
16
  },
17
17
  "dependencies": {
18
18
  "@babel/runtime-corejs3": "^7.26.0",
19
- "@rescui/dropdown": "0.9.4-RUI-285-Support-blur-for-glow-hover-6f393bc1.1+6f393bc1",
20
- "@rescui/menu": "0.13.2-RUI-285-Support-blur-for-glow-hover-6f393bc1.1+6f393bc1",
21
- "@rescui/tag": "0.13.4-RUI-285-Support-blur-for-glow-hover-6f393bc1.1+6f393bc1",
22
- "@rescui/use-resize-observer": "0.3.1-RUI-285-Support-blur-for-glow-hover-6f393bc1.96+6f393bc1",
19
+ "@rescui/dropdown": "^0.9.4",
20
+ "@rescui/form-field": "^0.1.0",
21
+ "@rescui/menu": "^0.13.2",
22
+ "@rescui/tag": "^0.13.4",
23
+ "@rescui/use-resize-observer": "^0.3.0",
23
24
  "classnames": "^2.2.6",
24
25
  "scroll-into-view-if-needed": "2.2.20"
25
26
  },
@@ -29,10 +30,10 @@
29
30
  "react": ">=16.8.0 <20"
30
31
  },
31
32
  "devDependencies": {
32
- "@rescui/colors": "0.2.13-RUI-285-Support-blur-for-glow-hover-6f393bc1.50+6f393bc1",
33
- "@rescui/scripts": "0.5.1",
34
- "@rescui/typography": "0.24.4-RUI-285-Support-blur-for-glow-hover-6f393bc1.1+6f393bc1",
35
- "@rescui/visual-regression": "0.1.4",
33
+ "@rescui/colors": "^0.3.0",
34
+ "@rescui/scripts": "^0.5.1",
35
+ "@rescui/typography": "^0.24.4",
36
+ "@rescui/visual-regression": "^0.1.4",
36
37
  "sniffr": "^1.2.0"
37
38
  },
38
39
  "scripts": {
@@ -40,5 +41,5 @@
40
41
  "build-pcss-api": "rescui-scripts build-pcss-api --file public-api.p.css"
41
42
  },
42
43
  "nx": {},
43
- "gitHead": "6f393bc1b7394a744b9737ba9fe13126c3163219"
44
+ "gitHead": "1c29c8940bcec78d637ea6070ee8a63c258c8e89"
44
45
  }
@@ -1,106 +0,0 @@
1
- import _extends from '@babel/runtime-corejs3/helpers/esm/extends';
2
- import React from 'react';
3
- import PropTypes from 'prop-types';
4
- import cn from 'classnames';
5
- import styles from './index.css.js';
6
- const sizeStyles = {
7
- "xs": styles.sizeXS,
8
- "s": styles.sizeS,
9
- "m": styles.sizeM,
10
- "l": styles.sizeL
11
- };
12
- const Size = {
13
- "xs": "xs",
14
- "s": "s",
15
- "m": "m",
16
- "l": "l"
17
- };
18
- const WarningIcon16 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
19
- viewBox: "0 0 16 16"
20
- }, props, {
21
- ref: ref
22
- }), /*#__PURE__*/React.createElement("path", {
23
- d: "m6.303 1.989-5.027 8.874C.483 12.263 1.494 14 3.103 14h9.793c1.609 0 2.62-1.736 1.827-3.137L9.696 1.99C8.949.67 7.05.67 6.303 1.989M8 12a1 1 0 1 1 0-2 1 1 0 0 1 0 2m0-8a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-1 0v-4A.5.5 0 0 1 8 4"
24
- })));
25
- WarningIcon16.displayName = 'WarningIcon16';
26
- const WarningIcon20 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
27
- viewBox: "0 0 20 20"
28
- }, props, {
29
- ref: ref
30
- }), /*#__PURE__*/React.createElement("path", {
31
- d: "m8.042 3.141-5.8 10.24C1.327 14.997 2.494 17 4.35 17h11.3c1.856 0 3.023-2.003 2.108-3.62l-5.8-10.239c-.862-1.521-3.054-1.521-3.916 0M10 5.25a.75.75 0 0 1 .75.75v5a.75.75 0 0 1-1.5 0V6a.75.75 0 0 1 .75-.75m0 9.25a1 1 0 1 1 0-2 1 1 0 0 1 0 2"
32
- })));
33
- WarningIcon20.displayName = 'WarningIcon20';
34
- const WarningIcon24 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
35
- viewBox: "0 0 24 24"
36
- }, props, {
37
- ref: ref
38
- }), /*#__PURE__*/React.createElement("path", {
39
- d: "m9.52 3.446-7.346 12.97C1.014 18.463 2.492 21 4.844 21h14.312c2.352 0 3.83-2.537 2.67-4.584L14.48 3.446c-1.092-1.928-3.868-1.928-4.96 0M12 7a1 1 0 0 1 1 1v5a1 1 0 1 1-2 0V8a1 1 0 0 1 1-1m0 11a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3"
40
- })));
41
- WarningIcon24.displayName = 'WarningIcon24';
42
- const WarningIcon28 = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement("svg", _extends({
43
- viewBox: "0 0 28 28"
44
- }, props, {
45
- ref: ref
46
- }), /*#__PURE__*/React.createElement("path", {
47
- d: "M11.26 4.598 3.14 18.933C1.858 21.195 3.492 24 6.09 24h15.82c2.599 0 4.232-2.805 2.951-5.067l-8.12-14.335c-1.207-2.13-4.275-2.13-5.481 0M14 8a1 1 0 0 1 1 1v6a1 1 0 1 1-2 0V9a1 1 0 0 1 1-1m0 12a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3"
48
- })));
49
- WarningIcon28.displayName = 'WarningIcon28';
50
- const WarningIcon = /*#__PURE__*/React.forwardRef((_ref, ref) => {
51
- let {
52
- theme,
53
- size: sizeFromProps = "m",
54
- className,
55
- style,
56
- ['data-render-all-sizes']: renderAllSizes = false,
57
- ...props
58
- } = _ref;
59
- const size = sizeFromProps in Size ? sizeFromProps : "m";
60
- const mainProps = { ...props,
61
- className: cn(styles.icon, styles[theme], sizeStyles[size], renderAllSizes && styles.allVariants, className),
62
- style: renderAllSizes ? {
63
- '--rs-icon-ar-width': 28,
64
- '--rs-icon-ar-height': 28,
65
- ...style
66
- } : style,
67
- ref
68
- };
69
-
70
- if (renderAllSizes) {
71
- return /*#__PURE__*/React.createElement("svg", _extends({
72
- viewBox: "0 0 28 28"
73
- }, mainProps), /*#__PURE__*/React.createElement(WarningIcon16, {
74
- className: styles.variant16
75
- }), /*#__PURE__*/React.createElement(WarningIcon20, {
76
- className: styles.variant20
77
- }), /*#__PURE__*/React.createElement(WarningIcon24, {
78
- className: styles.variant24
79
- }), /*#__PURE__*/React.createElement(WarningIcon28, {
80
- className: styles.variant28
81
- }));
82
- }
83
-
84
- if (size === Size['xs']) {
85
- return /*#__PURE__*/React.createElement(WarningIcon16, mainProps);
86
- }
87
-
88
- if (size === Size['s']) {
89
- return /*#__PURE__*/React.createElement(WarningIcon20, mainProps);
90
- }
91
-
92
- if (size === Size['m']) {
93
- return /*#__PURE__*/React.createElement(WarningIcon24, mainProps);
94
- }
95
-
96
- return /*#__PURE__*/React.createElement(WarningIcon28, mainProps);
97
- });
98
- WarningIcon.displayName = 'WarningIcon';
99
- WarningIcon.propTypes = {
100
- className: PropTypes.string,
101
- theme: PropTypes.oneOf(["light", "dark"]),
102
- size: PropTypes.oneOf(["xs", "s", "m", "l"]),
103
- 'data-render-all-sizes': PropTypes.bool,
104
- style: PropTypes.object
105
- };
106
- export { Size, WarningIcon as default };