@clickhouse/click-ui 0.0.131 → 0.0.133

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.
@@ -10051,7 +10051,7 @@ const LinkArrow = styled(ArrowContainer).withConfig({
10051
10051
  })([""]);
10052
10052
  const Wrapper$a = styled.div.withConfig({
10053
10053
  componentId: "sc-1drx130-7"
10054
- })(["background-color:", ";border-radius:", ";border:", ";max-width:420px;min-width:320px;display:flex;flex-direction:column;padding:", ";gap:", ";box-shadow:", ";&:hover,:focus{background-color:", ";cursor:pointer;", ",", "{color:", ";}}&[disabled],&[disabled]:hover,&[disabled]:active{background-color:", ";color:", ";border:1px solid ", ";cursor:not-allowed;", ",", "{color:", ";}}"], ({
10054
+ })(["background-color:", ";border-radius:", ";border:", ";max-width:420px;min-width:320px;display:flex;flex-direction:column;padding:", ";gap:", ";box-shadow:", ";&:hover,:focus{background-color:", ";cursor:pointer;", ",", "{color:", ";}}", ""], ({
10055
10055
  theme: theme2
10056
10056
  }) => theme2.click.card.secondary.color.background.default, ({
10057
10057
  theme: theme2
@@ -10069,14 +10069,24 @@ const Wrapper$a = styled.div.withConfig({
10069
10069
  }) => theme2.click.card.secondary.color.background.hover, LinkText, LinkArrow, ({
10070
10070
  theme: theme2
10071
10071
  }) => theme2.click.card.secondary.color.link.hover, ({
10072
+ $disabled,
10072
10073
  theme: theme2
10073
- }) => theme2.click.card.secondary.color.background.disabled, ({
10074
- theme: theme2
10075
- }) => theme2.click.card.secondary.color.title.disabled, ({
10076
- theme: theme2
10077
- }) => theme2.click.card.secondary.color.stroke.disabled, LinkText, LinkArrow, ({
10078
- theme: theme2
10079
- }) => theme2.click.card.secondary.color.link.disabled);
10074
+ }) => $disabled && `
10075
+ &,
10076
+ &:hover,
10077
+ &:focus,
10078
+ &:active {
10079
+ background-color: ${theme2.click.card.secondary.color.background.disabled};
10080
+ color: ${theme2.click.card.secondary.color.title.disabled};
10081
+ border: 1px solid ${theme2.click.card.secondary.color.stroke.disabled};
10082
+ cursor: not-allowed;
10083
+
10084
+ ${LinkText},
10085
+ ${LinkArrow} {
10086
+ color: ${theme2.click.card.secondary.color.link.disabled};
10087
+ }
10088
+ }
10089
+ `);
10080
10090
  const CardSecondary = ({
10081
10091
  title,
10082
10092
  icon,
@@ -10106,7 +10116,7 @@ const CardSecondary = ({
10106
10116
  };
10107
10117
  const Wrapper$9 = styled.div.withConfig({
10108
10118
  componentId: "sc-2dguvi-0"
10109
- })(["background-color:", ";border-radius:", ";border:", ";display:flex;width:100%;max-width:100%;text-align:", ";flex-direction:column;padding:", ";gap:", ";box-shadow:", ";&:hover,&:focus{background-color:", ";cursor:pointer;button{background-color:", ";border-color:", ";&:active{background-color:", ";border-color:", ";}}}&:active{border-color:", ";}&[disabled],&[disabled]:hover,&[disabled]:active{background-color:", ";color:", ";border:1px solid ", ";cursor:not-allowed;button{background-color:", ";border-color:", ";&:active{background-color:", ";border-color:", ";}}}", ""], ({
10119
+ })(["background-color:", ";border-radius:", ";border:", ";display:flex;width:100%;max-width:100%;text-align:", ";flex-direction:column;padding:", ";gap:", ";box-shadow:", ";&:hover,&:focus{background-color:", ";cursor:pointer;button{background-color:", ";border-color:", ";&:active{background-color:", ";border-color:", ";}}}&:active{border-color:", ";}", " ", ""], ({
10110
10120
  theme: theme2
10111
10121
  }) => theme2.click.card.primary.color.background.default, ({
10112
10122
  theme: theme2
@@ -10136,20 +10146,28 @@ const Wrapper$9 = styled.div.withConfig({
10136
10146
  }) => theme2.click.button.basic.color.primary.stroke.active, ({
10137
10147
  theme: theme2
10138
10148
  }) => theme2.click.button.basic.color.primary.stroke.active, ({
10149
+ $disabled,
10139
10150
  theme: theme2
10140
- }) => theme2.click.card.primary.color.background.disabled, ({
10141
- theme: theme2
10142
- }) => theme2.click.card.primary.color.title.disabled, ({
10143
- theme: theme2
10144
- }) => theme2.click.card.primary.color.stroke.disabled, ({
10145
- theme: theme2
10146
- }) => theme2.click.button.basic.color.primary.background.disabled, ({
10147
- theme: theme2
10148
- }) => theme2.click.button.basic.color.primary.stroke.disabled, ({
10149
- theme: theme2
10150
- }) => theme2.click.button.basic.color.primary.background.disabled, ({
10151
- theme: theme2
10152
- }) => theme2.click.button.basic.color.primary.stroke.disabled, ({
10151
+ }) => $disabled && `
10152
+ &,
10153
+ &:hover,
10154
+ &:focus,
10155
+ &:active {
10156
+ background-color: ${theme2.click.card.primary.color.background.disabled};
10157
+ color: ${theme2.click.card.primary.color.title.disabled};
10158
+ border: 1px solid ${theme2.click.card.primary.color.stroke.disabled};
10159
+ cursor: not-allowed;
10160
+
10161
+ button {
10162
+ background-color: ${theme2.click.button.basic.color.primary.background.disabled};
10163
+ border-color: ${theme2.click.button.basic.color.primary.stroke.disabled};
10164
+ &:active {
10165
+ background-color: ${theme2.click.button.basic.color.primary.background.disabled};
10166
+ border-color: ${theme2.click.button.basic.color.primary.stroke.disabled};
10167
+ }
10168
+ }
10169
+ }
10170
+ `, ({
10153
10171
  $isSelected,
10154
10172
  theme: theme2
10155
10173
  }) => $isSelected ? `border-color: ${theme2.click.button.basic.color.primary.stroke.active};` : "");
@@ -31372,6 +31390,7 @@ const Grid = forwardRef(({
31372
31390
  onMouseMove: onMouseMoveProp,
31373
31391
  showBorder = false,
31374
31392
  onCopy: onCopyProp,
31393
+ onCopyCallback,
31375
31394
  onContextMenu: onContextMenuProp,
31376
31395
  forwardedGridRef,
31377
31396
  ...props
@@ -31383,8 +31402,7 @@ const Grid = forwardRef(({
31383
31402
  const [selection, setSelection] = useState(selectionProp ?? {
31384
31403
  type: "empty"
31385
31404
  });
31386
- const onCopy = useCallback(async () => {
31387
- let isCopied = false;
31405
+ const defaultOnCopy = useCallback(async () => {
31388
31406
  try {
31389
31407
  await copyGridElements({
31390
31408
  cell,
@@ -31394,7 +31412,9 @@ const Grid = forwardRef(({
31394
31412
  columnCount,
31395
31413
  outerRef
31396
31414
  });
31397
- isCopied = true;
31415
+ if (onCopyCallback) {
31416
+ onCopyCallback(true);
31417
+ }
31398
31418
  if (showToast) {
31399
31419
  createToast({
31400
31420
  title: "Copied successfully",
@@ -31404,6 +31424,9 @@ const Grid = forwardRef(({
31404
31424
  }
31405
31425
  } catch (e) {
31406
31426
  console.error(e);
31427
+ if (onCopyCallback) {
31428
+ onCopyCallback(false);
31429
+ }
31407
31430
  if (showToast) {
31408
31431
  createToast({
31409
31432
  title: "Failed to copy",
@@ -31411,11 +31434,17 @@ const Grid = forwardRef(({
31411
31434
  type: "danger"
31412
31435
  });
31413
31436
  }
31414
- if (typeof onCopyProp === "function") {
31415
- onCopyProp(isCopied);
31416
- }
31417
31437
  }
31418
- }, [cell, columnCount, focus, focusProp, onCopyProp, rowCount, selection, showToast]);
31438
+ }, [cell, columnCount, focus, focusProp, rowCount, selection, showToast, onCopyCallback]);
31439
+ const customOnCopy = useMemo(() => {
31440
+ const result = async () => {
31441
+ if (onCopyProp) {
31442
+ await onCopyProp(selection, focus);
31443
+ }
31444
+ };
31445
+ return result;
31446
+ }, [onCopyProp, selection, focus]);
31447
+ const onCopy = typeof onCopyProp === "function" ? customOnCopy : defaultOnCopy;
31419
31448
  const defaultMenuOptions = [{
31420
31449
  label: "Copy",
31421
31450
  onSelect: onCopy
@@ -36469,6 +36498,8 @@ const InternalSelect = ({
36469
36498
  sortable = false,
36470
36499
  placeholder = "Select an option",
36471
36500
  multiple,
36501
+ checkbox,
36502
+ selectLabel,
36472
36503
  showSearch = false,
36473
36504
  container,
36474
36505
  ...props
@@ -36635,7 +36666,10 @@ const InternalSelect = ({
36635
36666
  /* @__PURE__ */ jsxRuntimeExports.jsxs(FormElementContainer, { children: [
36636
36667
  /* @__PURE__ */ jsxRuntimeExports.jsxs(SelectPopoverRoot, { open: open2, onOpenChange, modal: true, children: [
36637
36668
  /* @__PURE__ */ jsxRuntimeExports.jsxs(StyledSelectTrigger, { id: id ?? defaultId, $error: !!error2, disabled, "data-testid": "select-trigger", children: [
36638
- isInitialized && /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, { children: selectedValues.length === 0 ? placeholder : multiple ? /* @__PURE__ */ jsxRuntimeExports.jsx(MultiSelectValue, { disabled: disabled ?? false, onSelect, selectedValues, sortable: !disabled && sortable, valueNode: valueNode.current, onChange }) : /* @__PURE__ */ jsxRuntimeExports.jsx(SingleSelectValue, { valueNode: valueNode.current.get(selectedValues[0]), value: selectedValues[0] }) }),
36669
+ isInitialized && /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, { children: selectedValues.length === 0 ? placeholder : multiple ? /* @__PURE__ */ jsxRuntimeExports.jsx(MultiSelectValue, { disabled: disabled ?? false, onSelect, selectedValues, sortable: !disabled && sortable, valueNode: valueNode.current, onChange }) : /* @__PURE__ */ jsxRuntimeExports.jsx(SingleSelectValue, { valueNode: checkbox && selectLabel ? {
36670
+ label: selectLabel,
36671
+ value: selectLabel
36672
+ } : valueNode.current.get(selectedValues[0]), value: selectedValues[0] }) }),
36639
36673
  /* @__PURE__ */ jsxRuntimeExports.jsx(SvgImage, { name: "sort", size: "sm" })
36640
36674
  ] }),
36641
36675
  form && /* @__PURE__ */ jsxRuntimeExports.jsx(HiddenSelectElement, { multiple, name: name2, form, value: selectedValues, onChange: () => null, children: list.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: item.value, disabled: item.disabled, children: item.value }, item.value)) }),
@@ -36657,8 +36691,16 @@ const InternalSelect = ({
36657
36691
  return /* @__PURE__ */ jsxRuntimeExports.jsx(SelectGroup, { ...groupProps, children: itemList.map(({
36658
36692
  label: label2,
36659
36693
  ...itemProps
36660
- }, itemIndex) => /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { ...itemProps, children: label2 }, `select-${id}-group-${index2}-item-${itemIndex}`)) }, `select-${id}-group-${index2}`);
36694
+ }, itemIndex) => {
36695
+ if (checkbox) {
36696
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(MultiSelectCheckboxItem, { ...itemProps, children: label2 }, `select-${id}-group-${index2}-item-${itemIndex}`);
36697
+ }
36698
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { ...itemProps, children: label2 }, `select-${id}-group-${index2}-item-${itemIndex}`);
36699
+ }) }, `select-${id}-group-${index2}`);
36661
36700
  } else {
36701
+ if (checkbox) {
36702
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(MultiSelectCheckboxItem, { ...props2 }, `select-${id}-item-${index2}`);
36703
+ }
36662
36704
  return /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { ...props2 }, `select-${id}-item-${index2}`);
36663
36705
  }
36664
36706
  }) : children }) }),
@@ -36744,6 +36786,70 @@ const SelectItem = forwardRef(({
36744
36786
  ] });
36745
36787
  });
36746
36788
  SelectItem.displayName = "Select.Item";
36789
+ const MultiSelectCheckboxItem = forwardRef(({
36790
+ disabled = false,
36791
+ children,
36792
+ icon,
36793
+ iconDir = "end",
36794
+ label,
36795
+ onMouseOver: onMouseOverProp,
36796
+ onSelect: onSelectProp,
36797
+ separator,
36798
+ value = "",
36799
+ ...props
36800
+ }, forwardedRef) => {
36801
+ const {
36802
+ highlighted,
36803
+ updateHighlighted,
36804
+ isHidden,
36805
+ selectedValues,
36806
+ onSelect
36807
+ } = useOption();
36808
+ const onSelectValue = () => {
36809
+ if (!disabled) {
36810
+ onSelect(value);
36811
+ if (typeof onSelectProp == "function") {
36812
+ onSelectProp(value);
36813
+ }
36814
+ }
36815
+ };
36816
+ const onMouseOver = (e) => {
36817
+ if (onMouseOverProp) {
36818
+ onMouseOverProp(e);
36819
+ }
36820
+ if (!disabled) {
36821
+ updateHighlighted(value);
36822
+ }
36823
+ };
36824
+ if (isHidden(value)) {
36825
+ return null;
36826
+ }
36827
+ const isChecked = selectedValues.includes(value);
36828
+ const onChange = () => {
36829
+ onSelect(value);
36830
+ };
36831
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
36832
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(GenericMenuItem, { ...props, "data-value": value, onClick: onSelectValue, onMouseOver, ref: forwardedRef, "data-disabled": disabled ? true : void 0, "data-highlighted": highlighted == value ? "true" : void 0, "data-testid": `multi-select-checkbox-${value}`, "cui-select-item": "", children: [
36833
+ icon && iconDir === "start" && /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, { checked: isChecked, "data-testid": "multi-select-checkbox", disabled, label: label ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: {
36834
+ display: "flex",
36835
+ justifyContent: "center"
36836
+ }, children: [
36837
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SvgImage, { name: icon, size: "sm" }),
36838
+ label
36839
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: {
36840
+ display: "flex",
36841
+ justifyContent: "center"
36842
+ }, children: [
36843
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SvgImage, { name: icon, size: "sm" }),
36844
+ children
36845
+ ] }), onClick: onChange }),
36846
+ icon && iconDir === "end" && /* @__PURE__ */ jsxRuntimeExports.jsx(IconWrapper$3, { icon, iconDir: "end", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, { checked: isChecked, "data-testid": "multi-select-checkbox", disabled, label: label ?? children, onClick: onChange }) }),
36847
+ !icon && /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, { checked: isChecked, "data-testid": "multi-select-checkbox", disabled, label: label ?? children, onClick: onChange })
36848
+ ] }),
36849
+ separator && /* @__PURE__ */ jsxRuntimeExports.jsx(Separator$1, { size: "sm" })
36850
+ ] });
36851
+ });
36852
+ MultiSelectCheckboxItem.displayName = "Select.Item";
36747
36853
  const Select = ({
36748
36854
  value: valueProp,
36749
36855
  defaultValue,
@@ -36836,6 +36942,52 @@ const MultiSelect = ({
36836
36942
  };
36837
36943
  MultiSelect.Group = SelectGroup;
36838
36944
  MultiSelect.Item = SelectItem;
36945
+ const CheckboxMultiSelect = ({
36946
+ value: valueProp,
36947
+ defaultValue,
36948
+ onSelect: onSelectProp,
36949
+ options,
36950
+ children,
36951
+ onOpenChange: onOpenChangeProp,
36952
+ selectLabel,
36953
+ ...props
36954
+ }) => {
36955
+ const [selectedValues, setSelectedValues] = useState(valueProp ?? defaultValue ?? []);
36956
+ const [open2, setOpen] = useState(false);
36957
+ const onOpenChange = useCallback((open22) => {
36958
+ setOpen(open22);
36959
+ if (typeof onOpenChangeProp === "function") {
36960
+ onOpenChangeProp(open22);
36961
+ }
36962
+ }, [onOpenChangeProp]);
36963
+ useEffect(() => {
36964
+ setSelectedValues(valueProp ?? []);
36965
+ }, [valueProp]);
36966
+ const onChange = useCallback((values, type) => {
36967
+ setSelectedValues(values);
36968
+ if (typeof onSelectProp === "function") {
36969
+ onSelectProp(values, type);
36970
+ }
36971
+ }, [onSelectProp]);
36972
+ const onSelect = useCallback((value, type) => {
36973
+ let newValues = [];
36974
+ if (selectedValues.includes(value)) {
36975
+ newValues = selectedValues.filter((currentValue) => currentValue !== value);
36976
+ } else {
36977
+ newValues = [...selectedValues, value];
36978
+ }
36979
+ onChange(newValues, type);
36980
+ }, [onChange, selectedValues]);
36981
+ const conditionalProps = {};
36982
+ if (options) {
36983
+ conditionalProps.options = options;
36984
+ } else {
36985
+ conditionalProps.children = children;
36986
+ }
36987
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(InternalSelect, { onChange, value: selectedValues, open: open2, onOpenChange, onSelect, checkbox: true, selectLabel, ...conditionalProps, ...props });
36988
+ };
36989
+ CheckboxMultiSelect.Group = SelectGroup;
36990
+ CheckboxMultiSelect.Item = MultiSelectCheckboxItem;
36839
36991
  const $89eedd556c436f6a$var$DEFAULT_ORIENTATION = "horizontal";
36840
36992
  const $89eedd556c436f6a$var$ORIENTATIONS = [
36841
36993
  "horizontal",
@@ -47628,6 +47780,7 @@ export {
47628
47780
  CardPromotion,
47629
47781
  CardSecondary,
47630
47782
  Checkbox,
47783
+ CheckboxMultiSelect,
47631
47784
  ClickUIProvider,
47632
47785
  CodeBlock,
47633
47786
  ConfirmationDialog,
@@ -10068,7 +10068,7 @@ var __publicField = (obj, key, value) => {
10068
10068
  })([""]);
10069
10069
  const Wrapper$a = styled.div.withConfig({
10070
10070
  componentId: "sc-1drx130-7"
10071
- })(["background-color:", ";border-radius:", ";border:", ";max-width:420px;min-width:320px;display:flex;flex-direction:column;padding:", ";gap:", ";box-shadow:", ";&:hover,:focus{background-color:", ";cursor:pointer;", ",", "{color:", ";}}&[disabled],&[disabled]:hover,&[disabled]:active{background-color:", ";color:", ";border:1px solid ", ";cursor:not-allowed;", ",", "{color:", ";}}"], ({
10071
+ })(["background-color:", ";border-radius:", ";border:", ";max-width:420px;min-width:320px;display:flex;flex-direction:column;padding:", ";gap:", ";box-shadow:", ";&:hover,:focus{background-color:", ";cursor:pointer;", ",", "{color:", ";}}", ""], ({
10072
10072
  theme: theme2
10073
10073
  }) => theme2.click.card.secondary.color.background.default, ({
10074
10074
  theme: theme2
@@ -10086,14 +10086,24 @@ var __publicField = (obj, key, value) => {
10086
10086
  }) => theme2.click.card.secondary.color.background.hover, LinkText, LinkArrow, ({
10087
10087
  theme: theme2
10088
10088
  }) => theme2.click.card.secondary.color.link.hover, ({
10089
+ $disabled,
10089
10090
  theme: theme2
10090
- }) => theme2.click.card.secondary.color.background.disabled, ({
10091
- theme: theme2
10092
- }) => theme2.click.card.secondary.color.title.disabled, ({
10093
- theme: theme2
10094
- }) => theme2.click.card.secondary.color.stroke.disabled, LinkText, LinkArrow, ({
10095
- theme: theme2
10096
- }) => theme2.click.card.secondary.color.link.disabled);
10091
+ }) => $disabled && `
10092
+ &,
10093
+ &:hover,
10094
+ &:focus,
10095
+ &:active {
10096
+ background-color: ${theme2.click.card.secondary.color.background.disabled};
10097
+ color: ${theme2.click.card.secondary.color.title.disabled};
10098
+ border: 1px solid ${theme2.click.card.secondary.color.stroke.disabled};
10099
+ cursor: not-allowed;
10100
+
10101
+ ${LinkText},
10102
+ ${LinkArrow} {
10103
+ color: ${theme2.click.card.secondary.color.link.disabled};
10104
+ }
10105
+ }
10106
+ `);
10097
10107
  const CardSecondary = ({
10098
10108
  title,
10099
10109
  icon,
@@ -10123,7 +10133,7 @@ var __publicField = (obj, key, value) => {
10123
10133
  };
10124
10134
  const Wrapper$9 = styled.div.withConfig({
10125
10135
  componentId: "sc-2dguvi-0"
10126
- })(["background-color:", ";border-radius:", ";border:", ";display:flex;width:100%;max-width:100%;text-align:", ";flex-direction:column;padding:", ";gap:", ";box-shadow:", ";&:hover,&:focus{background-color:", ";cursor:pointer;button{background-color:", ";border-color:", ";&:active{background-color:", ";border-color:", ";}}}&:active{border-color:", ";}&[disabled],&[disabled]:hover,&[disabled]:active{background-color:", ";color:", ";border:1px solid ", ";cursor:not-allowed;button{background-color:", ";border-color:", ";&:active{background-color:", ";border-color:", ";}}}", ""], ({
10136
+ })(["background-color:", ";border-radius:", ";border:", ";display:flex;width:100%;max-width:100%;text-align:", ";flex-direction:column;padding:", ";gap:", ";box-shadow:", ";&:hover,&:focus{background-color:", ";cursor:pointer;button{background-color:", ";border-color:", ";&:active{background-color:", ";border-color:", ";}}}&:active{border-color:", ";}", " ", ""], ({
10127
10137
  theme: theme2
10128
10138
  }) => theme2.click.card.primary.color.background.default, ({
10129
10139
  theme: theme2
@@ -10153,20 +10163,28 @@ var __publicField = (obj, key, value) => {
10153
10163
  }) => theme2.click.button.basic.color.primary.stroke.active, ({
10154
10164
  theme: theme2
10155
10165
  }) => theme2.click.button.basic.color.primary.stroke.active, ({
10166
+ $disabled,
10156
10167
  theme: theme2
10157
- }) => theme2.click.card.primary.color.background.disabled, ({
10158
- theme: theme2
10159
- }) => theme2.click.card.primary.color.title.disabled, ({
10160
- theme: theme2
10161
- }) => theme2.click.card.primary.color.stroke.disabled, ({
10162
- theme: theme2
10163
- }) => theme2.click.button.basic.color.primary.background.disabled, ({
10164
- theme: theme2
10165
- }) => theme2.click.button.basic.color.primary.stroke.disabled, ({
10166
- theme: theme2
10167
- }) => theme2.click.button.basic.color.primary.background.disabled, ({
10168
- theme: theme2
10169
- }) => theme2.click.button.basic.color.primary.stroke.disabled, ({
10168
+ }) => $disabled && `
10169
+ &,
10170
+ &:hover,
10171
+ &:focus,
10172
+ &:active {
10173
+ background-color: ${theme2.click.card.primary.color.background.disabled};
10174
+ color: ${theme2.click.card.primary.color.title.disabled};
10175
+ border: 1px solid ${theme2.click.card.primary.color.stroke.disabled};
10176
+ cursor: not-allowed;
10177
+
10178
+ button {
10179
+ background-color: ${theme2.click.button.basic.color.primary.background.disabled};
10180
+ border-color: ${theme2.click.button.basic.color.primary.stroke.disabled};
10181
+ &:active {
10182
+ background-color: ${theme2.click.button.basic.color.primary.background.disabled};
10183
+ border-color: ${theme2.click.button.basic.color.primary.stroke.disabled};
10184
+ }
10185
+ }
10186
+ }
10187
+ `, ({
10170
10188
  $isSelected,
10171
10189
  theme: theme2
10172
10190
  }) => $isSelected ? `border-color: ${theme2.click.button.basic.color.primary.stroke.active};` : "");
@@ -31389,6 +31407,7 @@ var __publicField = (obj, key, value) => {
31389
31407
  onMouseMove: onMouseMoveProp,
31390
31408
  showBorder = false,
31391
31409
  onCopy: onCopyProp,
31410
+ onCopyCallback,
31392
31411
  onContextMenu: onContextMenuProp,
31393
31412
  forwardedGridRef,
31394
31413
  ...props
@@ -31400,8 +31419,7 @@ var __publicField = (obj, key, value) => {
31400
31419
  const [selection, setSelection] = React.useState(selectionProp ?? {
31401
31420
  type: "empty"
31402
31421
  });
31403
- const onCopy = React.useCallback(async () => {
31404
- let isCopied = false;
31422
+ const defaultOnCopy = React.useCallback(async () => {
31405
31423
  try {
31406
31424
  await copyGridElements({
31407
31425
  cell,
@@ -31411,7 +31429,9 @@ var __publicField = (obj, key, value) => {
31411
31429
  columnCount,
31412
31430
  outerRef
31413
31431
  });
31414
- isCopied = true;
31432
+ if (onCopyCallback) {
31433
+ onCopyCallback(true);
31434
+ }
31415
31435
  if (showToast) {
31416
31436
  createToast({
31417
31437
  title: "Copied successfully",
@@ -31421,6 +31441,9 @@ var __publicField = (obj, key, value) => {
31421
31441
  }
31422
31442
  } catch (e) {
31423
31443
  console.error(e);
31444
+ if (onCopyCallback) {
31445
+ onCopyCallback(false);
31446
+ }
31424
31447
  if (showToast) {
31425
31448
  createToast({
31426
31449
  title: "Failed to copy",
@@ -31428,11 +31451,17 @@ var __publicField = (obj, key, value) => {
31428
31451
  type: "danger"
31429
31452
  });
31430
31453
  }
31431
- if (typeof onCopyProp === "function") {
31432
- onCopyProp(isCopied);
31433
- }
31434
31454
  }
31435
- }, [cell, columnCount, focus, focusProp, onCopyProp, rowCount, selection, showToast]);
31455
+ }, [cell, columnCount, focus, focusProp, rowCount, selection, showToast, onCopyCallback]);
31456
+ const customOnCopy = React.useMemo(() => {
31457
+ const result = async () => {
31458
+ if (onCopyProp) {
31459
+ await onCopyProp(selection, focus);
31460
+ }
31461
+ };
31462
+ return result;
31463
+ }, [onCopyProp, selection, focus]);
31464
+ const onCopy = typeof onCopyProp === "function" ? customOnCopy : defaultOnCopy;
31436
31465
  const defaultMenuOptions = [{
31437
31466
  label: "Copy",
31438
31467
  onSelect: onCopy
@@ -36486,6 +36515,8 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
36486
36515
  sortable = false,
36487
36516
  placeholder = "Select an option",
36488
36517
  multiple,
36518
+ checkbox,
36519
+ selectLabel,
36489
36520
  showSearch = false,
36490
36521
  container,
36491
36522
  ...props
@@ -36652,7 +36683,10 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
36652
36683
  /* @__PURE__ */ jsxRuntimeExports.jsxs(FormElementContainer, { children: [
36653
36684
  /* @__PURE__ */ jsxRuntimeExports.jsxs(SelectPopoverRoot, { open: open2, onOpenChange, modal: true, children: [
36654
36685
  /* @__PURE__ */ jsxRuntimeExports.jsxs(StyledSelectTrigger, { id: id ?? defaultId, $error: !!error2, disabled, "data-testid": "select-trigger", children: [
36655
- isInitialized && /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, { children: selectedValues.length === 0 ? placeholder : multiple ? /* @__PURE__ */ jsxRuntimeExports.jsx(MultiSelectValue, { disabled: disabled ?? false, onSelect, selectedValues, sortable: !disabled && sortable, valueNode: valueNode.current, onChange }) : /* @__PURE__ */ jsxRuntimeExports.jsx(SingleSelectValue, { valueNode: valueNode.current.get(selectedValues[0]), value: selectedValues[0] }) }),
36686
+ isInitialized && /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, { children: selectedValues.length === 0 ? placeholder : multiple ? /* @__PURE__ */ jsxRuntimeExports.jsx(MultiSelectValue, { disabled: disabled ?? false, onSelect, selectedValues, sortable: !disabled && sortable, valueNode: valueNode.current, onChange }) : /* @__PURE__ */ jsxRuntimeExports.jsx(SingleSelectValue, { valueNode: checkbox && selectLabel ? {
36687
+ label: selectLabel,
36688
+ value: selectLabel
36689
+ } : valueNode.current.get(selectedValues[0]), value: selectedValues[0] }) }),
36656
36690
  /* @__PURE__ */ jsxRuntimeExports.jsx(SvgImage, { name: "sort", size: "sm" })
36657
36691
  ] }),
36658
36692
  form && /* @__PURE__ */ jsxRuntimeExports.jsx(HiddenSelectElement, { multiple, name: name2, form, value: selectedValues, onChange: () => null, children: list.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: item.value, disabled: item.disabled, children: item.value }, item.value)) }),
@@ -36674,8 +36708,16 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
36674
36708
  return /* @__PURE__ */ jsxRuntimeExports.jsx(SelectGroup, { ...groupProps, children: itemList.map(({
36675
36709
  label: label2,
36676
36710
  ...itemProps
36677
- }, itemIndex) => /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { ...itemProps, children: label2 }, `select-${id}-group-${index2}-item-${itemIndex}`)) }, `select-${id}-group-${index2}`);
36711
+ }, itemIndex) => {
36712
+ if (checkbox) {
36713
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(MultiSelectCheckboxItem, { ...itemProps, children: label2 }, `select-${id}-group-${index2}-item-${itemIndex}`);
36714
+ }
36715
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { ...itemProps, children: label2 }, `select-${id}-group-${index2}-item-${itemIndex}`);
36716
+ }) }, `select-${id}-group-${index2}`);
36678
36717
  } else {
36718
+ if (checkbox) {
36719
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(MultiSelectCheckboxItem, { ...props2 }, `select-${id}-item-${index2}`);
36720
+ }
36679
36721
  return /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { ...props2 }, `select-${id}-item-${index2}`);
36680
36722
  }
36681
36723
  }) : children }) }),
@@ -36761,6 +36803,70 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
36761
36803
  ] });
36762
36804
  });
36763
36805
  SelectItem.displayName = "Select.Item";
36806
+ const MultiSelectCheckboxItem = React.forwardRef(({
36807
+ disabled = false,
36808
+ children,
36809
+ icon,
36810
+ iconDir = "end",
36811
+ label,
36812
+ onMouseOver: onMouseOverProp,
36813
+ onSelect: onSelectProp,
36814
+ separator,
36815
+ value = "",
36816
+ ...props
36817
+ }, forwardedRef) => {
36818
+ const {
36819
+ highlighted,
36820
+ updateHighlighted,
36821
+ isHidden,
36822
+ selectedValues,
36823
+ onSelect
36824
+ } = useOption();
36825
+ const onSelectValue = () => {
36826
+ if (!disabled) {
36827
+ onSelect(value);
36828
+ if (typeof onSelectProp == "function") {
36829
+ onSelectProp(value);
36830
+ }
36831
+ }
36832
+ };
36833
+ const onMouseOver = (e) => {
36834
+ if (onMouseOverProp) {
36835
+ onMouseOverProp(e);
36836
+ }
36837
+ if (!disabled) {
36838
+ updateHighlighted(value);
36839
+ }
36840
+ };
36841
+ if (isHidden(value)) {
36842
+ return null;
36843
+ }
36844
+ const isChecked = selectedValues.includes(value);
36845
+ const onChange = () => {
36846
+ onSelect(value);
36847
+ };
36848
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
36849
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(GenericMenuItem, { ...props, "data-value": value, onClick: onSelectValue, onMouseOver, ref: forwardedRef, "data-disabled": disabled ? true : void 0, "data-highlighted": highlighted == value ? "true" : void 0, "data-testid": `multi-select-checkbox-${value}`, "cui-select-item": "", children: [
36850
+ icon && iconDir === "start" && /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, { checked: isChecked, "data-testid": "multi-select-checkbox", disabled, label: label ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: {
36851
+ display: "flex",
36852
+ justifyContent: "center"
36853
+ }, children: [
36854
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SvgImage, { name: icon, size: "sm" }),
36855
+ label
36856
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: {
36857
+ display: "flex",
36858
+ justifyContent: "center"
36859
+ }, children: [
36860
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SvgImage, { name: icon, size: "sm" }),
36861
+ children
36862
+ ] }), onClick: onChange }),
36863
+ icon && iconDir === "end" && /* @__PURE__ */ jsxRuntimeExports.jsx(IconWrapper$3, { icon, iconDir: "end", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, { checked: isChecked, "data-testid": "multi-select-checkbox", disabled, label: label ?? children, onClick: onChange }) }),
36864
+ !icon && /* @__PURE__ */ jsxRuntimeExports.jsx(Checkbox, { checked: isChecked, "data-testid": "multi-select-checkbox", disabled, label: label ?? children, onClick: onChange })
36865
+ ] }),
36866
+ separator && /* @__PURE__ */ jsxRuntimeExports.jsx(Separator$1, { size: "sm" })
36867
+ ] });
36868
+ });
36869
+ MultiSelectCheckboxItem.displayName = "Select.Item";
36764
36870
  const Select = ({
36765
36871
  value: valueProp,
36766
36872
  defaultValue,
@@ -36853,6 +36959,52 @@ Please read the updated README.md at https://github.com/SortableJS/react-sortabl
36853
36959
  };
36854
36960
  MultiSelect.Group = SelectGroup;
36855
36961
  MultiSelect.Item = SelectItem;
36962
+ const CheckboxMultiSelect = ({
36963
+ value: valueProp,
36964
+ defaultValue,
36965
+ onSelect: onSelectProp,
36966
+ options: options2,
36967
+ children,
36968
+ onOpenChange: onOpenChangeProp,
36969
+ selectLabel,
36970
+ ...props
36971
+ }) => {
36972
+ const [selectedValues, setSelectedValues] = React.useState(valueProp ?? defaultValue ?? []);
36973
+ const [open2, setOpen] = React.useState(false);
36974
+ const onOpenChange = React.useCallback((open22) => {
36975
+ setOpen(open22);
36976
+ if (typeof onOpenChangeProp === "function") {
36977
+ onOpenChangeProp(open22);
36978
+ }
36979
+ }, [onOpenChangeProp]);
36980
+ React.useEffect(() => {
36981
+ setSelectedValues(valueProp ?? []);
36982
+ }, [valueProp]);
36983
+ const onChange = React.useCallback((values, type) => {
36984
+ setSelectedValues(values);
36985
+ if (typeof onSelectProp === "function") {
36986
+ onSelectProp(values, type);
36987
+ }
36988
+ }, [onSelectProp]);
36989
+ const onSelect = React.useCallback((value, type) => {
36990
+ let newValues = [];
36991
+ if (selectedValues.includes(value)) {
36992
+ newValues = selectedValues.filter((currentValue) => currentValue !== value);
36993
+ } else {
36994
+ newValues = [...selectedValues, value];
36995
+ }
36996
+ onChange(newValues, type);
36997
+ }, [onChange, selectedValues]);
36998
+ const conditionalProps = {};
36999
+ if (options2) {
37000
+ conditionalProps.options = options2;
37001
+ } else {
37002
+ conditionalProps.children = children;
37003
+ }
37004
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(InternalSelect, { onChange, value: selectedValues, open: open2, onOpenChange, onSelect, checkbox: true, selectLabel, ...conditionalProps, ...props });
37005
+ };
37006
+ CheckboxMultiSelect.Group = SelectGroup;
37007
+ CheckboxMultiSelect.Item = MultiSelectCheckboxItem;
36856
37008
  const $89eedd556c436f6a$var$DEFAULT_ORIENTATION = "horizontal";
36857
37009
  const $89eedd556c436f6a$var$ORIENTATIONS = [
36858
37010
  "horizontal",
@@ -47644,6 +47796,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
47644
47796
  exports2.CardPromotion = CardPromotion;
47645
47797
  exports2.CardSecondary = CardSecondary;
47646
47798
  exports2.Checkbox = Checkbox;
47799
+ exports2.CheckboxMultiSelect = CheckboxMultiSelect;
47647
47800
  exports2.ClickUIProvider = ClickUIProvider;
47648
47801
  exports2.CodeBlock = CodeBlock;
47649
47802
  exports2.ConfirmationDialog = ConfirmationDialog;
@@ -130,7 +130,8 @@ export interface GridProps extends Omit<VariableSizeGridProps, "height" | "width
130
130
  onMouseDown?: MouseEventHandler<HTMLDivElement>;
131
131
  onMouseMove?: MouseEventHandler<HTMLDivElement>;
132
132
  showBorder?: boolean;
133
- onCopy?: (isCopied: boolean) => void | Promise<void>;
133
+ onCopy?: (selection: SelectedRegion, focus: SelectionFocus) => void | Promise<void>;
134
+ onCopyCallback?: (copied: boolean) => void;
134
135
  onContextMenu?: MouseEventHandler<HTMLDivElement>;
135
136
  forwardedGridRef?: MutableRefObject<VariableSizeGrid>;
136
137
  }
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { MultiSelectProps } from "..";
3
+ export interface CheckboxMultiSelectProps extends MultiSelectProps {
4
+ selectLabel?: string;
5
+ }
6
+ export declare const CheckboxMultiSelect: {
7
+ ({ value: valueProp, defaultValue, onSelect: onSelectProp, options, children, onOpenChange: onOpenChangeProp, selectLabel, ...props }: CheckboxMultiSelectProps): import("react/jsx-runtime").JSX.Element;
8
+ Group: import("react").ForwardRefExoticComponent<import("./common/types").SelectGroupProps & import("react").RefAttributes<HTMLDivElement>>;
9
+ Item: import("react").ForwardRefExoticComponent<import("./common/types").SelectItemProps & import("react").RefAttributes<HTMLDivElement>>;
10
+ };
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { SelectContainerProps, SelectGroupProps, SelectItemProps } from "./types";
3
- export declare const InternalSelect: ({ label, children, orientation, dir, disabled, id, error, value: selectedValues, onChange, onSelect, open, onOpenChange, name, form, allowCreateOption, customText, options, sortable, placeholder, multiple, showSearch, container, ...props }: SelectContainerProps) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const InternalSelect: ({ label, children, orientation, dir, disabled, id, error, value: selectedValues, onChange, onSelect, open, onOpenChange, name, form, allowCreateOption, customText, options, sortable, placeholder, multiple, checkbox, selectLabel, showSearch, container, ...props }: SelectContainerProps) => import("react/jsx-runtime").JSX.Element;
4
4
  export declare const SelectGroup: import("react").ForwardRefExoticComponent<SelectGroupProps & import("react").RefAttributes<HTMLDivElement>>;
5
5
  export declare const SelectItem: import("react").ForwardRefExoticComponent<SelectItemProps & import("react").RefAttributes<HTMLDivElement>>;
6
+ export declare const MultiSelectCheckboxItem: import("react").ForwardRefExoticComponent<SelectItemProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -60,6 +60,8 @@ interface InternalSelectProps extends PopoverProps, Omit<HTMLAttributes<HTMLDivE
60
60
  sortable?: boolean;
61
61
  onSelect: (value: string, type?: SelectionType) => void;
62
62
  multiple?: boolean;
63
+ checkbox?: boolean;
64
+ selectLabel?: string;
63
65
  placeholder?: string;
64
66
  showSearch?: boolean;
65
67
  customText?: string;
@@ -41,6 +41,7 @@ export { RadioGroup } from "./RadioGroup/RadioGroup";
41
41
  export { SearchField } from "./Input/SearchField";
42
42
  export { Select } from "./Select/SingleSelect";
43
43
  export { MultiSelect } from "./Select/MultiSelect";
44
+ export { CheckboxMultiSelect } from "./Select/CheckboxMultiSelect";
44
45
  export { default as Separator } from "./Separator/Separator";
45
46
  export { SidebarNavigationItem } from "./SidebarNavigationItem/SidebarNavigationItem";
46
47
  export { SidebarCollapsibleItem } from "./SidebarCollapsibleItem/SidebarCollapsibleItem";
@@ -32,6 +32,7 @@ export type { Menu, SplitButtonProps } from "./SplitButton/SplitButton";
32
32
  export type { ToastProps } from "./Toast/Toast";
33
33
  export type { SelectOptionListItem } from "./Select/common/types";
34
34
  export type { MultiSelectProps } from "./Select/MultiSelect";
35
+ export type { CheckboxMultiSelectProps } from "./Select/CheckboxMultiSelect";
35
36
  export type { PanelProps } from "./Panel/Panel";
36
37
  export type { FlyoutProps, FlyoutFooterProps, FlyoutHeaderProps } from "./Flyout/Flyout";
37
38
  export type { DialogContentProps } from "./Dialog/Dialog";
@@ -45,7 +46,7 @@ export type { VerticalStepperProps, VerticalStepProps, } from "./VerticalStepper
45
46
  export type { CardHorizontalProps } from "./CardHorizontal/CardHorizontal";
46
47
  export type { CardPromotionProps } from "./CardPromotion/CardPromotion";
47
48
  export type { ProgressBarProps } from "./ProgressBar/ProgressBar";
48
- export type { GridProps, CellProps, SelectedRegion, SelectionFocus, SelectionAction, GridContextMenuItemProps, } from "./Grid/types";
49
+ export type { GridProps, CellProps, SelectedRegion, SelectionFocus, SelectionAction, GridContextMenuItemProps, Rectangle } from "./Grid/types";
49
50
  export type States = "default" | "active" | "disabled" | "error" | "hover";
50
51
  export type HorizontalDirection = "start" | "end";
51
52
  export type Orientation = "horizontal" | "vertical";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clickhouse/click-ui",
3
- "version": "0.0.131",
3
+ "version": "0.0.133",
4
4
  "description": "Official ClickHouse design system react library",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",