@aglyn/shared-ui-jsx 1.0.0-beta.229 → 1.0.0-beta.231
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/package.json +5 -5
- package/src/lib/components/copy-field.component.d.ts +25 -0
- package/src/lib/components/copy-field.component.js +77 -0
- package/src/lib/components/copy-field.component.js.map +1 -0
- package/src/lib/components/download-cost-badge.component.d.ts +37 -0
- package/src/lib/components/download-cost-badge.component.js +89 -0
- package/src/lib/components/download-cost-badge.component.js.map +1 -0
- package/src/lib/components/file-drop-zone.component.d.ts +48 -0
- package/src/lib/components/file-drop-zone.component.js +173 -0
- package/src/lib/components/file-drop-zone.component.js.map +1 -0
- package/src/lib/components/list-query-notices.component.d.ts +1 -18
- package/src/lib/components/list-query-notices.component.js +1 -11
- package/src/lib/components/list-query-notices.component.js.map +1 -1
- package/src/lib/components/searchable-virtual-list.component.d.ts +72 -0
- package/src/lib/components/searchable-virtual-list.component.js +212 -0
- package/src/lib/components/searchable-virtual-list.component.js.map +1 -0
- package/src/lib/components/site-live-notice.component.d.ts +39 -0
- package/src/lib/components/site-live-notice.component.js +95 -0
- package/src/lib/components/site-live-notice.component.js.map +1 -0
- package/src/lib/components/status-chip.component.d.ts +26 -0
- package/src/lib/components/status-chip.component.js +48 -0
- package/src/lib/components/status-chip.component.js.map +1 -0
- package/src/lib/const/list-filter-sentence.d.ts +1 -24
- package/src/lib/const/list-filter-sentence.js +3 -105
- package/src/lib/const/list-filter-sentence.js.map +1 -1
- package/src/lib/const/list-filter.d.ts +1 -219
- package/src/lib/const/list-filter.js +4 -282
- package/src/lib/const/list-filter.js.map +1 -1
- package/src/lib/const/list-grid-filter.d.ts +4 -25
- package/src/lib/const/list-grid-filter.js +20 -44
- package/src/lib/const/list-grid-filter.js.map +1 -1
- package/src/lib/const/list-query-plan.d.ts +1 -154
- package/src/lib/const/list-query-plan.js +4 -610
- package/src/lib/const/list-query-plan.js.map +1 -1
- package/src/lib/hooks/use-client-pagination.d.ts +25 -0
- package/src/lib/hooks/use-client-pagination.js +65 -0
- package/src/lib/hooks/use-client-pagination.js.map +1 -0
- package/src/lib/hooks/use-in-view.d.ts +16 -0
- package/src/lib/hooks/use-in-view.js +66 -0
- package/src/lib/hooks/use-in-view.js.map +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx/src/lib/const/list-filter.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { listFilterDay } from './list-filter-sentence'\n\n/**\n * ONE declaration of what a paged list can be filtered by (AGL-2501).\n *\n * A paged list filters on the SERVER or it does not filter: `filterMode=\"server\"`\n * stops the grid narrowing anything itself, so the panel shows the rows already\n * fetched — ten of them by default — and an operator the route does not answer\n * becomes a control that quietly does nothing. On a staff list whose whole job\n * is that nobody is missing, \"no matches\" is the one answer it must never give\n * wrongly.\n *\n * So a list declares its filterable fields ONCE, in a module both its route and\n * its page import. The declaration decides two things that must never disagree:\n * which operators the menu offers (here) and which predicates the query builds\n * (`applyListFilter`, server-side, which needs firebase-admin and so cannot\n * live in this file).\n *\n * ⛔ No runtime import of `@mui/x-data-grid` here. This grammar is read by\n * `list-query-plan`, which the storefront's server-side catalog query reaches\n * from a published page, and the grid's filter inputs are `'use client'`\n * modules: imported from the server graph they become client references that\n * every published page downloads. The grid's own operator objects are built\n * in `list-grid-filter` (`listFilterColumn`, `hiddenFilterColumns`).\n *\n * ## Why the menu is shorter than MUI's\n *\n * Firestore has equality, `in`, ranges and `array-contains`. Everything below\n * is built from those four:\n *\n * equals / isAnyOf equality and `in` (Firestore caps `in` at 30 values)\n * startsWith a range over the normalized lower-case key\n * endsWith a range over the key stored REVERSED — a range is\n * anchored at the FRONT of a value, so storing the value\n * backwards is the only way to ask about its end\n * contains `array-contains` over word-prefix tokens, so it is\n * WORD-level: \"coffee\" finds \"Acme Coffee\", \"offee\" does\n * not find anything\n * before / after ranges on a timestamp or a number\n * isNotEmpty `!= null`, which in Firestore also requires the field to\n * EXIST — which is the meaning wanted\n *\n * ⛔ `doesNotContain` is offered nowhere and cannot be. Firestore has no\n * negated substring match, and no denormalization fixes it: the inverse of a\n * token array is every string the value does not contain, which is unbounded.\n *\n * ⚠️ The two empty operators depend on how a field's WRITERS behave, which is\n * what `presence` declares. Firestore cannot query for absence at all:\n * `where(path, '==', null)` matches an explicit null and never a missing field,\n * while `where(path, '!=', null)` additionally requires the field to exist.\n * So a field that writers omit can answer `isNotEmpty` exactly and can never\n * answer `isEmpty` — it would say \"none\" to a question with real answers — and\n * a field that is always written answers both, but each with a foregone\n * result. Only a `nullable` field earns both operators for real.\n */\n\n/** How a field can be queried, which decides which operators it offers. */\nexport type ListFilterKind =\n | 'text'\n | 'exact'\n | 'boolean'\n | 'number'\n | 'date'\n | 'id'\n\nexport interface ListFilterField {\n /** The grid column's `field` — what the client sends back. */\n column: string\n kind: ListFilterKind\n /** The Firestore field path the predicate targets. */\n path: string\n /**\n * The normalized lower-case twin, for `equals` and `startsWith` on text.\n * Without one a text field offers neither: a raw value is case-sensitive, so\n * it would miss rather than fail.\n */\n lowerPath?: string\n /** Word-prefix token array, for `contains`. */\n tokensPath?: string\n /**\n * The token array holds OPAQUE IDS, matched byte for byte.\n *\n * A word token array is lower-cased by its writer, so a `contains` folds\n * the typed value the same way before it looks. An id array — the forms a\n * contact came in through, the companies they are linked to — is not: the\n * ids are minted with mixed case, and folding one would look up an id\n * nothing wrote. A field that says so is matched on the value exactly as\n * given, in the query and in memory alike.\n */\n verbatimTokens?: boolean\n /**\n * What a `contains` orders by. Defaults to `lowerPath`, then `path`.\n *\n * A field whose `tokensPath` IS its own value — a real tag array, matched\n * whole rather than by word prefix — has no lower-case twin to sort by, and\n * defaulting to `path` would order by the array itself. Naming a scalar here\n * keeps the composite index that combination needs an ordinary one.\n */\n containsOrderBy?: string\n /**\n * Which way a `contains` orders by `containsOrderBy`. Ascending unless the\n * field says otherwise; a list sorted newest-first orders its `contains`\n * the same way, so the composite it needs is the one it already declares\n * (AGL-3321).\n */\n containsOrderDirection?: 'asc' | 'desc'\n /** The reversed key, for `endsWith`. */\n reversedPath?: string\n /**\n * How the field's writers treat \"no value\", which is the only thing that\n * decides whether the empty operators mean anything:\n *\n * `sparse` (default) writers OMIT the field. `isNotEmpty` is exact;\n * `isEmpty` is unanswerable and so is not offered.\n * `nullable` writers store `null`. Both operators are exact and both can\n * return rows — the only case where offering them is useful.\n * `always` the field is never absent and never null. Both operators have\n * a foregone answer (all rows, then none), so neither is\n * offered: a control whose result is known is a control that\n * wastes the reader's time.\n */\n presence?: 'sparse' | 'nullable' | 'always'\n /**\n * The operators this field offers, replacing the derived list.\n *\n * Not every list is a Firestore query. The staff account list is Firebase\n * Auth, which cannot filter at ALL — so a filter there is answered by\n * scanning the pools and matching in memory, and plain JavaScript can do\n * things no index can: a mid-string `contains`, and `doesNotContain`. A\n * list whose substrate is more capable says so here rather than being held\n * to Firestore's limits by a shared default.\n *\n * Pair with {@link matchListFilter}, which is the matcher those lists use.\n */\n operators?: readonly string[]\n /**\n * Where to read this field from a ROW, when the list matches in memory.\n * Defaults to `path`. Only needed when the row's shape differs from the\n * document's — an Auth record's `staff` lives under `customClaims`.\n */\n rowPath?: string\n /**\n * The field lives where no query can reach it, so the list matches it\n * over the rows it has loaded and the translators refuse it.\n *\n * A contact's owner, stage and custom values sit on the viewing group's\n * FACET — a map keyed per group — and a `where` on a per-group path would\n * need an index per group. Declaring the field at all is what puts it in\n * the menu and in a saved view; saying it is window-only is what keeps a\n * clause on it from being sent to a query that would answer with a\n * permission error or nothing. The list says which clauses narrowed only\n * the window — see `listFilterPlan`.\n */\n windowOnly?: boolean\n /**\n * A `date` field stored as epoch MILLISECONDS (`…AtMs`) rather than as a\n * Timestamp. The query twins compare numbers for it, and the matcher reads\n * both already (AGL-3321).\n */\n storedAs?: 'timestamp' | 'millis'\n /**\n * The stored value is a PRESENCE MAP — `{ form: true, order: true }` —\n * and the filter asks about its keys.\n *\n * A contact's `sources` is such a map: one key per door the person came\n * in through, never an array. Matched as though it were the array of its\n * truthy keys, so `equals form` and `isAnyOf form,order` read the way a\n * reader expects; a query can serve `equals` as `sources.form == true`.\n */\n keysOf?: boolean\n}\n\n/** The empty-operators a field can honestly offer. See `presence`. */\nconst emptyOperators = (field: ListFilterField): string[] => {\n switch (field.presence ?? 'sparse') {\n case 'always':\n return []\n case 'nullable':\n return ['isEmpty', 'isNotEmpty']\n default:\n return ['isNotEmpty']\n }\n}\n\n/** The operators a field offers, derived from the paths it actually has. */\nexport function listFilterOperators(field: ListFilterField): string[] {\n if (field.operators) return [...field.operators]\n const empties = emptyOperators(field)\n switch (field.kind) {\n case 'text':\n return [\n ...(field.tokensPath ? ['contains'] : []),\n ...(field.lowerPath ? ['equals', 'startsWith'] : []),\n ...(field.reversedPath ? ['endsWith'] : []),\n ...empties,\n ]\n case 'exact':\n return ['equals', 'isAnyOf', ...empties]\n case 'id':\n // An id is never absent, so the empty operators would answer nothing.\n return ['equals', 'startsWith', 'isAnyOf']\n case 'boolean':\n return ['is']\n case 'number':\n return ['=', '!=', '>', '>=', '<', '<=', ...empties]\n case 'date':\n return ['is', 'after', 'onOrAfter', 'before', 'onOrBefore', ...empties]\n default:\n return []\n }\n}\n\n/** What a page sends the route: one field, one operator, one value. */\nexport interface ListFilterRequest {\n field: string\n op: string\n value: string\n}\n\n/** Operators that carry no value — the grid leaves `item.value` undefined. */\nconst VALUELESS = ['isEmpty', 'isNotEmpty']\n\n/**\n * The one filter item a server-paged list can act on, read off a grid model.\n *\n * ONE, because Firestore composes predicates only through indexes nobody built\n * for every pair of columns; the first usable item wins and the rest are the\n * reader's to remove. Every list read this off the model itself, and each did\n * it slightly differently — the common miss being `isEmpty`, which sets no\n * value at all and so was skipped by any check that required one.\n */\nexport function gridFilterRequest(model: {\n items?: Array<{ field?: unknown; operator?: unknown; value?: unknown }>\n}): ListFilterRequest | null {\n const usable = (model.items ?? []).find((item) => {\n if (!item.field || !item.operator) return false\n if (VALUELESS.includes(String(item.operator))) return true\n if (item.value === undefined || item.value === null) return false\n return Array.isArray(item.value)\n ? item.value.length > 0\n : String(item.value).trim() !== ''\n })\n if (!usable) return null\n return gridItemRequest(usable)\n}\n\n/** Whether a grid filter item asks anything at all — see `gridFilterRequest`. */\nconst gridItemUsable = (item: {\n field?: unknown\n operator?: unknown\n value?: unknown\n}): boolean => {\n if (!item.field || !item.operator) return false\n if (VALUELESS.includes(String(item.operator))) return true\n if (item.value === undefined || item.value === null) return false\n return Array.isArray(item.value)\n ? item.value.length > 0\n : String(item.value).trim() !== ''\n}\n\nconst gridItemRequest = (item: {\n field?: unknown\n operator?: unknown\n value?: unknown\n}): ListFilterRequest => {\n const raw = item.value\n const value = Array.isArray(raw)\n ? raw.join(',')\n : // A date column hands back a `Date`, whose default string form is a\n // locale rendering the server would have to guess at. ISO travels\n // unambiguously and `new Date` reads it back exactly.\n raw instanceof Date\n ? raw.toISOString()\n : raw === undefined || raw === null\n ? ''\n : String(raw)\n return { field: String(item.field), op: String(item.operator), value }\n}\n\n/**\n * EVERY usable filter item on a grid model, in the order the panel holds\n * them — for a list that keeps more than one clause (AGL-2617).\n *\n * The singular reader above picks the first because a query serves one;\n * a saved view carries a list of clauses and a list that applies it puts\n * the first servable one on the query and matches the rest over the rows\n * it loaded, which `listFilterPlan` in the instance library decides. The\n * two readers share one notion of \"usable\", so a clause the singular one\n * would take is a clause this one keeps.\n */\nexport function gridFilterRequests(model: {\n items?: Array<{ field?: unknown; operator?: unknown; value?: unknown }>\n}): ListFilterRequest[] {\n return (model.items ?? []).filter(gridItemUsable).map(gridItemRequest)\n}\n\nexport { listFilterDay, listFilterOperatorLabel } from './list-filter-sentence'\n\nconst readPath = (row: unknown, path: string): unknown =>\n path\n .split('.')\n .reduce<any>(\n (value, key) => (value == null ? undefined : value[key]),\n row as any,\n )\n\nconst asTime = (value: unknown): number | null => {\n if (value == null) return null\n if (value instanceof Date) return value.getTime()\n if (typeof value === 'number') return value\n // A Firestore timestamp, in either the admin shape or the serialized one.\n const seconds = (value as { seconds?: unknown }).seconds\n if (typeof seconds === 'number') return seconds * 1000\n const parsed = new Date(String(value)).getTime()\n return Number.isNaN(parsed) ? null : parsed\n}\n\n\n/**\n * Match ONE row against a filter, for a list that cannot push it to a query.\n *\n * The staff account list is the reason this exists: it is Firebase Auth, whose\n * `listUsers` takes a page size and a cursor and nothing else — no predicate,\n * no ordering, no search. A filter there is answered by walking the pools and\n * matching here, which is why that list can offer a mid-string `contains` and\n * a `doesNotContain` that a Firestore-backed list cannot.\n *\n * The declaration is still the same `ListFilterField`, so a list swapping\n * substrates changes where the matching happens and not what it offers.\n */\nexport function matchListFilter(\n row: unknown,\n fields: readonly ListFilterField[],\n input: ListFilterRequest | null,\n): boolean {\n if (!input) return true\n const field = fields.find((entry) => entry.column === input.field)\n if (!field) return true\n const stored = readPath(row, field.rowPath ?? field.path)\n // A presence map is matched as the array of its truthy keys — see `keysOf`.\n const value =\n field.keysOf && stored && typeof stored === 'object' && !Array.isArray(stored)\n ? Object.keys(stored as Record<string, unknown>).filter((key) =>\n Boolean((stored as Record<string, unknown>)[key]),\n )\n : stored\n const op = input.op\n\n const blank =\n value == null || value === '' || (Array.isArray(value) && value.length === 0)\n if (op === 'isEmpty') return blank\n if (op === 'isNotEmpty') return !blank\n\n const raw = (input.value ?? '').trim()\n if (field.kind === 'boolean') {\n if (raw !== 'true' && raw !== 'false') return true\n return Boolean(value) === (raw === 'true')\n }\n if (!raw) return true\n\n /*\n * An array the QUERY serves whole is matched by whole member, never by\n * substring of its joined form. A tag array asked `contains vip` holds the\n * tag `vip` or it does not — `vip-gold` is a different tag, and the\n * query's `array-contains` says so too, so the in-memory answer and the\n * served answer agree. An id array keeps its case (`verbatimTokens`); a\n * word array is folded the way its writer folded it. `isAnyOf` is any\n * member in the asked list, which is what a saved segment's \"any of these\n * tags\" becomes as a view clause. A presence map's keys are members too.\n *\n * A plain array with no token path is served by nothing, so there is no\n * query to agree with, and it falls through to the scalar match over its\n * joined text — the staff account list's providers, where `contains\n * google` finding `google.com` is the mid-string answer that list\n * documents (`operators`).\n */\n if (Array.isArray(value) && (field.tokensPath || field.keysOf)) {\n const fold = (entry: unknown) =>\n field.verbatimTokens ? String(entry) : String(entry).toLowerCase()\n const members = value.map(fold)\n const asked = fold(raw)\n switch (op) {\n case 'contains':\n case 'equals':\n case 'is':\n return members.includes(asked)\n case 'doesNotContain':\n case 'doesNotEqual':\n return !members.includes(asked)\n case 'isAnyOf':\n return asked\n .split(',')\n .map((entry) => entry.trim())\n .filter(Boolean)\n .some((entry) => members.includes(entry))\n default:\n return true\n }\n }\n\n if (field.kind === 'date') {\n const at = asTime(value)\n const day = listFilterDay(raw)\n if (at === null || Number.isNaN(day.getTime())) return false\n const start = new Date(day)\n start.setHours(0, 0, 0, 0)\n const end = new Date(start)\n end.setDate(end.getDate() + 1)\n switch (op) {\n // A day, not an instant — a stored time never equals midnight.\n case 'is':\n return at >= start.getTime() && at < end.getTime()\n case 'after':\n return at >= end.getTime()\n case 'onOrAfter':\n return at >= start.getTime()\n case 'before':\n return at < start.getTime()\n case 'onOrBefore':\n return at < end.getTime()\n default:\n return true\n }\n }\n\n if (field.kind === 'number') {\n const asked = Number(raw)\n const held = Number(value)\n if (!Number.isFinite(asked) || !Number.isFinite(held)) return false\n switch (op) {\n case '=':\n return held === asked\n case '!=':\n return held !== asked\n case '>':\n return held > asked\n case '>=':\n return held >= asked\n case '<':\n return held < asked\n case '<=':\n return held <= asked\n default:\n return true\n }\n }\n\n // A scalar id is matched as typed — see `verbatimTokens`; the array case\n // was answered above.\n if (field.verbatimTokens && op === 'contains') return value === raw\n const held = value == null ? '' : String(value).toLowerCase()\n const asked = raw.toLowerCase()\n switch (op) {\n case 'contains':\n return held.includes(asked)\n case 'doesNotContain':\n return !held.includes(asked)\n case 'equals':\n return held === asked\n case 'doesNotEqual':\n return held !== asked\n case 'startsWith':\n return held.startsWith(asked)\n case 'endsWith':\n return held.endsWith(asked)\n case 'isAnyOf':\n return asked\n .split(',')\n .map((entry) => entry.trim())\n .filter(Boolean)\n .includes(held)\n default:\n // An operator nothing here answers must not narrow the list to\n // nothing — that reads as \"no such record\" rather than \"not supported\".\n return true\n }\n}\n\n/** The visibility model that hides what {@link hiddenFilterColumns} added. */\nexport function hiddenFilterVisibility(\n fields: readonly ListFilterField[],\n visible: readonly string[],\n): Record<string, boolean> {\n return Object.fromEntries(\n fields\n .filter((field) => !visible.includes(field.column))\n .map((field) => [field.column, false]),\n )\n}\n"],"names":["listFilterDay","emptyOperators","field","presence","listFilterOperators","operators","empties","kind","tokensPath","lowerPath","reversedPath","VALUELESS","gridFilterRequest","model","usable","items","find","item","operator","includes","String","value","undefined","Array","isArray","length","trim","gridItemRequest","gridItemUsable","raw","join","Date","toISOString","op","gridFilterRequests","filter","map","listFilterOperatorLabel","readPath","row","path","split","reduce","key","asTime","getTime","seconds","parsed","Number","isNaN","matchListFilter","fields","input","entry","column","stored","rowPath","keysOf","Object","keys","Boolean","blank","fold","verbatimTokens","toLowerCase","members","asked","some","at","day","start","setHours","end","setDate","getDate","held","isFinite","startsWith","endsWith","hiddenFilterVisibility","visible","fromEntries"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,aAAa,QAAQ,4BAAwB;AA4KtD,oEAAoE,GACpE,MAAMC,iBAAiB,CAACC;QACdA;IAAR,QAAQA,kBAAAA,MAAMC,QAAQ,YAAdD,kBAAkB;QACxB,KAAK;YACH,OAAO,EAAE;QACX,KAAK;YACH,OAAO;gBAAC;gBAAW;aAAa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AAUA,MAAM3B,IAAI,IACzBS,MAAM,CAACyB,SACPzC,QAAQ,CAACwD;QACd;YACE,+DAA+D;YAC/D,wEAAwE;YACxE,OAAO;IACX;AACF;AAEA,4EAA4E,GAC5E,OAAO,SAASI,uBACd5B,MAAkC,EAClC6B,OAA0B;IAE1B,OAAOtB,OAAOuB,WAAW,CACvB9B,OACGhB,MAAM,CAAC,CAACjC,QAAU,CAAC8E,QAAQ7D,QAAQ,CAACjB,MAAMoD,MAAM,GAChDlB,GAAG,CAAC,CAAClC,QAAU;YAACA,MAAMoD,MAAM;YAAE;SAAM;AAE3C"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx/src/lib/const/list-filter.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*\n * The list filter grammar lives in a pure module, so a surface with no web UI\n * (the native app) plans the same queries; this path stays its web entry.\n */\nexport * from '@aglyn/shared-util-tools/list-query/list-filter'\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;CAGC,GACD,cAAc,kDAAiD"}
|
|
@@ -14,17 +14,10 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
import { type GridColDef, type
|
|
18
|
-
import { type ListFilterField
|
|
19
|
-
|
|
20
|
-
export
|
|
21
|
-
label?: string;
|
|
22
|
-
}
|
|
23
|
-
/** A choice for a field whose value is picked rather than typed. */
|
|
24
|
-
export interface ListFilterOption {
|
|
25
|
-
value: string;
|
|
26
|
-
label: string;
|
|
27
|
-
}
|
|
17
|
+
import { type GridColDef, type GridFilterOperator } from '@mui/x-data-grid';
|
|
18
|
+
import { type ListFilterField } from './list-filter';
|
|
19
|
+
import { type ListFilterClause, type ListFilterOption } from '@aglyn/shared-util-tools/list-query/list-filter-codecs';
|
|
20
|
+
export { type ListFilterClause, type ListFilterOption, type ListGridFilterCodec, listPlainCodec, listSelectCodec, } from '@aglyn/shared-util-tools/list-query/list-filter-codecs';
|
|
28
21
|
/**
|
|
29
22
|
* The MUI operators for a field — the same list `listFilterOperators` names,
|
|
30
23
|
* resolved to the grid's own operator objects so the panel keeps its native
|
|
@@ -63,20 +56,6 @@ export declare function hiddenFilterColumns(fields: readonly ListFilterField[],
|
|
|
63
56
|
filterable: boolean;
|
|
64
57
|
filterOperators?: GridFilterOperator[];
|
|
65
58
|
}>;
|
|
66
|
-
/**
|
|
67
|
-
* How one field's stored clause and the panel's item translate. A field
|
|
68
|
-
* with choices uses {@link listSelectCodec}; a typed one,
|
|
69
|
-
* {@link listPlainCodec}. A list whose clauses predate the panel supplies
|
|
70
|
-
* its own.
|
|
71
|
-
*/
|
|
72
|
-
export interface ListGridFilterCodec {
|
|
73
|
-
toItem: (clause: ListFilterClause) => Pick<GridFilterItem, 'operator' | 'value'> | null;
|
|
74
|
-
toClause: (item: GridFilterItem) => ListFilterClause | null;
|
|
75
|
-
}
|
|
76
|
-
/** A typed field: the stored operator IS the grid's. */
|
|
77
|
-
export declare const listPlainCodec: ListGridFilterCodec;
|
|
78
|
-
/** A picked field: `equals` shows as `is`, and `isAnyOf` holds a comma list. */
|
|
79
|
-
export declare const listSelectCodec: ListGridFilterCodec;
|
|
80
59
|
/** The select operators a field's allowed clause operators map to. */
|
|
81
60
|
export declare function listSelectOperators(allowed: readonly string[]): GridFilterOperator<any, any, any, import("@mui/x-data-grid").GridFilterInputValueProps>[];
|
|
82
61
|
/**
|
|
@@ -15,8 +15,26 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
|
15
15
|
* See the License for the specific language governing permissions and
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/ import { getGridBooleanOperators, getGridDateOperators, getGridNumericOperators, getGridSingleSelectOperators, getGridStringOperators } from "@mui/x-data-grid";
|
|
18
|
-
import {
|
|
19
|
-
|
|
18
|
+
import { listFilterOperators } from "./list-filter.js";
|
|
19
|
+
import { SELECT_TO_GRID } from "@aglyn/shared-util-tools/list-query/list-filter-codecs";
|
|
20
|
+
export { listPlainCodec, listSelectCodec } from "@aglyn/shared-util-tools/list-query/list-filter-codecs";
|
|
21
|
+
/*
|
|
22
|
+
* ONE path from a list's filter clauses to the data grid's own Filters panel
|
|
23
|
+
* and quick search, and back (AGL-3313, shared by every list since AGL-3317).
|
|
24
|
+
*
|
|
25
|
+
* A list stores what it is narrowed by as clauses — `{ field, op, value }`,
|
|
26
|
+
* the shape saved views hold — and edits them through the grid's toolbar
|
|
27
|
+
* rather than controls of its own. What a list declares is its fields, as
|
|
28
|
+
* the `ListFilterField` grammar (`./list-filter`), plus the choices of the
|
|
29
|
+
* fields whose values are picked rather than typed. The grid then offers
|
|
30
|
+
* each as a typed column: a `singleSelect` with its choices where there are
|
|
31
|
+
* choices, the operators the grammar allows otherwise.
|
|
32
|
+
*
|
|
33
|
+
* The clauses keep their stored shape, so a view saved before the panel
|
|
34
|
+
* reads unchanged: the panel shows `equals` as the select's `is` and writes
|
|
35
|
+
* `is` back as `equals`, and a list whose clauses were stored in some other
|
|
36
|
+
* shape says so with a codec.
|
|
37
|
+
*/ const operatorPool = (kind)=>{
|
|
20
38
|
switch(kind){
|
|
21
39
|
case 'boolean':
|
|
22
40
|
return getGridBooleanOperators();
|
|
@@ -78,48 +96,6 @@ const operatorPool = (kind)=>{
|
|
|
78
96
|
}, listFilterColumn(fields, field.column));
|
|
79
97
|
}).filter((column)=>column.filterable);
|
|
80
98
|
}
|
|
81
|
-
/** The grid operator each stored select operator shows as. */ const SELECT_TO_GRID = {
|
|
82
|
-
equals: 'is',
|
|
83
|
-
doesNotEqual: 'not',
|
|
84
|
-
isAnyOf: 'isAnyOf'
|
|
85
|
-
};
|
|
86
|
-
const SELECT_FROM_GRID = {
|
|
87
|
-
is: 'equals',
|
|
88
|
-
not: 'doesNotEqual',
|
|
89
|
-
isAnyOf: 'isAnyOf'
|
|
90
|
-
};
|
|
91
|
-
/** The panel's item as a clause, through the grammar's one notion of "usable". */ const plainClause = (item)=>{
|
|
92
|
-
var _gridFilterRequests_;
|
|
93
|
-
return (_gridFilterRequests_ = gridFilterRequests({
|
|
94
|
-
items: [
|
|
95
|
-
item
|
|
96
|
-
]
|
|
97
|
-
})[0]) != null ? _gridFilterRequests_ : null;
|
|
98
|
-
};
|
|
99
|
-
/** A typed field: the stored operator IS the grid's. */ export const listPlainCodec = {
|
|
100
|
-
toItem: (clause)=>({
|
|
101
|
-
operator: clause.op,
|
|
102
|
-
value: clause.value === '' ? undefined : clause.value
|
|
103
|
-
}),
|
|
104
|
-
toClause: plainClause
|
|
105
|
-
};
|
|
106
|
-
/** A picked field: `equals` shows as `is`, and `isAnyOf` holds a comma list. */ export const listSelectCodec = {
|
|
107
|
-
toItem: (clause)=>{
|
|
108
|
-
const operator = SELECT_TO_GRID[clause.op];
|
|
109
|
-
if (!operator) return null;
|
|
110
|
-
return {
|
|
111
|
-
operator,
|
|
112
|
-
value: operator === 'isAnyOf' ? clause.value.split(',').map((entry)=>entry.trim()).filter(Boolean) : clause.value
|
|
113
|
-
};
|
|
114
|
-
},
|
|
115
|
-
toClause: (item)=>{
|
|
116
|
-
const op = SELECT_FROM_GRID[String(item.operator)];
|
|
117
|
-
const request = op ? plainClause(item) : null;
|
|
118
|
-
return request && op ? _extends({}, request, {
|
|
119
|
-
op
|
|
120
|
-
}) : null;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
99
|
/** The select operators a field's allowed clause operators map to. */ export function listSelectOperators(allowed) {
|
|
124
100
|
const shown = allowed.map((op)=>SELECT_TO_GRID[op]).filter(Boolean);
|
|
125
101
|
return getGridSingleSelectOperators().filter((operator)=>shown.includes(operator.value));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx/src/lib/const/list-grid-filter.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n getGridBooleanOperators,\n getGridDateOperators,\n getGridNumericOperators,\n getGridSingleSelectOperators,\n getGridStringOperators,\n type GridColDef,\n type GridFilterItem,\n type GridFilterOperator,\n} from '@mui/x-data-grid'\nimport {\n gridFilterRequests,\n type ListFilterField,\n type ListFilterKind,\n type ListFilterRequest,\n listFilterOperators,\n} from './list-filter'\n\n/*\n * ONE path from a list's filter clauses to the data grid's own Filters panel\n * and quick search, and back (AGL-3313, shared by every list since AGL-3317).\n *\n * A list stores what it is narrowed by as clauses — `{ field, op, value }`,\n * the shape saved views hold — and edits them through the grid's toolbar\n * rather than controls of its own. What a list declares is its fields, as\n * the `ListFilterField` grammar (`./list-filter`), plus the choices of the\n * fields whose values are picked rather than typed. The grid then offers\n * each as a typed column: a `singleSelect` with its choices where there are\n * choices, the operators the grammar allows otherwise.\n *\n * The clauses keep their stored shape, so a view saved before the panel\n * reads unchanged: the panel shows `equals` as the select's `is` and writes\n * `is` back as `equals`, and a list whose clauses were stored in some other\n * shape says so with a codec.\n */\n\n/** One clause a list is narrowed by; `label` names a picked value on a chip. */\nexport interface ListFilterClause extends ListFilterRequest {\n label?: string\n}\n\n/** A choice for a field whose value is picked rather than typed. */\nexport interface ListFilterOption {\n value: string\n label: string\n}\n\nconst operatorPool = (kind: ListFilterKind): GridFilterOperator[] => {\n switch (kind) {\n case 'boolean':\n return getGridBooleanOperators()\n case 'number':\n return getGridNumericOperators()\n case 'date':\n return getGridDateOperators()\n default:\n return getGridStringOperators()\n }\n}\n\n/**\n * The MUI operators for a field — the same list `listFilterOperators` names,\n * resolved to the grid's own operator objects so the panel keeps its native\n * inputs (a date picker for a date, a number field for a number).\n */\nexport function gridFilterOperators(\n field: ListFilterField,\n): GridFilterOperator[] {\n const allowed = listFilterOperators(field)\n return operatorPool(field.kind).filter((operator) =>\n allowed.includes(operator.value),\n )\n}\n\n/**\n * Spread onto a `GridColDef` to make a column filterable exactly as far as the\n * query can serve it. A column with NO declared field is turned off entirely —\n * deliberately, because the alternative is a funnel icon that opens a panel\n * nothing honours.\n */\nexport function listFilterColumn(\n fields: readonly ListFilterField[],\n column: string,\n): { filterable: boolean; filterOperators?: GridFilterOperator[] } {\n const field = fields.find((entry) => entry.column === column)\n if (!field) return { filterable: false }\n const operators = gridFilterOperators(field)\n return operators.length\n ? { filterable: true, filterOperators: operators }\n : { filterable: false }\n}\n\n/**\n * Fields a reader can filter by that are NOT columns on the table.\n *\n * MUI's filter panel lists COLUMNS — `gridFilterableColumnDefinitionsSelector`\n * reads every column definition, hidden ones included — so a filterable field\n * with no column is a field nobody can reach however well the route answers it.\n * Declaring it as a permanently hidden column keeps one source of truth, the\n * field list, instead of a second list of \"extra filters\" that drifts from it.\n *\n * `hideable: false` keeps them out of Manage columns as well: a column with no\n * `renderCell` and no width has nothing to show, and a reader who unhid one\n * would get a strip of blank cells for their trouble.\n *\n * Pair with {@link hiddenFilterVisibility}, which is what actually hides them.\n */\nexport function hiddenFilterColumns(\n fields: readonly ListFilterField[],\n visible: readonly string[],\n headers: Readonly<Record<string, string>> = {},\n): Array<{\n field: string\n headerName: string\n hideable: boolean\n filterable: boolean\n filterOperators?: GridFilterOperator[]\n}> {\n return fields\n .filter((field) => !visible.includes(field.column))\n .map((field) => ({\n field: field.column,\n headerName: headers[field.column] ?? field.column,\n hideable: false,\n ...listFilterColumn(fields, field.column),\n }))\n .filter((column) => column.filterable)\n}\n\n/** The grid operator each stored select operator shows as. */\nconst SELECT_TO_GRID: Readonly<Record<string, string>> = {\n equals: 'is',\n doesNotEqual: 'not',\n isAnyOf: 'isAnyOf',\n}\nconst SELECT_FROM_GRID: Readonly<Record<string, string>> = {\n is: 'equals',\n not: 'doesNotEqual',\n isAnyOf: 'isAnyOf',\n}\n\n/**\n * How one field's stored clause and the panel's item translate. A field\n * with choices uses {@link listSelectCodec}; a typed one,\n * {@link listPlainCodec}. A list whose clauses predate the panel supplies\n * its own.\n */\nexport interface ListGridFilterCodec {\n toItem: (clause: ListFilterClause) => Pick<GridFilterItem, 'operator' | 'value'> | null\n toClause: (item: GridFilterItem) => ListFilterClause | null\n}\n\n/** The panel's item as a clause, through the grammar's one notion of \"usable\". */\nconst plainClause = (item: GridFilterItem): ListFilterClause | null =>\n gridFilterRequests({ items: [item] })[0] ?? null\n\n/** A typed field: the stored operator IS the grid's. */\nexport const listPlainCodec: ListGridFilterCodec = {\n toItem: (clause) => ({\n operator: clause.op,\n value: clause.value === '' ? undefined : clause.value,\n }),\n toClause: plainClause,\n}\n\n/** A picked field: `equals` shows as `is`, and `isAnyOf` holds a comma list. */\nexport const listSelectCodec: ListGridFilterCodec = {\n toItem: (clause) => {\n const operator = SELECT_TO_GRID[clause.op]\n if (!operator) return null\n return {\n operator,\n value:\n operator === 'isAnyOf'\n ? clause.value.split(',').map((entry) => entry.trim()).filter(Boolean)\n : clause.value,\n }\n },\n toClause: (item) => {\n const op = SELECT_FROM_GRID[String(item.operator)]\n const request = op ? plainClause(item) : null\n return request && op ? { ...request, op } : null\n },\n}\n\n/** The select operators a field's allowed clause operators map to. */\nexport function listSelectOperators(allowed: readonly string[]) {\n const shown = allowed.map((op) => SELECT_TO_GRID[op]).filter(Boolean)\n return getGridSingleSelectOperators().filter((operator) =>\n shown.includes(operator.value),\n )\n}\n\n/**\n * The list's columns, each made filterable exactly as far as its field is\n * declared, and every declared field that is not a column added as a\n * permanently hidden one — the panel lists columns, so a field with none\n * could not be reached (`hiddenFilterColumns`).\n *\n * A field with choices becomes a `singleSelect` over them, whatever the\n * column rendered before; one without keeps the grammar's operators; a\n * column no field declares offers no filter, because the list, not the\n * grid, answers every filter and would have nothing to answer it with.\n */\nexport function listFilterGridColumns(\n columns: readonly GridColDef[],\n fields: readonly ListFilterField[],\n options: Readonly<Record<string, readonly ListFilterOption[]>> = {},\n headers: Readonly<Record<string, string>> = {},\n): GridColDef[] {\n const selectProps = (field: ListFilterField) => {\n const choices = options[field.column] ?? []\n const operators = listSelectOperators(listFilterOperators(field))\n return {\n type: 'singleSelect' as const,\n valueOptions: choices.map((choice) => ({ value: choice.value, label: choice.label })),\n filterable: choices.length > 0 && operators.length > 0,\n filterOperators: operators,\n }\n }\n /*\n * A column made a select keeps what it DREW. The grid formats a\n * `singleSelect` cell as the label of the option its value matches, and as\n * nothing when none does — so a column whose `valueGetter` hands back a\n * label (an address for an actor id, a site name for a scope id) went\n * blank the moment it gained a filter (AGL-3321). A column with its own\n * `renderCell` is left alone; any other draws the matching option's label\n * when there is one, and its own value when there is not.\n */\n const keepsItsCell = (column: GridColDef, field: ListFilterField) => {\n if (column.renderCell) return {}\n const labels = new Map(\n (options[field.column] ?? []).map((choice) => [choice.value, choice.label]),\n )\n return {\n renderCell: (params: { value?: unknown }) => {\n const value = params.value\n if (value === undefined || value === null) return ''\n return labels.get(String(value)) ?? String(value)\n },\n }\n }\n const shown = columns.map((column): GridColDef => {\n if (column.filterable === false && column.hideable === false) return column\n const field = fields.find((entry) => entry.column === column.field)\n if (!field) return { ...column, filterable: false }\n if (options[field.column]) {\n return { ...column, ...selectProps(field), ...keepsItsCell(column, field) } as GridColDef\n }\n return { ...column, ...listFilterColumn(fields, field.column) }\n })\n const present = columns.map((column) => column.field)\n /*\n * A field with choices is judged filterable by its choices, not by the\n * grid's operators for its kind: a Yes/No `boolean` field allows `equals`,\n * which the grid's boolean pool names `is`, so judged the plain way it has\n * no operator and was dropped before its choices could make it a select —\n * leaving a served filter nobody could reach (AGL-3332's Clicked). A field\n * with choices stays a column even while they are empty (products not yet\n * loaded): the list still reads a clause on it back through that column.\n */\n const hidden = fields\n .filter((field) => !present.includes(field.column))\n .flatMap((field): GridColDef[] => {\n const base = {\n field: field.column,\n headerName: headers[field.column] ?? field.column,\n hideable: false,\n }\n if (options[field.column]) return [{ ...base, ...selectProps(field) } as GridColDef]\n const plain = listFilterColumn(fields, field.column)\n return plain.filterable ? [{ ...base, ...plain } as GridColDef] : []\n })\n return [...shown, ...hidden]\n}\n\n/**\n * Whether a row answers a quick search: every whitespace-separated word\n * appears, case-insensitively, in SOME of the row's searched values. A\n * blank search matches every row, so an emptied box is the list unfiltered.\n * An array value (tags) is searched member by member.\n */\nexport function listRowMatchesSearch(\n row: object,\n paths: readonly string[],\n words: readonly string[],\n): boolean {\n const asked = words.map((word) => word.trim().toLowerCase()).filter(Boolean)\n if (!asked.length) return true\n const values = paths\n .flatMap((path) => {\n const value = path\n .split('.')\n .reduce<unknown>(\n (at, key) => (at == null ? undefined : (at as Record<string, unknown>)[key]),\n row,\n )\n return Array.isArray(value) ? value : [value]\n })\n .filter((value): value is string | number => typeof value === 'string' || typeof value === 'number')\n .map((value) => String(value).toLowerCase())\n .filter(Boolean)\n return asked.every((word) => values.some((value) => value.includes(word)))\n}\n\n/**\n * The clauses with one field's clause set: replaced in place where the field\n * already had one, appended where it did not, removed when `next` is null.\n * A field holds ONE clause, which is what the panel edits.\n */\nexport function upsertListFilterClause<Clause extends ListFilterClause>(\n clauses: readonly Clause[],\n field: string,\n next: Clause | null,\n): Clause[] {\n const at = clauses.findIndex((clause) => clause.field === field)\n const rest = clauses.filter((clause) => clause.field !== field)\n if (!next) return rest\n if (at === -1) return [...rest, next]\n return [...rest.slice(0, at), next, ...rest.slice(at)]\n}\n\nexport { listFilterClauseSentence } from './list-filter-sentence'\n"],"names":["getGridBooleanOperators","getGridDateOperators","getGridNumericOperators","getGridSingleSelectOperators","getGridStringOperators","gridFilterRequests","listFilterOperators","operatorPool","kind","gridFilterOperators","field","allowed","filter","operator","includes","value","listFilterColumn","fields","column","find","entry","filterable","operators","length","filterOperators","hiddenFilterColumns","visible","headers","map","headerName","hideable","SELECT_TO_GRID","equals","doesNotEqual","isAnyOf","SELECT_FROM_GRID","is","not","plainClause","item","items","listPlainCodec","toItem","clause","op","undefined","toClause","listSelectCodec","split","trim","Boolean","String","request","listSelectOperators","shown","listFilterGridColumns","columns","options","selectProps","choices","type","valueOptions","choice","label","keepsItsCell","renderCell","labels","Map","params","get","present","hidden","flatMap","base","plain","listRowMatchesSearch","row","paths","words","asked","word","toLowerCase","values","path","reduce","at","key","Array","isArray","every","some","upsertListFilterClause","clauses","next","findIndex","rest","slice","listFilterClauseSentence"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,uBAAuB,EACvBC,oBAAoB,EACpBC,uBAAuB,EACvBC,4BAA4B,EAC5BC,sBAAsB,QAIjB,mBAAkB;AACzB,SACEC,kBAAkB,EAIlBC,mBAAmB,QACd,mBAAe;AA+BtB,MAAMC,eAAe,CAACC;IACpB,OAAQA;QACN,KAAK;YACH,OAAOR;QACT,KAAK;YACH,OAAOE;QACT,KAAK;YACH,OAAOD;QACT;YACE,OAAOG;IACX;AACF;AAEA;;;;CAIC,GACD,OAAO,SAASK,oBACdC,KAAsB;IAEtB,MAAMC,UAAUL,oBAAoBI;IACpC,OAAOH,aAAaG,MAAMF,IAAI,EAAEI,MAAM,CAAC,CAACC,WACtCF,QAAQG,QAAQ,CAACD,SAASE,KAAK;AAEnC;AAEA;;;;;CAKC,GACD,OAAO,SAASC,iBACdC,MAAkC,EAClCC,MAAc;IAEd,MAAMR,QAAQO,OAAOE,IAAI,CAAC,CAACC,QAAUA,MAAMF,MAAM,KAAKA;IACtD,IAAI,CAACR,OAAO,OAAO;QAAEW,YAAY;IAAM;IACvC,MAAMC,YAAY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M,CAAC,CAAC+B,SAAWA,OAAOjC,KAAK,KAAKA;IACzD,IAAI,CAACmF,MAAM,OAAOE;IAClB,IAAIV,OAAO,CAAC,GAAG,OAAO;WAAIU;QAAMF;KAAK;IACrC,OAAO;WAAIE,KAAKC,KAAK,CAAC,GAAGX;QAAKQ;WAASE,KAAKC,KAAK,CAACX;KAAI;AACxD;AAEA,SAASY,wBAAwB,QAAQ,4BAAwB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx/src/lib/const/list-grid-filter.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n getGridBooleanOperators,\n getGridDateOperators,\n getGridNumericOperators,\n getGridSingleSelectOperators,\n getGridStringOperators,\n type GridColDef,\n type GridFilterOperator,\n} from '@mui/x-data-grid'\nimport {\n type ListFilterField,\n type ListFilterKind,\n listFilterOperators,\n} from './list-filter'\nimport {\n type ListFilterClause,\n type ListFilterOption,\n SELECT_TO_GRID,\n} from '@aglyn/shared-util-tools/list-query/list-filter-codecs'\n\nexport {\n type ListFilterClause,\n type ListFilterOption,\n type ListGridFilterCodec,\n listPlainCodec,\n listSelectCodec,\n} from '@aglyn/shared-util-tools/list-query/list-filter-codecs'\n\n/*\n * ONE path from a list's filter clauses to the data grid's own Filters panel\n * and quick search, and back (AGL-3313, shared by every list since AGL-3317).\n *\n * A list stores what it is narrowed by as clauses — `{ field, op, value }`,\n * the shape saved views hold — and edits them through the grid's toolbar\n * rather than controls of its own. What a list declares is its fields, as\n * the `ListFilterField` grammar (`./list-filter`), plus the choices of the\n * fields whose values are picked rather than typed. The grid then offers\n * each as a typed column: a `singleSelect` with its choices where there are\n * choices, the operators the grammar allows otherwise.\n *\n * The clauses keep their stored shape, so a view saved before the panel\n * reads unchanged: the panel shows `equals` as the select's `is` and writes\n * `is` back as `equals`, and a list whose clauses were stored in some other\n * shape says so with a codec.\n */\n\nconst operatorPool = (kind: ListFilterKind): GridFilterOperator[] => {\n switch (kind) {\n case 'boolean':\n return getGridBooleanOperators()\n case 'number':\n return getGridNumericOperators()\n case 'date':\n return getGridDateOperators()\n default:\n return getGridStringOperators()\n }\n}\n\n/**\n * The MUI operators for a field — the same list `listFilterOperators` names,\n * resolved to the grid's own operator objects so the panel keeps its native\n * inputs (a date picker for a date, a number field for a number).\n */\nexport function gridFilterOperators(\n field: ListFilterField,\n): GridFilterOperator[] {\n const allowed = listFilterOperators(field)\n return operatorPool(field.kind).filter((operator) =>\n allowed.includes(operator.value),\n )\n}\n\n/**\n * Spread onto a `GridColDef` to make a column filterable exactly as far as the\n * query can serve it. A column with NO declared field is turned off entirely —\n * deliberately, because the alternative is a funnel icon that opens a panel\n * nothing honours.\n */\nexport function listFilterColumn(\n fields: readonly ListFilterField[],\n column: string,\n): { filterable: boolean; filterOperators?: GridFilterOperator[] } {\n const field = fields.find((entry) => entry.column === column)\n if (!field) return { filterable: false }\n const operators = gridFilterOperators(field)\n return operators.length\n ? { filterable: true, filterOperators: operators }\n : { filterable: false }\n}\n\n/**\n * Fields a reader can filter by that are NOT columns on the table.\n *\n * MUI's filter panel lists COLUMNS — `gridFilterableColumnDefinitionsSelector`\n * reads every column definition, hidden ones included — so a filterable field\n * with no column is a field nobody can reach however well the route answers it.\n * Declaring it as a permanently hidden column keeps one source of truth, the\n * field list, instead of a second list of \"extra filters\" that drifts from it.\n *\n * `hideable: false` keeps them out of Manage columns as well: a column with no\n * `renderCell` and no width has nothing to show, and a reader who unhid one\n * would get a strip of blank cells for their trouble.\n *\n * Pair with {@link hiddenFilterVisibility}, which is what actually hides them.\n */\nexport function hiddenFilterColumns(\n fields: readonly ListFilterField[],\n visible: readonly string[],\n headers: Readonly<Record<string, string>> = {},\n): Array<{\n field: string\n headerName: string\n hideable: boolean\n filterable: boolean\n filterOperators?: GridFilterOperator[]\n}> {\n return fields\n .filter((field) => !visible.includes(field.column))\n .map((field) => ({\n field: field.column,\n headerName: headers[field.column] ?? field.column,\n hideable: false,\n ...listFilterColumn(fields, field.column),\n }))\n .filter((column) => column.filterable)\n}\n\n/** The select operators a field's allowed clause operators map to. */\nexport function listSelectOperators(allowed: readonly string[]) {\n const shown = allowed.map((op) => SELECT_TO_GRID[op]).filter(Boolean)\n return getGridSingleSelectOperators().filter((operator) =>\n shown.includes(operator.value),\n )\n}\n\n/**\n * The list's columns, each made filterable exactly as far as its field is\n * declared, and every declared field that is not a column added as a\n * permanently hidden one — the panel lists columns, so a field with none\n * could not be reached (`hiddenFilterColumns`).\n *\n * A field with choices becomes a `singleSelect` over them, whatever the\n * column rendered before; one without keeps the grammar's operators; a\n * column no field declares offers no filter, because the list, not the\n * grid, answers every filter and would have nothing to answer it with.\n */\nexport function listFilterGridColumns(\n columns: readonly GridColDef[],\n fields: readonly ListFilterField[],\n options: Readonly<Record<string, readonly ListFilterOption[]>> = {},\n headers: Readonly<Record<string, string>> = {},\n): GridColDef[] {\n const selectProps = (field: ListFilterField) => {\n const choices = options[field.column] ?? []\n const operators = listSelectOperators(listFilterOperators(field))\n return {\n type: 'singleSelect' as const,\n valueOptions: choices.map((choice) => ({ value: choice.value, label: choice.label })),\n filterable: choices.length > 0 && operators.length > 0,\n filterOperators: operators,\n }\n }\n /*\n * A column made a select keeps what it DREW. The grid formats a\n * `singleSelect` cell as the label of the option its value matches, and as\n * nothing when none does — so a column whose `valueGetter` hands back a\n * label (an address for an actor id, a site name for a scope id) went\n * blank the moment it gained a filter (AGL-3321). A column with its own\n * `renderCell` is left alone; any other draws the matching option's label\n * when there is one, and its own value when there is not.\n */\n const keepsItsCell = (column: GridColDef, field: ListFilterField) => {\n if (column.renderCell) return {}\n const labels = new Map(\n (options[field.column] ?? []).map((choice) => [choice.value, choice.label]),\n )\n return {\n renderCell: (params: { value?: unknown }) => {\n const value = params.value\n if (value === undefined || value === null) return ''\n return labels.get(String(value)) ?? String(value)\n },\n }\n }\n const shown = columns.map((column): GridColDef => {\n if (column.filterable === false && column.hideable === false) return column\n const field = fields.find((entry) => entry.column === column.field)\n if (!field) return { ...column, filterable: false }\n if (options[field.column]) {\n return { ...column, ...selectProps(field), ...keepsItsCell(column, field) } as GridColDef\n }\n return { ...column, ...listFilterColumn(fields, field.column) }\n })\n const present = columns.map((column) => column.field)\n /*\n * A field with choices is judged filterable by its choices, not by the\n * grid's operators for its kind: a Yes/No `boolean` field allows `equals`,\n * which the grid's boolean pool names `is`, so judged the plain way it has\n * no operator and was dropped before its choices could make it a select —\n * leaving a served filter nobody could reach (AGL-3332's Clicked). A field\n * with choices stays a column even while they are empty (products not yet\n * loaded): the list still reads a clause on it back through that column.\n */\n const hidden = fields\n .filter((field) => !present.includes(field.column))\n .flatMap((field): GridColDef[] => {\n const base = {\n field: field.column,\n headerName: headers[field.column] ?? field.column,\n hideable: false,\n }\n if (options[field.column]) return [{ ...base, ...selectProps(field) } as GridColDef]\n const plain = listFilterColumn(fields, field.column)\n return plain.filterable ? [{ ...base, ...plain } as GridColDef] : []\n })\n return [...shown, ...hidden]\n}\n\n/**\n * Whether a row answers a quick search: every whitespace-separated word\n * appears, case-insensitively, in SOME of the row's searched values. A\n * blank search matches every row, so an emptied box is the list unfiltered.\n * An array value (tags) is searched member by member.\n */\nexport function listRowMatchesSearch(\n row: object,\n paths: readonly string[],\n words: readonly string[],\n): boolean {\n const asked = words.map((word) => word.trim().toLowerCase()).filter(Boolean)\n if (!asked.length) return true\n const values = paths\n .flatMap((path) => {\n const value = path\n .split('.')\n .reduce<unknown>(\n (at, key) => (at == null ? undefined : (at as Record<string, unknown>)[key]),\n row,\n )\n return Array.isArray(value) ? value : [value]\n })\n .filter((value): value is string | number => typeof value === 'string' || typeof value === 'number')\n .map((value) => String(value).toLowerCase())\n .filter(Boolean)\n return asked.every((word) => values.some((value) => value.includes(word)))\n}\n\n/**\n * The clauses with one field's clause set: replaced in place where the field\n * already had one, appended where it did not, removed when `next` is null.\n * A field holds ONE clause, which is what the panel edits.\n */\nexport function upsertListFilterClause<Clause extends ListFilterClause>(\n clauses: readonly Clause[],\n field: string,\n next: Clause | null,\n): Clause[] {\n const at = clauses.findIndex((clause) => clause.field === field)\n const rest = clauses.filter((clause) => clause.field !== field)\n if (!next) return rest\n if (at === -1) return [...rest, next]\n return [...rest.slice(0, at), next, ...rest.slice(at)]\n}\n\nexport { listFilterClauseSentence } from './list-filter-sentence'\n"],"names":["getGridBooleanOperators","getGridDateOperators","getGridNumericOperators","getGridSingleSelectOperators","getGridStringOperators","listFilterOperators","SELECT_TO_GRID","listPlainCodec","listSelectCodec","operatorPool","kind","gridFilterOperators","field","allowed","filter","operator","includes","value","listFilterColumn","fields","column","find","entry","filterable","operators","length","filterOperators","hiddenFilterColumns","visible","headers","map","headerName","hideable","listSelectOperators","shown","op","Boolean","listFilterGridColumns","columns","options","selectProps","choices","type","valueOptions","choice","label","keepsItsCell","renderCell","labels","Map","params","undefined","get","String","present","hidden","flatMap","base","plain","listRowMatchesSearch","row","paths","words","asked","word","trim","toLowerCase","values","path","split","reduce","at","key","Array","isArray","every","some","upsertListFilterClause","clauses","next","findIndex","clause","rest","slice","listFilterClauseSentence"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,uBAAuB,EACvBC,oBAAoB,EACpBC,uBAAuB,EACvBC,4BAA4B,EAC5BC,sBAAsB,QAGjB,mBAAkB;AACzB,SAGEC,mBAAmB,QACd,mBAAe;AACtB,SAGEC,cAAc,QACT,yDAAwD;AAE/D,SAIEC,cAAc,EACdC,eAAe,QACV,yDAAwD;AAE/D;;;;;;;;;;;;;;;;CAgBC,GAED,MAAMC,eAAe,CAACC;IACpB,OAAQA;QACN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N,MACZL,OAAO,CAAC,CAACY;QACR,MAAMnD,QAAQmD,KACXC,KAAK,CAAC,KACNC,MAAM,CACL,CAACC,IAAIC,MAASD,MAAM,OAAOpB,YAAY,AAACoB,EAA8B,CAACC,IAAI,EAC3EZ;QAEJ,OAAOa,MAAMC,OAAO,CAACzD,SAASA,QAAQ;YAACA;SAAM;IAC/C,GACCH,MAAM,CAAC,CAACG,QAAoC,OAAOA,UAAU,YAAY,OAAOA,UAAU,UAC1Fa,GAAG,CAAC,CAACb,QAAUoC,OAAOpC,OAAOiD,WAAW,IACxCpD,MAAM,CAACsB;IACV,OAAO2B,MAAMY,KAAK,CAAC,CAACX,OAASG,OAAOS,IAAI,CAAC,CAAC3D,QAAUA,MAAMD,QAAQ,CAACgD;AACrE;AAEA;;;;CAIC,GACD,OAAO,SAASa,uBACdC,OAA0B,EAC1BlE,KAAa,EACbmE,IAAmB;IAEnB,MAAMR,KAAKO,QAAQE,SAAS,CAAC,CAACC,SAAWA,OAAOrE,KAAK,KAAKA;IAC1D,MAAMsE,OAAOJ,QAAQhE,MAAM,CAAC,CAACmE,SAAWA,OAAOrE,KAAK,KAAKA;IACzD,IAAI,CAACmE,MAAM,OAAOG;IAClB,IAAIX,OAAO,CAAC,GAAG,OAAO;WAAIW;QAAMH;KAAK;IACrC,OAAO;WAAIG,KAAKC,KAAK,CAAC,GAAGZ;QAAKQ;WAASG,KAAKC,KAAK,CAACZ;KAAI;AACxD;AAEA,SAASa,wBAAwB,QAAQ,4BAAwB"}
|
|
@@ -14,157 +14,4 @@
|
|
|
14
14
|
* See the License for the specific language governing permissions and
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* How the written search fields were normalized, so a typed value becomes the
|
|
20
|
-
* key the query can match: the lower-cased key (`equals`, `startsWith`), the
|
|
21
|
-
* one word-prefix token (`contains`, search), and the reversed key
|
|
22
|
-
* (`endsWith`). `maxPrefix` is the longest token a writer stores.
|
|
23
|
-
*/
|
|
24
|
-
export interface ListQueryNormalizers {
|
|
25
|
-
key(value: string): string;
|
|
26
|
-
token(value: string): string;
|
|
27
|
-
reversed(value: string): string;
|
|
28
|
-
maxPrefix: number;
|
|
29
|
-
}
|
|
30
|
-
/** A predicate on the query, SDK-free. `path` `__name__` is the document id. */
|
|
31
|
-
export type ListQueryOp = '==' | '!=' | '<' | '<=' | '>' | '>=' | 'in' | 'array-contains' | 'array-contains-any';
|
|
32
|
-
export type ListQueryValue = string | number | boolean | null | Date | readonly (string | number)[];
|
|
33
|
-
export interface ListQueryFilter {
|
|
34
|
-
path: string;
|
|
35
|
-
op: ListQueryOp;
|
|
36
|
-
value: ListQueryValue;
|
|
37
|
-
}
|
|
38
|
-
export interface ListQuerySort {
|
|
39
|
-
path: string;
|
|
40
|
-
direction: 'asc' | 'desc';
|
|
41
|
-
/** The grid column this order sorts, when the list lets the grid sort by it. */
|
|
42
|
-
column?: string;
|
|
43
|
-
}
|
|
44
|
-
/** The document id, as a path. */
|
|
45
|
-
export declare const LIST_QUERY_ID_PATH = "__name__";
|
|
46
|
-
/** Firestore's cap on disjunctions — `in` values times `array-contains-any` values. */
|
|
47
|
-
export declare const LIST_QUERY_DISJUNCTIONS = 30;
|
|
48
|
-
export interface ListQueryDeclaration {
|
|
49
|
-
/** Every field the Filters panel may name. */
|
|
50
|
-
fields: readonly ListFilterField[];
|
|
51
|
-
/**
|
|
52
|
-
* The orders the list offers, its default FIRST. The query takes no other:
|
|
53
|
-
* each is a composite the index file carries for every filterable field.
|
|
54
|
-
*/
|
|
55
|
-
sorts: readonly ListQuerySort[];
|
|
56
|
-
/**
|
|
57
|
-
* The quick search: the token array every write stamps (see
|
|
58
|
-
* `nameSearchTokens`), queried with `array-contains` on one typed word.
|
|
59
|
-
* Absent, the list offers no search box.
|
|
60
|
-
*/
|
|
61
|
-
search?: {
|
|
62
|
-
tokensPath: string;
|
|
63
|
-
/**
|
|
64
|
-
* Under a scope clause the search cannot be a SECOND array clause, so a
|
|
65
|
-
* scoped list writes `<scopeToken><join><prefix>` tokens and the query
|
|
66
|
-
* asks `array-contains-any` over the scope's tokens joined to the word —
|
|
67
|
-
* one array clause that answers both.
|
|
68
|
-
*
|
|
69
|
-
* ⛔ Rules that grant a list from `visibleTo.hasAny(...)` DENY this
|
|
70
|
-
* query, because it no longer constrains `visibleTo`. Declare it only for
|
|
71
|
-
* readers whose rule needs no `visibleTo` term, or for an Admin-SDK read;
|
|
72
|
-
* see `SCOPED_SEARCH_JOIN` in `@aglyn/aglyn/app-utils/name-search`.
|
|
73
|
-
*/
|
|
74
|
-
scoped?: {
|
|
75
|
-
tokensPath: string;
|
|
76
|
-
join: string;
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Keys a presence-map field (`keysOf`) is filtered by, for the index
|
|
81
|
-
* enumeration: `sources.form`, `sources.order`, …
|
|
82
|
-
*/
|
|
83
|
-
keys?: Readonly<Record<string, readonly string[]>>;
|
|
84
|
-
}
|
|
85
|
-
/** What the list asks this time. */
|
|
86
|
-
export interface ListQueryRequest {
|
|
87
|
-
clauses: readonly ListFilterRequest[];
|
|
88
|
-
/** The quick search's words. */
|
|
89
|
-
search?: readonly string[];
|
|
90
|
-
/** The order asked for; a sort the declaration does not offer is ignored. */
|
|
91
|
-
sort?: ListQuerySort | null;
|
|
92
|
-
/**
|
|
93
|
-
* Predicates the list always applies — its scope — which count against
|
|
94
|
-
* the same limits. An `array-contains-any` scope is what a scoped search
|
|
95
|
-
* folds into (`declaration.search.scoped`).
|
|
96
|
-
*/
|
|
97
|
-
base?: readonly ListQueryFilter[];
|
|
98
|
-
}
|
|
99
|
-
export interface ListQueryRefusal {
|
|
100
|
-
/** The clause refused, or `search`. */
|
|
101
|
-
clause: ListFilterRequest | 'search';
|
|
102
|
-
reason: string;
|
|
103
|
-
}
|
|
104
|
-
export interface ListQueryPlan {
|
|
105
|
-
/** Every predicate, base included, in the order the SDK should add them. */
|
|
106
|
-
filters: ListQueryFilter[];
|
|
107
|
-
/** The one order: the range field's when there is one, else the sort. */
|
|
108
|
-
orderBy: ListQuerySort;
|
|
109
|
-
/** The clauses on the query. */
|
|
110
|
-
served: ListFilterRequest[];
|
|
111
|
-
/** The search word on the query, or null. */
|
|
112
|
-
searched: string | null;
|
|
113
|
-
/** What was asked and could not be put on the query, with why. */
|
|
114
|
-
refused: ListQueryRefusal[];
|
|
115
|
-
/** Said to the reader about what WAS served — e.g. one search word of two. */
|
|
116
|
-
notices: string[];
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Every clause and the search, as ONE query — or as much of it as one query
|
|
120
|
-
* can hold, with the rest refused by name.
|
|
121
|
-
*
|
|
122
|
-
* Order of claim: the base (the list's scope) first, then the search, then
|
|
123
|
-
* the clauses in the order they were added. A clause that would be a second
|
|
124
|
-
* array clause, a second inequality field or push the disjunctions past
|
|
125
|
-
* thirty is refused, and the list shows the refusal beside its chip; the
|
|
126
|
-
* clauses before it stand. The search is claimed before the clauses because
|
|
127
|
-
* it is the thing a reader typed last and looks at.
|
|
128
|
-
*/
|
|
129
|
-
export declare function planListQuery(declaration: ListQueryDeclaration, request: ListQueryRequest, names: ListQueryNormalizers): ListQueryPlan;
|
|
130
|
-
/** A composite the plan's shapes need, in the index file's own terms. */
|
|
131
|
-
export interface ListQueryIndex {
|
|
132
|
-
fields: Array<{
|
|
133
|
-
fieldPath: string;
|
|
134
|
-
order?: 'ASCENDING' | 'DESCENDING';
|
|
135
|
-
arrayConfig?: 'CONTAINS';
|
|
136
|
-
}>;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Every composite a declaration's queries can need, under index merging:
|
|
140
|
-
* one `(predicate field, order)` index per equality or array field and per
|
|
141
|
-
* order the list can take — its sorts, and the order each range imposes.
|
|
142
|
-
*
|
|
143
|
-
* `base` names the scope predicates the list always applies (their paths
|
|
144
|
-
* and whether they are array clauses), which need their own index per order
|
|
145
|
-
* like any other equality. Pinned by each list's spec against
|
|
146
|
-
* `cloud/firebase-firestore.indexes.json`.
|
|
147
|
-
*/
|
|
148
|
-
export declare function listQueryIndexes(declaration: ListQueryDeclaration, base?: readonly {
|
|
149
|
-
path: string;
|
|
150
|
-
array?: boolean;
|
|
151
|
-
}[]): ListQueryIndex[];
|
|
152
|
-
/** An index entry as `cloud/firebase-firestore.indexes.json` stores it. */
|
|
153
|
-
interface IndexFileEntry {
|
|
154
|
-
collectionGroup: string;
|
|
155
|
-
queryScope: string;
|
|
156
|
-
fields: Array<{
|
|
157
|
-
fieldPath: string;
|
|
158
|
-
order?: string;
|
|
159
|
-
arrayConfig?: string;
|
|
160
|
-
}>;
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* The composites a declaration needs that an index file does not hold — what
|
|
164
|
-
* a list's spec asserts is empty, so a declared filter cannot ship without
|
|
165
|
-
* the index that serves it.
|
|
166
|
-
*/
|
|
167
|
-
export declare function missingListQueryIndexes(file: {
|
|
168
|
-
indexes: readonly IndexFileEntry[];
|
|
169
|
-
}, collectionGroup: string, needed: readonly ListQueryIndex[], queryScope?: 'COLLECTION' | 'COLLECTION_GROUP'): ListQueryIndex[];
|
|
170
|
-
export {};
|
|
17
|
+
export * from '@aglyn/shared-util-tools/list-query/list-query-plan';
|