@sparkstudio/storage-ui 1.0.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/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # React + TypeScript + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
9
+
10
+ ## React Compiler
11
+
12
+ The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13
+
14
+ ## Expanding the ESLint configuration
15
+
16
+ If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
17
+
18
+ ```js
19
+ export default defineConfig([
20
+ globalIgnores(['dist']),
21
+ {
22
+ files: ['**/*.{ts,tsx}'],
23
+ extends: [
24
+ // Other configs...
25
+
26
+ // Remove tseslint.configs.recommended and replace with this
27
+ tseslint.configs.recommendedTypeChecked,
28
+ // Alternatively, use this for stricter rules
29
+ tseslint.configs.strictTypeChecked,
30
+ // Optionally, add this for stylistic rules
31
+ tseslint.configs.stylisticTypeChecked,
32
+
33
+ // Other configs...
34
+ ],
35
+ languageOptions: {
36
+ parserOptions: {
37
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
38
+ tsconfigRootDir: import.meta.dirname,
39
+ },
40
+ // other options...
41
+ },
42
+ },
43
+ ])
44
+ ```
45
+
46
+ You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47
+
48
+ ```js
49
+ // eslint.config.js
50
+ import reactX from 'eslint-plugin-react-x'
51
+ import reactDom from 'eslint-plugin-react-dom'
52
+
53
+ export default defineConfig([
54
+ globalIgnores(['dist']),
55
+ {
56
+ files: ['**/*.{ts,tsx}'],
57
+ extends: [
58
+ // Other configs...
59
+ // Enable lint rules for React
60
+ reactX.configs['recommended-typescript'],
61
+ // Enable lint rules for React DOM
62
+ reactDom.configs.recommended,
63
+ ],
64
+ languageOptions: {
65
+ parserOptions: {
66
+ project: ['./tsconfig.node.json', './tsconfig.app.json'],
67
+ tsconfigRootDir: import.meta.dirname,
68
+ },
69
+ // other options...
70
+ },
71
+ },
72
+ ])
73
+ ```
package/dist/index.cjs ADDED
@@ -0,0 +1,310 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AWSCredentialsDTO: () => AWSCredentialsDTO,
24
+ Container: () => Container,
25
+ ContainerDTO: () => ContainerDTO,
26
+ ContainerType: () => ContainerType,
27
+ Home: () => Home,
28
+ HomeView: () => HomeView,
29
+ SparkStudioStorageSDK: () => SparkStudioStorageSDK,
30
+ UploadContainer: () => UploadContainer
31
+ });
32
+ module.exports = __toCommonJS(index_exports);
33
+
34
+ // src/api/Controllers/Container.ts
35
+ var Container = class {
36
+ baseUrl;
37
+ constructor(baseUrl) {
38
+ this.baseUrl = baseUrl;
39
+ }
40
+ async ReadChildrenByContainerId(parentId) {
41
+ const url = `${this.baseUrl}/api/Container/ReadChildrenByContainerId/` + parentId;
42
+ const token = localStorage.getItem("auth_token");
43
+ const requestOptions = {
44
+ method: "GET",
45
+ headers: {
46
+ "Content-Type": "application/json",
47
+ ...token && { Authorization: `Bearer ${token}` }
48
+ }
49
+ };
50
+ const response = await fetch(url, requestOptions);
51
+ if (!response.ok) throw new Error(await response.text());
52
+ return await response.json();
53
+ }
54
+ async ReadRootContainers() {
55
+ const url = `${this.baseUrl}/api/Container/ReadRootContainers`;
56
+ const token = localStorage.getItem("auth_token");
57
+ const requestOptions = {
58
+ method: "GET",
59
+ headers: {
60
+ "Content-Type": "application/json",
61
+ ...token && { Authorization: `Bearer ${token}` }
62
+ }
63
+ };
64
+ const response = await fetch(url, requestOptions);
65
+ if (!response.ok) throw new Error(await response.text());
66
+ return await response.json();
67
+ }
68
+ async Read(id) {
69
+ const url = `${this.baseUrl}/api/Container/Read/` + id;
70
+ const token = localStorage.getItem("auth_token");
71
+ const requestOptions = {
72
+ method: "GET",
73
+ headers: {
74
+ "Content-Type": "application/json",
75
+ ...token && { Authorization: `Bearer ${token}` }
76
+ }
77
+ };
78
+ const response = await fetch(url, requestOptions);
79
+ if (!response.ok) throw new Error(await response.text());
80
+ return await response.json();
81
+ }
82
+ async Create(containerDTO) {
83
+ const url = `${this.baseUrl}/api/Container/Create`;
84
+ const token = localStorage.getItem("auth_token");
85
+ const requestOptions = {
86
+ method: "POST",
87
+ headers: {
88
+ "Content-Type": "application/json",
89
+ ...token && { Authorization: `Bearer ${token}` }
90
+ },
91
+ body: JSON.stringify(containerDTO)
92
+ };
93
+ const response = await fetch(url, requestOptions);
94
+ if (!response.ok) throw new Error(await response.text());
95
+ return await response.json();
96
+ }
97
+ async Update(containerDTO) {
98
+ const url = `${this.baseUrl}/api/Container/Update`;
99
+ const token = localStorage.getItem("auth_token");
100
+ const requestOptions = {
101
+ method: "POST",
102
+ headers: {
103
+ "Content-Type": "application/json",
104
+ ...token && { Authorization: `Bearer ${token}` }
105
+ },
106
+ body: JSON.stringify(containerDTO)
107
+ };
108
+ const response = await fetch(url, requestOptions);
109
+ if (!response.ok) throw new Error(await response.text());
110
+ return await response.json();
111
+ }
112
+ async Delete(id) {
113
+ const url = `${this.baseUrl}/api/Container/Delete/` + id;
114
+ const token = localStorage.getItem("auth_token");
115
+ const requestOptions = {
116
+ method: "GET",
117
+ headers: {
118
+ "Content-Type": "application/json",
119
+ ...token && { Authorization: `Bearer ${token}` }
120
+ }
121
+ };
122
+ const response = await fetch(url, requestOptions);
123
+ if (!response.ok) throw new Error(await response.text());
124
+ return await response.json();
125
+ }
126
+ async GetUploadCredentials() {
127
+ const url = `${this.baseUrl}/api/Container/GetUploadCredentials`;
128
+ const token = localStorage.getItem("auth_token");
129
+ const requestOptions = {
130
+ method: "GET",
131
+ headers: {
132
+ "Content-Type": "application/json",
133
+ ...token && { Authorization: `Bearer ${token}` }
134
+ }
135
+ };
136
+ const response = await fetch(url, requestOptions);
137
+ if (!response.ok) throw new Error(await response.text());
138
+ return await response.json();
139
+ }
140
+ };
141
+
142
+ // src/api/Controllers/Home.ts
143
+ var Home = class {
144
+ baseUrl;
145
+ constructor(baseUrl) {
146
+ this.baseUrl = baseUrl;
147
+ }
148
+ };
149
+
150
+ // src/api/SparkStudioStorageSDK.ts
151
+ var SparkStudioStorageSDK = class {
152
+ container;
153
+ home;
154
+ constructor(baseUrl) {
155
+ this.container = new Container(baseUrl);
156
+ this.home = new Home(baseUrl);
157
+ }
158
+ };
159
+
160
+ // src/api/DTOs/AWSCredentialsDTO.ts
161
+ var AWSCredentialsDTO = class {
162
+ AccessKeyId;
163
+ SecretAccessKey;
164
+ SessionToken;
165
+ BucketName;
166
+ Region;
167
+ constructor(init) {
168
+ this.AccessKeyId = init.AccessKeyId;
169
+ this.SecretAccessKey = init.SecretAccessKey;
170
+ this.SessionToken = init.SessionToken;
171
+ this.BucketName = init.BucketName;
172
+ this.Region = init.Region;
173
+ }
174
+ };
175
+
176
+ // src/api/DTOs/ContainerDTO.ts
177
+ var ContainerDTO = class {
178
+ Id;
179
+ ContainerType;
180
+ Name;
181
+ CreatedDate;
182
+ FileSize;
183
+ UserId;
184
+ ParentContainerId;
185
+ constructor(init) {
186
+ this.Id = init.Id;
187
+ this.ContainerType = init.ContainerType;
188
+ this.Name = init.Name;
189
+ this.CreatedDate = init.CreatedDate;
190
+ this.FileSize = init.FileSize;
191
+ this.UserId = init.UserId;
192
+ this.ParentContainerId = init.ParentContainerId;
193
+ }
194
+ };
195
+
196
+ // src/api/Enums/ContainerType.ts
197
+ var ContainerType = /* @__PURE__ */ ((ContainerType2) => {
198
+ ContainerType2[ContainerType2["File"] = 0] = "File";
199
+ ContainerType2[ContainerType2["Folder"] = 1] = "Folder";
200
+ ContainerType2[ContainerType2["Root"] = 2] = "Root";
201
+ return ContainerType2;
202
+ })(ContainerType || {});
203
+
204
+ // src/components/UploadContainer.tsx
205
+ var import_react = require("react");
206
+ var import_jsx_runtime = require("react/jsx-runtime");
207
+ var UploadContainer = ({
208
+ title = "Upload files",
209
+ description = "Drag and drop files here, or click the button to browse.",
210
+ multiple = true,
211
+ accept,
212
+ onFilesSelected
213
+ }) => {
214
+ const [isDragging, setIsDragging] = (0, import_react.useState)(false);
215
+ const [fileNames, setFileNames] = (0, import_react.useState)([]);
216
+ const handleDragOver = (e) => {
217
+ e.preventDefault();
218
+ setIsDragging(true);
219
+ };
220
+ const handleDragLeave = (e) => {
221
+ e.preventDefault();
222
+ setIsDragging(false);
223
+ };
224
+ const handleDrop = (e) => {
225
+ e.preventDefault();
226
+ setIsDragging(false);
227
+ const files = e.dataTransfer.files;
228
+ if (!files || files.length === 0) return;
229
+ setFileNames(Array.from(files).map((f) => f.name));
230
+ onFilesSelected?.(files);
231
+ };
232
+ const handleFileChange = (e) => {
233
+ const files = e.target.files;
234
+ if (!files || files.length === 0) return;
235
+ setFileNames(Array.from(files).map((f) => f.name));
236
+ onFilesSelected?.(files);
237
+ };
238
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "container my-3", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "card shadow-sm", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "card-body", children: [
239
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h5", { className: "card-title mb-2", children: title }),
240
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "card-text text-muted", children: description }),
241
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
242
+ "div",
243
+ {
244
+ className: "border rounded-3 p-4 text-center mb-3 d-flex flex-column align-items-center justify-content-center " + (isDragging ? "bg-light border-primary" : "border-secondary border-dashed"),
245
+ style: { cursor: "pointer", minHeight: "140px" },
246
+ onDragOver: handleDragOver,
247
+ onDragLeave: handleDragLeave,
248
+ onDrop: handleDrop,
249
+ children: [
250
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: "bi bi-cloud-arrow-up fs-1 mb-2" }),
251
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "mb-2", children: "Drop files here" }),
252
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("small", { className: "text-muted", children: "or click the button below" })
253
+ ]
254
+ }
255
+ ),
256
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "d-flex gap-2 align-items-center", children: [
257
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "btn btn-primary mb-0", children: [
258
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("i", { className: "bi bi-folder2-open me-2" }),
259
+ "Browse files",
260
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
261
+ "input",
262
+ {
263
+ type: "file",
264
+ className: "d-none",
265
+ multiple,
266
+ accept,
267
+ onChange: handleFileChange
268
+ }
269
+ )
270
+ ] }),
271
+ fileNames.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex-grow-1", children: [
272
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "small text-muted", children: "Selected:" }),
273
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "mb-0 small", children: fileNames.map((name) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: name }, name)) })
274
+ ] })
275
+ ] })
276
+ ] }) }) });
277
+ };
278
+
279
+ // src/views/HomeView.tsx
280
+ var import_authentication_ui = require("@sparkstudio/authentication-ui");
281
+ var import_jsx_runtime2 = require("react/jsx-runtime");
282
+ function HomeView() {
283
+ function handleOnLoginSuccess(user) {
284
+ alert(user?.Id);
285
+ }
286
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
287
+ import_authentication_ui.AuthenticatorProvider,
288
+ {
289
+ googleClientId: import_authentication_ui.AppSettings.GoogleClientId,
290
+ authenticationUrl: import_authentication_ui.AppSettings.AuthenticationUrl,
291
+ accountsUrl: import_authentication_ui.AppSettings.AccountsUrl,
292
+ onLoginSuccess: handleOnLoginSuccess,
293
+ children: [
294
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_authentication_ui.UserInfoCard, {}),
295
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(UploadContainer, {})
296
+ ]
297
+ }
298
+ );
299
+ }
300
+ // Annotate the CommonJS export names for ESM import in node:
301
+ 0 && (module.exports = {
302
+ AWSCredentialsDTO,
303
+ Container,
304
+ ContainerDTO,
305
+ ContainerType,
306
+ Home,
307
+ HomeView,
308
+ SparkStudioStorageSDK,
309
+ UploadContainer
310
+ });
package/dist/index.css ADDED
@@ -0,0 +1,3 @@
1
+ @import "/node_modules/@sparkstudio/common-ui/dist/index.css";
2
+
3
+ /*# sourceMappingURL=index.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sourceRoot":"","sources":["../src/index.scss"],"names":[],"mappings":"AAAQ","file":"index.css"}
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+
4
+ declare enum ContainerType {
5
+ File = 0,
6
+ Folder = 1,
7
+ Root = 2
8
+ }
9
+
10
+ /**
11
+ * Represents an Auto-generated model for ContainerDTO.
12
+ */
13
+ interface IContainerDTO {
14
+ Id: string;
15
+ ContainerType: ContainerType;
16
+ Name?: string;
17
+ CreatedDate: string;
18
+ FileSize: number;
19
+ UserId: string;
20
+ ParentContainerId: string;
21
+ }
22
+ type ContainerDTOInit = Partial<IContainerDTO> & Pick<IContainerDTO, "Id" | "ContainerType" | "CreatedDate" | "FileSize" | "UserId" | "ParentContainerId">;
23
+ declare class ContainerDTO implements IContainerDTO {
24
+ Id: string;
25
+ ContainerType: ContainerType;
26
+ Name?: string;
27
+ CreatedDate: string;
28
+ FileSize: number;
29
+ UserId: string;
30
+ ParentContainerId: string;
31
+ constructor(init: ContainerDTOInit);
32
+ }
33
+
34
+ /**
35
+ * Represents an Auto-generated model for AWSCredentialsDTO.
36
+ */
37
+ interface IAWSCredentialsDTO {
38
+ AccessKeyId?: string;
39
+ SecretAccessKey?: string;
40
+ SessionToken?: string;
41
+ BucketName?: string;
42
+ Region?: string;
43
+ }
44
+ type AWSCredentialsDTOInit = Partial<IAWSCredentialsDTO>;
45
+ declare class AWSCredentialsDTO implements IAWSCredentialsDTO {
46
+ AccessKeyId?: string;
47
+ SecretAccessKey?: string;
48
+ SessionToken?: string;
49
+ BucketName?: string;
50
+ Region?: string;
51
+ constructor(init: AWSCredentialsDTOInit);
52
+ }
53
+
54
+ /**
55
+ * Auto-generated client for the Container controller.
56
+ */
57
+ declare class Container {
58
+ private baseUrl;
59
+ constructor(baseUrl: string);
60
+ ReadChildrenByContainerId(parentId: string): Promise<ContainerDTO[]>;
61
+ ReadRootContainers(): Promise<ContainerDTO[]>;
62
+ Read(id: string): Promise<ContainerDTO>;
63
+ Create(containerDTO: ContainerDTO): Promise<ContainerDTO>;
64
+ Update(containerDTO: ContainerDTO): Promise<ContainerDTO>;
65
+ Delete(id: string): Promise<ContainerDTO>;
66
+ GetUploadCredentials(): Promise<AWSCredentialsDTO>;
67
+ }
68
+
69
+ /**
70
+ * Auto-generated client for the Home controller.
71
+ */
72
+ declare class Home {
73
+ private baseUrl;
74
+ constructor(baseUrl: string);
75
+ }
76
+
77
+ /**
78
+ * Auto-generated API client.
79
+ */
80
+ declare class SparkStudioStorageSDK {
81
+ container: Container;
82
+ home: Home;
83
+ constructor(baseUrl: string);
84
+ }
85
+
86
+ interface UploadContainerProps {
87
+ title?: string;
88
+ description?: string;
89
+ multiple?: boolean;
90
+ accept?: string;
91
+ onFilesSelected?: (files: FileList) => void;
92
+ }
93
+ declare const UploadContainer: React.FC<UploadContainerProps>;
94
+
95
+ declare function HomeView(): react_jsx_runtime.JSX.Element;
96
+
97
+ export { AWSCredentialsDTO, Container, ContainerDTO, ContainerType, Home, HomeView, type IAWSCredentialsDTO, type IContainerDTO, SparkStudioStorageSDK, UploadContainer, type UploadContainerProps };
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+
4
+ declare enum ContainerType {
5
+ File = 0,
6
+ Folder = 1,
7
+ Root = 2
8
+ }
9
+
10
+ /**
11
+ * Represents an Auto-generated model for ContainerDTO.
12
+ */
13
+ interface IContainerDTO {
14
+ Id: string;
15
+ ContainerType: ContainerType;
16
+ Name?: string;
17
+ CreatedDate: string;
18
+ FileSize: number;
19
+ UserId: string;
20
+ ParentContainerId: string;
21
+ }
22
+ type ContainerDTOInit = Partial<IContainerDTO> & Pick<IContainerDTO, "Id" | "ContainerType" | "CreatedDate" | "FileSize" | "UserId" | "ParentContainerId">;
23
+ declare class ContainerDTO implements IContainerDTO {
24
+ Id: string;
25
+ ContainerType: ContainerType;
26
+ Name?: string;
27
+ CreatedDate: string;
28
+ FileSize: number;
29
+ UserId: string;
30
+ ParentContainerId: string;
31
+ constructor(init: ContainerDTOInit);
32
+ }
33
+
34
+ /**
35
+ * Represents an Auto-generated model for AWSCredentialsDTO.
36
+ */
37
+ interface IAWSCredentialsDTO {
38
+ AccessKeyId?: string;
39
+ SecretAccessKey?: string;
40
+ SessionToken?: string;
41
+ BucketName?: string;
42
+ Region?: string;
43
+ }
44
+ type AWSCredentialsDTOInit = Partial<IAWSCredentialsDTO>;
45
+ declare class AWSCredentialsDTO implements IAWSCredentialsDTO {
46
+ AccessKeyId?: string;
47
+ SecretAccessKey?: string;
48
+ SessionToken?: string;
49
+ BucketName?: string;
50
+ Region?: string;
51
+ constructor(init: AWSCredentialsDTOInit);
52
+ }
53
+
54
+ /**
55
+ * Auto-generated client for the Container controller.
56
+ */
57
+ declare class Container {
58
+ private baseUrl;
59
+ constructor(baseUrl: string);
60
+ ReadChildrenByContainerId(parentId: string): Promise<ContainerDTO[]>;
61
+ ReadRootContainers(): Promise<ContainerDTO[]>;
62
+ Read(id: string): Promise<ContainerDTO>;
63
+ Create(containerDTO: ContainerDTO): Promise<ContainerDTO>;
64
+ Update(containerDTO: ContainerDTO): Promise<ContainerDTO>;
65
+ Delete(id: string): Promise<ContainerDTO>;
66
+ GetUploadCredentials(): Promise<AWSCredentialsDTO>;
67
+ }
68
+
69
+ /**
70
+ * Auto-generated client for the Home controller.
71
+ */
72
+ declare class Home {
73
+ private baseUrl;
74
+ constructor(baseUrl: string);
75
+ }
76
+
77
+ /**
78
+ * Auto-generated API client.
79
+ */
80
+ declare class SparkStudioStorageSDK {
81
+ container: Container;
82
+ home: Home;
83
+ constructor(baseUrl: string);
84
+ }
85
+
86
+ interface UploadContainerProps {
87
+ title?: string;
88
+ description?: string;
89
+ multiple?: boolean;
90
+ accept?: string;
91
+ onFilesSelected?: (files: FileList) => void;
92
+ }
93
+ declare const UploadContainer: React.FC<UploadContainerProps>;
94
+
95
+ declare function HomeView(): react_jsx_runtime.JSX.Element;
96
+
97
+ export { AWSCredentialsDTO, Container, ContainerDTO, ContainerType, Home, HomeView, type IAWSCredentialsDTO, type IContainerDTO, SparkStudioStorageSDK, UploadContainer, type UploadContainerProps };
package/dist/index.js ADDED
@@ -0,0 +1,276 @@
1
+ // src/api/Controllers/Container.ts
2
+ var Container = class {
3
+ baseUrl;
4
+ constructor(baseUrl) {
5
+ this.baseUrl = baseUrl;
6
+ }
7
+ async ReadChildrenByContainerId(parentId) {
8
+ const url = `${this.baseUrl}/api/Container/ReadChildrenByContainerId/` + parentId;
9
+ const token = localStorage.getItem("auth_token");
10
+ const requestOptions = {
11
+ method: "GET",
12
+ headers: {
13
+ "Content-Type": "application/json",
14
+ ...token && { Authorization: `Bearer ${token}` }
15
+ }
16
+ };
17
+ const response = await fetch(url, requestOptions);
18
+ if (!response.ok) throw new Error(await response.text());
19
+ return await response.json();
20
+ }
21
+ async ReadRootContainers() {
22
+ const url = `${this.baseUrl}/api/Container/ReadRootContainers`;
23
+ const token = localStorage.getItem("auth_token");
24
+ const requestOptions = {
25
+ method: "GET",
26
+ headers: {
27
+ "Content-Type": "application/json",
28
+ ...token && { Authorization: `Bearer ${token}` }
29
+ }
30
+ };
31
+ const response = await fetch(url, requestOptions);
32
+ if (!response.ok) throw new Error(await response.text());
33
+ return await response.json();
34
+ }
35
+ async Read(id) {
36
+ const url = `${this.baseUrl}/api/Container/Read/` + id;
37
+ const token = localStorage.getItem("auth_token");
38
+ const requestOptions = {
39
+ method: "GET",
40
+ headers: {
41
+ "Content-Type": "application/json",
42
+ ...token && { Authorization: `Bearer ${token}` }
43
+ }
44
+ };
45
+ const response = await fetch(url, requestOptions);
46
+ if (!response.ok) throw new Error(await response.text());
47
+ return await response.json();
48
+ }
49
+ async Create(containerDTO) {
50
+ const url = `${this.baseUrl}/api/Container/Create`;
51
+ const token = localStorage.getItem("auth_token");
52
+ const requestOptions = {
53
+ method: "POST",
54
+ headers: {
55
+ "Content-Type": "application/json",
56
+ ...token && { Authorization: `Bearer ${token}` }
57
+ },
58
+ body: JSON.stringify(containerDTO)
59
+ };
60
+ const response = await fetch(url, requestOptions);
61
+ if (!response.ok) throw new Error(await response.text());
62
+ return await response.json();
63
+ }
64
+ async Update(containerDTO) {
65
+ const url = `${this.baseUrl}/api/Container/Update`;
66
+ const token = localStorage.getItem("auth_token");
67
+ const requestOptions = {
68
+ method: "POST",
69
+ headers: {
70
+ "Content-Type": "application/json",
71
+ ...token && { Authorization: `Bearer ${token}` }
72
+ },
73
+ body: JSON.stringify(containerDTO)
74
+ };
75
+ const response = await fetch(url, requestOptions);
76
+ if (!response.ok) throw new Error(await response.text());
77
+ return await response.json();
78
+ }
79
+ async Delete(id) {
80
+ const url = `${this.baseUrl}/api/Container/Delete/` + id;
81
+ const token = localStorage.getItem("auth_token");
82
+ const requestOptions = {
83
+ method: "GET",
84
+ headers: {
85
+ "Content-Type": "application/json",
86
+ ...token && { Authorization: `Bearer ${token}` }
87
+ }
88
+ };
89
+ const response = await fetch(url, requestOptions);
90
+ if (!response.ok) throw new Error(await response.text());
91
+ return await response.json();
92
+ }
93
+ async GetUploadCredentials() {
94
+ const url = `${this.baseUrl}/api/Container/GetUploadCredentials`;
95
+ const token = localStorage.getItem("auth_token");
96
+ const requestOptions = {
97
+ method: "GET",
98
+ headers: {
99
+ "Content-Type": "application/json",
100
+ ...token && { Authorization: `Bearer ${token}` }
101
+ }
102
+ };
103
+ const response = await fetch(url, requestOptions);
104
+ if (!response.ok) throw new Error(await response.text());
105
+ return await response.json();
106
+ }
107
+ };
108
+
109
+ // src/api/Controllers/Home.ts
110
+ var Home = class {
111
+ baseUrl;
112
+ constructor(baseUrl) {
113
+ this.baseUrl = baseUrl;
114
+ }
115
+ };
116
+
117
+ // src/api/SparkStudioStorageSDK.ts
118
+ var SparkStudioStorageSDK = class {
119
+ container;
120
+ home;
121
+ constructor(baseUrl) {
122
+ this.container = new Container(baseUrl);
123
+ this.home = new Home(baseUrl);
124
+ }
125
+ };
126
+
127
+ // src/api/DTOs/AWSCredentialsDTO.ts
128
+ var AWSCredentialsDTO = class {
129
+ AccessKeyId;
130
+ SecretAccessKey;
131
+ SessionToken;
132
+ BucketName;
133
+ Region;
134
+ constructor(init) {
135
+ this.AccessKeyId = init.AccessKeyId;
136
+ this.SecretAccessKey = init.SecretAccessKey;
137
+ this.SessionToken = init.SessionToken;
138
+ this.BucketName = init.BucketName;
139
+ this.Region = init.Region;
140
+ }
141
+ };
142
+
143
+ // src/api/DTOs/ContainerDTO.ts
144
+ var ContainerDTO = class {
145
+ Id;
146
+ ContainerType;
147
+ Name;
148
+ CreatedDate;
149
+ FileSize;
150
+ UserId;
151
+ ParentContainerId;
152
+ constructor(init) {
153
+ this.Id = init.Id;
154
+ this.ContainerType = init.ContainerType;
155
+ this.Name = init.Name;
156
+ this.CreatedDate = init.CreatedDate;
157
+ this.FileSize = init.FileSize;
158
+ this.UserId = init.UserId;
159
+ this.ParentContainerId = init.ParentContainerId;
160
+ }
161
+ };
162
+
163
+ // src/api/Enums/ContainerType.ts
164
+ var ContainerType = /* @__PURE__ */ ((ContainerType2) => {
165
+ ContainerType2[ContainerType2["File"] = 0] = "File";
166
+ ContainerType2[ContainerType2["Folder"] = 1] = "Folder";
167
+ ContainerType2[ContainerType2["Root"] = 2] = "Root";
168
+ return ContainerType2;
169
+ })(ContainerType || {});
170
+
171
+ // src/components/UploadContainer.tsx
172
+ import { useState } from "react";
173
+ import { jsx, jsxs } from "react/jsx-runtime";
174
+ var UploadContainer = ({
175
+ title = "Upload files",
176
+ description = "Drag and drop files here, or click the button to browse.",
177
+ multiple = true,
178
+ accept,
179
+ onFilesSelected
180
+ }) => {
181
+ const [isDragging, setIsDragging] = useState(false);
182
+ const [fileNames, setFileNames] = useState([]);
183
+ const handleDragOver = (e) => {
184
+ e.preventDefault();
185
+ setIsDragging(true);
186
+ };
187
+ const handleDragLeave = (e) => {
188
+ e.preventDefault();
189
+ setIsDragging(false);
190
+ };
191
+ const handleDrop = (e) => {
192
+ e.preventDefault();
193
+ setIsDragging(false);
194
+ const files = e.dataTransfer.files;
195
+ if (!files || files.length === 0) return;
196
+ setFileNames(Array.from(files).map((f) => f.name));
197
+ onFilesSelected?.(files);
198
+ };
199
+ const handleFileChange = (e) => {
200
+ const files = e.target.files;
201
+ if (!files || files.length === 0) return;
202
+ setFileNames(Array.from(files).map((f) => f.name));
203
+ onFilesSelected?.(files);
204
+ };
205
+ return /* @__PURE__ */ jsx("div", { className: "container my-3", children: /* @__PURE__ */ jsx("div", { className: "card shadow-sm", children: /* @__PURE__ */ jsxs("div", { className: "card-body", children: [
206
+ /* @__PURE__ */ jsx("h5", { className: "card-title mb-2", children: title }),
207
+ /* @__PURE__ */ jsx("p", { className: "card-text text-muted", children: description }),
208
+ /* @__PURE__ */ jsxs(
209
+ "div",
210
+ {
211
+ className: "border rounded-3 p-4 text-center mb-3 d-flex flex-column align-items-center justify-content-center " + (isDragging ? "bg-light border-primary" : "border-secondary border-dashed"),
212
+ style: { cursor: "pointer", minHeight: "140px" },
213
+ onDragOver: handleDragOver,
214
+ onDragLeave: handleDragLeave,
215
+ onDrop: handleDrop,
216
+ children: [
217
+ /* @__PURE__ */ jsx("i", { className: "bi bi-cloud-arrow-up fs-1 mb-2" }),
218
+ /* @__PURE__ */ jsx("p", { className: "mb-2", children: "Drop files here" }),
219
+ /* @__PURE__ */ jsx("small", { className: "text-muted", children: "or click the button below" })
220
+ ]
221
+ }
222
+ ),
223
+ /* @__PURE__ */ jsxs("div", { className: "d-flex gap-2 align-items-center", children: [
224
+ /* @__PURE__ */ jsxs("label", { className: "btn btn-primary mb-0", children: [
225
+ /* @__PURE__ */ jsx("i", { className: "bi bi-folder2-open me-2" }),
226
+ "Browse files",
227
+ /* @__PURE__ */ jsx(
228
+ "input",
229
+ {
230
+ type: "file",
231
+ className: "d-none",
232
+ multiple,
233
+ accept,
234
+ onChange: handleFileChange
235
+ }
236
+ )
237
+ ] }),
238
+ fileNames.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex-grow-1", children: [
239
+ /* @__PURE__ */ jsx("div", { className: "small text-muted", children: "Selected:" }),
240
+ /* @__PURE__ */ jsx("ul", { className: "mb-0 small", children: fileNames.map((name) => /* @__PURE__ */ jsx("li", { children: name }, name)) })
241
+ ] })
242
+ ] })
243
+ ] }) }) });
244
+ };
245
+
246
+ // src/views/HomeView.tsx
247
+ import { AppSettings, AuthenticatorProvider, UserInfoCard } from "@sparkstudio/authentication-ui";
248
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
249
+ function HomeView() {
250
+ function handleOnLoginSuccess(user) {
251
+ alert(user?.Id);
252
+ }
253
+ return /* @__PURE__ */ jsxs2(
254
+ AuthenticatorProvider,
255
+ {
256
+ googleClientId: AppSettings.GoogleClientId,
257
+ authenticationUrl: AppSettings.AuthenticationUrl,
258
+ accountsUrl: AppSettings.AccountsUrl,
259
+ onLoginSuccess: handleOnLoginSuccess,
260
+ children: [
261
+ /* @__PURE__ */ jsx2(UserInfoCard, {}),
262
+ /* @__PURE__ */ jsx2(UploadContainer, {})
263
+ ]
264
+ }
265
+ );
266
+ }
267
+ export {
268
+ AWSCredentialsDTO,
269
+ Container,
270
+ ContainerDTO,
271
+ ContainerType,
272
+ Home,
273
+ HomeView,
274
+ SparkStudioStorageSDK,
275
+ UploadContainer
276
+ };
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@sparkstudio/storage-ui",
3
+ "version": "1.0.3",
4
+ "type": "module",
5
+ "main": "dist/index.cjs",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.cjs"
13
+ },
14
+ "./dist/index.css": "./dist/index.css"
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "sideEffects": [
20
+ "./dist/index.css"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "scripts": {
26
+ "dev": "vite",
27
+ "generateIndex": "barrelsby --delete --directory src --exclude react-env.d.ts --exclude main.tsx --exclude App.tsx",
28
+ "build": "npm run generateIndex && tsup src/index.ts --format cjs,esm --dts --tsconfig tsconfig.lib.json && sass --load-path=node_modules src/index.scss dist/index.css",
29
+ "lint": "eslint .",
30
+ "preview": "vite preview",
31
+ "start": "vite"
32
+ },
33
+ "peerDependencies": {
34
+ "react": "18.3.1",
35
+ "react-dom": "18.3.1"
36
+ },
37
+ "dependencies": {
38
+ "@sparkstudio/authentication-ui": "^1.0.29",
39
+ "@sparkstudio/common-ui": "^1.0.5",
40
+ "barrelsby": "^2.8.1"
41
+ },
42
+ "devDependencies": {
43
+ "@eslint/js": "^9.36.0",
44
+ "@types/node": "^24.6.0",
45
+ "@types/react": "^19.1.16",
46
+ "@types/react-dom": "^19.1.9",
47
+ "@vitejs/plugin-react": "^5.0.4",
48
+ "eslint": "^9.36.0",
49
+ "eslint-plugin-react-hooks": "^5.2.0",
50
+ "eslint-plugin-react-refresh": "^0.4.22",
51
+ "globals": "^16.4.0",
52
+ "tsup": "^8.5.1",
53
+ "typescript": "~5.9.3",
54
+ "typescript-eslint": "^8.45.0",
55
+ "vite": "^7.1.7"
56
+ }
57
+ }