@keenmate/pure-admin-core 2.4.0 → 2.5.0

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.
Files changed (44) hide show
  1. package/README.md +11 -6
  2. package/dist/css/main.css +47 -130
  3. package/package.json +1 -1
  4. package/snippets/AUDIT.md +94 -0
  5. package/snippets/alerts.html +264 -89
  6. package/snippets/badges.html +193 -61
  7. package/snippets/buttons.html +178 -0
  8. package/snippets/callouts.html +210 -129
  9. package/snippets/cards.html +383 -200
  10. package/snippets/checkbox-lists.html +199 -65
  11. package/snippets/code.html +55 -11
  12. package/snippets/command-palette.html +401 -111
  13. package/snippets/comparison.html +144 -93
  14. package/snippets/customization.html +311 -104
  15. package/snippets/data-display.html +584 -0
  16. package/snippets/detail-panel.html +470 -138
  17. package/snippets/filter-card.html +246 -0
  18. package/snippets/forms.html +408 -308
  19. package/snippets/grid.html +253 -141
  20. package/snippets/layout.html +379 -480
  21. package/snippets/lists.html +144 -47
  22. package/snippets/loaders.html +64 -39
  23. package/snippets/manifest.json +330 -280
  24. package/snippets/modal-dialogs.html +137 -64
  25. package/snippets/modals.html +221 -151
  26. package/snippets/notifications.html +285 -0
  27. package/snippets/popconfirm.html +213 -19
  28. package/snippets/profile.html +290 -330
  29. package/snippets/statistics.html +247 -0
  30. package/snippets/tables.html +359 -150
  31. package/snippets/tabs.html +129 -45
  32. package/snippets/timeline.html +123 -56
  33. package/snippets/toasts.html +179 -31
  34. package/snippets/tooltips.html +199 -81
  35. package/snippets/typography.html +183 -58
  36. package/snippets/utilities.html +511 -415
  37. package/snippets/virtual-scroll.html +201 -75
  38. package/snippets/web-daterangepicker.html +369 -189
  39. package/snippets/web-multiselect.html +360 -124
  40. package/src/scss/core-components/_alerts.scss +51 -12
  41. package/src/scss/core-components/_pagers.scss +1 -1
  42. package/src/scss/core-components/_popconfirm.scss +35 -13
  43. package/src/scss/core-components/_tables.scss +2 -134
  44. package/src/scss/variables/_components.scss +17 -2
@@ -17,13 +17,16 @@ Perfect for:
17
17
  - No HTML boilerplate needed
18
18
 
19
19
  JAVASCRIPT FILE:
20
- - src/js/modal-dialogs.js (must be included in your page)
20
+ - src/js/modal-dialogs.js attaches to window.PureAdmin on load.
21
+ - Include it once in your page shell before calling PureAdmin.*:
22
+
23
+ <script src="/src/js/modal-dialogs.js"></script>
21
24
 
22
25
  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>
26
+ - PureAdmin.confirm(options) → Promise<boolean> (true on confirm, false on cancel)
27
+ - PureAdmin.alert(options) → Promise<void> (resolves when dismissed)
28
+ - PureAdmin.prompt(options) → Promise<string | null> (string on submit, null on cancel)
29
+ - PureAdmin.custom(options) → Promise<any> (whatever you pass to close())
27
30
  -->
28
31
 
29
32
 
@@ -199,33 +202,43 @@ async function customDialog() {
199
202
  ================================ -->
200
203
 
201
204
  <!--
205
+ Shared enum-like options (same across all four methods):
206
+ variant → 'primary' | 'success' | 'warning' | 'danger'
207
+ Default: 'primary'. Maps directly to pa-modal--{variant}
208
+ on the root; see modals.html for the visual result.
209
+ size → 'sm' | 'md' | 'lg' | 'xl' | 'xxl' | 'fw'
210
+ The value is string-interpolated into pa-modal__container--
211
+ {size}, so any size class defined in _modals.scss works.
212
+ Default: 'sm' for confirm/alert/prompt, 'md' for custom.
213
+ position → 'center' | 'top'
214
+ Default: 'center'. 'top' adds pa-modal--top (5vh offset).
215
+
216
+
202
217
  CONFIRM OPTIONS:
203
218
  {
204
219
  title: string // Modal title (default: 'Confirm')
205
220
  message: string // Message text (default: 'Are you sure?')
206
221
  confirmText: string // OK button text (default: 'OK')
207
222
  cancelText: string // Cancel button text (default: 'Cancel')
208
- variant: string // Modal header color: 'primary', 'success', 'warning', 'danger'
223
+ variant: string // (default: 'primary')
209
224
  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')
225
+ size: string // (default: 'sm')
226
+ position: string // (default: 'center')
212
227
  closeOnBackdrop: bool // Allow closing by clicking backdrop (default: true)
213
228
  }
214
-
215
- Returns: Promise<boolean> - true if confirmed, false if cancelled
229
+ Returns: Promise<boolean> — true on confirm, false on cancel/backdrop/Esc.
216
230
 
217
231
  ALERT OPTIONS:
218
232
  {
219
233
  title: string // Modal title (default: 'Alert')
220
234
  message: string // Message text (default: '')
221
235
  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)
236
+ variant: string // (default: 'primary')
237
+ size: string // (default: 'sm')
238
+ position: string // (default: 'center')
239
+ closeOnBackdrop: bool // (default: true)
226
240
  }
227
-
228
- Returns: Promise<void> - resolves when user clicks OK
241
+ Returns: Promise<void> — resolves when the user dismisses the dialog.
229
242
 
230
243
  PROMPT OPTIONS:
231
244
  {
@@ -235,35 +248,32 @@ PROMPT OPTIONS:
235
248
  placeholder: string // Input placeholder (default: '')
236
249
  confirmText: string // Submit button text (default: 'OK')
237
250
  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
251
+ variant: string // (default: 'primary')
252
+ size: string // (default: 'sm')
253
+ position: string // (default: 'center')
254
+ validator: function // (value: string) => true | errorMessage
255
+ closeOnBackdrop: bool // (default: true same as the other methods;
256
+ // if the user clicks backdrop it resolves null
257
+ // just like Cancel)
243
258
  }
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
259
+ Returns: Promise<string | null> — string on submit, null on cancel.
250
260
 
251
261
  CUSTOM OPTIONS:
252
262
  {
253
263
  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)
264
+ size: string // (default: 'md' note: different from the
265
+ // other methods, which default to 'sm')
266
+ variant: string // (default: 'primary')
267
+ position: string // (default: 'center')
268
+ closeOnBackdrop: bool // (default: true)
269
+ render: function // REQUIRED — (container, close) => void
270
+ // container: the .pa-modal__container element.
271
+ // The JS pre-renders __header; append
272
+ // __body and __footer yourself.
273
+ // close(value): resolve the promise with `value`
274
+ // and tear the modal down.
259
275
  }
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()
276
+ Returns: Promise<any> — whatever value you pass to close().
267
277
  -->
268
278
 
269
279
 
@@ -378,34 +388,97 @@ document.querySelector('#deleteForm').addEventListener('submit', async function(
378
388
 
379
389
 
380
390
  <!-- ================================
381
- NOTES
391
+ COMPONENT REFERENCE
382
392
  ================================ -->
383
393
 
384
394
  <!--
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)
395
+ MODULE CONTRACT:
396
+ - Loaded via <script src="/src/js/modal-dialogs.js"></script>.
397
+ - Attaches onto window.PureAdmin. If another script already set
398
+ window.PureAdmin, the file extends it non-destructively.
399
+ - Each method appends a fresh .pa-modal element to <body>, runs the
400
+ interaction, resolves the returned Promise, then removes the
401
+ element from the DOM.
402
+ - The DOM it produces is the same as the markup in modals.html — the
403
+ same pa-modal / pa-modal__backdrop / pa-modal__container / __header /
404
+ __body / __footer shell so any custom styles that target those
405
+ classes apply here too.
406
+
407
+ KEYBOARD / BEHAVIOUR BASELINES (built in, not configurable):
408
+ - Enter confirm / submit (where applicable)
409
+ - Esc cancel (resolves false / null / Promise)
410
+ - Backdrop click close (honours closeOnBackdrop; always dismisses
411
+ with the same value as Esc)
412
+ - Focus auto-focused on the primary button or input
413
+ after open
414
+ - Scrollbar gutter body gets padding-right compensation so the
415
+ layout doesn't shift when the scrollbar hides
416
+
417
+ SECURITY:
418
+ - title / message / button text / placeholder / defaultValue are all
419
+ escaped through textContent → innerHTML before being inserted.
420
+ - Anything you inject via the custom() render(container, close)
421
+ callback is YOUR responsibility — build it from DOM nodes or escape
422
+ it yourself.
405
423
 
406
424
  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
425
+ - role="dialog", aria-modal="true", aria-labelledby pointing at the
426
+ title. Trap-focus and focus-return-on-close are handled by the JS.
427
+
428
+ VS STATIC MODALS (modals.html):
429
+ - modals.html: markup is in the page; JS toggles --show.
430
+ - modal-dialogs.html: JS creates the markup per call; no page shell.
431
+ - Prefer modal-dialogs for confirm/alert/prompt/custom flows where
432
+ you'd otherwise juggle pre-built HTML and ad-hoc event wiring.
433
+ Prefer static modals when the dialog has rich, persistent content
434
+ (long forms, tab panels) that benefits from SSR or living in the
435
+ markup.
436
+
437
+ BROWSER SUPPORT:
438
+ - ES2017 (async/await), Promise, const/let, template literals.
439
+ Chrome / Firefox / Safari / Edge — evergreen only.
440
+
441
+ STRUCTURE PATTERNS:
442
+
443
+ Confirm:
444
+ const ok = await PureAdmin.confirm({
445
+ title: 'Delete item?',
446
+ message: 'Cannot be undone.',
447
+ variant: 'danger', confirmVariant: 'danger',
448
+ confirmText: 'Delete', cancelText: 'Keep',
449
+ closeOnBackdrop: false
450
+ });
451
+ if (!ok) return;
452
+
453
+ Alert:
454
+ await PureAdmin.alert({ title: 'Saved', variant: 'success' });
455
+
456
+ Prompt with validation:
457
+ const email = await PureAdmin.prompt({
458
+ title: 'Email', placeholder: 'you@example.com',
459
+ validator: (v) => v.includes('@') || 'Must be a valid email'
460
+ });
461
+ if (email === null) return;
462
+
463
+ Custom (promise resolves with whatever close() is called with):
464
+ const result = await PureAdmin.custom({
465
+ title: 'Preferences', size: 'lg',
466
+ render: (container, close) => {
467
+ const body = document.createElement('div');
468
+ body.className = 'pa-modal__body';
469
+ body.innerHTML = '<p>Custom content here.</p>';
470
+
471
+ const footer = document.createElement('div');
472
+ footer.className = 'pa-modal__footer';
473
+ footer.innerHTML = `
474
+ <button class="pa-btn pa-btn--secondary" data-cancel>Cancel</button>
475
+ <button class="pa-btn pa-btn--primary" data-save>Save</button>
476
+ `;
477
+
478
+ container.append(body, footer);
479
+ footer.querySelector('[data-cancel]').onclick = () => close(null);
480
+ footer.querySelector('[data-save]').onclick = () => close({ ok: true });
481
+ }
482
+ });
411
483
  -->
484
+