@neovici/cosmoz-autocomplete 8.5.0 → 8.7.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.
@@ -1,20 +1,4 @@
1
1
  import { Props } from './use-listbox';
2
2
  export declare const listbox: <I>({ multi, ...thru }: Props<I> & {
3
3
  multi?: boolean | undefined;
4
- }) => import("lit-html/directive.js").DirectiveResult<{
5
- new (_partInfo: import("lit-html/directive.js").PartInfo): {
6
- _op?: import("lit-html").ChildPart | undefined;
7
- _outlet?: HTMLElement | undefined;
8
- _content?: unknown;
9
- render(content: unknown, outlet?: HTMLElement | undefined): import("lit-html").TemplateResult<1>;
10
- update(part: import("lit-html").Part, [content, outlet]: [unknown, (HTMLElement | undefined)?]): import("lit-html").TemplateResult<1>;
11
- updateOutlet(outlet: HTMLElement, content: unknown): void;
12
- clearOutlet(): void;
13
- disconnected(): void;
14
- reconnected(): void;
15
- isConnected: boolean;
16
- _$initialize(part: import("lit-html").Part, parent: import("lit-html").Disconnectable, attributeIndex: number | undefined): void;
17
- setValue(value: unknown): void;
18
- readonly _$isConnected: boolean;
19
- };
20
- }>;
4
+ }) => import("lit-html").TemplateResult<1>;
@@ -1,6 +1,5 @@
1
1
  import { virtualize, virtualizerRef, } from '@lit-labs/virtualizer/virtualize.js';
2
2
  import { sheet } from '@neovici/cosmoz-utils';
3
- import { portal } from '@neovici/cosmoz-utils/directives/portal';
4
3
  import { spreadProps } from '@neovici/cosmoz-utils/directives/spread-props';
5
4
  import { useStyleSheet } from '@neovici/cosmoz-utils/hooks/use-stylesheet';
6
5
  import { props } from '@neovici/cosmoz-utils/object';
@@ -33,9 +32,25 @@ const Listbox = (props) => {
33
32
  })}
34
33
  </div>`;
35
34
  };
35
+ const supportsPopover = () => {
36
+ // eslint-disable-next-line no-prototype-builtins
37
+ return HTMLElement.prototype.hasOwnProperty('popover');
38
+ };
39
+ const showPopover = (popover) => {
40
+ const popoverElement = popover;
41
+ if (supportsPopover()) {
42
+ requestAnimationFrame(() => {
43
+ popoverElement?.showPopover();
44
+ });
45
+ }
46
+ };
36
47
  customElements.define('cosmoz-listbox', component(Listbox, { styleSheets: [sheet(style)] }));
37
- export const listbox = ({ multi, ...thru }) => portal(html `<cosmoz-listbox
38
- part="listbox"
39
- ?multi=${multi}
40
- ...=${spreadProps(props(properties)(thru))}
41
- ></cosmoz-listbox>`);
48
+ export const listbox = ({ multi, ...thru }) => {
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
+ };
@@ -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.7.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"