@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.
Files changed (175) hide show
  1. package/AGENTS.md +4 -0
  2. package/CHANGELOG.md +38 -0
  3. package/build/browser/action-form/ActionForm.js +15 -11
  4. package/build/browser/action-form/ActionForm.js.map +1 -1
  5. package/build/browser/action-form/FormFieldApi.js.map +1 -1
  6. package/build/browser/action-form/fields/{TextInputField.module.css → BaseInput.module.css} +2 -2
  7. package/build/browser/action-form/fields/BaseInput.module.css.js +6 -0
  8. package/build/browser/action-form/fields/CustomField.js +30 -0
  9. package/build/browser/action-form/fields/CustomField.js.map +1 -0
  10. package/build/browser/action-form/fields/FormFieldRenderer.js +26 -16
  11. package/build/browser/action-form/fields/FormFieldRenderer.js.map +1 -1
  12. package/build/browser/action-form/fields/RadioButtonsField.js +57 -0
  13. package/build/browser/action-form/fields/RadioButtonsField.js.map +1 -0
  14. package/build/browser/action-form/fields/RadioButtonsField.module.css +83 -0
  15. package/build/browser/action-form/fields/RadioButtonsField.module.css.js +10 -0
  16. package/build/browser/action-form/fields/TextAreaField.js +50 -0
  17. package/build/browser/action-form/fields/TextAreaField.js.map +1 -0
  18. package/build/browser/action-form/fields/TextInputField.js +3 -3
  19. package/build/browser/action-form/fields/TextInputField.js.map +1 -1
  20. package/build/browser/action-form/utils/getDefaultFieldDefinitions.js +97 -10
  21. package/build/browser/action-form/utils/getDefaultFieldDefinitions.js.map +1 -1
  22. package/build/browser/base-components/dialog/Dialog.js +4 -2
  23. package/build/browser/base-components/dialog/Dialog.js.map +1 -1
  24. package/build/browser/object-table/ObjectTableApi.js.map +1 -1
  25. package/build/browser/object-table/hooks/useFunctionColumnsData.js +57 -192
  26. package/build/browser/object-table/hooks/useFunctionColumnsData.js.map +1 -1
  27. package/build/browser/pdf-viewer/PdfViewer.js +49 -8
  28. package/build/browser/pdf-viewer/PdfViewer.js.map +1 -1
  29. package/build/browser/pdf-viewer/PdfViewerContext.js +108 -0
  30. package/build/browser/pdf-viewer/PdfViewerContext.js.map +1 -0
  31. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js +85 -18
  32. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
  33. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.module.css +18 -0
  34. package/build/browser/pdf-viewer/components/PdfViewerAnnotationLayer.module.css.js +1 -0
  35. package/build/browser/pdf-viewer/components/PdfViewerContent.js +15 -3
  36. package/build/browser/pdf-viewer/components/PdfViewerContent.js.map +1 -1
  37. package/build/browser/pdf-viewer/components/PdfViewerOutlineSidebar.module.css +1 -1
  38. package/build/browser/pdf-viewer/components/PdfViewerSidebar.module.css +1 -1
  39. package/build/browser/pdf-viewer/components/PdfViewerSidebarHeader.module.css +1 -1
  40. package/build/browser/pdf-viewer/components/PdfViewerToolbar.js +29 -2
  41. package/build/browser/pdf-viewer/components/PdfViewerToolbar.js.map +1 -1
  42. package/build/browser/pdf-viewer/components/PdfViewerToolbar.module.css +5 -0
  43. package/build/browser/pdf-viewer/components/PdfViewerToolbar.module.css.js +1 -0
  44. package/build/browser/pdf-viewer/constants.js +2 -1
  45. package/build/browser/pdf-viewer/constants.js.map +1 -1
  46. package/build/browser/pdf-viewer/hooks/usePdfAnnotationsByPage.js +30 -0
  47. package/build/browser/pdf-viewer/hooks/usePdfAnnotationsByPage.js.map +1 -0
  48. package/build/browser/pdf-viewer/hooks/usePdfFormFields.js +341 -0
  49. package/build/browser/pdf-viewer/hooks/usePdfFormFields.js.map +1 -0
  50. package/build/browser/pdf-viewer/hooks/usePdfHighlightMode.js +227 -0
  51. package/build/browser/pdf-viewer/hooks/usePdfHighlightMode.js.map +1 -0
  52. package/build/browser/pdf-viewer/hooks/usePdfViewer.js +16 -10
  53. package/build/browser/pdf-viewer/hooks/usePdfViewer.js.map +1 -1
  54. package/build/browser/pdf-viewer/hooks/usePdfViewerCore.js +3 -3
  55. package/build/browser/pdf-viewer/hooks/usePdfViewerCore.js.map +1 -1
  56. package/build/browser/pdf-viewer/hooks/usePdfViewerSearch.js +3 -3
  57. package/build/browser/pdf-viewer/hooks/usePdfViewerSearch.js.map +1 -1
  58. package/build/browser/pdf-viewer/hooks/usePdfViewerState.js +3 -3
  59. package/build/browser/pdf-viewer/hooks/usePdfViewerState.js.map +1 -1
  60. package/build/browser/pdf-viewer/types.js.map +1 -1
  61. package/build/browser/public/experimental.js +5 -0
  62. package/build/browser/public/experimental.js.map +1 -1
  63. package/build/browser/styles.css +144 -35
  64. package/build/cjs/{chunk-GT6IV6LV.cjs → chunk-MRRRZN44.cjs} +6 -4
  65. package/build/cjs/chunk-MRRRZN44.cjs.map +1 -0
  66. package/build/cjs/public/experimental.cjs +1981 -1314
  67. package/build/cjs/public/experimental.cjs.map +1 -1
  68. package/build/cjs/public/experimental.css +82 -5
  69. package/build/cjs/public/experimental.css.map +1 -1
  70. package/build/cjs/public/experimental.d.cts +267 -26
  71. package/build/cjs/public/primitives.cjs +5 -5
  72. package/build/cjs/public/primitives.d.cts +3 -2
  73. package/build/esm/action-form/ActionForm.js +15 -11
  74. package/build/esm/action-form/ActionForm.js.map +1 -1
  75. package/build/esm/action-form/FormFieldApi.js.map +1 -1
  76. package/build/esm/action-form/fields/{TextInputField.module.css → BaseInput.module.css} +2 -2
  77. package/build/esm/action-form/fields/CustomField.js +30 -0
  78. package/build/esm/action-form/fields/CustomField.js.map +1 -0
  79. package/build/esm/action-form/fields/FormFieldRenderer.js +26 -16
  80. package/build/esm/action-form/fields/FormFieldRenderer.js.map +1 -1
  81. package/build/esm/action-form/fields/RadioButtonsField.js +57 -0
  82. package/build/esm/action-form/fields/RadioButtonsField.js.map +1 -0
  83. package/build/esm/action-form/fields/RadioButtonsField.module.css +83 -0
  84. package/build/esm/action-form/fields/TextAreaField.js +50 -0
  85. package/build/esm/action-form/fields/TextAreaField.js.map +1 -0
  86. package/build/esm/action-form/fields/TextInputField.js +3 -3
  87. package/build/esm/action-form/fields/TextInputField.js.map +1 -1
  88. package/build/esm/action-form/utils/getDefaultFieldDefinitions.js +97 -10
  89. package/build/esm/action-form/utils/getDefaultFieldDefinitions.js.map +1 -1
  90. package/build/esm/base-components/dialog/Dialog.js +4 -2
  91. package/build/esm/base-components/dialog/Dialog.js.map +1 -1
  92. package/build/esm/object-table/ObjectTableApi.js.map +1 -1
  93. package/build/esm/object-table/hooks/useFunctionColumnsData.js +57 -192
  94. package/build/esm/object-table/hooks/useFunctionColumnsData.js.map +1 -1
  95. package/build/esm/pdf-viewer/PdfViewer.js +49 -8
  96. package/build/esm/pdf-viewer/PdfViewer.js.map +1 -1
  97. package/build/esm/pdf-viewer/PdfViewerContext.js +108 -0
  98. package/build/esm/pdf-viewer/PdfViewerContext.js.map +1 -0
  99. package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js +85 -18
  100. package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.js.map +1 -1
  101. package/build/esm/pdf-viewer/components/PdfViewerAnnotationLayer.module.css +18 -0
  102. package/build/esm/pdf-viewer/components/PdfViewerContent.js +15 -3
  103. package/build/esm/pdf-viewer/components/PdfViewerContent.js.map +1 -1
  104. package/build/esm/pdf-viewer/components/PdfViewerOutlineSidebar.module.css +1 -1
  105. package/build/esm/pdf-viewer/components/PdfViewerSidebar.module.css +1 -1
  106. package/build/esm/pdf-viewer/components/PdfViewerSidebarHeader.module.css +1 -1
  107. package/build/esm/pdf-viewer/components/PdfViewerToolbar.js +29 -2
  108. package/build/esm/pdf-viewer/components/PdfViewerToolbar.js.map +1 -1
  109. package/build/esm/pdf-viewer/components/PdfViewerToolbar.module.css +5 -0
  110. package/build/esm/pdf-viewer/constants.js +2 -1
  111. package/build/esm/pdf-viewer/constants.js.map +1 -1
  112. package/build/esm/pdf-viewer/hooks/usePdfAnnotationsByPage.js +30 -0
  113. package/build/esm/pdf-viewer/hooks/usePdfAnnotationsByPage.js.map +1 -0
  114. package/build/esm/pdf-viewer/hooks/usePdfFormFields.js +341 -0
  115. package/build/esm/pdf-viewer/hooks/usePdfFormFields.js.map +1 -0
  116. package/build/esm/pdf-viewer/hooks/usePdfHighlightMode.js +227 -0
  117. package/build/esm/pdf-viewer/hooks/usePdfHighlightMode.js.map +1 -0
  118. package/build/esm/pdf-viewer/hooks/usePdfViewer.js +16 -10
  119. package/build/esm/pdf-viewer/hooks/usePdfViewer.js.map +1 -1
  120. package/build/esm/pdf-viewer/hooks/usePdfViewerCore.js +3 -3
  121. package/build/esm/pdf-viewer/hooks/usePdfViewerCore.js.map +1 -1
  122. package/build/esm/pdf-viewer/hooks/usePdfViewerSearch.js +3 -3
  123. package/build/esm/pdf-viewer/hooks/usePdfViewerSearch.js.map +1 -1
  124. package/build/esm/pdf-viewer/hooks/usePdfViewerState.js +3 -3
  125. package/build/esm/pdf-viewer/hooks/usePdfViewerState.js.map +1 -1
  126. package/build/esm/pdf-viewer/types.js.map +1 -1
  127. package/build/esm/public/experimental.js +5 -0
  128. package/build/esm/public/experimental.js.map +1 -1
  129. package/build/types/action-form/FormFieldApi.d.ts +11 -5
  130. package/build/types/action-form/FormFieldApi.d.ts.map +1 -1
  131. package/build/types/action-form/fields/CustomField.d.ts +9 -0
  132. package/build/types/action-form/fields/CustomField.d.ts.map +1 -0
  133. package/build/types/action-form/fields/FormFieldRenderer.d.ts.map +1 -1
  134. package/build/types/action-form/fields/RadioButtonsField.d.ts +3 -0
  135. package/build/types/action-form/fields/RadioButtonsField.d.ts.map +1 -0
  136. package/build/types/action-form/fields/TextAreaField.d.ts +3 -0
  137. package/build/types/action-form/fields/TextAreaField.d.ts.map +1 -0
  138. package/build/types/action-form/utils/getDefaultFieldDefinitions.d.ts +7 -4
  139. package/build/types/action-form/utils/getDefaultFieldDefinitions.d.ts.map +1 -1
  140. package/build/types/base-components/dialog/Dialog.d.ts +3 -2
  141. package/build/types/base-components/dialog/Dialog.d.ts.map +1 -1
  142. package/build/types/object-table/ObjectTableApi.d.ts +4 -3
  143. package/build/types/object-table/ObjectTableApi.d.ts.map +1 -1
  144. package/build/types/object-table/hooks/useFunctionColumnsData.d.ts.map +1 -1
  145. package/build/types/pdf-viewer/PdfViewer.d.ts +2 -2
  146. package/build/types/pdf-viewer/PdfViewer.d.ts.map +1 -1
  147. package/build/types/pdf-viewer/PdfViewerContext.d.ts +64 -0
  148. package/build/types/pdf-viewer/PdfViewerContext.d.ts.map +1 -0
  149. package/build/types/pdf-viewer/components/PdfViewerAnnotationLayer.d.ts.map +1 -1
  150. package/build/types/pdf-viewer/components/PdfViewerContent.d.ts +8 -4
  151. package/build/types/pdf-viewer/components/PdfViewerContent.d.ts.map +1 -1
  152. package/build/types/pdf-viewer/components/PdfViewerToolbar.d.ts +6 -1
  153. package/build/types/pdf-viewer/components/PdfViewerToolbar.d.ts.map +1 -1
  154. package/build/types/pdf-viewer/constants.d.ts +1 -1
  155. package/build/types/pdf-viewer/constants.d.ts.map +1 -1
  156. package/build/types/pdf-viewer/hooks/usePdfAnnotationsByPage.d.ts +5 -0
  157. package/build/types/pdf-viewer/hooks/usePdfAnnotationsByPage.d.ts.map +1 -0
  158. package/build/types/pdf-viewer/hooks/usePdfFormFields.d.ts +24 -0
  159. package/build/types/pdf-viewer/hooks/usePdfFormFields.d.ts.map +1 -0
  160. package/build/types/pdf-viewer/hooks/usePdfHighlightMode.d.ts +36 -0
  161. package/build/types/pdf-viewer/hooks/usePdfHighlightMode.d.ts.map +1 -0
  162. package/build/types/pdf-viewer/hooks/usePdfViewer.d.ts.map +1 -1
  163. package/build/types/pdf-viewer/types.d.ts +137 -13
  164. package/build/types/pdf-viewer/types.d.ts.map +1 -1
  165. package/build/types/public/experimental.d.ts +6 -1
  166. package/build/types/public/experimental.d.ts.map +1 -1
  167. package/package.json +6 -6
  168. package/build/browser/action-form/fields/TextInputField.module.css.js +0 -6
  169. package/build/browser/action-form/utils/getDefaultFieldComponent.js +0 -56
  170. package/build/browser/action-form/utils/getDefaultFieldComponent.js.map +0 -1
  171. package/build/cjs/chunk-GT6IV6LV.cjs.map +0 -1
  172. package/build/esm/action-form/utils/getDefaultFieldComponent.js +0 -56
  173. package/build/esm/action-form/utils/getDefaultFieldComponent.js.map +0 -1
  174. package/build/types/action-form/utils/getDefaultFieldComponent.d.ts +0 -6
  175. package/build/types/action-form/utils/getDefaultFieldComponent.d.ts.map +0 -1
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2025 Palantir Technologies, Inc. All rights reserved.
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 "./TextInputField.module.css.js";
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.osdkTextInput,
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","osdkTextInput","type","onValueChange"],"sources":["TextInputField.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 { Input } from \"@base-ui/react/input\";\nimport React from \"react\";\nimport type { TextInputFieldProps } from \"../FormFieldApi.js\";\nimport styles from \"./TextInputField.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.osdkTextInput}\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,6BAA6B;AAEhD,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":[]}
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 { getDefaultFieldComponent } from "./getDefaultFieldComponent.js";
18
-
17
+ import { assertUnreachable } from "../../shared/assertUnreachable.js";
19
18
  /**
20
- * Derives default field definitions from fetched ActionMetadata.
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
- // Object.entries erases key types; assertion bridges runtime string to FieldKey<Q>
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
- // getDefaultFieldComponent returns FieldComponent (full union); TS can't verify
28
- // it matches ValidFormFieldForPropertyType for a deferred generic Q
29
- fieldComponent: getDefaultFieldComponent(param.type),
30
- isRequired: !param.nullable
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":["getDefaultFieldComponent","getDefaultFieldDefinitions","metadata","Object","entries","parameters","map","key","param","fieldKey","label","fieldComponent","type","isRequired","nullable"],"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 { ActionDefinition, ActionMetadata } from \"@osdk/api\";\nimport type {\n ActionParameters,\n FieldDescriptorType,\n FieldKey,\n FormFieldDefinition,\n ValidFormFieldForPropertyType,\n} from \"../FormFieldApi.js\";\nimport { getDefaultFieldComponent } from \"./getDefaultFieldComponent.js\";\n\n/**\n * Derives default field definitions from fetched ActionMetadata.\n */\nexport function getDefaultFieldDefinitions<\n Q extends ActionDefinition<unknown>,\n>(metadata: ActionMetadata): ReadonlyArray<FormFieldDefinition<Q>> {\n return Object.entries(metadata.parameters).map(([key, param]) => ({\n // Object.entries erases key types; assertion bridges runtime string to FieldKey<Q>\n fieldKey: key as FieldKey<Q>,\n label: key,\n // getDefaultFieldComponent returns FieldComponent (full union); TS can't verify\n // it matches ValidFormFieldForPropertyType for a deferred generic Q\n fieldComponent: getDefaultFieldComponent(\n param.type,\n ) as ValidFormFieldForPropertyType<\n FieldDescriptorType<Q, keyof ActionParameters<Q>>\n >,\n isRequired: !param.nullable,\n }));\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAUA,SAASA,wBAAwB,QAAQ,+BAA+B;;AAExE;AACA;AACA;AACA,OAAO,SAASC,0BAA0BA,CAExCC,QAAwB,EAAyC;EACjE,OAAOC,MAAM,CAACC,OAAO,CAACF,QAAQ,CAACG,UAAU,CAAC,CAACC,GAAG,CAAC,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,MAAM;IAChE;IACAC,QAAQ,EAAEF,GAAkB;IAC5BG,KAAK,EAAEH,GAAG;IACV;IACA;IACAI,cAAc,EAAEX,wBAAwB,CACtCQ,KAAK,CAACI,IACR,CAEC;IACDC,UAAU,EAAE,CAACL,KAAK,CAACM;EACrB,CAAC,CAAC,CAAC;AACL","ignoreList":[]}
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 open={isOpen} onOpenChange={onOpenChange}>\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;AAWxC,OAAO,SAASL,MAAMA,CAAC;EACrBM,MAAM;EACNC,YAAY;EACZC,KAAK;EACLC,QAAQ;EACRC,MAAM;EACNC;AACW,CAAC,EAAsB;EAClC,oBACEP,KAAA,CAAAQ,aAAA,CAACX,YAAY,CAACY,IAAI;IAACC,IAAI,EAAER,MAAO;IAACC,YAAY,EAAEA;EAAa,gBAC1DH,KAAA,CAAAQ,aAAA,CAACX,YAAY,CAACc,MAAM,qBAClBX,KAAA,CAAAQ,aAAA,CAACX,YAAY,CAACe,QAAQ;IAACL,SAAS,EAAEN,MAAM,CAACY;EAAS,CAAE,CAAC,eACrDb,KAAA,CAAAQ,aAAA,CAACX,YAAY,CAACiB,KAAK;IACjBP,SAAS,EAAER,UAAU,CACnBE,MAAM,CAACc,KAAK,EACZR,SACF;EAAE,gBAEFP,KAAA,CAAAQ,aAAA;IAAKD,SAAS,EAAEN,MAAM,CAACe;EAAO,gBAC5BhB,KAAA,CAAAQ,aAAA,CAACX,YAAY,CAACoB,KAAK;IAACV,SAAS,EAAEN,MAAM,CAACG;EAAM,GACzCA,KACiB,CAAC,eACrBJ,KAAA,CAAAQ,aAAA,CAACX,YAAY,CAACqB,KAAK;IACjBX,SAAS,EAAEN,MAAM,CAACkB,WAAY;IAC9B,cAAW;EAAc,gBAEzBnB,KAAA,CAAAQ,aAAA,CAACV,KAAK;IAACS,SAAS,EAAEN,MAAM,CAACmB;EAAU,CAAE,CACnB,CACjB,CAAC,eACNpB,KAAA,CAAAQ,aAAA;IAAKD,SAAS,EAAEN,MAAM,CAACoB;EAAK,GAAEhB,QAAc,CAAC,EAC5CC,MAAM,IAAI,IAAI,iBAAIN,KAAA,CAAAQ,aAAA;IAAKD,SAAS,EAAEN,MAAM,CAACK;EAAO,GAAEA,MAAY,CAC7C,CACD,CACJ,CAAC;AAExB","ignoreList":[]}
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 { useOsdkClient } from "@osdk/react";
18
- import { useEffect, useMemo, useRef, useState } from "react";
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
- useEffect(() => {
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
- // Cancel previous requests
37
- if (abortControllerRef.current) {
38
- abortControllerRef.current.abort();
30
+ // Prepare queries for useOsdkFunctions
31
+ const queries = useMemo(() => {
32
+ if (disabled) {
33
+ return [];
39
34
  }
40
- const abortController = new AbortController();
41
- abortControllerRef.current = abortController;
42
- void (async () => {
43
- if (!stableObjectSet) {
44
- return;
35
+ return functionColumnConfigs.map(config => ({
36
+ queryDefinition: config.queryDefinition,
37
+ options: {
38
+ params: config.getParams(stableObjectSet)
45
39
  }
46
- initializeFunctionColumnData(functionColumnConfigs, stableObjects, setData);
47
-
48
- // Process query results as they complete
49
- for await (const queryResult of executeQueriesGenerator(functionColumnConfigs, stableObjectSet, client, abortController.signal)) {
50
- if (abortController.signal.aborted) {
51
- break;
52
- }
53
- const {
54
- config,
55
- result,
56
- error,
57
- aborted
58
- } = queryResult;
59
- if (!aborted) {
60
- processQueryResult(config, result, error, stableObjects, setData);
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
- return () => {
65
- abortController.abort();
66
- abortControllerRef.current = null;
67
- };
68
- }, [functionColumnConfigs, stableObjects, stableObjectSet, client]);
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