@faststore/components 2.0.39-alpha.0 → 2.0.42-alpha.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.
Files changed (67) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/assets/ArrowElbowDownRight.d.ts +3 -0
  3. package/dist/assets/ArrowElbowDownRight.js +8 -0
  4. package/dist/assets/ArrowElbowDownRight.js.map +1 -0
  5. package/dist/assets/index.d.ts +1 -0
  6. package/dist/assets/index.js +1 -0
  7. package/dist/assets/index.js.map +1 -1
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.js +1 -0
  10. package/dist/index.js.map +1 -1
  11. package/dist/molecules/Dropdown/Dropdown.d.ts +9 -0
  12. package/dist/molecules/Dropdown/Dropdown.js +66 -0
  13. package/dist/molecules/Dropdown/Dropdown.js.map +1 -0
  14. package/dist/molecules/Dropdown/DropdownButton.d.ts +10 -0
  15. package/dist/molecules/Dropdown/DropdownButton.js +12 -0
  16. package/dist/molecules/Dropdown/DropdownButton.js.map +1 -0
  17. package/dist/molecules/Dropdown/DropdownItem.d.ts +15 -0
  18. package/dist/molecules/Dropdown/DropdownItem.js +29 -0
  19. package/dist/molecules/Dropdown/DropdownItem.js.map +1 -0
  20. package/dist/molecules/Dropdown/DropdownMenu.d.ts +26 -0
  21. package/dist/molecules/Dropdown/DropdownMenu.js +66 -0
  22. package/dist/molecules/Dropdown/DropdownMenu.js.map +1 -0
  23. package/dist/molecules/Dropdown/contexts/DropdownContext.d.ts +41 -0
  24. package/dist/molecules/Dropdown/contexts/DropdownContext.js +11 -0
  25. package/dist/molecules/Dropdown/contexts/DropdownContext.js.map +1 -0
  26. package/dist/molecules/Dropdown/hooks/useDropdown.d.ts +6 -0
  27. package/dist/molecules/Dropdown/hooks/useDropdown.js +14 -0
  28. package/dist/molecules/Dropdown/hooks/useDropdown.js.map +1 -0
  29. package/dist/molecules/Dropdown/hooks/useDropdownPosition.d.ts +8 -0
  30. package/dist/molecules/Dropdown/hooks/useDropdownPosition.js +25 -0
  31. package/dist/molecules/Dropdown/hooks/useDropdownPosition.js.map +1 -0
  32. package/dist/molecules/Dropdown/index.d.ts +8 -0
  33. package/dist/molecules/Dropdown/index.js +5 -0
  34. package/dist/molecules/Dropdown/index.js.map +1 -0
  35. package/dist/molecules/Table/Table.d.ts +4 -6
  36. package/dist/molecules/Table/Table.js +1 -1
  37. package/dist/molecules/Table/Table.js.map +1 -1
  38. package/dist/molecules/Table/TableBody.d.ts +4 -6
  39. package/dist/molecules/Table/TableBody.js.map +1 -1
  40. package/dist/molecules/Table/TableCell.d.ts +4 -2
  41. package/dist/molecules/Table/TableCell.js +1 -1
  42. package/dist/molecules/Table/TableCell.js.map +1 -1
  43. package/dist/molecules/Table/TableFooter.d.ts +4 -6
  44. package/dist/molecules/Table/TableFooter.js.map +1 -1
  45. package/dist/molecules/Table/TableHead.d.ts +4 -6
  46. package/dist/molecules/Table/TableHead.js.map +1 -1
  47. package/dist/molecules/Table/TableRow.d.ts +4 -6
  48. package/dist/molecules/Table/TableRow.js +1 -1
  49. package/dist/molecules/Table/TableRow.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/assets/ArrowElbowDownRight.tsx +34 -0
  52. package/src/assets/index.ts +1 -0
  53. package/src/index.ts +12 -0
  54. package/src/molecules/Dropdown/Dropdown.tsx +101 -0
  55. package/src/molecules/Dropdown/DropdownButton.tsx +43 -0
  56. package/src/molecules/Dropdown/DropdownItem.tsx +75 -0
  57. package/src/molecules/Dropdown/DropdownMenu.tsx +154 -0
  58. package/src/molecules/Dropdown/contexts/DropdownContext.ts +53 -0
  59. package/src/molecules/Dropdown/hooks/useDropdown.ts +18 -0
  60. package/src/molecules/Dropdown/hooks/useDropdownPosition.ts +33 -0
  61. package/src/molecules/Dropdown/index.ts +11 -0
  62. package/src/molecules/Table/Table.tsx +21 -23
  63. package/src/molecules/Table/TableBody.tsx +14 -17
  64. package/src/molecules/Table/TableCell.tsx +29 -28
  65. package/src/molecules/Table/TableFooter.tsx +14 -17
  66. package/src/molecules/Table/TableHead.tsx +14 -17
  67. package/src/molecules/Table/TableRow.tsx +11 -17
package/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@
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
+ ## [2.0.42-alpha.0](https://github.com/vtex/faststore/compare/v2.0.41-alpha.0...v2.0.42-alpha.0) (2023-01-10)
7
+
8
+
9
+ ### Chores
10
+
11
+ * `Table` component's improvements ([#1592](https://github.com/vtex/faststore/issues/1592)) ([176a710](https://github.com/vtex/faststore/commit/176a710cf8d2917527cb4f99a8ddc956d841ae76))
12
+
13
+
14
+
15
+ ## [2.0.41-alpha.0](https://github.com/vtex/faststore/compare/v2.0.40-alpha.0...v2.0.41-alpha.0) (2023-01-10)
16
+
17
+
18
+ ### Features
19
+
20
+ * Adds `Dropdown` component ([#1572](https://github.com/vtex/faststore/issues/1572)) ([edfe557](https://github.com/vtex/faststore/commit/edfe55797d51049b137c1d8c0d648f36d3ebf980))
21
+
22
+
23
+
6
24
  ## [2.0.39-alpha.0](https://github.com/vtex/faststore/compare/v2.0.38-alpha.0...v2.0.39-alpha.0) (2023-01-09)
7
25
 
8
26
 
@@ -0,0 +1,3 @@
1
+ import type { FC } from 'react';
2
+ declare const ArrowElbowDownRight: FC;
3
+ export default ArrowElbowDownRight;
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ // Icon from Phosphor Icons
3
+ const ArrowElbowDownRight = () => (React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 256 256", fill: "currentColor", strokeWidth: "16", width: 24, height: 24 },
4
+ React.createElement("rect", { width: "256", height: "256", fill: "none" }),
5
+ React.createElement("polyline", { points: "160 128 208 176 160 224", fill: "none", stroke: "currentColor", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "16" }),
6
+ React.createElement("polyline", { points: "64 32 64 176 208 176", fill: "none", stroke: "currentColor", "stroke-linecap": "round", "stroke-linejoin": "round", "stroke-width": "16" })));
7
+ export default ArrowElbowDownRight;
8
+ //# sourceMappingURL=ArrowElbowDownRight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ArrowElbowDownRight.js","sourceRoot":"","sources":["../../src/assets/ArrowElbowDownRight.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,2BAA2B;AAC3B,MAAM,mBAAmB,GAAO,GAAG,EAAE,CAAC,CACpC,6BACE,KAAK,EAAC,4BAA4B,EAClC,OAAO,EAAC,aAAa,EACrB,IAAI,EAAC,cAAc,EACnB,WAAW,EAAC,IAAI,EAChB,KAAK,EAAE,EAAE,EACT,MAAM,EAAE,EAAE;IAEV,8BAAM,KAAK,EAAC,KAAK,EAAC,MAAM,EAAC,KAAK,EAAC,IAAI,EAAC,MAAM,GAAQ;IAClD,kCACE,MAAM,EAAC,yBAAyB,EAChC,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,oBACN,OAAO,qBACN,OAAO,kBACV,IAAI,GACP;IACZ,kCACE,MAAM,EAAC,sBAAsB,EAC7B,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,oBACN,OAAO,qBACN,OAAO,kBACV,IAAI,GACP,CACR,CACP,CAAA;AAED,eAAe,mBAAmB,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export { default as ArrowRight } from './ArrowRight';
2
+ export { default as ArrowElbowDownRight } from './ArrowElbowDownRight';
2
3
  export { default as CaretDown } from './CaretDown';
3
4
  export { default as Checked } from './Checked';
4
5
  export { default as House } from './House';
@@ -1,4 +1,5 @@
1
1
  export { default as ArrowRight } from './ArrowRight';
2
+ export { default as ArrowElbowDownRight } from './ArrowElbowDownRight';
2
3
  export { default as CaretDown } from './CaretDown';
3
4
  export { default as Checked } from './Checked';
4
5
  export { default as House } from './House';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../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AE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,CAAC,EAAE,MAAM,KAAK,CAAA;AAClC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAA"}
package/dist/index.d.ts CHANGED
@@ -33,6 +33,8 @@ export { default as IconButton } from './molecules/IconButton';
33
33
  export type { IconButtonProps } from './molecules/IconButton';
34
34
  export { default as DiscountBadge } from './molecules/DiscountBadge';
35
35
  export type { DiscountBadgeProps } from './molecules/DiscountBadge';
36
+ export { default as Dropdown, DropdownButton, DropdownItem, DropdownMenu, } from './molecules/Dropdown';
37
+ export type { DropdownProps, DropdownButtonProps, DropdownItemProps, DropdownMenuProps, } from './molecules/Dropdown';
36
38
  export { default as InputField } from './molecules/InputField';
37
39
  export type { InputFieldProps } from './molecules/InputField';
38
40
  export { default as LinkButton } from './molecules/LinkButton';
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ export { default as BuyButton } from './molecules/BuyButton';
20
20
  export { default as CheckboxField } from './molecules/CheckboxField';
21
21
  export { default as IconButton } from './molecules/IconButton';
22
22
  export { default as DiscountBadge } from './molecules/DiscountBadge';
23
+ export { default as Dropdown, DropdownButton, DropdownItem, DropdownMenu, } from './molecules/Dropdown';
23
24
  export { default as InputField } from './molecules/InputField';
24
25
  export { default as LinkButton } from './molecules/LinkButton';
25
26
  export { default as RadioField } from './molecules/RadioField';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,SAAS;AACT,cAAc,UAAU,CAAA;AAExB,QAAQ;AACR,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,eAAe,CAAA;AAEhD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAE,OAAO,IAAI,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: 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,66 @@
1
+ import React, { useRef, useMemo, useState, useEffect, useCallback } from 'react';
2
+ import DropdownContext from '../Dropdown/contexts/DropdownContext';
3
+ const Dropdown = ({ children, isOpen: isOpenDefault = false, onDismiss, id = 'fs-dropdown', }) => {
4
+ const [isOpen, setIsOpen] = useState(isOpenDefault);
5
+ const dropdownItemsRef = useRef([]);
6
+ const selectedDropdownItemIndexRef = useRef(0);
7
+ const dropdownButtonRef = useRef(null);
8
+ const close = useCallback(() => {
9
+ setIsOpen(false);
10
+ onDismiss?.();
11
+ }, [onDismiss]);
12
+ const open = () => {
13
+ setIsOpen(true);
14
+ };
15
+ const toggle = useCallback(() => {
16
+ setIsOpen((old) => {
17
+ if (old) {
18
+ onDismiss?.();
19
+ dropdownButtonRef.current?.focus();
20
+ }
21
+ return !old;
22
+ });
23
+ }, [onDismiss]);
24
+ useEffect(() => {
25
+ setIsOpen(isOpenDefault);
26
+ }, [isOpenDefault]);
27
+ useEffect(() => {
28
+ isOpen && dropdownItemsRef?.current[0]?.focus();
29
+ }, [isOpen]);
30
+ useEffect(() => {
31
+ let firstClick = true;
32
+ const event = (e) => {
33
+ const someItemWasClicked = dropdownItemsRef?.current.some((item) => e.target === item);
34
+ if (firstClick) {
35
+ firstClick = false;
36
+ return;
37
+ }
38
+ !someItemWasClicked && close();
39
+ };
40
+ if (isOpen) {
41
+ document.addEventListener('click', event);
42
+ }
43
+ else {
44
+ document.removeEventListener('click', event);
45
+ }
46
+ return () => {
47
+ document.removeEventListener('click', event);
48
+ };
49
+ }, [close, isOpen]);
50
+ const value = useMemo(() => {
51
+ return {
52
+ isOpen,
53
+ close,
54
+ open,
55
+ toggle,
56
+ dropdownButtonRef,
57
+ onDismiss,
58
+ selectedDropdownItemIndexRef,
59
+ dropdownItemsRef,
60
+ id,
61
+ };
62
+ }, [close, id, isOpen, onDismiss, toggle]);
63
+ return (React.createElement(DropdownContext.Provider, { value: value }, children));
64
+ };
65
+ export default Dropdown;
66
+ //# sourceMappingURL=Dropdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../../../src/molecules/Dropdown/Dropdown.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAEhF,OAAO,eAAe,MAAM,sCAAsC,CAAA;AASlE,MAAM,QAAQ,GAAG,CAAC,EAChB,QAAQ,EACR,MAAM,EAAE,aAAa,GAAG,KAAK,EAC7B,SAAS,EACT,EAAE,GAAG,aAAa,GACJ,EAAE,EAAE;IAClB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAA;IACnD,MAAM,gBAAgB,GAAG,MAAM,CAAsB,EAAE,CAAC,CAAA;IACxD,MAAM,4BAA4B,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IAC9C,MAAM,iBAAiB,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAA;IAEzD,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7B,SAAS,CAAC,KAAK,CAAC,CAAA;QAChB,SAAS,EAAE,EAAE,CAAA;IACf,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;IAEf,MAAM,IAAI,GAAG,GAAG,EAAE;QAChB,SAAS,CAAC,IAAI,CAAC,CAAA;IACjB,CAAC,CAAA;IAED,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QAC9B,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE;YAChB,IAAI,GAAG,EAAE;gBACP,SAAS,EAAE,EAAE,CAAA;gBACb,iBAAiB,CAAC,OAAO,EA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AAiB;YACjB,SAAS;YACT,4BAA4B;YAC5B,gBAAgB;YAChB,EAAE;SACH,CAAA;IACH,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAA;IAE1C,OAAO,CACL,oBAAC,eAAe,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,IACnC,QAAQ,CACgB,CAC5B,CAAA;AACH,CAAC,CAAA;AAED,eAAe,QAAQ,CAAA"}
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { ButtonProps } from '../../atoms/Button';
3
+ export interface DropdownButtonProps extends Omit<ButtonProps, "variant" | "inverse"> {
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,12 @@
1
+ import React, { forwardRef, useImperativeHandle } from 'react';
2
+ import Button from '../../atoms/Button';
3
+ import { useDropdown } from './hooks/useDropdown';
4
+ const DropdownButton = forwardRef(function DropdownButton({ children, testId = 'fs-dropdown-button', ...otherProps }, ref) {
5
+ const { toggle, dropdownButtonRef, isOpen, id } = useDropdown();
6
+ useImperativeHandle(ref, () => dropdownButtonRef.current, [
7
+ dropdownButtonRef,
8
+ ]);
9
+ return (React.createElement(Button, { "data-fs-dropdown-button": true, onClick: toggle, "data-testid": testId, ref: dropdownButtonRef, "aria-expanded": isOpen, "aria-haspopup": "menu", "aria-controls": id, variant: 'tertiary', ...otherProps }, children));
10
+ });
11
+ export default DropdownButton;
12
+ //# sourceMappingURL=DropdownButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropdownButton.js","sourceRoot":"","sources":["../../../src/molecules/Dropdown/DropdownButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAA;AAC9D,OAAO,MAAuB,MAAM,oBAAoB,CAAA;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAUjD,MAAM,cAAc,GAAG,UAAU,CAC/B,SAAS,cAAc,CACrB,EAAE,QAAQ,EAAE,MAAM,GAAG,oBAAoB,EAAE,GAAG,UAAU,EAAE,EAC1D,GAAG;IAEH,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW,EAAE,CAAA;IAE/D,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,iBAAkB,CAAC,OAAQ,EAAE;QAC1D,iBAAiB;KAClB,CAAC,CAAA;IAEF,OAAO,CACL,oBAAC,MAAM,qCAEL,OAAO,EAAE,MAAM,iBACF,MAAM,EACnB,GAAG,EAAE,iBAAiB,mBACP,MAAM,mBACP,MAAM,mBACL,EAAE,EACjB,OAAO,EAAC,UAAU,KACd,UAAU,IAEb,QAAQ,CACF,CACV,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,cAAc,CAAA"}
@@ -0,0 +1,15 @@
1
+ import type { ButtonHTMLAttributes } from 'react';
2
+ import { IconProps } from '../../atoms/Icon';
3
+ import React from 'react';
4
+ export interface DropdownItemProps extends ButtonHTMLAttributes<HTMLButtonElement> {
5
+ /**
6
+ * ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
7
+ */
8
+ testId?: string;
9
+ /**
10
+ * A React component that will be rendered as an icon.
11
+ */
12
+ icon?: IconProps["component"];
13
+ }
14
+ declare const DropdownItem: React.ForwardRefExoticComponent<DropdownItemProps & React.RefAttributes<HTMLButtonElement>>;
15
+ export default DropdownItem;
@@ -0,0 +1,29 @@
1
+ import Icon from '../../atoms/Icon';
2
+ import React, { useImperativeHandle, forwardRef, useRef, useState } from 'react';
3
+ import { useDropdown } from './hooks/useDropdown';
4
+ const DropdownItem = forwardRef(function Button({ children, icon, onClick, testId = 'fs-dropdown-item', ...otherProps }, ref) {
5
+ const { dropdownItemsRef, selectedDropdownItemIndexRef, close } = useDropdown();
6
+ const [dropdownItemIndex, setDropdownItemIndex] = useState(0);
7
+ const dropdownItemRef = useRef();
8
+ const addToRefs = (el) => {
9
+ if (el && !dropdownItemsRef?.current.includes(el)) {
10
+ dropdownItemsRef?.current.push(el);
11
+ setDropdownItemIndex(dropdownItemsRef?.current.findIndex((element) => element === el) ?? 0);
12
+ }
13
+ dropdownItemRef.current = el;
14
+ };
15
+ const onFocusItem = () => {
16
+ selectedDropdownItemIndexRef.current = dropdownItemIndex;
17
+ dropdownItemsRef?.current[selectedDropdownItemIndexRef.current]?.focus();
18
+ };
19
+ const handleOnClickItem = (event) => {
20
+ onClick?.(event);
21
+ close?.();
22
+ };
23
+ useImperativeHandle(ref, () => dropdownItemRef.current, []);
24
+ return (React.createElement("button", { "data-fs-dropdown-item": true, "data-testid": testId, ref: addToRefs, onFocus: onFocusItem, onMouseEnter: onFocusItem, onClick: handleOnClickItem, role: "menuitem", tabIndex: -1, "data-index": dropdownItemIndex, ...otherProps },
25
+ icon && React.createElement(Icon, { "data-fs-dropdown-item-icon": true, component: icon }),
26
+ children));
27
+ });
28
+ export default DropdownItem;
29
+ //# sourceMappingURL=DropdownItem.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropdownItem.js","sourceRoot":"","sources":["../../../src/molecules/Dropdown/DropdownItem.tsx"],"names":[],"mappings":"AACA,OAAO,IAAmB,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAcjD,MAAM,YAAY,GAAG,UAAU,CAC7B,SAAS,MAAM,CACb,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,kBAAkB,EAAE,GAAG,UAAU,EAAE,EACv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BAAiB,KACzB,UAAU;QAEb,IAAI,IAAI,oBAAC,IAAI,wCAA4B,SAAS,EAAE,IAAI,GAAI;QAC5D,QAAQ,CACF,CACV,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,YAAY,CAAA"}
@@ -0,0 +1,26 @@
1
+ import type { AriaAttributes, KeyboardEvent, PropsWithChildren, MouseEvent, ReactNode, DetailedHTMLProps, HTMLAttributes } from 'react';
2
+ import React from 'react';
3
+ type BaseModalProps = Omit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, 'ref' | 'onClick'>;
4
+ export interface DropdownMenuProps extends BaseModalProps {
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
+ /**
20
+ * Specifies the size variant
21
+ */
22
+ size?: 'small' | 'regular';
23
+ children: ReactNode[] | ReactNode;
24
+ }
25
+ declare const DropdownMenu: ({ children, testId, size, style, ...otherProps }: PropsWithChildren<DropdownMenuProps>) => React.ReactPortal | null;
26
+ export default DropdownMenu;
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import { createPortal } from 'react-dom';
3
+ import { useDropdown } from './hooks/useDropdown';
4
+ import { useDropdownPosition } from './hooks/useDropdownPosition';
5
+ /*
6
+ * This component is based on @reach/dialog.
7
+ * https://github.com/reach/reach-ui/blob/main/packages/dialog/src/index.tsx
8
+ * https://reach.tech/dialog
9
+ */
10
+ const DropdownMenu = ({ children, testId = 'fs-dropdown-menu', size = 'regular', style, ...otherProps }) => {
11
+ const { isOpen, close, dropdownItemsRef, selectedDropdownItemIndexRef, dropdownButtonRef, id } = useDropdown();
12
+ const dropdownPosition = useDropdownPosition();
13
+ const childrenLength = React.Children.toArray(children).length;
14
+ const handleDownPress = () => {
15
+ if (selectedDropdownItemIndexRef.current < childrenLength - 1) {
16
+ selectedDropdownItemIndexRef.current++;
17
+ }
18
+ else {
19
+ selectedDropdownItemIndexRef.current = 0;
20
+ }
21
+ dropdownItemsRef?.current[selectedDropdownItemIndexRef.current]?.focus();
22
+ };
23
+ const handleUpPress = () => {
24
+ if (selectedDropdownItemIndexRef.current > 0) {
25
+ selectedDropdownItemIndexRef.current--;
26
+ }
27
+ else {
28
+ selectedDropdownItemIndexRef.current = childrenLength - 1;
29
+ }
30
+ dropdownItemsRef?.current[selectedDropdownItemIndexRef.current]?.focus();
31
+ };
32
+ const handleHomePress = () => {
33
+ selectedDropdownItemIndexRef.current = 0;
34
+ dropdownItemsRef?.current[selectedDropdownItemIndexRef.current]?.focus();
35
+ };
36
+ const handleEndPress = () => {
37
+ selectedDropdownItemIndexRef.current = childrenLength - 1;
38
+ dropdownItemsRef?.current[selectedDropdownItemIndexRef.current]?.focus();
39
+ };
40
+ const handleEscapePress = () => {
41
+ close?.();
42
+ dropdownButtonRef?.current?.focus();
43
+ };
44
+ const handleBackdropKeyDown = (event) => {
45
+ if (event.defaultPrevented || event.key === 'Enter') {
46
+ return;
47
+ }
48
+ event.preventDefault();
49
+ event.key === 'Escape' && handleEscapePress();
50
+ event.key === 'ArrowDown' && handleDownPress();
51
+ event.key === 'ArrowUp' && handleUpPress();
52
+ event.key === 'Home' && handleHomePress();
53
+ event.key === 'End' && handleEndPress();
54
+ event.stopPropagation();
55
+ };
56
+ const clearChildrenReferences = () => {
57
+ dropdownItemsRef.current = [];
58
+ return null;
59
+ };
60
+ return isOpen
61
+ ? createPortal(React.createElement("div", { role: "presentation", "data-fs-dropdown-overlay": true, onKeyDown: handleBackdropKeyDown, "data-testid": `${testId}-overlay` },
62
+ React.createElement("div", { role: "menu", "aria-orientation": "vertical", "data-fs-dropdown-menu": true, "data-fs-dropdown-menu-size": size, "data-testid": testId, style: { ...dropdownPosition, ...style }, id: id, ...otherProps }, children)), document.body)
63
+ : clearChildrenReferences();
64
+ };
65
+ export default DropdownMenu;
66
+ //# sourceMappingURL=DropdownMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropdownMenu.js","sourceRoot":"","sources":["../../../src/molecules/Dropdown/DropdownMenu.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AAiCjE;;;;GAIG;AAEH,MAAM,YAAY,GAAG,CAAC,EACpB,QAAQ,EACR,MAAM,GAAG,kBAAkB,EAC3B,IAAI,GAAG,SAAS,EAChB,KAAK,EACL,GAAG,UAAU,EACwB,EAAE,EAAE;IACzC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,4BAA4B,EAAE,iBAAiB,EAAE,EAAE,EAAE,GAC5F,WAAW,EAAE,CAAA;IAEf,MAAM,gBAAgB,GAAG,mBAAmB,EAAE,CAAA;IAE9C,MAAM,cAAc,GAAG,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAA;IAE9D,MAAM,eAAe,GAAG,GAAG,EAAE;QAC3B,IAAI,4BAA6B,CAAC,OAAO,GAAG,cAAc,GAAG,CAAC,EAAE;YAC9D,4BAA6B,CAAC,OAAO,EAAE,CAAA;SACxC;aAAM;YACL,4BAA6B,CAAC,OAAO,GAAG,CAAC,CAAA;SAC1C;QAED,gBAAgB,EAAE,OAAO,CAAC,4BAA6B,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAA;IAC3E,CAAC,CAAA;IAED,MAAM,aAAa,GAAG,GAAG,EAAE;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KAAK,KAAK,IAAI,cAAc,EAAE,CAAA;QAEvC,KAAK,CAAC,eAAe,EAAE,CAAA;IACzB,CAAC,CAAA;IAED,MAAM,uBAAuB,GAAG,GAAG,EAAE;QACnC,gBAAiB,CAAC,OAAO,GAAG,EAAE,CAAA;QAE9B,OAAO,IAAI,CAAA;IACb,CAAC,CAAA;IAED,OAAO,MAAM;QACX,CAAC,CAAC,YAAY,CACV,6BACE,IAAI,EAAC,cAAc,oCAEnB,SAAS,EAAE,qBAAqB,iBACnB,GAAG,MAAM,UAAU;YAEhC,6BACE,IAAI,EAAC,MAAM,sBACM,UAAU,+DAEC,IAAI,iBACnB,MAAM,EACnB,KAAK,EAAE,EAAE,GAAG,gBAAgB,EAAE,GAAG,KAAK,EAAE,EACxC,EAAE,EAAE,EAAE,KACF,UAAU,IAEb,QAAQ,CACL,CACF,EACN,QAAQ,CAAC,IAAI,CACd;QACH,CAAC,CAAC,uBAAuB,EAAE,CAAA;AAC/B,CAAC,CAAA;AAED,eAAe,YAAY,CAAA"}
@@ -0,0 +1,41 @@
1
+ /// <reference types="react" />
2
+ export 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,11 @@
1
+ import { createContext } from 'react';
2
+ const defaultState = {
3
+ isOpen: false,
4
+ dropdownButtonRef: null,
5
+ selectedDropdownItemIndexRef: null,
6
+ dropdownItemsRef: null,
7
+ id: 'fs-dropdown',
8
+ };
9
+ const DropdownContext = createContext(defaultState);
10
+ export default DropdownContext;
11
+ //# sourceMappingURL=DropdownContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DropdownContext.js","sourceRoot":"","sources":["../../../../src/molecules/Dropdown/contexts/DropdownContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AA0CrC,MAAM,YAAY,GAAyB;IACzC,MAAM,EAAE,KAAK;IACb,iBAAiB,EAAE,IAAI;IACvB,4BAA4B,EAAE,IAAI;IAClC,gBAAgB,EAAE,IAAI;IACtB,EAAE,EAAE,aAAa;CAClB,CAAA;AAED,MAAM,eAAe,GAAG,aAAa,CAAuB,YAAY,CAAC,CAAA;AAEzE,eAAe,eAAe,CAAA"}
@@ -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,14 @@
1
+ import { useContext } from 'react';
2
+ import DropdownContext from '../contexts/DropdownContext';
3
+ /**
4
+ * Hook to use the Dropdown context.
5
+ * @returns Dropdown context.
6
+ */
7
+ export const useDropdown = () => {
8
+ const context = useContext(DropdownContext);
9
+ if (context === undefined) {
10
+ throw new Error('Do not use useDropdown hook outside the Dropdown context.');
11
+ }
12
+ return context;
13
+ };
14
+ //# sourceMappingURL=useDropdown.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDropdown.js","sourceRoot":"","sources":["../../../../src/molecules/Dropdown/hooks/useDropdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAGlC,OAAO,eAAe,MAAM,6BAA6B,CAAA;AAEzD;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,MAAM,OAAO,GAAG,UAAU,CAAuB,eAAe,CAAC,CAAA;IAEjE,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAA;KAC7E;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ type DropdownPosition = Pick<React.CSSProperties, 'position' | 'top' | 'left'>;
3
+ /**
4
+ * Hook used to find the DropdownMenu position in relation to DropdownButton
5
+ * @returns Style with positions.
6
+ */
7
+ export declare const useDropdownPosition: () => DropdownPosition;
8
+ export {};
@@ -0,0 +1,25 @@
1
+ import { useDropdown } from './useDropdown';
2
+ /**
3
+ * Hook used to find the DropdownMenu position in relation to DropdownButton
4
+ * @returns Style with positions.
5
+ */
6
+ export const useDropdownPosition = () => {
7
+ const { dropdownButtonRef } = useDropdown();
8
+ // Necessary to use this component in SSR
9
+ const isBrowser = typeof window !== 'undefined';
10
+ const buttonRect = dropdownButtonRef?.current?.getBoundingClientRect();
11
+ const topLevel = buttonRect?.top ?? 0;
12
+ const topOffset = buttonRect?.height ?? 0;
13
+ const leftLevel = buttonRect?.left ?? 0;
14
+ // The scroll properties fix the position of DropdownMenu when the scroll is activated.
15
+ const scrollTop = isBrowser ? document?.documentElement?.scrollTop : 0;
16
+ const scrollLeft = isBrowser ? document?.documentElement?.scrollLeft : 0;
17
+ const topPosition = topLevel + topOffset + scrollTop;
18
+ const leftPosition = leftLevel + scrollLeft;
19
+ return {
20
+ position: 'absolute',
21
+ top: topPosition,
22
+ left: leftPosition,
23
+ };
24
+ };
25
+ //# sourceMappingURL=useDropdownPosition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDropdownPosition.js","sourceRoot":"","sources":["../../../../src/molecules/Dropdown/hooks/useDropdownPosition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAI3C;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAqB,EAAE;IACxD,MAAM,EAAE,iBAAiB,EAAE,GAAG,WAAW,EAAE,CAAA;IAE3C,yCAAyC;IACzC,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAA;IAE/C,MAAM,UAAU,GAAG,iBAAiB,EAAE,OAAO,EAAE,qBAAqB,EAAE,CAAA;IACtE,MAAM,QAAQ,GAAG,UAAU,EAAE,GAAG,IAAI,CAAC,CAAA;IACrC,MAAM,SAAS,GAAG,UAAU,EAAE,MAAM,IAAI,CAAC,CAAA;IACzC,MAAM,SAAS,GAAG,UAAU,EAAE,IAAI,IAAI,CAAC,CAAA;IAEvC,uFAAuF;IACvF,MAAM,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IACtE,MAAM,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,QAAQ,EAAE,eAAe,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IAExE,MAAM,WAAW,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAA;IAEpD,MAAM,YAAY,GAAG,SAAS,GAAG,UAAU,CAAA;IAE3C,OAAO;QACL,QAAQ,EAAE,UAAU;QACpB,GAAG,EAAE,WAAW;QAChB,IAAI,EAAE,YAAY;KACnB,CAAA;AACH,CAAC,CAAA"}
@@ -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,5 @@
1
+ export { default } from './Dropdown';
2
+ export { default as DropdownButton } from './DropdownButton';
3
+ export { default as DropdownItem } from './DropdownItem';
4
+ export { default as DropdownMenu } from './DropdownMenu';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/molecules/Dropdown/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAGpC,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAG5D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAGxD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA"}
@@ -1,18 +1,16 @@
1
- import type { TableHTMLAttributes } from 'react';
2
1
  import React from 'react';
2
+ import type { TableHTMLAttributes } from 'react';
3
3
  export interface TableProps extends TableHTMLAttributes<HTMLTableElement> {
4
4
  /**
5
5
  * ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
6
6
  */
7
7
  testId?: string;
8
- /**
9
- * Children for Table components.
10
- */
11
- children: React.ReactNode;
12
8
  /**
13
9
  * Defines what style this component should use.
14
10
  */
15
11
  variant?: 'colored' | 'bordered';
16
12
  }
17
- declare const Table: React.ForwardRefExoticComponent<TableProps & React.RefAttributes<HTMLTableElement>>;
13
+ declare const Table: React.ForwardRefExoticComponent<TableProps & {
14
+ children?: React.ReactNode;
15
+ } & React.RefAttributes<HTMLTableElement>>;
18
16
  export default Table;
@@ -1,5 +1,5 @@
1
1
  import React, { forwardRef } from 'react';
2
- const Table = forwardRef(function Table({ variant = 'colored', testId = 'fs-table', children, ...otherProps }, ref) {
2
+ const Table = forwardRef(function Table({ children, variant = 'colored', testId = 'fs-table', ...otherProps }, ref) {
3
3
  return (React.createElement("div", { "data-fs-table": true },
4
4
  React.createElement("table", { ref: ref, "data-fs-table-content": true, "data-fs-table-variant": variant, "data-testid": testId, ...otherProps }, children)));
5
5
  });
@@ -1 +1 @@
1
- {"version":3,"file":"Table.js","sourceRoot":"","sources":["../../../src/molecules/Table/Table.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAiBzC,MAAM,KAAK,GAAG,UAAU,CAA+B,SAAS,KAAK,CACnE,EAAE,OAAO,GAAG,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,EACrE,GAAG;IAEH,OAAO,CACL;QACE,+BACE,GAAG,EAAE,GAAG,0DAEe,OAAO,iBACjB,MAAM,KACf,UAAU,IAEb,QAAQ,CACH,CACJ,CACP,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,eAAe,KAAK,CAAA"}
1
+ {"version":3,"file":"Table.js","sourceRoot":"","sources":["../../../src/molecules/Table/Table.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAczC,MAAM,KAAK,GAAG,UAAU,CACtB,SAAS,KAAK,CACZ,EAAE,QAAQ,EAAE,OAAO,GAAG,SAAS,EAAE,MAAM,GAAG,UAAU,EAAE,GAAG,UAAU,EAAE,EACrE,GAAG;IAEH,OAAO,CACL;QACE,+BACE,GAAG,EAAE,GAAG,0DAEe,OAAO,iBACjB,MAAM,KACf,UAAU,IAEb,QAAQ,CACH,CACJ,CACP,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,KAAK,CAAA"}
@@ -1,14 +1,12 @@
1
- import type { HTMLAttributes } from 'react';
2
1
  import React from 'react';
2
+ import type { HTMLAttributes } from 'react';
3
3
  export interface TableBodyProps extends HTMLAttributes<HTMLTableSectionElement> {
4
4
  /**
5
5
  * ID to find this component in testing tools (e.g.: cypress, testing library, and jest).
6
6
  */
7
7
  testId?: string;
8
- /**
9
- * Children for TableBody components.
10
- */
11
- children: React.ReactNode;
12
8
  }
13
- declare const TableBody: React.ForwardRefExoticComponent<TableBodyProps & React.RefAttributes<HTMLTableSectionElement>>;
9
+ declare const TableBody: React.ForwardRefExoticComponent<TableBodyProps & {
10
+ children?: React.ReactNode;
11
+ } & React.RefAttributes<HTMLTableSectionElement>>;
14
12
  export default TableBody;
@@ -1 +1 @@
1
- {"version":3,"file":"TableBody.js","sourceRoot":"","sources":["../../../src/molecules/Table/TableBody.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAczC,MAAM,SAAS,GAAG,UAAU,CAC1B,SAAS,SAAS,CAChB,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,EAAE,GAAG,UAAU,EAAE,EACrD,GAAG;IAEH,OAAO,CACL,+BAAO,GAAG,EAAE,GAAG,iBAAe,MAAM,iCAAyB,UAAU,IACpE,QAAQ,CACH,CACT,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,SAAS,CAAA"}
1
+ {"version":3,"file":"TableBody.js","sourceRoot":"","sources":["../../../src/molecules/Table/TableBody.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAWzC,MAAM,SAAS,GAAG,UAAU,CAG1B,SAAS,SAAS,CAClB,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,EAAE,GAAG,UAAU,EAAE,EACrD,GAAG;IAEH,OAAO,CACL,+BAAO,GAAG,EAAE,GAAG,iBAAe,MAAM,iCAAyB,UAAU,IACpE,QAAQ,CACH,CACT,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,eAAe,SAAS,CAAA"}
@@ -1,5 +1,5 @@
1
- import type { HTMLAttributes } from 'react';
2
1
  import React from 'react';
2
+ import type { HTMLAttributes } from 'react';
3
3
  type TableCellVariant = 'data' | 'header';
4
4
  export interface TableCellProps extends HTMLAttributes<HTMLTableCellElement> {
5
5
  /**
@@ -20,5 +20,7 @@ export interface TableCellProps extends HTMLAttributes<HTMLTableCellElement> {
20
20
  */
21
21
  align?: 'left' | 'center' | 'right';
22
22
  }
23
- declare const TableCell: React.ForwardRefExoticComponent<TableCellProps & React.RefAttributes<HTMLTableCellElement>>;
23
+ declare const TableCell: React.ForwardRefExoticComponent<TableCellProps & {
24
+ children?: React.ReactNode;
25
+ } & React.RefAttributes<HTMLTableCellElement>>;
24
26
  export default TableCell;
@@ -1,5 +1,5 @@
1
1
  import React, { forwardRef } from 'react';
2
- const TableCell = forwardRef(function TableCell({ testId = 'fs-table-cell', children, variant = 'data', scope, align, ...otherProps }, ref) {
2
+ const TableCell = forwardRef(function TableCell({ scope, align, children, variant = 'data', testId = 'fs-table-cell', ...otherProps }, ref) {
3
3
  const Cell = variant === 'header' ? 'th' : 'td';
4
4
  return (React.createElement(Cell, { ref: ref, "data-fs-table-cell": variant, "data-fs-table-cell-align": align, "data-testid": testId, scope: scope, ...otherProps }, children));
5
5
  });
@@ -1 +1 @@
1
- {"version":3,"file":"TableCell.js","sourceRoot":"","sources":["../../../src/molecules/Table/TableCell.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAwBzC,MAAM,SAAS,GAAG,UAAU,CAC1B,SAAS,SAAS,CAChB,EACE,MAAM,GAAG,eAAe,EACxB,QAAQ,EACR,OAAO,GAAG,MAAM,EAChB,KAAK,EACL,KAAK,EACL,GAAG,UAAU,EACd,EACD,GAAG;IAEH,MAAM,IAAI,GAAG,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA;IAE/C,OAAO,CACL,oBAAC,IAAI,IACH,GAAG,EAAE,GAAG,wBACY,OAAO,8BACD,KAAK,iBAClB,MAAM,EACnB,KAAK,EAAE,KAAK,KACR,UAAU,IAEb,QAAQ,CACJ,CACR,CAAA;AACH,CAAC,CACF,CAAA;AAED,eAAe,SAAS,CAAA"}
1
+ {"version":3,"file":"TableCell.js","sourceRoot":"","sources":["../../../src/molecules/Table/TableCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAyBzC,MAAM,SAAS,GAAG,UAAU,CAG1B,SAAS,SAAS,CAClB,EACE,KAAK,EACL,KAAK,EACL,QAAQ,EACR,OAAO,GAAG,MAAM,EAChB,MAAM,GAAG,eAAe,EACxB,GAAG,UAAU,EACd,EACD,GAAG;IAEH,MAAM,IAAI,GAAG,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAA;IAE/C,OAAO,CACL,oBAAC,IAAI,IACH,GAAG,EAAE,GAAG,wBACY,OAAO,8BACD,KAAK,iBAClB,MAAM,EACnB,KAAK,EAAE,KAAK,KACR,UAAU,IAEb,QAAQ,CACJ,CACR,CAAA;AACH,CAAC,CAAC,CAAA;AAEF,eAAe,SAAS,CAAA"}