@shortfuse/materialdesignweb 0.9.0 → 0.9.2
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/README.md +50 -206
- package/components/Badge.js +5 -2
- package/components/Body.js +4 -0
- package/components/BottomAppBar.js +6 -2
- package/components/BottomSheet.js +62 -14
- package/components/Button.js +20 -0
- package/components/Card.js +20 -3
- package/components/Checkbox.js +8 -0
- package/components/CheckboxIcon.js +9 -3
- package/components/Chip.js +5 -2
- package/components/Dialog.js +22 -3
- package/components/DialogActions.js +4 -0
- package/components/Display.js +9 -0
- package/components/Divider.js +5 -0
- package/components/Fab.js +11 -0
- package/components/FabContainer.js +9 -0
- package/components/FilterChip.js +9 -0
- package/components/Grid.js +11 -0
- package/components/Headline.js +4 -0
- package/components/Icon.js +27 -3
- package/components/IconButton.js +8 -2
- package/components/Input.js +87 -14
- package/components/InputChip.js +33 -1
- package/components/Label.js +4 -0
- package/components/List.js +10 -0
- package/components/ListItem.js +53 -0
- package/components/ListOption.js +62 -1
- package/components/Listbox.js +44 -13
- package/components/Menu.js +31 -9
- package/components/MenuItem.js +24 -10
- package/components/NavBar.js +14 -3
- package/components/NavBarItem.js +5 -0
- package/components/NavDrawer.js +17 -0
- package/components/NavDrawerItem.js +5 -0
- package/components/NavItem.js +22 -2
- package/components/NavRail.js +9 -0
- package/components/NavRailItem.js +5 -0
- package/components/Page.js +15 -1
- package/components/Pane.js +7 -1
- package/components/Popup.js +6 -0
- package/components/Progress.js +25 -5
- package/components/Radio.js +6 -2
- package/components/RadioIcon.js +14 -1
- package/components/Ripple.js +14 -0
- package/components/Root.js +16 -0
- package/components/Scrim.js +10 -2
- package/components/Search.js +18 -5
- package/components/SegmentedButton.js +22 -6
- package/components/SegmentedButtonGroup.js +7 -10
- package/components/Select.js +13 -3
- package/components/Shape.js +4 -0
- package/components/SideSheet.js +31 -2
- package/components/Slider.js +22 -2
- package/components/Snackbar.js +30 -4
- package/components/SnackbarContainer.js +9 -0
- package/components/Surface.js +5 -0
- package/components/Switch.js +18 -2
- package/components/SwitchIcon.js +22 -1
- package/components/Tab.js +21 -0
- package/components/TabContent.js +32 -12
- package/components/TabList.js +36 -3
- package/components/TabPanel.js +9 -0
- package/components/Table.js +38 -3
- package/components/TextArea.js +32 -1
- package/components/Title.js +4 -0
- package/components/Tooltip.js +9 -2
- package/components/TopAppBar.js +15 -0
- package/core/Composition.js +45 -16
- package/core/CompositionAdapter.js +24 -6
- package/core/CustomElement.js +77 -49
- package/core/customTypes.js +43 -26
- package/core/dom.js +1 -0
- package/core/jsonMergePatch.js +15 -1
- package/core/observe.js +28 -21
- package/dist/CustomElement.min.js +2 -0
- package/dist/CustomElement.min.js.map +7 -0
- package/dist/core/CustomElement.min.js +2 -0
- package/dist/core/CustomElement.min.js.map +7 -0
- package/dist/index.min.js +9 -9
- package/dist/index.min.js.map +3 -3
- package/dist/meta.json +1 -1
- package/dom/HTMLOptionsCollectionProxy.js +5 -3
- package/mixins/AriaReflectorMixin.js +22 -13
- package/mixins/AriaToolbarMixin.js +3 -0
- package/mixins/ControlMixin.js +3 -0
- package/mixins/DelegatesFocusMixin.js +9 -1
- package/mixins/DensityMixin.js +5 -1
- package/mixins/ElevationMixin.js +1 -2
- package/mixins/FlexableMixin.js +21 -2
- package/mixins/FormAssociatedMixin.js +19 -5
- package/mixins/HyperlinkMixin.js +11 -1
- package/mixins/InputMixin.js +22 -0
- package/mixins/KeyboardNavMixin.js +3 -1
- package/mixins/PopupMixin.js +41 -12
- package/mixins/RTLObserverMixin.js +2 -0
- package/mixins/ResizeObserverMixin.js +2 -0
- package/mixins/RippleMixin.js +3 -1
- package/mixins/ScrollListenerMixin.js +13 -1
- package/mixins/SemiStickyMixin.js +7 -0
- package/mixins/ShapeMaskedMixin.js +9 -1
- package/mixins/ShapeMixin.js +9 -0
- package/mixins/StateMixin.js +4 -0
- package/mixins/TextFieldMixin.js +21 -2
- package/mixins/ThemableMixin.js +13 -0
- package/mixins/TooltipTriggerMixin.js +17 -3
- package/mixins/TouchTargetMixin.js +4 -1
- package/mixins/TypographyMixin.js +8 -1
- package/package.json +53 -45
- package/services/theme.js +4 -5
- package/types/components/BottomAppBar.d.ts +3 -4
- package/types/components/BottomSheet.d.ts +33 -7
- package/types/components/BottomSheet.d.ts.map +1 -1
- package/types/components/Button.d.ts +3 -472
- package/types/components/Button.d.ts.map +1 -1
- package/types/components/Card.d.ts +9 -274
- package/types/components/Card.d.ts.map +1 -1
- package/types/components/Checkbox.d.ts +2 -0
- package/types/components/Checkbox.d.ts.map +1 -1
- package/types/components/Chip.d.ts +3 -1180
- package/types/components/Dialog.d.ts +8 -191
- package/types/components/Dialog.d.ts.map +1 -1
- package/types/components/Display.d.ts +5 -4
- package/types/components/Display.d.ts.map +1 -1
- package/types/components/Fab.d.ts +2 -470
- package/types/components/FilterChip.d.ts +5 -4032
- package/types/components/Grid.d.ts +1 -0
- package/types/components/Grid.d.ts.map +1 -1
- package/types/components/Headline.d.ts +3 -4
- package/types/components/Icon.d.ts +1 -49
- package/types/components/Icon.d.ts.map +1 -1
- package/types/components/IconButton.d.ts +3 -1205
- package/types/components/Input.d.ts +1485 -50245
- package/types/components/Input.d.ts.map +1 -1
- package/types/components/InputChip.d.ts +2 -160
- package/types/components/List.d.ts +8 -4
- package/types/components/List.d.ts.map +1 -1
- package/types/components/ListItem.d.ts +10 -235
- package/types/components/ListItem.d.ts.map +1 -1
- package/types/components/ListOption.d.ts +17 -1352
- package/types/components/ListOption.d.ts.map +1 -1
- package/types/components/Listbox.d.ts +199 -11448
- package/types/components/Listbox.d.ts.map +1 -1
- package/types/components/Menu.d.ts +21 -10
- package/types/components/Menu.d.ts.map +1 -1
- package/types/components/MenuItem.d.ts +17 -2894
- package/types/components/MenuItem.d.ts.map +1 -1
- package/types/components/NavBar.d.ts +2 -0
- package/types/components/NavBar.d.ts.map +1 -1
- package/types/components/NavBarItem.d.ts +1 -90
- package/types/components/NavDrawer.d.ts +3 -4
- package/types/components/NavDrawerItem.d.ts +1 -90
- package/types/components/NavItem.d.ts +1 -92
- package/types/components/NavItem.d.ts.map +1 -1
- package/types/components/NavRail.d.ts +3 -4
- package/types/components/NavRailItem.d.ts +1 -90
- package/types/components/Page.d.ts +1 -0
- package/types/components/Page.d.ts.map +1 -1
- package/types/components/Popup.d.ts +5 -3
- package/types/components/Popup.d.ts.map +1 -1
- package/types/components/Progress.d.ts +2 -0
- package/types/components/Progress.d.ts.map +1 -1
- package/types/components/Radio.d.ts +2 -0
- package/types/components/Radio.d.ts.map +1 -1
- package/types/components/Ripple.d.ts +1 -0
- package/types/components/Ripple.d.ts.map +1 -1
- package/types/components/Root.d.ts +1 -1
- package/types/components/Root.d.ts.map +1 -1
- package/types/components/Search.d.ts +502 -2
- package/types/components/Search.d.ts.map +1 -1
- package/types/components/SegmentedButton.d.ts +4 -470
- package/types/components/SegmentedButton.d.ts.map +1 -1
- package/types/components/SegmentedButtonGroup.d.ts +3 -4
- package/types/components/SegmentedButtonGroup.d.ts.map +1 -1
- package/types/components/Select.d.ts +5 -1208
- package/types/components/Select.d.ts.map +1 -1
- package/types/components/SideSheet.d.ts +9 -4
- package/types/components/SideSheet.d.ts.map +1 -1
- package/types/components/Slider.d.ts +10 -189
- package/types/components/Slider.d.ts.map +1 -1
- package/types/components/Snackbar.d.ts +13 -5
- package/types/components/Snackbar.d.ts.map +1 -1
- package/types/components/Switch.d.ts +4 -0
- package/types/components/Switch.d.ts.map +1 -1
- package/types/components/SwitchIcon.d.ts +2 -110
- package/types/components/SwitchIcon.d.ts.map +1 -1
- package/types/components/Tab.d.ts +12 -752
- package/types/components/Tab.d.ts.map +1 -1
- package/types/components/TabContent.d.ts +23 -21
- package/types/components/TabContent.d.ts.map +1 -1
- package/types/components/TabList.d.ts +646 -5801
- package/types/components/TabList.d.ts.map +1 -1
- package/types/components/TabPanel.d.ts +4 -4
- package/types/components/TabPanel.d.ts.map +1 -1
- package/types/components/Table.d.ts +24 -1
- package/types/components/Table.d.ts.map +1 -1
- package/types/components/TextArea.d.ts +15 -1208
- package/types/components/TextArea.d.ts.map +1 -1
- package/types/components/Title.d.ts +3 -4
- package/types/components/Tooltip.d.ts +4 -4
- package/types/components/Tooltip.d.ts.map +1 -1
- package/types/components/TopAppBar.d.ts +4 -5
- package/types/components/TopAppBar.d.ts.map +1 -1
- package/types/constants/shapes.d.ts.map +1 -1
- package/types/core/Composition.d.ts +19 -11
- package/types/core/Composition.d.ts.map +1 -1
- package/types/core/CompositionAdapter.d.ts +30 -8
- package/types/core/CompositionAdapter.d.ts.map +1 -1
- package/types/core/CustomElement.d.ts +27 -25
- package/types/core/CustomElement.d.ts.map +1 -1
- package/types/core/customTypes.d.ts +2 -6
- package/types/core/customTypes.d.ts.map +1 -1
- package/types/core/dom.d.ts.map +1 -1
- package/types/core/jsonMergePatch.d.ts.map +1 -1
- package/types/core/observe.d.ts +20 -19
- package/types/core/observe.d.ts.map +1 -1
- package/types/core/template.d.ts.map +1 -1
- package/types/dom/HTMLOptionsCollectionProxy.d.ts +4 -4
- package/types/dom/HTMLOptionsCollectionProxy.d.ts.map +1 -1
- package/types/mixins/AriaReflectorMixin.d.ts +18 -10
- package/types/mixins/AriaReflectorMixin.d.ts.map +1 -1
- package/types/mixins/AriaToolbarMixin.d.ts +6 -4
- package/types/mixins/AriaToolbarMixin.d.ts.map +1 -1
- package/types/mixins/ControlMixin.d.ts +1 -1
- package/types/mixins/ControlMixin.d.ts.map +1 -1
- package/types/mixins/DelegatesFocusMixin.d.ts +9 -1
- package/types/mixins/DelegatesFocusMixin.d.ts.map +1 -1
- package/types/mixins/DensityMixin.d.ts +4 -1
- package/types/mixins/DensityMixin.d.ts.map +1 -1
- package/types/mixins/ElevationMixin.d.ts +1 -2
- package/types/mixins/ElevationMixin.d.ts.map +1 -1
- package/types/mixins/FlexableMixin.d.ts +1 -0
- package/types/mixins/FlexableMixin.d.ts.map +1 -1
- package/types/mixins/FormAssociatedMixin.d.ts +3 -2
- package/types/mixins/FormAssociatedMixin.d.ts.map +1 -1
- package/types/mixins/HyperlinkMixin.d.ts +4 -1
- package/types/mixins/HyperlinkMixin.d.ts.map +1 -1
- package/types/mixins/InputMixin.d.ts +1 -7
- package/types/mixins/InputMixin.d.ts.map +1 -1
- package/types/mixins/KeyboardNavMixin.d.ts +4 -5
- package/types/mixins/KeyboardNavMixin.d.ts.map +1 -1
- package/types/mixins/PopupMixin.d.ts +22 -6
- package/types/mixins/PopupMixin.d.ts.map +1 -1
- package/types/mixins/RTLObserverMixin.d.ts +1 -0
- package/types/mixins/RTLObserverMixin.d.ts.map +1 -1
- package/types/mixins/ResizeObserverMixin.d.ts +1 -0
- package/types/mixins/ResizeObserverMixin.d.ts.map +1 -1
- package/types/mixins/RippleMixin.d.ts +3 -1
- package/types/mixins/RippleMixin.d.ts.map +1 -1
- package/types/mixins/ScrollListenerMixin.d.ts +7 -2
- package/types/mixins/ScrollListenerMixin.d.ts.map +1 -1
- package/types/mixins/SemiStickyMixin.d.ts +1 -1
- package/types/mixins/SemiStickyMixin.d.ts.map +1 -1
- package/types/mixins/ShapeMaskedMixin.d.ts +4 -1
- package/types/mixins/ShapeMaskedMixin.d.ts.map +1 -1
- package/types/mixins/ShapeMixin.d.ts +1 -0
- package/types/mixins/ShapeMixin.d.ts.map +1 -1
- package/types/mixins/StateMixin.d.ts +2 -0
- package/types/mixins/StateMixin.d.ts.map +1 -1
- package/types/mixins/TextFieldMixin.d.ts +7 -1208
- package/types/mixins/TextFieldMixin.d.ts.map +1 -1
- package/types/mixins/ThemableMixin.d.ts +1 -0
- package/types/mixins/ThemableMixin.d.ts.map +1 -1
- package/types/mixins/TooltipTriggerMixin.d.ts +12 -4
- package/types/mixins/TooltipTriggerMixin.d.ts.map +1 -1
- package/types/mixins/TouchTargetMixin.d.ts +4 -1
- package/types/mixins/TouchTargetMixin.d.ts.map +1 -1
- package/types/mixins/TypographyMixin.d.ts +4 -1
- package/types/mixins/TypographyMixin.d.ts.map +1 -1
- package/types/services/theme.d.ts.map +1 -1
- package/types/utils/jsx-runtime.d.ts +3 -3
- package/types/utils/jsx-runtime.d.ts.map +1 -1
- package/types/utils/material-color/hct/Hct.d.ts.map +1 -1
- package/types/utils/material-color/palettes/CorePalette.d.ts +1 -1
- package/types/utils/material-color/palettes/CorePalette.d.ts.map +1 -1
- package/types/utils/material-color/scheme/Scheme.d.ts.map +1 -1
- package/types/utils/pixelmatch.d.ts +3 -3
- package/types/utils/pixelmatch.d.ts.map +1 -1
- package/types/utils/searchParams.d.ts.map +1 -1
- package/utils/jsx-runtime.js +9 -4
- package/utils/pixelmatch.js +10 -7
- package/utils/searchParams.js +3 -0
- package/components/Button.md +0 -61
package/core/observe.js
CHANGED
|
@@ -22,40 +22,40 @@ import { buildMergePatch, hasMergePatch } from './jsonMergePatch.js';
|
|
|
22
22
|
* @template {Object} [C=any]
|
|
23
23
|
* @typedef {Object} ObserverOptions
|
|
24
24
|
* @prop {T1} [type]
|
|
25
|
+
* @prop {boolean} [enumerable]
|
|
26
|
+
* @prop {boolean|'write'|'read'} [reflect]
|
|
25
27
|
* @prop {string} [attr]
|
|
26
28
|
* @prop {boolean} [readonly]
|
|
27
|
-
* @prop {boolean} [enumerable]
|
|
28
29
|
* Defaults to false if type is boolean
|
|
29
30
|
* @prop {boolean} [nullable]
|
|
30
31
|
* @prop {T2} [empty]
|
|
31
32
|
* @prop {T2} [value]
|
|
32
|
-
* @prop {
|
|
33
|
-
* @prop {boolean|'write'|'read'} [reflect]
|
|
33
|
+
* @prop {(this:C, data:Partial<C>, fn?: () => T2) => T2} [get]
|
|
34
34
|
* Function used when null passed
|
|
35
|
-
* @prop {(this:C, value:null|undefined)=>T2} [nullParser]
|
|
36
35
|
* @prop {(this:C, value:any)=>T2} [parser]
|
|
36
|
+
* @prop {(this:C, value:null|undefined)=>T2} [nullParser]
|
|
37
|
+
* @prop {(this:C, value: T2, fn?:(value2: T2) => any) => any} [set]
|
|
37
38
|
* Function used when comparing
|
|
38
39
|
* @prop {(this:C, a:T2, b:T2)=> any} [diff]
|
|
39
40
|
* @prop {(this:C, a:T2, b:T2)=>boolean} [is]
|
|
40
|
-
* @prop {(this:C, data:Partial<C>, fn?: () => T2) => T2} [get]
|
|
41
|
-
* @prop {(this:C, value: T2, fn?:(value2: T2) => any) => any} [set]
|
|
42
41
|
* Simple callback
|
|
43
42
|
* @prop {(this:C, oldValue:T2, newValue:T2, changes:any)=>any} [changedCallback]
|
|
44
43
|
* Named callback
|
|
45
44
|
* @prop {(this:C, name:string, oldValue: T2, newValue: T2, changes:any) => any} [propChangedCallback]
|
|
46
45
|
* Attribute callback
|
|
47
|
-
* @prop {(this:C, name:string, oldValue: string, newValue: string) => any} [attributeChangedCallback]
|
|
46
|
+
* @prop {(this:C, name:keyof C & string, oldValue: string, newValue: string) => any} [attributeChangedCallback]
|
|
47
|
+
* @prop {[keyof C & string, (this:C, ...args:any[]) => any][]} [watchers]
|
|
48
|
+
* @prop {Set<keyof C & string>} [props]
|
|
49
|
+
* @prop {WeakMap<C,T2>} [values]
|
|
48
50
|
* @prop {WeakMap<C, T2>} [computedValues]
|
|
49
|
-
* @prop {[keyof C, (this:C, ...args:any[]) => any][]} [watchers]
|
|
50
51
|
* @prop {WeakSet<C>} [needsSelfInvalidation]
|
|
51
|
-
* @prop {Set<keyof C>} [props]
|
|
52
52
|
*/
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* @template {ObserverPropertyType} T1
|
|
56
56
|
* @template {any} [T2=any]
|
|
57
|
-
* @template {string} [K=string]
|
|
58
57
|
* @template {Object} [C=any]
|
|
58
|
+
* @template {keyof C & string} [K=any]
|
|
59
59
|
* @typedef {ObserverOptions<T1, T2, C> & { key: K, values?: WeakMap<C, T2>; attrValues?: WeakMap<C, string> }} ObserverConfiguration
|
|
60
60
|
*/
|
|
61
61
|
|
|
@@ -107,7 +107,6 @@ function buildProxy(proxyTarget, set, deepSet, prefix) {
|
|
|
107
107
|
set.add(arg);
|
|
108
108
|
}
|
|
109
109
|
if (typeof value === 'object' && value != null) {
|
|
110
|
-
console.debug('tried to arg poke object get', p, value);
|
|
111
110
|
return buildProxy(value, set, deepSet, arg);
|
|
112
111
|
}
|
|
113
112
|
}
|
|
@@ -234,14 +233,18 @@ export function observeFunction(fn, ...args) {
|
|
|
234
233
|
};
|
|
235
234
|
}
|
|
236
235
|
|
|
236
|
+
/** @return {null} */
|
|
237
|
+
function defaultNullParser() { return null; }
|
|
238
|
+
|
|
237
239
|
/**
|
|
238
240
|
* @template {string} K
|
|
239
241
|
* @template {ObserverPropertyType} [T1=any]
|
|
240
242
|
* @template {any} [T2=ParsedObserverPropertyType<T1>]
|
|
243
|
+
* @template {Object} [C=any]
|
|
241
244
|
* @param {K} name
|
|
242
245
|
* @param {T1|ObserverOptions<T1,T2>} [typeOrOptions='string']
|
|
243
246
|
* @param {any} [object]
|
|
244
|
-
* @return {ObserverConfiguration<T1,T2,K> & ObserverOptions<T1,T2>}
|
|
247
|
+
* @return {ObserverConfiguration<T1,T2,C,K> & ObserverOptions<T1,T2,C>}
|
|
245
248
|
*/
|
|
246
249
|
export function parseObserverOptions(name, typeOrOptions, object) {
|
|
247
250
|
/** @type {Partial<ObserverOptions<T1,T2>>} */
|
|
@@ -295,14 +298,15 @@ export function parseObserverOptions(name, typeOrOptions, object) {
|
|
|
295
298
|
}
|
|
296
299
|
|
|
297
300
|
enumerable ??= name[0] !== '_';
|
|
298
|
-
reflect ??= enumerable ? type !== 'object' : (attr ? 'write' : false);
|
|
299
|
-
attr ??= (reflect ? attrNameFromPropName(name) : null);
|
|
300
301
|
nullable ??= (type === 'boolean') ? false : (empty == null);
|
|
301
302
|
if (!nullable) {
|
|
302
303
|
empty ??= emptyFromType(type);
|
|
303
304
|
value ??= empty;
|
|
304
305
|
}
|
|
305
306
|
|
|
307
|
+
reflect ??= enumerable ? (type !== 'object') : (attr ? 'write' : false);
|
|
308
|
+
attr ??= (reflect ? attrNameFromPropName(name) : null);
|
|
309
|
+
|
|
306
310
|
// if defined ? value
|
|
307
311
|
// else if boolean ? false
|
|
308
312
|
// else if onNullish ? false
|
|
@@ -310,7 +314,7 @@ export function parseObserverOptions(name, typeOrOptions, object) {
|
|
|
310
314
|
parser ??= defaultParserFromType(type);
|
|
311
315
|
if (!nullParser) {
|
|
312
316
|
if (nullable) {
|
|
313
|
-
nullParser =
|
|
317
|
+
nullParser = defaultNullParser;
|
|
314
318
|
} else {
|
|
315
319
|
nullParser = (empty === null)
|
|
316
320
|
? () => emptyFromType(type)
|
|
@@ -340,7 +344,9 @@ export function parseObserverOptions(name, typeOrOptions, object) {
|
|
|
340
344
|
parser,
|
|
341
345
|
nullParser,
|
|
342
346
|
key: name,
|
|
347
|
+
// @ts-ignore Can't cast
|
|
343
348
|
props,
|
|
349
|
+
// @ts-ignore Can't cast
|
|
344
350
|
watchers,
|
|
345
351
|
};
|
|
346
352
|
}
|
|
@@ -354,6 +360,7 @@ export function parsePropertyValue(value) {
|
|
|
354
360
|
newValue = value == null
|
|
355
361
|
? this.nullParser.call(this, value)
|
|
356
362
|
: this.parser.call(this, newValue);
|
|
363
|
+
return newValue;
|
|
357
364
|
}
|
|
358
365
|
|
|
359
366
|
/**
|
|
@@ -414,17 +421,16 @@ function detectChange(config, oldValue, value) {
|
|
|
414
421
|
/**
|
|
415
422
|
* @template {ObserverPropertyType} T1
|
|
416
423
|
* @template {any} T2
|
|
417
|
-
* @template {
|
|
418
|
-
* @template
|
|
424
|
+
* @template {Object} C
|
|
425
|
+
* @template {keyof C & string} K
|
|
419
426
|
* @param {C} object
|
|
420
427
|
* @param {K} key
|
|
421
428
|
* @param {ObserverOptions<T1, T2, C>} options
|
|
422
|
-
* @return {ObserverConfiguration<T1,T2,K
|
|
429
|
+
* @return {ObserverConfiguration<T1,T2,C,K>}
|
|
423
430
|
*/
|
|
424
431
|
export function defineObservableProperty(object, key, options) {
|
|
425
|
-
/** @type {ObserverConfiguration<T1,T2,K
|
|
426
|
-
|
|
427
|
-
const config = parseObserverOptions(key, options, object);
|
|
432
|
+
const config = /** @type {ObserverConfiguration<T1,T2,C,K>} */ (
|
|
433
|
+
parseObserverOptions(key, options, object));
|
|
428
434
|
|
|
429
435
|
/**
|
|
430
436
|
* @this {C}
|
|
@@ -469,6 +475,7 @@ export function defineObservableProperty(object, key, options) {
|
|
|
469
475
|
function cachedGet() {
|
|
470
476
|
const newValue = config.get.call(this, this, internalGet.bind(this));
|
|
471
477
|
// Store computed value internally. Used by onInvalidate to get previous value
|
|
478
|
+
// eslint-disable-next-line no-multi-assign
|
|
472
479
|
const computedValues = (config.computedValues ??= new WeakMap());
|
|
473
480
|
computedValues.set(this, newValue);
|
|
474
481
|
return newValue;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var Pt,_t;function lt(){return(Pt??=new Text).cloneNode()}function F(){return(_t??=new Comment).cloneNode()}var D=class{constructor(t){this.anchorNode=t.anchorNode,this.metadata=[],this.keys=[],this.needsArrayKeyFastPath=!1,this.composition=t.composition,this.renderOptions=t.renderOptions,this.metadataCache=null,this.queuedElements=[],this.batchStartIndex=null,this.batchEndIndex=null}render(t,e){return this.composition.render(t,e,this.renderOptions)}startBatch(){this.needsArrayKeyFastPath=!0}writeBatch(){var e;if(!this.queuedElements.length)return;(((e=this.metadata[this.batchStartIndex-1])==null?void 0:e.domNode)??this.anchorNode).after(...this.queuedElements),this.queuedElements.length=0}stopBatch(){if(this.writeBatch(),this.needsArrayKeyFastPath=!1,this.batchStartIndex=null,this.batchEndIndex=null,this.metadataCache){for(let{domNode:t}of this.metadataCache.values())t.remove();this.metadataCache.clear()}}removeByIndex(t){let[e]=this.metadata.splice(t,1),{domNode:s,key:n}=e;this.keys.splice(t,1),s.remove(),this.metadataCache?this.metadataCache.set(n,e):this.metadataCache=new Map([[n,e]])}renderData(t,e,s,n,i,o){var h;if(t<this.metadata.length){let c=this.metadata[t],u=c.key,p=u===n,m=i!==n;if(p){m?c.render(e,s):o||c.render(e,s);return}let b=this.metadataCache??=new Map,g=!1;this.needsArrayKeyFastPath&&(g=!this.keys.includes(n),this.needsArrayFastPath=!1);let S=g?-1:this.keys.indexOf(n,t+1);if(S===-1){if(b.has(n)){let d=b.get(n);this.metadata.splice(t,0,d),this.keys.splice(t,0,n),(((h=this.metadata[t-1])==null?void 0:h.domNode)??this.anchorNode).after(d.domNode),b.delete(n);return}b.set(u,c)}else{if(t-S===-1){this.removeByIndex(t);return}let d=this.metadata[S];this.metadata[t]=d,this.metadata.splice(S,1);let{domNode:f}=c;f.replaceWith(d.domNode),o||d.render(e,s),this.keys[t]=n,this.keys.splice(S,1),f.remove(),b.set(u,c);return}}let a=this.render(e,s),l=a.target;this.metadata[t]={render:a,element:l,key:n,domNode:l},this.keys[t]=n,(this.batchEndIndex===null||this.batchEndIndex!==t-1)&&(this.writeBatch(),this.batchStartIndex=t),this.batchEndIndex=t,this.queuedElements.push(l)}removeEntries(t=0){let{length:e}=this.metadata;for(let s=e-1;s>=t;s--)this.metadata[s].domNode.remove();this.metadata.length=t,this.keys.length=t}hide(t,e,s){if(!e&&(t==null&&(t=this.keys.indexOf(s)),e=this.metadata[t],!e)||e.hidden)return!1;let{comment:n,element:i}=e;return n||(n=F(),e.comment=n),i.replaceWith(n),e.domNode=n,e.hidden=!0,!0}show(t,e,s){if(!e&&(t==null&&(t=this.keys.indexOf(s)),e=this.metadata[t],!e)||!e.hidden)return!1;let{comment:n,element:i}=e;return n.replaceWith(i),e.domNode=i,e.hidden=!1,!0}};var G=new Map;function V(r,t=!0){if(t&&G.has(r))return G.get(r);let e=new CSSStyleSheet;return e.replaceSync(r),t&&G.set(r,e),e}var X=new Map,ct;function At(r,t=!0){let e;return t&&X.has(r)?e=X.get(r):(ct??=document.implementation.createHTMLDocument(),e=ct.createElement("style"),e.textContent=r,t&&X.set(r,e)),e.cloneNode(!0)}var q;function ht(r,t=!0){if(q==null)try{let e=V(r,t);return q=!0,e}catch{q=!1}return q?V(r,t):At(r,t)}function*ut(r,t=!0){for(let e of r)e instanceof HTMLStyleElement?yield V(e.textContent,t):e.ownerNode?yield V([...e.cssRules].map(s=>s.cssText).join(""),t):yield e}var z=new WeakMap;function*dt(r,t=!0){for(let e of r)if(e instanceof HTMLStyleElement)yield e;else if(e.ownerNode instanceof HTMLStyleElement)yield e.ownerNode.cloneNode(!0);else if(t&&z.has(e))yield z.get(e).cloneNode(!0);else{let s=document.createElement("style");s.textContent=[...e.cssRules].map(n=>n.cssText).join(""),t&&z.set(e,s),yield s.cloneNode(!0)}}function ft(r,...t){return ht(typeof r=="string"?r:String.raw({raw:r},...t))}function gt(r){switch(r){case void 0:case null:case!1:return null;case!0:return"";default:return`${r}`}}var $;function j(r){if($??=new Map,$.has(r))return $.get(r);let t=r.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);return $.set(r,t),t}var pt,Ot=Number.parseFloat((pt=navigator.userAgent.match(/Chrome\/([\d.]+)/))==null?void 0:pt[1]),mt,Gt=Number.parseFloat((mt=navigator.userAgent.match(/Firefox\/([\d.]+)/))==null?void 0:mt[1]),bt,Xt=Ot||!navigator.userAgent.includes("AppleWebKit")?Number.NaN:Number.parseFloat((bt=navigator.userAgent.match(/Version\/([\d.]+)/))==null?void 0:bt[1]);function Y(r,t){if(r===t)return r;if(r==null||t==null||typeof t!="object")return t;typeof r!="object"&&(r={});for(let[e,s]of Object.entries(t))s==null?e in r&&delete r[e]:r[e]=Y(r[e],s);return r}function H(r,t,e="reference"){if(r===t)return null;if(t==null||typeof t!="object")return t;if(r==null||typeof r!="object")return structuredClone(t);let s={};if(Array.isArray(t)){if(e==="reference")return t;if(e==="clone")return structuredClone(t);for(let[i,o]of t.entries()){if(o===null){s[i]=null;continue}if(o==null)continue;let a=H(r[i],o,e);a!==null&&(s[i]=a)}return t.length!==r.length&&(s.length=t.length),s}let n=new Set(Object.keys(r));for(let[i,o]of Object.entries(t)){if(n.delete(i),o===null){s[i]=null;continue}if(o==null)continue;let a=H(r[i],o,e);a!==null&&(s[i]=a)}for(let i of n)s[i]=null;return s}function Z(r,t){if(r===t)return!1;if(t==null||typeof t!="object"||r!=null&&typeof r!="object")return!0;for(let[e,s]of Object.entries(t))if(s==null){if(e in r)return!0}else if(Z(r[e],s))return!0;return!1}function yt(r){switch(r){case"boolean":return!1;case"integer":case"float":return 0;case"map":return new Map;case"set":return new Set;case"array":return[];case"object":return null;default:case"string":return""}}function tt(r,t,e,s){return r??={},new Proxy(r,{get(n,i){let o=n[i];if(typeof i!="symbol"){let a=s?`${s}.${i}`:i;if(s?e.add(a):t.add(a),typeof o=="object"&&o!=null)return tt(o,t,e,a)}return o},has(n,i){let o=Reflect.has(n,i);if(typeof i!="symbol"){let a=s?`${s}.p`:i;s?e.add(a):t.add(a)}return o}})}function Mt(r){switch(r){case"boolean":return t=>!!t;case"integer":return Math.round;case"float":return t=>+t;case"map":return Map;case"set":return Set;case"object":case"array":return t=>t;default:case"string":return t=>`${t}`}}function et(r,...t){let e=new Set,s=new Set,n=t.map(l=>{let h=new Set,c=new Set,u=tt(l,h,c);return{poked:h,pokedDeep:c,proxy:u}}),i=tt(this??{},e,s),o=r.apply(i,n.map(l=>l.proxy)),a=r.name?!0:!e.size;return{props:{this:[...e],args:n.map(l=>[...l.poked])},deepPropStrings:{this:[...s],args:n.map(l=>[...l.pokedDeep])},deepProps:{this:[...s].map(l=>l.split(".")),args:n.map(l=>[...l.pokedDeep].map(h=>h.split(".")))},defaultValue:o,reusable:a}}function Tt(){return null}function Ft(r,t,e){let s=typeof t=="string"?{type:t}:t,{watchers:n,value:i,readonly:o,empty:a,type:l,enumerable:h,reflect:c,attr:u,nullable:p,parser:m,nullParser:b,get:g,is:S,diff:d,props:f}=s;if(n??=[],o??=!1,a===void 0&&(a=null),i??=a,g&&!f){let E=et(g.bind(e),e,()=>i);i??=E.defaultValue,f=new Set([...E.props.this,...E.props.args[0]])}if(!l)if(i==null)l="string";else{let E=typeof i;l=E==="number"?Number.isInteger(i)?"integer":"number":E}return h??=r[0]!=="_",p??=l==="boolean"?!1:a==null,p||(a??=yt(l),i??=a),c??=h?l!=="object":u?"write":!1,u??=c?j(r):null,m??=Mt(l),b||(p?b=Tt:b=a===null?()=>yt(l):()=>a),S??=l==="object"?(E,N)=>!Z(E,N):l==="array"?()=>!1:Object.is,d===void 0&&(d=l==="object"?(E,N)=>H(E,N,"reference"):null),{...s,type:l,is:S,diff:d,attr:u,reflect:c,readonly:o,enumerable:h,value:i,parser:m,nullParser:b,key:r,props:f,watchers:n}}function J(r,t,e){var i,o;r.get;let s=e==null?r.nullParser.call(this,e):r.parser.call(this,e),n=s;if(t==null){if(s==null)return!1}else if(s!=null){if(r.diff){if(n=r.diff.call(this,t,s),n==null)return!1}else if(r.is.call(this,t,s))return!1}return r.values?r.values.set(this,s):r.values=new WeakMap([[this,s]]),(i=r.propChangedCallback)==null||i.call(this,r.key,t,s,n),(o=r.changedCallback)==null||o.call(this,t,s,n),!0}function st(r,t,e){let s=Ft(t,e,r);function n(){var c;return(c=s.values)!=null&&c.has(this)?s.values.get(this):s.value}function i(c){let u=this[t];J.call(this,s,u,c)}function o(){var p,m;let c=(p=s.computedValues)==null?void 0:p.get(this),u=this[t];(m=s.needsSelfInvalidation)==null||m.delete(this),J.call(this,s,c,u)}if(s.props)for(let c of s.props)s.watchers.push([c,o]);function a(){let c=s.get.call(this,this,n.bind(this));return(s.computedValues??=new WeakMap).set(this,c),c}function l(c){s.needsSelfInvalidation?s.needsSelfInvalidation.add(this):s.needsSelfInvalidation=new WeakSet([this]);let u=this[t];s.set.call(this,c,i.bind(this));let p=this[t];s.needsSelfInvalidation.has(this)&&(s.needsSelfInvalidation.delete(this),J.call(this,s,u,p))}let h={enumerable:s.enumerable,configurable:!0,get:s.get?a:n,set:s.set?l:i};return Object.defineProperty(r,t,h),s}var Ct=new Set;function U(r="mdw_",t=4){let e;for(;Ct.has(e=Math.random().toString(36).slice(2,t+2)););return Ct.add(e),`${r}${e}`}var nt,St,xt;function B(r){return nt??=document.implementation.createHTMLDocument(),r?(xt??=nt.createRange(),xt.createContextualFragment(r)):(St??=nt.createDocumentFragment(),St.cloneNode())}var K=new Map;function rt(r){let t=`#${U()}`;return K.set(t,{fn:r}),`{${t}}`}var it=new Map;function ot(r,...t){let e,s=t.map(o=>{switch(typeof o){case"string":return o;case"function":return rt(o);case"object":{if(o==null)return"";let a=U();return e??=new Map,e.set(a,o),`<div id="${a}"></div>`}default:throw new Error(`Unexpected substitution: ${o}`)}}),n=String.raw({raw:r},...s);if(e){let o=B(n);for(let[a,l]of e)o.getElementById(a).replaceWith(l);return o}let i;return it.has(n)?i=it.get(n):(i=B(n),it.set(n,i)),i.cloneNode(!0)}function jt({nodes:r},t){let{nodeIndex:e,attrName:s}=this,n=r[e];switch(t){case void 0:case null:case!1:return n.removeAttribute(s),!1;case!0:return n.setAttribute(s,""),"";default:return n.setAttribute(s,t),t}}function Bt({nodeStates:r,comments:t,nodes:e},s){let{commentIndex:n,nodeIndex:i}=this,o=r[i],a=o&1;if(!(s!=null&&s!==!1)){if(a)return;let u=t[n];u||(u=F(),t[n]=u),e[i].replaceWith(u),r[i]|=1;return}let h=e[i],c=o&2;if(typeof s!="object")if(c){let u=new Text(s);h.replaceWith(u),e[i]=u,r[i]&=-3}else h.data=s;a&&(t[n].replaceWith(h),r[i]&=-2)}function Rt({nodeStates:r,nodes:t,comments:e},s){let{commentIndex:n,nodeIndex:i}=this,o=r[i]&1,a=s!=null&&s!==!1;if(a===!o)return;let l=t[i],h=e[n];h||(h=F(),e[n]=h),a?(h.replaceWith(l),r[i]&=-2):(l.replaceWith(h),r[i]|=1)}function Lt({comments:r,nodeStates:t,nodes:e}){let{commentIndex:s,nodeIndex:n}=this,i=F();r[s]=i,t[n]|=1,e[n].replaceWith(i)}function at(r,...t){let[{caches:e,searchStates:s}]=t,{cacheIndex:n,searchIndex:i,subSearch:o,invocation:a}=r,l=e[n],h=s[i];if(h&1)return{value:l,dirty:(h&2)===2};s[i]|=1;let c;if(a){if(o){let u=at(o,...t);if(!u.dirty&&l!==void 0)return s[i]&=-3,{value:l,dirty:!1};c=r.invocation(u.value)}else c=r.invocation(...t);if(c===void 0||l===c)return{value:c,dirty:!1}}return e[n]=c,s[i]|=2,{value:c,dirty:!0}}function wt({options:{context:r,store:t,injections:e}},s,n){return this.expression.call(r,t??n,e)}function Wt(r,t){return t[this.prop]}function Dt(r,t,e){let s=t;for(let n of this.deepProp){if(s===null)return null;if(!(n in s))return;s=s[n]}return s}var Ut=/{([^}]*)}/g;function qt(r,t){if(t)return t[r]}function Et(r,t){if(!t)return;let e=t,s;for(s of r)if(typeof e=="object"){if(e===null)return null;if(!(s in e))return;e=e[s]}else return e[s];return e}function Vt(r,t){let e=t;for(let s of r.split("."))if(!s||(e=e[s],e==null))return null;return e===t?null:e}var Nt=new Map,R=class r{static EVENT_PREFIX_REGEX=/^([*1~]+)?(.*)$/;_interpolationState={nodeIndex:-1,searchIndex:0,cacheIndex:0,commentIndex:0,nodeEntry:null};static shadowRootTag=Symbol();nodesToBind=[];props=[];searches=[];initCache=[];searchByQuery;actionsByPropsUsed;postInitActions=[];tagsWithBindings;tags=[];adapter;events;cloneable;styles=[];adoptedStyleSheets=[];stylesFragment;allIds=[];temporaryIds;interpolated=!1;constructor(...t){this.template=B(),this.append(...t)}*[Symbol.iterator](){for(let t of this.styles)yield t;yield this.template}static compose(...t){for(let[s,n]of Nt)if(s.length===t.length&&t.every((i,o)=>i===s[o]))return n;let e=new r(...t);return Nt.set(t,e),e}append(...t){for(let e of t)typeof e=="string"?this.append(B(e.trim())):e instanceof r?this.append(...e):e instanceof DocumentFragment?this.template.append(e):(e instanceof CSSStyleSheet||e instanceof HTMLStyleElement)&&this.styles.push(e);return this}addCompositionEventListener(t){let e=t.tag??"",s=this.events??=new Map;return s.has(e)?s.get(e).push(t):s.set(e,[t]),this}#n(t,e,s){var n;if((n=this.events)!=null&&n.has(t))for(let i of this.events.get(t)){let o;i.handleEvent?o=i.handleEvent:i.deepProp.length?o=Et(i.deepProp,this.interpolateOptions.defaults):o=qt(i.prop,this.interpolateOptions.defaults),e.addEventListener(i.type,s?o.bind(s):o,i)}}render(t,e,s={}){this.interpolated||this.interpolate({defaults:e??t,...s});let n=this.cloneable.cloneNode(!0),i=s.shadowRoot,o=i??s.target??n.firstElementChild,a={lastChildNode:null,lastChildNodeIndex:0,lastElement:null,nodeStates:new Uint8Array(this._interpolationState.nodeIndex+1),searchStates:new Uint8Array(this._interpolationState.searchIndex),comments:[],nodes:[],caches:this.initCache.slice(),refs:[],options:s},{nodes:l,refs:h,searchStates:c,caches:u}=a;for(let{tag:m,textNodes:b}of this.nodesToBind){let g;if(m===""){if(!b.length)continue;h.push(null),l.push(null),g=n.firstChild}else{let d=n.getElementById(m);if(h.push(d),l.push(d),this.#n(m,d,s.context),!b.length)continue;g=d.firstChild}let S=0;for(let d of b){for(;d!==S;)g=g.nextSibling,S++;l.push(g)}}this.#n("",s.context),this.#n(r.shadowRootTag,s.context.shadowRoot,s.context);for(let m of this.postInitActions)m.invocation(a);let p=(m,b)=>{var S;if(!m)return;let g=!1;for(let d of this.props){if(!((S=this.actionsByPropsUsed)!=null&&S.has(d))||!(d in m))continue;let f=this.actionsByPropsUsed.get(d);for(let E of f){g=!0;let{dirty:N,value:P}=at(E.search,a,m,b);N&&E.invocation(a,P,m,b)}}g&&c.fill(0)};return i?(s.context??=i.host,"adoptedStyleSheets"in i?this.adoptedStyleSheets.length&&(i.adoptedStyleSheets=[...i.adoptedStyleSheets,...this.adoptedStyleSheets]):this.stylesFragment.hasChildNodes()&&n.prepend(this.stylesFragment.cloneNode(!0))):s.context??=o,t!==this.interpolateOptions.defaults&&p(t,e),i&&(i.append(n),customElements.upgrade(i)),p.target=o,p.byProp=(m,b,g)=>{var E,N;if(!((E=this.actionsByPropsUsed)!=null&&E.has(m)))return;let S=!1;if((N=this.searchByQuery)!=null&&N.has(m)){S=!0;let P=this.searchByQuery.get(m);if(u[P.cacheIndex]===b)return;u[P.cacheIndex]=b,c[P.searchIndex]=3}let d,f=this.actionsByPropsUsed.get(m);for(let P of f)if(P.search.query===m)P.invocation(a,b);else{d??={[m]:b},g??=d,S=!0;let _=at(P.search,a,d,g);_.dirty&&P.invocation(a,_.value,d,g)}S&&c.fill(0)},p.state=a,p}#s(t,e,s,n){var _,T;let{nodeValue:i,nodeName:o,nodeType:a}=t,l,h;if(a===Node.ATTRIBUTE_NODE?l=t:h=t,n==null){if(!i)return;let y=i.trim();if(!y)return;if(l||(e==null?void 0:e.tagName)==="STYLE"){if(y[0]!=="{")return;let{length:I}=y;if(y[I-1]!=="}")return;n=y.slice(1,-1)}else{let I=y.split(Ut);if(I.length<3)return;if(I.length===3&&!I[0]&&!I[2])n=I[1];else{for(let[C,k]of I.entries())if(C%2){let x=lt();h.before(x),this.#s(x,e,s,k)}else k&&h.before(k);return!0}}}let c=n,u=n[0]==="!",p=!1;u&&(n=n.slice(1),p=n[0]==="!",p&&(n=n.slice(1)));let m,b;if(h){e!==h.parentElement&&(e=h.parentElement),b=0;let y=h;for(;y=y.previousSibling;)b++}else if(e!==l.ownerElement&&(e=l.ownerElement),o.startsWith("on")){let y=o.indexOf("-");if(y===-1)return;m=y===2}if(m){e.removeAttribute(o);let y=this.#e(e),I=o.slice(3),[,C,k]=I.match(/^([*1~]+)?(.*)$/),x,v,w=[];if(n.startsWith("#"))x=K.get(n).fn;else{let O=n.split(".");O.length===1?(v=n,w=[]):(v=O[0],w=O)}this.addCompositionEventListener({tag:y,type:k,handleEvent:x,prop:v,deepProp:w,once:C==null?void 0:C.includes("1"),passive:C==null?void 0:C.includes("~"),capture:C==null?void 0:C.includes("*")});return}let g;if((_=this.searchByQuery)!=null&&_.has(c))g=this.searchByQuery.get(c);else{let y=n,I=y!==c,C;if(I&&((T=this.searchByQuery)!=null&&T.has(y)))C=this.searchByQuery.get(y);else{let k,x,v,w,O,L,W,A;if(n.startsWith("#")){if(A=K.get(n),!A)return;k=A.fn,W=wt,A.props?(x=A.props,v=A.deepProps,w=A.defaultValue??null):w=A.fn}else w=null,s!=null&&s.defaults&&(w=Et(n.split("."),s.defaults)??null),w==null&&(s!=null&&s.injections)&&(w=Vt(n,s.injections));if(!x)if(typeof w=="function"){let M=et.call(this,w,s==null?void 0:s.defaults,s==null?void 0:s.injections),It=new Set([...M.props.this,...M.props.args[0],...M.props.args[1]]),vt=new Set([...M.deepPropStrings.this,...M.deepPropStrings.args[0]]);k=w,w=M.defaultValue,x=[...It],v=[...vt].map(kt=>kt.split(".")),W=wt}else{let M=n.split(".");M.length===1?(O=n,x=[O],W=Wt):(x=[M[0]],L=M,v=[M],W=Dt)}A&&(A.defaultValue=w,A.props=x,A.deepProps=v),C={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:y,defaultValue:w,subSearch:null,prop:O,propsUsed:x,deepProp:L,deepPropsUsed:v,invocation:W,expression:k},this.addSearch(C)}I?(g={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:c,subSearch:C,negate:u,doubleNegate:p,prop:C.prop,deepProp:C.deepProp,propsUsed:C.propsUsed,deepPropsUsed:C.deepPropsUsed,defaultValue:p?!!C.defaultValue:u?!C.defaultValue:C.defaultValue,invocation(k){return this.doubleNegate?!!k:this.negate?!k:k}},this.addSearch(g)):g=C}let S,d=null,f=g.defaultValue;h?d=b:o==="mdw-if"?(S=this.#e(e),e.removeAttribute(o),f=f!=null&&f!==!1):(d=o,o==="id"||f==null||f===!1?e.removeAttribute(o):e.setAttribute(o,f===!0?"":f)),S??=this.#e(e);let E=this._interpolationState.nodeEntry;(!E||E.tag!==S)&&(E={tag:S,textNodes:[]},this._interpolationState.nodeEntry=E,this.nodesToBind.push(E),this._interpolationState.nodeIndex++);let N;if(h)switch(E.textNodes.push(b),this._interpolationState.nodeIndex++,N={nodeIndex:this._interpolationState.nodeIndex,commentIndex:this._interpolationState.commentIndex++,invocation:Bt,defaultValue:f,search:g},typeof f){case"string":h.data=f;break;case"number":h.data=`${f}`;break;default:h.data="";break}else d?N={nodeIndex:this._interpolationState.nodeIndex,attrName:d,defaultValue:f,invocation:jt,search:g}:(N={nodeIndex:this._interpolationState.nodeIndex,commentIndex:this._interpolationState.commentIndex++,defaultValue:f,invocation:Rt,search:g},f||this.postInitActions.push({...N,invocation:Lt}));this.addAction(N),(this.tagsWithBindings??=new Set).add(S)}#e(t){if(!t)return"";let e=t.id;return e?this.allIds.includes(e)||this.allIds.push(e):(e=U(),(this.temporaryIds??=new Set).add(e),this.allIds.push(e),t.id=e),e}#t(t,e){let s=t.getAttribute("mdw-for"),n=s==null?void 0:s.trim();if(!n||n[0]!=="{")return null;let{length:i}=n;if(n[i-1]!=="}")return null;let o=n.slice(1,-1),[a,l]=o.split(/\s+of\s+/);t.removeAttribute("mdw-for");let h=t.ownerDocument.createElement("template");t.replaceWith(h);let c=this.#e(h),u=this._interpolationState.nodeEntry;(!u||u.tag!==c)&&(u={tag:c,textNodes:[]},this._interpolationState.nodeEntry=u,this.nodesToBind.push(u),this._interpolationState.nodeIndex++);let p=new r;p.template.append(t);let m={...e.injections,[a]:null,index:null},b=[l],g={cacheIndex:this._interpolationState.cacheIndex++,searchIndex:this._interpolationState.searchIndex++,query:null,prop:null,deepProp:null,propsUsed:b,deepPropsUsed:[[l]],defaultValue:{},invocation:null},S={defaultValue:null,nodeIndex:this._interpolationState.nodeIndex,search:g,commentIndex:this._interpolationState.commentIndex++,injections:m,invocation(f,E,N,P){if(!p.adapter){let x=f.nodes[this.nodeIndex],v=F();f.comments[this.commentIndex]=v,x.replaceWith(v),p.adapter=new D({anchorNode:v,composition:p,renderOptions:{target:null,context:f.options.context,store:f.options.store,injections:this.injections}})}let{adapter:_}=p,T=(P??f.options.store)[l];if(!T||T.length===0){_.removeEntries();return}let y=N[l],I={...N},C=p.props.some(x=>x!==l&&x in N);_.startBatch();let k;if(!C&&!(k=Array.isArray(y))){let x=k?y.entries():Object.entries(y);for(let[v,w]of x){if(v==="length"||w===null)continue;let O=+v,L=T[O];I[a]=w,this.injections[a]=L,this.injections.index=O,_.renderData(O,I,P,L,w)}}else{y||delete I[a];for(let[x,v]of T.entries()){let w;if(y){if(!C&&!(x in y)||(w=y[x],w===null))continue;I[a]=w}this.injections[a]=v,this.injections.index=x,_.renderData(x,I,P,v,w)}}_.stopBatch(),_.removeEntries(T.length)}};return p.interpolate({defaults:e.defaults,injections:m}),b.push(...p.props),this.addSearch(g),this.addAction(S),(this.tagsWithBindings??=new Set).add(c),p}interpolate(t){var i;this.interpolateOptions=t,this.cloneable=this.template.cloneNode(!0);let s=document.createTreeWalker(this.cloneable,5),n=s.nextNode();for(;n;){let o=null;switch(n.nodeType){case Node.ELEMENT_NODE:if(o=n,o.tagName==="TEMPLATE"){for(;o.contains(n=s.nextNode()););continue}if(o.tagName==="SCRIPT"){for(;o.contains(n=s.nextNode()););continue}if(o.hasAttribute("mdw-for")){for(;o.contains(n=s.nextNode()););this.#t(o,t);continue}else{let a=o.attributes.id;a&&(this.#s(a,o,t),this.#e(o));for(let l of[...o.attributes].reverse())l.nodeName!=="id"&&this.#s(l,o,t)}break;case Node.TEXT_NODE:if(o=n.parentElement,this.#s(n,o,t)){let a=s.nextNode();n.remove(),n=a;continue}break;default:throw new Error(`Unexpected node type: ${n.nodeType}`)}n=s.nextNode()}"adoptedStyleSheets"in document?this.adoptedStyleSheets=[...ut(this.styles)]:(this.stylesFragment=B(),this.stylesFragment.append(...dt(this.styles))),this.props=this.actionsByPropsUsed?[...this.actionsByPropsUsed.keys()]:[];for(let o of this.allIds)(i=this.tagsWithBindings)!=null&&i.has(o)||this.nodesToBind.push({tag:o,textNodes:[]});this.tags=this.nodesToBind.map(o=>o.tag),this.interpolated=!0}addSearch(t){return this.searches.push(t),t.query&&((this.searchByQuery??=new Map).set(t.query,t),this.initCache[t.cacheIndex]=t.defaultValue),t}addAction(t){let e=this.actionsByPropsUsed??=new Map;for(let s of t.search.propsUsed)e.has(s)?e.get(s).push(t):e.set(s,[t]);return t}};function ge(r,t){return(e,s,n)=>{s==null?n.refs[t].removeAttribute(r):n.refs[t].setAttribute(r,s)}}var Q=class r extends HTMLElement{static elementName;static get observedAttributes(){return this.attrList.keys()}compose(){return this.#t??=new R}static _composition=null;static _props=new Map;static _attrs=new Map;static _propChangedCallbacks=new Map;static _attributeChangedCallbacks=new Map;static _onComposeCallbacks=[];static _onConnectedCallbacks=[];static _onDisconnectedCallbacks=[];static _onConstructedCallbacks=[];static interpolatesTemplate=!0;static supportsElementInternals="attachInternals"in HTMLElement.prototype;static supportsElementInternalsRole=r.supportsElementInternals&&"role"in ElementInternals.prototype;static templatable=null;static defined=!1;static autoRegistration=!0;static registrations=new Map;static expressions=this.set;static methods=this.set;static overrides=this.set;static props=this.observe;static idl=this.prop;static _addCallback(t,e){if(!this.hasOwnProperty(t)){this[t]=[...this[t],e];return}this[t].push(e)}static append(...t){return this._onComposeCallbacks.push(({composition:e})=>{e.append(...t)}),this._addCallback("_onComposeCallbacks",(e=>{let{composition:s}=e;s.append(...t)})),this}static recompose(t){return this._addCallback("_onComposeCallbacks",t),this}static css(t,...e){return this._addCallback("_onComposeCallbacks",(s=>{let{composition:n}=s;typeof t=="string"||Array.isArray(t)?n.append(ft(t,...e)):n.append(t,...e)})),this}static autoRegister(t){return this.hasOwnProperty("defined")&&this.defined?this:(this.register(t),this)}static html(t,...e){return this._addCallback("_onComposeCallbacks",(s=>{let{composition:n}=s;n.append(ot(t,...e))})),this}static extend(t){return t?t(this):class extends this{}}static setStatic(t){return Object.assign(this,t),this}static readonly(t,e){return this.set(t,{...e,writable:!1})}static set(t,e){return Object.defineProperties(this.prototype,Object.fromEntries([...Object.entries(t).map(([s,n])=>(this.undefine(s),[s,{enumerable:s[0]!=="_",configurable:!0,value:n,writable:!0,...e}])),...Object.getOwnPropertySymbols(t).map(s=>[s,{enumerable:!1,configurable:!0,value:t[s],writable:!0,...e}])])),this}static mixin(t){return t(this)}static register(t){return t&&(this.elementName=t),customElements.define(this.elementName,this),r.registrations.set(this.elementName,this),this.defined=!0,this}static get propList(){return this.hasOwnProperty("_props")||(this._props=new Map(this._props)),this._props}static get attrList(){return this.hasOwnProperty("_attrs")||(this._attrs=new Map(this._attrs)),this._attrs}static get propChangedCallbacks(){return this.hasOwnProperty("_propChangedCallbacks")||(this._propChangedCallbacks=new Map([...this._propChangedCallbacks].map(([t,e])=>[t,e.slice()]))),this._propChangedCallbacks}static get attributeChangedCallbacks(){return this.hasOwnProperty("_attributeChangedCallbacks")||(this._attributeChangedCallbacks=new Map([...this._attributeChangedCallbacks].map(([t,e])=>[t,e.slice()]))),this._attributeChangedCallbacks}static prop(t,e){let s=st(this.prototype,t,e),{changedCallback:n,attr:i,reflect:o,watchers:a}=s;return n&&a.push([t,n]),s.changedCallback=function(h,c,u){this._onObserverPropertyChanged.call(this,t,h,c,u)},this.propList.set(t,s),i&&(o===!0||o==="read")&&(s.enumerable||!this.attrList.has(i)||!this.attrList.get(i).enumerable)&&this.attrList.set(i,s),this.onPropChanged(a),this}static define(t){return Object.defineProperties(this.prototype,Object.fromEntries(Object.entries(t).map(([e,s])=>(this.undefine(e),[e,{enumerable:e[0]!=="_",configurable:!0,...typeof s=="function"?{get:s}:s}])))),this}static undefine(t){if(Reflect.deleteProperty(this.prototype,t),this.propList.has(t)){let{watchers:e,attr:s,reflect:n}=this.propList.get(t);if(e.length&&this.propChangedCallbacks.has(t)){let i=this.propChangedCallbacks.get(t);for(let[o,a]of e){let l=i.indexOf(a);l!==-1&&i.splice(l,1)}}s&&(n===!0||n==="read")&&this.attrList.delete(s),this.propList.delete(t)}return this}static observe(t){for(let[e,s]of Object.entries(t??{})){let n=typeof s=="function"?{reflect:!1,get:s}:s;this.prop(e,n)}return this}static defineStatic(t){for(let[e,s]of Object.entries(t??{}))st(this,e,{reflect:!1,...typeof s=="function"?{get:s}:typeof s=="string"?{type:s}:s});return this}static events(t,e){return this.on({composed({composition:s}){for(let[n,i]of Object.entries(t)){let[,o,a]=n.match(/^([*1~]+)?(.*)$/),l,h=[];if(typeof i=="string"){let c=i.split(".");c.length===1?(l=i,h=[]):(l=c[0],h=c)}s.addCompositionEventListener({type:a,once:o==null?void 0:o.includes("1"),passive:o==null?void 0:o.includes("~"),capture:o==null?void 0:o.includes("*"),...typeof i=="function"?{handleEvent:i}:typeof i=="string"?{prop:l,deepProp:h}:i,...e})}}}),this}static childEvents(t,e){for(let[s,n]of Object.entries(t))this.events(n,{tag:j(s),...e});return this}static rootEvents(t,e){return this.events(t,{tag:R.shadowRootTag,...e})}static on(t,e){let s=typeof t=="string"?{[t]:e}:t;for(let[n,i]of Object.entries(s)){let o;switch(n){case"composed":o="_onComposeCallbacks";break;case"constructed":o="_onConstructedCallbacks";break;case"connected":o="_onConnectedCallbacks";break;case"disconnected":o="_onDisconnectedCallbacks";break;case"props":this.onPropChanged(i);continue;case"attrs":this.onAttributeChanged(i);continue;default:if(n.endsWith("Changed")){let a=n.slice(0,n.length-7);this.onPropChanged({[a]:i});continue}throw new Error("Invalid callback name")}this._addCallback(o,i)}return this}static onPropChanged(t){let e=Array.isArray(t)?t:Object.entries(t),{propChangedCallbacks:s}=this;for(let[n,i]of e)s.has(n)?s.get(n).push(i):s.set(n,[i]);return this}static onAttributeChanged(t){let e=Array.isArray(t)?t:Object.entries(t),{attributeChangedCallbacks:s}=this;for(let[n,i]of e)s.has(n)?s.get(n).push(i):s.set(n,[i]);return this}#n;#s=new Map;#e=new Map;#t;#r=!1;#i=[];_propAttributeCache;_callbackArguments=null;constructor(...t){super(),r.supportsElementInternals&&(this.elementInternals=this.attachInternals()),this.attachShadow({mode:"open",delegatesFocus:this.delegatesFocus}),this.render=this.composition.render(this.constructor.prototype,this,{defaults:this.constructor.prototype,store:this,shadowRoot:this.shadowRoot,context:this});for(let e of this.static._onConstructedCallbacks)e.call(this,this.callbackArguments)}propChangedCallback(t,e,s,n=s){this.#r?this.#i.push([t,n,this]):this.render.byProp(t,n,this);let{_propChangedCallbacks:i}=this.static;if(i.has(t))for(let o of i.get(t))o.call(this,e,s,n,this)}attributeChangedCallback(t,e,s){let{attributeChangedCallbacks:n}=this.static;if(n.has(t))for(let c of n.get(t))c.call(this,e,s,this);let{attrList:i}=this.static;if(!i.has(t))return;let o=i.get(t);if(o.attributeChangedCallback){o.attributeChangedCallback.call(this,t,e,s);return}let a;if(this.attributeCache.has(t)&&(a=this.attributeCache.get(t),a.stringValue===s))return;let l=this[o.key],h=s===null?o.nullParser(s):o.type==="boolean"?!0:o.parser(s);h!==l&&(a?(a.stringValue=s,a.parsedValue=h):this.attributeCache.set(t,{stringValue:s,parsedValue:h}),this[o.key]=h)}get#o(){var t;return(t=this.#t)==null?void 0:t.template}_onObserverPropertyChanged(t,e,s,n){let{propList:i}=this.static;if(i.has(t)){let{reflect:o,attr:a}=i.get(t);if(a&&(o===!0||o==="write")){let l,h=!1,{attributeCache:c}=this;if(c.has(a)?(l=c.get(a),h=l.parsedValue!==s):(l={},c.set(a,l),h=!0),h){let u=gt(s);l.parsedValue=s,l.stringValue=u,u==null?this.removeAttribute(a):this.setAttribute(a,u)}}}this.propChangedCallback(t,e,s,n)}patch(t){this.#r=!0,Y(this,t);for(let[e,s,n]of this.#i)e in t||this.render.byProp(e,s,n);this.#i.slice(0,this.#i.length),this.render(t),this.#r=!1}get refs(){return this.#n??=new Proxy({},{get:(t,e)=>{this.#t;let s=this.composition,n;if(!s.interpolated){if(this.#e.has(e)&&(n=this.#e.get(e).deref(),n))return n;let a=j(e);return n=s.template.getElementById(a),n?(this.#e.set(e,new WeakRef(n)),n):null}if(this.#s.has(e)&&(n=this.#s.get(e).deref(),n))return n;let i=j(e),o=this.composition.tags.indexOf(i);return n=this.render.state.refs[o],n?(this.#s.set(e,new WeakRef(n)),n):null}})}get attributeCache(){return this._propAttributeCache??=new Map}get static(){return this.constructor}get unique(){return!1}get callbackArguments(){return this._callbackArguments??={composition:this.#t,refs:this.refs,html:ot.bind(this),inline:rt,template:this.#o,element:this}}get composition(){if(this.#t)return this.#t;if(!this.unique&&this.static.hasOwnProperty("_composition"))return this.#t=this.static._composition,this.static._composition;this.compose();for(let t of this.static._onComposeCallbacks)t.call(this,this.callbackArguments);return this.unique||(this.static._composition=this.#t),this.#t}connectedCallback(){for(let t of this.static._onConnectedCallbacks)t.call(this,this.callbackArguments)}disconnectedCallback(){for(let t of this.static._onDisconnectedCallbacks)t.call(this,this.callbackArguments)}};Q.prototype.delegatesFocus=!1;export{ge as cloneAttributeCallback,Q as default};
|
|
2
|
+
//# sourceMappingURL=CustomElement.min.js.map
|