@cratis/scene.components 3.5.0 → 3.7.0
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/README.md +56 -5
- package/bindings/bindingRegistry.ts +52 -4
- package/bindings/for_bindingRegistry/when_registering_query_identities.ts +81 -0
- package/bindings/for_requireArcProxy/when_mounting_bound_adapters.tsx +4 -2
- package/cratisComponents.ts +2 -0
- package/cratisComponentsPackage.ts +2 -1
- package/data/SingleResultRuntime.tsx +17 -3
- package/data/for_SceneDataTable/when_forwarding_query_arguments.tsx +19 -0
- package/dist/cjs/bindings/bindingRegistry.js +52 -4
- package/dist/cjs/bindings/bindingRegistry.js.map +1 -1
- package/dist/cjs/cratisComponents.js +2 -0
- package/dist/cjs/cratisComponents.js.map +1 -1
- package/dist/cjs/cratisComponentsPackage.js +2 -1
- package/dist/cjs/cratisComponentsPackage.js.map +1 -1
- package/dist/cjs/data/SingleResultRuntime.js +16 -1
- package/dist/cjs/data/SingleResultRuntime.js.map +1 -1
- package/dist/cjs/forms/CommandFormRuntime.js +81 -0
- package/dist/cjs/forms/CommandFormRuntime.js.map +1 -0
- package/dist/cjs/forms/CommandFormSubmit.js +19 -0
- package/dist/cjs/forms/CommandFormSubmit.js.map +1 -0
- package/dist/cjs/forms/ExplicitCommandField.js +109 -0
- package/dist/cjs/forms/ExplicitCommandField.js.map +1 -0
- package/dist/cjs/forms/SceneCommandForm.js +26 -21
- package/dist/cjs/forms/SceneCommandForm.js.map +1 -1
- package/dist/cjs/forms/SceneQueryInputForm.js +141 -0
- package/dist/cjs/forms/SceneQueryInputForm.js.map +1 -0
- package/dist/cjs/forms/commandInputs.js +35 -0
- package/dist/cjs/forms/commandInputs.js.map +1 -0
- package/dist/cjs/forms/queryInputs.js +50 -0
- package/dist/cjs/forms/queryInputs.js.map +1 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/bindings/bindingRegistry.d.ts +4 -0
- package/dist/esm/bindings/bindingRegistry.d.ts.map +1 -1
- package/dist/esm/bindings/bindingRegistry.js +49 -5
- package/dist/esm/bindings/bindingRegistry.js.map +1 -1
- package/dist/esm/bindings/for_bindingRegistry/when_registering_query_identities.d.ts +2 -0
- package/dist/esm/bindings/for_bindingRegistry/when_registering_query_identities.d.ts.map +1 -0
- package/dist/esm/bindings/for_bindingRegistry/when_registering_query_identities.js +73 -0
- package/dist/esm/bindings/for_bindingRegistry/when_registering_query_identities.js.map +1 -0
- package/dist/esm/bindings/for_requireArcProxy/when_mounting_bound_adapters.js +2 -2
- package/dist/esm/bindings/for_requireArcProxy/when_mounting_bound_adapters.js.map +1 -1
- package/dist/esm/cratisComponents.d.ts.map +1 -1
- package/dist/esm/cratisComponents.js +2 -0
- package/dist/esm/cratisComponents.js.map +1 -1
- package/dist/esm/cratisComponentsPackage.d.ts.map +1 -1
- package/dist/esm/cratisComponentsPackage.js +2 -1
- package/dist/esm/cratisComponentsPackage.js.map +1 -1
- package/dist/esm/data/SingleResultRuntime.d.ts +2 -1
- package/dist/esm/data/SingleResultRuntime.d.ts.map +1 -1
- package/dist/esm/data/SingleResultRuntime.js +16 -1
- package/dist/esm/data/SingleResultRuntime.js.map +1 -1
- package/dist/esm/data/for_SceneDataTable/when_forwarding_query_arguments.js +17 -0
- package/dist/esm/data/for_SceneDataTable/when_forwarding_query_arguments.js.map +1 -1
- package/dist/esm/for_cratisComponentsPackage/when_declaring_command_form_peers.d.ts +2 -0
- package/dist/esm/for_cratisComponentsPackage/when_declaring_command_form_peers.d.ts.map +1 -0
- package/dist/esm/for_cratisComponentsPackage/when_declaring_command_form_peers.js +16 -0
- package/dist/esm/for_cratisComponentsPackage/when_declaring_command_form_peers.js.map +1 -0
- package/dist/esm/for_cratisComponentsPackage/when_describing_query_input_form.d.ts +2 -0
- package/dist/esm/for_cratisComponentsPackage/when_describing_query_input_form.d.ts.map +1 -0
- package/dist/esm/for_cratisComponentsPackage/when_describing_query_input_form.js +14 -0
- package/dist/esm/for_cratisComponentsPackage/when_describing_query_input_form.js.map +1 -0
- package/dist/esm/forms/CommandFormRuntime.d.ts +11 -0
- package/dist/esm/forms/CommandFormRuntime.d.ts.map +1 -0
- package/dist/esm/forms/CommandFormRuntime.js +77 -0
- package/dist/esm/forms/CommandFormRuntime.js.map +1 -0
- package/dist/esm/forms/CommandFormSubmit.d.ts +6 -0
- package/dist/esm/forms/CommandFormSubmit.d.ts.map +1 -0
- package/dist/esm/forms/CommandFormSubmit.js +17 -0
- package/dist/esm/forms/CommandFormSubmit.js.map +1 -0
- package/dist/esm/forms/ExplicitCommandField.d.ts +5 -0
- package/dist/esm/forms/ExplicitCommandField.d.ts.map +1 -0
- package/dist/esm/forms/ExplicitCommandField.js +107 -0
- package/dist/esm/forms/ExplicitCommandField.js.map +1 -0
- package/dist/esm/forms/SceneCommandForm.d.ts.map +1 -1
- package/dist/esm/forms/SceneCommandForm.js +27 -22
- package/dist/esm/forms/SceneCommandForm.js.map +1 -1
- package/dist/esm/forms/SceneQueryInputForm.d.ts +3 -0
- package/dist/esm/forms/SceneQueryInputForm.d.ts.map +1 -0
- package/dist/esm/forms/SceneQueryInputForm.js +139 -0
- package/dist/esm/forms/SceneQueryInputForm.js.map +1 -0
- package/dist/esm/forms/commandInputs.d.ts +7 -0
- package/dist/esm/forms/commandInputs.d.ts.map +1 -0
- package/dist/esm/forms/commandInputs.js +33 -0
- package/dist/esm/forms/commandInputs.js.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/given/RecordNote.d.ts +22 -0
- package/dist/esm/forms/for_SceneCommandForm/given/RecordNote.d.ts.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/given/RecordNote.js +30 -0
- package/dist/esm/forms/for_SceneCommandForm/given/RecordNote.js.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/given/StartProject.d.ts +32 -0
- package/dist/esm/forms/for_SceneCommandForm/given/StartProject.d.ts.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/given/StartProject.js +32 -0
- package/dist/esm/forms/for_SceneCommandForm/given/StartProject.js.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/when_forwarding_to_the_lazy_runtime.d.ts +2 -0
- package/dist/esm/forms/for_SceneCommandForm/when_forwarding_to_the_lazy_runtime.d.ts.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/when_forwarding_to_the_lazy_runtime.js +66 -0
- package/dist/esm/forms/for_SceneCommandForm/when_forwarding_to_the_lazy_runtime.js.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/when_native_custom_field_errors_block_submission.d.ts +2 -0
- package/dist/esm/forms/for_SceneCommandForm/when_native_custom_field_errors_block_submission.d.ts.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/when_native_custom_field_errors_block_submission.js +26 -0
- package/dist/esm/forms/for_SceneCommandForm/when_native_custom_field_errors_block_submission.js.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/when_preserving_guid_error_ownership.d.ts +2 -0
- package/dist/esm/forms/for_SceneCommandForm/when_preserving_guid_error_ownership.d.ts.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/when_preserving_guid_error_ownership.js +44 -0
- package/dist/esm/forms/for_SceneCommandForm/when_preserving_guid_error_ownership.js.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/when_rendering_submit_in_native_context.d.ts +2 -0
- package/dist/esm/forms/for_SceneCommandForm/when_rendering_submit_in_native_context.d.ts.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/when_rendering_submit_in_native_context.js +49 -0
- package/dist/esm/forms/for_SceneCommandForm/when_rendering_submit_in_native_context.js.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/when_submitting_explicit_inputs.d.ts +2 -0
- package/dist/esm/forms/for_SceneCommandForm/when_submitting_explicit_inputs.d.ts.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/when_submitting_explicit_inputs.js +176 -0
- package/dist/esm/forms/for_SceneCommandForm/when_submitting_explicit_inputs.js.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/when_submitting_the_native_form.d.ts +2 -0
- package/dist/esm/forms/for_SceneCommandForm/when_submitting_the_native_form.d.ts.map +1 -0
- package/dist/esm/forms/for_SceneCommandForm/when_submitting_the_native_form.js +110 -0
- package/dist/esm/forms/for_SceneCommandForm/when_submitting_the_native_form.js.map +1 -0
- package/dist/esm/forms/for_SceneQueryInputForm/ProjectLookup.d.ts +26 -0
- package/dist/esm/forms/for_SceneQueryInputForm/ProjectLookup.d.ts.map +1 -0
- package/dist/esm/forms/for_SceneQueryInputForm/ProjectLookup.js +44 -0
- package/dist/esm/forms/for_SceneQueryInputForm/ProjectLookup.js.map +1 -0
- package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_generated_guid_parameters.d.ts +2 -0
- package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_generated_guid_parameters.d.ts.map +1 -0
- package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_generated_guid_parameters.js +175 -0
- package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_generated_guid_parameters.js.map +1 -0
- package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_native_queries.d.ts +2 -0
- package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_native_queries.d.ts.map +1 -0
- package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_native_queries.js +413 -0
- package/dist/esm/forms/for_SceneQueryInputForm/when_submitting_native_queries.js.map +1 -0
- package/dist/esm/forms/index.d.ts +2 -0
- package/dist/esm/forms/index.d.ts.map +1 -1
- package/dist/esm/forms/index.js +1 -0
- package/dist/esm/forms/index.js.map +1 -1
- package/dist/esm/forms/queryInputs.d.ts +10 -0
- package/dist/esm/forms/queryInputs.d.ts.map +1 -0
- package/dist/esm/forms/queryInputs.js +47 -0
- package/dist/esm/forms/queryInputs.js.map +1 -0
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/for_cratisComponentsPackage/when_declaring_command_form_peers.ts +26 -0
- package/for_cratisComponentsPackage/when_describing_query_input_form.ts +17 -0
- package/forms/CommandFormRuntime.tsx +71 -0
- package/forms/CommandFormSubmit.tsx +16 -0
- package/forms/ExplicitCommandField.tsx +86 -0
- package/forms/SceneCommandForm.tsx +30 -27
- package/forms/SceneQueryInputForm.tsx +79 -0
- package/forms/commandInputs.ts +29 -0
- package/forms/for_SceneCommandForm/given/RecordNote.ts +37 -0
- package/forms/for_SceneCommandForm/given/StartProject.ts +41 -0
- package/forms/for_SceneCommandForm/when_forwarding_to_the_lazy_runtime.tsx +69 -0
- package/forms/for_SceneCommandForm/when_native_custom_field_errors_block_submission.tsx +33 -0
- package/forms/for_SceneCommandForm/when_preserving_guid_error_ownership.tsx +50 -0
- package/forms/for_SceneCommandForm/when_rendering_submit_in_native_context.tsx +56 -0
- package/forms/for_SceneCommandForm/when_submitting_explicit_inputs.tsx +189 -0
- package/forms/for_SceneCommandForm/when_submitting_the_native_form.tsx +120 -0
- package/forms/for_SceneQueryInputForm/ProjectLookup.ts +54 -0
- package/forms/for_SceneQueryInputForm/when_submitting_generated_guid_parameters.tsx +188 -0
- package/forms/for_SceneQueryInputForm/when_submitting_native_queries.tsx +423 -0
- package/forms/index.ts +2 -0
- package/forms/queryInputs.ts +50 -0
- package/package.json +17 -13
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { useId, useRef, useState, useLayoutEffect } from 'react';
|
|
3
|
+
import { asCommandFormField, useCommandFormContext } from '@cratis/arc.react/commands';
|
|
4
|
+
import { Guid } from '@cratis/fundamentals';
|
|
5
|
+
|
|
6
|
+
function TextControl({ value, onChange, onBlur, invalid, required, errors, label, property, guid }) {
|
|
7
|
+
const id = useId();
|
|
8
|
+
const context = useCommandFormContext();
|
|
9
|
+
const { setCustomFieldError } = context;
|
|
10
|
+
// Keep the latest native getter: the context snapshot can be stale when another field sets an
|
|
11
|
+
// error and this field unmounts in the same event.
|
|
12
|
+
const contextRef = useRef(context);
|
|
13
|
+
contextRef.current = context;
|
|
14
|
+
// The draft is intentionally independent of the typed proxy value: malformed text must never
|
|
15
|
+
// reappear as a stale previously valid Guid in the command's serialized payload.
|
|
16
|
+
const [draft, setDraft] = useState(()=>value instanceof Guid && !value.equals(Guid.empty) ? value.toString() : '');
|
|
17
|
+
const draftRef = useRef(draft);
|
|
18
|
+
const ownedError = useRef(undefined);
|
|
19
|
+
const updateError = (error)=>{
|
|
20
|
+
const current = contextRef.current.getFieldError(property);
|
|
21
|
+
// Do not replace or erase another producer's error for this field.
|
|
22
|
+
if (ownedError.current !== undefined && current !== ownedError.current) {
|
|
23
|
+
ownedError.current = undefined;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (ownedError.current === undefined && Object.hasOwn(contextRef.current.customFieldErrors, property)) return;
|
|
27
|
+
if (error === undefined && ownedError.current === undefined) return;
|
|
28
|
+
ownedError.current = error;
|
|
29
|
+
setCustomFieldError(property, error);
|
|
30
|
+
};
|
|
31
|
+
// A label/required change must recalculate the message without disposing the field's error.
|
|
32
|
+
// Only a different field/type or an actual unmount relinquishes ownership.
|
|
33
|
+
useLayoutEffect(()=>()=>{
|
|
34
|
+
if (ownedError.current !== undefined && contextRef.current.getFieldError(property) === ownedError.current) {
|
|
35
|
+
contextRef.current.setCustomFieldError(property, undefined);
|
|
36
|
+
}
|
|
37
|
+
ownedError.current = undefined;
|
|
38
|
+
}, [
|
|
39
|
+
property,
|
|
40
|
+
guid
|
|
41
|
+
]);
|
|
42
|
+
useLayoutEffect(()=>{
|
|
43
|
+
if (guid) {
|
|
44
|
+
const current = draftRef.current || (value instanceof Guid && !value.equals(Guid.empty) ? value.toString() : '');
|
|
45
|
+
updateError(!current ? required ? `${label} is required` : undefined : !Guid.isGuid(current) ? `${label} must be a valid GUID` : undefined);
|
|
46
|
+
}
|
|
47
|
+
}, [
|
|
48
|
+
guid,
|
|
49
|
+
required,
|
|
50
|
+
property,
|
|
51
|
+
label,
|
|
52
|
+
setCustomFieldError
|
|
53
|
+
]);
|
|
54
|
+
const text = guid ? draft : typeof value === 'string' ? value : '';
|
|
55
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
56
|
+
children: [
|
|
57
|
+
/*#__PURE__*/ jsx("label", {
|
|
58
|
+
htmlFor: id,
|
|
59
|
+
children: label
|
|
60
|
+
}),
|
|
61
|
+
/*#__PURE__*/ jsx("input", {
|
|
62
|
+
id: id,
|
|
63
|
+
name: property,
|
|
64
|
+
type: "text",
|
|
65
|
+
required: required,
|
|
66
|
+
value: text,
|
|
67
|
+
"aria-invalid": invalid,
|
|
68
|
+
"aria-describedby": errors.length ? `${id}-error` : undefined,
|
|
69
|
+
onBlur: onBlur,
|
|
70
|
+
onChange: (event)=>{
|
|
71
|
+
const next = event.currentTarget.value;
|
|
72
|
+
if (!guid) {
|
|
73
|
+
onChange(next);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
draftRef.current = next;
|
|
77
|
+
setDraft(next);
|
|
78
|
+
const error = !next ? required ? `${label} is required` : undefined : !Guid.isGuid(next) ? `${label} must be a valid GUID` : undefined;
|
|
79
|
+
// A malformed draft clears the previously typed value, not just its display.
|
|
80
|
+
onChange(error || !next ? undefined : Guid.parse(next));
|
|
81
|
+
updateError(error);
|
|
82
|
+
}
|
|
83
|
+
}),
|
|
84
|
+
errors.length > 0 && /*#__PURE__*/ jsx("div", {
|
|
85
|
+
id: `${id}-error`,
|
|
86
|
+
role: "alert",
|
|
87
|
+
children: errors[0]
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const NativeTextField = asCommandFormField(TextControl, {
|
|
93
|
+
defaultValue: ''
|
|
94
|
+
});
|
|
95
|
+
/** Opaque child is self-bound by Arc's native runtime binding, with an exact fieldName. */ function ExplicitCommandField({ input }) {
|
|
96
|
+
return /*#__PURE__*/ jsx(NativeTextField, {
|
|
97
|
+
fieldName: input.property,
|
|
98
|
+
value: (command)=>command[input.property],
|
|
99
|
+
property: input.property,
|
|
100
|
+
guid: input.type === 'guid',
|
|
101
|
+
label: input.label,
|
|
102
|
+
title: input.label
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export { ExplicitCommandField };
|
|
107
|
+
//# sourceMappingURL=ExplicitCommandField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExplicitCommandField.js","sources":["../../../forms/ExplicitCommandField.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { useId, useLayoutEffect, useRef, useState } from 'react';\nimport { asCommandFormField, useCommandFormContext } from '@cratis/arc.react/commands';\nimport { Guid } from '@cratis/fundamentals';\nimport type { CommandInput } from './commandInputs';\n\ninterface TextProps {\n value: unknown;\n onChange: (value: unknown) => void;\n onBlur?: () => void;\n invalid: boolean;\n required: boolean;\n errors: string[];\n label: string;\n property: string;\n guid: boolean;\n}\n\nfunction TextControl({ value, onChange, onBlur, invalid, required, errors, label, property, guid }: TextProps) {\n const id = useId();\n const context = useCommandFormContext();\n const { setCustomFieldError } = context;\n // Keep the latest native getter: the context snapshot can be stale when another field sets an\n // error and this field unmounts in the same event.\n const contextRef = useRef(context);\n contextRef.current = context;\n // The draft is intentionally independent of the typed proxy value: malformed text must never\n // reappear as a stale previously valid Guid in the command's serialized payload.\n const [draft, setDraft] = useState(() => value instanceof Guid && !value.equals(Guid.empty) ? value.toString() : '');\n const draftRef = useRef(draft);\n const ownedError = useRef<string | undefined>(undefined);\n const updateError = (error: string | undefined) => {\n const current = contextRef.current.getFieldError(property);\n // Do not replace or erase another producer's error for this field.\n if (ownedError.current !== undefined && current !== ownedError.current) {\n ownedError.current = undefined;\n return;\n }\n if (ownedError.current === undefined && Object.hasOwn(contextRef.current.customFieldErrors, property)) return;\n if (error === undefined && ownedError.current === undefined) return;\n ownedError.current = error;\n setCustomFieldError(property, error);\n };\n // A label/required change must recalculate the message without disposing the field's error.\n // Only a different field/type or an actual unmount relinquishes ownership.\n useLayoutEffect(() => () => {\n if (ownedError.current !== undefined && contextRef.current.getFieldError(property) === ownedError.current) {\n contextRef.current.setCustomFieldError(property, undefined);\n }\n ownedError.current = undefined;\n }, [property, guid]);\n useLayoutEffect(() => {\n if (guid) {\n const current = draftRef.current || (value instanceof Guid && !value.equals(Guid.empty) ? value.toString() : '');\n updateError(!current ? required ? `${label} is required` : undefined :\n !Guid.isGuid(current) ? `${label} must be a valid GUID` : undefined);\n }\n }, [guid, required, property, label, setCustomFieldError]);\n const text = guid ? draft : typeof value === 'string' ? value : '';\n return <div>\n <label htmlFor={id}>{label}</label>\n <input id={id} name={property} type='text' required={required} value={text}\n aria-invalid={invalid} aria-describedby={errors.length ? `${id}-error` : undefined}\n onBlur={onBlur} onChange={event => {\n const next = event.currentTarget.value;\n if (!guid) { onChange(next); return; }\n draftRef.current = next;\n setDraft(next);\n const error = !next ? required ? `${label} is required` : undefined : !Guid.isGuid(next) ? `${label} must be a valid GUID` : undefined;\n // A malformed draft clears the previously typed value, not just its display.\n onChange(error || !next ? undefined : Guid.parse(next));\n updateError(error);\n }} />\n {errors.length > 0 && <div id={`${id}-error`} role='alert'>{errors[0]}</div>}\n </div>;\n}\n\nconst NativeTextField = asCommandFormField<TextProps>(TextControl, { defaultValue: '' });\n\n/** Opaque child is self-bound by Arc's native runtime binding, with an exact fieldName. */\nexport function ExplicitCommandField({ input }: { input: CommandInput }) {\n return <NativeTextField fieldName={input.property} value={(command: Record<string, unknown>) => command[input.property]}\n property={input.property} guid={input.type === 'guid'} label={input.label} title={input.label} />;\n}\n"],"names":["TextControl","value","onChange","onBlur","invalid","required","errors","label","property","guid","id","useId","context","useCommandFormContext","setCustomFieldError","contextRef","useRef","current","draft","setDraft","useState","Guid","equals","empty","toString","draftRef","ownedError","undefined","updateError","error","getFieldError","Object","hasOwn","customFieldErrors","useLayoutEffect","isGuid","text","_jsxs","div","_jsx","htmlFor","input","name","type","aria-invalid","aria-describedby","length","event","next","currentTarget","parse","role","NativeTextField","asCommandFormField","defaultValue","ExplicitCommandField","fieldName","command","title"],"mappings":";;;;;AAoBA,SAASA,YAAY,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,IAAI,EAAa,EAAA;AACzG,IAAA,MAAMC,EAAAA,GAAKC,KAAAA,EAAAA;AACX,IAAA,MAAMC,OAAAA,GAAUC,qBAAAA,EAAAA;IAChB,MAAM,EAAEC,mBAAmB,EAAE,GAAGF,OAAAA;;;AAGhC,IAAA,MAAMG,aAAaC,MAAAA,CAAOJ,OAAAA,CAAAA;AAC1BG,IAAAA,UAAAA,CAAWE,OAAO,GAAGL,OAAAA;;;AAGrB,IAAA,MAAM,CAACM,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,QAAAA,CAAS,IAAMnB,KAAAA,YAAiBoB,IAAAA,IAAQ,CAACpB,KAAAA,CAAMqB,MAAM,CAACD,IAAAA,CAAKE,KAAK,CAAA,GAAItB,KAAAA,CAAMuB,QAAQ,EAAA,GAAK,EAAA,CAAA;AACjH,IAAA,MAAMC,WAAWT,MAAAA,CAAOE,KAAAA,CAAAA;AACxB,IAAA,MAAMQ,aAAaV,MAAAA,CAA2BW,SAAAA,CAAAA;AAC9C,IAAA,MAAMC,cAAc,CAACC,KAAAA,GAAAA;AACjB,QAAA,MAAMZ,OAAAA,GAAUF,UAAAA,CAAWE,OAAO,CAACa,aAAa,CAACtB,QAAAA,CAAAA;;AAEjD,QAAA,IAAIkB,WAAWT,OAAO,KAAKU,aAAaV,OAAAA,KAAYS,UAAAA,CAAWT,OAAO,EAAE;AACpES,YAAAA,UAAAA,CAAWT,OAAO,GAAGU,SAAAA;AACrB,YAAA;AACJ,QAAA;AACA,QAAA,IAAID,UAAAA,CAAWT,OAAO,KAAKU,SAAAA,IAAaI,MAAAA,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AAqB,CAAC,GAAGoB,SAAAA;;AAE7HzB,oBAAAA,QAAAA,CAAS2B,SAAS,CAACmB,IAAAA,GAAOrB,SAAAA,GAAYN,IAAAA,CAAK6B,KAAK,CAACF,IAAAA,CAAAA,CAAAA;oBACjDpB,WAAAA,CAAYC,KAAAA,CAAAA;AAChB,gBAAA;;YACHvB,MAAAA,CAAOwC,MAAM,GAAG,CAAA,kBAAKP,GAAA,CAACD,KAAAA,EAAAA;gBAAI5B,EAAAA,EAAI,CAAA,EAAGA,EAAAA,CAAG,MAAM,CAAC;gBAAEyC,IAAAA,EAAK,OAAA;AAAS7C,gBAAAA,QAAAA,EAAAA,MAAM,CAAC,CAAA;;;;AAE3E;AAEA,MAAM8C,eAAAA,GAAkBC,mBAA8BrD,WAAAA,EAAa;IAAEsD,YAAAA,EAAc;AAAG,CAAA,CAAA;AAEtF,4FACO,SAASC,oBAAAA,CAAqB,EAAEd,KAAK,EAA2B,EAAA;AACnE,IAAA,qBAAOF,GAAA,CAACa,eAAAA,EAAAA;AAAgBI,QAAAA,SAAAA,EAAWf,MAAMjC,QAAQ;AAAEP,QAAAA,KAAAA,EAAO,CAACwD,OAAAA,GAAqCA,OAAO,CAAChB,KAAAA,CAAMjC,QAAQ,CAAC;AACnHA,QAAAA,QAAAA,EAAUiC,MAAMjC,QAAQ;QAAEC,IAAAA,EAAMgC,KAAAA,CAAME,IAAI,KAAK,MAAA;AAAQpC,QAAAA,KAAAA,EAAOkC,MAAMlC,KAAK;AAAEmD,QAAAA,KAAAA,EAAOjB,MAAMlC;;AAChG;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneCommandForm.d.ts","sourceRoot":"","sources":["../../../forms/SceneCommandForm.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"SceneCommandForm.d.ts","sourceRoot":"","sources":["../../../forms/SceneCommandForm.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAyB/D,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAkBrE"}
|
|
@@ -4,27 +4,25 @@ import { BindingKind } from '../bindings/BindingKind.js';
|
|
|
4
4
|
import { resolveElementBinding } from '../bindings/resolveElementBinding.js';
|
|
5
5
|
import { MissingBinding } from '../bindings/MissingBinding.js';
|
|
6
6
|
import { ArcRuntimeBoundary } from '../bindings/ArcRuntimeBoundary.js';
|
|
7
|
-
import { stringArrayProperty } from '../properties.js';
|
|
7
|
+
import { stringProperty, stringArrayProperty } from '../properties.js';
|
|
8
|
+
import { commandInputs } from './commandInputs.js';
|
|
8
9
|
|
|
10
|
+
const CommandFormRuntime = /*#__PURE__*/ lazy(()=>import('./CommandFormRuntime.js'));
|
|
11
|
+
// Arc's useCommand constructs the proxy only on mount. Key by the actual registered class,
|
|
12
|
+
// not its Scene name (which may be re-registered with a different route or roles).
|
|
13
|
+
const commandKeys = new WeakMap();
|
|
14
|
+
let nextCommandKey = 0;
|
|
15
|
+
function commandKey(command) {
|
|
16
|
+
let key = commandKeys.get(command);
|
|
17
|
+
if (key === undefined) {
|
|
18
|
+
key = ++nextCommandKey;
|
|
19
|
+
commandKeys.set(command, key);
|
|
20
|
+
}
|
|
21
|
+
return key;
|
|
22
|
+
}
|
|
9
23
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* registry rather than from a type annotation. The conversion states the shape this adapter actually
|
|
13
|
-
* passes; the underlying component reads `exclude` as property names either way.
|
|
14
|
-
*/ const AutoCommandForm = /*#__PURE__*/ lazy(async ()=>({
|
|
15
|
-
default: (await import('@cratis/components/CommandForm')).AutoCommandForm
|
|
16
|
-
}));
|
|
17
|
-
/**
|
|
18
|
-
* The `Cratis.Components:commandForm` component - `AutoCommandForm` from `@cratis/components/CommandForm`.
|
|
19
|
-
*
|
|
20
|
-
* `AutoCommandForm` rather than `CommandForm`, because a screen that had to list every field by hand
|
|
21
|
-
* would go stale the moment a property is added to the command on the backend. `AutoCommandForm` reads
|
|
22
|
-
* the command's own property descriptors and picks a field component per property type, so the form
|
|
23
|
-
* follows the command - which is the same guarantee Arc's generated proxies give the rest of the stack.
|
|
24
|
-
*
|
|
25
|
-
* A screen that does want to place fields itself puts the field components from this package in the
|
|
26
|
-
* `content` slot and names them individually; `exclude` keeps `AutoCommandForm` from generating a second
|
|
27
|
-
* copy of anything placed that way.
|
|
24
|
+
* Auto mode follows supported native proxy descriptors; opt-in inputs bind exactly named fields
|
|
25
|
+
* inside a single native Arc form. Neither mode consumes the content slot.
|
|
28
26
|
*/ function SceneCommandForm({ element }) {
|
|
29
27
|
const { name, target } = resolveElementBinding(element, BindingKind.Command);
|
|
30
28
|
if (!target) return /*#__PURE__*/ jsx(MissingBinding, {
|
|
@@ -32,11 +30,18 @@ import { stringArrayProperty } from '../properties.js';
|
|
|
32
30
|
kind: BindingKind.Command,
|
|
33
31
|
name: name
|
|
34
32
|
});
|
|
33
|
+
const inputs = Object.hasOwn(element.properties, 'inputs') ? commandInputs(element.properties) : undefined;
|
|
34
|
+
if (Object.hasOwn(element.properties, 'inputs') && !inputs) return /*#__PURE__*/ jsx("div", {
|
|
35
|
+
role: "alert",
|
|
36
|
+
children: "Invalid command form inputs declaration"
|
|
37
|
+
});
|
|
35
38
|
return /*#__PURE__*/ jsx(ArcRuntimeBoundary, {
|
|
36
|
-
children: /*#__PURE__*/ jsx(
|
|
39
|
+
children: /*#__PURE__*/ jsx(CommandFormRuntime, {
|
|
37
40
|
command: target,
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
inputs: inputs,
|
|
42
|
+
exclude: stringArrayProperty(element.properties, 'exclude'),
|
|
43
|
+
submitLabel: stringProperty(element.properties, 'submitLabel') ?? 'Submit'
|
|
44
|
+
}, commandKey(target))
|
|
40
45
|
});
|
|
41
46
|
}
|
|
42
47
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SceneCommandForm.js","sources":["../../../forms/SceneCommandForm.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport {
|
|
1
|
+
{"version":3,"file":"SceneCommandForm.js","sources":["../../../forms/SceneCommandForm.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { lazy } from 'react';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { ArcRuntimeBoundary, BindingKind, MissingBinding, resolveElementBinding } from '../bindings';\nimport type { BoundConstructor } from '../bindings';\nimport { stringArrayProperty, stringProperty } from '../properties';\nimport { commandInputs } from './commandInputs';\n\nconst CommandFormRuntime = lazy(() => import('./CommandFormRuntime'));\n\n// Arc's useCommand constructs the proxy only on mount. Key by the actual registered class,\n// not its Scene name (which may be re-registered with a different route or roles).\nconst commandKeys = new WeakMap<BoundConstructor, number>();\nlet nextCommandKey = 0;\nfunction commandKey(command: BoundConstructor): number {\n let key = commandKeys.get(command);\n if (key === undefined) {\n key = ++nextCommandKey;\n commandKeys.set(command, key);\n }\n return key;\n}\n\n/**\n * Auto mode follows supported native proxy descriptors; opt-in inputs bind exactly named fields\n * inside a single native Arc form. Neither mode consumes the content slot.\n */\nexport function SceneCommandForm({ element }: RegisteredComponentProps) {\n const { name, target } = resolveElementBinding(element, BindingKind.Command);\n if (!target) return <MissingBinding element={element} kind={BindingKind.Command} name={name} />;\n\n const inputs = Object.hasOwn(element.properties, 'inputs') ? commandInputs(element.properties) : undefined;\n if (Object.hasOwn(element.properties, 'inputs') && !inputs) return <div role='alert'>Invalid command form inputs declaration</div>;\n\n return (\n <ArcRuntimeBoundary>\n <CommandFormRuntime\n key={commandKey(target)}\n command={target}\n inputs={inputs}\n exclude={stringArrayProperty(element.properties, 'exclude')}\n submitLabel={stringProperty(element.properties, 'submitLabel') ?? 'Submit'}\n />\n </ArcRuntimeBoundary>\n );\n}\n"],"names":["CommandFormRuntime","lazy","commandKeys","WeakMap","nextCommandKey","commandKey","command","key","get","undefined","set","SceneCommandForm","element","name","target","resolveElementBinding","BindingKind","Command","_jsx","MissingBinding","kind","inputs","Object","hasOwn","properties","commandInputs","div","role","ArcRuntimeBoundary","exclude","stringArrayProperty","submitLabel","stringProperty"],"mappings":";;;;;;;;;AAUA,MAAMA,kBAAAA,iBAAqBC,IAAAA,CAAK,IAAM,OAAO,yBAAA,CAAA,CAAA;AAE7C;AACA;AACA,MAAMC,cAAc,IAAIC,OAAAA,EAAAA;AACxB,IAAIC,cAAAA,GAAiB,CAAA;AACrB,SAASC,WAAWC,OAAyB,EAAA;IACzC,IAAIC,GAAAA,GAAML,WAAAA,CAAYM,GAAG,CAACF,OAAAA,CAAAA;AAC1B,IAAA,IAAIC,QAAQE,SAAAA,EAAW;AACnBF,QAAAA,GAAAA,GAAM,EAAEH,cAAAA;QACRF,WAAAA,CAAYQ,GAAG,CAACJ,OAAAA,EAASC,GAAAA,CAAAA;AAC7B,IAAA;IACA,OAAOA,GAAAA;AACX;AAEA;;;AAGC,IACM,SAASI,gBAAAA,CAAiB,EAAEC,OAAO,EAA4B,EAAA;IAClE,MAAM,EAAEC,IAAI,EAAEC,MAAM,EAAE,GAAGC,qBAAAA,CAAsBH,OAAAA,EAASI,WAAAA,CAAYC,OAAO,CAAA;IAC3E,IAAI,CAACH,MAAAA,EAAQ,qBAAOI,GAAA,CAACC,cAAAA,EAAAA;QAAeP,OAAAA,EAASA,OAAAA;AAASQ,QAAAA,IAAAA,EAAMJ,YAAYC,OAAO;QAAEJ,IAAAA,EAAMA;;IAEvF,MAAMQ,MAAAA,GAASC,MAAAA,CAAOC,MAAM,CAACX,OAAAA,CAAQY,UAAU,EAAE,QAAA,CAAA,GAAYC,aAAAA,CAAcb,OAAAA,CAAQY,UAAU,CAAA,GAAIf,SAAAA;IACjG,IAAIa,MAAAA,CAAOC,MAAM,CAACX,OAAAA,CAAQY,UAAU,EAAE,QAAA,CAAA,IAAa,CAACH,MAAAA,EAAQ,qBAAOH,GAAA,CAACQ,KAAAA,EAAAA;QAAIC,IAAAA,EAAK,OAAA;AAAQ,QAAA,QAAA,EAAA;;AAErF,IAAA,qBACIT,GAAA,CAACU,kBAAAA,EAAAA;AACG,QAAA,QAAA,gBAAAV,GAAA,CAAClB,kBAAAA,EAAAA;YAEGM,OAAAA,EAASQ,MAAAA;YACTO,MAAAA,EAAQA,MAAAA;YACRQ,OAAAA,EAASC,mBAAAA,CAAoBlB,OAAAA,CAAQY,UAAU,EAAE,SAAA,CAAA;AACjDO,YAAAA,WAAAA,EAAaC,cAAAA,CAAepB,OAAAA,CAAQY,UAAU,EAAE,aAAA,CAAA,IAAkB;WAJ7DnB,UAAAA,CAAWS,MAAAA,CAAAA;;AAQhC;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SceneQueryInputForm.d.ts","sourceRoot":"","sources":["../../../forms/SceneQueryInputForm.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAS/D,wBAAgB,mBAAmB,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,+BAgBxE"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useSyncExternalStore, useId, useState, lazy } from 'react';
|
|
3
|
+
import { BindingKind } from '../bindings/BindingKind.js';
|
|
4
|
+
import { subscribeQueryBindings, resolveExactQuery } from '../bindings/bindingRegistry.js';
|
|
5
|
+
import '../bindings/resolveElementBinding.js';
|
|
6
|
+
import { MissingBinding } from '../bindings/MissingBinding.js';
|
|
7
|
+
import { ArcRuntimeBoundary } from '../bindings/ArcRuntimeBoundary.js';
|
|
8
|
+
import { stringProperty } from '../properties.js';
|
|
9
|
+
import { SingleResultStatus } from '../data/SingleResultStatus.js';
|
|
10
|
+
import { queryInputs, queryInputError } from './queryInputs.js';
|
|
11
|
+
|
|
12
|
+
const SingleResultRuntime = /*#__PURE__*/ lazy(()=>import('../data/SingleResultRuntime.js'));
|
|
13
|
+
/** Opt-in, form-local string drafts around the existing optional-single execution owner. */ function SceneQueryInputForm({ element }) {
|
|
14
|
+
const name = stringProperty(element.properties, 'query');
|
|
15
|
+
const target = useSyncExternalStore(subscribeQueryBindings, ()=>name ? resolveExactQuery(name) : undefined);
|
|
16
|
+
if (target === 'ambiguous') return /*#__PURE__*/ jsxs("div", {
|
|
17
|
+
role: "alert",
|
|
18
|
+
children: [
|
|
19
|
+
"Ambiguous query binding '",
|
|
20
|
+
name,
|
|
21
|
+
"' on ",
|
|
22
|
+
element.componentName
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
if (!target) return /*#__PURE__*/ jsx(MissingBinding, {
|
|
26
|
+
element: element,
|
|
27
|
+
kind: BindingKind.Query,
|
|
28
|
+
name: name
|
|
29
|
+
});
|
|
30
|
+
const inputs = queryInputs(element.properties);
|
|
31
|
+
const resultField = stringProperty(element.properties, 'resultField');
|
|
32
|
+
if (!inputs || !resultField) return /*#__PURE__*/ jsx("div", {
|
|
33
|
+
role: "alert",
|
|
34
|
+
children: "Invalid query input form configuration"
|
|
35
|
+
});
|
|
36
|
+
if (!element.isEnabled) return /*#__PURE__*/ jsx(SingleResultStatus, {
|
|
37
|
+
state: "idle"
|
|
38
|
+
});
|
|
39
|
+
// A different form declaration starts a new session; ordinary host rerenders retain drafts.
|
|
40
|
+
return /*#__PURE__*/ jsx(QueryInputForm, {
|
|
41
|
+
query: target,
|
|
42
|
+
inputs: inputs,
|
|
43
|
+
resultField: resultField,
|
|
44
|
+
label: stringProperty(element.properties, 'label') ?? 'Query input',
|
|
45
|
+
submitLabel: stringProperty(element.properties, 'submitLabel') ?? 'Search'
|
|
46
|
+
}, JSON.stringify([
|
|
47
|
+
name,
|
|
48
|
+
inputs,
|
|
49
|
+
resultField
|
|
50
|
+
]));
|
|
51
|
+
}
|
|
52
|
+
function QueryInputForm({ query, inputs, resultField, label, submitLabel }) {
|
|
53
|
+
const id = useId();
|
|
54
|
+
const [drafts, setDrafts] = useState(()=>Object.fromEntries(inputs.map((input)=>[
|
|
55
|
+
input.parameter,
|
|
56
|
+
''
|
|
57
|
+
])));
|
|
58
|
+
const [errors, setErrors] = useState({});
|
|
59
|
+
const [committed, setCommitted] = useState();
|
|
60
|
+
return /*#__PURE__*/ jsxs("form", {
|
|
61
|
+
"aria-label": label,
|
|
62
|
+
noValidate: true,
|
|
63
|
+
onSubmit: (event)=>{
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
const validation = Object.fromEntries(inputs.map((input)=>[
|
|
66
|
+
input.parameter,
|
|
67
|
+
queryInputError(input, drafts[input.parameter])
|
|
68
|
+
]));
|
|
69
|
+
setErrors(validation);
|
|
70
|
+
if (Object.values(validation).some(Boolean)) {
|
|
71
|
+
setCommitted(undefined);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
// New identity even for unchanged values: repeat submit is an explicit retry. No trimming,
|
|
75
|
+
// coercion, generated identifier, property-path evaluation or query while typing.
|
|
76
|
+
setCommitted(Object.freeze(Object.fromEntries(inputs.map((input)=>[
|
|
77
|
+
input.parameter,
|
|
78
|
+
drafts[input.parameter]
|
|
79
|
+
]))));
|
|
80
|
+
},
|
|
81
|
+
children: [
|
|
82
|
+
inputs.map((input, index)=>{
|
|
83
|
+
const controlId = `${id}-${index}`;
|
|
84
|
+
const error = Object.hasOwn(errors, input.parameter) ? errors[input.parameter] : undefined;
|
|
85
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
86
|
+
children: [
|
|
87
|
+
/*#__PURE__*/ jsx("label", {
|
|
88
|
+
htmlFor: controlId,
|
|
89
|
+
children: input.label
|
|
90
|
+
}),
|
|
91
|
+
/*#__PURE__*/ jsx("input", {
|
|
92
|
+
id: controlId,
|
|
93
|
+
name: input.parameter,
|
|
94
|
+
type: "text",
|
|
95
|
+
required: input.required,
|
|
96
|
+
value: drafts[input.parameter],
|
|
97
|
+
"aria-invalid": !!error,
|
|
98
|
+
"aria-describedby": error ? `${controlId}-error` : undefined,
|
|
99
|
+
onChange: (event)=>{
|
|
100
|
+
setDrafts({
|
|
101
|
+
...drafts,
|
|
102
|
+
[input.parameter]: event.currentTarget.value
|
|
103
|
+
});
|
|
104
|
+
setErrors({
|
|
105
|
+
...errors,
|
|
106
|
+
[input.parameter]: undefined
|
|
107
|
+
});
|
|
108
|
+
// Unmount synchronously on edit: runtime cleanup aborts and masks late replies.
|
|
109
|
+
setCommitted(undefined);
|
|
110
|
+
}
|
|
111
|
+
}),
|
|
112
|
+
error && /*#__PURE__*/ jsx("div", {
|
|
113
|
+
id: `${controlId}-error`,
|
|
114
|
+
role: "alert",
|
|
115
|
+
children: error
|
|
116
|
+
})
|
|
117
|
+
]
|
|
118
|
+
}, input.parameter);
|
|
119
|
+
}),
|
|
120
|
+
/*#__PURE__*/ jsx("button", {
|
|
121
|
+
type: "submit",
|
|
122
|
+
children: submitLabel
|
|
123
|
+
}),
|
|
124
|
+
committed ? /*#__PURE__*/ jsx(ArcRuntimeBoundary, {
|
|
125
|
+
children: /*#__PURE__*/ jsx(SingleResultRuntime, {
|
|
126
|
+
query: query,
|
|
127
|
+
queryArguments: committed,
|
|
128
|
+
resultField: resultField,
|
|
129
|
+
stringInputs: true
|
|
130
|
+
})
|
|
131
|
+
}) : /*#__PURE__*/ jsx(SingleResultStatus, {
|
|
132
|
+
state: "idle"
|
|
133
|
+
})
|
|
134
|
+
]
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export { SceneQueryInputForm };
|
|
139
|
+
//# sourceMappingURL=SceneQueryInputForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SceneQueryInputForm.js","sources":["../../../forms/SceneQueryInputForm.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { lazy, useId, useState, useSyncExternalStore } from 'react';\nimport { RegisteredComponentProps } from '@cratis/scene.react';\nimport { ArcRuntimeBoundary, BindingKind, BoundConstructor, MissingBinding, resolveExactQuery, subscribeQueryBindings } from '../bindings';\nimport { stringProperty } from '../properties';\nimport { SingleResultStatus } from '../data/SingleResultStatus';\nimport { QueryInput, queryInputError, queryInputs } from './queryInputs';\n\nconst SingleResultRuntime = lazy(() => import('../data/SingleResultRuntime'));\n\n/** Opt-in, form-local string drafts around the existing optional-single execution owner. */\nexport function SceneQueryInputForm({ element }: RegisteredComponentProps) {\n const name = stringProperty(element.properties, 'query');\n const target = useSyncExternalStore(subscribeQueryBindings, () => name ? resolveExactQuery(name) : undefined);\n if (target === 'ambiguous') return <div role='alert'>Ambiguous query binding '{name}' on {element.componentName}</div>;\n if (!target) return <MissingBinding element={element} kind={BindingKind.Query} name={name} />;\n\n const inputs = queryInputs(element.properties);\n const resultField = stringProperty(element.properties, 'resultField');\n if (!inputs || !resultField) return <div role='alert'>Invalid query input form configuration</div>;\n if (!element.isEnabled) return <SingleResultStatus state='idle' />;\n\n // A different form declaration starts a new session; ordinary host rerenders retain drafts.\n return <QueryInputForm key={JSON.stringify([name, inputs, resultField])}\n query={target} inputs={inputs} resultField={resultField}\n label={stringProperty(element.properties, 'label') ?? 'Query input'}\n submitLabel={stringProperty(element.properties, 'submitLabel') ?? 'Search'} />;\n}\n\ninterface Props {\n query: BoundConstructor;\n inputs: QueryInput[];\n resultField: string;\n label: string;\n submitLabel: string;\n}\n\nfunction QueryInputForm({ query, inputs, resultField, label, submitLabel }: Props) {\n const id = useId();\n const [drafts, setDrafts] = useState<Record<string, string>>(() => Object.fromEntries(inputs.map(input => [input.parameter, ''])));\n const [errors, setErrors] = useState<Record<string, string | undefined>>({});\n const [committed, setCommitted] = useState<Record<string, string>>();\n\n return <form aria-label={label} noValidate onSubmit={event => {\n event.preventDefault();\n const validation = Object.fromEntries(inputs.map(input => [input.parameter, queryInputError(input, drafts[input.parameter])]));\n setErrors(validation);\n if (Object.values(validation).some(Boolean)) {\n setCommitted(undefined);\n return;\n }\n // New identity even for unchanged values: repeat submit is an explicit retry. No trimming,\n // coercion, generated identifier, property-path evaluation or query while typing.\n setCommitted(Object.freeze(Object.fromEntries(inputs.map(input => [input.parameter, drafts[input.parameter]]))));\n }}>\n {inputs.map((input, index) => {\n const controlId = `${id}-${index}`;\n const error = Object.hasOwn(errors, input.parameter) ? errors[input.parameter] : undefined;\n return <div key={input.parameter}>\n <label htmlFor={controlId}>{input.label}</label>\n <input id={controlId} name={input.parameter} type='text' required={input.required}\n value={drafts[input.parameter]} aria-invalid={!!error} aria-describedby={error ? `${controlId}-error` : undefined}\n onChange={event => {\n setDrafts({ ...drafts, [input.parameter]: event.currentTarget.value });\n setErrors({ ...errors, [input.parameter]: undefined });\n // Unmount synchronously on edit: runtime cleanup aborts and masks late replies.\n setCommitted(undefined);\n }} />\n {error && <div id={`${controlId}-error`} role='alert'>{error}</div>}\n </div>;\n })}\n <button type='submit'>{submitLabel}</button>\n {committed ? <ArcRuntimeBoundary>\n <SingleResultRuntime query={query} queryArguments={committed} resultField={resultField} stringInputs />\n </ArcRuntimeBoundary> : <SingleResultStatus state='idle' />}\n </form>;\n}\n"],"names":["SingleResultRuntime","lazy","SceneQueryInputForm","element","name","stringProperty","properties","target","useSyncExternalStore","subscribeQueryBindings","resolveExactQuery","undefined","_jsxs","div","role","componentName","_jsx","MissingBinding","kind","BindingKind","Query","inputs","queryInputs","resultField","isEnabled","SingleResultStatus","state","QueryInputForm","query","label","submitLabel","JSON","stringify","id","useId","drafts","setDrafts","useState","Object","fromEntries","map","input","parameter","errors","setErrors","committed","setCommitted","form","aria-label","noValidate","onSubmit","event","preventDefault","validation","queryInputError","values","some","Boolean","freeze","index","controlId","error","hasOwn","htmlFor","type","required","value","aria-invalid","aria-describedby","onChange","currentTarget","button","ArcRuntimeBoundary","queryArguments","stringInputs"],"mappings":";;;;;;;;;;;AAUA,MAAMA,mBAAAA,iBAAsBC,IA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{"version":3,"file":"commandInputs.d.ts","sourceRoot":"","sources":["../../../forms/commandInputs.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,YAAY;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,GAAG,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACjB;AAGD,wBAAgB,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,YAAY,EAAE,GAAG,SAAS,CAe7F"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { arrayProperty, objectProperty, stringProperty } from '../properties.js';
|
|
2
|
+
|
|
3
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
4
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
5
|
+
/** An absent declaration selects legacy auto mode; a present but invalid declaration never does. */ function commandInputs(properties) {
|
|
6
|
+
const values = arrayProperty(properties, 'inputs');
|
|
7
|
+
if (!values?.length) return undefined;
|
|
8
|
+
const inputs = [];
|
|
9
|
+
const seen = new Set();
|
|
10
|
+
for (const value of values){
|
|
11
|
+
const input = objectProperty({
|
|
12
|
+
value
|
|
13
|
+
}, 'value');
|
|
14
|
+
if (!input || Object.keys(input).some((key)=>![
|
|
15
|
+
'property',
|
|
16
|
+
'type',
|
|
17
|
+
'label'
|
|
18
|
+
].includes(key))) return undefined;
|
|
19
|
+
const property = stringProperty(input, 'property');
|
|
20
|
+
const label = stringProperty(input, 'label');
|
|
21
|
+
if (!property?.trim() || !label?.trim() || input.type !== 'string' && input.type !== 'guid' || seen.has(property)) return undefined;
|
|
22
|
+
seen.add(property);
|
|
23
|
+
inputs.push({
|
|
24
|
+
property,
|
|
25
|
+
type: input.type,
|
|
26
|
+
label
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return inputs;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { commandInputs };
|
|
33
|
+
//# sourceMappingURL=commandInputs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandInputs.js","sources":["../../../forms/commandInputs.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { arrayProperty, objectProperty, stringProperty } from '../properties';\n\n/** Exact, case-sensitive names from a generated command's propertyDescriptors. */\nexport interface CommandInput {\n property: string;\n type: 'string' | 'guid';\n label: string;\n}\n\n/** An absent declaration selects legacy auto mode; a present but invalid declaration never does. */\nexport function commandInputs(properties: Record<string, unknown>): CommandInput[] | undefined {\n const values = arrayProperty(properties, 'inputs');\n if (!values?.length) return undefined;\n const inputs: CommandInput[] = [];\n const seen = new Set<string>();\n for (const value of values) {\n const input = objectProperty({ value }, 'value');\n if (!input || Object.keys(input).some(key => !['property', 'type', 'label'].includes(key))) return undefined;\n const property = stringProperty(input, 'property');\n const label = stringProperty(input, 'label');\n if (!property?.trim() || !label?.trim() || (input.type !== 'string' && input.type !== 'guid') || seen.has(property)) return undefined;\n seen.add(property);\n inputs.push({ property, type: input.type, label });\n }\n return inputs;\n}\n"],"names":["commandInputs","properties","values","arrayProperty","length","undefined","inputs","seen","Set","value","input","objectProperty","Object","keys","some","key","includes","property","stringProperty","label","trim","type","has","add","push"],"mappings":";;AAAA;AACA;AAWA,qGACO,SAASA,aAAAA,CAAcC,UAAmC,EAAA;IAC7D,MAAMC,MAAAA,GAASC,cAAcF,UAAAA,EAAY,QAAA,CAAA;IACzC,IAAI,CAACC,MAAAA,EAAQE,MAAAA,EAAQ,OAAOC,SAAAA;AAC5B,IAAA,MAAMC,SAAyB,EAAE;AACjC,IAAA,MAAMC,OAAO,IAAIC,GAAAA,EAAAA;IACjB,KAAK,MAAMC,SAASP,MAAAA,CAAQ;AACxB,QAAA,MAAMQ,QAAQC,cAAAA,CAAe;AAAEF,YAAAA;SAAM,EAAG,OAAA,CAAA;QACxC,IAAI,CAACC,KAAAA,IAASE,MAAAA,CAAOC,IAAI,CAACH,OAAOI,IAAI,CAACC,CAAAA,GAAAA,GAAO,CAAC;AAAC,gBAAA,UAAA;AAAY,gBAAA,MAAA;AAAQ,gBAAA;aAAQ,CAACC,QAAQ,CAACD,GAAAA,CAAAA,CAAAA,EAAO,OAAOV,SAAAA;QACnG,MAAMY,QAAAA,GAAWC,eAAeR,KAAAA,EAAO,UAAA,CAAA;QACvC,MAAMS,KAAAA,GAAQD,eAAeR,KAAAA,EAAO,OAAA,CAAA;AACpC,QAAA,IAAI,CAACO,QAAAA,EAAUG,IAAAA,EAAAA,IAAU,CAACD,KAAAA,EAAOC,IAAAA,EAAAA,IAAWV,MAAMW,IAAI,KAAK,QAAA,IAAYX,KAAAA,CAAMW,IAAI,KAAK,MAAA,IAAWd,KAAKe,GAAG,CAACL,WAAW,OAAOZ,SAAAA;AAC5HE,QAAAA,IAAAA,CAAKgB,GAAG,CAACN,QAAAA,CAAAA;AACTX,QAAAA,MAAAA,CAAOkB,IAAI,CAAC;AAAEP,YAAAA,QAAAA;AAAUI,YAAAA,IAAAA,EAAMX,MAAMW,IAAI;AAAEF,YAAAA;AAAM,SAAA,CAAA;AACpD,IAAA;IACA,OAAOb,MAAAA;AACX;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Command, CommandValidator } from '@cratis/arc/commands';
|
|
2
|
+
import { PropertyDescriptor } from '@cratis/arc/reflection';
|
|
3
|
+
declare class NoteValidator extends CommandValidator<{
|
|
4
|
+
subject: string;
|
|
5
|
+
}> {
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
export declare class RecordNote extends Command {
|
|
9
|
+
readonly route: string;
|
|
10
|
+
readonly propertyDescriptors: PropertyDescriptor[];
|
|
11
|
+
readonly requestParameters: never[];
|
|
12
|
+
readonly validation: NoteValidator;
|
|
13
|
+
subject: string;
|
|
14
|
+
internalValue: string;
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
|
17
|
+
export declare class RestrictedNote extends RecordNote {
|
|
18
|
+
readonly roles: string[];
|
|
19
|
+
}
|
|
20
|
+
export declare function successfulResponse(): Response;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=RecordNote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecordNote.d.ts","sourceRoot":"","sources":["../../../../../forms/for_SceneCommandForm/given/RecordNote.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,cAAM,aAAc,SAAQ,gBAAgB,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;IAC7D,cAGC;CACJ;AAGD,qBAAa,UAAW,SAAQ,OAAO;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAsB;IAC5C,QAAQ,CAAC,mBAAmB,uBAG1B;IACF,QAAQ,CAAC,iBAAiB,UAAM;IAChC,QAAQ,CAAC,UAAU,gBAAuB;IAC1C,OAAO,SAAM;IACb,aAAa,SAAmB;IAChC,cAAuC;CAC1C;AAED,qBAAa,cAAe,SAAQ,UAAU;IAC1C,QAAQ,CAAC,KAAK,WAAmB;CACpC;AAED,wBAAgB,kBAAkB,IAItB,QAAQ,CACnB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Command, CommandValidator } from '@cratis/arc/commands';
|
|
2
|
+
import { PropertyDescriptor } from '@cratis/arc/reflection';
|
|
3
|
+
class NoteValidator extends CommandValidator {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
this.ruleFor(command => command.subject).notEmpty().withMessage('Subject is required');
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class RecordNote extends Command {
|
|
10
|
+
route = '/synthetic/notes';
|
|
11
|
+
propertyDescriptors = [
|
|
12
|
+
new PropertyDescriptor('subject', String),
|
|
13
|
+
new PropertyDescriptor('internalValue', String, true),
|
|
14
|
+
];
|
|
15
|
+
requestParameters = [];
|
|
16
|
+
validation = new NoteValidator();
|
|
17
|
+
subject = '';
|
|
18
|
+
internalValue = 'proxy default';
|
|
19
|
+
constructor() { super(Object, false); }
|
|
20
|
+
}
|
|
21
|
+
export class RestrictedNote extends RecordNote {
|
|
22
|
+
roles = ['note-writer'];
|
|
23
|
+
}
|
|
24
|
+
export function successfulResponse() {
|
|
25
|
+
return { status: 200, json: async () => ({
|
|
26
|
+
isSuccess: true, isAuthorized: true, isValid: true, hasExceptions: false,
|
|
27
|
+
validationResults: [], exceptionMessages: [], exceptionStackTrace: '', response: {},
|
|
28
|
+
}) };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=RecordNote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RecordNote.js","sourceRoot":"","sources":["../../../../../forms/for_SceneCommandForm/given/RecordNote.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,aAAc,SAAQ,gBAAqC;IAC7D;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAC3F,CAAC;CACJ;AAGD,MAAM,OAAO,UAAW,SAAQ,OAAO;IAC1B,KAAK,GAAW,kBAAkB,CAAC;IACnC,mBAAmB,GAAG;QAC3B,IAAI,kBAAkB,CAAC,SAAS,EAAE,MAAM,CAAC;QACzC,IAAI,kBAAkB,CAAC,eAAe,EAAE,MAAM,EAAE,IAAI,CAAC;KACxD,CAAC;IACO,iBAAiB,GAAG,EAAE,CAAC;IACvB,UAAU,GAAG,IAAI,aAAa,EAAE,CAAC;IAC1C,OAAO,GAAG,EAAE,CAAC;IACb,aAAa,GAAG,eAAe,CAAC;IAChC,gBAAgB,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;CAC1C;AAED,MAAM,OAAO,cAAe,SAAQ,UAAU;IACjC,KAAK,GAAG,CAAC,aAAa,CAAC,CAAC;CACpC;AAED,MAAM,UAAU,kBAAkB;IAC9B,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;YACrC,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK;YACxE,iBAAiB,EAAE,EAAE,EAAE,iBAAiB,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE;SACtF,CAAC,EAAc,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Command, CommandValidator } from '@cratis/arc/commands';
|
|
2
|
+
import { PropertyDescriptor } from '@cratis/arc/reflection';
|
|
3
|
+
import { Guid } from '@cratis/fundamentals';
|
|
4
|
+
declare class ProjectValidator extends CommandValidator<{
|
|
5
|
+
name: string;
|
|
6
|
+
}> {
|
|
7
|
+
constructor();
|
|
8
|
+
}
|
|
9
|
+
export declare class StartProject extends Command {
|
|
10
|
+
readonly route: string;
|
|
11
|
+
readonly propertyDescriptors: PropertyDescriptor[];
|
|
12
|
+
readonly requestParameters: never[];
|
|
13
|
+
readonly validation: ProjectValidator;
|
|
14
|
+
projectId: Guid;
|
|
15
|
+
name: string;
|
|
16
|
+
constructor();
|
|
17
|
+
}
|
|
18
|
+
export declare class RestrictedProject extends StartProject {
|
|
19
|
+
readonly roles: string[];
|
|
20
|
+
}
|
|
21
|
+
export declare class OptionalUnsupported extends StartProject {
|
|
22
|
+
readonly propertyDescriptors: PropertyDescriptor[];
|
|
23
|
+
details?: object;
|
|
24
|
+
}
|
|
25
|
+
export declare class RequiredUnsupported extends OptionalUnsupported {
|
|
26
|
+
readonly propertyDescriptors: PropertyDescriptor[];
|
|
27
|
+
}
|
|
28
|
+
export declare class AmbiguousProject extends StartProject {
|
|
29
|
+
readonly propertyDescriptors: PropertyDescriptor[];
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=StartProject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StartProject.d.ts","sourceRoot":"","sources":["../../../../../forms/for_SceneCommandForm/given/StartProject.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAE5C,cAAM,gBAAiB,SAAQ,gBAAgB,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;IAC7D,cAGC;CACJ;AAGD,qBAAa,YAAa,SAAQ,OAAO;IACrC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAyB;IAC/C,QAAQ,CAAC,mBAAmB,uBAAuF;IACnH,QAAQ,CAAC,iBAAiB,UAAM;IAChC,QAAQ,CAAC,UAAU,mBAA0B;IAC7C,SAAS,EAAE,IAAI,CAAc;IAC7B,IAAI,SAAM;IACV,cAAuC;CAC1C;AAED,qBAAa,iBAAkB,SAAQ,YAAY;IAC/C,QAAQ,CAAC,KAAK,WAAsB;CACvC;AAED,qBAAa,mBAAoB,SAAQ,YAAY;IACjD,QAAQ,CAAC,mBAAmB,uBAAwI;IACpK,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,mBAAoB,SAAQ,mBAAmB;IACxD,QAAQ,CAAC,mBAAmB,uBAAkI;CACjK;AAED,qBAAa,gBAAiB,SAAQ,YAAY;IAC9C,QAAQ,CAAC,mBAAmB,uBAAkI;CACjK"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Command, CommandValidator } from '@cratis/arc/commands';
|
|
2
|
+
import { PropertyDescriptor } from '@cratis/arc/reflection';
|
|
3
|
+
import { Guid } from '@cratis/fundamentals';
|
|
4
|
+
class ProjectValidator extends CommandValidator {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
this.ruleFor(command => command.name).notEmpty().withMessage('Name is required');
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export class StartProject extends Command {
|
|
11
|
+
route = '/synthetic/projects';
|
|
12
|
+
propertyDescriptors = [new PropertyDescriptor('projectId', Guid), new PropertyDescriptor('name', String)];
|
|
13
|
+
requestParameters = [];
|
|
14
|
+
validation = new ProjectValidator();
|
|
15
|
+
projectId = Guid.empty;
|
|
16
|
+
name = '';
|
|
17
|
+
constructor() { super(Object, false); }
|
|
18
|
+
}
|
|
19
|
+
export class RestrictedProject extends StartProject {
|
|
20
|
+
roles = ['project-writer'];
|
|
21
|
+
}
|
|
22
|
+
export class OptionalUnsupported extends StartProject {
|
|
23
|
+
propertyDescriptors = [new PropertyDescriptor('projectId', Guid), new PropertyDescriptor('name', String), new PropertyDescriptor('details', Object, true)];
|
|
24
|
+
details;
|
|
25
|
+
}
|
|
26
|
+
export class RequiredUnsupported extends OptionalUnsupported {
|
|
27
|
+
propertyDescriptors = [new PropertyDescriptor('projectId', Guid), new PropertyDescriptor('name', String), new PropertyDescriptor('details', Object)];
|
|
28
|
+
}
|
|
29
|
+
export class AmbiguousProject extends StartProject {
|
|
30
|
+
propertyDescriptors = [new PropertyDescriptor('projectId', Guid), new PropertyDescriptor('name', String), new PropertyDescriptor('projectId', Guid)];
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=StartProject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StartProject.js","sourceRoot":"","sources":["../../../../../forms/for_SceneCommandForm/given/StartProject.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE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AW,EAAE,IAAI,CAAC,EAAE,IAAI,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,kBAAkB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;CACjK;AAED,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IACrC,mBAAmB,GAAG,CAAC,IAAI,kBAAkB,CAAC,WAAW,EAAE,IAAI,CAAC,EAAE,IAAI,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,kBAAkB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;CACjK"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"when_forwarding_to_the_lazy_runtime.d.ts","sourceRoot":"","sources":["../../../../forms/for_SceneCommandForm/when_forwarding_to_the_lazy_runtime.tsx"],"names":[],"mappings":""}
|