@communitiesuk/svelte-component-library 0.1.19-beta.10 → 0.1.19-beta.11
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.
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
{#if buttonType === "moreInfo"}
|
|
29
29
|
<div>
|
|
30
30
|
<button
|
|
31
|
+
type={formButton ? "submit" : "button"}
|
|
31
32
|
aria-label={textContent}
|
|
32
33
|
aria-expanded={ariaExpanded}
|
|
33
34
|
class="more-info-button"
|
|
@@ -60,7 +61,7 @@
|
|
|
60
61
|
</a>
|
|
61
62
|
{:else if buttonType === "disabled"}
|
|
62
63
|
<button
|
|
63
|
-
type="submit"
|
|
64
|
+
type={formButton ? "submit" : "button"}
|
|
64
65
|
disabled
|
|
65
66
|
aria-disabled="true"
|
|
66
67
|
class="govuk-button"
|
|
@@ -70,7 +71,11 @@
|
|
|
70
71
|
{textContent}
|
|
71
72
|
</button>
|
|
72
73
|
{:else if buttonType === "table header"}
|
|
73
|
-
<button
|
|
74
|
+
<button
|
|
75
|
+
type={formButton ? "submit" : "button"}
|
|
76
|
+
class="text-header"
|
|
77
|
+
onclick={onClickFunction}
|
|
78
|
+
>
|
|
74
79
|
{textContent}
|
|
75
80
|
<svg
|
|
76
81
|
width="22"
|
|
@@ -96,7 +101,7 @@
|
|
|
96
101
|
</button>
|
|
97
102
|
{:else}
|
|
98
103
|
<button
|
|
99
|
-
type="submit"
|
|
104
|
+
type={formButton ? "submit" : "button"}
|
|
100
105
|
class={buttonClass}
|
|
101
106
|
data-module="govuk-button"
|
|
102
107
|
onclick={onClickFunction}
|
|
@@ -109,6 +114,7 @@
|
|
|
109
114
|
{#if buttonType === "moreInfo"}
|
|
110
115
|
<div>
|
|
111
116
|
<button
|
|
117
|
+
type={formButton ? "submit" : "button"}
|
|
112
118
|
aria-label={textContent}
|
|
113
119
|
aria-expanded={ariaExpanded}
|
|
114
120
|
class="more-info-button"
|
|
@@ -141,7 +147,7 @@
|
|
|
141
147
|
</a>
|
|
142
148
|
{:else if buttonType === "disabled"}
|
|
143
149
|
<button
|
|
144
|
-
type="submit"
|
|
150
|
+
type={formButton ? "submit" : "button"}
|
|
145
151
|
disabled
|
|
146
152
|
aria-disabled="true"
|
|
147
153
|
class="govuk-button"
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
type ExtendedSelectGroup = SelectGroup & { choices: ExtendedSelectItem[] };
|
|
14
14
|
|
|
15
15
|
let {
|
|
16
|
+
onChangeFunction,
|
|
16
17
|
hoveredArea = $bindable(),
|
|
17
18
|
// Core attributes - pass through to Select component
|
|
18
19
|
id,
|
|
@@ -261,27 +262,43 @@
|
|
|
261
262
|
next: string[];
|
|
262
263
|
}> = [];
|
|
263
264
|
let __seq = 0;
|
|
265
|
+
let suppressInitialChangeEvents = true;
|
|
266
|
+
let suppressCounter = 0;
|
|
267
|
+
|
|
268
|
+
let debounceTimerX: any = null;
|
|
269
|
+
let hasInitialized = false;
|
|
270
|
+
|
|
264
271
|
$inspect(value).with((type: string, current: unknown) => {
|
|
265
272
|
const next = Array.isArray(current)
|
|
266
273
|
? current.map((x) => String(x))
|
|
267
274
|
: current == null
|
|
268
275
|
? []
|
|
269
276
|
: [String(current as any)];
|
|
270
|
-
const prev = __lastSnapshot;
|
|
271
|
-
__seq += 1;
|
|
272
|
-
__history.push({ seq: __seq, type, prev, next });
|
|
273
|
-
// Keep history bounded
|
|
274
|
-
if (__history.length > 50) __history.shift();
|
|
275
|
-
/*console.log("🧭 [inspect:value]", {
|
|
276
|
-
seq: __seq,
|
|
277
|
-
type,
|
|
278
|
-
prev,
|
|
279
|
-
next,
|
|
280
|
-
historyLen: __history.length,
|
|
281
|
-
});*/
|
|
282
|
-
__lastSnapshot = next.slice();
|
|
283
|
-
});
|
|
284
277
|
|
|
278
|
+
clearTimeout(debounceTimerX);
|
|
279
|
+
debounceTimerX = setTimeout(() => {
|
|
280
|
+
const prev = __lastSnapshot;
|
|
281
|
+
|
|
282
|
+
// ✅ Skip first diff to avoid triggering on initial load
|
|
283
|
+
if (!hasInitialized) {
|
|
284
|
+
__lastSnapshot = next.slice();
|
|
285
|
+
hasInitialized = true;
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
const added = next.filter((x) => !prev.includes(x));
|
|
290
|
+
const removed = prev.filter((x) => !next.includes(x));
|
|
291
|
+
|
|
292
|
+
for (const val of added) {
|
|
293
|
+
onChangeFunction("added", val);
|
|
294
|
+
}
|
|
295
|
+
for (const val of removed) {
|
|
296
|
+
onChangeFunction("removed", val);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
__lastSnapshot = next.slice();
|
|
300
|
+
}, 50);
|
|
301
|
+
});
|
|
285
302
|
// Helper function for getting group text
|
|
286
303
|
function getGroupText(item: any): string | undefined {
|
|
287
304
|
if (!groupKey || !item || typeof item !== "object") return undefined;
|
|
@@ -1297,7 +1314,6 @@
|
|
|
1297
1314
|
if (typeof pillOnMouseLeaveFunction === "function") {
|
|
1298
1315
|
pill.addEventListener("mouseleave", () => {
|
|
1299
1316
|
pillOnMouseLeaveFunction();
|
|
1300
|
-
console.log("hello");
|
|
1301
1317
|
});
|
|
1302
1318
|
}
|
|
1303
1319
|
|
|
@@ -1305,7 +1321,6 @@
|
|
|
1305
1321
|
if (removeButton) {
|
|
1306
1322
|
removeButton.addEventListener("mousedown", () => {
|
|
1307
1323
|
hoveredArea = null;
|
|
1308
|
-
console.log("hello");
|
|
1309
1324
|
});
|
|
1310
1325
|
}
|
|
1311
1326
|
|
|
@@ -46,7 +46,6 @@
|
|
|
46
46
|
// Handle tab selection - integrate focus and hash logic directly
|
|
47
47
|
function selectTab(tabId: string, shouldFocus = false): void {
|
|
48
48
|
// Skip if component isn't ready, or tab is already selected
|
|
49
|
-
console.log(isSupported, isInitialized, selectedTabId, tabId);
|
|
50
49
|
|
|
51
50
|
if (!isSupported || !isInitialized || selectedTabId === tabId) return;
|
|
52
51
|
|
|
@@ -143,7 +142,6 @@
|
|
|
143
142
|
|
|
144
143
|
// Check URL hash for deep linking AFTER initial prop value is set
|
|
145
144
|
const hash = window.location.hash.substring(1);
|
|
146
|
-
console.log(hash, "hash");
|
|
147
145
|
if (hash) {
|
|
148
146
|
const tabFromHash = tabs.find((tab) => tab.id === hash);
|
|
149
147
|
if (tabFromHash.id && tabFromHash.id !== selectedTabId) {
|
|
@@ -225,9 +223,9 @@
|
|
|
225
223
|
!tabs.some((tab) => tab.id === selectedTabId)
|
|
226
224
|
) {
|
|
227
225
|
// If selected tab ID is no longer valid, default to the first available tab
|
|
228
|
-
console.log(
|
|
226
|
+
/*console.log(
|
|
229
227
|
`Effect: selectedTabId '${selectedTabId}' no longer valid. Resetting.`,
|
|
230
|
-
); // Optional Debug
|
|
228
|
+
); // Optional Debug*/
|
|
231
229
|
selectedTabId = tabs[0]?.id ?? null; // Use optional chaining and nullish coalescing
|
|
232
230
|
}
|
|
233
231
|
});
|