@happyvertical/smrt-content 0.43.3 → 0.43.5
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/AGENTS.md +9 -0
- package/agents/content-list.md +869 -0
- package/dist/content-query.d.ts +310 -0
- package/dist/content-query.d.ts.map +1 -0
- package/dist/contents.d.ts +22 -0
- package/dist/contents.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +672 -4
- package/dist/index.js.map +1 -1
- package/dist/manifest.json +22 -2
- package/dist/smrt-knowledge.json +38 -5
- package/dist/svelte/components/ContentList.svelte +1580 -281
- package/dist/svelte/components/ContentList.svelte.d.ts +54 -2
- package/dist/svelte/components/ContentList.svelte.d.ts.map +1 -1
- package/dist/svelte/content-list-controller.d.ts +306 -0
- package/dist/svelte/content-list-controller.d.ts.map +1 -0
- package/dist/svelte/content-list-controller.js +921 -0
- package/dist/svelte/content-list-query.d.ts +498 -0
- package/dist/svelte/content-list-query.d.ts.map +1 -0
- package/dist/svelte/content-list-query.js +1294 -0
- package/dist/svelte/content-list-saved-views.d.ts +172 -0
- package/dist/svelte/content-list-saved-views.d.ts.map +1 -0
- package/dist/svelte/content-list-saved-views.js +298 -0
- package/dist/svelte/content-list-url-state.d.ts +211 -0
- package/dist/svelte/content-list-url-state.d.ts.map +1 -0
- package/dist/svelte/content-list-url-state.js +856 -0
- package/dist/svelte/i18n.contribution.d.ts +55 -0
- package/dist/svelte/i18n.contribution.d.ts.map +1 -1
- package/dist/svelte/i18n.contribution.js +57 -0
- package/dist/svelte/index.d.ts +5 -0
- package/dist/svelte/index.d.ts.map +1 -1
- package/dist/svelte/index.js +10 -0
- package/package.json +16 -15
|
@@ -1,15 +1,67 @@
|
|
|
1
|
+
import type { DataTableViewState as ContentListDataTableViewState } from '@happyvertical/smrt-ui/data';
|
|
2
|
+
import type { ContentListUrlStateOptions } from '../content-list-url-state.js';
|
|
3
|
+
/**
|
|
4
|
+
* Optional, router-agnostic URL state (#2452).
|
|
5
|
+
*
|
|
6
|
+
* `ContentList` never imports a router: it reads `params` once during
|
|
7
|
+
* initialization and hands the merged parameters back through `onChange`, so a
|
|
8
|
+
* SvelteKit host calls `replaceState`, a hash router rewrites the fragment, and
|
|
9
|
+
* a test passes a plain `URLSearchParams`.
|
|
10
|
+
*/
|
|
11
|
+
export interface ContentListUrlStateBinding {
|
|
12
|
+
/**
|
|
13
|
+
* Query parameters to restore the view from. Read once, at initialization —
|
|
14
|
+
* later navigation is the host's to drive (re-key the component to re-read).
|
|
15
|
+
*/
|
|
16
|
+
params?: URLSearchParams | string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Receives the full merged parameter set — every foreign parameter
|
|
19
|
+
* preserved — whenever the query-affecting state changes. Never called for
|
|
20
|
+
* the initial restore.
|
|
21
|
+
*/
|
|
22
|
+
onChange?: (params: URLSearchParams, state: ContentListDataTableViewState) => void;
|
|
23
|
+
/** Prefix and default page size, forwarded to the URL-state module. */
|
|
24
|
+
options?: ContentListUrlStateOptions;
|
|
25
|
+
}
|
|
1
26
|
import type { Snippet } from 'svelte';
|
|
2
27
|
import type { ContentData } from '../../mock-smrt-client.js';
|
|
28
|
+
import { type ContentListDataSurface, type ContentListViewMode } from '../content-list-controller.js';
|
|
29
|
+
import { type ContentListQuerySource } from '../content-list-query.js';
|
|
30
|
+
import { type ContentListSavedViewStore } from '../content-list-saved-views.js';
|
|
3
31
|
interface Props {
|
|
4
32
|
apiBaseUrl?: string;
|
|
5
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Client-side rows. Ignored when `query` is supplied — the server then owns
|
|
35
|
+
* filtering, sorting, and paging, and these rows would be a second, disagreeing
|
|
36
|
+
* source of truth.
|
|
37
|
+
*/
|
|
38
|
+
contents?: ContentData[];
|
|
6
39
|
type?: string;
|
|
7
|
-
defaultViewMode?:
|
|
40
|
+
defaultViewMode?: ContentListViewMode;
|
|
8
41
|
onEdit: (content: ContentData) => void;
|
|
9
42
|
onDelete: (content: ContentData) => void;
|
|
10
43
|
onAdd: () => void;
|
|
11
44
|
controls?: Snippet;
|
|
12
45
|
getViewHref?: (content: ContentData) => string | null;
|
|
46
|
+
/** Announced uniformly by every presentation; #2455 extends it. */
|
|
47
|
+
loading?: boolean;
|
|
48
|
+
/** Load failure announced instead of the list. */
|
|
49
|
+
error?: string | null;
|
|
50
|
+
/** Retry affordance rendered with an error. */
|
|
51
|
+
onRetry?: () => void;
|
|
52
|
+
/** Opt-in agent addressability. Non-table presentations land with #2456. */
|
|
53
|
+
dataSurface?: ContentListDataSurface;
|
|
54
|
+
/**
|
|
55
|
+
* Opt-in server-backed rows (#2452). `bind()` is called exactly once, during
|
|
56
|
+
* initialization, so a `remoteQuery(...)` binding is disposed with this
|
|
57
|
+
* component. Supplying it switches the list into server mode: `contents` is
|
|
58
|
+
* ignored and the local select/paginate transform never runs.
|
|
59
|
+
*/
|
|
60
|
+
query?: ContentListQuerySource;
|
|
61
|
+
/** Opt-in shareable URL state. The host owns navigation. */
|
|
62
|
+
urlState?: ContentListUrlStateBinding;
|
|
63
|
+
/** Opt-in saved views. `createContentListSavedViewStore()` is the default store. */
|
|
64
|
+
savedViews?: ContentListSavedViewStore;
|
|
13
65
|
}
|
|
14
66
|
declare const ContentList: import("svelte").Component<Props, {}, "">;
|
|
15
67
|
type ContentList = ReturnType<typeof ContentList>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentList.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/components/ContentList.svelte.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContentList.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/components/ContentList.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,IAAI,6BAA6B,EAAE,MAAM,6BAA6B,CAAC;AACvG,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE/E;;;;;;;GAOG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WAAW,CAAC,EAAE,sBAAsB,CAAC;IACrC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,0BAA0B,CAAC;IACtC,oFAAoF;IACpF,UAAU,CAAC,EAAE,yBAAyB,CAAC;CACxC;AAg2CD,QAAA,MAAM,WAAW,2CAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared content-list data adapter.
|
|
3
|
+
*
|
|
4
|
+
* Every ContentList presentation (grid, detailed, compact) and every
|
|
5
|
+
* agent-addressable data surface resolves rows, columns, filters, sorting, and
|
|
6
|
+
* per-row action eligibility here, so switching presentation can never change
|
|
7
|
+
* which rows exist or what may be done to them.
|
|
8
|
+
*
|
|
9
|
+
* The module owns no transport, no DOM, and no routing: callers supply the
|
|
10
|
+
* content array, a `getViewHref` resolver, and a `DataTableController` that
|
|
11
|
+
* holds the serializable view state.
|
|
12
|
+
*
|
|
13
|
+
* Query modes are `manual`: this adapter, not the renderer, applies search,
|
|
14
|
+
* filters, sorting, and paging, so a card view and the compact table can never
|
|
15
|
+
* disagree about the visible rows. #2452 replaces the local implementation of
|
|
16
|
+
* that transform with a server query behind the same contract.
|
|
17
|
+
*/
|
|
18
|
+
import { type DataSurfaceDescriptor, type DataSurfaceLimits, type DataSurfaceRegistry, type DataSurfaceSubject, type DataTableColumn, type DataTableCommand, type DataTableController, type DataTableFilter, type DataTableRowId, type DataTableSortRule, type DataTableViewState } from '@happyvertical/smrt-ui/data';
|
|
19
|
+
import type { ContentData } from '../mock-smrt-client.js';
|
|
20
|
+
/** Stable surface identity for the default mounted content list. */
|
|
21
|
+
export declare const CONTENT_LIST_SURFACE_ID = "content-list";
|
|
22
|
+
/** Descriptor and view-state schema version owned by this adapter. */
|
|
23
|
+
export declare const CONTENT_LIST_SCHEMA_VERSION = 1;
|
|
24
|
+
/** Row identity column. Selection and expansion address rows by this value. */
|
|
25
|
+
export declare const CONTENT_LIST_ROW_KEY = "id";
|
|
26
|
+
/** Stable filter ids dispatched by the toolbar and accepted from a surface. */
|
|
27
|
+
export declare const CONTENT_LIST_TYPE_FILTER_ID = "type";
|
|
28
|
+
export declare const CONTENT_LIST_STATUS_FILTER_ID = "status";
|
|
29
|
+
export type ContentListViewMode = 'grid' | 'detailed' | 'compact';
|
|
30
|
+
export type ContentListColumnId = 'type' | 'title' | 'author' | 'status' | 'state' | 'publish' | 'updated' | 'site' | 'description';
|
|
31
|
+
export type ContentListActionId = 'view' | 'edit' | 'delete';
|
|
32
|
+
/** Columns rendered by the compact table and published to a data surface. */
|
|
33
|
+
export declare const CONTENT_LIST_VISIBLE_COLUMN_IDS: readonly ["type", "title", "author", "status", "state", "publish", "updated", "site"];
|
|
34
|
+
/**
|
|
35
|
+
* `description` is searched but never rendered or published: it participates in
|
|
36
|
+
* local search so the rebuilt list keeps the legacy search reach.
|
|
37
|
+
*/
|
|
38
|
+
export declare const CONTENT_LIST_HIDDEN_COLUMN_IDS: readonly ["description"];
|
|
39
|
+
export declare const CONTENT_LIST_COLUMN_IDS: readonly ["type", "title", "author", "status", "state", "publish", "updated", "site", "description"];
|
|
40
|
+
/**
|
|
41
|
+
* Structural columns the compact table owns. They carry no query capability and
|
|
42
|
+
* are never published to a data surface, but the controller still has to know
|
|
43
|
+
* them: column order is reconciled from its known column ids, so leaving them
|
|
44
|
+
* out would push selection and actions behind every data column.
|
|
45
|
+
*/
|
|
46
|
+
export declare const CONTENT_LIST_SELECTION_COLUMN_ID = "select";
|
|
47
|
+
export declare const CONTENT_LIST_ACTIONS_COLUMN_ID = "actions";
|
|
48
|
+
/** Every column of the compact table, in render order. */
|
|
49
|
+
export declare const CONTENT_LIST_TABLE_COLUMN_IDS: readonly ["select", "type", "title", "author", "status", "state", "publish", "updated", "site", "description", "actions"];
|
|
50
|
+
/**
|
|
51
|
+
* One resolved list row. Display values are flattened so a column accessor,
|
|
52
|
+
* local search, and local sorting all read the same normalized text.
|
|
53
|
+
*/
|
|
54
|
+
export interface ContentListRow {
|
|
55
|
+
/** Canonical row id used by Svelte keys, selection, and expansion. */
|
|
56
|
+
id: DataTableRowId;
|
|
57
|
+
/**
|
|
58
|
+
* False when the source content carried no durable id, or repeated one that
|
|
59
|
+
* an earlier row already claimed. Such rows still render, but they are never
|
|
60
|
+
* selection-eligible because no stable address exists for them.
|
|
61
|
+
*/
|
|
62
|
+
identified: boolean;
|
|
63
|
+
content: ContentData;
|
|
64
|
+
type: string;
|
|
65
|
+
typeLabel: string;
|
|
66
|
+
title: string;
|
|
67
|
+
description: string;
|
|
68
|
+
author: string;
|
|
69
|
+
status: string;
|
|
70
|
+
statusLabel: string;
|
|
71
|
+
state: string;
|
|
72
|
+
stateLabel: string;
|
|
73
|
+
publish: string;
|
|
74
|
+
publishLabel: string;
|
|
75
|
+
updated: string;
|
|
76
|
+
updatedLabel: string;
|
|
77
|
+
site: string;
|
|
78
|
+
}
|
|
79
|
+
export type ContentListColumnLabels = Partial<Record<ContentListColumnId, string>>;
|
|
80
|
+
export type ContentListActionLabels = Partial<Record<ContentListActionId, string>>;
|
|
81
|
+
export interface ContentListControllerOptions {
|
|
82
|
+
/** Initial free-text search. */
|
|
83
|
+
search?: string;
|
|
84
|
+
/** Locks or seeds the type filter. */
|
|
85
|
+
type?: string | null;
|
|
86
|
+
/** Seeds the status filter. */
|
|
87
|
+
status?: string | null;
|
|
88
|
+
/** Initial sort rules; empty keeps the caller-supplied order. */
|
|
89
|
+
sorting?: readonly DataTableSortRule[];
|
|
90
|
+
/** `null` keeps the historical unpaginated list. #2452 supplies a size. */
|
|
91
|
+
pageSize?: number | null;
|
|
92
|
+
onStateChange?: (state: DataTableViewState, command: DataTableCommand) => void;
|
|
93
|
+
}
|
|
94
|
+
export interface ContentListSurfaceDescriptorOptions {
|
|
95
|
+
/** Distinguishes several mounted lists in one application. */
|
|
96
|
+
surfaceId?: string;
|
|
97
|
+
/** Optional owning subject, for example a site or a collection. */
|
|
98
|
+
subject?: DataSurfaceSubject;
|
|
99
|
+
label?: string;
|
|
100
|
+
description?: string;
|
|
101
|
+
/** Label for the declared row-key column. */
|
|
102
|
+
rowKeyLabel?: string;
|
|
103
|
+
columnLabels?: ContentListColumnLabels;
|
|
104
|
+
actionLabels?: ContentListActionLabels;
|
|
105
|
+
limits?: Partial<DataSurfaceLimits>;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Opt-in agent addressability for the compact table. The host owns the
|
|
109
|
+
* registry; the descriptor defaults to `buildContentListSurfaceDescriptor()`.
|
|
110
|
+
*/
|
|
111
|
+
export interface ContentListDataSurface {
|
|
112
|
+
registry: DataSurfaceRegistry;
|
|
113
|
+
descriptor?: DataSurfaceDescriptor;
|
|
114
|
+
}
|
|
115
|
+
export interface ContentListActionOptions {
|
|
116
|
+
getViewHref?: (content: ContentData) => string | null;
|
|
117
|
+
/** Hosts without an edit affordance can drop the action entirely. */
|
|
118
|
+
canEdit?: boolean;
|
|
119
|
+
/** Hosts without a delete affordance can drop the action entirely. */
|
|
120
|
+
canDelete?: boolean;
|
|
121
|
+
}
|
|
122
|
+
/** Normalizes a content type for filtering; unknown values become `content`. */
|
|
123
|
+
export declare function normalizeContentType(value: unknown): string;
|
|
124
|
+
/** Normalizes a status/state token for filtering and badge variants. */
|
|
125
|
+
export declare function normalizeContentToken(value: unknown): string;
|
|
126
|
+
/**
|
|
127
|
+
* The type tokens the toolbar select offers.
|
|
128
|
+
*
|
|
129
|
+
* `Content.type` is freeform, so this is a display vocabulary rather than the
|
|
130
|
+
* model's domain: a value outside it is still a valid filter, and the list
|
|
131
|
+
* surfaces it rather than hiding it (see `ContentList`).
|
|
132
|
+
*/
|
|
133
|
+
export declare const CONTENT_LIST_TYPE_OPTIONS: readonly ["article", "document", "mirror"];
|
|
134
|
+
/**
|
|
135
|
+
* The status tokens the toolbar select offers.
|
|
136
|
+
*
|
|
137
|
+
* `Content.status` is `published | draft | review | archived | deleted`.
|
|
138
|
+
* `review` is offered because it is a real, reachable state that governance
|
|
139
|
+
* puts content into; omitting it meant `?status=review` restored a live
|
|
140
|
+
* predicate the toolbar could not show.
|
|
141
|
+
*
|
|
142
|
+
* `deleted` is deliberately NOT offered: it is the trash lifecycle, which is
|
|
143
|
+
* #2454's, and exposing it here would imply a restore/purge affordance this
|
|
144
|
+
* list does not have.
|
|
145
|
+
*/
|
|
146
|
+
export declare const CONTENT_LIST_STATUS_OPTIONS: readonly ["published", "draft", "review", "archived"];
|
|
147
|
+
/**
|
|
148
|
+
* Resolves the normalized type a `type` prop locks the list to, or `null` when
|
|
149
|
+
* the list is unlocked. Shared so the lock effect and the initial restore
|
|
150
|
+
* cannot disagree about what "locked" means.
|
|
151
|
+
*/
|
|
152
|
+
export declare function normalizeContentListTypeLock(value: string | null | undefined): string | null;
|
|
153
|
+
export declare function contentTypeLabel(value: unknown): string;
|
|
154
|
+
/** Badge variant for a status; unrecognized statuses degrade to `unknown`. */
|
|
155
|
+
export declare function contentStatusVariant(value: unknown): string;
|
|
156
|
+
/** Badge variant for a workflow state; unrecognized states degrade to `unknown`. */
|
|
157
|
+
export declare function contentStateVariant(value: unknown): string;
|
|
158
|
+
/** Renders an ISO timestamp as a stable calendar date, or echoes free text. */
|
|
159
|
+
export declare function formatContentListDate(value: unknown): string;
|
|
160
|
+
/**
|
|
161
|
+
* Resolves the rows every presentation renders.
|
|
162
|
+
*
|
|
163
|
+
* A content without a durable id — or one repeating an id an earlier row
|
|
164
|
+
* already claimed — still renders, keyed by its position, but is marked
|
|
165
|
+
* unidentified so it never enters a selection that outlives the current order.
|
|
166
|
+
*/
|
|
167
|
+
export declare function toContentListRows(contents: readonly ContentData[]): ContentListRow[];
|
|
168
|
+
/** Row ids that may take part in selection. Unidentified rows are excluded. */
|
|
169
|
+
export declare function selectableContentListRowIds(rows: readonly ContentListRow[]): DataTableRowId[];
|
|
170
|
+
/**
|
|
171
|
+
* Resolves a selection to rows. Unidentified rows are dropped rather than
|
|
172
|
+
* throwing, so one malformed content can never break a bulk workflow (#2453).
|
|
173
|
+
*/
|
|
174
|
+
export declare function resolveSelectedContentListRows(rows: readonly ContentListRow[], state: DataTableViewState): ContentListRow[];
|
|
175
|
+
/** The durable contents behind the current selection. */
|
|
176
|
+
export declare function resolveSelectedContents(rows: readonly ContentListRow[], state: DataTableViewState): ContentData[];
|
|
177
|
+
/**
|
|
178
|
+
* Column metadata shared by the compact table and the local query helpers.
|
|
179
|
+
* Callers add cell snippets; they must not change ids, accessors, or the
|
|
180
|
+
* searchable/filterable/sortable flags the descriptor is derived from.
|
|
181
|
+
*/
|
|
182
|
+
export declare function buildContentListColumns(labels?: ContentListColumnLabels): DataTableColumn<ContentListRow>[];
|
|
183
|
+
/**
|
|
184
|
+
* Columns whose stored values are lowercase tokens rather than free text.
|
|
185
|
+
*
|
|
186
|
+
* Only these may have their case normalized by a filter: their domain is a
|
|
187
|
+
* fixed vocabulary the model writes in lower case, so folding the operator's
|
|
188
|
+
* input to match it is a correction. Every other column holds text a person
|
|
189
|
+
* typed.
|
|
190
|
+
*/
|
|
191
|
+
export declare const CONTENT_LIST_TOKEN_COLUMN_IDS: readonly ["type", "status", "state"];
|
|
192
|
+
/**
|
|
193
|
+
* One normalizer per filter column, so a filter built by the toolbar, by the
|
|
194
|
+
* `type` lock, and by a restored view all compare equal.
|
|
195
|
+
*
|
|
196
|
+
* CASE IS PRESERVED FOR FREE TEXT. This helper was written for #2451, when
|
|
197
|
+
* every comparison happened in the browser and lowercasing everything was
|
|
198
|
+
* harmless. Under #2452 a stored filter value becomes a server-side `eq` or
|
|
199
|
+
* `like` predicate compared against the STORED text, so lowercasing `NASA`
|
|
200
|
+
* would send `%nasa%` and miss `NASA Update` on a case-sensitive backend
|
|
201
|
+
* (PostgreSQL, DuckDB). Local matching is unaffected either way: the local
|
|
202
|
+
* evaluator compares through `textValue()`, which lower-cases BOTH sides at
|
|
203
|
+
* compare time, so a case-preserving stored value still matches
|
|
204
|
+
* case-insensitively there.
|
|
205
|
+
*/
|
|
206
|
+
export declare function normalizeContentListFilterValue(columnId: string, value: string): string;
|
|
207
|
+
/** Builds the declarative filter set for the two toolbar filters. */
|
|
208
|
+
export declare function contentListFilters(values: {
|
|
209
|
+
type?: string | null;
|
|
210
|
+
status?: string | null;
|
|
211
|
+
}): DataTableFilter[];
|
|
212
|
+
/**
|
|
213
|
+
* Reads one filter's value, or `null` when the filter is not applied.
|
|
214
|
+
*
|
|
215
|
+
* Value-only, and therefore NOT enough to drive a single-select toolbar
|
|
216
|
+
* control: it reports the same string for `equals 'draft'` and
|
|
217
|
+
* `notEquals 'draft'`. Use {@link readContentListSelectFilter} for anything
|
|
218
|
+
* that displays the filter to an operator.
|
|
219
|
+
*/
|
|
220
|
+
export declare function readContentListFilter(state: DataTableViewState, columnId: string): string | null;
|
|
221
|
+
/**
|
|
222
|
+
* The value a toolbar select carries while a live filter cannot be represented
|
|
223
|
+
* as one of its options. It is only ever set programmatically on a disabled
|
|
224
|
+
* option, so it can never be submitted; `applyContentListFilter` would replace
|
|
225
|
+
* every filter on the column anyway.
|
|
226
|
+
*
|
|
227
|
+
* The prefix is U+001F rather than U+0000 deliberately. The HTML tokenizer
|
|
228
|
+
* rewrites a NUL inside an attribute value to U+FFFD, so a server-rendered
|
|
229
|
+
* option would come back with a different value than the select was given and
|
|
230
|
+
* hydrate to no selection at all — exactly the state this sentinel exists to
|
|
231
|
+
* prevent. U+001F passes through attribute parsing unchanged.
|
|
232
|
+
*
|
|
233
|
+
* A crafted filter value could still equal it — the normalizer only trims and
|
|
234
|
+
* lower-cases — and that is harmless: the representable and unrepresentable
|
|
235
|
+
* paths are mutually exclusive, and the representable one renders the value as
|
|
236
|
+
* a real, enabled option carrying the same value.
|
|
237
|
+
*/
|
|
238
|
+
export declare const CONTENT_LIST_UNREPRESENTABLE_OPTION = "\u001Funrepresentable";
|
|
239
|
+
/** What a single-select toolbar control can honestly display for one column. */
|
|
240
|
+
export interface ContentListSelectFilterState {
|
|
241
|
+
/** The value to display, or `''` when there is nothing to display. */
|
|
242
|
+
value: string;
|
|
243
|
+
/**
|
|
244
|
+
* False when a live filter exists on this column that a single select cannot
|
|
245
|
+
* express — a non-`equals` operator, a list value, a valueless operator, or
|
|
246
|
+
* more than one filter. The caller must then not render a plain value: it
|
|
247
|
+
* would state something other than the query being run.
|
|
248
|
+
*/
|
|
249
|
+
representable: boolean;
|
|
250
|
+
/** A short, operator-facing summary of the live predicate when it is not. */
|
|
251
|
+
detail: string | null;
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Resolves what a toolbar select may show for one column.
|
|
255
|
+
*
|
|
256
|
+
* A select offers a single `equals` value, but the filter vocabulary a link or
|
|
257
|
+
* a saved view can restore is much wider. `?status.in=draft,review` and
|
|
258
|
+
* `?status.isNull=1` constrain the query while a value-only read reports
|
|
259
|
+
* nothing, and `?status.notEquals=draft` reports `draft` — the exact inverse of
|
|
260
|
+
* what is being applied. This is the seam that keeps the control from
|
|
261
|
+
* misstating the query: either it can show the predicate exactly, or the caller
|
|
262
|
+
* is told it cannot and reports it.
|
|
263
|
+
*/
|
|
264
|
+
export declare function readContentListSelectFilter(state: DataTableViewState, columnId: string): ContentListSelectFilterState;
|
|
265
|
+
/**
|
|
266
|
+
* True when a column is filtered to exactly the given value and nothing else.
|
|
267
|
+
*
|
|
268
|
+
* A locked filter has to be checked as a whole rather than by reading one
|
|
269
|
+
* value: a `notEquals` on the locked value, or a second filter on the same
|
|
270
|
+
* column, would otherwise satisfy a value-only comparison while selecting rows
|
|
271
|
+
* the lock is meant to exclude.
|
|
272
|
+
*/
|
|
273
|
+
export declare function isContentListFilterExactly(state: DataTableViewState, columnId: string, value: string): boolean;
|
|
274
|
+
/**
|
|
275
|
+
* Replaces one filter while preserving the others, so locking the type filter
|
|
276
|
+
* never discards a status the operator chose.
|
|
277
|
+
*
|
|
278
|
+
* A blank value clears the filter: normalizing whitespace into an `equals ''`
|
|
279
|
+
* filter would silently exclude every row instead.
|
|
280
|
+
*/
|
|
281
|
+
export declare function applyContentListFilter(controller: DataTableController, columnId: string, value: string | null): void;
|
|
282
|
+
export declare function createContentListController(options?: ContentListControllerOptions): DataTableController;
|
|
283
|
+
/**
|
|
284
|
+
* Applies search, declarative filters, and sorting once for every
|
|
285
|
+
* presentation. Pagination stays separate so a caller can report the unpaged
|
|
286
|
+
* result count (DataTable's `totalRows`) alongside the current page.
|
|
287
|
+
*/
|
|
288
|
+
export declare function selectContentListRows(rows: readonly ContentListRow[], state: DataTableViewState, columns?: DataTableColumn<ContentListRow>[]): ContentListRow[];
|
|
289
|
+
/** Slices the current page. An unset page size keeps the whole result. */
|
|
290
|
+
export declare function paginateContentListRows(rows: readonly ContentListRow[], state: DataTableViewState): ContentListRow[];
|
|
291
|
+
/**
|
|
292
|
+
* Resolves the host-owned view link. An unknown subtype — or a resolver that
|
|
293
|
+
* throws on one — degrades to plain text rather than a dead link.
|
|
294
|
+
*/
|
|
295
|
+
export declare function resolveContentHref(content: ContentData, getViewHref?: (content: ContentData) => string | null): string | null;
|
|
296
|
+
/**
|
|
297
|
+
* Per-row action eligibility, used identically by all three presentations.
|
|
298
|
+
* `view` requires a resolvable href, so unpublished content never renders one.
|
|
299
|
+
*/
|
|
300
|
+
export declare function contentListRowActions(row: ContentListRow, options?: ContentListActionOptions): ContentListActionId[];
|
|
301
|
+
/**
|
|
302
|
+
* Builds the discovery contract for a mounted content list. Only rendered
|
|
303
|
+
* columns are published: the search-only `description` column stays private.
|
|
304
|
+
*/
|
|
305
|
+
export declare function buildContentListSurfaceDescriptor(options?: ContentListSurfaceDescriptorOptions): DataSurfaceDescriptor;
|
|
306
|
+
//# sourceMappingURL=content-list-controller.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-list-controller.d.ts","sourceRoot":"","sources":["../../src/svelte/content-list-controller.ts"],"names":[],"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