@aglyn/shared-ui-jsx 1.0.0-beta.198 → 1.0.0-beta.200
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/list-filter-chips.component.d.ts +2 -2
- package/src/lib/components/list-filter-chips.component.js +6 -28
- package/src/lib/components/list-filter-chips.component.js.map +1 -1
- package/src/lib/components/list-filter-toolbar.component.d.ts +56 -0
- package/src/lib/components/list-filter-toolbar.component.js +280 -0
- package/src/lib/components/list-filter-toolbar.component.js.map +1 -0
- package/src/lib/components/list-query-notices.component.d.ts +61 -0
- package/src/lib/components/list-query-notices.component.js +61 -0
- package/src/lib/components/list-query-notices.component.js.map +1 -0
- package/src/lib/components/list-table.component.d.ts +16 -0
- package/src/lib/components/list-table.component.js +57 -8
- package/src/lib/components/list-table.component.js.map +1 -1
- package/src/lib/const/list-filter-sentence.d.ts +39 -0
- package/src/lib/const/list-filter-sentence.js +107 -0
- package/src/lib/const/list-filter-sentence.js.map +1 -0
- package/src/lib/const/list-filter.d.ts +14 -46
- package/src/lib/const/list-filter.js +54 -113
- package/src/lib/const/list-filter.js.map +1 -1
- package/src/lib/const/list-grid-filter.d.ts +38 -21
- package/src/lib/const/list-grid-filter.js +59 -65
- package/src/lib/const/list-grid-filter.js.map +1 -1
- package/src/lib/const/list-query-plan.d.ts +170 -0
- package/src/lib/const/list-query-plan.js +624 -0
- package/src/lib/const/list-query-plan.js.map +1 -0
- package/src/lib/hooks/use-list-grid-filter.d.ts +7 -11
- package/src/lib/hooks/use-list-grid-filter.js +11 -12
- package/src/lib/hooks/use-list-grid-filter.js.map +1 -1
- package/src/lib/hooks/use-list-rows-filter.d.ts +0 -75
- package/src/lib/hooks/use-list-rows-filter.js +0 -83
- package/src/lib/hooks/use-list-rows-filter.js.map +0 -1
- package/src/lib/hooks/use-paged-rows-filter.d.ts +0 -77
- package/src/lib/hooks/use-paged-rows-filter.js +0 -126
- package/src/lib/hooks/use-paged-rows-filter.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx/src/lib/hooks/use-paged-rows-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'use client'\n\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport {\n type ListRowsFilter,\n type ListRowsFilterOptions,\n useListRowsFilter,\n} from './use-list-rows-filter'\n\n/** How many rows a paged list reads while it is filtered — see below. */\nexport const PAGED_FILTER_WINDOW = 100\n\n/**\n * A paged window over a live list — the shape `usePagedCollection` returns:\n * every row from the first page to the one being read (plus, possibly, one\n * probe row past it), the page, and whether more exist.\n */\nexport interface PagedRowsWindow<Row> {\n /** Every row read so far, page 0 to the current page; may hold a probe row. */\n data?: readonly Row[] | null\n /** The current page's rows, when nothing narrows the list. */\n rows: readonly Row[]\n hasMore: boolean\n page: number\n setPage: (page: number) => void\n pageSize: number\n setPageSize: (pageSize: number) => void\n}\n\n/** What the list's grid, chips and footer take while it is paged. */\nexport interface PagedRowsFilter<Row> extends Omit<ListRowsFilter<Row>, 'rows'> {\n /** The rows the grid shows: the page, or the page of the matches. */\n rows: Row[]\n /** How many rows the window read — what a filter has looked through. */\n read: number\n /** Spread onto `ListPagination`. */\n pagination: {\n page: number\n pageSize: number\n rowCount: number\n hasMore: boolean\n onPageChange: (page: number) => void\n onPageSizeChange: (pageSize: number) => void\n }\n}\n\n/**\n * The grid's Filters panel and quick search over a PAGED live list\n * (AGL-3317), one that reads a window growing a page at a time rather than\n * every row.\n *\n * Unfiltered it is the pager it wraps: the grid shows the page, and the\n * footer turns it. While a clause or a search word is in force the list\n * matches over EVERYTHING the window has read — every page up to the\n * current one, not the page on screen — and pages the matches instead;\n * turning past the last match widens the window by one more page, so a\n * filter reaches further the further the reader goes. `read` says how far\n * it has looked, for the list to say so while more exist.\n *\n * ## The first filter widens the window once\n *\n * A window of one ten-row page is too little to filter: a search would look\n * through ten rows and call the rest \"no match\". So the first clause or word\n * widens the window to `filterWindow` rows (default\n * {@link PAGED_FILTER_WINDOW}) — one listener that much wider, for as long as\n * the list is narrowed — and clearing the last one puts the reader back on\n * the page they left.\n */\nexport function usePagedRowsFilter<Row extends object>(\n paged: PagedRowsWindow<Row>,\n options: Omit<ListRowsFilterOptions<Row>, 'rows'> & { filterWindow?: number },\n): PagedRowsFilter<Row> {\n const { pageSize } = paged\n const { filterWindow = PAGED_FILTER_WINDOW, ...filterOptions } = options\n const windowRows = useMemo(\n () => (paged.data ?? paged.rows).slice(0, pageSize * (paged.page + 1)),\n [paged.data, paged.rows, pageSize, paged.page],\n )\n const filter = useListRowsFilter({ ...filterOptions, rows: windowRows })\n const [matchPage, setMatchPage] = useState(0)\n const searchKey = filter.gridFilter.searchWords.join(' ')\n // A narrowed list starts again at its first page.\n useEffect(() => setMatchPage(0), [filter.gridFilter.clauses, searchKey])\n\n /** The page the reader was on before the list was narrowed. */\n const before = useRef<number | null>(null)\n const { filtering } = filter\n useEffect(() => {\n if (filtering && before.current === null) {\n before.current = paged.page\n const widened = Math.max(0, Math.ceil(filterWindow / pageSize) - 1)\n if (widened > paged.page) paged.setPage(widened)\n } else if (!filtering && before.current !== null) {\n paged.setPage(before.current)\n before.current = null\n }\n // Only the transition into and out of a filter moves the window.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [filtering])\n\n if (!filter.filtering) {\n return {\n ...filter,\n rows: [...paged.rows],\n read: windowRows.length,\n pagination: {\n page: paged.page,\n pageSize,\n rowCount: paged.rows.length,\n hasMore: paged.hasMore,\n onPageChange: paged.setPage,\n onPageSizeChange: paged.setPageSize,\n },\n }\n }\n const matches = filter.rows\n const shown = matches.slice(matchPage * pageSize, (matchPage + 1) * pageSize)\n const lastMatchPage = Math.max(0, Math.ceil(matches.length / pageSize) - 1)\n return {\n ...filter,\n rows: shown,\n read: windowRows.length,\n pagination: {\n page: matchPage,\n pageSize,\n rowCount: shown.length,\n hasMore: paged.hasMore || matchPage < lastMatchPage,\n onPageChange: (next) => {\n // Past the matches read so far, the window reads another page first.\n if ((next + 1) * pageSize > matches.length && paged.hasMore) {\n paged.setPage(paged.page + 1)\n }\n setMatchPage(next)\n },\n onPageSizeChange: (next) => {\n paged.setPageSize(next)\n setMatchPage(0)\n },\n },\n }\n}\n\nexport default usePagedRowsFilter\n"],"names":["useEffect","useMemo","useRef","useState","useListRowsFilter","PAGED_FILTER_WINDOW","usePagedRowsFilter","paged","options","pageSize","filterWindow","filterOptions","windowRows","data","rows","slice","page","filter","matchPage","setMatchPage","searchKey","gridFilter","searchWords","join","clauses","before","filtering","current","widened","Math","max","ceil","setPage","read","length","pagination","rowCount","hasMore","onPageChange","onPageSizeChange","setPageSize","matches","shown","lastMatchPage","next"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;AAEA,SAASA,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAC5D,SAGEC,iBAAiB,QACZ,4BAAwB;AAE/B,uEAAuE,GACvE,OAAO,MAAMC,sBAAsB,IAAG;AAoCtC;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASC,mBACdC,KAA2B,EAC3BC,OAA6E;IAE7E,MAAM,EAAEC,QAAQ,EAAE,GAAGF;IACrB,MAAM,EAAEG,eAAeL,mBAAmB,EAAoB,GAAGG,SAAlBG,iDAAkBH;;;IACjE,MAAMI,aAAaX,QACjB;YAAOM;eAAD,EAACA,cAAAA,MAAMM,IAAI,YAAVN,cAAcA,MAAMO,IAAI,EAAEC,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