be-hive 0.0.74 → 0.0.76
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/be-hive.js +28 -41
- package/be-hive.ts +29 -47
- package/be-hive.void +99 -0
- package/package.json +3 -6
- package/playwright.config.ts +4 -4
package/be-hive.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export class BeHive extends HTMLElement {
|
|
2
|
+
constructor() {
|
|
3
|
+
super();
|
|
4
|
+
this.registeredBehaviors = {};
|
|
5
|
+
}
|
|
6
|
+
connectedCallback() {
|
|
7
|
+
this.style.display = 'none';
|
|
8
|
+
const overridesAttr = this.getAttribute('overrides');
|
|
9
|
+
if (overridesAttr !== null) {
|
|
10
|
+
this.overrides = JSON.parse(overridesAttr);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
this.overrides = {};
|
|
14
|
+
}
|
|
15
|
+
this.#getInheritedBehaviors();
|
|
16
|
+
}
|
|
17
|
+
#getInheritedBehaviors() {
|
|
18
|
+
const beSevered = this.getAttribute('be-severed');
|
|
19
|
+
if (beSevered !== null)
|
|
6
20
|
return;
|
|
7
21
|
const rn = this.getRootNode();
|
|
8
22
|
const host = rn.host;
|
|
@@ -45,42 +59,15 @@ export class BeHiveCore extends HTMLElement {
|
|
|
45
59
|
ifWantsToBe: newIfWantsToBe,
|
|
46
60
|
};
|
|
47
61
|
this.registeredBehaviors[parentInstanceLocalName] = newRegisteredBehavior;
|
|
48
|
-
this.
|
|
62
|
+
this.dispatchEvent(new CustomEvent('latest-behavior-changed', {
|
|
63
|
+
detail: {
|
|
64
|
+
value: newRegisteredBehavior,
|
|
65
|
+
}
|
|
66
|
+
}));
|
|
67
|
+
//this.latestBehaviors = [...this.latestBehaviors, newRegisteredBehavior];
|
|
49
68
|
return newBehaviorEl;
|
|
50
69
|
}
|
|
51
|
-
onLatestBehaviors({}) {
|
|
52
|
-
if (this.latestBehaviors.length === 0)
|
|
53
|
-
return;
|
|
54
|
-
for (const behavior of this.latestBehaviors) {
|
|
55
|
-
this.dispatchEvent(new CustomEvent('latest-behavior-changed', {
|
|
56
|
-
detail: {
|
|
57
|
-
value: behavior,
|
|
58
|
-
}
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
this.latestBehaviors = [];
|
|
62
|
-
}
|
|
63
70
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
tagName,
|
|
68
|
-
propDefaults: {
|
|
69
|
-
overrides: {},
|
|
70
|
-
isC: true,
|
|
71
|
-
beSevered: false,
|
|
72
|
-
latestBehaviors: []
|
|
73
|
-
},
|
|
74
|
-
actions: {
|
|
75
|
-
intro: {
|
|
76
|
-
ifAllOf: ['isC'],
|
|
77
|
-
},
|
|
78
|
-
onLatestBehaviors: 'latestBehaviors'
|
|
79
|
-
},
|
|
80
|
-
style: {
|
|
81
|
-
display: 'none',
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
superclass: BeHiveCore
|
|
85
|
-
});
|
|
86
|
-
export const BeHive = ce.classDef;
|
|
71
|
+
if (!customElements.get('be-hive')) {
|
|
72
|
+
customElements.define('be-hive', BeHive);
|
|
73
|
+
}
|
package/be-hive.ts
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
import {CE} from 'trans-render/lib/CE.js';
|
|
2
1
|
import {BeHiveProps, BeHiveActions, BehaviorKeys} from './types';
|
|
2
|
+
export class BeHive extends HTMLElement{
|
|
3
|
+
constructor(){
|
|
4
|
+
super();
|
|
5
|
+
this.registeredBehaviors = {};
|
|
6
|
+
}
|
|
7
|
+
connectedCallback(){
|
|
8
|
+
this.style.display = 'none';
|
|
9
|
+
const overridesAttr = this.getAttribute('overrides');
|
|
10
|
+
if(overridesAttr !== null){
|
|
11
|
+
this.overrides = JSON.parse(overridesAttr);
|
|
12
|
+
}else{
|
|
13
|
+
this.overrides = {};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
this.#getInheritedBehaviors();
|
|
17
|
+
}
|
|
3
18
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
intro({beSevered}: this){
|
|
8
|
-
if(beSevered) return;
|
|
19
|
+
#getInheritedBehaviors(){
|
|
20
|
+
const beSevered = this.getAttribute('be-severed');
|
|
21
|
+
if(beSevered !== null) return;
|
|
9
22
|
const rn = this.getRootNode();
|
|
10
23
|
const host = (<any>rn).host;
|
|
11
24
|
if(!host) return;
|
|
@@ -23,7 +36,6 @@ export class BeHiveCore extends HTMLElement implements BeHiveActions{
|
|
|
23
36
|
}
|
|
24
37
|
}
|
|
25
38
|
|
|
26
|
-
|
|
27
39
|
register(parentInstance: BehaviorKeys){
|
|
28
40
|
const parentInstanceLocalName = parentInstance.localName;
|
|
29
41
|
if(this.querySelector(parentInstanceLocalName) !== null) return;
|
|
@@ -50,50 +62,20 @@ export class BeHiveCore extends HTMLElement implements BeHiveActions{
|
|
|
50
62
|
};
|
|
51
63
|
|
|
52
64
|
this.registeredBehaviors[parentInstanceLocalName] = newRegisteredBehavior;
|
|
53
|
-
this.
|
|
65
|
+
this.dispatchEvent(new CustomEvent('latest-behavior-changed', {
|
|
66
|
+
detail:{
|
|
67
|
+
value: newRegisteredBehavior,
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
//this.latestBehaviors = [...this.latestBehaviors, newRegisteredBehavior];
|
|
54
71
|
return newBehaviorEl;
|
|
55
72
|
}
|
|
56
73
|
|
|
57
74
|
|
|
58
|
-
onLatestBehaviors({}: this): void {
|
|
59
|
-
if(this.latestBehaviors.length === 0) return;
|
|
60
|
-
for(const behavior of this.latestBehaviors){
|
|
61
|
-
this.dispatchEvent(new CustomEvent('latest-behavior-changed', {
|
|
62
|
-
detail:{
|
|
63
|
-
value: behavior,
|
|
64
|
-
}
|
|
65
|
-
}))
|
|
66
|
-
}
|
|
67
|
-
this.latestBehaviors = [];
|
|
68
|
-
}
|
|
69
75
|
}
|
|
70
76
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const ce = new CE<BeHiveProps, BeHiveActions>({
|
|
76
|
-
config:{
|
|
77
|
-
tagName,
|
|
78
|
-
propDefaults:{
|
|
79
|
-
overrides: {},
|
|
80
|
-
isC: true,
|
|
81
|
-
beSevered: false,
|
|
82
|
-
latestBehaviors: []
|
|
83
|
-
},
|
|
84
|
-
actions:{
|
|
85
|
-
intro:{
|
|
86
|
-
ifAllOf:['isC'],
|
|
87
|
-
},
|
|
88
|
-
onLatestBehaviors: 'latestBehaviors'
|
|
89
|
-
},
|
|
90
|
-
style:{
|
|
91
|
-
display: 'none',
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
superclass: BeHiveCore
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
export const BeHive = ce.classDef!;
|
|
98
|
-
|
|
77
|
+
if(!customElements.get('be-hive')){
|
|
78
|
+
customElements.define('be-hive', BeHive);
|
|
79
|
+
}
|
|
99
80
|
|
|
81
|
+
export interface BeHive extends BeHiveProps{}
|
package/be-hive.void
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {CE} from 'trans-render/lib/CE.js';
|
|
2
|
+
import {BeHiveProps, BeHiveActions, BehaviorKeys} from './types';
|
|
3
|
+
|
|
4
|
+
export class BeHiveCore extends HTMLElement implements BeHiveActions{
|
|
5
|
+
registeredBehaviors: {[key: string]: BehaviorKeys} = {};
|
|
6
|
+
|
|
7
|
+
intro({beSevered}: this){
|
|
8
|
+
if(beSevered) return;
|
|
9
|
+
const rn = this.getRootNode();
|
|
10
|
+
const host = (<any>rn).host;
|
|
11
|
+
if(!host) return;
|
|
12
|
+
const parentShadowRealm = host.getRootNode();
|
|
13
|
+
const parentBeHiveInstance = parentShadowRealm.querySelector('be-hive') as BeHiveProps & Element;
|
|
14
|
+
if(parentBeHiveInstance !== null){
|
|
15
|
+
const {registeredBehaviors} = parentBeHiveInstance;
|
|
16
|
+
for(const key in registeredBehaviors){
|
|
17
|
+
this.register(registeredBehaviors[key]);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
parentBeHiveInstance.addEventListener('latest-behavior-changed', (e: Event) => {
|
|
21
|
+
this.register((<any>e).detail.value);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
register(parentInstance: BehaviorKeys){
|
|
28
|
+
const parentInstanceLocalName = parentInstance.localName;
|
|
29
|
+
if(this.querySelector(parentInstanceLocalName) !== null) return;
|
|
30
|
+
const override = this.overrides[parentInstanceLocalName];
|
|
31
|
+
let newInstanceTagName = parentInstanceLocalName;
|
|
32
|
+
let newIfWantsToBe = parentInstance.ifWantsToBe;
|
|
33
|
+
if(override !== undefined){
|
|
34
|
+
const {ifWantsToBe, block} = override;
|
|
35
|
+
if(block) return;
|
|
36
|
+
if(ifWantsToBe !== null){
|
|
37
|
+
newIfWantsToBe = ifWantsToBe;
|
|
38
|
+
newInstanceTagName = 'be-' + ifWantsToBe;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const newBehaviorEl = document.createElement(parentInstanceLocalName);
|
|
43
|
+
newBehaviorEl.setAttribute('if-wants-to-be', newIfWantsToBe);
|
|
44
|
+
newBehaviorEl.setAttribute('upgrade', parentInstance.upgrade);
|
|
45
|
+
this.appendChild(newBehaviorEl);
|
|
46
|
+
const newRegisteredBehavior: BehaviorKeys = {
|
|
47
|
+
...parentInstance,
|
|
48
|
+
ifWantsToBe: newIfWantsToBe,
|
|
49
|
+
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
this.registeredBehaviors[parentInstanceLocalName] = newRegisteredBehavior;
|
|
53
|
+
this.latestBehaviors = [...this.latestBehaviors, newRegisteredBehavior];
|
|
54
|
+
return newBehaviorEl;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
onLatestBehaviors({}: this): void {
|
|
59
|
+
if(this.latestBehaviors.length === 0) return;
|
|
60
|
+
for(const behavior of this.latestBehaviors){
|
|
61
|
+
this.dispatchEvent(new CustomEvent('latest-behavior-changed', {
|
|
62
|
+
detail:{
|
|
63
|
+
value: behavior,
|
|
64
|
+
}
|
|
65
|
+
}))
|
|
66
|
+
}
|
|
67
|
+
this.latestBehaviors = [];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface BeHiveCore extends BeHiveProps{}
|
|
72
|
+
|
|
73
|
+
const tagName = 'be-hive';
|
|
74
|
+
|
|
75
|
+
const ce = new CE<BeHiveProps, BeHiveActions>({
|
|
76
|
+
config:{
|
|
77
|
+
tagName,
|
|
78
|
+
propDefaults:{
|
|
79
|
+
overrides: {},
|
|
80
|
+
isC: true,
|
|
81
|
+
beSevered: false,
|
|
82
|
+
latestBehaviors: []
|
|
83
|
+
},
|
|
84
|
+
actions:{
|
|
85
|
+
intro:{
|
|
86
|
+
ifAllOf:['isC'],
|
|
87
|
+
},
|
|
88
|
+
onLatestBehaviors: 'latestBehaviors'
|
|
89
|
+
},
|
|
90
|
+
style:{
|
|
91
|
+
display: 'none',
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
superclass: BeHiveCore
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
export const BeHive = ce.classDef!;
|
|
98
|
+
|
|
99
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "be-hive",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.76",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"web-components",
|
|
6
6
|
"web-component",
|
|
@@ -27,17 +27,14 @@
|
|
|
27
27
|
"package-check": "package-check",
|
|
28
28
|
"doc": "custom-elements-manifest analyze"
|
|
29
29
|
},
|
|
30
|
-
"dependencies": {
|
|
31
|
-
"trans-render": "0.0.626"
|
|
32
|
-
},
|
|
33
30
|
"devDependencies": {
|
|
34
31
|
"@playwright/test": "1.27.1",
|
|
35
32
|
"@skypack/package-check": "0.2.2",
|
|
36
33
|
"may-it-serve": "0.0.3",
|
|
37
34
|
"@custom-elements-manifest/analyzer": "0.6.4",
|
|
38
|
-
"xtal-editor": "0.0.196",
|
|
39
35
|
"xtal-shell": "0.0.27",
|
|
40
|
-
"be-functional": "0.0.
|
|
36
|
+
"be-functional": "0.0.15",
|
|
37
|
+
"be-exportable": "0.0.41"
|
|
41
38
|
},
|
|
42
39
|
"repository": {
|
|
43
40
|
"type": "git",
|
package/playwright.config.ts
CHANGED
|
@@ -11,10 +11,10 @@ const config: PlaywrightTestConfig = {
|
|
|
11
11
|
baseURL: 'http://localhost:3030/',
|
|
12
12
|
},
|
|
13
13
|
projects: [
|
|
14
|
-
{
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
},
|
|
14
|
+
// {
|
|
15
|
+
// name: 'chromium',
|
|
16
|
+
// use: { ...devices['Desktop Chrome'] },
|
|
17
|
+
// },
|
|
18
18
|
// {
|
|
19
19
|
// name: 'firefox',
|
|
20
20
|
// use: { ...devices['Desktop Firefox'] },
|