@ultraviolet/ui 1.42.0 → 1.43.1
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
|
@@ -1202,6 +1202,7 @@ type CommonProps = {
|
|
|
1202
1202
|
sentiment?: SENTIMENT;
|
|
1203
1203
|
disabled?: boolean;
|
|
1204
1204
|
iconPosition?: 'left' | 'right';
|
|
1205
|
+
iconVariant?: ComponentProps<typeof Icon>['variant'];
|
|
1205
1206
|
fullWidth?: boolean;
|
|
1206
1207
|
isLoading?: boolean;
|
|
1207
1208
|
'aria-label'?: string;
|
|
@@ -1484,6 +1485,7 @@ type BulletSize = keyof typeof sizes;
|
|
|
1484
1485
|
type ContentProps$1 = XOR<[
|
|
1485
1486
|
{
|
|
1486
1487
|
icon: ComponentProps<typeof Icon>['name'];
|
|
1488
|
+
iconVariant?: ComponentProps<typeof Icon>['variant'];
|
|
1487
1489
|
},
|
|
1488
1490
|
{
|
|
1489
1491
|
text: string;
|
|
@@ -1501,7 +1503,7 @@ type BulletProps = {
|
|
|
1501
1503
|
/**
|
|
1502
1504
|
* Bullet component is used to display a small icon or text with a colored background in a circle.
|
|
1503
1505
|
*/
|
|
1504
|
-
declare const Bullet: ({ className, sentiment, size, icon, text, tooltip, tooltipBaseId, "data-testid": dataTestId, prominence, }: BulletProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
1506
|
+
declare const Bullet: ({ className, sentiment, size, icon, iconVariant, text, tooltip, tooltipBaseId, "data-testid": dataTestId, prominence, }: BulletProps) => _emotion_react_jsx_runtime.JSX.Element;
|
|
1505
1507
|
|
|
1506
1508
|
type CardProps = {
|
|
1507
1509
|
children: ReactNode;
|
|
@@ -2077,8 +2079,11 @@ declare const NumberInputV2: react.ForwardRefExoticComponent<{
|
|
|
2077
2079
|
error?: string | undefined;
|
|
2078
2080
|
success?: string | boolean | undefined;
|
|
2079
2081
|
helper?: ReactNode;
|
|
2080
|
-
value?:
|
|
2081
|
-
|
|
2082
|
+
value?: number | undefined;
|
|
2083
|
+
onChange?: ((newValue: number) => void) | undefined;
|
|
2084
|
+
min?: number | undefined;
|
|
2085
|
+
max?: number | undefined;
|
|
2086
|
+
} & Pick<InputHTMLAttributes<HTMLInputElement>, "autoFocus" | "id" | "aria-label" | "onFocus" | "onBlur" | "name" | "disabled" | "step" | "placeholder" | "readOnly" | "required"> & react.RefAttributes<HTMLInputElement>>;
|
|
2082
2087
|
|
|
2083
2088
|
type PaginationProps = {
|
|
2084
2089
|
/**
|
|
@@ -72,6 +72,7 @@ const Bullet = ({
|
|
|
72
72
|
sentiment = 'neutral',
|
|
73
73
|
size = 'medium',
|
|
74
74
|
icon,
|
|
75
|
+
iconVariant,
|
|
75
76
|
text,
|
|
76
77
|
tooltip,
|
|
77
78
|
tooltipBaseId,
|
|
@@ -88,7 +89,8 @@ const Bullet = ({
|
|
|
88
89
|
prominence: prominence,
|
|
89
90
|
children: icon ? jsx(Icon, {
|
|
90
91
|
name: icon,
|
|
91
|
-
size: "50%"
|
|
92
|
+
size: "50%",
|
|
93
|
+
variant: iconVariant
|
|
92
94
|
}) : text
|
|
93
95
|
})
|
|
94
96
|
});
|
|
@@ -201,6 +201,7 @@ const Button = /*#__PURE__*/forwardRef(({
|
|
|
201
201
|
disabled = false,
|
|
202
202
|
icon,
|
|
203
203
|
iconPosition = 'left',
|
|
204
|
+
iconVariant,
|
|
204
205
|
fullWidth = false,
|
|
205
206
|
isLoading = false,
|
|
206
207
|
children,
|
|
@@ -226,7 +227,8 @@ const Button = /*#__PURE__*/forwardRef(({
|
|
|
226
227
|
const content = jsxs(Fragment, {
|
|
227
228
|
children: [!isLoading && icon ? jsx(Icon, {
|
|
228
229
|
name: icon,
|
|
229
|
-
size:
|
|
230
|
+
size: "small",
|
|
231
|
+
variant: iconVariant
|
|
230
232
|
}) : null, isLoading ? jsx(Loader, {
|
|
231
233
|
active: true,
|
|
232
234
|
trailColor: "transparent",
|
|
@@ -9,6 +9,7 @@ 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;
|
|
12
13
|
const SIZES = {
|
|
13
14
|
small: '30px',
|
|
14
15
|
medium: '38px',
|
|
@@ -101,7 +102,7 @@ const Container = /*#__PURE__*/_styled("div", {
|
|
|
101
102
|
*/
|
|
102
103
|
const NumberInputV2 = /*#__PURE__*/forwardRef(({
|
|
103
104
|
disabled = false,
|
|
104
|
-
max =
|
|
105
|
+
max = Number.MAX_SAFE_INTEGER,
|
|
105
106
|
min = 0,
|
|
106
107
|
name,
|
|
107
108
|
onChange,
|
|
@@ -130,21 +131,35 @@ const NumberInputV2 = /*#__PURE__*/forwardRef(({
|
|
|
130
131
|
useImperativeHandle(ref, () => localRef.current);
|
|
131
132
|
const uniqueId = useId();
|
|
132
133
|
const localId = id ?? uniqueId;
|
|
133
|
-
const createChangeEvent = newValue => ({
|
|
134
|
-
target: {
|
|
135
|
-
value: newValue
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
134
|
const onClickSideButton = useCallback(direction => () => {
|
|
139
135
|
if (direction === 'up') {
|
|
140
136
|
localRef.current?.stepUp();
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
if (direction === 'down') {
|
|
137
|
+
} else if (direction === 'down') {
|
|
144
138
|
localRef.current?.stepDown();
|
|
145
|
-
onChange?.(createChangeEvent(localRef.current?.value ?? min));
|
|
146
139
|
}
|
|
140
|
+
onChange?.(parseInt(localRef.current?.value ?? '', 10) ?? min);
|
|
147
141
|
}, [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
|
+
};
|
|
148
163
|
const isMinusDisabled = useMemo(() => {
|
|
149
164
|
if (!localRef?.current?.value || localRef?.current?.value === '') {
|
|
150
165
|
return false;
|
|
@@ -231,25 +246,23 @@ const NumberInputV2 = /*#__PURE__*/forwardRef(({
|
|
|
231
246
|
name: name,
|
|
232
247
|
id: localId,
|
|
233
248
|
placeholder: placeholder,
|
|
249
|
+
onKeyDown: event => {
|
|
250
|
+
if (event.key === 'Enter') {
|
|
251
|
+
onChangeValue(localRef.current?.value ?? '');
|
|
252
|
+
}
|
|
253
|
+
},
|
|
234
254
|
onBlur: event => {
|
|
235
255
|
if (event.target.value === '') {
|
|
236
256
|
onBlur?.(event);
|
|
237
257
|
return;
|
|
238
258
|
}
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
const minValue = typeof min === 'number' ? min : Number(min);
|
|
242
|
-
if (Number.isNaN(numericValue) || !Number.isNaN(minValue) && numericValue < minValue) {
|
|
243
|
-
onChange?.(createChangeEvent(min.toString()));
|
|
244
|
-
}
|
|
245
|
-
if (Number.isNaN(numericValue) || !Number.isNaN(maxValue) && numericValue > maxValue) {
|
|
246
|
-
onChange?.(createChangeEvent(max.toString()));
|
|
259
|
+
if (onChange) {
|
|
260
|
+
onChangeValue(event.target.value);
|
|
247
261
|
}
|
|
248
262
|
onBlur?.(event);
|
|
249
263
|
},
|
|
264
|
+
defaultValue: value,
|
|
250
265
|
onFocus: onFocus,
|
|
251
|
-
onChange: onChange,
|
|
252
|
-
value: value,
|
|
253
266
|
"data-size": size,
|
|
254
267
|
step: step,
|
|
255
268
|
disabled: disabled,
|