svelte-reflector 2.1.3 → 2.1.4
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.
|
@@ -158,10 +158,18 @@ export function genericArrayBundler<T extends { bundle: () => BundleResult<T> }>
|
|
|
158
158
|
return (data as T[]).map((item) => item.bundle());
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Atualiza um query param na URL.
|
|
163
|
+
* - `""` (string vazia) → remove o param.
|
|
164
|
+
* - qualquer outro valor → `searchParams.set(key, String(event))`.
|
|
165
|
+
*/
|
|
161
166
|
export function changeParam({ event, key }: QueryContract) {
|
|
162
|
-
const newValue = event;
|
|
163
167
|
const url = new SvelteURL(page.url);
|
|
164
|
-
|
|
168
|
+
if (event === "") {
|
|
169
|
+
url.searchParams.delete(key);
|
|
170
|
+
} else {
|
|
171
|
+
url.searchParams.set(key, String(event));
|
|
172
|
+
}
|
|
165
173
|
goto(url, { replaceState: true, keepFocus: true });
|
|
166
174
|
}
|
|
167
175
|
|
|
@@ -190,12 +198,24 @@ export class QueryBuilder {
|
|
|
190
198
|
return fromUrl !== null ? fromUrl : this.defaultValue;
|
|
191
199
|
}
|
|
192
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Aplica o valor recebido ao query param.
|
|
203
|
+
* - `null` / `undefined` → no-op (não chama `goto`).
|
|
204
|
+
* - `""` (string vazia) → delega pra `changeParam`, que remove o param.
|
|
205
|
+
* - número / string não-vazia → `set(key, String(event))`.
|
|
206
|
+
*/
|
|
193
207
|
update(event: string | number | null) {
|
|
194
208
|
if (event === null || event === undefined) return;
|
|
195
209
|
return changeParam({ key: this.key, event: String(event) });
|
|
196
210
|
}
|
|
197
211
|
}
|
|
198
212
|
|
|
213
|
+
/**
|
|
214
|
+
* Atualiza vários query params de uma vez.
|
|
215
|
+
* - array → `delete(key)` seguido de `append` para cada item.
|
|
216
|
+
* - `""` → remove o param.
|
|
217
|
+
* - outros valores → `set(key, String(value))`.
|
|
218
|
+
*/
|
|
199
219
|
export function setQueryGroup(group: QueryWithArrayType[]) {
|
|
200
220
|
if (!browser) return;
|
|
201
221
|
|
|
@@ -210,6 +230,11 @@ export function setQueryGroup(group: QueryWithArrayType[]) {
|
|
|
210
230
|
continue;
|
|
211
231
|
}
|
|
212
232
|
|
|
233
|
+
if (value === "") {
|
|
234
|
+
url.searchParams.delete(key);
|
|
235
|
+
continue;
|
|
236
|
+
}
|
|
237
|
+
|
|
213
238
|
url.searchParams.set(key, String(value));
|
|
214
239
|
}
|
|
215
240
|
|