@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.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
|
(function (factory) {
|
|
@@ -20,49 +20,21 @@
|
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
24
|
-
if (source == null) return {};
|
|
25
|
-
var target = {};
|
|
26
|
-
var sourceKeys = Object.keys(source);
|
|
27
|
-
var key, i;
|
|
28
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
29
|
-
key = sourceKeys[i];
|
|
30
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
31
|
-
target[key] = source[key];
|
|
32
|
-
}
|
|
33
|
-
return target;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function IMask(el) {
|
|
37
|
-
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
38
|
-
return new IMask.InputMask(el, opts);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
class ChangeDetails {
|
|
42
|
-
constructor(details) {
|
|
43
|
-
Object.assign(this, {
|
|
44
|
-
inserted: '',
|
|
45
|
-
rawInserted: '',
|
|
46
|
-
skip: false,
|
|
47
|
-
tailShift: 0
|
|
48
|
-
}, details);
|
|
49
|
-
}
|
|
50
|
-
aggregate(details) {
|
|
51
|
-
this.rawInserted += details.rawInserted;
|
|
52
|
-
this.skip = this.skip || details.skip;
|
|
53
|
-
this.inserted += details.inserted;
|
|
54
|
-
this.tailShift += details.tailShift;
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
get offset() {
|
|
58
|
-
return this.tailShift + this.inserted.length;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
IMask.ChangeDetails = ChangeDetails;
|
|
62
|
-
|
|
63
23
|
function isString(str) {
|
|
64
24
|
return typeof str === 'string' || str instanceof String;
|
|
65
25
|
}
|
|
26
|
+
function isObject(obj) {
|
|
27
|
+
var _obj$constructor;
|
|
28
|
+
return typeof obj === 'object' && obj != null && (obj == null || (_obj$constructor = obj.constructor) == null ? void 0 : _obj$constructor.name) === 'Object';
|
|
29
|
+
}
|
|
30
|
+
function pick(obj, keys) {
|
|
31
|
+
if (Array.isArray(keys)) return pick(obj, (_, k) => keys.includes(k));
|
|
32
|
+
return Object.entries(obj).reduce((acc, _ref) => {
|
|
33
|
+
let [k, v] = _ref;
|
|
34
|
+
if (keys(v, k)) acc[k] = v;
|
|
35
|
+
return acc;
|
|
36
|
+
}, {});
|
|
37
|
+
}
|
|
66
38
|
const DIRECTION = {
|
|
67
39
|
NONE: 'NONE',
|
|
68
40
|
LEFT: 'LEFT',
|
|
@@ -81,16 +53,13 @@
|
|
|
81
53
|
}
|
|
82
54
|
}
|
|
83
55
|
function escapeRegExp(str) {
|
|
84
|
-
return str.replace(/([.*+?^=!:${}()|[\]
|
|
85
|
-
}
|
|
86
|
-
function normalizePrepare(prep) {
|
|
87
|
-
return Array.isArray(prep) ? prep : [prep, new ChangeDetails()];
|
|
56
|
+
return str.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1');
|
|
88
57
|
}
|
|
89
58
|
function objectIncludes(b, a) {
|
|
90
59
|
if (a === b) return true;
|
|
91
|
-
|
|
92
|
-
arrB = Array.isArray(b)
|
|
93
|
-
|
|
60
|
+
const arrA = Array.isArray(a),
|
|
61
|
+
arrB = Array.isArray(b);
|
|
62
|
+
let i;
|
|
94
63
|
if (arrA && arrB) {
|
|
95
64
|
if (a.length != b.length) return false;
|
|
96
65
|
for (i = 0; i < a.length; i++) if (!objectIncludes(a[i], b[i])) return false;
|
|
@@ -98,17 +67,16 @@
|
|
|
98
67
|
}
|
|
99
68
|
if (arrA != arrB) return false;
|
|
100
69
|
if (a && b && typeof a === 'object' && typeof b === 'object') {
|
|
101
|
-
|
|
70
|
+
const dateA = a instanceof Date,
|
|
102
71
|
dateB = b instanceof Date;
|
|
103
72
|
if (dateA && dateB) return a.getTime() == b.getTime();
|
|
104
73
|
if (dateA != dateB) return false;
|
|
105
|
-
|
|
74
|
+
const regexpA = a instanceof RegExp,
|
|
106
75
|
regexpB = b instanceof RegExp;
|
|
107
76
|
if (regexpA && regexpB) return a.toString() == b.toString();
|
|
108
77
|
if (regexpA != regexpB) return false;
|
|
109
|
-
|
|
110
|
-
for (i = 0; i < keys.length; i++)
|
|
111
|
-
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
78
|
+
const keys = Object.keys(a);
|
|
79
|
+
for (i = 0; i < keys.length; i++) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
|
|
112
80
|
for (i = 0; i < keys.length; i++) if (!objectIncludes(b[keys[i]], a[keys[i]])) return false;
|
|
113
81
|
return true;
|
|
114
82
|
} else if (a && b && typeof a === 'function' && typeof b === 'function') {
|
|
@@ -118,14 +86,16 @@
|
|
|
118
86
|
}
|
|
119
87
|
|
|
120
88
|
class ActionDetails {
|
|
121
|
-
constructor(
|
|
122
|
-
this
|
|
123
|
-
this.cursorPos = cursorPos;
|
|
124
|
-
this.oldValue = oldValue;
|
|
125
|
-
this.oldSelection = oldSelection;
|
|
89
|
+
constructor(opts) {
|
|
90
|
+
Object.assign(this, opts);
|
|
126
91
|
while (this.value.slice(0, this.startChangePos) !== this.oldValue.slice(0, this.startChangePos)) {
|
|
127
92
|
--this.oldSelection.start;
|
|
128
93
|
}
|
|
94
|
+
if (this.insertedCount) {
|
|
95
|
+
while (this.value.slice(this.cursorPos) !== this.oldValue.slice(this.oldSelection.end)) {
|
|
96
|
+
if (this.value.length - this.cursorPos < this.oldValue.length - this.oldSelection.end) ++this.oldSelection.end;else ++this.cursorPos;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
129
99
|
}
|
|
130
100
|
get startChangePos() {
|
|
131
101
|
return Math.min(this.cursorPos, this.oldSelection.start);
|
|
@@ -156,146 +126,718 @@
|
|
|
156
126
|
}
|
|
157
127
|
}
|
|
158
128
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
129
|
+
function IMask(el, opts) {
|
|
130
|
+
return new IMask.InputMask(el, opts);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function maskedClass(mask) {
|
|
134
|
+
if (mask == null) throw new Error('mask property should be defined');
|
|
135
|
+
if (mask instanceof RegExp) return IMask.MaskedRegExp;
|
|
136
|
+
if (isString(mask)) return IMask.MaskedPattern;
|
|
137
|
+
if (mask === Date) return IMask.MaskedDate;
|
|
138
|
+
if (mask === Number) return IMask.MaskedNumber;
|
|
139
|
+
if (Array.isArray(mask) || mask === Array) return IMask.MaskedDynamic;
|
|
140
|
+
if (IMask.Masked && mask.prototype instanceof IMask.Masked) return mask;
|
|
141
|
+
if (IMask.Masked && mask instanceof IMask.Masked) return mask.constructor;
|
|
142
|
+
if (mask instanceof Function) return IMask.MaskedFunction;
|
|
143
|
+
console.warn('Mask not found for mask', mask);
|
|
144
|
+
return IMask.Masked;
|
|
145
|
+
}
|
|
146
|
+
function normalizeOpts(opts) {
|
|
147
|
+
if (!opts) throw new Error('Options in not defined');
|
|
148
|
+
if (IMask.Masked) {
|
|
149
|
+
if (opts.prototype instanceof IMask.Masked) return {
|
|
150
|
+
mask: opts
|
|
151
|
+
};
|
|
152
|
+
const {
|
|
153
|
+
mask = undefined,
|
|
154
|
+
...instanceOpts
|
|
155
|
+
} = opts instanceof IMask.Masked ? {
|
|
156
|
+
mask: opts
|
|
157
|
+
} : isObject(opts) && opts.mask instanceof IMask.Masked ? opts : {};
|
|
158
|
+
if (mask) {
|
|
159
|
+
const _mask = mask.mask;
|
|
160
|
+
return {
|
|
161
|
+
...pick(mask, (_, k) => !k.startsWith('_')),
|
|
162
|
+
mask: mask.constructor,
|
|
163
|
+
_mask,
|
|
164
|
+
...instanceOpts
|
|
165
|
+
};
|
|
166
|
+
}
|
|
173
167
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
168
|
+
if (!isObject(opts)) return {
|
|
169
|
+
mask: opts
|
|
170
|
+
};
|
|
171
|
+
return {
|
|
172
|
+
...opts
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function createMask(opts) {
|
|
176
|
+
if (IMask.Masked && opts instanceof IMask.Masked) return opts;
|
|
177
|
+
const nOpts = normalizeOpts(opts);
|
|
178
|
+
const MaskedClass = maskedClass(nOpts.mask);
|
|
179
|
+
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.");
|
|
180
|
+
if (nOpts.mask === MaskedClass) delete nOpts.mask;
|
|
181
|
+
if (nOpts._mask) {
|
|
182
|
+
nOpts.mask = nOpts._mask;
|
|
183
|
+
delete nOpts._mask;
|
|
178
184
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
+
return new MaskedClass(nOpts);
|
|
186
|
+
}
|
|
187
|
+
IMask.createMask = createMask;
|
|
188
|
+
|
|
189
|
+
class MaskElement {
|
|
190
|
+
get selectionStart() {
|
|
191
|
+
let start;
|
|
192
|
+
try {
|
|
193
|
+
start = this._unsafeSelectionStart;
|
|
194
|
+
} catch {}
|
|
195
|
+
return start != null ? start : this.value.length;
|
|
185
196
|
}
|
|
186
|
-
|
|
187
|
-
|
|
197
|
+
get selectionEnd() {
|
|
198
|
+
let end;
|
|
199
|
+
try {
|
|
200
|
+
end = this._unsafeSelectionEnd;
|
|
201
|
+
} catch {}
|
|
202
|
+
return end != null ? end : this.value.length;
|
|
188
203
|
}
|
|
189
|
-
|
|
190
|
-
if (
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
204
|
+
select(start, end) {
|
|
205
|
+
if (start == null || end == null || start === this.selectionStart && end === this.selectionEnd) return;
|
|
206
|
+
try {
|
|
207
|
+
this._unsafeSelect(start, end);
|
|
208
|
+
} catch {}
|
|
194
209
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
const shiftChar = this.value[this.value.length - 1];
|
|
198
|
-
this.value = this.value.slice(0, -1);
|
|
199
|
-
return shiftChar;
|
|
210
|
+
get isActive() {
|
|
211
|
+
return false;
|
|
200
212
|
}
|
|
201
213
|
}
|
|
214
|
+
IMask.MaskElement = MaskElement;
|
|
202
215
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
216
|
+
const KEY_Z = 90;
|
|
217
|
+
const KEY_Y = 89;
|
|
218
|
+
class HTMLMaskElement extends MaskElement {
|
|
219
|
+
constructor(input) {
|
|
220
|
+
super();
|
|
221
|
+
this.input = input;
|
|
222
|
+
this._onKeydown = this._onKeydown.bind(this);
|
|
223
|
+
this._onInput = this._onInput.bind(this);
|
|
224
|
+
this._onBeforeinput = this._onBeforeinput.bind(this);
|
|
225
|
+
this._onCompositionEnd = this._onCompositionEnd.bind(this);
|
|
208
226
|
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
227
|
+
get rootElement() {
|
|
228
|
+
var _this$input$getRootNo, _this$input$getRootNo2, _this$input;
|
|
229
|
+
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;
|
|
212
230
|
}
|
|
213
|
-
|
|
214
|
-
|
|
231
|
+
get isActive() {
|
|
232
|
+
return this.input === this.rootElement.activeElement;
|
|
215
233
|
}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
234
|
+
bindEvents(handlers) {
|
|
235
|
+
this.input.addEventListener('keydown', this._onKeydown);
|
|
236
|
+
this.input.addEventListener('input', this._onInput);
|
|
237
|
+
this.input.addEventListener('beforeinput', this._onBeforeinput);
|
|
238
|
+
this.input.addEventListener('compositionend', this._onCompositionEnd);
|
|
239
|
+
this.input.addEventListener('drop', handlers.drop);
|
|
240
|
+
this.input.addEventListener('click', handlers.click);
|
|
241
|
+
this.input.addEventListener('focus', handlers.focus);
|
|
242
|
+
this.input.addEventListener('blur', handlers.commit);
|
|
243
|
+
this._handlers = handlers;
|
|
220
244
|
}
|
|
221
|
-
|
|
222
|
-
this.
|
|
245
|
+
_onKeydown(e) {
|
|
246
|
+
if (this._handlers.redo && (e.keyCode === KEY_Z && e.shiftKey && (e.metaKey || e.ctrlKey) || e.keyCode === KEY_Y && e.ctrlKey)) {
|
|
247
|
+
e.preventDefault();
|
|
248
|
+
return this._handlers.redo(e);
|
|
249
|
+
}
|
|
250
|
+
if (this._handlers.undo && e.keyCode === KEY_Z && (e.metaKey || e.ctrlKey)) {
|
|
251
|
+
e.preventDefault();
|
|
252
|
+
return this._handlers.undo(e);
|
|
253
|
+
}
|
|
254
|
+
if (!e.isComposing) this._handlers.selectionChange(e);
|
|
223
255
|
}
|
|
224
|
-
|
|
225
|
-
|
|
256
|
+
_onBeforeinput(e) {
|
|
257
|
+
if (e.inputType === 'historyUndo' && this._handlers.undo) {
|
|
258
|
+
e.preventDefault();
|
|
259
|
+
return this._handlers.undo(e);
|
|
260
|
+
}
|
|
261
|
+
if (e.inputType === 'historyRedo' && this._handlers.redo) {
|
|
262
|
+
e.preventDefault();
|
|
263
|
+
return this._handlers.redo(e);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
_onCompositionEnd(e) {
|
|
267
|
+
this._handlers.input(e);
|
|
268
|
+
}
|
|
269
|
+
_onInput(e) {
|
|
270
|
+
if (!e.isComposing) this._handlers.input(e);
|
|
271
|
+
}
|
|
272
|
+
unbindEvents() {
|
|
273
|
+
this.input.removeEventListener('keydown', this._onKeydown);
|
|
274
|
+
this.input.removeEventListener('input', this._onInput);
|
|
275
|
+
this.input.removeEventListener('beforeinput', this._onBeforeinput);
|
|
276
|
+
this.input.removeEventListener('compositionend', this._onCompositionEnd);
|
|
277
|
+
this.input.removeEventListener('drop', this._handlers.drop);
|
|
278
|
+
this.input.removeEventListener('click', this._handlers.click);
|
|
279
|
+
this.input.removeEventListener('focus', this._handlers.focus);
|
|
280
|
+
this.input.removeEventListener('blur', this._handlers.commit);
|
|
281
|
+
this._handlers = {};
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
IMask.HTMLMaskElement = HTMLMaskElement;
|
|
285
|
+
|
|
286
|
+
class HTMLInputMaskElement extends HTMLMaskElement {
|
|
287
|
+
constructor(input) {
|
|
288
|
+
super(input);
|
|
289
|
+
this.input = input;
|
|
290
|
+
}
|
|
291
|
+
get _unsafeSelectionStart() {
|
|
292
|
+
return this.input.selectionStart != null ? this.input.selectionStart : this.value.length;
|
|
293
|
+
}
|
|
294
|
+
get _unsafeSelectionEnd() {
|
|
295
|
+
return this.input.selectionEnd;
|
|
296
|
+
}
|
|
297
|
+
_unsafeSelect(start, end) {
|
|
298
|
+
this.input.setSelectionRange(start, end);
|
|
226
299
|
}
|
|
227
300
|
get value() {
|
|
228
|
-
return this.
|
|
301
|
+
return this.input.value;
|
|
229
302
|
}
|
|
230
303
|
set value(value) {
|
|
231
|
-
this.
|
|
304
|
+
this.input.value = value;
|
|
232
305
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
this.
|
|
239
|
-
|
|
306
|
+
}
|
|
307
|
+
IMask.HTMLMaskElement = HTMLMaskElement;
|
|
308
|
+
|
|
309
|
+
class HTMLContenteditableMaskElement extends HTMLMaskElement {
|
|
310
|
+
get _unsafeSelectionStart() {
|
|
311
|
+
const root = this.rootElement;
|
|
312
|
+
const selection = root.getSelection && root.getSelection();
|
|
313
|
+
const anchorOffset = selection && selection.anchorOffset;
|
|
314
|
+
const focusOffset = selection && selection.focusOffset;
|
|
315
|
+
if (focusOffset == null || anchorOffset == null || anchorOffset < focusOffset) {
|
|
316
|
+
return anchorOffset;
|
|
317
|
+
}
|
|
318
|
+
return focusOffset;
|
|
240
319
|
}
|
|
241
|
-
get
|
|
242
|
-
|
|
320
|
+
get _unsafeSelectionEnd() {
|
|
321
|
+
const root = this.rootElement;
|
|
322
|
+
const selection = root.getSelection && root.getSelection();
|
|
323
|
+
const anchorOffset = selection && selection.anchorOffset;
|
|
324
|
+
const focusOffset = selection && selection.focusOffset;
|
|
325
|
+
if (focusOffset == null || anchorOffset == null || anchorOffset > focusOffset) {
|
|
326
|
+
return anchorOffset;
|
|
327
|
+
}
|
|
328
|
+
return focusOffset;
|
|
243
329
|
}
|
|
244
|
-
|
|
245
|
-
this.
|
|
246
|
-
this.
|
|
247
|
-
this.
|
|
330
|
+
_unsafeSelect(start, end) {
|
|
331
|
+
if (!this.rootElement.createRange) return;
|
|
332
|
+
const range = this.rootElement.createRange();
|
|
333
|
+
range.setStart(this.input.firstChild || this.input, start);
|
|
334
|
+
range.setEnd(this.input.lastChild || this.input, end);
|
|
335
|
+
const root = this.rootElement;
|
|
336
|
+
const selection = root.getSelection && root.getSelection();
|
|
337
|
+
if (selection) {
|
|
338
|
+
selection.removeAllRanges();
|
|
339
|
+
selection.addRange(range);
|
|
340
|
+
}
|
|
248
341
|
}
|
|
249
|
-
get
|
|
250
|
-
return this.
|
|
342
|
+
get value() {
|
|
343
|
+
return this.input.textContent || '';
|
|
251
344
|
}
|
|
252
|
-
set
|
|
253
|
-
this.
|
|
345
|
+
set value(value) {
|
|
346
|
+
this.input.textContent = value;
|
|
254
347
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
348
|
+
}
|
|
349
|
+
IMask.HTMLContenteditableMaskElement = HTMLContenteditableMaskElement;
|
|
350
|
+
|
|
351
|
+
class InputHistory {
|
|
352
|
+
constructor() {
|
|
353
|
+
this.states = [];
|
|
354
|
+
this.currentIndex = 0;
|
|
259
355
|
}
|
|
260
|
-
|
|
261
|
-
this.
|
|
262
|
-
this.append(value, {
|
|
263
|
-
raw: true
|
|
264
|
-
}, '');
|
|
265
|
-
this.doCommit();
|
|
356
|
+
get currentState() {
|
|
357
|
+
return this.states[this.currentIndex];
|
|
266
358
|
}
|
|
267
|
-
get
|
|
268
|
-
return this.
|
|
359
|
+
get isEmpty() {
|
|
360
|
+
return this.states.length === 0;
|
|
269
361
|
}
|
|
270
|
-
|
|
271
|
-
|
|
362
|
+
push(state) {
|
|
363
|
+
if (this.currentIndex < this.states.length - 1) this.states.length = this.currentIndex + 1;
|
|
364
|
+
this.states.push(state);
|
|
365
|
+
if (this.states.length > InputHistory.MAX_LENGTH) this.states.shift();
|
|
366
|
+
this.currentIndex = this.states.length - 1;
|
|
272
367
|
}
|
|
273
|
-
|
|
274
|
-
|
|
368
|
+
go(steps) {
|
|
369
|
+
this.currentIndex = Math.min(Math.max(this.currentIndex + steps, 0), this.states.length - 1);
|
|
370
|
+
return this.currentState;
|
|
275
371
|
}
|
|
276
|
-
|
|
277
|
-
return
|
|
372
|
+
undo() {
|
|
373
|
+
return this.go(-1);
|
|
278
374
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
|
|
282
|
-
return Math.min(this.value.length, toPos - fromPos);
|
|
375
|
+
redo() {
|
|
376
|
+
return this.go(+1);
|
|
283
377
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
return this.value.slice(fromPos, toPos);
|
|
378
|
+
clear() {
|
|
379
|
+
this.states.length = 0;
|
|
380
|
+
this.currentIndex = 0;
|
|
288
381
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
382
|
+
}
|
|
383
|
+
InputHistory.MAX_LENGTH = 100;
|
|
384
|
+
|
|
385
|
+
class InputMask {
|
|
386
|
+
constructor(el, opts) {
|
|
387
|
+
this.el = el instanceof MaskElement ? el : el.isContentEditable && el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA' ? new HTMLContenteditableMaskElement(el) : new HTMLInputMaskElement(el);
|
|
388
|
+
this.masked = createMask(opts);
|
|
389
|
+
this._listeners = {};
|
|
390
|
+
this._value = '';
|
|
391
|
+
this._unmaskedValue = '';
|
|
392
|
+
this._rawInputValue = '';
|
|
393
|
+
this.history = new InputHistory();
|
|
394
|
+
this._saveSelection = this._saveSelection.bind(this);
|
|
395
|
+
this._onInput = this._onInput.bind(this);
|
|
396
|
+
this._onChange = this._onChange.bind(this);
|
|
397
|
+
this._onDrop = this._onDrop.bind(this);
|
|
398
|
+
this._onFocus = this._onFocus.bind(this);
|
|
399
|
+
this._onClick = this._onClick.bind(this);
|
|
400
|
+
this._onUndo = this._onUndo.bind(this);
|
|
401
|
+
this._onRedo = this._onRedo.bind(this);
|
|
402
|
+
this.alignCursor = this.alignCursor.bind(this);
|
|
403
|
+
this.alignCursorFriendly = this.alignCursorFriendly.bind(this);
|
|
404
|
+
this._bindEvents();
|
|
405
|
+
this.updateValue();
|
|
406
|
+
this._onChange();
|
|
293
407
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
return
|
|
408
|
+
maskEquals(mask) {
|
|
409
|
+
var _this$masked;
|
|
410
|
+
return mask == null || ((_this$masked = this.masked) == null ? void 0 : _this$masked.maskEquals(mask));
|
|
297
411
|
}
|
|
298
|
-
|
|
412
|
+
get mask() {
|
|
413
|
+
return this.masked.mask;
|
|
414
|
+
}
|
|
415
|
+
set mask(mask) {
|
|
416
|
+
if (this.maskEquals(mask)) return;
|
|
417
|
+
if (!(mask instanceof IMask.Masked) && this.masked.constructor === maskedClass(mask)) {
|
|
418
|
+
this.masked.updateOptions({
|
|
419
|
+
mask
|
|
420
|
+
});
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
const masked = mask instanceof IMask.Masked ? mask : createMask({
|
|
424
|
+
mask
|
|
425
|
+
});
|
|
426
|
+
masked.unmaskedValue = this.masked.unmaskedValue;
|
|
427
|
+
this.masked = masked;
|
|
428
|
+
}
|
|
429
|
+
get value() {
|
|
430
|
+
return this._value;
|
|
431
|
+
}
|
|
432
|
+
set value(str) {
|
|
433
|
+
if (this.value === str) return;
|
|
434
|
+
this.masked.value = str;
|
|
435
|
+
this.updateControl('auto');
|
|
436
|
+
}
|
|
437
|
+
get unmaskedValue() {
|
|
438
|
+
return this._unmaskedValue;
|
|
439
|
+
}
|
|
440
|
+
set unmaskedValue(str) {
|
|
441
|
+
if (this.unmaskedValue === str) return;
|
|
442
|
+
this.masked.unmaskedValue = str;
|
|
443
|
+
this.updateControl('auto');
|
|
444
|
+
}
|
|
445
|
+
get rawInputValue() {
|
|
446
|
+
return this._rawInputValue;
|
|
447
|
+
}
|
|
448
|
+
set rawInputValue(str) {
|
|
449
|
+
if (this.rawInputValue === str) return;
|
|
450
|
+
this.masked.rawInputValue = str;
|
|
451
|
+
this.updateControl();
|
|
452
|
+
this.alignCursor();
|
|
453
|
+
}
|
|
454
|
+
get typedValue() {
|
|
455
|
+
return this.masked.typedValue;
|
|
456
|
+
}
|
|
457
|
+
set typedValue(val) {
|
|
458
|
+
if (this.masked.typedValueEquals(val)) return;
|
|
459
|
+
this.masked.typedValue = val;
|
|
460
|
+
this.updateControl('auto');
|
|
461
|
+
}
|
|
462
|
+
get displayValue() {
|
|
463
|
+
return this.masked.displayValue;
|
|
464
|
+
}
|
|
465
|
+
_bindEvents() {
|
|
466
|
+
this.el.bindEvents({
|
|
467
|
+
selectionChange: this._saveSelection,
|
|
468
|
+
input: this._onInput,
|
|
469
|
+
drop: this._onDrop,
|
|
470
|
+
click: this._onClick,
|
|
471
|
+
focus: this._onFocus,
|
|
472
|
+
commit: this._onChange,
|
|
473
|
+
undo: this._onUndo,
|
|
474
|
+
redo: this._onRedo
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
_unbindEvents() {
|
|
478
|
+
if (this.el) this.el.unbindEvents();
|
|
479
|
+
}
|
|
480
|
+
_fireEvent(ev, e) {
|
|
481
|
+
const listeners = this._listeners[ev];
|
|
482
|
+
if (!listeners) return;
|
|
483
|
+
listeners.forEach(l => l(e));
|
|
484
|
+
}
|
|
485
|
+
get selectionStart() {
|
|
486
|
+
return this._cursorChanging ? this._changingCursorPos : this.el.selectionStart;
|
|
487
|
+
}
|
|
488
|
+
get cursorPos() {
|
|
489
|
+
return this._cursorChanging ? this._changingCursorPos : this.el.selectionEnd;
|
|
490
|
+
}
|
|
491
|
+
set cursorPos(pos) {
|
|
492
|
+
if (!this.el || !this.el.isActive) return;
|
|
493
|
+
this.el.select(pos, pos);
|
|
494
|
+
this._saveSelection();
|
|
495
|
+
}
|
|
496
|
+
_saveSelection(
|
|
497
|
+
) {
|
|
498
|
+
if (this.displayValue !== this.el.value) {
|
|
499
|
+
console.warn('Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.');
|
|
500
|
+
}
|
|
501
|
+
this._selection = {
|
|
502
|
+
start: this.selectionStart,
|
|
503
|
+
end: this.cursorPos
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
updateValue() {
|
|
507
|
+
this.masked.value = this.el.value;
|
|
508
|
+
this._value = this.masked.value;
|
|
509
|
+
this._unmaskedValue = this.masked.unmaskedValue;
|
|
510
|
+
this._rawInputValue = this.masked.rawInputValue;
|
|
511
|
+
}
|
|
512
|
+
updateControl(cursorPos) {
|
|
513
|
+
const newUnmaskedValue = this.masked.unmaskedValue;
|
|
514
|
+
const newValue = this.masked.value;
|
|
515
|
+
const newRawInputValue = this.masked.rawInputValue;
|
|
516
|
+
const newDisplayValue = this.displayValue;
|
|
517
|
+
const isChanged = this.unmaskedValue !== newUnmaskedValue || this.value !== newValue || this._rawInputValue !== newRawInputValue;
|
|
518
|
+
this._unmaskedValue = newUnmaskedValue;
|
|
519
|
+
this._value = newValue;
|
|
520
|
+
this._rawInputValue = newRawInputValue;
|
|
521
|
+
if (this.el.value !== newDisplayValue) this.el.value = newDisplayValue;
|
|
522
|
+
if (cursorPos === 'auto') this.alignCursor();else if (cursorPos != null) this.cursorPos = cursorPos;
|
|
523
|
+
if (isChanged) this._fireChangeEvents();
|
|
524
|
+
if (!this._historyChanging && (isChanged || this.history.isEmpty)) this.history.push({
|
|
525
|
+
unmaskedValue: newUnmaskedValue,
|
|
526
|
+
selection: {
|
|
527
|
+
start: this.selectionStart,
|
|
528
|
+
end: this.cursorPos
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
updateOptions(opts) {
|
|
533
|
+
const {
|
|
534
|
+
mask,
|
|
535
|
+
...restOpts
|
|
536
|
+
} = opts;
|
|
537
|
+
const updateMask = !this.maskEquals(mask);
|
|
538
|
+
const updateOpts = this.masked.optionsIsChanged(restOpts);
|
|
539
|
+
if (updateMask) this.mask = mask;
|
|
540
|
+
if (updateOpts) this.masked.updateOptions(restOpts);
|
|
541
|
+
if (updateMask || updateOpts) this.updateControl();
|
|
542
|
+
}
|
|
543
|
+
updateCursor(cursorPos) {
|
|
544
|
+
if (cursorPos == null) return;
|
|
545
|
+
this.cursorPos = cursorPos;
|
|
546
|
+
this._delayUpdateCursor(cursorPos);
|
|
547
|
+
}
|
|
548
|
+
_delayUpdateCursor(cursorPos) {
|
|
549
|
+
this._abortUpdateCursor();
|
|
550
|
+
this._changingCursorPos = cursorPos;
|
|
551
|
+
this._cursorChanging = setTimeout(() => {
|
|
552
|
+
if (!this.el) return;
|
|
553
|
+
this.cursorPos = this._changingCursorPos;
|
|
554
|
+
this._abortUpdateCursor();
|
|
555
|
+
}, 10);
|
|
556
|
+
}
|
|
557
|
+
_fireChangeEvents() {
|
|
558
|
+
this._fireEvent('accept', this._inputEvent);
|
|
559
|
+
if (this.masked.isComplete) this._fireEvent('complete', this._inputEvent);
|
|
560
|
+
}
|
|
561
|
+
_abortUpdateCursor() {
|
|
562
|
+
if (this._cursorChanging) {
|
|
563
|
+
clearTimeout(this._cursorChanging);
|
|
564
|
+
delete this._cursorChanging;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
alignCursor() {
|
|
568
|
+
this.cursorPos = this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos, DIRECTION.LEFT));
|
|
569
|
+
}
|
|
570
|
+
alignCursorFriendly() {
|
|
571
|
+
if (this.selectionStart !== this.cursorPos) return;
|
|
572
|
+
this.alignCursor();
|
|
573
|
+
}
|
|
574
|
+
on(ev, handler) {
|
|
575
|
+
if (!this._listeners[ev]) this._listeners[ev] = [];
|
|
576
|
+
this._listeners[ev].push(handler);
|
|
577
|
+
return this;
|
|
578
|
+
}
|
|
579
|
+
off(ev, handler) {
|
|
580
|
+
if (!this._listeners[ev]) return this;
|
|
581
|
+
if (!handler) {
|
|
582
|
+
delete this._listeners[ev];
|
|
583
|
+
return this;
|
|
584
|
+
}
|
|
585
|
+
const hIndex = this._listeners[ev].indexOf(handler);
|
|
586
|
+
if (hIndex >= 0) this._listeners[ev].splice(hIndex, 1);
|
|
587
|
+
return this;
|
|
588
|
+
}
|
|
589
|
+
_onInput(e) {
|
|
590
|
+
this._inputEvent = e;
|
|
591
|
+
this._abortUpdateCursor();
|
|
592
|
+
const details = new ActionDetails({
|
|
593
|
+
value: this.el.value,
|
|
594
|
+
cursorPos: this.cursorPos,
|
|
595
|
+
oldValue: this.displayValue,
|
|
596
|
+
oldSelection: this._selection
|
|
597
|
+
});
|
|
598
|
+
const oldRawValue = this.masked.rawInputValue;
|
|
599
|
+
const offset = this.masked.splice(details.startChangePos, details.removed.length, details.inserted, details.removeDirection, {
|
|
600
|
+
input: true,
|
|
601
|
+
raw: true
|
|
602
|
+
}).offset;
|
|
603
|
+
const removeDirection = oldRawValue === this.masked.rawInputValue ? details.removeDirection : DIRECTION.NONE;
|
|
604
|
+
let cursorPos = this.masked.nearestInputPos(details.startChangePos + offset, removeDirection);
|
|
605
|
+
if (removeDirection !== DIRECTION.NONE) cursorPos = this.masked.nearestInputPos(cursorPos, DIRECTION.NONE);
|
|
606
|
+
this.updateControl(cursorPos);
|
|
607
|
+
delete this._inputEvent;
|
|
608
|
+
}
|
|
609
|
+
_onChange() {
|
|
610
|
+
if (this.displayValue !== this.el.value) this.updateValue();
|
|
611
|
+
this.masked.doCommit();
|
|
612
|
+
this.updateControl();
|
|
613
|
+
this._saveSelection();
|
|
614
|
+
}
|
|
615
|
+
_onDrop(ev) {
|
|
616
|
+
ev.preventDefault();
|
|
617
|
+
ev.stopPropagation();
|
|
618
|
+
}
|
|
619
|
+
_onFocus(ev) {
|
|
620
|
+
this.alignCursorFriendly();
|
|
621
|
+
}
|
|
622
|
+
_onClick(ev) {
|
|
623
|
+
this.alignCursorFriendly();
|
|
624
|
+
}
|
|
625
|
+
_onUndo() {
|
|
626
|
+
this._applyHistoryState(this.history.undo());
|
|
627
|
+
}
|
|
628
|
+
_onRedo() {
|
|
629
|
+
this._applyHistoryState(this.history.redo());
|
|
630
|
+
}
|
|
631
|
+
_applyHistoryState(state) {
|
|
632
|
+
if (!state) return;
|
|
633
|
+
this._historyChanging = true;
|
|
634
|
+
this.unmaskedValue = state.unmaskedValue;
|
|
635
|
+
this.el.select(state.selection.start, state.selection.end);
|
|
636
|
+
this._saveSelection();
|
|
637
|
+
this._historyChanging = false;
|
|
638
|
+
}
|
|
639
|
+
destroy() {
|
|
640
|
+
this._unbindEvents();
|
|
641
|
+
this._listeners.length = 0;
|
|
642
|
+
delete this.el;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
IMask.InputMask = InputMask;
|
|
646
|
+
|
|
647
|
+
class ChangeDetails {
|
|
648
|
+
static normalize(prep) {
|
|
649
|
+
return Array.isArray(prep) ? prep : [prep, new ChangeDetails()];
|
|
650
|
+
}
|
|
651
|
+
constructor(details) {
|
|
652
|
+
Object.assign(this, {
|
|
653
|
+
inserted: '',
|
|
654
|
+
rawInserted: '',
|
|
655
|
+
tailShift: 0,
|
|
656
|
+
skip: false
|
|
657
|
+
}, details);
|
|
658
|
+
}
|
|
659
|
+
aggregate(details) {
|
|
660
|
+
this.inserted += details.inserted;
|
|
661
|
+
this.rawInserted += details.rawInserted;
|
|
662
|
+
this.tailShift += details.tailShift;
|
|
663
|
+
this.skip = this.skip || details.skip;
|
|
664
|
+
return this;
|
|
665
|
+
}
|
|
666
|
+
get offset() {
|
|
667
|
+
return this.tailShift + this.inserted.length;
|
|
668
|
+
}
|
|
669
|
+
get consumed() {
|
|
670
|
+
return Boolean(this.rawInserted) || this.skip;
|
|
671
|
+
}
|
|
672
|
+
equals(details) {
|
|
673
|
+
return this.inserted === details.inserted && this.tailShift === details.tailShift && this.rawInserted === details.rawInserted && this.skip === details.skip;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
IMask.ChangeDetails = ChangeDetails;
|
|
677
|
+
|
|
678
|
+
class ContinuousTailDetails {
|
|
679
|
+
constructor(value, from, stop) {
|
|
680
|
+
if (value === void 0) {
|
|
681
|
+
value = '';
|
|
682
|
+
}
|
|
683
|
+
if (from === void 0) {
|
|
684
|
+
from = 0;
|
|
685
|
+
}
|
|
686
|
+
this.value = value;
|
|
687
|
+
this.from = from;
|
|
688
|
+
this.stop = stop;
|
|
689
|
+
}
|
|
690
|
+
toString() {
|
|
691
|
+
return this.value;
|
|
692
|
+
}
|
|
693
|
+
extend(tail) {
|
|
694
|
+
this.value += String(tail);
|
|
695
|
+
}
|
|
696
|
+
appendTo(masked) {
|
|
697
|
+
return masked.append(this.toString(), {
|
|
698
|
+
tail: true
|
|
699
|
+
}).aggregate(masked._appendPlaceholder());
|
|
700
|
+
}
|
|
701
|
+
get state() {
|
|
702
|
+
return {
|
|
703
|
+
value: this.value,
|
|
704
|
+
from: this.from,
|
|
705
|
+
stop: this.stop
|
|
706
|
+
};
|
|
707
|
+
}
|
|
708
|
+
set state(state) {
|
|
709
|
+
Object.assign(this, state);
|
|
710
|
+
}
|
|
711
|
+
unshift(beforePos) {
|
|
712
|
+
if (!this.value.length || beforePos != null && this.from >= beforePos) return '';
|
|
713
|
+
const shiftChar = this.value[0];
|
|
714
|
+
this.value = this.value.slice(1);
|
|
715
|
+
return shiftChar;
|
|
716
|
+
}
|
|
717
|
+
shift() {
|
|
718
|
+
if (!this.value.length) return '';
|
|
719
|
+
const shiftChar = this.value[this.value.length - 1];
|
|
720
|
+
this.value = this.value.slice(0, -1);
|
|
721
|
+
return shiftChar;
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
class Masked {
|
|
726
|
+
constructor(opts) {
|
|
727
|
+
this._value = '';
|
|
728
|
+
this._update({
|
|
729
|
+
...Masked.DEFAULTS,
|
|
730
|
+
...opts
|
|
731
|
+
});
|
|
732
|
+
this._initialized = true;
|
|
733
|
+
}
|
|
734
|
+
updateOptions(opts) {
|
|
735
|
+
if (!this.optionsIsChanged(opts)) return;
|
|
736
|
+
this.withValueRefresh(this._update.bind(this, opts));
|
|
737
|
+
}
|
|
738
|
+
_update(opts) {
|
|
739
|
+
Object.assign(this, opts);
|
|
740
|
+
}
|
|
741
|
+
get state() {
|
|
742
|
+
return {
|
|
743
|
+
_value: this.value,
|
|
744
|
+
_rawInputValue: this.rawInputValue
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
set state(state) {
|
|
748
|
+
this._value = state._value;
|
|
749
|
+
}
|
|
750
|
+
reset() {
|
|
751
|
+
this._value = '';
|
|
752
|
+
}
|
|
753
|
+
get value() {
|
|
754
|
+
return this._value;
|
|
755
|
+
}
|
|
756
|
+
set value(value) {
|
|
757
|
+
this.resolve(value, {
|
|
758
|
+
input: true
|
|
759
|
+
});
|
|
760
|
+
}
|
|
761
|
+
resolve(value, flags) {
|
|
762
|
+
if (flags === void 0) {
|
|
763
|
+
flags = {
|
|
764
|
+
input: true
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
this.reset();
|
|
768
|
+
this.append(value, flags, '');
|
|
769
|
+
this.doCommit();
|
|
770
|
+
}
|
|
771
|
+
get unmaskedValue() {
|
|
772
|
+
return this.value;
|
|
773
|
+
}
|
|
774
|
+
set unmaskedValue(value) {
|
|
775
|
+
this.resolve(value, {});
|
|
776
|
+
}
|
|
777
|
+
get typedValue() {
|
|
778
|
+
return this.parse ? this.parse(this.value, this) : this.unmaskedValue;
|
|
779
|
+
}
|
|
780
|
+
set typedValue(value) {
|
|
781
|
+
if (this.format) {
|
|
782
|
+
this.value = this.format(value, this);
|
|
783
|
+
} else {
|
|
784
|
+
this.unmaskedValue = String(value);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
get rawInputValue() {
|
|
788
|
+
return this.extractInput(0, this.displayValue.length, {
|
|
789
|
+
raw: true
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
set rawInputValue(value) {
|
|
793
|
+
this.resolve(value, {
|
|
794
|
+
raw: true
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
get displayValue() {
|
|
798
|
+
return this.value;
|
|
799
|
+
}
|
|
800
|
+
get isComplete() {
|
|
801
|
+
return true;
|
|
802
|
+
}
|
|
803
|
+
get isFilled() {
|
|
804
|
+
return this.isComplete;
|
|
805
|
+
}
|
|
806
|
+
nearestInputPos(cursorPos, direction) {
|
|
807
|
+
return cursorPos;
|
|
808
|
+
}
|
|
809
|
+
totalInputPositions(fromPos, toPos) {
|
|
810
|
+
if (fromPos === void 0) {
|
|
811
|
+
fromPos = 0;
|
|
812
|
+
}
|
|
813
|
+
if (toPos === void 0) {
|
|
814
|
+
toPos = this.displayValue.length;
|
|
815
|
+
}
|
|
816
|
+
return Math.min(this.displayValue.length, toPos - fromPos);
|
|
817
|
+
}
|
|
818
|
+
extractInput(fromPos, toPos, flags) {
|
|
819
|
+
if (fromPos === void 0) {
|
|
820
|
+
fromPos = 0;
|
|
821
|
+
}
|
|
822
|
+
if (toPos === void 0) {
|
|
823
|
+
toPos = this.displayValue.length;
|
|
824
|
+
}
|
|
825
|
+
return this.displayValue.slice(fromPos, toPos);
|
|
826
|
+
}
|
|
827
|
+
extractTail(fromPos, toPos) {
|
|
828
|
+
if (fromPos === void 0) {
|
|
829
|
+
fromPos = 0;
|
|
830
|
+
}
|
|
831
|
+
if (toPos === void 0) {
|
|
832
|
+
toPos = this.displayValue.length;
|
|
833
|
+
}
|
|
834
|
+
return new ContinuousTailDetails(this.extractInput(fromPos, toPos), fromPos);
|
|
835
|
+
}
|
|
836
|
+
appendTail(tail) {
|
|
837
|
+
if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
|
|
838
|
+
return tail.appendTo(this);
|
|
839
|
+
}
|
|
840
|
+
_appendCharRaw(ch, flags) {
|
|
299
841
|
if (!ch) return new ChangeDetails();
|
|
300
842
|
this._value += ch;
|
|
301
843
|
return new ChangeDetails({
|
|
@@ -303,13 +845,28 @@
|
|
|
303
845
|
rawInserted: ch
|
|
304
846
|
});
|
|
305
847
|
}
|
|
306
|
-
_appendChar(ch) {
|
|
307
|
-
|
|
308
|
-
|
|
848
|
+
_appendChar(ch, flags, checkTail) {
|
|
849
|
+
if (flags === void 0) {
|
|
850
|
+
flags = {};
|
|
851
|
+
}
|
|
309
852
|
const consistentState = this.state;
|
|
310
853
|
let details;
|
|
311
|
-
[ch, details] =
|
|
312
|
-
|
|
854
|
+
[ch, details] = this.doPrepareChar(ch, flags);
|
|
855
|
+
if (ch) {
|
|
856
|
+
details = details.aggregate(this._appendCharRaw(ch, flags));
|
|
857
|
+
if (!details.rawInserted && this.autofix === 'pad') {
|
|
858
|
+
const noFixState = this.state;
|
|
859
|
+
this.state = consistentState;
|
|
860
|
+
let fixDetails = this.pad(flags);
|
|
861
|
+
const chDetails = this._appendCharRaw(ch, flags);
|
|
862
|
+
fixDetails = fixDetails.aggregate(chDetails);
|
|
863
|
+
if (chDetails.rawInserted || fixDetails.equals(details)) {
|
|
864
|
+
details = fixDetails;
|
|
865
|
+
} else {
|
|
866
|
+
this.state = noFixState;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
}
|
|
313
870
|
if (details.inserted) {
|
|
314
871
|
let consistentTail;
|
|
315
872
|
let appended = this.doValidate(flags) !== false;
|
|
@@ -317,16 +874,20 @@
|
|
|
317
874
|
const beforeTailState = this.state;
|
|
318
875
|
if (this.overwrite === true) {
|
|
319
876
|
consistentTail = checkTail.state;
|
|
320
|
-
|
|
877
|
+
for (let i = 0; i < details.rawInserted.length; ++i) {
|
|
878
|
+
checkTail.unshift(this.displayValue.length - details.tailShift);
|
|
879
|
+
}
|
|
321
880
|
}
|
|
322
881
|
let tailDetails = this.appendTail(checkTail);
|
|
323
|
-
appended = tailDetails.rawInserted === checkTail.toString();
|
|
882
|
+
appended = tailDetails.rawInserted.length === checkTail.toString().length;
|
|
324
883
|
if (!(appended && tailDetails.inserted) && this.overwrite === 'shift') {
|
|
325
884
|
this.state = beforeTailState;
|
|
326
885
|
consistentTail = checkTail.state;
|
|
327
|
-
|
|
886
|
+
for (let i = 0; i < details.rawInserted.length; ++i) {
|
|
887
|
+
checkTail.shift();
|
|
888
|
+
}
|
|
328
889
|
tailDetails = this.appendTail(checkTail);
|
|
329
|
-
appended = tailDetails.rawInserted === checkTail.toString();
|
|
890
|
+
appended = tailDetails.rawInserted.length === checkTail.toString().length;
|
|
330
891
|
}
|
|
331
892
|
if (appended && tailDetails.inserted) this.state = beforeTailState;
|
|
332
893
|
}
|
|
@@ -346,43 +907,49 @@
|
|
|
346
907
|
}
|
|
347
908
|
append(str, flags, tail) {
|
|
348
909
|
if (!isString(str)) throw new Error('value should be string');
|
|
349
|
-
const details = new ChangeDetails();
|
|
350
910
|
const checkTail = isString(tail) ? new ContinuousTailDetails(String(tail)) : tail;
|
|
351
|
-
if (flags
|
|
911
|
+
if (flags != null && flags.tail) flags._beforeTailState = this.state;
|
|
912
|
+
let details;
|
|
913
|
+
[str, details] = this.doPrepare(str, flags);
|
|
352
914
|
for (let ci = 0; ci < str.length; ++ci) {
|
|
353
915
|
const d = this._appendChar(str[ci], flags, checkTail);
|
|
354
916
|
if (!d.rawInserted && !this.doSkipInvalid(str[ci], flags, checkTail)) break;
|
|
355
917
|
details.aggregate(d);
|
|
356
918
|
}
|
|
919
|
+
if ((this.eager === true || this.eager === 'append') && flags != null && flags.input && str) {
|
|
920
|
+
details.aggregate(this._appendEager());
|
|
921
|
+
}
|
|
357
922
|
if (checkTail != null) {
|
|
358
923
|
details.tailShift += this.appendTail(checkTail).tailShift;
|
|
359
924
|
}
|
|
360
|
-
if ((this.eager === true || this.eager === 'append') && flags !== null && flags !== void 0 && flags.input && str) {
|
|
361
|
-
details.aggregate(this._appendEager());
|
|
362
|
-
}
|
|
363
925
|
return details;
|
|
364
926
|
}
|
|
365
|
-
remove() {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
927
|
+
remove(fromPos, toPos) {
|
|
928
|
+
if (fromPos === void 0) {
|
|
929
|
+
fromPos = 0;
|
|
930
|
+
}
|
|
931
|
+
if (toPos === void 0) {
|
|
932
|
+
toPos = this.displayValue.length;
|
|
933
|
+
}
|
|
934
|
+
this._value = this.displayValue.slice(0, fromPos) + this.displayValue.slice(toPos);
|
|
369
935
|
return new ChangeDetails();
|
|
370
936
|
}
|
|
371
937
|
withValueRefresh(fn) {
|
|
372
|
-
if (this._refreshing || !this.
|
|
938
|
+
if (this._refreshing || !this._initialized) return fn();
|
|
373
939
|
this._refreshing = true;
|
|
374
940
|
const rawInput = this.rawInputValue;
|
|
375
941
|
const value = this.value;
|
|
376
942
|
const ret = fn();
|
|
377
943
|
this.rawInputValue = rawInput;
|
|
378
944
|
if (this.value && this.value !== value && value.indexOf(this.value) === 0) {
|
|
379
|
-
this.append(value.slice(this.
|
|
945
|
+
this.append(value.slice(this.displayValue.length), {}, '');
|
|
946
|
+
this.doCommit();
|
|
380
947
|
}
|
|
381
948
|
delete this._refreshing;
|
|
382
949
|
return ret;
|
|
383
950
|
}
|
|
384
951
|
runIsolated(fn) {
|
|
385
|
-
if (this._isolated || !this.
|
|
952
|
+
if (this._isolated || !this._initialized) return fn(this);
|
|
386
953
|
this._isolated = true;
|
|
387
954
|
const state = this.state;
|
|
388
955
|
const ret = fn(this);
|
|
@@ -390,12 +957,20 @@
|
|
|
390
957
|
delete this._isolated;
|
|
391
958
|
return ret;
|
|
392
959
|
}
|
|
393
|
-
doSkipInvalid(ch) {
|
|
394
|
-
return this.skipInvalid;
|
|
960
|
+
doSkipInvalid(ch, flags, checkTail) {
|
|
961
|
+
return Boolean(this.skipInvalid);
|
|
962
|
+
}
|
|
963
|
+
doPrepare(str, flags) {
|
|
964
|
+
if (flags === void 0) {
|
|
965
|
+
flags = {};
|
|
966
|
+
}
|
|
967
|
+
return ChangeDetails.normalize(this.prepare ? this.prepare(str, this, flags) : str);
|
|
395
968
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
969
|
+
doPrepareChar(str, flags) {
|
|
970
|
+
if (flags === void 0) {
|
|
971
|
+
flags = {};
|
|
972
|
+
}
|
|
973
|
+
return ChangeDetails.normalize(this.prepareChar ? this.prepareChar(str, this, flags) : str);
|
|
399
974
|
}
|
|
400
975
|
doValidate(flags) {
|
|
401
976
|
return (!this.validate || this.validate(this.value, this, flags)) && (!this.parent || this.parent.doValidate(flags));
|
|
@@ -403,16 +978,18 @@
|
|
|
403
978
|
doCommit() {
|
|
404
979
|
if (this.commit) this.commit(this.value, this);
|
|
405
980
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
981
|
+
splice(start, deleteCount, inserted, removeDirection, flags) {
|
|
982
|
+
if (inserted === void 0) {
|
|
983
|
+
inserted = '';
|
|
984
|
+
}
|
|
985
|
+
if (removeDirection === void 0) {
|
|
986
|
+
removeDirection = DIRECTION.NONE;
|
|
987
|
+
}
|
|
988
|
+
if (flags === void 0) {
|
|
989
|
+
flags = {
|
|
990
|
+
input: true
|
|
991
|
+
};
|
|
992
|
+
}
|
|
416
993
|
const tailPos = start + deleteCount;
|
|
417
994
|
const tail = this.extractTail(tailPos);
|
|
418
995
|
const eagerRemove = this.eager === true || this.eager === 'remove';
|
|
@@ -433,7 +1010,7 @@
|
|
|
433
1010
|
if (eagerRemove && removeDirection !== DIRECTION.NONE && oldRawValue === this.rawInputValue) {
|
|
434
1011
|
if (removeDirection === DIRECTION.FORCE_LEFT) {
|
|
435
1012
|
let valLength;
|
|
436
|
-
while (oldRawValue === this.rawInputValue && (valLength = this.
|
|
1013
|
+
while (oldRawValue === this.rawInputValue && (valLength = this.displayValue.length)) {
|
|
437
1014
|
details.aggregate(new ChangeDetails({
|
|
438
1015
|
tailShift: -1
|
|
439
1016
|
})).aggregate(this.remove(valLength - 1));
|
|
@@ -442,296 +1019,36 @@
|
|
|
442
1019
|
tail.unshift();
|
|
443
1020
|
}
|
|
444
1021
|
}
|
|
445
|
-
return details.aggregate(this.append(inserted, flags, tail));
|
|
446
|
-
}
|
|
447
|
-
maskEquals(mask) {
|
|
448
|
-
return this.mask === mask;
|
|
449
|
-
}
|
|
450
|
-
typedValueEquals(value) {
|
|
451
|
-
const tval = this.typedValue;
|
|
452
|
-
return value === tval || Masked.EMPTY_VALUES.includes(value) && Masked.EMPTY_VALUES.includes(tval) || this.doFormat(value) === this.doFormat(this.typedValue);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
Masked.DEFAULTS = {
|
|
456
|
-
format: String,
|
|
457
|
-
parse: v => v,
|
|
458
|
-
skipInvalid: true
|
|
459
|
-
};
|
|
460
|
-
Masked.EMPTY_VALUES = [undefined, null, ''];
|
|
461
|
-
IMask.Masked = Masked;
|
|
462
|
-
|
|
463
|
-
function maskedClass(mask) {
|
|
464
|
-
if (mask == null) {
|
|
465
|
-
throw new Error('mask property should be defined');
|
|
466
|
-
}
|
|
467
|
-
if (mask instanceof RegExp) return IMask.MaskedRegExp;
|
|
468
|
-
if (isString(mask)) return IMask.MaskedPattern;
|
|
469
|
-
if (mask instanceof Date || mask === Date) return IMask.MaskedDate;
|
|
470
|
-
if (mask instanceof Number || typeof mask === 'number' || mask === Number) return IMask.MaskedNumber;
|
|
471
|
-
if (Array.isArray(mask) || mask === Array) return IMask.MaskedDynamic;
|
|
472
|
-
if (IMask.Masked && mask.prototype instanceof IMask.Masked) return mask;
|
|
473
|
-
if (mask instanceof IMask.Masked) return mask.constructor;
|
|
474
|
-
if (mask instanceof Function) return IMask.MaskedFunction;
|
|
475
|
-
console.warn('Mask not found for mask', mask);
|
|
476
|
-
return IMask.Masked;
|
|
477
|
-
}
|
|
478
|
-
function createMask(opts) {
|
|
479
|
-
if (IMask.Masked && opts instanceof IMask.Masked) return opts;
|
|
480
|
-
opts = Object.assign({}, opts);
|
|
481
|
-
const mask = opts.mask;
|
|
482
|
-
if (IMask.Masked && mask instanceof IMask.Masked) return mask;
|
|
483
|
-
const MaskedClass = maskedClass(mask);
|
|
484
|
-
if (!MaskedClass) throw new Error('Masked class is not found for provided mask, appropriate module needs to be import manually before creating mask.');
|
|
485
|
-
return new MaskedClass(opts);
|
|
486
|
-
}
|
|
487
|
-
IMask.createMask = createMask;
|
|
488
|
-
|
|
489
|
-
const _excluded$4 = ["parent", "isOptional", "placeholderChar", "displayChar", "lazy", "eager"];
|
|
490
|
-
const DEFAULT_INPUT_DEFINITIONS = {
|
|
491
|
-
'0': /\d/,
|
|
492
|
-
'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]/,
|
|
493
|
-
'*': /./
|
|
494
|
-
};
|
|
495
|
-
class PatternInputDefinition {
|
|
496
|
-
constructor(opts) {
|
|
497
|
-
const {
|
|
498
|
-
parent,
|
|
499
|
-
isOptional,
|
|
500
|
-
placeholderChar,
|
|
501
|
-
displayChar,
|
|
502
|
-
lazy,
|
|
503
|
-
eager
|
|
504
|
-
} = opts,
|
|
505
|
-
maskOpts = _objectWithoutPropertiesLoose(opts, _excluded$4);
|
|
506
|
-
this.masked = createMask(maskOpts);
|
|
507
|
-
Object.assign(this, {
|
|
508
|
-
parent,
|
|
509
|
-
isOptional,
|
|
510
|
-
placeholderChar,
|
|
511
|
-
displayChar,
|
|
512
|
-
lazy,
|
|
513
|
-
eager
|
|
514
|
-
});
|
|
515
|
-
}
|
|
516
|
-
reset() {
|
|
517
|
-
this.isFilled = false;
|
|
518
|
-
this.masked.reset();
|
|
519
|
-
}
|
|
520
|
-
remove() {
|
|
521
|
-
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
522
|
-
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
|
|
523
|
-
if (fromPos === 0 && toPos >= 1) {
|
|
524
|
-
this.isFilled = false;
|
|
525
|
-
return this.masked.remove(fromPos, toPos);
|
|
526
|
-
}
|
|
527
|
-
return new ChangeDetails();
|
|
528
|
-
}
|
|
529
|
-
get value() {
|
|
530
|
-
return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : '');
|
|
531
|
-
}
|
|
532
|
-
get unmaskedValue() {
|
|
533
|
-
return this.masked.unmaskedValue;
|
|
534
|
-
}
|
|
535
|
-
get displayValue() {
|
|
536
|
-
return this.masked.value && this.displayChar || this.value;
|
|
537
|
-
}
|
|
538
|
-
get isComplete() {
|
|
539
|
-
return Boolean(this.masked.value) || this.isOptional;
|
|
540
|
-
}
|
|
541
|
-
_appendChar(ch) {
|
|
542
|
-
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
543
|
-
if (this.isFilled) return new ChangeDetails();
|
|
544
|
-
const state = this.masked.state;
|
|
545
|
-
const details = this.masked._appendChar(ch, flags);
|
|
546
|
-
if (details.inserted && this.doValidate(flags) === false) {
|
|
547
|
-
details.inserted = details.rawInserted = '';
|
|
548
|
-
this.masked.state = state;
|
|
549
|
-
}
|
|
550
|
-
if (!details.inserted && !this.isOptional && !this.lazy && !flags.input) {
|
|
551
|
-
details.inserted = this.placeholderChar;
|
|
552
|
-
}
|
|
553
|
-
details.skip = !details.inserted && !this.isOptional;
|
|
554
|
-
this.isFilled = Boolean(details.inserted);
|
|
555
|
-
return details;
|
|
556
|
-
}
|
|
557
|
-
append() {
|
|
558
|
-
return this.masked.append(...arguments);
|
|
559
|
-
}
|
|
560
|
-
_appendPlaceholder() {
|
|
561
|
-
const details = new ChangeDetails();
|
|
562
|
-
if (this.isFilled || this.isOptional) return details;
|
|
563
|
-
this.isFilled = true;
|
|
564
|
-
details.inserted = this.placeholderChar;
|
|
565
|
-
return details;
|
|
566
|
-
}
|
|
567
|
-
_appendEager() {
|
|
568
|
-
return new ChangeDetails();
|
|
569
|
-
}
|
|
570
|
-
extractTail() {
|
|
571
|
-
return this.masked.extractTail(...arguments);
|
|
572
|
-
}
|
|
573
|
-
appendTail() {
|
|
574
|
-
return this.masked.appendTail(...arguments);
|
|
575
|
-
}
|
|
576
|
-
extractInput() {
|
|
577
|
-
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
578
|
-
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
|
|
579
|
-
let flags = arguments.length > 2 ? arguments[2] : undefined;
|
|
580
|
-
return this.masked.extractInput(fromPos, toPos, flags);
|
|
581
|
-
}
|
|
582
|
-
nearestInputPos(cursorPos) {
|
|
583
|
-
let direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
|
|
584
|
-
const minPos = 0;
|
|
585
|
-
const maxPos = this.value.length;
|
|
586
|
-
const boundPos = Math.min(Math.max(cursorPos, minPos), maxPos);
|
|
587
|
-
switch (direction) {
|
|
588
|
-
case DIRECTION.LEFT:
|
|
589
|
-
case DIRECTION.FORCE_LEFT:
|
|
590
|
-
return this.isComplete ? boundPos : minPos;
|
|
591
|
-
case DIRECTION.RIGHT:
|
|
592
|
-
case DIRECTION.FORCE_RIGHT:
|
|
593
|
-
return this.isComplete ? boundPos : maxPos;
|
|
594
|
-
case DIRECTION.NONE:
|
|
595
|
-
default:
|
|
596
|
-
return boundPos;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
totalInputPositions() {
|
|
600
|
-
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
601
|
-
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
|
|
602
|
-
return this.value.slice(fromPos, toPos).length;
|
|
603
|
-
}
|
|
604
|
-
doValidate() {
|
|
605
|
-
return this.masked.doValidate(...arguments) && (!this.parent || this.parent.doValidate(...arguments));
|
|
606
|
-
}
|
|
607
|
-
doCommit() {
|
|
608
|
-
this.masked.doCommit();
|
|
609
|
-
}
|
|
610
|
-
get state() {
|
|
611
|
-
return {
|
|
612
|
-
masked: this.masked.state,
|
|
613
|
-
isFilled: this.isFilled
|
|
614
|
-
};
|
|
615
|
-
}
|
|
616
|
-
set state(state) {
|
|
617
|
-
this.masked.state = state.masked;
|
|
618
|
-
this.isFilled = state.isFilled;
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
class PatternFixedDefinition {
|
|
623
|
-
constructor(opts) {
|
|
624
|
-
Object.assign(this, opts);
|
|
625
|
-
this._value = '';
|
|
626
|
-
this.isFixed = true;
|
|
627
|
-
}
|
|
628
|
-
get value() {
|
|
629
|
-
return this._value;
|
|
630
|
-
}
|
|
631
|
-
get unmaskedValue() {
|
|
632
|
-
return this.isUnmasking ? this.value : '';
|
|
633
|
-
}
|
|
634
|
-
get displayValue() {
|
|
635
|
-
return this.value;
|
|
636
|
-
}
|
|
637
|
-
reset() {
|
|
638
|
-
this._isRawInput = false;
|
|
639
|
-
this._value = '';
|
|
640
|
-
}
|
|
641
|
-
remove() {
|
|
642
|
-
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
643
|
-
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._value.length;
|
|
644
|
-
this._value = this._value.slice(0, fromPos) + this._value.slice(toPos);
|
|
645
|
-
if (!this._value) this._isRawInput = false;
|
|
646
|
-
return new ChangeDetails();
|
|
647
|
-
}
|
|
648
|
-
nearestInputPos(cursorPos) {
|
|
649
|
-
let direction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DIRECTION.NONE;
|
|
650
|
-
const minPos = 0;
|
|
651
|
-
const maxPos = this._value.length;
|
|
652
|
-
switch (direction) {
|
|
653
|
-
case DIRECTION.LEFT:
|
|
654
|
-
case DIRECTION.FORCE_LEFT:
|
|
655
|
-
return minPos;
|
|
656
|
-
case DIRECTION.NONE:
|
|
657
|
-
case DIRECTION.RIGHT:
|
|
658
|
-
case DIRECTION.FORCE_RIGHT:
|
|
659
|
-
default:
|
|
660
|
-
return maxPos;
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
totalInputPositions() {
|
|
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
|
-
return this._isRawInput ? toPos - fromPos : 0;
|
|
667
|
-
}
|
|
668
|
-
extractInput() {
|
|
669
|
-
let fromPos = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
670
|
-
let toPos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this._value.length;
|
|
671
|
-
let flags = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
672
|
-
return flags.raw && this._isRawInput && this._value.slice(fromPos, toPos) || '';
|
|
673
|
-
}
|
|
674
|
-
get isComplete() {
|
|
675
|
-
return true;
|
|
676
|
-
}
|
|
677
|
-
get isFilled() {
|
|
678
|
-
return Boolean(this._value);
|
|
679
|
-
}
|
|
680
|
-
_appendChar(ch) {
|
|
681
|
-
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
682
|
-
const details = new ChangeDetails();
|
|
683
|
-
if (this.isFilled) return details;
|
|
684
|
-
const appendEager = this.eager === true || this.eager === 'append';
|
|
685
|
-
const appended = this.char === ch;
|
|
686
|
-
const isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && (!flags.raw || !appendEager) && !flags.tail;
|
|
687
|
-
if (isResolved) details.rawInserted = this.char;
|
|
688
|
-
this._value = details.inserted = this.char;
|
|
689
|
-
this._isRawInput = isResolved && (flags.raw || flags.input);
|
|
690
|
-
return details;
|
|
691
|
-
}
|
|
692
|
-
_appendEager() {
|
|
693
|
-
return this._appendChar(this.char, {
|
|
694
|
-
tail: true
|
|
695
|
-
});
|
|
696
|
-
}
|
|
697
|
-
_appendPlaceholder() {
|
|
698
|
-
const details = new ChangeDetails();
|
|
699
|
-
if (this.isFilled) return details;
|
|
700
|
-
this._value = details.inserted = this.char;
|
|
701
|
-
return details;
|
|
702
|
-
}
|
|
703
|
-
extractTail() {
|
|
704
|
-
arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.value.length;
|
|
705
|
-
return new ContinuousTailDetails('');
|
|
1022
|
+
return details.aggregate(this.append(inserted, flags, tail));
|
|
706
1023
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
return tail.appendTo(this);
|
|
1024
|
+
maskEquals(mask) {
|
|
1025
|
+
return this.mask === mask;
|
|
710
1026
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
if (tail != null) {
|
|
714
|
-
details.tailShift += this.appendTail(tail).tailShift;
|
|
715
|
-
}
|
|
716
|
-
return details;
|
|
1027
|
+
optionsIsChanged(opts) {
|
|
1028
|
+
return !objectIncludes(this, opts);
|
|
717
1029
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
return
|
|
721
|
-
_value: this._value,
|
|
722
|
-
_isRawInput: this._isRawInput
|
|
723
|
-
};
|
|
1030
|
+
typedValueEquals(value) {
|
|
1031
|
+
const tval = this.typedValue;
|
|
1032
|
+
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);
|
|
724
1033
|
}
|
|
725
|
-
|
|
726
|
-
|
|
1034
|
+
pad(flags) {
|
|
1035
|
+
return new ChangeDetails();
|
|
727
1036
|
}
|
|
728
1037
|
}
|
|
1038
|
+
Masked.DEFAULTS = {
|
|
1039
|
+
skipInvalid: true
|
|
1040
|
+
};
|
|
1041
|
+
Masked.EMPTY_VALUES = [undefined, null, ''];
|
|
1042
|
+
IMask.Masked = Masked;
|
|
729
1043
|
|
|
730
|
-
const _excluded$3 = ["chunks"];
|
|
731
1044
|
class ChunksTailDetails {
|
|
732
|
-
constructor() {
|
|
733
|
-
|
|
734
|
-
|
|
1045
|
+
constructor(chunks, from) {
|
|
1046
|
+
if (chunks === void 0) {
|
|
1047
|
+
chunks = [];
|
|
1048
|
+
}
|
|
1049
|
+
if (from === void 0) {
|
|
1050
|
+
from = 0;
|
|
1051
|
+
}
|
|
735
1052
|
this.chunks = chunks;
|
|
736
1053
|
this.from = from;
|
|
737
1054
|
}
|
|
@@ -740,7 +1057,7 @@
|
|
|
740
1057
|
}
|
|
741
1058
|
extend(tailChunk) {
|
|
742
1059
|
if (!String(tailChunk)) return;
|
|
743
|
-
|
|
1060
|
+
tailChunk = isString(tailChunk) ? new ContinuousTailDetails(String(tailChunk)) : tailChunk;
|
|
744
1061
|
const lastChunk = this.chunks[this.chunks.length - 1];
|
|
745
1062
|
const extendLast = lastChunk && (
|
|
746
1063
|
lastChunk.stop === tailChunk.stop || tailChunk.stop == null) &&
|
|
@@ -772,25 +1089,22 @@
|
|
|
772
1089
|
return tail.appendTo(masked);
|
|
773
1090
|
}
|
|
774
1091
|
const details = new ChangeDetails();
|
|
775
|
-
for (let ci = 0; ci < this.chunks.length
|
|
1092
|
+
for (let ci = 0; ci < this.chunks.length; ++ci) {
|
|
776
1093
|
const chunk = this.chunks[ci];
|
|
777
|
-
const lastBlockIter = masked._mapPosToBlock(masked.
|
|
1094
|
+
const lastBlockIter = masked._mapPosToBlock(masked.displayValue.length);
|
|
778
1095
|
const stop = chunk.stop;
|
|
779
1096
|
let chunkBlock;
|
|
780
1097
|
if (stop != null && (
|
|
781
1098
|
!lastBlockIter || lastBlockIter.index <= stop)) {
|
|
782
1099
|
if (chunk instanceof ChunksTailDetails ||
|
|
783
1100
|
masked._stops.indexOf(stop) >= 0) {
|
|
784
|
-
|
|
785
|
-
details.aggregate(phDetails);
|
|
1101
|
+
details.aggregate(masked._appendPlaceholder(stop));
|
|
786
1102
|
}
|
|
787
1103
|
chunkBlock = chunk instanceof ChunksTailDetails && masked._blocks[stop];
|
|
788
1104
|
}
|
|
789
1105
|
if (chunkBlock) {
|
|
790
1106
|
const tailDetails = chunkBlock.appendTail(chunk);
|
|
791
|
-
tailDetails.skip = false;
|
|
792
1107
|
details.aggregate(tailDetails);
|
|
793
|
-
masked._value += tailDetails.inserted;
|
|
794
1108
|
const remainChars = chunk.toString().slice(tailDetails.rawInserted.length);
|
|
795
1109
|
if (remainChars) details.aggregate(masked.append(remainChars, {
|
|
796
1110
|
tail: true
|
|
@@ -813,9 +1127,9 @@
|
|
|
813
1127
|
}
|
|
814
1128
|
set state(state) {
|
|
815
1129
|
const {
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
1130
|
+
chunks,
|
|
1131
|
+
...props
|
|
1132
|
+
} = state;
|
|
819
1133
|
Object.assign(this, props);
|
|
820
1134
|
this.chunks = chunks.map(cstate => {
|
|
821
1135
|
const chunk = "chunks" in cstate ? new ChunksTailDetails() : new ContinuousTailDetails();
|
|
@@ -899,7 +1213,7 @@
|
|
|
899
1213
|
}
|
|
900
1214
|
popState() {
|
|
901
1215
|
const s = this._log.pop();
|
|
902
|
-
this.state = s;
|
|
1216
|
+
if (s) this.state = s;
|
|
903
1217
|
return s;
|
|
904
1218
|
}
|
|
905
1219
|
bindBlock() {
|
|
@@ -910,12 +1224,12 @@
|
|
|
910
1224
|
}
|
|
911
1225
|
if (this.index >= this.masked._blocks.length) {
|
|
912
1226
|
this.index = this.masked._blocks.length - 1;
|
|
913
|
-
this.offset = this.block.
|
|
1227
|
+
this.offset = this.block.displayValue.length;
|
|
914
1228
|
}
|
|
915
1229
|
}
|
|
916
1230
|
_pushLeft(fn) {
|
|
917
1231
|
this.pushState();
|
|
918
|
-
for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((_this$block = this.block)
|
|
1232
|
+
for (this.bindBlock(); 0 <= this.index; --this.index, this.offset = ((_this$block = this.block) == null ? void 0 : _this$block.displayValue.length) || 0) {
|
|
919
1233
|
var _this$block;
|
|
920
1234
|
if (fn()) return this.ok = true;
|
|
921
1235
|
}
|
|
@@ -963,32 +1277,335 @@
|
|
|
963
1277
|
return true;
|
|
964
1278
|
});
|
|
965
1279
|
}
|
|
966
|
-
pushRightBeforeRequired() {
|
|
967
|
-
return this._pushRight(() => {
|
|
968
|
-
if (this.block.isFixed || this.block.isOptional && !this.block.value) return;
|
|
969
|
-
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);
|
|
970
|
-
return true;
|
|
971
|
-
});
|
|
1280
|
+
pushRightBeforeRequired() {
|
|
1281
|
+
return this._pushRight(() => {
|
|
1282
|
+
if (this.block.isFixed || this.block.isOptional && !this.block.value) return;
|
|
1283
|
+
this.offset = this.block.nearestInputPos(this.offset, DIRECTION.NONE);
|
|
1284
|
+
return true;
|
|
1285
|
+
});
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
class PatternFixedDefinition {
|
|
1290
|
+
constructor(opts) {
|
|
1291
|
+
Object.assign(this, opts);
|
|
1292
|
+
this._value = '';
|
|
1293
|
+
this.isFixed = true;
|
|
1294
|
+
}
|
|
1295
|
+
get value() {
|
|
1296
|
+
return this._value;
|
|
1297
|
+
}
|
|
1298
|
+
get unmaskedValue() {
|
|
1299
|
+
return this.isUnmasking ? this.value : '';
|
|
1300
|
+
}
|
|
1301
|
+
get rawInputValue() {
|
|
1302
|
+
return this._isRawInput ? this.value : '';
|
|
1303
|
+
}
|
|
1304
|
+
get displayValue() {
|
|
1305
|
+
return this.value;
|
|
1306
|
+
}
|
|
1307
|
+
reset() {
|
|
1308
|
+
this._isRawInput = false;
|
|
1309
|
+
this._value = '';
|
|
1310
|
+
}
|
|
1311
|
+
remove(fromPos, toPos) {
|
|
1312
|
+
if (fromPos === void 0) {
|
|
1313
|
+
fromPos = 0;
|
|
1314
|
+
}
|
|
1315
|
+
if (toPos === void 0) {
|
|
1316
|
+
toPos = this._value.length;
|
|
1317
|
+
}
|
|
1318
|
+
this._value = this._value.slice(0, fromPos) + this._value.slice(toPos);
|
|
1319
|
+
if (!this._value) this._isRawInput = false;
|
|
1320
|
+
return new ChangeDetails();
|
|
1321
|
+
}
|
|
1322
|
+
nearestInputPos(cursorPos, direction) {
|
|
1323
|
+
if (direction === void 0) {
|
|
1324
|
+
direction = DIRECTION.NONE;
|
|
1325
|
+
}
|
|
1326
|
+
const minPos = 0;
|
|
1327
|
+
const maxPos = this._value.length;
|
|
1328
|
+
switch (direction) {
|
|
1329
|
+
case DIRECTION.LEFT:
|
|
1330
|
+
case DIRECTION.FORCE_LEFT:
|
|
1331
|
+
return minPos;
|
|
1332
|
+
case DIRECTION.NONE:
|
|
1333
|
+
case DIRECTION.RIGHT:
|
|
1334
|
+
case DIRECTION.FORCE_RIGHT:
|
|
1335
|
+
default:
|
|
1336
|
+
return maxPos;
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
totalInputPositions(fromPos, toPos) {
|
|
1340
|
+
if (fromPos === void 0) {
|
|
1341
|
+
fromPos = 0;
|
|
1342
|
+
}
|
|
1343
|
+
if (toPos === void 0) {
|
|
1344
|
+
toPos = this._value.length;
|
|
1345
|
+
}
|
|
1346
|
+
return this._isRawInput ? toPos - fromPos : 0;
|
|
1347
|
+
}
|
|
1348
|
+
extractInput(fromPos, toPos, flags) {
|
|
1349
|
+
if (fromPos === void 0) {
|
|
1350
|
+
fromPos = 0;
|
|
1351
|
+
}
|
|
1352
|
+
if (toPos === void 0) {
|
|
1353
|
+
toPos = this._value.length;
|
|
1354
|
+
}
|
|
1355
|
+
if (flags === void 0) {
|
|
1356
|
+
flags = {};
|
|
1357
|
+
}
|
|
1358
|
+
return flags.raw && this._isRawInput && this._value.slice(fromPos, toPos) || '';
|
|
1359
|
+
}
|
|
1360
|
+
get isComplete() {
|
|
1361
|
+
return true;
|
|
1362
|
+
}
|
|
1363
|
+
get isFilled() {
|
|
1364
|
+
return Boolean(this._value);
|
|
1365
|
+
}
|
|
1366
|
+
_appendChar(ch, flags) {
|
|
1367
|
+
if (flags === void 0) {
|
|
1368
|
+
flags = {};
|
|
1369
|
+
}
|
|
1370
|
+
if (this.isFilled) return new ChangeDetails();
|
|
1371
|
+
const appendEager = this.eager === true || this.eager === 'append';
|
|
1372
|
+
const appended = this.char === ch;
|
|
1373
|
+
const isResolved = appended && (this.isUnmasking || flags.input || flags.raw) && (!flags.raw || !appendEager) && !flags.tail;
|
|
1374
|
+
const details = new ChangeDetails({
|
|
1375
|
+
inserted: this.char,
|
|
1376
|
+
rawInserted: isResolved ? this.char : ''
|
|
1377
|
+
});
|
|
1378
|
+
this._value = this.char;
|
|
1379
|
+
this._isRawInput = isResolved && (flags.raw || flags.input);
|
|
1380
|
+
return details;
|
|
1381
|
+
}
|
|
1382
|
+
_appendEager() {
|
|
1383
|
+
return this._appendChar(this.char, {
|
|
1384
|
+
tail: true
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
_appendPlaceholder() {
|
|
1388
|
+
const details = new ChangeDetails();
|
|
1389
|
+
if (this.isFilled) return details;
|
|
1390
|
+
this._value = details.inserted = this.char;
|
|
1391
|
+
return details;
|
|
1392
|
+
}
|
|
1393
|
+
extractTail() {
|
|
1394
|
+
return new ContinuousTailDetails('');
|
|
1395
|
+
}
|
|
1396
|
+
appendTail(tail) {
|
|
1397
|
+
if (isString(tail)) tail = new ContinuousTailDetails(String(tail));
|
|
1398
|
+
return tail.appendTo(this);
|
|
1399
|
+
}
|
|
1400
|
+
append(str, flags, tail) {
|
|
1401
|
+
const details = this._appendChar(str[0], flags);
|
|
1402
|
+
if (tail != null) {
|
|
1403
|
+
details.tailShift += this.appendTail(tail).tailShift;
|
|
1404
|
+
}
|
|
1405
|
+
return details;
|
|
1406
|
+
}
|
|
1407
|
+
doCommit() {}
|
|
1408
|
+
get state() {
|
|
1409
|
+
return {
|
|
1410
|
+
_value: this._value,
|
|
1411
|
+
_rawInputValue: this.rawInputValue
|
|
1412
|
+
};
|
|
1413
|
+
}
|
|
1414
|
+
set state(state) {
|
|
1415
|
+
this._value = state._value;
|
|
1416
|
+
this._isRawInput = Boolean(state._rawInputValue);
|
|
1417
|
+
}
|
|
1418
|
+
pad(flags) {
|
|
1419
|
+
return this._appendPlaceholder();
|
|
1420
|
+
}
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
class PatternInputDefinition {
|
|
1424
|
+
constructor(opts) {
|
|
1425
|
+
const {
|
|
1426
|
+
parent,
|
|
1427
|
+
isOptional,
|
|
1428
|
+
placeholderChar,
|
|
1429
|
+
displayChar,
|
|
1430
|
+
lazy,
|
|
1431
|
+
eager,
|
|
1432
|
+
...maskOpts
|
|
1433
|
+
} = opts;
|
|
1434
|
+
this.masked = createMask(maskOpts);
|
|
1435
|
+
Object.assign(this, {
|
|
1436
|
+
parent,
|
|
1437
|
+
isOptional,
|
|
1438
|
+
placeholderChar,
|
|
1439
|
+
displayChar,
|
|
1440
|
+
lazy,
|
|
1441
|
+
eager
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
reset() {
|
|
1445
|
+
this.isFilled = false;
|
|
1446
|
+
this.masked.reset();
|
|
1447
|
+
}
|
|
1448
|
+
remove(fromPos, toPos) {
|
|
1449
|
+
if (fromPos === void 0) {
|
|
1450
|
+
fromPos = 0;
|
|
1451
|
+
}
|
|
1452
|
+
if (toPos === void 0) {
|
|
1453
|
+
toPos = this.value.length;
|
|
1454
|
+
}
|
|
1455
|
+
if (fromPos === 0 && toPos >= 1) {
|
|
1456
|
+
this.isFilled = false;
|
|
1457
|
+
return this.masked.remove(fromPos, toPos);
|
|
1458
|
+
}
|
|
1459
|
+
return new ChangeDetails();
|
|
1460
|
+
}
|
|
1461
|
+
get value() {
|
|
1462
|
+
return this.masked.value || (this.isFilled && !this.isOptional ? this.placeholderChar : '');
|
|
1463
|
+
}
|
|
1464
|
+
get unmaskedValue() {
|
|
1465
|
+
return this.masked.unmaskedValue;
|
|
1466
|
+
}
|
|
1467
|
+
get rawInputValue() {
|
|
1468
|
+
return this.masked.rawInputValue;
|
|
1469
|
+
}
|
|
1470
|
+
get displayValue() {
|
|
1471
|
+
return this.masked.value && this.displayChar || this.value;
|
|
1472
|
+
}
|
|
1473
|
+
get isComplete() {
|
|
1474
|
+
return Boolean(this.masked.value) || this.isOptional;
|
|
1475
|
+
}
|
|
1476
|
+
_appendChar(ch, flags) {
|
|
1477
|
+
if (flags === void 0) {
|
|
1478
|
+
flags = {};
|
|
1479
|
+
}
|
|
1480
|
+
if (this.isFilled) return new ChangeDetails();
|
|
1481
|
+
const state = this.masked.state;
|
|
1482
|
+
let details = this.masked._appendChar(ch, this.currentMaskFlags(flags));
|
|
1483
|
+
if (details.inserted && this.doValidate(flags) === false) {
|
|
1484
|
+
details = new ChangeDetails();
|
|
1485
|
+
this.masked.state = state;
|
|
1486
|
+
}
|
|
1487
|
+
if (!details.inserted && !this.isOptional && !this.lazy && !flags.input) {
|
|
1488
|
+
details.inserted = this.placeholderChar;
|
|
1489
|
+
}
|
|
1490
|
+
details.skip = !details.inserted && !this.isOptional;
|
|
1491
|
+
this.isFilled = Boolean(details.inserted);
|
|
1492
|
+
return details;
|
|
1493
|
+
}
|
|
1494
|
+
append(str, flags, tail) {
|
|
1495
|
+
return this.masked.append(str, this.currentMaskFlags(flags), tail);
|
|
1496
|
+
}
|
|
1497
|
+
_appendPlaceholder() {
|
|
1498
|
+
if (this.isFilled || this.isOptional) return new ChangeDetails();
|
|
1499
|
+
this.isFilled = true;
|
|
1500
|
+
return new ChangeDetails({
|
|
1501
|
+
inserted: this.placeholderChar
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
_appendEager() {
|
|
1505
|
+
return new ChangeDetails();
|
|
1506
|
+
}
|
|
1507
|
+
extractTail(fromPos, toPos) {
|
|
1508
|
+
return this.masked.extractTail(fromPos, toPos);
|
|
1509
|
+
}
|
|
1510
|
+
appendTail(tail) {
|
|
1511
|
+
return this.masked.appendTail(tail);
|
|
1512
|
+
}
|
|
1513
|
+
extractInput(fromPos, toPos, flags) {
|
|
1514
|
+
if (fromPos === void 0) {
|
|
1515
|
+
fromPos = 0;
|
|
1516
|
+
}
|
|
1517
|
+
if (toPos === void 0) {
|
|
1518
|
+
toPos = this.value.length;
|
|
1519
|
+
}
|
|
1520
|
+
return this.masked.extractInput(fromPos, toPos, flags);
|
|
1521
|
+
}
|
|
1522
|
+
nearestInputPos(cursorPos, direction) {
|
|
1523
|
+
if (direction === void 0) {
|
|
1524
|
+
direction = DIRECTION.NONE;
|
|
1525
|
+
}
|
|
1526
|
+
const minPos = 0;
|
|
1527
|
+
const maxPos = this.value.length;
|
|
1528
|
+
const boundPos = Math.min(Math.max(cursorPos, minPos), maxPos);
|
|
1529
|
+
switch (direction) {
|
|
1530
|
+
case DIRECTION.LEFT:
|
|
1531
|
+
case DIRECTION.FORCE_LEFT:
|
|
1532
|
+
return this.isComplete ? boundPos : minPos;
|
|
1533
|
+
case DIRECTION.RIGHT:
|
|
1534
|
+
case DIRECTION.FORCE_RIGHT:
|
|
1535
|
+
return this.isComplete ? boundPos : maxPos;
|
|
1536
|
+
case DIRECTION.NONE:
|
|
1537
|
+
default:
|
|
1538
|
+
return boundPos;
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
totalInputPositions(fromPos, toPos) {
|
|
1542
|
+
if (fromPos === void 0) {
|
|
1543
|
+
fromPos = 0;
|
|
1544
|
+
}
|
|
1545
|
+
if (toPos === void 0) {
|
|
1546
|
+
toPos = this.value.length;
|
|
1547
|
+
}
|
|
1548
|
+
return this.value.slice(fromPos, toPos).length;
|
|
1549
|
+
}
|
|
1550
|
+
doValidate(flags) {
|
|
1551
|
+
return this.masked.doValidate(this.currentMaskFlags(flags)) && (!this.parent || this.parent.doValidate(this.currentMaskFlags(flags)));
|
|
1552
|
+
}
|
|
1553
|
+
doCommit() {
|
|
1554
|
+
this.masked.doCommit();
|
|
1555
|
+
}
|
|
1556
|
+
get state() {
|
|
1557
|
+
return {
|
|
1558
|
+
_value: this.value,
|
|
1559
|
+
_rawInputValue: this.rawInputValue,
|
|
1560
|
+
masked: this.masked.state,
|
|
1561
|
+
isFilled: this.isFilled
|
|
1562
|
+
};
|
|
1563
|
+
}
|
|
1564
|
+
set state(state) {
|
|
1565
|
+
this.masked.state = state.masked;
|
|
1566
|
+
this.isFilled = state.isFilled;
|
|
1567
|
+
}
|
|
1568
|
+
currentMaskFlags(flags) {
|
|
1569
|
+
var _flags$_beforeTailSta;
|
|
1570
|
+
return {
|
|
1571
|
+
...flags,
|
|
1572
|
+
_beforeTailState: (flags == null || (_flags$_beforeTailSta = flags._beforeTailState) == null ? void 0 : _flags$_beforeTailSta.masked) || (flags == null ? void 0 : flags._beforeTailState)
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
pad(flags) {
|
|
1576
|
+
return new ChangeDetails();
|
|
972
1577
|
}
|
|
973
1578
|
}
|
|
1579
|
+
PatternInputDefinition.DEFAULT_DEFINITIONS = {
|
|
1580
|
+
'0': /\d/,
|
|
1581
|
+
'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]/,
|
|
1582
|
+
'*': /./
|
|
1583
|
+
};
|
|
974
1584
|
|
|
975
1585
|
class MaskedRegExp extends Masked {
|
|
1586
|
+
updateOptions(opts) {
|
|
1587
|
+
super.updateOptions(opts);
|
|
1588
|
+
}
|
|
976
1589
|
_update(opts) {
|
|
977
|
-
|
|
1590
|
+
const mask = opts.mask;
|
|
1591
|
+
if (mask) opts.validate = value => value.search(mask) >= 0;
|
|
978
1592
|
super._update(opts);
|
|
979
1593
|
}
|
|
980
1594
|
}
|
|
981
1595
|
IMask.MaskedRegExp = MaskedRegExp;
|
|
982
1596
|
|
|
983
|
-
const _excluded$2 = ["_blocks"];
|
|
984
1597
|
class MaskedPattern extends Masked {
|
|
985
|
-
constructor() {
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1598
|
+
constructor(opts) {
|
|
1599
|
+
super({
|
|
1600
|
+
...MaskedPattern.DEFAULTS,
|
|
1601
|
+
...opts,
|
|
1602
|
+
definitions: Object.assign({}, PatternInputDefinition.DEFAULT_DEFINITIONS, opts == null ? void 0 : opts.definitions)
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
updateOptions(opts) {
|
|
1606
|
+
super.updateOptions(opts);
|
|
989
1607
|
}
|
|
990
|
-
_update() {
|
|
991
|
-
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1608
|
+
_update(opts) {
|
|
992
1609
|
opts.definitions = Object.assign({}, this.definitions, opts.definitions);
|
|
993
1610
|
super._update(opts);
|
|
994
1611
|
this._rebuildMask();
|
|
@@ -996,30 +1613,40 @@
|
|
|
996
1613
|
_rebuildMask() {
|
|
997
1614
|
const defs = this.definitions;
|
|
998
1615
|
this._blocks = [];
|
|
1616
|
+
this.exposeBlock = undefined;
|
|
999
1617
|
this._stops = [];
|
|
1000
1618
|
this._maskedBlocks = {};
|
|
1001
|
-
|
|
1619
|
+
const pattern = this.mask;
|
|
1002
1620
|
if (!pattern || !defs) return;
|
|
1003
1621
|
let unmaskingBlock = false;
|
|
1004
1622
|
let optionalBlock = false;
|
|
1005
1623
|
for (let i = 0; i < pattern.length; ++i) {
|
|
1006
|
-
var _defs$char, _defs$char2;
|
|
1007
1624
|
if (this.blocks) {
|
|
1008
1625
|
const p = pattern.slice(i);
|
|
1009
1626
|
const bNames = Object.keys(this.blocks).filter(bName => p.indexOf(bName) === 0);
|
|
1010
1627
|
bNames.sort((a, b) => b.length - a.length);
|
|
1011
1628
|
const bName = bNames[0];
|
|
1012
1629
|
if (bName) {
|
|
1013
|
-
const
|
|
1014
|
-
|
|
1630
|
+
const {
|
|
1631
|
+
expose,
|
|
1632
|
+
repeat,
|
|
1633
|
+
...bOpts
|
|
1634
|
+
} = normalizeOpts(this.blocks[bName]);
|
|
1635
|
+
const blockOpts = {
|
|
1015
1636
|
lazy: this.lazy,
|
|
1016
1637
|
eager: this.eager,
|
|
1017
1638
|
placeholderChar: this.placeholderChar,
|
|
1018
1639
|
displayChar: this.displayChar,
|
|
1019
|
-
overwrite: this.overwrite
|
|
1020
|
-
|
|
1640
|
+
overwrite: this.overwrite,
|
|
1641
|
+
autofix: this.autofix,
|
|
1642
|
+
...bOpts,
|
|
1643
|
+
repeat,
|
|
1644
|
+
parent: this
|
|
1645
|
+
};
|
|
1646
|
+
const maskedBlock = repeat != null ? new IMask.RepeatBlock(blockOpts ) : createMask(blockOpts);
|
|
1021
1647
|
if (maskedBlock) {
|
|
1022
1648
|
this._blocks.push(maskedBlock);
|
|
1649
|
+
if (expose) this.exposeBlock = maskedBlock;
|
|
1023
1650
|
if (!this._maskedBlocks[bName]) this._maskedBlocks[bName] = [];
|
|
1024
1651
|
this._maskedBlocks[bName].push(this._blocks.length - 1);
|
|
1025
1652
|
}
|
|
@@ -1047,17 +1674,15 @@
|
|
|
1047
1674
|
if (!char) break;
|
|
1048
1675
|
isInput = false;
|
|
1049
1676
|
}
|
|
1050
|
-
const
|
|
1051
|
-
mask: defs[char]
|
|
1052
|
-
};
|
|
1053
|
-
const def = isInput ? new PatternInputDefinition(Object.assign({
|
|
1054
|
-
parent: this,
|
|
1677
|
+
const def = isInput ? new PatternInputDefinition({
|
|
1055
1678
|
isOptional: optionalBlock,
|
|
1056
1679
|
lazy: this.lazy,
|
|
1057
1680
|
eager: this.eager,
|
|
1058
1681
|
placeholderChar: this.placeholderChar,
|
|
1059
|
-
displayChar: this.displayChar
|
|
1060
|
-
|
|
1682
|
+
displayChar: this.displayChar,
|
|
1683
|
+
...normalizeOpts(defs[char]),
|
|
1684
|
+
parent: this
|
|
1685
|
+
}) : new PatternFixedDefinition({
|
|
1061
1686
|
char,
|
|
1062
1687
|
eager: this.eager,
|
|
1063
1688
|
isUnmasking: unmaskingBlock
|
|
@@ -1066,15 +1691,20 @@
|
|
|
1066
1691
|
}
|
|
1067
1692
|
}
|
|
1068
1693
|
get state() {
|
|
1069
|
-
return
|
|
1694
|
+
return {
|
|
1695
|
+
...super.state,
|
|
1070
1696
|
_blocks: this._blocks.map(b => b.state)
|
|
1071
|
-
}
|
|
1697
|
+
};
|
|
1072
1698
|
}
|
|
1073
1699
|
set state(state) {
|
|
1700
|
+
if (!state) {
|
|
1701
|
+
this.reset();
|
|
1702
|
+
return;
|
|
1703
|
+
}
|
|
1074
1704
|
const {
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1705
|
+
_blocks,
|
|
1706
|
+
...maskedState
|
|
1707
|
+
} = state;
|
|
1078
1708
|
this._blocks.forEach((b, bi) => b.state = _blocks[bi]);
|
|
1079
1709
|
super.state = maskedState;
|
|
1080
1710
|
}
|
|
@@ -1083,7 +1713,7 @@
|
|
|
1083
1713
|
this._blocks.forEach(b => b.reset());
|
|
1084
1714
|
}
|
|
1085
1715
|
get isComplete() {
|
|
1086
|
-
return this._blocks.every(b => b.isComplete);
|
|
1716
|
+
return this.exposeBlock ? this.exposeBlock.isComplete : this._blocks.every(b => b.isComplete);
|
|
1087
1717
|
}
|
|
1088
1718
|
get isFilled() {
|
|
1089
1719
|
return this._blocks.every(b => b.isFilled);
|
|
@@ -1099,16 +1729,38 @@
|
|
|
1099
1729
|
super.doCommit();
|
|
1100
1730
|
}
|
|
1101
1731
|
get unmaskedValue() {
|
|
1102
|
-
return this._blocks.reduce((str, b) => str += b.unmaskedValue, '');
|
|
1732
|
+
return this.exposeBlock ? this.exposeBlock.unmaskedValue : this._blocks.reduce((str, b) => str += b.unmaskedValue, '');
|
|
1103
1733
|
}
|
|
1104
1734
|
set unmaskedValue(unmaskedValue) {
|
|
1105
|
-
|
|
1735
|
+
if (this.exposeBlock) {
|
|
1736
|
+
const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
|
|
1737
|
+
this.exposeBlock.unmaskedValue = unmaskedValue;
|
|
1738
|
+
this.appendTail(tail);
|
|
1739
|
+
this.doCommit();
|
|
1740
|
+
} else super.unmaskedValue = unmaskedValue;
|
|
1106
1741
|
}
|
|
1107
1742
|
get value() {
|
|
1108
|
-
return this.
|
|
1743
|
+
return this.exposeBlock ? this.exposeBlock.value :
|
|
1744
|
+
this._blocks.reduce((str, b) => str += b.value, '');
|
|
1109
1745
|
}
|
|
1110
1746
|
set value(value) {
|
|
1111
|
-
|
|
1747
|
+
if (this.exposeBlock) {
|
|
1748
|
+
const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
|
|
1749
|
+
this.exposeBlock.value = value;
|
|
1750
|
+
this.appendTail(tail);
|
|
1751
|
+
this.doCommit();
|
|
1752
|
+
} else super.value = value;
|
|
1753
|
+
}
|
|
1754
|
+
get typedValue() {
|
|
1755
|
+
return this.exposeBlock ? this.exposeBlock.typedValue : super.typedValue;
|
|
1756
|
+
}
|
|
1757
|
+
set typedValue(value) {
|
|
1758
|
+
if (this.exposeBlock) {
|
|
1759
|
+
const tail = this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock)) + this.exposeBlock.displayValue.length);
|
|
1760
|
+
this.exposeBlock.typedValue = value;
|
|
1761
|
+
this.appendTail(tail);
|
|
1762
|
+
this.doCommit();
|
|
1763
|
+
} else super.typedValue = value;
|
|
1112
1764
|
}
|
|
1113
1765
|
get displayValue() {
|
|
1114
1766
|
return this._blocks.reduce((str, b) => str += b.displayValue, '');
|
|
@@ -1119,7 +1771,7 @@
|
|
|
1119
1771
|
_appendEager() {
|
|
1120
1772
|
var _this$_mapPosToBlock;
|
|
1121
1773
|
const details = new ChangeDetails();
|
|
1122
|
-
let startBlockIndex = (_this$_mapPosToBlock = this._mapPosToBlock(this.
|
|
1774
|
+
let startBlockIndex = (_this$_mapPosToBlock = this._mapPosToBlock(this.displayValue.length)) == null ? void 0 : _this$_mapPosToBlock.index;
|
|
1123
1775
|
if (startBlockIndex == null) return details;
|
|
1124
1776
|
if (this._blocks[startBlockIndex].isFilled) ++startBlockIndex;
|
|
1125
1777
|
for (let bi = startBlockIndex; bi < this._blocks.length; ++bi) {
|
|
@@ -1129,27 +1781,31 @@
|
|
|
1129
1781
|
}
|
|
1130
1782
|
return details;
|
|
1131
1783
|
}
|
|
1132
|
-
_appendCharRaw(ch) {
|
|
1133
|
-
|
|
1134
|
-
|
|
1784
|
+
_appendCharRaw(ch, flags) {
|
|
1785
|
+
if (flags === void 0) {
|
|
1786
|
+
flags = {};
|
|
1787
|
+
}
|
|
1788
|
+
const blockIter = this._mapPosToBlock(this.displayValue.length);
|
|
1135
1789
|
const details = new ChangeDetails();
|
|
1136
1790
|
if (!blockIter) return details;
|
|
1137
|
-
for (let bi = blockIter.index
|
|
1138
|
-
var _flags$_beforeTailSta
|
|
1139
|
-
const
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
}));
|
|
1144
|
-
const skip = blockDetails.skip;
|
|
1791
|
+
for (let bi = blockIter.index, block; block = this._blocks[bi]; ++bi) {
|
|
1792
|
+
var _flags$_beforeTailSta;
|
|
1793
|
+
const blockDetails = block._appendChar(ch, {
|
|
1794
|
+
...flags,
|
|
1795
|
+
_beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) == null || (_flags$_beforeTailSta = _flags$_beforeTailSta._blocks) == null ? void 0 : _flags$_beforeTailSta[bi]
|
|
1796
|
+
});
|
|
1145
1797
|
details.aggregate(blockDetails);
|
|
1146
|
-
if (
|
|
1798
|
+
if (blockDetails.consumed) break;
|
|
1147
1799
|
}
|
|
1148
1800
|
return details;
|
|
1149
1801
|
}
|
|
1150
|
-
extractTail() {
|
|
1151
|
-
|
|
1152
|
-
|
|
1802
|
+
extractTail(fromPos, toPos) {
|
|
1803
|
+
if (fromPos === void 0) {
|
|
1804
|
+
fromPos = 0;
|
|
1805
|
+
}
|
|
1806
|
+
if (toPos === void 0) {
|
|
1807
|
+
toPos = this.displayValue.length;
|
|
1808
|
+
}
|
|
1153
1809
|
const chunkTail = new ChunksTailDetails();
|
|
1154
1810
|
if (fromPos === toPos) return chunkTail;
|
|
1155
1811
|
this._forEachBlocksInRange(fromPos, toPos, (b, bi, bFromPos, bToPos) => {
|
|
@@ -1161,10 +1817,16 @@
|
|
|
1161
1817
|
});
|
|
1162
1818
|
return chunkTail;
|
|
1163
1819
|
}
|
|
1164
|
-
extractInput() {
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1820
|
+
extractInput(fromPos, toPos, flags) {
|
|
1821
|
+
if (fromPos === void 0) {
|
|
1822
|
+
fromPos = 0;
|
|
1823
|
+
}
|
|
1824
|
+
if (toPos === void 0) {
|
|
1825
|
+
toPos = this.displayValue.length;
|
|
1826
|
+
}
|
|
1827
|
+
if (flags === void 0) {
|
|
1828
|
+
flags = {};
|
|
1829
|
+
}
|
|
1168
1830
|
if (fromPos === toPos) return '';
|
|
1169
1831
|
let input = '';
|
|
1170
1832
|
this._forEachBlocksInRange(fromPos, toPos, (b, _, fromPos, toPos) => {
|
|
@@ -1183,16 +1845,14 @@
|
|
|
1183
1845
|
_appendPlaceholder(toBlockIndex) {
|
|
1184
1846
|
const details = new ChangeDetails();
|
|
1185
1847
|
if (this.lazy && toBlockIndex == null) return details;
|
|
1186
|
-
const startBlockIter = this._mapPosToBlock(this.
|
|
1848
|
+
const startBlockIter = this._mapPosToBlock(this.displayValue.length);
|
|
1187
1849
|
if (!startBlockIter) return details;
|
|
1188
1850
|
const startBlockIndex = startBlockIter.index;
|
|
1189
1851
|
const endBlockIndex = toBlockIndex != null ? toBlockIndex : this._blocks.length;
|
|
1190
1852
|
this._blocks.slice(startBlockIndex, endBlockIndex).forEach(b => {
|
|
1191
1853
|
if (!b.lazy || toBlockIndex != null) {
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
this._value += bDetails.inserted;
|
|
1195
|
-
details.aggregate(bDetails);
|
|
1854
|
+
var _blocks2;
|
|
1855
|
+
details.aggregate(b._appendPlaceholder((_blocks2 = b._blocks) == null ? void 0 : _blocks2.length));
|
|
1196
1856
|
}
|
|
1197
1857
|
});
|
|
1198
1858
|
return details;
|
|
@@ -1202,7 +1862,7 @@
|
|
|
1202
1862
|
for (let bi = 0; bi < this._blocks.length; ++bi) {
|
|
1203
1863
|
const block = this._blocks[bi];
|
|
1204
1864
|
const blockStartPos = accVal.length;
|
|
1205
|
-
accVal += block.
|
|
1865
|
+
accVal += block.displayValue;
|
|
1206
1866
|
if (pos <= accVal.length) {
|
|
1207
1867
|
return {
|
|
1208
1868
|
index: bi,
|
|
@@ -1212,44 +1872,51 @@
|
|
|
1212
1872
|
}
|
|
1213
1873
|
}
|
|
1214
1874
|
_blockStartPos(blockIndex) {
|
|
1215
|
-
return this._blocks.slice(0, blockIndex).reduce((pos, b) => pos += b.
|
|
1875
|
+
return this._blocks.slice(0, blockIndex).reduce((pos, b) => pos += b.displayValue.length, 0);
|
|
1216
1876
|
}
|
|
1217
|
-
_forEachBlocksInRange(fromPos) {
|
|
1218
|
-
|
|
1219
|
-
|
|
1877
|
+
_forEachBlocksInRange(fromPos, toPos, fn) {
|
|
1878
|
+
if (toPos === void 0) {
|
|
1879
|
+
toPos = this.displayValue.length;
|
|
1880
|
+
}
|
|
1220
1881
|
const fromBlockIter = this._mapPosToBlock(fromPos);
|
|
1221
1882
|
if (fromBlockIter) {
|
|
1222
1883
|
const toBlockIter = this._mapPosToBlock(toPos);
|
|
1223
1884
|
const isSameBlock = toBlockIter && fromBlockIter.index === toBlockIter.index;
|
|
1224
1885
|
const fromBlockStartPos = fromBlockIter.offset;
|
|
1225
|
-
const fromBlockEndPos = toBlockIter && isSameBlock ? toBlockIter.offset : this._blocks[fromBlockIter.index].
|
|
1886
|
+
const fromBlockEndPos = toBlockIter && isSameBlock ? toBlockIter.offset : this._blocks[fromBlockIter.index].displayValue.length;
|
|
1226
1887
|
fn(this._blocks[fromBlockIter.index], fromBlockIter.index, fromBlockStartPos, fromBlockEndPos);
|
|
1227
1888
|
if (toBlockIter && !isSameBlock) {
|
|
1228
1889
|
for (let bi = fromBlockIter.index + 1; bi < toBlockIter.index; ++bi) {
|
|
1229
|
-
fn(this._blocks[bi], bi, 0, this._blocks[bi].
|
|
1890
|
+
fn(this._blocks[bi], bi, 0, this._blocks[bi].displayValue.length);
|
|
1230
1891
|
}
|
|
1231
1892
|
fn(this._blocks[toBlockIter.index], toBlockIter.index, 0, toBlockIter.offset);
|
|
1232
1893
|
}
|
|
1233
1894
|
}
|
|
1234
1895
|
}
|
|
1235
|
-
remove() {
|
|
1236
|
-
|
|
1237
|
-
|
|
1896
|
+
remove(fromPos, toPos) {
|
|
1897
|
+
if (fromPos === void 0) {
|
|
1898
|
+
fromPos = 0;
|
|
1899
|
+
}
|
|
1900
|
+
if (toPos === void 0) {
|
|
1901
|
+
toPos = this.displayValue.length;
|
|
1902
|
+
}
|
|
1238
1903
|
const removeDetails = super.remove(fromPos, toPos);
|
|
1239
1904
|
this._forEachBlocksInRange(fromPos, toPos, (b, _, bFromPos, bToPos) => {
|
|
1240
1905
|
removeDetails.aggregate(b.remove(bFromPos, bToPos));
|
|
1241
1906
|
});
|
|
1242
1907
|
return removeDetails;
|
|
1243
1908
|
}
|
|
1244
|
-
nearestInputPos(cursorPos) {
|
|
1245
|
-
|
|
1909
|
+
nearestInputPos(cursorPos, direction) {
|
|
1910
|
+
if (direction === void 0) {
|
|
1911
|
+
direction = DIRECTION.NONE;
|
|
1912
|
+
}
|
|
1246
1913
|
if (!this._blocks.length) return 0;
|
|
1247
1914
|
const cursor = new PatternCursor(this, cursorPos);
|
|
1248
1915
|
if (direction === DIRECTION.NONE) {
|
|
1249
1916
|
if (cursor.pushRightBeforeInput()) return cursor.pos;
|
|
1250
1917
|
cursor.popState();
|
|
1251
1918
|
if (cursor.pushLeftBeforeInput()) return cursor.pos;
|
|
1252
|
-
return this.
|
|
1919
|
+
return this.displayValue.length;
|
|
1253
1920
|
}
|
|
1254
1921
|
if (direction === DIRECTION.LEFT || direction === DIRECTION.FORCE_LEFT) {
|
|
1255
1922
|
if (direction === DIRECTION.LEFT) {
|
|
@@ -1280,7 +1947,7 @@
|
|
|
1280
1947
|
cursor.pushRightBeforeInput();
|
|
1281
1948
|
cursor.pushRightBeforeRequired();
|
|
1282
1949
|
if (cursor.pushRightBeforeFilled()) return cursor.pos;
|
|
1283
|
-
if (direction === DIRECTION.FORCE_RIGHT) return this.
|
|
1950
|
+
if (direction === DIRECTION.FORCE_RIGHT) return this.displayValue.length;
|
|
1284
1951
|
cursor.popState();
|
|
1285
1952
|
if (cursor.ok) return cursor.pos;
|
|
1286
1953
|
cursor.popState();
|
|
@@ -1289,9 +1956,13 @@
|
|
|
1289
1956
|
}
|
|
1290
1957
|
return cursorPos;
|
|
1291
1958
|
}
|
|
1292
|
-
totalInputPositions() {
|
|
1293
|
-
|
|
1294
|
-
|
|
1959
|
+
totalInputPositions(fromPos, toPos) {
|
|
1960
|
+
if (fromPos === void 0) {
|
|
1961
|
+
fromPos = 0;
|
|
1962
|
+
}
|
|
1963
|
+
if (toPos === void 0) {
|
|
1964
|
+
toPos = this.displayValue.length;
|
|
1965
|
+
}
|
|
1295
1966
|
let total = 0;
|
|
1296
1967
|
this._forEachBlocksInRange(fromPos, toPos, (b, _, bFromPos, bToPos) => {
|
|
1297
1968
|
total += b.totalInputPositions(bFromPos, bToPos);
|
|
@@ -1306,8 +1977,14 @@
|
|
|
1306
1977
|
if (!indices) return [];
|
|
1307
1978
|
return indices.map(gi => this._blocks[gi]);
|
|
1308
1979
|
}
|
|
1980
|
+
pad(flags) {
|
|
1981
|
+
const details = new ChangeDetails();
|
|
1982
|
+
this._forEachBlocksInRange(0, this.displayValue.length, b => details.aggregate(b.pad(flags)));
|
|
1983
|
+
return details;
|
|
1984
|
+
}
|
|
1309
1985
|
}
|
|
1310
1986
|
MaskedPattern.DEFAULTS = {
|
|
1987
|
+
...Masked.DEFAULTS,
|
|
1311
1988
|
lazy: true,
|
|
1312
1989
|
placeholderChar: '_'
|
|
1313
1990
|
};
|
|
@@ -1321,21 +1998,30 @@
|
|
|
1321
1998
|
get _matchFrom() {
|
|
1322
1999
|
return this.maxLength - String(this.from).length;
|
|
1323
2000
|
}
|
|
2001
|
+
constructor(opts) {
|
|
2002
|
+
super(opts);
|
|
2003
|
+
}
|
|
2004
|
+
updateOptions(opts) {
|
|
2005
|
+
super.updateOptions(opts);
|
|
2006
|
+
}
|
|
1324
2007
|
_update(opts) {
|
|
1325
|
-
|
|
1326
|
-
to
|
|
1327
|
-
from
|
|
1328
|
-
maxLength
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
2008
|
+
const {
|
|
2009
|
+
to = this.to || 0,
|
|
2010
|
+
from = this.from || 0,
|
|
2011
|
+
maxLength = this.maxLength || 0,
|
|
2012
|
+
autofix = this.autofix,
|
|
2013
|
+
...patternOpts
|
|
2014
|
+
} = opts;
|
|
2015
|
+
this.to = to;
|
|
2016
|
+
this.from = from;
|
|
2017
|
+
this.maxLength = Math.max(String(to).length, maxLength);
|
|
2018
|
+
this.autofix = autofix;
|
|
2019
|
+
const fromStr = String(this.from).padStart(this.maxLength, '0');
|
|
2020
|
+
const toStr = String(this.to).padStart(this.maxLength, '0');
|
|
1335
2021
|
let sameCharsCount = 0;
|
|
1336
2022
|
while (sameCharsCount < toStr.length && toStr[sameCharsCount] === fromStr[sameCharsCount]) ++sameCharsCount;
|
|
1337
|
-
|
|
1338
|
-
super._update(
|
|
2023
|
+
patternOpts.mask = toStr.slice(0, sameCharsCount).replace(/0/g, '\\0') + '0'.repeat(this.maxLength - sameCharsCount);
|
|
2024
|
+
super._update(patternOpts);
|
|
1339
2025
|
}
|
|
1340
2026
|
get isComplete() {
|
|
1341
2027
|
return super.isComplete && Boolean(this.value);
|
|
@@ -1352,64 +2038,109 @@
|
|
|
1352
2038
|
maxstr = maxstr.padEnd(this.maxLength, '9');
|
|
1353
2039
|
return [minstr, maxstr];
|
|
1354
2040
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
2041
|
+
doPrepareChar(ch, flags) {
|
|
2042
|
+
if (flags === void 0) {
|
|
2043
|
+
flags = {};
|
|
2044
|
+
}
|
|
1357
2045
|
let details;
|
|
1358
|
-
[ch, details] =
|
|
1359
|
-
if (!
|
|
2046
|
+
[ch, details] = super.doPrepareChar(ch.replace(/\D/g, ''), flags);
|
|
2047
|
+
if (!ch) details.skip = !this.isComplete;
|
|
2048
|
+
return [ch, details];
|
|
2049
|
+
}
|
|
2050
|
+
_appendCharRaw(ch, flags) {
|
|
2051
|
+
if (flags === void 0) {
|
|
2052
|
+
flags = {};
|
|
2053
|
+
}
|
|
2054
|
+
if (!this.autofix || this.value.length + 1 > this.maxLength) return super._appendCharRaw(ch, flags);
|
|
1360
2055
|
const fromStr = String(this.from).padStart(this.maxLength, '0');
|
|
1361
2056
|
const toStr = String(this.to).padStart(this.maxLength, '0');
|
|
1362
|
-
|
|
1363
|
-
if (
|
|
1364
|
-
const [minstr, maxstr] = this.boundaries(nextVal);
|
|
1365
|
-
if (Number(maxstr) < this.from) return fromStr[nextVal.length - 1];
|
|
2057
|
+
const [minstr, maxstr] = this.boundaries(this.value + ch);
|
|
2058
|
+
if (Number(maxstr) < this.from) return super._appendCharRaw(fromStr[this.value.length], flags);
|
|
1366
2059
|
if (Number(minstr) > this.to) {
|
|
1367
|
-
if (this.autofix === 'pad' &&
|
|
1368
|
-
return [
|
|
2060
|
+
if (!flags.tail && this.autofix === 'pad' && this.value.length + 1 < this.maxLength) {
|
|
2061
|
+
return super._appendCharRaw(fromStr[this.value.length], flags).aggregate(this._appendCharRaw(ch, flags));
|
|
1369
2062
|
}
|
|
1370
|
-
return toStr[
|
|
2063
|
+
return super._appendCharRaw(toStr[this.value.length], flags);
|
|
1371
2064
|
}
|
|
1372
|
-
return ch;
|
|
2065
|
+
return super._appendCharRaw(ch, flags);
|
|
1373
2066
|
}
|
|
1374
|
-
doValidate() {
|
|
2067
|
+
doValidate(flags) {
|
|
1375
2068
|
const str = this.value;
|
|
1376
2069
|
const firstNonZero = str.search(/[^0]/);
|
|
1377
2070
|
if (firstNonZero === -1 && str.length <= this._matchFrom) return true;
|
|
1378
2071
|
const [minstr, maxstr] = this.boundaries(str);
|
|
1379
|
-
return this.from <= Number(maxstr) && Number(minstr) <= this.to && super.doValidate(
|
|
2072
|
+
return this.from <= Number(maxstr) && Number(minstr) <= this.to && super.doValidate(flags);
|
|
2073
|
+
}
|
|
2074
|
+
pad(flags) {
|
|
2075
|
+
const details = new ChangeDetails();
|
|
2076
|
+
if (this.value.length === this.maxLength) return details;
|
|
2077
|
+
const value = this.value;
|
|
2078
|
+
const padLength = this.maxLength - this.value.length;
|
|
2079
|
+
if (padLength) {
|
|
2080
|
+
this.reset();
|
|
2081
|
+
for (let i = 0; i < padLength; ++i) {
|
|
2082
|
+
details.aggregate(super._appendCharRaw('0', flags));
|
|
2083
|
+
}
|
|
2084
|
+
value.split('').forEach(ch => this._appendCharRaw(ch));
|
|
2085
|
+
}
|
|
2086
|
+
return details;
|
|
1380
2087
|
}
|
|
1381
2088
|
}
|
|
1382
2089
|
IMask.MaskedRange = MaskedRange;
|
|
1383
2090
|
|
|
2091
|
+
const DefaultPattern = 'd{.}`m{.}`Y';
|
|
1384
2092
|
class MaskedDate extends MaskedPattern {
|
|
2093
|
+
static extractPatternOptions(opts) {
|
|
2094
|
+
const {
|
|
2095
|
+
mask,
|
|
2096
|
+
pattern,
|
|
2097
|
+
...patternOpts
|
|
2098
|
+
} = opts;
|
|
2099
|
+
return {
|
|
2100
|
+
...patternOpts,
|
|
2101
|
+
mask: isString(mask) ? mask : pattern
|
|
2102
|
+
};
|
|
2103
|
+
}
|
|
1385
2104
|
constructor(opts) {
|
|
1386
|
-
super(
|
|
2105
|
+
super(MaskedDate.extractPatternOptions({
|
|
2106
|
+
...MaskedDate.DEFAULTS,
|
|
2107
|
+
...opts
|
|
2108
|
+
}));
|
|
2109
|
+
}
|
|
2110
|
+
updateOptions(opts) {
|
|
2111
|
+
super.updateOptions(opts);
|
|
1387
2112
|
}
|
|
1388
2113
|
_update(opts) {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
opts
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
2114
|
+
const {
|
|
2115
|
+
mask,
|
|
2116
|
+
pattern,
|
|
2117
|
+
blocks,
|
|
2118
|
+
...patternOpts
|
|
2119
|
+
} = {
|
|
2120
|
+
...MaskedDate.DEFAULTS,
|
|
2121
|
+
...opts
|
|
2122
|
+
};
|
|
2123
|
+
const patternBlocks = Object.assign({}, MaskedDate.GET_DEFAULT_BLOCKS());
|
|
2124
|
+
if (opts.min) patternBlocks.Y.from = opts.min.getFullYear();
|
|
2125
|
+
if (opts.max) patternBlocks.Y.to = opts.max.getFullYear();
|
|
2126
|
+
if (opts.min && opts.max && patternBlocks.Y.from === patternBlocks.Y.to) {
|
|
2127
|
+
patternBlocks.m.from = opts.min.getMonth() + 1;
|
|
2128
|
+
patternBlocks.m.to = opts.max.getMonth() + 1;
|
|
2129
|
+
if (patternBlocks.m.from === patternBlocks.m.to) {
|
|
2130
|
+
patternBlocks.d.from = opts.min.getDate();
|
|
2131
|
+
patternBlocks.d.to = opts.max.getDate();
|
|
1401
2132
|
}
|
|
1402
2133
|
}
|
|
1403
|
-
Object.assign(
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
2134
|
+
Object.assign(patternBlocks, this.blocks, blocks);
|
|
2135
|
+
super._update({
|
|
2136
|
+
...patternOpts,
|
|
2137
|
+
mask: isString(mask) ? mask : pattern,
|
|
2138
|
+
blocks: patternBlocks
|
|
1407
2139
|
});
|
|
1408
|
-
super._update(opts);
|
|
1409
2140
|
}
|
|
1410
|
-
doValidate() {
|
|
2141
|
+
doValidate(flags) {
|
|
1411
2142
|
const date = this.date;
|
|
1412
|
-
return super.doValidate(
|
|
2143
|
+
return super.doValidate(flags) && (!this.isComplete || this.isDateExist(this.value) && date != null && (this.min == null || this.min <= date) && (this.max == null || date <= this.max));
|
|
1413
2144
|
}
|
|
1414
2145
|
isDateExist(str) {
|
|
1415
2146
|
return this.format(this.parse(str, this), this).indexOf(str) >= 0;
|
|
@@ -1429,21 +2160,10 @@
|
|
|
1429
2160
|
maskEquals(mask) {
|
|
1430
2161
|
return mask === Date || super.maskEquals(mask);
|
|
1431
2162
|
}
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
pattern: 'd{.}`m{.}`Y',
|
|
1435
|
-
format: date => {
|
|
1436
|
-
if (!date) return '';
|
|
1437
|
-
const day = String(date.getDate()).padStart(2, '0');
|
|
1438
|
-
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
1439
|
-
const year = date.getFullYear();
|
|
1440
|
-
return [day, month, year].join('.');
|
|
1441
|
-
},
|
|
1442
|
-
parse: str => {
|
|
1443
|
-
const [day, month, year] = str.split('.');
|
|
1444
|
-
return new Date(year, month - 1, day);
|
|
2163
|
+
optionsIsChanged(opts) {
|
|
2164
|
+
return super.optionsIsChanged(MaskedDate.extractPatternOptions(opts));
|
|
1445
2165
|
}
|
|
1446
|
-
}
|
|
2166
|
+
}
|
|
1447
2167
|
MaskedDate.GET_DEFAULT_BLOCKS = () => ({
|
|
1448
2168
|
d: {
|
|
1449
2169
|
mask: MaskedRange,
|
|
@@ -1463,389 +2183,456 @@
|
|
|
1463
2183
|
to: 9999
|
|
1464
2184
|
}
|
|
1465
2185
|
});
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
} catch (e) {}
|
|
1481
|
-
return end != null ? end : this.value.length;
|
|
1482
|
-
}
|
|
1483
|
-
select(start, end) {
|
|
1484
|
-
if (start == null || end == null || start === this.selectionStart && end === this.selectionEnd) return;
|
|
1485
|
-
try {
|
|
1486
|
-
this._unsafeSelect(start, end);
|
|
1487
|
-
} catch (e) {}
|
|
1488
|
-
}
|
|
1489
|
-
_unsafeSelect(start, end) {}
|
|
1490
|
-
get isActive() {
|
|
1491
|
-
return false;
|
|
2186
|
+
MaskedDate.DEFAULTS = {
|
|
2187
|
+
...MaskedPattern.DEFAULTS,
|
|
2188
|
+
mask: Date,
|
|
2189
|
+
pattern: DefaultPattern,
|
|
2190
|
+
format: (date, masked) => {
|
|
2191
|
+
if (!date) return '';
|
|
2192
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
2193
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
2194
|
+
const year = date.getFullYear();
|
|
2195
|
+
return [day, month, year].join('.');
|
|
2196
|
+
},
|
|
2197
|
+
parse: (str, masked) => {
|
|
2198
|
+
const [day, month, year] = str.split('.').map(Number);
|
|
2199
|
+
return new Date(year, month - 1, day);
|
|
1492
2200
|
}
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
}
|
|
1496
|
-
IMask.MaskElement = MaskElement;
|
|
2201
|
+
};
|
|
2202
|
+
IMask.MaskedDate = MaskedDate;
|
|
1497
2203
|
|
|
1498
|
-
class
|
|
1499
|
-
constructor(
|
|
1500
|
-
super(
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
var _this$input$getRootNo, _this$input$getRootNo2, _this$input;
|
|
1506
|
-
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;
|
|
1507
|
-
}
|
|
1508
|
-
get isActive() {
|
|
1509
|
-
return this.input === this.rootElement.activeElement;
|
|
1510
|
-
}
|
|
1511
|
-
get _unsafeSelectionStart() {
|
|
1512
|
-
return this.input.selectionStart;
|
|
1513
|
-
}
|
|
1514
|
-
get _unsafeSelectionEnd() {
|
|
1515
|
-
return this.input.selectionEnd;
|
|
1516
|
-
}
|
|
1517
|
-
_unsafeSelect(start, end) {
|
|
1518
|
-
this.input.setSelectionRange(start, end);
|
|
1519
|
-
}
|
|
1520
|
-
get value() {
|
|
1521
|
-
return this.input.value;
|
|
1522
|
-
}
|
|
1523
|
-
set value(value) {
|
|
1524
|
-
this.input.value = value;
|
|
2204
|
+
class MaskedDynamic extends Masked {
|
|
2205
|
+
constructor(opts) {
|
|
2206
|
+
super({
|
|
2207
|
+
...MaskedDynamic.DEFAULTS,
|
|
2208
|
+
...opts
|
|
2209
|
+
});
|
|
2210
|
+
this.currentMask = undefined;
|
|
1525
2211
|
}
|
|
1526
|
-
|
|
1527
|
-
|
|
2212
|
+
updateOptions(opts) {
|
|
2213
|
+
super.updateOptions(opts);
|
|
1528
2214
|
}
|
|
1529
|
-
|
|
1530
|
-
|
|
2215
|
+
_update(opts) {
|
|
2216
|
+
super._update(opts);
|
|
2217
|
+
if ('mask' in opts) {
|
|
2218
|
+
this.exposeMask = undefined;
|
|
2219
|
+
this.compiledMasks = Array.isArray(opts.mask) ? opts.mask.map(m => {
|
|
2220
|
+
const {
|
|
2221
|
+
expose,
|
|
2222
|
+
...maskOpts
|
|
2223
|
+
} = normalizeOpts(m);
|
|
2224
|
+
const masked = createMask({
|
|
2225
|
+
overwrite: this._overwrite,
|
|
2226
|
+
eager: this._eager,
|
|
2227
|
+
skipInvalid: this._skipInvalid,
|
|
2228
|
+
...maskOpts
|
|
2229
|
+
});
|
|
2230
|
+
if (expose) this.exposeMask = masked;
|
|
2231
|
+
return masked;
|
|
2232
|
+
}) : [];
|
|
2233
|
+
}
|
|
1531
2234
|
}
|
|
1532
|
-
|
|
1533
|
-
if (
|
|
1534
|
-
|
|
1535
|
-
delete this._handlers[event];
|
|
2235
|
+
_appendCharRaw(ch, flags) {
|
|
2236
|
+
if (flags === void 0) {
|
|
2237
|
+
flags = {};
|
|
1536
2238
|
}
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
this.
|
|
2239
|
+
const details = this._applyDispatch(ch, flags);
|
|
2240
|
+
if (this.currentMask) {
|
|
2241
|
+
details.aggregate(this.currentMask._appendChar(ch, this.currentMaskFlags(flags)));
|
|
1540
2242
|
}
|
|
2243
|
+
return details;
|
|
1541
2244
|
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
input: 'input',
|
|
1546
|
-
drop: 'drop',
|
|
1547
|
-
click: 'click',
|
|
1548
|
-
focus: 'focus',
|
|
1549
|
-
commit: 'blur'
|
|
1550
|
-
};
|
|
1551
|
-
IMask.HTMLMaskElement = HTMLMaskElement;
|
|
1552
|
-
|
|
1553
|
-
class HTMLContenteditableMaskElement extends HTMLMaskElement {
|
|
1554
|
-
get _unsafeSelectionStart() {
|
|
1555
|
-
const root = this.rootElement;
|
|
1556
|
-
const selection = root.getSelection && root.getSelection();
|
|
1557
|
-
const anchorOffset = selection && selection.anchorOffset;
|
|
1558
|
-
const focusOffset = selection && selection.focusOffset;
|
|
1559
|
-
if (focusOffset == null || anchorOffset == null || anchorOffset < focusOffset) {
|
|
1560
|
-
return anchorOffset;
|
|
2245
|
+
_applyDispatch(appended, flags, tail) {
|
|
2246
|
+
if (appended === void 0) {
|
|
2247
|
+
appended = '';
|
|
1561
2248
|
}
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
get _unsafeSelectionEnd() {
|
|
1565
|
-
const root = this.rootElement;
|
|
1566
|
-
const selection = root.getSelection && root.getSelection();
|
|
1567
|
-
const anchorOffset = selection && selection.anchorOffset;
|
|
1568
|
-
const focusOffset = selection && selection.focusOffset;
|
|
1569
|
-
if (focusOffset == null || anchorOffset == null || anchorOffset > focusOffset) {
|
|
1570
|
-
return anchorOffset;
|
|
2249
|
+
if (flags === void 0) {
|
|
2250
|
+
flags = {};
|
|
1571
2251
|
}
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
const
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
const
|
|
1580
|
-
const
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
2252
|
+
if (tail === void 0) {
|
|
2253
|
+
tail = '';
|
|
2254
|
+
}
|
|
2255
|
+
const prevValueBeforeTail = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._value : this.value;
|
|
2256
|
+
const inputValue = this.rawInputValue;
|
|
2257
|
+
const insertValue = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._rawInputValue : inputValue;
|
|
2258
|
+
const tailValue = inputValue.slice(insertValue.length);
|
|
2259
|
+
const prevMask = this.currentMask;
|
|
2260
|
+
const details = new ChangeDetails();
|
|
2261
|
+
const prevMaskState = prevMask == null ? void 0 : prevMask.state;
|
|
2262
|
+
this.currentMask = this.doDispatch(appended, {
|
|
2263
|
+
...flags
|
|
2264
|
+
}, tail);
|
|
2265
|
+
if (this.currentMask) {
|
|
2266
|
+
if (this.currentMask !== prevMask) {
|
|
2267
|
+
this.currentMask.reset();
|
|
2268
|
+
if (insertValue) {
|
|
2269
|
+
this.currentMask.append(insertValue, {
|
|
2270
|
+
raw: true
|
|
2271
|
+
});
|
|
2272
|
+
details.tailShift = this.currentMask.value.length - prevValueBeforeTail.length;
|
|
2273
|
+
}
|
|
2274
|
+
if (tailValue) {
|
|
2275
|
+
details.tailShift += this.currentMask.append(tailValue, {
|
|
2276
|
+
raw: true,
|
|
2277
|
+
tail: true
|
|
2278
|
+
}).tailShift;
|
|
2279
|
+
}
|
|
2280
|
+
} else if (prevMaskState) {
|
|
2281
|
+
this.currentMask.state = prevMaskState;
|
|
2282
|
+
}
|
|
1584
2283
|
}
|
|
2284
|
+
return details;
|
|
1585
2285
|
}
|
|
1586
|
-
|
|
1587
|
-
|
|
2286
|
+
_appendPlaceholder() {
|
|
2287
|
+
const details = this._applyDispatch();
|
|
2288
|
+
if (this.currentMask) {
|
|
2289
|
+
details.aggregate(this.currentMask._appendPlaceholder());
|
|
2290
|
+
}
|
|
2291
|
+
return details;
|
|
1588
2292
|
}
|
|
1589
|
-
|
|
1590
|
-
|
|
2293
|
+
_appendEager() {
|
|
2294
|
+
const details = this._applyDispatch();
|
|
2295
|
+
if (this.currentMask) {
|
|
2296
|
+
details.aggregate(this.currentMask._appendEager());
|
|
2297
|
+
}
|
|
2298
|
+
return details;
|
|
1591
2299
|
}
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
class InputMask {
|
|
1597
|
-
constructor(el, opts) {
|
|
1598
|
-
this.el = el instanceof MaskElement ? el : el.isContentEditable && el.tagName !== 'INPUT' && el.tagName !== 'TEXTAREA' ? new HTMLContenteditableMaskElement(el) : new HTMLMaskElement(el);
|
|
1599
|
-
this.masked = createMask(opts);
|
|
1600
|
-
this._listeners = {};
|
|
1601
|
-
this._value = '';
|
|
1602
|
-
this._unmaskedValue = '';
|
|
1603
|
-
this._saveSelection = this._saveSelection.bind(this);
|
|
1604
|
-
this._onInput = this._onInput.bind(this);
|
|
1605
|
-
this._onChange = this._onChange.bind(this);
|
|
1606
|
-
this._onDrop = this._onDrop.bind(this);
|
|
1607
|
-
this._onFocus = this._onFocus.bind(this);
|
|
1608
|
-
this._onClick = this._onClick.bind(this);
|
|
1609
|
-
this.alignCursor = this.alignCursor.bind(this);
|
|
1610
|
-
this.alignCursorFriendly = this.alignCursorFriendly.bind(this);
|
|
1611
|
-
this._bindEvents();
|
|
1612
|
-
this.updateValue();
|
|
1613
|
-
this._onChange();
|
|
2300
|
+
appendTail(tail) {
|
|
2301
|
+
const details = new ChangeDetails();
|
|
2302
|
+
if (tail) details.aggregate(this._applyDispatch('', {}, tail));
|
|
2303
|
+
return details.aggregate(this.currentMask ? this.currentMask.appendTail(tail) : super.appendTail(tail));
|
|
1614
2304
|
}
|
|
1615
|
-
|
|
1616
|
-
|
|
2305
|
+
currentMaskFlags(flags) {
|
|
2306
|
+
var _flags$_beforeTailSta, _flags$_beforeTailSta2;
|
|
2307
|
+
return {
|
|
2308
|
+
...flags,
|
|
2309
|
+
_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
|
|
2310
|
+
};
|
|
1617
2311
|
}
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
2312
|
+
doDispatch(appended, flags, tail) {
|
|
2313
|
+
if (flags === void 0) {
|
|
2314
|
+
flags = {};
|
|
2315
|
+
}
|
|
2316
|
+
if (tail === void 0) {
|
|
2317
|
+
tail = '';
|
|
2318
|
+
}
|
|
2319
|
+
return this.dispatch(appended, this, flags, tail);
|
|
1621
2320
|
}
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
}
|
|
1628
|
-
return;
|
|
2321
|
+
doValidate(flags) {
|
|
2322
|
+
return super.doValidate(flags) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(flags)));
|
|
2323
|
+
}
|
|
2324
|
+
doPrepare(str, flags) {
|
|
2325
|
+
if (flags === void 0) {
|
|
2326
|
+
flags = {};
|
|
1629
2327
|
}
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
2328
|
+
let [s, details] = super.doPrepare(str, flags);
|
|
2329
|
+
if (this.currentMask) {
|
|
2330
|
+
let currentDetails;
|
|
2331
|
+
[s, currentDetails] = super.doPrepare(s, this.currentMaskFlags(flags));
|
|
2332
|
+
details = details.aggregate(currentDetails);
|
|
2333
|
+
}
|
|
2334
|
+
return [s, details];
|
|
2335
|
+
}
|
|
2336
|
+
doPrepareChar(str, flags) {
|
|
2337
|
+
if (flags === void 0) {
|
|
2338
|
+
flags = {};
|
|
2339
|
+
}
|
|
2340
|
+
let [s, details] = super.doPrepareChar(str, flags);
|
|
2341
|
+
if (this.currentMask) {
|
|
2342
|
+
let currentDetails;
|
|
2343
|
+
[s, currentDetails] = super.doPrepareChar(s, this.currentMaskFlags(flags));
|
|
2344
|
+
details = details.aggregate(currentDetails);
|
|
2345
|
+
}
|
|
2346
|
+
return [s, details];
|
|
2347
|
+
}
|
|
2348
|
+
reset() {
|
|
2349
|
+
var _this$currentMask;
|
|
2350
|
+
(_this$currentMask = this.currentMask) == null || _this$currentMask.reset();
|
|
2351
|
+
this.compiledMasks.forEach(m => m.reset());
|
|
1635
2352
|
}
|
|
1636
2353
|
get value() {
|
|
1637
|
-
return this.
|
|
2354
|
+
return this.exposeMask ? this.exposeMask.value : this.currentMask ? this.currentMask.value : '';
|
|
1638
2355
|
}
|
|
1639
|
-
set value(
|
|
1640
|
-
if (this.
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
2356
|
+
set value(value) {
|
|
2357
|
+
if (this.exposeMask) {
|
|
2358
|
+
this.exposeMask.value = value;
|
|
2359
|
+
this.currentMask = this.exposeMask;
|
|
2360
|
+
this._applyDispatch();
|
|
2361
|
+
} else super.value = value;
|
|
1644
2362
|
}
|
|
1645
2363
|
get unmaskedValue() {
|
|
1646
|
-
return this.
|
|
2364
|
+
return this.exposeMask ? this.exposeMask.unmaskedValue : this.currentMask ? this.currentMask.unmaskedValue : '';
|
|
1647
2365
|
}
|
|
1648
|
-
set unmaskedValue(
|
|
1649
|
-
if (this.
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
2366
|
+
set unmaskedValue(unmaskedValue) {
|
|
2367
|
+
if (this.exposeMask) {
|
|
2368
|
+
this.exposeMask.unmaskedValue = unmaskedValue;
|
|
2369
|
+
this.currentMask = this.exposeMask;
|
|
2370
|
+
this._applyDispatch();
|
|
2371
|
+
} else super.unmaskedValue = unmaskedValue;
|
|
1653
2372
|
}
|
|
1654
2373
|
get typedValue() {
|
|
1655
|
-
return this.
|
|
2374
|
+
return this.exposeMask ? this.exposeMask.typedValue : this.currentMask ? this.currentMask.typedValue : '';
|
|
1656
2375
|
}
|
|
1657
|
-
set typedValue(
|
|
1658
|
-
if (this.
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
2376
|
+
set typedValue(typedValue) {
|
|
2377
|
+
if (this.exposeMask) {
|
|
2378
|
+
this.exposeMask.typedValue = typedValue;
|
|
2379
|
+
this.currentMask = this.exposeMask;
|
|
2380
|
+
this._applyDispatch();
|
|
2381
|
+
return;
|
|
2382
|
+
}
|
|
2383
|
+
let unmaskedValue = String(typedValue);
|
|
2384
|
+
if (this.currentMask) {
|
|
2385
|
+
this.currentMask.typedValue = typedValue;
|
|
2386
|
+
unmaskedValue = this.currentMask.unmaskedValue;
|
|
2387
|
+
}
|
|
2388
|
+
this.unmaskedValue = unmaskedValue;
|
|
1662
2389
|
}
|
|
1663
2390
|
get displayValue() {
|
|
1664
|
-
return this.
|
|
2391
|
+
return this.currentMask ? this.currentMask.displayValue : '';
|
|
1665
2392
|
}
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
input: this._onInput,
|
|
1670
|
-
drop: this._onDrop,
|
|
1671
|
-
click: this._onClick,
|
|
1672
|
-
focus: this._onFocus,
|
|
1673
|
-
commit: this._onChange
|
|
1674
|
-
});
|
|
2393
|
+
get isComplete() {
|
|
2394
|
+
var _this$currentMask2;
|
|
2395
|
+
return Boolean((_this$currentMask2 = this.currentMask) == null ? void 0 : _this$currentMask2.isComplete);
|
|
1675
2396
|
}
|
|
1676
|
-
|
|
1677
|
-
|
|
2397
|
+
get isFilled() {
|
|
2398
|
+
var _this$currentMask3;
|
|
2399
|
+
return Boolean((_this$currentMask3 = this.currentMask) == null ? void 0 : _this$currentMask3.isFilled);
|
|
1678
2400
|
}
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
2401
|
+
remove(fromPos, toPos) {
|
|
2402
|
+
const details = new ChangeDetails();
|
|
2403
|
+
if (this.currentMask) {
|
|
2404
|
+
details.aggregate(this.currentMask.remove(fromPos, toPos))
|
|
2405
|
+
.aggregate(this._applyDispatch());
|
|
1682
2406
|
}
|
|
1683
|
-
|
|
1684
|
-
if (!listeners) return;
|
|
1685
|
-
listeners.forEach(l => l(...args));
|
|
2407
|
+
return details;
|
|
1686
2408
|
}
|
|
1687
|
-
get
|
|
1688
|
-
|
|
2409
|
+
get state() {
|
|
2410
|
+
var _this$currentMask4;
|
|
2411
|
+
return {
|
|
2412
|
+
...super.state,
|
|
2413
|
+
_rawInputValue: this.rawInputValue,
|
|
2414
|
+
compiledMasks: this.compiledMasks.map(m => m.state),
|
|
2415
|
+
currentMaskRef: this.currentMask,
|
|
2416
|
+
currentMask: (_this$currentMask4 = this.currentMask) == null ? void 0 : _this$currentMask4.state
|
|
2417
|
+
};
|
|
1689
2418
|
}
|
|
1690
|
-
|
|
1691
|
-
|
|
2419
|
+
set state(state) {
|
|
2420
|
+
const {
|
|
2421
|
+
compiledMasks,
|
|
2422
|
+
currentMaskRef,
|
|
2423
|
+
currentMask,
|
|
2424
|
+
...maskedState
|
|
2425
|
+
} = state;
|
|
2426
|
+
if (compiledMasks) this.compiledMasks.forEach((m, mi) => m.state = compiledMasks[mi]);
|
|
2427
|
+
if (currentMaskRef != null) {
|
|
2428
|
+
this.currentMask = currentMaskRef;
|
|
2429
|
+
this.currentMask.state = currentMask;
|
|
2430
|
+
}
|
|
2431
|
+
super.state = maskedState;
|
|
1692
2432
|
}
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
this.el.select(pos, pos);
|
|
1696
|
-
this._saveSelection();
|
|
2433
|
+
extractInput(fromPos, toPos, flags) {
|
|
2434
|
+
return this.currentMask ? this.currentMask.extractInput(fromPos, toPos, flags) : '';
|
|
1697
2435
|
}
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
if (this.displayValue !== this.el.value) {
|
|
1701
|
-
console.warn('Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly.');
|
|
1702
|
-
}
|
|
1703
|
-
this._selection = {
|
|
1704
|
-
start: this.selectionStart,
|
|
1705
|
-
end: this.cursorPos
|
|
1706
|
-
};
|
|
2436
|
+
extractTail(fromPos, toPos) {
|
|
2437
|
+
return this.currentMask ? this.currentMask.extractTail(fromPos, toPos) : super.extractTail(fromPos, toPos);
|
|
1707
2438
|
}
|
|
1708
|
-
|
|
1709
|
-
this.
|
|
1710
|
-
|
|
2439
|
+
doCommit() {
|
|
2440
|
+
if (this.currentMask) this.currentMask.doCommit();
|
|
2441
|
+
super.doCommit();
|
|
1711
2442
|
}
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
const newValue = this.masked.value;
|
|
1715
|
-
const newDisplayValue = this.displayValue;
|
|
1716
|
-
const isChanged = this.unmaskedValue !== newUnmaskedValue || this.value !== newValue;
|
|
1717
|
-
this._unmaskedValue = newUnmaskedValue;
|
|
1718
|
-
this._value = newValue;
|
|
1719
|
-
if (this.el.value !== newDisplayValue) this.el.value = newDisplayValue;
|
|
1720
|
-
if (isChanged) this._fireChangeEvents();
|
|
2443
|
+
nearestInputPos(cursorPos, direction) {
|
|
2444
|
+
return this.currentMask ? this.currentMask.nearestInputPos(cursorPos, direction) : super.nearestInputPos(cursorPos, direction);
|
|
1721
2445
|
}
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
mask
|
|
1725
|
-
} = opts,
|
|
1726
|
-
restOpts = _objectWithoutPropertiesLoose(opts, _excluded$1);
|
|
1727
|
-
const updateMask = !this.maskEquals(mask);
|
|
1728
|
-
const updateOpts = !objectIncludes(this.masked, restOpts);
|
|
1729
|
-
if (updateMask) this.mask = mask;
|
|
1730
|
-
if (updateOpts) this.masked.updateOptions(restOpts);
|
|
1731
|
-
if (updateMask || updateOpts) this.updateControl();
|
|
2446
|
+
get overwrite() {
|
|
2447
|
+
return this.currentMask ? this.currentMask.overwrite : this._overwrite;
|
|
1732
2448
|
}
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
this.cursorPos = cursorPos;
|
|
1736
|
-
this._delayUpdateCursor(cursorPos);
|
|
2449
|
+
set overwrite(overwrite) {
|
|
2450
|
+
this._overwrite = overwrite;
|
|
1737
2451
|
}
|
|
1738
|
-
|
|
1739
|
-
this.
|
|
1740
|
-
this._changingCursorPos = cursorPos;
|
|
1741
|
-
this._cursorChanging = setTimeout(() => {
|
|
1742
|
-
if (!this.el) return;
|
|
1743
|
-
this.cursorPos = this._changingCursorPos;
|
|
1744
|
-
this._abortUpdateCursor();
|
|
1745
|
-
}, 10);
|
|
2452
|
+
get eager() {
|
|
2453
|
+
return this.currentMask ? this.currentMask.eager : this._eager;
|
|
1746
2454
|
}
|
|
1747
|
-
|
|
1748
|
-
this.
|
|
1749
|
-
if (this.masked.isComplete) this._fireEvent('complete', this._inputEvent);
|
|
2455
|
+
set eager(eager) {
|
|
2456
|
+
this._eager = eager;
|
|
1750
2457
|
}
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
clearTimeout(this._cursorChanging);
|
|
1754
|
-
delete this._cursorChanging;
|
|
1755
|
-
}
|
|
2458
|
+
get skipInvalid() {
|
|
2459
|
+
return this.currentMask ? this.currentMask.skipInvalid : this._skipInvalid;
|
|
1756
2460
|
}
|
|
1757
|
-
|
|
1758
|
-
this.
|
|
2461
|
+
set skipInvalid(skipInvalid) {
|
|
2462
|
+
this._skipInvalid = skipInvalid;
|
|
1759
2463
|
}
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
this.alignCursor();
|
|
2464
|
+
get autofix() {
|
|
2465
|
+
return this.currentMask ? this.currentMask.autofix : this._autofix;
|
|
1763
2466
|
}
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
this._listeners[ev].push(handler);
|
|
1767
|
-
return this;
|
|
2467
|
+
set autofix(autofix) {
|
|
2468
|
+
this._autofix = autofix;
|
|
1768
2469
|
}
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
2470
|
+
maskEquals(mask) {
|
|
2471
|
+
return Array.isArray(mask) ? this.compiledMasks.every((m, mi) => {
|
|
2472
|
+
if (!mask[mi]) return;
|
|
2473
|
+
const {
|
|
2474
|
+
mask: oldMask,
|
|
2475
|
+
...restOpts
|
|
2476
|
+
} = mask[mi];
|
|
2477
|
+
return objectIncludes(m, restOpts) && m.maskEquals(oldMask);
|
|
2478
|
+
}) : super.maskEquals(mask);
|
|
1778
2479
|
}
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
this.
|
|
1782
|
-
if (!this._selection) return this.updateValue();
|
|
1783
|
-
const details = new ActionDetails(
|
|
1784
|
-
this.el.value, this.cursorPos,
|
|
1785
|
-
this.displayValue, this._selection);
|
|
1786
|
-
const oldRawValue = this.masked.rawInputValue;
|
|
1787
|
-
const offset = this.masked.splice(details.startChangePos, details.removed.length, details.inserted, details.removeDirection, {
|
|
1788
|
-
input: true,
|
|
1789
|
-
raw: true
|
|
1790
|
-
}).offset;
|
|
1791
|
-
const removeDirection = oldRawValue === this.masked.rawInputValue ? details.removeDirection : DIRECTION.NONE;
|
|
1792
|
-
let cursorPos = this.masked.nearestInputPos(details.startChangePos + offset, removeDirection);
|
|
1793
|
-
if (removeDirection !== DIRECTION.NONE) cursorPos = this.masked.nearestInputPos(cursorPos, DIRECTION.NONE);
|
|
1794
|
-
this.updateControl();
|
|
1795
|
-
this.updateCursor(cursorPos);
|
|
1796
|
-
delete this._inputEvent;
|
|
2480
|
+
typedValueEquals(value) {
|
|
2481
|
+
var _this$currentMask5;
|
|
2482
|
+
return Boolean((_this$currentMask5 = this.currentMask) == null ? void 0 : _this$currentMask5.typedValueEquals(value));
|
|
1797
2483
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
2484
|
+
}
|
|
2485
|
+
MaskedDynamic.DEFAULTS = {
|
|
2486
|
+
...Masked.DEFAULTS,
|
|
2487
|
+
dispatch: (appended, masked, flags, tail) => {
|
|
2488
|
+
if (!masked.compiledMasks.length) return;
|
|
2489
|
+
const inputValue = masked.rawInputValue;
|
|
2490
|
+
const inputs = masked.compiledMasks.map((m, index) => {
|
|
2491
|
+
const isCurrent = masked.currentMask === m;
|
|
2492
|
+
const startInputPos = isCurrent ? m.displayValue.length : m.nearestInputPos(m.displayValue.length, DIRECTION.FORCE_LEFT);
|
|
2493
|
+
if (m.rawInputValue !== inputValue) {
|
|
2494
|
+
m.reset();
|
|
2495
|
+
m.append(inputValue, {
|
|
2496
|
+
raw: true
|
|
2497
|
+
});
|
|
2498
|
+
} else if (!isCurrent) {
|
|
2499
|
+
m.remove(startInputPos);
|
|
2500
|
+
}
|
|
2501
|
+
m.append(appended, masked.currentMaskFlags(flags));
|
|
2502
|
+
m.appendTail(tail);
|
|
2503
|
+
return {
|
|
2504
|
+
index,
|
|
2505
|
+
weight: m.rawInputValue.length,
|
|
2506
|
+
totalInputPositions: m.totalInputPositions(0, Math.max(startInputPos, m.nearestInputPos(m.displayValue.length, DIRECTION.FORCE_LEFT)))
|
|
2507
|
+
};
|
|
2508
|
+
});
|
|
2509
|
+
inputs.sort((i1, i2) => i2.weight - i1.weight || i2.totalInputPositions - i1.totalInputPositions);
|
|
2510
|
+
return masked.compiledMasks[inputs[0].index];
|
|
1805
2511
|
}
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
2512
|
+
};
|
|
2513
|
+
IMask.MaskedDynamic = MaskedDynamic;
|
|
2514
|
+
|
|
2515
|
+
class MaskedEnum extends MaskedPattern {
|
|
2516
|
+
constructor(opts) {
|
|
2517
|
+
super({
|
|
2518
|
+
...MaskedEnum.DEFAULTS,
|
|
2519
|
+
...opts
|
|
2520
|
+
});
|
|
1809
2521
|
}
|
|
1810
|
-
|
|
1811
|
-
|
|
2522
|
+
updateOptions(opts) {
|
|
2523
|
+
super.updateOptions(opts);
|
|
2524
|
+
}
|
|
2525
|
+
_update(opts) {
|
|
2526
|
+
const {
|
|
2527
|
+
enum: enum_,
|
|
2528
|
+
...eopts
|
|
2529
|
+
} = opts;
|
|
2530
|
+
if (enum_) {
|
|
2531
|
+
const lengths = enum_.map(e => e.length);
|
|
2532
|
+
const requiredLength = Math.min(...lengths);
|
|
2533
|
+
const optionalLength = Math.max(...lengths) - requiredLength;
|
|
2534
|
+
eopts.mask = '*'.repeat(requiredLength);
|
|
2535
|
+
if (optionalLength) eopts.mask += '[' + '*'.repeat(optionalLength) + ']';
|
|
2536
|
+
this.enum = enum_;
|
|
2537
|
+
}
|
|
2538
|
+
super._update(eopts);
|
|
2539
|
+
}
|
|
2540
|
+
_appendCharRaw(ch, flags) {
|
|
2541
|
+
if (flags === void 0) {
|
|
2542
|
+
flags = {};
|
|
2543
|
+
}
|
|
2544
|
+
const matchFrom = Math.min(this.nearestInputPos(0, DIRECTION.FORCE_RIGHT), this.value.length);
|
|
2545
|
+
const matches = this.enum.filter(e => this.matchValue(e, this.unmaskedValue + ch, matchFrom));
|
|
2546
|
+
if (matches.length) {
|
|
2547
|
+
if (matches.length === 1) {
|
|
2548
|
+
this._forEachBlocksInRange(0, this.value.length, (b, bi) => {
|
|
2549
|
+
const mch = matches[0][bi];
|
|
2550
|
+
if (bi >= this.value.length || mch === b.value) return;
|
|
2551
|
+
b.reset();
|
|
2552
|
+
b._appendChar(mch, flags);
|
|
2553
|
+
});
|
|
2554
|
+
}
|
|
2555
|
+
const d = super._appendCharRaw(matches[0][this.value.length], flags);
|
|
2556
|
+
if (matches.length === 1) {
|
|
2557
|
+
matches[0].slice(this.unmaskedValue.length).split('').forEach(mch => d.aggregate(super._appendCharRaw(mch)));
|
|
2558
|
+
}
|
|
2559
|
+
return d;
|
|
2560
|
+
}
|
|
2561
|
+
return new ChangeDetails({
|
|
2562
|
+
skip: !this.isComplete
|
|
2563
|
+
});
|
|
1812
2564
|
}
|
|
1813
|
-
|
|
1814
|
-
|
|
2565
|
+
extractTail(fromPos, toPos) {
|
|
2566
|
+
if (fromPos === void 0) {
|
|
2567
|
+
fromPos = 0;
|
|
2568
|
+
}
|
|
2569
|
+
if (toPos === void 0) {
|
|
2570
|
+
toPos = this.displayValue.length;
|
|
2571
|
+
}
|
|
2572
|
+
return new ContinuousTailDetails('', fromPos);
|
|
1815
2573
|
}
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
2574
|
+
remove(fromPos, toPos) {
|
|
2575
|
+
if (fromPos === void 0) {
|
|
2576
|
+
fromPos = 0;
|
|
2577
|
+
}
|
|
2578
|
+
if (toPos === void 0) {
|
|
2579
|
+
toPos = this.displayValue.length;
|
|
2580
|
+
}
|
|
2581
|
+
if (fromPos === toPos) return new ChangeDetails();
|
|
2582
|
+
const matchFrom = Math.min(super.nearestInputPos(0, DIRECTION.FORCE_RIGHT), this.value.length);
|
|
2583
|
+
let pos;
|
|
2584
|
+
for (pos = fromPos; pos >= 0; --pos) {
|
|
2585
|
+
const matches = this.enum.filter(e => this.matchValue(e, this.value.slice(matchFrom, pos), matchFrom));
|
|
2586
|
+
if (matches.length > 1) break;
|
|
2587
|
+
}
|
|
2588
|
+
const details = super.remove(pos, toPos);
|
|
2589
|
+
details.tailShift += pos - fromPos;
|
|
2590
|
+
return details;
|
|
2591
|
+
}
|
|
2592
|
+
get isComplete() {
|
|
2593
|
+
return this.enum.indexOf(this.value) >= 0;
|
|
1820
2594
|
}
|
|
1821
2595
|
}
|
|
1822
|
-
|
|
2596
|
+
MaskedEnum.DEFAULTS = {
|
|
2597
|
+
...MaskedPattern.DEFAULTS,
|
|
2598
|
+
matchValue: (estr, istr, matchFrom) => estr.indexOf(istr, matchFrom) === matchFrom
|
|
2599
|
+
};
|
|
2600
|
+
IMask.MaskedEnum = MaskedEnum;
|
|
1823
2601
|
|
|
1824
|
-
class
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
super._update(opts);
|
|
2602
|
+
class MaskedFunction extends Masked {
|
|
2603
|
+
updateOptions(opts) {
|
|
2604
|
+
super.updateOptions(opts);
|
|
1828
2605
|
}
|
|
1829
|
-
|
|
1830
|
-
|
|
2606
|
+
_update(opts) {
|
|
2607
|
+
super._update({
|
|
2608
|
+
...opts,
|
|
2609
|
+
validate: opts.mask
|
|
2610
|
+
});
|
|
1831
2611
|
}
|
|
1832
2612
|
}
|
|
1833
|
-
IMask.
|
|
2613
|
+
IMask.MaskedFunction = MaskedFunction;
|
|
1834
2614
|
|
|
2615
|
+
var _MaskedNumber;
|
|
1835
2616
|
class MaskedNumber extends Masked {
|
|
1836
2617
|
constructor(opts) {
|
|
1837
|
-
super(
|
|
2618
|
+
super({
|
|
2619
|
+
...MaskedNumber.DEFAULTS,
|
|
2620
|
+
...opts
|
|
2621
|
+
});
|
|
2622
|
+
}
|
|
2623
|
+
updateOptions(opts) {
|
|
2624
|
+
super.updateOptions(opts);
|
|
1838
2625
|
}
|
|
1839
2626
|
_update(opts) {
|
|
1840
2627
|
super._update(opts);
|
|
1841
2628
|
this._updateRegExps();
|
|
1842
2629
|
}
|
|
1843
2630
|
_updateRegExps() {
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
2631
|
+
const start = '^' + (this.allowNegative ? '[+|\\-]?' : '');
|
|
2632
|
+
const mid = '\\d*';
|
|
2633
|
+
const end = (this.scale ? "(" + escapeRegExp(this.radix) + "\\d{0," + this.scale + "})?" : '') + '$';
|
|
1847
2634
|
this._numberRegExp = new RegExp(start + mid + end);
|
|
1848
|
-
this._mapToRadixRegExp = new RegExp("["
|
|
2635
|
+
this._mapToRadixRegExp = new RegExp("[" + this.mapToRadix.map(escapeRegExp).join('') + "]", 'g');
|
|
1849
2636
|
this._thousandsSeparatorRegExp = new RegExp(escapeRegExp(this.thousandsSeparator), 'g');
|
|
1850
2637
|
}
|
|
1851
2638
|
_removeThousandsSeparators(value) {
|
|
@@ -1856,16 +2643,20 @@
|
|
|
1856
2643
|
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, this.thousandsSeparator);
|
|
1857
2644
|
return parts.join(this.radix);
|
|
1858
2645
|
}
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
const [prepCh, details] =
|
|
2646
|
+
doPrepareChar(ch, flags) {
|
|
2647
|
+
if (flags === void 0) {
|
|
2648
|
+
flags = {};
|
|
2649
|
+
}
|
|
2650
|
+
const [prepCh, details] = super.doPrepareChar(this._removeThousandsSeparators(this.scale && this.mapToRadix.length && (
|
|
2651
|
+
flags.input && flags.raw || !flags.input && !flags.raw) ? ch.replace(this._mapToRadixRegExp, this.radix) : ch), flags);
|
|
1864
2652
|
if (ch && !prepCh) details.skip = true;
|
|
2653
|
+
if (prepCh && !this.allowPositive && !this.value && prepCh !== '-') details.aggregate(this._appendChar('-'));
|
|
1865
2654
|
return [prepCh, details];
|
|
1866
2655
|
}
|
|
1867
|
-
_separatorsCount(to) {
|
|
1868
|
-
|
|
2656
|
+
_separatorsCount(to, extendOnSeparators) {
|
|
2657
|
+
if (extendOnSeparators === void 0) {
|
|
2658
|
+
extendOnSeparators = false;
|
|
2659
|
+
}
|
|
1869
2660
|
let count = 0;
|
|
1870
2661
|
for (let pos = 0; pos < to; ++pos) {
|
|
1871
2662
|
if (this._value.indexOf(this.thousandsSeparator, pos) === pos) {
|
|
@@ -1875,29 +2666,63 @@
|
|
|
1875
2666
|
}
|
|
1876
2667
|
return count;
|
|
1877
2668
|
}
|
|
1878
|
-
_separatorsCountFromSlice() {
|
|
1879
|
-
|
|
2669
|
+
_separatorsCountFromSlice(slice) {
|
|
2670
|
+
if (slice === void 0) {
|
|
2671
|
+
slice = this._value;
|
|
2672
|
+
}
|
|
1880
2673
|
return this._separatorsCount(this._removeThousandsSeparators(slice).length, true);
|
|
1881
2674
|
}
|
|
1882
|
-
extractInput() {
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
2675
|
+
extractInput(fromPos, toPos, flags) {
|
|
2676
|
+
if (fromPos === void 0) {
|
|
2677
|
+
fromPos = 0;
|
|
2678
|
+
}
|
|
2679
|
+
if (toPos === void 0) {
|
|
2680
|
+
toPos = this.displayValue.length;
|
|
2681
|
+
}
|
|
1886
2682
|
[fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);
|
|
1887
2683
|
return this._removeThousandsSeparators(super.extractInput(fromPos, toPos, flags));
|
|
1888
2684
|
}
|
|
1889
|
-
_appendCharRaw(ch) {
|
|
1890
|
-
|
|
1891
|
-
|
|
2685
|
+
_appendCharRaw(ch, flags) {
|
|
2686
|
+
if (flags === void 0) {
|
|
2687
|
+
flags = {};
|
|
2688
|
+
}
|
|
1892
2689
|
const prevBeforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
|
|
1893
2690
|
const prevBeforeTailSeparatorsCount = this._separatorsCountFromSlice(prevBeforeTailValue);
|
|
1894
2691
|
this._value = this._removeThousandsSeparators(this.value);
|
|
1895
|
-
const
|
|
2692
|
+
const oldValue = this._value;
|
|
2693
|
+
this._value += ch;
|
|
2694
|
+
const num = this.number;
|
|
2695
|
+
let accepted = !isNaN(num);
|
|
2696
|
+
let skip = false;
|
|
2697
|
+
if (accepted) {
|
|
2698
|
+
let fixedNum;
|
|
2699
|
+
if (this.min != null && this.min < 0 && this.number < this.min) fixedNum = this.min;
|
|
2700
|
+
if (this.max != null && this.max > 0 && this.number > this.max) fixedNum = this.max;
|
|
2701
|
+
if (fixedNum != null) {
|
|
2702
|
+
if (this.autofix) {
|
|
2703
|
+
this._value = this.format(fixedNum, this).replace(MaskedNumber.UNMASKED_RADIX, this.radix);
|
|
2704
|
+
skip || (skip = oldValue === this._value && !flags.tail);
|
|
2705
|
+
} else {
|
|
2706
|
+
accepted = false;
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
accepted && (accepted = Boolean(this._value.match(this._numberRegExp)));
|
|
2710
|
+
}
|
|
2711
|
+
let appendDetails;
|
|
2712
|
+
if (!accepted) {
|
|
2713
|
+
this._value = oldValue;
|
|
2714
|
+
appendDetails = new ChangeDetails();
|
|
2715
|
+
} else {
|
|
2716
|
+
appendDetails = new ChangeDetails({
|
|
2717
|
+
inserted: this._value.slice(oldValue.length),
|
|
2718
|
+
rawInserted: skip ? '' : ch,
|
|
2719
|
+
skip
|
|
2720
|
+
});
|
|
2721
|
+
}
|
|
1896
2722
|
this._value = this._insertThousandsSeparators(this._value);
|
|
1897
2723
|
const beforeTailValue = flags.tail && flags._beforeTailState ? flags._beforeTailState._value : this._value;
|
|
1898
2724
|
const beforeTailSeparatorsCount = this._separatorsCountFromSlice(beforeTailValue);
|
|
1899
2725
|
appendDetails.tailShift += (beforeTailSeparatorsCount - prevBeforeTailSeparatorsCount) * this.thousandsSeparator.length;
|
|
1900
|
-
appendDetails.skip = !appendDetails.rawInserted && ch === this.thousandsSeparator;
|
|
1901
2726
|
return appendDetails;
|
|
1902
2727
|
}
|
|
1903
2728
|
_findSeparatorAround(pos) {
|
|
@@ -1915,9 +2740,13 @@
|
|
|
1915
2740
|
if (separatorAroundToPos >= 0) to = separatorAroundToPos + this.thousandsSeparator.length;
|
|
1916
2741
|
return [from, to];
|
|
1917
2742
|
}
|
|
1918
|
-
remove() {
|
|
1919
|
-
|
|
1920
|
-
|
|
2743
|
+
remove(fromPos, toPos) {
|
|
2744
|
+
if (fromPos === void 0) {
|
|
2745
|
+
fromPos = 0;
|
|
2746
|
+
}
|
|
2747
|
+
if (toPos === void 0) {
|
|
2748
|
+
toPos = this.displayValue.length;
|
|
2749
|
+
}
|
|
1921
2750
|
[fromPos, toPos] = this._adjustRangeWithSeparators(fromPos, toPos);
|
|
1922
2751
|
const valueBeforePos = this.value.slice(0, fromPos);
|
|
1923
2752
|
const valueAfterPos = this.value.slice(toPos);
|
|
@@ -1955,23 +2784,13 @@
|
|
|
1955
2784
|
}
|
|
1956
2785
|
return cursorPos;
|
|
1957
2786
|
}
|
|
1958
|
-
doValidate(flags) {
|
|
1959
|
-
let valid = Boolean(this._removeThousandsSeparators(this.value).match(this._numberRegExp));
|
|
1960
|
-
if (valid) {
|
|
1961
|
-
const number = this.number;
|
|
1962
|
-
valid = valid && !isNaN(number) && (
|
|
1963
|
-
this.min == null || this.min >= 0 || this.min <= this.number) && (
|
|
1964
|
-
this.max == null || this.max <= 0 || this.number <= this.max);
|
|
1965
|
-
}
|
|
1966
|
-
return valid && super.doValidate(flags);
|
|
1967
|
-
}
|
|
1968
2787
|
doCommit() {
|
|
1969
2788
|
if (this.value) {
|
|
1970
2789
|
const number = this.number;
|
|
1971
2790
|
let validnum = number;
|
|
1972
2791
|
if (this.min != null) validnum = Math.max(validnum, this.min);
|
|
1973
2792
|
if (this.max != null) validnum = Math.min(validnum, this.max);
|
|
1974
|
-
if (validnum !== number) this.unmaskedValue = this.
|
|
2793
|
+
if (validnum !== number) this.unmaskedValue = this.format(validnum, this);
|
|
1975
2794
|
let formatted = this.value;
|
|
1976
2795
|
if (this.normalizeZeros) formatted = this._normalizeZeros(formatted);
|
|
1977
2796
|
if (this.padFractionalZeros && this.scale > 0) formatted = this._padFractionalZeros(formatted);
|
|
@@ -1996,9 +2815,10 @@
|
|
|
1996
2815
|
parts[1] = parts[1].padEnd(this.scale, '0');
|
|
1997
2816
|
return parts.join(this.radix);
|
|
1998
2817
|
}
|
|
1999
|
-
doSkipInvalid(ch) {
|
|
2000
|
-
|
|
2001
|
-
|
|
2818
|
+
doSkipInvalid(ch, flags, checkTail) {
|
|
2819
|
+
if (flags === void 0) {
|
|
2820
|
+
flags = {};
|
|
2821
|
+
}
|
|
2002
2822
|
const dropFractional = this.scale === 0 && ch !== this.thousandsSeparator && (ch === this.radix || ch === MaskedNumber.UNMASKED_RADIX || this.mapToRadix.includes(ch));
|
|
2003
2823
|
return super.doSkipInvalid(ch, flags, checkTail) && !dropFractional;
|
|
2004
2824
|
}
|
|
@@ -2009,10 +2829,10 @@
|
|
|
2009
2829
|
super.unmaskedValue = unmaskedValue;
|
|
2010
2830
|
}
|
|
2011
2831
|
get typedValue() {
|
|
2012
|
-
return this.
|
|
2832
|
+
return this.parse(this.unmaskedValue, this);
|
|
2013
2833
|
}
|
|
2014
2834
|
set typedValue(n) {
|
|
2015
|
-
this.rawInputValue = this.
|
|
2835
|
+
this.rawInputValue = this.format(n, this).replace(MaskedNumber.UNMASKED_RADIX, this.radix);
|
|
2016
2836
|
}
|
|
2017
2837
|
get number() {
|
|
2018
2838
|
return this.typedValue;
|
|
@@ -2021,19 +2841,27 @@
|
|
|
2021
2841
|
this.typedValue = number;
|
|
2022
2842
|
}
|
|
2023
2843
|
get allowNegative() {
|
|
2024
|
-
return this.
|
|
2844
|
+
return this.min != null && this.min < 0 || this.max != null && this.max < 0;
|
|
2845
|
+
}
|
|
2846
|
+
get allowPositive() {
|
|
2847
|
+
return this.min != null && this.min > 0 || this.max != null && this.max > 0;
|
|
2025
2848
|
}
|
|
2026
2849
|
typedValueEquals(value) {
|
|
2027
2850
|
return (super.typedValueEquals(value) || MaskedNumber.EMPTY_VALUES.includes(value) && MaskedNumber.EMPTY_VALUES.includes(this.typedValue)) && !(value === 0 && this.value === '');
|
|
2028
2851
|
}
|
|
2029
2852
|
}
|
|
2853
|
+
_MaskedNumber = MaskedNumber;
|
|
2030
2854
|
MaskedNumber.UNMASKED_RADIX = '.';
|
|
2855
|
+
MaskedNumber.EMPTY_VALUES = [...Masked.EMPTY_VALUES, 0];
|
|
2031
2856
|
MaskedNumber.DEFAULTS = {
|
|
2857
|
+
...Masked.DEFAULTS,
|
|
2858
|
+
mask: Number,
|
|
2032
2859
|
radix: ',',
|
|
2033
2860
|
thousandsSeparator: '',
|
|
2034
|
-
mapToRadix: [
|
|
2861
|
+
mapToRadix: [_MaskedNumber.UNMASKED_RADIX],
|
|
2862
|
+
min: Number.MIN_SAFE_INTEGER,
|
|
2863
|
+
max: Number.MAX_SAFE_INTEGER,
|
|
2035
2864
|
scale: 2,
|
|
2036
|
-
signed: false,
|
|
2037
2865
|
normalizeZeros: true,
|
|
2038
2866
|
padFractionalZeros: false,
|
|
2039
2867
|
parse: Number,
|
|
@@ -2042,290 +2870,154 @@
|
|
|
2042
2870
|
maximumFractionDigits: 20
|
|
2043
2871
|
})
|
|
2044
2872
|
};
|
|
2045
|
-
MaskedNumber.EMPTY_VALUES = [...Masked.EMPTY_VALUES, 0];
|
|
2046
2873
|
IMask.MaskedNumber = MaskedNumber;
|
|
2047
2874
|
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2875
|
+
const PIPE_TYPE = {
|
|
2876
|
+
MASKED: 'value',
|
|
2877
|
+
UNMASKED: 'unmaskedValue',
|
|
2878
|
+
TYPED: 'typedValue'
|
|
2879
|
+
};
|
|
2880
|
+
function createPipe(arg, from, to) {
|
|
2881
|
+
if (from === void 0) {
|
|
2882
|
+
from = PIPE_TYPE.MASKED;
|
|
2052
2883
|
}
|
|
2884
|
+
if (to === void 0) {
|
|
2885
|
+
to = PIPE_TYPE.MASKED;
|
|
2886
|
+
}
|
|
2887
|
+
const masked = createMask(arg);
|
|
2888
|
+
return value => masked.runIsolated(m => {
|
|
2889
|
+
m[from] = value;
|
|
2890
|
+
return m[to];
|
|
2891
|
+
});
|
|
2053
2892
|
}
|
|
2054
|
-
|
|
2893
|
+
function pipe(value, mask, from, to) {
|
|
2894
|
+
return createPipe(mask, from, to)(value);
|
|
2895
|
+
}
|
|
2896
|
+
IMask.PIPE_TYPE = PIPE_TYPE;
|
|
2897
|
+
IMask.createPipe = createPipe;
|
|
2898
|
+
IMask.pipe = pipe;
|
|
2055
2899
|
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2900
|
+
class RepeatBlock extends MaskedPattern {
|
|
2901
|
+
get repeatFrom() {
|
|
2902
|
+
var _ref;
|
|
2903
|
+
return (_ref = Array.isArray(this.repeat) ? this.repeat[0] : this.repeat === Infinity ? 0 : this.repeat) != null ? _ref : 0;
|
|
2904
|
+
}
|
|
2905
|
+
get repeatTo() {
|
|
2906
|
+
var _ref2;
|
|
2907
|
+
return (_ref2 = Array.isArray(this.repeat) ? this.repeat[1] : this.repeat) != null ? _ref2 : Infinity;
|
|
2908
|
+
}
|
|
2059
2909
|
constructor(opts) {
|
|
2060
|
-
super(
|
|
2061
|
-
|
|
2910
|
+
super(opts);
|
|
2911
|
+
}
|
|
2912
|
+
updateOptions(opts) {
|
|
2913
|
+
super.updateOptions(opts);
|
|
2062
2914
|
}
|
|
2063
2915
|
_update(opts) {
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2916
|
+
var _ref3, _ref4, _this$_blocks;
|
|
2917
|
+
const {
|
|
2918
|
+
repeat,
|
|
2919
|
+
...blockOpts
|
|
2920
|
+
} = normalizeOpts(opts);
|
|
2921
|
+
this._blockOpts = Object.assign({}, this._blockOpts, blockOpts);
|
|
2922
|
+
const block = createMask(this._blockOpts);
|
|
2923
|
+
this.repeat = (_ref3 = (_ref4 = repeat != null ? repeat : block.repeat) != null ? _ref4 : this.repeat) != null ? _ref3 : Infinity;
|
|
2924
|
+
super._update({
|
|
2925
|
+
mask: 'm'.repeat(Math.max(this.repeatTo === Infinity && ((_this$_blocks = this._blocks) == null ? void 0 : _this$_blocks.length) || 0, this.repeatFrom)),
|
|
2926
|
+
blocks: {
|
|
2927
|
+
m: block
|
|
2928
|
+
},
|
|
2929
|
+
eager: block.eager,
|
|
2930
|
+
overwrite: block.overwrite,
|
|
2931
|
+
skipInvalid: block.skipInvalid,
|
|
2932
|
+
lazy: block.lazy,
|
|
2933
|
+
placeholderChar: block.placeholderChar,
|
|
2934
|
+
displayChar: block.displayChar
|
|
2935
|
+
});
|
|
2068
2936
|
}
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2937
|
+
_allocateBlock(bi) {
|
|
2938
|
+
if (bi < this._blocks.length) return this._blocks[bi];
|
|
2939
|
+
if (this.repeatTo === Infinity || this._blocks.length < this.repeatTo) {
|
|
2940
|
+
this._blocks.push(createMask(this._blockOpts));
|
|
2941
|
+
this.mask += 'm';
|
|
2942
|
+
return this._blocks[this._blocks.length - 1];
|
|
2074
2943
|
}
|
|
2075
|
-
return details;
|
|
2076
2944
|
}
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
const prevValueBeforeTail = flags.tail && flags._beforeTailState != null ? flags._beforeTailState._value : this.value;
|
|
2082
|
-
const inputValue = this.rawInputValue;
|
|
2083
|
-
const insertValue = flags.tail && flags._beforeTailState != null ?
|
|
2084
|
-
flags._beforeTailState._rawInputValue : inputValue;
|
|
2085
|
-
const tailValue = inputValue.slice(insertValue.length);
|
|
2086
|
-
const prevMask = this.currentMask;
|
|
2945
|
+
_appendCharRaw(ch, flags) {
|
|
2946
|
+
if (flags === void 0) {
|
|
2947
|
+
flags = {};
|
|
2948
|
+
}
|
|
2087
2949
|
const details = new ChangeDetails();
|
|
2088
|
-
|
|
2089
|
-
this.
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
if (tailValue) {
|
|
2100
|
-
details.tailShift += this.currentMask.append(tailValue, {
|
|
2101
|
-
raw: true,
|
|
2102
|
-
tail: true
|
|
2103
|
-
}).tailShift;
|
|
2104
|
-
}
|
|
2105
|
-
} else {
|
|
2106
|
-
this.currentMask.state = prevMaskState;
|
|
2950
|
+
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;
|
|
2951
|
+
block = (_this$_blocks$bi = this._blocks[bi]) != null ? _this$_blocks$bi : allocated = !allocated && this._allocateBlock(bi); ++bi) {
|
|
2952
|
+
var _this$_mapPosToBlock$, _this$_mapPosToBlock, _this$_blocks$bi, _flags$_beforeTailSta;
|
|
2953
|
+
const blockDetails = block._appendChar(ch, {
|
|
2954
|
+
...flags,
|
|
2955
|
+
_beforeTailState: (_flags$_beforeTailSta = flags._beforeTailState) == null || (_flags$_beforeTailSta = _flags$_beforeTailSta._blocks) == null ? void 0 : _flags$_beforeTailSta[bi]
|
|
2956
|
+
});
|
|
2957
|
+
if (blockDetails.skip && allocated) {
|
|
2958
|
+
this._blocks.pop();
|
|
2959
|
+
this.mask = this.mask.slice(1);
|
|
2960
|
+
break;
|
|
2107
2961
|
}
|
|
2962
|
+
details.aggregate(blockDetails);
|
|
2963
|
+
if (blockDetails.consumed) break;
|
|
2108
2964
|
}
|
|
2109
2965
|
return details;
|
|
2110
2966
|
}
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
if (
|
|
2114
|
-
|
|
2967
|
+
_trimEmptyTail(fromPos, toPos) {
|
|
2968
|
+
var _this$_mapPosToBlock2, _this$_mapPosToBlock3;
|
|
2969
|
+
if (fromPos === void 0) {
|
|
2970
|
+
fromPos = 0;
|
|
2115
2971
|
}
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2972
|
+
const firstBlockIndex = Math.max(((_this$_mapPosToBlock2 = this._mapPosToBlock(fromPos)) == null ? void 0 : _this$_mapPosToBlock2.index) || 0, this.repeatFrom, 0);
|
|
2973
|
+
let lastBlockIndex;
|
|
2974
|
+
if (toPos != null) lastBlockIndex = (_this$_mapPosToBlock3 = this._mapPosToBlock(toPos)) == null ? void 0 : _this$_mapPosToBlock3.index;
|
|
2975
|
+
if (lastBlockIndex == null) lastBlockIndex = this._blocks.length - 1;
|
|
2976
|
+
let removeCount = 0;
|
|
2977
|
+
for (let blockIndex = lastBlockIndex; firstBlockIndex <= blockIndex; --blockIndex, ++removeCount) {
|
|
2978
|
+
if (this._blocks[blockIndex].unmaskedValue) break;
|
|
2122
2979
|
}
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
const details = new ChangeDetails();
|
|
2127
|
-
if (tail) details.aggregate(this._applyDispatch('', {}, tail));
|
|
2128
|
-
return details.aggregate(this.currentMask ? this.currentMask.appendTail(tail) : super.appendTail(tail));
|
|
2129
|
-
}
|
|
2130
|
-
currentMaskFlags(flags) {
|
|
2131
|
-
var _flags$_beforeTailSta, _flags$_beforeTailSta2;
|
|
2132
|
-
return Object.assign({}, flags, {
|
|
2133
|
-
_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
|
|
2134
|
-
});
|
|
2135
|
-
}
|
|
2136
|
-
doDispatch(appended) {
|
|
2137
|
-
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2138
|
-
let tail = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
2139
|
-
return this.dispatch(appended, this, flags, tail);
|
|
2140
|
-
}
|
|
2141
|
-
doValidate(flags) {
|
|
2142
|
-
return super.doValidate(flags) && (!this.currentMask || this.currentMask.doValidate(this.currentMaskFlags(flags)));
|
|
2143
|
-
}
|
|
2144
|
-
doPrepare(str) {
|
|
2145
|
-
let flags = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2146
|
-
let [s, details] = normalizePrepare(super.doPrepare(str, flags));
|
|
2147
|
-
if (this.currentMask) {
|
|
2148
|
-
let currentDetails;
|
|
2149
|
-
[s, currentDetails] = normalizePrepare(super.doPrepare(s, this.currentMaskFlags(flags)));
|
|
2150
|
-
details = details.aggregate(currentDetails);
|
|
2980
|
+
if (removeCount) {
|
|
2981
|
+
this._blocks.splice(lastBlockIndex - removeCount + 1, removeCount);
|
|
2982
|
+
this.mask = this.mask.slice(removeCount);
|
|
2151
2983
|
}
|
|
2152
|
-
return [s, details];
|
|
2153
2984
|
}
|
|
2154
2985
|
reset() {
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
this.compiledMasks.forEach(m => m.reset());
|
|
2158
|
-
}
|
|
2159
|
-
get value() {
|
|
2160
|
-
return this.currentMask ? this.currentMask.value : '';
|
|
2161
|
-
}
|
|
2162
|
-
set value(value) {
|
|
2163
|
-
super.value = value;
|
|
2164
|
-
}
|
|
2165
|
-
get unmaskedValue() {
|
|
2166
|
-
return this.currentMask ? this.currentMask.unmaskedValue : '';
|
|
2167
|
-
}
|
|
2168
|
-
set unmaskedValue(unmaskedValue) {
|
|
2169
|
-
super.unmaskedValue = unmaskedValue;
|
|
2170
|
-
}
|
|
2171
|
-
get typedValue() {
|
|
2172
|
-
return this.currentMask ? this.currentMask.typedValue : '';
|
|
2986
|
+
super.reset();
|
|
2987
|
+
this._trimEmptyTail();
|
|
2173
2988
|
}
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
this.currentMask.typedValue = value;
|
|
2178
|
-
unmaskedValue = this.currentMask.unmaskedValue;
|
|
2989
|
+
remove(fromPos, toPos) {
|
|
2990
|
+
if (fromPos === void 0) {
|
|
2991
|
+
fromPos = 0;
|
|
2179
2992
|
}
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
var _this$currentMask2;
|
|
2187
|
-
return Boolean((_this$currentMask2 = this.currentMask) === null || _this$currentMask2 === void 0 ? void 0 : _this$currentMask2.isComplete);
|
|
2188
|
-
}
|
|
2189
|
-
get isFilled() {
|
|
2190
|
-
var _this$currentMask3;
|
|
2191
|
-
return Boolean((_this$currentMask3 = this.currentMask) === null || _this$currentMask3 === void 0 ? void 0 : _this$currentMask3.isFilled);
|
|
2993
|
+
if (toPos === void 0) {
|
|
2994
|
+
toPos = this.displayValue.length;
|
|
2995
|
+
}
|
|
2996
|
+
const removeDetails = super.remove(fromPos, toPos);
|
|
2997
|
+
this._trimEmptyTail(fromPos, toPos);
|
|
2998
|
+
return removeDetails;
|
|
2192
2999
|
}
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
details.aggregate(this.currentMask.remove(...arguments))
|
|
2197
|
-
.aggregate(this._applyDispatch());
|
|
3000
|
+
totalInputPositions(fromPos, toPos) {
|
|
3001
|
+
if (fromPos === void 0) {
|
|
3002
|
+
fromPos = 0;
|
|
2198
3003
|
}
|
|
2199
|
-
return
|
|
3004
|
+
if (toPos == null && this.repeatTo === Infinity) return Infinity;
|
|
3005
|
+
return super.totalInputPositions(fromPos, toPos);
|
|
2200
3006
|
}
|
|
2201
3007
|
get state() {
|
|
2202
|
-
|
|
2203
|
-
return Object.assign({}, super.state, {
|
|
2204
|
-
_rawInputValue: this.rawInputValue,
|
|
2205
|
-
compiledMasks: this.compiledMasks.map(m => m.state),
|
|
2206
|
-
currentMaskRef: this.currentMask,
|
|
2207
|
-
currentMask: (_this$currentMask4 = this.currentMask) === null || _this$currentMask4 === void 0 ? void 0 : _this$currentMask4.state
|
|
2208
|
-
});
|
|
3008
|
+
return super.state;
|
|
2209
3009
|
}
|
|
2210
3010
|
set state(state) {
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
currentMask
|
|
2215
|
-
} = state,
|
|
2216
|
-
maskedState = _objectWithoutPropertiesLoose(state, _excluded);
|
|
2217
|
-
this.compiledMasks.forEach((m, mi) => m.state = compiledMasks[mi]);
|
|
2218
|
-
if (currentMaskRef != null) {
|
|
2219
|
-
this.currentMask = currentMaskRef;
|
|
2220
|
-
this.currentMask.state = currentMask;
|
|
2221
|
-
}
|
|
2222
|
-
super.state = maskedState;
|
|
2223
|
-
}
|
|
2224
|
-
extractInput() {
|
|
2225
|
-
return this.currentMask ? this.currentMask.extractInput(...arguments) : '';
|
|
2226
|
-
}
|
|
2227
|
-
extractTail() {
|
|
2228
|
-
return this.currentMask ? this.currentMask.extractTail(...arguments) : super.extractTail(...arguments);
|
|
2229
|
-
}
|
|
2230
|
-
doCommit() {
|
|
2231
|
-
if (this.currentMask) this.currentMask.doCommit();
|
|
2232
|
-
super.doCommit();
|
|
2233
|
-
}
|
|
2234
|
-
nearestInputPos() {
|
|
2235
|
-
return this.currentMask ? this.currentMask.nearestInputPos(...arguments) : super.nearestInputPos(...arguments);
|
|
2236
|
-
}
|
|
2237
|
-
get overwrite() {
|
|
2238
|
-
return this.currentMask ? this.currentMask.overwrite : super.overwrite;
|
|
2239
|
-
}
|
|
2240
|
-
set overwrite(overwrite) {
|
|
2241
|
-
console.warn('"overwrite" option is not available in dynamic mask, use this option in siblings');
|
|
2242
|
-
}
|
|
2243
|
-
get eager() {
|
|
2244
|
-
return this.currentMask ? this.currentMask.eager : super.eager;
|
|
2245
|
-
}
|
|
2246
|
-
set eager(eager) {
|
|
2247
|
-
console.warn('"eager" option is not available in dynamic mask, use this option in siblings');
|
|
2248
|
-
}
|
|
2249
|
-
get skipInvalid() {
|
|
2250
|
-
return this.currentMask ? this.currentMask.skipInvalid : super.skipInvalid;
|
|
2251
|
-
}
|
|
2252
|
-
set skipInvalid(skipInvalid) {
|
|
2253
|
-
if (this.isInitialized || skipInvalid !== Masked.DEFAULTS.skipInvalid) {
|
|
2254
|
-
console.warn('"skipInvalid" option is not available in dynamic mask, use this option in siblings');
|
|
2255
|
-
}
|
|
2256
|
-
}
|
|
2257
|
-
maskEquals(mask) {
|
|
2258
|
-
return Array.isArray(mask) && this.compiledMasks.every((m, mi) => {
|
|
2259
|
-
if (!mask[mi]) return;
|
|
2260
|
-
const _mask$mi = mask[mi],
|
|
2261
|
-
{
|
|
2262
|
-
mask: oldMask
|
|
2263
|
-
} = _mask$mi,
|
|
2264
|
-
restOpts = _objectWithoutPropertiesLoose(_mask$mi, _excluded2);
|
|
2265
|
-
return objectIncludes(m, restOpts) && m.maskEquals(oldMask);
|
|
2266
|
-
});
|
|
2267
|
-
}
|
|
2268
|
-
typedValueEquals(value) {
|
|
2269
|
-
var _this$currentMask5;
|
|
2270
|
-
return Boolean((_this$currentMask5 = this.currentMask) === null || _this$currentMask5 === void 0 ? void 0 : _this$currentMask5.typedValueEquals(value));
|
|
2271
|
-
}
|
|
2272
|
-
}
|
|
2273
|
-
MaskedDynamic.DEFAULTS = {
|
|
2274
|
-
dispatch: (appended, masked, flags, tail) => {
|
|
2275
|
-
if (!masked.compiledMasks.length) return;
|
|
2276
|
-
const inputValue = masked.rawInputValue;
|
|
2277
|
-
const inputs = masked.compiledMasks.map((m, index) => {
|
|
2278
|
-
const isCurrent = masked.currentMask === m;
|
|
2279
|
-
const startInputPos = isCurrent ? m.value.length : m.nearestInputPos(m.value.length, DIRECTION.FORCE_LEFT);
|
|
2280
|
-
if (m.rawInputValue !== inputValue) {
|
|
2281
|
-
m.reset();
|
|
2282
|
-
m.append(inputValue, {
|
|
2283
|
-
raw: true
|
|
2284
|
-
});
|
|
2285
|
-
} else if (!isCurrent) {
|
|
2286
|
-
m.remove(startInputPos);
|
|
2287
|
-
}
|
|
2288
|
-
m.append(appended, masked.currentMaskFlags(flags));
|
|
2289
|
-
m.appendTail(tail);
|
|
2290
|
-
return {
|
|
2291
|
-
index,
|
|
2292
|
-
weight: m.rawInputValue.length,
|
|
2293
|
-
totalInputPositions: m.totalInputPositions(0, Math.max(startInputPos, m.nearestInputPos(m.value.length, DIRECTION.FORCE_LEFT)))
|
|
2294
|
-
};
|
|
2295
|
-
});
|
|
2296
|
-
inputs.sort((i1, i2) => i2.weight - i1.weight || i2.totalInputPositions - i1.totalInputPositions);
|
|
2297
|
-
return masked.compiledMasks[inputs[0].index];
|
|
2298
|
-
}
|
|
2299
|
-
};
|
|
2300
|
-
IMask.MaskedDynamic = MaskedDynamic;
|
|
2301
|
-
|
|
2302
|
-
const PIPE_TYPE = {
|
|
2303
|
-
MASKED: 'value',
|
|
2304
|
-
UNMASKED: 'unmaskedValue',
|
|
2305
|
-
TYPED: 'typedValue'
|
|
2306
|
-
};
|
|
2307
|
-
function createPipe(mask) {
|
|
2308
|
-
let from = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : PIPE_TYPE.MASKED;
|
|
2309
|
-
let to = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : PIPE_TYPE.MASKED;
|
|
2310
|
-
const masked = createMask(mask);
|
|
2311
|
-
return value => masked.runIsolated(m => {
|
|
2312
|
-
m[from] = value;
|
|
2313
|
-
return m[to];
|
|
2314
|
-
});
|
|
2315
|
-
}
|
|
2316
|
-
function pipe(value) {
|
|
2317
|
-
for (var _len = arguments.length, pipeArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
2318
|
-
pipeArgs[_key - 1] = arguments[_key];
|
|
3011
|
+
this._blocks.length = state._blocks.length;
|
|
3012
|
+
this.mask = this.mask.slice(0, this._blocks.length);
|
|
3013
|
+
super.state = state;
|
|
2319
3014
|
}
|
|
2320
|
-
return createPipe(...pipeArgs)(value);
|
|
2321
3015
|
}
|
|
2322
|
-
IMask.
|
|
2323
|
-
IMask.createPipe = createPipe;
|
|
2324
|
-
IMask.pipe = pipe;
|
|
3016
|
+
IMask.RepeatBlock = RepeatBlock;
|
|
2325
3017
|
|
|
2326
3018
|
try {
|
|
2327
3019
|
globalThis.IMask = IMask;
|
|
2328
|
-
} catch
|
|
3020
|
+
} catch {}
|
|
2329
3021
|
|
|
2330
3022
|
var maskElementList = [].slice.call(document.querySelectorAll('[data-mask]'));
|
|
2331
3023
|
maskElementList.map(function (maskEl) {
|
|
@@ -3869,8 +4561,8 @@
|
|
|
3869
4561
|
});
|
|
3870
4562
|
|
|
3871
4563
|
/*!
|
|
3872
|
-
* Bootstrap v5.3.
|
|
3873
|
-
* Copyright 2011-
|
|
4564
|
+
* Bootstrap v5.3.3 (https://getbootstrap.com/)
|
|
4565
|
+
* Copyright 2011-2024 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
|
3874
4566
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
3875
4567
|
*/
|
|
3876
4568
|
const elementMap = new Map();
|
|
@@ -4376,7 +5068,7 @@
|
|
|
4376
5068
|
}
|
|
4377
5069
|
}
|
|
4378
5070
|
}
|
|
4379
|
-
const VERSION = '5.3.
|
|
5071
|
+
const VERSION = '5.3.3';
|
|
4380
5072
|
class BaseComponent extends Config {
|
|
4381
5073
|
constructor(element, config) {
|
|
4382
5074
|
super();
|
|
@@ -4435,7 +5127,7 @@
|
|
|
4435
5127
|
}
|
|
4436
5128
|
selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null;
|
|
4437
5129
|
}
|
|
4438
|
-
return parseSelector(
|
|
5130
|
+
return selector ? selector.split(',').map(sel => parseSelector(sel)).join(',') : null;
|
|
4439
5131
|
};
|
|
4440
5132
|
const SelectorEngine = {
|
|
4441
5133
|
find(selector, element = document.documentElement) {
|
|
@@ -6196,7 +6888,10 @@
|
|
|
6196
6888
|
br: [],
|
|
6197
6889
|
col: [],
|
|
6198
6890
|
code: [],
|
|
6891
|
+
dd: [],
|
|
6199
6892
|
div: [],
|
|
6893
|
+
dl: [],
|
|
6894
|
+
dt: [],
|
|
6200
6895
|
em: [],
|
|
6201
6896
|
hr: [],
|
|
6202
6897
|
h1: [],
|
|
@@ -7096,7 +7791,7 @@
|
|
|
7096
7791
|
const CLASS_DROPDOWN = 'dropdown';
|
|
7097
7792
|
const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
|
|
7098
7793
|
const SELECTOR_DROPDOWN_MENU = '.dropdown-menu';
|
|
7099
|
-
const NOT_SELECTOR_DROPDOWN_TOGGLE =
|
|
7794
|
+
const NOT_SELECTOR_DROPDOWN_TOGGLE = `:not(${SELECTOR_DROPDOWN_TOGGLE})`;
|
|
7100
7795
|
const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]';
|
|
7101
7796
|
const SELECTOR_OUTER = '.nav-item, .list-group-item';
|
|
7102
7797
|
const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`;
|
|
@@ -7513,7 +8208,13 @@
|
|
|
7513
8208
|
|
|
7514
8209
|
var toastsTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="toast"]'));
|
|
7515
8210
|
toastsTriggerList.map(function (toastTriggerEl) {
|
|
7516
|
-
|
|
8211
|
+
if (!toastTriggerEl.hasAttribute('data-bs-target')) {
|
|
8212
|
+
return;
|
|
8213
|
+
}
|
|
8214
|
+
var toastEl = new Toast(toastTriggerEl.getAttribute('data-bs-target'));
|
|
8215
|
+
toastTriggerEl.addEventListener('click', function () {
|
|
8216
|
+
toastEl.show();
|
|
8217
|
+
});
|
|
7517
8218
|
});
|
|
7518
8219
|
|
|
7519
8220
|
var prefix = 'tblr-';
|