@paubox/ui 0.12.0 → 0.12.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
@@ -1676,7 +1676,7 @@ function _templateObject6$2() {
1676
1676
  };
1677
1677
  return data;
1678
1678
  }
1679
- function _templateObject7() {
1679
+ function _templateObject7$1() {
1680
1680
  var data = _tagged_template_literal$t([
1681
1681
  "\n ",
1682
1682
  "\n font-size: ",
@@ -1684,7 +1684,7 @@ function _templateObject7() {
1684
1684
  "rem;\n letter-spacing: ",
1685
1685
  "px;\n font-weight: 400;\n"
1686
1686
  ]);
1687
- _templateObject7 = function _templateObject() {
1687
+ _templateObject7$1 = function _templateObject() {
1688
1688
  return data;
1689
1689
  };
1690
1690
  return data;
@@ -1932,7 +1932,7 @@ var $headline200Semibold = css(_templateObject4$8(), commonStyles, headline200Fo
1932
1932
  var $headline300Regular = css(_templateObject5$4(), commonStyles, headline300FontSize / BASE_FONT_SIZE, headline300LineHeight / BASE_FONT_SIZE, headline300LetterSpacing);
1933
1933
  var $headline300Semibold = css(_templateObject6$2(), commonStyles, headline300FontSize / BASE_FONT_SIZE, headline300LineHeight / BASE_FONT_SIZE, headline300LetterSpacing);
1934
1934
  // PARAGRAPH
1935
- var $paragraph100Regular = css(_templateObject7(), commonStyles, paragraph100FontSize / BASE_FONT_SIZE, paragraph100LineHeight / BASE_FONT_SIZE, paragraph100LetterSpacing);
1935
+ var $paragraph100Regular = css(_templateObject7$1(), commonStyles, paragraph100FontSize / BASE_FONT_SIZE, paragraph100LineHeight / BASE_FONT_SIZE, paragraph100LetterSpacing);
1936
1936
  var $paragraph100Semibold = css(_templateObject8(), commonStyles, paragraph100FontSize / BASE_FONT_SIZE, paragraph100LineHeight / BASE_FONT_SIZE, paragraph100LetterSpacing);
1937
1937
  var $paragraph200Regular = css(_templateObject9(), commonStyles, paragraph200FontSize / BASE_FONT_SIZE, paragraph200LineHeight / BASE_FONT_SIZE, paragraph200LetterSpacing);
1938
1938
  var $paragraph200Semibold = css(_templateObject10(), commonStyles, paragraph200FontSize / BASE_FONT_SIZE, paragraph200LineHeight / BASE_FONT_SIZE, paragraph200LetterSpacing);
@@ -23213,6 +23213,17 @@ function _templateObject6() {
23213
23213
  };
23214
23214
  return data;
23215
23215
  }
23216
+ function _templateObject7() {
23217
+ var data = _tagged_template_literal$i([
23218
+ "\n ",
23219
+ "\n color: ",
23220
+ ";\n"
23221
+ ]);
23222
+ _templateObject7 = function _templateObject() {
23223
+ return data;
23224
+ };
23225
+ return data;
23226
+ }
23216
23227
  // Wrapper for the Input and Icons
23217
23228
  var InputWrapper$2 = styled.div(_templateObject$i());
23218
23229
  var MultiSelectWrapper = styled.div(_templateObject1$c());
@@ -23225,7 +23236,7 @@ var BaseSelect$1 = styled.select(_templateObject2$a(), function(param) {
23225
23236
  return disabled || type === 'secondary' ? neutral100 : 'white';
23226
23237
  }, neutral500, function(param) {
23227
23238
  var value = param.value;
23228
- return value ? textPrimary : neutral500;
23239
+ return Array.isArray(value) && value.length > 0 ? textPrimary : neutral500;
23229
23240
  }, function(param) {
23230
23241
  var sz = param.sz;
23231
23242
  return sz === 'lg' ? '0.5rem 0.563rem' : '0.375rem 0.563rem';
@@ -23268,13 +23279,16 @@ var MultiSelectChip = function(option) {
23268
23279
  // Style for the Icons
23269
23280
  var IconWrapper$2 = styled.span(_templateObject5$1());
23270
23281
  var PlaceholderOption = styled.option(_templateObject6(), $paragraph100Semibold, textSecondary);
23282
+ var SelectedOption = styled.option(_templateObject7(), $paragraph200Regular, textPrimary);
23271
23283
  var MultiSelect = function(_param) {
23272
- var _param_sz = _param.sz, sz = _param_sz === void 0 ? 'sm' : _param_sz; _param.error; var _param_options = _param.options, options = _param_options === void 0 ? [] : _param_options; _param.checkbox; var placeholder = _param.placeholder, values = _param.values, setValues = _param.setValues, _param_type = _param.type, type = _param_type === void 0 ? 'primary' : _param_type, props = _object_without_properties$d(_param, [
23284
+ var _param_sz = _param.sz, sz = _param_sz === void 0 ? 'sm' : _param_sz; _param.error; var _param_options = _param.options, options = _param_options === void 0 ? [] : _param_options; _param.checkbox; var placeholder = _param.placeholder, label = _param.label, _param_chips = _param.chips, chips = _param_chips === void 0 ? false : _param_chips, values = _param.values, setValues = _param.setValues, _param_type = _param.type, type = _param_type === void 0 ? 'primary' : _param_type, props = _object_without_properties$d(_param, [
23273
23285
  "sz",
23274
23286
  "error",
23275
23287
  "options",
23276
23288
  "checkbox",
23277
23289
  "placeholder",
23290
+ "label",
23291
+ "chips",
23278
23292
  "values",
23279
23293
  "setValues",
23280
23294
  "type"
@@ -23304,19 +23318,25 @@ var MultiSelect = function(_param) {
23304
23318
  }, props), {
23305
23319
  type: type,
23306
23320
  sz: sz,
23321
+ value: values,
23307
23322
  defaultValue: '',
23308
- children: !values.length && /*#__PURE__*/ jsx(PlaceholderOption, {
23323
+ children: !values.length ? /*#__PURE__*/ jsx(PlaceholderOption, {
23309
23324
  value: "",
23310
23325
  disabled: true,
23311
23326
  hidden: true,
23312
23327
  selected: true,
23313
23328
  children: "".concat(placeholder || 'Please select...')
23329
+ }) : !chips && /*#__PURE__*/ jsx(SelectedOption, {
23330
+ value: "",
23331
+ hidden: true,
23332
+ selected: true,
23333
+ children: "".concat(label || 'Selected', " (").concat(values.length, ")")
23314
23334
  })
23315
23335
  })),
23316
23336
  /*#__PURE__*/ jsx(IconWrapper$2, {
23317
23337
  children: /*#__PURE__*/ jsx(ChevronDown, {})
23318
23338
  }),
23319
- /*#__PURE__*/ jsx(ChipWrapper$1, {
23339
+ chips && /*#__PURE__*/ jsx(ChipWrapper$1, {
23320
23340
  sz: sz,
23321
23341
  children: values.map(function(value) {
23322
23342
  var optionData = options.find(function(o) {
@@ -23711,7 +23731,7 @@ function _templateObject2$9() {
23711
23731
  }
23712
23732
  function _templateObject3$7() {
23713
23733
  var data = _tagged_template_literal$g([
23714
- "\n display: flex;\n gap: 0.25rem;\n max-width: 70%;\n flex-wrap: wrap;\n height: auto;\n"
23734
+ "\n display: flex;\n gap: 0.25rem;\n flex-wrap: wrap;\n height: auto;\n"
23715
23735
  ]);
23716
23736
  _templateObject3$7 = function _templateObject() {
23717
23737
  return data;
@@ -23751,16 +23771,26 @@ var MultiInputChip = function(param) {
23751
23771
  });
23752
23772
  };
23753
23773
  var MultiInput = function(_param) {
23754
- var _param_sz = _param.sz, sz = _param_sz === void 0 ? 'sm' : _param_sz, _param_error = _param.error, error = _param_error === void 0 ? false : _param_error, _param_type = _param.type, type = _param_type === void 0 ? 'primary' : _param_type, values = _param.values, setValues = _param.setValues, placeholder = _param.placeholder, props = _object_without_properties$b(_param, [
23774
+ var _param_sz = _param.sz, sz = _param_sz === void 0 ? 'sm' : _param_sz, _param_error = _param.error, error = _param_error === void 0 ? false : _param_error, _param_type = _param.type, type = _param_type === void 0 ? 'primary' : _param_type, values = _param.values, setValues = _param.setValues, placeholder = _param.placeholder, _param_chips = _param.chips, chips = _param_chips === void 0 ? false : _param_chips, props = _object_without_properties$b(_param, [
23755
23775
  "sz",
23756
23776
  "error",
23757
23777
  "type",
23758
23778
  "values",
23759
23779
  "setValues",
23760
- "placeholder"
23780
+ "placeholder",
23781
+ "chips"
23761
23782
  ]);
23783
+ var _popperRef_current;
23762
23784
  var _useState = _sliced_to_array$9(useState(''), 2), inputValue = _useState[0], setInputValue = _useState[1];
23763
23785
  var _useState1 = _sliced_to_array$9(useState(false), 2), isFocused = _useState1[0], setIsFocused = _useState1[1];
23786
+ var popperRef = useRef(null);
23787
+ var popperContentRef = useRef(null);
23788
+ useClickOutside([
23789
+ popperRef,
23790
+ popperContentRef
23791
+ ], function() {
23792
+ setIsFocused(false);
23793
+ }, isFocused);
23764
23794
  var handleKeyDown = function(e) {
23765
23795
  if (e.key === 'Enter' && inputValue.trim()) {
23766
23796
  e.preventDefault();
@@ -23781,6 +23811,7 @@ var MultiInput = function(_param) {
23781
23811
  error: error,
23782
23812
  isFocused: isFocused
23783
23813
  }, props), {
23814
+ ref: popperRef,
23784
23815
  children: [
23785
23816
  /*#__PURE__*/ jsx(BaseInput, _object_spread_props$i(_object_spread$k({}, props), {
23786
23817
  value: inputValue,
@@ -23793,12 +23824,9 @@ var MultiInput = function(_param) {
23793
23824
  sz: sz,
23794
23825
  onFocus: function() {
23795
23826
  return setIsFocused(true);
23796
- },
23797
- onBlur: function() {
23798
- return setIsFocused(false);
23799
23827
  }
23800
23828
  })),
23801
- /*#__PURE__*/ jsx(ChipWrapper, {
23829
+ chips ? /*#__PURE__*/ jsx(ChipWrapper, {
23802
23830
  sz: sz,
23803
23831
  children: values === null || values === void 0 ? void 0 : values.map(function(value, index) {
23804
23832
  return /*#__PURE__*/ jsx(MultiInputChip, {
@@ -23809,6 +23837,28 @@ var MultiInput = function(_param) {
23809
23837
  }
23810
23838
  }, value);
23811
23839
  })
23840
+ }) : /*#__PURE__*/ jsx(Popper, {
23841
+ anchorRef: popperRef,
23842
+ maxWidth: popperRef === null || popperRef === void 0 ? void 0 : (_popperRef_current = popperRef.current) === null || _popperRef_current === void 0 ? void 0 : _popperRef_current.offsetWidth,
23843
+ side: "bottom",
23844
+ align: "start",
23845
+ open: isFocused,
23846
+ onClose: function() {
23847
+ return setIsFocused(false);
23848
+ },
23849
+ containerRefOverride: popperContentRef,
23850
+ children: /*#__PURE__*/ jsx(ChipWrapper, {
23851
+ sz: sz,
23852
+ children: values === null || values === void 0 ? void 0 : values.map(function(value, index) {
23853
+ return /*#__PURE__*/ jsx(MultiInputChip, {
23854
+ label: value,
23855
+ type: type,
23856
+ onClick: function() {
23857
+ return removeValue(index);
23858
+ }
23859
+ }, value);
23860
+ })
23861
+ })
23812
23862
  })
23813
23863
  ]
23814
23864
  }));
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": "0.12.0",
5
+ "version": "0.12.1",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "publishConfig": {
@@ -8,11 +8,13 @@ export interface MultiSelectProps extends BaseSelectProps {
8
8
  setValues: (values: string[]) => void;
9
9
  options: MultiSelectOption[];
10
10
  placeholder?: string;
11
+ label?: string;
11
12
  value?: string | string[];
13
+ chips?: boolean;
12
14
  sz?: 'sm' | 'lg';
13
15
  }
14
16
  export interface ChipProps {
15
17
  sz?: 'sm' | 'lg';
16
18
  secondary?: boolean;
17
19
  }
18
- export declare const MultiSelect: ({ sz, error, options, checkbox, placeholder, values, setValues, type, ...props }: MultiSelectProps) => import("@emotion/react/jsx-runtime").JSX.Element;
20
+ export declare const MultiSelect: ({ sz, error, options, checkbox, placeholder, label, chips, values, setValues, type, ...props }: MultiSelectProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -3,10 +3,11 @@ interface MultiInputProps extends React.InputHTMLAttributes<HTMLInputElement> {
3
3
  error?: boolean;
4
4
  type?: 'primary' | 'secondary';
5
5
  isFocused?: boolean;
6
+ chips?: boolean;
6
7
  }
7
8
  export interface MultiInputValues extends MultiInputProps {
8
9
  values: string[];
9
10
  setValues: (values: string[]) => void;
10
11
  }
11
- export declare const MultiInput: ({ sz, error, type, values, setValues, placeholder, ...props }: MultiInputValues) => import("@emotion/react/jsx-runtime").JSX.Element;
12
+ export declare const MultiInput: ({ sz, error, type, values, setValues, placeholder, chips, ...props }: MultiInputValues) => import("@emotion/react/jsx-runtime").JSX.Element;
12
13
  export {};