@wavemaker-ai/react-runtime 1.0.0-rc.309 → 1.0.0-rc.312
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/components/container/index.js +10 -1
- package/core/util/index.d.ts +5 -0
- package/core/util/index.js +7 -1
- package/core/util/utils.d.ts +4 -0
- package/core/util/utils.js +65 -2
- package/higherOrder/BaseApp.js +11 -9
- package/package-lock.json +148 -126
- package/package.json +3 -3
- package/runtime-dynamic/app-initializer.js +44 -19
- package/runtime-dynamic/components/partial-content.js +1 -4
- package/runtime-dynamic/factories/utils.js +1 -2
- package/runtime-dynamic/services/css-scoping.js +6 -2
- package/runtime-dynamic/services/prefab-resources.js +4 -14
- package/runtime-dynamic/utils/index.d.ts +2 -0
- package/runtime-dynamic/utils/index.js +14 -1
- package/tsconfig.declaration.tsbuildinfo +1 -1
- package/utils/style-utils.d.ts +2 -0
- package/utils/style-utils.js +6 -1
|
@@ -14,6 +14,7 @@ var _clsx2 = require("clsx");
|
|
|
14
14
|
var _withBaseWrapper = require("@wavemaker-ai/react-runtime/higherOrder/withBaseWrapper");
|
|
15
15
|
var _layoutsizeUtil = require("@wavemaker-ai/react-runtime/utils/layoutsize-util");
|
|
16
16
|
var _attr = require("@wavemaker-ai/react-runtime/utils/attr");
|
|
17
|
+
var _styleUtils = require("@wavemaker-ai/react-runtime/utils/style-utils");
|
|
17
18
|
var _excluded = ["listener"],
|
|
18
19
|
_excluded2 = ["className", "styles", "children", "renderPartial", "onLoad", "id", "direction", "wrap", "alignment", "gap", "columngap", "clipcontent", "position", "zindex", "name", "onClick", "onBlur", "onFocus", "onMouseEnter", "onMouseLeave", "onMouseOver", "onMouseOut", "onDoubleClick", "onKeydown", "onKeyup", "onKeypress", "animation", "show", "conditionalstyle", "conditionalclass", "showindevice", "eventCallback", "forwardedRef", "viewParent", "hint", "arialabel", "tabindex", "iswidget", "deferload", "datavalue", "prefab", "inbound", "outbound", "formfield", "updateon", "dataset", "prefabName", "content", "overflow", "display", "layoutClassName"];
|
|
19
20
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
@@ -82,6 +83,14 @@ var WmContainer = exports.WmContainer = function WmContainer(props) {
|
|
|
82
83
|
var isLoaded = (0, _react.useRef)(false);
|
|
83
84
|
var widget_instance = listener === null || listener === void 0 || (_listener$Widgets = listener.Widgets) === null || _listener$Widgets === void 0 ? void 0 : _listener$Widgets[name];
|
|
84
85
|
var containerRef = (0, _react.useRef)(null);
|
|
86
|
+
var containerStyles = (0, _react.useMemo)(function () {
|
|
87
|
+
if (!(styles !== null && styles !== void 0 && styles.backgroundImage)) {
|
|
88
|
+
return styles;
|
|
89
|
+
}
|
|
90
|
+
return _objectSpread(_objectSpread({}, styles), {}, {
|
|
91
|
+
backgroundImage: (0, _styleUtils.normalizeBackgroundImage)(styles.backgroundImage)
|
|
92
|
+
});
|
|
93
|
+
}, [styles]);
|
|
85
94
|
(0, _react.useEffect)(function () {
|
|
86
95
|
var _listener$Widgets2;
|
|
87
96
|
// expose nativeElement property to proxy
|
|
@@ -159,7 +168,7 @@ var WmContainer = exports.WmContainer = function WmContainer(props) {
|
|
|
159
168
|
hidden: props.hidden
|
|
160
169
|
}, (0, _attr.removeInvalidAttributes)(rest), domEvents, {
|
|
161
170
|
name: name,
|
|
162
|
-
style: _objectSpread(_objectSpread({},
|
|
171
|
+
style: _objectSpread(_objectSpread({}, containerStyles), conditionalstyle),
|
|
163
172
|
ref: containerRef
|
|
164
173
|
}), renderPartial ? renderPartial(restPartialProps, onLoad) : children);
|
|
165
174
|
};
|
package/core/util/index.d.ts
CHANGED
|
@@ -21,6 +21,11 @@ export declare const MATCH_MODES: {
|
|
|
21
21
|
IS_EQUAL_WITH_IGNORE_CASE: string;
|
|
22
22
|
IS_EQUAL: string;
|
|
23
23
|
};
|
|
24
|
+
/** Prism / app theme mode attribute values (parity with Angular `@wm/variables`). */
|
|
25
|
+
export declare const MODE_CONSTANTS: {
|
|
26
|
+
LIGHT: string;
|
|
27
|
+
DEFAULT: string;
|
|
28
|
+
};
|
|
24
29
|
export declare const MONTHNAMES: string[];
|
|
25
30
|
export declare const checkPublicAccess: (page?: string) => boolean;
|
|
26
31
|
export declare const setSessionStorageItem: (key: string, value: string) => void;
|
package/core/util/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.formatMessage = exports.deepCopy = exports.checkPublicAccess = exports._get = exports.VALIDATOR = exports.MONTHNAMES = exports.MATCH_MODES = void 0;
|
|
7
|
+
exports.formatMessage = exports.deepCopy = exports.checkPublicAccess = exports._get = exports.VALIDATOR = exports.MONTHNAMES = exports.MODE_CONSTANTS = exports.MATCH_MODES = void 0;
|
|
8
8
|
exports.getCurrentMonth = getCurrentMonth;
|
|
9
9
|
exports.isDefined = exports.getValidJSON = exports.getTimezone = exports.getSessionStorageItem = exports.getSessionLocaleSafe = void 0;
|
|
10
10
|
exports.reload = reload;
|
|
@@ -36,6 +36,12 @@ var MATCH_MODES = exports.MATCH_MODES = {
|
|
|
36
36
|
IS_EQUAL_WITH_IGNORE_CASE: "exactignorecase",
|
|
37
37
|
IS_EQUAL: "exact"
|
|
38
38
|
};
|
|
39
|
+
|
|
40
|
+
/** Prism / app theme mode attribute values (parity with Angular `@wm/variables`). */
|
|
41
|
+
var MODE_CONSTANTS = exports.MODE_CONSTANTS = {
|
|
42
|
+
LIGHT: "light",
|
|
43
|
+
DEFAULT: "default"
|
|
44
|
+
};
|
|
39
45
|
var MONTHNAMES = exports.MONTHNAMES = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
40
46
|
var checkPublicAccess = exports.checkPublicAccess = function checkPublicAccess(page) {
|
|
41
47
|
var _window$location$path, _store$getState$info$;
|
package/core/util/utils.d.ts
CHANGED
|
@@ -31,4 +31,8 @@ export declare const triggerItemAction: (item: any) => void;
|
|
|
31
31
|
export declare const getCurrentPath: () => string;
|
|
32
32
|
export declare const getItemLink: (item: any, props: any) => string | undefined;
|
|
33
33
|
export declare function hasOwnObjectProperty(obj: any, prop: string): any;
|
|
34
|
+
export declare const getModesFromLocalStorage: () => Record<string, string>;
|
|
35
|
+
export declare function setMode(modes: Record<string, string>, shouldPersist?: boolean): void;
|
|
36
|
+
export declare function initAppModes(): void;
|
|
37
|
+
export declare function teardownAppModes(): void;
|
|
34
38
|
export declare const mergeProxies: (firstProxy: any, secondProxy: any) => any;
|
package/core/util/utils.js
CHANGED
|
@@ -4,13 +4,19 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.getUrlParams = exports.getRouteNameFromLink = exports.getItemLink = exports.getCurrentPath = exports.Utils = void 0;
|
|
7
|
+
exports.getUrlParams = exports.getRouteNameFromLink = exports.getModesFromLocalStorage = exports.getItemLink = exports.getCurrentPath = exports.Utils = void 0;
|
|
8
8
|
exports.hasOwnObjectProperty = hasOwnObjectProperty;
|
|
9
|
-
exports.
|
|
9
|
+
exports.initAppModes = initAppModes;
|
|
10
|
+
exports.openLink = exports.mergeProxies = exports.isJQueryError = exports.isInsecureContentRequest = void 0;
|
|
11
|
+
exports.setMode = setMode;
|
|
12
|
+
exports.teardownAppModes = teardownAppModes;
|
|
13
|
+
exports.triggerItemAction = void 0;
|
|
10
14
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
15
|
var _navigationMiddleware = require("@wavemaker-ai/react-runtime/store/middleware/navigationMiddleware");
|
|
12
16
|
var _constants = require("../constants");
|
|
13
17
|
var _navigation = require("next/navigation");
|
|
18
|
+
var _isObject = _interopRequireDefault(require("lodash-es/isObject"));
|
|
19
|
+
var _index = require("./index");
|
|
14
20
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
15
21
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
16
22
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
@@ -215,6 +221,63 @@ var getItemLink = exports.getItemLink = function getItemLink(item, props) {
|
|
|
215
221
|
function hasOwnObjectProperty(obj, prop) {
|
|
216
222
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
217
223
|
}
|
|
224
|
+
var getModesFromLocalStorage = exports.getModesFromLocalStorage = function getModesFromLocalStorage() {
|
|
225
|
+
var storedValue = localStorage.getItem("wm-app-modes") || "{}";
|
|
226
|
+
try {
|
|
227
|
+
storedValue = JSON.parse(storedValue);
|
|
228
|
+
} catch (error) {
|
|
229
|
+
console.error("Error parsing modes", error === null || error === void 0 ? void 0 : error.message);
|
|
230
|
+
storedValue = {};
|
|
231
|
+
}
|
|
232
|
+
return (0, _isObject["default"])(storedValue) ? storedValue : {};
|
|
233
|
+
};
|
|
234
|
+
function setMode(modes) {
|
|
235
|
+
var shouldPersist = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
236
|
+
var htmlEl = document.getElementsByTagName("html")[0];
|
|
237
|
+
if (!htmlEl) return;
|
|
238
|
+
if (!(0, _isObject["default"])(modes)) {
|
|
239
|
+
modes = {};
|
|
240
|
+
}
|
|
241
|
+
var modesArr = Object.entries(modes);
|
|
242
|
+
if (!modesArr.length) return;
|
|
243
|
+
modesArr.forEach(function (_ref5) {
|
|
244
|
+
var _ref6 = (0, _slicedToArray2["default"])(_ref5, 2),
|
|
245
|
+
modeKey = _ref6[0],
|
|
246
|
+
modeValue = _ref6[1];
|
|
247
|
+
var isDefault = modeValue === _index.MODE_CONSTANTS.LIGHT || modeValue === _index.MODE_CONSTANTS.DEFAULT;
|
|
248
|
+
if (isDefault) {
|
|
249
|
+
htmlEl.removeAttribute(modeKey);
|
|
250
|
+
} else {
|
|
251
|
+
htmlEl.setAttribute(modeKey, modeValue);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
if (shouldPersist) {
|
|
255
|
+
localStorage.setItem("wm-app-modes", JSON.stringify(modes));
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
var windowMessageListener = null;
|
|
259
|
+
function initAppModes() {
|
|
260
|
+
setMode(getModesFromLocalStorage());
|
|
261
|
+
if (windowMessageListener) {
|
|
262
|
+
window.removeEventListener("message", windowMessageListener);
|
|
263
|
+
}
|
|
264
|
+
windowMessageListener = function windowMessageListener(event) {
|
|
265
|
+
var _ref7 = event.data || {},
|
|
266
|
+
key = _ref7.key,
|
|
267
|
+
modes = _ref7.modes,
|
|
268
|
+
shouldPersist = _ref7.shouldPersist;
|
|
269
|
+
if (key === "switch-mode" && modes) {
|
|
270
|
+
setMode(modes, !shouldPersist);
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
window.addEventListener("message", windowMessageListener);
|
|
274
|
+
}
|
|
275
|
+
function teardownAppModes() {
|
|
276
|
+
if (windowMessageListener) {
|
|
277
|
+
window.removeEventListener("message", windowMessageListener);
|
|
278
|
+
windowMessageListener = null;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
218
281
|
var mergeProxies = exports.mergeProxies = function mergeProxies(firstProxy, secondProxy) {
|
|
219
282
|
return new Proxy(firstProxy, {
|
|
220
283
|
get: function get(target, key) {
|
package/higherOrder/BaseApp.js
CHANGED
|
@@ -202,6 +202,7 @@ var BaseApp = exports.BaseApp = function BaseApp(WrappedComponent, addAppScript,
|
|
|
202
202
|
initializeApp();
|
|
203
203
|
// Cleanup function
|
|
204
204
|
return function () {
|
|
205
|
+
(0, _utils.teardownAppModes)();
|
|
205
206
|
// Clean up service error subscription
|
|
206
207
|
if (serviceErrorSubscriptionRef.current) {
|
|
207
208
|
serviceErrorSubscriptionRef.current();
|
|
@@ -316,6 +317,7 @@ var BaseApp = exports.BaseApp = function BaseApp(WrappedComponent, addAppScript,
|
|
|
316
317
|
appProxy = (0, _proxyService.createStateProxy)(appContext, [], setAppContext);
|
|
317
318
|
appProxy.serviceDefinitions = (0, _cloneDeep["default"])((info === null || info === void 0 ? void 0 : info.serviceDefs) || {});
|
|
318
319
|
appProxyRef.current = appProxy;
|
|
320
|
+
appProxy.setMode = _utils.setMode;
|
|
319
321
|
|
|
320
322
|
// Get app variables
|
|
321
323
|
appVariables = {
|
|
@@ -401,12 +403,12 @@ var BaseApp = exports.BaseApp = function BaseApp(WrappedComponent, addAppScript,
|
|
|
401
403
|
return _ref5.apply(this, arguments);
|
|
402
404
|
};
|
|
403
405
|
}(); // onBeforeAppReady should call before calling anything
|
|
404
|
-
_context3.next =
|
|
406
|
+
_context3.next = 14;
|
|
405
407
|
return executeAppBeforeStartup();
|
|
406
|
-
case
|
|
407
|
-
_context3.next =
|
|
408
|
+
case 14:
|
|
409
|
+
_context3.next = 16;
|
|
408
410
|
return executeAppStartup();
|
|
409
|
-
case
|
|
411
|
+
case 16:
|
|
410
412
|
// Initialize DialogService in appstore
|
|
411
413
|
_appstore["default"].DialogService.set(_dialog["default"]);
|
|
412
414
|
|
|
@@ -419,10 +421,10 @@ var BaseApp = exports.BaseApp = function BaseApp(WrappedComponent, addAppScript,
|
|
|
419
421
|
isAppReady: true
|
|
420
422
|
});
|
|
421
423
|
});
|
|
422
|
-
_context3.next =
|
|
424
|
+
_context3.next = 24;
|
|
423
425
|
break;
|
|
424
|
-
case
|
|
425
|
-
_context3.prev =
|
|
426
|
+
case 20:
|
|
427
|
+
_context3.prev = 20;
|
|
426
428
|
_context3.t0 = _context3["catch"](0);
|
|
427
429
|
console.error("Error initializing app:", _context3.t0);
|
|
428
430
|
setAppContext(function (prev) {
|
|
@@ -430,11 +432,11 @@ var BaseApp = exports.BaseApp = function BaseApp(WrappedComponent, addAppScript,
|
|
|
430
432
|
isAppReady: true
|
|
431
433
|
});
|
|
432
434
|
});
|
|
433
|
-
case
|
|
435
|
+
case 24:
|
|
434
436
|
case "end":
|
|
435
437
|
return _context3.stop();
|
|
436
438
|
}
|
|
437
|
-
}, _callee3, null, [[0,
|
|
439
|
+
}, _callee3, null, [[0, 20]]);
|
|
438
440
|
}));
|
|
439
441
|
return function initializeApp() {
|
|
440
442
|
return _ref3.apply(this, arguments);
|