@scottish-government/designsystem-react 0.9.0-beta.0 → 0.10.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 (165) hide show
  1. package/.storybook/main.ts +20 -0
  2. package/.storybook/manager.ts +13 -0
  3. package/.storybook/preview-head.html +1 -0
  4. package/.storybook/preview.tsx +56 -0
  5. package/.storybook/sgdsArgTypes.ts +123 -0
  6. package/.storybook/sgdsTheme.ts +9 -0
  7. package/.storybook/vitest.setup.ts +7 -0
  8. package/@types/common/AbstractNotificationBanner.d.ts +2 -2
  9. package/@types/common/ActionLink.d.ts +1 -1
  10. package/@types/common/Icon.d.ts +1 -1
  11. package/@types/components/Accordion.d.ts +2 -2
  12. package/@types/components/Button.d.ts +5 -5
  13. package/@types/components/CategoryItem.d.ts +10 -0
  14. package/@types/components/CategoryList.d.ts +7 -0
  15. package/@types/components/Checkbox.d.ts +2 -2
  16. package/@types/components/ContentsNav.d.ts +1 -1
  17. package/@types/components/DatePicker.d.ts +1 -1
  18. package/@types/components/ErrorMessage.d.ts +1 -2
  19. package/@types/components/ErrorSummary.d.ts +1 -1
  20. package/@types/components/FileDownload.d.ts +2 -2
  21. package/@types/components/Metadata.d.ts +1 -1
  22. package/@types/components/Pagination.d.ts +1 -1
  23. package/@types/components/RadioButton.d.ts +2 -2
  24. package/@types/components/SideNavigation.d.ts +1 -1
  25. package/@types/components/SiteNavigation.d.ts +1 -1
  26. package/@types/components/SummaryList.d.ts +1 -1
  27. package/@types/components/Tabs.d.ts +3 -3
  28. package/@types/components/TextInput.d.ts +1 -1
  29. package/@types/sgds.d.ts +2 -1
  30. package/CHANGELOG.md +29 -0
  31. package/dist/common/AbstractNotificationBanner.jsx +4 -4
  32. package/dist/common/Icon.jsx +2 -2
  33. package/dist/components/Accordion/Accordion.jsx +3 -7
  34. package/dist/components/Button/Button.jsx +6 -6
  35. package/dist/components/CategoryItem/CategoryItem.jsx +35 -0
  36. package/dist/components/CategoryList/CategoryList.jsx +55 -0
  37. package/dist/components/Checkbox/Checkbox.jsx +5 -5
  38. package/dist/components/Checkbox/CheckboxGroup.jsx +2 -2
  39. package/dist/components/ContentsNav/ContentsNav.jsx +2 -2
  40. package/dist/components/DatePicker/DatePicker.jsx +1 -1
  41. package/dist/components/ErrorMessage/ErrorMessage.jsx +3 -3
  42. package/dist/components/FileDownload/FileDownload.jsx +2 -2
  43. package/dist/components/NotificationBanner/NotificationBanner.jsx +2 -2
  44. package/dist/components/PageMetadata/PageMetadata.jsx +4 -4
  45. package/dist/components/Pagination/Pagination.jsx +4 -4
  46. package/dist/components/Question/Question.jsx +1 -1
  47. package/dist/components/RadioButton/RadioButton.jsx +3 -3
  48. package/dist/components/RadioButton/RadioGroup.jsx +3 -3
  49. package/dist/components/Select/Select.jsx +1 -1
  50. package/dist/components/SideNavigation/SideNavigation.jsx +2 -2
  51. package/dist/components/SiteHeader/SiteHeader.jsx +3 -3
  52. package/dist/components/SiteNavigation/SiteNavigation.jsx +2 -2
  53. package/dist/components/SiteSearch/SiteSearch.jsx +1 -1
  54. package/dist/components/SkipLinks/SkipLinks.jsx +1 -1
  55. package/dist/components/SummaryList/SummaryList.jsx +3 -3
  56. package/dist/components/Tabs/Tabs.jsx +6 -7
  57. package/dist/components/TextInput/TextInput.jsx +5 -5
  58. package/dist/components/Textarea/Textarea.jsx +1 -1
  59. package/dist/tsconfig.tsbuildinfo +1 -1
  60. package/dist/utils/context.js +1 -1
  61. package/package.json +14 -3
  62. package/src/common/AbstractNotificationBanner.test.tsx +1 -1
  63. package/src/common/AbstractNotificationBanner.tsx +4 -4
  64. package/src/common/Icon.test.tsx +1 -1
  65. package/src/common/Icon.tsx +2 -2
  66. package/src/components/Accordion/Accordion.stories.tsx +111 -0
  67. package/src/components/Accordion/Accordion.test.tsx +5 -30
  68. package/src/components/Accordion/Accordion.tsx +4 -9
  69. package/src/components/AspectBox/AspectBox.stories.tsx +64 -0
  70. package/src/components/BackToTop/BackToTop.stories.tsx +36 -0
  71. package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +49 -0
  72. package/src/components/Breadcrumbs/Breadcrumbs.tsx +1 -1
  73. package/src/components/Button/Button.stories.tsx +194 -0
  74. package/src/components/Button/Button.test.tsx +4 -4
  75. package/src/components/Button/Button.tsx +9 -9
  76. package/src/components/CategoryItem/CategoryItem.stories.tsx +55 -0
  77. package/src/components/CategoryItem/CategoryItem.test.tsx +93 -0
  78. package/src/components/CategoryItem/CategoryItem.tsx +56 -0
  79. package/src/components/CategoryList/CategoryList.stories.tsx +65 -0
  80. package/src/components/CategoryList/CategoryList.test.tsx +59 -0
  81. package/src/components/CategoryList/CategoryList.tsx +33 -0
  82. package/src/components/Checkbox/Checkbox.stories.tsx +85 -0
  83. package/src/components/Checkbox/Checkbox.test.tsx +2 -2
  84. package/src/components/Checkbox/Checkbox.tsx +7 -7
  85. package/src/components/Checkbox/CheckboxGroup.stories.tsx +68 -0
  86. package/src/components/Checkbox/CheckboxGroup.tsx +2 -2
  87. package/src/components/ConfirmationMessage/ConfirmationMessage.stories.tsx +38 -0
  88. package/src/components/ContentsNav/ContentsNav.stories.tsx +43 -0
  89. package/src/components/ContentsNav/ContentsNav.test.tsx +2 -2
  90. package/src/components/ContentsNav/ContentsNav.tsx +2 -2
  91. package/src/components/CookieBanner/CookieBanner.stories.tsx +33 -0
  92. package/src/components/DatePicker/DatePicker.stories.tsx +113 -0
  93. package/src/components/DatePicker/DatePicker.tsx +1 -1
  94. package/src/components/Details/Details.stories.tsx +36 -0
  95. package/src/components/ErrorMessage/ErrorMessage.stories.tsx +19 -0
  96. package/src/components/ErrorMessage/ErrorMessage.test.tsx +3 -15
  97. package/src/components/ErrorMessage/ErrorMessage.tsx +1 -3
  98. package/src/components/ErrorSummary/ErrorSummary.stories.tsx +38 -0
  99. package/src/components/FileDownload/FileDownload.stories.tsx +75 -0
  100. package/src/components/FileDownload/FileDownload.test.tsx +1 -1
  101. package/src/components/FileDownload/FileDownload.tsx +2 -2
  102. package/src/components/HideThisPage/HideThisPage.stories.tsx +20 -0
  103. package/src/components/InsetText/InsetText.stories.tsx +21 -0
  104. package/src/components/NotificationBanner/NotificationBanner.stories.tsx +57 -0
  105. package/src/components/NotificationBanner/NotificationBanner.test.tsx +1 -1
  106. package/src/components/NotificationBanner/NotificationBanner.tsx +4 -4
  107. package/src/components/NotificationPanel/NotificationPanel.stories.tsx +32 -0
  108. package/src/components/PageHeader/PageHeader.stories.tsx +60 -0
  109. package/src/components/PageMetadata/PageMetadata.stories.tsx +58 -0
  110. package/src/components/PageMetadata/PageMetadata.test.tsx +2 -2
  111. package/src/components/PageMetadata/PageMetadata.tsx +4 -4
  112. package/src/components/Pagination/Pagination.stories.tsx +69 -0
  113. package/src/components/Pagination/Pagination.test.tsx +1 -1
  114. package/src/components/Pagination/Pagination.tsx +4 -4
  115. package/src/components/PhaseBanner/PhaseBanner.stories.tsx +38 -0
  116. package/src/components/Question/Question.stories.tsx +78 -0
  117. package/src/components/Question/Question.tsx +1 -1
  118. package/src/components/RadioButton/RadioButton.stories.tsx +67 -0
  119. package/src/components/RadioButton/RadioButton.test.tsx +2 -1
  120. package/src/components/RadioButton/RadioButton.tsx +4 -4
  121. package/src/components/RadioButton/RadioGroup.stories.tsx +77 -0
  122. package/src/components/RadioButton/RadioGroup.test.tsx +2 -2
  123. package/src/components/RadioButton/RadioGroup.tsx +4 -4
  124. package/src/components/Select/Select.stories.tsx +76 -0
  125. package/src/components/Select/Select.tsx +1 -1
  126. package/src/components/SequentialNavigation/SequentialNavigation.stories.tsx +31 -0
  127. package/src/components/SideNavigation/SideNavigation.stories.tsx +92 -0
  128. package/src/components/SideNavigation/SideNavigation.test.tsx +2 -2
  129. package/src/components/SideNavigation/SideNavigation.tsx +2 -2
  130. package/src/components/SiteFooter/SiteFooter.stories.tsx +65 -0
  131. package/src/components/SiteHeader/SiteHeader.stories.tsx +92 -0
  132. package/src/components/SiteHeader/SiteHeader.tsx +2 -7
  133. package/src/components/SiteNavigation/SiteNavigation.stories.tsx +45 -0
  134. package/src/components/SiteNavigation/SiteNavigation.test.tsx +1 -1
  135. package/src/components/SiteNavigation/SiteNavigation.tsx +2 -2
  136. package/src/components/SiteSearch/SiteSearch.stories.tsx +81 -0
  137. package/src/components/SiteSearch/SiteSearch.tsx +1 -1
  138. package/src/components/SkipLinks/SkipLinks.stories.tsx +57 -0
  139. package/src/components/SkipLinks/SkipLinks.tsx +1 -1
  140. package/src/components/SummaryCard/SummaryCard.stories.tsx +46 -0
  141. package/src/components/SummaryList/SummaryList.stories.tsx +75 -0
  142. package/src/components/SummaryList/SummaryList.test.tsx +1 -1
  143. package/src/components/SummaryList/SummaryList.tsx +3 -3
  144. package/src/components/Table/Table.stories.tsx +96 -0
  145. package/src/components/Tabs/Tabs.stories.tsx +90 -0
  146. package/src/components/Tabs/Tabs.test.tsx +6 -8
  147. package/src/components/Tabs/Tabs.tsx +8 -9
  148. package/src/components/Tag/Tag.stories.tsx +25 -0
  149. package/src/components/TaskList/TaskList.stories.tsx +129 -0
  150. package/src/components/TextInput/TextInput.stories.tsx +123 -0
  151. package/src/components/TextInput/TextInput.test.tsx +2 -2
  152. package/src/components/TextInput/TextInput.tsx +5 -5
  153. package/src/components/Textarea/Textarea.stories.tsx +71 -0
  154. package/src/components/Textarea/Textarea.tsx +1 -1
  155. package/src/components/WarningText/WarningText.stories.tsx +21 -0
  156. package/src/utils/context.ts +1 -1
  157. package/static/data/autocomplete-dummy-data.json +2361 -0
  158. package/static/images/highland-cow.jpg +0 -0
  159. package/static/images/scottish-government--min.svg +11 -0
  160. package/static/images/scottish-government.svg +6 -0
  161. package/tsconfig.json +2 -1
  162. package/vite.config.ts +45 -11
  163. package/vitest-setup.ts +1 -0
  164. package/vitest.shims.d.ts +1 -0
  165. package/src/utils/slugify.ts +0 -13
@@ -0,0 +1,71 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import argTypes from '../../../.storybook/sgdsArgTypes';
3
+
4
+ import Textarea from './Textarea';
5
+
6
+ const meta = {
7
+ title: 'Components/Textarea',
8
+ component: Textarea,
9
+ argTypes: {
10
+ countThreshold: argTypes.countThreshold(),
11
+ errorMessage: argTypes.errorMessage(),
12
+ hasError: argTypes.hasError(),
13
+ hintText: argTypes.hintText(),
14
+ id: argTypes.id(),
15
+ label: argTypes.label(),
16
+ maxlength: argTypes.maxlength(),
17
+ name: { type: 'string' },
18
+ onBlur: argTypes.onBlur(),
19
+ onChange: argTypes.onChange(),
20
+ placeholder: {type: 'string'},
21
+ rows: {
22
+ type: 'number'
23
+ },
24
+ value: {type: 'string'}
25
+ },
26
+ args: {
27
+ id: 'description',
28
+ label: 'Description'
29
+ }
30
+ } satisfies Meta<typeof Textarea>;
31
+
32
+ export default meta;
33
+ type Story = StoryObj<typeof meta>;
34
+
35
+ export const Default: Story = {
36
+
37
+ };
38
+
39
+ export const KitchenSink: Story = {
40
+ args: {
41
+ defaultValue: 'Nothing seems to do anything when I click on it. I am using Megabrowser 3.8 on an OmniComputer 5000 and I\'ve disabled all of my plugins.\n\nThis problem didn\'t start happening until two weeks ago but now I can\'t use this tool at all.',
42
+ countThreshold: 50,
43
+ errorMessage: 'This field is required',
44
+ hasError: true,
45
+ hintText: 'Please describe the problem you are having',
46
+ id: 'kitchensink',
47
+ maxlength: 200,
48
+ rows: 6
49
+ }
50
+ };
51
+
52
+ export const Blur: Story = {
53
+ args: {
54
+ onBlur: () => {console.log('textarea blur')}
55
+ },
56
+ play: async ({ canvas, userEvent }) => {
57
+ await userEvent.click(canvas.getByRole('textbox'));
58
+ await userEvent.tab();
59
+ }
60
+ }
61
+
62
+ export const Change: Story = {
63
+ args: {
64
+ onChange: () => {console.log('textarea change')}
65
+ },
66
+ play: async ({ canvas, userEvent }) => {
67
+ await userEvent.click(canvas.getByRole('textbox'));
68
+ await userEvent.type(canvas.getByRole('textbox'),'banana');
69
+ await userEvent.tab();
70
+ }
71
+ }
@@ -55,7 +55,7 @@ const Textarea = ({
55
55
  >
56
56
  <label className="ds_label" htmlFor={id}>{label}</label>
57
57
  {hintText && <HintText id={hintTextId} text={hintText} />}
58
- {errorMessage && <ErrorMessage id={errorMessageId} text={errorMessage}/>}
58
+ {errorMessage && <ErrorMessage id={errorMessageId}>{errorMessage}</ErrorMessage>}
59
59
 
60
60
  <textarea
61
61
  aria-describedby={describedbys.join(' ')}
@@ -0,0 +1,21 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import argTypes from '../../../.storybook/sgdsArgTypes';
3
+
4
+ import WarningText from './WarningText';
5
+
6
+ const meta = {
7
+ title: 'Components/Warning text',
8
+ component: WarningText,
9
+ argTypes: {
10
+ children: argTypes.children()
11
+ }
12
+ } satisfies Meta<typeof WarningText>;
13
+
14
+ export default meta;
15
+ type Story = StoryObj<typeof meta>;
16
+
17
+ export const Default: Story = {
18
+ args: {
19
+ children: <p>Call 999 if you or someone else is in immediate danger, or if the crime is in progress.</p>
20
+ }
21
+ };
@@ -1,3 +1,3 @@
1
1
  import { createContext } from 'react';
2
2
 
3
- export const CheckboxRadioContext = createContext({ small: true, name: '' });
3
+ export const CheckboxRadioContext = createContext({ isSmall: false, name: '' });