be-hive 0.0.224 → 0.0.226

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 CHANGED
@@ -56,7 +56,7 @@ export class BeHive extends Synthesizer {
56
56
  const mergeWithDefaults = { ...defaultObsAttrs, ...synConfig };
57
57
  //TODO allow for programmatic adjustments in load event
58
58
  //this.dispatchEvent(new RegistryEventImpl(mergeWithDefaults));
59
- const { base, block, branches, enhancedElementInstanceOf, enhancedElementMatches, hostInstanceOf, hostMatches, leaves, preBaseDelimiter, preBranchDelimiter, importEnh, preLeafDelimiter, hasRootIn, map, osotas, mapLocalNameTo, ws } = mergeWithDefaults;
59
+ const { base, block, branches, enhancedElementInstanceOf, enhancedElementMatches, hostInstanceOf, hostMatches, leaves, preBaseDelimiter, preBranchDelimiter, importEnh, preLeafDelimiter, hasRootIn, map, osotas, mapLocalNameTo, ws, mapWSTo } = mergeWithDefaults;
60
60
  const mi = {
61
61
  on: enhancedElementMatches,
62
62
  whereInstanceOf: enhancedElementInstanceOf,
@@ -127,8 +127,12 @@ export class BeHive extends Synthesizer {
127
127
  initialPropValues[mapLocalNameTo] = mountedElement.localName;
128
128
  }
129
129
  initialPropValues.customHandlers = registeredHandlers.get(synConfig.top)?.get(enhPropKey);
130
+ let filteredWs;
130
131
  if (ws !== undefined) {
131
- (await import('./e.js')).e(mountedElement, ws, initialPropValues);
132
+ filteredWs = (await import('./e.js')).e(mountedElement, ws, initialPropValues);
133
+ if (mapWSTo !== undefined) {
134
+ initialPropValues[mapWSTo] = filteredWs;
135
+ }
132
136
  }
133
137
  //initialPropValues.scopedCustomHandlers = scopedHandlers.get(synConfig.top)?.get(enhPropKey);
134
138
  enhancementInstance.attach(mountedElement, {
@@ -136,7 +140,8 @@ export class BeHive extends Synthesizer {
136
140
  initialPropValues,
137
141
  mountCnfg: mergeWithDefaults,
138
142
  synConfig,
139
- observedAttrs
143
+ observedAttrs,
144
+ ws: filteredWs
140
145
  });
141
146
  });
142
147
  }
package/be-hive.ts CHANGED
@@ -4,7 +4,8 @@ export {EMC} from './ts-refs/trans-render/be/types';
4
4
  export {MountObserver, MOSE} from 'mount-observer/MountObserver.js';
5
5
  import {
6
6
  AttrMapPoint, CustomHandlerCluster, EMC, EventListenerOrFn,
7
- HandlerKey,
7
+ HandlerKey,
8
+ IW,
8
9
  } from './ts-refs/trans-render/be/types';
9
10
  import { MountEvent } from 'mount-observer/MountObserver';
10
11
  import 'be-enhanced/beEnhanced.js';
@@ -79,7 +80,7 @@ export class BeHive extends Synthesizer {
79
80
  enhancedElementMatches, hostInstanceOf, hostMatches,
80
81
  leaves, preBaseDelimiter, preBranchDelimiter, importEnh,
81
82
  preLeafDelimiter, hasRootIn, map, osotas,
82
- mapLocalNameTo, ws
83
+ mapLocalNameTo, ws, mapWSTo
83
84
 
84
85
  } = mergeWithDefaults;
85
86
  const mi: MountInit = {
@@ -148,9 +149,12 @@ export class BeHive extends Synthesizer {
148
149
  initialPropValues[mapLocalNameTo] = mountedElement.localName;
149
150
  }
150
151
  initialPropValues.customHandlers = registeredHandlers.get(synConfig.top)?.get(enhPropKey);
151
-
152
+ let filteredWs: Array<IW> | undefined;
152
153
  if(ws !== undefined){
153
- (await import('./e.js')).e(mountedElement, ws, initialPropValues);
154
+ filteredWs = (await import('./e.js')).e(mountedElement, ws, initialPropValues);
155
+ if(mapWSTo !== undefined){
156
+ initialPropValues[mapWSTo] = filteredWs
157
+ }
154
158
  }
155
159
  //initialPropValues.scopedCustomHandlers = scopedHandlers.get(synConfig.top)?.get(enhPropKey);
156
160
  enhancementInstance.attach(mountedElement, {
@@ -158,7 +162,8 @@ export class BeHive extends Synthesizer {
158
162
  initialPropValues,
159
163
  mountCnfg: mergeWithDefaults,
160
164
  synConfig,
161
- observedAttrs
165
+ observedAttrs,
166
+ ws: filteredWs
162
167
  });
163
168
  });
164
169
  }
package/e.js CHANGED
@@ -1,7 +1,9 @@
1
1
  export function e(matchingElement, ws, initialPropVals, ac) {
2
+ const matchingWs = [];
2
3
  for (const w of ws) {
3
4
  if (!matchingElement.matches(w.q))
4
5
  continue;
6
+ matchingWs.push(w);
5
7
  const { listeners, props } = w;
6
8
  for (const key in listeners) {
7
9
  let listener = listeners[key];
@@ -12,4 +14,5 @@ export function e(matchingElement, ws, initialPropVals, ac) {
12
14
  }
13
15
  Object.assign(initialPropVals, props);
14
16
  }
17
+ return matchingWs;
15
18
  }
package/e.ts CHANGED
@@ -2,8 +2,10 @@ import { EventListenerClass, EventListenerOrFn, IW } from "./ts-refs/trans-rende
2
2
 
3
3
 
4
4
  export function e(matchingElement: Element, ws: Array<IW>, initialPropVals: any, ac?: AbortController){
5
+ const matchingWs = [];
5
6
  for(const w of ws){
6
7
  if(!matchingElement.matches(w.q)) continue;
8
+ matchingWs.push(w);
7
9
  const {listeners, props} = w;
8
10
  for(const key in listeners){
9
11
  let listener = listeners[key] as any;
@@ -14,4 +16,5 @@ export function e(matchingElement: Element, ws: Array<IW>, initialPropVals: any,
14
16
  }
15
17
  Object.assign(initialPropVals, props);
16
18
  }
19
+ return matchingWs;
17
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "be-hive",
3
- "version": "0.0.224",
3
+ "version": "0.0.226",
4
4
  "keywords": [
5
5
  "web-components",
6
6
  "web-component",
package/w.js CHANGED
@@ -16,12 +16,35 @@ export class W {
16
16
  get props() {
17
17
  return this.#props;
18
18
  }
19
+ #refs = {};
20
+ get refs() {
21
+ return this.#refs;
22
+ }
23
+ /**
24
+ * add events
25
+ * @param eventsToAdd
26
+ * @returns
27
+ */
19
28
  a(eventsToAdd) {
20
29
  this.#listeners = { ...this.#listeners, ...eventsToAdd };
21
30
  return this;
22
31
  }
32
+ /**
33
+ * set props
34
+ * @param props
35
+ * @returns
36
+ */
23
37
  s(props) {
24
38
  this.#props = { ...this.#props, ...props };
25
39
  return this;
26
40
  }
41
+ /**
42
+ * register refs
43
+ * @param refs
44
+ * @returns
45
+ */
46
+ r(refs) {
47
+ this.#refs = { ...this.#refs, ...refs };
48
+ return this;
49
+ }
27
50
  }
package/w.ts CHANGED
@@ -16,13 +16,37 @@ export class W<T = EventTarget> implements IW<T>{
16
16
  get props(){
17
17
  return this.#props;
18
18
  }
19
+ #refs: {[key: string]: any} = {};
20
+ get refs(){
21
+ return this.#refs;
22
+ }
23
+ /**
24
+ * add events
25
+ * @param eventsToAdd
26
+ * @returns
27
+ */
19
28
  a(eventsToAdd: {[key: string]: EventListenerOrFn}){
20
29
  this.#listeners = {...this.#listeners, ...eventsToAdd};
21
30
  return this;
22
31
  }
32
+ /**
33
+ * set props
34
+ * @param props
35
+ * @returns
36
+ */
23
37
  s(props: Partial<T>){
24
38
  this.#props = {...this.#props, ...props};
25
39
  return this;
26
40
  }
27
41
 
42
+ /**
43
+ * register refs
44
+ * @param refs
45
+ * @returns
46
+ */
47
+ r(refs: {[key: string]: any}){
48
+ this.#refs = {...this.#refs, ...refs};
49
+ return this;
50
+ }
51
+
28
52
  }