@roadtrip/components 3.20.1 → 3.20.2

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.
@@ -22,8 +22,21 @@ const Tabs = class {
22
22
  }
23
23
  async componentWillLoad() {
24
24
  const tabs = this.tabs;
25
+ const tabBar = this.el.querySelector('road-tab-bar');
26
+ const selectedTabId = tabBar ? tabBar.getAttribute('selected-tab') : null;
25
27
  if (tabs.length > 0) {
26
- this.select(tabs[0]);
28
+ if (selectedTabId) {
29
+ const selectedTab = tabs.find(tab => tab.tab === selectedTabId);
30
+ if (selectedTab) {
31
+ await this.select(selectedTab);
32
+ }
33
+ else {
34
+ await this.select(tabs[0]);
35
+ }
36
+ }
37
+ else {
38
+ await this.select(tabs[0]);
39
+ }
27
40
  }
28
41
  }
29
42
  componentWillRender() {
@@ -1 +1 @@
1
- {"file":"road-tabs.entry.cjs.js","mappings":";;;;;;AAAA,MAAM,OAAO,GAAG,wCAAwC;;MCW3C,IAAI;;;;;;;IAEP,kBAAa,GAAG,KAAK,CAAC;IA+GtB,iBAAY,GAAG,CAAC,EAAe;MACrC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC;MAC1B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KAClB,CAAC;;;EA7FF,MAAM,iBAAiB;IACrB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACvB,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;MACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;KACtB;GACF;EAED,mBAAmB;IACjB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IACrD,IAAI,MAAM,EAAE;MACV,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,GAAG,SAAS,CAAC;MAChE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AC5B,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC3B,IAAI,CAAC,WAAW,EAAE;MAChB,OAAO;KACR;IAED,IAAI,UAAU,KAAK,WAAW,EAAE;MAC9B,IAAI,UAAU,EAAE;QACd,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC;OAC3B;MACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;KACvD;GACF;EAEO,YAAY,CAAC,WAA2C;IAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;IACpC,OAAO,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,UAAU,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;GACvF;EAED,IAAY,IAAI;IACd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC;GACzD;EAOD,MAAM;IACJ,QACEA,QAACC,UAAI,IACH,oBAAoB,EAAE,IAAI,CAAC,YAAY,IAEvCD,kBAAM,IAAI,EAAC,KAAK,GAAE,EAClBA,iBAAK,KAAK,EAAC,YAAY,IACrBA,qBAAO,CACH,CACD,EACP;GACH;;;AAGH,MAAM,MAAM,GAAG,CAAC,IAA0B,EAAE,GAAgC;EAC1E,MAAM,KAAK,GAAG,CAAC,OAAO,GAAG,KAAK,QAAQ;MAClC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC;MAC7B,GAAG,CAAC;EAER,IAAI,CAAC,KAAK,EAAE;IACV,OAAO,CAAC,KAAK,CAAC,iBAAiB,KAAK,kBAAkB,CAAC,CAAC;GACzD;EACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;;;;;","names":["h","Host"],"sources":["src/components/tabs/tabs.css?tag=road-tabs&encapsulation=shadow","src/components/tabs/tabs.tsx"],"sourcesContent":["/*\n * Tabs\n *\n */\n\n:host {\n position: relative;\n display: block;\n}\n","import { Component, Element, Event, EventEmitter, Host, Method, State, h } from '@stencil/core';\n\n/**\n * @slot - Content is placed between the named slots if provided without a slot.\n * @slot top - Content is placed at the top of the screen.\n */\n@Component({\n tag: 'road-tabs',\n styleUrl: 'tabs.css',\n shadow: true,\n})\nexport class Tabs {\n\n private transitioning = false;\n private leavingTab?: HTMLRoadTabElement;\n\n @Element() el!: HTMLRoadTabsElement;\n\n @State() selectedTab?: HTMLRoadTabElement;\n\n /**\n * Emitted when the navigation is about to transition to a new component.\n */\n @Event({ bubbles: false }) roadtabswillchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsWillChange!: EventEmitter<{tab: string}>;\n\n /**\n * Emitted when the navigation has finished transitioning to a new component.\n */\n @Event({ bubbles: false }) roadtabsdidchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsDidChange!: EventEmitter<{tab: string}>;\n\n async componentWillLoad() {\n const tabs = this.tabs;\n if (tabs.length > 0) {\n this.select(tabs[0]);\n }\n }\n\n componentWillRender() {\n const tabBar = this.el.querySelector('road-tab-bar');\n if (tabBar) {\n const tab = this.selectedTab ? this.selectedTab.tab : undefined;\n tabBar.selectedTab = tab;\n }\n }\n\n /**\n * Select a tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async select(tab: string | HTMLRoadTabElement): Promise<boolean> {\n const selectedTab = getTab(this.tabs, tab);\n if (!this.shouldSwitch(selectedTab)) {\n return false;\n }\n await this.setActive(selectedTab);\n this.tabSwitch();\n\n return true;\n }\n\n /**\n * Get a specific tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async getTab(tab: string | HTMLRoadTabElement): Promise<HTMLRoadTabElement | undefined> {\n return getTab(this.tabs, tab);\n }\n\n /**\n * Get the currently selected tab.\n */\n @Method()\n getSelected(): Promise<string | undefined> {\n return Promise.resolve(this.selectedTab ? this.selectedTab.tab : undefined);\n }\n\n private setActive(selectedTab: HTMLRoadTabElement): Promise<void> {\n if (this.transitioning) {\n return Promise.reject('transitioning already happening');\n }\n\n this.transitioning = true;\n this.leavingTab = this.selectedTab;\n this.selectedTab = selectedTab;\n this.roadTabsWillChange.emit({ tab: selectedTab.tab });\n selectedTab.active = true;\n return Promise.resolve();\n }\n\n private tabSwitch() {\n const selectedTab = this.selectedTab;\n const leavingTab = this.leavingTab;\n\n this.leavingTab = undefined;\n this.transitioning = false;\n if (!selectedTab) {\n return;\n }\n\n if (leavingTab !== selectedTab) {\n if (leavingTab) {\n leavingTab.active = false;\n }\n this.roadTabsDidChange.emit({ tab: selectedTab.tab });\n }\n }\n\n private shouldSwitch(selectedTab: HTMLRoadTabElement | undefined): selectedTab is HTMLRoadTabElement {\n const leavingTab = this.selectedTab;\n return selectedTab !== undefined && selectedTab !== leavingTab && !this.transitioning;\n }\n\n private get tabs() {\n return Array.from(this.el.querySelectorAll('road-tab'));\n }\n\n private onTabClicked = (ev: CustomEvent) => {\n const { tab } = ev.detail;\n this.select(tab);\n };\n\n render() {\n return (\n <Host\n onRoadTabButtonClick={this.onTabClicked}\n >\n <slot name=\"top\"/>\n <div class=\"tabs-inner\">\n <slot/>\n </div>\n </Host>\n );\n }\n}\n\nconst getTab = (tabs: HTMLRoadTabElement[], tab: string | HTMLRoadTabElement): HTMLRoadTabElement | undefined => {\n const tabEl = (typeof tab === 'string')\n ? tabs.find(t => t.tab === tab)\n : tab;\n\n if (!tabEl) {\n console.error(`tab with id: \"${tabEl}\" does not exist`);\n }\n return tabEl;\n};"],"version":3}
1
+ {"file":"road-tabs.entry.cjs.js","mappings":";;;;;;AAAA,MAAM,OAAO,GAAG,wCAAwC;;MCW3C,IAAI;;;;;;;IAEP,kBAAa,GAAG,KAAK,CAAC;IA2HtB,iBAAY,GAAG,CAAC,EAAe;MACrC,MAAM,E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AC,IAAI,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;KACvD;GACF;EAEO,YAAY,CAAC,WAA2C;IAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;IACpC,OAAO,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,UAAU,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;GACvF;EAED,IAAY,IAAI;IACd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC;GACzD;EAOD,MAAM;IACJ,QACEA,QAACC,UAAI,IACH,oBAAoB,EAAE,IAAI,CAAC,YAAY,IAEvCD,kBAAM,IAAI,EAAC,KAAK,GAAE,EAClBA,iBAAK,KAAK,EAAC,YAAY,IACrBA,qBAAO,CACH,CACD,EACP;GACH;;;AAGH,MAAM,MAAM,GAAG,CAAC,IAA0B,EAAE,GAAgC;EAC1E,MAAM,KAAK,GAAG,CAAC,OAAO,GAAG,KAAK,QAAQ;MAClC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC;MAC7B,GAAG,CAAC;EAER,IAAI,CAAC,KAAK,EAAE;IACV,OAAO,CAAC,KAAK,CAAC,iBAAiB,KAAK,kBAAkB,CAAC,CAAC;GACzD;EACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;;;;;","names":["h","Host"],"sources":["src/components/tabs/tabs.css?tag=road-tabs&encapsulation=shadow","src/components/tabs/tabs.tsx"],"sourcesContent":["/*\n * Tabs\n *\n */\n\n:host {\n position: relative;\n display: block;\n}\n","import { Component, Element, Event, EventEmitter, Host, Method, State, h } from '@stencil/core';\n\n/**\n * @slot - Content is placed between the named slots if provided without a slot.\n * @slot top - Content is placed at the top of the screen.\n */\n@Component({\n tag: 'road-tabs',\n styleUrl: 'tabs.css',\n shadow: true,\n})\nexport class Tabs {\n\n private transitioning = false;\n private leavingTab?: HTMLRoadTabElement;\n\n @Element() el!: HTMLRoadTabsElement;\n\n @State() selectedTab?: HTMLRoadTabElement;\n\n /**\n * Emitted when the navigation is about to transition to a new component.\n */\n @Event({ bubbles: false }) roadtabswillchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsWillChange!: EventEmitter<{tab: string}>;\n\n /**\n * Emitted when the navigation has finished transitioning to a new component.\n */\n @Event({ bubbles: false }) roadtabsdidchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsDidChange!: EventEmitter<{tab: string}>;\n\n async componentWillLoad() {\n const tabs = this.tabs;\n const tabBar = this.el.querySelector('road-tab-bar');\n const selectedTabId = tabBar ? tabBar.getAttribute('selected-tab') : null;\n \n if (tabs.length > 0) {\n if (selectedTabId) {\n const selectedTab = tabs.find(tab => tab.tab === selectedTabId);\n if (selectedTab) {\n await this.select(selectedTab);\n } else {\n await this.select(tabs[0]);\n }\n } else {\n await this.select(tabs[0]);\n }\n }\n }\n\n componentWillRender() {\n const tabBar = this.el.querySelector('road-tab-bar');\n if (tabBar) {\n const tab = this.selectedTab ? this.selectedTab.tab : undefined;\n tabBar.selectedTab = tab;\n }\n }\n\n /**\n * Select a tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async select(tab: string | HTMLRoadTabElement): Promise<boolean> {\n const selectedTab = getTab(this.tabs, tab);\n if (!this.shouldSwitch(selectedTab)) {\n return false;\n }\n await this.setActive(selectedTab);\n this.tabSwitch();\n\n return true;\n }\n\n /**\n * Get a specific tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async getTab(tab: string | HTMLRoadTabElement): Promise<HTMLRoadTabElement | undefined> {\n return getTab(this.tabs, tab);\n }\n\n /**\n * Get the currently selected tab.\n */\n @Method()\n getSelected(): Promise<string | undefined> {\n return Promise.resolve(this.selectedTab ? this.selectedTab.tab : undefined);\n }\n\n private setActive(selectedTab: HTMLRoadTabElement): Promise<void> {\n if (this.transitioning) {\n return Promise.reject('transitioning already happening');\n }\n\n this.transitioning = true;\n this.leavingTab = this.selectedTab;\n this.selectedTab = selectedTab;\n this.roadTabsWillChange.emit({ tab: selectedTab.tab });\n selectedTab.active = true;\n return Promise.resolve();\n }\n\n private tabSwitch() {\n const selectedTab = this.selectedTab;\n const leavingTab = this.leavingTab;\n\n this.leavingTab = undefined;\n this.transitioning = false;\n if (!selectedTab) {\n return;\n }\n\n if (leavingTab !== selectedTab) {\n if (leavingTab) {\n leavingTab.active = false;\n }\n this.roadTabsDidChange.emit({ tab: selectedTab.tab });\n }\n }\n\n private shouldSwitch(selectedTab: HTMLRoadTabElement | undefined): selectedTab is HTMLRoadTabElement {\n const leavingTab = this.selectedTab;\n return selectedTab !== undefined && selectedTab !== leavingTab && !this.transitioning;\n }\n\n private get tabs() {\n return Array.from(this.el.querySelectorAll('road-tab'));\n }\n\n private onTabClicked = (ev: CustomEvent) => {\n const { tab } = ev.detail;\n this.select(tab);\n };\n\n render() {\n return (\n <Host\n onRoadTabButtonClick={this.onTabClicked}\n >\n <slot name=\"top\"/>\n <div class=\"tabs-inner\">\n <slot/>\n </div>\n </Host>\n );\n }\n}\n\nconst getTab = (tabs: HTMLRoadTabElement[], tab: string | HTMLRoadTabElement): HTMLRoadTabElement | undefined => {\n const tabEl = (typeof tab === 'string')\n ? tabs.find(t => t.tab === tab)\n : tab;\n\n if (!tabEl) {\n console.error(`tab with id: \"${tabEl}\" does not exist`);\n }\n return tabEl;\n};"],"version":3}
@@ -14,8 +14,21 @@ export class Tabs {
14
14
  }
15
15
  async componentWillLoad() {
16
16
  const tabs = this.tabs;
17
+ const tabBar = this.el.querySelector('road-tab-bar');
18
+ const selectedTabId = tabBar ? tabBar.getAttribute('selected-tab') : null;
17
19
  if (tabs.length > 0) {
18
- this.select(tabs[0]);
20
+ if (selectedTabId) {
21
+ const selectedTab = tabs.find(tab => tab.tab === selectedTabId);
22
+ if (selectedTab) {
23
+ await this.select(selectedTab);
24
+ }
25
+ else {
26
+ await this.select(tabs[0]);
27
+ }
28
+ }
29
+ else {
30
+ await this.select(tabs[0]);
31
+ }
19
32
  }
20
33
  }
21
34
  componentWillRender() {
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../../src/components/tabs/tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAEhG;;;GAGG;AAMH,MAAM,OAAO,IAAI;;IAEP,kBAAa,GAAG,KAAK,CAAC;IA+GtB,iBAAY,GAAG,CAAC,EAAe,EAAE,EAAE;MACzC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC;MAC1B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC,CAAC;;;EA7FF,KAAK,CAAC,iBAAiB;IACrB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACvB,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;MACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;KACtB;EACH,CAAC;EAED,mBAAmB;IACjB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IACrD,IAAI,MAAM,EAAE;MACV,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;MAChE,MAAM,CAAC,WAAW,GAAG,GAAG,CAAC;KAC1B;EACH,CAAC;EAED;;;;KAIG;EAEH,KAAK,CAAC,MAAM,CAAC,GAAgC;IAC3C,MAAM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EAER,IAAI,CAAC,KAAK,EAAE;IACV,OAAO,CAAC,KAAK,CAAC,iBAAiB,KAAK,kBAAkB,CAAC,CAAC;GACzD;EACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["import { Component, Element, Event, EventEmitter, Host, Method, State, h } from '@stencil/core';\n\n/**\n * @slot - Content is placed between the named slots if provided without a slot.\n * @slot top - Content is placed at the top of the screen.\n */\n@Component({\n tag: 'road-tabs',\n styleUrl: 'tabs.css',\n shadow: true,\n})\nexport class Tabs {\n\n private transitioning = false;\n private leavingTab?: HTMLRoadTabElement;\n\n @Element() el!: HTMLRoadTabsElement;\n\n @State() selectedTab?: HTMLRoadTabElement;\n\n /**\n * Emitted when the navigation is about to transition to a new component.\n */\n @Event({ bubbles: false }) roadtabswillchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsWillChange!: EventEmitter<{tab: string}>;\n\n /**\n * Emitted when the navigation has finished transitioning to a new component.\n */\n @Event({ bubbles: false }) roadtabsdidchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsDidChange!: EventEmitter<{tab: string}>;\n\n async componentWillLoad() {\n const tabs = this.tabs;\n if (tabs.length > 0) {\n this.select(tabs[0]);\n }\n }\n\n componentWillRender() {\n const tabBar = this.el.querySelector('road-tab-bar');\n if (tabBar) {\n const tab = this.selectedTab ? this.selectedTab.tab : undefined;\n tabBar.selectedTab = tab;\n }\n }\n\n /**\n * Select a tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async select(tab: string | HTMLRoadTabElement): Promise<boolean> {\n const selectedTab = getTab(this.tabs, tab);\n if (!this.shouldSwitch(selectedTab)) {\n return false;\n }\n await this.setActive(selectedTab);\n this.tabSwitch();\n\n return true;\n }\n\n /**\n * Get a specific tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async getTab(tab: string | HTMLRoadTabElement): Promise<HTMLRoadTabElement | undefined> {\n return getTab(this.tabs, tab);\n }\n\n /**\n * Get the currently selected tab.\n */\n @Method()\n getSelected(): Promise<string | undefined> {\n return Promise.resolve(this.selectedTab ? this.selectedTab.tab : undefined);\n }\n\n private setActive(selectedTab: HTMLRoadTabElement): Promise<void> {\n if (this.transitioning) {\n return Promise.reject('transitioning already happening');\n }\n\n this.transitioning = true;\n this.leavingTab = this.selectedTab;\n this.selectedTab = selectedTab;\n this.roadTabsWillChange.emit({ tab: selectedTab.tab });\n selectedTab.active = true;\n return Promise.resolve();\n }\n\n private tabSwitch() {\n const selectedTab = this.selectedTab;\n const leavingTab = this.leavingTab;\n\n this.leavingTab = undefined;\n this.transitioning = false;\n if (!selectedTab) {\n return;\n }\n\n if (leavingTab !== selectedTab) {\n if (leavingTab) {\n leavingTab.active = false;\n }\n this.roadTabsDidChange.emit({ tab: selectedTab.tab });\n }\n }\n\n private shouldSwitch(selectedTab: HTMLRoadTabElement | undefined): selectedTab is HTMLRoadTabElement {\n const leavingTab = this.selectedTab;\n return selectedTab !== undefined && selectedTab !== leavingTab && !this.transitioning;\n }\n\n private get tabs() {\n return Array.from(this.el.querySelectorAll('road-tab'));\n }\n\n private onTabClicked = (ev: CustomEvent) => {\n const { tab } = ev.detail;\n this.select(tab);\n };\n\n render() {\n return (\n <Host\n onRoadTabButtonClick={this.onTabClicked}\n >\n <slot name=\"top\"/>\n <div class=\"tabs-inner\">\n <slot/>\n </div>\n </Host>\n );\n }\n}\n\nconst getTab = (tabs: HTMLRoadTabElement[], tab: string | HTMLRoadTabElement): HTMLRoadTabElement | undefined => {\n const tabEl = (typeof tab === 'string')\n ? tabs.find(t => t.tab === tab)\n : tab;\n\n if (!tabEl) {\n console.error(`tab with id: \"${tabEl}\" does not exist`);\n }\n return tabEl;\n};"]}
1
+ {"version":3,"file":"tabs.js","sourceRoot":"","sources":["../../../src/components/tabs/tabs.tsx"],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,CAAC,IAA0B,EAAE,GAAgC,EAAkC,EAAE;EAC9G,MAAM,KAAK,GAAG,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC;IACrC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC;IAC/B,CAAC,CAAC,GAAG,CAAC;EAER,IAAI,CAAC,KAAK,EAAE;IACV,OAAO,CAAC,KAAK,CAAC,iBAAiB,KAAK,kBAAkB,CAAC,CAAC;GACzD;EACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC","sourcesContent":["import { Component, Element, Event, EventEmitter, Host, Method, State, h } from '@stencil/core';\n\n/**\n * @slot - Content is placed between the named slots if provided without a slot.\n * @slot top - Content is placed at the top of the screen.\n */\n@Component({\n tag: 'road-tabs',\n styleUrl: 'tabs.css',\n shadow: true,\n})\nexport class Tabs {\n\n private transitioning = false;\n private leavingTab?: HTMLRoadTabElement;\n\n @Element() el!: HTMLRoadTabsElement;\n\n @State() selectedTab?: HTMLRoadTabElement;\n\n /**\n * Emitted when the navigation is about to transition to a new component.\n */\n @Event({ bubbles: false }) roadtabswillchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsWillChange!: EventEmitter<{tab: string}>;\n\n /**\n * Emitted when the navigation has finished transitioning to a new component.\n */\n @Event({ bubbles: false }) roadtabsdidchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsDidChange!: EventEmitter<{tab: string}>;\n\n async componentWillLoad() {\n const tabs = this.tabs;\n const tabBar = this.el.querySelector('road-tab-bar');\n const selectedTabId = tabBar ? tabBar.getAttribute('selected-tab') : null;\n \n if (tabs.length > 0) {\n if (selectedTabId) {\n const selectedTab = tabs.find(tab => tab.tab === selectedTabId);\n if (selectedTab) {\n await this.select(selectedTab);\n } else {\n await this.select(tabs[0]);\n }\n } else {\n await this.select(tabs[0]);\n }\n }\n }\n\n componentWillRender() {\n const tabBar = this.el.querySelector('road-tab-bar');\n if (tabBar) {\n const tab = this.selectedTab ? this.selectedTab.tab : undefined;\n tabBar.selectedTab = tab;\n }\n }\n\n /**\n * Select a tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async select(tab: string | HTMLRoadTabElement): Promise<boolean> {\n const selectedTab = getTab(this.tabs, tab);\n if (!this.shouldSwitch(selectedTab)) {\n return false;\n }\n await this.setActive(selectedTab);\n this.tabSwitch();\n\n return true;\n }\n\n /**\n * Get a specific tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async getTab(tab: string | HTMLRoadTabElement): Promise<HTMLRoadTabElement | undefined> {\n return getTab(this.tabs, tab);\n }\n\n /**\n * Get the currently selected tab.\n */\n @Method()\n getSelected(): Promise<string | undefined> {\n return Promise.resolve(this.selectedTab ? this.selectedTab.tab : undefined);\n }\n\n private setActive(selectedTab: HTMLRoadTabElement): Promise<void> {\n if (this.transitioning) {\n return Promise.reject('transitioning already happening');\n }\n\n this.transitioning = true;\n this.leavingTab = this.selectedTab;\n this.selectedTab = selectedTab;\n this.roadTabsWillChange.emit({ tab: selectedTab.tab });\n selectedTab.active = true;\n return Promise.resolve();\n }\n\n private tabSwitch() {\n const selectedTab = this.selectedTab;\n const leavingTab = this.leavingTab;\n\n this.leavingTab = undefined;\n this.transitioning = false;\n if (!selectedTab) {\n return;\n }\n\n if (leavingTab !== selectedTab) {\n if (leavingTab) {\n leavingTab.active = false;\n }\n this.roadTabsDidChange.emit({ tab: selectedTab.tab });\n }\n }\n\n private shouldSwitch(selectedTab: HTMLRoadTabElement | undefined): selectedTab is HTMLRoadTabElement {\n const leavingTab = this.selectedTab;\n return selectedTab !== undefined && selectedTab !== leavingTab && !this.transitioning;\n }\n\n private get tabs() {\n return Array.from(this.el.querySelectorAll('road-tab'));\n }\n\n private onTabClicked = (ev: CustomEvent) => {\n const { tab } = ev.detail;\n this.select(tab);\n };\n\n render() {\n return (\n <Host\n onRoadTabButtonClick={this.onTabClicked}\n >\n <slot name=\"top\"/>\n <div class=\"tabs-inner\">\n <slot/>\n </div>\n </Host>\n );\n }\n}\n\nconst getTab = (tabs: HTMLRoadTabElement[], tab: string | HTMLRoadTabElement): HTMLRoadTabElement | undefined => {\n const tabEl = (typeof tab === 'string')\n ? tabs.find(t => t.tab === tab)\n : tab;\n\n if (!tabEl) {\n console.error(`tab with id: \"${tabEl}\" does not exist`);\n }\n return tabEl;\n};"]}
@@ -18,8 +18,21 @@ const Tabs = class {
18
18
  }
19
19
  async componentWillLoad() {
20
20
  const tabs = this.tabs;
21
+ const tabBar = this.el.querySelector('road-tab-bar');
22
+ const selectedTabId = tabBar ? tabBar.getAttribute('selected-tab') : null;
21
23
  if (tabs.length > 0) {
22
- this.select(tabs[0]);
24
+ if (selectedTabId) {
25
+ const selectedTab = tabs.find(tab => tab.tab === selectedTabId);
26
+ if (selectedTab) {
27
+ await this.select(selectedTab);
28
+ }
29
+ else {
30
+ await this.select(tabs[0]);
31
+ }
32
+ }
33
+ else {
34
+ await this.select(tabs[0]);
35
+ }
23
36
  }
24
37
  }
25
38
  componentWillRender() {
@@ -1 +1 @@
1
- {"file":"road-tabs.entry.js","mappings":";;AAAA,MAAM,OAAO,GAAG,wCAAwC;;MCW3C,IAAI;;;;;;;IAEP,kBAAa,GAAG,KAAK,CAAC;IA+GtB,iBAAY,GAAG,CAAC,EAAe;MACrC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC;MAC1B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;KAClB,CAAC;;;EA7FF,MAAM,iBAAiB;IACrB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACvB,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;MACnB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAA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,CAAC,KAAK,EAAE;IACV,OAAO,CAAC,KAAK,CAAC,iBAAiB,KAAK,kBAAkB,CAAC,CAAC;GACzD;EACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;;;;;","names":[],"sources":["src/components/tabs/tabs.css?tag=road-tabs&encapsulation=shadow","src/components/tabs/tabs.tsx"],"sourcesContent":["/*\n * Tabs\n *\n */\n\n:host {\n position: relative;\n display: block;\n}\n","import { Component, Element, Event, EventEmitter, Host, Method, State, h } from '@stencil/core';\n\n/**\n * @slot - Content is placed between the named slots if provided without a slot.\n * @slot top - Content is placed at the top of the screen.\n */\n@Component({\n tag: 'road-tabs',\n styleUrl: 'tabs.css',\n shadow: true,\n})\nexport class Tabs {\n\n private transitioning = false;\n private leavingTab?: HTMLRoadTabElement;\n\n @Element() el!: HTMLRoadTabsElement;\n\n @State() selectedTab?: HTMLRoadTabElement;\n\n /**\n * Emitted when the navigation is about to transition to a new component.\n */\n @Event({ bubbles: false }) roadtabswillchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsWillChange!: EventEmitter<{tab: string}>;\n\n /**\n * Emitted when the navigation has finished transitioning to a new component.\n */\n @Event({ bubbles: false }) roadtabsdidchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsDidChange!: EventEmitter<{tab: string}>;\n\n async componentWillLoad() {\n const tabs = this.tabs;\n if (tabs.length > 0) {\n this.select(tabs[0]);\n }\n }\n\n componentWillRender() {\n const tabBar = this.el.querySelector('road-tab-bar');\n if (tabBar) {\n const tab = this.selectedTab ? this.selectedTab.tab : undefined;\n tabBar.selectedTab = tab;\n }\n }\n\n /**\n * Select a tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async select(tab: string | HTMLRoadTabElement): Promise<boolean> {\n const selectedTab = getTab(this.tabs, tab);\n if (!this.shouldSwitch(selectedTab)) {\n return false;\n }\n await this.setActive(selectedTab);\n this.tabSwitch();\n\n return true;\n }\n\n /**\n * Get a specific tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async getTab(tab: string | HTMLRoadTabElement): Promise<HTMLRoadTabElement | undefined> {\n return getTab(this.tabs, tab);\n }\n\n /**\n * Get the currently selected tab.\n */\n @Method()\n getSelected(): Promise<string | undefined> {\n return Promise.resolve(this.selectedTab ? this.selectedTab.tab : undefined);\n }\n\n private setActive(selectedTab: HTMLRoadTabElement): Promise<void> {\n if (this.transitioning) {\n return Promise.reject('transitioning already happening');\n }\n\n this.transitioning = true;\n this.leavingTab = this.selectedTab;\n this.selectedTab = selectedTab;\n this.roadTabsWillChange.emit({ tab: selectedTab.tab });\n selectedTab.active = true;\n return Promise.resolve();\n }\n\n private tabSwitch() {\n const selectedTab = this.selectedTab;\n const leavingTab = this.leavingTab;\n\n this.leavingTab = undefined;\n this.transitioning = false;\n if (!selectedTab) {\n return;\n }\n\n if (leavingTab !== selectedTab) {\n if (leavingTab) {\n leavingTab.active = false;\n }\n this.roadTabsDidChange.emit({ tab: selectedTab.tab });\n }\n }\n\n private shouldSwitch(selectedTab: HTMLRoadTabElement | undefined): selectedTab is HTMLRoadTabElement {\n const leavingTab = this.selectedTab;\n return selectedTab !== undefined && selectedTab !== leavingTab && !this.transitioning;\n }\n\n private get tabs() {\n return Array.from(this.el.querySelectorAll('road-tab'));\n }\n\n private onTabClicked = (ev: CustomEvent) => {\n const { tab } = ev.detail;\n this.select(tab);\n };\n\n render() {\n return (\n <Host\n onRoadTabButtonClick={this.onTabClicked}\n >\n <slot name=\"top\"/>\n <div class=\"tabs-inner\">\n <slot/>\n </div>\n </Host>\n );\n }\n}\n\nconst getTab = (tabs: HTMLRoadTabElement[], tab: string | HTMLRoadTabElement): HTMLRoadTabElement | undefined => {\n const tabEl = (typeof tab === 'string')\n ? tabs.find(t => t.tab === tab)\n : tab;\n\n if (!tabEl) {\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B,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC;IAC3B,IAAI,CAAC,WAAW,EAAE;MAChB,OAAO;KACR;IAED,IAAI,UAAU,KAAK,WAAW,EAAE;MAC9B,IAAI,UAAU,EAAE;QACd,UAAU,CAAC,MAAM,GAAG,KAAK,CAAC;OAC3B;MACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,EAAE,CAAC,CAAC;KACvD;GACF;EAEO,YAAY,CAAC,WAA2C;IAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC;IACpC,OAAO,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,UAAU,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;GACvF;EAED,IAAY,IAAI;IACd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC,CAAC;GACzD;EAOD,MAAM;IACJ,QACE,EAAC,IAAI,IACH,oBAAoB,EAAE,IAAI,CAAC,YAAY,IAEvC,YAAM,IAAI,EAAC,KAAK,GAAE,EAClB,WAAK,KAAK,EAAC,YAAY,IACrB,eAAO,CACH,CACD,EACP;GACH;;;AAGH,MAAM,MAAM,GAAG,CAAC,IAA0B,EAAE,GAAgC;EAC1E,MAAM,KAAK,GAAG,CAAC,OAAO,GAAG,KAAK,QAAQ;MAClC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC;MAC7B,GAAG,CAAC;EAER,IAAI,CAAC,KAAK,EAAE;IACV,OAAO,CAAC,KAAK,CAAC,iBAAiB,KAAK,kBAAkB,CAAC,CAAC;GACzD;EACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;;;;;","names":[],"sources":["src/components/tabs/tabs.css?tag=road-tabs&encapsulation=shadow","src/components/tabs/tabs.tsx"],"sourcesContent":["/*\n * Tabs\n *\n */\n\n:host {\n position: relative;\n display: block;\n}\n","import { Component, Element, Event, EventEmitter, Host, Method, State, h } from '@stencil/core';\n\n/**\n * @slot - Content is placed between the named slots if provided without a slot.\n * @slot top - Content is placed at the top of the screen.\n */\n@Component({\n tag: 'road-tabs',\n styleUrl: 'tabs.css',\n shadow: true,\n})\nexport class Tabs {\n\n private transitioning = false;\n private leavingTab?: HTMLRoadTabElement;\n\n @Element() el!: HTMLRoadTabsElement;\n\n @State() selectedTab?: HTMLRoadTabElement;\n\n /**\n * Emitted when the navigation is about to transition to a new component.\n */\n @Event({ bubbles: false }) roadtabswillchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsWillChange!: EventEmitter<{tab: string}>;\n\n /**\n * Emitted when the navigation has finished transitioning to a new component.\n */\n @Event({ bubbles: false }) roadtabsdidchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsDidChange!: EventEmitter<{tab: string}>;\n\n async componentWillLoad() {\n const tabs = this.tabs;\n const tabBar = this.el.querySelector('road-tab-bar');\n const selectedTabId = tabBar ? tabBar.getAttribute('selected-tab') : null;\n \n if (tabs.length > 0) {\n if (selectedTabId) {\n const selectedTab = tabs.find(tab => tab.tab === selectedTabId);\n if (selectedTab) {\n await this.select(selectedTab);\n } else {\n await this.select(tabs[0]);\n }\n } else {\n await this.select(tabs[0]);\n }\n }\n }\n\n componentWillRender() {\n const tabBar = this.el.querySelector('road-tab-bar');\n if (tabBar) {\n const tab = this.selectedTab ? this.selectedTab.tab : undefined;\n tabBar.selectedTab = tab;\n }\n }\n\n /**\n * Select a tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async select(tab: string | HTMLRoadTabElement): Promise<boolean> {\n const selectedTab = getTab(this.tabs, tab);\n if (!this.shouldSwitch(selectedTab)) {\n return false;\n }\n await this.setActive(selectedTab);\n this.tabSwitch();\n\n return true;\n }\n\n /**\n * Get a specific tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async getTab(tab: string | HTMLRoadTabElement): Promise<HTMLRoadTabElement | undefined> {\n return getTab(this.tabs, tab);\n }\n\n /**\n * Get the currently selected tab.\n */\n @Method()\n getSelected(): Promise<string | undefined> {\n return Promise.resolve(this.selectedTab ? this.selectedTab.tab : undefined);\n }\n\n private setActive(selectedTab: HTMLRoadTabElement): Promise<void> {\n if (this.transitioning) {\n return Promise.reject('transitioning already happening');\n }\n\n this.transitioning = true;\n this.leavingTab = this.selectedTab;\n this.selectedTab = selectedTab;\n this.roadTabsWillChange.emit({ tab: selectedTab.tab });\n selectedTab.active = true;\n return Promise.resolve();\n }\n\n private tabSwitch() {\n const selectedTab = this.selectedTab;\n const leavingTab = this.leavingTab;\n\n this.leavingTab = undefined;\n this.transitioning = false;\n if (!selectedTab) {\n return;\n }\n\n if (leavingTab !== selectedTab) {\n if (leavingTab) {\n leavingTab.active = false;\n }\n this.roadTabsDidChange.emit({ tab: selectedTab.tab });\n }\n }\n\n private shouldSwitch(selectedTab: HTMLRoadTabElement | undefined): selectedTab is HTMLRoadTabElement {\n const leavingTab = this.selectedTab;\n return selectedTab !== undefined && selectedTab !== leavingTab && !this.transitioning;\n }\n\n private get tabs() {\n return Array.from(this.el.querySelectorAll('road-tab'));\n }\n\n private onTabClicked = (ev: CustomEvent) => {\n const { tab } = ev.detail;\n this.select(tab);\n };\n\n render() {\n return (\n <Host\n onRoadTabButtonClick={this.onTabClicked}\n >\n <slot name=\"top\"/>\n <div class=\"tabs-inner\">\n <slot/>\n </div>\n </Host>\n );\n }\n}\n\nconst getTab = (tabs: HTMLRoadTabElement[], tab: string | HTMLRoadTabElement): HTMLRoadTabElement | undefined => {\n const tabEl = (typeof tab === 'string')\n ? tabs.find(t => t.tab === tab)\n : tab;\n\n if (!tabEl) {\n console.error(`tab with id: \"${tabEl}\" does not exist`);\n }\n return tabEl;\n};"],"version":3}
@@ -0,0 +1,2 @@
1
+ import{r as t,c as s,h as i,H as e,a as n}from"./p-f3d586b3.js";const a=":host{position:relative;display:block}";const r=class{constructor(i){t(this,i);this.roadtabswillchange=s(this,"roadtabswillchange",3);this.roadTabsWillChange=s(this,"roadTabsWillChange",3);this.roadtabsdidchange=s(this,"roadtabsdidchange",3);this.roadTabsDidChange=s(this,"roadTabsDidChange",3);this.transitioning=false;this.onTabClicked=t=>{const{tab:s}=t.detail;this.select(s)};this.selectedTab=undefined}async componentWillLoad(){const t=this.tabs;const s=this.el.querySelector("road-tab-bar");const i=s?s.getAttribute("selected-tab"):null;if(t.length>0){if(i){const s=t.find((t=>t.tab===i));if(s){await this.select(s)}else{await this.select(t[0])}}else{await this.select(t[0])}}}componentWillRender(){const t=this.el.querySelector("road-tab-bar");if(t){const s=this.selectedTab?this.selectedTab.tab:undefined;t.selectedTab=s}}async select(t){const s=h(this.tabs,t);if(!this.shouldSwitch(s)){return false}await this.setActive(s);this.tabSwitch();return true}async getTab(t){return h(this.tabs,t)}getSelected(){return Promise.resolve(this.selectedTab?this.selectedTab.tab:undefined)}setActive(t){if(this.transitioning){return Promise.reject("transitioning already happening")}this.transitioning=true;this.leavingTab=this.selectedTab;this.selectedTab=t;this.roadTabsWillChange.emit({tab:t.tab});t.active=true;return Promise.resolve()}tabSwitch(){const t=this.selectedTab;const s=this.leavingTab;this.leavingTab=undefined;this.transitioning=false;if(!t){return}if(s!==t){if(s){s.active=false}this.roadTabsDidChange.emit({tab:t.tab})}}shouldSwitch(t){const s=this.selectedTab;return t!==undefined&&t!==s&&!this.transitioning}get tabs(){return Array.from(this.el.querySelectorAll("road-tab"))}render(){return i(e,{onRoadTabButtonClick:this.onTabClicked},i("slot",{name:"top"}),i("div",{class:"tabs-inner"},i("slot",null)))}get el(){return n(this)}};const h=(t,s)=>{const i=typeof s==="string"?t.find((t=>t.tab===s)):s;if(!i){console.error(`tab with id: "${i}" does not exist`)}return i};r.style=a;export{r as road_tabs};
2
+ //# sourceMappingURL=p-f64453a3.entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["tabsCss","Tabs","this","transitioning","onTabClicked","ev","tab","detail","select","componentWillLoad","tabs","tabBar","el","querySelector","selectedTabId","getAttribute","length","selectedTab","find","componentWillRender","undefined","getTab","shouldSwitch","setActive","tabSwitch","getSelected","Promise","resolve","reject","leavingTab","roadTabsWillChange","emit","active","roadTabsDidChange","Array","from","querySelectorAll","render","h","Host","onRoadTabButtonClick","name","class","tabEl","t","console","error"],"sources":["src/components/tabs/tabs.css?tag=road-tabs&encapsulation=shadow","src/components/tabs/tabs.tsx"],"sourcesContent":["/*\n * Tabs\n *\n */\n\n:host {\n position: relative;\n display: block;\n}\n","import { Component, Element, Event, EventEmitter, Host, Method, State, h } from '@stencil/core';\n\n/**\n * @slot - Content is placed between the named slots if provided without a slot.\n * @slot top - Content is placed at the top of the screen.\n */\n@Component({\n tag: 'road-tabs',\n styleUrl: 'tabs.css',\n shadow: true,\n})\nexport class Tabs {\n\n private transitioning = false;\n private leavingTab?: HTMLRoadTabElement;\n\n @Element() el!: HTMLRoadTabsElement;\n\n @State() selectedTab?: HTMLRoadTabElement;\n\n /**\n * Emitted when the navigation is about to transition to a new component.\n */\n @Event({ bubbles: false }) roadtabswillchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsWillChange!: EventEmitter<{tab: string}>;\n\n /**\n * Emitted when the navigation has finished transitioning to a new component.\n */\n @Event({ bubbles: false }) roadtabsdidchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsDidChange!: EventEmitter<{tab: string}>;\n\n async componentWillLoad() {\n const tabs = this.tabs;\n const tabBar = this.el.querySelector('road-tab-bar');\n const selectedTabId = tabBar ? tabBar.getAttribute('selected-tab') : null;\n \n if (tabs.length > 0) {\n if (selectedTabId) {\n const selectedTab = tabs.find(tab => tab.tab === selectedTabId);\n if (selectedTab) {\n await this.select(selectedTab);\n } else {\n await this.select(tabs[0]);\n }\n } else {\n await this.select(tabs[0]);\n }\n }\n }\n\n componentWillRender() {\n const tabBar = this.el.querySelector('road-tab-bar');\n if (tabBar) {\n const tab = this.selectedTab ? this.selectedTab.tab : undefined;\n tabBar.selectedTab = tab;\n }\n }\n\n /**\n * Select a tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async select(tab: string | HTMLRoadTabElement): Promise<boolean> {\n const selectedTab = getTab(this.tabs, tab);\n if (!this.shouldSwitch(selectedTab)) {\n return false;\n }\n await this.setActive(selectedTab);\n this.tabSwitch();\n\n return true;\n }\n\n /**\n * Get a specific tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async getTab(tab: string | HTMLRoadTabElement): Promise<HTMLRoadTabElement | undefined> {\n return getTab(this.tabs, tab);\n }\n\n /**\n * Get the currently selected tab.\n */\n @Method()\n getSelected(): Promise<string | undefined> {\n return Promise.resolve(this.selectedTab ? this.selectedTab.tab : undefined);\n }\n\n private setActive(selectedTab: HTMLRoadTabElement): Promise<void> {\n if (this.transitioning) {\n return Promise.reject('transitioning already happening');\n }\n\n this.transitioning = true;\n this.leavingTab = this.selectedTab;\n this.selectedTab = selectedTab;\n this.roadTabsWillChange.emit({ tab: selectedTab.tab });\n selectedTab.active = true;\n return Promise.resolve();\n }\n\n private tabSwitch() {\n const selectedTab = this.selectedTab;\n const leavingTab = this.leavingTab;\n\n this.leavingTab = undefined;\n this.transitioning = false;\n if (!selectedTab) {\n return;\n }\n\n if (leavingTab !== selectedTab) {\n if (leavingTab) {\n leavingTab.active = false;\n }\n this.roadTabsDidChange.emit({ tab: selectedTab.tab });\n }\n }\n\n private shouldSwitch(selectedTab: HTMLRoadTabElement | undefined): selectedTab is HTMLRoadTabElement {\n const leavingTab = this.selectedTab;\n return selectedTab !== undefined && selectedTab !== leavingTab && !this.transitioning;\n }\n\n private get tabs() {\n return Array.from(this.el.querySelectorAll('road-tab'));\n }\n\n private onTabClicked = (ev: CustomEvent) => {\n const { tab } = ev.detail;\n this.select(tab);\n };\n\n render() {\n return (\n <Host\n onRoadTabButtonClick={this.onTabClicked}\n >\n <slot name=\"top\"/>\n <div class=\"tabs-inner\">\n <slot/>\n </div>\n </Host>\n );\n }\n}\n\nconst getTab = (tabs: HTMLRoadTabElement[], tab: string | HTMLRoadTabElement): HTMLRoadTabElement | undefined => {\n const tabEl = (typeof tab === 'string')\n ? tabs.find(t => t.tab === tab)\n : tab;\n\n if (!tabEl) {\n console.error(`tab with id: \"${tabEl}\" does not exist`);\n }\n return tabEl;\n};"],"mappings":"gEAAA,MAAMA,EAAU,yC,MCWHC,EAAI,M,iPAEPC,KAAAC,cAAgB,MA2HhBD,KAAAE,aAAgBC,IACtB,MAAMC,IAAEA,GAAQD,EAAGE,OACnBL,KAAKM,OAAOF,EAAI,E,2BAxGlB,uBAAMG,GACJ,MAAMC,EAAOR,KAAKQ,KAClB,MAAMC,EAAST,KAAKU,GAAGC,cAAc,gBACrC,MAAMC,EAAgBH,EAASA,EAAOI,aAAa,gBAAkB,KAErE,GAAIL,EAAKM,OAAS,EAAG,CACnB,GAAIF,EAAe,CACjB,MAAMG,EAAcP,EAAKQ,MAAKZ,GAAOA,EAAIA,MAAQQ,IACjD,GAAIG,EAAa,OACTf,KAAKM,OAAOS,E,KACb,OACCf,KAAKM,OAAOE,EAAK,G,MAEpB,OACCR,KAAKM,OAAOE,EAAK,G,GAK7B,mBAAAS,GACE,MAAMR,EAAST,KAAKU,GAAGC,cAAc,gBACrC,GAAIF,EAAQ,CACV,MAAML,EAAMJ,KAAKe,YAAcf,KAAKe,YAAYX,IAAMc,UACtDT,EAAOM,YAAcX,C,EAUzB,YAAME,CAAOF,GACX,MAAMW,EAAcI,EAAOnB,KAAKQ,KAAMJ,GACtC,IAAKJ,KAAKoB,aAAaL,GAAc,CACnC,OAAO,K,OAEHf,KAAKqB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,2 @@
1
- import{p as e,b as a}from"./p-f3d586b3.js";export{s as setNonce}from"./p-f3d586b3.js";const o=()=>{const a=import.meta.url;const o={};if(a!==""){o.resourcesUrl=new URL(".",a).href}return e(o)};o().then((e=>a(JSON.parse('[["p-27dcbb18",[[2,"road-counter",{"inputId":[1,"input-id"],"min":[2],"max":[2],"step":[1],"value":[2],"size":[1],"dustbin":[4],"readonly":[4],"leftIconClasses":[32],"rightIconClasses":[32],"isDustbinVisible":[32]},null,{"value":["onValueChange"]}],[1,"road-item",{"titleItem":[1,"title-item"],"text":[1],"button":[4],"detail":[4],"active":[4],"detailIcon":[1,"detail-icon"],"disabled":[4],"download":[1],"href":[1],"rel":[1],"lines":[1],"layout":[1],"target":[1],"type":[1],"multipleInputs":[32]}],[1,"road-badge",{"color":[1],"bubble":[4]}],[1,"road-list",{"lines":[1]}],[1,"road-toolbar",{"color":[1]}],[1,"road-drawer",{"isOpen":[1028,"is-open"],"position":[1],"drawerWidth":[2,"drawer-width"],"hasInverseHeader":[4,"has-inverse-header"],"hasBackIcon":[4,"has-back-icon"],"backText":[1,"back-text"],"drawerTitle":[1,"drawer-title"],"hasCloseIcon":[4,"has-close-icon"],"open":[64],"close":[64],"back":[64]},[[4,"keyup","onEscape"]],{"isOpen":["handleOpen"]}],[1,"road-col"],[1,"road-grid"],[1,"road-row"],[6,"road-input",{"inputId":[1,"input-id"],"autocapitalize":[1],"autocomplete":[1],"autocorrect":[1],"autofocus":[4],"disabled":[4],"enterkeyhint":[1],"inputmode":[1],"max":[1],"maxlength":[2],"min":[1],"minlength":[2],"name":[1],"pattern":[1],"placeholder":[1],"readonly":[4],"required":[4],"spellcheck":[4],"step":[1],"size":[2],"sizes":[1],"type":[1],"value":[1032],"label":[1],"error":[1],"helper":[1],"debounce":[2]},null,{"debounce":["debounceChanged"],"value":["valueChanged"]}],[1,"road-button",{"color":[1],"size":[513],"buttonType":[1,"button-type"],"iconOnly":[516,"icon-only"],"disabled":[516],"expand":[516],"download":[1],"href":[1],"rel":[1],"target":[1],"outline":[4]}],[1,"road-input-group"],[1,"road-label"],[1,"road-icon",{"color":[1],"ariaLabel":[1537,"aria-label"],"ariaHidden":[513,"aria-hidden"],"name":[1],"src":[1],"icon":[8],"size":[1],"rotate":[1],"lazy":[4],"sanitize":[4],"svgContent":[32],"isVisible":[32]},null,{"name":["loadIcon"],"src":["loadIcon"],"icon":["loadIcon"]}]]],["p-1c5ac353",[[1,"road-duration",{"isOpen":[1028,"is-open"],"header":[1],"min":[2],"max":[2],"step":[2],"open":[64],"close":[64]},[[0,"roadcardclick","handleClick"]]]]],["p-c6a552b7",[[2,"road-phone-number-input",{"disabled":[4],"countryData":[16],"language":[1],"codeLabel":[1,"code-label"],"phoneLabel":[1,"phone-label"],"phoneValue":[1,"phone-value"],"countryCode":[1,"country-code"],"errorMessage":[1,"error-message"],"required":[4],"selectedCountry":[32],"selectedCountryCode":[32],"phoneNumber":[32],"countryOptions":[32],"returnObject":[32]},null,{"errorMessage":["updateMessagePosition"]}]]],["p-09bfd80b",[[1,"road-content-card",{"insetImage":[4,"inset-image"]}]]],["p-27d2770a",[[2,"road-plate-number",{"country":[1],"disabled":[4],"placeholder":[1],"readonly":[4],"value":[1032],"motorbike":[4]},null,{"value":["valueChanged"]}]]],["p-5203acea",[[1,"road-profil-dropdown",{"isOpen":[1028,"is-open"]},[[4,"click","handleDocumentClick"]]]]],["p-cfc0a3a7",[[1,"road-rating",{"size":[513],"rate":[2],"showreviews":[4],"readonly":[4],"reviews":[2],"reviewsText":[1,"reviews-text"],"url":[1]}]]],["p-17ae87b0",[[1,"road-accordion",{"isOpen":[1028,"is-open"],"isLight":[4,"is-light"],"isLightSeparator":[4,"is-light-separator"],"isSmall":[4,"is-small"]}]]],["p-b510e552",[[1,"road-banner",{"isOpen":[1028,"is-open"],"label":[1],"link":[1],"url":[1],"close":[64]}]]],["p-72b3b34a",[[1,"road-carousel",{"options":[8],"pager":[4],"arrows":[4],"update":[64],"updateAutoHeight":[64],"slideTo":[64],"slideNext":[64],"slidePrev":[64],"getActiveIndex":[64],"getPreviousIndex":[64],"length":[64],"isEnd":[64],"isBeginning":[64],"startAutoplay":[64],"stopAutoplay":[64],"lockSwipeToNext":[64],"lockSwipeToPrev":[64],"lockSwipes":[64],"getSwiper":[64]},null,{"options":["optionsChanged"]}]]],["p-e8c9c816",[[6,"road-checkbox",{"checkboxId":[1,"checkbox-id"],"name":[1],"required":[4],"checked":[1028],"indeterminate":[4],"disabled":[4],"value":[1],"label":[1],"inverse":[4],"error":[1],"helper":[1]},null,{"checked":["checkedChanged"]}]]],["p-31cf9b61",[[1,"road-chip",{"color":[1],"outline":[4],"size":[1],"hasCloseIcon":[4,"has-close-icon"]}]]],["p-7a14e5b7",[[1,"road-collapse",{"isOpen":[1028,"is-open"],"showMore":[1,"show-more"],"showLess":[1,"show-less"],"centered":[4]}]]],["p-18967429",[[1,"road-dialog",{"isOpen":[1028,"is-open"],"hasCloseIcon":[4,"has-close-icon"],"color":[1],"icon":[1],"label":[1],"description":[1],"open":[64],"close":[64]},[[4,"keyup","onEscape"]]]]],["p-cdefa79c",[[1,"road-dropdown",{"isOpen":[1028,"is-open"],"isLight":[4,"is-light"],"isMedium":[4,"is-medium"],"position":[513],"direction":[513]},[[4,"click","handleDocumentClick"]]]]],["p-233eb25c",[[1,"road-modal",{"maxWidth":[2,"max-width"],"isOpen":[1028,"is-open"],"hasInverseHeader":[4,"has-inverse-header"],"modalTitle":[1,"modal-title"],"hasCloseIcon":[4,"has-close-icon"],"open":[64],"close":[64]},[[4,"keyup","onEscape"]]]]],["p-9a929988",[[6,"road-range",{"rangeId":[1,"range-id"],"value":[1032],"min":[1],"max":[1],"step":[1],"showValue":[4,"show-value"],"showTick":[4,"show-tick"],"showLabels":[4,"show-labels"]},[[2,"focus","handleFocus"],[2,"blur","handleBlur"]],{"value":["valueChanged"]}]]],["p-16c934bc",[[1,"road-toast",{"isOpen":[1028,"is-open"],"color":[1],"label":[1],"timeout":[2],"open":[64],"close":[64]},null,{"isOpen":["isOpenChanged"]}]]],["p-7db968e6",[[1,"road-alert",{"color":[1],"label":[1],"button":[1],"link":[1],"url":[1]}]]],["p-efe6e22f",[[2,"road-area-code",{"selectId":[1,"select-id"],"options":[16],"autofocus":[4],"disabled":[4],"name":[1],"required":[4],"size":[2],"sizes":[1],"label":[1],"error":[1],"value":[1025],"triggerRender":[1026,"trigger-render"],"selectedValue":[32]},null,{"value":["valueChanged"]}]]],["p-dcbb0d20",[[6,"road-autocomplete",{"options":[16],"visible":[32]},[[0,"roadFocus","handleFocus"],[0,"roadfocus","handleFocus"],[4,"click","onClickOutside"]]]]],["p-6ad5091d",[[1,"road-button-floating",{"position":[513],"href":[1],"rel":[1],"target":[1]},[[9,"scroll","onScroll"]]]]],["p-0fca389a",[[4,"road-carousel-item"]]],["p-25ade729",[[1,"road-flap",{"color":[1],"filled":[4],"size":[513]}]]],["p-a5eee655",[[1,"road-global-navigation",{"selectedTab":[1,"selected-tab"]},[[0,"roadNavbarItemClick","onNavbarChanged"],[0,"roadnavbaritemclick","onNavbarChanged"]],{"selectedTab":["selectedTabChanged"]}]]],["p-3bce3bdc",[[1,"road-illustration",{"ariaLabel":[1537,"aria-label"],"ariaHidden":[513,"aria-hidden"],"name":[1],"src":[1],"illustration":[8],"size":[1],"rotate":[1],"lazy":[4],"sanitize":[4],"illustrationSvgContent":[32],"isVisible":[32]},null,{"name":["loadIllustration"],"src":["loadIllustration"],"illustration":["loadIllustration"]}]]],["p-14ecc91e",[[1,"road-navbar",{"selectedTab":[1,"selected-tab"]},[[0,"roadNavbarItemClick","onNavbarChanged"],[0,"roadnavbaritemclick","onNavbarChanged"]],{"selectedTab":["selectedTabChanged"]}]]],["p-9ff79904",[[1,"road-navbar-item",{"disabled":[4],"download":[1],"href":[1],"rel":[1],"selected":[1028],"tab":[1],"target":[1]},[[8,"roadNavbarChanged","onNavbarChanged"],[8,"roadnavbarchanged","onNavbarChanged"]]]]],["p-ebd19369",[[1,"road-progress",{"value":[2],"numbersteps":[1],"label":[1],"showstep":[4],"animation":[4],"light":[4],"fullwidth":[4],"color":[1]}]]],["p-254ba3c4",[[1,"road-progress-indicator-horizontal",{"color":[513],"numberStep":[2,"number-step"],"stateFirstStep":[1,"state-first-step"],"stateSecondStep":[1,"state-second-step"],"stateThirdStep":[1,"state-third-step"],"urlStep1":[1,"url-step-1"],"urlStep2":[1,"url-step-2"],"urlStep3":[1,"url-step-3"]}]]],["p-054acf61",[[1,"road-progress-indicator-vertical"]]],["p-68599145",[[4,"road-progress-indicator-vertical-item"]]],["p-f90af0e1",[[1,"road-progress-tracker"]]],["p-e42a9ec4",[[4,"road-progress-tracker-item"]]],["p-76ccfc61",[[2,"road-radio",{"radioId":[1,"radio-id"],"name":[1],"required":[4],"disabled":[4],"value":[8],"label":[1],"inverse":[4],"error":[4],"helper":[1],"inline":[4],"checked":[32]},[[8,"roadChange","onRoadChangedChanged"],[8,"roadchange","onRoadChangedChanged"]]]]],["p-96abbe85",[[6,"road-radio-group",{"radioGroupId":[1,"radio-group-id"],"allowEmptySelection":[4,"allow-empty-selection"],"name":[1],"value":[1032],"label":[1],"asterisk":[4],"ariaLabel":[513,"aria-label"],"error":[1025],"helper":[1]},null,{"value":["valueChanged"],"error":["errorChanged"]}]]],["p-08b0be1b",[[1,"road-segmented-button",{"size":[1],"selected":[1028],"tab":[1]},[[8,"roadSegmentedButtonBarChanged","onButtonBarChanged"],[8,"roadSegmentedButtonbarchanged","onButtonBarChanged"]]]]],["p-20b115ed",[[1,"road-segmented-button-bar",{"selectedTab":[1,"selected-tab"]},null,{"selectedTab":["selectedTabChanged"]}]]],["p-4ba769a9",[[1,"road-segmented-buttons",{"selectedTab":[32],"select":[64],"getTab":[64],"getSelected":[64]}]]],["p-4a2f2612",[[2,"road-select",{"selectId":[1,"select-id"],"options":[16],"autofocus":[4],"disabled":[4],"name":[1],"required":[4],"size":[2],"sizes":[1],"label":[1],"error":[1],"value":[1032]},null,{"value":["valueChanged"]}]]],["p-73b4f413",[[6,"road-select-filter",{"options":[16],"parameters":[8],"isActive":[4,"is-active"],"onlySelect":[4,"only-select"],"isOpen":[32],"currentValue":[32],"activeIndex":[32]},[[0,"roadFocus","handleFocus"],[0,"roadfocus","handleFocus"],[0,"roadBlur","handleBlur"],[0,"roadblur","handleBlur"],[0,"roadChange","handleChange"],[0,"roadchange","handleChange"],[4,"click","onClickOutside"],[8,"keydown","handleKeydown"]]]]],["p-b614a9fb",[[1,"road-skeleton"]]],["p-f6d47cda",[[1,"road-spinner",{"size":[513],"color":[513]}]]],["p-30fa62f4",[[2,"road-switch",{"switchId":[1,"switch-id"],"name":[1],"checked":[1028],"disabled":[4],"label":[1],"color":[1],"hasLeftLabel":[4,"has-left-label"],"isSpaced":[4,"is-spaced"],"value":[1],"on":[1],"off":[1]},null,{"checked":["checkedChanged"]}]]],["p-74e359b7",[[1,"road-tab",{"active":[1028],"tab":[1],"setActive":[64]},[[8,"roadtabbarchanged","onTabBarChanged"]]]]],["p-faf16a12",[[1,"road-tab-bar",{"secondary":[4],"expand":[4],"center":[4],"selectedTab":[1537,"selected-tab"]},[[0,"roadTabButtonClick","onTabButtonClick"]],{"selectedTab":["selectedTabChanged"]}]]],["p-b09c076d",[[1,"road-tab-button",{"download":[1],"href":[1],"rel":[1],"layout":[1],"selected":[1028],"tab":[1],"target":[1]},[[8,"roadTabBarChanged","onTabBarChanged"],[8,"roadTabbarchanged","onTabBarChanged"]]]]],["p-d651deea",[[6,"road-table"]]],["p-db7cb1c8",[[1,"road-tabs",{"selectedTab":[32],"select":[64],"getTab":[64],"getSelected":[64]}]]],["p-cbe0c628",[[1,"road-tag",{"color":[1],"contrast":[4]}]]],["p-5483109e",[[1,"road-text",{"color":[1]}]]],["p-c7866ae4",[[2,"road-textarea",{"textareaId":[1,"textarea-id"],"autocapitalize":[1],"autofocus":[4],"disabled":[4],"inputmode":[1],"enterkeyhint":[1],"maxlength":[2],"minlength":[2],"name":[1],"placeholder":[1],"sizes":[1],"readonly":[4],"required":[4],"spellcheck":[4],"resize":[4],"cols":[2],"rows":[2],"wrap":[1],"value":[1025],"label":[1],"error":[1],"helper":[1]},null,{"value":["valueChanged"]}]]],["p-c1dca3cc",[[2,"road-toggle",{"toggleId":[1,"toggle-id"],"name":[1],"checked":[1028],"disabled":[4],"label":[1],"hasLeftLabel":[4,"has-left-label"],"isSpaced":[4,"is-spaced"],"value":[1],"on":[1],"off":[1]},null,{"checked":["checkedChanged"]}]]],["p-e2c6d81f",[[1,"road-toolbar-title"]]],["p-25683dc7",[[1,"road-toolbar-title-page"]]],["p-c096723c",[[1,"road-tooltip",{"tooltipId":[1,"tooltip-id"],"content":[1],"position":[1],"contentAlign":[1,"content-align"],"isOpen":[1028,"is-open"],"trigger":[1],"open":[64],"close":[64]}]]],["p-78e9bbd5",[[1,"road-avatar",{"size":[513]}]]],["p-dcbaee2f",[[1,"road-card",{"elevation":[1],"button":[4],"value":[1],"type":[1],"download":[1],"href":[1],"rel":[1],"target":[1]}]]],["p-bfcedcfb",[[1,"road-img",{"alt":[1],"src":[1],"loadSrc":[32],"loadError":[32]},null,{"src":["srcChanged"]}]]]]'),e)));
1
+ import{p as e,b as a}from"./p-f3d586b3.js";export{s as setNonce}from"./p-f3d586b3.js";const o=()=>{const a=import.meta.url;const o={};if(a!==""){o.resourcesUrl=new URL(".",a).href}return e(o)};o().then((e=>a(JSON.parse('[["p-27dcbb18",[[2,"road-counter",{"inputId":[1,"input-id"],"min":[2],"max":[2],"step":[1],"value":[2],"size":[1],"dustbin":[4],"readonly":[4],"leftIconClasses":[32],"rightIconClasses":[32],"isDustbinVisible":[32]},null,{"value":["onValueChange"]}],[1,"road-item",{"titleItem":[1,"title-item"],"text":[1],"button":[4],"detail":[4],"active":[4],"detailIcon":[1,"detail-icon"],"disabled":[4],"download":[1],"href":[1],"rel":[1],"lines":[1],"layout":[1],"target":[1],"type":[1],"multipleInputs":[32]}],[1,"road-badge",{"color":[1],"bubble":[4]}],[1,"road-list",{"lines":[1]}],[1,"road-toolbar",{"color":[1]}],[1,"road-drawer",{"isOpen":[1028,"is-open"],"position":[1],"drawerWidth":[2,"drawer-width"],"hasInverseHeader":[4,"has-inverse-header"],"hasBackIcon":[4,"has-back-icon"],"backText":[1,"back-text"],"drawerTitle":[1,"drawer-title"],"hasCloseIcon":[4,"has-close-icon"],"open":[64],"close":[64],"back":[64]},[[4,"keyup","onEscape"]],{"isOpen":["handleOpen"]}],[1,"road-col"],[1,"road-grid"],[1,"road-row"],[6,"road-input",{"inputId":[1,"input-id"],"autocapitalize":[1],"autocomplete":[1],"autocorrect":[1],"autofocus":[4],"disabled":[4],"enterkeyhint":[1],"inputmode":[1],"max":[1],"maxlength":[2],"min":[1],"minlength":[2],"name":[1],"pattern":[1],"placeholder":[1],"readonly":[4],"required":[4],"spellcheck":[4],"step":[1],"size":[2],"sizes":[1],"type":[1],"value":[1032],"label":[1],"error":[1],"helper":[1],"debounce":[2]},null,{"debounce":["debounceChanged"],"value":["valueChanged"]}],[1,"road-button",{"color":[1],"size":[513],"buttonType":[1,"button-type"],"iconOnly":[516,"icon-only"],"disabled":[516],"expand":[516],"download":[1],"href":[1],"rel":[1],"target":[1],"outline":[4]}],[1,"road-input-group"],[1,"road-label"],[1,"road-icon",{"color":[1],"ariaLabel":[1537,"aria-label"],"ariaHidden":[513,"aria-hidden"],"name":[1],"src":[1],"icon":[8],"size":[1],"rotate":[1],"lazy":[4],"sanitize":[4],"svgContent":[32],"isVisible":[32]},null,{"name":["loadIcon"],"src":["loadIcon"],"icon":["loadIcon"]}]]],["p-1c5ac353",[[1,"road-duration",{"isOpen":[1028,"is-open"],"header":[1],"min":[2],"max":[2],"step":[2],"open":[64],"close":[64]},[[0,"roadcardclick","handleClick"]]]]],["p-c6a552b7",[[2,"road-phone-number-input",{"disabled":[4],"countryData":[16],"language":[1],"codeLabel":[1,"code-label"],"phoneLabel":[1,"phone-label"],"phoneValue":[1,"phone-value"],"countryCode":[1,"country-code"],"errorMessage":[1,"error-message"],"required":[4],"selectedCountry":[32],"selectedCountryCode":[32],"phoneNumber":[32],"countryOptions":[32],"returnObject":[32]},null,{"errorMessage":["updateMessagePosition"]}]]],["p-09bfd80b",[[1,"road-content-card",{"insetImage":[4,"inset-image"]}]]],["p-27d2770a",[[2,"road-plate-number",{"country":[1],"disabled":[4],"placeholder":[1],"readonly":[4],"value":[1032],"motorbike":[4]},null,{"value":["valueChanged"]}]]],["p-5203acea",[[1,"road-profil-dropdown",{"isOpen":[1028,"is-open"]},[[4,"click","handleDocumentClick"]]]]],["p-cfc0a3a7",[[1,"road-rating",{"size":[513],"rate":[2],"showreviews":[4],"readonly":[4],"reviews":[2],"reviewsText":[1,"reviews-text"],"url":[1]}]]],["p-17ae87b0",[[1,"road-accordion",{"isOpen":[1028,"is-open"],"isLight":[4,"is-light"],"isLightSeparator":[4,"is-light-separator"],"isSmall":[4,"is-small"]}]]],["p-b510e552",[[1,"road-banner",{"isOpen":[1028,"is-open"],"label":[1],"link":[1],"url":[1],"close":[64]}]]],["p-72b3b34a",[[1,"road-carousel",{"options":[8],"pager":[4],"arrows":[4],"update":[64],"updateAutoHeight":[64],"slideTo":[64],"slideNext":[64],"slidePrev":[64],"getActiveIndex":[64],"getPreviousIndex":[64],"length":[64],"isEnd":[64],"isBeginning":[64],"startAutoplay":[64],"stopAutoplay":[64],"lockSwipeToNext":[64],"lockSwipeToPrev":[64],"lockSwipes":[64],"getSwiper":[64]},null,{"options":["optionsChanged"]}]]],["p-e8c9c816",[[6,"road-checkbox",{"checkboxId":[1,"checkbox-id"],"name":[1],"required":[4],"checked":[1028],"indeterminate":[4],"disabled":[4],"value":[1],"label":[1],"inverse":[4],"error":[1],"helper":[1]},null,{"checked":["checkedChanged"]}]]],["p-31cf9b61",[[1,"road-chip",{"color":[1],"outline":[4],"size":[1],"hasCloseIcon":[4,"has-close-icon"]}]]],["p-7a14e5b7",[[1,"road-collapse",{"isOpen":[1028,"is-open"],"showMore":[1,"show-more"],"showLess":[1,"show-less"],"centered":[4]}]]],["p-18967429",[[1,"road-dialog",{"isOpen":[1028,"is-open"],"hasCloseIcon":[4,"has-close-icon"],"color":[1],"icon":[1],"label":[1],"description":[1],"open":[64],"close":[64]},[[4,"keyup","onEscape"]]]]],["p-cdefa79c",[[1,"road-dropdown",{"isOpen":[1028,"is-open"],"isLight":[4,"is-light"],"isMedium":[4,"is-medium"],"position":[513],"direction":[513]},[[4,"click","handleDocumentClick"]]]]],["p-233eb25c",[[1,"road-modal",{"maxWidth":[2,"max-width"],"isOpen":[1028,"is-open"],"hasInverseHeader":[4,"has-inverse-header"],"modalTitle":[1,"modal-title"],"hasCloseIcon":[4,"has-close-icon"],"open":[64],"close":[64]},[[4,"keyup","onEscape"]]]]],["p-9a929988",[[6,"road-range",{"rangeId":[1,"range-id"],"value":[1032],"min":[1],"max":[1],"step":[1],"showValue":[4,"show-value"],"showTick":[4,"show-tick"],"showLabels":[4,"show-labels"]},[[2,"focus","handleFocus"],[2,"blur","handleBlur"]],{"value":["valueChanged"]}]]],["p-16c934bc",[[1,"road-toast",{"isOpen":[1028,"is-open"],"color":[1],"label":[1],"timeout":[2],"open":[64],"close":[64]},null,{"isOpen":["isOpenChanged"]}]]],["p-7db968e6",[[1,"road-alert",{"color":[1],"label":[1],"button":[1],"link":[1],"url":[1]}]]],["p-efe6e22f",[[2,"road-area-code",{"selectId":[1,"select-id"],"options":[16],"autofocus":[4],"disabled":[4],"name":[1],"required":[4],"size":[2],"sizes":[1],"label":[1],"error":[1],"value":[1025],"triggerRender":[1026,"trigger-render"],"selectedValue":[32]},null,{"value":["valueChanged"]}]]],["p-dcbb0d20",[[6,"road-autocomplete",{"options":[16],"visible":[32]},[[0,"roadFocus","handleFocus"],[0,"roadfocus","handleFocus"],[4,"click","onClickOutside"]]]]],["p-6ad5091d",[[1,"road-button-floating",{"position":[513],"href":[1],"rel":[1],"target":[1]},[[9,"scroll","onScroll"]]]]],["p-0fca389a",[[4,"road-carousel-item"]]],["p-25ade729",[[1,"road-flap",{"color":[1],"filled":[4],"size":[513]}]]],["p-a5eee655",[[1,"road-global-navigation",{"selectedTab":[1,"selected-tab"]},[[0,"roadNavbarItemClick","onNavbarChanged"],[0,"roadnavbaritemclick","onNavbarChanged"]],{"selectedTab":["selectedTabChanged"]}]]],["p-3bce3bdc",[[1,"road-illustration",{"ariaLabel":[1537,"aria-label"],"ariaHidden":[513,"aria-hidden"],"name":[1],"src":[1],"illustration":[8],"size":[1],"rotate":[1],"lazy":[4],"sanitize":[4],"illustrationSvgContent":[32],"isVisible":[32]},null,{"name":["loadIllustration"],"src":["loadIllustration"],"illustration":["loadIllustration"]}]]],["p-14ecc91e",[[1,"road-navbar",{"selectedTab":[1,"selected-tab"]},[[0,"roadNavbarItemClick","onNavbarChanged"],[0,"roadnavbaritemclick","onNavbarChanged"]],{"selectedTab":["selectedTabChanged"]}]]],["p-9ff79904",[[1,"road-navbar-item",{"disabled":[4],"download":[1],"href":[1],"rel":[1],"selected":[1028],"tab":[1],"target":[1]},[[8,"roadNavbarChanged","onNavbarChanged"],[8,"roadnavbarchanged","onNavbarChanged"]]]]],["p-ebd19369",[[1,"road-progress",{"value":[2],"numbersteps":[1],"label":[1],"showstep":[4],"animation":[4],"light":[4],"fullwidth":[4],"color":[1]}]]],["p-254ba3c4",[[1,"road-progress-indicator-horizontal",{"color":[513],"numberStep":[2,"number-step"],"stateFirstStep":[1,"state-first-step"],"stateSecondStep":[1,"state-second-step"],"stateThirdStep":[1,"state-third-step"],"urlStep1":[1,"url-step-1"],"urlStep2":[1,"url-step-2"],"urlStep3":[1,"url-step-3"]}]]],["p-054acf61",[[1,"road-progress-indicator-vertical"]]],["p-68599145",[[4,"road-progress-indicator-vertical-item"]]],["p-f90af0e1",[[1,"road-progress-tracker"]]],["p-e42a9ec4",[[4,"road-progress-tracker-item"]]],["p-76ccfc61",[[2,"road-radio",{"radioId":[1,"radio-id"],"name":[1],"required":[4],"disabled":[4],"value":[8],"label":[1],"inverse":[4],"error":[4],"helper":[1],"inline":[4],"checked":[32]},[[8,"roadChange","onRoadChangedChanged"],[8,"roadchange","onRoadChangedChanged"]]]]],["p-96abbe85",[[6,"road-radio-group",{"radioGroupId":[1,"radio-group-id"],"allowEmptySelection":[4,"allow-empty-selection"],"name":[1],"value":[1032],"label":[1],"asterisk":[4],"ariaLabel":[513,"aria-label"],"error":[1025],"helper":[1]},null,{"value":["valueChanged"],"error":["errorChanged"]}]]],["p-08b0be1b",[[1,"road-segmented-button",{"size":[1],"selected":[1028],"tab":[1]},[[8,"roadSegmentedButtonBarChanged","onButtonBarChanged"],[8,"roadSegmentedButtonbarchanged","onButtonBarChanged"]]]]],["p-20b115ed",[[1,"road-segmented-button-bar",{"selectedTab":[1,"selected-tab"]},null,{"selectedTab":["selectedTabChanged"]}]]],["p-4ba769a9",[[1,"road-segmented-buttons",{"selectedTab":[32],"select":[64],"getTab":[64],"getSelected":[64]}]]],["p-4a2f2612",[[2,"road-select",{"selectId":[1,"select-id"],"options":[16],"autofocus":[4],"disabled":[4],"name":[1],"required":[4],"size":[2],"sizes":[1],"label":[1],"error":[1],"value":[1032]},null,{"value":["valueChanged"]}]]],["p-73b4f413",[[6,"road-select-filter",{"options":[16],"parameters":[8],"isActive":[4,"is-active"],"onlySelect":[4,"only-select"],"isOpen":[32],"currentValue":[32],"activeIndex":[32]},[[0,"roadFocus","handleFocus"],[0,"roadfocus","handleFocus"],[0,"roadBlur","handleBlur"],[0,"roadblur","handleBlur"],[0,"roadChange","handleChange"],[0,"roadchange","handleChange"],[4,"click","onClickOutside"],[8,"keydown","handleKeydown"]]]]],["p-b614a9fb",[[1,"road-skeleton"]]],["p-f6d47cda",[[1,"road-spinner",{"size":[513],"color":[513]}]]],["p-30fa62f4",[[2,"road-switch",{"switchId":[1,"switch-id"],"name":[1],"checked":[1028],"disabled":[4],"label":[1],"color":[1],"hasLeftLabel":[4,"has-left-label"],"isSpaced":[4,"is-spaced"],"value":[1],"on":[1],"off":[1]},null,{"checked":["checkedChanged"]}]]],["p-74e359b7",[[1,"road-tab",{"active":[1028],"tab":[1],"setActive":[64]},[[8,"roadtabbarchanged","onTabBarChanged"]]]]],["p-faf16a12",[[1,"road-tab-bar",{"secondary":[4],"expand":[4],"center":[4],"selectedTab":[1537,"selected-tab"]},[[0,"roadTabButtonClick","onTabButtonClick"]],{"selectedTab":["selectedTabChanged"]}]]],["p-b09c076d",[[1,"road-tab-button",{"download":[1],"href":[1],"rel":[1],"layout":[1],"selected":[1028],"tab":[1],"target":[1]},[[8,"roadTabBarChanged","onTabBarChanged"],[8,"roadTabbarchanged","onTabBarChanged"]]]]],["p-d651deea",[[6,"road-table"]]],["p-f64453a3",[[1,"road-tabs",{"selectedTab":[32],"select":[64],"getTab":[64],"getSelected":[64]}]]],["p-cbe0c628",[[1,"road-tag",{"color":[1],"contrast":[4]}]]],["p-5483109e",[[1,"road-text",{"color":[1]}]]],["p-c7866ae4",[[2,"road-textarea",{"textareaId":[1,"textarea-id"],"autocapitalize":[1],"autofocus":[4],"disabled":[4],"inputmode":[1],"enterkeyhint":[1],"maxlength":[2],"minlength":[2],"name":[1],"placeholder":[1],"sizes":[1],"readonly":[4],"required":[4],"spellcheck":[4],"resize":[4],"cols":[2],"rows":[2],"wrap":[1],"value":[1025],"label":[1],"error":[1],"helper":[1]},null,{"value":["valueChanged"]}]]],["p-c1dca3cc",[[2,"road-toggle",{"toggleId":[1,"toggle-id"],"name":[1],"checked":[1028],"disabled":[4],"label":[1],"hasLeftLabel":[4,"has-left-label"],"isSpaced":[4,"is-spaced"],"value":[1],"on":[1],"off":[1]},null,{"checked":["checkedChanged"]}]]],["p-e2c6d81f",[[1,"road-toolbar-title"]]],["p-25683dc7",[[1,"road-toolbar-title-page"]]],["p-c096723c",[[1,"road-tooltip",{"tooltipId":[1,"tooltip-id"],"content":[1],"position":[1],"contentAlign":[1,"content-align"],"isOpen":[1028,"is-open"],"trigger":[1],"open":[64],"close":[64]}]]],["p-78e9bbd5",[[1,"road-avatar",{"size":[513]}]]],["p-dcbaee2f",[[1,"road-card",{"elevation":[1],"button":[4],"value":[1],"type":[1],"download":[1],"href":[1],"rel":[1],"target":[1]}]]],["p-bfcedcfb",[[1,"road-img",{"alt":[1],"src":[1],"loadSrc":[32],"loadError":[32]},null,{"src":["srcChanged"]}]]]]'),e)));
2
2
  //# sourceMappingURL=roadtrip.esm.js.map
package/hydrate/index.js CHANGED
@@ -36819,8 +36819,21 @@ class Tabs {
36819
36819
  }
36820
36820
  async componentWillLoad() {
36821
36821
  const tabs = this.tabs;
36822
+ const tabBar = this.el.querySelector('road-tab-bar');
36823
+ const selectedTabId = tabBar ? tabBar.getAttribute('selected-tab') : null;
36822
36824
  if (tabs.length > 0) {
36823
- this.select(tabs[0]);
36825
+ if (selectedTabId) {
36826
+ const selectedTab = tabs.find(tab => tab.tab === selectedTabId);
36827
+ if (selectedTab) {
36828
+ await this.select(selectedTab);
36829
+ }
36830
+ else {
36831
+ await this.select(tabs[0]);
36832
+ }
36833
+ }
36834
+ else {
36835
+ await this.select(tabs[0]);
36836
+ }
36824
36837
  }
36825
36838
  }
36826
36839
  componentWillRender() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roadtrip/components",
3
- "version": "3.20.1",
3
+ "version": "3.20.2",
4
4
  "description": "Web Component library for Roadtrip Design System",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://gitlab.com/mobivia-design/roadtrip/components",
@@ -1,2 +0,0 @@
1
- import{r as t,c as s,h as i,H as e,a as n}from"./p-f3d586b3.js";const a=":host{position:relative;display:block}";const r=class{constructor(i){t(this,i);this.roadtabswillchange=s(this,"roadtabswillchange",3);this.roadTabsWillChange=s(this,"roadTabsWillChange",3);this.roadtabsdidchange=s(this,"roadtabsdidchange",3);this.roadTabsDidChange=s(this,"roadTabsDidChange",3);this.transitioning=false;this.onTabClicked=t=>{const{tab:s}=t.detail;this.select(s)};this.selectedTab=undefined}async componentWillLoad(){const t=this.tabs;if(t.length>0){this.select(t[0])}}componentWillRender(){const t=this.el.querySelector("road-tab-bar");if(t){const s=this.selectedTab?this.selectedTab.tab:undefined;t.selectedTab=s}}async select(t){const s=h(this.tabs,t);if(!this.shouldSwitch(s)){return false}await this.setActive(s);this.tabSwitch();return true}async getTab(t){return h(this.tabs,t)}getSelected(){return Promise.resolve(this.selectedTab?this.selectedTab.tab:undefined)}setActive(t){if(this.transitioning){return Promise.reject("transitioning already happening")}this.transitioning=true;this.leavingTab=this.selectedTab;this.selectedTab=t;this.roadTabsWillChange.emit({tab:t.tab});t.active=true;return Promise.resolve()}tabSwitch(){const t=this.selectedTab;const s=this.leavingTab;this.leavingTab=undefined;this.transitioning=false;if(!t){return}if(s!==t){if(s){s.active=false}this.roadTabsDidChange.emit({tab:t.tab})}}shouldSwitch(t){const s=this.selectedTab;return t!==undefined&&t!==s&&!this.transitioning}get tabs(){return Array.from(this.el.querySelectorAll("road-tab"))}render(){return i(e,{onRoadTabButtonClick:this.onTabClicked},i("slot",{name:"top"}),i("div",{class:"tabs-inner"},i("slot",null)))}get el(){return n(this)}};const h=(t,s)=>{const i=typeof s==="string"?t.find((t=>t.tab===s)):s;if(!i){console.error(`tab with id: "${i}" does not exist`)}return i};r.style=a;export{r as road_tabs};
2
- //# sourceMappingURL=p-db7cb1c8.entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["tabsCss","Tabs","this","transitioning","onTabClicked","ev","tab","detail","select","componentWillLoad","tabs","length","componentWillRender","tabBar","el","querySelector","selectedTab","undefined","getTab","shouldSwitch","setActive","tabSwitch","getSelected","Promise","resolve","reject","leavingTab","roadTabsWillChange","emit","active","roadTabsDidChange","Array","from","querySelectorAll","render","h","Host","onRoadTabButtonClick","name","class","tabEl","find","t","console","error"],"sources":["src/components/tabs/tabs.css?tag=road-tabs&encapsulation=shadow","src/components/tabs/tabs.tsx"],"sourcesContent":["/*\n * Tabs\n *\n */\n\n:host {\n position: relative;\n display: block;\n}\n","import { Component, Element, Event, EventEmitter, Host, Method, State, h } from '@stencil/core';\n\n/**\n * @slot - Content is placed between the named slots if provided without a slot.\n * @slot top - Content is placed at the top of the screen.\n */\n@Component({\n tag: 'road-tabs',\n styleUrl: 'tabs.css',\n shadow: true,\n})\nexport class Tabs {\n\n private transitioning = false;\n private leavingTab?: HTMLRoadTabElement;\n\n @Element() el!: HTMLRoadTabsElement;\n\n @State() selectedTab?: HTMLRoadTabElement;\n\n /**\n * Emitted when the navigation is about to transition to a new component.\n */\n @Event({ bubbles: false }) roadtabswillchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsWillChange!: EventEmitter<{tab: string}>;\n\n /**\n * Emitted when the navigation has finished transitioning to a new component.\n */\n @Event({ bubbles: false }) roadtabsdidchange!: EventEmitter<{tab: string}>;\n /** @internal */\n @Event({ bubbles: false }) roadTabsDidChange!: EventEmitter<{tab: string}>;\n\n async componentWillLoad() {\n const tabs = this.tabs;\n if (tabs.length > 0) {\n this.select(tabs[0]);\n }\n }\n\n componentWillRender() {\n const tabBar = this.el.querySelector('road-tab-bar');\n if (tabBar) {\n const tab = this.selectedTab ? this.selectedTab.tab : undefined;\n tabBar.selectedTab = tab;\n }\n }\n\n /**\n * Select a tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async select(tab: string | HTMLRoadTabElement): Promise<boolean> {\n const selectedTab = getTab(this.tabs, tab);\n if (!this.shouldSwitch(selectedTab)) {\n return false;\n }\n await this.setActive(selectedTab);\n this.tabSwitch();\n\n return true;\n }\n\n /**\n * Get a specific tab by the value of its `tab` property or an element reference.\n *\n * @param tab The tab instance to select. If passed a string, it should be the value of the tab's `tab` property.\n */\n @Method()\n async getTab(tab: string | HTMLRoadTabElement): Promise<HTMLRoadTabElement | undefined> {\n return getTab(this.tabs, tab);\n }\n\n /**\n * Get the currently selected tab.\n */\n @Method()\n getSelected(): Promise<string | undefined> {\n return Promise.resolve(this.selectedTab ? this.selectedTab.tab : undefined);\n }\n\n private setActive(selectedTab: HTMLRoadTabElement): Promise<void> {\n if (this.transitioning) {\n return Promise.reject('transitioning already happening');\n }\n\n this.transitioning = true;\n this.leavingTab = this.selectedTab;\n this.selectedTab = selectedTab;\n this.roadTabsWillChange.emit({ tab: selectedTab.tab });\n selectedTab.active = true;\n return Promise.resolve();\n }\n\n private tabSwitch() {\n const selectedTab = this.selectedTab;\n const leavingTab = this.leavingTab;\n\n this.leavingTab = undefined;\n this.transitioning = false;\n if (!selectedTab) {\n return;\n }\n\n if (leavingTab !== selectedTab) {\n if (leavingTab) {\n leavingTab.active = false;\n }\n this.roadTabsDidChange.emit({ tab: selectedTab.tab });\n }\n }\n\n private shouldSwitch(selectedTab: HTMLRoadTabElement | undefined): selectedTab is HTMLRoadTabElement {\n const leavingTab = this.selectedTab;\n return selectedTab !== undefined && selectedTab !== leavingTab && !this.transitioning;\n }\n\n private get tabs() {\n return Array.from(this.el.querySelectorAll('road-tab'));\n }\n\n private onTabClicked = (ev: CustomEvent) => {\n const { tab } = ev.detail;\n this.select(tab);\n };\n\n render() {\n return (\n <Host\n onRoadTabButtonClick={this.onTabClicked}\n >\n <slot name=\"top\"/>\n <div class=\"tabs-inner\">\n <slot/>\n </div>\n </Host>\n );\n }\n}\n\nconst getTab = (tabs: HTMLRoadTabElement[], tab: string | HTMLRoadTabElement): HTMLRoadTabElement | undefined => {\n const tabEl = (typeof tab === 'string')\n ? tabs.find(t => t.tab === tab)\n : tab;\n\n if (!tabEl) {\n console.error(`tab with id: \"${tabEl}\" does not exist`);\n }\n return tabEl;\n};"],"mappings":"gEAAA,MAAMA,EAAU,yC,MCWHC,EAAI,M,iPAEPC,KAAAC,cAAgB,MA+GhBD,KAAAE,aAAgBC,IACtB,MAAMC,IAAEA,GAAQD,EAAGE,OACnBL,KAAKM,OAAOF,EAAI,E,2BA5FlB,uBAAMG,GACJ,MAAMC,EAAOR,KAAKQ,KAClB,GAAIA,EAAKC,OAAS,EAAG,CACnBT,KAAKM,OAAOE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