@servlyadmin/runtime-core 0.1.4 → 0.1.5
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/index.cjs +44 -9
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +44 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1471,15 +1471,50 @@ function applyAttributes(domElement, element, context) {
|
|
|
1471
1471
|
}
|
|
1472
1472
|
}
|
|
1473
1473
|
}
|
|
1474
|
-
function
|
|
1475
|
-
if (
|
|
1476
|
-
|
|
1474
|
+
function resolveFunctionBinding(binding, context) {
|
|
1475
|
+
if (binding.source === "props" || binding.source === "parent") {
|
|
1476
|
+
const path = binding.path;
|
|
1477
|
+
if (!path) return void 0;
|
|
1478
|
+
const parts = path.split(".");
|
|
1479
|
+
let value = context.props;
|
|
1480
|
+
for (const part of parts) {
|
|
1481
|
+
if (value === null || value === void 0) return void 0;
|
|
1482
|
+
value = value[part];
|
|
1483
|
+
}
|
|
1484
|
+
if (typeof value === "function") {
|
|
1485
|
+
return value;
|
|
1486
|
+
}
|
|
1487
|
+
return void 0;
|
|
1477
1488
|
}
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1489
|
+
if (binding.source === "static" && typeof binding.value === "function") {
|
|
1490
|
+
return binding.value;
|
|
1491
|
+
}
|
|
1492
|
+
return void 0;
|
|
1493
|
+
}
|
|
1494
|
+
function attachEventHandlers(domElement, element, eventHandlers, context, elementState) {
|
|
1495
|
+
const elementId = element.i;
|
|
1496
|
+
if (eventHandlers && eventHandlers[elementId]) {
|
|
1497
|
+
const handlers = eventHandlers[elementId];
|
|
1498
|
+
for (const [eventName, handler] of Object.entries(handlers)) {
|
|
1499
|
+
const domEventName = eventName.replace(/^on/, "").toLowerCase();
|
|
1500
|
+
elementState.eventListeners.set(domEventName, handler);
|
|
1501
|
+
domElement.addEventListener(domEventName, handler);
|
|
1502
|
+
}
|
|
1503
|
+
}
|
|
1504
|
+
const bindings = element.configuration?.bindings?.inputs;
|
|
1505
|
+
if (bindings) {
|
|
1506
|
+
for (const [propName, binding] of Object.entries(bindings)) {
|
|
1507
|
+
if (propName.startsWith("on") && propName.length > 2) {
|
|
1508
|
+
const handler = resolveFunctionBinding(binding, context);
|
|
1509
|
+
if (handler) {
|
|
1510
|
+
const domEventName = propName.slice(2).toLowerCase();
|
|
1511
|
+
if (!elementState.eventListeners.has(domEventName)) {
|
|
1512
|
+
elementState.eventListeners.set(domEventName, handler);
|
|
1513
|
+
domElement.addEventListener(domEventName, handler);
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1483
1518
|
}
|
|
1484
1519
|
}
|
|
1485
1520
|
function detachEventHandlers(elementState) {
|
|
@@ -1514,7 +1549,7 @@ function createElement(element, context, eventHandlers) {
|
|
|
1514
1549
|
textContent,
|
|
1515
1550
|
eventListeners: /* @__PURE__ */ new Map()
|
|
1516
1551
|
};
|
|
1517
|
-
attachEventHandlers(domElement, element
|
|
1552
|
+
attachEventHandlers(domElement, element, eventHandlers, context, elementState);
|
|
1518
1553
|
return elementState;
|
|
1519
1554
|
}
|
|
1520
1555
|
var globalRenderingStack = /* @__PURE__ */ new Set();
|
package/dist/index.d.cts
CHANGED
|
@@ -52,6 +52,15 @@ interface ElementConfig {
|
|
|
52
52
|
readOnly?: boolean;
|
|
53
53
|
/** Inline styles */
|
|
54
54
|
style?: Record<string, any>;
|
|
55
|
+
/** Input bindings for props */
|
|
56
|
+
bindings?: {
|
|
57
|
+
inputs?: Record<string, {
|
|
58
|
+
source: 'static' | 'props' | 'state' | 'parent' | 'function';
|
|
59
|
+
value?: any;
|
|
60
|
+
path?: string;
|
|
61
|
+
binding?: any;
|
|
62
|
+
}>;
|
|
63
|
+
};
|
|
55
64
|
/** Reference to another component (for componentView elements) */
|
|
56
65
|
componentViewRef?: string;
|
|
57
66
|
/** Version specifier for the referenced component */
|
package/dist/index.d.ts
CHANGED
|
@@ -52,6 +52,15 @@ interface ElementConfig {
|
|
|
52
52
|
readOnly?: boolean;
|
|
53
53
|
/** Inline styles */
|
|
54
54
|
style?: Record<string, any>;
|
|
55
|
+
/** Input bindings for props */
|
|
56
|
+
bindings?: {
|
|
57
|
+
inputs?: Record<string, {
|
|
58
|
+
source: 'static' | 'props' | 'state' | 'parent' | 'function';
|
|
59
|
+
value?: any;
|
|
60
|
+
path?: string;
|
|
61
|
+
binding?: any;
|
|
62
|
+
}>;
|
|
63
|
+
};
|
|
55
64
|
/** Reference to another component (for componentView elements) */
|
|
56
65
|
componentViewRef?: string;
|
|
57
66
|
/** Version specifier for the referenced component */
|
package/dist/index.js
CHANGED
|
@@ -1198,15 +1198,50 @@ function applyAttributes(domElement, element, context) {
|
|
|
1198
1198
|
}
|
|
1199
1199
|
}
|
|
1200
1200
|
}
|
|
1201
|
-
function
|
|
1202
|
-
if (
|
|
1203
|
-
|
|
1201
|
+
function resolveFunctionBinding(binding, context) {
|
|
1202
|
+
if (binding.source === "props" || binding.source === "parent") {
|
|
1203
|
+
const path = binding.path;
|
|
1204
|
+
if (!path) return void 0;
|
|
1205
|
+
const parts = path.split(".");
|
|
1206
|
+
let value = context.props;
|
|
1207
|
+
for (const part of parts) {
|
|
1208
|
+
if (value === null || value === void 0) return void 0;
|
|
1209
|
+
value = value[part];
|
|
1210
|
+
}
|
|
1211
|
+
if (typeof value === "function") {
|
|
1212
|
+
return value;
|
|
1213
|
+
}
|
|
1214
|
+
return void 0;
|
|
1204
1215
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1216
|
+
if (binding.source === "static" && typeof binding.value === "function") {
|
|
1217
|
+
return binding.value;
|
|
1218
|
+
}
|
|
1219
|
+
return void 0;
|
|
1220
|
+
}
|
|
1221
|
+
function attachEventHandlers(domElement, element, eventHandlers, context, elementState) {
|
|
1222
|
+
const elementId = element.i;
|
|
1223
|
+
if (eventHandlers && eventHandlers[elementId]) {
|
|
1224
|
+
const handlers = eventHandlers[elementId];
|
|
1225
|
+
for (const [eventName, handler] of Object.entries(handlers)) {
|
|
1226
|
+
const domEventName = eventName.replace(/^on/, "").toLowerCase();
|
|
1227
|
+
elementState.eventListeners.set(domEventName, handler);
|
|
1228
|
+
domElement.addEventListener(domEventName, handler);
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
const bindings = element.configuration?.bindings?.inputs;
|
|
1232
|
+
if (bindings) {
|
|
1233
|
+
for (const [propName, binding] of Object.entries(bindings)) {
|
|
1234
|
+
if (propName.startsWith("on") && propName.length > 2) {
|
|
1235
|
+
const handler = resolveFunctionBinding(binding, context);
|
|
1236
|
+
if (handler) {
|
|
1237
|
+
const domEventName = propName.slice(2).toLowerCase();
|
|
1238
|
+
if (!elementState.eventListeners.has(domEventName)) {
|
|
1239
|
+
elementState.eventListeners.set(domEventName, handler);
|
|
1240
|
+
domElement.addEventListener(domEventName, handler);
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1210
1245
|
}
|
|
1211
1246
|
}
|
|
1212
1247
|
function detachEventHandlers(elementState) {
|
|
@@ -1241,7 +1276,7 @@ function createElement(element, context, eventHandlers) {
|
|
|
1241
1276
|
textContent,
|
|
1242
1277
|
eventListeners: /* @__PURE__ */ new Map()
|
|
1243
1278
|
};
|
|
1244
|
-
attachEventHandlers(domElement, element
|
|
1279
|
+
attachEventHandlers(domElement, element, eventHandlers, context, elementState);
|
|
1245
1280
|
return elementState;
|
|
1246
1281
|
}
|
|
1247
1282
|
var globalRenderingStack = /* @__PURE__ */ new Set();
|