domma-js 0.53.3 → 0.55.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.
@@ -28,8 +28,8 @@ export interface EventAction {
28
28
  log?: string;
29
29
  }
30
30
 
31
- export type EventHandler = (event: Event, $el: DommaCollection) => void;
32
- export type EventActions = EventHandler | EventAction | (EventHandler | EventAction)[];
31
+ export type ConfigEventHandler = (event: Event, $el: DommaCollection) => void;
32
+ export type EventActions = ConfigEventHandler | EventAction | (ConfigEventHandler | EventAction)[];
33
33
 
34
34
  export interface SelectorConfig {
35
35
  /** Component type to initialise */
@@ -30,6 +30,18 @@ export interface ComponentInstance {
30
30
  /** Update component options at runtime */
31
31
  setOptions(newOptions: Record<string, any>): this;
32
32
 
33
+ /**
34
+ * Listen for a component event - the name of an `onX` option without `on`, lower-cased
35
+ * ('change', 'open', 'beforeclose'). The handler gets the same arguments as the option;
36
+ * returning false from a `before...` handler cancels. The same event is dispatched on
37
+ * `element` as `dm:<component>:<event>` with `detail = {instance, args}`.
38
+ */
39
+ on(event: string, handler: (...args: any[]) => any): this;
40
+ /** Listen once */
41
+ once(event: string, handler: (...args: any[]) => any): this;
42
+ /** Stop listening (every handler for the event when none is given) */
43
+ off(event: string, handler?: (...args: any[]) => any): this;
44
+
33
45
  /** Destroy the component and cleanup event listeners */
34
46
  destroy(): void;
35
47
  }
@@ -79,6 +91,14 @@ export interface ModalOptions {
79
91
  animationDuration?: number;
80
92
  /** Show close button */
81
93
  closeButton?: boolean;
94
+ /** Return false to keep the modal closed (also `.on('beforeopen')`, `dm:modal:beforeopen`) */
95
+ onBeforeOpen?: (modal: ModalInstance) => boolean | void;
96
+ /** Return false to keep the modal open (also `.on('beforeclose')`, `dm:modal:beforeclose`) */
97
+ onBeforeClose?: (modal: ModalInstance) => boolean | void;
98
+ /** Modal content (HTML, sanitised like $().html() unless `safe: false`) */
99
+ content?: string;
100
+ /** false: insert `content` as trusted markup */
101
+ safe?: boolean;
82
102
  /** Callback before opening */
83
103
  onOpen?: (modal: ModalInstance) => void;
84
104
  /** Callback after open animation completes */
@@ -622,7 +642,8 @@ export interface Elements {
622
642
  accordion(selector: string | HTMLElement, options?: AccordionOptions): AccordionInstance;
623
643
 
624
644
  /** Create Tooltip(s) - returns array if multiple elements match */
625
- tooltip(selector: string | HTMLElement, options?: TooltipOptions): TooltipInstance | TooltipInstance[];
645
+ /** Sets up every match; returns the first, with `all()` for every instance */
646
+ tooltip(selector: string | HTMLElement, options?: TooltipOptions): TooltipInstance & {all(): TooltipInstance[]};
626
647
 
627
648
  /** Create Badge(s) - returns array if multiple elements match */
628
649
  badge(selector: string | HTMLElement, options?: BadgeOptions): BadgeInstance | BadgeInstance[];
@@ -642,8 +663,8 @@ export interface Elements {
642
663
  /** Toast notification system */
643
664
  toast: ToastStatic;
644
665
 
645
- /** Get component instance for an element */
646
- get(selector: string | HTMLElement): ComponentInstance | undefined;
666
+ /** Get the component on an element - factory-made ones too. `name` picks one when an element hosts several. */
667
+ get(selector: string | HTMLElement, name?: string): ComponentInstance | undefined;
647
668
 
648
669
  /** Destroy a component */
649
670
  destroy(selector: string | HTMLElement): void;
@@ -22,11 +22,11 @@ export * from './flags';
22
22
  export * from './smooth-caret';
23
23
 
24
24
  // Import types for the main Domma object
25
- import {dom, DommaCollection} from './dom';
25
+ import {DommaCollection} from './dom';
26
26
  import {Utils, utils} from './utils';
27
27
  import {Dates, dates, DommaDate} from './dates';
28
28
  import {Model, models, Models} from './models';
29
- import {configEngine, SelectorConfig, SetupConfig} from './config';
29
+ import {SelectorConfig, SetupConfig} from './config';
30
30
  import {Elements, elements} from './elements';
31
31
  import {Tables, tables} from './tables';
32
32
  import {Storage, storage} from './storage';
@@ -55,9 +55,6 @@ export interface DommaStatic {
55
55
  */
56
56
  (callback: () => void): void;
57
57
 
58
- /** DOM manipulation module */
59
- dom: typeof dom;
60
-
61
58
  /** Utility functions (Lodash-compatible) */
62
59
  utils: Utils;
63
60
 
@@ -137,8 +134,12 @@ export interface DommaStatic {
137
134
  /** Domma version string */
138
135
  version: string;
139
136
 
140
- /** No-conflict mode - restore previous $ */
141
- noConflict(): DommaStatic;
137
+ /**
138
+ * Give `$` and `_` back to whatever owned them before Domma loaded (jQuery, Lodash).
139
+ * With `deep`, give back every short alias (`window.Domma` stays).
140
+ * @returns Domma, so `const dm = Domma.noConflict()` keeps a handle
141
+ */
142
+ noConflict(deep?: boolean): DommaStatic;
142
143
  }
143
144
 
144
145
  // ============================================
@@ -190,21 +191,43 @@ declare global {
190
191
  declare const Domma: DommaStatic;
191
192
  export default Domma;
192
193
 
193
- // Named exports for ES modules
194
- export {
195
- Domma,
196
- dom,
197
- utils,
198
- dates,
199
- models,
200
- elements,
201
- tables,
202
- storage,
203
- http,
204
- theme,
205
- icons,
206
- configEngine,
207
- DommaCollection,
208
- DommaDate,
209
- Model
210
- };
194
+ // Named exports for ES modules - exactly what src/index.js exports
195
+ declare const $: DommaStatic;
196
+ declare const _: Utils;
197
+ declare const M: Models;
198
+ declare const D: Dates;
199
+ declare const S: Storage;
200
+ declare const H: Http;
201
+ declare const E: Elements;
202
+ declare const I: Icons;
203
+ declare const T: Tables;
204
+ declare const smoothCaret: SmoothCaret;
205
+ // Not typed yet: auth, forms, router, blueprint helpers, web-component registry
206
+ declare const A: any;
207
+ declare const F: any;
208
+ declare const R: any;
209
+ declare const B: any;
210
+ declare const components: any;
211
+
212
+ export {Domma, $, _, M, D, S, A, F, H, E, I, T, R, B, components, smoothCaret};
213
+ export type {DommaCollection, DommaDate, Model};
214
+
215
+ /** Options read from `window.DommaOptions` when Domma loads - set it before the script tag. */
216
+ export interface DommaLoadOptions {
217
+ /** true (default): every alias; 'safe': only aliases nobody else owns; false: window.Domma only */
218
+ globals?: boolean | 'safe';
219
+ /** false: never add the `dm-cloaked` class */
220
+ cloak?: boolean;
221
+ /** false: don't initialise the theme engine automatically */
222
+ theme?: boolean;
223
+ /** false: no console warning when DOMPurify is missing */
224
+ purifyWarning?: boolean;
225
+ /** false: no deprecation warnings */
226
+ deprecationWarnings?: boolean;
227
+ }
228
+
229
+ declare global {
230
+ interface Window {
231
+ DommaOptions?: DommaLoadOptions;
232
+ }
233
+ }
@@ -23,7 +23,8 @@ export interface ThemeChangeEvent {
23
23
  }
24
24
 
25
25
  export type ThemeChangeCallback = (event: ThemeChangeEvent) => void;
26
- export type UnsubscribeFn = () => void;
26
+ import type {UnsubscribeFn} from './models';
27
+ export type {UnsubscribeFn};
27
28
 
28
29
  export interface ThemeOptions {
29
30
  /** Initial theme mode */
package/package.json CHANGED
@@ -1,10 +1,34 @@
1
1
  {
2
2
  "name": "domma-js",
3
- "version": "0.53.3",
3
+ "version": "0.55.0",
4
4
  "description": "Dynamic Object Manipulation & Modeling API - A complete front-end toolkit.",
5
5
  "main": "public/dist/domma.min.js",
6
6
  "module": "public/dist/domma.esm.js",
7
7
  "types": "assets/types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./assets/types/index.d.ts",
11
+ "import": "./public/dist/domma.esm.js",
12
+ "default": "./public/dist/domma.esm.js"
13
+ },
14
+ "./css": "./public/dist/domma.css",
15
+ "./elements.css": "./public/dist/elements.css",
16
+ "./grid.css": "./public/dist/grid.css",
17
+ "./syntax.css": "./public/dist/syntax.css",
18
+ "./syntax": "./public/dist/domma-syntax.min.js",
19
+ "./flags": {
20
+ "import": "./public/dist/domma-flags.esm.js",
21
+ "default": "./public/dist/domma-flags.min.js"
22
+ },
23
+ "./themes/*": "./public/dist/themes/*",
24
+ "./bundles/*": "./public/dist/bundles/*",
25
+ "./types": "./assets/types/index.d.ts",
26
+ "./package.json": "./package.json",
27
+ "./public/*": "./public/*",
28
+ "./assets/*": "./assets/*",
29
+ "./templates/*": "./templates/*",
30
+ "./bin/*": "./bin/*"
31
+ },
8
32
  "bin": {
9
33
  "domma": "./bin/domma-cli.js"
10
34
  },
@@ -15,15 +39,20 @@
15
39
  "templates/page-template/",
16
40
  "templates/view-template/",
17
41
  "public/dist/domma.min.js",
42
+ "public/dist/domma.min.js.map",
18
43
  "public/dist/domma.esm.js",
44
+ "public/dist/domma.esm.js.map",
19
45
  "public/dist/domma.css",
20
46
  "public/dist/bundles/",
21
47
  "public/dist/elements.css",
22
48
  "public/dist/grid.css",
23
49
  "public/dist/syntax.css",
24
50
  "public/dist/domma-syntax.min.js",
51
+ "public/dist/domma-syntax.min.js.map",
25
52
  "public/dist/domma-flags.min.js",
53
+ "public/dist/domma-flags.min.js.map",
26
54
  "public/dist/domma-flags.esm.js",
55
+ "public/dist/domma-flags.esm.js.map",
27
56
  "public/dist/themes/",
28
57
  "assets/types/",
29
58
  "LICENSE",
@@ -35,7 +64,6 @@
35
64
  },
36
65
  "type": "module",
37
66
  "scripts": {
38
- "postinstall": "node bin/postinstall.js",
39
67
  "start": "node bin/domma-cli.js serve",
40
68
  "serve": "node bin/domma-cli.js serve",
41
69
  "serve:3096": "node bin/domma-cli.js serve --port 3096",
@@ -95,10 +123,7 @@
95
123
  "live-server": "^1.2.0",
96
124
  "puppeteer": "^24.34.0",
97
125
  "rollup": "^4.28.0",
98
- "rollup-plugin-obfuscator": "^1.1.0",
99
126
  "vitest": "^4.0.16"
100
127
  },
101
- "dependencies": {
102
- "@fastify/cors": "^11.2.0"
103
- }
128
+ "dependencies": {}
104
129
  }