@ionic/core 9.0.0 → 9.0.1-nightly.20260820
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.
- package/components/index.js +1 -1
- package/components/ion-accordion-group.js +1 -1
- package/components/ion-accordion.js +1 -1
- package/components/ion-action-sheet.js +1 -1
- package/components/ion-alert.js +1 -1
- package/components/ion-app.js +1 -1
- package/components/ion-avatar.js +1 -1
- package/components/ion-back-button.js +1 -1
- package/components/ion-backdrop.js +1 -1
- package/components/ion-badge.js +1 -1
- package/components/ion-breadcrumb.js +1 -1
- package/components/ion-breadcrumbs.js +1 -1
- package/components/ion-button.js +1 -1
- package/components/ion-buttons.js +1 -1
- package/components/ion-card-content.js +1 -1
- package/components/ion-card-header.js +1 -1
- package/components/ion-card-subtitle.js +1 -1
- package/components/ion-card-title.js +1 -1
- package/components/ion-card.js +1 -1
- package/components/ion-checkbox.js +1 -1
- package/components/ion-chip.js +1 -1
- package/components/ion-col.js +1 -1
- package/components/ion-content.js +1 -1
- package/components/ion-datetime-button.js +1 -1
- package/components/ion-datetime.js +1 -1
- package/components/ion-fab-button.js +1 -1
- package/components/ion-fab-list.js +1 -1
- package/components/ion-fab.js +1 -1
- package/components/ion-footer.js +1 -1
- package/components/ion-grid.js +1 -1
- package/components/ion-header.js +1 -1
- package/components/ion-icon.js +1 -1
- package/components/ion-img.js +1 -1
- package/components/ion-infinite-scroll-content.js +1 -1
- package/components/ion-infinite-scroll.js +1 -1
- package/components/ion-input-otp.js +1 -1
- package/components/ion-input-password-toggle.js +1 -1
- package/components/ion-input.js +1 -1
- package/components/ion-item-divider.js +1 -1
- package/components/ion-item-group.js +1 -1
- package/components/ion-item-option.js +1 -1
- package/components/ion-item-options.js +1 -1
- package/components/ion-item-sliding.js +1 -1
- package/components/ion-item.js +1 -1
- package/components/ion-label.js +1 -1
- package/components/ion-list-header.js +1 -1
- package/components/ion-list.js +1 -1
- package/components/ion-loading.js +1 -1
- package/components/ion-menu-button.js +1 -1
- package/components/ion-menu-toggle.js +1 -1
- package/components/ion-menu.js +1 -1
- package/components/ion-modal.js +1 -1
- package/components/ion-nav-link.js +1 -1
- package/components/ion-nav.js +1 -1
- package/components/ion-note.js +1 -1
- package/components/ion-picker-column-option.js +1 -1
- package/components/ion-picker-column.js +1 -1
- package/components/ion-picker.js +1 -1
- package/components/ion-popover.js +1 -1
- package/components/ion-progress-bar.js +1 -1
- package/components/ion-radio-group.js +1 -1
- package/components/ion-radio.js +1 -1
- package/components/ion-range.js +1 -1
- package/components/ion-refresher-content.js +1 -1
- package/components/ion-refresher.js +1 -1
- package/components/ion-reorder-group.js +1 -1
- package/components/ion-reorder.js +1 -1
- package/components/ion-ripple-effect.js +1 -1
- package/components/ion-route-redirect.js +1 -1
- package/components/ion-route.js +1 -1
- package/components/ion-router-link.js +1 -1
- package/components/ion-router-outlet.js +1 -1
- package/components/ion-router.js +1 -1
- package/components/ion-row.js +1 -1
- package/components/ion-searchbar.js +1 -1
- package/components/ion-segment-button.js +1 -1
- package/components/ion-segment-content.js +1 -1
- package/components/ion-segment-view.js +1 -1
- package/components/ion-segment.js +1 -1
- package/components/ion-select-modal.js +1 -1
- package/components/ion-select-option.js +1 -1
- package/components/ion-select-popover.js +1 -1
- package/components/ion-select.js +1 -1
- package/components/ion-skeleton-text.js +1 -1
- package/components/ion-spinner.js +1 -1
- package/components/ion-split-pane.js +1 -1
- package/components/ion-tab-bar.js +1 -1
- package/components/ion-tab-button.js +1 -1
- package/components/ion-tab.js +1 -1
- package/components/ion-tabs.js +1 -1
- package/components/ion-text.js +1 -1
- package/components/ion-textarea.js +1 -1
- package/components/ion-thumbnail.js +1 -1
- package/components/ion-title.js +1 -1
- package/components/ion-toast.js +1 -1
- package/components/ion-toggle.js +1 -1
- package/components/ion-toolbar.js +1 -1
- package/components/{p-63OhffQv.js → p-66ogmUZU.js} +1 -1
- package/components/p-6Vp915Y7.js +4 -0
- package/components/p-7PNwKFZi.js +4 -0
- package/components/{p-G0TxqHfe.js → p-A8MJRBIY.js} +1 -1
- package/components/p-AQcCdH2_.js +4 -0
- package/{dist/ionic/p-Dn0mqQ_R.js → components/p-B6x5_b9w.js} +1 -1
- package/components/p-B8MQjdvk.js +4 -0
- package/components/p-BA_4ZIEg.js +4 -0
- package/components/p-BFtL8t1r.js +4 -0
- package/components/{p-DaA_8eqt.js → p-BMfgF-Tv.js} +1 -1
- package/components/p-BPDxVIRr.js +4 -0
- package/components/p-BSARlp49.js +4 -0
- package/components/p-B_gJaBk0.js +4 -0
- package/components/p-BdwCtX8Y.js +4 -0
- package/components/p-Bg4OwDwb.js +4 -0
- package/components/{p-DV85C0e0.js → p-BgUIV8NQ.js} +1 -1
- package/components/p-Bnc0m4SW.js +4 -0
- package/components/p-BpLt_Ptn.js +4 -0
- package/components/p-BqBDq1Ma.js +4 -0
- package/components/{p-C_phlPMC.js → p-BrFaQbGY.js} +1 -1
- package/{dist/ionic/p-Cdjxf_yg.js → components/p-BuPAFTWI.js} +1 -1
- package/components/p-Bx2saTHs.js +4 -0
- package/components/p-BxhE2W85.js +4 -0
- package/components/p-CHswSpKy.js +4 -0
- package/components/{p-fruGqVHh.js → p-CQAjyETU.js} +1 -1
- package/components/{p-1jI5oW-W.js → p-CR9OgE6N.js} +1 -1
- package/components/p-CWETxTjE.js +4 -0
- package/components/p-CaZeZIL2.js +4 -0
- package/components/p-CaiZOhfC.js +4 -0
- package/components/p-CgvDC7hC.js +4 -0
- package/components/{p-BqPNzJf6.js → p-CqyGR9Aq.js} +1 -1
- package/components/{p-UIBJkZf8.js → p-D0YpjgON.js} +1 -1
- package/components/p-D7ysFE2B.js +4 -0
- package/{dist/ionic/p-4eOQC00Z.js → components/p-DCWfzDM8.js} +1 -1
- package/components/{p-DwpKZ6rl.js → p-DDdkefwf.js} +1 -1
- package/components/{p-DzRT60Tw.js → p-DEW7CnUc.js} +1 -1
- package/components/p-DQ1IPvZO.js +4 -0
- package/components/p-DcOH6-o5.js +4 -0
- package/components/{p-DD5fQ4EQ.js → p-DfdYCsov.js} +1 -1
- package/components/{p-DSzSbVP2.js → p-DhOoEIAs.js} +1 -1
- package/components/{p-DM-PrAoh.js → p-Dl_7b_UJ.js} +1 -1
- package/components/p-DqAI6tg7.js +4 -0
- package/components/p-DrehWDfv.js +4 -0
- package/components/{p-ryyf_ItD.js → p-DysqCsJu.js} +1 -1
- package/components/p-H1f2qsk4.js +4 -0
- package/components/p-HVYBAhFx.js +4 -0
- package/components/{p-CbhUdtjf.js → p-Kmrg3Fed.js} +1 -1
- package/components/{p-Bjig0DJK.js → p-RFfE9hF6.js} +1 -1
- package/{dist/ionic/p-CBWAXjA5.js → components/p-SR-LLqp_.js} +1 -1
- package/components/p-eFI3mtEX.js +4 -0
- package/components/p-gFwXiYC_.js +4 -0
- package/components/p-tX3UxCnU.js +4 -0
- package/components/p-v2NpoOHp.js +4 -0
- package/dist/cjs/{animation-C0mOHzej.js → animation-D-OqR4a4.js} +1 -1
- package/dist/cjs/{app-globals-BREG4twP.js → app-globals-BzgwARwJ.js} +1 -1
- package/dist/cjs/{button-active-CVMevT9a.js → button-active-BlWSD7uK.js} +2 -2
- package/dist/cjs/{format-pp0Du3K-.js → format-D7ig6Vm0.js} +1 -1
- package/dist/cjs/{framework-delegate-Dfo5XsGv.js → framework-delegate-BZUx4TnE.js} +1 -1
- package/dist/cjs/{gesture-controller-BDUH7687.js → gesture-controller-CeJslptU.js} +6 -14
- package/dist/cjs/{hardware-back-button-fqpYh-kd.js → hardware-back-button-JOAEFSzc.js} +1 -1
- package/dist/cjs/{helpers-YPQybDph.js → helpers-Dj5o76mq.js} +1 -1
- package/dist/cjs/{index-BLdJCcJY.js → index-2sO-zkZ2.js} +4 -4
- package/dist/cjs/{index-uvry__L4.js → index-BrVMoqUk.js} +3 -1
- package/dist/cjs/{index-zVCah4Uz.js → index-C8zH6b3d.js} +2 -2
- package/dist/cjs/{index-DXsPSne6.js → index-CZ6vzt_q.js} +5 -5
- package/dist/cjs/{index-DDg31ZF5.js → index-Csue6G3m.js} +2 -2
- package/dist/cjs/{index-DwlRtFZe.js → index-DRPqwSvU.js} +1 -1
- package/dist/cjs/{index-B7zJsYWS.js → index-EJLjthTK.js} +1 -2
- package/dist/cjs/index.cjs.js +14 -14
- package/dist/cjs/{input-shims-Cbu1fcye.js → input-shims-Bh7bnt2v.js} +3 -3
- package/dist/cjs/{input.utils-BZdMWVrt.js → input.utils-Cq3g9uHy.js} +1 -1
- package/dist/cjs/ion-accordion_2.cjs.entry.js +335 -364
- package/dist/cjs/ion-action-sheet.cjs.entry.js +60 -140
- package/dist/cjs/ion-alert.cjs.entry.js +67 -159
- package/dist/cjs/ion-app_8.cjs.entry.js +163 -258
- package/dist/cjs/ion-avatar_3.cjs.entry.js +2 -8
- package/dist/cjs/ion-back-button.cjs.entry.js +21 -45
- package/dist/cjs/ion-backdrop.cjs.entry.js +14 -18
- package/dist/cjs/ion-breadcrumb_2.cjs.entry.js +117 -195
- package/dist/cjs/ion-button_2.cjs.entry.js +61 -130
- package/dist/cjs/ion-card_5.cjs.entry.js +28 -80
- package/dist/cjs/ion-checkbox.cjs.entry.js +98 -147
- package/dist/cjs/ion-chip.cjs.entry.js +10 -16
- package/dist/cjs/ion-col_3.cjs.entry.js +6 -126
- package/dist/cjs/ion-datetime-button.cjs.entry.js +232 -248
- package/dist/cjs/ion-datetime.cjs.entry.js +775 -953
- package/dist/cjs/ion-fab_3.cjs.entry.js +78 -136
- package/dist/cjs/ion-img.cjs.entry.js +11 -31
- package/dist/cjs/ion-infinite-scroll_2.cjs.entry.js +71 -98
- package/dist/cjs/ion-input-otp.cjs.entry.js +352 -424
- package/dist/cjs/ion-input-password-toggle.cjs.entry.js +14 -29
- package/dist/cjs/ion-input.cjs.entry.js +158 -302
- package/dist/cjs/ion-item-option_3.cjs.entry.js +45 -87
- package/dist/cjs/ion-item_8.cjs.entry.js +61 -157
- package/dist/cjs/ion-loading.cjs.entry.js +54 -131
- package/dist/cjs/ion-menu_3.cjs.entry.js +94 -158
- package/dist/cjs/ion-modal.cjs.entry.js +206 -362
- package/dist/cjs/ion-nav_2.cjs.entry.js +26 -78
- package/dist/cjs/ion-picker-column-option.cjs.entry.js +23 -33
- package/dist/cjs/ion-picker-column.cjs.entry.js +389 -410
- package/dist/cjs/ion-picker.cjs.entry.js +390 -400
- package/dist/cjs/ion-popover.cjs.entry.js +184 -292
- package/dist/cjs/ion-progress-bar.cjs.entry.js +23 -29
- package/dist/cjs/ion-radio_2.cjs.entry.js +128 -201
- package/dist/cjs/ion-range.cjs.entry.js +223 -293
- package/dist/cjs/ion-refresher_2.cjs.entry.js +79 -151
- package/dist/cjs/ion-reorder_2.cjs.entry.js +19 -49
- package/dist/cjs/ion-ripple-effect.cjs.entry.js +13 -13
- package/dist/cjs/ion-route_4.cjs.entry.js +45 -144
- package/dist/cjs/ion-searchbar.cjs.entry.js +182 -268
- package/dist/cjs/ion-segment-content.cjs.entry.js +1 -1
- package/dist/cjs/ion-segment-view.cjs.entry.js +12 -24
- package/dist/cjs/ion-segment_2.cjs.entry.js +111 -154
- package/dist/cjs/ion-select-modal.cjs.entry.js +19 -21
- package/dist/cjs/ion-select_3.cjs.entry.js +151 -319
- package/dist/cjs/ion-spinner.cjs.entry.js +6 -21
- package/dist/cjs/ion-split-pane.cjs.entry.js +14 -27
- package/dist/cjs/ion-tab-bar_2.cjs.entry.js +32 -89
- package/dist/cjs/ion-tab_2.cjs.entry.js +22 -49
- package/dist/cjs/ion-text.cjs.entry.js +2 -8
- package/dist/cjs/ion-textarea.cjs.entry.js +139 -256
- package/dist/cjs/ion-toast.cjs.entry.js +106 -221
- package/dist/cjs/ion-toggle.cjs.entry.js +114 -165
- package/dist/cjs/{ionic-global-k6hOWWpn.js → ionic-global-DvgIzM2F.js} +1 -1
- package/dist/cjs/ionic.cjs.js +4 -4
- package/dist/cjs/{ios.transition-zTmJz8T-.js → ios.transition-zIgdoSYe.js} +4 -4
- package/dist/cjs/{item-multiple-inputs-BdYSbfKN.js → item-multiple-inputs-DG-ZGm6j.js} +1 -1
- package/dist/cjs/loader.cjs.js +4 -4
- package/dist/cjs/{md.transition-nb_4pUXu.js → md.transition-CXeJ9rfh.js} +4 -4
- package/dist/cjs/{overlays-KaNVDNqC.js → overlays-Bg0auTQa.js} +6 -6
- package/dist/cjs/{select-option-render-pULCGldr.js → select-option-render-7m1WdFzF.js} +2 -2
- package/dist/cjs/{slot-mutation-controller-DPHmqXdV.js → slot-mutation-controller-BJEJzx_e.js} +1 -1
- package/dist/cjs/{status-tap-o9IIymsP.js → status-tap-DxbUM5XX.js} +3 -3
- package/dist/cjs/{swipe-back-B7X9VOlH.js → swipe-back-F_DBt-Aw.js} +4 -4
- package/dist/collection/components/accordion/accordion.js +310 -314
- package/dist/collection/components/accordion-group/accordion-group.js +23 -46
- package/dist/collection/components/action-sheet/action-sheet.js +49 -128
- package/dist/collection/components/action-sheet/test/basic/fixture.js +0 -3
- package/dist/collection/components/alert/alert.js +56 -147
- package/dist/collection/components/app/app.js +0 -3
- package/dist/collection/components/back-button/back-button.js +19 -42
- package/dist/collection/components/backdrop/backdrop.js +14 -16
- package/dist/collection/components/badge/badge.js +0 -6
- package/dist/collection/components/breadcrumb/breadcrumb.js +29 -90
- package/dist/collection/components/breadcrumbs/breadcrumbs.js +87 -102
- package/dist/collection/components/button/button.js +59 -127
- package/dist/collection/components/buttons/buttons.js +15 -13
- package/dist/collection/components/card/card.js +20 -53
- package/dist/collection/components/card-header/card-header.js +8 -12
- package/dist/collection/components/card-subtitle/card-subtitle.js +0 -6
- package/dist/collection/components/card-title/card-title.js +0 -6
- package/dist/collection/components/checkbox/checkbox.js +95 -143
- package/dist/collection/components/chip/chip.js +10 -14
- package/dist/collection/components/col/col.js +0 -120
- package/dist/collection/components/content/content.js +60 -90
- package/dist/collection/components/datetime/datetime.js +762 -939
- package/dist/collection/components/datetime-button/datetime-button.js +229 -244
- package/dist/collection/components/fab/fab.js +13 -20
- package/dist/collection/components/fab-button/fab-button.js +54 -103
- package/dist/collection/components/fab-list/fab-list.js +11 -10
- package/dist/collection/components/footer/footer.js +43 -49
- package/dist/collection/components/grid/grid.js +6 -4
- package/dist/collection/components/header/header.js +23 -33
- package/dist/collection/components/img/img.js +9 -28
- package/dist/collection/components/infinite-scroll/infinite-scroll.js +66 -73
- package/dist/collection/components/infinite-scroll-content/infinite-scroll-content.js +3 -20
- package/dist/collection/components/input/input.js +154 -297
- package/dist/collection/components/input-otp/input-otp.js +350 -421
- package/dist/collection/components/input-password-toggle/input-password-toggle.js +13 -27
- package/dist/collection/components/item/item.js +37 -80
- package/dist/collection/components/item-divider/item-divider.js +10 -15
- package/dist/collection/components/item-option/item-option.js +20 -48
- package/dist/collection/components/item-options/item-options.js +7 -10
- package/dist/collection/components/item-sliding/item-sliding.js +16 -24
- package/dist/collection/components/label/label.js +4 -24
- package/dist/collection/components/list/list.js +6 -9
- package/dist/collection/components/list-header/list-header.js +0 -10
- package/dist/collection/components/loading/loading.js +46 -122
- package/dist/collection/components/menu/menu.js +55 -99
- package/dist/collection/components/menu-button/menu-button.js +19 -28
- package/dist/collection/components/menu-toggle/menu-toggle.js +13 -20
- package/dist/collection/components/modal/modal.js +196 -351
- package/dist/collection/components/modal/test/fixtures.js +0 -3
- package/dist/collection/components/nav/nav.js +12 -45
- package/dist/collection/components/nav/view-controller.js +1 -7
- package/dist/collection/components/nav-link/nav-link.js +9 -20
- package/dist/collection/components/note/note.js +0 -6
- package/dist/collection/components/picker/picker.js +388 -397
- package/dist/collection/components/picker-column/picker-column.js +389 -409
- package/dist/collection/components/picker-column-option/picker-column-option.js +21 -30
- package/dist/collection/components/popover/popover.js +176 -283
- package/dist/collection/components/popover/test/fixture.js +0 -1
- package/dist/collection/components/progress-bar/progress-bar.js +22 -26
- package/dist/collection/components/radio/radio.js +62 -98
- package/dist/collection/components/radio-group/radio-group.js +64 -99
- package/dist/collection/components/radio-group/test/fixtures.js +0 -2
- package/dist/collection/components/range/range.js +220 -289
- package/dist/collection/components/refresher/refresher.js +69 -102
- package/dist/collection/components/refresher-content/refresher-content.js +3 -40
- package/dist/collection/components/reorder/reorder.js +0 -1
- package/dist/collection/components/reorder-group/reorder-group.js +14 -43
- package/dist/collection/components/ripple-effect/ripple-effect.js +12 -11
- package/dist/collection/components/route/route.js +9 -38
- package/dist/collection/components/route-redirect/route-redirect.js +0 -31
- package/dist/collection/components/router/router.js +27 -35
- package/dist/collection/components/router/utils/matching.js +0 -1
- package/dist/collection/components/router-link/router-link.js +10 -35
- package/dist/collection/components/router-outlet/router-outlet.js +12 -34
- package/dist/collection/components/searchbar/searchbar.js +180 -265
- package/dist/collection/components/segment/segment.js +76 -113
- package/dist/collection/components/segment-button/segment-button.js +33 -37
- package/dist/collection/components/segment-view/segment-view.js +12 -23
- package/dist/collection/components/select/select.js +127 -240
- package/dist/collection/components/select-modal/select-modal.js +11 -12
- package/dist/collection/components/select-modal/test/fixtures.js +1 -8
- package/dist/collection/components/select-option/select-option.js +7 -44
- package/dist/collection/components/select-popover/select-popover.js +10 -25
- package/dist/collection/components/select-popover/test/fixtures.js +1 -8
- package/dist/collection/components/skeleton-text/skeleton-text.js +6 -10
- package/dist/collection/components/spinner/spinner.js +6 -19
- package/dist/collection/components/split-pane/split-pane.js +13 -25
- package/dist/collection/components/tab/tab.js +4 -15
- package/dist/collection/components/tab-bar/tab-bar.js +12 -30
- package/dist/collection/components/tab-button/tab-button.js +19 -56
- package/dist/collection/components/tabs/tabs.js +17 -31
- package/dist/collection/components/text/text.js +0 -6
- package/dist/collection/components/textarea/textarea.js +135 -251
- package/dist/collection/components/title/title.js +0 -16
- package/dist/collection/components/toast/toast.js +97 -211
- package/dist/collection/components/toggle/toggle.js +111 -161
- package/dist/collection/components/toolbar/toolbar.js +3 -8
- package/dist/collection/global/config.js +3 -1
- package/dist/collection/utils/gesture/gesture-controller.js +6 -14
- package/dist/collection/utils/sanitization/index.js +0 -1
- package/dist/collection/utils/test/playwright/page/event-spy.js +8 -9
- package/dist/collection/utils/test/press-keys.js +1 -4
- package/dist/docs.json +1 -1
- package/dist/esm/{animation-CGFdmGk9.js → animation-TxGPYeDn.js} +1 -1
- package/dist/esm/{app-globals-CYmMeGdU.js → app-globals-Do8rJest.js} +1 -1
- package/dist/esm/{button-active-BDOsVAiZ.js → button-active-ChA4D-ml.js} +2 -2
- package/dist/esm/{format-Dcwga61t.js → format-CVk5e_GP.js} +2 -2
- package/dist/esm/{framework-delegate-BHTU2Ip9.js → framework-delegate-DaLWnISz.js} +1 -1
- package/dist/esm/{gesture-controller-TXPDHL13.js → gesture-controller-B_gJaBk0.js} +6 -14
- package/dist/esm/{hardware-back-button-gLJHMX_F.js → hardware-back-button-D8W4L0JP.js} +1 -1
- package/dist/esm/{helpers-CAGf8Wgp.js → helpers-BIgoInJU.js} +1 -1
- package/dist/esm/{index-DcPaH5uL.js → index-BmLuEdV7.js} +1 -1
- package/dist/esm/{index-T0JxBI8V.js → index-BmOR8tCv.js} +2 -2
- package/dist/esm/{index-CqneaaGd.js → index-C5ZdL0qp.js} +5 -5
- package/dist/esm/{index-WlteAIqz.js → index-C8Dsa6li.js} +4 -4
- package/dist/esm/{index-ChhhtsGZ.js → index-CKYcsw8f.js} +3 -1
- package/dist/esm/{index-Clc-28O1.js → index-DHw2lZxe.js} +2 -2
- package/dist/esm/{index-CKM1DdGm.js → index-elneMH8y.js} +1 -2
- package/dist/esm/index.js +14 -14
- package/dist/esm/{input-shims-B8sfni1e.js → input-shims-09NN97kF.js} +3 -3
- package/dist/esm/{input.utils-B1ValN_N.js → input.utils-BxyH9l1w.js} +1 -1
- package/dist/esm/ion-accordion_2.entry.js +335 -364
- package/dist/esm/ion-action-sheet.entry.js +60 -140
- package/dist/esm/ion-alert.entry.js +67 -159
- package/dist/esm/ion-app_8.entry.js +163 -258
- package/dist/esm/ion-avatar_3.entry.js +2 -8
- package/dist/esm/ion-back-button.entry.js +21 -45
- package/dist/esm/ion-backdrop.entry.js +14 -18
- package/dist/esm/ion-breadcrumb_2.entry.js +117 -195
- package/dist/esm/ion-button_2.entry.js +61 -130
- package/dist/esm/ion-card_5.entry.js +28 -80
- package/dist/esm/ion-checkbox.entry.js +98 -147
- package/dist/esm/ion-chip.entry.js +10 -16
- package/dist/esm/ion-col_3.entry.js +6 -126
- package/dist/esm/ion-datetime-button.entry.js +232 -248
- package/dist/esm/ion-datetime.entry.js +775 -953
- package/dist/esm/ion-fab_3.entry.js +78 -136
- package/dist/esm/ion-img.entry.js +11 -31
- package/dist/esm/ion-infinite-scroll_2.entry.js +71 -98
- package/dist/esm/ion-input-otp.entry.js +352 -424
- package/dist/esm/ion-input-password-toggle.entry.js +14 -29
- package/dist/esm/ion-input.entry.js +158 -302
- package/dist/esm/ion-item-option_3.entry.js +45 -87
- package/dist/esm/ion-item_8.entry.js +61 -157
- package/dist/esm/ion-loading.entry.js +54 -131
- package/dist/esm/ion-menu_3.entry.js +94 -158
- package/dist/esm/ion-modal.entry.js +206 -362
- package/dist/esm/ion-nav_2.entry.js +26 -78
- package/dist/esm/ion-picker-column-option.entry.js +23 -33
- package/dist/esm/ion-picker-column.entry.js +389 -410
- package/dist/esm/ion-picker.entry.js +390 -400
- package/dist/esm/ion-popover.entry.js +184 -292
- package/dist/esm/ion-progress-bar.entry.js +23 -29
- package/dist/esm/ion-radio_2.entry.js +128 -201
- package/dist/esm/ion-range.entry.js +223 -293
- package/dist/esm/ion-refresher_2.entry.js +79 -151
- package/dist/esm/ion-reorder_2.entry.js +19 -49
- package/dist/esm/ion-ripple-effect.entry.js +13 -13
- package/dist/esm/ion-route_4.entry.js +45 -144
- package/dist/esm/ion-searchbar.entry.js +182 -268
- package/dist/esm/ion-segment-content.entry.js +1 -1
- package/dist/esm/ion-segment-view.entry.js +12 -24
- package/dist/esm/ion-segment_2.entry.js +111 -154
- package/dist/esm/ion-select-modal.entry.js +19 -21
- package/dist/esm/ion-select_3.entry.js +151 -319
- package/dist/esm/ion-spinner.entry.js +6 -21
- package/dist/esm/ion-split-pane.entry.js +14 -27
- package/dist/esm/ion-tab-bar_2.entry.js +32 -89
- package/dist/esm/ion-tab_2.entry.js +22 -49
- package/dist/esm/ion-text.entry.js +2 -8
- package/dist/esm/ion-textarea.entry.js +139 -256
- package/dist/esm/ion-toast.entry.js +106 -221
- package/dist/esm/ion-toggle.entry.js +114 -165
- package/dist/esm/{ionic-global-BVB7BrLT.js → ionic-global-lrowsHfi.js} +1 -1
- package/dist/esm/ionic.js +5 -5
- package/dist/esm/{ios.transition-DXRCmcbC.js → ios.transition-BQhADrk1.js} +4 -4
- package/dist/esm/{item-multiple-inputs-rU8VaNNg.js → item-multiple-inputs-D_N3fDkD.js} +1 -1
- package/dist/esm/loader.js +5 -5
- package/dist/esm/{md.transition-BMngO4i_.js → md.transition-D58NpmRa.js} +4 -4
- package/dist/esm/{overlays-CPmIs9Ls.js → overlays-BpnIFlXI.js} +6 -6
- package/dist/esm/{select-option-render-C4m76VGH.js → select-option-render-lIuu64EV.js} +2 -2
- package/dist/esm/{slot-mutation-controller-DiE_C9un.js → slot-mutation-controller-rS_T3FDR.js} +1 -1
- package/dist/esm/{status-tap-CHB7KwIb.js → status-tap-CpFQMLl6.js} +3 -3
- package/dist/esm/{swipe-back-C9HW1bug.js → swipe-back-rmc7zeNW.js} +4 -4
- package/dist/ionic/index.esm.js +1 -1
- package/dist/ionic/ionic.esm.js +1 -1
- package/dist/ionic/p-05800a02.entry.js +4 -0
- package/dist/ionic/p-0eb50dca.entry.js +4 -0
- package/dist/ionic/p-16e9f542.entry.js +4 -0
- package/dist/ionic/p-18d532a3.entry.js +4 -0
- package/dist/ionic/p-1d694d39.entry.js +4 -0
- package/dist/ionic/p-1db2afb4.entry.js +4 -0
- package/dist/ionic/p-1df75f9e.entry.js +4 -0
- package/dist/ionic/p-295ff427.entry.js +4 -0
- package/dist/ionic/p-34b9379b.entry.js +4 -0
- package/dist/ionic/p-39a8d4e0.entry.js +4 -0
- package/dist/ionic/p-4437015c.entry.js +4 -0
- package/dist/ionic/p-478035a7.entry.js +4 -0
- package/dist/ionic/p-485fb218.entry.js +4 -0
- package/dist/ionic/p-48c859fe.entry.js +4 -0
- package/dist/ionic/p-49b9d405.entry.js +4 -0
- package/dist/ionic/p-56307aea.entry.js +4 -0
- package/dist/ionic/p-5ee2d7b1.entry.js +4 -0
- package/dist/ionic/p-5f216b79.entry.js +4 -0
- package/dist/ionic/p-61c799d1.entry.js +4 -0
- package/dist/ionic/p-63bbba8d.entry.js +4 -0
- package/dist/ionic/p-68507e70.entry.js +4 -0
- package/dist/ionic/{p-ded69ceb.entry.js → p-6f048604.entry.js} +1 -1
- package/dist/ionic/p-70ee8888.entry.js +4 -0
- package/dist/ionic/p-72ad7c64.entry.js +4 -0
- package/dist/ionic/p-75887ee0.entry.js +4 -0
- package/dist/ionic/p-873a315a.entry.js +4 -0
- package/dist/ionic/p-881b6954.entry.js +4 -0
- package/dist/ionic/p-886d9e66.entry.js +4 -0
- package/dist/ionic/p-8e007f11.entry.js +4 -0
- package/dist/ionic/p-8f464a8f.entry.js +4 -0
- package/dist/ionic/p-8f51110d.entry.js +4 -0
- package/dist/ionic/p-90ba736e.entry.js +4 -0
- package/dist/ionic/p-959df5f8.entry.js +4 -0
- package/dist/ionic/p-9e455875.entry.js +4 -0
- package/dist/ionic/{p-CBR_W98Z.js → p-9wczfs_v.js} +1 -1
- package/dist/ionic/p-B1Y7LZhV.js +4 -0
- package/dist/ionic/p-B5RyLYvl.js +4 -0
- package/dist/ionic/{p-CPcPmkGv.js → p-BQv5i5Kf.js} +1 -1
- package/{components/p-8FN7p701.js → dist/ionic/p-BZVE25Gu.js} +1 -1
- package/{components/p-DFvZn99E.js → dist/ionic/p-BZxjcGRP.js} +1 -1
- package/dist/ionic/p-B_gJaBk0.js +4 -0
- package/dist/ionic/p-BnGA34Pd.js +4 -0
- package/dist/ionic/p-ByLaqOPm.js +4 -0
- package/dist/ionic/p-C06QNN45.js +4 -0
- package/dist/ionic/p-C4IBDDj6.js +4 -0
- package/dist/ionic/p-CCVlNZ__.js +4 -0
- package/dist/ionic/{p-CMRtMbJc.js → p-CDBop-kz.js} +1 -1
- package/dist/ionic/p-CKYcsw8f.js +5 -0
- package/dist/ionic/p-CazSodad.js +4 -0
- package/{components/p-ia3IDdJS.js → dist/ionic/p-ClrlQU2y.js} +1 -1
- package/dist/ionic/{p-UIBJkZf8.js → p-D0YpjgON.js} +1 -1
- package/dist/ionic/p-D0dfUysx.js +4 -0
- package/dist/ionic/{p-BB0LlG4y.js → p-D9yvytgv.js} +1 -1
- package/{components/p-C5KYjZWD.js → dist/ionic/p-DF_Uqql8.js} +1 -1
- package/dist/ionic/{p-BYEAtHr-.js → p-DXJgZWgi.js} +1 -1
- package/dist/ionic/{p-D94_RztK.js → p-DdhHqKj-.js} +1 -1
- package/dist/ionic/p-De0eY881.js +4 -0
- package/dist/ionic/p-DgUL3JbO.js +4 -0
- package/dist/ionic/{p-7CBuOvEo.js → p-RzUn7cKs.js} +1 -1
- package/dist/ionic/p-VquyMbjp.js +4 -0
- package/dist/ionic/p-a0fee899.entry.js +4 -0
- package/dist/ionic/p-a54bcd16.entry.js +4 -0
- package/dist/ionic/p-aebc4d69.entry.js +4 -0
- package/dist/ionic/p-b5f37106.entry.js +4 -0
- package/dist/ionic/{p-40424a88.entry.js → p-b62bfce8.entry.js} +1 -1
- package/dist/ionic/p-b7a11b58.entry.js +4 -0
- package/dist/ionic/p-bbf6878c.entry.js +4 -0
- package/dist/ionic/p-c49165af.entry.js +4 -0
- package/dist/ionic/p-cad4eccf.entry.js +4 -0
- package/dist/ionic/p-cdc5115e.entry.js +4 -0
- package/dist/ionic/p-d3384a40.entry.js +4 -0
- package/dist/ionic/p-d8bae128.entry.js +4 -0
- package/dist/ionic/p-d8deff43.entry.js +4 -0
- package/dist/ionic/p-ddfb7e5f.entry.js +4 -0
- package/dist/ionic/p-e538f18d.entry.js +4 -0
- package/dist/ionic/p-f376876b.entry.js +4 -0
- package/dist/ionic/p-f521b13c.entry.js +4 -0
- package/dist/ionic/p-fbd83d4c.entry.js +4 -0
- package/hydrate/index.js +5420 -8359
- package/hydrate/index.mjs +5420 -8359
- package/package.json +1 -1
- package/components/p--m5cCjbK.js +0 -4
- package/components/p-B4uHHhPK.js +0 -4
- package/components/p-BNJOu1Q2.js +0 -4
- package/components/p-BOvLNVKq.js +0 -4
- package/components/p-BeamQXHF.js +0 -4
- package/components/p-BjluhQMI.js +0 -4
- package/components/p-BlsIikdZ.js +0 -4
- package/components/p-BrD9Xv62.js +0 -4
- package/components/p-BvJqoZ5R.js +0 -4
- package/components/p-Bz6z3Asd.js +0 -4
- package/components/p-C6HnVvHO.js +0 -4
- package/components/p-C7jvh5Wy.js +0 -4
- package/components/p-C9BGR5fy.js +0 -4
- package/components/p-CB-y1CdP.js +0 -4
- package/components/p-CHH3loEE.js +0 -4
- package/components/p-CJKUWjmg.js +0 -4
- package/components/p-CMLAwl_N.js +0 -4
- package/components/p-CejmQs3h.js +0 -4
- package/components/p-CtZqa4HM.js +0 -4
- package/components/p-D9qIVSWm.js +0 -4
- package/components/p-DE-3iMNW.js +0 -4
- package/components/p-DHFt2rdc.js +0 -4
- package/components/p-D_RCyzwu.js +0 -4
- package/components/p-D_tD8r3L.js +0 -4
- package/components/p-DjCtLZbF.js +0 -4
- package/components/p-Dmd2xqCe.js +0 -4
- package/components/p-G6JR-cr_.js +0 -4
- package/components/p-GG5GhznE.js +0 -4
- package/components/p-TXPDHL13.js +0 -4
- package/components/p-_IKFD3ID.js +0 -4
- package/components/p-dKq2jIum.js +0 -4
- package/components/p-iYhH60Tc.js +0 -4
- package/dist/ionic/p-06ec7136.entry.js +0 -4
- package/dist/ionic/p-09fe4fa3.entry.js +0 -4
- package/dist/ionic/p-10d45a07.entry.js +0 -4
- package/dist/ionic/p-208c8a07.entry.js +0 -4
- package/dist/ionic/p-212474fa.entry.js +0 -4
- package/dist/ionic/p-2eef1396.entry.js +0 -4
- package/dist/ionic/p-347e005d.entry.js +0 -4
- package/dist/ionic/p-3a0b3f1d.entry.js +0 -4
- package/dist/ionic/p-3b071259.entry.js +0 -4
- package/dist/ionic/p-4204184c.entry.js +0 -4
- package/dist/ionic/p-47464391.entry.js +0 -4
- package/dist/ionic/p-4f9c9126.entry.js +0 -4
- package/dist/ionic/p-5JsKPLJD.js +0 -4
- package/dist/ionic/p-5bc485c6.entry.js +0 -4
- package/dist/ionic/p-603a61e6.entry.js +0 -4
- package/dist/ionic/p-60576951.entry.js +0 -4
- package/dist/ionic/p-67a81d33.entry.js +0 -4
- package/dist/ionic/p-6affb775.entry.js +0 -4
- package/dist/ionic/p-6f120c25.entry.js +0 -4
- package/dist/ionic/p-71c82b60.entry.js +0 -4
- package/dist/ionic/p-79325ffe.entry.js +0 -4
- package/dist/ionic/p-7e4d51fa.entry.js +0 -4
- package/dist/ionic/p-7f5d4664.entry.js +0 -4
- package/dist/ionic/p-80ee82fc.entry.js +0 -4
- package/dist/ionic/p-84af7dbc.entry.js +0 -4
- package/dist/ionic/p-89ca830a.entry.js +0 -4
- package/dist/ionic/p-93b8ec8f.entry.js +0 -4
- package/dist/ionic/p-946f65c2.entry.js +0 -4
- package/dist/ionic/p-9c4b39fb.entry.js +0 -4
- package/dist/ionic/p-B1NEZUzQ.js +0 -4
- package/dist/ionic/p-B1ck5iy-.js +0 -4
- package/dist/ionic/p-B4FrqdW0.js +0 -4
- package/dist/ionic/p-C-94tAim.js +0 -4
- package/dist/ionic/p-C-eHZMYE.js +0 -4
- package/dist/ionic/p-CaRuIadB.js +0 -4
- package/dist/ionic/p-ChhhtsGZ.js +0 -5
- package/dist/ionic/p-CzS1qWve.js +0 -4
- package/dist/ionic/p-DjjfauRM.js +0 -4
- package/dist/ionic/p-DkUB-ROc.js +0 -4
- package/dist/ionic/p-DplOqGUv.js +0 -4
- package/dist/ionic/p-Dst_XmZh.js +0 -4
- package/dist/ionic/p-TXPDHL13.js +0 -4
- package/dist/ionic/p-a438b193.entry.js +0 -4
- package/dist/ionic/p-babaaaa7.entry.js +0 -4
- package/dist/ionic/p-be08d500.entry.js +0 -4
- package/dist/ionic/p-be9a4f51.entry.js +0 -4
- package/dist/ionic/p-c00d3092.entry.js +0 -4
- package/dist/ionic/p-c36dc8f5.entry.js +0 -4
- package/dist/ionic/p-c72a7e17.entry.js +0 -4
- package/dist/ionic/p-c8edd88c.entry.js +0 -4
- package/dist/ionic/p-ce0e380b.entry.js +0 -4
- package/dist/ionic/p-ce32912b.entry.js +0 -4
- package/dist/ionic/p-d07cf130.entry.js +0 -4
- package/dist/ionic/p-d27edeb3.entry.js +0 -4
- package/dist/ionic/p-d5d2c506.entry.js +0 -4
- package/dist/ionic/p-d5e31ca9.entry.js +0 -4
- package/dist/ionic/p-de91444f.entry.js +0 -4
- package/dist/ionic/p-df72866d.entry.js +0 -4
- package/dist/ionic/p-e47e3151.entry.js +0 -4
- package/dist/ionic/p-e621e5e8.entry.js +0 -4
- package/dist/ionic/p-eea9cf93.entry.js +0 -4
- package/dist/ionic/p-f402f5a4.entry.js +0 -4
- package/dist/ionic/p-fe1bfbcf.entry.js +0 -4
- package/dist/ionic/p-ffb90460.entry.js +0 -4
|
@@ -8,133 +8,356 @@ import { isRTL } from "../../utils/rtl/index";
|
|
|
8
8
|
import { createColorClasses } from "../../utils/theme";
|
|
9
9
|
import { getIonMode } from "../../global/ionic-global";
|
|
10
10
|
export class InputOTP {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
11
|
+
constructor() {
|
|
12
|
+
this.inheritedAttributes = {};
|
|
13
|
+
this.inputRefs = [];
|
|
14
|
+
this.inputId = `ion-input-otp-${inputIds++}`;
|
|
15
|
+
this.parsedSeparators = [];
|
|
16
|
+
/**
|
|
17
|
+
* Tracks whether the user is navigating through input boxes using keyboard navigation
|
|
18
|
+
* (arrow keys, tab) versus mouse clicks. This is used to determine the appropriate
|
|
19
|
+
* focus behavior when an input box is focused.
|
|
20
|
+
*/
|
|
21
|
+
this.isKeyboardNavigation = false;
|
|
22
|
+
this.inputValues = [];
|
|
23
|
+
this.hasFocus = false;
|
|
24
|
+
this.previousInputValues = [];
|
|
25
|
+
/**
|
|
26
|
+
* Indicates whether and how the text value should be automatically capitalized as it is entered/edited by the user.
|
|
27
|
+
* Available options: `"off"`, `"none"`, `"on"`, `"sentences"`, `"words"`, `"characters"`.
|
|
28
|
+
*/
|
|
29
|
+
this.autocapitalize = 'off';
|
|
30
|
+
/**
|
|
31
|
+
* If `true`, the user cannot interact with the input.
|
|
32
|
+
*/
|
|
33
|
+
this.disabled = false;
|
|
34
|
+
/**
|
|
35
|
+
* The fill for the input boxes. If `"solid"` the input boxes will have a background. If
|
|
36
|
+
* `"outline"` the input boxes will be transparent with a border.
|
|
37
|
+
*/
|
|
38
|
+
this.fill = 'outline';
|
|
39
|
+
/**
|
|
40
|
+
* The number of input boxes to display.
|
|
41
|
+
*/
|
|
42
|
+
this.length = 4;
|
|
43
|
+
/**
|
|
44
|
+
* If `true`, the user cannot modify the value.
|
|
45
|
+
*/
|
|
46
|
+
this.readonly = false;
|
|
47
|
+
/**
|
|
48
|
+
* The shape of the input boxes.
|
|
49
|
+
* If "round" they will have an increased border radius.
|
|
50
|
+
* If "rectangular" they will have no border radius.
|
|
51
|
+
* If "soft" they will have a soft border radius.
|
|
52
|
+
*/
|
|
53
|
+
this.shape = 'round';
|
|
54
|
+
/**
|
|
55
|
+
* The size of the input boxes.
|
|
56
|
+
*/
|
|
57
|
+
this.size = 'medium';
|
|
58
|
+
/**
|
|
59
|
+
* The type of input allowed in the input boxes.
|
|
60
|
+
*/
|
|
61
|
+
this.type = 'number';
|
|
62
|
+
/**
|
|
63
|
+
* The value of the input group.
|
|
64
|
+
*/
|
|
65
|
+
this.value = '';
|
|
66
|
+
/**
|
|
67
|
+
* Handles the focus behavior for the input OTP component.
|
|
68
|
+
*
|
|
69
|
+
* Focus behavior:
|
|
70
|
+
* 1. Keyboard navigation: Allow normal focus movement
|
|
71
|
+
* 2. Mouse click:
|
|
72
|
+
* - If clicked box has value: Focus that box
|
|
73
|
+
* - If clicked box is empty: Focus first empty box
|
|
74
|
+
*
|
|
75
|
+
* Emits the `ionFocus` event when the input group gains focus.
|
|
76
|
+
*/
|
|
77
|
+
this.onFocus = (index) => (event) => {
|
|
78
|
+
const { inputRefs } = this;
|
|
79
|
+
// Only emit ionFocus and set the focusedValue when the
|
|
80
|
+
// component first gains focus
|
|
81
|
+
if (!this.hasFocus) {
|
|
82
|
+
this.ionFocus.emit(event);
|
|
83
|
+
this.focusedValue = this.value;
|
|
84
|
+
}
|
|
85
|
+
this.hasFocus = true;
|
|
86
|
+
let finalIndex = index;
|
|
87
|
+
if (!this.isKeyboardNavigation) {
|
|
88
|
+
// If the clicked box has a value, focus it
|
|
89
|
+
// Otherwise focus the first empty box
|
|
90
|
+
const targetIndex = this.inputValues[index] ? index : this.getFirstEmptyIndex();
|
|
91
|
+
finalIndex = targetIndex === -1 ? this.length - 1 : targetIndex;
|
|
92
|
+
// Focus the target box
|
|
93
|
+
this.inputRefs[finalIndex]?.focus();
|
|
94
|
+
}
|
|
95
|
+
// Update tabIndexes to match the focused box
|
|
96
|
+
inputRefs.forEach((input, i) => {
|
|
97
|
+
input.tabIndex = i === finalIndex ? 0 : -1;
|
|
98
|
+
});
|
|
99
|
+
// Reset the keyboard navigation flag
|
|
100
|
+
this.isKeyboardNavigation = false;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Handles the blur behavior for the input OTP component.
|
|
104
|
+
* Emits the `ionBlur` event when the input group loses focus.
|
|
105
|
+
*/
|
|
106
|
+
this.onBlur = (event) => {
|
|
107
|
+
const { inputRefs } = this;
|
|
108
|
+
const relatedTarget = event.relatedTarget;
|
|
109
|
+
// Do not emit blur if we're moving to another input box in the same component
|
|
110
|
+
const isInternalFocus = relatedTarget != null && inputRefs.includes(relatedTarget);
|
|
111
|
+
if (!isInternalFocus) {
|
|
112
|
+
this.hasFocus = false;
|
|
113
|
+
// Reset tabIndexes when focus leaves the component
|
|
114
|
+
this.updateTabIndexes();
|
|
115
|
+
// Always emit ionBlur when focus leaves the component
|
|
116
|
+
this.ionBlur.emit(event);
|
|
117
|
+
// Only emit ionChange if the value has actually changed
|
|
118
|
+
if (this.focusedValue !== this.value) {
|
|
119
|
+
this.emitIonChange(event);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Handles keyboard navigation for the OTP component.
|
|
125
|
+
*
|
|
126
|
+
* Navigation:
|
|
127
|
+
* - Backspace: Clears current input and moves to previous box if empty
|
|
128
|
+
* - Arrow Left/Right: Moves focus between input boxes
|
|
129
|
+
* - Tab: Allows normal tab navigation between components
|
|
130
|
+
*/
|
|
131
|
+
this.onKeyDown = (index) => (event) => {
|
|
132
|
+
const { disabled, length, readonly } = this;
|
|
133
|
+
const rtl = isRTL(this.el);
|
|
134
|
+
const input = event.target;
|
|
135
|
+
if (disabled) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (readonly) {
|
|
139
|
+
if (event.key === 'Backspace' || event.key === 'Delete') {
|
|
140
|
+
event.preventDefault();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// Meta shortcuts are used to copy, paste, and select text
|
|
145
|
+
// We don't want to handle these keys here
|
|
146
|
+
const metaShortcuts = ['a', 'c', 'v', 'x', 'r', 'z', 'y'];
|
|
147
|
+
const isTextSelection = input.selectionStart !== input.selectionEnd;
|
|
148
|
+
// Return if the key is a meta shortcut or the input value
|
|
149
|
+
// text is selected and let the onPaste / onInput handler manage it
|
|
150
|
+
if (isTextSelection || ((event.metaKey || event.ctrlKey) && metaShortcuts.includes(event.key.toLowerCase()))) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (event.key === 'Backspace') {
|
|
154
|
+
if (this.inputValues[index]) {
|
|
155
|
+
// Shift all values to the right of the current index left by one
|
|
156
|
+
for (let i = index; i < length - 1; i++) {
|
|
157
|
+
this.inputValues[i] = this.inputValues[i + 1];
|
|
158
|
+
}
|
|
159
|
+
// Clear the last box
|
|
160
|
+
this.inputValues[length - 1] = '';
|
|
161
|
+
// Update all inputRefs to match inputValues
|
|
162
|
+
for (let i = 0; i < length; i++) {
|
|
163
|
+
this.inputRefs[i].value = this.inputValues[i] || '';
|
|
164
|
+
}
|
|
165
|
+
this.updateValue(event);
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
}
|
|
168
|
+
else if (!this.inputValues[index] && index > 0) {
|
|
169
|
+
// If current input is empty, move to previous input
|
|
170
|
+
this.focusPrevious(index);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
|
|
174
|
+
this.isKeyboardNavigation = true;
|
|
175
|
+
event.preventDefault();
|
|
176
|
+
const isLeft = event.key === 'ArrowLeft';
|
|
177
|
+
const shouldMoveNext = (isLeft && rtl) || (!isLeft && !rtl);
|
|
178
|
+
// Only allow moving to the next input if the current has a value
|
|
179
|
+
if (shouldMoveNext) {
|
|
180
|
+
if (this.inputValues[index] && index < length - 1) {
|
|
181
|
+
this.focusNext(index);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
this.focusPrevious(index);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else if (event.key === 'Tab') {
|
|
189
|
+
this.isKeyboardNavigation = true;
|
|
190
|
+
// Let all tab events proceed normally
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
/**
|
|
195
|
+
* Processes all input scenarios for each input box.
|
|
196
|
+
*
|
|
197
|
+
* This function manages:
|
|
198
|
+
* 1. Autofill handling
|
|
199
|
+
* 2. Input validation
|
|
200
|
+
* 3. Full selection replacement or typing in an empty box
|
|
201
|
+
* 4. Inserting in the middle with available space (shifting)
|
|
202
|
+
* 5. Single character replacement
|
|
203
|
+
*/
|
|
204
|
+
this.onInput = (index) => (event) => {
|
|
205
|
+
const { disabled, length, readonly, validKeyPattern } = this;
|
|
206
|
+
const input = event.target;
|
|
207
|
+
const value = input.value;
|
|
208
|
+
const previousValue = this.previousInputValues[index] || '';
|
|
209
|
+
if (disabled || readonly) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
// 1. Autofill handling
|
|
213
|
+
// If the length of the value increases by more than 1 from the previous
|
|
214
|
+
// value, treat this as autofill. This is to prevent the case where the
|
|
215
|
+
// user is typing a single character into an input box containing a value
|
|
216
|
+
// as that will trigger this function with a value length of 2 characters.
|
|
217
|
+
const isAutofill = value.length - previousValue.length > 1;
|
|
218
|
+
if (isAutofill) {
|
|
219
|
+
// Distribute valid characters across input boxes
|
|
220
|
+
const validChars = value
|
|
221
|
+
.split('')
|
|
222
|
+
.filter((char) => validKeyPattern.test(char))
|
|
223
|
+
.slice(0, length);
|
|
224
|
+
// If there are no valid characters coming from the
|
|
225
|
+
// autofill, all input refs have to be cleared after the
|
|
226
|
+
// browser has finished the autofill behavior
|
|
227
|
+
if (validChars.length === 0) {
|
|
228
|
+
requestAnimationFrame(() => {
|
|
229
|
+
this.inputRefs.forEach((input) => {
|
|
230
|
+
input.value = '';
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
for (let i = 0; i < length; i++) {
|
|
235
|
+
this.inputValues[i] = validChars[i] || '';
|
|
236
|
+
this.inputRefs[i].value = validChars[i] || '';
|
|
237
|
+
}
|
|
238
|
+
this.updateValue(event);
|
|
239
|
+
// Focus the first empty input box or the last input box if all boxes
|
|
240
|
+
// are filled after a small delay to ensure the input boxes have been
|
|
241
|
+
// updated before moving the focus
|
|
242
|
+
setTimeout(() => {
|
|
243
|
+
const nextIndex = validChars.length < length ? validChars.length : length - 1;
|
|
244
|
+
this.inputRefs[nextIndex]?.focus();
|
|
245
|
+
}, 20);
|
|
246
|
+
this.previousInputValues = [...this.inputValues];
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
// 2. Input validation
|
|
250
|
+
// If the character entered is invalid (does not match the pattern),
|
|
251
|
+
// restore the previous value and exit
|
|
252
|
+
if (value.length > 0 && !validKeyPattern.test(value[value.length - 1])) {
|
|
253
|
+
input.value = this.inputValues[index] || '';
|
|
254
|
+
this.previousInputValues = [...this.inputValues];
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
// 3. Full selection replacement or typing in an empty box
|
|
258
|
+
// If the user selects all text in the input box and types, or if the
|
|
259
|
+
// input box is empty, replace only this input box. If the box is empty,
|
|
260
|
+
// move to the next box, otherwise stay focused on this box.
|
|
261
|
+
const isAllSelected = input.selectionStart === 0 && input.selectionEnd === value.length;
|
|
262
|
+
const isEmpty = !this.inputValues[index];
|
|
263
|
+
if (isAllSelected || isEmpty) {
|
|
264
|
+
this.inputValues[index] = value;
|
|
265
|
+
input.value = value;
|
|
266
|
+
this.updateValue(event);
|
|
267
|
+
this.focusNext(index);
|
|
268
|
+
this.previousInputValues = [...this.inputValues];
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
// 4. Inserting in the middle with available space (shifting)
|
|
272
|
+
// If typing in a filled input box and there are empty boxes at the end,
|
|
273
|
+
// shift all values starting at the current box to the right, and insert
|
|
274
|
+
// the new character at the current box.
|
|
275
|
+
const hasAvailableBoxAtEnd = this.inputValues[this.inputValues.length - 1] === '';
|
|
276
|
+
if (this.inputValues[index] && hasAvailableBoxAtEnd && value.length === 2) {
|
|
277
|
+
// Get the inserted character (from event or by diffing value/previousValue)
|
|
278
|
+
let newChar = event.data;
|
|
279
|
+
if (!newChar) {
|
|
280
|
+
newChar = value.split('').find((c, i) => c !== previousValue[i]) || value[value.length - 1];
|
|
281
|
+
}
|
|
282
|
+
// Validate the new character before shifting
|
|
283
|
+
if (!validKeyPattern.test(newChar)) {
|
|
284
|
+
input.value = this.inputValues[index] || '';
|
|
285
|
+
this.previousInputValues = [...this.inputValues];
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
// Shift values right from the end to the insertion point
|
|
289
|
+
for (let i = this.inputValues.length - 1; i > index; i--) {
|
|
290
|
+
this.inputValues[i] = this.inputValues[i - 1];
|
|
291
|
+
this.inputRefs[i].value = this.inputValues[i] || '';
|
|
292
|
+
}
|
|
293
|
+
this.inputValues[index] = newChar;
|
|
294
|
+
this.inputRefs[index].value = newChar;
|
|
295
|
+
this.updateValue(event);
|
|
296
|
+
this.previousInputValues = [...this.inputValues];
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
// 5. Single character replacement
|
|
300
|
+
// Handles replacing a single character in a box containing a value based
|
|
301
|
+
// on the cursor position. We need the cursor position to determine which
|
|
302
|
+
// character was the last character typed. For example, if the user types "2"
|
|
303
|
+
// in an input box with the cursor at the beginning of the value of "6",
|
|
304
|
+
// the value will be "26", but we want to grab the "2" as the last character
|
|
305
|
+
// typed.
|
|
306
|
+
const cursorPos = input.selectionStart ?? value.length;
|
|
307
|
+
const newCharIndex = cursorPos - 1;
|
|
308
|
+
const newChar = value[newCharIndex] ?? value[0];
|
|
309
|
+
// Check if the new character is valid before updating the value
|
|
310
|
+
if (!validKeyPattern.test(newChar)) {
|
|
311
|
+
input.value = this.inputValues[index] || '';
|
|
312
|
+
this.previousInputValues = [...this.inputValues];
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
this.inputValues[index] = newChar;
|
|
316
|
+
input.value = newChar;
|
|
317
|
+
this.updateValue(event);
|
|
318
|
+
this.previousInputValues = [...this.inputValues];
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* Handles pasting text into the input OTP component.
|
|
322
|
+
* This function prevents the default paste behavior and
|
|
323
|
+
* validates the pasted text against the allowed pattern.
|
|
324
|
+
* It then updates the value of the input group and focuses
|
|
325
|
+
* the next empty input after pasting.
|
|
326
|
+
*/
|
|
327
|
+
this.onPaste = (event) => {
|
|
328
|
+
const { disabled, inputRefs, length, readonly, validKeyPattern } = this;
|
|
329
|
+
event.preventDefault();
|
|
330
|
+
if (disabled || readonly) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
const pastedText = event.clipboardData?.getData('text');
|
|
334
|
+
// If there is no pasted text, still emit the input change event
|
|
335
|
+
// because this is how the native input element behaves
|
|
336
|
+
// but return early because there is nothing to paste.
|
|
337
|
+
if (!pastedText) {
|
|
338
|
+
this.emitIonInput(event);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
const validChars = pastedText
|
|
342
|
+
.split('')
|
|
343
|
+
.filter((char) => validKeyPattern.test(char))
|
|
344
|
+
.slice(0, length);
|
|
345
|
+
// Always paste starting at the first box
|
|
346
|
+
validChars.forEach((char, index) => {
|
|
347
|
+
if (index < length) {
|
|
348
|
+
this.inputRefs[index].value = char;
|
|
349
|
+
this.inputValues[index] = char;
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
// Update the value so that all input boxes are updated
|
|
353
|
+
this.value = validChars.join('');
|
|
354
|
+
this.updateValue(event);
|
|
355
|
+
// Focus the next empty input after pasting
|
|
356
|
+
// If all boxes are filled, focus the last input
|
|
357
|
+
const nextEmptyIndex = validChars.length < length ? validChars.length : length - 1;
|
|
358
|
+
inputRefs[nextEmptyIndex]?.focus();
|
|
359
|
+
};
|
|
360
|
+
}
|
|
138
361
|
/**
|
|
139
362
|
* Sets focus to an input box.
|
|
140
363
|
* @param index - The index of the input box to focus (0-based).
|
|
@@ -308,63 +531,6 @@ export class InputOTP {
|
|
|
308
531
|
const newValue = value == null ? value : value.toString();
|
|
309
532
|
this.ionInput.emit({ value: newValue, event });
|
|
310
533
|
}
|
|
311
|
-
/**
|
|
312
|
-
* Handles the focus behavior for the input OTP component.
|
|
313
|
-
*
|
|
314
|
-
* Focus behavior:
|
|
315
|
-
* 1. Keyboard navigation: Allow normal focus movement
|
|
316
|
-
* 2. Mouse click:
|
|
317
|
-
* - If clicked box has value: Focus that box
|
|
318
|
-
* - If clicked box is empty: Focus first empty box
|
|
319
|
-
*
|
|
320
|
-
* Emits the `ionFocus` event when the input group gains focus.
|
|
321
|
-
*/
|
|
322
|
-
onFocus = (index) => (event) => {
|
|
323
|
-
const { inputRefs } = this;
|
|
324
|
-
// Only emit ionFocus and set the focusedValue when the
|
|
325
|
-
// component first gains focus
|
|
326
|
-
if (!this.hasFocus) {
|
|
327
|
-
this.ionFocus.emit(event);
|
|
328
|
-
this.focusedValue = this.value;
|
|
329
|
-
}
|
|
330
|
-
this.hasFocus = true;
|
|
331
|
-
let finalIndex = index;
|
|
332
|
-
if (!this.isKeyboardNavigation) {
|
|
333
|
-
// If the clicked box has a value, focus it
|
|
334
|
-
// Otherwise focus the first empty box
|
|
335
|
-
const targetIndex = this.inputValues[index] ? index : this.getFirstEmptyIndex();
|
|
336
|
-
finalIndex = targetIndex === -1 ? this.length - 1 : targetIndex;
|
|
337
|
-
// Focus the target box
|
|
338
|
-
this.inputRefs[finalIndex]?.focus();
|
|
339
|
-
}
|
|
340
|
-
// Update tabIndexes to match the focused box
|
|
341
|
-
inputRefs.forEach((input, i) => {
|
|
342
|
-
input.tabIndex = i === finalIndex ? 0 : -1;
|
|
343
|
-
});
|
|
344
|
-
// Reset the keyboard navigation flag
|
|
345
|
-
this.isKeyboardNavigation = false;
|
|
346
|
-
};
|
|
347
|
-
/**
|
|
348
|
-
* Handles the blur behavior for the input OTP component.
|
|
349
|
-
* Emits the `ionBlur` event when the input group loses focus.
|
|
350
|
-
*/
|
|
351
|
-
onBlur = (event) => {
|
|
352
|
-
const { inputRefs } = this;
|
|
353
|
-
const relatedTarget = event.relatedTarget;
|
|
354
|
-
// Do not emit blur if we're moving to another input box in the same component
|
|
355
|
-
const isInternalFocus = relatedTarget != null && inputRefs.includes(relatedTarget);
|
|
356
|
-
if (!isInternalFocus) {
|
|
357
|
-
this.hasFocus = false;
|
|
358
|
-
// Reset tabIndexes when focus leaves the component
|
|
359
|
-
this.updateTabIndexes();
|
|
360
|
-
// Always emit ionBlur when focus leaves the component
|
|
361
|
-
this.ionBlur.emit(event);
|
|
362
|
-
// Only emit ionChange if the value has actually changed
|
|
363
|
-
if (this.focusedValue !== this.value) {
|
|
364
|
-
this.emitIonChange(event);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
};
|
|
368
534
|
/**
|
|
369
535
|
* Focuses the next input box.
|
|
370
536
|
*/
|
|
@@ -430,243 +596,6 @@ export class InputOTP {
|
|
|
430
596
|
input.setAttribute('aria-hidden', isEmpty && !shouldBeTabbable ? 'true' : 'false');
|
|
431
597
|
});
|
|
432
598
|
}
|
|
433
|
-
/**
|
|
434
|
-
* Handles keyboard navigation for the OTP component.
|
|
435
|
-
*
|
|
436
|
-
* Navigation:
|
|
437
|
-
* - Backspace: Clears current input and moves to previous box if empty
|
|
438
|
-
* - Arrow Left/Right: Moves focus between input boxes
|
|
439
|
-
* - Tab: Allows normal tab navigation between components
|
|
440
|
-
*/
|
|
441
|
-
onKeyDown = (index) => (event) => {
|
|
442
|
-
const { disabled, length, readonly } = this;
|
|
443
|
-
const rtl = isRTL(this.el);
|
|
444
|
-
const input = event.target;
|
|
445
|
-
if (disabled) {
|
|
446
|
-
return;
|
|
447
|
-
}
|
|
448
|
-
if (readonly) {
|
|
449
|
-
if (event.key === 'Backspace' || event.key === 'Delete') {
|
|
450
|
-
event.preventDefault();
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
// Meta shortcuts are used to copy, paste, and select text
|
|
455
|
-
// We don't want to handle these keys here
|
|
456
|
-
const metaShortcuts = ['a', 'c', 'v', 'x', 'r', 'z', 'y'];
|
|
457
|
-
const isTextSelection = input.selectionStart !== input.selectionEnd;
|
|
458
|
-
// Return if the key is a meta shortcut or the input value
|
|
459
|
-
// text is selected and let the onPaste / onInput handler manage it
|
|
460
|
-
if (isTextSelection || ((event.metaKey || event.ctrlKey) && metaShortcuts.includes(event.key.toLowerCase()))) {
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
if (event.key === 'Backspace') {
|
|
464
|
-
if (this.inputValues[index]) {
|
|
465
|
-
// Shift all values to the right of the current index left by one
|
|
466
|
-
for (let i = index; i < length - 1; i++) {
|
|
467
|
-
this.inputValues[i] = this.inputValues[i + 1];
|
|
468
|
-
}
|
|
469
|
-
// Clear the last box
|
|
470
|
-
this.inputValues[length - 1] = '';
|
|
471
|
-
// Update all inputRefs to match inputValues
|
|
472
|
-
for (let i = 0; i < length; i++) {
|
|
473
|
-
this.inputRefs[i].value = this.inputValues[i] || '';
|
|
474
|
-
}
|
|
475
|
-
this.updateValue(event);
|
|
476
|
-
event.preventDefault();
|
|
477
|
-
}
|
|
478
|
-
else if (!this.inputValues[index] && index > 0) {
|
|
479
|
-
// If current input is empty, move to previous input
|
|
480
|
-
this.focusPrevious(index);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
else if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
|
|
484
|
-
this.isKeyboardNavigation = true;
|
|
485
|
-
event.preventDefault();
|
|
486
|
-
const isLeft = event.key === 'ArrowLeft';
|
|
487
|
-
const shouldMoveNext = (isLeft && rtl) || (!isLeft && !rtl);
|
|
488
|
-
// Only allow moving to the next input if the current has a value
|
|
489
|
-
if (shouldMoveNext) {
|
|
490
|
-
if (this.inputValues[index] && index < length - 1) {
|
|
491
|
-
this.focusNext(index);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
else {
|
|
495
|
-
this.focusPrevious(index);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
else if (event.key === 'Tab') {
|
|
499
|
-
this.isKeyboardNavigation = true;
|
|
500
|
-
// Let all tab events proceed normally
|
|
501
|
-
return;
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
/**
|
|
505
|
-
* Processes all input scenarios for each input box.
|
|
506
|
-
*
|
|
507
|
-
* This function manages:
|
|
508
|
-
* 1. Autofill handling
|
|
509
|
-
* 2. Input validation
|
|
510
|
-
* 3. Full selection replacement or typing in an empty box
|
|
511
|
-
* 4. Inserting in the middle with available space (shifting)
|
|
512
|
-
* 5. Single character replacement
|
|
513
|
-
*/
|
|
514
|
-
onInput = (index) => (event) => {
|
|
515
|
-
const { disabled, length, readonly, validKeyPattern } = this;
|
|
516
|
-
const input = event.target;
|
|
517
|
-
const value = input.value;
|
|
518
|
-
const previousValue = this.previousInputValues[index] || '';
|
|
519
|
-
if (disabled || readonly) {
|
|
520
|
-
return;
|
|
521
|
-
}
|
|
522
|
-
// 1. Autofill handling
|
|
523
|
-
// If the length of the value increases by more than 1 from the previous
|
|
524
|
-
// value, treat this as autofill. This is to prevent the case where the
|
|
525
|
-
// user is typing a single character into an input box containing a value
|
|
526
|
-
// as that will trigger this function with a value length of 2 characters.
|
|
527
|
-
const isAutofill = value.length - previousValue.length > 1;
|
|
528
|
-
if (isAutofill) {
|
|
529
|
-
// Distribute valid characters across input boxes
|
|
530
|
-
const validChars = value
|
|
531
|
-
.split('')
|
|
532
|
-
.filter((char) => validKeyPattern.test(char))
|
|
533
|
-
.slice(0, length);
|
|
534
|
-
// If there are no valid characters coming from the
|
|
535
|
-
// autofill, all input refs have to be cleared after the
|
|
536
|
-
// browser has finished the autofill behavior
|
|
537
|
-
if (validChars.length === 0) {
|
|
538
|
-
requestAnimationFrame(() => {
|
|
539
|
-
this.inputRefs.forEach((input) => {
|
|
540
|
-
input.value = '';
|
|
541
|
-
});
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
for (let i = 0; i < length; i++) {
|
|
545
|
-
this.inputValues[i] = validChars[i] || '';
|
|
546
|
-
this.inputRefs[i].value = validChars[i] || '';
|
|
547
|
-
}
|
|
548
|
-
this.updateValue(event);
|
|
549
|
-
// Focus the first empty input box or the last input box if all boxes
|
|
550
|
-
// are filled after a small delay to ensure the input boxes have been
|
|
551
|
-
// updated before moving the focus
|
|
552
|
-
setTimeout(() => {
|
|
553
|
-
const nextIndex = validChars.length < length ? validChars.length : length - 1;
|
|
554
|
-
this.inputRefs[nextIndex]?.focus();
|
|
555
|
-
}, 20);
|
|
556
|
-
this.previousInputValues = [...this.inputValues];
|
|
557
|
-
return;
|
|
558
|
-
}
|
|
559
|
-
// 2. Input validation
|
|
560
|
-
// If the character entered is invalid (does not match the pattern),
|
|
561
|
-
// restore the previous value and exit
|
|
562
|
-
if (value.length > 0 && !validKeyPattern.test(value[value.length - 1])) {
|
|
563
|
-
input.value = this.inputValues[index] || '';
|
|
564
|
-
this.previousInputValues = [...this.inputValues];
|
|
565
|
-
return;
|
|
566
|
-
}
|
|
567
|
-
// 3. Full selection replacement or typing in an empty box
|
|
568
|
-
// If the user selects all text in the input box and types, or if the
|
|
569
|
-
// input box is empty, replace only this input box. If the box is empty,
|
|
570
|
-
// move to the next box, otherwise stay focused on this box.
|
|
571
|
-
const isAllSelected = input.selectionStart === 0 && input.selectionEnd === value.length;
|
|
572
|
-
const isEmpty = !this.inputValues[index];
|
|
573
|
-
if (isAllSelected || isEmpty) {
|
|
574
|
-
this.inputValues[index] = value;
|
|
575
|
-
input.value = value;
|
|
576
|
-
this.updateValue(event);
|
|
577
|
-
this.focusNext(index);
|
|
578
|
-
this.previousInputValues = [...this.inputValues];
|
|
579
|
-
return;
|
|
580
|
-
}
|
|
581
|
-
// 4. Inserting in the middle with available space (shifting)
|
|
582
|
-
// If typing in a filled input box and there are empty boxes at the end,
|
|
583
|
-
// shift all values starting at the current box to the right, and insert
|
|
584
|
-
// the new character at the current box.
|
|
585
|
-
const hasAvailableBoxAtEnd = this.inputValues[this.inputValues.length - 1] === '';
|
|
586
|
-
if (this.inputValues[index] && hasAvailableBoxAtEnd && value.length === 2) {
|
|
587
|
-
// Get the inserted character (from event or by diffing value/previousValue)
|
|
588
|
-
let newChar = event.data;
|
|
589
|
-
if (!newChar) {
|
|
590
|
-
newChar = value.split('').find((c, i) => c !== previousValue[i]) || value[value.length - 1];
|
|
591
|
-
}
|
|
592
|
-
// Validate the new character before shifting
|
|
593
|
-
if (!validKeyPattern.test(newChar)) {
|
|
594
|
-
input.value = this.inputValues[index] || '';
|
|
595
|
-
this.previousInputValues = [...this.inputValues];
|
|
596
|
-
return;
|
|
597
|
-
}
|
|
598
|
-
// Shift values right from the end to the insertion point
|
|
599
|
-
for (let i = this.inputValues.length - 1; i > index; i--) {
|
|
600
|
-
this.inputValues[i] = this.inputValues[i - 1];
|
|
601
|
-
this.inputRefs[i].value = this.inputValues[i] || '';
|
|
602
|
-
}
|
|
603
|
-
this.inputValues[index] = newChar;
|
|
604
|
-
this.inputRefs[index].value = newChar;
|
|
605
|
-
this.updateValue(event);
|
|
606
|
-
this.previousInputValues = [...this.inputValues];
|
|
607
|
-
return;
|
|
608
|
-
}
|
|
609
|
-
// 5. Single character replacement
|
|
610
|
-
// Handles replacing a single character in a box containing a value based
|
|
611
|
-
// on the cursor position. We need the cursor position to determine which
|
|
612
|
-
// character was the last character typed. For example, if the user types "2"
|
|
613
|
-
// in an input box with the cursor at the beginning of the value of "6",
|
|
614
|
-
// the value will be "26", but we want to grab the "2" as the last character
|
|
615
|
-
// typed.
|
|
616
|
-
const cursorPos = input.selectionStart ?? value.length;
|
|
617
|
-
const newCharIndex = cursorPos - 1;
|
|
618
|
-
const newChar = value[newCharIndex] ?? value[0];
|
|
619
|
-
// Check if the new character is valid before updating the value
|
|
620
|
-
if (!validKeyPattern.test(newChar)) {
|
|
621
|
-
input.value = this.inputValues[index] || '';
|
|
622
|
-
this.previousInputValues = [...this.inputValues];
|
|
623
|
-
return;
|
|
624
|
-
}
|
|
625
|
-
this.inputValues[index] = newChar;
|
|
626
|
-
input.value = newChar;
|
|
627
|
-
this.updateValue(event);
|
|
628
|
-
this.previousInputValues = [...this.inputValues];
|
|
629
|
-
};
|
|
630
|
-
/**
|
|
631
|
-
* Handles pasting text into the input OTP component.
|
|
632
|
-
* This function prevents the default paste behavior and
|
|
633
|
-
* validates the pasted text against the allowed pattern.
|
|
634
|
-
* It then updates the value of the input group and focuses
|
|
635
|
-
* the next empty input after pasting.
|
|
636
|
-
*/
|
|
637
|
-
onPaste = (event) => {
|
|
638
|
-
const { disabled, inputRefs, length, readonly, validKeyPattern } = this;
|
|
639
|
-
event.preventDefault();
|
|
640
|
-
if (disabled || readonly) {
|
|
641
|
-
return;
|
|
642
|
-
}
|
|
643
|
-
const pastedText = event.clipboardData?.getData('text');
|
|
644
|
-
// If there is no pasted text, still emit the input change event
|
|
645
|
-
// because this is how the native input element behaves
|
|
646
|
-
// but return early because there is nothing to paste.
|
|
647
|
-
if (!pastedText) {
|
|
648
|
-
this.emitIonInput(event);
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
651
|
-
const validChars = pastedText
|
|
652
|
-
.split('')
|
|
653
|
-
.filter((char) => validKeyPattern.test(char))
|
|
654
|
-
.slice(0, length);
|
|
655
|
-
// Always paste starting at the first box
|
|
656
|
-
validChars.forEach((char, index) => {
|
|
657
|
-
if (index < length) {
|
|
658
|
-
this.inputRefs[index].value = char;
|
|
659
|
-
this.inputValues[index] = char;
|
|
660
|
-
}
|
|
661
|
-
});
|
|
662
|
-
// Update the value so that all input boxes are updated
|
|
663
|
-
this.value = validChars.join('');
|
|
664
|
-
this.updateValue(event);
|
|
665
|
-
// Focus the next empty input after pasting
|
|
666
|
-
// If all boxes are filled, focus the last input
|
|
667
|
-
const nextEmptyIndex = validChars.length < length ? validChars.length : length - 1;
|
|
668
|
-
inputRefs[nextEmptyIndex]?.focus();
|
|
669
|
-
};
|
|
670
599
|
/**
|
|
671
600
|
* Determines if a separator should be shown for a given index by
|
|
672
601
|
* checking if the index is included in the parsed separators array.
|