@pacem/pacem-core 2.0.0-chebyshev → 2.0.0-euler

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.
Files changed (40) hide show
  1. package/dist/browser/pacem-core.js +79 -22
  2. package/dist/browser/pacem-core.js.map +1 -1
  3. package/dist/browser/pacem-core.min.js +2 -2
  4. package/dist/bundle/pacem-core.min.mjs +5 -5
  5. package/dist/bundle/pacem-core.mjs +66 -9
  6. package/dist/bundle/pacem-core.mjs.map +2 -2
  7. package/dist/docs/pacem-core.json +93 -8
  8. package/dist/esm/adapter.js +1 -1
  9. package/dist/esm/binding-parser.js +1 -1
  10. package/dist/esm/command.js +1 -1
  11. package/dist/esm/comparers.js +1 -1
  12. package/dist/esm/converters.js +1 -1
  13. package/dist/esm/decorators-next.js +1 -1
  14. package/dist/esm/decorators.js +72 -17
  15. package/dist/esm/defaults.js +1 -1
  16. package/dist/esm/events.js +1 -1
  17. package/dist/esm/eventtarget.js +1 -1
  18. package/dist/esm/expression.js +1 -1
  19. package/dist/esm/index-animations.js +1 -1
  20. package/dist/esm/index-behaviors.js +1 -1
  21. package/dist/esm/index-components.js +1 -1
  22. package/dist/esm/index-iife.js +1 -1
  23. package/dist/esm/index-logging.js +1 -1
  24. package/dist/esm/index-net.js +1 -1
  25. package/dist/esm/index-root.js +1 -1
  26. package/dist/esm/index-ui.js +1 -1
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/logger.js +1 -1
  29. package/dist/esm/prefix.js +1 -1
  30. package/dist/esm/promise.js +1 -1
  31. package/dist/esm/regex.js +1 -1
  32. package/dist/esm/storage.js +1 -1
  33. package/dist/esm/template.js +1 -1
  34. package/dist/esm/transforms.js +1 -1
  35. package/dist/esm/types.js +1 -1
  36. package/dist/esm/utils-customelement.js +1 -1
  37. package/dist/esm/utils-customevent.js +1 -1
  38. package/dist/esm/utils.js +1 -1
  39. package/package.json +1 -1
  40. package/typings/index.d.ts +12 -2
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pacem/pacem-core v2.0.0-chebyshev (https://js.pacem.it)
2
+ * @pacem/pacem-core v2.0.0-euler (https://js.pacem.it)
3
3
  * Pacem (https://pacem.it)
4
4
  * Licensed under Apache-2.0
5
5
  */
@@ -3097,12 +3097,19 @@
3097
3097
  const WATCH_BIND_PREFIX = 'pacem:binding:';
3098
3098
  //const WATCH_THROTTLE_PREFIX: string = 'pacem:throttle:';
3099
3099
  const INSTANCE_CHILDREN_VAR = 'pacem:view-children';
3100
+ const VIEWCHILD_SURFACES_VAR = 'pacem:view-children:surface';
3100
3101
  const HAS_BIND_PREFIX = 'pacem:has-binding:';
3101
3102
  const HAS_TEMPLATE_VAR = 'pacem:custom-element:has-template';
3102
3103
  const HASBEEN_TEMPLATED_VAR = 'pacem:custom-element:has-templated';
3103
3104
  const INSTANCE_PROMISE_VAR = 'pacem:custom-element:promise';
3104
3105
  const INSTANCE_READY_VAR = 'pacem:custom-element:ready';
3105
3106
  const INSTANCE_ONREADY_VAR = 'pacem:custom-element:startup';
3107
+ const SURFACETHEME_FACE_ATTR = 'surface-face';
3108
+ const SURFACETHEME_CONTENT_ATTR = 'surface-content';
3109
+ const SURFACETHEME_MODIFIER_ATTR = 'surface-modifier';
3110
+ /** the modifier of a host that is its own face */
3111
+ const SURFACETHEME_FACE_MODIFIER = 'face';
3112
+ const SURFACETHEME_CONTENT_MODIFIER = 'content';
3106
3113
  //const TYPE_OPTIONS_VAR = 'pacem:custom-element:options';
3107
3114
  function processBinding(element, property, binding) {
3108
3115
  var _this = element;
@@ -3143,8 +3150,8 @@
3143
3150
  //cancelAnimationFrame(_this[handleName]);
3144
3151
  //_this[handleName] = requestAnimationFrame(() => {
3145
3152
  _this[prop] = value.evaluate /*Async*/() /*.then(val => {
3146
- _this[prop] = val;
3147
- })*/;
3153
+ _this[prop] = val;
3154
+ })*/;
3148
3155
  //});
3149
3156
  }
3150
3157
  }
@@ -3276,6 +3283,23 @@
3276
3283
  //console.log(`${_this.localName} connected.`);
3277
3284
  _this.setAttribute('pacem', '');
3278
3285
  _this.setAttribute('cloak', '');
3286
+ const faces = GET_VAL$5(proto, VIEWCHILD_SURFACES_VAR) ?? [];
3287
+ if (!Utils.isNullOrEmpty(config.modifiers)
3288
+ // if any surface face gets declared then the host must be spotted as a **surface** host, even if empty in modifiers
3289
+ || !Utils.isNullOrEmpty(faces)) {
3290
+ const currentModifiers = _this.getAttribute(SURFACETHEME_MODIFIER_ATTR)?.split(/\s+/) ?? [];
3291
+ const ownModifiers = (config.modifiers ?? []).slice(0);
3292
+ if (!faces.some(f => f.face)) {
3293
+ // no faces declared: the host is its own face
3294
+ ownModifiers.push(SURFACETHEME_FACE_MODIFIER);
3295
+ }
3296
+ if (!faces.some(f => f.content)) {
3297
+ // no contents declared: the host is its own content
3298
+ ownModifiers.push(SURFACETHEME_CONTENT_MODIFIER);
3299
+ }
3300
+ const modifiers = currentModifiers.union(ownModifiers);
3301
+ _this.setAttribute(SURFACETHEME_MODIFIER_ATTR, modifiers.join(' ').trim().replace(/\s+/g, ' '));
3302
+ }
3279
3303
  // reset INSTANCE_CHILDREN_VAR at connectedCallback
3280
3304
  DEL_VAL$4(_this, INSTANCE_CHILDREN_VAR);
3281
3305
  // ready to fire
@@ -3398,6 +3422,33 @@
3398
3422
  if (!Utils.isNull(deferred))
3399
3423
  deferred.resolve();
3400
3424
  };
3425
+ // apply surface face attributes
3426
+ for (let item of faces) {
3427
+ const element = _this[item.ref];
3428
+ if (Utils.isNull(element)) {
3429
+ continue;
3430
+ }
3431
+ // shadow dom
3432
+ if (config.shadow) {
3433
+ if (item.content) {
3434
+ const part = typeof item.content === 'string' ? item.content : 'content';
3435
+ Utils.addPart(element, part);
3436
+ }
3437
+ if (item.face) {
3438
+ const part = typeof item.face === 'string' ? item.face : 'face';
3439
+ Utils.addPart(element, part);
3440
+ }
3441
+ }
3442
+ else {
3443
+ // non shadow dom
3444
+ if (item.content) {
3445
+ element.setAttribute(SURFACETHEME_CONTENT_ATTR, item.content.toString());
3446
+ }
3447
+ if (item.face) {
3448
+ element.setAttribute(SURFACETHEME_FACE_ATTR, item.face.toString());
3449
+ }
3450
+ }
3451
+ }
3401
3452
  _this.removeAttribute('cloak');
3402
3453
  //...now that the document is ready:
3403
3454
  // fire original viewActivatedCallback
@@ -3524,7 +3575,7 @@
3524
3575
  // put proved to have relevant attribute empty. (e.g. some widget utils like `PacemWidgetFetchParameterElement` need this)
3525
3576
  || Utils.isNullOrEmpty(attr)) {
3526
3577
  var config;
3527
- if (val === undefined || val === null) {
3578
+ if (Utils.isNull(val)) {
3528
3579
  _this.removeAttribute(attrName);
3529
3580
  }
3530
3581
  else if (property && (config = property.config) && typeof config.converter.convertBack === 'function') {
@@ -3705,19 +3756,23 @@
3705
3756
  }
3706
3757
  };
3707
3758
  }
3708
- /**
3709
- * Property decorator that turns a class field into a lazily-resolved, cached reference to a descendant
3710
- * element matching `selector`. Resolution happens on first read (via `shadowRoot.querySelectorAll` when
3711
- * available, falling back to the element itself), and only nodes whose `INSTANCE_HOST_VAR` points back
3712
- * at `this` are considered — this keeps the lookup scoped to the current element's own template output,
3713
- * skipping over descendants that belong to a nested custom element's own template. The cache is reset
3714
- * whenever the host element reconnects to the DOM (`connectedCallback`, see the {@link CustomElement} decorator).
3715
- *
3716
- * @param selector CSS selector identifying the child element to bind to.
3717
- * @returns A property decorator to apply to the view-child field (read-only; no setter is defined).
3718
- */
3719
- function ViewChild(selector) {
3759
+ function ViewChild(selector, faceOrObj = false, content) {
3760
+ let face;
3761
+ // content falls back to face's truthy value when not provided.
3762
+ if (typeof faceOrObj === 'object') {
3763
+ const { face: face0, content: content0 } = faceOrObj;
3764
+ face = face0;
3765
+ content = content0 ?? (!!face0);
3766
+ }
3767
+ else {
3768
+ face = faceOrObj;
3769
+ content ??= (!!face);
3770
+ }
3720
3771
  return (target, prop, descriptor) => {
3772
+ if (face || content) {
3773
+ const faces = GET_VAL$5(target, VIEWCHILD_SURFACES_VAR, []);
3774
+ faces.push({ ref: prop, face, content });
3775
+ }
3721
3776
  const key = `${prop}_${Utils.uniqueCode()}`;
3722
3777
  function findElement() {
3723
3778
  const _this = this, nodelist = (_this.shadowRoot || _this).querySelectorAll(selector);
@@ -3733,7 +3788,7 @@
3733
3788
  const _this = this;
3734
3789
  // reset INSTANCE_CHILDREN_VAR on connectedCallback!
3735
3790
  const dict = GET_VAL$5(_this, INSTANCE_CHILDREN_VAR, {});
3736
- return dict[key] = dict[key] || findElement.call(_this);
3791
+ return dict[key] ??= findElement.call(_this);
3737
3792
  }
3738
3793
  if (delete target[prop]) {
3739
3794
  Object.defineProperty(target, prop, {
@@ -5112,10 +5167,11 @@
5112
5167
  this._tabIndex = -1;
5113
5168
  /** Gets or sets the list of behaviors to attach to this element. */
5114
5169
  this.behaviors = [];
5115
- this._aria = new ElementAria(this, role, aria);
5170
+ this.#aria = new ElementAria(this, role, aria);
5116
5171
  }
5117
5172
  // #region ARIA
5118
- get aria() { return this._aria; }
5173
+ get aria() { return this.#aria; }
5174
+ #aria;
5119
5175
  // #endregion
5120
5176
  static #stdEvtsMemoizer = null;
5121
5177
  static get emittedEventTypes() {
@@ -5125,10 +5181,11 @@
5125
5181
  #parts;
5126
5182
  connectedCallback() {
5127
5183
  super.connectedCallback();
5128
- if (!Utils.isNullOrEmpty(this._aria.role)) {
5129
- this.setAttribute('role', this._aria.role);
5184
+ const aria = this.#aria;
5185
+ if (!Utils.isNullOrEmpty(aria.role)) {
5186
+ this.setAttribute('role', aria.role);
5130
5187
  }
5131
- let ariaAttrs = this._aria.attributes.toObject();
5188
+ let ariaAttrs = aria.attributes.toObject();
5132
5189
  if (!Utils.isNullOrEmpty(ariaAttrs)) {
5133
5190
  for (let name in ariaAttrs) {
5134
5191
  this.setAttribute('aria-' + name, ariaAttrs[name]);