@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.
Files changed (217) hide show
  1. package/README.md +188 -0
  2. package/dist/assets/css/govuk-frontend.min.css +2 -0
  3. package/dist/assets/css/govuk-frontend.min.css.map +1 -0
  4. package/dist/assets/fonts/bold-affa96571d-v2.woff +0 -0
  5. package/dist/assets/fonts/bold-b542beb274-v2.woff2 +0 -0
  6. package/dist/assets/fonts/light-94a07e06a1-v2.woff2 +0 -0
  7. package/dist/assets/fonts/light-f591b13f7d-v2.woff +0 -0
  8. package/dist/assets/govuk_publishing_components/images/icon-autocomplete-search-suggestion.svg +4 -0
  9. package/dist/assets/govuk_publishing_components/images/icon-close.svg +1 -0
  10. package/dist/assets/images/favicon.ico +0 -0
  11. package/dist/assets/images/favicon.svg +1 -0
  12. package/dist/assets/images/govuk-crest-2x.png +0 -0
  13. package/dist/assets/images/govuk-crest.png +0 -0
  14. package/dist/assets/images/govuk-crest.svg +1 -0
  15. package/dist/assets/images/govuk-icon-180.png +0 -0
  16. package/dist/assets/images/govuk-icon-192.png +0 -0
  17. package/dist/assets/images/govuk-icon-512.png +0 -0
  18. package/dist/assets/images/govuk-icon-mask.svg +1 -0
  19. package/dist/assets/images/govuk-opengraph-image.png +0 -0
  20. package/dist/assets/images/homepage-illustration.svg +1 -0
  21. package/dist/assets/images/homepage.svg +44 -0
  22. package/dist/assets/images/masthead-illustration.svg +123 -0
  23. package/dist/assets/images/oflog_crest_black.png +0 -0
  24. package/dist/assets/images/oflog_crest_white.png +0 -0
  25. package/dist/assets/images/undraw_approved-wireframe_odf4.svg +1 -0
  26. package/dist/assets/images/undraw_collaborators_rgw4.svg +1 -0
  27. package/dist/assets/images/undraw_content-creator_vuqg.svg +1 -0
  28. package/dist/assets/images/undraw_online-media_opxh.svg +1 -0
  29. package/dist/assets/images/undraw_pull-request_zlsu.svg +1 -0
  30. package/dist/assets/images/undraw_reviewed-docs_g0cg.svg +1 -0
  31. package/dist/components/FilterPanel/codeBlocks.d.ts +3 -0
  32. package/dist/components/FilterPanel/codeBlocks.js +418 -0
  33. package/dist/components/content/InsetText.svelte +21 -0
  34. package/dist/components/content/InsetText.svelte.d.ts +7 -0
  35. package/dist/components/content/WarningText.svelte +27 -0
  36. package/dist/components/content/WarningText.svelte.d.ts +8 -0
  37. package/dist/components/data-vis/axis/Axis.svelte +51 -0
  38. package/dist/components/data-vis/axis/Axis.svelte.d.ts +33 -0
  39. package/dist/components/data-vis/axis/Ticks.svelte +113 -0
  40. package/dist/components/data-vis/axis/Ticks.svelte.d.ts +33 -0
  41. package/dist/components/data-vis/line-chart/Line.svelte +150 -0
  42. package/dist/components/data-vis/line-chart/Line.svelte.d.ts +85 -0
  43. package/dist/components/data-vis/line-chart/LineChart.svelte +249 -0
  44. package/dist/components/data-vis/line-chart/LineChart.svelte.d.ts +73 -0
  45. package/dist/components/data-vis/line-chart/Lines.svelte +138 -0
  46. package/dist/components/data-vis/line-chart/Lines.svelte.d.ts +57 -0
  47. package/dist/components/data-vis/line-chart/Marker.svelte +61 -0
  48. package/dist/components/data-vis/line-chart/Marker.svelte.d.ts +37 -0
  49. package/dist/components/data-vis/line-chart/SeriesLabel.svelte +67 -0
  50. package/dist/components/data-vis/line-chart/SeriesLabel.svelte.d.ts +43 -0
  51. package/dist/components/data-vis/line-chart/ValueLabel.svelte +50 -0
  52. package/dist/components/data-vis/line-chart/ValueLabel.svelte.d.ts +25 -0
  53. package/dist/components/data-vis/map/Map.svelte +392 -0
  54. package/dist/components/data-vis/map/Map.svelte.d.ts +47 -0
  55. package/dist/components/data-vis/map/MapLegend.svelte +41 -0
  56. package/dist/components/data-vis/map/MapLegend.svelte.d.ts +15 -0
  57. package/dist/components/data-vis/map/NonStandardControls.svelte +42 -0
  58. package/dist/components/data-vis/map/NonStandardControls.svelte.d.ts +13 -0
  59. package/dist/components/data-vis/map/Tooltip.svelte +41 -0
  60. package/dist/components/data-vis/map/Tooltip.svelte.d.ts +19 -0
  61. package/dist/components/data-vis/map/colorbrewer.d.ts +337 -0
  62. package/dist/components/data-vis/map/colorbrewer.js +1523 -0
  63. package/dist/components/data-vis/map/colors.d.ts +13 -0
  64. package/dist/components/data-vis/map/colors.js +65 -0
  65. package/dist/components/data-vis/map/dataJoin.d.ts +2 -0
  66. package/dist/components/data-vis/map/dataJoin.js +27 -0
  67. package/dist/components/data-vis/map/fullTopo.json +1 -0
  68. package/dist/components/data-vis/map/jenks.d.ts +1 -0
  69. package/dist/components/data-vis/map/jenks.js +51 -0
  70. package/dist/components/data-vis/map/lad2023.json +1 -0
  71. package/dist/components/data-vis/map/mapUtils.d.ts +5 -0
  72. package/dist/components/data-vis/map/mapUtils.js +86 -0
  73. package/dist/components/data-vis/map/topo.json +1 -0
  74. package/dist/components/data-vis/table/Table.svelte +247 -0
  75. package/dist/components/data-vis/table/Table.svelte.d.ts +19 -0
  76. package/dist/components/layout/Breadcrumbs.svelte +191 -0
  77. package/dist/components/layout/Breadcrumbs.svelte.d.ts +24 -0
  78. package/dist/components/layout/Footer.svelte +171 -0
  79. package/dist/components/layout/Footer.svelte.d.ts +30 -0
  80. package/dist/components/layout/Header.svelte +43 -0
  81. package/dist/components/layout/Header.svelte.d.ts +7 -0
  82. package/dist/components/layout/InternalHeader.svelte +628 -0
  83. package/dist/components/layout/InternalHeader.svelte.d.ts +15 -0
  84. package/dist/components/layout/PhaseBanner.svelte +28 -0
  85. package/dist/components/layout/PhaseBanner.svelte.d.ts +9 -0
  86. package/dist/components/layout/ServiceNavigation.svelte +143 -0
  87. package/dist/components/layout/ServiceNavigation.svelte.d.ts +13 -0
  88. package/dist/components/layout/SideNavigation.svelte +345 -0
  89. package/dist/components/layout/SideNavigation.svelte.d.ts +25 -0
  90. package/dist/components/layout/service-navigation-nested-mobile/HeaderNav.svelte +91 -0
  91. package/dist/components/layout/service-navigation-nested-mobile/HeaderNav.svelte.d.ts +15 -0
  92. package/dist/components/layout/service-navigation-nested-mobile/MobileNav.svelte +233 -0
  93. package/dist/components/layout/service-navigation-nested-mobile/MobileNav.svelte.d.ts +27 -0
  94. package/dist/components/layout/service-navigation-nested-mobile/ServiceNavigationNestedMobile.svelte +70 -0
  95. package/dist/components/layout/service-navigation-nested-mobile/ServiceNavigationNestedMobile.svelte.d.ts +11 -0
  96. package/dist/components/layout/service-navigation-nested-mobile/SideNav.svelte +276 -0
  97. package/dist/components/layout/service-navigation-nested-mobile/SideNav.svelte.d.ts +22 -0
  98. package/dist/components/ui/Accordion.svelte +244 -0
  99. package/dist/components/ui/Accordion.svelte.d.ts +23 -0
  100. package/dist/components/ui/Breadcrumbs.svelte +198 -0
  101. package/dist/components/ui/Breadcrumbs.svelte.d.ts +24 -0
  102. package/dist/components/ui/Button.svelte +96 -0
  103. package/dist/components/ui/Button.svelte.d.ts +17 -0
  104. package/dist/components/ui/CheckBox.svelte +198 -0
  105. package/dist/components/ui/CheckBox.svelte.d.ts +27 -0
  106. package/dist/components/ui/ContentsList.svelte +1117 -0
  107. package/dist/components/ui/ContentsList.svelte.d.ts +25 -0
  108. package/dist/components/ui/DateInput.svelte +255 -0
  109. package/dist/components/ui/DateInput.svelte.d.ts +59 -0
  110. package/dist/components/ui/Details.svelte +12 -0
  111. package/dist/components/ui/Details.svelte.d.ts +13 -0
  112. package/dist/components/ui/FilterPanel.svelte +588 -0
  113. package/dist/components/ui/FilterPanel.svelte.d.ts +74 -0
  114. package/dist/components/ui/Footer.svelte +171 -0
  115. package/dist/components/ui/Footer.svelte.d.ts +30 -0
  116. package/dist/components/ui/Header.svelte +43 -0
  117. package/dist/components/ui/Header.svelte.d.ts +7 -0
  118. package/dist/components/ui/Masthead.svelte +267 -0
  119. package/dist/components/ui/Masthead.svelte.d.ts +12 -0
  120. package/dist/components/ui/NavigationExample.svelte +117 -0
  121. package/dist/components/ui/NavigationExample.svelte.d.ts +3 -0
  122. package/dist/components/ui/NotificationBanner.svelte +93 -0
  123. package/dist/components/ui/NotificationBanner.svelte.d.ts +15 -0
  124. package/dist/components/ui/Radios.svelte +176 -0
  125. package/dist/components/ui/Radios.svelte.d.ts +28 -0
  126. package/dist/components/ui/RelatedContent.svelte +596 -0
  127. package/dist/components/ui/RelatedContent.svelte.d.ts +29 -0
  128. package/dist/components/ui/Search.svelte +499 -0
  129. package/dist/components/ui/Search.svelte.d.ts +32 -0
  130. package/dist/components/ui/SearchAutocomplete.svelte +655 -0
  131. package/dist/components/ui/SearchAutocomplete.svelte.d.ts +37 -0
  132. package/dist/components/ui/Select.svelte +116 -0
  133. package/dist/components/ui/Select.svelte.d.ts +22 -0
  134. package/dist/components/ui/ServiceNavigation.svelte +143 -0
  135. package/dist/components/ui/ServiceNavigation.svelte.d.ts +13 -0
  136. package/dist/components/ui/SideNavigation.svelte +346 -0
  137. package/dist/components/ui/SideNavigation.svelte.d.ts +25 -0
  138. package/dist/components/ui/Tabs.svelte +306 -0
  139. package/dist/components/ui/Tabs.svelte.d.ts +18 -0
  140. package/dist/components/ui/WhatsNew.svelte +155 -0
  141. package/dist/components/ui/WhatsNew.svelte.d.ts +29 -0
  142. package/dist/config.d.ts +51 -0
  143. package/dist/config.js +44 -0
  144. package/dist/icons/DoubleChevronButton.svelte +62 -0
  145. package/dist/icons/DoubleChevronButton.svelte.d.ts +13 -0
  146. package/dist/icons/IconSearch.svelte +42 -0
  147. package/dist/icons/IconSearch.svelte.d.ts +6 -0
  148. package/dist/icons/SingleChevronButtonWithLabel.svelte +132 -0
  149. package/dist/icons/SingleChevronButtonWithLabel.svelte.d.ts +19 -0
  150. package/dist/index.d.ts +44 -0
  151. package/dist/index.js +45 -0
  152. package/dist/main.css +1 -0
  153. package/dist/package-wrapping/BaseInformation.svelte +82 -0
  154. package/dist/package-wrapping/BaseInformation.svelte.d.ts +15 -0
  155. package/dist/package-wrapping/BaseNameAndStatus.svelte +108 -0
  156. package/dist/package-wrapping/BaseNameAndStatus.svelte.d.ts +10 -0
  157. package/dist/package-wrapping/CodeBlock.svelte +62 -0
  158. package/dist/package-wrapping/CodeBlock.svelte.d.ts +12 -0
  159. package/dist/package-wrapping/ComponentDemo.svelte +114 -0
  160. package/dist/package-wrapping/ComponentDemo.svelte.d.ts +25 -0
  161. package/dist/package-wrapping/ComponentDemoTEMP.svelte +305 -0
  162. package/dist/package-wrapping/ComponentDemoTEMP.svelte.d.ts +21 -0
  163. package/dist/package-wrapping/ComponentDetails.svelte +123 -0
  164. package/dist/package-wrapping/ComponentDetails.svelte.d.ts +13 -0
  165. package/dist/package-wrapping/DividerLine.svelte +21 -0
  166. package/dist/package-wrapping/DividerLine.svelte.d.ts +17 -0
  167. package/dist/package-wrapping/InputForParameter.svelte +205 -0
  168. package/dist/package-wrapping/InputForParameter.svelte.d.ts +13 -0
  169. package/dist/package-wrapping/InputForParameterUpdated.svelte +222 -0
  170. package/dist/package-wrapping/InputForParameterUpdated.svelte.d.ts +17 -0
  171. package/dist/package-wrapping/InputForParameterUpdatedTEMP.svelte +203 -0
  172. package/dist/package-wrapping/InputForParameterUpdatedTEMP.svelte.d.ts +17 -0
  173. package/dist/package-wrapping/ListOfComponentStatuses.svelte +19 -0
  174. package/dist/package-wrapping/ListOfComponentStatuses.svelte.d.ts +11 -0
  175. package/dist/package-wrapping/OverlayAndComponentContainer.svelte +426 -0
  176. package/dist/package-wrapping/OverlayAndComponentContainer.svelte.d.ts +33 -0
  177. package/dist/package-wrapping/ParametersSection.svelte +235 -0
  178. package/dist/package-wrapping/ParametersSection.svelte.d.ts +19 -0
  179. package/dist/package-wrapping/ParsingErrorToastsContainer.svelte +50 -0
  180. package/dist/package-wrapping/ParsingErrorToastsContainer.svelte.d.ts +15 -0
  181. package/dist/package-wrapping/Pill.svelte +54 -0
  182. package/dist/package-wrapping/Pill.svelte.d.ts +25 -0
  183. package/dist/package-wrapping/PlaygroundDetails.svelte +106 -0
  184. package/dist/package-wrapping/PlaygroundDetails.svelte.d.ts +13 -0
  185. package/dist/package-wrapping/ScreenSizeRadio.svelte +24 -0
  186. package/dist/package-wrapping/ScreenSizeRadio.svelte.d.ts +11 -0
  187. package/dist/package-wrapping/ScreenSizeRadioUpdated.svelte +23 -0
  188. package/dist/package-wrapping/ScreenSizeRadioUpdated.svelte.d.ts +11 -0
  189. package/dist/package-wrapping/SidebarContainer.svelte +103 -0
  190. package/dist/package-wrapping/SidebarContainer.svelte.d.ts +23 -0
  191. package/dist/package-wrapping/WrapperDetailsUpdate.svelte +40 -0
  192. package/dist/package-wrapping/WrapperDetailsUpdate.svelte.d.ts +15 -0
  193. package/dist/package-wrapping/templates/Template.svelte +100 -0
  194. package/dist/package-wrapping/templates/Template.svelte.d.ts +25 -0
  195. package/dist/templates/ComponentPageTemplate.svelte +1 -0
  196. package/dist/templates/ComponentPageTemplate.svelte.d.ts +26 -0
  197. package/dist/utils/data-transformations/convertCSV.d.ts +2 -0
  198. package/dist/utils/data-transformations/convertCSV.js +22 -0
  199. package/dist/utils/data-transformations/getValueFromParametersArray.d.ts +1 -0
  200. package/dist/utils/data-transformations/getValueFromParametersArray.js +9 -0
  201. package/dist/utils/layoutNavHelpers.d.ts +70 -0
  202. package/dist/utils/layoutNavHelpers.js +129 -0
  203. package/dist/utils/package-wrapping-specific/addIndexAndInitialValue.d.ts +1 -0
  204. package/dist/utils/package-wrapping-specific/addIndexAndInitialValue.js +21 -0
  205. package/dist/utils/package-wrapping-specific/createBindableParametersValuesArray.d.ts +1 -0
  206. package/dist/utils/package-wrapping-specific/createBindableParametersValuesArray.js +12 -0
  207. package/dist/utils/package-wrapping-specific/createParametersObject.d.ts +1 -0
  208. package/dist/utils/package-wrapping-specific/createParametersObject.js +29 -0
  209. package/dist/utils/package-wrapping-specific/defineDefaultEventHandler.d.ts +1 -0
  210. package/dist/utils/package-wrapping-specific/defineDefaultEventHandler.js +14 -0
  211. package/dist/utils/package-wrapping-specific/trackVisibleParameters.d.ts +1 -0
  212. package/dist/utils/package-wrapping-specific/trackVisibleParameters.js +29 -0
  213. package/dist/utils/syntax-highlighting/shikiHighlight.d.ts +7 -0
  214. package/dist/utils/syntax-highlighting/shikiHighlight.js +76 -0
  215. package/dist/utils/text-string-conversion/textStringConversion.d.ts +9 -0
  216. package/dist/utils/text-string-conversion/textStringConversion.js +86 -0
  217. package/package.json +113 -0
@@ -0,0 +1,499 @@
1
+ <script lang="ts">
2
+ import { clsx } from "clsx";
3
+ import { browser } from "$app/environment";
4
+ import { onMount } from "svelte";
5
+ import IconSearch from "../../icons/IconSearch.svelte";
6
+ import closeIconUrl from "../../assets/govuk_publishing_components/images/icon-close.svg?url";
7
+
8
+ // SSR-safe HTML sanitizer: no-op on server
9
+ let sanitize = $state<(html: string) => string>((html) => html);
10
+
11
+ // Hook up DOMPurify sanitize in browser
12
+ onMount(async () => {
13
+ if (browser) {
14
+ const DOMPurify = (await import("dompurify")).default;
15
+ sanitize = DOMPurify.sanitize;
16
+ }
17
+ });
18
+
19
+ // Define the props based on GOV.UK documentation
20
+ type Props = {
21
+ value?: string; // Initial input value
22
+ label_text?: string; // Text for the label
23
+ label_id?: string; // ID for the input, connects label
24
+ inline_label?: boolean; // Label appears inline (default depends on label_size)
25
+ hint?: string; // Add hint prop
26
+ on_govuk_blue?: boolean; // Style for blue background
27
+ homepage?: boolean; // Style for homepage use
28
+ size?: "large" | ""; // Size variation
29
+ name?: string; // Name attribute for input
30
+ aria_controls?: string; // ID of controlled element
31
+ button_text?: string; // Visually hidden button text
32
+ label_size?: "xl" | "l" | "m" | "s" | "" | null; // Add "" to the type
33
+ wrap_label_in_a_heading?: boolean; // Wrap label in heading
34
+ heading_level?: 1 | 2 | 3 | 4 | 5 | 6; // Heading level
35
+ margin_bottom?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; // Component margin
36
+ label_margin_bottom?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined; // Label margin
37
+ label_custom_class?: string; // Custom class for label
38
+ disable_corrections?: boolean; // Disable mobile autocorrect/caps
39
+ input_width?:
40
+ | "full"
41
+ | "three-quarters"
42
+ | "two-thirds"
43
+ | "one-half"
44
+ | "one-third"
45
+ | "one-quarter"
46
+ | ""
47
+ | null; // GOV.UK input width class
48
+ // Standard wrapper props
49
+ id?: string;
50
+ classes?: string;
51
+ dataAttributes?: Record<string, string>;
52
+ aria?: Record<string, string>;
53
+ role?: string;
54
+ lang?: string;
55
+ dir?: "rtl" | "ltr" | "auto";
56
+ button_background_color?: string; // Add prop for custom button bg
57
+ };
58
+
59
+ // --- Prop Defaults & Processing ---
60
+ let {
61
+ value = $bindable(""), // Make value bindable
62
+ label_text = "Search on GOV.UK",
63
+ label_id = undefined,
64
+ inline_label = undefined, // Default depends on label_size
65
+ hint = undefined, // Add hint default
66
+ on_govuk_blue = false,
67
+ homepage = false,
68
+ size = "",
69
+ name = "q",
70
+ aria_controls = undefined,
71
+ button_text = "Search",
72
+ label_size = null,
73
+ wrap_label_in_a_heading = false,
74
+ heading_level = 2,
75
+ margin_bottom = 6, // Matching default in Ruby template
76
+ label_margin_bottom = undefined,
77
+ label_custom_class = undefined,
78
+ disable_corrections = false,
79
+ input_width = null, // Add default for input_width
80
+ id = undefined,
81
+ classes = "",
82
+ dataAttributes = {},
83
+ aria = {},
84
+ role = undefined,
85
+ lang = undefined,
86
+ dir = undefined,
87
+ button_background_color = undefined, // Add default
88
+ }: Props = $props();
89
+
90
+ // Generate default ID if none provided (only in browser)
91
+ const defaultId = $derived(
92
+ label_id ||
93
+ (browser
94
+ ? `search-main-${crypto.randomUUID().slice(0, 8)}`
95
+ : "search-main-ssr"),
96
+ );
97
+
98
+ // Determine if label should be inline
99
+ // If label_size is set, force isInlineLabel = false
100
+ // Otherwise, respect inline_label if set to false, default to true
101
+ const isInlineLabel = $derived(
102
+ label_size
103
+ ? false // If label_size is set, it's NOT inline
104
+ : inline_label === false
105
+ ? false // If no size, but explicitly set to false, it's NOT inline
106
+ : true, // Otherwise (no size, inline_label is true or undefined), it IS inline
107
+ );
108
+
109
+ // --- Derived Classes & Attributes ---
110
+ const correctionValue = $derived(disable_corrections ? "off" : undefined);
111
+
112
+ const wrapperClasses = $derived(
113
+ clsx(
114
+ "gem-c-search",
115
+ "govuk-!-display-none-print",
116
+ input_width && `govuk-!-width-${input_width}`, // Apply width class to the wrapper
117
+ `govuk-!-margin-bottom-${margin_bottom}`,
118
+ size === "large" && "gem-c-search--large",
119
+ homepage && "gem-c-search--homepage",
120
+ on_govuk_blue || homepage
121
+ ? "gem-c-search--on-govuk-blue"
122
+ : "gem-c-search--on-white",
123
+ !isInlineLabel && "gem-c-search--separate-label",
124
+ classes,
125
+ ),
126
+ );
127
+
128
+ const derivedLabelClasses = $derived(
129
+ clsx(
130
+ label_custom_class
131
+ ? label_custom_class // If custom class, use it...
132
+ : [
133
+ // Otherwise calculate standard classes:
134
+ isInlineLabel ? "gem-c-search__label" : "govuk-label", // Base class depends on inline status
135
+ !isInlineLabel && label_size ? `govuk-label--${label_size}` : null, // Size modifier only if separate and size set
136
+ (!isInlineLabel && on_govuk_blue) || homepage
137
+ ? "gem-c-search__label--white"
138
+ : null, // White text only if separate and on blue
139
+ ],
140
+ // Margin applies if NOT inline, regardless of custom class
141
+ !isInlineLabel &&
142
+ label_margin_bottom !== undefined &&
143
+ label_margin_bottom >= 0 &&
144
+ label_margin_bottom <= 9 &&
145
+ `govuk-!-margin-bottom-${label_margin_bottom}`,
146
+ ),
147
+ );
148
+
149
+ const inputClasses = $derived(
150
+ clsx(
151
+ "gem-c-search__item",
152
+ "gem-c-search__input",
153
+ "js-class-toggle", // Assumed for JS interaction, kept from Ruby template
154
+ ),
155
+ );
156
+
157
+ const buttonClasses = $derived(clsx("gem-c-search__submit"));
158
+
159
+ const wrapperDataAttrs = $derived({
160
+ module: "gem-toggle-input-class-on-focus", // Kept from Ruby template
161
+ ...dataAttributes,
162
+ });
163
+
164
+ // --- Render Logic ---
165
+ // Define Tag based on heading_level
166
+ const Tag = $derived(`h${heading_level}`);
167
+ </script>
168
+
169
+ {#snippet LabelContent()}
170
+ <label for={defaultId} class={derivedLabelClasses}>
171
+ {@html sanitize(label_text)}
172
+ </label>
173
+ {/snippet}
174
+
175
+ <div
176
+ class={wrapperClasses}
177
+ {id}
178
+ data-module={wrapperDataAttrs.module}
179
+ {...aria}
180
+ {...dataAttributes}
181
+ {role}
182
+ {lang}
183
+ {dir}
184
+ >
185
+ {#if wrap_label_in_a_heading}
186
+ <svelte:element this={Tag} class="govuk-!-margin-0">
187
+ {@render LabelContent()}
188
+ </svelte:element>
189
+ {:else}
190
+ {@render LabelContent()}
191
+ {/if}
192
+
193
+ {#if hint && !isInlineLabel && !(homepage || on_govuk_blue)}
194
+ <div id="{defaultId}-hint" class="govuk-hint">
195
+ {hint}
196
+ </div>
197
+ {/if}
198
+
199
+ <div class="gem-c-search__item-wrapper">
200
+ <div class="js-search-input-wrapper">
201
+ <input
202
+ aria-controls={aria_controls}
203
+ enterkeyhint="search"
204
+ class={inputClasses}
205
+ id={defaultId}
206
+ {name}
207
+ title="Search"
208
+ type="search"
209
+ placeholder={hint && !isInlineLabel && (homepage || on_govuk_blue)
210
+ ? hint
211
+ : undefined}
212
+ bind:value
213
+ aria-describedby={hint
214
+ ? `${defaultId}-hint`
215
+ : label_text
216
+ ? `${defaultId}-label`
217
+ : undefined}
218
+ autocorrect={correctionValue}
219
+ autocapitalize={correctionValue}
220
+ style={`--cancel-icon: url("${closeIconUrl}")`}
221
+ />
222
+ </div>
223
+ <div class="gem-c-search__item gem-c-search__submit-wrapper">
224
+ <button
225
+ class={buttonClasses}
226
+ type="submit"
227
+ enterkeyhint="search"
228
+ style={button_background_color && !on_govuk_blue && !homepage
229
+ ? `background-color: ${button_background_color};`
230
+ : undefined}
231
+ >
232
+ <span class="govuk-visually-hidden">{button_text}</span>
233
+ <IconSearch class="gem-c-search__icon" />
234
+ </button>
235
+ </div>
236
+ </div>
237
+ </div>
238
+
239
+ <style>
240
+ .gem-c-search {
241
+ position: relative;
242
+ }
243
+
244
+ .gem-c-search__label {
245
+ display: block;
246
+ color: #0b0c0c;
247
+ cursor: text;
248
+ text-overflow: ellipsis;
249
+ height: 90%;
250
+ overflow: hidden;
251
+ white-space: nowrap;
252
+ font-family: "GDS Transport", arial, sans-serif;
253
+ -webkit-font-smoothing: antialiased;
254
+ -moz-osx-font-smoothing: grayscale;
255
+ font-weight: 400;
256
+ font-size: 1.1875rem;
257
+ line-height: 2.1052631579;
258
+ }
259
+
260
+ @media print {
261
+ .gem-c-search__label {
262
+ font-family: sans-serif;
263
+ font-size: 14pt;
264
+ line-height: 40px;
265
+ }
266
+ }
267
+
268
+ .gem-c-search__label h1 {
269
+ margin: 0;
270
+ font-family: "GDS Transport", arial, sans-serif;
271
+ -webkit-font-smoothing: antialiased;
272
+ -moz-osx-font-smoothing: grayscale;
273
+ font-weight: 400;
274
+ font-size: 1.1875rem;
275
+ line-height: 2.1052631579;
276
+ }
277
+
278
+ @media print {
279
+ .gem-c-search__label h1 {
280
+ font-family: sans-serif;
281
+ font-size: 14pt;
282
+ line-height: 40px;
283
+ }
284
+ }
285
+
286
+ /* Apply :global() to the external .govuk-frontend-supported class as it's not scoped to the component */
287
+ :global(.govuk-frontend-supported) .gem-c-search__label {
288
+ position: absolute;
289
+ left: 2px;
290
+ top: 2px;
291
+ bottom: 2px;
292
+ max-width: 68%;
293
+ padding-left: 15px;
294
+ z-index: 1;
295
+ color: #505a5f;
296
+ background: #fff;
297
+ }
298
+
299
+ /* Apply :global() to the external .govuk-frontend-supported class as it's not scoped to the component */
300
+ :global(.govuk-frontend-supported)
301
+ .gem-c-search--separate-label
302
+ .gem-c-search__label {
303
+ color: #0b0c0c;
304
+ }
305
+
306
+ /* REMOVED :global() - Restore original scoped rule */
307
+ .gem-c-search__input[type="search"] {
308
+ margin: 0;
309
+ width: 100%;
310
+ height: 2.1052631579em;
311
+ padding: 0.3157894737em;
312
+ border: 2px solid #0b0c0c;
313
+ background: #fff;
314
+ border-radius: 0;
315
+ box-sizing: border-box;
316
+ -webkit-appearance: none;
317
+ -moz-appearance: none;
318
+ appearance: none;
319
+ font-family: "GDS Transport", arial, sans-serif;
320
+ -webkit-font-smoothing: antialiased;
321
+ -moz-osx-font-smoothing: grayscale;
322
+ font-weight: 400;
323
+ font-size: 1.1875rem;
324
+ line-height: 1.4736842105;
325
+ }
326
+
327
+ @media print {
328
+ .gem-c-search__input[type="search"] {
329
+ font-family: sans-serif;
330
+ font-size: 14pt;
331
+ line-height: 1.4736842105;
332
+ }
333
+ }
334
+
335
+ .gem-c-search__input[type="search"]:focus,
336
+ .gem-c-search__input[type="search"].focus {
337
+ z-index: 2;
338
+ }
339
+
340
+ .gem-c-search__input[type="search"]:focus {
341
+ outline: 3px solid #fd0;
342
+ outline-offset: 0;
343
+ box-shadow: inset 0 0 0 2px;
344
+ }
345
+
346
+ .gem-c-search__input[type="search"]::-webkit-search-cancel-button {
347
+ -webkit-appearance: none;
348
+ background-image: var(--cancel-icon);
349
+ background-position: center;
350
+ background-repeat: no-repeat;
351
+ cursor: pointer;
352
+ height: 20px;
353
+ margin-left: 0;
354
+ margin-right: 0;
355
+ width: 20px;
356
+ }
357
+
358
+ .gem-c-search__submit {
359
+ border: 0;
360
+ cursor: pointer;
361
+ border-radius: 0;
362
+ outline: 2px solid rgba(0, 0, 0, 0);
363
+ outline-offset: 0;
364
+ position: relative;
365
+ padding: 0;
366
+ width: 40px;
367
+ height: 40px;
368
+ text-indent: -5000px;
369
+ overflow: hidden;
370
+ }
371
+
372
+ .gem-c-search__submit:focus {
373
+ z-index: 2;
374
+ outline: 3px solid #fd0;
375
+ box-shadow: inset 0 0 0 4px #0b0c0c;
376
+ }
377
+
378
+ .gem-c-search__submit::-moz-focus-inner {
379
+ border: 0;
380
+ }
381
+
382
+ .gem-c-search__item-wrapper {
383
+ display: table;
384
+ width: 100%;
385
+ background: #fff;
386
+ /* Override inherited line-height from global styles (currently from govuk-frontend) */
387
+ /* that can cause incorrect height calculation in table display which was causing the wrapper to be too tall */
388
+ line-height: 0;
389
+ }
390
+
391
+ .gem-c-search__item {
392
+ position: relative;
393
+ display: table-cell;
394
+ vertical-align: top;
395
+ }
396
+
397
+ .gem-c-search__submit-wrapper {
398
+ width: 1%;
399
+ }
400
+
401
+ .gem-c-search--on-govuk-blue .gem-c-search__label {
402
+ color: #fff;
403
+ }
404
+
405
+ .gem-c-search--on-govuk-blue .gem-c-search__input {
406
+ border-width: 0;
407
+ outline: 2px solid rgba(0, 0, 0, 0);
408
+ outline-offset: 0;
409
+ }
410
+
411
+ .gem-c-search--on-govuk-blue .gem-c-search__input:focus {
412
+ outline: 3px solid #fd0;
413
+ outline-offset: 0;
414
+ box-shadow: inset 0 0 0 2px;
415
+ box-shadow: inset 0 0 0 4px;
416
+ }
417
+
418
+ .gem-c-search--on-govuk-blue .gem-c-search__submit {
419
+ background-color: #0b0c0c;
420
+ color: #fff;
421
+ }
422
+
423
+ .gem-c-search--on-govuk-blue .gem-c-search__submit:hover {
424
+ background-color: hsl(180, 4.347826087%, 9.5098039216%);
425
+ }
426
+
427
+ :global(.govuk-frontend-supported)
428
+ .gem-c-search--on-govuk-blue
429
+ .gem-c-search__label {
430
+ color: #505a5f;
431
+ }
432
+
433
+ .gem-c-search--homepage .gem-c-search__submit {
434
+ background-color: #d2e2f1;
435
+ color: #1d70b8;
436
+ }
437
+
438
+ .gem-c-search--homepage .gem-c-search__submit:hover {
439
+ background-color: hsl(209.0322580645, 52.5423728814%, 93.431372549%);
440
+ }
441
+
442
+ .gem-c-search--on-white .gem-c-search__submit {
443
+ background-color: #1d70b8;
444
+ color: #fff;
445
+ }
446
+
447
+ .gem-c-search--on-white .gem-c-search__submit:hover {
448
+ background-color: rgb(32.4718309859, 125.4084507042, 206.0281690141);
449
+ }
450
+
451
+ .gem-c-search--on-white .gem-c-search__input[type="search"] {
452
+ border-right-width: 0;
453
+ }
454
+
455
+ .gem-c-search--on-white .gem-c-search__input[type="search"]:focus {
456
+ border-right-width: 2px;
457
+ }
458
+
459
+ .govuk-label.gem-c-search__label--white {
460
+ color: #fff;
461
+ }
462
+
463
+ .gem-c-search--large .gem-c-search__label {
464
+ font-family: "GDS Transport", arial, sans-serif;
465
+ -webkit-font-smoothing: antialiased;
466
+ -moz-osx-font-smoothing: grayscale;
467
+ font-weight: 400;
468
+ font-size: 1.1875rem;
469
+ line-height: 2.6315789474;
470
+ }
471
+
472
+ @media print {
473
+ .gem-c-search--large .gem-c-search__label {
474
+ font-family: sans-serif;
475
+ font-size: 14pt;
476
+ line-height: 50px;
477
+ }
478
+ }
479
+
480
+ .gem-c-search--large .gem-c-search__input[type="search"] {
481
+ height: 50px;
482
+ }
483
+
484
+ .gem-c-search--large .gem-c-search__submit {
485
+ width: 50px;
486
+ height: 50px;
487
+ }
488
+
489
+ .gem-c-search--large .gem-c-search__submit .gem-c-search__icon {
490
+ transform: scale(0.4);
491
+ }
492
+
493
+ .gem-c-search--separate-label .gem-c-search__label {
494
+ position: relative;
495
+ top: auto;
496
+ left: auto;
497
+ padding-left: 0;
498
+ }
499
+ </style>
@@ -0,0 +1,32 @@
1
+ type Props = {
2
+ value?: string;
3
+ label_text?: string;
4
+ label_id?: string;
5
+ inline_label?: boolean;
6
+ hint?: string;
7
+ on_govuk_blue?: boolean;
8
+ homepage?: boolean;
9
+ size?: "large" | "";
10
+ name?: string;
11
+ aria_controls?: string;
12
+ button_text?: string;
13
+ label_size?: "xl" | "l" | "m" | "s" | "" | null;
14
+ wrap_label_in_a_heading?: boolean;
15
+ heading_level?: 1 | 2 | 3 | 4 | 5 | 6;
16
+ margin_bottom?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
17
+ label_margin_bottom?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | undefined;
18
+ label_custom_class?: string;
19
+ disable_corrections?: boolean;
20
+ input_width?: "full" | "three-quarters" | "two-thirds" | "one-half" | "one-third" | "one-quarter" | "" | null;
21
+ id?: string;
22
+ classes?: string;
23
+ dataAttributes?: Record<string, string>;
24
+ aria?: Record<string, string>;
25
+ role?: string;
26
+ lang?: string;
27
+ dir?: "rtl" | "ltr" | "auto";
28
+ button_background_color?: string;
29
+ };
30
+ declare const Search: import("svelte").Component<Props, {}, "value">;
31
+ type Search = ReturnType<typeof Search>;
32
+ export default Search;