@omegagrid/tabs 0.6.75 → 0.6.77

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.
@@ -38,7 +38,7 @@ let TabContainer = TabContainer_1 = class TabContainer extends LitElement {
38
38
  this._onRemove = (e) => {
39
39
  this.components.delete(e.tab.id);
40
40
  if (this.tabs.items?.length === 0) {
41
- dom.showElement(this.tabs);
41
+ dom.showElement(this.tabs, 'flex');
42
42
  }
43
43
  };
44
44
  this.hideOverlay = () => {
@@ -167,7 +167,7 @@ let TabContainer = TabContainer_1 = class TabContainer extends LitElement {
167
167
  this.tabs.addTab(item);
168
168
  this.tabs.selectTabById(item.id, dispatchEvent);
169
169
  }
170
- dom.showElement(this.tabs);
170
+ dom.showElement(this.tabs, 'flex');
171
171
  }
172
172
  willUpdate() {
173
173
  if (!this.topLevelComponent)
@@ -1 +1 @@
1
- {"version":3,"file":"tabContainer.js","sourceRoot":"","sources":["../../src/components/tabContainer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,OAAO,EAAE,GAAG,EAAyF,MAAM,iBAAiB,CAAC;AAC7H,OAAO,EAAY,IAAI,EAAE,MAAM,QAAQ,CAAC;AAOjC,IAAM,YAAY,oBAAlB,MAAM,YAAa,SAAQ,UAAU;IAArC;;QAQN,iCAAY,KAAK,EAAC;QAelB,aAAQ,GAAG,KAAK,CAAC;QAYjB,UAAK,GAAG,KAAK,CAAC;QAGd,cAAS,GAAG,KAAK,CAAC;QAGlB,kBAAa,GAAG,CAAC,CAAC,CAAC;QAOnB,gBAAW,GAAqB,KAAK,CAAC;QAGtC,oBAAe,GAAG,KAAK,CAAC;QASR,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IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;iDACF;AAGtC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;qDACF;AAGxB;IADC,KAAK,CAAC,YAAY,CAAC;+CACM;AAG1B;IADC,KAAK,CAAC,UAAU,CAAC;6CACM;AAzDZ,YAAY;IADxB,aAAa,CAAC,iBAAiB,CAAC;GACpB,YAAY,CAiPxB","sourcesContent":["import { LitElement, html } from \"lit\";\nimport { customElement, property, query } from \"lit/decorators.js\";\nimport { style } from './tabContainer.style';\nimport { TabItem } from '../types';\nimport { dom, ComponentFactory, actions, Layout, ComponentId, DirectionalPosition, VerticalPosition } from \"@omegagrid/core\";\nimport { TabEvent, Tabs } from \"./tabs\";\n\nexport type TabsActionArgs = {\n\tindex: number\n}\n\n@customElement('og-tabcontainer')\nexport class TabContainer extends LitElement implements Layout {\n\n\tstatic dropPosition: DirectionalPosition;\n\tstatic dragParent: TabContainer;\n\tstatic dropTarget: TabContainer;\n\n\tstatic styles = [style];\n\n\t#inactive = false;\n\t@property({type: Boolean, noAccessor: true})\n\tset inactive(value: boolean) {\n\t\tthis.#inactive = value;\n\t\tif (this.tabs) this.tabs.classList.toggle('inactive', value);\n\t}\n\tget inactive() { return this.#inactive }\n\n\t@property({type: Object})\n\ttopLevelComponent: HTMLElement;\n\n\t@property({type: Array})\n\titems: TabItem[];\n\n\t@property({type: Boolean})\n\tclosable = false;\n\n\t@property({type: Object})\n\tcreateComponent: ComponentFactory;\n\n\t@query('og-tabs')\n\ttabs: Tabs;\n\n\t@property({type: Array})\n\tactions: actions.Action[];\n\n\t@property({type: Boolean})\n\tfixed = false;\n\n\t@property({type: Boolean})\n\taddButton = false;\n\n\t@property({type: Number, reflect: true})\n\tselectedIndex = -1;\n\n\tget selectedId(): ComponentId {\n\t\treturn this.tabs?.selectedItem?.id;\n\t}\n\n\t@property({type: String, reflect: true})\n\ttabPosition: VerticalPosition = 'top';\n\n\t@property({type: Boolean})\n\tcacheComponents = false;\n\n\t@query('#container')\n\tcontainer: HTMLDivElement;\n\n\t@query('#overlay')\n\toverlay: HTMLDivElement;\n\n\n\tpublic readonly components = new Map<ComponentId, HTMLElement>();\n\tprivate currentComponent: HTMLElement;\n\tget component() { return this.currentComponent }\n\n\t_firstLoad = true;\n\n\tlayout() {\n\t\tif ((this.currentComponent as Layout)?.layout) (this.currentComponent as Layout).layout();\n\t}\n\n\tupdateTabs() { this.tabs.requestUpdate() }\n\n\tasync getComponent(componentId: ComponentId) {\n\t\tif (!this.createComponent) return null;\n\t\tif (!this.cacheComponents || !this.components.has(componentId)) {\n\t\t\tconst component = await this.createComponent(componentId);\n\t\t\tif (!this.cacheComponents) return component;\n\t\t\tthis.components.set(componentId, component);\n\t\t}\n\t\treturn this.components.get(componentId);\n\t}\n\n\tasync loadComponent(componentId: ComponentId) {\n\t\tif (componentId != null) {\n\t\t\tthis.currentComponent = await this.getComponent(componentId);\n\t\t\tdom.empty(this.container);\n\t\t\tif (this.currentComponent) {\n\t\t\t\tdom.appendElement(this.container, this.currentComponent);\n\t\t\t}\n\t\t\tif (this._firstLoad) {\n\t\t\t\tthis._firstLoad = false;\n\t\t\t\tthis.dispatchEvent(new Event('load'));\n\t\t\t}\n\t\t} else {\n\t\t\tdom.empty(this.container);\n\t\t\tthis.currentComponent = null;\n\t\t}\n\n\t\tif (this._firstLoad) {\n\t\t\tthis._firstLoad = false;\n\t\t\tthis.layout();\n\t\t}\n\t}\n\n\trefresh() {\n\t\tconst id = this.tabs?.selectedItem?.id;\n\t\tif (id != null)\tthis.loadComponent(this.tabs.selectedItem?.id);\n\t}\n\n\t_onSelect = () => this.refresh();\n\n\t_onRemove = (e: TabEvent) => {\n\t\tthis.components.delete(e.tab.id);\n\t\tif (this.tabs.items?.length === 0) {\n\t\t\tdom.showElement(this.tabs);\n\t\t}\n\t};\n\n\topen(item: TabItem, dispatchEvent = true) {\n\t\tconst tabIndex = this.tabs.getIndexById(item.id);\n\t\tif (tabIndex > -1) {\n\t\t\tthis.tabs.selectTab(tabIndex, dispatchEvent);\n\t\t} else {\n\t\t\tthis.tabs.addTab(item);\n\t\t\tthis.tabs.selectTabById(item.id, dispatchEvent);\n\t\t}\n\n\t\tdom.showElement(this.tabs);\n\t}\n\n\twillUpdate() {\n\t\tif (!this.topLevelComponent) this.topLevelComponent = this;\n\t\tthis.selectedIndex = this.items?.length > 0 \n\t\t\t? Math.max(0, Math.min(this.selectedIndex ?? -1, this.items.length - 1))\n\t\t\t: -1;\n\t}\n\t\n\tfirstUpdated() {\n\t\tif (this.selectedIndex > -1) this.open(this.items[this.selectedIndex]);\n\t}\n\n\tupdated(props: Map<PropertyKey, unknown>) {\n\t\tif (props.has('items')) this._firstLoad = true;\n\t}\n\n\tpositionOverlay(pos: DirectionalPosition) {\n\t\tTabContainer.dropPosition = pos;\n\t\t\n\t\tthis.tabs.hideOverlay();\n\t\tif (pos == null) {\n\t\t\tthis.tabs.positionOverlay(this.tabs.empty);\n\t\t\treturn dom.hideElement(this.overlay);\n\t\t}\n\n\t\tdom.showElement(this.overlay);\n\t\tdom.setPosition(this.overlay, {\n\t\t\tt: (pos == 'bottom' ? this.container.clientHeight / 2 : 0) + this.container.offsetTop,\n\t\t\tl: pos == 'right' ? this.container.clientWidth / 2 : 0,\n\t\t\tb: pos == 'top' ? this.container.clientHeight / 2 : 0,\n\t\t\tr: pos == 'left' ? this.container.clientWidth / 2 : 0,\n\t\t});\n\t}\n\n\thideOverlay = () => {\n\t\tdom.hideElement(this.overlay);\n\t\tthis.tabs.hideOverlay();\n\t}\n\n\tcalculateOverlayPosition(x: number, y: number) {\n\t\tconst [w, h] = [this.container.clientWidth, this.container.clientHeight];\n\t\tconst margin = 0.3;\n\t\tif (x > w * margin && x < w - (w * margin) && y > h * margin && y < h - (h * margin)) return null;\n\t\tconst [q1, q2] = [w / h > x / y, w / h > x / (h - y)];\n\t\treturn (q1 ? (q2 ? 'left' : 'bottom') : (q2 ? 'top' : 'right')) as DirectionalPosition;\n\t}\n\n\t_onDragover = (e: DragEvent) => {\n\t\tif (!TabContainer.dragParent && !Tabs.dragParent) return;\n\t\tif (TabContainer.dragParent.topLevelComponent != this.topLevelComponent && Tabs.dragParent.topLevelComponent != this.topLevelComponent) return;\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t\te.dataTransfer.dropEffect = 'move';\n\t\tthis.positionOverlay(this.calculateOverlayPosition(e.offsetX, e.offsetY));\n\t}\n\n\t_onDrop = () => {\n\t\tif (TabContainer.dragParent?.topLevelComponent != this.topLevelComponent && Tabs.dragParent?.topLevelComponent != this.topLevelComponent) return;\n\t\tTabContainer.dropTarget = this;\n\t\tthis.hideOverlay();\n\t}\n\n\t_onDragStart = (_e: DragEvent) => {\n\t\tTabContainer.dragParent = this;\n\t}\n\n\t_onDragStop = () => {\n\t\tTabContainer.dragParent = null;\n\t}\n\n\t_onTabDrop = (e: DragEvent) => {\n\t\tTabContainer.dragParent = null;\n\t\te.stopPropagation();\n\t}\n\n\trender = () => {\n\t\tconst tabs = html`\n\t\t\t<og-tabs\n\t\t\t\tclass=\"${this.inactive ? 'inactive' : ''}\"\n\t\t\t\tstyle=\"${this.items?.length ? '' : 'display: none;'}\"\n\t\t\t\t?fixed=\"${this.fixed}\"\n\t\t\t\t.topLevelComponent=\"${this.topLevelComponent}\"\n\t\t\t\t.items=\"${this.items}\"\n\t\t\t\t.actions=\"${this.actions}\"\n\t\t\t\t.selectedIndex=\"${this.selectedIndex}\"\n\t\t\t\t.position=\"${this.tabPosition}\"\n\t\t\t\t?closable=\"${this.closable}\"\n\t\t\t\t?addButton=\"${this.addButton}\"\n\t\t\t\t@tab.select=\"${this._onSelect}\"\n\t\t\t\t@tab.remove=\"${this._onRemove}\"\n\t\t\t\t@dragstart=\"${this._onDragStart}\"\n\t\t\t\t@dragstop=\"${this._onDragStop}\"\n\t\t\t\t@drop=\"${this._onTabDrop}\">\n\t\t\t</og-tabs>\n\t\t`;\n\t\t\n\t\tconst container = html`\n\t\t\t<div\n\t\t\t\tid=\"container\"\n\t\t\t\t@drop=\"${this._onDrop}\"\n\t\t\t\t@dragover=\"${this._onDragover}\"\n\t\t\t\t@dragleave=\"${() => this.hideOverlay()}\">\n\t\t\t</div>\n\t\t`;\n\t\t\n\t\treturn html`\n\t\t\t${this.tabPosition == 'top' ? tabs : container}\n\t\t\t${this.tabPosition == 'bottom' ? tabs : container}\n\t\t\t<div id=\"overlay\" style=\"display: none\"></div>\n\t\t`\n\t};\n\n}"]}
1
+ {"version":3,"file":"tabContainer.js","sourceRoot":"","sources":["../../src/components/tabContainer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,OAAO,EAAE,GAAG,EAAyF,MAAM,iBAAiB,CAAC;AAC7H,OAAO,EAAY,IAAI,EAAE,MAAM,QAAQ,CAAC;AAOjC,IAAM,YAAY,oBAAlB,MAAM,YAAa,SAAQ,UAAU;IAArC;;QAQN,iCAAY,KAAK,EAAC;QAelB,aAAQ,GAAG,KAAK,CAAC;QAYjB,UAAK,GAAG,KAAK,CAAC;QAGd,cAAS,GAAG,KAAK,CAAC;QAGlB,kBAAa,GAAG,CAAC,CAAC,CAAC;QAOnB,gBAAW,GAAqB,KAAK,CAAC;QAGtC,oBAAe,GAAG,KAAK,CAAC;QASR,eAAU,GAAG,IAAI,GAAG,EAA4B,CAAC;QAIjE,eAAU,GAAG,IAAI,CAAC;QA6ClB,cAAS,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAEjC,cAAS,GAAG,CAAC,CAAW,EAAE,EAAE;YAC3B,IAAI,CAAC,UAAU,CAAC,MAAM,CA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B;IADC,KAAK,CAAC,UAAU,CAAC;6CACM;AAzDZ,YAAY;IADxB,aAAa,CAAC,iBAAiB,CAAC;GACpB,YAAY,CAiPxB","sourcesContent":["import { LitElement, html } from \"lit\";\nimport { customElement, property, query } from \"lit/decorators.js\";\nimport { style } from './tabContainer.style';\nimport { TabItem } from '../types';\nimport { dom, ComponentFactory, actions, Layout, ComponentId, DirectionalPosition, VerticalPosition } from \"@omegagrid/core\";\nimport { TabEvent, Tabs } from \"./tabs\";\n\nexport type TabsActionArgs = {\n\tindex: number\n}\n\n@customElement('og-tabcontainer')\nexport class TabContainer extends LitElement implements Layout {\n\n\tstatic dropPosition: DirectionalPosition;\n\tstatic dragParent: TabContainer;\n\tstatic dropTarget: TabContainer;\n\n\tstatic styles = [style];\n\n\t#inactive = false;\n\t@property({type: Boolean, noAccessor: true})\n\tset inactive(value: boolean) {\n\t\tthis.#inactive = value;\n\t\tif (this.tabs) this.tabs.classList.toggle('inactive', value);\n\t}\n\tget inactive() { return this.#inactive }\n\n\t@property({type: Object})\n\ttopLevelComponent: HTMLElement;\n\n\t@property({type: Array})\n\titems: TabItem[];\n\n\t@property({type: Boolean})\n\tclosable = false;\n\n\t@property({type: Object})\n\tcreateComponent: ComponentFactory;\n\n\t@query('og-tabs')\n\ttabs: Tabs;\n\n\t@property({type: Array})\n\tactions: actions.Action[];\n\n\t@property({type: Boolean})\n\tfixed = false;\n\n\t@property({type: Boolean})\n\taddButton = false;\n\n\t@property({type: Number, reflect: true})\n\tselectedIndex = -1;\n\n\tget selectedId(): ComponentId {\n\t\treturn this.tabs?.selectedItem?.id;\n\t}\n\n\t@property({type: String, reflect: true})\n\ttabPosition: VerticalPosition = 'top';\n\n\t@property({type: Boolean})\n\tcacheComponents = false;\n\n\t@query('#container')\n\tcontainer: HTMLDivElement;\n\n\t@query('#overlay')\n\toverlay: HTMLDivElement;\n\n\n\tpublic readonly components = new Map<ComponentId, HTMLElement>();\n\tprivate currentComponent: HTMLElement;\n\tget component() { return this.currentComponent }\n\n\t_firstLoad = true;\n\n\tlayout() {\n\t\tif ((this.currentComponent as Layout)?.layout) (this.currentComponent as Layout).layout();\n\t}\n\n\tupdateTabs() { this.tabs.requestUpdate() }\n\n\tasync getComponent(componentId: ComponentId) {\n\t\tif (!this.createComponent) return null;\n\t\tif (!this.cacheComponents || !this.components.has(componentId)) {\n\t\t\tconst component = await this.createComponent(componentId);\n\t\t\tif (!this.cacheComponents) return component;\n\t\t\tthis.components.set(componentId, component);\n\t\t}\n\t\treturn this.components.get(componentId);\n\t}\n\n\tasync loadComponent(componentId: ComponentId) {\n\t\tif (componentId != null) {\n\t\t\tthis.currentComponent = await this.getComponent(componentId);\n\t\t\tdom.empty(this.container);\n\t\t\tif (this.currentComponent) {\n\t\t\t\tdom.appendElement(this.container, this.currentComponent);\n\t\t\t}\n\t\t\tif (this._firstLoad) {\n\t\t\t\tthis._firstLoad = false;\n\t\t\t\tthis.dispatchEvent(new Event('load'));\n\t\t\t}\n\t\t} else {\n\t\t\tdom.empty(this.container);\n\t\t\tthis.currentComponent = null;\n\t\t}\n\n\t\tif (this._firstLoad) {\n\t\t\tthis._firstLoad = false;\n\t\t\tthis.layout();\n\t\t}\n\t}\n\n\trefresh() {\n\t\tconst id = this.tabs?.selectedItem?.id;\n\t\tif (id != null)\tthis.loadComponent(this.tabs.selectedItem?.id);\n\t}\n\n\t_onSelect = () => this.refresh();\n\n\t_onRemove = (e: TabEvent) => {\n\t\tthis.components.delete(e.tab.id);\n\t\tif (this.tabs.items?.length === 0) {\n\t\t\tdom.showElement(this.tabs, 'flex');\n\t\t}\n\t};\n\n\topen(item: TabItem, dispatchEvent = true) {\n\t\tconst tabIndex = this.tabs.getIndexById(item.id);\n\t\tif (tabIndex > -1) {\n\t\t\tthis.tabs.selectTab(tabIndex, dispatchEvent);\n\t\t} else {\n\t\t\tthis.tabs.addTab(item);\n\t\t\tthis.tabs.selectTabById(item.id, dispatchEvent);\n\t\t}\n\n\t\tdom.showElement(this.tabs, 'flex');\n\t}\n\n\twillUpdate() {\n\t\tif (!this.topLevelComponent) this.topLevelComponent = this;\n\t\tthis.selectedIndex = this.items?.length > 0 \n\t\t\t? Math.max(0, Math.min(this.selectedIndex ?? -1, this.items.length - 1))\n\t\t\t: -1;\n\t}\n\t\n\tfirstUpdated() {\n\t\tif (this.selectedIndex > -1) this.open(this.items[this.selectedIndex]);\n\t}\n\n\tupdated(props: Map<PropertyKey, unknown>) {\n\t\tif (props.has('items')) this._firstLoad = true;\n\t}\n\n\tpositionOverlay(pos: DirectionalPosition) {\n\t\tTabContainer.dropPosition = pos;\n\t\t\n\t\tthis.tabs.hideOverlay();\n\t\tif (pos == null) {\n\t\t\tthis.tabs.positionOverlay(this.tabs.empty);\n\t\t\treturn dom.hideElement(this.overlay);\n\t\t}\n\n\t\tdom.showElement(this.overlay);\n\t\tdom.setPosition(this.overlay, {\n\t\t\tt: (pos == 'bottom' ? this.container.clientHeight / 2 : 0) + this.container.offsetTop,\n\t\t\tl: pos == 'right' ? this.container.clientWidth / 2 : 0,\n\t\t\tb: pos == 'top' ? this.container.clientHeight / 2 : 0,\n\t\t\tr: pos == 'left' ? this.container.clientWidth / 2 : 0,\n\t\t});\n\t}\n\n\thideOverlay = () => {\n\t\tdom.hideElement(this.overlay);\n\t\tthis.tabs.hideOverlay();\n\t}\n\n\tcalculateOverlayPosition(x: number, y: number) {\n\t\tconst [w, h] = [this.container.clientWidth, this.container.clientHeight];\n\t\tconst margin = 0.3;\n\t\tif (x > w * margin && x < w - (w * margin) && y > h * margin && y < h - (h * margin)) return null;\n\t\tconst [q1, q2] = [w / h > x / y, w / h > x / (h - y)];\n\t\treturn (q1 ? (q2 ? 'left' : 'bottom') : (q2 ? 'top' : 'right')) as DirectionalPosition;\n\t}\n\n\t_onDragover = (e: DragEvent) => {\n\t\tif (!TabContainer.dragParent && !Tabs.dragParent) return;\n\t\tif (TabContainer.dragParent.topLevelComponent != this.topLevelComponent && Tabs.dragParent.topLevelComponent != this.topLevelComponent) return;\n\t\te.preventDefault();\n\t\te.stopPropagation();\n\t\te.dataTransfer.dropEffect = 'move';\n\t\tthis.positionOverlay(this.calculateOverlayPosition(e.offsetX, e.offsetY));\n\t}\n\n\t_onDrop = () => {\n\t\tif (TabContainer.dragParent?.topLevelComponent != this.topLevelComponent && Tabs.dragParent?.topLevelComponent != this.topLevelComponent) return;\n\t\tTabContainer.dropTarget = this;\n\t\tthis.hideOverlay();\n\t}\n\n\t_onDragStart = (_e: DragEvent) => {\n\t\tTabContainer.dragParent = this;\n\t}\n\n\t_onDragStop = () => {\n\t\tTabContainer.dragParent = null;\n\t}\n\n\t_onTabDrop = (e: DragEvent) => {\n\t\tTabContainer.dragParent = null;\n\t\te.stopPropagation();\n\t}\n\n\trender = () => {\n\t\tconst tabs = html`\n\t\t\t<og-tabs\n\t\t\t\tclass=\"${this.inactive ? 'inactive' : ''}\"\n\t\t\t\tstyle=\"${this.items?.length ? '' : 'display: none;'}\"\n\t\t\t\t?fixed=\"${this.fixed}\"\n\t\t\t\t.topLevelComponent=\"${this.topLevelComponent}\"\n\t\t\t\t.items=\"${this.items}\"\n\t\t\t\t.actions=\"${this.actions}\"\n\t\t\t\t.selectedIndex=\"${this.selectedIndex}\"\n\t\t\t\t.position=\"${this.tabPosition}\"\n\t\t\t\t?closable=\"${this.closable}\"\n\t\t\t\t?addButton=\"${this.addButton}\"\n\t\t\t\t@tab.select=\"${this._onSelect}\"\n\t\t\t\t@tab.remove=\"${this._onRemove}\"\n\t\t\t\t@dragstart=\"${this._onDragStart}\"\n\t\t\t\t@dragstop=\"${this._onDragStop}\"\n\t\t\t\t@drop=\"${this._onTabDrop}\">\n\t\t\t</og-tabs>\n\t\t`;\n\t\t\n\t\tconst container = html`\n\t\t\t<div\n\t\t\t\tid=\"container\"\n\t\t\t\t@drop=\"${this._onDrop}\"\n\t\t\t\t@dragover=\"${this._onDragover}\"\n\t\t\t\t@dragleave=\"${() => this.hideOverlay()}\">\n\t\t\t</div>\n\t\t`;\n\t\t\n\t\treturn html`\n\t\t\t${this.tabPosition == 'top' ? tabs : container}\n\t\t\t${this.tabPosition == 'bottom' ? tabs : container}\n\t\t\t<div id=\"overlay\" style=\"display: none\"></div>\n\t\t`\n\t};\n\n}"]}
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.style.d.ts","sourceRoot":"","sources":["../../src/components/tabs.style.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,KAAK,yBA+IjB,CAAC"}
1
+ {"version":3,"file":"tabs.style.d.ts","sourceRoot":"","sources":["../../src/components/tabs.style.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK,yBA+IjB,CAAC"}
@@ -1,5 +1,6 @@
1
+ import { device } from "@omegagrid/core";
1
2
  import constants from "../constants";
2
- import { css } from "lit";
3
+ import { css, unsafeCSS } from "lit";
3
4
  export const style = css `
4
5
  * {
5
6
  box-sizing: border-box;
@@ -77,7 +78,7 @@ export const style = css `
77
78
  font-size: 14px;
78
79
  position: absolute;
79
80
  right: 2px;
80
- display: none;
81
+ display: ${unsafeCSS(device.detect() == "mobile" ? "block" : "none")};
81
82
  width: 16px;
82
83
  height: 16px;
83
84
  line-height: 16px;
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.style.js","sourceRoot":"","sources":["../../src/components/tabs.style.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA;;;;;;;gBAOR,SAAS,CAAC,gBAAgB;iBACzB,SAAS,CAAC,gBAAgB;;;;;;;;;;YAU/B,SAAS,CAAC,gBAAgB,GAAG,CAAC;;;;;;;;gBAQ1B,SAAS,CAAC,gBAAgB;;;;;;;;mBAQvB,SAAS,CAAC,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA+BjC,SAAS,CAAC,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8ErC,CAAC","sourcesContent":["import constants from \"../constants\";\nimport { css } from \"lit\";\n\nexport const style = css`\n\t* {\n\t\tbox-sizing: border-box;\n\t}\n\n\t:host {\n\t\tcolor: var(--og-text-color);\n\t\tmin-height: ${constants.TAB_PANEL_HEIGHT}px;\n\t\tline-height: ${constants.TAB_PANEL_HEIGHT}px;\n\t\tbackground: var(--og-tab-panel-background-color);\n\t\tborder-bottom: 1px solid var(--og-tab-border-color);\n\t\tdisplay: flex;\n\t\tflex-direction: row;\n\t\tposition: relative;\n\t\tfont-size: var(--og-font-size);\n\t}\n\n\t.tabs {\n\t\theight: ${constants.TAB_PANEL_HEIGHT - 1}px;\n\t\tflex: 0;\n\t\twhite-space: nowrap;\n\t\tdisplay: flex;\n\t\tflex-direction: row;\n\t}\n\n\t:host([position=\"top\"]) .tab {\n\t\tborder-top: ${constants.TAB_PANEL_BORDER}px solid var(--og-tab-panel-background-color);\n\t}\n\n\t:host([position=\"top\"]) .tab:hover, :host([position=\"top\"]) .tab.active {\n\t\tborder-top-color: var(--og-accent-color);\n\t}\n\n\t:host([position=\"bottom\"]) .tab {\n\t\tborder-bottom: ${constants.TAB_PANEL_BORDER}px solid var(--og-tab-panel-background-color);\n\t}\n\n\t:host([position=\"bottom\"]) .tab:hover, :host([position=\"bottom\"]) .tab.active {\n\t\tborder-bottom-color: var(--og-accent-color);\n\t}\n\n\t:host(.inactive) .tab.active {\n\t\tborder-top-color: var(--og-tab-border-color);\n\t\tborder-bottom-color: var(--og-tab-border-color);\n\t}\n\n\t.tab {\n\t\tborder-right: 1px solid var(--og-tab-border-color);\n\t\tdisplay: flex;\n\t\tflex-direction: row;\n\t\theight: 100%;\n\t\tbackground: var(--og-tab-background-color);\n\t\tcursor: pointer;\n\t\tmargin-right: 1px;\n\t\tpadding-left: 7px;\n\t\tpadding-right: 7px;\n\t\tposition: relative;\n\t}\n\n\t.tab.closable {\n\t\tpadding-right: 20px;\n\t}\n\n\t.tab.active {\n\t\tbackground-color: var(--og-tab-background-color-active);\n\t\theight: ${constants.TAB_PANEL_HEIGHT}px;\n\t\tfont-weight: bold;\n\t}\n\n\t.tab:hover .tab-x {\n\t\tdisplay: block;\n\t}\n\n\t.tab-x {\n\t\tfont-size: 14px;\n\t\tposition: absolute;\n\t\tright: 2px;\n\t\tdisplay: none;\n\t\twidth: 16px;\n\t\theight: 16px;\n\t\tline-height: 16px;\n\t\tmargin: 6px 0 0 5px;\n\t\ttext-align: center;\n\t\tborder-radius: 50%;\n\t}\n\n\t.tab-save-mark {\n\t\theight: 16px;\n\t\tline-height: 16px;\n\t\tmargin: 6px 0 0 5px;\n\t}\n\n\t.tab.closable:hover .tab-save-mark {\n\t\tdisplay: none;\n\t}\n\n\t.tab.closable .tab-save-mark {\n\t\tposition: absolute;\n\t\tright: 5px;\n\t}\n\n\t.tab.unsaved {\n\t\tcolor: #959d00;\n\t}\n\n\t.tab-x og-fa-icon {\n\t\tdisplay: block;\n\t}\n\n\t.tab-x:hover {\n\t\tbackground-color: var(--og-accent-color-alpha-30);\n\t}\n\n\t.empty {\n\t\tflex: 1;\n\t\theight: 100%;\n\t}\n\t\n\t.buttons {\n\t\tflex: 0;\n\t\theight: 100%;\n\t\tpadding: 0 10px 0 10px;\n\t}\n\n\t.buttons og-fa-icon {\n\t\tcursor: pointer;\n\t}\n\n\t.buttons og-fa-icon:hover {\n\t\tcolor: var(--og-text-color-2)\n\t}\n\n\t#overlay {\n\t\tbackground-color: var(--og-accent-color);\n\t\topacity: 0.5;\n\t\tpointer-events: none;\n\t}\n\n\t#btnAdd {\n\t\tmargin-left: 5px;\n\t\tline-height: 0;\n\t}\n\n`;"]}
1
+ {"version":3,"file":"tabs.style.js","sourceRoot":"","sources":["../../src/components/tabs.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,KAAK,CAAC;AAErC,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA;;;;;;;gBAOR,SAAS,CAAC,gBAAgB;iBACzB,SAAS,CAAC,gBAAgB;;;;;;;;;;YAU/B,SAAS,CAAC,gBAAgB,GAAG,CAAC;;;;;;;;gBAQ1B,SAAS,CAAC,gBAAgB;;;;;;;;mBAQvB,SAAS,CAAC,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA+BjC,SAAS,CAAC,gBAAgB;;;;;;;;;;;;aAYzB,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkErE,CAAC","sourcesContent":["import { device } from \"@omegagrid/core\";\nimport constants from \"../constants\";\nimport { css, unsafeCSS } from \"lit\";\n\nexport const style = css`\n\t* {\n\t\tbox-sizing: border-box;\n\t}\n\n\t:host {\n\t\tcolor: var(--og-text-color);\n\t\tmin-height: ${constants.TAB_PANEL_HEIGHT}px;\n\t\tline-height: ${constants.TAB_PANEL_HEIGHT}px;\n\t\tbackground: var(--og-tab-panel-background-color);\n\t\tborder-bottom: 1px solid var(--og-tab-border-color);\n\t\tdisplay: flex;\n\t\tflex-direction: row;\n\t\tposition: relative;\n\t\tfont-size: var(--og-font-size);\n\t}\n\n\t.tabs {\n\t\theight: ${constants.TAB_PANEL_HEIGHT - 1}px;\n\t\tflex: 0;\n\t\twhite-space: nowrap;\n\t\tdisplay: flex;\n\t\tflex-direction: row;\n\t}\n\n\t:host([position=\"top\"]) .tab {\n\t\tborder-top: ${constants.TAB_PANEL_BORDER}px solid var(--og-tab-panel-background-color);\n\t}\n\n\t:host([position=\"top\"]) .tab:hover, :host([position=\"top\"]) .tab.active {\n\t\tborder-top-color: var(--og-accent-color);\n\t}\n\n\t:host([position=\"bottom\"]) .tab {\n\t\tborder-bottom: ${constants.TAB_PANEL_BORDER}px solid var(--og-tab-panel-background-color);\n\t}\n\n\t:host([position=\"bottom\"]) .tab:hover, :host([position=\"bottom\"]) .tab.active {\n\t\tborder-bottom-color: var(--og-accent-color);\n\t}\n\n\t:host(.inactive) .tab.active {\n\t\tborder-top-color: var(--og-tab-border-color);\n\t\tborder-bottom-color: var(--og-tab-border-color);\n\t}\n\n\t.tab {\n\t\tborder-right: 1px solid var(--og-tab-border-color);\n\t\tdisplay: flex;\n\t\tflex-direction: row;\n\t\theight: 100%;\n\t\tbackground: var(--og-tab-background-color);\n\t\tcursor: pointer;\n\t\tmargin-right: 1px;\n\t\tpadding-left: 7px;\n\t\tpadding-right: 7px;\n\t\tposition: relative;\n\t}\n\n\t.tab.closable {\n\t\tpadding-right: 20px;\n\t}\n\n\t.tab.active {\n\t\tbackground-color: var(--og-tab-background-color-active);\n\t\theight: ${constants.TAB_PANEL_HEIGHT}px;\n\t\tfont-weight: bold;\n\t}\n\n\t.tab:hover .tab-x {\n\t\tdisplay: block;\n\t}\n\n\t.tab-x {\n\t\tfont-size: 14px;\n\t\tposition: absolute;\n\t\tright: 2px;\n\t\tdisplay: ${unsafeCSS(device.detect() == \"mobile\" ? \"block\" : \"none\")};\n\t\twidth: 16px;\n\t\theight: 16px;\n\t\tline-height: 16px;\n\t\tmargin: 6px 0 0 5px;\n\t\ttext-align: center;\n\t\tborder-radius: 50%;\n\t}\n\n\t.tab-save-mark {\n\t\theight: 16px;\n\t\tline-height: 16px;\n\t\tmargin: 6px 0 0 5px;\n\t}\n\n\t.tab.closable:hover .tab-save-mark {\n\t\tdisplay: none;\n\t}\n\n\t.tab.closable .tab-save-mark {\n\t\tposition: absolute;\n\t\tright: 5px;\n\t}\n\n\t.tab.unsaved {\n\t\tcolor: #959d00;\n\t}\n\n\t.tab-x og-fa-icon {\n\t\tdisplay: block;\n\t}\n\n\t.tab-x:hover {\n\t\tbackground-color: var(--og-accent-color-alpha-30);\n\t}\n\n\t.empty {\n\t\tflex: 1;\n\t\theight: 100%;\n\t}\n\t\n\t.buttons {\n\t\tflex: 0;\n\t\theight: 100%;\n\t\tpadding: 0 10px 0 10px;\n\t}\n\n\t.buttons og-fa-icon {\n\t\tcursor: pointer;\n\t}\n\n\t.buttons og-fa-icon:hover {\n\t\tcolor: var(--og-text-color-2)\n\t}\n\n\t#overlay {\n\t\tbackground-color: var(--og-accent-color);\n\t\topacity: 0.5;\n\t\tpointer-events: none;\n\t}\n\n\t#btnAdd {\n\t\tmargin-left: 5px;\n\t\tline-height: 0;\n\t}\n\n`;"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/tabs",
3
- "version": "0.6.75",
3
+ "version": "0.6.77",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Universal tabbed layout component",
6
6
  "main": "./dist/index.js",
@@ -27,7 +27,7 @@
27
27
  "_prepublish": "yarn test && yarn lint"
28
28
  },
29
29
  "dependencies": {
30
- "@omegagrid/core": "^0.6.75",
30
+ "@omegagrid/core": "^0.6.77",
31
31
  "lit": "^3.1.1",
32
32
  "lit-html": "^3.1.1",
33
33
  "ts-debounce": "^4.0.0"