@react-ui-org/react-ui 0.64.0 → 0.65.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 (293) hide show
  1. package/README.md +3 -6
  2. package/dist/react-ui.css +16 -16
  3. package/dist/react-ui.d.ts +1928 -0
  4. package/dist/react-ui.development.css +2916 -2915
  5. package/dist/react-ui.development.js +2019 -1051
  6. package/dist/react-ui.js +1 -1
  7. package/package.json +74 -70
  8. package/scripts/write-lockfile-hash.sh +6 -0
  9. package/src/components/Alert/{Alert.jsx → Alert.tsx} +8 -43
  10. package/src/components/Alert/Alert.types.ts +34 -0
  11. package/src/components/Alert/README.md +1 -1
  12. package/src/components/Alert/index.ts +2 -0
  13. package/src/components/Badge/Badge.tsx +30 -0
  14. package/src/components/Badge/Badge.types.ts +24 -0
  15. package/src/components/Badge/README.md +1 -1
  16. package/src/components/Badge/index.ts +5 -0
  17. package/src/components/Button/Button.tsx +110 -0
  18. package/src/components/Button/Button.types.ts +93 -0
  19. package/src/components/Button/README.md +1 -1
  20. package/src/components/Button/helpers/{getRootLabelVisibilityClassName.js → getRootLabelVisibilityClassName.ts} +4 -1
  21. package/src/components/Button/index.ts +6 -0
  22. package/src/components/ButtonGroup/{ButtonGroup.jsx → ButtonGroup.tsx} +9 -40
  23. package/src/components/ButtonGroup/ButtonGroup.types.ts +45 -0
  24. package/src/components/ButtonGroup/ButtonGroupContext.ts +4 -0
  25. package/src/components/ButtonGroup/README.md +1 -1
  26. package/src/components/ButtonGroup/{index.js → index.ts} +4 -0
  27. package/src/components/Card/Card.tsx +33 -0
  28. package/src/components/Card/Card.types.ts +46 -0
  29. package/src/components/Card/{CardBody.jsx → CardBody.tsx} +4 -11
  30. package/src/components/Card/{CardFooter.jsx → CardFooter.tsx} +4 -15
  31. package/src/components/Card/README.md +6 -7
  32. package/src/components/Card/{index.js → index.ts} +5 -0
  33. package/src/components/CheckboxField/CheckboxField.tsx +81 -0
  34. package/src/components/CheckboxField/CheckboxField.types.ts +63 -0
  35. package/src/components/CheckboxField/README.md +67 -42
  36. package/src/components/CheckboxField/index.ts +5 -0
  37. package/src/components/FileInputField/{FileInputField.jsx → FileInputField.tsx} +42 -128
  38. package/src/components/FileInputField/FileInputField.types.ts +100 -0
  39. package/src/components/FileInputField/README.md +1 -1
  40. package/src/components/FileInputField/index.ts +6 -0
  41. package/src/components/FormLayout/FormLayout.module.scss +1 -1
  42. package/src/components/FormLayout/{FormLayout.jsx → FormLayout.tsx} +15 -50
  43. package/src/components/FormLayout/FormLayout.types.ts +55 -0
  44. package/src/components/FormLayout/FormLayoutContext.ts +4 -0
  45. package/src/components/FormLayout/{FormLayoutCustomField.jsx → FormLayoutCustomField.tsx} +10 -65
  46. package/src/components/FormLayout/FormLayoutCustomField.types.ts +59 -0
  47. package/src/components/FormLayout/FormLayoutCustomFieldContext.ts +4 -0
  48. package/src/components/FormLayout/README.md +4 -6
  49. package/src/components/FormLayout/index.ts +14 -0
  50. package/src/components/Grid/Grid.module.scss +1 -1
  51. package/src/components/Grid/Grid.tsx +50 -0
  52. package/src/components/Grid/Grid.types.ts +108 -0
  53. package/src/components/Grid/GridSpan.tsx +36 -0
  54. package/src/components/Grid/README.md +2 -2
  55. package/src/components/Grid/_helpers/generateResponsiveCustomProperties.ts +32 -0
  56. package/src/components/Grid/index.ts +9 -0
  57. package/src/components/InputGroup/{InputGroup.jsx → InputGroup.tsx} +25 -89
  58. package/src/components/InputGroup/InputGroup.types.ts +80 -0
  59. package/src/components/InputGroup/InputGroupContext.ts +4 -0
  60. package/src/components/InputGroup/README.md +5 -1
  61. package/src/components/InputGroup/{index.js → index.ts} +4 -0
  62. package/src/components/Modal/Modal.tsx +172 -0
  63. package/src/components/Modal/Modal.types.ts +181 -0
  64. package/src/components/Modal/ModalBody.tsx +34 -0
  65. package/src/components/Modal/{ModalCloseButton.jsx → ModalCloseButton.tsx} +6 -19
  66. package/src/components/Modal/{ModalContent.jsx → ModalContent.tsx} +4 -15
  67. package/src/components/Modal/ModalFooter.tsx +27 -0
  68. package/src/components/Modal/ModalHeader.tsx +27 -0
  69. package/src/components/Modal/ModalTitle.tsx +29 -0
  70. package/src/components/Modal/README.md +9 -9
  71. package/src/components/Modal/_helpers/{dialogOnCancelHandler.js → dialogOnCancelHandler.ts} +11 -1
  72. package/src/components/Modal/_helpers/{dialogOnClickHandler.js → dialogOnClickHandler.ts} +13 -7
  73. package/src/components/Modal/_helpers/{dialogOnCloseHandler.js → dialogOnCloseHandler.ts} +11 -1
  74. package/src/components/Modal/_helpers/{dialogOnKeyDownHandler.js → dialogOnKeyDownHandler.ts} +19 -6
  75. package/src/components/Modal/_helpers/{getJustifyClassName.js → getJustifyClassName.ts} +4 -1
  76. package/src/components/Modal/_helpers/getPositionClassName.ts +10 -0
  77. package/src/components/Modal/_helpers/getScrollingClassName.ts +14 -0
  78. package/src/components/Modal/_helpers/{getSizeClassName.js → getSizeClassName.ts} +4 -1
  79. package/src/components/Modal/_hooks/{useModalFocus.js → useModalFocus.ts} +9 -5
  80. package/src/components/Modal/_hooks/{useModalScrollPrevention.js → useModalScrollPrevention.ts} +4 -1
  81. package/src/components/Modal/{index.js → index.ts} +14 -0
  82. package/src/components/Paper/{Paper.jsx → Paper.tsx} +6 -26
  83. package/src/components/Paper/Paper.types.ts +19 -0
  84. package/src/components/Paper/README.md +3 -4
  85. package/src/components/Paper/index.ts +2 -0
  86. package/src/components/Popover/Popover.module.scss +1 -1
  87. package/src/components/Popover/Popover.tsx +61 -0
  88. package/src/components/Popover/Popover.types.ts +75 -0
  89. package/src/components/Popover/PopoverWrapper.tsx +27 -0
  90. package/src/components/Popover/README.md +34 -22
  91. package/src/components/Popover/_helpers/{cleanPlacementStyle.js → cleanPlacementStyle.ts} +4 -1
  92. package/src/components/Popover/_helpers/{getRootAlignmentClassName.js → getRootAlignmentClassName.ts} +4 -1
  93. package/src/components/Popover/_helpers/{getRootSideClassName.js → getRootSideClassName.ts} +4 -1
  94. package/src/components/Popover/index.ts +8 -0
  95. package/src/components/Radio/README.md +85 -45
  96. package/src/components/Radio/{Radio.jsx → Radio.tsx} +11 -107
  97. package/src/components/Radio/Radio.types.ts +90 -0
  98. package/src/components/Radio/index.ts +5 -0
  99. package/src/components/ScrollView/README.md +1 -1
  100. package/src/components/ScrollView/ScrollView.module.scss +5 -0
  101. package/src/components/ScrollView/{ScrollView.jsx → ScrollView.tsx} +55 -166
  102. package/src/components/ScrollView/ScrollView.types.ts +121 -0
  103. package/src/components/ScrollView/_helpers/getElementsPositionDifference.ts +17 -0
  104. package/src/components/ScrollView/_hooks/{useLoadResizeHook.js → useLoadResizeHook.ts} +14 -3
  105. package/src/components/ScrollView/_hooks/{useScrollPositionHook.js → useScrollPositionHook.ts} +11 -4
  106. package/src/components/ScrollView/index.ts +6 -0
  107. package/src/components/SelectField/README.md +84 -45
  108. package/src/components/SelectField/SelectField.tsx +139 -0
  109. package/src/components/SelectField/SelectField.types.ts +120 -0
  110. package/src/components/SelectField/_components/Option/Option.tsx +19 -0
  111. package/src/components/SelectField/_components/Option/Option.types.ts +21 -0
  112. package/src/components/SelectField/_components/Option/index.ts +2 -0
  113. package/src/components/SelectField/index.ts +7 -0
  114. package/src/components/Table/README.md +1 -1
  115. package/src/components/Table/{Table.jsx → Table.tsx} +4 -43
  116. package/src/components/Table/Table.types.ts +51 -0
  117. package/src/components/Table/_components/TableBodyCell/TableBodyCell.tsx +20 -0
  118. package/src/components/Table/_components/TableBodyCell/TableBodyCell.types.ts +20 -0
  119. package/src/components/Table/_components/TableBodyCell/index.ts +2 -0
  120. package/src/components/Table/_components/TableHeaderCell/{TableHeaderCell.jsx → TableHeaderCell.tsx} +3 -34
  121. package/src/components/Table/_components/TableHeaderCell/TableHeaderCell.types.ts +20 -0
  122. package/src/components/Table/_components/TableHeaderCell/index.ts +2 -0
  123. package/src/components/Table/index.ts +8 -0
  124. package/src/components/Tabs/README.md +2 -2
  125. package/src/components/Tabs/{Tabs.jsx → Tabs.tsx} +4 -20
  126. package/src/components/Tabs/Tabs.types.ts +19 -0
  127. package/src/components/Tabs/TabsItem.tsx +49 -0
  128. package/src/components/Tabs/TabsItem.types.ts +42 -0
  129. package/src/components/Tabs/index.ts +4 -0
  130. package/src/components/Text/README.md +1 -1
  131. package/src/components/Text/Text.module.scss +5 -7
  132. package/src/components/Text/Text.tsx +46 -0
  133. package/src/components/Text/Text.types.ts +31 -0
  134. package/src/components/Text/_helpers/getRootClampClassName.ts +13 -0
  135. package/src/components/Text/_helpers/getRootHyphensClassName.ts +14 -0
  136. package/src/components/Text/_helpers/getRootWordWrappingClassName.ts +14 -0
  137. package/src/components/Text/index.ts +6 -0
  138. package/src/components/TextArea/README.md +5 -8
  139. package/src/components/TextArea/TextArea.tsx +95 -0
  140. package/src/components/TextArea/TextArea.types.ts +75 -0
  141. package/src/components/TextArea/index.ts +5 -0
  142. package/src/components/TextField/README.md +5 -7
  143. package/src/components/TextField/TextField.tsx +112 -0
  144. package/src/components/TextField/TextField.types.ts +94 -0
  145. package/src/components/TextField/index.ts +6 -0
  146. package/src/components/TextLink/README.md +1 -1
  147. package/src/components/TextLink/{TextLink.jsx → TextLink.tsx} +4 -15
  148. package/src/components/TextLink/TextLink.types.ts +12 -0
  149. package/src/components/TextLink/index.ts +2 -0
  150. package/src/components/Toggle/README.md +67 -42
  151. package/src/components/Toggle/Toggle.tsx +82 -0
  152. package/src/components/Toggle/Toggle.types.ts +58 -0
  153. package/src/components/Toggle/index.ts +5 -0
  154. package/src/components/Toolbar/README.md +3 -3
  155. package/src/components/Toolbar/Toolbar.tsx +41 -0
  156. package/src/components/Toolbar/Toolbar.types.ts +74 -0
  157. package/src/components/Toolbar/ToolbarGroup.tsx +38 -0
  158. package/src/components/Toolbar/{ToolbarItem.jsx → ToolbarItem.tsx} +5 -21
  159. package/src/components/Toolbar/_helpers/{getAlignClassName.js → getAlignClassName.ts} +8 -1
  160. package/src/components/Toolbar/_helpers/{getJustifyClassName.js → getJustifyClassName.ts} +4 -1
  161. package/src/components/Toolbar/{index.js → index.ts} +7 -0
  162. package/src/components/_helpers/{getRootColorClassName.js → getRootColorClassName.ts} +6 -1
  163. package/src/components/_helpers/{getRootPriorityClassName.js → getRootPriorityClassName.ts} +6 -1
  164. package/src/components/_helpers/{getRootSizeClassName.js → getRootSizeClassName.ts} +6 -1
  165. package/src/components/_helpers/{getRootValidationStateClassName.js → getRootValidationStateClassName.ts} +6 -1
  166. package/src/components/_helpers/resolveContextOrProp.ts +13 -0
  167. package/src/helpers/classNames/{classNames.js → classNames.ts} +2 -2
  168. package/src/helpers/isChildrenEmpty/isChildrenEmpty.ts +5 -0
  169. package/src/helpers/transferProps/transferProps.ts +50 -0
  170. package/src/helpers/transferProps/transferProps.types.ts +11 -0
  171. package/src/index.ts +211 -0
  172. package/src/providers/globalProps/GlobalProps.types.ts +30 -0
  173. package/src/providers/globalProps/GlobalPropsContext.ts +6 -0
  174. package/src/providers/globalProps/{GlobalPropsProvider.jsx → GlobalPropsProvider.tsx} +8 -15
  175. package/src/providers/globalProps/{index.js → index.ts} +4 -0
  176. package/src/providers/globalProps/withGlobalProps.tsx +36 -0
  177. package/src/providers/translations/Translations.types.ts +26 -0
  178. package/src/providers/translations/TranslationsContext.ts +7 -0
  179. package/src/providers/translations/{TranslationsProvider.jsx → TranslationsProvider.tsx} +8 -15
  180. package/src/providers/translations/{index.js → index.ts} +5 -0
  181. package/src/styles/tools/_accessibility.scss +2 -2
  182. package/src/translations/{en.js → en.ts} +3 -1
  183. package/src/types/breakpoints.ts +1 -0
  184. package/src/types/colors.ts +7 -0
  185. package/src/types/index.ts +13 -0
  186. package/src/types/labelPositions.ts +1 -0
  187. package/src/types/layouts.ts +1 -0
  188. package/src/types/modules.d.ts +16 -0
  189. package/src/types/priorities.ts +1 -0
  190. package/src/types/sizes.ts +1 -0
  191. package/src/types/styles.ts +4 -0
  192. package/src/types/validationStates.ts +1 -0
  193. package/src/utils/mergeDeep.ts +34 -0
  194. package/src/utils/mergeDeep.types.ts +4 -0
  195. package/.claude/agents/code-reviewer.md +0 -122
  196. package/.claude/rules/code.md +0 -22
  197. package/.claude/rules/docs.md +0 -35
  198. package/.claude/rules/frontend.md +0 -72
  199. package/.claude/rules/git.md +0 -13
  200. package/.claude/rules/safety-guards.md +0 -9
  201. package/.claude/rules/styling.md +0 -32
  202. package/.claude/rules/testing.md +0 -59
  203. package/.claude/settings.json +0 -32
  204. package/.claude/skills/commit/SKILL.md +0 -54
  205. package/.devcontainer/devcontainer.json +0 -23
  206. package/.eslintrc-ts +0 -40
  207. package/.mcp.json +0 -8
  208. package/.nvmrc +0 -1
  209. package/CLAUDE.md +0 -82
  210. package/docker-compose.base.yml +0 -93
  211. package/docker-compose.yml.dist +0 -41
  212. package/jest.config-ts.js +0 -34
  213. package/opencode.json +0 -10
  214. package/playwright-ct.config.ts +0 -68
  215. package/scripts/auto-start-mkdocs.sh +0 -5
  216. package/scripts/auto-start-node.sh +0 -33
  217. package/scripts/mcps/chrome-host/README.md +0 -118
  218. package/scripts/mcps/chrome-host/cdp_proxy.py +0 -90
  219. package/scripts/mcps/chrome-host/mcp-entry.sh +0 -33
  220. package/scripts/mcps/chrome-host/mcp-launch.sh +0 -36
  221. package/scripts/mcps/chrome-host/mcp-setup.sh +0 -70
  222. package/scripts/mcps/chrome-host/start-host-chrome.sh +0 -267
  223. package/setup.sh +0 -107
  224. package/src/CNAME +0 -1
  225. package/src/components/Alert/index.js +0 -1
  226. package/src/components/Badge/Badge.jsx +0 -51
  227. package/src/components/Badge/index.js +0 -1
  228. package/src/components/Button/Button.jsx +0 -203
  229. package/src/components/Button/helpers/getRootPriorityClassName.js +0 -15
  230. package/src/components/Button/index.js +0 -1
  231. package/src/components/ButtonGroup/ButtonGroupContext.js +0 -3
  232. package/src/components/Card/Card.jsx +0 -67
  233. package/src/components/CheckboxField/CheckboxField.jsx +0 -144
  234. package/src/components/CheckboxField/index.js +0 -1
  235. package/src/components/FileInputField/index.js +0 -1
  236. package/src/components/FormLayout/FormLayoutContext.js +0 -3
  237. package/src/components/FormLayout/FormLayoutCustomFieldContext.js +0 -3
  238. package/src/components/FormLayout/index.js +0 -4
  239. package/src/components/Grid/Grid.jsx +0 -225
  240. package/src/components/Grid/GridSpan.jsx +0 -88
  241. package/src/components/Grid/_helpers/generateResponsiveCustomProperties.js +0 -22
  242. package/src/components/Grid/index.js +0 -2
  243. package/src/components/InputGroup/InputGroupContext.js +0 -3
  244. package/src/components/Modal/Modal.jsx +0 -262
  245. package/src/components/Modal/ModalBody.jsx +0 -60
  246. package/src/components/Modal/ModalFooter.jsx +0 -42
  247. package/src/components/Modal/ModalHeader.jsx +0 -42
  248. package/src/components/Modal/ModalTitle.jsx +0 -42
  249. package/src/components/Modal/_helpers/getPositionClassName.js +0 -7
  250. package/src/components/Modal/_helpers/getScrollingClassName.js +0 -11
  251. package/src/components/Paper/index.js +0 -1
  252. package/src/components/Popover/Popover.jsx +0 -124
  253. package/src/components/Popover/PopoverWrapper.jsx +0 -38
  254. package/src/components/Popover/index.js +0 -2
  255. package/src/components/Radio/index.js +0 -1
  256. package/src/components/ScrollView/_helpers/getElementsPositionDifference.js +0 -11
  257. package/src/components/ScrollView/index.js +0 -1
  258. package/src/components/SelectField/SelectField.jsx +0 -272
  259. package/src/components/SelectField/_components/Option/Option.jsx +0 -46
  260. package/src/components/SelectField/_components/Option/index.js +0 -1
  261. package/src/components/SelectField/index.js +0 -1
  262. package/src/components/Table/_components/TableBodyCell/TableBodyCell.jsx +0 -46
  263. package/src/components/Table/_components/TableBodyCell/index.js +0 -1
  264. package/src/components/Table/_components/TableHeaderCell/index.js +0 -1
  265. package/src/components/Table/index.js +0 -1
  266. package/src/components/Tabs/TabsItem.jsx +0 -91
  267. package/src/components/Tabs/index.js +0 -2
  268. package/src/components/Text/Text.jsx +0 -76
  269. package/src/components/Text/_helpers/getRootClampClassName.js +0 -11
  270. package/src/components/Text/_helpers/getRootHyphensClassName.js +0 -11
  271. package/src/components/Text/_helpers/getRootWordWrappingClassName.js +0 -11
  272. package/src/components/Text/index.js +0 -1
  273. package/src/components/TextArea/TextArea.jsx +0 -174
  274. package/src/components/TextArea/index.js +0 -1
  275. package/src/components/TextField/TextField.jsx +0 -208
  276. package/src/components/TextField/index.js +0 -1
  277. package/src/components/TextLink/index.js +0 -1
  278. package/src/components/Toggle/Toggle.jsx +0 -144
  279. package/src/components/Toggle/index.js +0 -1
  280. package/src/components/Toolbar/Toolbar.jsx +0 -76
  281. package/src/components/Toolbar/ToolbarGroup.jsx +0 -64
  282. package/src/components/_helpers/resolveContextOrProp.js +0 -10
  283. package/src/helpers/isChildrenEmpty/isChildrenEmpty.js +0 -3
  284. package/src/helpers/transferProps/transferProps.js +0 -38
  285. package/src/index.js +0 -67
  286. package/src/providers/globalProps/GlobalPropsContext.jsx +0 -5
  287. package/src/providers/globalProps/withGlobalProps.jsx +0 -38
  288. package/src/providers/translations/TranslationsContext.jsx +0 -6
  289. package/src/utils/mergeDeep.js +0 -28
  290. package/tsconfig.json +0 -27
  291. /package/src/helpers/classNames/{index.js → index.ts} +0 -0
  292. /package/src/helpers/isChildrenEmpty/{index.js → index.ts} +0 -0
  293. /package/src/helpers/transferProps/{index.js → index.ts} +0 -0
@@ -1,4 +1,11 @@
1
- export const getAlignClassName = (value, styles, type) => {
1
+ import type { CssModuleClasses } from '../../../types';
2
+ import type { ToolbarAlign } from '../Toolbar.types';
3
+
4
+ export const getAlignClassName = (
5
+ styles: CssModuleClasses,
6
+ type: 'toolbar' | 'group',
7
+ value?: ToolbarAlign,
8
+ ) => {
2
9
  if (value === 'top') {
3
10
  if (type === 'group') {
4
11
  return styles.isGroupAlignedToTop;
@@ -1,4 +1,7 @@
1
- export const getJustifyClassName = (value, styles) => {
1
+ import type { CssModuleClasses } from '../../../types';
2
+ import type { ToolbarJustify } from '../Toolbar.types';
3
+
4
+ export const getJustifyClassName = (styles: CssModuleClasses, value?: ToolbarJustify) => {
2
5
  if (value === 'start') {
3
6
  return styles.isToolbarJustifiedToStart;
4
7
  }
@@ -1,3 +1,10 @@
1
1
  export { default as Toolbar } from './Toolbar';
2
2
  export { default as ToolbarGroup } from './ToolbarGroup';
3
3
  export { default as ToolbarItem } from './ToolbarItem';
4
+ export type {
5
+ ToolbarAlign,
6
+ ToolbarGroupProps,
7
+ ToolbarItemProps,
8
+ ToolbarJustify,
9
+ ToolbarProps,
10
+ } from './Toolbar.types';
@@ -1,4 +1,9 @@
1
- export const getRootColorClassName = (variant, styles) => {
1
+ import type {
2
+ Color,
3
+ CssModuleClasses,
4
+ } from '../../types';
5
+
6
+ export const getRootColorClassName = (styles: CssModuleClasses, variant?: Color) => {
2
7
  if (variant === 'primary') {
3
8
  return styles.isRootColorPrimary;
4
9
  }
@@ -1,4 +1,9 @@
1
- export const getRootPriorityClassName = (priority, styles) => {
1
+ import type {
2
+ CssModuleClasses,
3
+ Priority,
4
+ } from '../../types';
5
+
6
+ export const getRootPriorityClassName = (styles: CssModuleClasses, priority?: Priority) => {
2
7
  if (priority === 'filled') {
3
8
  return styles.isRootPriorityFilled;
4
9
  }
@@ -1,4 +1,9 @@
1
- export const getRootSizeClassName = (size, styles) => {
1
+ import type {
2
+ CssModuleClasses,
3
+ Size,
4
+ } from '../../types';
5
+
6
+ export const getRootSizeClassName = (styles: CssModuleClasses, size?: Size) => {
2
7
  if (size === 'small') {
3
8
  return styles.isRootSizeSmall;
4
9
  }
@@ -1,4 +1,9 @@
1
- export const getRootValidationStateClassName = (validationState, styles) => {
1
+ import type {
2
+ CssModuleClasses,
3
+ ValidationState,
4
+ } from '../../types';
5
+
6
+ export const getRootValidationStateClassName = (styles: CssModuleClasses, validationState?: ValidationState) => {
2
7
  if (validationState === 'invalid') {
3
8
  return styles.isRootStateInvalid;
4
9
  }
@@ -0,0 +1,13 @@
1
+ export const resolveContextOrProp = <ContextValue, PropValue>(
2
+ contextValue: ContextValue,
3
+ propValue: PropValue,
4
+ ): Exclude<ContextValue, false | null> | PropValue => {
5
+ // We need to test:
6
+ // * `false` - for when the `contextValue` is boolean
7
+ // * `null` - for when the `contextValue` is non-boolean
8
+ if (contextValue === false || contextValue === null) {
9
+ return propValue;
10
+ }
11
+
12
+ return contextValue as Exclude<ContextValue, false | null>;
13
+ };
@@ -1,6 +1,6 @@
1
- export const classNames = (...classes) => {
1
+ export const classNames = (...classes: unknown[]): string | undefined => {
2
2
  const filteredClassNames = classes.filter(
3
- (className) => typeof className === 'string'
3
+ (className): className is string => typeof className === 'string'
4
4
  && className.trim().length > 0,
5
5
  );
6
6
 
@@ -0,0 +1,5 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ export const isChildrenEmpty = (children: ReactNode) => children == null
4
+ || children === false
5
+ || (Array.isArray(children) && children.length === 0);
@@ -0,0 +1,50 @@
1
+ import type { TransferPropsInvalidProp } from './transferProps.types';
2
+
3
+ const INVALID_PROPS = [
4
+ 'children', // It is always either handled by the component itself or not supported.
5
+ 'className', // Classes are set by component authors, changing it arbitrarily might break things.
6
+ 'contentEditable', // Components are either interactive or not, changing it arbitrarily might break things.
7
+ 'dangerouslySetInnerHTML', // This might break things and allow for XSS attacks.
8
+ 'ref', // Forwarding `ref` is hardcoded and documented for each component.
9
+ 'staticContext', // In `react-router` (v4, v5) this is used during server side rendering, it makes no sense to pass it to a component.
10
+ 'style', // Styles are set by component authors, changing it arbitrarily might break things.
11
+ 'suppressContentEditableWarning', // Since setting `contentEditable` is not allowed, this is not needed.
12
+ ] as const satisfies readonly TransferPropsInvalidProp[];
13
+
14
+ // Declared locally so that consumers compiling the sources directly do not need `@types/node`.
15
+ // Bundlers replace `process.env.NODE_ENV` at build time.
16
+ declare const process: {
17
+ env: {
18
+ NODE_ENV?: string;
19
+ };
20
+ };
21
+
22
+ /**
23
+ * @param props The props that were passed to the React component and were not used by it
24
+ * @returns The props to be passed to the HTML element
25
+ */
26
+ export const transferProps = <Props extends object>(props: Props): Omit<Props, TransferPropsInvalidProp> => {
27
+ const {
28
+ children,
29
+ className,
30
+ contentEditable,
31
+ dangerouslySetInnerHTML,
32
+ ref,
33
+ staticContext,
34
+ style,
35
+ suppressContentEditableWarning,
36
+ ...restProps
37
+ } = props as Props & Record<TransferPropsInvalidProp, unknown>;
38
+
39
+ if (process.env.NODE_ENV !== 'production') {
40
+ const invalidProps = INVALID_PROPS
41
+ .filter((key) => (props as Record<string, unknown>)[key] !== undefined);
42
+
43
+ if (invalidProps.length > 0) {
44
+ // eslint-disable-next-line no-console
45
+ console.error(`Invalid prop(s) supplied to the "transferProps" function: "${invalidProps.join('", "')}"`);
46
+ }
47
+ }
48
+
49
+ return restProps;
50
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Props that are never transferred to the HTML element by `transferProps`.
3
+ */
4
+ export type TransferPropsInvalidProp = 'children'
5
+ | 'className'
6
+ | 'contentEditable'
7
+ | 'dangerouslySetInnerHTML'
8
+ | 'ref'
9
+ | 'staticContext'
10
+ | 'style'
11
+ | 'suppressContentEditableWarning';
package/src/index.ts ADDED
@@ -0,0 +1,211 @@
1
+ // Global definitions
2
+ // The styles need to be imported here to be placed in the distribution CSS file.
3
+ // Component styles are imported in the components themselves below.
4
+ import './index.scss';
5
+
6
+ // Components
7
+ export { Alert } from './components/Alert';
8
+ export type { AlertProps } from './components/Alert';
9
+ export { Badge } from './components/Badge';
10
+ export type {
11
+ BadgePriority,
12
+ BadgeProps,
13
+ } from './components/Badge';
14
+ export { Button } from './components/Button';
15
+ export type {
16
+ ButtonLabelVisibility,
17
+ ButtonProps,
18
+ ButtonType,
19
+ } from './components/Button';
20
+ export { ButtonGroup } from './components/ButtonGroup';
21
+ export type {
22
+ ButtonGroupContextValue,
23
+ ButtonGroupProps,
24
+ } from './components/ButtonGroup';
25
+ export {
26
+ Card,
27
+ CardBody,
28
+ CardFooter,
29
+ } from './components/Card';
30
+ export type {
31
+ CardBodyProps,
32
+ CardFooterProps,
33
+ CardProps,
34
+ } from './components/Card';
35
+ export { CheckboxField } from './components/CheckboxField';
36
+ export type {
37
+ CheckboxFieldLabelPosition,
38
+ CheckboxFieldProps,
39
+ } from './components/CheckboxField';
40
+ export { FileInputField } from './components/FileInputField';
41
+ export type {
42
+ FileInputFieldFilesChangedEvent,
43
+ FileInputFieldProps,
44
+ FileInputFieldRef,
45
+ } from './components/FileInputField';
46
+ export {
47
+ FormLayout,
48
+ FormLayoutCustomField,
49
+ } from './components/FormLayout';
50
+ export type {
51
+ FormLayoutContextValue,
52
+ FormLayoutCustomFieldContextValue,
53
+ FormLayoutCustomFieldProps,
54
+ FormLayoutLabelWidth,
55
+ FormLayoutPredefinedLabelWidth,
56
+ FormLayoutProps,
57
+ } from './components/FormLayout';
58
+ export {
59
+ Grid,
60
+ GridSpan,
61
+ } from './components/Grid';
62
+ export type {
63
+ GridProps,
64
+ GridResponsiveValue,
65
+ GridSpacingValue,
66
+ GridSpanProps,
67
+ GridTag,
68
+ } from './components/Grid';
69
+ export { InputGroup } from './components/InputGroup';
70
+ export type {
71
+ InputGroupContextValue,
72
+ InputGroupProps,
73
+ } from './components/InputGroup';
74
+ export {
75
+ Modal,
76
+ ModalBody,
77
+ ModalCloseButton,
78
+ ModalContent,
79
+ ModalFooter,
80
+ ModalHeader,
81
+ ModalTitle,
82
+ } from './components/Modal';
83
+ export type {
84
+ ModalBodyProps,
85
+ ModalCloseButtonProps,
86
+ ModalContentProps,
87
+ ModalFooterProps,
88
+ ModalHeaderProps,
89
+ ModalJustify,
90
+ ModalPosition,
91
+ ModalProps,
92
+ ModalScrolling,
93
+ ModalScrollPrevention,
94
+ ModalSize,
95
+ ModalTitleProps,
96
+ } from './components/Modal';
97
+ export { Paper } from './components/Paper';
98
+ export type { PaperProps } from './components/Paper';
99
+ export {
100
+ Popover,
101
+ PopoverWrapper,
102
+ } from './components/Popover';
103
+ export type {
104
+ PopoverPlacement,
105
+ PopoverPlacementStyle,
106
+ PopoverProps,
107
+ PopoverWrapperProps,
108
+ } from './components/Popover';
109
+ export { Radio } from './components/Radio';
110
+ export type {
111
+ RadioOption,
112
+ RadioProps,
113
+ } from './components/Radio';
114
+ export { ScrollView } from './components/ScrollView';
115
+ export type {
116
+ ScrollViewAutoScroll,
117
+ ScrollViewDirection,
118
+ ScrollViewProps,
119
+ } from './components/ScrollView';
120
+ export { SelectField } from './components/SelectField';
121
+ export type {
122
+ SelectFieldOption,
123
+ SelectFieldOptionGroup,
124
+ SelectFieldProps,
125
+ SelectFieldVariant,
126
+ } from './components/SelectField';
127
+ export {
128
+ Tabs,
129
+ TabsItem,
130
+ } from './components/Tabs';
131
+ export type {
132
+ TabsItemProps,
133
+ TabsProps,
134
+ } from './components/Tabs';
135
+ export { Table } from './components/Table';
136
+ export type {
137
+ TableColumn,
138
+ TableProps,
139
+ TableRow,
140
+ TableSort,
141
+ TableSortDirection,
142
+ } from './components/Table';
143
+ export { Text } from './components/Text';
144
+ export type {
145
+ TextHyphens,
146
+ TextProps,
147
+ TextWordWrapping,
148
+ } from './components/Text';
149
+ export { TextArea } from './components/TextArea';
150
+ export type {
151
+ TextAreaProps,
152
+ TextAreaVariant,
153
+ } from './components/TextArea';
154
+ export { TextField } from './components/TextField';
155
+ export type {
156
+ TextFieldProps,
157
+ TextFieldType,
158
+ TextFieldVariant,
159
+ } from './components/TextField';
160
+ export { TextLink } from './components/TextLink';
161
+ export type { TextLinkProps } from './components/TextLink';
162
+ export { Toggle } from './components/Toggle';
163
+ export type {
164
+ ToggleLabelPosition,
165
+ ToggleProps,
166
+ } from './components/Toggle';
167
+ export {
168
+ Toolbar,
169
+ ToolbarGroup,
170
+ ToolbarItem,
171
+ } from './components/Toolbar';
172
+ export type {
173
+ ToolbarAlign,
174
+ ToolbarGroupProps,
175
+ ToolbarItemProps,
176
+ ToolbarJustify,
177
+ ToolbarProps,
178
+ } from './components/Toolbar';
179
+
180
+ // Providers
181
+ export { GlobalPropsProvider } from './providers/globalProps';
182
+ export type {
183
+ GlobalProps,
184
+ GlobalPropsProviderProps,
185
+ } from './providers/globalProps';
186
+ export { TranslationsProvider } from './providers/translations';
187
+ export type {
188
+ PartialTranslations,
189
+ Translations,
190
+ TranslationsProviderProps,
191
+ } from './providers/translations';
192
+
193
+ // Helpers
194
+ export { classNames } from './helpers/classNames';
195
+ export { transferProps } from './helpers/transferProps';
196
+ export { isChildrenEmpty } from './helpers/isChildrenEmpty';
197
+
198
+ // Types
199
+ export type {
200
+ ActionColor,
201
+ Breakpoint,
202
+ Color,
203
+ CssModuleClasses,
204
+ FeedbackColor,
205
+ LabelPosition,
206
+ Layout,
207
+ NeutralColor,
208
+ Priority,
209
+ Size,
210
+ ValidationState,
211
+ } from './types';
@@ -0,0 +1,30 @@
1
+ import type {
2
+ ForwardedRef,
3
+ ReactNode,
4
+ } from 'react';
5
+
6
+ /**
7
+ * Global props keyed by component name, e.g. `{ Button: { size: 'small' } }`.
8
+ */
9
+ export type GlobalProps = Record<string, Record<string, unknown>>;
10
+
11
+ /**
12
+ * Props of the `GlobalPropsProvider` component.
13
+ */
14
+ export type GlobalPropsProviderProps = {
15
+ /**
16
+ * Children wrapped by the provider.
17
+ */
18
+ children?: ReactNode;
19
+ /**
20
+ * Global props to be merged with the ones from the parent providers.
21
+ */
22
+ globalProps?: GlobalProps;
23
+ };
24
+
25
+ /**
26
+ * Props of the component `withGlobalProps` renders; `forwardedRef` carries the ref through.
27
+ */
28
+ export type WithGlobalPropsComponentProps<Props, Element> = Props & {
29
+ forwardedRef?: ForwardedRef<Element>;
30
+ };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import type { GlobalProps } from './GlobalProps.types';
3
+
4
+ const GlobalPropsContext = React.createContext<GlobalProps>({});
5
+
6
+ export default GlobalPropsContext;
@@ -1,33 +1,26 @@
1
- import PropTypes from 'prop-types';
2
1
  import React, {
3
2
  useContext,
4
3
  } from 'react';
5
4
  import { mergeDeep } from '../../utils/mergeDeep';
6
5
  import GlobalPropsContext from './GlobalPropsContext';
6
+ import type {
7
+ GlobalProps,
8
+ GlobalPropsProviderProps,
9
+ } from './GlobalProps.types';
7
10
 
8
- const GlobalPropsProvider = ({
11
+ const GlobalPropsProvider: React.FunctionComponent<GlobalPropsProviderProps> = ({
9
12
  children,
10
- globalProps,
11
- }) => {
13
+ globalProps = {},
14
+ }: GlobalPropsProviderProps) => {
12
15
  const contextGlobalProps = useContext(GlobalPropsContext);
13
16
 
14
17
  return (
15
18
  <GlobalPropsContext.Provider
16
- value={mergeDeep(contextGlobalProps, globalProps)}
19
+ value={mergeDeep<GlobalProps>(contextGlobalProps, globalProps)}
17
20
  >
18
21
  {children}
19
22
  </GlobalPropsContext.Provider>
20
23
  );
21
24
  };
22
25
 
23
- GlobalPropsProvider.defaultProps = {
24
- children: undefined,
25
- globalProps: {},
26
- };
27
-
28
- GlobalPropsProvider.propTypes = {
29
- children: PropTypes.node,
30
- globalProps: PropTypes.shape({}),
31
- };
32
-
33
26
  export default GlobalPropsProvider;
@@ -1,3 +1,7 @@
1
1
  export { default as GlobalPropsContext } from './GlobalPropsContext';
2
2
  export { default as GlobalPropsProvider } from './GlobalPropsProvider';
3
+ export type {
4
+ GlobalProps,
5
+ GlobalPropsProviderProps,
6
+ } from './GlobalProps.types';
3
7
  export { default as withGlobalProps } from './withGlobalProps';
@@ -0,0 +1,36 @@
1
+ import React, {
2
+ useContext,
3
+ } from 'react';
4
+ import type {
5
+ ComponentType,
6
+ RefAttributes,
7
+ } from 'react';
8
+ import GlobalPropsContext from './GlobalPropsContext';
9
+ import type { WithGlobalPropsComponentProps } from './GlobalProps.types';
10
+
11
+ export default <Props extends object, Element>(
12
+ Component: ComponentType<Props & RefAttributes<Element>>,
13
+ componentName: string,
14
+ ) => {
15
+ const WithGlobalPropsComponent = ({
16
+ forwardedRef,
17
+ ...rest
18
+ }: WithGlobalPropsComponentProps<Props, Element>) => {
19
+ const contextGlobalProps = useContext(GlobalPropsContext);
20
+
21
+ return (
22
+ <Component
23
+ {...contextGlobalProps[componentName] || {}}
24
+ {...rest as Props}
25
+ ref={forwardedRef}
26
+ />
27
+ );
28
+ };
29
+
30
+ return React.forwardRef<Element, Props>((props, ref) => (
31
+ <WithGlobalPropsComponent
32
+ {...props as Props}
33
+ forwardedRef={ref}
34
+ />
35
+ ));
36
+ };
@@ -0,0 +1,26 @@
1
+ import type { ReactNode } from 'react';
2
+ import type defaultTranslations from '../../translations/en';
3
+
4
+ export type Translations = typeof defaultTranslations;
5
+
6
+ /**
7
+ * Translations with any subset of components and keys, merged into the defaults by `TranslationsProvider`.
8
+ * Components not present in the default translations (e.g. of a consuming library) are allowed too.
9
+ */
10
+ export type PartialTranslations = {
11
+ [Component in keyof Translations]?: Partial<Translations[Component]>;
12
+ } & Record<string, Record<string, string | undefined> | undefined>;
13
+
14
+ /**
15
+ * Props of the `TranslationsProvider` component.
16
+ */
17
+ export type TranslationsProviderProps = {
18
+ /**
19
+ * Children wrapped by the provider.
20
+ */
21
+ children?: ReactNode;
22
+ /**
23
+ * Translations to be merged with the ones from the parent providers.
24
+ */
25
+ translations?: PartialTranslations;
26
+ };
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import defaultTranslations from '../../translations/en';
3
+ import type { Translations } from './Translations.types';
4
+
5
+ const TranslationsContext = React.createContext<Translations>(defaultTranslations);
6
+
7
+ export default TranslationsContext;
@@ -1,33 +1,26 @@
1
- import PropTypes from 'prop-types';
2
1
  import React, {
3
2
  useContext,
4
3
  } from 'react';
5
4
  import { mergeDeep } from '../../utils/mergeDeep';
6
5
  import TranslationsContext from './TranslationsContext';
6
+ import type {
7
+ Translations,
8
+ TranslationsProviderProps,
9
+ } from './Translations.types';
7
10
 
8
- const TranslationsProvider = ({
11
+ const TranslationsProvider: React.FunctionComponent<TranslationsProviderProps> = ({
9
12
  children,
10
- translations,
11
- }) => {
13
+ translations = {},
14
+ }: TranslationsProviderProps) => {
12
15
  const contextTranslations = useContext(TranslationsContext);
13
16
 
14
17
  return (
15
18
  <TranslationsContext.Provider
16
- value={mergeDeep(contextTranslations, translations)}
19
+ value={mergeDeep<Translations>(contextTranslations, translations)}
17
20
  >
18
21
  {children}
19
22
  </TranslationsContext.Provider>
20
23
  );
21
24
  };
22
25
 
23
- TranslationsProvider.defaultProps = {
24
- children: undefined,
25
- translations: {},
26
- };
27
-
28
- TranslationsProvider.propTypes = {
29
- children: PropTypes.node,
30
- translations: PropTypes.shape({}),
31
- };
32
-
33
26
  export default TranslationsProvider;
@@ -1,2 +1,7 @@
1
1
  export { default as TranslationsContext } from './TranslationsContext';
2
2
  export { default as TranslationsProvider } from './TranslationsProvider';
3
+ export type {
4
+ PartialTranslations,
5
+ Translations,
6
+ TranslationsProviderProps,
7
+ } from './Translations.types';
@@ -8,21 +8,21 @@
8
8
  // 1.
9
9
  @mixin hide-text() {
10
10
  position: absolute;
11
+ clip-path: inset(50%);
11
12
  width: 1px;
12
13
  height: 1px;
13
14
  padding: 0;
14
15
  overflow: hidden;
15
- clip: rect(0, 0, 0, 0);
16
16
  white-space: nowrap;
17
17
  border: 0;
18
18
  }
19
19
 
20
20
  @mixin unhide-text() {
21
21
  position: unset;
22
+ clip-path: unset;
22
23
  width: unset;
23
24
  height: unset;
24
25
  overflow: unset;
25
- clip: unset;
26
26
  white-space: unset;
27
27
  }
28
28
 
@@ -1,4 +1,4 @@
1
- export default {
1
+ const en = {
2
2
  Alert: {
3
3
  close: 'Close',
4
4
  },
@@ -16,3 +16,5 @@ export default {
16
16
  previous: 'Previous',
17
17
  },
18
18
  };
19
+
20
+ export default en;
@@ -0,0 +1 @@
1
+ export type Breakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'x2l' | 'x3l';
@@ -0,0 +1,7 @@
1
+ export type ActionColor = 'primary' | 'secondary' | 'selected';
2
+
3
+ export type FeedbackColor = 'success' | 'warning' | 'danger' | 'help' | 'info' | 'note';
4
+
5
+ export type NeutralColor = 'light' | 'dark';
6
+
7
+ export type Color = ActionColor | FeedbackColor | NeutralColor;
@@ -0,0 +1,13 @@
1
+ export type { Breakpoint } from './breakpoints';
2
+ export type {
3
+ ActionColor,
4
+ Color,
5
+ FeedbackColor,
6
+ NeutralColor,
7
+ } from './colors';
8
+ export type { LabelPosition } from './labelPositions';
9
+ export type { Layout } from './layouts';
10
+ export type { Priority } from './priorities';
11
+ export type { Size } from './sizes';
12
+ export type { CssModuleClasses } from './styles';
13
+ export type { ValidationState } from './validationStates';
@@ -0,0 +1 @@
1
+ export type LabelPosition = 'before' | 'after';
@@ -0,0 +1 @@
1
+ export type Layout = 'horizontal' | 'vertical';