@cratis/components 4.42.2 → 4.42.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compat-manifest.json +11 -11
- 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/package.json +1 -1
package/compat-manifest.json
CHANGED
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
{
|
|
69
69
|
"name": "@cratis/components",
|
|
70
70
|
"role": "core",
|
|
71
|
-
"version": "4.42.
|
|
71
|
+
"version": "4.42.3",
|
|
72
72
|
"releaseMajorRange": ">=4 <5",
|
|
73
73
|
"independentRelease": false,
|
|
74
74
|
"private": false,
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
{
|
|
93
93
|
"name": "@cratis/eslint-plugin-components",
|
|
94
94
|
"role": "eslint",
|
|
95
|
-
"version": "4.42.
|
|
95
|
+
"version": "4.42.3",
|
|
96
96
|
"releaseMajorRange": ">=4 <5",
|
|
97
97
|
"independentRelease": false,
|
|
98
98
|
"private": false,
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
{
|
|
106
106
|
"name": "@cratis/components.migrator",
|
|
107
107
|
"role": "migrator",
|
|
108
|
-
"version": "4.42.
|
|
108
|
+
"version": "4.42.3",
|
|
109
109
|
"releaseMajorRange": ">=4 <5",
|
|
110
110
|
"independentRelease": false,
|
|
111
111
|
"private": false,
|
|
@@ -116,13 +116,13 @@
|
|
|
116
116
|
{
|
|
117
117
|
"name": "@cratis/components.conformance",
|
|
118
118
|
"role": "conformance",
|
|
119
|
-
"version": "4.42.
|
|
119
|
+
"version": "4.42.3",
|
|
120
120
|
"releaseMajorRange": ">=4 <5",
|
|
121
121
|
"independentRelease": false,
|
|
122
122
|
"private": false,
|
|
123
123
|
"packageAccess": "public",
|
|
124
124
|
"peerDependencies": {
|
|
125
|
-
"@cratis/components": "4.42.
|
|
125
|
+
"@cratis/components": "4.42.3",
|
|
126
126
|
"react": "^19.0.0",
|
|
127
127
|
"react-dom": "^19.0.0"
|
|
128
128
|
},
|
|
@@ -132,13 +132,13 @@
|
|
|
132
132
|
{
|
|
133
133
|
"name": "@cratis/components.mui",
|
|
134
134
|
"role": "renderer-adapter",
|
|
135
|
-
"version": "4.42.
|
|
135
|
+
"version": "4.42.3",
|
|
136
136
|
"releaseMajorRange": ">=4 <5",
|
|
137
137
|
"independentRelease": false,
|
|
138
138
|
"private": false,
|
|
139
139
|
"packageAccess": "public",
|
|
140
140
|
"peerDependencies": {
|
|
141
|
-
"@cratis/components": "4.42.
|
|
141
|
+
"@cratis/components": "4.42.3",
|
|
142
142
|
"@emotion/react": ">=11.5 <12",
|
|
143
143
|
"@emotion/styled": ">=11.11 <12",
|
|
144
144
|
"@mui/material": ">=9 <10",
|
|
@@ -188,13 +188,13 @@
|
|
|
188
188
|
{
|
|
189
189
|
"name": "@cratis/components.primereact",
|
|
190
190
|
"role": "renderer-adapter",
|
|
191
|
-
"version": "4.42.
|
|
191
|
+
"version": "4.42.3",
|
|
192
192
|
"releaseMajorRange": ">=4 <5",
|
|
193
193
|
"independentRelease": false,
|
|
194
194
|
"private": false,
|
|
195
195
|
"packageAccess": "public",
|
|
196
196
|
"peerDependencies": {
|
|
197
|
-
"@cratis/components": "4.42.
|
|
197
|
+
"@cratis/components": "4.42.3",
|
|
198
198
|
"@primereact/core": ">=11 <12",
|
|
199
199
|
"@primereact/ui": ">=11 <12",
|
|
200
200
|
"@primeuix/themes": ">=3 <4",
|
|
@@ -256,13 +256,13 @@
|
|
|
256
256
|
{
|
|
257
257
|
"name": "@cratis/components.primereact10",
|
|
258
258
|
"role": "renderer-adapter",
|
|
259
|
-
"version": "4.42.
|
|
259
|
+
"version": "4.42.3",
|
|
260
260
|
"releaseMajorRange": ">=4 <5",
|
|
261
261
|
"independentRelease": false,
|
|
262
262
|
"private": false,
|
|
263
263
|
"packageAccess": "public",
|
|
264
264
|
"peerDependencies": {
|
|
265
|
-
"@cratis/components": "4.42.
|
|
265
|
+
"@cratis/components": "4.42.3",
|
|
266
266
|
"primereact": ">=10.9.9 <11",
|
|
267
267
|
"react": "^19.0.0",
|
|
268
268
|
"react-dom": "^19.0.0"
|
|
@@ -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,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAc,CAAC;AAE1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wBAAqB,CAAC;AAIn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e,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,EAAC,IAAI,EAAA,CAAG,EACvCA,GAAA,CAAA,MAAA,EAAA,EAAM,EAAE,EAAC,GAAG,EAAC,EAAE,EAAC,IAAI,EAAC,EA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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,YAAY,GAAG,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC;IACxF,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,2BAA2B,C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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,YAAY,IAAI,KAAK,CAAC,OAAO;AACpD,IAAA,MAAM,SAAS,GAAG,SAAS,IAAI,MAAM,EAAE,YAAY,IAAI,WAAW,IAAI,KAA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,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,CAAA,EAAA,CACrC,CACT;MAQY,oBAAoB,GAAG,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAA6B,MACxFD,iBAAQ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ACnB,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"}
|
|
@@ -2,6 +2,9 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { asCommandFormField } from '@cratis/arc.react/commands';
|
|
4
4
|
import { useFieldAccessibility } from './fieldAccessibility.js';
|
|
5
|
+
import { PasswordInput } from './PasswordInput.js';
|
|
6
|
+
import { PasswordRoot } from './PasswordRoot.js';
|
|
7
|
+
import { PasswordToggle } from './PasswordToggle.js';
|
|
5
8
|
|
|
6
9
|
const PasswordControl = (props) => {
|
|
7
10
|
const [visible, setVisible] = useState(false);
|
|
@@ -10,20 +13,7 @@ const PasswordControl = (props) => {
|
|
|
10
13
|
ariaLabel: props.pt?.input?.['aria-label'],
|
|
11
14
|
ariaDescribedBy: props.pt?.input?.['aria-describedby'],
|
|
12
15
|
});
|
|
13
|
-
return (jsxs(
|
|
14
|
-
'cratis-password-field',
|
|
15
|
-
'cratis:w-full',
|
|
16
|
-
props.pt?.root?.className,
|
|
17
|
-
props.className,
|
|
18
|
-
]
|
|
19
|
-
.filter(Boolean)
|
|
20
|
-
.join(' '), "data-cratis-part": 'root', "data-cratis-component": 'PasswordField', "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-readonly": props.pt?.input?.readOnly || undefined, children: [jsx("input", { ...props.pt?.input, id: accessibility.controlId, "aria-label": accessibility.ariaLabel, "aria-describedby": accessibility.ariaDescribedBy, type: visible ? 'text' : 'password', value: props.value, onChange: (event) => props.onChange(event.currentTarget.value), placeholder: props.placeholder, "aria-invalid": props.invalid || undefined, "data-disabled": props.pt?.input?.disabled || undefined, "data-invalid": props.invalid || undefined, "data-readonly": props.pt?.input?.readOnly || undefined, className: ['cratis-field-input', 'cratis:w-full', props.pt?.input?.className]
|
|
21
|
-
.filter(Boolean)
|
|
22
|
-
.join(' '), "data-cratis-part": 'input' }), jsx("button", { ...props.pt?.toggle, type: 'button', className: ['cratis-password-field__toggle', props.pt?.toggle?.className]
|
|
23
|
-
.filter(Boolean)
|
|
24
|
-
.join(' '), "data-cratis-part": 'toggle', "data-disabled": props.pt?.toggle?.disabled || undefined, "aria-label": visible
|
|
25
|
-
? (props.hideLabel ?? 'Hide password')
|
|
26
|
-
: (props.showLabel ?? 'Show password'), onClick: () => setVisible((current) => !current), children: jsx("span", { "aria-hidden": 'true', children: visible ? '◉' : '○' }) }), accessibility.hiddenError] }));
|
|
16
|
+
return (jsxs(PasswordRoot, { attributes: props.pt?.root, input: props.pt?.input, className: props.className, invalid: props.invalid, onBlur: props.onBlur, children: [jsx(PasswordInput, { attributes: props.pt?.input, id: accessibility.controlId, ariaLabel: accessibility.ariaLabel, ariaDescribedBy: accessibility.ariaDescribedBy, visible: visible, value: props.value, onChange: props.onChange, placeholder: props.placeholder, invalid: props.invalid }), jsx(PasswordToggle, { attributes: props.pt?.toggle, visible: visible, showLabel: props.showLabel, hideLabel: props.hideLabel, onToggle: () => setVisible((current) => !current) }), accessibility.hiddenError] }));
|
|
27
17
|
};
|
|
28
18
|
const PasswordField = asCommandFormField(PasswordControl, { defaultValue: '' });
|
|
29
19
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PasswordField.js","sources":["../../../../CommandForm/fields/PasswordField.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 {\n useState,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type InputHTMLAttributes,\n} from 'react';\nimport { asCommandFormField, type WrappedFieldProps } from '@cratis/arc.react/commands';\nimport {\n useFieldAccessibility,\n type FieldAccessibilityProps,\n} from './fieldAccessibility';\nimport type { ExactPartKeys } from '../../types/ExactPartKeys';\nimport type { PartsOf } from '../../types/parts';\n\n/** Stable part attributes for {@link PasswordField}. */\nexport interface PasswordParts {\n /** Field wrapper. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** Native password/text input. */\n input?: InputHTMLAttributes<HTMLInputElement>;\n /** Visibility toggle button. */\n toggle?: ButtonHTMLAttributes<HTMLButtonElement>;\n}\n\nconst passwordPartsMatchManifest: ExactPartKeys<PasswordParts, PartsOf<'PasswordField'>> = true;\nvoid passwordPartsMatchManifest;\n\ninterface PasswordFieldComponentProps\n extends WrappedFieldProps<string>,\n FieldAccessibilityProps {\n placeholder?: string;\n className?: string;\n pt?: PasswordParts;\n ptOptions?: object;\n unstyled?: boolean;\n showLabel?: string;\n hideLabel?: string;\n}\n\nconst PasswordControl = (props: PasswordFieldComponentProps) => {\n const [visible, setVisible] = useState(false);\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 return (\n <
|
|
1
|
+
{"version":3,"file":"PasswordField.js","sources":["../../../../CommandForm/fields/PasswordField.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 {\n useState,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type InputHTMLAttributes,\n} from 'react';\nimport { asCommandFormField, type WrappedFieldProps } from '@cratis/arc.react/commands';\nimport {\n useFieldAccessibility,\n type FieldAccessibilityProps,\n} from './fieldAccessibility';\nimport { PasswordInput } from './PasswordInput';\nimport { PasswordRoot } from './PasswordRoot';\nimport { PasswordToggle } from './PasswordToggle';\nimport type { ExactPartKeys } from '../../types/ExactPartKeys';\nimport type { PartsOf } from '../../types/parts';\n\n/** Stable part attributes for {@link PasswordField}. */\nexport interface PasswordParts {\n /** Field wrapper. */\n root?: HTMLAttributes<HTMLDivElement>;\n /** Native password/text input. */\n input?: InputHTMLAttributes<HTMLInputElement>;\n /** Visibility toggle button. */\n toggle?: ButtonHTMLAttributes<HTMLButtonElement>;\n}\n\nconst passwordPartsMatchManifest: ExactPartKeys<PasswordParts, PartsOf<'PasswordField'>> = true;\nvoid passwordPartsMatchManifest;\n\ninterface PasswordFieldComponentProps\n extends WrappedFieldProps<string>,\n FieldAccessibilityProps {\n placeholder?: string;\n className?: string;\n pt?: PasswordParts;\n ptOptions?: object;\n unstyled?: boolean;\n showLabel?: string;\n hideLabel?: string;\n}\n\nconst PasswordControl = (props: PasswordFieldComponentProps) => {\n const [visible, setVisible] = useState(false);\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 return (\n <PasswordRoot\n attributes={props.pt?.root}\n input={props.pt?.input}\n className={props.className}\n invalid={props.invalid}\n onBlur={props.onBlur}\n >\n <PasswordInput\n attributes={props.pt?.input}\n id={accessibility.controlId}\n ariaLabel={accessibility.ariaLabel}\n ariaDescribedBy={accessibility.ariaDescribedBy}\n visible={visible}\n value={props.value}\n onChange={props.onChange}\n placeholder={props.placeholder}\n invalid={props.invalid}\n />\n <PasswordToggle\n attributes={props.pt?.toggle}\n visible={visible}\n showLabel={props.showLabel}\n hideLabel={props.hideLabel}\n onToggle={() => setVisible((current) => !current)}\n />\n {accessibility.hiddenError}\n </PasswordRoot>\n );\n};\n\n/** A masked password field bound to a string property on an Arc command. */\nexport const PasswordField = asCommandFormField<PasswordFieldComponentProps>(\n PasswordControl,\n { defaultValue: '' },\n);\n"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;AA6CA,MAAM,eAAe,GAAG,CAAC,KAAkC,KAAI;IAC3D,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AAC7C,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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ordInputProps {
|
|
4
|
+
/** The part attributes for the native input. */
|
|
5
|
+
attributes?: InputHTMLAttributes<HTMLInputElement>;
|
|
6
|
+
id: string | undefined;
|
|
7
|
+
ariaLabel: string | undefined;
|
|
8
|
+
ariaDescribedBy: string | undefined;
|
|
9
|
+
visible: boolean;
|
|
10
|
+
value: string;
|
|
11
|
+
onChange: (value: string) => void;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
invalid?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** The native password/text input of a password field. */
|
|
16
|
+
export declare const PasswordInput: ({ attributes, id, ariaLabel, ariaDescribedBy, visible, value, onChange, placeholder, invalid, }: PasswordInputProps) => import("react").JSX.Element;
|
|
17
|
+
//# sourceMappingURL=PasswordInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PasswordInput.d.ts","sourceRoot":"","sources":["../../../../CommandForm/fields/PasswordInput.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAGjD,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IAC/B,gDAAgD;IAChD,UAAU,CAAC,EAAE,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;IACnD,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,0DAA0D;AAC1D,eAAO,MAAM,aAAa,oGAUvB,kBAAkB,gCAiBpB,CAAC"}
|