@edvisor/product-language 0.3.0 → 0.3.1

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 (278) hide show
  1. package/index.d.ts +2 -0
  2. package/index.js +7914 -0
  3. package/lib/components/alert-banner/alert-banner.d.ts +11 -0
  4. package/lib/components/alert-banner/alert-level-flags.d.ts +13 -0
  5. package/lib/components/alert-banner/index.d.ts +1 -0
  6. package/lib/components/badge/badge-type-flags.d.ts +18 -0
  7. package/lib/components/badge/badge.d.ts +5 -0
  8. package/lib/components/badge/index.d.ts +1 -0
  9. package/{src/lib/components/card/atoms/card-frame.tsx → lib/components/card/atoms/card-frame.d.ts} +7 -17
  10. package/lib/components/card/atoms/index.d.ts +1 -0
  11. package/lib/components/card/card.d.ts +14 -0
  12. package/lib/components/card/components/card-alert-banner-slot.d.ts +5 -0
  13. package/lib/components/card/components/card-controls-slot.d.ts +4 -0
  14. package/lib/components/card/components/card-section-slot.d.ts +11 -0
  15. package/lib/components/card/components/index.d.ts +3 -0
  16. package/lib/components/card/index.d.ts +2 -0
  17. package/lib/components/card/molecules/index.d.ts +1 -0
  18. package/lib/components/card/molecules/left-right-card.d.ts +16 -0
  19. package/lib/components/checkbox/checkbox.d.ts +10 -0
  20. package/lib/components/checkbox/helpers.d.ts +12 -0
  21. package/lib/components/checkbox/index.d.ts +1 -0
  22. package/lib/components/divider/divider-type-flags.d.ts +9 -0
  23. package/lib/components/divider/divider.d.ts +7 -0
  24. package/lib/components/divider/index.d.ts +1 -0
  25. package/lib/components/flag/flag-size-flags.d.ts +12 -0
  26. package/lib/components/flag/flag.d.ts +9 -0
  27. package/lib/components/flag/flag.list.d.ts +781 -0
  28. package/lib/components/flag/index.d.ts +1 -0
  29. package/lib/components/icon/icon-list.d.ts +131 -0
  30. package/lib/components/icon/icon.d.ts +131 -0
  31. package/lib/components/icon/index.d.ts +1 -0
  32. package/lib/components/index.d.ts +17 -0
  33. package/lib/components/input-field/components/index.d.ts +2 -0
  34. package/lib/components/input-field/components/labeled-input.d.ts +10 -0
  35. package/lib/components/input-field/components/stepper.d.ts +7 -0
  36. package/lib/components/input-field/index.d.ts +3 -0
  37. package/lib/components/input-field/input-field.d.ts +25 -0
  38. package/lib/components/input-field/input-number.d.ts +18 -0
  39. package/lib/components/input-field/input-text.d.ts +14 -0
  40. package/lib/components/layout/flex.d.ts +16 -0
  41. package/lib/components/layout/grid-layout.d.ts +11 -0
  42. package/lib/components/layout/index.d.ts +3 -0
  43. package/lib/components/layout/left-right-layout.d.ts +34 -0
  44. package/lib/components/link/index.d.ts +1 -0
  45. package/lib/components/link/link.d.ts +14 -0
  46. package/lib/components/molecules/avatar/avatar-size-flags.d.ts +12 -0
  47. package/lib/components/molecules/avatar/avatar.d.ts +12 -0
  48. package/lib/components/molecules/avatar/index.d.ts +1 -0
  49. package/lib/components/molecules/button/button-flags.d.ts +44 -0
  50. package/lib/components/molecules/button/button.d.ts +12 -0
  51. package/lib/components/molecules/button/index.d.ts +1 -0
  52. package/lib/components/molecules/index.d.ts +3 -0
  53. package/lib/components/molecules/input-checkbox/index.d.ts +1 -0
  54. package/lib/components/molecules/input-checkbox/input-checkbox.d.ts +8 -0
  55. package/lib/components/organisms/index.d.ts +1 -0
  56. package/lib/components/organisms/multi-choice-list/index.d.ts +1 -0
  57. package/lib/components/organisms/multi-choice-list/multi-choice-list.d.ts +10 -0
  58. package/lib/components/spinner/index.d.ts +1 -0
  59. package/lib/components/spinner/spinner-size-flags.d.ts +10 -0
  60. package/lib/components/spinner/spinner.d.ts +9 -0
  61. package/lib/components/tabs/components/index.d.ts +1 -0
  62. package/lib/components/tabs/components/tab.d.ts +7 -0
  63. package/lib/components/tabs/index.d.ts +1 -0
  64. package/lib/components/tabs/tabs.d.ts +15 -0
  65. package/lib/components/tag/components/close-button.d.ts +8 -0
  66. package/lib/components/tag/components/index.d.ts +2 -0
  67. package/lib/components/tag/components/tag-label.d.ts +8 -0
  68. package/lib/components/tag/index.d.ts +1 -0
  69. package/lib/components/tag/tag.d.ts +10 -0
  70. package/lib/components/thumbnail/index.d.ts +1 -0
  71. package/lib/components/thumbnail/thumbnail-size-flags.d.ts +10 -0
  72. package/lib/components/thumbnail/thumbnail.d.ts +10 -0
  73. package/lib/components/typography/index.d.ts +1 -0
  74. package/lib/components/typography/typography.d.ts +24 -0
  75. package/lib/foundations/color-system/base-palette/base-palette.d.ts +76 -0
  76. package/lib/foundations/color-system/base-palette/index.d.ts +1 -0
  77. package/lib/foundations/color-system/color-guidelines/color-guidelines.d.ts +132 -0
  78. package/lib/foundations/color-system/color-guidelines/index.d.ts +1 -0
  79. package/lib/foundations/color-system/components/color-sample.d.ts +17 -0
  80. package/lib/foundations/color-system/components/index.d.ts +1 -0
  81. package/lib/foundations/color-system/index.d.ts +1 -0
  82. package/lib/foundations/index.d.ts +4 -0
  83. package/lib/foundations/shadows/components.d.ts +8 -0
  84. package/lib/foundations/shadows/index.d.ts +1 -0
  85. package/lib/foundations/shadows/shadows.d.ts +8 -0
  86. package/lib/foundations/spacing/index.d.ts +1 -0
  87. package/lib/foundations/spacing/spacing-guidelines.d.ts +22 -0
  88. package/lib/foundations/spacing/spacing.d.ts +18 -0
  89. package/lib/foundations/typography/constants.d.ts +22 -0
  90. package/lib/foundations/typography/fonts.d.ts +1 -0
  91. package/lib/foundations/typography/index.d.ts +1 -0
  92. package/lib/foundations/typography/text-aspect-flags.d.ts +19 -0
  93. package/lib/foundations/typography/typography.d.ts +24 -0
  94. package/lib/helpers/generic-types.d.ts +21 -0
  95. package/lib/helpers/index.d.ts +6 -0
  96. package/lib/helpers/nothing.d.ts +8 -0
  97. package/{src/lib/helpers/numbers.ts → lib/helpers/numbers.d.ts} +50 -67
  98. package/lib/helpers/safe-navigation.d.ts +15 -0
  99. package/lib/helpers/slots.d.ts +23 -0
  100. package/lib/helpers/strings.d.ts +1 -0
  101. package/package.json +11 -3
  102. package/.babelrc +0 -12
  103. package/.eslintrc.json +0 -147
  104. package/.storybook/main.js +0 -57
  105. package/.storybook/manager.js +0 -7
  106. package/.storybook/preview.js +0 -15
  107. package/.storybook/tsconfig.json +0 -30
  108. package/jest.config.ts +0 -15
  109. package/jest.setup.ts +0 -2
  110. package/project.json +0 -96
  111. package/release-it.json +0 -18
  112. package/src/README.md +0 -61
  113. package/src/assets/svg/example_icon.svg +0 -3
  114. package/src/assets/svg/example_icon_white.svg +0 -3
  115. package/src/assets/svg/spinner.svg +0 -3
  116. package/src/assets/svg/spinner_white.svg +0 -3
  117. package/src/helpers/index.ts +0 -4
  118. package/src/helpers/playground.ts +0 -16
  119. package/src/helpers/talesOf.tsx +0 -42
  120. package/src/index.ts +0 -2
  121. package/src/lib/components/README.md +0 -49
  122. package/src/lib/components/alert-banner/alert-banner.tsx +0 -34
  123. package/src/lib/components/alert-banner/alert-level-flags.ts +0 -77
  124. package/src/lib/components/alert-banner/index.ts +0 -1
  125. package/src/lib/components/badge/badge-type-flags.ts +0 -72
  126. package/src/lib/components/badge/badge.test.tsx +0 -29
  127. package/src/lib/components/badge/badge.tsx +0 -22
  128. package/src/lib/components/badge/index.ts +0 -1
  129. package/src/lib/components/badge/stories/badge.stories.mdx +0 -44
  130. package/src/lib/components/badge/stories/components.tsx +0 -49
  131. package/src/lib/components/card/atoms/index.ts +0 -1
  132. package/src/lib/components/card/card.test.tsx +0 -162
  133. package/src/lib/components/card/card.tsx +0 -78
  134. package/src/lib/components/card/components/card-alert-banner-slot.tsx +0 -16
  135. package/src/lib/components/card/components/card-controls-slot.tsx +0 -19
  136. package/src/lib/components/card/components/card-section-slot.tsx +0 -51
  137. package/src/lib/components/card/components/index.ts +0 -3
  138. package/src/lib/components/card/index.ts +0 -2
  139. package/src/lib/components/card/molecules/index.ts +0 -1
  140. package/src/lib/components/card/molecules/left-right-card.test.tsx +0 -89
  141. package/src/lib/components/card/molecules/left-right-card.tsx +0 -63
  142. package/src/lib/components/card/storybook/card.stories.mdx +0 -100
  143. package/src/lib/components/card/storybook/components.tsx +0 -223
  144. package/src/lib/components/checkbox/checkbox.test.tsx +0 -39
  145. package/src/lib/components/checkbox/checkbox.tsx +0 -63
  146. package/src/lib/components/checkbox/helpers.tsx +0 -100
  147. package/src/lib/components/checkbox/index.tsx +0 -1
  148. package/src/lib/components/checkbox/stories/checkbox.stories.mdx +0 -57
  149. package/src/lib/components/checkbox/stories/components.tsx +0 -84
  150. package/src/lib/components/divider/divider-type-flags.tsx +0 -37
  151. package/src/lib/components/divider/divider.test.tsx +0 -34
  152. package/src/lib/components/divider/divider.tsx +0 -37
  153. package/src/lib/components/divider/index.tsx +0 -1
  154. package/src/lib/components/divider/stories/components.tsx +0 -13
  155. package/src/lib/components/divider/stories/divider.stories.mdx +0 -44
  156. package/src/lib/components/flag/flag-size-flags.tsx +0 -55
  157. package/src/lib/components/flag/flag.list.tsx +0 -788
  158. package/src/lib/components/flag/flag.test.tsx +0 -65
  159. package/src/lib/components/flag/flag.tsx +0 -97
  160. package/src/lib/components/flag/index.tsx +0 -1
  161. package/src/lib/components/flag/stories/components.tsx +0 -403
  162. package/src/lib/components/flag/stories/flag.stories.mdx +0 -48
  163. package/src/lib/components/flag/stories/playGround-select.tsx +0 -145
  164. package/src/lib/components/icon/icon-list.tsx +0 -135
  165. package/src/lib/components/icon/icon.test.tsx +0 -48
  166. package/src/lib/components/icon/icon.tsx +0 -181
  167. package/src/lib/components/icon/index.tsx +0 -1
  168. package/src/lib/components/icon/stories/components.tsx +0 -282
  169. package/src/lib/components/icon/stories/icon.stories.mdx +0 -65
  170. package/src/lib/components/index.ts +0 -19
  171. package/src/lib/components/input-field/components/index.ts +0 -2
  172. package/src/lib/components/input-field/components/labeled-input.tsx +0 -54
  173. package/src/lib/components/input-field/components/stepper.tsx +0 -60
  174. package/src/lib/components/input-field/index.ts +0 -6
  175. package/src/lib/components/input-field/input-field.test.tsx +0 -107
  176. package/src/lib/components/input-field/input-field.tsx +0 -126
  177. package/src/lib/components/input-field/input-number.tsx +0 -41
  178. package/src/lib/components/input-field/input-text.tsx +0 -30
  179. package/src/lib/components/input-field/storybook/components.tsx +0 -327
  180. package/src/lib/components/input-field/storybook/input-field.stories.mdx +0 -113
  181. package/src/lib/components/layout/flex.tsx +0 -22
  182. package/src/lib/components/layout/grid-layout.tsx +0 -40
  183. package/src/lib/components/layout/index.ts +0 -3
  184. package/src/lib/components/layout/left-right-layout.tsx +0 -67
  185. package/src/lib/components/link/index.ts +0 -1
  186. package/src/lib/components/link/link.test.tsx +0 -29
  187. package/src/lib/components/link/link.tsx +0 -56
  188. package/src/lib/components/link/storybook/link.stories.mdx +0 -52
  189. package/src/lib/components/molecules/avatar/avatar-size-flags.tsx +0 -55
  190. package/src/lib/components/molecules/avatar/avatar.test.tsx +0 -114
  191. package/src/lib/components/molecules/avatar/avatar.tsx +0 -80
  192. package/src/lib/components/molecules/avatar/index.tsx +0 -1
  193. package/src/lib/components/molecules/avatar/stories/avatar.stories.mdx +0 -52
  194. package/src/lib/components/molecules/avatar/stories/components.tsx +0 -36
  195. package/src/lib/components/molecules/button/button-flags.tsx +0 -340
  196. package/src/lib/components/molecules/button/button.test.tsx +0 -77
  197. package/src/lib/components/molecules/button/button.tsx +0 -214
  198. package/src/lib/components/molecules/button/index.tsx +0 -1
  199. package/src/lib/components/molecules/button/stories/button.stories.mdx +0 -105
  200. package/src/lib/components/molecules/button/stories/components.tsx +0 -84
  201. package/src/lib/components/molecules/index.ts +0 -3
  202. package/src/lib/components/molecules/input-checkbox/index.tsx +0 -1
  203. package/src/lib/components/molecules/input-checkbox/input-checkbox.test.tsx +0 -34
  204. package/src/lib/components/molecules/input-checkbox/input-checkbox.tsx +0 -49
  205. package/src/lib/components/molecules/input-checkbox/stories/components.tsx +0 -53
  206. package/src/lib/components/molecules/input-checkbox/stories/input-checkbox.stories.mdx +0 -49
  207. package/src/lib/components/organisms/index.ts +0 -1
  208. package/src/lib/components/organisms/multi-choice-list/index.tsx +0 -1
  209. package/src/lib/components/organisms/multi-choice-list/multi-choice-list.test.tsx +0 -33
  210. package/src/lib/components/organisms/multi-choice-list/multi-choice-list.tsx +0 -52
  211. package/src/lib/components/organisms/multi-choice-list/stories/components.tsx +0 -124
  212. package/src/lib/components/organisms/multi-choice-list/stories/multi-choice-list.stories.mdx +0 -99
  213. package/src/lib/components/spinner/index.tsx +0 -1
  214. package/src/lib/components/spinner/spinner-size-flags.tsx +0 -39
  215. package/src/lib/components/spinner/spinner.test.tsx +0 -31
  216. package/src/lib/components/spinner/spinner.tsx +0 -54
  217. package/src/lib/components/spinner/stories/components.tsx +0 -39
  218. package/src/lib/components/spinner/stories/spinner.stories.mdx +0 -35
  219. package/src/lib/components/tabs/components/index.ts +0 -1
  220. package/src/lib/components/tabs/components/tab.tsx +0 -62
  221. package/src/lib/components/tabs/index.tsx +0 -1
  222. package/src/lib/components/tabs/storybook/components.tsx +0 -282
  223. package/src/lib/components/tabs/storybook/tabs.stories.mdx +0 -97
  224. package/src/lib/components/tabs/tabs.test.tsx +0 -86
  225. package/src/lib/components/tabs/tabs.tsx +0 -101
  226. package/src/lib/components/tag/components/close-button.tsx +0 -85
  227. package/src/lib/components/tag/components/index.ts +0 -2
  228. package/src/lib/components/tag/components/tag-label.tsx +0 -44
  229. package/src/lib/components/tag/index.tsx +0 -1
  230. package/src/lib/components/tag/stories/components.tsx +0 -86
  231. package/src/lib/components/tag/stories/tag.stories.mdx +0 -42
  232. package/src/lib/components/tag/tag.test.tsx +0 -36
  233. package/src/lib/components/tag/tag.tsx +0 -33
  234. package/src/lib/components/thumbnail/index.tsx +0 -1
  235. package/src/lib/components/thumbnail/stories/thumbnail.stories.mdx +0 -34
  236. package/src/lib/components/thumbnail/thumbnail-size-flags.tsx +0 -41
  237. package/src/lib/components/thumbnail/thumbnail.test.tsx +0 -51
  238. package/src/lib/components/thumbnail/thumbnail.tsx +0 -45
  239. package/src/lib/components/typography/index.ts +0 -1
  240. package/src/lib/components/typography/storybook/components.tsx +0 -288
  241. package/src/lib/components/typography/storybook/typography.stories.mdx +0 -90
  242. package/src/lib/components/typography/typography.test.tsx +0 -97
  243. package/src/lib/components/typography/typography.tsx +0 -99
  244. package/src/lib/foundations/color-system/base-palette/base-palette.stories.tsx +0 -123
  245. package/src/lib/foundations/color-system/base-palette/base-palette.ts +0 -93
  246. package/src/lib/foundations/color-system/base-palette/index.ts +0 -1
  247. package/src/lib/foundations/color-system/color-guidelines/color-guidelines.stories.mdx +0 -85
  248. package/src/lib/foundations/color-system/color-guidelines/color-guidelines.stories.tsx +0 -231
  249. package/src/lib/foundations/color-system/color-guidelines/color-guidelines.ts +0 -160
  250. package/src/lib/foundations/color-system/color-guidelines/index.ts +0 -1
  251. package/src/lib/foundations/color-system/components/color-sample.tsx +0 -99
  252. package/src/lib/foundations/color-system/components/index.ts +0 -1
  253. package/src/lib/foundations/color-system/index.ts +0 -1
  254. package/src/lib/foundations/index.ts +0 -4
  255. package/src/lib/foundations/shadows/components.tsx +0 -59
  256. package/src/lib/foundations/shadows/index.ts +0 -1
  257. package/src/lib/foundations/shadows/shadows.stories.mdx +0 -71
  258. package/src/lib/foundations/shadows/shadows.tsx +0 -47
  259. package/src/lib/foundations/spacing/index.ts +0 -1
  260. package/src/lib/foundations/spacing/spacing-guidelines.ts +0 -24
  261. package/src/lib/foundations/spacing/spacing.stories.mdx +0 -51
  262. package/src/lib/foundations/spacing/spacing.ts +0 -18
  263. package/src/lib/foundations/typography/constants.ts +0 -25
  264. package/src/lib/foundations/typography/fonts.ts +0 -205
  265. package/src/lib/foundations/typography/index.tsx +0 -1
  266. package/src/lib/foundations/typography/text-aspect-flags.ts +0 -61
  267. package/src/lib/foundations/typography/typography.tsx +0 -102
  268. package/src/lib/helpers/generic-types.ts +0 -44
  269. package/src/lib/helpers/index.ts +0 -6
  270. package/src/lib/helpers/nothing.tsx +0 -18
  271. package/src/lib/helpers/safe-navigation.ts +0 -44
  272. package/src/lib/helpers/slots.test.tsx +0 -98
  273. package/src/lib/helpers/slots.tsx +0 -157
  274. package/src/lib/helpers/strings.test.ts +0 -47
  275. package/src/lib/helpers/strings.ts +0 -16
  276. package/tsconfig.json +0 -35
  277. package/tsconfig.lib.json +0 -28
  278. package/tsconfig.spec.json +0 -21
@@ -1,60 +0,0 @@
1
- import { Margin, Padding, Surface, Icons } from '@foundations'
2
- import { FC } from '@helpers'
3
- import { Center } from 'components/layout'
4
- import styled from 'styled-components'
5
-
6
- const Controls = styled.div`
7
- height: 34px;
8
- width: 26px;
9
- padding: ${Padding.xxxs} ${Padding.xxxs};
10
- box-sizing: border-box;
11
- `
12
-
13
- const Up = styled(Center)`
14
- background: ${Surface.Neutral.Default};
15
- width: 22px;
16
- height: 14px;
17
- border-radius: 3px 3px 0px 0px;
18
- margin-bottom: ${Margin.xxxs};
19
- display: flex;
20
- align-items: center;
21
- justify-content: center;
22
- margin-top: ${Margin.xs}
23
- `
24
-
25
- const TriangleUp = styled.div`
26
- width: 0px;
27
- height: 0px;
28
- border-left: 5px solid transparent;
29
- border-right: 5px solid transparent;
30
- border-bottom: 5px solid ${Icons.Default};
31
- `
32
-
33
- const TriangleDown = styled.div`
34
- width: 0px;
35
- height: 0px;
36
- border-left: 5px solid transparent;
37
- border-right: 5px solid transparent;
38
- border-top: 5px solid ${Icons.Default};
39
- `
40
-
41
- const Down = styled(Center)`
42
- background: ${Surface.Neutral.Default};
43
- width: 22px;
44
- height: 14px;
45
- border-radius: 0px 0px 3px 3px;
46
- `
47
-
48
- interface IStepperProps {
49
- onUpClick?: () => void
50
- onDownClick?: () => void
51
- }
52
-
53
- export const Stepper: FC<IStepperProps> = (props: IStepperProps) => {
54
- return (
55
- <Controls>
56
- <Up onClick={props.onUpClick}><TriangleUp /></Up>
57
- <Down onClick={props.onDownClick}><TriangleDown /></Down>
58
- </Controls>
59
- )
60
- }
@@ -1,6 +0,0 @@
1
- // the html input
2
- export * from './input-field'
3
-
4
- // the simple inputs
5
- export * from './input-number'
6
- export * from './input-text'
@@ -1,107 +0,0 @@
1
- import { render, screen } from '@testing-library/react'
2
- import userEvent from '@testing-library/user-event'
3
- import { InputField } from './index'
4
-
5
- describe('InputField', () => {
6
- describe('the inner input element', () => {
7
- it('should receive nice html props', async () => {
8
- render(
9
- <InputField
10
- value="value"
11
- onChange={() => undefined}
12
- type="text"
13
- label="Label"
14
- placeholder="placeholder"
15
- />
16
- )
17
-
18
- expect(screen.getByRole('textbox')).toBeInTheDocument()
19
- expect(screen.getByPlaceholderText('placeholder')).toBeInTheDocument()
20
- expect(screen.getByDisplayValue('value')).toBeInTheDocument()
21
- })
22
-
23
- it('should call the onChange callback on change events', async () => {
24
- const handleChange = jest.fn()
25
-
26
- render(<InputField value="value" onChange={handleChange} />)
27
-
28
- await userEvent.type(screen.getByRole('textbox'), 'hello')
29
-
30
- expect(handleChange).toHaveBeenCalledTimes(5)
31
- })
32
- })
33
-
34
- describe('Label', () => {
35
- it('should render when given', async () => {
36
- render(<InputField label="Label" />)
37
-
38
- expect(screen.getByLabelText('Label')).toBeInTheDocument()
39
- })
40
-
41
- it('should not render when not given', async () => {
42
- render(<InputField />)
43
-
44
- expect(screen.queryByLabelText('Label')).not.toBeInTheDocument()
45
- })
46
- })
47
-
48
- describe('Prefix', () => {
49
- it('should render when given', async () => {
50
- render(<InputField prefix="$" />)
51
-
52
- expect(screen.getByText('$')).toBeInTheDocument()
53
- })
54
-
55
- it('should not render when not given', async () => {
56
- render(<InputField />)
57
-
58
- expect(screen.queryByText('$')).not.toBeInTheDocument()
59
- })
60
- })
61
-
62
- describe('Suffix', () => {
63
- it('should render when given', async () => {
64
- render(<InputField suffix="%" />)
65
-
66
- expect(screen.getByText('%')).toBeInTheDocument()
67
- })
68
-
69
- it('should not render when not given', async () => {
70
- render(<InputField />)
71
-
72
- expect(screen.queryByText('&')).not.toBeInTheDocument()
73
- })
74
- })
75
-
76
- describe('Slots', () => {
77
- it('should render the Icon slot', async () => {
78
- render(
79
- <InputField>
80
- <InputField.Icon>Icon</InputField.Icon>
81
- </InputField>
82
- )
83
-
84
- expect(screen.getByText('Icon')).toBeInTheDocument()
85
- })
86
-
87
- it('should render the Controls slot', async () => {
88
- render(
89
- <InputField>
90
- <InputField.Controls>Controls</InputField.Controls>
91
- </InputField>
92
- )
93
-
94
- expect(screen.getByText('Controls')).toBeInTheDocument()
95
- })
96
-
97
- it('should not render other kinds of children', () => {
98
- render(
99
- <InputField>
100
- <div>Other Children</div>
101
- </InputField>
102
- )
103
-
104
- expect(screen.queryByText('Other Children')).not.toBeInTheDocument()
105
- })
106
- })
107
- })
@@ -1,126 +0,0 @@
1
- import styled from 'styled-components'
2
- import { InputHTMLAttributes } from 'react'
3
-
4
- import { Borders, Focused, Margin, Padding, Surface, Typography, _Typography } from '@foundations'
5
- import { getSlot, Slot, is, forwardRef, If } from '@helpers'
6
- import { Flex, SpaceBetween } from '../layout'
7
-
8
- import { LabeledInput } from './components'
9
- import { Label } from 'components/typography'
10
-
11
- const FancyBorder = styled(SpaceBetween)<{ invalid?: boolean }>`
12
- background: ${({ invalid }) => is(invalid) ? Surface.Critical.Subdued : Surface.Default.Default };
13
- border: 1px solid ${({ invalid }) => is(invalid) ? Borders.Critical.Default : Borders.Default.Default };
14
- border-radius: 6px;
15
- box-sizing: border-box;
16
- margin-bottom: ${Margin.xxs};
17
- padding-left: ${Padding.s};
18
-
19
- user-select: none;
20
-
21
- :focus, :focus-within, :active {
22
- border: ${({ invalid }) => is(invalid)
23
- ? `1px solid ${Borders.Critical.Default}`
24
- : `2px solid ${Focused.Default}`
25
- };
26
- }
27
- `
28
-
29
- const InputLayout = styled(Flex)`
30
- width: 100%;
31
- `
32
-
33
- export const HTMLInput = styled.input`
34
- all: unset;
35
-
36
- padding: ${Padding.none} ${Padding.none} ${Padding.xs} ${Padding.none};
37
-
38
- width: 100%;
39
-
40
- ::-webkit-inner-spin-button {
41
- -webkit-appearance: none;
42
- margin: ${Margin.none};
43
- }
44
-
45
- ${Typography.Body}
46
-
47
- ::placeholder {
48
- ${_Typography.LightText}
49
- }
50
- `
51
-
52
- const PrefixFrame = styled(Label)`
53
- margin-right: ${Margin.xs};
54
- `
55
-
56
- const SuffixFrame = styled(Label)`
57
- margin-right: ${Margin.xs};
58
- `
59
-
60
- class IconSlot extends Slot {}
61
- class ControlsSlot extends Slot {}
62
-
63
- export type InputFieldSlots = {
64
- Icon: typeof IconSlot,
65
- Controls: typeof ControlsSlot,
66
- Label: typeof LabeledInput,
67
- }
68
-
69
- interface IInputFieldProps extends InputHTMLAttributes<HTMLInputElement> {
70
- invalid?: boolean
71
- prefix?: string
72
- suffix?: string
73
- label?: string
74
- }
75
-
76
- const InputFrame = styled.label`
77
- width: 100%;
78
- padding: ${Padding.xs} ${Padding.none} ${Padding.none} ${Padding.none};
79
- flex-direction: column;
80
- display: flex;
81
- `
82
-
83
- const ControlsFrame = Flex
84
-
85
- const InputLabel = styled(Label)`
86
- margin-bottom: ${Margin.xxs};
87
- `
88
-
89
- export const InputField = forwardRef<
90
- HTMLInputElement,
91
- IInputFieldProps,
92
- InputFieldSlots
93
- >((props: IInputFieldProps, ref) => {
94
- const { children, prefix, suffix, label, className, ...inputProps } = props
95
- const icon = getSlot(IconSlot, children)
96
- const controls = getSlot(ControlsSlot, children)
97
- const required = is(props.required) ? '*' : ''
98
-
99
- return (
100
- <FancyBorder invalid={props.invalid} className={className}>
101
- <InputFrame>
102
- <If is={label}>
103
- <InputLabel subtle subdued>
104
- {label}
105
- {required}
106
- </InputLabel>
107
- </If>
108
- <InputLayout>
109
- {icon}
110
- <If is={prefix}>
111
- <PrefixFrame subtle subdued>{prefix}</PrefixFrame>
112
- </If>
113
- <HTMLInput ref={ref} {...inputProps} />
114
- <If is={suffix}>
115
- <SuffixFrame subtle subdued>{suffix}</SuffixFrame>
116
- </If>
117
- </InputLayout>
118
- </InputFrame>
119
- <ControlsFrame center>{controls}</ControlsFrame>
120
- </FancyBorder>
121
- )
122
- })
123
-
124
- InputField.Icon = IconSlot
125
- InputField.Controls = ControlsSlot
126
- InputField.Label = LabeledInput
@@ -1,41 +0,0 @@
1
- import { FC, isNil } from '@helpers'
2
- import { InputField, InputFieldSlots } from './input-field'
3
- import { Stepper } from './components'
4
-
5
- interface IInputNumberProps {
6
- value?: number
7
- onChange: (change?: number) => void
8
-
9
- label?: string
10
- placeholder?: string
11
- invalid?: boolean
12
- prefix?: string
13
- suffix?: string
14
- required?: boolean
15
- }
16
-
17
- type IInputNumberSlots = InputFieldSlots & {
18
- Stepper: typeof Stepper
19
- }
20
-
21
- export const InputNumber: FC<IInputNumberProps, IInputNumberSlots> = (props) => {
22
- const { onChange, value, ...inputFieldProps } = props
23
-
24
- return (
25
- <InputField
26
- type='number'
27
- value={isNil(value) || isNaN(value) ? '' : value}
28
- onChange={(e) => {
29
- const next = e.target.value === '' ? undefined : parseFloat(e.target.value)
30
-
31
- onChange(next)
32
- }}
33
- {...inputFieldProps}
34
- />
35
- )
36
- }
37
-
38
- InputNumber.Icon = InputField.Icon
39
- InputNumber.Controls = InputField.Controls
40
- InputNumber.Label = InputField.Label
41
- InputNumber.Stepper = Stepper
@@ -1,30 +0,0 @@
1
- import { FC } from '@helpers'
2
- import { InputField, InputFieldSlots } from './input-field'
3
-
4
- interface IInputTextProps {
5
- value: string
6
- onChange: (change: string) => void
7
-
8
- label?: string
9
- invalid?: boolean
10
- placeholder?: string
11
- prefix?: string
12
- suffix?: string
13
- required?: boolean
14
- }
15
-
16
- export const InputText: FC<IInputTextProps, InputFieldSlots> = (props) => {
17
- const { onChange, ...inputFieldProps } = props
18
-
19
- return (
20
- <InputField
21
- type='text'
22
- onChange={(e) => onChange(e.target.value)}
23
- {...inputFieldProps}
24
- />
25
- )
26
- }
27
-
28
- InputText.Icon = InputField.Icon
29
- InputText.Controls = InputField.Controls
30
- InputText.Label = InputField.Label
@@ -1,327 +0,0 @@
1
- import styled from 'styled-components'
2
- import { useForm } from 'react-hook-form'
3
-
4
- import { SpaceBetween } from 'components/layout'
5
- import { InputField } from '../input-field'
6
-
7
- import { IconMinor } from 'components/icon'
8
-
9
- import { Playground } from 'storybook-addon-jarle-monaco'
10
- import { InputNumber } from '../input-number'
11
- import { InputText } from '../input-text'
12
-
13
-
14
- export const PlainHTMLFormExample = () => (
15
- <Playground
16
- code={`
17
- /* Edit this code sample! */
18
- const [invalid, setInvalid] = useState(false);
19
-
20
- <form onSubmit={(e) => e.preventDefault()}>
21
- <label htmlFor="country_code">Country code*</label>
22
- {/* try replacing this element with an <input /> */}
23
- <InputField
24
- // try setting the prefix, suffix, and invalid props
25
- type="text"
26
- placeholder="Enter a country code..."
27
- id="country_code"
28
- name="country_code"
29
- pattern="[A-Za-z]{3}"
30
- onInvalid={setInvalid}
31
- invalid={invalid}
32
- onChange={() => setInvalid(false)}
33
- title="Three letter country code"
34
- required
35
- />
36
- <input type="submit"/>
37
- </form>
38
- `}
39
- providerProps={{
40
- renderAsComponent: true,
41
- scope: {
42
- InputField,
43
- },
44
- }}
45
- />
46
- )
47
-
48
- export const InnerLabelExample = () => (
49
- <Playground
50
- code={`
51
- <InputField
52
- type="text"
53
- label="Country Code"
54
- placeholder="Enter a country code..."
55
- />
56
- `}
57
- providerProps={{
58
- renderAsComponent: true,
59
- scope: {
60
- InputField,
61
- },
62
- }}
63
- />
64
- )
65
-
66
- export const ReactFormHookExample = () => (
67
- <Playground
68
- code={`
69
- const { register, formState: { errors }, handleSubmit } = useForm();
70
- const onSubmit = data => alert(data);
71
-
72
- <form onSubmit={handleSubmit(onSubmit)}>
73
- <InputField
74
- label="First name"
75
- invalid={errors.firstName}
76
- required
77
- {...register("firstName", { required: true, maxLength: 20 })}
78
- />
79
- <InputField
80
- label="Last name"
81
- invalid={errors.lastName}
82
- {...register("lastName", { pattern: /^[A-Za-z]+$/i })}
83
- />
84
- <InputField
85
- label="Age"
86
- type="number"
87
- invalid={errors.age}
88
- {...register("age", { min: 18, max: 99 })}
89
- />
90
- <input type="submit" />
91
- </form>
92
- `}
93
- providerProps={{
94
- renderAsComponent: true,
95
- scope: {
96
- InputField,
97
- useForm,
98
- },
99
- }}
100
- />
101
- )
102
-
103
- export const SimpleInputExample = () => (
104
- <Playground
105
- code={`
106
- const [state, setState] = useState({
107
- firstName: '',
108
- lastName: '',
109
- age: 18
110
- });
111
-
112
- const onChange = (change) => setState({
113
- ...state,
114
- ...change
115
- });
116
-
117
- <>
118
- <InputText
119
- label="First name"
120
- value={state.firstName}
121
- onChange={(firstName) => onChange({ firstName })}
122
- />
123
- <InputText
124
- label="Last name"
125
- value={state.lastName}
126
- onChange={(lastName) => onChange({ lastName })}
127
- />
128
- <InputNumber
129
- label="Age"
130
- value={state.age}
131
- onChange={(age) => onChange({ age })}
132
- required
133
- />
134
- </>
135
- `}
136
- providerProps={{
137
- renderAsComponent: true,
138
- scope: {
139
- InputNumber,
140
- InputText,
141
- },
142
- }}
143
- />
144
- )
145
-
146
- export const IconExample = () => (
147
- <Playground
148
- code={`
149
- <InputField
150
- label="Search"
151
- type="text"
152
- prefix="🍺"
153
- >
154
- <InputField.Icon>
155
- <IconMinor.FolderOpen title="Icons render before the input" />
156
- </InputField.Icon>
157
- </InputField>
158
- `}
159
- providerProps={{
160
- renderAsComponent: true,
161
- scope: {
162
- InputField,
163
- IconMinor,
164
- },
165
- }}
166
- />
167
- )
168
-
169
- export const ControlsExample = () => (
170
- <Playground
171
- code={`
172
- const [likes, setLikes] = useState(0);
173
-
174
- const onLike = () => setLikes(likes + 1);
175
- const onDislike = () => setLikes(Math.max(likes - 1, 0));
176
-
177
- <InputField
178
- label="Do you like this storybook?"
179
- value={likes}
180
- onChange={() => undefined}
181
- type="number"
182
- suffix="🍺"
183
- >
184
- <InputField.Controls>
185
- <SpaceBetween>
186
- <div onClick={onLike}>️👍</div>
187
- <div>/</div>
188
- <div onClick={onDislike}>👎️</div>
189
- </SpaceBetween>
190
- </InputField.Controls>
191
- </InputField>
192
- `}
193
- providerProps={{
194
- renderAsComponent: true,
195
- scope: {
196
- InputField,
197
- IconMinor,
198
- styled,
199
- SpaceBetween,
200
- },
201
- }}
202
- />
203
- )
204
-
205
- export const OuterLabelExample = () => (
206
- <Playground
207
- code={`
208
- const [value, setValue] = useState('');
209
- const [errors, setErrors] = useState([]);
210
-
211
- const handleChange = (change: string) => {
212
- const errors = [];
213
-
214
- if (!change) {
215
- errors.push({ message: 'This field is required' });
216
- }
217
-
218
- if (!change.match(/[A-Za-z]{3}/)) {
219
- errors.push({ message: 'Input was not a 3 letter country code' });
220
- }
221
-
222
- setValue(change);
223
- setErrors(errors);
224
- }
225
-
226
- <InputText.Label
227
- label="Country Code"
228
- helpText="Please enter a 3 letter country code"
229
- errors={errors}
230
- >
231
- <InputText
232
- value={value}
233
- invalid={errors.length > 0}
234
- placeholder="e.g. AUD"
235
- onChange={handleChange}
236
- />
237
- </InputText.Label>
238
- `}
239
- providerProps={{
240
- renderAsComponent: true,
241
- scope: {
242
- InputText,
243
- IconMinor,
244
- },
245
- }}
246
- />
247
- )
248
-
249
- export const StepperExample = () => (
250
- <Playground
251
- code={`
252
- const [age, setAge] = useState(0);
253
- const onUp = () => setAge(Math.min(age + 1, 99));
254
- const onDown = () => setAge(Math.max(age - 1, 0));
255
- const errors = []
256
-
257
- if (0 > age || age > 100) {
258
- errors.push({ message: 'Please choose an age between 0 and 99' })
259
- }
260
-
261
- <form onSubmit={(e) => e.preventDefault()}>
262
- <InputNumber.Label
263
- helpText='Age should be a number between 0 and 99'
264
- errors={errors}
265
- >
266
- <InputNumber
267
- label='Age'
268
- onChange={setAge}
269
- value={age}
270
- invalid={errors.length > 0}
271
- placeholder="Enter your age..."
272
- >
273
- <InputNumber.Controls>
274
- <InputNumber.Stepper onUpClick={onUp} onDownClick={onDown} />
275
- </InputNumber.Controls>
276
- </InputNumber>
277
- </InputNumber.Label>
278
- <input type="submit"/>
279
- </form>
280
- `}
281
- providerProps={{
282
- renderAsComponent: true,
283
- scope: {
284
- InputNumber,
285
- styled,
286
- },
287
- }}
288
- />
289
- )
290
-
291
- export const AllDressedExample = () => (
292
- <Playground
293
- code={`
294
- <InputField.Label
295
- label='Price'
296
- helpText='Enter a price in AUD'
297
- errors={[{ message: 'Too many UI decorations!' }]}
298
- >
299
- <InputField
300
- type="number"
301
- label='Price'
302
- // prefix and suffix render immediately
303
- // before and after the input field
304
- prefix="$"
305
- suffix="AUD"
306
- step={0.01}
307
- min={0.00}
308
- placeholder="Enter an amount..."
309
- >
310
- <InputField.Icon>
311
- <IconMinor.CircleDollar title="Icons render before the input" />
312
- </InputField.Icon>
313
- <InputField.Controls>
314
- <IconMinor.CircleDollar title="Controls render after the input" />
315
- </InputField.Controls>
316
- </InputField>
317
- </InputField.Label>
318
- `}
319
- providerProps={{
320
- renderAsComponent: true,
321
- scope: {
322
- InputField,
323
- IconMinor,
324
- },
325
- }}
326
- />
327
- )