@scottish-government/designsystem-react 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/dist/common/abstract-notification-banner.jsx +0 -63
- package/dist/common/conditional-wrapper.jsx +0 -8
- package/dist/common/file-icon.jsx +0 -51
- package/dist/common/hint-text.jsx +0 -9
- package/dist/common/icon.jsx +0 -57
- package/dist/common/screen-reader-text.jsx +0 -9
- package/dist/common/wrapper-tag.jsx +0 -11
- package/dist/components/accordion/accordion.jsx +0 -102
- package/dist/components/aspect-box/aspect-box.jsx +0 -79
- package/dist/components/back-to-top/back-to-top.jsx +0 -27
- package/dist/components/breadcrumbs/breadcrumbs.jsx +0 -28
- package/dist/components/button/button.jsx +0 -30
- package/dist/components/checkbox/checkbox.jsx +0 -62
- package/dist/components/confirmation-message/confirmation-message.jsx +0 -24
- package/dist/components/contents-nav/contents-nav.jsx +0 -33
- package/dist/components/cookie-banner/cookie-banner.jsx +0 -21
- package/dist/components/date-picker/date-picker.jsx +0 -54
- package/dist/components/details/details.jsx +0 -17
- package/dist/components/error-message/error-message.jsx +0 -12
- package/dist/components/error-summary/error-summary.jsx +0 -27
- package/dist/components/file-download/file-download.jsx +0 -50
- package/dist/components/hide-this-page/hide-this-page.jsx +0 -71
- package/dist/components/inset-text/inset-text.jsx +0 -14
- package/dist/components/notification-banner/notification-banner.jsx +0 -26
- package/dist/components/notification-panel/notification-panel.jsx +0 -21
- package/dist/components/page-header/page-header.jsx +0 -15
- package/dist/components/page-metadata/page-metadata.jsx +0 -26
- package/dist/components/pagination/pagination.jsx +0 -97
- package/dist/components/phase-banner/phase-banner.jsx +0 -23
- package/dist/components/question/question.jsx +0 -22
- package/dist/components/radio-button/radio-button.jsx +0 -43
- package/dist/components/select/select.jsx +0 -52
- package/dist/components/sequential-navigation/sequential-navigation.jsx +0 -31
- package/dist/components/side-navigation/side-navigation.jsx +0 -52
- package/dist/components/site-header/site-header.jsx +0 -68
- package/dist/components/site-navigation/site-navigation.jsx +0 -22
- package/dist/components/site-search/site-search.jsx +0 -55
- package/dist/components/skip-links/skip-links.jsx +0 -21
- package/dist/components/summary-card/summary-card.jsx +0 -67
- package/dist/components/summary-list/summary-list.jsx +0 -75
- package/dist/components/table/table.jsx +0 -24
- package/dist/components/tabs/tabs.jsx +0 -99
- package/dist/components/tag/tag.jsx +0 -13
- package/dist/components/task-list/task-list.jsx +0 -95
- package/dist/components/text-input/text-input.jsx +0 -58
- package/dist/components/textarea/textarea.jsx +0 -54
- package/dist/components/warning-text/warning-text.jsx +0 -16
- package/dist/icons/ArrowUpward.jsx +0 -41
- package/dist/icons/CalendarToday.jsx +0 -41
- package/dist/icons/Cancel.jsx +0 -40
- package/dist/icons/CheckCircle.jsx +0 -41
- package/dist/icons/ChevronLeft.jsx +0 -41
- package/dist/icons/ChevronRight.jsx +0 -41
- package/dist/icons/Close.jsx +0 -41
- package/dist/icons/Description.jsx +0 -41
- package/dist/icons/DoubleChevronLeft.jsx +0 -40
- package/dist/icons/DoubleChevronRight.jsx +0 -40
- package/dist/icons/Error.jsx +0 -41
- package/dist/icons/ExpandLess.jsx +0 -41
- package/dist/icons/ExpandMore.jsx +0 -41
- package/dist/icons/List.jsx +0 -44
- package/dist/icons/Menu.jsx +0 -41
- package/dist/icons/PriorityHigh.jsx +0 -42
- package/dist/icons/Search.jsx +0 -41
- package/dist/icons/index.js +0 -40
|
@@ -1,52 +0,0 @@
|
|
|
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.Link = exports.List = void 0;
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
// @ts-ignore
|
|
9
|
-
const side_navigation_1 = __importDefault(require("@scottish-government/design-system/src/components/side-navigation/side-navigation"));
|
|
10
|
-
const List = function ({ items, root }) {
|
|
11
|
-
return (<ul className="ds_side-navigation__list" id={root ? 'side-navigation-root' : undefined}>
|
|
12
|
-
{items && items.map((item, index) => (<exports.Link title={item.title} href={item.href} items={item.items} current={item.current} key={'sidenavitem' + index}/>))}
|
|
13
|
-
</ul>);
|
|
14
|
-
};
|
|
15
|
-
exports.List = List;
|
|
16
|
-
const Link = function ({ current = false, href, items, title }) {
|
|
17
|
-
return (<li className={[
|
|
18
|
-
'ds_side-navigation__item',
|
|
19
|
-
items && 'ds_side-navigation__item--has-children'
|
|
20
|
-
].join(' ')}>
|
|
21
|
-
{current ?
|
|
22
|
-
<span className="ds_side-navigation__link ds_current">{title}</span> :
|
|
23
|
-
<a href={href} className="ds_side-navigation__link">{title}</a>}
|
|
24
|
-
|
|
25
|
-
{items && <exports.List items={items}/>}
|
|
26
|
-
</li>);
|
|
27
|
-
};
|
|
28
|
-
exports.Link = Link;
|
|
29
|
-
const SideNavigation = function ({ children, className, items, ...props }) {
|
|
30
|
-
const ref = (0, react_1.useRef)(null);
|
|
31
|
-
(0, react_1.useEffect)(() => {
|
|
32
|
-
if (ref.current) {
|
|
33
|
-
new side_navigation_1.default(ref.current).init();
|
|
34
|
-
}
|
|
35
|
-
}, [ref]);
|
|
36
|
-
return (<nav aria-label="Sections" className={[
|
|
37
|
-
'ds_side-navigation',
|
|
38
|
-
className
|
|
39
|
-
].join(' ')} data-module="ds-side-navigation" ref={ref} {...props}>
|
|
40
|
-
<input type="checkbox" className="fully-hidden js-toggle-side-navigation" id="show-side-navigation" aria-controls="side-navigation-root"/>
|
|
41
|
-
<label className="ds_side-navigation__expand ds_link" htmlFor="show-side-navigation">
|
|
42
|
-
<span className="visually-hidden">Show all</span> Pages in this section
|
|
43
|
-
<span className="ds_side-navigation__expand-indicator"></span>
|
|
44
|
-
</label>
|
|
45
|
-
|
|
46
|
-
{items && <exports.List root items={items}/>}
|
|
47
|
-
</nav>);
|
|
48
|
-
};
|
|
49
|
-
SideNavigation.displayName = 'SideNavigation';
|
|
50
|
-
exports.Link.displayName = 'SideNavLink';
|
|
51
|
-
exports.List.displayName = 'SideNavList';
|
|
52
|
-
exports.default = SideNavigation;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const react_1 = require("react");
|
|
8
|
-
const icon_1 = __importDefault(require("../../common/icon"));
|
|
9
|
-
const phase_banner_1 = __importDefault(require("../phase-banner/phase-banner"));
|
|
10
|
-
const site_navigation_1 = __importDefault(require("../site-navigation/site-navigation"));
|
|
11
|
-
const site_search_1 = __importDefault(require("../site-search/site-search"));
|
|
12
|
-
// @ts-ignore
|
|
13
|
-
const site_navigation_2 = __importDefault(require("@scottish-government/design-system/src/components/site-navigation/site-navigation"));
|
|
14
|
-
const SiteHeader = ({ logo = {}, navigationItems, phaseBanner, siteSearch, siteTitle, ...props }) => {
|
|
15
|
-
const mobileMenuRef = (0, react_1.useRef)(null);
|
|
16
|
-
(0, react_1.useEffect)(() => {
|
|
17
|
-
if (mobileMenuRef.current) {
|
|
18
|
-
new site_navigation_2.default(mobileMenuRef.current).init();
|
|
19
|
-
}
|
|
20
|
-
}, [mobileMenuRef]);
|
|
21
|
-
return (<header className="ds_site-header" {...props}>
|
|
22
|
-
<div className="ds_wrapper">
|
|
23
|
-
<div className="ds_site-header__content">
|
|
24
|
-
<div className="ds_site-branding">
|
|
25
|
-
{logo &&
|
|
26
|
-
<a className="ds_site-branding__logo ds_site-branding__link" href={logo.href ? logo.href : '/'}>
|
|
27
|
-
<img className="ds_site-branding__logo-image" src={logo.src} alt={logo.alt}/>
|
|
28
|
-
</a>}
|
|
29
|
-
|
|
30
|
-
{siteTitle && <div className="ds_site-branding__title">
|
|
31
|
-
{siteTitle}
|
|
32
|
-
</div>}
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
{navigationItems &&
|
|
36
|
-
<div className="ds_site-header__controls">
|
|
37
|
-
<label aria-controls="mobile-navigation" className="ds_site-header__control js-toggle-menu" htmlFor="menu">
|
|
38
|
-
<span className="ds_site-header__control-text">Menu</span>
|
|
39
|
-
<icon_1.default fill className="ds_site-header__control-icon" icon="Menu" aria-hidden="true"/>
|
|
40
|
-
<icon_1.default fill className="ds_site-header__control-icon ds_site-header__control-icon--active-icon" icon="Close" aria-hidden="true"/>
|
|
41
|
-
</label>
|
|
42
|
-
</div>}
|
|
43
|
-
|
|
44
|
-
{navigationItems &&
|
|
45
|
-
<input className="ds_site-navigation__toggle" id="menu" type="checkbox"/>}
|
|
46
|
-
{navigationItems &&
|
|
47
|
-
<site_navigation_1.default id="mobile-navigation" className="ds_site-navigation--mobile" items={navigationItems} ref={mobileMenuRef}/>}
|
|
48
|
-
|
|
49
|
-
{siteSearch &&
|
|
50
|
-
<site_search_1.default className="ds_site-header__search" {...siteSearch}/>}
|
|
51
|
-
</div>
|
|
52
|
-
</div>
|
|
53
|
-
|
|
54
|
-
{phaseBanner &&
|
|
55
|
-
<phase_banner_1.default phaseName={phaseBanner.phaseName}>
|
|
56
|
-
{phaseBanner.content}
|
|
57
|
-
</phase_banner_1.default>}
|
|
58
|
-
|
|
59
|
-
{navigationItems &&
|
|
60
|
-
<div className="ds_site-header__navigation">
|
|
61
|
-
<div className="ds_wrapper">
|
|
62
|
-
<site_navigation_1.default items={navigationItems}/>
|
|
63
|
-
</div>
|
|
64
|
-
</div>}
|
|
65
|
-
</header>);
|
|
66
|
-
};
|
|
67
|
-
SiteHeader.displayName = 'SiteHeader';
|
|
68
|
-
exports.default = SiteHeader;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const SiteNavLink = ({ current = false, href, title }) => {
|
|
4
|
-
return (<li className="ds_site-navigation__item">
|
|
5
|
-
<a href={href} className={[
|
|
6
|
-
'ds_site-navigation__link',
|
|
7
|
-
current ? 'ds_current' : undefined
|
|
8
|
-
].join(' ')}>{title}</a>
|
|
9
|
-
</li>);
|
|
10
|
-
};
|
|
11
|
-
const SiteNavigation = ({ className, items, ...props }) => {
|
|
12
|
-
return (<nav className={[
|
|
13
|
-
'ds_site-navigation',
|
|
14
|
-
className
|
|
15
|
-
].join(' ')} {...props}>
|
|
16
|
-
<ul className="ds_site-navigation__list">
|
|
17
|
-
{items && items.map((item, index) => (<SiteNavLink current={item.current} href={item.href} title={item.title} key={`link-${index}`}/>))}
|
|
18
|
-
</ul>
|
|
19
|
-
</nav>);
|
|
20
|
-
};
|
|
21
|
-
SiteNavigation.displayName = 'SiteNavigation';
|
|
22
|
-
exports.default = SiteNavigation;
|
|
@@ -1,55 +0,0 @@
|
|
|
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
|
-
// @ts-ignore
|
|
8
|
-
const autocomplete_1 = __importDefault(require("@scottish-government/design-system/src/components/autocomplete/autocomplete"));
|
|
9
|
-
const button_1 = __importDefault(require("../button/button"));
|
|
10
|
-
const SiteSearch = function ({ action = '/search', autocompleteEndpoint, autocompleteSuggestionMappingFunction, className, id = 'site-search', method = 'GET', minLength = 3, name = 'q', placeholder = 'Search', ...props }) {
|
|
11
|
-
const ref = (0, react_1.useRef)(null);
|
|
12
|
-
const hasAutocomplete = !!autocompleteEndpoint;
|
|
13
|
-
let autocompleteId = hasAutocomplete ? id + '-autocomplete' : '';
|
|
14
|
-
(0, react_1.useEffect)(() => {
|
|
15
|
-
if (hasAutocomplete && ref.current) {
|
|
16
|
-
const options = {};
|
|
17
|
-
if (minLength) {
|
|
18
|
-
options.minLength = minLength;
|
|
19
|
-
}
|
|
20
|
-
if (autocompleteSuggestionMappingFunction) {
|
|
21
|
-
options.suggestionMappingFunction = autocompleteSuggestionMappingFunction;
|
|
22
|
-
}
|
|
23
|
-
const autocomplete = new autocomplete_1.default(document.getElementById(autocompleteId), autocompleteEndpoint, options);
|
|
24
|
-
autocomplete.init();
|
|
25
|
-
}
|
|
26
|
-
}, [ref, autocompleteEndpoint, autocompleteId, hasAutocomplete, minLength, autocompleteSuggestionMappingFunction]);
|
|
27
|
-
return (<div className={[
|
|
28
|
-
'ds_site-search', ,
|
|
29
|
-
className,
|
|
30
|
-
hasAutocomplete ? 'ds_autocomplete' : undefined
|
|
31
|
-
].join(' ')} id={autocompleteId ? autocompleteId : undefined} ref={ref} {...props}>
|
|
32
|
-
|
|
33
|
-
<form role="search" className="ds_site-search__form" method={method} action={action}>
|
|
34
|
-
<label className="ds_label visually-hidden" htmlFor={id} id={id + '-label'}>Search</label>
|
|
35
|
-
|
|
36
|
-
{hasAutocomplete && (<div role="status" aria-live="polite" id="autocomplete-status" className="visually-hidden"></div>)}
|
|
37
|
-
|
|
38
|
-
<div className="ds_input__wrapper ds_input__wrapper--has-icon">
|
|
39
|
-
<input aria-autocomplete={hasAutocomplete ? 'list' : undefined} aria-owns={hasAutocomplete ? 'autocomplete-suggestions' : undefined} autoComplete={hasAutocomplete ? 'off' : undefined} className={[
|
|
40
|
-
'ds_input',
|
|
41
|
-
'ds_site-search__input',
|
|
42
|
-
hasAutocomplete ? 'js-autocomplete-input' : undefined
|
|
43
|
-
].join(' ')} id={id} name={name} placeholder={placeholder} required spellCheck="false" type="search"/>
|
|
44
|
-
|
|
45
|
-
<button_1.default type="submit" icon="Search" iconOnly>Search</button_1.default>
|
|
46
|
-
|
|
47
|
-
{hasAutocomplete && (<div id="autocomplete-suggestions" className="ds_autocomplete__suggestions">
|
|
48
|
-
<ol className="ds_autocomplete__suggestions-list" role="listbox" aria-labelledby="site-search-label"></ol>
|
|
49
|
-
</div>)}
|
|
50
|
-
</div>
|
|
51
|
-
</form>
|
|
52
|
-
</div>);
|
|
53
|
-
};
|
|
54
|
-
SiteSearch.displayName = 'SiteSearch';
|
|
55
|
-
exports.default = SiteSearch;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SkipLink = void 0;
|
|
4
|
-
const SkipLink = ({ targetId, title }) => {
|
|
5
|
-
return (<li className="ds_skip-links__item">
|
|
6
|
-
<a href={`#${targetId}`} className="ds_skip-links__link">{title}</a>
|
|
7
|
-
</li>);
|
|
8
|
-
};
|
|
9
|
-
exports.SkipLink = SkipLink;
|
|
10
|
-
const SkipLinks = ({ items, mainContentId = 'main-content', mainLinkText = 'Skip to main content', ...props }) => {
|
|
11
|
-
return (<div className="ds_skip-links" {...props}>
|
|
12
|
-
<ul className="ds_skip-links__list">
|
|
13
|
-
<exports.SkipLink title={mainLinkText} targetId={mainContentId}/>
|
|
14
|
-
|
|
15
|
-
{items && items.map((item, index) => (<exports.SkipLink title={item.title} targetId={item.targetId} key={`skiplink-${index}`}/>))}
|
|
16
|
-
</ul>
|
|
17
|
-
</div>);
|
|
18
|
-
};
|
|
19
|
-
SkipLinks.displayName = 'SkipLinks';
|
|
20
|
-
exports.SkipLink.displayName = 'SkipLink';
|
|
21
|
-
exports.default = SkipLinks;
|
|
@@ -1,67 +0,0 @@
|
|
|
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 summary_list_1 = __importStar(require("../summary-list/summary-list"));
|
|
40
|
-
const wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
|
|
41
|
-
function convertToSlug(string) {
|
|
42
|
-
return string.toLowerCase()
|
|
43
|
-
.replace(/[^\w ]+/g, "")
|
|
44
|
-
.replace(/ +/g, "-");
|
|
45
|
-
}
|
|
46
|
-
const SummaryCard = ({ actions, className, headerLevel = 'h3', items, title, ...props }) => {
|
|
47
|
-
const describedById = `summary-card-${convertToSlug(title)}`;
|
|
48
|
-
return (<div className={[
|
|
49
|
-
'ds_summary-card',
|
|
50
|
-
className
|
|
51
|
-
].join(' ')} {...props}>
|
|
52
|
-
<div className="ds_summary-card__header">
|
|
53
|
-
<wrapper_tag_1.default className="ds_summary-card__header-title" id={describedById} tagName={headerLevel}>{title}</wrapper_tag_1.default>
|
|
54
|
-
|
|
55
|
-
<ul className="ds_summary-card__actions-list">
|
|
56
|
-
{actions && actions.map((action, index) => (<li className="ds_summary-card__actions-list-item" key={'summarylistaction' + index}>
|
|
57
|
-
<summary_list_1.Action describedby={describedById} href={action.href} onclick={action.onclick} title={action.title}/>
|
|
58
|
-
</li>))}
|
|
59
|
-
</ul>
|
|
60
|
-
</div>
|
|
61
|
-
<div className="ds_summary-card__content">
|
|
62
|
-
<summary_list_1.default items={items}/>
|
|
63
|
-
</div>
|
|
64
|
-
</div>);
|
|
65
|
-
};
|
|
66
|
-
SummaryCard.displayName = 'SummaryCard';
|
|
67
|
-
exports.default = SummaryCard;
|
|
@@ -1,75 +0,0 @@
|
|
|
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.Item = exports.Action = exports.Answer = void 0;
|
|
7
|
-
const conditional_wrapper_1 = __importDefault(require("../../common/conditional-wrapper"));
|
|
8
|
-
const wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
|
|
9
|
-
function escapedNewLineToLineBreakTag(string) {
|
|
10
|
-
if (typeof string === 'string') {
|
|
11
|
-
// @ts-ignore
|
|
12
|
-
return string.split('\n').map((item, index) => {
|
|
13
|
-
return (index === 0) ? item : [<br key={index}/>, item];
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function convertToSlug(string) {
|
|
18
|
-
return string.toLowerCase()
|
|
19
|
-
.replace(/[^\w ]+/g, "")
|
|
20
|
-
.replace(/ +/g, "-");
|
|
21
|
-
}
|
|
22
|
-
const Answer = ({ value }) => {
|
|
23
|
-
const processedValue = escapedNewLineToLineBreakTag(value.toString());
|
|
24
|
-
return (<q className="ds_summary-list__answer">{processedValue}</q>);
|
|
25
|
-
};
|
|
26
|
-
exports.Answer = Answer;
|
|
27
|
-
const Action = ({ describedby, href, onclick, title, }) => {
|
|
28
|
-
let tagName = 'button';
|
|
29
|
-
if (href) {
|
|
30
|
-
tagName = 'a';
|
|
31
|
-
}
|
|
32
|
-
return (<wrapper_tag_1.default aria-describedby={describedby} className="ds_link" href={href} onClick={onclick} tagName={tagName} type={tagName === 'button' ? 'button' : undefined}>
|
|
33
|
-
{title}
|
|
34
|
-
</wrapper_tag_1.default>);
|
|
35
|
-
};
|
|
36
|
-
exports.Action = Action;
|
|
37
|
-
const Item = ({ actions, index = 1, title, value }) => {
|
|
38
|
-
let values = [];
|
|
39
|
-
if (Array.isArray(value)) {
|
|
40
|
-
values = value;
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
values = [value || ''];
|
|
44
|
-
}
|
|
45
|
-
const describedById = `q${index + 1}-${convertToSlug(title)}`;
|
|
46
|
-
return (<li className="ds_summary-list__item">
|
|
47
|
-
<span className="ds_summary-list__key" id={describedById}>{title}</span>
|
|
48
|
-
<span className="ds_summary-list__value">
|
|
49
|
-
<conditional_wrapper_1.default condition={values.length > 1} wrapper={(children) => <ul className="ds_no-bullets">{children}</ul>}>
|
|
50
|
-
{values && values.map((value, index) => (<conditional_wrapper_1.default condition={values.length > 1} wrapper={(children) => <li>{children}</li>} key={'answer' + index}>
|
|
51
|
-
<exports.Answer value={value}/>
|
|
52
|
-
</conditional_wrapper_1.default>))}
|
|
53
|
-
</conditional_wrapper_1.default>
|
|
54
|
-
</span>
|
|
55
|
-
{actions &&
|
|
56
|
-
<div className="ds_summary-list__actions">
|
|
57
|
-
{actions && actions.map((action, index) => (<exports.Action describedby={describedById} href={action.href} onclick={action.onclick} title={action.title} key={'summarylistaction' + index}/>))}
|
|
58
|
-
</div>}
|
|
59
|
-
</li>);
|
|
60
|
-
};
|
|
61
|
-
exports.Item = Item;
|
|
62
|
-
const SummaryList = ({ className, items, noBorder, ...props }) => {
|
|
63
|
-
return (<ol className={[
|
|
64
|
-
'ds_summary-list',
|
|
65
|
-
noBorder && 'ds_summary-list--no-border',
|
|
66
|
-
className
|
|
67
|
-
].join(' ')} {...props}>
|
|
68
|
-
{items && items.map((item, index) => (<exports.Item actions={item.actions} title={item.title} value={item.value} index={index} key={'summarylistitem' + index}/>))}
|
|
69
|
-
</ol>);
|
|
70
|
-
};
|
|
71
|
-
SummaryList.displayName = 'SummaryList';
|
|
72
|
-
exports.Action.displayName = 'SummaryListAction';
|
|
73
|
-
exports.Answer.displayName = 'SumaryListAnswer';
|
|
74
|
-
exports.Item.displayName = 'SummaryListItem';
|
|
75
|
-
exports.default = SummaryList;
|
|
@@ -1,24 +0,0 @@
|
|
|
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
|
-
// @ts-ignore
|
|
8
|
-
const table_1 = __importDefault(require("@scottish-government/design-system/src/components/table/table"));
|
|
9
|
-
const Table = ({ children, className, smallscreen, ...props }) => {
|
|
10
|
-
const ref = (0, react_1.useRef)(null);
|
|
11
|
-
(0, react_1.useEffect)(() => {
|
|
12
|
-
if (ref.current) {
|
|
13
|
-
new table_1.default().init();
|
|
14
|
-
}
|
|
15
|
-
}, [ref]);
|
|
16
|
-
return (<table className={[
|
|
17
|
-
'ds_table',
|
|
18
|
-
className
|
|
19
|
-
].join(' ')} data-smallscreen={smallscreen} ref={ref} {...props}>
|
|
20
|
-
{children}
|
|
21
|
-
</table>);
|
|
22
|
-
};
|
|
23
|
-
Table.displayName = 'Table';
|
|
24
|
-
exports.default = Table;
|
|
@@ -1,99 +0,0 @@
|
|
|
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 wrapper_tag_1 = __importDefault(require("../../common/wrapper-tag"));
|
|
41
|
-
// @ts-ignore
|
|
42
|
-
const tabs_1 = __importDefault(require("@scottish-government/design-system/src/components/tabs/tabs"));
|
|
43
|
-
const slugify_1 = __importDefault(require("../../utils/slugify"));
|
|
44
|
-
const TabItem = ({ bordered, children, className, id, tabLabel, ...props }) => {
|
|
45
|
-
return (<div className={[
|
|
46
|
-
'ds_tabs__content',
|
|
47
|
-
bordered && 'ds_tabs__content--bordered',
|
|
48
|
-
className
|
|
49
|
-
].join(' ')} id={id} {...props}>
|
|
50
|
-
{children}
|
|
51
|
-
</div>);
|
|
52
|
-
};
|
|
53
|
-
const TabListItem = ({ title, href }) => {
|
|
54
|
-
return (<li className="ds_tabs__tab">
|
|
55
|
-
<a className="ds_tabs__tab-link" href={href}>{title}</a>
|
|
56
|
-
</li>);
|
|
57
|
-
};
|
|
58
|
-
const Tabs = ({ baseId = 'tabs', bordered = true, children, className, headerLevel = 'h2', manual = false, title = 'Contents', ...props }) => {
|
|
59
|
-
const ref = (0, react_1.useRef)(null);
|
|
60
|
-
const headingId = `${baseId}-heading`;
|
|
61
|
-
(0, react_1.useEffect)(() => {
|
|
62
|
-
if (ref.current) {
|
|
63
|
-
new tabs_1.default(ref.current).init();
|
|
64
|
-
}
|
|
65
|
-
}, [ref]);
|
|
66
|
-
const processedItems = react_1.Children.map(children, child => {
|
|
67
|
-
if ((0, react_1.isValidElement)(child) && child.type === TabItem) {
|
|
68
|
-
let thisChild = child;
|
|
69
|
-
return react_1.default.cloneElement(thisChild, {
|
|
70
|
-
bordered: bordered,
|
|
71
|
-
id: thisChild.props.id || `${baseId}-${(0, slugify_1.default)(thisChild.props.tabLabel)}`,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
const tabListItems = react_1.Children.map(processedItems, child => {
|
|
76
|
-
if ((0, react_1.isValidElement)(child) && child.type === TabItem) {
|
|
77
|
-
return react_1.default.createElement(TabListItem, { title: child.props.tabLabel, href: `#${child.props.id}` });
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
return (<div className={[
|
|
81
|
-
'ds_tabs',
|
|
82
|
-
manual && 'ds_tabs--manual',
|
|
83
|
-
className
|
|
84
|
-
].join(' ')} ref={ref} {...props}>
|
|
85
|
-
<wrapper_tag_1.default id={headingId} className="ds_tabs__title" tagName={headerLevel}>
|
|
86
|
-
{title}
|
|
87
|
-
</wrapper_tag_1.default>
|
|
88
|
-
|
|
89
|
-
<ul className="ds_tabs__list" aria-labelledby={headingId}>
|
|
90
|
-
{tabListItems}
|
|
91
|
-
</ul>
|
|
92
|
-
|
|
93
|
-
{processedItems}
|
|
94
|
-
</div>);
|
|
95
|
-
};
|
|
96
|
-
Tabs.displayName = 'Tabs';
|
|
97
|
-
TabItem.displayName = 'Tabs.Item';
|
|
98
|
-
Tabs.Item = TabItem;
|
|
99
|
-
exports.default = Tabs;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const Tag = ({ className, colour, title, ...props }) => {
|
|
4
|
-
return (<span className={[
|
|
5
|
-
'ds_tag',
|
|
6
|
-
className,
|
|
7
|
-
colour && `ds_tag--${colour}`,
|
|
8
|
-
].join(' ')} {...props}>
|
|
9
|
-
{title}
|
|
10
|
-
</span>);
|
|
11
|
-
};
|
|
12
|
-
Tag.displayName = 'Tag';
|
|
13
|
-
exports.default = Tag;
|
|
@@ -1,95 +0,0 @@
|
|
|
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 conditional_wrapper_1 = __importDefault(require("../../common/conditional-wrapper"));
|
|
8
|
-
const hint_text_1 = __importDefault(require("../../common/hint-text"));
|
|
9
|
-
const screen_reader_text_1 = __importDefault(require("../../common/screen-reader-text"));
|
|
10
|
-
const tag_1 = __importDefault(require("../tag/tag"));
|
|
11
|
-
const TaskItem = ({ children, className, href, id, isComplete = false, statusText, tagColour = 'grey', title, ...props }) => {
|
|
12
|
-
if (isComplete) {
|
|
13
|
-
tagColour = 'green';
|
|
14
|
-
}
|
|
15
|
-
return (<li className={[
|
|
16
|
-
'ds_task-list__task',
|
|
17
|
-
className
|
|
18
|
-
].join(' ')} id={id} {...props}>
|
|
19
|
-
<div className="ds_task-list__task-details">
|
|
20
|
-
<h3 className="ds_task-list__task-heading">
|
|
21
|
-
<conditional_wrapper_1.default condition={typeof href !== 'undefined'} wrapper={(children) => <a className="ds_task-list__task-link" href={href}>{children}</a>}>
|
|
22
|
-
{title}
|
|
23
|
-
{statusText && <screen_reader_text_1.default>({statusText})</screen_reader_text_1.default>}
|
|
24
|
-
</conditional_wrapper_1.default>
|
|
25
|
-
</h3>
|
|
26
|
-
<hint_text_1.default className="ds_task-list__task-summary">{children}</hint_text_1.default>
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
{typeof statusText !== 'undefined' &&
|
|
30
|
-
<tag_1.default aria-hidden="true" colour={tagColour} title={statusText}/>}
|
|
31
|
-
</li>);
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* @param {Object} props
|
|
35
|
-
* @param {string} props.intro - Intro text
|
|
36
|
-
* @param {string} props.title - The title of the task group
|
|
37
|
-
* @returns {JSX.Element} - The element
|
|
38
|
-
*/
|
|
39
|
-
const TaskGroup = ({ children, className, intro, title, ...props }) => {
|
|
40
|
-
return (<li className={[
|
|
41
|
-
'ds_task-list-group__section',
|
|
42
|
-
className
|
|
43
|
-
].join(' ')} {...props}>
|
|
44
|
-
<h2 className="ds_task-list-heading">{title}</h2>
|
|
45
|
-
{intro && <p className="ds_task-list-intro">{intro}</p>}
|
|
46
|
-
<ul className="ds_task-list">
|
|
47
|
-
{children}
|
|
48
|
-
</ul>
|
|
49
|
-
</li>);
|
|
50
|
-
};
|
|
51
|
-
const TaskList = ({ children, className, headingId = 'task-list', title, ...props }) => {
|
|
52
|
-
let taskCount = 0;
|
|
53
|
-
let incompleteTaskIds = [];
|
|
54
|
-
let completedTasksCount = 0;
|
|
55
|
-
function processChild(item) {
|
|
56
|
-
if (item.type.displayName === 'TaskList.Item') {
|
|
57
|
-
taskCount = taskCount + 1;
|
|
58
|
-
if (item.props.isComplete) {
|
|
59
|
-
completedTasksCount = completedTasksCount + 1;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
incompleteTaskIds.push(item.props.id);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
else if (item.type.displayName === 'TaskList.Group') {
|
|
66
|
-
react_1.Children.forEach(item.props.children, child => {
|
|
67
|
-
processChild(child);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function firstIncompleteTaskLink() {
|
|
72
|
-
if (incompleteTaskIds.length > 0) {
|
|
73
|
-
return (<p><a href={'#' + incompleteTaskIds[0]} className="js-task-list-skip-link">Skip to first incomplete section</a></p>);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
react_1.Children.forEach(children, child => {
|
|
77
|
-
processChild(child);
|
|
78
|
-
});
|
|
79
|
-
return (<div className={className} {...props}>
|
|
80
|
-
<h2 id={`${headingId}-status`} className="ds_task-list-status-heading">{title}</h2>
|
|
81
|
-
<nav aria-labelledby={`${headingId}-status`} className="ds_task-list-status">
|
|
82
|
-
<p>You have completed {completedTasksCount} of {taskCount} sections.</p>
|
|
83
|
-
{firstIncompleteTaskLink()}
|
|
84
|
-
</nav>
|
|
85
|
-
<ul className="ds_task-list">
|
|
86
|
-
{children}
|
|
87
|
-
</ul>
|
|
88
|
-
</div>);
|
|
89
|
-
};
|
|
90
|
-
TaskList.displayName = 'TaskList';
|
|
91
|
-
TaskItem.displayName = 'TaskList.Item';
|
|
92
|
-
TaskGroup.displayName = 'TaskList.Group';
|
|
93
|
-
TaskList.Item = TaskItem;
|
|
94
|
-
TaskList.Group = TaskGroup;
|
|
95
|
-
exports.default = TaskList;
|
|
@@ -1,58 +0,0 @@
|
|
|
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
|
-
// @ts-ignore
|
|
8
|
-
const character_count_1 = __importDefault(require("@scottish-government/design-system/src/forms/character-count/character-count"));
|
|
9
|
-
const button_1 = __importDefault(require("../button/button"));
|
|
10
|
-
const conditional_wrapper_1 = __importDefault(require("../../common/conditional-wrapper"));
|
|
11
|
-
const error_message_1 = __importDefault(require("../error-message/error-message"));
|
|
12
|
-
const hint_text_1 = __importDefault(require("../../common/hint-text"));
|
|
13
|
-
const TextInput = ({ buttonIcon, buttonText, children, className, countThreshold, width, currency, currencySymbol, error, errorMessage, hasButton = false, hintText, id, label, maxlength, name, onBlur, onChange, placeholder, type = 'text', value, ...props }) => {
|
|
14
|
-
const errorMessageId = `error-message-${id}`;
|
|
15
|
-
const hintTextId = `hint-text-${id}`;
|
|
16
|
-
const ref = (0, react_1.useRef)(null);
|
|
17
|
-
const inputWrapperClasses = `${hasButton ? 'ds_input__wrapper ds_input__wrapper--has-icon' : ''} ${currency ? 'ds_currency-wrapper' : ''}`;
|
|
18
|
-
const describedbys = [];
|
|
19
|
-
if (hintText) {
|
|
20
|
-
describedbys.push(hintTextId);
|
|
21
|
-
}
|
|
22
|
-
;
|
|
23
|
-
if (errorMessage) {
|
|
24
|
-
describedbys.push(errorMessageId);
|
|
25
|
-
}
|
|
26
|
-
;
|
|
27
|
-
(0, react_1.useEffect)(() => {
|
|
28
|
-
if (ref.current) {
|
|
29
|
-
new character_count_1.default(ref.current).init();
|
|
30
|
-
}
|
|
31
|
-
}, [ref]);
|
|
32
|
-
function handleBlur(event) {
|
|
33
|
-
if (typeof onBlur === 'function') {
|
|
34
|
-
onBlur(event);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function handleChange(event) {
|
|
38
|
-
if (typeof onChange === 'function') {
|
|
39
|
-
onChange(event);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return (<conditional_wrapper_1.default condition={typeof maxlength !== 'undefined' && maxlength > 0} wrapper={(children) => <div ref={ref} data-threshold={countThreshold} data-module="ds-character-count">{children}</div>}>
|
|
43
|
-
<label className="ds_label" htmlFor={id}>{label}</label>
|
|
44
|
-
{hintText && <hint_text_1.default id={hintTextId} text={hintText}/>}
|
|
45
|
-
{errorMessage && <error_message_1.default id={errorMessageId} text={errorMessage}/>}
|
|
46
|
-
<conditional_wrapper_1.default condition={hasButton || typeof currency !== 'undefined' && currency} wrapper={(children) => <div className={inputWrapperClasses} data-symbol={currencySymbol}>{children}</div>}>
|
|
47
|
-
<input aria-describedby={describedbys.join(' ')} aria-invalid={error} className={[
|
|
48
|
-
'ds_input',
|
|
49
|
-
className,
|
|
50
|
-
error ? 'ds_input--error' : '',
|
|
51
|
-
width ? `ds_input--${width}` : '',
|
|
52
|
-
].join(' ')} defaultValue={value} id={id} maxLength={maxlength} name={name || id} onBlur={handleBlur} onChange={handleChange} placeholder={placeholder} type={type} {...props}/>
|
|
53
|
-
{hasButton && (buttonText || buttonIcon) && <button_1.default iconOnly icon={buttonIcon}>{buttonText}</button_1.default>}
|
|
54
|
-
</conditional_wrapper_1.default>
|
|
55
|
-
</conditional_wrapper_1.default>);
|
|
56
|
-
};
|
|
57
|
-
TextInput.displayName = 'TextInput';
|
|
58
|
-
exports.default = TextInput;
|