runeforge 0.0.17 → 0.0.19

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.
@@ -1,5 +1,7 @@
1
+ import type { XlsxModule } from '../table/export.js';
1
2
  import type { AttributeMetadata } from '../../types/attribute.js';
2
- import type { ActionConfiguration, ColumnDefinition, CustomAction, FieldDefinition } from '../../types/crud.js';
3
+ import type { ActionConfiguration, ColumnDefinition, CustomAction, CustomBulkAction, FieldDefinition, SearchConfiguration } from '../../types/crud.js';
4
+ import type { TableQuery } from '../../types/table.js';
3
5
  declare function $$render<T extends object = Record<string, unknown>>(): {
4
6
  props: {
5
7
  data?: Record<string, unknown>;
@@ -14,12 +16,22 @@ declare function $$render<T extends object = Record<string, unknown>>(): {
14
16
  read?: ActionConfiguration<T>;
15
17
  deletion?: ActionConfiguration<T>;
16
18
  actions?: CustomAction<T>[];
19
+ customBulkActions?: CustomBulkAction<T>[];
20
+ search?: SearchConfiguration;
17
21
  columns?: ColumnDefinition<T>[];
18
22
  fields?: FieldDefinition<T>[];
19
23
  meta?: Partial<Record<string, AttributeMetadata>>;
20
24
  form?: {
21
25
  error?: string;
22
26
  } | null;
27
+ /** Shows an icon-only export button (CSV, and Excel if `xlsx` is provided). */
28
+ enableExport?: boolean;
29
+ /** Server-pagination mode only: fetch all rows matching the current query
30
+ * (unpaginated) for export. Without it, export falls back to the loaded page. */
31
+ onExport?: (query: TableQuery) => Promise<T[]>;
32
+ /** Resolved `xlsx` (SheetJS) module, e.g. `import * as xlsx from 'xlsx'`.
33
+ * Enables the "Export as Excel" option; omit to only offer CSV. */
34
+ xlsx?: XlsxModule;
23
35
  };
24
36
  exports: {};
25
37
  bindings: "";
@@ -0,0 +1,53 @@
1
+ <script lang="ts">
2
+ import { page } from '$app/state';
3
+ import { goto } from '$app/navigation';
4
+ import { getStrings } from '../../i18n/context.js';
5
+ import type { SearchConfiguration } from '../../types/crud.js';
6
+
7
+ const strings = getStrings();
8
+
9
+ let {
10
+ config = {} as SearchConfiguration
11
+ }: {
12
+ config?: SearchConfiguration;
13
+ } = $props();
14
+
15
+ const param = $derived(config.param ?? 'search');
16
+ const debounceMs = $derived(config.debounceMs ?? 300);
17
+
18
+ // Intentional one-time hydration of local state from the initial `param`
19
+ // value (not a live binding) - svelte-check's state_referenced_locally
20
+ // warning is a false positive here, same as PaginatedTable's initialSort
21
+ // etc. After mount this is the source of truth for what the user is
22
+ // typing, so it doesn't fight with the URL updates this component itself
23
+ // triggers on every keystroke.
24
+ let value = $state(page.url.searchParams.get(param) ?? '');
25
+ let debounceTimer: ReturnType<typeof setTimeout>;
26
+
27
+ function onInput() {
28
+ clearTimeout(debounceTimer);
29
+ debounceTimer = setTimeout(() => {
30
+ // eslint-disable-next-line svelte/prefer-svelte-reactivity
31
+ const params = new URLSearchParams(page.url.searchParams);
32
+ const trimmed = value.trim();
33
+ if (trimmed) params.set(param, trimmed);
34
+ else params.delete(param);
35
+ // A new search term can leave the current page past the end of the
36
+ // narrowed result set, and any open create/read/edit view stops
37
+ // making sense once the underlying list changes - drop both.
38
+ params.delete('page');
39
+ params.delete('view');
40
+ params.delete('id');
41
+ const qs = params.toString();
42
+ goto(qs ? `?${qs}` : '?', { keepFocus: true, noScroll: true, replaceState: true });
43
+ }, debounceMs);
44
+ }
45
+ </script>
46
+
47
+ <input
48
+ type="search"
49
+ bind:value
50
+ oninput={onInput}
51
+ placeholder={config.placeholder ?? strings.searchPlaceholder}
52
+ class="input input-bordered"
53
+ />
@@ -0,0 +1,7 @@
1
+ import type { SearchConfiguration } from '../../types/crud.js';
2
+ type $$ComponentProps = {
3
+ config?: SearchConfiguration;
4
+ };
5
+ declare const SearchInput: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type SearchInput = ReturnType<typeof SearchInput>;
7
+ export default SearchInput;