tiny-essentials 1.11.0 โ 1.12.1
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 +12 -3
- package/dist/node_modules/firebase-functions/lib/common/trace.cjs +82 -0
- package/dist/node_modules/firebase-functions/lib/logger/common.cjs +57 -0
- package/dist/node_modules/firebase-functions/lib/logger/index.cjs +158 -0
- package/dist/v1/TinyBasicsEs.js +1653 -1
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDragDropDetector.js +307 -0
- package/dist/v1/TinyDragDropDetector.min.js +1 -0
- package/dist/v1/TinyDragger.js +3668 -0
- package/dist/v1/TinyDragger.min.js +2 -0
- package/dist/v1/TinyDragger.min.js.LICENSE.txt +8 -0
- package/dist/v1/TinyEssentials.js +2888 -2
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyNotifyCenter.js +32 -0
- package/dist/v1/TinyNotifyCenter.min.js +1 -1
- package/dist/v1/TinyToastNotify.js +24 -0
- package/dist/v1/TinyToastNotify.min.js +1 -1
- package/dist/v1/TinyUploadClicker.js +5340 -0
- package/dist/v1/TinyUploadClicker.min.js +2 -0
- package/dist/v1/TinyUploadClicker.min.js.LICENSE.txt +8 -0
- package/dist/v1/basics/fileManager.cjs +524 -0
- package/dist/v1/basics/fileManager.d.mts +209 -0
- package/dist/v1/basics/fileManager.mjs +443 -0
- package/dist/v1/basics/fullScreen.cjs +134 -0
- package/dist/v1/basics/fullScreen.d.mts +8 -0
- package/dist/v1/basics/fullScreen.mjs +121 -0
- package/dist/v1/basics/html.cjs +262 -0
- package/dist/v1/basics/html.d.mts +63 -0
- package/dist/v1/basics/html.mjs +208 -0
- package/dist/v1/basics/index.cjs +40 -0
- package/dist/v1/basics/index.d.mts +38 -1
- package/dist/v1/basics/index.mjs +4 -1
- package/dist/v1/build/TinyDragDropDetector.cjs +7 -0
- package/dist/v1/build/TinyDragDropDetector.d.mts +3 -0
- package/dist/v1/build/TinyDragDropDetector.mjs +2 -0
- package/dist/v1/build/TinyDragger.cjs +7 -0
- package/dist/v1/build/TinyDragger.d.mts +3 -0
- package/dist/v1/build/TinyDragger.mjs +2 -0
- package/dist/v1/build/TinyUploadClicker.cjs +7 -0
- package/dist/v1/build/TinyUploadClicker.d.mts +3 -0
- package/dist/v1/build/TinyUploadClicker.mjs +2 -0
- package/dist/v1/css/TinyDraggerExample.css +21 -0
- package/dist/v1/css/TinyDraggerExample.min.css +1 -0
- package/dist/v1/index.cjs +44 -0
- package/dist/v1/index.d.mts +40 -1
- package/dist/v1/index.mjs +6 -1
- package/dist/v1/libs/TinyDragDropDetector.cjs +268 -0
- package/dist/v1/libs/TinyDragDropDetector.d.mts +123 -0
- package/dist/v1/libs/TinyDragDropDetector.mjs +228 -0
- package/dist/v1/libs/TinyDragger.cjs +906 -0
- package/dist/v1/libs/TinyDragger.d.mts +316 -0
- package/dist/v1/libs/TinyDragger.mjs +783 -0
- package/dist/v1/libs/TinyNotifyCenter.cjs +32 -0
- package/dist/v1/libs/TinyNotifyCenter.d.mts +9 -0
- package/dist/v1/libs/TinyNotifyCenter.mjs +28 -0
- package/dist/v1/libs/TinyToastNotify.cjs +24 -0
- package/dist/v1/libs/TinyToastNotify.d.mts +8 -0
- package/dist/v1/libs/TinyToastNotify.mjs +20 -0
- package/dist/v1/libs/TinyUploadClicker.cjs +223 -0
- package/dist/v1/libs/TinyUploadClicker.d.mts +80 -0
- package/dist/v1/libs/TinyUploadClicker.mjs +182 -0
- package/docs/v1/README.md +8 -2
- package/docs/v1/basics/fileManager.md +222 -0
- package/docs/v1/basics/fullScreen.md +183 -0
- package/docs/v1/basics/html.md +243 -0
- package/docs/v1/libs/TinyDragDropDetector.md +143 -0
- package/docs/v1/libs/TinyDragger.md +430 -0
- package/docs/v1/libs/TinyLevelUp.md +1 -1
- package/docs/v1/libs/TinyNotifyCenter.md +20 -0
- package/docs/v1/libs/TinyToastNotify.md +19 -0
- package/docs/v1/libs/TinyUploadClicker.md +108 -0
- package/package.json +12 -2
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# ๐ฆ TinyUploadClicker
|
|
2
|
+
|
|
3
|
+
A tiny but good JavaScript utility that lets you bind any clickable element (buttons, icons, divs, etc.) to trigger a hidden `<input type="file">`. This allows full control over file upload behavior, visual customization, and events โ without ever showing the native file input element.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ๐ Features
|
|
8
|
+
|
|
9
|
+
* ๐ฏ **Use any HTML element** as a file input trigger
|
|
10
|
+
* ๐จ **Custom attributes and styles** for the input element
|
|
11
|
+
* ๐ **Multiple file selection** support
|
|
12
|
+
* ๐ง **Strong runtime validations** with helpful errors
|
|
13
|
+
* ๐ช **Lifecycle hooks** for click and file selection
|
|
14
|
+
* ๐งน **Clean `destroy()` method** to remove everything
|
|
15
|
+
* ๐ **No dependencies**, pure JS
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## โจ Example
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
const uploader = new TinyUploadClicker({
|
|
23
|
+
triggers: '#uploadBtn',
|
|
24
|
+
accept: ['.png', '.jpg'],
|
|
25
|
+
multiple: true,
|
|
26
|
+
inputAttributes: { 'data-role': 'upload' },
|
|
27
|
+
inputStyles: { display: 'none' },
|
|
28
|
+
onClick: (el) => console.log('Trigger clicked:', el),
|
|
29
|
+
onFileLoad: (files, el) => console.log('Files selected:', files)
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Later, cleanup:
|
|
33
|
+
uploader.destroy();
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## ๐งฑ Constructor
|
|
39
|
+
|
|
40
|
+
### `new TinyUploadClicker(options)`
|
|
41
|
+
|
|
42
|
+
Creates a new instance of the upload click manager.
|
|
43
|
+
|
|
44
|
+
#### ๐ Throws
|
|
45
|
+
|
|
46
|
+
* `TypeError` if any part of the config is invalid
|
|
47
|
+
* `Error` if a trigger selector resolves to no element
|
|
48
|
+
|
|
49
|
+
#### ๐ก Parameters
|
|
50
|
+
|
|
51
|
+
| Name | Type | Required | Description |
|
|
52
|
+
| --------- | ----------------------------------------- | -------- | ------------------------------------------- |
|
|
53
|
+
| `options` | [`UploaderConfig`](#-uploaderconfig-type) | โ
Yes | Configuration object for the upload clicker |
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## ๐งฉ `UploaderConfig` Type
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
type UploaderConfig = {
|
|
61
|
+
triggers: string | HTMLElement | Array<string | HTMLElement>,
|
|
62
|
+
multiple?: boolean,
|
|
63
|
+
accept?: string | string[],
|
|
64
|
+
inputAttributes?: Record<string, string>,
|
|
65
|
+
inputStyles?: Partial<CSSStyleDeclaration>,
|
|
66
|
+
onClick?: ((triggerElement: HTMLElement) => void) | null,
|
|
67
|
+
onFileLoad?: ((files: FileList, triggerElement: HTMLElement) => void) | null
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
| Property | Type | Default | Description |
|
|
72
|
+
| ----------------- | ------------------------------------------------------- | --------------------- | --------------------------------------------------------------------- |
|
|
73
|
+
| `triggers` | `string \| HTMLElement \| Array<string \| HTMLElement>` | โ | Elements (or selectors) that will trigger file selection when clicked |
|
|
74
|
+
| `multiple` | `boolean` | `false` | Whether multiple files can be selected |
|
|
75
|
+
| `accept` | `string \| string[]` | `""` | Accepted file types (e.g., `".png"` or `"image/*"`) |
|
|
76
|
+
| `inputAttributes` | `Record<string, string>` | `{}` | Extra attributes to apply to the `<input type="file">` |
|
|
77
|
+
| `inputStyles` | `Partial<CSSStyleDeclaration>` | `{ display: 'none' }` | Custom inline styles for the hidden input |
|
|
78
|
+
| `onClick` | `(HTMLElement) => void \| null` | `null` | Hook triggered when a trigger is clicked (before file dialog opens) |
|
|
79
|
+
| `onFileLoad` | `(FileList, HTMLElement) => void \| null` | `null` | Hook triggered after files are selected |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## ๐ง Methods
|
|
84
|
+
|
|
85
|
+
### `destroy(): void`
|
|
86
|
+
|
|
87
|
+
Destroys all internal listeners and DOM elements created by the instance.
|
|
88
|
+
Cleans up memory and detaches everything from the DOM.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## ๐ก๏ธ Runtime Validations
|
|
93
|
+
|
|
94
|
+
The constructor performs strict type validation and helpful error reporting:
|
|
95
|
+
|
|
96
|
+
* โ Missing or invalid `triggers` throws immediately.
|
|
97
|
+
* โ Selectors that resolve to `null` will throw.
|
|
98
|
+
* โ Invalid types for `accept`, `onClick`, `onFileLoad`, `inputStyles`, and `inputAttributes` are rejected.
|
|
99
|
+
* โ
Supports string or array for `accept`.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## ๐ ๏ธ Internal Design
|
|
104
|
+
|
|
105
|
+
* Each trigger gets its own file input.
|
|
106
|
+
* Inputs are stored in a `WeakMap<HTMLElement, HTMLInputElement>`.
|
|
107
|
+
* After a file is selected, the input is reset so the same file can be selected again.
|
|
108
|
+
* All inputs are appended to `document.body` and styled invisibly by default.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "npm run test:mjs && npm run test:cjs && npm run test:js",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"test:mjs:jsoncolor": "node test/index.mjs colorStringify",
|
|
13
13
|
"test:mjs:ratelimit": "node test/index.mjs rateLimit",
|
|
14
14
|
"test:mjs:levelup": "node test/index.mjs levelUp",
|
|
15
|
+
"test:mjs:filemanager": "node test/index.mjs fileManager",
|
|
15
16
|
"fix:prettier": "npm run fix:prettier:src && npm run fix:prettier:test && npm run fix:prettier:rollup.config && npm run fix:prettier:webpack.config",
|
|
16
17
|
"fix:prettier:src": "prettier --write ./src/*",
|
|
17
18
|
"fix:prettier:test": "prettier --write ./test/*",
|
|
@@ -22,7 +23,8 @@
|
|
|
22
23
|
"build:js": "tsc -p tsconfig.json && rollup -c && webpack --mode production",
|
|
23
24
|
"build-clean": "npm run clean && npm run build",
|
|
24
25
|
"build-dist": "npm run build",
|
|
25
|
-
"build:css": "npm run build:css:aimaker && npm run build:css:tinynotify",
|
|
26
|
+
"build:css": "npm run build:css:aimaker && npm run build:css:tinynotify && npm run build:css:tinydragger:example",
|
|
27
|
+
"build:css:tinydragger:example": "sass src/v1/scss/TinyDraggerExample.scss dist/v1/css/TinyDraggerExample.css --no-source-map && sass src/v1/scss/TinyDraggerExample.scss dist/v1/css/TinyDraggerExample.min.css --no-source-map --style=compressed",
|
|
26
28
|
"build:css:aimaker": "sass src/v1/scss/aiMarker.scss dist/v1/css/aiMarker.css --no-source-map && sass src/v1/scss/aiMarker.scss dist/v1/css/aiMarker.min.css --no-source-map --style=compressed",
|
|
27
29
|
"build:css:tinynotify": "sass src/v1/scss/TinyNotify.scss dist/v1/css/TinyNotify.css --no-source-map && sass src/v1/scss/TinyNotify.scss dist/v1/css/TinyNotify.min.css --no-source-map --style=compressed",
|
|
28
30
|
"clean": "rm -rf dist",
|
|
@@ -36,6 +38,14 @@
|
|
|
36
38
|
".": {
|
|
37
39
|
"require": "./dist/v1/index.cjs",
|
|
38
40
|
"import": "./dist/v1/index.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./libs": {
|
|
43
|
+
"require": "./dist/v1/libs/index.cjs",
|
|
44
|
+
"import": "./dist/v1/libs/index.mjs"
|
|
45
|
+
},
|
|
46
|
+
"./basics": {
|
|
47
|
+
"require": "./dist/v1/basics/index.cjs",
|
|
48
|
+
"import": "./dist/v1/basics/index.mjs"
|
|
39
49
|
}
|
|
40
50
|
},
|
|
41
51
|
"repository": {
|