@osdk/react-components 0.2.0-beta.24 → 0.2.0-beta.26
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 +4 -0
- package/CHANGELOG.md +38 -0
- package/build/browser/action-form/ActionForm.js +15 -11
- package/build/browser/action-form/ActionForm.js.map +1 -1
- package/build/browser/action-form/FormFieldApi.js.map +1 -1
- package/build/browser/action-form/fields/{TextInputField.module.css → BaseInput.module.css} +2 -2
- package/build/browser/action-form/fields/BaseInput.module.css.js +6 -0
- package/build/browser/action-form/fields/CustomField.js +30 -0
- package/build/browser/action-form/fields/CustomField.js.map +1 -0
- package/build/browser/action-form/fields/FormFieldRenderer.js +26 -16
- package/build/browser/action-form/fields/FormFieldRenderer.js.map +1 -1
- package/build/browser/action-form/fields/RadioButtonsField.js +57 -0
- package/build/browser/action-form/fields/RadioButtonsField.js.map +1 -0
- package/build/browser/action-form/fields/RadioButtonsField.module.css +83 -0
- package/build/browser/action-form/fields/RadioButtonsField.module.css.js +10 -0
- package/build/browser/action-form/fields/TextAreaField.js +50 -0
- package/build/browser/action-form/fields/TextAreaField.js.map +1 -0
- package/build/browser/action-form/fields/TextInputField.js +3 -3
- package/build/browser/action-form/fields/TextInputField.js.map +1 -1
- package/build/browser/action-form/utils/getDefaultFieldDefinitions.js +97 -10
- package/build/browser/action-form/utils/getDefaultFieldDefinitions.js.map +1 -1
- package/build/browser/base-components/dialog/Dialog.js +4 -2
- package/build/browser/base-components/dialog/Dialog.js.map +1 -1
- package/build/browser/object-table/ObjectTableApi.js.map +1 -1
- package/build/browser/object-table/hooks/useFunctionColumnsData.js +57 -192
- package/build/browser/object-table/hooks/useFunctionColumnsData.js.map +1 -1
- package/build/browser/pdf-viewer/PdfViewer.js +49 -8
- package/build/browser/pdf-viewer/PdfViewer.js.map +1 -1
- package/build/browser/pdf-viewer/PdfViewerContext.js +108 -0
- package/build/browser/pdf-viewer/PdfViewerContext.js.map +1 -0
- package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js +85 -18
- package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.module.css +18 -0
- package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.module.css.js +1 -0
- package/build/browser/pdf-viewer/components/PdfViewerContent.js +15 -3
- package/build/browser/pdf-viewer/components/PdfViewerContent.js.map +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerOutlineSidebar.module.css +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerSidebar.module.css +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerSidebarHeader.module.css +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerToolbar.js +29 -2
- package/build/browser/pdf-viewer/components/PdfViewerToolbar.js.map +1 -1
- package/build/browser/pdf-viewer/components/PdfViewerToolbar.module.css +5 -0
- package/build/browser/pdf-viewer/components/PdfViewerToolbar.module.css.js +1 -0
- package/build/browser/pdf-viewer/constants.js +2 -1
- package/build/browser/pdf-viewer/constants.js.map +1 -1
- package/build/browser/pdf-viewer/hooks/usePdfAnnotationsByPage.js +30 -0
- package/build/browser/pdf-viewer/hooks/usePdfAnnotationsByPage.js.map +1 -0
- package/build/browser/pdf-viewer/hooks/usePdfFormFields.js +341 -0
- package/build/browser/pdf-viewer/hooks/usePdfFormFields.js.map +1 -0
- package/build/browser/pdf-viewer/hooks/usePdfHighlightMode.js +227 -0
- package/build/browser/pdf-viewer/hooks/usePdfHighlightMode.js.map +1 -0
- package/build/browser/pdf-viewer/hooks/usePdfViewer.js +16 -10
- package/build/browser/pdf-viewer/hooks/usePdfViewer.js.map +1 -1
- package/build/browser/pdf-viewer/hooks/usePdfViewerCore.js +3 -3
- package/build/browser/pdf-viewer/hooks/usePdfViewerCore.js.map +1 -1
- package/build/browser/pdf-viewer/hooks/usePdfViewerSearch.js +3 -3
- package/build/browser/pdf-viewer/hooks/usePdfViewerSearch.js.map +1 -1
- package/build/browser/pdf-viewer/hooks/usePdfViewerState.js +3 -3
- package/build/browser/pdf-viewer/hooks/usePdfViewerState.js.map +1 -1
- package/build/browser/pdf-viewer/types.js.map +1 -1
- package/build/browser/public/experimental.js +5 -0
- package/build/browser/public/experimental.js.map +1 -1
- package/build/browser/styles.css +144 -35
- package/build/cjs/{chunk-GT6IV6LV.cjs → chunk-MRRRZN44.cjs} +6 -4
- package/build/cjs/chunk-MRRRZN44.cjs.map +1 -0
- package/build/cjs/public/experimental.cjs +1981 -1314
- package/build/cjs/public/experimental.cjs.map +1 -1
- package/build/cjs/public/experimental.css +82 -5
- package/build/cjs/public/experimental.css.map +1 -1
- package/build/cjs/public/experimental.d.cts +267 -26
- package/build/cjs/public/primitives.cjs +5 -5
- package/build/cjs/public/primitives.d.cts +3 -2
- package/build/esm/action-form/ActionForm.js +15 -11
- package/build/esm/action-form/ActionForm.js.map +1 -1
- package/build/esm/action-form/FormFieldApi.js.map +1 -1
- package/build/esm/action-form/fields/{TextInputField.module.css → BaseInput.module.css} +2 -2
- package/build/esm/action-form/fields/CustomField.js +30 -0
- package/build/esm/action-form/fields/CustomField.js.map +1 -0
- package/build/esm/action-form/fields/FormFieldRenderer.js +26 -16
- package/build/esm/action-form/fields/FormFieldRenderer.js.map +1 -1
- package/build/esm/action-form/fields/RadioButtonsField.js +57 -0
- package/build/esm/action-form/fields/RadioButtonsField.js.map +1 -0
- package/build/esm/action-form/fields/RadioButtonsField.module.css +83 -0
- package/build/esm/action-form/fields/TextAreaField.js +50 -0
- package/build/esm/action-form/fields/TextAreaField.js.map +1 -0
- package/build/esm/action-form/fields/TextInputField.js +3 -3
- package/build/esm/action-form/fields/TextInputField.js.map +1 -1
- package/build/esm/action-form/utils/getDefaultFieldDefinitions.js +97 -10
- package/build/esm/action-form/utils/getDefaultFieldDefinitions.js.map +1 -1
- package/build/esm/base-components/dialog/Dialog.js +4 -2
- package/build/esm/base-components/dialog/Dialog.js.map +1 -1
- package/build/esm/object-table/ObjectTableApi.js.map +1 -1
- package/build/esm/object-table/hooks/useFunctionColumnsData.js +57 -192
- package/build/esm/object-table/hooks/useFunctionColumnsData.js.map +1 -1
- package/build/esm/pdf-viewer/PdfViewer.js +49 -8
- package/build/esm/pdf-viewer/PdfViewer.js.map +1 -1
- package/build/esm/pdf-viewer/PdfViewerContext.js +108 -0
- package/build/esm/pdf-viewer/PdfViewerContext.js.map +1 -0
- package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js +85 -18
- package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.module.css +18 -0
- package/build/esm/pdf-viewer/components/PdfViewerContent.js +15 -3
- package/build/esm/pdf-viewer/components/PdfViewerContent.js.map +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerOutlineSidebar.module.css +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerSidebar.module.css +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerSidebarHeader.module.css +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerToolbar.js +29 -2
- package/build/esm/pdf-viewer/components/PdfViewerToolbar.js.map +1 -1
- package/build/esm/pdf-viewer/components/PdfViewerToolbar.module.css +5 -0
- package/build/esm/pdf-viewer/constants.js +2 -1
- package/build/esm/pdf-viewer/constants.js.map +1 -1
- package/build/esm/pdf-viewer/hooks/usePdfAnnotationsByPage.js +30 -0
- package/build/esm/pdf-viewer/hooks/usePdfAnnotationsByPage.js.map +1 -0
- package/build/esm/pdf-viewer/hooks/usePdfFormFields.js +341 -0
- package/build/esm/pdf-viewer/hooks/usePdfFormFields.js.map +1 -0
- package/build/esm/pdf-viewer/hooks/usePdfHighlightMode.js +227 -0
- package/build/esm/pdf-viewer/hooks/usePdfHighlightMode.js.map +1 -0
- package/build/esm/pdf-viewer/hooks/usePdfViewer.js +16 -10
- package/build/esm/pdf-viewer/hooks/usePdfViewer.js.map +1 -1
- package/build/esm/pdf-viewer/hooks/usePdfViewerCore.js +3 -3
- package/build/esm/pdf-viewer/hooks/usePdfViewerCore.js.map +1 -1
- package/build/esm/pdf-viewer/hooks/usePdfViewerSearch.js +3 -3
- package/build/esm/pdf-viewer/hooks/usePdfViewerSearch.js.map +1 -1
- package/build/esm/pdf-viewer/hooks/usePdfViewerState.js +3 -3
- package/build/esm/pdf-viewer/hooks/usePdfViewerState.js.map +1 -1
- package/build/esm/pdf-viewer/types.js.map +1 -1
- package/build/esm/public/experimental.js +5 -0
- package/build/esm/public/experimental.js.map +1 -1
- package/build/types/action-form/FormFieldApi.d.ts +11 -5
- package/build/types/action-form/FormFieldApi.d.ts.map +1 -1
- package/build/types/action-form/fields/CustomField.d.ts +9 -0
- package/build/types/action-form/fields/CustomField.d.ts.map +1 -0
- package/build/types/action-form/fields/FormFieldRenderer.d.ts.map +1 -1
- package/build/types/action-form/fields/RadioButtonsField.d.ts +3 -0
- package/build/types/action-form/fields/RadioButtonsField.d.ts.map +1 -0
- package/build/types/action-form/fields/TextAreaField.d.ts +3 -0
- package/build/types/action-form/fields/TextAreaField.d.ts.map +1 -0
- package/build/types/action-form/utils/getDefaultFieldDefinitions.d.ts +7 -4
- package/build/types/action-form/utils/getDefaultFieldDefinitions.d.ts.map +1 -1
- package/build/types/base-components/dialog/Dialog.d.ts +3 -2
- package/build/types/base-components/dialog/Dialog.d.ts.map +1 -1
- package/build/types/object-table/ObjectTableApi.d.ts +4 -3
- package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
- package/build/types/object-table/hooks/useFunctionColumnsData.d.ts.map +1 -1
- package/build/types/pdf-viewer/PdfViewer.d.ts +2 -2
- package/build/types/pdf-viewer/PdfViewer.d.ts.map +1 -1
- package/build/types/pdf-viewer/PdfViewerContext.d.ts +64 -0
- package/build/types/pdf-viewer/PdfViewerContext.d.ts.map +1 -0
- package/build/types/pdf-viewer/components/PdfViewerAnnotationLayer.d.ts.map +1 -1
- package/build/types/pdf-viewer/components/PdfViewerContent.d.ts +8 -4
- package/build/types/pdf-viewer/components/PdfViewerContent.d.ts.map +1 -1
- package/build/types/pdf-viewer/components/PdfViewerToolbar.d.ts +6 -1
- package/build/types/pdf-viewer/components/PdfViewerToolbar.d.ts.map +1 -1
- package/build/types/pdf-viewer/constants.d.ts +1 -1
- package/build/types/pdf-viewer/constants.d.ts.map +1 -1
- package/build/types/pdf-viewer/hooks/usePdfAnnotationsByPage.d.ts +5 -0
- package/build/types/pdf-viewer/hooks/usePdfAnnotationsByPage.d.ts.map +1 -0
- package/build/types/pdf-viewer/hooks/usePdfFormFields.d.ts +24 -0
- package/build/types/pdf-viewer/hooks/usePdfFormFields.d.ts.map +1 -0
- package/build/types/pdf-viewer/hooks/usePdfHighlightMode.d.ts +36 -0
- package/build/types/pdf-viewer/hooks/usePdfHighlightMode.d.ts.map +1 -0
- package/build/types/pdf-viewer/hooks/usePdfViewer.d.ts.map +1 -1
- package/build/types/pdf-viewer/types.d.ts +137 -13
- package/build/types/pdf-viewer/types.d.ts.map +1 -1
- package/build/types/public/experimental.d.ts +6 -1
- package/build/types/public/experimental.d.ts.map +1 -1
- package/package.json +6 -6
- package/build/browser/action-form/fields/TextInputField.module.css.js +0 -6
- package/build/browser/action-form/utils/getDefaultFieldComponent.js +0 -56
- package/build/browser/action-form/utils/getDefaultFieldComponent.js.map +0 -1
- package/build/cjs/chunk-GT6IV6LV.cjs.map +0 -1
- package/build/esm/action-form/utils/getDefaultFieldComponent.js +0 -56
- package/build/esm/action-form/utils/getDefaultFieldComponent.js.map +0 -1
- package/build/types/action-form/utils/getDefaultFieldComponent.d.ts +0 -6
- package/build/types/action-form/utils/getDefaultFieldComponent.d.ts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright
|
|
2
|
+
* Copyright 2026 Palantir Technologies, Inc. All rights reserved.
|
|
3
3
|
*
|
|
4
4
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
* you may not use this file except in compliance with the License.
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { Input } from "@base-ui/react/input";
|
|
18
18
|
import React from "react";
|
|
19
|
-
import styles from "./
|
|
19
|
+
import styles from "./BaseInput.module.css.js";
|
|
20
20
|
export function TextInputField({
|
|
21
21
|
id,
|
|
22
22
|
value,
|
|
@@ -27,7 +27,7 @@ export function TextInputField({
|
|
|
27
27
|
}) {
|
|
28
28
|
return /*#__PURE__*/React.createElement(Input, {
|
|
29
29
|
id: id,
|
|
30
|
-
className: styles.
|
|
30
|
+
className: styles.osdkBaseInput,
|
|
31
31
|
type: "text",
|
|
32
32
|
value: value ?? "",
|
|
33
33
|
onValueChange: onChange,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextInputField.js","names":["Input","React","styles","TextInputField","id","value","onChange","placeholder","minLength","maxLength","createElement","className","
|
|
1
|
+
{"version":3,"file":"TextInputField.js","names":["Input","React","styles","TextInputField","id","value","onChange","placeholder","minLength","maxLength","createElement","className","osdkBaseInput","type","onValueChange"],"sources":["TextInputField.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 { Input } from \"@base-ui/react/input\";\nimport React from \"react\";\nimport type { TextInputFieldProps } from \"../FormFieldApi.js\";\nimport styles from \"./BaseInput.module.css\";\n\nexport function TextInputField({\n id,\n value,\n onChange,\n placeholder,\n minLength,\n maxLength,\n}: TextInputFieldProps & { id?: string }): React.ReactElement {\n return (\n <Input\n id={id}\n className={styles.osdkBaseInput}\n type=\"text\"\n value={value ?? \"\"}\n onValueChange={onChange}\n placeholder={placeholder}\n minLength={minLength}\n maxLength={maxLength}\n />\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,QAAQ,sBAAsB;AAC5C,OAAOC,KAAK,MAAM,OAAO;AAEzB,OAAOC,MAAM,MAAM,wBAAwB;AAE3C,OAAO,SAASC,cAAcA,CAAC;EAC7BC,EAAE;EACFC,KAAK;EACLC,QAAQ;EACRC,WAAW;EACXC,SAAS;EACTC;AACqC,CAAC,EAAsB;EAC5D,oBACER,KAAA,CAAAS,aAAA,CAACV,KAAK;IACJI,EAAE,EAAEA,EAAG;IACPO,SAAS,EAAET,MAAM,CAACU,aAAc;IAChCC,IAAI,EAAC,MAAM;IACXR,KAAK,EAAEA,KAAK,IAAI,EAAG;IACnBS,aAAa,EAAER,QAAS;IACxBC,WAAW,EAAEA,WAAY;IACzBC,SAAS,EAAEA,SAAU;IACrBC,SAAS,EAAEA;EAAU,CACtB,CAAC;AAEN","ignoreList":[]}
|
|
@@ -14,20 +14,107 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
18
|
-
|
|
17
|
+
import { assertUnreachable } from "../../shared/assertUnreachable.js";
|
|
19
18
|
/**
|
|
20
|
-
* Derives default field definitions from
|
|
19
|
+
* Derives default field definitions from ActionMetadata.
|
|
20
|
+
*
|
|
21
|
+
* Each parameter type maps to a concrete RendererFieldDefinition with the
|
|
22
|
+
* correct fieldComponent and default fieldComponentProps.
|
|
21
23
|
*/
|
|
22
24
|
export function getDefaultFieldDefinitions(metadata) {
|
|
23
|
-
return Object.entries(metadata.parameters).map(([key, param]) => (
|
|
24
|
-
|
|
25
|
+
return Object.entries(metadata.parameters).map(([key, param]) => buildFieldDefinition(key, param));
|
|
26
|
+
}
|
|
27
|
+
const EMPTY_ITEMS = [];
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Maps a single action parameter to its default RendererFieldDefinition.
|
|
31
|
+
*
|
|
32
|
+
* Switches on the parameter's data type to select both the field component
|
|
33
|
+
* and its required default props.
|
|
34
|
+
*/
|
|
35
|
+
function buildFieldDefinition(key, param) {
|
|
36
|
+
const base = {
|
|
25
37
|
fieldKey: key,
|
|
26
38
|
label: key,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
isRequired: !param.nullable,
|
|
40
|
+
fieldType: param.type
|
|
41
|
+
};
|
|
42
|
+
const paramType = param.type;
|
|
43
|
+
if (typeof paramType === "object") {
|
|
44
|
+
switch (paramType.type) {
|
|
45
|
+
case "objectSet":
|
|
46
|
+
return {
|
|
47
|
+
...base,
|
|
48
|
+
fieldComponent: "OBJECT_SET",
|
|
49
|
+
fieldComponentProps: {}
|
|
50
|
+
};
|
|
51
|
+
case "object":
|
|
52
|
+
case "interface":
|
|
53
|
+
// TODO: provide correct items
|
|
54
|
+
return {
|
|
55
|
+
...base,
|
|
56
|
+
fieldComponent: "DROPDOWN",
|
|
57
|
+
fieldComponentProps: {
|
|
58
|
+
items: EMPTY_ITEMS
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
case "struct":
|
|
62
|
+
return {
|
|
63
|
+
...base,
|
|
64
|
+
fieldComponent: "TEXT_INPUT",
|
|
65
|
+
fieldComponentProps: {}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
switch (paramType) {
|
|
70
|
+
case "string":
|
|
71
|
+
case "marking":
|
|
72
|
+
case "geohash":
|
|
73
|
+
case "geoshape":
|
|
74
|
+
case "objectType":
|
|
75
|
+
return {
|
|
76
|
+
...base,
|
|
77
|
+
fieldComponent: "TEXT_INPUT",
|
|
78
|
+
fieldComponentProps: {}
|
|
79
|
+
};
|
|
80
|
+
case "boolean":
|
|
81
|
+
return {
|
|
82
|
+
...base,
|
|
83
|
+
fieldComponent: "RADIO_BUTTONS",
|
|
84
|
+
fieldComponentProps: {
|
|
85
|
+
options: [{
|
|
86
|
+
label: "True",
|
|
87
|
+
value: true
|
|
88
|
+
}, {
|
|
89
|
+
label: "False",
|
|
90
|
+
value: false
|
|
91
|
+
}]
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
case "integer":
|
|
95
|
+
case "double":
|
|
96
|
+
case "long":
|
|
97
|
+
return {
|
|
98
|
+
...base,
|
|
99
|
+
fieldComponent: "NUMBER_INPUT",
|
|
100
|
+
fieldComponentProps: {}
|
|
101
|
+
};
|
|
102
|
+
case "datetime":
|
|
103
|
+
case "timestamp":
|
|
104
|
+
return {
|
|
105
|
+
...base,
|
|
106
|
+
fieldComponent: "DATETIME_PICKER",
|
|
107
|
+
fieldComponentProps: {}
|
|
108
|
+
};
|
|
109
|
+
case "attachment":
|
|
110
|
+
case "mediaReference":
|
|
111
|
+
return {
|
|
112
|
+
...base,
|
|
113
|
+
fieldComponent: "FILE_PICKER",
|
|
114
|
+
fieldComponentProps: {}
|
|
115
|
+
};
|
|
116
|
+
default:
|
|
117
|
+
return assertUnreachable(paramType);
|
|
118
|
+
}
|
|
32
119
|
}
|
|
33
120
|
//# sourceMappingURL=getDefaultFieldDefinitions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDefaultFieldDefinitions.js","names":["
|
|
1
|
+
{"version":3,"file":"getDefaultFieldDefinitions.js","names":["assertUnreachable","getDefaultFieldDefinitions","metadata","Object","entries","parameters","map","key","param","buildFieldDefinition","EMPTY_ITEMS","base","fieldKey","label","isRequired","nullable","fieldType","type","paramType","fieldComponent","fieldComponentProps","items","options","value"],"sources":["getDefaultFieldDefinitions.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 { ActionMetadata } from \"@osdk/api\";\nimport { assertUnreachable } from \"../../shared/assertUnreachable.js\";\nimport type { RendererFieldDefinition } from \"../FormFieldApi.js\";\n\n/**\n * Derives default field definitions from ActionMetadata.\n *\n * Each parameter type maps to a concrete RendererFieldDefinition with the\n * correct fieldComponent and default fieldComponentProps.\n */\nexport function getDefaultFieldDefinitions(\n metadata: ActionMetadata,\n): ReadonlyArray<RendererFieldDefinition> {\n return Object.entries(metadata.parameters).map(\n ([key, param]) => buildFieldDefinition(key, param),\n );\n}\n\nconst EMPTY_ITEMS: unknown[] = [];\n\n/**\n * Maps a single action parameter to its default RendererFieldDefinition.\n *\n * Switches on the parameter's data type to select both the field component\n * and its required default props.\n */\nfunction buildFieldDefinition(\n key: string,\n param: ActionMetadata.Parameter,\n): RendererFieldDefinition {\n const base = {\n fieldKey: key,\n label: key,\n isRequired: !param.nullable,\n fieldType: param.type,\n };\n\n const paramType = param.type;\n\n if (typeof paramType === \"object\") {\n switch (paramType.type) {\n case \"objectSet\":\n return {\n ...base,\n fieldComponent: \"OBJECT_SET\",\n fieldComponentProps: {},\n };\n case \"object\":\n case \"interface\":\n // TODO: provide correct items\n return {\n ...base,\n fieldComponent: \"DROPDOWN\",\n fieldComponentProps: { items: EMPTY_ITEMS },\n };\n case \"struct\":\n return {\n ...base,\n fieldComponent: \"TEXT_INPUT\",\n fieldComponentProps: {},\n };\n }\n }\n\n switch (paramType) {\n case \"string\":\n case \"marking\":\n case \"geohash\":\n case \"geoshape\":\n case \"objectType\":\n return {\n ...base,\n fieldComponent: \"TEXT_INPUT\",\n fieldComponentProps: {},\n };\n case \"boolean\":\n return {\n ...base,\n fieldComponent: \"RADIO_BUTTONS\",\n fieldComponentProps: {\n options: [{ label: \"True\", value: true }, {\n label: \"False\",\n value: false,\n }],\n },\n };\n case \"integer\":\n case \"double\":\n case \"long\":\n return {\n ...base,\n fieldComponent: \"NUMBER_INPUT\",\n fieldComponentProps: {},\n };\n case \"datetime\":\n case \"timestamp\":\n return {\n ...base,\n fieldComponent: \"DATETIME_PICKER\",\n fieldComponentProps: {},\n };\n case \"attachment\":\n case \"mediaReference\":\n return {\n ...base,\n fieldComponent: \"FILE_PICKER\",\n fieldComponentProps: {},\n };\n default:\n return assertUnreachable(paramType);\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,iBAAiB,QAAQ,mCAAmC;AAGrE;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,0BAA0BA,CACxCC,QAAwB,EACgB;EACxC,OAAOC,MAAM,CAACC,OAAO,CAACF,QAAQ,CAACG,UAAU,CAAC,CAACC,GAAG,CAC5C,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAKC,oBAAoB,CAACF,GAAG,EAAEC,KAAK,CACnD,CAAC;AACH;AAEA,MAAME,WAAsB,GAAG,EAAE;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA,SAASD,oBAAoBA,CAC3BF,GAAW,EACXC,KAA+B,EACN;EACzB,MAAMG,IAAI,GAAG;IACXC,QAAQ,EAAEL,GAAG;IACbM,KAAK,EAAEN,GAAG;IACVO,UAAU,EAAE,CAACN,KAAK,CAACO,QAAQ;IAC3BC,SAAS,EAAER,KAAK,CAACS;EACnB,CAAC;EAED,MAAMC,SAAS,GAAGV,KAAK,CAACS,IAAI;EAE5B,IAAI,OAAOC,SAAS,KAAK,QAAQ,EAAE;IACjC,QAAQA,SAAS,CAACD,IAAI;MACpB,KAAK,WAAW;QACd,OAAO;UACL,GAAGN,IAAI;UACPQ,cAAc,EAAE,YAAY;UAC5BC,mBAAmB,EAAE,CAAC;QACxB,CAAC;MACH,KAAK,QAAQ;MACb,KAAK,WAAW;QACd;QACA,OAAO;UACL,GAAGT,IAAI;UACPQ,cAAc,EAAE,UAAU;UAC1BC,mBAAmB,EAAE;YAAEC,KAAK,EAAEX;UAAY;QAC5C,CAAC;MACH,KAAK,QAAQ;QACX,OAAO;UACL,GAAGC,IAAI;UACPQ,cAAc,EAAE,YAAY;UAC5BC,mBAAmB,EAAE,CAAC;QACxB,CAAC;IACL;EACF;EAEA,QAAQF,SAAS;IACf,KAAK,QAAQ;IACb,KAAK,SAAS;IACd,KAAK,SAAS;IACd,KAAK,UAAU;IACf,KAAK,YAAY;MACf,OAAO;QACL,GAAGP,IAAI;QACPQ,cAAc,EAAE,YAAY;QAC5BC,mBAAmB,EAAE,CAAC;MACxB,CAAC;IACH,KAAK,SAAS;MACZ,OAAO;QACL,GAAGT,IAAI;QACPQ,cAAc,EAAE,eAAe;QAC/BC,mBAAmB,EAAE;UACnBE,OAAO,EAAE,CAAC;YAAET,KAAK,EAAE,MAAM;YAAEU,KAAK,EAAE;UAAK,CAAC,EAAE;YACxCV,KAAK,EAAE,OAAO;YACdU,KAAK,EAAE;UACT,CAAC;QACH;MACF,CAAC;IACH,KAAK,SAAS;IACd,KAAK,QAAQ;IACb,KAAK,MAAM;MACT,OAAO;QACL,GAAGZ,IAAI;QACPQ,cAAc,EAAE,cAAc;QAC9BC,mBAAmB,EAAE,CAAC;MACxB,CAAC;IACH,KAAK,UAAU;IACf,KAAK,WAAW;MACd,OAAO;QACL,GAAGT,IAAI;QACPQ,cAAc,EAAE,iBAAiB;QACjCC,mBAAmB,EAAE,CAAC;MACxB,CAAC;IACH,KAAK,YAAY;IACjB,KAAK,gBAAgB;MACnB,OAAO;QACL,GAAGT,IAAI;QACPQ,cAAc,EAAE,aAAa;QAC7BC,mBAAmB,EAAE,CAAC;MACxB,CAAC;IACH;MACE,OAAOpB,iBAAiB,CAACkB,SAAS,CAAC;EACvC;AACF","ignoreList":[]}
|
|
@@ -25,11 +25,13 @@ export function Dialog({
|
|
|
25
25
|
title,
|
|
26
26
|
children,
|
|
27
27
|
footer,
|
|
28
|
-
className
|
|
28
|
+
className,
|
|
29
|
+
disablePointerDismissal
|
|
29
30
|
}) {
|
|
30
31
|
return /*#__PURE__*/React.createElement(BaseUIDialog.Root, {
|
|
31
32
|
open: isOpen,
|
|
32
|
-
onOpenChange: onOpenChange
|
|
33
|
+
onOpenChange: onOpenChange,
|
|
34
|
+
disablePointerDismissal: disablePointerDismissal
|
|
33
35
|
}, /*#__PURE__*/React.createElement(BaseUIDialog.Portal, null, /*#__PURE__*/React.createElement(BaseUIDialog.Backdrop, {
|
|
34
36
|
className: styles.backdrop
|
|
35
37
|
}), /*#__PURE__*/React.createElement(BaseUIDialog.Popup, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog.js","names":["Dialog","BaseUIDialog","Cross","classnames","React","styles","isOpen","onOpenChange","title","children","footer","className","createElement","Root","open","Portal","Backdrop","backdrop","Popup","popup","header","Title","Close","closeButton","closeIcon","body"],"sources":["Dialog.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 { Dialog as BaseUIDialog } from \"@base-ui/react/dialog\";\nimport { Cross } from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\nimport React from \"react\";\nimport styles from \"./Dialog.module.css\";\n\nexport interface DialogProps {\n isOpen: boolean;\n onOpenChange: () => void;\n title: React.ReactNode;\n children: React.ReactNode;\n footer?: React.ReactNode;\n className?: string;\n}\n\nexport function Dialog({\n isOpen,\n onOpenChange,\n title,\n children,\n footer,\n className,\n}: DialogProps): React.ReactElement {\n return (\n <BaseUIDialog.Root
|
|
1
|
+
{"version":3,"file":"Dialog.js","names":["Dialog","BaseUIDialog","Cross","classnames","React","styles","isOpen","onOpenChange","title","children","footer","className","disablePointerDismissal","createElement","Root","open","Portal","Backdrop","backdrop","Popup","popup","header","Title","Close","closeButton","closeIcon","body"],"sources":["Dialog.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 { Dialog as BaseUIDialog } from \"@base-ui/react/dialog\";\nimport { Cross } from \"@blueprintjs/icons\";\nimport classnames from \"classnames\";\nimport React from \"react\";\nimport styles from \"./Dialog.module.css\";\n\nexport interface DialogProps {\n isOpen: boolean;\n onOpenChange: (open: boolean) => void;\n title: React.ReactNode;\n children: React.ReactNode;\n footer?: React.ReactNode;\n className?: string;\n disablePointerDismissal?: boolean;\n}\n\nexport function Dialog({\n isOpen,\n onOpenChange,\n title,\n children,\n footer,\n className,\n disablePointerDismissal,\n}: DialogProps): React.ReactElement {\n return (\n <BaseUIDialog.Root\n open={isOpen}\n onOpenChange={onOpenChange}\n disablePointerDismissal={disablePointerDismissal}\n >\n <BaseUIDialog.Portal>\n <BaseUIDialog.Backdrop className={styles.backdrop} />\n <BaseUIDialog.Popup\n className={classnames(\n styles.popup,\n className,\n )}\n >\n <div className={styles.header}>\n <BaseUIDialog.Title className={styles.title}>\n {title}\n </BaseUIDialog.Title>\n <BaseUIDialog.Close\n className={styles.closeButton}\n aria-label=\"Close dialog\"\n >\n <Cross className={styles.closeIcon} />\n </BaseUIDialog.Close>\n </div>\n <div className={styles.body}>{children}</div>\n {footer != null && <div className={styles.footer}>{footer}</div>}\n </BaseUIDialog.Popup>\n </BaseUIDialog.Portal>\n </BaseUIDialog.Root>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,MAAM,IAAIC,YAAY,QAAQ,uBAAuB;AAC9D,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAOC,MAAM,MAAM,qBAAqB;AAYxC,OAAO,SAASL,MAAMA,CAAC;EACrBM,MAAM;EACNC,YAAY;EACZC,KAAK;EACLC,QAAQ;EACRC,MAAM;EACNC,SAAS;EACTC;AACW,CAAC,EAAsB;EAClC,oBACER,KAAA,CAAAS,aAAA,CAACZ,YAAY,CAACa,IAAI;IAChBC,IAAI,EAAET,MAAO;IACbC,YAAY,EAAEA,YAAa;IAC3BK,uBAAuB,EAAEA;EAAwB,gBAEjDR,KAAA,CAAAS,aAAA,CAACZ,YAAY,CAACe,MAAM,qBAClBZ,KAAA,CAAAS,aAAA,CAACZ,YAAY,CAACgB,QAAQ;IAACN,SAAS,EAAEN,MAAM,CAACa;EAAS,CAAE,CAAC,eACrDd,KAAA,CAAAS,aAAA,CAACZ,YAAY,CAACkB,KAAK;IACjBR,SAAS,EAAER,UAAU,CACnBE,MAAM,CAACe,KAAK,EACZT,SACF;EAAE,gBAEFP,KAAA,CAAAS,aAAA;IAAKF,SAAS,EAAEN,MAAM,CAACgB;EAAO,gBAC5BjB,KAAA,CAAAS,aAAA,CAACZ,YAAY,CAACqB,KAAK;IAACX,SAAS,EAAEN,MAAM,CAACG;EAAM,GACzCA,KACiB,CAAC,eACrBJ,KAAA,CAAAS,aAAA,CAACZ,YAAY,CAACsB,KAAK;IACjBZ,SAAS,EAAEN,MAAM,CAACmB,WAAY;IAC9B,cAAW;EAAc,gBAEzBpB,KAAA,CAAAS,aAAA,CAACX,KAAK;IAACS,SAAS,EAAEN,MAAM,CAACoB;EAAU,CAAE,CACnB,CACjB,CAAC,eACNrB,KAAA,CAAAS,aAAA;IAAKF,SAAS,EAAEN,MAAM,CAACqB;EAAK,GAAEjB,QAAc,CAAC,EAC5CC,MAAM,IAAI,IAAI,iBAAIN,KAAA,CAAAS,aAAA;IAAKF,SAAS,EAAEN,MAAM,CAACK;EAAO,GAAEA,MAAY,CAC7C,CACD,CACJ,CAAC;AAExB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObjectTableApi.js","names":[],"sources":["ObjectTableApi.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 Osdk,\n PrimaryKeyType,\n PropertyKeys,\n QueryDefinition,\n QueryMetadata,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type * as React from \"react\";\nimport type { CellEditInfo } from \"./utils/types.js\";\n\nexport type ColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> = {\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>;\n\n /**\n * @default true\n */\n isVisible?: boolean;\n\n /**\n * @default none\n */\n pinned?: \"left\" | \"right\" | \"none\";\n width?: number;\n minWidth?: number;\n maxWidth?: number;\n resizable?: boolean;\n orderable?: boolean;\n filterable?: boolean;\n editable?: boolean;\n\n /**\n * Additional function to validate the cell value during edit\n *\n * @param value the current cell value\n * @returns a promise that resolves to an error message string if validation fails, or undefined if validation succeeds\n */\n validateEdit?: (\n value: unknown,\n ) => Promise<string | undefined>;\n\n renderCell?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>,\n ) => React.ReactNode;\n\n /**\n * If provided, this will be used in the column header.\n * If both columnName and renderHeader are provided, renderHeader will take precedence in the table header.\n * columnName will still be used in other parts where the column name is displayed.\n *\n * If not provided,\n * for a property column, the property displayName will be used\n * for other columns, the id will be used.\n */\n columnName?: string;\n\n /**\n * If provided, this will be used to render the header component.\n * When both columnName and renderHeader are provided, renderHeader will take precedence in the table header.\n */\n renderHeader?: () => React.ReactNode;\n};\n\nexport type ExtractQueryParameters<\n TQueryDef extends QueryDefinition,\n> = TQueryDef[\"__DefinitionMetadata\"] extends QueryMetadata\n ? TQueryDef[\"__DefinitionMetadata\"][\"parameters\"]\n : never;\n\nexport interface PropertyColumnLocator<Q extends ObjectOrInterfaceDefinition> {\n type: \"property\";\n id: PropertyKeys<Q>;\n}\n\nexport interface FunctionColumnLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n /**\n * This is equivalent to workshop's function-backed columns.\n * The function needs to meet the specifications stated in https://www.palantir.com/docs/foundry/workshop/widgets-object-table/#function-backed-columns\n */\n type: \"function\";\n id: keyof FunctionColumns;\n queryDefinition: FunctionColumns[keyof FunctionColumns];\n\n /**\n * The function will be called with the current object set to get the input parameters for the function query.\n * @param objectSet - The current object set.\n * @returns - The function's input parameters including the object set.\n */\n getFunctionParams: (\n objectSet: ObjectSet<Q>,\n ) => ExtractQueryParameters<FunctionColumns[keyof FunctionColumns]>;\n\n /**\n * Function to generate keys for looking up results in the FunctionsMap.\n * @param object - The object instance\n * @returns - The key to use for looking up this object's result in the FunctionsMap\n */\n getKey: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => string;\n\n /**\n * Function to extract the cell value from the raw cell data returned by the function.\n * This is useful when functions return custom types with multiple properties.\n * @param cellData - The raw data returned by the function for this object\n * @returns - The value to display in the cell\n */\n getValue?: (cellData: unknown) => unknown;\n}\n\nexport interface RdpColumnLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n type: \"rdp\";\n id: keyof RDPs;\n creator: DerivedProperty.Creator<Q, RDPs[keyof RDPs]>;\n}\n\nexport interface CustomColumnLocator {\n type: \"custom\";\n id: string;\n}\n\nexport type ColumnDefinitionLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> =\n | PropertyColumnLocator<Q>\n | FunctionColumnLocator<Q, RDPs, FunctionColumns>\n | RdpColumnLocator<Q, RDPs>\n | CustomColumnLocator;\n\nexport interface ObjectTableProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n /**\n * The object or interface type of the object\n * If objectSet is not provided, objects will be fetched based on this type.\n */\n objectType: Q;\n\n /**\n * The set of objects to show in the table.\n * If provided and the objectType is not an interface, the table will use objectSet to fetch objects instead of fetching based on objectType.\n */\n objectSet?: ObjectSet<Q>;\n\n objectSetOptions?: ObjectSetOptions<Q>;\n\n /**\n * Ordered list of column definitions to show in the table\n *\n * If not provided, all of the properties of the object type will be shown in default order.\n */\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>;\n\n /**\n * Whether the table is filterable by the user.\n *\n * @default true\n */\n enableFiltering?: boolean;\n\n /**\n * The current where clause to filter the objects in the table.\n * If provided, the filter is controlled.\n */\n filter?: WhereClause<Q, RDPs>;\n\n /**\n * Called when the where clause is changed.\n * Required when filter is controlled.\n *\n * @param newWhere The new where clause\n */\n onFilterChanged?: (newWhere: WhereClause<Q, RDPs>) => void;\n\n /**\n * Whether the table is sortable by the user.\n *\n * @default true\n */\n enableOrdering?: boolean;\n\n /**\n * Whether columns can be pinned by the user.\n *\n * @default true\n */\n enableColumnPinning?: boolean;\n\n /**\n * Whether columns can be resized by the user.\n *\n * @default true\n */\n enableColumnResizing?: boolean;\n\n /**\n * Whether the column configuration dialog for column visibility and ordering is available to the user.\n *\n * @default true\n */\n enableColumnConfig?: boolean;\n\n /**\n * Controls the edit mode behavior of the table.\n * - \"always\": Editable cells are immediately in edit mode on row clicked.\n * - \"manual\": User can toggle edit mode on/off via the Edit Table button.\n *\n * @default \"manual\"\n */\n editMode?: \"always\" | \"manual\";\n\n /**\n * The default order by clause to sort the objects in the table.\n * If provided without orderBy prop, the sorting is uncontrolled.\n * If both orderBy and defaultOrderBy are provided, orderBy takes precedence.\n */\n defaultOrderBy?: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>;\n\n /**\n * The current order by clause to sort the objects in the table.\n * If provided, the sorting is controlled.\n * If both orderBy and defaultOrderBy are provided, orderBy takes precedence.\n */\n orderBy?: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>;\n\n /**\n * Called when the order by clause is changed.\n * Required when sorting is controlled.\n *\n * @param newOrderBy The new order by clause\n */\n onOrderByChanged?: (\n newOrderBy: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>,\n ) => void;\n\n /**\n * Called after the value of a cell is edited and committed by the user.\n *\n * @param info An object containing details about the cell that was edited,\n * including the rowId, columnId, new and old values, and the row data before the edit\n */\n onCellValueChanged?: (\n info: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >,\n ) => void;\n\n /**\n * If provided, the button Submit Edits will be shown in the table\n *\n * @param edits an array of edit info containing details about the edited cells\n * including the rowId, columnId, new and old values, and the row data before the edit\n * @return a promise that resolves to true if the edits were successfully submitted\n */\n onSubmitEdits?: (edits: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >[]) => Promise<boolean>;\n\n /**\n * Called when the column visibility or ordering changed.\n *\n * If provided, the table will allow the user to show/hide columns.\n *\n * @param newStates The columns sorted in their display order in the table and their visibility state.\n */\n onColumnVisibilityChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n isVisible: boolean;\n }>,\n ) => void;\n\n /**\n * Called when the pinned columns change.\n *\n * If provided, the table will allow the user to pin/unpin columns.\n *\n * @param newStates The new list of column pin states\n */\n onColumnsPinnedChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n pinned: \"left\" | \"right\" | \"none\";\n }>,\n ) => void;\n\n /**\n * Called when a column is resized.\n *\n * @param columnId The ID of the resized column\n * @param newWidth The new width of the column. When newWidth = null, the column size is reset.\n */\n onColumnResize?: (\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns,\n newWidth: number | null,\n ) => void;\n\n /**\n * Called when a row is clicked.\n *\n * @param object The object representing the clicked row\n */\n onRowClick?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => void;\n\n /**\n * Selection mode for the table rows.\n *\n * If multiple, a checkbox will be shown for each row to allow selecting multiple rows\n * as well as a top-level checkbox in the header to select all rows.\n *\n * @default \"none\"\n */\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n\n /**\n * The currently selected rows in the table.\n * If provided, the row selection is controlled.\n */\n selectedRows?: PrimaryKeyType<Q>[];\n\n /**\n * Indicates whether all rows are selected in controlled mode.\n * When true, the table will show all rows as selected regardless of the selectedRows array.\n */\n isAllSelected?: boolean;\n\n /**\n * Called when the row selection changes.\n * Required when row selection is controlled.\n *\n * @param selectedRowIds The primary keys of currently selected rows\n * @param isSelectAll Whether the change was triggered by a \"select all\" action. Defaults to false\n */\n onRowSelection?: (\n selectedRowIds: PrimaryKeyType<Q>[],\n isSelectAll?: boolean,\n ) => void;\n /**\n * If provided, will render this context menu when right clicking on a cell\n */\n renderCellContextMenu?: (\n row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n cellValue: unknown,\n ) => React.ReactNode;\n\n /**\n * The height of each row in pixels.\n *\n * @default 40\n */\n rowHeight?: number;\n\n className?: string;\n}\n\nexport interface ObjectSetOptions<\n Q extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ObjectTableApi.js","names":[],"sources":["ObjectTableApi.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 CompileTimeMetadata,\n DerivedProperty,\n ObjectOrInterfaceDefinition,\n ObjectSet,\n Osdk,\n PrimaryKeyType,\n PropertyKeys,\n QueryDefinition,\n SimplePropertyDef,\n WhereClause,\n} from \"@osdk/api\";\nimport type { QueryParameterType } from \"@osdk/client/unstable-do-not-use\";\nimport type * as React from \"react\";\nimport type { CellEditInfo } from \"./utils/types.js\";\n\nexport type ColumnDefinition<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> = {\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>;\n\n /**\n * @default true\n */\n isVisible?: boolean;\n\n /**\n * @default none\n */\n pinned?: \"left\" | \"right\" | \"none\";\n width?: number;\n minWidth?: number;\n maxWidth?: number;\n resizable?: boolean;\n orderable?: boolean;\n filterable?: boolean;\n editable?: boolean;\n\n /**\n * Additional function to validate the cell value during edit\n *\n * @param value the current cell value\n * @returns a promise that resolves to an error message string if validation fails, or undefined if validation succeeds\n */\n validateEdit?: (\n value: unknown,\n ) => Promise<string | undefined>;\n\n renderCell?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n locator: ColumnDefinitionLocator<Q, RDPs, FunctionColumns>,\n ) => React.ReactNode;\n\n /**\n * If provided, this will be used in the column header.\n * If both columnName and renderHeader are provided, renderHeader will take precedence in the table header.\n * columnName will still be used in other parts where the column name is displayed.\n *\n * If not provided,\n * for a property column, the property displayName will be used\n * for other columns, the id will be used.\n */\n columnName?: string;\n\n /**\n * If provided, this will be used to render the header component.\n * When both columnName and renderHeader are provided, renderHeader will take precedence in the table header.\n */\n renderHeader?: () => React.ReactNode;\n};\n\nexport type ExtractQueryParameters<\n Q extends QueryDefinition,\n> = CompileTimeMetadata<Q>[\"parameters\"] extends Record<string, never>\n ? undefined\n : QueryParameterType<CompileTimeMetadata<Q>[\"parameters\"]>;\n\nexport interface PropertyColumnLocator<Q extends ObjectOrInterfaceDefinition> {\n type: \"property\";\n id: PropertyKeys<Q>;\n}\n\nexport interface FunctionColumnLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n /**\n * This is equivalent to workshop's function-backed columns.\n * The function needs to meet the specifications stated in https://www.palantir.com/docs/foundry/workshop/widgets-object-table/#function-backed-columns\n */\n type: \"function\";\n id: keyof FunctionColumns;\n queryDefinition: FunctionColumns[keyof FunctionColumns];\n\n /**\n * The function will be called with the current object set to get the input parameters for the function query.\n * @param objectSet - The current object set.\n * @returns - The function's input parameters including the object set.\n */\n getFunctionParams: (\n objectSet: ObjectSet<Q, RDPs>,\n ) => ExtractQueryParameters<FunctionColumns[keyof FunctionColumns]>;\n\n /**\n * Function to generate keys for looking up results in the FunctionsMap.\n * @param object - The object instance\n * @returns - The key to use for looking up this object's result in the FunctionsMap\n */\n getKey: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => string;\n\n /**\n * Function to extract the cell value from the raw cell data returned by the function.\n * This is useful when functions return custom types with multiple properties.\n * @param cellData - The raw data returned by the function for this object\n * @returns - The value to display in the cell\n */\n getValue?: (cellData: unknown) => unknown;\n}\n\nexport interface RdpColumnLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n> {\n type: \"rdp\";\n id: keyof RDPs;\n creator: DerivedProperty.Creator<Q, RDPs[keyof RDPs]>;\n}\n\nexport interface CustomColumnLocator {\n type: \"custom\";\n id: string;\n}\n\nexport type ColumnDefinitionLocator<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> =\n | PropertyColumnLocator<Q>\n | FunctionColumnLocator<Q, RDPs, FunctionColumns>\n | RdpColumnLocator<Q, RDPs>\n | CustomColumnLocator;\n\nexport interface ObjectTableProps<\n Q extends ObjectOrInterfaceDefinition,\n RDPs extends Record<string, SimplePropertyDef> = Record<string, never>,\n FunctionColumns extends Record<string, QueryDefinition<{}>> = Record<\n string,\n never\n >,\n> {\n /**\n * The object or interface type of the object\n * If objectSet is not provided, objects will be fetched based on this type.\n */\n objectType: Q;\n\n /**\n * The set of objects to show in the table.\n * If provided and the objectType is not an interface, the table will use objectSet to fetch objects instead of fetching based on objectType.\n */\n objectSet?: ObjectSet<Q>;\n\n objectSetOptions?: ObjectSetOptions<Q>;\n\n /**\n * Ordered list of column definitions to show in the table\n *\n * If not provided, all of the properties of the object type will be shown in default order.\n */\n columnDefinitions?: Array<ColumnDefinition<Q, RDPs, FunctionColumns>>;\n\n /**\n * Whether the table is filterable by the user.\n *\n * @default true\n */\n enableFiltering?: boolean;\n\n /**\n * The current where clause to filter the objects in the table.\n * If provided, the filter is controlled.\n */\n filter?: WhereClause<Q, RDPs>;\n\n /**\n * Called when the where clause is changed.\n * Required when filter is controlled.\n *\n * @param newWhere The new where clause\n */\n onFilterChanged?: (newWhere: WhereClause<Q, RDPs>) => void;\n\n /**\n * Whether the table is sortable by the user.\n *\n * @default true\n */\n enableOrdering?: boolean;\n\n /**\n * Whether columns can be pinned by the user.\n *\n * @default true\n */\n enableColumnPinning?: boolean;\n\n /**\n * Whether columns can be resized by the user.\n *\n * @default true\n */\n enableColumnResizing?: boolean;\n\n /**\n * Whether the column configuration dialog for column visibility and ordering is available to the user.\n *\n * @default true\n */\n enableColumnConfig?: boolean;\n\n /**\n * Controls the edit mode behavior of the table.\n * - \"always\": Editable cells are immediately in edit mode on row clicked.\n * - \"manual\": User can toggle edit mode on/off via the Edit Table button.\n *\n * @default \"manual\"\n */\n editMode?: \"always\" | \"manual\";\n\n /**\n * The default order by clause to sort the objects in the table.\n * If provided without orderBy prop, the sorting is uncontrolled.\n * If both orderBy and defaultOrderBy are provided, orderBy takes precedence.\n */\n defaultOrderBy?: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>;\n\n /**\n * The current order by clause to sort the objects in the table.\n * If provided, the sorting is controlled.\n * If both orderBy and defaultOrderBy are provided, orderBy takes precedence.\n */\n orderBy?: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>;\n\n /**\n * Called when the order by clause is changed.\n * Required when sorting is controlled.\n *\n * @param newOrderBy The new order by clause\n */\n onOrderByChanged?: (\n newOrderBy: Array<{\n property: PropertyKeys<Q>;\n direction: \"asc\" | \"desc\";\n }>,\n ) => void;\n\n /**\n * Called after the value of a cell is edited and committed by the user.\n *\n * @param info An object containing details about the cell that was edited,\n * including the rowId, columnId, new and old values, and the row data before the edit\n */\n onCellValueChanged?: (\n info: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >,\n ) => void;\n\n /**\n * If provided, the button Submit Edits will be shown in the table\n *\n * @param edits an array of edit info containing details about the edited cells\n * including the rowId, columnId, new and old values, and the row data before the edit\n * @return a promise that resolves to true if the edits were successfully submitted\n */\n onSubmitEdits?: (edits: CellEditInfo<\n Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n unknown\n >[]) => Promise<boolean>;\n\n /**\n * Called when the column visibility or ordering changed.\n *\n * If provided, the table will allow the user to show/hide columns.\n *\n * @param newStates The columns sorted in their display order in the table and their visibility state.\n */\n onColumnVisibilityChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n isVisible: boolean;\n }>,\n ) => void;\n\n /**\n * Called when the pinned columns change.\n *\n * If provided, the table will allow the user to pin/unpin columns.\n *\n * @param newStates The new list of column pin states\n */\n onColumnsPinnedChanged?: (\n newStates: Array<{\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns;\n pinned: \"left\" | \"right\" | \"none\";\n }>,\n ) => void;\n\n /**\n * Called when a column is resized.\n *\n * @param columnId The ID of the resized column\n * @param newWidth The new width of the column. When newWidth = null, the column size is reset.\n */\n onColumnResize?: (\n columnId: PropertyKeys<Q> | keyof RDPs | keyof FunctionColumns,\n newWidth: number | null,\n ) => void;\n\n /**\n * Called when a row is clicked.\n *\n * @param object The object representing the clicked row\n */\n onRowClick?: (\n object: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n ) => void;\n\n /**\n * Selection mode for the table rows.\n *\n * If multiple, a checkbox will be shown for each row to allow selecting multiple rows\n * as well as a top-level checkbox in the header to select all rows.\n *\n * @default \"none\"\n */\n selectionMode?: \"single\" | \"multiple\" | \"none\";\n\n /**\n * The currently selected rows in the table.\n * If provided, the row selection is controlled.\n */\n selectedRows?: PrimaryKeyType<Q>[];\n\n /**\n * Indicates whether all rows are selected in controlled mode.\n * When true, the table will show all rows as selected regardless of the selectedRows array.\n */\n isAllSelected?: boolean;\n\n /**\n * Called when the row selection changes.\n * Required when row selection is controlled.\n *\n * @param selectedRowIds The primary keys of currently selected rows\n * @param isSelectAll Whether the change was triggered by a \"select all\" action. Defaults to false\n */\n onRowSelection?: (\n selectedRowIds: PrimaryKeyType<Q>[],\n isSelectAll?: boolean,\n ) => void;\n /**\n * If provided, will render this context menu when right clicking on a cell\n */\n renderCellContextMenu?: (\n row: Osdk.Instance<Q, \"$allBaseProperties\", PropertyKeys<Q>, RDPs>,\n cellValue: unknown,\n ) => React.ReactNode;\n\n /**\n * The height of each row in pixels.\n *\n * @default 40\n */\n rowHeight?: number;\n\n className?: string;\n}\n\nexport interface ObjectSetOptions<\n Q extends ObjectOrInterfaceDefinition,\n> {\n /**\n * Object sets to union with\n */\n union?: ObjectSet<Q>[];\n\n /**\n * Object sets to intersect with\n */\n intersect?: ObjectSet<Q>[];\n\n /**\n * Object sets to subtract from\n */\n subtract?: ObjectSet<Q>[];\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -14,58 +14,75 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
17
|
+
import { useOsdkFunctions } from "@osdk/react/unstable-do-not-use";
|
|
18
|
+
import { useMemo } from "react";
|
|
19
19
|
import { createAsyncCellData } from "../utils/AsyncCellData.js";
|
|
20
20
|
export function useFunctionColumnsData(objectSet, objects, columnDefinitions) {
|
|
21
|
-
const client = useOsdkClient();
|
|
22
|
-
const [data, setData] = useState({});
|
|
23
|
-
const abortControllerRef = useRef(null);
|
|
24
|
-
|
|
25
21
|
// Function column configurations grouped by unique query definition
|
|
26
22
|
const functionColumnConfigs = useMemo(() => getFunctionColumnConfigs(columnDefinitions), [columnDefinitions]);
|
|
27
23
|
const stableObjects = useStableObjects(objects);
|
|
28
24
|
|
|
25
|
+
// TODO: replace with useDeepEqual when it's added
|
|
29
26
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
27
|
const stableObjectSet = useMemo(() => objectSet, [JSON.stringify(objectSet)]);
|
|
31
|
-
|
|
32
|
-
if (!stableObjects || stableObjects.length === 0 || functionColumnConfigs.length === 0 || !stableObjectSet) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
28
|
+
const disabled = !stableObjectSet || !stableObjects?.length || functionColumnConfigs.length === 0;
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
// Prepare queries for useOsdkFunctions
|
|
31
|
+
const queries = useMemo(() => {
|
|
32
|
+
if (disabled) {
|
|
33
|
+
return [];
|
|
39
34
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return;
|
|
35
|
+
return functionColumnConfigs.map(config => ({
|
|
36
|
+
queryDefinition: config.queryDefinition,
|
|
37
|
+
options: {
|
|
38
|
+
params: config.getParams(stableObjectSet)
|
|
45
39
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
40
|
+
}));
|
|
41
|
+
}, [disabled, functionColumnConfigs, stableObjectSet]);
|
|
42
|
+
const results = useOsdkFunctions({
|
|
43
|
+
queries,
|
|
44
|
+
enabled: !disabled
|
|
45
|
+
});
|
|
46
|
+
const data = useMemo(() => {
|
|
47
|
+
const columnData = {};
|
|
48
|
+
if (disabled || !stableObjects) return columnData;
|
|
49
|
+
results.forEach((result, index) => {
|
|
50
|
+
const config = functionColumnConfigs[index];
|
|
51
|
+
if (!config) return;
|
|
52
|
+
const functionsMap = result.data;
|
|
53
|
+
config.columnIds.forEach(({
|
|
54
|
+
columnId,
|
|
55
|
+
getValue,
|
|
56
|
+
getKey: columnGetKey
|
|
57
|
+
}) => {
|
|
58
|
+
if (!columnData[columnId]) {
|
|
59
|
+
columnData[columnId] = {};
|
|
61
60
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
stableObjects.forEach(obj => {
|
|
62
|
+
const key = String(obj.$primaryKey);
|
|
63
|
+
if (result.isLoading) {
|
|
64
|
+
columnData[columnId][key] = createAsyncCellData({
|
|
65
|
+
isLoading: true
|
|
66
|
+
});
|
|
67
|
+
} else if (result.error) {
|
|
68
|
+
columnData[columnId][key] = createAsyncCellData({
|
|
69
|
+
error: result.error,
|
|
70
|
+
isLoading: false
|
|
71
|
+
});
|
|
72
|
+
} else if (functionsMap) {
|
|
73
|
+
const customKey = columnGetKey(obj);
|
|
74
|
+
const rawData = functionsMap[customKey];
|
|
75
|
+
const cellData = getValue ? getValue(rawData) : rawData;
|
|
76
|
+
columnData[columnId][key] = createAsyncCellData({
|
|
77
|
+
data: cellData,
|
|
78
|
+
isLoading: false
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
return columnData;
|
|
85
|
+
}, [results, functionColumnConfigs, stableObjects, disabled]);
|
|
69
86
|
return data;
|
|
70
87
|
}
|
|
71
88
|
function getFunctionColumnConfigs(columnDefinitions) {
|
|
@@ -115,156 +132,4 @@ const useStableObjects = objects => {
|
|
|
115
132
|
return String(a.$primaryKey).localeCompare(String(b.$primaryKey));
|
|
116
133
|
}))]);
|
|
117
134
|
};
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Generator that yields query results as they complete
|
|
121
|
-
*/
|
|
122
|
-
async function* executeQueriesGenerator(functionColumnConfigs, objectSet, client, signal) {
|
|
123
|
-
// Start all queries in parallel
|
|
124
|
-
const queryPromises = functionColumnConfigs.map(config => createQueryPromise(config, objectSet, client, signal));
|
|
125
|
-
const pendingPromises = [...queryPromises];
|
|
126
|
-
|
|
127
|
-
// Yield results as they complete using Promise.race
|
|
128
|
-
while (pendingPromises.length > 0) {
|
|
129
|
-
const result = await Promise.race(pendingPromises.map((promise, index) => promise.then(result => ({
|
|
130
|
-
result,
|
|
131
|
-
index
|
|
132
|
-
}))));
|
|
133
|
-
yield result.result;
|
|
134
|
-
|
|
135
|
-
// Remove the completed promise from the pending list
|
|
136
|
-
void pendingPromises.splice(result.index, 1);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Create a promise that executes a function column query
|
|
142
|
-
*/
|
|
143
|
-
function createQueryPromise(config, objectSet, client, signal) {
|
|
144
|
-
return new Promise(resolve => {
|
|
145
|
-
if (signal?.aborted) {
|
|
146
|
-
resolve({
|
|
147
|
-
config,
|
|
148
|
-
result: null,
|
|
149
|
-
error: null,
|
|
150
|
-
aborted: true
|
|
151
|
-
});
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
const params = config.getParams(objectSet);
|
|
155
|
-
client(config.queryDefinition).executeFunction(params).then(result => {
|
|
156
|
-
// Check if aborted during execution
|
|
157
|
-
if (signal?.aborted) {
|
|
158
|
-
resolve({
|
|
159
|
-
config,
|
|
160
|
-
result: null,
|
|
161
|
-
error: null,
|
|
162
|
-
aborted: true
|
|
163
|
-
});
|
|
164
|
-
} else {
|
|
165
|
-
resolve({
|
|
166
|
-
config,
|
|
167
|
-
result,
|
|
168
|
-
error: null
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}).catch(error => {
|
|
172
|
-
// Check if aborted during error handling
|
|
173
|
-
if (signal?.aborted) {
|
|
174
|
-
resolve({
|
|
175
|
-
config,
|
|
176
|
-
result: null,
|
|
177
|
-
error: null,
|
|
178
|
-
aborted: true
|
|
179
|
-
});
|
|
180
|
-
} else {
|
|
181
|
-
resolve({
|
|
182
|
-
config,
|
|
183
|
-
result: null,
|
|
184
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Initialize function column data with isLoading state for all columns and objects
|
|
193
|
-
*/
|
|
194
|
-
function initializeFunctionColumnData(functionColumnConfigs, objects, setData) {
|
|
195
|
-
setData(prev => {
|
|
196
|
-
const newData = {
|
|
197
|
-
...prev
|
|
198
|
-
};
|
|
199
|
-
functionColumnConfigs.forEach(config => {
|
|
200
|
-
config.columnIds.forEach(({
|
|
201
|
-
columnId
|
|
202
|
-
}) => {
|
|
203
|
-
// Initialize column if it doesn't exist
|
|
204
|
-
if (!newData[columnId]) {
|
|
205
|
-
newData[columnId] = {};
|
|
206
|
-
}
|
|
207
|
-
objects.forEach(obj => {
|
|
208
|
-
const key = String(obj.$primaryKey);
|
|
209
|
-
// Only set isLoading state if this object's data doesn't already exist
|
|
210
|
-
if (!newData[columnId][key]) {
|
|
211
|
-
newData[columnId][key] = createAsyncCellData({
|
|
212
|
-
isLoading: true
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
return newData;
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
function processQueryResult(config, result, error, objects, setData) {
|
|
222
|
-
// Batch all updates into a single setState call
|
|
223
|
-
setData(prev => {
|
|
224
|
-
const newData = {
|
|
225
|
-
...prev
|
|
226
|
-
};
|
|
227
|
-
if (error) {
|
|
228
|
-
// Set error for all objects in all columns that use this query
|
|
229
|
-
config.columnIds.forEach(({
|
|
230
|
-
columnId
|
|
231
|
-
}) => {
|
|
232
|
-
if (!newData[columnId]) {
|
|
233
|
-
newData[columnId] = {};
|
|
234
|
-
}
|
|
235
|
-
objects.forEach(obj => {
|
|
236
|
-
const key = String(obj.$primaryKey);
|
|
237
|
-
newData[columnId][key] = createAsyncCellData({
|
|
238
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
239
|
-
isLoading: false
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
} else if (result) {
|
|
244
|
-
// Process the FunctionsMap result
|
|
245
|
-
objects.forEach(obj => {
|
|
246
|
-
const key = String(obj.$primaryKey);
|
|
247
|
-
|
|
248
|
-
// Process each column that uses this query result
|
|
249
|
-
config.columnIds.forEach(({
|
|
250
|
-
columnId,
|
|
251
|
-
getValue,
|
|
252
|
-
getKey: columnGetKey
|
|
253
|
-
}) => {
|
|
254
|
-
if (!newData[columnId]) {
|
|
255
|
-
newData[columnId] = {};
|
|
256
|
-
}
|
|
257
|
-
const customKey = columnGetKey(obj);
|
|
258
|
-
const rawData = result[customKey];
|
|
259
|
-
const cellData = getValue ? getValue(rawData) : rawData;
|
|
260
|
-
newData[columnId][key] = createAsyncCellData({
|
|
261
|
-
data: cellData,
|
|
262
|
-
isLoading: false
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
return newData;
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
135
|
//# sourceMappingURL=useFunctionColumnsData.js.map
|