@vollowx/seele 0.8.7 → 0.8.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vollowx/seele",
3
- "version": "0.8.7",
3
+ "version": "0.8.9",
4
4
  "description": "Standard Extensible Elements. A web components library that can be styled and extended freely, pre-providing components in Material Design 3.",
5
5
  "author": "vollowx",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "lit",
27
27
  "ui-components"
28
28
  ],
29
- "homepage": "https://docs.seele.v9.nz",
29
+ "homepage": "https://seele.v9.nz",
30
30
  "repository": {
31
31
  "type": "git",
32
32
  "url": "https://github.com/vollowx/seele.git"
package/src/base/menu.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { LitElement, html } from 'lit';
3
- import { property, query } from 'lit/decorators.js';
3
+ import { property, query, queryAssignedElements } from 'lit/decorators.js';
4
4
  import { setFocusVisible } from '../core/focus-visible.js';
5
5
  import { Attachable } from './mixins/attachable.js';
6
6
  import { InternalsAttached } from './mixins/internals-attached.js';
@@ -52,8 +52,7 @@ export class Menu extends Base {
52
52
  this.listController = new ListController(this, {
53
53
  isItem: (item) => this._possibleItemTags.includes(item.tagName.toLowerCase()) &&
54
54
  !item.hasAttribute('disabled'),
55
- getPossibleItems: () => Array.from(this.children).filter((child) => this._possibleItemTags.includes(child.tagName.toLowerCase()) &&
56
- !child.hasAttribute('disabled')),
55
+ getPossibleItems: () => this.slotItems,
57
56
  blurItem: (item) => {
58
57
  item.focused = false;
59
58
  },
@@ -90,9 +89,11 @@ export class Menu extends Base {
90
89
  // TODO: Handle $control change
91
90
  this.$control.addEventListener('focusout', this.#handleFocusOut.bind(this));
92
91
  }
93
- this.listController.items.forEach((item) => {
94
- item.addEventListener('mouseover', this.#handleItemMouseOver.bind(this));
95
- item.addEventListener('click', this.#handleItemClick.bind(this));
92
+ this.updateComplete.then(() => {
93
+ this.listController.items.forEach((item) => {
94
+ item.addEventListener('mouseover', this.#handleItemMouseOver.bind(this));
95
+ item.addEventListener('click', this.#handleItemClick.bind(this));
96
+ });
96
97
  });
97
98
  }
98
99
  disconnectedCallback() {
@@ -202,7 +203,7 @@ export class Menu extends Base {
202
203
  this.listController.items[index].focused = false;
203
204
  this.dispatchEvent(new CustomEvent('select', {
204
205
  detail: {
205
- item: this.listController.items[index],
206
+ item: clickedItem,
206
207
  index: index,
207
208
  },
208
209
  bubbles: true,
@@ -247,3 +248,6 @@ __decorate([
247
248
  __decorate([
248
249
  query('[part="menu"]')
249
250
  ], Menu.prototype, "$menu", void 0);
251
+ __decorate([
252
+ queryAssignedElements({ flatten: true })
253
+ ], Menu.prototype, "slotItems", void 0);
@@ -1,7 +1,7 @@
1
1
  var _a;
2
2
  import { __decorate } from "tslib";
3
3
  import { LitElement, isServer, html } from 'lit';
4
- import { property, query } from 'lit/decorators.js';
4
+ import { property, query, queryAssignedElements } from 'lit/decorators.js';
5
5
  import { FormAssociated } from './mixins/form-associated.js';
6
6
  import { InternalsAttached } from './mixins/internals-attached.js';
7
7
  import { PopoverController } from './controllers/popover-controller.js';
@@ -61,8 +61,7 @@ export class Select extends Base {
61
61
  this.listController = new ListController(this, {
62
62
  isItem: (item) => this._possibleItemTags.includes(item.tagName.toLowerCase()) &&
63
63
  !item.hasAttribute('disabled'),
64
- getPossibleItems: () => Array.from(this.children).filter((child) => this._possibleItemTags.includes(child.tagName.toLowerCase()) &&
65
- !child.hasAttribute('disabled')),
64
+ getPossibleItems: () => this.slotItems,
66
65
  blurItem: (item) => {
67
66
  item.focused = false;
68
67
  },
@@ -138,18 +137,19 @@ export class Select extends Base {
138
137
  this.removeEventListener('click', this.#handleOptionClick);
139
138
  }
140
139
  async firstUpdated(changed) {
141
- // Wait for slotted children to be ready
142
- await this.updateComplete;
143
- if (!this.listController.items.length) {
144
- setTimeout(() => {
145
- if (!this.lastSelectedOptionRecords.length) {
146
- this.updateValueAndDisplayText();
147
- }
148
- }, 0);
149
- }
140
+ // If this has been handled on update already due to SSR, try again.
150
141
  if (!this.lastSelectedOptionRecords.length) {
151
142
  this.initUserSelection();
152
143
  }
144
+ // Case for when the DOM is streaming, there are no children, and a child
145
+ // has [selected] set on it, we need to wait for DOM to render something.
146
+ if (!this.lastSelectedOptionRecords.length &&
147
+ !isServer &&
148
+ !this.options.length) {
149
+ setTimeout(() => {
150
+ this.updateValueAndDisplayText();
151
+ }, 0);
152
+ }
153
153
  super.firstUpdated(changed);
154
154
  }
155
155
  update(changed) {
@@ -378,3 +378,6 @@ __decorate([
378
378
  __decorate([
379
379
  query('[part="menu"]')
380
380
  ], Select.prototype, "$menu", void 0);
381
+ __decorate([
382
+ queryAssignedElements({ flatten: true })
383
+ ], Select.prototype, "slotItems", void 0);