@ultraviolet/ui 1.47.0 → 1.48.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.
@@ -0,0 +1,138 @@
1
+ import _styled from '@emotion/styled/base';
2
+ import { Icon } from '@ultraviolet/icons';
3
+ import { useRef } from 'react';
4
+ import { Stack } from '../Stack/index.js';
5
+ import { Text } from '../Text/index.js';
6
+ import { Dropdown } from './Dropdown.js';
7
+ import { SelectBar } from './SelectBar.js';
8
+ import { SelectInputProvider } from './SelectInputProvider.js';
9
+ import { jsx, jsxs } from '@emotion/react/jsx-runtime';
10
+
11
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
12
+ const SelectInputContainer = /*#__PURE__*/_styled("div", {
13
+ target: "ebdnz3x1"
14
+ })(process.env.NODE_ENV === "production" ? {
15
+ name: "1d3w5wq",
16
+ styles: "width:100%"
17
+ } : {
18
+ name: "1d3w5wq",
19
+ styles: "width:100%",
20
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
21
+ });
22
+ const HelperText = /*#__PURE__*/_styled(Text, {
23
+ target: "ebdnz3x0"
24
+ })("padding-top:", ({
25
+ theme
26
+ }) => theme.space['0.5'], ";");
27
+
28
+ /**
29
+ * SelectInputV2 component is used to select one or many elements from a selection.
30
+ */
31
+ const SelectInputV2 = ({
32
+ name,
33
+ id,
34
+ onBlur,
35
+ onFocus,
36
+ onChange,
37
+ 'aria-label': ariaLabel,
38
+ value,
39
+ label,
40
+ helper,
41
+ options,
42
+ size = 'large',
43
+ emptyState,
44
+ descriptionDirection = 'column',
45
+ success,
46
+ error,
47
+ 'data-testid': dataTestId,
48
+ className,
49
+ footer,
50
+ placeholderSearch = 'Search in list',
51
+ placeholder = 'Select item',
52
+ searchable = true,
53
+ disabled = false,
54
+ readOnly = false,
55
+ clearable = true,
56
+ multiselect = false,
57
+ required = false,
58
+ labelDescription,
59
+ autofocus,
60
+ loadMore,
61
+ optionalInfoPlacement = 'right',
62
+ isLoading,
63
+ selectAll,
64
+ selectAllGroup = false
65
+ }) => {
66
+ const ref = useRef(null);
67
+ const numberOfOptions = Array.isArray(options) ? options.length : Object.values(options).reduce((acc, current) => acc + current.filter(option => !option.disabled).length, 0);
68
+ return jsx(SelectInputProvider, {
69
+ options: options,
70
+ multiselect: multiselect,
71
+ selectAll: selectAll,
72
+ value: value,
73
+ selectAllGroup: selectAllGroup,
74
+ numberOfOptions: numberOfOptions,
75
+ children: jsxs(SelectInputContainer, {
76
+ id: id,
77
+ onBlur: onBlur,
78
+ onFocus: onFocus,
79
+ "data-testid": dataTestId,
80
+ className: className,
81
+ "aria-label": name,
82
+ children: [jsx(Dropdown, {
83
+ emptyState: emptyState,
84
+ descriptionDirection: descriptionDirection,
85
+ searchable: searchable,
86
+ placeholder: placeholderSearch,
87
+ footer: footer,
88
+ onChange: onChange,
89
+ refSelect: ref,
90
+ loadMore: loadMore,
91
+ optionalInfoPlacement: optionalInfoPlacement,
92
+ isLoading: isLoading,
93
+ children: jsxs(Stack, {
94
+ gap: 0.5,
95
+ "aria-label": ariaLabel,
96
+ children: [jsxs(Stack, {
97
+ direction: "row",
98
+ gap: 0.5,
99
+ children: [label ? jsx(Text, {
100
+ as: "label",
101
+ variant: size === 'large' ? 'bodyStrong' : 'bodySmallStrong',
102
+ children: label
103
+ }) : null, required ? jsx(Icon, {
104
+ name: "asterisk",
105
+ sentiment: "danger",
106
+ size: 8
107
+ }) : null, labelDescription ?? null]
108
+ }), jsx(SelectBar, {
109
+ size: size,
110
+ clearable: clearable,
111
+ readOnly: readOnly,
112
+ disabled: disabled,
113
+ placeholder: placeholder,
114
+ success: success,
115
+ error: error,
116
+ onChange: onChange,
117
+ autoFocus: autofocus,
118
+ innerRef: ref
119
+ })]
120
+ })
121
+ }), !error && !success ? jsx(HelperText, {
122
+ variant: "caption",
123
+ as: "p",
124
+ sentiment: "neutral",
125
+ prominence: "default",
126
+ children: helper
127
+ }) : null, error || success ? jsx(HelperText, {
128
+ variant: "caption",
129
+ as: "p",
130
+ sentiment: error ? 'danger' : 'success',
131
+ prominence: "default",
132
+ children: error || success
133
+ }) : null]
134
+ })
135
+ });
136
+ };
137
+
138
+ export { SelectInputV2 };
@@ -0,0 +1,11 @@
1
+ const INPUT_SIZE_HEIGHT = {
2
+ large: 48,
3
+ medium: 40,
4
+ small: 32
5
+ };
6
+ const SIZES_TAG = {
7
+ letterWidth: 5,
8
+ tagWidth: 72
9
+ };
10
+
11
+ export { INPUT_SIZE_HEIGHT, SIZES_TAG };
@@ -114,7 +114,8 @@ const TextInputV2 = /*#__PURE__*/forwardRef(({
114
114
  maxLength,
115
115
  'aria-labelledby': ariaLabelledBy,
116
116
  'aria-label': ariaLabel,
117
- autoComplete
117
+ autoComplete,
118
+ onKeyDown
118
119
  }, ref) => {
119
120
  const localId = useId();
120
121
  const [hasFocus, setHasFocus] = useState(false);
@@ -205,7 +206,8 @@ const TextInputV2 = /*#__PURE__*/forwardRef(({
205
206
  "aria-labelledby": ariaLabelledBy,
206
207
  "aria-label": ariaLabel,
207
208
  autoComplete: autoComplete,
208
- required: required
209
+ required: required,
210
+ onKeyDown: onKeyDown
209
211
  }), success || error || loading || computedClearable ? jsxs(StateStack, {
210
212
  direction: "row",
211
213
  gap: 1,
package/dist/src/index.js CHANGED
@@ -73,3 +73,4 @@ export { MenuV2 } from './components/MenuV2/index.js';
73
73
  export { GlobalAlert } from './components/GlobalAlert/index.js';
74
74
  export { NotificationContainer, notification } from './components/Notification/index.js';
75
75
  export { SelectableCardGroup } from './components/SelectableCardGroup/index.js';
76
+ export { SelectInputV2 } from './components/SelectInputV2/index.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultraviolet/ui",
3
- "version": "1.47.0",
3
+ "version": "1.48.0",
4
4
  "description": "Ultraviolet UI",
5
5
  "homepage": "https://github.com/scaleway/ultraviolet#readme",
6
6
  "repository": {
@@ -43,7 +43,7 @@
43
43
  "@emotion/babel-plugin": "11.11.0",
44
44
  "@emotion/react": "11.11.4",
45
45
  "@emotion/styled": "11.11.5",
46
- "@types/react": "18.2.78",
46
+ "@types/react": "18.2.79",
47
47
  "@types/react-datepicker": "4.19.6",
48
48
  "@types/react-dom": "18.2.25",
49
49
  "react": "18.2.0",
@@ -56,8 +56,8 @@
56
56
  "@nivo/line": "0.80.0",
57
57
  "@nivo/pie": "0.80.0",
58
58
  "@nivo/scales": "0.80.0",
59
- "@scaleway/random-name": "5.0.0",
60
- "@scaleway/use-media": "3.0.0",
59
+ "@scaleway/random-name": "5.0.1",
60
+ "@scaleway/use-media": "3.0.1",
61
61
  "deepmerge": "4.3.1",
62
62
  "react-datepicker": "4.25.0",
63
63
  "react-select": "5.8.0",
@@ -65,7 +65,7 @@
65
65
  "react-use-clipboard": "1.0.9",
66
66
  "reakit": "1.3.11",
67
67
  "@ultraviolet/themes": "1.10.0",
68
- "@ultraviolet/icons": "2.12.4"
68
+ "@ultraviolet/icons": "2.12.5"
69
69
  },
70
70
  "scripts": {
71
71
  "build": "rollup -c ../../rollup.config.mjs",