@kitschpatrol/tweakpane-plugin-file-import 1.1.2-beta.2 → 1.2.0-fork.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.
@@ -0,0 +1,247 @@
1
+ import { ClassName, CompositeConstraint, createPlugin, parseRecord } from "@tweakpane/core";
2
+ // src/view/view.ts
3
+ const containerClassName = ClassName("ctn");
4
+ const inputClassName = ClassName("input");
5
+ const buttonClassName = ClassName("btn");
6
+ var FilePluginView = class {
7
+ clearButton;
8
+ container;
9
+ element;
10
+ fileIcon;
11
+ input;
12
+ text;
13
+ warning;
14
+ constructor(doc, config) {
15
+ this.element = doc.createElement("div");
16
+ this.container = doc.createElement("div");
17
+ this.container.classList.add(containerClassName());
18
+ config.viewProps.bindClassModifiers(this.container);
19
+ this.input = doc.createElement("input");
20
+ this.input.classList.add(inputClassName());
21
+ this.input.setAttribute("type", "file");
22
+ this.input.setAttribute("accept", config.filetypes ? config.filetypes.join(",") : "*");
23
+ this.input.style.height = `calc(20px * ${config.lineCount})`;
24
+ this.fileIcon = doc.createElement("div");
25
+ this.fileIcon.classList.add(containerClassName("icon"));
26
+ this.text = doc.createElement("span");
27
+ this.text.classList.add(containerClassName("text"));
28
+ this.warning = doc.createElement("span");
29
+ this.warning.classList.add(containerClassName("warning"));
30
+ this.warning.textContent = config.invalidFiletypeMessage;
31
+ this.warning.style.display = "none";
32
+ this.clearButton = doc.createElement("button");
33
+ this.clearButton.classList.add(buttonClassName("b"));
34
+ this.clearButton.textContent = "Delete";
35
+ this.clearButton.style.display = "none";
36
+ this.container.append(this.input);
37
+ this.container.append(this.fileIcon);
38
+ this.element.append(this.container);
39
+ this.element.append(this.warning);
40
+ this.element.append(this.clearButton);
41
+ }
42
+ /**
43
+ * Changes the style of the container based on whether the user is dragging or
44
+ * not.
45
+ *
46
+ * @param state If the user is dragging or not.
47
+ */
48
+ changeDraggingState(state) {
49
+ if (state) this.container.classList.add(containerClassName("input_area_dragging"));
50
+ else this.container.classList.remove(containerClassName("input_area_dragging"));
51
+ }
52
+ };
53
+ // src/controller/controller.ts
54
+ var FilePluginController = class {
55
+ value;
56
+ view;
57
+ viewProps;
58
+ config;
59
+ constructor(doc, config) {
60
+ this.value = config.value;
61
+ this.viewProps = config.viewProps;
62
+ this.view = new FilePluginView(doc, {
63
+ filetypes: config.filetypes,
64
+ invalidFiletypeMessage: config.invalidFiletypeMessage,
65
+ lineCount: config.lineCount,
66
+ value: config.value,
67
+ viewProps: this.viewProps
68
+ });
69
+ this.config = config;
70
+ this.onFile = this.onFile.bind(this);
71
+ this.onDrop = this.onDrop.bind(this);
72
+ this.onDragOver = this.onDragOver.bind(this);
73
+ this.onDragLeave = this.onDragLeave.bind(this);
74
+ this.onDeleteClick = this.onDeleteClick.bind(this);
75
+ this.view.input.addEventListener("change", this.onFile);
76
+ this.view.element.addEventListener("drop", this.onDrop);
77
+ this.view.element.addEventListener("dragover", this.onDragOver);
78
+ this.view.element.addEventListener("dragleave", this.onDragLeave);
79
+ this.view.clearButton.addEventListener("click", this.onDeleteClick);
80
+ this.value.emitter.on("change", () => {
81
+ this.handleValueChange();
82
+ });
83
+ this.viewProps.handleDispose(() => {
84
+ this.view.input.removeEventListener("change", this.onFile);
85
+ this.view.element.removeEventListener("drop", this.onDrop);
86
+ this.view.element.removeEventListener("dragover", this.onDragOver);
87
+ this.view.element.removeEventListener("dragleave", this.onDragLeave);
88
+ this.view.clearButton.removeEventListener("click", this.onDeleteClick);
89
+ });
90
+ }
91
+ /**
92
+ * Called when the value (bound to the controller) changes (e.g. when the file
93
+ * is selected).
94
+ */
95
+ handleValueChange() {
96
+ const fileObject = this.value.rawValue;
97
+ const containerElement = this.view.container;
98
+ const textElement = this.view.text;
99
+ const fileIconElement = this.view.fileIcon;
100
+ const { clearButton } = this.view;
101
+ if (fileObject) {
102
+ textElement.textContent = fileObject.name;
103
+ containerElement.append(textElement);
104
+ if (containerElement.contains(fileIconElement)) fileIconElement.remove();
105
+ this.view.warning.style.display = "none";
106
+ clearButton.style.display = "block";
107
+ containerElement.style.border = "unset";
108
+ } else {
109
+ textElement.textContent = "";
110
+ containerElement.append(fileIconElement);
111
+ textElement.remove();
112
+ this.view.warning.style.display = "none";
113
+ clearButton.style.display = "none";
114
+ containerElement.style.border = "1px dashed #717070";
115
+ }
116
+ }
117
+ /**
118
+ * Checks if the file is valid with the given filetypes.
119
+ *
120
+ * @param file File object
121
+ *
122
+ * @returns True if the file is valid.
123
+ */
124
+ isFileValid(file) {
125
+ const { filetypes } = this.config;
126
+ const fileExtension = "." + (file.name.split(".").pop()?.toLowerCase() ?? "");
127
+ return !filetypes || filetypes.length === 0 || filetypes.includes(fileExtension);
128
+ }
129
+ /**
130
+ * Event handler when the delete HTML button is clicked. It resets the
131
+ * `rawValue` of the controller.
132
+ */
133
+ onDeleteClick() {
134
+ if (!this.value.rawValue) return;
135
+ this.value.setRawValue(null);
136
+ this.view.input.value = "";
137
+ this.view.warning.style.display = "none";
138
+ }
139
+ /**
140
+ * Called when the user leaves the container while dragging. Updates the style
141
+ * of the container.
142
+ */
143
+ onDragLeave() {
144
+ this.view.changeDraggingState(false);
145
+ }
146
+ /**
147
+ * Called when the user drags over a file. Updates the style of the container.
148
+ *
149
+ * @param event Drag event.
150
+ */
151
+ onDragOver(event) {
152
+ event.preventDefault();
153
+ this.view.changeDraggingState(true);
154
+ }
155
+ /**
156
+ * Called when the user drops a file in the container. Either shows a warning
157
+ * if it's invalid or updates the value if it's valid.
158
+ *
159
+ * @param event Drag event.
160
+ */
161
+ onDrop(event) {
162
+ try {
163
+ if (!(event instanceof DragEvent)) return;
164
+ event.preventDefault();
165
+ const files = event.dataTransfer?.files;
166
+ if (files?.length !== 1) return;
167
+ const file = files.item(0);
168
+ if (!file) return;
169
+ if (this.isFileValid(file)) this.value.setRawValue(file);
170
+ else this.showWarning();
171
+ } finally {
172
+ this.view.changeDraggingState(false);
173
+ }
174
+ }
175
+ /**
176
+ * Called when the value of the input changes.
177
+ *
178
+ * @param _event Change event.
179
+ */
180
+ onFile(_event) {
181
+ const file = this.view.input.files?.item(0);
182
+ if (!file) return;
183
+ if (this.isFileValid(file)) this.value.setRawValue(file);
184
+ else this.showWarning();
185
+ }
186
+ /**
187
+ * Shows warning text for 5 seconds.
188
+ */
189
+ showWarning() {
190
+ this.view.warning.style.display = "block";
191
+ setTimeout(() => {
192
+ this.view.warning.style.display = "none";
193
+ }, 5e3);
194
+ }
195
+ };
196
+ // src/plugin.ts
197
+ function readFile(exValue) {
198
+ return exValue instanceof File ? exValue : null;
199
+ }
200
+ function writeFile(target, inValue) {
201
+ target.write(inValue);
202
+ }
203
+ const TweakpaneFileInputPlugin = createPlugin({
204
+ accept(exValue, params) {
205
+ if (typeof exValue !== "string") return null;
206
+ const result = parseRecord(params, (p) => ({
207
+ filetypes: p.optional.array(p.required.string),
208
+ invalidFiletypeMessage: p.optional.string,
209
+ lineCount: p.optional.number,
210
+ view: p.required.constant("file-input")
211
+ }));
212
+ if (!result) return null;
213
+ return {
214
+ initialValue: exValue,
215
+ params: result
216
+ };
217
+ },
218
+ binding: {
219
+ constraint(_args) {
220
+ return new CompositeConstraint([]);
221
+ },
222
+ reader(_args) {
223
+ return readFile;
224
+ },
225
+ writer(_args) {
226
+ return writeFile;
227
+ }
228
+ },
229
+ controller(args) {
230
+ return new FilePluginController(args.document, {
231
+ filetypes: args.params.filetypes,
232
+ invalidFiletypeMessage: args.params.invalidFiletypeMessage ?? "Unaccepted file type.",
233
+ lineCount: args.params.lineCount ?? 3,
234
+ value: args.value,
235
+ viewProps: args.viewProps
236
+ });
237
+ },
238
+ id: "file-input",
239
+ type: "input"
240
+ });
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";
243
+ // src/index.ts
244
+ const id = "file-input";
245
+ const css = plugin_default;
246
+ const plugins = [TweakpaneFileInputPlugin];
247
+ export { css, id, plugins };
@@ -0,0 +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}
2
+ `;const p=`file-input`,m=f,h=[d];export{m as css,p as id,h as plugins};
@@ -1 +1,2 @@
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};
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}
2
+ `;const x=`file-input`,S=b,C=[y];export{S as css,x as id,C as plugins};
@@ -1,4 +1,8 @@
1
+ MIT License
2
+
1
3
  Copyright (c) 2021 cocopon <cocopon@me.com>
4
+ Copyright (c) 2023-2026 Luís Arteiro
5
+ Copyright (c) 2024-2026 Eric Mika (fork modifications)
2
6
 
3
7
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
8
  of this software and associated documentation files (the "Software"), to deal
package/package.json CHANGED
@@ -1,81 +1,89 @@
1
1
  {
2
2
  "name": "@kitschpatrol/tweakpane-plugin-file-import",
3
- "version": "1.1.2-beta.2",
4
- "type": "module",
5
- "description": "A fork of tweakpane-plugin-file-import with build optimizations.",
3
+ "version": "1.2.0-fork.2",
4
+ "description": "Fork of tweakpane-plugin-file-import with build optimizations.",
5
+ "keywords": [
6
+ "npm-package",
7
+ "tweakpane",
8
+ "tweakpane-plugin"
9
+ ],
10
+ "homepage": "https://github.com/kitschpatrol/tweakpane-plugin-file-import",
6
11
  "repository": {
7
12
  "type": "git",
8
- "url": "git+https://github.com/kitschpatrol/tweakpane-plugin-image.git"
13
+ "url": "git+https://github.com/kitschpatrol/tweakpane-plugin-file-import.git"
9
14
  },
10
- "homepage": "https://github.com/kitschpatrol/tweakpane-plugin-file-import",
11
- "author": "LuchoTurtle",
12
15
  "license": "MIT",
13
- "engines": {
14
- "node": ">=18.0.0"
16
+ "author": "Luís Arteiro",
17
+ "maintainers": [
18
+ {
19
+ "name": "Eric Mika",
20
+ "email": "eric@ericmika.com",
21
+ "url": "https://ericmika.com"
22
+ }
23
+ ],
24
+ "sideEffects": false,
25
+ "type": "module",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/tweakpane-plugin-file-import.d.ts",
29
+ "default": "./dist/tweakpane-plugin-file-import.js"
30
+ },
31
+ "./lite": {
32
+ "types": "./dist/tweakpane-plugin-file-import.d.ts",
33
+ "default": "./dist/tweakpane-plugin-file-import.lite.js"
34
+ },
35
+ "./package.json": "./package.json"
15
36
  },
16
- "main": "dist/tweakpane-plugin-file-import.js",
17
- "types": "dist/types/index.d.ts",
37
+ "main": "./dist/tweakpane-plugin-file-import.js",
38
+ "module": "./dist/tweakpane-plugin-file-import.js",
39
+ "types": "./dist/tweakpane-plugin-file-import.d.ts",
18
40
  "files": [
19
41
  "dist"
20
42
  ],
21
- "keywords": [
22
- "npm-package",
23
- "tweakpane",
24
- "tweakpane-plugin"
25
- ],
26
- "peerDependencies": {
27
- "tweakpane": "^4.0.0"
28
- },
29
43
  "dependencies": {
30
44
  "@tweakpane/core": "^2.0.5"
31
45
  },
32
46
  "devDependencies": {
33
- "@eslint/eslintrc": "^3.3.0",
34
- "@eslint/js": "^9.21.0",
35
- "@rollup/plugin-alias": "^5.1.1",
36
- "@rollup/plugin-node-resolve": "^15.3.1",
37
- "@rollup/plugin-replace": "^6.0.2",
38
- "@rollup/plugin-terser": "^0.4.4",
39
- "@rollup/plugin-typescript": "^12.1.2",
40
- "@typescript-eslint/eslint-plugin": "^8.26.0",
41
- "@typescript-eslint/parser": "^8.26.0",
42
- "autoprefixer": "^10.4.20",
43
- "bumpp": "^10.0.3",
44
- "eslint": "^9.21.0",
45
- "eslint-config-prettier": "^9.1.0",
46
- "eslint-plugin-prettier": "^5.2.3",
47
- "eslint-plugin-simple-import-sort": "^12.1.1",
48
- "http-server": "^14.1.1",
49
- "npm-run-all": "^4.1.5",
50
- "onchange": "^7.1.0",
51
- "postcss": "^8.5.3",
52
- "prettier": "^3.5.3",
53
- "prettier-plugin-pkg": "^0.18.1",
54
- "release-it": "^17.11.0",
55
- "rimraf": "^6.0.1",
56
- "rollup": "^4.34.9",
57
- "rollup-plugin-cleanup": "3.2.1",
58
- "sass": "^1.85.1",
59
- "typescript": "^5.8.2"
47
+ "@arethetypeswrong/core": "^0.18.5",
48
+ "@kitschpatrol/chagent": "^0.5.0",
49
+ "@kitschpatrol/shared-config": "^8.14.1",
50
+ "@tsdown/css": "^0.23.7",
51
+ "@types/node": "~24.13.6",
52
+ "bumpp": "^12.3.0",
53
+ "happy-dom": "^21.0.4",
54
+ "publint": "^0.3.25",
55
+ "sass": "^1.108.1",
56
+ "shx": "^0.4.0",
57
+ "stylelint-config-standard-scss": "^17.0.0",
58
+ "tsdown": "^0.23.7",
59
+ "tweakpane": "^4.0.5",
60
+ "typescript": "~6.0.3",
61
+ "vite": "^8.3.7",
62
+ "vitest": "^5.1.0"
63
+ },
64
+ "peerDependencies": {
65
+ "tweakpane": "^4.0.0"
66
+ },
67
+ "engines": {
68
+ "node": "^18.0.0 || ^20.0.0 || ^22.0.0 || ^24.0.0 || >=26.0.0"
69
+ },
70
+ "devEngines": {
71
+ "runtime": {
72
+ "name": "node",
73
+ "version": "^24.16.0 || >=26.3.0"
74
+ }
60
75
  },
61
76
  "publishConfig": {
62
77
  "access": "public"
63
78
  },
64
79
  "scripts": {
65
- "build": "run-p build:*",
66
- "build:dev": "rollup --config rollup.config.js",
67
- "build:dts": "tsc --project tsconfig-dts.json",
68
- "build:prod": "rollup --config rollup.config.js --environment BUILD:production",
69
- "clean": "rimraf dist",
70
- "format": "run-p format:*",
71
- "format:scss": "prettier --parser scss --write \"src/sass/**/*.scss\"",
72
- "format:ts": "eslint --fix \"src/**/*.ts\"",
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')",
74
- "server": "http-server -c-1 -o /test/browser.html",
75
- "start": "run-p watch server",
76
- "test": "eslint \"src/**/*.ts\"",
77
- "watch": "run-p watch:*",
78
- "watch:sass": "onchange --initial --kill \"src/sass/**/*.scss\" -- npm run build:dev",
79
- "watch:ts": "onchange --initial --kill \"src/**/*.ts\" -- rollup --config rollup.config.js"
80
+ "build": "tsdown",
81
+ "clean-deep": "shx rm -f pnpm-lock.yaml && git clean -fdX",
82
+ "dev": "vite",
83
+ "fix": "ksc fix",
84
+ "lint": "ksc lint",
85
+ "release": "bumpp --preid fork --commit 'Release: %s' --tag '%s' --all --execute 'chagent' && pnpm build && pnpm publish --otp $(op item get npm --otp) --tag latest",
86
+ "test": "vitest run",
87
+ "watch": "tsdown --watch"
80
88
  }
81
89
  }
package/readme.md ADDED
@@ -0,0 +1,119 @@
1
+ <!-- title -->
2
+
3
+ # @kitschpatrol/tweakpane-plugin-file-import
4
+
5
+ <!-- /title -->
6
+
7
+ <!-- badges({ npmDownloads: true }) -->
8
+
9
+ [![NPM Package @kitschpatrol/tweakpane-plugin-file-import](https://img.shields.io/npm/v/@kitschpatrol/tweakpane-plugin-file-import.svg)](https://www.npmjs.com/package/@kitschpatrol/tweakpane-plugin-file-import)
10
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/mit)
11
+ [![CI](https://github.com/kitschpatrol/tweakpane-plugin-file-import/actions/workflows/ci.yml/badge.svg)](https://github.com/kitschpatrol/tweakpane-plugin-file-import/actions/workflows/ci.yml)
12
+ [![NPM Downloads @kitschpatrol/tweakpane-plugin-file-import](https://img.shields.io/npm/dm/@kitschpatrol/tweakpane-plugin-file-import)](https://www.npmjs.com/package/@kitschpatrol/tweakpane-plugin-file-import)
13
+
14
+ <!-- /badges -->
15
+
16
+ <!-- description -->
17
+
18
+ **Fork of tweakpane-plugin-file-import with build optimizations.**
19
+
20
+ <!-- /description -->
21
+
22
+ ## Overview
23
+
24
+ This is a fork of [Luís Arteiro's](https://github.com/LuchoTurtle) [tweakpane-plugin-file-import](https://github.com/LuchoTurtle/tweakpane-plugin-file-import) with externalized dependencies.
25
+
26
+ This allows for smaller bundled file sizes in projects using multiple Tweakpane plugins.
27
+
28
+ It is published to NPM primarily for the [_Svelte Tweakpane UI_](https://kitschpatrol.com/svelte-tweakpane-ui) project, and will be kept in sync with the upstream version of the plugin, with minimal changes other than dependency externalization.
29
+
30
+ See the [upstream readme](https://github.com/LuchoTurtle/tweakpane-plugin-file-import#readme) for details on the original plugin and its usage.
31
+
32
+ ## Fork changes
33
+
34
+ - Publishes as `@kitschpatrol/tweakpane-plugin-file-import` instead of `tweakpane-plugin-file-import`.
35
+ - Adds a `/lite` export that imports `@tweakpane/core` instead of bundling it so projects can share one copy of `core` across multiple plugins.
36
+ - Exports public parameter types.
37
+ - Migrates the repository structure to align with the Tweakpane plugin template provided by [@kitschpatrol/create-project](https://github.com/kitschpatrol/create-project), which includes:
38
+ - [pnpm](https://pnpm.io/) instead of npm for local development
39
+ - [tsdown](https://tsdown.dev/) for bundling, type generation, and SCSS processing
40
+ - [vite](https://vite.dev/) for live-reloading the demo project
41
+ - [vitest](https://vitest.dev/) for automated tests
42
+ - [ksc](https://github.com/kitschpatrol/shared-config) for linting and shared configuration
43
+ - [chagent](https://github.com/kitschpatrol/chagent) for release notes
44
+ - Clears the drag state even when drop processing throws.
45
+
46
+ ## Getting started
47
+
48
+ ### Dependencies
49
+
50
+ The plugin requires [Tweakpane 4](https://www.npmjs.com/package/tweakpane).
51
+
52
+ The `/lite` export path imports [@tweakpane/core](https://www.npmjs.com/package/@tweakpane/core) rather than bundling it. It is installed as a dependency of this plugin, so only projects without a bundler need to provide it directly.
53
+
54
+ If you're using Svelte 4 or 5 as a front-end library, take a look at [Svelte Tweakpane UI](https://kitschpatrol.com/svelte-tweakpane-ui), which wraps Tweakpane in a set of Svelte-friendly components, including the [`<File>`](https://kitschpatrol.com/svelte-tweakpane-ui/docs/components/file) control from this plugin.
55
+
56
+ <!-- installation -->
57
+
58
+ ### Installation
59
+
60
+ Add it to your project:
61
+
62
+ ```sh
63
+ npm install @kitschpatrol/tweakpane-plugin-file-import
64
+ ```
65
+
66
+ <!-- /installation -->
67
+
68
+ ## Usage
69
+
70
+ ```ts
71
+ import * as TweakpanePluginFileImport from '@kitschpatrol/tweakpane-plugin-file-import'
72
+ import { Pane } from 'tweakpane'
73
+
74
+ const pane = new Pane()
75
+ pane.registerPlugin(TweakpanePluginFileImport)
76
+
77
+ const parameters = { file: '' }
78
+ pane.addBinding(parameters, 'file', {
79
+ filetypes: ['.png', '.jpg'],
80
+ lineCount: 3,
81
+ view: 'file-input',
82
+ })
83
+ ```
84
+
85
+ To share core through your bundler, import `@kitschpatrol/tweakpane-plugin-file-import/lite` instead.
86
+
87
+ ## Implementation notes
88
+
89
+ The [Rollup](https://rollupjs.org) configuration provided in the [Tweakpane plugin template](https://github.com/tweakpane/plugin-template) does not externalize [`@tweakpane/core`](https://github.com/cocopon/tweakpane/tree/main/packages/core) as a production dependency.
90
+
91
+ Instead, it gets built into the single-file plugin artifact, which is what's published to NPM and imported by plugin consumers. This makes it easy to import as an ES module from a URL, but means that larger projects importing multiple Tweakpane plugins end up with duplicate copies of the `@tweakpane/core` code, adding about \~100 Kb to the final minified build for each plugin after the first.
92
+
93
+ Externalizing this dependency allows build tools like [vite](https://vite.dev) to share a single instance of the `@tweakpane/core` code across multiple plugins.
94
+
95
+ 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/Reference/Elements/script/type/importmap).
96
+
97
+ ## Versioning
98
+
99
+ In addition to the dependency externalization change, this fork also includes dependency updates. In an effort to stay in sync with future upstream versions, release version numbers are tagged with a "fork" suffix and an incrementing number.
100
+
101
+ <!-- contributing -->
102
+
103
+ ## Contributing
104
+
105
+ [Issues](https://github.com/kitschpatrol/tweakpane-plugin-file-import/issues) are welcome and appreciated.
106
+
107
+ Please open an issue to discuss changes before submitting a pull request. Unsolicited PRs (especially AI-generated ones) are unlikely to be merged.
108
+
109
+ This repository uses [@kitschpatrol/shared-config](https://github.com/kitschpatrol/shared-config) (via its `ksc` CLI) for linting and formatting, plus [MDAT](https://github.com/kitschpatrol/mdat) for readme placeholder expansion.
110
+
111
+ <!-- /contributing -->
112
+
113
+ ## License
114
+
115
+ Original plugin: [MIT](license.txt) © Luís Arteiro
116
+
117
+ Original template contributions: [MIT](license.txt) © [cocopon](https://github.com/cocopon)
118
+
119
+ Fork modifications: [MIT](license.txt) © [Eric Mika](https://ericmika.com)
package/README.md DELETED
@@ -1,31 +0,0 @@
1
- # @kitschpatrol/tweakpane-plugin-file-import
2
-
3
- [![NPM Package @kitschpatrol/tweakpane-plugin-file-import](https://img.shields.io/npm/v/@kitschpatrol/tweakpane-plugin-file-import.svg)](https://npmjs.com/package/@kitschpatrol/tweakpane-plugin-file-import)
4
-
5
- ## Overview
6
-
7
- **This is a fork of [LuchoTurtle](https://github.com/LuchoTurtle)'s [tweakpane-plugin-file-import](https://github.com/LuchoTurtle/tweakpane-plugin-file-import) with externalized dependencies.**
8
-
9
- This allows for smaller bundled file sizes in projects using multiple Tweakpane plugins.
10
-
11
- It is published to NPM primarily for the [_Svelte Tweakpane UI_](https://kitschpatrol.com/svelte-tweakpane-ui) project, and will be kept in sync with the upstream version of the plugin, with minimal changes other than dependency externalization.
12
-
13
- For most use cases, you probably don't want this fork!
14
-
15
- ## Background
16
-
17
- The [Rollup](https://rollupjs.org) configuration provided in the [Tweakpane plugin template](https://github.com/tweakpane/plugin-template) does not externalize [`@tweakpane/core`](https://github.com/cocopon/tweakpane/tree/main/packages/core) as a production dependency.
18
-
19
- Instead, it gets built into the single-file plugin artifact, which is what's published to NPM and imported by plugin consumers. This makes it easy to import as an ES module from a URL, but means that larger projects importing multiple Tweakpane plugins end up with duplicate copies of the `@tweakpane/core` code, adding about ~100 Kb to the final minified build for each plugin after the first.
20
-
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
-
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
-
25
- ## Implementation notes
26
-
27
- PNPM is used as the package manager.
28
-
29
- ## Versioning
30
-
31
- In addition to the dependency externalization change, this fork also includes assorted dependency updates. In an effort to stay in sync with future upstream versions, intra-minor-version releases of the fork are tagged as "betas" of what would / will be the next patch release upstream.