@ndlib/component-library 0.0.8 → 0.0.14

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 (134) hide show
  1. package/README.md +101 -0
  2. package/dist/FontLoader.d.ts +1 -0
  3. package/dist/FontLoader.js +4 -0
  4. package/dist/components/composites/Card/Card.stories.d.ts +9 -0
  5. package/dist/components/composites/Card/Card.stories.js +77 -0
  6. package/dist/components/composites/Card/Card.test.d.ts +1 -0
  7. package/dist/components/composites/Card/Card.test.js +29 -0
  8. package/dist/components/composites/Card/index.d.ts +22 -0
  9. package/dist/components/composites/Card/index.js +71 -0
  10. package/dist/components/elements/Alerts/Alert.stories.d.ts +9 -0
  11. package/dist/components/elements/Alerts/Alert.stories.js +41 -0
  12. package/dist/components/elements/Alerts/Alerts.stories.d.ts +6 -0
  13. package/dist/components/elements/Alerts/Alerts.stories.js +12 -0
  14. package/dist/components/elements/Alerts/Alerts.test.d.ts +1 -0
  15. package/dist/components/elements/Alerts/Alerts.test.js +62 -0
  16. package/dist/components/elements/Alerts/index.d.ts +15 -0
  17. package/dist/components/elements/Alerts/index.js +63 -0
  18. package/dist/components/elements/BrandingBar/BrandingBar.stories.d.ts +6 -0
  19. package/dist/components/elements/BrandingBar/BrandingBar.stories.js +11 -0
  20. package/dist/components/elements/BrandingBar/index.d.ts +1 -0
  21. package/dist/components/elements/BrandingBar/index.js +52 -0
  22. package/dist/components/elements/Button/Button.stories.d.ts +4 -0
  23. package/dist/components/elements/Button/Button.stories.js +42 -9
  24. package/dist/components/elements/Button/Button.test.js +11 -2
  25. package/dist/components/elements/Button/index.d.ts +16 -11
  26. package/dist/components/elements/Button/index.js +84 -34
  27. package/dist/components/elements/Fields/Checkbox/Checkbox.stories.d.ts +6 -0
  28. package/dist/components/elements/Fields/Checkbox/Checkbox.stories.js +17 -0
  29. package/dist/components/elements/Fields/Checkbox/index.d.ts +9 -0
  30. package/dist/components/elements/Fields/Checkbox/index.js +22 -0
  31. package/dist/components/elements/Fields/CheckboxGroup/CheckboxGroup.stories.d.ts +6 -0
  32. package/dist/components/elements/Fields/CheckboxGroup/CheckboxGroup.stories.js +23 -0
  33. package/dist/components/elements/Fields/CheckboxGroup/index.d.ts +14 -0
  34. package/dist/components/elements/Fields/CheckboxGroup/index.js +35 -0
  35. package/dist/components/elements/Fields/Radio/Radio.stories.d.ts +6 -0
  36. package/dist/components/elements/Fields/Radio/Radio.stories.js +17 -0
  37. package/dist/components/elements/Fields/Radio/index.d.ts +9 -0
  38. package/dist/components/elements/Fields/Radio/index.js +22 -0
  39. package/dist/components/elements/Fields/RadioGroup/RadioGroup.stories.d.ts +6 -0
  40. package/dist/components/elements/Fields/RadioGroup/RadioGroup.stories.js +23 -0
  41. package/dist/components/elements/Fields/RadioGroup/index.d.ts +14 -0
  42. package/dist/components/elements/Fields/RadioGroup/index.js +28 -0
  43. package/dist/components/elements/Fields/Select/Select.stories.d.ts +6 -0
  44. package/dist/components/elements/Fields/Select/Select.stories.js +32 -0
  45. package/dist/components/elements/Fields/Select/index.d.ts +16 -0
  46. package/dist/components/elements/Fields/Select/index.js +136 -0
  47. package/dist/components/elements/Fields/TextInput/TextInput.stories.d.ts +6 -0
  48. package/dist/components/elements/Fields/TextInput/TextInput.stories.js +25 -0
  49. package/dist/components/elements/Fields/TextInput/index.d.ts +17 -0
  50. package/dist/components/elements/Fields/TextInput/index.js +60 -0
  51. package/dist/components/elements/Fields/option.d.ts +15 -0
  52. package/dist/components/elements/Fields/option.js +3 -0
  53. package/dist/components/elements/Group/index.js +3 -3
  54. package/dist/components/elements/Icon/Icon.stories.d.ts +7 -0
  55. package/dist/components/elements/Icon/Icon.stories.js +29 -0
  56. package/dist/components/elements/Icon/Icon.test.d.ts +1 -0
  57. package/dist/components/elements/Icon/Icon.test.js +26 -0
  58. package/dist/components/elements/Icon/index.d.ts +11 -0
  59. package/dist/components/elements/Icon/index.js +25 -0
  60. package/dist/components/elements/Link/Link.stories.js +3 -3
  61. package/dist/components/elements/Link/Link.test.js +13 -13
  62. package/dist/components/elements/Link/index.d.ts +2 -2
  63. package/dist/components/elements/Link/index.js +4 -4
  64. package/dist/components/elements/List/List.stories.d.ts +9 -0
  65. package/dist/components/elements/List/List.stories.js +31 -0
  66. package/dist/components/elements/List/List.test.d.ts +1 -0
  67. package/dist/components/elements/List/List.test.js +24 -0
  68. package/dist/components/elements/List/index.d.ts +21 -0
  69. package/dist/components/elements/List/index.js +75 -0
  70. package/dist/components/elements/ListBox/Listbox.stories.d.ts +6 -0
  71. package/dist/components/elements/ListBox/Listbox.stories.js +17 -0
  72. package/dist/components/elements/ListBox/index.d.ts +32 -0
  73. package/dist/components/elements/ListBox/index.js +50 -0
  74. package/dist/components/elements/Markdown/Markdown.stories.d.ts +6 -0
  75. package/dist/components/elements/Markdown/Markdown.stories.js +53 -0
  76. package/dist/components/elements/Markdown/Markdown.test.d.ts +1 -0
  77. package/dist/components/elements/Markdown/Markdown.test.js +58 -0
  78. package/dist/components/elements/Markdown/index.d.ts +7 -0
  79. package/dist/components/elements/Markdown/index.js +50 -0
  80. package/dist/components/elements/layout/Box.d.ts +1 -1
  81. package/dist/components/elements/layout/Box.stories.js +1 -1
  82. package/dist/components/elements/layout/Column.d.ts +2 -2
  83. package/dist/components/elements/layout/Column.js +2 -2
  84. package/dist/components/elements/layout/Flex.stories.js +2 -2
  85. package/dist/components/elements/layout/Flex.test.js +2 -2
  86. package/dist/components/elements/layout/Row.d.ts +2 -2
  87. package/dist/components/elements/layout/Row.js +1 -1
  88. package/dist/components/elements/text/Heading/Heading.stories.js +10 -11
  89. package/dist/components/elements/text/Heading/Heading.test.js +1 -1
  90. package/dist/components/elements/text/Heading/index.d.ts +6 -4
  91. package/dist/components/elements/text/Heading/index.js +19 -13
  92. package/dist/components/elements/text/Inline/Inline.stories.d.ts +6 -0
  93. package/dist/components/elements/text/Inline/Inline.stories.js +13 -0
  94. package/dist/components/elements/text/Inline/index.d.ts +7 -0
  95. package/dist/components/elements/text/Inline/index.js +21 -0
  96. package/dist/components/elements/text/Label/Label.stories.js +3 -3
  97. package/dist/components/elements/text/Label/Label.test.js +2 -2
  98. package/dist/components/elements/text/Label/index.d.ts +3 -3
  99. package/dist/components/elements/text/Label/index.js +4 -4
  100. package/dist/components/elements/text/Paragraph/Paragraph.stories.js +2 -2
  101. package/dist/components/elements/text/Paragraph/Paragraph.test.js +1 -1
  102. package/dist/components/elements/text/Paragraph/index.d.ts +2 -2
  103. package/dist/components/elements/text/Paragraph/index.js +2 -2
  104. package/dist/components/providers/alerts.d.ts +41 -0
  105. package/dist/components/providers/alerts.js +133 -0
  106. package/dist/components/providers/componentConfig.d.ts +3 -3
  107. package/dist/components/providers/componentConfig.js +5 -4
  108. package/dist/components/providers/env.d.ts +1 -1
  109. package/dist/components/providers/env.js +3 -3
  110. package/dist/components/providers/theme.js +1 -1
  111. package/dist/components/providers/ui.d.ts +7 -3
  112. package/dist/components/providers/ui.js +8 -6
  113. package/dist/index.d.ts +6 -1
  114. package/dist/index.js +6 -1
  115. package/dist/theme/Color.stories.js +18 -2
  116. package/dist/theme/Typography.stories.d.ts +6 -0
  117. package/dist/theme/Typography.stories.js +43 -0
  118. package/dist/theme/colors.d.ts +12 -1
  119. package/dist/theme/colors.js +22 -0
  120. package/dist/theme/custom.d.ts +3 -0
  121. package/dist/theme/custom.js +5 -0
  122. package/dist/theme/index.d.ts +139 -4
  123. package/dist/theme/index.js +18 -12
  124. package/dist/theme/typography.d.ts +47 -6
  125. package/dist/theme/typography.js +74 -36
  126. package/dist/utils/hooks/useStorage.d.ts +14 -0
  127. package/dist/utils/hooks/useStorage.js +31 -0
  128. package/dist/utils/hooks/useUniqueHtmlId.d.ts +1 -0
  129. package/dist/utils/hooks/useUniqueHtmlId.js +7 -0
  130. package/dist/utils/misc.d.ts +7 -0
  131. package/dist/utils/misc.js +13 -1
  132. package/dist/utils/test.js +3 -1
  133. package/global.css +4 -9
  134. package/package.json +21 -13
@@ -1,4 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import SearchIcon from '@mui/icons-material/Search';
3
+ import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
4
+ import SettingsIcon from '@mui/icons-material/Settings';
2
5
  import { BUTTON_SIZE, BUTTON_TYPE, Button } from '.';
3
6
  import { GROUP_TYPE, Group } from '../Group';
4
7
  import { HEADING_SIZE, Heading } from '../text/Heading';
@@ -16,24 +19,54 @@ const sizes = [
16
19
  { size: BUTTON_SIZE.SM, label: 'Small' },
17
20
  ];
18
21
  export const Default = {
19
- render: (args) => (_jsx(Column, { children: sizes.map(size => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, { children: size.label })), _jsx(Button, Object.assign({}, args, { size: size.size, sx: { mt: 1 } }))] })))) })),
22
+ render: (args) => (_jsx(Column, { children: sizes.map((size) => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, { children: size.label })), _jsx(Button, Object.assign({}, args, { size: size.size, sx: { mt: 1 } }))] })))) })),
20
23
  args: {
21
24
  type: BUTTON_TYPE.DEFAULT,
22
- children: "Click Me"
23
- }
25
+ children: 'Click Me',
26
+ },
24
27
  };
25
28
  export const CustomColor = {
26
- render: (args) => (_jsx(Column, { children: sizes.map(size => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, { children: size.label })), _jsx(Button, Object.assign({}, args, { size: size.size, color: COLOR.SECONDARY, sx: { mt: 1 } }))] })))) })),
29
+ render: (args) => (_jsx(Column, { children: sizes.map((size) => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, { children: size.label })), _jsx(Button, Object.assign({}, args, { size: size.size, color: COLOR.SECONDARY, sx: { mt: 1 } }))] })))) })),
27
30
  args: {
28
31
  type: BUTTON_TYPE.DEFAULT,
29
- children: "Click Me"
30
- }
32
+ children: 'Click Me',
33
+ },
34
+ };
35
+ export const OutlineButton = {
36
+ render: (args) => (_jsx(Column, { children: sizes.map((size) => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, { children: size.label })), _jsx(Button, Object.assign({}, args, { size: size.size, sx: { mt: 1 } }))] })))) })),
37
+ args: {
38
+ type: BUTTON_TYPE.OUTLINE,
39
+ children: 'Click Me',
40
+ onClick: () => { },
41
+ },
31
42
  };
32
43
  export const TextButton = {
33
- render: (args) => (_jsx(Column, { children: sizes.map(size => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, { children: size.label })), _jsx(Button, Object.assign({}, args, { size: size.size, sx: { mt: 1 } }))] })))) })),
44
+ render: (args) => (_jsx(Column, { children: sizes.map((size) => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, { children: size.label })), _jsx(Button, Object.assign({}, args, { size: size.size, sx: { mt: 1 } }))] })))) })),
45
+ args: {
46
+ type: BUTTON_TYPE.TEXT,
47
+ onClick: () => { },
48
+ children: 'Click Me',
49
+ },
50
+ };
51
+ export const IconButton = {
52
+ render: (args) => (_jsx(Column, { children: sizes.map((size) => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, { children: size.label })), _jsx(Button, Object.assign({}, args, { size: size.size, sx: { mt: 1 }, primaryIcon: SettingsIcon }))] })))) })),
34
53
  args: {
35
54
  type: BUTTON_TYPE.TEXT,
55
+ children: 'Click Me',
56
+ onClick: () => { },
57
+ },
58
+ };
59
+ export const LeftIcon = {
60
+ render: (args) => (_jsx(Column, { children: sizes.map((size) => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, { children: size.label })), _jsx(Button, Object.assign({}, args, { size: size.size, sx: { mt: 1 }, leftIcon: SearchIcon }))] })))) })),
61
+ args: {
62
+ onClick: () => { },
63
+ children: 'Search',
64
+ },
65
+ };
66
+ export const RightIcon = {
67
+ render: (args) => (_jsx(Column, { children: sizes.map((size) => (_jsxs(Group, Object.assign({ type: GROUP_TYPE.REGION }, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, { children: size.label })), _jsx(Button, Object.assign({}, args, { size: size.size, sx: { mt: 1 }, rightIcon: ArrowDropDownIcon }))] })))) })),
68
+ args: {
36
69
  onClick: () => { },
37
- children: "Click Me"
38
- }
70
+ children: 'Select',
71
+ },
39
72
  };
@@ -1,8 +1,11 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { fireEvent } from '@testing-library/react';
3
3
  import { vi } from 'vitest';
4
4
  import { render } from '../../../utils/test';
5
- import { Button } from ".";
5
+ import { Button } from '.';
6
+ const MockPrimaryIcon = () => _jsx("div", { children: "Mock Primary Icon" });
7
+ const MockLeftIcon = () => _jsx("div", { children: "Mock Left Icon" });
8
+ const MockRightIcon = () => _jsx("div", { children: "Mock Right Icon" });
6
9
  describe('Button', () => {
7
10
  const mockClickHandler = vi.fn();
8
11
  afterEach(() => {
@@ -12,6 +15,12 @@ describe('Button', () => {
12
15
  const { getByText } = render(_jsx(Button, { children: "Foo" }));
13
16
  expect(getByText('Foo')).toBeInTheDocument();
14
17
  });
18
+ it('renders icon component passed to it', () => {
19
+ const { getByText } = render(_jsxs(_Fragment, { children: [_jsx(Button, Object.assign({ leftIcon: MockLeftIcon }, { children: "Click Me" })), _jsx(Button, Object.assign({ primaryIcon: MockPrimaryIcon }, { children: "Click Me" })), _jsx(Button, Object.assign({ rightIcon: MockRightIcon }, { children: "Click Me" }))] }));
20
+ expect(getByText('Mock Primary Icon')).toBeDefined();
21
+ expect(getByText('Mock Left Icon')).toBeDefined();
22
+ expect(getByText('Mock Right Icon')).toBeDefined();
23
+ });
15
24
  it('responds to click handlers', () => {
16
25
  const { getByRole } = render(_jsx(Button, { onClick: mockClickHandler }));
17
26
  fireEvent.click(getByRole('button'));
@@ -1,7 +1,6 @@
1
1
  /** @jsxImportSource theme-ui */
2
- import React from "react";
3
- import { StyledElementProps } from "../../../theme";
4
- import { COLOR } from "../../../theme/colors";
2
+ import React from 'react';
3
+ import { COLOR } from '../../../theme/colors';
5
4
  export declare enum BUTTON_SIZE {
6
5
  SM = "sm",
7
6
  MD = "md",
@@ -9,12 +8,18 @@ export declare enum BUTTON_SIZE {
9
8
  }
10
9
  export declare enum BUTTON_TYPE {
11
10
  DEFAULT = "default",
12
- TEXT = "text"
11
+ TEXT = "text",
12
+ OUTLINE = "outline"
13
13
  }
14
- type ButtonProps = StyledElementProps<HTMLButtonElement, {
15
- size?: BUTTON_SIZE;
16
- type?: BUTTON_TYPE;
17
- color?: COLOR;
18
- }>;
19
- export declare const Button: React.FC<ButtonProps>;
20
- export {};
14
+ export declare const Button: React.ForwardRefExoticComponent<{
15
+ sx?: import("../../../theme").StylesProp | undefined;
16
+ children?: React.ReactNode;
17
+ } & React.HTMLAttributes<HTMLButtonElement> & {
18
+ size?: BUTTON_SIZE | undefined;
19
+ type?: BUTTON_TYPE | undefined;
20
+ color?: COLOR | undefined;
21
+ primaryIcon?: React.FC<any> | undefined;
22
+ leftIcon?: React.FC<any> | undefined;
23
+ rightIcon?: React.FC<any> | undefined;
24
+ accessibleLabel?: string | undefined;
25
+ } & React.RefAttributes<HTMLButtonElement>>;
@@ -9,9 +9,14 @@ var __rest = (this && this.__rest) || function (s, e) {
9
9
  }
10
10
  return t;
11
11
  };
12
- import { jsx as _jsx } from "theme-ui/jsx-runtime";
13
- import { COLOR, colors } from "../../../theme/colors";
14
- import { TYPOGRAPHY_TYPE, getTypographyStyles } from "../../../theme/typography";
12
+ import { jsx as _jsx, jsxs as _jsxs } from "theme-ui/jsx-runtime";
13
+ /** @jsxImportSource theme-ui */
14
+ import React, { useState } from 'react';
15
+ import { useTheme } from '../../../theme';
16
+ import { COLOR, colors } from '../../../theme/colors';
17
+ import { TYPOGRAPHY_TYPE, getIconSize, getTypographyStyles, } from '../../../theme/typography';
18
+ import { Icon } from '../Icon';
19
+ import { useEnvironment } from '../../providers/env';
15
20
  export var BUTTON_SIZE;
16
21
  (function (BUTTON_SIZE) {
17
22
  BUTTON_SIZE["SM"] = "sm";
@@ -28,55 +33,100 @@ const defaultPaddingX = {
28
33
  [BUTTON_SIZE.MD]: 3,
29
34
  [BUTTON_SIZE.LG]: 3,
30
35
  };
31
- const defaultPaddingY = {
36
+ const defaultHeight = {
37
+ [BUTTON_SIZE.SM]: '2rem',
38
+ [BUTTON_SIZE.MD]: '2.5rem',
39
+ [BUTTON_SIZE.LG]: '3rem',
40
+ };
41
+ const iconMargin = {
32
42
  [BUTTON_SIZE.SM]: 1,
33
- [BUTTON_SIZE.MD]: 1,
34
- [BUTTON_SIZE.LG]: 2
43
+ [BUTTON_SIZE.MD]: 2,
44
+ [BUTTON_SIZE.LG]: 2,
35
45
  };
36
46
  export var BUTTON_TYPE;
37
47
  (function (BUTTON_TYPE) {
38
48
  BUTTON_TYPE["DEFAULT"] = "default";
39
49
  BUTTON_TYPE["TEXT"] = "text";
50
+ BUTTON_TYPE["OUTLINE"] = "outline";
40
51
  // ARROW
41
52
  })(BUTTON_TYPE || (BUTTON_TYPE = {}));
42
- export const Button = (_a) => {
43
- var { size: sizeParam, type: typeParam, color, sx } = _a, rest = __rest(_a, ["size", "type", "color", "sx"]);
53
+ export const Button = React.forwardRef((_a, ref) => {
54
+ var { size: sizeParam, type: typeParam, color, primaryIcon, leftIcon, rightIcon, children, sx } = _a, rest = __rest(_a, ["size", "type", "color", "primaryIcon", "leftIcon", "rightIcon", "children", "sx"]);
55
+ const theme = useTheme();
56
+ const [hover, setHover] = useState(false);
57
+ const { flagInDevelopment } = useEnvironment();
44
58
  let bg = COLOR.PRIMARY;
45
- let highlightColor = COLOR.PRIMARY_HIGHLIGHT;
59
+ let hoverBg = COLOR.PRIMARY_HIGHLIGHT;
46
60
  let textColor = COLOR.TEXT;
47
- let highlightTextColor = undefined;
61
+ let hoverTextColor = undefined;
62
+ let borderColor = COLOR.TRANSPARENT;
63
+ let hoverShadow = theme.boxShadow.NORMAL;
64
+ let hoverDecoration = undefined;
65
+ let hoverTransform = 'scale(1.03)';
66
+ const isTextButton = typeParam === BUTTON_TYPE.TEXT;
67
+ const isIconButton = primaryIcon;
48
68
  const type = typeParam || BUTTON_TYPE.DEFAULT;
49
69
  const size = sizeParam || BUTTON_SIZE.MD;
70
+ const paddingX = isIconButton || isTextButton ? 0 : defaultPaddingX[size];
71
+ const height = isTextButton ? undefined : defaultHeight[size];
72
+ const width = primaryIcon ? height : undefined;
73
+ // const height = width;
74
+ if (isIconButton && !rest['aria-label']) {
75
+ flagInDevelopment('Icon buttons should include aria-label prop for accessibility');
76
+ }
77
+ if (isIconButton) {
78
+ hoverTransform = 'scale(1.15)';
79
+ }
50
80
  if (type === BUTTON_TYPE.DEFAULT) {
51
81
  bg = color || COLOR.PRIMARY;
52
- highlightColor = bg === COLOR.PRIMARY
53
- ? COLOR.PRIMARY_HIGHLIGHT
54
- : bg === COLOR.SECONDARY
55
- ? COLOR.SECONDARY_HIGHLIGHT
56
- : bg;
57
- textColor = bg === COLOR.PRIMARY
58
- ? COLOR.TEXT_ON_PRIMARY
59
- : bg === COLOR.SECONDARY
60
- ? COLOR.TEXT_ON_SECONDARY
61
- : COLOR.TEXT;
82
+ hoverBg =
83
+ bg === COLOR.PRIMARY
84
+ ? COLOR.PRIMARY_HIGHLIGHT
85
+ : bg === COLOR.SECONDARY
86
+ ? COLOR.SECONDARY_HIGHLIGHT
87
+ : bg;
88
+ textColor =
89
+ bg === COLOR.PRIMARY
90
+ ? COLOR.TEXT_ON_PRIMARY
91
+ : bg === COLOR.SECONDARY
92
+ ? COLOR.TEXT_ON_SECONDARY
93
+ : COLOR.TEXT;
94
+ hoverTextColor = textColor;
62
95
  }
63
96
  if (type === BUTTON_TYPE.TEXT) {
64
97
  bg = COLOR.TRANSPARENT;
98
+ hoverBg = bg;
65
99
  textColor = color || COLOR.PRIMARY;
66
- highlightColor = textColor === COLOR.PRIMARY
67
- ? COLOR.PRIMARY
68
- : textColor === COLOR.SECONDARY
69
- ? COLOR.SECONDARY
70
- : bg;
71
- highlightTextColor = COLOR.BACKGROUND;
100
+ hoverTextColor = textColor;
101
+ hoverShadow = undefined;
102
+ hoverDecoration = 'underline';
103
+ }
104
+ if (type === BUTTON_TYPE.OUTLINE) {
105
+ bg = COLOR.BACKGROUND;
106
+ hoverBg = COLOR.BACKGROUND;
107
+ textColor = color || COLOR.PRIMARY;
108
+ hoverTextColor = textColor;
109
+ borderColor = textColor;
72
110
  }
73
111
  const typography = typographyMap[size];
74
- return (_jsx("button", Object.assign({ sx: Object.assign(Object.assign({ bg: bg || colors.primary, color: textColor, px: defaultPaddingX[size], py: defaultPaddingY[size], border: 'none', borderRadius: '4px', ":hover": {
75
- bg: highlightColor,
76
- color: highlightTextColor,
112
+ const typographyStyles = getTypographyStyles(typography);
113
+ return (_jsxs("button", Object.assign({ ref: ref, onMouseEnter: () => {
114
+ setHover(true);
115
+ }, onMouseLeave: () => {
116
+ setHover(false);
117
+ }, sx: Object.assign(Object.assign({ bg: bg || colors.primary, color: textColor, px: paddingX, width: width, height: height, border: 'solid 1px', borderRadius: '4px', borderColor, display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'center', ':hover': {
118
+ bg: hoverBg,
119
+ color: hoverTextColor,
120
+ boxShadow: hoverShadow,
77
121
  cursor: 'pointer',
78
- }, ":focus": {
79
- bg: highlightColor,
80
- color: highlightTextColor
81
- } }, getTypographyStyles(typography)), sx) }, rest)));
82
- };
122
+ transform: hoverTransform,
123
+ textDecoration: hoverDecoration,
124
+ } }, typographyStyles), sx) }, rest, { children: [leftIcon && (_jsx(Icon, { icon: leftIcon, size: typographyStyles.fontSize, sx: { mr: iconMargin[size] }, color: hover ? hoverTextColor : textColor })), _jsx("div", Object.assign({ css: {
125
+ flexGrow: 1,
126
+ justifyContent: 'flex-start',
127
+ textOverflow: 'ellipsis',
128
+ whiteSpace: 'nowrap',
129
+ overflow: 'hidden',
130
+ textAlign: 'start',
131
+ } }, { children: primaryIcon ? (_jsx(Icon, { icon: primaryIcon, size: getIconSize(typographyStyles.fontSize), color: hover ? hoverTextColor : textColor })) : (children) })), rightIcon && (_jsx(Icon, { icon: rightIcon, size: typographyStyles.fontSize, sx: { ml: iconMargin[size] }, color: hover ? hoverTextColor : textColor }))] })));
132
+ });
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Checkbox } from './index';
3
+ declare const meta: Meta<typeof Checkbox>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Checkbox>;
6
+ export declare const Default: Story;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Checkbox } from './index';
3
+ import { useState } from 'react';
4
+ import { Row } from '../../layout/Row';
5
+ const meta = {
6
+ title: 'Elements/Fields/Checkbox',
7
+ component: Checkbox,
8
+ tags: ['autodocs'],
9
+ };
10
+ export default meta;
11
+ const StatefulCheckbox = (props) => {
12
+ const [checked, setChecked] = useState(false);
13
+ return _jsx(Checkbox, Object.assign({}, props, { checked: checked, onChange: setChecked }));
14
+ };
15
+ export const Default = {
16
+ render: () => (_jsx(Row, { children: _jsx(StatefulCheckbox, {}) })),
17
+ };
@@ -0,0 +1,9 @@
1
+ /** @jsxImportSource theme-ui */
2
+ import React from 'react';
3
+ import { StyledElementProps } from '../../../../theme';
4
+ type CheckboxProps = StyledElementProps<HTMLInputElement, {
5
+ checked: boolean;
6
+ onChange: (value: boolean) => void;
7
+ }, string>;
8
+ export declare const Checkbox: React.FC<CheckboxProps>;
9
+ export {};
@@ -0,0 +1,22 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "theme-ui/jsx-runtime";
13
+ import { useTheme } from '../../../../theme';
14
+ export const Checkbox = (_a) => {
15
+ var { checked, onChange, sx } = _a, rest = __rest(_a, ["checked", "onChange", "sx"]);
16
+ const theme = useTheme();
17
+ return (_jsx("input", Object.assign({ type: "checkbox", onClick: (e) => {
18
+ onChange(e.target.checked);
19
+ }, checked: checked, sx: Object.assign({ margin: '0px', height: '1.25rem', width: '1.25rem', cursor: 'pointer', ':hover': {
20
+ boxShadow: theme.boxShadow,
21
+ } }, sx) }, rest)));
22
+ };
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { CheckboxGroup } from './index';
3
+ declare const meta: Meta<typeof CheckboxGroup>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof CheckboxGroup>;
6
+ export declare const Default: Story;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { CheckboxGroup } from './index';
3
+ import { useState } from 'react';
4
+ import { Row } from '../../layout/Row';
5
+ const meta = {
6
+ title: 'Elements/Fields/CheckboxGroup',
7
+ component: CheckboxGroup,
8
+ tags: ['autodocs'],
9
+ };
10
+ export default meta;
11
+ const options = [
12
+ { value: 'orange', label: 'Orange' },
13
+ { value: 'apple', label: 'Apple' },
14
+ { value: 'strawberry', label: 'Strawberry' },
15
+ { value: 'pineapple', label: 'Pineapple' },
16
+ ];
17
+ const StatefulCheckboxGroup = (props) => {
18
+ const [checked, setChecked] = useState(new Set());
19
+ return (_jsx(CheckboxGroup, Object.assign({}, props, { checkedOptions: checked, options: options, onChange: setChecked })));
20
+ };
21
+ export const Default = {
22
+ render: () => (_jsx(Row, { children: _jsx(StatefulCheckboxGroup, {}) })),
23
+ };
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { StyledElementProps } from '../../../../theme';
3
+ import { Key } from '../option';
4
+ type Option = {
5
+ value: Key;
6
+ label: string;
7
+ };
8
+ type CheckboxGroupProps = StyledElementProps<HTMLDivElement, {
9
+ onChange: (value: Set<Key>) => void;
10
+ options: Option[];
11
+ checkedOptions?: Set<Key>;
12
+ }, string>;
13
+ export declare const CheckboxGroup: React.FC<CheckboxGroupProps>;
14
+ export {};
@@ -0,0 +1,35 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Row } from '../../layout/Row';
14
+ import { Checkbox } from '../Checkbox';
15
+ import { Label } from '../../text/Label';
16
+ import { Group } from '../../Group';
17
+ import { GROUP_TYPE } from '../../Group';
18
+ import { Column } from '../../layout/Column';
19
+ import { TYPOGRAPHY_TYPE, getTypographyStyles, } from '../../../../theme/typography';
20
+ export const CheckboxGroup = (_a) => {
21
+ var { options, checkedOptions, onChange } = _a, rest = __rest(_a, ["options", "checkedOptions", "onChange"]);
22
+ return (_jsx(Column, Object.assign({}, rest, { children: options.map((option) => (_jsx(Group, Object.assign({ type: GROUP_TYPE.RAW }, { children: ({ labelTargetId }) => (_jsxs(Row, Object.assign({ sx: {
23
+ mb: 3,
24
+ alignItems: 'center',
25
+ } }, { children: [_jsx(Checkbox, { onChange: (checked) => {
26
+ const updatedSet = new Set(checkedOptions || []);
27
+ if (checked) {
28
+ updatedSet.add(option.value);
29
+ }
30
+ else {
31
+ updatedSet.delete(option.value);
32
+ }
33
+ onChange(updatedSet);
34
+ }, checked: !!(checkedOptions === null || checkedOptions === void 0 ? void 0 : checkedOptions.has(option.value)), id: labelTargetId, sx: { mr: 2 } }), _jsx(Label, Object.assign({ sx: Object.assign({ cursor: 'pointer' }, getTypographyStyles(TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM)) }, { children: option.label }))] }))) })))) })));
35
+ };
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Radio } from './index';
3
+ declare const meta: Meta<typeof Radio>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Radio>;
6
+ export declare const Default: Story;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Radio } from './index';
3
+ import { useState } from 'react';
4
+ import { Row } from '../../layout/Row';
5
+ const meta = {
6
+ title: 'Elements/Fields/Radio',
7
+ component: Radio,
8
+ tags: ['autodocs'],
9
+ };
10
+ export default meta;
11
+ const StatefulRadio = (props) => {
12
+ const [checked, setChecked] = useState(false);
13
+ return _jsx(Radio, Object.assign({}, props, { checked: checked, onChange: setChecked }));
14
+ };
15
+ export const Default = {
16
+ render: () => (_jsx(Row, { children: _jsx(StatefulRadio, {}) })),
17
+ };
@@ -0,0 +1,9 @@
1
+ /** @jsxImportSource theme-ui */
2
+ import React from 'react';
3
+ import { StyledElementProps } from '../../../../theme';
4
+ type RadioProps = StyledElementProps<HTMLInputElement, {
5
+ checked: boolean;
6
+ onChange: (value: boolean) => void;
7
+ }, string>;
8
+ export declare const Radio: React.FC<RadioProps>;
9
+ export {};
@@ -0,0 +1,22 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "theme-ui/jsx-runtime";
13
+ import { useTheme } from '../../../../theme';
14
+ export const Radio = (_a) => {
15
+ var { checked, onChange, sx } = _a, rest = __rest(_a, ["checked", "onChange", "sx"]);
16
+ const theme = useTheme();
17
+ return (_jsx("input", Object.assign({ type: "radio", onClick: (e) => {
18
+ onChange(e.target.checked);
19
+ }, checked: checked, sx: Object.assign({ margin: '0px', height: '1.25rem', width: '1.25rem', cursor: 'pointer', ':hover': {
20
+ boxShadow: theme.boxShadow,
21
+ } }, sx) }, rest)));
22
+ };
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { RadioGroup } from './index';
3
+ declare const meta: Meta<typeof RadioGroup>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof RadioGroup>;
6
+ export declare const Default: Story;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { RadioGroup } from './index';
3
+ import { useState } from 'react';
4
+ import { Row } from '../../layout/Row';
5
+ const meta = {
6
+ title: 'Elements/Fields/RadioGroup',
7
+ component: RadioGroup,
8
+ tags: ['autodocs'],
9
+ };
10
+ export default meta;
11
+ const options = [
12
+ { value: 'orange', label: 'Orange' },
13
+ { value: 'apple', label: 'Apple' },
14
+ { value: 'strawberry', label: 'Strawberry' },
15
+ { value: 'pineapple', label: 'Pineapple' },
16
+ ];
17
+ const StatefulRadioGroup = (props) => {
18
+ const [checked, setChecked] = useState(new Set());
19
+ return (_jsx(RadioGroup, Object.assign({}, props, { checked: checked, options: options, onChange: setChecked })));
20
+ };
21
+ export const Default = {
22
+ render: () => (_jsx(Row, { children: _jsx(StatefulRadioGroup, {}) })),
23
+ };
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { StyledElementProps } from '../../../../theme';
3
+ import { Key } from '../option';
4
+ type Option = {
5
+ value: Key;
6
+ label: string;
7
+ };
8
+ type RadioGroupProps = StyledElementProps<HTMLDivElement, {
9
+ onChange: (value: Key) => void;
10
+ options: Option[];
11
+ checked?: Key;
12
+ }, string>;
13
+ export declare const RadioGroup: React.FC<RadioGroupProps>;
14
+ export {};
@@ -0,0 +1,28 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { Row } from '../../layout/Row';
14
+ import { Label } from '../../text/Label';
15
+ import { Group } from '../../Group';
16
+ import { GROUP_TYPE } from '../../Group';
17
+ import { Column } from '../../layout/Column';
18
+ import { TYPOGRAPHY_TYPE, getTypographyStyles, } from '../../../../theme/typography';
19
+ import { Radio } from '../Radio';
20
+ export const RadioGroup = (_a) => {
21
+ var { options, checked, onChange } = _a, rest = __rest(_a, ["options", "checked", "onChange"]);
22
+ return (_jsx(Column, Object.assign({}, rest, { children: options.map((option) => (_jsx(Group, Object.assign({ type: GROUP_TYPE.RAW }, { children: ({ labelTargetId }) => (_jsxs(Row, Object.assign({ sx: {
23
+ mb: 3,
24
+ alignItems: 'center',
25
+ } }, { children: [_jsx(Radio, { onChange: () => {
26
+ onChange(option.value);
27
+ }, checked: checked === option.value, id: labelTargetId, sx: { mr: 2 } }), _jsx(Label, Object.assign({ sx: Object.assign({ cursor: 'pointer' }, getTypographyStyles(TYPOGRAPHY_TYPE.PARAGRAPH_MEDIUM)) }, { children: option.label }))] }))) })))) })));
28
+ };
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { Select } from './index';
3
+ declare const meta: Meta<typeof Select>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof Select>;
6
+ export declare const Default: Story;
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import AppleIcon from '@mui/icons-material/Apple';
3
+ import { INPUT_SIZE } from '../TextInput';
4
+ import { Select } from './index';
5
+ import { useState } from 'react';
6
+ import { Column } from '../../layout/Column';
7
+ import { Group } from '../../Group';
8
+ import { Heading, HEADING_SIZE } from '../../text/Heading';
9
+ const meta = {
10
+ title: 'Elements/Fields/Select',
11
+ component: Select,
12
+ tags: ['autodocs'],
13
+ };
14
+ export default meta;
15
+ const sizes = [
16
+ { label: 'Large', size: INPUT_SIZE.LG },
17
+ { label: 'Medium', size: INPUT_SIZE.MD },
18
+ { label: 'Small', size: INPUT_SIZE.SM },
19
+ ];
20
+ const options = [
21
+ { value: 'orange', label: 'Orange' },
22
+ { value: 'apple', label: 'Apple' },
23
+ { value: 'strawberry', label: 'Strawberry' },
24
+ { value: 'pineapple', label: 'Pineapple' },
25
+ ];
26
+ const StatefulSelect = (props) => {
27
+ const [value, setValue] = useState('');
28
+ return (_jsx(Select, Object.assign({ options: options }, props, { value: value, onSelectOption: setValue, placeholder: "Select A Fruit..." })));
29
+ };
30
+ export const Default = {
31
+ render: () => (_jsx(Column, { children: sizes.map((size) => (_jsxs(Group, { children: [_jsx(Heading, Object.assign({ size: HEADING_SIZE.MD }, { children: size.label })), _jsx(StatefulSelect, { size: size.size, leftIcon: AppleIcon, sx: { mt: 1 } })] }))) })),
32
+ };
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { StyledElementProps } from '../../../../theme';
3
+ import { INPUT_SIZE } from '../TextInput';
4
+ import { BasicOption, Key, RenderOption, RenderOptionLabel } from '../option';
5
+ type SelectProps<Value extends Key, Option extends BasicOption<Value>> = StyledElementProps<HTMLSelectElement, {
6
+ placeholder: string;
7
+ size?: INPUT_SIZE;
8
+ leftIcon?: React.FC<any>;
9
+ value: Value;
10
+ onSelectOption: (value: Value) => void;
11
+ options: Option[];
12
+ renderOption: RenderOption<Value, Option>;
13
+ renderOptionLabel: RenderOptionLabel<Option>;
14
+ }, string>;
15
+ export declare function Select<Value extends Key, Option extends BasicOption<Value>>({ size: sizeParam, placeholder, leftIcon, value, onSelectOption, options, renderOption, renderOptionLabel: renderOptionLabelParam, sx, }: SelectProps<Value, Option>): import("react/jsx-runtime").JSX.Element;
16
+ export {};