tiny-essentials 1.28.18 โ 1.28.19
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/dist/v1/css/TinyCookieConsent.min.css +1 -0
- package/dist/v1/css/TinyCookieConsent.min.css.map +1 -0
- package/dist/v1/css/TinyDraggerExample.min.css +1 -0
- package/dist/v1/css/TinyDraggerExample.min.css.map +1 -0
- package/dist/v1/css/TinyLoadingScreen.min.css +1 -0
- package/dist/v1/css/TinyLoadingScreen.min.css.map +1 -0
- package/dist/v1/css/TinyNotify.min.css +1 -0
- package/dist/v1/css/TinyNotify.min.css.map +1 -0
- package/dist/v1/css/aiMarker.min.css +1 -0
- package/dist/v1/css/aiMarker.min.css.map +1 -0
- package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.cjs +699 -0
- package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.d.mts +290 -0
- package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.d.mts.map +1 -0
- package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.mjs +590 -0
- package/dist/v1/webTemplates/bootstrap/5.3/scss/input/Placeholder-Colors-Fix.scss +64 -0
- package/dist/v1/webTemplates/bootstrap/5.3/scss/spacing/Spacing-Plus.scss +31 -0
- package/docs/v1/Exports.md +10 -0
- package/docs/v1/README.md +7 -1
- package/docs/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.md +162 -0
- package/package.json +13 -8
package/docs/v1/Exports.md
CHANGED
|
@@ -225,6 +225,16 @@ Each library can be imported separately:
|
|
|
225
225
|
|
|
226
226
|
---
|
|
227
227
|
|
|
228
|
+
## ๐จ Web Templates
|
|
229
|
+
|
|
230
|
+
### Bootstrap 5.3 ๐
ฑ๏ธ
|
|
231
|
+
|
|
232
|
+
* `webTemplates/bootstrap/5.3/html/BootstrapDialogs`
|
|
233
|
+
* `webTemplates/bootstrap/5.3/scss/input/Placeholder-Colors-Fix.scss`
|
|
234
|
+
* `webTemplates/bootstrap/5.3/scss/spacing/Spacing-Plus.scss`
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
228
238
|
## โ
Import Examples
|
|
229
239
|
|
|
230
240
|
**ESM (modern projects)**
|
package/docs/v1/README.md
CHANGED
|
@@ -123,7 +123,13 @@ Here, you can navigate through different sections of the project. Below are the
|
|
|
123
123
|
* โ๏ธ **[TinyClassManager](./libs/tools/TinyClassManager.md)** โ A lightweight, immutable manager designed to linearly compose a base class with multiple modular plugins, featuring automatic dependency verification and duplicate conflict protection.
|
|
124
124
|
* ๐ ๏ธ **[TinyPluginInliner](./libs/tools/TinyClassManager/TinyPluginInliner.md)** โ A powerful build-time utility that inlines plugin code into a single bundle, automatically rewriting import paths and hoisting dependencies for seamless deployment.
|
|
125
125
|
|
|
126
|
-
### 3. **`
|
|
126
|
+
### 3. **`webTemplates/`**
|
|
127
|
+
|
|
128
|
+
#### 3.1. **`webTemplates/bootstrap/`**
|
|
129
|
+
|
|
130
|
+
- ๐ผ๏ธ **[BootstrapDialogs](./webTemplates/bootstrap/5.3/html/BootstrapDialogs.md)** โ An asynchronous JavaScript utility designed to replace native browser dialogs with customizable Bootstrap 5 Modals.
|
|
131
|
+
|
|
132
|
+
### 4. **`fileManager/`**
|
|
127
133
|
|
|
128
134
|
* ๐ **[Main](./fileManager/main.md)** โ A Node.js file/directory utility module with support for JSON, backups, renaming, size analysis, and more.
|
|
129
135
|
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# ๐ BootstrapDialogs Documentation
|
|
2
|
+
|
|
3
|
+
`BootstrapDialogs` is a asynchronous JavaScript utility designed to replace native browser dialogs (`alert`, `confirm`, `prompt`) with beautiful, customizable **Bootstrap 5 Modals**.
|
|
4
|
+
|
|
5
|
+
It provides a non-blocking, Promise-based workflow and features a robust configuration system to ensure your UI remains consistent and visually appealing.
|
|
6
|
+
|
|
7
|
+
## โจ Key Features
|
|
8
|
+
|
|
9
|
+
* **๐ Promise-Based:** All dialogs are `async`, allowing for clean `await` syntax in your business logic.
|
|
10
|
+
* **๐จ Deep Customization:** Every single part of the modal (header, body, footer, buttons, etc.) can be styled with custom CSS classes and inline styles.
|
|
11
|
+
* **๐ก๏ธ Security Focused:** Uses strict DOM manipulation to prevent XSS attacks.
|
|
12
|
+
* **โณ Loading State:** Includes a built-in, non-dismissible global loading overlay for background tasks.
|
|
13
|
+
* **๐งน Automatic Cleanup:** Automatically manages DOM elements and body classes (`modal-open`) to prevent memory leaks or broken scrolling.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## ๐ ๏ธ Setup
|
|
18
|
+
|
|
19
|
+
To use this library, you must have **Bootstrap 5** (JavaScript and CSS) included in your project. You must also initialize the library with the Bootstrap Modal class.
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
import { BootstrapDialogs } from 'tiny-essentials/webTemplates/bootstrap/5.3/html/BootstrapDialogs';
|
|
23
|
+
import { Modal } from 'bootstrap';
|
|
24
|
+
|
|
25
|
+
// 1. Initialize the Modal class
|
|
26
|
+
BootstrapDialogs.Modal = Modal;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## ๐ Global Replacement (Monkey Patching)
|
|
30
|
+
|
|
31
|
+
If you want to automatically use Bootstrap modals instead of the default browser dialogs throughout your entire application, you can "monkey patch" the global `window` object.
|
|
32
|
+
|
|
33
|
+
```javascript
|
|
34
|
+
import { BootstrapDialogs } from 'tiny-essentials/webTemplates/bootstrap/5.3/html/BootstrapDialogs';
|
|
35
|
+
|
|
36
|
+
window.alert = (msg) => BootstrapDialogs.alert(msg);
|
|
37
|
+
window.confirm = (msg) => BootstrapDialogs.confirm(msg);
|
|
38
|
+
window.prompt = (msg, def) => BootstrapDialogs.prompt(msg, def);
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
> [!WARNING]
|
|
42
|
+
> **โ ๏ธ Breaking Change Alert:** Native `window.confirm` and `window.prompt` are **synchronous** (they pause code execution). `BootstrapDialogs` methods are **asynchronous** (they return a `Promise`).
|
|
43
|
+
>
|
|
44
|
+
> If you use this replacement, you **must** update your existing code to use `await` when calling these functions.
|
|
45
|
+
>
|
|
46
|
+
> **โ Old (Synchronous):**
|
|
47
|
+
> `if (confirm("Are you sure?")) { ... }`
|
|
48
|
+
>
|
|
49
|
+
> **โ
New (Asynchronous):**
|
|
50
|
+
> `if (await confirm("Are you sure?")) { ... }`
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## โ๏ธ Configuration
|
|
55
|
+
|
|
56
|
+
### 1. Global Defaults
|
|
57
|
+
You can set a global configuration that applies to all dialogs created by the library.
|
|
58
|
+
|
|
59
|
+
```javascript
|
|
60
|
+
BootstrapDialogs.defaultConfig = {
|
|
61
|
+
modalConfig: { className: 'my-custom-modal', styles: { 'border': '2px solid blue' } },
|
|
62
|
+
confirmBtnConfig: { className: 'btn-success' },
|
|
63
|
+
// ... other config keys
|
|
64
|
+
};
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 2. Data Types (JSDoc Reference)
|
|
68
|
+
|
|
69
|
+
#### `CustomElementConfig` ๐จ
|
|
70
|
+
Used to customize specific parts of the modal.
|
|
71
|
+
| Property | Type | Description |
|
|
72
|
+
| :--- | :--- | :--- |
|
|
73
|
+
| `className` | `string \| string[]` | CSS classes to add to the element. |
|
|
74
|
+
| `styles` | `Object<string, string>` | CSS properties and values (e.g., `{ 'color': 'red' }`). |
|
|
75
|
+
|
|
76
|
+
#### `ModalOptions` ๐
|
|
77
|
+
Configuration options for individual dialog calls.
|
|
78
|
+
| Property | Type | Default | Description |
|
|
79
|
+
| :--- | :--- | :--- | :--- |
|
|
80
|
+
| `title` | `string` | `'Alert'` | Text for the modal header. |
|
|
81
|
+
| `confirmText` | `string` | `'OK'` | Text for the primary button. |
|
|
82
|
+
| `cancelText` | `string` | `'Cancel'` | Text for the secondary button. |
|
|
83
|
+
| `defaultValue` | `string` | `''` | Initial value for prompt inputs. |
|
|
84
|
+
| `modalConfig` | `CustomElementConfig` | `{}` | Customization for the main container. |
|
|
85
|
+
| `headerConfig` | `CustomElementConfig` | `{}` | Customization for the header. |
|
|
86
|
+
| `titleConfig` | `CustomElementConfig` | `{}` | Customization for the title. |
|
|
87
|
+
| `closeBtnConfig` | `CustomElementConfig` | `{}` | Customization for the close button. |
|
|
88
|
+
| `bodyConfig` | `CustomElementConfig` | `{}` | Customization for the body. |
|
|
89
|
+
| `footerConfig` | `CustomElementConfig` | `{}` | Customization for the footer. |
|
|
90
|
+
| `confirmBtnConfig`| `CustomElementConfig` | `{}` | Customization for the confirm button. |
|
|
91
|
+
| `cancelBtnConfig` | `CustomElementConfig` | `{}` | Customization for the cancel button. |
|
|
92
|
+
| `contentConfig` | `CustomElementConfig` | `{}` | Customization for the content wrapper. |
|
|
93
|
+
| `dialogConfig` | `CustomElementConfig` | `{}` | Customization for the dialog wrapper. |
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## ๐ API Reference
|
|
98
|
+
|
|
99
|
+
### ๐ข `alert(message, options)`
|
|
100
|
+
Displays a simple informational modal.
|
|
101
|
+
* **Returns:** `Promise<void>`
|
|
102
|
+
* **Usage:** `await alert('Operation successful!');`
|
|
103
|
+
|
|
104
|
+
### โ `confirm(message, options)`
|
|
105
|
+
Displays a confirmation modal with "Yes" and "No" options.
|
|
106
|
+
* **Returns:** `Promise<boolean>` (Resolves `true` if confirmed, `false` if cancelled).
|
|
107
|
+
* **Usage:**
|
|
108
|
+
```javascript
|
|
109
|
+
const isDeleted = await confirm('Are you sure you want to delete this?');
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### โจ๏ธ `prompt(message, defaultValue, options)`
|
|
113
|
+
Displays a modal with a text input field.
|
|
114
|
+
* **Returns:** `Promise<string | null>` (Resolves with the input value, or `null` if cancelled).
|
|
115
|
+
* **Usage:**
|
|
116
|
+
```javascript
|
|
117
|
+
const name = await prompt('Enter your name', 'Guest');
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### โณ `showLoading(message)`
|
|
121
|
+
Displays a global, non-dismissible loading spinner.
|
|
122
|
+
* **Returns:** `void`
|
|
123
|
+
* **Usage:** `showLoading('Fetching data...');`
|
|
124
|
+
|
|
125
|
+
### โ
`hideLoading()`
|
|
126
|
+
Removes the loading overlay.
|
|
127
|
+
* **Returns:** `void`
|
|
128
|
+
* **Usage:** `hideLoading();`
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## ๐ก Usage Example
|
|
133
|
+
|
|
134
|
+
```javascript
|
|
135
|
+
import { confirm, prompt, showLoading, hideLoading } from 'tiny-essentials/webTemplates/bootstrap/5.3/html/BootstrapDialogs';
|
|
136
|
+
|
|
137
|
+
async function handleDeleteUser(userId) {
|
|
138
|
+
// 1. Show loading state
|
|
139
|
+
showLoading('Processing request...');
|
|
140
|
+
|
|
141
|
+
try {
|
|
142
|
+
// 2. Ask for confirmation
|
|
143
|
+
const confirmed = await confirm('Do you really want to delete this user?', {
|
|
144
|
+
title: 'โ ๏ธ Warning',
|
|
145
|
+
confirmText: 'Delete Forever',
|
|
146
|
+
cancelText: 'Keep User',
|
|
147
|
+
confirmBtnConfig: { className: 'btn-danger' }
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
if (confirmed) {
|
|
151
|
+
// 3. Simulate API Call
|
|
152
|
+
await new Promise(res => setTimeout(res, 2000));
|
|
153
|
+
console.log(`User ${userId} deleted.`);
|
|
154
|
+
}
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.error(error);
|
|
157
|
+
} finally {
|
|
158
|
+
// 4. Hide loading
|
|
159
|
+
hideLoading();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.28.
|
|
3
|
+
"version": "1.28.19",
|
|
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
|
"bin": {
|
|
6
6
|
"tiny-essentials-fork": "./TinyFork.mjs"
|
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
"test:mjs:levelup": "node test/index.mjs levelUp",
|
|
19
19
|
"test:mjs:filemanager": "node test/index.mjs fileManager",
|
|
20
20
|
"test:mjs:i18": "node test/index.mjs i18",
|
|
21
|
-
"fix:prettier": "npm run fix:prettier:src && npm run fix:prettier:test && npm run fix:prettier:rollup.config && npm run fix:prettier:webpack.config && npm run fix:prettier:tiny_fork && npm run fix:prettier:check_exports",
|
|
21
|
+
"fix:prettier": "npm run fix:prettier:src && npm run fix:prettier:build && npm run fix:prettier:test && npm run fix:prettier:rollup.config && npm run fix:prettier:webpack.config && npm run fix:prettier:tiny_fork && npm run fix:prettier:check_exports",
|
|
22
22
|
"fix:prettier:src": "prettier --write ./src/*",
|
|
23
|
+
"fix:prettier:build": "prettier --write ./build/*",
|
|
23
24
|
"fix:prettier:test": "prettier --write ./test/*",
|
|
24
25
|
"fix:prettier:rollup.config": "prettier --write ./rollup.config.mjs",
|
|
25
26
|
"fix:prettier:webpack.config": "prettier --write ./webpack.config.mjs",
|
|
@@ -31,12 +32,7 @@
|
|
|
31
32
|
"build:js": "tsc -p tsconfig.json && rollup -c && webpack --mode production",
|
|
32
33
|
"build-clean": "npm run clean && npm run build",
|
|
33
34
|
"build-dist": "npm run build",
|
|
34
|
-
"build:css": "
|
|
35
|
-
"build:css:tinydragger:example": "sass src/v1/scss/TinyDraggerExample.scss dist/v1/css/TinyDraggerExample.min.css --no-source-map --style=compressed",
|
|
36
|
-
"build:css:aimaker": "sass src/v1/scss/aiMarker.scss dist/v1/css/aiMarker.min.css --no-source-map --style=compressed",
|
|
37
|
-
"build:css:tinynotify": "sass src/v1/scss/TinyNotify.scss dist/v1/css/TinyNotify.min.css --no-source-map --style=compressed",
|
|
38
|
-
"build:css:tinycookieconsent": "sass src/v1/scss/TinyCookieConsent.scss dist/v1/css/TinyCookieConsent.min.css --no-source-map --style=compressed",
|
|
39
|
-
"build:css:tinyloadingscreen": "sass src/v1/scss/TinyLoadingScreen.scss dist/v1/css/TinyLoadingScreen.min.css --no-source-map --style=compressed",
|
|
35
|
+
"build:css": "node build/sass.mjs && node build/scss.mjs",
|
|
40
36
|
"clean": "rm -rf dist",
|
|
41
37
|
"prepublishOnly": "npm run build"
|
|
42
38
|
},
|
|
@@ -50,10 +46,16 @@
|
|
|
50
46
|
"./css/TinyDraggerExample.min.css": "./dist/v1/css/TinyDraggerExample.min.css",
|
|
51
47
|
"./css/TinyNotify.min.css": "./dist/v1/css/TinyNotify.min.css",
|
|
52
48
|
"./css/TinyLoadingScreen.min.css": "./dist/v1/css/TinyLoadingScreen.min.css",
|
|
49
|
+
"./webTemplates/bootstrap/5.3/scss/input/Placeholder-Colors-Fix.scss": "./dist/v1/webTemplates/bootstrap/5.3/scss/input/Placeholder-Colors-Fix.scss",
|
|
50
|
+
"./webTemplates/bootstrap/5.3/scss/spacing/Spacing-Plus.scss": "./dist/v1/webTemplates/bootstrap/5.3/scss/spacing/Spacing-Plus.scss",
|
|
53
51
|
".": {
|
|
54
52
|
"require": "./dist/v1/index.cjs",
|
|
55
53
|
"import": "./dist/v1/index.mjs"
|
|
56
54
|
},
|
|
55
|
+
"./webTemplates/bootstrap/5.3/html/BootstrapDialogs": {
|
|
56
|
+
"require": "./dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.cjs",
|
|
57
|
+
"import": "./dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.mjs"
|
|
58
|
+
},
|
|
57
59
|
"./basics": {
|
|
58
60
|
"require": "./dist/v1/basics/index.cjs",
|
|
59
61
|
"import": "./dist/v1/basics/index.mjs"
|
|
@@ -621,11 +623,13 @@
|
|
|
621
623
|
"@rollup/plugin-json": "^6.1.0",
|
|
622
624
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
623
625
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
626
|
+
"@types/bootstrap": "^5.2.11",
|
|
624
627
|
"@types/lodash": "^4.17.16",
|
|
625
628
|
"@types/md5": "^2.3.6",
|
|
626
629
|
"@types/node": "^26.1.0",
|
|
627
630
|
"@types/node-fetch": "^2.6.12",
|
|
628
631
|
"babel-preset-es2015": "^6.24.1",
|
|
632
|
+
"bootstrap": "^5.3.8",
|
|
629
633
|
"buffer": "^6.0.3",
|
|
630
634
|
"esbuild": "^0.28.1",
|
|
631
635
|
"express": "^5.1.0",
|
|
@@ -638,6 +642,7 @@
|
|
|
638
642
|
"rollup-preserve-directives": "^1.1.3",
|
|
639
643
|
"safe-stable-stringify": "^2.5.0",
|
|
640
644
|
"sass": "^1.101.0",
|
|
645
|
+
"sass-embedded": "^1.102.0",
|
|
641
646
|
"tslib": "^2.8.1",
|
|
642
647
|
"type-fest": "^5.7.0",
|
|
643
648
|
"typescript": "^7.0.2",
|