@cratis/components 0.1.18 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -0
- package/dist/cjs/CommandDialog/CommandDialog.js +14 -25
- 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/Common/ErrorBoundary.js +26 -0
- package/dist/cjs/Common/ErrorBoundary.js.map +1 -0
- package/dist/cjs/Common/FormElement.js +10 -0
- package/dist/cjs/Common/FormElement.js.map +1 -0
- package/dist/cjs/Common/index.js +12 -0
- package/dist/cjs/Common/index.js.map +1 -0
- 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/ObjectContentEditor/index.js.map +1 -0
- 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/PivotViewer/components/PivotCanvas.js.map +1 -1
- package/dist/cjs/PivotViewer/components/PivotViewerMain.js.map +1 -1
- package/dist/cjs/PivotViewer/components/pivot/groups.js +15 -15
- package/dist/cjs/PivotViewer/components/pivot/groups.js.map +1 -1
- package/dist/cjs/PivotViewer/components/pivot/sprites.js +2 -2
- package/dist/cjs/PivotViewer/components/pivot/sprites.js.map +1 -1
- package/dist/cjs/PivotViewer/types.js.map +1 -1
- 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/TimeMachine/TimeMachine.js +0 -3
- package/dist/cjs/TimeMachine/TimeMachine.js.map +1 -1
- package/dist/cjs/index.js +20 -12
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/types/TypeFormat.js +20 -0
- package/dist/cjs/types/TypeFormat.js.map +1 -0
- package/dist/esm/CommandDialog/CommandDialog.d.ts +1 -1
- package/dist/esm/CommandDialog/CommandDialog.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.js +15 -26
- package/dist/esm/CommandDialog/CommandDialog.js.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.stories.d.ts +1 -0
- package/dist/esm/CommandDialog/CommandDialog.stories.d.ts.map +1 -1
- package/dist/esm/CommandDialog/CommandDialog.stories.js +57 -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.js +7 -4
- package/dist/esm/Common/ErrorBoundary.js.map +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.js +7 -4
- package/dist/esm/Common/FormElement.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/Common/index.js +4 -4
- package/dist/esm/Common/index.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 +33 -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 +55 -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 +31 -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/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/PivotViewer/components/PivotCanvas.d.ts +2 -2
- package/dist/esm/PivotViewer/components/PivotCanvas.d.ts.map +1 -1
- package/dist/esm/PivotViewer/components/PivotCanvas.js.map +1 -1
- package/dist/esm/PivotViewer/components/PivotViewerMain.d.ts +2 -2
- package/dist/esm/PivotViewer/components/PivotViewerMain.d.ts.map +1 -1
- package/dist/esm/PivotViewer/components/PivotViewerMain.js.map +1 -1
- package/dist/esm/PivotViewer/components/pivot/groups.d.ts.map +1 -1
- package/dist/esm/PivotViewer/components/pivot/groups.js +2 -2
- package/dist/esm/PivotViewer/components/pivot/groups.js.map +1 -1
- package/dist/esm/PivotViewer/components/pivot/sprites.d.ts +4 -4
- package/dist/esm/PivotViewer/components/pivot/sprites.d.ts.map +1 -1
- package/dist/esm/PivotViewer/components/pivot/sprites.js +2 -2
- package/dist/esm/PivotViewer/components/pivot/sprites.js.map +1 -1
- package/dist/esm/PivotViewer/types.d.ts +2 -2
- package/dist/esm/PivotViewer/types.d.ts.map +1 -1
- package/dist/esm/PivotViewer/types.js.map +1 -1
- 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/SchemaEditor/index.js.map +1 -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.js +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 +7 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +20 -12
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/package.json +3 -0
- 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 +41 -78
- 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/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/README.md
CHANGED
|
@@ -1 +1,84 @@
|
|
|
1
1
|
# Cratis Components
|
|
2
|
+
|
|
3
|
+
A collection of React components for building modern applications with Cratis.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
### Minimum Versions
|
|
8
|
+
|
|
9
|
+
- TypeScript: 4.7+
|
|
10
|
+
- React: 18.0+ or 19.0+
|
|
11
|
+
- Node.js: 16+ (for development)
|
|
12
|
+
|
|
13
|
+
### TypeScript Configuration
|
|
14
|
+
|
|
15
|
+
This package is compatible with all modern TypeScript `moduleResolution` strategies:
|
|
16
|
+
|
|
17
|
+
- ✅ `"bundler"` (recommended for Vite, esbuild, webpack 5+)
|
|
18
|
+
- ✅ `"node16"` / `"nodenext"` (for Node.js projects)
|
|
19
|
+
- ✅ `"node"` (legacy, but supported)
|
|
20
|
+
|
|
21
|
+
The package provides dual CommonJS and ES Module builds with proper conditional exports for optimal module resolution and tree-shaking.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install @cratis/components
|
|
27
|
+
# or
|
|
28
|
+
yarn add @cratis/components
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
### Importing Components
|
|
34
|
+
|
|
35
|
+
You can import components using subpath imports for better tree-shaking:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
// Import specific component modules
|
|
39
|
+
import { TimeMachine } from '@cratis/components/TimeMachine';
|
|
40
|
+
import { DataPage } from '@cratis/components/DataPage';
|
|
41
|
+
import { CommandForm } from '@cratis/components/CommandForm';
|
|
42
|
+
|
|
43
|
+
// Or import from the main entry point
|
|
44
|
+
import { TimeMachine, DataPage } from '@cratis/components';
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Available Subpath Exports
|
|
48
|
+
|
|
49
|
+
- `@cratis/components/CommandDialog`
|
|
50
|
+
- `@cratis/components/CommandForm`
|
|
51
|
+
- `@cratis/components/Common`
|
|
52
|
+
- `@cratis/components/DataPage`
|
|
53
|
+
- `@cratis/components/DataTables`
|
|
54
|
+
- `@cratis/components/Dialogs`
|
|
55
|
+
- `@cratis/components/Dropdown`
|
|
56
|
+
- `@cratis/components/EventModeling`
|
|
57
|
+
- `@cratis/components/PivotViewer`
|
|
58
|
+
- `@cratis/components/TimeMachine`
|
|
59
|
+
|
|
60
|
+
## Troubleshooting
|
|
61
|
+
|
|
62
|
+
### Module Resolution Errors
|
|
63
|
+
|
|
64
|
+
If you encounter errors like:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
Cannot find module '@cratis/components/TimeMachine' or its corresponding type declarations.
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Solution:** Ensure you're using the correct case-sensitive import paths (e.g., `TimeMachine`, not `timeMachine`).
|
|
71
|
+
|
|
72
|
+
If using TypeScript 4.7+, try updating your `tsconfig.json`:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"compilerOptions": {
|
|
77
|
+
"moduleResolution": "bundler" // or "node16" / "nodenext"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Import Errors
|
|
83
|
+
|
|
84
|
+
Ensure you're using the correct import paths. The package uses case-sensitive paths that match the actual component names.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var dialogs = require('@cratis/arc.react/dialogs');
|
|
5
|
+
var Dialog = require('../Dialogs/Dialog.js');
|
|
6
6
|
var React = require('react');
|
|
7
|
-
var
|
|
7
|
+
var commands = require('@cratis/arc.react/commands');
|
|
8
8
|
|
|
9
9
|
const CommandDialogContext = React.createContext(undefined);
|
|
10
10
|
const useCommandDialogContext = () => {
|
|
@@ -14,42 +14,31 @@ const useCommandDialogContext = () => {
|
|
|
14
14
|
}
|
|
15
15
|
return context;
|
|
16
16
|
};
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const { onSuccess: onConfirm, onCancel, confirmLabel, cancelLabel, confirmIcon, cancelIcon } = useCommandDialogContext();
|
|
17
|
+
const CommandDialogWrapper = ({ header, visible, width, confirmLabel, cancelLabel, onConfirm, onCancel, onBeforeExecute, children }) => {
|
|
18
|
+
const { isValid, setCommandValues, setCommandResult } = commands.useCommandFormContext();
|
|
19
|
+
const commandInstance = commands.useCommandInstance();
|
|
21
20
|
const handleConfirm = async () => {
|
|
22
21
|
if (onBeforeExecute) {
|
|
23
|
-
const transformedValues = onBeforeExecute(
|
|
22
|
+
const transformedValues = onBeforeExecute(commandInstance);
|
|
24
23
|
setCommandValues(transformedValues);
|
|
25
24
|
}
|
|
26
|
-
const result = await
|
|
25
|
+
const result = await commandInstance.execute();
|
|
27
26
|
if (result.isSuccess) {
|
|
28
27
|
await onConfirm(result);
|
|
28
|
+
return true;
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
31
|
setCommandResult(result);
|
|
32
|
+
return false;
|
|
32
33
|
}
|
|
33
34
|
};
|
|
34
|
-
|
|
35
|
-
onCancel();
|
|
36
|
-
};
|
|
37
|
-
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", { className: "card flex flex-wrap justify-content-center gap-3 mt-8", children: [jsxRuntime.jsx(button.Button, { label: confirmLabel, icon: confirmIcon, onClick: handleConfirm, disabled: !isValid }), jsxRuntime.jsx(button.Button, { label: cancelLabel, icon: cancelIcon, severity: 'secondary', onClick: handleCancel })] }) }));
|
|
35
|
+
return (jsxRuntime.jsx(Dialog.Dialog, { title: header, visible: visible, width: width, onConfirm: handleConfirm, onCancel: onCancel, buttons: dialogs.DialogButtons.OkCancel, okLabel: confirmLabel, cancelLabel: cancelLabel, isValid: isValid, children: children }));
|
|
38
36
|
};
|
|
39
37
|
const CommandDialogFieldsWrapper = (props) => {
|
|
40
|
-
|
|
41
|
-
if (React.isValidElement(child)) {
|
|
42
|
-
const component = child.type;
|
|
43
|
-
if (component.displayName !== 'CommandFormField') {
|
|
44
|
-
throw new Error(`Only CommandFormField components are allowed as children of CommandDialog.Fields. Got: ${component.displayName || component.name || 'Unknown'}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
return (jsxRuntime.jsx(CommandForm.CommandForm.Fields, { children: props.children }));
|
|
38
|
+
return (jsxRuntime.jsx(commands.CommandForm.Fields, { children: props.children }));
|
|
49
39
|
};
|
|
50
40
|
const CommandDialogComponent = (props) => {
|
|
51
|
-
const { command, initialValues, currentValues, visible, header, confirmLabel = 'Confirm', cancelLabel = 'Cancel', confirmIcon = 'pi pi-check', cancelIcon = 'pi pi-times', onConfirm, onCancel, onFieldValidate, onFieldChange, onBeforeExecute, children,
|
|
52
|
-
const dialogStyle = width ? { ...style, width } : style;
|
|
41
|
+
const { command, initialValues, currentValues, visible, header, confirmLabel = 'Confirm', cancelLabel = 'Cancel', confirmIcon = 'pi pi-check', cancelIcon = 'pi pi-times', onConfirm, onCancel, onFieldValidate, onFieldChange, onBeforeExecute, children, width = '50vw' } = props;
|
|
53
42
|
const contextValue = {
|
|
54
43
|
onSuccess: onConfirm,
|
|
55
44
|
onCancel,
|
|
@@ -61,7 +50,7 @@ const CommandDialogComponent = (props) => {
|
|
|
61
50
|
onFieldChange,
|
|
62
51
|
onBeforeExecute
|
|
63
52
|
};
|
|
64
|
-
return (jsxRuntime.jsx(
|
|
53
|
+
return (jsxRuntime.jsx(CommandDialogContext.Provider, { value: contextValue, children: jsxRuntime.jsx(commands.CommandForm, { command: command, initialValues: initialValues, currentValues: currentValues, onFieldValidate: onFieldValidate, onFieldChange: onFieldChange, onBeforeExecute: onBeforeExecute, children: jsxRuntime.jsx(CommandDialogWrapper, { header: header, visible: visible, width: width, confirmLabel: confirmLabel, cancelLabel: cancelLabel, onConfirm: onConfirm, onCancel: onCancel, onBeforeExecute: onBeforeExecute, children: children }) }) }));
|
|
65
54
|
};
|
|
66
55
|
CommandDialogComponent.Fields = CommandDialogFieldsWrapper;
|
|
67
56
|
const CommandDialog = CommandDialogComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandDialog.js","sources":["../../../CommandDialog/CommandDialog.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 { ICommandResult } from '@cratis/arc/commands';\nimport { Constructor } from '@cratis/fundamentals';\nimport {
|
|
1
|
+
{"version":3,"file":"CommandDialog.js","sources":["../../../CommandDialog/CommandDialog.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 { ICommandResult } from '@cratis/arc/commands';\nimport { Constructor } from '@cratis/fundamentals';\nimport { DialogButtons } from '@cratis/arc.react/dialogs';\nimport { Dialog } from '../Dialogs/Dialog';\nimport React, { createContext, useContext } from 'react';\nimport { \n CommandForm, \n useCommandFormContext, \n useCommandInstance\n} from '@cratis/arc.react/commands';\n\n// Local type definitions\nexport type BeforeExecuteCallback<TCommand> = (values: TCommand) => TCommand;\n\nexport type FieldValidator<TCommand> = (command: TCommand, fieldName: string, oldValue: unknown, newValue: unknown) => string | undefined;\nexport type FieldChangeCallback<TCommand> = (command: TCommand, fieldName: string, oldValue: unknown, newValue: unknown) => void;\n\nexport interface CommandDialogProps<TCommand, TResponse = object> {\n command: Constructor<TCommand>;\n initialValues?: Partial<TCommand>;\n currentValues?: Partial<TCommand> | undefined;\n visible: boolean;\n header: string;\n confirmLabel?: string;\n cancelLabel?: string;\n confirmIcon?: string;\n cancelIcon?: string;\n onConfirm: (result: ICommandResult<TResponse>) => void | Promise<void>;\n onCancel: () => void;\n onFieldValidate?: FieldValidator<TCommand>;\n onFieldChange?: FieldChangeCallback<TCommand>;\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n children?: React.ReactNode;\n style?: React.CSSProperties;\n width?: string;\n}\n\ninterface CommandDialogContextValue<TCommand = unknown> {\n onSuccess: (result: ICommandResult<unknown>) => void | Promise<void>;\n onCancel: () => void;\n confirmLabel: string;\n cancelLabel: string;\n confirmIcon: string;\n cancelIcon: string;\n onFieldValidate?: FieldValidator<TCommand>;\n onFieldChange?: FieldChangeCallback<TCommand>;\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n}\n\nconst CommandDialogContext = createContext<CommandDialogContextValue<unknown> | undefined>(undefined);\n\nexport const useCommandDialogContext = <TCommand = unknown,>() => {\n const context = useContext(CommandDialogContext);\n if (!context) {\n throw new Error('useCommandDialogContext must be used within a CommandDialog');\n }\n return context as CommandDialogContextValue<TCommand>;\n};\n\nconst CommandDialogWrapper = <TCommand extends object>({\n header,\n visible,\n width,\n confirmLabel,\n cancelLabel,\n onConfirm,\n onCancel,\n onBeforeExecute,\n children\n}: {\n header: string;\n visible: boolean;\n width: string;\n confirmLabel: string;\n cancelLabel: string;\n onConfirm: (result: ICommandResult<unknown>) => void | Promise<void>;\n onCancel: () => void;\n onBeforeExecute?: BeforeExecuteCallback<TCommand>;\n children: React.ReactNode;\n}) => {\n const { isValid, setCommandValues, setCommandResult } = useCommandFormContext<TCommand>();\n const commandInstance = useCommandInstance<TCommand>();\n\n const handleConfirm = async () => {\n if (onBeforeExecute) {\n const transformedValues = onBeforeExecute(commandInstance);\n setCommandValues(transformedValues);\n }\n const result = await (commandInstance as unknown as { execute: () => Promise<ICommandResult<unknown>> }).execute();\n if (result.isSuccess) {\n await onConfirm(result);\n return true;\n } else {\n setCommandResult(result);\n return false;\n }\n };\n\n return (\n <Dialog\n title={header}\n visible={visible}\n width={width}\n onConfirm={handleConfirm}\n onCancel={onCancel}\n buttons={DialogButtons.OkCancel}\n okLabel={confirmLabel}\n cancelLabel={cancelLabel}\n isValid={isValid}\n >\n {children}\n </Dialog>\n );\n};\n\nconst CommandDialogFieldsWrapper = (props: { children: React.ReactNode }) => {\n return (\n <CommandForm.Fields>\n {props.children}\n </CommandForm.Fields>\n );\n};\n\nconst CommandDialogComponent = <TCommand extends object = object, TResponse = object>(props: CommandDialogProps<TCommand, TResponse>) => {\n const {\n command,\n initialValues,\n currentValues,\n visible,\n header,\n confirmLabel = 'Confirm',\n cancelLabel = 'Cancel',\n confirmIcon = 'pi pi-check',\n cancelIcon = 'pi pi-times',\n onConfirm,\n onCancel,\n onFieldValidate,\n onFieldChange,\n onBeforeExecute,\n children,\n width = '50vw'\n } = props;\n\n const contextValue: CommandDialogContextValue<TCommand> = {\n onSuccess: onConfirm,\n onCancel,\n confirmLabel,\n cancelLabel,\n confirmIcon,\n cancelIcon,\n onFieldValidate,\n onFieldChange,\n onBeforeExecute\n };\n\n return (\n <CommandDialogContext.Provider value={contextValue}>\n <CommandForm\n command={command}\n initialValues={initialValues}\n currentValues={currentValues}\n onFieldValidate={onFieldValidate}\n onFieldChange={onFieldChange}\n onBeforeExecute={onBeforeExecute}>\n <CommandDialogWrapper\n header={header}\n visible={visible}\n width={width}\n confirmLabel={confirmLabel}\n cancelLabel={cancelLabel}\n onConfirm={onConfirm}\n onCancel={onCancel}\n onBeforeExecute={onBeforeExecute}\n >\n {children}\n </CommandDialogWrapper>\n </CommandForm>\n </CommandDialogContext.Provider>\n );\n};\n\nCommandDialogComponent.Fields = CommandDialogFieldsWrapper;\n\nexport const CommandDialog = CommandDialogComponent;\n"],"names":["createContext","useContext","useCommandFormContext","useCommandInstance","_jsx","Dialog","DialogButtons","CommandForm"],"mappings":";;;;;;;;AAoDA,MAAM,oBAAoB,GAAGA,mBAAa,CAAiD,SAAS,CAAC;AAE9F,MAAM,uBAAuB,GAAG,MAA0B;AAC7D,IAAA,MAAM,OAAO,GAAGC,gBAAU,CAAC,oBAAoB,CAAC;IAChD,IAAI,CAAC,OAAO,EAAE;AACV,QAAA,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC;IAClF;AACA,IAAA,OAAO,OAA8C;AACzD;AAEA,MAAM,oBAAoB,GAAG,CAA0B,EACnD,MAAM,EACN,OAAO,EACP,KAAK,EACL,YAAY,EACZ,WAAW,EACX,SAAS,EACT,QAAQ,EACR,eAAe,EACf,QAAQ,EAWX,KAAI;IACD,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,GAAGC,8BAAqB,EAAY;AACzF,IAAA,MAAM,eAAe,GAAGC,2BAAkB,EAAY;AAEtD,IAAA,MAAM,aAAa,GAAG,YAAW;QAC7B,IAAI,eAAe,EAAE;AACjB,YAAA,MAAM,iBAAiB,GAAG,eAAe,CAAC,eAAe,CAAC;YAC1D,gBAAgB,CAAC,iBAAiB,CAAC;QACvC;AACA,QAAA,MAAM,MAAM,GAAG,MAAO,eAAkF,CAAC,OAAO,EAAE;AAClH,QAAA,IAAI,MAAM,CAAC,SAAS,EAAE;AAClB,YAAA,MAAM,SAAS,CAAC,MAAM,CAAC;AACvB,YAAA,OAAO,IAAI;QACf;aAAO;YACH,gBAAgB,CAAC,MAAM,CAAC;AACxB,YAAA,OAAO,KAAK;QAChB;AACJ,IAAA,CAAC;IAED,QACIC,eAACC,aAAM,EAAA,EACH,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAEC,qBAAa,CAAC,QAAQ,EAC/B,OAAO,EAAE,YAAY,EACrB,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,EAAA,QAAA,EAEf,QAAQ,EAAA,CACJ;AAEjB,CAAC;AAED,MAAM,0BAA0B,GAAG,CAAC,KAAoC,KAAI;IACxE,QACIF,cAAA,CAACG,oBAAW,CAAC,MAAM,EAAA,EAAA,QAAA,EACd,KAAK,CAAC,QAAQ,EAAA,CACE;AAE7B,CAAC;AAED,MAAM,sBAAsB,GAAG,CAAuD,KAA8C,KAAI;IACpI,MAAM,EACF,OAAO,EACP,aAAa,EACb,aAAa,EACb,OAAO,EACP,MAAM,EACN,YAAY,GAAG,SAAS,EACxB,WAAW,GAAG,QAAQ,EACtB,WAAW,GAAG,aAAa,EAC3B,UAAU,GAAG,aAAa,EAC1B,SAAS,EACT,QAAQ,EACR,eAAe,EACf,aAAa,EACb,eAAe,EACf,QAAQ,EACR,KAAK,GAAG,MAAM,EACjB,GAAG,KAAK;AAET,IAAA,MAAM,YAAY,GAAwC;AACtD,QAAA,SAAS,EAAE,SAAS;QACpB,QAAQ;QACR,YAAY;QACZ,WAAW;QACX,WAAW;QACX,UAAU;QACV,eAAe;QACf,aAAa;QACb;KACH;AAED,IAAA,QACIH,cAAA,CAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,EAAA,QAAA,EAC9CA,eAACG,oBAAW,EAAA,EACR,OAAO,EAAE,OAAO,EAChB,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,aAAa,EAC5B,eAAe,EAAE,eAAe,EAAA,QAAA,EAChCH,cAAA,CAAC,oBAAoB,EAAA,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,WAAW,EACxB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,QAAQ,EAClB,eAAe,EAAE,eAAe,EAAA,QAAA,EAE/B,QAAQ,GACU,EAAA,CACb,EAAA,CACc;AAExC,CAAC;AAED,sBAAsB,CAAC,MAAM,GAAG,0BAA0B;AAEnD,MAAM,aAAa,GAAG;;;;;"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var checkbox = require('primereact/checkbox');
|
|
5
|
-
var
|
|
5
|
+
var commands = require('@cratis/arc.react/commands');
|
|
6
6
|
|
|
7
|
-
const CheckboxField =
|
|
7
|
+
const CheckboxField = commands.asCommandFormField((props) => (jsxRuntime.jsxs("div", { className: "flex align-items-center", children: [jsxRuntime.jsx(checkbox.Checkbox, { checked: props.value, onChange: props.onChange, invalid: props.invalid }), props.label && jsxRuntime.jsx("label", { className: "ml-2", children: props.label })] })), {
|
|
8
8
|
defaultValue: false,
|
|
9
9
|
extractValue: (e) => e.checked
|
|
10
10
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxField.js","sources":["../../../../CommandForm/fields/CheckboxField.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 { Checkbox } from 'primereact/checkbox';\nimport React from 'react';\nimport { asCommandFormField, WrappedFieldProps } from '
|
|
1
|
+
{"version":3,"file":"CheckboxField.js","sources":["../../../../CommandForm/fields/CheckboxField.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 { Checkbox } from 'primereact/checkbox';\nimport React from 'react';\nimport { asCommandFormField, WrappedFieldProps } from '@cratis/arc.react/commands';\n\ninterface CheckboxFieldComponentProps extends WrappedFieldProps<boolean> {\n label?: string;\n}\n\nexport const CheckboxField = asCommandFormField<CheckboxFieldComponentProps>(\n (props) => (\n <div className=\"flex align-items-center\">\n <Checkbox\n checked={props.value}\n onChange={props.onChange}\n invalid={props.invalid}\n />\n {props.label && <label className=\"ml-2\">{props.label}</label>}\n </div>\n ),\n {\n defaultValue: false,\n extractValue: (e: { checked: boolean }) => e.checked\n }\n);\n"],"names":["asCommandFormField","_jsxs","_jsx","Checkbox"],"mappings":";;;;;;AAWO,MAAM,aAAa,GAAGA,2BAAkB,CAC3C,CAAC,KAAK,MACFC,yBAAK,SAAS,EAAC,yBAAyB,EAAA,QAAA,EAAA,CACpCC,cAAA,CAACC,iBAAQ,EAAA,EACL,OAAO,EAAE,KAAK,CAAC,KAAK,EACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,OAAO,EAAE,KAAK,CAAC,OAAO,EAAA,CACxB,EACD,KAAK,CAAC,KAAK,IAAID,cAAA,CAAA,OAAA,EAAA,EAAO,SAAS,EAAC,MAAM,EAAA,QAAA,EAAE,KAAK,CAAC,KAAK,EAAA,CAAS,CAAA,EAAA,CAC3D,CACT,EACD;AACI,IAAA,YAAY,EAAE,KAAK;IACnB,YAAY,EAAE,CAAC,CAAuB,KAAK,CAAC,CAAC;AAChD,CAAA;;;;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var
|
|
4
|
+
var dropdown = require('primereact/dropdown');
|
|
5
|
+
var commands = require('@cratis/arc.react/commands');
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
-
const SelectField = asCommandFormField.asCommandFormField(SelectComponent, {
|
|
7
|
+
const DropdownField = commands.asCommandFormField((props) => (jsxRuntime.jsx(dropdown.Dropdown, { value: props.value, onChange: (e) => props.onChange(e.value), options: props.options, optionValue: props.optionValue, optionLabel: props.optionLabel, placeholder: props.placeholder, invalid: props.invalid, className: "w-full" })), {
|
|
8
8
|
defaultValue: '',
|
|
9
|
-
extractValue: (e) => e
|
|
9
|
+
extractValue: (e) => e
|
|
10
10
|
});
|
|
11
11
|
|
|
12
|
-
exports.
|
|
12
|
+
exports.DropdownField = DropdownField;
|
|
13
13
|
//# sourceMappingURL=DropdownField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownField.js","sources":["../../../../CommandForm/fields/DropdownField.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 { asCommandFormField, WrappedFieldProps } from '
|
|
1
|
+
{"version":3,"file":"DropdownField.js","sources":["../../../../CommandForm/fields/DropdownField.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 { Dropdown } from 'primereact/dropdown';\nimport React from 'react';\nimport { asCommandFormField, WrappedFieldProps } from '@cratis/arc.react/commands';\n\ninterface DropdownFieldComponentProps extends WrappedFieldProps<string | number> {\n options: Array<{ [key: string]: unknown }>;\n optionValue: string;\n optionLabel: string;\n placeholder?: string;\n}\n\nexport const DropdownField = asCommandFormField<DropdownFieldComponentProps>(\n (props) => (\n <Dropdown\n value={props.value}\n onChange={(e) => props.onChange(e.value)}\n options={props.options}\n optionValue={props.optionValue}\n optionLabel={props.optionLabel}\n placeholder={props.placeholder}\n invalid={props.invalid}\n className=\"w-full\"\n />\n ),\n {\n defaultValue: '',\n extractValue: (e: unknown) => e as string | number\n }\n);\n"],"names":["asCommandFormField","_jsx","Dropdown"],"mappings":";;;;;;AAcO,MAAM,aAAa,GAAGA,2BAAkB,CAC3C,CAAC,KAAK,MACFC,cAAA,CAACC,iBAAQ,IACL,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,QAAQ,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EACxC,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,SAAS,EAAC,QAAQ,EAAA,CACpB,CACL,EACD;AACI,IAAA,YAAY,EAAE,EAAE;AAChB,IAAA,YAAY,EAAE,CAAC,CAAU,KAAK;AACjC,CAAA;;;;"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var inputtext = require('primereact/inputtext');
|
|
5
|
-
var
|
|
5
|
+
var commands = require('@cratis/arc.react/commands');
|
|
6
6
|
|
|
7
|
-
const InputTextField =
|
|
7
|
+
const InputTextField = commands.asCommandFormField((props) => (jsxRuntime.jsx(inputtext.InputText, { type: props.type || 'text', value: props.value, onChange: props.onChange, invalid: props.invalid, placeholder: props.placeholder, className: "w-full" })), {
|
|
8
8
|
defaultValue: '',
|
|
9
9
|
extractValue: (e) => e.target.value
|
|
10
10
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputTextField.js","sources":["../../../../CommandForm/fields/InputTextField.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 { InputText } from 'primereact/inputtext';\nimport React from 'react';\nimport { asCommandFormField, WrappedFieldProps } from '
|
|
1
|
+
{"version":3,"file":"InputTextField.js","sources":["../../../../CommandForm/fields/InputTextField.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 { InputText } from 'primereact/inputtext';\nimport React from 'react';\nimport { asCommandFormField, WrappedFieldProps } from '@cratis/arc.react/commands';\n\ninterface InputTextComponentProps extends WrappedFieldProps<string> {\n type?: 'text' | 'email' | 'password' | 'color' | 'date' | 'datetime-local' | 'time' | 'url' | 'tel' | 'search';\n placeholder?: string;\n}\n\nexport const InputTextField = asCommandFormField<InputTextComponentProps>(\n (props) => (\n <InputText\n type={props.type || 'text'}\n value={props.value}\n onChange={props.onChange}\n invalid={props.invalid}\n placeholder={props.placeholder}\n className=\"w-full\"\n />\n ),\n {\n defaultValue: '',\n extractValue: (e: React.ChangeEvent<HTMLInputElement>) => e.target.value\n }\n);\n"],"names":["asCommandFormField","_jsx","InputText"],"mappings":";;;;;;AAYO,MAAM,cAAc,GAAGA,2BAAkB,CAC5C,CAAC,KAAK,MACFC,eAACC,mBAAS,EAAA,EACN,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,MAAM,EAC1B,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,SAAS,EAAC,QAAQ,EAAA,CACpB,CACL,EACD;AACI,IAAA,YAAY,EAAE,EAAE;IAChB,YAAY,EAAE,CAAC,CAAsC,KAAK,CAAC,CAAC,MAAM,CAAC;AACtE,CAAA;;;;"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var inputnumber = require('primereact/inputnumber');
|
|
5
|
-
var
|
|
5
|
+
var commands = require('@cratis/arc.react/commands');
|
|
6
6
|
|
|
7
|
-
const NumberField =
|
|
7
|
+
const NumberField = commands.asCommandFormField((props) => (jsxRuntime.jsx(inputnumber.InputNumber, { value: props.value, onValueChange: (e) => props.onChange(e.value ?? 0), invalid: props.invalid, placeholder: props.placeholder, min: props.min, max: props.max, step: props.step, className: "w-full" })), {
|
|
8
8
|
defaultValue: 0,
|
|
9
9
|
extractValue: (e) => (typeof e === 'number' ? e : 0)
|
|
10
10
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberField.js","sources":["../../../../CommandForm/fields/NumberField.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 { InputNumber } from 'primereact/inputnumber';\nimport React from 'react';\nimport { asCommandFormField, WrappedFieldProps } from '
|
|
1
|
+
{"version":3,"file":"NumberField.js","sources":["../../../../CommandForm/fields/NumberField.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 { InputNumber } from 'primereact/inputnumber';\nimport React from 'react';\nimport { asCommandFormField, WrappedFieldProps } from '@cratis/arc.react/commands';\n\ninterface NumberFieldComponentProps extends WrappedFieldProps<number> {\n placeholder?: string;\n min?: number;\n max?: number;\n step?: number;\n}\n\nexport const NumberField = asCommandFormField<NumberFieldComponentProps>(\n (props) => (\n <InputNumber\n value={props.value}\n onValueChange={(e) => props.onChange(e.value ?? 0)}\n invalid={props.invalid}\n placeholder={props.placeholder}\n min={props.min}\n max={props.max}\n step={props.step}\n className=\"w-full\"\n />\n ),\n {\n defaultValue: 0,\n extractValue: (e: unknown) => (typeof e === 'number' ? e : 0)\n }\n);\n"],"names":["asCommandFormField","_jsx","InputNumber"],"mappings":";;;;;;AAcO,MAAM,WAAW,GAAGA,2BAAkB,CACzC,CAAC,KAAK,MACFC,cAAA,CAACC,uBAAW,IACR,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,aAAa,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,EAClD,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,GAAG,EAAE,KAAK,CAAC,GAAG,EACd,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,SAAS,EAAC,QAAQ,EAAA,CACpB,CACL,EACD;AACI,IAAA,YAAY,EAAE,CAAC;AACf,IAAA,YAAY,EAAE,CAAC,CAAU,MAAM,OAAO,CAAC,KAAK,QAAQ,GAAG,CAAC,GAAG,CAAC;AAC/D,CAAA;;;;"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
-
var
|
|
4
|
+
var slider = require('primereact/slider');
|
|
5
|
+
var commands = require('@cratis/arc.react/commands');
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
-
const min = props.min ?? 0;
|
|
8
|
-
const max = props.max ?? 100;
|
|
9
|
-
const step = props.step ?? 1;
|
|
10
|
-
return (jsxRuntime.jsxs("div", { className: "w-full flex items-center gap-4 p-3 border border-gray-300 rounded-md", children: [jsxRuntime.jsx("input", { type: "range", value: props.value, onChange: props.onChange, min: min, max: max, step: step, required: props.required, className: "flex-1" }), jsxRuntime.jsx("span", { className: "min-w-[3rem] text-right font-semibold", children: props.value })] }));
|
|
11
|
-
}, {
|
|
7
|
+
const SliderField = commands.asCommandFormField((props) => (jsxRuntime.jsxs("div", { className: "w-full", children: [jsxRuntime.jsx(slider.Slider, { value: props.value, onChange: (e) => props.onChange(e.value), min: props.min ?? 0, max: props.max ?? 100, step: props.step ?? 1, className: "w-full" }), jsxRuntime.jsx("div", { className: "text-center mt-2", children: jsxRuntime.jsx("span", { className: "font-semibold", children: props.value }) })] })), {
|
|
12
8
|
defaultValue: 0,
|
|
13
|
-
extractValue: (e) =>
|
|
9
|
+
extractValue: (e) => (typeof e === 'number' ? e : 0)
|
|
14
10
|
});
|
|
15
11
|
|
|
16
|
-
exports.
|
|
12
|
+
exports.SliderField = SliderField;
|
|
17
13
|
//# sourceMappingURL=SliderField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderField.js","sources":["../../../../CommandForm/fields/SliderField.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 { asCommandFormField, WrappedFieldProps } from '
|
|
1
|
+
{"version":3,"file":"SliderField.js","sources":["../../../../CommandForm/fields/SliderField.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 { Slider } from 'primereact/slider';\nimport React from 'react';\nimport { asCommandFormField, WrappedFieldProps } from '@cratis/arc.react/commands';\n\ninterface SliderFieldComponentProps extends WrappedFieldProps<number> {\n min?: number;\n max?: number;\n step?: number;\n}\n\nexport const SliderField = asCommandFormField<SliderFieldComponentProps>(\n (props) => (\n <div className=\"w-full\">\n <Slider\n value={props.value}\n onChange={(e) => props.onChange(e.value)}\n min={props.min ?? 0}\n max={props.max ?? 100}\n step={props.step ?? 1}\n className=\"w-full\"\n />\n <div className=\"text-center mt-2\">\n <span className=\"font-semibold\">{props.value}</span>\n </div>\n </div>\n ),\n {\n defaultValue: 0,\n extractValue: (e: unknown) => (typeof e === 'number' ? e : 0)\n }\n);\n"],"names":["asCommandFormField","_jsxs","_jsx","Slider"],"mappings":";;;;;;AAaO,MAAM,WAAW,GAAGA,2BAAkB,CACzC,CAAC,KAAK,MACFC,yBAAK,SAAS,EAAC,QAAQ,EAAA,QAAA,EAAA,CACnBC,cAAA,CAACC,aAAM,EAAA,EACH,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,QAAQ,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EACxC,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC,EACnB,GAAG,EAAE,KAAK,CAAC,GAAG,IAAI,GAAG,EACrB,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,EACrB,SAAS,EAAC,QAAQ,GACpB,EACFD,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,kBAAkB,YAC7BA,cAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,eAAe,EAAA,QAAA,EAAE,KAAK,CAAC,KAAK,GAAQ,EAAA,CAClD,CAAA,EAAA,CACJ,CACT,EACD;AACI,IAAA,YAAY,EAAE,CAAC;AACf,IAAA,YAAY,EAAE,CAAC,CAAU,MAAM,OAAO,CAAC,KAAK,QAAQ,GAAG,CAAC,GAAG,CAAC;AAC/D,CAAA;;;;"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var inputtextarea = require('primereact/inputtextarea');
|
|
5
|
-
var
|
|
5
|
+
var commands = require('@cratis/arc.react/commands');
|
|
6
6
|
|
|
7
|
-
const TextAreaField =
|
|
7
|
+
const TextAreaField = commands.asCommandFormField((props) => (jsxRuntime.jsx(inputtextarea.InputTextarea, { value: props.value, onChange: props.onChange, invalid: props.invalid, placeholder: props.placeholder, rows: props.rows ?? 5, cols: props.cols, className: "w-full" })), {
|
|
8
8
|
defaultValue: '',
|
|
9
9
|
extractValue: (e) => e.target.value
|
|
10
10
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAreaField.js","sources":["../../../../CommandForm/fields/TextAreaField.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 { InputTextarea } from 'primereact/inputtextarea';\nimport React from 'react';\nimport { asCommandFormField, WrappedFieldProps } from '
|
|
1
|
+
{"version":3,"file":"TextAreaField.js","sources":["../../../../CommandForm/fields/TextAreaField.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 { InputTextarea } from 'primereact/inputtextarea';\nimport React from 'react';\nimport { asCommandFormField, WrappedFieldProps } from '@cratis/arc.react/commands';\n\ninterface TextAreaFieldComponentProps extends WrappedFieldProps<string> {\n placeholder?: string;\n rows?: number;\n cols?: number;\n}\n\nexport const TextAreaField = asCommandFormField<TextAreaFieldComponentProps>(\n (props) => (\n <InputTextarea\n value={props.value}\n onChange={props.onChange}\n invalid={props.invalid}\n placeholder={props.placeholder}\n rows={props.rows ?? 5}\n cols={props.cols}\n className=\"w-full\"\n />\n ),\n {\n defaultValue: '',\n extractValue: (e: React.ChangeEvent<HTMLTextAreaElement>) => e.target.value\n }\n);\n"],"names":["asCommandFormField","_jsx","InputTextarea"],"mappings":";;;;;;AAaO,MAAM,aAAa,GAAGA,2BAAkB,CAC3C,CAAC,KAAK,MACFC,cAAA,CAACC,2BAAa,EAAA,EACV,KAAK,EAAE,KAAK,CAAC,KAAK,EAClB,QAAQ,EAAE,KAAK,CAAC,QAAQ,EACxB,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,EACrB,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,SAAS,EAAC,QAAQ,EAAA,CACpB,CACL,EACD;AACI,IAAA,YAAY,EAAE,EAAE;IAChB,YAAY,EAAE,CAAC,CAAyC,KAAK,CAAC,CAAC,MAAM,CAAC;AACzE,CAAA;;;;"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var CommandFormField = require('./CommandFormField.js');
|
|
5
|
-
var ValidationMessage = require('./ValidationMessage.js');
|
|
6
|
-
var CommandFormFields = require('./CommandFormFields.js');
|
|
7
|
-
var asCommandFormField = require('./asCommandFormField.js');
|
|
3
|
+
var commands = require('@cratis/arc.react/commands');
|
|
8
4
|
var InputTextField = require('./fields/InputTextField.js');
|
|
9
5
|
var NumberField = require('./fields/NumberField.js');
|
|
10
6
|
var CheckboxField = require('./fields/CheckboxField.js');
|
|
@@ -14,18 +10,42 @@ var SliderField = require('./fields/SliderField.js');
|
|
|
14
10
|
|
|
15
11
|
|
|
16
12
|
|
|
17
|
-
exports
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
exports
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
Object.defineProperty(exports, "CommandForm", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return commands.CommandForm; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "CommandFormField", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return commands.CommandFormField; }
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "CommandFormFields", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return commands.CommandFormFields; }
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "ValidationMessage", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return commands.ValidationMessage; }
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports, "asCommandFormField", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return commands.asCommandFormField; }
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(exports, "useCommandFormContext", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return commands.useCommandFormContext; }
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(exports, "useCommandInstance", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function () { return commands.useCommandInstance; }
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(exports, "useSetCommandResult", {
|
|
42
|
+
enumerable: true,
|
|
43
|
+
get: function () { return commands.useSetCommandResult; }
|
|
44
|
+
});
|
|
25
45
|
exports.InputTextField = InputTextField.InputTextField;
|
|
26
46
|
exports.NumberField = NumberField.NumberField;
|
|
27
47
|
exports.CheckboxField = CheckboxField.CheckboxField;
|
|
28
48
|
exports.TextAreaField = TextAreaField.TextAreaField;
|
|
29
|
-
exports.
|
|
30
|
-
exports.
|
|
49
|
+
exports.DropdownField = DropdownField.DropdownField;
|
|
50
|
+
exports.SliderField = SliderField.SliderField;
|
|
31
51
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
|
|
6
|
+
class ErrorBoundary extends React.Component {
|
|
7
|
+
state = {
|
|
8
|
+
hasError: false,
|
|
9
|
+
error: new Error(),
|
|
10
|
+
};
|
|
11
|
+
static getDerivedStateFromError(error) {
|
|
12
|
+
return { hasError: true, error: error };
|
|
13
|
+
}
|
|
14
|
+
componentDidCatch(error, errorInfo) {
|
|
15
|
+
console.error('Uncaught error:', error, errorInfo);
|
|
16
|
+
}
|
|
17
|
+
render() {
|
|
18
|
+
if (this.state.hasError) {
|
|
19
|
+
return (jsxRuntime.jsxs("div", { className: 'p-4', children: [jsxRuntime.jsx("h1", { className: 'text-3xl m-3', children: "Error" }), jsxRuntime.jsx("p", { children: this.state.error.message }), jsxRuntime.jsx("p", { children: this.state.error.stack })] }));
|
|
20
|
+
}
|
|
21
|
+
return this.props.children;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
exports.ErrorBoundary = ErrorBoundary;
|
|
26
|
+
//# sourceMappingURL=ErrorBoundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.js","sources":["../../../Common/ErrorBoundary.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 { Component, ErrorInfo, ReactNode } from 'react';\n\ninterface Props {\n children: ReactNode;\n}\ninterface State {\n hasError: boolean;\n error: Error;\n}\n\nexport class ErrorBoundary extends Component<Props, State> {\n public state: State = {\n hasError: false,\n error: new Error(),\n };\n\n public static getDerivedStateFromError(error: Error): State {\n return { hasError: true, error: error };\n }\n\n public componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n console.error('Uncaught error:', error, errorInfo);\n }\n\n public render() {\n if (this.state.hasError) {\n return (\n <div className='p-4'>\n <h1 className='text-3xl m-3'>Error</h1>\n <p>{this.state.error.message}</p>\n <p>{this.state.error.stack}</p>\n </div>\n );\n }\n\n return this.props.children;\n }\n}\n"],"names":["Component","_jsxs","_jsx"],"mappings":";;;;;AAaM,MAAO,aAAc,SAAQA,eAAuB,CAAA;AAC/C,IAAA,KAAK,GAAU;AAClB,QAAA,QAAQ,EAAE,KAAK;QACf,KAAK,EAAE,IAAI,KAAK,EAAE;KACrB;IAEM,OAAO,wBAAwB,CAAC,KAAY,EAAA;QAC/C,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE;IAC3C;IAEO,iBAAiB,CAAC,KAAY,EAAE,SAAoB,EAAA;QACvD,OAAO,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,EAAE,SAAS,CAAC;IACtD;IAEO,MAAM,GAAA;AACT,QAAA,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;AACrB,YAAA,QACIC,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,KAAK,EAAA,QAAA,EAAA,CAChBC,cAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAC,cAAc,EAAA,QAAA,EAAA,OAAA,EAAA,CAAW,EACvCA,cAAA,CAAA,GAAA,EAAA,EAAA,QAAA,EAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAA,CAAK,EACjCA,gCAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAA,CAAK,CAAA,EAAA,CAC7B;QAEd;AAEA,QAAA,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ;IAC9B;AACH;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
|
|
5
|
+
const FormElement = (props) => {
|
|
6
|
+
return (jsxRuntime.jsx("div", { className: "card flex flex-column md:flex-row gap-3", children: jsxRuntime.jsxs("div", { className: "p-inputgroup flex-1", children: [jsxRuntime.jsx("span", { className: "p-inputgroup-addon", children: props.icon }), props.children] }) }));
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
exports.FormElement = FormElement;
|
|
10
|
+
//# sourceMappingURL=FormElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormElement.js","sources":["../../../Common/FormElement.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\nexport interface FormElementProps {\n children: React.ReactNode;\n icon: React.ReactNode;\n}\n\nexport const FormElement = (props: FormElementProps) => {\n return (\n <div className=\"card flex flex-column md:flex-row gap-3\">\n <div className=\"p-inputgroup flex-1\">\n <span className=\"p-inputgroup-addon\">\n {props.icon}\n </span>\n {props.children}\n </div>\n </div>\n );\n};\n"],"names":["_jsx","_jsxs"],"mappings":";;;;AAQO,MAAM,WAAW,GAAG,CAAC,KAAuB,KAAI;IACnD,QACIA,cAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,yCAAyC,EAAA,QAAA,EACpDC,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,qBAAqB,EAAA,QAAA,EAAA,CAChCD,cAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,oBAAoB,EAAA,QAAA,EAC/B,KAAK,CAAC,IAAI,EAAA,CACR,EACN,KAAK,CAAC,QAAQ,CAAA,EAAA,CACb,EAAA,CACJ;AAEd;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ErrorBoundary = require('./ErrorBoundary.js');
|
|
4
|
+
var Page = require('./Page.js');
|
|
5
|
+
var FormElement = require('./FormElement.js');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
exports.ErrorBoundary = ErrorBoundary.ErrorBoundary;
|
|
10
|
+
exports.Page = Page.Page;
|
|
11
|
+
exports.FormElement = FormElement.FormElement;
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
4
|
var datatable = require('primereact/datatable');
|
|
5
|
+
var paginator = require('primereact/paginator');
|
|
5
6
|
var queries = require('@cratis/arc/queries');
|
|
6
7
|
var queries$1 = require('@cratis/arc.react/queries');
|
|
7
8
|
var React = require('react');
|
|
@@ -9,8 +10,59 @@ var React = require('react');
|
|
|
9
10
|
const paging = new queries.Paging(0, 20);
|
|
10
11
|
const DataTableForObservableQuery = (props) => {
|
|
11
12
|
const [filters, setFilters] = React.useState(props.defaultFilters ?? {});
|
|
13
|
+
const [filteredTotal, setFilteredTotal] = React.useState(undefined);
|
|
12
14
|
const [result, , setPage] = queries$1.useObservableQueryWithPaging(props.query, paging, props.queryArguments);
|
|
13
|
-
|
|
15
|
+
const containerRef = React.useRef(null);
|
|
16
|
+
const [tableHeight, setTableHeight] = React.useState(600);
|
|
17
|
+
const timeoutRef = React.useRef(undefined);
|
|
18
|
+
const isClientFiltering = props.clientFiltering === true;
|
|
19
|
+
const totalRecords = isClientFiltering && filteredTotal !== undefined ? filteredTotal : result.paging.totalItems;
|
|
20
|
+
React.useEffect(() => {
|
|
21
|
+
if (!containerRef.current)
|
|
22
|
+
return;
|
|
23
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
24
|
+
if (timeoutRef.current) {
|
|
25
|
+
clearTimeout(timeoutRef.current);
|
|
26
|
+
}
|
|
27
|
+
timeoutRef.current = setTimeout(() => {
|
|
28
|
+
for (const entry of entries) {
|
|
29
|
+
const containerHeight = entry.contentRect.height;
|
|
30
|
+
if (containerHeight > 0) {
|
|
31
|
+
const paginatorHeight = result.paging.totalItems > 0 ? 56 : 0;
|
|
32
|
+
const calculatedHeight = containerHeight - paginatorHeight - 2;
|
|
33
|
+
const newHeight = Math.max(calculatedHeight, 200);
|
|
34
|
+
setTableHeight(prevHeight => {
|
|
35
|
+
if (Math.abs(newHeight - prevHeight) > 5) {
|
|
36
|
+
return newHeight;
|
|
37
|
+
}
|
|
38
|
+
return prevHeight;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}, 10);
|
|
43
|
+
});
|
|
44
|
+
resizeObserver.observe(containerRef.current);
|
|
45
|
+
return () => {
|
|
46
|
+
if (timeoutRef.current) {
|
|
47
|
+
clearTimeout(timeoutRef.current);
|
|
48
|
+
}
|
|
49
|
+
resizeObserver.disconnect();
|
|
50
|
+
};
|
|
51
|
+
}, [result.paging.totalItems]);
|
|
52
|
+
return (jsxRuntime.jsxs("div", { ref: containerRef, style: {
|
|
53
|
+
display: 'flex',
|
|
54
|
+
flexDirection: 'column',
|
|
55
|
+
height: '100%',
|
|
56
|
+
border: '1px solid var(--surface-border)',
|
|
57
|
+
borderRadius: 'var(--border-radius)',
|
|
58
|
+
overflow: 'hidden'
|
|
59
|
+
}, children: [jsxRuntime.jsx("div", { style: { height: `${tableHeight}px`, overflow: 'hidden' }, children: jsxRuntime.jsx(datatable.DataTable, { value: result.data, lazy: !isClientFiltering, rows: paging.pageSize, totalRecords: totalRecords, scrollable: true, scrollHeight: '100%', selectionMode: 'single', selection: props.selection, onSelectionChange: props.onSelectionChange, dataKey: props.dataKey, filters: filters, filterDisplay: 'menu', onFilter: (e) => {
|
|
60
|
+
setFilters(e.filters);
|
|
61
|
+
if (isClientFiltering) {
|
|
62
|
+
const filteredValue = e.filteredValue;
|
|
63
|
+
setFilteredTotal(filteredValue ? filteredValue.length : undefined);
|
|
64
|
+
}
|
|
65
|
+
}, globalFilterFields: props.globalFilterFields, emptyMessage: props.emptyMessage, children: props.children }) }), result.paging.totalItems > 0 && (jsxRuntime.jsx("div", { style: { borderTop: '1px solid var(--surface-border)' }, children: jsxRuntime.jsx(paginator.Paginator, { first: result.paging.page * paging.pageSize, rows: paging.pageSize, totalRecords: result.paging.totalItems, onPageChange: (e) => setPage(e.page) }) }))] }));
|
|
14
66
|
};
|
|
15
67
|
|
|
16
68
|
exports.DataTableForObservableQuery = DataTableForObservableQuery;
|