@papillonarts/components 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/build/index.ts +1 -0
  2. package/build/primer/Alert/Alert.mdx +88 -0
  3. package/build/primer/Alert/Alert.prop.ts +45 -0
  4. package/build/primer/Alert/Alert.tsx +101 -0
  5. package/build/primer/Alert/__tests__/Alert.int.story.tsx +86 -0
  6. package/build/primer/Alert/__tests__/Alert.int.test.ts +37 -0
  7. package/build/primer/Alert/index.ts +2 -0
  8. package/build/primer/Blankslate/Blankslate.mdx +57 -0
  9. package/build/primer/Blankslate/Blankslate.prop.ts +26 -0
  10. package/build/primer/Blankslate/Blankslate.tsx +26 -0
  11. package/build/primer/Blankslate/__tests__/Blankslate.int.story.tsx +43 -0
  12. package/build/primer/Blankslate/__tests__/Blankslate.int.test.ts +29 -0
  13. package/build/primer/Blankslate/index.ts +2 -0
  14. package/build/primer/Breadcrumb/Breadcrumb.mdx +23 -0
  15. package/build/primer/Breadcrumb/Breadcrumb.prop.ts +28 -0
  16. package/build/primer/Breadcrumb/Breadcrumb.tsx +57 -0
  17. package/build/primer/Breadcrumb/__tests__/Breadcrumb.int.story.tsx +40 -0
  18. package/build/primer/Breadcrumb/__tests__/Breadcrumb.int.test.ts +40 -0
  19. package/build/primer/Breadcrumb/index.ts +2 -0
  20. package/build/primer/Button/Button.mdx +239 -0
  21. package/build/primer/Button/Button.prop.ts +77 -0
  22. package/build/primer/Button/Button.tsx +91 -0
  23. package/build/primer/Button/__tests__/Button.int.story.tsx +173 -0
  24. package/build/primer/Button/__tests__/Button.int.test.ts +191 -0
  25. package/build/primer/Button/index.ts +2 -0
  26. package/build/primer/Dropdown/Dropdown.mdx +19 -0
  27. package/build/primer/Dropdown/Dropdown.prop.ts +33 -0
  28. package/build/primer/Dropdown/Dropdown.tsx +102 -0
  29. package/build/primer/Dropdown/__tests__/Dropdown.int.story.tsx +43 -0
  30. package/build/primer/Dropdown/__tests__/Dropdown.int.test.ts +53 -0
  31. package/build/primer/Dropdown/index.ts +2 -0
  32. package/build/primer/ErrorBoundary/ErrorBoundary.prop.ts +5 -0
  33. package/build/primer/ErrorBoundary/ErrorBoundary.tsx +35 -0
  34. package/build/primer/ErrorBoundary/__tests__/ErrorBoundary.int.story.tsx +23 -0
  35. package/build/primer/ErrorBoundary/__tests__/ErrorBoundary.int.test.ts +9 -0
  36. package/build/primer/ErrorBoundary/index.ts +1 -0
  37. package/build/primer/Form/Checkbox/Checkbox.prop.ts +34 -0
  38. package/build/primer/Form/Checkbox/Checkbox.tsx +40 -0
  39. package/build/primer/Form/Checkbox/__tests__/Checkbox.int.story.tsx +50 -0
  40. package/build/primer/Form/Checkbox/__tests__/Checkbox.int.test.ts +23 -0
  41. package/build/primer/Form/Checkbox/index.ts +2 -0
  42. package/build/primer/Form/Input/Input.prop.ts +43 -0
  43. package/build/primer/Form/Input/Input.tsx +43 -0
  44. package/build/primer/Form/Input/__tests__/Input.int.story.tsx +54 -0
  45. package/build/primer/Form/Input/__tests__/Input.int.test.ts +15 -0
  46. package/build/primer/Form/Input/index.ts +2 -0
  47. package/build/primer/Form/Radio/Radio.prop.ts +30 -0
  48. package/build/primer/Form/Radio/Radio.tsx +38 -0
  49. package/build/primer/Form/Radio/__tests__/Radio.int.story.tsx +42 -0
  50. package/build/primer/Form/Radio/__tests__/Radio.int.test.ts +13 -0
  51. package/build/primer/Form/Radio/index.ts +2 -0
  52. package/build/primer/Form/index.ts +19 -0
  53. package/build/primer/Grid/DisplayTable/DisplayTable.prop.ts +21 -0
  54. package/build/primer/Grid/DisplayTable/DisplayTable.tsx +68 -0
  55. package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.data.ts +289 -0
  56. package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.story.tsx +27 -0
  57. package/build/primer/Grid/DisplayTable/__tests__/DisplayTable.int.test.ts +9 -0
  58. package/build/primer/Grid/DisplayTable/index.ts +1 -0
  59. package/build/primer/Grid/FlexGrid/FlexGrid.prop.ts +59 -0
  60. package/build/primer/Grid/FlexGrid/FlexGrid.tsx +274 -0
  61. package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.data.ts +289 -0
  62. package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.story.tsx +146 -0
  63. package/build/primer/Grid/FlexGrid/__tests__/FlexGrid.int.test.ts +46 -0
  64. package/build/primer/Grid/FlexGrid/index.ts +2 -0
  65. package/build/primer/Grid/index.ts +9 -0
  66. package/build/primer/Icon/Icon.part.ts +1289 -0
  67. package/build/primer/Icon/Icon.prop.ts +1337 -0
  68. package/build/primer/Icon/Icon.tsx +49 -0
  69. package/build/primer/Icon/__tests__/Icon.int.story.tsx +58 -0
  70. package/build/primer/Icon/__tests__/Icon.int.test.ts +13 -0
  71. package/build/primer/Icon/index.ts +2 -0
  72. package/build/primer/Label/Label.mdx +13 -0
  73. package/build/primer/Label/Label.prop.ts +31 -0
  74. package/build/primer/Label/Label.tsx +27 -0
  75. package/build/primer/Label/__tests__/Label.int.story.tsx +19 -0
  76. package/build/primer/Label/__tests__/Label.int.test.ts +9 -0
  77. package/build/primer/Label/index.ts +1 -0
  78. package/build/primer/Loader/Loader.mdx +31 -0
  79. package/build/primer/Loader/Loader.prop.ts +16 -0
  80. package/build/primer/Loader/Loader.tsx +43 -0
  81. package/build/primer/Loader/__tests__/Loader.int.story.tsx +34 -0
  82. package/build/primer/Loader/__tests__/Loader.int.test.ts +21 -0
  83. package/build/primer/Loader/index.ts +2 -0
  84. package/build/primer/Navigation/Menu/Menu.prop.ts +26 -0
  85. package/build/primer/Navigation/Menu/Menu.tsx +42 -0
  86. package/build/primer/Navigation/Menu/__tests__/Menu.int.story.tsx +55 -0
  87. package/build/primer/Navigation/Menu/__tests__/Menu.int.test.ts +57 -0
  88. package/build/primer/Navigation/Menu/index.ts +1 -0
  89. package/build/primer/Navigation/TabNav/TabNav.prop.ts +39 -0
  90. package/build/primer/Navigation/TabNav/TabNav.tsx +105 -0
  91. package/build/primer/Navigation/TabNav/__tests__/TabNav.int.story.tsx +168 -0
  92. package/build/primer/Navigation/TabNav/__tests__/TabNav.int.test.ts +55 -0
  93. package/build/primer/Navigation/TabNav/index.ts +2 -0
  94. package/build/primer/Navigation/UnderlineNav/UnderlineNav.prop.ts +41 -0
  95. package/build/primer/Navigation/UnderlineNav/UnderlineNav.tsx +106 -0
  96. package/build/primer/Navigation/UnderlineNav/__tests__/UnderlineNav.int.story.tsx +140 -0
  97. package/build/primer/Navigation/UnderlineNav/__tests__/UnderlineNav.int.test.ts +81 -0
  98. package/build/primer/Navigation/UnderlineNav/index.ts +2 -0
  99. package/build/primer/Navigation/index.ts +12 -0
  100. package/build/primer/Pagination/PreviousNext/PreviousNext.prop.ts +53 -0
  101. package/build/primer/Pagination/PreviousNext/PreviousNext.tsx +71 -0
  102. package/build/primer/Pagination/PreviousNext/__tests__/PreviousNext.int.story.tsx +48 -0
  103. package/build/primer/Pagination/PreviousNext/__tests__/PreviousNext.int.test.ts +15 -0
  104. package/build/primer/Pagination/PreviousNext/index.ts +2 -0
  105. package/build/primer/Pagination/index.ts +6 -0
  106. package/build/primer/Popover/Popover.mdx +190 -0
  107. package/build/primer/Popover/Popover.prop.ts +49 -0
  108. package/build/primer/Popover/Popover.tsx +80 -0
  109. package/build/primer/Popover/__tests__/Popover.int.story.tsx +216 -0
  110. package/build/primer/Popover/__tests__/Popover.int.test.ts +71 -0
  111. package/build/primer/Popover/index.ts +2 -0
  112. package/build/primer/Progress/Progress.mdx +31 -0
  113. package/build/primer/Progress/Progress.prop.ts +16 -0
  114. package/build/primer/Progress/Progress.tsx +19 -0
  115. package/build/primer/Progress/__tests__/Progress.int.story.tsx +28 -0
  116. package/build/primer/Progress/__tests__/Progress.int.test.ts +17 -0
  117. package/build/primer/Progress/index.ts +2 -0
  118. package/build/primer/Select/Select.mdx +19 -0
  119. package/build/primer/Select/Select.prop.ts +24 -0
  120. package/build/primer/Select/Select.tsx +58 -0
  121. package/build/primer/Select/__tests__/Select.int.story.tsx +38 -0
  122. package/build/primer/Select/__tests__/Select.int.test.ts +42 -0
  123. package/build/primer/Select/index.ts +2 -0
  124. package/build/primer/SelectMenu/SelectMenu.mdx +13 -0
  125. package/build/primer/SelectMenu/SelectMenu.prop.ts +25 -0
  126. package/build/primer/SelectMenu/SelectMenu.tsx +68 -0
  127. package/build/primer/SelectMenu/__tests__/SelectMenu.int.story.tsx +50 -0
  128. package/build/primer/SelectMenu/__tests__/SelectMenu.int.test.ts +56 -0
  129. package/build/primer/SelectMenu/index.ts +1 -0
  130. package/build/primer/Subhead/Subhead.mdx +20 -0
  131. package/build/primer/Subhead/Subhead.prop.ts +10 -0
  132. package/build/primer/Subhead/Subhead.tsx +15 -0
  133. package/build/primer/Subhead/__tests__/Subhead.int.story.tsx +23 -0
  134. package/build/primer/Subhead/__tests__/Subhead.int.test.ts +13 -0
  135. package/build/primer/Subhead/index.ts +1 -0
  136. package/build/primer/Toast/Toast.prop.ts +21 -0
  137. package/build/primer/Toast/Toast.tsx +38 -0
  138. package/build/primer/Toast/__tests__/Toast.int.story.tsx +50 -0
  139. package/build/primer/Toast/__tests__/Toast.int.test.ts +25 -0
  140. package/build/primer/Toast/index.ts +2 -0
  141. package/build/primer/index.ts +83 -0
  142. package/package.json +4 -4
  143. package/build/index.js +0 -12
  144. package/build/primer/Alert/Alert.js +0 -121
  145. package/build/primer/Alert/Alert.prop.js +0 -38
  146. package/build/primer/Alert/index.js +0 -19
  147. package/build/primer/Blankslate/Blankslate.js +0 -31
  148. package/build/primer/Blankslate/Blankslate.prop.js +0 -26
  149. package/build/primer/Blankslate/index.js +0 -19
  150. package/build/primer/Breadcrumb/Breadcrumb.js +0 -74
  151. package/build/primer/Breadcrumb/Breadcrumb.prop.js +0 -29
  152. package/build/primer/Breadcrumb/index.js +0 -19
  153. package/build/primer/Button/Button.js +0 -99
  154. package/build/primer/Button/Button.prop.js +0 -67
  155. package/build/primer/Button/index.js +0 -49
  156. package/build/primer/Dropdown/Dropdown.js +0 -104
  157. package/build/primer/Dropdown/Dropdown.prop.js +0 -34
  158. package/build/primer/Dropdown/index.js +0 -19
  159. package/build/primer/ErrorBoundary/ErrorBoundary.js +0 -59
  160. package/build/primer/ErrorBoundary/ErrorBoundary.prop.js +0 -11
  161. package/build/primer/ErrorBoundary/index.js +0 -12
  162. package/build/primer/Form/Checkbox/Checkbox.js +0 -49
  163. package/build/primer/Form/Checkbox/Checkbox.prop.js +0 -36
  164. package/build/primer/Form/Checkbox/index.js +0 -19
  165. package/build/primer/Form/Input/Input.js +0 -56
  166. package/build/primer/Form/Input/Input.prop.js +0 -43
  167. package/build/primer/Form/Input/index.js +0 -25
  168. package/build/primer/Form/Radio/Radio.js +0 -48
  169. package/build/primer/Form/Radio/Radio.prop.js +0 -34
  170. package/build/primer/Form/Radio/index.js +0 -19
  171. package/build/primer/Form/index.js +0 -24
  172. package/build/primer/Grid/DisplayTable/DisplayTable.js +0 -58
  173. package/build/primer/Grid/DisplayTable/DisplayTable.prop.js +0 -18
  174. package/build/primer/Grid/DisplayTable/index.js +0 -12
  175. package/build/primer/Grid/FlexGrid/FlexGrid.js +0 -244
  176. package/build/primer/Grid/FlexGrid/FlexGrid.prop.js +0 -49
  177. package/build/primer/Grid/FlexGrid/index.js +0 -25
  178. package/build/primer/Grid/index.js +0 -14
  179. package/build/primer/Icon/Icon.js +0 -70
  180. package/build/primer/Icon/Icon.part.js +0 -1295
  181. package/build/primer/Icon/Icon.prop.js +0 -689
  182. package/build/primer/Icon/index.js +0 -25
  183. package/build/primer/Label/Label.js +0 -31
  184. package/build/primer/Label/Label.prop.js +0 -34
  185. package/build/primer/Label/index.js +0 -12
  186. package/build/primer/Loader/Loader.js +0 -65
  187. package/build/primer/Loader/Loader.prop.js +0 -21
  188. package/build/primer/Loader/index.js +0 -19
  189. package/build/primer/Navigation/Menu/Menu.js +0 -70
  190. package/build/primer/Navigation/Menu/Menu.prop.js +0 -28
  191. package/build/primer/Navigation/Menu/index.js +0 -12
  192. package/build/primer/Navigation/TabNav/TabNav.js +0 -125
  193. package/build/primer/Navigation/TabNav/TabNav.prop.js +0 -36
  194. package/build/primer/Navigation/TabNav/index.js +0 -19
  195. package/build/primer/Navigation/UnderlineNav/UnderlineNav.js +0 -121
  196. package/build/primer/Navigation/UnderlineNav/UnderlineNav.prop.js +0 -41
  197. package/build/primer/Navigation/UnderlineNav/index.js +0 -25
  198. package/build/primer/Navigation/index.js +0 -17
  199. package/build/primer/Pagination/PreviousNext/PreviousNext.js +0 -76
  200. package/build/primer/Pagination/PreviousNext/PreviousNext.prop.js +0 -56
  201. package/build/primer/Pagination/PreviousNext/index.js +0 -19
  202. package/build/primer/Pagination/index.js +0 -11
  203. package/build/primer/Popover/Popover.js +0 -63
  204. package/build/primer/Popover/Popover.prop.js +0 -41
  205. package/build/primer/Popover/index.js +0 -25
  206. package/build/primer/Progress/Progress.js +0 -31
  207. package/build/primer/Progress/Progress.prop.js +0 -21
  208. package/build/primer/Progress/index.js +0 -19
  209. package/build/primer/Select/Select.js +0 -66
  210. package/build/primer/Select/Select.prop.js +0 -27
  211. package/build/primer/Select/index.js +0 -19
  212. package/build/primer/SelectMenu/SelectMenu.js +0 -95
  213. package/build/primer/SelectMenu/SelectMenu.prop.js +0 -26
  214. package/build/primer/SelectMenu/index.js +0 -12
  215. package/build/primer/Subhead/Subhead.js +0 -27
  216. package/build/primer/Subhead/Subhead.prop.js +0 -16
  217. package/build/primer/Subhead/index.js +0 -12
  218. package/build/primer/Toast/Toast.js +0 -55
  219. package/build/primer/Toast/Toast.prop.js +0 -26
  220. package/build/primer/Toast/index.js +0 -19
  221. package/build/primer/index.js +0 -87
  222. /package/build/primer/Form/Checkbox/{Checkbox.md → Checkbox.mdx} +0 -0
  223. /package/build/primer/Form/Checkbox/__tests__/__snapshots__/{Checkbox.int.test.js.snap → Checkbox.int.test.ts.snap} +0 -0
  224. /package/build/primer/Form/Input/{Input.md → Input.mdx} +0 -0
  225. /package/build/primer/Form/Input/__tests__/__snapshots__/{Input.int.test.js.snap → Input.int.test.ts.snap} +0 -0
  226. /package/build/primer/Form/Radio/{Radio.md → Radio.mdx} +0 -0
  227. /package/build/primer/Form/Radio/__tests__/__snapshots__/{Radio.int.test.js.snap → Radio.int.test.ts.snap} +0 -0
  228. /package/build/primer/Grid/DisplayTable/{DisplayTable.md → DisplayTable.mdx} +0 -0
  229. /package/build/primer/Grid/DisplayTable/__tests__/__snapshots__/{DisplayTable.int.test.js.snap → DisplayTable.int.test.ts.snap} +0 -0
  230. /package/build/primer/Grid/FlexGrid/{FlexGrid.md → FlexGrid.mdx} +0 -0
  231. /package/build/primer/Grid/FlexGrid/__tests__/__snapshots__/{FlexGrid.int.test.js.snap → FlexGrid.int.test.ts.snap} +0 -0
  232. /package/build/primer/Navigation/Menu/{Menu.md → Menu.mdx} +0 -0
  233. /package/build/primer/Navigation/Menu/__tests__/__snapshots__/{Menu.int.test.js.snap → Menu.int.test.ts.snap} +0 -0
  234. /package/build/primer/Navigation/TabNav/{TabNav.md → TabNav.mdx} +0 -0
  235. /package/build/primer/Navigation/TabNav/__tests__/__snapshots__/{TabNav.int.test.js.snap → TabNav.int.test.ts.snap} +0 -0
  236. /package/build/primer/Navigation/UnderlineNav/{UnderlineNav.md → UnderlineNav.mdx} +0 -0
  237. /package/build/primer/Navigation/UnderlineNav/__tests__/__snapshots__/{UnderlineNav.int.test.js.snap → UnderlineNav.int.test.ts.snap} +0 -0
  238. /package/build/primer/Pagination/PreviousNext/{PreviousNext.md → PreviousNext.mdx} +0 -0
  239. /package/build/primer/Pagination/PreviousNext/__tests__/__snapshots__/{PreviousNext.int.test.js.snap → PreviousNext.int.test.ts.snap} +0 -0
@@ -0,0 +1,43 @@
1
+ export const inputState = {
2
+ active: 'active',
3
+ inactive: 'inactive',
4
+ }
5
+
6
+ export const inputType = {
7
+ text: 'text',
8
+ password: 'password',
9
+ }
10
+
11
+ export const defaultProps = {
12
+ dataTest: null,
13
+ id: null,
14
+ className: null,
15
+ placeholder: null,
16
+ ariaAttr: {
17
+ label: '',
18
+ },
19
+ inputType: inputType.text,
20
+ onFocus: () => {},
21
+ onBlur: () => {},
22
+ state: inputState.active,
23
+ }
24
+
25
+ export interface AriaAttrType {
26
+ label: string
27
+ }
28
+
29
+ export interface InputProps {
30
+ dataTest?: string
31
+ id?: string
32
+ className?: string
33
+ placeholder?: string
34
+ ariaAttr?: AriaAttrType
35
+ inputType?: typeof inputType.text | typeof inputType.password
36
+ value: string
37
+ onChange: (value) => void
38
+ onKeyUp: (value) => void
39
+ onFocus?: (value) => void
40
+ onBlur?: (value) => void
41
+ autoFocus: boolean
42
+ state?: typeof inputState.active | typeof inputState.inactive
43
+ }
@@ -0,0 +1,43 @@
1
+ import cx from 'classnames'
2
+ import { InputProps, defaultProps, inputState } from './Input.prop'
3
+ import styles from './Input.scss'
4
+ import formStyles from '../index.scss'
5
+
6
+ export function Input({
7
+ dataTest = defaultProps.dataTest,
8
+ id = defaultProps.id,
9
+ className = defaultProps.className,
10
+ placeholder = defaultProps.placeholder,
11
+ ariaAttr = defaultProps.ariaAttr,
12
+ inputType = defaultProps.inputType,
13
+ value,
14
+ onChange,
15
+ onKeyUp,
16
+ onFocus = defaultProps.onFocus,
17
+ onBlur = defaultProps.onBlur,
18
+ autoFocus,
19
+ state = defaultProps.state,
20
+ }: InputProps) {
21
+ return (
22
+ <input
23
+ data-test={dataTest}
24
+ id={id}
25
+ className={cx(className, formStyles['form-control'], {
26
+ [styles['input-inactive']]: state === inputState.inactive,
27
+ })}
28
+ value={value}
29
+ onChange={(event) => {
30
+ onChange(event)
31
+ }}
32
+ onKeyUp={(event) => {
33
+ onKeyUp(event)
34
+ }}
35
+ onFocus={onFocus}
36
+ onBlur={onBlur}
37
+ type={inputType}
38
+ placeholder={placeholder}
39
+ aria-label={ariaAttr.label}
40
+ autoFocus={autoFocus} // eslint-disable-line
41
+ />
42
+ )
43
+ }
@@ -0,0 +1,54 @@
1
+ import { action } from 'storybook/actions'
2
+ import { withTests } from '@storybook/addon-jest'
3
+ import { inputState } from '../Input.prop'
4
+ import results from '../../../../../../../.jest-test-results.json'
5
+
6
+ const Input =
7
+ process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
8
+ ? require('../../../../index').primer.Form.Input.Input
9
+ : require('../../../../../build').primer.Form.Input.Input
10
+
11
+ export default {
12
+ title: 'Primer/Atom/Form/Input',
13
+ component: Input,
14
+ decorators: [withTests({ results })],
15
+ parameters: { jest: ['Input.int.test.js'] },
16
+ excludeStories: ['placeholder', 'ariaAttr', 'custom'],
17
+ }
18
+
19
+ const placeholder = 'Fantastic placeholder'
20
+
21
+ const ariaAttr = {
22
+ label: 'Repository description',
23
+ }
24
+
25
+ export function custom(onChange, onKeyUp, onFocus, onBlur) {
26
+ return <Input placeholder={placeholder} ariaAttr={ariaAttr} onChange={onChange} onKeyUp={onKeyUp} onFocus={onFocus} onBlur={onBlur} />
27
+ }
28
+
29
+ export function regular() {
30
+ return (
31
+ <Input
32
+ placeholder={placeholder}
33
+ ariaAttr={ariaAttr}
34
+ onChange={action('onChange')}
35
+ onKeyUp={action('onKeyUp')}
36
+ onFocus={action('onFocus')}
37
+ onBlur={action('onBlur')}
38
+ />
39
+ )
40
+ }
41
+
42
+ export function inactive() {
43
+ return (
44
+ <Input
45
+ placeholder={placeholder}
46
+ ariaAttr={ariaAttr}
47
+ onChange={action('onChange')}
48
+ onKeyUp={action('onKeyUp')}
49
+ onFocus={action('onFocus')}
50
+ onBlur={action('onBlur')}
51
+ state={inputState.inactive}
52
+ />
53
+ )
54
+ }
@@ -0,0 +1,15 @@
1
+ import { regular, inactive } from './Input.int.story'
2
+
3
+ describe('<Input />', () => {
4
+ afterEach(() => jest.clearAllMocks())
5
+
6
+ describe('Render', () => {
7
+ test('must match regular()', () => {
8
+ expect(global.renderToJSON(regular())).toMatchSnapshot()
9
+ })
10
+
11
+ test('must match inactive()', () => {
12
+ expect(global.renderToJSON(inactive())).toMatchSnapshot()
13
+ })
14
+ })
15
+ })
@@ -0,0 +1,2 @@
1
+ export { Input } from './Input'
2
+ export { inputType, inputState } from './Input.prop'
@@ -0,0 +1,30 @@
1
+ export const radioState = {
2
+ active: 'active',
3
+ inactive: 'inactive',
4
+ }
5
+
6
+ export const inputType = {
7
+ radio: 'radio',
8
+ }
9
+
10
+ export const defaultProps = {
11
+ dataTest: null,
12
+ className: null,
13
+ htmlFor: 'checkbox',
14
+ inputType: inputType.radio,
15
+ isChecked: false,
16
+ text: null,
17
+ state: radioState.active,
18
+ }
19
+
20
+ export interface RadioProps {
21
+ dataTest?: string
22
+ className?: string
23
+ htmlFor?: string
24
+ inputType?: typeof inputType.radio
25
+ name: string
26
+ isChecked?: boolean
27
+ text?: string
28
+ onChange: (value) => void
29
+ state?: typeof radioState.active | typeof radioState.inactive
30
+ }
@@ -0,0 +1,38 @@
1
+ import cx from 'classnames'
2
+ import marginStyles from '@papillonarts/css/build/primer/utilities/margin.scss'
3
+ import { RadioProps, defaultProps, radioState } from './Radio.prop'
4
+ import styles from './Radio.scss'
5
+ import formStyles from '../index.scss'
6
+
7
+ export function Radio({
8
+ dataTest = defaultProps.dataTest,
9
+ className = defaultProps.className,
10
+ htmlFor = defaultProps.htmlFor,
11
+ inputType = defaultProps.inputType,
12
+ name,
13
+ isChecked = defaultProps.isChecked,
14
+ text = defaultProps.text,
15
+ onChange,
16
+ state = defaultProps.state,
17
+ }: RadioProps) {
18
+ return (
19
+ <div
20
+ data-test={dataTest}
21
+ className={cx(className, marginStyles['m-0'], formStyles['form-checkbox'], {
22
+ [styles['radio-inactive']]: state === radioState.inactive,
23
+ })}
24
+ >
25
+ <label htmlFor={htmlFor}>
26
+ <input
27
+ type={inputType}
28
+ name={name}
29
+ onChange={(event) => {
30
+ onChange(event)
31
+ }}
32
+ checked={isChecked}
33
+ />
34
+ {text}
35
+ </label>
36
+ </div>
37
+ )
38
+ }
@@ -0,0 +1,42 @@
1
+ import { Fragment } from 'react'
2
+ import { action } from 'storybook/actions'
3
+ import { withTests } from '@storybook/addon-jest'
4
+ import { radioState } from '../Radio.prop'
5
+ import results from '../../../../../../../.jest-test-results.json'
6
+
7
+ const Radio =
8
+ process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
9
+ ? require('../../../../index').primer.Form.Radio.Radio
10
+ : require('../../../../../build').primer.Form.Radio.Radio
11
+
12
+ export default {
13
+ title: 'Primer/Atom/Form/Radio',
14
+ component: Radio,
15
+ decorators: [withTests({ results })],
16
+ parameters: { jest: ['Radio.int.test.js'] },
17
+ excludeStories: ['name', 'custom'],
18
+ }
19
+
20
+ const name = 'fantastic-name'
21
+
22
+ export function custom(onChange) {
23
+ return <Radio name={name} onChange={onChange} text="White" />
24
+ }
25
+
26
+ export function regular() {
27
+ return (
28
+ <Fragment>
29
+ <Radio name={name} onChange={action('onChange-white')} text="White" />
30
+ <Radio name={name} isChecked={true} onChange={action('onChange-black')} text="Black" />
31
+ </Fragment>
32
+ )
33
+ }
34
+
35
+ export function inactive() {
36
+ return (
37
+ <Fragment>
38
+ <Radio name={name} onChange={action('onChange-white')} text="White" state={radioState.inactive} />
39
+ <Radio name={name} isChecked={true} onChange={action('onChange-black')} text="Black" state={radioState.inactive} />
40
+ </Fragment>
41
+ )
42
+ }
@@ -0,0 +1,13 @@
1
+ import { regular, inactive } from './Radio.int.story'
2
+
3
+ describe('<Radio />', () => {
4
+ describe('Render', () => {
5
+ test('must match regular()', () => {
6
+ expect(global.renderToJSON(regular())).toMatchSnapshot()
7
+ })
8
+
9
+ test('must match inactive()', () => {
10
+ expect(global.renderToJSON(inactive())).toMatchSnapshot()
11
+ })
12
+ })
13
+ })
@@ -0,0 +1,2 @@
1
+ export { Radio } from './Radio'
2
+ export { radioState } from './Radio.prop'
@@ -0,0 +1,19 @@
1
+ import { Checkbox, checkboxState } from './Checkbox'
2
+ import { Input, inputType, inputState } from './Input'
3
+ import { Radio, radioState } from './Radio'
4
+
5
+ export const Form = {
6
+ Checkbox: {
7
+ Checkbox,
8
+ checkboxState,
9
+ },
10
+ Input: {
11
+ Input,
12
+ inputType,
13
+ inputState,
14
+ },
15
+ Radio: {
16
+ Radio,
17
+ radioState,
18
+ },
19
+ }
@@ -0,0 +1,21 @@
1
+ export const defaultProps = {
2
+ className: null,
3
+ idIndex: -1,
4
+ isSelectedIndex: -1,
5
+ }
6
+
7
+ export interface ValueType {
8
+ value: React.ReactNode
9
+ }
10
+
11
+ export interface ItemType {
12
+ names: React.ReactNode[]
13
+ values: ValueType[] | React.ReactNode[]
14
+ }
15
+
16
+ export interface DisplayTableProps {
17
+ className: string
18
+ items: ItemType[]
19
+ idIndex: number
20
+ isSelectedIndex: number
21
+ }
@@ -0,0 +1,68 @@
1
+ import { Fragment } from 'react'
2
+ import cx from 'classnames'
3
+ import { v1 as uuidv1 } from 'uuid'
4
+ import displayStyles from '@papillonarts/css/build/primer/utilities/visibility-display.scss'
5
+ import borderStyles from '@papillonarts/css/build/primer/utilities/borders.scss'
6
+ import paddingStyles from '@papillonarts/css/build/primer/utilities/padding.scss'
7
+ import typographyStyles from '@papillonarts/css/build/primer/utilities/typography.scss'
8
+ import colorStyles from '@papillonarts/css/build/primer/utilities/colors.scss'
9
+ import gridStyles from '../../Layout/grid.scss'
10
+ import { DisplayTableProps, defaultProps } from './DisplayTable.prop'
11
+
12
+ export function DisplayTable({
13
+ className = defaultProps.className,
14
+ items,
15
+ idIndex = defaultProps.idIndex,
16
+ isSelectedIndex = defaultProps.isSelectedIndex,
17
+ }: DisplayTableProps) {
18
+ return (
19
+ <Fragment>
20
+ <div className={cx(className, displayStyles['d-table'], gridStyles['col-12'], colorStyles['bg-blue-light'])}>
21
+ {items[0].names.map((name, index) => {
22
+ const isIdColumn = index === idIndex
23
+ const isSelectedColumn = index === isSelectedIndex
24
+
25
+ return (
26
+ <Fragment key={uuidv1()}>
27
+ {!isIdColumn && (
28
+ <div
29
+ key={uuidv1()}
30
+ className={cx(
31
+ gridStyles['col-2'],
32
+ displayStyles['d-table-cell'],
33
+ borderStyles.border,
34
+ paddingStyles['p-2'],
35
+ typographyStyles.h6,
36
+ )}
37
+ >
38
+ {isSelectedColumn ? '' : name}
39
+ </div>
40
+ )}
41
+ </Fragment>
42
+ )
43
+ })}
44
+ </div>
45
+ {items.map((item) => (
46
+ <div key={uuidv1()} className={cx(className, displayStyles['d-table'], gridStyles['col-12'])}>
47
+ {item.values.map((value, valueIndex) => {
48
+ const isIdColumn = valueIndex === idIndex
49
+ const isSelectedColumn = valueIndex === isSelectedIndex
50
+
51
+ return (
52
+ <Fragment key={uuidv1()}>
53
+ {!isIdColumn && (
54
+ <div
55
+ key={uuidv1()}
56
+ className={cx(gridStyles['col-2'], displayStyles['d-table-cell'], borderStyles.border, paddingStyles['p-2'])}
57
+ >
58
+ {isSelectedColumn ? '' : (value?.value ?? value)}
59
+ </div>
60
+ )}
61
+ </Fragment>
62
+ )
63
+ })}
64
+ </div>
65
+ ))}
66
+ </Fragment>
67
+ )
68
+ }
@@ -0,0 +1,289 @@
1
+ export const filesObjects = [
2
+ {
3
+ contents: null,
4
+ 'date-created': 'Wed May 13 2015',
5
+ 'date-modified': 'Fri Feb 03 2017',
6
+ id: 'file-169a4ad0-ceaa-4a3b-9ee8-056f96c44953',
7
+ isSelected: false,
8
+ kind: 'PostScript file',
9
+ name: {
10
+ icon: 'File',
11
+ value: 'y8P.ps',
12
+ },
13
+ path: [
14
+ {
15
+ href: 'Files',
16
+ isSelected: true,
17
+ text: 'Files',
18
+ },
19
+ {
20
+ href: 'file-169a4ad0-ceaa-4a3b-9ee8-056f96c44953',
21
+ isSelected: false,
22
+ text: 'y8P.ps',
23
+ },
24
+ ],
25
+ size: '37.72 exabyte (EB)',
26
+ },
27
+ {
28
+ contents: null,
29
+ 'date-created': 'Fri May 01 2020',
30
+ 'date-modified': 'Mon Dec 31 2018',
31
+ id: 'file-26ea87eb-26e8-4f05-aec2-4c686ff7e2ec',
32
+ isSelected: false,
33
+ kind: 'Perl script file',
34
+ name: {
35
+ icon: 'File',
36
+ value: 'Pj9m.cgi',
37
+ },
38
+ path: [
39
+ {
40
+ href: 'Files',
41
+ isSelected: true,
42
+ text: 'Files',
43
+ },
44
+ {
45
+ href: 'file-26ea87eb-26e8-4f05-aec2-4c686ff7e2ec',
46
+ isSelected: false,
47
+ text: 'Pj9m.cgi',
48
+ },
49
+ ],
50
+ size: '339 gigabyte (GB)',
51
+ },
52
+ {
53
+ contents: null,
54
+ 'date-created': 'Mon Oct 31 2016',
55
+ 'date-modified': 'Tue Feb 21 2017',
56
+ id: 'file-bd9da022-f0c1-47ad-b4c4-c2f7176c4535',
57
+ isSelected: false,
58
+ kind: 'PSD image',
59
+ name: {
60
+ icon: 'File',
61
+ value: 'mRGfhp.psd',
62
+ },
63
+ path: [
64
+ {
65
+ href: 'Files',
66
+ isSelected: true,
67
+ text: 'Files',
68
+ },
69
+ {
70
+ href: 'file-bd9da022-f0c1-47ad-b4c4-c2f7176c4535',
71
+ isSelected: false,
72
+ text: 'mRGfhp.psd',
73
+ },
74
+ ],
75
+ size: '325.6 kilobyte (KB)',
76
+ },
77
+ {
78
+ contents: null,
79
+ 'date-created': 'Wed Mar 11 2020',
80
+ 'date-modified': 'Sun Aug 26 2018',
81
+ id: 'file-75c01598-a68d-43c5-bbe6-2d76678466ba',
82
+ isSelected: false,
83
+ kind: 'Active Server Page file',
84
+ name: {
85
+ icon: 'File',
86
+ value: 'FBrXhyh736LIV.aspx',
87
+ },
88
+ path: [
89
+ {
90
+ href: 'Files',
91
+ isSelected: true,
92
+ text: 'Files',
93
+ },
94
+ {
95
+ href: 'file-75c01598-a68d-43c5-bbe6-2d76678466ba',
96
+ isSelected: false,
97
+ text: 'FBrXhyh736LIV.aspx',
98
+ },
99
+ ],
100
+ size: '716 terabyte (TB)',
101
+ },
102
+ {
103
+ contents: [
104
+ {
105
+ contents: null,
106
+ 'date-created': 'Sun May 18 2014',
107
+ 'date-modified': 'Tue Feb 25 2020',
108
+ id: 'file-ad02e6c0-24aa-47cd-b65f-c3127dc01259',
109
+ isSelected: false,
110
+ kind: 'PostScript file',
111
+ name: {
112
+ icon: 'File',
113
+ value: 'OJNhlbZ8WMjuly.ps',
114
+ },
115
+ path: [
116
+ {
117
+ href: 'Files',
118
+ isSelected: true,
119
+ text: 'Files',
120
+ },
121
+ {
122
+ href: 'directory-56a0c7dc-dc95-4fd8-b079-256708e84e46',
123
+ isSelected: false,
124
+ text: 'beylpO7v',
125
+ },
126
+ {
127
+ href: 'file-ad02e6c0-24aa-47cd-b65f-c3127dc01259',
128
+ isSelected: false,
129
+ text: 'OJNhlbZ8WMjuly.ps',
130
+ },
131
+ ],
132
+ size: '580.5 exabyte (EB)',
133
+ },
134
+ ],
135
+ 'date-created': 'Fri Mar 21 2014',
136
+ 'date-modified': 'Wed Mar 04 2015',
137
+ id: 'directory-56a0c7dc-dc95-4fd8-b079-256708e84e46',
138
+ isSelected: false,
139
+ kind: 'Folder',
140
+ name: {
141
+ icon: 'FileDirectory',
142
+ value: 'beylpO7v',
143
+ },
144
+ path: [
145
+ {
146
+ href: 'Files',
147
+ isSelected: true,
148
+ text: 'Files',
149
+ },
150
+ {
151
+ href: 'directory-56a0c7dc-dc95-4fd8-b079-256708e84e46',
152
+ isSelected: false,
153
+ text: 'beylpO7v',
154
+ },
155
+ ],
156
+ size: '--',
157
+ },
158
+ {
159
+ contents: null,
160
+ 'date-created': 'Sun Oct 20 2019',
161
+ 'date-modified': 'Fri Feb 08 2019',
162
+ id: 'file-3be9cb1a-8744-438b-9506-99ef88a7480a',
163
+ isSelected: false,
164
+ kind: 'Database file',
165
+ name: {
166
+ icon: 'File',
167
+ value: 'aD9iiQhkj.db',
168
+ },
169
+ path: [
170
+ {
171
+ href: 'Files',
172
+ isSelected: true,
173
+ text: 'Files',
174
+ },
175
+ {
176
+ href: 'file-3be9cb1a-8744-438b-9506-99ef88a7480a',
177
+ isSelected: false,
178
+ text: 'aD9iiQhkj.db',
179
+ },
180
+ ],
181
+ size: '913.5 bit (b)',
182
+ },
183
+ {
184
+ contents: null,
185
+ 'date-created': 'Fri Mar 11 2016',
186
+ 'date-modified': 'Thu May 02 2019',
187
+ id: 'file-bbe22783-ec56-4ea3-8edb-a9e4cee48d9e',
188
+ isSelected: false,
189
+ kind: 'Apple Mail e-mail file',
190
+ name: {
191
+ icon: 'File',
192
+ value: '9kcUYOj65.emlx',
193
+ },
194
+ path: [
195
+ {
196
+ href: 'Files',
197
+ isSelected: true,
198
+ text: 'Files',
199
+ },
200
+ {
201
+ href: 'file-bbe22783-ec56-4ea3-8edb-a9e4cee48d9e',
202
+ isSelected: false,
203
+ text: '9kcUYOj65.emlx',
204
+ },
205
+ ],
206
+ size: '921.8 zettabyte (ZB)',
207
+ },
208
+ {
209
+ contents: [
210
+ {
211
+ contents: null,
212
+ 'date-created': 'Sat May 07 2016',
213
+ 'date-modified': 'Fri Sep 05 2014',
214
+ id: 'file-b4dddd05-fc2d-4fbe-b3f0-a69a6cab321c',
215
+ isSelected: false,
216
+ kind: 'Internet security certificate',
217
+ name: {
218
+ icon: 'File',
219
+ value: 'DTmnIjnVyaK.cer',
220
+ },
221
+ path: [
222
+ {
223
+ href: 'Files',
224
+ isSelected: true,
225
+ text: 'Files',
226
+ },
227
+ {
228
+ href: 'directory-8e2504aa-f428-441e-be2c-83c4a9c3219a',
229
+ isSelected: false,
230
+ text: '7',
231
+ },
232
+ {
233
+ href: 'file-b4dddd05-fc2d-4fbe-b3f0-a69a6cab321c',
234
+ isSelected: false,
235
+ text: 'DTmnIjnVyaK.cer',
236
+ },
237
+ ],
238
+ size: '760 terabyte (TB)',
239
+ },
240
+ ],
241
+ 'date-created': 'Sun Oct 25 2015',
242
+ 'date-modified': 'Thu Apr 11 2019',
243
+ id: 'directory-8e2504aa-f428-441e-be2c-83c4a9c3219a',
244
+ isSelected: false,
245
+ kind: 'Folder',
246
+ name: {
247
+ icon: 'FileDirectory',
248
+ value: '7',
249
+ },
250
+ path: [
251
+ {
252
+ href: 'Files',
253
+ isSelected: true,
254
+ text: 'Files',
255
+ },
256
+ {
257
+ href: 'directory-8e2504aa-f428-441e-be2c-83c4a9c3219a',
258
+ isSelected: false,
259
+ text: '7',
260
+ },
261
+ ],
262
+ size: '--',
263
+ },
264
+ {
265
+ contents: null,
266
+ 'date-created': 'Tue Jan 20 2015',
267
+ 'date-modified': 'Tue Oct 15 2013',
268
+ id: 'file-16db577b-1167-4add-bb79-9eab8c9b9217',
269
+ isSelected: false,
270
+ kind: 'Microsoft Excel file with macros',
271
+ name: {
272
+ icon: 'File',
273
+ value: '1NplEr0hHjFnTmW.xlsm',
274
+ },
275
+ path: [
276
+ {
277
+ href: 'Files',
278
+ isSelected: true,
279
+ text: 'Files',
280
+ },
281
+ {
282
+ href: 'file-16db577b-1167-4add-bb79-9eab8c9b9217',
283
+ isSelected: false,
284
+ text: '1NplEr0hHjFnTmW.xlsm',
285
+ },
286
+ ],
287
+ size: '474.53 petabyte (PB)',
288
+ },
289
+ ]