@keenmate/pure-admin-core 1.0.0-rc01
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/LICENSE +21 -0
- package/README.md +172 -0
- package/dist/css/main.css +11542 -0
- package/dist/fonts/Delivery/Delivery_W_Bd.woff2 +0 -0
- package/dist/fonts/Delivery/Delivery_W_BdIt.woff2 +0 -0
- package/dist/fonts/Delivery/Delivery_W_CdBlk.woff2 +0 -0
- package/dist/fonts/Delivery/Delivery_W_CdLt.woff2 +0 -0
- package/dist/fonts/Delivery/Delivery_W_It.woff2 +0 -0
- package/dist/fonts/Delivery/Delivery_W_Lt.woff2 +0 -0
- package/dist/fonts/Delivery/Delivery_W_LtIt.woff2 +0 -0
- package/dist/fonts/Delivery/Delivery_W_Rg.woff2 +0 -0
- package/dist/fonts/google/3y976aknfjLm_3lMKjiMgmUUYBs04Y8UH-qVHQ.woff2 +0 -0
- package/dist/fonts/google/3y976aknfjLm_3lMKjiMgmUUYBs04Y8UH-qVHQ.woff2.1 +0 -0
- package/dist/fonts/google/3y976aknfjLm_3lMKjiMgmUUYBs04Y8UH-qVHQ.woff2.2 +0 -0
- package/dist/fonts/google/3y976aknfjLm_3lMKjiMgmUUYBs04Y8VH-qVHQ.woff2 +0 -0
- package/dist/fonts/google/3y976aknfjLm_3lMKjiMgmUUYBs04Y8VH-qVHQ.woff2.1 +0 -0
- package/dist/fonts/google/3y976aknfjLm_3lMKjiMgmUUYBs04Y8VH-qVHQ.woff2.2 +0 -0
- package/dist/fonts/google/3y976aknfjLm_3lMKjiMgmUUYBs04Y8bH-o.woff2 +0 -0
- package/dist/fonts/google/3y976aknfjLm_3lMKjiMgmUUYBs04Y8bH-o.woff2.1 +0 -0
- package/dist/fonts/google/3y976aknfjLm_3lMKjiMgmUUYBs04Y8fH-qVHQ.woff2 +0 -0
- package/dist/fonts/google/3y976aknfjLm_3lMKjiMgmUUYBs04Y8fH-qVHQ.woff2.1 +0 -0
- package/dist/fonts/google/3y976aknfjLm_3lMKjiMgmUUYBs04Y8fH-qVHQ.woff2.2 +0 -0
- package/dist/fonts/google/6aez4K2oVqwIvtE2H68T.woff2 +0 -0
- package/dist/fonts/google/6aez4K2oVqwIvtU2Hw.woff2 +0 -0
- package/dist/fonts/google/6aez4K2oVqwIvtY2H68T.woff2 +0 -0
- package/dist/fonts/google/6aez4K2oVqwIvtg2H68T.woff2 +0 -0
- package/dist/fonts/google/6aez4K2oVqwIvto2H68T.woff2 +0 -0
- package/dist/fonts/google/6aez4K2oVqwIvts2H68T.woff2 +0 -0
- package/dist/fonts/google/7Auup_AqnyWWAxW2Wk3swUz56MS91Eww8SX21nejog.woff2 +0 -0
- package/dist/fonts/google/7Auup_AqnyWWAxW2Wk3swUz56MS91Eww8SX21nijogp5.woff2 +0 -0
- package/dist/fonts/google/7Auup_AqnyWWAxW2Wk3swUz56MS91Eww8SX21nmjogp5.woff2 +0 -0
- package/dist/fonts/google/PN_xRfK9oXHga0XdZ8g_vT0.woff2 +0 -0
- package/dist/fonts/google/PN_xRfK9oXHga0XdZsg_.woff2 +0 -0
- package/dist/fonts/google/PN_xRfK9oXHga0XdaMg_vT0.woff2 +0 -0
- package/dist/fonts/google/TK3tWkYFABsmjsphPho.woff2 +0 -0
- package/dist/fonts/google/TK3tWkYFABsmjspuPho7vA.woff2 +0 -0
- package/dist/fonts/google/TK3tWkYFABsmjspvPho7vA.woff2 +0 -0
- package/dist/fonts/google/dg45_pLmvrkcOkBnKsOzXyGWTBcmg-X6VjTYJwQj.woff2 +0 -0
- package/dist/fonts/google/dg45_pLmvrkcOkBnKsOzXyGWTBcmg-X6VjXYJwQj.woff2 +0 -0
- package/dist/fonts/google/dg45_pLmvrkcOkBnKsOzXyGWTBcmg-X6Vj_YJwQj.woff2 +0 -0
- package/dist/fonts/google/dg45_pLmvrkcOkBnKsOzXyGWTBcmg-X6VjbYJwQj.woff2 +0 -0
- package/dist/fonts/google/dg45_pLmvrkcOkBnKsOzXyGWTBcmg-X6VjvYJw.woff2 +0 -0
- package/dist/fonts/google/fonts-tracklist.txt +48 -0
- package/dist/fonts/google/vEFO2_JTCgwQ5ejvMV0O96D01E8J0tJXHKbBjM4.woff2 +0 -0
- package/dist/fonts/google/vEFO2_JTCgwQ5ejvMV0O96D01E8J0tJXHKbOjM7sfA.woff2 +0 -0
- package/dist/fonts/google/vEFO2_JTCgwQ5ejvMV0O96D01E8J0tJXHKbPjM7sfA.woff2 +0 -0
- package/dist/fonts/google/wEOhEADFm8hSaQTFG18FErVhsC9x-tarUfLtrftV.woff2 +0 -0
- package/dist/fonts/google/wEOhEADFm8hSaQTFG18FErVhsC9x-tarUfXtrftV.woff2 +0 -0
- package/dist/fonts/google/wEOhEADFm8hSaQTFG18FErVhsC9x-tarUfbtrQ.woff2 +0 -0
- package/dist/fonts/google/wEOhEADFm8hSaQTFG18FErVhsC9x-tarUfjtrftV.woff2 +0 -0
- package/dist/fonts/google/wEOhEADFm8hSaQTFG18FErVhsC9x-tarUfntrftV.woff2 +0 -0
- package/dist/fonts/google/wEOhEADFm8hSaQTFG18FErVhsC9x-tarUfrtrftV.woff2 +0 -0
- package/dist/fonts/google/wEOhEADFm8hSaQTFG18FErVhsC9x-tarUfvtrftV.woff2 +0 -0
- package/dist/fonts/google/xn7_YHE41ni1AdIRqAuZuw1Bx9mbZk79FN_B-bnBeA.woff2 +0 -0
- package/dist/fonts/google/xn7_YHE41ni1AdIRqAuZuw1Bx9mbZk79FN_C-bk.woff2 +0 -0
- package/dist/fonts/google/xn7_YHE41ni1AdIRqAuZuw1Bx9mbZk79FN_G-bnBeA.woff2 +0 -0
- package/dist/fonts/google/xn7_YHE41ni1AdIRqAuZuw1Bx9mbZk79FN_M-bnBeA.woff2 +0 -0
- package/dist/fonts/google/xn7_YHE41ni1AdIRqAuZuw1Bx9mbZk79FN_N-bnBeA.woff2 +0 -0
- package/dist/fonts/google/xn7_YHE41ni1AdIRqAuZuw1Bx9mbZk79FN_P-bnBeA.woff2 +0 -0
- package/package.json +60 -0
- package/snippets/alerts.html +281 -0
- package/snippets/badges.html +212 -0
- package/snippets/buttons.html +287 -0
- package/snippets/cards.html +393 -0
- package/snippets/checkbox-lists.html +490 -0
- package/snippets/code.html +225 -0
- package/snippets/command-palette.html +210 -0
- package/snippets/comparison.html +428 -0
- package/snippets/customization.html +142 -0
- package/snippets/forms.html +477 -0
- package/snippets/grid.html +338 -0
- package/snippets/layout.html +598 -0
- package/snippets/lists.html +232 -0
- package/snippets/loaders.html +183 -0
- package/snippets/manifest.json +388 -0
- package/snippets/modal-dialogs.html +411 -0
- package/snippets/modals.html +310 -0
- package/snippets/popconfirm.html +253 -0
- package/snippets/profile.html +264 -0
- package/snippets/tables.html +317 -0
- package/snippets/tabs.html +930 -0
- package/snippets/timeline.html +364 -0
- package/snippets/toasts.html +154 -0
- package/snippets/tooltips.html +411 -0
- package/snippets/typography.html +101 -0
- package/snippets/utilities.html +595 -0
- package/snippets/virtual-scroll.html +322 -0
- package/snippets/web-daterangepicker.html +634 -0
- package/snippets/web-multiselect.html +362 -0
- package/src/scss/.claude/settings.local.json +11 -0
- package/src/scss/_base-css-variables.scss +348 -0
- package/src/scss/_core.scss +99 -0
- package/src/scss/_fonts.scss +67 -0
- package/src/scss/_purecss-grid-responsive.scss +138 -0
- package/src/scss/_purecss-grid.scss +58 -0
- package/src/scss/_variables.scss +14 -0
- package/src/scss/core-components/_alerts.scss +212 -0
- package/src/scss/core-components/_badges.scss +16 -0
- package/src/scss/core-components/_base.scss +124 -0
- package/src/scss/core-components/_buttons.scss +473 -0
- package/src/scss/core-components/_cards.scss +285 -0
- package/src/scss/core-components/_checkbox-lists.scss +289 -0
- package/src/scss/core-components/_code.scss +141 -0
- package/src/scss/core-components/_command-palette.scss +518 -0
- package/src/scss/core-components/_comparison.scss +172 -0
- package/src/scss/core-components/_file-selector.scss +780 -0
- package/src/scss/core-components/_forms.scss +16 -0
- package/src/scss/core-components/_grid.scss +264 -0
- package/src/scss/core-components/_layout.scss +15 -0
- package/src/scss/core-components/_lists.scss +211 -0
- package/src/scss/core-components/_loaders.scss +277 -0
- package/src/scss/core-components/_logic-tree.scss +280 -0
- package/src/scss/core-components/_modals.scss +209 -0
- package/src/scss/core-components/_notifications.scss +253 -0
- package/src/scss/core-components/_pagers.scss +141 -0
- package/src/scss/core-components/_popconfirm.scss +170 -0
- package/src/scss/core-components/_profile.scss +281 -0
- package/src/scss/core-components/_settings-panel.scss +128 -0
- package/src/scss/core-components/_statistics.scss +200 -0
- package/src/scss/core-components/_tables.scss +555 -0
- package/src/scss/core-components/_tabs.scss +438 -0
- package/src/scss/core-components/_timeline.scss +589 -0
- package/src/scss/core-components/_toasts.scss +281 -0
- package/src/scss/core-components/_tooltips.scss +503 -0
- package/src/scss/core-components/_utilities.scss +241 -0
- package/src/scss/core-components/_web-components-theme.scss +294 -0
- package/src/scss/core-components/badges/_badge-base.scss +131 -0
- package/src/scss/core-components/badges/_badge-group.scss +25 -0
- package/src/scss/core-components/badges/_composite-badge-variants.scss +396 -0
- package/src/scss/core-components/badges/_composite-badge.scss +70 -0
- package/src/scss/core-components/badges/_index.scss +10 -0
- package/src/scss/core-components/badges/_labels.scss +155 -0
- package/src/scss/core-components/forms/_checkboxes-radios.scss +205 -0
- package/src/scss/core-components/forms/_form-inputs.scss +100 -0
- package/src/scss/core-components/forms/_form-layout.scss +66 -0
- package/src/scss/core-components/forms/_form-states.scss +89 -0
- package/src/scss/core-components/forms/_index.scss +12 -0
- package/src/scss/core-components/forms/_input-groups.scss +149 -0
- package/src/scss/core-components/forms/_input-wrapper.scss +89 -0
- package/src/scss/core-components/forms/_query-editor.scss +313 -0
- package/src/scss/core-components/layout/_index.scss +11 -0
- package/src/scss/core-components/layout/_layout-container.scss +105 -0
- package/src/scss/core-components/layout/_layout-responsive.scss +100 -0
- package/src/scss/core-components/layout/_navbar-elements.scss +238 -0
- package/src/scss/core-components/layout/_navbar.scss +71 -0
- package/src/scss/core-components/layout/_sidebar-states.scss +228 -0
- package/src/scss/core-components/layout/_sidebar.scss +177 -0
- package/src/scss/main.scss +7 -0
- package/src/scss/themes/_dark-base.scss +207 -0
- package/src/scss/themes/audi-light.scss +311 -0
- package/src/scss/themes/audi.scss +288 -0
- package/src/scss/themes/corporate.scss +203 -0
- package/src/scss/themes/dark-blue.scss +152 -0
- package/src/scss/themes/dark-green.scss +156 -0
- package/src/scss/themes/dark-red.scss +160 -0
- package/src/scss/themes/dark.scss +145 -0
- package/src/scss/themes/express.scss +281 -0
- package/src/scss/themes/minimal.scss +121 -0
- package/src/scss/utilities.scss +481 -0
- package/src/scss/variables/_base.scss +81 -0
- package/src/scss/variables/_colors.scss +148 -0
- package/src/scss/variables/_components.scss +509 -0
- package/src/scss/variables/_index.scss +13 -0
- package/src/scss/variables/_layout.scss +65 -0
- package/src/scss/variables/_spacing.scss +66 -0
- package/src/scss/variables/_system.scss +80 -0
- package/src/scss/variables/_typography.scss +37 -0
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
<!-- ================================
|
|
2
|
+
MODAL DIALOGS (PROGRAMMATIC)
|
|
3
|
+
Pure Admin Visual Framework
|
|
4
|
+
================================ -->
|
|
5
|
+
|
|
6
|
+
<!--
|
|
7
|
+
PROGRAMMATIC MODAL DIALOGS
|
|
8
|
+
|
|
9
|
+
This is a Promise-based JavaScript API for creating modal dialogs programmatically.
|
|
10
|
+
Unlike static modals (see modals.html), these are created on-demand via JavaScript
|
|
11
|
+
and automatically cleaned up after use.
|
|
12
|
+
|
|
13
|
+
Perfect for:
|
|
14
|
+
- Async/await workflows
|
|
15
|
+
- Svelte/React/Vue components
|
|
16
|
+
- Programmatic confirmations, alerts, and prompts
|
|
17
|
+
- No HTML boilerplate needed
|
|
18
|
+
|
|
19
|
+
JAVASCRIPT FILE:
|
|
20
|
+
- src/js/modal-dialogs.js (must be included in your page)
|
|
21
|
+
|
|
22
|
+
AVAILABLE METHODS:
|
|
23
|
+
- PureAdmin.confirm(options) → Promise<boolean>
|
|
24
|
+
- PureAdmin.alert(options) → Promise<void>
|
|
25
|
+
- PureAdmin.prompt(options) → Promise<string | null>
|
|
26
|
+
- PureAdmin.custom(options) → Promise<any>
|
|
27
|
+
-->
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
<!-- ================================
|
|
31
|
+
USAGE EXAMPLES
|
|
32
|
+
================================ -->
|
|
33
|
+
|
|
34
|
+
<!-- 1. CONFIRMATION DIALOG -->
|
|
35
|
+
<script>
|
|
36
|
+
// Basic confirm
|
|
37
|
+
async function deleteItem() {
|
|
38
|
+
const confirmed = await PureAdmin.confirm({
|
|
39
|
+
title: 'Delete Item?',
|
|
40
|
+
message: 'This action cannot be undone.',
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
if (confirmed) {
|
|
44
|
+
// User clicked OK
|
|
45
|
+
console.log('Item deleted');
|
|
46
|
+
} else {
|
|
47
|
+
// User clicked Cancel or Esc
|
|
48
|
+
console.log('Cancelled');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Confirm with custom buttons and variant
|
|
53
|
+
async function dangerConfirm() {
|
|
54
|
+
const result = await PureAdmin.confirm({
|
|
55
|
+
title: 'Delete Account?',
|
|
56
|
+
message: 'This will permanently delete your account and all data.',
|
|
57
|
+
confirmText: 'Delete Forever',
|
|
58
|
+
cancelText: 'Keep Account',
|
|
59
|
+
variant: 'danger',
|
|
60
|
+
confirmVariant: 'danger',
|
|
61
|
+
size: 'md',
|
|
62
|
+
closeOnBackdrop: false // Require explicit button click
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
return result; // true or false
|
|
66
|
+
}
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
<!-- 2. ALERT DIALOG -->
|
|
71
|
+
<script>
|
|
72
|
+
// Basic alert
|
|
73
|
+
async function showSuccess() {
|
|
74
|
+
await PureAdmin.alert({
|
|
75
|
+
title: 'Success!',
|
|
76
|
+
message: 'Your changes have been saved.',
|
|
77
|
+
variant: 'success'
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Code here runs AFTER user clicks OK
|
|
81
|
+
console.log('Alert dismissed');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Warning alert
|
|
85
|
+
async function showWarning() {
|
|
86
|
+
await PureAdmin.alert({
|
|
87
|
+
title: 'Warning',
|
|
88
|
+
message: 'Your session will expire in 5 minutes.',
|
|
89
|
+
okText: 'I Understand',
|
|
90
|
+
variant: 'warning',
|
|
91
|
+
size: 'sm'
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
<!-- 3. PROMPT DIALOG -->
|
|
98
|
+
<script>
|
|
99
|
+
// Basic prompt
|
|
100
|
+
async function askForName() {
|
|
101
|
+
const name = await PureAdmin.prompt({
|
|
102
|
+
title: 'Enter Your Name',
|
|
103
|
+
message: 'Please provide your full name:',
|
|
104
|
+
defaultValue: '',
|
|
105
|
+
placeholder: 'John Doe'
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
if (name !== null) {
|
|
109
|
+
console.log('User entered:', name);
|
|
110
|
+
} else {
|
|
111
|
+
console.log('User cancelled');
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Prompt with validation
|
|
116
|
+
async function askForEmail() {
|
|
117
|
+
const email = await PureAdmin.prompt({
|
|
118
|
+
title: 'Email Address',
|
|
119
|
+
message: 'Enter a valid email address:',
|
|
120
|
+
placeholder: 'user@example.com',
|
|
121
|
+
confirmText: 'Submit',
|
|
122
|
+
cancelText: 'Skip',
|
|
123
|
+
variant: 'primary',
|
|
124
|
+
validator: (value) => {
|
|
125
|
+
// Return true if valid, or error message string if invalid
|
|
126
|
+
if (!value) return 'Email is required';
|
|
127
|
+
if (!value.includes('@')) return 'Invalid email format';
|
|
128
|
+
return true;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
return email; // string or null
|
|
133
|
+
}
|
|
134
|
+
</script>
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
<!-- 4. CUSTOM DIALOG -->
|
|
138
|
+
<script>
|
|
139
|
+
// Advanced custom modal with render function
|
|
140
|
+
async function customDialog() {
|
|
141
|
+
const result = await PureAdmin.custom({
|
|
142
|
+
title: 'Select Options',
|
|
143
|
+
size: 'lg',
|
|
144
|
+
variant: 'primary',
|
|
145
|
+
closeOnBackdrop: true,
|
|
146
|
+
render: (container, close) => {
|
|
147
|
+
// container is the .pa-modal__container element
|
|
148
|
+
// close is a callback function to close the modal with a value
|
|
149
|
+
|
|
150
|
+
// Create body
|
|
151
|
+
const body = document.createElement('div');
|
|
152
|
+
body.className = 'pa-modal__body';
|
|
153
|
+
body.innerHTML = `
|
|
154
|
+
<p>Choose your preferences:</p>
|
|
155
|
+
<div class="pa-form-group">
|
|
156
|
+
<label class="pa-checkbox">
|
|
157
|
+
<input type="checkbox" id="option1"> Enable notifications
|
|
158
|
+
</label>
|
|
159
|
+
</div>
|
|
160
|
+
<div class="pa-form-group">
|
|
161
|
+
<label class="pa-checkbox">
|
|
162
|
+
<input type="checkbox" id="option2"> Auto-save
|
|
163
|
+
</label>
|
|
164
|
+
</div>
|
|
165
|
+
`;
|
|
166
|
+
|
|
167
|
+
// Create footer
|
|
168
|
+
const footer = document.createElement('div');
|
|
169
|
+
footer.className = 'pa-modal__footer';
|
|
170
|
+
footer.innerHTML = `
|
|
171
|
+
<button class="pa-btn pa-btn--secondary" id="cancelBtn">Cancel</button>
|
|
172
|
+
<button class="pa-btn pa-btn--primary" id="saveBtn">Save</button>
|
|
173
|
+
`;
|
|
174
|
+
|
|
175
|
+
container.appendChild(body);
|
|
176
|
+
container.appendChild(footer);
|
|
177
|
+
|
|
178
|
+
// Attach event listeners
|
|
179
|
+
footer.querySelector('#cancelBtn').addEventListener('click', () => {
|
|
180
|
+
close(null); // Close with null value
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
footer.querySelector('#saveBtn').addEventListener('click', () => {
|
|
184
|
+
const option1 = body.querySelector('#option1').checked;
|
|
185
|
+
const option2 = body.querySelector('#option2').checked;
|
|
186
|
+
close({ option1, option2 }); // Close with custom data
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
console.log('User selected:', result);
|
|
192
|
+
// result = { option1: true, option2: false } or null
|
|
193
|
+
}
|
|
194
|
+
</script>
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
<!-- ================================
|
|
198
|
+
OPTIONS REFERENCE
|
|
199
|
+
================================ -->
|
|
200
|
+
|
|
201
|
+
<!--
|
|
202
|
+
CONFIRM OPTIONS:
|
|
203
|
+
{
|
|
204
|
+
title: string // Modal title (default: 'Confirm')
|
|
205
|
+
message: string // Message text (default: 'Are you sure?')
|
|
206
|
+
confirmText: string // OK button text (default: 'OK')
|
|
207
|
+
cancelText: string // Cancel button text (default: 'Cancel')
|
|
208
|
+
variant: string // Modal header color: 'primary', 'success', 'warning', 'danger'
|
|
209
|
+
confirmVariant: string // Confirm button color (default: same as variant)
|
|
210
|
+
size: string // 'sm', 'md', 'lg', 'xl' (default: 'sm')
|
|
211
|
+
position: string // 'center' or 'top' (default: 'center')
|
|
212
|
+
closeOnBackdrop: bool // Allow closing by clicking backdrop (default: true)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
Returns: Promise<boolean> - true if confirmed, false if cancelled
|
|
216
|
+
|
|
217
|
+
ALERT OPTIONS:
|
|
218
|
+
{
|
|
219
|
+
title: string // Modal title (default: 'Alert')
|
|
220
|
+
message: string // Message text (default: '')
|
|
221
|
+
okText: string // Button text (default: 'OK')
|
|
222
|
+
variant: string // 'primary', 'success', 'warning', 'danger'
|
|
223
|
+
size: string // 'sm', 'md', 'lg', 'xl' (default: 'sm')
|
|
224
|
+
position: string // 'center' or 'top' (default: 'center')
|
|
225
|
+
closeOnBackdrop: bool // Allow closing by clicking backdrop (default: true)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
Returns: Promise<void> - resolves when user clicks OK
|
|
229
|
+
|
|
230
|
+
PROMPT OPTIONS:
|
|
231
|
+
{
|
|
232
|
+
title: string // Modal title (default: 'Input')
|
|
233
|
+
message: string // Message text (default: 'Enter value:')
|
|
234
|
+
defaultValue: string // Pre-filled input value (default: '')
|
|
235
|
+
placeholder: string // Input placeholder (default: '')
|
|
236
|
+
confirmText: string // Submit button text (default: 'OK')
|
|
237
|
+
cancelText: string // Cancel button text (default: 'Cancel')
|
|
238
|
+
variant: string // 'primary', 'success', 'warning', 'danger'
|
|
239
|
+
size: string // 'sm', 'md', 'lg', 'xl' (default: 'sm')
|
|
240
|
+
position: string // 'center' or 'top' (default: 'center')
|
|
241
|
+
validator: function // Validation function (optional)
|
|
242
|
+
closeOnBackdrop: bool // ALWAYS false for prompts
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
Validator function signature:
|
|
246
|
+
(value: string) => true | string
|
|
247
|
+
Return true if valid, or error message string if invalid
|
|
248
|
+
|
|
249
|
+
Returns: Promise<string | null> - string if submitted, null if cancelled
|
|
250
|
+
|
|
251
|
+
CUSTOM OPTIONS:
|
|
252
|
+
{
|
|
253
|
+
title: string // Modal title (default: 'Dialog')
|
|
254
|
+
size: string // 'sm', 'md', 'lg', 'xl' (default: 'md')
|
|
255
|
+
variant: string // 'primary', 'success', 'warning', 'danger'
|
|
256
|
+
position: string // 'center' or 'top' (default: 'center')
|
|
257
|
+
closeOnBackdrop: bool // Allow closing by clicking backdrop (default: true)
|
|
258
|
+
render: function // Render function (required)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
Render function signature:
|
|
262
|
+
(container: HTMLElement, close: Function) => void
|
|
263
|
+
container: The .pa-modal__container element to append content to
|
|
264
|
+
close: Function to close modal with a value: close(value)
|
|
265
|
+
|
|
266
|
+
Returns: Promise<any> - whatever value you pass to close()
|
|
267
|
+
-->
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
<!-- ================================
|
|
271
|
+
SEQUENTIAL DIALOGS
|
|
272
|
+
================================ -->
|
|
273
|
+
|
|
274
|
+
<script>
|
|
275
|
+
// Example: Multi-step wizard with dialogs
|
|
276
|
+
async function multiStepWizard() {
|
|
277
|
+
// Step 1: Confirm start
|
|
278
|
+
const start = await PureAdmin.confirm({
|
|
279
|
+
title: 'Start Wizard?',
|
|
280
|
+
message: 'This will guide you through the setup process.',
|
|
281
|
+
confirmText: 'Start',
|
|
282
|
+
variant: 'primary'
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
if (!start) return;
|
|
286
|
+
|
|
287
|
+
// Step 2: Get name
|
|
288
|
+
const name = await PureAdmin.prompt({
|
|
289
|
+
title: 'Step 1: Your Name',
|
|
290
|
+
message: 'Enter your name:',
|
|
291
|
+
validator: (v) => v.trim() ? true : 'Name is required'
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
if (!name) return;
|
|
295
|
+
|
|
296
|
+
// Step 3: Get email
|
|
297
|
+
const email = await PureAdmin.prompt({
|
|
298
|
+
title: 'Step 2: Email',
|
|
299
|
+
message: 'Enter your email:',
|
|
300
|
+
validator: (v) => v.includes('@') ? true : 'Invalid email'
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
if (!email) return;
|
|
304
|
+
|
|
305
|
+
// Step 4: Confirm
|
|
306
|
+
const confirm = await PureAdmin.confirm({
|
|
307
|
+
title: 'Review Information',
|
|
308
|
+
message: `Name: ${name}\nEmail: ${email}\n\nIs this correct?`,
|
|
309
|
+
confirmText: 'Submit',
|
|
310
|
+
variant: 'success'
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
if (confirm) {
|
|
314
|
+
await PureAdmin.alert({
|
|
315
|
+
title: 'Success!',
|
|
316
|
+
message: 'Your information has been saved.',
|
|
317
|
+
variant: 'success'
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
</script>
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
<!-- ================================
|
|
325
|
+
INTEGRATION WITH FORMS
|
|
326
|
+
================================ -->
|
|
327
|
+
|
|
328
|
+
<script>
|
|
329
|
+
// Example: Confirm before form submission
|
|
330
|
+
document.querySelector('#deleteForm').addEventListener('submit', async function(e) {
|
|
331
|
+
e.preventDefault();
|
|
332
|
+
|
|
333
|
+
const confirmed = await PureAdmin.confirm({
|
|
334
|
+
title: 'Delete Item?',
|
|
335
|
+
message: 'This action cannot be undone.',
|
|
336
|
+
variant: 'danger',
|
|
337
|
+
confirmVariant: 'danger',
|
|
338
|
+
confirmText: 'Delete',
|
|
339
|
+
closeOnBackdrop: false
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
if (confirmed) {
|
|
343
|
+
// Submit the form
|
|
344
|
+
this.submit();
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
</script>
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
<!-- ================================
|
|
351
|
+
SVELTE INTEGRATION EXAMPLE
|
|
352
|
+
================================ -->
|
|
353
|
+
|
|
354
|
+
<!--
|
|
355
|
+
<script>
|
|
356
|
+
import { onMount } from 'svelte';
|
|
357
|
+
|
|
358
|
+
// Make sure modal-dialogs.js is loaded globally
|
|
359
|
+
onMount(() => {
|
|
360
|
+
// Now you can use PureAdmin.confirm/alert/prompt anywhere
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
async function handleDelete() {
|
|
364
|
+
const result = await PureAdmin.confirm({
|
|
365
|
+
title: 'Delete Item?',
|
|
366
|
+
message: 'Are you sure?',
|
|
367
|
+
variant: 'danger'
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
if (result) {
|
|
371
|
+
// Delete the item
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
</script>
|
|
375
|
+
|
|
376
|
+
<button on:click={handleDelete}>Delete</button>
|
|
377
|
+
-->
|
|
378
|
+
|
|
379
|
+
|
|
380
|
+
<!-- ================================
|
|
381
|
+
NOTES
|
|
382
|
+
================================ -->
|
|
383
|
+
|
|
384
|
+
<!--
|
|
385
|
+
KEY FEATURES:
|
|
386
|
+
- ✅ Promise-based API (works with async/await)
|
|
387
|
+
- ✅ No HTML boilerplate needed
|
|
388
|
+
- ✅ Automatic cleanup (modal removed from DOM after use)
|
|
389
|
+
- ✅ XSS protection (all text is escaped)
|
|
390
|
+
- ✅ Keyboard navigation (Enter confirms, Esc cancels)
|
|
391
|
+
- ✅ Auto-focus on inputs/buttons
|
|
392
|
+
- ✅ Backdrop click to close (configurable)
|
|
393
|
+
- ✅ Scrollbar compensation (prevents layout shift)
|
|
394
|
+
- ✅ Input validation for prompts
|
|
395
|
+
|
|
396
|
+
DIFFERENCES FROM STATIC MODALS:
|
|
397
|
+
- Static modals require pre-defined HTML in the page
|
|
398
|
+
- Dialog modals are created on-demand via JavaScript
|
|
399
|
+
- Dialog modals are automatically removed after use
|
|
400
|
+
- Dialog modals return Promise for easy async/await usage
|
|
401
|
+
|
|
402
|
+
BROWSER COMPATIBILITY:
|
|
403
|
+
- Requires ES6+ (async/await, Promise, const/let)
|
|
404
|
+
- Modern browsers (Chrome/Firefox/Safari/Edge)
|
|
405
|
+
|
|
406
|
+
ACCESSIBILITY:
|
|
407
|
+
- ARIA attributes (role="dialog", aria-modal, aria-labelledby)
|
|
408
|
+
- Keyboard support (Enter, Esc)
|
|
409
|
+
- Focus management (auto-focus first input/button)
|
|
410
|
+
- Proper modal structure for screen readers
|
|
411
|
+
-->
|