@microsoft/fast-element 2.0.0-beta.20 → 2.0.0-beta.22

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 (64) hide show
  1. package/CHANGELOG.json +54 -0
  2. package/CHANGELOG.md +21 -1
  3. package/dist/dts/binding/binding.d.ts +49 -0
  4. package/dist/dts/binding/normalize.d.ts +9 -0
  5. package/dist/dts/binding/one-time.d.ts +11 -0
  6. package/dist/dts/binding/one-way.d.ts +20 -0
  7. package/dist/dts/{templating/binding-signal.d.ts → binding/signal.d.ts} +1 -1
  8. package/dist/dts/{templating/binding-two-way.d.ts → binding/two-way.d.ts} +3 -4
  9. package/dist/dts/components/element-controller.d.ts +20 -5
  10. package/dist/dts/context.d.ts +26 -13
  11. package/dist/dts/dom-policy.d.ts +15 -0
  12. package/dist/dts/index.d.ts +6 -2
  13. package/dist/dts/interfaces.d.ts +6 -5
  14. package/dist/dts/metadata.d.ts +6 -5
  15. package/dist/dts/pending-task.d.ts +19 -7
  16. package/dist/dts/platform.d.ts +10 -2
  17. package/dist/dts/styles/css-binding-directive.d.ts +60 -0
  18. package/dist/dts/styles/css.d.ts +9 -2
  19. package/dist/dts/styles/host.d.ts +2 -5
  20. package/dist/dts/templating/{binding.d.ts → html-binding-directive.d.ts} +3 -34
  21. package/dist/dts/templating/html-directive.d.ts +3 -35
  22. package/dist/dts/templating/render.d.ts +19 -5
  23. package/dist/dts/templating/repeat.d.ts +3 -2
  24. package/dist/dts/templating/template.d.ts +2 -6
  25. package/dist/dts/templating/view.d.ts +16 -6
  26. package/dist/dts/testing/fakes.d.ts +2 -1
  27. package/dist/dts/utilities.d.ts +3 -2
  28. package/dist/esm/binding/binding.js +18 -0
  29. package/dist/esm/binding/normalize.js +17 -0
  30. package/dist/esm/binding/one-time.js +21 -0
  31. package/dist/esm/binding/one-way.js +30 -0
  32. package/dist/esm/{templating/binding-signal.js → binding/signal.js} +5 -8
  33. package/dist/esm/{templating/binding-two-way.js → binding/two-way.js} +11 -15
  34. package/dist/esm/components/element-controller.js +33 -9
  35. package/dist/esm/context.js +24 -3
  36. package/dist/esm/debug.js +1 -0
  37. package/dist/esm/di/di.js +5 -5
  38. package/dist/esm/dom-policy.js +9 -1
  39. package/dist/esm/index.js +8 -2
  40. package/dist/esm/interfaces.js +3 -3
  41. package/dist/esm/metadata.js +11 -8
  42. package/dist/esm/observation/observable.js +3 -6
  43. package/dist/esm/pending-task.js +13 -1
  44. package/dist/esm/platform.js +10 -1
  45. package/dist/esm/styles/css-binding-directive.js +76 -0
  46. package/dist/esm/styles/css.js +14 -2
  47. package/dist/esm/templating/compiler.js +2 -1
  48. package/dist/esm/templating/{binding.js → html-binding-directive.js} +3 -70
  49. package/dist/esm/templating/html-directive.js +2 -25
  50. package/dist/esm/templating/render.js +25 -12
  51. package/dist/esm/templating/repeat.js +3 -3
  52. package/dist/esm/templating/template.js +9 -10
  53. package/dist/esm/templating/view.js +2 -6
  54. package/dist/esm/testing/fakes.js +1 -1
  55. package/dist/esm/utilities.js +3 -2
  56. package/dist/fast-element.api.json +1827 -663
  57. package/dist/fast-element.d.ts +167 -43
  58. package/dist/fast-element.debug.js +227 -120
  59. package/dist/fast-element.debug.min.js +1 -1
  60. package/dist/fast-element.js +226 -120
  61. package/dist/fast-element.min.js +1 -1
  62. package/dist/fast-element.untrimmed.d.ts +134 -82
  63. package/docs/api-report.md +54 -57
  64. package/package.json +5 -5
@@ -1,10 +1,10 @@
1
1
  import { Observable } from "../observation/observable.js";
2
2
  import { emptyArray } from "../platform.js";
3
3
  import { ArrayObserver } from "../observation/arrays.js";
4
+ import { normalizeBinding } from "../binding/normalize.js";
4
5
  import { Markup } from "./markup.js";
5
6
  import { HTMLDirective, } from "./html-directive.js";
6
7
  import { HTMLView } from "./view.js";
7
- import { normalizeBinding } from "./binding.js";
8
8
  const defaultRepeatOptions = Object.freeze({
9
9
  positioning: false,
10
10
  recycle: true,
@@ -42,8 +42,8 @@ export class RepeatBehavior {
42
42
  this.bindView = bindWithoutPositioning;
43
43
  /** @internal */
44
44
  this.views = [];
45
- this.itemsBindingObserver = directive.dataBinding.createObserver(directive, this);
46
- this.templateBindingObserver = directive.templateBinding.createObserver(directive, this);
45
+ this.itemsBindingObserver = directive.dataBinding.createObserver(this, directive);
46
+ this.templateBindingObserver = directive.templateBinding.createObserver(this, directive);
47
47
  if (directive.options.positioning) {
48
48
  this.bindView = bindWithPositioning;
49
49
  }
@@ -1,8 +1,11 @@
1
- import { isFunction, isString, noop } from "../interfaces.js";
2
- import { FAST } from "../platform.js";
3
- import { bind, HTMLBindingDirective, oneTime } from "./binding.js";
1
+ import { isFunction, isString } from "../interfaces.js";
2
+ import { Binding } from "../binding/binding.js";
3
+ import { FAST, makeSerializationNoop } from "../platform.js";
4
+ import { oneWay } from "../binding/one-way.js";
5
+ import { oneTime } from "../binding/one-time.js";
6
+ import { HTMLBindingDirective } from "./html-binding-directive.js";
4
7
  import { Compiler } from "./compiler.js";
5
- import { Binding, HTMLDirective, } from "./html-directive.js";
8
+ import { HTMLDirective, } from "./html-directive.js";
6
9
  import { nextId } from "./markup.js";
7
10
  // Much thanks to LitHTML for working this out!
8
11
  const lastAttributeNameRegex =
@@ -62,11 +65,6 @@ export class ViewTemplate {
62
65
  constructor(html, factories = {}, policy) {
63
66
  this.policy = policy;
64
67
  this.result = null;
65
- /**
66
- * Opts out of JSON stringification.
67
- * @internal
68
- */
69
- this.toJSON = noop;
70
68
  this.html = html;
71
69
  this.factories = factories;
72
70
  }
@@ -145,7 +143,7 @@ export class ViewTemplate {
145
143
  let definition;
146
144
  html += currentString;
147
145
  if (isFunction(currentValue)) {
148
- currentValue = new HTMLBindingDirective(bind(currentValue));
146
+ currentValue = new HTMLBindingDirective(oneWay(currentValue));
149
147
  }
150
148
  else if (currentValue instanceof Binding) {
151
149
  currentValue = new HTMLBindingDirective(currentValue);
@@ -159,6 +157,7 @@ export class ViewTemplate {
159
157
  return new ViewTemplate(html + strings[strings.length - 1], factories, policy);
160
158
  }
161
159
  }
160
+ makeSerializationNoop(ViewTemplate);
162
161
  /**
163
162
  * Transforms a template literal string into a ViewTemplate.
164
163
  * @param strings - The string fragments that are interpolated with the values.
@@ -1,5 +1,5 @@
1
- import { noop } from "../interfaces.js";
2
1
  import { ExecutionContext, Observable, SourceLifetime, } from "../observation/observable.js";
2
+ import { makeSerializationNoop } from "../platform.js";
3
3
  function removeNodeSequence(firstNode, lastNode) {
4
4
  const parent = firstNode.parentNode;
5
5
  let current = firstNode;
@@ -51,11 +51,6 @@ export class HTMLView {
51
51
  * The length of the current collection within a repeat context.
52
52
  */
53
53
  this.length = 0;
54
- /**
55
- * Opts out of JSON stringification.
56
- * @internal
57
- */
58
- this.toJSON = noop;
59
54
  this.firstChild = fragment.firstChild;
60
55
  this.lastChild = fragment.lastChild;
61
56
  }
@@ -236,5 +231,6 @@ export class HTMLView {
236
231
  }
237
232
  }
238
233
  }
234
+ makeSerializationNoop(HTMLView);
239
235
  Observable.defineProperty(HTMLView.prototype, "index");
240
236
  Observable.defineProperty(HTMLView.prototype, "length");
@@ -1,5 +1,5 @@
1
- import { ExecutionContext, } from "../index.js";
2
1
  import { noop } from "../interfaces.js";
2
+ import { ExecutionContext } from "../observation/observable.js";
3
3
  export const Fake = Object.freeze({
4
4
  executionContext(parent, parentContext) {
5
5
  return {
@@ -28,7 +28,7 @@ export function composedParent(element) {
28
28
  * Determines if the reference element contains the test element in a "composed" DOM tree that
29
29
  * ignores shadow DOM boundaries.
30
30
  *
31
- * Returns true of the test element is a descendent of the reference, or exist in
31
+ * Returns true of the test element is a descendent of the reference, or exists in
32
32
  * a shadow DOM that is a logical descendent of the reference. Otherwise returns false.
33
33
  * @param reference - The element to test for containment against.
34
34
  * @param test - The element being tested for containment.
@@ -46,11 +46,12 @@ export function composedContains(reference, test) {
46
46
  return false;
47
47
  }
48
48
  /**
49
+ * An extension of MutationObserver that supports unobserving nodes.
49
50
  * @internal
50
51
  */
51
52
  export class UnobservableMutationObserver extends MutationObserver {
52
53
  /**
53
- * An extension of MutationObserver that supports unobserving nodes.
54
+ * Creates an instance of UnobservableMutationObserver.
54
55
  * @param callback - The callback to invoke when observed nodes are changed.
55
56
  */
56
57
  constructor(callback) {