@nypl/design-system-react-components 0.23.4 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (307) hide show
  1. package/CHANGELOG.md +98 -1
  2. package/README.md +46 -11
  3. package/dist/components/Accordion/Accordion.d.ts +14 -14
  4. package/dist/components/Autosuggest/Autosuggest.stories.d.ts +1 -0
  5. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +11 -14
  6. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +6 -0
  7. package/dist/components/Button/Button.d.ts +6 -13
  8. package/dist/components/Button/ButtonTypes.d.ts +5 -3
  9. package/dist/components/Card/Card.d.ts +59 -10
  10. package/dist/components/Card/CardTypes.d.ts +19 -0
  11. package/dist/components/CardEdition/CardEdition.d.ts +21 -0
  12. package/dist/components/{StyleGuide/Colors.stories.d.ts → CardEdition/CardEdition.stories.d.ts} +5 -2
  13. package/dist/components/Checkbox/Checkbox.d.ts +21 -16
  14. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +43 -0
  15. package/dist/components/CheckboxGroup/CheckboxGroupLayoutTypes.d.ts +4 -0
  16. package/dist/components/DatePicker/DatePicker.d.ts +79 -0
  17. package/dist/components/DatePicker/DatePickerTypes.d.ts +5 -0
  18. package/dist/components/Form/Form.d.ts +16 -8
  19. package/dist/components/Form/FormTypes.d.ts +2 -0
  20. package/dist/components/Grid/GridTypes.d.ts +9 -0
  21. package/dist/components/Grid/SimpleGrid.d.ts +14 -0
  22. package/dist/components/Heading/Heading.d.ts +9 -11
  23. package/dist/components/Heading/{HeadingDisplaySizes.d.ts → HeadingTypes.d.ts} +8 -0
  24. package/dist/components/HelperErrorText/HelperErrorText.stories.d.ts +2 -1
  25. package/dist/components/Hero/Hero.d.ts +19 -14
  26. package/dist/components/Hero/HeroTypes.d.ts +10 -5
  27. package/dist/components/Icons/Icon.d.ts +13 -16
  28. package/dist/components/Icons/IconSvgs.d.ts +4 -0
  29. package/dist/components/Icons/IconTypes.d.ts +78 -60
  30. package/dist/components/Image/Image.stories.d.ts +2 -1
  31. package/dist/components/Label/Label.d.ts +10 -26
  32. package/dist/components/Link/Link.d.ts +8 -12
  33. package/dist/components/List/List.stories.d.ts +1 -0
  34. package/dist/components/Radio/Radio.d.ts +30 -24
  35. package/dist/components/RadioGroup/RadioGroup.d.ts +40 -0
  36. package/dist/components/RadioGroup/RadioGroupLayoutTypes.d.ts +4 -0
  37. package/dist/components/SearchBar/SearchBar.d.ts +45 -27
  38. package/dist/components/Select/Select.d.ts +34 -35
  39. package/dist/components/Select/SelectTypes.d.ts +4 -0
  40. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +1 -1
  41. package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +2 -2
  42. package/dist/components/StatusBadge/StatusBadge.d.ts +8 -6
  43. package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +5 -0
  44. package/dist/components/Tabs/Tabs.d.ts +25 -0
  45. package/dist/components/Template/Template.d.ts +91 -0
  46. package/dist/components/Text/Text.d.ts +16 -0
  47. package/dist/components/Text/TextTypes.d.ts +6 -0
  48. package/dist/components/TextInput/TextInput.d.ts +37 -30
  49. package/dist/components/TextInput/TextInputTypes.d.ts +5 -0
  50. package/dist/design-system-react-components.cjs.development.js +4102 -917
  51. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  52. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  53. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  54. package/dist/design-system-react-components.esm.js +4023 -920
  55. package/dist/design-system-react-components.esm.js.map +1 -1
  56. package/dist/index.d.ts +23 -5
  57. package/dist/resources.scss +133 -24
  58. package/dist/styles.css +1 -1
  59. package/dist/theme/components/accordion.d.ts +25 -0
  60. package/dist/theme/components/breadcrumb.d.ts +90 -0
  61. package/dist/theme/components/button.d.ts +109 -0
  62. package/dist/theme/components/checkbox.d.ts +91 -0
  63. package/dist/theme/components/customCheckboxGroup.d.ts +18 -0
  64. package/dist/theme/components/customRadioGroup.d.ts +18 -0
  65. package/dist/theme/components/global.d.ts +55 -0
  66. package/dist/theme/components/globalMixins.d.ts +15 -0
  67. package/dist/theme/components/heading.d.ts +110 -0
  68. package/dist/theme/components/hero.d.ts +492 -0
  69. package/dist/theme/components/icon.d.ts +13 -0
  70. package/dist/theme/components/label.d.ts +16 -0
  71. package/dist/theme/components/link.d.ts +45 -0
  72. package/dist/theme/components/radio.d.ts +95 -0
  73. package/dist/theme/components/searchBar.d.ts +20 -0
  74. package/dist/theme/components/select.d.ts +58 -0
  75. package/dist/theme/components/statusBadge.d.ts +25 -0
  76. package/dist/theme/components/tabs.d.ts +85 -0
  77. package/dist/theme/components/template.d.ts +105 -0
  78. package/dist/theme/components/text.d.ts +20 -0
  79. package/dist/theme/components/textInput.d.ts +105 -0
  80. package/dist/theme/foundations/breakpoints.d.ts +23 -0
  81. package/dist/theme/foundations/colors.d.ts +3 -0
  82. package/dist/theme/foundations/global.d.ts +23 -0
  83. package/dist/theme/foundations/shadows.d.ts +4 -0
  84. package/dist/theme/foundations/spacing.d.ts +77 -0
  85. package/dist/theme/foundations/typography.d.ts +8 -0
  86. package/dist/theme/index.d.ts +20 -0
  87. package/dist/theme/provider.d.ts +5 -0
  88. package/dist/theme/types.d.ts +1 -0
  89. package/dist/utils/utils.d.ts +6 -0
  90. package/package.json +9 -2
  91. package/src/components/Accordion/Accordion.stories.mdx +233 -33
  92. package/src/components/Accordion/Accordion.test.tsx +135 -19
  93. package/src/components/Accordion/Accordion.tsx +81 -56
  94. package/src/components/Autosuggest/Autosuggest.stories.mdx +4 -3
  95. package/src/components/Autosuggest/Autosuggest.stories.tsx +1 -1
  96. package/src/components/Autosuggest/_Autosuggest.scss +2 -2
  97. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +57 -56
  98. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +31 -25
  99. package/src/components/Breadcrumbs/Breadcrumbs.tsx +71 -73
  100. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +6 -0
  101. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +100 -0
  102. package/src/components/Button/Button.stories.mdx +125 -138
  103. package/src/components/Button/Button.test.tsx +65 -11
  104. package/src/components/Button/Button.tsx +72 -68
  105. package/src/components/Button/ButtonTypes.tsx +4 -2
  106. package/src/components/Button/_Button.scss +7 -92
  107. package/src/components/Button/__snapshots__/Button.test.tsx.snap +58 -3
  108. package/src/components/Card/Card.stories.mdx +694 -0
  109. package/src/components/Card/Card.test.tsx +97 -102
  110. package/src/components/Card/Card.tsx +182 -31
  111. package/src/components/Card/CardTypes.tsx +21 -0
  112. package/src/components/Card/_Card.scss +234 -49
  113. package/src/components/{Card/Card.stories.tsx → CardEdition/CardEdition.stories.tsx} +32 -22
  114. package/src/components/CardEdition/CardEdition.test.tsx +395 -0
  115. package/src/components/CardEdition/CardEdition.tsx +60 -0
  116. package/src/components/CardEdition/_CardEdition.scss +138 -0
  117. package/src/components/Chakra/Box.stories.mdx +57 -0
  118. package/src/components/Chakra/Center.stories.mdx +99 -0
  119. package/src/components/Chakra/Grid.stories.mdx +79 -0
  120. package/src/components/Chakra/Stack.stories.mdx +93 -0
  121. package/src/components/Checkbox/Checkbox.stories.mdx +57 -35
  122. package/src/components/Checkbox/Checkbox.test.tsx +117 -147
  123. package/src/components/Checkbox/Checkbox.tsx +76 -50
  124. package/src/components/Checkbox/__snapshots__/Checkbox.test.tsx.snap +325 -0
  125. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +249 -0
  126. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +345 -0
  127. package/src/components/CheckboxGroup/CheckboxGroup.tsx +148 -0
  128. package/src/components/CheckboxGroup/CheckboxGroupLayoutTypes.tsx +4 -0
  129. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +1360 -0
  130. package/src/components/DatePicker/DatePicker.stories.mdx +284 -0
  131. package/src/components/DatePicker/DatePicker.test.tsx +657 -0
  132. package/src/components/DatePicker/DatePicker.tsx +396 -0
  133. package/src/components/DatePicker/DatePickerTypes.tsx +5 -0
  134. package/src/components/DatePicker/_DatePicker.scss +76 -0
  135. package/src/components/Form/Form.stories.mdx +130 -27
  136. package/src/components/Form/Form.test.tsx +78 -36
  137. package/src/components/Form/Form.tsx +53 -19
  138. package/src/components/Form/FormTypes.tsx +3 -0
  139. package/src/components/Form/__snapshots__/Form.test.tsx.snap +38 -0
  140. package/src/components/Grid/GridTypes.tsx +9 -0
  141. package/src/components/Grid/SimpleGrid.stories.mdx +275 -0
  142. package/src/components/Grid/SimpleGrid.test.tsx +66 -0
  143. package/src/components/Grid/SimpleGrid.tsx +37 -0
  144. package/src/components/Grid/__snapshots__/SimpleGrid.test.tsx.snap +8 -0
  145. package/src/components/Heading/Heading.stories.mdx +63 -33
  146. package/src/components/Heading/Heading.test.tsx +24 -16
  147. package/src/components/Heading/Heading.tsx +54 -38
  148. package/src/components/Heading/{HeadingDisplaySizes.tsx → HeadingTypes.tsx} +9 -0
  149. package/src/components/HelperErrorText/HelperErrorText.stories.tsx +2 -1
  150. package/src/components/HelperErrorText/_HelperErrorText.scss +1 -1
  151. package/src/components/Hero/Hero.stories.mdx +195 -85
  152. package/src/components/Hero/Hero.test.tsx +544 -113
  153. package/src/components/Hero/Hero.tsx +80 -93
  154. package/src/components/Hero/HeroTypes.tsx +17 -5
  155. package/src/components/Hero/__snapshots__/Hero.test.tsx.snap +307 -0
  156. package/src/components/HorizontalRule/HorizontalRule.stories.mdx +6 -1
  157. package/src/components/HorizontalRule/_HorizontalRule.scss +1 -1
  158. package/src/components/Icons/Icon.stories.mdx +89 -74
  159. package/src/components/Icons/Icon.test.tsx +30 -22
  160. package/src/components/Icons/Icon.tsx +63 -61
  161. package/src/components/Icons/IconSvgs.tsx +8 -0
  162. package/src/components/Icons/IconTypes.tsx +80 -60
  163. package/src/components/Image/Image.stories.tsx +2 -1
  164. package/src/components/Input/_Input.scss +2 -2
  165. package/src/components/Label/Label.stories.mdx +77 -0
  166. package/src/components/Label/Label.test.tsx +43 -12
  167. package/src/components/Label/Label.tsx +28 -45
  168. package/src/components/Label/__snapshots__/Label.test.tsx.snap +41 -0
  169. package/src/components/Link/Link.stories.mdx +47 -41
  170. package/src/components/Link/Link.test.tsx +33 -44
  171. package/src/components/Link/Link.tsx +114 -100
  172. package/src/components/List/List.stories.mdx +7 -3
  173. package/src/components/List/List.stories.tsx +14 -9
  174. package/src/components/List/List.test.tsx +12 -8
  175. package/src/components/List/List.tsx +9 -7
  176. package/src/components/List/_List.scss +3 -3
  177. package/src/components/Modal/Modal.stories.mdx +7 -3
  178. package/src/components/Modal/_Modal.scss +1 -1
  179. package/src/components/Notification/Notification.stories.mdx +99 -65
  180. package/src/components/Notification/Notification.test.tsx +3 -16
  181. package/src/components/Notification/Notification.tsx +12 -12
  182. package/src/components/Notification/_Notification.scss +5 -4
  183. package/src/components/Notification/__snapshots__/Notification.test.tsx.snap +1 -1
  184. package/src/components/Pagination/Pagination.stories.mdx +7 -1
  185. package/src/components/Pagination/Pagination.test.tsx +16 -10
  186. package/src/components/Radio/Radio.stories.mdx +57 -46
  187. package/src/components/Radio/Radio.test.tsx +92 -138
  188. package/src/components/Radio/Radio.tsx +70 -69
  189. package/src/components/Radio/__snapshots__/Radio.test.tsx.snap +250 -0
  190. package/src/components/RadioGroup/RadioGroup.stories.mdx +247 -0
  191. package/src/components/RadioGroup/RadioGroup.test.tsx +327 -0
  192. package/src/components/RadioGroup/RadioGroup.tsx +154 -0
  193. package/src/components/RadioGroup/RadioGroupLayoutTypes.tsx +4 -0
  194. package/src/components/RadioGroup/__snapshots__/RadioGroup.test.tsx.snap +1101 -0
  195. package/src/components/SearchBar/SearchBar.Test.tsx +151 -16
  196. package/src/components/SearchBar/SearchBar.stories.mdx +196 -224
  197. package/src/components/SearchBar/SearchBar.tsx +151 -46
  198. package/src/components/Select/Select.stories.mdx +193 -168
  199. package/src/components/Select/Select.test.tsx +129 -324
  200. package/src/components/Select/Select.tsx +120 -160
  201. package/src/components/Select/SelectTypes.tsx +4 -0
  202. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +18 -29
  203. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -7
  204. package/src/components/SkeletonLoader/SkeletonLoader.tsx +4 -2
  205. package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +2 -2
  206. package/src/components/SkeletonLoader/_SkeletonLoader.scss +3 -3
  207. package/src/components/StatusBadge/StatusBadge.stories.mdx +91 -0
  208. package/src/components/StatusBadge/StatusBadge.test.tsx +35 -7
  209. package/src/components/StatusBadge/StatusBadge.tsx +24 -25
  210. package/src/components/StatusBadge/StatusBadgeTypes.tsx +5 -0
  211. package/src/components/StatusBadge/__snapshots__/StatusBadge.test.tsx.snap +28 -0
  212. package/src/components/StyleGuide/Bidirectionality.stories.mdx +112 -90
  213. package/src/components/StyleGuide/Buttons.stories.mdx +98 -100
  214. package/src/components/StyleGuide/Colors.stories.mdx +336 -0
  215. package/src/components/StyleGuide/Forms.stories.mdx +85 -0
  216. package/src/components/StyleGuide/Iconography.stories.mdx +86 -93
  217. package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
  218. package/src/components/StyleGuide/Typography.stories.mdx +164 -166
  219. package/src/components/StyleGuide/UIDocCard.tsx +4 -4
  220. package/src/components/Tabs/Tabs.stories.mdx +221 -0
  221. package/src/components/Tabs/Tabs.test.tsx +264 -0
  222. package/src/components/Tabs/Tabs.tsx +220 -0
  223. package/src/components/Template/Template.stories.mdx +574 -0
  224. package/src/components/Template/Template.test.tsx +124 -0
  225. package/src/components/Template/Template.tsx +226 -0
  226. package/src/components/Text/Text.stories.mdx +70 -0
  227. package/src/components/Text/Text.test.tsx +63 -0
  228. package/src/components/Text/Text.tsx +55 -0
  229. package/src/components/Text/TextTypes.tsx +6 -0
  230. package/src/components/Text/__snapshots__/Text.test.tsx.snap +33 -0
  231. package/src/components/TextInput/TextInput.stories.mdx +90 -90
  232. package/src/components/TextInput/TextInput.test.tsx +103 -83
  233. package/src/components/TextInput/TextInput.tsx +108 -91
  234. package/src/components/TextInput/TextInputTypes.tsx +6 -0
  235. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +2 -1
  236. package/src/components/VideoPlayer/VideoPlayer.tsx +4 -2
  237. package/src/components/VideoPlayer/_VideoPlayer.scss +1 -1
  238. package/src/docs/Chakra.stories.mdx +341 -0
  239. package/src/docs/Intro.stories.mdx +31 -24
  240. package/src/index.ts +70 -5
  241. package/src/styles/01-colors/_colors-brand.scss +6 -4
  242. package/src/styles/01-colors/_colors-utility.scss +14 -15
  243. package/src/styles/03-space/_space-inline.scss +47 -7
  244. package/src/styles/03-space/_space-inset.scss +33 -5
  245. package/src/styles/03-space/_space-stack.scss +48 -8
  246. package/src/styles/base/_02-breakpoints.scss +5 -4
  247. package/src/styles/base/_04-base.scss +2 -1
  248. package/src/styles/base/_place-holder.scss +1 -1
  249. package/src/styles/base/_typography.scss +1 -29
  250. package/src/styles.scss +22 -25
  251. package/src/theme/components/accordion.ts +30 -0
  252. package/src/theme/components/breadcrumb.ts +77 -0
  253. package/src/theme/components/button.ts +125 -0
  254. package/src/theme/components/checkbox.ts +107 -0
  255. package/src/theme/components/customCheckboxGroup.ts +12 -0
  256. package/src/theme/components/customRadioGroup.ts +12 -0
  257. package/src/theme/components/global.ts +71 -0
  258. package/src/theme/components/globalMixins.ts +16 -0
  259. package/src/theme/components/heading.ts +72 -0
  260. package/src/theme/components/hero.ts +239 -0
  261. package/src/theme/components/icon.ts +79 -0
  262. package/src/theme/components/label.ts +17 -0
  263. package/src/theme/components/link.ts +47 -0
  264. package/src/theme/components/radio.ts +106 -0
  265. package/src/theme/components/searchBar.ts +21 -0
  266. package/src/theme/components/select.ts +50 -0
  267. package/src/theme/components/statusBadge.ts +27 -0
  268. package/src/theme/components/tabs.ts +79 -0
  269. package/src/theme/components/template.ts +114 -0
  270. package/src/theme/components/text.ts +31 -0
  271. package/src/theme/components/textInput.ts +61 -0
  272. package/src/theme/foundations/breakpoints.ts +24 -0
  273. package/src/theme/foundations/colors.ts +208 -0
  274. package/src/theme/foundations/global.ts +26 -0
  275. package/src/theme/foundations/shadows.ts +5 -0
  276. package/src/theme/foundations/spacing.ts +85 -0
  277. package/src/theme/foundations/typography.ts +35 -0
  278. package/src/theme/index.ts +88 -0
  279. package/src/theme/provider.tsx +9 -0
  280. package/src/theme/types.ts +1 -0
  281. package/src/utils/componentCategories.ts +56 -21
  282. package/src/utils/utils.ts +13 -0
  283. package/dist/components/Accordion/Accordion.stories.d.ts +0 -5
  284. package/dist/components/Card/Card.stories.d.ts +0 -27
  285. package/dist/components/Label/Label.stories.d.ts +0 -12
  286. package/dist/components/StatusBadge/StatusBadge.stories.d.ts +0 -8
  287. package/dist/components/Template/Template.stories.d.ts +0 -29
  288. package/src/components/Accordion/Accordion.stories.tsx +0 -65
  289. package/src/components/Accordion/_Accordion.scss +0 -81
  290. package/src/components/Breadcrumbs/_Breadcrumbs.scss +0 -97
  291. package/src/components/Checkbox/_Checkbox.scss +0 -97
  292. package/src/components/Form/_Form.scss +0 -28
  293. package/src/components/Heading/_Heading.scss +0 -163
  294. package/src/components/Hero/_Hero.scss +0 -256
  295. package/src/components/Icons/_Icons.scss +0 -116
  296. package/src/components/Label/Label.stories.tsx +0 -30
  297. package/src/components/Label/_Label.scss +0 -22
  298. package/src/components/Link/_Link.scss +0 -73
  299. package/src/components/Radio/_Radio.scss +0 -84
  300. package/src/components/SearchBar/_SearchBar.scss +0 -16
  301. package/src/components/Select/_Select.scss +0 -82
  302. package/src/components/StatusBadge/StatusBadge.stories.tsx +0 -33
  303. package/src/components/StatusBadge/_StatusBadge.scss +0 -23
  304. package/src/components/StyleGuide/Colors.stories.tsx +0 -288
  305. package/src/components/Template/Template.stories.tsx +0 -85
  306. package/src/components/Template/_Template.scss +0 -63
  307. package/src/components/TextInput/_TextInput.scss +0 -59
@@ -1,185 +1,145 @@
1
1
  import React from "react";
2
- import bem from "../../utils/bem";
2
+ import {
3
+ Box,
4
+ Select as ChakraSelect,
5
+ useMultiStyleConfig,
6
+ } from "@chakra-ui/react";
7
+
3
8
  import Label from "../Label/Label";
4
9
  import HelperErrorText from "../HelperErrorText/HelperErrorText";
5
10
  import generateUUID from "../../helpers/generateUUID";
11
+ import { IconNames, IconSizes } from "../Icons/IconTypes";
12
+ import Icon from "../Icons/Icon";
13
+ import { SelectTypes } from "./SelectTypes";
6
14
 
7
15
  export interface SelectProps {
8
- /** DEPRECATED - When passed, will populate the aria-label on the select */
9
- ariaLabel?: string;
10
- /** Additional attributes passed to the <select> tag */
11
- attributes?: { [key: string]: any };
12
- /** BlockName for use with BEM. See how to work with modifiers and BEM here: http://getbem.com/introduction/ */
13
- blockName?: string;
14
- /** ClassName you can add in addition to 'select' */
16
+ /** A class name for the `div` parent element. */
15
17
  className?: string;
16
- children?: React.ReactNode;
17
- /** When true, disables the select */
18
- disabled?: boolean;
19
- /** Helper for modifiers array; adds 'errored' styling */
20
- errored?: boolean;
21
- /** Populates the HelperErrorText for error state */
22
- errorText?: string;
23
- /** DEPRECATED - ID of associated HelperText */
24
- helperTextId?: string;
25
- /** Populates the HelperErrorText for standard state */
18
+ /** Optional string to populate the `HelperErrorText` for the standard state. */
26
19
  helperText?: string;
27
20
  /** ID that other components can cross reference for accessibility purposes */
28
21
  id?: string;
29
- /** DEPRECATED - Attribute indicating that an option with a non-empty string value must be selected */
22
+ /** Optional string to populate the `HelperErrorText` for the error state
23
+ * when `isInvalid` is true. */
24
+ invalidText?: string;
25
+ /** Adds the `disabled` and `aria-disabled` attributes to the select when true */
26
+ isDisabled?: boolean;
27
+ /** Adds the `aria-invalid` attribute to the select when true. This also makes
28
+ * the color theme "NYPL error" red for the select and text. */
29
+ isInvalid?: boolean;
30
+ /** Adds the `required` and `aria-required` attributes to the input when true. */
30
31
  isRequired?: boolean;
31
- /** DEPRECATED - ID of associated label */
32
- labelId?: string;
33
- /** Provides text for a `Label` component if `showLabel` is set to `true`; populates a `aria-label` attribute on the select input if `showLabel` is set to `false`. */
32
+ /** Provides text for a `Label` component if `showLabel` is set to `true`;
33
+ * populates an `aria-label` attribute on the select input if `showLabel` is
34
+ * set to `false`. */
34
35
  labelText: string;
35
- /** Modifiers array for use with BEM. See how to work with modifiers and BEM here: http://getbem.com/introduction/ */
36
- modifiers?: string[];
37
- /** The name of the select element to use in form submission */
36
+ /** Used to reference the select element in forms. */
38
37
  name: string;
39
- /** Passes select's current value to the React state handler */
40
- onBlur?: (event: React.FormEvent) => void;
41
- /** Passes selects' current value to the React state handler */
38
+ /** The callback function to get the selected value.
39
+ * Should be passed along with `value` for controlled components. */
42
40
  onChange?: (event: React.FormEvent) => void;
43
- /** Will add `aria-required: true` and native HTML `required` attribute to the select input */
44
- required?: boolean;
45
- /** The value of the selected option */
46
- selectedOption?: string;
47
- /** Offers the ability to show the label onscreen or hide it. Refer to the `labelText` property for more information. */
41
+ /** Offers the ability to show the select's label onscreen or hide it. Refer
42
+ * to the `labelText` property for more information. */
48
43
  showLabel?: boolean;
44
+ /** Whether or not to display the "Required"/"Optional" text in the label text. */
45
+ showOptReqLabel?: boolean;
46
+ /** The variant to display. */
47
+ type?: SelectTypes;
48
+ /** The value of the selected option.
49
+ * Should be passed along with `onChange` for controlled components. */
50
+ value?: string;
49
51
  }
50
52
 
51
- const Select = React.forwardRef<HTMLSelectElement, SelectProps>(
52
- (props, ref?) => {
53
- const {
54
- ariaLabel = null,
55
- blockName,
56
- children,
57
- className,
58
- errored,
59
- errorText,
60
- helperText,
61
- helperTextId,
62
- isRequired,
63
- labelId,
64
- labelText,
65
- onBlur,
66
- onChange,
67
- name,
68
- required,
69
- attributes = {},
70
- disabled = false,
71
- selectedOption,
72
- showLabel,
73
- } = props;
74
-
75
- const modifiers = props.modifiers ? props.modifiers : [];
76
- const id = props.id || generateUUID();
77
- let ariaLabelledBy = null;
78
-
79
- if (!showLabel) attributes["aria-label"] = labelText;
80
-
81
- if (helperText && showLabel)
82
- attributes["aria-describedby"] = `${id}-helperText`;
83
-
84
- if (errored) modifiers.push("error");
85
-
86
- const req = isRequired || required;
87
- const optReqFlag = req ? "Required" : "Optional";
88
-
89
- const errorOutput = errorText
90
- ? errorText
91
- : "There is an error related to this field.";
92
-
93
- const footnote = errored ? errorOutput : helperText;
94
-
95
- // Support for deprecated prop
96
- if (ariaLabel) attributes["aria-label"] = ariaLabel;
97
-
98
- // Support for deprecated props
99
- if (labelId && !helperTextId) {
100
- ariaLabelledBy = labelId;
101
- } else if (helperTextId && !labelId) {
102
- ariaLabelledBy = helperTextId;
103
- } else if (labelId && helperTextId) {
104
- ariaLabelledBy = labelId + " " + helperTextId;
105
- }
106
-
107
- if (React.Children.count(children) > 10) {
108
- console.warn(
109
- "NYPL DS recommends that <select> fields have no more than 10 options; an auto-complete text input is a good alternative for 11 or more options."
110
- );
111
- }
112
-
113
- if (React.Children.count(children) < 4) {
114
- console.warn(
115
- "NYPL DS recommends that <select> fields have at least 4 options; a radio button group is a good alternative for 3 or fewer options."
116
- );
117
- }
118
-
119
- if (ariaLabel) {
120
- console.warn(
121
- "The ariaLabel prop has been deprecated in the Select component and will be removed in a future release. Check the documentation for updated props."
122
- );
123
- }
124
-
125
- if (helperTextId) {
126
- console.warn(
127
- "The helperTextId prop has been deprecated in the Select component and will be removed in a future release. Check the documentation for updated props."
128
- );
129
- }
53
+ /**
54
+ * Component that renders Chakra's `Select` component along with an accessible
55
+ * `Label` and optional `HelperErrorText` component.
56
+ */
57
+ const Select = React.forwardRef<
58
+ HTMLSelectElement,
59
+ React.PropsWithChildren<SelectProps>
60
+ >((props: React.PropsWithChildren<SelectProps>, ref?) => {
61
+ const {
62
+ children,
63
+ className,
64
+ helperText,
65
+ id = generateUUID(),
66
+ invalidText,
67
+ isDisabled = false,
68
+ isInvalid = false,
69
+ isRequired = false,
70
+ labelText,
71
+ name,
72
+ onChange,
73
+ showLabel = true,
74
+ showOptReqLabel = true,
75
+ type = SelectTypes.Default,
76
+ value,
77
+ } = props;
78
+ const ariaAttributes = {};
79
+ const optReqFlag = isRequired ? "Required" : "Optional";
80
+ const styles = useMultiStyleConfig("CustomSelect", { variant: type });
81
+ const finalInvalidText = invalidText
82
+ ? invalidText
83
+ : "There is an error related to this field.";
84
+ const footnote = isInvalid ? finalInvalidText : helperText;
85
+ // To control the `Select` component, both `onChange` and `value`
86
+ // must be passed.
87
+ const controlledProps = onChange && value ? { onChange, value } : {};
88
+
89
+ if (!showLabel) {
90
+ ariaAttributes["aria-label"] =
91
+ labelText && footnote ? `${labelText} - ${footnote}` : labelText;
92
+ } else if (helperText) {
93
+ ariaAttributes["aria-describedby"] = `${id}-helperText`;
94
+ }
130
95
 
131
- if (isRequired === true || isRequired === false) {
132
- console.warn(
133
- "The isRequired prop has been deprecated in the Select component and will be removed in a future release. Check the documentation for updated props."
134
- );
135
- }
96
+ if (React.Children.count(children) > 10) {
97
+ console.warn(
98
+ "NYPL DS recommends that <select> fields have no more than 10 options; an auto-complete text input is a good alternative for 11 or more options."
99
+ );
100
+ }
136
101
 
137
- if (labelId) {
138
- console.warn(
139
- "The labelId prop has been deprecated in the Select component and will be removed in a future release. Check the documentation for updated props."
140
- );
141
- }
102
+ if (React.Children.count(children) < 4) {
103
+ console.warn(
104
+ "NYPL DS recommends that <select> fields have at least 4 options; a radio button group is a good alternative for 3 or fewer options."
105
+ );
106
+ }
142
107
 
143
- return (
144
- <div className="select">
145
- {labelText && showLabel && (
146
- <Label htmlFor={id} optReqFlag={optReqFlag} id={id + `-label`}>
147
- {labelText}
148
- </Label>
149
- )}
150
- <select
151
- name={name}
152
- id={id}
153
- className={bem("selectfield", modifiers, blockName, [className])}
154
- aria-required={req}
155
- required={req}
156
- disabled={disabled}
157
- aria-label={ariaLabel}
158
- aria-labelledby={ariaLabelledBy}
159
- value={selectedOption}
160
- ref={ref}
161
- onBlur={onBlur}
162
- onChange={onChange}
163
- {...attributes}
108
+ return (
109
+ <Box className={className} __css={styles}>
110
+ {showLabel && (
111
+ <Label
112
+ id={`${id}-label`}
113
+ htmlFor={id}
114
+ optReqFlag={showOptReqLabel && optReqFlag}
164
115
  >
165
- {React.Children.map(children, (child, key) => {
166
- return React.cloneElement(child as React.ReactElement<any>, {
167
- "aria-selected": children[key]
168
- ? children[key].props.children === selectedOption
169
- : false,
170
- });
171
- })}
172
- </select>
173
- {(helperText || errored) && (
174
- <HelperErrorText isError={errored} id={id + `-helperText`}>
116
+ {labelText}
117
+ </Label>
118
+ )}
119
+ <ChakraSelect
120
+ id={id}
121
+ variant="outline"
122
+ isRequired={isRequired}
123
+ isDisabled={isDisabled}
124
+ isInvalid={isInvalid}
125
+ name={name}
126
+ ref={ref}
127
+ {...controlledProps}
128
+ {...ariaAttributes}
129
+ icon={<Icon name={IconNames.Arrow} size={IconSizes.Medium} />}
130
+ __css={styles.select}
131
+ >
132
+ {children}
133
+ </ChakraSelect>
134
+ {footnote && (
135
+ <Box __css={styles.helper} aria-disabled={isDisabled}>
136
+ <HelperErrorText isError={isInvalid} id={id + `-helperText`}>
175
137
  {footnote}
176
138
  </HelperErrorText>
177
- )}
178
- </div>
179
- );
180
- }
181
- );
182
-
183
- Select.displayName = "Select";
139
+ </Box>
140
+ )}
141
+ </Box>
142
+ );
143
+ });
184
144
 
185
145
  export default Select;
@@ -0,0 +1,4 @@
1
+ export enum SelectTypes {
2
+ Default = "default",
3
+ SearchBar = "searchbar",
4
+ }
@@ -14,9 +14,10 @@ import {
14
14
  SkeletonLoaderImageRatios,
15
15
  } from "./SkeletonLoaderTypes";
16
16
  import { action } from "@storybook/addon-actions";
17
+ import { getCategory } from "../../utils/componentCategories";
17
18
 
18
19
  <Meta
19
- title="Skeleton Loader"
20
+ title={getCategory("SkeletonLoader")}
20
21
  component={SkeletonLoader}
21
22
  decorators={[withDesign]}
22
23
  parameters={{
@@ -32,7 +33,7 @@ import { action } from "@storybook/addon-actions";
32
33
  className: { table: { disable: true } },
33
34
  modifiers: { table: { disable: true } },
34
35
  layout: {
35
- table: { defaultValue: { summary: "vertical" } },
36
+ table: { defaultValue: { summary: "column" } },
36
37
  },
37
38
  showImage: {
38
39
  table: { defaultValue: { summary: "true" } },
@@ -58,7 +59,7 @@ import { action } from "@storybook/addon-actions";
58
59
  }}
59
60
  />
60
61
 
61
- # Skeleton Loader
62
+ # SkeletonLoader
62
63
 
63
64
  | Component Version | DS Version |
64
65
  | ----------------- | ---------- |
@@ -67,13 +68,16 @@ import { action } from "@storybook/addon-actions";
67
68
 
68
69
  <Description of={SkeletonLoader} />
69
70
 
70
- The `SkeletonLoader` component renders a placeholder to be used while dynamic content is loading. The `layout`, `width` and placeholder elements within the `SkeletonLoader` can be customized.
71
+ The `SkeletonLoader` component renders a placeholder to be used while dynamic
72
+ content is loading. The `layout`, `width` and placeholder elements within the
73
+ `SkeletonLoader` can be customized.
71
74
 
72
- Please note that the initial rendering below has the `width` prop set to `300px`. The default value is `100%`.
75
+ Please note that the initial rendering below has the `width` prop set to `300px`.
76
+ The default value is `100%`.
73
77
 
74
78
  <Preview withToolbar>
75
79
  <Story
76
- name="Skeleton Loader"
80
+ name="SkeletonLoader"
77
81
  args={{
78
82
  width: "300px",
79
83
  }}
@@ -82,7 +86,7 @@ Please note that the initial rendering below has the `width` prop set to `300px`
82
86
  </Story>
83
87
  </Preview>
84
88
 
85
- <ArgsTable story="Skeleton Loader" />
89
+ <ArgsTable story="SkeletonLoader" />
86
90
 
87
91
  # Card Placeholders in a Grid
88
92
 
@@ -92,7 +96,7 @@ Please note that the initial rendering below has the `width` prop set to `300px`
92
96
  style={{
93
97
  display: "grid",
94
98
  gap: "2rem",
95
- "grid-template-columns": "repeat(3, 1fr)",
99
+ gridTemplateColumns: "repeat(3, 1fr)",
96
100
  }}
97
101
  >
98
102
  <SkeletonLoader
@@ -131,29 +135,14 @@ Please note that the initial rendering below has the `width` prop set to `300px`
131
135
  style={{
132
136
  display: "grid",
133
137
  gap: "2rem",
134
- "grid-template-columns": "repeat(1, 1fr)",
138
+ gridTemplateColumns: "repeat(1, 1fr)",
135
139
  }}
136
140
  >
137
- <SkeletonLoader
138
- layout={SkeletonLoaderLayouts.Horizontal}
139
- showImage={false}
140
- />
141
- <SkeletonLoader
142
- layout={SkeletonLoaderLayouts.Horizontal}
143
- showImage={false}
144
- />
145
- <SkeletonLoader
146
- layout={SkeletonLoaderLayouts.Horizontal}
147
- showImage={false}
148
- />
149
- <SkeletonLoader
150
- layout={SkeletonLoaderLayouts.Horizontal}
151
- showImage={false}
152
- />
153
- <SkeletonLoader
154
- layout={SkeletonLoaderLayouts.Horizontal}
155
- showImage={false}
156
- />
141
+ <SkeletonLoader layout={SkeletonLoaderLayouts.Row} showImage={false} />
142
+ <SkeletonLoader layout={SkeletonLoaderLayouts.Row} showImage={false} />
143
+ <SkeletonLoader layout={SkeletonLoaderLayouts.Row} showImage={false} />
144
+ <SkeletonLoader layout={SkeletonLoaderLayouts.Row} showImage={false} />
145
+ <SkeletonLoader layout={SkeletonLoaderLayouts.Row} showImage={false} />
157
146
  </div>
158
147
  </Story>
159
148
  </Preview>
@@ -26,7 +26,7 @@ describe("SkeletonLoader", () => {
26
26
  expect(container.querySelector(".skeleton-loader")).toBeInTheDocument();
27
27
  expect(container.querySelector(".skeleton-loader")).toHaveAttribute(
28
28
  "class",
29
- "skeleton-loader skeleton-loader--vertical "
29
+ "skeleton-loader skeleton-loader--column "
30
30
  );
31
31
  expect(container.querySelector(".skeleton-loader")).not.toHaveAttribute(
32
32
  "class",
@@ -34,27 +34,27 @@ describe("SkeletonLoader", () => {
34
34
  );
35
35
  });
36
36
 
37
- it("renders vertical layout", () => {
37
+ it("renders column layout", () => {
38
38
  const utils = render(
39
- <SkeletonLoader layout={SkeletonLoaderLayouts.Vertical} />
39
+ <SkeletonLoader layout={SkeletonLoaderLayouts.Column} />
40
40
  );
41
41
  container = utils.container;
42
42
 
43
43
  expect(container.querySelector(".skeleton-loader")).toBeInTheDocument();
44
44
  expect(
45
- container.querySelector(".skeleton-loader--vertical")
45
+ container.querySelector(".skeleton-loader--column")
46
46
  ).toBeInTheDocument();
47
47
  });
48
48
 
49
- it("renders horizontal layout", () => {
49
+ it("renders row layout", () => {
50
50
  const utils = render(
51
- <SkeletonLoader layout={SkeletonLoaderLayouts.Horizontal} />
51
+ <SkeletonLoader layout={SkeletonLoaderLayouts.Row} />
52
52
  );
53
53
  container = utils.container;
54
54
 
55
55
  expect(container.querySelector(".skeleton-loader")).toBeInTheDocument();
56
56
  expect(
57
- container.querySelector(".skeleton-loader--horizontal")
57
+ container.querySelector(".skeleton-loader--row")
58
58
  ).toBeInTheDocument();
59
59
  });
60
60
  });
@@ -16,7 +16,7 @@ export interface SkeletonLoaderProps {
16
16
  headingSize?: number;
17
17
  /** Optional value to control the aspect ratio of the image placeholder; default value is `square` */
18
18
  imageAspectRatio?: SkeletonLoaderImageRatios;
19
- /** Optional value to control the position of the image placeholder; default value is `vertical` */
19
+ /** Optional value to control the position of the image placeholder; default value is `column` */
20
20
  layout?: SkeletonLoaderLayouts;
21
21
  /** Modifiers array for use with BEM. See how to work with modifiers and BEM here: http://getbem.com/introduction/ */
22
22
  modifiers?: string[];
@@ -41,7 +41,7 @@ export default function SkeletonLoader(
41
41
  contentSize = 3,
42
42
  headingSize = 1,
43
43
  imageAspectRatio = SkeletonLoaderImageRatios.Square,
44
- layout = SkeletonLoaderLayouts.Vertical,
44
+ layout = SkeletonLoaderLayouts.Column,
45
45
  showButton = false,
46
46
  showContent = true,
47
47
  showImage = true,
@@ -61,6 +61,7 @@ export default function SkeletonLoader(
61
61
  for (let i = 0; i < headingSize; i++) {
62
62
  headingItems.push(
63
63
  <div
64
+ key={`heading-${i}`}
64
65
  className={bem("skeleton-loader-heading", imageModifiers, "", [
65
66
  "skeleton-element",
66
67
  ])}
@@ -72,6 +73,7 @@ export default function SkeletonLoader(
72
73
  for (let i = 0; i < contentSize; i++) {
73
74
  contentItems.push(
74
75
  <div
76
+ key={`content-${i}`}
75
77
  className={bem("skeleton-loader-content", imageModifiers, "", [
76
78
  "skeleton-element",
77
79
  ])}
@@ -1,6 +1,6 @@
1
1
  export enum SkeletonLoaderLayouts {
2
- Horizontal = "horizontal",
3
- Vertical = "vertical",
2
+ Row = "row",
3
+ Column = "column",
4
4
  }
5
5
 
6
6
  export enum SkeletonLoaderImageRatios {
@@ -1,6 +1,6 @@
1
1
  @mixin skeleton-highlight {
2
2
  animation: Pulsate 1000ms cubic-bezier(0.25, -0.5, 1, 0) infinite;
3
- background: var(--ui-gray-warm-light);
3
+ background: var(--ui-gray-light-warm);
4
4
  }
5
5
 
6
6
  .skeleton-loader {
@@ -79,11 +79,11 @@
79
79
  }
80
80
 
81
81
  &--border {
82
- border: 1px solid var(--ui-gray-light);
82
+ border: 1px solid var(--ui-gray-light-cool);
83
83
  padding: var(--space-s);
84
84
  }
85
85
 
86
- &--horizontal {
86
+ &--row {
87
87
  @include breakpoint($breakpoint-medium) {
88
88
  display: flex;
89
89
 
@@ -0,0 +1,91 @@
1
+ import {
2
+ Meta,
3
+ Story,
4
+ Canvas,
5
+ ArgsTable,
6
+ Description,
7
+ } from "@storybook/addon-docs/blocks";
8
+ import { withDesign } from "storybook-addon-designs";
9
+ import { VStack } from "@chakra-ui/react";
10
+
11
+ import StatusBadge from "./StatusBadge";
12
+ import { StatusBadgeTypes } from "./StatusBadgeTypes";
13
+ import getCSSVariable from "../../helpers/getCSSVariable";
14
+ import { getCategory } from "../../utils/componentCategories";
15
+ import DSProvider from "../../theme/provider";
16
+
17
+ <Meta
18
+ title={getCategory("StatusBadge")}
19
+ component={StatusBadge}
20
+ decorators={[withDesign]}
21
+ parameters={{
22
+ design: {
23
+ type: "figma",
24
+ url:
25
+ "https://www.figma.com/file/qShodlfNCJHb8n03IFyApM/Main?node-id=11256%3A0",
26
+ },
27
+ jest: ["StatusBadge.test.tsx"],
28
+ }}
29
+ argTypes={{
30
+ className: { table: { disable: true } },
31
+ id: { table: { disable: true } },
32
+ level: {
33
+ control: {
34
+ type: "select",
35
+ },
36
+ options: Object.values(StatusBadgeTypes).map((value) => value),
37
+ },
38
+ }}
39
+ />
40
+
41
+ # StatusBadge
42
+
43
+ | Component Version | DS Version |
44
+ | ----------------- | ---------- |
45
+ | Added | `0.18.7` |
46
+ | Latest | `0.25.1` |
47
+
48
+ <Description of={StatusBadge} />
49
+
50
+ <Canvas withToolbar>
51
+ <Story
52
+ name="Basic with props"
53
+ args={{ level: StatusBadgeTypes.Low, text: "Registration Required" }}
54
+ >
55
+ {(args) => <StatusBadge {...args}>{args.text}</StatusBadge>}
56
+ </Story>
57
+ </Canvas>
58
+
59
+ <ArgsTable story="Basic with props" />
60
+
61
+ ## Patterns
62
+
63
+ ### Higher Barrier
64
+
65
+ Used in instances where the associated message is the highest barrier. Use
66
+ `"high"` and `"medium"` for these levels.
67
+
68
+ <Canvas>
69
+ <DSProvider>
70
+ <VStack spacing="s" align="stretch">
71
+ <StatusBadge level={StatusBadgeTypes.High}>
72
+ On-Site Access Only
73
+ </StatusBadge>
74
+ <StatusBadge level={StatusBadgeTypes.Medium}>Cancelled</StatusBadge>
75
+ </VStack>
76
+ </DSProvider>
77
+ </Canvas>
78
+
79
+ ### Lower Barrier
80
+
81
+ Used in instances where the associated message is the lower barrier. Use
82
+ `"low"` for this level which is the default.
83
+
84
+ <Canvas>
85
+ <DSProvider>
86
+ <VStack spacing="s" align="stretch">
87
+ <StatusBadge>Library Card Required</StatusBadge>
88
+ <StatusBadge>Registration Required</StatusBadge>
89
+ </VStack>
90
+ </DSProvider>
91
+ </Canvas>