@cratis/components 0.1.9 → 0.1.12

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.
Files changed (258) hide show
  1. package/dist/cjs/CommandForm/CommandFormFields.js +9 -3
  2. package/dist/cjs/CommandForm/CommandFormFields.js.map +1 -1
  3. package/dist/cjs/CommandForm/ValidationMessage.js +24 -0
  4. package/dist/cjs/CommandForm/ValidationMessage.js.map +1 -0
  5. package/dist/cjs/CommandForm/asCommandFormField.js +47 -0
  6. package/dist/cjs/CommandForm/asCommandFormField.js.map +1 -0
  7. package/dist/cjs/CommandForm/fields/CheckboxField.js +13 -0
  8. package/dist/cjs/CommandForm/fields/CheckboxField.js.map +1 -0
  9. package/dist/cjs/CommandForm/fields/DropdownField.js +13 -0
  10. package/dist/cjs/CommandForm/fields/DropdownField.js.map +1 -0
  11. package/dist/cjs/CommandForm/fields/InputTextField.js +13 -0
  12. package/dist/cjs/CommandForm/fields/InputTextField.js.map +1 -0
  13. package/dist/cjs/CommandForm/fields/NumberField.js +13 -0
  14. package/dist/cjs/CommandForm/fields/NumberField.js.map +1 -0
  15. package/dist/cjs/CommandForm/fields/SliderField.js +17 -0
  16. package/dist/cjs/CommandForm/fields/SliderField.js.map +1 -0
  17. package/dist/cjs/CommandForm/fields/TextAreaField.js +13 -0
  18. package/dist/cjs/CommandForm/fields/TextAreaField.js.map +1 -0
  19. package/dist/cjs/CommandForm/index.js +15 -7
  20. package/dist/cjs/CommandForm/index.js.map +1 -1
  21. package/dist/cjs/PivotViewer/PivotViewer.css +1258 -0
  22. package/dist/cjs/PivotViewer/PivotViewer.js +14 -0
  23. package/dist/cjs/PivotViewer/PivotViewer.js.map +1 -1
  24. package/dist/cjs/PivotViewer/components/PivotCanvas.js +33 -10
  25. package/dist/cjs/PivotViewer/components/PivotCanvas.js.map +1 -1
  26. package/dist/cjs/PivotViewer/components/PivotViewerMain.js +1 -1
  27. package/dist/cjs/PivotViewer/components/PivotViewerMain.js.map +1 -1
  28. package/dist/cjs/PivotViewer/components/Spinner.css +77 -0
  29. package/dist/cjs/PivotViewer/components/pivot/sprites.js +79 -15
  30. package/dist/cjs/PivotViewer/components/pivot/sprites.js.map +1 -1
  31. package/dist/cjs/PivotViewer/components/pivot/visibility.js +36 -10
  32. package/dist/cjs/PivotViewer/components/pivot/visibility.js.map +1 -1
  33. package/dist/cjs/PivotViewer/engine/layout.js +2 -1
  34. package/dist/cjs/PivotViewer/engine/layout.js.map +1 -1
  35. package/dist/cjs/PivotViewer/hooks/usePivotEngine.js +37 -2
  36. package/dist/cjs/PivotViewer/hooks/usePivotEngine.js.map +1 -1
  37. package/dist/cjs/PivotViewer/index.js +3 -0
  38. package/dist/cjs/PivotViewer/index.js.map +1 -1
  39. package/dist/cjs/PivotViewer/types.js +22 -0
  40. package/dist/cjs/PivotViewer/types.js.map +1 -0
  41. package/dist/cjs/TimeMachine/EventsView.css +213 -0
  42. package/dist/cjs/TimeMachine/TimeMachine.css +567 -0
  43. package/dist/cjs/TimeMachine/TimeMachine.js +8 -3
  44. package/dist/cjs/TimeMachine/TimeMachine.js.map +1 -1
  45. package/dist/esm/CommandForm/CommandForm.stories.d.ts +1 -0
  46. package/dist/esm/CommandForm/CommandForm.stories.d.ts.map +1 -1
  47. package/dist/esm/CommandForm/CommandForm.stories.js +34 -1
  48. package/dist/esm/CommandForm/CommandForm.stories.js.map +1 -1
  49. package/dist/esm/CommandForm/CommandFormFields.d.ts.map +1 -1
  50. package/dist/esm/CommandForm/CommandFormFields.js +9 -3
  51. package/dist/esm/CommandForm/CommandFormFields.js.map +1 -1
  52. package/dist/esm/CommandForm/UserRegistrationCommand.d.ts +63 -0
  53. package/dist/esm/CommandForm/UserRegistrationCommand.d.ts.map +1 -0
  54. package/dist/esm/CommandForm/UserRegistrationCommand.js +143 -0
  55. package/dist/esm/CommandForm/UserRegistrationCommand.js.map +1 -0
  56. package/dist/esm/CommandForm/ValidationMessage.d.ts +8 -0
  57. package/dist/esm/CommandForm/ValidationMessage.d.ts.map +1 -0
  58. package/dist/esm/CommandForm/ValidationMessage.js +22 -0
  59. package/dist/esm/CommandForm/ValidationMessage.js.map +1 -0
  60. package/dist/esm/CommandForm/asCommandFormField.d.ts +32 -0
  61. package/dist/esm/CommandForm/asCommandFormField.d.ts.map +1 -0
  62. package/dist/esm/CommandForm/asCommandFormField.js +45 -0
  63. package/dist/esm/CommandForm/asCommandFormField.js.map +1 -0
  64. package/dist/esm/CommandForm/fields/CheckboxField.d.ts +10 -0
  65. package/dist/esm/CommandForm/fields/CheckboxField.d.ts.map +1 -0
  66. package/dist/esm/CommandForm/fields/CheckboxField.js +11 -0
  67. package/dist/esm/CommandForm/fields/CheckboxField.js.map +1 -0
  68. package/dist/esm/CommandForm/fields/DropdownField.d.ts +15 -0
  69. package/dist/esm/CommandForm/fields/DropdownField.d.ts.map +1 -0
  70. package/dist/esm/CommandForm/fields/DropdownField.js +11 -0
  71. package/dist/esm/CommandForm/fields/DropdownField.js.map +1 -0
  72. package/dist/esm/CommandForm/fields/InputTextField.d.ts +11 -0
  73. package/dist/esm/CommandForm/fields/InputTextField.d.ts.map +1 -0
  74. package/dist/esm/CommandForm/fields/InputTextField.js +11 -0
  75. package/dist/esm/CommandForm/fields/InputTextField.js.map +1 -0
  76. package/dist/esm/CommandForm/fields/NumberField.d.ts +13 -0
  77. package/dist/esm/CommandForm/fields/NumberField.d.ts.map +1 -0
  78. package/dist/esm/CommandForm/fields/NumberField.js +11 -0
  79. package/dist/esm/CommandForm/fields/NumberField.js.map +1 -0
  80. package/dist/esm/CommandForm/fields/SliderField.d.ts +12 -0
  81. package/dist/esm/CommandForm/fields/SliderField.d.ts.map +1 -0
  82. package/dist/esm/CommandForm/fields/SliderField.js +15 -0
  83. package/dist/esm/CommandForm/fields/SliderField.js.map +1 -0
  84. package/dist/esm/CommandForm/fields/TextAreaField.d.ts +12 -0
  85. package/dist/esm/CommandForm/fields/TextAreaField.d.ts.map +1 -0
  86. package/dist/esm/CommandForm/fields/TextAreaField.js +11 -0
  87. package/dist/esm/CommandForm/fields/TextAreaField.js.map +1 -0
  88. package/dist/esm/CommandForm/fields/index.d.ts +7 -0
  89. package/dist/esm/CommandForm/fields/index.d.ts.map +1 -0
  90. package/dist/esm/CommandForm/fields/index.js +7 -0
  91. package/dist/esm/CommandForm/fields/index.js.map +1 -0
  92. package/dist/esm/CommandForm/index.d.ts +3 -4
  93. package/dist/esm/CommandForm/index.d.ts.map +1 -1
  94. package/dist/esm/CommandForm/index.js +8 -4
  95. package/dist/esm/CommandForm/index.js.map +1 -1
  96. package/dist/esm/PivotViewer/PivotViewer.css +1258 -0
  97. package/dist/esm/PivotViewer/PivotViewer.d.ts.map +1 -1
  98. package/dist/esm/PivotViewer/PivotViewer.js +14 -0
  99. package/dist/esm/PivotViewer/PivotViewer.js.map +1 -1
  100. package/dist/esm/PivotViewer/PivotViewer.stories.d.ts +1 -0
  101. package/dist/esm/PivotViewer/PivotViewer.stories.d.ts.map +1 -1
  102. package/dist/esm/PivotViewer/PivotViewer.stories.js +43 -3
  103. package/dist/esm/PivotViewer/PivotViewer.stories.js.map +1 -1
  104. package/dist/esm/PivotViewer/components/PivotCanvas.d.ts.map +1 -1
  105. package/dist/esm/PivotViewer/components/PivotCanvas.js +33 -10
  106. package/dist/esm/PivotViewer/components/PivotCanvas.js.map +1 -1
  107. package/dist/esm/PivotViewer/components/PivotViewerMain.js +1 -1
  108. package/dist/esm/PivotViewer/components/PivotViewerMain.js.map +1 -1
  109. package/dist/esm/PivotViewer/components/Spinner.css +77 -0
  110. package/dist/esm/PivotViewer/components/pivot/sprites.d.ts.map +1 -1
  111. package/dist/esm/PivotViewer/components/pivot/sprites.js +79 -15
  112. package/dist/esm/PivotViewer/components/pivot/sprites.js.map +1 -1
  113. package/dist/esm/PivotViewer/components/pivot/visibility.d.ts.map +1 -1
  114. package/dist/esm/PivotViewer/components/pivot/visibility.js +36 -10
  115. package/dist/esm/PivotViewer/components/pivot/visibility.js.map +1 -1
  116. package/dist/esm/PivotViewer/engine/layout.js +2 -1
  117. package/dist/esm/PivotViewer/engine/layout.js.map +1 -1
  118. package/dist/esm/PivotViewer/engine/pivot.worker.d.ts.map +1 -1
  119. package/dist/esm/PivotViewer/engine/pivot.worker.js +22 -7
  120. package/dist/esm/PivotViewer/engine/pivot.worker.js.map +1 -1
  121. package/dist/esm/PivotViewer/hooks/useFilteredData.d.ts +2 -2
  122. package/dist/esm/PivotViewer/hooks/useFilteredData.d.ts.map +1 -1
  123. package/dist/esm/PivotViewer/hooks/useFilteredData.js +4 -2
  124. package/dist/esm/PivotViewer/hooks/useFilteredData.js.map +1 -1
  125. package/dist/esm/PivotViewer/hooks/usePivotEngine.d.ts.map +1 -1
  126. package/dist/esm/PivotViewer/hooks/usePivotEngine.js +37 -2
  127. package/dist/esm/PivotViewer/hooks/usePivotEngine.js.map +1 -1
  128. package/dist/esm/PivotViewer/index.d.ts +2 -1
  129. package/dist/esm/PivotViewer/index.d.ts.map +1 -1
  130. package/dist/esm/PivotViewer/index.js +1 -0
  131. package/dist/esm/PivotViewer/index.js.map +1 -1
  132. package/dist/esm/PivotViewer/types.d.ts +4 -1
  133. package/dist/esm/PivotViewer/types.d.ts.map +1 -1
  134. package/dist/esm/PivotViewer/types.js +19 -2
  135. package/dist/esm/PivotViewer/types.js.map +1 -1
  136. package/dist/esm/TimeMachine/EventsView.css +213 -0
  137. package/dist/esm/TimeMachine/TimeMachine.css +567 -0
  138. package/dist/esm/TimeMachine/TimeMachine.d.ts.map +1 -1
  139. package/dist/esm/TimeMachine/TimeMachine.js +8 -3
  140. package/dist/esm/TimeMachine/TimeMachine.js.map +1 -1
  141. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  142. package/package.json +31 -32
  143. package/.storybook/main.ts +0 -24
  144. package/CommandDialog/CommandDialog.stories.tsx +0 -25
  145. package/CommandDialog/CommandDialog.tsx +0 -161
  146. package/CommandDialog/index.ts +0 -4
  147. package/CommandForm/CommandForm.stories.tsx +0 -24
  148. package/CommandForm/CommandForm.tsx +0 -266
  149. package/CommandForm/CommandFormField.tsx +0 -27
  150. package/CommandForm/CommandFormFields.tsx +0 -142
  151. package/CommandForm/DatePickerField.tsx +0 -57
  152. package/CommandForm/DropdownField.tsx +0 -65
  153. package/CommandForm/InputTextField.tsx +0 -62
  154. package/CommandForm/SliderField.tsx +0 -68
  155. package/CommandForm/index.ts +0 -10
  156. package/Common/ErrorBoundary.stories.tsx +0 -10
  157. package/Common/ErrorBoundary.tsx +0 -41
  158. package/Common/FormElement.stories.tsx +0 -10
  159. package/Common/FormElement.tsx +0 -20
  160. package/Common/Page.stories.tsx +0 -10
  161. package/Common/Page.tsx +0 -21
  162. package/Common/index.ts +0 -6
  163. package/DataPage/DataPage.stories.tsx +0 -10
  164. package/DataPage/DataPage.tsx +0 -191
  165. package/DataPage/index.ts +0 -4
  166. package/DataTables/DataTableForObservableQuery.stories.tsx +0 -10
  167. package/DataTables/DataTableForObservableQuery.tsx +0 -97
  168. package/DataTables/DataTableForQuery.stories.tsx +0 -10
  169. package/DataTables/DataTableForQuery.tsx +0 -97
  170. package/DataTables/index.ts +0 -5
  171. package/Dialogs/BusyIndicatorDialog.stories.tsx +0 -26
  172. package/Dialogs/BusyIndicatorDialog.tsx +0 -26
  173. package/Dialogs/ConfirmationDialog.stories.tsx +0 -36
  174. package/Dialogs/ConfirmationDialog.tsx +0 -75
  175. package/Dialogs/index.ts +0 -5
  176. package/Dropdown/Dropdown.tsx +0 -23
  177. package/Dropdown/index.ts +0 -4
  178. package/PivotViewer/PivotViewer.stories.tsx +0 -24
  179. package/PivotViewer/PivotViewer.tsx +0 -791
  180. package/PivotViewer/components/AxisLabels.tsx +0 -69
  181. package/PivotViewer/components/DetailPanel.tsx +0 -108
  182. package/PivotViewer/components/FilterPanel.tsx +0 -189
  183. package/PivotViewer/components/FilterPanelContainer.tsx +0 -10
  184. package/PivotViewer/components/PivotCanvas.tsx +0 -660
  185. package/PivotViewer/components/PivotViewerMain.tsx +0 -229
  186. package/PivotViewer/components/RangeHistogramFilter.tsx +0 -220
  187. package/PivotViewer/components/Spinner.tsx +0 -21
  188. package/PivotViewer/components/Toolbar.tsx +0 -130
  189. package/PivotViewer/components/ToolbarContainer.tsx +0 -10
  190. package/PivotViewer/components/index.ts +0 -12
  191. package/PivotViewer/components/pivot/animation.ts +0 -108
  192. package/PivotViewer/components/pivot/buckets.ts +0 -152
  193. package/PivotViewer/components/pivot/colorResolver.ts +0 -67
  194. package/PivotViewer/components/pivot/constants.ts +0 -46
  195. package/PivotViewer/components/pivot/sprites.ts +0 -265
  196. package/PivotViewer/components/pivot/visibility.ts +0 -319
  197. package/PivotViewer/constants.ts +0 -9
  198. package/PivotViewer/engine/layout.ts +0 -149
  199. package/PivotViewer/engine/pivot.worker.ts +0 -86
  200. package/PivotViewer/engine/store.ts +0 -437
  201. package/PivotViewer/engine/types.ts +0 -255
  202. package/PivotViewer/hooks/index.ts +0 -13
  203. package/PivotViewer/hooks/useContainerDimensions.ts +0 -45
  204. package/PivotViewer/hooks/useDimensionState.ts +0 -53
  205. package/PivotViewer/hooks/useFilterOptions.ts +0 -36
  206. package/PivotViewer/hooks/useFilterPanelDrag.ts +0 -49
  207. package/PivotViewer/hooks/useFilterState.ts +0 -106
  208. package/PivotViewer/hooks/useFilteredData.ts +0 -119
  209. package/PivotViewer/hooks/usePanning.ts +0 -163
  210. package/PivotViewer/hooks/usePivotEngine.ts +0 -252
  211. package/PivotViewer/hooks/useSelectedItem.ts +0 -402
  212. package/PivotViewer/hooks/useWheelZoom.ts +0 -114
  213. package/PivotViewer/hooks/useZoomState.ts +0 -34
  214. package/PivotViewer/index.ts +0 -7
  215. package/PivotViewer/types.ts +0 -59
  216. package/PivotViewer/utils/animations.ts +0 -249
  217. package/PivotViewer/utils/constants.ts +0 -20
  218. package/PivotViewer/utils/index.ts +0 -6
  219. package/PivotViewer/utils/selection.ts +0 -292
  220. package/PivotViewer/utils/utils.ts +0 -259
  221. package/TimeMachine/EventsView.stories.tsx +0 -10
  222. package/TimeMachine/EventsView.tsx +0 -119
  223. package/TimeMachine/Properties.stories.tsx +0 -10
  224. package/TimeMachine/Properties.tsx +0 -98
  225. package/TimeMachine/ReadModelView.stories.tsx +0 -10
  226. package/TimeMachine/ReadModelView.tsx +0 -143
  227. package/TimeMachine/TimeMachine.stories.tsx +0 -10
  228. package/TimeMachine/TimeMachine.tsx +0 -244
  229. package/TimeMachine/index.ts +0 -8
  230. package/TimeMachine/types.ts +0 -23
  231. package/dist/cjs/CommandForm/DatePickerField.js +0 -31
  232. package/dist/cjs/CommandForm/DatePickerField.js.map +0 -1
  233. package/dist/cjs/CommandForm/DropdownField.js +0 -31
  234. package/dist/cjs/CommandForm/DropdownField.js.map +0 -1
  235. package/dist/cjs/CommandForm/InputTextField.js +0 -32
  236. package/dist/cjs/CommandForm/InputTextField.js.map +0 -1
  237. package/dist/cjs/CommandForm/SliderField.js +0 -34
  238. package/dist/cjs/CommandForm/SliderField.js.map +0 -1
  239. package/dist/esm/CommandForm/DatePickerField.d.ts +0 -20
  240. package/dist/esm/CommandForm/DatePickerField.d.ts.map +0 -1
  241. package/dist/esm/CommandForm/DatePickerField.js +0 -29
  242. package/dist/esm/CommandForm/DatePickerField.js.map +0 -1
  243. package/dist/esm/CommandForm/DropdownField.d.ts +0 -24
  244. package/dist/esm/CommandForm/DropdownField.d.ts.map +0 -1
  245. package/dist/esm/CommandForm/DropdownField.js +0 -29
  246. package/dist/esm/CommandForm/DropdownField.js.map +0 -1
  247. package/dist/esm/CommandForm/InputTextField.d.ts +0 -20
  248. package/dist/esm/CommandForm/InputTextField.d.ts.map +0 -1
  249. package/dist/esm/CommandForm/InputTextField.js +0 -30
  250. package/dist/esm/CommandForm/InputTextField.js.map +0 -1
  251. package/dist/esm/CommandForm/SliderField.d.ts +0 -23
  252. package/dist/esm/CommandForm/SliderField.d.ts.map +0 -1
  253. package/dist/esm/CommandForm/SliderField.js +0 -32
  254. package/dist/esm/CommandForm/SliderField.js.map +0 -1
  255. package/global.d.ts +0 -11
  256. package/index.ts +0 -22
  257. package/useOverlayZIndex.ts +0 -32
  258. package/vite.config.ts +0 -80
@@ -1,98 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import React from 'react';
5
-
6
- interface PropertiesProps {
7
- data: Record<string, unknown>;
8
- /** CSS class name for the container */
9
- className?: string;
10
- /** Text alignment for the table */
11
- align?: 'left' | 'right';
12
- }
13
-
14
- export const Properties: React.FC<PropertiesProps> = ({ data, className, align = 'left' }) => {
15
- const tableStyle: React.CSSProperties = {
16
- width: '100%',
17
- borderCollapse: 'collapse',
18
- fontFamily: '-apple-system, BlinkMacSystemFont, "SF Mono", monospace',
19
- fontSize: '13px',
20
- };
21
-
22
- const rowStyle: React.CSSProperties = {
23
- borderBottom: '1px solid rgba(255,255,255,0.1)',
24
- };
25
-
26
- const labelStyle: React.CSSProperties = {
27
- padding: '8px 12px',
28
- color: 'rgba(255,255,255,0.6)',
29
- textAlign: align,
30
- fontWeight: 500,
31
- width: '40%',
32
- };
33
-
34
- const valueStyle: React.CSSProperties = {
35
- padding: '8px 12px',
36
- color: '#fff',
37
- textAlign: align,
38
- };
39
-
40
- const renderValue = (value: unknown): React.ReactNode => {
41
- if (value === null || value === undefined) {
42
- return <span style={{ color: 'rgba(255,255,255,0.4)' }}>null</span>;
43
- }
44
-
45
- if (typeof value === 'boolean') {
46
- return <span style={{ color: value ? '#4ade80' : '#f87171' }}>{value.toString()}</span>;
47
- }
48
-
49
- if (typeof value === 'number') {
50
- return <span style={{ color: '#fbbf24' }}>{value}</span>;
51
- }
52
-
53
- if (value instanceof Date) {
54
- return <span style={{ color: '#60a5fa' }}>{value.toLocaleString()}</span>;
55
- }
56
-
57
- if (Array.isArray(value)) {
58
- return (
59
- <span style={{ color: 'rgba(255,255,255,0.7)' }}>
60
- Array[{value.length}]
61
- </span>
62
- );
63
- }
64
-
65
- if (typeof value === 'object') {
66
- return (
67
- <span style={{ color: 'rgba(255,255,255,0.7)' }}>
68
- {'{'}...{'}'}
69
- </span>
70
- );
71
- }
72
-
73
- return <span>{String(value)}</span>;
74
- };
75
-
76
- const formatPropertyName = (key: string): string => {
77
- // Convert camelCase to Title Case with spaces
78
- return key
79
- .replace(/([A-Z])/g, ' $1')
80
- .replace(/^./, str => str.toUpperCase())
81
- .trim();
82
- };
83
-
84
- return (
85
- <div className={className}>
86
- <table style={tableStyle}>
87
- <tbody>
88
- {data && Object.entries(data).map(([key, value], index) => (
89
- <tr key={`${key}-${index}`} style={rowStyle}>
90
- <td style={labelStyle}>{formatPropertyName(key)}</td>
91
- <td style={valueStyle}>{renderValue(value)}</td>
92
- </tr>
93
- ))}
94
- </tbody>
95
- </table>
96
- </div>
97
- );
98
- };
@@ -1,10 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import React from 'react';
5
- import * as Comp from './ReadModelView';
6
- const Component: React.ComponentType<any> | undefined = (Comp as any).default || (Object.values(Comp)[0] as any);
7
-
8
- export default { title: 'TimeMachine/ReadModelView', component: Component };
9
-
10
- export const Default = () => (Component ? <Component /> : <div>Unable to render component</div>);
@@ -1,143 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import React, { useState } from 'react';
5
- import type { Version } from './types';
6
- import { Properties } from './Properties';
7
-
8
- interface ReadModelViewProps {
9
- versions: Version[];
10
- selectedIndex: number;
11
- hoveredIndex: number | null;
12
- onVersionSelect: (index: number) => void;
13
- onHoveringCardChange: (isHovering: boolean) => void;
14
- }
15
-
16
- export const ReadModelView: React.FC<ReadModelViewProps> = ({
17
- versions,
18
- selectedIndex,
19
- hoveredIndex,
20
- onVersionSelect,
21
- onHoveringCardChange,
22
- }) => {
23
- const displayIndex = hoveredIndex ?? selectedIndex;
24
- const [flippedMap, setFlippedMap] = useState<Record<string, boolean>>({});
25
-
26
- const toggleFlip = (id: string) => (event: React.MouseEvent<HTMLButtonElement>) => {
27
- event.stopPropagation();
28
- setFlippedMap(previous => ({
29
- ...previous,
30
- [id]: !previous[id]
31
- }));
32
- };
33
-
34
- return (
35
- <>
36
- {/* Starfield background */}
37
- <div className="time-machine-background">
38
- <div className="stars"></div>
39
- <div className="stars stars-2"></div>
40
- <div className="stars stars-3"></div>
41
- </div>
42
-
43
- {/* 3D Stacked Windows */}
44
- <div className="time-machine-viewport">
45
- <div className="windows-container">
46
- {versions.map((version, index) => {
47
- const depth = index - displayIndex;
48
- const isActive = index === displayIndex;
49
- const isVisible = depth >= 0 && depth < 10;
50
- const isFlipped = flippedMap[version.id] ?? false;
51
-
52
- if (!isVisible) return null;
53
-
54
- // Only prepare events for the active version to avoid showing all events at once
55
- const events = isActive && version.events?.length
56
- ? version.events.map(event => ({
57
- ...event,
58
- occurred: new Date(event.occurred)
59
- }))
60
- : [];
61
-
62
- return (
63
- <div
64
- key={version.id}
65
- className={`version-window ${isActive ? 'active' : ''} ${isFlipped ? 'flipped' : ''}`}
66
- style={{
67
- '--depth': depth,
68
- '--z-offset': -depth * 150,
69
- '--scale': 1 - depth * 0.05,
70
- '--opacity': 1 - depth * 0.12,
71
- } as React.CSSProperties}
72
- onClick={() => onVersionSelect(index)}
73
- onMouseEnter={() => onHoveringCardChange(true)}
74
- onMouseLeave={() => onHoveringCardChange(false)}
75
- >
76
- <div className="version-window-inner">
77
- <div className="version-window-face version-window-face--front">
78
- <div className="window-chrome">
79
- <div className="window-controls">
80
- <span className="control close"></span>
81
- <span className="control minimize"></span>
82
- <span className="control maximize"></span>
83
- </div>
84
- <div className="window-title">{version.label}</div>
85
- <div className="window-actions">
86
- <button
87
- type="button"
88
- className="window-flip-button"
89
- onClick={toggleFlip(version.id)}
90
- aria-label="Show related events"
91
- aria-pressed={isFlipped}
92
- >
93
- <i className={`pi ${isFlipped ? 'pi-undo' : 'pi-refresh'}`} />
94
- </button>
95
- </div>
96
- </div>
97
- <div className="window-content">
98
- {version.content}
99
- </div>
100
- </div>
101
- <div className="version-window-face version-window-face--back">
102
- <div className="window-chrome window-chrome--back">
103
- <div className="window-controls">
104
- <span className="control close"></span>
105
- <span className="control minimize"></span>
106
- <span className="control maximize"></span>
107
- </div>
108
- <div className="window-title">Related Events</div>
109
- <div className="window-actions">
110
- <button
111
- type="button"
112
- className="window-flip-button"
113
- onClick={toggleFlip(version.id)}
114
- aria-label="Show read model snapshot"
115
- aria-pressed={isFlipped}
116
- >
117
- <i className={`pi ${isFlipped ? 'pi-undo' : 'pi-refresh'}`} />
118
- </button>
119
- </div>
120
- </div>
121
- <div className="window-content window-content--events">
122
- <div className="snapshot-event-list">
123
- {events.map((event, eventIndex) => (
124
- <div key={`${version.id}-${event.sequenceNumber ?? eventIndex}`} className="snapshot-event">
125
- <div className="snapshot-event-header">
126
- <span className="snapshot-event-name">{event.type}</span>
127
- <span className="snapshot-event-timestamp">{event.occurred.toLocaleString()}</span>
128
- </div>
129
- <Properties data={event.content} align="left" />
130
- </div>
131
- ))}
132
- </div>
133
- </div>
134
- </div>
135
- </div>
136
- </div>
137
- );
138
- })}
139
- </div>
140
- </div>
141
- </>
142
- );
143
- };
@@ -1,10 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import React from 'react';
5
- import * as Comp from './TimeMachine';
6
- const Component: React.ComponentType<any> | undefined = (Comp as any).default || (Object.values(Comp)[0] as any);
7
-
8
- export default { title: 'TimeMachine/TimeMachine', component: Component };
9
-
10
- export const Default = () => (Component ? <Component /> : <div>Unable to render component</div>);
@@ -1,244 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- import React, { useState, useCallback, useRef, useEffect } from 'react';
5
- import type { Version } from './types';
6
- import { ReadModelView } from './ReadModelView';
7
- import { EventsView } from './EventsView';
8
- import './TimeMachine.css';
9
-
10
- type ViewMode = 'readmodel' | 'events';
11
-
12
- interface TimeMachineProps {
13
- versions: Version[];
14
- currentVersionIndex?: number;
15
- onVersionChange?: (index: number) => void;
16
- /** Scroll sensitivity - higher values require more scrolling to change versions */
17
- scrollSensitivity?: number;
18
- }
19
-
20
- export const TimeMachine: React.FC<TimeMachineProps> = ({
21
- versions,
22
- currentVersionIndex = 0,
23
- onVersionChange,
24
- scrollSensitivity = 50,
25
- }) => {
26
- const [selectedIndex, setSelectedIndex] = useState(currentVersionIndex);
27
- const [hoveredIndex, setHoveredIndex] = useState<number | null>(null);
28
- const [isHoveringCard, setIsHoveringCard] = useState(false);
29
- const [viewMode, setViewMode] = useState<ViewMode>('readmodel');
30
- const containerRef = useRef<HTMLDivElement>(null);
31
- const scrollAccumulatorRef = useRef(0);
32
-
33
- const handleVersionSelect = useCallback((index: number) => {
34
- setSelectedIndex(index);
35
- onVersionChange?.(index);
36
- }, [onVersionChange]);
37
-
38
- const handleTimelineHover = useCallback((index: number | null) => {
39
- setHoveredIndex(index);
40
- }, []);
41
-
42
- // Handle trackpad two-finger scroll gesture
43
- useEffect(() => {
44
- if (viewMode !== 'readmodel') {
45
- return;
46
- }
47
-
48
- const container = containerRef.current;
49
- if (!container) return;
50
-
51
- const handleWheel = (e: WheelEvent) => {
52
- // Only handle navigation when not hovering over a card
53
- if (isHoveringCard) {
54
- return; // Allow normal scrolling within cards
55
- }
56
-
57
- // Prevent default scrolling behavior
58
- e.preventDefault();
59
-
60
- // Use deltaX for horizontal scroll, fallback to deltaY for vertical
61
- // Most trackpads send horizontal delta for two-finger swipe
62
- const delta = Math.abs(e.deltaX) > Math.abs(e.deltaY) ? e.deltaX : e.deltaY;
63
-
64
- // Accumulate scroll delta
65
- scrollAccumulatorRef.current += delta;
66
-
67
- // Check if we've accumulated enough scroll to change version
68
- if (Math.abs(scrollAccumulatorRef.current) >= scrollSensitivity) {
69
- const direction = scrollAccumulatorRef.current > 0 ? 1 : -1;
70
- const newIndex = Math.max(0, Math.min(versions.length - 1, selectedIndex + direction));
71
-
72
- if (newIndex !== selectedIndex) {
73
- setSelectedIndex(newIndex);
74
- onVersionChange?.(newIndex);
75
- }
76
-
77
- // Reset accumulator after version change
78
- scrollAccumulatorRef.current = 0;
79
- }
80
- };
81
-
82
- container.addEventListener('wheel', handleWheel, { passive: false });
83
-
84
- return () => {
85
- container.removeEventListener('wheel', handleWheel);
86
- };
87
- }, [versions.length, selectedIndex, onVersionChange, scrollSensitivity, isHoveringCard, viewMode]);
88
-
89
- // Calculate the display index - either hovered or selected
90
- // (not used in this component; ReadModelView computes its own display index)
91
- void hoveredIndex;
92
- void selectedIndex;
93
-
94
- // Get all events from all versions
95
- const allEvents = versions.flatMap(version => version.events || []);
96
-
97
- return (
98
- <div className="time-machine" ref={containerRef}>
99
- {/* View Switcher */}
100
- <div className="view-switcher">
101
- <button
102
- className={`view-button ${viewMode === 'readmodel' ? 'active' : ''}`}
103
- onClick={() => setViewMode('readmodel')}
104
- aria-label="Read Model View"
105
- title="Read Model View"
106
- >
107
- <i className="pi pi-box" />
108
- </button>
109
- <button
110
- className={`view-button ${viewMode === 'events' ? 'active' : ''}`}
111
- onClick={() => setViewMode('events')}
112
- aria-label="Events View"
113
- title="Events View"
114
- >
115
- <i className="pi pi-list" />
116
- </button>
117
- </div>
118
-
119
- {/* Render the appropriate view */}
120
- {viewMode === 'readmodel' ? (
121
- <ReadModelView
122
- versions={versions}
123
- selectedIndex={selectedIndex}
124
- hoveredIndex={hoveredIndex}
125
- onVersionSelect={handleVersionSelect}
126
- onHoveringCardChange={setIsHoveringCard}
127
- />
128
- ) : (
129
- <EventsView events={allEvents} />
130
- )}
131
-
132
- {/* Timeline - only show in ReadModel view */}
133
- {viewMode === 'readmodel' && (
134
- <Timeline
135
- versions={versions}
136
- selectedIndex={selectedIndex}
137
- hoveredIndex={hoveredIndex}
138
- onSelect={handleVersionSelect}
139
- onHover={handleTimelineHover}
140
- />
141
- )}
142
-
143
- {/* Navigation arrows - only show in ReadModel view */}
144
- {viewMode === 'readmodel' && (
145
- <div className="navigation-controls">
146
- <button
147
- className="nav-button prev"
148
- disabled={selectedIndex === 0}
149
- onClick={() => handleVersionSelect(Math.max(0, selectedIndex - 1))}
150
- aria-label="Previous version"
151
- >
152
-
153
- </button>
154
- <button
155
- className="nav-button next"
156
- disabled={selectedIndex === versions.length - 1}
157
- onClick={() => handleVersionSelect(Math.min(versions.length - 1, selectedIndex + 1))}
158
- aria-label="Next version"
159
- >
160
-
161
- </button>
162
- </div>
163
- )}
164
- </div>
165
- );
166
- };
167
-
168
- interface TimelineProps {
169
- versions: Version[];
170
- selectedIndex: number;
171
- hoveredIndex: number | null;
172
- onSelect: (index: number) => void;
173
- onHover: (index: number | null) => void;
174
- }
175
-
176
- const Timeline: React.FC<TimelineProps> = ({
177
- versions,
178
- selectedIndex,
179
- hoveredIndex,
180
- onSelect,
181
- onHover,
182
- }) => {
183
- const getMagnification = (index: number, hoverIdx: number | null): number => {
184
- if (hoverIdx === null) return 1;
185
- const distance = Math.abs(index - hoverIdx);
186
- // Fish-eye effect: items close to hover get magnified
187
- if (distance === 0) return 2.0;
188
- if (distance === 1) return 1.6;
189
- if (distance === 2) return 1.3;
190
- if (distance === 3) return 1.1;
191
- return 1;
192
- };
193
-
194
- const formatDate = (date: Date): string => {
195
- return date.toLocaleDateString('en-US', {
196
- month: 'short',
197
- day: 'numeric',
198
- year: 'numeric',
199
- });
200
- };
201
-
202
- const formatTime = (date: Date): string => {
203
- return date.toLocaleTimeString('en-US', {
204
- hour: 'numeric',
205
- minute: '2-digit',
206
- hour12: true,
207
- });
208
- };
209
-
210
- return (
211
- <div
212
- className="timeline"
213
- onMouseLeave={() => onHover(null)}
214
- >
215
- <div className="timeline-track">
216
- {versions.map((version, index) => {
217
- const magnification = getMagnification(index, hoveredIndex);
218
- const isSelected = index === selectedIndex;
219
- const isHovered = index === hoveredIndex;
220
-
221
- return (
222
- <div
223
- key={version.id}
224
- className={`timeline-entry ${isSelected ? 'selected' : ''} ${isHovered ? 'hovered' : ''}`}
225
- style={{
226
- '--magnification': magnification,
227
- } as React.CSSProperties}
228
- onMouseEnter={() => onHover(index)}
229
- onClick={() => onSelect(index)}
230
- >
231
- <div className="timeline-tick"></div>
232
- <div className="timeline-label">
233
- <span className="timeline-date">{formatDate(version.timestamp)}</span>
234
- <span className="timeline-time">{formatTime(version.timestamp)}</span>
235
- </div>
236
- </div>
237
- );
238
- })}
239
- </div>
240
- </div>
241
- );
242
- };
243
-
244
- export default TimeMachine;
@@ -1,8 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- export { TimeMachine } from './TimeMachine';
5
- export { ReadModelView } from './ReadModelView';
6
- export { EventsView } from './EventsView';
7
- export { Properties } from './Properties';
8
- export * from './types';
@@ -1,23 +0,0 @@
1
- // Copyright (c) Cratis. All rights reserved.
2
- // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
-
4
- export interface Version {
5
- id: string;
6
- timestamp: Date;
7
- label: string;
8
- content: React.ReactNode;
9
- events?: Event[];
10
- }
11
-
12
- export interface Event {
13
- sequenceNumber: number;
14
- type: string;
15
- occurred: Date;
16
- content: Record<string, unknown>;
17
- }
18
-
19
- export interface TimelineEntry {
20
- id: string;
21
- timestamp: Date;
22
- label: string;
23
- }
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var React = require('react');
5
- var inputtext = require('primereact/inputtext');
6
- var CommandForm = require('./CommandForm.js');
7
-
8
- const DatePickerField = (props) => {
9
- const [localValue, setLocalValue] = React.useState(props.currentValue || '');
10
- const required = props.required ?? true;
11
- const isValid = !required || localValue.trim().length > 0;
12
- const { setFieldValidity } = CommandForm.useCommandFormContext();
13
- React.useEffect(() => {
14
- setLocalValue(props.currentValue || '');
15
- }, [props.currentValue]);
16
- React.useEffect(() => {
17
- if (props.fieldName) {
18
- setFieldValidity(props.fieldName, isValid);
19
- }
20
- }, [isValid, props.fieldName, setFieldValidity]);
21
- const handleChange = (e) => {
22
- const newValue = e.target.value;
23
- setLocalValue(newValue);
24
- props.onValueChange?.(newValue);
25
- };
26
- return (jsxRuntime.jsx(inputtext.InputText, { type: "date", value: localValue, onChange: handleChange, required: required, invalid: !isValid, placeholder: props.title }));
27
- };
28
- DatePickerField.displayName = 'CommandFormField';
29
-
30
- exports.DatePickerField = DatePickerField;
31
- //# sourceMappingURL=DatePickerField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DatePickerField.js","sources":["../../../CommandForm/DatePickerField.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 } from 'react';\nimport { InputText } from 'primereact/inputtext';\nimport { useCommandFormContext } from './CommandForm';\n\nexport interface DatePickerFieldProps<TCommand> {\n icon?: React.ReactElement;\n value: PropertyAccessor<TCommand>;\n onChange?: (value: unknown) => void;\n currentValue?: string;\n onValueChange?: (value: string) => void;\n required?: boolean;\n title?: string;\n description?: string;\n propertyDescriptor?: PropertyDescriptor;\n fieldName?: string;\n}\n\nexport const DatePickerField = <TCommand,>(props: DatePickerFieldProps<TCommand>) => {\n const [localValue, setLocalValue] = useState(props.currentValue || '');\n const required = props.required ?? true;\n const isValid = !required || localValue.trim().length > 0;\n const { setFieldValidity } = useCommandFormContext();\n\n useEffect(() => {\n setLocalValue(props.currentValue || '');\n }, [props.currentValue]);\n\n useEffect(() => {\n if (props.fieldName) {\n setFieldValidity(props.fieldName, isValid);\n }\n }, [isValid, props.fieldName, setFieldValidity]);\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n setLocalValue(newValue);\n props.onValueChange?.(newValue);\n };\n\n return (\n <InputText\n type=\"date\"\n value={localValue}\n onChange={handleChange}\n required={required}\n invalid={!isValid}\n placeholder={props.title}\n />\n );\n};\n\nDatePickerField.displayName = 'CommandFormField';\n"],"names":["useState","useCommandFormContext","useEffect","_jsx","InputText"],"mappings":";;;;;;;AAsBO,MAAM,eAAe,GAAG,CAAY,KAAqC,KAAI;AAChF,IAAA,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC;AACtE,IAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,IAAI;AACvC,IAAA,MAAM,OAAO,GAAG,CAAC,QAAQ,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;AACzD,IAAA,MAAM,EAAE,gBAAgB,EAAE,GAAGC,iCAAqB,EAAE;IAEpDC,eAAS,CAAC,MAAK;AACX,QAAA,aAAa,CAAC,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC;AAC3C,IAAA,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAExBA,eAAS,CAAC,MAAK;AACX,QAAA,IAAI,KAAK,CAAC,SAAS,EAAE;AACjB,YAAA,gBAAgB,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC;QAC9C;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;AAEhD,IAAA,MAAM,YAAY,GAAG,CAAC,CAAsC,KAAI;AAC5D,QAAA,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK;QAC/B,aAAa,CAAC,QAAQ,CAAC;AACvB,QAAA,KAAK,CAAC,aAAa,GAAG,QAAQ,CAAC;AACnC,IAAA,CAAC;AAED,IAAA,QACIC,cAAA,CAACC,mBAAS,EAAA,EACN,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,CAAC,OAAO,EACjB,WAAW,EAAE,KAAK,CAAC,KAAK,EAAA,CAC1B;AAEV;AAEA,eAAe,CAAC,WAAW,GAAG,kBAAkB;;;;"}
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var React = require('react');
5
- var Dropdown = require('../Dropdown/Dropdown.js');
6
- var CommandForm = require('./CommandForm.js');
7
-
8
- const DropdownField = (props) => {
9
- const [localValue, setLocalValue] = React.useState(props.currentValue);
10
- const required = props.required ?? true;
11
- const isValid = !required || localValue !== null && localValue !== undefined;
12
- const { setFieldValidity } = CommandForm.useCommandFormContext();
13
- React.useEffect(() => {
14
- setLocalValue(props.currentValue);
15
- }, [props.currentValue]);
16
- React.useEffect(() => {
17
- if (props.fieldName) {
18
- setFieldValidity(props.fieldName, isValid);
19
- }
20
- }, [isValid, props.fieldName, setFieldValidity]);
21
- const handleChange = (e) => {
22
- const newValue = e.value;
23
- setLocalValue(newValue);
24
- props.onValueChange?.(newValue);
25
- };
26
- return (jsxRuntime.jsx(Dropdown.Dropdown, { value: localValue, onChange: handleChange, options: props.options, optionLabel: props.optionLabelField, optionValue: props.optionIdField, placeholder: props.placeholder || props.title, required: required, invalid: !isValid, className: "w-full" }));
27
- };
28
- DropdownField.displayName = 'CommandFormField';
29
-
30
- exports.DropdownField = DropdownField;
31
- //# sourceMappingURL=DropdownField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DropdownField.js","sources":["../../../CommandForm/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 { PropertyAccessor } from '@cratis/fundamentals';\nimport { PropertyDescriptor } from '@cratis/arc/reflection';\nimport React, { useState, useEffect } from 'react';\nimport { DropdownChangeEvent } from 'primereact/dropdown';\nimport { Dropdown } from '../Dropdown';\nimport { useCommandFormContext } from './CommandForm';\n\nexport interface DropdownFieldProps<TCommand, TOption> {\n icon?: React.ReactElement;\n value: PropertyAccessor<TCommand>;\n options: TOption[];\n optionIdField: keyof TOption;\n optionLabelField: keyof TOption;\n placeholder?: string;\n onChange?: (value: unknown) => void;\n currentValue?: unknown;\n onValueChange?: (value: unknown) => void;\n required?: boolean;\n title?: string;\n description?: string;\n propertyDescriptor?: PropertyDescriptor;\n fieldName?: string;\n}\n\nexport const DropdownField = <TCommand, TOption>(props: DropdownFieldProps<TCommand, TOption>) => {\n const [localValue, setLocalValue] = useState(props.currentValue);\n const required = props.required ?? true;\n const isValid = !required || localValue !== null && localValue !== undefined;\n const { setFieldValidity } = useCommandFormContext();\n\n useEffect(() => {\n setLocalValue(props.currentValue);\n }, [props.currentValue]);\n\n useEffect(() => {\n if (props.fieldName) {\n setFieldValidity(props.fieldName, isValid);\n }\n }, [isValid, props.fieldName, setFieldValidity]);\n\n const handleChange = (e: DropdownChangeEvent) => {\n const newValue = e.value;\n setLocalValue(newValue);\n props.onValueChange?.(newValue);\n };\n\n return (\n <Dropdown\n value={localValue}\n onChange={handleChange}\n options={props.options}\n optionLabel={props.optionLabelField as string}\n optionValue={props.optionIdField as string}\n placeholder={props.placeholder || props.title}\n required={required}\n invalid={!isValid}\n className=\"w-full\"\n />\n );\n};\n\nDropdownField.displayName = 'CommandFormField';\n"],"names":["useState","useCommandFormContext","useEffect","_jsx","Dropdown"],"mappings":";;;;;;;AA2BO,MAAM,aAAa,GAAG,CAAoB,KAA4C,KAAI;AAC7F,IAAA,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC,YAAY,CAAC;AAChE,IAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,IAAI;AACvC,IAAA,MAAM,OAAO,GAAG,CAAC,QAAQ,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,KAAK,SAAS;AAC5E,IAAA,MAAM,EAAE,gBAAgB,EAAE,GAAGC,iCAAqB,EAAE;IAEpDC,eAAS,CAAC,MAAK;AACX,QAAA,aAAa,CAAC,KAAK,CAAC,YAAY,CAAC;AACrC,IAAA,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAExBA,eAAS,CAAC,MAAK;AACX,QAAA,IAAI,KAAK,CAAC,SAAS,EAAE;AACjB,YAAA,gBAAgB,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC;QAC9C;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;AAEhD,IAAA,MAAM,YAAY,GAAG,CAAC,CAAsB,KAAI;AAC5C,QAAA,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK;QACxB,aAAa,CAAC,QAAQ,CAAC;AACvB,QAAA,KAAK,CAAC,aAAa,GAAG,QAAQ,CAAC;AACnC,IAAA,CAAC;IAED,QACIC,cAAA,CAACC,iBAAQ,EAAA,EACL,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,WAAW,EAAE,KAAK,CAAC,gBAA0B,EAC7C,WAAW,EAAE,KAAK,CAAC,aAAuB,EAC1C,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,KAAK,EAC7C,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,CAAC,OAAO,EACjB,SAAS,EAAC,QAAQ,EAAA,CACpB;AAEV;AAEA,aAAa,CAAC,WAAW,GAAG,kBAAkB;;;;"}
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var React = require('react');
5
- var inputtext = require('primereact/inputtext');
6
- var CommandForm = require('./CommandForm.js');
7
-
8
- const InputTextField = (props) => {
9
- const [localValue, setLocalValue] = React.useState(props.currentValue || '');
10
- const required = props.required ?? true;
11
- const isValid = !required || localValue.trim().length > 0;
12
- const { setFieldValidity } = CommandForm.useCommandFormContext();
13
- const inputType = props.propertyDescriptor?.type === Number ? 'number' : 'text';
14
- React.useEffect(() => {
15
- setLocalValue(props.currentValue || '');
16
- }, [props.currentValue]);
17
- React.useEffect(() => {
18
- if (props.fieldName) {
19
- setFieldValidity(props.fieldName, isValid);
20
- }
21
- }, [isValid, props.fieldName, setFieldValidity]);
22
- const handleChange = (e) => {
23
- const newValue = e.target.value;
24
- setLocalValue(newValue);
25
- props.onValueChange?.(newValue);
26
- };
27
- return (jsxRuntime.jsx(inputtext.InputText, { type: inputType, value: localValue, onChange: handleChange, required: required, invalid: !isValid, placeholder: props.title }));
28
- };
29
- InputTextField.displayName = 'CommandFormField';
30
-
31
- exports.InputTextField = InputTextField;
32
- //# sourceMappingURL=InputTextField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InputTextField.js","sources":["../../../CommandForm/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 { PropertyAccessor } from '@cratis/fundamentals';\nimport { PropertyDescriptor } from '@cratis/arc/reflection';\nimport React, { useState, useEffect } from 'react';\nimport { InputText } from 'primereact/inputtext';\nimport { useCommandFormContext } from './CommandForm';\n\nexport interface InputTextFieldProps<TCommand> {\n icon?: React.ReactElement;\n value: PropertyAccessor<TCommand>;\n onChange?: (value: unknown) => void;\n currentValue?: string;\n onValueChange?: (value: string) => void;\n required?: boolean;\n title?: string;\n description?: string;\n propertyDescriptor?: PropertyDescriptor;\n fieldName?: string;\n}\n\nexport const InputTextField = <TCommand,>(props: InputTextFieldProps<TCommand>) => {\n const [localValue, setLocalValue] = useState(props.currentValue || '');\n const required = props.required ?? true;\n const isValid = !required || localValue.trim().length > 0;\n const { setFieldValidity } = useCommandFormContext();\n\n // Determine input type based on property descriptor\n const inputType = props.propertyDescriptor?.type === Number ? 'number' : 'text';\n\n // Update local value when prop changes from outside\n useEffect(() => {\n setLocalValue(props.currentValue || '');\n }, [props.currentValue]);\n\n // Report validity changes\n useEffect(() => {\n if (props.fieldName) {\n setFieldValidity(props.fieldName, isValid);\n }\n }, [isValid, props.fieldName, setFieldValidity]);\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = e.target.value;\n setLocalValue(newValue);\n props.onValueChange?.(newValue);\n };\n\n return (\n <InputText\n type={inputType}\n value={localValue}\n onChange={handleChange}\n required={required}\n invalid={!isValid}\n placeholder={props.title}\n />\n );\n};\n\nInputTextField.displayName = 'CommandFormField';\n"],"names":["useState","useCommandFormContext","useEffect","_jsx","InputText"],"mappings":";;;;;;;AAsBO,MAAM,cAAc,GAAG,CAAY,KAAoC,KAAI;AAC9E,IAAA,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC;AACtE,IAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,IAAI;AACvC,IAAA,MAAM,OAAO,GAAG,CAAC,QAAQ,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;AACzD,IAAA,MAAM,EAAE,gBAAgB,EAAE,GAAGC,iCAAqB,EAAE;AAGpD,IAAA,MAAM,SAAS,GAAG,KAAK,CAAC,kBAAkB,EAAE,IAAI,KAAK,MAAM,GAAG,QAAQ,GAAG,MAAM;IAG/EC,eAAS,CAAC,MAAK;AACX,QAAA,aAAa,CAAC,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC;AAC3C,IAAA,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAGxBA,eAAS,CAAC,MAAK;AACX,QAAA,IAAI,KAAK,CAAC,SAAS,EAAE;AACjB,YAAA,gBAAgB,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC;QAC9C;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;AAEhD,IAAA,MAAM,YAAY,GAAG,CAAC,CAAsC,KAAI;AAC5D,QAAA,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,KAAK;QAC/B,aAAa,CAAC,QAAQ,CAAC;AACvB,QAAA,KAAK,CAAC,aAAa,GAAG,QAAQ,CAAC;AACnC,IAAA,CAAC;AAED,IAAA,QACIC,cAAA,CAACC,mBAAS,EAAA,EACN,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,UAAU,EACjB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,CAAC,OAAO,EACjB,WAAW,EAAE,KAAK,CAAC,KAAK,EAAA,CAC1B;AAEV;AAEA,cAAc,CAAC,WAAW,GAAG,kBAAkB;;;;"}