@nypl/design-system-react-components 0.25.13 → 0.26.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 (299) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +10 -10
  3. package/dist/components/Accordion/Accordion.d.ts +1 -1
  4. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  5. package/dist/components/Button/Button.d.ts +2 -2
  6. package/dist/components/Card/Card.d.ts +11 -9
  7. package/dist/components/Checkbox/Checkbox.d.ts +2 -2
  8. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +5 -4
  9. package/dist/components/ComponentWrapper/ComponentWrapper.d.ts +1 -1
  10. package/dist/components/DatePicker/DatePicker.d.ts +5 -6
  11. package/dist/components/Fieldset/Fieldset.d.ts +5 -6
  12. package/dist/components/Form/Form.d.ts +6 -6
  13. package/dist/components/Grid/GridTypes.d.ts +7 -7
  14. package/dist/components/Grid/SimpleGrid.d.ts +1 -1
  15. package/dist/components/Heading/Heading.d.ts +1 -1
  16. package/dist/components/HelperErrorText/HelperErrorText.d.ts +9 -8
  17. package/dist/components/Hero/Hero.d.ts +2 -1
  18. package/dist/components/HorizontalRule/HorizontalRule.d.ts +2 -10
  19. package/dist/components/Icons/Icon.d.ts +2 -1
  20. package/dist/components/Image/Image.d.ts +2 -2
  21. package/dist/components/Label/Label.d.ts +7 -4
  22. package/dist/components/Link/Link.d.ts +1 -1
  23. package/dist/components/List/List.d.ts +11 -11
  24. package/dist/components/List/ListTypes.d.ts +1 -1
  25. package/dist/components/Logo/Logo.d.ts +2 -1
  26. package/dist/components/Logo/LogoSvgs.d.ts +2 -0
  27. package/dist/components/Logo/LogoTypes.d.ts +2 -0
  28. package/dist/components/Notification/Notification.d.ts +4 -4
  29. package/dist/components/Pagination/Pagination.d.ts +2 -2
  30. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +3 -3
  31. package/dist/components/Radio/Radio.d.ts +4 -6
  32. package/dist/components/RadioGroup/RadioGroup.d.ts +12 -6
  33. package/dist/components/SearchBar/SearchBar.d.ts +4 -4
  34. package/dist/components/Select/Select.d.ts +10 -6
  35. package/dist/components/Select/SelectTypes.d.ts +4 -0
  36. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -3
  37. package/dist/components/Slider/Slider.d.ts +6 -4
  38. package/dist/components/StatusBadge/StatusBadge.d.ts +5 -1
  39. package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
  40. package/dist/components/Table/Table.d.ts +1 -1
  41. package/dist/components/Tabs/Tabs.d.ts +4 -3
  42. package/dist/components/Template/Template.d.ts +4 -3
  43. package/dist/components/Text/Text.d.ts +1 -1
  44. package/dist/components/TextInput/TextInput.d.ts +5 -5
  45. package/dist/components/Toggle/Toggle.d.ts +3 -4
  46. package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
  47. package/dist/design-system-react-components.cjs.development.js +1663 -1139
  48. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  49. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  50. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  51. package/dist/design-system-react-components.esm.js +1667 -1143
  52. package/dist/design-system-react-components.esm.js.map +1 -1
  53. package/dist/hooks/useCarouselStyles.d.ts +3 -2
  54. package/dist/hooks/useNYPLTheme.d.ts +12 -0
  55. package/dist/index.d.ts +4 -1
  56. package/dist/styles.css +1 -1
  57. package/dist/theme/components/button.d.ts +10 -2
  58. package/dist/theme/components/card.d.ts +42 -22
  59. package/dist/theme/components/checkbox.d.ts +5 -4
  60. package/dist/theme/components/checkboxGroup.d.ts +1 -1
  61. package/dist/theme/components/componentWrapper.d.ts +2 -2
  62. package/dist/theme/components/customTable.d.ts +84 -1
  63. package/dist/theme/components/fieldset.d.ts +4 -14
  64. package/dist/theme/components/global.d.ts +23 -17
  65. package/dist/theme/components/heading.d.ts +53 -0
  66. package/dist/theme/components/helperErrorText.d.ts +1 -0
  67. package/dist/theme/components/hero.d.ts +20 -14
  68. package/dist/theme/components/label.d.ts +9 -10
  69. package/dist/theme/components/list.d.ts +99 -9
  70. package/dist/theme/components/radio.d.ts +6 -4
  71. package/dist/theme/components/radioGroup.d.ts +1 -1
  72. package/dist/theme/components/select.d.ts +34 -5
  73. package/dist/theme/components/skeletonLoader.d.ts +2 -2
  74. package/dist/theme/components/slider.d.ts +6 -3
  75. package/dist/theme/components/structuredContent.d.ts +197 -0
  76. package/dist/theme/components/textInput.d.ts +18 -6
  77. package/dist/theme/components/toggle.d.ts +7 -4
  78. package/dist/theme/foundations/global.d.ts +2 -0
  79. package/dist/theme/foundations/radii.d.ts +1 -0
  80. package/dist/theme/foundations/spacing.d.ts +46 -43
  81. package/package.json +5 -6
  82. package/src/components/Accordion/Accordion.stories.mdx +9 -9
  83. package/src/components/Accordion/Accordion.test.tsx +21 -0
  84. package/src/components/Accordion/Accordion.tsx +13 -9
  85. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +276 -27
  86. package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
  87. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -5
  88. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +52 -31
  89. package/src/components/Breadcrumbs/Breadcrumbs.tsx +8 -7
  90. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +211 -12
  91. package/src/components/Button/Button.stories.mdx +87 -23
  92. package/src/components/Button/Button.test.tsx +25 -0
  93. package/src/components/Button/Button.tsx +18 -7
  94. package/src/components/Button/__snapshots__/Button.test.tsx.snap +27 -7
  95. package/src/components/Card/Card.stories.mdx +287 -194
  96. package/src/components/Card/Card.test.tsx +102 -0
  97. package/src/components/Card/Card.tsx +73 -32
  98. package/src/components/Card/__snapshots__/Card.test.tsx.snap +195 -35
  99. package/src/components/Chakra/Grid.stories.mdx +4 -4
  100. package/src/components/Checkbox/Checkbox.stories.mdx +62 -10
  101. package/src/components/Checkbox/Checkbox.test.tsx +32 -9
  102. package/src/components/Checkbox/Checkbox.tsx +20 -15
  103. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +134 -7
  104. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +65 -17
  105. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +137 -81
  106. package/src/components/CheckboxGroup/CheckboxGroup.tsx +31 -21
  107. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +332 -97
  108. package/src/components/ComponentWrapper/ComponentWrapper.test.tsx +12 -0
  109. package/src/components/ComponentWrapper/ComponentWrapper.tsx +39 -41
  110. package/src/components/ComponentWrapper/__snapshots__/ComponentWrapper.test.tsx.snap +47 -34
  111. package/src/components/DatePicker/DatePicker.stories.mdx +63 -27
  112. package/src/components/DatePicker/DatePicker.test.tsx +89 -13
  113. package/src/components/DatePicker/DatePicker.tsx +62 -56
  114. package/src/components/DatePicker/_DatePicker.scss +71 -13
  115. package/src/components/DatePicker/__snapshots__/DatePicker.test.tsx.snap +250 -206
  116. package/src/components/Fieldset/Fieldset.stories.mdx +33 -3
  117. package/src/components/Fieldset/Fieldset.test.tsx +58 -28
  118. package/src/components/Fieldset/Fieldset.tsx +35 -30
  119. package/src/components/Fieldset/__snapshots__/Fieldset.test.tsx.snap +40 -19
  120. package/src/components/Form/Form.stories.mdx +72 -39
  121. package/src/components/Form/Form.test.tsx +58 -15
  122. package/src/components/Form/Form.tsx +89 -67
  123. package/src/components/Form/__snapshots__/Form.test.tsx.snap +83 -5
  124. package/src/components/Grid/GridTypes.tsx +7 -7
  125. package/src/components/Grid/SimpleGrid.stories.mdx +34 -6
  126. package/src/components/Grid/SimpleGrid.test.tsx +9 -0
  127. package/src/components/Grid/SimpleGrid.tsx +29 -20
  128. package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +16 -1
  129. package/src/components/Heading/Heading.stories.mdx +36 -3
  130. package/src/components/Heading/Heading.test.tsx +10 -0
  131. package/src/components/Heading/Heading.tsx +56 -50
  132. package/src/components/Heading/__snapshots__/Heading.test.tsx.snap +26 -7
  133. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +64 -42
  134. package/src/components/HelperErrorText/HelperErrorText.test.tsx +15 -0
  135. package/src/components/HelperErrorText/HelperErrorText.tsx +40 -35
  136. package/src/components/HelperErrorText/__snapshots__/HelperErrorText.test.tsx.snap +35 -4
  137. package/src/components/Hero/Hero.stories.mdx +125 -95
  138. package/src/components/Hero/Hero.test.tsx +33 -0
  139. package/src/components/Hero/Hero.tsx +135 -126
  140. package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +89 -17
  141. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +26 -4
  142. package/src/components/HorizontalRule/HorizontalRule.test.tsx +9 -19
  143. package/src/components/HorizontalRule/HorizontalRule.tsx +9 -26
  144. package/src/components/HorizontalRule/__snapshots__/HorizontalRule.test.tsx.snap +18 -5
  145. package/src/components/Icons/Icon.stories.mdx +31 -6
  146. package/src/components/Icons/Icon.test.tsx +38 -0
  147. package/src/components/Icons/Icon.tsx +93 -76
  148. package/src/components/Icons/__snapshots__/Icon.test.tsx.snap +129 -0
  149. package/src/components/Image/Image.stories.mdx +29 -5
  150. package/src/components/Image/Image.test.tsx +8 -0
  151. package/src/components/Image/Image.tsx +38 -26
  152. package/src/components/Image/__snapshots__/Image.test.tsx.snap +24 -8
  153. package/src/components/Label/Label.stories.mdx +42 -20
  154. package/src/components/Label/Label.test.tsx +42 -17
  155. package/src/components/Label/Label.tsx +22 -13
  156. package/src/components/Label/__snapshots__/Label.test.tsx.snap +19 -15
  157. package/src/components/Link/Link.stories.mdx +25 -1
  158. package/src/components/Link/Link.test.tsx +21 -0
  159. package/src/components/Link/Link.tsx +8 -8
  160. package/src/components/Link/__snapshots__/Link.test.tsx.snap +37 -11
  161. package/src/components/List/List.stories.mdx +75 -40
  162. package/src/components/List/List.test.tsx +67 -19
  163. package/src/components/List/List.tsx +38 -25
  164. package/src/components/List/ListTypes.tsx +1 -1
  165. package/src/components/List/__snapshots__/List.test.tsx.snap +110 -8
  166. package/src/components/Logo/Logo.stories.mdx +30 -6
  167. package/src/components/Logo/Logo.test.tsx +17 -0
  168. package/src/components/Logo/Logo.tsx +18 -6
  169. package/src/components/Logo/LogoSvgs.tsx +4 -0
  170. package/src/components/Logo/LogoTypes.tsx +2 -0
  171. package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +73 -2
  172. package/src/components/Modal/Modal.stories.mdx +13 -0
  173. package/src/components/Notification/Notification.stories.mdx +25 -1
  174. package/src/components/Notification/Notification.test.tsx +23 -0
  175. package/src/components/Notification/Notification.tsx +46 -44
  176. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +158 -29
  177. package/src/components/Pagination/Pagination.stories.mdx +24 -4
  178. package/src/components/Pagination/Pagination.test.tsx +25 -0
  179. package/src/components/Pagination/Pagination.tsx +6 -6
  180. package/src/components/Pagination/__snapshots__/Pagination.test.tsx.snap +244 -27
  181. package/src/components/Placeholder/Placeholder.tsx +3 -1
  182. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +76 -10
  183. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +81 -11
  184. package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -9
  185. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +101 -14
  186. package/src/components/Radio/Radio.stories.mdx +64 -12
  187. package/src/components/Radio/Radio.test.tsx +28 -8
  188. package/src/components/Radio/Radio.tsx +66 -63
  189. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +103 -6
  190. package/src/components/RadioGroup/RadioGroup.stories.mdx +224 -89
  191. package/src/components/RadioGroup/RadioGroup.test.tsx +122 -62
  192. package/src/components/RadioGroup/RadioGroup.tsx +106 -100
  193. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1236 -1020
  194. package/src/components/SearchBar/SearchBar.stories.mdx +101 -36
  195. package/src/components/SearchBar/{SearchBar.Test.tsx → SearchBar.test.tsx} +46 -4
  196. package/src/components/SearchBar/SearchBar.tsx +17 -8
  197. package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +1039 -0
  198. package/src/components/Select/Select.stories.mdx +128 -49
  199. package/src/components/Select/Select.test.tsx +63 -16
  200. package/src/components/Select/Select.tsx +125 -92
  201. package/src/components/Select/SelectTypes.tsx +5 -0
  202. package/src/components/Select/__snapshots__/Select.test.tsx.snap +749 -409
  203. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +42 -10
  204. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +8 -0
  205. package/src/components/SkeletonLoader/SkeletonLoader.tsx +76 -72
  206. package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +169 -10
  207. package/src/components/Slider/Slider.stories.mdx +91 -42
  208. package/src/components/Slider/Slider.test.tsx +65 -17
  209. package/src/components/Slider/Slider.tsx +26 -19
  210. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +403 -226
  211. package/src/components/StatusBadge/StatusBadge.stories.mdx +19 -1
  212. package/src/components/StatusBadge/StatusBadge.test.tsx +16 -0
  213. package/src/components/StatusBadge/StatusBadge.tsx +25 -20
  214. package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +22 -3
  215. package/src/components/StructuredContent/StructuredContent.stories.mdx +131 -12
  216. package/src/components/StructuredContent/StructuredContent.test.tsx +34 -0
  217. package/src/components/StructuredContent/StructuredContent.tsx +80 -75
  218. package/src/components/StructuredContent/__snapshots__/StructuredContent.test.tsx.snap +102 -17
  219. package/src/components/StyleGuide/Bidirectionality.stories.mdx +5 -5
  220. package/src/components/StyleGuide/Breakpoints.stories.mdx +6 -6
  221. package/src/components/StyleGuide/Buttons.stories.mdx +2 -12
  222. package/src/components/StyleGuide/ColorCard.tsx +1 -1
  223. package/src/components/StyleGuide/Colors.stories.mdx +1 -2
  224. package/src/components/StyleGuide/DesignTokens.stories.mdx +56 -26
  225. package/src/components/StyleGuide/Forms.stories.mdx +27 -12
  226. package/src/components/StyleGuide/Iconography.stories.mdx +2 -12
  227. package/src/components/StyleGuide/Spacing.stories.mdx +80 -41
  228. package/src/components/StyleGuide/Typography.stories.mdx +30 -21
  229. package/src/components/Table/Table.stories.mdx +38 -11
  230. package/src/components/Table/Table.test.tsx +15 -0
  231. package/src/components/Table/Table.tsx +7 -7
  232. package/src/components/Table/__snapshots__/Table.test.tsx.snap +408 -5
  233. package/src/components/Tabs/Tabs.stories.mdx +52 -3
  234. package/src/components/Tabs/Tabs.test.tsx +16 -0
  235. package/src/components/Tabs/Tabs.tsx +10 -6
  236. package/src/components/Tabs/__snapshots__/Tabs.test.tsx.snap +394 -5
  237. package/src/components/Template/Template.stories.mdx +47 -43
  238. package/src/components/Template/Template.test.tsx +33 -0
  239. package/src/components/Template/Template.tsx +65 -60
  240. package/src/components/Template/__snapshots__/Template.test.tsx.snap +191 -20
  241. package/src/components/Text/Text.stories.mdx +20 -1
  242. package/src/components/Text/Text.test.tsx +12 -0
  243. package/src/components/Text/Text.tsx +6 -4
  244. package/src/components/Text/__snapshots__/Text.test.tsx.snap +21 -4
  245. package/src/components/TextInput/TextInput.stories.mdx +65 -19
  246. package/src/components/TextInput/TextInput.test.tsx +42 -28
  247. package/src/components/TextInput/TextInput.tsx +121 -113
  248. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +96 -73
  249. package/src/components/Toggle/Toggle.stories.mdx +80 -22
  250. package/src/components/Toggle/Toggle.test.tsx +27 -9
  251. package/src/components/Toggle/Toggle.tsx +22 -18
  252. package/src/components/Toggle/__snapshots__/Toggle.test.tsx.snap +128 -5
  253. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +52 -4
  254. package/src/components/VideoPlayer/VideoPlayer.test.tsx +23 -0
  255. package/src/components/VideoPlayer/VideoPlayer.tsx +133 -126
  256. package/src/components/VideoPlayer/__snapshots__/VideoPlayer.test.tsx.snap +81 -39
  257. package/src/docs/Chakra.stories.mdx +50 -9
  258. package/src/docs/Welcome.stories.mdx +160 -41
  259. package/src/hooks/useCarouselStyles.stories.mdx +22 -2
  260. package/src/hooks/useCarouselStyles.ts +3 -2
  261. package/src/hooks/useNYPLTheme.stories.mdx +101 -0
  262. package/src/hooks/useNYPLTheme.ts +30 -6
  263. package/src/hooks/useWindowSize.stories.mdx +23 -0
  264. package/src/index.ts +4 -1
  265. package/src/styles/base/_place-holder.scss +1 -1
  266. package/src/theme/components/button.ts +15 -7
  267. package/src/theme/components/card.ts +30 -19
  268. package/src/theme/components/checkbox.ts +10 -8
  269. package/src/theme/components/checkboxGroup.ts +1 -1
  270. package/src/theme/components/componentWrapper.ts +2 -2
  271. package/src/theme/components/customTable.ts +39 -31
  272. package/src/theme/components/fieldset.ts +1 -2
  273. package/src/theme/components/global.ts +25 -20
  274. package/src/theme/components/heading.ts +1 -1
  275. package/src/theme/components/helperErrorText.ts +1 -0
  276. package/src/theme/components/hero.ts +13 -15
  277. package/src/theme/components/label.ts +4 -3
  278. package/src/theme/components/list.ts +73 -66
  279. package/src/theme/components/notification.ts +2 -2
  280. package/src/theme/components/radio.ts +9 -9
  281. package/src/theme/components/radioGroup.ts +1 -1
  282. package/src/theme/components/select.ts +35 -22
  283. package/src/theme/components/skeletonLoader.ts +3 -3
  284. package/src/theme/components/slider.ts +8 -7
  285. package/src/theme/components/statusBadge.ts +2 -2
  286. package/src/theme/components/structuredContent.ts +66 -1
  287. package/src/theme/components/tabs.ts +2 -2
  288. package/src/theme/components/template.ts +9 -9
  289. package/src/theme/components/textInput.ts +13 -12
  290. package/src/theme/components/toggle.ts +17 -10
  291. package/src/theme/components/videoPlayer.ts +1 -1
  292. package/src/theme/foundations/colors.ts +1 -1
  293. package/src/theme/foundations/radii.ts +1 -0
  294. package/src/theme/foundations/spacing.ts +70 -22
  295. package/src/theme/foundations/typography.ts +2 -2
  296. package/src/utils/componentCategories.ts +1 -2
  297. package/dist/components/SearchBar/SearchBar.Test.d.ts +0 -1
  298. package/dist/helpers/generateUUID.d.ts +0 -1
  299. package/src/helpers/generateUUID.tsx +0 -5
@@ -9,10 +9,15 @@ import { ProgressIndicatorTypes } from "./ProgressIndicatorTypes";
9
9
  describe("ProgressIndicator Accessibility", () => {
10
10
  it("passes axe accessibility for linear and circular types", async () => {
11
11
  const linearUtils = render(
12
- <ProgressIndicator labelText="Linear" value={50} />
12
+ <ProgressIndicator
13
+ id="progressIndicatorLinear"
14
+ labelText="Linear"
15
+ value={50}
16
+ />
13
17
  );
14
18
  const circularUtils = render(
15
19
  <ProgressIndicator
20
+ id="progressIndicatorCircular"
16
21
  labelText="Circular"
17
22
  value={50}
18
23
  indicatorType={ProgressIndicatorTypes.Circular}
@@ -24,10 +29,16 @@ describe("ProgressIndicator Accessibility", () => {
24
29
 
25
30
  it("passes axe accessibility for linear and circular types without labels", async () => {
26
31
  const linearUtils = render(
27
- <ProgressIndicator labelText="Linear" value={50} showLabel={false} />
32
+ <ProgressIndicator
33
+ id="progressIndicatorLinear"
34
+ labelText="Linear"
35
+ value={50}
36
+ showLabel={false}
37
+ />
28
38
  );
29
39
  const circularUtils = render(
30
40
  <ProgressIndicator
41
+ id="progressIndicatorCircular"
31
42
  labelText="Circular"
32
43
  value={50}
33
44
  indicatorType={ProgressIndicatorTypes.Circular}
@@ -40,10 +51,16 @@ describe("ProgressIndicator Accessibility", () => {
40
51
 
41
52
  it("passes axe accessibility for linear and circular types for indeterminate state", async () => {
42
53
  const linearUtils = render(
43
- <ProgressIndicator labelText="Linear" value={50} isIndeterminate />
54
+ <ProgressIndicator
55
+ id="progressIndicatorLinear"
56
+ labelText="Linear"
57
+ value={50}
58
+ isIndeterminate
59
+ />
44
60
  );
45
61
  const circularUtils = render(
46
62
  <ProgressIndicator
63
+ id="progressIndicatorCircular"
47
64
  labelText="Circular"
48
65
  value={50}
49
66
  indicatorType={ProgressIndicatorTypes.Circular}
@@ -56,10 +73,16 @@ describe("ProgressIndicator Accessibility", () => {
56
73
 
57
74
  it("passes axe accessibility for linear and circular types for dark mode", async () => {
58
75
  const linearUtils = render(
59
- <ProgressIndicator labelText="Linear" value={50} darkMode />
76
+ <ProgressIndicator
77
+ id="progressIndicatorLinear"
78
+ labelText="Linear"
79
+ value={50}
80
+ darkMode
81
+ />
60
82
  );
61
83
  const circularUtils = render(
62
84
  <ProgressIndicator
85
+ id="progressIndicatorCircular"
63
86
  labelText="Circular"
64
87
  value={50}
65
88
  indicatorType={ProgressIndicatorTypes.Circular}
@@ -73,7 +96,9 @@ describe("ProgressIndicator Accessibility", () => {
73
96
 
74
97
  describe("ProgressIndicator", () => {
75
98
  it("renders a label and a progressbar for the linear type", () => {
76
- render(<ProgressIndicator labelText="Linear" value={50} />);
99
+ render(
100
+ <ProgressIndicator id="progressIndicator" labelText="Linear" value={50} />
101
+ );
77
102
  expect(screen.getByLabelText("Linear")).toBeInTheDocument();
78
103
  expect(screen.getByRole("progressbar")).toBeInTheDocument();
79
104
  });
@@ -81,6 +106,7 @@ describe("ProgressIndicator", () => {
81
106
  it("renders a label, a progressbar, and an svg for the circular type", () => {
82
107
  const { container } = render(
83
108
  <ProgressIndicator
109
+ id="progressIndicator"
84
110
  labelText="Circular"
85
111
  indicatorType={ProgressIndicatorTypes.Circular}
86
112
  value={50}
@@ -93,7 +119,12 @@ describe("ProgressIndicator", () => {
93
119
 
94
120
  it("renders the appropriate aria atttribute when the label is hidden", () => {
95
121
  render(
96
- <ProgressIndicator labelText="Linear" value={50} showLabel={false} />
122
+ <ProgressIndicator
123
+ id="progressIndicator"
124
+ labelText="Linear"
125
+ value={50}
126
+ showLabel={false}
127
+ />
97
128
  );
98
129
  expect(screen.getByLabelText("Linear")).toBeInTheDocument();
99
130
  expect(screen.getByRole("progressbar")).toHaveAttribute(
@@ -104,20 +135,30 @@ describe("ProgressIndicator", () => {
104
135
 
105
136
  it("renders the value passed", () => {
106
137
  const { rerender } = render(
107
- <ProgressIndicator labelText="Linear" value={50} />
138
+ <ProgressIndicator id="progressIndicator" labelText="Linear" value={50} />
108
139
  );
109
140
  expect(screen.getByText("50%")).toBeInTheDocument();
110
141
 
111
- rerender(<ProgressIndicator labelText="Linear" value={89} />);
142
+ rerender(
143
+ <ProgressIndicator id="progressIndicator" labelText="Linear" value={89} />
144
+ );
112
145
  expect(screen.getByText("89%")).toBeInTheDocument();
113
146
 
114
- rerender(<ProgressIndicator labelText="Linear" value={4} />);
147
+ rerender(
148
+ <ProgressIndicator id="progressIndicator" labelText="Linear" value={4} />
149
+ );
115
150
  expect(screen.getByText("4%")).toBeInTheDocument();
116
151
  });
117
152
 
118
153
  it("logs a warning if a value less than 0 is passed", () => {
119
154
  const warn = jest.spyOn(console, "warn");
120
- render(<ProgressIndicator labelText="Linear" value={-20} />);
155
+ render(
156
+ <ProgressIndicator
157
+ id="progressIndicator"
158
+ labelText="Linear"
159
+ value={-20}
160
+ />
161
+ );
121
162
 
122
163
  expect(warn).toHaveBeenCalledWith(
123
164
  "NYPL Reservoir ProgressIndicator: An invalid value was passed for the" +
@@ -128,7 +169,13 @@ describe("ProgressIndicator", () => {
128
169
 
129
170
  it("logs a warning if a value more than 100 is passed", () => {
130
171
  const warn = jest.spyOn(console, "warn");
131
- render(<ProgressIndicator labelText="Linear" value={150} />);
172
+ render(
173
+ <ProgressIndicator
174
+ id="progressIndicator"
175
+ labelText="Linear"
176
+ value={150}
177
+ />
178
+ );
132
179
 
133
180
  expect(warn).toHaveBeenCalledWith(
134
181
  "NYPL Reservoir ProgressIndicator: An invalid value was passed for the" +
@@ -216,6 +263,27 @@ describe("ProgressIndicator", () => {
216
263
  />
217
264
  )
218
265
  .toJSON();
266
+ const withChakraProps = renderer
267
+ .create(
268
+ <ProgressIndicator
269
+ id="chakra"
270
+ labelText="Linear"
271
+ value={50}
272
+ p="20px"
273
+ color="ui.red.primary"
274
+ />
275
+ )
276
+ .toJSON();
277
+ const withOtherProps = renderer
278
+ .create(
279
+ <ProgressIndicator
280
+ id="props"
281
+ labelText="Linear"
282
+ value={50}
283
+ data-testid="props"
284
+ />
285
+ )
286
+ .toJSON();
219
287
 
220
288
  expect(linearBasic).toMatchSnapshot();
221
289
  expect(circularBasic).toMatchSnapshot();
@@ -225,5 +293,7 @@ describe("ProgressIndicator", () => {
225
293
  expect(circularIndeterminate).toMatchSnapshot();
226
294
  expect(linearDarkMode).toMatchSnapshot();
227
295
  expect(circularDarkMode).toMatchSnapshot();
296
+ expect(withChakraProps).toMatchSnapshot();
297
+ expect(withOtherProps).toMatchSnapshot();
228
298
  });
229
299
  });
@@ -1,24 +1,24 @@
1
- import React from "react";
2
1
  import {
3
2
  Box,
3
+ chakra,
4
4
  CircularProgress as ChakraCircularProgress,
5
5
  CircularProgressLabel as ChakraCircularProgressLabel,
6
6
  Progress as ChakraProgress,
7
7
  useMultiStyleConfig,
8
8
  } from "@chakra-ui/react";
9
+ import React from "react";
9
10
 
10
11
  import {
11
12
  ProgressIndicatorSizes,
12
13
  ProgressIndicatorTypes,
13
14
  } from "./ProgressIndicatorTypes";
14
- import generateUUID from "../../helpers/generateUUID";
15
15
  import Label from "../Label/Label";
16
16
 
17
17
  export interface ProgressIndicatorProps {
18
18
  /** Flag to render the component in a dark background. */
19
19
  darkMode?: boolean;
20
20
  /** ID that other components can cross reference for accessibility purposes. */
21
- id?: string;
21
+ id: string;
22
22
  /** Whether the `ProgressIndicator` should be linear or circular. */
23
23
  indicatorType?: ProgressIndicatorTypes;
24
24
  /** Whether the progress animation should display because the `value` prop is
@@ -40,24 +40,28 @@ export interface ProgressIndicatorProps {
40
40
  * time to complete or consists of multiple steps. Examples include downloading,
41
41
  * uploading, or processing.
42
42
  */
43
- const ProgressIndicator: React.FC<ProgressIndicatorProps> = (
44
- props: ProgressIndicatorProps
45
- ) => {
43
+ export const ProgressIndicator = chakra((props: ProgressIndicatorProps) => {
46
44
  const {
47
45
  darkMode = false,
48
- id = generateUUID(),
46
+ id,
49
47
  indicatorType = ProgressIndicatorTypes.Linear,
50
48
  isIndeterminate = false,
51
49
  labelText,
52
50
  showLabel = true,
53
51
  size = ProgressIndicatorSizes.Default,
54
52
  value = 0,
53
+ ...rest
55
54
  } = props;
56
55
  const styles = useMultiStyleConfig("ProgressIndicator", {
57
56
  darkMode,
58
57
  size,
59
58
  });
60
59
  let finalValue = value;
60
+ if (!id) {
61
+ console.warn(
62
+ "NYPL Reservoir Progress Indicator: This component's required `id` prop was not passed."
63
+ );
64
+ }
61
65
  if (finalValue < 0 || finalValue > 100) {
62
66
  console.warn(
63
67
  "NYPL Reservoir ProgressIndicator: An invalid value was passed for the" +
@@ -122,7 +126,11 @@ const ProgressIndicator: React.FC<ProgressIndicatorProps> = (
122
126
  );
123
127
  };
124
128
 
125
- return <Box __css={styles}>{progressComponent(indicatorType)}</Box>;
126
- };
129
+ return (
130
+ <Box __css={styles} {...rest}>
131
+ {progressComponent(indicatorType)}
132
+ </Box>
133
+ );
134
+ });
127
135
 
128
136
  export default ProgressIndicator;
@@ -2,10 +2,10 @@
2
2
 
3
3
  exports[`ProgressIndicator Renders the UI snapshot correctly 1`] = `
4
4
  <div
5
- className="css-0"
5
+ className="css-1xdhyk6"
6
6
  >
7
7
  <label
8
- className="css-0"
8
+ className="css-1xdhyk6"
9
9
  htmlFor="linearBasic"
10
10
  id="linearBasic-label"
11
11
  >
@@ -45,7 +45,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 1`] = `
45
45
 
46
46
  exports[`ProgressIndicator Renders the UI snapshot correctly 2`] = `
47
47
  <div
48
- className="css-0"
48
+ className="css-1xdhyk6"
49
49
  >
50
50
  <div
51
51
  className="css-0"
@@ -89,7 +89,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 2`] = `
89
89
  </div>
90
90
  </div>
91
91
  <label
92
- className="css-0"
92
+ className="css-1xdhyk6"
93
93
  htmlFor="circularBasic"
94
94
  id="circularBasic-label"
95
95
  >
@@ -101,7 +101,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 2`] = `
101
101
 
102
102
  exports[`ProgressIndicator Renders the UI snapshot correctly 3`] = `
103
103
  <div
104
- className="css-0"
104
+ className="css-1xdhyk6"
105
105
  >
106
106
  <div
107
107
  className="css-0"
@@ -131,7 +131,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 3`] = `
131
131
 
132
132
  exports[`ProgressIndicator Renders the UI snapshot correctly 4`] = `
133
133
  <div
134
- className="css-0"
134
+ className="css-1xdhyk6"
135
135
  >
136
136
  <div
137
137
  className="css-0"
@@ -174,10 +174,10 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 4`] = `
174
174
 
175
175
  exports[`ProgressIndicator Renders the UI snapshot correctly 5`] = `
176
176
  <div
177
- className="css-0"
177
+ className="css-1xdhyk6"
178
178
  >
179
179
  <label
180
- className="css-0"
180
+ className="css-1xdhyk6"
181
181
  htmlFor="linearIndeterminate"
182
182
  id="linearIndeterminate-label"
183
183
  >
@@ -211,7 +211,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 5`] = `
211
211
 
212
212
  exports[`ProgressIndicator Renders the UI snapshot correctly 6`] = `
213
213
  <div
214
- className="css-0"
214
+ className="css-1xdhyk6"
215
215
  >
216
216
  <div
217
217
  className="css-0"
@@ -247,7 +247,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 6`] = `
247
247
  </svg>
248
248
  </div>
249
249
  <label
250
- className="css-0"
250
+ className="css-1xdhyk6"
251
251
  htmlFor="circularIndeterminate"
252
252
  id="circularIndeterminate-label"
253
253
  >
@@ -259,10 +259,10 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 6`] = `
259
259
 
260
260
  exports[`ProgressIndicator Renders the UI snapshot correctly 7`] = `
261
261
  <div
262
- className="css-0"
262
+ className="css-1xdhyk6"
263
263
  >
264
264
  <label
265
- className="css-0"
265
+ className="css-1xdhyk6"
266
266
  htmlFor="linearDarkMode"
267
267
  id="linearDarkMode-label"
268
268
  >
@@ -302,7 +302,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 7`] = `
302
302
 
303
303
  exports[`ProgressIndicator Renders the UI snapshot correctly 8`] = `
304
304
  <div
305
- className="css-0"
305
+ className="css-1xdhyk6"
306
306
  >
307
307
  <div
308
308
  className="css-0"
@@ -346,7 +346,7 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 8`] = `
346
346
  </div>
347
347
  </div>
348
348
  <label
349
- className="css-0"
349
+ className="css-1xdhyk6"
350
350
  htmlFor="circularDarkMode"
351
351
  id="circularDarkMode-label"
352
352
  >
@@ -355,3 +355,90 @@ exports[`ProgressIndicator Renders the UI snapshot correctly 8`] = `
355
355
  </div>
356
356
  </div>
357
357
  `;
358
+
359
+ exports[`ProgressIndicator Renders the UI snapshot correctly 9`] = `
360
+ <div
361
+ className="css-10g9ftz"
362
+ >
363
+ <label
364
+ className="css-1xdhyk6"
365
+ htmlFor="chakra"
366
+ id="chakra-label"
367
+ >
368
+ Linear
369
+ </label>
370
+ <div
371
+ className="css-0"
372
+ >
373
+ <div
374
+ className="css-kdwx3d"
375
+ id="chakra"
376
+ >
377
+ <div
378
+ aria-label={null}
379
+ aria-labelledby="chakra-label"
380
+ aria-valuemax={100}
381
+ aria-valuemin={0}
382
+ aria-valuenow={50}
383
+ className="css-1jy0d03"
384
+ role="progressbar"
385
+ style={
386
+ Object {
387
+ "width": "50%",
388
+ }
389
+ }
390
+ />
391
+ </div>
392
+ <div
393
+ className="css-0"
394
+ >
395
+ 50
396
+ %
397
+ </div>
398
+ </div>
399
+ </div>
400
+ `;
401
+
402
+ exports[`ProgressIndicator Renders the UI snapshot correctly 10`] = `
403
+ <div
404
+ className="css-1xdhyk6"
405
+ data-testid="props"
406
+ >
407
+ <label
408
+ className="css-1xdhyk6"
409
+ htmlFor="props"
410
+ id="props-label"
411
+ >
412
+ Linear
413
+ </label>
414
+ <div
415
+ className="css-0"
416
+ >
417
+ <div
418
+ className="css-kdwx3d"
419
+ id="props"
420
+ >
421
+ <div
422
+ aria-label={null}
423
+ aria-labelledby="props-label"
424
+ aria-valuemax={100}
425
+ aria-valuemin={0}
426
+ aria-valuenow={50}
427
+ className="css-1jy0d03"
428
+ role="progressbar"
429
+ style={
430
+ Object {
431
+ "width": "50%",
432
+ }
433
+ }
434
+ />
435
+ </div>
436
+ <div
437
+ className="css-0"
438
+ >
439
+ 50
440
+ %
441
+ </div>
442
+ </div>
443
+ </div>
444
+ `;
@@ -53,7 +53,22 @@ import DSProvider from "../../theme/provider";
53
53
  | Component Version | DS Version |
54
54
  | ----------------- | ---------- |
55
55
  | Added | `0.22.0` |
56
- | Latest | `0.25.13` |
56
+ | Latest | `0.26.0` |
57
+
58
+ ## Table of Contents
59
+
60
+ - [Overview](#overview)
61
+ - [Component Props](#component-props)
62
+ - [Accessibility](#accessibility)
63
+ - [Checked](#checked)
64
+ - [Focused](#focused)
65
+ - [Errored](#errored)
66
+ - [Disabled](#disabled)
67
+ - [Helper Text](#helper-text)
68
+ - [Error Text](#error-text)
69
+ - [With JSX Element Label](#with-jsx-element-label)
70
+
71
+ ## Overview
57
72
 
58
73
  <Description of={Radio} />
59
74
 
@@ -62,6 +77,8 @@ show the `Radio` button in isolation. We recommend to always use the `Radio`
62
77
  component inside the Design System `RadioGroup` component. The `RadioGroup`
63
78
  component will handle all the states and data management.
64
79
 
80
+ ## Component Props
81
+
65
82
  <Canvas withToolbar>
66
83
  <Story
67
84
  name="Radio"
@@ -88,11 +105,27 @@ component will handle all the states and data management.
88
105
 
89
106
  <ArgsTable story="Radio" />
90
107
 
108
+ ## Accessibility
109
+
110
+ The `Radio` component renders an `input` element with the `type="radio"` attribute.
111
+ This HTML element is accessible by default.
112
+
113
+ When `showLabel` is set to false, the `labelText` value will be set to the
114
+ `<input>`'s `aria-label` attribute.
115
+
116
+ Resources:
117
+
118
+ - [W3C ARIA radiogroup and radio example](https://www.w3.org/TR/2016/WD-wai-aria-practices-1.1-20160317/examples/radio/radio.html)
119
+ - [W3C Radio Button Example](https://www.w3.org/TR/2017/WD-wai-aria-practices-1.1-20170628/examples/radio/radio-1/radio-1.html)
120
+ - [MDN input type="radio"](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio)
121
+ - [Deque University Radio and Radio Group](https://dequeuniversity.com/library/aria/radio-and-radio-group)
122
+ - [Chakra UI Radio](https://chakra-ui.com/docs/components/form/radio)
123
+
91
124
  ## Checked
92
125
 
93
126
  <Canvas>
94
127
  <DSProvider>
95
- <Radio labelText="I am checked" isChecked value="1" />
128
+ <Radio labelText="I am checked" id="checked" isChecked value="1" />
96
129
  </DSProvider>
97
130
  </Canvas>
98
131
 
@@ -100,7 +133,10 @@ component will handle all the states and data management.
100
133
 
101
134
  <Canvas>
102
135
  <DSProvider>
103
- <Radio labelText="Click or tab to the Radio to see its focus state" />
136
+ <Radio
137
+ id="focused"
138
+ labelText="Click or tab to the Radio to see its focus state"
139
+ />
104
140
  </DSProvider>
105
141
  </Canvas>
106
142
 
@@ -109,8 +145,13 @@ component will handle all the states and data management.
109
145
  <Canvas>
110
146
  <DSProvider>
111
147
  <HStack>
112
- <Radio isInvalid labelText="I am in an error state" />
113
- <Radio isInvalid isChecked labelText="I am checked in an error state" />
148
+ <Radio id="invalid" isInvalid labelText="I am in an error state" />
149
+ <Radio
150
+ id="invalid-checked"
151
+ isInvalid
152
+ isChecked
153
+ labelText="I am checked in an error state"
154
+ />
114
155
  </HStack>
115
156
  </DSProvider>
116
157
  </Canvas>
@@ -120,8 +161,13 @@ component will handle all the states and data management.
120
161
  <Canvas>
121
162
  <DSProvider>
122
163
  <HStack>
123
- <Radio isDisabled labelText="I am disabled" />
124
- <Radio isDisabled isChecked labelText="I am checked and disabled" />
164
+ <Radio id="disabled" isDisabled labelText="I am disabled" />
165
+ <Radio
166
+ id="disabled-checked"
167
+ isDisabled
168
+ isChecked
169
+ labelText="I am checked and disabled"
170
+ />
125
171
  </HStack>
126
172
  </DSProvider>
127
173
  </Canvas>
@@ -131,9 +177,10 @@ component will handle all the states and data management.
131
177
  <Canvas>
132
178
  <DSProvider>
133
179
  <Radio
134
- name="testHelperText"
135
- labelText="I have helper text"
136
180
  helperText="I am the helper text for this Radio"
181
+ id="help-text"
182
+ labelText="I have helper text"
183
+ name="testHelperText"
137
184
  />
138
185
  </DSProvider>
139
186
  </Canvas>
@@ -143,10 +190,11 @@ component will handle all the states and data management.
143
190
  <Canvas>
144
191
  <DSProvider>
145
192
  <Radio
146
- name="testErrorText"
147
- labelText="I have error text"
193
+ id="invalid-text"
148
194
  invalidText="I am the error text for this Radio"
149
195
  isInvalid
196
+ labelText="I have error text"
197
+ name="testErrorText"
150
198
  />
151
199
  </DSProvider>
152
200
  </Canvas>
@@ -159,6 +207,10 @@ usage.
159
207
 
160
208
  <Canvas>
161
209
  <DSProvider>
162
- <Radio labelText={<span>Arts</span>} name="jsxElementLabel" />
210
+ <Radio
211
+ id="jsx-label"
212
+ labelText={<span>Arts</span>}
213
+ name="jsxElementLabel"
214
+ />
163
215
  </DSProvider>
164
216
  </Canvas>
@@ -5,7 +5,6 @@ import { axe } from "jest-axe";
5
5
  import renderer from "react-test-renderer";
6
6
 
7
7
  import Radio from "./Radio";
8
- import * as generateUUID from "../../helpers/generateUUID";
9
8
 
10
9
  describe("Radio Accessibility", () => {
11
10
  it("passes axe accessibility test with string label", async () => {
@@ -93,13 +92,6 @@ describe("Radio Button", () => {
93
92
  expect(screen.getByRole("radio")).toHaveAttribute("id", "inputID");
94
93
  });
95
94
 
96
- it("calls the UUID generation function if no id prop value is passed", () => {
97
- const generateUUIDSpy = jest.spyOn(generateUUID, "default");
98
- expect(generateUUIDSpy).toHaveBeenCalledTimes(0);
99
- render(<Radio labelText="Hello" />);
100
- expect(generateUUIDSpy).toHaveBeenCalledTimes(1);
101
- });
102
-
103
95
  it("sets the 'checked' attribute", () => {
104
96
  render(
105
97
  <Radio
@@ -168,6 +160,7 @@ describe("Radio Button", () => {
168
160
  const warn = jest.spyOn(console, "warn");
169
161
  render(
170
162
  <Radio
163
+ id="radio"
171
164
  value="arts"
172
165
  labelText={
173
166
  <Flex>
@@ -185,6 +178,18 @@ describe("Radio Button", () => {
185
178
  );
186
179
  });
187
180
 
181
+ it("logs a warning when there is no `id` passed", () => {
182
+ const warn = jest.spyOn(console, "warn");
183
+ render(
184
+ // @ts-ignore: Typescript complains when a required prop is not passed, but
185
+ // here we don't want to pass the required prop to make sure the warning appears.
186
+ <Radio labelText="Arts" />
187
+ );
188
+ expect(warn).toHaveBeenCalledWith(
189
+ "NYPL Reservoir Radio: This component's required `id` prop was not passed."
190
+ );
191
+ });
192
+
188
193
  it("renders the UI snapshot correctly", () => {
189
194
  const primary = renderer
190
195
  .create(<Radio id="inputID" labelText="Test Label" />)
@@ -216,6 +221,19 @@ describe("Radio Button", () => {
216
221
  />
217
222
  )
218
223
  .toJSON();
224
+ const withChakraProps = renderer
225
+ .create(
226
+ <Radio
227
+ id="chakra"
228
+ labelText="Test Label"
229
+ p="20px"
230
+ color="ui.error.primary"
231
+ />
232
+ )
233
+ .toJSON();
234
+ const withOtherProps = renderer
235
+ .create(<Radio id="props" labelText="Test Label" data-testid="props" />)
236
+ .toJSON();
219
237
 
220
238
  expect(primary).toMatchSnapshot();
221
239
  expect(isChecked).toMatchSnapshot();
@@ -223,5 +241,7 @@ describe("Radio Button", () => {
223
241
  expect(isInvalid).toMatchSnapshot();
224
242
  expect(isDisabled).toMatchSnapshot();
225
243
  expect(withJSXLabel).toMatchSnapshot();
244
+ expect(withChakraProps).toMatchSnapshot();
245
+ expect(withOtherProps).toMatchSnapshot();
226
246
  });
227
247
  });