@paubox/ui 0.8.1 → 0.8.3

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
@@ -1637,7 +1637,7 @@ function _templateObject3$7() {
1637
1637
  };
1638
1638
  return data;
1639
1639
  }
1640
- function _templateObject4$4() {
1640
+ function _templateObject4$5() {
1641
1641
  var data = _tagged_template_literal$o([
1642
1642
  "\n ",
1643
1643
  "\n font-size: ",
@@ -1645,7 +1645,7 @@ function _templateObject4$4() {
1645
1645
  "rem;\n letter-spacing: ",
1646
1646
  "px;\n font-weight: 600;\n"
1647
1647
  ]);
1648
- _templateObject4$4 = function _templateObject() {
1648
+ _templateObject4$5 = function _templateObject() {
1649
1649
  return data;
1650
1650
  };
1651
1651
  return data;
@@ -1928,7 +1928,7 @@ var commonStyles = css(_templateObject$o());
1928
1928
  var $headline100Regular = css(_templateObject1$d(), commonStyles, headline100FontSize / BASE_FONT_SIZE, headline100LineHeight / BASE_FONT_SIZE, headline100LetterSpacing);
1929
1929
  var $headline100Semibold = css(_templateObject2$a(), commonStyles, headline100FontSize / BASE_FONT_SIZE, headline100LineHeight / BASE_FONT_SIZE, headline100LetterSpacing);
1930
1930
  var $headline200Regular = css(_templateObject3$7(), commonStyles, headline200FontSize / BASE_FONT_SIZE, headline200LineHeight / BASE_FONT_SIZE, headline200LetterSpacing);
1931
- var $headline200Semibold = css(_templateObject4$4(), commonStyles, headline200FontSize / BASE_FONT_SIZE, headline200LineHeight / BASE_FONT_SIZE, headline200LetterSpacing);
1931
+ var $headline200Semibold = css(_templateObject4$5(), commonStyles, headline200FontSize / BASE_FONT_SIZE, headline200LineHeight / BASE_FONT_SIZE, headline200LetterSpacing);
1932
1932
  var $headline300Regular = css(_templateObject5$3(), commonStyles, headline300FontSize / BASE_FONT_SIZE, headline300LineHeight / BASE_FONT_SIZE, headline300LetterSpacing);
1933
1933
  var $headline300Semibold = css(_templateObject6$3(), commonStyles, headline300FontSize / BASE_FONT_SIZE, headline300LineHeight / BASE_FONT_SIZE, headline300LetterSpacing);
1934
1934
  // PARAGRAPH
@@ -2080,12 +2080,12 @@ function _templateObject3$6() {
2080
2080
  };
2081
2081
  return data;
2082
2082
  }
2083
- function _templateObject4$3() {
2083
+ function _templateObject4$4() {
2084
2084
  var data = _tagged_template_literal$n([
2085
2085
  "\n background-color: ",
2086
2086
  ";\n "
2087
2087
  ]);
2088
- _templateObject4$3 = function _templateObject() {
2088
+ _templateObject4$4 = function _templateObject() {
2089
2089
  return data;
2090
2090
  };
2091
2091
  return data;
@@ -2152,7 +2152,7 @@ var AlertBar = function(props) {
2152
2152
  var textStyles = css(_templateObject2$9(), $paragraph200Regular);
2153
2153
  var alertStyles = {
2154
2154
  info: css(_templateObject3$6(), primary100),
2155
- warning: css(_templateObject4$3(), warning100),
2155
+ warning: css(_templateObject4$4(), warning100),
2156
2156
  error: css(_templateObject5$2(), danger100),
2157
2157
  success: css(_templateObject6$2(), success100)
2158
2158
  };
@@ -2400,13 +2400,15 @@ var IconWrapper$3 = styled.span(_templateObject$l(), function(props) {
2400
2400
  return props.iconLeft ? '0 8px 0 0' : props.iconRight ? '0 0 0 8px' : '0';
2401
2401
  });
2402
2402
  var Button = /*#__PURE__*/ forwardRef(function(_param, ref) {
2403
- var IconLeft = _param.iconLeft, IconRight = _param.iconRight, children = _param.children, props = _object_without_properties$i(_param, [
2403
+ var IconLeft = _param.iconLeft, IconRight = _param.iconRight, _param_type = _param.type, type = _param_type === void 0 ? 'button' : _param_type, children = _param.children, props = _object_without_properties$i(_param, [
2404
2404
  "iconLeft",
2405
2405
  "iconRight",
2406
+ "type",
2406
2407
  "children"
2407
2408
  ]);
2408
2409
  return /*#__PURE__*/ jsxs(BaseButton, _object_spread_props$n(_object_spread$t({
2409
- ref: ref
2410
+ ref: ref,
2411
+ type: type
2410
2412
  }, props), {
2411
2413
  children: [
2412
2414
  IconLeft && /*#__PURE__*/ jsx(IconWrapper$3, {
@@ -22359,8 +22361,7 @@ function _tagged_template_literal$f(strings, raw) {
22359
22361
  }
22360
22362
  function _templateObject$f() {
22361
22363
  var data = _tagged_template_literal$f([
22362
- "\n cursor: pointer;\n width: 100%;\n padding: 0 0.5rem;\n display: flex;\n flex-direction: row;\n box-sizing: border-box;\n white-space: nowrap;\n gap: 0.5rem;\n\n &:hover {\n background-color: ",
22363
- ";\n }\n "
22364
+ "\n cursor: pointer;\n width: 100%;\n display: flex;\n flex-direction: row;\n align-items: center;\n box-sizing: border-box;\n white-space: nowrap;\n gap: 0.5rem;\n "
22364
22365
  ]);
22365
22366
  _templateObject$f = function _templateObject() {
22366
22367
  return data;
@@ -22369,8 +22370,8 @@ function _templateObject$f() {
22369
22370
  }
22370
22371
  function _templateObject1$a() {
22371
22372
  var data = _tagged_template_literal$f([
22372
- "\n cursor: pointer;\n background-color: transparent;\n text-align: left;\n border: none;\n padding: 1rem 0.625rem;\n white-space: nowrap;\n width: 100%;\n ",
22373
- "\n "
22373
+ "\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 0 0.5rem;\n &:hover {\n background-color: ",
22374
+ ";\n }\n "
22374
22375
  ]);
22375
22376
  _templateObject1$a = function _templateObject() {
22376
22377
  return data;
@@ -22379,7 +22380,8 @@ function _templateObject1$a() {
22379
22380
  }
22380
22381
  function _templateObject2$7() {
22381
22382
  var data = _tagged_template_literal$f([
22382
- "\n display: flex;\n align-items: center;\n justify-content: center;\n "
22383
+ "\n cursor: pointer;\n background-color: transparent;\n text-align: left;\n border: none;\n padding: 1rem 0.625rem;\n white-space: nowrap;\n width: 100%;\n ",
22384
+ "\n "
22383
22385
  ]);
22384
22386
  _templateObject2$7 = function _templateObject() {
22385
22387
  return data;
@@ -22388,44 +22390,65 @@ function _templateObject2$7() {
22388
22390
  }
22389
22391
  function _templateObject3$5() {
22390
22392
  var data = _tagged_template_literal$f([
22391
- "\n display: inline-block;\n width: 100%;\n "
22393
+ "\n display: flex;\n align-items: center;\n justify-content: center;\n "
22392
22394
  ]);
22393
22395
  _templateObject3$5 = function _templateObject() {
22394
22396
  return data;
22395
22397
  };
22396
22398
  return data;
22397
22399
  }
22400
+ function _templateObject4$3() {
22401
+ var data = _tagged_template_literal$f([
22402
+ "\n display: inline-block;\n width: 100%;\n "
22403
+ ]);
22404
+ _templateObject4$3 = function _templateObject() {
22405
+ return data;
22406
+ };
22407
+ return data;
22408
+ }
22398
22409
  var DropdownOption = function(param) {
22399
- var label = param.label, href = param.href, onClick = param.onClick, icon = param.icon;
22400
- var dropdownOptionStyles = css(_templateObject$f(), primary100);
22401
- var optionStyles = css(_templateObject1$a(), $paragraph200Regular);
22402
- var iconStyles = css(_templateObject2$7());
22403
- var dropdownOptionWrapper = css(_templateObject3$5());
22410
+ var label = param.label, href = param.href, selected = param.selected, checkbox = param.checkbox, onClick = param.onClick, icon = param.icon;
22411
+ var dropdownOptionStyles = css(_templateObject$f());
22412
+ var checkboxStyles = css(_templateObject1$a(), primary100);
22413
+ var optionStyles = css(_templateObject2$7(), $paragraph200Regular);
22414
+ var iconStyles = css(_templateObject3$5());
22415
+ var dropdownOptionWrapper = css(_templateObject4$3());
22404
22416
  return /*#__PURE__*/ jsx("div", {
22405
22417
  css: dropdownOptionWrapper,
22406
22418
  children: /*#__PURE__*/ jsxs("div", {
22407
- css: dropdownOptionStyles,
22419
+ css: checkboxStyles,
22408
22420
  children: [
22409
- icon && /*#__PURE__*/ jsx("div", {
22410
- css: iconStyles,
22411
- children: icon
22412
- }),
22413
- href ? /*#__PURE__*/ jsx("a", {
22414
- css: optionStyles,
22415
- href: href,
22421
+ checkbox && /*#__PURE__*/ jsx(Checkbox, {
22422
+ checked: selected,
22416
22423
  onClick: function() {
22417
22424
  return onClick === null || onClick === void 0 ? void 0 : onClick();
22418
- },
22419
- children: /*#__PURE__*/ jsx("div", {
22420
- children: label
22421
- })
22422
- }) : /*#__PURE__*/ jsx("button", {
22423
- css: optionStyles,
22424
- type: "button",
22425
- onClick: function() {
22426
- return onClick === null || onClick === void 0 ? void 0 : onClick();
22427
- },
22428
- children: label
22425
+ }
22426
+ }),
22427
+ /*#__PURE__*/ jsxs("div", {
22428
+ css: dropdownOptionStyles,
22429
+ children: [
22430
+ icon && /*#__PURE__*/ jsx("div", {
22431
+ css: iconStyles,
22432
+ children: icon
22433
+ }),
22434
+ href ? /*#__PURE__*/ jsx("a", {
22435
+ css: optionStyles,
22436
+ href: href,
22437
+ onClick: function() {
22438
+ return onClick === null || onClick === void 0 ? void 0 : onClick();
22439
+ },
22440
+ children: /*#__PURE__*/ jsx("div", {
22441
+ children: label
22442
+ })
22443
+ }) : /*#__PURE__*/ jsx("button", {
22444
+ css: optionStyles,
22445
+ type: "button",
22446
+ onClick: function() {
22447
+ return onClick === null || onClick === void 0 ? void 0 : onClick();
22448
+ },
22449
+ children: label
22450
+ })
22451
+ ]
22429
22452
  })
22430
22453
  ]
22431
22454
  })
@@ -22872,11 +22895,13 @@ function _templateObject1$8() {
22872
22895
  function _templateObject2$5() {
22873
22896
  var data = _tagged_template_literal$d([
22874
22897
  "\n flex: 1;\n cursor: pointer;\n border: 1px solid\n ",
22875
- ";\n background-color: ",
22898
+ ";\n\n background-color: ",
22876
22899
  ";\n border-radius: 0.5rem;\n -webkit-appearance: none;\n -moz-appearance: none;\n &::-ms-expand {\n display: none;\n }\n color: ",
22877
22900
  ";\n padding: ",
22878
22901
  ";\n outline: none;\n &::placeholder {\n color: ",
22879
22902
  ";\n opacity: 0.3;\n }\n transition: all 150ms ease-in-out;\n\n &:focus-within {\n border-color: ",
22903
+ ";\n }\n\n &:hover {\n background-color: ",
22904
+ ";\n }\n\n &:focus {\n background-color: ",
22880
22905
  ";\n }\n\n ",
22881
22906
  "\n"
22882
22907
  ]);
@@ -22931,11 +22956,11 @@ var InputWrapper = styled.div(_templateObject$d());
22931
22956
  var DropdownWrapper = styled.div(_templateObject1$8());
22932
22957
  // Style for the Select itself
22933
22958
  var BaseSelect = styled.select(_templateObject2$5(), function(param) {
22934
- var error = param.error, disabled = param.disabled;
22935
- return error && !disabled ? danger600 : neutral200;
22959
+ var error = param.error, disabled = param.disabled, type = param.type;
22960
+ return type === 'primary' ? error && !disabled ? danger600 : neutral200 : error && !disabled ? danger600 : 'transparent';
22936
22961
  }, function(param) {
22937
- var disabled = param.disabled;
22938
- return disabled ? neutral100 : 'white';
22962
+ var disabled = param.disabled, type = param.type;
22963
+ return disabled || type === 'secondary' ? neutral100 : 'white';
22939
22964
  }, textPrimary, function(param) {
22940
22965
  var sz = param.sz;
22941
22966
  return sz === 'lg' ? '0.5rem 0.563rem' : '0.375rem 0.563rem';
@@ -22943,18 +22968,28 @@ var BaseSelect = styled.select(_templateObject2$5(), function(param) {
22943
22968
  var error = param.error;
22944
22969
  return error ? danger600 : primary600;
22945
22970
  }, function(param) {
22946
- var sz = param.sz;
22947
- return sz === 'lg' ? $paragraph100Regular : $paragraph200Regular;
22971
+ var type = param.type;
22972
+ return type === 'primary' ? neutral100 : neutral200;
22973
+ }, function(param) {
22974
+ var type = param.type;
22975
+ return type === 'primary' ? neutral100 : neutral200;
22976
+ }, function(param) {
22977
+ var sz = param.sz, type = param.type;
22978
+ return type === 'primary' ? sz === 'lg' ? $paragraph100Regular : $paragraph200Regular : sz === 'lg' ? $paragraph100Semibold : $paragraph200Semibold;
22948
22979
  });
22949
- var Chip = styled.button(_templateObject3$4(), neutral100, $label200Medium);
22980
+ var Chip = styled.button(_templateObject3$4(), function(param) {
22981
+ var secondary = param.secondary;
22982
+ return secondary ? neutral300 : neutral100;
22983
+ }, $label200Medium);
22950
22984
  var ChipWrapper = styled.div(_templateObject4$2(), function(param) {
22951
22985
  var sz = param.sz;
22952
22986
  return sz === 'lg' ? '0.5rem 0.563rem' : '0.375rem 0.563rem';
22953
22987
  });
22954
22988
  var MultiSelectChip = function(option) {
22955
- var label = option.label, onClick = option.onClick;
22989
+ var label = option.label, onClick = option.onClick, _option_type = option.type, type = _option_type === void 0 ? 'primary' : _option_type;
22956
22990
  return /*#__PURE__*/ jsxs(Chip, {
22957
22991
  onClick: onClick,
22992
+ secondary: type === 'secondary',
22958
22993
  children: [
22959
22994
  label,
22960
22995
  /*#__PURE__*/ jsx(Cancel, {})
@@ -22963,15 +22998,21 @@ var MultiSelectChip = function(option) {
22963
22998
  };
22964
22999
  // Style for the Icons
22965
23000
  var IconWrapper$1 = styled.span(_templateObject5$1());
22966
- var PlaceholderOption = styled.option(_templateObject6$1(), $paragraph100Regular, textSecondary);
23001
+ var PlaceholderOption = styled.option(_templateObject6$1(), $paragraph100Semibold, textSecondary);
22967
23002
  var MultiSelect = function(_param) {
22968
- 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, props = _object_without_properties$a(_param, [
23003
+ 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, initialValue = _param.initialValue, _param_type = _param.type, type = _param_type === void 0 ? 'primary' : _param_type, props = _object_without_properties$a(_param, [
22969
23004
  "sz",
22970
23005
  "error",
22971
- "options"
23006
+ "options",
23007
+ "checkbox",
23008
+ "placeholder",
23009
+ "initialValue",
23010
+ "type"
22972
23011
  ]);
22973
23012
  var _useState = _sliced_to_array$7(useState(false), 2), open = _useState[0], setOpen = _useState[1];
22974
- var _useState1 = _sliced_to_array$7(useState([]), 2), values = _useState1[0], setValues = _useState1[1];
23013
+ var _useState1 = _sliced_to_array$7(useState(initialValue ? [
23014
+ initialValue
23015
+ ] : []), 2), values = _useState1[0], setValues = _useState1[1];
22975
23016
  var toggleSelect = function(option) {
22976
23017
  setValues(function(prevValues) {
22977
23018
  if (prevValues.some(function(val) {
@@ -22991,6 +23032,7 @@ var MultiSelect = function(_param) {
22991
23032
  /*#__PURE__*/ jsxs(InputWrapper, {
22992
23033
  children: [
22993
23034
  /*#__PURE__*/ jsx(BaseSelect, _object_spread_props$d(_object_spread$h({}, props), {
23035
+ type: type,
22994
23036
  onMouseDown: function(e) {
22995
23037
  setOpen(!open);
22996
23038
  e.stopPropagation();
@@ -23000,7 +23042,8 @@ var MultiSelect = function(_param) {
23000
23042
  value: "",
23001
23043
  disabled: true,
23002
23044
  hidden: true,
23003
- children: "Please select..."
23045
+ selected: true,
23046
+ children: "".concat(placeholder || 'Please select...')
23004
23047
  })
23005
23048
  })),
23006
23049
  /*#__PURE__*/ jsx(IconWrapper$1, {
@@ -23010,6 +23053,7 @@ var MultiSelect = function(_param) {
23010
23053
  sz: sz,
23011
23054
  children: values.map(function(option) {
23012
23055
  return /*#__PURE__*/ jsx(MultiSelectChip, _object_spread_props$d(_object_spread$h({}, option), {
23056
+ type: type,
23013
23057
  onClick: function() {
23014
23058
  return toggleSelect(option);
23015
23059
  }
@@ -23024,7 +23068,12 @@ var MultiSelect = function(_param) {
23024
23068
  bottom: 110,
23025
23069
  children: /*#__PURE__*/ jsx(Fragment, {
23026
23070
  children: options.map(function(option) {
23027
- return /*#__PURE__*/ jsx(DropdownOption, _object_spread_props$d(_object_spread$h({}, option), {
23071
+ return /*#__PURE__*/ jsx(DropdownOption, _object_spread_props$d(_object_spread$h({
23072
+ checkbox: true,
23073
+ selected: values.some(function(val) {
23074
+ return val.value === option.value;
23075
+ })
23076
+ }, option), {
23028
23077
  onClick: function() {
23029
23078
  return toggleSelect(option);
23030
23079
  }
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.8.1",
5
+ "version": "0.8.3",
6
6
  "type": "module",
7
7
  "private": false,
8
8
  "publishConfig": {
@@ -1,5 +1,5 @@
1
1
  import { CSSProperties, MouseEventHandler } from 'react';
2
- export interface BaseButtonProps {
2
+ export interface BaseButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3
3
  color?: 'primary' | 'secondary' | 'danger';
4
4
  disabled?: boolean;
5
5
  size?: 'large' | 'small';
@@ -3,5 +3,7 @@ export interface DropdownOptionProps {
3
3
  href?: string;
4
4
  onClick?: () => void;
5
5
  icon?: React.ReactNode;
6
+ selected?: boolean;
7
+ checkbox?: boolean;
6
8
  }
7
- export declare const DropdownOption: ({ label, href, onClick, icon, }: DropdownOptionProps) => import("@emotion/react/jsx-runtime").JSX.Element;
9
+ export declare const DropdownOption: ({ label, href, selected, checkbox, onClick, icon, }: DropdownOptionProps) => import("@emotion/react/jsx-runtime").JSX.Element;
@@ -8,8 +8,12 @@ export interface MultiSelectProps extends React.InputHTMLAttributes<HTMLSelectEl
8
8
  leftIcon?: React.ElementType;
9
9
  rightIcon?: React.ElementType;
10
10
  options?: MultiSelectOption[];
11
+ checkbox?: boolean;
12
+ initialValue?: MultiSelectOption;
13
+ type?: 'primary' | 'secondary';
11
14
  }
12
15
  export interface ChipProps {
13
16
  sz?: 'sm' | 'lg';
17
+ secondary?: boolean;
14
18
  }
15
- export declare const MultiSelect: ({ sz, error, options, ...props }: MultiSelectProps) => import("@emotion/react/jsx-runtime").JSX.Element;
19
+ export declare const MultiSelect: ({ sz, error, options, checkbox, placeholder, initialValue, type, ...props }: MultiSelectProps) => import("@emotion/react/jsx-runtime").JSX.Element;