@tidbcloud/uikit 2.2.11 → 2.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @tidbcloud/uikit
2
2
 
3
+ ## 2.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - fix(TimePicker): change value types to string and update format handling ([#529](https://github.com/tidbcloud/tidbcloud-uikit/pull/529))
8
+
9
+ ## 2.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - feat(TimePicker): add TimePicker componnet ([#527](https://github.com/tidbcloud/tidbcloud-uikit/pull/527))
14
+ - feat(theme): add default props for HoverCard/Popover ([#526](https://github.com/tidbcloud/tidbcloud-uikit/pull/526))
15
+ - chore: update snapshot release workflow to push all tags ([#524](https://github.com/tidbcloud/tidbcloud-uikit/pull/524))
16
+ - docs: enhance snapshot release section with GitHub Actions workflow details ([#523](https://github.com/tidbcloud/tidbcloud-uikit/pull/523))
17
+ - chore: add npm setup step for publishing snapshots ([#522](https://github.com/tidbcloud/tidbcloud-uikit/pull/522))
18
+
3
19
  ## 2.2.11
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, "HH:mm:ss") : void 0,
247
+ defaultValue: defaultValue ? dayjs.dayjs(defaultValue, "HH:mm:ss") : dayjs.dayjs(),
248
+ onChange: (v) => {
249
+ onChange == null ? void 0 : onChange(v.format("HH:mm:ss"));
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,14 @@ 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?: string;
19
+ /**
20
+ * with format of `HH:mm:ss`
21
+ */
22
+ value?: string;
23
+ onChange?: (val: string) => void;
24
+ disable?: boolean;
25
+ size?: MantineSize;
26
+ }
27
+ 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,14 @@ 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?: string;
19
+ /**
20
+ * with format of `HH:mm:ss`
21
+ */
22
+ value?: string;
23
+ onChange?: (val: string) => void;
24
+ disable?: boolean;
25
+ size?: MantineSize;
26
+ }
27
+ 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, "HH:mm:ss") : void 0,
245
+ defaultValue: defaultValue ? dayjs(defaultValue, "HH:mm:ss") : dayjs(),
246
+ onChange: (v) => {
247
+ onChange == null ? void 0 : onChange(v.format("HH:mm:ss"));
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,
@@ -1178,6 +1178,18 @@ const theme = createTheme.createTheme({
1178
1178
  }
1179
1179
  };
1180
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
+ }
1181
1193
  }
1182
1194
  }
1183
1195
  });
@@ -1176,6 +1176,18 @@ const theme = createTheme({
1176
1176
  }
1177
1177
  };
1178
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
+ }
1179
1191
  }
1180
1192
  }
1181
1193
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidbcloud/uikit",
3
- "version": "2.2.11",
3
+ "version": "2.3.1",
4
4
  "description": "tidbcloud uikit",
5
5
  "type": "module",
6
6
  "main": "dist/primitive/index.cjs",