datocms-react-ui 0.3.24 → 0.3.28

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 (94) hide show
  1. package/dist/cjs/SelectInput/index.js +2 -2
  2. package/dist/cjs/SelectInput/index.js.map +1 -1
  3. package/dist/esm/SelectInput/index.js +2 -2
  4. package/dist/esm/SelectInput/index.js.map +1 -1
  5. package/package.json +4 -3
  6. package/src/Button/index.tsx +173 -0
  7. package/src/Button/styles.module.css +149 -0
  8. package/src/Button/styles.module.css.json +1 -0
  9. package/src/ButtonGroup/Button/index.tsx +40 -0
  10. package/src/ButtonGroup/Button/styles.module.css +72 -0
  11. package/src/ButtonGroup/Button/styles.module.css.json +1 -0
  12. package/src/ButtonGroup/Group/index.tsx +31 -0
  13. package/src/ButtonGroup/Group/styles.module.css +6 -0
  14. package/src/ButtonGroup/Group/styles.module.css.json +1 -0
  15. package/src/ButtonGroup/index.ts +4 -0
  16. package/src/Canvas/index.tsx +556 -0
  17. package/src/Canvas/styles.module.css +75 -0
  18. package/src/Canvas/styles.module.css.json +1 -0
  19. package/src/ContextInspector/index.tsx +316 -0
  20. package/src/ContextInspector/styles.module.css +90 -0
  21. package/src/ContextInspector/styles.module.css.json +1 -0
  22. package/src/Dropdown/Dropdown.tsx +171 -0
  23. package/src/Dropdown/DropdownContext.tsx +10 -0
  24. package/src/Dropdown/Group.tsx +16 -0
  25. package/src/Dropdown/Menu.tsx +351 -0
  26. package/src/Dropdown/MenuContext.tsx +18 -0
  27. package/src/Dropdown/Option.tsx +148 -0
  28. package/src/Dropdown/OptionAction.tsx +42 -0
  29. package/src/Dropdown/Portal.tsx +46 -0
  30. package/src/Dropdown/Separator.tsx +13 -0
  31. package/src/Dropdown/Text.tsx +8 -0
  32. package/src/Dropdown/index.tsx +26 -0
  33. package/src/Dropdown/styles.module.css +331 -0
  34. package/src/Dropdown/styles.module.css.json +1 -0
  35. package/src/FieldError/index.tsx +10 -0
  36. package/src/FieldError/styles.module.css +6 -0
  37. package/src/FieldError/styles.module.css.json +1 -0
  38. package/src/FieldGroup/index.tsx +25 -0
  39. package/src/FieldGroup/styles.module.css +12 -0
  40. package/src/FieldGroup/styles.module.css.json +1 -0
  41. package/src/FieldHint/index.tsx +10 -0
  42. package/src/FieldHint/styles.module.css +6 -0
  43. package/src/FieldHint/styles.module.css.json +1 -0
  44. package/src/Form/index.tsx +145 -0
  45. package/src/Form/styles.module.css +19 -0
  46. package/src/Form/styles.module.css.json +1 -0
  47. package/src/FormLabel/index.tsx +36 -0
  48. package/src/FormLabel/styles.module.css +31 -0
  49. package/src/FormLabel/styles.module.css.json +1 -0
  50. package/src/Section/index.tsx +104 -0
  51. package/src/Section/styles.module.css +100 -0
  52. package/src/Section/styles.module.css.json +1 -0
  53. package/src/SelectField/index.tsx +244 -0
  54. package/src/SelectInput/index.tsx +233 -0
  55. package/src/SidebarPanel/index.tsx +110 -0
  56. package/src/SidebarPanel/styles.module.css +49 -0
  57. package/src/SidebarPanel/styles.module.css.json +1 -0
  58. package/src/Spinner/index.tsx +68 -0
  59. package/src/Spinner/styles.module.css +31 -0
  60. package/src/Spinner/styles.module.css.json +1 -0
  61. package/src/SwitchField/index.tsx +67 -0
  62. package/src/SwitchField/styles.module.css +25 -0
  63. package/src/SwitchField/styles.module.css.json +1 -0
  64. package/src/SwitchInput/index.tsx +74 -0
  65. package/src/SwitchInput/styles.module.css +100 -0
  66. package/src/SwitchInput/styles.module.css.json +1 -0
  67. package/src/TextField/index.tsx +58 -0
  68. package/src/TextField/styles.module.css +0 -0
  69. package/src/TextField/styles.module.css.json +1 -0
  70. package/src/TextInput/index.tsx +73 -0
  71. package/src/TextInput/styles.module.css +52 -0
  72. package/src/TextInput/styles.module.css.json +1 -0
  73. package/src/Toolbar/Button/index.tsx +32 -0
  74. package/src/Toolbar/Button/styles.module.css +43 -0
  75. package/src/Toolbar/Button/styles.module.css.json +1 -0
  76. package/src/Toolbar/Stack/index.tsx +33 -0
  77. package/src/Toolbar/Stack/styles.module.css +18 -0
  78. package/src/Toolbar/Stack/styles.module.css.json +1 -0
  79. package/src/Toolbar/Title/index.tsx +17 -0
  80. package/src/Toolbar/Title/styles.module.css +12 -0
  81. package/src/Toolbar/Title/styles.module.css.json +1 -0
  82. package/src/Toolbar/Toolbar/index.tsx +112 -0
  83. package/src/Toolbar/Toolbar/styles.module.css +15 -0
  84. package/src/Toolbar/Toolbar/styles.module.css.json +1 -0
  85. package/src/Toolbar/index.ts +8 -0
  86. package/src/base.css +89 -0
  87. package/src/generateStyleFromCtx/index.ts +25 -0
  88. package/src/global.css +23 -0
  89. package/src/icons.tsx +108 -0
  90. package/src/index.ts +23 -0
  91. package/src/mergeRefs/index.ts +8 -0
  92. package/src/useClickOutside/index.ts +30 -0
  93. package/src/useMediaQuery/index.ts +185 -0
  94. package/types.json +8 -8
@@ -0,0 +1,52 @@
1
+ .TextInput {
2
+ display: block;
3
+ box-sizing: border-box;
4
+ width: 100%;
5
+ padding: 10px;
6
+ border: 1px solid var(--border-color);
7
+ appearance: none;
8
+ border-radius: 0;
9
+ background-image: none;
10
+ transition: border 0.2s var(--material-ease);
11
+ font-size: var(--font-size-m);
12
+ resize: none;
13
+ font-family: inherit;
14
+
15
+ &::placeholder {
16
+ color: var(--placeholder-body-color);
17
+ }
18
+
19
+ &:hover {
20
+ border-color: var(--darker-border-color);
21
+ }
22
+
23
+ &:focus {
24
+ outline: 0;
25
+ border-color: var(--accent-color);
26
+ box-shadow: 0 0 0 3px var(--semi-transparent-accent-color);
27
+ }
28
+ }
29
+
30
+ .TextInput--monospaced {
31
+ font-family: var(--monospaced-font-family);
32
+ font-size: var(--font-size-s);
33
+ }
34
+
35
+ .TextInput--disabled {
36
+ color: var(--light-body-color);
37
+ border-color: var(--border-color);
38
+ background: var(--lighter-bg-color);
39
+ }
40
+
41
+ .TextInput--error {
42
+ border-color: var(--alert-color);
43
+
44
+ &:hover,
45
+ &:focus {
46
+ border-color: var(--alert-color);
47
+ }
48
+
49
+ &:focus {
50
+ box-shadow: 0 0 0 3px rgba(var(--alert-color-rgb-components), 0.2);
51
+ }
52
+ }
@@ -0,0 +1 @@
1
+ {"TextInput":"_TextInput_x2oj2_1","TextInput--monospaced":"_TextInput--monospaced_x2oj2_30","TextInput--disabled":"_TextInput--disabled_x2oj2_35","TextInput--error":"_TextInput--error_x2oj2_41"}
@@ -0,0 +1,32 @@
1
+ import classNames from 'classnames';
2
+ import React, { CSSProperties, MouseEventHandler, ReactNode } from 'react';
3
+ import s from './styles.module.css.json';
4
+
5
+ export type ButtonProps = {
6
+ children?: ReactNode;
7
+ className?: string;
8
+ style?: CSSProperties;
9
+ onClick?: MouseEventHandler;
10
+ };
11
+
12
+ export function Button({
13
+ children,
14
+ style,
15
+ className,
16
+ onClick,
17
+ }: ButtonProps): JSX.Element {
18
+ return (
19
+ <button
20
+ type="button"
21
+ onClick={onClick}
22
+ className={classNames(
23
+ s['Button'],
24
+
25
+ className,
26
+ )}
27
+ style={style}
28
+ >
29
+ {children}
30
+ </button>
31
+ );
32
+ }
@@ -0,0 +1,43 @@
1
+ .Button {
2
+ font-family: inherit;
3
+ cursor: pointer;
4
+ line-height: inherit;
5
+ background-color: transparent;
6
+ color: var(--base-body-color);
7
+ -webkit-appearance: none;
8
+ -moz-appearance: none;
9
+ box-sizing: border-box;
10
+ border: 0;
11
+ padding: 0;
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+ width: 49px;
16
+ min-height: 49px;
17
+ border-left: 1px solid var(--border-color);
18
+ border-right: 1px solid var(--border-color);
19
+ }
20
+
21
+ .Button:hover,
22
+ .Button:focus {
23
+ background-color: var(--light-bg-color);
24
+ }
25
+
26
+ .Button:first-child {
27
+ border-left: 0;
28
+ }
29
+
30
+ .Button:last-child {
31
+ border-right: 0;
32
+ }
33
+
34
+ @media screen and (min-width: 380px) {
35
+ .Button {
36
+ width: 59px;
37
+ min-height: 59px;
38
+ }
39
+
40
+ .Button svg {
41
+ font-size: 20px;
42
+ }
43
+ }
@@ -0,0 +1 @@
1
+ {"Button":"_Button_fy6g6_1"}
@@ -0,0 +1,33 @@
1
+ import classNames from 'classnames';
2
+ import React, { CSSProperties, ReactNode } from 'react';
3
+ import s from './styles.module.css.json';
4
+
5
+ export type StackProps = {
6
+ children?: ReactNode;
7
+ className?: string;
8
+ stackSize?: 's' | 'm' | 'l';
9
+ style?: CSSProperties;
10
+ };
11
+
12
+ export function Stack({
13
+ children,
14
+ style,
15
+ className,
16
+ stackSize,
17
+ }: StackProps): JSX.Element {
18
+ return (
19
+ <div
20
+ className={classNames(
21
+ s['Stack'],
22
+ {
23
+ [s['Stack--s']]: stackSize === 's',
24
+ [s['Stack--l']]: stackSize === 'l',
25
+ },
26
+ className,
27
+ )}
28
+ style={style}
29
+ >
30
+ {children}
31
+ </div>
32
+ );
33
+ }
@@ -0,0 +1,18 @@
1
+ .Stack {
2
+ display: flex;
3
+ padding: 10px 15px;
4
+ flex: 1;
5
+ justify-content: center;
6
+ flex-direction: row;
7
+ align-items: center;
8
+ }
9
+
10
+ .Stack--s {
11
+ padding-top: var(--spacing-s);
12
+ padding-bottom: var(--spacing-s);
13
+ }
14
+
15
+ .Stack--l {
16
+ padding-left: var(--spacing-xl);
17
+ padding-right: var(--spacing-xl);
18
+ }
@@ -0,0 +1 @@
1
+ {"Stack":"_Stack_1nnzo_1","Stack--s":"_Stack--s_1nnzo_10","Stack--l":"_Stack--l_1nnzo_15"}
@@ -0,0 +1,17 @@
1
+ import classNames from 'classnames';
2
+ import React, { CSSProperties, ReactNode } from 'react';
3
+ import s from './styles.module.css.json';
4
+
5
+ export type TitleProps = {
6
+ children?: ReactNode;
7
+ className?: string;
8
+ style?: CSSProperties;
9
+ };
10
+
11
+ export function Title({ children, style, className }: TitleProps): JSX.Element {
12
+ return (
13
+ <div className={classNames(s['Title'], className)} style={style}>
14
+ {children}
15
+ </div>
16
+ );
17
+ }
@@ -0,0 +1,12 @@
1
+ .Title {
2
+ font-weight: 500;
3
+ line-height: 1.1;
4
+ margin-right: 15px;
5
+ font-size: var(--font-size-l);
6
+ }
7
+
8
+ @media screen and (min-width: 380px) {
9
+ .Title {
10
+ font-size: var(--font-size-xl);
11
+ }
12
+ }
@@ -0,0 +1 @@
1
+ {"Title":"_Title_1dx5n_1"}
@@ -0,0 +1,112 @@
1
+ import classNames from 'classnames';
2
+ import React, { CSSProperties, ReactNode } from 'react';
3
+ import s from './styles.module.css.json';
4
+
5
+ export type ToolbarProps = {
6
+ children?: ReactNode;
7
+ className?: string;
8
+ style?: CSSProperties;
9
+ };
10
+
11
+ /**
12
+ * - @example Basic example
13
+ *
14
+ * ```js
15
+ * <Canvas ctx={ctx}>
16
+ * <Toolbar>
17
+ * <ToolbarStack stackSize="l">
18
+ * <ToolbarTitle>Media Area</ToolbarTitle>
19
+ * </ToolbarStack>
20
+ * </Toolbar>
21
+ * <div
22
+ * style={{
23
+ * display: 'flex',
24
+ * justifyContent: 'center',
25
+ * alignItems: 'center',
26
+ * background: 'var(--light-bg-color)',
27
+ * height: '150px',
28
+ * }}
29
+ * >
30
+ * Main content
31
+ * </div>
32
+ * </Canvas>;
33
+ * ```
34
+ *
35
+ * @example Buttons and actions
36
+ *
37
+ * ```js
38
+ * <Canvas ctx={ctx}>
39
+ * <Toolbar>
40
+ * <ToolbarButton>
41
+ * <BackIcon />
42
+ * </ToolbarButton>
43
+ * <ToolbarStack stackSize="l">
44
+ * <ToolbarTitle>Media Area</ToolbarTitle>
45
+ * <div style={{ flex: '1' }} />
46
+ * <Button buttonType="primary">Action</Button>
47
+ * </ToolbarStack>
48
+ * <ToolbarButton>
49
+ * <SidebarLeftArrowIcon />
50
+ * </ToolbarButton>
51
+ * </Toolbar>
52
+ * <div
53
+ * style={{
54
+ * display: 'flex',
55
+ * justifyContent: 'center',
56
+ * alignItems: 'center',
57
+ * background: 'var(--light-bg-color)',
58
+ * height: '150px',
59
+ * }}
60
+ * >
61
+ * Main content
62
+ * </div>
63
+ * </Canvas>;
64
+ * ```
65
+ *
66
+ * @example With button group
67
+ *
68
+ * ```js
69
+ * <Canvas ctx={ctx}>
70
+ * <Toolbar>
71
+ * <ToolbarStack stackSize="l">
72
+ * <ToolbarTitle>Media Area</ToolbarTitle>
73
+ * <div style={{ flex: '1' }} />
74
+ * <ButtonGroup>
75
+ * <ButtonGroupButton>First</ButtonGroupButton>
76
+ * <ButtonGroupButton selected>Second</ButtonGroupButton>
77
+ * <ButtonGroupButton>Third</ButtonGroupButton>
78
+ * </ButtonGroup>
79
+ * </ToolbarStack>
80
+ * </Toolbar>
81
+ * <div
82
+ * style={{
83
+ * display: 'flex',
84
+ * justifyContent: 'center',
85
+ * alignItems: 'center',
86
+ * background: 'var(--light-bg-color)',
87
+ * height: '150px',
88
+ * }}
89
+ * >
90
+ * Main content
91
+ * </div>
92
+ * </Canvas>;
93
+ * ```
94
+ */
95
+ export function Toolbar({
96
+ children,
97
+ style,
98
+ className,
99
+ }: ToolbarProps): JSX.Element {
100
+ return (
101
+ <div
102
+ className={classNames(
103
+ s['Toolbar'],
104
+
105
+ className,
106
+ )}
107
+ style={style}
108
+ >
109
+ {children}
110
+ </div>
111
+ );
112
+ }
@@ -0,0 +1,15 @@
1
+ .Toolbar {
2
+ display: flex;
3
+ border-bottom: 1px solid var(--border-color);
4
+ border-top: 1px solid var(--border-color);
5
+ align-items: stretch;
6
+ position: relative;
7
+ }
8
+
9
+ .Toolbar:first-child {
10
+ border-top-width: 0;
11
+ }
12
+
13
+ .Toolbar:last-child {
14
+ border-bottom-width: 0;
15
+ }
@@ -0,0 +1 @@
1
+ {"Toolbar":"_Toolbar_1cwb8_1"}
@@ -0,0 +1,8 @@
1
+ export { Toolbar } from './Toolbar';
2
+ export type { ToolbarProps } from './Toolbar';
3
+ export { Button as ToolbarButton } from './Button';
4
+ export type { ButtonProps as ToolbarButtonProps } from './Button';
5
+ export { Title as ToolbarTitle } from './Title';
6
+ export type { TitleProps as ToolbarTitleProps } from './Title';
7
+ export { Stack as ToolbarStack } from './Stack';
8
+ export type { StackProps as ToolbarStackProps } from './Stack';
package/src/base.css ADDED
@@ -0,0 +1,89 @@
1
+ @font-face {
2
+ font-family: 'colfax-web';
3
+ src: url('https://use.typekit.net/af/522c51/00000000000000003b9acde6/27/l?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=n5&v=3')
4
+ format('woff2'),
5
+ url('https://use.typekit.net/af/522c51/00000000000000003b9acde6/27/d?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=n5&v=3')
6
+ format('woff'),
7
+ url('https://use.typekit.net/af/522c51/00000000000000003b9acde6/27/a?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=n5&v=3')
8
+ format('opentype');
9
+ font-display: auto;
10
+ font-style: normal;
11
+ font-weight: 700;
12
+ }
13
+
14
+ @font-face {
15
+ font-family: 'colfax-web';
16
+ src: url('https://use.typekit.net/af/4e71b3/00000000000000003b9acde7/27/l?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=i5&v=3')
17
+ format('woff2'),
18
+ url('https://use.typekit.net/af/4e71b3/00000000000000003b9acde7/27/d?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=i5&v=3')
19
+ format('woff'),
20
+ url('https://use.typekit.net/af/4e71b3/00000000000000003b9acde7/27/a?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=i5&v=3')
21
+ format('opentype');
22
+ font-display: auto;
23
+ font-style: italic;
24
+ font-weight: 700;
25
+ }
26
+
27
+ @font-face {
28
+ font-family: 'colfax-web';
29
+ src: url('https://use.typekit.net/af/522c51/00000000000000003b9acde6/27/l?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=n5&v=3')
30
+ format('woff2'),
31
+ url('https://use.typekit.net/af/522c51/00000000000000003b9acde6/27/d?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=n5&v=3')
32
+ format('woff'),
33
+ url('https://use.typekit.net/af/522c51/00000000000000003b9acde6/27/a?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=n5&v=3')
34
+ format('opentype');
35
+ font-display: auto;
36
+ font-style: normal;
37
+ font-weight: 500;
38
+ }
39
+
40
+ @font-face {
41
+ font-family: 'colfax-web';
42
+ src: url('https://use.typekit.net/af/4e71b3/00000000000000003b9acde7/27/l?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=i5&v=3')
43
+ format('woff2'),
44
+ url('https://use.typekit.net/af/4e71b3/00000000000000003b9acde7/27/d?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=i5&v=3')
45
+ format('woff'),
46
+ url('https://use.typekit.net/af/4e71b3/00000000000000003b9acde7/27/a?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=i5&v=3')
47
+ format('opentype');
48
+ font-display: auto;
49
+ font-style: italic;
50
+ font-weight: 500;
51
+ }
52
+
53
+ @font-face {
54
+ font-family: 'colfax-web';
55
+ src: url('https://use.typekit.net/af/bac079/00000000000000003b9acde4/27/l?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=n4&v=3')
56
+ format('woff2'),
57
+ url('https://use.typekit.net/af/bac079/00000000000000003b9acde4/27/d?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=n4&v=3')
58
+ format('woff'),
59
+ url('https://use.typekit.net/af/bac079/00000000000000003b9acde4/27/a?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=n4&v=3')
60
+ format('opentype');
61
+ font-display: auto;
62
+ font-style: normal;
63
+ font-weight: 400;
64
+ }
65
+
66
+ @font-face {
67
+ font-family: 'colfax-web';
68
+ src: url('https://use.typekit.net/af/c1cc04/00000000000000003b9acde5/27/l?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=i4&v=3')
69
+ format('woff2'),
70
+ url('https://use.typekit.net/af/c1cc04/00000000000000003b9acde5/27/d?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=i4&v=3')
71
+ format('woff'),
72
+ url('https://use.typekit.net/af/c1cc04/00000000000000003b9acde5/27/a?primer=f592e0a4b9356877842506ce344308576437e4f677d7c9b78ca2162e6cad991a&fvd=i4&v=3')
73
+ format('opentype');
74
+ font-display: auto;
75
+ font-style: italic;
76
+ font-weight: 400;
77
+ }
78
+
79
+ html {
80
+ padding: 0;
81
+ margin: 0;
82
+ height: auto;
83
+ font-size: 16px;
84
+ }
85
+
86
+ body {
87
+ padding: 0;
88
+ margin: 0;
89
+ }
@@ -0,0 +1,25 @@
1
+ import { RenderProperties } from 'datocms-plugin-sdk';
2
+ import { CSSProperties } from 'react';
3
+
4
+ function camelToDash(str: string) {
5
+ if (str != str.toLowerCase()) {
6
+ str = str.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());
7
+ }
8
+ return str;
9
+ }
10
+
11
+ export function generateStyleFromCtx(ctx: RenderProperties): CSSProperties {
12
+ return Object.entries(ctx.theme).reduce(
13
+ (acc, [k, v]) => {
14
+ return {
15
+ ...acc,
16
+ [`--${camelToDash(k)}`]: v,
17
+ [`--${camelToDash(`${k}RgbComponents`)}`]:
18
+ v.match(/rgb\((\d+, \d+, \d+)\)/)?.[1] || undefined,
19
+ };
20
+ },
21
+ {
22
+ padding: ctx.bodyPadding.map((p) => `${p}px`).join(' '),
23
+ },
24
+ );
25
+ }
package/src/global.css ADDED
@@ -0,0 +1,23 @@
1
+ @import './base.css';
2
+ @import './Button/styles.module.css';
3
+ @import './ButtonGroup/Button/styles.module.css';
4
+ @import './ButtonGroup/Group/styles.module.css';
5
+ @import './Canvas/styles.module.css';
6
+ @import './ContextInspector/styles.module.css';
7
+ @import './FieldError/styles.module.css';
8
+ @import './FieldGroup/styles.module.css';
9
+ @import './FieldHint/styles.module.css';
10
+ @import './Form/styles.module.css';
11
+ @import './FormLabel/styles.module.css';
12
+ @import './Section/styles.module.css';
13
+ @import './SidebarPanel/styles.module.css';
14
+ @import './Spinner/styles.module.css';
15
+ @import './SwitchField/styles.module.css';
16
+ @import './SwitchInput/styles.module.css';
17
+ @import './TextField/styles.module.css';
18
+ @import './TextInput/styles.module.css';
19
+ @import './Toolbar/Button/styles.module.css';
20
+ @import './Toolbar/Stack/styles.module.css';
21
+ @import './Toolbar/Title/styles.module.css';
22
+ @import './Toolbar/Toolbar/styles.module.css';
23
+ @import './Dropdown/styles.module.css';
package/src/icons.tsx ADDED
@@ -0,0 +1,108 @@
1
+ import React, { CSSProperties } from 'react';
2
+
3
+ export type IconProps = {
4
+ width?: string | number;
5
+ height?: string | number;
6
+ className?: string;
7
+ style?: CSSProperties;
8
+ };
9
+
10
+ export function BackIcon({
11
+ width = '1em',
12
+ height = '1em',
13
+ style,
14
+ className,
15
+ }: IconProps): JSX.Element {
16
+ return (
17
+ <svg
18
+ xmlns="http://www.w3.org/2000/svg"
19
+ viewBox="0 0 256 512"
20
+ width={width}
21
+ height={height}
22
+ style={style}
23
+ className={className}
24
+ >
25
+ <path d="M238.475 475.535l7.071-7.07c4.686-4.686 4.686-12.284 0-16.971L50.053 256 245.546 60.506c4.686-4.686 4.686-12.284 0-16.971l-7.071-7.07c-4.686-4.686-12.284-4.686-16.97 0L10.454 247.515c-4.686 4.686-4.686 12.284 0 16.971l211.051 211.05c4.686 4.686 12.284 4.686 16.97-.001z"></path>
26
+ </svg>
27
+ );
28
+ }
29
+
30
+ export function SidebarLeftArrowIcon({
31
+ width = '1em',
32
+ height = '1em',
33
+ style,
34
+ className,
35
+ }: IconProps): JSX.Element {
36
+ return (
37
+ <svg
38
+ xmlns="http://www.w3.org/2000/svg"
39
+ viewBox="0 0 448 512"
40
+ width={width}
41
+ height={height}
42
+ style={style}
43
+ className={className}
44
+ >
45
+ <path d="M152 412.5L3.5 264.5c-4.7-4.7-4.7-12.3 0-17L152 99.5c4.7-4.7 12.3-4.7 17 0l7.1 7.1c4.7 4.7 4.7 12.3 0 17L60.1 239H372c6.6 0 12 5.4 12 12v10c0 6.6-5.4 12-12 12H60.1L176 388.4c4.7 4.7 4.7 12.3 0 17l-7.1 7.1c-4.6 4.7-12.2 4.7-16.9 0zM436 64h-8c-6.6 0-12 5.4-12 12v360c0 6.6 5.4 12 12 12h8c6.6 0 12-5.4 12-12V76c0-6.6-5.4-12-12-12z"></path>
46
+ </svg>
47
+ );
48
+ }
49
+
50
+ export function SidebarRightArrowIcon({
51
+ width = '1em',
52
+ height = '1em',
53
+ style,
54
+ className,
55
+ }: IconProps): JSX.Element {
56
+ return (
57
+ <svg
58
+ xmlns="http://www.w3.org/2000/svg"
59
+ viewBox="0 0 448 512"
60
+ width={width}
61
+ height={height}
62
+ style={style}
63
+ className={className}
64
+ >
65
+ <path d="M296 99.5l148.5 148c4.7 4.7 4.7 12.3 0 17L296 412.5c-4.7 4.7-12.3 4.7-17 0l-7.1-7.1c-4.7-4.7-4.7-12.3 0-17l116-115.4H76c-6.6 0-12-5.4-12-12v-10c0-6.6 5.4-12 12-12h311.9L272 123.6c-4.7-4.7-4.7-12.3 0-17l7.1-7.1c4.6-4.7 12.2-4.7 16.9 0zM12 448h8c6.6 0 12-5.4 12-12V76c0-6.6-5.4-12-12-12h-8C5.4 64 0 69.4 0 76v360c0 6.6 5.4 12 12 12z"></path>
66
+ </svg>
67
+ );
68
+ }
69
+
70
+ export function CaretDownIcon({
71
+ width = '1em',
72
+ height = '1em',
73
+ style,
74
+ className,
75
+ }: IconProps): JSX.Element {
76
+ return (
77
+ <svg
78
+ xmlns="http://www.w3.org/2000/svg"
79
+ viewBox="0 0 320 512"
80
+ width={width}
81
+ height={height}
82
+ style={style}
83
+ className={className}
84
+ >
85
+ <path d="M31.3 192h257.3c17.8 0 26.7 21.5 14.1 34.1L174.1 354.8c-7.8 7.8-20.5 7.8-28.3 0L17.2 226.1C4.6 213.5 13.5 192 31.3 192z" />
86
+ </svg>
87
+ );
88
+ }
89
+
90
+ export function CaretUpIcon({
91
+ width = '1em',
92
+ height = '1em',
93
+ style,
94
+ className,
95
+ }: IconProps): JSX.Element {
96
+ return (
97
+ <svg
98
+ xmlns="http://www.w3.org/2000/svg"
99
+ viewBox="0 0 320 512"
100
+ width={width}
101
+ height={height}
102
+ style={style}
103
+ className={className}
104
+ >
105
+ <path d="M288.662 352H31.338c-17.818 0-26.741-21.543-14.142-34.142l128.662-128.662c7.81-7.81 20.474-7.81 28.284 0l128.662 128.662c12.6 12.599 3.676 34.142-14.142 34.142z" />
106
+ </svg>
107
+ );
108
+ }
package/src/index.ts ADDED
@@ -0,0 +1,23 @@
1
+ export * from './Button';
2
+ export * from './ButtonGroup';
3
+ export * from './Canvas';
4
+ export * from './ContextInspector';
5
+ export * from './Dropdown';
6
+ export * from './FieldError';
7
+ export * from './FieldGroup';
8
+ export * from './FieldHint';
9
+ export * from './Form';
10
+ export * from './FormLabel';
11
+ export * from './icons';
12
+ export * from './Section';
13
+ export * from './SelectField';
14
+ export * from './SelectInput';
15
+ export * from './SidebarPanel';
16
+ export * from './Spinner';
17
+ export * from './SwitchField';
18
+ export * from './SwitchInput';
19
+ export * from './TextField';
20
+ export * from './TextInput';
21
+ export * from './Toolbar';
22
+ export * from './useClickOutside';
23
+ export * from './useMediaQuery';
@@ -0,0 +1,8 @@
1
+ export const mergeRefs = <T extends unknown>(
2
+ ...refs: React.Ref<T>[]
3
+ ): React.RefCallback<T> => (element: T) =>
4
+ refs.forEach((ref) => {
5
+ if (typeof ref === 'function') ref(element);
6
+ else if (ref && typeof ref === 'object')
7
+ (ref as React.MutableRefObject<T>).current = element;
8
+ });
@@ -0,0 +1,30 @@
1
+ import { useCallback, useEffect, useRef } from 'react';
2
+
3
+ export function useClickOutside<T extends HTMLElement>(
4
+ handler: (event: MouseEvent | TouchEvent) => void,
5
+ ): React.RefObject<T> {
6
+ const ref = useRef<T>(null);
7
+
8
+ const handleClick = useCallback(
9
+ (event: MouseEvent | TouchEvent) => {
10
+ event.target;
11
+ if (!ref.current || ref.current.contains(event.target as Node)) {
12
+ return;
13
+ }
14
+ handler(event);
15
+ },
16
+ [handler],
17
+ );
18
+
19
+ useEffect(() => {
20
+ document.addEventListener('mousedown', handleClick);
21
+ document.addEventListener('touchstart', handleClick);
22
+
23
+ return () => {
24
+ document.removeEventListener('mousedown', handleClick);
25
+ document.removeEventListener('touchstart', handleClick);
26
+ };
27
+ }, [handleClick]);
28
+
29
+ return ref;
30
+ }