@neovici/cosmoz-autocomplete 8.5.0 → 8.6.0

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.
@@ -33,9 +33,30 @@ const Listbox = (props) => {
33
33
  })}
34
34
  </div>`;
35
35
  };
36
+ const supportsPopover = () => {
37
+ // eslint-disable-next-line no-prototype-builtins
38
+ return HTMLElement.prototype.hasOwnProperty('popover');
39
+ };
40
+ const showPopover = (popover) => {
41
+ const popoverElement = popover;
42
+ requestAnimationFrame(() => {
43
+ popoverElement?.showPopover();
44
+ });
45
+ };
36
46
  customElements.define('cosmoz-listbox', component(Listbox, { styleSheets: [sheet(style)] }));
37
- export const listbox = ({ multi, ...thru }) => portal(html `<cosmoz-listbox
47
+ export const listbox = ({ multi, ...thru }) => {
48
+ if (supportsPopover()) {
49
+ return html `<cosmoz-listbox
50
+ ${ref(showPopover)}
51
+ popover="manual"
52
+ part="listbox"
53
+ ?multi=${multi}
54
+ ...=${spreadProps(props(properties)(thru))}
55
+ ></cosmoz-listbox>`;
56
+ }
57
+ return portal(html `<cosmoz-listbox
38
58
  part="listbox"
39
59
  ?multi=${multi}
40
60
  ...=${spreadProps(props(properties)(thru))}
41
61
  ></cosmoz-listbox>`);
62
+ };
@@ -11,9 +11,17 @@ const style = css `
11
11
  font-family: var(--paper-font-subhead_-_font-family, initial);
12
12
  background: #fff;
13
13
  min-width: 72px;
14
- box-shadow: 0 3px 4px 0 rgba(0, 0, 0, 0.14), 0 1px 8px 0 rgba(0, 0, 0, 0.12),
14
+ box-shadow:
15
+ 0 3px 4px 0 rgba(0, 0, 0, 0.14),
16
+ 0 1px 8px 0 rgba(0, 0, 0, 0.12),
15
17
  0 3px 3px -2px rgba(0, 0, 0, 0.4);
16
18
  }
19
+ :host(:popover-open) {
20
+ box-sizing: border-box;
21
+ display: block;
22
+ margin: 0;
23
+ border: 0;
24
+ }
17
25
  .items {
18
26
  position: relative;
19
27
  overflow-y: auto;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-autocomplete",
3
- "version": "8.5.0",
3
+ "version": "8.6.0",
4
4
  "description": "A autocomplete input web component",
5
5
  "keywords": [
6
6
  "lit-html",
@@ -70,8 +70,8 @@
70
70
  },
71
71
  "dependencies": {
72
72
  "@lit-labs/virtualizer": "^2.0.0",
73
- "@neovici/cosmoz-dropdown": "^4.0.0",
74
- "@neovici/cosmoz-input": "^4.3.1",
73
+ "@neovici/cosmoz-dropdown": "^4.4.0",
74
+ "@neovici/cosmoz-input": "^4.3.3",
75
75
  "@neovici/cosmoz-utils": "^6.0.0",
76
76
  "@pionjs/pion": "^2.0.0",
77
77
  "lit-html": "^2.0.0 || ^3.0.0"