@tidbcloud/uikit 2.4.3 → 2.4.5
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/CHANGELOG.md +12 -0
- package/dist/biz/DateTimePicker/index.cjs +2 -1
- package/dist/biz/DateTimePicker/index.d.cts +19 -2
- package/dist/biz/DateTimePicker/index.d.mts +19 -2
- package/dist/biz/DateTimePicker/index.mjs +2 -1
- package/dist/theme/theme.cjs +32 -17
- package/dist/theme/theme.mjs +32 -17
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @tidbcloud/uikit
|
|
2
2
|
|
|
3
|
+
## 2.4.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fix(biz): enhance DateTimePicker with formatter prop and update storybook demo ([#551](https://github.com/tidbcloud/tidbcloud-uikit/pull/551))
|
|
8
|
+
|
|
9
|
+
## 2.4.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- fix(uikit): enhance Tabs component with variant themes support and update storybook controls ([#549](https://github.com/tidbcloud/tidbcloud-uikit/pull/549))
|
|
14
|
+
|
|
3
15
|
## 2.4.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -28,6 +28,7 @@ const Flex = require("../../node_modules/.pnpm/@mantine_core@7.15.2_patch_hash_j
|
|
|
28
28
|
const DateTimePicker = ({
|
|
29
29
|
placeholder = "Select time",
|
|
30
30
|
format = helpers.DEFAULT_TIME_FORMAT,
|
|
31
|
+
formatter,
|
|
31
32
|
defaultValue,
|
|
32
33
|
value,
|
|
33
34
|
startDate = dayjs.dayjs().subtract(10, "year").toDate(),
|
|
@@ -68,7 +69,7 @@ const DateTimePicker = ({
|
|
|
68
69
|
setCurrentValueChangedBy(null);
|
|
69
70
|
}, 20);
|
|
70
71
|
});
|
|
71
|
-
const inputStr = currentValue.format(format);
|
|
72
|
+
const inputStr = formatter ? formatter(currentValue.utcOffset(utcOffset).toDate()) : currentValue.utcOffset(utcOffset).format(format);
|
|
72
73
|
const utcStr = React.useMemo(() => {
|
|
73
74
|
const h = Math.floor(utcOffset / 60);
|
|
74
75
|
const m = utcOffset % 60;
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
import { MantineSize, TextInputProps, TimeInputProps
|
|
1
|
+
import { MantineSize, PopoverProps, TextInputProps, TimeInputProps } from '../../primitive/index.cjs';
|
|
2
2
|
export interface DateTimePickerProps extends Omit<TextInputProps, 'value' | 'onChange' | 'defaultValue'> {
|
|
3
|
+
/**
|
|
4
|
+
* The placeholder of the input.
|
|
5
|
+
* @default 'Select time'
|
|
6
|
+
*/
|
|
3
7
|
placeholder?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The format of the date string.
|
|
10
|
+
* @default 'YYYY-MM-DD HH:mm:ss'
|
|
11
|
+
*/
|
|
4
12
|
format?: string;
|
|
13
|
+
/**
|
|
14
|
+
* A function to format the date in the input
|
|
15
|
+
* If provided, `format` prop will be ignored.
|
|
16
|
+
*/
|
|
17
|
+
formatter?: (val: Date) => string;
|
|
18
|
+
/**
|
|
19
|
+
* The UTC offset in minutes.
|
|
20
|
+
* See https://day.js.org/docs/en/manipulate/utc-offset
|
|
21
|
+
*/
|
|
5
22
|
utcOffset?: number;
|
|
6
23
|
defaultValue?: Date;
|
|
7
24
|
value?: Date;
|
|
@@ -13,7 +30,7 @@ export interface DateTimePickerProps extends Omit<TextInputProps, 'value' | 'onC
|
|
|
13
30
|
loading?: boolean;
|
|
14
31
|
size?: MantineSize;
|
|
15
32
|
}
|
|
16
|
-
export declare const DateTimePicker: ({ placeholder, format, defaultValue, value, startDate, endDate, onChange, disable, utcOffset, withinPortal, sx, loading, size }: DateTimePickerProps) => import("react/jsx-runtime.js").JSX.Element;
|
|
33
|
+
export declare const DateTimePicker: ({ placeholder, format, formatter, defaultValue, value, startDate, endDate, onChange, disable, utcOffset, withinPortal, sx, loading, size }: DateTimePickerProps) => import("react/jsx-runtime.js").JSX.Element;
|
|
17
34
|
export interface TimePickerProps extends Omit<TimeInputProps, 'value' | 'onChange' | 'defaultValue'>, Pick<PopoverProps, 'withinPortal' | 'withArrow' | 'position' | 'shadow'> {
|
|
18
35
|
defaultValue?: string;
|
|
19
36
|
/**
|
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
import { MantineSize, TextInputProps, TimeInputProps
|
|
1
|
+
import { MantineSize, PopoverProps, TextInputProps, TimeInputProps } from '../../primitive/index.mjs';
|
|
2
2
|
export interface DateTimePickerProps extends Omit<TextInputProps, 'value' | 'onChange' | 'defaultValue'> {
|
|
3
|
+
/**
|
|
4
|
+
* The placeholder of the input.
|
|
5
|
+
* @default 'Select time'
|
|
6
|
+
*/
|
|
3
7
|
placeholder?: string;
|
|
8
|
+
/**
|
|
9
|
+
* The format of the date string.
|
|
10
|
+
* @default 'YYYY-MM-DD HH:mm:ss'
|
|
11
|
+
*/
|
|
4
12
|
format?: string;
|
|
13
|
+
/**
|
|
14
|
+
* A function to format the date in the input
|
|
15
|
+
* If provided, `format` prop will be ignored.
|
|
16
|
+
*/
|
|
17
|
+
formatter?: (val: Date) => string;
|
|
18
|
+
/**
|
|
19
|
+
* The UTC offset in minutes.
|
|
20
|
+
* See https://day.js.org/docs/en/manipulate/utc-offset
|
|
21
|
+
*/
|
|
5
22
|
utcOffset?: number;
|
|
6
23
|
defaultValue?: Date;
|
|
7
24
|
value?: Date;
|
|
@@ -13,7 +30,7 @@ export interface DateTimePickerProps extends Omit<TextInputProps, 'value' | 'onC
|
|
|
13
30
|
loading?: boolean;
|
|
14
31
|
size?: MantineSize;
|
|
15
32
|
}
|
|
16
|
-
export declare const DateTimePicker: ({ placeholder, format, defaultValue, value, startDate, endDate, onChange, disable, utcOffset, withinPortal, sx, loading, size }: DateTimePickerProps) => import("react/jsx-runtime.js").JSX.Element;
|
|
33
|
+
export declare const DateTimePicker: ({ placeholder, format, formatter, defaultValue, value, startDate, endDate, onChange, disable, utcOffset, withinPortal, sx, loading, size }: DateTimePickerProps) => import("react/jsx-runtime.js").JSX.Element;
|
|
17
34
|
export interface TimePickerProps extends Omit<TimeInputProps, 'value' | 'onChange' | 'defaultValue'>, Pick<PopoverProps, 'withinPortal' | 'withArrow' | 'position' | 'shadow'> {
|
|
18
35
|
defaultValue?: string;
|
|
19
36
|
/**
|
|
@@ -26,6 +26,7 @@ import { Flex } from "../../node_modules/.pnpm/@mantine_core@7.15.2_patch_hash_j
|
|
|
26
26
|
const DateTimePicker = ({
|
|
27
27
|
placeholder = "Select time",
|
|
28
28
|
format = DEFAULT_TIME_FORMAT,
|
|
29
|
+
formatter,
|
|
29
30
|
defaultValue,
|
|
30
31
|
value,
|
|
31
32
|
startDate = dayjs().subtract(10, "year").toDate(),
|
|
@@ -66,7 +67,7 @@ const DateTimePicker = ({
|
|
|
66
67
|
setCurrentValueChangedBy(null);
|
|
67
68
|
}, 20);
|
|
68
69
|
});
|
|
69
|
-
const inputStr = currentValue.format(format);
|
|
70
|
+
const inputStr = formatter ? formatter(currentValue.utcOffset(utcOffset).toDate()) : currentValue.utcOffset(utcOffset).format(format);
|
|
70
71
|
const utcStr = useMemo(() => {
|
|
71
72
|
const h = Math.floor(utcOffset / 60);
|
|
72
73
|
const m = utcOffset % 60;
|
package/dist/theme/theme.cjs
CHANGED
|
@@ -342,25 +342,40 @@ const theme = createTheme.createTheme({
|
|
|
342
342
|
},
|
|
343
343
|
Tabs: {
|
|
344
344
|
styles(theme2, props) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
fontWeight: 600,
|
|
353
|
-
paddingLeft: 0,
|
|
354
|
-
paddingRight: props.orientation === "vertical" ? 8 : 0,
|
|
355
|
-
"&[data-active]": {
|
|
356
|
-
color: themeColor(theme2, "carbon", 9)
|
|
345
|
+
const variant = props.variant || "default";
|
|
346
|
+
if (variant === "default") {
|
|
347
|
+
return {
|
|
348
|
+
list: {
|
|
349
|
+
"--tab-border-color": "transparent",
|
|
350
|
+
gap: props.orientation === "vertical" ? 8 : 32,
|
|
351
|
+
border: 0
|
|
357
352
|
},
|
|
358
|
-
|
|
359
|
-
color: themeColor(theme2, "carbon",
|
|
360
|
-
|
|
353
|
+
tab: {
|
|
354
|
+
color: themeColor(theme2, "carbon", 7),
|
|
355
|
+
fontWeight: 600,
|
|
356
|
+
paddingLeft: 0,
|
|
357
|
+
paddingRight: props.orientation === "vertical" ? 8 : 0,
|
|
358
|
+
"&[data-active]": {
|
|
359
|
+
color: themeColor(theme2, "carbon", 9)
|
|
360
|
+
},
|
|
361
|
+
"&:hover": {
|
|
362
|
+
color: themeColor(theme2, "carbon", 9),
|
|
363
|
+
backgroundColor: "transparent"
|
|
364
|
+
}
|
|
361
365
|
}
|
|
362
|
-
}
|
|
363
|
-
}
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
if (variant === "outline") {
|
|
369
|
+
return {
|
|
370
|
+
list: {
|
|
371
|
+
"--tab-border-color": themeColor(theme2, "carbon", 4)
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
if (variant === "pills") {
|
|
376
|
+
return {};
|
|
377
|
+
}
|
|
378
|
+
return {};
|
|
364
379
|
}
|
|
365
380
|
},
|
|
366
381
|
Notification: {
|
package/dist/theme/theme.mjs
CHANGED
|
@@ -340,25 +340,40 @@ const theme = createTheme({
|
|
|
340
340
|
},
|
|
341
341
|
Tabs: {
|
|
342
342
|
styles(theme2, props) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
fontWeight: 600,
|
|
351
|
-
paddingLeft: 0,
|
|
352
|
-
paddingRight: props.orientation === "vertical" ? 8 : 0,
|
|
353
|
-
"&[data-active]": {
|
|
354
|
-
color: themeColor(theme2, "carbon", 9)
|
|
343
|
+
const variant = props.variant || "default";
|
|
344
|
+
if (variant === "default") {
|
|
345
|
+
return {
|
|
346
|
+
list: {
|
|
347
|
+
"--tab-border-color": "transparent",
|
|
348
|
+
gap: props.orientation === "vertical" ? 8 : 32,
|
|
349
|
+
border: 0
|
|
355
350
|
},
|
|
356
|
-
|
|
357
|
-
color: themeColor(theme2, "carbon",
|
|
358
|
-
|
|
351
|
+
tab: {
|
|
352
|
+
color: themeColor(theme2, "carbon", 7),
|
|
353
|
+
fontWeight: 600,
|
|
354
|
+
paddingLeft: 0,
|
|
355
|
+
paddingRight: props.orientation === "vertical" ? 8 : 0,
|
|
356
|
+
"&[data-active]": {
|
|
357
|
+
color: themeColor(theme2, "carbon", 9)
|
|
358
|
+
},
|
|
359
|
+
"&:hover": {
|
|
360
|
+
color: themeColor(theme2, "carbon", 9),
|
|
361
|
+
backgroundColor: "transparent"
|
|
362
|
+
}
|
|
359
363
|
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
if (variant === "outline") {
|
|
367
|
+
return {
|
|
368
|
+
list: {
|
|
369
|
+
"--tab-border-color": themeColor(theme2, "carbon", 4)
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
if (variant === "pills") {
|
|
374
|
+
return {};
|
|
375
|
+
}
|
|
376
|
+
return {};
|
|
362
377
|
}
|
|
363
378
|
},
|
|
364
379
|
Notification: {
|