@optiaxiom/proteus 0.2.14 → 0.2.16
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/esm/proteus-document/ProteusDocumentShell.js +5 -3
- package/dist/esm/proteus-file-icon/ProteusFileIcon.js +4 -3
- package/dist/esm/proteus-file-upload/ProteusFileUpload.js +17 -5
- package/dist/esm/schema/public-schema.json.js +14 -0
- package/dist/esm/schema/runtime-schema.json.js +14 -0
- package/dist/index.d.ts +2 -0
- package/dist/spec.d.ts +361 -348
- package/package.json +3 -3
|
@@ -9,6 +9,7 @@ import { useEffectEvent } from '../hooks/useEffectEvent.js';
|
|
|
9
9
|
import { downloadFile } from '../proteus-image/downloadFile.js';
|
|
10
10
|
import { ProteusDocumentProvider } from './ProteusDocumentContext.js';
|
|
11
11
|
import { scrollIndicator, body } from './ProteusDocumentShell-css.js';
|
|
12
|
+
import { resolveProteusValue } from './resolveProteusValue.js';
|
|
12
13
|
|
|
13
14
|
function ProteusDocumentShell({
|
|
14
15
|
collapsible: collapsibleProp,
|
|
@@ -62,7 +63,8 @@ function ProteusDocumentShell({
|
|
|
62
63
|
}, []);
|
|
63
64
|
const collapsible = collapsibleProp && element.appName;
|
|
64
65
|
const Trigger = collapsible ? DisclosureTrigger : Box;
|
|
65
|
-
const
|
|
66
|
+
const appearance = resolveProteusValue(element.appearance, data, "", []);
|
|
67
|
+
const inline = appearance === "inline";
|
|
66
68
|
return /* @__PURE__ */ jsx(
|
|
67
69
|
ProteusDocumentProvider,
|
|
68
70
|
{
|
|
@@ -126,7 +128,7 @@ function ProteusDocumentShell({
|
|
|
126
128
|
p: inline ? void 0 : "20",
|
|
127
129
|
rounded: inline ? void 0 : "xl",
|
|
128
130
|
children: [
|
|
129
|
-
element.appName && /* @__PURE__ */ jsx(Trigger, { py: "0", ...collapsible ? { chevronPosition: "end" } : {}, children: /* @__PURE__ */ jsxs(Group, { fontSize: "sm", gap: "8", children: [
|
|
131
|
+
!inline && element.appName && /* @__PURE__ */ jsx(Trigger, { py: "0", ...collapsible ? { chevronPosition: "end" } : {}, children: /* @__PURE__ */ jsxs(Group, { fontSize: "sm", gap: "8", children: [
|
|
130
132
|
/* @__PURE__ */ jsx(
|
|
131
133
|
Box,
|
|
132
134
|
{
|
|
@@ -151,7 +153,7 @@ function ProteusDocumentShell({
|
|
|
151
153
|
pb: "0",
|
|
152
154
|
pt: element.appName ? "16" : "0",
|
|
153
155
|
children: [
|
|
154
|
-
element.title && /* @__PURE__ */ jsxs(
|
|
156
|
+
!inline && element.title && /* @__PURE__ */ jsxs(
|
|
155
157
|
Group,
|
|
156
158
|
{
|
|
157
159
|
alignItems: element.titleIcon ? "start" : void 0,
|
|
@@ -8,13 +8,14 @@ const mimeIconMap = [
|
|
|
8
8
|
[/^video\//, IconFileVideo],
|
|
9
9
|
[/^audio\//, IconMusic],
|
|
10
10
|
[/presentation|powerpoint|keynote|slides/, IconPresentationScreen],
|
|
11
|
-
[/spreadsheet|excel|csv|tsv|parquet/, IconTableLayout],
|
|
11
|
+
[/spreadsheet|excel|csv|tab-separated-values|tsv|parquet/, IconTableLayout],
|
|
12
12
|
[/zip|tar|compress|archive|x-7z|x-rar/, IconFileZipper],
|
|
13
|
-
[/pdf|
|
|
13
|
+
[/pdf|wordprocessing|opendocument\.text/, IconFileLines],
|
|
14
14
|
[
|
|
15
15
|
/json|xml|yaml|javascript|typescript|html|css|x-sh|x-python|code|script/,
|
|
16
16
|
IconCode
|
|
17
|
-
]
|
|
17
|
+
],
|
|
18
|
+
[/^text\/|word|rtf/, IconFileLines]
|
|
18
19
|
];
|
|
19
20
|
function ProteusFileIcon({ mimeType, ...props }) {
|
|
20
21
|
const Icon = getIconForMimeType(mimeType);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { IconPlus } from '@optiaxiom/icons';
|
|
4
|
-
import { Flex } from '@optiaxiom/react';
|
|
4
|
+
import { toaster, Flex } from '@optiaxiom/react';
|
|
5
5
|
import { FileUpload, VisuallyHidden, FileUploadTrigger, FileUploadList, FileUploadDropzone } from '@optiaxiom/react/unstable';
|
|
6
6
|
import { useRef, useState, useCallback } from 'react';
|
|
7
7
|
import { useObserveValue } from '../hooks/useObserveValue.js';
|
|
@@ -40,10 +40,22 @@ function ProteusFileUpload({
|
|
|
40
40
|
}, [forceValueChange, name, onDataChange, parentPath]);
|
|
41
41
|
const handleFilesDrop = useCallback(
|
|
42
42
|
async (incoming) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
let skipped = 0;
|
|
44
|
+
if (maxFiles !== void 0) {
|
|
45
|
+
const existing = multiple ? itemsRef.current.length : 0;
|
|
46
|
+
const remaining = Math.max(0, maxFiles - existing);
|
|
47
|
+
if (incoming.length > remaining) {
|
|
48
|
+
skipped = incoming.length - remaining;
|
|
49
|
+
incoming = incoming.slice(0, remaining);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (skipped > 0) {
|
|
53
|
+
const accepted = incoming.length;
|
|
54
|
+
const skippedWord = skipped === 1 ? "was" : "were";
|
|
55
|
+
toaster.create(
|
|
56
|
+
accepted > 0 ? `Added ${accepted} file${accepted === 1 ? "" : "s"}. ${skipped} ${skippedWord} skipped because the limit is ${maxFiles}.` : `${skipped} file${skipped === 1 ? "" : "s"} ${skippedWord} skipped because the limit is ${maxFiles}.`,
|
|
57
|
+
{ type: "warning" }
|
|
58
|
+
);
|
|
47
59
|
}
|
|
48
60
|
if (!onUpload || readOnly || incoming.length === 0) {
|
|
49
61
|
return;
|
|
@@ -2657,6 +2657,20 @@ var definitions = {
|
|
|
2657
2657
|
$ref: "#/definitions/ProteusNode",
|
|
2658
2658
|
description: "Actions available for this document"
|
|
2659
2659
|
},
|
|
2660
|
+
appearance: {
|
|
2661
|
+
anyOf: [
|
|
2662
|
+
{
|
|
2663
|
+
"const": "default"
|
|
2664
|
+
},
|
|
2665
|
+
{
|
|
2666
|
+
"const": "inline"
|
|
2667
|
+
},
|
|
2668
|
+
{
|
|
2669
|
+
$ref: "#/definitions/ProteusExpression"
|
|
2670
|
+
}
|
|
2671
|
+
],
|
|
2672
|
+
description: "Visual treatment of the document shell. 'default' renders the document as a card with background, border, and padding. 'inline' strips the surrounding chrome so the document blends into its host container."
|
|
2673
|
+
},
|
|
2660
2674
|
appIcon: {
|
|
2661
2675
|
description: "URL or data URI for the application icon (e.g., 'https://example.com/icon.png' or 'data:image/svg+xml,...'). Rendered as an <img> element.",
|
|
2662
2676
|
type: "string"
|
|
@@ -2645,6 +2645,20 @@ var definitions = {
|
|
|
2645
2645
|
$ref: "#/definitions/ProteusNode",
|
|
2646
2646
|
description: "Actions available for this document"
|
|
2647
2647
|
},
|
|
2648
|
+
appearance: {
|
|
2649
|
+
anyOf: [
|
|
2650
|
+
{
|
|
2651
|
+
"const": "default"
|
|
2652
|
+
},
|
|
2653
|
+
{
|
|
2654
|
+
"const": "inline"
|
|
2655
|
+
},
|
|
2656
|
+
{
|
|
2657
|
+
$ref: "#/definitions/ProteusExpression"
|
|
2658
|
+
}
|
|
2659
|
+
],
|
|
2660
|
+
description: "Visual treatment of the document shell. 'default' renders the document as a card with background, border, and padding. 'inline' strips the surrounding chrome so the document blends into its host container."
|
|
2661
|
+
},
|
|
2648
2662
|
appIcon: {
|
|
2649
2663
|
description: "URL or data URI for the application icon (e.g., 'https://example.com/icon.png' or 'data:image/svg+xml,...'). Rendered as an <img> element.",
|
|
2650
2664
|
type: "string"
|
package/dist/index.d.ts
CHANGED
|
@@ -340,6 +340,7 @@ type ProteusDocumentShellProps = Pick<ComponentPropsWithoutRef<typeof Disclosure
|
|
|
340
340
|
};
|
|
341
341
|
type ProteusDocument$2 = {
|
|
342
342
|
actions?: ReactNode;
|
|
343
|
+
appearance?: "default" | "inline" | Record<string, unknown>;
|
|
343
344
|
appIcon?: string;
|
|
344
345
|
appName?: string;
|
|
345
346
|
blocking?: boolean;
|
|
@@ -416,6 +417,7 @@ type ProteusDocumentRendererProps = Omit<ComponentPropsWithoutRef<typeof Proteus
|
|
|
416
417
|
type ProteusDocument = {
|
|
417
418
|
$type: "Document";
|
|
418
419
|
actions?: unknown;
|
|
420
|
+
appearance?: "default" | "inline" | Record<string, unknown>;
|
|
419
421
|
appIcon?: string;
|
|
420
422
|
appName?: string;
|
|
421
423
|
blocking?: boolean;
|