@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,27 @@
1
+ import { withTests } from '@storybook/addon-jest'
2
+ import { filesObjects } from './DisplayTable.int.data'
3
+ import results from '../../../../../../../.jest-test-results.json'
4
+
5
+ const DisplayTable =
6
+ process.env.NODE_ENV === 'develop' || process.env.NODE_ENV === 'test'
7
+ ? require('../../../../index').primer.Grid.DisplayTable
8
+ : require('../../../../../build').primer.Grid.DisplayTable
9
+
10
+ export default {
11
+ title: 'Primer/Atom/Grid/DisplayTable',
12
+ component: DisplayTable,
13
+ decorators: [withTests({ results })],
14
+ parameters: { jest: ['DisplayTable.int.test.js'] },
15
+ excludeStories: ['custom'],
16
+ }
17
+
18
+ export function regular() {
19
+ const items = filesObjects.map((filesObject) =>
20
+ (({ contents, path, id, isSelected, ...otherProperties }) => ({
21
+ names: Object.keys({ id, isSelected, ...otherProperties }),
22
+ values: Object.values({ id, isSelected, ...otherProperties }),
23
+ }))(filesObject),
24
+ )
25
+
26
+ return <DisplayTable items={items} idIndex={0} isSelectedIndex={1} />
27
+ }
@@ -0,0 +1,9 @@
1
+ import { regular } from './DisplayTable.int.story'
2
+
3
+ describe('<DisplayTable />', () => {
4
+ describe('Render', () => {
5
+ test('must match regular()', () => {
6
+ expect(global.renderToJSON(regular())).toMatchSnapshot()
7
+ })
8
+ })
9
+ })
@@ -0,0 +1 @@
1
+ export { DisplayTable } from './DisplayTable'
@@ -0,0 +1,59 @@
1
+ export const flexGridState = {
2
+ active: 'active',
3
+ inactive: 'inactive',
4
+ }
5
+
6
+ export const flexGridSelection = {
7
+ checkbox: 'checkbox',
8
+ radio: 'radio',
9
+ }
10
+
11
+ export const defaultProps = {
12
+ className: null,
13
+ idIndex: -1,
14
+ isSelectedIndex: -1,
15
+ selection: flexGridSelection.checkbox,
16
+ onChange: () => {},
17
+ onClick: () => {},
18
+ onDoubleClick: () => {},
19
+ iconColor: {
20
+ sort: '#990000',
21
+ object: '#79b8ff',
22
+ },
23
+ state: flexGridState.active,
24
+ }
25
+
26
+ export interface ValueType {
27
+ value: React.ReactNode
28
+ icon: React.ReactNode
29
+ }
30
+
31
+ export interface ItemType {
32
+ names: React.ReactNode[]
33
+ values: ValueType[] | React.ReactNode[]
34
+ }
35
+
36
+ export interface SortType {
37
+ index: number
38
+ value: string
39
+ order: string
40
+ }
41
+
42
+ export interface IconColorType {
43
+ sort: string
44
+ object: string
45
+ }
46
+
47
+ export interface FlexGridProps {
48
+ className?: string
49
+ items: ItemType[]
50
+ idIndex?: number
51
+ isSelectedIndex?: number
52
+ selection?: typeof flexGridSelection.checkbox | typeof flexGridSelection.radio
53
+ sort: SortType
54
+ onChange?: (value) => void
55
+ onClick?: (value) => void
56
+ onDoubleClick?: (value) => void
57
+ iconColor?: IconColorType
58
+ state?: typeof flexGridState.active | typeof flexGridState.inactive
59
+ }
@@ -0,0 +1,274 @@
1
+ import { Fragment } from 'react'
2
+ import cx from 'classnames'
3
+ import { v1 as uuidv1 } from 'uuid'
4
+ import { getCapizalizedString } from '@papillonarts/library/string'
5
+ import { sortOrder } from '@papillonarts/library/sort'
6
+ import displayStyles from '@papillonarts/css/build/primer/utilities/visibility-display.scss'
7
+ import flexboxStyles from '@papillonarts/css/build/primer/utilities/flexbox.scss'
8
+ import borderStyles from '@papillonarts/css/build/primer/utilities/borders.scss'
9
+ import paddingStyles from '@papillonarts/css/build/primer/utilities/padding.scss'
10
+ import marginStyles from '@papillonarts/css/build/primer/utilities/margin.scss'
11
+ import typographyStyles from '@papillonarts/css/build/primer/utilities/typography.scss'
12
+ import layoutStyles from '@papillonarts/css/build/primer/utilities/layout.scss'
13
+ import colorStyles from '@papillonarts/css/build/primer/utilities/colors.scss'
14
+ import truncateStyles from '@papillonarts/css/build/primer/truncate/index.scss'
15
+ import gridStyles from '../../Layout/grid.scss'
16
+ import { FlexGridProps, defaultProps, flexGridSelection, flexGridState } from './FlexGrid.prop'
17
+ import styles from './FlexGrid.scss'
18
+ import { Radio } from '../../Form/Radio'
19
+ import { Checkbox } from '../../Form/Checkbox'
20
+ import { Icon, iconName, iconSize } from '../../Icon'
21
+
22
+ export function FlexGrid({
23
+ className = defaultProps.className,
24
+ items,
25
+ idIndex = defaultProps.idIndex,
26
+ isSelectedIndex = defaultProps.isSelectedIndex,
27
+ selection = defaultProps.selection,
28
+ sort,
29
+ onChange = defaultProps.onChange,
30
+ onClick = defaultProps.onClick,
31
+ onDoubleClick = defaultProps.onDoubleClick,
32
+ iconColor = defaultProps.iconColor,
33
+ state = defaultProps.state,
34
+ }: FlexGridProps) {
35
+ return (
36
+ <div
37
+ className={cx(className, {
38
+ [styles['flexGrid-inactive']]: state === flexGridState.inactive,
39
+ })}
40
+ >
41
+ <div
42
+ className={cx(displayStyles['d-flex'], flexboxStyles['flex-row'], flexboxStyles['flex-items-start'], colorStyles['bg-blue-light'], {
43
+ [borderStyles.border]: items?.[0],
44
+ })}
45
+ >
46
+ {items?.[0]?.names?.map((name, nameIndex) => {
47
+ const isIdColumn = nameIndex === idIndex
48
+ const isSelectedColumn = nameIndex === isSelectedIndex
49
+ const isSelectedComponent =
50
+ selection === flexGridSelection.radio ? null : (
51
+ <Checkbox
52
+ ariaAttr={{ describedBy: name.toString() }}
53
+ isChecked={items.map((item) => item.values[1]).every((isSelected) => isSelected === true)}
54
+ onChange={(event) => {
55
+ const newItems = items
56
+ ?.map(({ values }) =>
57
+ values?.map((value, valueIndex) => (valueIndex === isSelectedIndex ? event.target.checked : value)),
58
+ )
59
+ .map((newItem) => ({
60
+ id: newItem[idIndex],
61
+ isSelected: newItem[isSelectedIndex],
62
+ }))
63
+ // @ts-ignore
64
+ onChange(newItems)
65
+ }}
66
+ />
67
+ )
68
+
69
+ let sortComponent
70
+
71
+ if (sort.index === nameIndex && sort.value === name) {
72
+ if (sort.order === sortOrder.ascending) {
73
+ sortComponent = <Icon icon={iconName.TriangleUp16} size={iconSize.small} fill={iconColor.sort} />
74
+ } else {
75
+ sortComponent = <Icon icon={iconName.TriangleDown16} size={iconSize.small} fill={iconColor.sort} />
76
+ }
77
+ }
78
+
79
+ return (
80
+ <Fragment key={uuidv1()}>
81
+ {!isIdColumn && (
82
+ <div
83
+ className={cx(
84
+ typographyStyles.h6,
85
+ displayStyles['d-flex'],
86
+ flexboxStyles['flex-row'],
87
+ paddingStyles['p-2'],
88
+ truncateStyles['css-truncate'],
89
+ truncateStyles['css-truncate-overflow'],
90
+ styles.item,
91
+ {
92
+ [gridStyles['col-2']]: isSelectedColumn,
93
+ [gridStyles['col-12']]: !isSelectedColumn,
94
+ [flexboxStyles['flex-justify-center']]: isSelectedColumn,
95
+ [flexboxStyles['flex-justify-between']]: !isSelectedColumn,
96
+ },
97
+ )}
98
+ onClick={() => {
99
+ if (!isSelectedColumn) {
100
+ // @ts-ignore
101
+ onClick({
102
+ index: nameIndex,
103
+ value: name,
104
+ order: sort.order,
105
+ })
106
+ }
107
+ }}
108
+ onKeyPress={() => {}}
109
+ role="button"
110
+ tabIndex={0}
111
+ >
112
+ {isSelectedColumn ? (
113
+ isSelectedComponent
114
+ ) : (
115
+ <div className={cx(displayStyles['d-flex'], flexboxStyles['flex-justify-between'], layoutStyles['width-full'])}>
116
+ <div className={cx(truncateStyles['css-truncate'], truncateStyles['css-truncate-overflow'])}>
117
+ {getCapizalizedString({ string: name })}
118
+ </div>
119
+ <div className={cx(displayStyles['d-flex'], flexboxStyles['flex-items-start'], marginStyles['ml-1'])}>
120
+ {sortComponent}
121
+ {nameIndex < items?.[0]?.names.length - 1 ? ( // eslint-disable-line no-unsafe-optional-chaining
122
+ <span className={cx(marginStyles['ml-1'], colorStyles['text-gray-light'])}> |</span>
123
+ ) : null}
124
+ </div>
125
+ </div>
126
+ )}
127
+ </div>
128
+ )}
129
+ </Fragment>
130
+ )
131
+ })}
132
+ </div>
133
+ {items?.map((item, itemIndex) => (
134
+ <div
135
+ key={uuidv1()}
136
+ className={cx(
137
+ displayStyles['d-flex'],
138
+ flexboxStyles['flex-row'],
139
+ flexboxStyles['flex-items-start'],
140
+ borderStyles.border,
141
+ styles.item,
142
+ styles.row,
143
+ )}
144
+ onClick={() => {
145
+ let bubleUpNewItems = true
146
+
147
+ const newItems = items
148
+ ?.map(({ values }, newItemIndex) =>
149
+ values?.map((newValue, newValueIndex) => {
150
+ if (typeof newValue === 'object' && ['FileDirectory16', 'File16'].includes(newValue?.icon)) {
151
+ bubleUpNewItems = false
152
+ }
153
+ return newItemIndex === itemIndex && newValueIndex === isSelectedIndex ? !newValue : newValue
154
+ }),
155
+ )
156
+ .map((newItem) => ({
157
+ id: newItem[idIndex],
158
+ isSelected: newItem[isSelectedIndex],
159
+ }))
160
+ if (bubleUpNewItems) {
161
+ // @ts-ignore
162
+ onChange(newItems)
163
+ }
164
+ }}
165
+ onKeyPress={() => {}}
166
+ role="button"
167
+ tabIndex={0}
168
+ onDoubleClick={() => {
169
+ // @ts-ignore
170
+ onDoubleClick(itemIndex)
171
+ }}
172
+ >
173
+ {item.values.map((value, valueIndex) => {
174
+ const isIdColumn = valueIndex === idIndex
175
+ const isSelectedColumn = valueIndex === isSelectedIndex
176
+ const isSelectedComponent =
177
+ selection === flexGridSelection.radio ? (
178
+ <Radio
179
+ name="isSelected"
180
+ isChecked={item.values[isSelectedIndex] === true}
181
+ onChange={(event) => {
182
+ const newItems = items?.map(({ names, values }, newItemIndex) => ({
183
+ names,
184
+ values: values.map((newValue, newValueIndex) => {
185
+ if (newItemIndex === itemIndex && newValueIndex === isSelectedIndex) {
186
+ return event.target.checked
187
+ }
188
+
189
+ if (newItemIndex === itemIndex && newValueIndex !== isSelectedIndex) {
190
+ return newValue
191
+ }
192
+
193
+ if (newItemIndex !== itemIndex && newValueIndex === isSelectedIndex) {
194
+ return false
195
+ }
196
+
197
+ if (newItemIndex !== itemIndex && newValueIndex !== isSelectedIndex) {
198
+ return newValue
199
+ }
200
+
201
+ return newValue
202
+ }),
203
+ }))
204
+ // @ts-ignore
205
+ onChange(newItems)
206
+ }}
207
+ />
208
+ ) : (
209
+ <Checkbox
210
+ ariaAttr={{ describedBy: 'isSelected' }}
211
+ isChecked={item.values[isSelectedIndex] === true}
212
+ onChange={(event) => {
213
+ const newItems = items
214
+ ?.map(({ values }, newItemIndex) =>
215
+ values?.map((newValue, newValueIndex) =>
216
+ newItemIndex === itemIndex && newValueIndex === isSelectedIndex ? event.target.checked : newValue,
217
+ ),
218
+ )
219
+ .map((newItem) => ({
220
+ id: newItem[idIndex],
221
+ isSelected: newItem[isSelectedIndex],
222
+ }))
223
+ // @ts-ignore
224
+ onChange(newItems)
225
+ }}
226
+ />
227
+ )
228
+ const iconComponent = value?.icon ? <Icon icon={iconName[value.icon]} size={iconSize.small} fill={iconColor.object} /> : null
229
+
230
+ return (
231
+ <Fragment key={uuidv1()}>
232
+ {!isIdColumn && (
233
+ <div
234
+ key={uuidv1()}
235
+ className={cx(
236
+ displayStyles['d-flex'],
237
+ flexboxStyles['flex-row'],
238
+ paddingStyles['p-2'],
239
+ truncateStyles['css-truncate'],
240
+ truncateStyles['css-truncate-overflow'],
241
+ typographyStyles['no-wrap'],
242
+ {
243
+ [gridStyles['col-2']]: isSelectedColumn,
244
+ [gridStyles['col-12']]: !isSelectedColumn,
245
+ [flexboxStyles['flex-justify-center']]: isSelectedColumn,
246
+ [flexboxStyles['flex-justify-start']]: !isSelectedColumn,
247
+ },
248
+ )}
249
+ >
250
+ {isSelectedColumn ? (
251
+ isSelectedComponent
252
+ ) : (
253
+ <div className={cx(truncateStyles['css-truncate'], truncateStyles['css-truncate-overflow'])}>
254
+ {value?.icon && (
255
+ <Fragment>
256
+ {iconComponent}
257
+ <span className={marginStyles['ml-2']}>{value.value}</span>
258
+ </Fragment>
259
+ )}
260
+ {value instanceof Date && `${value.toLocaleDateString()} ${value.toLocaleTimeString()}`}
261
+ {Array.isArray(value) && value.find(({ isSelected }) => isSelected === true).text}
262
+ {!value?.icon && !(value instanceof Date) && !Array.isArray(value) && value?.toString()}
263
+ </div>
264
+ )}
265
+ </div>
266
+ )}
267
+ </Fragment>
268
+ )
269
+ })}
270
+ </div>
271
+ ))}
272
+ </div>
273
+ )
274
+ }
@@ -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: 'File16',
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: 'File16',
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: 'File16',
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: 'File16',
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: 'File16',
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: 'FileDirectory16',
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: 'File16',
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: 'File16',
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: 'File16',
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: 'FileDirectory16',
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: 'File16',
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
+ ]