@cratis/scene.components 4.7.0 → 4.9.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/cratisComponentsDescriptors.ts +53 -1
- package/cratisComponentsPackage.ts +15 -0
- package/dist/cjs/cratisComponentsDescriptors.js +150 -0
- package/dist/cjs/cratisComponentsDescriptors.js.map +1 -1
- package/dist/cjs/cratisComponentsPackage.js +32 -2
- package/dist/cjs/cratisComponentsPackage.js.map +1 -1
- package/dist/cjs/forms/CommandFormRuntime.js +11 -4
- package/dist/cjs/forms/CommandFormRuntime.js.map +1 -1
- package/dist/cjs/forms/ExplicitCommandField.js +13 -7
- package/dist/cjs/forms/ExplicitCommandField.js.map +1 -1
- package/dist/cjs/forms/SceneCommandForm.js +10 -3
- package/dist/cjs/forms/SceneCommandForm.js.map +1 -1
- package/dist/cjs/forms/commandInputs.js +8 -2
- package/dist/cjs/forms/commandInputs.js.map +1 -1
- package/dist/cjs/forms/generateCommandFieldsAction.js +58 -0
- package/dist/cjs/forms/generateCommandFieldsAction.js.map +1 -0
- package/dist/esm/cratisComponentsDescriptors.d.ts.map +1 -1
- package/dist/esm/cratisComponentsDescriptors.js +151 -1
- package/dist/esm/cratisComponentsDescriptors.js.map +1 -1
- package/dist/esm/cratisComponentsPackage.d.ts.map +1 -1
- package/dist/esm/cratisComponentsPackage.js +32 -2
- package/dist/esm/cratisComponentsPackage.js.map +1 -1
- package/dist/esm/forms/CommandFormRuntime.d.ts +2 -1
- package/dist/esm/forms/CommandFormRuntime.d.ts.map +1 -1
- package/dist/esm/forms/CommandFormRuntime.js +11 -4
- package/dist/esm/forms/CommandFormRuntime.js.map +1 -1
- package/dist/esm/forms/ExplicitCommandField.d.ts.map +1 -1
- package/dist/esm/forms/ExplicitCommandField.js +13 -7
- package/dist/esm/forms/ExplicitCommandField.js.map +1 -1
- package/dist/esm/forms/SceneCommandForm.d.ts.map +1 -1
- package/dist/esm/forms/SceneCommandForm.js +11 -4
- package/dist/esm/forms/SceneCommandForm.js.map +1 -1
- package/dist/esm/forms/commandInputs.d.ts +2 -0
- package/dist/esm/forms/commandInputs.d.ts.map +1 -1
- package/dist/esm/forms/commandInputs.js +9 -3
- package/dist/esm/forms/commandInputs.js.map +1 -1
- package/dist/esm/forms/generateCommandFieldsAction.d.ts +3 -0
- package/dist/esm/forms/generateCommandFieldsAction.d.ts.map +1 -0
- package/dist/esm/forms/generateCommandFieldsAction.js +56 -0
- package/dist/esm/forms/generateCommandFieldsAction.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/forms/CommandFormRuntime.tsx +5 -2
- package/forms/ExplicitCommandField.tsx +4 -2
- package/forms/SceneCommandForm.tsx +5 -3
- package/forms/commandInputs.ts +7 -3
- package/forms/generateCommandFieldsAction.ts +46 -0
- package/package.json +10 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Cratis. All rights reserved.
|
|
2
2
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
3
|
|
|
4
|
-
import { ComponentDescriptor, PropertyDescriptor, PropertyValueType, QueryResultShape } from '@cratis/scene.model';
|
|
4
|
+
import { BindingMode, BindingSourceKind, ComponentDescriptor, DesignTimeActionPlacement, PropertyDescriptor, PropertyValueType, QueryResultShape } from '@cratis/scene.model';
|
|
5
5
|
import { componentRegistryKey } from '@cratis/scene.react';
|
|
6
6
|
|
|
7
7
|
// The package name, spelled out so describing components does not pull every adapter (and its UI dependencies) in
|
|
@@ -32,6 +32,45 @@ const dataTableProperties: PropertyDescriptor[] = [
|
|
|
32
32
|
path: 'globalFilterFields', label: 'Searchable fields', group: 'Data', valueType: PropertyValueType.Object, editorKind: 'resultFieldList',
|
|
33
33
|
description: 'The result fields the table\'s search box looks in.',
|
|
34
34
|
},
|
|
35
|
+
{
|
|
36
|
+
path: 'selectedItem', label: 'Selected item', group: 'Outputs', valueType: PropertyValueType.Object, readOnly: true,
|
|
37
|
+
output: true, bindingMode: BindingMode.OneWay,
|
|
38
|
+
description: 'The currently selected row, or null after selection is cleared.',
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const commandFormProperties: PropertyDescriptor[] = [
|
|
43
|
+
{
|
|
44
|
+
path: 'command', label: 'Command', group: 'Command', valueType: PropertyValueType.String, editorKind: 'commandBinding',
|
|
45
|
+
constraints: { required: true },
|
|
46
|
+
description: 'The Arc command proxy rendered through the native command form runtime.',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
path: 'mode', label: 'Mode', group: 'Layout', valueType: PropertyValueType.Enum,
|
|
50
|
+
choices: [{ value: 'auto', label: 'Auto' }, { value: 'manual', label: 'Manual' }], default: 'auto',
|
|
51
|
+
description: 'Auto follows command metadata; manual renders explicit inputs inside the same native form boundary.',
|
|
52
|
+
},
|
|
53
|
+
{ path: 'columns', label: 'Columns', group: 'Layout', valueType: PropertyValueType.Number, default: 1 },
|
|
54
|
+
{ path: 'fieldWidths', label: 'Field widths', group: 'Layout', valueType: PropertyValueType.Object, editorKind: 'fieldWidths' },
|
|
55
|
+
{
|
|
56
|
+
path: 'inputs', label: 'Fields', group: 'Layout', valueType: PropertyValueType.Collection, editorKind: 'commandFields',
|
|
57
|
+
acceptedBindingKinds: [BindingSourceKind.DataContext, BindingSourceKind.ComponentProperty],
|
|
58
|
+
item: {
|
|
59
|
+
label: 'Field',
|
|
60
|
+
properties: [
|
|
61
|
+
{ path: 'property', label: 'Property', group: 'Field', valueType: PropertyValueType.String },
|
|
62
|
+
{ path: 'type', label: 'Type', group: 'Field', valueType: PropertyValueType.Enum, choices: [{ value: 'string', label: 'String' }, { value: 'guid', label: 'Guid' }] },
|
|
63
|
+
{ path: 'label', label: 'Label', group: 'Field', valueType: PropertyValueType.String },
|
|
64
|
+
{ path: 'column', label: 'Column', group: 'Layout', valueType: PropertyValueType.Number },
|
|
65
|
+
{ path: 'width', label: 'Width', group: 'Layout', valueType: PropertyValueType.String },
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
path: 'exclude', label: 'Excluded fields', group: 'Command', valueType: PropertyValueType.Collection,
|
|
71
|
+
item: { label: 'Excluded field', properties: [{ path: 'property', label: 'Property', group: 'Field', valueType: PropertyValueType.String }] },
|
|
72
|
+
},
|
|
73
|
+
{ path: 'submitLabel', label: 'Submit label', group: 'Content', valueType: PropertyValueType.String, default: 'Submit' },
|
|
35
74
|
];
|
|
36
75
|
|
|
37
76
|
/**
|
|
@@ -45,4 +84,17 @@ export const cratisComponentsDescriptors: ComponentDescriptor[] = [
|
|
|
45
84
|
{ component: key('dataTable'), displayName: 'Data table', properties: dataTableProperties },
|
|
46
85
|
{ component: key('table'), displayName: 'Table', properties: dataTableProperties },
|
|
47
86
|
{ component: key('observableDataTable'), displayName: 'Live data table', properties: dataTableProperties },
|
|
87
|
+
{
|
|
88
|
+
component: key('commandForm'),
|
|
89
|
+
displayName: 'Command form',
|
|
90
|
+
editorKind: 'commandFormDesigner',
|
|
91
|
+
properties: commandFormProperties,
|
|
92
|
+
actions: [{
|
|
93
|
+
id: 'Cratis.Components.commandForm.generateFields',
|
|
94
|
+
label: 'Generate fields',
|
|
95
|
+
placement: DesignTimeActionPlacement.Toolbar,
|
|
96
|
+
availability: 'commandForm.canGenerateFields',
|
|
97
|
+
description: 'Creates a deterministic editable field layout from the selected command metadata.',
|
|
98
|
+
}],
|
|
99
|
+
},
|
|
48
100
|
];
|
|
@@ -5,6 +5,7 @@ import { PackageKind, ScenePackage } from '@cratis/scene.model';
|
|
|
5
5
|
import { ScenePackageBundle } from '@cratis/scene.react';
|
|
6
6
|
import { cratisComponents, cratisComponentsPackageName } from './cratisComponents';
|
|
7
7
|
import { cratisComponentsDescriptors } from './cratisComponentsDescriptors';
|
|
8
|
+
import { generateCommandFieldsAction } from './forms/generateCommandFieldsAction';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* The `Cratis.Components` package's declaration - what a profile gets when it lists this package.
|
|
@@ -95,6 +96,15 @@ export const cratisComponentsPackageManifest: ScenePackage = {
|
|
|
95
96
|
module: '@cratis/scene.components',
|
|
96
97
|
license: 'MIT',
|
|
97
98
|
licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',
|
|
99
|
+
designTime: {
|
|
100
|
+
previews: [],
|
|
101
|
+
designers: ['commandFormDesigner'],
|
|
102
|
+
propertyEditors: ['commandBinding', 'commandFields', 'fieldWidths'],
|
|
103
|
+
propertyDisplays: [],
|
|
104
|
+
actions: ['Cratis.Components.commandForm.generateFields'],
|
|
105
|
+
},
|
|
106
|
+
assets: ['@cratis/components/styles', '@cratis/components/tokens'],
|
|
107
|
+
runtimeSingletons: ['react', '@cratis/arc', '@cratis/components'],
|
|
98
108
|
};
|
|
99
109
|
|
|
100
110
|
/**
|
|
@@ -108,4 +118,9 @@ export const cratisComponentsPackage: ScenePackageBundle = {
|
|
|
108
118
|
manifest: cratisComponentsPackageManifest,
|
|
109
119
|
components: cratisComponents,
|
|
110
120
|
descriptors: cratisComponentsDescriptors,
|
|
121
|
+
designTime: {
|
|
122
|
+
actions: {
|
|
123
|
+
[generateCommandFieldsAction.descriptor.id]: generateCommandFieldsAction,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
111
126
|
};
|
|
@@ -53,6 +53,141 @@ const key = (name)=>scene_react.componentRegistryKey('Cratis.Components', name);
|
|
|
53
53
|
valueType: scene_model.PropertyValueType.Object,
|
|
54
54
|
editorKind: 'resultFieldList',
|
|
55
55
|
description: 'The result fields the table\'s search box looks in.'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
path: 'selectedItem',
|
|
59
|
+
label: 'Selected item',
|
|
60
|
+
group: 'Outputs',
|
|
61
|
+
valueType: scene_model.PropertyValueType.Object,
|
|
62
|
+
readOnly: true,
|
|
63
|
+
output: true,
|
|
64
|
+
bindingMode: scene_model.BindingMode.OneWay,
|
|
65
|
+
description: 'The currently selected row, or null after selection is cleared.'
|
|
66
|
+
}
|
|
67
|
+
];
|
|
68
|
+
const commandFormProperties = [
|
|
69
|
+
{
|
|
70
|
+
path: 'command',
|
|
71
|
+
label: 'Command',
|
|
72
|
+
group: 'Command',
|
|
73
|
+
valueType: scene_model.PropertyValueType.String,
|
|
74
|
+
editorKind: 'commandBinding',
|
|
75
|
+
constraints: {
|
|
76
|
+
required: true
|
|
77
|
+
},
|
|
78
|
+
description: 'The Arc command proxy rendered through the native command form runtime.'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
path: 'mode',
|
|
82
|
+
label: 'Mode',
|
|
83
|
+
group: 'Layout',
|
|
84
|
+
valueType: scene_model.PropertyValueType.Enum,
|
|
85
|
+
choices: [
|
|
86
|
+
{
|
|
87
|
+
value: 'auto',
|
|
88
|
+
label: 'Auto'
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
value: 'manual',
|
|
92
|
+
label: 'Manual'
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
default: 'auto',
|
|
96
|
+
description: 'Auto follows command metadata; manual renders explicit inputs inside the same native form boundary.'
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
path: 'columns',
|
|
100
|
+
label: 'Columns',
|
|
101
|
+
group: 'Layout',
|
|
102
|
+
valueType: scene_model.PropertyValueType.Number,
|
|
103
|
+
default: 1
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
path: 'fieldWidths',
|
|
107
|
+
label: 'Field widths',
|
|
108
|
+
group: 'Layout',
|
|
109
|
+
valueType: scene_model.PropertyValueType.Object,
|
|
110
|
+
editorKind: 'fieldWidths'
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
path: 'inputs',
|
|
114
|
+
label: 'Fields',
|
|
115
|
+
group: 'Layout',
|
|
116
|
+
valueType: scene_model.PropertyValueType.Collection,
|
|
117
|
+
editorKind: 'commandFields',
|
|
118
|
+
acceptedBindingKinds: [
|
|
119
|
+
scene_model.BindingSourceKind.DataContext,
|
|
120
|
+
scene_model.BindingSourceKind.ComponentProperty
|
|
121
|
+
],
|
|
122
|
+
item: {
|
|
123
|
+
label: 'Field',
|
|
124
|
+
properties: [
|
|
125
|
+
{
|
|
126
|
+
path: 'property',
|
|
127
|
+
label: 'Property',
|
|
128
|
+
group: 'Field',
|
|
129
|
+
valueType: scene_model.PropertyValueType.String
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
path: 'type',
|
|
133
|
+
label: 'Type',
|
|
134
|
+
group: 'Field',
|
|
135
|
+
valueType: scene_model.PropertyValueType.Enum,
|
|
136
|
+
choices: [
|
|
137
|
+
{
|
|
138
|
+
value: 'string',
|
|
139
|
+
label: 'String'
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
value: 'guid',
|
|
143
|
+
label: 'Guid'
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
path: 'label',
|
|
149
|
+
label: 'Label',
|
|
150
|
+
group: 'Field',
|
|
151
|
+
valueType: scene_model.PropertyValueType.String
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
path: 'column',
|
|
155
|
+
label: 'Column',
|
|
156
|
+
group: 'Layout',
|
|
157
|
+
valueType: scene_model.PropertyValueType.Number
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
path: 'width',
|
|
161
|
+
label: 'Width',
|
|
162
|
+
group: 'Layout',
|
|
163
|
+
valueType: scene_model.PropertyValueType.String
|
|
164
|
+
}
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
path: 'exclude',
|
|
170
|
+
label: 'Excluded fields',
|
|
171
|
+
group: 'Command',
|
|
172
|
+
valueType: scene_model.PropertyValueType.Collection,
|
|
173
|
+
item: {
|
|
174
|
+
label: 'Excluded field',
|
|
175
|
+
properties: [
|
|
176
|
+
{
|
|
177
|
+
path: 'property',
|
|
178
|
+
label: 'Property',
|
|
179
|
+
group: 'Field',
|
|
180
|
+
valueType: scene_model.PropertyValueType.String
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
path: 'submitLabel',
|
|
187
|
+
label: 'Submit label',
|
|
188
|
+
group: 'Content',
|
|
189
|
+
valueType: scene_model.PropertyValueType.String,
|
|
190
|
+
default: 'Submit'
|
|
56
191
|
}
|
|
57
192
|
];
|
|
58
193
|
/**
|
|
@@ -76,6 +211,21 @@ const key = (name)=>scene_react.componentRegistryKey('Cratis.Components', name);
|
|
|
76
211
|
component: key('observableDataTable'),
|
|
77
212
|
displayName: 'Live data table',
|
|
78
213
|
properties: dataTableProperties
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
component: key('commandForm'),
|
|
217
|
+
displayName: 'Command form',
|
|
218
|
+
editorKind: 'commandFormDesigner',
|
|
219
|
+
properties: commandFormProperties,
|
|
220
|
+
actions: [
|
|
221
|
+
{
|
|
222
|
+
id: 'Cratis.Components.commandForm.generateFields',
|
|
223
|
+
label: 'Generate fields',
|
|
224
|
+
placement: scene_model.DesignTimeActionPlacement.Toolbar,
|
|
225
|
+
availability: 'commandForm.canGenerateFields',
|
|
226
|
+
description: 'Creates a deterministic editable field layout from the selected command metadata.'
|
|
227
|
+
}
|
|
228
|
+
]
|
|
79
229
|
}
|
|
80
230
|
];
|
|
81
231
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cratisComponentsDescriptors.js","sources":["../../cratisComponentsDescriptors.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 { ComponentDescriptor, PropertyDescriptor, PropertyValueType, QueryResultShape } from '@cratis/scene.model';\nimport { componentRegistryKey } from '@cratis/scene.react';\n\n// The package name, spelled out so describing components does not pull every adapter (and its UI dependencies) in\n// with it; the bundle's validation checks each key against the manifest.\nconst key = (name: string) => componentRegistryKey('Cratis.Components', name);\n\n/**\n * The properties every query-bound data table shares: which query feeds it, and the few settings that shape how\n * it shows the result.\n *\n * `query` is a `QueryReference`, so an editor binds it to a host-supplied query candidate and validates the\n * arguments against it. What is stored is a `QueryBinding`; a plain query name - what screens carried before\n * bindings existed - is still read, as a binding with no explicit connections. The columns are not properties:\n * they are the `content` slot's children, edited as nodes.\n */\nconst dataTableProperties: PropertyDescriptor[] = [\n {\n path: 'query', label: 'Query', group: 'Data', valueType: PropertyValueType.QueryReference, editorKind: 'queryBinding',\n description: 'The collection query that feeds the table.',\n constraints: { required: true, resultShapes: [QueryResultShape.Collection] },\n },\n { path: 'emptyMessage', label: 'Empty message', group: 'Content', valueType: PropertyValueType.String, default: '' },\n {\n path: 'dataKey', label: 'Row identity', group: 'Data', valueType: PropertyValueType.String, editorKind: 'resultField',\n description: 'The result field that identifies a row.',\n },\n {\n path: 'globalFilterFields', label: 'Searchable fields', group: 'Data', valueType: PropertyValueType.Object, editorKind: 'resultFieldList',\n description: 'The result fields the table\\'s search box looks in.',\n },\n];\n\n/**\n * What can be edited on the `Cratis.Components` package's components.\n *\n * Only the query-bound tables are described so far; the form, dialog and editor composites carry\n * Arc proxy classes by name and are configured through their own tooling. A package adds a descriptor here the\n * same way it adds a component to the manifest.\n */\nexport const cratisComponentsDescriptors: ComponentDescriptor[] = [\n { component: key('dataTable'), displayName: 'Data table', properties: dataTableProperties },\n { component: key('table'), displayName: 'Table', properties: dataTableProperties },\n { component: key('observableDataTable'), displayName: 'Live data table', properties: dataTableProperties },\n];\n"],"names":["key","name","componentRegistryKey","dataTableProperties","path","label","group","valueType","PropertyValueType","QueryReference","editorKind","description","constraints","required","resultShapes","QueryResultShape","Collection","String","default","Object","cratisComponentsDescriptors","component","displayName","properties"],"mappings":";;;;;AAAA;AACA;AAKA;AACA;AACA,MAAMA,GAAAA,GAAM,CAACC,IAAAA,GAAiBC,gCAAAA,CAAqB,mBAAA,EAAqBD,IAAAA,CAAAA;AAExE;;;;;;;;AAQC,IACD,MAAME,mBA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AAAA,CAAI,qBAAA,CAAA;QAAwBsB,WAAAA,EAAa,iBAAA;QAAmBC,UAAAA,EAAYpB;AAAoB;;;"}
|
|
1
|
+
{"version":3,"file":"cratisComponentsDescriptors.js","sources":["../../cratisComponentsDescriptors.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 { BindingMode, BindingSourceKind, ComponentDescriptor, DesignTimeActionPlacement, PropertyDescriptor, PropertyValueType, QueryResultShape } from '@cratis/scene.model';\nimport { componentRegistryKey } from '@cratis/scene.react';\n\n// The package name, spelled out so describing components does not pull every adapter (and its UI dependencies) in\n// with it; the bundle's validation checks each key against the manifest.\nconst key = (name: string) => componentRegistryKey('Cratis.Components', name);\n\n/**\n * The properties every query-bound data table shares: which query feeds it, and the few settings that shape how\n * it shows the result.\n *\n * `query` is a `QueryReference`, so an editor binds it to a host-supplied query candidate and validates the\n * arguments against it. What is stored is a `QueryBinding`; a plain query name - what screens carried before\n * bindings existed - is still read, as a binding with no explicit connections. The columns are not properties:\n * they are the `content` slot's children, edited as nodes.\n */\nconst dataTableProperties: PropertyDescriptor[] = [\n {\n path: 'query', label: 'Query', group: 'Data', valueType: PropertyValueType.QueryReference, editorKind: 'queryBinding',\n description: 'The collection query that feeds the table.',\n constraints: { required: true, resultShapes: [QueryResultShape.Collection] },\n },\n { path: 'emptyMessage', label: 'Empty message', group: 'Content', valueType: PropertyValueType.String, default: '' },\n {\n path: 'dataKey', label: 'Row identity', group: 'Data', valueType: PropertyValueType.String, editorKind: 'resultField',\n description: 'The result field that identifies a row.',\n },\n {\n path: 'globalFilterFields', label: 'Searchable fields', group: 'Data', valueType: PropertyValueType.Object, editorKind: 'resultFieldList',\n description: 'The result fields the table\\'s search box looks in.',\n },\n {\n path: 'selectedItem', label: 'Selected item', group: 'Outputs', valueType: PropertyValueType.Object, readOnly: true,\n output: true, bindingMode: BindingMode.OneWay,\n description: 'The currently selected row, or null after selection is cleared.',\n },\n];\n\nconst commandFormProperties: PropertyDescriptor[] = [\n {\n path: 'command', label: 'Command', group: 'Command', valueType: PropertyValueType.String, editorKind: 'commandBinding',\n constraints: { required: true },\n description: 'The Arc command proxy rendered through the native command form runtime.',\n },\n {\n path: 'mode', label: 'Mode', group: 'Layout', valueType: PropertyValueType.Enum,\n choices: [{ value: 'auto', label: 'Auto' }, { value: 'manual', label: 'Manual' }], default: 'auto',\n description: 'Auto follows command metadata; manual renders explicit inputs inside the same native form boundary.',\n },\n { path: 'columns', label: 'Columns', group: 'Layout', valueType: PropertyValueType.Number, default: 1 },\n { path: 'fieldWidths', label: 'Field widths', group: 'Layout', valueType: PropertyValueType.Object, editorKind: 'fieldWidths' },\n {\n path: 'inputs', label: 'Fields', group: 'Layout', valueType: PropertyValueType.Collection, editorKind: 'commandFields',\n acceptedBindingKinds: [BindingSourceKind.DataContext, BindingSourceKind.ComponentProperty],\n item: {\n label: 'Field',\n properties: [\n { path: 'property', label: 'Property', group: 'Field', valueType: PropertyValueType.String },\n { path: 'type', label: 'Type', group: 'Field', valueType: PropertyValueType.Enum, choices: [{ value: 'string', label: 'String' }, { value: 'guid', label: 'Guid' }] },\n { path: 'label', label: 'Label', group: 'Field', valueType: PropertyValueType.String },\n { path: 'column', label: 'Column', group: 'Layout', valueType: PropertyValueType.Number },\n { path: 'width', label: 'Width', group: 'Layout', valueType: PropertyValueType.String },\n ],\n },\n },\n {\n path: 'exclude', label: 'Excluded fields', group: 'Command', valueType: PropertyValueType.Collection,\n item: { label: 'Excluded field', properties: [{ path: 'property', label: 'Property', group: 'Field', valueType: PropertyValueType.String }] },\n },\n { path: 'submitLabel', label: 'Submit label', group: 'Content', valueType: PropertyValueType.String, default: 'Submit' },\n];\n\n/**\n * What can be edited on the `Cratis.Components` package's components.\n *\n * Only the query-bound tables are described so far; the form, dialog and editor composites carry\n * Arc proxy classes by name and are configured through their own tooling. A package adds a descriptor here the\n * same way it adds a component to the manifest.\n */\nexport const cratisComponentsDescriptors: ComponentDescriptor[] = [\n { component: key('dataTable'), displayName: 'Data table', properties: dataTableProperties },\n { component: key('table'), displayName: 'Table', properties: dataTableProperties },\n { component: key('observableDataTable'), displayName: 'Live data table', properties: dataTableProperties },\n {\n component: key('commandForm'),\n displayName: 'Command form',\n editorKind: 'commandFormDesigner',\n properties: commandFormProperties,\n actions: [{\n id: 'Cratis.Components.commandForm.generateFields',\n label: 'Generate fields',\n placement: DesignTimeActionPlacement.Toolbar,\n availability: 'commandForm.canGenerateFields',\n description: 'Creates a deterministic editable field layout from the selected command metadata.',\n }],\n },\n];\n"],"names":["key","name","componentRegistryKey","dataTableProperties","path","label","group","valueType","PropertyValueType","QueryReference","editorKind","description","constraints","required","resultShapes","QueryResultShape","Collection","String","default","Object","readOnly","output","bindingMode","BindingMode","OneWay","commandFormProperties","Enum","choices","value","Number","acceptedBindingKinds","BindingSourceKind","DataContext","ComponentProperty","item","properties","cratisComponentsDescriptors","component","displayName","actions","id","placement","DesignTimeActionPlacement","Toolbar","availability"],"mappings":";;;;;AAAA;AACA;AAKA;AACA;AACA,MAAMA,GAAAA,GAAM,CAACC,IAAAA,GAAiBC,gCAAAA,CAAqB,mBAAA,EAAqBD,IAAAA,CAAAA;AAExE;;;;;;;;AAQC,IACD,MAAME,mBAAAA,GAA4C;AAC9C,IAAA;QACIC,IAAAA,EAAM,OAAA;QAASC,KAAAA,EAAO,OAAA;QAASC,KAAAA,EAAO,MAAA;AAAQC,QAAAA,SAAAA,EAAWC,8BAAkBC,cAAc;QAAEC,UAAAA,EAAY,cAAA;QACvGC,WAAAA,EAAa,4CAAA;QACbC,WAAAA,EAAa;YAAEC,QAAAA,EAAU,IAAA;YAAMC,YAAAA,EAAc;AAACC,gBAAAA,4BAAAA,CAAiBC;AAAW;AAAC;AAC/E,KAAA;AACA,IAAA;QAAEZ,IAAAA,EAAM,cAAA;QAAgBC,KAAAA,EAAO,eAAA;QAAiBC,KAAAA,EAAO,SAAA;AAAWC,QAAAA,SAAAA,EAAWC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AAC1F,IAAA;AAAEkC,QAAAA,SAAAA,EAAWrC,GAAAA,CAAI,OAAA,CAAA;QAAUsC,WAAAA,EAAa,OAAA;QAASH,UAAAA,EAAYhC;AAAoB,KAAA;AACjF,IAAA;AAAEkC,QAAAA,SAAAA,EAAWrC,GAAAA,CAAI,qBAAA,CAAA;QAAwBsC,WAAAA,EAAa,iBAAA;QAAmBH,UAAAA,EAAYhC;AAAoB,KAAA;AACzG,IAAA;AACIkC,QAAAA,SAAAA,EAAWrC,GAAAA,CAAI,aAAA,CAAA;QACfsC,WAAAA,EAAa,cAAA;QACb5B,UAAAA,EAAY,qBAAA;QACZyB,UAAAA,EAAYV,qBAAAA;QACZc,OAAAA,EAAS;AAAC,YAAA;gBACNC,EAAAA,EAAI,8CAAA;gBACJnC,KAAAA,EAAO,iBAAA;AACPoC,gBAAAA,SAAAA,EAAWC,sCAA0BC,OAAO;gBAC5CC,YAAAA,EAAc,+BAAA;gBACdjC,WAAAA,EAAa;AACjB;AAAE;AACN;;;"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var scene_model = require('@cratis/scene.model');
|
|
4
4
|
var cratisComponents = require('./cratisComponents.js');
|
|
5
5
|
var cratisComponentsDescriptors = require('./cratisComponentsDescriptors.js');
|
|
6
|
+
var generateCommandFieldsAction = require('./forms/generateCommandFieldsAction.js');
|
|
6
7
|
|
|
7
8
|
// Copyright (c) Cratis. All rights reserved.
|
|
8
9
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
@@ -96,7 +97,31 @@ var cratisComponentsDescriptors = require('./cratisComponentsDescriptors.js');
|
|
|
96
97
|
description: "Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind. dataTable and table accept optional object-valued queryArguments for collection queries. singleResult displays one read-only scalar own resultField of an optional model using an explicit query, object queryArguments and enabled: true. queryInputForm commits explicit string inputs on submit to the same optional-single runtime; drafts never execute a query.",
|
|
97
98
|
module: '@cratis/scene.components',
|
|
98
99
|
license: 'MIT',
|
|
99
|
-
licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE'
|
|
100
|
+
licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',
|
|
101
|
+
designTime: {
|
|
102
|
+
previews: [],
|
|
103
|
+
designers: [
|
|
104
|
+
'commandFormDesigner'
|
|
105
|
+
],
|
|
106
|
+
propertyEditors: [
|
|
107
|
+
'commandBinding',
|
|
108
|
+
'commandFields',
|
|
109
|
+
'fieldWidths'
|
|
110
|
+
],
|
|
111
|
+
propertyDisplays: [],
|
|
112
|
+
actions: [
|
|
113
|
+
'Cratis.Components.commandForm.generateFields'
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
assets: [
|
|
117
|
+
'@cratis/components/styles',
|
|
118
|
+
'@cratis/components/tokens'
|
|
119
|
+
],
|
|
120
|
+
runtimeSingletons: [
|
|
121
|
+
'react',
|
|
122
|
+
'@cratis/arc',
|
|
123
|
+
'@cratis/components'
|
|
124
|
+
]
|
|
100
125
|
};
|
|
101
126
|
/**
|
|
102
127
|
* The `Cratis.Components` package as a loadable bundle - the manifest above, plus the React components
|
|
@@ -107,7 +132,12 @@ var cratisComponentsDescriptors = require('./cratisComponentsDescriptors.js');
|
|
|
107
132
|
*/ const cratisComponentsPackage = {
|
|
108
133
|
manifest: cratisComponentsPackageManifest,
|
|
109
134
|
components: cratisComponents.cratisComponents,
|
|
110
|
-
descriptors: cratisComponentsDescriptors.cratisComponentsDescriptors
|
|
135
|
+
descriptors: cratisComponentsDescriptors.cratisComponentsDescriptors,
|
|
136
|
+
designTime: {
|
|
137
|
+
actions: {
|
|
138
|
+
[generateCommandFieldsAction.generateCommandFieldsAction.descriptor.id]: generateCommandFieldsAction.generateCommandFieldsAction
|
|
139
|
+
}
|
|
140
|
+
}
|
|
111
141
|
};
|
|
112
142
|
|
|
113
143
|
exports.cratisComponentsPackage = cratisComponentsPackage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cratisComponentsPackage.js","sources":["../../cratisComponentsPackage.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 { PackageKind, ScenePackage } from '@cratis/scene.model';\nimport { ScenePackageBundle } from '@cratis/scene.react';\nimport { cratisComponents, cratisComponentsPackageName } from './cratisComponents';\nimport { cratisComponentsDescriptors } from './cratisComponentsDescriptors';\n\n/**\n * The `Cratis.Components` package's declaration - what a profile gets when it lists this package.\n *\n * This is the concrete case the whole package-dependency mechanism exists for. `@cratis/components` is\n * not a self-contained library: every component in it is a wrapper over a PrimeReact widget, and its own\n * styling is a `--cratis-*` token layer (`@cratis/components/tokens`) plus the component stylesheets and\n * compiled Tailwind utilities in `@cratis/components/styles`. Activate it in a profile without PrimeReact\n * and nothing renders; activate it without Tailwind and everything renders unstyled. Both are stated as\n * dependencies so a package picker can say so while the profile is being configured, instead of leaving\n * it to be discovered when the page opens.\n *\n * The version ranges are the real ones the library carries. `>=11.0.0` for PrimeReact: version 3.0.0\n * declares `primereact@^11` as a peer dependency and is built against version 11's component set, so the\n * span across the major boundary that the previous `>=10.9.0` range described is over. The `--cratis-*`\n * tokens still resolve a version 10 theme variable as their last fallback, but that is an upgrade-window\n * courtesy for an application with a compiled version 10 stylesheet still on the page - not a version of\n * PrimeReact this package can be activated against. `^4.0.0` for Tailwind, because the utility sheet is\n * compiled against Tailwind 4.\n */\nexport const cratisComponentsPackageManifest: ScenePackage = {\n name: cratisComponentsPackageName,\n version: '3.0.0',\n kind: PackageKind.ComponentLibrary,\n dependencies: [\n { name: 'PrimeReact', versionRange: '>=11.0.0' },\n { name: 'Tailwind', versionRange: '^4.0.0' },\n ],\n components: [\n 'page',\n 'dataPage',\n 'formElement',\n 'singleResult',\n 'queryInputForm',\n 'dataTable',\n 'table',\n 'observableDataTable',\n 'commandForm',\n 'inputTextField',\n 'numberField',\n 'checkboxField',\n 'textAreaField',\n 'dropdownField',\n 'sliderField',\n 'calendarField',\n 'colorPickerField',\n 'multiSelectField',\n 'chipsField',\n 'radioButtonField',\n 'radioGroupField',\n 'dialog',\n 'confirmationDialog',\n 'busyIndicatorDialog',\n 'commandDialog',\n 'stepperCommandDialog',\n 'icon',\n 'tooltip',\n 'dropdown',\n 'errorBoundary',\n 'objectContentEditor',\n 'objectNavigationalBar',\n 'schemaEditor',\n 'timeMachine',\n 'filterPanel',\n 'toolbar',\n 'toolbarButton',\n 'toolbarGroup',\n 'toolbarSeparator',\n ],\n\n // A component library ships components, and nothing else. Layouts, screen templates and dialog\n // templates all belong to a Blueprint: they are decisions about what an application looks like as a\n // whole, and this package deliberately makes none of them - it provides the Arc-bound composites a\n // template is *built from*, so that a blueprint can place a `dataPage` in a slot and configure it,\n // rather than shipping one opinionated data page nobody can rearrange.\n layouts: [],\n screenTemplates: [],\n dialogTemplates: [],\n\n // No themes either, for a different reason: `@cratis/components` has no palette of its own. It reads\n // a `--cratis-*` variable layer that resolves whatever is in front of it - the `--p-*` properties a\n // PrimeReact 11 preset emits at runtime, or a Scene theme through this package's token bridge.\n // Shipping a theme here would be this library asserting a look it was specifically built not to have.\n themes: [],\n\n displayName: 'Cratis Components',\n description: \"Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind. dataTable and table accept optional object-valued queryArguments for collection queries. singleResult displays one read-only scalar own resultField of an optional model using an explicit query, object queryArguments and enabled: true. queryInputForm commits explicit string inputs on submit to the same optional-single runtime; drafts never execute a query.\",\n module: '@cratis/scene.components',\n license: 'MIT',\n licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',\n};\n\n/**\n * The `Cratis.Components` package as a loadable bundle - the manifest above, plus the React components\n * behind the names it declares.\n *\n * No `layouts`, `screenTemplates`, `dialogTemplates` or `themes` are provided, matching a manifest that\n * declares none of them; `validatePackageBundle` is what proves the two halves agree.\n */\nexport const cratisComponentsPackage: ScenePackageBundle = {\n manifest: cratisComponentsPackageManifest,\n components: cratisComponents,\n descriptors: cratisComponentsDescriptors,\n};\n"],"names":["cratisComponentsPackageManifest","name","cratisComponentsPackageName","version","kind","PackageKind","ComponentLibrary","dependencies","versionRange","components","layouts","screenTemplates","dialogTemplates","themes","displayName","description","module","license","licenseUrl","cratisComponentsPackage","manifest","cratisComponents","descriptors","cratisComponentsDescriptors"],"mappings":"
|
|
1
|
+
{"version":3,"file":"cratisComponentsPackage.js","sources":["../../cratisComponentsPackage.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 { PackageKind, ScenePackage } from '@cratis/scene.model';\nimport { ScenePackageBundle } from '@cratis/scene.react';\nimport { cratisComponents, cratisComponentsPackageName } from './cratisComponents';\nimport { cratisComponentsDescriptors } from './cratisComponentsDescriptors';\nimport { generateCommandFieldsAction } from './forms/generateCommandFieldsAction';\n\n/**\n * The `Cratis.Components` package's declaration - what a profile gets when it lists this package.\n *\n * This is the concrete case the whole package-dependency mechanism exists for. `@cratis/components` is\n * not a self-contained library: every component in it is a wrapper over a PrimeReact widget, and its own\n * styling is a `--cratis-*` token layer (`@cratis/components/tokens`) plus the component stylesheets and\n * compiled Tailwind utilities in `@cratis/components/styles`. Activate it in a profile without PrimeReact\n * and nothing renders; activate it without Tailwind and everything renders unstyled. Both are stated as\n * dependencies so a package picker can say so while the profile is being configured, instead of leaving\n * it to be discovered when the page opens.\n *\n * The version ranges are the real ones the library carries. `>=11.0.0` for PrimeReact: version 3.0.0\n * declares `primereact@^11` as a peer dependency and is built against version 11's component set, so the\n * span across the major boundary that the previous `>=10.9.0` range described is over. The `--cratis-*`\n * tokens still resolve a version 10 theme variable as their last fallback, but that is an upgrade-window\n * courtesy for an application with a compiled version 10 stylesheet still on the page - not a version of\n * PrimeReact this package can be activated against. `^4.0.0` for Tailwind, because the utility sheet is\n * compiled against Tailwind 4.\n */\nexport const cratisComponentsPackageManifest: ScenePackage = {\n name: cratisComponentsPackageName,\n version: '3.0.0',\n kind: PackageKind.ComponentLibrary,\n dependencies: [\n { name: 'PrimeReact', versionRange: '>=11.0.0' },\n { name: 'Tailwind', versionRange: '^4.0.0' },\n ],\n components: [\n 'page',\n 'dataPage',\n 'formElement',\n 'singleResult',\n 'queryInputForm',\n 'dataTable',\n 'table',\n 'observableDataTable',\n 'commandForm',\n 'inputTextField',\n 'numberField',\n 'checkboxField',\n 'textAreaField',\n 'dropdownField',\n 'sliderField',\n 'calendarField',\n 'colorPickerField',\n 'multiSelectField',\n 'chipsField',\n 'radioButtonField',\n 'radioGroupField',\n 'dialog',\n 'confirmationDialog',\n 'busyIndicatorDialog',\n 'commandDialog',\n 'stepperCommandDialog',\n 'icon',\n 'tooltip',\n 'dropdown',\n 'errorBoundary',\n 'objectContentEditor',\n 'objectNavigationalBar',\n 'schemaEditor',\n 'timeMachine',\n 'filterPanel',\n 'toolbar',\n 'toolbarButton',\n 'toolbarGroup',\n 'toolbarSeparator',\n ],\n\n // A component library ships components, and nothing else. Layouts, screen templates and dialog\n // templates all belong to a Blueprint: they are decisions about what an application looks like as a\n // whole, and this package deliberately makes none of them - it provides the Arc-bound composites a\n // template is *built from*, so that a blueprint can place a `dataPage` in a slot and configure it,\n // rather than shipping one opinionated data page nobody can rearrange.\n layouts: [],\n screenTemplates: [],\n dialogTemplates: [],\n\n // No themes either, for a different reason: `@cratis/components` has no palette of its own. It reads\n // a `--cratis-*` variable layer that resolves whatever is in front of it - the `--p-*` properties a\n // PrimeReact 11 preset emits at runtime, or a Scene theme through this package's token bridge.\n // Shipping a theme here would be this library asserting a look it was specifically built not to have.\n themes: [],\n\n displayName: 'Cratis Components',\n description: \"Cratis' Arc-bound data, form and dialog composites, built on PrimeReact and Tailwind. dataTable and table accept optional object-valued queryArguments for collection queries. singleResult displays one read-only scalar own resultField of an optional model using an explicit query, object queryArguments and enabled: true. queryInputForm commits explicit string inputs on submit to the same optional-single runtime; drafts never execute a query.\",\n module: '@cratis/scene.components',\n license: 'MIT',\n licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',\n designTime: {\n previews: [],\n designers: ['commandFormDesigner'],\n propertyEditors: ['commandBinding', 'commandFields', 'fieldWidths'],\n propertyDisplays: [],\n actions: ['Cratis.Components.commandForm.generateFields'],\n },\n assets: ['@cratis/components/styles', '@cratis/components/tokens'],\n runtimeSingletons: ['react', '@cratis/arc', '@cratis/components'],\n};\n\n/**\n * The `Cratis.Components` package as a loadable bundle - the manifest above, plus the React components\n * behind the names it declares.\n *\n * No `layouts`, `screenTemplates`, `dialogTemplates` or `themes` are provided, matching a manifest that\n * declares none of them; `validatePackageBundle` is what proves the two halves agree.\n */\nexport const cratisComponentsPackage: ScenePackageBundle = {\n manifest: cratisComponentsPackageManifest,\n components: cratisComponents,\n descriptors: cratisComponentsDescriptors,\n designTime: {\n actions: {\n [generateCommandFieldsAction.descriptor.id]: generateCommandFieldsAction,\n },\n },\n};\n"],"names":["cratisComponentsPackageManifest","name","cratisComponentsPackageName","version","kind","PackageKind","ComponentLibrary","dependencies","versionRange","components","layouts","screenTemplates","dialogTemplates","themes","displayName","description","module","license","licenseUrl","designTime","previews","designers","propertyEditors","propertyDisplays","actions","assets","runtimeSingletons","cratisComponentsPackage","manifest","cratisComponents","descriptors","cratisComponentsDescriptors","generateCommandFieldsAction","descriptor","id"],"mappings":";;;;;;;AAAA;AACA;AAQA;;;;;;;;;;;;;;;;;;UAmBaA,+BAAAA,GAAgD;IACzDC,IAAAA,EAAMC,4CAAAA;IACNC,OAAAA,EAAS,OAAA;AACTC,IAAAA,IAAAA,EAAMC,wBAAYC,gBAAgB;IAClCC,YAAAA,EAAc;AACV,QAAA;YAAEN,IAAAA,EAAM,YAAA;YAAcO,YAAAA,EAAc;AAAW,SAAA;AAC/C,QAAA;YAAEP,IAAAA,EAAM,UAAA;YAAYO,YAAAA,EAAc;AAAS;AAC9C,KAAA;IACDC,UAAAA,EAAY;AACR,QAAA,MAAA;AACA,QAAA,UAAA;AACA,QAAA,aAAA;AACA,QAAA,cAAA;AACA,QAAA,gBAAA;AACA,QAA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AA,OAAA;AAAS,QAAA,aAAA;AAAe,QAAA;AAAqB;AACrE;AAEA;;;;;;UAOaC,uBAAAA,GAA8C;IACvDC,QAAAA,EAAU5B,+BAAAA;IACVS,UAAAA,EAAYoB,iCAAAA;IACZC,WAAAA,EAAaC,uDAAAA;IACbZ,UAAAA,EAAY;QACRK,OAAAA,EAAS;AACL,YAAA,CAACQ,uDAAAA,CAA4BC,UAAU,CAACC,EAAE,GAAGF;AACjD;AACJ;AACJ;;;"}
|
|
@@ -49,7 +49,7 @@ const NativeAutoCommandForm = CommandForm.AutoCommandForm;
|
|
|
49
49
|
}
|
|
50
50
|
return undefined;
|
|
51
51
|
}
|
|
52
|
-
/** Private lazy entry point: importing the Scene registry must not import Arc. */ function CommandFormRuntime({ command, inputs, exclude, submitLabel }) {
|
|
52
|
+
/** Private lazy entry point: importing the Scene registry must not import Arc. */ function CommandFormRuntime({ command, inputs, exclude, submitLabel, columns = 1 }) {
|
|
53
53
|
const error = capability(command, inputs, exclude);
|
|
54
54
|
if (error) return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
55
55
|
role: "alert",
|
|
@@ -60,9 +60,16 @@ const NativeAutoCommandForm = CommandForm.AutoCommandForm;
|
|
|
60
60
|
command: command,
|
|
61
61
|
showTitles: false,
|
|
62
62
|
children: [
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
64
|
+
style: {
|
|
65
|
+
display: 'grid',
|
|
66
|
+
gridTemplateColumns: `repeat(${Math.max(1, columns)}, minmax(0, 1fr))`,
|
|
67
|
+
gap: '1rem'
|
|
68
|
+
},
|
|
69
|
+
children: inputs.map((input)=>/*#__PURE__*/ jsxRuntime.jsx(ExplicitCommandField.ExplicitCommandField, {
|
|
70
|
+
input: input
|
|
71
|
+
}, input.property))
|
|
72
|
+
}),
|
|
66
73
|
/*#__PURE__*/ jsxRuntime.jsx(CommandFormSubmit.CommandFormSubmit, {
|
|
67
74
|
label: submitLabel
|
|
68
75
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandFormRuntime.js","sources":["../../../forms/CommandFormRuntime.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 type { ComponentType, ReactNode } from 'react';\nimport { AutoCommandForm } from '@cratis/components/CommandForm';\nimport { CommandForm } from '@cratis/arc.react/commands';\nimport { Guid } from '@cratis/fundamentals';\nimport type { BoundConstructor } from '../bindings';\nimport type { CommandInput } from './commandInputs';\nimport { CommandFormSubmit } from './CommandFormSubmit';\nimport { ExplicitCommandField } from './ExplicitCommandField';\n\ninterface CommandFormRuntimeProps {\n command: BoundConstructor;\n inputs?: CommandInput[];\n exclude?: string[];\n submitLabel: string;\n}\n\n// Runtime bindings erase the proxy's keys; the optional footer is a Components >=4.13 contract.\nconst NativeAutoCommandForm = AutoCommandForm as unknown as ComponentType<{\n command: BoundConstructor;\n exclude?: string[];\n footer?: ReactNode;\n}>;\n\ntype Descriptor = { name: string; type: unknown; isOptional: boolean };\n\n/** Verify the whole command before mounting any native form: partial forms must never execute. */\nfunction capability(command: BoundConstructor, inputs?: CommandInput[], exclude?: string[]): string | undefined {\n let descriptors: unknown;\n try { descriptors = (new command() as { propertyDescriptors?: unknown }).propertyDescriptors; }\n catch { return 'Unable to inspect command proxy'; }\n if (!Array.isArray(descriptors)) return 'Command proxy has no property descriptors';\n const byName = new Map<string, Descriptor>();\n for (const descriptor of descriptors) {\n if (!descriptor || typeof descriptor.name !== 'string' || !descriptor.name ||\n typeof descriptor.isOptional !== 'boolean' || byName.has(descriptor.name)) return 'Ambiguous or invalid command property descriptors';\n byName.set(descriptor.name, descriptor);\n }\n if (inputs) {\n for (const input of inputs) {\n const descriptor = byName.get(input.property);\n if (!descriptor) return `Unknown command property '${input.property}'`;\n if (descriptor.type !== (input.type === 'guid' ? Guid : String)) return `Command property '${input.property}' type does not match '${input.type}'`;\n }\n for (const descriptor of byName.values()) {\n if (!descriptor.isOptional && !inputs.some(input => input.property === descriptor.name)) return `Required command property '${descriptor.name}' has no input`;\n }\n } else {\n for (const descriptor of byName.values()) {\n if (!descriptor.isOptional && (exclude?.includes(descriptor.name) ||\n ![String, Number, Boolean, Date].includes(descriptor.type as typeof String))) {\n return `Required command property '${descriptor.name}' has no supported automatic field; declare inputs`;\n }\n }\n }\n return undefined;\n}\n\n/** Private lazy entry point: importing the Scene registry must not import Arc. */\nexport default function CommandFormRuntime({ command, inputs, exclude, submitLabel }: CommandFormRuntimeProps) {\n const error = capability(command, inputs, exclude);\n if (error) return <div role='alert'>{error}</div>;\n // The registry's never-argument constructor is erased; Arc creates this checked proxy with no args.\n if (inputs) return <CommandForm command={command as unknown as new () => object} showTitles={false}>\n {inputs.map(input => <ExplicitCommandField key={input.property} input={input} />)}\n <CommandFormSubmit label={submitLabel} />\n </CommandForm>;\n return <NativeAutoCommandForm command={command} exclude={exclude} footer={<CommandFormSubmit label={submitLabel} />} />;\n}\n"],"names":["NativeAutoCommandForm","AutoCommandForm","capability","command","inputs","exclude","descriptors","propertyDescriptors","Array","isArray","byName","Map","descriptor","name","isOptional","has","set","input","get","property","type","Guid","String","values","some","includes","Number","Boolean","Date","undefined","CommandFormRuntime","submitLabel","error","_jsx","div","role","_jsxs","CommandForm","showTitles","map","ExplicitCommandField","CommandFormSubmit","label","footer"],"mappings":";;;;;;;;;;;AAAA;AACA;
|
|
1
|
+
{"version":3,"file":"CommandFormRuntime.js","sources":["../../../forms/CommandFormRuntime.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 type { ComponentType, ReactNode } from 'react';\nimport { AutoCommandForm } from '@cratis/components/CommandForm';\nimport { CommandForm } from '@cratis/arc.react/commands';\nimport { Guid } from '@cratis/fundamentals';\nimport type { BoundConstructor } from '../bindings';\nimport type { CommandInput } from './commandInputs';\nimport { CommandFormSubmit } from './CommandFormSubmit';\nimport { ExplicitCommandField } from './ExplicitCommandField';\n\ninterface CommandFormRuntimeProps {\n command: BoundConstructor;\n inputs?: CommandInput[];\n exclude?: string[];\n submitLabel: string;\n columns?: number;\n}\n\n// Runtime bindings erase the proxy's keys; the optional footer is a Components >=4.13 contract.\nconst NativeAutoCommandForm = AutoCommandForm as unknown as ComponentType<{\n command: BoundConstructor;\n exclude?: string[];\n footer?: ReactNode;\n}>;\n\ntype Descriptor = { name: string; type: unknown; isOptional: boolean };\n\n/** Verify the whole command before mounting any native form: partial forms must never execute. */\nfunction capability(command: BoundConstructor, inputs?: CommandInput[], exclude?: string[]): string | undefined {\n let descriptors: unknown;\n try { descriptors = (new command() as { propertyDescriptors?: unknown }).propertyDescriptors; }\n catch { return 'Unable to inspect command proxy'; }\n if (!Array.isArray(descriptors)) return 'Command proxy has no property descriptors';\n const byName = new Map<string, Descriptor>();\n for (const descriptor of descriptors) {\n if (!descriptor || typeof descriptor.name !== 'string' || !descriptor.name ||\n typeof descriptor.isOptional !== 'boolean' || byName.has(descriptor.name)) return 'Ambiguous or invalid command property descriptors';\n byName.set(descriptor.name, descriptor);\n }\n if (inputs) {\n for (const input of inputs) {\n const descriptor = byName.get(input.property);\n if (!descriptor) return `Unknown command property '${input.property}'`;\n if (descriptor.type !== (input.type === 'guid' ? Guid : String)) return `Command property '${input.property}' type does not match '${input.type}'`;\n }\n for (const descriptor of byName.values()) {\n if (!descriptor.isOptional && !inputs.some(input => input.property === descriptor.name)) return `Required command property '${descriptor.name}' has no input`;\n }\n } else {\n for (const descriptor of byName.values()) {\n if (!descriptor.isOptional && (exclude?.includes(descriptor.name) ||\n ![String, Number, Boolean, Date].includes(descriptor.type as typeof String))) {\n return `Required command property '${descriptor.name}' has no supported automatic field; declare inputs`;\n }\n }\n }\n return undefined;\n}\n\n/** Private lazy entry point: importing the Scene registry must not import Arc. */\nexport default function CommandFormRuntime({ command, inputs, exclude, submitLabel, columns = 1 }: CommandFormRuntimeProps) {\n const error = capability(command, inputs, exclude);\n if (error) return <div role='alert'>{error}</div>;\n // The registry's never-argument constructor is erased; Arc creates this checked proxy with no args.\n if (inputs) return <CommandForm command={command as unknown as new () => object} showTitles={false}>\n <div style={{ display: 'grid', gridTemplateColumns: `repeat(${Math.max(1, columns)}, minmax(0, 1fr))`, gap: '1rem' }}>\n {inputs.map(input => <ExplicitCommandField key={input.property} input={input} />)}\n </div>\n <CommandFormSubmit label={submitLabel} />\n </CommandForm>;\n return <NativeAutoCommandForm command={command} exclude={exclude} footer={<CommandFormSubmit label={submitLabel} />} />;\n}\n"],"names":["NativeAutoCommandForm","AutoCommandForm","capability","command","inputs","exclude","descriptors","propertyDescriptors","Array","isArray","byName","Map","descriptor","name","isOptional","has","set","input","get","property","type","Guid","String","values","some","includes","Number","Boolean","Date","undefined","CommandFormRuntime","submitLabel","columns","error","_jsx","div","role","_jsxs","CommandForm","showTitles","style","display","gridTemplateColumns","Math","max","gap","map","ExplicitCommandField","CommandFormSubmit","label","footer"],"mappings":";;;;;;;;;;;AAAA;AACA;AAmBA;AACA,MAAMA,qBAAAA,GAAwBC,2BAAAA;AAQ9B,mGACA,SAASC,UAAAA,CAAWC,OAAyB,EAAEC,MAAuB,EAAEC,OAAkB,EAAA;IACtF,IAAIC,WAAAA;IACJ,IAAI;QAAEA,WAAAA,GAAe,IAAIH,OAAAA,EAAAA,CAAgDI,mBAAmB;AAAE,IAAA,CAAA,CAC9F,OAAM;QAAE,OAAO,iCAAA;AAAmC,IAAA;AAClD,IAAA,IAAI,CAACC,KAAAA,CAAMC,OAAO,CAACH,cAAc,OAAO,2CAAA;AACxC,IAAA,MAAMI,SAAS,IAAIC,GAAAA,EAAAA;IACnB,KAAK,MAAMC,cAAcN,WAAAA,CAAa;QAClC,IAAI,CAACM,cAAc,OAAOA,UAAAA,CAAWC,IAAI,KAAK,QAAA,IAAY,CAACD,UAAAA,CAAWC,IAAI,IACtE,OAAOD,UAAAA,CAAWE,UAAU,KAAK,SAAA,IA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A,EAASA,OAAAA;QAASE,OAAAA,EAASA,OAAAA;AAAS6C,QAAAA,MAAAA,gBAAQhB,cAAA,CAACc,mCAAAA,EAAAA;YAAkBC,KAAAA,EAAOlB;;;AACxG;;"}
|
|
@@ -95,13 +95,19 @@ const NativeTextField = commands.asCommandFormField(TextControl, {
|
|
|
95
95
|
defaultValue: ''
|
|
96
96
|
});
|
|
97
97
|
/** Opaque child is self-bound by Arc's native runtime binding, with an exact fieldName. */ function ExplicitCommandField({ input }) {
|
|
98
|
-
return /*#__PURE__*/ jsxRuntime.jsx(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
99
|
+
style: {
|
|
100
|
+
gridColumn: input.column === undefined ? undefined : `${input.column}`,
|
|
101
|
+
width: input.width
|
|
102
|
+
},
|
|
103
|
+
children: /*#__PURE__*/ jsxRuntime.jsx(NativeTextField, {
|
|
104
|
+
fieldName: input.property,
|
|
105
|
+
value: (command)=>command[input.property],
|
|
106
|
+
property: input.property,
|
|
107
|
+
guid: input.type === 'guid',
|
|
108
|
+
label: input.label,
|
|
109
|
+
title: input.label
|
|
110
|
+
})
|
|
105
111
|
});
|
|
106
112
|
}
|
|
107
113
|
|
|
@@ -1 +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
|
|
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 <div style={{ gridColumn: input.column === undefined ? undefined : `${input.column}`, width: input.width }}>\n <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 </div>;\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","style","gridColumn","column","width","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,WAAAA,EAAAA;AACX,IAAA,MAAMC,OAAAA,GAAUC,8BAAAA,EAAAA;IAChB,MAAM,EAAEC,mBAAmB,EAAE,GAAGF,OAAAA;;;AAGhC,IAAA,MAAMG,aAAaC,YAAAA,CAAOJ,OAAAA,CAAAA;AAC1BG,IAAAA,UAAAA,CAAWE,OAAO,GAAGL,OAAAA;;;AAGrB,IAAA,MAAM,CAACM,KAAAA,EAAOC,QAAAA,CAAS,GAAGC,cAAAA,CAAS,IAAMnB,KAAAA,YAAiBoB,iBAAAA,IAAQ,CAACpB,KAAAA,CAAMqB,MAAM,CAACD,iBAAAA,CAAKE,KAAK,CAAA,GAAItB,KAAAA,CAAMuB,QAAQ,EAAA,GAAK,EAAA,CAAA;AACjH,IAAA,MAAMC,WAAWT,YAAAA,CAAOE,KAAAA,CAAAA;AACxB,IAAA,MAAMQ,aAAaV,YAAAA,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,aAA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QAAAA,EAAUiC,MAAMjC,QAAQ;YAAEC,IAAAA,EAAMgC,KAAAA,CAAME,IAAI,KAAK,MAAA;AAAQpC,YAAAA,KAAAA,EAAOkC,MAAMlC,KAAK;AAAEuD,YAAAA,KAAAA,EAAOrB,MAAMlC;;;AAEpG;;"}
|
|
@@ -32,8 +32,12 @@ function commandKey(command) {
|
|
|
32
32
|
kind: BindingKind.BindingKind.Command,
|
|
33
33
|
name: name
|
|
34
34
|
});
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const mode = properties.unionProperty(element.properties, 'mode', [
|
|
36
|
+
'auto',
|
|
37
|
+
'manual'
|
|
38
|
+
]) ?? (Object.hasOwn(element.properties, 'inputs') ? 'manual' : 'auto');
|
|
39
|
+
const inputs = mode === 'manual' ? commandInputs.commandInputs(element.properties) : undefined;
|
|
40
|
+
if (mode === 'manual' && !inputs) return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
37
41
|
role: "alert",
|
|
38
42
|
children: "Invalid command form inputs declaration"
|
|
39
43
|
});
|
|
@@ -42,7 +46,10 @@ function commandKey(command) {
|
|
|
42
46
|
command: target,
|
|
43
47
|
inputs: inputs,
|
|
44
48
|
exclude: properties.stringArrayProperty(element.properties, 'exclude'),
|
|
45
|
-
submitLabel: properties.stringProperty(element.properties, 'submitLabel') ?? 'Submit'
|
|
49
|
+
submitLabel: properties.stringProperty(element.properties, 'submitLabel') ?? 'Submit',
|
|
50
|
+
...properties.numberProperty(element.properties, 'columns') === undefined ? {} : {
|
|
51
|
+
columns: properties.numberProperty(element.properties, 'columns')
|
|
52
|
+
}
|
|
46
53
|
}, commandKey(target))
|
|
47
54
|
});
|
|
48
55
|
}
|
|
@@ -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 { 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
|
|
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 { numberProperty, stringArrayProperty, stringProperty, unionProperty } 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 mode = unionProperty(element.properties, 'mode', ['auto', 'manual'] as const) ?? (Object.hasOwn(element.properties, 'inputs') ? 'manual' : 'auto');\n const inputs = mode === 'manual' ? commandInputs(element.properties) : undefined;\n if (mode === 'manual' && !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 {...(numberProperty(element.properties, 'columns') === undefined ? {} : { columns: numberProperty(element.properties, 'columns') })}\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","mode","unionProperty","properties","Object","hasOwn","inputs","commandInputs","div","role","ArcRuntimeBoundary","exclude","stringArrayProperty","submitLabel","stringProperty","numberProperty","columns"],"mappings":";;;;;;;;;;;AAUA,MAAMA,kBAAAA,iBAAqBC,UAAAA,CAAK,IAAM,oDAAO,yBAAA,KAAA,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,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