@clickhouse/click-ui 0.0.129 → 0.0.130

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.
@@ -32359,9 +32359,11 @@ const Pagination = ({
32359
32359
  onPrevPageClick,
32360
32360
  onPageNumberFocus,
32361
32361
  onPageNumberBlur,
32362
+ disableNextButton,
32362
32363
  ...props
32363
32364
  }) => {
32364
32365
  const hasRowCount = ["number", "string"].includes(typeof rowCount);
32366
+ const inputRef = useRef(null);
32365
32367
  const formatNumber = (value) => {
32366
32368
  return new Intl.NumberFormat("en").format(value);
32367
32369
  };
@@ -32373,38 +32375,51 @@ const Pagination = ({
32373
32375
  }
32374
32376
  };
32375
32377
  const onChange = (value) => {
32376
- onChangeProp(Number(value));
32378
+ var _a;
32379
+ const valueToNumber = Number(value);
32380
+ if (valueToNumber < 1 || ((_a = inputRef.current) == null ? void 0 : _a.disabled)) {
32381
+ return;
32382
+ }
32383
+ onChangeProp(valueToNumber);
32377
32384
  };
32378
32385
  const onPageSizeChange = (value) => {
32379
32386
  if (typeof onPageSizeChangeProp === "function") {
32380
32387
  onPageSizeChangeProp(Number(value));
32381
32388
  }
32382
32389
  };
32390
+ const leftButtonDisabled = currentPage <= 1;
32391
+ const rightButtonDisabled = !!totalPages && currentPage === totalPages || disableNextButton;
32383
32392
  const onPrevClick = useCallback((e) => {
32393
+ if (leftButtonDisabled) {
32394
+ return;
32395
+ }
32384
32396
  onChangeProp(currentPage - 1);
32385
32397
  if (typeof onPrevPageClick === "function") {
32386
32398
  onPrevPageClick(e);
32387
32399
  }
32388
- }, [currentPage, onChangeProp, onPrevPageClick]);
32400
+ }, [currentPage, leftButtonDisabled, onChangeProp, onPrevPageClick]);
32389
32401
  const onNextClick = useCallback((e) => {
32402
+ if (rightButtonDisabled) {
32403
+ return;
32404
+ }
32390
32405
  onChangeProp(currentPage + 1);
32391
32406
  if (typeof onNextPageClick === "function") {
32392
32407
  onNextPageClick(e);
32393
32408
  }
32394
- }, [currentPage, onChangeProp, onNextPageClick]);
32409
+ }, [currentPage, onChangeProp, onNextPageClick, rightButtonDisabled]);
32395
32410
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Container, { gap, justifyContent: justifyContent ?? (rowCount || maxRowsPerPageList.length > 0 ? "space-between" : "center"), fillWidth, ...props, children: [
32396
32411
  hasRowCount && /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { component: "div", color: "muted", size: "sm", children: [
32397
32412
  typeof rowCount === "number" ? formatNumber(rowCount) : rowCount,
32398
32413
  " rows"
32399
32414
  ] }),
32400
32415
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Container, { gap: "xxs", fillWidth: false, children: [
32401
- /* @__PURE__ */ jsxRuntimeExports.jsx(IconButton$1, { icon: "chevron-left", type: "ghost", disabled: currentPage === 1, onClick: onPrevClick, "data-testid": "prev-btn" }),
32402
- /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { maxWidth: "50px", fillWidth: false, children: /* @__PURE__ */ jsxRuntimeExports.jsx(NumberField, { onChange, value: currentPage, loading: false, onKeyDown, min: 1, max: totalPages, onFocus: onPageNumberFocus, hideControls: true, onBlur: onPageNumberBlur }) }),
32416
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IconButton$1, { icon: "chevron-left", type: "ghost", disabled: leftButtonDisabled, onClick: onPrevClick, "data-testid": "prev-btn" }),
32417
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { maxWidth: "50px", fillWidth: false, children: /* @__PURE__ */ jsxRuntimeExports.jsx(NumberField, { ref: inputRef, onChange, value: currentPage, loading: false, onKeyDown, min: 1, max: totalPages, onFocus: onPageNumberFocus, hideControls: true, onBlur: onPageNumberBlur, disabled: leftButtonDisabled && rightButtonDisabled }) }),
32403
32418
  !!totalPages && /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { component: "div", color: "muted", size: "sm", children: [
32404
32419
  "of ",
32405
32420
  formatNumber(totalPages)
32406
32421
  ] }),
32407
- /* @__PURE__ */ jsxRuntimeExports.jsx(IconButton$1, { icon: "chevron-right", type: "ghost", disabled: !!totalPages && currentPage === totalPages, onClick: onNextClick, "data-testid": "next-btn" })
32422
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IconButton$1, { icon: "chevron-right", type: "ghost", disabled: rightButtonDisabled, onClick: onNextClick, "data-testid": "next-btn" })
32408
32423
  ] }),
32409
32424
  maxRowsPerPageList.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(CustomSelect, { as: Select, onSelect: onPageSizeChange, value: pageSize.toString(), children: [
32410
32425
  /* @__PURE__ */ jsxRuntimeExports.jsx(Select.Item, { value: "-1", children: "All rows" }),
@@ -38761,13 +38776,16 @@ Tooltip.Trigger = TooltipTrigger;
38761
38776
  const RadixTooltipContent = styled($a093c7e1ec25a057$export$7c6e2c02157bb7d2).withConfig({
38762
38777
  componentId: "sc-ymqkp1-0"
38763
38778
  })(["display:flex;align-items:flex-start;", ""], ({
38764
- theme: theme2
38779
+ theme: theme2,
38780
+ $maxWidth
38765
38781
  }) => `
38766
38782
  padding: ${theme2.click.tooltip.space.y} ${theme2.click.tooltip.space.x};
38767
38783
  color: ${theme2.click.tooltip.color.label.default};
38768
38784
  background: ${theme2.click.tooltip.color.background.default};
38769
38785
  border-radius: ${theme2.click.tooltip.radii.all};
38770
38786
  font: ${theme2.click.tooltip.typography.label.default};
38787
+ white-space: pre-wrap;
38788
+ ${$maxWidth && `max-width: ${$maxWidth}`};
38771
38789
  `);
38772
38790
  const Arrow = styled.svg.withConfig({
38773
38791
  componentId: "sc-ymqkp1-1"
@@ -38780,9 +38798,10 @@ const TooltipContent = ({
38780
38798
  showArrow,
38781
38799
  children,
38782
38800
  sideOffset = 6,
38801
+ maxWidth,
38783
38802
  ...props
38784
38803
  }) => {
38785
- return /* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$602eac185826482c, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(RadixTooltipContent, { sideOffset, ...props, children: [
38804
+ return /* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$602eac185826482c, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(RadixTooltipContent, { sideOffset, $maxWidth: maxWidth, ...props, children: [
38786
38805
  showArrow && /* @__PURE__ */ jsxRuntimeExports.jsx(Arrow, { as: $a093c7e1ec25a057$export$21b07c8f274aebd5, width: 20, height: 8 }),
38787
38806
  children
38788
38807
  ] }) });
@@ -32376,9 +32376,11 @@ var __publicField = (obj, key, value) => {
32376
32376
  onPrevPageClick,
32377
32377
  onPageNumberFocus,
32378
32378
  onPageNumberBlur,
32379
+ disableNextButton,
32379
32380
  ...props
32380
32381
  }) => {
32381
32382
  const hasRowCount = ["number", "string"].includes(typeof rowCount);
32383
+ const inputRef = React.useRef(null);
32382
32384
  const formatNumber = (value) => {
32383
32385
  return new Intl.NumberFormat("en").format(value);
32384
32386
  };
@@ -32390,38 +32392,51 @@ var __publicField = (obj, key, value) => {
32390
32392
  }
32391
32393
  };
32392
32394
  const onChange = (value) => {
32393
- onChangeProp(Number(value));
32395
+ var _a;
32396
+ const valueToNumber = Number(value);
32397
+ if (valueToNumber < 1 || ((_a = inputRef.current) == null ? void 0 : _a.disabled)) {
32398
+ return;
32399
+ }
32400
+ onChangeProp(valueToNumber);
32394
32401
  };
32395
32402
  const onPageSizeChange = (value) => {
32396
32403
  if (typeof onPageSizeChangeProp === "function") {
32397
32404
  onPageSizeChangeProp(Number(value));
32398
32405
  }
32399
32406
  };
32407
+ const leftButtonDisabled = currentPage <= 1;
32408
+ const rightButtonDisabled = !!totalPages && currentPage === totalPages || disableNextButton;
32400
32409
  const onPrevClick = React.useCallback((e) => {
32410
+ if (leftButtonDisabled) {
32411
+ return;
32412
+ }
32401
32413
  onChangeProp(currentPage - 1);
32402
32414
  if (typeof onPrevPageClick === "function") {
32403
32415
  onPrevPageClick(e);
32404
32416
  }
32405
- }, [currentPage, onChangeProp, onPrevPageClick]);
32417
+ }, [currentPage, leftButtonDisabled, onChangeProp, onPrevPageClick]);
32406
32418
  const onNextClick = React.useCallback((e) => {
32419
+ if (rightButtonDisabled) {
32420
+ return;
32421
+ }
32407
32422
  onChangeProp(currentPage + 1);
32408
32423
  if (typeof onNextPageClick === "function") {
32409
32424
  onNextPageClick(e);
32410
32425
  }
32411
- }, [currentPage, onChangeProp, onNextPageClick]);
32426
+ }, [currentPage, onChangeProp, onNextPageClick, rightButtonDisabled]);
32412
32427
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Container, { gap, justifyContent: justifyContent ?? (rowCount || maxRowsPerPageList.length > 0 ? "space-between" : "center"), fillWidth, ...props, children: [
32413
32428
  hasRowCount && /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { component: "div", color: "muted", size: "sm", children: [
32414
32429
  typeof rowCount === "number" ? formatNumber(rowCount) : rowCount,
32415
32430
  " rows"
32416
32431
  ] }),
32417
32432
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Container, { gap: "xxs", fillWidth: false, children: [
32418
- /* @__PURE__ */ jsxRuntimeExports.jsx(IconButton$1, { icon: "chevron-left", type: "ghost", disabled: currentPage === 1, onClick: onPrevClick, "data-testid": "prev-btn" }),
32419
- /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { maxWidth: "50px", fillWidth: false, children: /* @__PURE__ */ jsxRuntimeExports.jsx(NumberField, { onChange, value: currentPage, loading: false, onKeyDown, min: 1, max: totalPages, onFocus: onPageNumberFocus, hideControls: true, onBlur: onPageNumberBlur }) }),
32433
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IconButton$1, { icon: "chevron-left", type: "ghost", disabled: leftButtonDisabled, onClick: onPrevClick, "data-testid": "prev-btn" }),
32434
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Container, { maxWidth: "50px", fillWidth: false, children: /* @__PURE__ */ jsxRuntimeExports.jsx(NumberField, { ref: inputRef, onChange, value: currentPage, loading: false, onKeyDown, min: 1, max: totalPages, onFocus: onPageNumberFocus, hideControls: true, onBlur: onPageNumberBlur, disabled: leftButtonDisabled && rightButtonDisabled }) }),
32420
32435
  !!totalPages && /* @__PURE__ */ jsxRuntimeExports.jsxs(Text, { component: "div", color: "muted", size: "sm", children: [
32421
32436
  "of ",
32422
32437
  formatNumber(totalPages)
32423
32438
  ] }),
32424
- /* @__PURE__ */ jsxRuntimeExports.jsx(IconButton$1, { icon: "chevron-right", type: "ghost", disabled: !!totalPages && currentPage === totalPages, onClick: onNextClick, "data-testid": "next-btn" })
32439
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IconButton$1, { icon: "chevron-right", type: "ghost", disabled: rightButtonDisabled, onClick: onNextClick, "data-testid": "next-btn" })
32425
32440
  ] }),
32426
32441
  maxRowsPerPageList.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs(CustomSelect, { as: Select, onSelect: onPageSizeChange, value: pageSize.toString(), children: [
32427
32442
  /* @__PURE__ */ jsxRuntimeExports.jsx(Select.Item, { value: "-1", children: "All rows" }),
@@ -38778,13 +38793,16 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
38778
38793
  const RadixTooltipContent = styled($a093c7e1ec25a057$export$7c6e2c02157bb7d2).withConfig({
38779
38794
  componentId: "sc-ymqkp1-0"
38780
38795
  })(["display:flex;align-items:flex-start;", ""], ({
38781
- theme: theme2
38796
+ theme: theme2,
38797
+ $maxWidth
38782
38798
  }) => `
38783
38799
  padding: ${theme2.click.tooltip.space.y} ${theme2.click.tooltip.space.x};
38784
38800
  color: ${theme2.click.tooltip.color.label.default};
38785
38801
  background: ${theme2.click.tooltip.color.background.default};
38786
38802
  border-radius: ${theme2.click.tooltip.radii.all};
38787
38803
  font: ${theme2.click.tooltip.typography.label.default};
38804
+ white-space: pre-wrap;
38805
+ ${$maxWidth && `max-width: ${$maxWidth}`};
38788
38806
  `);
38789
38807
  const Arrow = styled.svg.withConfig({
38790
38808
  componentId: "sc-ymqkp1-1"
@@ -38797,9 +38815,10 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
38797
38815
  showArrow,
38798
38816
  children,
38799
38817
  sideOffset = 6,
38818
+ maxWidth,
38800
38819
  ...props
38801
38820
  }) => {
38802
- return /* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$602eac185826482c, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(RadixTooltipContent, { sideOffset, ...props, children: [
38821
+ return /* @__PURE__ */ jsxRuntimeExports.jsx($a093c7e1ec25a057$export$602eac185826482c, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(RadixTooltipContent, { sideOffset, $maxWidth: maxWidth, ...props, children: [
38803
38822
  showArrow && /* @__PURE__ */ jsxRuntimeExports.jsx(Arrow, { as: $a093c7e1ec25a057$export$21b07c8f274aebd5, width: 20, height: 8 }),
38804
38823
  children
38805
38824
  ] }) });
@@ -12,5 +12,6 @@ export interface PaginationProps extends Omit<ContainerProps<"div">, "children"
12
12
  onPrevPageClick?: MouseEventHandler<HTMLButtonElement>;
13
13
  onPageNumberFocus?: FocusEventHandler<HTMLInputElement>;
14
14
  onPageNumberBlur?: FocusEventHandler<HTMLInputElement>;
15
+ disableNextButton?: boolean;
15
16
  }
16
- export declare const Pagination: ({ totalPages, currentPage, maxRowsPerPageList, rowCount, onChange: onChangeProp, onPageSizeChange: onPageSizeChangeProp, pageSize, fillWidth, gap, justifyContent, onNextPageClick, onPrevPageClick, onPageNumberFocus, onPageNumberBlur, ...props }: PaginationProps) => ReactElement;
17
+ export declare const Pagination: ({ totalPages, currentPage, maxRowsPerPageList, rowCount, onChange: onChangeProp, onPageSizeChange: onPageSizeChangeProp, pageSize, fillWidth, gap, justifyContent, onNextPageClick, onPrevPageClick, onPageNumberFocus, onPageNumberBlur, disableNextButton, ...props }: PaginationProps) => ReactElement;
@@ -10,11 +10,12 @@ export declare const Tooltip: {
10
10
  displayName: string;
11
11
  };
12
12
  Content: {
13
- ({ showArrow, children, sideOffset, ...props }: TooltipContentProps): import("react/jsx-runtime").JSX.Element;
13
+ ({ showArrow, children, sideOffset, maxWidth, ...props }: TooltipContentProps): import("react/jsx-runtime").JSX.Element;
14
14
  displayName: string;
15
15
  };
16
16
  };
17
17
  interface TooltipContentProps extends RadixTooltip.TooltipContentProps {
18
18
  showArrow?: boolean;
19
+ maxWidth?: string;
19
20
  }
20
21
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clickhouse/click-ui",
3
- "version": "0.0.129",
3
+ "version": "0.0.130",
4
4
  "description": "Official ClickHouse design system react library",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",