@optimum-intelligence/opti-ui 0.8.1 → 0.9.1

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/components/calendar/Calendar.js +29 -17
  3. package/dist/components/calendar/Calendar.js.map +1 -1
  4. package/dist/components/data-table/DataTable.d.ts +4 -1
  5. package/dist/components/data-table/DataTable.js +20 -16
  6. package/dist/components/data-table/DataTable.js.map +1 -1
  7. package/dist/components/data-table/DataTableFilters.d.ts +3 -2
  8. package/dist/components/data-table/DataTableFilters.js +287 -171
  9. package/dist/components/data-table/DataTableFilters.js.map +1 -1
  10. package/dist/components/data-table/DataTableRow.js +76 -72
  11. package/dist/components/data-table/DataTableRow.js.map +1 -1
  12. package/dist/components/data-table/layout.js +1 -1
  13. package/dist/components/data-table/layout.js.map +1 -1
  14. package/dist/components/data-table/types.d.ts +35 -3
  15. package/dist/components/data-table/useDataTable.d.ts +1 -1
  16. package/dist/components/data-table/useDataTable.js +312 -299
  17. package/dist/components/data-table/useDataTable.js.map +1 -1
  18. package/dist/components/dialog/ConfirmDialog.d.ts +6 -1
  19. package/dist/components/dialog/ConfirmDialog.js +88 -85
  20. package/dist/components/dialog/ConfirmDialog.js.map +1 -1
  21. package/dist/components/table/Table.d.ts +5 -1
  22. package/dist/components/table/Table.js +2 -1
  23. package/dist/components/table/Table.js.map +1 -1
  24. package/dist/components.json +23 -4
  25. package/dist/fonts/JetBrainsMono-OFL.txt +93 -0
  26. package/dist/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
  27. package/dist/fonts/jetbrains-mono-latin.woff2 +0 -0
  28. package/dist/fonts.css +22 -1
  29. package/dist/llms-full.txt +8 -4
  30. package/dist/opti-ui.css +135 -33
  31. package/dist/utils/scroll-fade.d.ts +5 -1
  32. package/dist/utils/scroll-fade.js +11 -1
  33. package/dist/utils/scroll-fade.js.map +1 -1
  34. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"layout.js","names":["React","getColumnValue","DataTableColumn","DataTableEntry","tableOf","anchor","HTMLElement","closest","wrapperOf","parentElement","ColumnLock","key","container","table","widths","useColumnLock","enabled","ready","$","_c","lock","setLock","useState","shown","setShown","held","measuring","t0","wrapper","clientWidth","heads","querySelectorAll","getBoundingClientRect","width","Array","from","_temp","t1","useLayoutEffect","t2","t3","wrapper_0","ResizeObserver","observer","current","Math","abs","observe","disconnect","useEffect","t4","head","pickSizerRows","entries","T","columns","picked","Set","step","max","ceil","length","index","add","column","longest","entry","value","row","size","undefined","String","usePageHeight","full","setHeld","height","useHeaderHeight","setHeight","tHead","rows","next","VirtualRowsOptions","count","rowHeight","overscan","estimate","viewport","VirtualRows","start","end","before","after","onScroll","event","UIEvent","useVirtualRows","assumed","first","setFirst","setViewport","tallest","setTallest","measured","visible","top","min","clientHeight","t5","_temp2","t6","t7","t8","floor","currentTarget","scrollTop","t9","_c"],"sources":["../../../src/components/data-table/layout.ts"],"sourcesContent":["import * as React from 'react';\nimport { getColumnValue } from './useDataTable';\nimport type { DataTableColumn, DataTableEntry } from './types';\n\n// The hooks here find the table through an element rendered inside it (its\n// `<colgroup>`), so `tableProps` keeps its own `ref` for the consumer.\nfunction tableOf(anchor: HTMLElement | null) {\n return anchor?.closest('table') ?? null;\n}\n\nfunction wrapperOf(anchor: HTMLElement | null) {\n return tableOf(anchor)?.parentElement ?? null;\n}\n\n// ─── Column widths ───────────────────────────────────────────────────────────\n\n/** Column widths taken from the browser's own layout, then held. */\nexport interface ColumnLock {\n key: string;\n /** Width of the wrapper when measured; another one asks for a new measurement. */\n container: number;\n table: number;\n widths: number[];\n}\n\n/**\n * Lets the browser lay the columns out once, then holds their widths, so\n * paging, sorting, scrolling and editing cannot move them. The widths are\n * measured again when the table is resized or `key` (the column set) changes.\n * `measuring` is true for the render the widths are read from; it is replaced\n * before the browser paints.\n */\nexport function useColumnLock(anchor: HTMLElement | null, enabled: boolean, key: string, ready: boolean) {\n const [lock, setLock] = React.useState<ColumnLock | null>(null);\n const [shown, setShown] = React.useState(true);\n const held = enabled && lock?.key === key ? lock : null;\n const measuring = enabled && ready && !held && anchor !== null;\n\n React.useLayoutEffect(() => {\n const table = tableOf(anchor);\n const wrapper = table?.parentElement;\n // A hidden table (a closed tab) has no widths to read: it is measured when it shows.\n if (!measuring || !table || !wrapper || !wrapper.clientWidth) return;\n const heads = table.querySelectorAll<HTMLElement>(':scope > thead > tr > th');\n setLock({\n key,\n container: wrapper.clientWidth,\n table: table.getBoundingClientRect().width,\n widths: Array.from(heads, (head) => head.getBoundingClientRect().width),\n });\n }, [anchor, measuring, key, shown]);\n\n React.useEffect(() => {\n const wrapper = wrapperOf(anchor);\n if (!enabled || !wrapper || typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(() => {\n const width = wrapper.clientWidth;\n setShown(width > 0);\n if (width > 0) setLock((current) => (current && Math.abs(current.container - width) >= 1 ? null : current));\n });\n observer.observe(wrapper);\n return () => observer.disconnect();\n }, [anchor, enabled]);\n\n return { lock: held, measuring };\n}\n\n/**\n * Rows the column widths are measured with, next to the ones on screen: the\n * row with the longest text of each column, and a few spread over the data.\n * Without them the widths would fit the first page only.\n */\nexport function pickSizerRows<T>(entries: DataTableEntry<T>[], columns: DataTableColumn<T>[]): DataTableEntry<T>[] {\n const picked = new Set<DataTableEntry<T>>();\n const step = Math.max(1, Math.ceil(entries.length / 12));\n for (let index = 0; index < entries.length; index += step) picked.add(entries[index]!);\n for (const column of columns) {\n let longest: DataTableEntry<T> | null = null;\n let length = 0;\n for (const entry of entries) {\n const value = getColumnValue(column, entry.row);\n const size = value === null || value === undefined ? 0 : String(value).length;\n if (size > length) {\n longest = entry;\n length = size;\n }\n }\n if (longest) picked.add(longest);\n }\n return [...picked];\n}\n\n// ─── Page height ─────────────────────────────────────────────────────────────\n\n/**\n * Height of the table with a full page of rows, so a shorter last page can keep\n * it and the pagination below stays where the pointer is.\n */\nexport function usePageHeight(anchor: HTMLElement | null, enabled: boolean, full: boolean, key: string) {\n const [held, setHeld] = React.useState<{ key: string; height: number } | null>(null);\n\n React.useLayoutEffect(() => {\n const wrapper = wrapperOf(anchor);\n if (!enabled || !full || !wrapper) return;\n const height = wrapper.getBoundingClientRect().height;\n if (height) setHeld((current) => (current?.key === key && Math.abs(current.height - height) < 1 ? current : { key, height }));\n });\n\n return enabled && held?.key === key ? held.height : undefined;\n}\n\n// ─── Header height ───────────────────────────────────────────────────────────\n\n/**\n * Height of the header row while it shows the column names, so the selection bar that takes its place can\n * keep it and the rows stay where they are.\n */\nexport function useHeaderHeight(anchor: HTMLElement | null, enabled: boolean) {\n const [height, setHeight] = React.useState<number | undefined>(undefined);\n\n React.useLayoutEffect(() => {\n const row = tableOf(anchor)?.tHead?.rows[0];\n if (!enabled || !row) return;\n const next = row.getBoundingClientRect().height;\n if (next) setHeight((current) => (current !== undefined && Math.abs(current - next) < 0.5 ? current : next));\n });\n\n return height;\n}\n\n// ─── Virtual rows ────────────────────────────────────────────────────────────\n\nexport interface VirtualRowsOptions {\n enabled: boolean;\n /** Number of rows in the list. */\n count: number;\n /** Height every row has. Left out, it is the tallest row seen. */\n rowHeight?: number;\n /** Rows rendered beyond each edge of the view. */\n overscan: number;\n /** Row height assumed before the first row is measured. */\n estimate: number;\n /** Height of the view assumed before it is measured, and on the server. */\n viewport: number;\n /** Changes when the row height may (density): forgets the measured one. */\n key: string;\n}\n\nexport interface VirtualRows {\n /** Rows `start` (included) to `end` (excluded) are rendered. */\n start: number;\n end: number;\n /** Heights standing in for the rows above and below them. */\n before: number;\n after: number;\n /** Height to give every row, once known: equal rows keep the scrollbar steady. */\n rowHeight?: number;\n onScroll: (event: React.UIEvent<HTMLElement>) => void;\n}\n\n/** Renders only the rows in view of the scrolling wrapper, and stands in for the rest with empty space. */\nexport function useVirtualRows(\n anchor: HTMLElement | null,\n { enabled, count, rowHeight, overscan, estimate, viewport: assumed, key }: VirtualRowsOptions,\n): VirtualRows {\n const [first, setFirst] = React.useState(0);\n const [viewport, setViewport] = React.useState<number | null>(null);\n const [tallest, setTallest] = React.useState<{ key: string; height: number } | null>(null);\n\n const measured = tallest?.key === key ? tallest.height : undefined;\n const height = rowHeight ?? measured ?? estimate;\n const visible = Math.ceil((viewport ?? assumed) / height) + 1;\n const top = Math.max(0, Math.min(first, count - 1));\n const from = Math.max(0, top - overscan);\n // An even start keeps the stripes of a striped table on the same rows.\n const start = from - (from % 2);\n const end = Math.min(count, top + visible + overscan);\n\n React.useLayoutEffect(() => {\n const table = tableOf(anchor);\n if (!enabled || rowHeight !== undefined || !table) return;\n let max = 0;\n for (const row of table.querySelectorAll(':scope > tbody > tr[aria-rowindex]')) {\n max = Math.max(max, row.getBoundingClientRect().height);\n }\n // Only ever grows: rows are given this height, so a smaller reading is the height itself.\n if (max) setTallest((current) => (current?.key === key && max - current.height < 0.5 ? current : { key, height: max }));\n }, [anchor, enabled, rowHeight, key, start, end, count]);\n\n React.useEffect(() => {\n const wrapper = wrapperOf(anchor);\n if (!enabled || !wrapper) return;\n setViewport(wrapper.clientHeight);\n if (typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(() => setViewport(wrapper.clientHeight));\n observer.observe(wrapper);\n return () => observer.disconnect();\n }, [anchor, enabled]);\n\n if (!enabled) return { start: 0, end: count, before: 0, after: 0, onScroll: () => undefined };\n return {\n start,\n end,\n before: start * height,\n after: (count - end) * height,\n rowHeight: rowHeight ?? measured,\n onScroll: (event) => setFirst(Math.floor(event.currentTarget.scrollTop / height)),\n };\n}\n"],"mappings":";;;;;AAMA,SAASI,QAAQC,QAA4B;CAC3C,OAAOA,QAAQE,QAAQ,OAAO,KAAK;AACrC;AAEA,SAASC,UAAUH,QAA4B;CAC7C,OAAOD,QAAQC,MAAM,CAAC,EAAEI,iBAAiB;AAC3C;;;;;;;;AAoBA,SAAOM,cAAAV,QAAAW,SAAAL,KAAAM,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CACL,MAAA,CAAAC,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A5F,EAAA,QAAA6F,IAAA;EAN5EI,KAAA;GAAA3B;GAAAC;GAAAC,QAGGiB;GAAchB,OACfkB;GAAsB1B,WAClB2B;GAAqBlB,UACtBmB;EACZ;EAAC7F,EAAA,MAAAuE;EAAAvE,EAAA,MAAAsE;EAAAtE,EAAA,MAAAyF;EAAAzF,EAAA,MAAA2F;EAAA3F,EAAA,MAAA4F;EAAA5F,EAAA,MAAA6F;EAAA7F,EAAA,MAAAiG;CAAA,OAAAA,KAAAjG,EAAA;CAAA,OAPMiG;AAON;AA9CI,SAAAP,SAAA,CAAA"}
1
+ {"version":3,"file":"layout.js","names":["React","getColumnValue","DataTableColumn","DataTableEntry","tableOf","anchor","HTMLElement","closest","wrapperOf","parentElement","ColumnLock","key","container","table","widths","useColumnLock","enabled","ready","$","_c","lock","setLock","useState","shown","setShown","held","measuring","t0","wrapper","clientWidth","heads","querySelectorAll","getBoundingClientRect","width","Array","from","_temp","t1","useLayoutEffect","t2","t3","wrapper_0","ResizeObserver","observer","current","Math","abs","observe","disconnect","useEffect","t4","head","pickSizerRows","entries","T","columns","picked","Set","step","max","ceil","length","index","add","column","longest","entry","value","row","size","undefined","String","usePageHeight","full","setHeld","height","useHeaderHeight","setHeight","querySelector","next","VirtualRowsOptions","count","rowHeight","overscan","estimate","viewport","VirtualRows","start","end","before","after","onScroll","event","UIEvent","useVirtualRows","assumed","first","setFirst","setViewport","tallest","setTallest","measured","visible","top","min","clientHeight","t5","_temp2","t6","t7","t8","floor","currentTarget","scrollTop","t9","_c"],"sources":["../../../src/components/data-table/layout.ts"],"sourcesContent":["import * as React from 'react';\nimport { getColumnValue } from './useDataTable';\nimport type { DataTableColumn, DataTableEntry } from './types';\n\n// The hooks here find the table through an element rendered inside it (its\n// `<colgroup>`), so `tableProps` keeps its own `ref` for the consumer.\nfunction tableOf(anchor: HTMLElement | null) {\n return anchor?.closest('table') ?? null;\n}\n\nfunction wrapperOf(anchor: HTMLElement | null) {\n return tableOf(anchor)?.parentElement ?? null;\n}\n\n// ─── Column widths ───────────────────────────────────────────────────────────\n\n/** Column widths taken from the browser's own layout, then held. */\nexport interface ColumnLock {\n key: string;\n /** Width of the wrapper when measured; another one asks for a new measurement. */\n container: number;\n table: number;\n widths: number[];\n}\n\n/**\n * Lets the browser lay the columns out once, then holds their widths, so\n * paging, sorting, scrolling and editing cannot move them. The widths are\n * measured again when the table is resized or `key` (the column set) changes.\n * `measuring` is true for the render the widths are read from; it is replaced\n * before the browser paints.\n */\nexport function useColumnLock(anchor: HTMLElement | null, enabled: boolean, key: string, ready: boolean) {\n const [lock, setLock] = React.useState<ColumnLock | null>(null);\n const [shown, setShown] = React.useState(true);\n const held = enabled && lock?.key === key ? lock : null;\n const measuring = enabled && ready && !held && anchor !== null;\n\n React.useLayoutEffect(() => {\n const table = tableOf(anchor);\n const wrapper = table?.parentElement;\n // A hidden table (a closed tab) has no widths to read: it is measured when it shows.\n if (!measuring || !table || !wrapper || !wrapper.clientWidth) return;\n const heads = table.querySelectorAll<HTMLElement>(':scope > thead > tr > th');\n setLock({\n key,\n container: wrapper.clientWidth,\n table: table.getBoundingClientRect().width,\n widths: Array.from(heads, (head) => head.getBoundingClientRect().width),\n });\n }, [anchor, measuring, key, shown]);\n\n React.useEffect(() => {\n const wrapper = wrapperOf(anchor);\n if (!enabled || !wrapper || typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(() => {\n const width = wrapper.clientWidth;\n setShown(width > 0);\n if (width > 0) setLock((current) => (current && Math.abs(current.container - width) >= 1 ? null : current));\n });\n observer.observe(wrapper);\n return () => observer.disconnect();\n }, [anchor, enabled]);\n\n return { lock: held, measuring };\n}\n\n/**\n * Rows the column widths are measured with, next to the ones on screen: the\n * row with the longest text of each column, and a few spread over the data.\n * Without them the widths would fit the first page only.\n */\nexport function pickSizerRows<T>(entries: DataTableEntry<T>[], columns: DataTableColumn<T>[]): DataTableEntry<T>[] {\n const picked = new Set<DataTableEntry<T>>();\n const step = Math.max(1, Math.ceil(entries.length / 12));\n for (let index = 0; index < entries.length; index += step) picked.add(entries[index]!);\n for (const column of columns) {\n let longest: DataTableEntry<T> | null = null;\n let length = 0;\n for (const entry of entries) {\n const value = getColumnValue(column, entry.row);\n const size = value === null || value === undefined ? 0 : String(value).length;\n if (size > length) {\n longest = entry;\n length = size;\n }\n }\n if (longest) picked.add(longest);\n }\n return [...picked];\n}\n\n// ─── Page height ─────────────────────────────────────────────────────────────\n\n/**\n * Height of the table with a full page of rows, so a shorter last page can keep\n * it and the pagination below stays where the pointer is.\n */\nexport function usePageHeight(anchor: HTMLElement | null, enabled: boolean, full: boolean, key: string) {\n const [held, setHeld] = React.useState<{ key: string; height: number } | null>(null);\n\n React.useLayoutEffect(() => {\n const wrapper = wrapperOf(anchor);\n if (!enabled || !full || !wrapper) return;\n const height = wrapper.getBoundingClientRect().height;\n if (height) setHeld((current) => (current?.key === key && Math.abs(current.height - height) < 1 ? current : { key, height }));\n });\n\n return enabled && held?.key === key ? held.height : undefined;\n}\n\n// ─── Header height ───────────────────────────────────────────────────────────\n\n/**\n * Height of the header row while it shows the column names, so the selection bar that takes its place can\n * keep it and the rows stay where they are.\n */\nexport function useHeaderHeight(anchor: HTMLElement | null, enabled: boolean) {\n const [height, setHeight] = React.useState<number | undefined>(undefined);\n\n React.useLayoutEffect(() => {\n // `querySelector`, not `tHead.rows`: happy-dom, which apps test with, has no `rows`.\n const row = tableOf(anchor)?.querySelector('thead > tr');\n if (!enabled || !row) return;\n const next = row.getBoundingClientRect().height;\n if (next) setHeight((current) => (current !== undefined && Math.abs(current - next) < 0.5 ? current : next));\n });\n\n return height;\n}\n\n// ─── Virtual rows ────────────────────────────────────────────────────────────\n\nexport interface VirtualRowsOptions {\n enabled: boolean;\n /** Number of rows in the list. */\n count: number;\n /** Height every row has. Left out, it is the tallest row seen. */\n rowHeight?: number;\n /** Rows rendered beyond each edge of the view. */\n overscan: number;\n /** Row height assumed before the first row is measured. */\n estimate: number;\n /** Height of the view assumed before it is measured, and on the server. */\n viewport: number;\n /** Changes when the row height may (density): forgets the measured one. */\n key: string;\n}\n\nexport interface VirtualRows {\n /** Rows `start` (included) to `end` (excluded) are rendered. */\n start: number;\n end: number;\n /** Heights standing in for the rows above and below them. */\n before: number;\n after: number;\n /** Height to give every row, once known: equal rows keep the scrollbar steady. */\n rowHeight?: number;\n onScroll: (event: React.UIEvent<HTMLElement>) => void;\n}\n\n/** Renders only the rows in view of the scrolling wrapper, and stands in for the rest with empty space. */\nexport function useVirtualRows(\n anchor: HTMLElement | null,\n { enabled, count, rowHeight, overscan, estimate, viewport: assumed, key }: VirtualRowsOptions,\n): VirtualRows {\n const [first, setFirst] = React.useState(0);\n const [viewport, setViewport] = React.useState<number | null>(null);\n const [tallest, setTallest] = React.useState<{ key: string; height: number } | null>(null);\n\n const measured = tallest?.key === key ? tallest.height : undefined;\n const height = rowHeight ?? measured ?? estimate;\n const visible = Math.ceil((viewport ?? assumed) / height) + 1;\n const top = Math.max(0, Math.min(first, count - 1));\n const from = Math.max(0, top - overscan);\n // An even start keeps the stripes of a striped table on the same rows.\n const start = from - (from % 2);\n const end = Math.min(count, top + visible + overscan);\n\n React.useLayoutEffect(() => {\n const table = tableOf(anchor);\n if (!enabled || rowHeight !== undefined || !table) return;\n let max = 0;\n for (const row of table.querySelectorAll(':scope > tbody > tr[aria-rowindex]')) {\n max = Math.max(max, row.getBoundingClientRect().height);\n }\n // Only ever grows: rows are given this height, so a smaller reading is the height itself.\n if (max) setTallest((current) => (current?.key === key && max - current.height < 0.5 ? current : { key, height: max }));\n }, [anchor, enabled, rowHeight, key, start, end, count]);\n\n React.useEffect(() => {\n const wrapper = wrapperOf(anchor);\n if (!enabled || !wrapper) return;\n setViewport(wrapper.clientHeight);\n if (typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(() => setViewport(wrapper.clientHeight));\n observer.observe(wrapper);\n return () => observer.disconnect();\n }, [anchor, enabled]);\n\n if (!enabled) return { start: 0, end: count, before: 0, after: 0, onScroll: () => undefined };\n return {\n start,\n end,\n before: start * height,\n after: (count - end) * height,\n rowHeight: rowHeight ?? measured,\n onScroll: (event) => setFirst(Math.floor(event.currentTarget.scrollTop / height)),\n };\n}\n"],"mappings":";;;;;AAMA,SAASI,QAAQC,QAA4B;CAC3C,OAAOA,QAAQE,QAAQ,OAAO,KAAK;AACrC;AAEA,SAASC,UAAUH,QAA4B;CAC7C,OAAOD,QAAQC,MAAM,CAAC,EAAEI,iBAAiB;AAC3C;;;;;;;;AAoBA,SAAOM,cAAAV,QAAAW,SAAAL,KAAAM,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CACL,MAAA,CAAAC,MAAAC,WAAwBrB,MAAKsB,SAA6B,IAAI;CAC9D,MAAA,CAAAC,OAAAC,YAA0BxB,MAAKsB,SAAU,IAAI;CAC7C,MAAAG,OAAaT,WAAWI,MAAIT,QAAUA,MAAzBS,OAAA;CACb,MAAAM,YAAkBV,WAAAC,SAAA,CAAqBQ,QAAQpB,WAAW;CAAK,IAAAsB;CAAA,IAAAT,EAAA,OAAAb,UAAAa,EAAA,OAAAP,OAAAO,EAAA,OAAAQ,WAAA;EAEzCC,WAAA;GACpB,MAAAd,QAAcT,QAAQC,MAAM;GAC5B,MAAAuB,UAAgBf,OAAKJ;GAErB,IAAI,CAACiB,aAAD,CAAeb,SAAf,CAAyBe,WAAzB,CAAqCA,QAAOC,aAAY;GAC5D,MAAAC,QAAcjB,MAAKkB,iBAA+B,0BAA0B;GAC5EV,QAAQ;IAAAV;IAAAC,WAEKgB,QAAOC;IAAYhB,OACvBA,MAAKmB,sBAAuB,CAAC,CAAAC;IAAMnB,QAClCoB,MAAKC,KAAML,OAAOM,KAA4C;GACxE,CAAC;EAAC;EACHlB,EAAA,KAAAb;EAAAa,EAAA,KAAAP;EAAAO,EAAA,KAAAQ;EAAAR,EAAA,KAAAS;CAAA,OAAAA,KAAAT,EAAA;CAAA,IAAAmB;CAAA,IAAAnB,EAAA,OAAAb,UAAAa,EAAA,OAAAP,O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,MAAC3B,QAAQO,OAAOb;CACZ,MAAAkC,KAAA3B,aAAAmB;CAAqB,IAAAS;CAAA,IAAA5F,EAAA,QAAAyD,QAAA;EACtBmC,MAAAlB,UAAWK,SAASpD,KAAIkE,MAAOnB,MAAKoB,cAAcC,YAAatC,MAAM,CAAC;EAACzD,EAAA,MAAAyD;EAAAzD,EAAA,MAAA4F;CAAA,OAAAA,KAAA5F,EAAA;CAAA,IAAAgG;CAAA,IAAAhG,EAAA,QAAAsE,OAAAtE,EAAA,QAAAqE,SAAArE,EAAA,QAAAwF,MAAAxF,EAAA,QAAA0F,MAAA1F,EAAA,QAAA2F,MAAA3F,EAAA,QAAA4F,IAAA;EAN5EI,KAAA;GAAA3B;GAAAC;GAAAC,QAGGiB;GAAchB,OACfkB;GAAsB1B,WAClB2B;GAAqBlB,UACtBmB;EACZ;EAAC5F,EAAA,MAAAsE;EAAAtE,EAAA,MAAAqE;EAAArE,EAAA,MAAAwF;EAAAxF,EAAA,MAAA0F;EAAA1F,EAAA,MAAA2F;EAAA3F,EAAA,MAAA4F;EAAA5F,EAAA,MAAAgG;CAAA,OAAAA,KAAAhG,EAAA;CAAA,OAPMgG;AAON;AA9CI,SAAAP,SAAA,CAAA"}
@@ -18,14 +18,24 @@ interface FilterBase {
18
18
  * "Filters" button. On phones every filter is in the filter sheet.
19
19
  */
20
20
  quick?: boolean;
21
+ /**
22
+ * Width of a select or date range control in the toolbar row (any CSS length), instead of
23
+ * `--oui-data-table-filter-width` for selects and the width of a full range for date ranges.
24
+ */
25
+ width?: string;
21
26
  }
22
- /** Dropdown that keeps the rows with one chosen value. */
27
+ /** Dropdown that keeps the rows with the chosen value, or with any of the chosen values with `multiple`. */
23
28
  export interface DataTableSelectFilter<T> extends FilterBase {
24
29
  type: 'select';
25
30
  /** Value compared with the chosen option; an array matches on any of its items. Defaults to `row[id]`. */
26
31
  value?: (row: T) => unknown;
27
32
  /** Options to offer. Left out, they are collected from the rows. */
28
33
  options?: DataTableFilterOption[];
34
+ /**
35
+ * Let several options be chosen; rows matching any of them are kept. The filter value is then an array,
36
+ * as for a chips filter. Use it instead of `chips` when there are too many options for a row of chips.
37
+ */
38
+ multiple?: boolean;
29
39
  }
30
40
  /** On/off chip that keeps the matching rows while it is on. */
31
41
  export interface DataTableToggleFilter<T> extends FilterBase {
@@ -64,7 +74,10 @@ type ColumnFilterConfig<F> = F extends FilterBase ? Omit<F, 'id' | 'label'> & {
64
74
  } : never;
65
75
  /** A filter declared on a column: its type, or its definition without the `id` (the column's). */
66
76
  export type DataTableColumnFilter<T> = DataTableFilter<T>['type'] | ColumnFilterConfig<DataTableFilter<T>>;
67
- /** A select filter holds the option value, chips the pressed values, a toggle `true`, a date range `{ start, end }`. */
77
+ /**
78
+ * A select filter holds the option value (the chosen values with `multiple`), chips the pressed values,
79
+ * a toggle `true`, a date range `{ start, end }`.
80
+ */
68
81
  export type DataTableFilterValue = string | string[] | true | DateRange;
69
82
  /** Values of the active filters by filter id. An inactive filter has no key. */
70
83
  export type DataTableFilterValues = Record<string, DataTableFilterValue>;
@@ -79,6 +92,10 @@ export interface DataTableResolvedFilter<T> {
79
92
  options: DataTableFilterOption[];
80
93
  /** Chips filters with `counts`: number of rows per option value. */
81
94
  counts?: Record<string, number>;
95
+ /** Select filter that takes several values. */
96
+ multiple?: boolean;
97
+ /** Width of the control in the toolbar row. */
98
+ width?: string;
82
99
  presets?: DateRangePreset[];
83
100
  min?: string;
84
101
  max?: string;
@@ -179,6 +196,11 @@ export interface DataTableRowAction {
179
196
  danger?: boolean;
180
197
  }
181
198
  export type DataTableRowTone = 'accent' | 'info' | 'success' | 'warning' | 'danger' | ColorTone;
199
+ /**
200
+ * How a row tone shows: `fill` tints the whole row, `bar` draws a bar in the tone at the row's start,
201
+ * `both` does both.
202
+ */
203
+ export type DataTableRowToneStyle = 'fill' | 'bar' | 'both';
182
204
  export interface DataTableEntry<T> {
183
205
  id: string;
184
206
  row: T;
@@ -189,7 +211,10 @@ export interface DataTableLabels extends PaginationLabels {
189
211
  selectAll: string;
190
212
  selectRow: (label: string) => string;
191
213
  count: (count: number) => React.ReactNode;
192
- /** Summary while a search or filter narrows the rows. Defaults to `count` of the total, prefixed with the match count. */
214
+ /**
215
+ * Row count in the summary: matching rows of all rows, `"3 / 10"` by default. In server mode, where the
216
+ * total before filters is not known, the summary uses `count` instead.
217
+ */
193
218
  filteredCount: (count: number, total: number) => React.ReactNode;
194
219
  selected: (count: number) => React.ReactNode;
195
220
  emptyTitle: React.ReactNode;
@@ -308,6 +333,12 @@ export interface UseDataTableOptions<T> {
308
333
  rowActions?: (row: T) => DataTableRowAction[] | React.ReactNode;
309
334
  /** Tints a row to flag its state. */
310
335
  rowTone?: (row: T) => DataTableRowTone | null | undefined;
336
+ /**
337
+ * How `rowTone` shows: `fill` tints the whole row, `bar` draws a 3px bar in the tone on the row's first
338
+ * cell, which marks rows without a block of colour and stays in view with `stickyFirstColumn`, and
339
+ * `both` tints the row and draws the bar.
340
+ */
341
+ rowToneStyle?: DataTableRowToneStyle;
311
342
  /** Extra props for a row's `<tr>` (`className`, `style`, `data-*`). */
312
343
  rowProps?: (row: T) => React.HTMLAttributes<HTMLTableRowElement> & Record<`data-${string}`, unknown>;
313
344
  /**
@@ -403,6 +434,7 @@ export interface DataTableInstance<T> {
403
434
  rowLabel?: (row: T) => string;
404
435
  rowActions?: (row: T) => DataTableRowAction[] | React.ReactNode;
405
436
  rowTone?: (row: T) => DataTableRowTone | null | undefined;
437
+ rowToneStyle: DataTableRowToneStyle;
406
438
  rowProps?: (row: T) => React.HTMLAttributes<HTMLTableRowElement>;
407
439
  }
408
440
  export {};
@@ -6,4 +6,4 @@ export declare function getColumnValue<T>(column: DataTableColumn<T>, row: T): u
6
6
  * result to `DataTable.Root` to lay the parts out yourself, or read `rows`,
7
7
  * `filterValues` and the rest to drive something else (an export, a chart).
8
8
  */
9
- export declare function useDataTable<T>({ data, columns, mode, total, loading, error, onRetry, getRowId, locale, searchable, search: searchProp, defaultSearch, onSearchChange, searchDebounce, filter, filters: filtersProp, filterValues: filterValuesProp, defaultFilterValues, onFilterValuesChange, sort: sortProp, defaultSort, onSortChange, paginated, page: pageProp, onPageChange, pageSize: pageSizeProp, defaultPageSize, onPageSizeChange, selection: selectionProp, onSelectionChange, hiddenColumns: hiddenColumnsProp, defaultHiddenColumns, onHiddenColumnsChange, onRowClick, rowLabel, rowActions, rowTone, rowProps, onRowSave, onRowDelete, labels: labelsProp, }: UseDataTableOptions<T>): DataTableInstance<T>;
9
+ export declare function useDataTable<T>({ data, columns, mode, total, loading, error, onRetry, getRowId, locale, searchable, search: searchProp, defaultSearch, onSearchChange, searchDebounce, filter, filters: filtersProp, filterValues: filterValuesProp, defaultFilterValues, onFilterValuesChange, sort: sortProp, defaultSort, onSortChange, paginated, page: pageProp, onPageChange, pageSize: pageSizeProp, defaultPageSize, onPageSizeChange, selection: selectionProp, onSelectionChange, hiddenColumns: hiddenColumnsProp, defaultHiddenColumns, onHiddenColumnsChange, onRowClick, rowLabel, rowActions, rowTone, rowToneStyle, rowProps, onRowSave, onRowDelete, labels: labelsProp, }: UseDataTableOptions<T>): DataTableInstance<T>;