@zextras/carbonio-design-system 3.0.2 → 4.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,36 @@
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
+ ## [4.0.0](https://github.com/Zextras/carbonio-design-system/compare/v3.0.2...v4.0.0) (2023-11-14)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * remove KeyboardPreset type
11
+ * update the keyboard utils to accept only event-like keys
12
+ In order to migrate from the old string keys to the new event-like keys,
13
+ transform each string in an object with the previous string set as key or code
14
+ (according to its value), and the field ctrlKey set to the value of the old "modifier"
15
+ field/argument (its default was false).
16
+ * update the ChipInput separators prop to receive only event-like keys
17
+ * **ChipInput:** remove deprecated prop confirmChipOnSpace. Use separators instead
18
+ * **ChipInput:** remove deprecated errorLabel. Use description instead.
19
+ * all the placement props relative to Tooltip, Dropdown, Popper and Popover do not support auto, auto-start and auto-end anymore.
20
+
21
+ ### Features
22
+
23
+ * **ChipInput:** remove deprecated props ([e57ca80](https://github.com/Zextras/carbonio-design-system/commit/e57ca80a7034fae38847132664a3e34a573470f4)), closes [#235](https://github.com/Zextras/carbonio-design-system/issues/235)
24
+ * migrate from Popper to Floating UI ([9e8864c](https://github.com/Zextras/carbonio-design-system/commit/9e8864c0d63e9d52c85683d6f71ace5e40259aeb)), closes [#233](https://github.com/Zextras/carbonio-design-system/issues/233)
25
+ * update icon set ([da424d2](https://github.com/Zextras/carbonio-design-system/commit/da424d208692264f3a9e53512f0cb057cac3c016)), closes [#243](https://github.com/Zextras/carbonio-design-system/issues/243)
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * **ChipInput,types:** make ChipInput infer generic type from value ([88c3f63](https://github.com/Zextras/carbonio-design-system/commit/88c3f636bfdfb5c53ac75bef6950823af989ea71)), closes [#237](https://github.com/Zextras/carbonio-design-system/issues/237)
31
+ * **Drop:** remove dropzone overlay when drag leave the dropzone ([33de354](https://github.com/Zextras/carbonio-design-system/commit/33de35459da2cd64b80c51cc23b39505e4d0bf78)), closes [#234](https://github.com/Zextras/carbonio-design-system/issues/234)
32
+ * **ModalFooter:** pass the confirmDisabled prop to the ModalFooterContent component ([b04cc66](https://github.com/Zextras/carbonio-design-system/commit/b04cc665e21a75e430be06a3fc70f99b16acaf1b)), closes [#246](https://github.com/Zextras/carbonio-design-system/issues/246)
33
+ * prevent creation of chips on keyboard events with modifier ([38b470c](https://github.com/Zextras/carbonio-design-system/commit/38b470cc7f0439f7d647f32049514c0cac7bce30)), closes [#236](https://github.com/Zextras/carbonio-design-system/issues/236)
34
+
5
35
  ### [3.0.2](https://github.com/Zextras/carbonio-design-system/compare/v3.0.1...v3.0.2) (2023-10-23)
6
36
 
7
37
 
package/README.md CHANGED
@@ -20,21 +20,25 @@ SPDX-License-Identifier: AGPL-3.0-only
20
20
 
21
21
  This is the Design System and Component Library used in most of the Zextras Projects
22
22
 
23
- <h2>How To Build</h2>
23
+ <h2>Setup</h2>
24
24
 
25
- - Clone and install dependencies
25
+ - Clone the repo
26
+
27
+ - Install the dependencies:
26
28
 
27
- - Run Styleguidist in watch mode with
28
29
  ```
29
- npm run styleguide
30
+ nvm use
31
+ npm install
30
32
  ```
31
33
 
32
- - Build the Styleguide with
34
+ - Run Styleguidist in watch mode with
35
+
33
36
  ```
34
- npm run styleguide:build
37
+ npm start
35
38
  ```
36
39
 
37
40
  - Build the component library with
41
+
38
42
  ```
39
43
  npm run build
40
44
  ```
@@ -9,8 +9,7 @@ import { ForwardRefExoticComponent } from 'react';
9
9
  import { getDefaultLocale } from 'react-datepicker';
10
10
  import { HTMLAttributes } from 'react';
11
11
  import { InputHTMLAttributes } from 'react';
12
- import { Placement } from '@popperjs/core/lib/enums';
13
- import { Placement as Placement_2 } from '@popperjs/core';
12
+ import { Placement } from '@floating-ui/dom';
14
13
  import { PropsWithoutRef } from 'react';
15
14
  import { default as React_2 } from 'react';
16
15
  import { ReactDatePickerProps } from 'react-datepicker';
@@ -392,13 +391,7 @@ export declare type ChipAction = {
392
391
  type: 'icon';
393
392
  });
394
393
 
395
- declare type ChipInput<TValue> = React_2.ForwardRefExoticComponent<ChipInputProps<TValue> & React_2.RefAttributes<HTMLDivElement>> & {
396
- _newId?: number;
397
- };
398
-
399
- declare const ChipInput: ChipInput<any>;
400
- export { ChipInput }
401
- export { ChipInput as ChipInputType }
394
+ export declare const ChipInput: ChipInputType;
402
395
 
403
396
  export declare interface ChipInputProps<TValue = unknown> extends Omit<ContainerProps, 'defaultValue' | 'onChange'> {
404
397
  /** ref to the input element */
@@ -435,22 +428,12 @@ export declare interface ChipInputProps<TValue = unknown> extends Omit<Container
435
428
  onAdd?: (value: string | unknown) => ChipItem<TValue>;
436
429
  /** Set the current input text as a Chip when it loses focus */
437
430
  confirmChipOnBlur?: boolean;
438
- /**
439
- * Set the current input text as a Chip when 'Space' is pressed
440
- * @deprecated use separators prop instead
441
- */
442
- confirmChipOnSpace?: boolean;
443
431
  /** ChipInput backgroundColor */
444
432
  background?: keyof DefaultTheme['palette'];
445
433
  /** Chip generation triggers */
446
- separators?: string[];
434
+ separators?: KeyboardPresetKey[];
447
435
  /** Show the error */
448
436
  hasError?: boolean;
449
- /**
450
- * Set the label for the error
451
- * @deprecated use description instead
452
- */
453
- errorLabel?: string;
454
437
  /** Background color for the error status */
455
438
  errorBackgroundColor?: keyof DefaultTheme['palette'];
456
439
  /** Set the limit for chip inputs <br />
@@ -493,7 +476,7 @@ export declare interface ChipInputProps<TValue = unknown> extends Omit<Container
493
476
  description?: string;
494
477
  /** Custom Chip component */
495
478
  ChipComponent?: React_2.ComponentType<ChipItem<TValue>>;
496
- /** allow to create chips from pasted values */
479
+ /** allow creating chips from pasted values */
497
480
  createChipOnPaste?: boolean;
498
481
  /** Chip generation triggers on paste */
499
482
  pasteSeparators?: string[];
@@ -503,6 +486,10 @@ export declare interface ChipInputProps<TValue = unknown> extends Omit<Container
503
486
  maxHeight?: string;
504
487
  }
505
488
 
489
+ export declare type ChipInputType = (<TValue = unknown>(p: ChipInputProps<TValue> & React_2.RefAttributes<HTMLDivElement>) => React_2.ReactElement<ChipInputProps> | null) & {
490
+ _newId?: number;
491
+ };
492
+
506
493
  export declare type ChipItem<TValue = unknown> = {
507
494
  label?: string;
508
495
  } & ChipProps & {
@@ -877,7 +864,7 @@ export declare interface DropdownProps extends Omit<HTMLAttributes<HTMLDivElemen
877
864
  /** trigger ref that can be used instead of lost children ref caused by cloneElement */
878
865
  triggerRef?: React_2.Ref<HTMLElement>;
879
866
  /** Placement of the dropdown */
880
- placement?: 'auto' | 'auto-start' | 'auto-end' | 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'right' | 'right-start' | 'right-end' | 'left' | 'left-start' | 'left-end';
867
+ placement?: Placement;
881
868
  /** Flag to disable the Portal implementation */
882
869
  disablePortal?: boolean;
883
870
  /** Whether the Component is visible or not */
@@ -1006,7 +993,7 @@ export declare function generateHighlightSet(fromColorSet: Parameters<typeof gen
1006
993
 
1007
994
  export { getDefaultLocale }
1008
995
 
1009
- export declare function getKeyboardPreset(type: ElementType, callback: (e: KeyboardEvent) => void, ref?: React_2.MutableRefObject<HTMLElement | null> | undefined, keys?: string[], modifier?: boolean): KeyboardPreset;
996
+ export declare function getKeyboardPreset(type: ElementType, callback: (e: KeyboardEvent) => void, ref?: React_2.MutableRefObject<HTMLElement | null> | undefined, keys?: KeyboardPresetObj['keys']): KeyboardPresetObj[];
1010
997
 
1011
998
  declare function getPadding(padding: PaddingStringComposition | PaddingObj): (args: {
1012
999
  theme: DefaultTheme;
@@ -1186,13 +1173,12 @@ export declare function generateHighlightSet(fromColorSet: Parameters<typeof gen
1186
1173
  id: string;
1187
1174
  }
1188
1175
 
1189
- export declare type KeyboardPreset = Array<KeyboardPresetObj>;
1176
+ export declare type KeyboardPresetKey = Partial<Pick<KeyboardEvent, 'ctrlKey' | 'altKey' | 'metaKey' | 'shiftKey'>> & RequireAtLeastOne_2<Pick<KeyboardEvent, 'key' | 'code'>>;
1190
1177
 
1191
- declare type KeyboardPresetObj = {
1178
+ export declare type KeyboardPresetObj = {
1192
1179
  type: HtmlElementKeyboardEventKey;
1193
1180
  callback: (e: KeyboardEvent) => void;
1194
- keys: string[];
1195
- modifier?: boolean;
1181
+ keys: KeyboardPresetKey[];
1196
1182
  haveToPreventDefault?: boolean;
1197
1183
  };
1198
1184
 
@@ -1346,7 +1332,7 @@ export declare function generateHighlightSet(fromColorSet: Parameters<typeof gen
1346
1332
  centered?: boolean | undefined;
1347
1333
  }, never>;
1348
1334
 
1349
- export declare const ModalFooter: ({ centered, confirmColor, confirmLabel, errorActionLabel, customFooter, dismissLabel, onClose, onConfirm, onErrorAction, onSecondaryAction, optionalFooter, secondaryActionLabel, type }: ModalFooterProps) => React_2.JSX.Element;
1335
+ export declare const ModalFooter: ({ centered, confirmColor, confirmLabel, confirmDisabled, errorActionLabel, customFooter, dismissLabel, onClose, onConfirm, onErrorAction, onSecondaryAction, optionalFooter, secondaryActionLabel, type }: ModalFooterProps) => React_2.JSX.Element;
1350
1336
 
1351
1337
  export declare const ModalFooterContent: React_2.VFC<ModalFooterContentProps>;
1352
1338
 
@@ -1528,7 +1514,7 @@ export declare function generateHighlightSet(fromColorSet: Parameters<typeof gen
1528
1514
  /** Whether to disable the re-focus of Popper trigger */
1529
1515
  disableRestoreFocus?: boolean;
1530
1516
  /** Popper placement relative to the anchorEl */
1531
- placement?: Placement_2;
1517
+ placement?: Placement;
1532
1518
  /** Callback for closed Popper */
1533
1519
  onClose: () => void;
1534
1520
  /** Flag to disable the Portal implementation */
@@ -1636,6 +1622,10 @@ export declare function generateHighlightSet(fromColorSet: Parameters<typeof gen
1636
1622
  [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
1637
1623
  }[Keys];
1638
1624
 
1625
+ declare type RequireAtLeastOne_2<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
1626
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
1627
+ }[Keys];
1628
+
1639
1629
  export declare function Responsive({ children, mode, target }: ResponsiveProps): React_2.JSX.Element;
1640
1630
 
1641
1631
  export declare interface ResponsiveProps {
@@ -2078,9 +2068,9 @@ export declare function generateHighlightSet(fromColorSet: Parameters<typeof gen
2078
2068
  /** Tooltip text */
2079
2069
  label: string | React_2.ReactNode | undefined;
2080
2070
  /** Tooltip placement */
2081
- placement?: Placement_2;
2071
+ placement?: Placement;
2082
2072
  /** Fallback placements to use when tooltip cannot fit in the primary placement */
2083
- fallbackPlacements?: Placement_2[];
2073
+ fallbackPlacements?: Placement[];
2084
2074
  /** Tooltip max-width css property */
2085
2075
  maxWidth?: string;
2086
2076
  /** Whether to disable the tooltip and render only the child component */
@@ -2199,13 +2189,13 @@ export declare function generateHighlightSet(fromColorSet: Parameters<typeof gen
2199
2189
  export declare const useIsVisible: <T extends HTMLElement>(listRef: React_2.RefObject<HTMLDivElement> | undefined, itemRef?: React_2.Ref<T> | undefined) => [boolean, React_2.RefObject<T>];
2200
2190
 
2201
2191
  /**
2202
- * Attach listeners for the given events to the given ref.
2192
+ * Attach listeners for the given presets to the given ref.
2203
2193
  *
2204
- * Note: an event with the `keys` field set to an empty array is considered as an event for any key.
2205
- * In order to have an event for no key, you should either provide an event with the `keys` field set
2206
- * to an array with an empty key (`['']`), or not provide an event at all.
2194
+ * Note:
2195
+ * a preset with the `keys` field set to an empty array is considered an event for any keyboard key.
2196
+ * To avoid having listeners registered on the keyboard events, provide an empty presets array.
2207
2197
  */
2208
- export declare function useKeyboard(ref: React_2.RefObject<HTMLElement>, events: KeyboardPreset): void;
2198
+ export declare function useKeyboard(ref: React_2.RefObject<HTMLElement>, presets: KeyboardPresetObj[]): void;
2209
2199
 
2210
2200
  export declare function useModal(): CreateModalFn;
2211
2201