ion-segment.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /*!
  2. * (C) Ionic http://ionicframework.com - MIT License
  3. */
  4. import { proxyCustomElement, HTMLElement, createEvent, writeTask, h, Host } from '@stencil/core/internal/client';
  5. import { r as raf } from './helpers.js';
  6. import { i as isRTL } from './dir.js';
  7. import { c as createColorClasses, h as hostContext } from './theme.js';
  8. import { b as getIonMode } from './ionic-global.js';
  9. const segmentIosCss = ":host{--ripple-color:currentColor;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:grid;grid-auto-columns:1fr;position:relative;-ms-flex-align:stretch;align-items:stretch;-ms-flex-pack:center;justify-content:center;width:100%;background:var(--background);font-family:var(--ion-font-family, inherit);text-align:center;contain:paint;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}:host(.segment-scrollable){-ms-flex-pack:start;justify-content:start;width:auto;overflow-x:auto;grid-auto-columns:minmax(-webkit-min-content, 1fr);grid-auto-columns:minmax(min-content, 1fr)}:host(.segment-scrollable::-webkit-scrollbar){display:none}:host{--background:rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.065);border-radius:8px;overflow:hidden;z-index:0}:host(.ion-color){background:rgba(var(--ion-color-base-rgb), 0.065)}:host(.in-toolbar){-webkit-margin-start:auto;margin-inline-start:auto;-webkit-margin-end:auto;margin-inline-end:auto;margin-top:0;margin-bottom:0;width:auto}:host(.in-toolbar:not(.ion-color)){background:var(--ion-toolbar-segment-background, var(--background))}:host(.in-toolbar-color:not(.ion-color)){background:rgba(var(--ion-color-contrast-rgb), 0.11)}";
  10. const IonSegmentIosStyle0 = segmentIosCss;
  11. const segmentMdCss = ":host{--ripple-color:currentColor;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:grid;grid-auto-columns:1fr;position:relative;-ms-flex-align:stretch;align-items:stretch;-ms-flex-pack:center;justify-content:center;width:100%;background:var(--background);font-family:var(--ion-font-family, inherit);text-align:center;contain:paint;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}:host(.segment-scrollable){-ms-flex-pack:start;justify-content:start;width:auto;overflow-x:auto;grid-auto-columns:minmax(-webkit-min-content, 1fr);grid-auto-columns:minmax(min-content, 1fr)}:host(.segment-scrollable::-webkit-scrollbar){display:none}:host{--background:transparent;grid-auto-columns:minmax(auto, 360px)}:host(.in-toolbar){min-height:var(--min-height)}:host(.segment-scrollable) ::slotted(ion-segment-button){min-width:auto}";
  12. const IonSegmentMdStyle0 = segmentMdCss;
  13. const Segment = /*@__PURE__*/ proxyCustomElement(class Segment extends HTMLElement {
  14. constructor() {
  15. super();
  16. this.__registerHost();
  17. this.__attachShadow();
  18. this.ionChange = createEvent(this, "ionChange", 7);
  19. this.ionSelect = createEvent(this, "ionSelect", 7);
  20. this.ionStyle = createEvent(this, "ionStyle", 7);
  21. this.segmentViewEl = null;
  22. this.onClick = (ev) => {
  23. const current = ev.target;
  24. const previous = this.checked;
  25. // If the current element is a segment then that means
  26. // the user tried to swipe to a segment button and
  27. // click a segment button at the same time so we should
  28. // not update the checked segment button
  29. if (current.tagName === 'ION-SEGMENT') {
  30. return;
  31. }
  32. this.value = current.value;
  33. if (current !== previous) {
  34. this.emitValueChange();
  35. }
  36. if (this.segmentViewEl) {
  37. this.updateSegmentView();
  38. if (this.scrollable && previous) {
  39. this.checkButton(previous, current);
  40. }
  41. }
  42. else if (this.scrollable || !this.swipeGesture) {
  43. if (previous) {
  44. this.checkButton(previous, current);
  45. }
  46. else {
  47. this.setCheckedClasses();
  48. }
  49. }
  50. };
  51. this.onSlottedItemsChange = () => {
  52. /**
  53. * When the slotted segment buttons change we need to
  54. * ensure that the new segment buttons are checked if
  55. * the value matches the segment button value.
  56. */
  57. this.valueChanged(this.value);
  58. };
  59. this.getSegmentButton = (selector) => {
  60. var _a, _b;
  61. const buttons = this.getButtons().filter((button) => !button.disabled);
  62. const currIndex = buttons.findIndex((button) => button === document.activeElement);
  63. switch (selector) {
  64. case 'first':
  65. return buttons[0];
  66. case 'last':
  67. return buttons[buttons.length - 1];
  68. case 'next':
  69. return (_a = buttons[currIndex + 1]) !== null && _a !== void 0 ? _a : buttons[0];
  70. case 'previous':
  71. return (_b = buttons[currIndex - 1]) !== null && _b !== void 0 ? _b : buttons[buttons.length - 1];
  72. default:
  73. return null;
  74. }
  75. };
  76. this.activated = false;
  77. this.color = undefined;
  78. this.disabled = false;
  79. this.scrollable = false;
  80. this.swipeGesture = true;
  81. this.value = undefined;
  82. this.selectOnFocus = false;
  83. }
  84. colorChanged(value, oldValue) {
  85. /**
  86. * If color is set after not having
  87. * previously been set (or vice versa),
  88. * we need to emit style so the segment-buttons
  89. * can apply their color classes properly.
  90. */
  91. if ((oldValue === undefined && value !== undefined) || (oldValue !== undefined && value === undefined)) {
  92. this.emitStyle();
  93. }
  94. }
  95. swipeGestureChanged() {
  96. this.gestureChanged();
  97. }
  98. valueChanged(value, oldValue) {
  99. // Force a value to exist if we're using a segment view
  100. if (this.segmentViewEl && value === undefined) {
  101. this.value = this.getButtons()[0].value;
  102. return;
  103. }
  104. if (oldValue !== undefined && value !== undefined) {
  105. const buttons = this.getButtons();
  106. const previous = buttons.find((button) => button.value === oldValue);
  107. const current = buttons.find((button) => button.value === value);
  108. if (previous && current) {
  109. if (!this.segmentViewEl) {
  110. this.checkButton(previous, current);
  111. }
  112. else if (this.triggerScrollOnValueChange !== false) {
  113. this.updateSegmentView();
  114. }
  115. }
  116. }
  117. else if (value !== undefined && oldValue === undefined && this.segmentViewEl) {
  118. this.updateSegmentView();
  119. }
  120. /**
  121. * `ionSelect` is emitted every time the value changes (internal or external changes).
  122. * Used by `ion-segment-button` to determine if the button should be checked.
  123. */
  124. this.ionSelect.emit({ value });
  125. // The scroll listener should handle scrolling the active button into view as needed
  126. if (!this.segmentViewEl) {
  127. this.scrollActiveButtonIntoView();
  128. }
  129. this.triggerScrollOnValueChange = undefined;
  130. }
  131. disabledChanged() {
  132. this.gestureChanged();
  133. if (!this.segmentViewEl) {
  134. const buttons = this.getButtons();
  135. for (const button of buttons) {
  136. button.disabled = this.disabled;
  137. }
  138. }
  139. else {
  140. this.segmentViewEl.disabled = this.disabled;
  141. }
  142. }
  143. gestureChanged() {
  144. if (this.gesture) {
  145. this.gesture.enable(!this.scrollable && !this.disabled && this.swipeGesture);
  146. }
  147. }
  148. connectedCallback() {
  149. this.emitStyle();
  150. this.segmentViewEl = this.getSegmentView();
  151. }
  152. disconnectedCallback() {
  153. this.segmentViewEl = null;
  154. }
  155. componentWillLoad() {
  156. this.emitStyle();
  157. }
  158. async componentDidLoad() {
  159. this.segmentViewEl = this.getSegmentView();
  160. this.setCheckedClasses();
  161. /**
  162. * We need to wait for the buttons to all be rendered
  163. * before we can scroll.
  164. */
  165. raf(() => {
  166. /**
  167. * When the segment loads for the first
  168. * time we just want to snap the active button into
  169. * place instead of scroll. Smooth scrolling should only
  170. * happen when the user interacts with the segment.
  171. */
  172. this.scrollActiveButtonIntoView(false);
  173. });
  174. this.gesture = (await import('./index3.js')).createGesture({
  175. el: this.el,
  176. gestureName: 'segment',
  177. gesturePriority: 100,
  178. threshold: 0,
  179. passive: false,
  180. onStart: (ev) => this.onStart(ev),
  181. onMove: (ev) => this.onMove(ev),
  182. onEnd: (ev) => this.onEnd(ev),
  183. });
  184. this.gestureChanged();
  185. if (this.disabled) {
  186. this.disabledChanged();
  187. }
  188. // Update segment view based on the initial value,
  189. // but do not animate the scroll
  190. this.updateSegmentView(false);
  191. }
  192. onStart(detail) {
  193. this.valueBeforeGesture = this.value;
  194. this.activate(detail);
  195. }
  196. onMove(detail) {
  197. this.setNextIndex(detail);
  198. }
  199. onEnd(detail) {
  200. this.setActivated(false);
  201. this.setNextIndex(detail, true);
  202. detail.event.stopImmediatePropagation();
  203. const value = this.value;
  204. if (value !== undefined) {
  205. if (this.valueBeforeGesture !== value) {
  206. this.emitValueChange();
  207. this.updateSegmentView();
  208. }
  209. }
  210. this.valueBeforeGesture = undefined;
  211. }
  212. /**
  213. * Emits an `ionChange` event.
  214. *
  215. * This API should be called for user committed changes.
  216. * This API should not be used for external value changes.
  217. */
  218. emitValueChange() {
  219. const { value } = this;
  220. this.ionChange.emit({ value });
  221. }
  222. getButtons() {
  223. return Array.from(this.el.querySelectorAll('ion-segment-button'));
  224. }
  225. get checked() {
  226. return this.getButtons().find((button) => button.value === this.value);
  227. }
  228. /*
  229. * Activate both the segment and the buttons
  230. * due to a bug with ::slotted in Safari
  231. */
  232. setActivated(activated) {
  233. const buttons = this.getButtons();
  234. buttons.forEach((button) => {
  235. button.classList.toggle('segment-button-activated', activated);
  236. });
  237. this.activated = activated;
  238. }
  239. activate(detail) {
  240. const clicked = detail.event.target;
  241. const buttons = this.getButtons();
  242. const checked = buttons.find((button) => button.value === this.value);
  243. // Make sure we are only checking for activation on a segment button
  244. // since disabled buttons will get the click on the segment
  245. if (clicked.tagName !== 'ION-SEGMENT-BUTTON') {
  246. return;
  247. }
  248. // If there are no checked buttons, set the current button to checked
  249. if (!checked) {
  250. this.value = clicked.value;
  251. this.setCheckedClasses();
  252. }
  253. // If the gesture began on the clicked button with the indicator
  254. // then we should activate the indicator
  255. if (this.value === clicked.value) {
  256. this.setActivated(true);
  257. }
  258. }
  259. getIndicator(button) {
  260. const root = button.shadowRoot || button;
  261. return root.querySelector('.segment-button-indicator');
  262. }
  263. checkButton(previous, current) {
  264. const previousIndicator = this.getIndicator(previous);
  265. const currentIndicator = this.getIndicator(current);
  266. if (previousIndicator === null || currentIndicator === null) {
  267. return;
  268. }
  269. const previousClientRect = previousIndicator.getBoundingClientRect();
  270. const currentClientRect = currentIndicator.getBoundingClientRect();
  271. const widthDelta = previousClientRect.width / currentClientRect.width;
  272. const xPosition = previousClientRect.left - currentClientRect.left;
  273. // Scale the indicator width to match the previous indicator width
  274. // and translate it on top of the previous indicator
  275. const transform = `translate3d(${xPosition}px, 0, 0) scaleX(${widthDelta})`;
  276. writeTask(() => {
  277. // Remove the transition before positioning on top of the previous indicator
  278. currentIndicator.classList.remove('segment-button-indicator-animated');
  279. currentIndicator.style.setProperty('transform', transform);
  280. // Force a repaint to ensure the transform happens
  281. currentIndicator.getBoundingClientRect();
  282. // Add the transition to move the indicator into place
  283. currentIndicator.classList.add('segment-button-indicator-animated');
  284. // Remove the transform to slide the indicator back to the button clicked
  285. currentIndicator.style.setProperty('transform', '');
  286. this.scrollActiveButtonIntoView(true);
  287. });
  288. this.value = current.value;
  289. this.setCheckedClasses();
  290. }
  291. setCheckedClasses() {
  292. const buttons = this.getButtons();
  293. const index = buttons.findIndex((button) => button.value === this.value);
  294. const next = index + 1;
  295. for (const button of buttons) {
  296. button.classList.remove('segment-button-after-checked');
  297. }
  298. if (next < buttons.length) {
  299. buttons[next].classList.add('segment-button-after-checked');
  300. }
  301. }
  302. getSegmentView() {
  303. const buttons = this.getButtons();
  304. // Get the first button with a contentId
  305. const firstContentId = buttons.find((button) => button.contentId);
  306. // Get the segment content with an id matching the button's contentId
  307. const segmentContent = document.querySelector(`ion-segment-content[id="${firstContentId === null || firstContentId === void 0 ? void 0 : firstContentId.contentId}"]`);
  308. // Return the segment view for that matching segment content
  309. return segmentContent === null || segmentContent === void 0 ? void 0 : segmentContent.closest('ion-segment-view');
  310. }
  311. handleSegmentViewScroll(ev) {
  312. const { scrollRatio, isManualScroll } = ev.detail;
  313. if (!isManualScroll) {
  314. return;
  315. }
  316. const dispatchedFrom = ev.target;
  317. const segmentViewEl = this.segmentViewEl;
  318. const segmentEl = this.el;
  319. // Only update the indicator if the event was dispatched from the correct segment view
  320. if (ev.composedPath().includes(segmentViewEl) || (dispatchedFrom === null || dispatchedFrom === void 0 ? void 0 : dispatchedFrom.contains(segmentEl))) {
  321. const buttons = this.getButtons();
  322. // If no buttons are found or there is no value set then do nothing
  323. if (!buttons.length)
  324. return;
  325. const index = buttons.findIndex((button) => button.value === this.value);
  326. const current = buttons[index];
  327. const nextIndex = Math.round(scrollRatio * (buttons.length - 1));
  328. if (this.lastNextIndex === undefined || this.lastNextIndex !== nextIndex) {
  329. this.lastNextIndex = nextIndex;
  330. this.triggerScrollOnValueChange = false;
  331. this.checkButton(current, buttons[nextIndex]);
  332. this.emitValueChange();
  333. }
  334. }
  335. }
  336. /**
  337. * Finds the related segment view and sets its current content
  338. * based on the selected segment button. This method
  339. * should be called on initial load of the segment,
  340. * after the gesture is completed (if dragging between segments)
  341. * and when a segment button is clicked directly.
  342. */
  343. updateSegmentView(smoothScroll = true) {
  344. const buttons = this.getButtons();
  345. const button = buttons.find((btn) => btn.value === this.value);
  346. // If the button does not have a contentId then there is
  347. // no associated segment view to update
  348. if (!(button === null || button === void 0 ? void 0 : button.contentId)) {
  349. return;
  350. }
  351. const segmentView = this.segmentViewEl;
  352. if (segmentView) {
  353. segmentView.setContent(button.contentId, smoothScroll);
  354. }
  355. }
  356. scrollActiveButtonIntoView(smoothScroll = true) {
  357. const { scrollable, value, el } = this;
  358. if (scrollable) {
  359. const buttons = this.getButtons();
  360. const activeButton = buttons.find((button) => button.value === value);
  361. if (activeButton !== undefined) {
  362. const scrollContainerBox = el.getBoundingClientRect();
  363. const activeButtonBox = activeButton.getBoundingClientRect();
  364. /**
  365. * Subtract the active button x position from the scroll
  366. * container x position. This will give us the x position
  367. * of the active button within the scroll container.
  368. */
  369. const activeButtonLeft = activeButtonBox.x - scrollContainerBox.x;
  370. /**
  371. * If we just used activeButtonLeft, then the active button
  372. * would be aligned with the left edge of the scroll container.
  373. * Instead, we want the segment button to be centered. As a result,
  374. * we subtract half of the scroll container width. This will position
  375. * the left edge of the active button at the midpoint of the scroll container.
  376. * We then add half of the active button width. This will position the active
  377. * button such that the midpoint of the active button is at the midpoint of the
  378. * scroll container.
  379. */
  380. const centeredX = activeButtonLeft - scrollContainerBox.width / 2 + activeButtonBox.width / 2;
  381. /**
  382. * newScrollPosition is the absolute scroll position that the
  383. * container needs to move to in order to center the active button.
  384. * It is calculated by adding the current scroll position
  385. * (scrollLeft) to the offset needed to center the button
  386. * (centeredX).
  387. */
  388. const newScrollPosition = el.scrollLeft + centeredX;
  389. /**
  390. * We intentionally use scrollTo here instead of scrollIntoView
  391. * to avoid a WebKit bug where accelerated animations break
  392. * when using scrollIntoView. Using scrollIntoView will cause the
  393. * segment container to jump during the transition and then snap into place.
  394. * This is because scrollIntoView can potentially cause parent element
  395. * containers to also scroll. scrollTo does not have this same behavior, so
  396. * we use this API instead.
  397. *
  398. * scrollTo is used instead of scrollBy because there is a
  399. * Webkit bug that causes scrollBy to not work smoothly when
  400. * the active button is near the edge of the scroll container.
  401. * This leads to the buttons to jump around during the transition.
  402. *
  403. * Note that if there is not enough scrolling space to center the element
  404. * within the scroll container, the browser will attempt
  405. * to center by as much as it can.
  406. */
  407. el.scrollTo({
  408. top: 0,
  409. left: newScrollPosition,
  410. behavior: smoothScroll ? 'smooth' : 'instant',
  411. });
  412. }
  413. }
  414. }
  415. setNextIndex(detail, isEnd = false) {
  416. const rtl = isRTL(this.el);
  417. const activated = this.activated;
  418. const buttons = this.getButtons();
  419. const index = buttons.findIndex((button) => button.value === this.value);
  420. const previous = buttons[index];
  421. let current;
  422. let nextIndex;
  423. if (index === -1) {
  424. return;
  425. }
  426. // Get the element that the touch event started on in case
  427. // it was the checked button, then we will move the indicator
  428. const rect = previous.getBoundingClientRect();
  429. const left = rect.left;
  430. const width = rect.width;
  431. // Get the element that the gesture is on top of based on the currentX of the
  432. // gesture event and the Y coordinate of the starting element, since the gesture
  433. // can move up and down off of the segment
  434. const currentX = detail.currentX;
  435. const previousY = rect.top + rect.height / 2;
  436. /**
  437. * Segment can be used inside the shadow dom
  438. * so doing document.elementFromPoint would never
  439. * return a segment button in that instance.
  440. * We use getRootNode to which will return the parent
  441. * shadow root if used inside a shadow component and
  442. * returns document otherwise.
  443. */
  444. const root = this.el.getRootNode();
  445. const nextEl = root.elementFromPoint(currentX, previousY);
  446. const decreaseIndex = rtl ? currentX > left + width : currentX < left;
  447. const increaseIndex = rtl ? currentX < left : currentX > left + width;
  448. // If the indicator is currently activated then we have started the gesture
  449. // on top of the checked button so we need to slide the indicator
  450. // by checking the button next to it as we move
  451. if (activated && !isEnd) {
  452. // Decrease index, move left in LTR & right in RTL
  453. if (decreaseIndex) {
  454. const newIndex = index - 1;
  455. if (newIndex >= 0) {
  456. nextIndex = newIndex;
  457. }
  458. // Increase index, moves right in LTR & left in RTL
  459. }
  460. else if (increaseIndex) {
  461. if (activated && !isEnd) {
  462. const newIndex = index + 1;
  463. if (newIndex < buttons.length) {
  464. nextIndex = newIndex;
  465. }
  466. }
  467. }
  468. if (nextIndex !== undefined && !buttons[nextIndex].disabled) {
  469. current = buttons[nextIndex];
  470. }
  471. }
  472. // If the indicator is not activated then we will just set the indicator
  473. // to the element where the gesture ended
  474. if (!activated && isEnd) {
  475. current = nextEl;
  476. }
  477. if (current != null) {
  478. /**
  479. * If current element is ion-segment then that means
  480. * user tried to select a disabled ion-segment-button,
  481. * and we should not update the ripple.
  482. */
  483. if (current.tagName === 'ION-SEGMENT') {
  484. return false;
  485. }
  486. if (previous !== current) {
  487. this.checkButton(previous, current);
  488. }
  489. }
  490. return true;
  491. }
  492. emitStyle() {
  493. this.ionStyle.emit({
  494. segment: true,
  495. });
  496. }
  497. onKeyDown(ev) {
  498. const rtl = isRTL(this.el);
  499. let keyDownSelectsButton = this.selectOnFocus;
  500. let current;
  501. switch (ev.key) {
  502. case 'ArrowRight':
  503. ev.preventDefault();
  504. current = rtl ? this.getSegmentButton('previous') : this.getSegmentButton('next');
  505. break;
  506. case 'ArrowLeft':
  507. ev.preventDefault();
  508. current = rtl ? this.getSegmentButton('next') : this.getSegmentButton('previous');
  509. break;
  510. case 'Home':
  511. ev.preventDefault();
  512. current = this.getSegmentButton('first');
  513. break;
  514. case 'End':
  515. ev.preventDefault();
  516. current = this.getSegmentButton('last');
  517. break;
  518. case ' ':
  519. case 'Enter':
  520. ev.preventDefault();
  521. current = document.activeElement;
  522. keyDownSelectsButton = true;
  523. }
  524. if (!current) {
  525. return;
  526. }
  527. if (keyDownSelectsButton) {
  528. const previous = this.checked;
  529. this.checkButton(previous || current, current);
  530. if (current !== previous) {
  531. this.emitValueChange();
  532. }
  533. }
  534. current.setFocus();
  535. }
  536. render() {
  537. const mode = getIonMode(this);
  538. return (h(Host, { key: 'a64e39352050b516f7dc82ce95a4bcff8431d1d0', role: "tablist", onClick: this.onClick, class: createColorClasses(this.color, {
  539. [mode]: true,
  540. 'in-toolbar': hostContext('ion-toolbar', this.el),
  541. 'in-toolbar-color': hostContext('ion-toolbar[color]', this.el),
  542. 'segment-activated': this.activated,
  543. 'segment-disabled': this.disabled,
  544. 'segment-scrollable': this.scrollable,
  545. }) }, h("slot", { key: 'bb3f3ec30e59e0461fa620d8961ab730cc802a4e', onSlotchange: this.onSlottedItemsChange })));
  546. }
  547. get el() { return this; }
  548. static get watchers() { return {
  549. "color": ["colorChanged"],
  550. "swipeGesture": ["swipeGestureChanged"],
  551. "value": ["valueChanged"],
  552. "disabled": ["disabledChanged"]
  553. }; }
  554. static get style() { return {
  555. ios: IonSegmentIosStyle0,
  556. md: IonSegmentMdStyle0
  557. }; }
  558. }, [33, "ion-segment", {
  559. "color": [513],
  560. "disabled": [4],
  561. "scrollable": [4],
  562. "swipeGesture": [4, "swipe-gesture"],
  563. "value": [1032],
  564. "selectOnFocus": [4, "select-on-focus"],
  565. "activated": [32]
  566. }, [[16, "ionSegmentViewScroll", "handleSegmentViewScroll"], [0, "keydown", "onKeyDown"]], {
  567. "color": ["colorChanged"],
  568. "swipeGesture": ["swipeGestureChanged"],
  569. "value": ["valueChanged"],
  570. "disabled": ["disabledChanged"]
  571. }]);
  572. function defineCustomElement$1() {
  573. if (typeof customElements === "undefined") {
  574. return;
  575. }
  576. const components = ["ion-segment"];
  577. components.forEach(tagName => { switch (tagName) {
  578. case "ion-segment":
  579. if (!customElements.get(tagName)) {
  580. customElements.define(tagName, Segment);
  581. }
  582. break;
  583. } });
  584. }
  585. const IonSegment = Segment;
  586. const defineCustomElement = defineCustomElement$1;
  587. export { IonSegment, defineCustomElement };