@zextras/carbonio-design-system 2.1.0 → 2.1.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/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
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.1.1](https://github.com/Zextras/carbonio-design-system/compare/v2.1.0...v2.1.1) (2023-06-15)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **TextArea:** update label position when value change ([542cb70](https://github.com/Zextras/carbonio-design-system/commit/542cb704c652805ef0cad3035a429c1b42be4a57)), closes [#190](https://github.com/Zextras/carbonio-design-system/issues/190)
11
+
5
12
  ## [2.1.0](https://github.com/Zextras/carbonio-design-system/compare/v2.0.0...v2.1.0) (2023-05-23)
6
13
 
7
14
 
@@ -651,18 +651,18 @@ export declare interface ContainerProps extends Omit<ContainerElProps, 'orientat
651
651
  children?: React_2.ReactNode | React_2.ReactNode[];
652
652
  }
653
653
 
654
- declare type ControlledMultipleSelection = {
654
+ declare type ControlledMultipleSelection<T> = {
655
655
  multiple: true;
656
- selection: Array<SelectItem>;
656
+ selection: Array<SelectItem<T>>;
657
657
  defaultSelection?: never;
658
- onChange: MultipleSelectionOnChange;
658
+ onChange: MultipleSelectionOnChange<T>;
659
659
  };
660
660
 
661
- declare type ControlledSingleSelection = {
661
+ declare type ControlledSingleSelection<T> = {
662
662
  multiple?: false;
663
- selection: SelectItem;
663
+ selection: SelectItem<T>;
664
664
  defaultSelection?: never;
665
- onChange: SingleSelectionOnChange;
665
+ onChange: SingleSelectionOnChange<T>;
666
666
  };
667
667
 
668
668
  declare type ControlledTableProps = {
@@ -1166,14 +1166,14 @@ export declare function generateHighlightSet(fromColorSet: Parameters<typeof gen
1166
1166
  haveToPreventDefault?: boolean;
1167
1167
  };
1168
1168
 
1169
- export declare interface LabelFactoryProps {
1169
+ export declare interface LabelFactoryProps<T = string> {
1170
1170
  label: string | undefined;
1171
1171
  open: boolean;
1172
1172
  focus: boolean;
1173
- background: string | keyof DefaultTheme['palette'];
1173
+ background: string;
1174
1174
  multiple: boolean;
1175
1175
  disabled: boolean;
1176
- selected: SelectItem[];
1176
+ selected: SelectItem<T>[];
1177
1177
  }
1178
1178
 
1179
1179
  export declare const Link: React_2.ForwardRefExoticComponent<{
@@ -1453,7 +1453,7 @@ export declare function generateHighlightSet(fromColorSet: Parameters<typeof gen
1453
1453
  dropdownProps?: DropdownProps;
1454
1454
  } & Omit<ButtonProps, 'secondaryAction' | 'icon' | 'disabled'>;
1455
1455
 
1456
- export declare type MultipleSelectionOnChange = (value: Array<SelectItem>) => void;
1456
+ export declare type MultipleSelectionOnChange<T = string> = (value: Array<SelectItem<T>>) => void;
1457
1457
 
1458
1458
  declare type NonEmptyArray<T> = [T, ...T[]];
1459
1459
 
@@ -1637,13 +1637,13 @@ export declare function generateHighlightSet(fromColorSet: Parameters<typeof gen
1637
1637
  inputRef?: React_2.RefObject<HTMLInputElement>;
1638
1638
  }
1639
1639
 
1640
- export declare const Select: React_2.ForwardRefExoticComponent<SelectProps & React_2.RefAttributes<HTMLDivElement>>;
1640
+ export declare const Select: SelectType;
1641
1641
 
1642
- declare type SelectComponentProps = {
1642
+ declare type SelectComponentProps<T> = {
1643
1643
  label?: string;
1644
- background?: string | keyof DefaultTheme['palette'];
1644
+ background?: string;
1645
1645
  disabled?: boolean;
1646
- items?: SelectItem[];
1646
+ items?: SelectItem<T>[];
1647
1647
  /** Css display property of select */
1648
1648
  display?: 'block' | 'inline-block';
1649
1649
  /** Css width property of dropdown */
@@ -1652,22 +1652,24 @@ export declare function generateHighlightSet(fromColorSet: Parameters<typeof gen
1652
1652
  dropdownMaxWidth?: string;
1653
1653
  /** Css max-height property of dropdown */
1654
1654
  dropdownMaxHeight?: string;
1655
- LabelFactory?: React_2.ComponentType<LabelFactoryProps>;
1655
+ LabelFactory?: React_2.ComponentType<LabelFactoryProps<T>>;
1656
1656
  i18nAllLabel?: string;
1657
1657
  /** Flag to disable the Portal implementation of dropdown */
1658
1658
  disablePortal?: boolean;
1659
1659
  /** Whether to show checkboxes */
1660
1660
  showCheckbox?: boolean;
1661
- } & (UncontrolledMultipleSelection | ControlledMultipleSelection | UncontrolledSingleSelection | ControlledSingleSelection);
1661
+ } & (UncontrolledMultipleSelection<T> | ControlledMultipleSelection<T> | UncontrolledSingleSelection<T> | ControlledSingleSelection<T>);
1662
1662
 
1663
- export declare type SelectItem = {
1663
+ export declare type SelectItem<T = string> = {
1664
1664
  label: string;
1665
- value: string;
1665
+ value: T;
1666
1666
  disabled?: boolean;
1667
1667
  customComponent?: React_2.ReactElement;
1668
1668
  };
1669
1669
 
1670
- export declare type SelectProps = SelectComponentProps & Omit<DropdownProps, keyof SelectComponentProps | 'children'>;
1670
+ export declare type SelectProps<T = string> = SelectComponentProps<T> & Omit<DropdownProps, keyof SelectComponentProps<T> | 'children'>;
1671
+
1672
+ declare type SelectType = <T = string>(p: SelectProps<T> & React_2.RefAttributes<HTMLDivElement>) => React_2.ReactElement | null;
1671
1673
 
1672
1674
  export { setDefaultLocale }
1673
1675
 
@@ -1733,7 +1735,7 @@ export declare function generateHighlightSet(fromColorSet: Parameters<typeof gen
1733
1735
 
1734
1736
  declare type SingleItemArray<T> = [T] | [];
1735
1737
 
1736
- export declare type SingleSelectionOnChange = (value: string | null) => void;
1738
+ export declare type SingleSelectionOnChange<T = string> = (value: T | null) => void;
1737
1739
 
1738
1740
  declare const SIZES: {
1739
1741
  readonly small: 0.3125;
@@ -2121,18 +2123,18 @@ export declare function generateHighlightSet(fromColorSet: Parameters<typeof gen
2121
2123
  showCheckbox: boolean;
2122
2124
  }
2123
2125
 
2124
- declare type UncontrolledMultipleSelection = {
2126
+ declare type UncontrolledMultipleSelection<T> = {
2125
2127
  multiple: true;
2126
2128
  selection?: never;
2127
- defaultSelection?: Array<SelectItem>;
2128
- onChange: MultipleSelectionOnChange;
2129
+ defaultSelection?: Array<SelectItem<T>>;
2130
+ onChange: MultipleSelectionOnChange<T>;
2129
2131
  };
2130
2132
 
2131
- declare type UncontrolledSingleSelection = {
2133
+ declare type UncontrolledSingleSelection<T> = {
2132
2134
  multiple?: false;
2133
2135
  selection?: never;
2134
- defaultSelection?: SelectItem;
2135
- onChange: SingleSelectionOnChange;
2136
+ defaultSelection?: SelectItem<T>;
2137
+ onChange: SingleSelectionOnChange<T>;
2136
2138
  };
2137
2139
 
2138
2140
  declare type UncontrolledTableProps = {
@@ -12312,18 +12312,18 @@ const initialValue = value => {
12312
12312
  }
12313
12313
  return [];
12314
12314
  };
12315
- function selectedReducer$1(state, action) {
12316
- if (action.type === SELECT_ACTION$1.SET) {
12317
- if (action.multiple) {
12318
- return action.items;
12319
- }
12320
- return [action.item];
12321
- }
12322
- if (!action.multiple) {
12323
- const value = action.item ? [action.item] : [];
12324
- action.onChange(action.item.value);
12325
- return action.isControlled ? state : value;
12315
+ function singleSelectionReducer(state, action) {
12316
+ switch (action.type) {
12317
+ case SELECT_ACTION$1.SET:
12318
+ return [action.item];
12319
+ case SELECT_ACTION$1.PUSH:
12320
+ action.onChange(action.item.value);
12321
+ return action.isControlled && state || (action.item ? [action.item] : []);
12322
+ default:
12323
+ return state;
12326
12324
  }
12325
+ }
12326
+ function multipleSelectionReducer(state, action) {
12327
12327
  switch (action.type) {
12328
12328
  case SELECT_ACTION$1.PUSH:
12329
12329
  {
@@ -12350,11 +12350,21 @@ function selectedReducer$1(state, action) {
12350
12350
  action.onChange([]);
12351
12351
  return action.isControlled ? state : [];
12352
12352
  }
12353
+ case SELECT_ACTION$1.SET:
12354
+ {
12355
+ return action.items;
12356
+ }
12353
12357
  default:
12354
12358
  throw new Error();
12355
12359
  }
12356
12360
  }
12357
- const Select = /*#__PURE__*/React__default["default"].forwardRef(function SelectFn(_ref7, ref) {
12361
+ function selectedReducer$1(state, action) {
12362
+ return action.multiple ? multipleSelectionReducer(state, action) : singleSelectionReducer(state, action);
12363
+ }
12364
+ /**
12365
+ * @visibleName Select
12366
+ */
12367
+ const SelectComponent = /*#__PURE__*/React__default["default"].forwardRef(function SelectFn(_ref7, ref) {
12358
12368
  let {
12359
12369
  background = INPUT_BACKGROUND_COLOR,
12360
12370
  disabled = false,
@@ -12504,6 +12514,9 @@ const Select = /*#__PURE__*/React__default["default"].forwardRef(function Select
12504
12514
  })));
12505
12515
  });
12506
12516
 
12517
+ // styleguidist is not able to parse the props if the cast is made directly on the component
12518
+ const Select = SelectComponent;
12519
+
12507
12520
  const IconWrapper = styled__default["default"].div.withConfig({
12508
12521
  displayName: "Switch__IconWrapper",
12509
12522
  componentId: "sc-rsxrtl-0"
@@ -22370,6 +22383,9 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef(function Text
22370
22383
  const innerTextAreaRef = useCombinedRefs(textAreaRef);
22371
22384
  const [hasFocus, setHasFocus] = React.useState(false);
22372
22385
  const [textAreaHasValue, setTextAreaHasValue] = React.useState(!!defaultValue || !!value);
22386
+ React.useEffect(() => {
22387
+ setTextAreaHasValue(!!defaultValue || !!value);
22388
+ }, [defaultValue, value]);
22373
22389
  const [id] = React.useState(() => {
22374
22390
  if (TextArea._newId === undefined) {
22375
22391
  TextArea._newId = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zextras/carbonio-design-system",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
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",