@assistant-ui/react 0.10.6 → 0.10.7
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/primitives/composer/ComposerAddAttachment.d.ts.map +1 -1
- package/dist/primitives/composer/ComposerAddAttachment.js +8 -0
- package/dist/primitives/composer/ComposerAddAttachment.js.map +1 -1
- package/dist/tests/setup.js +8 -8
- package/dist/tests/setup.js.map +1 -1
- package/package.json +13 -13
- package/src/primitives/composer/ComposerAddAttachment.tsx +12 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ComposerAddAttachment.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerAddAttachment.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,MAAM,gCAAgC,CAAC;AAIxC,QAAA,MAAM,wBAAwB,GAAI,gBAE/B;IACD,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC3B,
|
1
|
+
{"version":3,"file":"ComposerAddAttachment.d.ts","sourceRoot":"","sources":["../../../src/primitives/composer/ComposerAddAttachment.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,MAAM,gCAAgC,CAAC;AAIxC,QAAA,MAAM,wBAAwB,GAAI,gBAE/B;IACD,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAC3B,wBAsCL,CAAC;AAEF,yBAAiB,8BAA8B,CAAC;IAC9C,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,wBAAwB,CAAC,CAAC;CACxE;AAED,eAAO,MAAM,8BAA8B;;;IA/CzC,qCAAqC;eAC1B,OAAO,GAAG,SAAS;qDAkD/B,CAAC"}
|
@@ -15,16 +15,24 @@ var useComposerAddAttachment = ({
|
|
15
15
|
const input = document.createElement("input");
|
16
16
|
input.type = "file";
|
17
17
|
input.multiple = multiple;
|
18
|
+
input.hidden = true;
|
18
19
|
const attachmentAccept = composerRuntime.getAttachmentAccept();
|
19
20
|
if (attachmentAccept !== "*") {
|
20
21
|
input.accept = attachmentAccept;
|
21
22
|
}
|
23
|
+
document.body.appendChild(input);
|
22
24
|
input.onchange = (e) => {
|
23
25
|
const fileList = e.target.files;
|
24
26
|
if (!fileList) return;
|
25
27
|
for (const file of fileList) {
|
26
28
|
composerRuntime.addAttachment(file);
|
27
29
|
}
|
30
|
+
document.body.removeChild(input);
|
31
|
+
};
|
32
|
+
input.oncancel = () => {
|
33
|
+
if (!input.files || input.files.length === 0) {
|
34
|
+
document.body.removeChild(input);
|
35
|
+
}
|
28
36
|
};
|
29
37
|
input.click();
|
30
38
|
}, [composerRuntime, multiple]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/primitives/composer/ComposerAddAttachment.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ActionButtonElement,\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport { useComposer, useComposerRuntime } from \"../../context\";\n\nconst useComposerAddAttachment = ({\n multiple = true,\n}: {\n /** allow selecting multiple files */\n multiple?: boolean | undefined;\n} = {}) => {\n const disabled = useComposer((c) => !c.isEditing);\n\n const composerRuntime = useComposerRuntime();\n const callback = useCallback(() => {\n const input = document.createElement(\"input\");\n input.type = \"file\";\n input.multiple = multiple;\n\n const attachmentAccept = composerRuntime.getAttachmentAccept();\n if (attachmentAccept !== \"*\") {\n input.accept = attachmentAccept;\n }\n\n input.onchange = (e) => {\n const fileList = (e.target as HTMLInputElement).files;\n if (!fileList) return;\n for (const file of fileList) {\n composerRuntime.addAttachment(file);\n }\n };\n\n input.click();\n }, [composerRuntime, multiple]);\n\n if (disabled) return null;\n return callback;\n};\n\nexport namespace ComposerPrimitiveAddAttachment {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useComposerAddAttachment>;\n}\n\nexport const ComposerPrimitiveAddAttachment = createActionButton(\n \"ComposerPrimitive.AddAttachment\",\n useComposerAddAttachment,\n [\"multiple\"],\n);\n"],"mappings":";;;AAEA;AAAA,EAGE;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,aAAa,0BAA0B;AAEhD,IAAM,2BAA2B,CAAC;AAAA,EAChC,WAAW;AACb,IAGI,CAAC,MAAM;AACT,QAAM,WAAW,YAAY,CAAC,MAAM,CAAC,EAAE,SAAS;AAEhD,QAAM,kBAAkB,mBAAmB;AAC3C,QAAM,WAAW,YAAY,MAAM;AACjC,UAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,UAAM,OAAO;AACb,UAAM,WAAW;
|
1
|
+
{"version":3,"sources":["../../../src/primitives/composer/ComposerAddAttachment.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ActionButtonElement,\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport { useComposer, useComposerRuntime } from \"../../context\";\n\nconst useComposerAddAttachment = ({\n multiple = true,\n}: {\n /** allow selecting multiple files */\n multiple?: boolean | undefined;\n} = {}) => {\n const disabled = useComposer((c) => !c.isEditing);\n\n const composerRuntime = useComposerRuntime();\n const callback = useCallback(() => {\n const input = document.createElement(\"input\");\n input.type = \"file\";\n input.multiple = multiple;\n input.hidden = true;\n\n const attachmentAccept = composerRuntime.getAttachmentAccept();\n if (attachmentAccept !== \"*\") {\n input.accept = attachmentAccept;\n }\n \n document.body.appendChild(input);\n \n input.onchange = (e) => {\n const fileList = (e.target as HTMLInputElement).files;\n if (!fileList) return;\n for (const file of fileList) {\n composerRuntime.addAttachment(file);\n }\n\n document.body.removeChild(input);\n };\n\n input.oncancel = () => {\n if (!input.files || input.files.length === 0) {\n document.body.removeChild(input);\n }\n }\n \n input.click();\n }, [composerRuntime, multiple]);\n\n if (disabled) return null;\n return callback;\n};\n\nexport namespace ComposerPrimitiveAddAttachment {\n export type Element = ActionButtonElement;\n export type Props = ActionButtonProps<typeof useComposerAddAttachment>;\n}\n\nexport const ComposerPrimitiveAddAttachment = createActionButton(\n \"ComposerPrimitive.AddAttachment\",\n useComposerAddAttachment,\n [\"multiple\"],\n);\n"],"mappings":";;;AAEA;AAAA,EAGE;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,aAAa,0BAA0B;AAEhD,IAAM,2BAA2B,CAAC;AAAA,EAChC,WAAW;AACb,IAGI,CAAC,MAAM;AACT,QAAM,WAAW,YAAY,CAAC,MAAM,CAAC,EAAE,SAAS;AAEhD,QAAM,kBAAkB,mBAAmB;AAC3C,QAAM,WAAW,YAAY,MAAM;AACjC,UAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,UAAM,OAAO;AACb,UAAM,WAAW;AACjB,UAAM,SAAS;AAEf,UAAM,mBAAmB,gBAAgB,oBAAoB;AAC7D,QAAI,qBAAqB,KAAK;AAC5B,YAAM,SAAS;AAAA,IACjB;AAEA,aAAS,KAAK,YAAY,KAAK;AAE/B,UAAM,WAAW,CAAC,MAAM;AACtB,YAAM,WAAY,EAAE,OAA4B;AAChD,UAAI,CAAC,SAAU;AACf,iBAAW,QAAQ,UAAU;AAC3B,wBAAgB,cAAc,IAAI;AAAA,MACpC;AAEA,eAAS,KAAK,YAAY,KAAK;AAAA,IACjC;AAEA,UAAM,WAAW,MAAM;AACrB,UAAI,CAAC,MAAM,SAAS,MAAM,MAAM,WAAW,GAAG;AAC5C,iBAAS,KAAK,YAAY,KAAK;AAAA,MACjC;AAAA,IACF;AAEA,UAAM,MAAM;AAAA,EACd,GAAG,CAAC,iBAAiB,QAAQ,CAAC;AAE9B,MAAI,SAAU,QAAO;AACrB,SAAO;AACT;AAOO,IAAM,iCAAiC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA,CAAC,UAAU;AACb;","names":[]}
|
package/dist/tests/setup.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
// ../../node_modules/.pnpm/vitest@3.1.
|
1
|
+
// ../../node_modules/.pnpm/vitest@3.1.3_@types+debug@4.1.12_@types+node@22.15.18_jiti@2.4.2_lightningcss@1.30.1_terser@5.39.0_tsx@4.19.4/node_modules/vitest/dist/chunks/vi.ClIskdbk.js
|
2
2
|
import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters, customMatchers } from "@vitest/expect.js";
|
3
3
|
import { getCurrentTest } from "@vitest/runner.js";
|
4
4
|
import { getNames, getTestName } from "@vitest/runner/utils.js";
|
5
5
|
import * as chai$1 from "chai.js";
|
6
6
|
|
7
|
-
// ../../node_modules/.pnpm/vitest@3.1.
|
7
|
+
// ../../node_modules/.pnpm/vitest@3.1.3_@types+debug@4.1.12_@types+node@22.15.18_jiti@2.4.2_lightningcss@1.30.1_terser@5.39.0_tsx@4.19.4/node_modules/vitest/dist/chunks/utils.CgTj3MsC.js
|
8
8
|
import { getSafeTimers } from "@vitest/utils.js";
|
9
9
|
var NAME_WORKER_STATE = "__vitest_worker__";
|
10
10
|
function getWorkerState() {
|
@@ -61,22 +61,22 @@ async function waitForImportsToResolve() {
|
|
61
61
|
await waitForImportsToResolve();
|
62
62
|
}
|
63
63
|
|
64
|
-
// ../../node_modules/.pnpm/vitest@3.1.
|
64
|
+
// ../../node_modules/.pnpm/vitest@3.1.3_@types+debug@4.1.12_@types+node@22.15.18_jiti@2.4.2_lightningcss@1.30.1_terser@5.39.0_tsx@4.19.4/node_modules/vitest/dist/chunks/vi.ClIskdbk.js
|
65
65
|
import { getSafeTimers as getSafeTimers2, assertTypes, createSimpleStackTrace } from "@vitest/utils.js";
|
66
66
|
|
67
|
-
// ../../node_modules/.pnpm/vitest@3.1.
|
67
|
+
// ../../node_modules/.pnpm/vitest@3.1.3_@types+debug@4.1.12_@types+node@22.15.18_jiti@2.4.2_lightningcss@1.30.1_terser@5.39.0_tsx@4.19.4/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js
|
68
68
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
69
69
|
function getDefaultExportFromCjs(x) {
|
70
70
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
71
71
|
}
|
72
72
|
|
73
|
-
// ../../node_modules/.pnpm/vitest@3.1.
|
73
|
+
// ../../node_modules/.pnpm/vitest@3.1.3_@types+debug@4.1.12_@types+node@22.15.18_jiti@2.4.2_lightningcss@1.30.1_terser@5.39.0_tsx@4.19.4/node_modules/vitest/dist/chunks/vi.ClIskdbk.js
|
74
74
|
import { stripSnapshotIndentation, addSerializer, SnapshotClient } from "@vitest/snapshot.js";
|
75
75
|
import "@vitest/utils/error.js";
|
76
76
|
import { fn, spyOn, mocks, isMockFunction } from "@vitest/spy.js";
|
77
77
|
import { parseSingleStack } from "@vitest/utils/source-map.js";
|
78
78
|
|
79
|
-
// ../../node_modules/.pnpm/vitest@3.1.
|
79
|
+
// ../../node_modules/.pnpm/vitest@3.1.3_@types+debug@4.1.12_@types+node@22.15.18_jiti@2.4.2_lightningcss@1.30.1_terser@5.39.0_tsx@4.19.4/node_modules/vitest/dist/chunks/date.CDOsz-HY.js
|
80
80
|
var RealDate = Date;
|
81
81
|
var now = null;
|
82
82
|
var MockDate = class _MockDate extends RealDate {
|
@@ -129,7 +129,7 @@ function resetDate() {
|
|
129
129
|
globalThis.Date = RealDate;
|
130
130
|
}
|
131
131
|
|
132
|
-
// ../../node_modules/.pnpm/vitest@3.1.
|
132
|
+
// ../../node_modules/.pnpm/vitest@3.1.3_@types+debug@4.1.12_@types+node@22.15.18_jiti@2.4.2_lightningcss@1.30.1_terser@5.39.0_tsx@4.19.4/node_modules/vitest/dist/chunks/vi.ClIskdbk.js
|
133
133
|
var unsupported = [
|
134
134
|
"matchSnapshot",
|
135
135
|
"toMatchSnapshot",
|
@@ -2953,7 +2953,7 @@ function getImporter(name) {
|
|
2953
2953
|
return stack?.file || "";
|
2954
2954
|
}
|
2955
2955
|
|
2956
|
-
// ../../node_modules/.pnpm/vitest@3.1.
|
2956
|
+
// ../../node_modules/.pnpm/vitest@3.1.3_@types+debug@4.1.12_@types+node@22.15.18_jiti@2.4.2_lightningcss@1.30.1_terser@5.39.0_tsx@4.19.4/node_modules/vitest/dist/index.js
|
2957
2957
|
import { expectTypeOf } from "expect-type.js";
|
2958
2958
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from "@vitest/runner.js";
|
2959
2959
|
import * as chai2 from "chai.js";
|