@edvisor/product-language 0.2.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 (248) 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 -53
  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 +12 -5
  102. package/.babelrc +0 -12
  103. package/.eslintrc.json +0 -139
  104. package/.storybook/main.js +0 -57
  105. package/.storybook/manager.js +0 -7
  106. package/.storybook/preview-head.html +0 -1
  107. package/.storybook/preview.js +0 -15
  108. package/.storybook/tsconfig.json +0 -30
  109. package/jest.config.ts +0 -15
  110. package/jest.setup.ts +0 -2
  111. package/project.json +0 -85
  112. package/release-it.json +0 -18
  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 -3
  118. package/src/helpers/talesOf.tsx +0 -42
  119. package/src/index.ts +0 -2
  120. package/src/lib/components/README.md +0 -49
  121. package/src/lib/components/alert-banner/alert-banner.tsx +0 -34
  122. package/src/lib/components/alert-banner/alert-level-flags.ts +0 -77
  123. package/src/lib/components/alert-banner/index.ts +0 -1
  124. package/src/lib/components/badge/badge-type-flags.ts +0 -72
  125. package/src/lib/components/badge/badge.stories.tsx +0 -16
  126. package/src/lib/components/badge/badge.test.tsx +0 -29
  127. package/src/lib/components/badge/badge.tsx +0 -31
  128. package/src/lib/components/badge/index.ts +0 -1
  129. package/src/lib/components/card/atoms/index.ts +0 -1
  130. package/src/lib/components/card/card.test.tsx +0 -163
  131. package/src/lib/components/card/card.tsx +0 -78
  132. package/src/lib/components/card/components/card-alert-banner-slot.tsx +0 -16
  133. package/src/lib/components/card/components/card-controls-slot.tsx +0 -19
  134. package/src/lib/components/card/components/card-section-slot.tsx +0 -51
  135. package/src/lib/components/card/components/index.ts +0 -3
  136. package/src/lib/components/card/index.ts +0 -2
  137. package/src/lib/components/card/molecules/index.ts +0 -1
  138. package/src/lib/components/card/molecules/left-right-card.test.tsx +0 -89
  139. package/src/lib/components/card/molecules/left-right-card.tsx +0 -63
  140. package/src/lib/components/card/storybook/card.stories.mdx +0 -100
  141. package/src/lib/components/card/storybook/components.tsx +0 -240
  142. package/src/lib/components/checkbox/checkbox.test.tsx +0 -39
  143. package/src/lib/components/checkbox/checkbox.tsx +0 -124
  144. package/src/lib/components/checkbox/components/components.tsx +0 -59
  145. package/src/lib/components/checkbox/index.tsx +0 -1
  146. package/src/lib/components/checkbox/stories/checkbox.stories.mdx +0 -54
  147. package/src/lib/components/checkbox/stories/components.tsx +0 -36
  148. package/src/lib/components/checkbox/stories/index.tsx +0 -1
  149. package/src/lib/components/divider/divider-type-flags.tsx +0 -37
  150. package/src/lib/components/divider/divider.test.tsx +0 -34
  151. package/src/lib/components/divider/divider.tsx +0 -37
  152. package/src/lib/components/divider/index.tsx +0 -1
  153. package/src/lib/components/divider/stories/components.tsx +0 -13
  154. package/src/lib/components/divider/stories/divider.stories.mdx +0 -50
  155. package/src/lib/components/index.ts +0 -14
  156. package/src/lib/components/input-field/components/index.ts +0 -2
  157. package/src/lib/components/input-field/components/labeled-input.tsx +0 -61
  158. package/src/lib/components/input-field/components/stepper.tsx +0 -59
  159. package/src/lib/components/input-field/index.ts +0 -6
  160. package/src/lib/components/input-field/input-field.test.tsx +0 -108
  161. package/src/lib/components/input-field/input-field.tsx +0 -126
  162. package/src/lib/components/input-field/input-number.tsx +0 -41
  163. package/src/lib/components/input-field/input-text.tsx +0 -30
  164. package/src/lib/components/input-field/storybook/components.tsx +0 -334
  165. package/src/lib/components/input-field/storybook/input-field.stories.mdx +0 -113
  166. package/src/lib/components/layout/flex.tsx +0 -22
  167. package/src/lib/components/layout/grid-layout.tsx +0 -40
  168. package/src/lib/components/layout/index.ts +0 -3
  169. package/src/lib/components/layout/left-right-layout.tsx +0 -67
  170. package/src/lib/components/link/index.ts +0 -1
  171. package/src/lib/components/link/link.test.tsx +0 -29
  172. package/src/lib/components/link/link.tsx +0 -56
  173. package/src/lib/components/link/storybook/link.stories.mdx +0 -51
  174. package/src/lib/components/molecules/avatar/avatar-size-flags.tsx +0 -55
  175. package/src/lib/components/molecules/avatar/avatar.test.tsx +0 -114
  176. package/src/lib/components/molecules/avatar/avatar.tsx +0 -80
  177. package/src/lib/components/molecules/avatar/index.tsx +0 -1
  178. package/src/lib/components/molecules/avatar/stories/avatar.stories.mdx +0 -55
  179. package/src/lib/components/molecules/avatar/stories/components.tsx +0 -36
  180. package/src/lib/components/molecules/button/button-flags.tsx +0 -235
  181. package/src/lib/components/molecules/button/button.test.tsx +0 -77
  182. package/src/lib/components/molecules/button/button.tsx +0 -231
  183. package/src/lib/components/molecules/button/index.tsx +0 -1
  184. package/src/lib/components/molecules/button/stories/button.stories.mdx +0 -104
  185. package/src/lib/components/molecules/button/stories/components.tsx +0 -86
  186. package/src/lib/components/molecules/index.ts +0 -3
  187. package/src/lib/components/molecules/input-checkbox/index.tsx +0 -1
  188. package/src/lib/components/molecules/input-checkbox/input-checkbox.test.tsx +0 -34
  189. package/src/lib/components/molecules/input-checkbox/input-checkbox.tsx +0 -50
  190. package/src/lib/components/molecules/input-checkbox/stories/components.tsx +0 -36
  191. package/src/lib/components/molecules/input-checkbox/stories/index.tsx +0 -1
  192. package/src/lib/components/molecules/input-checkbox/stories/input-checkbox.stories.mdx +0 -51
  193. package/src/lib/components/organisms/index.ts +0 -1
  194. package/src/lib/components/organisms/multi-choice-list/index.tsx +0 -1
  195. package/src/lib/components/organisms/multi-choice-list/multi-choice-list.test.tsx +0 -33
  196. package/src/lib/components/organisms/multi-choice-list/multi-choice-list.tsx +0 -53
  197. package/src/lib/components/organisms/multi-choice-list/stories/components.tsx +0 -126
  198. package/src/lib/components/organisms/multi-choice-list/stories/index.tsx +0 -1
  199. package/src/lib/components/organisms/multi-choice-list/stories/multi-choice-list.stories.mdx +0 -99
  200. package/src/lib/components/spinner/index.tsx +0 -1
  201. package/src/lib/components/spinner/spinner-size-flags.tsx +0 -39
  202. package/src/lib/components/spinner/spinner.test.tsx +0 -31
  203. package/src/lib/components/spinner/spinner.tsx +0 -67
  204. package/src/lib/components/spinner/stories/components.tsx +0 -8
  205. package/src/lib/components/spinner/stories/spinner.stories.mdx +0 -42
  206. package/src/lib/components/thumbnail/index.tsx +0 -1
  207. package/src/lib/components/thumbnail/stories/thumbnail.stories.mdx +0 -34
  208. package/src/lib/components/thumbnail/thumbnail-size-flags.tsx +0 -41
  209. package/src/lib/components/thumbnail/thumbnail.test.tsx +0 -51
  210. package/src/lib/components/thumbnail/thumbnail.tsx +0 -40
  211. package/src/lib/components/typography/index.ts +0 -1
  212. package/src/lib/components/typography/storybook/components.tsx +0 -256
  213. package/src/lib/components/typography/storybook/typography.stories.mdx +0 -88
  214. package/src/lib/components/typography/typography.test.tsx +0 -93
  215. package/src/lib/components/typography/typography.tsx +0 -57
  216. package/src/lib/foundations/color-system/base-palette/base-palette.stories.tsx +0 -123
  217. package/src/lib/foundations/color-system/base-palette/base-palette.ts +0 -94
  218. package/src/lib/foundations/color-system/base-palette/index.ts +0 -1
  219. package/src/lib/foundations/color-system/color-guidelines/color-guidelines.stories.mdx +0 -85
  220. package/src/lib/foundations/color-system/color-guidelines/color-guidelines.stories.tsx +0 -231
  221. package/src/lib/foundations/color-system/color-guidelines/color-guidelines.ts +0 -159
  222. package/src/lib/foundations/color-system/color-guidelines/index.ts +0 -1
  223. package/src/lib/foundations/color-system/components/color-sample.tsx +0 -99
  224. package/src/lib/foundations/color-system/components/index.ts +0 -1
  225. package/src/lib/foundations/color-system/index.ts +0 -1
  226. package/src/lib/foundations/index.ts +0 -4
  227. package/src/lib/foundations/shadows/components.tsx +0 -59
  228. package/src/lib/foundations/shadows/index.ts +0 -1
  229. package/src/lib/foundations/shadows/shadows.stories.mdx +0 -71
  230. package/src/lib/foundations/shadows/shadows.tsx +0 -47
  231. package/src/lib/foundations/spacing/index.ts +0 -1
  232. package/src/lib/foundations/spacing/spacing-guidelines.ts +0 -24
  233. package/src/lib/foundations/spacing/spacing.stories.mdx +0 -51
  234. package/src/lib/foundations/spacing/spacing.ts +0 -18
  235. package/src/lib/foundations/typography/constants.ts +0 -25
  236. package/src/lib/foundations/typography/index.tsx +0 -1
  237. package/src/lib/foundations/typography/text-aspect-flags.ts +0 -54
  238. package/src/lib/foundations/typography/typography.tsx +0 -97
  239. package/src/lib/helpers/generic-types.ts +0 -44
  240. package/src/lib/helpers/index.ts +0 -6
  241. package/src/lib/helpers/nothing.tsx +0 -18
  242. package/src/lib/helpers/safe-navigation.ts +0 -34
  243. package/src/lib/helpers/slots.tsx +0 -76
  244. package/src/lib/helpers/strings.test.ts +0 -47
  245. package/src/lib/helpers/strings.ts +0 -16
  246. package/tsconfig.json +0 -35
  247. package/tsconfig.lib.json +0 -28
  248. package/tsconfig.spec.json +0 -21
@@ -1,86 +0,0 @@
1
-
2
- import { Playground } from 'storybook-addon-jarle-monaco'
3
- import { InputField } from '../../../input-field'
4
- import { Button, ButtonPrimary } from '../button'
5
-
6
- export const PlainHTMLFormExample = () => (
7
- <Playground
8
- code={`
9
- /* Edit this code sample! */
10
- const [invalid, setInvalid] = useState(false);
11
-
12
- <form onSubmit={(e) => e.preventDefault()}>
13
- <label htmlFor="country_code">Country code:</label>
14
- <InputField
15
- type="text"
16
- placeholder="Enter a country code..."
17
- id="country_code"
18
- name="country_code"
19
- pattern="[A-Za-z]{3}"
20
- onInvalid={setInvalid}
21
- invalid={invalid}
22
- onChange={() => setInvalid(false)}
23
- title="Three letter country code"
24
- required
25
- />
26
- <div style={{display:'flex', gap:'8px'}}>
27
- <ButtonBasic type="reset">Clear</ButtonBasic>
28
- <ButtonPrimary type="submit">Send</ButtonPrimary>
29
- </div>
30
- </form>
31
- `}
32
- providerProps={{
33
- renderAsComponent: true,
34
- scope: {
35
- InputField,
36
- ButtonBasic: Button,
37
- ButtonPrimary
38
- },
39
- }}
40
- />
41
- )
42
-
43
- export const DisabledLoadingExample = () => (
44
- <Playground
45
- code={`
46
- /* Edit this code sample! */
47
- const [invalid, setInvalid] = useState(false);
48
- const [disabled, setDisabled] = useState(true);
49
- const [loading, setLoading] = useState(false);
50
-
51
- <form onSubmit={(e) => {
52
- e.preventDefault();
53
- setLoading(true)
54
- setTimeout(() => setLoading(false), 2000)
55
- }}>
56
- <label htmlFor="country_code">Country code:</label>
57
- <InputField
58
- type="text"
59
- placeholder="Enter a country code..."
60
- id="country_code"
61
- name="country_code"
62
- pattern="[A-Za-z]{3}"
63
- onInvalid={setInvalid}
64
- invalid={invalid}
65
- onChange={() => {
66
- setInvalid(false);
67
- setDisabled(false);
68
- }}
69
- title="Three letter country code"
70
- required
71
- />
72
- <div style={{display:'flex', gap:'8px'}}>
73
- <ButtonPrimary type="submit" disabled={disabled} loading={loading}>Send</ButtonPrimary>
74
- </div>
75
- </form>
76
- `}
77
- providerProps={{
78
- renderAsComponent: true,
79
- scope: {
80
- InputField,
81
- ButtonBasic: Button,
82
- ButtonPrimary
83
- },
84
- }}
85
- />
86
- )
@@ -1,3 +0,0 @@
1
- export * from './avatar'
2
- export * from './button'
3
- export * from './input-checkbox'
@@ -1 +0,0 @@
1
- export * from './input-checkbox'
@@ -1,34 +0,0 @@
1
- import {render, screen } from '@testing-library/react'
2
- import userEvent from '@testing-library/user-event'
3
- import { InputCheckbox } from './input-checkbox'
4
-
5
- describe('InputCheckbox Tests', () => {
6
- it('should render the component and handle event after click', async () => {
7
- const spyOnChange = jest.fn()
8
- render(
9
- <InputCheckbox
10
- label='My Checkbox'
11
- onChange={spyOnChange}
12
- />
13
- )
14
-
15
- expect(spyOnChange).not.toHaveBeenCalled()
16
- const myComponent = screen.getByRole('checkbox')
17
- expect(screen.getByText('My Checkbox')).toBeInTheDocument()
18
- expect(myComponent).toBeInTheDocument()
19
-
20
- await userEvent.click(myComponent)
21
-
22
- expect(spyOnChange).toHaveBeenCalled()
23
- })
24
- it('should not render the component if dont receive a label', async () => {
25
- const { container } = render(
26
- <InputCheckbox
27
- label=''
28
- />
29
- )
30
-
31
-
32
- expect(container).toBeEmptyDOMElement()
33
- })
34
- })
@@ -1,50 +0,0 @@
1
- import { useState } from 'react'
2
- import styled from 'styled-components'
3
- import { FC, isDefined, isEmpty, Nothing } from '@helpers'
4
- import { Margin } from '@foundations'
5
- import { Checkbox, ICheckboxProps } from '../../checkbox'
6
- import { Label1 } from 'components/typography'
7
- import { Flex } from 'components/layout'
8
-
9
- const Text = styled(Label1)`
10
- margin-left: ${Margin.s};
11
- user-select: none;
12
- `
13
- const Wrapper = styled(Flex)`
14
- width: 100%;
15
- align-items: center;
16
- `
17
- interface IInputCheckboxProps {
18
- label: string
19
- }
20
-
21
- export type IInputCheckbox = IInputCheckboxProps & ICheckboxProps
22
-
23
- export const InputCheckbox: FC<IInputCheckbox> = (props) => {
24
- const { onChange, label = '', disabled = false, error = false, checked = false } = props
25
- const [isChecked, setIsChecked] = useState(checked)
26
- if (isEmpty(label)) {
27
- return <Nothing />
28
- }
29
-
30
- const handleOnChange = () => {
31
- setIsChecked(!isChecked)
32
- if(isDefined(onChange)){
33
- onChange(!isChecked)
34
- }
35
- }
36
-
37
- return (
38
- <Wrapper>
39
- <Checkbox
40
- {...props}
41
- onChange={handleOnChange}
42
- onClick={handleOnChange}
43
- disabled={disabled}
44
- error={error}
45
- checked={isChecked}
46
- />
47
- <Text>{label}</Text>
48
- </Wrapper>
49
- )
50
- }
@@ -1,36 +0,0 @@
1
- import { Playground } from 'storybook-addon-jarle-monaco'
2
- import { InputCheckbox } from '../index'
3
-
4
- export const PlainHTMLFormExample = () => (
5
- <Playground
6
- code={`
7
- /* Edit this code sample! */
8
- const [withError, setWithError] = useState(false);
9
-
10
- <form onSubmit={(e) => {
11
- e.preventDefault()
12
- console.log('form submitted')
13
- }}
14
- >
15
- <InputCheckbox
16
- onInvalid={(e) => {
17
- setWithError(true)
18
- }}
19
- error={withError}
20
- onChange={(e) => {
21
- console.log('at stories', e)
22
- setWithError(false)
23
- }}
24
- label="My label"
25
- required />
26
- <input type="submit"/>
27
- </form>
28
- `}
29
- providerProps={{
30
- renderAsComponent: true,
31
- scope: {
32
- InputCheckbox,
33
- },
34
- }}
35
- />
36
- )
@@ -1 +0,0 @@
1
- export * from './components'
@@ -1,51 +0,0 @@
1
- import { Canvas, Meta, Story } from '@storybook/addon-docs';
2
- import { InputCheckbox } from '../index'
3
- import { PlainHTMLFormExample } from './index'
4
-
5
- <Meta
6
- title="Components/InputCheckbox"
7
- component={InputCheckbox}
8
- />
9
-
10
- # InputCheckbox
11
-
12
- This is a molecule, composed by the atoms checkbox input and typography as well.
13
-
14
- For more details, check out the component page on [Figma](https://www.figma.com/file/ue1CurHfZ426o2T2l8Dk64/Edvisor-Product-Language?node-id=1008%3A1257)
15
-
16
- ## How to use
17
-
18
- ```javascript
19
- // Import the component
20
- import { InputCheckbox } from './index'
21
-
22
-
23
- // Render the component sending the required parameters
24
- <InputCheckbox label="MY-TEXT-HERE" />
25
- ```
26
-
27
- ## Examples
28
-
29
- <Canvas>
30
- <InputCheckbox label="My label" onChange={(e) => console.log('at stories', e)} />
31
- <InputCheckbox label="My label" disabled />
32
- <InputCheckbox label="My label" error />
33
- <InputCheckbox label="My label" checked />
34
- <InputCheckbox label="My label" error checked />
35
- </Canvas>
36
-
37
-
38
- ## API
39
- You can send all the possible values from Checkbox component.
40
- Also, you can sen this parameters:
41
-
42
-
43
- | Name | Type | Description | Required (Y/N)|
44
- | ---- | ----- | ------ | ------- |
45
- | `label` | `string` | `The label from the checkbox` | `Y` |
46
- | `onChange` | `event` | `You can listen the changes from the component` | `N` |
47
-
48
-
49
- ## Playground
50
-
51
- <PlainHTMLFormExample />
@@ -1 +0,0 @@
1
- export * from './multi-choice-list'
@@ -1 +0,0 @@
1
- export * from './multi-choice-list'
@@ -1,33 +0,0 @@
1
- import { render, screen } from '@testing-library/react'
2
- import { MultiChoiceList } from './multi-choice-list'
3
-
4
- describe('MultiChoiceList Tests', () => {
5
- it('should render the amount of checkbox matching with the options size', async () => {
6
- render(
7
- <MultiChoiceList options={[
8
- {
9
- label: 'My Awesome label',
10
- id: 'My checkbox 1',
11
- checked: true,
12
- error: true,
13
- helpfulMessage: 'Alternative text here',
14
- },
15
- {
16
- label: 'My Awesome label',
17
- id: 'My checkbox 2'
18
- },
19
- ]}
20
- />
21
- )
22
-
23
- expect(screen.getByText('Alternative text here')).toBeInTheDocument()
24
- expect(screen.getAllByRole('checkbox').length).toBe(2)
25
- })
26
- it('should not render anything if dont send valid options', async () => {
27
- render(
28
- <MultiChoiceList options={[]}
29
- />
30
- )
31
- expect(screen.queryAllByRole('checkbox').length).toBe(0)
32
- })
33
- })
@@ -1,53 +0,0 @@
1
- import styled from 'styled-components'
2
- import { FC, isDefined, isEmpty, Nothing } from '@helpers'
3
- import { Text , Margin } from '@foundations'
4
- import { Flex } from 'components/layout'
5
- import { Label1 } from 'components/typography'
6
- import { InputCheckbox, IInputCheckbox } from '../../molecules/input-checkbox'
7
-
8
- const HelpfulMessage = styled(Label1)`
9
- margin-top: ${Margin.xxs};
10
- margin-left: ${Margin.xl};
11
- color: ${Text.Subdued};
12
- user-select: none;
13
- `
14
- const Group = styled(Flex)`
15
- width: 100%;
16
- flex-direction: column;
17
- gap: 18px;
18
- `
19
- interface IOption extends IInputCheckbox {
20
- id: string
21
- helpfulMessage?: string
22
- }
23
- interface IMultiChoiceList {
24
- options: IOption[]
25
- }
26
-
27
- export const MultiChoiceList: FC<IMultiChoiceList> = (props: IMultiChoiceList) => {
28
- const { options } = props
29
-
30
- if (isEmpty(options)) {
31
- return <Nothing />
32
- }
33
- return (
34
- <Group role="group">
35
- {options.map((option:IOption) => (
36
- <div key={option.id}>
37
- <InputCheckbox
38
- aria-describedby={isDefined(option.helpfulMessage)
39
- ? `${option.id}-id`
40
- : ''
41
- }
42
- {...option}
43
- />
44
- {isDefined(option.helpfulMessage) && (
45
- <HelpfulMessage id={`${option.id}-id`}>
46
- {option.helpfulMessage}
47
- </HelpfulMessage>
48
- )}
49
- </div>
50
- ))}
51
- </Group>
52
- )
53
- }
@@ -1,126 +0,0 @@
1
- import { Body, Heading4 } from '@components'
2
- import { Playground } from 'storybook-addon-jarle-monaco'
3
- import { MultiChoiceList } from '../index'
4
-
5
- export const PlainHTMLFormExample = () => (
6
- <Playground
7
- code={`
8
- /* Edit this code sample! */
9
- const [withError, setWithError] = useState(false);
10
-
11
- <form onSubmit={(e) => {
12
- e.preventDefault()
13
- console.log('form submitted')
14
- }}
15
- >
16
- <MultiChoiceList options={[
17
- {
18
- label: "My Awesome label",
19
- id: 'My checkbox 1',
20
- required: true,
21
- error: withError,
22
- helpfulMessage: 'Alternative text here',
23
- onInvalid: function(e){
24
- setWithError(true);
25
- },
26
- onChange: function(e){
27
- console.log('at stories', e);
28
- setWithError(false);
29
- }
30
- },
31
- {
32
- label: "My Awesome label",
33
- id: 'My checkbox 2',
34
- checked: true,
35
- helpfulMessage: 'Alternative text here',
36
- },
37
- ]}
38
- />
39
- <input type="submit"/>
40
- </form>
41
- `}
42
- providerProps={{
43
- renderAsComponent: true,
44
- scope: {
45
- MultiChoiceList,
46
- },
47
- }}
48
- />
49
- )
50
-
51
- export const ExampleWithStateManagement = () => (
52
- <Playground
53
- code={`
54
- /* Edit this code sample! */
55
- const Locations = [
56
- {
57
- label: "Vancouver, BC",
58
- id: 1,
59
- },
60
- {
61
- label: "Toronto, ON",
62
- id: 2,
63
- },
64
- {
65
- label: "Quebec, QC",
66
- id: 3,
67
- },
68
- {
69
- label: "Montreal, QC",
70
- id: 4,
71
- },
72
- ];
73
- const [locations, setLocations] = useState([]);
74
- const [withError, setWithError] = useState(false);
75
-
76
- const options = Locations.map((location) => {
77
- return {
78
- ...location,
79
- checked: locations.find((l) => l.id === location.id),
80
- onChange: (checked) => {
81
- if (checked) {
82
- setLocations([
83
- ...locations,
84
- location,
85
- ])
86
- } else {
87
- const i = locations.findIndex((l) => l.id === location.id)
88
- locations.splice(i, 1)
89
- setLocations([
90
- ...locations
91
- ])
92
- }
93
- }
94
- }
95
- });
96
-
97
- <>
98
- <form onSubmit={(e) => {
99
- e.preventDefault()
100
- console.log('locations', locations)
101
- }}
102
- >
103
- <MultiChoiceList options={options}
104
- />
105
- <input type="submit"/>
106
- </form>
107
- <div>
108
- <Heading4>Your Selection</Heading4>
109
- {locations.map((location) => {
110
- return (
111
- <Body key={location.id}>{location.label}</Body>
112
- )
113
- })}
114
- </div>
115
- </>
116
- `}
117
- providerProps={{
118
- renderAsComponent: true,
119
- scope: {
120
- MultiChoiceList,
121
- Heading4,
122
- Body,
123
- },
124
- }}
125
- />
126
- )
@@ -1 +0,0 @@
1
- export * from './components'
@@ -1,99 +0,0 @@
1
- import { Canvas, Meta, Story } from '@storybook/addon-docs';
2
- import { MultiChoiceList } from '../index'
3
- import { PlainHTMLFormExample, ExampleWithStateManagement } from './index'
4
-
5
- <Meta
6
- title="Components/MultiChoiceList"
7
- component={MultiChoiceList}
8
- />
9
-
10
- # MultiChoiceList
11
-
12
- This is a organism, composed by checkbox molecule and some atoms.
13
-
14
- For more details, check out the component page on [Figma](https://www.figma.com/file/ue1CurHfZ426o2T2l8Dk64/Edvisor-Product-Language?node-id=1097%3A2349)
15
-
16
- ## How to use
17
-
18
- ```javascript
19
- // Import the component
20
- import { MultiChoiceList } from './index'
21
-
22
-
23
- // Render the component sending the required parameters
24
- <MultiChoiceList options={[
25
- {
26
- label: 'My Awesome label',
27
- checked: true,
28
- id: '1',
29
- }]
30
- />
31
- ```
32
- ## Examples
33
-
34
- <Canvas>
35
- <MultiChoiceList options={[
36
- {
37
- label: "My Awesome label",
38
- checked: true,
39
- id: '1',
40
- },
41
- {
42
- label: "My label",
43
- id: '2',
44
- },
45
- {
46
- label: "My label",
47
- id: '3',
48
- },
49
- {
50
- label: "My label",
51
- id: '4',
52
- },
53
- ]}/>
54
- </Canvas>
55
-
56
- Also, you can send the altive text in order to helping user
57
- <Canvas>
58
- <MultiChoiceList options={[
59
- {
60
- label: "My Awesome label",
61
- id: 'My checkbox 1',
62
- checked: true,
63
- error: true,
64
- helpfulMessage: 'Alternative text here',
65
- },
66
- {
67
- label: "My Awesome label",
68
- id: 'My checkbox 2',
69
- helpfulMessage: 'Alternative text here',
70
- },
71
- {
72
- label: "My Awesome label",
73
- id: 'My checkbox 3',
74
- helpfulMessage: 'Alternative text here',
75
- }
76
- ]}/>
77
- </Canvas>
78
-
79
-
80
- ## API
81
- This component receive a list (`options` parameter) from N amount of Checkbox if you'd like to render.
82
- So all the possible values from Checkbox component can be passed here.
83
- Also, you can sen this parameters:
84
-
85
- | Name | Type | Description | Required (Y/N)|
86
- | ---- | ----- | ------ | ----- |
87
- | `id` | `string` | `The id from each checkbox in the list` | `Y` |
88
- | `helpfulMessage` | `string` | `Message that will be render bellow each checkbox field` | `N` |
89
-
90
- ## Playground
91
-
92
- <PlainHTMLFormExample />
93
-
94
- ### With State Management Example
95
-
96
- <ExampleWithStateManagement />
97
-
98
- ## Changelog
99
- - Offer the "indeterminate" behavior to render this list nesting
@@ -1 +0,0 @@
1
- export * from './spinner'
@@ -1,39 +0,0 @@
1
- import { bitwiseOr, MappedEnum, RequireOnlyOne, PropsWithChildren } from '@helpers'
2
-
3
- const enum SpinnerSize {
4
- small = 1,
5
- medium = 2,
6
- large = 4,
7
- }
8
-
9
- type SpinnerSizes<T> = MappedEnum<typeof SpinnerSize, T>
10
-
11
- function toSpinner(n: number): SpinnerSize {
12
- switch (n) {
13
- case SpinnerSize.small:
14
- return SpinnerSize.small
15
- case SpinnerSize.medium:
16
- return SpinnerSize.medium
17
- case SpinnerSize.large:
18
- return SpinnerSize.large
19
- default:
20
- return SpinnerSize.medium
21
- }
22
- }
23
-
24
- const SpinnerValues = {
25
- [SpinnerSize.small]: '18px',
26
- [SpinnerSize.medium]: '40px',
27
- [SpinnerSize.large]: '60px',
28
- }
29
-
30
- export type SpinnerProps = Partial<RequireOnlyOne<SpinnerSizes<boolean>>> &
31
- PropsWithChildren
32
-
33
- export function getValuesBySize(props: SpinnerProps): string {
34
- return SpinnerValues[
35
- toSpinner(
36
- bitwiseOr([props.small, props.medium, props.large])
37
- )
38
- ]
39
- }
@@ -1,31 +0,0 @@
1
- import { render, screen } from '@testing-library/react'
2
- import { Spinner } from './index'
3
-
4
- describe('Spinner Tests', () => {
5
- describe('Spinner Tests', () => {
6
- it('should render the Spinner with default size', async () => {
7
- render(
8
- <Spinner />
9
- )
10
-
11
- const spinner = screen.getByRole('progressbar')
12
-
13
- expect(spinner).toBeInTheDocument()
14
- expect(spinner).toHaveStyle('height: 40px')
15
-
16
- })
17
-
18
- it('should render the Spinner with small size', async () => {
19
- render(
20
- <Spinner small/>
21
- )
22
-
23
- const spinner = screen.getByRole('progressbar')
24
-
25
- expect(spinner).toBeInTheDocument()
26
- expect(spinner).toHaveStyle('height: 18px')
27
-
28
- })
29
-
30
- })
31
- })