glchat-a2ui-react-renderer 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/src/components/a2ui/v0_8/UnknownComponent/UnknownComponent.d.ts +7 -0
- package/dist/src/components/a2ui/v0_8/UnknownComponent/UnknownComponent.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/UnknownComponent/UnknownComponent.js +13 -0
- package/dist/src/components/a2ui/v0_9/AudioPlayer/AudioPlayer.d.ts +6 -0
- package/dist/src/components/a2ui/v0_9/AudioPlayer/AudioPlayer.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_9/AudioPlayer/AudioPlayer.js +15 -0
- package/dist/src/components/a2ui/v0_9/Button/Button.d.ts +22 -22
- package/dist/src/components/a2ui/v0_9/Button/Button.d.ts.map +1 -1
- package/dist/src/components/a2ui/v0_9/Timeout/Timeout.d.ts +2 -2
- package/dist/src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.d.ts +231 -0
- package/dist/src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.js +24 -0
- package/dist/src/components/ui/AudioPlayer/AudioPlayer.d.ts +9 -0
- package/dist/src/components/ui/AudioPlayer/AudioPlayer.d.ts.map +1 -0
- package/dist/src/components/ui/AudioPlayer/AudioPlayer.js +156 -0
- package/dist/src/components/ui/AudioPlayer/theme.d.ts +12 -0
- package/dist/src/components/ui/AudioPlayer/theme.d.ts.map +1 -0
- package/dist/src/components/ui/AudioPlayer/theme.js +69 -0
- package/dist/src/components/ui/InlineAlert/InlineAlert.d.ts +14 -0
- package/dist/src/components/ui/InlineAlert/InlineAlert.d.ts.map +1 -0
- package/dist/src/components/ui/InlineAlert/InlineAlert.js +9 -0
- package/dist/src/components/ui/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/dist/src/components/ui/MultiSelect/MultiSelect.js +4 -10
- package/dist/src/components/ui/Select/Select.d.ts.map +1 -1
- package/dist/src/components/ui/Select/Select.js +1 -1
- package/dist/src/v0_8/Provider.d.ts.map +1 -1
- package/dist/src/v0_8/Provider.js +10 -2
- package/dist/src/v0_8/registry.d.ts +5 -0
- package/dist/src/v0_8/registry.d.ts.map +1 -1
- package/dist/src/v0_8/registry.js +26 -12
- package/dist/src/v0_9/Provider.d.ts +6 -1
- package/dist/src/v0_9/Provider.d.ts.map +1 -1
- package/dist/src/v0_9/Provider.js +17 -8
- package/dist/src/v0_9/SurfaceRenderer.d.ts.map +1 -1
- package/dist/src/v0_9/SurfaceRenderer.js +28 -3
- package/dist/src/v0_9/catalog.d.ts +8 -2
- package/dist/src/v0_9/catalog.d.ts.map +1 -1
- package/dist/src/v0_9/catalog.js +20 -3
- package/json/v0_8/a2ui-sample-messages.json +1 -14
- package/json/v0_8/glchat_standard_catalog_definition.json +1 -1
- package/json/v0_9/glchat_standard_catalog_definition.json +1 -1
- package/package.json +1 -1
- package/styles/globals.css +124 -0
- package/styles/theme-v4.css +5 -0
- package/tailwind.config.cjs +9 -0
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { SurfaceRenderer, type SurfaceRendererProps } from './src/SurfaceRendere
|
|
|
3
3
|
export { useSurfaces } from './src/v0_9/useSurfaces.js';
|
|
4
4
|
export { createGlchatCatalog, GLCHAT_CATALOG_ID } from './src/v0_9/catalog.js';
|
|
5
5
|
export { createGlchatRegistry, GLCHAT_CATALOG_ID_V08, ensureGlchatComponentsRegistered } from './src/v0_8/registry.js';
|
|
6
|
+
export { GlchatAudioPlayerComponent } from './src/components/a2ui/v0_9/AudioPlayer/AudioPlayer.js';
|
|
6
7
|
export { GlchatButtonComponent, GlchatButtonApi } from './src/components/a2ui/v0_9/Button/Button.js';
|
|
7
8
|
export { GlchatChoicePickerComponent } from './src/components/a2ui/v0_9/ChoicePicker/ChoicePicker.js';
|
|
8
9
|
export { GlchatTagInputComponent, TagInputApi } from './src/components/a2ui/v0_9/TagInput/TagInput.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,eAAe,EACf,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,GACzB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEtF,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAGvH,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AACrG,OAAO,EAAE,2BAA2B,EAAE,MAAM,yDAAyD,CAAC;AACtG,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAC;AACvG,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAGnG,OAAO,EACL,WAAW,EACX,6BAA6B,EAC7B,uCAAuC,EACvC,eAAe,EACf,mBAAmB,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,GAC7B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,OAAO,EACP,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EACf,6BAA6B,EAC7B,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,eAAe,EACf,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,GACzB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEtF,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAGvH,OAAO,EAAE,0BAA0B,EAAE,MAAM,uDAAuD,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AACrG,OAAO,EAAE,2BAA2B,EAAE,MAAM,yDAAyD,CAAC;AACtG,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAC;AACvG,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAGnG,OAAO,EACL,WAAW,EACX,6BAA6B,EAC7B,uCAAuC,EACvC,eAAe,EACf,mBAAmB,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,GAC7B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,OAAO,EACP,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EACf,6BAA6B,EAC7B,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { useSurfaces } from './src/v0_9/useSurfaces.js';
|
|
|
4
4
|
export { createGlchatCatalog, GLCHAT_CATALOG_ID } from './src/v0_9/catalog.js';
|
|
5
5
|
export { createGlchatRegistry, GLCHAT_CATALOG_ID_V08, ensureGlchatComponentsRegistered } from './src/v0_8/registry.js';
|
|
6
6
|
// GLChat custom component implementations and their schemas (v0.9)
|
|
7
|
+
export { GlchatAudioPlayerComponent } from './src/components/a2ui/v0_9/AudioPlayer/AudioPlayer.js';
|
|
7
8
|
export { GlchatButtonComponent, GlchatButtonApi } from './src/components/a2ui/v0_9/Button/Button.js';
|
|
8
9
|
export { GlchatChoicePickerComponent } from './src/components/a2ui/v0_9/ChoicePicker/ChoicePicker.js';
|
|
9
10
|
export { GlchatTagInputComponent, TagInputApi } from './src/components/a2ui/v0_9/TagInput/TagInput.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { A2UIComponentProps } from '@a2ui/react/v0_8';
|
|
2
|
+
/**
|
|
3
|
+
* Renders a warning alert for unknown v0.8 component types.
|
|
4
|
+
* Wired into registries via `installUnknownComponentFallback`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function CustomUnknownComponent({ node }: Readonly<A2UIComponentProps>): import("react").JSX.Element;
|
|
7
|
+
//# sourceMappingURL=UnknownComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnknownComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_8/UnknownComponent/UnknownComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAI3D;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,EAAE,QAAQ,CAAC,kBAAkB,CAAC,+BAS5E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { InlineAlert } from '../../../../components/ui/InlineAlert/InlineAlert.js';
|
|
4
|
+
/**
|
|
5
|
+
* Renders a warning alert for unknown v0.8 component types.
|
|
6
|
+
* Wired into registries via `installUnknownComponentFallback`.
|
|
7
|
+
*/
|
|
8
|
+
export function CustomUnknownComponent({ node }) {
|
|
9
|
+
const type = node && typeof node === 'object' && 'type' in node && node.type != null
|
|
10
|
+
? String(node.type)
|
|
11
|
+
: 'unknown';
|
|
12
|
+
return (_jsx(InlineAlert, { role: "status", variant: "warning", message: `[A2UI] Unknown component: ${type}` }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GLChat-styled AudioPlayer. Overrides the basic catalog native `<audio controls>`
|
|
3
|
+
* with the custom player UI (play/pause, scrubber, download).
|
|
4
|
+
*/
|
|
5
|
+
export declare const GlchatAudioPlayerComponent: import("@a2ui/react/v0_9").ReactComponentImplementation;
|
|
6
|
+
//# sourceMappingURL=AudioPlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudioPlayer.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_9/AudioPlayer/AudioPlayer.tsx"],"names":[],"mappings":"AAQA;;;GAGG;AACH,eAAO,MAAM,0BAA0B,yDAWtC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createComponentImplementation } from '@a2ui/react/v0_9';
|
|
4
|
+
import { AudioPlayerApi } from '@a2ui/web_core/v0_9/basic_catalog';
|
|
5
|
+
import { AudioPlayer } from '../../../../components/ui/AudioPlayer/AudioPlayer.js';
|
|
6
|
+
import { getWeightStyle } from '../common.js';
|
|
7
|
+
/**
|
|
8
|
+
* GLChat-styled AudioPlayer. Overrides the basic catalog native `<audio controls>`
|
|
9
|
+
* with the custom player UI (play/pause, scrubber, download).
|
|
10
|
+
*/
|
|
11
|
+
export const GlchatAudioPlayerComponent = createComponentImplementation(AudioPlayerApi, ({ props }) => {
|
|
12
|
+
if (!props.url)
|
|
13
|
+
return null;
|
|
14
|
+
return (_jsx("div", { className: "a2ui-audioplayer", style: getWeightStyle(props.weight), children: _jsx(AudioPlayer, { src: props.url, title: props.description }) }));
|
|
15
|
+
});
|
|
@@ -229,18 +229,8 @@ export declare const GlchatButtonApi: {
|
|
|
229
229
|
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
230
230
|
};
|
|
231
231
|
};
|
|
232
|
-
weight?: number | undefined;
|
|
233
232
|
variant?: "primary" | "destructive" | "borderless" | "default" | undefined;
|
|
234
|
-
|
|
235
|
-
message: string;
|
|
236
|
-
condition: boolean | {
|
|
237
|
-
path: string;
|
|
238
|
-
} | {
|
|
239
|
-
call: string;
|
|
240
|
-
args: Record<string, any>;
|
|
241
|
-
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
242
|
-
};
|
|
243
|
-
}[] | undefined;
|
|
233
|
+
weight?: number | undefined;
|
|
244
234
|
accessibility?: {
|
|
245
235
|
description?: string | {
|
|
246
236
|
path: string;
|
|
@@ -257,6 +247,16 @@ export declare const GlchatButtonApi: {
|
|
|
257
247
|
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
258
248
|
} | undefined;
|
|
259
249
|
} | undefined;
|
|
250
|
+
checks?: {
|
|
251
|
+
message: string;
|
|
252
|
+
condition: boolean | {
|
|
253
|
+
path: string;
|
|
254
|
+
} | {
|
|
255
|
+
call: string;
|
|
256
|
+
args: Record<string, any>;
|
|
257
|
+
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
258
|
+
};
|
|
259
|
+
}[] | undefined;
|
|
260
260
|
}, {
|
|
261
261
|
child: string;
|
|
262
262
|
action: {
|
|
@@ -277,18 +277,8 @@ export declare const GlchatButtonApi: {
|
|
|
277
277
|
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
278
278
|
};
|
|
279
279
|
};
|
|
280
|
-
weight?: number | undefined;
|
|
281
280
|
variant?: "primary" | "destructive" | "borderless" | "default" | undefined;
|
|
282
|
-
|
|
283
|
-
message: string;
|
|
284
|
-
condition: boolean | {
|
|
285
|
-
path: string;
|
|
286
|
-
} | {
|
|
287
|
-
call: string;
|
|
288
|
-
args: Record<string, any>;
|
|
289
|
-
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
290
|
-
};
|
|
291
|
-
}[] | undefined;
|
|
281
|
+
weight?: number | undefined;
|
|
292
282
|
accessibility?: {
|
|
293
283
|
description?: string | {
|
|
294
284
|
path: string;
|
|
@@ -305,6 +295,16 @@ export declare const GlchatButtonApi: {
|
|
|
305
295
|
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
306
296
|
} | undefined;
|
|
307
297
|
} | undefined;
|
|
298
|
+
checks?: {
|
|
299
|
+
message: string;
|
|
300
|
+
condition: boolean | {
|
|
301
|
+
path: string;
|
|
302
|
+
} | {
|
|
303
|
+
call: string;
|
|
304
|
+
args: Record<string, any>;
|
|
305
|
+
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
306
|
+
};
|
|
307
|
+
}[] | undefined;
|
|
308
308
|
}>;
|
|
309
309
|
};
|
|
310
310
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_9/Button/Button.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;8BAqC4vsE,CAAC;;;;uBAA0M,CAAC;;;;;;;;;uBAA6Y,CAAC;;;;;8BAA8N,CAAC;;;;;;uBAAmP,CAAC;;;;;;;;;;;uBAA6a,CAAC;;;;;8BAA8N,CAAC;;;;;;;;;;;;;;;0BAAmuB,CAAC;;;;;;;;;;;;0BAA4e,CAAC;;;;;;;;;;;;;;;;;;;;;0BAA27B,CAAC;;;;;;;;;;;;;;;;;;;0BAAwrB,CAAC;;;;;;;;;;;;;;;;;;;;;0BAAw8B,CAAC;;;;;;;;;;;;;;;;;;;0BAAy4B,CAAC;;;uBAAmK,CAAC;;;;;;;iBAAqR,CAAC;;;;;;;;uBAAwS,CAAC;;;;;0BAAgK,CAAC;;iBAAiI,CAAC;;;;;0BAAgK,CAAC;;;;;;;;;;;uBAA98M,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAA6a,CAAC;;;;;8BAA8N,CAAC;;;;;;;0BAAgtC,CAAC
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_9/Button/Button.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;GAEG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;8BAqC4vsE,CAAC;;;;uBAA0M,CAAC;;;;;;;;;uBAA6Y,CAAC;;;;;8BAA8N,CAAC;;;;;;uBAAmP,CAAC;;;;;;;;;;;uBAA6a,CAAC;;;;;8BAA8N,CAAC;;;;;;;;;;;;;;;0BAAmuB,CAAC;;;;;;;;;;;;0BAA4e,CAAC;;;;;;;;;;;;;;;;;;;;;0BAA27B,CAAC;;;;;;;;;;;;;;;;;;;0BAAwrB,CAAC;;;;;;;;;;;;;;;;;;;;;0BAAw8B,CAAC;;;;;;;;;;;;;;;;;;;0BAAy4B,CAAC;;;uBAAmK,CAAC;;;;;;;iBAAqR,CAAC;;;;;;;;uBAAwS,CAAC;;;;;0BAAgK,CAAC;;iBAAiI,CAAC;;;;;0BAAgK,CAAC;;;;;;;;;;;uBAA98M,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAA6a,CAAC;;;;;8BAA8N,CAAC;;;;;;;0BAAgtC,CAAC;;;;;;;;;;;0BAA20I,CAAC;;;;;;;0BAAkS,CAAC;;;;;;;;;;0BAA3/F,CAAC;;;;CA1Bvx1E,CAAC;AASF;;GAEG;AACH,eAAO,MAAM,qBAAqB,yDAajC,CAAC"}
|
|
@@ -105,8 +105,8 @@ export declare const TimeoutApi: {
|
|
|
105
105
|
args: Record<string, any>;
|
|
106
106
|
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
107
107
|
};
|
|
108
|
-
weight?: number | undefined;
|
|
109
108
|
variant?: "caption" | "h3" | "body" | "h4" | "h5" | undefined;
|
|
109
|
+
weight?: number | undefined;
|
|
110
110
|
accessibility?: {
|
|
111
111
|
description?: string | {
|
|
112
112
|
path: string;
|
|
@@ -131,8 +131,8 @@ export declare const TimeoutApi: {
|
|
|
131
131
|
args: Record<string, any>;
|
|
132
132
|
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
133
133
|
};
|
|
134
|
-
weight?: number | undefined;
|
|
135
134
|
variant?: "caption" | "h3" | "body" | "h4" | "h5" | undefined;
|
|
135
|
+
weight?: number | undefined;
|
|
136
136
|
accessibility?: {
|
|
137
137
|
description?: string | {
|
|
138
138
|
path: string;
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Fallback API used when a message references a component type that is not
|
|
4
|
+
* registered in the active catalog. Properties are accepted but ignored.
|
|
5
|
+
*/
|
|
6
|
+
export declare const UnknownComponentApi: {
|
|
7
|
+
name: string;
|
|
8
|
+
schema: z.ZodObject<{
|
|
9
|
+
accessibility: z.ZodOptional<z.ZodObject<{
|
|
10
|
+
label: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
11
|
+
path: z.ZodString;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
path: string;
|
|
14
|
+
}, {
|
|
15
|
+
path: string;
|
|
16
|
+
}>, z.ZodObject<{
|
|
17
|
+
call: z.ZodString;
|
|
18
|
+
args: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
19
|
+
returnType: z.ZodDefault<z.ZodEnum<["string", "number", "boolean", "array", "object", "any", "void"]>>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
call: string;
|
|
22
|
+
args: Record<string, any>;
|
|
23
|
+
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
24
|
+
}, {
|
|
25
|
+
call: string;
|
|
26
|
+
args: Record<string, any>;
|
|
27
|
+
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
28
|
+
}>]>>;
|
|
29
|
+
description: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
30
|
+
path: z.ZodString;
|
|
31
|
+
}, "strip", z.ZodTypeAny, {
|
|
32
|
+
path: string;
|
|
33
|
+
}, {
|
|
34
|
+
path: string;
|
|
35
|
+
}>, z.ZodObject<{
|
|
36
|
+
call: z.ZodString;
|
|
37
|
+
args: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
38
|
+
returnType: z.ZodDefault<z.ZodEnum<["string", "number", "boolean", "array", "object", "any", "void"]>>;
|
|
39
|
+
}, "strip", z.ZodTypeAny, {
|
|
40
|
+
call: string;
|
|
41
|
+
args: Record<string, any>;
|
|
42
|
+
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
43
|
+
}, {
|
|
44
|
+
call: string;
|
|
45
|
+
args: Record<string, any>;
|
|
46
|
+
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
47
|
+
}>]>>;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
description?: string | {
|
|
50
|
+
path: string;
|
|
51
|
+
} | {
|
|
52
|
+
call: string;
|
|
53
|
+
args: Record<string, any>;
|
|
54
|
+
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
55
|
+
} | undefined;
|
|
56
|
+
label?: string | {
|
|
57
|
+
path: string;
|
|
58
|
+
} | {
|
|
59
|
+
call: string;
|
|
60
|
+
args: Record<string, any>;
|
|
61
|
+
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
62
|
+
} | undefined;
|
|
63
|
+
}, {
|
|
64
|
+
description?: string | {
|
|
65
|
+
path: string;
|
|
66
|
+
} | {
|
|
67
|
+
call: string;
|
|
68
|
+
args: Record<string, any>;
|
|
69
|
+
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
70
|
+
} | undefined;
|
|
71
|
+
label?: string | {
|
|
72
|
+
path: string;
|
|
73
|
+
} | {
|
|
74
|
+
call: string;
|
|
75
|
+
args: Record<string, any>;
|
|
76
|
+
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
77
|
+
} | undefined;
|
|
78
|
+
}>>;
|
|
79
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
81
|
+
accessibility: z.ZodOptional<z.ZodObject<{
|
|
82
|
+
label: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
83
|
+
path: z.ZodString;
|
|
84
|
+
}, "strip", z.ZodTypeAny, {
|
|
85
|
+
path: string;
|
|
86
|
+
}, {
|
|
87
|
+
path: string;
|
|
88
|
+
}>, z.ZodObject<{
|
|
89
|
+
call: z.ZodString;
|
|
90
|
+
args: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
91
|
+
returnType: z.ZodDefault<z.ZodEnum<["string", "number", "boolean", "array", "object", "any", "void"]>>;
|
|
92
|
+
}, "strip", z.ZodTypeAny, {
|
|
93
|
+
call: string;
|
|
94
|
+
args: Record<string, any>;
|
|
95
|
+
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
96
|
+
}, {
|
|
97
|
+
call: string;
|
|
98
|
+
args: Record<string, any>;
|
|
99
|
+
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
100
|
+
}>]>>;
|
|
101
|
+
description: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
102
|
+
path: z.ZodString;
|
|
103
|
+
}, "strip", z.ZodTypeAny, {
|
|
104
|
+
path: string;
|
|
105
|
+
}, {
|
|
106
|
+
path: string;
|
|
107
|
+
}>, z.ZodObject<{
|
|
108
|
+
call: z.ZodString;
|
|
109
|
+
args: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
110
|
+
returnType: z.ZodDefault<z.ZodEnum<["string", "number", "boolean", "array", "object", "any", "void"]>>;
|
|
111
|
+
}, "strip", z.ZodTypeAny, {
|
|
112
|
+
call: string;
|
|
113
|
+
args: Record<string, any>;
|
|
114
|
+
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
115
|
+
}, {
|
|
116
|
+
call: string;
|
|
117
|
+
args: Record<string, any>;
|
|
118
|
+
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
119
|
+
}>]>>;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
description?: string | {
|
|
122
|
+
path: string;
|
|
123
|
+
} | {
|
|
124
|
+
call: string;
|
|
125
|
+
args: Record<string, any>;
|
|
126
|
+
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
127
|
+
} | undefined;
|
|
128
|
+
label?: string | {
|
|
129
|
+
path: string;
|
|
130
|
+
} | {
|
|
131
|
+
call: string;
|
|
132
|
+
args: Record<string, any>;
|
|
133
|
+
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
134
|
+
} | undefined;
|
|
135
|
+
}, {
|
|
136
|
+
description?: string | {
|
|
137
|
+
path: string;
|
|
138
|
+
} | {
|
|
139
|
+
call: string;
|
|
140
|
+
args: Record<string, any>;
|
|
141
|
+
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
142
|
+
} | undefined;
|
|
143
|
+
label?: string | {
|
|
144
|
+
path: string;
|
|
145
|
+
} | {
|
|
146
|
+
call: string;
|
|
147
|
+
args: Record<string, any>;
|
|
148
|
+
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
149
|
+
} | undefined;
|
|
150
|
+
}>>;
|
|
151
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
152
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
153
|
+
accessibility: z.ZodOptional<z.ZodObject<{
|
|
154
|
+
label: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
155
|
+
path: z.ZodString;
|
|
156
|
+
}, "strip", z.ZodTypeAny, {
|
|
157
|
+
path: string;
|
|
158
|
+
}, {
|
|
159
|
+
path: string;
|
|
160
|
+
}>, z.ZodObject<{
|
|
161
|
+
call: z.ZodString;
|
|
162
|
+
args: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
163
|
+
returnType: z.ZodDefault<z.ZodEnum<["string", "number", "boolean", "array", "object", "any", "void"]>>;
|
|
164
|
+
}, "strip", z.ZodTypeAny, {
|
|
165
|
+
call: string;
|
|
166
|
+
args: Record<string, any>;
|
|
167
|
+
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
168
|
+
}, {
|
|
169
|
+
call: string;
|
|
170
|
+
args: Record<string, any>;
|
|
171
|
+
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
172
|
+
}>]>>;
|
|
173
|
+
description: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodObject<{
|
|
174
|
+
path: z.ZodString;
|
|
175
|
+
}, "strip", z.ZodTypeAny, {
|
|
176
|
+
path: string;
|
|
177
|
+
}, {
|
|
178
|
+
path: string;
|
|
179
|
+
}>, z.ZodObject<{
|
|
180
|
+
call: z.ZodString;
|
|
181
|
+
args: z.ZodRecord<z.ZodString, z.ZodAny>;
|
|
182
|
+
returnType: z.ZodDefault<z.ZodEnum<["string", "number", "boolean", "array", "object", "any", "void"]>>;
|
|
183
|
+
}, "strip", z.ZodTypeAny, {
|
|
184
|
+
call: string;
|
|
185
|
+
args: Record<string, any>;
|
|
186
|
+
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
187
|
+
}, {
|
|
188
|
+
call: string;
|
|
189
|
+
args: Record<string, any>;
|
|
190
|
+
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
191
|
+
}>]>>;
|
|
192
|
+
}, "strip", z.ZodTypeAny, {
|
|
193
|
+
description?: string | {
|
|
194
|
+
path: string;
|
|
195
|
+
} | {
|
|
196
|
+
call: string;
|
|
197
|
+
args: Record<string, any>;
|
|
198
|
+
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
199
|
+
} | undefined;
|
|
200
|
+
label?: string | {
|
|
201
|
+
path: string;
|
|
202
|
+
} | {
|
|
203
|
+
call: string;
|
|
204
|
+
args: Record<string, any>;
|
|
205
|
+
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
206
|
+
} | undefined;
|
|
207
|
+
}, {
|
|
208
|
+
description?: string | {
|
|
209
|
+
path: string;
|
|
210
|
+
} | {
|
|
211
|
+
call: string;
|
|
212
|
+
args: Record<string, any>;
|
|
213
|
+
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
214
|
+
} | undefined;
|
|
215
|
+
label?: string | {
|
|
216
|
+
path: string;
|
|
217
|
+
} | {
|
|
218
|
+
call: string;
|
|
219
|
+
args: Record<string, any>;
|
|
220
|
+
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
221
|
+
} | undefined;
|
|
222
|
+
}>>;
|
|
223
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
224
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Renders a warning alert for unknown component types.
|
|
228
|
+
* Wired into catalogs via `installUnknownComponentFallback`.
|
|
229
|
+
*/
|
|
230
|
+
export declare const UnknownComponentFallback: import("@a2ui/react/v0_9").ReactComponentImplementation;
|
|
231
|
+
//# sourceMappingURL=UnknownComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UnknownComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;0BAwB4pZ,CAAC;;;;;;;;;;;;;;;;;;;0BAAivB,CAAC;;;;;;;;;;;;;;;;;;;;;;;0BAA2sB,CAAC;;;;;;;0BAA0O,CAAC;;;;;;;;;;;;;;;;;;;;;;;0BAA1qD,CAAC;;;;;;;;;;;;;;;;;;;0BAAivB,CAAC;;;;;;;;;;;;;;;;;;;;;;;0BAA2sB,CAAC;;;;;;;0BAA0O,CAAC;;;;;;;;;;;;;;;;;;;;;;;0BAA1qD,CAAC;;;;;;;;;;;;;;;;;;;0BAAivB,CAAC;;;;;;;;;;;;;;;;;;;;;;;0BAA2sB,CAAC;;;;;;;0BAA0O,CAAC;;;;;CAhBr2c,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,yDASpC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createBinderlessComponentImplementation } from '@a2ui/react/v0_9';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { InlineAlert } from '../../../../components/ui/InlineAlert/InlineAlert.js';
|
|
6
|
+
import { CommonProps } from '../common.js';
|
|
7
|
+
/**
|
|
8
|
+
* Fallback API used when a message references a component type that is not
|
|
9
|
+
* registered in the active catalog. Properties are accepted but ignored.
|
|
10
|
+
*/
|
|
11
|
+
export const UnknownComponentApi = {
|
|
12
|
+
name: '__UnknownComponent__',
|
|
13
|
+
schema: z
|
|
14
|
+
.object({
|
|
15
|
+
...CommonProps,
|
|
16
|
+
})
|
|
17
|
+
.passthrough()
|
|
18
|
+
.describe('Placeholder for an unsupported or unregistered A2UI component.'),
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Renders a warning alert for unknown component types.
|
|
22
|
+
* Wired into catalogs via `installUnknownComponentFallback`.
|
|
23
|
+
*/
|
|
24
|
+
export const UnknownComponentFallback = createBinderlessComponentImplementation(UnknownComponentApi, ({ context }) => (_jsx(InlineAlert, { role: "status", variant: "warning", message: `[A2UI] Unknown component: ${context.componentModel.type}` })));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
export type AudioPlayerProps = {
|
|
3
|
+
src: string;
|
|
4
|
+
title?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
style?: CSSProperties;
|
|
7
|
+
};
|
|
8
|
+
export declare function AudioPlayer({ src, title, className, style }: Readonly<AudioPlayerProps>): import("react").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=AudioPlayer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudioPlayer.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/AudioPlayer/AudioPlayer.tsx"],"names":[],"mappings":"AAGA,OAAO,EAA+B,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAmBxE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAoEF,wBAAgB,WAAW,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,QAAQ,CAAC,gBAAgB,CAAC,+BAiKvF"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Download, Pause, Play } from 'lucide-react';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { Button } from '../../../components/ui/Button/Button.js';
|
|
6
|
+
import { ButtonAsLink } from '../../../components/ui/Button/ButtonAsLink.js';
|
|
7
|
+
import { cn } from '../../../utils/css.js';
|
|
8
|
+
import { audioPlayerCardStyles, audioPlayerControlsStyles, audioPlayerHeaderStyles, audioPlayerHiddenAudioStyles, audioPlayerIconButtonStyles, audioPlayerMetaStyles, audioPlayerProgressStyles, audioPlayerRootStyles, audioPlayerTimeStyles, audioPlayerTitleStyles, } from './theme.js';
|
|
9
|
+
function formatAudioDuration(seconds) {
|
|
10
|
+
if (!Number.isFinite(seconds) || seconds < 0) {
|
|
11
|
+
return '0:00';
|
|
12
|
+
}
|
|
13
|
+
const minutes = Math.floor(seconds / 60);
|
|
14
|
+
const secs = Math.floor(seconds % 60);
|
|
15
|
+
return `${minutes}:${secs.toString().padStart(2, '0')}`;
|
|
16
|
+
}
|
|
17
|
+
function formatBytes(bytes, decimals = 1) {
|
|
18
|
+
if (!Number.isFinite(bytes) || bytes < 0)
|
|
19
|
+
return '0 B';
|
|
20
|
+
if (bytes === 0)
|
|
21
|
+
return '0 B';
|
|
22
|
+
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
23
|
+
const unitIndex = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), units.length - 1);
|
|
24
|
+
const value = bytes / 1024 ** unitIndex;
|
|
25
|
+
return `${value.toFixed(decimals)} ${units[unitIndex]}`;
|
|
26
|
+
}
|
|
27
|
+
function getFilenameFromUrl(url) {
|
|
28
|
+
try {
|
|
29
|
+
const pathname = new URL(url).pathname;
|
|
30
|
+
const parts = pathname.split('/').filter(Boolean);
|
|
31
|
+
const segment = parts.at(-1);
|
|
32
|
+
return segment ? decodeURIComponent(segment) : 'audio';
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return 'audio';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function getFileExtension(filename) {
|
|
39
|
+
const match = /\.([^.]+)$/.exec(filename);
|
|
40
|
+
return match?.[1] ?? '';
|
|
41
|
+
}
|
|
42
|
+
const AUDIO_MIME_LABELS = {
|
|
43
|
+
'audio/mpeg': 'MP3',
|
|
44
|
+
'audio/mp3': 'MP3',
|
|
45
|
+
'audio/wav': 'WAV',
|
|
46
|
+
'audio/x-wav': 'WAV',
|
|
47
|
+
'audio/wave': 'WAV',
|
|
48
|
+
'audio/ogg': 'OGG',
|
|
49
|
+
'audio/flac': 'FLAC',
|
|
50
|
+
'audio/mp4': 'M4A',
|
|
51
|
+
'audio/x-m4a': 'M4A',
|
|
52
|
+
'audio/m4a': 'M4A',
|
|
53
|
+
'audio/aac': 'AAC',
|
|
54
|
+
'audio/webm': 'WEBM',
|
|
55
|
+
};
|
|
56
|
+
function getAudioLabelFromContentType(contentType) {
|
|
57
|
+
if (!contentType)
|
|
58
|
+
return null;
|
|
59
|
+
const mime = contentType.split(';', 1)[0]?.trim().toLowerCase() ?? '';
|
|
60
|
+
const knownLabel = AUDIO_MIME_LABELS[mime];
|
|
61
|
+
if (knownLabel)
|
|
62
|
+
return knownLabel;
|
|
63
|
+
if (mime.startsWith('audio/')) {
|
|
64
|
+
const subtype = mime.slice('audio/'.length);
|
|
65
|
+
if (subtype && subtype !== '*')
|
|
66
|
+
return subtype.toUpperCase();
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
export function AudioPlayer({ src, title, className, style }) {
|
|
71
|
+
const audioRef = useRef(null);
|
|
72
|
+
const [isPlaying, setIsPlaying] = useState(false);
|
|
73
|
+
const [currentTime, setCurrentTime] = useState(0);
|
|
74
|
+
const [duration, setDuration] = useState(0);
|
|
75
|
+
const [fileSize, setFileSize] = useState(null);
|
|
76
|
+
const [audioType, setAudioType] = useState(null);
|
|
77
|
+
const fileNameFromUrl = getFilenameFromUrl(src);
|
|
78
|
+
const fileName = title?.trim() || fileNameFromUrl;
|
|
79
|
+
const extension = audioType ?? (getFileExtension(fileNameFromUrl).toUpperCase() || 'AUDIO');
|
|
80
|
+
const metadata = fileSize ? `${extension} · ${formatBytes(fileSize, 1)}` : extension;
|
|
81
|
+
const progress = duration > 0 ? (currentTime / duration) * 100 : 0;
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
let cancelled = false;
|
|
84
|
+
fetch(src, { method: 'HEAD' })
|
|
85
|
+
.then((response) => {
|
|
86
|
+
if (cancelled)
|
|
87
|
+
return;
|
|
88
|
+
const length = response.headers.get('Content-Length');
|
|
89
|
+
if (length) {
|
|
90
|
+
const parsed = Number.parseInt(length, 10);
|
|
91
|
+
if (!Number.isNaN(parsed))
|
|
92
|
+
setFileSize(parsed);
|
|
93
|
+
}
|
|
94
|
+
const label = getAudioLabelFromContentType(response.headers.get('Content-Type'));
|
|
95
|
+
if (label)
|
|
96
|
+
setAudioType(label);
|
|
97
|
+
})
|
|
98
|
+
.catch(() => undefined);
|
|
99
|
+
return () => {
|
|
100
|
+
cancelled = true;
|
|
101
|
+
};
|
|
102
|
+
}, [src]);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (!isPlaying)
|
|
105
|
+
return;
|
|
106
|
+
let frameId = 0;
|
|
107
|
+
function updateProgress() {
|
|
108
|
+
const audio = audioRef.current;
|
|
109
|
+
if (audio)
|
|
110
|
+
setCurrentTime(audio.currentTime);
|
|
111
|
+
frameId = requestAnimationFrame(updateProgress);
|
|
112
|
+
}
|
|
113
|
+
frameId = requestAnimationFrame(updateProgress);
|
|
114
|
+
return () => cancelAnimationFrame(frameId);
|
|
115
|
+
}, [isPlaying]);
|
|
116
|
+
async function togglePlayback() {
|
|
117
|
+
const audio = audioRef.current;
|
|
118
|
+
if (!audio)
|
|
119
|
+
return;
|
|
120
|
+
if (isPlaying) {
|
|
121
|
+
audio.pause();
|
|
122
|
+
setIsPlaying(false);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
await audio.play();
|
|
127
|
+
setIsPlaying(true);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
// Browser cannot play the audio format; leave state unchanged.
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return (_jsxs("figure", { className: cn('glchat-a2ui-audio-player', className), style: { ...audioPlayerRootStyles, ...style }, children: [_jsxs("div", { style: audioPlayerCardStyles, children: [_jsxs("div", { style: audioPlayerHeaderStyles, children: [_jsx("span", { style: audioPlayerTitleStyles, children: fileName }), _jsx("span", { style: audioPlayerMetaStyles, children: metadata })] }), _jsxs("div", { style: audioPlayerControlsStyles, children: [_jsx(Button, { variant: "borderless", onClick: togglePlayback, "aria-label": isPlaying ? 'Pause audio' : 'Play audio', style: audioPlayerIconButtonStyles, children: isPlaying ? (_jsx(Pause, { size: 20, strokeWidth: 1.5 })) : (_jsx(Play, { size: 20, strokeWidth: 1.5 })) }), _jsxs("span", { style: audioPlayerTimeStyles, children: [formatAudioDuration(currentTime), " / ", formatAudioDuration(duration)] }), _jsx("input", { type: "range", min: 0, max: duration || 0, step: "any", value: currentTime, "aria-label": "Audio progress", className: "glchat-a2ui-audio-progress", onChange: (event) => {
|
|
134
|
+
const audio = audioRef.current;
|
|
135
|
+
if (!audio)
|
|
136
|
+
return;
|
|
137
|
+
const nextTime = Number(event.target.value);
|
|
138
|
+
audio.currentTime = nextTime;
|
|
139
|
+
setCurrentTime(nextTime);
|
|
140
|
+
}, style: {
|
|
141
|
+
...audioPlayerProgressStyles,
|
|
142
|
+
background: `linear-gradient(to right, hsl(var(--primary)) 0%, hsl(var(--primary)) ${progress}%, hsl(var(--border)) ${progress}%, hsl(var(--border)) 100%)`,
|
|
143
|
+
} }), _jsx(ButtonAsLink, { variant: "borderless", href: src, download: fileName, target: "_blank", "aria-label": "Download audio", style: audioPlayerIconButtonStyles, children: _jsx(Download, { size: 16, strokeWidth: 1.5 }) })] })] }), _jsx("audio", { ref: audioRef, src: src, preload: "metadata", style: audioPlayerHiddenAudioStyles, onLoadedMetadata: (event) => setDuration(event.currentTarget.duration), onPlay: () => setIsPlaying(true), onPause: (event) => {
|
|
144
|
+
setIsPlaying(false);
|
|
145
|
+
setCurrentTime(event.currentTarget.currentTime);
|
|
146
|
+
}, onEnded: (event) => {
|
|
147
|
+
setIsPlaying(false);
|
|
148
|
+
setCurrentTime(event.currentTarget.duration);
|
|
149
|
+
}, onTimeUpdate: (event) => {
|
|
150
|
+
const audio = event.currentTarget;
|
|
151
|
+
setCurrentTime(audio.currentTime);
|
|
152
|
+
if (audio.duration !== duration) {
|
|
153
|
+
setDuration(audio.duration);
|
|
154
|
+
}
|
|
155
|
+
}, children: _jsx("track", { kind: "captions", label: fileName }) })] }));
|
|
156
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
export declare const audioPlayerRootStyles: CSSProperties;
|
|
3
|
+
export declare const audioPlayerCardStyles: CSSProperties;
|
|
4
|
+
export declare const audioPlayerHeaderStyles: CSSProperties;
|
|
5
|
+
export declare const audioPlayerTitleStyles: CSSProperties;
|
|
6
|
+
export declare const audioPlayerMetaStyles: CSSProperties;
|
|
7
|
+
export declare const audioPlayerControlsStyles: CSSProperties;
|
|
8
|
+
export declare const audioPlayerIconButtonStyles: CSSProperties;
|
|
9
|
+
export declare const audioPlayerTimeStyles: CSSProperties;
|
|
10
|
+
export declare const audioPlayerProgressStyles: CSSProperties;
|
|
11
|
+
export declare const audioPlayerHiddenAudioStyles: CSSProperties;
|
|
12
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/AudioPlayer/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,eAAO,MAAM,qBAAqB,EAAE,aAInC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,aASnC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,aAMrC,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,aAQpC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,aAInC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,aAKvC,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE,aAMzC,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,aAKnC,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,aAUvC,CAAC;AAEF,eAAO,MAAM,4BAA4B,EAAE,aAE1C,CAAC"}
|