@domql/element 2.34.25 → 2.34.29
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/cjs/methods/index.js +6 -0
- package/dist/cjs/methods/root.js +78 -0
- package/dist/cjs/methods/set.js +6 -0
- package/dist/esm/methods/index.js +6 -0
- package/dist/esm/methods/root.js +59 -0
- package/dist/esm/methods/set.js +12 -0
- package/methods/index.js +6 -0
- package/methods/root.js +59 -0
- package/methods/set.js +12 -0
- package/package.json +6 -6
|
@@ -48,6 +48,7 @@ __export(methods_exports, {
|
|
|
48
48
|
warn: () => warn
|
|
49
49
|
});
|
|
50
50
|
module.exports = __toCommonJS(methods_exports);
|
|
51
|
+
var import_root = require("./root.js");
|
|
51
52
|
var import_event = require("@domql/event");
|
|
52
53
|
var import_utils = require("@domql/utils");
|
|
53
54
|
var import_tree = require("../tree.js");
|
|
@@ -353,6 +354,11 @@ const METHODS = [
|
|
|
353
354
|
"getRef",
|
|
354
355
|
"getChildren",
|
|
355
356
|
"getPath",
|
|
357
|
+
"getRootState",
|
|
358
|
+
"getRoot",
|
|
359
|
+
"getRootData",
|
|
360
|
+
"getRootContext",
|
|
361
|
+
"getContext",
|
|
356
362
|
"setNodeStyles",
|
|
357
363
|
"spotByPath",
|
|
358
364
|
"keys",
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var root_exports = {};
|
|
19
|
+
__export(root_exports, {
|
|
20
|
+
getChildren: () => getChildren,
|
|
21
|
+
getContext: () => getContext,
|
|
22
|
+
getRef: () => getRef,
|
|
23
|
+
getRoot: () => getRoot,
|
|
24
|
+
getRootContext: () => getRootContext,
|
|
25
|
+
getRootData: () => getRootData,
|
|
26
|
+
getRootState: () => getRootState
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(root_exports);
|
|
29
|
+
function getRootState(param) {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
let state = null;
|
|
32
|
+
const hasRootState = (obj) => {
|
|
33
|
+
var _a2;
|
|
34
|
+
return obj.__element && ((_a2 = obj.root) == null ? void 0 : _a2.isRootState);
|
|
35
|
+
};
|
|
36
|
+
if (!this) {
|
|
37
|
+
state = window.platformState || ((_a = window.smblsApp) == null ? void 0 : _a.state);
|
|
38
|
+
} else if (hasRootState(this)) {
|
|
39
|
+
state = this.root;
|
|
40
|
+
} else if (this.__ref && this.__ref.path) {
|
|
41
|
+
const hasPlatformState = this.state && hasRootState(this.state);
|
|
42
|
+
const hasPlatformStateOnParent = this.call("isFunction", this.state) && this.parent.state && hasRootState(this.parent.state);
|
|
43
|
+
if (hasPlatformState || hasPlatformStateOnParent) {
|
|
44
|
+
state = this.state.root || this.parent.state.root;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (!state) {
|
|
48
|
+
state = window.platformState || ((_b = window.smblsApp) == null ? void 0 : _b.state);
|
|
49
|
+
}
|
|
50
|
+
return param ? state[param] : state;
|
|
51
|
+
}
|
|
52
|
+
function getRef(key) {
|
|
53
|
+
if (key) {
|
|
54
|
+
return this.__ref && this.__ref[key];
|
|
55
|
+
}
|
|
56
|
+
return this.__ref;
|
|
57
|
+
}
|
|
58
|
+
function getChildren() {
|
|
59
|
+
const __children = this.getRef("__children");
|
|
60
|
+
return __children == null ? void 0 : __children.map((k) => this[k]);
|
|
61
|
+
}
|
|
62
|
+
function getRoot(key) {
|
|
63
|
+
var _a;
|
|
64
|
+
const rootElem = (_a = this.getRootState()) == null ? void 0 : _a.__element;
|
|
65
|
+
return rootElem && Object.keys(rootElem).length > 0 && key ? rootElem[key] : rootElem;
|
|
66
|
+
}
|
|
67
|
+
function getRootData(key) {
|
|
68
|
+
return this.getRoot("data") && Object.keys(this.getRoot("data")).length > 0 && key ? this.getRoot("data")[key] : this.getRoot("data");
|
|
69
|
+
}
|
|
70
|
+
function getRootContext(key) {
|
|
71
|
+
var _a;
|
|
72
|
+
const ctx = (_a = this.getRoot()) == null ? void 0 : _a.context;
|
|
73
|
+
return key ? ctx[key] : ctx;
|
|
74
|
+
}
|
|
75
|
+
function getContext(key) {
|
|
76
|
+
const ctx = this.context;
|
|
77
|
+
return key ? ctx[key] : ctx;
|
|
78
|
+
}
|
package/dist/cjs/methods/set.js
CHANGED
|
@@ -26,6 +26,7 @@ var import_set = require("../set.js");
|
|
|
26
26
|
var import_update = require("../update.js");
|
|
27
27
|
var import_content = require("../mixins/content.js");
|
|
28
28
|
var import_index = require("./index.js");
|
|
29
|
+
var import_root = require("./root.js");
|
|
29
30
|
const addMethods = (element, parent, options = {}) => {
|
|
30
31
|
const proto = {
|
|
31
32
|
set: import_set.set,
|
|
@@ -40,6 +41,11 @@ const addMethods = (element, parent, options = {}) => {
|
|
|
40
41
|
lookdown: import_index.lookdown,
|
|
41
42
|
lookdownAll: import_index.lookdownAll,
|
|
42
43
|
getRef: import_index.getRef,
|
|
44
|
+
getRootState: import_root.getRootState,
|
|
45
|
+
getRoot: import_root.getRoot,
|
|
46
|
+
getRootData: import_root.getRootData,
|
|
47
|
+
getRootContext: import_root.getRootContext,
|
|
48
|
+
getContext: import_root.getContext,
|
|
43
49
|
getPath: import_index.getPath,
|
|
44
50
|
setNodeStyles: import_index.setNodeStyles,
|
|
45
51
|
spotByPath: import_index.spotByPath,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "./root.js";
|
|
1
2
|
import { triggerEventOn } from "@domql/event";
|
|
2
3
|
import {
|
|
3
4
|
isDefined,
|
|
@@ -312,6 +313,11 @@ const METHODS = [
|
|
|
312
313
|
"getRef",
|
|
313
314
|
"getChildren",
|
|
314
315
|
"getPath",
|
|
316
|
+
"getRootState",
|
|
317
|
+
"getRoot",
|
|
318
|
+
"getRootData",
|
|
319
|
+
"getRootContext",
|
|
320
|
+
"getContext",
|
|
315
321
|
"setNodeStyles",
|
|
316
322
|
"spotByPath",
|
|
317
323
|
"keys",
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
function getRootState(param) {
|
|
2
|
+
var _a, _b;
|
|
3
|
+
let state = null;
|
|
4
|
+
const hasRootState = (obj) => {
|
|
5
|
+
var _a2;
|
|
6
|
+
return obj.__element && ((_a2 = obj.root) == null ? void 0 : _a2.isRootState);
|
|
7
|
+
};
|
|
8
|
+
if (!this) {
|
|
9
|
+
state = window.platformState || ((_a = window.smblsApp) == null ? void 0 : _a.state);
|
|
10
|
+
} else if (hasRootState(this)) {
|
|
11
|
+
state = this.root;
|
|
12
|
+
} else if (this.__ref && this.__ref.path) {
|
|
13
|
+
const hasPlatformState = this.state && hasRootState(this.state);
|
|
14
|
+
const hasPlatformStateOnParent = this.call("isFunction", this.state) && this.parent.state && hasRootState(this.parent.state);
|
|
15
|
+
if (hasPlatformState || hasPlatformStateOnParent) {
|
|
16
|
+
state = this.state.root || this.parent.state.root;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (!state) {
|
|
20
|
+
state = window.platformState || ((_b = window.smblsApp) == null ? void 0 : _b.state);
|
|
21
|
+
}
|
|
22
|
+
return param ? state[param] : state;
|
|
23
|
+
}
|
|
24
|
+
function getRef(key) {
|
|
25
|
+
if (key) {
|
|
26
|
+
return this.__ref && this.__ref[key];
|
|
27
|
+
}
|
|
28
|
+
return this.__ref;
|
|
29
|
+
}
|
|
30
|
+
function getChildren() {
|
|
31
|
+
const __children = this.getRef("__children");
|
|
32
|
+
return __children == null ? void 0 : __children.map((k) => this[k]);
|
|
33
|
+
}
|
|
34
|
+
function getRoot(key) {
|
|
35
|
+
var _a;
|
|
36
|
+
const rootElem = (_a = this.getRootState()) == null ? void 0 : _a.__element;
|
|
37
|
+
return rootElem && Object.keys(rootElem).length > 0 && key ? rootElem[key] : rootElem;
|
|
38
|
+
}
|
|
39
|
+
function getRootData(key) {
|
|
40
|
+
return this.getRoot("data") && Object.keys(this.getRoot("data")).length > 0 && key ? this.getRoot("data")[key] : this.getRoot("data");
|
|
41
|
+
}
|
|
42
|
+
function getRootContext(key) {
|
|
43
|
+
var _a;
|
|
44
|
+
const ctx = (_a = this.getRoot()) == null ? void 0 : _a.context;
|
|
45
|
+
return key ? ctx[key] : ctx;
|
|
46
|
+
}
|
|
47
|
+
function getContext(key) {
|
|
48
|
+
const ctx = this.context;
|
|
49
|
+
return key ? ctx[key] : ctx;
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
getChildren,
|
|
53
|
+
getContext,
|
|
54
|
+
getRef,
|
|
55
|
+
getRoot,
|
|
56
|
+
getRootContext,
|
|
57
|
+
getRootData,
|
|
58
|
+
getRootState
|
|
59
|
+
};
|
package/dist/esm/methods/set.js
CHANGED
|
@@ -25,6 +25,13 @@ import {
|
|
|
25
25
|
append,
|
|
26
26
|
warn
|
|
27
27
|
} from "./index.js";
|
|
28
|
+
import {
|
|
29
|
+
getContext,
|
|
30
|
+
getRoot,
|
|
31
|
+
getRootContext,
|
|
32
|
+
getRootData,
|
|
33
|
+
getRootState
|
|
34
|
+
} from "./root.js";
|
|
28
35
|
const addMethods = (element, parent, options = {}) => {
|
|
29
36
|
const proto = {
|
|
30
37
|
set,
|
|
@@ -39,6 +46,11 @@ const addMethods = (element, parent, options = {}) => {
|
|
|
39
46
|
lookdown,
|
|
40
47
|
lookdownAll,
|
|
41
48
|
getRef,
|
|
49
|
+
getRootState,
|
|
50
|
+
getRoot,
|
|
51
|
+
getRootData,
|
|
52
|
+
getRootContext,
|
|
53
|
+
getContext,
|
|
42
54
|
getPath,
|
|
43
55
|
setNodeStyles,
|
|
44
56
|
spotByPath,
|
package/methods/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
import './root.js'
|
|
3
4
|
import { triggerEventOn } from '@domql/event'
|
|
4
5
|
import {
|
|
5
6
|
isDefined,
|
|
@@ -397,6 +398,11 @@ export const METHODS = [
|
|
|
397
398
|
'getRef',
|
|
398
399
|
'getChildren',
|
|
399
400
|
'getPath',
|
|
401
|
+
'getRootState',
|
|
402
|
+
'getRoot',
|
|
403
|
+
'getRootData',
|
|
404
|
+
'getRootContext',
|
|
405
|
+
'getContext',
|
|
400
406
|
'setNodeStyles',
|
|
401
407
|
'spotByPath',
|
|
402
408
|
'keys',
|
package/methods/root.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export function getRootState(param) {
|
|
2
|
+
let state = null
|
|
3
|
+
const hasRootState = (obj) => obj.__element && obj.root?.isRootState
|
|
4
|
+
if (!this) {
|
|
5
|
+
state = window.platformState || window.smblsApp?.state
|
|
6
|
+
} else if (hasRootState(this)) {
|
|
7
|
+
state = this.root
|
|
8
|
+
} else if (this.__ref && this.__ref.path) {
|
|
9
|
+
const hasPlatformState = this.state && hasRootState(this.state)
|
|
10
|
+
const hasPlatformStateOnParent =
|
|
11
|
+
this.call('isFunction', this.state) &&
|
|
12
|
+
this.parent.state &&
|
|
13
|
+
hasRootState(this.parent.state)
|
|
14
|
+
if (hasPlatformState || hasPlatformStateOnParent) {
|
|
15
|
+
state = this.state.root || this.parent.state.root
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
if (!state) {
|
|
19
|
+
state = window.platformState || window.smblsApp?.state
|
|
20
|
+
}
|
|
21
|
+
return param ? state[param] : state
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function getRef(key) {
|
|
25
|
+
if (key) {
|
|
26
|
+
return this.__ref && this.__ref[key]
|
|
27
|
+
}
|
|
28
|
+
return this.__ref
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function getChildren() {
|
|
32
|
+
const __children = this.getRef('__children')
|
|
33
|
+
return __children?.map((k) => this[k])
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function getRoot(key) {
|
|
37
|
+
const rootElem = this.getRootState()?.__element
|
|
38
|
+
return rootElem && Object.keys(rootElem).length > 0 && key
|
|
39
|
+
? rootElem[key]
|
|
40
|
+
: rootElem
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getRootData(key) {
|
|
44
|
+
return this.getRoot('data') &&
|
|
45
|
+
Object.keys(this.getRoot('data')).length > 0 &&
|
|
46
|
+
key
|
|
47
|
+
? this.getRoot('data')[key]
|
|
48
|
+
: this.getRoot('data')
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function getRootContext(key) {
|
|
52
|
+
const ctx = this.getRoot()?.context
|
|
53
|
+
return key ? ctx[key] : ctx
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function getContext(key) {
|
|
57
|
+
const ctx = this.context
|
|
58
|
+
return key ? ctx[key] : ctx
|
|
59
|
+
}
|
package/methods/set.js
CHANGED
|
@@ -29,6 +29,13 @@ import {
|
|
|
29
29
|
append,
|
|
30
30
|
warn
|
|
31
31
|
} from './index.js'
|
|
32
|
+
import {
|
|
33
|
+
getContext,
|
|
34
|
+
getRoot,
|
|
35
|
+
getRootContext,
|
|
36
|
+
getRootData,
|
|
37
|
+
getRootState
|
|
38
|
+
} from './root.js'
|
|
32
39
|
|
|
33
40
|
export const addMethods = (element, parent, options = {}) => {
|
|
34
41
|
const proto = {
|
|
@@ -44,6 +51,11 @@ export const addMethods = (element, parent, options = {}) => {
|
|
|
44
51
|
lookdown,
|
|
45
52
|
lookdownAll,
|
|
46
53
|
getRef,
|
|
54
|
+
getRootState,
|
|
55
|
+
getRoot,
|
|
56
|
+
getRootData,
|
|
57
|
+
getRootContext,
|
|
58
|
+
getContext,
|
|
47
59
|
getPath,
|
|
48
60
|
setNodeStyles,
|
|
49
61
|
spotByPath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/element",
|
|
3
|
-
"version": "2.34.
|
|
3
|
+
"version": "2.34.29",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"prepublish": "npx rimraf -I dist && npm run build && npm run copy:package:cjs"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@domql/event": "^2.34.
|
|
32
|
-
"@domql/render": "^2.34.
|
|
33
|
-
"@domql/state": "^2.34.
|
|
34
|
-
"@domql/utils": "^2.34.
|
|
31
|
+
"@domql/event": "^2.34.29",
|
|
32
|
+
"@domql/render": "^2.34.29",
|
|
33
|
+
"@domql/state": "^2.34.29",
|
|
34
|
+
"@domql/utils": "^2.34.29"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "90cb8b61065249122ff356c3ea6eb56191c49bfa",
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@babel/core": "^7.27.1"
|
|
39
39
|
}
|