datocms-react-ui 1.0.1 → 1.1.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 (239) hide show
  1. package/dist/cjs/Button/index.js +5 -5
  2. package/dist/cjs/Button/index.js.map +1 -1
  3. package/dist/cjs/ButtonGroup/Button/index.js +1 -1
  4. package/dist/cjs/ButtonGroup/Button/index.js.map +1 -1
  5. package/dist/cjs/ButtonGroup/Group/index.js +1 -1
  6. package/dist/cjs/ButtonGroup/Group/index.js.map +1 -1
  7. package/dist/cjs/Canvas/index.js +3 -3
  8. package/dist/cjs/Canvas/index.js.map +1 -1
  9. package/dist/cjs/ContextInspector/index.js +34 -35
  10. package/dist/cjs/ContextInspector/index.js.map +1 -1
  11. package/dist/cjs/Dropdown/Dropdown.js +8 -30
  12. package/dist/cjs/Dropdown/Dropdown.js.map +1 -1
  13. package/dist/cjs/Dropdown/Group.js +2 -2
  14. package/dist/cjs/Dropdown/Group.js.map +1 -1
  15. package/dist/cjs/Dropdown/Menu.js +20 -18
  16. package/dist/cjs/Dropdown/Menu.js.map +1 -1
  17. package/dist/cjs/Dropdown/MenuContext.js.map +1 -1
  18. package/dist/cjs/Dropdown/Option.js +3 -3
  19. package/dist/cjs/Dropdown/Option.js.map +1 -1
  20. package/dist/cjs/Dropdown/OptionAction.js +1 -1
  21. package/dist/cjs/Dropdown/OptionAction.js.map +1 -1
  22. package/dist/cjs/Dropdown/Portal.js +6 -28
  23. package/dist/cjs/Dropdown/Portal.js.map +1 -1
  24. package/dist/cjs/Dropdown/Separator.js +1 -1
  25. package/dist/cjs/Dropdown/Separator.js.map +1 -1
  26. package/dist/cjs/Dropdown/Text.js +1 -1
  27. package/dist/cjs/Dropdown/Text.js.map +1 -1
  28. package/dist/cjs/Dropdown/index.js.map +1 -1
  29. package/dist/cjs/FieldError/index.js.map +1 -1
  30. package/dist/cjs/FieldGroup/index.js +1 -1
  31. package/dist/cjs/FieldGroup/index.js.map +1 -1
  32. package/dist/cjs/FieldHint/index.js.map +1 -1
  33. package/dist/cjs/FieldWrapper/index.js.map +1 -1
  34. package/dist/cjs/Form/index.js +1 -1
  35. package/dist/cjs/Form/index.js.map +1 -1
  36. package/dist/cjs/FormLabel/index.js +1 -1
  37. package/dist/cjs/FormLabel/index.js.map +1 -1
  38. package/dist/cjs/Section/index.js +6 -6
  39. package/dist/cjs/Section/index.js.map +1 -1
  40. package/dist/cjs/SelectField/index.js.map +1 -1
  41. package/dist/cjs/SelectInput/index.js.map +1 -1
  42. package/dist/cjs/SidebarPanel/index.js +5 -5
  43. package/dist/cjs/SidebarPanel/index.js.map +1 -1
  44. package/dist/cjs/Spinner/index.js +1 -1
  45. package/dist/cjs/Spinner/index.js.map +1 -1
  46. package/dist/cjs/SwitchField/index.js +1 -1
  47. package/dist/cjs/SwitchField/index.js.map +1 -1
  48. package/dist/cjs/SwitchInput/index.js +5 -5
  49. package/dist/cjs/SwitchInput/index.js.map +1 -1
  50. package/dist/cjs/TextField/index.js.map +1 -1
  51. package/dist/cjs/TextInput/index.js +4 -26
  52. package/dist/cjs/TextInput/index.js.map +1 -1
  53. package/dist/cjs/TextareaField/index.js.map +1 -1
  54. package/dist/cjs/TextareaInput/index.js +4 -26
  55. package/dist/cjs/TextareaInput/index.js.map +1 -1
  56. package/dist/cjs/Toolbar/Button/index.js +1 -1
  57. package/dist/cjs/Toolbar/Button/index.js.map +1 -1
  58. package/dist/cjs/Toolbar/Stack/index.js +1 -1
  59. package/dist/cjs/Toolbar/Stack/index.js.map +1 -1
  60. package/dist/cjs/Toolbar/Title/index.js +1 -1
  61. package/dist/cjs/Toolbar/Title/index.js.map +1 -1
  62. package/dist/cjs/Toolbar/Toolbar/index.js +1 -1
  63. package/dist/cjs/Toolbar/Toolbar/index.js.map +1 -1
  64. package/dist/cjs/generateStyleFromCtx/index.js +16 -10
  65. package/dist/cjs/generateStyleFromCtx/index.js.map +1 -1
  66. package/dist/cjs/icons.js.map +1 -1
  67. package/dist/cjs/mergeRefs/index.js +3 -2
  68. package/dist/cjs/mergeRefs/index.js.map +1 -1
  69. package/dist/cjs/useMediaQuery/index.js +14 -5
  70. package/dist/cjs/useMediaQuery/index.js.map +1 -1
  71. package/dist/esm/Button/index.d.ts +2 -1
  72. package/dist/esm/Button/index.js +5 -5
  73. package/dist/esm/Button/index.js.map +1 -1
  74. package/dist/esm/ButtonGroup/Button/index.d.ts +1 -1
  75. package/dist/esm/ButtonGroup/Button/index.js +1 -1
  76. package/dist/esm/ButtonGroup/Button/index.js.map +1 -1
  77. package/dist/esm/ButtonGroup/Group/index.d.ts +1 -1
  78. package/dist/esm/ButtonGroup/Group/index.js +1 -1
  79. package/dist/esm/ButtonGroup/Group/index.js.map +1 -1
  80. package/dist/esm/Canvas/index.d.ts +2 -2
  81. package/dist/esm/Canvas/index.js +4 -4
  82. package/dist/esm/Canvas/index.js.map +1 -1
  83. package/dist/esm/ContextInspector/index.js +34 -35
  84. package/dist/esm/ContextInspector/index.js.map +1 -1
  85. package/dist/esm/Dropdown/Dropdown.js +4 -3
  86. package/dist/esm/Dropdown/Dropdown.js.map +1 -1
  87. package/dist/esm/Dropdown/Group.d.ts +2 -1
  88. package/dist/esm/Dropdown/Group.js +2 -2
  89. package/dist/esm/Dropdown/Group.js.map +1 -1
  90. package/dist/esm/Dropdown/Menu.js +20 -18
  91. package/dist/esm/Dropdown/Menu.js.map +1 -1
  92. package/dist/esm/Dropdown/MenuContext.d.ts +1 -1
  93. package/dist/esm/Dropdown/MenuContext.js.map +1 -1
  94. package/dist/esm/Dropdown/Option.js +3 -3
  95. package/dist/esm/Dropdown/Option.js.map +1 -1
  96. package/dist/esm/Dropdown/OptionAction.d.ts +2 -1
  97. package/dist/esm/Dropdown/OptionAction.js +1 -1
  98. package/dist/esm/Dropdown/OptionAction.js.map +1 -1
  99. package/dist/esm/Dropdown/Portal.d.ts +2 -1
  100. package/dist/esm/Dropdown/Portal.js +4 -3
  101. package/dist/esm/Dropdown/Portal.js.map +1 -1
  102. package/dist/esm/Dropdown/Separator.js +1 -1
  103. package/dist/esm/Dropdown/Separator.js.map +1 -1
  104. package/dist/esm/Dropdown/Text.js +1 -1
  105. package/dist/esm/Dropdown/Text.js.map +1 -1
  106. package/dist/esm/Dropdown/index.d.ts +6 -6
  107. package/dist/esm/Dropdown/index.js.map +1 -1
  108. package/dist/esm/FieldError/index.d.ts +1 -1
  109. package/dist/esm/FieldError/index.js.map +1 -1
  110. package/dist/esm/FieldGroup/index.js +1 -1
  111. package/dist/esm/FieldGroup/index.js.map +1 -1
  112. package/dist/esm/FieldHint/index.d.ts +1 -1
  113. package/dist/esm/FieldHint/index.js.map +1 -1
  114. package/dist/esm/FieldWrapper/index.d.ts +2 -2
  115. package/dist/esm/FieldWrapper/index.js.map +1 -1
  116. package/dist/esm/Form/index.d.ts +1 -1
  117. package/dist/esm/Form/index.js +1 -1
  118. package/dist/esm/Form/index.js.map +1 -1
  119. package/dist/esm/FormLabel/index.js +1 -1
  120. package/dist/esm/FormLabel/index.js.map +1 -1
  121. package/dist/esm/Section/index.d.ts +1 -1
  122. package/dist/esm/Section/index.js +6 -6
  123. package/dist/esm/Section/index.js.map +1 -1
  124. package/dist/esm/SelectField/index.d.ts +3 -3
  125. package/dist/esm/SelectField/index.js.map +1 -1
  126. package/dist/esm/SelectInput/index.d.ts +4 -4
  127. package/dist/esm/SelectInput/index.js.map +1 -1
  128. package/dist/esm/SidebarPanel/index.d.ts +1 -1
  129. package/dist/esm/SidebarPanel/index.js +5 -5
  130. package/dist/esm/SidebarPanel/index.js.map +1 -1
  131. package/dist/esm/Spinner/index.js +1 -1
  132. package/dist/esm/Spinner/index.js.map +1 -1
  133. package/dist/esm/SwitchField/index.d.ts +2 -2
  134. package/dist/esm/SwitchField/index.js +1 -1
  135. package/dist/esm/SwitchField/index.js.map +1 -1
  136. package/dist/esm/SwitchInput/index.js +5 -5
  137. package/dist/esm/SwitchInput/index.js.map +1 -1
  138. package/dist/esm/TextField/index.d.ts +2 -2
  139. package/dist/esm/TextField/index.js +1 -1
  140. package/dist/esm/TextField/index.js.map +1 -1
  141. package/dist/esm/TextInput/index.d.ts +2 -1
  142. package/dist/esm/TextInput/index.js +3 -2
  143. package/dist/esm/TextInput/index.js.map +1 -1
  144. package/dist/esm/TextareaField/index.d.ts +2 -2
  145. package/dist/esm/TextareaField/index.js.map +1 -1
  146. package/dist/esm/TextareaInput/index.d.ts +2 -1
  147. package/dist/esm/TextareaInput/index.js +3 -2
  148. package/dist/esm/TextareaInput/index.js.map +1 -1
  149. package/dist/esm/Toolbar/Button/index.d.ts +1 -1
  150. package/dist/esm/Toolbar/Button/index.js +1 -1
  151. package/dist/esm/Toolbar/Button/index.js.map +1 -1
  152. package/dist/esm/Toolbar/Stack/index.d.ts +1 -1
  153. package/dist/esm/Toolbar/Stack/index.js +1 -1
  154. package/dist/esm/Toolbar/Stack/index.js.map +1 -1
  155. package/dist/esm/Toolbar/Title/index.d.ts +1 -1
  156. package/dist/esm/Toolbar/Title/index.js +1 -1
  157. package/dist/esm/Toolbar/Title/index.js.map +1 -1
  158. package/dist/esm/Toolbar/Toolbar/index.d.ts +1 -1
  159. package/dist/esm/Toolbar/Toolbar/index.js +1 -1
  160. package/dist/esm/Toolbar/Toolbar/index.js.map +1 -1
  161. package/dist/esm/generateStyleFromCtx/index.d.ts +3 -3
  162. package/dist/esm/generateStyleFromCtx/index.js +16 -10
  163. package/dist/esm/generateStyleFromCtx/index.js.map +1 -1
  164. package/dist/esm/icons.d.ts +1 -1
  165. package/dist/esm/icons.js.map +1 -1
  166. package/dist/esm/mergeRefs/index.js +3 -2
  167. package/dist/esm/mergeRefs/index.js.map +1 -1
  168. package/dist/esm/useMediaQuery/index.js +14 -5
  169. package/dist/esm/useMediaQuery/index.js.map +1 -1
  170. package/dist/types/Button/index.d.ts +2 -1
  171. package/dist/types/ButtonGroup/Button/index.d.ts +1 -1
  172. package/dist/types/ButtonGroup/Group/index.d.ts +1 -1
  173. package/dist/types/Canvas/index.d.ts +2 -2
  174. package/dist/types/Dropdown/Group.d.ts +2 -1
  175. package/dist/types/Dropdown/MenuContext.d.ts +1 -1
  176. package/dist/types/Dropdown/OptionAction.d.ts +2 -1
  177. package/dist/types/Dropdown/Portal.d.ts +2 -1
  178. package/dist/types/Dropdown/index.d.ts +6 -6
  179. package/dist/types/FieldError/index.d.ts +1 -1
  180. package/dist/types/FieldHint/index.d.ts +1 -1
  181. package/dist/types/FieldWrapper/index.d.ts +2 -2
  182. package/dist/types/Form/index.d.ts +1 -1
  183. package/dist/types/Section/index.d.ts +1 -1
  184. package/dist/types/SelectField/index.d.ts +3 -3
  185. package/dist/types/SelectInput/index.d.ts +4 -4
  186. package/dist/types/SidebarPanel/index.d.ts +1 -1
  187. package/dist/types/SwitchField/index.d.ts +2 -2
  188. package/dist/types/TextField/index.d.ts +2 -2
  189. package/dist/types/TextInput/index.d.ts +2 -1
  190. package/dist/types/TextareaField/index.d.ts +2 -2
  191. package/dist/types/TextareaInput/index.d.ts +2 -1
  192. package/dist/types/Toolbar/Button/index.d.ts +1 -1
  193. package/dist/types/Toolbar/Stack/index.d.ts +1 -1
  194. package/dist/types/Toolbar/Title/index.d.ts +1 -1
  195. package/dist/types/Toolbar/Toolbar/index.d.ts +1 -1
  196. package/dist/types/generateStyleFromCtx/index.d.ts +3 -3
  197. package/dist/types/icons.d.ts +1 -1
  198. package/package.json +3 -3
  199. package/src/Button/index.tsx +6 -9
  200. package/src/ButtonGroup/Button/index.tsx +6 -2
  201. package/src/ButtonGroup/Group/index.tsx +2 -2
  202. package/src/Canvas/index.tsx +10 -5
  203. package/src/ContextInspector/index.tsx +76 -80
  204. package/src/Dropdown/Dropdown.tsx +4 -3
  205. package/src/Dropdown/Group.tsx +4 -3
  206. package/src/Dropdown/Menu.tsx +25 -24
  207. package/src/Dropdown/MenuContext.tsx +1 -1
  208. package/src/Dropdown/Option.tsx +3 -3
  209. package/src/Dropdown/OptionAction.tsx +3 -2
  210. package/src/Dropdown/Portal.tsx +5 -4
  211. package/src/Dropdown/Separator.tsx +1 -1
  212. package/src/Dropdown/Text.tsx +1 -1
  213. package/src/Dropdown/index.tsx +6 -6
  214. package/src/FieldError/index.tsx +1 -1
  215. package/src/FieldGroup/index.tsx +1 -1
  216. package/src/FieldHint/index.tsx +1 -1
  217. package/src/FieldWrapper/index.tsx +2 -2
  218. package/src/Form/index.tsx +5 -5
  219. package/src/FormLabel/index.tsx +1 -1
  220. package/src/Section/index.tsx +6 -6
  221. package/src/SelectField/index.tsx +7 -7
  222. package/src/SelectInput/index.tsx +9 -7
  223. package/src/SidebarPanel/index.tsx +8 -8
  224. package/src/Spinner/index.tsx +1 -1
  225. package/src/SwitchField/index.tsx +4 -4
  226. package/src/SwitchInput/index.tsx +5 -5
  227. package/src/TextField/index.tsx +7 -2
  228. package/src/TextInput/index.tsx +3 -2
  229. package/src/TextareaField/index.tsx +3 -3
  230. package/src/TextareaInput/index.tsx +3 -2
  231. package/src/Toolbar/Button/index.tsx +6 -2
  232. package/src/Toolbar/Stack/index.tsx +2 -2
  233. package/src/Toolbar/Title/index.tsx +2 -2
  234. package/src/Toolbar/Toolbar/index.tsx +2 -2
  235. package/src/generateStyleFromCtx/index.ts +22 -18
  236. package/src/icons.tsx +4 -4
  237. package/src/mergeRefs/index.ts +4 -3
  238. package/src/useMediaQuery/index.ts +5 -3
  239. package/types.json +353 -353
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { type ReactNode } from 'react';
2
2
  export declare type SidebarPanelProps = {
3
3
  title?: ReactNode;
4
4
  startOpen?: boolean;
@@ -1,5 +1,5 @@
1
- import { ReactNode } from 'react';
2
- import { FormLabelProps, SwitchInputProps } from '..';
1
+ import { type ReactNode } from 'react';
2
+ import { type FormLabelProps, type SwitchInputProps } from '..';
3
3
  declare type SwitchFieldProps = {
4
4
  id: string;
5
5
  name: string;
@@ -1,5 +1,5 @@
1
- import { ReactNode } from 'react';
2
- import { FormLabelProps, TextInputProps } from '..';
1
+ import { type ReactNode } from 'react';
2
+ import { type FormLabelProps, type TextInputProps } from '..';
3
3
  declare type TextFieldProps = {
4
4
  id: string;
5
5
  name: string;
@@ -1,4 +1,5 @@
1
- import React, { RefObject } from 'react';
1
+ import React from 'react';
2
+ import { type RefObject } from 'react';
2
3
  export declare type TextInputChangeEventHandler = (newValue: string, event: React.ChangeEvent<HTMLInputElement>) => void;
3
4
  export declare type TextInputProps = {
4
5
  type?: 'text' | 'password' | 'email' | 'number' | 'search' | 'url' | 'date' | 'time';
@@ -1,5 +1,5 @@
1
- import { ReactNode } from 'react';
2
- import { FormLabelProps, TextareaInputProps } from '..';
1
+ import { type ReactNode } from 'react';
2
+ import { type FormLabelProps, type TextareaInputProps } from '..';
3
3
  declare type TextareaFieldProps = {
4
4
  id: string;
5
5
  name: string;
@@ -1,4 +1,5 @@
1
- import React, { RefObject } from 'react';
1
+ import React from 'react';
2
+ import { type RefObject } from 'react';
2
3
  export declare type TextareaInputChangeEventHandler = (newValue: string, event: React.ChangeEvent<HTMLTextAreaElement>) => void;
3
4
  export declare type TextareaInputProps = {
4
5
  name?: string;
@@ -1,4 +1,4 @@
1
- import { CSSProperties, MouseEventHandler, ReactNode } from 'react';
1
+ import { type CSSProperties, type MouseEventHandler, type ReactNode } from 'react';
2
2
  export declare type ButtonProps = {
3
3
  children?: ReactNode;
4
4
  className?: string;
@@ -1,4 +1,4 @@
1
- import { CSSProperties, ReactNode } from 'react';
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
2
  export declare type StackProps = {
3
3
  children?: ReactNode;
4
4
  className?: string;
@@ -1,4 +1,4 @@
1
- import { CSSProperties, ReactNode } from 'react';
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
2
  export declare type TitleProps = {
3
3
  children?: ReactNode;
4
4
  className?: string;
@@ -1,4 +1,4 @@
1
- import { CSSProperties, ReactNode } from 'react';
1
+ import { type CSSProperties, type ReactNode } from 'react';
2
2
  export declare type ToolbarProps = {
3
3
  children?: ReactNode;
4
4
  className?: string;
@@ -1,3 +1,3 @@
1
- import { RenderProperties } from 'datocms-plugin-sdk';
2
- import { CSSProperties } from 'react';
3
- export declare function generateStyleFromCtx(ctx: RenderProperties): CSSProperties;
1
+ import type { RenderProperties } from 'datocms-plugin-sdk';
2
+ import type { CSSProperties } from 'react';
3
+ export declare function generateStyleFromCtx(ctx: RenderProperties, noBodyPadding?: boolean): CSSProperties;
@@ -1,4 +1,4 @@
1
- import { CSSProperties } from 'react';
1
+ import { type CSSProperties } from 'react';
2
2
  export declare type IconProps = {
3
3
  width?: string | number;
4
4
  height?: string | number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datocms-react-ui",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "React components to use inside DatoCMS plugins",
5
5
  "keywords": [
6
6
  "datocms",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "classnames": "^2.3.1",
44
- "datocms-plugin-sdk": "^1.0.1",
44
+ "datocms-plugin-sdk": "^1.1.0",
45
45
  "react-intersection-observer": "^8.31.0",
46
46
  "react-select": "^5.2.1",
47
47
  "scroll-into-view-if-needed": "^2.2.20"
@@ -57,5 +57,5 @@
57
57
  "postcss-nested": "^5.0.6",
58
58
  "typedoc": "^0.23.20"
59
59
  },
60
- "gitHead": "c9263fd5eaa3e84244ff55314521d24ebf5813a1"
60
+ "gitHead": "fa6d8ee19dcbc6553af5bf1a74dcca5d50db21e7"
61
61
  }
@@ -1,5 +1,6 @@
1
- import React, { CSSProperties, MouseEventHandler, ReactNode } from 'react';
2
1
  import cn from 'classnames';
2
+ import React from 'react';
3
+ import type { CSSProperties, MouseEventHandler, ReactNode } from 'react';
3
4
  import styles from './styles.module.css.json';
4
5
 
5
6
  export type ButtonProps = {
@@ -107,12 +108,10 @@ export function Button({
107
108
  onClick={onClick}
108
109
  style={style}
109
110
  >
110
- {leftIcon && (
111
- <span className={styles['button__leftIcon']}>{leftIcon}</span>
112
- )}
111
+ {leftIcon && <span className={styles.button__leftIcon}>{leftIcon}</span>}
113
112
  {children && <span>{children}</span>}
114
113
  {rightIcon && (
115
- <span className={styles['button__rightIcon']}>{rightIcon}</span>
114
+ <span className={styles.button__rightIcon}>{rightIcon}</span>
116
115
  )}
117
116
  </button>
118
117
  );
@@ -161,12 +160,10 @@ export function ButtonLink({
161
160
  style={style}
162
161
  onClick={onClick}
163
162
  >
164
- {leftIcon && (
165
- <span className={styles['button__leftIcon']}>{leftIcon}</span>
166
- )}
163
+ {leftIcon && <span className={styles.button__leftIcon}>{leftIcon}</span>}
167
164
  {children && <span>{children}</span>}
168
165
  {rightIcon && (
169
- <span className={styles['button__rightIcon']}>{rightIcon}</span>
166
+ <span className={styles.button__rightIcon}>{rightIcon}</span>
170
167
  )}
171
168
  </a>
172
169
  );
@@ -1,5 +1,9 @@
1
1
  import classNames from 'classnames';
2
- import React, { CSSProperties, MouseEventHandler, ReactNode } from 'react';
2
+ import React, {
3
+ type CSSProperties,
4
+ type MouseEventHandler,
5
+ type ReactNode,
6
+ } from 'react';
3
7
  import s from './styles.module.css.json';
4
8
 
5
9
  export type ButtonProps = {
@@ -25,7 +29,7 @@ export function Button({
25
29
  onClick={onClick}
26
30
  disabled={disabled}
27
31
  className={classNames(
28
- s['Button'],
32
+ s.Button,
29
33
  {
30
34
  [s['Button--selected']]: selected,
31
35
  [s['Button--disabled']]: disabled,
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import React, { CSSProperties, ReactNode } from 'react';
2
+ import React, { type CSSProperties, type ReactNode } from 'react';
3
3
  import s from './styles.module.css.json';
4
4
 
5
5
  export type GroupProps = {
@@ -24,7 +24,7 @@ export type GroupProps = {
24
24
  */
25
25
  export function Group({ children, style, className }: GroupProps): JSX.Element {
26
26
  return (
27
- <div className={classNames(s['Group'], className)} style={style}>
27
+ <div className={classNames(s.Group, className)} style={style}>
28
28
  {children}
29
29
  </div>
30
30
  );
@@ -1,12 +1,17 @@
1
- import React, { createContext, ReactNode, useContext, useEffect } from 'react';
2
- import {
1
+ import classNames from 'classnames';
2
+ import type {
3
3
  RenderMethods,
4
4
  RenderProperties,
5
5
  SizingUtilities,
6
6
  } from 'datocms-plugin-sdk';
7
- import s from './styles.module.css.json';
7
+ import React, {
8
+ createContext,
9
+ type ReactNode,
10
+ useContext,
11
+ useEffect,
12
+ } from 'react';
8
13
  import { generateStyleFromCtx } from '../generateStyleFromCtx';
9
- import classNames from 'classnames';
14
+ import s from './styles.module.css.json';
10
15
 
11
16
  type BaseRenderPropertiesAndMethods = RenderProperties & RenderMethods;
12
17
 
@@ -550,7 +555,7 @@ export function Canvas({
550
555
  return (
551
556
  <CtxContext.Provider value={ctx}>
552
557
  <div
553
- className={classNames(s['themeVariables'], s['canvas'])}
558
+ className={classNames(s.themeVariables, s.canvas)}
554
559
  style={generateStyleFromCtx(ctx)}
555
560
  >
556
561
  {children}
@@ -99,7 +99,7 @@ function buildCtx(manifest: any, definition: any): any {
99
99
  if (definition.type.type === 'intersection') {
100
100
  let result: any[] = [];
101
101
 
102
- definition.type.types.forEach((elementInIntersection: any) => {
102
+ for (const elementInIntersection of definition.type.types) {
103
103
  if (elementInIntersection.type === 'reference') {
104
104
  const innerDefinition = findChildrenById(
105
105
  manifest,
@@ -107,7 +107,7 @@ function buildCtx(manifest: any, definition: any): any {
107
107
  );
108
108
  result = [...result, buildCtx(manifest, innerDefinition)];
109
109
  }
110
- });
110
+ }
111
111
 
112
112
  return result.flat().filter((x) => x);
113
113
  }
@@ -128,11 +128,7 @@ function buildCtx(manifest: any, definition: any): any {
128
128
  name: definition.name,
129
129
  description: findShortText(definition),
130
130
  properties: properties.map((child: any) => {
131
- if (
132
- child.type &&
133
- child.type.declaration &&
134
- child.type.declaration.signatures
135
- ) {
131
+ if (child.type?.declaration?.signatures) {
136
132
  child.signatures = child.type.declaration.signatures;
137
133
  }
138
134
 
@@ -176,6 +172,7 @@ const ExpandablePane = ({ children, label }: any) => {
176
172
  return (
177
173
  <div className={s.panel}>
178
174
  <button
175
+ type="button"
179
176
  className={s.panelHandle}
180
177
  onClick={() => setOpen((open) => !open)}
181
178
  >
@@ -249,81 +246,80 @@ export function ContextInspector(): JSX.Element {
249
246
 
250
247
  return (
251
248
  <div className={s.inspector}>
252
- {groups &&
253
- groups.map((group) => {
254
- const name = group.name
255
- .replace('AdditionalMethods', 'Methods')
256
- .replace('AdditionalProperties', 'Properties')
257
- .replace('Methods', ' methods')
258
- .replace('Properties', ' properties')
259
- .replace('Utilities', ' utilities');
260
-
261
- return (
262
- <ExpandablePane label={`${name}`} key={name}>
263
- <div className={s.groupDescription}>{group.description}</div>
264
- <div className={s.propertyGroup}>
265
- {(group.properties || []).map((item: any) => (
266
- <div key={item.name} className={s.propertyOrMethod}>
267
- <div className={s.propertyOrMethodBody}>
268
- <a
269
- className={s.propertyOrMethodName}
270
- href={`${baseUrl}#L${item.lineNumber}`}
271
- target="_blank"
272
- rel="noreferrer"
273
- >
274
- {item.name}
275
- {item.type === 'function' ? '()' : ''}
276
- </a>
277
-
278
- <div>{item.description}</div>
279
- </div>
280
- {item.type === 'property' && (
281
- <div className={s.propertyOrMethodExample}>
282
- <pre>
283
- {JSON.stringify((ctx as any)[item.name], null, 2)}
284
- </pre>
285
- <div className={s.propertyOrMethodExampleActions}>
286
- <Button
287
- type="button"
288
- buttonSize="xxs"
289
- onClick={handleCopy.bind(
290
- null,
291
- JSON.stringify((ctx as any)[item.name], null, 2),
292
- )}
293
- >
294
- Copy value
295
- </Button>
296
- </div>
249
+ {groups?.map((group) => {
250
+ const name = group.name
251
+ .replace('AdditionalMethods', 'Methods')
252
+ .replace('AdditionalProperties', 'Properties')
253
+ .replace('Methods', ' methods')
254
+ .replace('Properties', ' properties')
255
+ .replace('Utilities', ' utilities');
256
+
257
+ return (
258
+ <ExpandablePane label={`${name}`} key={name}>
259
+ <div className={s.groupDescription}>{group.description}</div>
260
+ <div className={s.propertyGroup}>
261
+ {(group.properties || []).map((item: any) => (
262
+ <div key={item.name} className={s.propertyOrMethod}>
263
+ <div className={s.propertyOrMethodBody}>
264
+ <a
265
+ className={s.propertyOrMethodName}
266
+ href={`${baseUrl}#L${item.lineNumber}`}
267
+ target="_blank"
268
+ rel="noreferrer"
269
+ >
270
+ {item.name}
271
+ {item.type === 'function' ? '()' : ''}
272
+ </a>
273
+
274
+ <div>{item.description}</div>
275
+ </div>
276
+ {item.type === 'property' && (
277
+ <div className={s.propertyOrMethodExample}>
278
+ <pre>
279
+ {JSON.stringify((ctx as any)[item.name], null, 2)}
280
+ </pre>
281
+ <div className={s.propertyOrMethodExampleActions}>
282
+ <Button
283
+ type="button"
284
+ buttonSize="xxs"
285
+ onClick={handleCopy.bind(
286
+ null,
287
+ JSON.stringify((ctx as any)[item.name], null, 2),
288
+ )}
289
+ >
290
+ Copy value
291
+ </Button>
297
292
  </div>
298
- )}
299
- {item.example && (
300
- <div className={s.propertyOrMethodExample}>
301
- <pre>{item.example}</pre>
302
- <div className={s.propertyOrMethodExampleActions}>
303
- <Button
304
- type="button"
305
- buttonSize="xxs"
306
- buttonType="primary"
307
- onClick={handleRun.bind(null, item.example)}
308
- >
309
- Run example
310
- </Button>
311
- <Button
312
- type="button"
313
- buttonSize="xxs"
314
- onClick={handleCopy.bind(null, item.example)}
315
- >
316
- Copy example
317
- </Button>
318
- </div>
293
+ </div>
294
+ )}
295
+ {item.example && (
296
+ <div className={s.propertyOrMethodExample}>
297
+ <pre>{item.example}</pre>
298
+ <div className={s.propertyOrMethodExampleActions}>
299
+ <Button
300
+ type="button"
301
+ buttonSize="xxs"
302
+ buttonType="primary"
303
+ onClick={handleRun.bind(null, item.example)}
304
+ >
305
+ Run example
306
+ </Button>
307
+ <Button
308
+ type="button"
309
+ buttonSize="xxs"
310
+ onClick={handleCopy.bind(null, item.example)}
311
+ >
312
+ Copy example
313
+ </Button>
319
314
  </div>
320
- )}
321
- </div>
322
- ))}
323
- </div>
324
- </ExpandablePane>
325
- );
326
- })}
315
+ </div>
316
+ )}
317
+ </div>
318
+ ))}
319
+ </div>
320
+ </ExpandablePane>
321
+ );
322
+ })}
327
323
  </div>
328
324
  );
329
325
  }
@@ -1,4 +1,5 @@
1
- import React, { useCallback, useState } from 'react';
1
+ import React from 'react';
2
+ import { useCallback, useState } from 'react';
2
3
  import { useClickOutside } from '../useClickOutside';
3
4
  import { DropdownContext } from './DropdownContext';
4
5
  import s from './styles.module.css.json';
@@ -123,7 +124,7 @@ export function Dropdown({
123
124
 
124
125
  const handleClickOutside = useCallback(
125
126
  (event) => {
126
- if (!event.target.closest('.' + s['Dropdown__menu']) && isOpen) {
127
+ if (!event.target.closest(`.${s.Dropdown__menu}`) && isOpen) {
127
128
  setOpen(false);
128
129
  }
129
130
  },
@@ -142,7 +143,7 @@ export function Dropdown({
142
143
 
143
144
  return (
144
145
  <DropdownContext.Provider value={{ closeMenu: handleClose }}>
145
- <div className={s['Dropdown']} ref={outsideRef}>
146
+ <div className={s.Dropdown} ref={outsideRef}>
146
147
  {renderTrigger({ open: isOpen, onClick: handleToggle })}
147
148
  {isOpen && children}
148
149
  </div>
@@ -1,4 +1,5 @@
1
- import React, { ReactNode } from 'react';
1
+ import React from 'react';
2
+ import type { ReactNode } from 'react';
2
3
  import s from './styles.module.css.json';
3
4
 
4
5
  export type GroupProps = {
@@ -9,8 +10,8 @@ export type GroupProps = {
9
10
  export const Group = ({ children, name }: GroupProps): JSX.Element => {
10
11
  return (
11
12
  <div>
12
- <div className={s['Dropdown__menu__group__title']}>{name}</div>
13
- <div className={s['Dropdown__menu__group__content']}>{children}</div>
13
+ <div className={s.Dropdown__menu__group__title}>{name}</div>
14
+ <div className={s.Dropdown__menu__group__content}>{children}</div>
14
15
  </div>
15
16
  );
16
17
  };
@@ -1,20 +1,20 @@
1
1
  import React, {
2
2
  createRef,
3
- SyntheticEvent,
3
+ type SyntheticEvent,
4
4
  useCallback,
5
5
  useContext,
6
6
  useEffect,
7
7
  useRef,
8
8
  useState,
9
9
  } from 'react';
10
- import scrollIntoView from 'scroll-into-view-if-needed';
11
10
  import { useInView } from 'react-intersection-observer';
12
- import { Portal } from './Portal';
11
+ import scrollIntoView from 'scroll-into-view-if-needed';
12
+ import { mergeRefs } from '../mergeRefs';
13
13
  import { DropdownContext } from './DropdownContext';
14
14
  import { Group } from './Group';
15
15
  import { MenuContext } from './MenuContext';
16
+ import { Portal } from './Portal';
16
17
  import s from './styles.module.css.json';
17
- import { mergeRefs } from '../mergeRefs';
18
18
 
19
19
  const MenuDesktopContainer = React.forwardRef<
20
20
  HTMLDivElement,
@@ -33,13 +33,17 @@ const MenuDesktopContainer = React.forwardRef<
33
33
 
34
34
  function getAbsoluteHeight(el: HTMLElement) {
35
35
  const styles = window.getComputedStyle(el);
36
- const margin = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
36
+ const margin =
37
+ Number.parseFloat(styles.marginTop) +
38
+ Number.parseFloat(styles.marginBottom);
37
39
  return Math.ceil(el.offsetHeight + margin);
38
40
  }
39
41
 
40
42
  function getAbsoluteWidth(el: HTMLElement) {
41
43
  const styles = window.getComputedStyle(el);
42
- const margin = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
44
+ const margin =
45
+ Number.parseFloat(styles.marginLeft) +
46
+ Number.parseFloat(styles.marginRight);
43
47
  return Math.ceil(el.offsetWidth + margin);
44
48
  }
45
49
 
@@ -68,14 +72,14 @@ function setPosition(
68
72
  window.innerHeight || 0,
69
73
  );
70
74
 
71
- const menu = panel.querySelector<HTMLElement>('.' + s['Dropdown__menu']);
75
+ const menu = panel.querySelector<HTMLElement>(`.${s.Dropdown__menu}`);
72
76
 
73
77
  if (!menu) {
74
78
  return;
75
79
  }
76
80
 
77
81
  const styles = window.getComputedStyle(menu);
78
- const marginTop = parseFloat(styles.marginTop);
82
+ const marginTop = Number.parseFloat(styles.marginTop);
79
83
 
80
84
  const fitsBelow = rect.bottom + height <= windowHeight;
81
85
  const fitsAbove = rect.top - height > 0;
@@ -96,7 +100,7 @@ function setPosition(
96
100
  menu.style.maxHeight = `${windowHeight - rect.bottom - marginTop - 10}px`;
97
101
  } else {
98
102
  // eslint-disable-next-line no-param-reassign
99
- panel.style.top = `0px`;
103
+ panel.style.top = '0px';
100
104
  menu.style.maxHeight = `${rect.top - marginTop}px`;
101
105
  }
102
106
  }
@@ -178,20 +182,18 @@ export const Menu = ({
178
182
  const delta = event.key === 'ArrowUp' ? -1 : 1;
179
183
 
180
184
  const selectedOption = contentRef.current.querySelector(
181
- '.' + s['Dropdown__menu__option--is-selected'],
185
+ `.${s['Dropdown__menu__option--is-selected']}`,
182
186
  );
183
187
 
184
- let nextOption;
188
+ let nextOption: Element | null;
185
189
 
186
190
  if (!selectedOption) {
187
191
  nextOption = contentRef.current.querySelector(
188
- '.' + s['Dropdown__menu__option'],
192
+ `.${s.Dropdown__menu__option}`,
189
193
  );
190
194
  } else {
191
195
  const elements = Array.from(
192
- contentRef.current.querySelectorAll(
193
- '.' + s['Dropdown__menu__option'],
194
- ),
196
+ contentRef.current.querySelectorAll(`.${s.Dropdown__menu__option}`),
195
197
  );
196
198
  const index = elements.findIndex((el) => el === selectedOption);
197
199
  const nextIndex =
@@ -223,13 +225,13 @@ export const Menu = ({
223
225
  }
224
226
 
225
227
  const selectedOption = contentRef.current.querySelector(
226
- '.' + s['Dropdown__menu__option--is-selected'],
228
+ `.${s['Dropdown__menu__option--is-selected']}`,
227
229
  );
228
230
 
229
231
  if (selectedOption) {
230
232
  const id = (selectedOption as HTMLButtonElement).dataset.optionId;
231
233
  const option = options.find((x) => x.id === id);
232
- if (option && option.handler) {
234
+ if (option?.handler) {
233
235
  option.handler(event);
234
236
  }
235
237
  }
@@ -280,31 +282,30 @@ export const Menu = ({
280
282
  <>
281
283
  <div
282
284
  ref={mergeRefs(observerRef, parentRef)}
283
- className={s['Dropdown__spacer']}
285
+ className={s.Dropdown__spacer}
284
286
  />
285
287
  <MenuDesktopContainer ref={menuRef}>
286
- <div className={s['Dropdown__menu']}>
288
+ <div className={s.Dropdown__menu}>
287
289
  {options.length > 5 && (
288
- <div className={s['Dropdown__menu__search']}>
290
+ <div className={s.Dropdown__menu__search}>
289
291
  <input
290
292
  type="text"
291
293
  value={searchTerm || ''}
292
294
  onChange={handleChange}
293
295
  onKeyDown={handleKeyDown}
294
296
  placeholder="Search..."
295
- autoFocus
296
- className={s['Dropdown__menu__search__input']}
297
+ className={s.Dropdown__menu__search__input}
297
298
  />
298
299
  </div>
299
300
  )}
300
301
  <MenuContext.Provider
301
302
  value={{ searchTerm, addOption, setClickHandlerForOption }}
302
303
  >
303
- <div className={s['Dropdown__menu__inner']} ref={contentRef}>
304
+ <div className={s.Dropdown__menu__inner} ref={contentRef}>
304
305
  {anyGroup ? (
305
306
  children
306
307
  ) : (
307
- <div className={s['Dropdown__menu__group__content']}>
308
+ <div className={s.Dropdown__menu__group__content}>
308
309
  {children}
309
310
  </div>
310
311
  )}
@@ -1,4 +1,4 @@
1
- import { createContext, SyntheticEvent } from 'react';
1
+ import { type SyntheticEvent, createContext } from 'react';
2
2
 
3
3
  type Context = {
4
4
  searchTerm: string;
@@ -118,21 +118,21 @@ export const Option = ({
118
118
  <>
119
119
  <button
120
120
  type="button"
121
- className={s['Dropdown__menu__option__content']}
121
+ className={s.Dropdown__menu__option__content}
122
122
  ref={contentRef}
123
123
  onClick={handleClick}
124
124
  >
125
125
  {notButtons}
126
126
  </button>
127
127
  {buttons.length > 0 && (
128
- <div className={s['Dropdown__menu__option__icons']}>{buttons}</div>
128
+ <div className={s.Dropdown__menu__option__icons}>{buttons}</div>
129
129
  )}
130
130
  </>
131
131
  );
132
132
 
133
133
  return (
134
134
  <div
135
- className={classNames(s['Dropdown__menu__option'], {
135
+ className={classNames(s.Dropdown__menu__option, {
136
136
  [s['Dropdown__menu__option--is-active']]: active,
137
137
  [s['Dropdown__menu__option--is-disabled']]: disabled,
138
138
  [s['Dropdown__menu__option--is-valid']]: valid,