@tabler/core 1.0.0-beta20 → 1.0.0-beta21
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/README.md +7 -6
- package/dist/css/demo.css +8 -8
- package/dist/css/demo.min.css +5 -5
- package/dist/css/demo.rtl.css +8 -8
- package/dist/css/demo.rtl.min.css +5 -5
- package/dist/css/tabler-flags.css +10 -10
- package/dist/css/tabler-flags.min.css +5 -5
- package/dist/css/tabler-flags.rtl.css +10 -10
- package/dist/css/tabler-flags.rtl.min.css +5 -5
- package/dist/css/tabler-payments.css +4 -4
- package/dist/css/tabler-payments.min.css +4 -4
- package/dist/css/tabler-payments.rtl.css +4 -4
- package/dist/css/tabler-payments.rtl.min.css +4 -4
- package/dist/css/tabler-social.css +4 -4
- package/dist/css/tabler-social.min.css +4 -4
- package/dist/css/tabler-social.rtl.css +4 -4
- package/dist/css/tabler-social.rtl.min.css +4 -4
- package/dist/css/tabler-vendors.css +246 -253
- package/dist/css/tabler-vendors.min.css +5 -5
- package/dist/css/tabler-vendors.rtl.css +246 -253
- package/dist/css/tabler-vendors.rtl.min.css +5 -5
- package/dist/css/tabler.css +643 -426
- package/dist/css/tabler.min.css +8 -8
- package/dist/css/tabler.rtl.css +667 -441
- package/dist/css/tabler.rtl.min.css +8 -8
- package/dist/js/demo-theme.js +4 -4
- package/dist/js/demo-theme.min.js +4 -4
- package/dist/js/demo.js +41 -42
- package/dist/js/demo.min.js +5 -5
- package/dist/js/tabler.esm.js +1949 -1248
- package/dist/js/tabler.esm.min.js +8 -8
- package/dist/js/tabler.js +1949 -1248
- package/dist/js/tabler.min.js +8 -8
- package/dist/libs/apexcharts/dist/apexcharts.amd.js +1 -1
- package/dist/libs/apexcharts/dist/apexcharts.common.js +5 -5
- package/dist/libs/apexcharts/dist/apexcharts.css +166 -65
- package/dist/libs/apexcharts/dist/apexcharts.esm.js +5 -5
- package/dist/libs/apexcharts/dist/apexcharts.js +7964 -8527
- package/dist/libs/apexcharts/dist/apexcharts.min.js +5 -5
- package/dist/libs/apexcharts/dist/locales/be-cyrl.json +55 -0
- package/dist/libs/apexcharts/dist/locales/be-latn.json +55 -0
- package/dist/libs/apexcharts/dist/locales/da.json +55 -0
- package/dist/libs/apexcharts/dist/locales/ms.json +63 -0
- package/dist/libs/apexcharts/dist/locales/pt.json +3 -3
- package/dist/libs/apexcharts/dist/locales/vi.json +63 -0
- package/dist/libs/apexcharts/dist/locales/zh-tw.json +1 -1
- package/dist/libs/bootstrap/dist/js/bootstrap.bundle.js +8 -8
- package/dist/libs/bootstrap/dist/js/bootstrap.bundle.js.map +1 -1
- package/dist/libs/bootstrap/dist/js/bootstrap.bundle.min.js +3 -3
- package/dist/libs/bootstrap/dist/js/bootstrap.bundle.min.js.map +1 -1
- package/dist/libs/bootstrap/dist/js/bootstrap.esm.js +8 -8
- package/dist/libs/bootstrap/dist/js/bootstrap.esm.js.map +1 -1
- package/dist/libs/bootstrap/dist/js/bootstrap.esm.min.js +3 -3
- package/dist/libs/bootstrap/dist/js/bootstrap.esm.min.js.map +1 -1
- package/dist/libs/bootstrap/dist/js/bootstrap.js +8 -8
- package/dist/libs/bootstrap/dist/js/bootstrap.js.map +1 -1
- package/dist/libs/bootstrap/dist/js/bootstrap.min.js +3 -3
- package/dist/libs/bootstrap/dist/js/bootstrap.min.js.map +1 -1
- package/dist/libs/countup.js/dist/countUp.d.ts +1 -0
- package/dist/libs/countup.js/dist/countUp.js +4 -1
- package/dist/libs/countup.js/dist/countUp.min.js +1 -1
- package/dist/libs/countup.js/dist/countUp.umd.js +1 -1
- package/dist/libs/jsvectormap/dist/jsvectormap.cjs +2279 -0
- package/dist/libs/jsvectormap/dist/jsvectormap.css +121 -0
- package/dist/libs/jsvectormap/dist/jsvectormap.esm.js +2277 -0
- package/dist/libs/jsvectormap/dist/jsvectormap.js +2285 -0
- package/dist/libs/jsvectormap/dist/jsvectormap.min.css +1 -0
- package/dist/libs/jsvectormap/dist/jsvectormap.min.js +1 -0
- package/dist/libs/jsvectormap/dist/maps/world-merc.js +1 -1
- package/dist/libs/jsvectormap/dist/maps/world.js +1 -1
- package/dist/libs/nouislider/dist/nouislider.d.ts +8 -10
- package/dist/libs/nouislider/dist/nouislider.js +64 -5
- package/dist/libs/nouislider/dist/nouislider.min.js +1 -1
- package/dist/libs/nouislider/dist/nouislider.min.mjs +1 -1
- package/dist/libs/nouislider/dist/nouislider.mjs +64 -5
- package/dist/libs/star-rating.js/dist/star-rating.cjs.js +5 -2
- package/dist/libs/star-rating.js/dist/star-rating.css +23 -20
- package/dist/libs/star-rating.js/dist/star-rating.esm.js +5 -2
- package/dist/libs/star-rating.js/dist/star-rating.js +5 -9
- package/dist/libs/star-rating.js/dist/star-rating.min.css +1 -8
- package/dist/libs/star-rating.js/dist/star-rating.min.js +1 -8
- package/dist/libs/tinymce/CHANGELOG.md +471 -12
- package/dist/libs/tinymce/README.md +16 -10
- package/dist/libs/tinymce/bower.json +1 -1
- package/dist/libs/tinymce/composer.json +2 -2
- package/dist/libs/tinymce/icons/default/icons.js +13 -2
- package/dist/libs/tinymce/icons/default/icons.min.js +1 -1
- package/dist/libs/tinymce/license.md +6 -0
- package/dist/libs/tinymce/models/dom/model.js +237 -213
- package/dist/libs/tinymce/models/dom/model.min.js +2 -2
- package/dist/libs/tinymce/package.json +2 -2
- package/dist/libs/tinymce/plugins/accordion/index.js +7 -0
- package/dist/libs/tinymce/plugins/accordion/plugin.js +1055 -0
- package/dist/libs/tinymce/plugins/accordion/plugin.min.js +4 -0
- package/dist/libs/tinymce/plugins/advlist/plugin.js +4 -4
- package/dist/libs/tinymce/plugins/advlist/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/anchor/plugin.js +21 -3
- package/dist/libs/tinymce/plugins/anchor/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/autolink/plugin.js +1 -1
- package/dist/libs/tinymce/plugins/autolink/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/autoresize/plugin.js +20 -33
- package/dist/libs/tinymce/plugins/autoresize/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/autosave/plugin.js +1 -1
- package/dist/libs/tinymce/plugins/autosave/plugin.min.js +1 -1
- package/dist/libs/tinymce/plugins/charmap/plugin.js +15 -3
- package/dist/libs/tinymce/plugins/charmap/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/code/plugin.js +1 -1
- package/dist/libs/tinymce/plugins/code/plugin.min.js +1 -1
- package/dist/libs/tinymce/plugins/codesample/plugin.js +27 -13
- package/dist/libs/tinymce/plugins/codesample/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/directionality/plugin.js +33 -27
- package/dist/libs/tinymce/plugins/directionality/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/emoticons/plugin.js +17 -4
- package/dist/libs/tinymce/plugins/emoticons/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/fullscreen/plugin.js +168 -105
- package/dist/libs/tinymce/plugins/fullscreen/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/ar.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/bg_BG.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/ca.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/cs.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/da.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/de.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/el.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/en.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/es.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/eu.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/fa.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/fi.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/fr_FR.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/he_IL.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/hi.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/hr.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/hu_HU.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/id.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/it.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/ja.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/kk.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/ko_KR.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/ms.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/nb_NO.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/nl.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/pl.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/pt_BR.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/pt_PT.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/ro.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/ru.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/sk.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/sl_SI.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/sv_SE.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/th_TH.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/tr.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/uk.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/vi.js +93 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/zh_CN.js +87 -0
- package/dist/libs/tinymce/plugins/help/js/i18n/keynav/zh_TW.js +93 -0
- package/dist/libs/tinymce/plugins/help/plugin.js +115 -135
- package/dist/libs/tinymce/plugins/help/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/image/plugin.js +23 -5
- package/dist/libs/tinymce/plugins/image/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/importcss/plugin.js +4 -3
- package/dist/libs/tinymce/plugins/importcss/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/insertdatetime/plugin.js +15 -3
- package/dist/libs/tinymce/plugins/insertdatetime/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/link/plugin.js +193 -114
- package/dist/libs/tinymce/plugins/link/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/lists/plugin.js +290 -66
- package/dist/libs/tinymce/plugins/lists/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/media/plugin.js +80 -33
- package/dist/libs/tinymce/plugins/media/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/nonbreaking/plugin.js +15 -3
- package/dist/libs/tinymce/plugins/nonbreaking/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/pagebreak/plugin.js +15 -3
- package/dist/libs/tinymce/plugins/pagebreak/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/preview/plugin.js +1 -1
- package/dist/libs/tinymce/plugins/preview/plugin.min.js +1 -1
- package/dist/libs/tinymce/plugins/quickbars/plugin.js +19 -7
- package/dist/libs/tinymce/plugins/quickbars/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/save/plugin.js +3 -2
- package/dist/libs/tinymce/plugins/save/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/searchreplace/plugin.js +42 -36
- package/dist/libs/tinymce/plugins/searchreplace/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/table/plugin.js +121 -76
- package/dist/libs/tinymce/plugins/table/plugin.min.js +2 -2
- package/dist/libs/tinymce/plugins/visualblocks/plugin.js +1 -1
- package/dist/libs/tinymce/plugins/visualblocks/plugin.min.js +1 -1
- package/dist/libs/tinymce/plugins/visualchars/plugin.js +1 -1
- package/dist/libs/tinymce/plugins/visualchars/plugin.min.js +1 -1
- package/dist/libs/tinymce/plugins/wordcount/plugin.js +27 -19
- package/dist/libs/tinymce/plugins/wordcount/plugin.min.js +2 -2
- package/dist/libs/tinymce/skins/content/dark/content.js +1 -0
- package/dist/libs/tinymce/skins/content/default/content.js +1 -0
- package/dist/libs/tinymce/skins/content/document/content.js +1 -0
- package/dist/libs/tinymce/skins/content/tinymce-5/content.js +1 -0
- package/dist/libs/tinymce/skins/content/tinymce-5-dark/content.js +1 -0
- package/dist/libs/tinymce/skins/content/writer/content.js +1 -0
- package/dist/libs/tinymce/skins/ui/oxide/content.css +32 -29
- package/dist/libs/tinymce/skins/ui/oxide/content.inline.css +32 -29
- package/dist/libs/tinymce/skins/ui/oxide/content.inline.js +1 -0
- package/dist/libs/tinymce/skins/ui/oxide/content.inline.min.css +1 -1
- package/dist/libs/tinymce/skins/ui/oxide/content.js +1 -0
- package/dist/libs/tinymce/skins/ui/oxide/content.min.css +1 -1
- package/dist/libs/tinymce/skins/ui/oxide/skin.css +1003 -105
- package/dist/libs/tinymce/skins/ui/oxide/skin.js +1 -0
- package/dist/libs/tinymce/skins/ui/oxide/skin.min.css +1 -1
- package/dist/libs/tinymce/skins/ui/oxide/skin.shadowdom.js +1 -0
- package/dist/libs/tinymce/skins/ui/oxide-dark/content.css +32 -22
- package/dist/libs/tinymce/skins/ui/oxide-dark/content.inline.css +32 -29
- package/dist/libs/tinymce/skins/ui/oxide-dark/content.inline.js +1 -0
- package/dist/libs/tinymce/skins/ui/oxide-dark/content.inline.min.css +1 -1
- package/dist/libs/tinymce/skins/ui/oxide-dark/content.js +1 -0
- package/dist/libs/tinymce/skins/ui/oxide-dark/content.min.css +1 -1
- package/dist/libs/tinymce/skins/ui/oxide-dark/skin.css +1008 -110
- package/dist/libs/tinymce/skins/ui/oxide-dark/skin.js +1 -0
- package/dist/libs/tinymce/skins/ui/oxide-dark/skin.min.css +1 -1
- package/dist/libs/tinymce/skins/ui/oxide-dark/skin.shadowdom.js +1 -0
- package/dist/libs/tinymce/skins/ui/tinymce-5/content.css +32 -29
- package/dist/libs/tinymce/skins/ui/tinymce-5/content.inline.css +32 -29
- package/dist/libs/tinymce/skins/ui/tinymce-5/content.inline.js +1 -0
- package/dist/libs/tinymce/skins/ui/tinymce-5/content.inline.min.css +1 -1
- package/dist/libs/tinymce/skins/ui/tinymce-5/content.js +1 -0
- package/dist/libs/tinymce/skins/ui/tinymce-5/content.min.css +1 -1
- package/dist/libs/tinymce/skins/ui/tinymce-5/skin.css +1003 -86
- package/dist/libs/tinymce/skins/ui/tinymce-5/skin.js +1 -0
- package/dist/libs/tinymce/skins/ui/tinymce-5/skin.min.css +1 -1
- package/dist/libs/tinymce/skins/ui/tinymce-5/skin.shadowdom.js +1 -0
- package/dist/libs/tinymce/skins/ui/tinymce-5-dark/content.css +32 -22
- package/dist/libs/tinymce/skins/ui/tinymce-5-dark/content.inline.css +32 -29
- package/dist/libs/tinymce/skins/ui/tinymce-5-dark/content.inline.js +1 -0
- package/dist/libs/tinymce/skins/ui/tinymce-5-dark/content.inline.min.css +1 -1
- package/dist/libs/tinymce/skins/ui/tinymce-5-dark/content.js +1 -0
- package/dist/libs/tinymce/skins/ui/tinymce-5-dark/content.min.css +1 -1
- package/dist/libs/tinymce/skins/ui/tinymce-5-dark/skin.css +1009 -92
- package/dist/libs/tinymce/skins/ui/tinymce-5-dark/skin.js +1 -0
- package/dist/libs/tinymce/skins/ui/tinymce-5-dark/skin.min.css +1 -1
- package/dist/libs/tinymce/skins/ui/tinymce-5-dark/skin.shadowdom.js +1 -0
- package/dist/libs/tinymce/themes/silver/theme.js +26361 -24936
- package/dist/libs/tinymce/themes/silver/theme.min.js +2 -2
- package/dist/libs/tinymce/tinymce.d.ts +205 -136
- package/dist/libs/tinymce/tinymce.js +4400 -2838
- package/dist/libs/tinymce/tinymce.min.js +2 -2
- package/dist/libs/tom-select/dist/js/plugins/caret_position.js +11 -16
- package/dist/libs/tom-select/dist/js/plugins/caret_position.js.map +1 -1
- package/dist/libs/tom-select/dist/js/plugins/change_listener.js +3 -2
- package/dist/libs/tom-select/dist/js/plugins/change_listener.js.map +1 -1
- package/dist/libs/tom-select/dist/js/plugins/checkbox_options.js +47 -34
- package/dist/libs/tom-select/dist/js/plugins/checkbox_options.js.map +1 -1
- package/dist/libs/tom-select/dist/js/plugins/clear_button.js +3 -13
- package/dist/libs/tom-select/dist/js/plugins/clear_button.js.map +1 -1
- package/dist/libs/tom-select/dist/js/plugins/drag_drop.js +249 -29
- package/dist/libs/tom-select/dist/js/plugins/drag_drop.js.map +1 -1
- package/dist/libs/tom-select/dist/js/plugins/dropdown_header.js +3 -11
- package/dist/libs/tom-select/dist/js/plugins/dropdown_header.js.map +1 -1
- package/dist/libs/tom-select/dist/js/plugins/dropdown_input.js +15 -24
- package/dist/libs/tom-select/dist/js/plugins/dropdown_input.js.map +1 -1
- package/dist/libs/tom-select/dist/js/plugins/input_autogrow.js +4 -6
- package/dist/libs/tom-select/dist/js/plugins/input_autogrow.js.map +1 -1
- package/dist/libs/tom-select/dist/js/plugins/no_active_items.js +2 -1
- package/dist/libs/tom-select/dist/js/plugins/no_active_items.js.map +1 -1
- package/dist/libs/tom-select/dist/js/plugins/no_backspace_delete.js +2 -2
- package/dist/libs/tom-select/dist/js/plugins/no_backspace_delete.js.map +1 -1
- package/dist/libs/tom-select/dist/js/plugins/optgroup_columns.js +3 -15
- package/dist/libs/tom-select/dist/js/plugins/optgroup_columns.js.map +1 -1
- package/dist/libs/tom-select/dist/js/plugins/remove_button.js +11 -15
- package/dist/libs/tom-select/dist/js/plugins/remove_button.js.map +1 -1
- package/dist/libs/tom-select/dist/js/plugins/restore_on_backspace.js +2 -3
- package/dist/libs/tom-select/dist/js/plugins/restore_on_backspace.js.map +1 -1
- package/dist/libs/tom-select/dist/js/plugins/virtual_scroll.js +41 -50
- package/dist/libs/tom-select/dist/js/plugins/virtual_scroll.js.map +1 -1
- package/dist/libs/tom-select/dist/js/tom-select.base.js +411 -685
- package/dist/libs/tom-select/dist/js/tom-select.base.js.map +1 -1
- package/dist/libs/tom-select/dist/js/tom-select.base.min.js +87 -78
- package/dist/libs/tom-select/dist/js/tom-select.base.min.js.map +1 -1
- package/dist/libs/tom-select/dist/js/tom-select.complete.js +614 -820
- package/dist/libs/tom-select/dist/js/tom-select.complete.js.map +1 -1
- package/dist/libs/tom-select/dist/js/tom-select.complete.min.js +195 -176
- package/dist/libs/tom-select/dist/js/tom-select.complete.min.js.map +1 -1
- package/dist/libs/tom-select/dist/js/tom-select.popular.js +436 -705
- package/dist/libs/tom-select/dist/js/tom-select.popular.js.map +1 -1
- package/dist/libs/tom-select/dist/js/tom-select.popular.min.js +87 -78
- package/dist/libs/tom-select/dist/js/tom-select.popular.min.js.map +1 -1
- package/docs/base/colors.mdx +25 -0
- package/docs/base/typography.mdx +296 -0
- package/docs/components/alerts.mdx +430 -0
- package/docs/components/autosize.mdx +16 -0
- package/docs/components/avatars.mdx +172 -0
- package/docs/components/badges.mdx +127 -0
- package/docs/components/breadcrumb.mdx +107 -0
- package/docs/components/buttons.mdx +863 -0
- package/docs/components/cards.mdx +343 -0
- package/docs/components/carousel.mdx +235 -0
- package/docs/components/charts.mdx +526 -0
- package/docs/components/countup.mdx +136 -0
- package/docs/components/datagrid.mdx +90 -0
- package/docs/components/divider.mdx +63 -0
- package/docs/components/dropdowns.mdx +245 -0
- package/docs/components/dropzone.mdx +63 -0
- package/docs/components/empty.mdx +103 -0
- package/docs/components/icons.mdx +120 -0
- package/docs/components/inline-player.mdx +31 -0
- package/docs/components/modals.mdx +222 -0
- package/docs/components/placeholder.mdx +270 -0
- package/docs/components/popover.mdx +55 -0
- package/docs/components/progress.mdx +92 -0
- package/docs/components/progressbg.mdx +16 -0
- package/docs/components/range-slider.mdx +17 -0
- package/docs/components/ribbons.mdx +151 -0
- package/docs/components/spinners.mdx +119 -0
- package/docs/components/statuses.mdx +285 -0
- package/docs/components/steps.mdx +111 -0
- package/docs/components/switch-icon.mdx +155 -0
- package/docs/components/tables.mdx +410 -0
- package/docs/components/tabs.mdx +243 -0
- package/docs/components/timelines.mdx +506 -0
- package/docs/components/tinymce.mdx +44 -0
- package/docs/components/toasts.mdx +73 -0
- package/docs/components/tooltips.mdx +34 -0
- package/docs/components/tracking.mdx +162 -0
- package/docs/forms/form-color-check.mdx +179 -0
- package/docs/forms/form-elements.mdx +498 -0
- package/docs/forms/form-fieldset.mdx +44 -0
- package/docs/forms/form-helpers.mdx +12 -0
- package/docs/forms/form-image-check.mdx +162 -0
- package/docs/forms/form-input-mask.mdx +18 -0
- package/docs/forms/form-selectboxes.mdx +205 -0
- package/docs/forms/form-validation.mdx +25 -0
- package/docs/getting-started/browser-support.mdx +20 -0
- package/docs/getting-started/customize.mdx +24 -0
- package/docs/getting-started/download.mdx +42 -0
- package/docs/getting-started/faq.mdx +28 -0
- package/docs/getting-started/index.mdx +40 -0
- package/docs/icons/eps.mdx +13 -0
- package/docs/icons/figma.mdx +7 -0
- package/docs/icons/index.mdx +103 -0
- package/docs/icons/pdf.mdx +13 -0
- package/docs/icons/png.mdx +19 -0
- package/docs/icons/preact.mdx +40 -0
- package/docs/icons/react.mdx +40 -0
- package/docs/icons/solidjs.mdx +39 -0
- package/docs/icons/svelte.mdx +40 -0
- package/docs/icons/svg.mdx +74 -0
- package/docs/icons/vue.mdx +45 -0
- package/docs/icons/webfont.mdx +52 -0
- package/docs/layout/page-headers.mdx +226 -0
- package/docs/layout/page-layouts.mdx +204 -0
- package/docs/menu.json +317 -0
- package/docs/plugins/flags.mdx +52 -0
- package/docs/plugins/payments.mdx +43 -0
- package/docs/utilities/borders.mdx +114 -0
- package/docs/utilities/cursors.mdx +92 -0
- package/docs/utilities/interactions.mdx +23 -0
- package/package.json +37 -37
- package/src/js/src/toast.js +9 -1
- package/src/scss/_variables-dark.scss +3 -3
- package/src/scss/_variables.scss +38 -33
- package/src/scss/layout/_dark.scss +10 -2
- package/src/scss/layout/_navbar.scss +22 -13
- package/src/scss/layout/_page.scss +4 -4
- package/src/scss/layout/_root.scss +1 -1
- package/src/scss/mixins/_mixins.scss +4 -4
- package/src/scss/ui/_alerts.scss +2 -2
- package/src/scss/ui/_buttons.scss +4 -4
- package/src/scss/ui/_dropdowns.scss +1 -0
- package/src/scss/ui/_empty.scss +0 -5
- package/src/scss/ui/_flags.scss +2 -2
- package/src/scss/ui/_forms.scss +5 -4
- package/src/scss/ui/_modals.scss +3 -3
- package/src/scss/ui/_ribbons.scss +1 -0
- package/src/scss/ui/_toasts.scss +0 -1
- package/src/scss/ui/_type.scss +4 -2
- package/src/scss/vendor/_apexcharts.scss +2 -2
- package/src/scss/vendor/_jsvectormap.scss +1 -1
- package/src/scss/vendor/_litepicker.scss +1 -1
- package/dist/libs/jsvectormap/dist/js/jsvectormap.js +0 -2318
- package/dist/libs/jsvectormap/dist/js/jsvectormap.min.js +0 -1
- package/dist/libs/tinymce/license.txt +0 -21
- package/dist/libs/tinymce/plugins/template/index.js +0 -7
- package/dist/libs/tinymce/plugins/template/plugin.js +0 -554
- package/dist/libs/tinymce/plugins/template/plugin.min.js +0 -4
package/dist/js/tabler.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Tabler v1.0.0-
|
|
3
|
-
* @version 1.0.0-
|
|
2
|
+
* Tabler v1.0.0-beta21 (https://tabler.io)
|
|
3
|
+
* @version 1.0.0-beta21
|
|
4
4
|
* @link https://tabler.io
|
|
5
|
-
* Copyright 2018-
|
|
6
|
-
* Copyright 2018-
|
|
5
|
+
* Copyright 2018-2024 The Tabler Authors
|
|
6
|
+
* Copyright 2018-2024 codecalm.net Paweł Kuna
|
|
7
7
|
* Licensed under MIT (https://github.com/tabler/tabler/blob/master/LICENSE)
|
|
8
8
|
*/
|
|
9
9
|
var e=new Map;function t(t){var o=e.get(t);o&&o.destroy();}function o(t){var o=e.get(t);o&&o.update();}var r=null;"undefined"==typeof window?((r=function(e){return e}).destroy=function(e){return e},r.update=function(e){return e}):((r=function(t,o){return t&&Array.prototype.forEach.call(t.length?t:[t],function(t){return function(t){if(t&&t.nodeName&&"TEXTAREA"===t.nodeName&&!e.has(t)){var o,r=null,n=window.getComputedStyle(t),i=(o=t.value,function(){a({testForHeightReduction:""===o||!t.value.startsWith(o),restoreTextAlign:null}),o=t.value;}),l=function(o){t.removeEventListener("autosize:destroy",l),t.removeEventListener("autosize:update",s),t.removeEventListener("input",i),window.removeEventListener("resize",s),Object.keys(o).forEach(function(e){return t.style[e]=o[e]}),e.delete(t);}.bind(t,{height:t.style.height,resize:t.style.resize,textAlign:t.style.textAlign,overflowY:t.style.overflowY,overflowX:t.style.overflowX,wordWrap:t.style.wordWrap});t.addEventListener("autosize:destroy",l),t.addEventListener("autosize:update",s),t.addEventListener("input",i),window.addEventListener("resize",s),t.style.overflowX="hidden",t.style.wordWrap="break-word",e.set(t,{destroy:l,update:s}),s();}function a(e){var o,i,l=e.restoreTextAlign,s=void 0===l?null:l,d=e.testForHeightReduction,u=void 0===d||d,c=n.overflowY;if(0!==t.scrollHeight&&("vertical"===n.resize?t.style.resize="none":"both"===n.resize&&(t.style.resize="horizontal"),u&&(o=function(e){for(var t=[];e&&e.parentNode&&e.parentNode instanceof Element;)e.parentNode.scrollTop&&t.push([e.parentNode,e.parentNode.scrollTop]),e=e.parentNode;return function(){return t.forEach(function(e){var t=e[0],o=e[1];t.style.scrollBehavior="auto",t.scrollTop=o,t.style.scrollBehavior=null;})}}(t),t.style.height=""),i="content-box"===n.boxSizing?t.scrollHeight-(parseFloat(n.paddingTop)+parseFloat(n.paddingBottom)):t.scrollHeight+parseFloat(n.borderTopWidth)+parseFloat(n.borderBottomWidth),"none"!==n.maxHeight&&i>parseFloat(n.maxHeight)?("hidden"===n.overflowY&&(t.style.overflow="scroll"),i=parseFloat(n.maxHeight)):"hidden"!==n.overflowY&&(t.style.overflow="hidden"),t.style.height=i+"px",s&&(t.style.textAlign=s),o&&o(),r!==i&&(t.dispatchEvent(new Event("autosize:resized",{bubbles:!0})),r=i),c!==n.overflow&&!s)){var v=n.textAlign;"hidden"===n.overflow&&(t.style.textAlign="start"===v?"end":"start"),a({restoreTextAlign:v,testForHeightReduction:!0});}}function s(){a({testForHeightReduction:!0,restoreTextAlign:null});}}(t)}),t}).destroy=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],t),e},r.update=function(e){return e&&Array.prototype.forEach.call(e.length?e:[e],o),e});var n=r;
|
|
@@ -15,49 +15,21 @@ if (elements.length) {
|
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
19
|
-
if (source == null) return {};
|
|
20
|
-
var target = {};
|
|
21
|
-
var sourceKeys = Object.keys(source);
|
|
22
|
-
var key, i;
|
|
23
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
24
|
-
key = sourceKeys[i];
|
|
25
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
26
|
-
target[key] = source[key];
|
|
27
|
-
}
|
|
28
|
-
return target;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function IMask(el) {
|
|
32
|
-
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
33
|
-
return new IMask.InputMask(el, opts);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
class ChangeDetails {
|
|
37
|
-
constructor(details) {
|
|
38
|
-
Object.assign(this, {
|
|
39
|
-
inserted: '',
|
|
40
|
-
rawInserted: '',
|
|
41
|
-
skip: false,
|
|
42
|
-
tailShift: 0
|
|
43
|
-
}, details);
|
|
44
|
-
}
|
|
45
|
-
aggregate(details) {
|
|
46
|
-
this.rawInserted += details.rawInserted;
|
|
47
|
-
this.skip = this.skip || details.skip;
|
|
48
|
-
this.inserted += details.inserted;
|
|
49
|
-
this.tailShift += details.tailShift;
|
|
50
|
-
return this;
|
|
51
|
-
}
|
|
52
|
-
get offset() {
|
|
53
|
-
return this.tailShift + this.inserted.length;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
IMask.ChangeDetails = ChangeDetails;
|
|
57
|
-
|
|
58
18
|
function isString(str) {
|
|
59
19
|
return typeof str === 'string' || str instanceof String;
|
|
60
20
|
}
|
|
21
|
+
function isObject(obj) {
|
|
22
|
+
var _obj$constructor;
|
|
23
|
+
return typeof obj === 'object' && obj != null && (obj == null || (_obj$constructor = obj.constructor) == null ? void 0 : _obj$constructor.name) === 'Object';
|
|
24
|
+
}
|
|
25
|
+
function pick(obj, keys) {
|
|
26
|
+
if (Array.isArray(keys)) return pick(obj, (_, k) => keys.includes(k));
|
|
27
|
+
return Object.entries(obj).reduce((acc, _ref) => {
|
|
28
|
+
let [k, v] = _ref;
|
|
29
|
+
if (keys(v, k)) acc[k] = v;
|
|
30
|
+
return acc;
|
|
31
|
+
}, {});
|
|
32
|
+
}
|
|
61
33
|
const DIRECTION = {
|
|
62
34
|
NONE: 'NONE',
|
|
63
35
|
LEFT: 'LEFT',
|
|
@@ -76,16 +48,13 @@ function forceDirection(direction) {
|
|
|
76
48
|
}
|
|
77
49
|
}
|
|
78
50
|
function escapeRegExp(str) {
|
|
79
|
-
return str.replace(/([.*+?^=!:${}()|[\]
|
|
80
|
-
}
|
|
81
|
-
function normalizePrepare(prep) {
|
|
82
|
-
return Array.isArray(prep) ? prep : [prep, new ChangeDetails()];
|
|
51
|
+
return str.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1');
|
|
83
52
|
}
|
|
84
53
|
function objectIncludes(b, a) {
|
|
85
54
|
if (a === b) return true;
|
|
86
|
-
|
|
87
|
-
arrB = Array.isArray(b)
|
|
88
|
-
|
|
55
|
+
const arrA = Array.isArray(a),
|
|
56
|
+
arrB = Array.isArray(b);
|
|
57
|
+
let i;
|
|
89
58
|
if (arrA && arrB) {
|
|
90
59
|
if (a.length != b.length) return false;
|
|
91
60
|
for (i = 0; i < a.length; i++) if (!objectIncludes(a[i], b[i])) return false;
|
|
@@ -93,17 +62,16 @@ function objectIncludes(b, a) {
|
|
|
93
62
|
}
|
|
94
63
|
if (arrA != arrB) return false;
|
|
95
64
|
if (a && b && typeof a === 'object' && typeof b === 'object') {
|
|
96
|
-
|
|
65
|
+
const dateA = a instanceof Date,
|
|
97
66
|
dateB = b instanceof Date;
|
|
98
67
|
if (dateA && dateB) return a.getTime() == b.getTime();
|
|
99
68
|
if (dateA != dateB) return false;
|
|
100
|
-
|
|
69
|
+
const regexpA = a instanceof RegExp,
|
|
101
70
|
regexpB = b instanceof RegExp;
|
|
102
71
|
if (regexpA && regexpB) return a.toString() == b.toString();
|
|
103
72
|
if (regexpA != regexpB) return false;
|
|
104
|
-
|
|
105
|
-
for (i = 0; i < keys.length; i++)
|
|
106
|
-
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
73
|
+
const keys = Object.keys(a);
|
|
74
|
+
for (i = 0; i < keys.length; i++) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
107
75
|
for (i = 0; i < keys.length; i++) if (!objectIncludes(b[keys[i]], a[keys[i]])) return false;
|
|
108
76
|
return true;
|
|
109
77
|
} else if (a && b && typeof a === 'function' && typeof b === 'function') {
|
|
@@ -113,14 +81,16 @@ function objectIncludes(b, a) {
|
|
|
113
81
|
}
|
|
114
82
|
|
|
115
83
|
class ActionDetails {
|
|
116
|
-
constructor(
|
|
117
|
-
this
|
|
118
|
-
this.cursorPos = cursorPos;
|
|
119
|
-
this.oldValue = oldValue;
|
|
120
|
-
this.oldSelection = oldSelection;
|
|
84
|
+
constructor(opts) {
|
|
85
|
+
Object.assign(this, opts);
|
|
121
86
|
while (this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos)) {
|
|
122
87
|
--this.oldSelection.start;
|
|
123
88
|
}
|
|
89
|
+
if (this.insertedCount) {
|
|
90
|
+
while (this.value.slice(this.cursorPos) !== this.oldValue.slice(this.oldSelection.end)) {
|
|
91
|
+
if (this.value.length - this.cursorPos < this.oldValue.length - this.oldSelection.end) ++this.oldSelection.end;else ++this.cursorPos;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
124
94
|
}
|
|
125
95
|
get startChangePos() {
|
|
126
96
|
return Math.min(this.cursorPos, this.oldSelection.start);
|
|
@@ -151,146 +121,718 @@ class ActionDetails {
|
|
|
151
121
|
}
|
|
152
122
|
}
|
|
153
123
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
124
|
+
function IMask(el, opts) {
|
|
125
|
+
return new IMask.InputMask(el, opts);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function maskedClass(mask) {
|
|
129
|
+
if (mask == null) throw new Error('mask property should be defined');
|
|
130
|
+
if (mask instanceof RegExp) return IMask.MaskedRegExp;
|
|
131
|
+
if (isString(mask)) return IMask.MaskedPattern;
|
|
132
|
+
if (mask === Date) return IMask.MaskedDate;
|
|
133
|
+
if (mask === Number) return IMask.MaskedNumber;
|
|
134
|
+
if (Array.isArray(mask) || mask === Array) return IMask.MaskedDynamic;
|
|
135
|
+
if (IMask.Masked && mask.prototype instanceof IMask.Masked) return mask;
|
|
136
|
+
if (IMask.Masked && mask instanceof IMask.Masked) return mask.constructor;
|
|
137
|
+
if (mask instanceof Function) return IMask.MaskedFunction;
|
|
138
|
+
console.warn('Mask not found for mask', mask);
|
|
139
|
+
return IMask.Masked;
|
|
140
|
+
}
|
|
141
|
+
function normalizeOpts(opts) {
|
|
142
|
+
if (!opts) throw new Error('Options in not defined');
|
|
143
|
+
if (IMask.Masked) {
|
|
144
|
+
if (opts.prototype instanceof IMask.Masked) return {
|
|
145
|
+
mask: opts
|
|
146
|
+
};
|
|
147
|
+
const {
|
|
148
|
+
mask = undefined,
|
|
149
|
+
...instanceOpts
|
|
150
|
+
} = opts instanceof IMask.Masked ? {
|
|
151
|
+
mask: opts
|
|
152
|
+
} : isObject(opts) && opts.mask instanceof IMask.Masked ? opts : {};
|
|
153
|
+
if (mask) {
|
|
154
|
+
const _mask = mask.mask;
|
|
155
|
+
return {
|
|
156
|
+
...pick(mask, (_, k) => !k.startsWith('_')),
|
|
157
|
+
mask: mask.constructor,
|
|
158
|
+
_mask,
|
|
159
|
+
...instanceOpts
|
|
160
|
+
};
|
|
161
|
+
}
|
|
168
162
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
163
|
+
if (!isObject(opts)) return {
|
|
164
|
+
mask: opts
|
|
165
|
+
};
|
|
166
|
+
return {
|
|
167
|
+
...opts
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function createMask(opts) {
|
|
171
|
+
if (IMask.Masked && opts instanceof IMask.Masked) return opts;
|
|
172
|
+
const nOpts = normalizeOpts(opts);
|
|
173
|
+
const MaskedClass = maskedClass(nOpts.mask);
|
|
174
|
+
if (!MaskedClass) throw new Error("Masked class is not found for provided mask " + nOpts.mask + ", appropriate module needs to be imported manually before creating mask.");
|
|
175
|
+
if (nOpts.mask === MaskedClass) delete nOpts.mask;
|
|
176
|
+
if (nOpts._mask) {
|
|
177
|
+
nOpts.mask = nOpts._mask;
|
|
178
|
+
delete nOpts._mask;
|
|
173
179
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
return new MaskedClass(nOpts);
|
|
181
|
+
}
|
|
182
|
+
IMask.createMask = createMask;
|
|
183
|
+
|
|
184
|
+
class MaskElement {
|
|
185
|
+
get selectionStart() {
|
|
186
|
+
let start;
|
|
187
|
+
try {
|
|
188
|
+
start = this._unsafeSelectionStart;
|
|
189
|
+
} catch {}
|
|
190
|
+
return start != null ? start : this.value.length;
|
|
180
191
|
}
|
|
181
|
-
|
|
182
|
-
|
|
192
|
+
get selectionEnd() {
|
|
193
|
+
let end;
|
|
194
|
+
try {
|
|
195
|
+
end = this._unsafeSelectionEnd;
|
|
196
|
+
} catch {}
|
|
197
|
+
return end != null ? end : this.value.length;
|
|
183
198
|
}
|
|
184
|
-
|
|
185
|
-
if (
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
199
|
+
select(start, end) {
|
|
200
|
+
if (start == null || end == null || start === this.selectionStart && end === this.selectionEnd) return;
|
|
201
|
+
try {
|
|
202
|
+
this._unsafeSelect(start, end);
|
|
203
|
+
} catch {}
|
|
189
204
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const shiftChar = this.value[this.value.length - 1];
|
|
193
|
-
this.value = this.value.slice(0, -1);
|
|
194
|
-
return shiftChar;
|
|
205
|
+
get isActive() {
|
|
206
|
+
return false;
|
|
195
207
|
}
|
|
196
208
|
}
|
|
209
|
+
IMask.MaskElement = MaskElement;
|
|
197
210
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
211
|
+
const KEY_Z = 90;
|
|
212
|
+
const KEY_Y = 89;
|
|
213
|
+
class HTMLMaskElement extends MaskElement {
|
|
214
|
+
constructor(input) {
|
|
215
|
+
super();
|
|
216
|
+
this.input = input;
|
|
217
|
+
this._onKeydown = this._onKeydown.bind(this);
|
|
218
|
+
this._onInput = this._onInput.bind(this);
|
|
219
|
+
this._onBeforeinput = this._onBeforeinput.bind(this);
|
|
220
|
+
this._onCompositionEnd = this._onCompositionEnd.bind(this);
|
|
203
221
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
222
|
+
get rootElement() {
|
|
223
|
+
var _this$input$getRootNo, _this$input$getRootNo2, _this$input;
|
|
224
|
+
return (_this$input$getRootNo = (_this$input$getRootNo2 = (_this$input = this.input).getRootNode) == null ? void 0 : _this$input$getRootNo2.call(_this$input)) != null ? _this$input$getRootNo : document;
|
|
207
225
|
}
|
|
208
|
-
|
|
209
|
-
|
|
226
|
+
get isActive() {
|
|
227
|
+
return this.input === this.rootElement.activeElement;
|
|
210
228
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
229
|
+
bindEvents(handlers) {
|
|
230
|
+
this.input.addEventListener('keydown', this._onKeydown);
|
|
231
|
+
this.input.addEventListener('input', this._onInput);
|
|
232
|
+
this.input.addEventListener('beforeinput', this._onBeforeinput);
|
|
233
|
+
this.input.addEventListener('compositionend', this._onCompositionEnd);
|
|
234
|
+
this.input.addEventListener('drop', handlers.drop);
|
|
235
|
+
this.input.addEventListener('click', handlers.click);
|
|
236
|
+
this.input.addEventListener('focus', handlers.focus);
|
|
237
|
+
this.input.addEventListener('blur', handlers.commit);
|
|
238
|
+
this._handlers = handlers;
|
|
215
239
|
}
|
|
216
|
-
|
|
217
|
-
this.
|
|
240
|
+
_onKeydown(e) {
|
|
241
|
+
if (this._handlers.redo && (e.keyCode === KEY_Z && e.shiftKey && (e.metaKey || e.ctrlKey) || e.keyCode === KEY_Y && e.ctrlKey)) {
|
|
242
|
+
e.preventDefault();
|
|
243
|
+
return this._handlers.redo(e);
|
|
244
|
+
}
|
|
245
|
+
if (this._handlers.undo && e.keyCode === KEY_Z && (e.metaKey || e.ctrlKey)) {
|
|
246
|
+
e.preventDefault();
|
|
247
|
+
return this._handlers.undo(e);
|
|
248
|
+
}
|
|
249
|
+
if (!e.isComposing) this._handlers.selectionChange(e);
|
|
218
250
|
}
|
|
219
|
-
|
|
220
|
-
|
|
251
|
+
_onBeforeinput(e) {
|
|
252
|
+
if (e.inputType === 'historyUndo' && this._handlers.undo) {
|
|
253
|
+
e.preventDefault();
|
|
254
|
+
return this._handlers.undo(e);
|
|
255
|
+
}
|
|
256
|
+
if (e.inputType === 'historyRedo' && this._handlers.redo) {
|
|
257
|
+
e.preventDefault();
|
|
258
|
+
return this._handlers.redo(e);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
_onCompositionEnd(e) {
|
|
262
|
+
this._handlers.input(e);
|
|
263
|
+
}
|
|
264
|
+
_onInput(e) {
|
|
265
|
+
if (!e.isComposing) this._handlers.input(e);
|
|
266
|
+
}
|
|
267
|
+
unbindEvents() {
|
|
268
|
+
this.input.removeEventListener('keydown', this._onKeydown);
|
|
269
|
+
this.input.removeEventListener('input', this._onInput);
|
|
270
|
+
this.input.removeEventListener('beforeinput', this._onBeforeinput);
|
|
271
|
+
this.input.removeEventListener('compositionend', this._onCompositionEnd);
|
|
272
|
+
this.input.removeEventListener('drop', this._handlers.drop);
|
|
273
|
+
this.input.removeEventListener('click', this._handlers.click);
|
|
274
|
+
this.input.removeEventListener('focus', this._handlers.focus);
|
|
275
|
+
this.input.removeEventListener('blur', this._handlers.commit);
|
|
276
|
+
this._handlers = {};
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
IMask.HTMLMaskElement = HTMLMaskElement;
|
|
280
|
+
|
|
281
|
+
class HTMLInputMaskElement extends HTMLMaskElement {
|
|
282
|
+
constructor(input) {
|
|
283
|
+
super(input);
|
|
284
|
+
this.input = input;
|
|
285
|
+
}
|
|
286
|
+
get _unsafeSelectionStart() {
|
|
287
|
+
return this.input.selectionStart != null ? this.input.selectionStart : this.value.length;
|
|
288
|
+
}
|
|
289
|
+
get _unsafeSelectionEnd() {
|
|
290
|
+
return this.input.selectionEnd;
|
|
291
|
+
}
|
|
292
|
+
_unsafeSelect(start, end) {
|
|
293
|
+
this.input.setSelectionRange(start, end);
|
|
221
294
|
}
|
|
222
295
|
get value() {
|
|
223
|
-
return this.
|
|
296
|
+
return this.input.value;
|
|
224
297
|
}
|
|
225
298
|
set value(value) {
|
|
226
|
-
this.
|
|
299
|
+
this.input.value = value;
|
|
227
300
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
this.
|
|
234
|
-
|
|
301
|
+
}
|
|
302
|
+
IMask.HTMLMaskElement = HTMLMaskElement;
|
|
303
|
+
|
|
304
|
+
class HTMLContenteditableMaskElement extends HTMLMaskElement {
|
|
305
|
+
get _unsafeSelectionStart() {
|
|
306
|
+
const root = this.rootElement;
|
|
307
|
+
const selection = root.getSelection && root.getSelection();
|
|
308
|
+
const anchorOffset = selection && selection.anchorOffset;
|
|
309
|
+
const focusOffset = selection && selection.focusOffset;
|
|
310
|
+
if (focusOffset == null || anchorOffset == null || anchorOffset < focusOffset) {
|
|
311
|
+
return anchorOffset;
|
|
312
|
+
}
|
|
313
|
+
return focusOffset;
|
|
235
314
|
}
|
|
236
|
-
get
|
|
237
|
-
|
|
315
|
+
get _unsafeSelectionEnd() {
|
|
316
|
+
const root = this.rootElement;
|
|
317
|
+
const selection = root.getSelection && root.getSelection();
|
|
318
|
+
const anchorOffset = selection && selection.anchorOffset;
|
|
319
|
+
const focusOffset = selection && selection.focusOffset;
|
|
320
|
+
if (focusOffset == null || anchorOffset == null || anchorOffset > focusOffset) {
|
|
321
|
+
return anchorOffset;
|
|
322
|
+
}
|
|
323
|
+
return focusOffset;
|
|
238
324
|
}
|
|
239
|
-
|
|
240
|
-
this.
|
|
241
|
-
this.
|
|
242
|
-
this.
|
|
325
|
+
_unsafeSelect(start, end) {
|
|
326
|
+
if (!this.rootElement.createRange) return;
|
|
327
|
+
const range = this.rootElement.createRange();
|
|
328
|
+
range.setStart(this.input.firstChild || this.input, start);
|
|
329
|
+
range.setEnd(this.input.lastChild || this.input, end);
|
|
330
|
+
const root = this.rootElement;
|
|
331
|
+
const selection = root.getSelection && root.getSelection();
|
|
332
|
+
if (selection) {
|
|
333
|
+
selection.removeAllRanges();
|
|
334
|
+
selection.addRange(range);
|
|
335
|
+
}
|
|
243
336
|
}
|
|
244
|
-
get
|
|
245
|
-
return this.
|
|
337
|
+
get value() {
|
|
338
|
+
return this.input.textContent || '';
|
|
246
339
|
}
|
|
247
|
-
set
|
|
248
|
-
this.
|
|
340
|
+
set value(value) {
|
|
341
|
+
this.input.textContent = value;
|
|
249
342
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
343
|
+
}
|
|
344
|
+
IMask.HTMLContenteditableMaskElement = HTMLContenteditableMaskElement;
|
|
345
|
+
|
|
346
|
+
class InputHistory {
|
|
347
|
+
constructor() {
|
|
348
|
+
this.states = [];
|
|
349
|
+
this.currentIndex = 0;
|
|
254
350
|
}
|
|
255
|
-
|
|
256
|
-
this.
|
|
257
|
-
this.append(value, {
|
|
258
|
-
raw: true
|
|
259
|
-
}, '');
|
|
260
|
-
this.doCommit();
|
|
351
|
+
get currentState() {
|
|
352
|
+
return this.states[this.currentIndex];
|
|
261
353
|
}
|
|
262
|
-
get
|
|
263
|
-
return this.
|
|
354
|
+
get isEmpty() {
|
|
355
|
+
return this.states.length === 0;
|
|
264
356
|
}
|
|
265
|
-
|
|
266
|
-
|
|
357
|
+
push(state) {
|
|
358
|
+
if (this.currentIndex < this.states.length - 1) this.states.length = this.currentIndex + 1;
|
|
359
|
+
this.states.push(state);
|
|
360
|
+
if (this.states.length > InputHistory.MAX_LENGTH) this.states.shift();
|
|
361
|
+
this.currentIndex = this.states.length - 1;
|
|
267
362
|
}
|
|
268
|
-
|
|
269
|
-
|
|
363
|
+
go(steps) {
|
|
364
|
+
this.currentIndex = Math.min(Math.max(this.currentIndex + steps, 0), this.states.length - 1);
|
|
365
|
+
return this.currentState;
|
|
270
366
|
}
|
|
271
|
-
|
|
272
|
-
return
|
|
367
|
+
undo() {
|
|
368
|
+
return this.go(-1);
|
|
273
369
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
|
|
277
|
-
return Math.min(this.value.length, toPos - fromPos);
|
|
370
|
+
redo() {
|
|
371
|
+
return this.go(+1);
|
|
278
372
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return this.value.slice(fromPos, toPos);
|
|
373
|
+
clear() {
|
|
374
|
+
this.states.length = 0;
|
|
375
|
+
this.currentIndex = 0;
|
|
283
376
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
377
|
+
}
|
|
378
|
+
InputHistory.MAX_LENGTH = 100;
|
|
379
|
+
|
|
380
|
+
class InputMask {
|
|
381
|
+
constructor(el, opts) {
|
|
382
|
+
this.el = el instanceof MaskElement ? el : el.isContentEditable && el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA' ? new HTMLContenteditableMaskElement(el) : new HTMLInputMaskElement(el);
|
|
383
|
+
this.masked = createMask(opts);
|
|
384
|
+
this._listeners = {};
|
|
385
|
+
this._value = '';
|
|
386
|
+
this._unmaskedValue = '';
|
|
387
|
+
this._rawInputValue = '';
|
|
388
|
+
this.history = new InputHistory();
|
|
389
|
+
this._saveSelection = this._saveSelection.bind(this);
|
|
390
|
+
this._onInput = this._onInput.bind(this);
|
|
391
|
+
this._onChange = this._onChange.bind(this);
|
|
392
|
+
this._onDrop = this._onDrop.bind(this);
|
|
393
|
+
this._onFocus = this._onFocus.bind(this);
|
|
394
|
+
this._onClick = this._onClick.bind(this);
|
|
395
|
+
this._onUndo = this._onUndo.bind(this);
|
|
396
|
+
this._onRedo = this._onRedo.bind(this);
|
|
397
|
+
this.alignCursor = this.alignCursor.bind(this);
|
|
398
|
+
this.alignCursorFriendly = this.alignCursorFriendly.bind(this);
|
|
399
|
+
this._bindEvents();
|
|
400
|
+
this.updateValue();
|
|
401
|
+
this._onChange();
|
|
288
402
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return
|
|
403
|
+
maskEquals(mask) {
|
|
404
|
+
var _this$masked;
|
|
405
|
+
return mask == null || ((_this$masked = this.masked) == null ? void 0 : _this$masked.maskEquals(mask));
|
|
292
406
|
}
|
|
293
|
-
|
|
407
|
+
get mask() {
|
|
408
|
+
return this.masked.mask;
|
|
409
|
+
}
|
|
410
|
+
set mask(mask) {
|
|
411
|
+
if (this.maskEquals(mask)) return;
|
|
412
|
+
if (!(mask instanceof IMask.Masked) && this.masked.constructor === maskedClass(mask)) {
|
|
413
|
+
this.masked.updateOptions({
|
|
414
|
+
mask
|
|
415
|
+
});
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
const masked = mask instanceof IMask.Masked ? mask : createMask({
|
|
419
|
+
mask
|
|
420
|
+
});
|
|
421
|
+
masked.unmaskedValue = this.masked.unmaskedValue;
|
|
422
|
+
this.masked = masked;
|
|
423
|
+
}
|
|
424
|
+
get value() {
|
|
425
|
+
return this._value;
|
|
426
|
+
}
|
|
427
|
+
set value(str) {
|
|
428
|
+
if (this.value === str) return;
|
|
429
|
+
this.masked.value = str;
|
|
430
|
+
this.updateControl('auto');
|
|
431
|
+
}
|
|
432
|
+
get unmaskedValue() {
|
|
433
|
+
return this._unmaskedValue;
|
|
434
|
+
}
|
|
435
|
+
set unmaskedValue(str) {
|
|
436
|
+
if (this.unmaskedValue === str) return;
|
|
437
|
+
this.masked.unmaskedValue = str;
|
|
438
|
+
this.updateControl('auto');
|
|
439
|
+
}
|
|
440
|
+
get rawInputValue() {
|
|
441
|
+
return this._rawInputValue;
|
|
442
|
+
}
|
|
443
|
+
set rawInputValue(str) {
|
|
444
|
+
if (this.rawInputValue === str) return;
|
|
445
|
+
this.masked.rawInputValue = str;
|
|
446
|
+
this.updateControl();
|
|
447
|
+
this.alignCursor();
|
|
448
|
+
}
|
|
449
|
+
get typedValue() {
|
|
450
|
+
return this.masked.typedValue;
|
|
451
|
+
}
|
|
452
|
+
set typedValue(val) {
|
|
453
|
+
if (this.masked.typedValueEquals(val)) return;
|
|
454
|
+
this.masked.typedValue = val;
|
|
455
|
+
this.updateControl('auto');
|
|
456
|
+
}
|
|
457
|
+
get displayValue() {
|
|
458
|
+
return this.masked.displayValue;
|
|
459
|
+
}
|
|
460
|
+
_bindEvents() {
|
|
461
|
+
this.el.bindEvents({
|
|
462
|
+
selectionChange: this._saveSelection,
|
|
463
|
+
input: this._onInput,
|
|
464
|
+
drop: this._onDrop,
|
|
465
|
+
click: this._onClick,
|
|
466
|
+
focus: this._onFocus,
|
|
467
|
+
commit: this._onChange,
|
|
468
|
+
undo: this._onUndo,
|
|
469
|
+
redo: this._onRedo
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
_unbindEvents() {
|
|
473
|
+
if (this.el) this.el.unbindEvents();
|
|
474
|
+
}
|
|
475
|
+
_fireEvent(ev, e) {
|
|
476
|
+
const listeners = this._listeners[ev];
|
|
477
|
+
if (!listeners) return;
|
|
478
|
+
listeners.forEach(l => l(e));
|
|
479
|
+
}
|
|
480
|
+
get selectionStart() {
|
|
481
|
+
return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
|
|
482
|
+
}
|
|
483
|
+
get cursorPos() {
|
|
484
|
+
return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
|
|
485
|
+
}
|
|
486
|
+
set cursorPos(pos) {
|
|
487
|
+
if (!this.el || !this.el.isActive) return;
|
|
488
|
+
this.el.select(pos, pos);
|
|
489
|
+
this._saveSelection();
|
|
490
|
+
}
|
|
491
|
+
_saveSelection(
|
|
492
|
+
) {
|
|
493
|
+
if (this.displayValue !== this.el.value) {
|
|
494
|
+
console.warn('Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.');
|
|
495
|
+
}
|
|
496
|
+
this._selection = {
|
|
497
|
+
start: this.selectionStart,
|
|
498
|
+
end: this.cursorPos
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
updateValue() {
|
|
502
|
+
this.masked.value = this.el.value;
|
|
503
|
+
this._value = this.masked.value;
|
|
504
|
+
this._unmaskedValue = this.masked.unmaskedValue;
|
|
505
|
+
this._rawInputValue = this.masked.rawInputValue;
|
|
506
|
+
}
|
|
507
|
+
updateControl(cursorPos) {
|
|
508
|
+
const newUnmaskedValue = this.masked.unmaskedValue;
|
|
509
|
+
const newValue = this.masked.value;
|
|
510
|
+
const newRawInputValue = this.masked.rawInputValue;
|
|
511
|
+
const newDisplayValue = this.displayValue;
|
|
512
|
+
const isChanged = this.unmaskedValue !== newUnmaskedValue || this.value !== newValue || this._rawInputValue !== newRawInputValue;
|
|
513
|
+
this._unmaskedValue = newUnmaskedValue;
|
|
514
|
+
this._value = newValue;
|
|
515
|
+
this._rawInputValue = newRawInputValue;
|
|
516
|
+
if (this.el.value !== newDisplayValue) this.el.value = newDisplayValue;
|
|
517
|
+
if (cursorPos === 'auto') this.alignCursor();else if (cursorPos != null) this.cursorPos = cursorPos;
|
|
518
|
+
if (isChanged) this._fireChangeEvents();
|
|
519
|
+
if (!this._historyChanging && (isChanged || this.history.isEmpty)) this.history.push({
|
|
520
|
+
unmaskedValue: newUnmaskedValue,
|
|
521
|
+
selection: {
|
|
522
|
+
start: this.selectionStart,
|
|
523
|
+
end: this.cursorPos
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
updateOptions(opts) {
|
|
528
|
+
const {
|
|
529
|
+
mask,
|
|
530
|
+
...restOpts
|
|
531
|
+
} = opts;
|
|
532
|
+
const updateMask = !this.maskEquals(mask);
|
|
533
|
+
const updateOpts = this.masked.optionsIsChanged(restOpts);
|
|
534
|
+
if (updateMask) this.mask = mask;
|
|
535
|
+
if (updateOpts) this.masked.updateOptions(restOpts);
|
|
536
|
+
if (updateMask || updateOpts) this.updateControl();
|
|
537
|
+
}
|
|
538
|
+
updateCursor(cursorPos) {
|
|
539
|
+
if (cursorPos == null) return;
|
|
540
|
+
this.cursorPos = cursorPos;
|
|
541
|
+
this._delayUpdateCursor(cursorPos);
|
|
542
|
+
}
|
|
543
|
+
_delayUpdateCursor(cursorPos) {
|
|
544
|
+
this._abortUpdateCursor();
|
|
545
|
+
this._changingCursorPos = cursorPos;
|
|
546
|
+
this._cursorChanging = setTimeout(() => {
|
|
547
|
+
if (!this.el) return;
|
|
548
|
+
this.cursorPos = this._changingCursorPos;
|
|
549
|
+
this._abortUpdateCursor();
|
|
550
|
+
}, 10);
|
|
551
|
+
}
|
|
552
|
+
_fireChangeEvents() {
|
|
553
|
+
this._fireEvent('accept', this._inputEvent);
|
|
554
|
+
if (this.masked.isComplete) this._fireEvent('complete', this._inputEvent);
|
|
555
|
+
}
|
|
556
|
+
_abortUpdateCursor() {
|
|
557
|
+
if (this._cursorChanging) {
|
|
558
|
+
clearTimeout(this._cursorChanging);
|
|
559
|
+
delete this._cursorChanging;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
alignCursor() {
|
|
563
|
+
this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, DIRECTION.LEFT));
|
|
564
|
+
}
|
|
565
|
+
alignCursorFriendly() {
|
|
566
|
+
if (this.selectionStart !== this.cursorPos) return;
|
|
567
|
+
this.alignCursor();
|
|
568
|
+
}
|
|
569
|
+
on(ev, handler) {
|
|
570
|
+
if (!this._listeners[ev]) this._listeners[ev] = [];
|
|
571
|
+
this._listeners[ev].push(handler);
|
|
572
|
+
return this;
|
|
573
|
+
}
|
|
574
|
+
off(ev, handler) {
|
|
575
|
+
if (!this._listeners[ev]) return this;
|
|
576
|
+
if (!handler) {
|
|
577
|
+
delete this._listeners[ev];
|
|
578
|
+
return this;
|
|
579
|
+
}
|
|
580
|
+
const hIndex = this._listeners[ev].indexOf(handler);
|
|
581
|
+
if (hIndex >= 0) this._listeners[ev].splice(hIndex, 1);
|
|
582
|
+
return this;
|
|
583
|
+
}
|
|
584
|
+
_onInput(e) {
|
|
585
|
+
this._inputEvent = e;
|
|
586
|
+
this._abortUpdateCursor();
|
|
587
|
+
const details = new ActionDetails({
|
|
588
|
+
value: this.el.value,
|
|
589
|
+
cursorPos: this.cursorPos,
|
|
590
|
+
oldValue: this.displayValue,
|
|
591
|
+
oldSelection: this._selection
|
|
592
|
+
});
|
|
593
|
+
const oldRawValue = this.masked.rawInputValue;
|
|
594
|
+
const offset = this.masked.splice(details.startChangePos, details.removed.length, details.inserted, details.removeDirection, {
|
|
595
|
+
input: true,
|
|
596
|
+
raw: true
|
|
597
|
+
}).offset;
|
|
598
|
+
const removeDirection = oldRawValue === this.masked.rawInputValue ? details.removeDirection : DIRECTION.NONE;
|
|
599
|
+
let cursorPos = this.masked.nearestInputPos(details.startChangePos + offset, removeDirection);
|
|
600
|
+
if (removeDirection !== DIRECTION.NONE) cursorPos = this.masked.nearestInputPos(cursorPos, DIRECTION.NONE);
|
|
601
|
+
this.updateControl(cursorPos);
|
|
602
|
+
delete this._inputEvent;
|
|
603
|
+
}
|
|
604
|
+
_onChange() {
|
|
605
|
+
if (this.displayValue !== this.el.value) this.updateValue();
|
|
606
|
+
this.masked.doCommit();
|
|
607
|
+
this.updateControl();
|
|
608
|
+
this._saveSelection();
|
|
609
|
+
}
|
|
610
|
+
_onDrop(ev) {
|
|
611
|
+
ev.preventDefault();
|
|
612
|
+
ev.stopPropagation();
|
|
613
|
+
}
|
|
614
|
+
_onFocus(ev) {
|
|
615
|
+
this.alignCursorFriendly();
|
|
616
|
+
}
|
|
617
|
+
_onClick(ev) {
|
|
618
|
+
this.alignCursorFriendly();
|
|
619
|
+
}
|
|
620
|
+
_onUndo() {
|
|
621
|
+
this._applyHistoryState(this.history.undo());
|
|
622
|
+
}
|
|
623
|
+
_onRedo() {
|
|
624
|
+
this._applyHistoryState(this.history.redo());
|
|
625
|
+
}
|
|
626
|
+
_applyHistoryState(state) {
|
|
627
|
+
if (!state) return;
|
|
628
|
+
this._historyChanging = true;
|
|
629
|
+
this.unmaskedValue = state.unmaskedValue;
|
|
630
|
+
this.el.select(state.selection.start, state.selection.end);
|
|
631
|
+
this._saveSelection();
|
|
632
|
+
this._historyChanging = false;
|
|
633
|
+
}
|
|
634
|
+
destroy() {
|
|
635
|
+
this._unbindEvents();
|
|
636
|
+
this._listeners.length = 0;
|
|
637
|
+
delete this.el;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
IMask.InputMask = InputMask;
|
|
641
|
+
|
|
642
|
+
class ChangeDetails {
|
|
643
|
+
static normalize(prep) {
|
|
644
|
+
return Array.isArray(prep) ? prep : [prep, new ChangeDetails()];
|
|
645
|
+
}
|
|
646
|
+
constructor(details) {
|
|
647
|
+
Object.assign(this, {
|
|
648
|
+
inserted: '',
|
|
649
|
+
rawInserted: '',
|
|
650
|
+
tailShift: 0,
|
|
651
|
+
skip: false
|
|
652
|
+
}, details);
|
|
653
|
+
}
|
|
654
|
+
aggregate(details) {
|
|
655
|
+
this.inserted += details.inserted;
|
|
656
|
+
this.rawInserted += details.rawInserted;
|
|
657
|
+
this.tailShift += details.tailShift;
|
|
658
|
+
this.skip = this.skip || details.skip;
|
|
659
|
+
return this;
|
|
660
|
+
}
|
|
661
|
+
get offset() {
|
|
662
|
+
return this.tailShift + this.inserted.length;
|
|
663
|
+
}
|
|
664
|
+
get consumed() {
|
|
665
|
+
return Boolean(this.rawInserted) || this.skip;
|
|
666
|
+
}
|
|
667
|
+
equals(details) {
|
|
668
|
+
return this.inserted === details.inserted && this.tailShift === details.tailShift && this.rawInserted === details.rawInserted && this.skip === details.skip;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
IMask.ChangeDetails = ChangeDetails;
|
|
672
|
+
|
|
673
|
+
class ContinuousTailDetails {
|
|
674
|
+
constructor(value, from, stop) {
|
|
675
|
+
if (value === void 0) {
|
|
676
|
+
value = '';
|
|
677
|
+
}
|
|
678
|
+
if (from === void 0) {
|
|
679
|
+
from = 0;
|
|
680
|
+
}
|
|
681
|
+
this.value = value;
|
|
682
|
+
this.from = from;
|
|
683
|
+
this.stop = stop;
|
|
684
|
+
}
|
|
685
|
+
toString() {
|
|
686
|
+
return this.value;
|
|
687
|
+
}
|
|
688
|
+
extend(tail) {
|
|
689
|
+
this.value += String(tail);
|
|
690
|
+
}
|
|
691
|
+
appendTo(masked) {
|
|
692
|
+
return masked.append(this.toString(), {
|
|
693
|
+
tail: true
|
|
694
|
+
}).aggregate(masked._appendPlaceholder());
|
|
695
|
+
}
|
|
696
|
+
get state() {
|
|
697
|
+
return {
|
|
698
|
+
value: this.value,
|
|
699
|
+
from: this.from,
|
|
700
|
+
stop: this.stop
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
set state(state) {
|
|
704
|
+
Object.assign(this, state);
|
|
705
|
+
}
|
|
706
|
+
unshift(beforePos) {
|
|
707
|
+
if (!this.value.length || beforePos != null && this.from >= beforePos) return '';
|
|
708
|
+
const shiftChar = this.value[0];
|
|
709
|
+
this.value = this.value.slice(1);
|
|
710
|
+
return shiftChar;
|
|
711
|
+
}
|
|
712
|
+
shift() {
|
|
713
|
+
if (!this.value.length) return '';
|
|
714
|
+
const shiftChar = this.value[this.value.length - 1];
|
|
715
|
+
this.value = this.value.slice(0, -1);
|
|
716
|
+
return shiftChar;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
class Masked {
|
|
721
|
+
constructor(opts) {
|
|
722
|
+
this._value = '';
|
|
723
|
+
this._update({
|
|
724
|
+
...Masked.DEFAULTS,
|
|
725
|
+
...opts
|
|
726
|
+
});
|
|
727
|
+
this._initialized = true;
|
|
728
|
+
}
|
|
729
|
+
updateOptions(opts) {
|
|
730
|
+
if (!this.optionsIsChanged(opts)) return;
|
|
731
|
+
this.withValueRefresh(this._update.bind(this, opts));
|
|
732
|
+
}
|
|
733
|
+
_update(opts) {
|
|
734
|
+
Object.assign(this, opts);
|
|
735
|
+
}
|
|
736
|
+
get state() {
|
|
737
|
+
return {
|
|
738
|
+
_value: this.value,
|
|
739
|
+
_rawInputValue: this.rawInputValue
|
|
740
|
+
};
|
|
741
|
+
}
|
|
742
|
+
set state(state) {
|
|
743
|
+
this._value = state._value;
|
|
744
|
+
}
|
|
745
|
+
reset() {
|
|
746
|
+
this._value = '';
|
|
747
|
+
}
|
|
748
|
+
get value() {
|
|
749
|
+
return this._value;
|
|
750
|
+
}
|
|
751
|
+
set value(value) {
|
|
752
|
+
this.resolve(value, {
|
|
753
|
+
input: true
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
resolve(value, flags) {
|
|
757
|
+
if (flags === void 0) {
|
|
758
|
+
flags = {
|
|
759
|
+
input: true
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
this.reset();
|
|
763
|
+
this.append(value, flags, '');
|
|
764
|
+
this.doCommit();
|
|
765
|
+
}
|
|
766
|
+
get unmaskedValue() {
|
|
767
|
+
return this.value;
|
|
768
|
+
}
|
|
769
|
+
set unmaskedValue(value) {
|
|
770
|
+
this.resolve(value, {});
|
|
771
|
+
}
|
|
772
|
+
get typedValue() {
|
|
773
|
+
return this.parse ? this.parse(this.value, this) : this.unmaskedValue;
|
|
774
|
+
}
|
|
775
|
+
set typedValue(value) {
|
|
776
|
+
if (this.format) {
|
|
777
|
+
this.value = this.format(value, this);
|
|
778
|
+
} else {
|
|
779
|
+
this.unmaskedValue = String(value);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
get rawInputValue() {
|
|
783
|
+
return this.extractInput(0, this.displayValue.length, {
|
|
784
|
+
raw: true
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
set rawInputValue(value) {
|
|
788
|
+
this.resolve(value, {
|
|
789
|
+
raw: true
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
get displayValue() {
|
|
793
|
+
return this.value;
|
|
794
|
+
}
|
|
795
|
+
get isComplete() {
|
|
796
|
+
return true;
|
|
797
|
+
}
|
|
798
|
+
get isFilled() {
|
|
799
|
+
return this.isComplete;
|
|
800
|
+
}
|
|
801
|
+
nearestInputPos(cursorPos, direction) {
|
|
802
|
+
return cursorPos;
|
|
803
|
+
}
|
|
804
|
+
totalInputPositions(fromPos, toPos) {
|
|
805
|
+
if (fromPos === void 0) {
|
|
806
|
+
fromPos = 0;
|
|
807
|
+
}
|
|
808
|
+
if (toPos === void 0) {
|
|
809
|
+
toPos = this.displayValue.length;
|
|
810
|
+
}
|
|
811
|
+
return Math.min(this.displayValue.length, toPos - fromPos);
|
|
812
|
+
}
|
|
813
|
+
extractInput(fromPos, toPos, flags) {
|
|
814
|
+
if (fromPos === void 0) {
|
|
815
|
+
fromPos = 0;
|
|
816
|
+
}
|
|
817
|
+
if (toPos === void 0) {
|
|
818
|
+
toPos = this.displayValue.length;
|
|
819
|
+
}
|
|
820
|
+
return this.displayValue.slice(fromPos, toPos);
|
|
821
|
+
}
|
|
822
|
+
extractTail(fromPos, toPos) {
|
|
823
|
+
if (fromPos === void 0) {
|
|
824
|
+
fromPos = 0;
|
|
825
|
+
}
|
|
826
|
+
if (toPos === void 0) {
|
|
827
|
+
toPos = this.displayValue.length;
|
|
828
|
+
}
|
|
829
|
+
return new ContinuousTailDetails(this.extractInput(fromPos, toPos), fromPos);
|
|
830
|
+
}
|
|
831
|
+
appendTail(tail) {
|
|
832
|
+
if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
|
|
833
|
+
return tail.appendTo(this);
|
|
834
|
+
}
|
|
835
|
+
_appendCharRaw(ch, flags) {
|
|
294
836
|
if (!ch) return new ChangeDetails();
|
|
295
837
|
this._value += ch;
|
|
296
838
|
return new ChangeDetails({
|
|
@@ -298,13 +840,28 @@ class Masked {
|
|
|
298
840
|
rawInserted: ch
|
|
299
841
|
});
|
|
300
842
|
}
|
|
301
|
-
_appendChar(ch) {
|
|
302
|
-
|
|
303
|
-
|
|
843
|
+
_appendChar(ch, flags, checkTail) {
|
|
844
|
+
if (flags === void 0) {
|
|
845
|
+
flags = {};
|
|
846
|
+
}
|
|
304
847
|
const consistentState = this.state;
|
|
305
848
|
let details;
|
|
306
|
-
[ch, details] =
|
|
307
|
-
|
|
849
|
+
[ch, details] = this.doPrepareChar(ch, flags);
|
|
850
|
+
if (ch) {
|
|
851
|
+
details = details.aggregate(this._appendCharRaw(ch, flags));
|
|
852
|
+
if (!details.rawInserted && this.autofix === 'pad') {
|
|
853
|
+
const noFixState = this.state;
|
|
854
|
+
this.state = consistentState;
|
|
855
|
+
let fixDetails = this.pad(flags);
|
|
856
|
+
const chDetails = this._appendCharRaw(ch, flags);
|
|
857
|
+
fixDetails = fixDetails.aggregate(chDetails);
|
|
858
|
+
if (chDetails.rawInserted || fixDetails.equals(details)) {
|
|
859
|
+
details = fixDetails;
|
|
860
|
+
} else {
|
|
861
|
+
this.state = noFixState;
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
}
|
|
308
865
|
if (details.inserted) {
|
|
309
866
|
let consistentTail;
|
|
310
867
|
let appended = this.doValidate(flags) !== false;
|
|
@@ -312,16 +869,20 @@ class Masked {
|
|
|
312
869
|
const beforeTailState = this.state;
|
|
313
870
|
if (this.overwrite === true) {
|
|
314
871
|
consistentTail = checkTail.state;
|
|
315
|
-
|
|
872
|
+
for (let i = 0; i < details.rawInserted.length; ++i) {
|
|
873
|
+
checkTail.unshift(this.displayValue.length - details.tailShift);
|
|
874
|
+
}
|
|
316
875
|
}
|
|
317
876
|
let tailDetails = this.appendTail(checkTail);
|
|
318
|
-
appended = tailDetails.rawInserted === checkTail.toString();
|
|
877
|
+
appended = tailDetails.rawInserted.length === checkTail.toString().length;
|
|
319
878
|
if (!(appended && tailDetails.inserted) && this.overwrite === 'shift') {
|
|
320
879
|
this.state = beforeTailState;
|
|
321
880
|
consistentTail = checkTail.state;
|
|
322
|
-
|
|
881
|
+
for (let i = 0; i < details.rawInserted.length; ++i) {
|
|
882
|
+
checkTail.shift();
|
|
883
|
+
}
|
|
323
884
|
tailDetails = this.appendTail(checkTail);
|
|
324
|
-
appended = tailDetails.rawInserted === checkTail.toString();
|
|
885
|
+
appended = tailDetails.rawInserted.length === checkTail.toString().length;
|
|
325
886
|
}
|
|
326
887
|
if (appended && tailDetails.inserted) this.state = beforeTailState;
|
|
327
888
|
}
|
|
@@ -341,43 +902,49 @@ class Masked {
|
|
|
341
902
|
}
|
|
342
903
|
append(str, flags, tail) {
|
|
343
904
|
if (!isString(str)) throw new Error('value should be string');
|
|
344
|
-
const details = new ChangeDetails();
|
|
345
905
|
const checkTail = isString(tail) ? new ContinuousTailDetails(String(tail)) : tail;
|
|
346
|
-
if (flags
|
|
906
|
+
if (flags != null && flags.tail) flags._beforeTailState = this.state;
|
|
907
|
+
let details;
|
|
908
|
+
[str, details] = this.doPrepare(str, flags);
|
|
347
909
|
for (let ci = 0; ci < str.length; ++ci) {
|
|
348
910
|
const d = this._appendChar(str[ci], flags, checkTail);
|
|
349
911
|
if (!d.rawInserted && !this.doSkipInvalid(str[ci], flags, checkTail)) break;
|
|
350
912
|
details.aggregate(d);
|
|
351
913
|
}
|
|
914
|
+
if ((this.eager === true || this.eager === 'append') && flags != null && flags.input && str) {
|
|
915
|
+
details.aggregate(this._appendEager());
|
|
916
|
+
}
|
|
352
917
|
if (checkTail != null) {
|
|
353
918
|
details.tailShift += this.appendTail(checkTail).tailShift;
|
|
354
919
|
}
|
|
355
|
-
if ((this.eager === true || this.eager === 'append') && flags !== null && flags !== void 0 && flags.input && str) {
|
|
356
|
-
details.aggregate(this._appendEager());
|
|
357
|
-
}
|
|
358
920
|
return details;
|
|
359
921
|
}
|
|
360
|
-
remove() {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
922
|
+
remove(fromPos, toPos) {
|
|
923
|
+
if (fromPos === void 0) {
|
|
924
|
+
fromPos = 0;
|
|
925
|
+
}
|
|
926
|
+
if (toPos === void 0) {
|
|
927
|
+
toPos = this.displayValue.length;
|
|
928
|
+
}
|
|
929
|
+
this._value = this.displayValue.slice(0, fromPos) + this.displayValue.slice(toPos);
|
|
364
930
|
return new ChangeDetails();
|
|
365
931
|
}
|
|
366
932
|
withValueRefresh(fn) {
|
|
367
|
-
if (this._refreshing || !this.
|
|
933
|
+
if (this._refreshing || !this._initialized) return fn();
|
|
368
934
|
this._refreshing = true;
|
|
369
935
|
const rawInput = this.rawInputValue;
|
|
370
936
|
const value = this.value;
|
|
371
937
|
const ret = fn();
|
|
372
938
|
this.rawInputValue = rawInput;
|
|
373
939
|
if (this.value && this.value !== value && value.indexOf(this.value) === 0) {
|
|
374
|
-
this.append(value.slice(this.
|
|
940
|
+
this.append(value.slice(this.displayValue.length), {}, '');
|
|
941
|
+
this.doCommit();
|
|
375
942
|
}
|
|
376
943
|
delete this._refreshing;
|
|
377
944
|
return ret;
|
|
378
945
|
}
|
|
379
946
|
runIsolated(fn) {
|
|
380
|
-
if (this._isolated || !this.
|
|
947
|
+
if (this._isolated || !this._initialized) return fn(this);
|
|
381
948
|
this._isolated = true;
|
|
382
949
|
const state = this.state;
|
|
383
950
|
const ret = fn(this);
|
|
@@ -385,12 +952,20 @@ class Masked {
|
|
|
385
952
|
delete this._isolated;
|
|
386
953
|
return ret;
|
|
387
954
|
}
|
|
388
|
-
doSkipInvalid(ch) {
|
|
389
|
-
return this.skipInvalid;
|
|
955
|
+
doSkipInvalid(ch, flags, checkTail) {
|
|
956
|
+
return Boolean(this.skipInvalid);
|
|
957
|
+
}
|
|
958
|
+
doPrepare(str, flags) {
|
|
959
|
+
if (flags === void 0) {
|
|
960
|
+
flags = {};
|
|
961
|
+
}
|
|
962
|
+
return ChangeDetails.normalize(this.prepare ? this.prepare(str, this, flags) : str);
|
|
390
963
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
964
|
+
doPrepareChar(str, flags) {
|
|
965
|
+
if (flags === void 0) {
|
|
966
|
+
flags = {};
|
|
967
|
+
}
|
|
968
|
+
return ChangeDetails.normalize(this.prepareChar ? this.prepareChar(str, this, flags) : str);
|
|
394
969
|
}
|
|
395
970
|
doValidate(flags) {
|
|
396
971
|
return (!this.validate || this.validate(this.value, this, flags)) && (!this.parent || this.parent.doValidate(flags));
|
|
@@ -398,16 +973,18 @@ class Masked {
|
|
|
398
973
|
doCommit() {
|
|
399
974
|
if (this.commit) this.commit(this.value, this);
|
|
400
975
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
976
|
+
splice(start, deleteCount, inserted, removeDirection, flags) {
|
|
977
|
+
if (inserted === void 0) {
|
|
978
|
+
inserted = '';
|
|
979
|
+
}
|
|
980
|
+
if (removeDirection === void 0) {
|
|
981
|
+
removeDirection = DIRECTION.NONE;
|
|
982
|
+
}
|
|
983
|
+
if (flags === void 0) {
|
|
984
|
+
flags = {
|
|
985
|
+
input: true
|
|
986
|
+
};
|
|
987
|
+
}
|
|
411
988
|
const tailPos = start + deleteCount;
|
|
412
989
|
const tail = this.extractTail(tailPos);
|
|
413
990
|
const eagerRemove = this.eager === true || this.eager === 'remove';
|
|
@@ -428,7 +1005,7 @@ class Masked {
|
|
|
428
1005
|
if (eagerRemove && removeDirection !== DIRECTION.NONE && oldRawValue === this.rawInputValue) {
|
|
429
1006
|
if (removeDirection === DIRECTION.FORCE_LEFT) {
|
|
430
1007
|
let valLength;
|
|
431
|
-
while (oldRawValue === this.rawInputValue && (valLength = this.
|
|
1008
|
+
while (oldRawValue === this.rawInputValue && (valLength = this.displayValue.length)) {
|
|
432
1009
|
details.aggregate(new ChangeDetails({
|
|
433
1010
|
tailShift: -1
|
|
434
1011
|
})).aggregate(this.remove(valLength - 1));
|
|
@@ -437,296 +1014,36 @@ class Masked {
|
|
|
437
1014
|
tail.unshift();
|
|
438
1015
|
}
|
|
439
1016
|
}
|
|
440
|
-
return details.aggregate(this.append(inserted, flags, tail));
|
|
441
|
-
}
|
|
442
|
-
maskEquals(mask) {
|
|
443
|
-
return this.mask === mask;
|
|
444
|
-
}
|
|
445
|
-
typedValueEquals(value) {
|
|
446
|
-
const tval = this.typedValue;
|
|
447
|
-
return value === tval || Masked.EMPTY_VALUES.includes(value) && Masked.EMPTY_VALUES.includes(tval) || this.doFormat(value) === this.doFormat(this.typedValue);
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
Masked.DEFAULTS = {
|
|
451
|
-
format: String,
|
|
452
|
-
parse: v => v,
|
|
453
|
-
skipInvalid: true
|
|
454
|
-
};
|
|
455
|
-
Masked.EMPTY_VALUES = [undefined, null, ''];
|
|
456
|
-
IMask.Masked = Masked;
|
|
457
|
-
|
|
458
|
-
function maskedClass(mask) {
|
|
459
|
-
if (mask == null) {
|
|
460
|
-
throw new Error('mask property should be defined');
|
|
461
|
-
}
|
|
462
|
-
if (mask instanceof RegExp) return IMask.MaskedRegExp;
|
|
463
|
-
if (isString(mask)) return IMask.MaskedPattern;
|
|
464
|
-
if (mask instanceof Date || mask === Date) return IMask.MaskedDate;
|
|
465
|
-
if (mask instanceof Number || typeof mask === 'number' || mask === Number) return IMask.MaskedNumber;
|
|
466
|
-
if (Array.isArray(mask) || mask === Array) return IMask.MaskedDynamic;
|
|
467
|
-
if (IMask.Masked && mask.prototype instanceof IMask.Masked) return mask;
|
|
468
|
-
if (mask instanceof IMask.Masked) return mask.constructor;
|
|
469
|
-
if (mask instanceof Function) return IMask.MaskedFunction;
|
|
470
|
-
console.warn('Mask not found for mask', mask);
|
|
471
|
-
return IMask.Masked;
|
|
472
|
-
}
|
|
473
|
-
function createMask(opts) {
|
|
474
|
-
if (IMask.Masked && opts instanceof IMask.Masked) return opts;
|
|
475
|
-
opts = Object.assign({}, opts);
|
|
476
|
-
const mask = opts.mask;
|
|
477
|
-
if (IMask.Masked && mask instanceof IMask.Masked) return mask;
|
|
478
|
-
const MaskedClass = maskedClass(mask);
|
|
479
|
-
if (!MaskedClass) throw new Error('Masked class is not found for provided mask, appropriate module needs to be import manually before creating mask.');
|
|
480
|
-
return new MaskedClass(opts);
|
|
481
|
-
}
|
|
482
|
-
IMask.createMask = createMask;
|
|
483
|
-
|
|
484
|
-
const _excluded$4 = ["parent", "isOptional", "placeholderChar", "displayChar", "lazy", "eager"];
|
|
485
|
-
const DEFAULT_INPUT_DEFINITIONS = {
|
|
486
|
-
'0': /\d/,
|
|
487
|
-
'a': /[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
|
|
488
|
-
'*': /./
|
|
489
|
-
};
|
|
490
|
-
class PatternInputDefinition {
|
|
491
|
-
constructor(opts) {
|
|
492
|
-
const {
|
|
493
|
-
parent,
|
|
494
|
-
isOptional,
|
|
495
|
-
placeholderChar,
|
|
496
|
-
displayChar,
|
|
497
|
-
lazy,
|
|
498
|
-
eager
|
|
499
|
-
} = opts,
|
|
500
|
-
maskOpts = _objectWithoutPropertiesLoose(opts, _excluded$4);
|
|
501
|
-
this.masked = createMask(maskOpts);
|
|
502
|
-
Object.assign(this, {
|
|
503
|
-
parent,
|
|
504
|
-
isOptional,
|
|
505
|
-
placeholderChar,
|
|
506
|
-
displayChar,
|
|
507
|
-
lazy,
|
|
508
|
-
eager
|
|
509
|
-
});
|
|
510
|
-
}
|
|
511
|
-
reset() {
|
|
512
|
-
this.isFilled = false;
|
|
513
|
-
this.masked.reset();
|
|
514
|
-
}
|
|
515
|
-
remove() {
|
|
516
|
-
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
517
|
-
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
|
|
518
|
-
if (fromPos === 0 && toPos >= 1) {
|
|
519
|
-
this.isFilled = false;
|
|
520
|
-
return this.masked.remove(fromPos, toPos);
|
|
521
|
-
}
|
|
522
|
-
return new ChangeDetails();
|
|
523
|
-
}
|
|
524
|
-
get value() {
|
|
525
|
-
return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : '');
|
|
526
|
-
}
|
|
527
|
-
get unmaskedValue() {
|
|
528
|
-
return this.masked.unmaskedValue;
|
|
529
|
-
}
|
|
530
|
-
get displayValue() {
|
|
531
|
-
return this.masked.value && this.displayChar || this.value;
|
|
532
|
-
}
|
|
533
|
-
get isComplete() {
|
|
534
|
-
return Boolean(this.masked.value) || this.isOptional;
|
|
535
|
-
}
|
|
536
|
-
_appendChar(ch) {
|
|
537
|
-
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
538
|
-
if (this.isFilled) return new ChangeDetails();
|
|
539
|
-
const state = this.masked.state;
|
|
540
|
-
const details = this.masked._appendChar(ch, flags);
|
|
541
|
-
if (details.inserted && this.doValidate(flags) === false) {
|
|
542
|
-
details.inserted = details.rawInserted = '';
|
|
543
|
-
this.masked.state = state;
|
|
544
|
-
}
|
|
545
|
-
if (!details.inserted && !this.isOptional && !this.lazy && !flags.input) {
|
|
546
|
-
details.inserted = this.placeholderChar;
|
|
547
|
-
}
|
|
548
|
-
details.skip = !details.inserted && !this.isOptional;
|
|
549
|
-
this.isFilled = Boolean(details.inserted);
|
|
550
|
-
return details;
|
|
551
|
-
}
|
|
552
|
-
append() {
|
|
553
|
-
return this.masked.append(...arguments);
|
|
554
|
-
}
|
|
555
|
-
_appendPlaceholder() {
|
|
556
|
-
const details = new ChangeDetails();
|
|
557
|
-
if (this.isFilled || this.isOptional) return details;
|
|
558
|
-
this.isFilled = true;
|
|
559
|
-
details.inserted = this.placeholderChar;
|
|
560
|
-
return details;
|
|
561
|
-
}
|
|
562
|
-
_appendEager() {
|
|
563
|
-
return new ChangeDetails();
|
|
564
|
-
}
|
|
565
|
-
extractTail() {
|
|
566
|
-
return this.masked.extractTail(...arguments);
|
|
567
|
-
}
|
|
568
|
-
appendTail() {
|
|
569
|
-
return this.masked.appendTail(...arguments);
|
|
570
|
-
}
|
|
571
|
-
extractInput() {
|
|
572
|
-
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
573
|
-
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
|
|
574
|
-
let flags = arguments.length > 2 ? arguments[2] : undefined;
|
|
575
|
-
return this.masked.extractInput(fromPos, toPos, flags);
|
|
576
|
-
}
|
|
577
|
-
nearestInputPos(cursorPos) {
|
|
578
|
-
let direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
|
|
579
|
-
const minPos = 0;
|
|
580
|
-
const maxPos = this.value.length;
|
|
581
|
-
const boundPos = Math.min(Math.max(cursorPos, minPos), maxPos);
|
|
582
|
-
switch (direction) {
|
|
583
|
-
case DIRECTION.LEFT:
|
|
584
|
-
case DIRECTION.FORCE_LEFT:
|
|
585
|
-
return this.isComplete ? boundPos : minPos;
|
|
586
|
-
case DIRECTION.RIGHT:
|
|
587
|
-
case DIRECTION.FORCE_RIGHT:
|
|
588
|
-
return this.isComplete ? boundPos : maxPos;
|
|
589
|
-
case DIRECTION.NONE:
|
|
590
|
-
default:
|
|
591
|
-
return boundPos;
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
totalInputPositions() {
|
|
595
|
-
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
596
|
-
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
|
|
597
|
-
return this.value.slice(fromPos, toPos).length;
|
|
598
|
-
}
|
|
599
|
-
doValidate() {
|
|
600
|
-
return this.masked.doValidate(...arguments) && (!this.parent || this.parent.doValidate(...arguments));
|
|
601
|
-
}
|
|
602
|
-
doCommit() {
|
|
603
|
-
this.masked.doCommit();
|
|
604
|
-
}
|
|
605
|
-
get state() {
|
|
606
|
-
return {
|
|
607
|
-
masked: this.masked.state,
|
|
608
|
-
isFilled: this.isFilled
|
|
609
|
-
};
|
|
610
|
-
}
|
|
611
|
-
set state(state) {
|
|
612
|
-
this.masked.state = state.masked;
|
|
613
|
-
this.isFilled = state.isFilled;
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
class PatternFixedDefinition {
|
|
618
|
-
constructor(opts) {
|
|
619
|
-
Object.assign(this, opts);
|
|
620
|
-
this._value = '';
|
|
621
|
-
this.isFixed = true;
|
|
622
|
-
}
|
|
623
|
-
get value() {
|
|
624
|
-
return this._value;
|
|
625
|
-
}
|
|
626
|
-
get unmaskedValue() {
|
|
627
|
-
return this.isUnmasking ? this.value : '';
|
|
628
|
-
}
|
|
629
|
-
get displayValue() {
|
|
630
|
-
return this.value;
|
|
631
|
-
}
|
|
632
|
-
reset() {
|
|
633
|
-
this._isRawInput = false;
|
|
634
|
-
this._value = '';
|
|
635
|
-
}
|
|
636
|
-
remove() {
|
|
637
|
-
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
638
|
-
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._value.length;
|
|
639
|
-
this._value = this._value.slice(0, fromPos) + this._value.slice(toPos);
|
|
640
|
-
if (!this._value) this._isRawInput = false;
|
|
641
|
-
return new ChangeDetails();
|
|
642
|
-
}
|
|
643
|
-
nearestInputPos(cursorPos) {
|
|
644
|
-
let direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
|
|
645
|
-
const minPos = 0;
|
|
646
|
-
const maxPos = this._value.length;
|
|
647
|
-
switch (direction) {
|
|
648
|
-
case DIRECTION.LEFT:
|
|
649
|
-
case DIRECTION.FORCE_LEFT:
|
|
650
|
-
return minPos;
|
|
651
|
-
case DIRECTION.NONE:
|
|
652
|
-
case DIRECTION.RIGHT:
|
|
653
|
-
case DIRECTION.FORCE_RIGHT:
|
|
654
|
-
default:
|
|
655
|
-
return maxPos;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
totalInputPositions() {
|
|
659
|
-
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
660
|
-
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._value.length;
|
|
661
|
-
return this._isRawInput ? toPos - fromPos : 0;
|
|
662
|
-
}
|
|
663
|
-
extractInput() {
|
|
664
|
-
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
665
|
-
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._value.length;
|
|
666
|
-
let flags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
667
|
-
return flags.raw && this._isRawInput && this._value.slice(fromPos, toPos) || '';
|
|
668
|
-
}
|
|
669
|
-
get isComplete() {
|
|
670
|
-
return true;
|
|
671
|
-
}
|
|
672
|
-
get isFilled() {
|
|
673
|
-
return Boolean(this._value);
|
|
674
|
-
}
|
|
675
|
-
_appendChar(ch) {
|
|
676
|
-
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
677
|
-
const details = new ChangeDetails();
|
|
678
|
-
if (this.isFilled) return details;
|
|
679
|
-
const appendEager = this.eager === true || this.eager === 'append';
|
|
680
|
-
const appended = this.char === ch;
|
|
681
|
-
const isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && (!flags.raw || !appendEager) && !flags.tail;
|
|
682
|
-
if (isResolved) details.rawInserted = this.char;
|
|
683
|
-
this._value = details.inserted = this.char;
|
|
684
|
-
this._isRawInput = isResolved && (flags.raw || flags.input);
|
|
685
|
-
return details;
|
|
686
|
-
}
|
|
687
|
-
_appendEager() {
|
|
688
|
-
return this._appendChar(this.char, {
|
|
689
|
-
tail: true
|
|
690
|
-
});
|
|
691
|
-
}
|
|
692
|
-
_appendPlaceholder() {
|
|
693
|
-
const details = new ChangeDetails();
|
|
694
|
-
if (this.isFilled) return details;
|
|
695
|
-
this._value = details.inserted = this.char;
|
|
696
|
-
return details;
|
|
697
|
-
}
|
|
698
|
-
extractTail() {
|
|
699
|
-
arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
|
|
700
|
-
return new ContinuousTailDetails('');
|
|
1017
|
+
return details.aggregate(this.append(inserted, flags, tail));
|
|
701
1018
|
}
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
return tail.appendTo(this);
|
|
1019
|
+
maskEquals(mask) {
|
|
1020
|
+
return this.mask === mask;
|
|
705
1021
|
}
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
if (tail != null) {
|
|
709
|
-
details.tailShift += this.appendTail(tail).tailShift;
|
|
710
|
-
}
|
|
711
|
-
return details;
|
|
1022
|
+
optionsIsChanged(opts) {
|
|
1023
|
+
return !objectIncludes(this, opts);
|
|
712
1024
|
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
return
|
|
716
|
-
_value: this._value,
|
|
717
|
-
_isRawInput: this._isRawInput
|
|
718
|
-
};
|
|
1025
|
+
typedValueEquals(value) {
|
|
1026
|
+
const tval = this.typedValue;
|
|
1027
|
+
return value === tval || Masked.EMPTY_VALUES.includes(value) && Masked.EMPTY_VALUES.includes(tval) || (this.format ? this.format(value, this) === this.format(this.typedValue, this) : false);
|
|
719
1028
|
}
|
|
720
|
-
|
|
721
|
-
|
|
1029
|
+
pad(flags) {
|
|
1030
|
+
return new ChangeDetails();
|
|
722
1031
|
}
|
|
723
1032
|
}
|
|
1033
|
+
Masked.DEFAULTS = {
|
|
1034
|
+
skipInvalid: true
|
|
1035
|
+
};
|
|
1036
|
+
Masked.EMPTY_VALUES = [undefined, null, ''];
|
|
1037
|
+
IMask.Masked = Masked;
|
|
724
1038
|
|
|
725
|
-
const _excluded$3 = ["chunks"];
|
|
726
1039
|
class ChunksTailDetails {
|
|
727
|
-
constructor() {
|
|
728
|
-
|
|
729
|
-
|
|
1040
|
+
constructor(chunks, from) {
|
|
1041
|
+
if (chunks === void 0) {
|
|
1042
|
+
chunks = [];
|
|
1043
|
+
}
|
|
1044
|
+
if (from === void 0) {
|
|
1045
|
+
from = 0;
|
|
1046
|
+
}
|
|
730
1047
|
this.chunks = chunks;
|
|
731
1048
|
this.from = from;
|
|
732
1049
|
}
|
|
@@ -735,7 +1052,7 @@ class ChunksTailDetails {
|
|
|
735
1052
|
}
|
|
736
1053
|
extend(tailChunk) {
|
|
737
1054
|
if (!String(tailChunk)) return;
|
|
738
|
-
|
|
1055
|
+
tailChunk = isString(tailChunk) ? new ContinuousTailDetails(String(tailChunk)) : tailChunk;
|
|
739
1056
|
const lastChunk = this.chunks[this.chunks.length - 1];
|
|
740
1057
|
const extendLast = lastChunk && (
|
|
741
1058
|
lastChunk.stop === tailChunk.stop || tailChunk.stop == null) &&
|
|
@@ -767,25 +1084,22 @@ class ChunksTailDetails {
|
|
|
767
1084
|
return tail.appendTo(masked);
|
|
768
1085
|
}
|
|
769
1086
|
const details = new ChangeDetails();
|
|
770
|
-
for (let ci = 0; ci < this.chunks.length
|
|
1087
|
+
for (let ci = 0; ci < this.chunks.length; ++ci) {
|
|
771
1088
|
const chunk = this.chunks[ci];
|
|
772
|
-
const lastBlockIter = masked._mapPosToBlock(masked.
|
|
1089
|
+
const lastBlockIter = masked._mapPosToBlock(masked.displayValue.length);
|
|
773
1090
|
const stop = chunk.stop;
|
|
774
1091
|
let chunkBlock;
|
|
775
1092
|
if (stop != null && (
|
|
776
1093
|
!lastBlockIter || lastBlockIter.index <= stop)) {
|
|
777
1094
|
if (chunk instanceof ChunksTailDetails ||
|
|
778
1095
|
masked._stops.indexOf(stop) >= 0) {
|
|
779
|
-
|
|
780
|
-
details.aggregate(phDetails);
|
|
1096
|
+
details.aggregate(masked._appendPlaceholder(stop));
|
|
781
1097
|
}
|
|
782
1098
|
chunkBlock = chunk instanceof ChunksTailDetails && masked._blocks[stop];
|
|
783
1099
|
}
|
|
784
1100
|
if (chunkBlock) {
|
|
785
1101
|
const tailDetails = chunkBlock.appendTail(chunk);
|
|
786
|
-
tailDetails.skip = false;
|
|
787
1102
|
details.aggregate(tailDetails);
|
|
788
|
-
masked._value += tailDetails.inserted;
|
|
789
1103
|
const remainChars = chunk.toString().slice(tailDetails.rawInserted.length);
|
|
790
1104
|
if (remainChars) details.aggregate(masked.append(remainChars, {
|
|
791
1105
|
tail: true
|
|
@@ -808,9 +1122,9 @@ class ChunksTailDetails {
|
|
|
808
1122
|
}
|
|
809
1123
|
set state(state) {
|
|
810
1124
|
const {
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
1125
|
+
chunks,
|
|
1126
|
+
...props
|
|
1127
|
+
} = state;
|
|
814
1128
|
Object.assign(this, props);
|
|
815
1129
|
this.chunks = chunks.map(cstate => {
|
|
816
1130
|
const chunk = "chunks" in cstate ? new ChunksTailDetails() : new ContinuousTailDetails();
|
|
@@ -894,7 +1208,7 @@ class PatternCursor {
|
|
|
894
1208
|
}
|
|
895
1209
|
popState() {
|
|
896
1210
|
const s = this._log.pop();
|
|
897
|
-
this.state = s;
|
|
1211
|
+
if (s) this.state = s;
|
|
898
1212
|
return s;
|
|
899
1213
|
}
|
|
900
1214
|
bindBlock() {
|
|
@@ -905,12 +1219,12 @@ class PatternCursor {
|
|
|
905
1219
|
}
|
|
906
1220
|
if (this.index >= this.masked._blocks.length) {
|
|
907
1221
|
this.index = this.masked._blocks.length - 1;
|
|
908
|
-
this.offset = this.block.
|
|
1222
|
+
this.offset = this.block.displayValue.length;
|
|
909
1223
|
}
|
|
910
1224
|
}
|
|
911
1225
|
_pushLeft(fn) {
|
|
912
1226
|
this.pushState();
|
|
913
|
-
for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((_this$block = this.block)
|
|
1227
|
+
for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((_this$block = this.block) == null ? void 0 : _this$block.displayValue.length) || 0) {
|
|
914
1228
|
var _this$block;
|
|
915
1229
|
if (fn()) return this.ok = true;
|
|
916
1230
|
}
|
|
@@ -958,32 +1272,335 @@ class PatternCursor {
|
|
|
958
1272
|
return true;
|
|
959
1273
|
});
|
|
960
1274
|
}
|
|
961
|
-
pushRightBeforeRequired() {
|
|
962
|
-
return this._pushRight(() => {
|
|
963
|
-
if (this.block.isFixed || this.block.isOptional && !this.block.value) return;
|
|
964
|
-
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);
|
|
965
|
-
return true;
|
|
966
|
-
});
|
|
1275
|
+
pushRightBeforeRequired() {
|
|
1276
|
+
return this._pushRight(() => {
|
|
1277
|
+
if (this.block.isFixed || this.block.isOptional && !this.block.value) return;
|
|
1278
|
+
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);
|
|
1279
|
+
return true;
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
class PatternFixedDefinition {
|
|
1285
|
+
constructor(opts) {
|
|
1286
|
+
Object.assign(this, opts);
|
|
1287
|
+
this._value = '';
|
|
1288
|
+
this.isFixed = true;
|
|
1289
|
+
}
|
|
1290
|
+
get value() {
|
|
1291
|
+
return this._value;
|
|
1292
|
+
}
|
|
1293
|
+
get unmaskedValue() {
|
|
1294
|
+
return this.isUnmasking ? this.value : '';
|
|
1295
|
+
}
|
|
1296
|
+
get rawInputValue() {
|
|
1297
|
+
return this._isRawInput ? this.value : '';
|
|
1298
|
+
}
|
|
1299
|
+
get displayValue() {
|
|
1300
|
+
return this.value;
|
|
1301
|
+
}
|
|
1302
|
+
reset() {
|
|
1303
|
+
this._isRawInput = false;
|
|
1304
|
+
this._value = '';
|
|
1305
|
+
}
|
|
1306
|
+
remove(fromPos, toPos) {
|
|
1307
|
+
if (fromPos === void 0) {
|
|
1308
|
+
fromPos = 0;
|
|
1309
|
+
}
|
|
1310
|
+
if (toPos === void 0) {
|
|
1311
|
+
toPos = this._value.length;
|
|
1312
|
+
}
|
|
1313
|
+
this._value = this._value.slice(0, fromPos) + this._value.slice(toPos);
|
|
1314
|
+
if (!this._value) this._isRawInput = false;
|
|
1315
|
+
return new ChangeDetails();
|
|
1316
|
+
}
|
|
1317
|
+
nearestInputPos(cursorPos, direction) {
|
|
1318
|
+
if (direction === void 0) {
|
|
1319
|
+
direction = DIRECTION.NONE;
|
|
1320
|
+
}
|
|
1321
|
+
const minPos = 0;
|
|
1322
|
+
const maxPos = this._value.length;
|
|
1323
|
+
switch (direction) {
|
|
1324
|
+
case DIRECTION.LEFT:
|
|
1325
|
+
case DIRECTION.FORCE_LEFT:
|
|
1326
|
+
return minPos;
|
|
1327
|
+
case DIRECTION.NONE:
|
|
1328
|
+
case DIRECTION.RIGHT:
|
|
1329
|
+
case DIRECTION.FORCE_RIGHT:
|
|
1330
|
+
default:
|
|
1331
|
+
return maxPos;
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
totalInputPositions(fromPos, toPos) {
|
|
1335
|
+
if (fromPos === void 0) {
|
|
1336
|
+
fromPos = 0;
|
|
1337
|
+
}
|
|
1338
|
+
if (toPos === void 0) {
|
|
1339
|
+
toPos = this._value.length;
|
|
1340
|
+
}
|
|
1341
|
+
return this._isRawInput ? toPos - fromPos : 0;
|
|
1342
|
+
}
|
|
1343
|
+
extractInput(fromPos, toPos, flags) {
|
|
1344
|
+
if (fromPos === void 0) {
|
|
1345
|
+
fromPos = 0;
|
|
1346
|
+
}
|
|
1347
|
+
if (toPos === void 0) {
|
|
1348
|
+
toPos = this._value.length;
|
|
1349
|
+
}
|
|
1350
|
+
if (flags === void 0) {
|
|
1351
|
+
flags = {};
|
|
1352
|
+
}
|
|
1353
|
+
return flags.raw && this._isRawInput && this._value.slice(fromPos, toPos) || '';
|
|
1354
|
+
}
|
|
1355
|
+
get isComplete() {
|
|
1356
|
+
return true;
|
|
1357
|
+
}
|
|
1358
|
+
get isFilled() {
|
|
1359
|
+
return Boolean(this._value);
|
|
1360
|
+
}
|
|
1361
|
+
_appendChar(ch, flags) {
|
|
1362
|
+
if (flags === void 0) {
|
|
1363
|
+
flags = {};
|
|
1364
|
+
}
|
|
1365
|
+
if (this.isFilled) return new ChangeDetails();
|
|
1366
|
+
const appendEager = this.eager === true || this.eager === 'append';
|
|
1367
|
+
const appended = this.char === ch;
|
|
1368
|
+
const isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && (!flags.raw || !appendEager) && !flags.tail;
|
|
1369
|
+
const details = new ChangeDetails({
|
|
1370
|
+
inserted: this.char,
|
|
1371
|
+
rawInserted: isResolved ? this.char : ''
|
|
1372
|
+
});
|
|
1373
|
+
this._value = this.char;
|
|
1374
|
+
this._isRawInput = isResolved && (flags.raw || flags.input);
|
|
1375
|
+
return details;
|
|
1376
|
+
}
|
|
1377
|
+
_appendEager() {
|
|
1378
|
+
return this._appendChar(this.char, {
|
|
1379
|
+
tail: true
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1382
|
+
_appendPlaceholder() {
|
|
1383
|
+
const details = new ChangeDetails();
|
|
1384
|
+
if (this.isFilled) return details;
|
|
1385
|
+
this._value = details.inserted = this.char;
|
|
1386
|
+
return details;
|
|
1387
|
+
}
|
|
1388
|
+
extractTail() {
|
|
1389
|
+
return new ContinuousTailDetails('');
|
|
1390
|
+
}
|
|
1391
|
+
appendTail(tail) {
|
|
1392
|
+
if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
|
|
1393
|
+
return tail.appendTo(this);
|
|
1394
|
+
}
|
|
1395
|
+
append(str, flags, tail) {
|
|
1396
|
+
const details = this._appendChar(str[0], flags);
|
|
1397
|
+
if (tail != null) {
|
|
1398
|
+
details.tailShift += this.appendTail(tail).tailShift;
|
|
1399
|
+
}
|
|
1400
|
+
return details;
|
|
1401
|
+
}
|
|
1402
|
+
doCommit() {}
|
|
1403
|
+
get state() {
|
|
1404
|
+
return {
|
|
1405
|
+
_value: this._value,
|
|
1406
|
+
_rawInputValue: this.rawInputValue
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1409
|
+
set state(state) {
|
|
1410
|
+
this._value = state._value;
|
|
1411
|
+
this._isRawInput = Boolean(state._rawInputValue);
|
|
1412
|
+
}
|
|
1413
|
+
pad(flags) {
|
|
1414
|
+
return this._appendPlaceholder();
|
|
1415
|
+
}
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
class PatternInputDefinition {
|
|
1419
|
+
constructor(opts) {
|
|
1420
|
+
const {
|
|
1421
|
+
parent,
|
|
1422
|
+
isOptional,
|
|
1423
|
+
placeholderChar,
|
|
1424
|
+
displayChar,
|
|
1425
|
+
lazy,
|
|
1426
|
+
eager,
|
|
1427
|
+
...maskOpts
|
|
1428
|
+
} = opts;
|
|
1429
|
+
this.masked = createMask(maskOpts);
|
|
1430
|
+
Object.assign(this, {
|
|
1431
|
+
parent,
|
|
1432
|
+
isOptional,
|
|
1433
|
+
placeholderChar,
|
|
1434
|
+
displayChar,
|
|
1435
|
+
lazy,
|
|
1436
|
+
eager
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
reset() {
|
|
1440
|
+
this.isFilled = false;
|
|
1441
|
+
this.masked.reset();
|
|
1442
|
+
}
|
|
1443
|
+
remove(fromPos, toPos) {
|
|
1444
|
+
if (fromPos === void 0) {
|
|
1445
|
+
fromPos = 0;
|
|
1446
|
+
}
|
|
1447
|
+
if (toPos === void 0) {
|
|
1448
|
+
toPos = this.value.length;
|
|
1449
|
+
}
|
|
1450
|
+
if (fromPos === 0 && toPos >= 1) {
|
|
1451
|
+
this.isFilled = false;
|
|
1452
|
+
return this.masked.remove(fromPos, toPos);
|
|
1453
|
+
}
|
|
1454
|
+
return new ChangeDetails();
|
|
1455
|
+
}
|
|
1456
|
+
get value() {
|
|
1457
|
+
return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : '');
|
|
1458
|
+
}
|
|
1459
|
+
get unmaskedValue() {
|
|
1460
|
+
return this.masked.unmaskedValue;
|
|
1461
|
+
}
|
|
1462
|
+
get rawInputValue() {
|
|
1463
|
+
return this.masked.rawInputValue;
|
|
1464
|
+
}
|
|
1465
|
+
get displayValue() {
|
|
1466
|
+
return this.masked.value && this.displayChar || this.value;
|
|
1467
|
+
}
|
|
1468
|
+
get isComplete() {
|
|
1469
|
+
return Boolean(this.masked.value) || this.isOptional;
|
|
1470
|
+
}
|
|
1471
|
+
_appendChar(ch, flags) {
|
|
1472
|
+
if (flags === void 0) {
|
|
1473
|
+
flags = {};
|
|
1474
|
+
}
|
|
1475
|
+
if (this.isFilled) return new ChangeDetails();
|
|
1476
|
+
const state = this.masked.state;
|
|
1477
|
+
let details = this.masked._appendChar(ch, this.currentMaskFlags(flags));
|
|
1478
|
+
if (details.inserted && this.doValidate(flags) === false) {
|
|
1479
|
+
details = new ChangeDetails();
|
|
1480
|
+
this.masked.state = state;
|
|
1481
|
+
}
|
|
1482
|
+
if (!details.inserted && !this.isOptional && !this.lazy && !flags.input) {
|
|
1483
|
+
details.inserted = this.placeholderChar;
|
|
1484
|
+
}
|
|
1485
|
+
details.skip = !details.inserted && !this.isOptional;
|
|
1486
|
+
this.isFilled = Boolean(details.inserted);
|
|
1487
|
+
return details;
|
|
1488
|
+
}
|
|
1489
|
+
append(str, flags, tail) {
|
|
1490
|
+
return this.masked.append(str, this.currentMaskFlags(flags), tail);
|
|
1491
|
+
}
|
|
1492
|
+
_appendPlaceholder() {
|
|
1493
|
+
if (this.isFilled || this.isOptional) return new ChangeDetails();
|
|
1494
|
+
this.isFilled = true;
|
|
1495
|
+
return new ChangeDetails({
|
|
1496
|
+
inserted: this.placeholderChar
|
|
1497
|
+
});
|
|
1498
|
+
}
|
|
1499
|
+
_appendEager() {
|
|
1500
|
+
return new ChangeDetails();
|
|
1501
|
+
}
|
|
1502
|
+
extractTail(fromPos, toPos) {
|
|
1503
|
+
return this.masked.extractTail(fromPos, toPos);
|
|
1504
|
+
}
|
|
1505
|
+
appendTail(tail) {
|
|
1506
|
+
return this.masked.appendTail(tail);
|
|
1507
|
+
}
|
|
1508
|
+
extractInput(fromPos, toPos, flags) {
|
|
1509
|
+
if (fromPos === void 0) {
|
|
1510
|
+
fromPos = 0;
|
|
1511
|
+
}
|
|
1512
|
+
if (toPos === void 0) {
|
|
1513
|
+
toPos = this.value.length;
|
|
1514
|
+
}
|
|
1515
|
+
return this.masked.extractInput(fromPos, toPos, flags);
|
|
1516
|
+
}
|
|
1517
|
+
nearestInputPos(cursorPos, direction) {
|
|
1518
|
+
if (direction === void 0) {
|
|
1519
|
+
direction = DIRECTION.NONE;
|
|
1520
|
+
}
|
|
1521
|
+
const minPos = 0;
|
|
1522
|
+
const maxPos = this.value.length;
|
|
1523
|
+
const boundPos = Math.min(Math.max(cursorPos, minPos), maxPos);
|
|
1524
|
+
switch (direction) {
|
|
1525
|
+
case DIRECTION.LEFT:
|
|
1526
|
+
case DIRECTION.FORCE_LEFT:
|
|
1527
|
+
return this.isComplete ? boundPos : minPos;
|
|
1528
|
+
case DIRECTION.RIGHT:
|
|
1529
|
+
case DIRECTION.FORCE_RIGHT:
|
|
1530
|
+
return this.isComplete ? boundPos : maxPos;
|
|
1531
|
+
case DIRECTION.NONE:
|
|
1532
|
+
default:
|
|
1533
|
+
return boundPos;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
totalInputPositions(fromPos, toPos) {
|
|
1537
|
+
if (fromPos === void 0) {
|
|
1538
|
+
fromPos = 0;
|
|
1539
|
+
}
|
|
1540
|
+
if (toPos === void 0) {
|
|
1541
|
+
toPos = this.value.length;
|
|
1542
|
+
}
|
|
1543
|
+
return this.value.slice(fromPos, toPos).length;
|
|
1544
|
+
}
|
|
1545
|
+
doValidate(flags) {
|
|
1546
|
+
return this.masked.doValidate(this.currentMaskFlags(flags)) && (!this.parent || this.parent.doValidate(this.currentMaskFlags(flags)));
|
|
1547
|
+
}
|
|
1548
|
+
doCommit() {
|
|
1549
|
+
this.masked.doCommit();
|
|
1550
|
+
}
|
|
1551
|
+
get state() {
|
|
1552
|
+
return {
|
|
1553
|
+
_value: this.value,
|
|
1554
|
+
_rawInputValue: this.rawInputValue,
|
|
1555
|
+
masked: this.masked.state,
|
|
1556
|
+
isFilled: this.isFilled
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
set state(state) {
|
|
1560
|
+
this.masked.state = state.masked;
|
|
1561
|
+
this.isFilled = state.isFilled;
|
|
1562
|
+
}
|
|
1563
|
+
currentMaskFlags(flags) {
|
|
1564
|
+
var _flags$_beforeTailSta;
|
|
1565
|
+
return {
|
|
1566
|
+
...flags,
|
|
1567
|
+
_beforeTailState: (flags == null || (_flags$_beforeTailSta = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta.masked) || (flags == null ? void 0 : flags._beforeTailState)
|
|
1568
|
+
};
|
|
1569
|
+
}
|
|
1570
|
+
pad(flags) {
|
|
1571
|
+
return new ChangeDetails();
|
|
967
1572
|
}
|
|
968
1573
|
}
|
|
1574
|
+
PatternInputDefinition.DEFAULT_DEFINITIONS = {
|
|
1575
|
+
'0': /\d/,
|
|
1576
|
+
'a': /[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,
|
|
1577
|
+
'*': /./
|
|
1578
|
+
};
|
|
969
1579
|
|
|
970
1580
|
class MaskedRegExp extends Masked {
|
|
1581
|
+
updateOptions(opts) {
|
|
1582
|
+
super.updateOptions(opts);
|
|
1583
|
+
}
|
|
971
1584
|
_update(opts) {
|
|
972
|
-
|
|
1585
|
+
const mask = opts.mask;
|
|
1586
|
+
if (mask) opts.validate = value => value.search(mask) >= 0;
|
|
973
1587
|
super._update(opts);
|
|
974
1588
|
}
|
|
975
1589
|
}
|
|
976
1590
|
IMask.MaskedRegExp = MaskedRegExp;
|
|
977
1591
|
|
|
978
|
-
const _excluded$2 = ["_blocks"];
|
|
979
1592
|
class MaskedPattern extends Masked {
|
|
980
|
-
constructor() {
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1593
|
+
constructor(opts) {
|
|
1594
|
+
super({
|
|
1595
|
+
...MaskedPattern.DEFAULTS,
|
|
1596
|
+
...opts,
|
|
1597
|
+
definitions: Object.assign({}, PatternInputDefinition.DEFAULT_DEFINITIONS, opts == null ? void 0 : opts.definitions)
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1600
|
+
updateOptions(opts) {
|
|
1601
|
+
super.updateOptions(opts);
|
|
984
1602
|
}
|
|
985
|
-
_update() {
|
|
986
|
-
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1603
|
+
_update(opts) {
|
|
987
1604
|
opts.definitions = Object.assign({}, this.definitions, opts.definitions);
|
|
988
1605
|
super._update(opts);
|
|
989
1606
|
this._rebuildMask();
|
|
@@ -991,30 +1608,40 @@ class MaskedPattern extends Masked {
|
|
|
991
1608
|
_rebuildMask() {
|
|
992
1609
|
const defs = this.definitions;
|
|
993
1610
|
this._blocks = [];
|
|
1611
|
+
this.exposeBlock = undefined;
|
|
994
1612
|
this._stops = [];
|
|
995
1613
|
this._maskedBlocks = {};
|
|
996
|
-
|
|
1614
|
+
const pattern = this.mask;
|
|
997
1615
|
if (!pattern || !defs) return;
|
|
998
1616
|
let unmaskingBlock = false;
|
|
999
1617
|
let optionalBlock = false;
|
|
1000
1618
|
for (let i = 0; i < pattern.length; ++i) {
|
|
1001
|
-
var _defs$char, _defs$char2;
|
|
1002
1619
|
if (this.blocks) {
|
|
1003
1620
|
const p = pattern.slice(i);
|
|
1004
1621
|
const bNames = Object.keys(this.blocks).filter(bName => p.indexOf(bName) === 0);
|
|
1005
1622
|
bNames.sort((a, b) => b.length - a.length);
|
|
1006
1623
|
const bName = bNames[0];
|
|
1007
1624
|
if (bName) {
|
|
1008
|
-
const
|
|
1009
|
-
|
|
1625
|
+
const {
|
|
1626
|
+
expose,
|
|
1627
|
+
repeat,
|
|
1628
|
+
...bOpts
|
|
1629
|
+
} = normalizeOpts(this.blocks[bName]);
|
|
1630
|
+
const blockOpts = {
|
|
1010
1631
|
lazy: this.lazy,
|
|
1011
1632
|
eager: this.eager,
|
|
1012
1633
|
placeholderChar: this.placeholderChar,
|
|
1013
1634
|
displayChar: this.displayChar,
|
|
1014
|
-
overwrite: this.overwrite
|
|
1015
|
-
|
|
1635
|
+
overwrite: this.overwrite,
|
|
1636
|
+
autofix: this.autofix,
|
|
1637
|
+
...bOpts,
|
|
1638
|
+
repeat,
|
|
1639
|
+
parent: this
|
|
1640
|
+
};
|
|
1641
|
+
const maskedBlock = repeat != null ? new IMask.RepeatBlock(blockOpts ) : createMask(blockOpts);
|
|
1016
1642
|
if (maskedBlock) {
|
|
1017
1643
|
this._blocks.push(maskedBlock);
|
|
1644
|
+
if (expose) this.exposeBlock = maskedBlock;
|
|
1018
1645
|
if (!this._maskedBlocks[bName]) this._maskedBlocks[bName] = [];
|
|
1019
1646
|
this._maskedBlocks[bName].push(this._blocks.length - 1);
|
|
1020
1647
|
}
|
|
@@ -1042,17 +1669,15 @@ class MaskedPattern extends Masked {
|
|
|
1042
1669
|
if (!char) break;
|
|
1043
1670
|
isInput = false;
|
|
1044
1671
|
}
|
|
1045
|
-
const
|
|
1046
|
-
mask: defs[char]
|
|
1047
|
-
};
|
|
1048
|
-
const def = isInput ? new PatternInputDefinition(Object.assign({
|
|
1049
|
-
parent: this,
|
|
1672
|
+
const def = isInput ? new PatternInputDefinition({
|
|
1050
1673
|
isOptional: optionalBlock,
|
|
1051
1674
|
lazy: this.lazy,
|
|
1052
1675
|
eager: this.eager,
|
|
1053
1676
|
placeholderChar: this.placeholderChar,
|
|
1054
|
-
displayChar: this.displayChar
|
|
1055
|
-
|
|
1677
|
+
displayChar: this.displayChar,
|
|
1678
|
+
...normalizeOpts(defs[char]),
|
|
1679
|
+
parent: this
|
|
1680
|
+
}) : new PatternFixedDefinition({
|
|
1056
1681
|
char,
|
|
1057
1682
|
eager: this.eager,
|
|
1058
1683
|
isUnmasking: unmaskingBlock
|
|
@@ -1061,15 +1686,20 @@ class MaskedPattern extends Masked {
|
|
|
1061
1686
|
}
|
|
1062
1687
|
}
|
|
1063
1688
|
get state() {
|
|
1064
|
-
return
|
|
1689
|
+
return {
|
|
1690
|
+
...super.state,
|
|
1065
1691
|
_blocks: this._blocks.map(b => b.state)
|
|
1066
|
-
}
|
|
1692
|
+
};
|
|
1067
1693
|
}
|
|
1068
1694
|
set state(state) {
|
|
1695
|
+
if (!state) {
|
|
1696
|
+
this.reset();
|
|
1697
|
+
return;
|
|
1698
|
+
}
|
|
1069
1699
|
const {
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1700
|
+
_blocks,
|
|
1701
|
+
...maskedState
|
|
1702
|
+
} = state;
|
|
1073
1703
|
this._blocks.forEach((b, bi) => b.state = _blocks[bi]);
|
|
1074
1704
|
super.state = maskedState;
|
|
1075
1705
|
}
|
|
@@ -1078,7 +1708,7 @@ class MaskedPattern extends Masked {
|
|
|
1078
1708
|
this._blocks.forEach(b => b.reset());
|
|
1079
1709
|
}
|
|
1080
1710
|
get isComplete() {
|
|
1081
|
-
return this._blocks.every(b => b.isComplete);
|
|
1711
|
+
return this.exposeBlock ? this.exposeBlock.isComplete : this._blocks.every(b => b.isComplete);
|
|
1082
1712
|
}
|
|
1083
1713
|
get isFilled() {
|
|
1084
1714
|
return this._blocks.every(b => b.isFilled);
|
|
@@ -1094,16 +1724,38 @@ class MaskedPattern extends Masked {
|
|
|
1094
1724
|
super.doCommit();
|
|
1095
1725
|
}
|
|
1096
1726
|
get unmaskedValue() {
|
|
1097
|
-
return this._blocks.reduce((str, b) => str += b.unmaskedValue, '');
|
|
1727
|
+
return this.exposeBlock ? this.exposeBlock.unmaskedValue : this._blocks.reduce((str, b) => str += b.unmaskedValue, '');
|
|
1098
1728
|
}
|
|
1099
1729
|
set unmaskedValue(unmaskedValue) {
|
|
1100
|
-
|
|
1730
|
+
if (this.exposeBlock) {
|
|
1731
|
+
const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
|
|
1732
|
+
this.exposeBlock.unmaskedValue = unmaskedValue;
|
|
1733
|
+
this.appendTail(tail);
|
|
1734
|
+
this.doCommit();
|
|
1735
|
+
} else super.unmaskedValue = unmaskedValue;
|
|
1101
1736
|
}
|
|
1102
1737
|
get value() {
|
|
1103
|
-
return this.
|
|
1738
|
+
return this.exposeBlock ? this.exposeBlock.value :
|
|
1739
|
+
this._blocks.reduce((str, b) => str += b.value, '');
|
|
1104
1740
|
}
|
|
1105
1741
|
set value(value) {
|
|
1106
|
-
|
|
1742
|
+
if (this.exposeBlock) {
|
|
1743
|
+
const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
|
|
1744
|
+
this.exposeBlock.value = value;
|
|
1745
|
+
this.appendTail(tail);
|
|
1746
|
+
this.doCommit();
|
|
1747
|
+
} else super.value = value;
|
|
1748
|
+
}
|
|
1749
|
+
get typedValue() {
|
|
1750
|
+
return this.exposeBlock ? this.exposeBlock.typedValue : super.typedValue;
|
|
1751
|
+
}
|
|
1752
|
+
set typedValue(value) {
|
|
1753
|
+
if (this.exposeBlock) {
|
|
1754
|
+
const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
|
|
1755
|
+
this.exposeBlock.typedValue = value;
|
|
1756
|
+
this.appendTail(tail);
|
|
1757
|
+
this.doCommit();
|
|
1758
|
+
} else super.typedValue = value;
|
|
1107
1759
|
}
|
|
1108
1760
|
get displayValue() {
|
|
1109
1761
|
return this._blocks.reduce((str, b) => str += b.displayValue, '');
|
|
@@ -1114,7 +1766,7 @@ class MaskedPattern extends Masked {
|
|
|
1114
1766
|
_appendEager() {
|
|
1115
1767
|
var _this$_mapPosToBlock;
|
|
1116
1768
|
const details = new ChangeDetails();
|
|
1117
|
-
let startBlockIndex = (_this$_mapPosToBlock = this._mapPosToBlock(this.
|
|
1769
|
+
let startBlockIndex = (_this$_mapPosToBlock = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : _this$_mapPosToBlock.index;
|
|
1118
1770
|
if (startBlockIndex == null) return details;
|
|
1119
1771
|
if (this._blocks[startBlockIndex].isFilled) ++startBlockIndex;
|
|
1120
1772
|
for (let bi = startBlockIndex; bi < this._blocks.length; ++bi) {
|
|
@@ -1124,27 +1776,31 @@ class MaskedPattern extends Masked {
|
|
|
1124
1776
|
}
|
|
1125
1777
|
return details;
|
|
1126
1778
|
}
|
|
1127
|
-
_appendCharRaw(ch) {
|
|
1128
|
-
|
|
1129
|
-
|
|
1779
|
+
_appendCharRaw(ch, flags) {
|
|
1780
|
+
if (flags === void 0) {
|
|
1781
|
+
flags = {};
|
|
1782
|
+
}
|
|
1783
|
+
const blockIter = this._mapPosToBlock(this.displayValue.length);
|
|
1130
1784
|
const details = new ChangeDetails();
|
|
1131
1785
|
if (!blockIter) return details;
|
|
1132
|
-
for (let bi = blockIter.index
|
|
1133
|
-
var _flags$_beforeTailSta
|
|
1134
|
-
const
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
}));
|
|
1139
|
-
const skip = blockDetails.skip;
|
|
1786
|
+
for (let bi = blockIter.index, block; block = this._blocks[bi]; ++bi) {
|
|
1787
|
+
var _flags$_beforeTailSta;
|
|
1788
|
+
const blockDetails = block._appendChar(ch, {
|
|
1789
|
+
...flags,
|
|
1790
|
+
_beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) == null || (_flags$_beforeTailSta = _flags$_beforeTailSta._blocks) == null ? void 0 : _flags$_beforeTailSta[bi]
|
|
1791
|
+
});
|
|
1140
1792
|
details.aggregate(blockDetails);
|
|
1141
|
-
if (
|
|
1793
|
+
if (blockDetails.consumed) break;
|
|
1142
1794
|
}
|
|
1143
1795
|
return details;
|
|
1144
1796
|
}
|
|
1145
|
-
extractTail() {
|
|
1146
|
-
|
|
1147
|
-
|
|
1797
|
+
extractTail(fromPos, toPos) {
|
|
1798
|
+
if (fromPos === void 0) {
|
|
1799
|
+
fromPos = 0;
|
|
1800
|
+
}
|
|
1801
|
+
if (toPos === void 0) {
|
|
1802
|
+
toPos = this.displayValue.length;
|
|
1803
|
+
}
|
|
1148
1804
|
const chunkTail = new ChunksTailDetails();
|
|
1149
1805
|
if (fromPos === toPos) return chunkTail;
|
|
1150
1806
|
this._forEachBlocksInRange(fromPos, toPos, (b, bi, bFromPos, bToPos) => {
|
|
@@ -1156,10 +1812,16 @@ class MaskedPattern extends Masked {
|
|
|
1156
1812
|
});
|
|
1157
1813
|
return chunkTail;
|
|
1158
1814
|
}
|
|
1159
|
-
extractInput() {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1815
|
+
extractInput(fromPos, toPos, flags) {
|
|
1816
|
+
if (fromPos === void 0) {
|
|
1817
|
+
fromPos = 0;
|
|
1818
|
+
}
|
|
1819
|
+
if (toPos === void 0) {
|
|
1820
|
+
toPos = this.displayValue.length;
|
|
1821
|
+
}
|
|
1822
|
+
if (flags === void 0) {
|
|
1823
|
+
flags = {};
|
|
1824
|
+
}
|
|
1163
1825
|
if (fromPos === toPos) return '';
|
|
1164
1826
|
let input = '';
|
|
1165
1827
|
this._forEachBlocksInRange(fromPos, toPos, (b, _, fromPos, toPos) => {
|
|
@@ -1178,16 +1840,14 @@ class MaskedPattern extends Masked {
|
|
|
1178
1840
|
_appendPlaceholder(toBlockIndex) {
|
|
1179
1841
|
const details = new ChangeDetails();
|
|
1180
1842
|
if (this.lazy && toBlockIndex == null) return details;
|
|
1181
|
-
const startBlockIter = this._mapPosToBlock(this.
|
|
1843
|
+
const startBlockIter = this._mapPosToBlock(this.displayValue.length);
|
|
1182
1844
|
if (!startBlockIter) return details;
|
|
1183
1845
|
const startBlockIndex = startBlockIter.index;
|
|
1184
1846
|
const endBlockIndex = toBlockIndex != null ? toBlockIndex : this._blocks.length;
|
|
1185
1847
|
this._blocks.slice(startBlockIndex, endBlockIndex).forEach(b => {
|
|
1186
1848
|
if (!b.lazy || toBlockIndex != null) {
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
this._value += bDetails.inserted;
|
|
1190
|
-
details.aggregate(bDetails);
|
|
1849
|
+
var _blocks2;
|
|
1850
|
+
details.aggregate(b._appendPlaceholder((_blocks2 = b._blocks) == null ? void 0 : _blocks2.length));
|
|
1191
1851
|
}
|
|
1192
1852
|
});
|
|
1193
1853
|
return details;
|
|
@@ -1197,7 +1857,7 @@ class MaskedPattern extends Masked {
|
|
|
1197
1857
|
for (let bi = 0; bi < this._blocks.length; ++bi) {
|
|
1198
1858
|
const block = this._blocks[bi];
|
|
1199
1859
|
const blockStartPos = accVal.length;
|
|
1200
|
-
accVal += block.
|
|
1860
|
+
accVal += block.displayValue;
|
|
1201
1861
|
if (pos <= accVal.length) {
|
|
1202
1862
|
return {
|
|
1203
1863
|
index: bi,
|
|
@@ -1207,44 +1867,51 @@ class MaskedPattern extends Masked {
|
|
|
1207
1867
|
}
|
|
1208
1868
|
}
|
|
1209
1869
|
_blockStartPos(blockIndex) {
|
|
1210
|
-
return this._blocks.slice(0, blockIndex).reduce((pos, b) => pos += b.
|
|
1870
|
+
return this._blocks.slice(0, blockIndex).reduce((pos, b) => pos += b.displayValue.length, 0);
|
|
1211
1871
|
}
|
|
1212
|
-
_forEachBlocksInRange(fromPos) {
|
|
1213
|
-
|
|
1214
|
-
|
|
1872
|
+
_forEachBlocksInRange(fromPos, toPos, fn) {
|
|
1873
|
+
if (toPos === void 0) {
|
|
1874
|
+
toPos = this.displayValue.length;
|
|
1875
|
+
}
|
|
1215
1876
|
const fromBlockIter = this._mapPosToBlock(fromPos);
|
|
1216
1877
|
if (fromBlockIter) {
|
|
1217
1878
|
const toBlockIter = this._mapPosToBlock(toPos);
|
|
1218
1879
|
const isSameBlock = toBlockIter && fromBlockIter.index === toBlockIter.index;
|
|
1219
1880
|
const fromBlockStartPos = fromBlockIter.offset;
|
|
1220
|
-
const fromBlockEndPos = toBlockIter && isSameBlock ? toBlockIter.offset : this._blocks[fromBlockIter.index].
|
|
1881
|
+
const fromBlockEndPos = toBlockIter && isSameBlock ? toBlockIter.offset : this._blocks[fromBlockIter.index].displayValue.length;
|
|
1221
1882
|
fn(this._blocks[fromBlockIter.index], fromBlockIter.index, fromBlockStartPos, fromBlockEndPos);
|
|
1222
1883
|
if (toBlockIter && !isSameBlock) {
|
|
1223
1884
|
for (let bi = fromBlockIter.index + 1; bi < toBlockIter.index; ++bi) {
|
|
1224
|
-
fn(this._blocks[bi], bi, 0, this._blocks[bi].
|
|
1885
|
+
fn(this._blocks[bi], bi, 0, this._blocks[bi].displayValue.length);
|
|
1225
1886
|
}
|
|
1226
1887
|
fn(this._blocks[toBlockIter.index], toBlockIter.index, 0, toBlockIter.offset);
|
|
1227
1888
|
}
|
|
1228
1889
|
}
|
|
1229
1890
|
}
|
|
1230
|
-
remove() {
|
|
1231
|
-
|
|
1232
|
-
|
|
1891
|
+
remove(fromPos, toPos) {
|
|
1892
|
+
if (fromPos === void 0) {
|
|
1893
|
+
fromPos = 0;
|
|
1894
|
+
}
|
|
1895
|
+
if (toPos === void 0) {
|
|
1896
|
+
toPos = this.displayValue.length;
|
|
1897
|
+
}
|
|
1233
1898
|
const removeDetails = super.remove(fromPos, toPos);
|
|
1234
1899
|
this._forEachBlocksInRange(fromPos, toPos, (b, _, bFromPos, bToPos) => {
|
|
1235
1900
|
removeDetails.aggregate(b.remove(bFromPos, bToPos));
|
|
1236
1901
|
});
|
|
1237
1902
|
return removeDetails;
|
|
1238
1903
|
}
|
|
1239
|
-
nearestInputPos(cursorPos) {
|
|
1240
|
-
|
|
1904
|
+
nearestInputPos(cursorPos, direction) {
|
|
1905
|
+
if (direction === void 0) {
|
|
1906
|
+
direction = DIRECTION.NONE;
|
|
1907
|
+
}
|
|
1241
1908
|
if (!this._blocks.length) return 0;
|
|
1242
1909
|
const cursor = new PatternCursor(this, cursorPos);
|
|
1243
1910
|
if (direction === DIRECTION.NONE) {
|
|
1244
1911
|
if (cursor.pushRightBeforeInput()) return cursor.pos;
|
|
1245
1912
|
cursor.popState();
|
|
1246
1913
|
if (cursor.pushLeftBeforeInput()) return cursor.pos;
|
|
1247
|
-
return this.
|
|
1914
|
+
return this.displayValue.length;
|
|
1248
1915
|
}
|
|
1249
1916
|
if (direction === DIRECTION.LEFT || direction === DIRECTION.FORCE_LEFT) {
|
|
1250
1917
|
if (direction === DIRECTION.LEFT) {
|
|
@@ -1275,7 +1942,7 @@ class MaskedPattern extends Masked {
|
|
|
1275
1942
|
cursor.pushRightBeforeInput();
|
|
1276
1943
|
cursor.pushRightBeforeRequired();
|
|
1277
1944
|
if (cursor.pushRightBeforeFilled()) return cursor.pos;
|
|
1278
|
-
if (direction === DIRECTION.FORCE_RIGHT) return this.
|
|
1945
|
+
if (direction === DIRECTION.FORCE_RIGHT) return this.displayValue.length;
|
|
1279
1946
|
cursor.popState();
|
|
1280
1947
|
if (cursor.ok) return cursor.pos;
|
|
1281
1948
|
cursor.popState();
|
|
@@ -1284,9 +1951,13 @@ class MaskedPattern extends Masked {
|
|
|
1284
1951
|
}
|
|
1285
1952
|
return cursorPos;
|
|
1286
1953
|
}
|
|
1287
|
-
totalInputPositions() {
|
|
1288
|
-
|
|
1289
|
-
|
|
1954
|
+
totalInputPositions(fromPos, toPos) {
|
|
1955
|
+
if (fromPos === void 0) {
|
|
1956
|
+
fromPos = 0;
|
|
1957
|
+
}
|
|
1958
|
+
if (toPos === void 0) {
|
|
1959
|
+
toPos = this.displayValue.length;
|
|
1960
|
+
}
|
|
1290
1961
|
let total = 0;
|
|
1291
1962
|
this._forEachBlocksInRange(fromPos, toPos, (b, _, bFromPos, bToPos) => {
|
|
1292
1963
|
total += b.totalInputPositions(bFromPos, bToPos);
|
|
@@ -1301,8 +1972,14 @@ class MaskedPattern extends Masked {
|
|
|
1301
1972
|
if (!indices) return [];
|
|
1302
1973
|
return indices.map(gi => this._blocks[gi]);
|
|
1303
1974
|
}
|
|
1975
|
+
pad(flags) {
|
|
1976
|
+
const details = new ChangeDetails();
|
|
1977
|
+
this._forEachBlocksInRange(0, this.displayValue.length, b => details.aggregate(b.pad(flags)));
|
|
1978
|
+
return details;
|
|
1979
|
+
}
|
|
1304
1980
|
}
|
|
1305
1981
|
MaskedPattern.DEFAULTS = {
|
|
1982
|
+
...Masked.DEFAULTS,
|
|
1306
1983
|
lazy: true,
|
|
1307
1984
|
placeholderChar: '_'
|
|
1308
1985
|
};
|
|
@@ -1316,21 +1993,30 @@ class MaskedRange extends MaskedPattern {
|
|
|
1316
1993
|
get _matchFrom() {
|
|
1317
1994
|
return this.maxLength - String(this.from).length;
|
|
1318
1995
|
}
|
|
1996
|
+
constructor(opts) {
|
|
1997
|
+
super(opts);
|
|
1998
|
+
}
|
|
1999
|
+
updateOptions(opts) {
|
|
2000
|
+
super.updateOptions(opts);
|
|
2001
|
+
}
|
|
1319
2002
|
_update(opts) {
|
|
1320
|
-
|
|
1321
|
-
to
|
|
1322
|
-
from
|
|
1323
|
-
maxLength
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
2003
|
+
const {
|
|
2004
|
+
to = this.to || 0,
|
|
2005
|
+
from = this.from || 0,
|
|
2006
|
+
maxLength = this.maxLength || 0,
|
|
2007
|
+
autofix = this.autofix,
|
|
2008
|
+
...patternOpts
|
|
2009
|
+
} = opts;
|
|
2010
|
+
this.to = to;
|
|
2011
|
+
this.from = from;
|
|
2012
|
+
this.maxLength = Math.max(String(to).length, maxLength);
|
|
2013
|
+
this.autofix = autofix;
|
|
2014
|
+
const fromStr = String(this.from).padStart(this.maxLength, '0');
|
|
2015
|
+
const toStr = String(this.to).padStart(this.maxLength, '0');
|
|
1330
2016
|
let sameCharsCount = 0;
|
|
1331
2017
|
while (sameCharsCount < toStr.length && toStr[sameCharsCount] === fromStr[sameCharsCount]) ++sameCharsCount;
|
|
1332
|
-
|
|
1333
|
-
super._update(
|
|
2018
|
+
patternOpts.mask = toStr.slice(0, sameCharsCount).replace(/0/g, '\\0') + '0'.repeat(this.maxLength - sameCharsCount);
|
|
2019
|
+
super._update(patternOpts);
|
|
1334
2020
|
}
|
|
1335
2021
|
get isComplete() {
|
|
1336
2022
|
return super.isComplete && Boolean(this.value);
|
|
@@ -1347,64 +2033,109 @@ class MaskedRange extends MaskedPattern {
|
|
|
1347
2033
|
maxstr = maxstr.padEnd(this.maxLength, '9');
|
|
1348
2034
|
return [minstr, maxstr];
|
|
1349
2035
|
}
|
|
1350
|
-
|
|
1351
|
-
|
|
2036
|
+
doPrepareChar(ch, flags) {
|
|
2037
|
+
if (flags === void 0) {
|
|
2038
|
+
flags = {};
|
|
2039
|
+
}
|
|
1352
2040
|
let details;
|
|
1353
|
-
[ch, details] =
|
|
1354
|
-
if (!
|
|
2041
|
+
[ch, details] = super.doPrepareChar(ch.replace(/\D/g, ''), flags);
|
|
2042
|
+
if (!ch) details.skip = !this.isComplete;
|
|
2043
|
+
return [ch, details];
|
|
2044
|
+
}
|
|
2045
|
+
_appendCharRaw(ch, flags) {
|
|
2046
|
+
if (flags === void 0) {
|
|
2047
|
+
flags = {};
|
|
2048
|
+
}
|
|
2049
|
+
if (!this.autofix || this.value.length + 1 > this.maxLength) return super._appendCharRaw(ch, flags);
|
|
1355
2050
|
const fromStr = String(this.from).padStart(this.maxLength, '0');
|
|
1356
2051
|
const toStr = String(this.to).padStart(this.maxLength, '0');
|
|
1357
|
-
|
|
1358
|
-
if (
|
|
1359
|
-
const [minstr, maxstr] = this.boundaries(nextVal);
|
|
1360
|
-
if (Number(maxstr) < this.from) return fromStr[nextVal.length - 1];
|
|
2052
|
+
const [minstr, maxstr] = this.boundaries(this.value + ch);
|
|
2053
|
+
if (Number(maxstr) < this.from) return super._appendCharRaw(fromStr[this.value.length], flags);
|
|
1361
2054
|
if (Number(minstr) > this.to) {
|
|
1362
|
-
if (this.autofix === 'pad' &&
|
|
1363
|
-
return [
|
|
2055
|
+
if (!flags.tail && this.autofix === 'pad' && this.value.length + 1 < this.maxLength) {
|
|
2056
|
+
return super._appendCharRaw(fromStr[this.value.length], flags).aggregate(this._appendCharRaw(ch, flags));
|
|
1364
2057
|
}
|
|
1365
|
-
return toStr[
|
|
2058
|
+
return super._appendCharRaw(toStr[this.value.length], flags);
|
|
1366
2059
|
}
|
|
1367
|
-
return ch;
|
|
2060
|
+
return super._appendCharRaw(ch, flags);
|
|
1368
2061
|
}
|
|
1369
|
-
doValidate() {
|
|
2062
|
+
doValidate(flags) {
|
|
1370
2063
|
const str = this.value;
|
|
1371
2064
|
const firstNonZero = str.search(/[^0]/);
|
|
1372
2065
|
if (firstNonZero === -1 && str.length <= this._matchFrom) return true;
|
|
1373
2066
|
const [minstr, maxstr] = this.boundaries(str);
|
|
1374
|
-
return this.from <= Number(maxstr) && Number(minstr) <= this.to && super.doValidate(
|
|
2067
|
+
return this.from <= Number(maxstr) && Number(minstr) <= this.to && super.doValidate(flags);
|
|
2068
|
+
}
|
|
2069
|
+
pad(flags) {
|
|
2070
|
+
const details = new ChangeDetails();
|
|
2071
|
+
if (this.value.length === this.maxLength) return details;
|
|
2072
|
+
const value = this.value;
|
|
2073
|
+
const padLength = this.maxLength - this.value.length;
|
|
2074
|
+
if (padLength) {
|
|
2075
|
+
this.reset();
|
|
2076
|
+
for (let i = 0; i < padLength; ++i) {
|
|
2077
|
+
details.aggregate(super._appendCharRaw('0', flags));
|
|
2078
|
+
}
|
|
2079
|
+
value.split('').forEach(ch => this._appendCharRaw(ch));
|
|
2080
|
+
}
|
|
2081
|
+
return details;
|
|
1375
2082
|
}
|
|
1376
2083
|
}
|
|
1377
2084
|
IMask.MaskedRange = MaskedRange;
|
|
1378
2085
|
|
|
2086
|
+
const DefaultPattern = 'd{.}`m{.}`Y';
|
|
1379
2087
|
class MaskedDate extends MaskedPattern {
|
|
2088
|
+
static extractPatternOptions(opts) {
|
|
2089
|
+
const {
|
|
2090
|
+
mask,
|
|
2091
|
+
pattern,
|
|
2092
|
+
...patternOpts
|
|
2093
|
+
} = opts;
|
|
2094
|
+
return {
|
|
2095
|
+
...patternOpts,
|
|
2096
|
+
mask: isString(mask) ? mask : pattern
|
|
2097
|
+
};
|
|
2098
|
+
}
|
|
1380
2099
|
constructor(opts) {
|
|
1381
|
-
super(
|
|
2100
|
+
super(MaskedDate.extractPatternOptions({
|
|
2101
|
+
...MaskedDate.DEFAULTS,
|
|
2102
|
+
...opts
|
|
2103
|
+
}));
|
|
2104
|
+
}
|
|
2105
|
+
updateOptions(opts) {
|
|
2106
|
+
super.updateOptions(opts);
|
|
1382
2107
|
}
|
|
1383
2108
|
_update(opts) {
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
opts
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
2109
|
+
const {
|
|
2110
|
+
mask,
|
|
2111
|
+
pattern,
|
|
2112
|
+
blocks,
|
|
2113
|
+
...patternOpts
|
|
2114
|
+
} = {
|
|
2115
|
+
...MaskedDate.DEFAULTS,
|
|
2116
|
+
...opts
|
|
2117
|
+
};
|
|
2118
|
+
const patternBlocks = Object.assign({}, MaskedDate.GET_DEFAULT_BLOCKS());
|
|
2119
|
+
if (opts.min) patternBlocks.Y.from = opts.min.getFullYear();
|
|
2120
|
+
if (opts.max) patternBlocks.Y.to = opts.max.getFullYear();
|
|
2121
|
+
if (opts.min && opts.max && patternBlocks.Y.from === patternBlocks.Y.to) {
|
|
2122
|
+
patternBlocks.m.from = opts.min.getMonth() + 1;
|
|
2123
|
+
patternBlocks.m.to = opts.max.getMonth() + 1;
|
|
2124
|
+
if (patternBlocks.m.from === patternBlocks.m.to) {
|
|
2125
|
+
patternBlocks.d.from = opts.min.getDate();
|
|
2126
|
+
patternBlocks.d.to = opts.max.getDate();
|
|
1396
2127
|
}
|
|
1397
2128
|
}
|
|
1398
|
-
Object.assign(
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
2129
|
+
Object.assign(patternBlocks, this.blocks, blocks);
|
|
2130
|
+
super._update({
|
|
2131
|
+
...patternOpts,
|
|
2132
|
+
mask: isString(mask) ? mask : pattern,
|
|
2133
|
+
blocks: patternBlocks
|
|
1402
2134
|
});
|
|
1403
|
-
super._update(opts);
|
|
1404
2135
|
}
|
|
1405
|
-
doValidate() {
|
|
2136
|
+
doValidate(flags) {
|
|
1406
2137
|
const date = this.date;
|
|
1407
|
-
return super.doValidate(
|
|
2138
|
+
return super.doValidate(flags) && (!this.isComplete || this.isDateExist(this.value) && date != null && (this.min == null || this.min <= date) && (this.max == null || date <= this.max));
|
|
1408
2139
|
}
|
|
1409
2140
|
isDateExist(str) {
|
|
1410
2141
|
return this.format(this.parse(str, this), this).indexOf(str) >= 0;
|
|
@@ -1424,21 +2155,10 @@ class MaskedDate extends MaskedPattern {
|
|
|
1424
2155
|
maskEquals(mask) {
|
|
1425
2156
|
return mask === Date || super.maskEquals(mask);
|
|
1426
2157
|
}
|
|
1427
|
-
|
|
1428
|
-
MaskedDate.
|
|
1429
|
-
pattern: 'd{.}`m{.}`Y',
|
|
1430
|
-
format: date => {
|
|
1431
|
-
if (!date) return '';
|
|
1432
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
1433
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
1434
|
-
const year = date.getFullYear();
|
|
1435
|
-
return [day, month, year].join('.');
|
|
1436
|
-
},
|
|
1437
|
-
parse: str => {
|
|
1438
|
-
const [day, month, year] = str.split('.');
|
|
1439
|
-
return new Date(year, month - 1, day);
|
|
2158
|
+
optionsIsChanged(opts) {
|
|
2159
|
+
return super.optionsIsChanged(MaskedDate.extractPatternOptions(opts));
|
|
1440
2160
|
}
|
|
1441
|
-
}
|
|
2161
|
+
}
|
|
1442
2162
|
MaskedDate.GET_DEFAULT_BLOCKS = () => ({
|
|
1443
2163
|
d: {
|
|
1444
2164
|
mask: MaskedRange,
|
|
@@ -1458,389 +2178,456 @@ MaskedDate.GET_DEFAULT_BLOCKS = () => ({
|
|
|
1458
2178
|
to: 9999
|
|
1459
2179
|
}
|
|
1460
2180
|
});
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
} catch (e) {}
|
|
1476
|
-
return end != null ? end : this.value.length;
|
|
1477
|
-
}
|
|
1478
|
-
select(start, end) {
|
|
1479
|
-
if (start == null || end == null || start === this.selectionStart && end === this.selectionEnd) return;
|
|
1480
|
-
try {
|
|
1481
|
-
this._unsafeSelect(start, end);
|
|
1482
|
-
} catch (e) {}
|
|
1483
|
-
}
|
|
1484
|
-
_unsafeSelect(start, end) {}
|
|
1485
|
-
get isActive() {
|
|
1486
|
-
return false;
|
|
2181
|
+
MaskedDate.DEFAULTS = {
|
|
2182
|
+
...MaskedPattern.DEFAULTS,
|
|
2183
|
+
mask: Date,
|
|
2184
|
+
pattern: DefaultPattern,
|
|
2185
|
+
format: (date, masked) => {
|
|
2186
|
+
if (!date) return '';
|
|
2187
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
2188
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
2189
|
+
const year = date.getFullYear();
|
|
2190
|
+
return [day, month, year].join('.');
|
|
2191
|
+
},
|
|
2192
|
+
parse: (str, masked) => {
|
|
2193
|
+
const [day, month, year] = str.split('.').map(Number);
|
|
2194
|
+
return new Date(year, month - 1, day);
|
|
1487
2195
|
}
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
}
|
|
1491
|
-
IMask.MaskElement = MaskElement;
|
|
2196
|
+
};
|
|
2197
|
+
IMask.MaskedDate = MaskedDate;
|
|
1492
2198
|
|
|
1493
|
-
class
|
|
1494
|
-
constructor(
|
|
1495
|
-
super(
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
var _this$input$getRootNo, _this$input$getRootNo2, _this$input;
|
|
1501
|
-
return (_this$input$getRootNo = (_this$input$getRootNo2 = (_this$input = this.input).getRootNode) === null || _this$input$getRootNo2 === void 0 ? void 0 : _this$input$getRootNo2.call(_this$input)) !== null && _this$input$getRootNo !== void 0 ? _this$input$getRootNo : document;
|
|
1502
|
-
}
|
|
1503
|
-
get isActive() {
|
|
1504
|
-
return this.input === this.rootElement.activeElement;
|
|
1505
|
-
}
|
|
1506
|
-
get _unsafeSelectionStart() {
|
|
1507
|
-
return this.input.selectionStart;
|
|
1508
|
-
}
|
|
1509
|
-
get _unsafeSelectionEnd() {
|
|
1510
|
-
return this.input.selectionEnd;
|
|
1511
|
-
}
|
|
1512
|
-
_unsafeSelect(start, end) {
|
|
1513
|
-
this.input.setSelectionRange(start, end);
|
|
1514
|
-
}
|
|
1515
|
-
get value() {
|
|
1516
|
-
return this.input.value;
|
|
1517
|
-
}
|
|
1518
|
-
set value(value) {
|
|
1519
|
-
this.input.value = value;
|
|
2199
|
+
class MaskedDynamic extends Masked {
|
|
2200
|
+
constructor(opts) {
|
|
2201
|
+
super({
|
|
2202
|
+
...MaskedDynamic.DEFAULTS,
|
|
2203
|
+
...opts
|
|
2204
|
+
});
|
|
2205
|
+
this.currentMask = undefined;
|
|
1520
2206
|
}
|
|
1521
|
-
|
|
1522
|
-
|
|
2207
|
+
updateOptions(opts) {
|
|
2208
|
+
super.updateOptions(opts);
|
|
1523
2209
|
}
|
|
1524
|
-
|
|
1525
|
-
|
|
2210
|
+
_update(opts) {
|
|
2211
|
+
super._update(opts);
|
|
2212
|
+
if ('mask' in opts) {
|
|
2213
|
+
this.exposeMask = undefined;
|
|
2214
|
+
this.compiledMasks = Array.isArray(opts.mask) ? opts.mask.map(m => {
|
|
2215
|
+
const {
|
|
2216
|
+
expose,
|
|
2217
|
+
...maskOpts
|
|
2218
|
+
} = normalizeOpts(m);
|
|
2219
|
+
const masked = createMask({
|
|
2220
|
+
overwrite: this._overwrite,
|
|
2221
|
+
eager: this._eager,
|
|
2222
|
+
skipInvalid: this._skipInvalid,
|
|
2223
|
+
...maskOpts
|
|
2224
|
+
});
|
|
2225
|
+
if (expose) this.exposeMask = masked;
|
|
2226
|
+
return masked;
|
|
2227
|
+
}) : [];
|
|
2228
|
+
}
|
|
1526
2229
|
}
|
|
1527
|
-
|
|
1528
|
-
if (
|
|
1529
|
-
|
|
1530
|
-
delete this._handlers[event];
|
|
2230
|
+
_appendCharRaw(ch, flags) {
|
|
2231
|
+
if (flags === void 0) {
|
|
2232
|
+
flags = {};
|
|
1531
2233
|
}
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
this.
|
|
2234
|
+
const details = this._applyDispatch(ch, flags);
|
|
2235
|
+
if (this.currentMask) {
|
|
2236
|
+
details.aggregate(this.currentMask._appendChar(ch, this.currentMaskFlags(flags)));
|
|
1535
2237
|
}
|
|
2238
|
+
return details;
|
|
1536
2239
|
}
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
input: 'input',
|
|
1541
|
-
drop: 'drop',
|
|
1542
|
-
click: 'click',
|
|
1543
|
-
focus: 'focus',
|
|
1544
|
-
commit: 'blur'
|
|
1545
|
-
};
|
|
1546
|
-
IMask.HTMLMaskElement = HTMLMaskElement;
|
|
1547
|
-
|
|
1548
|
-
class HTMLContenteditableMaskElement extends HTMLMaskElement {
|
|
1549
|
-
get _unsafeSelectionStart() {
|
|
1550
|
-
const root = this.rootElement;
|
|
1551
|
-
const selection = root.getSelection && root.getSelection();
|
|
1552
|
-
const anchorOffset = selection && selection.anchorOffset;
|
|
1553
|
-
const focusOffset = selection && selection.focusOffset;
|
|
1554
|
-
if (focusOffset == null || anchorOffset == null || anchorOffset < focusOffset) {
|
|
1555
|
-
return anchorOffset;
|
|
2240
|
+
_applyDispatch(appended, flags, tail) {
|
|
2241
|
+
if (appended === void 0) {
|
|
2242
|
+
appended = '';
|
|
1556
2243
|
}
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
get _unsafeSelectionEnd() {
|
|
1560
|
-
const root = this.rootElement;
|
|
1561
|
-
const selection = root.getSelection && root.getSelection();
|
|
1562
|
-
const anchorOffset = selection && selection.anchorOffset;
|
|
1563
|
-
const focusOffset = selection && selection.focusOffset;
|
|
1564
|
-
if (focusOffset == null || anchorOffset == null || anchorOffset > focusOffset) {
|
|
1565
|
-
return anchorOffset;
|
|
2244
|
+
if (flags === void 0) {
|
|
2245
|
+
flags = {};
|
|
1566
2246
|
}
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
const
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
const
|
|
1575
|
-
const
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
2247
|
+
if (tail === void 0) {
|
|
2248
|
+
tail = '';
|
|
2249
|
+
}
|
|
2250
|
+
const prevValueBeforeTail = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._value : this.value;
|
|
2251
|
+
const inputValue = this.rawInputValue;
|
|
2252
|
+
const insertValue = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._rawInputValue : inputValue;
|
|
2253
|
+
const tailValue = inputValue.slice(insertValue.length);
|
|
2254
|
+
const prevMask = this.currentMask;
|
|
2255
|
+
const details = new ChangeDetails();
|
|
2256
|
+
const prevMaskState = prevMask == null ? void 0 : prevMask.state;
|
|
2257
|
+
this.currentMask = this.doDispatch(appended, {
|
|
2258
|
+
...flags
|
|
2259
|
+
}, tail);
|
|
2260
|
+
if (this.currentMask) {
|
|
2261
|
+
if (this.currentMask !== prevMask) {
|
|
2262
|
+
this.currentMask.reset();
|
|
2263
|
+
if (insertValue) {
|
|
2264
|
+
this.currentMask.append(insertValue, {
|
|
2265
|
+
raw: true
|
|
2266
|
+
});
|
|
2267
|
+
details.tailShift = this.currentMask.value.length - prevValueBeforeTail.length;
|
|
2268
|
+
}
|
|
2269
|
+
if (tailValue) {
|
|
2270
|
+
details.tailShift += this.currentMask.append(tailValue, {
|
|
2271
|
+
raw: true,
|
|
2272
|
+
tail: true
|
|
2273
|
+
}).tailShift;
|
|
2274
|
+
}
|
|
2275
|
+
} else if (prevMaskState) {
|
|
2276
|
+
this.currentMask.state = prevMaskState;
|
|
2277
|
+
}
|
|
1579
2278
|
}
|
|
2279
|
+
return details;
|
|
1580
2280
|
}
|
|
1581
|
-
|
|
1582
|
-
|
|
2281
|
+
_appendPlaceholder() {
|
|
2282
|
+
const details = this._applyDispatch();
|
|
2283
|
+
if (this.currentMask) {
|
|
2284
|
+
details.aggregate(this.currentMask._appendPlaceholder());
|
|
2285
|
+
}
|
|
2286
|
+
return details;
|
|
1583
2287
|
}
|
|
1584
|
-
|
|
1585
|
-
|
|
2288
|
+
_appendEager() {
|
|
2289
|
+
const details = this._applyDispatch();
|
|
2290
|
+
if (this.currentMask) {
|
|
2291
|
+
details.aggregate(this.currentMask._appendEager());
|
|
2292
|
+
}
|
|
2293
|
+
return details;
|
|
1586
2294
|
}
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
class InputMask {
|
|
1592
|
-
constructor(el, opts) {
|
|
1593
|
-
this.el = el instanceof MaskElement ? el : el.isContentEditable && el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA' ? new HTMLContenteditableMaskElement(el) : new HTMLMaskElement(el);
|
|
1594
|
-
this.masked = createMask(opts);
|
|
1595
|
-
this._listeners = {};
|
|
1596
|
-
this._value = '';
|
|
1597
|
-
this._unmaskedValue = '';
|
|
1598
|
-
this._saveSelection = this._saveSelection.bind(this);
|
|
1599
|
-
this._onInput = this._onInput.bind(this);
|
|
1600
|
-
this._onChange = this._onChange.bind(this);
|
|
1601
|
-
this._onDrop = this._onDrop.bind(this);
|
|
1602
|
-
this._onFocus = this._onFocus.bind(this);
|
|
1603
|
-
this._onClick = this._onClick.bind(this);
|
|
1604
|
-
this.alignCursor = this.alignCursor.bind(this);
|
|
1605
|
-
this.alignCursorFriendly = this.alignCursorFriendly.bind(this);
|
|
1606
|
-
this._bindEvents();
|
|
1607
|
-
this.updateValue();
|
|
1608
|
-
this._onChange();
|
|
2295
|
+
appendTail(tail) {
|
|
2296
|
+
const details = new ChangeDetails();
|
|
2297
|
+
if (tail) details.aggregate(this._applyDispatch('', {}, tail));
|
|
2298
|
+
return details.aggregate(this.currentMask ? this.currentMask.appendTail(tail) : super.appendTail(tail));
|
|
1609
2299
|
}
|
|
1610
|
-
|
|
1611
|
-
|
|
2300
|
+
currentMaskFlags(flags) {
|
|
2301
|
+
var _flags$_beforeTailSta, _flags$_beforeTailSta2;
|
|
2302
|
+
return {
|
|
2303
|
+
...flags,
|
|
2304
|
+
_beforeTailState: ((_flags$_beforeTailSta = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta.currentMaskRef) === this.currentMask && ((_flags$_beforeTailSta2 = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta2.currentMask) || flags._beforeTailState
|
|
2305
|
+
};
|
|
1612
2306
|
}
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
2307
|
+
doDispatch(appended, flags, tail) {
|
|
2308
|
+
if (flags === void 0) {
|
|
2309
|
+
flags = {};
|
|
2310
|
+
}
|
|
2311
|
+
if (tail === void 0) {
|
|
2312
|
+
tail = '';
|
|
2313
|
+
}
|
|
2314
|
+
return this.dispatch(appended, this, flags, tail);
|
|
1616
2315
|
}
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
}
|
|
1623
|
-
return;
|
|
2316
|
+
doValidate(flags) {
|
|
2317
|
+
return super.doValidate(flags) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(flags)));
|
|
2318
|
+
}
|
|
2319
|
+
doPrepare(str, flags) {
|
|
2320
|
+
if (flags === void 0) {
|
|
2321
|
+
flags = {};
|
|
1624
2322
|
}
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
2323
|
+
let [s, details] = super.doPrepare(str, flags);
|
|
2324
|
+
if (this.currentMask) {
|
|
2325
|
+
let currentDetails;
|
|
2326
|
+
[s, currentDetails] = super.doPrepare(s, this.currentMaskFlags(flags));
|
|
2327
|
+
details = details.aggregate(currentDetails);
|
|
2328
|
+
}
|
|
2329
|
+
return [s, details];
|
|
2330
|
+
}
|
|
2331
|
+
doPrepareChar(str, flags) {
|
|
2332
|
+
if (flags === void 0) {
|
|
2333
|
+
flags = {};
|
|
2334
|
+
}
|
|
2335
|
+
let [s, details] = super.doPrepareChar(str, flags);
|
|
2336
|
+
if (this.currentMask) {
|
|
2337
|
+
let currentDetails;
|
|
2338
|
+
[s, currentDetails] = super.doPrepareChar(s, this.currentMaskFlags(flags));
|
|
2339
|
+
details = details.aggregate(currentDetails);
|
|
2340
|
+
}
|
|
2341
|
+
return [s, details];
|
|
2342
|
+
}
|
|
2343
|
+
reset() {
|
|
2344
|
+
var _this$currentMask;
|
|
2345
|
+
(_this$currentMask = this.currentMask) == null || _this$currentMask.reset();
|
|
2346
|
+
this.compiledMasks.forEach(m => m.reset());
|
|
1630
2347
|
}
|
|
1631
2348
|
get value() {
|
|
1632
|
-
return this.
|
|
2349
|
+
return this.exposeMask ? this.exposeMask.value : this.currentMask ? this.currentMask.value : '';
|
|
1633
2350
|
}
|
|
1634
|
-
set value(
|
|
1635
|
-
if (this.
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
2351
|
+
set value(value) {
|
|
2352
|
+
if (this.exposeMask) {
|
|
2353
|
+
this.exposeMask.value = value;
|
|
2354
|
+
this.currentMask = this.exposeMask;
|
|
2355
|
+
this._applyDispatch();
|
|
2356
|
+
} else super.value = value;
|
|
1639
2357
|
}
|
|
1640
2358
|
get unmaskedValue() {
|
|
1641
|
-
return this.
|
|
2359
|
+
return this.exposeMask ? this.exposeMask.unmaskedValue : this.currentMask ? this.currentMask.unmaskedValue : '';
|
|
1642
2360
|
}
|
|
1643
|
-
set unmaskedValue(
|
|
1644
|
-
if (this.
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
2361
|
+
set unmaskedValue(unmaskedValue) {
|
|
2362
|
+
if (this.exposeMask) {
|
|
2363
|
+
this.exposeMask.unmaskedValue = unmaskedValue;
|
|
2364
|
+
this.currentMask = this.exposeMask;
|
|
2365
|
+
this._applyDispatch();
|
|
2366
|
+
} else super.unmaskedValue = unmaskedValue;
|
|
1648
2367
|
}
|
|
1649
2368
|
get typedValue() {
|
|
1650
|
-
return this.
|
|
2369
|
+
return this.exposeMask ? this.exposeMask.typedValue : this.currentMask ? this.currentMask.typedValue : '';
|
|
1651
2370
|
}
|
|
1652
|
-
set typedValue(
|
|
1653
|
-
if (this.
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
2371
|
+
set typedValue(typedValue) {
|
|
2372
|
+
if (this.exposeMask) {
|
|
2373
|
+
this.exposeMask.typedValue = typedValue;
|
|
2374
|
+
this.currentMask = this.exposeMask;
|
|
2375
|
+
this._applyDispatch();
|
|
2376
|
+
return;
|
|
2377
|
+
}
|
|
2378
|
+
let unmaskedValue = String(typedValue);
|
|
2379
|
+
if (this.currentMask) {
|
|
2380
|
+
this.currentMask.typedValue = typedValue;
|
|
2381
|
+
unmaskedValue = this.currentMask.unmaskedValue;
|
|
2382
|
+
}
|
|
2383
|
+
this.unmaskedValue = unmaskedValue;
|
|
1657
2384
|
}
|
|
1658
2385
|
get displayValue() {
|
|
1659
|
-
return this.
|
|
2386
|
+
return this.currentMask ? this.currentMask.displayValue : '';
|
|
1660
2387
|
}
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
input: this._onInput,
|
|
1665
|
-
drop: this._onDrop,
|
|
1666
|
-
click: this._onClick,
|
|
1667
|
-
focus: this._onFocus,
|
|
1668
|
-
commit: this._onChange
|
|
1669
|
-
});
|
|
2388
|
+
get isComplete() {
|
|
2389
|
+
var _this$currentMask2;
|
|
2390
|
+
return Boolean((_this$currentMask2 = this.currentMask) == null ? void 0 : _this$currentMask2.isComplete);
|
|
1670
2391
|
}
|
|
1671
|
-
|
|
1672
|
-
|
|
2392
|
+
get isFilled() {
|
|
2393
|
+
var _this$currentMask3;
|
|
2394
|
+
return Boolean((_this$currentMask3 = this.currentMask) == null ? void 0 : _this$currentMask3.isFilled);
|
|
1673
2395
|
}
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
2396
|
+
remove(fromPos, toPos) {
|
|
2397
|
+
const details = new ChangeDetails();
|
|
2398
|
+
if (this.currentMask) {
|
|
2399
|
+
details.aggregate(this.currentMask.remove(fromPos, toPos))
|
|
2400
|
+
.aggregate(this._applyDispatch());
|
|
1677
2401
|
}
|
|
1678
|
-
|
|
1679
|
-
if (!listeners) return;
|
|
1680
|
-
listeners.forEach(l => l(...args));
|
|
2402
|
+
return details;
|
|
1681
2403
|
}
|
|
1682
|
-
get
|
|
1683
|
-
|
|
2404
|
+
get state() {
|
|
2405
|
+
var _this$currentMask4;
|
|
2406
|
+
return {
|
|
2407
|
+
...super.state,
|
|
2408
|
+
_rawInputValue: this.rawInputValue,
|
|
2409
|
+
compiledMasks: this.compiledMasks.map(m => m.state),
|
|
2410
|
+
currentMaskRef: this.currentMask,
|
|
2411
|
+
currentMask: (_this$currentMask4 = this.currentMask) == null ? void 0 : _this$currentMask4.state
|
|
2412
|
+
};
|
|
1684
2413
|
}
|
|
1685
|
-
|
|
1686
|
-
|
|
2414
|
+
set state(state) {
|
|
2415
|
+
const {
|
|
2416
|
+
compiledMasks,
|
|
2417
|
+
currentMaskRef,
|
|
2418
|
+
currentMask,
|
|
2419
|
+
...maskedState
|
|
2420
|
+
} = state;
|
|
2421
|
+
if (compiledMasks) this.compiledMasks.forEach((m, mi) => m.state = compiledMasks[mi]);
|
|
2422
|
+
if (currentMaskRef != null) {
|
|
2423
|
+
this.currentMask = currentMaskRef;
|
|
2424
|
+
this.currentMask.state = currentMask;
|
|
2425
|
+
}
|
|
2426
|
+
super.state = maskedState;
|
|
1687
2427
|
}
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
this.el.select(pos, pos);
|
|
1691
|
-
this._saveSelection();
|
|
2428
|
+
extractInput(fromPos, toPos, flags) {
|
|
2429
|
+
return this.currentMask ? this.currentMask.extractInput(fromPos, toPos, flags) : '';
|
|
1692
2430
|
}
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
if (this.displayValue !== this.el.value) {
|
|
1696
|
-
console.warn('Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.');
|
|
1697
|
-
}
|
|
1698
|
-
this._selection = {
|
|
1699
|
-
start: this.selectionStart,
|
|
1700
|
-
end: this.cursorPos
|
|
1701
|
-
};
|
|
2431
|
+
extractTail(fromPos, toPos) {
|
|
2432
|
+
return this.currentMask ? this.currentMask.extractTail(fromPos, toPos) : super.extractTail(fromPos, toPos);
|
|
1702
2433
|
}
|
|
1703
|
-
|
|
1704
|
-
this.
|
|
1705
|
-
|
|
2434
|
+
doCommit() {
|
|
2435
|
+
if (this.currentMask) this.currentMask.doCommit();
|
|
2436
|
+
super.doCommit();
|
|
1706
2437
|
}
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
const newValue = this.masked.value;
|
|
1710
|
-
const newDisplayValue = this.displayValue;
|
|
1711
|
-
const isChanged = this.unmaskedValue !== newUnmaskedValue || this.value !== newValue;
|
|
1712
|
-
this._unmaskedValue = newUnmaskedValue;
|
|
1713
|
-
this._value = newValue;
|
|
1714
|
-
if (this.el.value !== newDisplayValue) this.el.value = newDisplayValue;
|
|
1715
|
-
if (isChanged) this._fireChangeEvents();
|
|
2438
|
+
nearestInputPos(cursorPos, direction) {
|
|
2439
|
+
return this.currentMask ? this.currentMask.nearestInputPos(cursorPos, direction) : super.nearestInputPos(cursorPos, direction);
|
|
1716
2440
|
}
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
mask
|
|
1720
|
-
} = opts,
|
|
1721
|
-
restOpts = _objectWithoutPropertiesLoose(opts, _excluded$1);
|
|
1722
|
-
const updateMask = !this.maskEquals(mask);
|
|
1723
|
-
const updateOpts = !objectIncludes(this.masked, restOpts);
|
|
1724
|
-
if (updateMask) this.mask = mask;
|
|
1725
|
-
if (updateOpts) this.masked.updateOptions(restOpts);
|
|
1726
|
-
if (updateMask || updateOpts) this.updateControl();
|
|
2441
|
+
get overwrite() {
|
|
2442
|
+
return this.currentMask ? this.currentMask.overwrite : this._overwrite;
|
|
1727
2443
|
}
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
this.cursorPos = cursorPos;
|
|
1731
|
-
this._delayUpdateCursor(cursorPos);
|
|
2444
|
+
set overwrite(overwrite) {
|
|
2445
|
+
this._overwrite = overwrite;
|
|
1732
2446
|
}
|
|
1733
|
-
|
|
1734
|
-
this.
|
|
1735
|
-
this._changingCursorPos = cursorPos;
|
|
1736
|
-
this._cursorChanging = setTimeout(() => {
|
|
1737
|
-
if (!this.el) return;
|
|
1738
|
-
this.cursorPos = this._changingCursorPos;
|
|
1739
|
-
this._abortUpdateCursor();
|
|
1740
|
-
}, 10);
|
|
2447
|
+
get eager() {
|
|
2448
|
+
return this.currentMask ? this.currentMask.eager : this._eager;
|
|
1741
2449
|
}
|
|
1742
|
-
|
|
1743
|
-
this.
|
|
1744
|
-
if (this.masked.isComplete) this._fireEvent('complete', this._inputEvent);
|
|
2450
|
+
set eager(eager) {
|
|
2451
|
+
this._eager = eager;
|
|
1745
2452
|
}
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
clearTimeout(this._cursorChanging);
|
|
1749
|
-
delete this._cursorChanging;
|
|
1750
|
-
}
|
|
2453
|
+
get skipInvalid() {
|
|
2454
|
+
return this.currentMask ? this.currentMask.skipInvalid : this._skipInvalid;
|
|
1751
2455
|
}
|
|
1752
|
-
|
|
1753
|
-
this.
|
|
2456
|
+
set skipInvalid(skipInvalid) {
|
|
2457
|
+
this._skipInvalid = skipInvalid;
|
|
1754
2458
|
}
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
this.alignCursor();
|
|
2459
|
+
get autofix() {
|
|
2460
|
+
return this.currentMask ? this.currentMask.autofix : this._autofix;
|
|
1758
2461
|
}
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
this._listeners[ev].push(handler);
|
|
1762
|
-
return this;
|
|
2462
|
+
set autofix(autofix) {
|
|
2463
|
+
this._autofix = autofix;
|
|
1763
2464
|
}
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
2465
|
+
maskEquals(mask) {
|
|
2466
|
+
return Array.isArray(mask) ? this.compiledMasks.every((m, mi) => {
|
|
2467
|
+
if (!mask[mi]) return;
|
|
2468
|
+
const {
|
|
2469
|
+
mask: oldMask,
|
|
2470
|
+
...restOpts
|
|
2471
|
+
} = mask[mi];
|
|
2472
|
+
return objectIncludes(m, restOpts) && m.maskEquals(oldMask);
|
|
2473
|
+
}) : super.maskEquals(mask);
|
|
1773
2474
|
}
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
this.
|
|
1777
|
-
if (!this._selection) return this.updateValue();
|
|
1778
|
-
const details = new ActionDetails(
|
|
1779
|
-
this.el.value, this.cursorPos,
|
|
1780
|
-
this.displayValue, this._selection);
|
|
1781
|
-
const oldRawValue = this.masked.rawInputValue;
|
|
1782
|
-
const offset = this.masked.splice(details.startChangePos, details.removed.length, details.inserted, details.removeDirection, {
|
|
1783
|
-
input: true,
|
|
1784
|
-
raw: true
|
|
1785
|
-
}).offset;
|
|
1786
|
-
const removeDirection = oldRawValue === this.masked.rawInputValue ? details.removeDirection : DIRECTION.NONE;
|
|
1787
|
-
let cursorPos = this.masked.nearestInputPos(details.startChangePos + offset, removeDirection);
|
|
1788
|
-
if (removeDirection !== DIRECTION.NONE) cursorPos = this.masked.nearestInputPos(cursorPos, DIRECTION.NONE);
|
|
1789
|
-
this.updateControl();
|
|
1790
|
-
this.updateCursor(cursorPos);
|
|
1791
|
-
delete this._inputEvent;
|
|
2475
|
+
typedValueEquals(value) {
|
|
2476
|
+
var _this$currentMask5;
|
|
2477
|
+
return Boolean((_this$currentMask5 = this.currentMask) == null ? void 0 : _this$currentMask5.typedValueEquals(value));
|
|
1792
2478
|
}
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
2479
|
+
}
|
|
2480
|
+
MaskedDynamic.DEFAULTS = {
|
|
2481
|
+
...Masked.DEFAULTS,
|
|
2482
|
+
dispatch: (appended, masked, flags, tail) => {
|
|
2483
|
+
if (!masked.compiledMasks.length) return;
|
|
2484
|
+
const inputValue = masked.rawInputValue;
|
|
2485
|
+
const inputs = masked.compiledMasks.map((m, index) => {
|
|
2486
|
+
const isCurrent = masked.currentMask === m;
|
|
2487
|
+
const startInputPos = isCurrent ? m.displayValue.length : m.nearestInputPos(m.displayValue.length, DIRECTION.FORCE_LEFT);
|
|
2488
|
+
if (m.rawInputValue !== inputValue) {
|
|
2489
|
+
m.reset();
|
|
2490
|
+
m.append(inputValue, {
|
|
2491
|
+
raw: true
|
|
2492
|
+
});
|
|
2493
|
+
} else if (!isCurrent) {
|
|
2494
|
+
m.remove(startInputPos);
|
|
2495
|
+
}
|
|
2496
|
+
m.append(appended, masked.currentMaskFlags(flags));
|
|
2497
|
+
m.appendTail(tail);
|
|
2498
|
+
return {
|
|
2499
|
+
index,
|
|
2500
|
+
weight: m.rawInputValue.length,
|
|
2501
|
+
totalInputPositions: m.totalInputPositions(0, Math.max(startInputPos, m.nearestInputPos(m.displayValue.length, DIRECTION.FORCE_LEFT)))
|
|
2502
|
+
};
|
|
2503
|
+
});
|
|
2504
|
+
inputs.sort((i1, i2) => i2.weight - i1.weight || i2.totalInputPositions - i1.totalInputPositions);
|
|
2505
|
+
return masked.compiledMasks[inputs[0].index];
|
|
1800
2506
|
}
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
2507
|
+
};
|
|
2508
|
+
IMask.MaskedDynamic = MaskedDynamic;
|
|
2509
|
+
|
|
2510
|
+
class MaskedEnum extends MaskedPattern {
|
|
2511
|
+
constructor(opts) {
|
|
2512
|
+
super({
|
|
2513
|
+
...MaskedEnum.DEFAULTS,
|
|
2514
|
+
...opts
|
|
2515
|
+
});
|
|
1804
2516
|
}
|
|
1805
|
-
|
|
1806
|
-
|
|
2517
|
+
updateOptions(opts) {
|
|
2518
|
+
super.updateOptions(opts);
|
|
2519
|
+
}
|
|
2520
|
+
_update(opts) {
|
|
2521
|
+
const {
|
|
2522
|
+
enum: enum_,
|
|
2523
|
+
...eopts
|
|
2524
|
+
} = opts;
|
|
2525
|
+
if (enum_) {
|
|
2526
|
+
const lengths = enum_.map(e => e.length);
|
|
2527
|
+
const requiredLength = Math.min(...lengths);
|
|
2528
|
+
const optionalLength = Math.max(...lengths) - requiredLength;
|
|
2529
|
+
eopts.mask = '*'.repeat(requiredLength);
|
|
2530
|
+
if (optionalLength) eopts.mask += '[' + '*'.repeat(optionalLength) + ']';
|
|
2531
|
+
this.enum = enum_;
|
|
2532
|
+
}
|
|
2533
|
+
super._update(eopts);
|
|
2534
|
+
}
|
|
2535
|
+
_appendCharRaw(ch, flags) {
|
|
2536
|
+
if (flags === void 0) {
|
|
2537
|
+
flags = {};
|
|
2538
|
+
}
|
|
2539
|
+
const matchFrom = Math.min(this.nearestInputPos(0, DIRECTION.FORCE_RIGHT), this.value.length);
|
|
2540
|
+
const matches = this.enum.filter(e => this.matchValue(e, this.unmaskedValue + ch, matchFrom));
|
|
2541
|
+
if (matches.length) {
|
|
2542
|
+
if (matches.length === 1) {
|
|
2543
|
+
this._forEachBlocksInRange(0, this.value.length, (b, bi) => {
|
|
2544
|
+
const mch = matches[0][bi];
|
|
2545
|
+
if (bi >= this.value.length || mch === b.value) return;
|
|
2546
|
+
b.reset();
|
|
2547
|
+
b._appendChar(mch, flags);
|
|
2548
|
+
});
|
|
2549
|
+
}
|
|
2550
|
+
const d = super._appendCharRaw(matches[0][this.value.length], flags);
|
|
2551
|
+
if (matches.length === 1) {
|
|
2552
|
+
matches[0].slice(this.unmaskedValue.length).split('').forEach(mch => d.aggregate(super._appendCharRaw(mch)));
|
|
2553
|
+
}
|
|
2554
|
+
return d;
|
|
2555
|
+
}
|
|
2556
|
+
return new ChangeDetails({
|
|
2557
|
+
skip: !this.isComplete
|
|
2558
|
+
});
|
|
1807
2559
|
}
|
|
1808
|
-
|
|
1809
|
-
|
|
2560
|
+
extractTail(fromPos, toPos) {
|
|
2561
|
+
if (fromPos === void 0) {
|
|
2562
|
+
fromPos = 0;
|
|
2563
|
+
}
|
|
2564
|
+
if (toPos === void 0) {
|
|
2565
|
+
toPos = this.displayValue.length;
|
|
2566
|
+
}
|
|
2567
|
+
return new ContinuousTailDetails('', fromPos);
|
|
1810
2568
|
}
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
2569
|
+
remove(fromPos, toPos) {
|
|
2570
|
+
if (fromPos === void 0) {
|
|
2571
|
+
fromPos = 0;
|
|
2572
|
+
}
|
|
2573
|
+
if (toPos === void 0) {
|
|
2574
|
+
toPos = this.displayValue.length;
|
|
2575
|
+
}
|
|
2576
|
+
if (fromPos === toPos) return new ChangeDetails();
|
|
2577
|
+
const matchFrom = Math.min(super.nearestInputPos(0, DIRECTION.FORCE_RIGHT), this.value.length);
|
|
2578
|
+
let pos;
|
|
2579
|
+
for (pos = fromPos; pos >= 0; --pos) {
|
|
2580
|
+
const matches = this.enum.filter(e => this.matchValue(e, this.value.slice(matchFrom, pos), matchFrom));
|
|
2581
|
+
if (matches.length > 1) break;
|
|
2582
|
+
}
|
|
2583
|
+
const details = super.remove(pos, toPos);
|
|
2584
|
+
details.tailShift += pos - fromPos;
|
|
2585
|
+
return details;
|
|
2586
|
+
}
|
|
2587
|
+
get isComplete() {
|
|
2588
|
+
return this.enum.indexOf(this.value) >= 0;
|
|
1815
2589
|
}
|
|
1816
2590
|
}
|
|
1817
|
-
|
|
2591
|
+
MaskedEnum.DEFAULTS = {
|
|
2592
|
+
...MaskedPattern.DEFAULTS,
|
|
2593
|
+
matchValue: (estr, istr, matchFrom) => estr.indexOf(istr, matchFrom) === matchFrom
|
|
2594
|
+
};
|
|
2595
|
+
IMask.MaskedEnum = MaskedEnum;
|
|
1818
2596
|
|
|
1819
|
-
class
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
super._update(opts);
|
|
2597
|
+
class MaskedFunction extends Masked {
|
|
2598
|
+
updateOptions(opts) {
|
|
2599
|
+
super.updateOptions(opts);
|
|
1823
2600
|
}
|
|
1824
|
-
|
|
1825
|
-
|
|
2601
|
+
_update(opts) {
|
|
2602
|
+
super._update({
|
|
2603
|
+
...opts,
|
|
2604
|
+
validate: opts.mask
|
|
2605
|
+
});
|
|
1826
2606
|
}
|
|
1827
2607
|
}
|
|
1828
|
-
IMask.
|
|
2608
|
+
IMask.MaskedFunction = MaskedFunction;
|
|
1829
2609
|
|
|
2610
|
+
var _MaskedNumber;
|
|
1830
2611
|
class MaskedNumber extends Masked {
|
|
1831
2612
|
constructor(opts) {
|
|
1832
|
-
super(
|
|
2613
|
+
super({
|
|
2614
|
+
...MaskedNumber.DEFAULTS,
|
|
2615
|
+
...opts
|
|
2616
|
+
});
|
|
2617
|
+
}
|
|
2618
|
+
updateOptions(opts) {
|
|
2619
|
+
super.updateOptions(opts);
|
|
1833
2620
|
}
|
|
1834
2621
|
_update(opts) {
|
|
1835
2622
|
super._update(opts);
|
|
1836
2623
|
this._updateRegExps();
|
|
1837
2624
|
}
|
|
1838
2625
|
_updateRegExps() {
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
2626
|
+
const start = '^' + (this.allowNegative ? '[+|\\-]?' : '');
|
|
2627
|
+
const mid = '\\d*';
|
|
2628
|
+
const end = (this.scale ? "(" + escapeRegExp(this.radix) + "\\d{0," + this.scale + "})?" : '') + '$';
|
|
1842
2629
|
this._numberRegExp = new RegExp(start + mid + end);
|
|
1843
|
-
this._mapToRadixRegExp = new RegExp("["
|
|
2630
|
+
this._mapToRadixRegExp = new RegExp("[" + this.mapToRadix.map(escapeRegExp).join('') + "]", 'g');
|
|
1844
2631
|
this._thousandsSeparatorRegExp = new RegExp(escapeRegExp(this.thousandsSeparator), 'g');
|
|
1845
2632
|
}
|
|
1846
2633
|
_removeThousandsSeparators(value) {
|
|
@@ -1851,16 +2638,20 @@ class MaskedNumber extends Masked {
|
|
|
1851
2638
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator);
|
|
1852
2639
|
return parts.join(this.radix);
|
|
1853
2640
|
}
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
const [prepCh, details] =
|
|
2641
|
+
doPrepareChar(ch, flags) {
|
|
2642
|
+
if (flags === void 0) {
|
|
2643
|
+
flags = {};
|
|
2644
|
+
}
|
|
2645
|
+
const [prepCh, details] = super.doPrepareChar(this._removeThousandsSeparators(this.scale && this.mapToRadix.length && (
|
|
2646
|
+
flags.input && flags.raw || !flags.input && !flags.raw) ? ch.replace(this._mapToRadixRegExp, this.radix) : ch), flags);
|
|
1859
2647
|
if (ch && !prepCh) details.skip = true;
|
|
2648
|
+
if (prepCh && !this.allowPositive && !this.value && prepCh !== '-') details.aggregate(this._appendChar('-'));
|
|
1860
2649
|
return [prepCh, details];
|
|
1861
2650
|
}
|
|
1862
|
-
_separatorsCount(to) {
|
|
1863
|
-
|
|
2651
|
+
_separatorsCount(to, extendOnSeparators) {
|
|
2652
|
+
if (extendOnSeparators === void 0) {
|
|
2653
|
+
extendOnSeparators = false;
|
|
2654
|
+
}
|
|
1864
2655
|
let count = 0;
|
|
1865
2656
|
for (let pos = 0; pos < to; ++pos) {
|
|
1866
2657
|
if (this._value.indexOf(this.thousandsSeparator, pos) === pos) {
|
|
@@ -1870,29 +2661,63 @@ class MaskedNumber extends Masked {
|
|
|
1870
2661
|
}
|
|
1871
2662
|
return count;
|
|
1872
2663
|
}
|
|
1873
|
-
_separatorsCountFromSlice() {
|
|
1874
|
-
|
|
2664
|
+
_separatorsCountFromSlice(slice) {
|
|
2665
|
+
if (slice === void 0) {
|
|
2666
|
+
slice = this._value;
|
|
2667
|
+
}
|
|
1875
2668
|
return this._separatorsCount(this._removeThousandsSeparators(slice).length, true);
|
|
1876
2669
|
}
|
|
1877
|
-
extractInput() {
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
2670
|
+
extractInput(fromPos, toPos, flags) {
|
|
2671
|
+
if (fromPos === void 0) {
|
|
2672
|
+
fromPos = 0;
|
|
2673
|
+
}
|
|
2674
|
+
if (toPos === void 0) {
|
|
2675
|
+
toPos = this.displayValue.length;
|
|
2676
|
+
}
|
|
1881
2677
|
[fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);
|
|
1882
2678
|
return this._removeThousandsSeparators(super.extractInput(fromPos, toPos, flags));
|
|
1883
2679
|
}
|
|
1884
|
-
_appendCharRaw(ch) {
|
|
1885
|
-
|
|
1886
|
-
|
|
2680
|
+
_appendCharRaw(ch, flags) {
|
|
2681
|
+
if (flags === void 0) {
|
|
2682
|
+
flags = {};
|
|
2683
|
+
}
|
|
1887
2684
|
const prevBeforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
|
|
1888
2685
|
const prevBeforeTailSeparatorsCount = this._separatorsCountFromSlice(prevBeforeTailValue);
|
|
1889
2686
|
this._value = this._removeThousandsSeparators(this.value);
|
|
1890
|
-
const
|
|
2687
|
+
const oldValue = this._value;
|
|
2688
|
+
this._value += ch;
|
|
2689
|
+
const num = this.number;
|
|
2690
|
+
let accepted = !isNaN(num);
|
|
2691
|
+
let skip = false;
|
|
2692
|
+
if (accepted) {
|
|
2693
|
+
let fixedNum;
|
|
2694
|
+
if (this.min != null && this.min < 0 && this.number < this.min) fixedNum = this.min;
|
|
2695
|
+
if (this.max != null && this.max > 0 && this.number > this.max) fixedNum = this.max;
|
|
2696
|
+
if (fixedNum != null) {
|
|
2697
|
+
if (this.autofix) {
|
|
2698
|
+
this._value = this.format(fixedNum, this).replace(MaskedNumber.UNMASKED_RADIX, this.radix);
|
|
2699
|
+
skip || (skip = oldValue === this._value && !flags.tail);
|
|
2700
|
+
} else {
|
|
2701
|
+
accepted = false;
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
accepted && (accepted = Boolean(this._value.match(this._numberRegExp)));
|
|
2705
|
+
}
|
|
2706
|
+
let appendDetails;
|
|
2707
|
+
if (!accepted) {
|
|
2708
|
+
this._value = oldValue;
|
|
2709
|
+
appendDetails = new ChangeDetails();
|
|
2710
|
+
} else {
|
|
2711
|
+
appendDetails = new ChangeDetails({
|
|
2712
|
+
inserted: this._value.slice(oldValue.length),
|
|
2713
|
+
rawInserted: skip ? '' : ch,
|
|
2714
|
+
skip
|
|
2715
|
+
});
|
|
2716
|
+
}
|
|
1891
2717
|
this._value = this._insertThousandsSeparators(this._value);
|
|
1892
2718
|
const beforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
|
|
1893
2719
|
const beforeTailSeparatorsCount = this._separatorsCountFromSlice(beforeTailValue);
|
|
1894
2720
|
appendDetails.tailShift += (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length;
|
|
1895
|
-
appendDetails.skip = !appendDetails.rawInserted && ch === this.thousandsSeparator;
|
|
1896
2721
|
return appendDetails;
|
|
1897
2722
|
}
|
|
1898
2723
|
_findSeparatorAround(pos) {
|
|
@@ -1910,9 +2735,13 @@ class MaskedNumber extends Masked {
|
|
|
1910
2735
|
if (separatorAroundToPos >= 0) to = separatorAroundToPos + this.thousandsSeparator.length;
|
|
1911
2736
|
return [from, to];
|
|
1912
2737
|
}
|
|
1913
|
-
remove() {
|
|
1914
|
-
|
|
1915
|
-
|
|
2738
|
+
remove(fromPos, toPos) {
|
|
2739
|
+
if (fromPos === void 0) {
|
|
2740
|
+
fromPos = 0;
|
|
2741
|
+
}
|
|
2742
|
+
if (toPos === void 0) {
|
|
2743
|
+
toPos = this.displayValue.length;
|
|
2744
|
+
}
|
|
1916
2745
|
[fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);
|
|
1917
2746
|
const valueBeforePos = this.value.slice(0, fromPos);
|
|
1918
2747
|
const valueAfterPos = this.value.slice(toPos);
|
|
@@ -1950,23 +2779,13 @@ class MaskedNumber extends Masked {
|
|
|
1950
2779
|
}
|
|
1951
2780
|
return cursorPos;
|
|
1952
2781
|
}
|
|
1953
|
-
doValidate(flags) {
|
|
1954
|
-
let valid = Boolean(this._removeThousandsSeparators(this.value).match(this._numberRegExp));
|
|
1955
|
-
if (valid) {
|
|
1956
|
-
const number = this.number;
|
|
1957
|
-
valid = valid && !isNaN(number) && (
|
|
1958
|
-
this.min == null || this.min >= 0 || this.min <= this.number) && (
|
|
1959
|
-
this.max == null || this.max <= 0 || this.number <= this.max);
|
|
1960
|
-
}
|
|
1961
|
-
return valid && super.doValidate(flags);
|
|
1962
|
-
}
|
|
1963
2782
|
doCommit() {
|
|
1964
2783
|
if (this.value) {
|
|
1965
2784
|
const number = this.number;
|
|
1966
2785
|
let validnum = number;
|
|
1967
2786
|
if (this.min != null) validnum = Math.max(validnum, this.min);
|
|
1968
2787
|
if (this.max != null) validnum = Math.min(validnum, this.max);
|
|
1969
|
-
if (validnum !== number) this.unmaskedValue = this.
|
|
2788
|
+
if (validnum !== number) this.unmaskedValue = this.format(validnum, this);
|
|
1970
2789
|
let formatted = this.value;
|
|
1971
2790
|
if (this.normalizeZeros) formatted = this._normalizeZeros(formatted);
|
|
1972
2791
|
if (this.padFractionalZeros && this.scale > 0) formatted = this._padFractionalZeros(formatted);
|
|
@@ -1991,9 +2810,10 @@ class MaskedNumber extends Masked {
|
|
|
1991
2810
|
parts[1] = parts[1].padEnd(this.scale, '0');
|
|
1992
2811
|
return parts.join(this.radix);
|
|
1993
2812
|
}
|
|
1994
|
-
doSkipInvalid(ch) {
|
|
1995
|
-
|
|
1996
|
-
|
|
2813
|
+
doSkipInvalid(ch, flags, checkTail) {
|
|
2814
|
+
if (flags === void 0) {
|
|
2815
|
+
flags = {};
|
|
2816
|
+
}
|
|
1997
2817
|
const dropFractional = this.scale === 0 && ch !== this.thousandsSeparator && (ch === this.radix || ch === MaskedNumber.UNMASKED_RADIX || this.mapToRadix.includes(ch));
|
|
1998
2818
|
return super.doSkipInvalid(ch, flags, checkTail) && !dropFractional;
|
|
1999
2819
|
}
|
|
@@ -2004,10 +2824,10 @@ class MaskedNumber extends Masked {
|
|
|
2004
2824
|
super.unmaskedValue = unmaskedValue;
|
|
2005
2825
|
}
|
|
2006
2826
|
get typedValue() {
|
|
2007
|
-
return this.
|
|
2827
|
+
return this.parse(this.unmaskedValue, this);
|
|
2008
2828
|
}
|
|
2009
2829
|
set typedValue(n) {
|
|
2010
|
-
this.rawInputValue = this.
|
|
2830
|
+
this.rawInputValue = this.format(n, this).replace(MaskedNumber.UNMASKED_RADIX, this.radix);
|
|
2011
2831
|
}
|
|
2012
2832
|
get number() {
|
|
2013
2833
|
return this.typedValue;
|
|
@@ -2016,19 +2836,27 @@ class MaskedNumber extends Masked {
|
|
|
2016
2836
|
this.typedValue = number;
|
|
2017
2837
|
}
|
|
2018
2838
|
get allowNegative() {
|
|
2019
|
-
return this.
|
|
2839
|
+
return this.min != null && this.min < 0 || this.max != null && this.max < 0;
|
|
2840
|
+
}
|
|
2841
|
+
get allowPositive() {
|
|
2842
|
+
return this.min != null && this.min > 0 || this.max != null && this.max > 0;
|
|
2020
2843
|
}
|
|
2021
2844
|
typedValueEquals(value) {
|
|
2022
2845
|
return (super.typedValueEquals(value) || MaskedNumber.EMPTY_VALUES.includes(value) && MaskedNumber.EMPTY_VALUES.includes(this.typedValue)) && !(value === 0 && this.value === '');
|
|
2023
2846
|
}
|
|
2024
2847
|
}
|
|
2848
|
+
_MaskedNumber = MaskedNumber;
|
|
2025
2849
|
MaskedNumber.UNMASKED_RADIX = '.';
|
|
2850
|
+
MaskedNumber.EMPTY_VALUES = [...Masked.EMPTY_VALUES, 0];
|
|
2026
2851
|
MaskedNumber.DEFAULTS = {
|
|
2852
|
+
...Masked.DEFAULTS,
|
|
2853
|
+
mask: Number,
|
|
2027
2854
|
radix: ',',
|
|
2028
2855
|
thousandsSeparator: '',
|
|
2029
|
-
mapToRadix: [
|
|
2856
|
+
mapToRadix: [_MaskedNumber.UNMASKED_RADIX],
|
|
2857
|
+
min: Number.MIN_SAFE_INTEGER,
|
|
2858
|
+
max: Number.MAX_SAFE_INTEGER,
|
|
2030
2859
|
scale: 2,
|
|
2031
|
-
signed: false,
|
|
2032
2860
|
normalizeZeros: true,
|
|
2033
2861
|
padFractionalZeros: false,
|
|
2034
2862
|
parse: Number,
|
|
@@ -2037,290 +2865,154 @@ MaskedNumber.DEFAULTS = {
|
|
|
2037
2865
|
maximumFractionDigits: 20
|
|
2038
2866
|
})
|
|
2039
2867
|
};
|
|
2040
|
-
MaskedNumber.EMPTY_VALUES = [...Masked.EMPTY_VALUES, 0];
|
|
2041
2868
|
IMask.MaskedNumber = MaskedNumber;
|
|
2042
2869
|
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2870
|
+
const PIPE_TYPE = {
|
|
2871
|
+
MASKED: 'value',
|
|
2872
|
+
UNMASKED: 'unmaskedValue',
|
|
2873
|
+
TYPED: 'typedValue'
|
|
2874
|
+
};
|
|
2875
|
+
function createPipe(arg, from, to) {
|
|
2876
|
+
if (from === void 0) {
|
|
2877
|
+
from = PIPE_TYPE.MASKED;
|
|
2047
2878
|
}
|
|
2879
|
+
if (to === void 0) {
|
|
2880
|
+
to = PIPE_TYPE.MASKED;
|
|
2881
|
+
}
|
|
2882
|
+
const masked = createMask(arg);
|
|
2883
|
+
return value => masked.runIsolated(m => {
|
|
2884
|
+
m[from] = value;
|
|
2885
|
+
return m[to];
|
|
2886
|
+
});
|
|
2048
2887
|
}
|
|
2049
|
-
|
|
2888
|
+
function pipe(value, mask, from, to) {
|
|
2889
|
+
return createPipe(mask, from, to)(value);
|
|
2890
|
+
}
|
|
2891
|
+
IMask.PIPE_TYPE = PIPE_TYPE;
|
|
2892
|
+
IMask.createPipe = createPipe;
|
|
2893
|
+
IMask.pipe = pipe;
|
|
2050
2894
|
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2895
|
+
class RepeatBlock extends MaskedPattern {
|
|
2896
|
+
get repeatFrom() {
|
|
2897
|
+
var _ref;
|
|
2898
|
+
return (_ref = Array.isArray(this.repeat) ? this.repeat[0] : this.repeat === Infinity ? 0 : this.repeat) != null ? _ref : 0;
|
|
2899
|
+
}
|
|
2900
|
+
get repeatTo() {
|
|
2901
|
+
var _ref2;
|
|
2902
|
+
return (_ref2 = Array.isArray(this.repeat) ? this.repeat[1] : this.repeat) != null ? _ref2 : Infinity;
|
|
2903
|
+
}
|
|
2054
2904
|
constructor(opts) {
|
|
2055
|
-
super(
|
|
2056
|
-
|
|
2905
|
+
super(opts);
|
|
2906
|
+
}
|
|
2907
|
+
updateOptions(opts) {
|
|
2908
|
+
super.updateOptions(opts);
|
|
2057
2909
|
}
|
|
2058
2910
|
_update(opts) {
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2911
|
+
var _ref3, _ref4, _this$_blocks;
|
|
2912
|
+
const {
|
|
2913
|
+
repeat,
|
|
2914
|
+
...blockOpts
|
|
2915
|
+
} = normalizeOpts(opts);
|
|
2916
|
+
this._blockOpts = Object.assign({}, this._blockOpts, blockOpts);
|
|
2917
|
+
const block = createMask(this._blockOpts);
|
|
2918
|
+
this.repeat = (_ref3 = (_ref4 = repeat != null ? repeat : block.repeat) != null ? _ref4 : this.repeat) != null ? _ref3 : Infinity;
|
|
2919
|
+
super._update({
|
|
2920
|
+
mask: 'm'.repeat(Math.max(this.repeatTo === Infinity && ((_this$_blocks = this._blocks) == null ? void 0 : _this$_blocks.length) || 0, this.repeatFrom)),
|
|
2921
|
+
blocks: {
|
|
2922
|
+
m: block
|
|
2923
|
+
},
|
|
2924
|
+
eager: block.eager,
|
|
2925
|
+
overwrite: block.overwrite,
|
|
2926
|
+
skipInvalid: block.skipInvalid,
|
|
2927
|
+
lazy: block.lazy,
|
|
2928
|
+
placeholderChar: block.placeholderChar,
|
|
2929
|
+
displayChar: block.displayChar
|
|
2930
|
+
});
|
|
2063
2931
|
}
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2932
|
+
_allocateBlock(bi) {
|
|
2933
|
+
if (bi < this._blocks.length) return this._blocks[bi];
|
|
2934
|
+
if (this.repeatTo === Infinity || this._blocks.length < this.repeatTo) {
|
|
2935
|
+
this._blocks.push(createMask(this._blockOpts));
|
|
2936
|
+
this.mask += 'm';
|
|
2937
|
+
return this._blocks[this._blocks.length - 1];
|
|
2069
2938
|
}
|
|
2070
|
-
return details;
|
|
2071
2939
|
}
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
const prevValueBeforeTail = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._value : this.value;
|
|
2077
|
-
const inputValue = this.rawInputValue;
|
|
2078
|
-
const insertValue = flags.tail && flags._beforeTailState != null ?
|
|
2079
|
-
flags._beforeTailState._rawInputValue : inputValue;
|
|
2080
|
-
const tailValue = inputValue.slice(insertValue.length);
|
|
2081
|
-
const prevMask = this.currentMask;
|
|
2940
|
+
_appendCharRaw(ch, flags) {
|
|
2941
|
+
if (flags === void 0) {
|
|
2942
|
+
flags = {};
|
|
2943
|
+
}
|
|
2082
2944
|
const details = new ChangeDetails();
|
|
2083
|
-
|
|
2084
|
-
this.
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
if (tailValue) {
|
|
2095
|
-
details.tailShift += this.currentMask.append(tailValue, {
|
|
2096
|
-
raw: true,
|
|
2097
|
-
tail: true
|
|
2098
|
-
}).tailShift;
|
|
2099
|
-
}
|
|
2100
|
-
} else {
|
|
2101
|
-
this.currentMask.state = prevMaskState;
|
|
2945
|
+
for (let bi = (_this$_mapPosToBlock$ = (_this$_mapPosToBlock = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : _this$_mapPosToBlock.index) != null ? _this$_mapPosToBlock$ : Math.max(this._blocks.length - 1, 0), block, allocated;
|
|
2946
|
+
block = (_this$_blocks$bi = this._blocks[bi]) != null ? _this$_blocks$bi : allocated = !allocated && this._allocateBlock(bi); ++bi) {
|
|
2947
|
+
var _this$_mapPosToBlock$, _this$_mapPosToBlock, _this$_blocks$bi, _flags$_beforeTailSta;
|
|
2948
|
+
const blockDetails = block._appendChar(ch, {
|
|
2949
|
+
...flags,
|
|
2950
|
+
_beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) == null || (_flags$_beforeTailSta = _flags$_beforeTailSta._blocks) == null ? void 0 : _flags$_beforeTailSta[bi]
|
|
2951
|
+
});
|
|
2952
|
+
if (blockDetails.skip && allocated) {
|
|
2953
|
+
this._blocks.pop();
|
|
2954
|
+
this.mask = this.mask.slice(1);
|
|
2955
|
+
break;
|
|
2102
2956
|
}
|
|
2957
|
+
details.aggregate(blockDetails);
|
|
2958
|
+
if (blockDetails.consumed) break;
|
|
2103
2959
|
}
|
|
2104
2960
|
return details;
|
|
2105
2961
|
}
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
if (
|
|
2109
|
-
|
|
2962
|
+
_trimEmptyTail(fromPos, toPos) {
|
|
2963
|
+
var _this$_mapPosToBlock2, _this$_mapPosToBlock3;
|
|
2964
|
+
if (fromPos === void 0) {
|
|
2965
|
+
fromPos = 0;
|
|
2110
2966
|
}
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2967
|
+
const firstBlockIndex = Math.max(((_this$_mapPosToBlock2 = this._mapPosToBlock(fromPos)) == null ? void 0 : _this$_mapPosToBlock2.index) || 0, this.repeatFrom, 0);
|
|
2968
|
+
let lastBlockIndex;
|
|
2969
|
+
if (toPos != null) lastBlockIndex = (_this$_mapPosToBlock3 = this._mapPosToBlock(toPos)) == null ? void 0 : _this$_mapPosToBlock3.index;
|
|
2970
|
+
if (lastBlockIndex == null) lastBlockIndex = this._blocks.length - 1;
|
|
2971
|
+
let removeCount = 0;
|
|
2972
|
+
for (let blockIndex = lastBlockIndex; firstBlockIndex <= blockIndex; --blockIndex, ++removeCount) {
|
|
2973
|
+
if (this._blocks[blockIndex].unmaskedValue) break;
|
|
2117
2974
|
}
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
const details = new ChangeDetails();
|
|
2122
|
-
if (tail) details.aggregate(this._applyDispatch('', {}, tail));
|
|
2123
|
-
return details.aggregate(this.currentMask ? this.currentMask.appendTail(tail) : super.appendTail(tail));
|
|
2124
|
-
}
|
|
2125
|
-
currentMaskFlags(flags) {
|
|
2126
|
-
var _flags$_beforeTailSta, _flags$_beforeTailSta2;
|
|
2127
|
-
return Object.assign({}, flags, {
|
|
2128
|
-
_beforeTailState: ((_flags$_beforeTailSta = flags._beforeTailState) === null || _flags$_beforeTailSta === void 0 ? void 0 : _flags$_beforeTailSta.currentMaskRef) === this.currentMask && ((_flags$_beforeTailSta2 = flags._beforeTailState) === null || _flags$_beforeTailSta2 === void 0 ? void 0 : _flags$_beforeTailSta2.currentMask) || flags._beforeTailState
|
|
2129
|
-
});
|
|
2130
|
-
}
|
|
2131
|
-
doDispatch(appended) {
|
|
2132
|
-
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2133
|
-
let tail = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
2134
|
-
return this.dispatch(appended, this, flags, tail);
|
|
2135
|
-
}
|
|
2136
|
-
doValidate(flags) {
|
|
2137
|
-
return super.doValidate(flags) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(flags)));
|
|
2138
|
-
}
|
|
2139
|
-
doPrepare(str) {
|
|
2140
|
-
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2141
|
-
let [s, details] = normalizePrepare(super.doPrepare(str, flags));
|
|
2142
|
-
if (this.currentMask) {
|
|
2143
|
-
let currentDetails;
|
|
2144
|
-
[s, currentDetails] = normalizePrepare(super.doPrepare(s, this.currentMaskFlags(flags)));
|
|
2145
|
-
details = details.aggregate(currentDetails);
|
|
2975
|
+
if (removeCount) {
|
|
2976
|
+
this._blocks.splice(lastBlockIndex - removeCount + 1, removeCount);
|
|
2977
|
+
this.mask = this.mask.slice(removeCount);
|
|
2146
2978
|
}
|
|
2147
|
-
return [s, details];
|
|
2148
2979
|
}
|
|
2149
2980
|
reset() {
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
this.compiledMasks.forEach(m => m.reset());
|
|
2153
|
-
}
|
|
2154
|
-
get value() {
|
|
2155
|
-
return this.currentMask ? this.currentMask.value : '';
|
|
2156
|
-
}
|
|
2157
|
-
set value(value) {
|
|
2158
|
-
super.value = value;
|
|
2159
|
-
}
|
|
2160
|
-
get unmaskedValue() {
|
|
2161
|
-
return this.currentMask ? this.currentMask.unmaskedValue : '';
|
|
2162
|
-
}
|
|
2163
|
-
set unmaskedValue(unmaskedValue) {
|
|
2164
|
-
super.unmaskedValue = unmaskedValue;
|
|
2165
|
-
}
|
|
2166
|
-
get typedValue() {
|
|
2167
|
-
return this.currentMask ? this.currentMask.typedValue : '';
|
|
2981
|
+
super.reset();
|
|
2982
|
+
this._trimEmptyTail();
|
|
2168
2983
|
}
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
this.currentMask.typedValue = value;
|
|
2173
|
-
unmaskedValue = this.currentMask.unmaskedValue;
|
|
2984
|
+
remove(fromPos, toPos) {
|
|
2985
|
+
if (fromPos === void 0) {
|
|
2986
|
+
fromPos = 0;
|
|
2174
2987
|
}
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
var _this$currentMask2;
|
|
2182
|
-
return Boolean((_this$currentMask2 = this.currentMask) === null || _this$currentMask2 === void 0 ? void 0 : _this$currentMask2.isComplete);
|
|
2183
|
-
}
|
|
2184
|
-
get isFilled() {
|
|
2185
|
-
var _this$currentMask3;
|
|
2186
|
-
return Boolean((_this$currentMask3 = this.currentMask) === null || _this$currentMask3 === void 0 ? void 0 : _this$currentMask3.isFilled);
|
|
2988
|
+
if (toPos === void 0) {
|
|
2989
|
+
toPos = this.displayValue.length;
|
|
2990
|
+
}
|
|
2991
|
+
const removeDetails = super.remove(fromPos, toPos);
|
|
2992
|
+
this._trimEmptyTail(fromPos, toPos);
|
|
2993
|
+
return removeDetails;
|
|
2187
2994
|
}
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
details.aggregate(this.currentMask.remove(...arguments))
|
|
2192
|
-
.aggregate(this._applyDispatch());
|
|
2995
|
+
totalInputPositions(fromPos, toPos) {
|
|
2996
|
+
if (fromPos === void 0) {
|
|
2997
|
+
fromPos = 0;
|
|
2193
2998
|
}
|
|
2194
|
-
return
|
|
2999
|
+
if (toPos == null && this.repeatTo === Infinity) return Infinity;
|
|
3000
|
+
return super.totalInputPositions(fromPos, toPos);
|
|
2195
3001
|
}
|
|
2196
3002
|
get state() {
|
|
2197
|
-
|
|
2198
|
-
return Object.assign({}, super.state, {
|
|
2199
|
-
_rawInputValue: this.rawInputValue,
|
|
2200
|
-
compiledMasks: this.compiledMasks.map(m => m.state),
|
|
2201
|
-
currentMaskRef: this.currentMask,
|
|
2202
|
-
currentMask: (_this$currentMask4 = this.currentMask) === null || _this$currentMask4 === void 0 ? void 0 : _this$currentMask4.state
|
|
2203
|
-
});
|
|
3003
|
+
return super.state;
|
|
2204
3004
|
}
|
|
2205
3005
|
set state(state) {
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
currentMask
|
|
2210
|
-
} = state,
|
|
2211
|
-
maskedState = _objectWithoutPropertiesLoose(state, _excluded);
|
|
2212
|
-
this.compiledMasks.forEach((m, mi) => m.state = compiledMasks[mi]);
|
|
2213
|
-
if (currentMaskRef != null) {
|
|
2214
|
-
this.currentMask = currentMaskRef;
|
|
2215
|
-
this.currentMask.state = currentMask;
|
|
2216
|
-
}
|
|
2217
|
-
super.state = maskedState;
|
|
2218
|
-
}
|
|
2219
|
-
extractInput() {
|
|
2220
|
-
return this.currentMask ? this.currentMask.extractInput(...arguments) : '';
|
|
2221
|
-
}
|
|
2222
|
-
extractTail() {
|
|
2223
|
-
return this.currentMask ? this.currentMask.extractTail(...arguments) : super.extractTail(...arguments);
|
|
2224
|
-
}
|
|
2225
|
-
doCommit() {
|
|
2226
|
-
if (this.currentMask) this.currentMask.doCommit();
|
|
2227
|
-
super.doCommit();
|
|
2228
|
-
}
|
|
2229
|
-
nearestInputPos() {
|
|
2230
|
-
return this.currentMask ? this.currentMask.nearestInputPos(...arguments) : super.nearestInputPos(...arguments);
|
|
2231
|
-
}
|
|
2232
|
-
get overwrite() {
|
|
2233
|
-
return this.currentMask ? this.currentMask.overwrite : super.overwrite;
|
|
2234
|
-
}
|
|
2235
|
-
set overwrite(overwrite) {
|
|
2236
|
-
console.warn('"overwrite" option is not available in dynamic mask, use this option in siblings');
|
|
2237
|
-
}
|
|
2238
|
-
get eager() {
|
|
2239
|
-
return this.currentMask ? this.currentMask.eager : super.eager;
|
|
2240
|
-
}
|
|
2241
|
-
set eager(eager) {
|
|
2242
|
-
console.warn('"eager" option is not available in dynamic mask, use this option in siblings');
|
|
2243
|
-
}
|
|
2244
|
-
get skipInvalid() {
|
|
2245
|
-
return this.currentMask ? this.currentMask.skipInvalid : super.skipInvalid;
|
|
2246
|
-
}
|
|
2247
|
-
set skipInvalid(skipInvalid) {
|
|
2248
|
-
if (this.isInitialized || skipInvalid !== Masked.DEFAULTS.skipInvalid) {
|
|
2249
|
-
console.warn('"skipInvalid" option is not available in dynamic mask, use this option in siblings');
|
|
2250
|
-
}
|
|
2251
|
-
}
|
|
2252
|
-
maskEquals(mask) {
|
|
2253
|
-
return Array.isArray(mask) && this.compiledMasks.every((m, mi) => {
|
|
2254
|
-
if (!mask[mi]) return;
|
|
2255
|
-
const _mask$mi = mask[mi],
|
|
2256
|
-
{
|
|
2257
|
-
mask: oldMask
|
|
2258
|
-
} = _mask$mi,
|
|
2259
|
-
restOpts = _objectWithoutPropertiesLoose(_mask$mi, _excluded2);
|
|
2260
|
-
return objectIncludes(m, restOpts) && m.maskEquals(oldMask);
|
|
2261
|
-
});
|
|
2262
|
-
}
|
|
2263
|
-
typedValueEquals(value) {
|
|
2264
|
-
var _this$currentMask5;
|
|
2265
|
-
return Boolean((_this$currentMask5 = this.currentMask) === null || _this$currentMask5 === void 0 ? void 0 : _this$currentMask5.typedValueEquals(value));
|
|
2266
|
-
}
|
|
2267
|
-
}
|
|
2268
|
-
MaskedDynamic.DEFAULTS = {
|
|
2269
|
-
dispatch: (appended, masked, flags, tail) => {
|
|
2270
|
-
if (!masked.compiledMasks.length) return;
|
|
2271
|
-
const inputValue = masked.rawInputValue;
|
|
2272
|
-
const inputs = masked.compiledMasks.map((m, index) => {
|
|
2273
|
-
const isCurrent = masked.currentMask === m;
|
|
2274
|
-
const startInputPos = isCurrent ? m.value.length : m.nearestInputPos(m.value.length, DIRECTION.FORCE_LEFT);
|
|
2275
|
-
if (m.rawInputValue !== inputValue) {
|
|
2276
|
-
m.reset();
|
|
2277
|
-
m.append(inputValue, {
|
|
2278
|
-
raw: true
|
|
2279
|
-
});
|
|
2280
|
-
} else if (!isCurrent) {
|
|
2281
|
-
m.remove(startInputPos);
|
|
2282
|
-
}
|
|
2283
|
-
m.append(appended, masked.currentMaskFlags(flags));
|
|
2284
|
-
m.appendTail(tail);
|
|
2285
|
-
return {
|
|
2286
|
-
index,
|
|
2287
|
-
weight: m.rawInputValue.length,
|
|
2288
|
-
totalInputPositions: m.totalInputPositions(0, Math.max(startInputPos, m.nearestInputPos(m.value.length, DIRECTION.FORCE_LEFT)))
|
|
2289
|
-
};
|
|
2290
|
-
});
|
|
2291
|
-
inputs.sort((i1, i2) => i2.weight - i1.weight || i2.totalInputPositions - i1.totalInputPositions);
|
|
2292
|
-
return masked.compiledMasks[inputs[0].index];
|
|
2293
|
-
}
|
|
2294
|
-
};
|
|
2295
|
-
IMask.MaskedDynamic = MaskedDynamic;
|
|
2296
|
-
|
|
2297
|
-
const PIPE_TYPE = {
|
|
2298
|
-
MASKED: 'value',
|
|
2299
|
-
UNMASKED: 'unmaskedValue',
|
|
2300
|
-
TYPED: 'typedValue'
|
|
2301
|
-
};
|
|
2302
|
-
function createPipe(mask) {
|
|
2303
|
-
let from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : PIPE_TYPE.MASKED;
|
|
2304
|
-
let to = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : PIPE_TYPE.MASKED;
|
|
2305
|
-
const masked = createMask(mask);
|
|
2306
|
-
return value => masked.runIsolated(m => {
|
|
2307
|
-
m[from] = value;
|
|
2308
|
-
return m[to];
|
|
2309
|
-
});
|
|
2310
|
-
}
|
|
2311
|
-
function pipe(value) {
|
|
2312
|
-
for (var _len = arguments.length, pipeArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2313
|
-
pipeArgs[_key - 1] = arguments[_key];
|
|
3006
|
+
this._blocks.length = state._blocks.length;
|
|
3007
|
+
this.mask = this.mask.slice(0, this._blocks.length);
|
|
3008
|
+
super.state = state;
|
|
2314
3009
|
}
|
|
2315
|
-
return createPipe(...pipeArgs)(value);
|
|
2316
3010
|
}
|
|
2317
|
-
IMask.
|
|
2318
|
-
IMask.createPipe = createPipe;
|
|
2319
|
-
IMask.pipe = pipe;
|
|
3011
|
+
IMask.RepeatBlock = RepeatBlock;
|
|
2320
3012
|
|
|
2321
3013
|
try {
|
|
2322
3014
|
globalThis.IMask = IMask;
|
|
2323
|
-
} catch
|
|
3015
|
+
} catch {}
|
|
2324
3016
|
|
|
2325
3017
|
var maskElementList = [].slice.call(document.querySelectorAll('[data-mask]'));
|
|
2326
3018
|
maskElementList.map(function (maskEl) {
|
|
@@ -3864,8 +4556,8 @@ var Popper = /*#__PURE__*/Object.freeze({
|
|
|
3864
4556
|
});
|
|
3865
4557
|
|
|
3866
4558
|
/*!
|
|
3867
|
-
* Bootstrap v5.3.
|
|
3868
|
-
* Copyright 2011-
|
|
4559
|
+
* Bootstrap v5.3.3 (https://getbootstrap.com/)
|
|
4560
|
+
* Copyright 2011-2024 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
|
3869
4561
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
3870
4562
|
*/
|
|
3871
4563
|
const elementMap = new Map();
|
|
@@ -4371,7 +5063,7 @@ class Config {
|
|
|
4371
5063
|
}
|
|
4372
5064
|
}
|
|
4373
5065
|
}
|
|
4374
|
-
const VERSION = '5.3.
|
|
5066
|
+
const VERSION = '5.3.3';
|
|
4375
5067
|
class BaseComponent extends Config {
|
|
4376
5068
|
constructor(element, config) {
|
|
4377
5069
|
super();
|
|
@@ -4430,7 +5122,7 @@ const getSelector = element => {
|
|
|
4430
5122
|
}
|
|
4431
5123
|
selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null;
|
|
4432
5124
|
}
|
|
4433
|
-
return parseSelector(
|
|
5125
|
+
return selector ? selector.split(',').map(sel => parseSelector(sel)).join(',') : null;
|
|
4434
5126
|
};
|
|
4435
5127
|
const SelectorEngine = {
|
|
4436
5128
|
find(selector, element = document.documentElement) {
|
|
@@ -6191,7 +6883,10 @@ const DefaultAllowlist = {
|
|
|
6191
6883
|
br: [],
|
|
6192
6884
|
col: [],
|
|
6193
6885
|
code: [],
|
|
6886
|
+
dd: [],
|
|
6194
6887
|
div: [],
|
|
6888
|
+
dl: [],
|
|
6889
|
+
dt: [],
|
|
6195
6890
|
em: [],
|
|
6196
6891
|
hr: [],
|
|
6197
6892
|
h1: [],
|
|
@@ -7091,7 +7786,7 @@ const CLASS_NAME_SHOW$1 = 'show';
|
|
|
7091
7786
|
const CLASS_DROPDOWN = 'dropdown';
|
|
7092
7787
|
const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
|
|
7093
7788
|
const SELECTOR_DROPDOWN_MENU = '.dropdown-menu';
|
|
7094
|
-
const NOT_SELECTOR_DROPDOWN_TOGGLE =
|
|
7789
|
+
const NOT_SELECTOR_DROPDOWN_TOGGLE = `:not(${SELECTOR_DROPDOWN_TOGGLE})`;
|
|
7095
7790
|
const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]';
|
|
7096
7791
|
const SELECTOR_OUTER = '.nav-item, .list-group-item';
|
|
7097
7792
|
const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`;
|
|
@@ -7478,5 +8173,11 @@ switchesTriggerList.map(function (switchTriggerEl) {
|
|
|
7478
8173
|
|
|
7479
8174
|
var toastsTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="toast"]'));
|
|
7480
8175
|
toastsTriggerList.map(function (toastTriggerEl) {
|
|
7481
|
-
|
|
8176
|
+
if (!toastTriggerEl.hasAttribute('data-bs-target')) {
|
|
8177
|
+
return;
|
|
8178
|
+
}
|
|
8179
|
+
var toastEl = new Toast(toastTriggerEl.getAttribute('data-bs-target'));
|
|
8180
|
+
toastTriggerEl.addEventListener('click', function () {
|
|
8181
|
+
toastEl.show();
|
|
8182
|
+
});
|
|
7482
8183
|
});
|