@kitschpatrol/tweakpane-plugin-file-import 1.1.2-beta.1 → 1.1.2-beta.2
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
CHANGED
|
@@ -20,7 +20,7 @@ Instead, it gets built into the single-file plugin artifact, which is what's pub
|
|
|
20
20
|
|
|
21
21
|
Externalizing this dependency allows build tools like [vite](https://vitejs.dev) to share a single instance of the `@tweakpane/core` code across multiple plugins.
|
|
22
22
|
|
|
23
|
-
If you're not using a bundler, direct ESM imports from URLs can still work
|
|
23
|
+
If you're not using a bundler, direct ESM imports from URLs can still work by defining the `@tweakpane/core` dependency in an [importmap](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type/importmap).
|
|
24
24
|
|
|
25
25
|
## Implementation notes
|
|
26
26
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ClassName, createPlugin,
|
|
1
|
+
import { ClassName, createPlugin, CompositeConstraint, parseRecord } from '@tweakpane/core';
|
|
2
2
|
|
|
3
3
|
// Create a class name generator from the view name
|
|
4
4
|
// ClassName('tmp') will generate a CSS class name like `tp-tmpv`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ClassName as e,createPlugin as t,
|
|
1
|
+
import{ClassName as e,createPlugin as t,CompositeConstraint as i,parseRecord as n}from"@tweakpane/core";const a=e("ctn"),o=e("input"),s=e("btn");class r{constructor(e,t){this.element=e.createElement("div"),this.container=e.createElement("div"),this.container.classList.add(a()),t.viewProps.bindClassModifiers(this.container),this.input=e.createElement("input"),this.input.classList.add(o()),this.input.setAttribute("type","file"),this.input.setAttribute("accept",t.filetypes?t.filetypes.join(","):"*"),this.input.style.height=`calc(20px * ${t.lineCount})`,this.fileIcon=e.createElement("div"),this.fileIcon.classList.add(a("icon")),this.text=e.createElement("span"),this.text.classList.add(a("text")),this.warning=e.createElement("span"),this.warning.classList.add(a("warning")),this.warning.innerHTML=t.invalidFiletypeMessage,this.warning.style.display="none",this.deleteButton=e.createElement("button"),this.deleteButton.classList.add(s("b")),this.deleteButton.innerHTML="Delete",this.deleteButton.style.display="none",this.container.appendChild(this.input),this.container.appendChild(this.fileIcon),this.element.appendChild(this.container),this.element.appendChild(this.warning),this.element.appendChild(this.deleteButton)}changeDraggingState(e){var t,i;e?null===(t=this.container)||void 0===t||t.classList.add(a("input_area_dragging")):null===(i=this.container)||void 0===i||i.classList.remove(a("input_area_dragging"))}}class l{constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new r(e,{viewProps:this.viewProps,value:t.value,invalidFiletypeMessage:t.invalidFiletypeMessage,lineCount:t.lineCount,filetypes:t.filetypes}),this.config=t,this.onFile=this.onFile.bind(this),this.onDrop=this.onDrop.bind(this),this.onDragOver=this.onDragOver.bind(this),this.onDragLeave=this.onDragLeave.bind(this),this.onDeleteClick=this.onDeleteClick.bind(this),this.view.input.addEventListener("change",this.onFile),this.view.element.addEventListener("drop",this.onDrop),this.view.element.addEventListener("dragover",this.onDragOver),this.view.element.addEventListener("dragleave",this.onDragLeave),this.view.deleteButton.addEventListener("click",this.onDeleteClick),this.value.emitter.on("change",(()=>this.handleValueChange())),this.viewProps.handleDispose((()=>{this.view.input.removeEventListener("change",this.onFile),this.view.element.removeEventListener("drop",this.onDrop),this.view.element.removeEventListener("dragover",this.onDragOver),this.view.element.removeEventListener("dragleave",this.onDragLeave),this.view.deleteButton.removeEventListener("click",this.onDeleteClick)}))}onFile(e){const t=this.view.input;if(t.files&&t.files.length>0){const e=t.files[0];this.isFileValid(e)?this.value.setRawValue(e):this.showWarning()}}showWarning(){this.view.warning.style.display="block",setTimeout((()=>{this.view.warning.style.display="none"}),5e3)}isFileValid(e){var t;const i=this.config.filetypes,n="."+(null===(t=e.name.split(".").pop())||void 0===t?void 0:t.toLowerCase());return!(i&&i.length>0&&!i.includes(n)&&n)}onDeleteClick(){this.value.rawValue&&(this.value.setRawValue(null),this.view.input.value="",this.view.warning.style.display="none")}onDragOver(e){e.preventDefault(),this.view.changeDraggingState(!0)}onDragLeave(){this.view.changeDraggingState(!1)}onDrop(e){if(e instanceof DragEvent&&(e.preventDefault(),e.dataTransfer&&e.dataTransfer.files)){const t=e.dataTransfer.files;if(1==t.length){const e=t.item(0);e&&(this.isFileValid(e)?this.value.setRawValue(e):this.showWarning())}}this.view.changeDraggingState(!1)}handleValueChange(){const e=this.value.rawValue,t=this.view.container,i=this.view.text,n=this.view.fileIcon,a=this.view.deleteButton;e?(i.textContent=e.name,t.appendChild(i),t.contains(n)&&t.removeChild(n),this.view.warning.style.display="none",a.style.display="block",t.style.border="unset"):(i.textContent="",t.appendChild(n),t.removeChild(i),this.view.warning.style.display="none",a.style.display="none",t.style.border="1px dashed #717070")}}const h="file-input",p='.tp-ctnv{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:rgba(0,0,0,0);border-width:0;font-family:inherit;font-size:inherit;font-weight:inherit;margin:0;outline:none;padding:0}.tp-ctnv{background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);font-family:inherit;height:var(--cnt-usz);line-height:var(--cnt-usz);min-width:0;width:100%}.tp-ctnv:hover{background-color:var(--in-bg-h)}.tp-ctnv:focus{background-color:var(--in-bg-f)}.tp-ctnv:active{background-color:var(--in-bg-a)}.tp-ctnv:disabled{opacity:.5}.tp-ctnv{cursor:pointer;display:flex;justify-content:center;align-items:center;overflow:hidden;position:relative;height:100%;width:100%;border:1px dashed #717070;border-radius:5px}.tp-ctnv.tp-v-disabled{opacity:.5}.tp-ctnv_input_area_dragging{border:1px dashed #6774ff;background-color:rgba(88,88,185,.231372549)}.tp-ctnv_warning{color:var(--in-fg);bottom:2px;display:inline-block;font-size:.9em;height:-moz-max-content;height:max-content;line-height:1.5;opacity:.5;white-space:normal;width:-moz-max-content;width:max-content;word-wrap:break-word;text-align:right;width:100%;margin-top:var(--cnt-vp)}.tp-ctnv_text{color:var(--in-fg);bottom:2px;display:inline-block;font-size:.9em;height:-moz-max-content;height:max-content;line-height:.9;margin:.2rem;max-height:100%;max-width:100%;opacity:.5;position:absolute;right:2px;text-align:right;white-space:normal;width:-moz-max-content;width:max-content;word-wrap:break-word}.tp-ctnv_frac{background-color:var(--in-fg);border-radius:1px;height:2px;left:50%;margin-top:-1px;position:absolute;top:50%}.tp-ctnv_icon{box-sizing:border-box;position:absolute;display:block;transform:scale(var(--ggs, 1));width:16px;height:6px;border:2px solid;border-top:0;border-bottom-left-radius:2px;border-bottom-right-radius:2px;margin-top:8px;opacity:.5}.tp-ctnv_icon::after{content:"";display:block;box-sizing:border-box;position:absolute;width:8px;height:8px;border-left:2px solid;border-top:2px solid;transform:rotate(45deg);left:2px;bottom:4px}.tp-ctnv_icon::before{content:"";display:block;box-sizing:border-box;position:absolute;border-radius:3px;width:2px;height:10px;background:currentColor;left:5px;bottom:3px}.tp-btnv_b{margin-top:10px}.tp-inputv{opacity:0}',d=[t({id:"file-input",type:"input",accept(e,t){if("string"!=typeof e)return null;const i=n(t,(e=>({view:e.required.constant("file-input"),invalidFiletypeMessage:e.optional.string,lineCount:e.optional.number,filetypes:e.optional.array(e.required.string)})));return i?{initialValue:e,params:i}:null},binding:{reader:e=>e=>e instanceof File?e:null,constraint:e=>new i([]),writer:e=>(e,t)=>{e.write(t)}},controller(e){var t,i;return new l(e.document,{value:e.value,viewProps:e.viewProps,invalidFiletypeMessage:null!==(t=e.params.invalidFiletypeMessage)&&void 0!==t?t:"Unaccepted file type.",lineCount:null!==(i=e.params.lineCount)&&void 0!==i?i:3,filetypes:e.params.filetypes})}})];export{p as css,h as id,d as plugins};
|
package/package.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/tweakpane-plugin-file-import",
|
|
3
|
-
"version": "1.1.2-beta.
|
|
3
|
+
"version": "1.1.2-beta.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A fork of tweakpane-plugin-file-import with build optimizations.",
|
|
6
|
-
"repository":
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/kitschpatrol/tweakpane-plugin-image.git"
|
|
9
|
+
},
|
|
7
10
|
"homepage": "https://github.com/kitschpatrol/tweakpane-plugin-file-import",
|
|
8
11
|
"author": "LuchoTurtle",
|
|
9
12
|
"license": "MIT",
|
|
10
13
|
"engines": {
|
|
11
|
-
"node": ">=18.0.0"
|
|
12
|
-
"pnpm": ">=9.0.0"
|
|
14
|
+
"node": ">=18.0.0"
|
|
13
15
|
},
|
|
14
16
|
"main": "dist/tweakpane-plugin-file-import.js",
|
|
15
17
|
"types": "dist/types/index.d.ts",
|
|
@@ -25,34 +27,36 @@
|
|
|
25
27
|
"tweakpane": "^4.0.0"
|
|
26
28
|
},
|
|
27
29
|
"dependencies": {
|
|
28
|
-
"@tweakpane/core": "^2.0.
|
|
30
|
+
"@tweakpane/core": "^2.0.5"
|
|
29
31
|
},
|
|
30
32
|
"devDependencies": {
|
|
33
|
+
"@eslint/eslintrc": "^3.3.0",
|
|
34
|
+
"@eslint/js": "^9.21.0",
|
|
31
35
|
"@rollup/plugin-alias": "^5.1.1",
|
|
32
|
-
"@rollup/plugin-node-resolve": "^15.3.
|
|
33
|
-
"@rollup/plugin-replace": "^6.0.
|
|
36
|
+
"@rollup/plugin-node-resolve": "^15.3.1",
|
|
37
|
+
"@rollup/plugin-replace": "^6.0.2",
|
|
34
38
|
"@rollup/plugin-terser": "^0.4.4",
|
|
35
|
-
"@rollup/plugin-typescript": "^12.1.
|
|
36
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
37
|
-
"@typescript-eslint/parser": "^8.
|
|
39
|
+
"@rollup/plugin-typescript": "^12.1.2",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^8.26.0",
|
|
41
|
+
"@typescript-eslint/parser": "^8.26.0",
|
|
38
42
|
"autoprefixer": "^10.4.20",
|
|
39
|
-
"bumpp": "^
|
|
40
|
-
"eslint": "^9.
|
|
43
|
+
"bumpp": "^10.0.3",
|
|
44
|
+
"eslint": "^9.21.0",
|
|
41
45
|
"eslint-config-prettier": "^9.1.0",
|
|
42
|
-
"eslint-plugin-prettier": "^5.2.
|
|
46
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
43
47
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
44
48
|
"http-server": "^14.1.1",
|
|
45
49
|
"npm-run-all": "^4.1.5",
|
|
46
50
|
"onchange": "^7.1.0",
|
|
47
|
-
"postcss": "^8.
|
|
48
|
-
"prettier": "^3.
|
|
51
|
+
"postcss": "^8.5.3",
|
|
52
|
+
"prettier": "^3.5.3",
|
|
49
53
|
"prettier-plugin-pkg": "^0.18.1",
|
|
50
|
-
"release-it": "^17.
|
|
54
|
+
"release-it": "^17.11.0",
|
|
51
55
|
"rimraf": "^6.0.1",
|
|
52
|
-
"rollup": "^4.
|
|
56
|
+
"rollup": "^4.34.9",
|
|
53
57
|
"rollup-plugin-cleanup": "3.2.1",
|
|
54
|
-
"sass": "^1.
|
|
55
|
-
"typescript": "^5.
|
|
58
|
+
"sass": "^1.85.1",
|
|
59
|
+
"typescript": "^5.8.2"
|
|
56
60
|
},
|
|
57
61
|
"publishConfig": {
|
|
58
62
|
"access": "public"
|
|
@@ -66,7 +70,7 @@
|
|
|
66
70
|
"format": "run-p format:*",
|
|
67
71
|
"format:scss": "prettier --parser scss --write \"src/sass/**/*.scss\"",
|
|
68
72
|
"format:ts": "eslint --fix \"src/**/*.ts\"",
|
|
69
|
-
"release": "bumpp --commit 'Release: %s' --tag '%s' && pnpm run build && pnpm publish --otp $(op read 'op://Personal/Npmjs/one-time password?attribute=otp')",
|
|
73
|
+
"release": "bumpp --commit 'Release: %s' --tag '%s' && pnpm run build && pnpm publish --tag latest --otp $(op read 'op://Personal/Npmjs/one-time password?attribute=otp')",
|
|
70
74
|
"server": "http-server -c-1 -o /test/browser.html",
|
|
71
75
|
"start": "run-p watch server",
|
|
72
76
|
"test": "eslint \"src/**/*.ts\"",
|