@optimum-intelligence/opti-ui 0.8.0 → 0.9.0

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 (68) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/README.md +3 -3
  3. package/dist/components/app-shell/AppShell.d.ts +6 -1
  4. package/dist/components/app-shell/AppShell.js +99 -94
  5. package/dist/components/app-shell/AppShell.js.map +1 -1
  6. package/dist/components/breadcrumbs/Breadcrumbs.d.ts +6 -1
  7. package/dist/components/breadcrumbs/Breadcrumbs.js +42 -40
  8. package/dist/components/breadcrumbs/Breadcrumbs.js.map +1 -1
  9. package/dist/components/calendar/Calendar.js +29 -17
  10. package/dist/components/calendar/Calendar.js.map +1 -1
  11. package/dist/components/combobox/Combobox.d.ts +1 -1
  12. package/dist/components/combobox/Combobox.js +38 -29
  13. package/dist/components/combobox/Combobox.js.map +1 -1
  14. package/dist/components/command-palette/CommandPalette.d.ts +13 -4
  15. package/dist/components/command-palette/CommandPalette.js +91 -89
  16. package/dist/components/command-palette/CommandPalette.js.map +1 -1
  17. package/dist/components/data-table/DataTable.d.ts +38 -13
  18. package/dist/components/data-table/DataTable.js +421 -266
  19. package/dist/components/data-table/DataTable.js.map +1 -1
  20. package/dist/components/data-table/DataTableContent.d.ts +7 -1
  21. package/dist/components/data-table/DataTableContent.js +246 -210
  22. package/dist/components/data-table/DataTableContent.js.map +1 -1
  23. package/dist/components/data-table/DataTableFilters.d.ts +4 -3
  24. package/dist/components/data-table/DataTableFilters.js +311 -194
  25. package/dist/components/data-table/DataTableFilters.js.map +1 -1
  26. package/dist/components/data-table/DataTableRow.js +76 -72
  27. package/dist/components/data-table/DataTableRow.js.map +1 -1
  28. package/dist/components/data-table/layout.d.ts +5 -0
  29. package/dist/components/data-table/layout.js +23 -1
  30. package/dist/components/data-table/layout.js.map +1 -1
  31. package/dist/components/data-table/types.d.ts +57 -3
  32. package/dist/components/data-table/useDataTable.d.ts +1 -1
  33. package/dist/components/data-table/useDataTable.js +396 -351
  34. package/dist/components/data-table/useDataTable.js.map +1 -1
  35. package/dist/components/dialog/ConfirmDialog.d.ts +6 -1
  36. package/dist/components/dialog/ConfirmDialog.js +88 -85
  37. package/dist/components/dialog/ConfirmDialog.js.map +1 -1
  38. package/dist/components/progress/Progress.d.ts +2 -1
  39. package/dist/components/progress/Progress.js.map +1 -1
  40. package/dist/components/stat-card/StatCard.d.ts +7 -2
  41. package/dist/components/stat-card/StatCard.js +1 -1
  42. package/dist/components/stat-card/StatCard.js.map +1 -1
  43. package/dist/components/table/Table.d.ts +5 -1
  44. package/dist/components/table/Table.js +2 -1
  45. package/dist/components/table/Table.js.map +1 -1
  46. package/dist/components.json +124 -18
  47. package/dist/fonts/JetBrainsMono-OFL.txt +93 -0
  48. package/dist/fonts/jetbrains-mono-latin-ext.woff2 +0 -0
  49. package/dist/fonts/jetbrains-mono-latin.woff2 +0 -0
  50. package/dist/fonts.css +22 -1
  51. package/dist/icons/index.d.ts +4 -0
  52. package/dist/icons/index.js +12 -1
  53. package/dist/icons/index.js.map +1 -1
  54. package/dist/index.d.ts +1 -0
  55. package/dist/index.js +3 -2
  56. package/dist/labels/Labels.d.ts +9 -1
  57. package/dist/labels/Labels.js +4 -0
  58. package/dist/labels/Labels.js.map +1 -1
  59. package/dist/labels/hu.d.ts +17 -0
  60. package/dist/labels/hu.js +124 -0
  61. package/dist/labels/hu.js.map +1 -0
  62. package/dist/llms-full.txt +60 -17
  63. package/dist/llms.txt +2 -1
  64. package/dist/opti-ui.css +303 -70
  65. package/dist/utils/scroll-fade.d.ts +5 -1
  66. package/dist/utils/scroll-fade.js +11 -1
  67. package/dist/utils/scroll-fade.js.map +1 -1
  68. 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","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// ─── 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,QA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E,EAAA,QAAAoF,MAAApF,EAAA,QAAAsF,MAAAtF,EAAA,QAAAuF,MAAAvF,EAAA,QAAAwF,IAAA;EAN5EI,KAAA;GAAA3B;GAAAC;GAAAC,QAGGiB;GAAchB,OACfkB;GAAsB1B,WAClB2B;GAAqBlB,UACtBmB;EACZ;EAACxF,EAAA,MAAAkE;EAAAlE,EAAA,MAAAiE;EAAAjE,EAAA,MAAAoF;EAAApF,EAAA,MAAAsF;EAAAtF,EAAA,MAAAuF;EAAAvF,EAAA,MAAAwF;EAAAxF,EAAA,MAAA4F;CAAA,OAAAA,KAAA5F,EAAA;CAAA,OAPM4F;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;C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AA,OAAxEwF;CAAwE;CAInF,MAAAA,KAAAnB,QAAQZ;CACT,MAAAiC,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;
@@ -137,6 +154,11 @@ export interface DataTableColumn<T> {
137
154
  edit?: NonNullable<DataTableColumnEdit<T>['type']> | DataTableColumnEdit<T>;
138
155
  /** Leaves the column out of the grid; it still takes part in search, filters and sorting. */
139
156
  hidden?: boolean;
157
+ /**
158
+ * `false` keeps the column out of `DataTable.ColumnsMenu`, so it cannot be hidden: the row's name or id.
159
+ * @default true
160
+ */
161
+ hideable?: boolean;
140
162
  align?: 'start' | 'center' | 'end';
141
163
  /** Right-align with tabular figures. */
142
164
  numeric?: boolean;
@@ -174,6 +196,11 @@ export interface DataTableRowAction {
174
196
  danger?: boolean;
175
197
  }
176
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';
177
204
  export interface DataTableEntry<T> {
178
205
  id: string;
179
206
  row: T;
@@ -184,7 +211,10 @@ export interface DataTableLabels extends PaginationLabels {
184
211
  selectAll: string;
185
212
  selectRow: (label: string) => string;
186
213
  count: (count: number) => React.ReactNode;
187
- /** 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
+ */
188
218
  filteredCount: (count: number, total: number) => React.ReactNode;
189
219
  selected: (count: number) => React.ReactNode;
190
220
  emptyTitle: React.ReactNode;
@@ -209,6 +239,10 @@ export interface DataTableLabels extends PaginationLabels {
209
239
  clearFilters: string;
210
240
  /** Accessible name of the row actions column. */
211
241
  actions: string;
242
+ /** The columns menu button (its name and tooltip) and the menu's heading. */
243
+ columns: string;
244
+ /** Button in the selection bar that unselects every row. */
245
+ clearSelection: string;
212
246
  /** The CSV export button. */
213
247
  export: string;
214
248
  edit: string;
@@ -285,6 +319,12 @@ export interface UseDataTableOptions<T> {
285
319
  selection?: string[];
286
320
  /** Called with the selected row ids. */
287
321
  onSelectionChange?: (selection: string[]) => void;
322
+ /** Ids of the columns hidden from the columns menu (controlled). Columns with `hidden` stay hidden regardless. */
323
+ hiddenColumns?: string[];
324
+ /** Initial hidden column ids when uncontrolled. */
325
+ defaultHiddenColumns?: string[];
326
+ /** Called with the hidden column ids when one is shown or hidden; store them to keep the choice. */
327
+ onHiddenColumnsChange?: (hiddenColumns: string[]) => void;
288
328
  /** Makes rows clickable and keyboard-activatable (Enter). */
289
329
  onRowClick?: (row: T) => void;
290
330
  /** Accessible name of a row, used by row selection and clickable rows. */
@@ -293,6 +333,12 @@ export interface UseDataTableOptions<T> {
293
333
  rowActions?: (row: T) => DataTableRowAction[] | React.ReactNode;
294
334
  /** Tints a row to flag its state. */
295
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;
296
342
  /** Extra props for a row's `<tr>` (`className`, `style`, `data-*`). */
297
343
  rowProps?: (row: T) => React.HTMLAttributes<HTMLTableRowElement> & Record<`data-${string}`, unknown>;
298
344
  /**
@@ -311,7 +357,12 @@ export interface DataTableInstance<T> {
311
357
  mode: 'client' | 'server';
312
358
  /** Every column, hidden ones included. */
313
359
  columns: DataTableColumn<T>[];
360
+ /** Columns in the grid: without `hidden` ones and those hidden from the columns menu. */
314
361
  visibleColumns: DataTableColumn<T>[];
362
+ /** Ids of the columns hidden from the columns menu. */
363
+ hiddenColumns: string[];
364
+ /** Shows or hides a column, as the columns menu does. */
365
+ setColumnHidden: (id: string, hidden: boolean) => void;
315
366
  labels: DataTableResolvedLabels;
316
367
  locale?: string;
317
368
  /** Every row of `data`, before search and filters. */
@@ -362,6 +413,8 @@ export interface DataTableInstance<T> {
362
413
  isSelected: (id: string) => boolean;
363
414
  toggleRow: (id: string, selected: boolean) => void;
364
415
  toggleAll: (selected: boolean) => void;
416
+ /** Unselects every row, filtered out ones included. */
417
+ clearSelection: () => void;
365
418
  allSelected: boolean;
366
419
  someSelected: boolean;
367
420
  editable: boolean;
@@ -381,6 +434,7 @@ export interface DataTableInstance<T> {
381
434
  rowLabel?: (row: T) => string;
382
435
  rowActions?: (row: T) => DataTableRowAction[] | React.ReactNode;
383
436
  rowTone?: (row: T) => DataTableRowTone | null | undefined;
437
+ rowToneStyle: DataTableRowToneStyle;
384
438
  rowProps?: (row: T) => React.HTMLAttributes<HTMLTableRowElement>;
385
439
  }
386
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, 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>;