@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
@@ -80,13 +80,10 @@ export class AttributeDefinition implements Accessor {
80
80
  // @public
81
81
  export type AttributeMode = typeof reflectMode | typeof booleanMode | "fromView";
82
82
 
83
- // @public
84
- export function bind<T = any>(expression: Expression<T>, policy?: DOMPolicy, isVolatile?: boolean): Binding<T>;
85
-
86
83
  // @public
87
84
  export abstract class Binding<TSource = any, TReturn = any, TParent = any> {
88
85
  constructor(evaluate: Expression<TSource, TReturn, TParent>, policy?: DOMPolicy | undefined, isVolatile?: boolean);
89
- abstract createObserver(directive: HTMLDirective, subscriber: Subscriber): ExpressionObserver<TSource, TReturn, TParent>;
86
+ abstract createObserver(subscriber: Subscriber, directive: BindingDirective): ExpressionObserver<TSource, TReturn, TParent>;
90
87
  // (undocumented)
91
88
  evaluate: Expression<TSource, TReturn, TParent>;
92
89
  // (undocumented)
@@ -96,6 +93,13 @@ export abstract class Binding<TSource = any, TReturn = any, TParent = any> {
96
93
  policy?: DOMPolicy | undefined;
97
94
  }
98
95
 
96
+ // @public
97
+ export interface BindingDirective {
98
+ readonly aspectType?: DOMAspect;
99
+ readonly dataBinding: Binding;
100
+ readonly targetAspect?: string;
101
+ }
102
+
99
103
  // @public
100
104
  export const booleanConverter: ValueConverter;
101
105
 
@@ -175,19 +179,30 @@ export interface ContentView {
175
179
  unbind(): void;
176
180
  }
177
181
 
178
- // Warning: (ae-internal-missing-underscore) The name "createMetadataLocator" should be prefixed with an underscore because the declaration is marked as @internal
179
- //
180
- // @internal
181
- export function createMetadataLocator<TMetadata>(): (target: {}) => TMetadata[];
182
-
183
- // Warning: (ae-internal-missing-underscore) The name "createTypeRegistry" should be prefixed with an underscore because the declaration is marked as @internal
184
- //
185
- // @internal
186
- export function createTypeRegistry<TDefinition extends TypeDefinition>(): TypeRegistry<TDefinition>;
187
-
188
182
  // @public
189
183
  export const css: CSSTemplateTag;
190
184
 
185
+ // @public
186
+ export class CSSBindingDirective implements HostBehavior, Subscriber, CSSDirective, BindingDirective {
187
+ constructor(dataBinding: Binding, targetAspect: string);
188
+ addedCallback(controller: HostController<HTMLElement & {
189
+ $cssBindings: Map<CSSBindingDirective, CSSBindingEntry>;
190
+ }>): void;
191
+ connectedCallback(controller: HostController<HTMLElement & {
192
+ $cssBindings: Map<CSSBindingDirective, CSSBindingEntry>;
193
+ }>): void;
194
+ createCSS(add: AddBehavior): ComposableStyles;
195
+ // (undocumented)
196
+ readonly dataBinding: Binding;
197
+ // @internal
198
+ handleChange(_: any, observer: ExpressionObserver): void;
199
+ removedCallback(controller: HostController<HTMLElement & {
200
+ $cssBindings: Map<CSSBindingDirective, CSSBindingEntry>;
201
+ }>): void;
202
+ // (undocumented)
203
+ readonly targetAspect: string;
204
+ }
205
+
191
206
  // @public
192
207
  export interface CSSDirective {
193
208
  createCSS(add: AddBehavior): ComposableStyles;
@@ -209,10 +224,13 @@ export interface CSSDirectiveDefinition<TType extends Constructable<CSSDirective
209
224
  }
210
225
 
211
226
  // @public
212
- export type CSSTemplateTag = ((strings: TemplateStringsArray, ...values: (ComposableStyles | CSSDirective)[]) => ElementStyles) & {
213
- partial(strings: TemplateStringsArray, ...values: (ComposableStyles | CSSDirective)[]): CSSDirective;
227
+ export type CSSTemplateTag = (<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: CSSValue<TSource, TParent>[]) => ElementStyles) & {
228
+ partial<TSource = any, TParent = any>(strings: TemplateStringsArray, ...values: CSSValue<TSource, TParent>[]): CSSDirective;
214
229
  };
215
230
 
231
+ // @public
232
+ export type CSSValue<TSource, TParent = any> = Expression<TSource, any, TParent> | Binding<TSource, any, TParent> | ComposableStyles | CSSDirective;
233
+
216
234
  // @public
217
235
  export function customElement(nameOrDef: string | PartialFASTElementDefinition): (type: Constructable<HTMLElement>) => void;
218
236
 
@@ -262,22 +280,26 @@ export class ElementController<TElement extends HTMLElement = HTMLElement> exten
262
280
  addBehavior(behavior: HostBehavior<TElement>): void;
263
281
  addStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
264
282
  connect(): void;
283
+ get context(): ExecutionContext;
265
284
  readonly definition: FASTElementDefinition;
266
285
  disconnect(): void;
267
286
  emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): void | boolean;
268
287
  static forCustomElement(element: HTMLElement): ElementController;
288
+ get isBound(): boolean;
269
289
  get isConnected(): boolean;
270
290
  get mainStyles(): ElementStyles | null;
271
291
  set mainStyles(value: ElementStyles | null);
272
292
  onAttributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
293
+ onUnbind(behavior: {
294
+ unbind(controller: ExpressionController<TElement>): any;
295
+ }): void;
273
296
  removeBehavior(behavior: HostBehavior<TElement>, force?: boolean): void;
274
297
  removeStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
275
298
  static setStrategy(strategy: ElementControllerStrategy): void;
276
299
  readonly source: TElement;
300
+ get sourceLifetime(): SourceLifetime | undefined;
277
301
  get template(): ElementViewTemplate<TElement> | null;
278
302
  set template(value: ElementViewTemplate<TElement> | null);
279
- // @internal
280
- toJSON: () => undefined;
281
303
  readonly view: ElementView<TElement> | null;
282
304
  }
283
305
 
@@ -316,6 +338,10 @@ export class ElementStyles {
316
338
  // @public
317
339
  export interface ElementView<TSource = any, TParent = any> extends View<TSource, TParent> {
318
340
  appendTo(node: Node): void;
341
+ onUnbind(behavior: {
342
+ unbind(controller: ViewController<TSource, TParent>): any;
343
+ }): void;
344
+ readonly sourceLifetime?: SourceLifetime;
319
345
  }
320
346
 
321
347
  // @public
@@ -376,9 +402,7 @@ export interface ExpressionObserver<TSource = any, TReturn = any, TParent = any>
376
402
  bind(controller: ExpressionController<TSource, TParent>): TReturn;
377
403
  }
378
404
 
379
- // Warning: (ae-internal-missing-underscore) The name "FAST" should be prefixed with an underscore because the declaration is marked as @internal
380
- //
381
- // @internal
405
+ // @public
382
406
  export const FAST: FASTGlobal;
383
407
 
384
408
  // @public
@@ -419,9 +443,7 @@ export class FASTElementDefinition<TType extends Constructable<HTMLElement> = Co
419
443
  readonly type: TType;
420
444
  }
421
445
 
422
- // Warning: (ae-internal-missing-underscore) The name "FASTGlobal" should be prefixed with an underscore because the declaration is marked as @internal
423
- //
424
- // @internal
446
+ // @public
425
447
  export interface FASTGlobal {
426
448
  addMessages(messages: Record<number, string>): void;
427
449
  error(code: number, values?: Record<string, any>): Error;
@@ -441,21 +463,20 @@ export interface HostBehavior<TSource = any> {
441
463
  }
442
464
 
443
465
  // @public
444
- export interface HostController<TSource = any> {
466
+ export interface HostController<TSource = any> extends ExpressionController<TSource> {
445
467
  addBehavior(behavior: HostBehavior<TSource>): void;
446
468
  addStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
447
469
  readonly isConnected: boolean;
448
470
  mainStyles: ElementStyles | null;
449
471
  removeBehavior(behavior: HostBehavior<TSource>, force?: boolean): void;
450
472
  removeStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
451
- readonly source: TSource;
452
473
  }
453
474
 
454
475
  // @public
455
476
  export const html: HTMLTemplateTag;
456
477
 
457
478
  // @public
458
- export class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected {
479
+ export class HTMLBindingDirective implements HTMLDirective, ViewBehaviorFactory, ViewBehavior, Aspected, BindingDirective {
459
480
  constructor(dataBinding: Binding);
460
481
  aspectType: DOMAspect;
461
482
  // @internal (undocumented)
@@ -542,8 +563,6 @@ export class HTMLView<TSource = any, TParent = any> implements ElementView<TSour
542
563
  readonly sourceLifetime: SourceLifetime;
543
564
  // (undocumented)
544
565
  readonly targets: ViewBehaviorTargets;
545
- // @internal
546
- toJSON: () => undefined;
547
566
  unbind(): void;
548
567
  }
549
568
 
@@ -593,9 +612,6 @@ export abstract class NodeObservationDirective<T extends NodeBehaviorOptions> ex
593
612
  protected updateTarget(source: any, value: ReadonlyArray<any>): void;
594
613
  }
595
614
 
596
- // @public
597
- export function normalizeBinding<TSource = any, TReturn = any, TParent = any>(value: Expression<TSource, TReturn, TParent> | Binding<TSource, TReturn, TParent> | {}): Binding<TSource, TReturn, TParent>;
598
-
599
615
  // @public
600
616
  export interface Notifier {
601
617
  notify(args: any): void;
@@ -635,6 +651,9 @@ export interface ObservationRecord {
635
651
  // @public
636
652
  export function oneTime<T = any>(expression: Expression<T>, policy?: DOMPolicy): Binding<T>;
637
653
 
654
+ // @public
655
+ export function oneWay<T = any>(expression: Expression<T>, policy?: DOMPolicy, isVolatile?: boolean): Binding<T>;
656
+
638
657
  // @public
639
658
  export const Parser: Readonly<{
640
659
  parse(value: string, factories: Record<string, ViewBehaviorFactory>): (string | ViewBehaviorFactory)[] | null;
@@ -688,7 +707,7 @@ export class RepeatBehavior<TSource = any> implements ViewBehavior, Subscriber {
688
707
  }
689
708
 
690
709
  // @public
691
- export class RepeatDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory {
710
+ export class RepeatDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory, BindingDirective {
692
711
  constructor(dataBinding: Binding<TSource>, templateBinding: Binding<TSource, SyntheticViewTemplate>, options: RepeatOptions);
693
712
  createBehavior(): RepeatBehavior<TSource>;
694
713
  createHTML(add: AddViewBehaviorFactory): string;
@@ -788,8 +807,6 @@ export abstract class StatelessAttachedAttributeDirective<TOptions> implements H
788
807
  createHTML(add: AddViewBehaviorFactory): string;
789
808
  // (undocumented)
790
809
  protected options: TOptions;
791
- // @internal
792
- toJSON: () => undefined;
793
810
  }
794
811
 
795
812
  // @public
@@ -849,26 +866,6 @@ export type TrustedTypesPolicy = {
849
866
  createHTML(html: string): string;
850
867
  };
851
868
 
852
- // Warning: (ae-internal-missing-underscore) The name "TypeDefinition" should be prefixed with an underscore because the declaration is marked as @internal
853
- //
854
- // @internal
855
- export interface TypeDefinition {
856
- // (undocumented)
857
- type: Function;
858
- }
859
-
860
- // Warning: (ae-internal-missing-underscore) The name "TypeRegistry" should be prefixed with an underscore because the declaration is marked as @internal
861
- //
862
- // @internal
863
- export interface TypeRegistry<TDefinition extends TypeDefinition> {
864
- // (undocumented)
865
- getByType(key: Function): TDefinition | undefined;
866
- // (undocumented)
867
- getForInstance(object: any): TDefinition | undefined;
868
- // (undocumented)
869
- register(definition: TDefinition): boolean;
870
- }
871
-
872
869
  // @public
873
870
  export interface UpdateQueue {
874
871
  enqueue(callable: Callable): void;
@@ -890,6 +887,7 @@ export interface ValueConverter {
890
887
  export interface View<TSource = any, TParent = any> extends Disposable {
891
888
  bind(source: TSource, context?: ExecutionContext<TParent>): void;
892
889
  readonly context: ExecutionContext<TParent>;
890
+ readonly isBound: boolean;
893
891
  readonly source: TSource | null;
894
892
  unbind(): void;
895
893
  }
@@ -927,8 +925,6 @@ export class ViewTemplate<TSource = any, TParent = any> implements ElementViewTe
927
925
  readonly html: string | HTMLTemplateElement;
928
926
  inline(): CaptureType<TSource, TParent>;
929
927
  render(source: TSource, host: Node, hostBindingTarget?: Element): HTMLView<TSource, TParent>;
930
- // @internal
931
- toJSON: () => undefined;
932
928
  withPolicy(policy: DOMPolicy): this;
933
929
  }
934
930
 
@@ -943,6 +939,7 @@ export function when<TSource = any, TReturn = any, TParent = any>(condition: Exp
943
939
  // dist/dts/components/fast-element.d.ts:60:5 - (ae-forgotten-export) The symbol "define" needs to be exported by the entry point index.d.ts
944
940
  // dist/dts/components/fast-element.d.ts:61:5 - (ae-forgotten-export) The symbol "compose" needs to be exported by the entry point index.d.ts
945
941
  // dist/dts/components/fast-element.d.ts:62:5 - (ae-forgotten-export) The symbol "from" needs to be exported by the entry point index.d.ts
942
+ // dist/dts/styles/css-binding-directive.d.ts:35:9 - (ae-forgotten-export) The symbol "CSSBindingEntry" needs to be exported by the entry point index.d.ts
946
943
 
947
944
  // (No @packageDocumentation comment for this package)
948
945
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@microsoft/fast-element",
3
3
  "description": "A library for constructing Web Components",
4
- "version": "2.0.0-beta.20",
4
+ "version": "2.0.0-beta.22",
5
5
  "author": {
6
6
  "name": "Microsoft",
7
7
  "url": "https://discord.gg/FcSNfg4"
@@ -31,12 +31,12 @@
31
31
  "default": "./dist/esm/debug.js"
32
32
  },
33
33
  "./binding/two-way": {
34
- "types": "./dist/dts/templating/binding-two-way.d.ts",
35
- "default": "./dist/esm/templating/binding-two-way.js"
34
+ "types": "./dist/dts/binding/two-way.d.ts",
35
+ "default": "./dist/esm/binding/two-way.js"
36
36
  },
37
37
  "./binding/signal": {
38
- "types": "./dist/dts/templating/binding-signal.d.ts",
39
- "default": "./dist/esm/templating/binding-signal.js"
38
+ "types": "./dist/dts/binding/signal.d.ts",
39
+ "default": "./dist/esm/binding/signal.js"
40
40
  },
41
41
  "./render": {
42
42
  "types": "./dist/dts/templating/render.d.ts",