@kitschpatrol/tweakpane-plugin-file-import 1.2.0-fork.2 → 1.2.0-fork.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.
|
@@ -388,7 +388,7 @@ const TweakpaneFileInputPlugin = createPlugin({
|
|
|
388
388
|
type: "input"
|
|
389
389
|
});
|
|
390
390
|
// src/styles/plugin.scss?inline
|
|
391
|
-
var plugin_default = ".tp-ctnv{appearance:none;font-family:inherit;font-size:inherit;font-weight:inherit;background-color:#0000;background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);height:var(--cnt-usz);font-family:inherit;line-height:var(--cnt-usz);border-width:0;outline:none;width:100%;min-width:0;margin:0;padding:0}.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;border:1px dashed #717070;border-radius:5px;flex-wrap:nowrap;justify-content:center;align-items:center;width:100%;height:100%;display:flex;position:relative;overflow:hidden}.tp-ctnv.tp-v-disabled{opacity:.5}.tp-ctnv_input_area_dragging{background-color:#5858b93b;border:1px dashed #6774ff}.tp-ctnv_warning{width:100%;height:max-content;margin-top:var(--cnt-vp);color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;font-size:.9em;line-height:1.5;display:inline-block;bottom:2px}.tp-ctnv_text{width:max-content;max-width:100%;height:max-content;max-height:100%;color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;margin:.2rem;font-size:.9em;line-height:.9;display:inline-block;position:absolute;bottom:2px;right:2px}.tp-ctnv_frac{background-color:var(--in-fg);border-radius:1px;height:2px;margin-top:-1px;position:absolute;top:50%;left:50%}.tp-ctnv_icon{transform:scale(var(--ggs,1));box-sizing:border-box;opacity:.5;border:2px solid;border-top:0;border-bottom-right-radius:2px;border-bottom-left-radius:2px;width:16px;height:6px;margin-top:8px;display:block;position:absolute}.tp-ctnv_icon:after{content:\"\";box-sizing:border-box;border-top:2px solid;border-left:2px solid;width:8px;height:8px;display:block;position:absolute;bottom:4px;left:2px;transform:rotate(45deg)}.tp-ctnv_icon:before{content:\"\";box-sizing:border-box;background:currentColor;border-radius:3px;width:2px;height:10px;display:block;position:absolute;bottom:3px;left:5px}.tp-btnv_b{margin-top:10px}.tp-inputv{opacity:0}\n";
|
|
391
|
+
var plugin_default = ".tp-ctnv{appearance:none;font-family:inherit;font-size:inherit;font-weight:inherit;background-color:#0000;background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);height:var(--cnt-usz);font-family:inherit;line-height:var(--cnt-usz);border-width:0;outline:none;width:100%;min-width:0;margin:0;padding:0}.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;border:1px dashed #717070;border-radius:5px;flex-wrap:nowrap;justify-content:center;align-items:center;width:100%;height:100%;display:flex;position:relative;overflow:hidden}.tp-ctnv.tp-v-disabled{opacity:.5}.tp-ctnv_input_area_dragging{background-color:#5858b93b;border:1px dashed #6774ff}.tp-ctnv_warning{width:100%;height:max-content;margin-top:var(--cnt-vp);color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;font-size:.9em;line-height:1.5;display:inline-block;bottom:2px}.tp-ctnv_text{width:max-content;max-width:100%;height:max-content;max-height:100%;color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;margin:.2rem;font-size:.9em;line-height:.9;display:inline-block;position:absolute;bottom:2px;right:2px}.tp-ctnv_frac{background-color:var(--in-fg);border-radius:1px;height:2px;margin-top:-1px;position:absolute;top:50%;left:50%}.tp-ctnv_icon{transform:scale(var(--ggs,1));box-sizing:border-box;opacity:.5;border:2px solid;border-top:0;border-bottom-right-radius:2px;border-bottom-left-radius:2px;width:16px;height:6px;margin-top:8px;display:block;position:absolute}.tp-ctnv_icon:after{content:\"\";box-sizing:border-box;border-top:2px solid;border-left:2px solid;width:8px;height:8px;display:block;position:absolute;bottom:4px;left:2px;transform:rotate(45deg)}.tp-ctnv_icon:before{content:\"\";box-sizing:border-box;background:currentColor;border-radius:3px;width:2px;height:10px;display:block;position:absolute;bottom:3px;left:5px}.tp-ctnv~.tp-btnv_b{margin-top:10px}.tp-inputv{opacity:0}\n";
|
|
392
392
|
// src/index.ts
|
|
393
393
|
const id = "file-input";
|
|
394
394
|
const css = plugin_default;
|
|
@@ -239,7 +239,7 @@ const TweakpaneFileInputPlugin = createPlugin({
|
|
|
239
239
|
type: "input"
|
|
240
240
|
});
|
|
241
241
|
// src/styles/plugin.scss?inline
|
|
242
|
-
var plugin_default = ".tp-ctnv{appearance:none;font-family:inherit;font-size:inherit;font-weight:inherit;background-color:#0000;background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);height:var(--cnt-usz);font-family:inherit;line-height:var(--cnt-usz);border-width:0;outline:none;width:100%;min-width:0;margin:0;padding:0}.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;border:1px dashed #717070;border-radius:5px;flex-wrap:nowrap;justify-content:center;align-items:center;width:100%;height:100%;display:flex;position:relative;overflow:hidden}.tp-ctnv.tp-v-disabled{opacity:.5}.tp-ctnv_input_area_dragging{background-color:#5858b93b;border:1px dashed #6774ff}.tp-ctnv_warning{width:100%;height:max-content;margin-top:var(--cnt-vp);color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;font-size:.9em;line-height:1.5;display:inline-block;bottom:2px}.tp-ctnv_text{width:max-content;max-width:100%;height:max-content;max-height:100%;color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;margin:.2rem;font-size:.9em;line-height:.9;display:inline-block;position:absolute;bottom:2px;right:2px}.tp-ctnv_frac{background-color:var(--in-fg);border-radius:1px;height:2px;margin-top:-1px;position:absolute;top:50%;left:50%}.tp-ctnv_icon{transform:scale(var(--ggs,1));box-sizing:border-box;opacity:.5;border:2px solid;border-top:0;border-bottom-right-radius:2px;border-bottom-left-radius:2px;width:16px;height:6px;margin-top:8px;display:block;position:absolute}.tp-ctnv_icon:after{content:\"\";box-sizing:border-box;border-top:2px solid;border-left:2px solid;width:8px;height:8px;display:block;position:absolute;bottom:4px;left:2px;transform:rotate(45deg)}.tp-ctnv_icon:before{content:\"\";box-sizing:border-box;background:currentColor;border-radius:3px;width:2px;height:10px;display:block;position:absolute;bottom:3px;left:5px}.tp-btnv_b{margin-top:10px}.tp-inputv{opacity:0}\n";
|
|
242
|
+
var plugin_default = ".tp-ctnv{appearance:none;font-family:inherit;font-size:inherit;font-weight:inherit;background-color:#0000;background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);height:var(--cnt-usz);font-family:inherit;line-height:var(--cnt-usz);border-width:0;outline:none;width:100%;min-width:0;margin:0;padding:0}.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;border:1px dashed #717070;border-radius:5px;flex-wrap:nowrap;justify-content:center;align-items:center;width:100%;height:100%;display:flex;position:relative;overflow:hidden}.tp-ctnv.tp-v-disabled{opacity:.5}.tp-ctnv_input_area_dragging{background-color:#5858b93b;border:1px dashed #6774ff}.tp-ctnv_warning{width:100%;height:max-content;margin-top:var(--cnt-vp);color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;font-size:.9em;line-height:1.5;display:inline-block;bottom:2px}.tp-ctnv_text{width:max-content;max-width:100%;height:max-content;max-height:100%;color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;margin:.2rem;font-size:.9em;line-height:.9;display:inline-block;position:absolute;bottom:2px;right:2px}.tp-ctnv_frac{background-color:var(--in-fg);border-radius:1px;height:2px;margin-top:-1px;position:absolute;top:50%;left:50%}.tp-ctnv_icon{transform:scale(var(--ggs,1));box-sizing:border-box;opacity:.5;border:2px solid;border-top:0;border-bottom-right-radius:2px;border-bottom-left-radius:2px;width:16px;height:6px;margin-top:8px;display:block;position:absolute}.tp-ctnv_icon:after{content:\"\";box-sizing:border-box;border-top:2px solid;border-left:2px solid;width:8px;height:8px;display:block;position:absolute;bottom:4px;left:2px;transform:rotate(45deg)}.tp-ctnv_icon:before{content:\"\";box-sizing:border-box;background:currentColor;border-radius:3px;width:2px;height:10px;display:block;position:absolute;bottom:3px;left:5px}.tp-ctnv~.tp-btnv_b{margin-top:10px}.tp-inputv{opacity:0}\n";
|
|
243
243
|
// src/index.ts
|
|
244
244
|
const id = "file-input";
|
|
245
245
|
const css = plugin_default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{ClassName as e,CompositeConstraint as t,createPlugin as n,parseRecord as r}from"@tweakpane/core";const i=e(`ctn`),a=e(`input`),o=e(`btn`);var s=class{clearButton;container;element;fileIcon;input;text;warning;constructor(e,t){this.element=e.createElement(`div`),this.container=e.createElement(`div`),this.container.classList.add(i()),t.viewProps.bindClassModifiers(this.container),this.input=e.createElement(`input`),this.input.classList.add(a()),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(i(`icon`)),this.text=e.createElement(`span`),this.text.classList.add(i(`text`)),this.warning=e.createElement(`span`),this.warning.classList.add(i(`warning`)),this.warning.textContent=t.invalidFiletypeMessage,this.warning.style.display=`none`,this.clearButton=e.createElement(`button`),this.clearButton.classList.add(o(`b`)),this.clearButton.textContent=`Delete`,this.clearButton.style.display=`none`,this.container.append(this.input),this.container.append(this.fileIcon),this.element.append(this.container),this.element.append(this.warning),this.element.append(this.clearButton)}changeDraggingState(e){e?this.container.classList.add(i(`input_area_dragging`)):this.container.classList.remove(i(`input_area_dragging`))}},c=class{value;view;viewProps;config;constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new s(e,{filetypes:t.filetypes,invalidFiletypeMessage:t.invalidFiletypeMessage,lineCount:t.lineCount,value:t.value,viewProps:this.viewProps}),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.clearButton.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.clearButton.removeEventListener(`click`,this.onDeleteClick)})}handleValueChange(){let e=this.value.rawValue,t=this.view.container,n=this.view.text,r=this.view.fileIcon,{clearButton:i}=this.view;e?(n.textContent=e.name,t.append(n),t.contains(r)&&r.remove(),this.view.warning.style.display=`none`,i.style.display=`block`,t.style.border=`unset`):(n.textContent=``,t.append(r),n.remove(),this.view.warning.style.display=`none`,i.style.display=`none`,t.style.border=`1px dashed #717070`)}isFileValid(e){let{filetypes:t}=this.config,n=`.`+(e.name.split(`.`).pop()?.toLowerCase()??``);return!t||t.length===0||t.includes(n)}onDeleteClick(){this.value.rawValue&&(this.value.setRawValue(null),this.view.input.value=``,this.view.warning.style.display=`none`)}onDragLeave(){this.view.changeDraggingState(!1)}onDragOver(e){e.preventDefault(),this.view.changeDraggingState(!0)}onDrop(e){try{if(!(e instanceof DragEvent))return;e.preventDefault();let t=e.dataTransfer?.files;if(t?.length!==1)return;let n=t.item(0);if(!n)return;this.isFileValid(n)?this.value.setRawValue(n):this.showWarning()}finally{this.view.changeDraggingState(!1)}}onFile(e){let t=this.view.input.files?.item(0);t&&(this.isFileValid(t)?this.value.setRawValue(t):this.showWarning())}showWarning(){this.view.warning.style.display=`block`,setTimeout(()=>{this.view.warning.style.display=`none`},5e3)}};function l(e){return e instanceof File?e:null}function u(e,t){e.write(t)}const d=n({accept(e,t){if(typeof e!=`string`)return null;let n=r(t,e=>({filetypes:e.optional.array(e.required.string),invalidFiletypeMessage:e.optional.string,lineCount:e.optional.number,view:e.required.constant(`file-input`)}));return n?{initialValue:e,params:n}:null},binding:{constraint(e){return new t([])},reader(e){return l},writer(e){return u}},controller(e){return new c(e.document,{filetypes:e.params.filetypes,invalidFiletypeMessage:e.params.invalidFiletypeMessage??`Unaccepted file type.`,lineCount:e.params.lineCount??3,value:e.value,viewProps:e.viewProps})},id:`file-input`,type:`input`});var f=`.tp-ctnv{appearance:none;font-family:inherit;font-size:inherit;font-weight:inherit;background-color:#0000;background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);height:var(--cnt-usz);font-family:inherit;line-height:var(--cnt-usz);border-width:0;outline:none;width:100%;min-width:0;margin:0;padding:0}.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;border:1px dashed #717070;border-radius:5px;flex-wrap:nowrap;justify-content:center;align-items:center;width:100%;height:100%;display:flex;position:relative;overflow:hidden}.tp-ctnv.tp-v-disabled{opacity:.5}.tp-ctnv_input_area_dragging{background-color:#5858b93b;border:1px dashed #6774ff}.tp-ctnv_warning{width:100%;height:max-content;margin-top:var(--cnt-vp);color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;font-size:.9em;line-height:1.5;display:inline-block;bottom:2px}.tp-ctnv_text{width:max-content;max-width:100%;height:max-content;max-height:100%;color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;margin:.2rem;font-size:.9em;line-height:.9;display:inline-block;position:absolute;bottom:2px;right:2px}.tp-ctnv_frac{background-color:var(--in-fg);border-radius:1px;height:2px;margin-top:-1px;position:absolute;top:50%;left:50%}.tp-ctnv_icon{transform:scale(var(--ggs,1));box-sizing:border-box;opacity:.5;border:2px solid;border-top:0;border-bottom-right-radius:2px;border-bottom-left-radius:2px;width:16px;height:6px;margin-top:8px;display:block;position:absolute}.tp-ctnv_icon:after{content:"";box-sizing:border-box;border-top:2px solid;border-left:2px solid;width:8px;height:8px;display:block;position:absolute;bottom:4px;left:2px;transform:rotate(45deg)}.tp-ctnv_icon:before{content:"";box-sizing:border-box;background:currentColor;border-radius:3px;width:2px;height:10px;display:block;position:absolute;bottom:3px;left:5px}.tp-btnv_b{margin-top:10px}.tp-inputv{opacity:0}
|
|
1
|
+
import{ClassName as e,CompositeConstraint as t,createPlugin as n,parseRecord as r}from"@tweakpane/core";const i=e(`ctn`),a=e(`input`),o=e(`btn`);var s=class{clearButton;container;element;fileIcon;input;text;warning;constructor(e,t){this.element=e.createElement(`div`),this.container=e.createElement(`div`),this.container.classList.add(i()),t.viewProps.bindClassModifiers(this.container),this.input=e.createElement(`input`),this.input.classList.add(a()),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(i(`icon`)),this.text=e.createElement(`span`),this.text.classList.add(i(`text`)),this.warning=e.createElement(`span`),this.warning.classList.add(i(`warning`)),this.warning.textContent=t.invalidFiletypeMessage,this.warning.style.display=`none`,this.clearButton=e.createElement(`button`),this.clearButton.classList.add(o(`b`)),this.clearButton.textContent=`Delete`,this.clearButton.style.display=`none`,this.container.append(this.input),this.container.append(this.fileIcon),this.element.append(this.container),this.element.append(this.warning),this.element.append(this.clearButton)}changeDraggingState(e){e?this.container.classList.add(i(`input_area_dragging`)):this.container.classList.remove(i(`input_area_dragging`))}},c=class{value;view;viewProps;config;constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new s(e,{filetypes:t.filetypes,invalidFiletypeMessage:t.invalidFiletypeMessage,lineCount:t.lineCount,value:t.value,viewProps:this.viewProps}),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.clearButton.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.clearButton.removeEventListener(`click`,this.onDeleteClick)})}handleValueChange(){let e=this.value.rawValue,t=this.view.container,n=this.view.text,r=this.view.fileIcon,{clearButton:i}=this.view;e?(n.textContent=e.name,t.append(n),t.contains(r)&&r.remove(),this.view.warning.style.display=`none`,i.style.display=`block`,t.style.border=`unset`):(n.textContent=``,t.append(r),n.remove(),this.view.warning.style.display=`none`,i.style.display=`none`,t.style.border=`1px dashed #717070`)}isFileValid(e){let{filetypes:t}=this.config,n=`.`+(e.name.split(`.`).pop()?.toLowerCase()??``);return!t||t.length===0||t.includes(n)}onDeleteClick(){this.value.rawValue&&(this.value.setRawValue(null),this.view.input.value=``,this.view.warning.style.display=`none`)}onDragLeave(){this.view.changeDraggingState(!1)}onDragOver(e){e.preventDefault(),this.view.changeDraggingState(!0)}onDrop(e){try{if(!(e instanceof DragEvent))return;e.preventDefault();let t=e.dataTransfer?.files;if(t?.length!==1)return;let n=t.item(0);if(!n)return;this.isFileValid(n)?this.value.setRawValue(n):this.showWarning()}finally{this.view.changeDraggingState(!1)}}onFile(e){let t=this.view.input.files?.item(0);t&&(this.isFileValid(t)?this.value.setRawValue(t):this.showWarning())}showWarning(){this.view.warning.style.display=`block`,setTimeout(()=>{this.view.warning.style.display=`none`},5e3)}};function l(e){return e instanceof File?e:null}function u(e,t){e.write(t)}const d=n({accept(e,t){if(typeof e!=`string`)return null;let n=r(t,e=>({filetypes:e.optional.array(e.required.string),invalidFiletypeMessage:e.optional.string,lineCount:e.optional.number,view:e.required.constant(`file-input`)}));return n?{initialValue:e,params:n}:null},binding:{constraint(e){return new t([])},reader(e){return l},writer(e){return u}},controller(e){return new c(e.document,{filetypes:e.params.filetypes,invalidFiletypeMessage:e.params.invalidFiletypeMessage??`Unaccepted file type.`,lineCount:e.params.lineCount??3,value:e.value,viewProps:e.viewProps})},id:`file-input`,type:`input`});var f=`.tp-ctnv{appearance:none;font-family:inherit;font-size:inherit;font-weight:inherit;background-color:#0000;background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);height:var(--cnt-usz);font-family:inherit;line-height:var(--cnt-usz);border-width:0;outline:none;width:100%;min-width:0;margin:0;padding:0}.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;border:1px dashed #717070;border-radius:5px;flex-wrap:nowrap;justify-content:center;align-items:center;width:100%;height:100%;display:flex;position:relative;overflow:hidden}.tp-ctnv.tp-v-disabled{opacity:.5}.tp-ctnv_input_area_dragging{background-color:#5858b93b;border:1px dashed #6774ff}.tp-ctnv_warning{width:100%;height:max-content;margin-top:var(--cnt-vp);color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;font-size:.9em;line-height:1.5;display:inline-block;bottom:2px}.tp-ctnv_text{width:max-content;max-width:100%;height:max-content;max-height:100%;color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;margin:.2rem;font-size:.9em;line-height:.9;display:inline-block;position:absolute;bottom:2px;right:2px}.tp-ctnv_frac{background-color:var(--in-fg);border-radius:1px;height:2px;margin-top:-1px;position:absolute;top:50%;left:50%}.tp-ctnv_icon{transform:scale(var(--ggs,1));box-sizing:border-box;opacity:.5;border:2px solid;border-top:0;border-bottom-right-radius:2px;border-bottom-left-radius:2px;width:16px;height:6px;margin-top:8px;display:block;position:absolute}.tp-ctnv_icon:after{content:"";box-sizing:border-box;border-top:2px solid;border-left:2px solid;width:8px;height:8px;display:block;position:absolute;bottom:4px;left:2px;transform:rotate(45deg)}.tp-ctnv_icon:before{content:"";box-sizing:border-box;background:currentColor;border-radius:3px;width:2px;height:10px;display:block;position:absolute;bottom:3px;left:5px}.tp-ctnv~.tp-btnv_b{margin-top:10px}.tp-inputv{opacity:0}
|
|
2
2
|
`;const p=`file-input`,m=f,h=[d];export{m as css,p as id,h as plugins};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e){return e}function t(t,n){return e(Object.keys(n).reduce((e,r)=>{if(e===void 0)return;let i=n[r],a=i(t[r]);return a.succeeded?Object.assign(Object.assign({},e),{[r]:a.value}):void 0},{}))}function n(e,t){return e.reduce((e,n)=>{if(e===void 0)return;let r=t(n);if(r.succeeded&&r.value!==void 0)return[...e,r.value]},[])}function r(e){return typeof e==`object`&&!!e}function i(e){return t=>n=>{if(!t&&n===void 0)return{succeeded:!1,value:void 0};if(t&&n===void 0)return{succeeded:!0,value:void 0};let r=e(n);return r===void 0?{succeeded:!1,value:void 0}:{succeeded:!0,value:r}}}function a(e){return{custom:t=>i(t)(e),boolean:i(e=>typeof e==`boolean`?e:void 0)(e),number:i(e=>typeof e==`number`?e:void 0)(e),string:i(e=>typeof e==`string`?e:void 0)(e),function:i(e=>typeof e==`function`?e:void 0)(e),constant:t=>i(e=>e===t?t:void 0)(e),raw:i(e=>e)(e),object:n=>i(e=>{if(r(e))return t(e,n)})(e),array:t=>i(e=>{if(Array.isArray(e))return n(e,t)})(e)}}const o={optional:a(!0),required:a(!1)};function s(e,t){let n=t(o),r=o.required.object(n)(e);return r.succeeded?r.value:void 0}function c(e){return(t,n)=>[`tp`,`-`,e,`v`,t?`_${t}`:``,n?`-${n}`:``].join(``)}const l=new class{constructor(e){let[t,n]=e.split(`-`),r=t.split(`.`);this.major=parseInt(r[0],10),this.minor=parseInt(r[1],10),this.patch=parseInt(r[2],10),this.prerelease=n??null}toString(){let e=[this.major,this.minor,this.patch].join(`.`);return this.prerelease===null?e:[e,this.prerelease].join(`-`)}}(`2.0.5`);function u(e){return Object.assign({core:l},e)}var d=class{constructor(e){this.constraints=e}constrain(e){return this.constraints.reduce((e,t)=>t.constrain(e),e)}};const f=c(`ctn`),p=c(`input`),m=c(`btn`);var h=class{clearButton;container;element;fileIcon;input;text;warning;constructor(e,t){this.element=e.createElement(`div`),this.container=e.createElement(`div`),this.container.classList.add(f()),t.viewProps.bindClassModifiers(this.container),this.input=e.createElement(`input`),this.input.classList.add(p()),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(f(`icon`)),this.text=e.createElement(`span`),this.text.classList.add(f(`text`)),this.warning=e.createElement(`span`),this.warning.classList.add(f(`warning`)),this.warning.textContent=t.invalidFiletypeMessage,this.warning.style.display=`none`,this.clearButton=e.createElement(`button`),this.clearButton.classList.add(m(`b`)),this.clearButton.textContent=`Delete`,this.clearButton.style.display=`none`,this.container.append(this.input),this.container.append(this.fileIcon),this.element.append(this.container),this.element.append(this.warning),this.element.append(this.clearButton)}changeDraggingState(e){e?this.container.classList.add(f(`input_area_dragging`)):this.container.classList.remove(f(`input_area_dragging`))}},g=class{value;view;viewProps;config;constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new h(e,{filetypes:t.filetypes,invalidFiletypeMessage:t.invalidFiletypeMessage,lineCount:t.lineCount,value:t.value,viewProps:this.viewProps}),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.clearButton.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.clearButton.removeEventListener(`click`,this.onDeleteClick)})}handleValueChange(){let e=this.value.rawValue,t=this.view.container,n=this.view.text,r=this.view.fileIcon,{clearButton:i}=this.view;e?(n.textContent=e.name,t.append(n),t.contains(r)&&r.remove(),this.view.warning.style.display=`none`,i.style.display=`block`,t.style.border=`unset`):(n.textContent=``,t.append(r),n.remove(),this.view.warning.style.display=`none`,i.style.display=`none`,t.style.border=`1px dashed #717070`)}isFileValid(e){let{filetypes:t}=this.config,n=`.`+(e.name.split(`.`).pop()?.toLowerCase()??``);return!t||t.length===0||t.includes(n)}onDeleteClick(){this.value.rawValue&&(this.value.setRawValue(null),this.view.input.value=``,this.view.warning.style.display=`none`)}onDragLeave(){this.view.changeDraggingState(!1)}onDragOver(e){e.preventDefault(),this.view.changeDraggingState(!0)}onDrop(e){try{if(!(e instanceof DragEvent))return;e.preventDefault();let t=e.dataTransfer?.files;if(t?.length!==1)return;let n=t.item(0);if(!n)return;this.isFileValid(n)?this.value.setRawValue(n):this.showWarning()}finally{this.view.changeDraggingState(!1)}}onFile(e){let t=this.view.input.files?.item(0);t&&(this.isFileValid(t)?this.value.setRawValue(t):this.showWarning())}showWarning(){this.view.warning.style.display=`block`,setTimeout(()=>{this.view.warning.style.display=`none`},5e3)}};function _(e){return e instanceof File?e:null}function v(e,t){e.write(t)}const y=u({accept(e,t){if(typeof e!=`string`)return null;let n=s(t,e=>({filetypes:e.optional.array(e.required.string),invalidFiletypeMessage:e.optional.string,lineCount:e.optional.number,view:e.required.constant(`file-input`)}));return n?{initialValue:e,params:n}:null},binding:{constraint(e){return new d([])},reader(e){return _},writer(e){return v}},controller(e){return new g(e.document,{filetypes:e.params.filetypes,invalidFiletypeMessage:e.params.invalidFiletypeMessage??`Unaccepted file type.`,lineCount:e.params.lineCount??3,value:e.value,viewProps:e.viewProps})},id:`file-input`,type:`input`});var b=`.tp-ctnv{appearance:none;font-family:inherit;font-size:inherit;font-weight:inherit;background-color:#0000;background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);height:var(--cnt-usz);font-family:inherit;line-height:var(--cnt-usz);border-width:0;outline:none;width:100%;min-width:0;margin:0;padding:0}.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;border:1px dashed #717070;border-radius:5px;flex-wrap:nowrap;justify-content:center;align-items:center;width:100%;height:100%;display:flex;position:relative;overflow:hidden}.tp-ctnv.tp-v-disabled{opacity:.5}.tp-ctnv_input_area_dragging{background-color:#5858b93b;border:1px dashed #6774ff}.tp-ctnv_warning{width:100%;height:max-content;margin-top:var(--cnt-vp);color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;font-size:.9em;line-height:1.5;display:inline-block;bottom:2px}.tp-ctnv_text{width:max-content;max-width:100%;height:max-content;max-height:100%;color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;margin:.2rem;font-size:.9em;line-height:.9;display:inline-block;position:absolute;bottom:2px;right:2px}.tp-ctnv_frac{background-color:var(--in-fg);border-radius:1px;height:2px;margin-top:-1px;position:absolute;top:50%;left:50%}.tp-ctnv_icon{transform:scale(var(--ggs,1));box-sizing:border-box;opacity:.5;border:2px solid;border-top:0;border-bottom-right-radius:2px;border-bottom-left-radius:2px;width:16px;height:6px;margin-top:8px;display:block;position:absolute}.tp-ctnv_icon:after{content:"";box-sizing:border-box;border-top:2px solid;border-left:2px solid;width:8px;height:8px;display:block;position:absolute;bottom:4px;left:2px;transform:rotate(45deg)}.tp-ctnv_icon:before{content:"";box-sizing:border-box;background:currentColor;border-radius:3px;width:2px;height:10px;display:block;position:absolute;bottom:3px;left:5px}.tp-btnv_b{margin-top:10px}.tp-inputv{opacity:0}
|
|
1
|
+
function e(e){return e}function t(t,n){return e(Object.keys(n).reduce((e,r)=>{if(e===void 0)return;let i=n[r],a=i(t[r]);return a.succeeded?Object.assign(Object.assign({},e),{[r]:a.value}):void 0},{}))}function n(e,t){return e.reduce((e,n)=>{if(e===void 0)return;let r=t(n);if(r.succeeded&&r.value!==void 0)return[...e,r.value]},[])}function r(e){return typeof e==`object`&&!!e}function i(e){return t=>n=>{if(!t&&n===void 0)return{succeeded:!1,value:void 0};if(t&&n===void 0)return{succeeded:!0,value:void 0};let r=e(n);return r===void 0?{succeeded:!1,value:void 0}:{succeeded:!0,value:r}}}function a(e){return{custom:t=>i(t)(e),boolean:i(e=>typeof e==`boolean`?e:void 0)(e),number:i(e=>typeof e==`number`?e:void 0)(e),string:i(e=>typeof e==`string`?e:void 0)(e),function:i(e=>typeof e==`function`?e:void 0)(e),constant:t=>i(e=>e===t?t:void 0)(e),raw:i(e=>e)(e),object:n=>i(e=>{if(r(e))return t(e,n)})(e),array:t=>i(e=>{if(Array.isArray(e))return n(e,t)})(e)}}const o={optional:a(!0),required:a(!1)};function s(e,t){let n=t(o),r=o.required.object(n)(e);return r.succeeded?r.value:void 0}function c(e){return(t,n)=>[`tp`,`-`,e,`v`,t?`_${t}`:``,n?`-${n}`:``].join(``)}const l=new class{constructor(e){let[t,n]=e.split(`-`),r=t.split(`.`);this.major=parseInt(r[0],10),this.minor=parseInt(r[1],10),this.patch=parseInt(r[2],10),this.prerelease=n??null}toString(){let e=[this.major,this.minor,this.patch].join(`.`);return this.prerelease===null?e:[e,this.prerelease].join(`-`)}}(`2.0.5`);function u(e){return Object.assign({core:l},e)}var d=class{constructor(e){this.constraints=e}constrain(e){return this.constraints.reduce((e,t)=>t.constrain(e),e)}};const f=c(`ctn`),p=c(`input`),m=c(`btn`);var h=class{clearButton;container;element;fileIcon;input;text;warning;constructor(e,t){this.element=e.createElement(`div`),this.container=e.createElement(`div`),this.container.classList.add(f()),t.viewProps.bindClassModifiers(this.container),this.input=e.createElement(`input`),this.input.classList.add(p()),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(f(`icon`)),this.text=e.createElement(`span`),this.text.classList.add(f(`text`)),this.warning=e.createElement(`span`),this.warning.classList.add(f(`warning`)),this.warning.textContent=t.invalidFiletypeMessage,this.warning.style.display=`none`,this.clearButton=e.createElement(`button`),this.clearButton.classList.add(m(`b`)),this.clearButton.textContent=`Delete`,this.clearButton.style.display=`none`,this.container.append(this.input),this.container.append(this.fileIcon),this.element.append(this.container),this.element.append(this.warning),this.element.append(this.clearButton)}changeDraggingState(e){e?this.container.classList.add(f(`input_area_dragging`)):this.container.classList.remove(f(`input_area_dragging`))}},g=class{value;view;viewProps;config;constructor(e,t){this.value=t.value,this.viewProps=t.viewProps,this.view=new h(e,{filetypes:t.filetypes,invalidFiletypeMessage:t.invalidFiletypeMessage,lineCount:t.lineCount,value:t.value,viewProps:this.viewProps}),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.clearButton.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.clearButton.removeEventListener(`click`,this.onDeleteClick)})}handleValueChange(){let e=this.value.rawValue,t=this.view.container,n=this.view.text,r=this.view.fileIcon,{clearButton:i}=this.view;e?(n.textContent=e.name,t.append(n),t.contains(r)&&r.remove(),this.view.warning.style.display=`none`,i.style.display=`block`,t.style.border=`unset`):(n.textContent=``,t.append(r),n.remove(),this.view.warning.style.display=`none`,i.style.display=`none`,t.style.border=`1px dashed #717070`)}isFileValid(e){let{filetypes:t}=this.config,n=`.`+(e.name.split(`.`).pop()?.toLowerCase()??``);return!t||t.length===0||t.includes(n)}onDeleteClick(){this.value.rawValue&&(this.value.setRawValue(null),this.view.input.value=``,this.view.warning.style.display=`none`)}onDragLeave(){this.view.changeDraggingState(!1)}onDragOver(e){e.preventDefault(),this.view.changeDraggingState(!0)}onDrop(e){try{if(!(e instanceof DragEvent))return;e.preventDefault();let t=e.dataTransfer?.files;if(t?.length!==1)return;let n=t.item(0);if(!n)return;this.isFileValid(n)?this.value.setRawValue(n):this.showWarning()}finally{this.view.changeDraggingState(!1)}}onFile(e){let t=this.view.input.files?.item(0);t&&(this.isFileValid(t)?this.value.setRawValue(t):this.showWarning())}showWarning(){this.view.warning.style.display=`block`,setTimeout(()=>{this.view.warning.style.display=`none`},5e3)}};function _(e){return e instanceof File?e:null}function v(e,t){e.write(t)}const y=u({accept(e,t){if(typeof e!=`string`)return null;let n=s(t,e=>({filetypes:e.optional.array(e.required.string),invalidFiletypeMessage:e.optional.string,lineCount:e.optional.number,view:e.required.constant(`file-input`)}));return n?{initialValue:e,params:n}:null},binding:{constraint(e){return new d([])},reader(e){return _},writer(e){return v}},controller(e){return new g(e.document,{filetypes:e.params.filetypes,invalidFiletypeMessage:e.params.invalidFiletypeMessage??`Unaccepted file type.`,lineCount:e.params.lineCount??3,value:e.value,viewProps:e.viewProps})},id:`file-input`,type:`input`});var b=`.tp-ctnv{appearance:none;font-family:inherit;font-size:inherit;font-weight:inherit;background-color:#0000;background-color:var(--in-bg);border-radius:var(--bld-br);box-sizing:border-box;color:var(--in-fg);height:var(--cnt-usz);font-family:inherit;line-height:var(--cnt-usz);border-width:0;outline:none;width:100%;min-width:0;margin:0;padding:0}.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;border:1px dashed #717070;border-radius:5px;flex-wrap:nowrap;justify-content:center;align-items:center;width:100%;height:100%;display:flex;position:relative;overflow:hidden}.tp-ctnv.tp-v-disabled{opacity:.5}.tp-ctnv_input_area_dragging{background-color:#5858b93b;border:1px dashed #6774ff}.tp-ctnv_warning{width:100%;height:max-content;margin-top:var(--cnt-vp);color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;font-size:.9em;line-height:1.5;display:inline-block;bottom:2px}.tp-ctnv_text{width:max-content;max-width:100%;height:max-content;max-height:100%;color:var(--in-fg);text-align:right;overflow-wrap:break-word;white-space:normal;opacity:.5;margin:.2rem;font-size:.9em;line-height:.9;display:inline-block;position:absolute;bottom:2px;right:2px}.tp-ctnv_frac{background-color:var(--in-fg);border-radius:1px;height:2px;margin-top:-1px;position:absolute;top:50%;left:50%}.tp-ctnv_icon{transform:scale(var(--ggs,1));box-sizing:border-box;opacity:.5;border:2px solid;border-top:0;border-bottom-right-radius:2px;border-bottom-left-radius:2px;width:16px;height:6px;margin-top:8px;display:block;position:absolute}.tp-ctnv_icon:after{content:"";box-sizing:border-box;border-top:2px solid;border-left:2px solid;width:8px;height:8px;display:block;position:absolute;bottom:4px;left:2px;transform:rotate(45deg)}.tp-ctnv_icon:before{content:"";box-sizing:border-box;background:currentColor;border-radius:3px;width:2px;height:10px;display:block;position:absolute;bottom:3px;left:5px}.tp-ctnv~.tp-btnv_b{margin-top:10px}.tp-inputv{opacity:0}
|
|
2
2
|
`;const x=`file-input`,S=b,C=[y];export{S as css,x as id,C as plugins};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kitschpatrol/tweakpane-plugin-file-import",
|
|
3
|
-
"version": "1.2.0-fork.
|
|
3
|
+
"version": "1.2.0-fork.3",
|
|
4
4
|
"description": "Fork of tweakpane-plugin-file-import with build optimizations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"npm-package",
|
|
@@ -52,13 +52,13 @@
|
|
|
52
52
|
"bumpp": "^12.3.0",
|
|
53
53
|
"happy-dom": "^21.0.4",
|
|
54
54
|
"publint": "^0.3.25",
|
|
55
|
-
"sass": "^1.108.
|
|
55
|
+
"sass": "^1.108.2",
|
|
56
56
|
"shx": "^0.4.0",
|
|
57
57
|
"stylelint-config-standard-scss": "^17.0.0",
|
|
58
58
|
"tsdown": "^0.23.7",
|
|
59
59
|
"tweakpane": "^4.0.5",
|
|
60
60
|
"typescript": "~6.0.3",
|
|
61
|
-
"vite": "^8.3.
|
|
61
|
+
"vite": "^8.3.8",
|
|
62
62
|
"vitest": "^5.1.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|