@rxdi/lit-html 0.7.157 → 0.7.159

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 (95) hide show
  1. package/dist/async.d.ts +3 -3
  2. package/dist/async.js +4 -4
  3. package/dist/decorators/component.decorator.d.ts +1 -2
  4. package/dist/decorators/component.decorator.js +3 -3
  5. package/dist/index.d.ts +28 -17
  6. package/dist/index.js +28 -17
  7. package/package.json +4 -2
  8. package/dist/lit-element/decorators.d.ts +0 -14
  9. package/dist/lit-element/decorators.js +0 -32
  10. package/dist/lit-element/experimental-hydrate-support.d.ts +0 -6
  11. package/dist/lit-element/experimental-hydrate-support.js +0 -65
  12. package/dist/lit-element/index.d.ts +0 -7
  13. package/dist/lit-element/index.js +0 -25
  14. package/dist/lit-element/lit-element.d.ts +0 -157
  15. package/dist/lit-element/lit-element.js +0 -258
  16. package/dist/lit-element/polyfill-support.d.ts +0 -24
  17. package/dist/lit-element/polyfill-support.js +0 -58
  18. package/dist/lit-element/private-ssr-support.d.ts +0 -21
  19. package/dist/lit-element/private-ssr-support.js +0 -25
  20. package/dist/lit-html/async-directive.d.ts +0 -170
  21. package/dist/lit-html/async-directive.js +0 -250
  22. package/dist/lit-html/directive-helpers.d.ts +0 -105
  23. package/dist/lit-html/directive-helpers.js +0 -192
  24. package/dist/lit-html/directive.d.ts +0 -65
  25. package/dist/lit-html/directive.js +0 -52
  26. package/dist/lit-html/directives/async-append.d.ts +0 -38
  27. package/dist/lit-html/directives/async-append.js +0 -55
  28. package/dist/lit-html/directives/async-replace.d.ts +0 -39
  29. package/dist/lit-html/directives/async-replace.js +0 -112
  30. package/dist/lit-html/directives/cache.d.ts +0 -34
  31. package/dist/lit-html/directives/cache.js +0 -80
  32. package/dist/lit-html/directives/class-map.d.ts +0 -44
  33. package/dist/lit-html/directives/class-map.js +0 -92
  34. package/dist/lit-html/directives/guard.d.ts +0 -59
  35. package/dist/lit-html/directives/guard.js +0 -82
  36. package/dist/lit-html/directives/if-defined.d.ts +0 -13
  37. package/dist/lit-html/directives/if-defined.js +0 -17
  38. package/dist/lit-html/directives/live.d.ts +0 -42
  39. package/dist/lit-html/directives/live.js +0 -79
  40. package/dist/lit-html/directives/private-async-helpers.d.ts +0 -57
  41. package/dist/lit-html/directives/private-async-helpers.js +0 -117
  42. package/dist/lit-html/directives/ref.d.ts +0 -65
  43. package/dist/lit-html/directives/ref.js +0 -113
  44. package/dist/lit-html/directives/repeat.d.ts +0 -63
  45. package/dist/lit-html/directives/repeat.js +0 -416
  46. package/dist/lit-html/directives/style-map.d.ts +0 -46
  47. package/dist/lit-html/directives/style-map.js +0 -102
  48. package/dist/lit-html/directives/template-content.d.ts +0 -25
  49. package/dist/lit-html/directives/template-content.js +0 -33
  50. package/dist/lit-html/directives/unsafe-html.d.ts +0 -26
  51. package/dist/lit-html/directives/unsafe-html.js +0 -64
  52. package/dist/lit-html/directives/unsafe-svg.d.ts +0 -26
  53. package/dist/lit-html/directives/unsafe-svg.js +0 -26
  54. package/dist/lit-html/directives/until.d.ts +0 -43
  55. package/dist/lit-html/directives/until.js +0 -137
  56. package/dist/lit-html/experimental-hydrate.d.ts +0 -50
  57. package/dist/lit-html/experimental-hydrate.js +0 -322
  58. package/dist/lit-html/lit-html.d.ts +0 -335
  59. package/dist/lit-html/lit-html.js +0 -1259
  60. package/dist/lit-html/polyfill-support.d.ts +0 -67
  61. package/dist/lit-html/polyfill-support.js +0 -185
  62. package/dist/lit-html/private-ssr-support.d.ts +0 -52
  63. package/dist/lit-html/private-ssr-support.js +0 -54
  64. package/dist/lit-html/static.d.ts +0 -58
  65. package/dist/lit-html/static.js +0 -114
  66. package/dist/reactive-element/css-tag.d.ts +0 -64
  67. package/dist/reactive-element/css-tag.js +0 -125
  68. package/dist/reactive-element/decorators/base.d.ts +0 -47
  69. package/dist/reactive-element/decorators/base.js +0 -70
  70. package/dist/reactive-element/decorators/custom-element.d.ts +0 -26
  71. package/dist/reactive-element/decorators/custom-element.js +0 -47
  72. package/dist/reactive-element/decorators/event-options.d.ts +0 -37
  73. package/dist/reactive-element/decorators/event-options.js +0 -47
  74. package/dist/reactive-element/decorators/index.d.ts +0 -14
  75. package/dist/reactive-element/decorators/index.js +0 -32
  76. package/dist/reactive-element/decorators/property.d.ts +0 -40
  77. package/dist/reactive-element/decorators/property.js +0 -92
  78. package/dist/reactive-element/decorators/query-all.d.ts +0 -31
  79. package/dist/reactive-element/decorators/query-all.js +0 -46
  80. package/dist/reactive-element/decorators/query-assigned-nodes.d.ts +0 -33
  81. package/dist/reactive-element/decorators/query-assigned-nodes.js +0 -55
  82. package/dist/reactive-element/decorators/query-async.d.ts +0 -39
  83. package/dist/reactive-element/decorators/query-async.js +0 -71
  84. package/dist/reactive-element/decorators/query.d.ts +0 -32
  85. package/dist/reactive-element/decorators/query.js +0 -60
  86. package/dist/reactive-element/decorators/state.d.ts +0 -24
  87. package/dist/reactive-element/decorators/state.js +0 -29
  88. package/dist/reactive-element/index.d.ts +0 -5
  89. package/dist/reactive-element/index.js +0 -17
  90. package/dist/reactive-element/polyfill-support.d.ts +0 -40
  91. package/dist/reactive-element/polyfill-support.js +0 -89
  92. package/dist/reactive-element/reactive-controller.d.ts +0 -76
  93. package/dist/reactive-element/reactive-controller.js +0 -7
  94. package/dist/reactive-element/reactive-element.d.ts +0 -653
  95. package/dist/reactive-element/reactive-element.js +0 -979
@@ -1,250 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright 2017 Google LLC
5
- * SPDX-License-Identifier: BSD-3-Clause
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.AsyncDirective = exports.directive = void 0;
9
- const directive_helpers_1 = require("./directive-helpers");
10
- const directive_1 = require("./directive");
11
- var directive_2 = require("./directive");
12
- Object.defineProperty(exports, "directive", { enumerable: true, get: function () { return directive_2.directive; } });
13
- const DEV_MODE = true;
14
- /**
15
- * Recursively walks down the tree of Parts/TemplateInstances/Directives to set
16
- * the connected state of directives and run `disconnected`/ `reconnected`
17
- * callbacks.
18
- *
19
- * @return True if there were children to disconnect; false otherwise
20
- */
21
- const notifyChildrenConnectedChanged = (parent, isConnected) => {
22
- var _a, _b;
23
- const children = parent._$disconnectableChildren;
24
- if (children === undefined) {
25
- return false;
26
- }
27
- for (const obj of children) {
28
- // The existence of `_$notifyDirectiveConnectionChanged` is used as a "brand" to
29
- // disambiguate AsyncDirectives from other DisconnectableChildren
30
- // (as opposed to using an instanceof check to know when to call it); the
31
- // redundancy of "Directive" in the API name is to avoid conflicting with
32
- // `_$notifyConnectionChanged`, which exists `ChildParts` which are also in
33
- // this list
34
- // Disconnect Directive (and any nested directives contained within)
35
- // This property needs to remain unminified.
36
- (_b = (_a = obj)['_$notifyDirectiveConnectionChanged']) === null || _b === void 0 ? void 0 : _b.call(_a, isConnected, false);
37
- // Disconnect Part/TemplateInstance
38
- notifyChildrenConnectedChanged(obj, isConnected);
39
- }
40
- return true;
41
- };
42
- /**
43
- * Removes the given child from its parent list of disconnectable children, and
44
- * if the parent list becomes empty as a result, removes the parent from its
45
- * parent, and so forth up the tree when that causes subsequent parent lists to
46
- * become empty.
47
- */
48
- const removeDisconnectableFromParent = (obj) => {
49
- let parent, children;
50
- do {
51
- if ((parent = obj._$parent) === undefined) {
52
- break;
53
- }
54
- children = parent._$disconnectableChildren;
55
- children.delete(obj);
56
- obj = parent;
57
- } while ((children === null || children === void 0 ? void 0 : children.size) === 0);
58
- };
59
- const addDisconnectableToParent = (obj) => {
60
- // Climb the parent tree, creating a sparse tree of children needing
61
- // disconnection
62
- for (let parent; (parent = obj._$parent); obj = parent) {
63
- let children = parent._$disconnectableChildren;
64
- if (children === undefined) {
65
- parent._$disconnectableChildren = children = new Set();
66
- }
67
- else if (children.has(obj)) {
68
- // Once we've reached a parent that already contains this child, we
69
- // can short-circuit
70
- break;
71
- }
72
- children.add(obj);
73
- installDisconnectAPI(parent);
74
- }
75
- };
76
- /**
77
- * Changes the parent reference of the ChildPart, and updates the sparse tree of
78
- * Disconnectable children accordingly.
79
- *
80
- * Note, this method will be patched onto ChildPart instances and called from
81
- * the core code when parts are moved between different parents.
82
- */
83
- function reparentDisconnectables(newParent) {
84
- if (this._$disconnectableChildren !== undefined) {
85
- removeDisconnectableFromParent(this);
86
- this._$parent = newParent;
87
- addDisconnectableToParent(this);
88
- }
89
- else {
90
- this._$parent = newParent;
91
- }
92
- }
93
- /**
94
- * Sets the connected state on any directives contained within the committed
95
- * value of this part (i.e. within a TemplateInstance or iterable of
96
- * ChildParts) and runs their `disconnected`/`reconnected`s, as well as within
97
- * any directives stored on the ChildPart (when `valueOnly` is false).
98
- *
99
- * `isClearingValue` should be passed as `true` on a top-level part that is
100
- * clearing itself, and not as a result of recursively disconnecting directives
101
- * as part of a `clear` operation higher up the tree. This both ensures that any
102
- * directive on this ChildPart that produced a value that caused the clear
103
- * operation is not disconnected, and also serves as a performance optimization
104
- * to avoid needless bookkeeping when a subtree is going away; when clearing a
105
- * subtree, only the top-most part need to remove itself from the parent.
106
- *
107
- * `fromPartIndex` is passed only in the case of a partial `_clear` running as a
108
- * result of truncating an iterable.
109
- *
110
- * Note, this method will be patched onto ChildPart instances and called from the
111
- * core code when parts are cleared or the connection state is changed by the
112
- * user.
113
- */
114
- function notifyChildPartConnectedChanged(isConnected, isClearingValue = false, fromPartIndex = 0) {
115
- const value = this._$committedValue;
116
- const children = this._$disconnectableChildren;
117
- if (children === undefined || children.size === 0) {
118
- return;
119
- }
120
- if (isClearingValue) {
121
- if (Array.isArray(value)) {
122
- // Iterable case: Any ChildParts created by the iterable should be
123
- // disconnected and removed from this ChildPart's disconnectable
124
- // children (starting at `fromPartIndex` in the case of truncation)
125
- for (let i = fromPartIndex; i < value.length; i++) {
126
- notifyChildrenConnectedChanged(value[i], false);
127
- removeDisconnectableFromParent(value[i]);
128
- }
129
- }
130
- else if (value != null) {
131
- // TemplateInstance case: If the value has disconnectable children (will
132
- // only be in the case that it is a TemplateInstance), we disconnect it
133
- // and remove it from this ChildPart's disconnectable children
134
- notifyChildrenConnectedChanged(value, false);
135
- removeDisconnectableFromParent(value);
136
- }
137
- }
138
- else {
139
- notifyChildrenConnectedChanged(this, isConnected);
140
- }
141
- }
142
- /**
143
- * Patches disconnection API onto ChildParts.
144
- */
145
- const installDisconnectAPI = (obj) => {
146
- var _a, _b;
147
- var _c, _d;
148
- if (obj.type == directive_1.PartType.CHILD) {
149
- (_a = (_c = obj)._$notifyConnectionChanged) !== null && _a !== void 0 ? _a : (_c._$notifyConnectionChanged = notifyChildPartConnectedChanged);
150
- (_b = (_d = obj)._$reparentDisconnectables) !== null && _b !== void 0 ? _b : (_d._$reparentDisconnectables = reparentDisconnectables);
151
- }
152
- };
153
- /**
154
- * An abstract `Directive` base class whose `disconnected` method will be
155
- * called when the part containing the directive is cleared as a result of
156
- * re-rendering, or when the user calls `part.setConnected(false)` on
157
- * a part that was previously rendered containing the directive (as happens
158
- * when e.g. a LitElement disconnects from the DOM).
159
- *
160
- * If `part.setConnected(true)` is subsequently called on a
161
- * containing part, the directive's `reconnected` method will be called prior
162
- * to its next `update`/`render` callbacks. When implementing `disconnected`,
163
- * `reconnected` should also be implemented to be compatible with reconnection.
164
- *
165
- * Note that updates may occur while the directive is disconnected. As such,
166
- * directives should generally check the `this.isConnected` flag during
167
- * render/update to determine whether it is safe to subscribe to resources
168
- * that may prevent garbage collection.
169
- */
170
- class AsyncDirective extends directive_1.Directive {
171
- constructor() {
172
- super(...arguments);
173
- // @internal
174
- this._$disconnectableChildren = undefined;
175
- }
176
- /**
177
- * Initialize the part with internal fields
178
- * @param part
179
- * @param parent
180
- * @param attributeIndex
181
- */
182
- _$initialize(part, parent, attributeIndex) {
183
- super._$initialize(part, parent, attributeIndex);
184
- addDisconnectableToParent(this);
185
- this.isConnected = part._$isConnected;
186
- }
187
- // This property needs to remain unminified.
188
- /**
189
- * Called from the core code when a directive is going away from a part (in
190
- * which case `shouldRemoveFromParent` should be true), and from the
191
- * `setChildrenConnected` helper function when recursively changing the
192
- * connection state of a tree (in which case `shouldRemoveFromParent` should
193
- * be false).
194
- *
195
- * @param isConnected
196
- * @param isClearingDirective - True when the directive itself is being
197
- * removed; false when the tree is being disconnected
198
- * @internal
199
- */
200
- ['_$notifyDirectiveConnectionChanged'](isConnected, isClearingDirective = true) {
201
- var _a, _b;
202
- if (isConnected !== this.isConnected) {
203
- this.isConnected = isConnected;
204
- if (isConnected) {
205
- (_a = this.reconnected) === null || _a === void 0 ? void 0 : _a.call(this);
206
- }
207
- else {
208
- (_b = this.disconnected) === null || _b === void 0 ? void 0 : _b.call(this);
209
- }
210
- }
211
- if (isClearingDirective) {
212
- notifyChildrenConnectedChanged(this, isConnected);
213
- removeDisconnectableFromParent(this);
214
- }
215
- }
216
- /**
217
- * Sets the value of the directive's Part outside the normal `update`/`render`
218
- * lifecycle of a directive.
219
- *
220
- * This method should not be called synchronously from a directive's `update`
221
- * or `render`.
222
- *
223
- * @param directive The directive to update
224
- * @param value The value to set
225
- */
226
- setValue(value) {
227
- if ((0, directive_helpers_1.isSingleExpression)(this.__part)) {
228
- this.__part._$setValue(value, this);
229
- }
230
- else {
231
- // this.__attributeIndex will be defined in this case, but
232
- // assert it in dev mode
233
- if (DEV_MODE && this.__attributeIndex === undefined) {
234
- throw new Error(`Expected this.__attributeIndex to be a number`);
235
- }
236
- const newValues = [...this.__part._$committedValue];
237
- newValues[this.__attributeIndex] = value;
238
- this.__part._$setValue(newValues, this, 0);
239
- }
240
- }
241
- /**
242
- * User callbacks for implementing logic to release any resources/subscriptions
243
- * that may have been retained by this directive. Since directives may also be
244
- * re-connected, `reconnected` should also be implemented to restore the
245
- * working state of the directive prior to the next render.
246
- */
247
- disconnected() { }
248
- reconnected() { }
249
- }
250
- exports.AsyncDirective = AsyncDirective;
@@ -1,105 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2020 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
- import { Part, DirectiveParent, TemplateResult } from './lit-html';
7
- import { DirectiveResult, DirectiveClass, PartInfo } from './directive';
8
- declare type Primitive = null | undefined | boolean | number | string | symbol | bigint;
9
- /**
10
- * Tests if a value is a primitive value.
11
- *
12
- * See https://tc39.github.io/ecma262/#sec-typeof-operator
13
- */
14
- export declare const isPrimitive: (value: unknown) => value is Primitive;
15
- export declare const TemplateResultType: {
16
- readonly HTML: 1;
17
- readonly SVG: 2;
18
- };
19
- export declare type TemplateResultType = typeof TemplateResultType[keyof typeof TemplateResultType];
20
- /**
21
- * Tests if a value is a TemplateResult.
22
- */
23
- export declare const isTemplateResult: (value: unknown, type?: TemplateResultType) => value is TemplateResult<1 | 2>;
24
- /**
25
- * Tests if a value is a DirectiveResult.
26
- */
27
- export declare const isDirectiveResult: (value: unknown) => value is DirectiveResult<DirectiveClass>;
28
- /**
29
- * Retrieves the Directive class for a DirectiveResult
30
- */
31
- export declare const getDirectiveClass: (value: unknown) => DirectiveClass | undefined;
32
- /**
33
- * Tests whether a part has only a single-expression with no strings to
34
- * interpolate between.
35
- *
36
- * Only AttributePart and PropertyPart can have multiple expressions.
37
- * Multi-expression parts have a `strings` property and single-expression
38
- * parts do not.
39
- */
40
- export declare const isSingleExpression: (part: PartInfo) => boolean;
41
- /**
42
- * Inserts a ChildPart into the given container ChildPart's DOM, either at the
43
- * end of the container ChildPart, or before the optional `refPart`.
44
- *
45
- * This does not add the part to the containerPart's committed value. That must
46
- * be done by callers.
47
- *
48
- * @param containerPart Part within which to add the new ChildPart
49
- * @param refPart Part before which to add the new ChildPart; when omitted the
50
- * part added to the end of the `containerPart`
51
- * @param part Part to insert, or undefined to create a new part
52
- */
53
- export declare const insertPart: (containerPart: import("./lit-html").ChildPart, refPart?: import("./lit-html").ChildPart, part?: import("./lit-html").ChildPart) => import("./lit-html").ChildPart;
54
- /**
55
- * Sets the value of a Part.
56
- *
57
- * Note that this should only be used to set/update the value of user-created
58
- * parts (i.e. those created using `insertPart`); it should not be used
59
- * by directives to set the value of the directive's container part. Directives
60
- * should return a value from `update`/`render` to update their part state.
61
- *
62
- * For directives that require setting their part value asynchronously, they
63
- * should extend `AsyncDirective` and call `this.setValue()`.
64
- *
65
- * @param part Part to set
66
- * @param value Value to set
67
- * @param index For `AttributePart`s, the index to set
68
- * @param directiveParent Used internally; should not be set by user
69
- */
70
- export declare const setChildPartValue: <T extends import("./lit-html").ChildPart>(part: T, value: unknown, directiveParent?: DirectiveParent) => T;
71
- /**
72
- * Sets the committed value of a ChildPart directly without triggering the
73
- * commit stage of the part.
74
- *
75
- * This is useful in cases where a directive needs to update the part such
76
- * that the next update detects a value change or not. When value is omitted,
77
- * the next update will be guaranteed to be detected as a change.
78
- *
79
- * @param part
80
- * @param value
81
- */
82
- export declare const setCommittedValue: (part: Part, value?: unknown) => unknown;
83
- /**
84
- * Returns the committed value of a ChildPart.
85
- *
86
- * The committed value is used for change detection and efficient updates of
87
- * the part. It can differ from the value set by the template or directive in
88
- * cases where the template value is transformed before being commited.
89
- *
90
- * - `TemplateResult`s are committed as a `TemplateInstance`
91
- * - Iterables are committed as `Array<ChildPart>`
92
- * - All other types are committed as the template value or value returned or
93
- * set by a directive.
94
- *
95
- * @param part
96
- */
97
- export declare const getCommittedValue: (part: import("./lit-html").ChildPart) => unknown;
98
- /**
99
- * Removes a ChildPart from the DOM, including any of its content.
100
- *
101
- * @param part The Part to remove
102
- */
103
- export declare const removePart: (part: import("./lit-html").ChildPart) => void;
104
- export declare const clearPart: (part: import("./lit-html").ChildPart) => void;
105
- export {};
@@ -1,192 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright 2020 Google LLC
5
- * SPDX-License-Identifier: BSD-3-Clause
6
- */
7
- var _a, _b;
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.clearPart = exports.removePart = exports.getCommittedValue = exports.setCommittedValue = exports.setChildPartValue = exports.insertPart = exports.isSingleExpression = exports.getDirectiveClass = exports.isDirectiveResult = exports.isTemplateResult = exports.TemplateResultType = exports.isPrimitive = void 0;
10
- const lit_html_1 = require("./lit-html");
11
- const { _ChildPart: ChildPart } = lit_html_1._$LH;
12
- const ENABLE_SHADYDOM_NOPATCH = true;
13
- const wrap = ENABLE_SHADYDOM_NOPATCH &&
14
- ((_a = window.ShadyDOM) === null || _a === void 0 ? void 0 : _a.inUse) &&
15
- ((_b = window.ShadyDOM) === null || _b === void 0 ? void 0 : _b.noPatch) === true
16
- ? window.ShadyDOM.wrap
17
- : (node) => node;
18
- /**
19
- * Tests if a value is a primitive value.
20
- *
21
- * See https://tc39.github.io/ecma262/#sec-typeof-operator
22
- */
23
- const isPrimitive = (value) => value === null || (typeof value != 'object' && typeof value != 'function');
24
- exports.isPrimitive = isPrimitive;
25
- exports.TemplateResultType = {
26
- HTML: 1,
27
- SVG: 2,
28
- };
29
- /**
30
- * Tests if a value is a TemplateResult.
31
- */
32
- const isTemplateResult = (value, type) => {
33
- var _a, _b;
34
- return type === undefined
35
- ? // This property needs to remain unminified.
36
- ((_a = value) === null || _a === void 0 ? void 0 : _a['_$litType$']) !== undefined
37
- : ((_b = value) === null || _b === void 0 ? void 0 : _b['_$litType$']) === type;
38
- };
39
- exports.isTemplateResult = isTemplateResult;
40
- /**
41
- * Tests if a value is a DirectiveResult.
42
- */
43
- const isDirectiveResult = (value) => { var _a;
44
- // This property needs to remain unminified.
45
- return ((_a = value) === null || _a === void 0 ? void 0 : _a['_$litDirective$']) !== undefined; };
46
- exports.isDirectiveResult = isDirectiveResult;
47
- /**
48
- * Retrieves the Directive class for a DirectiveResult
49
- */
50
- const getDirectiveClass = (value) => { var _a;
51
- // This property needs to remain unminified.
52
- return (_a = value) === null || _a === void 0 ? void 0 : _a['_$litDirective$']; };
53
- exports.getDirectiveClass = getDirectiveClass;
54
- /**
55
- * Tests whether a part has only a single-expression with no strings to
56
- * interpolate between.
57
- *
58
- * Only AttributePart and PropertyPart can have multiple expressions.
59
- * Multi-expression parts have a `strings` property and single-expression
60
- * parts do not.
61
- */
62
- const isSingleExpression = (part) => part.strings === undefined;
63
- exports.isSingleExpression = isSingleExpression;
64
- const createMarker = () => document.createComment('');
65
- /**
66
- * Inserts a ChildPart into the given container ChildPart's DOM, either at the
67
- * end of the container ChildPart, or before the optional `refPart`.
68
- *
69
- * This does not add the part to the containerPart's committed value. That must
70
- * be done by callers.
71
- *
72
- * @param containerPart Part within which to add the new ChildPart
73
- * @param refPart Part before which to add the new ChildPart; when omitted the
74
- * part added to the end of the `containerPart`
75
- * @param part Part to insert, or undefined to create a new part
76
- */
77
- const insertPart = (containerPart, refPart, part) => {
78
- var _a;
79
- const container = wrap(containerPart._$startNode).parentNode;
80
- const refNode = refPart === undefined ? containerPart._$endNode : refPart._$startNode;
81
- if (part === undefined) {
82
- const startNode = wrap(container).insertBefore(createMarker(), refNode);
83
- const endNode = wrap(container).insertBefore(createMarker(), refNode);
84
- part = new ChildPart(startNode, endNode, containerPart, containerPart.options);
85
- }
86
- else {
87
- const endNode = wrap(part._$endNode).nextSibling;
88
- const oldParent = part._$parent;
89
- const parentChanged = oldParent !== containerPart;
90
- if (parentChanged) {
91
- (_a = part._$reparentDisconnectables) === null || _a === void 0 ? void 0 : _a.call(part, containerPart);
92
- // Note that although `_$reparentDisconnectables` updates the part's
93
- // `_$parent` reference after unlinking from its current parent, that
94
- // method only exists if Disconnectables are present, so we need to
95
- // unconditionally set it here
96
- part._$parent = containerPart;
97
- // Since the _$isConnected getter is somewhat costly, only
98
- // read it once we know the subtree has directives that need
99
- // to be notified
100
- let newConnectionState;
101
- if (part._$notifyConnectionChanged !== undefined &&
102
- (newConnectionState = containerPart._$isConnected) !==
103
- oldParent._$isConnected) {
104
- part._$notifyConnectionChanged(newConnectionState);
105
- }
106
- }
107
- if (endNode !== refNode || parentChanged) {
108
- let start = part._$startNode;
109
- while (start !== endNode) {
110
- const n = wrap(start).nextSibling;
111
- wrap(container).insertBefore(start, refNode);
112
- start = n;
113
- }
114
- }
115
- }
116
- return part;
117
- };
118
- exports.insertPart = insertPart;
119
- /**
120
- * Sets the value of a Part.
121
- *
122
- * Note that this should only be used to set/update the value of user-created
123
- * parts (i.e. those created using `insertPart`); it should not be used
124
- * by directives to set the value of the directive's container part. Directives
125
- * should return a value from `update`/`render` to update their part state.
126
- *
127
- * For directives that require setting their part value asynchronously, they
128
- * should extend `AsyncDirective` and call `this.setValue()`.
129
- *
130
- * @param part Part to set
131
- * @param value Value to set
132
- * @param index For `AttributePart`s, the index to set
133
- * @param directiveParent Used internally; should not be set by user
134
- */
135
- const setChildPartValue = (part, value, directiveParent = part) => {
136
- part._$setValue(value, directiveParent);
137
- return part;
138
- };
139
- exports.setChildPartValue = setChildPartValue;
140
- // A sentinal value that can never appear as a part value except when set by
141
- // live(). Used to force a dirty-check to fail and cause a re-render.
142
- const RESET_VALUE = {};
143
- /**
144
- * Sets the committed value of a ChildPart directly without triggering the
145
- * commit stage of the part.
146
- *
147
- * This is useful in cases where a directive needs to update the part such
148
- * that the next update detects a value change or not. When value is omitted,
149
- * the next update will be guaranteed to be detected as a change.
150
- *
151
- * @param part
152
- * @param value
153
- */
154
- const setCommittedValue = (part, value = RESET_VALUE) => (part._$committedValue = value);
155
- exports.setCommittedValue = setCommittedValue;
156
- /**
157
- * Returns the committed value of a ChildPart.
158
- *
159
- * The committed value is used for change detection and efficient updates of
160
- * the part. It can differ from the value set by the template or directive in
161
- * cases where the template value is transformed before being commited.
162
- *
163
- * - `TemplateResult`s are committed as a `TemplateInstance`
164
- * - Iterables are committed as `Array<ChildPart>`
165
- * - All other types are committed as the template value or value returned or
166
- * set by a directive.
167
- *
168
- * @param part
169
- */
170
- const getCommittedValue = (part) => part._$committedValue;
171
- exports.getCommittedValue = getCommittedValue;
172
- /**
173
- * Removes a ChildPart from the DOM, including any of its content.
174
- *
175
- * @param part The Part to remove
176
- */
177
- const removePart = (part) => {
178
- var _a;
179
- (_a = part._$notifyConnectionChanged) === null || _a === void 0 ? void 0 : _a.call(part, false, true);
180
- let start = part._$startNode;
181
- const end = wrap(part._$endNode).nextSibling;
182
- while (start !== end) {
183
- const n = wrap(start).nextSibling;
184
- wrap(start).remove();
185
- start = n;
186
- }
187
- };
188
- exports.removePart = removePart;
189
- const clearPart = (part) => {
190
- part._$clear();
191
- };
192
- exports.clearPart = clearPart;
@@ -1,65 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- * SPDX-License-Identifier: BSD-3-Clause
5
- */
6
- import { Disconnectable, Part } from './lit-html';
7
- export { AttributePart, BooleanAttributePart, ChildPart, ElementPart, EventPart, Part, PropertyPart, } from './lit-html';
8
- export interface DirectiveClass {
9
- new (part: PartInfo): Directive;
10
- }
11
- /**
12
- * This utility type extracts the signature of a directive class's render()
13
- * method so we can use it for the type of the generated directive function.
14
- */
15
- export declare type DirectiveParameters<C extends Directive> = Parameters<C['render']>;
16
- /**
17
- * A generated directive function doesn't evaluate the directive, but just
18
- * returns a DirectiveResult object that captures the arguments.
19
- */
20
- export interface DirectiveResult<C extends DirectiveClass = DirectiveClass> {
21
- }
22
- export declare const PartType: {
23
- readonly ATTRIBUTE: 1;
24
- readonly CHILD: 2;
25
- readonly PROPERTY: 3;
26
- readonly BOOLEAN_ATTRIBUTE: 4;
27
- readonly EVENT: 5;
28
- readonly ELEMENT: 6;
29
- };
30
- export declare type PartType = typeof PartType[keyof typeof PartType];
31
- export interface ChildPartInfo {
32
- readonly type: typeof PartType.CHILD;
33
- }
34
- export interface AttributePartInfo {
35
- readonly type: typeof PartType.ATTRIBUTE | typeof PartType.PROPERTY | typeof PartType.BOOLEAN_ATTRIBUTE | typeof PartType.EVENT;
36
- readonly strings?: ReadonlyArray<string>;
37
- readonly name: string;
38
- readonly tagName: string;
39
- }
40
- export interface ElementPartInfo {
41
- readonly type: typeof PartType.ELEMENT;
42
- }
43
- /**
44
- * Information about the part a directive is bound to.
45
- *
46
- * This is useful for checking that a directive is attached to a valid part,
47
- * such as with directive that can only be used on attribute bindings.
48
- */
49
- export declare type PartInfo = ChildPartInfo | AttributePartInfo | ElementPartInfo;
50
- /**
51
- * Creates a user-facing directive function from a Directive class. This
52
- * function has the same parameters as the directive's render() method.
53
- */
54
- export declare const directive: <C extends DirectiveClass>(c: C) => (...values: Parameters<InstanceType<C>["render"]>) => DirectiveResult<C>;
55
- /**
56
- * Base class for creating custom directives. Users should extend this class,
57
- * implement `render` and/or `update`, and then pass their subclass to
58
- * `directive`.
59
- */
60
- export declare abstract class Directive implements Disconnectable {
61
- constructor(_partInfo: PartInfo);
62
- get _$isConnected(): boolean;
63
- abstract render(...props: Array<unknown>): unknown;
64
- update(_part: Part, props: Array<unknown>): unknown;
65
- }
@@ -1,52 +0,0 @@
1
- "use strict";
2
- /**
3
- * @license
4
- * Copyright 2017 Google LLC
5
- * SPDX-License-Identifier: BSD-3-Clause
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.Directive = exports.directive = exports.PartType = void 0;
9
- exports.PartType = {
10
- ATTRIBUTE: 1,
11
- CHILD: 2,
12
- PROPERTY: 3,
13
- BOOLEAN_ATTRIBUTE: 4,
14
- EVENT: 5,
15
- ELEMENT: 6,
16
- };
17
- /**
18
- * Creates a user-facing directive function from a Directive class. This
19
- * function has the same parameters as the directive's render() method.
20
- */
21
- const directive = (c) => (...values) => ({
22
- // This property needs to remain unminified.
23
- ['_$litDirective$']: c,
24
- values,
25
- });
26
- exports.directive = directive;
27
- /**
28
- * Base class for creating custom directives. Users should extend this class,
29
- * implement `render` and/or `update`, and then pass their subclass to
30
- * `directive`.
31
- */
32
- class Directive {
33
- constructor(_partInfo) { }
34
- // See comment in Disconnectable interface for why this is a getter
35
- get _$isConnected() {
36
- return this._$parent._$isConnected;
37
- }
38
- /** @internal */
39
- _$initialize(part, parent, attributeIndex) {
40
- this.__part = part;
41
- this._$parent = parent;
42
- this.__attributeIndex = attributeIndex;
43
- }
44
- /** @internal */
45
- _$resolve(part, props) {
46
- return this.update(part, props);
47
- }
48
- update(_part, props) {
49
- return this.render(...props);
50
- }
51
- }
52
- exports.Directive = Directive;