@tidbcloud/uikit 2.2.10 → 2.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @tidbcloud/uikit
2
2
 
3
+ ## 2.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - feat(TimePicker): add TimePicker componnet ([#527](https://github.com/tidbcloud/tidbcloud-uikit/pull/527))
8
+ - feat(theme): add default props for HoverCard/Popover ([#526](https://github.com/tidbcloud/tidbcloud-uikit/pull/526))
9
+ - chore: update snapshot release workflow to push all tags ([#524](https://github.com/tidbcloud/tidbcloud-uikit/pull/524))
10
+ - docs: enhance snapshot release section with GitHub Actions workflow details ([#523](https://github.com/tidbcloud/tidbcloud-uikit/pull/523))
11
+ - chore: add npm setup step for publishing snapshots ([#522](https://github.com/tidbcloud/tidbcloud-uikit/pull/522))
12
+
13
+ ## 2.2.11
14
+
15
+ ### Patch Changes
16
+
17
+ - fix(theme): update Card and Paper components' shadow and border styles ([#520](https://github.com/tidbcloud/tidbcloud-uikit/pull/520))
18
+
3
19
  ## 2.2.10
4
20
 
5
21
  ### Patch Changes
@@ -227,4 +227,138 @@ const DateTimePicker = ({
227
227
  }
228
228
  );
229
229
  };
230
+ const TimePicker = ({
231
+ value,
232
+ onChange,
233
+ defaultValue,
234
+ disable = false,
235
+ sx,
236
+ size,
237
+ minTime,
238
+ maxTime,
239
+ withinPortal,
240
+ withArrow,
241
+ position,
242
+ shadow,
243
+ ...rest
244
+ }) => {
245
+ const [currentValue, setCurrentValue] = useUncontrolled.useUncontrolled({
246
+ value: value ? dayjs.dayjs(value) : void 0,
247
+ defaultValue: defaultValue ? dayjs.dayjs(defaultValue) : dayjs.dayjs(),
248
+ onChange: (v) => {
249
+ onChange == null ? void 0 : onChange(v.toDate());
250
+ }
251
+ });
252
+ const [currentValueChangedBy, setCurrentValueChangedBy] = React.useState(null);
253
+ const startDate = React.useMemo(() => dayjs.dayjs(minTime, "HH:mm:ss"), [minTime]);
254
+ const endDate = React.useMemo(() => dayjs.dayjs(maxTime, "HH:mm:ss"), [maxTime]);
255
+ const updateCurrentValue = ahooks.useMemoizedFn((val, from) => {
256
+ let next = val;
257
+ if (!next.isValid()) {
258
+ return;
259
+ }
260
+ if ((currentValue == null ? void 0 : currentValue.unix()) === next.unix()) {
261
+ return;
262
+ }
263
+ if (startDate && next.isBefore(startDate)) {
264
+ next = dayjs.dayjs(startDate);
265
+ } else if (endDate && next.isAfter(endDate)) {
266
+ next = dayjs.dayjs(endDate);
267
+ }
268
+ setCurrentValue(next);
269
+ setCurrentValueChangedBy(from);
270
+ setTimeout(() => {
271
+ setCurrentValueChangedBy(null);
272
+ }, 20);
273
+ });
274
+ const timeInputChange = ahooks.useMemoizedFn((e) => {
275
+ const originVal = e.currentTarget.value;
276
+ const v = dayjs.dayjs(originVal, "HH:mm:ss").toDate();
277
+ let next = currentValue;
278
+ next = next.hour(v.getHours()).minute(v.getMinutes()).second(v.getSeconds());
279
+ updateCurrentValue(next, "timeInput");
280
+ });
281
+ const timeScrollPickerChange = ahooks.useMemoizedFn((v) => {
282
+ const [h, m, s] = v;
283
+ let next = currentValue;
284
+ next = next.hour(h).minute(m).second(s);
285
+ updateCurrentValue(next, "timeScroller");
286
+ });
287
+ return /* @__PURE__ */ jsxRuntime.jsxs(Popover.Popover, { withinPortal, withArrow, position, shadow, children: [
288
+ /* @__PURE__ */ jsxRuntime.jsx(Popover.Popover.Target, { children: /* @__PURE__ */ jsxRuntime.jsx(
289
+ TimeInput.TimeInput,
290
+ {
291
+ ...rest,
292
+ disabled: disable,
293
+ withSeconds: true,
294
+ value: currentValue.format("HH:mm:ss"),
295
+ onChange: timeInputChange,
296
+ size,
297
+ sx,
298
+ rightSection: /* @__PURE__ */ jsxRuntime.jsx(index.IconClock, { size: 16, c: "carbon.7" })
299
+ }
300
+ ) }),
301
+ /* @__PURE__ */ jsxRuntime.jsx(Popover.Popover.Dropdown, { children: /* @__PURE__ */ jsxRuntime.jsxs(
302
+ Box.Box,
303
+ {
304
+ pos: "relative",
305
+ fz: 14,
306
+ fw: 400,
307
+ h: 224,
308
+ sx: (theme) => ({ color: theme.colors.carbon[8], overflow: "hidden", zIndex: 9999 }),
309
+ children: [
310
+ /* @__PURE__ */ jsxRuntime.jsxs(Flex.Flex, { mah: "100%", gap: 8, children: [
311
+ /* @__PURE__ */ jsxRuntime.jsx(
312
+ Box.Box,
313
+ {
314
+ bg: "carbon.3",
315
+ pos: "absolute",
316
+ top: 0,
317
+ left: 0,
318
+ h: 32,
319
+ w: 32,
320
+ sx: (theme) => ({ zIndex: -1, borderRadius: theme.defaultRadius, pointerEvents: "none" })
321
+ }
322
+ ),
323
+ /* @__PURE__ */ jsxRuntime.jsx(
324
+ Box.Box,
325
+ {
326
+ bg: "carbon.3",
327
+ pos: "absolute",
328
+ top: 0,
329
+ left: 40,
330
+ h: 32,
331
+ w: 32,
332
+ sx: (theme) => ({ zIndex: -1, borderRadius: theme.defaultRadius, pointerEvents: "none" })
333
+ }
334
+ ),
335
+ /* @__PURE__ */ jsxRuntime.jsx(
336
+ Box.Box,
337
+ {
338
+ bg: "carbon.3",
339
+ pos: "absolute",
340
+ top: 0,
341
+ left: 80,
342
+ h: 32,
343
+ w: 32,
344
+ sx: (theme) => ({ zIndex: -1, borderRadius: theme.defaultRadius, pointerEvents: "none" })
345
+ }
346
+ )
347
+ ] }),
348
+ /* @__PURE__ */ jsxRuntime.jsx(
349
+ TimeScollerPicker.TimeScollerPicker,
350
+ {
351
+ currentValue,
352
+ currentValueChangedBy,
353
+ onChange: timeScrollPickerChange,
354
+ start: startDate.toDate(),
355
+ end: endDate.toDate()
356
+ }
357
+ )
358
+ ]
359
+ }
360
+ ) })
361
+ ] });
362
+ };
230
363
  exports.DateTimePicker = DateTimePicker;
364
+ exports.TimePicker = TimePicker;
@@ -1,4 +1,4 @@
1
- import { MantineSize, TextInputProps } from '../../primitive/index.cjs';
1
+ import { MantineSize, TextInputProps, TimeInputProps, PopoverProps } from '../../primitive/index.cjs';
2
2
  export interface DateTimePickerProps extends Omit<TextInputProps, 'value' | 'onChange' | 'defaultValue'> {
3
3
  placeholder?: string;
4
4
  format?: string;
@@ -14,3 +14,11 @@ export interface DateTimePickerProps extends Omit<TextInputProps, 'value' | 'onC
14
14
  size?: MantineSize;
15
15
  }
16
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;
17
+ export interface TimePickerProps extends Omit<TimeInputProps, 'value' | 'onChange' | 'defaultValue'>, Pick<PopoverProps, 'withinPortal' | 'withArrow' | 'position' | 'shadow'> {
18
+ defaultValue?: Date;
19
+ value?: Date;
20
+ onChange?: (val: Date) => void;
21
+ disable?: boolean;
22
+ size?: MantineSize;
23
+ }
24
+ export declare const TimePicker: ({ value, onChange, defaultValue, disable, sx, size, minTime, maxTime, withinPortal, withArrow, position, shadow, ...rest }: TimePickerProps) => import("react/jsx-runtime.js").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { MantineSize, TextInputProps } from '../../primitive/index.mjs';
1
+ import { MantineSize, TextInputProps, TimeInputProps, PopoverProps } from '../../primitive/index.mjs';
2
2
  export interface DateTimePickerProps extends Omit<TextInputProps, 'value' | 'onChange' | 'defaultValue'> {
3
3
  placeholder?: string;
4
4
  format?: string;
@@ -14,3 +14,11 @@ export interface DateTimePickerProps extends Omit<TextInputProps, 'value' | 'onC
14
14
  size?: MantineSize;
15
15
  }
16
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;
17
+ export interface TimePickerProps extends Omit<TimeInputProps, 'value' | 'onChange' | 'defaultValue'>, Pick<PopoverProps, 'withinPortal' | 'withArrow' | 'position' | 'shadow'> {
18
+ defaultValue?: Date;
19
+ value?: Date;
20
+ onChange?: (val: Date) => void;
21
+ disable?: boolean;
22
+ size?: MantineSize;
23
+ }
24
+ export declare const TimePicker: ({ value, onChange, defaultValue, disable, sx, size, minTime, maxTime, withinPortal, withArrow, position, shadow, ...rest }: TimePickerProps) => import("react/jsx-runtime.js").JSX.Element;
@@ -225,6 +225,140 @@ const DateTimePicker = ({
225
225
  }
226
226
  );
227
227
  };
228
+ const TimePicker = ({
229
+ value,
230
+ onChange,
231
+ defaultValue,
232
+ disable = false,
233
+ sx,
234
+ size,
235
+ minTime,
236
+ maxTime,
237
+ withinPortal,
238
+ withArrow,
239
+ position,
240
+ shadow,
241
+ ...rest
242
+ }) => {
243
+ const [currentValue, setCurrentValue] = useUncontrolled({
244
+ value: value ? dayjs(value) : void 0,
245
+ defaultValue: defaultValue ? dayjs(defaultValue) : dayjs(),
246
+ onChange: (v) => {
247
+ onChange == null ? void 0 : onChange(v.toDate());
248
+ }
249
+ });
250
+ const [currentValueChangedBy, setCurrentValueChangedBy] = useState(null);
251
+ const startDate = useMemo(() => dayjs(minTime, "HH:mm:ss"), [minTime]);
252
+ const endDate = useMemo(() => dayjs(maxTime, "HH:mm:ss"), [maxTime]);
253
+ const updateCurrentValue = useMemoizedFn((val, from) => {
254
+ let next = val;
255
+ if (!next.isValid()) {
256
+ return;
257
+ }
258
+ if ((currentValue == null ? void 0 : currentValue.unix()) === next.unix()) {
259
+ return;
260
+ }
261
+ if (startDate && next.isBefore(startDate)) {
262
+ next = dayjs(startDate);
263
+ } else if (endDate && next.isAfter(endDate)) {
264
+ next = dayjs(endDate);
265
+ }
266
+ setCurrentValue(next);
267
+ setCurrentValueChangedBy(from);
268
+ setTimeout(() => {
269
+ setCurrentValueChangedBy(null);
270
+ }, 20);
271
+ });
272
+ const timeInputChange = useMemoizedFn((e) => {
273
+ const originVal = e.currentTarget.value;
274
+ const v = dayjs(originVal, "HH:mm:ss").toDate();
275
+ let next = currentValue;
276
+ next = next.hour(v.getHours()).minute(v.getMinutes()).second(v.getSeconds());
277
+ updateCurrentValue(next, "timeInput");
278
+ });
279
+ const timeScrollPickerChange = useMemoizedFn((v) => {
280
+ const [h, m, s] = v;
281
+ let next = currentValue;
282
+ next = next.hour(h).minute(m).second(s);
283
+ updateCurrentValue(next, "timeScroller");
284
+ });
285
+ return /* @__PURE__ */ jsxs(Popover, { withinPortal, withArrow, position, shadow, children: [
286
+ /* @__PURE__ */ jsx(Popover.Target, { children: /* @__PURE__ */ jsx(
287
+ TimeInput,
288
+ {
289
+ ...rest,
290
+ disabled: disable,
291
+ withSeconds: true,
292
+ value: currentValue.format("HH:mm:ss"),
293
+ onChange: timeInputChange,
294
+ size,
295
+ sx,
296
+ rightSection: /* @__PURE__ */ jsx(IconClock, { size: 16, c: "carbon.7" })
297
+ }
298
+ ) }),
299
+ /* @__PURE__ */ jsx(Popover.Dropdown, { children: /* @__PURE__ */ jsxs(
300
+ Box,
301
+ {
302
+ pos: "relative",
303
+ fz: 14,
304
+ fw: 400,
305
+ h: 224,
306
+ sx: (theme) => ({ color: theme.colors.carbon[8], overflow: "hidden", zIndex: 9999 }),
307
+ children: [
308
+ /* @__PURE__ */ jsxs(Flex, { mah: "100%", gap: 8, children: [
309
+ /* @__PURE__ */ jsx(
310
+ Box,
311
+ {
312
+ bg: "carbon.3",
313
+ pos: "absolute",
314
+ top: 0,
315
+ left: 0,
316
+ h: 32,
317
+ w: 32,
318
+ sx: (theme) => ({ zIndex: -1, borderRadius: theme.defaultRadius, pointerEvents: "none" })
319
+ }
320
+ ),
321
+ /* @__PURE__ */ jsx(
322
+ Box,
323
+ {
324
+ bg: "carbon.3",
325
+ pos: "absolute",
326
+ top: 0,
327
+ left: 40,
328
+ h: 32,
329
+ w: 32,
330
+ sx: (theme) => ({ zIndex: -1, borderRadius: theme.defaultRadius, pointerEvents: "none" })
331
+ }
332
+ ),
333
+ /* @__PURE__ */ jsx(
334
+ Box,
335
+ {
336
+ bg: "carbon.3",
337
+ pos: "absolute",
338
+ top: 0,
339
+ left: 80,
340
+ h: 32,
341
+ w: 32,
342
+ sx: (theme) => ({ zIndex: -1, borderRadius: theme.defaultRadius, pointerEvents: "none" })
343
+ }
344
+ )
345
+ ] }),
346
+ /* @__PURE__ */ jsx(
347
+ TimeScollerPicker,
348
+ {
349
+ currentValue,
350
+ currentValueChangedBy,
351
+ onChange: timeScrollPickerChange,
352
+ start: startDate.toDate(),
353
+ end: endDate.toDate()
354
+ }
355
+ )
356
+ ]
357
+ }
358
+ ) })
359
+ ] });
360
+ };
228
361
  export {
229
- DateTimePicker
362
+ DateTimePicker,
363
+ TimePicker
230
364
  };
@@ -52,6 +52,7 @@ exports.PropertyCard = index$9.PropertyCard;
52
52
  exports.PageShell = index$a.PageShell;
53
53
  exports.TimeRangePicker = index$b.TimeRangePicker;
54
54
  exports.DateTimePicker = index$c.DateTimePicker;
55
+ exports.TimePicker = index$c.TimePicker;
55
56
  exports.ProMultiSelect = index$d.ProMultiSelect;
56
57
  exports.validPhoneNumber = helper.validPhoneNumber;
57
58
  exports.MRT_AggregationFns = index_esm.MRT_AggregationFns;
@@ -9,7 +9,7 @@ import { TransferTree } from "./TransferTree/index.mjs";
9
9
  import { PropertyCard } from "./PropertyCard/index.mjs";
10
10
  import { PageShell } from "./PageShell/index.mjs";
11
11
  import { TimeRangePicker } from "./TimeRangePicker/index.mjs";
12
- import { DateTimePicker } from "./DateTimePicker/index.mjs";
12
+ import { DateTimePicker, TimePicker } from "./DateTimePicker/index.mjs";
13
13
  import { ProMultiSelect } from "./ProMultiSelect/index.mjs";
14
14
  import { validPhoneNumber } from "./PhoneInput/helper.mjs";
15
15
  import { MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextInput, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_FilterCheckbox, MRT_FilterFns, MRT_FilterOptionMenu, MRT_FilterRangeFields, MRT_FilterRangeSlider, MRT_FilterTextInput, MRT_GlobalFilterTextInput, MRT_GrabHandleButton, MRT_ProgressBar, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectCheckbox, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellFilterContainer, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleFullScreenButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MantineReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, createMRTColumnHelper, createRow, dataVariable, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getIsRankingRows, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getMRT_SelectAllHandler, getPrimaryColor, getPrimaryShade, getTrailingDisplayColumnIds, localizedFilterOption, mrtFilterOptions, parseCSSVarId, prepareColumns, rankGlobalFuzzy, reorderColumn, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMantineReactTable } from "../node_modules/.pnpm/mantine-react-table@2.0.0-beta.7_@mantine_core@7.15.2_patch_hash_jclkxeaefn6uz54h34k3r3yjsq_@_6pmziqsvipqgt5gv2plqw5hct4/node_modules/mantine-react-table/dist/index.esm.mjs";
@@ -139,6 +139,7 @@ export {
139
139
  ProTable,
140
140
  PropertyCard,
141
141
  SearchArea,
142
+ TimePicker,
142
143
  TimeRangePicker,
143
144
  TransferTree,
144
145
  Tree,
@@ -741,23 +741,30 @@ const theme = createTheme.createTheme({
741
741
  },
742
742
  Card: {
743
743
  defaultProps: {
744
- shadow: "xs",
744
+ shadow: "none",
745
745
  withBorder: true
746
746
  },
747
747
  styles: (theme2) => {
748
748
  return {
749
749
  root: {
750
- backgroundColor: theme2.colors.carbon[0]
750
+ borderColor: theme2.colors.carbon[4]
751
+ },
752
+ section: {
753
+ borderColor: theme2.colors.carbon[4]
751
754
  }
752
755
  };
753
756
  }
754
757
  },
755
758
  Paper: {
759
+ defaultProps: {
760
+ shadow: "none",
761
+ withBorder: false
762
+ },
756
763
  styles: (theme2, props) => {
757
764
  return {
758
765
  root: {
759
766
  backgroundColor: themeColor(theme2, "carbon", 0),
760
- borderColor: props.withBorder ? themeColor(theme2, "carbon", 3) : "transparent"
767
+ borderColor: props.withBorder ? themeColor(theme2, "carbon", 4) : "transparent"
761
768
  }
762
769
  };
763
770
  }
@@ -1171,6 +1178,18 @@ const theme = createTheme.createTheme({
1171
1178
  }
1172
1179
  };
1173
1180
  }
1181
+ },
1182
+ HoverCard: {
1183
+ defaultProps: {
1184
+ withArrow: true,
1185
+ shadow: "md"
1186
+ }
1187
+ },
1188
+ Popover: {
1189
+ defaultProps: {
1190
+ withArrow: true,
1191
+ shadow: "md"
1192
+ }
1174
1193
  }
1175
1194
  }
1176
1195
  });
@@ -739,23 +739,30 @@ const theme = createTheme({
739
739
  },
740
740
  Card: {
741
741
  defaultProps: {
742
- shadow: "xs",
742
+ shadow: "none",
743
743
  withBorder: true
744
744
  },
745
745
  styles: (theme2) => {
746
746
  return {
747
747
  root: {
748
- backgroundColor: theme2.colors.carbon[0]
748
+ borderColor: theme2.colors.carbon[4]
749
+ },
750
+ section: {
751
+ borderColor: theme2.colors.carbon[4]
749
752
  }
750
753
  };
751
754
  }
752
755
  },
753
756
  Paper: {
757
+ defaultProps: {
758
+ shadow: "none",
759
+ withBorder: false
760
+ },
754
761
  styles: (theme2, props) => {
755
762
  return {
756
763
  root: {
757
764
  backgroundColor: themeColor(theme2, "carbon", 0),
758
- borderColor: props.withBorder ? themeColor(theme2, "carbon", 3) : "transparent"
765
+ borderColor: props.withBorder ? themeColor(theme2, "carbon", 4) : "transparent"
759
766
  }
760
767
  };
761
768
  }
@@ -1169,6 +1176,18 @@ const theme = createTheme({
1169
1176
  }
1170
1177
  };
1171
1178
  }
1179
+ },
1180
+ HoverCard: {
1181
+ defaultProps: {
1182
+ withArrow: true,
1183
+ shadow: "md"
1184
+ }
1185
+ },
1186
+ Popover: {
1187
+ defaultProps: {
1188
+ withArrow: true,
1189
+ shadow: "md"
1190
+ }
1172
1191
  }
1173
1192
  }
1174
1193
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidbcloud/uikit",
3
- "version": "2.2.10",
3
+ "version": "2.3.0",
4
4
  "description": "tidbcloud uikit",
5
5
  "type": "module",
6
6
  "main": "dist/primitive/index.cjs",