web-mojo 2.2.27 → 2.2.28
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/admin.cjs.js +1 -1
- package/dist/admin.cjs.js.map +1 -1
- package/dist/admin.es.js +13 -802
- package/dist/admin.es.js.map +1 -1
- package/dist/auth.cjs.js +1 -1
- package/dist/auth.es.js +1 -1
- package/dist/charts.cjs.js +1 -1
- package/dist/charts.es.js +4 -4
- package/dist/chunks/{ChatView-DK692WUV.js → ChatView-ChGpB5fY.js} +2 -2
- package/dist/chunks/{ChatView-DK692WUV.js.map → ChatView-ChGpB5fY.js.map} +1 -1
- package/dist/chunks/{ChatView-WQHC44om.js → ChatView-wMhIMZ01.js} +7 -7
- package/dist/chunks/{ChatView-WQHC44om.js.map → ChatView-wMhIMZ01.js.map} +1 -1
- package/dist/chunks/{Collection-DFPQ8X0o.js → Collection-9DhgHESv.js} +2 -2
- package/dist/chunks/{Collection-DFPQ8X0o.js.map → Collection-9DhgHESv.js.map} +1 -1
- package/dist/chunks/{ContextMenu-BEFu3lOK.js → ContextMenu-fsEv-iq5.js} +3 -3
- package/dist/chunks/{ContextMenu-BEFu3lOK.js.map → ContextMenu-fsEv-iq5.js.map} +1 -1
- package/dist/chunks/{DataView-BC82eli9.js → DataView-aFvKzCsO.js} +2 -2
- package/dist/chunks/{DataView-BC82eli9.js.map → DataView-aFvKzCsO.js.map} +1 -1
- package/dist/chunks/{Dialog-C2P6rKyT.js → Dialog-2U9faiAH.js} +6 -1370
- package/dist/chunks/Dialog-2U9faiAH.js.map +1 -0
- package/dist/chunks/Dialog-t8WYyPj8.js +2 -0
- package/dist/chunks/Dialog-t8WYyPj8.js.map +1 -0
- package/dist/chunks/FormPlugins-CEjco_Hb.js +2 -0
- package/dist/chunks/FormPlugins-CEjco_Hb.js.map +1 -0
- package/dist/chunks/FormPlugins-DY6e88YT.js +124 -0
- package/dist/chunks/FormPlugins-DY6e88YT.js.map +1 -0
- package/dist/chunks/{FormView-DPqIYixn.js → FormView-D6TdblYe.js} +3 -122
- package/dist/chunks/FormView-D6TdblYe.js.map +1 -0
- package/dist/chunks/FormView-DokttDQL.js +3 -0
- package/dist/chunks/FormView-DokttDQL.js.map +1 -0
- package/dist/chunks/{ListView-Db3Qhvpx.js → ListView-Whl0135W.js} +5 -5
- package/dist/chunks/{ListView-Db3Qhvpx.js.map → ListView-Whl0135W.js.map} +1 -1
- package/dist/chunks/MetricsCountryMapView-BNpojbUy.js +1054 -0
- package/dist/chunks/MetricsCountryMapView-BNpojbUy.js.map +1 -0
- package/dist/chunks/MetricsCountryMapView-D1bXRxjZ.js +2 -0
- package/dist/chunks/MetricsCountryMapView-D1bXRxjZ.js.map +1 -0
- package/dist/chunks/MetricsMiniChartWidget-BaQjSl7x.js +2 -0
- package/dist/chunks/{MetricsMiniChartWidget-CQdjokTH.js.map → MetricsMiniChartWidget-BaQjSl7x.js.map} +1 -1
- package/dist/chunks/{MetricsMiniChartWidget-BkyY9Z4b.js → MetricsMiniChartWidget-C976DEgD.js} +4 -4
- package/dist/chunks/{MetricsMiniChartWidget-BkyY9Z4b.js.map → MetricsMiniChartWidget-C976DEgD.js.map} +1 -1
- package/dist/chunks/{PDFViewer-DvAQE5qi.js → PDFViewer-Bx7pn5kV.js} +2 -2
- package/dist/chunks/{PDFViewer-DvAQE5qi.js.map → PDFViewer-Bx7pn5kV.js.map} +1 -1
- package/dist/chunks/{PDFViewer-DQaqFVAJ.js → PDFViewer-DQwOZokX.js} +3 -3
- package/dist/chunks/{PDFViewer-DQaqFVAJ.js.map → PDFViewer-DQwOZokX.js.map} +1 -1
- package/dist/chunks/{Rest-Bqy5Cbt6.js → Rest-DnVeH4wg.js} +5 -5
- package/dist/chunks/{Rest-Bqy5Cbt6.js.map → Rest-DnVeH4wg.js.map} +1 -1
- package/dist/chunks/TokenManager-Bwdnkh5h.js +2 -0
- package/dist/chunks/{TokenManager-DuTYWpFy.js.map → TokenManager-Bwdnkh5h.js.map} +1 -1
- package/dist/chunks/{TokenManager-B_Su1An2.js → TokenManager-EiNkojsp.js} +5 -5
- package/dist/chunks/{TokenManager-B_Su1An2.js.map → TokenManager-EiNkojsp.js.map} +1 -1
- package/dist/chunks/WebApp-D1ob7GxI.js +2 -0
- package/dist/chunks/WebApp-D1ob7GxI.js.map +1 -0
- package/dist/chunks/WebApp-DEo7MILL.js +1364 -0
- package/dist/chunks/WebApp-DEo7MILL.js.map +1 -0
- package/dist/chunks/{WebSocketClient-Dz0AiiM-.js → WebSocketClient-D6kP3imj.js} +2 -2
- package/dist/chunks/{WebSocketClient-Dz0AiiM-.js.map → WebSocketClient-D6kP3imj.js.map} +1 -1
- package/dist/chunks/{version-CLnDCq_b.js → version-CbWgDs2g.js} +4 -4
- package/dist/chunks/{version-CLnDCq_b.js.map → version-CbWgDs2g.js.map} +1 -1
- package/dist/chunks/{version-BqrCmxqg.js → version-DGV8FEbm.js} +2 -2
- package/dist/chunks/{version-BqrCmxqg.js.map → version-DGV8FEbm.js.map} +1 -1
- package/dist/css/web-mojo.css +1 -1
- package/dist/docit.cjs.js +1 -1
- package/dist/docit.es.js +6 -6
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +28 -27
- package/dist/index.es.js.map +1 -1
- package/dist/lightbox.cjs.js +1 -1
- package/dist/lightbox.cjs.js.map +1 -1
- package/dist/lightbox.es.js +5 -5
- package/dist/map.cjs.js +1 -1
- package/dist/map.cjs.js.map +1 -1
- package/dist/map.es.js +995 -229
- package/dist/map.es.js.map +1 -1
- package/dist/timeline.es.js +4 -4
- package/package.json +1 -1
- package/dist/chunks/Dialog-C2P6rKyT.js.map +0 -1
- package/dist/chunks/Dialog-CA4DXjJ5.js +0 -2
- package/dist/chunks/Dialog-CA4DXjJ5.js.map +0 -1
- package/dist/chunks/FormView-BVWavB_q.js +0 -3
- package/dist/chunks/FormView-BVWavB_q.js.map +0 -1
- package/dist/chunks/FormView-DPqIYixn.js.map +0 -1
- package/dist/chunks/MetricsMiniChartWidget-CQdjokTH.js +0 -2
- package/dist/chunks/TokenManager-DuTYWpFy.js +0 -2
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
class FormPlugins {
|
|
2
|
+
// Registered plugins
|
|
3
|
+
static _plugins = [];
|
|
4
|
+
// Map of field type => { renderer: Function, pluginId: string }
|
|
5
|
+
static _renderers = /* @__PURE__ */ new Map();
|
|
6
|
+
/**
|
|
7
|
+
* Register a plugin. If a plugin with the same id exists, it's replaced.
|
|
8
|
+
* @param {object} plugin - Plugin definition (see header)
|
|
9
|
+
* @returns {Function} unregister function
|
|
10
|
+
*/
|
|
11
|
+
static register(plugin) {
|
|
12
|
+
if (!plugin || typeof plugin !== "object") {
|
|
13
|
+
console.warn("[FormPlugins] register called with invalid plugin:", plugin);
|
|
14
|
+
return () => {
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
if (!plugin.id || typeof plugin.id !== "string") {
|
|
18
|
+
console.warn('[FormPlugins] plugin must have a unique string "id"', plugin);
|
|
19
|
+
return () => {
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
this.unregister(plugin.id);
|
|
23
|
+
if (plugin.fieldTypes && typeof plugin.fieldTypes === "object") {
|
|
24
|
+
Object.entries(plugin.fieldTypes).forEach(([type, renderer]) => {
|
|
25
|
+
if (typeof renderer === "function") {
|
|
26
|
+
this._renderers.set(type, { renderer, pluginId: plugin.id });
|
|
27
|
+
} else {
|
|
28
|
+
console.warn(`[FormPlugins] renderer for type "${type}" is not a function`);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
this._plugins.push(plugin);
|
|
33
|
+
return () => this.unregister(plugin.id);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Unregister a plugin by id. Removes its field renderers as well.
|
|
37
|
+
* @param {string} id - Plugin id
|
|
38
|
+
*/
|
|
39
|
+
static unregister(id) {
|
|
40
|
+
if (!id) return;
|
|
41
|
+
this._plugins = this._plugins.filter((p) => p.id !== id);
|
|
42
|
+
for (const [type, meta] of this._renderers.entries()) {
|
|
43
|
+
if (meta?.pluginId === id) {
|
|
44
|
+
this._renderers.delete(type);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get a custom field renderer by type (if registered).
|
|
50
|
+
* @param {string} type - Field type
|
|
51
|
+
* @returns {(builder: any, fieldConfig: object) => string | null}
|
|
52
|
+
*/
|
|
53
|
+
static getRenderer(type) {
|
|
54
|
+
const meta = this._renderers.get(type);
|
|
55
|
+
return meta?.renderer || null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns true if a renderer exists for a field type
|
|
59
|
+
*/
|
|
60
|
+
static hasRenderer(type) {
|
|
61
|
+
return this._renderers.has(type);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get a shallow copy of registered plugins (read-only use).
|
|
65
|
+
*/
|
|
66
|
+
static getPlugins() {
|
|
67
|
+
return [...this._plugins];
|
|
68
|
+
}
|
|
69
|
+
// -----------------------------
|
|
70
|
+
// Safe dispatch to plugin hooks
|
|
71
|
+
// -----------------------------
|
|
72
|
+
static _invoke(plugin, hook, ...args) {
|
|
73
|
+
const fn = plugin?.[hook];
|
|
74
|
+
if (typeof fn !== "function") return;
|
|
75
|
+
try {
|
|
76
|
+
return fn.apply(plugin, args);
|
|
77
|
+
} catch (err) {
|
|
78
|
+
console.error(`[FormPlugins] ${hook} error from plugin "${plugin.id}":`, err);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Called by FormBuilder (e.g., in ctor or initializeTemplates)
|
|
83
|
+
* @param {any} builder
|
|
84
|
+
*/
|
|
85
|
+
static onFormBuilderInit(builder) {
|
|
86
|
+
this._plugins.forEach((p) => this._invoke(p, "onFormBuilderInit", builder));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Called by FormView constructor or early init
|
|
90
|
+
* @param {any} formView
|
|
91
|
+
*/
|
|
92
|
+
static onFormViewInit(formView) {
|
|
93
|
+
this._plugins.forEach((p) => this._invoke(p, "onFormViewInit", formView));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Called by FormView.onAfterRender
|
|
97
|
+
* @param {any} formView
|
|
98
|
+
*/
|
|
99
|
+
static onFormViewAfterRender(formView) {
|
|
100
|
+
this._plugins.forEach((p) => this._invoke(p, "onAfterRender", formView));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Called when a specific field element is initialized (after DOM exists)
|
|
104
|
+
* @param {any} formView
|
|
105
|
+
* @param {HTMLElement} fieldEl
|
|
106
|
+
* @param {object} fieldConfig
|
|
107
|
+
*/
|
|
108
|
+
static onFieldInit(formView, fieldEl, fieldConfig) {
|
|
109
|
+
this._plugins.forEach((p) => this._invoke(p, "onFieldInit", formView, fieldEl, fieldConfig));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Called when a field value changes (normalized point)
|
|
113
|
+
* @param {any} formView
|
|
114
|
+
* @param {string} fieldName
|
|
115
|
+
* @param {any} value
|
|
116
|
+
*/
|
|
117
|
+
static onFieldChange(formView, fieldName, value) {
|
|
118
|
+
this._plugins.forEach((p) => this._invoke(p, "onFieldChange", formView, fieldName, value));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export {
|
|
122
|
+
FormPlugins as F
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=FormPlugins-DY6e88YT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FormPlugins-DY6e88YT.js","sources":["../../src/core/forms/FormPlugins.js"],"sourcesContent":["/**\n * FormPlugins - Lightweight, pluggable registry for FormView/FormBuilder extensions\n *\n * Goals:\n * - Zero hard dependency on any single extension; core remains stable\n * - Extensions opt-in by calling FormPlugins.register(plugin)\n * - If no plugin is loaded, nothing changes\n *\n * A plugin is a plain object:\n * {\n * id: 'location', // required, unique\n * // Optional: custom field renderers by type\n * fieldTypes: {\n * 'address': (builder, fieldConfig) => stringHTML\n * },\n * // Optional lifecycle hooks\n * onFormBuilderInit(builder) {},\n * onFormViewInit(formView) {},\n * onAfterRender(formView) {},\n * onFieldInit(formView, fieldEl, fieldConfig) {},\n * onFieldChange(formView, fieldName, value) {}\n * }\n *\n * Usage (in an extension):\n * import { FormPlugins } from '@core/forms/FormPlugins.js';\n * const unregister = FormPlugins.register(myPlugin);\n * // later (optional)\n * unregister();\n */\n\nexport class FormPlugins {\n // Registered plugins\n static _plugins = [];\n // Map of field type => { renderer: Function, pluginId: string }\n static _renderers = new Map();\n\n /**\n * Register a plugin. If a plugin with the same id exists, it's replaced.\n * @param {object} plugin - Plugin definition (see header)\n * @returns {Function} unregister function\n */\n static register(plugin) {\n if (!plugin || typeof plugin !== 'object') {\n console.warn('[FormPlugins] register called with invalid plugin:', plugin);\n return () => {};\n }\n if (!plugin.id || typeof plugin.id !== 'string') {\n console.warn('[FormPlugins] plugin must have a unique string \"id\"', plugin);\n return () => {};\n }\n\n // Remove any previous plugin with same id\n this.unregister(plugin.id);\n\n // Register field renderers (if any)\n if (plugin.fieldTypes && typeof plugin.fieldTypes === 'object') {\n Object.entries(plugin.fieldTypes).forEach(([type, renderer]) => {\n if (typeof renderer === 'function') {\n this._renderers.set(type, { renderer, pluginId: plugin.id });\n } else {\n console.warn(`[FormPlugins] renderer for type \"${type}\" is not a function`);\n }\n });\n }\n\n // Store plugin\n this._plugins.push(plugin);\n\n // Return disposer\n return () => this.unregister(plugin.id);\n }\n\n /**\n * Unregister a plugin by id. Removes its field renderers as well.\n * @param {string} id - Plugin id\n */\n static unregister(id) {\n if (!id) return;\n\n // Remove from plugin list\n this._plugins = this._plugins.filter(p => p.id !== id);\n\n // Remove its renderers\n for (const [type, meta] of this._renderers.entries()) {\n if (meta?.pluginId === id) {\n this._renderers.delete(type);\n }\n }\n }\n\n /**\n * Get a custom field renderer by type (if registered).\n * @param {string} type - Field type\n * @returns {(builder: any, fieldConfig: object) => string | null}\n */\n static getRenderer(type) {\n const meta = this._renderers.get(type);\n return meta?.renderer || null;\n }\n\n /**\n * Returns true if a renderer exists for a field type\n */\n static hasRenderer(type) {\n return this._renderers.has(type);\n }\n\n /**\n * Get a shallow copy of registered plugins (read-only use).\n */\n static getPlugins() {\n return [...this._plugins];\n }\n\n // -----------------------------\n // Safe dispatch to plugin hooks\n // -----------------------------\n\n static _invoke(plugin, hook, ...args) {\n const fn = plugin?.[hook];\n if (typeof fn !== 'function') return;\n try {\n return fn.apply(plugin, args);\n } catch (err) {\n console.error(`[FormPlugins] ${hook} error from plugin \"${plugin.id}\":`, err);\n }\n }\n\n /**\n * Called by FormBuilder (e.g., in ctor or initializeTemplates)\n * @param {any} builder\n */\n static onFormBuilderInit(builder) {\n this._plugins.forEach(p => this._invoke(p, 'onFormBuilderInit', builder));\n }\n\n /**\n * Called by FormView constructor or early init\n * @param {any} formView\n */\n static onFormViewInit(formView) {\n this._plugins.forEach(p => this._invoke(p, 'onFormViewInit', formView));\n }\n\n /**\n * Called by FormView.onAfterRender\n * @param {any} formView\n */\n static onFormViewAfterRender(formView) {\n this._plugins.forEach(p => this._invoke(p, 'onAfterRender', formView));\n }\n\n /**\n * Called when a specific field element is initialized (after DOM exists)\n * @param {any} formView\n * @param {HTMLElement} fieldEl\n * @param {object} fieldConfig\n */\n static onFieldInit(formView, fieldEl, fieldConfig) {\n this._plugins.forEach(p => this._invoke(p, 'onFieldInit', formView, fieldEl, fieldConfig));\n }\n\n /**\n * Called when a field value changes (normalized point)\n * @param {any} formView\n * @param {string} fieldName\n * @param {any} value\n */\n static onFieldChange(formView, fieldName, value) {\n this._plugins.forEach(p => this._invoke(p, 'onFieldChange', formView, fieldName, value));\n }\n}\n\nexport default FormPlugins;"],"names":[],"mappings":"AA8BO,MAAM,YAAY;AAAA;AAAA,EAEvB,OAAO,WAAW,CAAA;AAAA;AAAA,EAElB,OAAO,aAAa,oBAAI,IAA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|
-
import {
|
|
2
|
-
|
|
3
|
-
// Registered plugins
|
|
4
|
-
static _plugins = [];
|
|
5
|
-
// Map of field type => { renderer: Function, pluginId: string }
|
|
6
|
-
static _renderers = /* @__PURE__ */ new Map();
|
|
7
|
-
/**
|
|
8
|
-
* Register a plugin. If a plugin with the same id exists, it's replaced.
|
|
9
|
-
* @param {object} plugin - Plugin definition (see header)
|
|
10
|
-
* @returns {Function} unregister function
|
|
11
|
-
*/
|
|
12
|
-
static register(plugin) {
|
|
13
|
-
if (!plugin || typeof plugin !== "object") {
|
|
14
|
-
console.warn("[FormPlugins] register called with invalid plugin:", plugin);
|
|
15
|
-
return () => {
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
if (!plugin.id || typeof plugin.id !== "string") {
|
|
19
|
-
console.warn('[FormPlugins] plugin must have a unique string "id"', plugin);
|
|
20
|
-
return () => {
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
this.unregister(plugin.id);
|
|
24
|
-
if (plugin.fieldTypes && typeof plugin.fieldTypes === "object") {
|
|
25
|
-
Object.entries(plugin.fieldTypes).forEach(([type, renderer]) => {
|
|
26
|
-
if (typeof renderer === "function") {
|
|
27
|
-
this._renderers.set(type, { renderer, pluginId: plugin.id });
|
|
28
|
-
} else {
|
|
29
|
-
console.warn(`[FormPlugins] renderer for type "${type}" is not a function`);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
this._plugins.push(plugin);
|
|
34
|
-
return () => this.unregister(plugin.id);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Unregister a plugin by id. Removes its field renderers as well.
|
|
38
|
-
* @param {string} id - Plugin id
|
|
39
|
-
*/
|
|
40
|
-
static unregister(id) {
|
|
41
|
-
if (!id) return;
|
|
42
|
-
this._plugins = this._plugins.filter((p) => p.id !== id);
|
|
43
|
-
for (const [type, meta] of this._renderers.entries()) {
|
|
44
|
-
if (meta?.pluginId === id) {
|
|
45
|
-
this._renderers.delete(type);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Get a custom field renderer by type (if registered).
|
|
51
|
-
* @param {string} type - Field type
|
|
52
|
-
* @returns {(builder: any, fieldConfig: object) => string | null}
|
|
53
|
-
*/
|
|
54
|
-
static getRenderer(type) {
|
|
55
|
-
const meta = this._renderers.get(type);
|
|
56
|
-
return meta?.renderer || null;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Returns true if a renderer exists for a field type
|
|
60
|
-
*/
|
|
61
|
-
static hasRenderer(type) {
|
|
62
|
-
return this._renderers.has(type);
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Get a shallow copy of registered plugins (read-only use).
|
|
66
|
-
*/
|
|
67
|
-
static getPlugins() {
|
|
68
|
-
return [...this._plugins];
|
|
69
|
-
}
|
|
70
|
-
// -----------------------------
|
|
71
|
-
// Safe dispatch to plugin hooks
|
|
72
|
-
// -----------------------------
|
|
73
|
-
static _invoke(plugin, hook, ...args) {
|
|
74
|
-
const fn = plugin?.[hook];
|
|
75
|
-
if (typeof fn !== "function") return;
|
|
76
|
-
try {
|
|
77
|
-
return fn.apply(plugin, args);
|
|
78
|
-
} catch (err) {
|
|
79
|
-
console.error(`[FormPlugins] ${hook} error from plugin "${plugin.id}":`, err);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Called by FormBuilder (e.g., in ctor or initializeTemplates)
|
|
84
|
-
* @param {any} builder
|
|
85
|
-
*/
|
|
86
|
-
static onFormBuilderInit(builder) {
|
|
87
|
-
this._plugins.forEach((p) => this._invoke(p, "onFormBuilderInit", builder));
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Called by FormView constructor or early init
|
|
91
|
-
* @param {any} formView
|
|
92
|
-
*/
|
|
93
|
-
static onFormViewInit(formView) {
|
|
94
|
-
this._plugins.forEach((p) => this._invoke(p, "onFormViewInit", formView));
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Called by FormView.onAfterRender
|
|
98
|
-
* @param {any} formView
|
|
99
|
-
*/
|
|
100
|
-
static onFormViewAfterRender(formView) {
|
|
101
|
-
this._plugins.forEach((p) => this._invoke(p, "onAfterRender", formView));
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Called when a specific field element is initialized (after DOM exists)
|
|
105
|
-
* @param {any} formView
|
|
106
|
-
* @param {HTMLElement} fieldEl
|
|
107
|
-
* @param {object} fieldConfig
|
|
108
|
-
*/
|
|
109
|
-
static onFieldInit(formView, fieldEl, fieldConfig) {
|
|
110
|
-
this._plugins.forEach((p) => this._invoke(p, "onFieldInit", formView, fieldEl, fieldConfig));
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Called when a field value changes (normalized point)
|
|
114
|
-
* @param {any} formView
|
|
115
|
-
* @param {string} fieldName
|
|
116
|
-
* @param {any} value
|
|
117
|
-
*/
|
|
118
|
-
static onFieldChange(formView, fieldName, value) {
|
|
119
|
-
this._plugins.forEach((p) => this._invoke(p, "onFieldChange", formView, fieldName, value));
|
|
120
|
-
}
|
|
121
|
-
}
|
|
1
|
+
import { M as Mustache, a as MOJOUtils, V as View } from "./Rest-DnVeH4wg.js";
|
|
2
|
+
import { F as FormPlugins } from "./FormPlugins-DY6e88YT.js";
|
|
122
3
|
class FormBuilder {
|
|
123
4
|
constructor(config = {}) {
|
|
124
5
|
this.fields = config.fields || [];
|
|
@@ -8592,4 +8473,4 @@ export {
|
|
|
8592
8473
|
applyFileDropMixin as a,
|
|
8593
8474
|
FormView$1 as b
|
|
8594
8475
|
};
|
|
8595
|
-
//# sourceMappingURL=FormView-
|
|
8476
|
+
//# sourceMappingURL=FormView-D6TdblYe.js.map
|