@osdk/react-components 0.2.0-beta.10 → 0.2.0-beta.12
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/AGENTS.md +105 -0
- package/CHANGELOG.md +22 -0
- package/build/browser/object-table/DefaultCellRenderer.js +5 -2
- package/build/browser/object-table/DefaultCellRenderer.js.map +1 -1
- package/build/browser/object-table/EditableCell.js +16 -6
- package/build/browser/object-table/EditableCell.js.map +1 -1
- package/build/browser/object-table/EditableCell.module.css +30 -2
- package/build/browser/object-table/EditableCell.module.css.js +2 -1
- package/build/browser/object-table/ObjectTable.js +9 -22
- package/build/browser/object-table/ObjectTable.js.map +1 -1
- package/build/browser/object-table/ObjectTableApi.js.map +1 -1
- package/build/browser/object-table/Table.js +23 -15
- package/build/browser/object-table/Table.js.map +1 -1
- package/build/browser/object-table/Table.module.css +0 -8
- package/build/browser/object-table/Table.module.css.js +1 -2
- package/build/browser/object-table/TableBody.js +8 -2
- package/build/browser/object-table/TableBody.js.map +1 -1
- package/build/browser/object-table/TableCell.module.css +0 -8
- package/build/browser/object-table/TableEditContainer.js +79 -0
- package/build/browser/object-table/TableEditContainer.js.map +1 -0
- package/build/browser/object-table/TableEditContainer.module.css +44 -0
- package/build/browser/object-table/TableEditContainer.module.css.js +9 -0
- package/build/browser/object-table/TableRow.js +12 -4
- package/build/browser/object-table/TableRow.js.map +1 -1
- package/build/browser/object-table/TableRow.module.css +2 -1
- package/build/browser/object-table/hooks/useEditableTable.js +20 -11
- package/build/browser/object-table/hooks/useEditableTable.js.map +1 -1
- package/build/browser/object-table/hooks/useObjectTableData.js +0 -5
- package/build/browser/object-table/hooks/useObjectTableData.js.map +1 -1
- package/build/browser/object-table/utils/getCellId.js +0 -7
- package/build/browser/object-table/utils/getCellId.js.map +1 -1
- package/build/browser/object-table/utils/types.js.map +1 -1
- package/build/browser/public/experimental.js.map +1 -1
- package/build/browser/styles.css +79 -19
- package/build/cjs/public/experimental.cjs +179 -90
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.css +96 -57
- package/build/cjs/public/experimental.css.map +1 -1
- package/build/cjs/public/experimental.d.cts +40 -18
- package/build/esm/object-table/DefaultCellRenderer.js +5 -2
- package/build/esm/object-table/DefaultCellRenderer.js.map +1 -1
- package/build/esm/object-table/EditableCell.js +16 -6
- package/build/esm/object-table/EditableCell.js.map +1 -1
- package/build/esm/object-table/EditableCell.module.css +30 -2
- package/build/esm/object-table/ObjectTable.js +9 -22
- package/build/esm/object-table/ObjectTable.js.map +1 -1
- package/build/esm/object-table/ObjectTableApi.js.map +1 -1
- package/build/esm/object-table/Table.js +23 -15
- package/build/esm/object-table/Table.js.map +1 -1
- package/build/esm/object-table/Table.module.css +0 -8
- package/build/esm/object-table/TableBody.js +8 -2
- package/build/esm/object-table/TableBody.js.map +1 -1
- package/build/esm/object-table/TableCell.module.css +0 -8
- package/build/esm/object-table/TableEditContainer.js +79 -0
- package/build/esm/object-table/TableEditContainer.js.map +1 -0
- package/build/esm/object-table/TableEditContainer.module.css +44 -0
- package/build/esm/object-table/TableRow.js +12 -4
- package/build/esm/object-table/TableRow.js.map +1 -1
- package/build/esm/object-table/TableRow.module.css +2 -1
- package/build/esm/object-table/hooks/useEditableTable.js +20 -11
- package/build/esm/object-table/hooks/useEditableTable.js.map +1 -1
- package/build/esm/object-table/hooks/useObjectTableData.js +0 -5
- package/build/esm/object-table/hooks/useObjectTableData.js.map +1 -1
- package/build/esm/object-table/utils/getCellId.js +0 -7
- package/build/esm/object-table/utils/getCellId.js.map +1 -1
- package/build/esm/object-table/utils/types.js.map +1 -1
- package/build/esm/public/experimental.js.map +1 -1
- package/build/types/object-table/DefaultCellRenderer.d.ts +2 -2
- package/build/types/object-table/DefaultCellRenderer.d.ts.map +1 -1
- package/build/types/object-table/EditableCell.d.ts +18 -6
- package/build/types/object-table/EditableCell.d.ts.map +1 -1
- package/build/types/object-table/ObjectTable.d.ts +1 -1
- package/build/types/object-table/ObjectTable.d.ts.map +1 -1
- package/build/types/object-table/ObjectTableApi.d.ts +16 -6
- package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
- package/build/types/object-table/Table.d.ts +5 -10
- package/build/types/object-table/Table.d.ts.map +1 -1
- package/build/types/object-table/TableBody.d.ts +4 -1
- package/build/types/object-table/TableBody.d.ts.map +1 -1
- package/build/types/object-table/TableEditContainer.d.ts +9 -0
- package/build/types/object-table/TableEditContainer.d.ts.map +1 -0
- package/build/types/object-table/TableRow.d.ts +5 -1
- package/build/types/object-table/TableRow.d.ts.map +1 -1
- package/build/types/object-table/hooks/useEditableTable.d.ts +4 -9
- package/build/types/object-table/hooks/useEditableTable.d.ts.map +1 -1
- package/build/types/object-table/utils/getCellId.d.ts +0 -1
- package/build/types/object-table/utils/getCellId.d.ts.map +1 -1
- package/build/types/object-table/utils/types.d.ts +25 -3
- package/build/types/object-table/utils/types.d.ts.map +1 -1
- package/build/types/public/experimental.d.ts +1 -1
- package/build/types/public/experimental.d.ts.map +1 -1
- package/package.json +7 -6
- package/build/browser/filter-list/__tests__/LinkedPropertyInput.test.js +0 -202
- package/build/browser/filter-list/__tests__/LinkedPropertyInput.test.js.map +0 -1
- package/build/browser/filter-list/__tests__/dateUtils.test.js +0 -55
- package/build/browser/filter-list/__tests__/dateUtils.test.js.map +0 -1
- package/build/browser/filter-list/__tests__/filterStateToWhereClause.test.js +0 -296
- package/build/browser/filter-list/__tests__/filterStateToWhereClause.test.js.map +0 -1
- package/build/browser/filter-list/__tests__/getFilterKey.test.js +0 -53
- package/build/browser/filter-list/__tests__/getFilterKey.test.js.map +0 -1
- package/build/browser/filter-list/__tests__/testUtils.js +0 -203
- package/build/browser/filter-list/__tests__/testUtils.js.map +0 -1
- package/build/browser/filter-list/hooks/__tests__/useFilterListState.test.js +0 -128
- package/build/browser/filter-list/hooks/__tests__/useFilterListState.test.js.map +0 -1
- package/build/browser/object-table/__tests__/useEditableTable.test.js +0 -197
- package/build/browser/object-table/__tests__/useEditableTable.test.js.map +0 -1
- package/build/browser/object-table/hooks/__tests__/useCellContextMenu.test.js +0 -147
- package/build/browser/object-table/hooks/__tests__/useCellContextMenu.test.js.map +0 -1
- package/build/browser/object-table/hooks/__tests__/useColumnDefs.test.js +0 -520
- package/build/browser/object-table/hooks/__tests__/useColumnDefs.test.js.map +0 -1
- package/build/browser/object-table/hooks/__tests__/useColumnPinning.test.js +0 -266
- package/build/browser/object-table/hooks/__tests__/useColumnPinning.test.js.map +0 -1
- package/build/browser/object-table/hooks/__tests__/useColumnVisibility.test.js +0 -200
- package/build/browser/object-table/hooks/__tests__/useColumnVisibility.test.js.map +0 -1
- package/build/browser/object-table/hooks/__tests__/useObjectTableData.test.js +0 -315
- package/build/browser/object-table/hooks/__tests__/useObjectTableData.test.js.map +0 -1
- package/build/browser/object-table/hooks/__tests__/useRowSelection.test.js +0 -596
- package/build/browser/object-table/hooks/__tests__/useRowSelection.test.js.map +0 -1
- package/build/browser/object-table/hooks/__tests__/useSelectionColumn.test.js +0 -220
- package/build/browser/object-table/hooks/__tests__/useSelectionColumn.test.js.map +0 -1
- package/build/browser/object-table/hooks/__tests__/useTableSorting.test.js +0 -501
- package/build/browser/object-table/hooks/__tests__/useTableSorting.test.js.map +0 -1
- package/build/esm/filter-list/__tests__/LinkedPropertyInput.test.js +0 -202
- package/build/esm/filter-list/__tests__/LinkedPropertyInput.test.js.map +0 -1
- package/build/esm/filter-list/__tests__/dateUtils.test.js +0 -55
- package/build/esm/filter-list/__tests__/dateUtils.test.js.map +0 -1
- package/build/esm/filter-list/__tests__/filterStateToWhereClause.test.js +0 -296
- package/build/esm/filter-list/__tests__/filterStateToWhereClause.test.js.map +0 -1
- package/build/esm/filter-list/__tests__/getFilterKey.test.js +0 -53
- package/build/esm/filter-list/__tests__/getFilterKey.test.js.map +0 -1
- package/build/esm/filter-list/__tests__/testUtils.js +0 -203
- package/build/esm/filter-list/__tests__/testUtils.js.map +0 -1
- package/build/esm/filter-list/hooks/__tests__/useFilterListState.test.js +0 -128
- package/build/esm/filter-list/hooks/__tests__/useFilterListState.test.js.map +0 -1
- package/build/esm/object-table/__tests__/useEditableTable.test.js +0 -197
- package/build/esm/object-table/__tests__/useEditableTable.test.js.map +0 -1
- package/build/esm/object-table/hooks/__tests__/useCellContextMenu.test.js +0 -147
- package/build/esm/object-table/hooks/__tests__/useCellContextMenu.test.js.map +0 -1
- package/build/esm/object-table/hooks/__tests__/useColumnDefs.test.js +0 -520
- package/build/esm/object-table/hooks/__tests__/useColumnDefs.test.js.map +0 -1
- package/build/esm/object-table/hooks/__tests__/useColumnPinning.test.js +0 -266
- package/build/esm/object-table/hooks/__tests__/useColumnPinning.test.js.map +0 -1
- package/build/esm/object-table/hooks/__tests__/useColumnVisibility.test.js +0 -200
- package/build/esm/object-table/hooks/__tests__/useColumnVisibility.test.js.map +0 -1
- package/build/esm/object-table/hooks/__tests__/useObjectTableData.test.js +0 -315
- package/build/esm/object-table/hooks/__tests__/useObjectTableData.test.js.map +0 -1
- package/build/esm/object-table/hooks/__tests__/useRowSelection.test.js +0 -596
- package/build/esm/object-table/hooks/__tests__/useRowSelection.test.js.map +0 -1
- package/build/esm/object-table/hooks/__tests__/useSelectionColumn.test.js +0 -220
- package/build/esm/object-table/hooks/__tests__/useSelectionColumn.test.js.map +0 -1
- package/build/esm/object-table/hooks/__tests__/useTableSorting.test.js +0 -501
- package/build/esm/object-table/hooks/__tests__/useTableSorting.test.js.map +0 -1
- package/build/types/filter-list/__tests__/LinkedPropertyInput.test.d.ts +0 -1
- package/build/types/filter-list/__tests__/LinkedPropertyInput.test.d.ts.map +0 -1
- package/build/types/filter-list/__tests__/dateUtils.test.d.ts +0 -1
- package/build/types/filter-list/__tests__/dateUtils.test.d.ts.map +0 -1
- package/build/types/filter-list/__tests__/filterStateToWhereClause.test.d.ts +0 -1
- package/build/types/filter-list/__tests__/filterStateToWhereClause.test.d.ts.map +0 -1
- package/build/types/filter-list/__tests__/getFilterKey.test.d.ts +0 -1
- package/build/types/filter-list/__tests__/getFilterKey.test.d.ts.map +0 -1
- package/build/types/filter-list/__tests__/testUtils.d.ts +0 -65
- package/build/types/filter-list/__tests__/testUtils.d.ts.map +0 -1
- package/build/types/filter-list/hooks/__tests__/useFilterListState.test.d.ts +0 -1
- package/build/types/filter-list/hooks/__tests__/useFilterListState.test.d.ts.map +0 -1
- package/build/types/object-table/__tests__/useEditableTable.test.d.ts +0 -1
- package/build/types/object-table/__tests__/useEditableTable.test.d.ts.map +0 -1
- package/build/types/object-table/hooks/__tests__/useCellContextMenu.test.d.ts +0 -1
- package/build/types/object-table/hooks/__tests__/useCellContextMenu.test.d.ts.map +0 -1
- package/build/types/object-table/hooks/__tests__/useColumnDefs.test.d.ts +0 -1
- package/build/types/object-table/hooks/__tests__/useColumnDefs.test.d.ts.map +0 -1
- package/build/types/object-table/hooks/__tests__/useColumnPinning.test.d.ts +0 -1
- package/build/types/object-table/hooks/__tests__/useColumnPinning.test.d.ts.map +0 -1
- package/build/types/object-table/hooks/__tests__/useColumnVisibility.test.d.ts +0 -1
- package/build/types/object-table/hooks/__tests__/useColumnVisibility.test.d.ts.map +0 -1
- package/build/types/object-table/hooks/__tests__/useObjectTableData.test.d.ts +0 -1
- package/build/types/object-table/hooks/__tests__/useObjectTableData.test.d.ts.map +0 -1
- package/build/types/object-table/hooks/__tests__/useRowSelection.test.d.ts +0 -1
- package/build/types/object-table/hooks/__tests__/useRowSelection.test.d.ts.map +0 -1
- package/build/types/object-table/hooks/__tests__/useSelectionColumn.test.d.ts +0 -1
- package/build/types/object-table/hooks/__tests__/useSelectionColumn.test.d.ts.map +0 -1
- package/build/types/object-table/hooks/__tests__/useTableSorting.test.d.ts +0 -1
- package/build/types/object-table/hooks/__tests__/useTableSorting.test.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.js","names":["classNames","React","useCallback","useEffect","useRef","useState","ActionButton","LoadingStateTable","NonIdealState","styles","TableBody","TableHeader","BaseTable","table","isLoading","fetchNextPage","onRowClick","rowHeight","renderCellContextMenu","className","error","headerMenuFeatureFlags","editableConfig","tableContainerRef","isLoadingMore","setIsLoadingMore","fetchingRef","fetchMoreOnEndReached","containerRefElement","current","scrollHeight","scrollTop","clientHeight","handleScroll","e","currentTarget","rows","getRowModel","headerGroups","getHeaderGroups","hasData","length","hasEdits","Object","keys","cellEdits","handleSubmitEdits","onSubmitEdits","clearEdits","createElement","osdkTableWrapper","ref","osdkTableContainer","osdkTableContainerWithButton","onScroll","Fragment","message","submitButtonContainer","variant","onClick","disabled"],"sources":["Table.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Cell, RowData, Table } from \"@tanstack/react-table\";\nimport classNames from \"classnames\";\nimport React, {\n type ReactElement,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { ActionButton } from \"../base-components/action-button/ActionButton.js\";\nimport { LoadingStateTable } from \"./LoadingStateTable.js\";\nimport { NonIdealState } from \"./NonIdealState.js\";\nimport styles from \"./Table.module.css\";\nimport { TableBody } from \"./TableBody.js\";\nimport { TableHeader } from \"./TableHeader.js\";\nimport type { HeaderMenuFeatureFlags } from \"./TableHeaderWithPopover.js\";\nimport type { CellValueState } from \"./utils/types.js\";\n\ndeclare module \"@tanstack/react-table\" {\n interface ColumnMeta<TData extends RowData = unknown, TValue = unknown> {\n columnName?: string;\n isVisible?: boolean;\n editable?: boolean;\n dataType?: string;\n }\n interface TableMeta<TData extends RowData = unknown> {\n onCellEdit?: (\n cellId: string,\n state: CellValueState,\n ) => void;\n cellEdits?: Record<string, CellValueState>;\n }\n}\n\ninterface EditableConfig {\n onSubmitEdits?: () => Promise<void>;\n clearEdits?: () => void;\n cellEdits?: Record<string, CellValueState>;\n}\n\nexport interface BaseTableProps<\n TData extends RowData,\n> {\n table: Table<TData>;\n isLoading?: boolean;\n fetchNextPage?: () => Promise<void>;\n onRowClick?: (row: TData) => void;\n rowHeight?: number;\n renderCellContextMenu?: (\n row: TData,\n cell: Cell<TData, unknown>,\n ) => React.ReactNode;\n className?: string;\n error?: Error;\n headerMenuFeatureFlags?: HeaderMenuFeatureFlags;\n editableConfig?: EditableConfig;\n}\n\nexport function BaseTable<\n TData extends RowData,\n>(\n {\n table,\n isLoading,\n fetchNextPage,\n onRowClick,\n rowHeight,\n renderCellContextMenu,\n className,\n error,\n headerMenuFeatureFlags,\n editableConfig,\n }: BaseTableProps<TData>,\n): ReactElement {\n const tableContainerRef = useRef<HTMLDivElement>(null);\n const [isLoadingMore, setIsLoadingMore] = useState(false);\n\n // Using a ref to prevent duplicate fetches from rapid scroll events while a fetch is in-flight\n const fetchingRef = useRef(false);\n\n useEffect(() => {\n if (!isLoading || fetchNextPage == null) {\n setIsLoadingMore(false);\n }\n }, [isLoading, fetchNextPage]);\n\n const fetchMoreOnEndReached = useCallback(\n async (containerRefElement?: HTMLDivElement | null) => {\n if (containerRefElement && !fetchingRef.current && !isLoadingMore) {\n const { scrollHeight, scrollTop, clientHeight } = containerRefElement;\n if (\n scrollHeight - scrollTop - clientHeight < 100\n && !isLoading && fetchNextPage != null\n ) {\n fetchingRef.current = true;\n setIsLoadingMore(true);\n try {\n await fetchNextPage();\n } finally {\n fetchingRef.current = false;\n }\n }\n }\n },\n [fetchNextPage, isLoading, isLoadingMore],\n );\n\n const handleScroll = useCallback(\n async (e: React.UIEvent<HTMLDivElement>) => {\n await fetchMoreOnEndReached(e.currentTarget);\n },\n [fetchMoreOnEndReached],\n );\n\n const rows = table.getRowModel().rows;\n const headerGroups = table.getHeaderGroups();\n const hasData = rows.length > 0;\n const hasEdits = Object.keys(editableConfig?.cellEdits ?? {}).length > 0;\n\n const handleSubmitEdits = useCallback(async () => {\n await editableConfig?.onSubmitEdits?.();\n editableConfig?.clearEdits?.();\n }, [editableConfig]);\n\n return (\n <div className={classNames(styles.osdkTableWrapper, className)}>\n <div\n ref={tableContainerRef}\n className={classNames(\n styles.osdkTableContainer,\n editableConfig && styles.osdkTableContainerWithButton,\n )}\n onScroll={handleScroll}\n >\n <table>\n {isLoading && !hasData\n ? (\n <LoadingStateTable\n table={table}\n headerGroups={headerGroups}\n rowHeight={rowHeight}\n tableContainerRef={tableContainerRef}\n />\n )\n : (\n <>\n <TableHeader\n table={table}\n headerMenuFeatureFlags={headerMenuFeatureFlags}\n />\n <TableBody\n rows={rows}\n tableContainerRef={tableContainerRef}\n onRowClick={onRowClick}\n rowHeight={rowHeight}\n renderCellContextMenu={renderCellContextMenu}\n isLoadingMore={isLoadingMore}\n headerGroups={headerGroups}\n />\n </>\n )}\n </table>\n {!hasData && error == null && <NonIdealState message={\"No Data\"} />}\n {error != null && (\n <NonIdealState message={`Error Loading Data: ${error.message}`} />\n )}\n </div>\n {editableConfig && (\n <div className={styles.submitButtonContainer}>\n <ActionButton\n variant=\"primary\"\n onClick={handleSubmitEdits}\n disabled={!hasEdits}\n >\n Submit Edits\n </ActionButton>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAEVC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SAASC,YAAY,QAAQ,kDAAkD;AAC/E,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,aAAa,QAAQ,oBAAoB;AAClD,OAAOC,MAAM,MAAM,oBAAoB;AACvC,SAASC,SAAS,QAAQ,gBAAgB;AAC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,KAAM;IACbQ,sBAAsB,EAAEA;EAAuB,CAChD,CAAC,eACFpB,KAAA,CAAAgD,aAAA,CAACvC,SAAS;IACR0B,IAAI,EAAEA,IAAK;IACXb,iBAAiB,EAAEA,iBAAkB;IACrCP,UAAU,EAAEA,UAAW;IACvBC,SAAS,EAAEA,SAAU;IACrBC,qBAAqB,EAAEA,qBAAsB;IAC7CM,aAAa,EAAEA,aAAc;IAC7Bc,YAAY,EAAEA;EAAa,CAC5B,CACD,CAED,CAAC,EACP,CAACE,OAAO,IAAIpB,KAAK,IAAI,IAAI,iBAAInB,KAAA,CAAAgD,aAAA,CAACzC,aAAa;IAACgD,OAAO,EAAE;EAAU,CAAE,CAAC,EAClEpC,KAAK,IAAI,IAAI,iBACZnB,KAAA,CAAAgD,aAAA,CAACzC,aAAa;IAACgD,OAAO,EAAE,uBAAuBpC,KAAK,CAACoC,OAAO;EAAG,CAAE,CAEhE,CAAC,EACLlC,cAAc,iBACbrB,KAAA,CAAAgD,aAAA;IAAK9B,SAAS,EAAEV,MAAM,CAACgD;EAAsB,gBAC3CxD,KAAA,CAAAgD,aAAA,CAAC3C,YAAY;IACXoD,OAAO,EAAC,SAAS;IACjBC,OAAO,EAAEb,iBAAkB;IAC3Bc,QAAQ,EAAE,CAAClB;EAAS,GACrB,cAEa,CACX,CAEJ,CAAC;AAEV","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Table.js","names":["classNames","React","useCallback","useEffect","useRef","useState","LoadingStateTable","NonIdealState","styles","TableBody","TableEditContainer","TableHeader","BaseTable","table","isLoading","fetchNextPage","onRowClick","rowHeight","renderCellContextMenu","className","error","headerMenuFeatureFlags","editableConfig","tableContainerRef","isLoadingMore","setIsLoadingMore","focusedRowId","setFocusedRowId","fetchingRef","fetchMoreOnEndReached","containerRefElement","current","scrollHeight","scrollTop","clientHeight","handleScroll","e","currentTarget","rows","getRowModel","headerGroups","getHeaderGroups","hasData","length","hasEditableColumns","getAllColumns","some","column","columnDef","meta","editable","handleClickOutside","event","contains","target","document","addEventListener","removeEventListener","createElement","osdkTableWrapper","ref","osdkTableContainer","onScroll","Fragment","isInEditMode","editMode","isActive","message"],"sources":["Table.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Cell, RowData, Table } from \"@tanstack/react-table\";\nimport classNames from \"classnames\";\nimport React, {\n type ReactElement,\n useCallback,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport { LoadingStateTable } from \"./LoadingStateTable.js\";\nimport { NonIdealState } from \"./NonIdealState.js\";\nimport styles from \"./Table.module.css\";\nimport { TableBody } from \"./TableBody.js\";\nimport { TableEditContainer } from \"./TableEditContainer.js\";\nimport { TableHeader } from \"./TableHeader.js\";\nimport type { HeaderMenuFeatureFlags } from \"./TableHeaderWithPopover.js\";\nimport type { CellEditInfo, EditableConfig } from \"./utils/types.js\";\n\ndeclare module \"@tanstack/react-table\" {\n interface ColumnMeta<TData extends RowData = unknown, TValue = unknown> {\n columnName?: string;\n isVisible?: boolean;\n editable?: boolean;\n dataType?: string;\n }\n interface TableMeta<TData extends RowData = unknown> {\n onCellEdit?: (\n cellId: string,\n info: CellEditInfo<TData, unknown>,\n ) => void;\n cellEdits?: Record<string, CellEditInfo<TData, unknown>>;\n isInEditMode?: boolean;\n }\n}\n\nexport interface BaseTableProps<\n TData extends RowData,\n> {\n table: Table<TData>;\n isLoading?: boolean;\n fetchNextPage?: () => Promise<void>;\n onRowClick?: (row: TData) => void;\n rowHeight?: number;\n renderCellContextMenu?: (\n row: TData,\n cell: Cell<TData, unknown>,\n ) => React.ReactNode;\n className?: string;\n error?: Error;\n headerMenuFeatureFlags?: HeaderMenuFeatureFlags;\n editableConfig?: EditableConfig<TData, unknown>;\n}\n\nexport function BaseTable<\n TData extends RowData,\n>(\n {\n table,\n isLoading,\n fetchNextPage,\n onRowClick,\n rowHeight,\n renderCellContextMenu,\n className,\n error,\n headerMenuFeatureFlags,\n editableConfig,\n }: BaseTableProps<TData>,\n): ReactElement {\n const tableContainerRef = useRef<HTMLDivElement>(null);\n const [isLoadingMore, setIsLoadingMore] = useState(false);\n const [focusedRowId, setFocusedRowId] = useState<string | null>(null);\n\n // Using a ref to prevent duplicate fetches from rapid scroll events while a fetch is in-flight\n const fetchingRef = useRef(false);\n\n useEffect(() => {\n if (!isLoading || fetchNextPage == null) {\n setIsLoadingMore(false);\n }\n }, [isLoading, fetchNextPage]);\n\n const fetchMoreOnEndReached = useCallback(\n async (containerRefElement?: HTMLDivElement | null) => {\n if (containerRefElement && !fetchingRef.current && !isLoadingMore) {\n const { scrollHeight, scrollTop, clientHeight } = containerRefElement;\n if (\n scrollHeight - scrollTop - clientHeight < 100\n && !isLoading && fetchNextPage != null\n ) {\n fetchingRef.current = true;\n setIsLoadingMore(true);\n try {\n await fetchNextPage();\n } finally {\n fetchingRef.current = false;\n }\n }\n }\n },\n [fetchNextPage, isLoading, isLoadingMore],\n );\n\n const handleScroll = useCallback(\n async (e: React.UIEvent<HTMLDivElement>) => {\n await fetchMoreOnEndReached(e.currentTarget);\n },\n [fetchMoreOnEndReached],\n );\n\n const rows = table.getRowModel().rows;\n const headerGroups = table.getHeaderGroups();\n const hasData = rows.length > 0;\n\n const hasEditableColumns = table\n .getAllColumns()\n .some(column => column.columnDef.meta?.editable === true);\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (\n tableContainerRef.current\n && !tableContainerRef.current.contains(event.target as Node)\n ) {\n setFocusedRowId(null);\n }\n };\n\n document.addEventListener(\"click\", handleClickOutside);\n return () => {\n document.removeEventListener(\"click\", handleClickOutside);\n };\n }, []);\n\n return (\n <div className={classNames(styles.osdkTableWrapper, className)}>\n <div\n ref={tableContainerRef}\n className={styles.osdkTableContainer}\n onScroll={handleScroll}\n >\n <table>\n {isLoading && !hasData\n ? (\n <LoadingStateTable\n table={table}\n headerGroups={headerGroups}\n rowHeight={rowHeight}\n tableContainerRef={tableContainerRef}\n />\n )\n : (\n <>\n <TableHeader\n table={table}\n headerMenuFeatureFlags={headerMenuFeatureFlags}\n />\n <TableBody\n rows={rows}\n tableContainerRef={tableContainerRef}\n onRowClick={onRowClick}\n rowHeight={rowHeight}\n renderCellContextMenu={renderCellContextMenu}\n isLoadingMore={isLoadingMore}\n headerGroups={headerGroups}\n focusedRowId={focusedRowId}\n setFocusedRowId={setFocusedRowId}\n isInEditMode={editableConfig?.editMode.isActive}\n />\n </>\n )}\n </table>\n {!hasData && error == null && <NonIdealState message={\"No Data\"} />}\n {error != null && (\n <NonIdealState message={`Error Loading Data: ${error.message}`} />\n )}\n </div>\n {hasEditableColumns && (\n <TableEditContainer\n editableConfig={editableConfig}\n focusedRowId={focusedRowId}\n />\n )}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAEVC,WAAW,EACXC,SAAS,EACTC,MAAM,EACNC,QAAQ,QACH,OAAO;AACd,SAASC,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,aAAa,QAAQ,oBAAoB;AAClD,OAAOC,MAAM,MAAM,oBAAoB;AACvC,SAASC,SAAS,QAAQ,gBAAgB;AAC1C,SAASC,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,WAAW,QAAQ,kBAAkB;AAuC9C,OAAO,SAASC,SAASA,CAGvB;EACEC,KAAK;EACLC,SAAS;EACTC,aAAa;EACbC,UAAU;EACVC,SAAS;EACTC,qBAAqB;EACrBC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AAEA;EAAkB,CACtC,CAAC,gBAGFtB,KAAA,CAAAyD,aAAA,CAAAzD,KAAA,CAAA8D,QAAA,qBACE9D,KAAA,CAAAyD,aAAA,CAAC/C,WAAW;IACVE,KAAK,EAAEA,KAAM;IACbQ,sBAAsB,EAAEA;EAAuB,CAChD,CAAC,eACFpB,KAAA,CAAAyD,aAAA,CAACjD,SAAS;IACR6B,IAAI,EAAEA,IAAK;IACXf,iBAAiB,EAAEA,iBAAkB;IACrCP,UAAU,EAAEA,UAAW;IACvBC,SAAS,EAAEA,SAAU;IACrBC,qBAAqB,EAAEA,qBAAsB;IAC7CM,aAAa,EAAEA,aAAc;IAC7BgB,YAAY,EAAEA,YAAa;IAC3Bd,YAAY,EAAEA,YAAa;IAC3BC,eAAe,EAAEA,eAAgB;IACjCqC,YAAY,EAAE1C,cAAc,EAAE2C,QAAQ,CAACC;EAAS,CACjD,CACD,CAED,CAAC,EACP,CAACxB,OAAO,IAAItB,KAAK,IAAI,IAAI,iBAAInB,KAAA,CAAAyD,aAAA,CAACnD,aAAa;IAAC4D,OAAO,EAAE;EAAU,CAAE,CAAC,EAClE/C,KAAK,IAAI,IAAI,iBACZnB,KAAA,CAAAyD,aAAA,CAACnD,aAAa;IAAC4D,OAAO,EAAE,uBAAuB/C,KAAK,CAAC+C,OAAO;EAAG,CAAE,CAEhE,CAAC,EACLvB,kBAAkB,iBACjB3C,KAAA,CAAAyD,aAAA,CAAChD,kBAAkB;IACjBY,cAAc,EAAEA,cAAe;IAC/BI,YAAY,EAAEA;EAAa,CAC5B,CAEA,CAAC;AAEV","ignoreList":[]}
|
|
@@ -35,11 +35,3 @@
|
|
|
35
35
|
width: max-content;
|
|
36
36
|
min-width: 100%;
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
.submitButtonContainer {
|
|
40
|
-
background-color: var(--osdk-surface-background-color-default-rest);
|
|
41
|
-
border-top: var(--osdk-table-border);
|
|
42
|
-
padding: var(--osdk-table-button-container-padding);
|
|
43
|
-
display: flex;
|
|
44
|
-
justify-content: flex-end;
|
|
45
|
-
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// CSS Module proxy for Table.module.css
|
|
2
2
|
const styles = {
|
|
3
3
|
"osdkTableWrapper": "Table-module__osdkTableWrapper___qNSuMAE2",
|
|
4
|
-
"osdkTableContainer": "Table-module__osdkTableContainer___QBj68RD-"
|
|
5
|
-
"submitButtonContainer": "Table-module__submitButtonContainer___2UgcHhXl"
|
|
4
|
+
"osdkTableContainer": "Table-module__osdkTableContainer___QBj68RD-"
|
|
6
5
|
};
|
|
7
6
|
|
|
8
7
|
export default styles;
|
|
@@ -26,7 +26,10 @@ export function TableBody({
|
|
|
26
26
|
renderCellContextMenu,
|
|
27
27
|
rowHeight = 40,
|
|
28
28
|
isLoadingMore = false,
|
|
29
|
-
headerGroups = []
|
|
29
|
+
headerGroups = [],
|
|
30
|
+
focusedRowId,
|
|
31
|
+
setFocusedRowId,
|
|
32
|
+
isInEditMode
|
|
30
33
|
}) {
|
|
31
34
|
// Important: Keep the row virtualizer in the lowest component possible to avoid unnecessary re-renders.
|
|
32
35
|
const rowVirtualizer = useVirtualizer({
|
|
@@ -55,7 +58,10 @@ export function TableBody({
|
|
|
55
58
|
row: row,
|
|
56
59
|
virtualRow: virtualRow,
|
|
57
60
|
onRowClick: onRowClick,
|
|
58
|
-
renderCellContextMenu: renderCellContextMenu
|
|
61
|
+
renderCellContextMenu: renderCellContextMenu,
|
|
62
|
+
focusedRowId: focusedRowId,
|
|
63
|
+
setFocusedRowId: setFocusedRowId,
|
|
64
|
+
isInEditMode: isInEditMode
|
|
59
65
|
});
|
|
60
66
|
}), isLoadingMore && /*#__PURE__*/React.createElement(LoadingRow, {
|
|
61
67
|
headers: headers,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableBody.js","names":["useVirtualizer","React","useLayoutEffect","LoadingRow","styles","TableRow","TableBody","rows","tableContainerRef","onRowClick","renderCellContextMenu","rowHeight","isLoadingMore","headerGroups","rowVirtualizer","count","length","estimateSize","getScrollElement","current","overscan","measure","totalSize","getTotalSize","bodyHeight","headers","createElement","className","osdkTableBody","style","height","getVirtualItems","map","virtualRow","row","index","key","id","translateY","columnCount"],"sources":["TableBody.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Cell, HeaderGroup, Row, RowData } from \"@tanstack/react-table\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport React, { useLayoutEffect } from \"react\";\nimport { LoadingRow } from \"./LoadingRow.js\";\nimport styles from \"./TableBody.module.css\";\nimport { TableRow } from \"./TableRow.js\";\n\ninterface TableBodyProps<TData extends RowData> {\n rows: Array<Row<TData>>;\n tableContainerRef: React.RefObject<HTMLDivElement>;\n onRowClick?: (row: TData) => void;\n rowHeight?: number;\n renderCellContextMenu?: (\n row: TData,\n cell: Cell<TData, unknown>,\n ) => React.ReactNode;\n isLoadingMore?: boolean;\n headerGroups?: Array<HeaderGroup<TData>>;\n}\n\nexport function TableBody<TData extends RowData>({\n rows,\n tableContainerRef,\n onRowClick,\n renderCellContextMenu,\n rowHeight = 40,\n isLoadingMore = false,\n headerGroups = [],\n}: TableBodyProps<TData>): React.ReactElement {\n // Important: Keep the row virtualizer in the lowest component possible to avoid unnecessary re-renders.\n const rowVirtualizer = useVirtualizer<HTMLDivElement, HTMLTableRowElement>({\n count: rows.length,\n estimateSize: () => rowHeight,\n getScrollElement: () => tableContainerRef.current,\n overscan: 5,\n });\n\n // Measure the virtualizer after the DOM has been laid out to ensure proper dimensions\n useLayoutEffect(() => {\n rowVirtualizer.measure();\n }, [rowVirtualizer, rows.length]);\n\n const totalSize = rowVirtualizer.getTotalSize();\n const bodyHeight = isLoadingMore\n ? totalSize + rowHeight\n : totalSize;\n\n const headers = headerGroups[0]?.headers ?? [];\n\n return (\n <tbody\n className={styles.osdkTableBody}\n style={{\n height: `${bodyHeight}px`,\n }}\n >\n {rowVirtualizer.getVirtualItems().map((virtualRow) => {\n const row = rows[virtualRow.index];\n\n return (\n <TableRow\n key={row.id}\n row={row}\n virtualRow={virtualRow}\n onRowClick={onRowClick}\n renderCellContextMenu={renderCellContextMenu}\n />\n );\n })}\n {isLoadingMore && (\n <LoadingRow\n headers={headers}\n translateY={totalSize}\n rowHeight={rowHeight}\n columnCount={headers.length}\n />\n )}\n </tbody>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,cAAc,QAAQ,yBAAyB;AACxD,OAAOC,KAAK,IAAIC,eAAe,QAAQ,OAAO;AAC9C,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,OAAOC,MAAM,MAAM,wBAAwB;AAC3C,SAASC,QAAQ,QAAQ,eAAe;
|
|
1
|
+
{"version":3,"file":"TableBody.js","names":["useVirtualizer","React","useLayoutEffect","LoadingRow","styles","TableRow","TableBody","rows","tableContainerRef","onRowClick","renderCellContextMenu","rowHeight","isLoadingMore","headerGroups","focusedRowId","setFocusedRowId","isInEditMode","rowVirtualizer","count","length","estimateSize","getScrollElement","current","overscan","measure","totalSize","getTotalSize","bodyHeight","headers","createElement","className","osdkTableBody","style","height","getVirtualItems","map","virtualRow","row","index","key","id","translateY","columnCount"],"sources":["TableBody.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Cell, HeaderGroup, Row, RowData } from \"@tanstack/react-table\";\nimport { useVirtualizer } from \"@tanstack/react-virtual\";\nimport React, { useLayoutEffect } from \"react\";\nimport { LoadingRow } from \"./LoadingRow.js\";\nimport styles from \"./TableBody.module.css\";\nimport { TableRow } from \"./TableRow.js\";\n\ninterface TableBodyProps<TData extends RowData> {\n rows: Array<Row<TData>>;\n tableContainerRef: React.RefObject<HTMLDivElement>;\n onRowClick?: (row: TData) => void;\n rowHeight?: number;\n renderCellContextMenu?: (\n row: TData,\n cell: Cell<TData, unknown>,\n ) => React.ReactNode;\n isLoadingMore?: boolean;\n headerGroups?: Array<HeaderGroup<TData>>;\n focusedRowId?: string | null;\n setFocusedRowId?: (rowId: string | null) => void;\n isInEditMode?: boolean;\n}\n\nexport function TableBody<TData extends RowData>({\n rows,\n tableContainerRef,\n onRowClick,\n renderCellContextMenu,\n rowHeight = 40,\n isLoadingMore = false,\n headerGroups = [],\n focusedRowId,\n setFocusedRowId,\n isInEditMode,\n}: TableBodyProps<TData>): React.ReactElement {\n // Important: Keep the row virtualizer in the lowest component possible to avoid unnecessary re-renders.\n const rowVirtualizer = useVirtualizer<HTMLDivElement, HTMLTableRowElement>({\n count: rows.length,\n estimateSize: () => rowHeight,\n getScrollElement: () => tableContainerRef.current,\n overscan: 5,\n });\n\n // Measure the virtualizer after the DOM has been laid out to ensure proper dimensions\n useLayoutEffect(() => {\n rowVirtualizer.measure();\n }, [rowVirtualizer, rows.length]);\n\n const totalSize = rowVirtualizer.getTotalSize();\n const bodyHeight = isLoadingMore\n ? totalSize + rowHeight\n : totalSize;\n\n const headers = headerGroups[0]?.headers ?? [];\n\n return (\n <tbody\n className={styles.osdkTableBody}\n style={{\n height: `${bodyHeight}px`,\n }}\n >\n {rowVirtualizer.getVirtualItems().map((virtualRow) => {\n const row = rows[virtualRow.index];\n\n return (\n <TableRow\n key={row.id}\n row={row}\n virtualRow={virtualRow}\n onRowClick={onRowClick}\n renderCellContextMenu={renderCellContextMenu}\n focusedRowId={focusedRowId}\n setFocusedRowId={setFocusedRowId}\n isInEditMode={isInEditMode}\n />\n );\n })}\n {isLoadingMore && (\n <LoadingRow\n headers={headers}\n translateY={totalSize}\n rowHeight={rowHeight}\n columnCount={headers.length}\n />\n )}\n </tbody>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,cAAc,QAAQ,yBAAyB;AACxD,OAAOC,KAAK,IAAIC,eAAe,QAAQ,OAAO;AAC9C,SAASC,UAAU,QAAQ,iBAAiB;AAC5C,OAAOC,MAAM,MAAM,wBAAwB;AAC3C,SAASC,QAAQ,QAAQ,eAAe;AAkBxC,OAAO,SAASC,SAASA,CAAwB;EAC/CC,IAAI;EACJC,iBAAiB;EACjBC,UAAU;EACVC,qBAAqB;EACrBC,SAAS,GAAG,EAAE;EACdC,aAAa,GAAG,KAAK;EACrBC,YAAY,GAAG,EAAE;EACjBC,YAAY;EACZC,eAAe;EACfC;AACqB,CAAC,EAAsB;EAC5C;EACA,MAAMC,cAAc,GAAGjB,cAAc,CAAsC;IACzEkB,KAAK,EAAEX,IAAI,CAACY,MAAM;IAClBC,YAAY,EAAEA,CAAA,KAAMT,SAAS;IAC7BU,gBAAgB,EAAEA,CAAA,KAAMb,iBAAiB,CAACc,OAAO;IACjDC,QAAQ,EAAE;EACZ,CAAC,CAAC;;EAEF;EACArB,eAAe,CAAC,MAAM;IACpBe,cAAc,CAACO,OAAO,CAAC,CAAC;EAC1B,CAAC,EAAE,CAACP,cAAc,EAAEV,IAAI,CAACY,MAAM,CAAC,CAAC;EAEjC,MAAMM,SAAS,GAAGR,cAAc,CAACS,YAAY,CAAC,CAAC;EAC/C,MAAMC,UAAU,GAAGf,aAAa,GAC5Ba,SAAS,GAAGd,SAAS,GACrBc,SAAS;EAEb,MAAMG,OAAO,GAAGf,YAAY,CAAC,CAAC,CAAC,EAAEe,OAAO,IAAI,EAAE;EAE9C,oBACE3B,KAAA,CAAA4B,aAAA;IACEC,SAAS,EAAE1B,MAAM,CAAC2B,aAAc;IAChCC,KAAK,EAAE;MACLC,MAAM,EAAE,GAAGN,UAAU;IACvB;EAAE,GAEDV,cAAc,CAACiB,eAAe,CAAC,CAAC,CAACC,GAAG,CAAEC,UAAU,IAAK;IACpD,MAAMC,GAAG,GAAG9B,IAAI,CAAC6B,UAAU,CAACE,KAAK,CAAC;IAElC,oBACErC,KAAA,CAAA4B,aAAA,CAACxB,QAAQ;MACPkC,GAAG,EAAEF,GAAG,CAACG,EAAG;MACZH,GAAG,EAAEA,GAAI;MACTD,UAAU,EAAEA,UAAW;MACvB3B,UAAU,EAAEA,UAAW;MACvBC,qBAAqB,EAAEA,qBAAsB;MAC7CI,YAAY,EAAEA,YAAa;MAC3BC,eAAe,EAAEA,eAAgB;MACjCC,YAAY,EAAEA;IAAa,CAC5B,CAAC;EAEN,CAAC,CAAC,EACDJ,aAAa,iBACZX,KAAA,CAAA4B,aAAA,CAAC1B,UAAU;IACTyB,OAAO,EAAEA,OAAQ;IACjBa,UAAU,EAAEhB,SAAU;IACtBd,SAAS,EAAEA,SAAU;IACrB+B,WAAW,EAAEd,OAAO,CAACT;EAAO,CAC7B,CAEE,CAAC;AAEZ","ignoreList":[]}
|
|
@@ -59,14 +59,6 @@
|
|
|
59
59
|
padding: 0;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
/* Show focus state for editable cells */
|
|
63
|
-
.osdkTableCell:not(:has([role="checkbox"])):has(input):focus-within {
|
|
64
|
-
border: var(--osdk-emphasis-focus-width) solid
|
|
65
|
-
var(--osdk-emphasis-focus-color);
|
|
66
|
-
border-radius: var(--osdk-surface-border-radius);
|
|
67
|
-
background-color: var(--osdk-table-cell-editable-bg);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
62
|
.osdkTableCellContent:not(:has([role="checkbox"])) {
|
|
71
63
|
overflow: hidden;
|
|
72
64
|
text-overflow: ellipsis;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import React, { useCallback, useState } from "react";
|
|
18
|
+
import { ActionButton } from "../base-components/action-button/ActionButton.js";
|
|
19
|
+
import styles from "./TableEditContainer.module.css.js";
|
|
20
|
+
export function TableEditContainer({
|
|
21
|
+
editableConfig,
|
|
22
|
+
focusedRowId
|
|
23
|
+
}) {
|
|
24
|
+
const {
|
|
25
|
+
cellEdits,
|
|
26
|
+
onSubmitEdits,
|
|
27
|
+
clearEdits,
|
|
28
|
+
editMode
|
|
29
|
+
} = editableConfig ?? {};
|
|
30
|
+
const hasEdits = Object.keys(cellEdits ?? {}).length > 0;
|
|
31
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
32
|
+
const isInEditMode = editMode?.isActive;
|
|
33
|
+
const canToggleEditMode = editMode?.type === "manual";
|
|
34
|
+
const handleSubmitEdits = useCallback(async () => {
|
|
35
|
+
setIsSubmitting(true);
|
|
36
|
+
try {
|
|
37
|
+
const success = await onSubmitEdits?.();
|
|
38
|
+
if (success) {
|
|
39
|
+
clearEdits?.();
|
|
40
|
+
if (editMode?.type === "manual") {
|
|
41
|
+
editMode.setActive(false);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
} finally {
|
|
45
|
+
setIsSubmitting(false);
|
|
46
|
+
}
|
|
47
|
+
}, [editMode, onSubmitEdits, clearEdits]);
|
|
48
|
+
const handleCancelEdits = useCallback(() => {
|
|
49
|
+
clearEdits?.();
|
|
50
|
+
if (editMode?.type === "manual") {
|
|
51
|
+
editMode.setActive(false);
|
|
52
|
+
}
|
|
53
|
+
}, [clearEdits, editMode]);
|
|
54
|
+
const handleEnterEditMode = useCallback(() => {
|
|
55
|
+
if (editMode?.type === "manual") {
|
|
56
|
+
editMode.setActive(true);
|
|
57
|
+
}
|
|
58
|
+
}, [editMode]);
|
|
59
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
60
|
+
className: styles.tableEditContainer
|
|
61
|
+
}, hasEdits ? /*#__PURE__*/React.createElement("div", {
|
|
62
|
+
className: styles.modificationCount
|
|
63
|
+
}, `${cellEdits ? Object.keys(cellEdits).length : 0} modifications`) : isInEditMode && !focusedRowId && /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
className: styles.placeholder
|
|
65
|
+
}, "Select a row to edit data\u2026"), /*#__PURE__*/React.createElement("div", {
|
|
66
|
+
className: styles.editButtons
|
|
67
|
+
}, !isInEditMode && canToggleEditMode && /*#__PURE__*/React.createElement(ActionButton, {
|
|
68
|
+
variant: "primary",
|
|
69
|
+
onClick: handleEnterEditMode
|
|
70
|
+
}, "Edit Table"), isInEditMode && canToggleEditMode && /*#__PURE__*/React.createElement(ActionButton, {
|
|
71
|
+
variant: "secondary",
|
|
72
|
+
onClick: handleCancelEdits
|
|
73
|
+
}, "Cancel"), isInEditMode && !!onSubmitEdits && /*#__PURE__*/React.createElement(ActionButton, {
|
|
74
|
+
variant: "primary",
|
|
75
|
+
onClick: handleSubmitEdits,
|
|
76
|
+
disabled: !hasEdits || isSubmitting
|
|
77
|
+
}, "Submit Edits")));
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=TableEditContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableEditContainer.js","names":["React","useCallback","useState","ActionButton","styles","TableEditContainer","editableConfig","focusedRowId","cellEdits","onSubmitEdits","clearEdits","editMode","hasEdits","Object","keys","length","isSubmitting","setIsSubmitting","isInEditMode","isActive","canToggleEditMode","type","handleSubmitEdits","success","setActive","handleCancelEdits","handleEnterEditMode","createElement","className","tableEditContainer","modificationCount","placeholder","editButtons","variant","onClick","disabled"],"sources":["TableEditContainer.tsx"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RowData } from \"@tanstack/react-table\";\nimport React, { type ReactElement, useCallback, useState } from \"react\";\nimport { ActionButton } from \"../base-components/action-button/ActionButton.js\";\nimport styles from \"./TableEditContainer.module.css\";\nimport type { EditableConfig } from \"./utils/types.js\";\n\ninterface TableEditContainerProps<\n TData extends RowData,\n> {\n editableConfig?: EditableConfig<TData, unknown>;\n focusedRowId?: string | null;\n}\n\nexport function TableEditContainer<\n TData extends RowData,\n>({\n editableConfig,\n focusedRowId,\n}: TableEditContainerProps<TData>): ReactElement {\n const {\n cellEdits,\n onSubmitEdits,\n clearEdits,\n editMode,\n } = editableConfig ?? {};\n\n const hasEdits = Object.keys(cellEdits ?? {}).length > 0;\n const [isSubmitting, setIsSubmitting] = useState(false);\n\n const isInEditMode = editMode?.isActive;\n const canToggleEditMode = editMode?.type === \"manual\";\n\n const handleSubmitEdits = useCallback(async () => {\n setIsSubmitting(true);\n try {\n const success = await onSubmitEdits?.();\n if (success) {\n clearEdits?.();\n if (editMode?.type === \"manual\") {\n editMode.setActive(false);\n }\n }\n } finally {\n setIsSubmitting(false);\n }\n }, [editMode, onSubmitEdits, clearEdits]);\n\n const handleCancelEdits = useCallback(() => {\n clearEdits?.();\n if (editMode?.type === \"manual\") {\n editMode.setActive(false);\n }\n }, [clearEdits, editMode]);\n\n const handleEnterEditMode = useCallback(() => {\n if (editMode?.type === \"manual\") {\n editMode.setActive(true);\n }\n }, [editMode]);\n\n return (\n <div className={styles.tableEditContainer}>\n {hasEdits\n ? (\n <div className={styles.modificationCount}>\n {`${cellEdits ? Object.keys(cellEdits).length : 0} modifications`}\n </div>\n )\n : (isInEditMode && !focusedRowId && (\n <div className={styles.placeholder}>\n Select a row to edit data…\n </div>\n ))}\n <div className={styles.editButtons}>\n {!isInEditMode && canToggleEditMode && (\n <ActionButton\n variant=\"primary\"\n onClick={handleEnterEditMode}\n >\n Edit Table\n </ActionButton>\n )}\n {isInEditMode && canToggleEditMode && (\n <ActionButton\n variant=\"secondary\"\n onClick={handleCancelEdits}\n >\n Cancel\n </ActionButton>\n )}\n {isInEditMode && !!onSubmitEdits && (\n <ActionButton\n variant=\"primary\"\n onClick={handleSubmitEdits}\n disabled={!hasEdits || isSubmitting}\n >\n Submit Edits\n </ActionButton>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,OAAOA,KAAK,IAAuBC,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AACvE,SAASC,YAAY,QAAQ,kDAAkD;AAC/E,OAAOC,MAAM,MAAM,iCAAiC;AAUpD,OAAO,SAASC,kBAAkBA,CAEhC;EACAC,cAAc;EACdC;AAC8B,CAAC,EAAgB;EAC/C,M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AC,CAAC;EAEd,oBACEX,KAAA,CAAA2B,aAAA;IAAKC,SAAS,EAAExB,MAAM,CAACyB;EAAmB,GACvCjB,QAAQ,gBAELZ,KAAA,CAAA2B,aAAA;IAAKC,SAAS,EAAExB,MAAM,CAAC0B;EAAkB,GACtC,GAAGtB,SAAS,GAAGK,MAAM,CAACC,IAAI,CAACN,SAAS,CAAC,CAACO,MAAM,GAAG,CAAC,gBAC9C,CAAC,GAELG,YAAY,IAAI,CAACX,YAAY,iBAC9BP,KAAA,CAAA2B,aAAA;IAAKC,SAAS,EAAExB,MAAM,CAAC2B;EAAY,GAAC,iCAE/B,CACL,eACJ/B,KAAA,CAAA2B,aAAA;IAAKC,SAAS,EAAExB,MAAM,CAAC4B;EAAY,GAChC,CAACd,YAAY,IAAIE,iBAAiB,iBACjCpB,KAAA,CAAA2B,aAAA,CAACxB,YAAY;IACX8B,OAAO,EAAC,SAAS;IACjBC,OAAO,EAAER;EAAoB,GAC9B,YAEa,CACf,EACAR,YAAY,IAAIE,iBAAiB,iBAChCpB,KAAA,CAAA2B,aAAA,CAACxB,YAAY;IACX8B,OAAO,EAAC,WAAW;IACnBC,OAAO,EAAET;EAAkB,GAC5B,QAEa,CACf,EACAP,YAAY,IAAI,CAAC,CAACT,aAAa,iBAC9BT,KAAA,CAAA2B,aAAA,CAACxB,YAAY;IACX8B,OAAO,EAAC,SAAS;IACjBC,OAAO,EAAEZ,iBAAkB;IAC3Ba,QAAQ,EAAE,CAACvB,QAAQ,IAAII;EAAa,GACrC,cAEa,CAEb,CACF,CAAC;AAEV","ignoreList":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Palantir Technologies, Inc. All rights reserved.
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
.tableEditContainer {
|
|
18
|
+
display: flex;
|
|
19
|
+
justify-content: space-between;
|
|
20
|
+
align-items: center;
|
|
21
|
+
background-color: var(--osdk-surface-background-color-default-rest);
|
|
22
|
+
border-top: var(--osdk-table-border);
|
|
23
|
+
padding: var(--osdk-table-edit-container-padding);
|
|
24
|
+
min-height: var(--osdk-table-edit-container-min-height);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.placeholder {
|
|
28
|
+
color: var(--osdk-typography-color-muted);
|
|
29
|
+
font-size: var(--osdk-typography-size-body-small);
|
|
30
|
+
padding: calc(var(--osdk-surface-spacing) * 2) 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.modificationCount {
|
|
34
|
+
color: var(--osdk-intent-primary-rest);
|
|
35
|
+
font-size: var(--osdk-typography-size-body-small);
|
|
36
|
+
padding: calc(var(--osdk-surface-spacing) * 2) 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.editButtons {
|
|
40
|
+
display: flex;
|
|
41
|
+
justify-content: flex-end;
|
|
42
|
+
gap: 8px;
|
|
43
|
+
flex: 1;
|
|
44
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// CSS Module proxy for TableEditContainer.module.css
|
|
2
|
+
const styles = {
|
|
3
|
+
"tableEditContainer": "TableEditContainer-module__tableEditContainer___cIVjgtld",
|
|
4
|
+
"placeholder": "TableEditContainer-module__placeholder___ggxoxvTp",
|
|
5
|
+
"modificationCount": "TableEditContainer-module__modificationCount___sLN93v77",
|
|
6
|
+
"editButtons": "TableEditContainer-module__editButtons___xI-Z7kz1"
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default styles;
|
|
@@ -17,17 +17,24 @@
|
|
|
17
17
|
import React, { useCallback } from "react";
|
|
18
18
|
import { TableCell } from "./TableCell.js";
|
|
19
19
|
import styles from "./TableRow.module.css.js";
|
|
20
|
-
|
|
20
|
+
function TableRowInner({
|
|
21
21
|
row,
|
|
22
22
|
virtualRow,
|
|
23
23
|
onRowClick,
|
|
24
|
-
renderCellContextMenu
|
|
24
|
+
renderCellContextMenu,
|
|
25
|
+
focusedRowId,
|
|
26
|
+
setFocusedRowId,
|
|
27
|
+
isInEditMode
|
|
25
28
|
}) {
|
|
26
29
|
const handleClick = useCallback(() => {
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
setFocusedRowId?.(row.id);
|
|
31
|
+
if (!isInEditMode) {
|
|
32
|
+
onRowClick?.(row.original);
|
|
33
|
+
}
|
|
34
|
+
}, [isInEditMode, onRowClick, row.original, row.id, setFocusedRowId]);
|
|
29
35
|
return /*#__PURE__*/React.createElement("tr", {
|
|
30
36
|
"data-selected": row.getIsSelected(),
|
|
37
|
+
"data-focused": focusedRowId === row.id,
|
|
31
38
|
className: styles.osdkTableRow,
|
|
32
39
|
style: {
|
|
33
40
|
height: `${virtualRow.size}px`,
|
|
@@ -40,4 +47,5 @@ export function TableRow({
|
|
|
40
47
|
renderCellContextMenu: renderCellContextMenu
|
|
41
48
|
})));
|
|
42
49
|
}
|
|
50
|
+
export const TableRow = /*#__PURE__*/React.memo(TableRowInner);
|
|
43
51
|
//# sourceMappingURL=TableRow.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableRow.js","names":["React","useCallback","TableCell","styles","
|
|
1
|
+
{"version":3,"file":"TableRow.js","names":["React","useCallback","TableCell","styles","TableRowInner","row","virtualRow","onRowClick","renderCellContextMenu","focusedRowId","setFocusedRowId","isInEditMode","handleClick","id","original","createElement","getIsSelected","className","osdkTableRow","style","height","size","transform","start","onClick","getVisibleCells","map","cell","key","TableRow","memo"],"sources":["TableRow.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { Cell, Row, RowData } from \"@tanstack/react-table\";\nimport type { VirtualItem } from \"@tanstack/react-virtual\";\nimport React, { useCallback } from \"react\";\nimport { TableCell } from \"./TableCell.js\";\nimport styles from \"./TableRow.module.css\";\n\ninterface TableRowProps<TData extends RowData> {\n row: Row<TData>;\n virtualRow: VirtualItem;\n onRowClick?: (row: TData) => void;\n renderCellContextMenu?: (\n row: TData,\n cell: Cell<TData, unknown>,\n ) => React.ReactNode;\n focusedRowId?: string | null;\n setFocusedRowId?: (rowId: string | null) => void;\n isInEditMode?: boolean;\n}\n\nfunction TableRowInner<TData extends RowData>({\n row,\n virtualRow,\n onRowClick,\n renderCellContextMenu,\n focusedRowId,\n setFocusedRowId,\n isInEditMode,\n}: TableRowProps<TData>): React.ReactElement {\n const handleClick = useCallback(() => {\n setFocusedRowId?.(row.id);\n\n if (!isInEditMode) {\n onRowClick?.(row.original);\n }\n }, [isInEditMode, onRowClick, row.original, row.id, setFocusedRowId]);\n\n return (\n <tr\n data-selected={row.getIsSelected()}\n data-focused={focusedRowId === row.id}\n className={styles.osdkTableRow}\n style={{\n height: `${virtualRow.size}px`,\n transform: `translateY(${virtualRow.start}px)`,\n }}\n onClick={handleClick}\n >\n {row.getVisibleCells().map((cell) => (\n <TableCell\n key={cell.id}\n cell={cell}\n renderCellContextMenu={renderCellContextMenu}\n />\n ))}\n </tr>\n );\n}\n\nexport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AMqB,QAAQ,gBAAG7B,KAAK,CAAC8B,IAAI,CAChC1B,aACF,CAAyB","ignoreList":[]}
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
border-bottom-color: var(--osdk-table-row-border-color-hover);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
&[data-selected="true"]
|
|
48
|
+
&[data-selected="true"],
|
|
49
|
+
&[data-focused="true"] {
|
|
49
50
|
z-index: 2;
|
|
50
51
|
background-color: var(--osdk-table-row-bg-active);
|
|
51
52
|
border-top-color: var(--osdk-table-row-border-color-active);
|
|
@@ -15,17 +15,16 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { useCallback, useState } from "react";
|
|
18
|
-
import { getCellIdentifier } from "../utils/getCellId.js";
|
|
19
18
|
export function useEditableTable({
|
|
19
|
+
editMode = "manual",
|
|
20
20
|
onCellValueChanged,
|
|
21
21
|
onSubmitEdits
|
|
22
22
|
}) {
|
|
23
|
+
const [isActive, setActive] = useState(editMode === "always");
|
|
23
24
|
const [cellEdits, setCellEdits] = useState({});
|
|
24
|
-
const handleCellEdit = useCallback((cellId,
|
|
25
|
-
const cellIdentifier = getCellIdentifier(cellId);
|
|
26
|
-
|
|
25
|
+
const handleCellEdit = useCallback((cellId, info) => {
|
|
27
26
|
// If value is changed back to original, remove it from edits
|
|
28
|
-
if (
|
|
27
|
+
if (info.newValue === info.oldValue) {
|
|
29
28
|
setCellEdits(prev => {
|
|
30
29
|
const {
|
|
31
30
|
[cellId]: _,
|
|
@@ -36,22 +35,32 @@ export function useEditableTable({
|
|
|
36
35
|
} else {
|
|
37
36
|
setCellEdits(prev => ({
|
|
38
37
|
...prev,
|
|
39
|
-
[cellId]:
|
|
38
|
+
[cellId]: info
|
|
40
39
|
}));
|
|
41
40
|
}
|
|
42
|
-
onCellValueChanged?.(
|
|
41
|
+
onCellValueChanged?.(info);
|
|
43
42
|
}, [onCellValueChanged]);
|
|
44
43
|
const clearEdits = useCallback(() => {
|
|
45
44
|
setCellEdits({});
|
|
46
45
|
}, []);
|
|
47
46
|
const handleSubmitEdits = useCallback(async () => {
|
|
48
|
-
|
|
47
|
+
const edits = Object.values(cellEdits);
|
|
48
|
+
return onSubmitEdits ? onSubmitEdits(edits) : false;
|
|
49
49
|
}, [cellEdits, onSubmitEdits]);
|
|
50
|
+
const editModeConfig = editMode === "always" ? {
|
|
51
|
+
type: "always",
|
|
52
|
+
isActive: true
|
|
53
|
+
} : {
|
|
54
|
+
type: "manual",
|
|
55
|
+
isActive,
|
|
56
|
+
setActive
|
|
57
|
+
};
|
|
50
58
|
return {
|
|
51
59
|
cellEdits,
|
|
52
|
-
handleCellEdit,
|
|
53
|
-
handleSubmitEdits,
|
|
54
|
-
clearEdits
|
|
60
|
+
onCellEdit: handleCellEdit,
|
|
61
|
+
onSubmitEdits: onSubmitEdits ? handleSubmitEdits : undefined,
|
|
62
|
+
clearEdits,
|
|
63
|
+
editMode: editModeConfig
|
|
55
64
|
};
|
|
56
65
|
}
|
|
57
66
|
//# sourceMappingURL=useEditableTable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditableTable.js","names":["useCallback","useState","
|
|
1
|
+
{"version":3,"file":"useEditableTable.js","names":["useCallback","useState","useEditableTable","editMode","onCellValueChanged","onSubmitEdits","isActive","setActive","cellEdits","setCellEdits","handleCellEdit","cellId","info","newValue","oldValue","prev","_","rest","clearEdits","handleSubmitEdits","edits","Object","values","editModeConfig","type","onCellEdit","undefined"],"sources":["useEditableTable.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ObjectOrInterfaceDefinition,\n Osdk,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n} from \"@osdk/api\";\nimport { useCallback, useState } from \"react\";\nimport type { ObjectTableProps } from \"../ObjectTableApi.js\";\nimport type { CellEditInfo, EditableConfig, EditMode } from \"../utils/types.js\";\n\nexport interface UseEditableTableProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n editMode?: \"always\" | \"manual\";\n\n onCellValueChanged?: ObjectTableProps<\n Q,\n RDPs,\n FunctionColumns\n >[\"onCellValueChanged\"];\n\n onSubmitEdits?: ObjectTableProps<\n Q,\n RDPs,\n FunctionColumns\n >[\"onSubmitEdits\"];\n}\n\nexport function useEditableTable<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>({\n editMode = \"manual\",\n onCellValueChanged,\n onSubmitEdits,\n}: UseEditableTableProps<Q, RDPs, FunctionColumns>): EditableConfig<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n> {\n const [isActive, setActive] = useState(editMode === \"always\");\n const [cellEdits, setCellEdits] = useState<\n Record<\n string,\n CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >\n >\n >(\n {},\n );\n\n const handleCellEdit = useCallback(\n (\n cellId: string,\n info: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >,\n ) => {\n // If value is changed back to original, remove it from edits\n if (info.newValue === info.oldValue) {\n setCellEdits(prev => {\n const { [cellId]: _, ...rest } = prev;\n return rest;\n });\n } else {\n setCellEdits(prev => ({\n ...prev,\n [cellId]: info,\n }));\n }\n\n onCellValueChanged?.(info);\n },\n [onCellValueChanged],\n );\n\n const clearEdits = useCallback(() => {\n setCellEdits({});\n }, []);\n\n const handleSubmitEdits = useCallback(async () => {\n const edits = Object.values(cellEdits);\n return onSubmitEdits ? onSubmitEdits(edits) : false;\n }, [cellEdits, onSubmitEdits]);\n\n const editModeConfig: EditMode = editMode === \"always\"\n ? { type: \"always\", isActive: true }\n : { type: \"manual\", isActive, setActive };\n\n return {\n cellEdits,\n onCellEdit: handleCellEdit,\n onSubmitEdits: onSubmitEdits ? handleSubmitEdits : undefined,\n clearEdits,\n editMode: editModeConfig,\n };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,SAASA,WAAW,EAAEC,QAAQ,QAAQ,OAAO;AA8B7C,OAAO,SAASC,gBAAgBA,CAU9B;EACAC,QAAQ,GAAG,QAAQ;EACnBC,kBAAkB;EAClBC;AAC+C,CAAC,EAGhD;EACA,MAAM,CAACC,QAAQ,EAAEC,SAAS,CAAC,GAAGN,QAAQ,CAACE,QAAQ,KAAK,QAAQ,CAAC;EAC7D,MAAM,CAACK,SAAS,EAAEC,YAAY,CAAC,GAAGR,QAAQ,CASxC,CAAC,CACH,CAAC;EAED,MAAMS,cAAc,GAAGV,WAAW,CAChC,CACEW,MAAc,EACdC,IAGC,KACE;IACH;IACA,IAAIA,IAAI,CAACC,QAAQ,KAAKD,IAAI,CAACE,QAAQ,EAAE;MACnCL,YAAY,CAACM,IAAI,IAAI;QACnB,MAAM;UAAE,CAACJ,MAAM,GAAGK,CAAC;UAAE,GAAGC;QAAK,CAAC,GAAGF,IAAI;QACrC,OAAOE,IAAI;MACb,CAAC,CAAC;IACJ,CAAC,MAAM;MACLR,YAAY,CAACM,IAAI,KAAK;QACpB,GAAGA,IAAI;QACP,CAACJ,MAAM,GAAGC;MACZ,CAAC,CAAC,CAAC;IACL;IAEAR,kBAAkB,GAAGQ,IAAI,CAAC;EAC5B,CAAC,EACD,CAACR,kBAAkB,CACrB,CAAC;EAED,MAAMc,UAAU,GAAGlB,WAAW,CAAC,MAAM;IACnCS,YAAY,CAAC,CAAC,CAAC,CAAC;EAClB,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMU,iBAAiB,GAAGnB,WAAW,CAAC,YAAY;IAChD,MAAMoB,KAAK,GAAGC,MAAM,CAACC,MAAM,CAACd,SAAS,CAAC;IACtC,OAAOH,aAAa,GAAGA,aAAa,CAACe,KAAK,CAAC,GAAG,KAAK;EACrD,CAAC,EAAE,CAACZ,SAAS,EAAEH,aAAa,CAAC,CAAC;EAE9B,MAAMkB,cAAwB,GAAGpB,QAAQ,KAAK,QAAQ,GAClD;IAAEqB,IAAI,EAAE,QAAQ;IAAElB,QAAQ,EAAE;EAAK,CAAC,GAClC;IAAEkB,IAAI,EAAE,QAAQ;IAAElB,QAAQ;IAAEC;EAAU,CAAC;EAE3C,OAAO;IACLC,SAAS;IACTiB,UAAU,EAAEf,cAAc;IAC1BL,aAAa,EAAEA,aAAa,GAAGc,iBAAiB,GAAGO,SAAS;IAC5DR,UAAU;IACVf,QAAQ,EAAEoB;EACZ,CAAC;AACH","ignoreList":[]}
|
|
@@ -77,8 +77,6 @@ export function useObjectTableData(objectOrInterfaceType, columnDefinitions, fil
|
|
|
77
77
|
|
|
78
78
|
// Return the appropriate result based on which hook is enabled
|
|
79
79
|
if (shouldUseObjectSet) {
|
|
80
|
-
// eslint-disable-next-line no-console
|
|
81
|
-
console.debug("Using useObjectSet for data fetching in ObjectTable because objectSet is provided and objectType is an object.");
|
|
82
80
|
// Convert UseObjectSetResult to UseOsdkListResult format
|
|
83
81
|
return {
|
|
84
82
|
data: objectSetResult.data,
|
|
@@ -89,9 +87,6 @@ export function useObjectTableData(objectOrInterfaceType, columnDefinitions, fil
|
|
|
89
87
|
isOptimistic: false // ObjectSet doesn't support optimistic updates
|
|
90
88
|
};
|
|
91
89
|
}
|
|
92
|
-
|
|
93
|
-
// eslint-disable-next-line no-console
|
|
94
|
-
console.debug("Using useOsdkObjects for data fetching in ObjectTable because objectSet is not provided or objectType is an interface.");
|
|
95
90
|
return osdkObjectsResult;
|
|
96
91
|
}
|
|
97
92
|
//# sourceMappingURL=useObjectTableData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useObjectTableData.js","names":["useObjectSet","useOsdkObjects","useMemo","PAGE_SIZE","useObjectTableData","objectOrInterfaceType","columnDefinitions","filter","sorting","objectSet","objectSetOptions","orderBy","length","undefined","reduce","acc","sort","id","desc","withProperties","rdpColumns","map","colDef","locator","colLocator","type","cur","creator","isObjectType","shouldUseObjectSet","objectSetResult","where","pageSize","enabled","osdkObjectsResult","
|
|
1
|
+
{"version":3,"file":"useObjectTableData.js","names":["useObjectSet","useOsdkObjects","useMemo","PAGE_SIZE","useObjectTableData","objectOrInterfaceType","columnDefinitions","filter","sorting","objectSet","objectSetOptions","orderBy","length","undefined","reduce","acc","sort","id","desc","withProperties","rdpColumns","map","colDef","locator","colLocator","type","cur","creator","isObjectType","shouldUseObjectSet","objectSetResult","where","pageSize","enabled","osdkObjectsResult","data","fetchMore","isLoading","error","totalCount","isOptimistic"],"sources":["useObjectTableData.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { UseOsdkListResult } from \"@osdk/react/experimental\";\nimport { useObjectSet, useOsdkObjects } from \"@osdk/react/experimental\";\nimport type { SortingState } from \"@tanstack/react-table\";\nimport { useMemo } from \"react\";\nimport type { ColumnDefinition, ObjectSetOptions } from \"../ObjectTableApi.js\";\n\nconst PAGE_SIZE = 50;\n\ntype WithProperties<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n> = {\n [K in keyof RDPs]: DerivedProperty.Creator<Q, RDPs[K]>;\n};\n/**\n * This hook is a wrapper that conditionally uses either useObjectSet or useOsdkObjects\n * based on whether an objectSet prop is provided.\n * It extracts RDP locators from columnDefinitions and applies withProperties\n * to return data containing the derived properties.\n */\nexport function useObjectTableData<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<\n string,\n never\n >,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n>(\n objectOrInterfaceType: Q,\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>,\n filter?: WhereClause<Q, RDPs>,\n sorting?: SortingState,\n objectSet?: ObjectSet<Q>,\n objectSetOptions?: ObjectSetOptions<Q>,\n): UseOsdkListResult<Q, RDPs> {\n const orderBy = useMemo(() => {\n if (!sorting || sorting.length === 0) {\n return undefined;\n }\n\n return sorting.reduce<{ [K in PropertyKeys<Q>]?: \"asc\" | \"desc\" }>(\n (acc, sort) => {\n acc[sort.id as PropertyKeys<Q>] = sort.desc ? \"desc\" : \"asc\";\n return acc;\n },\n {},\n );\n }, [sorting]);\n\n // Extract derived properties definition\n const withProperties = useMemo(() => {\n if (!columnDefinitions) {\n return;\n }\n\n const rdpColumns = columnDefinitions.map(colDef => colDef.locator).filter(\n (colLocator) => {\n return colLocator.type === \"rdp\";\n },\n );\n\n if (!rdpColumns.length) {\n return;\n }\n\n return rdpColumns.reduce<WithProperties<Q, RDPs>>(\n (acc, cur) => {\n return {\n ...acc,\n [cur.id]: cur.creator,\n };\n },\n {} as WithProperties<Q, RDPs>,\n );\n }, [columnDefinitions]);\n\n // When objectSet is provided and it's an object type, use useObjectSet. Otherwise, use useOsdkObjects.\n const isObjectType = objectOrInterfaceType.type === \"object\";\n const shouldUseObjectSet = !!objectSet && isObjectType;\n\n // When shouldUseObjectSet is true, we know objectSet is defined\n // and objectOrInterfaceType is an ObjectTypeDefinition\n const objectSetResult = useObjectSet(\n shouldUseObjectSet ? objectSet as ObjectSet<Q> : undefined as any,\n {\n ...(objectSetOptions as ObjectSetOptions<Q>),\n withProperties: withProperties as WithProperties<\n Q,\n RDPs\n >,\n where: filter,\n orderBy,\n pageSize: PAGE_SIZE,\n enabled: shouldUseObjectSet,\n },\n );\n\n const osdkObjectsResult = useOsdkObjects<\n Q,\n RDPs\n >(\n objectOrInterfaceType,\n {\n withProperties,\n pageSize: PAGE_SIZE,\n where: filter,\n orderBy,\n enabled: !shouldUseObjectSet,\n },\n );\n\n // Return the appropriate result based on which hook is enabled\n if (shouldUseObjectSet) {\n // Convert UseObjectSetResult to UseOsdkListResult format\n return {\n data: objectSetResult.data,\n fetchMore: objectSetResult.fetchMore,\n isLoading: objectSetResult.isLoading,\n error: objectSetResult.error,\n totalCount: objectSetResult.totalCount,\n isOptimistic: false, // ObjectSet doesn't support optimistic updates\n } as UseOsdkListResult<Q, RDPs>;\n }\n\n return osdkObjectsResult;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYA,SAASA,YAAY,EAAEC,cAAc,QAAQ,0BAA0B;AAEvE,SAASC,OAAO,QAAQ,OAAO;AAG/B,MAAMC,SAAS,GAAG,EAAE;AAWpB;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAWhCC,qBAAwB,EACxBC,iBAAqE,EACrEC,MAA6B,EAC7BC,OAAsB,EACtBC,SAAwB,EACxBC,gBAAsC,EACV;E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,cAGf;IACDY,KAAK,EAAExB,MAAM;IACbI,OAAO;IACPqB,QAAQ,EAAE7B,SAAS;IACnB8B,OAAO,EAAEJ;EACX,CACF,CAAC;EAED,MAAMK,iBAAiB,GAAGjC,cAAc,CAItCI,qBAAqB,EACrB;IACEc,cAAc;IACda,QAAQ,EAAE7B,SAAS;IACnB4B,KAAK,EAAExB,MAAM;IACbI,OAAO;IACPsB,OAAO,EAAE,CAACJ;EACZ,CACF,CAAC;;EAED;EACA,IAAIA,kBAAkB,EAAE;IACtB;IACA,OAAO;MACLM,IAAI,EAAEL,eAAe,CAACK,IAAI;MAC1BC,SAAS,EAAEN,eAAe,CAACM,SAAS;MACpCC,SAAS,EAAEP,eAAe,CAACO,SAAS;MACpCC,KAAK,EAAER,eAAe,CAACQ,KAAK;MAC5BC,UAAU,EAAET,eAAe,CAACS,UAAU;MACtCC,YAAY,EAAE,KAAK,CAAE;IACvB,CAAC;EACH;EAEA,OAAON,iBAAiB;AAC1B","ignoreList":[]}
|
|
@@ -17,11 +17,4 @@
|
|
|
17
17
|
export function getCellId(cellIdentifier) {
|
|
18
18
|
return JSON.stringify(cellIdentifier);
|
|
19
19
|
}
|
|
20
|
-
export function getCellIdentifier(cellId) {
|
|
21
|
-
const parsed = JSON.parse(cellId);
|
|
22
|
-
if (typeof parsed === "object" && parsed != null && "rowId" in parsed && "columnId" in parsed) {
|
|
23
|
-
return parsed;
|
|
24
|
-
}
|
|
25
|
-
throw new Error("Parsed cellId does not have required properties");
|
|
26
|
-
}
|
|
27
20
|
//# sourceMappingURL=getCellId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCellId.js","names":["getCellId","cellIdentifier","JSON","stringify"
|
|
1
|
+
{"version":3,"file":"getCellId.js","names":["getCellId","cellIdentifier","JSON","stringify"],"sources":["getCellId.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { CellIdentifier } from \"./types.js\";\n\nexport function getCellId(cellIdentifier: CellIdentifier): string {\n return JSON.stringify(cellIdentifier);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,SAASA,SAASA,CAACC,cAA8B,EAAU;EAChE,OAAOC,IAAI,CAACC,SAAS,CAACF,cAAc,CAAC;AACvC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["types.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RowData } from \"@tanstack/react-table\";\n\nexport interface ColumnOption {\n id: string;\n name: string;\n canSort: boolean;\n}\n\nexport interface CellIdentifier {\n rowId: string;\n columnId: string;\n}\n\nexport interface
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["types.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { RowData } from \"@tanstack/react-table\";\n\nexport interface ColumnOption {\n id: string;\n name: string;\n canSort: boolean;\n}\n\nexport interface CellIdentifier {\n rowId: string;\n columnId: string;\n}\n\nexport interface CellEditInfo<\n TData extends RowData = unknown,\n CellValue = unknown,\n> extends CellIdentifier {\n newValue: CellValue;\n oldValue: CellValue;\n originalRowData: TData;\n}\n\nexport type EditMode =\n | { type: \"always\"; isActive: true }\n | { type: \"manual\"; isActive: boolean; setActive: (value: boolean) => void };\n\nexport interface EditableConfig<\n TData extends RowData = unknown,\n CellValue = unknown,\n> {\n cellEdits: Record<string, CellEditInfo<TData, CellValue>>;\n onCellEdit: (\n cellId: string,\n info: CellEditInfo<TData, CellValue>,\n ) => void;\n onSubmitEdits?: () => Promise<boolean>;\n clearEdits: () => void;\n editMode: EditMode;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"experimental.js","names":["FilterList","ObjectTable","BaseTable","ColumnConfigDialog"],"sources":["experimental.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { FilterList } from \"../filter-list/base/FilterList.js\";\nexport type {\n FilterDefinitionUnion,\n FilterListProps,\n} from \"../filter-list/FilterListApi.js\";\nexport type {\n FilterComponentType,\n FilterListItemProps,\n FilterState,\n PropertyFilterDefinition,\n} from \"../filter-list/FilterListItemApi.js\";\n\n// ObjectTable that loads and displays data for a given objectSet\nexport { ObjectTable } from \"../object-table/ObjectTable.js\";\nexport type {\n ColumnDefinition,\n ColumnDefinitionLocator,\n ObjectTableProps,\n} from \"../object-table/ObjectTableApi.js\";\nexport type {
|
|
1
|
+
{"version":3,"file":"experimental.js","names":["FilterList","ObjectTable","BaseTable","ColumnConfigDialog"],"sources":["experimental.ts"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport { FilterList } from \"../filter-list/base/FilterList.js\";\nexport type {\n FilterDefinitionUnion,\n FilterListProps,\n} from \"../filter-list/FilterListApi.js\";\nexport type {\n FilterComponentType,\n FilterListItemProps,\n FilterState,\n PropertyFilterDefinition,\n} from \"../filter-list/FilterListItemApi.js\";\n\n// ObjectTable that loads and displays data for a given objectSet\nexport { ObjectTable } from \"../object-table/ObjectTable.js\";\nexport type {\n ColumnDefinition,\n ColumnDefinitionLocator,\n ObjectTableProps,\n} from \"../object-table/ObjectTableApi.js\";\nexport type { CellEditInfo } from \"../object-table/utils/types.js\";\n\n// BaseTable that does not handle data fetching\nexport type { BaseTableProps } from \"../object-table/Table.js\";\nexport { BaseTable } from \"../object-table/Table.js\";\n\nexport { ColumnConfigDialog } from \"../object-table/ColumnConfigDialog.js\";\nexport type {\n ColumnConfigDialogProps,\n ColumnConfigOptions,\n} from \"../object-table/ColumnConfigDialog.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,QAAQ,mCAAmC;AAY9D;AACA,SAASC,WAAW,QAAQ,gCAAgC;;AAQ5D;;AAEA,SAASC,SAAS,QAAQ,0BAA0B;AAEpD,SAASC,kBAAkB,QAAQ,uCAAuC","ignoreList":[]}
|