@ultraviolet/ui 1.43.1 → 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 = {
@@ -2079,8 +2080,8 @@ declare const NumberInputV2: react.ForwardRefExoticComponent<{
2079
2080
  error?: string | undefined;
2080
2081
  success?: string | boolean | undefined;
2081
2082
  helper?: ReactNode;
2082
- value?: number | undefined;
2083
- onChange?: ((newValue: number) => void) | undefined;
2083
+ value?: number | null | undefined;
2084
+ onChange?: ((newValue: number | null) => void) | undefined;
2084
2085
  min?: number | undefined;
2085
2086
  max?: number | undefined;
2086
2087
  } & Pick<InputHTMLAttributes<HTMLInputElement>, "autoFocus" | "id" | "aria-label" | "onFocus" | "onBlur" | "name" | "disabled" | "step" | "placeholder" | "readOnly" | "required"> & react.RefAttributes<HTMLInputElement>>;
@@ -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,23 +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
- onChangeValue(localRef.current?.value ?? '');
252
- }
253
- },
254
- onBlur: event => {
255
- if (event.target.value === '') {
256
- onBlur?.(event);
257
- return;
258
- }
259
- if (onChange) {
260
- onChangeValue(event.target.value);
261
- }
262
- onBlur?.(event);
263
- },
264
- defaultValue: value,
231
+ onChange: onChange ? event => {
232
+ const newNumber = parseInt(event.target.value, 10);
233
+ onChange(Number.isNaN(newNumber) ? null : newNumber);
234
+ } : undefined,
235
+ value: inputValue,
265
236
  onFocus: onFocus,
237
+ onBlur: onBlur,
266
238
  "data-size": size,
267
239
  step: step,
268
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"
@@ -58,7 +58,7 @@ const StyledInputWrapper = /*#__PURE__*/_styled('div', {
58
58
  theme
59
59
  }) => theme.colors.success.border, ";}&[data-error='true']{border-color:", ({
60
60
  theme
61
- }) => theme.colors.danger.border, ";}&[data-readOnly='true']{background:", ({
61
+ }) => theme.colors.danger.border, ";}&[data-readonly='true']{background:", ({
62
62
  theme
63
63
  }) => theme.colors.neutral.backgroundWeak, ";border-color:", ({
64
64
  theme
@@ -70,7 +70,7 @@ const StyledInputWrapper = /*#__PURE__*/_styled('div', {
70
70
  theme
71
71
  }) => theme.colors.neutral.textDisabled, ";&::placeholder{color:", ({
72
72
  theme
73
- }) => theme.colors.neutral.textWeakDisabled, ";}}}&:not([data-disabled='true']):not([data-readOnly]):hover{border-color:", ({
73
+ }) => theme.colors.neutral.textWeakDisabled, ";}}}&:not([data-disabled='true']):not([data-readonly]):hover{border-color:", ({
74
74
  theme
75
75
  }) => theme.colors.primary.border, ";}", ({
76
76
  theme,
@@ -159,7 +159,7 @@ const TextInputV2 = /*#__PURE__*/forwardRef(({
159
159
  children: jsxs(StyledInputWrapper, {
160
160
  hasFocus: hasFocus,
161
161
  "data-disabled": disabled,
162
- "data-readOnly": readOnly,
162
+ "data-readonly": readOnly,
163
163
  "data-success": !!success,
164
164
  "data-error": !!error,
165
165
  size: size,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultraviolet/ui",
3
- "version": "1.43.1",
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",
@@ -63,11 +63,11 @@
63
63
  "react-datepicker": "4.25.0",
64
64
  "react-flatten-children": "1.1.2",
65
65
  "react-select": "5.8.0",
66
- "react-toastify": "10.0.4",
66
+ "react-toastify": "10.0.5",
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",