@haiilo/catalyst 10.2.0 → 10.4.0
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/dist/catalyst/assets/fonts/Lato-Black.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-Black.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Black.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-BlackItalic.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-BlackItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-BlackItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Bold.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-Bold.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Bold.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-BoldItalic.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-BoldItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-BoldItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Hairline.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-Hairline.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Hairline.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-HairlineItalic.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-HairlineItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-HairlineItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Heavy.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-Heavy.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Heavy.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-HeavyItalic.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-HeavyItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-HeavyItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Italic.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-Italic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Italic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Light.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-Light.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Light.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-LightItalic.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-LightItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-LightItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Medium.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-Medium.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Medium.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-MediumItalic.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-MediumItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-MediumItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Regular.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-Regular.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Regular.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Semibold.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-Semibold.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Semibold.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-SemiboldItalic.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-SemiboldItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-SemiboldItalic.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-Thin.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-Thin.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-Thin.woff2 +0 -0
- package/dist/catalyst/assets/fonts/Lato-ThinItalic.ttf +0 -0
- package/dist/catalyst/assets/fonts/Lato-ThinItalic.woff +0 -0
- package/dist/catalyst/assets/fonts/Lato-ThinItalic.woff2 +0 -0
- package/dist/catalyst/catalyst.css +10 -1
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/index.esm.js +1 -1
- package/dist/catalyst/p-81800b65.js +2 -0
- package/dist/catalyst/p-81800b65.js.map +1 -0
- package/dist/catalyst/p-8a1d505d.entry.js +10 -0
- package/dist/catalyst/p-8a1d505d.entry.js.map +1 -0
- package/dist/catalyst/scss/core/_form.scss +12 -3
- package/dist/cjs/{cat-alert_26.cjs.entry.js → cat-alert_28.cjs.entry.js} +2293 -128
- package/dist/cjs/cat-alert_28.cjs.entry.js.map +1 -0
- package/dist/cjs/catalyst.cjs.js +1 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{of-a6e7c491.js → of-45281229.js} +34 -19
- package/dist/cjs/of-45281229.js.map +1 -0
- package/dist/collection/assets/fonts/Lato-Black.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-Black.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Black.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-BlackItalic.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-BlackItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-BlackItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Bold.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-Bold.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Bold.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-BoldItalic.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-BoldItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-BoldItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Hairline.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-Hairline.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Hairline.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-HairlineItalic.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-HairlineItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-HairlineItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Heavy.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-Heavy.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Heavy.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-HeavyItalic.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-HeavyItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-HeavyItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Italic.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-Italic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Italic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Light.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-Light.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Light.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-LightItalic.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-LightItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-LightItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Medium.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-Medium.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Medium.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-MediumItalic.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-MediumItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-MediumItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Regular.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-Regular.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Regular.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Semibold.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-Semibold.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Semibold.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-SemiboldItalic.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-SemiboldItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-SemiboldItalic.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-Thin.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-Thin.woff +0 -0
- package/dist/collection/assets/fonts/Lato-Thin.woff2 +0 -0
- package/dist/collection/assets/fonts/Lato-ThinItalic.ttf +0 -0
- package/dist/collection/assets/fonts/Lato-ThinItalic.woff +0 -0
- package/dist/collection/assets/fonts/Lato-ThinItalic.woff2 +0 -0
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/cat-alert/cat-alert.spec.js +2 -9
- package/dist/collection/components/cat-alert/cat-alert.spec.js.map +1 -1
- package/dist/collection/components/cat-avatar/cat-avatar.spec.js +3 -7
- package/dist/collection/components/cat-avatar/cat-avatar.spec.js.map +1 -1
- package/dist/collection/components/cat-badge/cat-badge.spec.js +2 -6
- package/dist/collection/components/cat-badge/cat-badge.spec.js.map +1 -1
- package/dist/collection/components/cat-button/cat-button.css +29 -0
- package/dist/collection/components/cat-button/cat-button.spec.js +1 -1
- package/dist/collection/components/cat-button/cat-button.spec.js.map +1 -1
- package/dist/collection/components/cat-button-group/cat-button-group.spec.js +2 -6
- package/dist/collection/components/cat-button-group/cat-button-group.spec.js.map +1 -1
- package/dist/collection/components/cat-card/cat-card.spec.js +2 -6
- package/dist/collection/components/cat-card/cat-card.spec.js.map +1 -1
- package/dist/collection/components/cat-checkbox/cat-checkbox.spec.js +2 -17
- package/dist/collection/components/cat-checkbox/cat-checkbox.spec.js.map +1 -1
- package/dist/collection/components/cat-date/cat-date-locale.js +54 -0
- package/dist/collection/components/cat-date/cat-date-locale.js.map +1 -0
- package/dist/collection/components/cat-date/cat-date-math.js +28 -0
- package/dist/collection/components/cat-date/cat-date-math.js.map +1 -0
- package/dist/collection/components/cat-date/cat-date.css +122 -0
- package/dist/collection/components/cat-date/cat-date.e2e.js +11 -0
- package/dist/collection/components/cat-date/cat-date.e2e.js.map +1 -0
- package/dist/collection/components/cat-date/cat-date.js +923 -0
- package/dist/collection/components/cat-date/cat-date.js.map +1 -0
- package/dist/collection/components/cat-date/cat-date.spec.js +16 -0
- package/dist/collection/components/cat-date/cat-date.spec.js.map +1 -0
- package/dist/collection/components/cat-datepicker/cat-datepicker.js +3 -3
- package/dist/collection/components/cat-datepicker/cat-datepicker.spec.js +3 -8
- package/dist/collection/components/cat-datepicker/cat-datepicker.spec.js.map +1 -1
- package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.js +2 -2
- package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.spec.js +2 -8
- package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.spec.js.map +1 -1
- package/dist/collection/components/cat-dropdown/cat-dropdown.js +100 -30
- package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -1
- package/dist/collection/components/cat-dropdown/cat-dropdown.spec.js +2 -8
- package/dist/collection/components/cat-dropdown/cat-dropdown.spec.js.map +1 -1
- package/dist/collection/components/cat-form-group/cat-form-group.js +1 -1
- package/dist/collection/components/cat-form-group/cat-form-group.spec.js +2 -6
- package/dist/collection/components/cat-form-group/cat-form-group.spec.js.map +1 -1
- package/dist/collection/components/cat-form-hint/cat-form-hint.spec.js +1 -1
- package/dist/collection/components/cat-form-hint/cat-form-hint.spec.js.map +1 -1
- package/dist/collection/components/cat-icon/cat-icon-registry.js +27 -15
- package/dist/collection/components/cat-icon/cat-icon-registry.js.map +1 -1
- package/dist/collection/components/cat-icon/cat-icon.js +1 -1
- package/dist/collection/components/cat-icon/cat-icon.spec.js +1 -1
- package/dist/collection/components/cat-icon/cat-icon.spec.js.map +1 -1
- package/dist/collection/components/cat-input/cat-input.css +15 -0
- package/dist/collection/components/cat-input/cat-input.js +44 -6
- package/dist/collection/components/cat-input/cat-input.js.map +1 -1
- package/dist/collection/components/cat-input/cat-input.spec.js +2 -23
- package/dist/collection/components/cat-input/cat-input.spec.js.map +1 -1
- package/dist/collection/components/cat-pagination/cat-pagination.js +2 -2
- package/dist/collection/components/cat-pagination/cat-pagination.spec.js +2 -18
- package/dist/collection/components/cat-pagination/cat-pagination.spec.js.map +1 -1
- package/dist/collection/components/cat-radio/cat-radio.js +1 -1
- package/dist/collection/components/cat-radio/cat-radio.spec.js +3 -13
- package/dist/collection/components/cat-radio/cat-radio.spec.js.map +1 -1
- package/dist/collection/components/cat-radio-group/cat-radio-group.js +1 -1
- package/dist/collection/components/cat-radio-group/cat-radio-group.spec.js +2 -8
- package/dist/collection/components/cat-radio-group/cat-radio-group.spec.js.map +1 -1
- package/dist/collection/components/cat-scrollable/cat-scrollable.js +3 -3
- package/dist/collection/components/cat-scrollable/cat-scrollable.spec.js +2 -13
- package/dist/collection/components/cat-scrollable/cat-scrollable.spec.js.map +1 -1
- package/dist/collection/components/cat-select/cat-select.js +4 -4
- package/dist/collection/components/cat-select/cat-select.spec.js +2 -28
- package/dist/collection/components/cat-select/cat-select.spec.js.map +1 -1
- package/dist/collection/components/cat-select-demo/cat-select-demo.js +1 -1
- package/dist/collection/components/cat-select-demo/cat-select-demo.js.map +1 -1
- package/dist/collection/components/cat-skeleton/cat-skeleton.js +1 -1
- package/dist/collection/components/cat-skeleton/cat-skeleton.spec.js +2 -6
- package/dist/collection/components/cat-skeleton/cat-skeleton.spec.js.map +1 -1
- package/dist/collection/components/cat-spinner/cat-spinner.js +2 -2
- package/dist/collection/components/cat-spinner/cat-spinner.spec.js +1 -1
- package/dist/collection/components/cat-spinner/cat-spinner.spec.js.map +1 -1
- package/dist/collection/components/cat-tab/cat-tab.js +1 -1
- package/dist/collection/components/cat-tab/cat-tab.spec.js +2 -5
- package/dist/collection/components/cat-tab/cat-tab.spec.js.map +1 -1
- package/dist/collection/components/cat-tabs/cat-tabs.js +1 -1
- package/dist/collection/components/cat-tabs/cat-tabs.spec.js +2 -5
- package/dist/collection/components/cat-tabs/cat-tabs.spec.js.map +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.js +3 -3
- package/dist/collection/components/cat-textarea/cat-textarea.spec.js +2 -21
- package/dist/collection/components/cat-textarea/cat-textarea.spec.js.map +1 -1
- package/dist/collection/components/cat-time/cat-time-locale.js +15 -0
- package/dist/collection/components/cat-time/cat-time-locale.js.map +1 -0
- package/dist/collection/components/cat-time/cat-time-math.js +28 -0
- package/dist/collection/components/cat-time/cat-time-math.js.map +1 -0
- package/dist/collection/components/cat-time/cat-time.css +41 -0
- package/dist/collection/components/cat-time/cat-time.e2e.js +11 -0
- package/dist/collection/components/cat-time/cat-time.e2e.js.map +1 -0
- package/dist/collection/components/cat-time/cat-time.js +801 -0
- package/dist/collection/components/cat-time/cat-time.js.map +1 -0
- package/dist/collection/components/cat-time/cat-time.spec.js +16 -0
- package/dist/collection/components/cat-time/cat-time.spec.js.map +1 -0
- package/dist/collection/components/cat-toggle/cat-toggle.js +1 -1
- package/dist/collection/components/cat-toggle/cat-toggle.spec.js +2 -10
- package/dist/collection/components/cat-toggle/cat-toggle.spec.js.map +1 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.js +2 -2
- package/dist/collection/components/cat-tooltip/cat-tooltip.spec.js +1 -9
- package/dist/collection/components/cat-tooltip/cat-tooltip.spec.js.map +1 -1
- package/dist/collection/scss/core/_form.scss +12 -3
- package/dist/components/cat-button2.js +1 -1
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-date.d.ts +11 -0
- package/dist/components/cat-date.js +469 -0
- package/dist/components/cat-date.js.map +1 -0
- package/dist/components/cat-datepicker-inline.js +2 -2
- package/dist/components/cat-datepicker.js +2 -2
- package/dist/components/cat-dropdown2.js +35 -30
- package/dist/components/cat-dropdown2.js.map +1 -1
- package/dist/components/cat-form-group.js +1 -1
- package/dist/components/cat-icon-registry.js +33 -18
- package/dist/components/cat-icon-registry.js.map +1 -1
- package/dist/components/cat-icon2.js +1 -1
- package/dist/components/cat-input2.js +1572 -6
- package/dist/components/cat-input2.js.map +1 -1
- package/dist/components/cat-pagination.js +2 -2
- package/dist/components/cat-radio-group.js +1 -1
- package/dist/components/cat-radio.js +1 -1
- package/dist/components/cat-scrollable2.js +3 -3
- package/dist/components/cat-select-demo.js +1 -1
- package/dist/components/cat-select-demo.js.map +1 -1
- package/dist/components/cat-skeleton2.js +1 -1
- package/dist/components/cat-spinner2.js +2 -2
- package/dist/components/cat-tab.js +1 -1
- package/dist/components/cat-tabs.js +1 -1
- package/dist/components/cat-textarea.js +3 -3
- package/dist/components/cat-time.d.ts +11 -0
- package/dist/components/cat-time.js +303 -0
- package/dist/components/cat-time.js.map +1 -0
- package/dist/components/cat-toggle.js +1 -1
- package/dist/components/cat-tooltip.js +2 -2
- package/dist/esm/{cat-alert_26.entry.js → cat-alert_28.entry.js} +2293 -130
- package/dist/esm/cat-alert_28.entry.js.map +1 -0
- package/dist/esm/catalyst.js +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{of-d37c1933.js → of-19888f3b.js} +34 -19
- package/dist/esm/of-19888f3b.js.map +1 -0
- package/dist/types/components/cat-date/cat-date-locale.d.ts +24 -0
- package/dist/types/components/cat-date/cat-date-math.d.ts +7 -0
- package/dist/types/components/cat-date/cat-date.d.ts +180 -0
- package/dist/types/components/cat-dropdown/cat-dropdown.d.ts +9 -3
- package/dist/types/components/cat-input/cat-input.d.ts +9 -2
- package/dist/types/components/cat-time/cat-time-locale.d.ts +6 -0
- package/dist/types/components/cat-time/cat-time-math.d.ts +3 -0
- package/dist/types/components/cat-time/cat-time.d.ts +168 -0
- package/dist/types/components.d.ts +551 -8
- package/package.json +7 -5
- package/dist/catalyst/p-37905c93.entry.js +0 -10
- package/dist/catalyst/p-37905c93.entry.js.map +0 -1
- package/dist/catalyst/p-8fc7b0f0.js +0 -2
- package/dist/catalyst/p-8fc7b0f0.js.map +0 -1
- package/dist/cjs/cat-alert_26.cjs.entry.js.map +0 -1
- package/dist/cjs/of-a6e7c491.js.map +0 -1
- package/dist/esm/cat-alert_26.entry.js.map +0 -1
- package/dist/esm/of-d37c1933.js.map +0 -1
|
@@ -7,7 +7,1564 @@ import { d as defineCustomElement$3 } from './cat-button2.js';
|
|
|
7
7
|
import { d as defineCustomElement$2 } from './cat-icon2.js';
|
|
8
8
|
import { d as defineCustomElement$1 } from './cat-spinner2.js';
|
|
9
9
|
|
|
10
|
-
const catInputCss = ".hint-wrapper{flex:0 1 auto;display:flex;gap:0.5rem}.hint-section{flex:1 1 auto;display:flex;flex-direction:column;gap:0.25rem;color:rgb(var(--cat-font-color-muted, 81, 92, 108));font-size:0.875rem;line-height:1.125rem}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){margin:0 !important}.cat-bg-primary{background-color:rgb(var(--cat-primary-bg, 0, 129, 148)) !important;color:rgb(var(--cat-primary-fill, 255, 255, 255)) !important;--cat-primary-text:var(--cat-primary-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-primary-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-primary-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-bg-primary-hover{transition:background-color 125ms, color 125ms}.cat-bg-primary-hover:hover{background-color:rgb(var(--cat-primary-bg-hover, 1, 115, 132)) !important;color:rgb(var(--cat-primary-fill-hover, 255, 255, 255)) !important;--cat-primary-text:var(--cat-primary-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-primary-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-primary-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-text-primary,.cat-link-primary{color:rgb(var(--cat-primary-text, 0, 129, 148)) !important}.cat-link-primary,.cat-text-primary-hover{transition:color 125ms}.cat-link-primary:hover,.cat-text-primary-hover:hover{color:rgb(var(--cat-primary-text-hover, 1, 115, 132)) !important}.cat-link-primary:active,.cat-text-primary-hover:active{color:rgb(var(--cat-primary-text-active, 2, 99, 113)) !important}.cat-bg-primaryInverted{background-color:#93b4f2 !important;color:black !important;--cat-primary-text:0, 0, 0;--cat-primary-text-hover:0, 0, 0;--cat-primary-text-active:0, 0, 0;--cat-link-decoration:underline}.cat-bg-primaryInverted-hover{transition:background-color 125ms, color 125ms}.cat-bg-primaryInverted-hover:hover{background-color:#93b4f2 !important;color:black !important;--cat-primary-text:0, 0, 0;--cat-primary-text-hover:0, 0, 0;--cat-primary-text-active:0, 0, 0;--cat-link-decoration:underline}.cat-text-primaryInverted,.cat-link-primaryInverted{color:#93b4f2 !important}.cat-link-primaryInverted,.cat-text-primaryInverted-hover{transition:color 125ms}.cat-link-primaryInverted:hover,.cat-text-primaryInverted-hover:hover{color:#93b4f2 !important}.cat-link-primaryInverted:active,.cat-text-primaryInverted-hover:active{color:#93b4f2 !important}.cat-bg-secondary{background-color:rgb(var(--cat-secondary-bg, 105, 118, 135)) !important;color:rgb(var(--cat-secondary-fill, 255, 255, 255)) !important;--cat-primary-text:var(--cat-secondary-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-secondary-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-secondary-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-bg-secondary-hover{transition:background-color 125ms, color 125ms}.cat-bg-secondary-hover:hover{background-color:rgb(var(--cat-secondary-bg-hover, 105, 118, 135)) !important;color:rgb(var(--cat-secondary-fill-hover, 255, 255, 255)) !important;--cat-primary-text:var(--cat-secondary-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-secondary-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-secondary-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-text-secondary,.cat-link-secondary{color:rgb(var(--cat-secondary-text, 0, 0, 0)) !important}.cat-link-secondary,.cat-text-secondary-hover{transition:color 125ms}.cat-link-secondary:hover,.cat-text-secondary-hover:hover{color:rgb(var(--cat-secondary-text-hover, 0, 0, 0)) !important}.cat-link-secondary:active,.cat-text-secondary-hover:active{color:rgb(var(--cat-secondary-text-active, 0, 0, 0)) !important}.cat-bg-secondaryInverted{background-color:#697687 !important;color:black !important;--cat-primary-text:0, 0, 0;--cat-primary-text-hover:0, 0, 0;--cat-primary-text-active:0, 0, 0;--cat-link-decoration:underline}.cat-bg-secondaryInverted-hover{transition:background-color 125ms, color 125ms}.cat-bg-secondaryInverted-hover:hover{background-color:#697687 !important;color:black !important;--cat-primary-text:0, 0, 0;--cat-primary-text-hover:0, 0, 0;--cat-primary-text-active:0, 0, 0;--cat-link-decoration:underline}.cat-text-secondaryInverted,.cat-link-secondaryInverted{color:white !important}.cat-link-secondaryInverted,.cat-text-secondaryInverted-hover{transition:color 125ms}.cat-link-secondaryInverted:hover,.cat-text-secondaryInverted-hover:hover{color:white !important}.cat-link-secondaryInverted:active,.cat-text-secondaryInverted-hover:active{color:white !important}.cat-bg-info{background-color:rgb(var(--cat-info-bg, 0, 115, 230)) !important;color:rgb(var(--cat-info-fill, 255, 255, 255)) !important;--cat-primary-text:var(--cat-info-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-info-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-info-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-bg-info-hover{transition:background-color 125ms, color 125ms}.cat-bg-info-hover:hover{background-color:rgb(var(--cat-info-bg-hover, 0, 107, 227)) !important;color:rgb(var(--cat-info-fill-hover, 255, 255, 255)) !important;--cat-primary-text:var(--cat-info-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-info-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-info-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-text-info,.cat-link-info{color:rgb(var(--cat-info-text, 0, 115, 230)) !important}.cat-link-info,.cat-text-info-hover{transition:color 125ms}.cat-link-info:hover,.cat-text-info-hover:hover{color:rgb(var(--cat-info-text-hover, 0, 107, 227)) !important}.cat-link-info:active,.cat-text-info-hover:active{color:rgb(var(--cat-info-text-active, 0, 96, 223)) !important}.cat-bg-success{background-color:rgb(var(--cat-success-bg, 0, 132, 88)) !important;color:rgb(var(--cat-success-fill, 255, 255, 255)) !important;--cat-primary-text:var(--cat-success-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-success-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-success-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-bg-success-hover{transition:background-color 125ms, color 125ms}.cat-bg-success-hover:hover{background-color:rgb(var(--cat-success-bg-hover, 0, 117, 78)) !important;color:rgb(var(--cat-success-fill-hover, 255, 255, 255)) !important;--cat-primary-text:var(--cat-success-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-success-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-success-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-text-success,.cat-link-success{color:rgb(var(--cat-success-text, 0, 132, 88)) !important}.cat-link-success,.cat-text-success-hover{transition:color 125ms}.cat-link-success:hover,.cat-text-success-hover:hover{color:rgb(var(--cat-success-text-hover, 0, 117, 78)) !important}.cat-link-success:active,.cat-text-success-hover:active{color:rgb(var(--cat-success-text-active, 0, 105, 70)) !important}.cat-bg-warning{background-color:rgb(var(--cat-warning-bg, 255, 206, 128)) !important;color:rgb(var(--cat-warning-fill, 0, 0, 0)) !important;--cat-primary-text:var(--cat-warning-fill, 0, 0, 0);--cat-primary-text-hover:var(--cat-warning-fill-hover, 0, 0, 0);--cat-primary-text-active:var(--cat-warning-fill-active, 0, 0, 0);--cat-link-decoration:underline}.cat-bg-warning-hover{transition:background-color 125ms, color 125ms}.cat-bg-warning-hover:hover{background-color:rgb(var(--cat-warning-bg-hover, 255, 214, 148)) !important;color:rgb(var(--cat-warning-fill-hover, 0, 0, 0)) !important;--cat-primary-text:var(--cat-warning-fill, 0, 0, 0);--cat-primary-text-hover:var(--cat-warning-fill-hover, 0, 0, 0);--cat-primary-text-active:var(--cat-warning-fill-active, 0, 0, 0);--cat-link-decoration:underline}.cat-text-warning,.cat-link-warning{color:rgb(var(--cat-warning-text, 159, 97, 0)) !important}.cat-link-warning,.cat-text-warning-hover{transition:color 125ms}.cat-link-warning:hover,.cat-text-warning-hover:hover{color:rgb(var(--cat-warning-text-hover, 159, 97, 0)) !important}.cat-link-warning:active,.cat-text-warning-hover:active{color:rgb(var(--cat-warning-text-active, 159, 97, 0)) !important}.cat-bg-danger{background-color:rgb(var(--cat-danger-bg, 217, 52, 13)) !important;color:rgb(var(--cat-danger-fill, 255, 255, 255)) !important;--cat-primary-text:var(--cat-danger-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-danger-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-danger-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-bg-danger-hover{transition:background-color 125ms, color 125ms}.cat-bg-danger-hover:hover{background-color:rgb(var(--cat-danger-bg-hover, 194, 46, 11)) !important;color:rgb(var(--cat-danger-fill-hover, 255, 255, 255)) !important;--cat-primary-text:var(--cat-danger-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-danger-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-danger-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-text-danger,.cat-link-danger{color:rgb(var(--cat-danger-text, 217, 52, 13)) !important}.cat-link-danger,.cat-text-danger-hover{transition:color 125ms}.cat-link-danger:hover,.cat-text-danger-hover:hover{color:rgb(var(--cat-danger-text-hover, 194, 46, 11)) !important}.cat-link-danger:active,.cat-text-danger-hover:active{color:rgb(var(--cat-danger-text-active, 174, 42, 10)) !important}.cat-active{color:rgb(var(--cat-primary-text, 0, 129, 148)) !important}.cat-text-active{color:rgb(var(--cat-primary-text, 0, 129, 148)) !important}.cat-muted{color:rgb(var(--cat-font-color-muted, 81, 92, 108)) !important}.cat-text-muted{color:rgb(var(--cat-font-color-muted, 81, 92, 108)) !important}.cat-bg-muted{background-color:#f2f4f7 !important}.cat-text-reset{color:inherit !important}.cat-link-reset{color:inherit !important;text-decoration:inherit !important}.label{overflow:hidden;word-wrap:break-word;word-break:break-word}.input-field:not(.input-horizontal) .label-container.hidden,.textarea-field:not(.textarea-horizontal) .label-container.hidden,.select-field:not(.select-horizontal) .label-container.hidden{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.label-container{flex-basis:var(--label-size, 33.33%)}.label-container .label-wrapper{display:flex;gap:0.25rem}.label-metadata{display:flex;flex-shrink:0;flex-grow:1;justify-content:space-between;gap:0.25rem;color:rgb(var(--cat-font-color-muted, 81, 92, 108))}.label-optional,.label-character-count{display:inline-flex;align-items:center;max-height:1.25rem;font-size:0.75rem;line-height:1rem}.label-character-count{margin-left:auto}.input-horizontal .label-container.hidden label,.textarea-horizontal .label-container.hidden label,.select-horizontal .label-container.hidden label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.input-horizontal .label-wrapper,.textarea-horizontal .label-wrapper,.select-horizontal .label-wrapper{flex-direction:column}.input-horizontal label,.textarea-horizontal label,.select-horizontal label{min-height:2.5rem;display:inline-flex;align-items:center}.input-horizontal .label-metadata,.textarea-horizontal .label-metadata,.select-horizontal .label-metadata{justify-content:flex-start}.input-horizontal .label-metadata .label-character-count,.textarea-horizontal .label-metadata .label-character-count,.select-horizontal .label-metadata .label-character-count{margin-left:0}:host{display:flex;font-size:0.9375rem;line-height:1.25rem}:host([hidden]){display:none}.input-field,.input-container{display:flex;flex-direction:column;gap:0.5rem;flex:1 1 auto}.input-field.input-horizontal{flex-direction:row;gap:1rem}.input-wrapper{display:flex;align-items:stretch;gap:0.75rem;padding:0 0.75rem;height:2.5rem;overflow:hidden;background:white;border-radius:var(--cat-border-radius-m, 0.25rem);box-shadow:inset 0 0 0 1px rgb(var(--border-color));transition:box-shadow 125ms linear;--border-color:var(--cat-border-color-dark, 215, 219, 224);}.input-wrapper.input-round{border-radius:10rem}.input-wrapper.input-readonly{pointer-events:none}.input-wrapper.input-disabled{background:#f2f4f7;cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 81, 92, 108))}.input-wrapper:not(.input-disabled):hover{box-shadow:inset 0 0 0 1px rgb(var(--border-color)), 0 0 0 1px rgb(var(--border-color))}.input-wrapper:focus-within{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:-1px}.input-wrapper.input-invalid{--border-color:var(--cat-danger-bg, 217, 52, 13), 0.2}.input-wrapper:has(input:-webkit-autofill),.input-wrapper:has(input:-webkit-autofill):hover,.input-wrapper:has(input:-webkit-autofill):focus{background-color:#e8f0fe}.text-prefix,.text-suffix{display:inline-flex;align-items:center;-webkit-user-select:none;-ms-user-select:none;user-select:none;}.text-prefix{border-right:1px solid rgb(var(--cat-border-color-dark, 215, 219, 224));padding-right:0.75rem}.text-suffix{border-left:1px solid rgb(var(--cat-border-color-dark, 215, 219, 224));padding-left:0.75rem}.icon-prefix,.icon-suffix{align-self:center}.input-inner-wrapper{display:flex;align-items:center;position:relative;flex:1 1 auto}input{font:inherit;margin:0;padding:0;width:100%;min-width:0;border:none;outline:none;background:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.input-disabled input{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 81, 92, 108))}input.has-clearable,input.has-toggle-password{padding-right:1.5rem}input.has-clearable.has-toggle-password{padding-right:3.5rem}input::placeholder{color:rgb(var(--cat-font-color-muted, 81, 92, 108))}input:-webkit-autofill,input:-webkit-autofill:hover,input:-webkit-autofill:focus{-webkit-box-shadow:0 0 0 9999px #e8f0fe inset}.clearable{position:absolute;top:calc(50% - 1rem);right:-0.5rem}.toggle-password{position:absolute;top:calc(50% - 1rem);right:-0.5rem}.has-clearable~.toggle-password{right:1.5rem}";
|
|
10
|
+
var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
11
|
+
|
|
12
|
+
var NumeralFormatter = function (numeralDecimalMark,
|
|
13
|
+
numeralIntegerScale,
|
|
14
|
+
numeralDecimalScale,
|
|
15
|
+
numeralThousandsGroupStyle,
|
|
16
|
+
numeralPositiveOnly,
|
|
17
|
+
stripLeadingZeroes,
|
|
18
|
+
prefix,
|
|
19
|
+
signBeforePrefix,
|
|
20
|
+
tailPrefix,
|
|
21
|
+
delimiter) {
|
|
22
|
+
var owner = this;
|
|
23
|
+
|
|
24
|
+
owner.numeralDecimalMark = numeralDecimalMark || '.';
|
|
25
|
+
owner.numeralIntegerScale = numeralIntegerScale > 0 ? numeralIntegerScale : 0;
|
|
26
|
+
owner.numeralDecimalScale = numeralDecimalScale >= 0 ? numeralDecimalScale : 2;
|
|
27
|
+
owner.numeralThousandsGroupStyle = numeralThousandsGroupStyle || NumeralFormatter.groupStyle.thousand;
|
|
28
|
+
owner.numeralPositiveOnly = !!numeralPositiveOnly;
|
|
29
|
+
owner.stripLeadingZeroes = stripLeadingZeroes !== false;
|
|
30
|
+
owner.prefix = (prefix || prefix === '') ? prefix : '';
|
|
31
|
+
owner.signBeforePrefix = !!signBeforePrefix;
|
|
32
|
+
owner.tailPrefix = !!tailPrefix;
|
|
33
|
+
owner.delimiter = (delimiter || delimiter === '') ? delimiter : ',';
|
|
34
|
+
owner.delimiterRE = delimiter ? new RegExp('\\' + delimiter, 'g') : '';
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
NumeralFormatter.groupStyle = {
|
|
38
|
+
thousand: 'thousand',
|
|
39
|
+
lakh: 'lakh',
|
|
40
|
+
wan: 'wan',
|
|
41
|
+
none: 'none'
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
NumeralFormatter.prototype = {
|
|
45
|
+
getRawValue: function (value) {
|
|
46
|
+
return value.replace(this.delimiterRE, '').replace(this.numeralDecimalMark, '.');
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
format: function (value) {
|
|
50
|
+
var owner = this, parts, partSign, partSignAndPrefix, partInteger, partDecimal = '';
|
|
51
|
+
|
|
52
|
+
// strip alphabet letters
|
|
53
|
+
value = value.replace(/[A-Za-z]/g, '')
|
|
54
|
+
// replace the first decimal mark with reserved placeholder
|
|
55
|
+
.replace(owner.numeralDecimalMark, 'M')
|
|
56
|
+
|
|
57
|
+
// strip non numeric letters except minus and "M"
|
|
58
|
+
// this is to ensure prefix has been stripped
|
|
59
|
+
.replace(/[^\dM-]/g, '')
|
|
60
|
+
|
|
61
|
+
// replace the leading minus with reserved placeholder
|
|
62
|
+
.replace(/^\-/, 'N')
|
|
63
|
+
|
|
64
|
+
// strip the other minus sign (if present)
|
|
65
|
+
.replace(/\-/g, '')
|
|
66
|
+
|
|
67
|
+
// replace the minus sign (if present)
|
|
68
|
+
.replace('N', owner.numeralPositiveOnly ? '' : '-')
|
|
69
|
+
|
|
70
|
+
// replace decimal mark
|
|
71
|
+
.replace('M', owner.numeralDecimalMark);
|
|
72
|
+
|
|
73
|
+
// strip any leading zeros
|
|
74
|
+
if (owner.stripLeadingZeroes) {
|
|
75
|
+
value = value.replace(/^(-)?0+(?=\d)/, '$1');
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
partSign = value.slice(0, 1) === '-' ? '-' : '';
|
|
79
|
+
if (typeof owner.prefix != 'undefined') {
|
|
80
|
+
if (owner.signBeforePrefix) {
|
|
81
|
+
partSignAndPrefix = partSign + owner.prefix;
|
|
82
|
+
} else {
|
|
83
|
+
partSignAndPrefix = owner.prefix + partSign;
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
partSignAndPrefix = partSign;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
partInteger = value;
|
|
90
|
+
|
|
91
|
+
if (value.indexOf(owner.numeralDecimalMark) >= 0) {
|
|
92
|
+
parts = value.split(owner.numeralDecimalMark);
|
|
93
|
+
partInteger = parts[0];
|
|
94
|
+
partDecimal = owner.numeralDecimalMark + parts[1].slice(0, owner.numeralDecimalScale);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if(partSign === '-') {
|
|
98
|
+
partInteger = partInteger.slice(1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (owner.numeralIntegerScale > 0) {
|
|
102
|
+
partInteger = partInteger.slice(0, owner.numeralIntegerScale);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
switch (owner.numeralThousandsGroupStyle) {
|
|
106
|
+
case NumeralFormatter.groupStyle.lakh:
|
|
107
|
+
partInteger = partInteger.replace(/(\d)(?=(\d\d)+\d$)/g, '$1' + owner.delimiter);
|
|
108
|
+
|
|
109
|
+
break;
|
|
110
|
+
|
|
111
|
+
case NumeralFormatter.groupStyle.wan:
|
|
112
|
+
partInteger = partInteger.replace(/(\d)(?=(\d{4})+$)/g, '$1' + owner.delimiter);
|
|
113
|
+
|
|
114
|
+
break;
|
|
115
|
+
|
|
116
|
+
case NumeralFormatter.groupStyle.thousand:
|
|
117
|
+
partInteger = partInteger.replace(/(\d)(?=(\d{3})+$)/g, '$1' + owner.delimiter);
|
|
118
|
+
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (owner.tailPrefix) {
|
|
123
|
+
return partSign + partInteger.toString() + (owner.numeralDecimalScale > 0 ? partDecimal.toString() : '') + owner.prefix;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return partSignAndPrefix + partInteger.toString() + (owner.numeralDecimalScale > 0 ? partDecimal.toString() : '');
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
var NumeralFormatter_1 = NumeralFormatter;
|
|
131
|
+
|
|
132
|
+
var DateFormatter = function (datePattern, dateMin, dateMax) {
|
|
133
|
+
var owner = this;
|
|
134
|
+
|
|
135
|
+
owner.date = [];
|
|
136
|
+
owner.blocks = [];
|
|
137
|
+
owner.datePattern = datePattern;
|
|
138
|
+
owner.dateMin = dateMin
|
|
139
|
+
.split('-')
|
|
140
|
+
.reverse()
|
|
141
|
+
.map(function(x) {
|
|
142
|
+
return parseInt(x, 10);
|
|
143
|
+
});
|
|
144
|
+
if (owner.dateMin.length === 2) owner.dateMin.unshift(0);
|
|
145
|
+
|
|
146
|
+
owner.dateMax = dateMax
|
|
147
|
+
.split('-')
|
|
148
|
+
.reverse()
|
|
149
|
+
.map(function(x) {
|
|
150
|
+
return parseInt(x, 10);
|
|
151
|
+
});
|
|
152
|
+
if (owner.dateMax.length === 2) owner.dateMax.unshift(0);
|
|
153
|
+
|
|
154
|
+
owner.initBlocks();
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
DateFormatter.prototype = {
|
|
158
|
+
initBlocks: function () {
|
|
159
|
+
var owner = this;
|
|
160
|
+
owner.datePattern.forEach(function (value) {
|
|
161
|
+
if (value === 'Y') {
|
|
162
|
+
owner.blocks.push(4);
|
|
163
|
+
} else {
|
|
164
|
+
owner.blocks.push(2);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
getISOFormatDate: function () {
|
|
170
|
+
var owner = this,
|
|
171
|
+
date = owner.date;
|
|
172
|
+
|
|
173
|
+
return date[2] ? (
|
|
174
|
+
date[2] + '-' + owner.addLeadingZero(date[1]) + '-' + owner.addLeadingZero(date[0])
|
|
175
|
+
) : '';
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
getBlocks: function () {
|
|
179
|
+
return this.blocks;
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
getValidatedDate: function (value) {
|
|
183
|
+
var owner = this, result = '';
|
|
184
|
+
|
|
185
|
+
value = value.replace(/[^\d]/g, '');
|
|
186
|
+
|
|
187
|
+
owner.blocks.forEach(function (length, index) {
|
|
188
|
+
if (value.length > 0) {
|
|
189
|
+
var sub = value.slice(0, length),
|
|
190
|
+
sub0 = sub.slice(0, 1),
|
|
191
|
+
rest = value.slice(length);
|
|
192
|
+
|
|
193
|
+
switch (owner.datePattern[index]) {
|
|
194
|
+
case 'd':
|
|
195
|
+
if (sub === '00') {
|
|
196
|
+
sub = '01';
|
|
197
|
+
} else if (parseInt(sub0, 10) > 3) {
|
|
198
|
+
sub = '0' + sub0;
|
|
199
|
+
} else if (parseInt(sub, 10) > 31) {
|
|
200
|
+
sub = '31';
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
break;
|
|
204
|
+
|
|
205
|
+
case 'm':
|
|
206
|
+
if (sub === '00') {
|
|
207
|
+
sub = '01';
|
|
208
|
+
} else if (parseInt(sub0, 10) > 1) {
|
|
209
|
+
sub = '0' + sub0;
|
|
210
|
+
} else if (parseInt(sub, 10) > 12) {
|
|
211
|
+
sub = '12';
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
result += sub;
|
|
218
|
+
|
|
219
|
+
// update remaining string
|
|
220
|
+
value = rest;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
return this.getFixedDateString(result);
|
|
225
|
+
},
|
|
226
|
+
|
|
227
|
+
getFixedDateString: function (value) {
|
|
228
|
+
var owner = this, datePattern = owner.datePattern, date = [],
|
|
229
|
+
dayIndex = 0, monthIndex = 0, yearIndex = 0,
|
|
230
|
+
dayStartIndex = 0, monthStartIndex = 0, yearStartIndex = 0,
|
|
231
|
+
day, month, year, fullYearDone = false;
|
|
232
|
+
|
|
233
|
+
// mm-dd || dd-mm
|
|
234
|
+
if (value.length === 4 && datePattern[0].toLowerCase() !== 'y' && datePattern[1].toLowerCase() !== 'y') {
|
|
235
|
+
dayStartIndex = datePattern[0] === 'd' ? 0 : 2;
|
|
236
|
+
monthStartIndex = 2 - dayStartIndex;
|
|
237
|
+
day = parseInt(value.slice(dayStartIndex, dayStartIndex + 2), 10);
|
|
238
|
+
month = parseInt(value.slice(monthStartIndex, monthStartIndex + 2), 10);
|
|
239
|
+
|
|
240
|
+
date = this.getFixedDate(day, month, 0);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// yyyy-mm-dd || yyyy-dd-mm || mm-dd-yyyy || dd-mm-yyyy || dd-yyyy-mm || mm-yyyy-dd
|
|
244
|
+
if (value.length === 8) {
|
|
245
|
+
datePattern.forEach(function (type, index) {
|
|
246
|
+
switch (type) {
|
|
247
|
+
case 'd':
|
|
248
|
+
dayIndex = index;
|
|
249
|
+
break;
|
|
250
|
+
case 'm':
|
|
251
|
+
monthIndex = index;
|
|
252
|
+
break;
|
|
253
|
+
default:
|
|
254
|
+
yearIndex = index;
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
yearStartIndex = yearIndex * 2;
|
|
260
|
+
dayStartIndex = (dayIndex <= yearIndex) ? dayIndex * 2 : (dayIndex * 2 + 2);
|
|
261
|
+
monthStartIndex = (monthIndex <= yearIndex) ? monthIndex * 2 : (monthIndex * 2 + 2);
|
|
262
|
+
|
|
263
|
+
day = parseInt(value.slice(dayStartIndex, dayStartIndex + 2), 10);
|
|
264
|
+
month = parseInt(value.slice(monthStartIndex, monthStartIndex + 2), 10);
|
|
265
|
+
year = parseInt(value.slice(yearStartIndex, yearStartIndex + 4), 10);
|
|
266
|
+
|
|
267
|
+
fullYearDone = value.slice(yearStartIndex, yearStartIndex + 4).length === 4;
|
|
268
|
+
|
|
269
|
+
date = this.getFixedDate(day, month, year);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// mm-yy || yy-mm
|
|
273
|
+
if (value.length === 4 && (datePattern[0] === 'y' || datePattern[1] === 'y')) {
|
|
274
|
+
monthStartIndex = datePattern[0] === 'm' ? 0 : 2;
|
|
275
|
+
yearStartIndex = 2 - monthStartIndex;
|
|
276
|
+
month = parseInt(value.slice(monthStartIndex, monthStartIndex + 2), 10);
|
|
277
|
+
year = parseInt(value.slice(yearStartIndex, yearStartIndex + 2), 10);
|
|
278
|
+
|
|
279
|
+
fullYearDone = value.slice(yearStartIndex, yearStartIndex + 2).length === 2;
|
|
280
|
+
|
|
281
|
+
date = [0, month, year];
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// mm-yyyy || yyyy-mm
|
|
285
|
+
if (value.length === 6 && (datePattern[0] === 'Y' || datePattern[1] === 'Y')) {
|
|
286
|
+
monthStartIndex = datePattern[0] === 'm' ? 0 : 4;
|
|
287
|
+
yearStartIndex = 2 - 0.5 * monthStartIndex;
|
|
288
|
+
month = parseInt(value.slice(monthStartIndex, monthStartIndex + 2), 10);
|
|
289
|
+
year = parseInt(value.slice(yearStartIndex, yearStartIndex + 4), 10);
|
|
290
|
+
|
|
291
|
+
fullYearDone = value.slice(yearStartIndex, yearStartIndex + 4).length === 4;
|
|
292
|
+
|
|
293
|
+
date = [0, month, year];
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
date = owner.getRangeFixedDate(date);
|
|
297
|
+
owner.date = date;
|
|
298
|
+
|
|
299
|
+
var result = date.length === 0 ? value : datePattern.reduce(function (previous, current) {
|
|
300
|
+
switch (current) {
|
|
301
|
+
case 'd':
|
|
302
|
+
return previous + (date[0] === 0 ? '' : owner.addLeadingZero(date[0]));
|
|
303
|
+
case 'm':
|
|
304
|
+
return previous + (date[1] === 0 ? '' : owner.addLeadingZero(date[1]));
|
|
305
|
+
case 'y':
|
|
306
|
+
return previous + (fullYearDone ? owner.addLeadingZeroForYear(date[2], false) : '');
|
|
307
|
+
case 'Y':
|
|
308
|
+
return previous + (fullYearDone ? owner.addLeadingZeroForYear(date[2], true) : '');
|
|
309
|
+
}
|
|
310
|
+
}, '');
|
|
311
|
+
|
|
312
|
+
return result;
|
|
313
|
+
},
|
|
314
|
+
|
|
315
|
+
getRangeFixedDate: function (date) {
|
|
316
|
+
var owner = this,
|
|
317
|
+
datePattern = owner.datePattern,
|
|
318
|
+
dateMin = owner.dateMin || [],
|
|
319
|
+
dateMax = owner.dateMax || [];
|
|
320
|
+
|
|
321
|
+
if (!date.length || (dateMin.length < 3 && dateMax.length < 3)) return date;
|
|
322
|
+
|
|
323
|
+
if (
|
|
324
|
+
datePattern.find(function(x) {
|
|
325
|
+
return x.toLowerCase() === 'y';
|
|
326
|
+
}) &&
|
|
327
|
+
date[2] === 0
|
|
328
|
+
) return date;
|
|
329
|
+
|
|
330
|
+
if (dateMax.length && (dateMax[2] < date[2] || (
|
|
331
|
+
dateMax[2] === date[2] && (dateMax[1] < date[1] || (
|
|
332
|
+
dateMax[1] === date[1] && dateMax[0] < date[0]
|
|
333
|
+
))
|
|
334
|
+
))) return dateMax;
|
|
335
|
+
|
|
336
|
+
if (dateMin.length && (dateMin[2] > date[2] || (
|
|
337
|
+
dateMin[2] === date[2] && (dateMin[1] > date[1] || (
|
|
338
|
+
dateMin[1] === date[1] && dateMin[0] > date[0]
|
|
339
|
+
))
|
|
340
|
+
))) return dateMin;
|
|
341
|
+
|
|
342
|
+
return date;
|
|
343
|
+
},
|
|
344
|
+
|
|
345
|
+
getFixedDate: function (day, month, year) {
|
|
346
|
+
day = Math.min(day, 31);
|
|
347
|
+
month = Math.min(month, 12);
|
|
348
|
+
year = parseInt((year || 0), 10);
|
|
349
|
+
|
|
350
|
+
if ((month < 7 && month % 2 === 0) || (month > 8 && month % 2 === 1)) {
|
|
351
|
+
day = Math.min(day, month === 2 ? (this.isLeapYear(year) ? 29 : 28) : 30);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return [day, month, year];
|
|
355
|
+
},
|
|
356
|
+
|
|
357
|
+
isLeapYear: function (year) {
|
|
358
|
+
return ((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0);
|
|
359
|
+
},
|
|
360
|
+
|
|
361
|
+
addLeadingZero: function (number) {
|
|
362
|
+
return (number < 10 ? '0' : '') + number;
|
|
363
|
+
},
|
|
364
|
+
|
|
365
|
+
addLeadingZeroForYear: function (number, fullYearMode) {
|
|
366
|
+
if (fullYearMode) {
|
|
367
|
+
return (number < 10 ? '000' : (number < 100 ? '00' : (number < 1000 ? '0' : ''))) + number;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
return (number < 10 ? '0' : '') + number;
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
var DateFormatter_1 = DateFormatter;
|
|
375
|
+
|
|
376
|
+
var TimeFormatter = function (timePattern, timeFormat) {
|
|
377
|
+
var owner = this;
|
|
378
|
+
|
|
379
|
+
owner.time = [];
|
|
380
|
+
owner.blocks = [];
|
|
381
|
+
owner.timePattern = timePattern;
|
|
382
|
+
owner.timeFormat = timeFormat;
|
|
383
|
+
owner.initBlocks();
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
TimeFormatter.prototype = {
|
|
387
|
+
initBlocks: function () {
|
|
388
|
+
var owner = this;
|
|
389
|
+
owner.timePattern.forEach(function () {
|
|
390
|
+
owner.blocks.push(2);
|
|
391
|
+
});
|
|
392
|
+
},
|
|
393
|
+
|
|
394
|
+
getISOFormatTime: function () {
|
|
395
|
+
var owner = this,
|
|
396
|
+
time = owner.time;
|
|
397
|
+
|
|
398
|
+
return time[2] ? (
|
|
399
|
+
owner.addLeadingZero(time[0]) + ':' + owner.addLeadingZero(time[1]) + ':' + owner.addLeadingZero(time[2])
|
|
400
|
+
) : '';
|
|
401
|
+
},
|
|
402
|
+
|
|
403
|
+
getBlocks: function () {
|
|
404
|
+
return this.blocks;
|
|
405
|
+
},
|
|
406
|
+
|
|
407
|
+
getTimeFormatOptions: function () {
|
|
408
|
+
var owner = this;
|
|
409
|
+
if (String(owner.timeFormat) === '12') {
|
|
410
|
+
return {
|
|
411
|
+
maxHourFirstDigit: 1,
|
|
412
|
+
maxHours: 12,
|
|
413
|
+
maxMinutesFirstDigit: 5,
|
|
414
|
+
maxMinutes: 60
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
return {
|
|
419
|
+
maxHourFirstDigit: 2,
|
|
420
|
+
maxHours: 23,
|
|
421
|
+
maxMinutesFirstDigit: 5,
|
|
422
|
+
maxMinutes: 60
|
|
423
|
+
};
|
|
424
|
+
},
|
|
425
|
+
|
|
426
|
+
getValidatedTime: function (value) {
|
|
427
|
+
var owner = this, result = '';
|
|
428
|
+
|
|
429
|
+
value = value.replace(/[^\d]/g, '');
|
|
430
|
+
|
|
431
|
+
var timeFormatOptions = owner.getTimeFormatOptions();
|
|
432
|
+
|
|
433
|
+
owner.blocks.forEach(function (length, index) {
|
|
434
|
+
if (value.length > 0) {
|
|
435
|
+
var sub = value.slice(0, length),
|
|
436
|
+
sub0 = sub.slice(0, 1),
|
|
437
|
+
rest = value.slice(length);
|
|
438
|
+
|
|
439
|
+
switch (owner.timePattern[index]) {
|
|
440
|
+
|
|
441
|
+
case 'h':
|
|
442
|
+
if (parseInt(sub0, 10) > timeFormatOptions.maxHourFirstDigit) {
|
|
443
|
+
sub = '0' + sub0;
|
|
444
|
+
} else if (parseInt(sub, 10) > timeFormatOptions.maxHours) {
|
|
445
|
+
sub = timeFormatOptions.maxHours + '';
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
break;
|
|
449
|
+
|
|
450
|
+
case 'm':
|
|
451
|
+
case 's':
|
|
452
|
+
if (parseInt(sub0, 10) > timeFormatOptions.maxMinutesFirstDigit) {
|
|
453
|
+
sub = '0' + sub0;
|
|
454
|
+
} else if (parseInt(sub, 10) > timeFormatOptions.maxMinutes) {
|
|
455
|
+
sub = timeFormatOptions.maxMinutes + '';
|
|
456
|
+
}
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
result += sub;
|
|
461
|
+
|
|
462
|
+
// update remaining string
|
|
463
|
+
value = rest;
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
return this.getFixedTimeString(result);
|
|
468
|
+
},
|
|
469
|
+
|
|
470
|
+
getFixedTimeString: function (value) {
|
|
471
|
+
var owner = this, timePattern = owner.timePattern, time = [],
|
|
472
|
+
secondIndex = 0, minuteIndex = 0, hourIndex = 0,
|
|
473
|
+
secondStartIndex = 0, minuteStartIndex = 0, hourStartIndex = 0,
|
|
474
|
+
second, minute, hour;
|
|
475
|
+
|
|
476
|
+
if (value.length === 6) {
|
|
477
|
+
timePattern.forEach(function (type, index) {
|
|
478
|
+
switch (type) {
|
|
479
|
+
case 's':
|
|
480
|
+
secondIndex = index * 2;
|
|
481
|
+
break;
|
|
482
|
+
case 'm':
|
|
483
|
+
minuteIndex = index * 2;
|
|
484
|
+
break;
|
|
485
|
+
case 'h':
|
|
486
|
+
hourIndex = index * 2;
|
|
487
|
+
break;
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
hourStartIndex = hourIndex;
|
|
492
|
+
minuteStartIndex = minuteIndex;
|
|
493
|
+
secondStartIndex = secondIndex;
|
|
494
|
+
|
|
495
|
+
second = parseInt(value.slice(secondStartIndex, secondStartIndex + 2), 10);
|
|
496
|
+
minute = parseInt(value.slice(minuteStartIndex, minuteStartIndex + 2), 10);
|
|
497
|
+
hour = parseInt(value.slice(hourStartIndex, hourStartIndex + 2), 10);
|
|
498
|
+
|
|
499
|
+
time = this.getFixedTime(hour, minute, second);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if (value.length === 4 && owner.timePattern.indexOf('s') < 0) {
|
|
503
|
+
timePattern.forEach(function (type, index) {
|
|
504
|
+
switch (type) {
|
|
505
|
+
case 'm':
|
|
506
|
+
minuteIndex = index * 2;
|
|
507
|
+
break;
|
|
508
|
+
case 'h':
|
|
509
|
+
hourIndex = index * 2;
|
|
510
|
+
break;
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
hourStartIndex = hourIndex;
|
|
515
|
+
minuteStartIndex = minuteIndex;
|
|
516
|
+
|
|
517
|
+
second = 0;
|
|
518
|
+
minute = parseInt(value.slice(minuteStartIndex, minuteStartIndex + 2), 10);
|
|
519
|
+
hour = parseInt(value.slice(hourStartIndex, hourStartIndex + 2), 10);
|
|
520
|
+
|
|
521
|
+
time = this.getFixedTime(hour, minute, second);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
owner.time = time;
|
|
525
|
+
|
|
526
|
+
return time.length === 0 ? value : timePattern.reduce(function (previous, current) {
|
|
527
|
+
switch (current) {
|
|
528
|
+
case 's':
|
|
529
|
+
return previous + owner.addLeadingZero(time[2]);
|
|
530
|
+
case 'm':
|
|
531
|
+
return previous + owner.addLeadingZero(time[1]);
|
|
532
|
+
case 'h':
|
|
533
|
+
return previous + owner.addLeadingZero(time[0]);
|
|
534
|
+
}
|
|
535
|
+
}, '');
|
|
536
|
+
},
|
|
537
|
+
|
|
538
|
+
getFixedTime: function (hour, minute, second) {
|
|
539
|
+
second = Math.min(parseInt(second || 0, 10), 60);
|
|
540
|
+
minute = Math.min(minute, 60);
|
|
541
|
+
hour = Math.min(hour, 60);
|
|
542
|
+
|
|
543
|
+
return [hour, minute, second];
|
|
544
|
+
},
|
|
545
|
+
|
|
546
|
+
addLeadingZero: function (number) {
|
|
547
|
+
return (number < 10 ? '0' : '') + number;
|
|
548
|
+
}
|
|
549
|
+
};
|
|
550
|
+
|
|
551
|
+
var TimeFormatter_1 = TimeFormatter;
|
|
552
|
+
|
|
553
|
+
var PhoneFormatter = function (formatter, delimiter) {
|
|
554
|
+
var owner = this;
|
|
555
|
+
|
|
556
|
+
owner.delimiter = (delimiter || delimiter === '') ? delimiter : ' ';
|
|
557
|
+
owner.delimiterRE = delimiter ? new RegExp('\\' + delimiter, 'g') : '';
|
|
558
|
+
|
|
559
|
+
owner.formatter = formatter;
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
PhoneFormatter.prototype = {
|
|
563
|
+
setFormatter: function (formatter) {
|
|
564
|
+
this.formatter = formatter;
|
|
565
|
+
},
|
|
566
|
+
|
|
567
|
+
format: function (phoneNumber) {
|
|
568
|
+
var owner = this;
|
|
569
|
+
|
|
570
|
+
owner.formatter.clear();
|
|
571
|
+
|
|
572
|
+
// only keep number and +
|
|
573
|
+
phoneNumber = phoneNumber.replace(/[^\d+]/g, '');
|
|
574
|
+
|
|
575
|
+
// strip non-leading +
|
|
576
|
+
phoneNumber = phoneNumber.replace(/^\+/, 'B').replace(/\+/g, '').replace('B', '+');
|
|
577
|
+
|
|
578
|
+
// strip delimiter
|
|
579
|
+
phoneNumber = phoneNumber.replace(owner.delimiterRE, '');
|
|
580
|
+
|
|
581
|
+
var result = '', current, validated = false;
|
|
582
|
+
|
|
583
|
+
for (var i = 0, iMax = phoneNumber.length; i < iMax; i++) {
|
|
584
|
+
current = owner.formatter.inputDigit(phoneNumber.charAt(i));
|
|
585
|
+
|
|
586
|
+
// has ()- or space inside
|
|
587
|
+
if (/[\s()-]/g.test(current)) {
|
|
588
|
+
result = current;
|
|
589
|
+
|
|
590
|
+
validated = true;
|
|
591
|
+
} else {
|
|
592
|
+
if (!validated) {
|
|
593
|
+
result = current;
|
|
594
|
+
}
|
|
595
|
+
// else: over length input
|
|
596
|
+
// it turns to invalid number again
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
// strip ()
|
|
601
|
+
// e.g. US: 7161234567 returns (716) 123-4567
|
|
602
|
+
result = result.replace(/[()]/g, '');
|
|
603
|
+
// replace library delimiter with user customized delimiter
|
|
604
|
+
result = result.replace(/[\s-]/g, owner.delimiter);
|
|
605
|
+
|
|
606
|
+
return result;
|
|
607
|
+
}
|
|
608
|
+
};
|
|
609
|
+
|
|
610
|
+
var PhoneFormatter_1 = PhoneFormatter;
|
|
611
|
+
|
|
612
|
+
var CreditCardDetector = {
|
|
613
|
+
blocks: {
|
|
614
|
+
uatp: [4, 5, 6],
|
|
615
|
+
amex: [4, 6, 5],
|
|
616
|
+
diners: [4, 6, 4],
|
|
617
|
+
discover: [4, 4, 4, 4],
|
|
618
|
+
mastercard: [4, 4, 4, 4],
|
|
619
|
+
dankort: [4, 4, 4, 4],
|
|
620
|
+
instapayment: [4, 4, 4, 4],
|
|
621
|
+
jcb15: [4, 6, 5],
|
|
622
|
+
jcb: [4, 4, 4, 4],
|
|
623
|
+
maestro: [4, 4, 4, 4],
|
|
624
|
+
visa: [4, 4, 4, 4],
|
|
625
|
+
mir: [4, 4, 4, 4],
|
|
626
|
+
unionPay: [4, 4, 4, 4],
|
|
627
|
+
general: [4, 4, 4, 4]
|
|
628
|
+
},
|
|
629
|
+
|
|
630
|
+
re: {
|
|
631
|
+
// starts with 1; 15 digits, not starts with 1800 (jcb card)
|
|
632
|
+
uatp: /^(?!1800)1\d{0,14}/,
|
|
633
|
+
|
|
634
|
+
// starts with 34/37; 15 digits
|
|
635
|
+
amex: /^3[47]\d{0,13}/,
|
|
636
|
+
|
|
637
|
+
// starts with 6011/65/644-649; 16 digits
|
|
638
|
+
discover: /^(?:6011|65\d{0,2}|64[4-9]\d?)\d{0,12}/,
|
|
639
|
+
|
|
640
|
+
// starts with 300-305/309 or 36/38/39; 14 digits
|
|
641
|
+
diners: /^3(?:0([0-5]|9)|[689]\d?)\d{0,11}/,
|
|
642
|
+
|
|
643
|
+
// starts with 51-55/2221–2720; 16 digits
|
|
644
|
+
mastercard: /^(5[1-5]\d{0,2}|22[2-9]\d{0,1}|2[3-7]\d{0,2})\d{0,12}/,
|
|
645
|
+
|
|
646
|
+
// starts with 5019/4175/4571; 16 digits
|
|
647
|
+
dankort: /^(5019|4175|4571)\d{0,12}/,
|
|
648
|
+
|
|
649
|
+
// starts with 637-639; 16 digits
|
|
650
|
+
instapayment: /^63[7-9]\d{0,13}/,
|
|
651
|
+
|
|
652
|
+
// starts with 2131/1800; 15 digits
|
|
653
|
+
jcb15: /^(?:2131|1800)\d{0,11}/,
|
|
654
|
+
|
|
655
|
+
// starts with 2131/1800/35; 16 digits
|
|
656
|
+
jcb: /^(?:35\d{0,2})\d{0,12}/,
|
|
657
|
+
|
|
658
|
+
// starts with 50/56-58/6304/67; 16 digits
|
|
659
|
+
maestro: /^(?:5[0678]\d{0,2}|6304|67\d{0,2})\d{0,12}/,
|
|
660
|
+
|
|
661
|
+
// starts with 22; 16 digits
|
|
662
|
+
mir: /^220[0-4]\d{0,12}/,
|
|
663
|
+
|
|
664
|
+
// starts with 4; 16 digits
|
|
665
|
+
visa: /^4\d{0,15}/,
|
|
666
|
+
|
|
667
|
+
// starts with 62/81; 16 digits
|
|
668
|
+
unionPay: /^(62|81)\d{0,14}/
|
|
669
|
+
},
|
|
670
|
+
|
|
671
|
+
getStrictBlocks: function (block) {
|
|
672
|
+
var total = block.reduce(function (prev, current) {
|
|
673
|
+
return prev + current;
|
|
674
|
+
}, 0);
|
|
675
|
+
|
|
676
|
+
return block.concat(19 - total);
|
|
677
|
+
},
|
|
678
|
+
|
|
679
|
+
getInfo: function (value, strictMode) {
|
|
680
|
+
var blocks = CreditCardDetector.blocks,
|
|
681
|
+
re = CreditCardDetector.re;
|
|
682
|
+
|
|
683
|
+
// Some credit card can have up to 19 digits number.
|
|
684
|
+
// Set strictMode to true will remove the 16 max-length restrain,
|
|
685
|
+
// however, I never found any website validate card number like
|
|
686
|
+
// this, hence probably you don't want to enable this option.
|
|
687
|
+
strictMode = !!strictMode;
|
|
688
|
+
|
|
689
|
+
for (var key in re) {
|
|
690
|
+
if (re[key].test(value)) {
|
|
691
|
+
var matchedBlocks = blocks[key];
|
|
692
|
+
return {
|
|
693
|
+
type: key,
|
|
694
|
+
blocks: strictMode ? this.getStrictBlocks(matchedBlocks) : matchedBlocks
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
return {
|
|
700
|
+
type: 'unknown',
|
|
701
|
+
blocks: strictMode ? this.getStrictBlocks(blocks.general) : blocks.general
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
|
|
706
|
+
var CreditCardDetector_1 = CreditCardDetector;
|
|
707
|
+
|
|
708
|
+
var Util = {
|
|
709
|
+
noop: function () {
|
|
710
|
+
},
|
|
711
|
+
|
|
712
|
+
strip: function (value, re) {
|
|
713
|
+
return value.replace(re, '');
|
|
714
|
+
},
|
|
715
|
+
|
|
716
|
+
getPostDelimiter: function (value, delimiter, delimiters) {
|
|
717
|
+
// single delimiter
|
|
718
|
+
if (delimiters.length === 0) {
|
|
719
|
+
return value.slice(-delimiter.length) === delimiter ? delimiter : '';
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// multiple delimiters
|
|
723
|
+
var matchedDelimiter = '';
|
|
724
|
+
delimiters.forEach(function (current) {
|
|
725
|
+
if (value.slice(-current.length) === current) {
|
|
726
|
+
matchedDelimiter = current;
|
|
727
|
+
}
|
|
728
|
+
});
|
|
729
|
+
|
|
730
|
+
return matchedDelimiter;
|
|
731
|
+
},
|
|
732
|
+
|
|
733
|
+
getDelimiterREByDelimiter: function (delimiter) {
|
|
734
|
+
return new RegExp(delimiter.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1'), 'g');
|
|
735
|
+
},
|
|
736
|
+
|
|
737
|
+
getNextCursorPosition: function (prevPos, oldValue, newValue, delimiter, delimiters) {
|
|
738
|
+
// If cursor was at the end of value, just place it back.
|
|
739
|
+
// Because new value could contain additional chars.
|
|
740
|
+
if (oldValue.length === prevPos) {
|
|
741
|
+
return newValue.length;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
return prevPos + this.getPositionOffset(prevPos, oldValue, newValue, delimiter ,delimiters);
|
|
745
|
+
},
|
|
746
|
+
|
|
747
|
+
getPositionOffset: function (prevPos, oldValue, newValue, delimiter, delimiters) {
|
|
748
|
+
var oldRawValue, newRawValue, lengthOffset;
|
|
749
|
+
|
|
750
|
+
oldRawValue = this.stripDelimiters(oldValue.slice(0, prevPos), delimiter, delimiters);
|
|
751
|
+
newRawValue = this.stripDelimiters(newValue.slice(0, prevPos), delimiter, delimiters);
|
|
752
|
+
lengthOffset = oldRawValue.length - newRawValue.length;
|
|
753
|
+
|
|
754
|
+
return (lengthOffset !== 0) ? (lengthOffset / Math.abs(lengthOffset)) : 0;
|
|
755
|
+
},
|
|
756
|
+
|
|
757
|
+
stripDelimiters: function (value, delimiter, delimiters) {
|
|
758
|
+
var owner = this;
|
|
759
|
+
|
|
760
|
+
// single delimiter
|
|
761
|
+
if (delimiters.length === 0) {
|
|
762
|
+
var delimiterRE = delimiter ? owner.getDelimiterREByDelimiter(delimiter) : '';
|
|
763
|
+
|
|
764
|
+
return value.replace(delimiterRE, '');
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
// multiple delimiters
|
|
768
|
+
delimiters.forEach(function (current) {
|
|
769
|
+
current.split('').forEach(function (letter) {
|
|
770
|
+
value = value.replace(owner.getDelimiterREByDelimiter(letter), '');
|
|
771
|
+
});
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
return value;
|
|
775
|
+
},
|
|
776
|
+
|
|
777
|
+
headStr: function (str, length) {
|
|
778
|
+
return str.slice(0, length);
|
|
779
|
+
},
|
|
780
|
+
|
|
781
|
+
getMaxLength: function (blocks) {
|
|
782
|
+
return blocks.reduce(function (previous, current) {
|
|
783
|
+
return previous + current;
|
|
784
|
+
}, 0);
|
|
785
|
+
},
|
|
786
|
+
|
|
787
|
+
// strip prefix
|
|
788
|
+
// Before type | After type | Return value
|
|
789
|
+
// PEFIX-... | PEFIX-... | ''
|
|
790
|
+
// PREFIX-123 | PEFIX-123 | 123
|
|
791
|
+
// PREFIX-123 | PREFIX-23 | 23
|
|
792
|
+
// PREFIX-123 | PREFIX-1234 | 1234
|
|
793
|
+
getPrefixStrippedValue: function (value, prefix, prefixLength, prevResult, delimiter, delimiters, noImmediatePrefix, tailPrefix, signBeforePrefix) {
|
|
794
|
+
// No prefix
|
|
795
|
+
if (prefixLength === 0) {
|
|
796
|
+
return value;
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
// Value is prefix
|
|
800
|
+
if (value === prefix && value !== '') {
|
|
801
|
+
return '';
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
if (signBeforePrefix && (value.slice(0, 1) == '-')) {
|
|
805
|
+
var prev = (prevResult.slice(0, 1) == '-') ? prevResult.slice(1) : prevResult;
|
|
806
|
+
return '-' + this.getPrefixStrippedValue(value.slice(1), prefix, prefixLength, prev, delimiter, delimiters, noImmediatePrefix, tailPrefix, signBeforePrefix);
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
// Pre result prefix string does not match pre-defined prefix
|
|
810
|
+
if (prevResult.slice(0, prefixLength) !== prefix && !tailPrefix) {
|
|
811
|
+
// Check if the first time user entered something
|
|
812
|
+
if (noImmediatePrefix && !prevResult && value) return value;
|
|
813
|
+
return '';
|
|
814
|
+
} else if (prevResult.slice(-prefixLength) !== prefix && tailPrefix) {
|
|
815
|
+
// Check if the first time user entered something
|
|
816
|
+
if (noImmediatePrefix && !prevResult && value) return value;
|
|
817
|
+
return '';
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
var prevValue = this.stripDelimiters(prevResult, delimiter, delimiters);
|
|
821
|
+
|
|
822
|
+
// New value has issue, someone typed in between prefix letters
|
|
823
|
+
// Revert to pre value
|
|
824
|
+
if (value.slice(0, prefixLength) !== prefix && !tailPrefix) {
|
|
825
|
+
return prevValue.slice(prefixLength);
|
|
826
|
+
} else if (value.slice(-prefixLength) !== prefix && tailPrefix) {
|
|
827
|
+
return prevValue.slice(0, -prefixLength - 1);
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
// No issue, strip prefix for new value
|
|
831
|
+
return tailPrefix ? value.slice(0, -prefixLength) : value.slice(prefixLength);
|
|
832
|
+
},
|
|
833
|
+
|
|
834
|
+
getFirstDiffIndex: function (prev, current) {
|
|
835
|
+
var index = 0;
|
|
836
|
+
|
|
837
|
+
while (prev.charAt(index) === current.charAt(index)) {
|
|
838
|
+
if (prev.charAt(index++) === '') {
|
|
839
|
+
return -1;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
return index;
|
|
844
|
+
},
|
|
845
|
+
|
|
846
|
+
getFormattedValue: function (value, blocks, blocksLength, delimiter, delimiters, delimiterLazyShow) {
|
|
847
|
+
var result = '',
|
|
848
|
+
multipleDelimiters = delimiters.length > 0,
|
|
849
|
+
currentDelimiter = '';
|
|
850
|
+
|
|
851
|
+
// no options, normal input
|
|
852
|
+
if (blocksLength === 0) {
|
|
853
|
+
return value;
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
blocks.forEach(function (length, index) {
|
|
857
|
+
if (value.length > 0) {
|
|
858
|
+
var sub = value.slice(0, length),
|
|
859
|
+
rest = value.slice(length);
|
|
860
|
+
|
|
861
|
+
if (multipleDelimiters) {
|
|
862
|
+
currentDelimiter = delimiters[delimiterLazyShow ? (index - 1) : index] || currentDelimiter;
|
|
863
|
+
} else {
|
|
864
|
+
currentDelimiter = delimiter;
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
if (delimiterLazyShow) {
|
|
868
|
+
if (index > 0) {
|
|
869
|
+
result += currentDelimiter;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
result += sub;
|
|
873
|
+
} else {
|
|
874
|
+
result += sub;
|
|
875
|
+
|
|
876
|
+
if (sub.length === length && index < blocksLength - 1) {
|
|
877
|
+
result += currentDelimiter;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
// update remaining string
|
|
882
|
+
value = rest;
|
|
883
|
+
}
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
return result;
|
|
887
|
+
},
|
|
888
|
+
|
|
889
|
+
// move cursor to the end
|
|
890
|
+
// the first time user focuses on an input with prefix
|
|
891
|
+
fixPrefixCursor: function (el, prefix, delimiter, delimiters) {
|
|
892
|
+
if (!el) {
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
var val = el.value,
|
|
897
|
+
appendix = delimiter || (delimiters[0] || ' ');
|
|
898
|
+
|
|
899
|
+
if (!el.setSelectionRange || !prefix || (prefix.length + appendix.length) <= val.length) {
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
var len = val.length * 2;
|
|
904
|
+
|
|
905
|
+
// set timeout to avoid blink
|
|
906
|
+
setTimeout(function () {
|
|
907
|
+
el.setSelectionRange(len, len);
|
|
908
|
+
}, 1);
|
|
909
|
+
},
|
|
910
|
+
|
|
911
|
+
// Check if input field is fully selected
|
|
912
|
+
checkFullSelection: function(value) {
|
|
913
|
+
try {
|
|
914
|
+
var selection = window.getSelection() || document.getSelection() || {};
|
|
915
|
+
return selection.toString().length === value.length;
|
|
916
|
+
} catch (ex) {
|
|
917
|
+
// Ignore
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
return false;
|
|
921
|
+
},
|
|
922
|
+
|
|
923
|
+
setSelection: function (element, position, doc) {
|
|
924
|
+
if (element !== this.getActiveElement(doc)) {
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
// cursor is already in the end
|
|
929
|
+
if (element && element.value.length <= position) {
|
|
930
|
+
return;
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
if (element.createTextRange) {
|
|
934
|
+
var range = element.createTextRange();
|
|
935
|
+
|
|
936
|
+
range.move('character', position);
|
|
937
|
+
range.select();
|
|
938
|
+
} else {
|
|
939
|
+
try {
|
|
940
|
+
element.setSelectionRange(position, position);
|
|
941
|
+
} catch (e) {
|
|
942
|
+
// eslint-disable-next-line
|
|
943
|
+
console.warn('The input element type does not support selection');
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
},
|
|
947
|
+
|
|
948
|
+
getActiveElement: function(parent) {
|
|
949
|
+
var activeElement = parent.activeElement;
|
|
950
|
+
if (activeElement && activeElement.shadowRoot) {
|
|
951
|
+
return this.getActiveElement(activeElement.shadowRoot);
|
|
952
|
+
}
|
|
953
|
+
return activeElement;
|
|
954
|
+
},
|
|
955
|
+
|
|
956
|
+
isAndroid: function () {
|
|
957
|
+
return navigator && /android/i.test(navigator.userAgent);
|
|
958
|
+
},
|
|
959
|
+
|
|
960
|
+
// On Android chrome, the keyup and keydown events
|
|
961
|
+
// always return key code 229 as a composition that
|
|
962
|
+
// buffers the user’s keystrokes
|
|
963
|
+
// see https://github.com/nosir/cleave.js/issues/147
|
|
964
|
+
isAndroidBackspaceKeydown: function (lastInputValue, currentInputValue) {
|
|
965
|
+
if (!this.isAndroid() || !lastInputValue || !currentInputValue) {
|
|
966
|
+
return false;
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
return currentInputValue === lastInputValue.slice(0, -1);
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
|
|
973
|
+
var Util_1 = Util;
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* Props Assignment
|
|
977
|
+
*
|
|
978
|
+
* Separate this, so react module can share the usage
|
|
979
|
+
*/
|
|
980
|
+
var DefaultProperties = {
|
|
981
|
+
// Maybe change to object-assign
|
|
982
|
+
// for now just keep it as simple
|
|
983
|
+
assign: function (target, opts) {
|
|
984
|
+
target = target || {};
|
|
985
|
+
opts = opts || {};
|
|
986
|
+
|
|
987
|
+
// credit card
|
|
988
|
+
target.creditCard = !!opts.creditCard;
|
|
989
|
+
target.creditCardStrictMode = !!opts.creditCardStrictMode;
|
|
990
|
+
target.creditCardType = '';
|
|
991
|
+
target.onCreditCardTypeChanged = opts.onCreditCardTypeChanged || (function () {});
|
|
992
|
+
|
|
993
|
+
// phone
|
|
994
|
+
target.phone = !!opts.phone;
|
|
995
|
+
target.phoneRegionCode = opts.phoneRegionCode || 'AU';
|
|
996
|
+
target.phoneFormatter = {};
|
|
997
|
+
|
|
998
|
+
// time
|
|
999
|
+
target.time = !!opts.time;
|
|
1000
|
+
target.timePattern = opts.timePattern || ['h', 'm', 's'];
|
|
1001
|
+
target.timeFormat = opts.timeFormat || '24';
|
|
1002
|
+
target.timeFormatter = {};
|
|
1003
|
+
|
|
1004
|
+
// date
|
|
1005
|
+
target.date = !!opts.date;
|
|
1006
|
+
target.datePattern = opts.datePattern || ['d', 'm', 'Y'];
|
|
1007
|
+
target.dateMin = opts.dateMin || '';
|
|
1008
|
+
target.dateMax = opts.dateMax || '';
|
|
1009
|
+
target.dateFormatter = {};
|
|
1010
|
+
|
|
1011
|
+
// numeral
|
|
1012
|
+
target.numeral = !!opts.numeral;
|
|
1013
|
+
target.numeralIntegerScale = opts.numeralIntegerScale > 0 ? opts.numeralIntegerScale : 0;
|
|
1014
|
+
target.numeralDecimalScale = opts.numeralDecimalScale >= 0 ? opts.numeralDecimalScale : 2;
|
|
1015
|
+
target.numeralDecimalMark = opts.numeralDecimalMark || '.';
|
|
1016
|
+
target.numeralThousandsGroupStyle = opts.numeralThousandsGroupStyle || 'thousand';
|
|
1017
|
+
target.numeralPositiveOnly = !!opts.numeralPositiveOnly;
|
|
1018
|
+
target.stripLeadingZeroes = opts.stripLeadingZeroes !== false;
|
|
1019
|
+
target.signBeforePrefix = !!opts.signBeforePrefix;
|
|
1020
|
+
target.tailPrefix = !!opts.tailPrefix;
|
|
1021
|
+
|
|
1022
|
+
// others
|
|
1023
|
+
target.swapHiddenInput = !!opts.swapHiddenInput;
|
|
1024
|
+
|
|
1025
|
+
target.numericOnly = target.creditCard || target.date || !!opts.numericOnly;
|
|
1026
|
+
|
|
1027
|
+
target.uppercase = !!opts.uppercase;
|
|
1028
|
+
target.lowercase = !!opts.lowercase;
|
|
1029
|
+
|
|
1030
|
+
target.prefix = (target.creditCard || target.date) ? '' : (opts.prefix || '');
|
|
1031
|
+
target.noImmediatePrefix = !!opts.noImmediatePrefix;
|
|
1032
|
+
target.prefixLength = target.prefix.length;
|
|
1033
|
+
target.rawValueTrimPrefix = !!opts.rawValueTrimPrefix;
|
|
1034
|
+
target.copyDelimiter = !!opts.copyDelimiter;
|
|
1035
|
+
|
|
1036
|
+
target.initValue = (opts.initValue !== undefined && opts.initValue !== null) ? opts.initValue.toString() : '';
|
|
1037
|
+
|
|
1038
|
+
target.delimiter =
|
|
1039
|
+
(opts.delimiter || opts.delimiter === '') ? opts.delimiter :
|
|
1040
|
+
(opts.date ? '/' :
|
|
1041
|
+
(opts.time ? ':' :
|
|
1042
|
+
(opts.numeral ? ',' :
|
|
1043
|
+
(opts.phone ? ' ' :
|
|
1044
|
+
' '))));
|
|
1045
|
+
target.delimiterLength = target.delimiter.length;
|
|
1046
|
+
target.delimiterLazyShow = !!opts.delimiterLazyShow;
|
|
1047
|
+
target.delimiters = opts.delimiters || [];
|
|
1048
|
+
|
|
1049
|
+
target.blocks = opts.blocks || [];
|
|
1050
|
+
target.blocksLength = target.blocks.length;
|
|
1051
|
+
|
|
1052
|
+
target.root = (typeof commonjsGlobal === 'object' && commonjsGlobal) ? commonjsGlobal : window;
|
|
1053
|
+
target.document = opts.document || target.root.document;
|
|
1054
|
+
|
|
1055
|
+
target.maxLength = 0;
|
|
1056
|
+
|
|
1057
|
+
target.backspace = false;
|
|
1058
|
+
target.result = '';
|
|
1059
|
+
|
|
1060
|
+
target.onValueChanged = opts.onValueChanged || (function () {});
|
|
1061
|
+
|
|
1062
|
+
return target;
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1065
|
+
|
|
1066
|
+
var DefaultProperties_1 = DefaultProperties;
|
|
1067
|
+
|
|
1068
|
+
/**
|
|
1069
|
+
* Construct a new Cleave instance by passing the configuration object
|
|
1070
|
+
*
|
|
1071
|
+
* @param {String | HTMLElement} element
|
|
1072
|
+
* @param {Object} opts
|
|
1073
|
+
*/
|
|
1074
|
+
var Cleave = function (element, opts) {
|
|
1075
|
+
var owner = this;
|
|
1076
|
+
var hasMultipleElements = false;
|
|
1077
|
+
|
|
1078
|
+
if (typeof element === 'string') {
|
|
1079
|
+
owner.element = document.querySelector(element);
|
|
1080
|
+
hasMultipleElements = document.querySelectorAll(element).length > 1;
|
|
1081
|
+
} else {
|
|
1082
|
+
if (typeof element.length !== 'undefined' && element.length > 0) {
|
|
1083
|
+
owner.element = element[0];
|
|
1084
|
+
hasMultipleElements = element.length > 1;
|
|
1085
|
+
} else {
|
|
1086
|
+
owner.element = element;
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
if (!owner.element) {
|
|
1091
|
+
throw new Error('[cleave.js] Please check the element');
|
|
1092
|
+
}
|
|
1093
|
+
|
|
1094
|
+
if (hasMultipleElements) {
|
|
1095
|
+
try {
|
|
1096
|
+
// eslint-disable-next-line
|
|
1097
|
+
console.warn('[cleave.js] Multiple input fields matched, cleave.js will only take the first one.');
|
|
1098
|
+
} catch (e) {
|
|
1099
|
+
// Old IE
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
opts.initValue = owner.element.value;
|
|
1104
|
+
|
|
1105
|
+
owner.properties = Cleave.DefaultProperties.assign({}, opts);
|
|
1106
|
+
|
|
1107
|
+
owner.init();
|
|
1108
|
+
};
|
|
1109
|
+
|
|
1110
|
+
Cleave.prototype = {
|
|
1111
|
+
init: function () {
|
|
1112
|
+
var owner = this, pps = owner.properties;
|
|
1113
|
+
|
|
1114
|
+
// no need to use this lib
|
|
1115
|
+
if (!pps.numeral && !pps.phone && !pps.creditCard && !pps.time && !pps.date && (pps.blocksLength === 0 && !pps.prefix)) {
|
|
1116
|
+
owner.onInput(pps.initValue);
|
|
1117
|
+
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
|
|
1121
|
+
pps.maxLength = Cleave.Util.getMaxLength(pps.blocks);
|
|
1122
|
+
|
|
1123
|
+
owner.isAndroid = Cleave.Util.isAndroid();
|
|
1124
|
+
owner.lastInputValue = '';
|
|
1125
|
+
owner.isBackward = '';
|
|
1126
|
+
|
|
1127
|
+
owner.onChangeListener = owner.onChange.bind(owner);
|
|
1128
|
+
owner.onKeyDownListener = owner.onKeyDown.bind(owner);
|
|
1129
|
+
owner.onFocusListener = owner.onFocus.bind(owner);
|
|
1130
|
+
owner.onCutListener = owner.onCut.bind(owner);
|
|
1131
|
+
owner.onCopyListener = owner.onCopy.bind(owner);
|
|
1132
|
+
|
|
1133
|
+
owner.initSwapHiddenInput();
|
|
1134
|
+
|
|
1135
|
+
owner.element.addEventListener('input', owner.onChangeListener);
|
|
1136
|
+
owner.element.addEventListener('keydown', owner.onKeyDownListener);
|
|
1137
|
+
owner.element.addEventListener('focus', owner.onFocusListener);
|
|
1138
|
+
owner.element.addEventListener('cut', owner.onCutListener);
|
|
1139
|
+
owner.element.addEventListener('copy', owner.onCopyListener);
|
|
1140
|
+
|
|
1141
|
+
|
|
1142
|
+
owner.initPhoneFormatter();
|
|
1143
|
+
owner.initDateFormatter();
|
|
1144
|
+
owner.initTimeFormatter();
|
|
1145
|
+
owner.initNumeralFormatter();
|
|
1146
|
+
|
|
1147
|
+
// avoid touch input field if value is null
|
|
1148
|
+
// otherwise Firefox will add red box-shadow for <input required />
|
|
1149
|
+
if (pps.initValue || (pps.prefix && !pps.noImmediatePrefix)) {
|
|
1150
|
+
owner.onInput(pps.initValue);
|
|
1151
|
+
}
|
|
1152
|
+
},
|
|
1153
|
+
|
|
1154
|
+
initSwapHiddenInput: function () {
|
|
1155
|
+
var owner = this, pps = owner.properties;
|
|
1156
|
+
if (!pps.swapHiddenInput) return;
|
|
1157
|
+
|
|
1158
|
+
var inputFormatter = owner.element.cloneNode(true);
|
|
1159
|
+
owner.element.parentNode.insertBefore(inputFormatter, owner.element);
|
|
1160
|
+
|
|
1161
|
+
owner.elementSwapHidden = owner.element;
|
|
1162
|
+
owner.elementSwapHidden.type = 'hidden';
|
|
1163
|
+
|
|
1164
|
+
owner.element = inputFormatter;
|
|
1165
|
+
owner.element.id = '';
|
|
1166
|
+
},
|
|
1167
|
+
|
|
1168
|
+
initNumeralFormatter: function () {
|
|
1169
|
+
var owner = this, pps = owner.properties;
|
|
1170
|
+
|
|
1171
|
+
if (!pps.numeral) {
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
pps.numeralFormatter = new Cleave.NumeralFormatter(
|
|
1176
|
+
pps.numeralDecimalMark,
|
|
1177
|
+
pps.numeralIntegerScale,
|
|
1178
|
+
pps.numeralDecimalScale,
|
|
1179
|
+
pps.numeralThousandsGroupStyle,
|
|
1180
|
+
pps.numeralPositiveOnly,
|
|
1181
|
+
pps.stripLeadingZeroes,
|
|
1182
|
+
pps.prefix,
|
|
1183
|
+
pps.signBeforePrefix,
|
|
1184
|
+
pps.tailPrefix,
|
|
1185
|
+
pps.delimiter
|
|
1186
|
+
);
|
|
1187
|
+
},
|
|
1188
|
+
|
|
1189
|
+
initTimeFormatter: function() {
|
|
1190
|
+
var owner = this, pps = owner.properties;
|
|
1191
|
+
|
|
1192
|
+
if (!pps.time) {
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
pps.timeFormatter = new Cleave.TimeFormatter(pps.timePattern, pps.timeFormat);
|
|
1197
|
+
pps.blocks = pps.timeFormatter.getBlocks();
|
|
1198
|
+
pps.blocksLength = pps.blocks.length;
|
|
1199
|
+
pps.maxLength = Cleave.Util.getMaxLength(pps.blocks);
|
|
1200
|
+
},
|
|
1201
|
+
|
|
1202
|
+
initDateFormatter: function () {
|
|
1203
|
+
var owner = this, pps = owner.properties;
|
|
1204
|
+
|
|
1205
|
+
if (!pps.date) {
|
|
1206
|
+
return;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
pps.dateFormatter = new Cleave.DateFormatter(pps.datePattern, pps.dateMin, pps.dateMax);
|
|
1210
|
+
pps.blocks = pps.dateFormatter.getBlocks();
|
|
1211
|
+
pps.blocksLength = pps.blocks.length;
|
|
1212
|
+
pps.maxLength = Cleave.Util.getMaxLength(pps.blocks);
|
|
1213
|
+
},
|
|
1214
|
+
|
|
1215
|
+
initPhoneFormatter: function () {
|
|
1216
|
+
var owner = this, pps = owner.properties;
|
|
1217
|
+
|
|
1218
|
+
if (!pps.phone) {
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
// Cleave.AsYouTypeFormatter should be provided by
|
|
1223
|
+
// external google closure lib
|
|
1224
|
+
try {
|
|
1225
|
+
pps.phoneFormatter = new Cleave.PhoneFormatter(
|
|
1226
|
+
new pps.root.Cleave.AsYouTypeFormatter(pps.phoneRegionCode),
|
|
1227
|
+
pps.delimiter
|
|
1228
|
+
);
|
|
1229
|
+
} catch (ex) {
|
|
1230
|
+
throw new Error('[cleave.js] Please include phone-type-formatter.{country}.js lib');
|
|
1231
|
+
}
|
|
1232
|
+
},
|
|
1233
|
+
|
|
1234
|
+
onKeyDown: function (event) {
|
|
1235
|
+
var owner = this,
|
|
1236
|
+
charCode = event.which || event.keyCode;
|
|
1237
|
+
|
|
1238
|
+
owner.lastInputValue = owner.element.value;
|
|
1239
|
+
owner.isBackward = charCode === 8;
|
|
1240
|
+
},
|
|
1241
|
+
|
|
1242
|
+
onChange: function (event) {
|
|
1243
|
+
var owner = this, pps = owner.properties,
|
|
1244
|
+
Util = Cleave.Util;
|
|
1245
|
+
|
|
1246
|
+
owner.isBackward = owner.isBackward || event.inputType === 'deleteContentBackward';
|
|
1247
|
+
|
|
1248
|
+
var postDelimiter = Util.getPostDelimiter(owner.lastInputValue, pps.delimiter, pps.delimiters);
|
|
1249
|
+
|
|
1250
|
+
if (owner.isBackward && postDelimiter) {
|
|
1251
|
+
pps.postDelimiterBackspace = postDelimiter;
|
|
1252
|
+
} else {
|
|
1253
|
+
pps.postDelimiterBackspace = false;
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
this.onInput(this.element.value);
|
|
1257
|
+
},
|
|
1258
|
+
|
|
1259
|
+
onFocus: function () {
|
|
1260
|
+
var owner = this,
|
|
1261
|
+
pps = owner.properties;
|
|
1262
|
+
owner.lastInputValue = owner.element.value;
|
|
1263
|
+
|
|
1264
|
+
if (pps.prefix && pps.noImmediatePrefix && !owner.element.value) {
|
|
1265
|
+
this.onInput(pps.prefix);
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
Cleave.Util.fixPrefixCursor(owner.element, pps.prefix, pps.delimiter, pps.delimiters);
|
|
1269
|
+
},
|
|
1270
|
+
|
|
1271
|
+
onCut: function (e) {
|
|
1272
|
+
if (!Cleave.Util.checkFullSelection(this.element.value)) return;
|
|
1273
|
+
this.copyClipboardData(e);
|
|
1274
|
+
this.onInput('');
|
|
1275
|
+
},
|
|
1276
|
+
|
|
1277
|
+
onCopy: function (e) {
|
|
1278
|
+
if (!Cleave.Util.checkFullSelection(this.element.value)) return;
|
|
1279
|
+
this.copyClipboardData(e);
|
|
1280
|
+
},
|
|
1281
|
+
|
|
1282
|
+
copyClipboardData: function (e) {
|
|
1283
|
+
var owner = this,
|
|
1284
|
+
pps = owner.properties,
|
|
1285
|
+
Util = Cleave.Util,
|
|
1286
|
+
inputValue = owner.element.value,
|
|
1287
|
+
textToCopy = '';
|
|
1288
|
+
|
|
1289
|
+
if (!pps.copyDelimiter) {
|
|
1290
|
+
textToCopy = Util.stripDelimiters(inputValue, pps.delimiter, pps.delimiters);
|
|
1291
|
+
} else {
|
|
1292
|
+
textToCopy = inputValue;
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
try {
|
|
1296
|
+
if (e.clipboardData) {
|
|
1297
|
+
e.clipboardData.setData('Text', textToCopy);
|
|
1298
|
+
} else {
|
|
1299
|
+
window.clipboardData.setData('Text', textToCopy);
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
e.preventDefault();
|
|
1303
|
+
} catch (ex) {
|
|
1304
|
+
// empty
|
|
1305
|
+
}
|
|
1306
|
+
},
|
|
1307
|
+
|
|
1308
|
+
onInput: function (value) {
|
|
1309
|
+
var owner = this, pps = owner.properties,
|
|
1310
|
+
Util = Cleave.Util;
|
|
1311
|
+
|
|
1312
|
+
// case 1: delete one more character "4"
|
|
1313
|
+
// 1234*| -> hit backspace -> 123|
|
|
1314
|
+
// case 2: last character is not delimiter which is:
|
|
1315
|
+
// 12|34* -> hit backspace -> 1|34*
|
|
1316
|
+
// note: no need to apply this for numeral mode
|
|
1317
|
+
var postDelimiterAfter = Util.getPostDelimiter(value, pps.delimiter, pps.delimiters);
|
|
1318
|
+
if (!pps.numeral && pps.postDelimiterBackspace && !postDelimiterAfter) {
|
|
1319
|
+
value = Util.headStr(value, value.length - pps.postDelimiterBackspace.length);
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
// phone formatter
|
|
1323
|
+
if (pps.phone) {
|
|
1324
|
+
if (pps.prefix && (!pps.noImmediatePrefix || value.length)) {
|
|
1325
|
+
pps.result = pps.prefix + pps.phoneFormatter.format(value).slice(pps.prefix.length);
|
|
1326
|
+
} else {
|
|
1327
|
+
pps.result = pps.phoneFormatter.format(value);
|
|
1328
|
+
}
|
|
1329
|
+
owner.updateValueState();
|
|
1330
|
+
|
|
1331
|
+
return;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
// numeral formatter
|
|
1335
|
+
if (pps.numeral) {
|
|
1336
|
+
// Do not show prefix when noImmediatePrefix is specified
|
|
1337
|
+
// This mostly because we need to show user the native input placeholder
|
|
1338
|
+
if (pps.prefix && pps.noImmediatePrefix && value.length === 0) {
|
|
1339
|
+
pps.result = '';
|
|
1340
|
+
} else {
|
|
1341
|
+
pps.result = pps.numeralFormatter.format(value);
|
|
1342
|
+
}
|
|
1343
|
+
owner.updateValueState();
|
|
1344
|
+
|
|
1345
|
+
return;
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
// date
|
|
1349
|
+
if (pps.date) {
|
|
1350
|
+
value = pps.dateFormatter.getValidatedDate(value);
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
// time
|
|
1354
|
+
if (pps.time) {
|
|
1355
|
+
value = pps.timeFormatter.getValidatedTime(value);
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
// strip delimiters
|
|
1359
|
+
value = Util.stripDelimiters(value, pps.delimiter, pps.delimiters);
|
|
1360
|
+
|
|
1361
|
+
// strip prefix
|
|
1362
|
+
value = Util.getPrefixStrippedValue(value, pps.prefix, pps.prefixLength, pps.result, pps.delimiter, pps.delimiters, pps.noImmediatePrefix, pps.tailPrefix, pps.signBeforePrefix);
|
|
1363
|
+
|
|
1364
|
+
// strip non-numeric characters
|
|
1365
|
+
value = pps.numericOnly ? Util.strip(value, /[^\d]/g) : value;
|
|
1366
|
+
|
|
1367
|
+
// convert case
|
|
1368
|
+
value = pps.uppercase ? value.toUpperCase() : value;
|
|
1369
|
+
value = pps.lowercase ? value.toLowerCase() : value;
|
|
1370
|
+
|
|
1371
|
+
// prevent from showing prefix when no immediate option enabled with empty input value
|
|
1372
|
+
if (pps.prefix) {
|
|
1373
|
+
if (pps.tailPrefix) {
|
|
1374
|
+
value = value + pps.prefix;
|
|
1375
|
+
} else {
|
|
1376
|
+
value = pps.prefix + value;
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
|
|
1380
|
+
// no blocks specified, no need to do formatting
|
|
1381
|
+
if (pps.blocksLength === 0) {
|
|
1382
|
+
pps.result = value;
|
|
1383
|
+
owner.updateValueState();
|
|
1384
|
+
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
// update credit card props
|
|
1390
|
+
if (pps.creditCard) {
|
|
1391
|
+
owner.updateCreditCardPropsByValue(value);
|
|
1392
|
+
}
|
|
1393
|
+
|
|
1394
|
+
// strip over length characters
|
|
1395
|
+
value = Util.headStr(value, pps.maxLength);
|
|
1396
|
+
|
|
1397
|
+
// apply blocks
|
|
1398
|
+
pps.result = Util.getFormattedValue(
|
|
1399
|
+
value,
|
|
1400
|
+
pps.blocks, pps.blocksLength,
|
|
1401
|
+
pps.delimiter, pps.delimiters, pps.delimiterLazyShow
|
|
1402
|
+
);
|
|
1403
|
+
|
|
1404
|
+
owner.updateValueState();
|
|
1405
|
+
},
|
|
1406
|
+
|
|
1407
|
+
updateCreditCardPropsByValue: function (value) {
|
|
1408
|
+
var owner = this, pps = owner.properties,
|
|
1409
|
+
Util = Cleave.Util,
|
|
1410
|
+
creditCardInfo;
|
|
1411
|
+
|
|
1412
|
+
// At least one of the first 4 characters has changed
|
|
1413
|
+
if (Util.headStr(pps.result, 4) === Util.headStr(value, 4)) {
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
creditCardInfo = Cleave.CreditCardDetector.getInfo(value, pps.creditCardStrictMode);
|
|
1418
|
+
|
|
1419
|
+
pps.blocks = creditCardInfo.blocks;
|
|
1420
|
+
pps.blocksLength = pps.blocks.length;
|
|
1421
|
+
pps.maxLength = Util.getMaxLength(pps.blocks);
|
|
1422
|
+
|
|
1423
|
+
// credit card type changed
|
|
1424
|
+
if (pps.creditCardType !== creditCardInfo.type) {
|
|
1425
|
+
pps.creditCardType = creditCardInfo.type;
|
|
1426
|
+
|
|
1427
|
+
pps.onCreditCardTypeChanged.call(owner, pps.creditCardType);
|
|
1428
|
+
}
|
|
1429
|
+
},
|
|
1430
|
+
|
|
1431
|
+
updateValueState: function () {
|
|
1432
|
+
var owner = this,
|
|
1433
|
+
Util = Cleave.Util,
|
|
1434
|
+
pps = owner.properties;
|
|
1435
|
+
|
|
1436
|
+
if (!owner.element) {
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
var endPos = owner.element.selectionEnd;
|
|
1441
|
+
var oldValue = owner.element.value;
|
|
1442
|
+
var newValue = pps.result;
|
|
1443
|
+
|
|
1444
|
+
endPos = Util.getNextCursorPosition(endPos, oldValue, newValue, pps.delimiter, pps.delimiters);
|
|
1445
|
+
|
|
1446
|
+
// fix Android browser type="text" input field
|
|
1447
|
+
// cursor not jumping issue
|
|
1448
|
+
if (owner.isAndroid) {
|
|
1449
|
+
window.setTimeout(function () {
|
|
1450
|
+
owner.element.value = newValue;
|
|
1451
|
+
Util.setSelection(owner.element, endPos, pps.document, false);
|
|
1452
|
+
owner.callOnValueChanged();
|
|
1453
|
+
}, 1);
|
|
1454
|
+
|
|
1455
|
+
return;
|
|
1456
|
+
}
|
|
1457
|
+
|
|
1458
|
+
owner.element.value = newValue;
|
|
1459
|
+
if (pps.swapHiddenInput) owner.elementSwapHidden.value = owner.getRawValue();
|
|
1460
|
+
|
|
1461
|
+
Util.setSelection(owner.element, endPos, pps.document, false);
|
|
1462
|
+
owner.callOnValueChanged();
|
|
1463
|
+
},
|
|
1464
|
+
|
|
1465
|
+
callOnValueChanged: function () {
|
|
1466
|
+
var owner = this,
|
|
1467
|
+
pps = owner.properties;
|
|
1468
|
+
|
|
1469
|
+
pps.onValueChanged.call(owner, {
|
|
1470
|
+
target: {
|
|
1471
|
+
name: owner.element.name,
|
|
1472
|
+
value: pps.result,
|
|
1473
|
+
rawValue: owner.getRawValue()
|
|
1474
|
+
}
|
|
1475
|
+
});
|
|
1476
|
+
},
|
|
1477
|
+
|
|
1478
|
+
setPhoneRegionCode: function (phoneRegionCode) {
|
|
1479
|
+
var owner = this, pps = owner.properties;
|
|
1480
|
+
|
|
1481
|
+
pps.phoneRegionCode = phoneRegionCode;
|
|
1482
|
+
owner.initPhoneFormatter();
|
|
1483
|
+
owner.onChange();
|
|
1484
|
+
},
|
|
1485
|
+
|
|
1486
|
+
setRawValue: function (value) {
|
|
1487
|
+
var owner = this, pps = owner.properties;
|
|
1488
|
+
|
|
1489
|
+
value = value !== undefined && value !== null ? value.toString() : '';
|
|
1490
|
+
|
|
1491
|
+
if (pps.numeral) {
|
|
1492
|
+
value = value.replace('.', pps.numeralDecimalMark);
|
|
1493
|
+
}
|
|
1494
|
+
|
|
1495
|
+
pps.postDelimiterBackspace = false;
|
|
1496
|
+
|
|
1497
|
+
owner.element.value = value;
|
|
1498
|
+
owner.onInput(value);
|
|
1499
|
+
},
|
|
1500
|
+
|
|
1501
|
+
getRawValue: function () {
|
|
1502
|
+
var owner = this,
|
|
1503
|
+
pps = owner.properties,
|
|
1504
|
+
Util = Cleave.Util,
|
|
1505
|
+
rawValue = owner.element.value;
|
|
1506
|
+
|
|
1507
|
+
if (pps.rawValueTrimPrefix) {
|
|
1508
|
+
rawValue = Util.getPrefixStrippedValue(rawValue, pps.prefix, pps.prefixLength, pps.result, pps.delimiter, pps.delimiters, pps.noImmediatePrefix, pps.tailPrefix, pps.signBeforePrefix);
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
if (pps.numeral) {
|
|
1512
|
+
rawValue = pps.numeralFormatter.getRawValue(rawValue);
|
|
1513
|
+
} else {
|
|
1514
|
+
rawValue = Util.stripDelimiters(rawValue, pps.delimiter, pps.delimiters);
|
|
1515
|
+
}
|
|
1516
|
+
|
|
1517
|
+
return rawValue;
|
|
1518
|
+
},
|
|
1519
|
+
|
|
1520
|
+
getISOFormatDate: function () {
|
|
1521
|
+
var owner = this,
|
|
1522
|
+
pps = owner.properties;
|
|
1523
|
+
|
|
1524
|
+
return pps.date ? pps.dateFormatter.getISOFormatDate() : '';
|
|
1525
|
+
},
|
|
1526
|
+
|
|
1527
|
+
getISOFormatTime: function () {
|
|
1528
|
+
var owner = this,
|
|
1529
|
+
pps = owner.properties;
|
|
1530
|
+
|
|
1531
|
+
return pps.time ? pps.timeFormatter.getISOFormatTime() : '';
|
|
1532
|
+
},
|
|
1533
|
+
|
|
1534
|
+
getFormattedValue: function () {
|
|
1535
|
+
return this.element.value;
|
|
1536
|
+
},
|
|
1537
|
+
|
|
1538
|
+
destroy: function () {
|
|
1539
|
+
var owner = this;
|
|
1540
|
+
|
|
1541
|
+
owner.element.removeEventListener('input', owner.onChangeListener);
|
|
1542
|
+
owner.element.removeEventListener('keydown', owner.onKeyDownListener);
|
|
1543
|
+
owner.element.removeEventListener('focus', owner.onFocusListener);
|
|
1544
|
+
owner.element.removeEventListener('cut', owner.onCutListener);
|
|
1545
|
+
owner.element.removeEventListener('copy', owner.onCopyListener);
|
|
1546
|
+
},
|
|
1547
|
+
|
|
1548
|
+
toString: function () {
|
|
1549
|
+
return '[Cleave Object]';
|
|
1550
|
+
}
|
|
1551
|
+
};
|
|
1552
|
+
|
|
1553
|
+
Cleave.NumeralFormatter = NumeralFormatter_1;
|
|
1554
|
+
Cleave.DateFormatter = DateFormatter_1;
|
|
1555
|
+
Cleave.TimeFormatter = TimeFormatter_1;
|
|
1556
|
+
Cleave.PhoneFormatter = PhoneFormatter_1;
|
|
1557
|
+
Cleave.CreditCardDetector = CreditCardDetector_1;
|
|
1558
|
+
Cleave.Util = Util_1;
|
|
1559
|
+
Cleave.DefaultProperties = DefaultProperties_1;
|
|
1560
|
+
|
|
1561
|
+
// for angular directive
|
|
1562
|
+
((typeof commonjsGlobal === 'object' && commonjsGlobal) ? commonjsGlobal : window)['Cleave'] = Cleave;
|
|
1563
|
+
|
|
1564
|
+
// CommonJS
|
|
1565
|
+
var Cleave_1 = Cleave;
|
|
1566
|
+
|
|
1567
|
+
const catInputCss = ".hint-wrapper{flex:0 1 auto;display:flex;gap:0.5rem}.hint-section{flex:1 1 auto;display:flex;flex-direction:column;gap:0.25rem;color:rgb(var(--cat-font-color-muted, 81, 92, 108));font-size:0.875rem;line-height:1.125rem}.hint-section .input-hint,.hint-section ::slotted([slot=hint]){margin:0 !important}.cat-bg-primary{background-color:rgb(var(--cat-primary-bg, 0, 129, 148)) !important;color:rgb(var(--cat-primary-fill, 255, 255, 255)) !important;--cat-primary-text:var(--cat-primary-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-primary-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-primary-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-bg-primary-hover{transition:background-color 125ms, color 125ms}.cat-bg-primary-hover:hover{background-color:rgb(var(--cat-primary-bg-hover, 1, 115, 132)) !important;color:rgb(var(--cat-primary-fill-hover, 255, 255, 255)) !important;--cat-primary-text:var(--cat-primary-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-primary-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-primary-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-text-primary,.cat-link-primary{color:rgb(var(--cat-primary-text, 0, 129, 148)) !important}.cat-link-primary,.cat-text-primary-hover{transition:color 125ms}.cat-link-primary:hover,.cat-text-primary-hover:hover{color:rgb(var(--cat-primary-text-hover, 1, 115, 132)) !important}.cat-link-primary:active,.cat-text-primary-hover:active{color:rgb(var(--cat-primary-text-active, 2, 99, 113)) !important}.cat-bg-primaryInverted{background-color:#93b4f2 !important;color:black !important;--cat-primary-text:0, 0, 0;--cat-primary-text-hover:0, 0, 0;--cat-primary-text-active:0, 0, 0;--cat-link-decoration:underline}.cat-bg-primaryInverted-hover{transition:background-color 125ms, color 125ms}.cat-bg-primaryInverted-hover:hover{background-color:#93b4f2 !important;color:black !important;--cat-primary-text:0, 0, 0;--cat-primary-text-hover:0, 0, 0;--cat-primary-text-active:0, 0, 0;--cat-link-decoration:underline}.cat-text-primaryInverted,.cat-link-primaryInverted{color:#93b4f2 !important}.cat-link-primaryInverted,.cat-text-primaryInverted-hover{transition:color 125ms}.cat-link-primaryInverted:hover,.cat-text-primaryInverted-hover:hover{color:#93b4f2 !important}.cat-link-primaryInverted:active,.cat-text-primaryInverted-hover:active{color:#93b4f2 !important}.cat-bg-secondary{background-color:rgb(var(--cat-secondary-bg, 105, 118, 135)) !important;color:rgb(var(--cat-secondary-fill, 255, 255, 255)) !important;--cat-primary-text:var(--cat-secondary-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-secondary-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-secondary-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-bg-secondary-hover{transition:background-color 125ms, color 125ms}.cat-bg-secondary-hover:hover{background-color:rgb(var(--cat-secondary-bg-hover, 105, 118, 135)) !important;color:rgb(var(--cat-secondary-fill-hover, 255, 255, 255)) !important;--cat-primary-text:var(--cat-secondary-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-secondary-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-secondary-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-text-secondary,.cat-link-secondary{color:rgb(var(--cat-secondary-text, 0, 0, 0)) !important}.cat-link-secondary,.cat-text-secondary-hover{transition:color 125ms}.cat-link-secondary:hover,.cat-text-secondary-hover:hover{color:rgb(var(--cat-secondary-text-hover, 0, 0, 0)) !important}.cat-link-secondary:active,.cat-text-secondary-hover:active{color:rgb(var(--cat-secondary-text-active, 0, 0, 0)) !important}.cat-bg-secondaryInverted{background-color:#697687 !important;color:black !important;--cat-primary-text:0, 0, 0;--cat-primary-text-hover:0, 0, 0;--cat-primary-text-active:0, 0, 0;--cat-link-decoration:underline}.cat-bg-secondaryInverted-hover{transition:background-color 125ms, color 125ms}.cat-bg-secondaryInverted-hover:hover{background-color:#697687 !important;color:black !important;--cat-primary-text:0, 0, 0;--cat-primary-text-hover:0, 0, 0;--cat-primary-text-active:0, 0, 0;--cat-link-decoration:underline}.cat-text-secondaryInverted,.cat-link-secondaryInverted{color:white !important}.cat-link-secondaryInverted,.cat-text-secondaryInverted-hover{transition:color 125ms}.cat-link-secondaryInverted:hover,.cat-text-secondaryInverted-hover:hover{color:white !important}.cat-link-secondaryInverted:active,.cat-text-secondaryInverted-hover:active{color:white !important}.cat-bg-info{background-color:rgb(var(--cat-info-bg, 0, 115, 230)) !important;color:rgb(var(--cat-info-fill, 255, 255, 255)) !important;--cat-primary-text:var(--cat-info-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-info-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-info-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-bg-info-hover{transition:background-color 125ms, color 125ms}.cat-bg-info-hover:hover{background-color:rgb(var(--cat-info-bg-hover, 0, 107, 227)) !important;color:rgb(var(--cat-info-fill-hover, 255, 255, 255)) !important;--cat-primary-text:var(--cat-info-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-info-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-info-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-text-info,.cat-link-info{color:rgb(var(--cat-info-text, 0, 115, 230)) !important}.cat-link-info,.cat-text-info-hover{transition:color 125ms}.cat-link-info:hover,.cat-text-info-hover:hover{color:rgb(var(--cat-info-text-hover, 0, 107, 227)) !important}.cat-link-info:active,.cat-text-info-hover:active{color:rgb(var(--cat-info-text-active, 0, 96, 223)) !important}.cat-bg-success{background-color:rgb(var(--cat-success-bg, 0, 132, 88)) !important;color:rgb(var(--cat-success-fill, 255, 255, 255)) !important;--cat-primary-text:var(--cat-success-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-success-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-success-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-bg-success-hover{transition:background-color 125ms, color 125ms}.cat-bg-success-hover:hover{background-color:rgb(var(--cat-success-bg-hover, 0, 117, 78)) !important;color:rgb(var(--cat-success-fill-hover, 255, 255, 255)) !important;--cat-primary-text:var(--cat-success-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-success-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-success-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-text-success,.cat-link-success{color:rgb(var(--cat-success-text, 0, 132, 88)) !important}.cat-link-success,.cat-text-success-hover{transition:color 125ms}.cat-link-success:hover,.cat-text-success-hover:hover{color:rgb(var(--cat-success-text-hover, 0, 117, 78)) !important}.cat-link-success:active,.cat-text-success-hover:active{color:rgb(var(--cat-success-text-active, 0, 105, 70)) !important}.cat-bg-warning{background-color:rgb(var(--cat-warning-bg, 255, 206, 128)) !important;color:rgb(var(--cat-warning-fill, 0, 0, 0)) !important;--cat-primary-text:var(--cat-warning-fill, 0, 0, 0);--cat-primary-text-hover:var(--cat-warning-fill-hover, 0, 0, 0);--cat-primary-text-active:var(--cat-warning-fill-active, 0, 0, 0);--cat-link-decoration:underline}.cat-bg-warning-hover{transition:background-color 125ms, color 125ms}.cat-bg-warning-hover:hover{background-color:rgb(var(--cat-warning-bg-hover, 255, 214, 148)) !important;color:rgb(var(--cat-warning-fill-hover, 0, 0, 0)) !important;--cat-primary-text:var(--cat-warning-fill, 0, 0, 0);--cat-primary-text-hover:var(--cat-warning-fill-hover, 0, 0, 0);--cat-primary-text-active:var(--cat-warning-fill-active, 0, 0, 0);--cat-link-decoration:underline}.cat-text-warning,.cat-link-warning{color:rgb(var(--cat-warning-text, 159, 97, 0)) !important}.cat-link-warning,.cat-text-warning-hover{transition:color 125ms}.cat-link-warning:hover,.cat-text-warning-hover:hover{color:rgb(var(--cat-warning-text-hover, 159, 97, 0)) !important}.cat-link-warning:active,.cat-text-warning-hover:active{color:rgb(var(--cat-warning-text-active, 159, 97, 0)) !important}.cat-bg-danger{background-color:rgb(var(--cat-danger-bg, 217, 52, 13)) !important;color:rgb(var(--cat-danger-fill, 255, 255, 255)) !important;--cat-primary-text:var(--cat-danger-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-danger-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-danger-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-bg-danger-hover{transition:background-color 125ms, color 125ms}.cat-bg-danger-hover:hover{background-color:rgb(var(--cat-danger-bg-hover, 194, 46, 11)) !important;color:rgb(var(--cat-danger-fill-hover, 255, 255, 255)) !important;--cat-primary-text:var(--cat-danger-fill, 255, 255, 255);--cat-primary-text-hover:var(--cat-danger-fill-hover, 255, 255, 255);--cat-primary-text-active:var(--cat-danger-fill-active, 255, 255, 255);--cat-link-decoration:underline}.cat-text-danger,.cat-link-danger{color:rgb(var(--cat-danger-text, 217, 52, 13)) !important}.cat-link-danger,.cat-text-danger-hover{transition:color 125ms}.cat-link-danger:hover,.cat-text-danger-hover:hover{color:rgb(var(--cat-danger-text-hover, 194, 46, 11)) !important}.cat-link-danger:active,.cat-text-danger-hover:active{color:rgb(var(--cat-danger-text-active, 174, 42, 10)) !important}.cat-active{color:rgb(var(--cat-primary-text, 0, 129, 148)) !important}.cat-text-active{color:rgb(var(--cat-primary-text, 0, 129, 148)) !important}.cat-muted{color:rgb(var(--cat-font-color-muted, 81, 92, 108)) !important}.cat-text-muted{color:rgb(var(--cat-font-color-muted, 81, 92, 108)) !important}.cat-bg-muted{background-color:#f2f4f7 !important}.cat-text-reset{color:inherit !important}.cat-link-reset{color:inherit !important;text-decoration:inherit !important}.label{overflow:hidden;word-wrap:break-word;word-break:break-word}.input-field:not(.input-horizontal) .label-container.hidden,.textarea-field:not(.textarea-horizontal) .label-container.hidden,.select-field:not(.select-horizontal) .label-container.hidden{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.label-container{flex-basis:var(--label-size, 33.33%)}.label-container .label-wrapper{display:flex;gap:0.25rem}.label-metadata{display:flex;flex-shrink:0;flex-grow:1;justify-content:space-between;gap:0.25rem;color:rgb(var(--cat-font-color-muted, 81, 92, 108))}.label-optional,.label-character-count{display:inline-flex;align-items:center;max-height:1.25rem;font-size:0.75rem;line-height:1rem}.label-character-count{margin-left:auto}.input-horizontal .label-container.hidden label,.textarea-horizontal .label-container.hidden label,.select-horizontal .label-container.hidden label{position:absolute !important;width:1px !important;height:1px !important;padding:0 !important;margin:-1px !important;overflow:hidden !important;clip:rect(0, 0, 0, 0) !important;white-space:nowrap !important;border:0 !important}.input-horizontal .label-wrapper,.textarea-horizontal .label-wrapper,.select-horizontal .label-wrapper{flex-direction:column}.input-horizontal label,.textarea-horizontal label,.select-horizontal label{min-height:2.5rem;display:inline-flex;align-items:center}.input-horizontal .label-metadata,.textarea-horizontal .label-metadata,.select-horizontal .label-metadata{justify-content:flex-start}.input-horizontal .label-metadata .label-character-count,.textarea-horizontal .label-metadata .label-character-count,.select-horizontal .label-metadata .label-character-count{margin-left:0}:host{display:flex;font-size:0.9375rem;line-height:1.25rem}:host([hidden]){display:none}.input-field,.input-container{display:flex;flex-direction:column;gap:0.5rem;flex:1 1 auto}.input-field.input-horizontal{flex-direction:row;gap:1rem}.input-wrapper{flex:1 1 auto;display:flex;align-items:stretch;gap:0.75rem;padding:0 0.75rem;height:2.5rem;overflow:hidden;background:white;border-radius:var(--cat-border-radius-m, 0.25rem);box-shadow:inset 0 0 0 1px rgb(var(--border-color));transition:box-shadow 125ms linear;--border-color:var(--cat-border-color-dark, 215, 219, 224);}.input-wrapper.input-round{border-radius:10rem}.input-wrapper.input-readonly{pointer-events:none}.input-wrapper.input-disabled{background:#f2f4f7;cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 81, 92, 108))}.input-wrapper:not(.input-disabled):hover{box-shadow:inset 0 0 0 1px rgb(var(--border-color)), 0 0 0 1px rgb(var(--border-color))}.input-wrapper:focus-within{outline:2px solid rgb(var(--cat-border-color-focus, 0, 113, 255));outline-offset:-1px}.input-wrapper:focus-within:has(.clearable:focus){outline:none}.input-wrapper.input-invalid{--border-color:var(--cat-danger-bg, 217, 52, 13), 0.2}.input-wrapper:has(input:-webkit-autofill),.input-wrapper:has(input:-webkit-autofill):hover,.input-wrapper:has(input:-webkit-autofill):focus{background-color:#e8f0fe}.text-prefix,.text-suffix{display:inline-flex;align-items:center;-webkit-user-select:none;-ms-user-select:none;user-select:none;}.text-prefix{border-right:1px solid rgb(var(--cat-border-color-dark, 215, 219, 224));padding-right:0.75rem}.text-suffix{border-left:1px solid rgb(var(--cat-border-color-dark, 215, 219, 224));padding-left:0.75rem}.icon-prefix,.icon-suffix{align-self:center}.input-outer-wrapper{display:flex}.input-inner-wrapper{display:flex;align-items:center;position:relative;flex:1 1 auto}input{font:inherit;margin:0;padding:0;width:100%;min-width:0;border:none;outline:none;background:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.input-disabled input{cursor:not-allowed;color:rgb(var(--cat-font-color-muted, 81, 92, 108))}input.has-clearable,input.has-toggle-password{padding-right:1.5rem}input.has-clearable.has-toggle-password{padding-right:3.5rem}input::placeholder{color:rgb(var(--cat-font-color-muted, 81, 92, 108))}input:-webkit-autofill,input:-webkit-autofill:hover,input:-webkit-autofill:focus{-webkit-box-shadow:0 0 0 9999px #e8f0fe inset}.clearable{position:absolute;top:calc(50% - 1rem);right:-0.5rem}.toggle-password{position:absolute;top:calc(50% - 1rem);right:-0.5rem}.has-clearable~.toggle-password{right:1.5rem}:host(.cat-date-input) .input-wrapper,:host(.cat-time-input) .input-wrapper{z-index:1;border-top-right-radius:0;border-bottom-right-radius:0}";
|
|
11
1568
|
const CatInputStyle0 = catInputCss;
|
|
12
1569
|
|
|
13
1570
|
let nextUniqueId = 0;
|
|
@@ -92,6 +1649,14 @@ const CatInput = /*@__PURE__*/ proxyCustomElement(class CatInput extends HTMLEle
|
|
|
92
1649
|
this.value = '';
|
|
93
1650
|
this.catChange.emit(this.value);
|
|
94
1651
|
}
|
|
1652
|
+
/**
|
|
1653
|
+
* Adds a Cleave.js mask to the input.
|
|
1654
|
+
*
|
|
1655
|
+
* @param options The Cleave.js options.
|
|
1656
|
+
*/
|
|
1657
|
+
async mask(options) {
|
|
1658
|
+
new Cleave_1(this.input, options);
|
|
1659
|
+
}
|
|
95
1660
|
onErrorsChanged(value) {
|
|
96
1661
|
if (!coerceBoolean(this.errorUpdate)) {
|
|
97
1662
|
this.errorMap = undefined;
|
|
@@ -106,19 +1671,19 @@ const CatInput = /*@__PURE__*/ proxyCustomElement(class CatInput extends HTMLEle
|
|
|
106
1671
|
}
|
|
107
1672
|
}
|
|
108
1673
|
render() {
|
|
109
|
-
return (h("div", { key: '
|
|
1674
|
+
return (h("div", { key: 'aab57f9704562874b2dee392630c473fc31a33cb', class: {
|
|
110
1675
|
'input-field': true,
|
|
111
1676
|
'input-horizontal': this.horizontal
|
|
112
|
-
} }, h("div", { key: '
|
|
1677
|
+
} }, h("div", { key: 'f599b443389362d9eb3ee72d496d225ca2a8bf8d', class: { 'label-container': true, hidden: this.labelHidden } }, (this.hasSlottedLabel || this.label) && (h("label", { htmlFor: this.id, part: "label" }, h("span", { class: "label-wrapper" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label, h("div", { class: "label-metadata" }, !this.required && (this.requiredMarker ?? 'optional').startsWith('optional') && (h("span", { class: "label-optional", "aria-hidden": "true" }, "(", catI18nRegistry.t('input.optional'), ")")), this.required && this.requiredMarker?.startsWith('required') && (h("span", { class: "label-optional", "aria-hidden": "true" }, "(", catI18nRegistry.t('input.required'), ")")), this.maxLength && (h("div", { class: "label-character-count", "aria-hidden": "true" }, this.value?.toString().length ?? 0, "/", this.maxLength))))))), h("div", { key: 'ddce0aaa854e32ae4b8a8686a3886089beac6300', class: "input-container" }, h("div", { key: '25eb9aa776ba2cee97fb2bf79bc52d5c44c54b55', class: "input-outer-wrapper" }, h("div", { key: '7cd420c3525b8e15a7c0f2d8405cdd70f2e5291c', class: {
|
|
113
1678
|
'input-wrapper': true,
|
|
114
1679
|
'input-round': this.round,
|
|
115
1680
|
'input-readonly': this.readonly,
|
|
116
1681
|
'input-disabled': this.disabled,
|
|
117
1682
|
'input-invalid': this.invalid
|
|
118
|
-
}, onClick: () => this.input.focus() }, this.textPrefix && (h("span", { class: "text-prefix", part: "prefix" }, this.textPrefix)), this.icon && !this.iconRight && (h("cat-icon", { icon: this.icon, class: "icon-prefix", size: "l", onClick: () => this.doFocus() })), h("div", { key: '
|
|
1683
|
+
}, onClick: () => this.input.focus() }, this.textPrefix && (h("span", { class: "text-prefix", part: "prefix" }, this.textPrefix)), this.icon && !this.iconRight && (h("cat-icon", { icon: this.icon, class: "icon-prefix", size: "l", onClick: () => this.doFocus() })), h("div", { key: '7f0c24c572ddfb4a1f76457955b28c111c1b444a', class: "input-inner-wrapper" }, h("input", { key: 'fcef418a1eb7c5d54f47e239f8db0cf52f23d3f7', ...this.nativeAttributes, part: "input", ref: el => (this.input = el), id: this.id, class: {
|
|
119
1684
|
'has-clearable': this.clearable && !this.disabled && !this.readonly && !!this.value,
|
|
120
1685
|
'has-toggle-password': this.togglePassword && !this.disabled && !this.readonly && !!this.value
|
|
121
|
-
}, autocomplete: this.autoComplete, disabled: this.disabled, max: this.max, maxlength: this.maxLength, min: this.min, minlength: this.minLength, name: this.name, placeholder: this.placeholder, readonly: this.readonly, required: this.required, type: this.isPasswordShown ? 'text' : this.type, value: this.value, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this), "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.hasHint ? this.id + '-hint' : undefined }), this.clearable && !this.disabled && !this.readonly && this.value && (h("cat-button", { class: "clearable", icon: "$cat:input-close", "icon-only": "true", size: "s", variant: "text", "a11y-label": catI18nRegistry.t('input.clear'), onClick: this.clear.bind(this), "data-dropdown-no-close": true })), this.togglePassword && !this.disabled && !this.readonly && this.value && (h("cat-button", { class: "toggle-password", icon: this.isPasswordShown ? '$cat:input-password-hide' : '$cat:input-password-show', "icon-only": "true", size: "s", variant: "text", "a11y-label": catI18nRegistry.t(this.isPasswordShown ? 'input.hidePassword' : 'input.showPassword'), onClick: this.doTogglePassword.bind(this) }))), !this.invalid && this.icon && this.iconRight && (h("cat-icon", { icon: this.icon, class: "icon-suffix", size: "l", onClick: () => this.doFocus() })), this.invalid && h("cat-icon", { icon: "$cat:input-error", class: "icon-suffix cat-text-danger", size: "l" }), this.textSuffix && (h("span", { class: "text-suffix", part: "suffix" }, this.textSuffix))), this.hasHint && (h(CatFormHint, { id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }), errorMap: this.errorMap })))));
|
|
1686
|
+
}, autocomplete: this.autoComplete, disabled: this.disabled, max: this.max, maxlength: this.maxLength, min: this.min, minlength: this.minLength, name: this.name, placeholder: this.placeholder, readonly: this.readonly, required: this.required, type: this.isPasswordShown ? 'text' : this.type, value: this.value, onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this), "aria-invalid": this.invalid ? 'true' : undefined, "aria-describedby": this.hasHint ? this.id + '-hint' : undefined }), this.clearable && !this.disabled && !this.readonly && this.value && (h("cat-button", { class: "clearable", icon: "$cat:input-close", "icon-only": "true", size: "s", variant: "text", "a11y-label": catI18nRegistry.t('input.clear'), onClick: this.clear.bind(this), "data-dropdown-no-close": true })), this.togglePassword && !this.disabled && !this.readonly && this.value && (h("cat-button", { class: "toggle-password", icon: this.isPasswordShown ? '$cat:input-password-hide' : '$cat:input-password-show', "icon-only": "true", size: "s", variant: "text", "a11y-label": catI18nRegistry.t(this.isPasswordShown ? 'input.hidePassword' : 'input.showPassword'), onClick: this.doTogglePassword.bind(this) }))), !this.invalid && this.icon && this.iconRight && (h("cat-icon", { icon: this.icon, class: "icon-suffix", size: "l", onClick: () => this.doFocus() })), this.invalid && (h("cat-icon", { icon: "$cat:input-error", class: "icon-suffix cat-text-danger", size: "l" })), this.textSuffix && (h("span", { class: "text-suffix", part: "suffix" }, this.textSuffix))), h("slot", { key: '3c3ff6368c631ae0634a7d0b875cb0d6a69edcba', name: "addon" })), this.hasHint && (h(CatFormHint, { id: this.id, hint: this.hint, slottedHint: this.hasSlottedHint && h("slot", { name: "hint" }), errorMap: this.errorMap })))));
|
|
122
1687
|
}
|
|
123
1688
|
get hasHint() {
|
|
124
1689
|
return !!this.hint || !!this.hasSlottedHint || this.invalid;
|
|
@@ -210,7 +1775,8 @@ const CatInput = /*@__PURE__*/ proxyCustomElement(class CatInput extends HTMLEle
|
|
|
210
1775
|
"errorMap": [32],
|
|
211
1776
|
"doFocus": [64],
|
|
212
1777
|
"doBlur": [64],
|
|
213
|
-
"clear": [64]
|
|
1778
|
+
"clear": [64],
|
|
1779
|
+
"mask": [64]
|
|
214
1780
|
}, undefined, {
|
|
215
1781
|
"errors": ["onErrorsChanged"]
|
|
216
1782
|
}]);
|