@cratis/scene.components 4.14.0 → 4.16.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 +5 -0
- package/cratisComponentsPackage.ts +9 -123
- package/cratisComponentsPackageManifest.ts +106 -0
- package/cratisComponentsRuntimePackage.ts +22 -0
- package/designTime/cratisComponentsDesignTime.ts +22 -0
- package/dist/cjs/cratisComponentsDescriptors.js +18 -0
- package/dist/cjs/cratisComponentsDescriptors.js.map +1 -1
- package/dist/cjs/cratisComponentsPackage.js +10 -141
- package/dist/cjs/cratisComponentsPackage.js.map +1 -1
- package/dist/cjs/cratisComponentsPackageManifest.js +126 -0
- package/dist/cjs/cratisComponentsPackageManifest.js.map +1 -0
- package/dist/cjs/cratisComponentsRuntimePackage.js +24 -0
- package/dist/cjs/cratisComponentsRuntimePackage.js.map +1 -0
- package/dist/cjs/designTime/cratisComponentsDesignTime.js +24 -0
- package/dist/cjs/designTime/cratisComponentsDesignTime.js.map +1 -0
- package/dist/cjs/forms/CommandFormLayoutEditor.js +73 -0
- package/dist/cjs/forms/CommandFormLayoutEditor.js.map +1 -0
- package/dist/cjs/forms/CommandFormRuntime.js +5 -3
- package/dist/cjs/forms/CommandFormRuntime.js.map +1 -1
- package/dist/cjs/forms/SceneCommandForm.js +5 -1
- package/dist/cjs/forms/SceneCommandForm.js.map +1 -1
- package/dist/cjs/forms/generateCommandFieldsAction.js +10 -1
- package/dist/cjs/forms/generateCommandFieldsAction.js.map +1 -1
- package/dist/cjs/index.js +6 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/runtime.js +15 -0
- package/dist/cjs/runtime.js.map +1 -0
- package/dist/esm/cratisComponentsDescriptors.d.ts.map +1 -1
- package/dist/esm/cratisComponentsDescriptors.js +18 -0
- package/dist/esm/cratisComponentsDescriptors.js.map +1 -1
- package/dist/esm/cratisComponentsPackage.d.ts +1 -2
- package/dist/esm/cratisComponentsPackage.d.ts.map +1 -1
- package/dist/esm/cratisComponentsPackage.js +10 -141
- package/dist/esm/cratisComponentsPackage.js.map +1 -1
- package/dist/esm/cratisComponentsPackageManifest.d.ts +3 -0
- package/dist/esm/cratisComponentsPackageManifest.d.ts.map +1 -0
- package/dist/esm/cratisComponentsPackageManifest.js +124 -0
- package/dist/esm/cratisComponentsPackageManifest.js.map +1 -0
- package/dist/esm/cratisComponentsRuntimePackage.d.ts +3 -0
- package/dist/esm/cratisComponentsRuntimePackage.d.ts.map +1 -0
- package/dist/esm/cratisComponentsRuntimePackage.js +22 -0
- package/dist/esm/cratisComponentsRuntimePackage.js.map +1 -0
- package/dist/esm/designTime/cratisComponentsDesignTime.d.ts +3 -0
- package/dist/esm/designTime/cratisComponentsDesignTime.d.ts.map +1 -0
- package/dist/esm/designTime/cratisComponentsDesignTime.js +22 -0
- package/dist/esm/designTime/cratisComponentsDesignTime.js.map +1 -0
- package/dist/esm/forms/CommandFormLayoutEditor.d.ts +3 -0
- package/dist/esm/forms/CommandFormLayoutEditor.d.ts.map +1 -0
- package/dist/esm/forms/CommandFormLayoutEditor.js +71 -0
- package/dist/esm/forms/CommandFormLayoutEditor.js.map +1 -0
- 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 +6 -4
- package/dist/esm/forms/CommandFormRuntime.js.map +1 -1
- package/dist/esm/forms/SceneCommandForm.d.ts.map +1 -1
- package/dist/esm/forms/SceneCommandForm.js +6 -2
- package/dist/esm/forms/SceneCommandForm.js.map +1 -1
- package/dist/esm/forms/generateCommandFieldsAction.js +10 -1
- package/dist/esm/forms/generateCommandFieldsAction.js.map +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/runtime.d.ts +5 -0
- package/dist/esm/runtime.d.ts.map +1 -0
- package/dist/esm/runtime.js +5 -0
- package/dist/esm/runtime.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/forms/CommandFormLayoutEditor.tsx +49 -0
- package/forms/CommandFormRuntime.tsx +9 -5
- package/forms/SceneCommandForm.tsx +2 -0
- package/forms/generateCommandFieldsAction.ts +5 -1
- package/index.ts +2 -0
- package/package.json +12 -7
- package/runtime.ts +9 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var scene_model = require('@cratis/scene.model');
|
|
4
|
+
var cratisComponents = require('./cratisComponents.js');
|
|
5
|
+
|
|
6
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
7
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
8
|
+
/**
|
|
9
|
+
* The `Cratis.Components` package's declaration - what a profile gets when it lists this package.
|
|
10
|
+
*
|
|
11
|
+
* This is the concrete case the whole package-dependency mechanism exists for. `@cratis/components` is
|
|
12
|
+
* not a self-contained library: every component in it is a wrapper over a PrimeReact widget, and its own
|
|
13
|
+
* styling is a `--cratis-*` token layer (`@cratis/components/tokens`) plus the component stylesheets and
|
|
14
|
+
* compiled Tailwind utilities in `@cratis/components/styles`. Activate it in a profile without PrimeReact
|
|
15
|
+
* and nothing renders; activate it without Tailwind and everything renders unstyled. Both are stated as
|
|
16
|
+
* dependencies so a package picker can say so while the profile is being configured, instead of leaving
|
|
17
|
+
* it to be discovered when the page opens.
|
|
18
|
+
*
|
|
19
|
+
* The version ranges are the real ones the library carries. `>=11.0.0` for PrimeReact: version 3.0.0
|
|
20
|
+
* declares `primereact@^11` as a peer dependency and is built against version 11's component set, so the
|
|
21
|
+
* span across the major boundary that the previous `>=10.9.0` range described is over. The `--cratis-*`
|
|
22
|
+
* tokens still resolve a version 10 theme variable as their last fallback, but that is an upgrade-window
|
|
23
|
+
* courtesy for an application with a compiled version 10 stylesheet still on the page - not a version of
|
|
24
|
+
* PrimeReact this package can be activated against. `^4.0.0` for Tailwind, because the utility sheet is
|
|
25
|
+
* compiled against Tailwind 4.
|
|
26
|
+
*/ const cratisComponentsPackageManifest = {
|
|
27
|
+
name: cratisComponents.cratisComponentsPackageName,
|
|
28
|
+
version: '3.0.0',
|
|
29
|
+
kind: scene_model.PackageKind.ComponentLibrary,
|
|
30
|
+
dependencies: [
|
|
31
|
+
{
|
|
32
|
+
name: 'PrimeReact',
|
|
33
|
+
versionRange: '>=11.0.0'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'Tailwind',
|
|
37
|
+
versionRange: '^4.0.0'
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
components: [
|
|
41
|
+
'page',
|
|
42
|
+
'dataPage',
|
|
43
|
+
'formElement',
|
|
44
|
+
'singleResult',
|
|
45
|
+
'queryInputForm',
|
|
46
|
+
'dataTable',
|
|
47
|
+
'table',
|
|
48
|
+
'observableDataTable',
|
|
49
|
+
'commandForm',
|
|
50
|
+
'inputTextField',
|
|
51
|
+
'numberField',
|
|
52
|
+
'checkboxField',
|
|
53
|
+
'textAreaField',
|
|
54
|
+
'dropdownField',
|
|
55
|
+
'sliderField',
|
|
56
|
+
'calendarField',
|
|
57
|
+
'colorPickerField',
|
|
58
|
+
'multiSelectField',
|
|
59
|
+
'chipsField',
|
|
60
|
+
'radioButtonField',
|
|
61
|
+
'radioGroupField',
|
|
62
|
+
'dialog',
|
|
63
|
+
'confirmationDialog',
|
|
64
|
+
'busyIndicatorDialog',
|
|
65
|
+
'commandDialog',
|
|
66
|
+
'stepperCommandDialog',
|
|
67
|
+
'icon',
|
|
68
|
+
'tooltip',
|
|
69
|
+
'dropdown',
|
|
70
|
+
'errorBoundary',
|
|
71
|
+
'objectContentEditor',
|
|
72
|
+
'objectNavigationalBar',
|
|
73
|
+
'schemaEditor',
|
|
74
|
+
'timeMachine',
|
|
75
|
+
'filterPanel',
|
|
76
|
+
'toolbar',
|
|
77
|
+
'toolbarButton',
|
|
78
|
+
'toolbarGroup',
|
|
79
|
+
'toolbarSeparator'
|
|
80
|
+
],
|
|
81
|
+
// A component library ships components, and nothing else. Layouts, screen templates and dialog
|
|
82
|
+
// templates all belong to a Blueprint: they are decisions about what an application looks like as a
|
|
83
|
+
// whole, and this package deliberately makes none of them - it provides the Arc-bound composites a
|
|
84
|
+
// template is *built from*, so that a blueprint can place a `dataPage` in a slot and configure it,
|
|
85
|
+
// rather than shipping one opinionated data page nobody can rearrange.
|
|
86
|
+
layouts: [],
|
|
87
|
+
screenTemplates: [],
|
|
88
|
+
dialogTemplates: [],
|
|
89
|
+
// No themes either, for a different reason: `@cratis/components` has no palette of its own. It reads
|
|
90
|
+
// a `--cratis-*` variable layer that resolves whatever is in front of it - the `--p-*` properties a
|
|
91
|
+
// PrimeReact 11 preset emits at runtime, or a Scene theme through this package's token bridge.
|
|
92
|
+
// Shipping a theme here would be this library asserting a look it was specifically built not to have.
|
|
93
|
+
themes: [],
|
|
94
|
+
displayName: 'Cratis Components',
|
|
95
|
+
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.",
|
|
96
|
+
module: '@cratis/scene.components',
|
|
97
|
+
license: 'MIT',
|
|
98
|
+
licenseUrl: 'https://github.com/Cratis/Scene/blob/main/LICENSE',
|
|
99
|
+
designTime: {
|
|
100
|
+
previews: [],
|
|
101
|
+
designers: [
|
|
102
|
+
'commandFormDesigner'
|
|
103
|
+
],
|
|
104
|
+
// `commandFields` and `fieldWidths` are host editor kinds (Studio implements them); the package does not ship them.
|
|
105
|
+
propertyEditors: [
|
|
106
|
+
'commandBinding',
|
|
107
|
+
'commandFormLayout'
|
|
108
|
+
],
|
|
109
|
+
propertyDisplays: [],
|
|
110
|
+
actions: [
|
|
111
|
+
'Cratis.Components.commandForm.generateFields'
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
assets: [
|
|
115
|
+
'@cratis/components/styles',
|
|
116
|
+
'@cratis/components/tokens'
|
|
117
|
+
],
|
|
118
|
+
runtimeSingletons: [
|
|
119
|
+
'react',
|
|
120
|
+
'@cratis/arc',
|
|
121
|
+
'@cratis/components'
|
|
122
|
+
]
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
exports.cratisComponentsPackageManifest = cratisComponentsPackageManifest;
|
|
126
|
+
//# sourceMappingURL=cratisComponentsPackageManifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cratisComponentsPackageManifest.js","sources":["../../cratisComponentsPackageManifest.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 { cratisComponentsPackageName } from './cratisComponents';\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 // `commandFields` and `fieldWidths` are host editor kinds (Studio implements them); the package does not ship them.\n propertyEditors: ['commandBinding', 'commandFormLayout'],\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"],"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"],"mappings":";;;;;AAAA;AACA;AAKA;;;;;;;;;;;;;;;;;;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,QAAA,WAAA;AACA,QAAA,OAAA;AACA,QAAA,qBAAA;AACA,QAAA,aAAA;AACA,QAAA,gBAAA;AACA,QAAA,aAAA;AACA,QAAA,eAAA;AACA,QAAA,eAAA;AACA,QAAA,eAAA;AACA,QAAA,aAAA;AACA,QAAA,eAAA;AACA,QAAA,kBAAA;AACA,QAAA,kBAAA;AACA,QAAA,YAAA;AACA,QAAA,kBAAA;AACA,QAAA,iBAAA;AACA,QAAA,QAAA;AACA,QAAA,oBAAA;AACA,QAAA,qBAAA;AACA,QAAA,eAAA;AACA,QAAA,sBAAA;AACA,QAAA,MAAA;AACA,QAAA,SAAA;AACA,QAAA,UAAA;AACA,QAAA,eAAA;AACA,QAAA,qBAAA;AACA,QAAA,uBAAA;AACA,QAAA,cAAA;AACA,QAAA,aAAA;AACA,QAAA,aAAA;AACA,QAAA,SAAA;AACA,QAAA,eAAA;AACA,QAAA,cAAA;AACA,QAAA;AACH,KAAA;;;;;;AAODC,IAAAA,OAAAA,EAAS,EAAE;AACXC,IAAAA,eAAAA,EAAiB,EAAE;AACnBC,IAAAA,eAAAA,EAAiB,EAAE;;;;;AAMnBC,IAAAA,MAAAA,EAAQ,EAAE;IAEVC,WAAAA,EAAa,mBAAA;IACbC,WAAAA,EAAa,6bAAA;IACbC,MAAAA,EAAQ,0BAAA;IACRC,OAAAA,EAAS,KAAA;IACTC,UAAAA,EAAY,mDAAA;IACZC,UAAAA,EAAY;AACRC,QAAAA,QAAAA,EAAU,EAAE;QACZC,SAAAA,EAAW;AAAC,YAAA;AAAsB,SAAA;;QAElCC,eAAAA,EAAiB;AAAC,YAAA,gBAAA;AAAkB,YAAA;AAAoB,SAAA;AACxDC,QAAAA,gBAAAA,EAAkB,EAAE;QACpBC,OAAAA,EAAS;AAAC,YAAA;AAA+C;AAC7D,KAAA;IACAC,MAAAA,EAAQ;AAAC,QAAA,2BAAA;AAA6B,QAAA;AAA4B,KAAA;IAClEC,iBAAAA,EAAmB;AAAC,QAAA,OAAA;AAAS,QAAA,aAAA;AAAe,QAAA;AAAqB;AACrE;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cratisComponents = require('./cratisComponents.js');
|
|
4
|
+
var cratisComponentsDescriptors = require('./cratisComponentsDescriptors.js');
|
|
5
|
+
var cratisComponentsPackageManifest = require('./cratisComponentsPackageManifest.js');
|
|
6
|
+
|
|
7
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
8
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
9
|
+
/**
|
|
10
|
+
* The `Cratis.Components` package without design-time contributions: the manifest, the components and their
|
|
11
|
+
* descriptors. The manifest still names the design-time extensions - that is data a host reads without
|
|
12
|
+
* loading them - but no designer, editor or action module is reachable from this bundle, which is what a
|
|
13
|
+
* runtime host imports from `@cratis/scene.components/runtime`.
|
|
14
|
+
*
|
|
15
|
+
* No `layouts`, `screenTemplates`, `dialogTemplates` or `themes` are provided, matching a manifest that
|
|
16
|
+
* declares none of them; `validatePackageBundle` is what proves the two halves agree.
|
|
17
|
+
*/ const cratisComponentsRuntimePackage = {
|
|
18
|
+
manifest: cratisComponentsPackageManifest.cratisComponentsPackageManifest,
|
|
19
|
+
components: cratisComponents.cratisComponents,
|
|
20
|
+
descriptors: cratisComponentsDescriptors.cratisComponentsDescriptors
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.cratisComponentsRuntimePackage = cratisComponentsRuntimePackage;
|
|
24
|
+
//# sourceMappingURL=cratisComponentsRuntimePackage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cratisComponentsRuntimePackage.js","sources":["../../cratisComponentsRuntimePackage.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 { ScenePackageBundle } from '@cratis/scene.react';\nimport { cratisComponents } from './cratisComponents';\nimport { cratisComponentsDescriptors } from './cratisComponentsDescriptors';\nimport { cratisComponentsPackageManifest } from './cratisComponentsPackageManifest';\n\n/**\n * The `Cratis.Components` package without design-time contributions: the manifest, the components and their\n * descriptors. The manifest still names the design-time extensions - that is data a host reads without\n * loading them - but no designer, editor or action module is reachable from this bundle, which is what a\n * runtime host imports from `@cratis/scene.components/runtime`.\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 cratisComponentsRuntimePackage: ScenePackageBundle = {\n manifest: cratisComponentsPackageManifest,\n components: cratisComponents,\n descriptors: cratisComponentsDescriptors,\n};\n"],"names":["cratisComponentsRuntimePackage","manifest","cratisComponentsPackageManifest","components","cratisComponents","descriptors","cratisComponentsDescriptors"],"mappings":";;;;;;AAAA;AACA;AAOA;;;;;;;;UASaA,8BAAAA,GAAqD;IAC9DC,QAAAA,EAAUC,+DAAAA;IACVC,UAAAA,EAAYC,iCAAAA;IACZC,WAAAA,EAAaC;AACjB;;"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var CommandFieldPropertyEditor = require('../forms/CommandFieldPropertyEditor.js');
|
|
4
|
+
var CommandFormDesigner = require('../forms/CommandFormDesigner.js');
|
|
5
|
+
var CommandFormLayoutEditor = require('../forms/CommandFormLayoutEditor.js');
|
|
6
|
+
var generateCommandFieldsAction = require('../forms/generateCommandFieldsAction.js');
|
|
7
|
+
|
|
8
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
9
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
10
|
+
/** Every design-time contribution of `Cratis.Components`, under the names its manifest declares. */ const cratisComponentsDesignTime = {
|
|
11
|
+
designers: {
|
|
12
|
+
commandFormDesigner: CommandFormDesigner.CommandFormDesigner
|
|
13
|
+
},
|
|
14
|
+
propertyEditors: {
|
|
15
|
+
commandBinding: CommandFieldPropertyEditor.CommandFieldPropertyEditor,
|
|
16
|
+
commandFormLayout: CommandFormLayoutEditor.CommandFormLayoutEditor
|
|
17
|
+
},
|
|
18
|
+
actions: {
|
|
19
|
+
[generateCommandFieldsAction.generateCommandFieldsAction.descriptor.id]: generateCommandFieldsAction.generateCommandFieldsAction
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.cratisComponentsDesignTime = cratisComponentsDesignTime;
|
|
24
|
+
//# sourceMappingURL=cratisComponentsDesignTime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cratisComponentsDesignTime.js","sources":["../../../designTime/cratisComponentsDesignTime.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 { DesignTimeBundle } from '@cratis/scene.react';\nimport { CommandFieldPropertyEditor } from '../forms/CommandFieldPropertyEditor';\nimport { CommandFormDesigner } from '../forms/CommandFormDesigner';\nimport { CommandFormLayoutEditor } from '../forms/CommandFormLayoutEditor';\nimport { generateCommandFieldsAction } from '../forms/generateCommandFieldsAction';\n\n/** Every design-time contribution of `Cratis.Components`, under the names its manifest declares. */\nexport const cratisComponentsDesignTime: DesignTimeBundle = {\n designers: {\n commandFormDesigner: CommandFormDesigner,\n },\n propertyEditors: {\n commandBinding: CommandFieldPropertyEditor,\n commandFormLayout: CommandFormLayoutEditor,\n },\n actions: {\n [generateCommandFieldsAction.descriptor.id]: generateCommandFieldsAction,\n },\n};\n"],"names":["cratisComponentsDesignTime","designers","commandFormDesigner","CommandFormDesigner","propertyEditors","commandBinding","CommandFieldPropertyEditor","commandFormLayout","CommandFormLayoutEditor","actions","generateCommandFieldsAction","descriptor","id"],"mappings":";;;;;;;AAAA;AACA;AAQA,qGACO,MAAMA,0BAAAA,GAA+C;IACxDC,SAAAA,EAAW;QACPC,mBAAAA,EAAqBC;AACzB,KAAA;IACAC,eAAAA,EAAiB;QACbC,cAAAA,EAAgBC,qDAAAA;QAChBC,iBAAAA,EAAmBC;AACvB,KAAA;IACAC,OAAAA,EAAS;AACL,QAAA,CAACC,uDAAAA,CAA4BC,UAAU,CAACC,EAAE,GAAGF;AACjD;AACJ;;"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var scene_model = require('@cratis/scene.model');
|
|
6
|
+
var scene_engine = require('@cratis/scene.engine');
|
|
7
|
+
var commandFormLayout = require('./commandFormLayout.js');
|
|
8
|
+
|
|
9
|
+
const layoutKeys = new Set(Object.values(scene_engine.CommandFormLayoutKey));
|
|
10
|
+
/**
|
|
11
|
+
* Arranges a command form's fields from the keyboard. Each placed field is a focusable cell: the arrow keys
|
|
12
|
+
* move it one cell, and Shift with an arrow key resizes it. A valid change is submitted as one canonical
|
|
13
|
+
* edit of the `layout` property; an invalid one is announced and the committed layout is kept.
|
|
14
|
+
*/ function CommandFormLayoutEditor({ context, property, value, setValue }) {
|
|
15
|
+
const layout = commandFormLayout.commandFormLayout({
|
|
16
|
+
layout: value
|
|
17
|
+
});
|
|
18
|
+
const [problem, setProblem] = react.useState();
|
|
19
|
+
if (!layout) return /*#__PURE__*/ jsxRuntime.jsxs("p", {
|
|
20
|
+
role: "note",
|
|
21
|
+
children: [
|
|
22
|
+
property.label,
|
|
23
|
+
": no layout is authored yet."
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
const onKeyDown = (field)=>(event)=>{
|
|
27
|
+
if (!layoutKeys.has(event.key)) return;
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
const draft = scene_engine.applyCommandFormLayoutKey(layout, field, event.key, event.shiftKey, layout.placements.map((placement)=>placement.field));
|
|
30
|
+
if (!draft) return;
|
|
31
|
+
if (!draft.isValid) {
|
|
32
|
+
setProblem(draft.diagnostics[0].message);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
setProblem(undefined);
|
|
36
|
+
commit(draft.draft);
|
|
37
|
+
};
|
|
38
|
+
const commit = (next)=>{
|
|
39
|
+
setValue(next);
|
|
40
|
+
context.submitEdits([
|
|
41
|
+
{
|
|
42
|
+
kind: scene_model.SceneEditKind.SetProperty,
|
|
43
|
+
nodeId: context.element.id,
|
|
44
|
+
path: property.path,
|
|
45
|
+
value: next
|
|
46
|
+
}
|
|
47
|
+
]);
|
|
48
|
+
};
|
|
49
|
+
return /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
50
|
+
role: "group",
|
|
51
|
+
"aria-label": property.label,
|
|
52
|
+
"aria-describedby": `${context.element.id}-layout-help`,
|
|
53
|
+
children: [
|
|
54
|
+
/*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
55
|
+
id: `${context.element.id}-layout-help`,
|
|
56
|
+
children: "Arrow keys move a field. Shift and an arrow key resize it."
|
|
57
|
+
}),
|
|
58
|
+
layout.placements.map((placement)=>/*#__PURE__*/ jsxRuntime.jsx("button", {
|
|
59
|
+
type: "button",
|
|
60
|
+
onKeyDown: onKeyDown(placement.field),
|
|
61
|
+
"aria-label": `${placement.field}: row ${placement.row}, column ${placement.column}, spans ${placement.columnSpan ?? 1} column(s) and ${placement.rowSpan ?? 1} row(s)`,
|
|
62
|
+
children: placement.field
|
|
63
|
+
}, placement.field)),
|
|
64
|
+
problem && /*#__PURE__*/ jsxRuntime.jsx("p", {
|
|
65
|
+
role: "alert",
|
|
66
|
+
children: problem
|
|
67
|
+
})
|
|
68
|
+
]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
exports.CommandFormLayoutEditor = CommandFormLayoutEditor;
|
|
73
|
+
//# sourceMappingURL=CommandFormLayoutEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandFormLayoutEditor.js","sources":["../../../forms/CommandFormLayoutEditor.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 { KeyboardEvent, useState } from 'react';\nimport { CommandFormLayout, SceneEditKind } from '@cratis/scene.model';\nimport { CommandFormLayoutKey, applyCommandFormLayoutKey } from '@cratis/scene.engine';\nimport { DesignTimePropertyEditorProps } from '@cratis/scene.react';\nimport { commandFormLayout } from './commandFormLayout';\n\nconst layoutKeys = new Set<string>(Object.values(CommandFormLayoutKey));\n\n/**\n * Arranges a command form's fields from the keyboard. Each placed field is a focusable cell: the arrow keys\n * move it one cell, and Shift with an arrow key resizes it. A valid change is submitted as one canonical\n * edit of the `layout` property; an invalid one is announced and the committed layout is kept.\n */\nexport function CommandFormLayoutEditor({ context, property, value, setValue }: DesignTimePropertyEditorProps) {\n const layout = commandFormLayout({ layout: value });\n const [problem, setProblem] = useState<string>();\n if (!layout) return <p role='note'>{property.label}: no layout is authored yet.</p>;\n\n const onKeyDown = (field: string) => (event: KeyboardEvent<HTMLButtonElement>) => {\n if (!layoutKeys.has(event.key)) return;\n event.preventDefault();\n const draft = applyCommandFormLayoutKey(layout, field, event.key as CommandFormLayoutKey, event.shiftKey, layout.placements.map(placement => placement.field));\n if (!draft) return;\n if (!draft.isValid) {\n setProblem(draft.diagnostics[0].message);\n return;\n }\n\n setProblem(undefined);\n commit(draft.draft);\n };\n\n const commit = (next: CommandFormLayout) => {\n setValue(next);\n context.submitEdits([{ kind: SceneEditKind.SetProperty, nodeId: context.element.id, path: property.path, value: next }]);\n };\n\n return <div role='group' aria-label={property.label} aria-describedby={`${context.element.id}-layout-help`}>\n <p id={`${context.element.id}-layout-help`}>Arrow keys move a field. Shift and an arrow key resize it.</p>\n {layout.placements.map(placement => <button key={placement.field} type='button' onKeyDown={onKeyDown(placement.field)}\n aria-label={`${placement.field}: row ${placement.row}, column ${placement.column}, spans ${placement.columnSpan ?? 1} column(s) and ${placement.rowSpan ?? 1} row(s)`}>\n {placement.field}\n </button>)}\n {problem && <p role='alert'>{problem}</p>}\n </div>;\n}\n"],"names":["layoutKeys","Set","Object","values","CommandFormLayoutKey","CommandFormLayoutEditor","context","property","value","setValue","layout","commandFormLayout","problem","setProblem","useState","_jsxs","p","role","label","onKeyDown","field","event","has","key","preventDefault","draft","applyCommandFormLayoutKey","shiftKey","placements","map","placement","isValid","diagnostics","message","undefined","commit","next","submitEdits","kind","SceneEditKind","SetProperty","nodeId","element","id","path","div","aria-label","aria-describedby","_jsx","button","type","row","column","columnSpan","rowSpan"],"mappings":";;;;;;;;AASA,MAAMA,UAAAA,GAAa,IA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AAAA,kBAAWoC,cAAA,CAAChC,GAAAA,EAAAA;gBAAEC,IAAAA,EAAK,OAAA;AAASL,gBAAAA,QAAAA,EAAAA;;;;AAErC;;"}
|
|
@@ -50,7 +50,7 @@ const NativeAutoCommandForm = CommandForm.AutoCommandForm;
|
|
|
50
50
|
}
|
|
51
51
|
return undefined;
|
|
52
52
|
}
|
|
53
|
-
/** Private lazy entry point: importing the Scene registry must not import Arc. */ function CommandFormRuntime({ command, inputs, exclude, submitLabel, columns = 1, layout }) {
|
|
53
|
+
/** Private lazy entry point: importing the Scene registry must not import Arc. */ function CommandFormRuntime({ command, inputs, exclude, submitLabel, columns = 1, layout, compact = false }) {
|
|
54
54
|
const error = capability(command, inputs, exclude);
|
|
55
55
|
if (error) return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
56
56
|
role: "alert",
|
|
@@ -58,18 +58,20 @@ const NativeAutoCommandForm = CommandForm.AutoCommandForm;
|
|
|
58
58
|
});
|
|
59
59
|
// The registry's never-argument constructor is erased; Arc creates this checked proxy with no args.
|
|
60
60
|
if (inputs) {
|
|
61
|
-
const
|
|
62
|
-
const diagnostics = scene_engine.validateCommandFormLayout(
|
|
61
|
+
const authoredLayout = scene_engine.normalizeCommandFormLayout(layout, inputs);
|
|
62
|
+
const diagnostics = scene_engine.validateCommandFormLayout(authoredLayout, inputs.map((input)=>input.property));
|
|
63
63
|
if (diagnostics.length) return /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
64
64
|
role: "alert",
|
|
65
65
|
children: diagnostics[0].message
|
|
66
66
|
});
|
|
67
|
+
const formLayout = compact ? scene_engine.stackCommandFormLayout(authoredLayout) : authoredLayout;
|
|
67
68
|
const columnsCss = formLayout.columns.map((column)=>scene_engine.formWidthToCss(column.width) ?? 'minmax(0, 1fr)').join(' ') || `repeat(${Math.max(1, columns)}, minmax(0, 1fr))`;
|
|
68
69
|
return /*#__PURE__*/ jsxRuntime.jsxs(commands.CommandForm, {
|
|
69
70
|
command: command,
|
|
70
71
|
showTitles: false,
|
|
71
72
|
children: [
|
|
72
73
|
/*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
74
|
+
"data-scene-form-columns": formLayout.columns.length,
|
|
73
75
|
style: {
|
|
74
76
|
display: 'grid',
|
|
75
77
|
gridTemplateColumns: columnsCss,
|
|
@@ -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 { formWidthToCss, normalizeCommandFormLayout, validateCommandFormLayout } from '@cratis/scene.engine';\nimport { Guid } from '@cratis/fundamentals';\nimport type { BoundConstructor } from '../bindings';\nimport type { CommandInput } from './commandInputs';\nimport type { CommandFormLayout } from '@cratis/scene.model';\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 layout?: CommandFormLayout;\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, layout }: 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) {\n const
|
|
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 { formWidthToCss, normalizeCommandFormLayout, stackCommandFormLayout, validateCommandFormLayout } from '@cratis/scene.engine';\nimport { Guid } from '@cratis/fundamentals';\nimport type { BoundConstructor } from '../bindings';\nimport type { CommandInput } from './commandInputs';\nimport type { CommandFormLayout } from '@cratis/scene.model';\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 layout?: CommandFormLayout;\n\n /** At a compact width the fields stack in one column, in reading order. */\n compact?: boolean;\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, layout, compact = false }: 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) {\n const authoredLayout = normalizeCommandFormLayout(layout, inputs);\n const diagnostics = validateCommandFormLayout(authoredLayout, inputs.map(input => input.property));\n if (diagnostics.length) return <div role='alert'>{diagnostics[0].message}</div>;\n const formLayout = compact ? stackCommandFormLayout(authoredLayout) : authoredLayout;\n const columnsCss = formLayout.columns.map(column => formWidthToCss(column.width) ?? 'minmax(0, 1fr)').join(' ') || `repeat(${Math.max(1, columns)}, minmax(0, 1fr))`;\n return <CommandForm command={command as unknown as new () => object} showTitles={false}>\n <div data-scene-form-columns={formLayout.columns.length} style={{ display: 'grid', gridTemplateColumns: columnsCss, columnGap: formWidthToCss(formLayout.columnGap) ?? '1rem', rowGap: formWidthToCss(formLayout.rowGap) ?? '1rem' }}>\n {inputs.map(input => <ExplicitCommandField key={input.property} input={input} placement={formLayout.placements.find(placement => placement.field === input.property) ?? input.placement} />)}\n </div>\n <CommandFormSubmit label={submitLabel} />\n </CommandForm>;\n }\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","layout","compact","error","_jsx","div","role","authoredLayout","normalizeCommandFormLayout","diagnostics","validateCommandFormLayout","map","length","message","formLayout","stackCommandFormLayout","columnsCss","column","formWidthToCss","width","join","Math","max","_jsxs","CommandForm","showTitles","data-scene-form-columns","style","display","gridTemplateColumns","columnGap","rowGap","ExplicitCommandField","placement","placements","find","field","CommandFormSubmit","label","footer"],"mappings":";;;;;;;;;;;;AAAA;AACA;AAyBA;AACA,MAAMA,qBAAAA,GAA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AAAA,EAAOA,KAAAA;AAAOgD,4BAAAA,SAAAA,EAAWnB,UAAAA,CAAWoB,UAAU,CAACC,IAAI,CAACF,CAAAA,SAAAA,GAAaA,SAAAA,CAAUG,KAAK,KAAKnD,KAAAA,CAAME,QAAQ,CAAA,IAAKF,MAAMgD;AAA9HhD,yBAAAA,EAAAA,KAAAA,CAAME,QAAQ,CAAA;;8BAElEiB,cAAA,CAACiC,mCAAAA,EAAAA;oBAAkBC,KAAAA,EAAOvC;;;;AAElC,IAAA;AACA,IAAA,qBAAOK,cAAA,CAACpC,qBAAAA,EAAAA;QAAsBG,OAAAA,EAASA,OAAAA;QAASE,OAAAA,EAASA,OAAAA;AAASkE,QAAAA,MAAAA,gBAAQnC,cAAA,CAACiC,mCAAAA,EAAAA;YAAkBC,KAAAA,EAAOvC;;;AACxG;;"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var react = require('react');
|
|
5
|
+
var scene_model = require('@cratis/scene.model');
|
|
5
6
|
var BindingKind = require('../bindings/BindingKind.js');
|
|
6
7
|
var resolveElementBinding = require('../bindings/resolveElementBinding.js');
|
|
7
8
|
var MissingBinding = require('../bindings/MissingBinding.js');
|
|
@@ -53,7 +54,10 @@ function commandKey(command) {
|
|
|
53
54
|
},
|
|
54
55
|
...commandFormLayout.commandFormLayout(element.properties) === undefined ? {} : {
|
|
55
56
|
layout: commandFormLayout.commandFormLayout(element.properties)
|
|
56
|
-
}
|
|
57
|
+
},
|
|
58
|
+
...properties.stringProperty(element.properties, 'widthSizeClass') === scene_model.WidthSizeClass.Compact ? {
|
|
59
|
+
compact: true
|
|
60
|
+
} : {}
|
|
57
61
|
}, commandKey(target))
|
|
58
62
|
});
|
|
59
63
|
}
|
|
@@ -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 { numberProperty, stringArrayProperty, stringProperty, unionProperty } from '../properties';\nimport { commandFormLayout } from './commandFormLayout';\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 {...(commandFormLayout(element.properties) === undefined ? {} : { layout: commandFormLayout(element.properties) })}\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","commandFormLayout","layout"],"mappings":"
|
|
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 { WidthSizeClass } from '@cratis/scene.model';\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 { commandFormLayout } from './commandFormLayout';\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 {...(commandFormLayout(element.properties) === undefined ? {} : { layout: commandFormLayout(element.properties) })}\n {...(stringProperty(element.properties, 'widthSizeClass') === WidthSizeClass.Compact ? { compact: true } : {})}\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","commandFormLayout","layout","WidthSizeClass","Compact","compact"],"mappings":";;;;;;;;;;;;;AAYA,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,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,MAA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UAAU,EAAE,SAAA;aAAY;AACjI,YAAA,GAAIc,oCAAkBzB,OAAAA,CAAQW,UAAU,CAAA,KAAMd,SAAAA,GAAY,EAAC,GAAI;gBAAE6B,MAAAA,EAAQD,mCAAAA,CAAkBzB,QAAQW,UAAU;aAAG;AAChH,YAAA,GAAIW,0BAAetB,OAAAA,CAAQW,UAAU,EAAE,gBAAA,CAAA,KAAsBgB,0BAAAA,CAAeC,OAAO,GAAG;gBAAEC,OAAAA,EAAS;AAAK,aAAA,GAAI;WAPtGpC,UAAAA,CAAWS,MAAAA,CAAAA;;AAWhC;;"}
|
|
@@ -13,7 +13,7 @@ const generateCommandFieldsAction = {
|
|
|
13
13
|
description: 'Creates a deterministic editable field layout from the selected command metadata.'
|
|
14
14
|
},
|
|
15
15
|
isVisible: (context)=>context.element.componentName.endsWith(':commandForm'),
|
|
16
|
-
isEnabled: (context)=>Array.isArray(context.commandMetadata?.properties) &&
|
|
16
|
+
isEnabled: (context)=>Array.isArray(context.commandMetadata?.properties) && context.element.properties.inputs === undefined,
|
|
17
17
|
execute: (context)=>generateCommandFields(context)
|
|
18
18
|
};
|
|
19
19
|
function generateCommandFields(context) {
|
|
@@ -24,6 +24,7 @@ function generateCommandFields(context) {
|
|
|
24
24
|
'No command metadata was supplied.'
|
|
25
25
|
]
|
|
26
26
|
};
|
|
27
|
+
// Authored fields, or a binding that supplies them, are never overwritten.
|
|
27
28
|
if (Array.isArray(context.element.properties.inputs)) {
|
|
28
29
|
return {
|
|
29
30
|
edits: [],
|
|
@@ -32,6 +33,14 @@ function generateCommandFields(context) {
|
|
|
32
33
|
]
|
|
33
34
|
};
|
|
34
35
|
}
|
|
36
|
+
if (context.element.properties.inputs !== undefined) {
|
|
37
|
+
return {
|
|
38
|
+
edits: [],
|
|
39
|
+
diagnostics: [
|
|
40
|
+
'The form\'s fields come from a binding; Generate fields will not overwrite it.'
|
|
41
|
+
]
|
|
42
|
+
};
|
|
43
|
+
}
|
|
35
44
|
return {
|
|
36
45
|
diagnostics: [],
|
|
37
46
|
edits: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateCommandFieldsAction.js","sources":["../../../forms/generateCommandFieldsAction.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 { DesignTimeAction, DesignTimeActionContext, DesignTimeActionResult } from '@cratis/scene.react';\nimport { DesignTimeActionPlacement, SceneEditKind } from '@cratis/scene.model';\n\nexport const generateCommandFieldsAction: DesignTimeAction = {\n descriptor: {\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 isVisible: context => context.element.componentName.endsWith(':commandForm'),\n isEnabled: context => Array.isArray(context.commandMetadata?.properties) &&
|
|
1
|
+
{"version":3,"file":"generateCommandFieldsAction.js","sources":["../../../forms/generateCommandFieldsAction.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 { DesignTimeAction, DesignTimeActionContext, DesignTimeActionResult } from '@cratis/scene.react';\nimport { DesignTimeActionPlacement, SceneEditKind } from '@cratis/scene.model';\n\nexport const generateCommandFieldsAction: DesignTimeAction = {\n descriptor: {\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 isVisible: context => context.element.componentName.endsWith(':commandForm'),\n isEnabled: context => Array.isArray(context.commandMetadata?.properties) && context.element.properties.inputs === undefined,\n execute: context => generateCommandFields(context),\n};\n\nfunction generateCommandFields(context: DesignTimeActionContext): DesignTimeActionResult {\n const properties = context.commandMetadata?.properties ?? [];\n if (!properties.length) return { edits: [], diagnostics: ['No command metadata was supplied.'] };\n // Authored fields, or a binding that supplies them, are never overwritten.\n if (Array.isArray(context.element.properties.inputs)) {\n return { edits: [], diagnostics: ['The form already has authored fields; Generate fields will not overwrite them.'] };\n }\n if (context.element.properties.inputs !== undefined) {\n return { edits: [], diagnostics: ['The form\\'s fields come from a binding; Generate fields will not overwrite it.'] };\n }\n\n return {\n diagnostics: [],\n edits: [{\n kind: SceneEditKind.SetProperty,\n nodeId: context.element.id,\n path: 'inputs',\n value: properties.map((property, index) => ({\n property: property.name,\n type: property.type === 'Guid' || property.type === 'guid' ? 'guid' : 'string',\n label: property.label ?? humanize(property.name),\n column: (index % 2) + 1,\n width: '1fr',\n })),\n }],\n };\n}\n\nfunction humanize(name: string): string {\n return name.replace(/([a-z0-9])([A-Z])/g, '$1 $2').replace(/^./, value => value.toUpperCase());\n}\n"],"names":["generateCommandFieldsAction","descriptor","id","label","placement","DesignTimeActionPlacement","Toolbar","availability","description","isVisible","context","element","componentName","endsWith","isEnabled","Array","isArray","commandMetadata","properties","inputs","undefined","execute","generateCommandFields","length","edits","diagnostics","kind","SceneEditKind","SetProperty","nodeId","path","value","map","property","index","name","type","humanize","column","width","replace","toUpperCase"],"mappings":";;;;AAAA;AACA;MAKaA,2BAAAA,GAAgD;IACzDC,UAAAA,EAAY;QACRC,EAAAA,EAAI,8CAAA;QACJC,KAAAA,EAAO,iBAAA;AACPC,QAAAA,SAAAA,EAAWC,sCAA0BC,OAAO;QAC5CC,YAAAA,EAAc,+BAAA;QACdC,WAAAA,EAAa;AACjB,KAAA;IACAC,SAAAA,EAAWC,CAAAA,UAAWA,OAAAA,CAAQC,OAAO,CAACC,aAAa,CAACC,QAAQ,CAAC,cAAA,CAAA;AAC7DC,IAAAA,SAAAA,EAAWJ,CAAAA,OAAAA,GAAWK,KAAAA,CAAMC,OAAO,CAACN,OAAAA,CAAQO,eAAe,EAAEC,UAAAA,CAAAA,IAAeR,QAAQC,OAAO,CAACO,UAAU,CAACC,MAAM,KAAKC,SAAAA;IAClHC,OAAAA,EAASX,CA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A,EAASJ,QAAQ,CAAA,GAAK,CAAA;wBACtBK,KAAAA,EAAO;qBACX,CAAA;AACJ;AAAE;AACN,KAAA;AACJ;AAEA,SAASF,SAASF,IAAY,EAAA;IAC1B,OAAOA,IAAAA,CAAKK,OAAO,CAAC,oBAAA,EAAsB,OAAA,CAAA,CAASA,OAAO,CAAC,IAAA,EAAMT,CAAAA,KAAAA,GAASA,KAAAA,CAAMU,WAAW,EAAA,CAAA;AAC/F;;"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -53,6 +53,9 @@ var SceneToolbarSeparator = require('./toolbar/SceneToolbarSeparator.js');
|
|
|
53
53
|
var cratisComponents = require('./cratisComponents.js');
|
|
54
54
|
var cratisComponentsDescriptors = require('./cratisComponentsDescriptors.js');
|
|
55
55
|
var cratisComponentsPackage = require('./cratisComponentsPackage.js');
|
|
56
|
+
var cratisComponentsRuntimePackage = require('./cratisComponentsRuntimePackage.js');
|
|
57
|
+
var cratisComponentsDesignTime = require('./designTime/cratisComponentsDesignTime.js');
|
|
58
|
+
var cratisComponentsPackageManifest = require('./cratisComponentsPackageManifest.js');
|
|
56
59
|
|
|
57
60
|
|
|
58
61
|
|
|
@@ -129,5 +132,7 @@ exports.cratisComponents = cratisComponents.cratisComponents;
|
|
|
129
132
|
exports.cratisComponentsPackageName = cratisComponents.cratisComponentsPackageName;
|
|
130
133
|
exports.cratisComponentsDescriptors = cratisComponentsDescriptors.cratisComponentsDescriptors;
|
|
131
134
|
exports.cratisComponentsPackage = cratisComponentsPackage.cratisComponentsPackage;
|
|
132
|
-
exports.
|
|
135
|
+
exports.cratisComponentsRuntimePackage = cratisComponentsRuntimePackage.cratisComponentsRuntimePackage;
|
|
136
|
+
exports.cratisComponentsDesignTime = cratisComponentsDesignTime.cratisComponentsDesignTime;
|
|
137
|
+
exports.cratisComponentsPackageManifest = cratisComponentsPackageManifest.cratisComponentsPackageManifest;
|
|
133
138
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cratisComponents = require('./cratisComponents.js');
|
|
4
|
+
var cratisComponentsDescriptors = require('./cratisComponentsDescriptors.js');
|
|
5
|
+
var cratisComponentsPackageManifest = require('./cratisComponentsPackageManifest.js');
|
|
6
|
+
var cratisComponentsRuntimePackage = require('./cratisComponentsRuntimePackage.js');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
exports.cratisComponents = cratisComponents.cratisComponents;
|
|
11
|
+
exports.cratisComponentsPackageName = cratisComponents.cratisComponentsPackageName;
|
|
12
|
+
exports.cratisComponentsDescriptors = cratisComponentsDescriptors.cratisComponentsDescriptors;
|
|
13
|
+
exports.cratisComponentsPackageManifest = cratisComponentsPackageManifest.cratisComponentsPackageManifest;
|
|
14
|
+
exports.cratisComponentsRuntimePackage = cratisComponentsRuntimePackage.cratisComponentsRuntimePackage;
|
|
15
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cratisComponentsDescriptors.d.ts","sourceRoot":"","sources":["../../cratisComponentsDescriptors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkC,mBAAmB,EAAsF,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"cratisComponentsDescriptors.d.ts","sourceRoot":"","sources":["../../cratisComponentsDescriptors.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkC,mBAAmB,EAAsF,MAAM,qBAAqB,CAAC;AAsF9K,eAAO,MAAM,2BAA2B,EAAE,mBAAmB,EAiB5D,CAAC"}
|
|
@@ -109,6 +109,24 @@ const commandFormProperties = [
|
|
|
109
109
|
editorKind: 'commandFormLayout',
|
|
110
110
|
description: 'Typed command-form geometry: columns, gaps and field placements. Independent of auto/manual field generation.'
|
|
111
111
|
},
|
|
112
|
+
{
|
|
113
|
+
path: 'widthSizeClass',
|
|
114
|
+
label: 'Width size class',
|
|
115
|
+
group: 'Layout',
|
|
116
|
+
valueType: PropertyValueType.Enum,
|
|
117
|
+
default: 'Regular',
|
|
118
|
+
choices: [
|
|
119
|
+
{
|
|
120
|
+
value: 'Regular',
|
|
121
|
+
label: 'Regular'
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
value: 'Compact',
|
|
125
|
+
label: 'Compact'
|
|
126
|
+
}
|
|
127
|
+
],
|
|
128
|
+
description: 'The width size class the host evaluated. At Compact the fields of a manual form stack in one column in reading order.'
|
|
129
|
+
},
|
|
112
130
|
{
|
|
113
131
|
path: 'fieldWidths',
|
|
114
132
|
label: 'Legacy field widths',
|