@osdk/react-components 0.70.0 → 0.71.0-main-62ebddd7d14dd54cc6de480bc4f21a16fad9b529
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/CHANGELOG.md +14 -0
- package/build/browser/action-form/ActionForm.js +86 -5
- package/build/browser/action-form/ActionForm.js.map +1 -1
- package/build/browser/action-form/ActionFormApi.js.map +1 -1
- package/build/browser/action-form/BaseForm.js +8 -6
- package/build/browser/action-form/BaseForm.js.map +1 -1
- package/build/browser/action-form/BaseForm.module.css +2 -2
- package/build/browser/public/action-form.js.map +1 -1
- package/build/browser/public/experimental/action-form.js +2 -0
- package/build/browser/public/experimental/action-form.js.map +1 -1
- package/build/browser/styles.css +2 -2
- package/build/browser/util/UserAgent.js +1 -1
- package/build/browser/util/UserAgent.js.map +1 -1
- package/build/cjs/{action-form-B6wbHrW1.d.cts → action-form-Iq1Ru5RI.d.cts} +18 -1
- package/build/cjs/chunk-2DZBPTO2.cjs +12 -0
- package/build/cjs/{chunk-Z4BT3QO3.cjs.map → chunk-2DZBPTO2.cjs.map} +1 -1
- package/build/cjs/{chunk-J4NBM6OE.cjs → chunk-2MVCZ4FV.cjs} +4 -4
- package/build/cjs/{chunk-J4NBM6OE.cjs.map → chunk-2MVCZ4FV.cjs.map} +1 -1
- package/build/cjs/{chunk-T6TEMUKX.cjs → chunk-33R4CSSV.cjs} +4 -4
- package/build/cjs/{chunk-T6TEMUKX.cjs.map → chunk-33R4CSSV.cjs.map} +1 -1
- package/build/cjs/{chunk-7EUTWZMR.cjs → chunk-3SIF2GHA.cjs} +4 -4
- package/build/cjs/{chunk-7EUTWZMR.cjs.map → chunk-3SIF2GHA.cjs.map} +1 -1
- package/build/cjs/chunk-7NF6PKQH.cjs +12 -0
- package/build/cjs/{chunk-BPC7IVVD.cjs.map → chunk-7NF6PKQH.cjs.map} +1 -1
- package/build/cjs/chunk-A5IYCFJY.cjs +48 -0
- package/build/cjs/{chunk-NSPWQRJC.cjs.map → chunk-A5IYCFJY.cjs.map} +1 -1
- package/build/cjs/{chunk-DNQRRSU2.cjs → chunk-A74PTBTK.cjs} +4 -4
- package/build/cjs/{chunk-DNQRRSU2.cjs.map → chunk-A74PTBTK.cjs.map} +1 -1
- package/build/cjs/{chunk-IXXUU66T.cjs → chunk-BKBVMOZF.cjs} +4 -4
- package/build/cjs/{chunk-IXXUU66T.cjs.map → chunk-BKBVMOZF.cjs.map} +1 -1
- package/build/cjs/{chunk-P6SBA35V.cjs → chunk-D4FP3TVQ.cjs} +4 -4
- package/build/cjs/{chunk-P6SBA35V.cjs.map → chunk-D4FP3TVQ.cjs.map} +1 -1
- package/build/cjs/chunk-DAV3HQAF.cjs +11 -0
- package/build/cjs/{chunk-RWM5Q2TL.cjs.map → chunk-DAV3HQAF.cjs.map} +1 -1
- package/build/cjs/chunk-EA5Y3I74.cjs +11 -0
- package/build/cjs/{chunk-RSRRWH6V.cjs.map → chunk-EA5Y3I74.cjs.map} +1 -1
- package/build/cjs/chunk-EXMRYTRS.cjs +11 -0
- package/build/cjs/{chunk-KPCU4HM4.cjs.map → chunk-EXMRYTRS.cjs.map} +1 -1
- package/build/cjs/chunk-FCS7HZST.cjs +11 -0
- package/build/cjs/{chunk-34K44M7E.cjs.map → chunk-FCS7HZST.cjs.map} +1 -1
- package/build/cjs/{chunk-ZYBJ3LNA.cjs → chunk-GC46SZAK.cjs} +4 -4
- package/build/cjs/{chunk-ZYBJ3LNA.cjs.map → chunk-GC46SZAK.cjs.map} +1 -1
- package/build/cjs/{chunk-WVORK4J6.cjs → chunk-H26R6XAZ.cjs} +5 -5
- package/build/cjs/{chunk-WVORK4J6.cjs.map → chunk-H26R6XAZ.cjs.map} +1 -1
- package/build/cjs/{chunk-PKLHZUNU.cjs → chunk-HEGWR76M.cjs} +8 -8
- package/build/cjs/{chunk-PKLHZUNU.cjs.map → chunk-HEGWR76M.cjs.map} +1 -1
- package/build/cjs/chunk-OH6WOVND.cjs +11 -0
- package/build/cjs/{chunk-DUH54L3A.cjs.map → chunk-OH6WOVND.cjs.map} +1 -1
- package/build/cjs/{chunk-V6EHMYW3.cjs → chunk-PK7YJTAG.cjs} +4 -4
- package/build/cjs/{chunk-V6EHMYW3.cjs.map → chunk-PK7YJTAG.cjs.map} +1 -1
- package/build/cjs/chunk-QCHYZ5LW.cjs +34 -0
- package/build/cjs/{chunk-TPLDHL43.cjs.map → chunk-QCHYZ5LW.cjs.map} +1 -1
- package/build/cjs/{chunk-KIJIMTQX.cjs → chunk-QXBSKBO4.cjs} +369 -428
- package/build/cjs/chunk-QXBSKBO4.cjs.map +1 -0
- package/build/cjs/{chunk-HDSFUQBQ.cjs → chunk-R6QWBLCY.cjs} +4 -4
- package/build/cjs/{chunk-HDSFUQBQ.cjs.map → chunk-R6QWBLCY.cjs.map} +1 -1
- package/build/cjs/chunk-UQ5PSYYW.cjs +11 -0
- package/build/cjs/{chunk-A3DQM47Z.cjs.map → chunk-UQ5PSYYW.cjs.map} +1 -1
- package/build/cjs/{chunk-MNJON7D3.cjs → chunk-VQAVTOU3.cjs} +98 -22
- package/build/cjs/chunk-VQAVTOU3.cjs.map +1 -0
- package/build/cjs/{chunk-JDOJZGDO.cjs → chunk-W7LK7SRO.cjs} +92 -51
- package/build/cjs/chunk-W7LK7SRO.cjs.map +1 -0
- package/build/cjs/{chunk-UQTGPL5X.cjs → chunk-XKALHVSZ.cjs} +5 -5
- package/build/cjs/{chunk-UQTGPL5X.cjs.map → chunk-XKALHVSZ.cjs.map} +1 -1
- package/build/cjs/{chunk-WUTJ2FYF.cjs → chunk-YAGR3EZL.cjs} +3 -3
- package/build/cjs/chunk-YAGR3EZL.cjs.map +1 -0
- package/build/cjs/{chunk-JQTXDYGJ.cjs → chunk-ZMZXGMMO.cjs} +4 -4
- package/build/cjs/{chunk-JQTXDYGJ.cjs.map → chunk-ZMZXGMMO.cjs.map} +1 -1
- package/build/cjs/public/action-form.cjs +5 -5
- package/build/cjs/public/action-form.css +2 -2
- package/build/cjs/public/action-form.css.map +1 -1
- package/build/cjs/public/action-form.d.cts +1 -1
- package/build/cjs/public/document-viewer.cjs +4 -4
- package/build/cjs/public/email-viewer.cjs +3 -3
- package/build/cjs/public/experimental/action-form.cjs +6 -6
- package/build/cjs/public/experimental/action-form.css +2 -2
- package/build/cjs/public/experimental/action-form.css.map +1 -1
- package/build/cjs/public/experimental/action-form.d.cts +4 -2
- package/build/cjs/public/experimental/cbac-picker.cjs +8 -8
- package/build/cjs/public/experimental/document-viewer.cjs +5 -5
- package/build/cjs/public/experimental/email-viewer.cjs +5 -5
- package/build/cjs/public/experimental/filter-list.cjs +16 -16
- package/build/cjs/public/experimental/image-viewer.cjs +5 -5
- package/build/cjs/public/experimental/markdown-renderer.cjs +7 -7
- package/build/cjs/public/experimental/object-table.cjs +24 -24
- package/build/cjs/public/experimental/pdf-viewer.cjs +25 -25
- package/build/cjs/public/experimental/spreadsheet-viewer.cjs +5 -5
- package/build/cjs/public/experimental/tiff-renderer.cjs +7 -7
- package/build/cjs/public/experimental/video-viewer.cjs +5 -5
- package/build/cjs/public/experimental/workshop-module.cjs +2 -2
- package/build/cjs/public/experimental/xml-viewer.cjs +5 -5
- package/build/cjs/public/experimental.cjs +110 -110
- package/build/cjs/public/experimental.css +2 -2
- package/build/cjs/public/experimental.css.map +1 -1
- package/build/cjs/public/experimental.d.cts +2 -2
- package/build/cjs/public/filter-list.cjs +15 -15
- package/build/cjs/public/image-viewer.cjs +3 -3
- package/build/cjs/public/markdown-viewer.cjs +3 -3
- package/build/cjs/public/object-table.cjs +23 -23
- package/build/cjs/public/pdf-viewer.cjs +7 -7
- package/build/cjs/public/spreadsheet-viewer.cjs +3 -3
- package/build/cjs/public/tiff-viewer.cjs +3 -3
- package/build/cjs/public/video-viewer.cjs +3 -3
- package/build/cjs/public/xml-viewer.cjs +3 -3
- package/build/esm/action-form/ActionForm.js +86 -5
- package/build/esm/action-form/ActionForm.js.map +1 -1
- package/build/esm/action-form/ActionFormApi.js.map +1 -1
- package/build/esm/action-form/BaseForm.js +8 -6
- package/build/esm/action-form/BaseForm.js.map +1 -1
- package/build/esm/action-form/BaseForm.module.css +2 -2
- package/build/esm/public/action-form.js.map +1 -1
- package/build/esm/public/experimental/action-form.js +2 -0
- package/build/esm/public/experimental/action-form.js.map +1 -1
- package/build/esm/util/UserAgent.js +1 -1
- package/build/esm/util/UserAgent.js.map +1 -1
- package/build/types/action-form/ActionForm.d.ts.map +1 -1
- package/build/types/action-form/ActionFormApi.d.ts +17 -0
- package/build/types/action-form/ActionFormApi.d.ts.map +1 -1
- package/build/types/action-form/BaseForm.d.ts.map +1 -1
- package/build/types/public/action-form.d.ts +1 -1
- package/build/types/public/action-form.d.ts.map +1 -1
- package/build/types/public/experimental/action-form.d.ts +2 -0
- package/build/types/public/experimental/action-form.d.ts.map +1 -1
- package/docs/ActionFormOverview.md +14 -13
- package/package.json +8 -8
- package/build/cjs/chunk-34K44M7E.cjs +0 -11
- package/build/cjs/chunk-A3DQM47Z.cjs +0 -11
- package/build/cjs/chunk-BPC7IVVD.cjs +0 -12
- package/build/cjs/chunk-DUH54L3A.cjs +0 -11
- package/build/cjs/chunk-JDOJZGDO.cjs.map +0 -1
- package/build/cjs/chunk-KIJIMTQX.cjs.map +0 -1
- package/build/cjs/chunk-KPCU4HM4.cjs +0 -11
- package/build/cjs/chunk-MNJON7D3.cjs.map +0 -1
- package/build/cjs/chunk-NSPWQRJC.cjs +0 -48
- package/build/cjs/chunk-RSRRWH6V.cjs +0 -11
- package/build/cjs/chunk-RWM5Q2TL.cjs +0 -11
- package/build/cjs/chunk-TPLDHL43.cjs +0 -34
- package/build/cjs/chunk-WUTJ2FYF.cjs.map +0 -1
- package/build/cjs/chunk-Z4BT3QO3.cjs +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @osdk/react-components
|
|
2
2
|
|
|
3
|
+
## 0.71.0-main-62ebddd7d14dd54cc6de480bc4f21a16fad9b529
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0899055: Fix ActionForm validation: change error message to match Foundry, fix stuck submit button after validation error, add debounced server-side validation on field change
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [62ebddd]
|
|
12
|
+
- @osdk/client@2.89.0-main-62ebddd7d14dd54cc6de480bc4f21a16fad9b529
|
|
13
|
+
- @osdk/aip-core@0.13.0
|
|
14
|
+
- @osdk/react@2.89.0-main-62ebddd7d14dd54cc6de480bc4f21a16fad9b529
|
|
15
|
+
- @osdk/api@2.89.0-main-62ebddd7d14dd54cc6de480bc4f21a16fad9b529
|
|
16
|
+
|
|
3
17
|
## 0.70.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -16,12 +16,50 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
18
|
import { useOsdkAction, useOsdkMetadata } from "@osdk/react";
|
|
19
|
-
import React, { useCallback, useEffect, useMemo } from "react";
|
|
19
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
20
|
+
import { useDebouncedCallback } from "../shared/hooks/useDebouncedCallback.js";
|
|
20
21
|
import { typedReactMemo } from "../shared/typedMemo.js";
|
|
21
22
|
import { BaseForm } from "./BaseForm.js";
|
|
22
23
|
import { coerceFieldValue } from "./utils/coerceFieldValue.js";
|
|
23
24
|
import { getDefaultFieldDefinitions } from "./utils/getDefaultFieldDefinitions.js";
|
|
24
25
|
const EMPTY_FORM_CONTENT = [];
|
|
26
|
+
const EMPTY_VALIDATION_ERRORS = [];
|
|
27
|
+
function getValidationErrors(response) {
|
|
28
|
+
const errors = [];
|
|
29
|
+
for (const criterion of response.submissionCriteria) {
|
|
30
|
+
if (criterion.result === "INVALID") {
|
|
31
|
+
errors.push({
|
|
32
|
+
message: criterion.configuredFailureMessage ?? "Submission criteria not met. Review the values and try again."
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
for (const [paramKey, param] of Object.entries(response.parameters)) {
|
|
37
|
+
if (param.result === "INVALID") {
|
|
38
|
+
errors.push({
|
|
39
|
+
label: paramKey,
|
|
40
|
+
message: getParameterErrorMessage(param.evaluatedConstraints)
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (errors.length === 0 && response.result === "INVALID") {
|
|
45
|
+
errors.push({
|
|
46
|
+
message: "Validation failed"
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return errors.length > 0 ? errors : EMPTY_VALIDATION_ERRORS;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// TODO: Derive constraint-specific error messages from evaluatedConstraints
|
|
53
|
+
// (e.g. "Must have at least 3 characters" for stringLength constraints)
|
|
54
|
+
// and surface them inline next to the field, matching Foundry ActionForm behavior.
|
|
55
|
+
function getParameterErrorMessage(constraints) {
|
|
56
|
+
for (const c of constraints) {
|
|
57
|
+
if ("configuredFailureMessage" in c && c.configuredFailureMessage != null) {
|
|
58
|
+
return c.configuredFailureMessage;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return "The parameter value is invalid";
|
|
62
|
+
}
|
|
25
63
|
function toRendererDef(def, parameters) {
|
|
26
64
|
const {
|
|
27
65
|
defaultValue,
|
|
@@ -47,12 +85,13 @@ export const ActionForm = typedReactMemo(function ({
|
|
|
47
85
|
onFormStateChange,
|
|
48
86
|
isSubmitDisabled,
|
|
49
87
|
onSubmit,
|
|
50
|
-
onValidationResponse
|
|
88
|
+
onValidationResponse,
|
|
51
89
|
onSuccess,
|
|
52
90
|
onError
|
|
53
91
|
}) {
|
|
54
92
|
const {
|
|
55
93
|
applyAction: osdkApplyAction,
|
|
94
|
+
validateAction: osdkValidateAction,
|
|
56
95
|
isPending
|
|
57
96
|
} = useOsdkAction(actionDefinition);
|
|
58
97
|
const {
|
|
@@ -69,6 +108,7 @@ export const ActionForm = typedReactMemo(function ({
|
|
|
69
108
|
}
|
|
70
109
|
}, [metadataError, onError]);
|
|
71
110
|
const parameters = metadata?.parameters;
|
|
111
|
+
const [validationErrors, setValidationErrors] = useState(EMPTY_VALIDATION_ERRORS);
|
|
72
112
|
const extractFieldDefinition = useCallback(def => toRendererDef(def, parameters), [parameters]);
|
|
73
113
|
const customFieldDefinitions = useMemo(() => {
|
|
74
114
|
if (formContentDefinitions != null) {
|
|
@@ -109,12 +149,45 @@ export const ActionForm = typedReactMemo(function ({
|
|
|
109
149
|
}
|
|
110
150
|
return coerced;
|
|
111
151
|
}, [parameters]);
|
|
152
|
+
const formStateRef = useRef(controlledFormState != null ? controlledFormState : {});
|
|
153
|
+
if (controlledFormState != null) {
|
|
154
|
+
formStateRef.current = controlledFormState;
|
|
155
|
+
}
|
|
156
|
+
const debouncedValidate = useDebouncedCallback(async () => {
|
|
157
|
+
if (onSubmit != null) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const formState = coerceFormState(formStateRef.current);
|
|
161
|
+
try {
|
|
162
|
+
const validation = await osdkValidateAction(formState);
|
|
163
|
+
if (validation != null) {
|
|
164
|
+
onValidationResponse?.(validation);
|
|
165
|
+
if (validation.result === "INVALID") {
|
|
166
|
+
setValidationErrors(getValidationErrors(validation));
|
|
167
|
+
} else {
|
|
168
|
+
setValidationErrors(EMPTY_VALIDATION_ERRORS);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
} catch {
|
|
172
|
+
// Validation errors from the network are not surfaced inline;
|
|
173
|
+
// they will be caught at submit time.
|
|
174
|
+
}
|
|
175
|
+
}, 500);
|
|
112
176
|
const handleSubmit = useCallback(async rawFormState => {
|
|
113
177
|
const formState = coerceFormState(rawFormState);
|
|
114
178
|
try {
|
|
115
179
|
if (onSubmit != null) {
|
|
116
180
|
await onSubmit(formState, osdkApplyAction);
|
|
117
181
|
} else {
|
|
182
|
+
const validation = await osdkValidateAction(formState);
|
|
183
|
+
if (validation != null) {
|
|
184
|
+
onValidationResponse?.(validation);
|
|
185
|
+
if (validation.result === "INVALID") {
|
|
186
|
+
setValidationErrors(getValidationErrors(validation));
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
setValidationErrors(EMPTY_VALIDATION_ERRORS);
|
|
118
191
|
const result = await osdkApplyAction(formState);
|
|
119
192
|
onSuccess?.(result);
|
|
120
193
|
}
|
|
@@ -123,14 +196,21 @@ export const ActionForm = typedReactMemo(function ({
|
|
|
123
196
|
type: "submission",
|
|
124
197
|
error: e
|
|
125
198
|
});
|
|
199
|
+
throw e;
|
|
126
200
|
}
|
|
127
|
-
}, [coerceFormState, onSubmit, osdkApplyAction, onSuccess, onError]);
|
|
201
|
+
}, [coerceFormState, osdkValidateAction, onValidationResponse, onSubmit, osdkApplyAction, onSuccess, onError]);
|
|
128
202
|
const handleFieldValueChange = useCallback((fieldKey, value) => {
|
|
203
|
+
setValidationErrors(EMPTY_VALIDATION_ERRORS);
|
|
204
|
+
formStateRef.current = {
|
|
205
|
+
...formStateRef.current,
|
|
206
|
+
[fieldKey]: value
|
|
207
|
+
};
|
|
129
208
|
onFormStateChange?.(prev => ({
|
|
130
209
|
...prev,
|
|
131
210
|
[fieldKey]: value
|
|
132
211
|
}));
|
|
133
|
-
|
|
212
|
+
void debouncedValidate();
|
|
213
|
+
}, [onFormStateChange, debouncedValidate]);
|
|
134
214
|
const resolvedTitle = showFormTitle ? formTitle ?? metadata?.displayName ?? actionDefinition.apiName : undefined;
|
|
135
215
|
const commonProps = {
|
|
136
216
|
formTitle: resolvedTitle,
|
|
@@ -139,7 +219,8 @@ export const ActionForm = typedReactMemo(function ({
|
|
|
139
219
|
isSubmitDisabled,
|
|
140
220
|
isPending,
|
|
141
221
|
isLoading: metadataLoading,
|
|
142
|
-
onFieldValueChange: handleFieldValueChange
|
|
222
|
+
onFieldValueChange: handleFieldValueChange,
|
|
223
|
+
validationErrors
|
|
143
224
|
};
|
|
144
225
|
if (!(controlledFormState != null)) {
|
|
145
226
|
return /*#__PURE__*/React.createElement(BaseForm, commonProps);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionForm.js","names":["useOsdkAction","useOsdkMetadata","React","useCallback","useEffect","useMemo","typedReactMemo","BaseForm","coerceFieldValue","getDefaultFieldDefinitions","EMPTY_FORM_CONTENT","toRendererDef","def","parameters","defaultValue","fieldDefinition","fieldKey","String","fieldType","type","fieldComponentProps","undefined","ActionForm","actionDefinition","formTitle","showFormTitle","formFieldDefinitions","formContentDefinitions","formState","controlledFormState","onFormStateChange","isSubmitDisabled","onSubmit","onValidationResponse","_onValidationResponse","onSuccess","onError","applyAction","osdkApplyAction","isPending","metadata","loading","metadataLoading","error","metadataError","extractFieldDefinition","customFieldDefinitions","map","item","definition","key","fields","rendererFieldDefinitions","defaults","length","coerceFormState","rawState","coerced","value","Object","entries","handleSubmit","rawFormState","result","e","handleFieldValueChange","prev","resolvedTitle","displayName","apiName","commonProps","formContent","isLoading","onFieldValueChange","createElement","_extends"],"sources":["ActionForm.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ActionDefinition, ActionMetadata } from \"@osdk/api\";\nimport { useOsdkAction, useOsdkMetadata } from \"@osdk/react\";\nimport React, { useCallback, useEffect, useMemo } from \"react\";\n\nimport { typedReactMemo } from \"../shared/typedMemo.js\";\nimport type {\n ActionFormProps,\n FormContentItem,\n FormState,\n} from \"./ActionFormApi.js\";\nimport { BaseForm } from \"./BaseForm.js\";\nimport type {\n FormFieldDefinition,\n RendererFieldDefinition,\n} from \"./FormFieldApi.js\";\nimport { coerceFieldValue } from \"./utils/coerceFieldValue.js\";\nimport { getDefaultFieldDefinitions } from \"./utils/getDefaultFieldDefinitions.js\";\n\nconst EMPTY_FORM_CONTENT: ReadonlyArray<FormContentItem> = [];\n\nfunction toRendererDef<Q extends ActionDefinition<unknown>>(\n def: FormFieldDefinition<Q>,\n parameters: ActionMetadata[\"parameters\"] | undefined,\n): RendererFieldDefinition {\n const { defaultValue, ...fieldDefinition } = def;\n return {\n ...fieldDefinition,\n fieldKey: String(def.fieldKey),\n fieldType: parameters?.[String(def.fieldKey)]?.type,\n fieldComponentProps:\n defaultValue === undefined\n ? def.fieldComponentProps\n : { ...def.fieldComponentProps, defaultValue },\n } as RendererFieldDefinition;\n}\n\nexport const ActionForm: <Q extends ActionDefinition<unknown>>(\n props: ActionFormProps<Q>,\n) => React.ReactElement = typedReactMemo(function ActionFormFn<\n Q extends ActionDefinition<unknown>,\n>({\n actionDefinition,\n formTitle,\n showFormTitle = false,\n formFieldDefinitions,\n formContentDefinitions,\n formState: controlledFormState,\n onFormStateChange,\n isSubmitDisabled,\n onSubmit,\n onValidationResponse: _onValidationResponse,\n onSuccess,\n onError,\n}: ActionFormProps<Q>): React.ReactElement {\n const { applyAction: osdkApplyAction, isPending } =\n useOsdkAction(actionDefinition);\n const {\n metadata,\n loading: metadataLoading,\n error: metadataError,\n } = useOsdkMetadata(actionDefinition);\n\n useEffect(\n function saveMetadataError() {\n if (metadataError != null) {\n onError?.({ type: \"unknown\", error: metadataError });\n }\n },\n [metadataError, onError],\n );\n\n const parameters = metadata?.parameters;\n\n const extractFieldDefinition = useCallback(\n (def: FormFieldDefinition<Q>): RendererFieldDefinition =>\n toRendererDef(def, parameters),\n [parameters],\n );\n\n const customFieldDefinitions = useMemo(():\n | ReadonlyArray<FormContentItem>\n | undefined => {\n if (formContentDefinitions != null) {\n return formContentDefinitions.map(\n (item): FormContentItem =>\n item.type === \"field\"\n ? {\n type: \"field\",\n definition: extractFieldDefinition(item.definition),\n }\n : {\n type: \"section\",\n key: item.key,\n definition: {\n ...item.definition,\n fields: item.definition.fields.map(extractFieldDefinition),\n },\n },\n );\n }\n if (formFieldDefinitions != null) {\n return formFieldDefinitions.map(\n (def): FormContentItem => ({\n type: \"field\",\n definition: extractFieldDefinition(def),\n }),\n );\n }\n return undefined;\n }, [formContentDefinitions, formFieldDefinitions, extractFieldDefinition]);\n\n const rendererFieldDefinitions = useMemo(():\n | ReadonlyArray<FormContentItem>\n | undefined => {\n if (metadata != null && customFieldDefinitions == null) {\n const defaults = getDefaultFieldDefinitions(metadata);\n return defaults.length === 0\n ? EMPTY_FORM_CONTENT\n : defaults.map(\n (def): FormContentItem => ({ type: \"field\", definition: def }),\n );\n }\n return undefined;\n }, [metadata, customFieldDefinitions]);\n\n const formContent =\n customFieldDefinitions ?? rendererFieldDefinitions ?? EMPTY_FORM_CONTENT;\n\n const coerceFormState = useCallback(\n (rawState: Record<string, unknown>): Record<string, unknown> => {\n const coerced: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rawState)) {\n coerced[key] = coerceFieldValue(parameters?.[key]?.type, value);\n }\n return coerced;\n },\n [parameters],\n );\n\n const handleSubmit = useCallback(\n async (rawFormState: Record<string, unknown>) => {\n const formState = coerceFormState(rawFormState) as FormState<Q>;\n try {\n if (onSubmit != null) {\n await onSubmit(formState, osdkApplyAction);\n } else {\n const result = await osdkApplyAction(formState);\n onSuccess?.(result);\n }\n } catch (e) {\n onError?.({ type: \"submission\", error: e });\n }\n },\n [coerceFormState, onSubmit, osdkApplyAction, onSuccess, onError],\n );\n\n const handleFieldValueChange = useCallback(\n (fieldKey: string, value: unknown) => {\n onFormStateChange?.(\n (prev) =>\n ({\n ...prev,\n [fieldKey]: value,\n }) as FormState<Q>,\n );\n },\n [onFormStateChange],\n );\n\n const resolvedTitle = showFormTitle\n ? (formTitle ?? metadata?.displayName ?? actionDefinition.apiName)\n : undefined;\n\n const isControlled = controlledFormState != null;\n\n const commonProps = {\n formTitle: resolvedTitle,\n formContent,\n onSubmit: handleSubmit,\n isSubmitDisabled,\n isPending,\n isLoading: metadataLoading,\n onFieldValueChange: handleFieldValueChange,\n };\n\n if (!isControlled) {\n return <BaseForm {...commonProps} />;\n }\n\n return <BaseForm {...commonProps} formState={controlledFormState} />;\n});\n\n// The inner render fn is anonymous in the published build, so set a displayName\n// on the memo wrapper for React DevTools and the OSDK devtools component tree.\n(ActionForm as { displayName?: string }).displayName = \"ActionForm\";\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,aAAa,EAAEC,eAAe,QAAQ,aAAa;AAC5D,OAAOC,KAAK,IAAIC,WAAW,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAE9D,SAASC,cAAc,QAAQ,wBAAwB;AAMvD,SAASC,QAAQ,QAAQ,eAAe;AAKxC,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,0BAA0B,QAAQ,uCAAuC;AAElF,MAAMC,kBAAkD,GAAG,EAAE;AAE7D,SAASC,aAAaA,CACpBC,GAA2B,EAC3BC,UAAoD,EAC3B;EACzB,MAAM;IAAEC,YAAY;IAAE,GAAGC;EAAgB,CAAC,GAAGH,GAAG;EAChD,OAAO;IACL,GAAGG,eAAe;IAClBC,QAAQ,EAAEC,MAAM,CAACL,GAAG,CAACI,QAAQ,CAAC;IAC9BE,SAAS,EAAEL,UAAU,GAAGI,MAAM,CAACL,GAAG,CAACI,QAAQ,CAAC,CAAC,EAAEG,IAAI;IACnDC,mBAAmB,EACjBN,YAAY,KAAKO,SAAS,GACtBT,GAAG,CAACQ,mBAAmB,GACvB;MAAE,GAAGR,GAAG,CAACQ,mBAAmB;MAAEN;IAAa;EACnD,CAAC;AACH;AAEA,OAAO,MAAMQ,UAEU,GAAGhB,cAAc,CAAC,UAEvC;EACAiB,gBAAgB;EAChBC,SAAS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EA,oBAAOpE,KAAA,CAAAwE,aAAA,CAACnE,QAAQ,EAAAoE,QAAA,KAAKL,WAAW;IAAE1C,SAAS,EAAEC;EAAoB,EAAE,CAAC;AACtE,CAAC,CAAC;;AAEF;AACA;AACCP,UAAU,CAA8B8C,WAAW,GAAG,YAAY","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ActionForm.js","names":["useOsdkAction","useOsdkMetadata","React","useCallback","useEffect","useMemo","useRef","useState","useDebouncedCallback","typedReactMemo","BaseForm","coerceFieldValue","getDefaultFieldDefinitions","EMPTY_FORM_CONTENT","EMPTY_VALIDATION_ERRORS","getValidationErrors","response","errors","criterion","submissionCriteria","result","push","message","configuredFailureMessage","paramKey","param","Object","entries","parameters","label","getParameterErrorMessage","evaluatedConstraints","length","constraints","c","toRendererDef","def","defaultValue","fieldDefinition","fieldKey","String","fieldType","type","fieldComponentProps","undefined","ActionForm","actionDefinition","formTitle","showFormTitle","formFieldDefinitions","formContentDefinitions","formState","controlledFormState","onFormStateChange","isSubmitDisabled","onSubmit","onValidationResponse","onSuccess","onError","applyAction","osdkApplyAction","validateAction","osdkValidateAction","isPending","metadata","loading","metadataLoading","error","metadataError","validationErrors","setValidationErrors","extractFieldDefinition","customFieldDefinitions","map","item","definition","key","fields","rendererFieldDefinitions","defaults","coerceFormState","rawState","coerced","value","formStateRef","current","debouncedValidate","validation","handleSubmit","rawFormState","e","handleFieldValueChange","prev","resolvedTitle","displayName","apiName","commonProps","formContent","isLoading","onFieldValueChange","createElement","_extends"],"sources":["ActionForm.tsx"],"sourcesContent":["/*\n * Copyright 2025 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n ActionDefinition,\n ActionMetadata,\n ActionValidationResponse,\n} from \"@osdk/api\";\nimport { useOsdkAction, useOsdkMetadata } from \"@osdk/react\";\nimport React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport { useDebouncedCallback } from \"../shared/hooks/useDebouncedCallback.js\";\nimport { typedReactMemo } from \"../shared/typedMemo.js\";\nimport type {\n ActionFormProps,\n FormErrorEntry,\n FormContentItem,\n FormState,\n} from \"./ActionFormApi.js\";\nimport { BaseForm } from \"./BaseForm.js\";\nimport type {\n FormFieldDefinition,\n RendererFieldDefinition,\n} from \"./FormFieldApi.js\";\nimport { coerceFieldValue } from \"./utils/coerceFieldValue.js\";\nimport { getDefaultFieldDefinitions } from \"./utils/getDefaultFieldDefinitions.js\";\n\nconst EMPTY_FORM_CONTENT: ReadonlyArray<FormContentItem> = [];\nconst EMPTY_VALIDATION_ERRORS: ReadonlyArray<FormErrorEntry> = [];\n\nfunction getValidationErrors(\n response: ActionValidationResponse,\n): ReadonlyArray<FormErrorEntry> {\n const errors: FormErrorEntry[] = [];\n\n for (const criterion of response.submissionCriteria) {\n if (criterion.result === \"INVALID\") {\n errors.push({\n message:\n criterion.configuredFailureMessage ??\n \"Submission criteria not met. Review the values and try again.\",\n });\n }\n }\n\n for (const [paramKey, param] of Object.entries(response.parameters)) {\n if (param.result === \"INVALID\") {\n errors.push({\n label: paramKey,\n message: getParameterErrorMessage(param.evaluatedConstraints),\n });\n }\n }\n\n if (errors.length === 0 && response.result === \"INVALID\") {\n errors.push({ message: \"Validation failed\" });\n }\n\n return errors.length > 0 ? errors : EMPTY_VALIDATION_ERRORS;\n}\n\n// TODO: Derive constraint-specific error messages from evaluatedConstraints\n// (e.g. \"Must have at least 3 characters\" for stringLength constraints)\n// and surface them inline next to the field, matching Foundry ActionForm behavior.\nfunction getParameterErrorMessage(\n constraints: ReadonlyArray<{\n type: string;\n configuredFailureMessage?: string;\n }>,\n): string {\n for (const c of constraints) {\n if (\"configuredFailureMessage\" in c && c.configuredFailureMessage != null) {\n return c.configuredFailureMessage;\n }\n }\n return \"The parameter value is invalid\";\n}\n\nfunction toRendererDef<Q extends ActionDefinition<unknown>>(\n def: FormFieldDefinition<Q>,\n parameters: ActionMetadata[\"parameters\"] | undefined,\n): RendererFieldDefinition {\n const { defaultValue, ...fieldDefinition } = def;\n return {\n ...fieldDefinition,\n fieldKey: String(def.fieldKey),\n fieldType: parameters?.[String(def.fieldKey)]?.type,\n fieldComponentProps:\n defaultValue === undefined\n ? def.fieldComponentProps\n : { ...def.fieldComponentProps, defaultValue },\n } as RendererFieldDefinition;\n}\n\nexport const ActionForm: <Q extends ActionDefinition<unknown>>(\n props: ActionFormProps<Q>,\n) => React.ReactElement = typedReactMemo(function ActionFormFn<\n Q extends ActionDefinition<unknown>,\n>({\n actionDefinition,\n formTitle,\n showFormTitle = false,\n formFieldDefinitions,\n formContentDefinitions,\n formState: controlledFormState,\n onFormStateChange,\n isSubmitDisabled,\n onSubmit,\n onValidationResponse,\n onSuccess,\n onError,\n}: ActionFormProps<Q>): React.ReactElement {\n const {\n applyAction: osdkApplyAction,\n validateAction: osdkValidateAction,\n isPending,\n } = useOsdkAction(actionDefinition);\n const {\n metadata,\n loading: metadataLoading,\n error: metadataError,\n } = useOsdkMetadata(actionDefinition);\n\n useEffect(\n function saveMetadataError() {\n if (metadataError != null) {\n onError?.({ type: \"unknown\", error: metadataError });\n }\n },\n [metadataError, onError],\n );\n\n const parameters = metadata?.parameters;\n\n const [validationErrors, setValidationErrors] = useState<\n ReadonlyArray<FormErrorEntry>\n >(EMPTY_VALIDATION_ERRORS);\n\n const extractFieldDefinition = useCallback(\n (def: FormFieldDefinition<Q>): RendererFieldDefinition =>\n toRendererDef(def, parameters),\n [parameters],\n );\n\n const customFieldDefinitions = useMemo(():\n | ReadonlyArray<FormContentItem>\n | undefined => {\n if (formContentDefinitions != null) {\n return formContentDefinitions.map(\n (item): FormContentItem =>\n item.type === \"field\"\n ? {\n type: \"field\",\n definition: extractFieldDefinition(item.definition),\n }\n : {\n type: \"section\",\n key: item.key,\n definition: {\n ...item.definition,\n fields: item.definition.fields.map(extractFieldDefinition),\n },\n },\n );\n }\n if (formFieldDefinitions != null) {\n return formFieldDefinitions.map(\n (def): FormContentItem => ({\n type: \"field\",\n definition: extractFieldDefinition(def),\n }),\n );\n }\n return undefined;\n }, [formContentDefinitions, formFieldDefinitions, extractFieldDefinition]);\n\n const rendererFieldDefinitions = useMemo(():\n | ReadonlyArray<FormContentItem>\n | undefined => {\n if (metadata != null && customFieldDefinitions == null) {\n const defaults = getDefaultFieldDefinitions(metadata);\n return defaults.length === 0\n ? EMPTY_FORM_CONTENT\n : defaults.map(\n (def): FormContentItem => ({ type: \"field\", definition: def }),\n );\n }\n return undefined;\n }, [metadata, customFieldDefinitions]);\n\n const formContent =\n customFieldDefinitions ?? rendererFieldDefinitions ?? EMPTY_FORM_CONTENT;\n\n const coerceFormState = useCallback(\n (rawState: Record<string, unknown>): Record<string, unknown> => {\n const coerced: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(rawState)) {\n coerced[key] = coerceFieldValue(parameters?.[key]?.type, value);\n }\n return coerced;\n },\n [parameters],\n );\n\n const formStateRef = useRef<Record<string, unknown>>(\n controlledFormState != null\n ? (controlledFormState as Record<string, unknown>)\n : {},\n );\n if (controlledFormState != null) {\n formStateRef.current = controlledFormState as Record<string, unknown>;\n }\n\n const debouncedValidate = useDebouncedCallback(async () => {\n if (onSubmit != null) {\n return;\n }\n const formState = coerceFormState(formStateRef.current);\n try {\n const validation = await osdkValidateAction(formState);\n if (validation != null) {\n onValidationResponse?.(validation);\n if (validation.result === \"INVALID\") {\n setValidationErrors(getValidationErrors(validation));\n } else {\n setValidationErrors(EMPTY_VALIDATION_ERRORS);\n }\n }\n } catch {\n // Validation errors from the network are not surfaced inline;\n // they will be caught at submit time.\n }\n }, 500);\n\n const handleSubmit = useCallback(\n async (rawFormState: Record<string, unknown>) => {\n const formState = coerceFormState(rawFormState) as FormState<Q>;\n try {\n if (onSubmit != null) {\n await onSubmit(formState, osdkApplyAction);\n } else {\n const validation = await osdkValidateAction(formState);\n if (validation != null) {\n onValidationResponse?.(validation);\n if (validation.result === \"INVALID\") {\n setValidationErrors(getValidationErrors(validation));\n return;\n }\n }\n setValidationErrors(EMPTY_VALIDATION_ERRORS);\n const result = await osdkApplyAction(formState);\n onSuccess?.(result);\n }\n } catch (e) {\n onError?.({ type: \"submission\", error: e });\n throw e;\n }\n },\n [\n coerceFormState,\n osdkValidateAction,\n onValidationResponse,\n onSubmit,\n osdkApplyAction,\n onSuccess,\n onError,\n ],\n );\n\n const handleFieldValueChange = useCallback(\n (fieldKey: string, value: unknown) => {\n setValidationErrors(EMPTY_VALIDATION_ERRORS);\n formStateRef.current = { ...formStateRef.current, [fieldKey]: value };\n onFormStateChange?.(\n (prev) =>\n ({\n ...prev,\n [fieldKey]: value,\n }) as FormState<Q>,\n );\n void debouncedValidate();\n },\n [onFormStateChange, debouncedValidate],\n );\n\n const resolvedTitle = showFormTitle\n ? (formTitle ?? metadata?.displayName ?? actionDefinition.apiName)\n : undefined;\n\n const isControlled = controlledFormState != null;\n\n const commonProps = {\n formTitle: resolvedTitle,\n formContent,\n onSubmit: handleSubmit,\n isSubmitDisabled,\n isPending,\n isLoading: metadataLoading,\n onFieldValueChange: handleFieldValueChange,\n validationErrors,\n };\n\n if (!isControlled) {\n return <BaseForm {...commonProps} />;\n }\n\n return <BaseForm {...commonProps} formState={controlledFormState} />;\n});\n\n// The inner render fn is anonymous in the published build, so set a displayName\n// on the memo wrapper for React DevTools and the OSDK devtools component tree.\n(ActionForm as { displayName?: string }).displayName = \"ActionForm\";\n"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASA,aAAa,EAAEC,eAAe,QAAQ,aAAa;AAC5D,OAAOC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AACoC,QAAgB,EAAE4C,KAAc,KAAK;IACpCb,mBAAmB,CAACxD,uBAAuB,CAAC;IAC5CsE,YAAY,CAACC,OAAO,GAAG;MAAE,GAAGD,YAAY,CAACC,OAAO;MAAE,CAAC9C,QAAQ,GAAG4C;IAAM,CAAC;IACrE9B,iBAAiB,GACduC,IAAI,KACF;MACC,GAAGA,IAAI;MACP,CAACrD,QAAQ,GAAG4C;IACd,CAAC,CACL,CAAC;IACD,KAAKG,iBAAiB,CAAC,CAAC;EAC1B,CAAC,EACD,CAACjC,iBAAiB,EAAEiC,iBAAiB,CACvC,CAAC;EAED,MAAMO,aAAa,GAAG7C,aAAa,GAC9BD,SAAS,IAAIiB,QAAQ,EAAE8B,WAAW,IAAIhD,gBAAgB,CAACiD,OAAO,GAC/DnD,SAAS;EAIb,MAAMoD,WAAW,GAAG;IAClBjD,SAAS,EAAE8C,aAAa;IACxBI,WAAW,EAtGXzB,sBAAsB,IAAIM,wBAAwB,IAAIjE,kBAsG3C;IACX0C,QAAQ,EAAEiC,YAAY;IACtBlC,gBAAgB;IAChBS,SAAS;IACTmC,SAAS,EAAEhC,eAAe;IAC1BiC,kBAAkB,EAAER,sBAAsB;IAC1CtB;EACF,CAAC;EAED,IAAI,EAbiBjB,mBAAmB,IAAI,IAAI,CAa/B,EAAE;IACjB,oBAAOlD,KAAA,CAAAkG,aAAA,CAAC1F,QAAQ,EAAKsF,WAAc,CAAC;EACtC;EAEA,oBAAO9F,KAAA,CAAAkG,aAAA,CAAC1F,QAAQ,EAAA2F,QAAA,KAAKL,WAAW;IAAE7C,SAAS,EAAEC;EAAoB,EAAE,CAAC;AACtE,CAAC,CAAC;;AAEF;AACA;AACCP,UAAU,CAA8BiD,WAAW,GAAG,YAAY","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionFormApi.js","names":[],"sources":["ActionFormApi.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 ActionDefinition,\n ActionEditResponse,\n ActionValidationResponse,\n} from \"@osdk/api\";\n\nimport type {\n FieldKey,\n FieldValueType,\n FormFieldDefinition,\n RendererFieldDefinition,\n} from \"./FormFieldApi.js\";\n\n/**\n * Props for the ActionForm component.\n *\n * A discriminated union ensures that controlled mode (formState provided)\n * always requires onFormStateChange, and uncontrolled mode makes `onFormStateChange` optional\n */\nexport type ActionFormProps<Q extends ActionDefinition<unknown>> =\n | (ActionFormConfigProps<Q> & {\n /**\n * The current form values.\n * If provided, the form state is controlled.\n */\n formState: FormState<Q>;\n /**\n * Called when a field value changes, with a state updater.\n * Required when the form state is controlled; also fires in\n * uncontrolled mode so callers can observe changes.\n */\n onFormStateChange: (\n updater: (prevState: FormState<Q>) => FormState<Q>,\n ) => void;\n })\n | (ActionFormConfigProps<Q> & {\n formState?: undefined;\n onFormStateChange?: (\n updater: (prevState: FormState<Q>) => FormState<Q>,\n ) => void;\n });\n\n/**\n * Determines how the form fields are specified. Exactly one of the three\n * branches may be used:\n *\n * 1. Neither prop — fields are auto-generated from action metadata.\n * 2. `formFieldDefinitions` — a flat list of field definitions.\n * 3. `formContentDefinitions` — fields and sections for richer layout.\n */\ntype ActionFormContentConfig<Q extends ActionDefinition<unknown>> =\n | { formFieldDefinitions?: undefined; formContentDefinitions?: undefined }\n | {\n /** Custom flat list of field definitions. */\n formFieldDefinitions: ReadonlyArray<FormFieldDefinition<Q>>;\n formContentDefinitions?: never;\n }\n | {\n /** Ordered list of fields and sections that define the form layout. */\n formContentDefinitions: ReadonlyArray<ActionFormContentItem<Q>>;\n formFieldDefinitions?: never;\n };\n\ntype ActionFormConfigProps<Q extends ActionDefinition<unknown>> =\n ActionFormBaseConfigProps<Q> & ActionFormContentConfig<Q>;\n\ninterface ActionFormBaseConfigProps<\n Q extends ActionDefinition<unknown>,\n> extends Pick<BaseFormProps, \"formTitle\" | \"isSubmitDisabled\"> {\n /**\n * The OSDK action definition. Its parameters drive the rendered fields\n * and the submission.\n */\n actionDefinition: Q;\n\n /**\n * Whether to show the form title.\n *\n * @default false\n */\n showFormTitle?: boolean;\n\n /**\n * If supplied, this will override the default submit action.\n * By default, the action's applyAction will be called.\n *\n * @param formState all field values when onSubmit is called\n * @param applyAction the function to execute the action\n * @returns a promise of the submission response\n */\n onSubmit?: (\n formState: FormState<Q>,\n applyAction: (\n formState: FormState<Q>,\n ) => Promise<ActionEditResponse | undefined>,\n ) => Promise<unknown> | void;\n\n /**\n * Called when the validation response is returned from a validateOnly submission\n *\n * @param results the validation response\n */\n onValidationResponse?: (results: ActionValidationResponse) => void;\n\n /**\n * Called when the action is successfully executed from a non-validateOnly submission\n *\n * @param results the submission response\n */\n onSuccess?: (results: ActionEditResponse | undefined) => void;\n\n /**\n * Called when action metadata fails to load or form submission fails.\n *\n * @param error the error that occurred\n */\n onError?: (error: FormError) => void;\n}\n\n/**\n * Form values mapping parameter names to their values\n */\nexport type FormState<Q extends ActionDefinition<unknown>> = {\n [K in FieldKey<Q>]?: FieldValueType<Q, K>;\n};\n\n/**\n * Form error discriminated union\n */\nexport type FormError =\n | { type: \"submission\"; error: unknown }\n | { type: \"unknown\"; error: unknown };\n\n/**\n * Generic content item parameterized by its field-definition type.\n * Both the OSDK-typed and renderer-level content items derive from this\n * so their structure cannot diverge.\n */\ntype BaseContentItem<F, S extends BaseSectionDefinition<F>> =\n | { type: \"field\"; definition: F }\n | { type: \"section\"; key: string; definition: S };\n\n/**\n * Generic section definition parameterized by its field-definition type.\n */\ninterface BaseSectionDefinition<F> {\n /** Section heading. */\n title: string;\n /** Optional description below the heading. */\n description?: string;\n /** The fields rendered inside this section. */\n fields: ReadonlyArray<F>;\n /**\n * Whether the section starts collapsed.\n * @default false\n */\n collapsedByDefault?: boolean;\n /**\n * Whether to show the title bar.\n * @default true\n */\n showTitleBar?: boolean;\n /**\n * Number of columns for fields.\n * @default 1\n */\n columnCount?: 1 | 2;\n /**\n * Visual style. `\"box\"` = bordered card, `\"minimal\"` = heading only.\n * @default \"box\"\n */\n style?: \"box\" | \"minimal\";\n}\n\n/**\n * A single item in the ActionForm content array — either a standalone\n * field or a section that groups multiple fields.\n */\nexport type ActionFormContentItem<Q extends ActionDefinition<unknown>> =\n BaseContentItem<FormFieldDefinition<Q>, ActionFormSectionDefinition<Q>>;\n\n/**\n * Configuration for a section in the ActionForm.\n */\nexport interface ActionFormSectionDefinition<\n Q extends ActionDefinition<unknown>,\n> extends BaseSectionDefinition<FormFieldDefinition<Q>> {}\n\n/**\n * A single item in the form content array — either a standalone field\n * or a section that groups multiple fields.\n */\nexport type FormContentItem = BaseContentItem<\n RendererFieldDefinition,\n FormSectionDefinition\n>;\n\n/**\n * Configuration for a form section — a visual group of fields with\n * optional title bar, collapse behavior, and multi-column layout.\n */\nexport interface FormSectionDefinition extends BaseSectionDefinition<RendererFieldDefinition> {}\n\n/**\n * Props for the `BaseForm` component, which renders a form without\n * OSDK data fetching.\n *\n * Uses a discriminated union so that controlled mode (`formState` provided)\n * always requires `onFieldValueChange`; uncontrolled mode omits `formState`\n * (`onFieldValueChange` stays optional).\n * `onSubmit` receives the current form state so callers can access values\n * even in uncontrolled mode.\n */\nexport type BaseFormProps = BaseFormCommonProps &\n (\n | {\n /**\n * The current field values keyed by field key.\n * If provided, the form state is controlled.\n */\n formState: Record<string, unknown>;\n /**\n * Called when a field value changes.\n * Required when the form state is controlled; also fires in\n * uncontrolled mode so callers can observe changes.\n */\n onFieldValueChange: (fieldKey: string, value: unknown) => void;\n }\n | {\n formState?: undefined;\n onFieldValueChange?: (fieldKey: string, value: unknown) => void;\n }\n );\n\ninterface BaseFormCommonProps {\n /** Title shown in the form header. Omit to hide the header. */\n formTitle?: string;\n /** The fields and sections to render, in order. */\n formContent: ReadonlyArray<FormContentItem>;\n /** Called when the form is submitted with valid values. Receives the current form state. */\n onSubmit: (formState: Record<string, unknown>) => Promise<void> | void;\n /** Whether the submit button is disabled. Default `false`. */\n isSubmitDisabled?: boolean;\n /** Whether a submission is in progress. Shows the submit button in a pending state. Default `false`. */\n isPending?: boolean;\n /** Whether the form is loading its fields. Shows a skeleton placeholder. Default `false`. */\n isLoading?: boolean;\n /** Additional CSS class name for the root element. */\n className?: string;\n /** Label for the submit button. Default `\"Submit\"`. */\n submitButtonText?: string;\n /** Visual variant of the submit button. Default `\"primary\"`. */\n submitButtonVariant?: \"primary\" | \"secondary\";\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"ActionFormApi.js","names":[],"sources":["ActionFormApi.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 ActionDefinition,\n ActionEditResponse,\n ActionValidationResponse,\n} from \"@osdk/api\";\n\nimport type {\n FieldKey,\n FieldValueType,\n FormFieldDefinition,\n RendererFieldDefinition,\n} from \"./FormFieldApi.js\";\n\n/**\n * Props for the ActionForm component.\n *\n * A discriminated union ensures that controlled mode (formState provided)\n * always requires onFormStateChange, and uncontrolled mode makes `onFormStateChange` optional\n */\nexport type ActionFormProps<Q extends ActionDefinition<unknown>> =\n | (ActionFormConfigProps<Q> & {\n /**\n * The current form values.\n * If provided, the form state is controlled.\n */\n formState: FormState<Q>;\n /**\n * Called when a field value changes, with a state updater.\n * Required when the form state is controlled; also fires in\n * uncontrolled mode so callers can observe changes.\n */\n onFormStateChange: (\n updater: (prevState: FormState<Q>) => FormState<Q>,\n ) => void;\n })\n | (ActionFormConfigProps<Q> & {\n formState?: undefined;\n onFormStateChange?: (\n updater: (prevState: FormState<Q>) => FormState<Q>,\n ) => void;\n });\n\n/**\n * Determines how the form fields are specified. Exactly one of the three\n * branches may be used:\n *\n * 1. Neither prop — fields are auto-generated from action metadata.\n * 2. `formFieldDefinitions` — a flat list of field definitions.\n * 3. `formContentDefinitions` — fields and sections for richer layout.\n */\ntype ActionFormContentConfig<Q extends ActionDefinition<unknown>> =\n | { formFieldDefinitions?: undefined; formContentDefinitions?: undefined }\n | {\n /** Custom flat list of field definitions. */\n formFieldDefinitions: ReadonlyArray<FormFieldDefinition<Q>>;\n formContentDefinitions?: never;\n }\n | {\n /** Ordered list of fields and sections that define the form layout. */\n formContentDefinitions: ReadonlyArray<ActionFormContentItem<Q>>;\n formFieldDefinitions?: never;\n };\n\ntype ActionFormConfigProps<Q extends ActionDefinition<unknown>> =\n ActionFormBaseConfigProps<Q> & ActionFormContentConfig<Q>;\n\ninterface ActionFormBaseConfigProps<\n Q extends ActionDefinition<unknown>,\n> extends Pick<BaseFormProps, \"formTitle\" | \"isSubmitDisabled\"> {\n /**\n * The OSDK action definition. Its parameters drive the rendered fields\n * and the submission.\n */\n actionDefinition: Q;\n\n /**\n * Whether to show the form title.\n *\n * @default false\n */\n showFormTitle?: boolean;\n\n /**\n * If supplied, this will override the default submit action.\n * By default, the action's applyAction will be called.\n *\n * @param formState all field values when onSubmit is called\n * @param applyAction the function to execute the action\n * @returns a promise of the submission response\n */\n onSubmit?: (\n formState: FormState<Q>,\n applyAction: (\n formState: FormState<Q>,\n ) => Promise<ActionEditResponse | undefined>,\n ) => Promise<unknown> | void;\n\n /**\n * Called when the validation response is returned from a validateOnly submission\n *\n * @param results the validation response\n */\n onValidationResponse?: (results: ActionValidationResponse) => void;\n\n /**\n * Called when the action is successfully executed from a non-validateOnly submission\n *\n * @param results the submission response\n */\n onSuccess?: (results: ActionEditResponse | undefined) => void;\n\n /**\n * Called when action metadata fails to load or form submission fails.\n *\n * @param error the error that occurred\n */\n onError?: (error: FormError) => void;\n}\n\n/**\n * Form values mapping parameter names to their values\n */\nexport type FormState<Q extends ActionDefinition<unknown>> = {\n [K in FieldKey<Q>]?: FieldValueType<Q, K>;\n};\n\n/**\n * Form error discriminated union\n */\nexport type FormError =\n | { type: \"submission\"; error: unknown }\n | { type: \"unknown\"; error: unknown };\n\n/**\n * Generic content item parameterized by its field-definition type.\n * Both the OSDK-typed and renderer-level content items derive from this\n * so their structure cannot diverge.\n */\ntype BaseContentItem<F, S extends BaseSectionDefinition<F>> =\n | { type: \"field\"; definition: F }\n | { type: \"section\"; key: string; definition: S };\n\n/**\n * Generic section definition parameterized by its field-definition type.\n */\ninterface BaseSectionDefinition<F> {\n /** Section heading. */\n title: string;\n /** Optional description below the heading. */\n description?: string;\n /** The fields rendered inside this section. */\n fields: ReadonlyArray<F>;\n /**\n * Whether the section starts collapsed.\n * @default false\n */\n collapsedByDefault?: boolean;\n /**\n * Whether to show the title bar.\n * @default true\n */\n showTitleBar?: boolean;\n /**\n * Number of columns for fields.\n * @default 1\n */\n columnCount?: 1 | 2;\n /**\n * Visual style. `\"box\"` = bordered card, `\"minimal\"` = heading only.\n * @default \"box\"\n */\n style?: \"box\" | \"minimal\";\n}\n\n/**\n * A single item in the ActionForm content array — either a standalone\n * field or a section that groups multiple fields.\n */\nexport type ActionFormContentItem<Q extends ActionDefinition<unknown>> =\n BaseContentItem<FormFieldDefinition<Q>, ActionFormSectionDefinition<Q>>;\n\n/**\n * Configuration for a section in the ActionForm.\n */\nexport interface ActionFormSectionDefinition<\n Q extends ActionDefinition<unknown>,\n> extends BaseSectionDefinition<FormFieldDefinition<Q>> {}\n\n/**\n * A single item in the form content array — either a standalone field\n * or a section that groups multiple fields.\n */\nexport type FormContentItem = BaseContentItem<\n RendererFieldDefinition,\n FormSectionDefinition\n>;\n\n/**\n * Configuration for a form section — a visual group of fields with\n * optional title bar, collapse behavior, and multi-column layout.\n */\nexport interface FormSectionDefinition extends BaseSectionDefinition<RendererFieldDefinition> {}\n\n/**\n * Props for the `BaseForm` component, which renders a form without\n * OSDK data fetching.\n *\n * Uses a discriminated union so that controlled mode (`formState` provided)\n * always requires `onFieldValueChange`; uncontrolled mode omits `formState`\n * (`onFieldValueChange` stays optional).\n * `onSubmit` receives the current form state so callers can access values\n * even in uncontrolled mode.\n */\nexport type BaseFormProps = BaseFormCommonProps &\n (\n | {\n /**\n * The current field values keyed by field key.\n * If provided, the form state is controlled.\n */\n formState: Record<string, unknown>;\n /**\n * Called when a field value changes.\n * Required when the form state is controlled; also fires in\n * uncontrolled mode so callers can observe changes.\n */\n onFieldValueChange: (fieldKey: string, value: unknown) => void;\n }\n | {\n formState?: undefined;\n onFieldValueChange?: (fieldKey: string, value: unknown) => void;\n }\n );\n\n/**\n * A message surfaced in the form footer error indicator.\n * The label is optional — omit it for errors not tied to a specific field.\n */\nexport interface FormErrorEntry {\n label?: string;\n message: string;\n}\n\ninterface BaseFormCommonProps {\n /** Title shown in the form header. Omit to hide the header. */\n formTitle?: string;\n /** The fields and sections to render, in order. */\n formContent: ReadonlyArray<FormContentItem>;\n /** Called when the form is submitted with valid values. Receives the current form state. */\n onSubmit: (formState: Record<string, unknown>) => Promise<void> | void;\n /** Whether the submit button is disabled. Default `false`. */\n isSubmitDisabled?: boolean;\n /** Whether a submission is in progress. Shows the submit button in a pending state. Default `false`. */\n isPending?: boolean;\n /** Whether the form is loading its fields. Shows a skeleton placeholder. Default `false`. */\n isLoading?: boolean;\n /** Additional CSS class name for the root element. */\n className?: string;\n /** Label for the submit button. Default `\"Submit\"`. */\n submitButtonText?: string;\n /** Visual variant of the submit button. Default `\"primary\"`. */\n submitButtonVariant?: \"primary\" | \"secondary\";\n /**\n * External validation errors to display in the footer error indicator\n * alongside field errors. Controlled: the caller owns the array and is\n * responsible for clearing it (e.g. on field change). BaseForm never\n * modifies this value.\n *\n * @default undefined (no external errors)\n */\n validationErrors?: ReadonlyArray<FormErrorEntry>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -37,7 +37,8 @@ export const BaseForm = /*#__PURE__*/memo(function ({
|
|
|
37
37
|
isLoading = false,
|
|
38
38
|
className,
|
|
39
39
|
submitButtonText = "Submit",
|
|
40
|
-
submitButtonVariant = "primary"
|
|
40
|
+
submitButtonVariant = "primary",
|
|
41
|
+
validationErrors
|
|
41
42
|
}) {
|
|
42
43
|
const portalContainerRef = useRef(null);
|
|
43
44
|
const allFieldDefinitions = useMemo(() => flattenFieldDefinitions(formContent), [formContent]);
|
|
@@ -91,12 +92,13 @@ export const BaseForm = /*#__PURE__*/memo(function ({
|
|
|
91
92
|
const labelByFieldKey = useMemo(() => new Map(allFieldDefinitions.map(d => [d.fieldKey, d.label])), [allFieldDefinitions]);
|
|
92
93
|
|
|
93
94
|
// RHF reuses the same errors object reference across renders so we cannot memoize errorEntries
|
|
94
|
-
const
|
|
95
|
+
const fieldErrorEntries = Object.entries(errors).map(([key, entry]) => ({
|
|
95
96
|
label: labelByFieldKey.get(key) ?? key,
|
|
96
|
-
message: entry?.message ?? "
|
|
97
|
+
message: entry?.message ?? "The parameter value is invalid"
|
|
97
98
|
}));
|
|
99
|
+
const errorEntries = validationErrors != null && validationErrors.length > 0 ? [...fieldErrorEntries, ...validationErrors] : fieldErrorEntries;
|
|
98
100
|
const areErrorsPresent = errorEntries.length > 0;
|
|
99
|
-
const buttonErrorMessage = areErrorsPresent ? "Some fields are invalid" : submissionErrorMessage;
|
|
101
|
+
const buttonErrorMessage = areErrorsPresent ? fieldErrorEntries.length > 0 ? "Some fields are invalid" : "Submission criteria not met" : submissionErrorMessage;
|
|
100
102
|
return /*#__PURE__*/React.createElement("form", {
|
|
101
103
|
ref: portalContainerRef,
|
|
102
104
|
className: classNames(styles.osdkForm, className)
|
|
@@ -233,7 +235,7 @@ function ErrorIndicator({
|
|
|
233
235
|
}), count === 1 ? "1 issue" : `${count} issues`)), /*#__PURE__*/React.createElement(Tooltip.Portal, null, /*#__PURE__*/React.createElement(Tooltip.Positioner, null, /*#__PURE__*/React.createElement(Tooltip.Popup, null, /*#__PURE__*/React.createElement(Tooltip.Arrow, null), /*#__PURE__*/React.createElement("ul", {
|
|
234
236
|
className: styles.osdkFormErrorList
|
|
235
237
|
}, errorEntries.map(entry => /*#__PURE__*/React.createElement("li", {
|
|
236
|
-
key: entry.label
|
|
237
|
-
}, /*#__PURE__*/React.createElement("strong", null, entry.label, ":"),
|
|
238
|
+
key: `${entry.label ?? ""}:${entry.message}`
|
|
239
|
+
}, entry.label != null && /*#__PURE__*/React.createElement("strong", null, entry.label, ": "), entry.message)))))));
|
|
238
240
|
}
|
|
239
241
|
//# sourceMappingURL=BaseForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseForm.js","names":["Error","ErrorIcon","classNames","React","memo","useCallback","useMemo","useRef","useState","useForm","ActionButton","SkeletonBar","Tooltip","useAsyncAction","FieldBridge","FormHeader","FormSection","styles","BaseForm","formTitle","formContent","formState","controlledFormState","onFieldValueChange","onSubmit","isSubmitDisabled","isPending","isLoading","className","submitButtonText","submitButtonVariant","portalContainerRef","allFieldDefinitions","flattenFieldDefinitions","defaultValues","buildDefaultValues","control","trigger","getValues","errors","mode","values","hasAttemptedSubmit","setHasAttemptedSubmit","isSubmitting","error","submissionError","execute","executeSubmit","clearError","submissionErrorMessage","message","undefined","submitForm","isValid","handleFieldChange","fieldKey","value","labelByFieldKey","Map","map","d","label","errorEntries","Object","entries","key","entry","get","areErrorsPresent","length","buttonErrorMessage","createElement","ref","osdkForm","title","role","osdkFormFields","FORM_SKELETON","item","type","definition","fieldDef","onExternalChange","portalContainer","sectionErrorCount","fields","reduce","count","field","errorCount","osdkFormFooter","ErrorIndicator","osdkFormSubmitButton","SubmitButton","errorMessage","buttonText","buttonVariant","onClick","result","push","SKELETON_FIELD_COUNT","Array","from","_","i","osdkFormSkeletonField","osdkFormSkeletonLabel","osdkFormSkeletonInput","fieldDefinitions","def","props","fieldComponentProps","defaultValue","buttonLabel","button","variant","disabled","Root","defaultOpen","Trigger","render","osdkTooltipTriggerWrapper","Portal","Positioner","Popup","Arrow","osdkFormErrorIndicator","size","osdkFormErrorList"],"sources":["BaseForm.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 { Error as ErrorIcon } from \"@blueprintjs/icons\";\nimport classNames from \"classnames\";\nimport React, { memo, useCallback, useMemo, useRef, useState } from \"react\";\nimport { useForm } from \"react-hook-form\";\n\nimport { ActionButton } from \"../base-components/action-button/ActionButton.js\";\nimport { SkeletonBar } from \"../base-components/skeleton/SkeletonBar.js\";\nimport { Tooltip } from \"../base-components/tooltip/Tooltip.js\";\nimport { useAsyncAction } from \"../shared/hooks/useAsyncAction.js\";\nimport type { BaseFormProps, FormContentItem } from \"./ActionFormApi.js\";\nimport { FieldBridge } from \"./fields/FieldBridge.js\";\nimport type { RendererFieldDefinition } from \"./FormFieldApi.js\";\nimport { FormHeader } from \"./FormHeader.js\";\nimport { FormSection } from \"./FormSection.js\";\n\nimport styles from \"./BaseForm.module.css\";\n\nexport const BaseForm: React.FC<BaseFormProps> = memo(function BaseFormFn({\n formTitle,\n formContent,\n formState: controlledFormState,\n onFieldValueChange,\n onSubmit,\n isSubmitDisabled = false,\n isPending = false,\n isLoading = false,\n className,\n submitButtonText = \"Submit\",\n submitButtonVariant = \"primary\",\n}: BaseFormProps): React.ReactElement {\n const portalContainerRef = useRef<HTMLFormElement>(null);\n const isControlled = controlledFormState != null;\n\n const allFieldDefinitions = useMemo(\n () => flattenFieldDefinitions(formContent),\n [formContent],\n );\n\n const defaultValues = useMemo(\n () => buildDefaultValues(allFieldDefinitions),\n [allFieldDefinitions],\n );\n\n const {\n control,\n trigger,\n getValues,\n formState: { errors },\n } = useForm<Record<string, unknown>>({\n // Validate on blur first, then revalidate on change after the first\n // error. This gives the user a chance to finish typing before seeing\n // errors, while staying responsive once an error is surfaced.\n mode: \"onTouched\",\n ...(isControlled ? { values: controlledFormState } : { defaultValues }),\n });\n\n const [hasAttemptedSubmit, setHasAttemptedSubmit] = useState(false);\n\n const {\n isPending: isSubmitting,\n error: submissionError,\n execute: executeSubmit,\n clearError,\n } = useAsyncAction(onSubmit);\n const submissionErrorMessage =\n submissionError != null\n ? submissionError instanceof Error\n ? submissionError.message\n : // TODO: provide better error message\n \"Submission failed\"\n : undefined;\n\n const submitForm = useCallback(async () => {\n setHasAttemptedSubmit(true);\n\n const isValid = await trigger();\n if (!isValid) {\n return;\n }\n\n // In controlled mode, always submit the controlled state, not RHF's\n // internal state. Between a user keystroke and the parent re-rendering,\n // RHF's store may hold the user-typed value rather than the parent's\n // value. Using controlledFormState directly preserves the existing\n // guarantee that controlled mode submits the parent's state.\n await executeSubmit(controlledFormState ?? getValues());\n }, [trigger, executeSubmit, controlledFormState, getValues]);\n\n const handleFieldChange = useCallback(\n (fieldKey: string, value: unknown) => {\n clearError();\n onFieldValueChange?.(fieldKey, value);\n },\n [clearError, onFieldValueChange],\n );\n\n const labelByFieldKey = useMemo(\n () => new Map(allFieldDefinitions.map((d) => [d.fieldKey, d.label])),\n [allFieldDefinitions],\n );\n\n // RHF reuses the same errors object reference across renders so we cannot memoize errorEntries\n const errorEntries = Object.entries(errors).map(([key, entry]) => ({\n label: labelByFieldKey.get(key) ?? key,\n message: entry?.message ?? \"Invalid\",\n }));\n const areErrorsPresent = errorEntries.length > 0;\n const buttonErrorMessage = areErrorsPresent\n ? \"Some fields are invalid\"\n : submissionErrorMessage;\n const isFormPending = isPending || isSubmitting;\n const isSubmitButtonDisabled =\n isSubmitDisabled || (hasAttemptedSubmit && areErrorsPresent);\n\n return (\n <form\n ref={portalContainerRef}\n className={classNames(styles.osdkForm, className)}\n // Workshop widgets can run in iframes without `allow-forms`, where\n // native form submission is blocked. Keep the form landmark, but do not\n // wire any form-level submit handlers; the submit button invokes our\n // JavaScript submit path directly.\n >\n {formTitle != null && <FormHeader title={formTitle} />}\n {isLoading && allFieldDefinitions.length === 0 && (\n <div\n role=\"status\"\n aria-label=\"Loading form fields\"\n className={styles.osdkFormFields}\n >\n {FORM_SKELETON}\n </div>\n )}\n <div className={styles.osdkFormFields}>\n {formContent.map((item) => {\n if (item.type === \"field\") {\n return (\n <FieldBridge\n key={item.definition.fieldKey}\n fieldDef={item.definition}\n control={control}\n onExternalChange={handleFieldChange}\n portalContainer={portalContainerRef}\n />\n );\n }\n const sectionErrorCount = item.definition.fields.reduce(\n (count, field) => count + (errors[field.fieldKey] != null ? 1 : 0),\n 0,\n );\n return (\n <FormSection\n key={item.key}\n definition={item.definition}\n errorCount={sectionErrorCount}\n >\n {item.definition.fields.map((fieldDef) => (\n <FieldBridge\n key={fieldDef.fieldKey}\n fieldDef={fieldDef}\n control={control}\n onExternalChange={handleFieldChange}\n portalContainer={portalContainerRef}\n />\n ))}\n </FormSection>\n );\n })}\n </div>\n <div className={styles.osdkFormFooter}>\n <ErrorIndicator errorEntries={errorEntries} />\n <div className={styles.osdkFormSubmitButton}>\n <SubmitButton\n isPending={isFormPending}\n isSubmitDisabled={isSubmitButtonDisabled}\n errorMessage={buttonErrorMessage}\n buttonText={submitButtonText}\n buttonVariant={submitButtonVariant}\n onClick={submitForm}\n />\n </div>\n </div>\n </form>\n );\n});\n\n/**\n * Extracts all RendererFieldDefinitions from formContent, flattening\n * section fields into a single array. RHF sees a flat field namespace\n * regardless of visual grouping, so this is used to build default values\n * and the field-key-to-label map for error display.\n */\nfunction flattenFieldDefinitions(\n formContent: ReadonlyArray<FormContentItem>,\n): ReadonlyArray<RendererFieldDefinition> {\n const result: RendererFieldDefinition[] = [];\n for (const item of formContent) {\n if (item.type === \"field\") {\n result.push(item.definition);\n } else {\n for (const fieldDef of item.definition.fields) {\n result.push(fieldDef);\n }\n }\n }\n return result;\n}\n\nconst SKELETON_FIELD_COUNT = 3;\n\n// Mimics the label + input layout of real form fields.\nconst FORM_SKELETON = Array.from({ length: SKELETON_FIELD_COUNT }, (_, i) => (\n <div key={i} className={styles.osdkFormSkeletonField}>\n <SkeletonBar className={styles.osdkFormSkeletonLabel} />\n <SkeletonBar className={styles.osdkFormSkeletonInput} />\n </div>\n));\n\nfunction buildDefaultValues(\n fieldDefinitions: ReadonlyArray<RendererFieldDefinition>,\n): Record<string, unknown> {\n const values: Record<string, unknown> = {};\n for (const def of fieldDefinitions) {\n const props: Record<string, unknown> = def.fieldComponentProps;\n if (\"defaultValue\" in props) {\n values[def.fieldKey] = props.defaultValue;\n }\n }\n return values;\n}\n\ninterface ErrorEntry {\n label: string;\n message: string;\n}\n\ninterface SubmitButtonProps {\n isPending: boolean;\n isSubmitDisabled: boolean;\n errorMessage: string | undefined;\n buttonText: string;\n buttonVariant: \"primary\" | \"secondary\";\n onClick: () => void;\n}\n\nconst SubmitButton = memo(function SubmitButtonFn({\n isPending,\n isSubmitDisabled,\n errorMessage,\n buttonText,\n buttonVariant,\n onClick,\n}: SubmitButtonProps): React.ReactElement {\n const buttonLabel = isPending ? \"Submitting\\u2026\" : buttonText;\n const button = (\n <ActionButton\n type=\"button\"\n variant={buttonVariant}\n disabled={isSubmitDisabled || isPending}\n onClick={onClick}\n >\n {buttonLabel}\n </ActionButton>\n );\n\n if (errorMessage == null) {\n return button;\n }\n\n return (\n <Tooltip.Root defaultOpen={true}>\n <Tooltip.Trigger\n render={<span className={styles.osdkTooltipTriggerWrapper} />}\n >\n {button}\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Positioner>\n <Tooltip.Popup>\n <Tooltip.Arrow />\n {errorMessage}\n </Tooltip.Popup>\n </Tooltip.Positioner>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n});\n\ninterface ErrorIndicatorProps {\n errorEntries: ReadonlyArray<ErrorEntry>;\n}\n\n// memo omitted: errorEntries is always a new array (RHF reuses the same errors ref)\nfunction ErrorIndicator({\n errorEntries,\n}: ErrorIndicatorProps): React.ReactElement | null {\n if (errorEntries.length === 0) {\n return null;\n }\n\n const count = errorEntries.length;\n\n return (\n <Tooltip.Root>\n <Tooltip.Trigger>\n <span className={styles.osdkFormErrorIndicator}>\n <ErrorIcon size={14} />\n {count === 1 ? \"1 issue\" : `${count} issues`}\n </span>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Positioner>\n <Tooltip.Popup>\n <Tooltip.Arrow />\n <ul className={styles.osdkFormErrorList}>\n {errorEntries.map((entry) => (\n <li key={entry.label}>\n <strong>{entry.label}:</strong> {entry.message}\n </li>\n ))}\n </ul>\n </Tooltip.Popup>\n </Tooltip.Positioner>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,IAAIC,SAAS,QAAQ,oBAAoB;AACvD,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAAIC,IAAI,EAAEC,WAAW,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAC3E,SAASC,OAAO,QAAQ,iBAAiB;AAEzC,SAASC,YAAY,QAAQ,kDAAkD;AAC/E,SAASC,WAAW,QAAQ,4CAA4C;AACxE,SAASC,OAAO,QAAQ,uCAAuC;AAC/D,SAASC,cAAc,QAAQ,mCAAmC;AAElE,SAASC,WAAW,QAAQ,yBAAyB;AAErD,S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AAG,SAAS,GAAG,GAAGA,KAAK,SAC/B,CACS,CAAC,eAClBrF,KAAA,CAAAqE,aAAA,CAAC5D,OAAO,CAAC+G,MAAM,qBACbxH,KAAA,CAAAqE,aAAA,CAAC5D,OAAO,CAACgH,UAAU,qBACjBzH,KAAA,CAAAqE,aAAA,CAAC5D,OAAO,CAACiH,KAAK,qBACZ1H,KAAA,CAAAqE,aAAA,CAAC5D,OAAO,CAACkH,KAAK,MAAE,CAAC,eACjB3H,KAAA,CAAAqE,aAAA;IAAI5C,SAAS,EAAEX,MAAM,CAACgH;EAAkB,GACrClE,YAAY,CAACH,GAAG,CAAEO,KAAK,iBACtBhE,KAAA,CAAAqE,aAAA;IAAIN,GAAG,EAAEC,KAAK,CAACL;EAAM,gBACnB3D,KAAA,CAAAqE,aAAA,iBAASL,KAAK,CAACL,KAAK,EAAC,GAAS,CAAC,KAAC,EAACK,KAAK,CAAChB,OACrC,CACL,CACC,CACS,CACG,CACN,CACJ,CAAC;AAEnB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"BaseForm.js","names":["Error","ErrorIcon","classNames","React","memo","useCallback","useMemo","useRef","useState","useForm","ActionButton","SkeletonBar","Tooltip","useAsyncAction","FieldBridge","FormHeader","FormSection","styles","BaseForm","formTitle","formContent","formState","controlledFormState","onFieldValueChange","onSubmit","isSubmitDisabled","isPending","isLoading","className","submitButtonText","submitButtonVariant","validationErrors","portalContainerRef","allFieldDefinitions","flattenFieldDefinitions","defaultValues","buildDefaultValues","control","trigger","getValues","errors","mode","values","hasAttemptedSubmit","setHasAttemptedSubmit","isSubmitting","error","submissionError","execute","executeSubmit","clearError","submissionErrorMessage","message","undefined","submitForm","isValid","handleFieldChange","fieldKey","value","labelByFieldKey","Map","map","d","label","fieldErrorEntries","Object","entries","key","entry","get","errorEntries","length","areErrorsPresent","buttonErrorMessage","createElement","ref","osdkForm","title","role","osdkFormFields","FORM_SKELETON","item","type","definition","fieldDef","onExternalChange","portalContainer","sectionErrorCount","fields","reduce","count","field","errorCount","osdkFormFooter","ErrorIndicator","osdkFormSubmitButton","SubmitButton","errorMessage","buttonText","buttonVariant","onClick","result","push","SKELETON_FIELD_COUNT","Array","from","_","i","osdkFormSkeletonField","osdkFormSkeletonLabel","osdkFormSkeletonInput","fieldDefinitions","def","props","fieldComponentProps","defaultValue","buttonLabel","button","variant","disabled","Root","defaultOpen","Trigger","render","osdkTooltipTriggerWrapper","Portal","Positioner","Popup","Arrow","osdkFormErrorIndicator","size","osdkFormErrorList"],"sources":["BaseForm.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 { Error as ErrorIcon } from \"@blueprintjs/icons\";\nimport classNames from \"classnames\";\nimport React, { memo, useCallback, useMemo, useRef, useState } from \"react\";\nimport { useForm } from \"react-hook-form\";\n\nimport { ActionButton } from \"../base-components/action-button/ActionButton.js\";\nimport { SkeletonBar } from \"../base-components/skeleton/SkeletonBar.js\";\nimport { Tooltip } from \"../base-components/tooltip/Tooltip.js\";\nimport { useAsyncAction } from \"../shared/hooks/useAsyncAction.js\";\nimport type {\n BaseFormProps,\n FormErrorEntry,\n FormContentItem,\n} from \"./ActionFormApi.js\";\nimport { FieldBridge } from \"./fields/FieldBridge.js\";\nimport type { RendererFieldDefinition } from \"./FormFieldApi.js\";\nimport { FormHeader } from \"./FormHeader.js\";\nimport { FormSection } from \"./FormSection.js\";\n\nimport styles from \"./BaseForm.module.css\";\n\nexport const BaseForm: React.FC<BaseFormProps> = memo(function BaseFormFn({\n formTitle,\n formContent,\n formState: controlledFormState,\n onFieldValueChange,\n onSubmit,\n isSubmitDisabled = false,\n isPending = false,\n isLoading = false,\n className,\n submitButtonText = \"Submit\",\n submitButtonVariant = \"primary\",\n validationErrors,\n}: BaseFormProps): React.ReactElement {\n const portalContainerRef = useRef<HTMLFormElement>(null);\n const isControlled = controlledFormState != null;\n\n const allFieldDefinitions = useMemo(\n () => flattenFieldDefinitions(formContent),\n [formContent],\n );\n\n const defaultValues = useMemo(\n () => buildDefaultValues(allFieldDefinitions),\n [allFieldDefinitions],\n );\n\n const {\n control,\n trigger,\n getValues,\n formState: { errors },\n } = useForm<Record<string, unknown>>({\n // Validate on blur first, then revalidate on change after the first\n // error. This gives the user a chance to finish typing before seeing\n // errors, while staying responsive once an error is surfaced.\n mode: \"onTouched\",\n ...(isControlled ? { values: controlledFormState } : { defaultValues }),\n });\n\n const [hasAttemptedSubmit, setHasAttemptedSubmit] = useState(false);\n\n const {\n isPending: isSubmitting,\n error: submissionError,\n execute: executeSubmit,\n clearError,\n } = useAsyncAction(onSubmit);\n const submissionErrorMessage =\n submissionError != null\n ? submissionError instanceof Error\n ? submissionError.message\n : // TODO: provide better error message\n \"Submission failed\"\n : undefined;\n\n const submitForm = useCallback(async () => {\n setHasAttemptedSubmit(true);\n\n const isValid = await trigger();\n if (!isValid) {\n return;\n }\n\n // In controlled mode, always submit the controlled state, not RHF's\n // internal state. Between a user keystroke and the parent re-rendering,\n // RHF's store may hold the user-typed value rather than the parent's\n // value. Using controlledFormState directly preserves the existing\n // guarantee that controlled mode submits the parent's state.\n await executeSubmit(controlledFormState ?? getValues());\n }, [trigger, executeSubmit, controlledFormState, getValues]);\n\n const handleFieldChange = useCallback(\n (fieldKey: string, value: unknown) => {\n clearError();\n onFieldValueChange?.(fieldKey, value);\n },\n [clearError, onFieldValueChange],\n );\n\n const labelByFieldKey = useMemo(\n () => new Map(allFieldDefinitions.map((d) => [d.fieldKey, d.label])),\n [allFieldDefinitions],\n );\n\n // RHF reuses the same errors object reference across renders so we cannot memoize errorEntries\n const fieldErrorEntries: FormErrorEntry[] = Object.entries(errors).map(\n ([key, entry]) => ({\n label: labelByFieldKey.get(key) ?? key,\n message: entry?.message ?? \"The parameter value is invalid\",\n }),\n );\n const errorEntries: ReadonlyArray<FormErrorEntry> =\n validationErrors != null && validationErrors.length > 0\n ? [...fieldErrorEntries, ...validationErrors]\n : fieldErrorEntries;\n const areErrorsPresent = errorEntries.length > 0;\n const buttonErrorMessage = areErrorsPresent\n ? fieldErrorEntries.length > 0\n ? \"Some fields are invalid\"\n : \"Submission criteria not met\"\n : submissionErrorMessage;\n const isFormPending = isPending || isSubmitting;\n const isSubmitButtonDisabled =\n isSubmitDisabled || (hasAttemptedSubmit && areErrorsPresent);\n\n return (\n <form\n ref={portalContainerRef}\n className={classNames(styles.osdkForm, className)}\n // Workshop widgets can run in iframes without `allow-forms`, where\n // native form submission is blocked. Keep the form landmark, but do not\n // wire any form-level submit handlers; the submit button invokes our\n // JavaScript submit path directly.\n >\n {formTitle != null && <FormHeader title={formTitle} />}\n {isLoading && allFieldDefinitions.length === 0 && (\n <div\n role=\"status\"\n aria-label=\"Loading form fields\"\n className={styles.osdkFormFields}\n >\n {FORM_SKELETON}\n </div>\n )}\n <div className={styles.osdkFormFields}>\n {formContent.map((item) => {\n if (item.type === \"field\") {\n return (\n <FieldBridge\n key={item.definition.fieldKey}\n fieldDef={item.definition}\n control={control}\n onExternalChange={handleFieldChange}\n portalContainer={portalContainerRef}\n />\n );\n }\n const sectionErrorCount = item.definition.fields.reduce(\n (count, field) => count + (errors[field.fieldKey] != null ? 1 : 0),\n 0,\n );\n return (\n <FormSection\n key={item.key}\n definition={item.definition}\n errorCount={sectionErrorCount}\n >\n {item.definition.fields.map((fieldDef) => (\n <FieldBridge\n key={fieldDef.fieldKey}\n fieldDef={fieldDef}\n control={control}\n onExternalChange={handleFieldChange}\n portalContainer={portalContainerRef}\n />\n ))}\n </FormSection>\n );\n })}\n </div>\n <div className={styles.osdkFormFooter}>\n <ErrorIndicator errorEntries={errorEntries} />\n <div className={styles.osdkFormSubmitButton}>\n <SubmitButton\n isPending={isFormPending}\n isSubmitDisabled={isSubmitButtonDisabled}\n errorMessage={buttonErrorMessage}\n buttonText={submitButtonText}\n buttonVariant={submitButtonVariant}\n onClick={submitForm}\n />\n </div>\n </div>\n </form>\n );\n});\n\n/**\n * Extracts all RendererFieldDefinitions from formContent, flattening\n * section fields into a single array. RHF sees a flat field namespace\n * regardless of visual grouping, so this is used to build default values\n * and the field-key-to-label map for error display.\n */\nfunction flattenFieldDefinitions(\n formContent: ReadonlyArray<FormContentItem>,\n): ReadonlyArray<RendererFieldDefinition> {\n const result: RendererFieldDefinition[] = [];\n for (const item of formContent) {\n if (item.type === \"field\") {\n result.push(item.definition);\n } else {\n for (const fieldDef of item.definition.fields) {\n result.push(fieldDef);\n }\n }\n }\n return result;\n}\n\nconst SKELETON_FIELD_COUNT = 3;\n\n// Mimics the label + input layout of real form fields.\nconst FORM_SKELETON = Array.from({ length: SKELETON_FIELD_COUNT }, (_, i) => (\n <div key={i} className={styles.osdkFormSkeletonField}>\n <SkeletonBar className={styles.osdkFormSkeletonLabel} />\n <SkeletonBar className={styles.osdkFormSkeletonInput} />\n </div>\n));\n\nfunction buildDefaultValues(\n fieldDefinitions: ReadonlyArray<RendererFieldDefinition>,\n): Record<string, unknown> {\n const values: Record<string, unknown> = {};\n for (const def of fieldDefinitions) {\n const props: Record<string, unknown> = def.fieldComponentProps;\n if (\"defaultValue\" in props) {\n values[def.fieldKey] = props.defaultValue;\n }\n }\n return values;\n}\n\ninterface SubmitButtonProps {\n isPending: boolean;\n isSubmitDisabled: boolean;\n errorMessage: string | undefined;\n buttonText: string;\n buttonVariant: \"primary\" | \"secondary\";\n onClick: () => void;\n}\n\nconst SubmitButton = memo(function SubmitButtonFn({\n isPending,\n isSubmitDisabled,\n errorMessage,\n buttonText,\n buttonVariant,\n onClick,\n}: SubmitButtonProps): React.ReactElement {\n const buttonLabel = isPending ? \"Submitting\\u2026\" : buttonText;\n const button = (\n <ActionButton\n type=\"button\"\n variant={buttonVariant}\n disabled={isSubmitDisabled || isPending}\n onClick={onClick}\n >\n {buttonLabel}\n </ActionButton>\n );\n\n if (errorMessage == null) {\n return button;\n }\n\n return (\n <Tooltip.Root defaultOpen={true}>\n <Tooltip.Trigger\n render={<span className={styles.osdkTooltipTriggerWrapper} />}\n >\n {button}\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Positioner>\n <Tooltip.Popup>\n <Tooltip.Arrow />\n {errorMessage}\n </Tooltip.Popup>\n </Tooltip.Positioner>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n});\n\ninterface ErrorIndicatorProps {\n errorEntries: ReadonlyArray<FormErrorEntry>;\n}\n\n// memo omitted: errorEntries is always a new array (RHF reuses the same errors ref)\nfunction ErrorIndicator({\n errorEntries,\n}: ErrorIndicatorProps): React.ReactElement | null {\n if (errorEntries.length === 0) {\n return null;\n }\n\n const count = errorEntries.length;\n\n return (\n <Tooltip.Root>\n <Tooltip.Trigger>\n <span className={styles.osdkFormErrorIndicator}>\n <ErrorIcon size={14} />\n {count === 1 ? \"1 issue\" : `${count} issues`}\n </span>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Positioner>\n <Tooltip.Popup>\n <Tooltip.Arrow />\n <ul className={styles.osdkFormErrorList}>\n {errorEntries.map((entry) => (\n <li key={`${entry.label ?? \"\"}:${entry.message}`}>\n {entry.label != null && <strong>{entry.label}: </strong>}\n {entry.message}\n </li>\n ))}\n </ul>\n </Tooltip.Popup>\n </Tooltip.Positioner>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,KAAK,IAAIC,SAAS,QAAQ,oBAAoB;AACvD,OAAOC,UAAU,MAAM,YAAY;AACnC,OAAOC,KAAK,IAAIC,IAAI,EAAEC,WAAW,EAAEC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@
|
|
|
1
|
-
{"version":3,"file":"action-form.js","names":["ActionForm","_ActionForm","withOsdkMetrics","BaseForm"],"sources":["action-form.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 { ActionForm as _ActionForm } from \"../action-form/ActionForm.js\";\nimport { withOsdkMetrics } from \"../util/withOsdkMetrics.js\";\nexport const ActionForm: typeof _ActionForm = withOsdkMetrics(\n _ActionForm,\n \"ActionForm\",\n);\nexport type {\n ActionFormContentItem,\n ActionFormProps,\n ActionFormSectionDefinition,\n BaseFormProps,\n FormContentItem,\n FormError,\n FormSectionDefinition,\n FormState,\n} from \"../action-form/ActionFormApi.js\";\nexport { BaseForm } from \"../action-form/BaseForm.js\";\nexport type {\n ActionParameters,\n BaseFormFieldProps,\n CustomFieldProps,\n DropdownFieldProps,\n FieldComponent,\n FieldValueType,\n FilePickerProps,\n FormFieldDefinition,\n FormFieldPropsByType,\n NumberInputFieldProps,\n ObjectSelectFieldProps,\n ObjectSetFieldProps,\n Option,\n PortalContainer,\n RadioButtonsFieldProps,\n RendererFieldDefinition,\n TextAreaFieldProps,\n TextInputFieldProps,\n UnsupportedFieldProps,\n ValidationError,\n} from \"../action-form/FormFieldApi.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,IAAIC,WAAW,QAAQ,8BAA8B;AACxE,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,OAAO,MAAMF,UAA8B,GAAGE,eAAe,CAC3DD,WAAW,EACX,YACF,CAAC;
|
|
1
|
+
{"version":3,"file":"action-form.js","names":["ActionForm","_ActionForm","withOsdkMetrics","BaseForm"],"sources":["action-form.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 { ActionForm as _ActionForm } from \"../action-form/ActionForm.js\";\nimport { withOsdkMetrics } from \"../util/withOsdkMetrics.js\";\nexport const ActionForm: typeof _ActionForm = withOsdkMetrics(\n _ActionForm,\n \"ActionForm\",\n);\nexport type {\n ActionFormContentItem,\n ActionFormProps,\n ActionFormSectionDefinition,\n BaseFormProps,\n FormErrorEntry,\n FormContentItem,\n FormError,\n FormSectionDefinition,\n FormState,\n} from \"../action-form/ActionFormApi.js\";\nexport { BaseForm } from \"../action-form/BaseForm.js\";\nexport type {\n ActionParameters,\n BaseFormFieldProps,\n CustomFieldProps,\n DropdownFieldProps,\n FieldComponent,\n FieldValueType,\n FilePickerProps,\n FormFieldDefinition,\n FormFieldPropsByType,\n NumberInputFieldProps,\n ObjectSelectFieldProps,\n ObjectSetFieldProps,\n Option,\n PortalContainer,\n RadioButtonsFieldProps,\n RendererFieldDefinition,\n TextAreaFieldProps,\n TextInputFieldProps,\n UnsupportedFieldProps,\n ValidationError,\n} from \"../action-form/FormFieldApi.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,UAAU,IAAIC,WAAW,QAAQ,8BAA8B;AACxE,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,OAAO,MAAMF,UAA8B,GAAGE,eAAe,CAC3DD,WAAW,EACX,YACF,CAAC;AAYD,SAASE,QAAQ,QAAQ,4BAA4B","ignoreList":[]}
|
|
@@ -35,6 +35,8 @@ export const ActionForm = Stable.ActionForm;
|
|
|
35
35
|
|
|
36
36
|
/** @deprecated Import from `@osdk/react-components/action-form` instead. */
|
|
37
37
|
|
|
38
|
+
/** @deprecated Import from `@osdk/react-components/action-form` instead. */
|
|
39
|
+
|
|
38
40
|
/** @deprecated Import from `@osdk/react-components/action-form` instead. */
|
|
39
41
|
export const BaseForm = Stable.BaseForm;
|
|
40
42
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-form.js","names":["Stable","ActionForm","BaseForm"],"sources":["action-form.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as Api from \"@osdk/api\";\n\nimport type * as FormFieldApi from \"../../action-form/FormFieldApi.js\";\nimport * as Stable from \"../action-form.js\";\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport const ActionForm: typeof Stable.ActionForm = Stable.ActionForm;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type ActionFormContentItem<Q extends Api.ActionDefinition<unknown>> =\n Stable.ActionFormContentItem<Q>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type ActionFormProps<Q extends Api.ActionDefinition<unknown>> =\n Stable.ActionFormProps<Q>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type ActionFormSectionDefinition<\n Q extends Api.ActionDefinition<unknown>,\n> = Stable.ActionFormSectionDefinition<Q>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type BaseFormProps = Stable.BaseFormProps;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FormContentItem = Stable.FormContentItem;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FormError = Stable.FormError;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FormSectionDefinition = Stable.FormSectionDefinition;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FormState<Q extends Api.ActionDefinition<unknown>> =\n Stable.FormState<Q>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport const BaseForm: typeof Stable.BaseForm = Stable.BaseForm;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type ActionParameters<Q extends Api.ActionDefinition<unknown>> =\n Stable.ActionParameters<Q>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type BaseFormFieldProps<V> = Stable.BaseFormFieldProps<V>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type CustomFieldProps<V> = Stable.CustomFieldProps<V>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type DropdownFieldProps<\n V,\n Multiple extends boolean = false,\n> = Stable.DropdownFieldProps<V, Multiple>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FieldComponent = Stable.FieldComponent;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FieldValueType<\n Q extends Api.ActionDefinition<unknown>,\n K extends keyof Stable.ActionParameters<Q> = keyof Stable.ActionParameters<Q>,\n> = Stable.FieldValueType<Q, K>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FilePickerProps = Stable.FilePickerProps;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FormFieldDefinition<\n Q extends Api.ActionDefinition<unknown>,\n K extends FormFieldApi.FieldKey<Q> = FormFieldApi.FieldKey<Q>,\n> = Stable.FormFieldDefinition<Q, K>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FormFieldPropsByType = Stable.FormFieldPropsByType;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type NumberInputFieldProps = Stable.NumberInputFieldProps;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type ObjectSelectFieldProps<\n Q extends Api.ObjectTypeDefinition = Api.ObjectTypeDefinition,\n> = Stable.ObjectSelectFieldProps<Q>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type ObjectSetFieldProps<T extends Api.ObjectTypeDefinition> =\n Stable.ObjectSetFieldProps<T>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type Option<V> = Stable.Option<V>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type PortalContainer = Stable.PortalContainer;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type RadioButtonsFieldProps<V> = Stable.RadioButtonsFieldProps<V>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type RendererFieldDefinition = Stable.RendererFieldDefinition;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type TextAreaFieldProps = Stable.TextAreaFieldProps;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type TextInputFieldProps = Stable.TextInputFieldProps;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type UnsupportedFieldProps = Stable.UnsupportedFieldProps;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type ValidationError = Stable.ValidationError;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,OAAO,KAAKA,MAAM,MAAM,mBAAmB;;AAE3C;AACA,OAAO,MAAMC,UAAoC,GAAGD,MAAM,CAACC,UAAU;;AAErE;;AAIA;;AAIA;;AAKA;;AAGA;;AAGA;;AAGA;;AAGA;;AAIA;AACA,OAAO,MAAMC,QAAgC,GAAGF,MAAM,CAACE,QAAQ;;AAE/D;;AAIA;;AAGA;;AAGA;;AAMA;;AAGA;;AAMA;;AAGA;;AAMA;;AAGA;;AAGA;;AAKA;;AAIA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"action-form.js","names":["Stable","ActionForm","BaseForm"],"sources":["action-form.ts"],"sourcesContent":["/*\n * Copyright 2026 Palantir Technologies, Inc. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as Api from \"@osdk/api\";\n\nimport type * as FormFieldApi from \"../../action-form/FormFieldApi.js\";\nimport * as Stable from \"../action-form.js\";\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport const ActionForm: typeof Stable.ActionForm = Stable.ActionForm;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type ActionFormContentItem<Q extends Api.ActionDefinition<unknown>> =\n Stable.ActionFormContentItem<Q>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type ActionFormProps<Q extends Api.ActionDefinition<unknown>> =\n Stable.ActionFormProps<Q>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type ActionFormSectionDefinition<\n Q extends Api.ActionDefinition<unknown>,\n> = Stable.ActionFormSectionDefinition<Q>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type BaseFormProps = Stable.BaseFormProps;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FormContentItem = Stable.FormContentItem;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FormError = Stable.FormError;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FormErrorEntry = Stable.FormErrorEntry;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FormSectionDefinition = Stable.FormSectionDefinition;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FormState<Q extends Api.ActionDefinition<unknown>> =\n Stable.FormState<Q>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport const BaseForm: typeof Stable.BaseForm = Stable.BaseForm;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type ActionParameters<Q extends Api.ActionDefinition<unknown>> =\n Stable.ActionParameters<Q>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type BaseFormFieldProps<V> = Stable.BaseFormFieldProps<V>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type CustomFieldProps<V> = Stable.CustomFieldProps<V>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type DropdownFieldProps<\n V,\n Multiple extends boolean = false,\n> = Stable.DropdownFieldProps<V, Multiple>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FieldComponent = Stable.FieldComponent;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FieldValueType<\n Q extends Api.ActionDefinition<unknown>,\n K extends keyof Stable.ActionParameters<Q> = keyof Stable.ActionParameters<Q>,\n> = Stable.FieldValueType<Q, K>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FilePickerProps = Stable.FilePickerProps;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FormFieldDefinition<\n Q extends Api.ActionDefinition<unknown>,\n K extends FormFieldApi.FieldKey<Q> = FormFieldApi.FieldKey<Q>,\n> = Stable.FormFieldDefinition<Q, K>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type FormFieldPropsByType = Stable.FormFieldPropsByType;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type NumberInputFieldProps = Stable.NumberInputFieldProps;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type ObjectSelectFieldProps<\n Q extends Api.ObjectTypeDefinition = Api.ObjectTypeDefinition,\n> = Stable.ObjectSelectFieldProps<Q>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type ObjectSetFieldProps<T extends Api.ObjectTypeDefinition> =\n Stable.ObjectSetFieldProps<T>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type Option<V> = Stable.Option<V>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type PortalContainer = Stable.PortalContainer;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type RadioButtonsFieldProps<V> = Stable.RadioButtonsFieldProps<V>;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type RendererFieldDefinition = Stable.RendererFieldDefinition;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type TextAreaFieldProps = Stable.TextAreaFieldProps;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type TextInputFieldProps = Stable.TextInputFieldProps;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type UnsupportedFieldProps = Stable.UnsupportedFieldProps;\n\n/** @deprecated Import from `@osdk/react-components/action-form` instead. */\nexport type ValidationError = Stable.ValidationError;\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,OAAO,KAAKA,MAAM,MAAM,mBAAmB;;AAE3C;AACA,OAAO,MAAMC,UAAoC,GAAGD,MAAM,CAACC,UAAU;;AAErE;;AAIA;;AAIA;;AAKA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAIA;AACA,OAAO,MAAMC,QAAgC,GAAGF,MAAM,CAACE,QAAQ;;AAE/D;;AAIA;;AAGA;;AAGA;;AAMA;;AAGA;;AAMA;;AAGA;;AAMA;;AAGA;;AAGA;;AAKA;;AAIA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA;;AAGA","ignoreList":[]}
|
package/build/browser/styles.css
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
const PACKAGE_USER_AGENT = `osdk-react-components/${"0.
|
|
17
|
+
const PACKAGE_USER_AGENT = `osdk-react-components/${"0.71.0-main-62ebddd7d14dd54cc6de480bc4f21a16fad9b529"}`;
|
|
18
18
|
export function componentUserAgent(componentName) {
|
|
19
19
|
return `${PACKAGE_USER_AGENT}/${componentName}`;
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserAgent.js","names":["PACKAGE_USER_AGENT","componentUserAgent","componentName"],"sources":["UserAgent.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\nconst PACKAGE_USER_AGENT = `osdk-react-components/${process.env.PACKAGE_VERSION}`;\n\nexport function componentUserAgent(componentName: string): string {\n return `${PACKAGE_USER_AGENT}/${componentName}`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,kBAAkB,GAAG,
|
|
1
|
+
{"version":3,"file":"UserAgent.js","names":["PACKAGE_USER_AGENT","componentUserAgent","componentName"],"sources":["UserAgent.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\nconst PACKAGE_USER_AGENT = `osdk-react-components/${process.env.PACKAGE_VERSION}`;\n\nexport function componentUserAgent(componentName: string): string {\n return `${PACKAGE_USER_AGENT}/${componentName}`;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMA,kBAAkB,GAAG,iFAAsD;AAEjF,OAAO,SAASC,kBAAkBA,CAACC,aAAqB,EAAU;EAChE,OAAO,GAAGF,kBAAkB,IAAIE,aAAa,EAAE;AACjD","ignoreList":[]}
|
|
@@ -829,6 +829,14 @@ type BaseFormProps = BaseFormCommonProps & ({
|
|
|
829
829
|
formState?: undefined;
|
|
830
830
|
onFieldValueChange?: (fieldKey: string, value: unknown) => void;
|
|
831
831
|
});
|
|
832
|
+
/**
|
|
833
|
+
* A message surfaced in the form footer error indicator.
|
|
834
|
+
* The label is optional — omit it for errors not tied to a specific field.
|
|
835
|
+
*/
|
|
836
|
+
interface FormErrorEntry {
|
|
837
|
+
label?: string;
|
|
838
|
+
message: string;
|
|
839
|
+
}
|
|
832
840
|
interface BaseFormCommonProps {
|
|
833
841
|
/** Title shown in the form header. Omit to hide the header. */
|
|
834
842
|
formTitle?: string;
|
|
@@ -848,6 +856,15 @@ interface BaseFormCommonProps {
|
|
|
848
856
|
submitButtonText?: string;
|
|
849
857
|
/** Visual variant of the submit button. Default `"primary"`. */
|
|
850
858
|
submitButtonVariant?: "primary" | "secondary";
|
|
859
|
+
/**
|
|
860
|
+
* External validation errors to display in the footer error indicator
|
|
861
|
+
* alongside field errors. Controlled: the caller owns the array and is
|
|
862
|
+
* responsible for clearing it (e.g. on field change). BaseForm never
|
|
863
|
+
* modifies this value.
|
|
864
|
+
*
|
|
865
|
+
* @default undefined (no external errors)
|
|
866
|
+
*/
|
|
867
|
+
validationErrors?: ReadonlyArray<FormErrorEntry>;
|
|
851
868
|
}
|
|
852
869
|
|
|
853
870
|
declare const ActionForm$1: <Q extends ActionDefinition<unknown>>(props: ActionFormProps<Q>) => React__default.ReactElement;
|
|
@@ -856,4 +873,4 @@ declare const BaseForm: React__default.FC<BaseFormProps>;
|
|
|
856
873
|
|
|
857
874
|
declare const ActionForm: typeof ActionForm$1;
|
|
858
875
|
|
|
859
|
-
export { ActionForm as A, BaseForm as B, type CustomFieldProps as C, type DropdownFieldProps as D, type FieldComponent as F, type NumberInputFieldProps as N, type ObjectSelectFieldProps as O, type PortalContainer as P, type RadioButtonsFieldProps as R, type TextAreaFieldProps as T, type UnsupportedFieldProps as U, type ValidationError as V, type ActionFormContentItem as a, type ActionFormProps as b, type ActionFormSectionDefinition as c, type ActionParameters as d, type BaseFormFieldProps as e, type BaseFormProps as f, type FieldValueType as g, type FilePickerProps as h, type FormContentItem as i, type FormError as j, type
|
|
876
|
+
export { ActionForm as A, BaseForm as B, type CustomFieldProps as C, type DropdownFieldProps as D, type FieldComponent as F, type NumberInputFieldProps as N, type ObjectSelectFieldProps as O, type PortalContainer as P, type RadioButtonsFieldProps as R, type TextAreaFieldProps as T, type UnsupportedFieldProps as U, type ValidationError as V, type ActionFormContentItem as a, type ActionFormProps as b, type ActionFormSectionDefinition as c, type ActionParameters as d, type BaseFormFieldProps as e, type BaseFormProps as f, type FieldValueType as g, type FilePickerProps as h, type FormContentItem as i, type FormError as j, type FormErrorEntry as k, type FieldKey as l, type FormFieldDefinition as m, type FormFieldPropsByType as n, type FormSectionDefinition as o, type FormState as p, type ObjectSetFieldProps as q, type Option as r, type RendererFieldDefinition as s, type TextInputFieldProps as t };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkZMZXGMMO_cjs = require('./chunk-ZMZXGMMO.cjs');
|
|
4
|
+
|
|
5
|
+
// src/public/experimental/document-viewer.ts
|
|
6
|
+
var DocumentViewer2 = chunkZMZXGMMO_cjs.DocumentViewer;
|
|
7
|
+
var ViewerType2 = chunkZMZXGMMO_cjs.ViewerType;
|
|
8
|
+
|
|
9
|
+
exports.DocumentViewer = DocumentViewer2;
|
|
10
|
+
exports.ViewerType = ViewerType2;
|
|
11
|
+
//# sourceMappingURL=chunk-2DZBPTO2.cjs.map
|
|
12
|
+
//# sourceMappingURL=chunk-2DZBPTO2.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/public/experimental/document-viewer.ts"],"names":["DocumentViewer","ViewerType"],"mappings":";;;;;AAmBO,IAAMA,eAAAA,GAAwBA;AAK9B,IAAMC,WAAAA,GAAoBA","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../../src/public/experimental/document-viewer.ts"],"names":["DocumentViewer","ViewerType"],"mappings":";;;;;AAmBO,IAAMA,eAAAA,GAAwBA;AAK9B,IAAMC,WAAAA,GAAoBA","file":"chunk-2DZBPTO2.cjs","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 * as Stable from \"../document-viewer.js\";\n\n/** @deprecated Import from `@osdk/react-components/document-viewer` instead. */\nexport const DocumentViewer = Stable.DocumentViewer;\n\n/** @deprecated Import from `@osdk/react-components/document-viewer` instead. */\n\n/** @deprecated Import from `@osdk/react-components/document-viewer` instead. */\nexport const ViewerType = Stable.ViewerType;\n\n/** @deprecated Import from `@osdk/react-components/document-viewer` instead. */"]}
|