@communitiesuk/svelte-component-library 0.1.17
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 +188 -0
- package/dist/assets/css/govuk-frontend.min.css +2 -0
- package/dist/assets/css/govuk-frontend.min.css.map +1 -0
- package/dist/assets/fonts/bold-affa96571d-v2.woff +0 -0
- package/dist/assets/fonts/bold-b542beb274-v2.woff2 +0 -0
- package/dist/assets/fonts/light-94a07e06a1-v2.woff2 +0 -0
- package/dist/assets/fonts/light-f591b13f7d-v2.woff +0 -0
- package/dist/assets/govuk_publishing_components/images/icon-autocomplete-search-suggestion.svg +4 -0
- package/dist/assets/govuk_publishing_components/images/icon-close.svg +1 -0
- package/dist/assets/images/favicon.ico +0 -0
- package/dist/assets/images/favicon.svg +1 -0
- package/dist/assets/images/govuk-crest-2x.png +0 -0
- package/dist/assets/images/govuk-crest.png +0 -0
- package/dist/assets/images/govuk-crest.svg +1 -0
- package/dist/assets/images/govuk-icon-180.png +0 -0
- package/dist/assets/images/govuk-icon-192.png +0 -0
- package/dist/assets/images/govuk-icon-512.png +0 -0
- package/dist/assets/images/govuk-icon-mask.svg +1 -0
- package/dist/assets/images/govuk-opengraph-image.png +0 -0
- package/dist/assets/images/homepage-illustration.svg +1 -0
- package/dist/assets/images/homepage.svg +44 -0
- package/dist/assets/images/masthead-illustration.svg +123 -0
- package/dist/assets/images/oflog_crest_black.png +0 -0
- package/dist/assets/images/oflog_crest_white.png +0 -0
- package/dist/assets/images/undraw_approved-wireframe_odf4.svg +1 -0
- package/dist/assets/images/undraw_collaborators_rgw4.svg +1 -0
- package/dist/assets/images/undraw_content-creator_vuqg.svg +1 -0
- package/dist/assets/images/undraw_online-media_opxh.svg +1 -0
- package/dist/assets/images/undraw_pull-request_zlsu.svg +1 -0
- package/dist/assets/images/undraw_reviewed-docs_g0cg.svg +1 -0
- package/dist/components/FilterPanel/codeBlocks.d.ts +3 -0
- package/dist/components/FilterPanel/codeBlocks.js +418 -0
- package/dist/components/content/InsetText.svelte +21 -0
- package/dist/components/content/InsetText.svelte.d.ts +7 -0
- package/dist/components/content/WarningText.svelte +27 -0
- package/dist/components/content/WarningText.svelte.d.ts +8 -0
- package/dist/components/data-vis/axis/Axis.svelte +51 -0
- package/dist/components/data-vis/axis/Axis.svelte.d.ts +33 -0
- package/dist/components/data-vis/axis/Ticks.svelte +113 -0
- package/dist/components/data-vis/axis/Ticks.svelte.d.ts +33 -0
- package/dist/components/data-vis/line-chart/Line.svelte +150 -0
- package/dist/components/data-vis/line-chart/Line.svelte.d.ts +85 -0
- package/dist/components/data-vis/line-chart/LineChart.svelte +249 -0
- package/dist/components/data-vis/line-chart/LineChart.svelte.d.ts +73 -0
- package/dist/components/data-vis/line-chart/Lines.svelte +138 -0
- package/dist/components/data-vis/line-chart/Lines.svelte.d.ts +57 -0
- package/dist/components/data-vis/line-chart/Marker.svelte +61 -0
- package/dist/components/data-vis/line-chart/Marker.svelte.d.ts +37 -0
- package/dist/components/data-vis/line-chart/SeriesLabel.svelte +67 -0
- package/dist/components/data-vis/line-chart/SeriesLabel.svelte.d.ts +43 -0
- package/dist/components/data-vis/line-chart/ValueLabel.svelte +50 -0
- package/dist/components/data-vis/line-chart/ValueLabel.svelte.d.ts +25 -0
- package/dist/components/data-vis/map/Map.svelte +392 -0
- package/dist/components/data-vis/map/Map.svelte.d.ts +47 -0
- package/dist/components/data-vis/map/MapLegend.svelte +41 -0
- package/dist/components/data-vis/map/MapLegend.svelte.d.ts +15 -0
- package/dist/components/data-vis/map/NonStandardControls.svelte +42 -0
- package/dist/components/data-vis/map/NonStandardControls.svelte.d.ts +13 -0
- package/dist/components/data-vis/map/Tooltip.svelte +41 -0
- package/dist/components/data-vis/map/Tooltip.svelte.d.ts +19 -0
- package/dist/components/data-vis/map/colorbrewer.d.ts +337 -0
- package/dist/components/data-vis/map/colorbrewer.js +1523 -0
- package/dist/components/data-vis/map/colors.d.ts +13 -0
- package/dist/components/data-vis/map/colors.js +65 -0
- package/dist/components/data-vis/map/dataJoin.d.ts +2 -0
- package/dist/components/data-vis/map/dataJoin.js +27 -0
- package/dist/components/data-vis/map/fullTopo.json +1 -0
- package/dist/components/data-vis/map/jenks.d.ts +1 -0
- package/dist/components/data-vis/map/jenks.js +51 -0
- package/dist/components/data-vis/map/lad2023.json +1 -0
- package/dist/components/data-vis/map/mapUtils.d.ts +5 -0
- package/dist/components/data-vis/map/mapUtils.js +86 -0
- package/dist/components/data-vis/map/topo.json +1 -0
- package/dist/components/data-vis/table/Table.svelte +247 -0
- package/dist/components/data-vis/table/Table.svelte.d.ts +19 -0
- package/dist/components/layout/Breadcrumbs.svelte +191 -0
- package/dist/components/layout/Breadcrumbs.svelte.d.ts +24 -0
- package/dist/components/layout/Footer.svelte +171 -0
- package/dist/components/layout/Footer.svelte.d.ts +30 -0
- package/dist/components/layout/Header.svelte +43 -0
- package/dist/components/layout/Header.svelte.d.ts +7 -0
- package/dist/components/layout/InternalHeader.svelte +628 -0
- package/dist/components/layout/InternalHeader.svelte.d.ts +15 -0
- package/dist/components/layout/PhaseBanner.svelte +28 -0
- package/dist/components/layout/PhaseBanner.svelte.d.ts +9 -0
- package/dist/components/layout/ServiceNavigation.svelte +143 -0
- package/dist/components/layout/ServiceNavigation.svelte.d.ts +13 -0
- package/dist/components/layout/SideNavigation.svelte +345 -0
- package/dist/components/layout/SideNavigation.svelte.d.ts +25 -0
- package/dist/components/layout/service-navigation-nested-mobile/HeaderNav.svelte +91 -0
- package/dist/components/layout/service-navigation-nested-mobile/HeaderNav.svelte.d.ts +15 -0
- package/dist/components/layout/service-navigation-nested-mobile/MobileNav.svelte +233 -0
- package/dist/components/layout/service-navigation-nested-mobile/MobileNav.svelte.d.ts +27 -0
- package/dist/components/layout/service-navigation-nested-mobile/ServiceNavigationNestedMobile.svelte +70 -0
- package/dist/components/layout/service-navigation-nested-mobile/ServiceNavigationNestedMobile.svelte.d.ts +11 -0
- package/dist/components/layout/service-navigation-nested-mobile/SideNav.svelte +276 -0
- package/dist/components/layout/service-navigation-nested-mobile/SideNav.svelte.d.ts +22 -0
- package/dist/components/ui/Accordion.svelte +244 -0
- package/dist/components/ui/Accordion.svelte.d.ts +23 -0
- package/dist/components/ui/Breadcrumbs.svelte +198 -0
- package/dist/components/ui/Breadcrumbs.svelte.d.ts +24 -0
- package/dist/components/ui/Button.svelte +96 -0
- package/dist/components/ui/Button.svelte.d.ts +17 -0
- package/dist/components/ui/CheckBox.svelte +198 -0
- package/dist/components/ui/CheckBox.svelte.d.ts +27 -0
- package/dist/components/ui/ContentsList.svelte +1117 -0
- package/dist/components/ui/ContentsList.svelte.d.ts +25 -0
- package/dist/components/ui/DateInput.svelte +255 -0
- package/dist/components/ui/DateInput.svelte.d.ts +59 -0
- package/dist/components/ui/Details.svelte +12 -0
- package/dist/components/ui/Details.svelte.d.ts +13 -0
- package/dist/components/ui/FilterPanel.svelte +588 -0
- package/dist/components/ui/FilterPanel.svelte.d.ts +74 -0
- package/dist/components/ui/Footer.svelte +171 -0
- package/dist/components/ui/Footer.svelte.d.ts +30 -0
- package/dist/components/ui/Header.svelte +43 -0
- package/dist/components/ui/Header.svelte.d.ts +7 -0
- package/dist/components/ui/Masthead.svelte +267 -0
- package/dist/components/ui/Masthead.svelte.d.ts +12 -0
- package/dist/components/ui/NavigationExample.svelte +117 -0
- package/dist/components/ui/NavigationExample.svelte.d.ts +3 -0
- package/dist/components/ui/NotificationBanner.svelte +93 -0
- package/dist/components/ui/NotificationBanner.svelte.d.ts +15 -0
- package/dist/components/ui/Radios.svelte +176 -0
- package/dist/components/ui/Radios.svelte.d.ts +28 -0
- package/dist/components/ui/RelatedContent.svelte +596 -0
- package/dist/components/ui/RelatedContent.svelte.d.ts +29 -0
- package/dist/components/ui/Search.svelte +499 -0
- package/dist/components/ui/Search.svelte.d.ts +32 -0
- package/dist/components/ui/SearchAutocomplete.svelte +655 -0
- package/dist/components/ui/SearchAutocomplete.svelte.d.ts +37 -0
- package/dist/components/ui/Select.svelte +116 -0
- package/dist/components/ui/Select.svelte.d.ts +22 -0
- package/dist/components/ui/ServiceNavigation.svelte +143 -0
- package/dist/components/ui/ServiceNavigation.svelte.d.ts +13 -0
- package/dist/components/ui/SideNavigation.svelte +346 -0
- package/dist/components/ui/SideNavigation.svelte.d.ts +25 -0
- package/dist/components/ui/Tabs.svelte +306 -0
- package/dist/components/ui/Tabs.svelte.d.ts +18 -0
- package/dist/components/ui/WhatsNew.svelte +155 -0
- package/dist/components/ui/WhatsNew.svelte.d.ts +29 -0
- package/dist/config.d.ts +51 -0
- package/dist/config.js +44 -0
- package/dist/icons/DoubleChevronButton.svelte +62 -0
- package/dist/icons/DoubleChevronButton.svelte.d.ts +13 -0
- package/dist/icons/IconSearch.svelte +42 -0
- package/dist/icons/IconSearch.svelte.d.ts +6 -0
- package/dist/icons/SingleChevronButtonWithLabel.svelte +132 -0
- package/dist/icons/SingleChevronButtonWithLabel.svelte.d.ts +19 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +45 -0
- package/dist/main.css +1 -0
- package/dist/package-wrapping/BaseInformation.svelte +82 -0
- package/dist/package-wrapping/BaseInformation.svelte.d.ts +15 -0
- package/dist/package-wrapping/BaseNameAndStatus.svelte +108 -0
- package/dist/package-wrapping/BaseNameAndStatus.svelte.d.ts +10 -0
- package/dist/package-wrapping/CodeBlock.svelte +62 -0
- package/dist/package-wrapping/CodeBlock.svelte.d.ts +12 -0
- package/dist/package-wrapping/ComponentDemo.svelte +114 -0
- package/dist/package-wrapping/ComponentDemo.svelte.d.ts +25 -0
- package/dist/package-wrapping/ComponentDemoTEMP.svelte +305 -0
- package/dist/package-wrapping/ComponentDemoTEMP.svelte.d.ts +21 -0
- package/dist/package-wrapping/ComponentDetails.svelte +123 -0
- package/dist/package-wrapping/ComponentDetails.svelte.d.ts +13 -0
- package/dist/package-wrapping/DividerLine.svelte +21 -0
- package/dist/package-wrapping/DividerLine.svelte.d.ts +17 -0
- package/dist/package-wrapping/InputForParameter.svelte +205 -0
- package/dist/package-wrapping/InputForParameter.svelte.d.ts +13 -0
- package/dist/package-wrapping/InputForParameterUpdated.svelte +222 -0
- package/dist/package-wrapping/InputForParameterUpdated.svelte.d.ts +17 -0
- package/dist/package-wrapping/InputForParameterUpdatedTEMP.svelte +203 -0
- package/dist/package-wrapping/InputForParameterUpdatedTEMP.svelte.d.ts +17 -0
- package/dist/package-wrapping/ListOfComponentStatuses.svelte +19 -0
- package/dist/package-wrapping/ListOfComponentStatuses.svelte.d.ts +11 -0
- package/dist/package-wrapping/OverlayAndComponentContainer.svelte +426 -0
- package/dist/package-wrapping/OverlayAndComponentContainer.svelte.d.ts +33 -0
- package/dist/package-wrapping/ParametersSection.svelte +235 -0
- package/dist/package-wrapping/ParametersSection.svelte.d.ts +19 -0
- package/dist/package-wrapping/ParsingErrorToastsContainer.svelte +50 -0
- package/dist/package-wrapping/ParsingErrorToastsContainer.svelte.d.ts +15 -0
- package/dist/package-wrapping/Pill.svelte +54 -0
- package/dist/package-wrapping/Pill.svelte.d.ts +25 -0
- package/dist/package-wrapping/PlaygroundDetails.svelte +106 -0
- package/dist/package-wrapping/PlaygroundDetails.svelte.d.ts +13 -0
- package/dist/package-wrapping/ScreenSizeRadio.svelte +24 -0
- package/dist/package-wrapping/ScreenSizeRadio.svelte.d.ts +11 -0
- package/dist/package-wrapping/ScreenSizeRadioUpdated.svelte +23 -0
- package/dist/package-wrapping/ScreenSizeRadioUpdated.svelte.d.ts +11 -0
- package/dist/package-wrapping/SidebarContainer.svelte +103 -0
- package/dist/package-wrapping/SidebarContainer.svelte.d.ts +23 -0
- package/dist/package-wrapping/WrapperDetailsUpdate.svelte +40 -0
- package/dist/package-wrapping/WrapperDetailsUpdate.svelte.d.ts +15 -0
- package/dist/package-wrapping/templates/Template.svelte +100 -0
- package/dist/package-wrapping/templates/Template.svelte.d.ts +25 -0
- package/dist/templates/ComponentPageTemplate.svelte +1 -0
- package/dist/templates/ComponentPageTemplate.svelte.d.ts +26 -0
- package/dist/utils/data-transformations/convertCSV.d.ts +2 -0
- package/dist/utils/data-transformations/convertCSV.js +22 -0
- package/dist/utils/data-transformations/getValueFromParametersArray.d.ts +1 -0
- package/dist/utils/data-transformations/getValueFromParametersArray.js +9 -0
- package/dist/utils/layoutNavHelpers.d.ts +70 -0
- package/dist/utils/layoutNavHelpers.js +129 -0
- package/dist/utils/package-wrapping-specific/addIndexAndInitialValue.d.ts +1 -0
- package/dist/utils/package-wrapping-specific/addIndexAndInitialValue.js +21 -0
- package/dist/utils/package-wrapping-specific/createBindableParametersValuesArray.d.ts +1 -0
- package/dist/utils/package-wrapping-specific/createBindableParametersValuesArray.js +12 -0
- package/dist/utils/package-wrapping-specific/createParametersObject.d.ts +1 -0
- package/dist/utils/package-wrapping-specific/createParametersObject.js +29 -0
- package/dist/utils/package-wrapping-specific/defineDefaultEventHandler.d.ts +1 -0
- package/dist/utils/package-wrapping-specific/defineDefaultEventHandler.js +14 -0
- package/dist/utils/package-wrapping-specific/trackVisibleParameters.d.ts +1 -0
- package/dist/utils/package-wrapping-specific/trackVisibleParameters.js +29 -0
- package/dist/utils/syntax-highlighting/shikiHighlight.d.ts +7 -0
- package/dist/utils/syntax-highlighting/shikiHighlight.js +76 -0
- package/dist/utils/text-string-conversion/textStringConversion.d.ts +9 -0
- package/dist/utils/text-string-conversion/textStringConversion.js +86 -0
- package/package.json +113 -0
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
// Based on GOV.UK Finder Frontend
|
|
3
|
+
// Original: https://github.com/alphagov/finder-frontend
|
|
4
|
+
|
|
5
|
+
import Radios from "./Radios.svelte";
|
|
6
|
+
import CheckBox from "./CheckBox.svelte";
|
|
7
|
+
import Select from "./Select.svelte";
|
|
8
|
+
import DateInput from "./DateInput.svelte";
|
|
9
|
+
|
|
10
|
+
interface FilterOption {
|
|
11
|
+
value: string;
|
|
12
|
+
label: string;
|
|
13
|
+
id?: string; // Optional, can be generated
|
|
14
|
+
checked?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface BaseSection {
|
|
18
|
+
id: string; // for unique key in #each, and details element id
|
|
19
|
+
title: string;
|
|
20
|
+
ga4Section: string; // For data-ga4-section
|
|
21
|
+
ga4IndexSection: number;
|
|
22
|
+
ga4IndexSectionCount: number;
|
|
23
|
+
openByDefault?: boolean; // To control if the details section is open by default
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface RadioSection extends BaseSection {
|
|
27
|
+
type: string;
|
|
28
|
+
name: string;
|
|
29
|
+
legend: string;
|
|
30
|
+
options: FilterOption[];
|
|
31
|
+
selectedValue?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface DateSection extends BaseSection {
|
|
35
|
+
type: string;
|
|
36
|
+
fromLegend: string;
|
|
37
|
+
fromNamePrefix: string; // e.g., "public_timestamp[from]"
|
|
38
|
+
fromHint?: string;
|
|
39
|
+
fromInitialValue?: { day?: string; month?: string; year?: string };
|
|
40
|
+
toLegend: string;
|
|
41
|
+
toNamePrefix: string; // e.g., "public_timestamp[to]"
|
|
42
|
+
toHint?: string;
|
|
43
|
+
toInitialValue?: { day?: string; month?: string; year?: string };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface SelectOption extends FilterOption {
|
|
47
|
+
disabled?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
interface SelectField {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
label: string;
|
|
54
|
+
options: SelectOption[];
|
|
55
|
+
value?: string;
|
|
56
|
+
fullWidth?: boolean;
|
|
57
|
+
disabled?: boolean;
|
|
58
|
+
}
|
|
59
|
+
interface SelectSection extends BaseSection {
|
|
60
|
+
type: string;
|
|
61
|
+
selects: SelectField[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
interface CheckboxSection extends BaseSection {
|
|
65
|
+
type: string;
|
|
66
|
+
name: string; // e.g., "content_purpose_supergroup[]"
|
|
67
|
+
legend: string;
|
|
68
|
+
options: FilterOption[];
|
|
69
|
+
selectedValues?: string[];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
type Section = RadioSection | DateSection | SelectSection | CheckboxSection;
|
|
73
|
+
|
|
74
|
+
let {
|
|
75
|
+
resultsCount = "0 results",
|
|
76
|
+
sectionsData = [] as Section[],
|
|
77
|
+
filterButtonText = "Filter and sort",
|
|
78
|
+
applyButtonText = "Apply",
|
|
79
|
+
// GA4 related props
|
|
80
|
+
ga4BaseEvent = { event_name: "select_content", type: "finder" },
|
|
81
|
+
} = $props<{
|
|
82
|
+
resultsCount?: string;
|
|
83
|
+
sectionsData?: Section[];
|
|
84
|
+
filterButtonText?: string;
|
|
85
|
+
applyButtonText?: string;
|
|
86
|
+
ga4BaseEvent?: Record<string, any>;
|
|
87
|
+
}>();
|
|
88
|
+
|
|
89
|
+
let sections = $derived(sectionsData);
|
|
90
|
+
|
|
91
|
+
// Call $props.id() once at the top level
|
|
92
|
+
const componentId = $props.id();
|
|
93
|
+
|
|
94
|
+
let panelOpen = $state(true);
|
|
95
|
+
// Use the stored componentId to create other IDs
|
|
96
|
+
const panelId = `filter-panel-${componentId}`;
|
|
97
|
+
const filterButtonId = `filter-button-${componentId}`;
|
|
98
|
+
|
|
99
|
+
function togglePanel() {
|
|
100
|
+
panelOpen = !panelOpen;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function getGa4Event(customData: Record<string, any>) {
|
|
104
|
+
return JSON.stringify({ ...ga4BaseEvent, ...customData });
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Helper to create items for DateInput, now including spellcheck attribute
|
|
108
|
+
function createDateInputItems(
|
|
109
|
+
initialValues: { day?: string; month?: string; year?: string } | undefined,
|
|
110
|
+
) {
|
|
111
|
+
return [
|
|
112
|
+
{
|
|
113
|
+
name: "day",
|
|
114
|
+
label: "Day",
|
|
115
|
+
value: initialValues?.day,
|
|
116
|
+
attributes: { spellcheck: "false" },
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "month",
|
|
120
|
+
label: "Month",
|
|
121
|
+
value: initialValues?.month,
|
|
122
|
+
attributes: { spellcheck: "false" },
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "year",
|
|
126
|
+
label: "Year",
|
|
127
|
+
value: initialValues?.year,
|
|
128
|
+
attributes: { spellcheck: "false" },
|
|
129
|
+
},
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
</script>
|
|
133
|
+
|
|
134
|
+
<div data-module="filter-panel ga4-event-tracker" class="app-c-filter-panel">
|
|
135
|
+
<div class="app-c-filter-panel__header">
|
|
136
|
+
<button
|
|
137
|
+
id={filterButtonId}
|
|
138
|
+
class="app-c-filter-panel__button govuk-link"
|
|
139
|
+
aria-expanded={panelOpen}
|
|
140
|
+
aria-controls={panelId}
|
|
141
|
+
onclick={togglePanel}
|
|
142
|
+
data-ga4-expandable=""
|
|
143
|
+
data-ga4-event={getGa4Event({
|
|
144
|
+
section: filterButtonText,
|
|
145
|
+
text: filterButtonText,
|
|
146
|
+
index_section: 0,
|
|
147
|
+
index_section_count: sections.length,
|
|
148
|
+
})}
|
|
149
|
+
>
|
|
150
|
+
<span class="app-c-filter-panel__button-inner">{filterButtonText}</span>
|
|
151
|
+
</button>
|
|
152
|
+
<h2 id="js-result-count" class="app-c-filter-panel__count">
|
|
153
|
+
{resultsCount}
|
|
154
|
+
</h2>
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
{#if panelOpen}
|
|
158
|
+
<div
|
|
159
|
+
class="app-c-filter-panel__content"
|
|
160
|
+
id={panelId}
|
|
161
|
+
role="region"
|
|
162
|
+
aria-labelledby={filterButtonId}
|
|
163
|
+
>
|
|
164
|
+
{#each sections as section (section.id)}
|
|
165
|
+
<details
|
|
166
|
+
data-ga4-index={JSON.stringify({
|
|
167
|
+
index_section: section.ga4IndexSection,
|
|
168
|
+
index_section_count: section.ga4IndexSectionCount,
|
|
169
|
+
})}
|
|
170
|
+
data-module="filter-section"
|
|
171
|
+
data-ga4-section={section.ga4Section}
|
|
172
|
+
data-ga4-filter-parent={section.ga4Section}
|
|
173
|
+
data-ga4-change-category={`update-filter ${section.type === "radios" || section.type === "checkboxes" ? section.type.slice(0, -2) : section.type}`}
|
|
174
|
+
class="app-c-filter-section {section.type === 'select' &&
|
|
175
|
+
section.title === 'Topic'
|
|
176
|
+
? 'js-all-content-finder-taxonomy-select'
|
|
177
|
+
: ''}"
|
|
178
|
+
open={section.openByDefault === undefined
|
|
179
|
+
? true
|
|
180
|
+
: section.openByDefault}
|
|
181
|
+
>
|
|
182
|
+
<summary
|
|
183
|
+
class="app-c-filter-section__summary"
|
|
184
|
+
data-ga4-expandable=""
|
|
185
|
+
data-ga4-event={getGa4Event({
|
|
186
|
+
section: section.ga4Section,
|
|
187
|
+
text: section.ga4Section,
|
|
188
|
+
index_section: section.ga4IndexSection,
|
|
189
|
+
index_section_count: section.ga4IndexSectionCount,
|
|
190
|
+
})}
|
|
191
|
+
>
|
|
192
|
+
<h2 class="app-c-filter-section__summary-heading">
|
|
193
|
+
{#if section.type !== "radios"}
|
|
194
|
+
<span class="govuk-visually-hidden">Filter by</span>{/if}
|
|
195
|
+
{section.title}
|
|
196
|
+
</h2>
|
|
197
|
+
</summary>
|
|
198
|
+
<div class="app-c-filter-section__content">
|
|
199
|
+
{#if section.type === "radios"}
|
|
200
|
+
{@const radioData = section}
|
|
201
|
+
<div class="govuk-form-group govuk-!-margin-bottom-2">
|
|
202
|
+
<Radios
|
|
203
|
+
name={radioData.name}
|
|
204
|
+
legend={radioData.legend}
|
|
205
|
+
legendSize="m"
|
|
206
|
+
isPageHeading={false}
|
|
207
|
+
options={radioData.options.map((opt) => ({ ...opt }))}
|
|
208
|
+
selectedValue={radioData.selectedValue}
|
|
209
|
+
small={true}
|
|
210
|
+
/>
|
|
211
|
+
</div>
|
|
212
|
+
{:else if section.type === "date"}
|
|
213
|
+
{@const dateData = section}
|
|
214
|
+
<div data-ga4-section="Updated after">
|
|
215
|
+
<DateInput
|
|
216
|
+
id={`${dateData.id}-from`}
|
|
217
|
+
namePrefix={dateData.fromNamePrefix}
|
|
218
|
+
items={createDateInputItems(dateData.fromInitialValue)}
|
|
219
|
+
fieldset={{
|
|
220
|
+
legend: { text: dateData.fromLegend, isPageHeading: false },
|
|
221
|
+
}}
|
|
222
|
+
hint={{ text: dateData.fromHint }}
|
|
223
|
+
legendSize={undefined}
|
|
224
|
+
/>
|
|
225
|
+
</div>
|
|
226
|
+
<div data-ga4-section="Updated before">
|
|
227
|
+
<DateInput
|
|
228
|
+
id={`${dateData.id}-to`}
|
|
229
|
+
namePrefix={dateData.toNamePrefix}
|
|
230
|
+
items={createDateInputItems(dateData.toInitialValue)}
|
|
231
|
+
fieldset={{
|
|
232
|
+
legend: { text: dateData.toLegend, isPageHeading: false },
|
|
233
|
+
}}
|
|
234
|
+
hint={{ text: dateData.toHint }}
|
|
235
|
+
legendSize={undefined}
|
|
236
|
+
/>
|
|
237
|
+
</div>
|
|
238
|
+
{:else if section.type === "select"}
|
|
239
|
+
{@const selectData = section}
|
|
240
|
+
{#each selectData.selects as sel, selIdx (sel.id)}
|
|
241
|
+
<div
|
|
242
|
+
class={`govuk-form-group gem-c-select ${selIdx === 1 ? "js-required" : ""}`}
|
|
243
|
+
style={selIdx === 1 ? "display: block;" : undefined}
|
|
244
|
+
data-ga4-section={selIdx === 1 ? sel.label : undefined}
|
|
245
|
+
>
|
|
246
|
+
<Select
|
|
247
|
+
id={sel.id}
|
|
248
|
+
name={sel.name}
|
|
249
|
+
label={sel.label}
|
|
250
|
+
items={sel.options.map((opt) => ({
|
|
251
|
+
value: opt.value,
|
|
252
|
+
text: opt.label,
|
|
253
|
+
disabled: opt.disabled,
|
|
254
|
+
}))}
|
|
255
|
+
value={sel.value}
|
|
256
|
+
fullWidth={sel.fullWidth}
|
|
257
|
+
labelIsPageHeading={false}
|
|
258
|
+
/>
|
|
259
|
+
</div>
|
|
260
|
+
{/each}
|
|
261
|
+
{:else if section.type === "checkboxes"}
|
|
262
|
+
{@const checkboxData = section}
|
|
263
|
+
<div
|
|
264
|
+
id={`checkboxes-${checkboxData.id}`}
|
|
265
|
+
data-module="gem-checkboxes govuk-checkboxes"
|
|
266
|
+
class="gem-c-checkboxes govuk-form-group govuk-checkboxes--small"
|
|
267
|
+
>
|
|
268
|
+
<CheckBox
|
|
269
|
+
name={checkboxData.name}
|
|
270
|
+
legend={checkboxData.legend}
|
|
271
|
+
legendSize="m"
|
|
272
|
+
isPageHeading={false}
|
|
273
|
+
options={checkboxData.options.map((opt) => ({ ...opt }))}
|
|
274
|
+
selectedValues={checkboxData.selectedValues}
|
|
275
|
+
small={true}
|
|
276
|
+
/>
|
|
277
|
+
</div>
|
|
278
|
+
{/if}
|
|
279
|
+
</div>
|
|
280
|
+
</details>
|
|
281
|
+
{/each}
|
|
282
|
+
|
|
283
|
+
<div class="app-c-filter-panel__actions">
|
|
284
|
+
<input
|
|
285
|
+
type="submit"
|
|
286
|
+
value={applyButtonText}
|
|
287
|
+
class="govuk-button app-c-filter-panel__action app-c-filter-panel__action--submit"
|
|
288
|
+
data-ga4-event={getGa4Event({
|
|
289
|
+
text: applyButtonText,
|
|
290
|
+
section: filterButtonText,
|
|
291
|
+
action: "apply",
|
|
292
|
+
index_section: 0,
|
|
293
|
+
index_section_count: sections.length,
|
|
294
|
+
})}
|
|
295
|
+
data-disable-with={applyButtonText}
|
|
296
|
+
/>
|
|
297
|
+
</div>
|
|
298
|
+
</div>
|
|
299
|
+
{/if}
|
|
300
|
+
</div>
|
|
301
|
+
|
|
302
|
+
<style>
|
|
303
|
+
/* Test comment to see if line 1 error changes */
|
|
304
|
+
.app-c-filter-panel {
|
|
305
|
+
padding-top: 15px;
|
|
306
|
+
margin-bottom: 10px;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.app-c-filter-panel__content {
|
|
310
|
+
background-color: #f3f2f1;
|
|
311
|
+
padding: 0 15px;
|
|
312
|
+
margin-top: 10px;
|
|
313
|
+
margin-bottom: 5px;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.app-c-filter-panel__content .govuk-checkboxes__label::before,
|
|
317
|
+
.app-c-filter-panel__content .govuk-radios__label::before {
|
|
318
|
+
background-color: #fff;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.app-c-filter-panel__header {
|
|
322
|
+
display: flex;
|
|
323
|
+
flex-wrap: wrap;
|
|
324
|
+
place-content: space-between;
|
|
325
|
+
align-items: baseline;
|
|
326
|
+
gap: 10px;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.app-c-filter-panel__count {
|
|
330
|
+
margin: 0;
|
|
331
|
+
color: #505a5f;
|
|
332
|
+
font-family: "GDS Transport", arial, sans-serif;
|
|
333
|
+
-webkit-font-smoothing: antialiased;
|
|
334
|
+
-moz-osx-font-smoothing: grayscale;
|
|
335
|
+
font-weight: 400;
|
|
336
|
+
font-size: 1rem;
|
|
337
|
+
line-height: 1.25;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
@media print {
|
|
341
|
+
.app-c-filter-panel__count {
|
|
342
|
+
font-family: sans-serif;
|
|
343
|
+
font-size: 14pt;
|
|
344
|
+
line-height: 1.2;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.app-c-filter-panel__button {
|
|
349
|
+
background-color: rgba(0, 0, 0, 0);
|
|
350
|
+
color: #1d70b8;
|
|
351
|
+
text-decoration: none;
|
|
352
|
+
border-style: none;
|
|
353
|
+
padding-left: 0;
|
|
354
|
+
cursor: pointer;
|
|
355
|
+
font-family: "GDS Transport", arial, sans-serif;
|
|
356
|
+
-webkit-font-smoothing: antialiased;
|
|
357
|
+
-moz-osx-font-smoothing: grayscale;
|
|
358
|
+
font-weight: 400;
|
|
359
|
+
font-size: 1.1875rem;
|
|
360
|
+
line-height: 1.3157894737;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/* General style for the button's pseudo-element, including margin */
|
|
364
|
+
.app-c-filter-panel__button::before {
|
|
365
|
+
margin: 0 10px 5px 0;
|
|
366
|
+
border-style: solid;
|
|
367
|
+
border-width: 2px 2px 0 0;
|
|
368
|
+
content: "";
|
|
369
|
+
display: inline-block;
|
|
370
|
+
height: 10px;
|
|
371
|
+
left: 5px;
|
|
372
|
+
position: relative;
|
|
373
|
+
vertical-align: middle;
|
|
374
|
+
width: 10px;
|
|
375
|
+
border-color: initial;
|
|
376
|
+
clip-path: unset;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
@media print {
|
|
380
|
+
.app-c-filter-panel__button {
|
|
381
|
+
font-family: sans-serif;
|
|
382
|
+
font-size: 14pt;
|
|
383
|
+
line-height: 1.15;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.app-c-filter-panel__button[aria-expanded="true"]::before {
|
|
388
|
+
/* Down arrow when expanded */
|
|
389
|
+
transform: translateY(30%) rotate(-45deg) scale(1);
|
|
390
|
+
}
|
|
391
|
+
.app-c-filter-panel__button[aria-expanded="false"]::before {
|
|
392
|
+
/* Up/Right arrow when collapsed - to match image */
|
|
393
|
+
transform: translateY(-25%) rotate(135deg) scale(1);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.app-c-filter-panel__button:hover .app-c-filter-panel__button-inner {
|
|
397
|
+
text-decoration: underline;
|
|
398
|
+
text-decoration-thickness: max(1px, 0.0625rem);
|
|
399
|
+
text-underline-offset: 0.1578em;
|
|
400
|
+
text-decoration-thickness: max(3px, 0.1875rem, 0.12em);
|
|
401
|
+
-webkit-text-decoration-skip-ink: none;
|
|
402
|
+
text-decoration-skip-ink: none;
|
|
403
|
+
-webkit-text-decoration-skip: none;
|
|
404
|
+
text-decoration-skip: none;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.app-c-filter-panel__button:focus,
|
|
408
|
+
.app-c-filter-panel__button:focus-visible {
|
|
409
|
+
text-decoration: none;
|
|
410
|
+
text-decoration-thickness: max(3px, 0.1875rem, 0.12em);
|
|
411
|
+
-webkit-text-decoration-skip-ink: none;
|
|
412
|
+
text-decoration-skip-ink: none;
|
|
413
|
+
-webkit-text-decoration-skip: none;
|
|
414
|
+
text-decoration-skip: none;
|
|
415
|
+
outline: 3px solid rgba(0, 0, 0, 0);
|
|
416
|
+
color: #0b0c0c;
|
|
417
|
+
background-color: #fd0;
|
|
418
|
+
box-shadow:
|
|
419
|
+
0 -2px #fd0,
|
|
420
|
+
0 4px #0b0c0c;
|
|
421
|
+
-webkit-box-decoration-break: clone;
|
|
422
|
+
box-decoration-break: clone;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
.app-c-filter-panel__button:focus .app-c-filter-panel__button-inner,
|
|
426
|
+
.app-c-filter-panel__button:focus-visible .app-c-filter-panel__button-inner {
|
|
427
|
+
text-decoration: none;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
.app-c-filter-panel__actions {
|
|
431
|
+
display: flex;
|
|
432
|
+
flex-wrap: wrap;
|
|
433
|
+
align-items: center;
|
|
434
|
+
gap: 15px;
|
|
435
|
+
padding: 20px 0;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
.app-c-filter-panel__action--submit {
|
|
439
|
+
flex: 2 0 60%;
|
|
440
|
+
margin-bottom: 0;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
.app-c-filter-panel__action--reset {
|
|
444
|
+
flex: 1 0 30%;
|
|
445
|
+
white-space: nowrap;
|
|
446
|
+
padding: 5px 0;
|
|
447
|
+
text-align: center;
|
|
448
|
+
font-family: "GDS Transport", arial, sans-serif;
|
|
449
|
+
-webkit-font-smoothing: antialiased;
|
|
450
|
+
-moz-osx-font-smoothing: grayscale;
|
|
451
|
+
font-weight: 400;
|
|
452
|
+
font-size: 1.1875rem;
|
|
453
|
+
line-height: 1.3157894737;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
@media print {
|
|
457
|
+
.app-c-filter-panel__action--reset {
|
|
458
|
+
font-family: sans-serif;
|
|
459
|
+
font-size: 14pt;
|
|
460
|
+
line-height: 1.15;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
.app-c-filter-section {
|
|
464
|
+
border-bottom: 1px solid #b1b4b6;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
.app-c-filter-section:last-child {
|
|
468
|
+
border-bottom: 0;
|
|
469
|
+
margin-bottom: 0;
|
|
470
|
+
padding-bottom: 0;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
.app-c-filter-section:first-child {
|
|
474
|
+
margin-top: 0;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
.app-c-filter-section[open] .app-c-filter-section__summary::before {
|
|
478
|
+
border-style: solid;
|
|
479
|
+
border-width: 2px 2px 0 0;
|
|
480
|
+
content: "";
|
|
481
|
+
display: inline-block;
|
|
482
|
+
height: 10px;
|
|
483
|
+
left: 5px;
|
|
484
|
+
position: relative;
|
|
485
|
+
vertical-align: middle;
|
|
486
|
+
width: 10px;
|
|
487
|
+
border-color: initial;
|
|
488
|
+
clip-path: unset;
|
|
489
|
+
transform: translateY(-25%) rotate(135deg) scale(1);
|
|
490
|
+
transform: translateY(30%) rotate(-45deg) scale(1);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.app-c-filter-section__summary {
|
|
494
|
+
display: flex;
|
|
495
|
+
align-items: center;
|
|
496
|
+
width: 100%;
|
|
497
|
+
cursor: pointer;
|
|
498
|
+
color: #0b0c0c;
|
|
499
|
+
list-style: none;
|
|
500
|
+
padding: 5px 0;
|
|
501
|
+
min-height: 66.5px;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
.app-c-filter-section__summary::before {
|
|
505
|
+
border-style: solid;
|
|
506
|
+
border-width: 2px 2px 0 0;
|
|
507
|
+
content: "";
|
|
508
|
+
display: inline-block;
|
|
509
|
+
height: 10px;
|
|
510
|
+
left: 5px;
|
|
511
|
+
position: relative;
|
|
512
|
+
vertical-align: middle;
|
|
513
|
+
width: 10px;
|
|
514
|
+
border-color: initial;
|
|
515
|
+
clip-path: unset;
|
|
516
|
+
transform: translateY(-25%) rotate(135deg) scale(1);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
.app-c-filter-section__summary::marker,
|
|
520
|
+
.app-c-filter-section__summary::-webkit-details-marker {
|
|
521
|
+
display: none;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
.app-c-filter-section__summary:hover .app-c-filter-section__summary-heading {
|
|
525
|
+
text-decoration: underline;
|
|
526
|
+
text-decoration-thickness: max(1px, 0.0625rem);
|
|
527
|
+
text-underline-offset: 0.1578em;
|
|
528
|
+
text-decoration-thickness: max(3px, 0.1875rem, 0.12em);
|
|
529
|
+
-webkit-text-decoration-skip-ink: none;
|
|
530
|
+
text-decoration-skip-ink: none;
|
|
531
|
+
-webkit-text-decoration-skip: none;
|
|
532
|
+
text-decoration-skip: none;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.app-c-filter-section__summary:focus .app-c-filter-section__summary-heading {
|
|
536
|
+
outline: 3px solid rgba(0, 0, 0, 0);
|
|
537
|
+
color: #0b0c0c;
|
|
538
|
+
background-color: #fd0;
|
|
539
|
+
box-shadow:
|
|
540
|
+
0 -2px #fd0,
|
|
541
|
+
0 4px #0b0c0c;
|
|
542
|
+
text-decoration: none;
|
|
543
|
+
-webkit-box-decoration-break: clone;
|
|
544
|
+
box-decoration-break: clone;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
.app-c-filter-section__summary:focus-visible {
|
|
548
|
+
outline: none;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
.app-c-filter-section__summary-heading {
|
|
552
|
+
margin-left: 15px;
|
|
553
|
+
font-family: "GDS Transport", arial, sans-serif;
|
|
554
|
+
-webkit-font-smoothing: antialiased;
|
|
555
|
+
-moz-osx-font-smoothing: grayscale;
|
|
556
|
+
font-weight: 700;
|
|
557
|
+
font-size: 1.1875rem;
|
|
558
|
+
line-height: 1.3157894737;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
@media print {
|
|
562
|
+
.app-c-filter-section__summary-heading {
|
|
563
|
+
font-family: sans-serif;
|
|
564
|
+
font-size: 14pt;
|
|
565
|
+
line-height: 1.15;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
.app-c-filter-section__summary-status {
|
|
570
|
+
padding-right: 5px;
|
|
571
|
+
flex-grow: 1;
|
|
572
|
+
text-align: right;
|
|
573
|
+
font-family: "GDS Transport", arial, sans-serif;
|
|
574
|
+
-webkit-font-smoothing: antialiased;
|
|
575
|
+
-moz-osx-font-smoothing: grayscale;
|
|
576
|
+
font-weight: 400;
|
|
577
|
+
font-size: 1rem;
|
|
578
|
+
line-height: 1.25;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
@media print {
|
|
582
|
+
.app-c-filter-section__summary-status {
|
|
583
|
+
font-family: sans-serif;
|
|
584
|
+
font-size: 14pt;
|
|
585
|
+
line-height: 1.2;
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
</style>
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
interface FilterOption {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
id?: string;
|
|
5
|
+
checked?: boolean;
|
|
6
|
+
}
|
|
7
|
+
interface BaseSection {
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
ga4Section: string;
|
|
11
|
+
ga4IndexSection: number;
|
|
12
|
+
ga4IndexSectionCount: number;
|
|
13
|
+
openByDefault?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface RadioSection extends BaseSection {
|
|
16
|
+
type: string;
|
|
17
|
+
name: string;
|
|
18
|
+
legend: string;
|
|
19
|
+
options: FilterOption[];
|
|
20
|
+
selectedValue?: string;
|
|
21
|
+
}
|
|
22
|
+
interface DateSection extends BaseSection {
|
|
23
|
+
type: string;
|
|
24
|
+
fromLegend: string;
|
|
25
|
+
fromNamePrefix: string;
|
|
26
|
+
fromHint?: string;
|
|
27
|
+
fromInitialValue?: {
|
|
28
|
+
day?: string;
|
|
29
|
+
month?: string;
|
|
30
|
+
year?: string;
|
|
31
|
+
};
|
|
32
|
+
toLegend: string;
|
|
33
|
+
toNamePrefix: string;
|
|
34
|
+
toHint?: string;
|
|
35
|
+
toInitialValue?: {
|
|
36
|
+
day?: string;
|
|
37
|
+
month?: string;
|
|
38
|
+
year?: string;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
interface SelectOption extends FilterOption {
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
}
|
|
44
|
+
interface SelectField {
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
label: string;
|
|
48
|
+
options: SelectOption[];
|
|
49
|
+
value?: string;
|
|
50
|
+
fullWidth?: boolean;
|
|
51
|
+
disabled?: boolean;
|
|
52
|
+
}
|
|
53
|
+
interface SelectSection extends BaseSection {
|
|
54
|
+
type: string;
|
|
55
|
+
selects: SelectField[];
|
|
56
|
+
}
|
|
57
|
+
interface CheckboxSection extends BaseSection {
|
|
58
|
+
type: string;
|
|
59
|
+
name: string;
|
|
60
|
+
legend: string;
|
|
61
|
+
options: FilterOption[];
|
|
62
|
+
selectedValues?: string[];
|
|
63
|
+
}
|
|
64
|
+
type Section = RadioSection | DateSection | SelectSection | CheckboxSection;
|
|
65
|
+
type $$ComponentProps = {
|
|
66
|
+
resultsCount?: string;
|
|
67
|
+
sectionsData?: Section[];
|
|
68
|
+
filterButtonText?: string;
|
|
69
|
+
applyButtonText?: string;
|
|
70
|
+
ga4BaseEvent?: Record<string, any>;
|
|
71
|
+
};
|
|
72
|
+
declare const FilterPanel: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
73
|
+
type FilterPanel = ReturnType<typeof FilterPanel>;
|
|
74
|
+
export default FilterPanel;
|