@momentum-design/components 0.120.11 → 0.120.12

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.
@@ -1,12 +1,12 @@
1
1
  export { default as Accordion } from './accordion';
2
2
  export { default as AccordionGroup } from './accordiongroup';
3
3
  export { default as AccordionButton } from './accordionbutton';
4
- export { default as AlertChip } from './alertchip';
5
4
  export { default as Animation } from './animation';
6
- export { default as AnnouncementDialog } from './announcementdialog';
5
+ export { default as AlertChip } from './alertchip';
7
6
  export { default as Appheader } from './appheader';
8
7
  export { default as Avatar } from './avatar';
9
8
  export { default as AvatarButton } from './avatarbutton';
9
+ export { default as AnnouncementDialog } from './announcementdialog';
10
10
  export { default as Badge } from './badge';
11
11
  export { default as Banner } from './banner';
12
12
  export { default as Brandvisual } from './brandvisual';
@@ -48,9 +48,9 @@ export { default as MenuItemCheckbox } from './menuitemcheckbox';
48
48
  export { default as MenuItemRadio } from './menuitemradio';
49
49
  export { default as MenuPopover } from './menupopover';
50
50
  export { default as MenuSection } from './menusection';
51
+ export { default as NavMenuItem } from './navmenuitem';
51
52
  export { default as OptGroup } from './optgroup';
52
53
  export { default as Option } from './option';
53
- export { default as NavMenuItem } from './navmenuitem';
54
54
  export { default as Password } from './password';
55
55
  export { default as Popover } from './popover';
56
56
  export { default as Presence } from './presence';
@@ -60,10 +60,10 @@ export { default as Radio } from './radio';
60
60
  export { default as RadioGroup } from './radiogroup';
61
61
  export { default as ScreenreaderAnnouncer } from './screenreaderannouncer';
62
62
  export { default as Searchfield } from './searchfield';
63
- export { default as Select } from './select';
64
63
  export { default as Selectlistbox } from './selectlistbox';
65
64
  export { default as SideNavigation } from './sidenavigation';
66
65
  export { default as Skeleton } from './skeleton';
66
+ export { default as Select } from './select';
67
67
  export { default as Slider } from './slider';
68
68
  export { default as Spinner } from './spinner';
69
69
  export { default as StaticCheckbox } from './staticcheckbox';
@@ -1,12 +1,12 @@
1
1
  export { default as Accordion } from './accordion';
2
2
  export { default as AccordionGroup } from './accordiongroup';
3
3
  export { default as AccordionButton } from './accordionbutton';
4
- export { default as AlertChip } from './alertchip';
5
4
  export { default as Animation } from './animation';
6
- export { default as AnnouncementDialog } from './announcementdialog';
5
+ export { default as AlertChip } from './alertchip';
7
6
  export { default as Appheader } from './appheader';
8
7
  export { default as Avatar } from './avatar';
9
8
  export { default as AvatarButton } from './avatarbutton';
9
+ export { default as AnnouncementDialog } from './announcementdialog';
10
10
  export { default as Badge } from './badge';
11
11
  export { default as Banner } from './banner';
12
12
  export { default as Brandvisual } from './brandvisual';
@@ -48,9 +48,9 @@ export { default as MenuItemCheckbox } from './menuitemcheckbox';
48
48
  export { default as MenuItemRadio } from './menuitemradio';
49
49
  export { default as MenuPopover } from './menupopover';
50
50
  export { default as MenuSection } from './menusection';
51
+ export { default as NavMenuItem } from './navmenuitem';
51
52
  export { default as OptGroup } from './optgroup';
52
53
  export { default as Option } from './option';
53
- export { default as NavMenuItem } from './navmenuitem';
54
54
  export { default as Password } from './password';
55
55
  export { default as Popover } from './popover';
56
56
  export { default as Presence } from './presence';
@@ -60,10 +60,10 @@ export { default as Radio } from './radio';
60
60
  export { default as RadioGroup } from './radiogroup';
61
61
  export { default as ScreenreaderAnnouncer } from './screenreaderannouncer';
62
62
  export { default as Searchfield } from './searchfield';
63
- export { default as Select } from './select';
64
63
  export { default as Selectlistbox } from './selectlistbox';
65
64
  export { default as SideNavigation } from './sidenavigation';
66
65
  export { default as Skeleton } from './skeleton';
66
+ export { default as Select } from './select';
67
67
  export { default as Slider } from './slider';
68
68
  export { default as Spinner } from './spinner';
69
69
  export { default as StaticCheckbox } from './staticcheckbox';
@@ -1,7 +1,7 @@
1
1
  import { ReactiveController } from 'lit';
2
2
  import type { Component } from '../../models';
3
3
  export type ElementStoreChangeTypes = 'added' | 'removed';
4
- interface ElementStoreOptions<TItem extends HTMLElement = HTMLElement> {
4
+ interface ElementStoreOptions<TItem extends HTMLElement> {
5
5
  /**
6
6
  * Checks if the item is valid.
7
7
  * Invalid items will not be collected or processed.
@@ -19,9 +19,9 @@ interface ElementStoreOptions<TItem extends HTMLElement = HTMLElement> {
19
19
  * @param item - The item that is being added or removed.
20
20
  * @param changeType - The type of change ('added' or 'removed').
21
21
  * @param index - Index at which the item is added or removed.
22
- * @param store - The current state of the store.
22
+ * @param items - Items in the store before the change.
23
23
  */
24
- onStoreUpdate?: (item: TItem, changeType: ElementStoreChangeTypes, index: number, store?: TItem[]) => void;
24
+ onStoreUpdate?: (item: TItem, changeType: ElementStoreChangeTypes, index: number, items: TItem[]) => void;
25
25
  }
26
26
  /**
27
27
  * ElementStore is a controller that manages a collection of elements.
@@ -102,7 +102,7 @@ export declare class ElementStore<TItem extends HTMLElement> implements Reactive
102
102
  * @param host - The host component that this controller is attached to.
103
103
  * @param options - Element store options
104
104
  */
105
- constructor(host: Component, options?: ElementStoreOptions);
105
+ constructor(host: Component, options?: ElementStoreOptions<TItem>);
106
106
  hostConnected(): void;
107
107
  hostDisconnected(): void;
108
108
  /**
@@ -159,6 +159,6 @@ export declare class ElementStore<TItem extends HTMLElement> implements Reactive
159
159
  *
160
160
  * @param items - The items to set in the cache.
161
161
  */
162
- protected reset(items: TItem[]): void;
162
+ protected reset(items?: TItem[]): void;
163
163
  }
164
164
  export {};
@@ -98,11 +98,19 @@ export class ElementStore {
98
98
  host.addController(this);
99
99
  this.isValidItem = (options === null || options === void 0 ? void 0 : options.isValidItem) || defaultIsValidFn;
100
100
  this.onStoreUpdate = options === null || options === void 0 ? void 0 : options.onStoreUpdate;
101
+ }
102
+ hostConnected() {
101
103
  this.host.addEventListener(LIFE_CYCLE_EVENTS.CREATED, this.itemCreationHandler);
102
104
  this.host.addEventListener(LIFE_CYCLE_EVENTS.DESTROYED, this.itemDestroyHandler);
103
105
  }
104
- hostConnected() { }
105
- hostDisconnected() { }
106
+ hostDisconnected() {
107
+ this.host.removeEventListener(LIFE_CYCLE_EVENTS.CREATED, this.itemCreationHandler);
108
+ this.host.removeEventListener(LIFE_CYCLE_EVENTS.DESTROYED, this.itemDestroyHandler);
109
+ // This is a shortcut, because after the removal of the parent the children will emit the destroyed event,
110
+ // but it is less performant also we want to skip the onStoreUpdate calls after disconnection
111
+ // re-connection of the element will fill the cache again
112
+ this.reset();
113
+ }
106
114
  /**
107
115
  * Adds an item to the cache.
108
116
  * If the item is valid and not already in the cache, it will be added at the end of the cache.
@@ -175,6 +183,7 @@ export class ElementStore {
175
183
  */
176
184
  reset(items) {
177
185
  this.cache.length = 0;
178
- this.cache.push(...(items || []));
186
+ if (items)
187
+ this.cache.push(...items);
179
188
  }
180
189
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@momentum-design/components",
3
3
  "packageManager": "yarn@3.2.4",
4
- "version": "0.120.11",
4
+ "version": "0.120.12",
5
5
  "engines": {
6
6
  "node": ">=20.0.0",
7
7
  "npm": ">=8.0.0"