@hexclave/dashboard-ui-components 1.0.23 → 1.0.25
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/dist/components/data-grid/data-grid.test.js +1 -0
- package/dist/components/data-grid/data-grid.test.js.map +1 -1
- package/dist/dashboard-ui-components.global.js +19 -6
- package/dist/dashboard-ui-components.global.js.map +2 -2
- package/dist/esm/components/data-grid/data-grid.test.js +1 -0
- package/dist/esm/components/data-grid/data-grid.test.js.map +1 -1
- package/package.json +3 -3
- package/src/components/data-grid/data-grid.test.tsx +2 -0
|
@@ -37,6 +37,7 @@ var MockIntersectionObserver = class {
|
|
|
37
37
|
this.callback = callback;
|
|
38
38
|
this.root = options?.root ?? null;
|
|
39
39
|
this.rootMargin = options?.rootMargin ?? "";
|
|
40
|
+
this.scrollMargin = "";
|
|
40
41
|
this.thresholds = Array.isArray(options?.threshold) ? options.threshold : [options?.threshold ?? 0];
|
|
41
42
|
this.record = { options };
|
|
42
43
|
intersectionObserverRecords.push(this.record);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data-grid.test.js","names":["DataGrid","vi"],"sources":["../../../src/components/data-grid/data-grid.test.tsx"],"sourcesContent":["// @vitest-environment jsdom\n\nimport { cleanup, fireEvent, render, waitFor } from \"@testing-library/react\";\nimport { useState } from \"react\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport {\n createDefaultDataGridState,\n DataGrid,\n isDataGridInteractiveRowClickTarget,\n type DataGridColumnDef,\n type DataGridProps,\n} from \"./index\";\n\ntype Row = {\n id: string,\n name: string,\n};\n\nconst columns: DataGridColumnDef<Row>[] = [\n {\n id: \"name\",\n header: \"Name\",\n accessor: (row) => row.name,\n width: 160,\n minWidth: 80,\n sortable: true,\n type: \"string\",\n },\n];\n\nconst wideColumns: DataGridColumnDef<Row>[] = [\n {\n id: \"name\",\n header: \"Name\",\n accessor: (row) => row.name,\n width: 320,\n minWidth: 80,\n type: \"string\",\n },\n {\n id: \"email\",\n header: \"Email\",\n accessor: (row) => `${row.name.toLowerCase().replaceAll(\" \", \".\")}@example.com`,\n width: 420,\n minWidth: 80,\n type: \"string\",\n },\n];\n\ntype ObserverRecord = {\n options?: IntersectionObserverInit,\n};\n\nlet intersectionObserverRecords: ObserverRecord[] = [];\n\nclass MockIntersectionObserver implements IntersectionObserver {\n readonly root: Element | Document | null;\n readonly rootMargin: string;\n readonly thresholds: ReadonlyArray<number>;\n private readonly callback: IntersectionObserverCallback;\n private readonly record: ObserverRecord;\n\n constructor(\n callback: IntersectionObserverCallback,\n options?: IntersectionObserverInit,\n ) {\n this.callback = callback;\n this.root = options?.root ?? null;\n this.rootMargin = options?.rootMargin ?? \"\";\n this.thresholds = Array.isArray(options?.threshold)\n ? options.threshold\n : [options?.threshold ?? 0];\n this.record = { options };\n intersectionObserverRecords.push(this.record);\n }\n\n disconnect() {}\n observe() {}\n takeRecords(): IntersectionObserverEntry[] {\n return [];\n }\n unobserve() {}\n\n trigger(entry: Partial<IntersectionObserverEntry> = {}) {\n this.callback(\n [\n {\n boundingClientRect: {} as DOMRectReadOnly,\n intersectionRatio: 1,\n intersectionRect: {} as DOMRectReadOnly,\n isIntersecting: true,\n rootBounds: null,\n target: document.createElement(\"div\"),\n time: 0,\n ...entry,\n },\n ],\n this,\n );\n }\n}\n\nclass MockResizeObserver implements ResizeObserver {\n private readonly callback: ResizeObserverCallback;\n\n constructor(callback: ResizeObserverCallback) {\n this.callback = callback;\n }\n\n disconnect() {}\n observe(target: Element) {\n const el = target instanceof HTMLElement ? target : null;\n const parentWidth = el?.parentElement instanceof HTMLElement ? el.parentElement.clientWidth : 0;\n const width = (el?.clientWidth ?? 0) > 0 ? (el?.clientWidth ?? 320) : parentWidth > 0 ? parentWidth : 320;\n const height = (el?.clientHeight ?? 0) > 0 ? (el?.clientHeight ?? 400) : 400;\n this.callback(\n [\n {\n target,\n contentRect: {\n x: 0,\n y: 0,\n width,\n height,\n top: 0,\n left: 0,\n right: width,\n bottom: height,\n toJSON() {\n return this;\n },\n } as DOMRectReadOnly,\n borderBoxSize: [],\n contentBoxSize: [],\n devicePixelContentBoxSize: [],\n },\n ],\n this,\n );\n }\n unobserve() {}\n}\n\nfunction DataGridHarness(props: { fillHeight?: boolean }) {\n const [state, setState] = useState(() => createDefaultDataGridState(columns));\n\n return (\n <div style={{ height: 400 }}>\n <DataGrid<Row>\n columns={columns}\n rows={[{ id: \"row-1\", name: \"Row 1\" }]}\n getRowId={(row) => row.id}\n state={state}\n onChange={setState}\n paginationMode=\"infinite\"\n hasMore\n fillHeight={props.fillHeight}\n />\n </div>\n );\n}\n\nfunction InteractiveDataGridHarness(props: {\n onSortChange?: DataGridProps<Row>[\"onSortChange\"],\n onSelectionChange?: DataGridProps<Row>[\"onSelectionChange\"],\n}) {\n const [state, setState] = useState(() => createDefaultDataGridState(columns));\n\n return (\n <DataGrid<Row>\n columns={columns}\n rows={[{ id: \"row-1\", name: \"Row 1\" }]}\n getRowId={(row) => row.id}\n state={state}\n onChange={setState}\n selectionMode=\"multiple\"\n onSortChange={props.onSortChange}\n onSelectionChange={props.onSelectionChange}\n />\n );\n}\n\nfunction WideDataGridHarness() {\n const [state, setState] = useState(() => createDefaultDataGridState(wideColumns));\n\n return (\n <div style={{ width: 320 }}>\n <DataGrid<Row>\n columns={wideColumns}\n rows={[{ id: \"row-1\", name: \"Row 1\" }]}\n getRowId={(row) => row.id}\n state={state}\n onChange={setState}\n />\n </div>\n );\n}\n\ndescribe(\"DataGrid infinite scroll observer\", () => {\n beforeEach(() => {\n intersectionObserverRecords = [];\n\n vi.stubGlobal(\"IntersectionObserver\", MockIntersectionObserver);\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n vi.spyOn(HTMLElement.prototype, \"getBoundingClientRect\").mockImplementation(\n function getBoundingClientRect() {\n return {\n x: 0,\n y: 0,\n width: 320,\n height: 44,\n top: 0,\n left: 0,\n right: 320,\n bottom: 44,\n toJSON() {\n return this;\n },\n } as DOMRect;\n },\n );\n Object.defineProperty(HTMLElement.prototype, \"clientHeight\", {\n configurable: true,\n get() {\n return 400;\n },\n });\n Object.defineProperty(HTMLElement.prototype, \"scrollHeight\", {\n configurable: true,\n get() {\n return 400;\n },\n });\n });\n\n afterEach(() => {\n cleanup();\n vi.restoreAllMocks();\n vi.unstubAllGlobals();\n });\n\n it(\"observes against the grid body when the grid owns vertical scrolling\", async () => {\n const { container } = render(<DataGridHarness fillHeight />);\n\n await waitFor(() => {\n expect(intersectionObserverRecords.length).toBeGreaterThan(0);\n });\n\n const grid = container.querySelector('[role=\"grid\"]');\n expect(grid).not.toBeNull();\n const scrollContainer = grid?.children.item(1);\n\n expect(intersectionObserverRecords.at(-1)?.options?.root).toBe(scrollContainer);\n });\n\n it(\"falls back to the viewport when the page owns vertical scrolling\", async () => {\n render(<DataGridHarness fillHeight={false} />);\n\n await waitFor(() => {\n expect(intersectionObserverRecords.length).toBeGreaterThan(0);\n });\n\n expect(intersectionObserverRecords.at(-1)?.options?.root ?? null).toBeNull();\n });\n});\n\ndescribe(\"DataGrid controlled callbacks\", () => {\n beforeEach(() => {\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n vi.spyOn(HTMLElement.prototype, \"getBoundingClientRect\").mockImplementation(\n function getBoundingClientRect() {\n return {\n x: 0,\n y: 0,\n width: 320,\n height: 44,\n top: 0,\n left: 0,\n right: 320,\n bottom: 44,\n toJSON() {\n return this;\n },\n } as DOMRect;\n },\n );\n Object.defineProperty(HTMLElement.prototype, \"clientHeight\", {\n configurable: true,\n get() {\n return 400;\n },\n });\n Object.defineProperty(HTMLElement.prototype, \"scrollHeight\", {\n configurable: true,\n get() {\n return 400;\n },\n });\n });\n\n afterEach(() => {\n cleanup();\n vi.restoreAllMocks();\n vi.unstubAllGlobals();\n });\n\n it(\"fires onSortChange from the current controlled sort state\", () => {\n const onSortChange = vi.fn();\n const { getByRole } = render(<InteractiveDataGridHarness onSortChange={onSortChange} />);\n\n fireEvent.click(getByRole(\"columnheader\", { name: /name/i }));\n\n expect(onSortChange).toHaveBeenCalledTimes(1);\n expect(onSortChange).toHaveBeenCalledWith([{ columnId: \"name\", direction: \"asc\" }]);\n });\n\n it(\"fires onSelectionChange when selecting all rows\", () => {\n const onSelectionChange = vi.fn();\n const { getByRole } = render(<InteractiveDataGridHarness onSelectionChange={onSelectionChange} />);\n\n fireEvent.click(getByRole(\"checkbox\", { name: /select all rows/i }));\n\n expect(onSelectionChange).toHaveBeenCalledTimes(1);\n const [selectedIds, selectedRows] = onSelectionChange.mock.calls[0];\n expect([...selectedIds]).toEqual([\"row-1\"]);\n expect(selectedRows).toEqual([{ id: \"row-1\", name: \"Row 1\" }]);\n });\n\n it(\"identifies nested interactive controls as row-click blockers\", () => {\n const cell = document.createElement(\"div\");\n const button = document.createElement(\"button\");\n const label = document.createElement(\"span\");\n label.textContent = \"Open menu\";\n button.append(label);\n cell.append(button);\n\n expect(isDataGridInteractiveRowClickTarget(label.firstChild)).toBe(true);\n expect(isDataGridInteractiveRowClickTarget(cell)).toBe(false);\n });\n});\n\ndescribe(\"DataGrid horizontal scrolling\", () => {\n beforeEach(() => {\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n Object.defineProperty(HTMLElement.prototype, \"clientWidth\", {\n configurable: true,\n get() {\n return 320;\n },\n });\n vi.spyOn(HTMLElement.prototype, \"getBoundingClientRect\").mockImplementation(\n function getBoundingClientRect() {\n return {\n x: 0,\n y: 0,\n width: 320,\n height: 44,\n top: 0,\n left: 0,\n right: 320,\n bottom: 44,\n toJSON() {\n return this;\n },\n } as DOMRect;\n },\n );\n Object.defineProperty(HTMLElement.prototype, \"clientHeight\", {\n configurable: true,\n get() {\n return 400;\n },\n });\n Object.defineProperty(HTMLElement.prototype, \"scrollHeight\", {\n configurable: true,\n get() {\n return 400;\n },\n });\n });\n\n afterEach(() => {\n cleanup();\n vi.restoreAllMocks();\n vi.unstubAllGlobals();\n });\n\n it(\"sizes the sticky clipping layer to the full row width\", () => {\n const { container } = render(<WideDataGridHarness />);\n\n const rowsClip = container.querySelector(\"[data-data-grid-rows-clip]\");\n\n expect(rowsClip).toBeInstanceOf(HTMLElement);\n expect((rowsClip as HTMLElement).style.minWidth).toBe(\"740px\");\n });\n\n it(\"lets the columns popover escape the sticky toolbar bounds\", () => {\n const { container, getByTitle } = render(<WideDataGridHarness />);\n\n fireEvent.click(getByTitle(\"Columns\"));\n\n const stickyChrome = container.querySelector('[role=\"grid\"]')?.firstElementChild;\n expect(stickyChrome).toBeInstanceOf(HTMLElement);\n expect((stickyChrome as HTMLElement).className).toContain(\"overflow-visible\");\n expect(container.textContent).toContain(\"Email\");\n });\n});\n"],"mappings":";;;;;;;;;AAkBA,MAAM,UAAoC,CACxC;CACE,IAAI;CACJ,QAAQ;CACR,WAAW,QAAQ,IAAI;CACvB,OAAO;CACP,UAAU;CACV,UAAU;CACV,MAAM;CACP,CACF;AAED,MAAM,cAAwC,CAC5C;CACE,IAAI;CACJ,QAAQ;CACR,WAAW,QAAQ,IAAI;CACvB,OAAO;CACP,UAAU;CACV,MAAM;CACP,EACD;CACE,IAAI;CACJ,QAAQ;CACR,WAAW,QAAQ,GAAG,IAAI,KAAK,aAAa,CAAC,WAAW,KAAK,IAAI,CAAC;CAClE,OAAO;CACP,UAAU;CACV,MAAM;CACP,CACF;AAMD,IAAI,8BAAgD,EAAE;AAEtD,IAAM,2BAAN,MAA+D;CAO7D,YACE,UACA,SACA;AACA,OAAK,WAAW;AAChB,OAAK,OAAO,SAAS,QAAQ;AAC7B,OAAK,aAAa,SAAS,cAAc;AACzC,OAAK,aAAa,MAAM,QAAQ,SAAS,UAAU,GAC/C,QAAQ,YACR,CAAC,SAAS,aAAa,EAAE;AAC7B,OAAK,SAAS,EAAE,SAAS;AACzB,8BAA4B,KAAK,KAAK,OAAO;;CAG/C,aAAa;CACb,UAAU;CACV,cAA2C;AACzC,SAAO,EAAE;;CAEX,YAAY;CAEZ,QAAQ,QAA4C,EAAE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,CAAC;EAErD,MAAM,WAAW,UAAU,cAAc,6BAA6B;AAEtE,qBAAO,SAAS,CAAC,eAAe,YAAY;AAC5C,qBAAQ,SAAyB,MAAM,SAAS,CAAC,KAAK,QAAQ;GAC9D;AAEF,gBAAG,mEAAmE;EACpE,MAAM,EAAE,WAAW,kDAAsB,2CAAC,wBAAsB,CAAC;AAEjE,mCAAU,MAAM,WAAW,UAAU,CAAC;EAEtC,MAAM,eAAe,UAAU,cAAc,kBAAgB,EAAE;AAC/D,qBAAO,aAAa,CAAC,eAAe,YAAY;AAChD,qBAAQ,aAA6B,UAAU,CAAC,UAAU,mBAAmB;AAC7E,qBAAO,UAAU,YAAY,CAAC,UAAU,QAAQ;GAChD;EACF"}
|
|
1
|
+
{"version":3,"file":"data-grid.test.js","names":["DataGrid","vi"],"sources":["../../../src/components/data-grid/data-grid.test.tsx"],"sourcesContent":["// @vitest-environment jsdom\n\nimport { cleanup, fireEvent, render, waitFor } from \"@testing-library/react\";\nimport { useState } from \"react\";\nimport { afterEach, beforeEach, describe, expect, it, vi } from \"vitest\";\nimport {\n createDefaultDataGridState,\n DataGrid,\n isDataGridInteractiveRowClickTarget,\n type DataGridColumnDef,\n type DataGridProps,\n} from \"./index\";\n\ntype Row = {\n id: string,\n name: string,\n};\n\nconst columns: DataGridColumnDef<Row>[] = [\n {\n id: \"name\",\n header: \"Name\",\n accessor: (row) => row.name,\n width: 160,\n minWidth: 80,\n sortable: true,\n type: \"string\",\n },\n];\n\nconst wideColumns: DataGridColumnDef<Row>[] = [\n {\n id: \"name\",\n header: \"Name\",\n accessor: (row) => row.name,\n width: 320,\n minWidth: 80,\n type: \"string\",\n },\n {\n id: \"email\",\n header: \"Email\",\n accessor: (row) => `${row.name.toLowerCase().replaceAll(\" \", \".\")}@example.com`,\n width: 420,\n minWidth: 80,\n type: \"string\",\n },\n];\n\ntype ObserverRecord = {\n options?: IntersectionObserverInit,\n};\n\nlet intersectionObserverRecords: ObserverRecord[] = [];\n\nclass MockIntersectionObserver implements IntersectionObserver {\n readonly root: Element | Document | null;\n readonly rootMargin: string;\n readonly scrollMargin: string;\n readonly thresholds: ReadonlyArray<number>;\n private readonly callback: IntersectionObserverCallback;\n private readonly record: ObserverRecord;\n\n constructor(\n callback: IntersectionObserverCallback,\n options?: IntersectionObserverInit,\n ) {\n this.callback = callback;\n this.root = options?.root ?? null;\n this.rootMargin = options?.rootMargin ?? \"\";\n this.scrollMargin = \"\";\n this.thresholds = Array.isArray(options?.threshold)\n ? options.threshold\n : [options?.threshold ?? 0];\n this.record = { options };\n intersectionObserverRecords.push(this.record);\n }\n\n disconnect() {}\n observe() {}\n takeRecords(): IntersectionObserverEntry[] {\n return [];\n }\n unobserve() {}\n\n trigger(entry: Partial<IntersectionObserverEntry> = {}) {\n this.callback(\n [\n {\n boundingClientRect: {} as DOMRectReadOnly,\n intersectionRatio: 1,\n intersectionRect: {} as DOMRectReadOnly,\n isIntersecting: true,\n rootBounds: null,\n target: document.createElement(\"div\"),\n time: 0,\n ...entry,\n },\n ],\n this,\n );\n }\n}\n\nclass MockResizeObserver implements ResizeObserver {\n private readonly callback: ResizeObserverCallback;\n\n constructor(callback: ResizeObserverCallback) {\n this.callback = callback;\n }\n\n disconnect() {}\n observe(target: Element) {\n const el = target instanceof HTMLElement ? target : null;\n const parentWidth = el?.parentElement instanceof HTMLElement ? el.parentElement.clientWidth : 0;\n const width = (el?.clientWidth ?? 0) > 0 ? (el?.clientWidth ?? 320) : parentWidth > 0 ? parentWidth : 320;\n const height = (el?.clientHeight ?? 0) > 0 ? (el?.clientHeight ?? 400) : 400;\n this.callback(\n [\n {\n target,\n contentRect: {\n x: 0,\n y: 0,\n width,\n height,\n top: 0,\n left: 0,\n right: width,\n bottom: height,\n toJSON() {\n return this;\n },\n } as DOMRectReadOnly,\n borderBoxSize: [],\n contentBoxSize: [],\n devicePixelContentBoxSize: [],\n },\n ],\n this,\n );\n }\n unobserve() {}\n}\n\nfunction DataGridHarness(props: { fillHeight?: boolean }) {\n const [state, setState] = useState(() => createDefaultDataGridState(columns));\n\n return (\n <div style={{ height: 400 }}>\n <DataGrid<Row>\n columns={columns}\n rows={[{ id: \"row-1\", name: \"Row 1\" }]}\n getRowId={(row) => row.id}\n state={state}\n onChange={setState}\n paginationMode=\"infinite\"\n hasMore\n fillHeight={props.fillHeight}\n />\n </div>\n );\n}\n\nfunction InteractiveDataGridHarness(props: {\n onSortChange?: DataGridProps<Row>[\"onSortChange\"],\n onSelectionChange?: DataGridProps<Row>[\"onSelectionChange\"],\n}) {\n const [state, setState] = useState(() => createDefaultDataGridState(columns));\n\n return (\n <DataGrid<Row>\n columns={columns}\n rows={[{ id: \"row-1\", name: \"Row 1\" }]}\n getRowId={(row) => row.id}\n state={state}\n onChange={setState}\n selectionMode=\"multiple\"\n onSortChange={props.onSortChange}\n onSelectionChange={props.onSelectionChange}\n />\n );\n}\n\nfunction WideDataGridHarness() {\n const [state, setState] = useState(() => createDefaultDataGridState(wideColumns));\n\n return (\n <div style={{ width: 320 }}>\n <DataGrid<Row>\n columns={wideColumns}\n rows={[{ id: \"row-1\", name: \"Row 1\" }]}\n getRowId={(row) => row.id}\n state={state}\n onChange={setState}\n />\n </div>\n );\n}\n\ndescribe(\"DataGrid infinite scroll observer\", () => {\n beforeEach(() => {\n intersectionObserverRecords = [];\n\n vi.stubGlobal(\"IntersectionObserver\", MockIntersectionObserver);\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n vi.spyOn(HTMLElement.prototype, \"getBoundingClientRect\").mockImplementation(\n function getBoundingClientRect() {\n return {\n x: 0,\n y: 0,\n width: 320,\n height: 44,\n top: 0,\n left: 0,\n right: 320,\n bottom: 44,\n toJSON() {\n return this;\n },\n } as DOMRect;\n },\n );\n Object.defineProperty(HTMLElement.prototype, \"clientHeight\", {\n configurable: true,\n get() {\n return 400;\n },\n });\n Object.defineProperty(HTMLElement.prototype, \"scrollHeight\", {\n configurable: true,\n get() {\n return 400;\n },\n });\n });\n\n afterEach(() => {\n cleanup();\n vi.restoreAllMocks();\n vi.unstubAllGlobals();\n });\n\n it(\"observes against the grid body when the grid owns vertical scrolling\", async () => {\n const { container } = render(<DataGridHarness fillHeight />);\n\n await waitFor(() => {\n expect(intersectionObserverRecords.length).toBeGreaterThan(0);\n });\n\n const grid = container.querySelector('[role=\"grid\"]');\n expect(grid).not.toBeNull();\n const scrollContainer = grid?.children.item(1);\n\n expect(intersectionObserverRecords.at(-1)?.options?.root).toBe(scrollContainer);\n });\n\n it(\"falls back to the viewport when the page owns vertical scrolling\", async () => {\n render(<DataGridHarness fillHeight={false} />);\n\n await waitFor(() => {\n expect(intersectionObserverRecords.length).toBeGreaterThan(0);\n });\n\n expect(intersectionObserverRecords.at(-1)?.options?.root ?? null).toBeNull();\n });\n});\n\ndescribe(\"DataGrid controlled callbacks\", () => {\n beforeEach(() => {\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n vi.spyOn(HTMLElement.prototype, \"getBoundingClientRect\").mockImplementation(\n function getBoundingClientRect() {\n return {\n x: 0,\n y: 0,\n width: 320,\n height: 44,\n top: 0,\n left: 0,\n right: 320,\n bottom: 44,\n toJSON() {\n return this;\n },\n } as DOMRect;\n },\n );\n Object.defineProperty(HTMLElement.prototype, \"clientHeight\", {\n configurable: true,\n get() {\n return 400;\n },\n });\n Object.defineProperty(HTMLElement.prototype, \"scrollHeight\", {\n configurable: true,\n get() {\n return 400;\n },\n });\n });\n\n afterEach(() => {\n cleanup();\n vi.restoreAllMocks();\n vi.unstubAllGlobals();\n });\n\n it(\"fires onSortChange from the current controlled sort state\", () => {\n const onSortChange = vi.fn();\n const { getByRole } = render(<InteractiveDataGridHarness onSortChange={onSortChange} />);\n\n fireEvent.click(getByRole(\"columnheader\", { name: /name/i }));\n\n expect(onSortChange).toHaveBeenCalledTimes(1);\n expect(onSortChange).toHaveBeenCalledWith([{ columnId: \"name\", direction: \"asc\" }]);\n });\n\n it(\"fires onSelectionChange when selecting all rows\", () => {\n const onSelectionChange = vi.fn();\n const { getByRole } = render(<InteractiveDataGridHarness onSelectionChange={onSelectionChange} />);\n\n fireEvent.click(getByRole(\"checkbox\", { name: /select all rows/i }));\n\n expect(onSelectionChange).toHaveBeenCalledTimes(1);\n const [selectedIds, selectedRows] = onSelectionChange.mock.calls[0];\n expect([...selectedIds]).toEqual([\"row-1\"]);\n expect(selectedRows).toEqual([{ id: \"row-1\", name: \"Row 1\" }]);\n });\n\n it(\"identifies nested interactive controls as row-click blockers\", () => {\n const cell = document.createElement(\"div\");\n const button = document.createElement(\"button\");\n const label = document.createElement(\"span\");\n label.textContent = \"Open menu\";\n button.append(label);\n cell.append(button);\n\n expect(isDataGridInteractiveRowClickTarget(label.firstChild)).toBe(true);\n expect(isDataGridInteractiveRowClickTarget(cell)).toBe(false);\n });\n});\n\ndescribe(\"DataGrid horizontal scrolling\", () => {\n beforeEach(() => {\n vi.stubGlobal(\"ResizeObserver\", MockResizeObserver);\n Object.defineProperty(HTMLElement.prototype, \"clientWidth\", {\n configurable: true,\n get() {\n return 320;\n },\n });\n vi.spyOn(HTMLElement.prototype, \"getBoundingClientRect\").mockImplementation(\n function getBoundingClientRect() {\n return {\n x: 0,\n y: 0,\n width: 320,\n height: 44,\n top: 0,\n left: 0,\n right: 320,\n bottom: 44,\n toJSON() {\n return this;\n },\n } as DOMRect;\n },\n );\n Object.defineProperty(HTMLElement.prototype, \"clientHeight\", {\n configurable: true,\n get() {\n return 400;\n },\n });\n Object.defineProperty(HTMLElement.prototype, \"scrollHeight\", {\n configurable: true,\n get() {\n return 400;\n },\n });\n });\n\n afterEach(() => {\n cleanup();\n vi.restoreAllMocks();\n vi.unstubAllGlobals();\n });\n\n it(\"sizes the sticky clipping layer to the full row width\", () => {\n const { container } = render(<WideDataGridHarness />);\n\n const rowsClip = container.querySelector(\"[data-data-grid-rows-clip]\");\n\n expect(rowsClip).toBeInstanceOf(HTMLElement);\n expect((rowsClip as HTMLElement).style.minWidth).toBe(\"740px\");\n });\n\n it(\"lets the columns popover escape the sticky toolbar bounds\", () => {\n const { container, getByTitle } = render(<WideDataGridHarness />);\n\n fireEvent.click(getByTitle(\"Columns\"));\n\n const stickyChrome = container.querySelector('[role=\"grid\"]')?.firstElementChild;\n expect(stickyChrome).toBeInstanceOf(HTMLElement);\n expect((stickyChrome as HTMLElement).className).toContain(\"overflow-visible\");\n expect(container.textContent).toContain(\"Email\");\n });\n});\n"],"mappings":";;;;;;;;;AAkBA,MAAM,UAAoC,CACxC;CACE,IAAI;CACJ,QAAQ;CACR,WAAW,QAAQ,IAAI;CACvB,OAAO;CACP,UAAU;CACV,UAAU;CACV,MAAM;CACP,CACF;AAED,MAAM,cAAwC,CAC5C;CACE,IAAI;CACJ,QAAQ;CACR,WAAW,QAAQ,IAAI;CACvB,OAAO;CACP,UAAU;CACV,MAAM;CACP,EACD;CACE,IAAI;CACJ,QAAQ;CACR,WAAW,QAAQ,GAAG,IAAI,KAAK,aAAa,CAAC,WAAW,KAAK,IAAI,CAAC;CAClE,OAAO;CACP,UAAU;CACV,MAAM;CACP,CACF;AAMD,IAAI,8BAAgD,EAAE;AAEtD,IAAM,2BAAN,MAA+D;CAQ7D,YACE,UACA,SACA;AACA,OAAK,WAAW;AAChB,OAAK,OAAO,SAAS,QAAQ;AAC7B,OAAK,aAAa,SAAS,cAAc;AACzC,OAAK,eAAe;AACpB,OAAK,aAAa,MAAM,QAAQ,SAAS,UAAU,GAC/C,QAAQ,YACR,CAAC,SAAS,aAAa,EAAE;AAC7B,OAAK,SAAS,EAAE,SAAS;AACzB,8BAA4B,KAAK,KAAK,OAAO;;CAG/C,aAAa;CACb,UAAU;CACV,cAA2C;AACzC,SAAO,EAAE;;CAEX,YAAY;CAEZ,QAAQ,QAA4C,EAAE,EAAE;AACtD,OAAK,SACH,CACE;GACE,oBAAoB,EAAE;GACtB,mBAAmB;GACnB,kBAAkB,EAAE;GACpB,gBAAgB;GAChB,YAAY;GACZ,QAAQ,SAAS,cAAc,MAAM;GACrC,MAAM;GACN,GAAG;GAC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;EACpE,MAAM,EAAE,WAAW,kDAAsB,2CAAC,wBAAsB,CAAC;AAEjE,mCAAU,MAAM,WAAW,UAAU,CAAC;EAEtC,MAAM,eAAe,UAAU,cAAc,kBAAgB,EAAE;AAC/D,qBAAO,aAAa,CAAC,eAAe,YAAY;AAChD,qBAAQ,aAA6B,UAAU,CAAC,UAAU,mBAAmB;AAC7E,qBAAO,UAAU,YAAY,CAAC,UAAU,QAAQ;GAChD;EACF"}
|
|
@@ -4113,7 +4113,10 @@ This is likely an error in Hexclave. Please make sure you are running the newest
|
|
|
4113
4113
|
},
|
|
4114
4114
|
enumerable: false
|
|
4115
4115
|
});
|
|
4116
|
-
|
|
4116
|
+
const hexclaveDebuggerValue = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_HEXCLAVE_DEBUGGER_ON_ASSERTION_ERROR : void 0;
|
|
4117
|
+
const stackDebuggerValue = typeof process !== "undefined" ? process.env.NEXT_PUBLIC_STACK_DEBUGGER_ON_ASSERTION_ERROR : void 0;
|
|
4118
|
+
if (hexclaveDebuggerValue && stackDebuggerValue && hexclaveDebuggerValue !== stackDebuggerValue) throw new Error("Environment variables NEXT_PUBLIC_HEXCLAVE_DEBUGGER_ON_ASSERTION_ERROR and NEXT_PUBLIC_STACK_DEBUGGER_ON_ASSERTION_ERROR are both set to different values. Remove one of them or set them to the same value.");
|
|
4119
|
+
if ((hexclaveDebuggerValue || stackDebuggerValue) === "true") debugger;
|
|
4117
4120
|
}
|
|
4118
4121
|
};
|
|
4119
4122
|
HexclaveAssertionError.prototype.name = "HexclaveAssertionError";
|
|
@@ -4316,14 +4319,24 @@ This is likely an error in Hexclave. Please make sure you are running the newest
|
|
|
4316
4319
|
StatusError.prototype.name = "StatusError";
|
|
4317
4320
|
|
|
4318
4321
|
// ../shared/dist/esm/utils/env.js
|
|
4319
|
-
function
|
|
4320
|
-
if (
|
|
4321
|
-
return
|
|
4322
|
+
function resolveHexclaveStackEnvVarValue(hexclaveName, stackName, hexclaveValue, stackValue) {
|
|
4323
|
+
if (hexclaveValue && stackValue && hexclaveValue !== stackValue) throw new Error(`Environment variables ${hexclaveName} and ${stackName} are both set to different values. Remove one of them or set them to the same value.`);
|
|
4324
|
+
return hexclaveValue || stackValue || void 0;
|
|
4325
|
+
}
|
|
4326
|
+
function getEnvVarWithHexclaveFallback(name) {
|
|
4327
|
+
if (name.includes("STACK_")) {
|
|
4328
|
+
const hexclaveName = name.replace("STACK_", "HEXCLAVE_");
|
|
4329
|
+
return resolveHexclaveStackEnvVarValue(hexclaveName, name, process.env[hexclaveName], process.env[name]);
|
|
4330
|
+
}
|
|
4331
|
+
if (name.includes("HEXCLAVE_")) {
|
|
4332
|
+
const stackName = name.replace("HEXCLAVE_", "STACK_");
|
|
4333
|
+
return resolveHexclaveStackEnvVarValue(name, stackName, process.env[name], process.env[stackName]);
|
|
4334
|
+
}
|
|
4335
|
+
return process.env[name];
|
|
4322
4336
|
}
|
|
4323
4337
|
function getProcessEnv(name) {
|
|
4324
4338
|
if (typeof process === "undefined" || typeof process.env === "undefined") return;
|
|
4325
|
-
|
|
4326
|
-
return (hexclaveName ? process.env[hexclaveName] : void 0) ?? process.env[name];
|
|
4339
|
+
return getEnvVarWithHexclaveFallback(name);
|
|
4327
4340
|
}
|
|
4328
4341
|
|
|
4329
4342
|
// ../shared/dist/esm/utils/results.js
|