@ultraviolet/ui 1.43.2 → 1.44.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/dist/index.d.ts CHANGED
@@ -1682,13 +1682,14 @@ type ExpandableProps = {
1682
1682
  minHeight?: number;
1683
1683
  className?: string;
1684
1684
  'data-testid'?: string;
1685
+ animationDuration?: number;
1685
1686
  };
1686
1687
  /**
1687
1688
  * The Expandable component is a dynamic React component that allows for the expansion of its children content
1688
1689
  * based on its height. The component comes with a sleek and smooth animation, providing a visually pleasing
1689
1690
  * user experience.
1690
1691
  */
1691
- declare const Expandable: ({ children, opened, minHeight, className, "data-testid": dataTestId, }: ExpandableProps) => _emotion_react_jsx_runtime.JSX.Element;
1692
+ declare const Expandable: ({ children, opened, minHeight, className, "data-testid": dataTestId, animationDuration, }: ExpandableProps) => _emotion_react_jsx_runtime.JSX.Element;
1692
1693
 
1693
1694
  type Transformer = (value: DatumValue) => string;
1694
1695
  type CustomLegendProps = {
@@ -5,9 +5,13 @@ import { jsx } from '@emotion/react/jsx-runtime';
5
5
  const ANIMATION_DURATION = 300; // in ms
6
6
 
7
7
  const StyledExpandable = /*#__PURE__*/_styled('div', {
8
- shouldForwardProp: prop => !['opened', 'minHeight'].includes(prop),
8
+ shouldForwardProp: prop => !['opened', 'minHeight', 'animationDuration'].includes(prop),
9
9
  target: "e5hc7t70"
10
- })("transition:max-height ", ANIMATION_DURATION, "ms ease-out,opacity ", ANIMATION_DURATION, "ms ease-out;overflow:", ({
10
+ })("transition:max-height ", ({
11
+ animationDuration
12
+ }) => animationDuration, "ms ease-out,opacity ", ({
13
+ animationDuration
14
+ }) => animationDuration, "ms ease-out;overflow:", ({
11
15
  opened
12
16
  }) => opened ? 'visible' : 'hidden', ";height:auto;max-height:", ({
13
17
  opened,
@@ -24,7 +28,8 @@ const Expandable = ({
24
28
  opened,
25
29
  minHeight = 0,
26
30
  className,
27
- 'data-testid': dataTestId
31
+ 'data-testid': dataTestId,
32
+ animationDuration = ANIMATION_DURATION
28
33
  }) => {
29
34
  const [height, setHeight] = useState(null);
30
35
  const transitionTimer = useRef();
@@ -76,6 +81,7 @@ const Expandable = ({
76
81
  className: className,
77
82
  opened: opened,
78
83
  minHeight: minHeight,
84
+ animationDuration: animationDuration,
79
85
  children: children
80
86
  });
81
87
  };
@@ -9,7 +9,6 @@ import { Tooltip } from '../Tooltip/index.js';
9
9
  import { jsxs, jsx } from '@emotion/react/jsx-runtime';
10
10
 
11
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 NUMBER_INPUT_MAX_STR_LENGTH = /*#__PURE__*/Number.MAX_SAFE_INTEGER.toString().length;
13
12
  const SIZES = {
14
13
  small: '30px',
15
14
  medium: '38px',
@@ -139,27 +138,6 @@ const NumberInputV2 = /*#__PURE__*/forwardRef(({
139
138
  }
140
139
  onChange?.(parseInt(localRef.current?.value ?? '', 10) ?? min);
141
140
  }, [localRef, min, onChange]);
142
- const onChangeValue = inputStr => {
143
- if (onChange) {
144
- let numericValue;
145
- if (inputStr.length > NUMBER_INPUT_MAX_STR_LENGTH && inputStr.startsWith('-')) {
146
- numericValue = min;
147
- } else if (inputStr.length > NUMBER_INPUT_MAX_STR_LENGTH) {
148
- numericValue = max;
149
- } else {
150
- numericValue = parseInt(inputStr, 10);
151
- if (Number.isNaN(numericValue) || numericValue < min) {
152
- numericValue = min;
153
- } else if (numericValue > max) {
154
- numericValue = max;
155
- }
156
- }
157
- onChange(numericValue);
158
- if (localRef.current) {
159
- localRef.current.value = numericValue.toString();
160
- }
161
- }
162
- };
163
141
  const isMinusDisabled = useMemo(() => {
164
142
  if (!localRef?.current?.value || localRef?.current?.value === '') {
165
143
  return false;
@@ -191,6 +169,10 @@ const NumberInputV2 = /*#__PURE__*/forwardRef(({
191
169
  }
192
170
  return 'neutral';
193
171
  }, [error, success]);
172
+ let inputValue;
173
+ if (value !== undefined) {
174
+ inputValue = value !== null && Number.isInteger(value) ? value.toString() : '';
175
+ }
194
176
  return jsxs(Stack, {
195
177
  gap: "0.5",
196
178
  className: className,
@@ -246,28 +228,13 @@ const NumberInputV2 = /*#__PURE__*/forwardRef(({
246
228
  name: name,
247
229
  id: localId,
248
230
  placeholder: placeholder,
249
- onKeyDown: event => {
250
- if (event.key === 'Enter') {
251
- if (!localRef.current?.value) {
252
- onChange?.(null);
253
- } else if (onChange) {
254
- onChangeValue(localRef.current?.value ?? '');
255
- }
256
- }
257
- },
258
- onBlur: event => {
259
- if (event.target.value === '') {
260
- onBlur?.(event);
261
- onChange?.(null);
262
- return;
263
- }
264
- if (onChange) {
265
- onChangeValue(event.target.value);
266
- }
267
- onBlur?.(event);
268
- },
269
- defaultValue: value?.toString(),
231
+ onChange: onChange ? event => {
232
+ const newNumber = parseInt(event.target.value, 10);
233
+ onChange(Number.isNaN(newNumber) ? null : newNumber);
234
+ } : undefined,
235
+ value: inputValue,
270
236
  onFocus: onFocus,
237
+ onBlur: onBlur,
271
238
  "data-size": size,
272
239
  step: step,
273
240
  disabled: disabled,
@@ -13,7 +13,7 @@ const StyledIcon = /*#__PURE__*/_styled(Icon, {
13
13
  })("fill:", ({
14
14
  color,
15
15
  theme
16
- }) => theme.colors[color].border, ";");
16
+ }) => theme.colors[color].borderWeak, ";");
17
17
  const StyledHr = /*#__PURE__*/_styled('hr', {
18
18
  shouldForwardProp: prop => !['direction', 'thickness', 'color', 'hasIcon'].includes(prop),
19
19
  target: "e1d1zom90"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultraviolet/ui",
3
- "version": "1.43.2",
3
+ "version": "1.44.0",
4
4
  "description": "Ultraviolet UI",
5
5
  "homepage": "https://github.com/scaleway/ultraviolet#readme",
6
6
  "repository": {
@@ -39,7 +39,7 @@
39
39
  "react-dom": "18.2.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@babel/core": "7.24.0",
42
+ "@babel/core": "7.24.1",
43
43
  "@emotion/babel-plugin": "11.11.0",
44
44
  "@emotion/react": "11.11.4",
45
45
  "@emotion/styled": "11.11.0",
@@ -67,7 +67,7 @@
67
67
  "react-use-clipboard": "1.0.9",
68
68
  "reakit": "1.3.11",
69
69
  "@ultraviolet/themes": "1.9.0",
70
- "@ultraviolet/icons": "2.10.1"
70
+ "@ultraviolet/icons": "2.11.0"
71
71
  },
72
72
  "scripts": {
73
73
  "build": "rollup -c ../../rollup.config.mjs",