@scottish-government/designsystem-react 0.9.0-beta.0 → 0.10.0-beta.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,20 @@
1
+ import type { StorybookConfig } from '@storybook/react-vite';
2
+
3
+ const config: StorybookConfig = {
4
+ "stories": [
5
+ "../src/**/*.mdx",
6
+ "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"
7
+ ],
8
+ "addons": [
9
+ "@chromatic-com/storybook",
10
+ "@storybook/addon-docs",
11
+ "@storybook/addon-onboarding",
12
+ "@storybook/addon-a11y",
13
+ "@storybook/addon-vitest"
14
+ ],
15
+ "framework": {
16
+ "name": "@storybook/react-vite",
17
+ "options": {}
18
+ }
19
+ };
20
+ export default config;
@@ -0,0 +1,13 @@
1
+ import { addons } from 'storybook/manager-api';
2
+ import capitalize from "lodash/capitalize";
3
+
4
+ import sgdsTheme from './sgdsTheme';
5
+
6
+ addons.setConfig({
7
+ theme: sgdsTheme,
8
+ sidebar: {
9
+ renderLabel: ({ name, type }) => {
10
+ return capitalize(name);
11
+ }
12
+ }
13
+ });
@@ -0,0 +1 @@
1
+ <link href="https://fonts.googleapis.com/css?family=Roboto:300,400,700,400italic&amp;display=swap" rel="stylesheet" type="text/css">
@@ -0,0 +1,56 @@
1
+ import type { Preview } from "@storybook/react-vite";
2
+
3
+ import {
4
+ Title,
5
+ Subtitle,
6
+ Description,
7
+ Primary,
8
+ Controls,
9
+ Stories,
10
+ } from '@storybook/addon-docs/blocks';
11
+
12
+ import '@scottish-government/design-system/dist/css/design-system.css';
13
+
14
+ const preview: Preview = {
15
+ parameters: {
16
+ controls: {
17
+ matchers: {
18
+ color: /(background|color)$/i,
19
+ date: /Date$/i,
20
+ },
21
+ },
22
+
23
+ a11y: {
24
+ // 'todo' - show a11y violations in the test UI only
25
+ // 'error' - fail CI on a11y violations
26
+ // 'off' - skip a11y checks entirely
27
+ test: "todo",
28
+ },
29
+
30
+ backgrounds: {
31
+ grid: {
32
+ cellSize: 8,
33
+ opacity: 0.25,
34
+ cellAmount: 8,
35
+ offsetX: 30, // Default is 0 if story has 'fullscreen' layout, 16 if layout is 'padded'
36
+ offsetY: 40, // Default is 0 if story has 'fullscreen' layout, 16 if layout is 'padded'
37
+ },
38
+ },
39
+
40
+ docs: {
41
+ page: () => (
42
+ <>
43
+ <Title />
44
+ <Subtitle />
45
+ <Description />
46
+ <Primary />
47
+ <Controls />
48
+ <Stories />
49
+ </>
50
+ )
51
+ },
52
+ },
53
+ tags: ['autodocs']
54
+ };
55
+
56
+ export default preview;
@@ -0,0 +1,123 @@
1
+ const SGDSArgTypes = {
2
+ ariaLabel: (options?: any) => {
3
+ return Object.assign({
4
+ type: 'string'
5
+ }, options);
6
+ },
7
+ ariaLive: (options?: any) => {
8
+ return Object.assign({
9
+ options: ['off', 'polite', 'assertive'],
10
+ control: { type: 'select' },
11
+ type: 'string'
12
+ }, options);
13
+ },
14
+ children: (options?: any) => {
15
+ return Object.assign({
16
+ control: false
17
+ }, options);
18
+ },
19
+ countThreshold: (options?: any) => {
20
+ return Object.assign({
21
+ control: {
22
+ type: 'number', min: 1, max: 100, step: 1
23
+ },
24
+ description: 'Percentage threshold to show the character count at',
25
+ type: 'number'
26
+ }, options);
27
+ },
28
+ errorMessage: (options?: any) => {
29
+ return Object.assign({
30
+ description: 'Text to use for an error message',
31
+ type: 'string'
32
+ }, options);
33
+ },
34
+ hasError: (options?: any) => {
35
+ return Object.assign({
36
+ control: 'boolean',
37
+ description: 'Whether the field is in an error state'
38
+ }, options);
39
+ },
40
+ headingLevel: (options?: any) => {
41
+ return Object.assign({
42
+ description: 'Heading level for the component\'s title',
43
+ options: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
44
+ control: { type: 'select' },
45
+ type: 'string'
46
+ }, options);
47
+ },
48
+ hintText: (options?: any) => {
49
+ return Object.assign({
50
+ description: 'Text to use for the field\'s hint text',
51
+ type: 'string'
52
+ }, options);
53
+ },
54
+ id: (options?: any) => {
55
+ return Object.assign({
56
+ type: {
57
+ required: true,
58
+ name: 'string'
59
+ }
60
+ }, options);
61
+ },
62
+ inputWidth: (options?: any) => {
63
+ return Object.assign({
64
+ control: { type: 'select' },
65
+ options: [undefined, 'fixed-20', 'fixed-10', 'fixed-5', 'fixed-4', 'fixed-3', 'fixed-2', 'fluid-three-quarters', 'fluid-two-thirds', 'fluid-half', 'fluid-one-third', 'fluid-one-quarter'],
66
+ type: 'string'
67
+ }, options);
68
+ },
69
+ isSmall: (options?: any) => {
70
+ return Object.assign({
71
+ control: 'boolean',
72
+ description: 'Whether to use the ‘small’ input control variant'
73
+ }, options);
74
+ },
75
+ label: (options?: any) => {
76
+ return Object.assign({
77
+ description: 'Text to use for the field\'s associated label',
78
+ type: {
79
+ required: true,
80
+ name: 'string'
81
+ }
82
+ }, options);
83
+ },
84
+ linkComponent: (options?: any) => {
85
+ return Object.assign({
86
+ control: false,
87
+ description: 'Function that returns an element, to customise the output',
88
+ type: 'function'
89
+ }, options);
90
+ },
91
+ maxlength: (options?: any) => {
92
+ return Object.assign({
93
+ description: 'Maximum number of characters permitted',
94
+ type: 'number'
95
+ }, options);
96
+ },
97
+ noBorder: (options?: any) => {
98
+ return Object.assign({
99
+ control: 'boolean',
100
+ description: 'Use the borderless display variant'
101
+ }, options);
102
+ },
103
+ onBlur: (options?: any) => {
104
+ return Object.assign({
105
+ description: 'Function to fire in response to a blur event',
106
+ type: 'function'
107
+ }, options);
108
+ },
109
+ onChange: (options?: any) => {
110
+ return Object.assign({
111
+ description: 'Function to fire in response to a change event',
112
+ type: 'function'
113
+ }, options);
114
+ },
115
+ onClick: (options?: any) => {
116
+ return Object.assign({
117
+ description: 'Function to fire in response to a click event',
118
+ type: 'function'
119
+ }, options);
120
+ },
121
+ }
122
+
123
+ export default SGDSArgTypes;
@@ -0,0 +1,9 @@
1
+ import { create } from 'storybook/theming';
2
+
3
+ export default create({
4
+ base: 'light',
5
+ brandTitle: 'Scottish Government Design System',
6
+ brandUrl: 'https://designsystem.gov.scot',
7
+ brandImage: 'static/images/scottish-government--min.svg',
8
+ brandTarget: '_self',
9
+ });
@@ -0,0 +1,7 @@
1
+ import * as a11yAddonAnnotations from "@storybook/addon-a11y/preview";
2
+ import { setProjectAnnotations } from '@storybook/react-vite';
3
+ import * as projectAnnotations from './preview';
4
+
5
+ // This is an important step to apply the right configuration when testing your stories.
6
+ // More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
7
+ setProjectAnnotations([a11yAddonAnnotations, projectAnnotations]);
@@ -6,11 +6,11 @@ declare namespace SGDS.Common {
6
6
  }
7
7
 
8
8
  interface AbstractNotificationBanner extends React.AllHTMLAttributes<HTMLDivElement> {
9
- close?: boolean,
10
9
  hasIcon?: boolean,
11
- icon?: IconName,
12
10
  hasColourIcon?: boolean,
13
11
  hasInverseIcon?: boolean,
12
+ icon?: IconName,
13
+ isDismissable?: boolean,
14
14
  title: string,
15
15
  ref?: any
16
16
  }
@@ -1,6 +1,6 @@
1
1
  declare namespace SGDS.Common {
2
2
  interface ActionLink extends React.AllHTMLAttributes<HTMLElement> {
3
- describedby: string,
3
+ describedby?: string,
4
4
  href?: string,
5
5
  linkComponent?: SGDS.LinkComponent,
6
6
  onclick?: React.EventHandler<any>
@@ -2,7 +2,7 @@ declare namespace SGDS.Common {
2
2
  interface Icon extends React.AllHTMLAttributes<SVGSVGElement> {
3
3
  ariaLabel?: React.AriaAttributes['aria-label'],
4
4
  className?: string,
5
- fill?: boolean,
5
+ isFilled?: boolean,
6
6
  icon: IconName,
7
7
  iconSize?: string
8
8
  }
@@ -1,8 +1,8 @@
1
1
  declare namespace SGDS.Component {
2
2
  namespace Accordion {
3
3
  interface Item extends React.AllHTMLAttributes<HTMLElement> {
4
- id: string,
5
- open?: boolean,
4
+ id?: string,
5
+ isOpen?: boolean,
6
6
  title: string
7
7
  }
8
8
  }
@@ -4,13 +4,13 @@ declare namespace SGDS.Component {
4
4
  type ButtonWidth = 'fluid' | 'fixed' | 'max';
5
5
 
6
6
  interface Button extends React.AllHTMLAttributes<HTMLButtonElement> {
7
- icon?: IconName,
8
- iconLeft?: boolean
9
- iconOnly?: boolean,
7
+ hasLinkStyle?: boolean,
10
8
  href?: string,
11
- small?: boolean,
9
+ icon?: IconName,
10
+ isIconLeft?: boolean
11
+ isIconOnly?: boolean,
12
+ isSmall?: boolean,
12
13
  buttonStyle?: ButtonStyle,
13
- styleAsLink?: boolean,
14
14
  type?: ButtonType
15
15
  width?: ButtonWidth
16
16
  }
@@ -0,0 +1,10 @@
1
+ declare namespace SGDS.Component {
2
+ interface CategoryItem extends React.AllHTMLAttributes<HTMLElement> {
3
+ className?: string,
4
+ headingLevel?: SGDS.HeadingLevel,
5
+ href?: string,
6
+ linkComponent?: SGDS.LinkComponent
7
+ tagName?: string,
8
+ title: string,
9
+ }
10
+ }
@@ -0,0 +1,7 @@
1
+ declare namespace SGDS.Component {
2
+ interface CategoryList extends React.AllHTMLAttributes<HTMLElement> {
3
+ className?: string,
4
+ isGrid?: boolean,
5
+ isOrdered?: boolean
6
+ }
7
+ }
@@ -1,11 +1,11 @@
1
1
  declare namespace SGDS.Component {
2
2
  namespace Checkbox {
3
3
  interface Group extends React.AllHTMLAttributes<HTMLElement> {
4
- small?: boolean
4
+ isSmall?: boolean
5
5
  }
6
6
  }
7
7
 
8
8
  interface Checkbox extends CheckboxRadioBase<HTMLInputElement> {
9
- exclusive?: boolean
9
+ isExclusive?: boolean
10
10
  }
11
11
  }
@@ -1,7 +1,7 @@
1
1
  declare namespace SGDS.Component {
2
2
  namespace ContentsNav {
3
3
  interface ContentsNavItem extends React.AllHTMLAttributes<HTMLElement> {
4
- current?: boolean,
4
+ isCurrent?: boolean,
5
5
  linkComponent?: SGDS.LinkComponent;
6
6
  }
7
7
  }
@@ -10,7 +10,7 @@ declare namespace SGDS.Component {
10
10
  label: string,
11
11
  maxDate?: string,
12
12
  minDate?: string,
13
- multiple?: boolean,
13
+ isMultiple?: boolean,
14
14
  name?: string,
15
15
  onBlur?: React.EventHandler<any>,
16
16
  onChange?: React.EventHandler<any>,
@@ -1,6 +1,5 @@
1
1
  declare namespace SGDS.Component {
2
2
  interface ErrorMessage extends React.AllHTMLAttributes<HTMLElement> {
3
- id?: string,
4
- text: string | undefined
3
+ id?: string
5
4
  }
6
5
  }
@@ -2,7 +2,7 @@ declare namespace SGDS.Component {
2
2
  namespace ErrorSummary {
3
3
  interface Item extends React.AllHTMLAttributes<HTMLElement> {
4
4
  fragmentId: string,
5
- linkComponent: SGDS.LinkComponent
5
+ linkComponent?: SGDS.LinkComponent
6
6
  }
7
7
  }
8
8
 
@@ -1,11 +1,11 @@
1
1
  declare namespace SGDS.Component {
2
2
  interface FileDownload extends React.AllHTMLAttributes<HTMLElement> {
3
3
  cover?: string,
4
- icon?: DocumentIconName,
5
4
  fileSize?: string,
6
5
  fileType?: string,
7
6
  fileUrl: string,
8
- highlighted?: boolean,
7
+ icon?: DocumentIconName,
8
+ isHighlighted?: boolean,
9
9
  title: string
10
10
  }
11
11
  }
@@ -6,6 +6,6 @@ declare namespace SGDS.Component {
6
6
  }
7
7
 
8
8
  interface Metadata extends React.AllHTMLAttributes<HTMLDListElement> {
9
- inline?: boolean
9
+ isInline?: boolean
10
10
  }
11
11
  }
@@ -2,7 +2,7 @@ declare namespace SGDS.Component {
2
2
  namespace Pagination {
3
3
  interface Page extends React.AllHTMLAttributes<HTMLElement> {
4
4
  ariaLabel: React.AriaAttributes['aria-label'],
5
- current?: boolean,
5
+ isCurrent?: boolean,
6
6
  href: string,
7
7
  linkComponent?: SGDS.LinkComponent,
8
8
  onClick?: React.EventHandler<any>
@@ -1,9 +1,9 @@
1
1
  declare namespace SGDS.Component {
2
2
  namespace RadioButton {
3
3
  interface Group extends React.AllHTMLAttributes<HTMLElement> {
4
- inline?: boolean,
4
+ isInline?: boolean,
5
5
  name: string,
6
- small?: boolean
6
+ isSmall?: boolean
7
7
  }
8
8
  }
9
9
 
@@ -5,7 +5,7 @@ declare namespace SGDS.Component {
5
5
  }
6
6
 
7
7
  interface Item extends React.AllHTMLAttributes<HTMLLIElement> {
8
- current?: boolean,
8
+ isCurrent?: boolean,
9
9
  href: string,
10
10
  linkComponent?: SGDS.LinkComponent,
11
11
  title: string,
@@ -1,7 +1,7 @@
1
1
  declare namespace SGDS.Component {
2
2
  namespace SiteNavigation {
3
3
  interface Item extends React.AllHTMLAttributes<HTMLLIElement> {
4
- current?: boolean,
4
+ isCurrent?: boolean,
5
5
  href: string,
6
6
  linkComponent?: SGDS.LinkComponent
7
7
  }
@@ -9,6 +9,6 @@ declare namespace SGDS.Component {
9
9
  }
10
10
 
11
11
  interface SummaryList extends React.OlHTMLAttributes<HTMLOListElement> {
12
- noBorder?: boolean
12
+ isBorderless?: boolean
13
13
  }
14
14
  }
@@ -1,7 +1,7 @@
1
1
  declare namespace SGDS.Component {
2
2
  namespace Tabs {
3
3
  interface Item extends React.AllHTMLAttributes<HTMLElement> {
4
- bordered?: boolean,
4
+ isBorderless?: boolean,
5
5
  id: string,
6
6
  tabLabel: string
7
7
  }
@@ -13,9 +13,9 @@ declare namespace SGDS.Component {
13
13
 
14
14
  interface Tabs extends React.AllHTMLAttributes<HTMLElement> {
15
15
  baseId: string,
16
- bordered?: boolean,
16
+ isBorderless?: boolean,
17
17
  headingLevel?: SGDS.HeadingLevel,
18
- manual?: boolean,
18
+ isManual?: boolean,
19
19
  title: string
20
20
  }
21
21
  }
@@ -3,9 +3,9 @@ declare namespace SGDS.Component {
3
3
  buttonIcon?: IconName,
4
4
  buttonText?: string,
5
5
  className?: string,
6
- currency?: boolean,
7
6
  currencySymbol?: string,
8
7
  hasButton?: boolean,
8
+ isCurrency?: boolean,
9
9
  type?: string,
10
10
  width?: InputWidth
11
11
  }
package/@types/sgds.d.ts CHANGED
@@ -4,6 +4,7 @@ declare namespace SGDS {
4
4
  type DocumentIconName = 'Audio' | 'Csv' | 'Excel' | 'File' | 'Generic' | 'Geodata' | 'Ical' | 'Ico' | 'Image' | 'Odf' | 'Odg' | 'Odp' | 'Ods' | 'Odt' | 'Pdf' | 'Ppt' | 'Rtf' | 'Text' | 'Video' | 'Word' | 'Xml' | 'Zip';
5
5
  type InputWidth = 'fixed-20' | 'fixed-10' | 'fixed-5' | 'fixed-4' | 'fixed-3' | 'fixed-2' | 'fluid-three-quarters' | 'fluid-two-thirds' | 'fluid-half' | 'fluid-one-third' | 'fluid-one-quarter';
6
6
  type TagColour = 'grey' | 'green' | 'teal' | 'blue' | 'purple' | 'pink' | 'red' | 'orange' | 'yellow';
7
+ type TextInputType = 'date' | 'datetime-local' | 'email' | 'month' | 'number' | 'password' | 'search' | 'tel' | 'text' | 'time' | 'url' | 'week';
7
8
 
8
9
  type LinkComponent = (linkComponent: LinkComponentProps) => React.ReactNode;
9
10
 
@@ -25,7 +26,7 @@ declare namespace SGDS {
25
26
  name?: string,
26
27
  onBlur?: React.EventHandler<any>,
27
28
  onChange?: React.EventHandler<any>,
28
- small?: boolean
29
+ isSmall?: boolean
29
30
  }
30
31
 
31
32
  interface FormFieldBase<T> extends React.AllHTMLAttributes <T> {
package/CHANGELOG.md CHANGED
@@ -7,6 +7,35 @@ Changes are grouped under the labels: `Added`, `Changed`, `Deprecated`, `Fixed`,
7
7
 
8
8
  ---
9
9
 
10
+ ## [0.9.0] - 2025-09-17
11
+ ## Added
12
+ - Storybook now added for all components. `npm run storybook`
13
+ - CategoryList component
14
+ - CategoryItem component
15
+ ## Changed
16
+ - 'text' prop removed from ErrorMessage. Use children instead.
17
+ - Many boolean prop names updated for clarity/consistency
18
+ - AbstractNotificationBanner (used by NotificationBanner and CookieBanner): close -> isDismissable
19
+ - Accordion.Item: open -> isOpen
20
+ - Button: small -> isSmall
21
+ - Button: iconLeft -> isIconLeft
22
+ - Button: iconOnly -> isIconOnly
23
+ - Button: styleAsLink -> hasLinkStyle
24
+ - Checkbox: exclusive -> isExclusive
25
+ - CheckboxGroup: small -> isSmall
26
+ - ContentsNav: curent -> isCurrent
27
+ - DatePicker: multiple -> isMultiple
28
+ - FileDownload: highlighted -> isHighlighted
29
+ - Metadata: inline -> isInline
30
+ - Pagination.Item: current -> isCurrent
31
+ - RadioButton: inline -> isInline
32
+ - RadioGroup: small -> isSmall
33
+ - SideNavigation.Item: current -> isCurrent
34
+ - SiteNavigation.Item: current -> isCurrent
35
+ - SummaryList: noBorder -> isBorderless
36
+ - Tabs: bordered -> isBorderless (logic inverted), manual -> isManual
37
+ - TextInput: currency -> isCurrency
38
+
10
39
  ## [0.8.0] - 2025-08-18
11
40
  ## Added
12
41
  - ActionLink component, centralising behaviour used in actions in both SummaryCard and SummaryList
@@ -9,7 +9,7 @@ const ScreenReaderText_1 = __importDefault(require("./ScreenReaderText"));
9
9
  const Buttons = ({ children }) => {
10
10
  return (<>{children}</>);
11
11
  };
12
- const AbstractNotificationBanner = ({ children, className, close, hasColourIcon, hasInverseIcon, icon, title = 'Information', ...props }) => {
12
+ const AbstractNotificationBanner = ({ children, className, hasColourIcon, hasInverseIcon, icon, isDismissable, title = 'Information', ...props }) => {
13
13
  let content = [];
14
14
  let buttons;
15
15
  react_1.Children.forEach(children, (child) => {
@@ -28,7 +28,7 @@ const AbstractNotificationBanner = ({ children, className, close, hasColourIcon,
28
28
  <div className="ds_wrapper">
29
29
  <div className={[
30
30
  'ds_notification__content',
31
- close && 'ds_notification__content--has-close'
31
+ isDismissable && 'ds_notification__content--has-close'
32
32
  ].join(' ')}>
33
33
  <h2 className="visually-hidden">{title}</h2>
34
34
 
@@ -45,10 +45,10 @@ const AbstractNotificationBanner = ({ children, className, close, hasColourIcon,
45
45
  {content}
46
46
  </div>
47
47
 
48
- {close &&
48
+ {isDismissable &&
49
49
  <button type="button" className="ds_notification__close js-close-notification">
50
50
  <ScreenReaderText_1.default>Close this notification</ScreenReaderText_1.default>
51
- <Icon_1.default fill icon="Close" aria-hidden="true"/>
51
+ <Icon_1.default isFilled icon="Close" aria-hidden="true"/>
52
52
  </button>}
53
53
 
54
54
  {buttons &&
@@ -38,12 +38,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  const react_1 = __importDefault(require("react"));
40
40
  const Icons = __importStar(require("../images/icons"));
41
- const Icon = ({ ariaLabel, className, fill, icon, iconSize }) => {
41
+ const Icon = ({ ariaLabel, className, isFilled, icon, iconSize }) => {
42
42
  const IconComponent = Icons[icon];
43
43
  return (<IconComponent aria-hidden={ariaLabel ? undefined : true} aria-label={ariaLabel} className={[
44
44
  'ds_icon',
45
45
  className,
46
- fill && 'ds_icon--fill',
46
+ isFilled && 'ds_icon--fill',
47
47
  iconSize && `ds_icon--${iconSize}`
48
48
  ].join(' ')}/>);
49
49
  };
@@ -42,14 +42,10 @@ const WrapperTag_1 = __importDefault(require("../../common/WrapperTag"));
42
42
  const accordion_1 = __importDefault(require("@scottish-government/design-system/src/components/accordion/accordion"));
43
43
  let accordionItemCounter = 0;
44
44
  const AccordionHeadingLevelContext = (0, react_1.createContext)('h3');
45
- const AccordionItem = ({ children, className, id: rawId, open = false, title, ...props }) => {
45
+ const AccordionItem = ({ children, className, id: rawId, isOpen = false, title, ...props }) => {
46
46
  accordionItemCounter = accordionItemCounter + 1;
47
- const processedId = rawId || `accordion-item-${accordionItemCounter}`;
48
- const DEFAULT_HEADING_LEVEL = 'h3';
47
+ const processedId = rawId || `accordion-item-${(0, react_1.useId)()}`;
49
48
  let headingLevel = (0, react_1.useContext)(AccordionHeadingLevelContext);
50
- if (!['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(headingLevel)) {
51
- headingLevel = DEFAULT_HEADING_LEVEL;
52
- }
53
49
  return (<div className={[
54
50
  'ds_accordion-item',
55
51
  className
@@ -57,7 +53,7 @@ const AccordionItem = ({ children, className, id: rawId, open = false, title, ..
57
53
  <input aria-labelledby={`panel-${processedId}-heading`} className={[
58
54
  'ds_accordion-item__control',
59
55
  'visually-hidden'
60
- ].join(' ')} defaultChecked={open} id={`${processedId}-control`} type="checkbox"/>
56
+ ].join(' ')} defaultChecked={isOpen} id={`${processedId}-control`} type="checkbox"/>
61
57
  <div className="ds_accordion-item__header">
62
58
  <WrapperTag_1.default id={`panel-${processedId}-heading`} className="ds_accordion-item__title" tagName={headingLevel}>
63
59
  {title}
@@ -6,22 +6,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const Icon_1 = __importDefault(require("../../common/Icon"));
7
7
  const ScreenReaderText_1 = __importDefault(require("../../common/ScreenReaderText"));
8
8
  const WrapperTag_1 = __importDefault(require("../../common/WrapperTag"));
9
- const Button = ({ buttonStyle, children, className, icon, iconLeft, iconOnly = false, href, small, styleAsLink, type = 'button', width, ...props }) => {
9
+ const Button = ({ buttonStyle, children, className, icon, hasLinkStyle, href, isIconLeft, isIconOnly = false, isSmall, type = 'button', width, ...props }) => {
10
10
  // determine which HTML tag to use
11
11
  let tagName = 'button';
12
12
  if (href) {
13
13
  tagName = 'a';
14
14
  }
15
15
  return (<WrapperTag_1.default tagName={tagName} className={[
16
- !styleAsLink ? 'ds_button' : 'ds_link',
16
+ !hasLinkStyle ? 'ds_button' : 'ds_link',
17
17
  width && `ds_button--${width}`,
18
18
  buttonStyle && `ds_button--${buttonStyle}`,
19
- small && 'ds_button--small',
20
- (icon && !iconOnly) ? 'ds_button--has-icon' : undefined,
21
- iconLeft && 'ds_button--has-icon--left',
19
+ isSmall && 'ds_button--small',
20
+ (icon && !isIconOnly) ? 'ds_button--has-icon' : undefined,
21
+ isIconLeft && 'ds_button--has-icon--left',
22
22
  className
23
23
  ].join(' ')} href={href} {...(tagName === 'button' ? { type: type } : {})} {...props}>
24
- {iconOnly ? <ScreenReaderText_1.default>{children}</ScreenReaderText_1.default> : children}
24
+ {isIconOnly ? <ScreenReaderText_1.default>{children}</ScreenReaderText_1.default> : children}
25
25
 
26
26
  {icon && <Icon_1.default icon={icon}/>}
27
27
  </WrapperTag_1.default>);