@omegagrid/core 0.9.11 → 0.9.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.
@@ -14,6 +14,7 @@ export declare class Dropdown extends LitElement implements Layout {
14
14
  alignment: 'left' | 'right';
15
15
  positionOffset: number;
16
16
  dropdownParent: HTMLElement;
17
+ animation: number;
17
18
  label: string | HTMLElement | TemplateResult;
18
19
  icon: IconSpec | string;
19
20
  width: number;
@@ -26,6 +27,7 @@ export declare class Dropdown extends LitElement implements Layout {
26
27
  get isOpen(): boolean;
27
28
  connectedCallback(): void;
28
29
  _onDocumentMouseDown: (e: MouseEvent) => void;
30
+ animateDropdown(seconds: number): void;
29
31
  open(): Promise<void>;
30
32
  close(): void;
31
33
  toggle(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../src/ui/dropdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,cAAc,EAAE,MAAM,KAAK,CAAC;AAE5D,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAK9C,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAKlC,qBAAa,aAAc,SAAQ,KAAK;gBAE3B,KAAK,EAAE,MAAM;CAGzB;AAED,qBACa,iBAAkB,SAAQ,UAAU;IAEhD,MAAM,CAAC,MAAM,0BAkBX;;IAOF,MAAM,0BAA6D;CACnE;AAED,qBAEa,QAAS,SAAQ,UAAW,YAAW,MAAM;IAEzD,MAAM,CAAC,MAAM,4BAmCV;IAGH,SAAS,EAAE,MAAM,GAAC,OAAO,CAAW;IAGpC,cAAc,SAAK;IAGnB,cAAc,EAAE,WAAW,CAAiB;IAG5C,KAAK,EAAE,MAAM,GAAC,WAAW,GAAC,cAAc,CAAC;IAGzC,IAAI,EAAE,QAAQ,GAAC,MAAM,CAAC;IAGtB,KAAK,EAAE,MAAM,CAAC;IAGd,KAAK,aAAq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E,cAAc,CAAC;IAEzB,OAAO,CAAC,WAAW,CAAc;IAEjC,SAAS,CAAC,WAAW,8DAAkC;IACvD,IAAI,QAAQ,sBAAqC;IAEjD,IAAI,MAAM,YAA2D;IAErE,iBAAiB,IAAI,IAAI;IAKzB,oBAAoB,GAAI,GAAG,UAAU,UAKpC;IAED,eAAe,CAAC,OAAO,EAAE,MAAM;IAWzB,IAAI;IA4BV,KAAK;IAML,MAAM;IAKN,YAAY,sBAA6B;IAEzC,oBAAoB;IAKpB,cAAc,0BAIZ;IAEF,WAAW,2HAMT;IAEF,IAAI,YAAY,YAEf;IAED,IAAI,QAAQ,YAEX;IAED,MAAM,0BAeJ;IAEF,MAAM;CA0BN"}
@@ -37,7 +37,7 @@ DropdownContainer.styles = css `
37
37
  z-index: 60000;
38
38
  font-size: var(--og-font-size);
39
39
  font-family: var(--og-font-family);
40
- border-radius: var(--og-base-radius);
40
+ border-radius: var(--og-base-radius);
41
41
  }
42
42
 
43
43
  :host(.radiusfix) {
@@ -55,6 +55,7 @@ let Dropdown = class Dropdown extends LitElement {
55
55
  this.alignment = 'right';
56
56
  this.positionOffset = 0;
57
57
  this.dropdownParent = document.body;
58
+ this.animation = 0.1;
58
59
  this.color = ColorTypes.Accent;
59
60
  this.noCaret = false;
60
61
  this.dropdownRef = createRef();
@@ -102,6 +103,16 @@ let Dropdown = class Dropdown extends LitElement {
102
103
  super.connectedCallback();
103
104
  this.tabIndex = 0;
104
105
  }
106
+ animateDropdown(seconds) {
107
+ const height = this.dropdown.offsetHeight;
108
+ dom.setSize(this.dropdown, { h: 0 });
109
+ this.dropdown.style.transition = `height ${seconds}s ease-in-out`;
110
+ setTimeout(() => dom.setSize(this.dropdown, { h: height }), 0);
111
+ setTimeout(() => {
112
+ this.dropdown.style.height = 'auto';
113
+ this.dropdown.style.transition = '';
114
+ }, seconds * 1000);
115
+ }
105
116
  async open() {
106
117
  this.dispatchEvent(new DropdownEvent('beforeOpen'));
107
118
  await this.updateComplete;
@@ -122,6 +133,8 @@ let Dropdown = class Dropdown extends LitElement {
122
133
  await this.dropdown.updateComplete;
123
134
  this.dispatchEvent(new DropdownEvent('open'));
124
135
  this.layout();
136
+ if (this.animation > 0)
137
+ this.animateDropdown(this.animation);
125
138
  document.body.addEventListener('mousedown', this._onDocumentMouseDown);
126
139
  }
127
140
  close() {
@@ -217,6 +230,9 @@ __decorate([
217
230
  __decorate([
218
231
  property({ type: Object })
219
232
  ], Dropdown.prototype, "dropdownParent", void 0);
233
+ __decorate([
234
+ property({ type: Number })
235
+ ], Dropdown.prototype, "animation", void 0);
220
236
  __decorate([
221
237
  property()
222
238
  ], Dropdown.prototype, "label", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.js","sourceRoot":"","sources":["../../src/ui/dropdown.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAU,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEhD,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,MAAM,OAAO,aAAc,SAAQ,KAAK;IAEvC,YAAY,KAAa;QACxB,KAAK,CAAC,YAAY,KAAK,EAAE,CAAC,CAAC;IAC5B,CAAC;CACD;AAGM,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAsBh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pB,aAAa,CAAC,aAAa,CAAC;IAC5B,SAAS,CAAC,EAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAC,CAAC;GAClB,QAAQ,CAiMpB","sourcesContent":["import { LitElement, html, css, TemplateResult } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { ColorTypes, Layout } from '../types';\nimport * as dom from '../common/dom';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\nimport { createRef, ref } from 'lit-html/directives/ref.js';\nimport { guard } from 'lit/directives/guard.js';\nimport { IconSpec } from './icon';\nimport { utils } from '../common';\nimport { colorable } from '../themes';\nimport constants from '../constants';\n\nexport class DropdownEvent extends Event {\n\n\tconstructor(event: string) {\n\t\tsuper(`dropdown.${event}`);\n\t}\n}\n\n@customElement('og-dropdown-container')\nexport class DropdownContainer extends LitElement {\n\n\tstatic styles = css`\n\t\t:host {\n\t\t\tborder: 1px solid var(--og-accent-color);\n\t\t\tbackground-color: var(--og-background-color);\n\t\t\tposition: absolute;\n\t\t\toverflow: hidden;\n\t\t\tbox-sizing: border-box;\n\t\t\tcolor: var(--og-text-color);\n\t\t\tz-index: 60000;\n\t\t\tfont-size: var(--og-font-size);\n\t\t\tfont-family: var(--og-font-family);\n\t\t\tborder-radius: var(--og-base-radius);\n\t\t}\n\n\t\t:host(.radiusfix) {\n\t\t\tborder-top-left-radius: 0;\n\t\t\tborder-top-right-radius: 0;\n\t\t}\n\t`;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addEventListener('mousedown', (e: MouseEvent) => e.stopPropagation());\n\t}\n\n\trender = () => html`<div><slot name=\"inner-content\"></slot></div>`;\n}\n\n@customElement('og-dropdown')\n@colorable({props: ['border']})\nexport class Dropdown extends LitElement implements Layout {\n\n\tstatic styles = [css`\n\t\t:host {\n\t\t\tbox-sizing: border-box;\n\t\t\tdisplay: flex;\n\t\t\talign-items: stretch;\n\t\t\tflex-direction: row;\n\t\t\tfont-size: var(--og-font-size);\n\t\t\tfont-family: var(--og-font-family);\n\t\t\tcursor: pointer;\n\t\t\tuser-select: none;\n\t\t\toutline: none;\n\t\t\tborder-radius: var(--og-base-radius);\n\t\t\theight: ${constants.BUTTON_HEIGHT}px;\n\t\t}\n\n\t\t:host(.radiusfix) {\n\t\t\tborder-bottom-left-radius: 0;\n\t\t\tborder-bottom-right-radius: 0;\n\t\t}\n\n\t\tdiv.text {\n\t\t\tflex: 1;\n\t\t\tcolor: var(--og-text-color-1);\n\t\t\tpadding-left: 2px;\n\t\t\twhite-space: nowrap;\n\t\t\ttext-overflow: ellipsis;\n\t\t\toverflow: hidden;\n\t\t}\n\n\t\tog-button {\n\t\t\tflex: 1;\n\t\t\tborder-radius: 0;\n\t\t\tborder: none;\n\t\t\theight: 100%;\n\t\t}\n\t`];\n\n\t@property({type: String})\n\talignment: 'left'|'right' = 'right';\n\n\t@property({type: Number})\n\tpositionOffset = 0;\n\n\t@property({type: Object})\n\tdropdownParent: HTMLElement = document.body;\n\n\t@property()\n\tlabel: string|HTMLElement|TemplateResult;\n\n\t@property()\n\ticon: IconSpec|string;\n\n\t@property({type: Number})\n\twidth: number;\n\n\t@property({type: String, reflect: true})\n\tcolor = ColorTypes.Accent;\n\n\t@property({type: Boolean})\n\tnoCaret = false;\n\n\t@query('.label')\n\tlabelElm: HTMLDivElement;\n\n\tprivate _contentElm: HTMLElement;\n\n\tprotected dropdownRef = createRef<DropdownContainer>();\n\tget dropdown() { return this.dropdownRef?.value }\n\n\tget isOpen() { return this.dropdown && !dom.isHidden(this.dropdown) }\n\n\tconnectedCallback(): void {\n\t\tsuper.connectedCallback();\n\t\tthis.tabIndex = 0;\n\t}\n\n\t_onDocumentMouseDown = (e: MouseEvent) => {\n\t\tfor (const elm of e.composedPath()) {\n\t\t\tif (elm == this.dropdown || elm == this) return;\n\t\t}\n\t\tthis.close();\n\t}\n\n\tasync open() {\n\t\tthis.dispatchEvent(new DropdownEvent('beforeOpen'));\n\t\tawait this.updateComplete;\n\t\t\n\t\tif (this.dropdown.parentElement !== this.dropdownParent) {\n\t\t\tthis.dropdownParent.appendChild(this.dropdown);\n\t\t}\n\n\t\tif (this.children.length > 0 && !this._contentElm) {\n\t\t\tthis._contentElm = [...this.children].find(elm => elm.slot == 'content') as HTMLElement;\n\t\t\tif (this._contentElm) {\n\t\t\t\tthis._contentElm.slot = 'inner-content';\n\t\t\t\tthis.dropdown.appendChild(this._contentElm);\n\t\t\t}\n\t\t}\n\n\t\tif (this.width > 0) dom.setSize(this.dropdown, {w: this.width});\n\t\tdom.showElement(this.dropdown);\n\t\tthis.requestUpdate();\n\t\tawait this.dropdown.updateComplete;\n\t\tthis.dispatchEvent(new DropdownEvent('open'));\n\t\tthis.layout();\n\t\tdocument.body.addEventListener('mousedown', this._onDocumentMouseDown);\n\t}\n\n\tclose() {\n\t\tif (this.dropdown) dom.hideElement(this.dropdown);\n\t\tthis.layout();\n\t\tdocument.body.removeEventListener('mousedown', this._onDocumentMouseDown);\n\t}\n\n\ttoggle() {\n\t\tif (this.isOpen) this.close();\n\t\telse this.open();\n\t}\n\n\t_onMousedown = async () => this.toggle();\n\n\tdisconnectedCallback() {\n\t\tthis.dropdown?.remove();\n\t\tsuper.disconnectedCallback();\n\t}\n\n\trenderDropdown = () => html`\n\t\t<og-dropdown-container ${ref(this.dropdownRef)}\n\t\t\tstyle=\"display: none\">\n\t\t</og-dropdown-container>\n\t`;\n\n\trenderLabel = () => {\n\t\tif (utils.isString(this.label)) {\n\t\t\treturn this.label === '' ? unsafeHTML('&nbsp;') : html`<div class=\"text\">${this.label}</div>`;\n\t\t} else {\n\t\t\treturn this.label;\n\t\t}\n\t};\n\n\tget hasLabelSlot() {\n\t\treturn this.querySelector('[slot=\"label\"]') != null;\n\t}\n\n\tget hasLabel() {\n\t\treturn this.label !== '' && this.label != null;\n\t}\n\n\trender = () => html`\n\t\t<og-button\n\t\t\t@mousedown=\"${this._onMousedown}\"\n\t\t\tclass=\"main\"\n\t\t\tcolor=\"${this.color}\"\n\t\t\t.icon=\"${this.icon}\"\n\t\t\t?caret=\"${!this.noCaret}\">\n\t\t\t${this.hasLabelSlot ? html`\n\t\t\t\t<div class=\"label\" slot=\"content\"><slot name=\"label\"></slot></div>\n\t\t\t` : guard([this.label], () => (this.hasLabel ? html`\n\t\t\t\t<div class=\"label\" slot=\"content\">${this.renderLabel()}</div>\n\t\t\t` : ''))}\n\t\t</og-button>\n\n\t\t${this.renderDropdown()}\n\t`;\n\n\tlayout() {\n\t\tthis.classList.toggle('radiusfix', this.isOpen);\n\t\tif (!this.dropdown) return;\n\t\tthis.dropdown.classList.toggle('radiusfix', this.isOpen);\n\t\tif (!this.isOpen) return;\n\n\t\tconst offset = dom.getElementOffset(this, this.dropdownParent);\n\t\tdom.setSize(this.dropdown, {w: this.offsetWidth}, true);\n\n\t\tif (this.alignment == 'left') {\n\t\t\tthis.dropdown.style.right = 'auto';\n\t\t\tdom.setPosition(this.dropdown, {\n\t\t\t\tt: offset.top + this.offsetHeight - 1, \n\t\t\t\tl: this.positionOffset + offset.left\n\t\t\t});\n\t\t\tdom.fixElementPosition(this.dropdown);\n\t\t} else {\n\t\t\tthis.dropdown.style.left = 'auto';\n\t\t\tdom.setPosition(this.dropdown, {\n\t\t\t\tt: offset.top + this.offsetHeight - 1, \n\t\t\t\tr: this.dropdownParent.clientWidth - this.positionOffset - offset.left - this.offsetWidth\n\t\t\t});\n\t\t}\n\n\t}\n\n}"]}
1
+ {"version":3,"file":"dropdown.js","sourceRoot":"","sources":["../../src/ui/dropdown.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAU,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,+BA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KAAK,CAAC,QAAQ,CAAC;0CACS;AAnEb,QAAQ;IAFpB,aAAa,CAAC,aAAa,CAAC;IAC5B,SAAS,CAAC,EAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAC,CAAC;GAClB,QAAQ,CAkNpB","sourcesContent":["import { LitElement, html, css, TemplateResult } from 'lit';\nimport { customElement, property, query } from 'lit/decorators.js';\nimport { ColorTypes, Layout } from '../types';\nimport * as dom from '../common/dom';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\nimport { createRef, ref } from 'lit-html/directives/ref.js';\nimport { guard } from 'lit/directives/guard.js';\nimport { IconSpec } from './icon';\nimport { utils } from '../common';\nimport { colorable } from '../themes';\nimport constants from '../constants';\n\nexport class DropdownEvent extends Event {\n\n\tconstructor(event: string) {\n\t\tsuper(`dropdown.${event}`);\n\t}\n}\n\n@customElement('og-dropdown-container')\nexport class DropdownContainer extends LitElement {\n\n\tstatic styles = css`\n\t\t:host {\n\t\t\tborder: 1px solid var(--og-accent-color);\n\t\t\tbackground-color: var(--og-background-color);\n\t\t\tposition: absolute;\n\t\t\toverflow: hidden;\n\t\t\tbox-sizing: border-box;\n\t\t\tcolor: var(--og-text-color);\n\t\t\tz-index: 60000;\n\t\t\tfont-size: var(--og-font-size);\n\t\t\tfont-family: var(--og-font-family);\n\t\t\tborder-radius: var(--og-base-radius);\t\t\t\n\t\t}\n\n\t\t:host(.radiusfix) {\n\t\t\tborder-top-left-radius: 0;\n\t\t\tborder-top-right-radius: 0;\n\t\t}\n\t`;\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.addEventListener('mousedown', (e: MouseEvent) => e.stopPropagation());\n\t}\n\n\trender = () => html`<div><slot name=\"inner-content\"></slot></div>`;\n}\n\n@customElement('og-dropdown')\n@colorable({props: ['border']})\nexport class Dropdown extends LitElement implements Layout {\n\n\tstatic styles = [css`\n\t\t:host {\n\t\t\tbox-sizing: border-box;\n\t\t\tdisplay: flex;\n\t\t\talign-items: stretch;\n\t\t\tflex-direction: row;\n\t\t\tfont-size: var(--og-font-size);\n\t\t\tfont-family: var(--og-font-family);\n\t\t\tcursor: pointer;\n\t\t\tuser-select: none;\n\t\t\toutline: none;\n\t\t\tborder-radius: var(--og-base-radius);\n\t\t\theight: ${constants.BUTTON_HEIGHT}px;\n\t\t}\n\n\t\t:host(.radiusfix) {\n\t\t\tborder-bottom-left-radius: 0;\n\t\t\tborder-bottom-right-radius: 0;\n\t\t}\n\n\t\tdiv.text {\n\t\t\tflex: 1;\n\t\t\tcolor: var(--og-text-color-1);\n\t\t\tpadding-left: 2px;\n\t\t\twhite-space: nowrap;\n\t\t\ttext-overflow: ellipsis;\n\t\t\toverflow: hidden;\n\t\t}\n\n\t\tog-button {\n\t\t\tflex: 1;\n\t\t\tborder-radius: 0;\n\t\t\tborder: none;\n\t\t\theight: 100%;\n\t\t}\n\t`];\n\n\t@property({type: String})\n\talignment: 'left'|'right' = 'right';\n\n\t@property({type: Number})\n\tpositionOffset = 0;\n\n\t@property({type: Object})\n\tdropdownParent: HTMLElement = document.body;\n\n\t@property({type: Number})\n\tanimation = 0.1;\n\n\t@property()\n\tlabel: string|HTMLElement|TemplateResult;\n\n\t@property()\n\ticon: IconSpec|string;\n\n\t@property({type: Number})\n\twidth: number;\n\n\t@property({type: String, reflect: true})\n\tcolor = ColorTypes.Accent;\n\n\t@property({type: Boolean})\n\tnoCaret = false;\n\n\t@query('.label')\n\tlabelElm: HTMLDivElement;\n\n\tprivate _contentElm: HTMLElement;\n\n\tprotected dropdownRef = createRef<DropdownContainer>();\n\tget dropdown() { return this.dropdownRef?.value }\n\n\tget isOpen() { return this.dropdown && !dom.isHidden(this.dropdown) }\n\n\tconnectedCallback(): void {\n\t\tsuper.connectedCallback();\n\t\tthis.tabIndex = 0;\n\t}\n\n\t_onDocumentMouseDown = (e: MouseEvent) => {\n\t\tfor (const elm of e.composedPath()) {\n\t\t\tif (elm == this.dropdown || elm == this) return;\n\t\t}\n\t\tthis.close();\n\t}\n\n\tanimateDropdown(seconds: number) {\n\t\tconst height = this.dropdown.offsetHeight;\n\t\tdom.setSize(this.dropdown, {h: 0});\n\t\tthis.dropdown.style.transition = `height ${seconds}s ease-in-out`;\n\t\tsetTimeout(() => dom.setSize(this.dropdown, {h: height}), 0);\n\t\tsetTimeout(() => {\n\t\t\tthis.dropdown.style.height = 'auto';\n\t\t\tthis.dropdown.style.transition = '';\n\t\t}, seconds * 1000);\n\t}\n\n\tasync open() {\n\t\tthis.dispatchEvent(new DropdownEvent('beforeOpen'));\n\t\tawait this.updateComplete;\n\t\t\n\t\tif (this.dropdown.parentElement !== this.dropdownParent) {\n\t\t\tthis.dropdownParent.appendChild(this.dropdown);\n\t\t}\n\n\t\tif (this.children.length > 0 && !this._contentElm) {\n\t\t\tthis._contentElm = [...this.children].find(elm => elm.slot == 'content') as HTMLElement;\n\t\t\tif (this._contentElm) {\n\t\t\t\tthis._contentElm.slot = 'inner-content';\n\t\t\t\tthis.dropdown.appendChild(this._contentElm);\n\t\t\t}\n\t\t}\n\n\t\tif (this.width > 0) dom.setSize(this.dropdown, {w: this.width});\n\t\tdom.showElement(this.dropdown);\n\t\tthis.requestUpdate();\n\t\tawait this.dropdown.updateComplete;\n\t\tthis.dispatchEvent(new DropdownEvent('open'));\n\t\tthis.layout();\n\n\t\tif (this.animation > 0) this.animateDropdown(this.animation);\n\n\t\tdocument.body.addEventListener('mousedown', this._onDocumentMouseDown);\n\t}\n\n\tclose() {\n\t\tif (this.dropdown) dom.hideElement(this.dropdown);\n\t\tthis.layout();\n\t\tdocument.body.removeEventListener('mousedown', this._onDocumentMouseDown);\n\t}\n\n\ttoggle() {\n\t\tif (this.isOpen) this.close();\n\t\telse this.open();\n\t}\n\n\t_onMousedown = async () => this.toggle();\n\n\tdisconnectedCallback() {\n\t\tthis.dropdown?.remove();\n\t\tsuper.disconnectedCallback();\n\t}\n\n\trenderDropdown = () => html`\n\t\t<og-dropdown-container ${ref(this.dropdownRef)}\n\t\t\tstyle=\"display: none\">\n\t\t</og-dropdown-container>\n\t`;\n\n\trenderLabel = () => {\n\t\tif (utils.isString(this.label)) {\n\t\t\treturn this.label === '' ? unsafeHTML('&nbsp;') : html`<div class=\"text\">${this.label}</div>`;\n\t\t} else {\n\t\t\treturn this.label;\n\t\t}\n\t};\n\n\tget hasLabelSlot() {\n\t\treturn this.querySelector('[slot=\"label\"]') != null;\n\t}\n\n\tget hasLabel() {\n\t\treturn this.label !== '' && this.label != null;\n\t}\n\n\trender = () => html`\n\t\t<og-button\n\t\t\t@mousedown=\"${this._onMousedown}\"\n\t\t\tclass=\"main\"\n\t\t\tcolor=\"${this.color}\"\n\t\t\t.icon=\"${this.icon}\"\n\t\t\t?caret=\"${!this.noCaret}\">\n\t\t\t${this.hasLabelSlot ? html`\n\t\t\t\t<div class=\"label\" slot=\"content\"><slot name=\"label\"></slot></div>\n\t\t\t` : guard([this.label], () => (this.hasLabel ? html`\n\t\t\t\t<div class=\"label\" slot=\"content\">${this.renderLabel()}</div>\n\t\t\t` : ''))}\n\t\t</og-button>\n\n\t\t${this.renderDropdown()}\n\t`;\n\n\tlayout() {\n\t\tthis.classList.toggle('radiusfix', this.isOpen);\n\t\tif (!this.dropdown) return;\n\t\tthis.dropdown.classList.toggle('radiusfix', this.isOpen);\n\t\tif (!this.isOpen) return;\n\n\t\tconst offset = dom.getElementOffset(this, this.dropdownParent);\n\t\tdom.setSize(this.dropdown, {w: this.offsetWidth}, true);\n\n\t\tif (this.alignment == 'left') {\n\t\t\tthis.dropdown.style.right = 'auto';\n\t\t\tdom.setPosition(this.dropdown, {\n\t\t\t\tt: offset.top + this.offsetHeight - 1, \n\t\t\t\tl: this.positionOffset + offset.left\n\t\t\t});\n\t\t\tdom.fixElementPosition(this.dropdown);\n\t\t} else {\n\t\t\tthis.dropdown.style.left = 'auto';\n\t\t\tdom.setPosition(this.dropdown, {\n\t\t\t\tt: offset.top + this.offsetHeight - 1, \n\t\t\t\tr: this.dropdownParent.clientWidth - this.positionOffset - offset.left - this.offsetWidth\n\t\t\t});\n\t\t}\n\n\t}\n\n}"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/core",
3
- "version": "0.9.11",
3
+ "version": "0.9.12",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Core components",
6
6
  "main": "./dist/index.js",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@fortawesome/fontawesome-svg-core": "^7.0.1",
39
- "@omegagrid/localize": "^0.9.11",
39
+ "@omegagrid/localize": "^0.9.12",
40
40
  "color": "^4.2.3",
41
41
  "date-fns": "^3.2.0",
42
42
  "lit": "^3.1.1",