@zextras/carbonio-design-system 1.2.0 → 2.0.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,26 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [2.0.0](https://github.com/Zextras/carbonio-design-system/compare/v1.2.0...v2.0.0) (2023-04-17)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * in Dropdown Component, items prop elements must replace click with onClick
11
+ * in Breadcrumbs component, crumbs prop elements must replace click with onClick
12
+ * **Button:** set main ref to external grid container and add buttonRef prop
13
+ to receive the ref for the main button element, in order to make events fire also on
14
+ disabled element if registered on the main ref.
15
+
16
+ ### Bug Fixes
17
+
18
+ * **Button:** change ref destination to make events fire on disabled button ([0499e78](https://github.com/Zextras/carbonio-design-system/commit/0499e78e154341a4a3c090d6a46a435dd63fc3d7)), closes [#173](https://github.com/Zextras/carbonio-design-system/issues/173)
19
+ * update default colors for input components ([03cc6a5](https://github.com/Zextras/carbonio-design-system/commit/03cc6a512fc9327969be6be5c7e1da9ffab94e17)), closes [#180](https://github.com/Zextras/carbonio-design-system/issues/180)
20
+ * wrap button to a new line to keep text readable ([b9ab57a](https://github.com/Zextras/carbonio-design-system/commit/b9ab57aef08420b253398802d24a4c90cb06f191)), closes [#179](https://github.com/Zextras/carbonio-design-system/issues/179)
21
+
22
+
23
+ * remove deprecated click prop in favor of onClick in DropdownItem ([b8fadc6](https://github.com/Zextras/carbonio-design-system/commit/b8fadc6a6a2b68b0ec6315d466f29f107f2f4a9c)), closes [#172](https://github.com/Zextras/carbonio-design-system/issues/172)
24
+
5
25
  ## [1.2.0](https://github.com/Zextras/carbonio-design-system/compare/v1.1.0...v1.2.0) (2023-02-28)
6
26
 
7
27
 
@@ -147,7 +147,7 @@ export declare interface BreadcrumbsProps extends HTMLAttributes<HTMLDivElement>
147
147
  dropdownProps?: Omit<DropdownProps, 'items' | 'children'>;
148
148
  }
149
149
 
150
- export declare const Button: React_2.ForwardRefExoticComponent<ButtonProps & React_2.RefAttributes<HTMLButtonElement>>;
150
+ export declare const Button: React_2.ForwardRefExoticComponent<ButtonProps & React_2.RefAttributes<HTMLDivElement>>;
151
151
 
152
152
  declare type ButtonColorsByType = ({
153
153
  type?: 'default' | 'outlined';
@@ -224,6 +224,8 @@ declare type ButtonPropsInternal = {
224
224
  width?: ButtonWidth;
225
225
  /** min width of the button */
226
226
  minWidth?: string;
227
+ /** Ref for the button element */
228
+ buttonRef?: React_2.Ref<HTMLButtonElement> | null;
227
229
  } & ({
228
230
  /** Size variant of the button */
229
231
  size?: 'medium' | 'large' | 'extralarge';
@@ -773,12 +775,6 @@ export declare interface DropdownItem {
773
775
  id: string;
774
776
  label: string;
775
777
  icon?: string;
776
- /**
777
- * @deprecated
778
- * Use onClick instead
779
- * TODO(BREAKING CHANGE): remove click prop
780
- */
781
- click?: (e: React_2.SyntheticEvent<HTMLElement> | KeyboardEvent) => void;
782
778
  onClick?: (e: React_2.SyntheticEvent<HTMLElement> | KeyboardEvent) => void;
783
779
  selected?: boolean;
784
780
  customComponent?: React_2.ReactNode;
@@ -883,7 +879,7 @@ export declare interface EmailComposerInputProps extends HTMLAttributes<HTMLDivE
883
879
  onChange?: (ev: React_2.ChangeEvent<HTMLInputElement>) => void;
884
880
  }
885
881
 
886
- export declare const FileLoader: React_2.ForwardRefExoticComponent<FileLoaderProps & React_2.RefAttributes<HTMLButtonElement>>;
882
+ export declare const FileLoader: React_2.ForwardRefExoticComponent<FileLoaderProps & React_2.RefAttributes<HTMLDivElement>>;
887
883
 
888
884
  export declare type FileLoaderProps = IconButtonProps & {
889
885
  onChange?: (event: React_2.ChangeEvent<HTMLInputElement>, files: FileList | null) => void;
@@ -971,7 +967,7 @@ export declare function generateHighlightSet(fromColorSet: Parameters<typeof gen
971
967
 
972
968
  export declare const Icon: StyledComponent<React_2.ForwardRefExoticComponent<IconComponentProps & React_2.RefAttributes<SVGSVGElement>>, DefaultTheme, Required<Pick<IconProps, "color" | "size">> & IconProps & React_2.SVGAttributes<SVGSVGElement>, "color" | "size">;
973
969
 
974
- export declare const IconButton: React_2.ForwardRefExoticComponent<IconButtonProps & React_2.RefAttributes<HTMLButtonElement>>;
970
+ export declare const IconButton: React_2.ForwardRefExoticComponent<IconButtonProps & React_2.RefAttributes<HTMLDivElement>>;
975
971
 
976
972
  export declare type IconButtonProps = ButtonProps & {
977
973
  /** Color of the icon */
@@ -7759,9 +7759,10 @@ const Button$1 = /*#__PURE__*/React__default["default"].forwardRef(function Butt
7759
7759
  shape = 'regular',
7760
7760
  secondaryAction,
7761
7761
  minWidth,
7762
+ buttonRef = null,
7762
7763
  ...rest
7763
7764
  } = _ref22;
7764
- const buttonRef = useCombinedRefs(ref);
7765
+ const innerButtonRef = useCombinedRefs(buttonRef);
7765
7766
  const clickHandler = React.useCallback(e => {
7766
7767
  if (!disabled && onClick && !e.defaultPrevented) {
7767
7768
  onClick(e);
@@ -7774,7 +7775,7 @@ const Button$1 = /*#__PURE__*/React__default["default"].forwardRef(function Butt
7774
7775
  e.preventDefault();
7775
7776
  }, [secondaryAction]);
7776
7777
  const keyEvents = React.useMemo(() => getKeyboardPreset('button', clickHandler), [clickHandler]);
7777
- useKeyboard(buttonRef, keyEvents);
7778
+ useKeyboard(innerButtonRef, keyEvents);
7778
7779
  const colors = React.useMemo(() => getColors(type, {
7779
7780
  type,
7780
7781
  ...rest
@@ -7782,7 +7783,8 @@ const Button$1 = /*#__PURE__*/React__default["default"].forwardRef(function Butt
7782
7783
  return /*#__PURE__*/React__default["default"].createElement(StyledGrid, {
7783
7784
  width: width,
7784
7785
  minWidth: minWidth,
7785
- padding: SIZES$2[size].padding
7786
+ padding: SIZES$2[size].padding,
7787
+ ref: ref
7786
7788
  }, /*#__PURE__*/React__default["default"].createElement(StyledButton, _extends({}, rest, {
7787
7789
  backgroundColor: colors.backgroundColor,
7788
7790
  color: colors.color,
@@ -7794,7 +7796,7 @@ const Button$1 = /*#__PURE__*/React__default["default"].forwardRef(function Butt
7794
7796
  gap: SIZES$2[size].gap,
7795
7797
  iconPlacement: iconPlacement,
7796
7798
  onClick: clickHandler,
7797
- ref: buttonRef,
7799
+ ref: innerButtonRef,
7798
7800
  width: width,
7799
7801
  minWidth: minWidth
7800
7802
  }), icon && /*#__PURE__*/React__default["default"].createElement(StyledIcon$1, {
@@ -9755,6 +9757,14 @@ function usePrevious(value) {
9755
9757
  return ref.current;
9756
9758
  }
9757
9759
 
9760
+ /*
9761
+ * SPDX-FileCopyrightText: 2023 Zextras <https://www.zextras.com>
9762
+ *
9763
+ * SPDX-License-Identifier: AGPL-3.0-only
9764
+ */
9765
+ const INPUT_BACKGROUND_COLOR = 'gray5';
9766
+ const INPUT_DIVIDER_COLOR = 'gray3';
9767
+
9758
9768
  const StyledIconButton = styled__default["default"](Button$1).withConfig({
9759
9769
  displayName: "IconButton__StyledIconButton",
9760
9770
  componentId: "sc-1bl28kg-0"
@@ -10607,9 +10617,7 @@ const Dropdown = /*#__PURE__*/React__default["default"].forwardRef(function Drop
10607
10617
  id,
10608
10618
  icon,
10609
10619
  label,
10610
- click,
10611
- onClick = click,
10612
- // TODO: remove default assignation once click prop will be removed from DropdownItem interface
10620
+ onClick,
10613
10621
  selected,
10614
10622
  customComponent,
10615
10623
  items: subItems,
@@ -11022,7 +11030,7 @@ const ChipInput = /*#__PURE__*/React__default["default"].forwardRef(function Chi
11022
11030
  onInputType,
11023
11031
  onInputTypeDebounce = 300,
11024
11032
  onAdd = DefaultOnAdd,
11025
- background = 'gray6',
11033
+ background = INPUT_BACKGROUND_COLOR,
11026
11034
  confirmChipOnBlur = true,
11027
11035
  confirmChipOnSpace = true,
11028
11036
  separators = ['Enter', 'NumpadEnter', 'Comma', 'Space'],
@@ -11041,7 +11049,7 @@ const ChipInput = /*#__PURE__*/React__default["default"].forwardRef(function Chi
11041
11049
  errorBackgroundColor,
11042
11050
  disableOptions = true,
11043
11051
  singleSelection = false,
11044
- bottomBorderColor = 'gray4',
11052
+ bottomBorderColor = INPUT_DIVIDER_COLOR,
11045
11053
  dropdownMaxHeight,
11046
11054
  description,
11047
11055
  ChipComponent,
@@ -11185,8 +11193,8 @@ const ChipInput = /*#__PURE__*/React__default["default"].forwardRef(function Chi
11185
11193
  }
11186
11194
  return map_1(options, o => ({
11187
11195
  ...o,
11188
- click: event => {
11189
- o.click && o.click(event);
11196
+ onClick: event => {
11197
+ o.onClick && o.onClick(event);
11190
11198
  onOptionClick(o.value ? o.value : o.label);
11191
11199
  }
11192
11200
  }));
@@ -11758,8 +11766,8 @@ const Input = /*#__PURE__*/React__default["default"].forwardRef(function InputFn
11758
11766
  let {
11759
11767
  autoFocus = false,
11760
11768
  autoComplete = 'off',
11761
- borderColor = 'gray2',
11762
- backgroundColor = 'gray6',
11769
+ borderColor = INPUT_DIVIDER_COLOR,
11770
+ backgroundColor = INPUT_BACKGROUND_COLOR,
11763
11771
  defaultValue,
11764
11772
  disabled = false,
11765
11773
  textColor = 'text',
@@ -12269,7 +12277,7 @@ const DefaultLabelFactory = _ref6 => {
12269
12277
  icon: open ? 'ArrowUp' : 'ArrowDown',
12270
12278
  color: disabled && 'gray2' || (open || focus) && 'primary' || 'secondary'
12271
12279
  })), /*#__PURE__*/React__default["default"].createElement(Divider, {
12272
- color: open || focus ? 'primary' : 'gray2'
12280
+ color: open || focus ? 'primary' : INPUT_DIVIDER_COLOR
12273
12281
  }));
12274
12282
  };
12275
12283
  const TabContainer = styled__default["default"](Container).withConfig({
@@ -12336,7 +12344,7 @@ function selectedReducer$1(state, action) {
12336
12344
  }
12337
12345
  const Select = /*#__PURE__*/React__default["default"].forwardRef(function SelectFn(_ref7, ref) {
12338
12346
  let {
12339
- background = 'gray5',
12347
+ background = INPUT_BACKGROUND_COLOR,
12340
12348
  disabled = false,
12341
12349
  items = [],
12342
12350
  label,
@@ -12385,7 +12393,7 @@ const Select = /*#__PURE__*/React__default["default"].forwardRef(function Select
12385
12393
  });
12386
12394
  }
12387
12395
  }, [isControlled, multiple, onChange, selected]);
12388
- const mappedItems = React.useMemo(() => items.map((item, index) => {
12396
+ const mappedItems = React.useMemo(() => map_1(items, (item, index) => {
12389
12397
  const isSelected = some_1(selected, {
12390
12398
  value: item.value
12391
12399
  });
@@ -12393,7 +12401,7 @@ const Select = /*#__PURE__*/React__default["default"].forwardRef(function Select
12393
12401
  id: `${index}-${item.label}`,
12394
12402
  label: item.label,
12395
12403
  icon: showCheckbox && (isSelected && 'CheckmarkSquare' || 'Square') || '',
12396
- click: clickItemHandler(item, isSelected),
12404
+ onClick: clickItemHandler(item, isSelected),
12397
12405
  selected: isSelected,
12398
12406
  disabled: item.disabled,
12399
12407
  customComponent: item.customComponent
@@ -12430,7 +12438,7 @@ const Select = /*#__PURE__*/React__default["default"].forwardRef(function Select
12430
12438
  id: 'all',
12431
12439
  label: i18nAllLabel,
12432
12440
  icon: showCheckbox && (isSelected && 'CheckmarkSquare' || 'Square') || '',
12433
- click: toggleSelectAll(isSelected),
12441
+ onClick: toggleSelectAll(isSelected),
12434
12442
  selected: isSelected
12435
12443
  }, ...mappedItems];
12436
12444
  }, [multiple, items, selected, i18nAllLabel, showCheckbox, toggleSelectAll, mappedItems]);
@@ -21633,7 +21641,7 @@ const DateTimePicker = /*#__PURE__*/React__default["default"].forwardRef(functio
21633
21641
  enableChips,
21634
21642
  chipProps,
21635
21643
  CustomComponent,
21636
- backgroundColor = 'gray4',
21644
+ backgroundColor = INPUT_BACKGROUND_COLOR,
21637
21645
  errorLabel = 'Error',
21638
21646
  isClearable = false,
21639
21647
  onChange,
@@ -22008,9 +22016,9 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef(function Text
22008
22016
  textAreaRef = null,
22009
22017
  label,
22010
22018
  description,
22011
- backgroundColor = 'gray5',
22019
+ backgroundColor = INPUT_BACKGROUND_COLOR,
22012
22020
  textColor = 'text',
22013
- borderColor = 'gray2',
22021
+ borderColor = INPUT_DIVIDER_COLOR,
22014
22022
  ...props
22015
22023
  } = _ref14;
22016
22024
  const {
@@ -22731,7 +22739,7 @@ const Breadcrumbs = /*#__PURE__*/React__default["default"].forwardRef(function B
22731
22739
  }, "\u2026")))), map_1(visibleCrumbs, (_ref3, index) => {
22732
22740
  let {
22733
22741
  label,
22734
- click,
22742
+ onClick,
22735
22743
  id,
22736
22744
  ...crumbProps
22737
22745
  } = _ref3;
@@ -22741,7 +22749,7 @@ const Breadcrumbs = /*#__PURE__*/React__default["default"].forwardRef(function B
22741
22749
  color: index === visibleCrumbs.length - 1 ? 'text' : 'secondary'
22742
22750
  }), /*#__PURE__*/React__default["default"].createElement(CrumbPadding, _extends({
22743
22751
  all: "extrasmall",
22744
- onClick: click
22752
+ onClick: onClick
22745
22753
  }, crumbProps), /*#__PURE__*/React__default["default"].createElement(Text, {
22746
22754
  size: "large",
22747
22755
  color: index === visibleCrumbs.length - 1 ? 'text' : 'secondary'
@@ -24399,7 +24407,7 @@ function useScreenMode() {
24399
24407
  const SnackContainer = styled__default["default"](Container).withConfig({
24400
24408
  displayName: "Snackbar__SnackContainer",
24401
24409
  componentId: "sc-p9v4vn-0"
24402
- })(["position:fixed;box-shadow:0 0 0.25rem 0 ", ";user-select:none;z-index:", ";", ";", ";"], _ref => {
24410
+ })(["position:fixed;box-shadow:0 0 0.25rem 0 ", ";user-select:none;z-index:", ";right:0;bottom:5vh;", ";"], _ref => {
24403
24411
  let {
24404
24412
  theme
24405
24413
  } = _ref;
@@ -24411,16 +24419,9 @@ const SnackContainer = styled__default["default"](Container).withConfig({
24411
24419
  return $zIndex;
24412
24420
  }, _ref3 => {
24413
24421
  let {
24414
- $screenMode,
24415
- theme
24422
+ $screenMode
24416
24423
  } = _ref3;
24417
- return $screenMode === 'desktop' && styled.css(["right:0;bottom:5vh;max-width:25rem;min-width:calc(20rem - ", " - ", ");"], theme.sizes.padding.small, theme.sizes.padding.small);
24418
- }, _ref4 => {
24419
- let {
24420
- $screenMode,
24421
- theme
24422
- } = _ref4;
24423
- return $screenMode === 'mobile' && styled.css(["right:50%;transform:translateX(50%);bottom:", ";min-width:calc(20rem - ", " - ", ");max-width:calc(100% - ", " - ", ");"], theme.sizes.padding.small, theme.sizes.padding.small, theme.sizes.padding.small, theme.sizes.padding.small, theme.sizes.padding.small);
24424
+ return $screenMode === 'mobile' && styled.css(["right:50%;transform:translateX(50%);"]);
24424
24425
  });
24425
24426
  const icons = {
24426
24427
  success: 'Checkmark',
@@ -24428,7 +24429,7 @@ const icons = {
24428
24429
  warning: 'AlertTriangleOutline',
24429
24430
  error: 'Close'
24430
24431
  };
24431
- const Snackbar = /*#__PURE__*/React__default["default"].forwardRef(function SnackbarFn(_ref5, ref) {
24432
+ const Snackbar = /*#__PURE__*/React__default["default"].forwardRef(function SnackbarFn(_ref4, ref) {
24432
24433
  let {
24433
24434
  open = false,
24434
24435
  type = 'info',
@@ -24444,7 +24445,7 @@ const Snackbar = /*#__PURE__*/React__default["default"].forwardRef(function Snac
24444
24445
  disablePortal = false,
24445
24446
  singleLine = false,
24446
24447
  ...rest
24447
- } = _ref5;
24448
+ } = _ref4;
24448
24449
  const screenMode = useScreenMode(target);
24449
24450
  const handleClick = React.useCallback(() => {
24450
24451
  onActionClick ? onActionClick() : onClose && onClose();
@@ -24466,44 +24467,56 @@ const Snackbar = /*#__PURE__*/React__default["default"].forwardRef(function Snac
24466
24467
  }, /*#__PURE__*/React__default["default"].createElement(SnackContainer, _extends({
24467
24468
  $screenMode: screenMode,
24468
24469
  orientation: "horizontal",
24469
- mainAlignment: "space-between",
24470
+ mainAlignment: "flex-start",
24470
24471
  background: type,
24471
24472
  height: "auto",
24472
24473
  width: "auto",
24473
24474
  $zIndex: zIndex,
24474
- "data-testid": "snackbar"
24475
- }, rest), /*#__PURE__*/React__default["default"].createElement(Row, {
24476
- mainAlignment: "flex-start",
24477
- takeAvailableSpace: true,
24475
+ "data-testid": "snackbar",
24478
24476
  padding: {
24479
- top: 'small',
24480
- bottom: 'small',
24481
- left: 'small'
24482
- }
24483
- }, /*#__PURE__*/React__default["default"].createElement(Icon, {
24477
+ top: '0.5rem',
24478
+ right: '0.5rem',
24479
+ bottom: '0.5rem',
24480
+ left: '1.5rem'
24481
+ },
24482
+ gap: '1rem',
24483
+ maxWidth: screenMode === 'mobile' ? '100%' : '40%'
24484
+ }, rest), /*#__PURE__*/React__default["default"].createElement(Icon, {
24484
24485
  size: "large",
24485
24486
  icon: icons[type],
24486
24487
  color: "gray6"
24487
- }), /*#__PURE__*/React__default["default"].createElement(Padding, {
24488
- left: "medium",
24489
- right: "medium",
24490
- style: {
24491
- flexBasis: 0,
24492
- flexGrow: 1,
24493
- minWidth: '0.0625rem'
24494
- }
24488
+ }), /*#__PURE__*/React__default["default"].createElement(Container, {
24489
+ gap: '1rem',
24490
+ wrap: 'wrap',
24491
+ flexBasis: 'fit-content',
24492
+ mainAlignment: 'flex-start',
24493
+ orientation: 'row'
24494
+ }, /*#__PURE__*/React__default["default"].createElement(Row, {
24495
+ mainAlignment: "flex-start",
24496
+ flexBasis: '50%',
24497
+ flexShrink: 1,
24498
+ flexGrow: 1,
24499
+ width: 'auto'
24495
24500
  }, /*#__PURE__*/React__default["default"].createElement(Text, {
24496
24501
  color: "gray6",
24497
24502
  size: "large",
24498
24503
  overflow: singleLine ? 'ellipsis' : 'break-word'
24499
- }, label))), !hideButton && /*#__PURE__*/React__default["default"].createElement(Padding, {
24500
- right: "extrasmall"
24504
+ }, label)), !hideButton && /*#__PURE__*/React__default["default"].createElement(Row, {
24505
+ margin: {
24506
+ left: 'auto',
24507
+ right: '0'
24508
+ },
24509
+ wrap: 'nowrap',
24510
+ flexGrow: 0,
24511
+ flexShrink: 0,
24512
+ minWidth: 0,
24513
+ flexBasis: 'fit-content'
24501
24514
  }, /*#__PURE__*/React__default["default"].createElement(Button$1, {
24502
24515
  label: actionLabel,
24503
24516
  type: "ghost",
24504
- labelColor: "gray6",
24517
+ color: "gray6",
24505
24518
  onClick: handleClick
24506
- })))));
24519
+ }))))));
24507
24520
  });
24508
24521
 
24509
24522
  /*
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zextras/carbonio-design-system",
3
- "version": "1.2.0",
3
+ "version": "2.0.0",
4
4
  "description": "An awesome UI for Zextras Projects.",
5
5
  "main": "dist/zapp-ui.bundle.js",
6
6
  "types": "dist/zapp-ui.bundle.d.ts",