@cratis/components 0.1.19 → 1.0.4
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/dist/cjs/CommandDialog/CommandDialog.js +35 -24
- package/dist/cjs/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/cjs/CommandForm/fields/CheckboxField.js +2 -2
- package/dist/cjs/CommandForm/fields/CheckboxField.js.map +1 -1
- package/dist/cjs/CommandForm/fields/DropdownField.js +5 -5
- package/dist/cjs/CommandForm/fields/DropdownField.js.map +1 -1
- package/dist/cjs/CommandForm/fields/InputTextField.js +2 -2
- package/dist/cjs/CommandForm/fields/InputTextField.js.map +1 -1
- package/dist/cjs/CommandForm/fields/NumberField.js +2 -2
- package/dist/cjs/CommandForm/fields/NumberField.js.map +1 -1
- package/dist/cjs/CommandForm/fields/SliderField.js +5 -9
- package/dist/cjs/CommandForm/fields/SliderField.js.map +1 -1
- package/dist/cjs/CommandForm/fields/TextAreaField.js +2 -2
- package/dist/cjs/CommandForm/fields/TextAreaField.js.map +1 -1
- package/dist/cjs/CommandForm/index.js +35 -15
- package/dist/cjs/CommandForm/index.js.map +1 -1
- package/dist/cjs/DataTables/DataTableForObservableQuery.js +53 -1
- package/dist/cjs/DataTables/DataTableForObservableQuery.js.map +1 -1
- package/dist/cjs/DataTables/DataTableForQuery.js +19 -1
- package/dist/cjs/DataTables/DataTableForQuery.js.map +1 -1
- package/dist/cjs/Dialogs/BusyIndicatorDialog.js +2 -3
- package/dist/cjs/Dialogs/BusyIndicatorDialog.js.map +1 -1
- package/dist/cjs/Dialogs/ConfirmationDialog.js +4 -21
- package/dist/cjs/Dialogs/ConfirmationDialog.js.map +1 -1
- package/dist/cjs/Dialogs/Dialog.js +66 -0
- package/dist/cjs/Dialogs/Dialog.js.map +1 -0
- package/dist/cjs/Dialogs/index.js +4 -2
- package/dist/cjs/Dialogs/index.js.map +1 -1
- package/dist/cjs/ObjectContentEditor/ObjectContentEditor.js +156 -0
- package/dist/cjs/ObjectContentEditor/ObjectContentEditor.js.map +1 -0
- package/dist/cjs/ObjectContentEditor/index.js +8 -0
- package/dist/cjs/{EventModeling → ObjectContentEditor}/index.js.map +1 -1
- package/dist/cjs/ObjectNavigationalBar/ObjectNavigationalBar.js +45 -0
- package/dist/cjs/ObjectNavigationalBar/ObjectNavigationalBar.js.map +1 -0
- package/dist/cjs/ObjectNavigationalBar/index.js +8 -0
- package/dist/cjs/ObjectNavigationalBar/index.js.map +1 -0
- package/dist/cjs/SchemaEditor/NameCell.js +38 -0
- package/dist/cjs/SchemaEditor/NameCell.js.map +1 -0
- package/dist/cjs/SchemaEditor/SchemaEditor.js +352 -0
- package/dist/cjs/SchemaEditor/SchemaEditor.js.map +1 -0
- package/dist/cjs/SchemaEditor/SchemaEditor.module.css +11 -0
- package/dist/cjs/SchemaEditor/TypeCell.js +102 -0
- package/dist/cjs/SchemaEditor/TypeCell.js.map +1 -0
- package/dist/cjs/SchemaEditor/index.js +10 -0
- package/dist/cjs/SchemaEditor/index.js.map +1 -0
- package/dist/cjs/index.js +10 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/TypeFormat.js +20 -0
- package/dist/cjs/types/TypeFormat.js.map +1 -0
- package/dist/esm/CommandDialog/CommandDialog.d.ts +22 -1
- package/dist/esm/CommandDialog/CommandDialog.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.js +35 -24
- package/dist/esm/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.stories.d.ts +11 -0
- package/dist/esm/CommandDialog/CommandDialog.stories.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.stories.js +208 -3
- package/dist/esm/CommandDialog/CommandDialog.stories.js.map +1 -1
- package/dist/esm/CommandForm/fields/CheckboxField.d.ts +3 -2
- package/dist/esm/CommandForm/fields/CheckboxField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/CheckboxField.js +1 -1
- package/dist/esm/CommandForm/fields/CheckboxField.js.map +1 -1
- package/dist/esm/CommandForm/fields/DropdownField.d.ts +7 -6
- package/dist/esm/CommandForm/fields/DropdownField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/DropdownField.js +6 -6
- package/dist/esm/CommandForm/fields/DropdownField.js.map +1 -1
- package/dist/esm/CommandForm/fields/Fields.stories.d.ts +13 -0
- package/dist/esm/CommandForm/fields/Fields.stories.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/Fields.stories.js +137 -0
- package/dist/esm/CommandForm/fields/Fields.stories.js.map +1 -0
- package/dist/esm/CommandForm/fields/InputTextField.d.ts +3 -2
- package/dist/esm/CommandForm/fields/InputTextField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/InputTextField.js +1 -1
- package/dist/esm/CommandForm/fields/InputTextField.js.map +1 -1
- package/dist/esm/CommandForm/fields/NumberField.d.ts +3 -2
- package/dist/esm/CommandForm/fields/NumberField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/NumberField.js +1 -1
- package/dist/esm/CommandForm/fields/NumberField.js.map +1 -1
- package/dist/esm/CommandForm/fields/SliderField.d.ts +5 -4
- package/dist/esm/CommandForm/fields/SliderField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/SliderField.js +5 -9
- package/dist/esm/CommandForm/fields/SliderField.js.map +1 -1
- package/dist/esm/CommandForm/fields/TextAreaField.d.ts +3 -2
- package/dist/esm/CommandForm/fields/TextAreaField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/TextAreaField.js +1 -1
- package/dist/esm/CommandForm/fields/TextAreaField.js.map +1 -1
- package/dist/esm/CommandForm/fields/index.d.ts +2 -2
- package/dist/esm/CommandForm/fields/index.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/index.js +2 -2
- package/dist/esm/CommandForm/fields/index.js.map +1 -1
- package/dist/esm/CommandForm/index.d.ts +1 -5
- package/dist/esm/CommandForm/index.d.ts.map +1 -1
- package/dist/esm/CommandForm/index.js +3 -7
- package/dist/esm/CommandForm/index.js.map +1 -1
- package/dist/esm/Common/ErrorBoundary.d.ts +1 -1
- package/dist/esm/Common/ErrorBoundary.stories.d.ts +7 -7
- package/dist/esm/Common/ErrorBoundary.stories.d.ts.map +1 -1
- package/dist/esm/Common/ErrorBoundary.stories.js +21 -5
- package/dist/esm/Common/ErrorBoundary.stories.js.map +1 -1
- package/dist/esm/Common/FormElement.stories.d.ts +8 -7
- package/dist/esm/Common/FormElement.stories.d.ts.map +1 -1
- package/dist/esm/Common/FormElement.stories.js +25 -4
- package/dist/esm/Common/FormElement.stories.js.map +1 -1
- package/dist/esm/Common/Page.stories.d.ts +7 -7
- package/dist/esm/Common/Page.stories.d.ts.map +1 -1
- package/dist/esm/Common/Page.stories.js +20 -5
- package/dist/esm/Common/Page.stories.js.map +1 -1
- package/dist/esm/DataPage/DataPage.stories.d.ts +7 -7
- package/dist/esm/DataPage/DataPage.stories.d.ts.map +1 -1
- package/dist/esm/DataPage/DataPage.stories.js +56 -5
- package/dist/esm/DataPage/DataPage.stories.js.map +1 -1
- package/dist/esm/DataTables/DataTableForObservableQuery.d.ts +1 -0
- package/dist/esm/DataTables/DataTableForObservableQuery.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableForObservableQuery.js +55 -3
- package/dist/esm/DataTables/DataTableForObservableQuery.js.map +1 -1
- package/dist/esm/DataTables/DataTableForObservableQuery.stories.d.ts +7 -7
- package/dist/esm/DataTables/DataTableForObservableQuery.stories.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableForObservableQuery.stories.js +78 -5
- package/dist/esm/DataTables/DataTableForObservableQuery.stories.js.map +1 -1
- package/dist/esm/DataTables/DataTableForQuery.d.ts +1 -0
- package/dist/esm/DataTables/DataTableForQuery.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableForQuery.js +21 -3
- package/dist/esm/DataTables/DataTableForQuery.js.map +1 -1
- package/dist/esm/DataTables/DataTableForQuery.stories.d.ts +7 -7
- package/dist/esm/DataTables/DataTableForQuery.stories.d.ts.map +1 -1
- package/dist/esm/DataTables/DataTableForQuery.stories.js +53 -5
- package/dist/esm/DataTables/DataTableForQuery.stories.js.map +1 -1
- package/dist/esm/Dialogs/BusyIndicatorDialog.d.ts.map +1 -1
- package/dist/esm/Dialogs/BusyIndicatorDialog.js +3 -4
- package/dist/esm/Dialogs/BusyIndicatorDialog.js.map +1 -1
- package/dist/esm/Dialogs/ConfirmationDialog.d.ts.map +1 -1
- package/dist/esm/Dialogs/ConfirmationDialog.js +6 -23
- package/dist/esm/Dialogs/ConfirmationDialog.js.map +1 -1
- package/dist/esm/Dialogs/Dialog.d.ts +23 -0
- package/dist/esm/Dialogs/Dialog.d.ts.map +1 -0
- package/dist/esm/Dialogs/Dialog.js +64 -0
- package/dist/esm/Dialogs/Dialog.js.map +1 -0
- package/dist/esm/Dialogs/Dialog.stories.d.ts +12 -0
- package/dist/esm/Dialogs/Dialog.stories.d.ts.map +1 -0
- package/dist/esm/Dialogs/Dialog.stories.js +44 -0
- package/dist/esm/Dialogs/Dialog.stories.js.map +1 -0
- package/dist/esm/Dialogs/index.d.ts +2 -1
- package/dist/esm/Dialogs/index.d.ts.map +1 -1
- package/dist/esm/Dialogs/index.js +2 -1
- package/dist/esm/Dialogs/index.js.map +1 -1
- package/dist/esm/ObjectContentEditor/ObjectContentEditor.d.ts +8 -0
- package/dist/esm/ObjectContentEditor/ObjectContentEditor.d.ts.map +1 -0
- package/dist/esm/ObjectContentEditor/ObjectContentEditor.js +135 -0
- package/dist/esm/ObjectContentEditor/ObjectContentEditor.js.map +1 -0
- package/dist/esm/ObjectContentEditor/ObjectContentEditor.stories.d.ts +10 -0
- package/dist/esm/ObjectContentEditor/ObjectContentEditor.stories.d.ts.map +1 -0
- package/dist/esm/ObjectContentEditor/ObjectContentEditor.stories.js +144 -0
- package/dist/esm/ObjectContentEditor/ObjectContentEditor.stories.js.map +1 -0
- package/dist/esm/ObjectContentEditor/index.d.ts +2 -0
- package/dist/esm/ObjectContentEditor/index.d.ts.map +1 -0
- package/dist/esm/ObjectContentEditor/index.js +2 -0
- package/dist/esm/ObjectContentEditor/index.js.map +1 -0
- package/dist/esm/ObjectNavigationalBar/ObjectNavigationalBar.d.ts +6 -0
- package/dist/esm/ObjectNavigationalBar/ObjectNavigationalBar.d.ts.map +1 -0
- package/dist/esm/ObjectNavigationalBar/ObjectNavigationalBar.js +24 -0
- package/dist/esm/ObjectNavigationalBar/ObjectNavigationalBar.js.map +1 -0
- package/dist/esm/ObjectNavigationalBar/ObjectNavigationalBar.stories.d.ts +10 -0
- package/dist/esm/ObjectNavigationalBar/ObjectNavigationalBar.stories.d.ts.map +1 -0
- package/dist/esm/ObjectNavigationalBar/ObjectNavigationalBar.stories.js +46 -0
- package/dist/esm/ObjectNavigationalBar/ObjectNavigationalBar.stories.js.map +1 -0
- package/dist/esm/ObjectNavigationalBar/index.d.ts +2 -0
- package/dist/esm/ObjectNavigationalBar/index.d.ts.map +1 -0
- package/dist/esm/ObjectNavigationalBar/index.js +2 -0
- package/dist/esm/ObjectNavigationalBar/index.js.map +1 -0
- package/dist/esm/SchemaEditor/NameCell.d.ts +9 -0
- package/dist/esm/SchemaEditor/NameCell.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/NameCell.js +17 -0
- package/dist/esm/SchemaEditor/NameCell.js.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditor.d.ts +17 -0
- package/dist/esm/SchemaEditor/SchemaEditor.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditor.js +331 -0
- package/dist/esm/SchemaEditor/SchemaEditor.js.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditor.module.css +11 -0
- package/dist/esm/SchemaEditor/SchemaEditor.stories.d.ts +12 -0
- package/dist/esm/SchemaEditor/SchemaEditor.stories.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/SchemaEditor.stories.js +158 -0
- package/dist/esm/SchemaEditor/SchemaEditor.stories.js.map +1 -0
- package/dist/esm/SchemaEditor/TypeCell.d.ts +14 -0
- package/dist/esm/SchemaEditor/TypeCell.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/TypeCell.js +81 -0
- package/dist/esm/SchemaEditor/TypeCell.js.map +1 -0
- package/dist/esm/SchemaEditor/index.d.ts +4 -0
- package/dist/esm/SchemaEditor/index.d.ts.map +1 -0
- package/dist/esm/SchemaEditor/index.js +3 -0
- package/dist/esm/TimeMachine/EventsView.stories.d.ts +8 -7
- package/dist/esm/TimeMachine/EventsView.stories.d.ts.map +1 -1
- package/dist/esm/TimeMachine/EventsView.stories.js +80 -4
- package/dist/esm/TimeMachine/EventsView.stories.js.map +1 -1
- package/dist/esm/TimeMachine/Properties.stories.d.ts +9 -7
- package/dist/esm/TimeMachine/Properties.stories.d.ts.map +1 -1
- package/dist/esm/TimeMachine/Properties.stories.js +49 -4
- package/dist/esm/TimeMachine/Properties.stories.js.map +1 -1
- package/dist/esm/TimeMachine/ReadModelView.stories.d.ts +7 -7
- package/dist/esm/TimeMachine/ReadModelView.stories.d.ts.map +1 -1
- package/dist/esm/TimeMachine/ReadModelView.stories.js +79 -5
- package/dist/esm/TimeMachine/ReadModelView.stories.js.map +1 -1
- package/dist/esm/TimeMachine/TimeMachine.stories.d.ts +8 -7
- package/dist/esm/TimeMachine/TimeMachine.stories.d.ts.map +1 -1
- package/dist/esm/TimeMachine/TimeMachine.stories.js +113 -4
- package/dist/esm/TimeMachine/TimeMachine.stories.js.map +1 -1
- package/dist/esm/index.d.ts +4 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +10 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/types/JsonSchema.d.ts +32 -0
- package/dist/esm/types/JsonSchema.d.ts.map +1 -0
- package/dist/esm/types/JsonSchema.js +2 -0
- package/dist/esm/types/JsonSchema.js.map +1 -0
- package/dist/esm/types/TypeFormat.d.ts +6 -0
- package/dist/esm/types/TypeFormat.d.ts.map +1 -0
- package/dist/esm/types/TypeFormat.js +18 -0
- package/dist/esm/types/TypeFormat.js.map +1 -0
- package/package.json +12 -7
- package/dist/cjs/CommandForm/CommandForm.js +0 -183
- package/dist/cjs/CommandForm/CommandForm.js.map +0 -1
- package/dist/cjs/CommandForm/CommandFormField.js +0 -11
- package/dist/cjs/CommandForm/CommandFormField.js.map +0 -1
- package/dist/cjs/CommandForm/CommandFormFields.js +0 -73
- package/dist/cjs/CommandForm/CommandFormFields.js.map +0 -1
- package/dist/cjs/CommandForm/ValidationMessage.js +0 -24
- package/dist/cjs/CommandForm/ValidationMessage.js.map +0 -1
- package/dist/cjs/CommandForm/asCommandFormField.js +0 -47
- package/dist/cjs/CommandForm/asCommandFormField.js.map +0 -1
- package/dist/cjs/EventModeling/EventModeling.css +0 -146
- package/dist/cjs/EventModeling/EventModeling.js +0 -209
- package/dist/cjs/EventModeling/EventModeling.js.map +0 -1
- package/dist/cjs/EventModeling/components/Canvas.js +0 -403
- package/dist/cjs/EventModeling/components/Canvas.js.map +0 -1
- package/dist/cjs/EventModeling/components/CanvasControls.js +0 -10
- package/dist/cjs/EventModeling/components/CanvasControls.js.map +0 -1
- package/dist/cjs/EventModeling/components/Toolbox.js +0 -18
- package/dist/cjs/EventModeling/components/Toolbox.js.map +0 -1
- package/dist/cjs/EventModeling/engine/connectorGraphics.js +0 -173
- package/dist/cjs/EventModeling/engine/connectorGraphics.js.map +0 -1
- package/dist/cjs/EventModeling/engine/elementSprites.js +0 -301
- package/dist/cjs/EventModeling/engine/elementSprites.js.map +0 -1
- package/dist/cjs/EventModeling/index.js +0 -12
- package/dist/cjs/EventModeling/types.js +0 -60
- package/dist/cjs/EventModeling/types.js.map +0 -1
- package/dist/esm/CommandForm/CommandForm.d.ts +0 -49
- package/dist/esm/CommandForm/CommandForm.d.ts.map +0 -1
- package/dist/esm/CommandForm/CommandForm.js +0 -178
- package/dist/esm/CommandForm/CommandForm.js.map +0 -1
- package/dist/esm/CommandForm/CommandForm.stories.d.ts +0 -8
- package/dist/esm/CommandForm/CommandForm.stories.d.ts.map +0 -1
- package/dist/esm/CommandForm/CommandForm.stories.js +0 -45
- package/dist/esm/CommandForm/CommandForm.stories.js.map +0 -1
- package/dist/esm/CommandForm/CommandFormField.d.ts +0 -18
- package/dist/esm/CommandForm/CommandFormField.d.ts.map +0 -1
- package/dist/esm/CommandForm/CommandFormField.js +0 -9
- package/dist/esm/CommandForm/CommandFormField.js.map +0 -1
- package/dist/esm/CommandForm/CommandFormFields.d.ts +0 -11
- package/dist/esm/CommandForm/CommandFormFields.d.ts.map +0 -1
- package/dist/esm/CommandForm/CommandFormFields.js +0 -71
- package/dist/esm/CommandForm/CommandFormFields.js.map +0 -1
- package/dist/esm/CommandForm/UserRegistrationCommand.d.ts +0 -63
- package/dist/esm/CommandForm/UserRegistrationCommand.d.ts.map +0 -1
- package/dist/esm/CommandForm/UserRegistrationCommand.js +0 -143
- package/dist/esm/CommandForm/UserRegistrationCommand.js.map +0 -1
- package/dist/esm/CommandForm/ValidationMessage.d.ts +0 -8
- package/dist/esm/CommandForm/ValidationMessage.d.ts.map +0 -1
- package/dist/esm/CommandForm/ValidationMessage.js +0 -22
- package/dist/esm/CommandForm/ValidationMessage.js.map +0 -1
- package/dist/esm/CommandForm/asCommandFormField.d.ts +0 -32
- package/dist/esm/CommandForm/asCommandFormField.d.ts.map +0 -1
- package/dist/esm/CommandForm/asCommandFormField.js +0 -45
- package/dist/esm/CommandForm/asCommandFormField.js.map +0 -1
- package/dist/esm/EventModeling/EventModeling.css +0 -146
- package/dist/esm/EventModeling/EventModeling.d.ts +0 -11
- package/dist/esm/EventModeling/EventModeling.d.ts.map +0 -1
- package/dist/esm/EventModeling/EventModeling.js +0 -207
- package/dist/esm/EventModeling/EventModeling.js.map +0 -1
- package/dist/esm/EventModeling/EventModeling.stories.d.ts +0 -10
- package/dist/esm/EventModeling/EventModeling.stories.d.ts.map +0 -1
- package/dist/esm/EventModeling/EventModeling.stories.js +0 -252
- package/dist/esm/EventModeling/EventModeling.stories.js.map +0 -1
- package/dist/esm/EventModeling/components/Canvas.d.ts +0 -23
- package/dist/esm/EventModeling/components/Canvas.d.ts.map +0 -1
- package/dist/esm/EventModeling/components/Canvas.js +0 -382
- package/dist/esm/EventModeling/components/Canvas.js.map +0 -1
- package/dist/esm/EventModeling/components/CanvasControls.d.ts +0 -10
- package/dist/esm/EventModeling/components/CanvasControls.d.ts.map +0 -1
- package/dist/esm/EventModeling/components/CanvasControls.js +0 -8
- package/dist/esm/EventModeling/components/CanvasControls.js.map +0 -1
- package/dist/esm/EventModeling/components/Toolbox.d.ts +0 -9
- package/dist/esm/EventModeling/components/Toolbox.d.ts.map +0 -1
- package/dist/esm/EventModeling/components/Toolbox.js +0 -16
- package/dist/esm/EventModeling/components/Toolbox.js.map +0 -1
- package/dist/esm/EventModeling/engine/connectorGraphics.d.ts +0 -12
- package/dist/esm/EventModeling/engine/connectorGraphics.d.ts.map +0 -1
- package/dist/esm/EventModeling/engine/connectorGraphics.js +0 -151
- package/dist/esm/EventModeling/engine/connectorGraphics.js.map +0 -1
- package/dist/esm/EventModeling/engine/elementSprites.d.ts +0 -23
- package/dist/esm/EventModeling/engine/elementSprites.d.ts.map +0 -1
- package/dist/esm/EventModeling/engine/elementSprites.js +0 -276
- package/dist/esm/EventModeling/engine/elementSprites.js.map +0 -1
- package/dist/esm/EventModeling/index.d.ts +0 -3
- package/dist/esm/EventModeling/index.d.ts.map +0 -1
- package/dist/esm/EventModeling/index.js +0 -3
- package/dist/esm/EventModeling/types.d.ts +0 -79
- package/dist/esm/EventModeling/types.d.ts.map +0 -1
- package/dist/esm/EventModeling/types.js +0 -56
- package/dist/esm/EventModeling/types.js.map +0 -1
- /package/dist/esm/{EventModeling → SchemaEditor}/index.js.map +0 -0
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { Command, CommandValidator } from '@cratis/arc/commands';
|
|
2
|
-
import { useCommand } from '@cratis/arc.react/commands';
|
|
3
|
-
import { PropertyDescriptor } from '@cratis/arc/reflection';
|
|
4
|
-
import '@cratis/arc/validation';
|
|
5
|
-
export class UserRegistrationCommandValidator extends CommandValidator {
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
this.ruleFor(c => c.username).notEmpty().minLength(3).maxLength(20);
|
|
9
|
-
this.ruleFor(c => c.email).notEmpty().emailAddress();
|
|
10
|
-
this.ruleFor(c => c.password).notEmpty().minLength(8);
|
|
11
|
-
this.ruleFor(c => c.age).greaterThanOrEqual(13).lessThanOrEqual(120);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export class UserRegistrationCommand extends Command {
|
|
15
|
-
route = '/api/users/register';
|
|
16
|
-
validation = new UserRegistrationCommandValidator();
|
|
17
|
-
propertyDescriptors = [
|
|
18
|
-
new PropertyDescriptor('username', String),
|
|
19
|
-
new PropertyDescriptor('email', String),
|
|
20
|
-
new PropertyDescriptor('password', String),
|
|
21
|
-
new PropertyDescriptor('confirmPassword', String),
|
|
22
|
-
new PropertyDescriptor('age', Number),
|
|
23
|
-
new PropertyDescriptor('bio', String),
|
|
24
|
-
new PropertyDescriptor('favoriteColor', String),
|
|
25
|
-
new PropertyDescriptor('birthDate', String),
|
|
26
|
-
new PropertyDescriptor('agreeToTerms', Boolean),
|
|
27
|
-
new PropertyDescriptor('experienceLevel', Number),
|
|
28
|
-
new PropertyDescriptor('role', String),
|
|
29
|
-
];
|
|
30
|
-
_username;
|
|
31
|
-
_email;
|
|
32
|
-
_password;
|
|
33
|
-
_confirmPassword;
|
|
34
|
-
_age;
|
|
35
|
-
_bio;
|
|
36
|
-
_favoriteColor;
|
|
37
|
-
_birthDate;
|
|
38
|
-
_agreeToTerms;
|
|
39
|
-
_experienceLevel;
|
|
40
|
-
_role;
|
|
41
|
-
constructor() {
|
|
42
|
-
super(Object, false);
|
|
43
|
-
}
|
|
44
|
-
get requestParameters() {
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
get properties() {
|
|
48
|
-
return [
|
|
49
|
-
'username',
|
|
50
|
-
'email',
|
|
51
|
-
'password',
|
|
52
|
-
'confirmPassword',
|
|
53
|
-
'age',
|
|
54
|
-
'bio',
|
|
55
|
-
'favoriteColor',
|
|
56
|
-
'birthDate',
|
|
57
|
-
'agreeToTerms',
|
|
58
|
-
'experienceLevel',
|
|
59
|
-
'role',
|
|
60
|
-
];
|
|
61
|
-
}
|
|
62
|
-
get username() {
|
|
63
|
-
return this._username;
|
|
64
|
-
}
|
|
65
|
-
set username(value) {
|
|
66
|
-
this._username = value;
|
|
67
|
-
this.propertyChanged('username');
|
|
68
|
-
}
|
|
69
|
-
get email() {
|
|
70
|
-
return this._email;
|
|
71
|
-
}
|
|
72
|
-
set email(value) {
|
|
73
|
-
this._email = value;
|
|
74
|
-
this.propertyChanged('email');
|
|
75
|
-
}
|
|
76
|
-
get password() {
|
|
77
|
-
return this._password;
|
|
78
|
-
}
|
|
79
|
-
set password(value) {
|
|
80
|
-
this._password = value;
|
|
81
|
-
this.propertyChanged('password');
|
|
82
|
-
}
|
|
83
|
-
get confirmPassword() {
|
|
84
|
-
return this._confirmPassword;
|
|
85
|
-
}
|
|
86
|
-
set confirmPassword(value) {
|
|
87
|
-
this._confirmPassword = value;
|
|
88
|
-
this.propertyChanged('confirmPassword');
|
|
89
|
-
}
|
|
90
|
-
get age() {
|
|
91
|
-
return this._age;
|
|
92
|
-
}
|
|
93
|
-
set age(value) {
|
|
94
|
-
this._age = value;
|
|
95
|
-
this.propertyChanged('age');
|
|
96
|
-
}
|
|
97
|
-
get bio() {
|
|
98
|
-
return this._bio;
|
|
99
|
-
}
|
|
100
|
-
set bio(value) {
|
|
101
|
-
this._bio = value;
|
|
102
|
-
this.propertyChanged('bio');
|
|
103
|
-
}
|
|
104
|
-
get favoriteColor() {
|
|
105
|
-
return this._favoriteColor;
|
|
106
|
-
}
|
|
107
|
-
set favoriteColor(value) {
|
|
108
|
-
this._favoriteColor = value;
|
|
109
|
-
this.propertyChanged('favoriteColor');
|
|
110
|
-
}
|
|
111
|
-
get birthDate() {
|
|
112
|
-
return this._birthDate;
|
|
113
|
-
}
|
|
114
|
-
set birthDate(value) {
|
|
115
|
-
this._birthDate = value;
|
|
116
|
-
this.propertyChanged('birthDate');
|
|
117
|
-
}
|
|
118
|
-
get agreeToTerms() {
|
|
119
|
-
return this._agreeToTerms;
|
|
120
|
-
}
|
|
121
|
-
set agreeToTerms(value) {
|
|
122
|
-
this._agreeToTerms = value;
|
|
123
|
-
this.propertyChanged('agreeToTerms');
|
|
124
|
-
}
|
|
125
|
-
get experienceLevel() {
|
|
126
|
-
return this._experienceLevel;
|
|
127
|
-
}
|
|
128
|
-
set experienceLevel(value) {
|
|
129
|
-
this._experienceLevel = value;
|
|
130
|
-
this.propertyChanged('experienceLevel');
|
|
131
|
-
}
|
|
132
|
-
get role() {
|
|
133
|
-
return this._role;
|
|
134
|
-
}
|
|
135
|
-
set role(value) {
|
|
136
|
-
this._role = value;
|
|
137
|
-
this.propertyChanged('role');
|
|
138
|
-
}
|
|
139
|
-
static use(initialValues) {
|
|
140
|
-
return useCommand(UserRegistrationCommand, initialValues);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
//# sourceMappingURL=UserRegistrationCommand.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UserRegistrationCommand.js","sourceRoot":"","sources":["../../../CommandForm/UserRegistrationCommand.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface ValidationMessageProps<TCommand> {
|
|
2
|
-
value: (command: TCommand) => unknown;
|
|
3
|
-
}
|
|
4
|
-
export declare const ValidationMessage: {
|
|
5
|
-
<TCommand>(props: ValidationMessageProps<TCommand>): import("react/jsx-runtime").JSX.Element | null;
|
|
6
|
-
displayName: string;
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=ValidationMessage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationMessage.d.ts","sourceRoot":"","sources":["../../../CommandForm/ValidationMessage.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,sBAAsB,CAAC,QAAQ;IAC5C,KAAK,EAAE,CAAC,OAAO,EAAE,QAAQ,KAAK,OAAO,CAAC;CACzC;AAED,eAAO,MAAM,iBAAiB;KAAI,QAAQ,SAAU,sBAAsB,CAAC,QAAQ,CAAC;;CAqBnF,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useCommandFormContext } from './CommandForm.js';
|
|
3
|
-
|
|
4
|
-
const ValidationMessage = (props) => {
|
|
5
|
-
const context = useCommandFormContext();
|
|
6
|
-
const propertyAccessor = props.value;
|
|
7
|
-
const getPropertyName = (accessor) => {
|
|
8
|
-
const fnStr = accessor.toString();
|
|
9
|
-
const match = fnStr.match(/\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);
|
|
10
|
-
return match ? match[1] : '';
|
|
11
|
-
};
|
|
12
|
-
const propertyName = getPropertyName(propertyAccessor);
|
|
13
|
-
const errorMessage = propertyName ? context.getFieldError(propertyName) : undefined;
|
|
14
|
-
if (!errorMessage) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
return (jsx("small", { className: "p-error block mt-1", children: errorMessage }));
|
|
18
|
-
};
|
|
19
|
-
ValidationMessage.displayName = 'ValidationMessage';
|
|
20
|
-
|
|
21
|
-
export { ValidationMessage };
|
|
22
|
-
//# sourceMappingURL=ValidationMessage.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationMessage.js","sources":["../../../CommandForm/ValidationMessage.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 React from 'react';\nimport { useCommandFormContext } from './CommandForm';\n\nexport interface ValidationMessageProps<TCommand> {\n value: (command: TCommand) => unknown;\n}\n\nexport const ValidationMessage = <TCommand,>(props: ValidationMessageProps<TCommand>) => {\n const context = useCommandFormContext<TCommand>();\n const propertyAccessor = props.value;\n \n // Get the property name from the accessor function\n const getPropertyName = (accessor: (obj: TCommand) => unknown): string => {\n const fnStr = accessor.toString();\n const match = fnStr.match(/\\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);\n return match ? match[1] : '';\n };\n \n const propertyName = getPropertyName(propertyAccessor);\n const errorMessage = propertyName ? context.getFieldError(propertyName) : undefined;\n \n if (!errorMessage) {\n return null;\n }\n \n return (\n <small className=\"p-error block mt-1\">{errorMessage}</small>\n );\n};\n\nValidationMessage.displayName = 'ValidationMessage';\n"],"names":["_jsx"],"mappings":";;;AAUO,MAAM,iBAAiB,GAAG,CAAY,KAAuC,KAAI;AACpF,IAAA,MAAM,OAAO,GAAG,qBAAqB,EAAY;AACjD,IAAA,MAAM,gBAAgB,GAAG,KAAK,CAAC,KAAK;AAGpC,IAAA,MAAM,eAAe,GAAG,CAAC,QAAoC,KAAY;AACrE,QAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,QAAQ,EAAE;QACjC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,8BAA8B,CAAC;AACzD,QAAA,OAAO,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE;AAChC,IAAA,CAAC;AAED,IAAA,MAAM,YAAY,GAAG,eAAe,CAAC,gBAAgB,CAAC;AACtD,IAAA,MAAM,YAAY,GAAG,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,GAAG,SAAS;IAEnF,IAAI,CAAC,YAAY,EAAE;AACf,QAAA,OAAO,IAAI;IACf;IAEA,QACIA,eAAO,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAAE,YAAY,EAAA,CAAS;AAEpE;AAEA,iBAAiB,CAAC,WAAW,GAAG,mBAAmB;;;;"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { PropertyAccessor } from '@cratis/fundamentals';
|
|
2
|
-
import { PropertyDescriptor } from '@cratis/arc/reflection';
|
|
3
|
-
import React, { ComponentType } from 'react';
|
|
4
|
-
export interface InjectedCommandFormFieldProps {
|
|
5
|
-
currentValue?: unknown;
|
|
6
|
-
onValueChange?: (value: unknown) => void;
|
|
7
|
-
propertyDescriptor?: PropertyDescriptor;
|
|
8
|
-
fieldName?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface BaseCommandFormFieldProps<TCommand> {
|
|
11
|
-
icon?: React.ReactElement;
|
|
12
|
-
value: PropertyAccessor<TCommand>;
|
|
13
|
-
required?: boolean;
|
|
14
|
-
title?: string;
|
|
15
|
-
description?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface CommandFormFieldConfig<TValue = unknown> {
|
|
18
|
-
defaultValue: TValue;
|
|
19
|
-
extractValue?: (event: unknown) => TValue;
|
|
20
|
-
}
|
|
21
|
-
export interface WrappedFieldProps<TValue = unknown> {
|
|
22
|
-
value: TValue;
|
|
23
|
-
onChange: (valueOrEvent: TValue | unknown) => void;
|
|
24
|
-
invalid: boolean;
|
|
25
|
-
required: boolean;
|
|
26
|
-
errors: string[];
|
|
27
|
-
}
|
|
28
|
-
export declare function asCommandFormField<TComponentProps extends WrappedFieldProps<unknown>>(component: ComponentType<TComponentProps> | ((props: TComponentProps) => React.ReactElement), config: CommandFormFieldConfig<TComponentProps['value']>): {
|
|
29
|
-
<TCommand>(props: Omit<TComponentProps, keyof WrappedFieldProps> & BaseCommandFormFieldProps<TCommand> & InjectedCommandFormFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
-
displayName: string;
|
|
31
|
-
};
|
|
32
|
-
//# sourceMappingURL=asCommandFormField.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"asCommandFormField.d.ts","sourceRoot":"","sources":["../../../CommandForm/asCommandFormField.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,EAAuB,aAAa,EAAE,MAAM,OAAO,CAAC;AAMlE,MAAM,WAAW,6BAA6B;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACzC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAKD,MAAM,WAAW,yBAAyB,CAAC,QAAQ;IAC/C,IAAI,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC1B,KAAK,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAKD,MAAM,WAAW,sBAAsB,CAAC,MAAM,GAAG,OAAO;IAEpD,YAAY,EAAE,MAAM,CAAC;IAErB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;CAC7C;AAKD,MAAM,WAAW,iBAAiB,CAAC,MAAM,GAAG,OAAO;IAC/C,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,KAAK,IAAI,CAAC;IACnD,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;CACpB;AAoCD,wBAAgB,kBAAkB,CAAC,eAAe,SAAS,iBAAiB,CAAC,OAAO,CAAC,EACjF,SAAS,EAAE,aAAa,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,eAAe,KAAK,KAAK,CAAC,YAAY,CAAC,EAC5F,MAAM,EAAE,sBAAsB,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;KAOlC,QAAQ,SACnB,IAAI,CAAC,eAAe,EAAE,MAAM,iBAAiB,CAAC,GAC9C,yBAAyB,CAAC,QAAQ,CAAC,GACnC,6BAA6B;;EA+C3C"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useState, useEffect } from 'react';
|
|
3
|
-
import { useCommandFormContext } from './CommandForm.js';
|
|
4
|
-
|
|
5
|
-
function asCommandFormField(component, config) {
|
|
6
|
-
const { defaultValue, extractValue } = config;
|
|
7
|
-
const Component = typeof component === 'function' && !component.prototype?.render
|
|
8
|
-
? component
|
|
9
|
-
: component;
|
|
10
|
-
const WrappedField = (props) => {
|
|
11
|
-
const { currentValue, onValueChange, fieldName, required = true, ...componentProps } = props;
|
|
12
|
-
const [localValue, setLocalValue] = useState(currentValue ?? defaultValue);
|
|
13
|
-
const { getFieldError, customFieldErrors } = useCommandFormContext();
|
|
14
|
-
const serverError = fieldName ? getFieldError(fieldName) : undefined;
|
|
15
|
-
const customError = fieldName ? customFieldErrors[fieldName] : undefined;
|
|
16
|
-
const errors = [];
|
|
17
|
-
if (serverError)
|
|
18
|
-
errors.push(serverError);
|
|
19
|
-
if (customError)
|
|
20
|
-
errors.push(customError);
|
|
21
|
-
const isInvalid = errors.length > 0;
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
setLocalValue(currentValue ?? defaultValue);
|
|
24
|
-
}, [currentValue]);
|
|
25
|
-
const handleChange = (valueOrEvent) => {
|
|
26
|
-
const newValue = extractValue ? extractValue(valueOrEvent) : valueOrEvent;
|
|
27
|
-
setLocalValue(newValue);
|
|
28
|
-
onValueChange?.(newValue);
|
|
29
|
-
};
|
|
30
|
-
const wrappedProps = {
|
|
31
|
-
...componentProps,
|
|
32
|
-
value: localValue,
|
|
33
|
-
onChange: handleChange,
|
|
34
|
-
invalid: isInvalid,
|
|
35
|
-
required,
|
|
36
|
-
errors
|
|
37
|
-
};
|
|
38
|
-
return jsx(Component, { ...wrappedProps });
|
|
39
|
-
};
|
|
40
|
-
WrappedField.displayName = 'CommandFormField';
|
|
41
|
-
return WrappedField;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { asCommandFormField };
|
|
45
|
-
//# sourceMappingURL=asCommandFormField.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"asCommandFormField.js","sources":["../../../CommandForm/asCommandFormField.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 { PropertyAccessor } from '@cratis/fundamentals';\nimport { PropertyDescriptor } from '@cratis/arc/reflection';\nimport React, { useState, useEffect, ComponentType } from 'react';\nimport { useCommandFormContext } from './CommandForm';\n\n/**\n * Props that will be injected by CommandFormFields into your wrapped component\n */\nexport interface InjectedCommandFormFieldProps {\n currentValue?: unknown;\n onValueChange?: (value: unknown) => void;\n propertyDescriptor?: PropertyDescriptor;\n fieldName?: string;\n}\n\n/**\n * Props that your field component should accept (excluding the injected ones)\n */\nexport interface BaseCommandFormFieldProps<TCommand> {\n icon?: React.ReactElement;\n value: PropertyAccessor<TCommand>;\n required?: boolean;\n title?: string;\n description?: string;\n}\n\n/**\n * Configuration for the field wrapper\n */\nexport interface CommandFormFieldConfig<TValue = unknown> {\n /** Default value when currentValue is undefined */\n defaultValue: TValue;\n /** Value extractor from the change event */\n extractValue?: (event: unknown) => TValue;\n}\n\n/**\n * Props that your wrapped component will receive\n */\nexport interface WrappedFieldProps<TValue = unknown> {\n value: TValue;\n onChange: (valueOrEvent: TValue | unknown) => void;\n invalid: boolean;\n required: boolean;\n errors: string[];\n}\n\n/**\n * Wraps a field component to work with CommandForm, handling all integration automatically.\n * \n * @example\n * ```typescript\n * interface MyInputProps extends WrappedFieldProps<string> {\n * placeholder?: string;\n * }\n * \n * export const MyInputField = asCommandFormField<MyInputProps>(\n * (props) => (\n * <div>\n * <input\n * value={props.value}\n * onChange={props.onChange}\n * placeholder={props.placeholder}\n * className={props.invalid ? 'invalid' : ''}\n * />\n * {props.errors.length > 0 && (\n * <div className=\"error-messages\">\n * {props.errors.map((error, idx) => (\n * <small key={idx} className=\"p-error\">{error}</small>\n * ))}\n * </div>\n * )}\n * </div>\n * ),\n * {\n * defaultValue: '',\n * extractValue: (e) => e.target.value\n * }\n * );\n * ```\n */\nexport function asCommandFormField<TComponentProps extends WrappedFieldProps<unknown>>(\n component: ComponentType<TComponentProps> | ((props: TComponentProps) => React.ReactElement),\n config: CommandFormFieldConfig<TComponentProps['value']>\n) {\n const { defaultValue, extractValue } = config;\n const Component = typeof component === 'function' && !component.prototype?.render \n ? component \n : component as ComponentType<TComponentProps>;\n\n const WrappedField = <TCommand,>(\n props: Omit<TComponentProps, keyof WrappedFieldProps> & \n BaseCommandFormFieldProps<TCommand> & \n InjectedCommandFormFieldProps\n ) => {\n const { \n currentValue, \n onValueChange, \n fieldName, \n required = true,\n ...componentProps \n } = props;\n\n const [localValue, setLocalValue] = useState(currentValue ?? defaultValue);\n const { getFieldError, customFieldErrors } = useCommandFormContext();\n\n const serverError = fieldName ? getFieldError(fieldName) : undefined;\n const customError = fieldName ? customFieldErrors[fieldName] : undefined;\n \n const errors: string[] = [];\n if (serverError) errors.push(serverError);\n if (customError) errors.push(customError);\n\n const isInvalid = errors.length > 0;\n\n useEffect(() => {\n setLocalValue(currentValue ?? defaultValue);\n }, [currentValue]);\n\n const handleChange = (valueOrEvent: unknown) => {\n const newValue = extractValue ? extractValue(valueOrEvent) : valueOrEvent;\n setLocalValue(newValue);\n onValueChange?.(newValue);\n };\n\n const wrappedProps = {\n ...componentProps,\n value: localValue,\n onChange: handleChange,\n invalid: isInvalid,\n required,\n errors\n } as TComponentProps;\n\n return <Component {...wrappedProps} />;\n };\n\n WrappedField.displayName = 'CommandFormField';\n\n return WrappedField;\n}\n"],"names":["_jsx"],"mappings":";;;;AAoFM,SAAU,kBAAkB,CAC9B,SAA4F,EAC5F,MAAwD,EAAA;AAExD,IAAA,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,MAAM;AAC7C,IAAA,MAAM,SAAS,GAAG,OAAO,SAAS,KAAK,UAAU,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE;AACvE,UAAE;UACA,SAA2C;AAEjD,IAAA,MAAM,YAAY,GAAG,CACjB,KAEoC,KACpC;AACA,QAAA,MAAM,EACF,YAAY,EACZ,aAAa,EACb,SAAS,EACT,QAAQ,GAAG,IAAI,EACf,GAAG,cAAc,EACpB,GAAG,KAAK;AAET,QAAA,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,YAAY,IAAI,YAAY,CAAC;QAC1E,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,GAAG,qBAAqB,EAAE;AAEpE,QAAA,MAAM,WAAW,GAAG,SAAS,GAAG,aAAa,CAAC,SAAS,CAAC,GAAG,SAAS;AACpE,QAAA,MAAM,WAAW,GAAG,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC,GAAG,SAAS;QAExE,MAAM,MAAM,GAAa,EAAE;AAC3B,QAAA,IAAI,WAAW;AAAE,YAAA,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;AACzC,QAAA,IAAI,WAAW;AAAE,YAAA,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC;AAEzC,QAAA,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC;QAEnC,SAAS,CAAC,MAAK;AACX,YAAA,aAAa,CAAC,YAAY,IAAI,YAAY,CAAC;AAC/C,QAAA,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC;AAElB,QAAA,MAAM,YAAY,GAAG,CAAC,YAAqB,KAAI;AAC3C,YAAA,MAAM,QAAQ,GAAG,YAAY,GAAG,YAAY,CAAC,YAAY,CAAC,GAAG,YAAY;YACzE,aAAa,CAAC,QAAQ,CAAC;AACvB,YAAA,aAAa,GAAG,QAAQ,CAAC;AAC7B,QAAA,CAAC;AAED,QAAA,MAAM,YAAY,GAAG;AACjB,YAAA,GAAG,cAAc;AACjB,YAAA,KAAK,EAAE,UAAU;AACjB,YAAA,QAAQ,EAAE,YAAY;AACtB,YAAA,OAAO,EAAE,SAAS;YAClB,QAAQ;YACR;SACgB;AAEpB,QAAA,OAAOA,GAAA,CAAC,SAAS,EAAA,EAAA,GAAK,YAAY,GAAI;AAC1C,IAAA,CAAC;AAED,IAAA,YAAY,CAAC,WAAW,GAAG,kBAAkB;AAE7C,IAAA,OAAO,YAAY;AACvB;;;;"}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/* Copyright (c) Cratis. All rights reserved.
|
|
2
|
-
Licensed under the MIT license. See LICENSE file in the project root for full license information. */
|
|
3
|
-
|
|
4
|
-
.event-modeling {
|
|
5
|
-
position: relative;
|
|
6
|
-
overflow: hidden;
|
|
7
|
-
background: var(--surface-ground, #f8f9fa);
|
|
8
|
-
display: flex;
|
|
9
|
-
flex-direction: column;
|
|
10
|
-
width: 100%;
|
|
11
|
-
height: 100%;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.event-modeling-canvas-container {
|
|
15
|
-
flex: 1;
|
|
16
|
-
position: relative;
|
|
17
|
-
overflow: hidden;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.event-modeling-canvas {
|
|
21
|
-
position: absolute;
|
|
22
|
-
top: 0;
|
|
23
|
-
left: 0;
|
|
24
|
-
z-index: 0;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.event-modeling-toolbox {
|
|
28
|
-
position: absolute;
|
|
29
|
-
top: 20px;
|
|
30
|
-
left: 20px;
|
|
31
|
-
background: var(--surface-card, #ffffff);
|
|
32
|
-
border-radius: 12px;
|
|
33
|
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
34
|
-
border: 1px solid var(--surface-border, #dee2e6);
|
|
35
|
-
padding: 8px;
|
|
36
|
-
z-index: 1000;
|
|
37
|
-
display: flex;
|
|
38
|
-
gap: 6px;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.event-modeling-tool-button {
|
|
42
|
-
width: 64px;
|
|
43
|
-
height: 64px;
|
|
44
|
-
border: 2px solid transparent;
|
|
45
|
-
border-radius: 8px;
|
|
46
|
-
background: var(--surface-0, #ffffff);
|
|
47
|
-
cursor: pointer;
|
|
48
|
-
display: flex;
|
|
49
|
-
flex-direction: column;
|
|
50
|
-
align-items: center;
|
|
51
|
-
justify-content: center;
|
|
52
|
-
gap: 4px;
|
|
53
|
-
transition: all 0.15s ease;
|
|
54
|
-
font-size: 11px;
|
|
55
|
-
font-weight: 600;
|
|
56
|
-
color: var(--text-color, #495057);
|
|
57
|
-
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.event-modeling-tool-button:hover {
|
|
61
|
-
background: var(--surface-100, #f8f9fa);
|
|
62
|
-
transform: translateY(-1px);
|
|
63
|
-
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.event-modeling-tool-button.selected {
|
|
67
|
-
border-color: var(--primary-color, #3B82F6);
|
|
68
|
-
background: var(--primary-50, #EFF6FF);
|
|
69
|
-
box-shadow: 0 0 0 1px var(--primary-color, #3B82F6);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.event-modeling-tool-icon {
|
|
73
|
-
font-size: 24px;
|
|
74
|
-
display: flex;
|
|
75
|
-
align-items: center;
|
|
76
|
-
justify-content: center;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.event-modeling-tool-button.command .event-modeling-tool-icon {
|
|
80
|
-
width: 40px;
|
|
81
|
-
height: 24px;
|
|
82
|
-
background: var(--blue-500, #3b82f6);
|
|
83
|
-
border-radius: 4px;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
.event-modeling-tool-button.event .event-modeling-tool-icon {
|
|
87
|
-
width: 40px;
|
|
88
|
-
height: 24px;
|
|
89
|
-
background: var(--orange-500, #f59e0b);
|
|
90
|
-
border-radius: 4px;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.event-modeling-tool-button.readmodel .event-modeling-tool-icon {
|
|
94
|
-
width: 40px;
|
|
95
|
-
height: 24px;
|
|
96
|
-
background: var(--green-500, #10b981);
|
|
97
|
-
border-radius: 4px;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.event-modeling-tool-button.process .event-modeling-tool-icon {
|
|
101
|
-
width: 28px;
|
|
102
|
-
height: 28px;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.event-modeling-controls {
|
|
106
|
-
position: absolute;
|
|
107
|
-
bottom: 20px;
|
|
108
|
-
right: 20px;
|
|
109
|
-
background: var(--surface-card, #ffffff);
|
|
110
|
-
border-radius: 12px;
|
|
111
|
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.08);
|
|
112
|
-
border: 1px solid var(--surface-border, #dee2e6);
|
|
113
|
-
padding: 6px;
|
|
114
|
-
z-index: 1000;
|
|
115
|
-
display: flex;
|
|
116
|
-
flex-direction: column;
|
|
117
|
-
gap: 4px;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.event-modeling-control-button {
|
|
121
|
-
width: 40px;
|
|
122
|
-
height: 40px;
|
|
123
|
-
border: none;
|
|
124
|
-
border-radius: 8px;
|
|
125
|
-
background: var(--surface-0, #ffffff);
|
|
126
|
-
cursor: pointer;
|
|
127
|
-
display: flex;
|
|
128
|
-
align-items: center;
|
|
129
|
-
justify-content: center;
|
|
130
|
-
transition: all 0.15s ease;
|
|
131
|
-
font-size: 16px;
|
|
132
|
-
font-weight: 600;
|
|
133
|
-
color: var(--text-color, #495057);
|
|
134
|
-
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
.event-modeling-control-button:hover {
|
|
138
|
-
background: var(--surface-100, #f8f9fa);
|
|
139
|
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.event-modeling-control-button:disabled {
|
|
143
|
-
opacity: 0.4;
|
|
144
|
-
cursor: not-allowed;
|
|
145
|
-
background: var(--surface-100, #f8f9fa);
|
|
146
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { EventModelingState } from './types';
|
|
3
|
-
import './EventModeling.css';
|
|
4
|
-
export interface EventModelingProps {
|
|
5
|
-
initialState?: EventModelingState;
|
|
6
|
-
onStateChange?: (state: EventModelingState) => void;
|
|
7
|
-
width?: string;
|
|
8
|
-
height?: string;
|
|
9
|
-
}
|
|
10
|
-
export declare const EventModeling: React.FC<EventModelingProps>;
|
|
11
|
-
//# sourceMappingURL=EventModeling.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventModeling.d.ts","sourceRoot":"","sources":["../../../EventModeling/EventModeling.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAgC,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAoF,MAAM,SAAS,CAAC;AAI/H,OAAO,qBAAqB,CAAC;AAE7B,MAAM,WAAW,kBAAkB;IAC/B,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACpD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAyRtD,CAAC"}
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import React, { useState, useCallback } from 'react';
|
|
3
|
-
import { DEFAULT_ELEMENT_SIZE, calculateOptimalEdges } from './types.js';
|
|
4
|
-
import { Toolbox } from './components/Toolbox.js';
|
|
5
|
-
import { Canvas } from './components/Canvas.js';
|
|
6
|
-
import { CanvasControls } from './components/CanvasControls.js';
|
|
7
|
-
import './EventModeling.css';
|
|
8
|
-
|
|
9
|
-
const EventModeling = ({ initialState, onStateChange, width = '100%', height = '100vh', }) => {
|
|
10
|
-
const [state, setState] = useState(initialState || {
|
|
11
|
-
elements: [],
|
|
12
|
-
connectors: [],
|
|
13
|
-
});
|
|
14
|
-
const [selectedTool, setSelectedTool] = useState('select');
|
|
15
|
-
const [zoom, setZoom] = useState(1);
|
|
16
|
-
const [pan, setPan] = useState({ x: 0, y: 0 });
|
|
17
|
-
const updateState = useCallback((newState) => {
|
|
18
|
-
setState(newState);
|
|
19
|
-
onStateChange?.(newState);
|
|
20
|
-
}, [onStateChange]);
|
|
21
|
-
const handleZoomChange = useCallback((newZoom) => {
|
|
22
|
-
setZoom(newZoom);
|
|
23
|
-
}, []);
|
|
24
|
-
const handlePanChange = useCallback((newPan) => {
|
|
25
|
-
setPan(newPan);
|
|
26
|
-
}, []);
|
|
27
|
-
const handleAddElement = useCallback((type, x, y) => {
|
|
28
|
-
console.log('Adding element:', type, 'at', x, y);
|
|
29
|
-
const size = DEFAULT_ELEMENT_SIZE[type];
|
|
30
|
-
const newElement = {
|
|
31
|
-
id: `${type}-${Date.now()}`,
|
|
32
|
-
type,
|
|
33
|
-
position: { x, y },
|
|
34
|
-
size,
|
|
35
|
-
label: `New ${type.charAt(0).toUpperCase() + type.slice(1)}`,
|
|
36
|
-
};
|
|
37
|
-
updateState({
|
|
38
|
-
...state,
|
|
39
|
-
elements: [...state.elements, newElement],
|
|
40
|
-
});
|
|
41
|
-
setSelectedTool('select');
|
|
42
|
-
}, [state, updateState]);
|
|
43
|
-
const handleUpdateElement = useCallback((id, updates) => {
|
|
44
|
-
const updatedElements = state.elements.map(el => el.id === id ? { ...el, ...updates } : el);
|
|
45
|
-
let updatedConnectors = state.connectors;
|
|
46
|
-
if (updates.position) {
|
|
47
|
-
updatedConnectors = state.connectors.map(connector => {
|
|
48
|
-
if (connector.from.elementId === id || connector.to.elementId === id) {
|
|
49
|
-
const fromElement = updatedElements.find(el => el.id === connector.from.elementId);
|
|
50
|
-
const toElement = updatedElements.find(el => el.id === connector.to.elementId);
|
|
51
|
-
if (fromElement && toElement) {
|
|
52
|
-
const optimalEdges = calculateOptimalEdges(fromElement, toElement);
|
|
53
|
-
return {
|
|
54
|
-
...connector,
|
|
55
|
-
from: { elementId: connector.from.elementId, side: optimalEdges.fromSide },
|
|
56
|
-
to: { elementId: connector.to.elementId, side: optimalEdges.toSide },
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return connector;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
updateState({
|
|
64
|
-
...state,
|
|
65
|
-
elements: updatedElements,
|
|
66
|
-
connectors: updatedConnectors,
|
|
67
|
-
});
|
|
68
|
-
}, [state, updateState]);
|
|
69
|
-
const handleDeleteElement = useCallback((id) => {
|
|
70
|
-
updateState({
|
|
71
|
-
...state,
|
|
72
|
-
elements: state.elements.filter(el => el.id !== id),
|
|
73
|
-
connectors: state.connectors.filter(conn => conn.from.elementId !== id && conn.to.elementId !== id),
|
|
74
|
-
selectedElementId: state.selectedElementId === id ? undefined : state.selectedElementId,
|
|
75
|
-
});
|
|
76
|
-
}, [state, updateState]);
|
|
77
|
-
const handleAddConnector = useCallback((connector) => {
|
|
78
|
-
if (connector.from.elementId === connector.to.elementId) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const fromElement = state.elements.find(el => el.id === connector.from.elementId);
|
|
82
|
-
const toElement = state.elements.find(el => el.id === connector.to.elementId);
|
|
83
|
-
if (!fromElement || !toElement) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
const optimalEdges = calculateOptimalEdges(fromElement, toElement);
|
|
87
|
-
const optimizedConnector = {
|
|
88
|
-
...connector,
|
|
89
|
-
from: { elementId: connector.from.elementId, side: optimalEdges.fromSide },
|
|
90
|
-
to: { elementId: connector.to.elementId, side: optimalEdges.toSide },
|
|
91
|
-
};
|
|
92
|
-
const isDuplicate = state.connectors.some(c => c.from.elementId === optimizedConnector.from.elementId &&
|
|
93
|
-
c.to.elementId === optimizedConnector.to.elementId);
|
|
94
|
-
if (isDuplicate) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
updateState({
|
|
98
|
-
...state,
|
|
99
|
-
connectors: [...state.connectors, optimizedConnector],
|
|
100
|
-
});
|
|
101
|
-
}, [state, updateState]);
|
|
102
|
-
const handleDeleteConnector = useCallback((id) => {
|
|
103
|
-
updateState({
|
|
104
|
-
...state,
|
|
105
|
-
connectors: state.connectors.filter(conn => conn.id !== id),
|
|
106
|
-
selectedConnectorId: state.selectedConnectorId === id ? undefined : state.selectedConnectorId,
|
|
107
|
-
});
|
|
108
|
-
}, [state, updateState]);
|
|
109
|
-
const handleSelectElement = useCallback((id) => {
|
|
110
|
-
updateState({
|
|
111
|
-
...state,
|
|
112
|
-
selectedElementId: id,
|
|
113
|
-
selectedConnectorId: undefined,
|
|
114
|
-
});
|
|
115
|
-
}, [state, updateState]);
|
|
116
|
-
const handleSelectConnector = useCallback((id) => {
|
|
117
|
-
updateState({
|
|
118
|
-
...state,
|
|
119
|
-
selectedConnectorId: id,
|
|
120
|
-
selectedElementId: undefined,
|
|
121
|
-
});
|
|
122
|
-
}, [state, updateState]);
|
|
123
|
-
const handleZoomIn = useCallback(() => {
|
|
124
|
-
setZoom(prev => Math.min(5, prev * 1.2));
|
|
125
|
-
}, []);
|
|
126
|
-
const handleZoomOut = useCallback(() => {
|
|
127
|
-
setZoom(prev => Math.max(0.1, prev / 1.2));
|
|
128
|
-
}, []);
|
|
129
|
-
const handleZoomReset = useCallback(() => {
|
|
130
|
-
setZoom(1);
|
|
131
|
-
}, []);
|
|
132
|
-
const handleFitToView = useCallback(() => {
|
|
133
|
-
if (state.elements.length === 0) {
|
|
134
|
-
setZoom(1);
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
|
138
|
-
state.elements.forEach(el => {
|
|
139
|
-
minX = Math.min(minX, el.position.x);
|
|
140
|
-
minY = Math.min(minY, el.position.y);
|
|
141
|
-
maxX = Math.max(maxX, el.position.x + el.size.width);
|
|
142
|
-
maxY = Math.max(maxY, el.position.y + el.size.height);
|
|
143
|
-
});
|
|
144
|
-
const padding = 50;
|
|
145
|
-
const contentWidth = maxX - minX + padding * 2;
|
|
146
|
-
const contentHeight = maxY - minY + padding * 2;
|
|
147
|
-
const canvasWidth = window.innerWidth * 0.8;
|
|
148
|
-
const canvasHeight = window.innerHeight * 0.8;
|
|
149
|
-
const scaleX = canvasWidth / contentWidth;
|
|
150
|
-
const scaleY = canvasHeight / contentHeight;
|
|
151
|
-
const newZoom = Math.min(scaleX, scaleY, 1);
|
|
152
|
-
setZoom(newZoom);
|
|
153
|
-
}, [state.elements]);
|
|
154
|
-
React.useEffect(() => {
|
|
155
|
-
const handleKeyDown = (e) => {
|
|
156
|
-
if (e.target instanceof HTMLInputElement || e.target instanceof HTMLTextAreaElement) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
switch (e.key.toLowerCase()) {
|
|
160
|
-
case 'v':
|
|
161
|
-
setSelectedTool('select');
|
|
162
|
-
break;
|
|
163
|
-
case 'c':
|
|
164
|
-
setSelectedTool('command');
|
|
165
|
-
break;
|
|
166
|
-
case 'e':
|
|
167
|
-
setSelectedTool('event');
|
|
168
|
-
break;
|
|
169
|
-
case 'r':
|
|
170
|
-
setSelectedTool('readmodel');
|
|
171
|
-
break;
|
|
172
|
-
case 'p':
|
|
173
|
-
setSelectedTool('process');
|
|
174
|
-
break;
|
|
175
|
-
case 'delete':
|
|
176
|
-
case 'backspace':
|
|
177
|
-
if (state.selectedElementId) {
|
|
178
|
-
handleDeleteElement(state.selectedElementId);
|
|
179
|
-
}
|
|
180
|
-
else if (state.selectedConnectorId) {
|
|
181
|
-
handleDeleteConnector(state.selectedConnectorId);
|
|
182
|
-
}
|
|
183
|
-
break;
|
|
184
|
-
case '+':
|
|
185
|
-
case '=':
|
|
186
|
-
handleZoomIn();
|
|
187
|
-
break;
|
|
188
|
-
case '-':
|
|
189
|
-
case '_':
|
|
190
|
-
handleZoomOut();
|
|
191
|
-
break;
|
|
192
|
-
case '0':
|
|
193
|
-
handleZoomReset();
|
|
194
|
-
break;
|
|
195
|
-
case 'f':
|
|
196
|
-
handleFitToView();
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
window.addEventListener('keydown', handleKeyDown);
|
|
201
|
-
return () => window.removeEventListener('keydown', handleKeyDown);
|
|
202
|
-
}, [state, selectedTool, handleDeleteElement, handleDeleteConnector, handleZoomIn, handleZoomOut, handleZoomReset, handleFitToView]);
|
|
203
|
-
return (jsxs("div", { className: "event-modeling", style: { width, height }, children: [jsx(Toolbox, { selectedTool: selectedTool, onToolSelect: setSelectedTool }), jsx(Canvas, { state: state, selectedTool: selectedTool, zoom: zoom, pan: pan, onZoomChange: handleZoomChange, onPanChange: handlePanChange, onAddElement: handleAddElement, onUpdateElement: handleUpdateElement, onAddConnector: handleAddConnector, onSelectElement: handleSelectElement, onSelectConnector: handleSelectConnector }), jsx(CanvasControls, { zoom: zoom, onZoomIn: handleZoomIn, onZoomOut: handleZoomOut, onZoomReset: handleZoomReset, onFitToView: handleFitToView })] }));
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
export { EventModeling };
|
|
207
|
-
//# sourceMappingURL=EventModeling.js.map
|