@nypl/design-system-react-components 0.27.0 → 0.28.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 (298) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/components/Accordion/Accordion.d.ts +1 -1
  3. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +1 -5
  4. package/dist/components/Button/Button.d.ts +2 -10
  5. package/dist/components/ButtonGroup/ButtonGroup.d.ts +22 -0
  6. package/dist/components/Card/Card.d.ts +2 -2
  7. package/dist/components/Checkbox/Checkbox.d.ts +10 -8
  8. package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +1 -1
  9. package/dist/components/DatePicker/DatePicker.d.ts +1 -1
  10. package/dist/components/Form/Form.d.ts +2 -2
  11. package/dist/components/Grid/SimpleGrid.d.ts +6 -3
  12. package/dist/components/Heading/Heading.d.ts +2 -5
  13. package/dist/components/HelperErrorText/HelperErrorText.d.ts +1 -5
  14. package/dist/components/Hero/Hero.d.ts +13 -9
  15. package/dist/components/Icons/Icon.d.ts +6 -5
  16. package/dist/components/Icons/IconSvgs.d.ts +21 -21
  17. package/dist/components/Image/Image.d.ts +8 -5
  18. package/dist/components/Link/Link.d.ts +1 -9
  19. package/dist/components/List/List.d.ts +7 -11
  20. package/dist/components/Logo/Logo.d.ts +2 -5
  21. package/dist/components/Logo/LogoSvgs.d.ts +39 -39
  22. package/dist/components/Notification/Notification.d.ts +1 -1
  23. package/dist/components/ProgressIndicator/ProgressIndicator.d.ts +2 -1
  24. package/dist/components/RadioGroup/RadioGroup.d.ts +1 -1
  25. package/dist/components/SearchBar/SearchBar.d.ts +3 -2
  26. package/dist/components/Select/Select.d.ts +2 -5
  27. package/dist/components/SkeletonLoader/SkeletonLoader.d.ts +4 -4
  28. package/dist/components/SkipNavigation/SkipNavigation.d.ts +17 -0
  29. package/dist/components/StatusBadge/StatusBadge.d.ts +2 -3
  30. package/dist/components/StructuredContent/StructuredContent.d.ts +2 -2
  31. package/dist/components/Table/Table.d.ts +1 -1
  32. package/dist/components/Template/Template.d.ts +2 -0
  33. package/dist/components/Text/Text.d.ts +1 -1
  34. package/dist/components/TextInput/TextInput.d.ts +21 -9
  35. package/dist/components/Toggle/Toggle.d.ts +1 -5
  36. package/dist/components/VideoPlayer/VideoPlayer.d.ts +2 -1
  37. package/dist/design-system-react-components.cjs.development.js +856 -1155
  38. package/dist/design-system-react-components.cjs.development.js.map +1 -1
  39. package/dist/design-system-react-components.cjs.production.min.js +1 -1
  40. package/dist/design-system-react-components.cjs.production.min.js.map +1 -1
  41. package/dist/design-system-react-components.esm.js +858 -1220
  42. package/dist/design-system-react-components.esm.js.map +1 -1
  43. package/dist/helpers/types.d.ts +1 -0
  44. package/dist/index.d.ts +26 -47
  45. package/dist/theme/components/buttonGroup.d.ts +11 -0
  46. package/dist/theme/components/card.d.ts +104 -8
  47. package/dist/theme/components/componentWrapper.d.ts +4 -3
  48. package/dist/theme/components/customTable.d.ts +11 -14
  49. package/dist/theme/components/fieldset.d.ts +4 -3
  50. package/dist/theme/components/helperErrorText.d.ts +4 -3
  51. package/dist/theme/components/hero.d.ts +1 -1
  52. package/dist/theme/components/horizontalRule.d.ts +4 -3
  53. package/dist/theme/components/icon.d.ts +47743 -1
  54. package/dist/theme/components/image.d.ts +563 -10
  55. package/dist/theme/components/label.d.ts +4 -3
  56. package/dist/theme/components/list.d.ts +6 -7
  57. package/dist/theme/components/logo.d.ts +474 -1
  58. package/dist/theme/components/notification.d.ts +20 -16
  59. package/dist/theme/components/progressIndicator.d.ts +6 -4
  60. package/dist/theme/components/select.d.ts +4 -4
  61. package/dist/theme/components/skeletonLoader.d.ts +14 -10
  62. package/dist/theme/components/skipNavigation.d.ts +22 -0
  63. package/dist/theme/components/slider.d.ts +7 -6
  64. package/dist/theme/components/structuredContent.d.ts +10 -9
  65. package/dist/theme/components/text.d.ts +7 -1
  66. package/dist/theme/components/toggle.d.ts +6 -4
  67. package/dist/theme/provider.d.ts +2 -4
  68. package/dist/utils/componentCategories.d.ts +1 -1
  69. package/dist/utils/interfaces.d.ts +5 -0
  70. package/dist/utils/utils.d.ts +2 -18
  71. package/package.json +2 -2
  72. package/src/__tests__/setup.ts +3 -3
  73. package/src/__tests__/utils/utils.test.ts +1 -23
  74. package/src/components/AccessibilityGuide/SkipNavigation.stories.mdx +22 -14
  75. package/src/components/Accordion/Accordion.stories.mdx +43 -44
  76. package/src/components/Accordion/Accordion.test.tsx +5 -13
  77. package/src/components/Accordion/Accordion.tsx +14 -18
  78. package/src/components/Accordion/__snapshots__/Accordion.test.tsx.snap +6 -6
  79. package/src/components/Autosuggest/Autosuggest.stories.mdx +1 -1
  80. package/src/components/Autosuggest/Autosuggest.stories.tsx +23 -25
  81. package/src/components/Breadcrumbs/Breadcrumbs.stories.mdx +21 -37
  82. package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +4 -17
  83. package/src/components/Breadcrumbs/Breadcrumbs.tsx +18 -21
  84. package/src/components/Breadcrumbs/__snapshots__/Breadcrumbs.test.tsx.snap +1 -100
  85. package/src/components/Button/Button.stories.mdx +89 -126
  86. package/src/components/Button/Button.test.tsx +16 -30
  87. package/src/components/Button/Button.tsx +14 -20
  88. package/src/components/ButtonGroup/ButtonGroup.stories.mdx +147 -0
  89. package/src/components/ButtonGroup/ButtonGroup.test.tsx +141 -0
  90. package/src/components/ButtonGroup/ButtonGroup.tsx +99 -0
  91. package/src/components/ButtonGroup/__snapshots__/ButtonGroup.test.tsx.snap +117 -0
  92. package/src/components/Card/Card.stories.mdx +143 -177
  93. package/src/components/Card/Card.test.tsx +36 -97
  94. package/src/components/Card/Card.tsx +78 -74
  95. package/src/components/Chakra/Box.stories.mdx +2 -6
  96. package/src/components/Chakra/Center.stories.mdx +5 -23
  97. package/src/components/Chakra/Flex.stories.mdx +4 -6
  98. package/src/components/Chakra/Stack.stories.mdx +9 -10
  99. package/src/components/Checkbox/Checkbox.stories.mdx +1 -1
  100. package/src/components/Checkbox/Checkbox.test.tsx +2 -2
  101. package/src/components/Checkbox/Checkbox.tsx +20 -13
  102. package/src/components/CheckboxGroup/CheckboxGroup.stories.mdx +6 -17
  103. package/src/components/CheckboxGroup/CheckboxGroup.test.tsx +1 -7
  104. package/src/components/CheckboxGroup/CheckboxGroup.tsx +33 -29
  105. package/src/components/CheckboxGroup/__snapshots__/CheckboxGroup.test.tsx.snap +0 -11
  106. package/src/components/ComponentWrapper/ComponentWrapper.tsx +3 -10
  107. package/src/components/DatePicker/DatePicker.stories.mdx +23 -37
  108. package/src/components/DatePicker/DatePicker.test.tsx +21 -19
  109. package/src/components/DatePicker/DatePicker.tsx +57 -49
  110. package/src/components/Form/Form.stories.mdx +46 -31
  111. package/src/components/Form/Form.test.tsx +1 -18
  112. package/src/components/Form/Form.tsx +7 -7
  113. package/src/components/Grid/SimpleGrid.stories.mdx +73 -49
  114. package/src/components/Grid/SimpleGrid.test.tsx +7 -9
  115. package/src/components/Grid/SimpleGrid.tsx +14 -11
  116. package/src/components/Heading/Heading.stories.mdx +27 -72
  117. package/src/components/Heading/Heading.test.tsx +18 -44
  118. package/src/components/Heading/Heading.tsx +7 -10
  119. package/src/components/HelperErrorText/HelperErrorText.stories.mdx +1 -3
  120. package/src/components/HelperErrorText/HelperErrorText.tsx +1 -5
  121. package/src/components/Hero/Hero.stories.mdx +219 -216
  122. package/src/components/Hero/Hero.test.tsx +107 -223
  123. package/src/components/Hero/Hero.tsx +63 -61
  124. package/src/components/Icons/Icon.stories.mdx +172 -118
  125. package/src/components/Icons/Icon.test.tsx +8 -16
  126. package/src/components/Icons/Icon.tsx +75 -29
  127. package/src/components/Icons/IconSvgs.tsx +42 -42
  128. package/src/components/Image/Image.stories.mdx +45 -132
  129. package/src/components/Image/Image.test.tsx +16 -31
  130. package/src/components/Image/Image.tsx +28 -12
  131. package/src/components/Link/Link.stories.mdx +30 -80
  132. package/src/components/Link/Link.test.tsx +25 -53
  133. package/src/components/Link/Link.tsx +43 -56
  134. package/src/components/Link/__snapshots__/Link.test.tsx.snap +1 -2
  135. package/src/components/List/List.stories.mdx +20 -31
  136. package/src/components/List/List.test.tsx +24 -43
  137. package/src/components/List/List.tsx +25 -36
  138. package/src/components/Logo/Logo.stories.mdx +94 -50
  139. package/src/components/Logo/Logo.test.tsx +10 -19
  140. package/src/components/Logo/Logo.tsx +50 -17
  141. package/src/components/Logo/LogoSvgs.tsx +78 -78
  142. package/src/components/Logo/__snapshots__/Logo.test.tsx.snap +4 -4
  143. package/src/components/Modal/Modal.stories.mdx +8 -9
  144. package/src/components/Modal/Modal.test.tsx +5 -10
  145. package/src/components/Modal/Modal.tsx +1 -1
  146. package/src/components/Notification/Notification.stories.mdx +10 -28
  147. package/src/components/Notification/Notification.test.tsx +9 -12
  148. package/src/components/Notification/Notification.tsx +34 -37
  149. package/src/components/Pagination/Pagination.stories.mdx +2 -2
  150. package/src/components/Pagination/Pagination.tsx +15 -10
  151. package/src/components/ProgressIndicator/ProgressIndicator.stories.mdx +27 -53
  152. package/src/components/ProgressIndicator/ProgressIndicator.test.tsx +9 -10
  153. package/src/components/ProgressIndicator/ProgressIndicator.tsx +17 -21
  154. package/src/components/ProgressIndicator/__snapshots__/ProgressIndicator.test.tsx.snap +0 -10
  155. package/src/components/Radio/Radio.stories.mdx +1 -1
  156. package/src/components/Radio/Radio.tsx +9 -6
  157. package/src/components/RadioGroup/RadioGroup.stories.mdx +15 -16
  158. package/src/components/RadioGroup/RadioGroup.test.tsx +2 -8
  159. package/src/components/RadioGroup/RadioGroup.tsx +28 -24
  160. package/src/components/SearchBar/SearchBar.stories.mdx +1 -1
  161. package/src/components/SearchBar/SearchBar.test.tsx +1 -1
  162. package/src/components/SearchBar/SearchBar.tsx +14 -22
  163. package/src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap +0 -12
  164. package/src/components/Select/Select.stories.mdx +8 -23
  165. package/src/components/Select/Select.test.tsx +6 -7
  166. package/src/components/Select/Select.tsx +13 -26
  167. package/src/components/SkeletonLoader/SkeletonLoader.stories.mdx +17 -56
  168. package/src/components/SkeletonLoader/SkeletonLoader.test.tsx +7 -21
  169. package/src/components/SkeletonLoader/SkeletonLoader.tsx +9 -8
  170. package/src/components/SkeletonLoader/__snapshots__/SkeletonLoader.test.tsx.snap +33 -33
  171. package/src/components/SkipNavigation/SkipNavigation.stories.mdx +90 -0
  172. package/src/components/SkipNavigation/SkipNavigation.test.tsx +63 -0
  173. package/src/components/SkipNavigation/SkipNavigation.tsx +51 -0
  174. package/src/components/SkipNavigation/__snapshots__/SkipNavigation.test.tsx.snap +130 -0
  175. package/src/components/Slider/Slider.stories.mdx +19 -53
  176. package/src/components/Slider/Slider.test.tsx +2 -2
  177. package/src/components/Slider/Slider.tsx +10 -12
  178. package/src/components/Slider/__snapshots__/Slider.test.tsx.snap +2 -9
  179. package/src/components/StatusBadge/StatusBadge.stories.mdx +6 -21
  180. package/src/components/StatusBadge/StatusBadge.test.tsx +2 -3
  181. package/src/components/StatusBadge/StatusBadge.tsx +3 -10
  182. package/src/components/StructuredContent/StructuredContent.stories.mdx +30 -58
  183. package/src/components/StructuredContent/StructuredContent.test.tsx +42 -44
  184. package/src/components/StructuredContent/StructuredContent.tsx +9 -18
  185. package/src/components/StyleGuide/Bidirectionality.stories.mdx +9 -23
  186. package/src/components/StyleGuide/Buttons.stories.mdx +62 -62
  187. package/src/components/StyleGuide/ColorCard.tsx +2 -4
  188. package/src/components/StyleGuide/Colors.stories.mdx +7 -8
  189. package/src/components/StyleGuide/DesignTokens.stories.mdx +5 -7
  190. package/src/components/StyleGuide/Forms.stories.mdx +0 -1
  191. package/src/components/StyleGuide/Iconography.stories.mdx +59 -77
  192. package/src/components/StyleGuide/Spacing.stories.mdx +0 -1
  193. package/src/components/StyleGuide/Typography.stories.mdx +15 -18
  194. package/src/components/Table/Table.stories.mdx +85 -1
  195. package/src/components/Table/Table.test.tsx +57 -1
  196. package/src/components/Table/Table.tsx +7 -4
  197. package/src/components/Table/__snapshots__/Table.test.tsx.snap +121 -0
  198. package/src/components/Tabs/Tabs.stories.mdx +1 -1
  199. package/src/components/Tabs/Tabs.test.tsx +2 -2
  200. package/src/components/Tabs/Tabs.tsx +26 -27
  201. package/src/components/Template/Template.stories.mdx +49 -54
  202. package/src/components/Template/Template.tsx +9 -3
  203. package/src/components/Text/Text.stories.mdx +5 -11
  204. package/src/components/Text/Text.test.tsx +3 -6
  205. package/src/components/Text/Text.tsx +3 -5
  206. package/src/components/TextInput/TextInput.stories.mdx +10 -22
  207. package/src/components/TextInput/TextInput.test.tsx +32 -62
  208. package/src/components/TextInput/TextInput.tsx +61 -30
  209. package/src/components/TextInput/__snapshots__/TextInput.test.tsx.snap +1 -0
  210. package/src/components/Toggle/Toggle.stories.mdx +5 -16
  211. package/src/components/Toggle/Toggle.test.tsx +2 -3
  212. package/src/components/Toggle/Toggle.tsx +9 -10
  213. package/src/components/VideoPlayer/VideoPlayer.stories.mdx +13 -29
  214. package/src/components/VideoPlayer/VideoPlayer.test.tsx +18 -23
  215. package/src/components/VideoPlayer/VideoPlayer.tsx +13 -10
  216. package/src/docs/Chakra.stories.mdx +14 -11
  217. package/src/docs/Welcome.stories.mdx +23 -43
  218. package/src/helpers/types.ts +1 -0
  219. package/src/hooks/tests/useNYPLTheme.test.tsx +1 -1
  220. package/src/hooks/useNYPLTheme.stories.mdx +3 -6
  221. package/src/index.ts +51 -45
  222. package/src/theme/components/buttonGroup.ts +10 -0
  223. package/src/theme/components/card.ts +50 -15
  224. package/src/theme/components/componentWrapper.ts +5 -1
  225. package/src/theme/components/customTable.ts +8 -2
  226. package/src/theme/components/fieldset.ts +5 -1
  227. package/src/theme/components/helperErrorText.ts +5 -1
  228. package/src/theme/components/hero.ts +2 -2
  229. package/src/theme/components/horizontalRule.ts +5 -1
  230. package/src/theme/components/icon.ts +7 -1
  231. package/src/theme/components/image.ts +14 -3
  232. package/src/theme/components/label.ts +5 -1
  233. package/src/theme/components/list.ts +8 -2
  234. package/src/theme/components/logo.ts +5 -1
  235. package/src/theme/components/notification.ts +38 -14
  236. package/src/theme/components/progressIndicator.ts +10 -5
  237. package/src/theme/components/select.ts +5 -2
  238. package/src/theme/components/skeletonLoader.ts +8 -2
  239. package/src/theme/components/skipNavigation.ts +26 -0
  240. package/src/theme/components/slider.ts +13 -1
  241. package/src/theme/components/structuredContent.ts +11 -1
  242. package/src/theme/components/text.ts +12 -5
  243. package/src/theme/components/toggle.ts +9 -3
  244. package/src/theme/index.ts +4 -0
  245. package/src/theme/provider.tsx +1 -1
  246. package/src/utils/componentCategories.ts +13 -5
  247. package/src/utils/interfaces.ts +5 -0
  248. package/src/utils/utils.ts +2 -32
  249. package/dist/components/Accordion/AccordionTypes.d.ts +0 -5
  250. package/dist/components/Breadcrumbs/BreadcrumbsTypes.d.ts +0 -8
  251. package/dist/components/Button/ButtonTypes.d.ts +0 -8
  252. package/dist/components/DatePicker/DatePickerTypes.d.ts +0 -5
  253. package/dist/components/Form/FormTypes.d.ts +0 -2
  254. package/dist/components/Grid/GridTypes.d.ts +0 -9
  255. package/dist/components/Heading/HeadingTypes.d.ts +0 -14
  256. package/dist/components/Hero/HeroTypes.d.ts +0 -12
  257. package/dist/components/Icons/IconTypes.d.ts +0 -77
  258. package/dist/components/Image/ImageTypes.d.ts +0 -22
  259. package/dist/components/Link/LinkTypes.d.ts +0 -8
  260. package/dist/components/List/ListTypes.d.ts +0 -5
  261. package/dist/components/Logo/LogoTypes.d.ts +0 -54
  262. package/dist/components/Notification/NotificationTypes.d.ts +0 -5
  263. package/dist/components/ProgressIndicator/ProgressIndicatorTypes.d.ts +0 -8
  264. package/dist/components/Select/SelectTypes.d.ts +0 -8
  265. package/dist/components/SkeletonLoader/SkeletonLoaderTypes.d.ts +0 -5
  266. package/dist/components/StatusBadge/StatusBadgeTypes.d.ts +0 -5
  267. package/dist/components/StructuredContent/StructuredContentTypes.d.ts +0 -5
  268. package/dist/components/Text/TextTypes.d.ts +0 -6
  269. package/dist/components/TextInput/TextInputTypes.d.ts +0 -25
  270. package/dist/components/Toggle/ToggleTypes.d.ts +0 -4
  271. package/dist/components/VideoPlayer/VideoPlayerTypes.d.ts +0 -9
  272. package/dist/helpers/enums.d.ts +0 -4
  273. package/dist/utils/siteSections.d.ts +0 -2
  274. package/src/components/Accordion/AccordionTypes.tsx +0 -5
  275. package/src/components/Breadcrumbs/BreadcrumbsTypes.tsx +0 -8
  276. package/src/components/Button/ButtonTypes.tsx +0 -8
  277. package/src/components/DatePicker/DatePickerTypes.tsx +0 -5
  278. package/src/components/Form/FormTypes.tsx +0 -3
  279. package/src/components/Grid/GridTypes.tsx +0 -9
  280. package/src/components/Heading/HeadingTypes.tsx +0 -15
  281. package/src/components/Hero/HeroTypes.tsx +0 -20
  282. package/src/components/Icons/IconTypes.tsx +0 -83
  283. package/src/components/Image/ImageTypes.ts +0 -24
  284. package/src/components/Link/LinkTypes.tsx +0 -8
  285. package/src/components/List/ListTypes.tsx +0 -5
  286. package/src/components/Logo/LogoTypes.tsx +0 -56
  287. package/src/components/Notification/NotificationTypes.tsx +0 -5
  288. package/src/components/ProgressIndicator/ProgressIndicatorTypes.ts +0 -8
  289. package/src/components/Select/SelectTypes.tsx +0 -10
  290. package/src/components/SkeletonLoader/SkeletonLoaderTypes.tsx +0 -5
  291. package/src/components/StatusBadge/StatusBadgeTypes.tsx +0 -5
  292. package/src/components/StructuredContent/StructuredContentTypes.tsx +0 -5
  293. package/src/components/Text/TextTypes.tsx +0 -6
  294. package/src/components/TextInput/TextInputTypes.tsx +0 -48
  295. package/src/components/Toggle/ToggleTypes.tsx +0 -4
  296. package/src/components/VideoPlayer/VideoPlayerTypes.tsx +0 -10
  297. package/src/helpers/enums.ts +0 -4
  298. package/src/utils/siteSections.ts +0 -10
@@ -10,12 +10,12 @@ import HelperErrorText, {
10
10
  HelperErrorTextType,
11
11
  } from "../HelperErrorText/HelperErrorText";
12
12
  import Icon from "../Icons/Icon";
13
- import { IconNames, IconSizes } from "../Icons/IconTypes";
14
13
  import Label from "../Label/Label";
15
- import { SelectTypes, LabelPositions } from "./SelectTypes";
14
+ import { AriaAttributes } from "../../utils/interfaces";
15
+
16
+ export type SelectTypes = "default" | "searchbar";
17
+ export type LabelPositions = "default" | "inline";
16
18
  export interface SelectProps {
17
- /** Optionally pass in additional Chakra-based styles. */
18
- additionalStyles?: { [key: string]: any };
19
19
  /** A class name for the `div` parent element. */
20
20
  className?: string;
21
21
  /** Optional string to populate the `HelperErrorText` for the standard state. */
@@ -69,7 +69,6 @@ export const Select = chakra(
69
69
  React.forwardRef<HTMLSelectElement, React.PropsWithChildren<SelectProps>>(
70
70
  (props: React.PropsWithChildren<SelectProps>, ref?) => {
71
71
  const {
72
- additionalStyles = {},
73
72
  children,
74
73
  className,
75
74
  helperText,
@@ -78,21 +77,21 @@ export const Select = chakra(
78
77
  isDisabled = false,
79
78
  isInvalid = false,
80
79
  isRequired = false,
81
- labelPosition = LabelPositions.Default,
80
+ labelPosition = "default",
82
81
  labelText,
83
82
  name,
84
83
  onChange,
85
84
  placeholder,
86
- selectType = SelectTypes.Default,
85
+ selectType = "default",
87
86
  showHelperInvalidText = true,
88
87
  showLabel = true,
89
88
  showRequiredLabel = true,
90
89
  value = "",
91
90
  ...rest
92
91
  } = props;
93
- const ariaAttributes = {};
92
+ const ariaAttributes: AriaAttributes = {};
94
93
  const [labelWidth, setLabelWidth] = useState<number>(0);
95
- const labelRef = useRef<HTMLInputElement>();
94
+ const labelRef = useRef<HTMLDivElement>(null);
96
95
  const styles = useMultiStyleConfig("CustomSelect", {
97
96
  variant: selectType,
98
97
  labelPosition,
@@ -100,9 +99,7 @@ export const Select = chakra(
100
99
  const finalInvalidText = invalidText
101
100
  ? invalidText
102
101
  : "There is an error related to this field.";
103
- const footnote: HelperErrorTextType = isInvalid
104
- ? finalInvalidText
105
- : helperText;
102
+ const footnote = isInvalid ? finalInvalidText : helperText;
106
103
  // To control the `Select` component, both `onChange` and `value`
107
104
  // must be passed.
108
105
  const controlledProps = onChange ? { onChange, value } : {};
@@ -125,7 +122,7 @@ export const Select = chakra(
125
122
  }
126
123
 
127
124
  useEffect(() => {
128
- if (labelPosition === LabelPositions.Inline) {
125
+ if (labelPosition === "inline") {
129
126
  if (labelRef.current) {
130
127
  const width = labelRef.current.clientWidth + labelSelectGap;
131
128
  setLabelWidth(width);
@@ -136,12 +133,8 @@ export const Select = chakra(
136
133
  }, [labelPosition]);
137
134
 
138
135
  return (
139
- <Box
140
- className={className}
141
- __css={{ ...styles, ...additionalStyles }}
142
- {...rest}
143
- >
144
- <Box __css={labelPosition === LabelPositions.Inline && styles.inline}>
136
+ <Box className={className} __css={styles} {...rest}>
137
+ <Box __css={labelPosition === "inline" && styles.inline}>
145
138
  {showLabel && (
146
139
  <Box ref={labelRef}>
147
140
  <Label
@@ -165,13 +158,7 @@ export const Select = chakra(
165
158
  ref={ref}
166
159
  {...controlledProps}
167
160
  {...ariaAttributes}
168
- icon={
169
- <Icon
170
- id={`${id}-icon`}
171
- name={IconNames.Arrow}
172
- size={IconSizes.Medium}
173
- />
174
- }
161
+ icon={<Icon id={`${id}-icon`} name="arrow" size="medium" />}
175
162
  __css={styles.select}
176
163
  >
177
164
  {children}
@@ -10,19 +10,7 @@ import { withDesign } from "storybook-addon-designs";
10
10
 
11
11
  import SimpleGrid from "../Grid/SimpleGrid";
12
12
  import SkeletonLoader from "./SkeletonLoader";
13
- import { SkeletonLoaderImageRatios } from "./SkeletonLoaderTypes";
14
- import { LayoutTypes } from "../../helpers/enums";
15
13
  import { getCategory } from "../../utils/componentCategories";
16
- import { getStorybookEnumValues } from "../../utils/utils";
17
-
18
- export const imageRatiosEnumValues = getStorybookEnumValues(
19
- SkeletonLoaderImageRatios,
20
- "SkeletonLoaderImageRatios"
21
- );
22
- export const layoutsEnumValues = getStorybookEnumValues(
23
- LayoutTypes,
24
- "LayoutTypes"
25
- );
26
14
 
27
15
  <Meta
28
16
  title={getCategory("SkeletonLoader")}
@@ -40,16 +28,13 @@ export const layoutsEnumValues = getStorybookEnumValues(
40
28
  contentSize: { table: { defaultValue: { summary: "3" } } },
41
29
  headingSize: { table: { defaultValue: { summary: "1" } } },
42
30
  imageAspectRatio: {
43
- control: { type: "select" },
44
31
  table: {
45
- defaultValue: { summary: "SkeletonLoaderImageRatios.Square" },
32
+ defaultValue: { summary: "square" },
46
33
  },
47
- options: imageRatiosEnumValues.options,
48
34
  },
49
35
  isBordered: { table: { defaultValue: { summary: "false" } } },
50
36
  layout: {
51
- table: { defaultValue: { summary: "LayoutTypes.Column" } },
52
- options: layoutsEnumValues.options,
37
+ table: { defaultValue: { summary: "column" } },
53
38
  },
54
39
  showButton: { table: { defaultValue: { summary: "false" } } },
55
40
  showContent: { table: { defaultValue: { summary: "true" } } },
@@ -63,7 +48,7 @@ export const layoutsEnumValues = getStorybookEnumValues(
63
48
  | Component Version | DS Version |
64
49
  | ----------------- | ---------- |
65
50
  | Added | `0.17.3` |
66
- | Latest | `0.26.0` |
51
+ | Latest | `0.28.0` |
67
52
 
68
53
  ## Table of Contents
69
54
 
@@ -92,9 +77,9 @@ to better view the example. The default value is `100%`.
92
77
  className: undefined,
93
78
  contentSize: 3,
94
79
  headingSize: 1,
95
- imageAspectRatio: "SkeletonLoaderImageRatios.Square",
80
+ imageAspectRatio: "square",
96
81
  isBordered: false,
97
- layout: "LayoutTypes.Column",
82
+ layout: "column",
98
83
  showButton: false,
99
84
  showContent: true,
100
85
  showHeading: true,
@@ -102,13 +87,7 @@ to better view the example. The default value is `100%`.
102
87
  width: "300px",
103
88
  }}
104
89
  >
105
- {(args) => (
106
- <SkeletonLoader
107
- {...args}
108
- imageAspectRatio={imageRatiosEnumValues.getValue(args.imageAspectRatio)}
109
- layout={layoutsEnumValues.getValue(args.layout)}
110
- />
111
- )}
90
+ {(args) => <SkeletonLoader {...args} />}
112
91
  </Story>
113
92
  </Canvas>
114
93
 
@@ -138,30 +117,12 @@ Resources:
138
117
  <Canvas>
139
118
  <Story name="Placeholders in a Grid">
140
119
  <SimpleGrid columns={3}>
141
- <SkeletonLoader
142
- imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
143
- isBordered
144
- />
145
- <SkeletonLoader
146
- imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
147
- isBordered
148
- />
149
- <SkeletonLoader
150
- imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
151
- isBordered
152
- />
153
- <SkeletonLoader
154
- imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
155
- isBordered
156
- />
157
- <SkeletonLoader
158
- imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
159
- isBordered
160
- />
161
- <SkeletonLoader
162
- imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
163
- isBordered
164
- />
120
+ <SkeletonLoader imageAspectRatio="landscape" isBordered />
121
+ <SkeletonLoader imageAspectRatio="landscape" isBordered />
122
+ <SkeletonLoader imageAspectRatio="landscape" isBordered />
123
+ <SkeletonLoader imageAspectRatio="landscape" isBordered />
124
+ <SkeletonLoader imageAspectRatio="landscape" isBordered />
125
+ <SkeletonLoader imageAspectRatio="landscape" isBordered />
165
126
  </SimpleGrid>
166
127
  </Story>
167
128
  </Canvas>
@@ -171,11 +132,11 @@ Resources:
171
132
  <Canvas>
172
133
  <Story name="Placeholders in a List">
173
134
  <SimpleGrid columns={1}>
174
- <SkeletonLoader layout={LayoutTypes.Row} showImage={false} />
175
- <SkeletonLoader layout={LayoutTypes.Row} showImage={false} />
176
- <SkeletonLoader layout={LayoutTypes.Row} showImage={false} />
177
- <SkeletonLoader layout={LayoutTypes.Row} showImage={false} />
178
- <SkeletonLoader layout={LayoutTypes.Row} showImage={false} />
135
+ <SkeletonLoader layout="row" showImage={false} />
136
+ <SkeletonLoader layout="row" showImage={false} />
137
+ <SkeletonLoader layout="row" showImage={false} />
138
+ <SkeletonLoader layout="row" showImage={false} />
139
+ <SkeletonLoader layout="row" showImage={false} />
179
140
  </SimpleGrid>
180
141
  </Story>
181
142
  </Canvas>
@@ -4,8 +4,6 @@ import { axe } from "jest-axe";
4
4
  import renderer from "react-test-renderer";
5
5
 
6
6
  import SkeletonLoader from "./SkeletonLoader";
7
- import { SkeletonLoaderImageRatios } from "./SkeletonLoaderTypes";
8
- import { LayoutTypes } from "../../helpers/enums";
9
7
 
10
8
  describe("SkeletonLoader Accessibility", () => {
11
9
  it("passes axe accessibility test", async () => {
@@ -24,13 +22,11 @@ describe("SkeletonLoader", () => {
24
22
  });
25
23
 
26
24
  it("renders in the column or row layout", () => {
27
- const { container, rerender } = render(
28
- <SkeletonLoader layout={LayoutTypes.Column} />
29
- );
25
+ const { container, rerender } = render(<SkeletonLoader layout="column" />);
30
26
 
31
27
  expect(container.querySelector(".column")).toBeInTheDocument();
32
28
 
33
- rerender(<SkeletonLoader layout={LayoutTypes.Row} />);
29
+ rerender(<SkeletonLoader layout="row" />);
34
30
  expect(container.querySelector(".row")).toBeInTheDocument();
35
31
  });
36
32
 
@@ -72,11 +68,9 @@ describe("SkeletonLoader", () => {
72
68
 
73
69
  it("renders the UI snapshot correctly", () => {
74
70
  const basic = renderer.create(<SkeletonLoader />).toJSON();
75
- const rowLayout = renderer
76
- .create(<SkeletonLoader layout={LayoutTypes.Row} />)
77
- .toJSON();
71
+ const rowLayout = renderer.create(<SkeletonLoader layout="row" />).toJSON();
78
72
  const columnLayout = renderer
79
- .create(<SkeletonLoader layout={LayoutTypes.Column} />)
73
+ .create(<SkeletonLoader layout="column" />)
80
74
  .toJSON();
81
75
  const noImage = renderer
82
76
  .create(<SkeletonLoader showImage={false} />)
@@ -91,21 +85,13 @@ describe("SkeletonLoader", () => {
91
85
  .create(<SkeletonLoader showButton={true} />)
92
86
  .toJSON();
93
87
  const landscape = renderer
94
- .create(
95
- <SkeletonLoader
96
- imageAspectRatio={SkeletonLoaderImageRatios.Landscape}
97
- />
98
- )
88
+ .create(<SkeletonLoader imageAspectRatio="landscape" />)
99
89
  .toJSON();
100
90
  const portrait = renderer
101
- .create(
102
- <SkeletonLoader imageAspectRatio={SkeletonLoaderImageRatios.Portrait} />
103
- )
91
+ .create(<SkeletonLoader imageAspectRatio="portrait" />)
104
92
  .toJSON();
105
93
  const square = renderer
106
- .create(
107
- <SkeletonLoader imageAspectRatio={SkeletonLoaderImageRatios.Square} />
108
- )
94
+ .create(<SkeletonLoader imageAspectRatio="square" />)
109
95
  .toJSON();
110
96
  const withChakraProps = renderer
111
97
  .create(<SkeletonLoader p="20px" color="ui.error.primary" />)
@@ -6,8 +6,9 @@ import {
6
6
  } from "@chakra-ui/react";
7
7
  import * as React from "react";
8
8
 
9
- import { SkeletonLoaderImageRatios } from "./SkeletonLoaderTypes";
10
- import { LayoutTypes } from "../../helpers/enums";
9
+ import { LayoutTypes } from "../../helpers/types";
10
+
11
+ export type SkeletonLoaderImageRatios = "landscape" | "portrait" | "square";
11
12
 
12
13
  export interface SkeletonLoaderProps {
13
14
  /** Additional class name for the Skeleton component. */
@@ -19,12 +20,12 @@ export interface SkeletonLoaderProps {
19
20
  * placeholder; default value is `1`. */
20
21
  headingSize?: number;
21
22
  /** Optional value to control the aspect ratio of the image placeholder;
22
- * default value is `SkeletonLoaderImageRatios.Square`. */
23
+ * default value is `"square"`. */
23
24
  imageAspectRatio?: SkeletonLoaderImageRatios;
24
25
  /** Optional boolean value to control visibility of border around skeleton loader. */
25
26
  isBordered?: boolean;
26
27
  /** Optional value to control the position of the image placeholder;
27
- * default value is `LayoutTypes.Column`. */
28
+ * default value is `"column"`. */
28
29
  layout?: LayoutTypes;
29
30
  /** Optional boolean value to control visibility of button placeholder. */
30
31
  showButton?: boolean;
@@ -50,9 +51,9 @@ export const SkeletonLoader = chakra(
50
51
  className,
51
52
  contentSize = 3,
52
53
  headingSize = 1,
53
- imageAspectRatio = SkeletonLoaderImageRatios.Square,
54
+ imageAspectRatio = "square",
54
55
  isBordered = false,
55
- layout = LayoutTypes.Column,
56
+ layout = "column",
56
57
  showButton = false,
57
58
  showContent = true,
58
59
  showHeading = true,
@@ -72,11 +73,11 @@ export const SkeletonLoader = chakra(
72
73
  * "heading" and "content" areas defined by the `type` argument. The last
73
74
  * element will have width of `lastWidth`.
74
75
  */
75
- const getSkeletonElements = (type, size = 1, lastWidth = "80%") => {
76
+ const getSkeletonElements = (type: string, size = 1, lastWidth = "80%") => {
76
77
  return new Array(size).fill(null).map((_, i) => {
77
78
  const width = i === size - 1 ? lastWidth : "100%";
78
79
  const marginBottomValue =
79
- i === size - 1 && type === "content" ? "0" : null;
80
+ i === size - 1 && type === "content" ? "0" : undefined;
80
81
  return (
81
82
  <ChakraSkeleton key={`${type}-${i}`} width={width}>
82
83
  <Box
@@ -29,7 +29,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 1`] = `
29
29
  className="css-0"
30
30
  style={
31
31
  Object {
32
- "marginBottom": null,
32
+ "marginBottom": undefined,
33
33
  }
34
34
  }
35
35
  />
@@ -45,7 +45,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 1`] = `
45
45
  className="css-0"
46
46
  style={
47
47
  Object {
48
- "marginBottom": null,
48
+ "marginBottom": undefined,
49
49
  }
50
50
  }
51
51
  />
@@ -57,7 +57,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 1`] = `
57
57
  className="css-0"
58
58
  style={
59
59
  Object {
60
- "marginBottom": null,
60
+ "marginBottom": undefined,
61
61
  }
62
62
  }
63
63
  />
@@ -108,7 +108,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 2`] = `
108
108
  className="css-0"
109
109
  style={
110
110
  Object {
111
- "marginBottom": null,
111
+ "marginBottom": undefined,
112
112
  }
113
113
  }
114
114
  />
@@ -124,7 +124,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 2`] = `
124
124
  className="css-0"
125
125
  style={
126
126
  Object {
127
- "marginBottom": null,
127
+ "marginBottom": undefined,
128
128
  }
129
129
  }
130
130
  />
@@ -136,7 +136,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 2`] = `
136
136
  className="css-0"
137
137
  style={
138
138
  Object {
139
- "marginBottom": null,
139
+ "marginBottom": undefined,
140
140
  }
141
141
  }
142
142
  />
@@ -187,7 +187,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 3`] = `
187
187
  className="css-0"
188
188
  style={
189
189
  Object {
190
- "marginBottom": null,
190
+ "marginBottom": undefined,
191
191
  }
192
192
  }
193
193
  />
@@ -203,7 +203,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 3`] = `
203
203
  className="css-0"
204
204
  style={
205
205
  Object {
206
- "marginBottom": null,
206
+ "marginBottom": undefined,
207
207
  }
208
208
  }
209
209
  />
@@ -215,7 +215,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 3`] = `
215
215
  className="css-0"
216
216
  style={
217
217
  Object {
218
- "marginBottom": null,
218
+ "marginBottom": undefined,
219
219
  }
220
220
  }
221
221
  />
@@ -259,7 +259,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 4`] = `
259
259
  className="css-0"
260
260
  style={
261
261
  Object {
262
- "marginBottom": null,
262
+ "marginBottom": undefined,
263
263
  }
264
264
  }
265
265
  />
@@ -275,7 +275,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 4`] = `
275
275
  className="css-0"
276
276
  style={
277
277
  Object {
278
- "marginBottom": null,
278
+ "marginBottom": undefined,
279
279
  }
280
280
  }
281
281
  />
@@ -287,7 +287,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 4`] = `
287
287
  className="css-0"
288
288
  style={
289
289
  Object {
290
- "marginBottom": null,
290
+ "marginBottom": undefined,
291
291
  }
292
292
  }
293
293
  />
@@ -338,7 +338,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 5`] = `
338
338
  className="css-0"
339
339
  style={
340
340
  Object {
341
- "marginBottom": null,
341
+ "marginBottom": undefined,
342
342
  }
343
343
  }
344
344
  />
@@ -350,7 +350,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 5`] = `
350
350
  className="css-0"
351
351
  style={
352
352
  Object {
353
- "marginBottom": null,
353
+ "marginBottom": undefined,
354
354
  }
355
355
  }
356
356
  />
@@ -401,7 +401,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 6`] = `
401
401
  className="css-0"
402
402
  style={
403
403
  Object {
404
- "marginBottom": null,
404
+ "marginBottom": undefined,
405
405
  }
406
406
  }
407
407
  />
@@ -440,7 +440,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 7`] = `
440
440
  className="css-0"
441
441
  style={
442
442
  Object {
443
- "marginBottom": null,
443
+ "marginBottom": undefined,
444
444
  }
445
445
  }
446
446
  />
@@ -456,7 +456,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 7`] = `
456
456
  className="css-0"
457
457
  style={
458
458
  Object {
459
- "marginBottom": null,
459
+ "marginBottom": undefined,
460
460
  }
461
461
  }
462
462
  />
@@ -468,7 +468,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 7`] = `
468
468
  className="css-0"
469
469
  style={
470
470
  Object {
471
- "marginBottom": null,
471
+ "marginBottom": undefined,
472
472
  }
473
473
  }
474
474
  />
@@ -530,7 +530,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 8`] = `
530
530
  className="css-0"
531
531
  style={
532
532
  Object {
533
- "marginBottom": null,
533
+ "marginBottom": undefined,
534
534
  }
535
535
  }
536
536
  />
@@ -546,7 +546,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 8`] = `
546
546
  className="css-0"
547
547
  style={
548
548
  Object {
549
- "marginBottom": null,
549
+ "marginBottom": undefined,
550
550
  }
551
551
  }
552
552
  />
@@ -558,7 +558,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 8`] = `
558
558
  className="css-0"
559
559
  style={
560
560
  Object {
561
- "marginBottom": null,
561
+ "marginBottom": undefined,
562
562
  }
563
563
  }
564
564
  />
@@ -609,7 +609,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 9`] = `
609
609
  className="css-0"
610
610
  style={
611
611
  Object {
612
- "marginBottom": null,
612
+ "marginBottom": undefined,
613
613
  }
614
614
  }
615
615
  />
@@ -625,7 +625,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 9`] = `
625
625
  className="css-0"
626
626
  style={
627
627
  Object {
628
- "marginBottom": null,
628
+ "marginBottom": undefined,
629
629
  }
630
630
  }
631
631
  />
@@ -637,7 +637,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 9`] = `
637
637
  className="css-0"
638
638
  style={
639
639
  Object {
640
- "marginBottom": null,
640
+ "marginBottom": undefined,
641
641
  }
642
642
  }
643
643
  />
@@ -688,7 +688,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 10`] = `
688
688
  className="css-0"
689
689
  style={
690
690
  Object {
691
- "marginBottom": null,
691
+ "marginBottom": undefined,
692
692
  }
693
693
  }
694
694
  />
@@ -704,7 +704,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 10`] = `
704
704
  className="css-0"
705
705
  style={
706
706
  Object {
707
- "marginBottom": null,
707
+ "marginBottom": undefined,
708
708
  }
709
709
  }
710
710
  />
@@ -716,7 +716,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 10`] = `
716
716
  className="css-0"
717
717
  style={
718
718
  Object {
719
- "marginBottom": null,
719
+ "marginBottom": undefined,
720
720
  }
721
721
  }
722
722
  />
@@ -767,7 +767,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 11`] = `
767
767
  className="css-0"
768
768
  style={
769
769
  Object {
770
- "marginBottom": null,
770
+ "marginBottom": undefined,
771
771
  }
772
772
  }
773
773
  />
@@ -783,7 +783,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 11`] = `
783
783
  className="css-0"
784
784
  style={
785
785
  Object {
786
- "marginBottom": null,
786
+ "marginBottom": undefined,
787
787
  }
788
788
  }
789
789
  />
@@ -795,7 +795,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 11`] = `
795
795
  className="css-0"
796
796
  style={
797
797
  Object {
798
- "marginBottom": null,
798
+ "marginBottom": undefined,
799
799
  }
800
800
  }
801
801
  />
@@ -847,7 +847,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 12`] = `
847
847
  className="css-0"
848
848
  style={
849
849
  Object {
850
- "marginBottom": null,
850
+ "marginBottom": undefined,
851
851
  }
852
852
  }
853
853
  />
@@ -863,7 +863,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 12`] = `
863
863
  className="css-0"
864
864
  style={
865
865
  Object {
866
- "marginBottom": null,
866
+ "marginBottom": undefined,
867
867
  }
868
868
  }
869
869
  />
@@ -875,7 +875,7 @@ exports[`SkeletonLoader renders the UI snapshot correctly 12`] = `
875
875
  className="css-0"
876
876
  style={
877
877
  Object {
878
- "marginBottom": null,
878
+ "marginBottom": undefined,
879
879
  }
880
880
  }
881
881
  />