@cratis/components 4.42.2 → 4.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compat-manifest.json +67 -13
- package/dist/esm/Chat/ChatTopicEmptyMessage.d.ts +9 -0
- package/dist/esm/Chat/ChatTopicEmptyMessage.d.ts.map +1 -0
- package/dist/esm/Chat/ChatTopicEmptyMessage.js +19 -0
- package/dist/esm/Chat/ChatTopicEmptyMessage.js.map +1 -0
- package/dist/esm/Chat/ChatTopicList.d.ts +2 -2
- package/dist/esm/Chat/ChatTopicList.d.ts.map +1 -1
- package/dist/esm/Chat/ChatTopicList.js +5 -20
- package/dist/esm/Chat/ChatTopicList.js.map +1 -1
- package/dist/esm/Chat/ChatTopicRow.d.ts +22 -0
- package/dist/esm/Chat/ChatTopicRow.d.ts.map +1 -0
- package/dist/esm/Chat/ChatTopicRow.js +23 -0
- package/dist/esm/Chat/ChatTopicRow.js.map +1 -0
- package/dist/esm/Chat/ChatTopicStartButton.d.ts +8 -0
- package/dist/esm/Chat/ChatTopicStartButton.d.ts.map +1 -0
- package/dist/esm/Chat/ChatTopicStartButton.js +7 -0
- package/dist/esm/Chat/ChatTopicStartButton.js.map +1 -0
- package/dist/esm/CommandForm/fields/ChipsField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/ChipsField.js +2 -6
- package/dist/esm/CommandForm/fields/ChipsField.js.map +1 -1
- package/dist/esm/CommandForm/fields/ChipsRoot.d.ts +15 -0
- package/dist/esm/CommandForm/fields/ChipsRoot.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/ChipsRoot.js +11 -0
- package/dist/esm/CommandForm/fields/ChipsRoot.js.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordField.d.ts.map +1 -1
- package/dist/esm/CommandForm/fields/PasswordField.js +4 -14
- package/dist/esm/CommandForm/fields/PasswordField.js.map +1 -1
- package/dist/esm/CommandForm/fields/PasswordInput.d.ts +17 -0
- package/dist/esm/CommandForm/fields/PasswordInput.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordInput.js +7 -0
- package/dist/esm/CommandForm/fields/PasswordInput.js.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordRoot.d.ts +15 -0
- package/dist/esm/CommandForm/fields/PasswordRoot.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordRoot.js +7 -0
- package/dist/esm/CommandForm/fields/PasswordRoot.js.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordToggle.d.ts +13 -0
- package/dist/esm/CommandForm/fields/PasswordToggle.d.ts.map +1 -0
- package/dist/esm/CommandForm/fields/PasswordToggle.js +9 -0
- package/dist/esm/CommandForm/fields/PasswordToggle.js.map +1 -0
- package/dist/esm/DataTables/TablePaginatorImplementation.js +1 -1
- package/dist/esm/Dialogs/DialogImplementation.js +1 -1
- package/dist/esm/Dropdown/useDropdownState.js +1 -1
- package/dist/esm/Filter/FilterPanel.d.ts +69 -0
- package/dist/esm/Filter/FilterPanel.d.ts.map +1 -1
- package/dist/esm/Filter/FilterPanel.js +6 -21
- package/dist/esm/Filter/FilterPanel.js.map +1 -1
- package/dist/esm/Filter/FilterPanelContent.d.ts +14 -0
- package/dist/esm/Filter/FilterPanelContent.d.ts.map +1 -0
- package/dist/esm/Filter/FilterPanelContent.js +8 -0
- package/dist/esm/Filter/FilterPanelContent.js.map +1 -0
- package/dist/esm/Filter/usePortalTarget.d.ts +13 -0
- package/dist/esm/Filter/usePortalTarget.d.ts.map +1 -0
- package/dist/esm/Filter/usePortalTarget.js +24 -0
- package/dist/esm/Filter/usePortalTarget.js.map +1 -0
- package/dist/esm/Notifications/ToastCloseButton.d.ts +11 -0
- package/dist/esm/Notifications/ToastCloseButton.d.ts.map +1 -0
- package/dist/esm/Notifications/ToastCloseButton.js +14 -0
- package/dist/esm/Notifications/ToastCloseButton.js.map +1 -0
- package/dist/esm/Notifications/ToastContent.d.ts +10 -0
- package/dist/esm/Notifications/ToastContent.d.ts.map +1 -0
- package/dist/esm/Notifications/ToastContent.js +7 -0
- package/dist/esm/Notifications/ToastContent.js.map +1 -0
- package/dist/esm/Notifications/Toaster.d.ts.map +1 -1
- package/dist/esm/Notifications/Toaster.js +8 -17
- package/dist/esm/Notifications/Toaster.js.map +1 -1
- package/dist/esm/Notifications/useToastAutoDismiss.d.ts +4 -0
- package/dist/esm/Notifications/useToastAutoDismiss.d.ts.map +1 -0
- package/dist/esm/Notifications/useToastAutoDismiss.js +20 -0
- package/dist/esm/Notifications/useToastAutoDismiss.js.map +1 -0
- package/dist/esm/PivotViewer/PivotViewer.d.ts +1 -1
- package/dist/esm/PivotViewer/PivotViewer.d.ts.map +1 -1
- package/dist/esm/PivotViewer/PivotViewer.js +24 -31
- package/dist/esm/PivotViewer/PivotViewer.js.map +1 -1
- package/dist/esm/PivotViewer/components/PivotViewerContent.d.ts +40 -0
- package/dist/esm/PivotViewer/components/PivotViewerContent.d.ts.map +1 -0
- package/dist/esm/PivotViewer/components/PivotViewerContent.js +13 -0
- package/dist/esm/PivotViewer/components/PivotViewerContent.js.map +1 -0
- package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.d.ts +37 -0
- package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.d.ts.map +1 -0
- package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.js +35 -0
- package/dist/esm/PivotViewer/hooks/usePivotViewerViewState.js.map +1 -0
- package/dist/esm/TimeMachine/EventCard.d.ts +9 -0
- package/dist/esm/TimeMachine/EventCard.d.ts.map +1 -0
- package/dist/esm/TimeMachine/EventCard.js +8 -0
- package/dist/esm/TimeMachine/EventCard.js.map +1 -0
- package/dist/esm/TimeMachine/EventSeparator.d.ts +11 -0
- package/dist/esm/TimeMachine/EventSeparator.d.ts.map +1 -0
- package/dist/esm/TimeMachine/EventSeparator.js +7 -0
- package/dist/esm/TimeMachine/EventSeparator.js.map +1 -0
- package/dist/esm/TimeMachine/EventTimelineItem.d.ts +14 -0
- package/dist/esm/TimeMachine/EventTimelineItem.d.ts.map +1 -0
- package/dist/esm/TimeMachine/EventTimelineItem.js +9 -0
- package/dist/esm/TimeMachine/EventTimelineItem.js.map +1 -0
- package/dist/esm/TimeMachine/EventsScrollButton.d.ts +10 -0
- package/dist/esm/TimeMachine/EventsScrollButton.d.ts.map +1 -0
- package/dist/esm/TimeMachine/EventsScrollButton.js +6 -0
- package/dist/esm/TimeMachine/EventsScrollButton.js.map +1 -0
- package/dist/esm/TimeMachine/EventsView.d.ts +1 -1
- package/dist/esm/TimeMachine/EventsView.d.ts.map +1 -1
- package/dist/esm/TimeMachine/EventsView.js +6 -39
- package/dist/esm/TimeMachine/EventsView.js.map +1 -1
- package/dist/esm/TimeMachine/useScrollEdges.d.ts +13 -0
- package/dist/esm/TimeMachine/useScrollEdges.d.ts.map +1 -0
- package/dist/esm/TimeMachine/useScrollEdges.js +40 -0
- package/dist/esm/TimeMachine/useScrollEdges.js.map +1 -0
- package/dist/esm/Toolbar/ToolbarFolder.js +1 -1
- package/dist/esm/renderer/index.d.ts +1 -1
- package/dist/esm/renderer/index.d.ts.map +1 -1
- package/dist/esm/renderer/index.js +1 -1
- package/dist/esm/renderer/manifest.d.ts.map +1 -1
- package/dist/esm/renderer/manifest.js +23 -3
- package/dist/esm/renderer/manifest.js.map +1 -1
- package/dist/esm/renderer/presentation.d.ts +45 -2
- package/dist/esm/renderer/presentation.d.ts.map +1 -1
- package/dist/esm/renderer/presentation.js +113 -29
- package/dist/esm/renderer/presentation.js.map +1 -1
- package/dist/esm/renderer/resolve.d.ts +4 -1
- package/dist/esm/renderer/resolve.d.ts.map +1 -1
- package/dist/esm/renderer/resolve.js +24 -15
- package/dist/esm/renderer/resolve.js.map +1 -1
- package/package.json +1 -1
package/compat-manifest.json
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"@cratis/components.conformance",
|
|
11
11
|
"@cratis/components.mui",
|
|
12
12
|
"@cratis/components.primereact",
|
|
13
|
-
"@cratis/components.primereact10"
|
|
13
|
+
"@cratis/components.primereact10",
|
|
14
|
+
"@cratis/components.designsystemet"
|
|
14
15
|
],
|
|
15
16
|
"privateEvidence": [
|
|
16
17
|
{
|
|
@@ -60,7 +61,8 @@
|
|
|
60
61
|
"@cratis/components.conformance": ">=4 <5",
|
|
61
62
|
"@cratis/components.mui": ">=4 <5",
|
|
62
63
|
"@cratis/components.primereact": ">=4 <5",
|
|
63
|
-
"@cratis/components.primereact10": ">=4 <5"
|
|
64
|
+
"@cratis/components.primereact10": ">=4 <5",
|
|
65
|
+
"@cratis/components.designsystemet": ">=4 <5"
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
68
|
},
|
|
@@ -68,7 +70,7 @@
|
|
|
68
70
|
{
|
|
69
71
|
"name": "@cratis/components",
|
|
70
72
|
"role": "core",
|
|
71
|
-
"version": "4.
|
|
73
|
+
"version": "4.43.0",
|
|
72
74
|
"releaseMajorRange": ">=4 <5",
|
|
73
75
|
"independentRelease": false,
|
|
74
76
|
"private": false,
|
|
@@ -92,7 +94,7 @@
|
|
|
92
94
|
{
|
|
93
95
|
"name": "@cratis/eslint-plugin-components",
|
|
94
96
|
"role": "eslint",
|
|
95
|
-
"version": "4.
|
|
97
|
+
"version": "4.43.0",
|
|
96
98
|
"releaseMajorRange": ">=4 <5",
|
|
97
99
|
"independentRelease": false,
|
|
98
100
|
"private": false,
|
|
@@ -105,7 +107,7 @@
|
|
|
105
107
|
{
|
|
106
108
|
"name": "@cratis/components.migrator",
|
|
107
109
|
"role": "migrator",
|
|
108
|
-
"version": "4.
|
|
110
|
+
"version": "4.43.0",
|
|
109
111
|
"releaseMajorRange": ">=4 <5",
|
|
110
112
|
"independentRelease": false,
|
|
111
113
|
"private": false,
|
|
@@ -116,13 +118,13 @@
|
|
|
116
118
|
{
|
|
117
119
|
"name": "@cratis/components.conformance",
|
|
118
120
|
"role": "conformance",
|
|
119
|
-
"version": "4.
|
|
121
|
+
"version": "4.43.0",
|
|
120
122
|
"releaseMajorRange": ">=4 <5",
|
|
121
123
|
"independentRelease": false,
|
|
122
124
|
"private": false,
|
|
123
125
|
"packageAccess": "public",
|
|
124
126
|
"peerDependencies": {
|
|
125
|
-
"@cratis/components": "4.
|
|
127
|
+
"@cratis/components": "4.43.0",
|
|
126
128
|
"react": "^19.0.0",
|
|
127
129
|
"react-dom": "^19.0.0"
|
|
128
130
|
},
|
|
@@ -132,13 +134,13 @@
|
|
|
132
134
|
{
|
|
133
135
|
"name": "@cratis/components.mui",
|
|
134
136
|
"role": "renderer-adapter",
|
|
135
|
-
"version": "4.
|
|
137
|
+
"version": "4.43.0",
|
|
136
138
|
"releaseMajorRange": ">=4 <5",
|
|
137
139
|
"independentRelease": false,
|
|
138
140
|
"private": false,
|
|
139
141
|
"packageAccess": "public",
|
|
140
142
|
"peerDependencies": {
|
|
141
|
-
"@cratis/components": "4.
|
|
143
|
+
"@cratis/components": "4.43.0",
|
|
142
144
|
"@emotion/react": ">=11.5 <12",
|
|
143
145
|
"@emotion/styled": ">=11.11 <12",
|
|
144
146
|
"@mui/material": ">=9 <10",
|
|
@@ -188,13 +190,13 @@
|
|
|
188
190
|
{
|
|
189
191
|
"name": "@cratis/components.primereact",
|
|
190
192
|
"role": "renderer-adapter",
|
|
191
|
-
"version": "4.
|
|
193
|
+
"version": "4.43.0",
|
|
192
194
|
"releaseMajorRange": ">=4 <5",
|
|
193
195
|
"independentRelease": false,
|
|
194
196
|
"private": false,
|
|
195
197
|
"packageAccess": "public",
|
|
196
198
|
"peerDependencies": {
|
|
197
|
-
"@cratis/components": "4.
|
|
199
|
+
"@cratis/components": "4.43.0",
|
|
198
200
|
"@primereact/core": ">=11 <12",
|
|
199
201
|
"@primereact/ui": ">=11 <12",
|
|
200
202
|
"@primeuix/themes": ">=3 <4",
|
|
@@ -256,13 +258,13 @@
|
|
|
256
258
|
{
|
|
257
259
|
"name": "@cratis/components.primereact10",
|
|
258
260
|
"role": "renderer-adapter",
|
|
259
|
-
"version": "4.
|
|
261
|
+
"version": "4.43.0",
|
|
260
262
|
"releaseMajorRange": ">=4 <5",
|
|
261
263
|
"independentRelease": false,
|
|
262
264
|
"private": false,
|
|
263
265
|
"packageAccess": "public",
|
|
264
266
|
"peerDependencies": {
|
|
265
|
-
"@cratis/components": "4.
|
|
267
|
+
"@cratis/components": "4.43.0",
|
|
266
268
|
"primereact": ">=10.9.9 <11",
|
|
267
269
|
"react": "^19.0.0",
|
|
268
270
|
"react-dom": "^19.0.0"
|
|
@@ -300,6 +302,58 @@
|
|
|
300
302
|
"tsyringe": "4.10.0"
|
|
301
303
|
}
|
|
302
304
|
}
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"name": "@cratis/components.designsystemet",
|
|
308
|
+
"role": "renderer-adapter",
|
|
309
|
+
"version": "4.43.0",
|
|
310
|
+
"releaseMajorRange": ">=4 <5",
|
|
311
|
+
"independentRelease": false,
|
|
312
|
+
"private": false,
|
|
313
|
+
"packageAccess": "public",
|
|
314
|
+
"peerDependencies": {
|
|
315
|
+
"@cratis/components": "4.43.0",
|
|
316
|
+
"@digdir/designsystemet-css": ">=1.24 <2",
|
|
317
|
+
"@digdir/designsystemet-react": ">=1.24 <2",
|
|
318
|
+
"react": "^19.0.0",
|
|
319
|
+
"react-dom": "^19.0.0"
|
|
320
|
+
},
|
|
321
|
+
"upstream": {
|
|
322
|
+
"@digdir/designsystemet-css": ">=1.24 <2",
|
|
323
|
+
"@digdir/designsystemet-react": ">=1.24 <2",
|
|
324
|
+
"react": "^19.0.0",
|
|
325
|
+
"react-dom": "^19.0.0"
|
|
326
|
+
},
|
|
327
|
+
"rendererAbi": 1,
|
|
328
|
+
"rendererProfile": "stable-presentation/v1",
|
|
329
|
+
"verifiedPeers": {
|
|
330
|
+
"minimum": {
|
|
331
|
+
"@cratis/arc": "22.16.0",
|
|
332
|
+
"@cratis/arc.react": "22.16.0",
|
|
333
|
+
"@cratis/fundamentals": "7.19.2",
|
|
334
|
+
"@digdir/designsystemet-css": "1.24.0",
|
|
335
|
+
"@digdir/designsystemet-react": "1.24.0",
|
|
336
|
+
"@types/react": "19.0.0",
|
|
337
|
+
"react": "19.0.0",
|
|
338
|
+
"react-dom": "19.0.0",
|
|
339
|
+
"reflect-metadata": "0.2.2",
|
|
340
|
+
"rxjs": "7.8.2",
|
|
341
|
+
"tsyringe": "4.10.0"
|
|
342
|
+
},
|
|
343
|
+
"current": {
|
|
344
|
+
"@cratis/arc": "22.16.0",
|
|
345
|
+
"@cratis/arc.react": "22.16.0",
|
|
346
|
+
"@cratis/fundamentals": "7.19.2",
|
|
347
|
+
"@digdir/designsystemet-css": "1.24.0",
|
|
348
|
+
"@digdir/designsystemet-react": "1.24.0",
|
|
349
|
+
"@types/react": "19.2.18",
|
|
350
|
+
"react": "19.2.8",
|
|
351
|
+
"react-dom": "19.2.8",
|
|
352
|
+
"reflect-metadata": "0.2.2",
|
|
353
|
+
"rxjs": "7.8.2",
|
|
354
|
+
"tsyringe": "4.10.0"
|
|
355
|
+
}
|
|
356
|
+
}
|
|
303
357
|
}
|
|
304
358
|
]
|
|
305
359
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ChatTopicListLabels } from './ChatTopicList.js';
|
|
2
|
+
import { ChatStatus } from './ChatStatus.js';
|
|
3
|
+
interface ChatTopicEmptyMessageProps {
|
|
4
|
+
status: ChatStatus;
|
|
5
|
+
labels?: ChatTopicListLabels;
|
|
6
|
+
}
|
|
7
|
+
export declare const ChatTopicEmptyMessage: (props: ChatTopicEmptyMessageProps) => import("react").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=ChatTopicEmptyMessage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatTopicEmptyMessage.d.ts","sourceRoot":"","sources":["../../../Chat/ChatTopicEmptyMessage.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAiB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAc,CAAC;AAE1C,UAAU,0BAA0B;IAChC,MAAM,EAAE,UAAU,CAAC;IACnB,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAChC;AAeD,eAAO,MAAM,qBAAqB,UAAW,0BAA0B,gCAItE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { ChatStatus } from './ChatStatus.js';
|
|
3
|
+
|
|
4
|
+
const StatusText = ({ status, labels }) => {
|
|
5
|
+
if (status === ChatStatus.Loading) {
|
|
6
|
+
return jsx("span", { role: 'status', children: labels?.loading ?? 'Loading topics…' }, status);
|
|
7
|
+
}
|
|
8
|
+
if (status === ChatStatus.Failed) {
|
|
9
|
+
return jsx("span", { role: 'alert', children: labels?.failed ?? 'Could not load topics.' }, status);
|
|
10
|
+
}
|
|
11
|
+
if (status === ChatStatus.Unauthorized) {
|
|
12
|
+
return jsx("span", { role: 'alert', children: labels?.unauthorized ?? 'You are not authorized to view these topics.' }, status);
|
|
13
|
+
}
|
|
14
|
+
return jsx(Fragment, { children: labels?.empty ?? 'No topics yet. Start the first one!' });
|
|
15
|
+
};
|
|
16
|
+
const ChatTopicEmptyMessage = (props) => (jsx("p", { className: 'cratis-chat-topics__empty', children: jsx(StatusText, { ...props }) }));
|
|
17
|
+
|
|
18
|
+
export { ChatTopicEmptyMessage };
|
|
19
|
+
//# sourceMappingURL=ChatTopicEmptyMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatTopicEmptyMessage.js","sources":["../../../Chat/ChatTopicEmptyMessage.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ChatTopicListLabels } from './ChatTopicList';\nimport { ChatStatus } from './ChatStatus';\n\ninterface ChatTopicEmptyMessageProps {\n status: ChatStatus;\n labels?: ChatTopicListLabels;\n}\n\nconst StatusText = ({ status, labels }: ChatTopicEmptyMessageProps) => {\n if (status === ChatStatus.Loading) {\n return <span key={status} role='status'>{labels?.loading ?? 'Loading topics…'}</span>;\n }\n if (status === ChatStatus.Failed) {\n return <span key={status} role='alert'>{labels?.failed ?? 'Could not load topics.'}</span>;\n }\n if (status === ChatStatus.Unauthorized) {\n return <span key={status} role='alert'>{labels?.unauthorized ?? 'You are not authorized to view these topics.'}</span>;\n }\n return <>{labels?.empty ?? 'No topics yet. Start the first one!'}</>;\n};\n\nexport const ChatTopicEmptyMessage = (props: ChatTopicEmptyMessageProps) => (\n <p className='cratis-chat-topics__empty'>\n <StatusText {...props} />\n </p>\n);\n"],"names":["_jsx"],"mappings":";;;AAWA,MAAM,UAAU,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,EAA8B,KAAI;AAClE,IAAA,IAAI,MAAM,KAAK,UAAU,CAAC,OAAO,EAAE;AAC/B,QAAA,OAAOA,GAAA,CAAA,MAAA,EAAA,EAAmB,IAAI,EAAC,QAAQ,EAAA,QAAA,EAAE,MAAM,EAAE,OAAO,IAAI,iBAAiB,EAAA,EAA3D,MAAM,CAA6D;IACzF;AACA,IAAA,IAAI,MAAM,KAAK,UAAU,CAAC,MAAM,EAAE;AAC9B,QAAA,OAAOA,GAAA,CAAA,MAAA,EAAA,EAAmB,IAAI,EAAC,OAAO,EAAA,QAAA,EAAE,MAAM,EAAE,MAAM,IAAI,wBAAwB,EAAA,EAAhE,MAAM,CAAkE;IAC9F;AACA,IAAA,IAAI,MAAM,KAAK,UAAU,CAAC,YAAY,EAAE;AACpC,QAAA,OAAOA,GAAA,CAAA,MAAA,EAAA,EAAmB,IAAI,EAAC,OAAO,EAAA,QAAA,EAAE,MAAM,EAAE,YAAY,IAAI,8CAA8C,EAAA,EAA5F,MAAM,CAA8F;IAC1H;AACA,IAAA,OAAOA,0BAAG,MAAM,EAAE,KAAK,IAAI,qCAAqC,GAAI;AACxE,CAAC;MAEY,qBAAqB,GAAG,CAAC,KAAiC,MACnEA,GAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,2BAA2B,YACpCA,GAAA,CAAC,UAAU,OAAK,KAAK,EAAA,CAAI,EAAA,CACzB;;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import type { BuildAvatarUrlParams } from './Kit/Avatar/index.js';
|
|
3
3
|
import type { ChatAuthor } from './ChatAuthor.js';
|
|
4
4
|
import { type ChatIdentifier } from './ChatIdentifier.js';
|
|
5
5
|
import type { ChatTopic } from './ChatTopic.js';
|
|
6
6
|
import type { ChatTopicAction } from './ChatTopicAction.js';
|
|
7
7
|
import { ChatStatus } from './ChatStatus.js';
|
|
8
|
-
import {
|
|
8
|
+
import type { RelativeTimestampLabels } from './relativeTimestamp.js';
|
|
9
9
|
/** Overrides for every label the {@link ChatTopicList} renders. Any field left unset falls back
|
|
10
10
|
* to a literal English default. */
|
|
11
11
|
export interface ChatTopicListLabels {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatTopicList.d.ts","sourceRoot":"","sources":["../../../Chat/ChatTopicList.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"ChatTopicList.d.ts","sourceRoot":"","sources":["../../../Chat/ChatTopicList.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAc,CAAC;AAEzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAc,CAAC;AAC/C,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAmB,CAAC;AAIzD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M,CAAC;IAE1D,8FAA8F;IAC9F,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAE7B,0EAA0E;IAC1E,YAAY,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;IAEzC,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,MAAM,SAAS,SAAS,GAAG,SAAS,iIAY/D,kBAAkB,CAAC,MAAM,CAAC,gCAwC5B,CAAC"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useRef } from 'react';
|
|
3
|
-
import { PersonAvatarCircle } from './Kit/Avatar/PersonAvatarCircle.js';
|
|
4
3
|
import { ChatAuthorKind } from './Kit/ChatAuthorKind.js';
|
|
5
4
|
import { chatIdentifierString } from './ChatIdentifier.js';
|
|
6
|
-
import {
|
|
5
|
+
import { ChatTopicEmptyMessage } from './ChatTopicEmptyMessage.js';
|
|
6
|
+
import { ChatTopicRow } from './ChatTopicRow.js';
|
|
7
|
+
import { ChatTopicStartButton } from './ChatTopicStartButton.js';
|
|
7
8
|
import { ChatStatus } from './ChatStatus.js';
|
|
8
9
|
import { isTopicUnnamed } from './isTopicUnnamed.js';
|
|
9
|
-
import { relativeTimestamp } from './relativeTimestamp.js';
|
|
10
10
|
import { useTopicActionFocusRecovery } from './useTopicActionFocusRecovery.js';
|
|
11
11
|
import { topicsByActivity } from './topicsByActivity.js';
|
|
12
12
|
|
|
13
|
-
const PlusIcon = () => (jsxs("svg", { width: '14', height: '14', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2.5', "aria-hidden": 'true', children: [jsx("line", { x1: '12', y1: '5', x2: '12', y2: '19' }), jsx("line", { x1: '5', y1: '12', x2: '19', y2: '12' })] }));
|
|
14
13
|
const ChatTopicList = ({ topics, status = ChatStatus.Ready, onOpen, onStart, authorOf, renderAvatar, isTopicUnnamed: isTopicUnnamed$1, buildAvatarUrl, labels, topicActions, className, }) => {
|
|
15
14
|
const unnamed = isTopicUnnamed$1 ?? isTopicUnnamed;
|
|
16
15
|
const listRef = useRef(null);
|
|
@@ -20,22 +19,8 @@ const ChatTopicList = ({ topics, status = ChatStatus.Ready, onOpen, onStart, aut
|
|
|
20
19
|
name: chatIdentifierString(authorId),
|
|
21
20
|
kind: ChatAuthorKind.User,
|
|
22
21
|
};
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
? undefined
|
|
26
|
-
: authorFor(topic.startedBy);
|
|
27
|
-
const isPending = unnamed(topic);
|
|
28
|
-
const activity = topic.lastActivity ?? topic.started;
|
|
29
|
-
const topicName = isPending ? (labels?.unnamedTopic ?? 'New topic') : topic.name;
|
|
30
|
-
const availableActions = (topicActions ?? []).filter((action) => action.isAvailable?.(topic) ?? true);
|
|
31
|
-
const topicButton = (jsxs("button", { type: 'button', className: 'cratis-chat-topics__topic', onClick: () => onOpen(topic), children: [topic.startedBy !== undefined &&
|
|
32
|
-
starter &&
|
|
33
|
-
(renderAvatar ? (renderAvatar(topic.startedBy, starter)) : (jsx(PersonAvatarCircle, { userId: chatIdentifierString(topic.startedBy), name: starter.name, hasAvatar: starter.hasAvatar ?? false, size: 28, ownerType: starter.kind === ChatAuthorKind.Agent
|
|
34
|
-
? 'Agents'
|
|
35
|
-
: 'Users', version: starter.avatarVersion, buildAvatarUrl: buildAvatarUrl }))), jsxs("span", { className: 'cratis-chat-topics__details', children: [jsx("span", { className: `cratis-chat-topics__name${isPending ? ' cratis-chat-topics__name--pending' : ''}`, children: topicName }), starter && (jsx("span", { className: 'cratis-chat-topics__started-by', children: (labels?.startedBy ?? 'Started by {name}').replace('{name}', starter.name) }))] }), activity !== undefined && (jsx("span", { className: 'cratis-chat-topics__activity', children: relativeTimestamp(activity, new Date(), labels?.timestamps) }))] }));
|
|
36
|
-
const topicKey = chatIdentifierString(topic.id);
|
|
37
|
-
return (jsxs("li", { className: availableActions.length > 0 ? 'cratis-chat-topics__row' : undefined, children: [topicButton, availableActions.length > 0 && (jsx(ChatTopicActions, { topic: topic, topicName: topicName, actions: availableActions, onActionFocus: onActionFocus(topicKey), onActionBlur: onActionBlur }))] }, topicKey));
|
|
38
|
-
}) })] }));
|
|
22
|
+
const showMessage = topics.length === 0 || status === ChatStatus.Failed || status === ChatStatus.Unauthorized;
|
|
23
|
+
return (jsxs("div", { className: `cratis-chat-topics${className ? ` ${className}` : ''}`, "aria-busy": status === ChatStatus.Loading && topics.length > 0 || undefined, children: [onStart && jsx(ChatTopicStartButton, { label: labels?.newTopic, disabled: status === ChatStatus.Unauthorized, onStart: onStart }), showMessage && jsx(ChatTopicEmptyMessage, { status: status, labels: labels }), jsx("ul", { ref: listRef, className: 'cratis-chat-topics__list', children: orderedTopics.map((topic) => (jsx(ChatTopicRow, { topic: topic, isPending: unnamed(topic), starter: topic.startedBy === undefined ? undefined : authorFor(topic.startedBy), labels: labels, availableActions: (topicActions ?? []).filter((action) => action.isAvailable?.(topic) ?? true), onOpen: onOpen, renderAvatar: renderAvatar, buildAvatarUrl: buildAvatarUrl, onActionFocus: onActionFocus, onActionBlur: onActionBlur }, chatIdentifierString(topic.id)))) })] }));
|
|
39
24
|
};
|
|
40
25
|
|
|
41
26
|
export { ChatTopicList };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatTopicList.js","sources":["../../../Chat/ChatTopicList.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 { useRef, type ReactNode } from 'react';\nimport { PersonAvatarCircle, type BuildAvatarUrlParams } from './Kit/Avatar';\nimport { ChatAuthorKind } from './Kit/ChatAuthorKind';\nimport type { ChatAuthor } from './ChatAuthor';\nimport { chatIdentifierString, type ChatIdentifier } from './ChatIdentifier';\nimport type { ChatTopic } from './ChatTopic';\nimport type { ChatTopicAction } from './ChatTopicAction';\nimport { ChatTopicActions } from './ChatTopicActions';\nimport { ChatStatus } from './ChatStatus';\nimport { isTopicUnnamed as defaultIsTopicUnnamed } from './isTopicUnnamed';\nimport { relativeTimestamp, type RelativeTimestampLabels } from './relativeTimestamp';\nimport { useTopicActionFocusRecovery } from './useTopicActionFocusRecovery';\nimport { topicsByActivity } from './topicsByActivity';\n\nconst PlusIcon = () => (\n <svg\n width='14'\n height='14'\n viewBox='0 0 24 24'\n fill='none'\n stroke='currentColor'\n strokeWidth='2.5'\n aria-hidden='true'\n >\n <line x1='12' y1='5' x2='12' y2='19' />\n <line x1='5' y1='12' x2='19' y2='12' />\n </svg>\n);\n\n/** Overrides for every label the {@link ChatTopicList} renders. Any field left unset falls back\n * to a literal English default. */\nexport interface ChatTopicListLabels {\n /** The new-topic button. Defaults to `'New topic'`. */\n newTopic?: string;\n\n /** Placeholder name for a topic that has not been named yet. Defaults to `'New topic'`. */\n unnamedTopic?: string;\n\n /** The started-by line under a topic's name. `{name}` is substituted. Defaults to `'Started by {name}'`. */\n startedBy?: string;\n\n /** Shown while loading without topics. Defaults to `'Loading topics…'`. */\n loading?: string;\n\n /** Shown when loading topics fails, alongside any existing topics. Defaults to `'Could not load topics.'`. */\n failed?: string;\n\n /** Shown when access is denied; replaces any existing topics. Defaults to `'You are not authorized to view these topics.'`. */\n unauthorized?: string;\n\n /** Shown when there are no topics yet. Defaults to `'No topics yet. Start the first one!'`. */\n empty?: string;\n\n /** Overrides for the relative last-activity timestamps. */\n timestamps?: RelativeTimestampLabels;\n}\n\n/**\n * Props for {@link ChatTopicList}.\n * @typeParam TTopic The host's topic type — anything extending {@link ChatTopic}.\n */\nexport interface ChatTopicListProps<TTopic extends ChatTopic = ChatTopic> {\n /**\n * The topics, in any order — the list orders them by most recent activity itself. Hand this\n * the array a live (observable) query delivers and the list re-renders as it changes.\n */\n topics: TTopic[];\n\n /** Query display state. Defaults to {@link ChatStatus.Ready}; existing topics remain visible on loading or failure, and unauthorized disables starting a topic. */\n status?: ChatStatus;\n\n /**\n * Invoked when a topic is picked from the list.\n * @param topic The topic that was picked.\n */\n onOpen: (topic: TTopic) => void;\n\n /**\n * Invoked when a new topic is asked for. Creating the topic is the host's business — the\n * component only raises the intent. Omit to leave the new-topic affordance off.\n */\n onStart?: () => void;\n\n /**\n * Resolves an author id into what it takes to render whoever started a topic. Omit to fall\n * back to rendering the id itself as the name.\n * @param authorId The identifier of the author to resolve.\n * @returns The author.\n */\n authorOf?: (authorId: ChatIdentifier) => ChatAuthor;\n\n /**\n * Renders the avatar for whoever started a topic, replacing the built-in initials circle.\n * @param authorId The identifier of the author.\n * @param author The resolved author, as {@link authorOf} answered.\n * @returns What to render.\n */\n renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;\n\n /**\n * Decides whether a topic counts as unnamed and renders the pending placeholder. Defaults to\n * \"no name, or only whitespace\" — override when the host's backend stores a literal\n * placeholder for unnamed topics instead.\n * @param topic The topic to check.\n * @returns True when the topic has no usable name yet.\n */\n isTopicUnnamed?: (topic: TTopic) => boolean;\n\n /** Builds the avatar image URL for topic starters. Omit to always show initials. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Overrides for every label rendered. Unset fields fall back to literal English defaults. */\n labels?: ChatTopicListLabels;\n\n /** The host's actions to offer on each topic where they are available. */\n topicActions?: ChatTopicAction<TTopic>[];\n\n /** Additional class name for the list's root element. */\n className?: string;\n}\n\n/**\n * The topics of a chat, most recently active first — pick one to open its conversation, or start\n * a new one. A topic that has not been named yet renders a placeholder in a pending style: with\n * host-side auto-naming, the name arrives through the data once the host has produced it, and\n * the placeholder simply stops being needed.\n */\nexport const ChatTopicList = <TTopic extends ChatTopic = ChatTopic>({\n topics,\n status = ChatStatus.Ready,\n onOpen,\n onStart,\n authorOf,\n renderAvatar,\n isTopicUnnamed,\n buildAvatarUrl,\n labels,\n topicActions,\n className,\n}: ChatTopicListProps<TTopic>) => {\n const unnamed = isTopicUnnamed ?? defaultIsTopicUnnamed;\n const listRef = useRef<HTMLUListElement>(null);\n const orderedTopics = status === ChatStatus.Unauthorized ? [] : topicsByActivity(topics);\n const { onActionFocus, onActionBlur } = useTopicActionFocusRecovery(\n listRef,\n orderedTopics.map((topic) => chatIdentifierString(topic.id)),\n );\n\n const authorFor = (authorId: ChatIdentifier): ChatAuthor =>\n authorOf?.(authorId) ?? {\n name: chatIdentifierString(authorId),\n kind: ChatAuthorKind.User,\n };\n\n return (\n <div className={`cratis-chat-topics${className ? ` ${className}` : ''}`} aria-busy={status === ChatStatus.Loading && topics.length > 0 || undefined}>\n {onStart && (\n <button\n type='button'\n className='cratis-chat-topics__start'\n disabled={status === ChatStatus.Unauthorized}\n onClick={onStart}\n >\n <PlusIcon />\n <span>{labels?.newTopic ?? 'New topic'}</span>\n </button>\n )}\n {(topics.length === 0 || status === ChatStatus.Failed || status === ChatStatus.Unauthorized) && (\n <p className='cratis-chat-topics__empty'>\n {status === ChatStatus.Loading ? (\n <span key={status} role='status'>{labels?.loading ?? 'Loading topics…'}</span>\n ) : status === ChatStatus.Failed ? (\n <span key={status} role='alert'>{labels?.failed ?? 'Could not load topics.'}</span>\n ) : status === ChatStatus.Unauthorized ? (\n <span key={status} role='alert'>{labels?.unauthorized ?? 'You are not authorized to view these topics.'}</span>\n ) : (\n labels?.empty ?? 'No topics yet. Start the first one!'\n )}\n </p>\n )}\n <ul ref={listRef} className='cratis-chat-topics__list'>\n {status !== ChatStatus.Unauthorized && orderedTopics.map((topic) => {\n const starter =\n topic.startedBy === undefined\n ? undefined\n : authorFor(topic.startedBy);\n const isPending = unnamed(topic);\n const activity = topic.lastActivity ?? topic.started;\n const topicName = isPending ? (labels?.unnamedTopic ?? 'New topic') : topic.name;\n const availableActions = (topicActions ?? []).filter(\n (action) => action.isAvailable?.(topic) ?? true,\n );\n\n const topicButton = (\n <button\n type='button'\n className='cratis-chat-topics__topic'\n onClick={() => onOpen(topic)}\n >\n {topic.startedBy !== undefined &&\n starter &&\n (renderAvatar ? (\n renderAvatar(topic.startedBy, starter)\n ) : (\n <PersonAvatarCircle\n userId={chatIdentifierString(topic.startedBy)}\n name={starter.name}\n hasAvatar={starter.hasAvatar ?? false}\n size={28}\n ownerType={\n starter.kind === ChatAuthorKind.Agent\n ? 'Agents'\n : 'Users'\n }\n version={starter.avatarVersion}\n buildAvatarUrl={buildAvatarUrl}\n />\n ))}\n <span className='cratis-chat-topics__details'>\n <span\n className={`cratis-chat-topics__name${isPending ? ' cratis-chat-topics__name--pending' : ''}`}\n >\n {topicName}\n </span>\n {starter && (\n <span className='cratis-chat-topics__started-by'>\n {(\n labels?.startedBy ?? 'Started by {name}'\n ).replace('{name}', starter.name)}\n </span>\n )}\n </span>\n {activity !== undefined && (\n <span className='cratis-chat-topics__activity'>\n {relativeTimestamp(\n activity,\n new Date(),\n labels?.timestamps,\n )}\n </span>\n )}\n </button>\n );\n\n const topicKey = chatIdentifierString(topic.id);\n // Reuses the message action overlay styling; keyboard focus reveals the controls.\n return (\n <li\n key={topicKey}\n className={availableActions.length > 0 ? 'cratis-chat-topics__row' : undefined}\n >\n {topicButton}\n {availableActions.length > 0 && (\n <ChatTopicActions<TTopic>\n topic={topic}\n topicName={topicName}\n actions={availableActions}\n onActionFocus={onActionFocus(topicKey)}\n onActionBlur={onActionBlur}\n />\n )}\n </li>\n );\n })}\n </ul>\n </div>\n );\n};\n"],"names":["_jsxs","_jsx","isTopicUnnamed","defaultIsTopicUnnamed"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,QAAQ,GAAG,OACbA,IAAA,CAAA,KAAA,EAAA,EACI,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EAAA,aAAA,EACL,MAAM,aAElBC,GAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAA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AAA,EAAM,SAAS,EAAC,gCAAgC,YAC3C,CACG,MAAM,EAAE,SAAS,IAAI,mBAAmB,EAC1C,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,EAAA,CAC9B,CACV,CAAA,EAAA,CACE,EACN,QAAQ,KAAK,SAAS,KACnBA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAC,8BAA8B,YACzC,iBAAiB,CACd,QAAQ,EACR,IAAI,IAAI,EAAE,EACV,MAAM,EAAE,UAAU,CACrB,EAAA,CACE,CACV,CAAA,EAAA,CACI,CACZ;oBAED,MAAM,QAAQ,GAAG,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC;oBAE/C,QACID,IAAA,CAAA,IAAA,EAAA,EAEI,SAAS,EAAE,gBAAgB,CAAC,MAAM,GAAG,CAAC,GAAG,yBAAyB,GAAG,SAAS,EAAA,QAAA,EAAA,CAE7E,WAAW,EACX,gBAAgB,CAAC,MAAM,GAAG,CAAC,KACxBC,GAAA,CAAC,gBAAgB,IACb,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,aAAa,CAAC,QAAQ,CAAC,EACtC,YAAY,EAAE,YAAY,EAAA,CAC5B,CACL,CAAA,EAAA,EAZI,QAAQ,CAaZ;AAEb,gBAAA,CAAC,CAAC,EAAA,CACD,CAAA,EAAA,CACH;AAEd;;"}
|
|
1
|
+
{"version":3,"file":"ChatTopicList.js","sources":["../../../Chat/ChatTopicList.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 { useRef, type ReactNode } from 'react';\nimport type { BuildAvatarUrlParams } from './Kit/Avatar';\nimport { ChatAuthorKind } from './Kit/ChatAuthorKind';\nimport type { ChatAuthor } from './ChatAuthor';\nimport { chatIdentifierString, type ChatIdentifier } from './ChatIdentifier';\nimport type { ChatTopic } from './ChatTopic';\nimport type { ChatTopicAction } from './ChatTopicAction';\nimport { ChatTopicEmptyMessage } from './ChatTopicEmptyMessage';\nimport { ChatTopicRow } from './ChatTopicRow';\nimport { ChatTopicStartButton } from './ChatTopicStartButton';\nimport { ChatStatus } from './ChatStatus';\nimport { isTopicUnnamed as defaultIsTopicUnnamed } from './isTopicUnnamed';\nimport type { RelativeTimestampLabels } from './relativeTimestamp';\nimport { useTopicActionFocusRecovery } from './useTopicActionFocusRecovery';\nimport { topicsByActivity } from './topicsByActivity';\n\n/** Overrides for every label the {@link ChatTopicList} renders. Any field left unset falls back\n * to a literal English default. */\nexport interface ChatTopicListLabels {\n /** The new-topic button. Defaults to `'New topic'`. */\n newTopic?: string;\n\n /** Placeholder name for a topic that has not been named yet. Defaults to `'New topic'`. */\n unnamedTopic?: string;\n\n /** The started-by line under a topic's name. `{name}` is substituted. Defaults to `'Started by {name}'`. */\n startedBy?: string;\n\n /** Shown while loading without topics. Defaults to `'Loading topics…'`. */\n loading?: string;\n\n /** Shown when loading topics fails, alongside any existing topics. Defaults to `'Could not load topics.'`. */\n failed?: string;\n\n /** Shown when access is denied; replaces any existing topics. Defaults to `'You are not authorized to view these topics.'`. */\n unauthorized?: string;\n\n /** Shown when there are no topics yet. Defaults to `'No topics yet. Start the first one!'`. */\n empty?: string;\n\n /** Overrides for the relative last-activity timestamps. */\n timestamps?: RelativeTimestampLabels;\n}\n\n/**\n * Props for {@link ChatTopicList}.\n * @typeParam TTopic The host's topic type — anything extending {@link ChatTopic}.\n */\nexport interface ChatTopicListProps<TTopic extends ChatTopic = ChatTopic> {\n /**\n * The topics, in any order — the list orders them by most recent activity itself. Hand this\n * the array a live (observable) query delivers and the list re-renders as it changes.\n */\n topics: TTopic[];\n\n /** Query display state. Defaults to {@link ChatStatus.Ready}; existing topics remain visible on loading or failure, and unauthorized disables starting a topic. */\n status?: ChatStatus;\n\n /**\n * Invoked when a topic is picked from the list.\n * @param topic The topic that was picked.\n */\n onOpen: (topic: TTopic) => void;\n\n /**\n * Invoked when a new topic is asked for. Creating the topic is the host's business — the\n * component only raises the intent. Omit to leave the new-topic affordance off.\n */\n onStart?: () => void;\n\n /**\n * Resolves an author id into what it takes to render whoever started a topic. Omit to fall\n * back to rendering the id itself as the name.\n * @param authorId The identifier of the author to resolve.\n * @returns The author.\n */\n authorOf?: (authorId: ChatIdentifier) => ChatAuthor;\n\n /**\n * Renders the avatar for whoever started a topic, replacing the built-in initials circle.\n * @param authorId The identifier of the author.\n * @param author The resolved author, as {@link authorOf} answered.\n * @returns What to render.\n */\n renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;\n\n /**\n * Decides whether a topic counts as unnamed and renders the pending placeholder. Defaults to\n * \"no name, or only whitespace\" — override when the host's backend stores a literal\n * placeholder for unnamed topics instead.\n * @param topic The topic to check.\n * @returns True when the topic has no usable name yet.\n */\n isTopicUnnamed?: (topic: TTopic) => boolean;\n\n /** Builds the avatar image URL for topic starters. Omit to always show initials. */\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n\n /** Overrides for every label rendered. Unset fields fall back to literal English defaults. */\n labels?: ChatTopicListLabels;\n\n /** The host's actions to offer on each topic where they are available. */\n topicActions?: ChatTopicAction<TTopic>[];\n\n /** Additional class name for the list's root element. */\n className?: string;\n}\n\n/**\n * The topics of a chat, most recently active first — pick one to open its conversation, or start\n * a new one. A topic that has not been named yet renders a placeholder in a pending style: with\n * host-side auto-naming, the name arrives through the data once the host has produced it, and\n * the placeholder simply stops being needed.\n */\nexport const ChatTopicList = <TTopic extends ChatTopic = ChatTopic>({\n topics,\n status = ChatStatus.Ready,\n onOpen,\n onStart,\n authorOf,\n renderAvatar,\n isTopicUnnamed,\n buildAvatarUrl,\n labels,\n topicActions,\n className,\n}: ChatTopicListProps<TTopic>) => {\n const unnamed = isTopicUnnamed ?? defaultIsTopicUnnamed;\n const listRef = useRef<HTMLUListElement>(null);\n const orderedTopics = status === ChatStatus.Unauthorized ? [] : topicsByActivity(topics);\n const { onActionFocus, onActionBlur } = useTopicActionFocusRecovery(\n listRef,\n orderedTopics.map((topic) => chatIdentifierString(topic.id)),\n );\n\n const authorFor = (authorId: ChatIdentifier): ChatAuthor =>\n authorOf?.(authorId) ?? {\n name: chatIdentifierString(authorId),\n kind: ChatAuthorKind.User,\n };\n\n const showMessage = topics.length === 0 || status === ChatStatus.Failed || status === ChatStatus.Unauthorized;\n\n return (\n <div className={`cratis-chat-topics${className ? ` ${className}` : ''}`} aria-busy={status === ChatStatus.Loading && topics.length > 0 || undefined}>\n {onStart && <ChatTopicStartButton label={labels?.newTopic} disabled={status === ChatStatus.Unauthorized} onStart={onStart} />}\n {showMessage && <ChatTopicEmptyMessage status={status} labels={labels} />}\n <ul ref={listRef} className='cratis-chat-topics__list'>\n {orderedTopics.map((topic) => (\n <ChatTopicRow<TTopic>\n key={chatIdentifierString(topic.id)}\n topic={topic}\n isPending={unnamed(topic)}\n starter={topic.startedBy === undefined ? undefined : authorFor(topic.startedBy)}\n labels={labels}\n availableActions={(topicActions ?? []).filter((action) => action.isAvailable?.(topic) ?? true)}\n onOpen={onOpen}\n renderAvatar={renderAvatar}\n buildAvatarUrl={buildAvatarUrl}\n onActionFocus={onActionFocus}\n onActionBlur={onActionBlur}\n />\n ))}\n </ul>\n </div>\n );\n};\n"],"names":["isTopicUnnamed","defaultIsTopicUnnamed","_jsxs","_jsx"],"mappings":";;;;;;;;;;;;AAqHO,MAAM,aAAa,GAAG,CAAuC,EAChE,MAAM,EACN,MAAM,GAAG,UAAU,CAAC,KAAK,EACzB,MAAM,EACN,OAAO,EACP,QAAQ,EACR,YAAY,kBACZA,gBAAc,EACd,cAAc,EACd,MAAM,EACN,YAAY,EACZ,SAAS,GACgB,KAAI;AAC7B,IAAA,MAAM,OAAO,GAAGA,gBAAc,IAAIC,cAAqB;AACvD,IAAA,MAAM,OAAO,GAAG,MAAM,CAAmB,IAAI,CAAC;AAC9C,IAAA,MAAM,aAAa,GAAG,MAAM,KAAK,UAAU,CAAC,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EAAE,OAAO,CAAC,KAAK,CAAC,EACzB,OAAO,EAAE,KAAK,CAAC,SAAS,KAAK,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,SAAS,CAAC,EAC/E,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,CAAC,YAAY,IAAI,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,WAAW,GAAG,KAAK,CAAC,IAAI,IAAI,CAAC,EAC9F,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,YAAY,IAVrB,oBAAoB,CAAC,KAAK,CAAC,EAAE,CAAC,CAWrC,CACL,CAAC,EAAA,CACD,CAAA,EAAA,CACH;AAEd;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FocusEventHandler, ReactNode } from 'react';
|
|
2
|
+
import { type BuildAvatarUrlParams } from './Kit/Avatar/index.js';
|
|
3
|
+
import type { ChatAuthor } from './ChatAuthor.js';
|
|
4
|
+
import { type ChatIdentifier } from './ChatIdentifier.js';
|
|
5
|
+
import type { ChatTopic } from './ChatTopic.js';
|
|
6
|
+
import type { ChatTopicAction } from './ChatTopicAction.js';
|
|
7
|
+
import type { ChatTopicListLabels } from './ChatTopicList.js';
|
|
8
|
+
interface ChatTopicRowProps<TTopic extends ChatTopic> {
|
|
9
|
+
topic: TTopic;
|
|
10
|
+
isPending: boolean;
|
|
11
|
+
starter?: ChatAuthor;
|
|
12
|
+
labels?: ChatTopicListLabels;
|
|
13
|
+
availableActions: ChatTopicAction<TTopic>[];
|
|
14
|
+
onOpen: (topic: TTopic) => void;
|
|
15
|
+
renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;
|
|
16
|
+
buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;
|
|
17
|
+
onActionFocus: (topicKey: string) => FocusEventHandler<HTMLElement>;
|
|
18
|
+
onActionBlur: FocusEventHandler<HTMLElement>;
|
|
19
|
+
}
|
|
20
|
+
export declare const ChatTopicRow: <TTopic extends ChatTopic>({ topic, isPending, starter, labels, availableActions, onOpen, renderAvatar, buildAvatarUrl, onActionFocus, onActionBlur, }: ChatTopicRowProps<TTopic>) => import("react").JSX.Element;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=ChatTopicRow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatTopicRow.d.ts","sourceRoot":"","sources":["../../../Chat/ChatTopicRow.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAsB,KAAK,oBAAoB,EAAE,MAAM,uBAAc,CAAC;AAE7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAc,CAAC;AAC/C,OAAO,EAAwB,KAAK,cAAc,EAAE,MAAM,qBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAiB,CAAC;AA2B3D,UAAU,iBAAiB,CAAC,MAAM,SAAS,SAAS;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,gBAAgB,EAAE,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;IAC5C,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,KAAK,SAAS,CAAC;IAC3E,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,MAAM,CAAC;IAC1D,aAAa,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACpE,YAAY,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;CAChD;AAED,eAAO,MAAM,YAAY,GAAI,MAAM,SAAS,SAAS,+HAWlD,iBAAiB,CAAC,MAAM,CAAC,gCA6C3B,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { PersonAvatarCircle } from './Kit/Avatar/PersonAvatarCircle.js';
|
|
3
|
+
import { ChatAuthorKind } from './Kit/ChatAuthorKind.js';
|
|
4
|
+
import { chatIdentifierString } from './ChatIdentifier.js';
|
|
5
|
+
import { ChatTopicActions } from './ChatTopicActions.js';
|
|
6
|
+
import { relativeTimestamp } from './relativeTimestamp.js';
|
|
7
|
+
|
|
8
|
+
const TopicStarterAvatar = ({ startedBy, starter, renderAvatar, buildAvatarUrl }) => {
|
|
9
|
+
if (renderAvatar) {
|
|
10
|
+
return jsx(Fragment, { children: renderAvatar(startedBy, starter) });
|
|
11
|
+
}
|
|
12
|
+
return (jsx(PersonAvatarCircle, { userId: chatIdentifierString(startedBy), name: starter.name, hasAvatar: starter.hasAvatar ?? false, size: 28, ownerType: starter.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users', version: starter.avatarVersion, buildAvatarUrl: buildAvatarUrl }));
|
|
13
|
+
};
|
|
14
|
+
const ChatTopicRow = ({ topic, isPending, starter, labels, availableActions, onOpen, renderAvatar, buildAvatarUrl, onActionFocus, onActionBlur, }) => {
|
|
15
|
+
const activity = topic.lastActivity ?? topic.started;
|
|
16
|
+
const topicName = isPending ? (labels?.unnamedTopic ?? 'New topic') : topic.name;
|
|
17
|
+
const topicKey = chatIdentifierString(topic.id);
|
|
18
|
+
const hasActions = availableActions.length > 0;
|
|
19
|
+
return (jsxs("li", { className: hasActions ? 'cratis-chat-topics__row' : undefined, children: [jsxs("button", { type: 'button', className: 'cratis-chat-topics__topic', onClick: () => onOpen(topic), children: [topic.startedBy !== undefined && starter && (jsx(TopicStarterAvatar, { startedBy: topic.startedBy, starter: starter, renderAvatar: renderAvatar, buildAvatarUrl: buildAvatarUrl })), jsxs("span", { className: 'cratis-chat-topics__details', children: [jsx("span", { className: `cratis-chat-topics__name${isPending ? ' cratis-chat-topics__name--pending' : ''}`, children: topicName }), starter && (jsx("span", { className: 'cratis-chat-topics__started-by', children: (labels?.startedBy ?? 'Started by {name}').replace('{name}', starter.name) }))] }), activity !== undefined && (jsx("span", { className: 'cratis-chat-topics__activity', children: relativeTimestamp(activity, new Date(), labels?.timestamps) }))] }), hasActions && (jsx(ChatTopicActions, { topic: topic, topicName: topicName, actions: availableActions, onActionFocus: onActionFocus(topicKey), onActionBlur: onActionBlur }))] }));
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { ChatTopicRow };
|
|
23
|
+
//# sourceMappingURL=ChatTopicRow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatTopicRow.js","sources":["../../../Chat/ChatTopicRow.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { FocusEventHandler, ReactNode } from 'react';\nimport { PersonAvatarCircle, type BuildAvatarUrlParams } from './Kit/Avatar';\nimport { ChatAuthorKind } from './Kit/ChatAuthorKind';\nimport type { ChatAuthor } from './ChatAuthor';\nimport { chatIdentifierString, type ChatIdentifier } from './ChatIdentifier';\nimport type { ChatTopic } from './ChatTopic';\nimport type { ChatTopicAction } from './ChatTopicAction';\nimport { ChatTopicActions } from './ChatTopicActions';\nimport type { ChatTopicListLabels } from './ChatTopicList';\nimport { relativeTimestamp } from './relativeTimestamp';\n\ninterface TopicStarterAvatarProps {\n startedBy: ChatIdentifier;\n starter: ChatAuthor;\n renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n}\n\nconst TopicStarterAvatar = ({ startedBy, starter, renderAvatar, buildAvatarUrl }: TopicStarterAvatarProps) => {\n if (renderAvatar) {\n return <>{renderAvatar(startedBy, starter)}</>;\n }\n return (\n <PersonAvatarCircle\n userId={chatIdentifierString(startedBy)}\n name={starter.name}\n hasAvatar={starter.hasAvatar ?? false}\n size={28}\n ownerType={starter.kind === ChatAuthorKind.Agent ? 'Agents' : 'Users'}\n version={starter.avatarVersion}\n buildAvatarUrl={buildAvatarUrl}\n />\n );\n};\n\ninterface ChatTopicRowProps<TTopic extends ChatTopic> {\n topic: TTopic;\n isPending: boolean;\n starter?: ChatAuthor;\n labels?: ChatTopicListLabels;\n availableActions: ChatTopicAction<TTopic>[];\n onOpen: (topic: TTopic) => void;\n renderAvatar?: (authorId: ChatIdentifier, author: ChatAuthor) => ReactNode;\n buildAvatarUrl?: (params: BuildAvatarUrlParams) => string;\n onActionFocus: (topicKey: string) => FocusEventHandler<HTMLElement>;\n onActionBlur: FocusEventHandler<HTMLElement>;\n}\n\nexport const ChatTopicRow = <TTopic extends ChatTopic>({\n topic,\n isPending,\n starter,\n labels,\n availableActions,\n onOpen,\n renderAvatar,\n buildAvatarUrl,\n onActionFocus,\n onActionBlur,\n}: ChatTopicRowProps<TTopic>) => {\n const activity = topic.lastActivity ?? topic.started;\n const topicName = isPending ? (labels?.unnamedTopic ?? 'New topic') : topic.name;\n const topicKey = chatIdentifierString(topic.id);\n const hasActions = availableActions.length > 0;\n\n // Reuses the message action overlay styling; keyboard focus reveals the controls.\n return (\n <li className={hasActions ? 'cratis-chat-topics__row' : undefined}>\n <button type='button' className='cratis-chat-topics__topic' onClick={() => onOpen(topic)}>\n {topic.startedBy !== undefined && starter && (\n <TopicStarterAvatar\n startedBy={topic.startedBy}\n starter={starter}\n renderAvatar={renderAvatar}\n buildAvatarUrl={buildAvatarUrl}\n />\n )}\n <span className='cratis-chat-topics__details'>\n <span className={`cratis-chat-topics__name${isPending ? ' cratis-chat-topics__name--pending' : ''}`}>\n {topicName}\n </span>\n {starter && (\n <span className='cratis-chat-topics__started-by'>\n {(labels?.startedBy ?? 'Started by {name}').replace('{name}', starter.name)}\n </span>\n )}\n </span>\n {activity !== undefined && (\n <span className='cratis-chat-topics__activity'>\n {relativeTimestamp(activity, new Date(), labels?.timestamps)}\n </span>\n )}\n </button>\n {hasActions && (\n <ChatTopicActions<TTopic>\n topic={topic}\n topicName={topicName}\n actions={availableActions}\n onActionFocus={onActionFocus(topicKey)}\n onActionBlur={onActionBlur}\n />\n )}\n </li>\n );\n};\n"],"names":["_jsx","_Fragment","_jsxs"],"mappings":";;;;;;;AAqBA,MAAM,kBAAkB,GAAG,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,EAAE,cAAc,EAA2B,KAAI;IACzG,IAAI,YAAY,EAAE;QACd,OAAOA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EAAG,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,GAAI;IAClD;IACA,QACID,GAAA,CAAC,kBAAkB,EAAA,EACf,MAAM,EAAE,oBAAoB,CAAC,SAAS,CAAC,EACvC,IAAI,EAAE,OAAO,CAAC,IAAI,EAClB,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,KAAK,EACrC,IAAI,EAAE,EAAE,EACR,SAAS,EAAE,OAAO,CAAC,IAAI,KAAK,cAAc,CAAC,KAAK,GAAG,QAAQ,GAAG,OAAO,EACrE,OAAO,EAAE,OAAO,CAAC,aAAa,EAC9B,cAAc,EAAE,cAAc,EAAA,CAChC;AAEV,CAAC;AAeM,MAAM,YAAY,GAAG,CAA2B,EACnD,KAAK,EACL,SAAS,EACT,OAAO,EACP,MAAM,EACN,gBAAgB,EAChB,MAAM,EACN,YAAY,EACZ,cAAc,EACd,aAAa,EACb,YAAY,GACY,KAAI;IAC5B,MAAM,QAAQ,GAAG,KAAK,CAAC,YAA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AU,CAAC,EAAA,CACzD,CACV,CAAA,EAAA,CACI,EACR,UAAU,KACPA,GAAA,CAAC,gBAAgB,IACb,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,gBAAgB,EACzB,aAAa,EAAE,aAAa,CAAC,QAAQ,CAAC,EACtC,YAAY,EAAE,YAAY,GAC5B,CACL,CAAA,EAAA,CACA;AAEb;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface ChatTopicStartButtonProps {
|
|
2
|
+
label?: string;
|
|
3
|
+
disabled: boolean;
|
|
4
|
+
onStart: () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const ChatTopicStartButton: ({ label, disabled, onStart }: ChatTopicStartButtonProps) => import("react").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=ChatTopicStartButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatTopicStartButton.d.ts","sourceRoot":"","sources":["../../../Chat/ChatTopicStartButton.tsx"],"names":[],"mappings":"AAkBA,UAAU,yBAAyB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,eAAO,MAAM,oBAAoB,iCAAkC,yBAAyB,gCAK3F,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
const PlusIcon = () => (jsxs("svg", { width: '14', height: '14', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2.5', "aria-hidden": 'true', children: [jsx("line", { x1: '12', y1: '5', x2: '12', y2: '19' }), jsx("line", { x1: '5', y1: '12', x2: '19', y2: '12' })] }));
|
|
4
|
+
const ChatTopicStartButton = ({ label, disabled, onStart }) => (jsxs("button", { type: 'button', className: 'cratis-chat-topics__start', disabled: disabled, onClick: onStart, children: [jsx(PlusIcon, {}), jsx("span", { children: label ?? 'New topic' })] }));
|
|
5
|
+
|
|
6
|
+
export { ChatTopicStartButton };
|
|
7
|
+
//# sourceMappingURL=ChatTopicStartButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatTopicStartButton.js","sources":["../../../Chat/ChatTopicStartButton.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\nconst PlusIcon = () => (\n <svg\n width='14'\n height='14'\n viewBox='0 0 24 24'\n fill='none'\n stroke='currentColor'\n strokeWidth='2.5'\n aria-hidden='true'\n >\n <line x1='12' y1='5' x2='12' y2='19' />\n <line x1='5' y1='12' x2='19' y2='12' />\n </svg>\n);\n\ninterface ChatTopicStartButtonProps {\n label?: string;\n disabled: boolean;\n onStart: () => void;\n}\n\nexport const ChatTopicStartButton = ({ label, disabled, onStart }: ChatTopicStartButtonProps) => (\n <button type='button' className='cratis-chat-topics__start' disabled={disabled} onClick={onStart}>\n <PlusIcon />\n <span>{label ?? 'New topic'}</span>\n </button>\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;AAGA,MAAM,QAAQ,GAAG,OACbA,IAAA,CAAA,KAAA,EAAA,EACI,KAAK,EAAC,IAAI,EACV,MAAM,EAAC,IAAI,EACX,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,KAAK,EAAA,aAAA,EACL,MAAM,aAElBC,GAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG,EACvCA,GAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAC,EAAE,EAAC,IAAI,EAAA,CAAG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AAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,UAAU,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACtB;AA+CD,wEAAwE;AACxE,eAAO,MAAM,UAAU,uNAErB,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { asCommandFormField } from '@cratis/arc.react/commands';
|
|
3
3
|
import { useFieldAccessibility } from './fieldAccessibility.js';
|
|
4
|
-
import { classNames } from '../../ClassNames/classNames.js';
|
|
5
4
|
import { ChipsInput } from './ChipsInput.js';
|
|
6
5
|
import { ChipsItem } from './ChipsItem.js';
|
|
6
|
+
import { ChipsRoot } from './ChipsRoot.js';
|
|
7
7
|
import { useChipsDraft } from './useChipsDraft.js';
|
|
8
8
|
|
|
9
9
|
const ChipsControl = (props) => {
|
|
@@ -13,11 +13,7 @@ const ChipsControl = (props) => {
|
|
|
13
13
|
ariaLabel: props.pt?.input?.['aria-label'],
|
|
14
14
|
ariaDescribedBy: props.pt?.input?.['aria-describedby'],
|
|
15
15
|
});
|
|
16
|
-
return (jsxs(
|
|
17
|
-
props.onBlur?.();
|
|
18
|
-
if (props.addOnBlur && !event.currentTarget.contains(event.relatedTarget))
|
|
19
|
-
commit();
|
|
20
|
-
}, "data-cratis-part": 'root', "data-cratis-component": 'ChipsField', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-readonly": props.pt?.input?.readOnly || undefined, children: [props.value.map((item, index) => (jsx(ChipsItem, { item: item, index: index, removeAriaLabel: props.removeAriaLabel, parts: props.pt, onRemove: () => props.onChange(props.value.filter((_, itemIndex) => itemIndex !== index)) }, `${item}-${index}`))), jsx(ChipsInput, { id: accessibility.controlId, ariaLabel: accessibility.ariaLabel, ariaDescribedBy: accessibility.ariaDescribedBy, draft: draft, onDraftChange: setDraft, onCommit: commit, placeholder: props.placeholder, invalid: props.invalid, parts: props.pt }), accessibility.hiddenError] }));
|
|
16
|
+
return (jsxs(ChipsRoot, { parts: props.pt, className: props.className, invalid: props.invalid, addOnBlur: props.addOnBlur, onBlur: props.onBlur, onCommit: commit, children: [props.value.map((item, index) => (jsx(ChipsItem, { item: item, index: index, removeAriaLabel: props.removeAriaLabel, parts: props.pt, onRemove: () => props.onChange(props.value.filter((_, itemIndex) => itemIndex !== index)) }, `${item}-${index}`))), jsx(ChipsInput, { id: accessibility.controlId, ariaLabel: accessibility.ariaLabel, ariaDescribedBy: accessibility.ariaDescribedBy, draft: draft, onDraftChange: setDraft, onCommit: commit, placeholder: props.placeholder, invalid: props.invalid, parts: props.pt }), accessibility.hiddenError] }));
|
|
21
17
|
};
|
|
22
18
|
const ChipsField = asCommandFormField(ChipsControl, {
|
|
23
19
|
defaultValue: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChipsField.js","sources":["../../../../CommandForm/fields/ChipsField.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { HTMLAttributes, InputHTMLAttributes } from 'react';\nimport { asCommandFormField, type WrappedFieldProps } from '@cratis/arc.react/commands';\nimport {\n useFieldAccessibility,\n type FieldAccessibilityProps,\n} from './fieldAccessibility';\nimport {
|
|
1
|
+
{"version":3,"file":"ChipsField.js","sources":["../../../../CommandForm/fields/ChipsField.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { HTMLAttributes, InputHTMLAttributes } from 'react';\nimport { asCommandFormField, type WrappedFieldProps } from '@cratis/arc.react/commands';\nimport {\n useFieldAccessibility,\n type FieldAccessibilityProps,\n} from './fieldAccessibility';\nimport { ChipsInput } from './ChipsInput';\nimport { ChipsItem } from './ChipsItem';\nimport { ChipsRoot } from './ChipsRoot';\nimport { useChipsDraft } from './useChipsDraft';\nimport type { ExactPartKeys } from '../../types/ExactPartKeys';\nimport type { PartsOf } from '../../types/parts';\n\n/** Stable part attributes for {@link ChipsField}. */\nexport interface ChipsParts {\n /** Field wrapper. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** One selected chip. */\n item?: HTMLAttributes<HTMLSpanElement>;\n /** Chip removal button. */\n remove?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n /** Native draft-value input. */\n input?: InputHTMLAttributes<HTMLInputElement>;\n}\n\nconst chipsPartsMatchManifest: ExactPartKeys<ChipsParts, PartsOf<'ChipsField'>> = true;\nvoid chipsPartsMatchManifest;\n\ninterface ChipsFieldComponentProps\n extends WrappedFieldProps<string[]>, FieldAccessibilityProps {\n placeholder?: string;\n max?: number;\n separator?: string;\n addOnBlur?: boolean;\n allowDuplicate?: boolean;\n /** Builds a remove-button label, or supplies one shared localized label. */\n removeAriaLabel?: string | ((item: string, index: number) => string);\n className?: string;\n pt?: ChipsParts;\n ptOptions?: object;\n unstyled?: boolean;\n}\n\nconst ChipsControl = (props: ChipsFieldComponentProps) => {\n const { draft, setDraft, commit } = useChipsDraft(props);\n const accessibility = useFieldAccessibility(props, {\n id: props.pt?.input?.id,\n ariaLabel: props.pt?.input?.['aria-label'],\n ariaDescribedBy: props.pt?.input?.['aria-describedby'],\n });\n\n return (\n <ChipsRoot\n parts={props.pt}\n className={props.className}\n invalid={props.invalid}\n addOnBlur={props.addOnBlur}\n onBlur={props.onBlur}\n onCommit={commit}\n >\n {props.value.map((item, index) => (\n <ChipsItem\n key={`${item}-${index}`}\n item={item}\n index={index}\n removeAriaLabel={props.removeAriaLabel}\n parts={props.pt}\n onRemove={() =>\n props.onChange(props.value.filter((_, itemIndex) => itemIndex !== index))\n }\n />\n ))}\n <ChipsInput\n id={accessibility.controlId}\n ariaLabel={accessibility.ariaLabel}\n ariaDescribedBy={accessibility.ariaDescribedBy}\n draft={draft}\n onDraftChange={setDraft}\n onCommit={commit}\n placeholder={props.placeholder}\n invalid={props.invalid}\n parts={props.pt}\n />\n {accessibility.hiddenError}\n </ChipsRoot>\n );\n};\n\n/** A token input bound to a string array property on an Arc command. */\nexport const ChipsField = asCommandFormField<ChipsFieldComponentProps>(ChipsControl, {\n defaultValue: [],\n});\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;AA8CA,MAAM,YAAY,GAAG,CAAC,KAA+B,KAAI;AACrD,IAAA,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC,KAAK,CAAC;AACxD,IAAA,MAAM,aAAa,GAAG,qBAAqB,CAAC,KAAK,EAAE;AAC/C,QAAA,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;QACvB,SAAS,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,GAAG,YAAY,CAAC;QAC1C,eAAe,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,GAAG,kBAAkB,CAAC;AACzD,KAAA,CAAC;AAEF,IAAA,QACIA,IAAA,CAAC,SAAS,EAAA,EACN,KAAK,EAAE,KAAK,CAAC,EAAE,EACf,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,SAAS,EAAE,KAAK,CAAC,SAAS,EAC1B,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,QAAQ,EAAE,MAAM,EAAA,QAAA,EAAA,CAEf,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,MACzBC,GAAA,CAAC,SAAS,EAAA,EAEN,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,eAAe,EAAE,KAAK,CAAC,eAAe,EACtC,KAAK,EAAE,KAAK,CAAC,EAAE,EACf,QAAQ,EAAE,MACN,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,SAAS,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,IANxE,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,KAAK,EAAE,CAQzB,CACL,CAAC,EACFA,GAAA,CAAC,UAAU,EAAA,EACP,EAAE,EAAE,aAAa,CAAC,SAAS,EAC3B,SAAS,EAAE,aAAa,CAAC,SAAS,EAClC,eAAe,EAAE,aAAa,CAAC,eAAe,EAC9C,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,QAAQ,EACvB,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,KAAK,CAAC,WAAW,EAC9B,OAAO,EAAE,KAAK,CAAC,OAAO,EACtB,KAAK,EAAE,KAAK,CAAC,EAAE,GACjB,EACD,aAAa,CAAC,WAAW,CAAA,EAAA,CAClB;AAEpB,CAAC;AAGM,MAAM,UAAU,GAAG,kBAAkB,CAA2B,YAAY,EAAE;AACjF,IAAA,YAAY,EAAE,EAAE;AACnB,CAAA;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ChipsParts } from './ChipsField.js';
|
|
3
|
+
/** Props for {@link ChipsRoot}. */
|
|
4
|
+
export interface ChipsRootProps {
|
|
5
|
+
parts?: ChipsParts;
|
|
6
|
+
className?: string;
|
|
7
|
+
invalid?: boolean;
|
|
8
|
+
addOnBlur?: boolean;
|
|
9
|
+
onBlur?: () => void;
|
|
10
|
+
onCommit: () => void;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
/** The field wrapper of a chips field, which commits the draft when focus leaves it. */
|
|
14
|
+
export declare const ChipsRoot: ({ parts: pt, className, invalid, addOnBlur, onBlur, onCommit, children }: ChipsRootProps) => import("react").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=ChipsRoot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChipsRoot.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/ChipsRoot.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAc,CAAC;AAE/C,mCAAmC;AACnC,MAAM,WAAW,cAAc;IAC3B,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED,wFAAwF;AACxF,eAAO,MAAM,SAAS,6EAA8E,cAAc,gCAiBjH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { classNames } from '../../ClassNames/classNames.js';
|
|
3
|
+
|
|
4
|
+
const ChipsRoot = ({ parts: pt, className, invalid, addOnBlur, onBlur, onCommit, children }) => (jsx("div", { ...pt?.root, className: classNames('cratis-chips-field', 'cratis:w-full', pt?.root?.className, className), onBlur: (event) => {
|
|
5
|
+
onBlur?.();
|
|
6
|
+
if (addOnBlur && !event.currentTarget.contains(event.relatedTarget))
|
|
7
|
+
onCommit();
|
|
8
|
+
}, "data-cratis-part": 'root', "data-cratis-component": 'ChipsField', "data-disabled": pt?.input?.disabled || undefined, "data-invalid": invalid || undefined, "data-readonly": pt?.input?.readOnly || undefined, children: children }));
|
|
9
|
+
|
|
10
|
+
export { ChipsRoot };
|
|
11
|
+
//# sourceMappingURL=ChipsRoot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChipsRoot.js","sources":["../../../../CommandForm/fields/ChipsRoot.tsx"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport type { ReactNode } from 'react';\nimport { classNames } from '../../ClassNames/classNames';\nimport type { ChipsParts } from './ChipsField';\n\n/** Props for {@link ChipsRoot}. */\nexport interface ChipsRootProps {\n parts?: ChipsParts;\n className?: string;\n invalid?: boolean;\n addOnBlur?: boolean;\n onBlur?: () => void;\n onCommit: () => void;\n children: ReactNode;\n}\n\n/** The field wrapper of a chips field, which commits the draft when focus leaves it. */\nexport const ChipsRoot = ({ parts: pt, className, invalid, addOnBlur, onBlur, onCommit, children }: ChipsRootProps) => (\n <div\n {...pt?.root}\n className={classNames('cratis-chips-field', 'cratis:w-full', pt?.root?.className, className)}\n onBlur={(event) => {\n onBlur?.();\n if (addOnBlur && !event.currentTarget.contains(event.relatedTarget))\n onCommit();\n }}\n data-cratis-part='root'\n data-cratis-component='ChipsField'\n data-disabled={pt?.input?.disabled || undefined}\n data-invalid={invalid || undefined}\n data-readonly={pt?.input?.readOnly || undefined}\n >\n {children}\n </div>\n);\n"],"names":["_jsx"],"mappings":";;;AAmBO,MAAM,SAAS,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAkB,MAC9GA,gBACQ,EAAE,EAAE,IAAI,EACZ,SAAS,EAAE,UAAU,CAAC,oBAAoB,EAAE,eAAe,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,CAAC,EAC5F,MAAM,EAAE,CAAC,KAAK,KAAI;QACd,MAAM,IAAI;AACV,QAAA,IAAI,SAAS,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC;AAC/D,YAAA,QAAQ,EAAE;AAClB,IAAA,CAAC,EAAA,kBAAA,EACgB,MAAM,EAAA,uBAAA,EACD,YAAY,EAAA,eAAA,EACnB,EAAE,EAAE,KAAK,EAAE,QAAQ,IAAI,SAAS,EAAA,cAAA,EACjC,OAAO,IAAI,SAAS,EAAA,eAAA,EACnB,EAAE,EAAE,KAAK,EAAE,QAAQ,IAAI,SAAS,EAAA,QAAA,EAE9C,QAAQ,EAAA,CACP;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/PasswordField.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEH,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EAC3B,MAAM,OAAO,CAAC;AACf,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAEH,KAAK,uBAAuB,EAC/B,MAAM,yBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"PasswordField.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/PasswordField.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEH,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EAC3B,MAAM,OAAO,CAAC;AACf,OAAO,EAAsB,KAAK,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAEH,KAAK,uBAAuB,EAC/B,MAAM,yBAAsB,CAAC;AAO9B,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC1B,qBAAqB;IACrB,IAAI,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IACtC,kCAAkC;IAClC,KAAK,CAAC,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IAC9C,gCAAgC;IAChC,MAAM,CAAC,EAAE,oBAAoB,CAAC,iBAAiB,CAAC,CAAC;CACpD;AAKD,UAAU,2BACN,SAAQ,iBAAiB,CAAC,MAAM,CAAC,EAC7B,uBAAuB;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,EAAE,CAAC,EAAE,aAAa,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAwCD,4EAA4E;AAC5E,eAAO,MAAM,aAAa,0NAGzB,CAAC"}
|