@brftech/filex-react 0.1.56

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BRF Tech
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @brftech/filex-react
2
+
3
+ React adapter for the [filex](https://github.com/brf-tech/filex)
4
+ file manager. Thin wrapper around `<filex-explorer>` (the
5
+ `@brftech/filex` Web Component) — gives you proper React props and
6
+ camelCased event handlers via `@lit/react`'s `createComponent`.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm i @brftech/filex-react react react-dom
12
+ ```
13
+
14
+ ## Use
15
+
16
+ ```jsx
17
+ import { FileManager } from '@brftech/filex-react';
18
+
19
+ export function App() {
20
+ return (
21
+ <FileManager
22
+ config={{
23
+ apiBase: 'https://files.example.com',
24
+ auth: { kind: 'bearer', token: '<jwt>' },
25
+ locale: 'tr',
26
+ theme: 'auto',
27
+ }}
28
+ onError={(e) => console.error(e.detail)}
29
+ onShareCreated={(e) => navigator.clipboard.writeText(e.detail.url)}
30
+ onFileOpened={(e) => console.log('opened', e.detail.basename)}
31
+ onUploadProgress={(e) => console.log(e.detail.percent + '%')}
32
+ onSelectionChange={(e) => console.log(e.detail.length, 'selected')}
33
+ />
34
+ );
35
+ }
36
+ ```
37
+
38
+ The `config` prop accepts the full `ExplorerConfig` (re-exported from
39
+ `@brftech/filex-core` for convenience). Event handlers receive native
40
+ `CustomEvent`s — payload is on `event.detail`.
41
+
42
+ ## Build
43
+
44
+ ```bash
45
+ pnpm build # tsc check + vite lib build → dist/filex-react.{js,cjs}
46
+ ```
47
+
48
+ ## License
49
+
50
+ MIT
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),a=require("@lit/react");require("@brftech/filex");function l(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const c=l(o),s=typeof customElements<"u"&&customElements.get("filex-explorer")||class{},i=a.createComponent({react:c,tagName:"filex-explorer",elementClass:s,events:{onError:"error",onShareCreated:"share-created",onFileOpened:"file-opened",onUploadProgress:"upload-progress",onSelectionChange:"selection-change"}});exports.FileManager=i;
2
+ //# sourceMappingURL=filex-react.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filex-react.cjs","sources":["../src/index.ts"],"sourcesContent":["/**\r\n * @brftech/filex-react — React adapter around the `<filex-explorer>`\r\n * Web Component.\r\n *\r\n * Uses `@lit/react`'s `createComponent` to map element attributes /\r\n * properties / events into idiomatic React props (camelCased event\r\n * handlers like `onError`, real prop assignment for the `config`\r\n * object, no need to imperatively reach for `.addEventListener`).\r\n *\r\n * Side-effect: importing this module also imports `@brftech/filex`\r\n * which registers the underlying custom element.\r\n */\r\n\r\nimport * as React from 'react';\r\nimport { createComponent } from '@lit/react';\r\nimport '@brftech/filex'; // side-effect: registers `<filex-explorer>`\r\nimport type { ExplorerConfig } from '@brftech/filex';\r\n\r\n/**\r\n * Resolve the registered class. We do this lazily inside a getter so\r\n * tree-shaking-time evaluation in some bundlers doesn't trip the\r\n * `customElements.get(…)` lookup before the side-effect import has run\r\n * (it has, but TS analysers can be jumpy). At runtime this evaluates\r\n * once at module load.\r\n */\r\nconst FilexElementClass =\r\n (typeof customElements !== 'undefined' && customElements.get('filex-explorer')) ||\r\n // Fallback for SSR — the element class is irrelevant on the server\r\n // because createComponent only renders the tag string. Provide an\r\n // empty class shim so types resolve.\r\n (class {} as unknown as CustomElementConstructor);\r\n\r\n/**\r\n * Idiomatic React component — used like a normal JSX tag with native\r\n * props.\r\n *\r\n * <FileManager\r\n * config={{ apiBase: 'https://files.example.com',\r\n * auth: { kind: 'bearer', token } }}\r\n * onError={(e) => console.error(e.detail)}\r\n * />\r\n */\r\nexport const FileManager = createComponent({\r\n react: React,\r\n tagName: 'filex-explorer',\r\n elementClass: FilexElementClass,\r\n events: {\r\n onError: 'error',\r\n onShareCreated: 'share-created',\r\n onFileOpened: 'file-opened',\r\n onUploadProgress: 'upload-progress',\r\n onSelectionChange: 'selection-change',\r\n },\r\n});\r\n\r\n/**\r\n * Re-export the config types so React consumers don't need a second\r\n * dependency on `@brftech/filex-core` just to type the `config` prop.\r\n */\r\nexport type {\r\n ExplorerConfig,\r\n AuthConfig,\r\n ThemeMode,\r\n LocaleCode,\r\n FileNode,\r\n ShareInfo,\r\n Capabilities,\r\n UploadInitResponse,\r\n UploadFinalizeResponse,\r\n ArchiveEntry,\r\n ViewMode,\r\n} from '@brftech/filex-core';\r\n\r\n/**\r\n * Helper-typed payloads the events carry — matches the SFC's emit\r\n * declarations so consumers get autocomplete on `event.detail`.\r\n */\r\nexport interface FilexErrorDetail {\r\n message: string;\r\n context?: unknown;\r\n}\r\n\r\nexport interface FilexShareCreatedDetail {\r\n path: string;\r\n url: string;\r\n pin: string | null;\r\n}\r\n\r\nexport interface FilexFileOpenedDetail {\r\n path: string;\r\n basename: string;\r\n}\r\n\r\nexport interface FilexUploadProgressDetail {\r\n uploadId: string;\r\n percent: number;\r\n done: boolean;\r\n}\r\n\r\nexport type FilexSelectionChangeDetail = Array<{\r\n path: string;\r\n basename: string;\r\n type: 'file' | 'dir';\r\n}>;\r\n"],"names":["FilexElementClass","FileManager","createComponent","React"],"mappings":"qbAyBMA,EACH,OAAO,eAAmB,KAAe,eAAe,IAAI,gBAAgB,GAI5E,KAAM,CAAC,EAYGC,EAAcC,EAAAA,gBAAgB,CACzC,MAAOC,EACP,QAAS,iBACT,aAAcH,EACd,OAAQ,CACN,QAAS,QACT,eAAgB,gBAChB,aAAc,cACd,iBAAkB,kBAClB,kBAAmB,kBAAA,CAEvB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import * as e from "react";
2
+ import { createComponent as o } from "@lit/react";
3
+ import "@brftech/filex";
4
+ const r = typeof customElements < "u" && customElements.get("filex-explorer") || // Fallback for SSR — the element class is irrelevant on the server
5
+ // because createComponent only renders the tag string. Provide an
6
+ // empty class shim so types resolve.
7
+ class {
8
+ }, s = o({
9
+ react: e,
10
+ tagName: "filex-explorer",
11
+ elementClass: r,
12
+ events: {
13
+ onError: "error",
14
+ onShareCreated: "share-created",
15
+ onFileOpened: "file-opened",
16
+ onUploadProgress: "upload-progress",
17
+ onSelectionChange: "selection-change"
18
+ }
19
+ });
20
+ export {
21
+ s as FileManager
22
+ };
23
+ //# sourceMappingURL=filex-react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filex-react.js","sources":["../src/index.ts"],"sourcesContent":["/**\r\n * @brftech/filex-react — React adapter around the `<filex-explorer>`\r\n * Web Component.\r\n *\r\n * Uses `@lit/react`'s `createComponent` to map element attributes /\r\n * properties / events into idiomatic React props (camelCased event\r\n * handlers like `onError`, real prop assignment for the `config`\r\n * object, no need to imperatively reach for `.addEventListener`).\r\n *\r\n * Side-effect: importing this module also imports `@brftech/filex`\r\n * which registers the underlying custom element.\r\n */\r\n\r\nimport * as React from 'react';\r\nimport { createComponent } from '@lit/react';\r\nimport '@brftech/filex'; // side-effect: registers `<filex-explorer>`\r\nimport type { ExplorerConfig } from '@brftech/filex';\r\n\r\n/**\r\n * Resolve the registered class. We do this lazily inside a getter so\r\n * tree-shaking-time evaluation in some bundlers doesn't trip the\r\n * `customElements.get(…)` lookup before the side-effect import has run\r\n * (it has, but TS analysers can be jumpy). At runtime this evaluates\r\n * once at module load.\r\n */\r\nconst FilexElementClass =\r\n (typeof customElements !== 'undefined' && customElements.get('filex-explorer')) ||\r\n // Fallback for SSR — the element class is irrelevant on the server\r\n // because createComponent only renders the tag string. Provide an\r\n // empty class shim so types resolve.\r\n (class {} as unknown as CustomElementConstructor);\r\n\r\n/**\r\n * Idiomatic React component — used like a normal JSX tag with native\r\n * props.\r\n *\r\n * <FileManager\r\n * config={{ apiBase: 'https://files.example.com',\r\n * auth: { kind: 'bearer', token } }}\r\n * onError={(e) => console.error(e.detail)}\r\n * />\r\n */\r\nexport const FileManager = createComponent({\r\n react: React,\r\n tagName: 'filex-explorer',\r\n elementClass: FilexElementClass,\r\n events: {\r\n onError: 'error',\r\n onShareCreated: 'share-created',\r\n onFileOpened: 'file-opened',\r\n onUploadProgress: 'upload-progress',\r\n onSelectionChange: 'selection-change',\r\n },\r\n});\r\n\r\n/**\r\n * Re-export the config types so React consumers don't need a second\r\n * dependency on `@brftech/filex-core` just to type the `config` prop.\r\n */\r\nexport type {\r\n ExplorerConfig,\r\n AuthConfig,\r\n ThemeMode,\r\n LocaleCode,\r\n FileNode,\r\n ShareInfo,\r\n Capabilities,\r\n UploadInitResponse,\r\n UploadFinalizeResponse,\r\n ArchiveEntry,\r\n ViewMode,\r\n} from '@brftech/filex-core';\r\n\r\n/**\r\n * Helper-typed payloads the events carry — matches the SFC's emit\r\n * declarations so consumers get autocomplete on `event.detail`.\r\n */\r\nexport interface FilexErrorDetail {\r\n message: string;\r\n context?: unknown;\r\n}\r\n\r\nexport interface FilexShareCreatedDetail {\r\n path: string;\r\n url: string;\r\n pin: string | null;\r\n}\r\n\r\nexport interface FilexFileOpenedDetail {\r\n path: string;\r\n basename: string;\r\n}\r\n\r\nexport interface FilexUploadProgressDetail {\r\n uploadId: string;\r\n percent: number;\r\n done: boolean;\r\n}\r\n\r\nexport type FilexSelectionChangeDetail = Array<{\r\n path: string;\r\n basename: string;\r\n type: 'file' | 'dir';\r\n}>;\r\n"],"names":["FilexElementClass","FileManager","createComponent","React"],"mappings":";;;AAyBA,MAAMA,IACH,OAAO,iBAAmB,OAAe,eAAe,IAAI,gBAAgB;AAAA;AAAA;AAI5E,MAAM;AAAC,GAYGC,IAAcC,EAAgB;AAAA,EACzC,OAAOC;AAAA,EACP,SAAS;AAAA,EACT,cAAcH;AAAA,EACd,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,cAAc;AAAA,IACd,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,EAAA;AAEvB,CAAC;"}
@@ -0,0 +1,86 @@
1
+ import { ArchiveEntry } from '@brftech/filex-core';
2
+ import { AuthConfig } from '@brftech/filex-core';
3
+ import { Capabilities } from '@brftech/filex-core';
4
+ import { ExplorerConfig } from '@brftech/filex-core';
5
+ import { FileNode } from '@brftech/filex-core';
6
+ import { LocaleCode } from '@brftech/filex-core';
7
+ import { ReactWebComponent } from '@lit/react';
8
+ import { ShareInfo } from '@brftech/filex-core';
9
+ import { ThemeMode } from '@brftech/filex-core';
10
+ import { UploadFinalizeResponse } from '@brftech/filex-core';
11
+ import { UploadInitResponse } from '@brftech/filex-core';
12
+ import { ViewMode } from '@brftech/filex-core';
13
+
14
+ export { ArchiveEntry }
15
+
16
+ export { AuthConfig }
17
+
18
+ export { Capabilities }
19
+
20
+ export { ExplorerConfig }
21
+
22
+ /**
23
+ * Idiomatic React component — used like a normal JSX tag with native
24
+ * props.
25
+ *
26
+ * <FileManager
27
+ * config={{ apiBase: 'https://files.example.com',
28
+ * auth: { kind: 'bearer', token } }}
29
+ * onError={(e) => console.error(e.detail)}
30
+ * />
31
+ */
32
+ export declare const FileManager: ReactWebComponent<HTMLElement, {
33
+ onError: string;
34
+ onShareCreated: string;
35
+ onFileOpened: string;
36
+ onUploadProgress: string;
37
+ onSelectionChange: string;
38
+ }>;
39
+
40
+ export { FileNode }
41
+
42
+ /**
43
+ * Helper-typed payloads the events carry — matches the SFC's emit
44
+ * declarations so consumers get autocomplete on `event.detail`.
45
+ */
46
+ export declare interface FilexErrorDetail {
47
+ message: string;
48
+ context?: unknown;
49
+ }
50
+
51
+ export declare interface FilexFileOpenedDetail {
52
+ path: string;
53
+ basename: string;
54
+ }
55
+
56
+ export declare type FilexSelectionChangeDetail = Array<{
57
+ path: string;
58
+ basename: string;
59
+ type: 'file' | 'dir';
60
+ }>;
61
+
62
+ export declare interface FilexShareCreatedDetail {
63
+ path: string;
64
+ url: string;
65
+ pin: string | null;
66
+ }
67
+
68
+ export declare interface FilexUploadProgressDetail {
69
+ uploadId: string;
70
+ percent: number;
71
+ done: boolean;
72
+ }
73
+
74
+ export { LocaleCode }
75
+
76
+ export { ShareInfo }
77
+
78
+ export { ThemeMode }
79
+
80
+ export { UploadFinalizeResponse }
81
+
82
+ export { UploadInitResponse }
83
+
84
+ export { ViewMode }
85
+
86
+ export { }
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@brftech/filex-react",
3
+ "version": "0.1.56",
4
+ "description": "filex React adapter — wraps <filex-explorer> for React idiom (props + camelCase event handlers)",
5
+ "type": "module",
6
+ "main": "./dist/filex-react.cjs",
7
+ "module": "./dist/filex-react.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/filex-react.js",
13
+ "require": "./dist/filex-react.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md"
19
+ ],
20
+ "dependencies": {
21
+ "@lit/react": "^1.0.5",
22
+ "@brftech/filex": "0.1.56",
23
+ "@brftech/filex-core": "0.1.56"
24
+ },
25
+ "peerDependencies": {
26
+ "react": "^18.0.0 || ^19.0.0",
27
+ "react-dom": "^18.0.0 || ^19.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^22.7.0",
31
+ "@types/react": "^18.3.12",
32
+ "@types/react-dom": "^18.3.1",
33
+ "react": "^18.3.1",
34
+ "react-dom": "^18.3.1",
35
+ "rimraf": "^6.0.1",
36
+ "typescript": "^5.6.0",
37
+ "vite": "^5.4.10",
38
+ "vite-plugin-dts": "^4.3.0"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "keywords": [
44
+ "filex",
45
+ "file-manager",
46
+ "react",
47
+ "brftech"
48
+ ],
49
+ "author": "BRF Tech <hello@example.com>",
50
+ "license": "MIT",
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "git+https://github.com/brf-tech/filex.git",
54
+ "directory": "packages/react"
55
+ },
56
+ "scripts": {
57
+ "build": "tsc --noEmit && vite build",
58
+ "build:no-dts": "vite build",
59
+ "dev": "vite build --watch",
60
+ "typecheck": "tsc --noEmit",
61
+ "clean": "rimraf dist"
62
+ }
63
+ }