@faststore/ui 1.6.15 → 1.6.18

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/molecules/Dropdown/Dropdown.d.ts +9 -0
  3. package/dist/molecules/Dropdown/DropdownButton.d.ts +10 -0
  4. package/dist/molecules/Dropdown/DropdownItem.d.ts +10 -0
  5. package/dist/molecules/Dropdown/DropdownMenu.d.ts +22 -0
  6. package/dist/molecules/Dropdown/contexts/DropdownContext.d.ts +41 -0
  7. package/dist/molecules/Dropdown/hooks/useDropdown.d.ts +6 -0
  8. package/dist/molecules/Dropdown/hooks/useDropdownPosition.d.ts +11 -0
  9. package/dist/molecules/Dropdown/index.d.ts +8 -0
  10. package/dist/molecules/Dropdown/stories/Dropdown.stories.d.ts +7 -0
  11. package/dist/molecules/Dropdown/stories/assets/Caret.d.ts +2 -0
  12. package/dist/ui.cjs.development.js +2 -3
  13. package/dist/ui.cjs.development.js.map +1 -1
  14. package/dist/ui.cjs.production.min.js +1 -1
  15. package/dist/ui.cjs.production.min.js.map +1 -1
  16. package/dist/ui.esm.js +2 -3
  17. package/dist/ui.esm.js.map +1 -1
  18. package/package.json +3 -3
  19. package/src/molecules/Dropdown/Dropdown.test.tsx +159 -0
  20. package/src/molecules/Dropdown/Dropdown.tsx +65 -0
  21. package/src/molecules/Dropdown/DropdownButton.tsx +42 -0
  22. package/src/molecules/Dropdown/DropdownItem.tsx +72 -0
  23. package/src/molecules/Dropdown/DropdownMenu.tsx +156 -0
  24. package/src/molecules/Dropdown/contexts/DropdownContext.ts +53 -0
  25. package/src/molecules/Dropdown/hooks/useDropdown.ts +18 -0
  26. package/src/molecules/Dropdown/hooks/useDropdownPosition.ts +26 -0
  27. package/src/molecules/Dropdown/index.ts +11 -0
  28. package/src/molecules/Dropdown/stories/Dropdown.mdx +51 -0
  29. package/src/molecules/Dropdown/stories/Dropdown.stories.tsx +94 -0
  30. package/src/molecules/Dropdown/stories/assets/Caret.tsx +19 -0
  31. package/src/molecules/Modal/ModalContent.tsx +1 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,36 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 1.6.18 (2022-03-24)
7
+
8
+
9
+ ### Features
10
+
11
+ * **api:** Add session mutation ([#1176](https://github.com/vtex/faststore/issues/1176)) ([0306167](https://github.com/vtex/faststore/commit/030616739cc62d9b5aa55cdf532ee6dea0bd793c))
12
+
13
+
14
+
15
+
16
+
17
+ ## 1.6.17 (2022-03-23)
18
+
19
+
20
+ ### Features
21
+
22
+ * **UI:** Add dropdown component ([#1178](https://github.com/vtex/faststore/issues/1178)) ([e5153a6](https://github.com/vtex/faststore/commit/e5153a674c37bd2a8b4c65ae6f56eb5cabaf3fc8))
23
+
24
+
25
+
26
+
27
+
28
+ ## 1.6.16 (2022-03-23)
29
+
30
+ **Note:** Version bump only for package @faststore/ui
31
+
32
+
33
+
34
+
35
+
6
36
  ## 1.6.15 (2022-03-22)
7
37
 
8
38
 
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from 'react';
2
+ export declare type DropdownProps = {
3
+ children: ReactNode;
4
+ onDismiss?(): void;
5
+ isOpen?: boolean;
6
+ id?: string;
7
+ };
8
+ declare const Dropdown: ({ children, isOpen: isOpenDefault, onDismiss, id, }: DropdownProps) => JSX.Element;
9
+ export default Dropdown;
@@ -0,0 +1,10 @@
1
+ import type { ButtonHTMLAttributes } from 'react';
2
+ import React from 'react';
3
+ export interface DropdownButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
4
+ /**
5
+ * ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
6
+ */
7
+ testId?: string;
8
+ }
9
+ declare const DropdownButton: React.ForwardRefExoticComponent<DropdownButtonProps & React.RefAttributes<HTMLButtonElement>>;
10
+ export default DropdownButton;
@@ -0,0 +1,10 @@
1
+ import type { ButtonHTMLAttributes } from 'react';
2
+ import React from 'react';
3
+ export interface DropdownItemProps extends ButtonHTMLAttributes<HTMLButtonElement> {
4
+ /**
5
+ * ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
6
+ */
7
+ testId?: string;
8
+ }
9
+ declare const DropdownItem: React.ForwardRefExoticComponent<DropdownItemProps & React.RefAttributes<HTMLButtonElement>>;
10
+ export default DropdownItem;
@@ -0,0 +1,22 @@
1
+ import type { AriaAttributes, KeyboardEvent, MouseEvent, PropsWithChildren, ReactElement } from 'react';
2
+ import React from 'react';
3
+ import type { ModalContentProps } from '../Modal/ModalContent';
4
+ export interface DropdownMenuProps extends ModalContentProps {
5
+ /**
6
+ * ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
7
+ */
8
+ testId?: string;
9
+ /**
10
+ * Identifies the element (or elements) that labels the current element.
11
+ * @see aria-labelledby https://www.w3.org/TR/wai-aria-1.1/#aria-labelledby
12
+ */
13
+ 'aria-labelledby'?: AriaAttributes['aria-label'];
14
+ /**
15
+ * This function is called whenever the user hits "Escape" or clicks outside
16
+ * the dialog.
17
+ */
18
+ onDismiss?: (event: MouseEvent | KeyboardEvent) => void;
19
+ children: ReactElement[];
20
+ }
21
+ declare const DropdownMenu: ({ children, testId, style, ...otherProps }: PropsWithChildren<DropdownMenuProps>) => React.ReactPortal | null;
22
+ export default DropdownMenu;
@@ -0,0 +1,41 @@
1
+ /// <reference types="react" />
2
+ export declare type DropdownContextState = {
3
+ /**
4
+ * Control de Dropdown state as Opened (true) or Closed (false).
5
+ */
6
+ isOpen: boolean;
7
+ /**
8
+ * Reference to DropdownButton, used to calculate a position for the DropdownMenu.
9
+ */
10
+ dropdownButtonRef: React.RefObject<HTMLButtonElement> | null;
11
+ /**
12
+ * Reference to a selected DropdownItem, used to manipulate focus.
13
+ */
14
+ selectedDropdownItemIndexRef: React.MutableRefObject<number> | null;
15
+ /**
16
+ * Array of References to dropdownItems in a DropdownMenu.
17
+ */
18
+ dropdownItemsRef: React.MutableRefObject<HTMLButtonElement[]> | null;
19
+ /**
20
+ * Close DropdownMenu event inherited from Modal.
21
+ */
22
+ onDismiss?(): void;
23
+ /**
24
+ * Function responsible for close the DropdownMenu in this context.
25
+ */
26
+ close?(): void;
27
+ /**
28
+ * Function responsible for open the DropdownMenu in this context.
29
+ */
30
+ open?(): void;
31
+ /**
32
+ * Function responsible for switch the the DropdownMenu state in this context.
33
+ */
34
+ toggle?(): void;
35
+ /**
36
+ * Identifier to be used in aria-controls
37
+ */
38
+ id: string;
39
+ };
40
+ declare const DropdownContext: import("react").Context<DropdownContextState>;
41
+ export default DropdownContext;
@@ -0,0 +1,6 @@
1
+ import type { DropdownContextState } from '../contexts/DropdownContext';
2
+ /**
3
+ * Hook to use the Dropdown context.
4
+ * @returns Dropdown context.
5
+ */
6
+ export declare const useDropdown: () => DropdownContextState;
@@ -0,0 +1,11 @@
1
+ declare type DropdownPosition = {
2
+ position: 'absolute';
3
+ top: number;
4
+ left: number;
5
+ };
6
+ /**
7
+ * Hook used to find the DropdownMenu position in relation to DropdownButton
8
+ * @returns Style with positions.
9
+ */
10
+ export declare const useDropdownPosition: () => DropdownPosition;
11
+ export {};
@@ -0,0 +1,8 @@
1
+ export { default } from './Dropdown';
2
+ export type { DropdownProps } from './Dropdown';
3
+ export { default as DropdownButton } from './DropdownButton';
4
+ export type { DropdownButtonProps } from './DropdownButton';
5
+ export { default as DropdownItem } from './DropdownItem';
6
+ export type { DropdownItemProps } from './DropdownItem';
7
+ export { default as DropdownMenu } from './DropdownMenu';
8
+ export type { DropdownMenuProps } from './DropdownMenu';
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { DropdownProps } from '..';
3
+ export declare const Uncontrolled: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, React.PropsWithChildren<DropdownProps>>;
4
+ export declare const Controlled: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, React.PropsWithChildren<DropdownProps>>;
5
+ export declare const Selectable: import("@storybook/csf").AnnotatedStoryFn<import("@storybook/react").ReactFramework, React.PropsWithChildren<DropdownProps>>;
6
+ declare const _default: import("@storybook/csf").ComponentAnnotations<import("@storybook/react").ReactFramework, import("@storybook/react").Args>;
7
+ export default _default;
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare const Caret: () => JSX.Element;
@@ -956,14 +956,13 @@ const ModalContentPure = ({
956
956
  tabIndex: 0,
957
957
  "aria-hidden": "true"
958
958
  }), React__default.createElement("div", Object.assign({
959
- "data-store-modal-content": true
960
- }, otherProps, {
959
+ "data-store-modal-content": true,
961
960
  "data-testid": testId,
962
961
  ref: trapFocusRef,
963
962
  "aria-modal": "true",
964
963
  role: "dialog",
965
964
  tabIndex: -1
966
- }), children), React__default.createElement("div", {
965
+ }, otherProps), children), React__default.createElement("div", {
967
966
  ref: afterElementRef,
968
967
  "data-testid": "afterElement",
969
968
  tabIndex: 0,