@paubox/ui 1.8.0 → 1.9.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/index.esm.js CHANGED
@@ -22324,6 +22324,8 @@ var Popper = function(param) {
22324
22324
  ], onClose, open);
22325
22325
  var updatePosition = useCallback(function() {
22326
22326
  if (!anchorRef.current || !containerRef.current) return;
22327
+ // Check if anchor element is still connected to the DOM
22328
+ if (!anchorRef.current.isConnected) return;
22327
22329
  var anchorRect = anchorRef.current.getBoundingClientRect();
22328
22330
  var popperRect = containerRef.current.getBoundingClientRect();
22329
22331
  var el = anchorRef.current;
@@ -23778,7 +23780,8 @@ function _templateObject$g() {
23778
23780
  }
23779
23781
  function _templateObject1$c() {
23780
23782
  var data = _tagged_template_literal$g([
23781
- "\n display: flex;\n align-items: center;\n\n width: 100%;\n position: relative;\n cursor: pointer;\n &:hover {\n background-color: ",
23783
+ "\n display: flex;\n align-items: center;\n\n width: 100%;\n position: relative;\n cursor: ",
23784
+ ";\n &:hover {\n background-color: ",
23782
23785
  ";\n }\n transition: all 150ms ease-in-out;\n\n &:focus-within {\n border-color: ",
23783
23786
  ";\n }\n\n &:focus {\n background-color: ",
23784
23787
  ";\n }\n\n border: 1px solid\n ",
@@ -23792,7 +23795,7 @@ function _templateObject1$c() {
23792
23795
  }
23793
23796
  function _templateObject2$b() {
23794
23797
  var data = _tagged_template_literal$g([
23795
- "\n flex: 1;\n z-index: 2;\n cursor: pointer;\n border: none;\n background-color: transparent;\n\n -webkit-appearance: none;\n -moz-appearance: none;\n &::-ms-expand {\n display: none;\n }\n &::placeholder {\n color: ",
23798
+ "\n flex: 1;\n z-index: 2;\n pointer-events: none;\n border: none;\n background-color: transparent;\n\n -webkit-appearance: none;\n -moz-appearance: none;\n &::-ms-expand {\n display: none;\n }\n &::placeholder {\n color: ",
23796
23799
  ";\n }\n color: ",
23797
23800
  ";\n padding: ",
23798
23801
  ";\n padding-right: 2rem;\n outline: none;\n &::placeholder {\n color: ",
@@ -23862,6 +23865,9 @@ function _templateObject7$1() {
23862
23865
  // Wrapper for the Input and Icons
23863
23866
  var InputWrapper$2 = styled.div(_templateObject$g());
23864
23867
  var MultiSelectWrapper = styled.div(_templateObject1$c(), function(param) {
23868
+ var disabled = param.disabled;
23869
+ return disabled ? 'not-allowed' : 'pointer';
23870
+ }, function(param) {
23865
23871
  var disabled = param.disabled, type = param.type;
23866
23872
  return disabled || type === 'secondary' ? neutral100 : 'white';
23867
23873
  }, function(param) {
@@ -23902,7 +23908,10 @@ var ChipWrapper$1 = styled.div(_templateObject4$8(), neutral100, neutral300, fun
23902
23908
  var MultiSelectChip = function(option) {
23903
23909
  var label = option.label, onClick = option.onClick, _option_type = option.type, type = _option_type === void 0 ? 'primary' : _option_type, _option_sz = option.sz, sz = _option_sz === void 0 ? 'sm' : _option_sz;
23904
23910
  return /*#__PURE__*/ jsxs(Chip$1, {
23905
- onClick: onClick,
23911
+ onClick: function(e) {
23912
+ e.stopPropagation();
23913
+ onClick();
23914
+ },
23906
23915
  secondary: type === 'secondary',
23907
23916
  sz: sz,
23908
23917
  children: [
@@ -23934,7 +23943,7 @@ var MultiSelect = function(_param) {
23934
23943
  "type"
23935
23944
  ]);
23936
23945
  var _useState = _sliced_to_array$b(useState(false), 2), open = _useState[0], setOpen = _useState[1];
23937
- var selectRef = useRef(null);
23946
+ var wrapperRef = useRef(null);
23938
23947
  var toggleSelect = function(option) {
23939
23948
  setValues(values.some(function(val) {
23940
23949
  return val === option.value;
@@ -23945,22 +23954,21 @@ var MultiSelect = function(_param) {
23945
23954
  ]), option);
23946
23955
  };
23947
23956
  return /*#__PURE__*/ jsxs(MultiSelectWrapper, {
23957
+ ref: wrapperRef,
23948
23958
  disabled: disabled,
23949
23959
  type: type,
23950
23960
  error: error,
23951
23961
  open: open,
23952
23962
  className: className,
23963
+ onClick: function() {
23964
+ return !disabled && setOpen(function(prev) {
23965
+ return !prev;
23966
+ });
23967
+ },
23953
23968
  children: [
23954
23969
  /*#__PURE__*/ jsxs(InputWrapper$2, {
23955
23970
  children: [
23956
- /*#__PURE__*/ jsx(BaseSelect$1, _object_spread_props$j(_object_spread$n({
23957
- ref: selectRef,
23958
- onClick: function() {
23959
- setOpen(function(prev) {
23960
- return !prev;
23961
- });
23962
- }
23963
- }, props), {
23971
+ /*#__PURE__*/ jsx(BaseSelect$1, _object_spread_props$j(_object_spread$n({}, props), {
23964
23972
  type: type,
23965
23973
  sz: sz,
23966
23974
  value: values,
@@ -24009,7 +24017,7 @@ var MultiSelect = function(_param) {
24009
24017
  onClose: function() {
24010
24018
  return setOpen(false);
24011
24019
  },
24012
- anchorRef: selectRef,
24020
+ anchorRef: wrapperRef,
24013
24021
  align: "start",
24014
24022
  offset: 4,
24015
24023
  maxHeight: 400,
@@ -24025,8 +24033,9 @@ var MultiSelect = function(_param) {
24025
24033
  return val === option.value;
24026
24034
  })
24027
24035
  }, option), {
24028
- onClick: function() {
24029
- return toggleSelect(option);
24036
+ onClick: function(e) {
24037
+ e.stopPropagation();
24038
+ toggleSelect(option);
24030
24039
  }
24031
24040
  }), option.value);
24032
24041
  })
@@ -24679,7 +24688,8 @@ function _templateObject$d() {
24679
24688
  }
24680
24689
  function _templateObject1$a() {
24681
24690
  var data = _tagged_template_literal$d([
24682
- "\n display: flex;\n align-items: center;\n width: max-content;\n position: relative;\n cursor: pointer;\n &:hover {\n background-color: ",
24691
+ "\n display: flex;\n align-items: center;\n width: max-content;\n position: relative;\n cursor: ",
24692
+ ";\n &:hover {\n background-color: ",
24683
24693
  ";\n }\n transition: all 150ms ease-in-out;\n\n &:focus-within {\n border-color: ",
24684
24694
  ";\n }\n\n &:focus {\n background-color: ",
24685
24695
  ";\n }\n\n border: 1px solid\n ",
@@ -24694,7 +24704,7 @@ function _templateObject1$a() {
24694
24704
  }
24695
24705
  function _templateObject2$9() {
24696
24706
  var data = _tagged_template_literal$d([
24697
- "\n flex: 1;\n cursor: pointer;\n border: none;\n width: 100%;\n text-overflow: ellipsis;\n white-space: nowrap;\n background-color: transparent;\n z-index: 1;\n -webkit-appearance: none;\n -moz-appearance: none;\n &::-ms-expand {\n display: none;\n }\n color: ",
24707
+ "\n flex: 1;\n pointer-events: none;\n border: none;\n width: 100%;\n text-overflow: ellipsis;\n white-space: nowrap;\n background-color: transparent;\n z-index: 1;\n -webkit-appearance: none;\n -moz-appearance: none;\n &::-ms-expand {\n display: none;\n }\n color: ",
24698
24708
  ";\n padding: ",
24699
24709
  ";\n padding-right: 2rem;\n outline: none;\n\n ",
24700
24710
  "\n"
@@ -24729,6 +24739,9 @@ function _templateObject4$6() {
24729
24739
  // Wrapper for the Input and Icons
24730
24740
  var InputWrapper = styled.div(_templateObject$d());
24731
24741
  var SelectWrapper = styled.div(_templateObject1$a(), function(param) {
24742
+ var disabled = param.disabled;
24743
+ return disabled ? 'not-allowed' : 'pointer';
24744
+ }, function(param) {
24732
24745
  var disabled = param.disabled, type = param.type;
24733
24746
  return disabled || type === 'secondary' ? neutral100 : 'white';
24734
24747
  }, function(param) {
@@ -24797,20 +24810,21 @@ var Select = function(_param) {
24797
24810
  error: error,
24798
24811
  open: open,
24799
24812
  style: style,
24813
+ onClick: function() {
24814
+ return !disabled && setOpen(function(prev) {
24815
+ return !prev;
24816
+ });
24817
+ },
24800
24818
  children: [
24801
24819
  /*#__PURE__*/ jsxs(InputWrapper, {
24802
24820
  children: [
24803
- /*#__PURE__*/ jsx(BaseSelect, _object_spread_props$h(_object_spread$k({
24804
- onClick: function() {
24805
- return setOpen(function(prev) {
24806
- return !prev;
24807
- });
24808
- }
24809
- }, props), {
24821
+ /*#__PURE__*/ jsx(BaseSelect, _object_spread_props$h(_object_spread$k({}, props), {
24810
24822
  type: type,
24811
24823
  disabled: disabled,
24812
24824
  sz: sz,
24813
24825
  value: value,
24826
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
24827
+ onChange: function() {},
24814
24828
  error: error,
24815
24829
  children: !value ? /*#__PURE__*/ jsx(SelectOption, {
24816
24830
  value: "",
@@ -24852,8 +24866,9 @@ var Select = function(_param) {
24852
24866
  return /*#__PURE__*/ jsx(MenuItem, _object_spread_props$h(_object_spread$k({
24853
24867
  selected: value === option.value
24854
24868
  }, option), {
24855
- onClick: function() {
24856
- return handleSelect(option);
24869
+ onClick: function(e) {
24870
+ e.stopPropagation();
24871
+ handleSelect(option);
24857
24872
  }
24858
24873
  }), option.value);
24859
24874
  })
@@ -29160,14 +29175,15 @@ var Modal = function(param) {
29160
29175
  }),
29161
29176
  Boolean(actions === null || actions === void 0 ? void 0 : actions.length) && /*#__PURE__*/ jsx(ModalFooter, {
29162
29177
  children: actions === null || actions === void 0 ? void 0 : actions.map(function(_param) {
29163
- var label = _param.label, rest = _object_without_properties$4(_param, [
29178
+ var id = _param.id, label = _param.label, rest = _object_without_properties$4(_param, [
29179
+ "id",
29164
29180
  "label"
29165
29181
  ]);
29166
29182
  return /*#__PURE__*/ jsx(Button, _object_spread_props$7(_object_spread$8({
29167
29183
  "data-testid": "".concat(testId, "-").concat(formatForId(label), "-button")
29168
29184
  }, rest), {
29169
29185
  children: label
29170
- }));
29186
+ }), id !== null && id !== void 0 ? id : formatForId(label));
29171
29187
  })
29172
29188
  }),
29173
29189
  loading && /*#__PURE__*/ jsx(LoadingOverlay, {})
@@ -34315,13 +34331,9 @@ var Table = function(param) {
34315
34331
  ]);
34316
34332
  var handleContextMenu = useCallback(function(e, row) {
34317
34333
  e.stopPropagation();
34334
+ ctxMenuAnchorRef.current = e.currentTarget;
34318
34335
  setCtxMenuRow(function(prev) {
34319
- if (prev === row.original) {
34320
- ctxMenuAnchorRef.current = null;
34321
- return null;
34322
- }
34323
- ctxMenuAnchorRef.current = e.currentTarget;
34324
- return row.original;
34336
+ return prev === row.original ? null : row.original;
34325
34337
  });
34326
34338
  }, []);
34327
34339
  var contextColumn = useMemo(function() {
@@ -34334,6 +34346,12 @@ var Table = function(param) {
34334
34346
  cell: function(param) {
34335
34347
  var row = param.row;
34336
34348
  return /*#__PURE__*/ jsx(ContextMenuButton, {
34349
+ ref: function(el) {
34350
+ // Keep anchor ref in sync when this row's menu is open
34351
+ if (ctxMenuRow === row.original && el) {
34352
+ ctxMenuAnchorRef.current = el;
34353
+ }
34354
+ },
34337
34355
  onClick: function(e) {
34338
34356
  e.stopPropagation();
34339
34357
  handleContextMenu(e, row);
@@ -34348,7 +34366,8 @@ var Table = function(param) {
34348
34366
  };
34349
34367
  }, [
34350
34368
  handleContextMenu,
34351
- testId
34369
+ testId,
34370
+ ctxMenuRow
34352
34371
  ]);
34353
34372
  var allColumns = useMemo(function() {
34354
34373
  var cols = _to_consumable_array(tableColumns);
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@paubox/ui",
3
3
  "author": "Paubox, Inc.",
4
4
  "description": "Paubox Component Library",
5
- "version": "1.8.0",
5
+ "version": "1.9.1",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "publishConfig": {
@@ -1,6 +1,7 @@
1
1
  import { CSSProperties, ReactNode } from 'react';
2
2
  import { BaseButtonProps } from '../Button/BaseButton';
3
3
  type ModalAction = {
4
+ id?: string;
4
5
  label: string;
5
6
  onClick: () => void;
6
7
  color?: BaseButtonProps['color'];