@scottish-government/designsystem-react 0.10.2 → 0.11.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.
- package/@types/components/Accordion.d.ts +3 -2
- package/@types/components/ButtonGroup.d.ts +5 -0
- package/@types/components/RadioButton.d.ts +2 -2
- package/@types/components/SearchFacets.d.ts +18 -0
- package/@types/components/SearchFilters.d.ts +14 -0
- package/@types/components/SearchResult.d.ts +30 -0
- package/@types/components/SearchSort.d.ts +9 -0
- package/@types/components/SideNavigation.d.ts +1 -1
- package/CHANGELOG.md +31 -5
- package/dist/components/Accordion/Accordion.jsx +8 -3
- package/dist/components/ButtonGroup/ButtonGroup.jsx +13 -0
- package/dist/components/RadioButton/RadioGroup.jsx +1 -1
- package/dist/components/SearchFacets/SearchFacets.jsx +101 -0
- package/dist/components/SearchFilters/SearchFilters.jsx +63 -0
- package/dist/components/SearchResult/SearchResult.jsx +93 -0
- package/dist/components/SearchSort/SearchSort.jsx +28 -0
- package/dist/components/SequentialNavigation/SequentialNavigation.jsx +0 -1
- package/dist/components/SideNavigation/SideNavigation.jsx +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/components/Accordion/Accordion.Item.stories.tsx +10 -9
- package/src/components/Accordion/Accordion.stories.tsx +4 -4
- package/src/components/Accordion/Accordion.test.tsx +48 -14
- package/src/components/Accordion/Accordion.tsx +12 -1
- package/src/components/Breadcrumbs/Breadcrumbs.Item.stories.tsx +8 -1
- package/src/components/Button/Button.stories.tsx +1 -1
- package/src/components/ButtonGroup/ButtonGroup.stories.tsx +41 -0
- package/src/components/ButtonGroup/ButtonGroup.test.tsx +45 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +20 -0
- package/src/components/ContentsNav/ContentsNav.Item.stories.tsx +8 -0
- package/src/components/ErrorSummary/ErrorSummary.Item.stories.tsx +7 -0
- package/src/components/PageMetadata/PageMetadata.Item.stories.tsx +9 -0
- package/src/components/RadioButton/RadioGroup.tsx +2 -2
- package/src/components/SearchFacets/SearchFacets.Group.stories.tsx +56 -0
- package/src/components/SearchFacets/SearchFacets.Item.stories.tsx +53 -0
- package/src/components/SearchFacets/SearchFacets.stories.tsx +38 -0
- package/src/components/SearchFacets/SearchFacets.test.tsx +214 -0
- package/src/components/SearchFacets/SearchFacets.tsx +99 -0
- package/src/components/SearchFilters/SearchFilters.Panel.stories.tsx +201 -0
- package/src/components/SearchFilters/SearchFilters.stories.tsx +137 -0
- package/src/components/SearchFilters/SearchFilters.test.tsx +161 -0
- package/src/components/SearchFilters/SearchFilters.tsx +89 -0
- package/src/components/SearchResult/SearchResult.stories.tsx +111 -0
- package/src/components/SearchResult/SearchResult.test.tsx +215 -0
- package/src/components/SearchResult/SearchResult.tsx +137 -0
- package/src/components/SearchSort/SearchSort.stories.tsx +32 -0
- package/src/components/SearchSort/SearchSort.test.tsx +129 -0
- package/src/components/SearchSort/SearchSort.tsx +45 -0
- package/src/components/SequentialNavigation/SequentialNavigation.Next.stories.tsx +1 -1
- package/src/components/SequentialNavigation/SequentialNavigation.Previous.stories.tsx +1 -1
- package/src/components/SequentialNavigation/SequentialNavigation.tsx +0 -1
- package/src/components/SideNavigation/SideNavigation.Item.stories.tsx +9 -0
- package/src/components/SideNavigation/SideNavigation.List.stories.tsx +7 -0
- package/src/components/SideNavigation/SideNavigation.tsx +2 -1
- package/src/components/SiteFooter/SiteFooter.License.stories.tsx +7 -0
- package/src/components/SiteFooter/SiteFooter.Link.stories.tsx +9 -0
- package/src/components/SiteFooter/SiteFooter.Org.stories.tsx +7 -0
- package/src/components/SiteNavigation/SiteNavigation.Item.stories.tsx +10 -0
- package/src/components/SkipLinks/SkipLinks.Item.stories.tsx +11 -1
- package/src/components/SummaryCard/SummaryCard.Action.stories.tsx +7 -0
- package/src/components/SummaryCard/SummaryCard.stories.tsx +7 -0
- package/src/components/SummaryList/SummaryList.Item.stories.tsx +15 -0
- package/src/components/SummaryList/SummaryList.Value.stories.tsx +5 -2
- package/src/components/Tabs/Tabs.Item.stories.tsx +4 -1
- package/src/components/TaskList/TaskList.Group.stories.tsx +9 -0
- package/src/components/TaskList/TaskList.Item.stories.tsx +7 -0
|
@@ -2,13 +2,14 @@ declare namespace SGDS.Component {
|
|
|
2
2
|
namespace Accordion {
|
|
3
3
|
interface Item extends React.AllHTMLAttributes<HTMLElement> {
|
|
4
4
|
id?: string,
|
|
5
|
+
heading: string | React.ReactNode
|
|
5
6
|
isOpen?: boolean,
|
|
6
|
-
title: string
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
interface Accordion extends React.AllHTMLAttributes<HTMLElement> {
|
|
11
11
|
headingLevel?: SGDS.HeadingLevel,
|
|
12
|
-
hideOpenAll?: boolean
|
|
12
|
+
hideOpenAll?: boolean,
|
|
13
|
+
isSmall?: boolean
|
|
13
14
|
}
|
|
14
15
|
}
|
|
@@ -2,13 +2,13 @@ declare namespace SGDS.Component {
|
|
|
2
2
|
namespace RadioButton {
|
|
3
3
|
interface Group extends React.AllHTMLAttributes<HTMLElement> {
|
|
4
4
|
isInline?: boolean,
|
|
5
|
-
name
|
|
5
|
+
name?: string,
|
|
6
6
|
isSmall?: boolean
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
interface RadioButton extends CheckboxRadioBase<HTMLInputElement> {
|
|
11
11
|
id: string,
|
|
12
|
-
name
|
|
12
|
+
name?: string
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare namespace SGDS.Component {
|
|
2
|
+
namespace SearchFacets {
|
|
3
|
+
interface Group extends React.AllHTMLAttributes<HTMLElement> {
|
|
4
|
+
joinContent?: string,
|
|
5
|
+
title: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface Item extends React.AllHTMLAttributes<HTMLElement> {
|
|
9
|
+
accessibleName?: string
|
|
10
|
+
joinContent?: string
|
|
11
|
+
title: string
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface SearchFacets extends React.AllHTMLAttributes<HTMLElement> {
|
|
16
|
+
headingId?: string
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare namespace SGDS.Component {
|
|
2
|
+
namespace SearchFilters {
|
|
3
|
+
interface Panel extends React.AllHTMLAttributes<HTMLElement> {
|
|
4
|
+
activeFilterCount?: number,
|
|
5
|
+
heading: string | React.ReactNode
|
|
6
|
+
isScrollable?: boolean,
|
|
7
|
+
legend: string,
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface SearchFilters extends React.AllHTMLAttributes<HTMLElement> {
|
|
12
|
+
searchResultsContainerId?: string
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
declare namespace SGDS.Component {
|
|
2
|
+
namespace SearchResult {
|
|
3
|
+
interface Content extends React.AllHTMLAttributes<HTMLElement> {
|
|
4
|
+
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface Context extends React.AllHTMLAttributes<HTMLDListElement> {
|
|
8
|
+
title: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface ContextItem extends React.AllHTMLAttributes<HTMLElement> {
|
|
12
|
+
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface Media extends React.AllHTMLAttributes<HTMLElement> {
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface Meta extends React.AllHTMLAttributes<HTMLElement> {
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface SearchResult extends React.AllHTMLAttributes<HTMLElement> {
|
|
24
|
+
href: string,
|
|
25
|
+
isPromoted?: boolean,
|
|
26
|
+
linkComponent?: SGDS.LinkComponent,
|
|
27
|
+
promotedTitle?: string,
|
|
28
|
+
title: string
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare namespace SGDS.Component {
|
|
2
|
+
interface SearchSort extends React.AllHTMLAttributes<HTMLElement> {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
onApply?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
8
|
+
}
|
|
9
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -6,13 +6,37 @@ Changes are grouped under the labels: `Added`, `Changed`, `Deprecated`, `Fixed`,
|
|
|
6
6
|
`Removed` and `Security`.
|
|
7
7
|
|
|
8
8
|
---
|
|
9
|
+
## [0.11.0] - 2025-10-22
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
### Added
|
|
12
|
+
- SearchResult, SearchFilters, SearchFacets, SearchSort components
|
|
13
|
+
- ButtonGroup component
|
|
14
|
+
### Changed
|
|
15
|
+
- Accordion.Item now uses a new `heading` prop for its heading content, which allows both string and ReactNode
|
|
16
|
+
- add "ariaLabel" property to SideNavigation to make the aria label editable
|
|
17
|
+
### Deprecated
|
|
18
|
+
- Accordion.Item `title` prop replaced with `heading`
|
|
19
|
+
### Fixed
|
|
20
|
+
- decorators added to many storybook components for correct rendering
|
|
21
|
+
|
|
22
|
+
## [0.10.2] - 2025-09-18
|
|
23
|
+
### Fixed
|
|
24
|
+
- correction to handling of subcomponents in Storybook
|
|
25
|
+
|
|
26
|
+
## [0.10.1] - 2025-09-18
|
|
27
|
+
### Fixed
|
|
28
|
+
- correction to white space on PageMetadata
|
|
29
|
+
|
|
30
|
+
## [0.10.0] - 2025-09-18
|
|
31
|
+
### Added
|
|
12
32
|
- Storybook now added for all components. `npm run storybook`
|
|
13
33
|
- CategoryList component
|
|
14
34
|
- CategoryItem component
|
|
15
|
-
|
|
35
|
+
- useTracking hook, to add DS tracking attributes
|
|
36
|
+
### Changed
|
|
37
|
+
- Accordion uses useContext instead of cloneElement to pass props (headingLevel) to its children
|
|
38
|
+
- CheckboxGroup uses useContext instead of cloneElement to pass props (isSmall) to its children
|
|
39
|
+
- RadioGroup use useContext instead of cloneElement to pass props (isSmall, name) to its children
|
|
16
40
|
- 'text' prop removed from ErrorMessage. Use children instead.
|
|
17
41
|
- Many boolean prop names updated for clarity/consistency
|
|
18
42
|
- AbstractNotificationBanner (used by NotificationBanner and CookieBanner): close -> isDismissable
|
|
@@ -36,13 +60,15 @@ Changes are grouped under the labels: `Added`, `Changed`, `Deprecated`, `Fixed`,
|
|
|
36
60
|
- Tabs: bordered -> isBorderless (logic inverted), manual -> isManual
|
|
37
61
|
- TextInput: currency -> isCurrency
|
|
38
62
|
|
|
63
|
+
## [0.9.0] - skipped due to user error with the CI script
|
|
64
|
+
|
|
39
65
|
## [0.8.0] - 2025-08-18
|
|
40
|
-
|
|
66
|
+
### Added
|
|
41
67
|
- ActionLink component, centralising behaviour used in actions in both SummaryCard and SummaryList
|
|
42
68
|
- SiteFooter component
|
|
43
69
|
- Add support for the SkipLinks 'static' variant
|
|
44
70
|
|
|
45
|
-
|
|
71
|
+
### Changed
|
|
46
72
|
|
|
47
73
|
Two headline changes:
|
|
48
74
|
|
|
@@ -42,10 +42,14 @@ 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, isOpen = false, title, ...props }) => {
|
|
45
|
+
const AccordionItem = ({ children, className, id: rawId, isOpen = false, heading, title, ...props }) => {
|
|
46
46
|
accordionItemCounter = accordionItemCounter + 1;
|
|
47
47
|
const processedId = rawId || `accordion-item-${(0, react_1.useId)()}`;
|
|
48
48
|
let headingLevel = (0, react_1.useContext)(AccordionHeadingLevelContext);
|
|
49
|
+
if (title) {
|
|
50
|
+
console.warn('Warning: Using the `title` prop for heading text on an Accordion.Item is deprecated and will be removed in a future release. Please use the `heading` prop instead.');
|
|
51
|
+
heading = heading || title;
|
|
52
|
+
}
|
|
49
53
|
return (<div className={[
|
|
50
54
|
'ds_accordion-item',
|
|
51
55
|
className
|
|
@@ -56,7 +60,7 @@ const AccordionItem = ({ children, className, id: rawId, isOpen = false, title,
|
|
|
56
60
|
].join(' ')} defaultChecked={isOpen} id={`${processedId}-control`} type="checkbox"/>
|
|
57
61
|
<div className="ds_accordion-item__header">
|
|
58
62
|
<WrapperTag_1.default id={`panel-${processedId}-heading`} className="ds_accordion-item__title" tagName={headingLevel}>
|
|
59
|
-
{
|
|
63
|
+
{heading}
|
|
60
64
|
</WrapperTag_1.default>
|
|
61
65
|
<span className="ds_accordion-item__indicator"/>
|
|
62
66
|
<label className="ds_accordion-item__label" htmlFor={`${processedId}-control`}>
|
|
@@ -68,7 +72,7 @@ const AccordionItem = ({ children, className, id: rawId, isOpen = false, title,
|
|
|
68
72
|
</div>
|
|
69
73
|
</div>);
|
|
70
74
|
};
|
|
71
|
-
const Accordion = ({ children, className, headingLevel = 'h3', hideOpenAll, ...props }) => {
|
|
75
|
+
const Accordion = ({ children, className, headingLevel = 'h3', hideOpenAll, isSmall, ...props }) => {
|
|
72
76
|
const ref = (0, react_1.useRef)(null);
|
|
73
77
|
(0, react_1.useEffect)(() => {
|
|
74
78
|
if (ref.current) {
|
|
@@ -80,6 +84,7 @@ const Accordion = ({ children, className, headingLevel = 'h3', hideOpenAll, ...p
|
|
|
80
84
|
}
|
|
81
85
|
return (<div className={[
|
|
82
86
|
'ds_accordion',
|
|
87
|
+
isSmall ? 'ds_accordion--small' : '',
|
|
83
88
|
className
|
|
84
89
|
].join(' ')} ref={ref} {...props}>
|
|
85
90
|
{!hideOpenAll && (<button className={[
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ButtonGroup = ({ children, className, isInline, ...props }) => {
|
|
4
|
+
return (<div className={[
|
|
5
|
+
"ds_button-group",
|
|
6
|
+
isInline ? "ds_button-group--inline" : undefined,
|
|
7
|
+
className
|
|
8
|
+
].join(' ')} {...props}>
|
|
9
|
+
{children}
|
|
10
|
+
</div>);
|
|
11
|
+
};
|
|
12
|
+
ButtonGroup.displayName = 'ButtonGroup';
|
|
13
|
+
exports.default = ButtonGroup;
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const react_1 = __importDefault(require("react"));
|
|
7
7
|
const context_1 = require("../../utils/context");
|
|
8
|
-
const RadioGroup = ({ children, className, isInline, isSmall, name, ...props }) => {
|
|
8
|
+
const RadioGroup = ({ children, className, isInline, isSmall, name = '', ...props }) => {
|
|
9
9
|
return (<div className={[
|
|
10
10
|
'ds_radios',
|
|
11
11
|
'ds_field-group',
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const react_1 = __importStar(require("react"));
|
|
40
|
+
const Icon_1 = __importDefault(require("../../common/Icon"));
|
|
41
|
+
const icons_1 = require("../../../src/images/icons");
|
|
42
|
+
const FacetsItem = ({ accessibleName, joinContent, onClick, title, ...props }) => {
|
|
43
|
+
accessibleName = accessibleName ? accessibleName : title;
|
|
44
|
+
return (<dd className="ds_facet-wrapper" {...props}>
|
|
45
|
+
{joinContent &&
|
|
46
|
+
<span aria-hidden="true">{joinContent}</span>}
|
|
47
|
+
<span className="ds_facet">
|
|
48
|
+
{title}
|
|
49
|
+
<button type="button" onClick={onClick} aria-label={`Remove '${accessibleName}' filter`} className="ds_facet__button">
|
|
50
|
+
<Icon_1.default className="ds_facet__button-icon" aria-hidden="true" role="img" icon="Cancel"/>
|
|
51
|
+
</button>
|
|
52
|
+
</span>
|
|
53
|
+
</dd>);
|
|
54
|
+
};
|
|
55
|
+
const FacetsGroup = ({ children, joinContent = 'or', title, ...props }) => {
|
|
56
|
+
return (<div className="ds_facet-group" {...props}>
|
|
57
|
+
<dt className="ds_facet__group-title">
|
|
58
|
+
{title.trim()}:
|
|
59
|
+
</dt>
|
|
60
|
+
{react_1.Children.map(children, (child, index) => {
|
|
61
|
+
const thisChild = child;
|
|
62
|
+
return react_1.default.cloneElement(thisChild, { joinContent: index > 0 ? joinContent : undefined, key: 'facet' + index });
|
|
63
|
+
})}
|
|
64
|
+
</div>);
|
|
65
|
+
};
|
|
66
|
+
const Facets = ({ children, className, ...props }) => {
|
|
67
|
+
let facetCount = 0;
|
|
68
|
+
function processChild(item) {
|
|
69
|
+
if (item.type.displayName === 'Facets.Item') {
|
|
70
|
+
facetCount = facetCount + 1;
|
|
71
|
+
}
|
|
72
|
+
else if (item.type.displayName === 'Facets.Group') {
|
|
73
|
+
react_1.Children.forEach(item.props.children, child => {
|
|
74
|
+
processChild(child);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
react_1.Children.forEach(children, child => {
|
|
79
|
+
processChild(child);
|
|
80
|
+
});
|
|
81
|
+
return (<div className={[
|
|
82
|
+
"ds_facets",
|
|
83
|
+
className
|
|
84
|
+
].join(' ')} {...props}>
|
|
85
|
+
<p className="visually-hidden">There {facetCount === 1 ? 'is' : 'are'} {facetCount} search {facetCount === 1 ? 'filter' : 'filters'} applied</p>
|
|
86
|
+
<dl className="ds_facets__list">
|
|
87
|
+
{children}
|
|
88
|
+
</dl>
|
|
89
|
+
{facetCount > 0 &&
|
|
90
|
+
<button className="ds_button ds_button--secondary ds_button--has-icon ds_facets__clear-button" type="button">
|
|
91
|
+
Clear all filters
|
|
92
|
+
<icons_1.Cancel className="ds_facet__button-icon"/>
|
|
93
|
+
</button>}
|
|
94
|
+
</div>);
|
|
95
|
+
};
|
|
96
|
+
Facets.displayName = 'Facets';
|
|
97
|
+
FacetsItem.displayName = 'Facets.Item';
|
|
98
|
+
FacetsGroup.displayName = 'Facets.Group';
|
|
99
|
+
Facets.Item = FacetsItem;
|
|
100
|
+
Facets.Group = FacetsGroup;
|
|
101
|
+
exports.default = Facets;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FilterPanel = void 0;
|
|
7
|
+
const Accordion_1 = __importDefault(require("../Accordion/Accordion"));
|
|
8
|
+
const Button_1 = __importDefault(require("../Button/Button"));
|
|
9
|
+
const SkipLinks_1 = __importDefault(require("../SkipLinks/SkipLinks"));
|
|
10
|
+
const ConditionalWrapper_1 = __importDefault(require("../../common/ConditionalWrapper"));
|
|
11
|
+
const CheckboxGroup_1 = __importDefault(require("../Checkbox/CheckboxGroup"));
|
|
12
|
+
const FilterPanel = ({ activeFilterCount = 0, children, isScrollable = false, legend, heading = 'Filter', ...props }) => {
|
|
13
|
+
const headingWithCount = <>
|
|
14
|
+
{heading}
|
|
15
|
+
{activeFilterCount > 0 && <div className="ds_search-filters__filter-count">({activeFilterCount} selected)</div>}
|
|
16
|
+
</>;
|
|
17
|
+
return (<Accordion_1.default.Item heading={headingWithCount} {...props}>
|
|
18
|
+
<fieldset>
|
|
19
|
+
<legend className="visually-hidden">{legend}</legend>
|
|
20
|
+
|
|
21
|
+
<ConditionalWrapper_1.default condition={isScrollable} wrapper={(children) => <div className="ds_search-filters__scrollable">{children}</div>}>
|
|
22
|
+
{children}
|
|
23
|
+
</ConditionalWrapper_1.default>
|
|
24
|
+
</fieldset>
|
|
25
|
+
</Accordion_1.default.Item>);
|
|
26
|
+
};
|
|
27
|
+
exports.FilterPanel = FilterPanel;
|
|
28
|
+
const FilterCheckboxGroup = ({ children, ...props }) => {
|
|
29
|
+
return (<CheckboxGroup_1.default className="ds_search-filters__checkboxes" isSmall {...props}>
|
|
30
|
+
{children}
|
|
31
|
+
</CheckboxGroup_1.default>);
|
|
32
|
+
};
|
|
33
|
+
const Filters = ({ children, searchResultsContainerId = 'search-results', ...props }) => {
|
|
34
|
+
return (<div className="ds_search-filters" {...props}>
|
|
35
|
+
<div className="ds_details ds_no-margin" data-module="ds-details">
|
|
36
|
+
<input id="filters-toggle" type="checkbox" className="ds_details__toggle visually-hidden"/>
|
|
37
|
+
<label htmlFor="filters-toggle" className="ds_details__summary">
|
|
38
|
+
Search filters
|
|
39
|
+
</label>
|
|
40
|
+
|
|
41
|
+
<SkipLinks_1.default isStatic>
|
|
42
|
+
<SkipLinks_1.default.Link fragmentId={searchResultsContainerId}>Skip to results</SkipLinks_1.default.Link>
|
|
43
|
+
</SkipLinks_1.default>
|
|
44
|
+
|
|
45
|
+
<div className="ds_details__text">
|
|
46
|
+
<form id="filters">
|
|
47
|
+
<h2 className="ds_search-filters__title ds_h4">Filter by</h2>
|
|
48
|
+
|
|
49
|
+
<Accordion_1.default className="ds_!_margin-top--0" isSmall hideOpenAll>
|
|
50
|
+
{children}
|
|
51
|
+
</Accordion_1.default>
|
|
52
|
+
|
|
53
|
+
<Button_1.default isSmall width="max" className="ds_no-margin">Apply filter</Button_1.default>
|
|
54
|
+
</form>
|
|
55
|
+
</div>
|
|
56
|
+
</div>
|
|
57
|
+
</div>);
|
|
58
|
+
};
|
|
59
|
+
Filters.Panel = exports.FilterPanel;
|
|
60
|
+
Filters.CheckboxGroup = FilterCheckboxGroup;
|
|
61
|
+
FilterCheckboxGroup.displayName = 'Filters.CheckboxGroup';
|
|
62
|
+
exports.FilterPanel.displayName = 'Filters.Panel';
|
|
63
|
+
exports.default = Filters;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const ConditionalWrapper_1 = __importDefault(require("../../common/ConditionalWrapper"));
|
|
8
|
+
const AspectBox_1 = __importDefault(require("../AspectBox/AspectBox"));
|
|
9
|
+
const PageMetadata_1 = __importDefault(require("../PageMetadata/PageMetadata"));
|
|
10
|
+
const SearchResultLinkHrefContext = (0, react_1.createContext)('');
|
|
11
|
+
const SearchResultContent = ({ children }) => {
|
|
12
|
+
const otherChildren = [];
|
|
13
|
+
let imageChild = null;
|
|
14
|
+
// assign to slots
|
|
15
|
+
react_1.Children.forEach(children, (child) => {
|
|
16
|
+
const thisChild = child;
|
|
17
|
+
if (thisChild && thisChild.type === SearchResultMedia) {
|
|
18
|
+
imageChild = thisChild;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
otherChildren.push(thisChild);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return (imageChild ?
|
|
25
|
+
(<div className="ds_search-result__has-media">
|
|
26
|
+
{imageChild}
|
|
27
|
+
<div className="ds_search-result__summary">{otherChildren}</div>
|
|
28
|
+
</div>)
|
|
29
|
+
:
|
|
30
|
+
(<div className="ds_search-result__summary">
|
|
31
|
+
{otherChildren}
|
|
32
|
+
</div>));
|
|
33
|
+
};
|
|
34
|
+
const SearchResultContext = ({ children, title = 'Part of' }) => {
|
|
35
|
+
return (<dl className="ds_search-result__context">
|
|
36
|
+
<dt className="ds_search-result__context-key">{title}:</dt>
|
|
37
|
+
{children}
|
|
38
|
+
</dl>);
|
|
39
|
+
};
|
|
40
|
+
const SearchResultContextItem = ({ children }) => {
|
|
41
|
+
return (<dd className="ds_search-result__context-value">
|
|
42
|
+
{children}
|
|
43
|
+
</dd>);
|
|
44
|
+
};
|
|
45
|
+
const SearchResultMedia = ({ children }) => {
|
|
46
|
+
return (<div className="ds_search-result__media-wrapper">
|
|
47
|
+
<a className="ds_search-result__media-link" href={(0, react_1.useContext)(SearchResultLinkHrefContext)} tabIndex={-1} aria-hidden="true">
|
|
48
|
+
<AspectBox_1.default className="ds_search-result__media" ratio="1:1">
|
|
49
|
+
{children}
|
|
50
|
+
</AspectBox_1.default>
|
|
51
|
+
</a>
|
|
52
|
+
</div>);
|
|
53
|
+
};
|
|
54
|
+
const SearchResultMeta = ({ children }) => {
|
|
55
|
+
return (<PageMetadata_1.default className="ds_search-result__metadata" isInline>
|
|
56
|
+
{children}
|
|
57
|
+
</PageMetadata_1.default>);
|
|
58
|
+
};
|
|
59
|
+
const SearchResult = ({ children, href, isPromoted, linkComponent, promotedTitle = 'Recommended', title, ...props }) => {
|
|
60
|
+
const LINK_CLASS = 'ds_search-result__link';
|
|
61
|
+
return (<div className={[
|
|
62
|
+
'ds_search-result',
|
|
63
|
+
isPromoted ? 'ds_search-result--promoted' : ''
|
|
64
|
+
].join(' ')} {...props}>
|
|
65
|
+
<ConditionalWrapper_1.default condition={!!isPromoted} wrapper={(children) => <div className="ds_search-result--promoted-content">
|
|
66
|
+
<header className="ds_search-result--promoted-title">{promotedTitle}</header>
|
|
67
|
+
{children}
|
|
68
|
+
</div>}>
|
|
69
|
+
<SearchResultLinkHrefContext value={href}>
|
|
70
|
+
<h3 className="ds_search-result__title">
|
|
71
|
+
{linkComponent ?
|
|
72
|
+
linkComponent({ className: LINK_CLASS, children: title, href }) :
|
|
73
|
+
<a className={LINK_CLASS} href={href}>{title}</a>}
|
|
74
|
+
</h3>
|
|
75
|
+
|
|
76
|
+
{children}
|
|
77
|
+
</SearchResultLinkHrefContext>
|
|
78
|
+
</ConditionalWrapper_1.default>
|
|
79
|
+
</div>);
|
|
80
|
+
};
|
|
81
|
+
SearchResult.Content = SearchResultContent;
|
|
82
|
+
SearchResult.Context = SearchResultContext;
|
|
83
|
+
SearchResult.ContextItem = SearchResultContextItem;
|
|
84
|
+
SearchResult.Media = SearchResultMedia;
|
|
85
|
+
SearchResult.Meta = SearchResultMeta;
|
|
86
|
+
SearchResult.MetaItem = PageMetadata_1.default.Item;
|
|
87
|
+
SearchResultContent.displayName = 'SearchResult.Content';
|
|
88
|
+
SearchResultContext.displayName = 'SearchResult.Context';
|
|
89
|
+
SearchResultContextItem.displayName = 'SearchResult.ContextItem';
|
|
90
|
+
SearchResultMedia.displayName = 'SearchResult.Media';
|
|
91
|
+
SearchResultMeta.displayName = 'SearchResult.Meta';
|
|
92
|
+
SearchResult.MetaItem.displayName = 'SearchResult.MetaItem';
|
|
93
|
+
exports.default = SearchResult;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const Button_1 = __importDefault(require("../Button/Button"));
|
|
7
|
+
const Select_1 = __importDefault(require("../Select/Select"));
|
|
8
|
+
const Option = ({ children, value }) => {
|
|
9
|
+
return (<option value={value}>
|
|
10
|
+
{children}
|
|
11
|
+
</option>);
|
|
12
|
+
};
|
|
13
|
+
const SearchSort = ({ children, className, id = 'sort-by', label = 'Sort by', onApply, ...props }) => {
|
|
14
|
+
return (<div className={[
|
|
15
|
+
'ds_sort-options',
|
|
16
|
+
className
|
|
17
|
+
].join(' ')} {...props}>
|
|
18
|
+
<Select_1.default id={id} label={label}>
|
|
19
|
+
{children}
|
|
20
|
+
</Select_1.default>
|
|
21
|
+
|
|
22
|
+
<Button_1.default onClick={onApply} isSmall buttonStyle="secondary" type="submit">Apply sort</Button_1.default>
|
|
23
|
+
</div>);
|
|
24
|
+
};
|
|
25
|
+
SearchSort.displayName = 'SearchSort';
|
|
26
|
+
Option.displayName = 'SearchSort.Option';
|
|
27
|
+
SearchSort.Option = Option;
|
|
28
|
+
exports.default = SearchSort;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const SeqNavLink = ({ children, href, isPrev, linkComponent, textLabel }) => {
|
|
4
|
-
console.log(textLabel);
|
|
5
4
|
const LINK_CLASSES = [
|
|
6
5
|
'ds_sequential-nav__button',
|
|
7
6
|
isPrev ? 'ds_sequential-nav__button--left' : 'ds_sequential-nav__button--right'
|
|
@@ -25,14 +25,14 @@ const SideNavigationItem = function ({ children, href, isCurrent = false, linkCo
|
|
|
25
25
|
{children}
|
|
26
26
|
</li>);
|
|
27
27
|
};
|
|
28
|
-
const SideNavigation = function ({ children, className, ...props }) {
|
|
28
|
+
const SideNavigation = function ({ ariaLabel = 'Sections', children, className, ...props }) {
|
|
29
29
|
const ref = (0, react_1.useRef)(null);
|
|
30
30
|
(0, react_1.useEffect)(() => {
|
|
31
31
|
if (ref.current && children) {
|
|
32
32
|
new side_navigation_1.default(ref.current).init();
|
|
33
33
|
}
|
|
34
34
|
}, [ref]);
|
|
35
|
-
return (<nav aria-label=
|
|
35
|
+
return (<nav aria-label={ariaLabel} className={[
|
|
36
36
|
'ds_side-navigation',
|
|
37
37
|
className
|
|
38
38
|
].join(' ')} data-module="ds-side-navigation" ref={ref} {...props}>
|