@onsvisual/svelte-components 1.0.30 → 1.0.32
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/dist/decorators/Icon/Icon.svelte +9 -1
- package/dist/decorators/Icon/Icon.svelte.d.ts +2 -2
- package/dist/inputs/Button/Button.stories.svelte +0 -1
- package/dist/inputs/Button/Button.svelte +1 -1
- package/dist/inputs/Button/Button.svelte.d.ts +2 -2
- package/dist/inputs/Select/Select.svelte +51 -32
- package/dist/inputs/Select/Select.svelte.d.ts +4 -3
- package/dist/layout/AnalyticsBanner/docs/component.md +27 -0
- package/dist/layout/NavSections/NavSections.stories.svelte +5 -2
- package/dist/layout/NavSections/docs/component.md +2 -4
- package/dist/layout/Scroller/Scroller.stories.svelte +4 -5
- package/dist/layout/Scroller/docs/component.md +1 -3
- package/dist/templates/FeatureArticle/FeatureArticle.stories.svelte +4 -5
- package/dist/wrappers/Observe/Observe.svelte +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
/**
|
|
3
3
|
* Set the type of icon
|
|
4
|
-
* @type {"arrow"|"carret"|"cross"|"external"|"signout"|"print"|"download"|"tick"|"search"}
|
|
4
|
+
* @type {"arrow"|"carret"|"cross"|"external"|"signout"|"print"|"download"|"tick"|"search"|"pin"|"cog"}
|
|
5
5
|
*/
|
|
6
6
|
export let type = "arrow";
|
|
7
7
|
/**
|
|
@@ -65,6 +65,14 @@
|
|
|
65
65
|
search: {
|
|
66
66
|
d: "M11.86 10.23 8.62 6.99a4.63 4.63 0 1 0-6.34 1.64 4.55 4.55 0 0 0 2.36.64 4.65 4.65 0 0 0 2.33-.65l3.24 3.23a.46.46 0 0 0 .65 0l1-1a.48.48 0 0 0 0-.62Zm-5-3.32a3.28 3.28 0 0 1-2.31.93 3.22 3.22 0 1 1 2.35-.93Z",
|
|
67
67
|
viewBox: "0 0 12 12"
|
|
68
|
+
},
|
|
69
|
+
pin: {
|
|
70
|
+
d: "M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7m0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5Z",
|
|
71
|
+
viewBox: "0 0 24 24"
|
|
72
|
+
},
|
|
73
|
+
cog: {
|
|
74
|
+
d: "M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.05.3-.09.63-.09.94s.02.64.07.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6Z",
|
|
75
|
+
viewBox: "0 0 24 24"
|
|
68
76
|
}
|
|
69
77
|
};
|
|
70
78
|
</script>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/** @typedef {typeof __propDef.events} IconEvents */
|
|
3
3
|
/** @typedef {typeof __propDef.slots} IconSlots */
|
|
4
4
|
export default class Icon extends SvelteComponentTyped<{
|
|
5
|
-
type?: "search" | "arrow" | "carret" | "cross" | "external" | "signout" | "print" | "download" | "tick" | undefined;
|
|
5
|
+
type?: "search" | "arrow" | "carret" | "cross" | "external" | "signout" | "print" | "download" | "tick" | "pin" | "cog" | undefined;
|
|
6
6
|
size?: "s" | "m" | "l" | "xl" | "2xl" | "3xl" | null | undefined;
|
|
7
7
|
rotation?: number | undefined;
|
|
8
8
|
marginLeft?: boolean | undefined;
|
|
@@ -17,7 +17,7 @@ export type IconSlots = typeof __propDef.slots;
|
|
|
17
17
|
import { SvelteComponentTyped } from "svelte";
|
|
18
18
|
declare const __propDef: {
|
|
19
19
|
props: {
|
|
20
|
-
type?: "search" | "arrow" | "carret" | "cross" | "external" | "signout" | "print" | "download" | "tick" | undefined;
|
|
20
|
+
type?: "search" | "arrow" | "carret" | "cross" | "external" | "signout" | "print" | "download" | "tick" | "pin" | "cog" | undefined;
|
|
21
21
|
size?: "s" | "m" | "l" | "xl" | "2xl" | "3xl" | null | undefined;
|
|
22
22
|
rotation?: number | undefined;
|
|
23
23
|
marginLeft?: boolean | undefined;
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
export let small = false;
|
|
38
38
|
/**
|
|
39
39
|
* Icon on button, eg. "arrow", "search"
|
|
40
|
-
* @type {"arrow"|"external"|"signout"|"print"|"download"|"tick"|"search"|null}
|
|
40
|
+
* @type {"arrow"|"carret"|"cross"|"external"|"signout"|"print"|"download"|"tick"|"search"|"pin"|"cog"|null}
|
|
41
41
|
*/
|
|
42
42
|
export let icon = null;
|
|
43
43
|
/**
|
|
@@ -10,7 +10,7 @@ export default class Button extends SvelteComponentTyped<{
|
|
|
10
10
|
type?: "button" | "reset" | "sumbit" | undefined;
|
|
11
11
|
variant?: "secondary" | "primary" | "ghost" | undefined;
|
|
12
12
|
noScroll?: boolean | undefined;
|
|
13
|
-
icon?: "search" | "arrow" | "external" | "signout" | "print" | "download" | "tick" | null | undefined;
|
|
13
|
+
icon?: "search" | "arrow" | "carret" | "cross" | "external" | "signout" | "print" | "download" | "tick" | "pin" | "cog" | null | undefined;
|
|
14
14
|
iconPosition?: "before" | "after" | undefined;
|
|
15
15
|
disabled?: boolean | undefined;
|
|
16
16
|
hideLabel?: boolean | undefined;
|
|
@@ -38,7 +38,7 @@ declare const __propDef: {
|
|
|
38
38
|
type?: "button" | "reset" | "sumbit" | undefined;
|
|
39
39
|
variant?: "secondary" | "primary" | "ghost" | undefined;
|
|
40
40
|
noScroll?: boolean | undefined;
|
|
41
|
-
icon?: "search" | "arrow" | "external" | "signout" | "print" | "download" | "tick" | null | undefined;
|
|
41
|
+
icon?: "search" | "arrow" | "carret" | "cross" | "external" | "signout" | "print" | "download" | "tick" | "pin" | "cog" | null | undefined;
|
|
42
42
|
iconPosition?: "before" | "after" | undefined;
|
|
43
43
|
disabled?: boolean | undefined;
|
|
44
44
|
hideLabel?: boolean | undefined;
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
// @ts-nocheck
|
|
3
3
|
|
|
4
4
|
import { onMount, createEventDispatcher } from "svelte";
|
|
5
|
+
import Dropdown from "../Dropdown/Dropdown.svelte";
|
|
6
|
+
import Input from "../Input/Input.svelte";
|
|
5
7
|
|
|
6
8
|
const dispatch = createEventDispatcher();
|
|
7
9
|
const sleep = (ms = 1000) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -68,6 +70,11 @@
|
|
|
68
70
|
* @type {string|null}
|
|
69
71
|
*/
|
|
70
72
|
export let groupKey = null;
|
|
73
|
+
/**
|
|
74
|
+
* When using SSR or pre-rendering, this option will render a text input or dropdown before the page is hydrated (allows for progressive enhancement).
|
|
75
|
+
* @type {boolean}
|
|
76
|
+
*/
|
|
77
|
+
export let renderFallback = false;
|
|
71
78
|
/**
|
|
72
79
|
* Optional: Minimum query length to return results
|
|
73
80
|
* @type {number}
|
|
@@ -92,23 +99,22 @@
|
|
|
92
99
|
*/
|
|
93
100
|
export let scriptUrl =
|
|
94
101
|
"https://cdn.ons.gov.uk/vendor/accessible-autocomplete/3.0.1/accessible-autocomplete.min.js";
|
|
95
|
-
|
|
96
|
-
// This clearing method is a bit of a hack, but no better options available at present
|
|
97
|
-
// https://github.com/alphagov/accessible-autocomplete/issues/390
|
|
98
102
|
/**
|
|
99
103
|
* Call this function externally to clear the input
|
|
100
104
|
* @type {function}
|
|
101
105
|
*/
|
|
102
|
-
export async
|
|
106
|
+
export let clearInput = async () => {
|
|
103
107
|
await setInputValue(null);
|
|
104
108
|
dispatch("clear", null);
|
|
105
|
-
}
|
|
109
|
+
};
|
|
106
110
|
/**
|
|
107
111
|
* Optional: Set an additional CSS class for the component
|
|
108
112
|
* @type {string|null}
|
|
109
113
|
*/
|
|
110
114
|
export let cls = null;
|
|
111
115
|
|
|
116
|
+
// This method is a bit of a hack, but no better options available at present
|
|
117
|
+
// https://github.com/alphagov/accessible-autocomplete/issues/390
|
|
112
118
|
async function setInputValue(textValue) {
|
|
113
119
|
hideMenu = true;
|
|
114
120
|
inputElement.value = textValue || "";
|
|
@@ -204,35 +210,48 @@
|
|
|
204
210
|
<script src={scriptUrl} on:load={handleScriptLoad}></script>
|
|
205
211
|
</svelte:head>
|
|
206
212
|
|
|
207
|
-
|
|
208
|
-
{#if
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
{#if
|
|
218
|
-
<
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
<
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
213
|
+
{#if renderFallback && !scriptLoaded}
|
|
214
|
+
{#if mode === "search"}
|
|
215
|
+
<Input {id} {label} {hideLabel} value={value?.[labelKey]} />
|
|
216
|
+
{:else}
|
|
217
|
+
<Dropdown {id} {options} {label} {hideLabel} {placeholder} {value} />
|
|
218
|
+
{/if}
|
|
219
|
+
{:else}
|
|
220
|
+
<div class="ons-field {cls}">
|
|
221
|
+
{#if label}<label for={id} class="ons-label" class:ons-u-vh={hideLabel}>{label}</label>{/if}
|
|
222
|
+
<div class="ons-autocomplete-wrapper">
|
|
223
|
+
{#if scriptLoaded}
|
|
224
|
+
<div
|
|
225
|
+
id="{id}-container"
|
|
226
|
+
class="ons-autocomplete"
|
|
227
|
+
class:hide-menu={hideMenu}
|
|
228
|
+
use:initAutocomplete
|
|
229
|
+
></div>
|
|
230
|
+
{#if clearable && !autoClear && value}
|
|
231
|
+
<button
|
|
232
|
+
type="reset"
|
|
233
|
+
title="Clear selection"
|
|
234
|
+
aria-label="Clear selection"
|
|
235
|
+
on:click={clearInput}
|
|
236
|
+
class="ons-autocomplete-clear"
|
|
237
|
+
>
|
|
238
|
+
<svg
|
|
239
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
240
|
+
aria-hidden="true"
|
|
241
|
+
viewBox="0 0 14 14"
|
|
242
|
+
width="18"
|
|
243
|
+
>
|
|
244
|
+
<path
|
|
245
|
+
fill="currentColor"
|
|
246
|
+
d="M13.6 1 l -0.71 -0.71 a 0.5 0.5 0 0 0 -0.71 0 l -5.25 5.25 l -5.25 -5.25 a 0.51 0.51 0 0 0 -0.71 0 l -0.71 0.71 a 0.5 0.5 0 0 0 0 0.71 l 5.25 5.25 l -5.25 5.25 a 0.5 0.5 0 0 0 0 0.71 l 0.71 0.71 a 0.5 0.5 0 0 0 0.71 0 l 5.25 -5.25 l 5.25 5.25 a 0.5 0.5 0 0 0 0.71 0 l 0.71 -0.71 a 0.5 0.5 0 0 0 0 -0.71 l -5.25 -5.25 l 5.25 -5.25 a 0.5 0.5 0 0 0 0 -0.71Z"
|
|
247
|
+
></path>
|
|
248
|
+
</svg>
|
|
249
|
+
</button>
|
|
250
|
+
{/if}
|
|
232
251
|
{/if}
|
|
233
|
-
|
|
252
|
+
</div>
|
|
234
253
|
</div>
|
|
235
|
-
|
|
254
|
+
{/if}
|
|
236
255
|
|
|
237
256
|
<style>
|
|
238
257
|
.ons-autocomplete-wrapper {
|
|
@@ -14,17 +14,17 @@ export default class Select extends SvelteComponentTyped<{
|
|
|
14
14
|
autoClear?: boolean | undefined;
|
|
15
15
|
labelKey?: string | undefined;
|
|
16
16
|
groupKey?: string | null | undefined;
|
|
17
|
+
renderFallback?: boolean | undefined;
|
|
17
18
|
minLength?: number | undefined;
|
|
18
19
|
loadOptions?: Function | undefined;
|
|
19
20
|
scriptUrl?: string | undefined;
|
|
20
|
-
clearInput?:
|
|
21
|
+
clearInput?: Function | undefined;
|
|
21
22
|
}, {
|
|
22
23
|
clear: CustomEvent<any>;
|
|
23
24
|
change: CustomEvent<any>;
|
|
24
25
|
} & {
|
|
25
26
|
[evt: string]: CustomEvent<any>;
|
|
26
27
|
}, {}> {
|
|
27
|
-
get clearInput(): () => Promise<void>;
|
|
28
28
|
}
|
|
29
29
|
export type SelectProps = typeof __propDef.props;
|
|
30
30
|
export type SelectEvents = typeof __propDef.events;
|
|
@@ -44,10 +44,11 @@ declare const __propDef: {
|
|
|
44
44
|
autoClear?: boolean | undefined;
|
|
45
45
|
labelKey?: string | undefined;
|
|
46
46
|
groupKey?: string | null | undefined;
|
|
47
|
+
renderFallback?: boolean | undefined;
|
|
47
48
|
minLength?: number | undefined;
|
|
48
49
|
loadOptions?: Function | undefined;
|
|
49
50
|
scriptUrl?: string | undefined;
|
|
50
|
-
clearInput?:
|
|
51
|
+
clearInput?: Function | undefined;
|
|
51
52
|
};
|
|
52
53
|
events: {
|
|
53
54
|
clear: CustomEvent<any>;
|
|
@@ -15,3 +15,30 @@ This component will display a cookie banner and export a function that allows yo
|
|
|
15
15
|
<AnalyticsBanner analyticsId="{id_string}" />
|
|
16
16
|
<!-- Rest of page content -->
|
|
17
17
|
```
|
|
18
|
+
|
|
19
|
+
`AnalyticsBanner` can also take props.
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
const analyticsProps = {
|
|
23
|
+
contentTitle: "Weekly deaths dashboard",
|
|
24
|
+
releaseDate: data.dates.current.replaceAll("-", ""),
|
|
25
|
+
nextReleaseDate: data.dates.next.replaceAll("-", ""),
|
|
26
|
+
outputSeries: "weeklyprovisionalfiguresondeathsregisteredinenglandandwales",
|
|
27
|
+
contentType: "dashboard",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
<AnalyticsBanner {analyticsProps}/>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
An example analytics events. See this [doc](https://officenationalstatistics.sharepoint.com/:w:/r/sites/digpub/_layouts/15/Doc.aspx?sourcedoc=%7BBA405554-4040-4B61-9559-851F5C55DA39%7D&file=Google%20Analytics%20-%20GTM%20requirements.docx&action=default&mobileredirect=true) for more details (need to be on network).
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
analyticsEvent({
|
|
37
|
+
event: "interaction",
|
|
38
|
+
interactionType: "accordion",
|
|
39
|
+
interactionValue: e?.detail?.open ? "open" : "close",
|
|
40
|
+
label,
|
|
41
|
+
sectionTitle,
|
|
42
|
+
sectionNumber
|
|
43
|
+
});
|
|
44
|
+
```
|
|
@@ -6,17 +6,20 @@
|
|
|
6
6
|
import componentDocs from "./docs/component.md?raw";
|
|
7
7
|
import { lipsum } from "../../js/utils.js";
|
|
8
8
|
|
|
9
|
+
const parameters = { ...withComponentDocs(componentDocs), layout: "fullscreen" };
|
|
10
|
+
parameters.docs.story = { inline: false, iframeHeight: 600 };
|
|
11
|
+
|
|
9
12
|
const { Story } = defineMeta({
|
|
10
13
|
title: "Layout/NavSections",
|
|
11
14
|
component: NavSections,
|
|
12
15
|
tags: ["autodocs"],
|
|
13
16
|
argTypes: {},
|
|
14
|
-
parameters
|
|
17
|
+
parameters
|
|
15
18
|
});
|
|
16
19
|
</script>
|
|
17
20
|
|
|
18
21
|
{#snippet template(args)}
|
|
19
|
-
<NavSections>
|
|
22
|
+
<NavSections {...args}>
|
|
20
23
|
<NavSection title="Section one">
|
|
21
24
|
<p>
|
|
22
25
|
{lipsum()}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
Use this
|
|
1
|
+
Use this component to allow users to quickly jump to named sections within a long page of content.
|
|
2
2
|
|
|
3
|
-
As the user scrolls down the page,
|
|
4
|
-
|
|
5
|
-
Note: These examples will not preview correctly in the iframes on this page. You can select the examples from the menu instead.
|
|
3
|
+
As the user scrolls down the page, a table of contents will remain visible on the left of the viewport and will highlight the subheading of the section currently in view.
|
|
6
4
|
|
|
7
5
|
<!-- prettier-ignore -->
|
|
8
6
|
```html
|
|
@@ -7,16 +7,15 @@
|
|
|
7
7
|
import Em from "../../decorators/Em/Em.svelte";
|
|
8
8
|
import componentDocs from "./docs/component.md?raw";
|
|
9
9
|
|
|
10
|
+
const parameters = { ...withComponentDocs(componentDocs), layout: "fullscreen" };
|
|
11
|
+
parameters.docs.story = { inline: false, iframeHeight: 600 };
|
|
12
|
+
|
|
10
13
|
const { Story } = defineMeta({
|
|
11
14
|
title: "Layout/Scroller",
|
|
12
15
|
component: Scroller,
|
|
13
16
|
tags: ["autodocs"],
|
|
14
17
|
argTypes: {},
|
|
15
|
-
parameters
|
|
16
|
-
...withComponentDocs(componentDocs),
|
|
17
|
-
layout: "fullscreen",
|
|
18
|
-
docs: { story: { inline: false, iframeHeight: 600 } }
|
|
19
|
-
}
|
|
18
|
+
parameters
|
|
20
19
|
});
|
|
21
20
|
</script>
|
|
22
21
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
Components for adding scrollytelling sections to a feature article.
|
|
2
|
-
|
|
3
|
-
Note: These examples will not preview correctly in the iframes on this page. You can select the examples from the menu instead.
|
|
1
|
+
Components for adding interactive scrollytelling sections to a feature article.
|
|
4
2
|
|
|
5
3
|
<!-- prettier-ignore -->
|
|
6
4
|
```html
|
|
@@ -18,16 +18,15 @@
|
|
|
18
18
|
import ScrollerSection from "../../layout/Scroller/ScrollerSection.svelte";
|
|
19
19
|
import Footer from "../../layout/Footer/Footer.svelte";
|
|
20
20
|
|
|
21
|
+
const parameters = { ...withComponentDocs(componentDocs), layout: "fullscreen" };
|
|
22
|
+
parameters.docs.story = { inline: false, iframeHeight: 600 };
|
|
23
|
+
|
|
21
24
|
const { Story } = defineMeta({
|
|
22
25
|
title: "Templates/Feature article",
|
|
23
26
|
component: Header,
|
|
24
27
|
tags: ["autodocs"],
|
|
25
28
|
argTypes: {},
|
|
26
|
-
parameters
|
|
27
|
-
...withComponentDocs(componentDocs),
|
|
28
|
-
layout: "fullscreen",
|
|
29
|
-
docs: { story: { inline: false, iframeHeight: 600 } }
|
|
30
|
-
}
|
|
29
|
+
parameters
|
|
31
30
|
});
|
|
32
31
|
</script>
|
|
33
32
|
|