@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
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface JsonSchema {
|
|
2
|
+
title?: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
$id?: string;
|
|
5
|
+
$ref?: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
format?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
10
|
+
items?: JsonSchema;
|
|
11
|
+
required?: string[];
|
|
12
|
+
definitions?: Record<string, JsonSchema>;
|
|
13
|
+
}
|
|
14
|
+
export interface JsonSchemaProperty {
|
|
15
|
+
id?: string;
|
|
16
|
+
name?: string;
|
|
17
|
+
type?: string;
|
|
18
|
+
format?: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
items?: JsonSchema;
|
|
21
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
$ref?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface NavigationItem {
|
|
26
|
+
name: string;
|
|
27
|
+
path: string[];
|
|
28
|
+
}
|
|
29
|
+
export type Json = string | number | boolean | null | Json[] | {
|
|
30
|
+
[key: string]: Json;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=JsonSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonSchema.d.ts","sourceRoot":"","sources":["../../../types/JsonSchema.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,UAAU;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAChD,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,kBAAkB;IAC/B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,IAAI,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JsonSchema.js","sourceRoot":"","sources":["../../../types/JsonSchema.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeFormat.d.ts","sourceRoot":"","sources":["../../../types/TypeFormat.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,UAAU;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,oBAAoB,EAAE,UAAU,EAc5C,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const DEFAULT_TYPE_FORMATS = [
|
|
2
|
+
{ jsonType: 'string', format: '' },
|
|
3
|
+
{ jsonType: 'string', format: 'guid' },
|
|
4
|
+
{ jsonType: 'string', format: 'date-time' },
|
|
5
|
+
{ jsonType: 'string', format: 'date' },
|
|
6
|
+
{ jsonType: 'string', format: 'time' },
|
|
7
|
+
{ jsonType: 'integer', format: '' },
|
|
8
|
+
{ jsonType: 'integer', format: 'int16' },
|
|
9
|
+
{ jsonType: 'integer', format: 'int32' },
|
|
10
|
+
{ jsonType: 'integer', format: 'int64' },
|
|
11
|
+
{ jsonType: 'number', format: '' },
|
|
12
|
+
{ jsonType: 'number', format: 'float' },
|
|
13
|
+
{ jsonType: 'number', format: 'double' },
|
|
14
|
+
{ jsonType: 'boolean', format: '' },
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
export { DEFAULT_TYPE_FORMATS };
|
|
18
|
+
//# sourceMappingURL=TypeFormat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypeFormat.js","sources":["../../../types/TypeFormat.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\nexport interface TypeFormat {\n jsonType: string;\n format: string;\n}\n\nexport const DEFAULT_TYPE_FORMATS: TypeFormat[] = [\n { jsonType: 'string', format: '' },\n { jsonType: 'string', format: 'guid' },\n { jsonType: 'string', format: 'date-time' },\n { jsonType: 'string', format: 'date' },\n { jsonType: 'string', format: 'time' },\n { jsonType: 'integer', format: '' },\n { jsonType: 'integer', format: 'int16' },\n { jsonType: 'integer', format: 'int32' },\n { jsonType: 'integer', format: 'int64' },\n { jsonType: 'number', format: '' },\n { jsonType: 'number', format: 'float' },\n { jsonType: 'number', format: 'double' },\n { jsonType: 'boolean', format: '' },\n];\n"],"names":[],"mappings":"AAQO,MAAM,oBAAoB,GAAiB;AAC9C,IAAA,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE;AAClC,IAAA,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE;AACtC,IAAA,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE;AAC3C,IAAA,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE;AACtC,IAAA,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE;AACtC,IAAA,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE;AACnC,IAAA,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE;AACxC,IAAA,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE;AACxC,IAAA,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE;AACxC,IAAA,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE;AAClC,IAAA,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE;AACvC,IAAA,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE;AACxC,IAAA,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cratis/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Cratis",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,6 +34,11 @@
|
|
|
34
34
|
"require": "./dist/cjs/CommandForm/index.js",
|
|
35
35
|
"import": "./dist/esm/CommandForm/index.js"
|
|
36
36
|
},
|
|
37
|
+
"./CommandForm/fields": {
|
|
38
|
+
"types": "./dist/esm/CommandForm/fields/index.d.ts",
|
|
39
|
+
"require": "./dist/cjs/CommandForm/fields/index.js",
|
|
40
|
+
"import": "./dist/esm/CommandForm/fields/index.js"
|
|
41
|
+
},
|
|
37
42
|
"./Common": {
|
|
38
43
|
"types": "./dist/esm/Common/index.d.ts",
|
|
39
44
|
"require": "./dist/cjs/Common/index.js",
|
|
@@ -90,11 +95,11 @@
|
|
|
90
95
|
"build-storybook": "storybook build"
|
|
91
96
|
},
|
|
92
97
|
"dependencies": {
|
|
93
|
-
"@cratis/arc": "^19.
|
|
94
|
-
"@cratis/arc.react": "^19.
|
|
95
|
-
"@cratis/arc.vite": "^19.
|
|
98
|
+
"@cratis/arc": "^19.6.1",
|
|
99
|
+
"@cratis/arc.react": "^19.6.1",
|
|
100
|
+
"@cratis/arc.vite": "^19.6.1",
|
|
96
101
|
"allotment": "1.20.5",
|
|
97
|
-
"framer-motion": "12.34.
|
|
102
|
+
"framer-motion": "12.34.3",
|
|
98
103
|
"pixi.js": "^8.16.0",
|
|
99
104
|
"primeicons": "7.0.0",
|
|
100
105
|
"primereact": "10.9.7",
|
|
@@ -103,14 +108,14 @@
|
|
|
103
108
|
"react-dom": "19.2.4",
|
|
104
109
|
"react-icons": "5.5.0",
|
|
105
110
|
"react-leaflet": "^5.0.0",
|
|
106
|
-
"react-router-dom": "7.13.
|
|
111
|
+
"react-router-dom": "7.13.1",
|
|
107
112
|
"reflect-metadata": "0.2.2",
|
|
108
113
|
"ts-deepmerge": "7.0.3",
|
|
109
114
|
"tsyringe": "4.10.0",
|
|
110
115
|
"usehooks-ts": "3.1.1"
|
|
111
116
|
},
|
|
112
117
|
"devDependencies": {
|
|
113
|
-
"storybook": "^10.2.
|
|
118
|
+
"storybook": "^10.2.12"
|
|
114
119
|
},
|
|
115
120
|
"peerDependencies": {
|
|
116
121
|
"react": "^18.0.0 || ^19.0.0"
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var CommandFormFields = require('./CommandFormFields.js');
|
|
5
|
-
var commands = require('@cratis/arc.react/commands');
|
|
6
|
-
var React = require('react');
|
|
7
|
-
var panel = require('primereact/panel');
|
|
8
|
-
|
|
9
|
-
const CommandFormContext = React.createContext(undefined);
|
|
10
|
-
const useCommandFormContext = () => {
|
|
11
|
-
const context = React.useContext(CommandFormContext);
|
|
12
|
-
if (!context) {
|
|
13
|
-
throw new Error('useCommandFormContext must be used within a CommandForm');
|
|
14
|
-
}
|
|
15
|
-
return context;
|
|
16
|
-
};
|
|
17
|
-
const useCommandInstance = () => {
|
|
18
|
-
const { commandInstance } = useCommandFormContext();
|
|
19
|
-
return commandInstance;
|
|
20
|
-
};
|
|
21
|
-
const useSetCommandResult = () => {
|
|
22
|
-
const { setCommandResult } = useCommandFormContext();
|
|
23
|
-
return setCommandResult;
|
|
24
|
-
};
|
|
25
|
-
const CommandFormFieldsWrapper = (props) => {
|
|
26
|
-
React.Children.forEach(props.children, child => {
|
|
27
|
-
if (React.isValidElement(child)) {
|
|
28
|
-
const component = child.type;
|
|
29
|
-
if (component.displayName !== 'CommandFormField') {
|
|
30
|
-
throw new Error(`Only CommandFormField components are allowed as children of CommandForm.Fields. Got: ${component.displayName || component.name || 'Unknown'}`);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
35
|
-
};
|
|
36
|
-
CommandFormFieldsWrapper.displayName = 'CommandFormFieldsWrapper';
|
|
37
|
-
const getCommandFormFields = (props) => {
|
|
38
|
-
if (!props.children) {
|
|
39
|
-
return { fieldsOrColumns: [], otherChildren: [], initialValuesFromFields: {} };
|
|
40
|
-
}
|
|
41
|
-
let fields = [];
|
|
42
|
-
const columns = [];
|
|
43
|
-
let hasColumns = false;
|
|
44
|
-
const otherChildren = [];
|
|
45
|
-
let initialValuesFromFields = {};
|
|
46
|
-
const extractInitialValue = (field) => {
|
|
47
|
-
const fieldProps = field.props;
|
|
48
|
-
if (fieldProps.currentValue !== undefined && fieldProps.value) {
|
|
49
|
-
const propertyAccessor = fieldProps.value;
|
|
50
|
-
const propertyName = getPropertyNameFromAccessor(propertyAccessor);
|
|
51
|
-
if (propertyName) {
|
|
52
|
-
initialValuesFromFields = { ...initialValuesFromFields, [propertyName]: fieldProps.currentValue };
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
React.Children.toArray(props.children).forEach(child => {
|
|
57
|
-
if (!React.isValidElement(child)) {
|
|
58
|
-
otherChildren.push(child);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
const component = child.type;
|
|
62
|
-
if (component.displayName === 'CommandFormColumn') {
|
|
63
|
-
hasColumns = true;
|
|
64
|
-
const childProps = child.props;
|
|
65
|
-
const columnFields = React.Children.toArray(childProps.children).filter(child => {
|
|
66
|
-
if (React.isValidElement(child)) {
|
|
67
|
-
const comp = child.type;
|
|
68
|
-
if (comp.displayName === 'CommandFormField') {
|
|
69
|
-
extractInitialValue(child);
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return false;
|
|
74
|
-
});
|
|
75
|
-
columns.push({ fields: columnFields });
|
|
76
|
-
}
|
|
77
|
-
else if (component.displayName === 'CommandFormField') {
|
|
78
|
-
extractInitialValue(child);
|
|
79
|
-
fields.push(child);
|
|
80
|
-
}
|
|
81
|
-
else if (component === CommandFormFieldsWrapper || component.displayName === 'CommandFormFieldsWrapper') {
|
|
82
|
-
const childProps = child.props;
|
|
83
|
-
const relevantChildren = React.Children.toArray(childProps.children).filter(child => {
|
|
84
|
-
if (React.isValidElement(child)) {
|
|
85
|
-
const component = child.type;
|
|
86
|
-
if (component.displayName === 'CommandFormField') {
|
|
87
|
-
extractInitialValue(child);
|
|
88
|
-
return true;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return false;
|
|
92
|
-
});
|
|
93
|
-
fields = [...fields, ...relevantChildren];
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
otherChildren.push(child);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
return { fieldsOrColumns: hasColumns ? columns : fields, otherChildren, initialValuesFromFields };
|
|
100
|
-
};
|
|
101
|
-
function getPropertyNameFromAccessor(accessor) {
|
|
102
|
-
if (typeof accessor !== 'function')
|
|
103
|
-
return '';
|
|
104
|
-
const fnStr = accessor.toString();
|
|
105
|
-
const match = fnStr.match(/\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);
|
|
106
|
-
return match ? match[1] : '';
|
|
107
|
-
}
|
|
108
|
-
const CommandFormComponent = (props) => {
|
|
109
|
-
const { fieldsOrColumns, otherChildren, initialValuesFromFields } = React.useMemo(() => getCommandFormFields(props), [props.children]);
|
|
110
|
-
const valuesFromCurrentValues = React.useMemo(() => {
|
|
111
|
-
if (!props.currentValues)
|
|
112
|
-
return {};
|
|
113
|
-
const tempCommand = new props.command();
|
|
114
|
-
const commandProperties = (tempCommand.properties || []);
|
|
115
|
-
const extracted = {};
|
|
116
|
-
commandProperties.forEach((propertyName) => {
|
|
117
|
-
if (props.currentValues[propertyName] !== undefined) {
|
|
118
|
-
extracted[propertyName] = props.currentValues[propertyName];
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
return extracted;
|
|
122
|
-
}, [props.currentValues, props.command]);
|
|
123
|
-
const mergedInitialValues = React.useMemo(() => ({
|
|
124
|
-
...valuesFromCurrentValues,
|
|
125
|
-
...initialValuesFromFields,
|
|
126
|
-
...props.initialValues
|
|
127
|
-
}), [valuesFromCurrentValues, initialValuesFromFields, props.initialValues]);
|
|
128
|
-
const useCommandResult = commands.useCommand(props.command, mergedInitialValues);
|
|
129
|
-
const commandInstance = useCommandResult[0];
|
|
130
|
-
const setCommandValues = useCommandResult[1];
|
|
131
|
-
const [commandResult, setCommandResult] = React.useState(undefined);
|
|
132
|
-
const [fieldValidities, setFieldValidities] = React.useState({});
|
|
133
|
-
const [customFieldErrors, setCustomFieldErrors] = React.useState({});
|
|
134
|
-
React.useEffect(() => {
|
|
135
|
-
if (mergedInitialValues && Object.keys(mergedInitialValues).length > 0) {
|
|
136
|
-
setCommandValues(mergedInitialValues);
|
|
137
|
-
}
|
|
138
|
-
}, [mergedInitialValues, setCommandValues]);
|
|
139
|
-
const isValid = Object.values(fieldValidities).every(valid => valid);
|
|
140
|
-
const setFieldValidity = React.useCallback((fieldName, isFieldValid) => {
|
|
141
|
-
setFieldValidities(prev => ({ ...prev, [fieldName]: isFieldValid }));
|
|
142
|
-
}, []);
|
|
143
|
-
const setCustomFieldError = React.useCallback((fieldName, error) => {
|
|
144
|
-
setCustomFieldErrors(prev => {
|
|
145
|
-
if (error === undefined) {
|
|
146
|
-
const newErrors = { ...prev };
|
|
147
|
-
delete newErrors[fieldName];
|
|
148
|
-
return newErrors;
|
|
149
|
-
}
|
|
150
|
-
return { ...prev, [fieldName]: error };
|
|
151
|
-
});
|
|
152
|
-
}, []);
|
|
153
|
-
const getFieldError = (propertyName) => {
|
|
154
|
-
if (customFieldErrors[propertyName]) {
|
|
155
|
-
return customFieldErrors[propertyName];
|
|
156
|
-
}
|
|
157
|
-
if (!commandResult || !commandResult.validationResults) {
|
|
158
|
-
return undefined;
|
|
159
|
-
}
|
|
160
|
-
for (const validationResult of commandResult.validationResults) {
|
|
161
|
-
if (validationResult.members && validationResult.members.includes(propertyName)) {
|
|
162
|
-
return validationResult.message;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return undefined;
|
|
166
|
-
};
|
|
167
|
-
const exceptionMessages = commandResult?.exceptionMessages || [];
|
|
168
|
-
const hasColumns = fieldsOrColumns.length > 0 && 'fields' in fieldsOrColumns[0];
|
|
169
|
-
return (jsxRuntime.jsxs(CommandFormContext.Provider, { value: { command: props.command, commandInstance, setCommandValues, commandResult, setCommandResult, getFieldError, isValid, setFieldValidity, onFieldValidate: props.onFieldValidate, onFieldChange: props.onFieldChange, onBeforeExecute: props.onBeforeExecute, customFieldErrors, setCustomFieldError }, children: [jsxRuntime.jsx(CommandFormFields.CommandFormFields, { fields: hasColumns ? undefined : fieldsOrColumns, columns: hasColumns ? fieldsOrColumns : undefined }), exceptionMessages.length > 0 && (jsxRuntime.jsx("div", { className: "card flex flex-row gap-3 mt-3", children: jsxRuntime.jsx(panel.Panel, { header: "The server responded with", className: "w-full", children: jsxRuntime.jsx("ul", { children: exceptionMessages.map((msg, idx) => (jsxRuntime.jsx("li", { children: msg }, idx))) }) }) })), otherChildren] }));
|
|
170
|
-
};
|
|
171
|
-
const CommandFormColumnComponent = (_props) => {
|
|
172
|
-
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
173
|
-
};
|
|
174
|
-
CommandFormColumnComponent.displayName = 'CommandFormColumn';
|
|
175
|
-
CommandFormComponent.Fields = CommandFormFieldsWrapper;
|
|
176
|
-
CommandFormComponent.Column = CommandFormColumnComponent;
|
|
177
|
-
const CommandForm = CommandFormComponent;
|
|
178
|
-
|
|
179
|
-
exports.CommandForm = CommandForm;
|
|
180
|
-
exports.useCommandFormContext = useCommandFormContext;
|
|
181
|
-
exports.useCommandInstance = useCommandInstance;
|
|
182
|
-
exports.useSetCommandResult = useSetCommandResult;
|
|
183
|
-
//# sourceMappingURL=CommandForm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CommandForm.js","sources":["../../../CommandForm/CommandForm.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 { CommandFormFields, ColumnInfo } from './CommandFormFields';\nimport { Constructor } from '@cratis/fundamentals';\nimport { useCommand, SetCommandValues } from '@cratis/arc.react/commands';\nimport { ICommandResult } from '@cratis/arc/commands';\nimport { Command } from '@cratis/arc/commands';\nimport React, { createContext, useContext, useMemo, useState, useCallback } from 'react';\nimport type { CommandFormFieldProps } from './CommandFormField';\nimport { Panel } from 'primereact/panel';\n\nexport type BeforeExecuteCallback<TCommand> = (values: TCommand) => TCommand;\n\nexport interface CommandFormProps<TCommand extends object> {\n command: Constructor<TCommand>;\n initialValues?: Partial<TCommand>;\n currentValues?: Partial<TCommand> | undefined;\n onFieldValidate?: (command: TCommand, fieldName: string, oldValue: unknown, newValue: unknown) => string | undefined;\n onFieldChange?: (command: TCommand, fieldName: string, oldValue: unknown, newValue: unknown) => void;\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n children?: React.ReactNode;\n}\n\ninterface CommandFormContextValue<TCommand> {\n command: Constructor<TCommand>;\n commandInstance: TCommand;\n setCommandValues: SetCommandValues<TCommand>;\n commandResult?: ICommandResult<unknown>;\n setCommandResult: (result: ICommandResult<unknown>) => void;\n getFieldError: (propertyName: string) => string | undefined;\n isValid: boolean;\n setFieldValidity: (fieldName: string, isValid: boolean) => void;\n onFieldValidate?: (command: TCommand, fieldName: string, oldValue: unknown, newValue: unknown) => string | undefined;\n onFieldChange?: (command: TCommand, fieldName: string, oldValue: unknown, newValue: unknown) => void;\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n customFieldErrors: Record<string, string>;\n setCustomFieldError: (fieldName: string, error: string | undefined) => void;\n}\n\nconst CommandFormContext = createContext<CommandFormContextValue<unknown> | undefined>(undefined);\n\nexport const useCommandFormContext = <TCommand,>() => {\n const context = useContext(CommandFormContext);\n if (!context) {\n throw new Error('useCommandFormContext must be used within a CommandForm');\n }\n return context as CommandFormContextValue<TCommand>;\n};\n\n// Hook to get just the command instance for easier access\nexport const useCommandInstance = <TCommand = unknown>() => {\n const { commandInstance } = useCommandFormContext<TCommand>();\n return commandInstance as TCommand;\n};\n\n// Hook to get setCommandResult for easier access\nexport const useSetCommandResult = () => {\n const { setCommandResult } = useCommandFormContext();\n return setCommandResult;\n};\n\nconst CommandFormFieldsWrapper = (props: { children: React.ReactNode }) => {\n React.Children.forEach(props.children, child => {\n if (React.isValidElement(child)) {\n const component = child.type as React.ComponentType<unknown>;\n if (component.displayName !== 'CommandFormField') {\n throw new Error(`Only CommandFormField components are allowed as children of CommandForm.Fields. Got: ${component.displayName || component.name || 'Unknown'}`);\n }\n }\n });\n\n return <></>;\n};\n\nCommandFormFieldsWrapper.displayName = 'CommandFormFieldsWrapper';\n\nconst getCommandFormFields = <TCommand,>(props: { children?: React.ReactNode }): { fieldsOrColumns: React.ReactElement[] | ColumnInfo[], otherChildren: React.ReactNode[], initialValuesFromFields: Partial<TCommand> } => {\n if (!props.children) {\n return { fieldsOrColumns: [], otherChildren: [], initialValuesFromFields: {} };\n }\n let fields: React.ReactElement<CommandFormFieldProps<unknown>>[] = [];\n const columns: ColumnInfo[] = [];\n let hasColumns = false;\n const otherChildren: React.ReactNode[] = [];\n let initialValuesFromFields: Partial<TCommand> = {};\n\n const extractInitialValue = (field: React.ReactElement) => {\n const fieldProps = field.props as Record<string, unknown>;\n if (fieldProps.currentValue !== undefined && fieldProps.value) {\n const propertyAccessor = fieldProps.value;\n const propertyName = getPropertyNameFromAccessor(propertyAccessor);\n if (propertyName) {\n initialValuesFromFields = { ...initialValuesFromFields, [propertyName]: fieldProps.currentValue } as Partial<TCommand>;\n }\n }\n };\n\n React.Children.toArray(props.children).forEach(child => {\n if (!React.isValidElement(child)) {\n otherChildren.push(child);\n return;\n }\n\n const component = child.type as React.ComponentType<unknown>;\n\n // Check if child is a CommandFormColumn\n if (component.displayName === 'CommandFormColumn') {\n hasColumns = true;\n const childProps = child.props as { children?: React.ReactNode };\n const columnFields = React.Children.toArray(childProps.children).filter(child => {\n if (React.isValidElement(child)) {\n const comp = child.type as React.ComponentType<unknown>;\n if (comp.displayName === 'CommandFormField') {\n extractInitialValue(child as React.ReactElement);\n return true;\n }\n }\n return false;\n }) as React.ReactElement[];\n columns.push({ fields: columnFields as React.ReactElement<CommandFormFieldProps<unknown>>[] });\n }\n // Check if child is a CommandFormField (direct child)\n else if (component.displayName === 'CommandFormField') {\n extractInitialValue(child as React.ReactElement);\n fields.push(child as React.ReactElement<CommandFormFieldProps<unknown>>);\n }\n // Check if child is Fields wrapper (backwards compatibility)\n else if (component === CommandFormFieldsWrapper || component.displayName === 'CommandFormFieldsWrapper') {\n const childProps = child.props as { children: React.ReactNode };\n const relevantChildren = React.Children.toArray(childProps.children).filter(child => {\n if (React.isValidElement(child)) {\n const component = child.type as React.ComponentType<unknown>;\n if (component.displayName === 'CommandFormField') {\n extractInitialValue(child as React.ReactElement);\n return true;\n }\n }\n return false;\n }) as React.ReactElement[];\n fields = [...fields, ...(relevantChildren as React.ReactElement<CommandFormFieldProps<unknown>>[])];\n }\n // Everything else is not a field, keep it as other children\n else {\n otherChildren.push(child);\n }\n });\n\n return { fieldsOrColumns: hasColumns ? columns : fields, otherChildren, initialValuesFromFields };\n};\n\n// Helper function to extract property name from accessor function\nfunction getPropertyNameFromAccessor<T = unknown>(accessor: ((obj: T) => unknown) | unknown): string {\n if (typeof accessor !== 'function') return '';\n const fnStr = accessor.toString();\n const match = fnStr.match(/\\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);\n return match ? match[1] : '';\n}\n\nconst CommandFormComponent = <TCommand extends object = object>(props: CommandFormProps<TCommand>) => {\n const { fieldsOrColumns, otherChildren, initialValuesFromFields } = useMemo(() => getCommandFormFields<TCommand>(props), [props.children]);\n\n // Extract matching properties from currentValues\n const valuesFromCurrentValues = useMemo(() => {\n if (!props.currentValues) return {};\n\n const tempCommand = new props.command();\n const commandProperties = ((tempCommand as Record<string, unknown>).properties || []) as string[];\n const extracted: Partial<TCommand> = {};\n\n commandProperties.forEach((propertyName: string) => {\n if ((props.currentValues as Record<string, unknown>)[propertyName] !== undefined) {\n (extracted as Record<string, unknown>)[propertyName] = (props.currentValues as Record<string, unknown>)[propertyName];\n }\n });\n\n return extracted;\n }, [props.currentValues, props.command]);\n\n // Merge initialValues prop with values extracted from field currentValue props and currentValues\n const mergedInitialValues = useMemo(() => ({\n ...valuesFromCurrentValues,\n ...initialValuesFromFields,\n ...props.initialValues\n }), [valuesFromCurrentValues, initialValuesFromFields, props.initialValues]);\n\n // useCommand returns [instance, setter] for the typed command. Provide generics so commandInstance is TCommand.\n // Using type assertion through unknown to work around generic constraint mismatch\n const useCommandResult = useCommand(props.command as unknown as Constructor<Command<Partial<TCommand>, object>>, mergedInitialValues);\n const commandInstance = useCommandResult[0] as unknown as TCommand;\n const setCommandValues = useCommandResult[1] as SetCommandValues<TCommand>;\n const [commandResult, setCommandResult] = useState<ICommandResult<unknown> | undefined>(undefined);\n const [fieldValidities, setFieldValidities] = useState<Record<string, boolean>>({});\n const [customFieldErrors, setCustomFieldErrors] = useState<Record<string, string>>({});\n\n // Update command values when mergedInitialValues changes (e.g., when data loads asynchronously)\n React.useEffect(() => {\n if (mergedInitialValues && Object.keys(mergedInitialValues).length > 0) {\n setCommandValues(mergedInitialValues as TCommand);\n }\n }, [mergedInitialValues, setCommandValues]);\n\n const isValid = Object.values(fieldValidities).every(valid => valid);\n\n const setFieldValidity = useCallback((fieldName: string, isFieldValid: boolean) => {\n setFieldValidities(prev => ({ ...prev, [fieldName]: isFieldValid }));\n }, []);\n\n const setCustomFieldError = useCallback((fieldName: string, error: string | undefined) => {\n setCustomFieldErrors(prev => {\n if (error === undefined) {\n const newErrors = { ...prev };\n delete newErrors[fieldName];\n return newErrors;\n }\n return { ...prev, [fieldName]: error };\n });\n }, []);\n\n const getFieldError = (propertyName: string): string | undefined => {\n // Check custom field errors first\n if (customFieldErrors[propertyName]) {\n return customFieldErrors[propertyName];\n }\n\n if (!commandResult || !commandResult.validationResults) {\n return undefined;\n }\n\n for (const validationResult of commandResult.validationResults) {\n if (validationResult.members && validationResult.members.includes(propertyName)) {\n return validationResult.message;\n }\n }\n\n return undefined;\n };\n\n const exceptionMessages = commandResult?.exceptionMessages || [];\n const hasColumns = fieldsOrColumns.length > 0 && 'fields' in fieldsOrColumns[0];\n\n return (\n <CommandFormContext.Provider value={{ command: props.command, commandInstance, setCommandValues, commandResult, setCommandResult, getFieldError, isValid, setFieldValidity, onFieldValidate: props.onFieldValidate, onFieldChange: props.onFieldChange, onBeforeExecute: props.onBeforeExecute, customFieldErrors, setCustomFieldError }}>\n <CommandFormFields fields={hasColumns ? undefined : (fieldsOrColumns as React.ReactElement<CommandFormFieldProps<unknown>>[])} columns={hasColumns ? fieldsOrColumns as ColumnInfo[] : undefined} />\n {exceptionMessages.length > 0 && (\n <div className=\"card flex flex-row gap-3 mt-3\">\n <Panel header=\"The server responded with\" className=\"w-full\">\n <ul>\n {exceptionMessages.map((msg, idx) => (\n <li key={idx}>{msg}</li>\n ))}\n </ul>\n </Panel>\n </div>\n )}\n {otherChildren}\n </CommandFormContext.Provider>\n );\n};\n\nconst CommandFormColumnComponent = (_props: { children: React.ReactNode }) => {\n void _props;\n return <></>;\n};\n\nCommandFormColumnComponent.displayName = 'CommandFormColumn';\n\nCommandFormComponent.Fields = CommandFormFieldsWrapper;\nCommandFormComponent.Column = CommandFormColumnComponent;\n\nexport const CommandForm = CommandFormComponent;\n"],"names":["createContext","useContext","_jsx","useMemo","useCommand","useState","useCallback","_jsxs","CommandFormFields","Panel"],"mappings":";;;;;;;;AAwCA,MAAM,kBAAkB,GAAGA,mBAAa,CAA+C,SAAS,CAAC;AAE1F,MAAM,qBAAqB,GAAG,MAAgB;AACjD,IAAA,MAAM,OAAO,GAAGC,gBAAU,CAAC,kBAAkB,CAAC;IAC9C,IAAI,CAAC,OAAO,EAAE;AACV,QAAA,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC;IAC9E;AACA,IAAA,OAAO,OAA4C;AACvD;AAGO,MAAM,kBAAkB,GAAG,MAAyB;AACvD,IAAA,MAAM,EAAE,eAAe,EAAE,GAAG,qBAAqB,EAAY;AAC7D,IAAA,OAAO,eAA2B;AACtC;AAGO,MAAM,mBAAmB,GAAG,MAAK;AACpC,IAAA,MAAM,EAAE,gBAAgB,EAAE,GAAG,qBAAqB,EAAE;AACpD,IAAA,OAAO,gBAAgB;AAC3B;AAEA,MAAM,wBAAwB,GAAG,CAAC,KAAoC,KAAI;IACtE,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,IAAG;AAC3C,QAAA,IAAI,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;AAC7B,YAAA,MAAM,SAAS,GAAG,KAAK,CAAC,IAAoC;AAC5D,YAAA,IAAI,SAA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CAAC;AAED,0BAA0B,CAAC,WAAW,GAAG,mBAAmB;AAE5D,oBAAoB,CAAC,MAAM,GAAG,wBAAwB;AACtD,oBAAoB,CAAC,MAAM,GAAG,0BAA0B;AAEjD,MAAM,WAAW,GAAG;;;;;;;"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
|
|
5
|
-
const CommandFormField = (_props) => {
|
|
6
|
-
return jsxRuntime.jsx(jsxRuntime.Fragment, {});
|
|
7
|
-
};
|
|
8
|
-
CommandFormField.displayName = 'CommandFormField';
|
|
9
|
-
|
|
10
|
-
exports.CommandFormField = CommandFormField;
|
|
11
|
-
//# sourceMappingURL=CommandFormField.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CommandFormField.js","sources":["../../../CommandForm/CommandFormField.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 { PropertyAccessor } from '@cratis/fundamentals';\n\nexport interface CommandFormFieldProps<TCommand = unknown> {\n icon?: React.ReactElement;\n /** Accessor function that selects a property on the command, e.g. c => c.name */\n value?: PropertyAccessor<TCommand>;\n /** Current value for the property (injected by CommandFormFields) */\n currentValue?: unknown;\n /** Called when the field value changes (injected by CommandFormFields) */\n onValueChange?: (value: unknown) => void;\n onChange?: (value: unknown) => void;\n required?: boolean;\n title?: string;\n description?: string;\n propertyDescriptor?: unknown;\n fieldName?: string;\n}\n\nexport const CommandFormField = <TCommand,>(_props?: CommandFormFieldProps<TCommand>) => {\n void _props;\n return <></>;\n};\n\nCommandFormField.displayName = 'CommandFormField';\n"],"names":["_jsx"],"mappings":";;;;AAqBO,MAAM,gBAAgB,GAAG,CAAY,MAAwC,KAAI;AAEpF,IAAA,OAAOA,uCAAK;AAChB;AAEA,gBAAgB,CAAC,WAAW,GAAG,kBAAkB;;;;"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var CommandForm = require('./CommandForm.js');
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var tooltip = require('primereact/tooltip');
|
|
7
|
-
|
|
8
|
-
const CommandFormFieldWrapper = ({ field, index }) => {
|
|
9
|
-
const context = CommandForm.useCommandFormContext();
|
|
10
|
-
const fieldProps = field.props;
|
|
11
|
-
const propertyAccessor = fieldProps.value;
|
|
12
|
-
const propertyName = propertyAccessor ? getPropertyName(propertyAccessor) : '';
|
|
13
|
-
const currentValue = propertyName ? context.commandInstance?.[propertyName] : undefined;
|
|
14
|
-
const errorMessage = propertyName ? context.getFieldError(propertyName) : undefined;
|
|
15
|
-
const propertyDescriptor = propertyName && context.commandInstance?.propertyDescriptors
|
|
16
|
-
? context.commandInstance.propertyDescriptors.find((pd) => pd.name === propertyName)
|
|
17
|
-
: undefined;
|
|
18
|
-
const clonedField = React.cloneElement(field, {
|
|
19
|
-
...fieldProps,
|
|
20
|
-
currentValue,
|
|
21
|
-
propertyDescriptor,
|
|
22
|
-
fieldName: propertyName,
|
|
23
|
-
onValueChange: (value) => {
|
|
24
|
-
if (propertyName) {
|
|
25
|
-
const oldValue = currentValue;
|
|
26
|
-
context.setCommandValues({ [propertyName]: value });
|
|
27
|
-
if (context.commandInstance && typeof context.commandInstance.validate === 'function') {
|
|
28
|
-
const validationResult = context.commandInstance.validate();
|
|
29
|
-
if (validationResult) {
|
|
30
|
-
context.setCommandResult(validationResult);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (context.onFieldValidate) {
|
|
34
|
-
const validationError = context.onFieldValidate(context.commandInstance, propertyName, oldValue, value);
|
|
35
|
-
context.setCustomFieldError(propertyName, validationError);
|
|
36
|
-
}
|
|
37
|
-
if (context.onFieldChange) {
|
|
38
|
-
context.onFieldChange(context.commandInstance, propertyName, oldValue, value);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
fieldProps.onChange?.(value);
|
|
42
|
-
},
|
|
43
|
-
required: fieldProps.required ?? true,
|
|
44
|
-
invalid: !!errorMessage
|
|
45
|
-
});
|
|
46
|
-
const tooltipId = fieldProps.description ? `tooltip-${propertyName}-${index}` : undefined;
|
|
47
|
-
return (jsxRuntime.jsxs("div", { className: "w-full", children: [jsxRuntime.jsxs("div", { className: "p-inputgroup w-full", children: [fieldProps.description && (jsxRuntime.jsx(tooltip.Tooltip, { target: `.${tooltipId}`, content: fieldProps.description })), fieldProps.icon && (jsxRuntime.jsx("span", { className: `p-inputgroup-addon ${tooltipId || ''}`, children: fieldProps.icon })), clonedField] }), errorMessage && (jsxRuntime.jsx("small", { className: "p-error block mt-1", children: errorMessage }))] }));
|
|
48
|
-
};
|
|
49
|
-
const CommandFormFields = (props) => {
|
|
50
|
-
const { fields, columns } = props;
|
|
51
|
-
if (columns && columns.length > 0) {
|
|
52
|
-
return (jsxRuntime.jsx("div", { className: "card flex flex-column md:flex-row gap-3", children: columns.map((column, columnIndex) => (jsxRuntime.jsx("div", { className: "flex flex-column gap-3 flex-1", children: column.fields.map((field, index) => {
|
|
53
|
-
const fieldProps = field.props;
|
|
54
|
-
const propertyAccessor = fieldProps.value;
|
|
55
|
-
const propertyName = propertyAccessor ? getPropertyName(propertyAccessor) : `field-${columnIndex}-${index}`;
|
|
56
|
-
return (jsxRuntime.jsx(CommandFormFieldWrapper, { field: field, index: index }, propertyName));
|
|
57
|
-
}) }, `column-${columnIndex}`))) }));
|
|
58
|
-
}
|
|
59
|
-
return (jsxRuntime.jsx("div", { className: "flex flex-col gap-4 w-full", children: (fields || []).map((field, index) => {
|
|
60
|
-
const fieldProps = field.props;
|
|
61
|
-
const propertyAccessor = fieldProps.value;
|
|
62
|
-
const propertyName = propertyAccessor ? getPropertyName(propertyAccessor) : `field-${index}`;
|
|
63
|
-
return (jsxRuntime.jsx(CommandFormFieldWrapper, { field: field, index: index }, propertyName));
|
|
64
|
-
}) }));
|
|
65
|
-
};
|
|
66
|
-
function getPropertyName(accessor) {
|
|
67
|
-
const fnStr = accessor.toString();
|
|
68
|
-
const match = fnStr.match(/\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);
|
|
69
|
-
return match ? match[1] : '';
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
exports.CommandFormFields = CommandFormFields;
|
|
73
|
-
//# sourceMappingURL=CommandFormFields.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CommandFormFields.js","sources":["../../../CommandForm/CommandFormFields.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 { useCommandFormContext } from './CommandForm';\nimport React from 'react';\nimport { Tooltip } from 'primereact/tooltip';\nimport type { CommandFormFieldProps } from './CommandFormField';\nimport type { ICommandResult } from '@cratis/arc/commands';\n\nexport interface ColumnInfo {\n fields: React.ReactElement<CommandFormFieldProps<unknown>>[];\n}\n\nexport interface CommandFormFieldsProps {\n fields?: React.ReactElement<CommandFormFieldProps<unknown>>[];\n columns?: ColumnInfo[];\n}\n\n// Separate component for each field to prevent re-rendering all fields\nconst CommandFormFieldWrapper = ({ field, index }: { field: React.ReactElement<CommandFormFieldProps<unknown>>; index: number }) => {\n const context = useCommandFormContext<unknown>();\n const fieldProps = field.props as CommandFormFieldProps<unknown>;\n const propertyAccessor = fieldProps.value;\n\n // Get the property name from the accessor function\n const propertyName = propertyAccessor ? getPropertyName(propertyAccessor) : '';\n\n // Get the current value from the command instance\n const currentValue = propertyName ? (context.commandInstance as Record<string, unknown>)?.[propertyName] : undefined;\n\n // Get the error message for this field, if any\n const errorMessage = propertyName ? context.getFieldError(propertyName) : undefined;\n\n // Get the property descriptor for this field from the command instance\n const propertyDescriptor = propertyName && (context.commandInstance as Record<string, unknown>)?.propertyDescriptors\n ? ((context.commandInstance as Record<string, unknown>).propertyDescriptors as Array<Record<string, unknown>>).find((pd: Record<string, unknown>) => pd.name === propertyName)\n : undefined;\n\n // Clone the field element with the current value and onChange handler\n const clonedField = React.cloneElement(field as React.ReactElement, {\n ...fieldProps,\n currentValue,\n propertyDescriptor,\n fieldName: propertyName,\n onValueChange: (value: unknown) => {\n if (propertyName) {\n const oldValue = currentValue;\n\n // Update the command value\n context.setCommandValues({ [propertyName]: value } as Record<string, unknown>);\n\n // Call validate() on the command instance and store the result\n if (context.commandInstance && typeof (context.commandInstance as Record<string, unknown>).validate === 'function') {\n const validationResult = ((context.commandInstance as Record<string, unknown>).validate as () => ICommandResult<unknown>)();\n if (validationResult) {\n context.setCommandResult(validationResult);\n }\n }\n\n // Call custom field validator if provided\n if (context.onFieldValidate) {\n const validationError = context.onFieldValidate(context.commandInstance as Record<string, unknown>, propertyName, oldValue, value);\n context.setCustomFieldError(propertyName, validationError);\n }\n\n // Call field change callback if provided\n if (context.onFieldChange) {\n context.onFieldChange(context.commandInstance as Record<string, unknown>, propertyName, oldValue, value);\n }\n }\n fieldProps.onChange?.(value as unknown);\n },\n required: fieldProps.required ?? true,\n invalid: !!errorMessage\n } as Record<string, unknown>);\n\n const tooltipId = fieldProps.description ? `tooltip-${propertyName}-${index}` : undefined;\n\n return (\n <div className=\"w-full\">\n <div className=\"p-inputgroup w-full\">\n {fieldProps.description && (\n <Tooltip target={`.${tooltipId}`} content={fieldProps.description} />\n )}\n {fieldProps.icon && (\n <span className={`p-inputgroup-addon ${tooltipId || ''}`}>\n {fieldProps.icon}\n </span>\n )}\n {clonedField}\n </div>\n {errorMessage && (\n <small className=\"p-error block mt-1\">{errorMessage}</small>\n )}\n </div>\n );\n};\n\nexport const CommandFormFields = (props: CommandFormFieldsProps) => {\n const { fields, columns } = props;\n\n // Render columns if provided\n if (columns && columns.length > 0) {\n return (\n <div className=\"card flex flex-column md:flex-row gap-3\">\n {columns.map((column, columnIndex) => (\n <div key={`column-${columnIndex}`} className=\"flex flex-column gap-3 flex-1\">\n {column.fields.map((field, index) => {\n const fieldProps = field.props as CommandFormFieldProps<unknown>;\n const propertyAccessor = fieldProps.value;\n const propertyName = propertyAccessor ? getPropertyName(propertyAccessor) : `field-${columnIndex}-${index}`;\n\n return (\n <CommandFormFieldWrapper\n key={propertyName}\n field={field}\n index={index}\n />\n );\n })}\n </div>\n ))}\n </div>\n );\n }\n\n // Render fields (single column layout)\n return (\n <div className=\"flex flex-col gap-4 w-full\">\n {(fields || []).map((field, index) => {\n const fieldProps = field.props as CommandFormFieldProps<unknown>;\n const propertyAccessor = fieldProps.value;\n const propertyName = propertyAccessor ? getPropertyName(propertyAccessor) : `field-${index}`;\n\n return (\n <CommandFormFieldWrapper\n key={propertyName}\n field={field}\n index={index}\n />\n );\n })}\n </div>\n );\n};\n\n// Helper function to extract property name from accessor function\nfunction getPropertyName<T>(accessor: (obj: T) => 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"],"names":["useCommandFormContext","_jsxs","_jsx","Tooltip"],"mappings":";;;;;;;AAmBA,MAAM,uBAAuB,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAgF,KAAI;AAC/H,IAAA,MAAM,OAAO,GAAGA,iCAAqB,EAAW;AAChD,IAAA,MAAM,UAAU,GAAG,KAAK,CAAC,KAAuC;AAChE,IAAA,MAAM,gBAAgB,GAAG,UAAU,CAAC,KAAK;AAGzC,IAAA,MAAM,YAAY,GAAG,gBAAgB,GAAG,eAAe,CAAC,gBAAgB,CAAC,GAAG,EAAE;AAG9E,IAAA,MAAM,YAAY,GAAG,YAAY,GAAI,OAAO,CAAC,eAA2C,GAAG,YAAY,CAAC,GAAG,SAAS;AAGpH,IAAA,MAAM,YAAY,GAAG,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC,YAAY,CAAC,GAAG,SAAS;IAGnF,MAAM,kBAAkB,GAAG,YAAY,IAAK,OAAO,CAAC,eAA2C,EAAE;AAC7F,UAAI,OA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|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var CommandForm = require('./CommandForm.js');
|
|
5
|
-
|
|
6
|
-
const ValidationMessage = (props) => {
|
|
7
|
-
const context = CommandForm.useCommandFormContext();
|
|
8
|
-
const propertyAccessor = props.value;
|
|
9
|
-
const getPropertyName = (accessor) => {
|
|
10
|
-
const fnStr = accessor.toString();
|
|
11
|
-
const match = fnStr.match(/\.([a-zA-Z_$][a-zA-Z0-9_$]*)/);
|
|
12
|
-
return match ? match[1] : '';
|
|
13
|
-
};
|
|
14
|
-
const propertyName = getPropertyName(propertyAccessor);
|
|
15
|
-
const errorMessage = propertyName ? context.getFieldError(propertyName) : undefined;
|
|
16
|
-
if (!errorMessage) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
return (jsxRuntime.jsx("small", { className: "p-error block mt-1", children: errorMessage }));
|
|
20
|
-
};
|
|
21
|
-
ValidationMessage.displayName = 'ValidationMessage';
|
|
22
|
-
|
|
23
|
-
exports.ValidationMessage = ValidationMessage;
|
|
24
|
-
//# 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":["useCommandFormContext","_jsx"],"mappings":";;;;;AAUO,MAAM,iBAAiB,GAAG,CAAY,KAAuC,KAAI;AACpF,IAAA,MAAM,OAAO,GAAGA,iCAAqB,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,QACIC,0BAAO,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAAE,YAAY,EAAA,CAAS;AAEpE;AAEA,iBAAiB,CAAC,WAAW,GAAG,mBAAmB;;;;"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var React = require('react');
|
|
5
|
-
var CommandForm = require('./CommandForm.js');
|
|
6
|
-
|
|
7
|
-
function asCommandFormField(component, config) {
|
|
8
|
-
const { defaultValue, extractValue } = config;
|
|
9
|
-
const Component = typeof component === 'function' && !component.prototype?.render
|
|
10
|
-
? component
|
|
11
|
-
: component;
|
|
12
|
-
const WrappedField = (props) => {
|
|
13
|
-
const { currentValue, onValueChange, fieldName, required = true, ...componentProps } = props;
|
|
14
|
-
const [localValue, setLocalValue] = React.useState(currentValue ?? defaultValue);
|
|
15
|
-
const { getFieldError, customFieldErrors } = CommandForm.useCommandFormContext();
|
|
16
|
-
const serverError = fieldName ? getFieldError(fieldName) : undefined;
|
|
17
|
-
const customError = fieldName ? customFieldErrors[fieldName] : undefined;
|
|
18
|
-
const errors = [];
|
|
19
|
-
if (serverError)
|
|
20
|
-
errors.push(serverError);
|
|
21
|
-
if (customError)
|
|
22
|
-
errors.push(customError);
|
|
23
|
-
const isInvalid = errors.length > 0;
|
|
24
|
-
React.useEffect(() => {
|
|
25
|
-
setLocalValue(currentValue ?? defaultValue);
|
|
26
|
-
}, [currentValue]);
|
|
27
|
-
const handleChange = (valueOrEvent) => {
|
|
28
|
-
const newValue = extractValue ? extractValue(valueOrEvent) : valueOrEvent;
|
|
29
|
-
setLocalValue(newValue);
|
|
30
|
-
onValueChange?.(newValue);
|
|
31
|
-
};
|
|
32
|
-
const wrappedProps = {
|
|
33
|
-
...componentProps,
|
|
34
|
-
value: localValue,
|
|
35
|
-
onChange: handleChange,
|
|
36
|
-
invalid: isInvalid,
|
|
37
|
-
required,
|
|
38
|
-
errors
|
|
39
|
-
};
|
|
40
|
-
return jsxRuntime.jsx(Component, { ...wrappedProps });
|
|
41
|
-
};
|
|
42
|
-
WrappedField.displayName = 'CommandFormField';
|
|
43
|
-
return WrappedField;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
exports.asCommandFormField = asCommandFormField;
|
|
47
|
-
//# 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":["useState","useCommandFormContext","useEffect","_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;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