@microsoft/fast-element 1.10.5 → 2.0.0-beta.10
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/.eslintrc.json +1 -12
- package/CHANGELOG.json +629 -6
- package/CHANGELOG.md +152 -5
- package/dist/dts/components/attributes.d.ts +14 -1
- package/dist/dts/components/{controller.d.ts → element-controller.d.ts} +32 -32
- package/dist/dts/components/fast-definitions.d.ts +51 -11
- package/dist/dts/components/fast-element.d.ts +18 -23
- package/dist/dts/context.d.ts +157 -0
- package/dist/{esm/observation/behavior.js → dts/debug.d.ts} +0 -0
- package/dist/dts/di/di.d.ts +899 -0
- package/dist/dts/index.d.ts +17 -16
- package/dist/dts/index.debug.d.ts +2 -0
- package/dist/dts/index.rollup.d.ts +2 -0
- package/dist/dts/index.rollup.debug.d.ts +3 -0
- package/dist/dts/interfaces.d.ts +176 -0
- package/dist/dts/metadata.d.ts +25 -0
- package/dist/dts/observation/arrays.d.ts +207 -0
- package/dist/dts/observation/notifier.d.ts +18 -18
- package/dist/dts/observation/observable.d.ts +117 -34
- package/dist/dts/observation/update-queue.d.ts +40 -0
- package/dist/dts/pending-task.d.ts +20 -0
- package/dist/dts/platform.d.ts +23 -66
- package/dist/dts/polyfills.d.ts +8 -0
- package/dist/dts/state/exports.d.ts +3 -0
- package/dist/dts/state/reactive.d.ts +8 -0
- package/dist/dts/state/state.d.ts +141 -0
- package/dist/dts/state/visitor.d.ts +6 -0
- package/dist/dts/state/watch.d.ts +10 -0
- package/dist/dts/styles/css-directive.d.ts +44 -6
- package/dist/dts/styles/css.d.ts +19 -3
- package/dist/dts/styles/element-styles.d.ts +49 -63
- package/dist/dts/styles/host.d.ts +68 -0
- package/dist/dts/templating/binding-signal.d.ts +21 -0
- package/dist/dts/templating/binding-two-way.d.ts +39 -0
- package/dist/dts/templating/binding.d.ts +101 -70
- package/dist/dts/templating/children.d.ts +18 -15
- package/dist/dts/templating/compiler.d.ts +46 -28
- package/dist/dts/templating/dom.d.ts +41 -0
- package/dist/dts/templating/html-directive.d.ts +239 -45
- package/dist/dts/templating/markup.d.ts +48 -0
- package/dist/dts/templating/node-observation.d.ts +45 -30
- package/dist/dts/templating/ref.d.ts +6 -20
- package/dist/dts/templating/render.d.ts +272 -0
- package/dist/dts/templating/repeat.d.ts +36 -33
- package/dist/dts/templating/slotted.d.ts +13 -14
- package/dist/dts/templating/template.d.ts +28 -22
- package/dist/dts/templating/view.d.ts +82 -24
- package/dist/dts/templating/when.d.ts +3 -3
- package/dist/dts/testing/exports.d.ts +3 -0
- package/dist/dts/testing/fakes.d.ts +4 -0
- package/dist/dts/testing/fixture.d.ts +84 -0
- package/dist/dts/testing/timeout.d.ts +7 -0
- package/dist/{tsdoc-metadata.json → dts/tsdoc-metadata.json} +1 -1
- package/dist/dts/utilities.d.ts +22 -0
- package/dist/esm/components/attributes.js +38 -28
- package/dist/esm/components/{controller.js → element-controller.js} +150 -140
- package/dist/esm/components/fast-definitions.js +48 -46
- package/dist/esm/components/fast-element.js +31 -12
- package/dist/esm/context.js +163 -0
- package/dist/esm/debug.js +61 -0
- package/dist/esm/di/di.js +1435 -0
- package/dist/esm/index.debug.js +2 -0
- package/dist/esm/index.js +20 -14
- package/dist/esm/index.rollup.debug.js +3 -0
- package/dist/esm/index.rollup.js +2 -0
- package/dist/esm/interfaces.js +12 -1
- package/dist/esm/metadata.js +60 -0
- package/dist/esm/observation/arrays.js +570 -0
- package/dist/esm/observation/notifier.js +27 -35
- package/dist/esm/observation/observable.js +116 -149
- package/dist/esm/observation/update-queue.js +67 -0
- package/dist/esm/pending-task.js +16 -0
- package/dist/esm/platform.js +60 -42
- package/dist/esm/polyfills.js +85 -0
- package/dist/esm/state/exports.js +3 -0
- package/dist/esm/state/reactive.js +34 -0
- package/dist/esm/state/state.js +148 -0
- package/dist/esm/state/visitor.js +28 -0
- package/dist/esm/state/watch.js +36 -0
- package/dist/esm/styles/css-directive.js +29 -13
- package/dist/esm/styles/css.js +29 -42
- package/dist/esm/styles/element-styles.js +79 -104
- package/dist/esm/styles/host.js +1 -0
- package/dist/esm/templating/binding-signal.js +83 -0
- package/dist/esm/templating/binding-two-way.js +103 -0
- package/dist/esm/templating/binding.js +189 -159
- package/dist/esm/templating/children.js +33 -23
- package/dist/esm/templating/compiler.js +258 -152
- package/dist/esm/templating/dom.js +49 -0
- package/dist/esm/templating/html-directive.js +193 -36
- package/dist/esm/templating/markup.js +75 -0
- package/dist/esm/templating/node-observation.js +51 -45
- package/dist/esm/templating/ref.js +8 -25
- package/dist/esm/templating/render.js +391 -0
- package/dist/esm/templating/repeat.js +83 -79
- package/dist/esm/templating/slotted.js +23 -20
- package/dist/esm/templating/template.js +51 -93
- package/dist/esm/templating/view.js +125 -46
- package/dist/esm/templating/when.js +6 -4
- package/dist/esm/testing/exports.js +3 -0
- package/dist/esm/testing/fakes.js +76 -0
- package/dist/esm/testing/fixture.js +86 -0
- package/dist/esm/testing/timeout.js +24 -0
- package/dist/esm/utilities.js +44 -0
- package/dist/fast-element.api.json +12153 -5373
- package/dist/fast-element.d.ts +1448 -696
- package/dist/fast-element.debug.js +4107 -0
- package/dist/fast-element.debug.min.js +1 -0
- package/dist/fast-element.js +3817 -4029
- package/dist/fast-element.min.js +1 -1
- package/dist/fast-element.untrimmed.d.ts +2814 -0
- package/docs/api-report.md +567 -254
- package/docs/fast-element-2-changes.md +15 -0
- package/karma.conf.cjs +6 -17
- package/package.json +76 -15
- package/dist/dts/dom.d.ts +0 -112
- package/dist/dts/observation/array-change-records.d.ts +0 -48
- package/dist/dts/observation/array-observer.d.ts +0 -9
- package/dist/dts/observation/behavior.d.ts +0 -19
- package/dist/esm/dom.js +0 -207
- package/dist/esm/observation/array-change-records.js +0 -326
- package/dist/esm/observation/array-observer.js +0 -177
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,163 @@
|
|
|
1
1
|
# Change Log - @microsoft/fast-element
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Mon, 03 Oct 2022 23:44:38 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## 2.0.0-beta.10
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Mon, 03 Oct 2022 23:44:38 GMT
|
|
10
10
|
|
|
11
|
-
###
|
|
11
|
+
### Changes
|
|
12
|
+
|
|
13
|
+
- fix: observation kernel missing binding observer disconnect method (roeisenb@microsoft.com)
|
|
14
|
+
- feat: less surprising class bindings w/ more flexibility for developers (roeisenb@microsoft.com)
|
|
15
|
+
- fix: don't allow registering FASTElement itself as a web component (roeisenb@microsoft.com)
|
|
16
|
+
|
|
17
|
+
## 2.0.0-beta.9
|
|
18
|
+
|
|
19
|
+
Wed, 28 Sep 2022 20:45:51 GMT
|
|
20
|
+
|
|
21
|
+
### Changes
|
|
22
|
+
|
|
23
|
+
- fix: ensure composed templates receive the existing execution context (roeisenb@microsoft.com)
|
|
24
|
+
|
|
25
|
+
## 2.0.0-beta.8
|
|
26
|
+
|
|
27
|
+
Tue, 27 Sep 2022 22:31:52 GMT
|
|
28
|
+
|
|
29
|
+
### Changes
|
|
30
|
+
|
|
31
|
+
- fix: correct view state when processing unbindables during rebind (roeisenb@microsoft.com)
|
|
32
|
+
- fix: do not crash when null/undefined is provided literally in templates (roeisenb@microsoft.com)
|
|
33
|
+
|
|
34
|
+
## 2.0.0-beta.7
|
|
35
|
+
|
|
36
|
+
Fri, 23 Sep 2022 22:53:27 GMT
|
|
37
|
+
|
|
38
|
+
### Changes
|
|
39
|
+
|
|
40
|
+
- feat: improve parent typing and fix repeat context type bug (roeisenb@microsoft.com)
|
|
41
|
+
- feat: prepare fast-element for scoped element registries (roeisenb@microsoft.com)
|
|
42
|
+
- persist totalAvailableViews to compare against removeIndex (wendywendy@microsoft.com)
|
|
43
|
+
- make ElementsFilter type arguments optional (863023+radium-v@users.noreply.github.com)
|
|
44
|
+
- fix(fast-element): attributes properly located in inheritance hierarchy (roeisenb@microsoft.com)
|
|
45
|
+
- Adds PendingTask community protocol (nicholasrice@users.noreply.github.com)
|
|
46
|
+
- feat: new behavior and context API design (roeisenb@microsoft.com)
|
|
47
|
+
- feat: implement getAsync code path for dependency injection (roeisenb@microsoft.com)
|
|
48
|
+
|
|
49
|
+
## 2.0.0-beta.6
|
|
50
|
+
|
|
51
|
+
Thu, 01 Sep 2022 21:53:34 GMT
|
|
52
|
+
|
|
53
|
+
### Changes
|
|
54
|
+
|
|
55
|
+
- feat: add new state, ownedState, and computedState APIs (roeisenb@microsoft.com)
|
|
56
|
+
|
|
57
|
+
## 2.0.0-beta.5
|
|
58
|
+
|
|
59
|
+
Thu, 18 Aug 2022 20:46:10 GMT
|
|
12
60
|
|
|
13
|
-
|
|
61
|
+
### Changes
|
|
62
|
+
|
|
63
|
+
- Fix ExpressionObserer bug where watcher was not reset if the binding threw (nicholasrice@users.noreply.github.com)
|
|
64
|
+
- make insertbefore noop in view (prudepixie@users.noreply.github.com)
|
|
65
|
+
- make sure default options for recycle gets set in different scenarios (prudepixie@users.noreply.github.com)
|
|
66
|
+
- refactor: remove dependency of DI on FASTElement (roeisenb@microsoft.com)
|
|
67
|
+
- add subpath export for package.json to packages (32497422+KingOfTac@users.noreply.github.com)
|
|
68
|
+
- change default array strategy to merge strategy, update repeat directive (prudepixie@users.noreply.github.com)
|
|
69
|
+
- assert FASTElement's type so that instanceof behavior is consistent with other class implementations (nicholasrice@users.noreply.github.com)
|
|
70
|
+
|
|
71
|
+
## 2.0.0-beta.4
|
|
72
|
+
|
|
73
|
+
Mon, 18 Jul 2022 21:10:01 GMT
|
|
74
|
+
|
|
75
|
+
### Changes
|
|
76
|
+
|
|
77
|
+
- feat: extract all error messages from context and DI (roeisenb@microsoft.com)
|
|
78
|
+
- feat: introduce new binding API (roeisenb@microsoft.com)
|
|
79
|
+
- Enabled DOM Container fallback functions when a container cannot be located. (roeisenb@microsoft.com)
|
|
80
|
+
- feat: add render directive, renderWith decorator, and RenderInstruction (roeisenb@microsoft.com)
|
|
81
|
+
- only store removed views if it can't be reused right away (prudepixie@users.noreply.github.com)
|
|
82
|
+
- fix: enable createElementTemplate to have undefined attributes (32497422+KingOfTac@users.noreply.github.com)
|
|
83
|
+
- use index to track reusable views (prudepixie@users.noreply.github.com)
|
|
84
|
+
- feat: enable render, repeat, and when template helpers to handle static data in addition to the already supported dynamic bindings (roeisenb@microsoft.com)
|
|
85
|
+
- fix: FASTElementDefinition#isDefined should be true only after define (roeisenb@microsoft.com)
|
|
86
|
+
- feat: move testing and dependency injection to fast-element (roeisenb@microsoft.com)
|
|
87
|
+
- fix: warn when host bindings are accidentally applied on non CE views (roeisenb@microsoft.com)
|
|
88
|
+
- feat: perf and safety improvements to fast element definition (roeisenb@microsoft.com)
|
|
89
|
+
|
|
90
|
+
## 2.0.0-beta.3
|
|
91
|
+
|
|
92
|
+
Wed, 22 Jun 2022 20:17:50 GMT
|
|
93
|
+
|
|
94
|
+
### Changes
|
|
95
|
+
|
|
96
|
+
- fix: correct aspect type for content that looks like an attribute (nicholasrice@users.noreply.github.com)
|
|
97
|
+
|
|
98
|
+
## 2.0.0-beta.2
|
|
99
|
+
|
|
100
|
+
Wed, 15 Jun 2022 17:41:10 GMT
|
|
101
|
+
|
|
102
|
+
### Changes
|
|
103
|
+
|
|
104
|
+
- doc: add note to FASTElement.metadata API (roeisenb@microsoft.com)
|
|
105
|
+
- when recycle is set to false while itemBinding stays the same, views should be recreated (wendy.hsu@microsoft.com)
|
|
106
|
+
- feat: simplify execution context to align closer with v1 (roeisenb@microsoft.com)
|
|
107
|
+
- feat: ergo improvements to context, array length, and metadata (roeisenb@microsoft.com)
|
|
108
|
+
- feat: move optional bindings out of rollup and list as exports (roeisenb@microsoft.com)
|
|
109
|
+
- fix: make SyntheticViewTemplate type a string so it is generally usable (roeisenb@microsoft.com)
|
|
110
|
+
- feat: implement W3C WC community context protocol and integrate with DI (roeisenb@microsoft.com)
|
|
111
|
+
|
|
112
|
+
## 2.0.0-beta.1
|
|
113
|
+
|
|
114
|
+
Wed, 01 Jun 2022 17:53:14 GMT
|
|
115
|
+
|
|
116
|
+
### Changes
|
|
117
|
+
|
|
118
|
+
- `DOM` - Tree Walker methods are no longer used and are thus removed. The API for removing child nodes has been removed as well since it was only used in one place and could be inlined. The helper `createCustomAttributePlaceholder()` no longer requires an attribute name. It will be uniquely generated internally. (roeisenb@microsoft.com)
|
|
119
|
+
- `class` - Bindings to `class` are now more nuanced. Binding directly to `class` will simply set the `className` property. If you need to bind to `class` knowing that manual JS will also manipulate the `classList` in addition to the binding, then you should now bind to `:classList` instead. This allows for performance optimizations in the simple, most common case. (roeisenb@microsoft.com)
|
|
120
|
+
- `Behavior` and `ViewBehavior` - `Behavior` now requires an `ExecutionContext` for `unbind`. Behaviors can be used for elements or views. `ViewBehavior` has been introduced for use exclusively with views, and provides some optimization opportunities. (roeisenb@microsoft.com)
|
|
121
|
+
- `RefBehavior` has been replaced with `RefDirective`. The directive also implements `ViewBehavior` allowing a single directive instance to be shared across all template instances that use the ref. (roeisenb@microsoft.com)
|
|
122
|
+
- Removed `SlottedBehavior` and `ChildrenBehavior` have been replaced with `SlottedDirective` and `ChildrenDirective`. These directives allow a single directive instance to be shared across all template instances that use the ref. (roeisenb@microsoft.com)
|
|
123
|
+
- Removed `AttachedBehaviorHTMLDirective` and `AttachedBehaviorType` since they are no longer used in the new directive/behavior architecture for ref, slotted, and children. (roeisenb@microsoft.com)
|
|
124
|
+
- Renamed `Notifier#source` to `Notifier#subject` to align with other observable terminology and prevent name clashes with `BindingObserver` properties. (roeisenb@microsoft.com)
|
|
125
|
+
- feat: create unified API for parsing markers (roeisenb@microsoft.com)
|
|
126
|
+
- allow null values in attributeChangedCallback (nicholasrice@users.noreply.github.com)
|
|
127
|
+
- feat: add splice strategies for array observation (roeisenb@microsoft.com)
|
|
128
|
+
- feat: handle existing shadow roots when upgrading (roeisenb@microsoft.com)
|
|
129
|
+
- fix: enable safer type inference on the repeat helper (roeisenb@microsoft.com)
|
|
130
|
+
- Set prerelease version (nicholasrice@users.noreply.github.com)
|
|
131
|
+
- refactor: separate update queue from DOM and fix architectural layers (roeisenb@microsoft.com)
|
|
132
|
+
- feat: aspected html directive exposes metadata (roeisenb@microsoft.com)
|
|
133
|
+
- `HTMLDirective` - The `targetIndex: number` property has been replaced by a `targetId: string` property. The `createBehavior` method no longer takes a target `Node` but instead takes a `BehaviorTargets` instance. The actual target can be looked up on the `BehaviorTargets` instance by indexing with the `targetId` property. (roeisenb@microsoft.com)
|
|
134
|
+
- `compileTemplate()` - Internals have been significantly changed. The implementation no longer uses a TreeWalker. The return type has change to an `HTMLTemplateCompilationResult` with different properties. (roeisenb@microsoft.com)
|
|
135
|
+
- refactor: move template/style resolution to lazy getter (roeisenb@microsoft.com)
|
|
136
|
+
- refactor: enable pluggable template compiler for SSR scenarios (roeisenb@microsoft.com)
|
|
137
|
+
- feat: enable pluggable style handling strategies (roeisenb@microsoft.com)
|
|
138
|
+
- fix(fast-element): do not notify splices for changes pre-subscription (roeisenb@microsoft.com)
|
|
139
|
+
- feat: new directive registration/identification model (roeisenb@microsoft.com)
|
|
140
|
+
- fix: prevent duplicative array observation patch (roeisenb@microsoft.com)
|
|
141
|
+
- Adds Aspect as public export (nicholasrice@users.noreply.github.com)
|
|
142
|
+
- feat: expose official Markup and Parser APIs (roeisenb@microsoft.com)
|
|
143
|
+
- refactor: refine binding mode types (roeisenb@microsoft.com)
|
|
144
|
+
- feat: add two-way binding (roeisenb@microsoft.com)
|
|
145
|
+
- fix: defend against for/in use on arrays (roeisenb@microsoft.com)
|
|
146
|
+
- fix: merge bug related to moved APIs (roeisenb@microsoft.com)
|
|
147
|
+
- feat: enable multiple instances of fast-element on a page at once (roeisenb@microsoft.com)
|
|
148
|
+
- Upgrade TypeScript (nicholasrice@users.noreply.github.com)
|
|
149
|
+
- enumerate fast-element package as a ES module package (nicholasrice@users.noreply.github.com)
|
|
150
|
+
- feat: enable array length observation (roeisenb@microsoft.com)
|
|
151
|
+
- feat: add utilities and hooks, and change exports (roeisenb@microsoft.com)
|
|
152
|
+
- refactor: new design for execution context (roeisenb@microsoft.com)
|
|
153
|
+
- chore: fast-element package and build modernization (roeisenb@microsoft.com)
|
|
154
|
+
- feat: new CSSDirective design (roeisenb@microsoft.com)
|
|
155
|
+
- chore: configure fast-element for internal stripping (roeisenb@microsoft.com)
|
|
156
|
+
- feat: enable synchronous dom updates for SSR (roeisenb@microsoft.com)
|
|
157
|
+
- refactor: extract polyfill and polyfill-like code to an optional module (roeisenb@microsoft.com)
|
|
158
|
+
- feat: add warn/error message infrastructure (roeisenb@microsoft.com)
|
|
159
|
+
- `View` and `HTMLView` - Type parameters added to enable strongly typed views based on their data source. The constructor of `HTMLView` has a new signature based on changes to the compiler's output. Internals have been cleaned up and no longer rely on the Range type. (roeisenb@microsoft.com)
|
|
160
|
+
- `ElementViewTemplate`, `SyntheticViewTemplate`, and `ViewTemplate` - Added type parameters throughout. Logic to instantiate and apply behaviors moved out of the template and into the view where it can be lazily executed. Removed the ability of the `render` method to take a string id of the node to render to. You must provide a node. (roeisenb@microsoft.com)
|
|
14
161
|
|
|
15
162
|
## 1.10.2
|
|
16
163
|
|
|
@@ -16,6 +16,8 @@ export interface ValueConverter {
|
|
|
16
16
|
*/
|
|
17
17
|
fromView(value: any): any;
|
|
18
18
|
}
|
|
19
|
+
declare const booleanMode = "boolean";
|
|
20
|
+
declare const reflectMode = "reflect";
|
|
19
21
|
/**
|
|
20
22
|
* The mode that specifies the runtime behavior of the attribute.
|
|
21
23
|
* @remarks
|
|
@@ -27,7 +29,7 @@ export interface ValueConverter {
|
|
|
27
29
|
* changes in the DOM, but does not reflect property changes back.
|
|
28
30
|
* @public
|
|
29
31
|
*/
|
|
30
|
-
export declare type AttributeMode =
|
|
32
|
+
export declare type AttributeMode = typeof reflectMode | typeof booleanMode | "fromView";
|
|
31
33
|
/**
|
|
32
34
|
* Metadata used to configure a custom attribute's behavior.
|
|
33
35
|
* @public
|
|
@@ -38,6 +40,16 @@ export declare type AttributeConfiguration = {
|
|
|
38
40
|
mode?: AttributeMode;
|
|
39
41
|
converter?: ValueConverter;
|
|
40
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Metadata used to configure a custom attribute's behavior.
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export declare const AttributeConfiguration: Readonly<{
|
|
48
|
+
/**
|
|
49
|
+
* Locates all attribute configurations associated with a type.
|
|
50
|
+
*/
|
|
51
|
+
locate: (target: {}) => AttributeConfiguration[];
|
|
52
|
+
}>;
|
|
41
53
|
/**
|
|
42
54
|
* Metadata used to configure a custom attribute's behavior through a decorator.
|
|
43
55
|
* @public
|
|
@@ -135,3 +147,4 @@ export declare function attr(config?: DecoratorAttributeConfiguration): (target:
|
|
|
135
147
|
* @public
|
|
136
148
|
*/
|
|
137
149
|
export declare function attr(target: {}, prop: string): void;
|
|
150
|
+
export {};
|
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HostBehavior, HostController } from "../styles/host.js";
|
|
2
2
|
import { PropertyChangeNotifier } from "../observation/notifier.js";
|
|
3
|
-
import type { ElementStyles } from "../styles/element-styles.js";
|
|
4
3
|
import type { ElementViewTemplate } from "../templating/template.js";
|
|
5
4
|
import type { ElementView } from "../templating/view.js";
|
|
5
|
+
import type { ElementStyles } from "../styles/element-styles.js";
|
|
6
6
|
import { FASTElementDefinition } from "./fast-definitions.js";
|
|
7
7
|
/**
|
|
8
8
|
* Controls the lifecycle and rendering of a `FASTElement`.
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
|
-
export declare class
|
|
11
|
+
export declare class ElementController<TElement extends HTMLElement = HTMLElement> extends PropertyChangeNotifier implements HostController<TElement> {
|
|
12
12
|
private boundObservables;
|
|
13
|
-
private behaviors;
|
|
14
13
|
private needsInitialization;
|
|
14
|
+
private hasExistingShadowRoot;
|
|
15
15
|
private _template;
|
|
16
|
-
private _styles;
|
|
17
16
|
private _isConnected;
|
|
17
|
+
private behaviors;
|
|
18
|
+
private _mainStyles;
|
|
18
19
|
/**
|
|
19
20
|
* This allows Observable.getNotifier(...) to return the Controller
|
|
20
21
|
* when the notifier for the Controller itself is being requested. The
|
|
@@ -27,7 +28,7 @@ export declare class Controller extends PropertyChangeNotifier {
|
|
|
27
28
|
/**
|
|
28
29
|
* The element being controlled by this controller.
|
|
29
30
|
*/
|
|
30
|
-
readonly
|
|
31
|
+
readonly source: TElement;
|
|
31
32
|
/**
|
|
32
33
|
* The element definition that instructs this controller
|
|
33
34
|
* in how to handle rendering and other platform integrations.
|
|
@@ -38,7 +39,7 @@ export declare class Controller extends PropertyChangeNotifier {
|
|
|
38
39
|
* @remarks
|
|
39
40
|
* If `null` then the element is managing its own rendering.
|
|
40
41
|
*/
|
|
41
|
-
readonly view: ElementView | null;
|
|
42
|
+
readonly view: ElementView<TElement> | null;
|
|
42
43
|
/**
|
|
43
44
|
* Indicates whether or not the custom element has been
|
|
44
45
|
* connected to the document.
|
|
@@ -50,15 +51,14 @@ export declare class Controller extends PropertyChangeNotifier {
|
|
|
50
51
|
* @remarks
|
|
51
52
|
* This value can only be accurately read after connect but can be set at any time.
|
|
52
53
|
*/
|
|
53
|
-
get template(): ElementViewTemplate | null;
|
|
54
|
-
set template(value: ElementViewTemplate | null);
|
|
54
|
+
get template(): ElementViewTemplate<TElement> | null;
|
|
55
|
+
set template(value: ElementViewTemplate<TElement> | null);
|
|
55
56
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* This value can only be accurately read after connect but can be set at any time.
|
|
57
|
+
* The main set of styles used for the component, independent
|
|
58
|
+
* of any dynamically added styles.
|
|
59
59
|
*/
|
|
60
|
-
get
|
|
61
|
-
set
|
|
60
|
+
get mainStyles(): ElementStyles | null;
|
|
61
|
+
set mainStyles(value: ElementStyles | null);
|
|
62
62
|
/**
|
|
63
63
|
* Creates a Controller to control the specified element.
|
|
64
64
|
* @param element - The element to be controlled by this controller.
|
|
@@ -66,43 +66,43 @@ export declare class Controller extends PropertyChangeNotifier {
|
|
|
66
66
|
* controller in how to handle rendering and other platform integrations.
|
|
67
67
|
* @internal
|
|
68
68
|
*/
|
|
69
|
-
constructor(element:
|
|
69
|
+
constructor(element: TElement, definition: FASTElementDefinition);
|
|
70
70
|
/**
|
|
71
|
-
* Adds
|
|
72
|
-
* @param
|
|
71
|
+
* Adds the behavior to the component.
|
|
72
|
+
* @param behavior - The behavior to add.
|
|
73
73
|
*/
|
|
74
|
-
|
|
74
|
+
addBehavior(behavior: HostBehavior<TElement>): void;
|
|
75
75
|
/**
|
|
76
|
-
* Removes
|
|
77
|
-
* @param
|
|
76
|
+
* Removes the behavior from the component.
|
|
77
|
+
* @param behavior - The behavior to remove.
|
|
78
|
+
* @param force - Forces removal even if this behavior was added more than once.
|
|
78
79
|
*/
|
|
79
|
-
|
|
80
|
+
removeBehavior(behavior: HostBehavior<TElement>, force?: boolean): void;
|
|
80
81
|
/**
|
|
81
|
-
* Adds
|
|
82
|
-
* @param
|
|
82
|
+
* Adds styles to this element. Providing an HTMLStyleElement will attach the element instance to the shadowRoot.
|
|
83
|
+
* @param styles - The styles to add.
|
|
83
84
|
*/
|
|
84
|
-
|
|
85
|
+
addStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
|
|
85
86
|
/**
|
|
86
|
-
* Removes
|
|
87
|
-
* @param
|
|
88
|
-
* @param force - Forces unbinding of behaviors.
|
|
87
|
+
* Removes styles from this element. Providing an HTMLStyleElement will detach the element instance from the shadowRoot.
|
|
88
|
+
* @param styles - the styles to remove.
|
|
89
89
|
*/
|
|
90
|
-
|
|
90
|
+
removeStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
|
|
91
91
|
/**
|
|
92
92
|
* Runs connected lifecycle behavior on the associated element.
|
|
93
93
|
*/
|
|
94
|
-
|
|
94
|
+
connect(): void;
|
|
95
95
|
/**
|
|
96
96
|
* Runs disconnected lifecycle behavior on the associated element.
|
|
97
97
|
*/
|
|
98
|
-
|
|
98
|
+
disconnect(): void;
|
|
99
99
|
/**
|
|
100
100
|
* Runs the attribute changed callback for the associated element.
|
|
101
101
|
* @param name - The name of the attribute that changed.
|
|
102
102
|
* @param oldValue - The previous value of the attribute.
|
|
103
103
|
* @param newValue - The new value of the attribute.
|
|
104
104
|
*/
|
|
105
|
-
onAttributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
105
|
+
onAttributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
106
106
|
/**
|
|
107
107
|
* Emits a custom HTML event.
|
|
108
108
|
* @param type - The type name of the event.
|
|
@@ -122,5 +122,5 @@ export declare class Controller extends PropertyChangeNotifier {
|
|
|
122
122
|
* registered either through the use of the {@link customElement}
|
|
123
123
|
* decorator or a call to `FASTElement.define`.
|
|
124
124
|
*/
|
|
125
|
-
static forCustomElement(element: HTMLElement):
|
|
125
|
+
static forCustomElement(element: HTMLElement): ElementController;
|
|
126
126
|
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
import { Constructable } from "../interfaces.js";
|
|
1
2
|
import { ComposableStyles, ElementStyles } from "../styles/element-styles.js";
|
|
2
3
|
import type { ElementViewTemplate } from "../templating/template.js";
|
|
3
4
|
import { AttributeConfiguration, AttributeDefinition } from "./attributes.js";
|
|
5
|
+
/**
|
|
6
|
+
* Shadow root initialization options.
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export interface ShadowRootOptions extends ShadowRootInit {
|
|
10
|
+
/**
|
|
11
|
+
* A registry that provides the custom elements visible
|
|
12
|
+
* from within this shadow root.
|
|
13
|
+
* @beta
|
|
14
|
+
*/
|
|
15
|
+
registry?: CustomElementRegistry;
|
|
16
|
+
}
|
|
4
17
|
/**
|
|
5
18
|
* Represents metadata configuration for a custom element.
|
|
6
19
|
* @public
|
|
@@ -24,19 +37,28 @@ export interface PartialFASTElementDefinition {
|
|
|
24
37
|
readonly attributes?: (AttributeConfiguration | string)[];
|
|
25
38
|
/**
|
|
26
39
|
* Options controlling the creation of the custom element's shadow DOM.
|
|
40
|
+
* @remarks
|
|
41
|
+
* If not provided, defaults to an open shadow root. Provide null
|
|
42
|
+
* to render to the associated template to the light DOM instead.
|
|
27
43
|
*/
|
|
28
|
-
readonly shadowOptions?: Partial<
|
|
44
|
+
readonly shadowOptions?: Partial<ShadowRootOptions> | null;
|
|
29
45
|
/**
|
|
30
46
|
* Options controlling how the custom element is defined with the platform.
|
|
31
47
|
*/
|
|
32
48
|
readonly elementOptions?: ElementDefinitionOptions;
|
|
49
|
+
/**
|
|
50
|
+
* The registry to register this component in by default.
|
|
51
|
+
* @remarks
|
|
52
|
+
* If not provided, defaults to the global registry.
|
|
53
|
+
*/
|
|
54
|
+
readonly registry?: CustomElementRegistry;
|
|
33
55
|
}
|
|
34
56
|
/**
|
|
35
57
|
* Defines metadata for a FASTElement.
|
|
36
58
|
* @public
|
|
37
59
|
*/
|
|
38
|
-
export declare class FASTElementDefinition<TType extends
|
|
39
|
-
private
|
|
60
|
+
export declare class FASTElementDefinition<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>> {
|
|
61
|
+
private platformDefined;
|
|
40
62
|
/**
|
|
41
63
|
* The type this element definition describes.
|
|
42
64
|
*/
|
|
@@ -72,26 +94,44 @@ export declare class FASTElementDefinition<TType extends Function = Function> {
|
|
|
72
94
|
/**
|
|
73
95
|
* Options controlling the creation of the custom element's shadow DOM.
|
|
74
96
|
*/
|
|
75
|
-
readonly shadowOptions?:
|
|
97
|
+
readonly shadowOptions?: ShadowRootOptions;
|
|
76
98
|
/**
|
|
77
99
|
* Options controlling how the custom element is defined with the platform.
|
|
78
100
|
*/
|
|
79
|
-
readonly elementOptions
|
|
101
|
+
readonly elementOptions: ElementDefinitionOptions;
|
|
80
102
|
/**
|
|
81
|
-
*
|
|
82
|
-
* @param type - The type this definition is being created for.
|
|
83
|
-
* @param nameOrConfig - The name of the element to define or a config object
|
|
84
|
-
* that describes the element to define.
|
|
103
|
+
* The registry to register this component in by default.
|
|
85
104
|
*/
|
|
86
|
-
|
|
105
|
+
readonly registry: CustomElementRegistry;
|
|
106
|
+
private constructor();
|
|
87
107
|
/**
|
|
88
108
|
* Defines a custom element based on this definition.
|
|
89
109
|
* @param registry - The element registry to define the element in.
|
|
110
|
+
* @remarks
|
|
111
|
+
* This operation is idempotent per registry.
|
|
90
112
|
*/
|
|
91
113
|
define(registry?: CustomElementRegistry): this;
|
|
114
|
+
/**
|
|
115
|
+
* Creates an instance of FASTElementDefinition.
|
|
116
|
+
* @param type - The type this definition is being created for.
|
|
117
|
+
* @param nameOrDef - The name of the element to define or a config object
|
|
118
|
+
* that describes the element to define.
|
|
119
|
+
*/
|
|
120
|
+
static compose<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition): FASTElementDefinition<TType>;
|
|
121
|
+
/**
|
|
122
|
+
* Registers a FASTElement base type.
|
|
123
|
+
* @param type - The type to register as a base type.
|
|
124
|
+
* @internal
|
|
125
|
+
*/
|
|
126
|
+
static registerBaseType(type: Function): void;
|
|
92
127
|
/**
|
|
93
128
|
* Gets the element definition associated with the specified type.
|
|
94
129
|
* @param type - The custom element type to retrieve the definition for.
|
|
95
130
|
*/
|
|
96
|
-
static readonly
|
|
131
|
+
static readonly getByType: (key: Function) => FASTElementDefinition<Constructable<HTMLElement>> | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Gets the element definition associated with the instance.
|
|
134
|
+
* @param instance - The custom element instance to retrieve the definition for.
|
|
135
|
+
*/
|
|
136
|
+
static readonly getForInstance: (object: any) => FASTElementDefinition<Constructable<HTMLElement>> | undefined;
|
|
97
137
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Constructable } from "../interfaces.js";
|
|
2
|
+
import { ElementController } from "./element-controller.js";
|
|
3
|
+
import { FASTElementDefinition, PartialFASTElementDefinition } from "./fast-definitions.js";
|
|
3
4
|
/**
|
|
4
5
|
* Represents a custom element based on the FASTElement infrastructure.
|
|
5
6
|
* @public
|
|
6
7
|
*/
|
|
7
|
-
export interface FASTElement {
|
|
8
|
+
export interface FASTElement extends HTMLElement {
|
|
8
9
|
/**
|
|
9
10
|
* The underlying controller that handles the lifecycle and rendering of
|
|
10
11
|
* this FASTElement.
|
|
11
12
|
*/
|
|
12
|
-
readonly $fastController:
|
|
13
|
+
readonly $fastController: ElementController;
|
|
13
14
|
/**
|
|
14
15
|
* Emits a custom HTML event.
|
|
15
16
|
* @param type - The type name of the event.
|
|
@@ -42,30 +43,23 @@ export interface FASTElement {
|
|
|
42
43
|
* This method is invoked by the platform whenever an observed
|
|
43
44
|
* attribute of FASTElement has a value change.
|
|
44
45
|
*/
|
|
45
|
-
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
46
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
46
47
|
}
|
|
48
|
+
declare function compose<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(this: TType, nameOrDef: string | PartialFASTElementDefinition): FASTElementDefinition<TType>;
|
|
49
|
+
declare function compose<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition): FASTElementDefinition<TType>;
|
|
50
|
+
declare function define<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(this: TType, nameOrDef: string | PartialFASTElementDefinition): TType;
|
|
51
|
+
declare function define<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>>(type: TType, nameOrDef?: string | PartialFASTElementDefinition): TType;
|
|
52
|
+
declare function from<TBase extends typeof HTMLElement>(BaseType: TBase): new () => InstanceType<TBase> & FASTElement;
|
|
47
53
|
/**
|
|
48
54
|
* A minimal base class for FASTElements that also provides
|
|
49
55
|
* static helpers for working with FASTElements.
|
|
50
56
|
* @public
|
|
51
57
|
*/
|
|
52
|
-
export declare const FASTElement:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*/
|
|
58
|
-
from<TBase extends {
|
|
59
|
-
new (): HTMLElement;
|
|
60
|
-
prototype: HTMLElement;
|
|
61
|
-
}>(BaseType: TBase): new () => InstanceType<TBase> & FASTElement;
|
|
62
|
-
/**
|
|
63
|
-
* Defines a platform custom element based on the provided type and definition.
|
|
64
|
-
* @param type - The custom element type to define.
|
|
65
|
-
* @param nameOrDef - The name of the element to define or a definition object
|
|
66
|
-
* that describes the element to define.
|
|
67
|
-
*/
|
|
68
|
-
define<TType extends Function>(type: TType, nameOrDef?: string | PartialFASTElementDefinition | undefined): TType;
|
|
58
|
+
export declare const FASTElement: {
|
|
59
|
+
new (): FASTElement;
|
|
60
|
+
define: typeof define;
|
|
61
|
+
compose: typeof compose;
|
|
62
|
+
from: typeof from;
|
|
69
63
|
};
|
|
70
64
|
/**
|
|
71
65
|
* Decorator: Defines a platform custom element based on `FASTElement`.
|
|
@@ -73,4 +67,5 @@ export declare const FASTElement: (new () => HTMLElement & FASTElement) & {
|
|
|
73
67
|
* that describes the element to define.
|
|
74
68
|
* @public
|
|
75
69
|
*/
|
|
76
|
-
export declare function customElement(nameOrDef: string | PartialFASTElementDefinition): (type:
|
|
70
|
+
export declare function customElement(nameOrDef: string | PartialFASTElementDefinition): (type: Constructable<HTMLElement>) => void;
|
|
71
|
+
export {};
|