@communitiesuk/svelte-component-library 0.1.19-beta.3 → 0.1.19-beta.34
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/README.md +7 -0
- package/dist/components/content/Tag.svelte +32 -0
- package/dist/components/content/Tag.svelte.d.ts +13 -0
- package/dist/components/data-vis/Histogram.svelte +287 -0
- package/dist/components/data-vis/Histogram.svelte.d.ts +75 -0
- package/dist/components/data-vis/axis/Axis.svelte +217 -34
- package/dist/components/data-vis/axis/Axis.svelte.d.ts +38 -30
- package/dist/components/data-vis/axis/Ticks.svelte +142 -78
- package/dist/components/data-vis/axis/Ticks.svelte.d.ts +28 -31
- package/dist/components/data-vis/line-chart/LineChart.svelte +51 -21
- package/dist/components/data-vis/line-chart/LineChart.svelte.d.ts +14 -6
- package/dist/components/data-vis/line-chart/ValueLabel.svelte +2 -1
- package/dist/components/data-vis/line-chart/ValueLabel.svelte.d.ts +2 -0
- package/dist/components/data-vis/position-chart/PositionChart.svelte +279 -122
- package/dist/components/data-vis/position-chart/PositionChart.svelte.d.ts +37 -5
- package/dist/components/data-vis/position-chart/PositionChartAxis.svelte +59 -48
- package/dist/components/data-vis/position-chart/PositionChartAxis.svelte.d.ts +4 -4
- package/dist/components/data-vis/table/Table.svelte +145 -95
- package/dist/components/data-vis/table/Table.svelte.d.ts +4 -4
- package/dist/components/layout/Footer.svelte +9 -0
- package/dist/components/layout/Footer.svelte.d.ts +1 -0
- package/dist/components/layout/PhaseBanner.svelte +10 -1
- package/dist/components/layout/PhaseBanner.svelte.d.ts +1 -0
- package/dist/components/layout/ServiceNavigation.svelte +19 -1
- package/dist/components/layout/ServiceNavigation.svelte.d.ts +2 -0
- package/dist/components/ui/Accordion.svelte +212 -66
- package/dist/components/ui/Accordion.svelte.d.ts +2 -0
- package/dist/components/ui/BasicMultiSelect.svelte +716 -0
- package/dist/components/ui/BasicMultiSelect.svelte.d.ts +18 -0
- package/dist/components/ui/Button.svelte +220 -104
- package/dist/components/ui/Button.svelte.d.ts +4 -0
- package/dist/components/ui/Card.svelte +48 -60
- package/dist/components/ui/Card.svelte.d.ts +26 -12
- package/dist/components/ui/CardHeader.svelte +46 -0
- package/dist/components/ui/CardHeader.svelte.d.ts +21 -0
- package/dist/components/ui/ChartExporter.svelte +142 -0
- package/dist/components/ui/ChartExporter.svelte.d.ts +16 -0
- package/dist/components/ui/CheckBox.svelte +1 -0
- package/dist/components/ui/Details.svelte +47 -8
- package/dist/components/ui/Details.svelte.d.ts +8 -10
- package/dist/components/ui/Masthead.svelte +44 -6
- package/dist/components/ui/Masthead.svelte.d.ts +6 -0
- package/dist/components/ui/RelatedContent.svelte +4 -1
- package/dist/components/ui/RelatedContent.svelte.d.ts +1 -0
- package/dist/components/ui/SearchAutocomplete.svelte +69 -44
- package/dist/components/ui/SearchAutocomplete.svelte.d.ts +1 -0
- package/dist/components/ui/Select.svelte +18 -7
- package/dist/components/ui/Tabs.svelte +192 -18
- package/dist/components/ui/Tabs.svelte.d.ts +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/package.json +4 -1
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
minSectionsAllSectionToggle = 2,
|
|
17
17
|
rememberIsExpandedState = true,
|
|
18
18
|
headingLevel = "h4",
|
|
19
|
+
useCustomSectionIcon = false,
|
|
20
|
+
useLightweightAccordionStyles = false,
|
|
19
21
|
}: {
|
|
20
22
|
sections: {
|
|
21
23
|
heading: string;
|
|
@@ -34,35 +36,35 @@
|
|
|
34
36
|
minSectionsAllSectionToggle?: number;
|
|
35
37
|
rememberIsExpandedState?: boolean;
|
|
36
38
|
headingLevel?: string;
|
|
39
|
+
useCustomSectionIcon?: boolean;
|
|
40
|
+
useLightweightAccordionStyles?: boolean;
|
|
37
41
|
} = $props();
|
|
38
42
|
|
|
39
|
-
//Attempt to ensure that ids are unique by attaching extra characters
|
|
43
|
+
// Attempt to ensure that ids are unique by attaching extra characters
|
|
40
44
|
let uniqueSections = $derived(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
sections.map((section) => {
|
|
46
|
+
return {
|
|
47
|
+
...section,
|
|
48
|
+
uniqueid:
|
|
49
|
+
section.id +
|
|
50
|
+
section.heading.slice(1, 3) +
|
|
51
|
+
(section?.summary?.slice(0, 2) ?? ""),
|
|
52
|
+
};
|
|
53
|
+
}),
|
|
50
54
|
);
|
|
51
55
|
|
|
52
56
|
let expandedSections = $derived(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
new SvelteSet(
|
|
58
|
+
uniqueSections
|
|
59
|
+
.filter((section) => section.expanded)
|
|
60
|
+
.map((section) => section.uniqueid),
|
|
61
|
+
),
|
|
58
62
|
);
|
|
59
63
|
|
|
60
64
|
let allExpanded = $derived(expandedSections.size === sections.length);
|
|
61
65
|
|
|
62
66
|
let ariaLiveValue: "polite" | "off" | "assertive" | null | undefined =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
// Event handlers
|
|
67
|
+
$state("polite");
|
|
66
68
|
|
|
67
69
|
function toggleSection(uniqueid: string) {
|
|
68
70
|
if (expandedSections.has(uniqueid)) {
|
|
@@ -70,28 +72,25 @@
|
|
|
70
72
|
} else {
|
|
71
73
|
expandedSections.add(uniqueid);
|
|
72
74
|
}
|
|
73
|
-
|
|
75
|
+
|
|
74
76
|
ariaLiveValue = "polite";
|
|
75
77
|
}
|
|
76
78
|
|
|
77
79
|
function toggleAll() {
|
|
78
80
|
if (!allExpanded) {
|
|
79
81
|
uniqueSections.forEach((section) =>
|
|
80
|
-
|
|
82
|
+
expandedSections.add(section.uniqueid),
|
|
81
83
|
);
|
|
82
84
|
} else {
|
|
83
85
|
expandedSections.clear();
|
|
84
86
|
}
|
|
85
|
-
|
|
87
|
+
|
|
86
88
|
ariaLiveValue = "off";
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
// Only use session storage logic if rememberIsExpandedState is true
|
|
90
91
|
onMount(() => {
|
|
91
92
|
if (rememberIsExpandedState) {
|
|
92
93
|
uniqueSections.forEach((section) => {
|
|
93
|
-
// If the section is explicitly expanded, respect that.
|
|
94
|
-
// Otherwise, try to restore from session storage.
|
|
95
94
|
if (section.expanded) {
|
|
96
95
|
expandedSections.add(section.uniqueid);
|
|
97
96
|
} else {
|
|
@@ -102,7 +101,6 @@
|
|
|
102
101
|
}
|
|
103
102
|
});
|
|
104
103
|
} else {
|
|
105
|
-
// If rememberIsExpandedState is false, just respect the initial `section.expanded` values
|
|
106
104
|
uniqueSections.forEach((section) => {
|
|
107
105
|
if (section.expanded) {
|
|
108
106
|
expandedSections.add(section.uniqueid);
|
|
@@ -111,13 +109,12 @@
|
|
|
111
109
|
}
|
|
112
110
|
});
|
|
113
111
|
|
|
114
|
-
// Effect to update sessionStorage when uniqueSections change
|
|
115
112
|
$effect(() => {
|
|
116
113
|
if (rememberIsExpandedState) {
|
|
117
114
|
uniqueSections.forEach((section) => {
|
|
118
115
|
sessionStorage.setItem(
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
section.uniqueid,
|
|
117
|
+
expandedSections.has(section.uniqueid).toString(),
|
|
121
118
|
);
|
|
122
119
|
});
|
|
123
120
|
}
|
|
@@ -125,67 +122,112 @@
|
|
|
125
122
|
</script>
|
|
126
123
|
|
|
127
124
|
<div
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
class="govuk-accordion"
|
|
126
|
+
class:govuk-accordion--download-style={useLightweightAccordionStyles}
|
|
127
|
+
data-module="govuk-accordion"
|
|
128
|
+
id="accordion-default"
|
|
131
129
|
>
|
|
132
130
|
<div
|
|
133
|
-
|
|
134
|
-
|
|
131
|
+
class="govuk-accordion__controls"
|
|
132
|
+
hidden={!allSectionToggle ||
|
|
135
133
|
uniqueSections.length < minSectionsAllSectionToggle}
|
|
134
|
+
style="display: flex; flex-direction: row"
|
|
136
135
|
>
|
|
137
136
|
<button
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
137
|
+
type="button"
|
|
138
|
+
class="govuk-accordion__show-all"
|
|
139
|
+
aria-expanded={allExpanded}
|
|
140
|
+
onclick={toggleAll}
|
|
142
141
|
>
|
|
143
142
|
<span class="govuk-accordion__show-all-text">
|
|
144
143
|
{allExpanded ? hideAllSections : showAllSections}
|
|
145
144
|
</span>
|
|
146
145
|
<span
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
class="govuk-accordion-nav__chevron"
|
|
147
|
+
class:govuk-accordion-nav__chevron--down={!allExpanded}
|
|
149
148
|
></span>
|
|
150
149
|
</button>
|
|
151
150
|
</div>
|
|
152
151
|
|
|
153
152
|
{#snippet headerContent(section, isExpanded)}
|
|
154
153
|
<button
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
154
|
+
type="button"
|
|
155
|
+
aria-controls="{section.uniqueid}-content"
|
|
156
|
+
id="{section.uniqueid}-button"
|
|
157
|
+
class="govuk-accordion__section-button"
|
|
158
|
+
aria-expanded={isExpanded}
|
|
159
|
+
onclick={() => toggleSection(section.uniqueid)}
|
|
160
|
+
aria-label="{section.heading}, {section.summary
|
|
162
161
|
? section.summary + ','
|
|
163
162
|
: ''} {isExpanded ? hideSectionAriaLabel : showSectionAriaLabel}"
|
|
164
163
|
>
|
|
165
164
|
<span class="govuk-accordion__section-heading-text">
|
|
166
|
-
<span class="govuk-accordion__section-heading-text-focus"
|
|
167
|
-
|
|
168
|
-
>
|
|
165
|
+
<span class="govuk-accordion__section-heading-text-focus">
|
|
166
|
+
{section.heading}
|
|
167
|
+
</span>
|
|
169
168
|
</span>
|
|
170
169
|
|
|
171
170
|
{#if section.summary}
|
|
172
171
|
<span
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
class="govuk-visually-hidden govuk-accordion__section-heading-divider"
|
|
173
|
+
>
|
|
174
|
+
,
|
|
175
175
|
</span>
|
|
176
176
|
<span class="govuk-accordion__section-summary govuk-body">
|
|
177
|
-
<span class="govuk-accordion__section-summary-focus"
|
|
178
|
-
|
|
179
|
-
>
|
|
177
|
+
<span class="govuk-accordion__section-summary-focus">
|
|
178
|
+
{section.summary}
|
|
179
|
+
</span>
|
|
180
180
|
</span>
|
|
181
181
|
{/if}
|
|
182
182
|
|
|
183
183
|
<span class="govuk-accordion__section-toggle" data-nosnippet>
|
|
184
184
|
<span class="govuk-accordion__section-toggle-focus">
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
{#if useCustomSectionIcon}
|
|
186
|
+
<svg
|
|
187
|
+
width="30"
|
|
188
|
+
height="30"
|
|
189
|
+
viewBox="0 0 30 30"
|
|
190
|
+
aria-hidden="true"
|
|
191
|
+
class="govuk-accordion__custom-icon"
|
|
192
|
+
>
|
|
193
|
+
<g
|
|
194
|
+
transform="translate({12 + (isExpanded ? 3 : 0)},{15 + (isExpanded ? -3 : 0)}) rotate({isExpanded ? -45 : -135})"
|
|
195
|
+
>
|
|
196
|
+
{#each [-5, 5] as cxcy}
|
|
197
|
+
<circle
|
|
198
|
+
data-role={isExpanded
|
|
199
|
+
? "button-circle-selected"
|
|
200
|
+
: "button-circle-unselected"}
|
|
201
|
+
cx={cxcy}
|
|
202
|
+
cy={cxcy}
|
|
203
|
+
></circle>
|
|
204
|
+
{/each}
|
|
205
|
+
|
|
206
|
+
<path
|
|
207
|
+
data-role={isExpanded
|
|
208
|
+
? "button-path-selected"
|
|
209
|
+
: "button-path-unselected"}
|
|
210
|
+
d="M -5 -5 l0 9.75 m0.25 0.25 l9.75 0"
|
|
211
|
+
></path>
|
|
212
|
+
|
|
213
|
+
<rect
|
|
214
|
+
data-role={isExpanded
|
|
215
|
+
? "button-rect-selected"
|
|
216
|
+
: "button-rect-unselected"}
|
|
217
|
+
transform="translate(-6, 4)"
|
|
218
|
+
width="2"
|
|
219
|
+
height="2"
|
|
220
|
+
rx="4px"
|
|
221
|
+
></rect>
|
|
222
|
+
</g>
|
|
223
|
+
</svg>
|
|
224
|
+
{:else}
|
|
225
|
+
<span
|
|
226
|
+
class="govuk-accordion-nav__chevron"
|
|
227
|
+
class:govuk-accordion-nav__chevron--down={!isExpanded}
|
|
228
|
+
></span>
|
|
229
|
+
{/if}
|
|
230
|
+
|
|
189
231
|
<span class="govuk-accordion__section-toggle-text">
|
|
190
232
|
{isExpanded ? hideSection : showSection}
|
|
191
233
|
</span>
|
|
@@ -197,8 +239,8 @@
|
|
|
197
239
|
{#each uniqueSections as section}
|
|
198
240
|
{@const isExpanded = expandedSections.has(section.uniqueid)}
|
|
199
241
|
<div
|
|
200
|
-
|
|
201
|
-
|
|
242
|
+
class="govuk-accordion__section"
|
|
243
|
+
class:govuk-accordion__section--expanded={isExpanded}
|
|
202
244
|
>
|
|
203
245
|
<div class="govuk-accordion__section-header">
|
|
204
246
|
{#if headingLevel.toLowerCase() == "h2"}
|
|
@@ -223,13 +265,14 @@
|
|
|
223
265
|
</h6>
|
|
224
266
|
{/if}
|
|
225
267
|
</div>
|
|
268
|
+
|
|
226
269
|
<div
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
270
|
+
id="{section.uniqueid}-content"
|
|
271
|
+
class="govuk-accordion__section-content"
|
|
272
|
+
aria-live={ariaLiveValue}
|
|
273
|
+
hidden={!isExpanded}
|
|
274
|
+
role={uniqueSections.length < 6 ? "region" : ""}
|
|
275
|
+
aria-labelledby={uniqueSections.length < 6
|
|
233
276
|
? section.uniqueid + "-button"
|
|
234
277
|
: ""}
|
|
235
278
|
>
|
|
@@ -242,3 +285,106 @@
|
|
|
242
285
|
</div>
|
|
243
286
|
{/each}
|
|
244
287
|
</div>
|
|
288
|
+
|
|
289
|
+
<style>
|
|
290
|
+
.govuk-accordion__custom-icon {
|
|
291
|
+
display: inline-block;
|
|
292
|
+
vertical-align: middle;
|
|
293
|
+
flex: 0 0 auto;
|
|
294
|
+
margin-right: 0.35rem;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
[data-role="button-circle-unselected"] {
|
|
298
|
+
fill: #0B0C0C;
|
|
299
|
+
stroke: #0B0C0C;
|
|
300
|
+
stroke-width: 1.5;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
[data-role="button-circle-selected"] {
|
|
304
|
+
fill: #0B0C0C;
|
|
305
|
+
stroke: #0B0C0C;
|
|
306
|
+
stroke-width: 1.5;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
[data-role="button-path-unselected"] {
|
|
310
|
+
stroke: #0B0C0C;
|
|
311
|
+
stroke-width: 2;
|
|
312
|
+
fill: none;
|
|
313
|
+
stroke-linecap: round;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
[data-role="button-path-selected"] {
|
|
317
|
+
stroke: #0B0C0C;
|
|
318
|
+
stroke-width: 2;
|
|
319
|
+
fill: none;
|
|
320
|
+
stroke-linecap: round;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
[data-role="button-rect-unselected"] {
|
|
324
|
+
fill: #0B0C0C;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
[data-role="button-rect-selected"] {
|
|
328
|
+
fill: #0B0C0C;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
/* Alternative style mode */
|
|
332
|
+
.govuk-accordion--download-style {
|
|
333
|
+
background: #f8f8f8;
|
|
334
|
+
padding: 0.75rem 1rem;
|
|
335
|
+
border: 1px solid #e0e0e0;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
.govuk-accordion--download-style.govuk-accordion {
|
|
339
|
+
border-bottom: 0;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.govuk-accordion--download-style .govuk-accordion__section {
|
|
343
|
+
border-bottom: 1px solid #b1b4b6;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.govuk-accordion--download-style .govuk-accordion__section-button {
|
|
347
|
+
display: flex;
|
|
348
|
+
align-items: center;
|
|
349
|
+
gap: 0.5rem;
|
|
350
|
+
width: 100%;
|
|
351
|
+
padding: 1rem 0;
|
|
352
|
+
border: 0;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
.govuk-accordion--download-style .govuk-accordion__section-button:hover {
|
|
356
|
+
color: #0b0c0c;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
.govuk-accordion--download-style .govuk-accordion__section-toggle {
|
|
360
|
+
order: -1;
|
|
361
|
+
margin: 0;
|
|
362
|
+
min-width: 1rem;
|
|
363
|
+
display: flex;
|
|
364
|
+
align-items: center;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
.govuk-accordion--download-style .govuk-accordion__section-toggle-focus {
|
|
368
|
+
display: flex;
|
|
369
|
+
align-items: center;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.govuk-accordion--download-style .govuk-accordion__section-toggle-text {
|
|
373
|
+
display: none;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
.govuk-accordion--download-style .govuk-accordion__section-content .govuk-body {
|
|
377
|
+
padding-top: 0;
|
|
378
|
+
margin-top: 0;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
.govuk-accordion--download-style .govuk-accordion__section-heading-text {
|
|
382
|
+
margin-bottom: 0;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.govuk-accordion--download-style .govuk-hint {
|
|
386
|
+
all: unset;
|
|
387
|
+
display: block;
|
|
388
|
+
margin-bottom: 0.5rem;
|
|
389
|
+
}
|
|
390
|
+
</style>
|
|
@@ -17,6 +17,8 @@ type $$ComponentProps = {
|
|
|
17
17
|
minSectionsAllSectionToggle?: number;
|
|
18
18
|
rememberIsExpandedState?: boolean;
|
|
19
19
|
headingLevel?: string;
|
|
20
|
+
useCustomSectionIcon?: boolean;
|
|
21
|
+
useLightweightAccordionStyles?: boolean;
|
|
20
22
|
};
|
|
21
23
|
declare const Accordion: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
22
24
|
type Accordion = ReturnType<typeof Accordion>;
|