@globalpayments/vega 2.57.0 → 2.58.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/cjs/card-config-2ee5505e.js +65 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{string-input-formatter-slimmer-92ab034f.js → string-input-formatter-slimmer-dc1747ad.js} +20 -1
- package/dist/cjs/vega-calendar_3.cjs.entry.js +197 -114
- package/dist/cjs/vega-date-picker_2.cjs.entry.js +1 -1
- package/dist/cjs/vega-dropdown_5.cjs.entry.js +28 -4
- package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
- package/dist/cjs/vega-input-credit-card.cjs.entry.js +20 -116
- package/dist/cjs/vega-input-phone-number.cjs.entry.js +1 -1
- package/dist/cjs/vega-input-select.cjs.entry.js +6 -3
- package/dist/cjs/vega-input.cjs.entry.js +194 -2
- package/dist/cjs/vega-selection-tile_2.cjs.entry.js +26 -2
- package/dist/cjs/vega.cjs.js +1 -1
- package/dist/collection/components/vega-calendar/slimmers/common/controllers/vega-calendar-post-operation-date-controller.js +48 -0
- package/dist/collection/components/vega-calendar/slimmers/common/renderers/vega-calendar-switch-panel.js +8 -2
- package/dist/collection/components/vega-calendar/vega-calendar.js +42 -1
- package/dist/collection/components/vega-dropdown/vega-dropdown-item/slimmers/renderers/vega-dropdown-item-renderer.js +27 -3
- package/dist/collection/components/vega-dropdown/vega-dropdown-item/vega-dropdown-item.css +6 -0
- package/dist/collection/components/vega-input/slimmers/controllers/vega-input-mask-config-controller.js +25 -2
- package/dist/collection/components/vega-input/vega-input.js +1 -1
- package/dist/collection/components/vega-input-credit-card/vega-input-credit-card.js +13 -52
- package/dist/collection/components/vega-input-phone-number/vega-input-phone-number.css +4 -0
- package/dist/collection/components/vega-input-select/slimmers/renderers/vega-input-select-dropdown-renderer.js +5 -2
- package/dist/collection/components/vega-input-select/vega-input-select.css +0 -3
- package/dist/collection/components/vega-selection-tile/slimmers/controllers/vega-selection-tile-state-controller.js +7 -0
- package/dist/collection/components/vega-selection-tile/vega-selection-tile-group/vega-selection-tile-group.js +37 -0
- package/dist/collection/components/vega-selection-tile/vega-selection-tile.css +12 -0
- package/dist/collection/components/vega-selection-tile/vega-selection-tile.js +7 -2
- package/dist/collection/components/vega-table/vega-table-head-cell/vega-table-head-cell.js +1 -1
- package/dist/collection/components/vega-table/vega-table.js +1 -1
- package/dist/collection/constants/card-config.js +4 -4
- package/dist/collection/helpers/calendar/calendar-period/month-period.js +15 -1
- package/dist/collection/helpers/calendar/calendar-period/week-period.js +6 -7
- package/dist/collection/helpers/calendar/test/calendar-period/month-period.test.js +12 -4
- package/dist/collection/helpers/calendar/test/calendar-period/week-period.test.js +2 -2
- package/dist/collection/helpers/formatter/string-formatter/credit-card-blur-mask-strategy.js +74 -0
- package/dist/collection/helpers/formatter/string-formatter/credit-card-input-mask-strategy.js +34 -0
- package/dist/collection/helpers/formatter/string-formatter/credit-card-mask-strategy.abstract.js +63 -0
- package/dist/collection/helpers/formatter/string-formatter/string-format-strategy.abstract.js +4 -1
- package/dist/collection/helpers/formatter/string-formatter/string-mask-strategy.js +8 -0
- package/dist/collection/helpers/slimmers/string-input-formatter-slimmer.js +8 -0
- package/dist/esm/{app-globals-366415b3.js → app-globals-ee6a1250.js} +3 -3
- package/dist/esm/card-config-d2ad484e.js +63 -0
- package/dist/esm/{code-block-73869a3c.js → code-block-7bd4cb87.js} +1 -1
- package/dist/esm/{component-value-history-controller-slimmer.abstract-dfe89c93.js → component-value-history-controller-slimmer.abstract-41c58caf.js} +2 -2
- package/dist/esm/{content-state-953906e8.js → content-state-a43e703e.js} +1 -1
- package/dist/esm/{design-token-28a0a2e6.js → design-token-23522f5c.js} +1 -1
- package/dist/esm/{element-appender-slimmer-7b9f4a8e.js → element-appender-slimmer-042df95a.js} +2 -2
- package/dist/esm/{form-field-controller-slimmer-707a6da2.js → form-field-controller-slimmer-f0982f11.js} +2 -2
- package/dist/esm/{image-annotation-action-5bfda07c.js → image-annotation-action-1e88f5a0.js} +1 -1
- package/dist/esm/{index-3e551cbe.js → index-fb3b74bd.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/loader.js +6 -6
- package/dist/esm/{public-rules-c5d2c1e1.js → public-rules-287d4d77.js} +4 -4
- package/dist/esm/{responsive-format-facade-60731164.js → responsive-format-facade-d2632288.js} +1 -1
- package/dist/esm/{rich-text-editor-required-rule-4429066e.js → rich-text-editor-required-rule-69d5f035.js} +1 -1
- package/dist/esm/{string-input-formatter-slimmer-6ab5cad6.js → string-input-formatter-slimmer-09478e0d.js} +23 -4
- package/dist/esm/{style-formatter-57fc600a.js → style-formatter-f7951677.js} +1 -1
- package/dist/esm/{sub-state-notify-slimmer-1c4d1e78.js → sub-state-notify-slimmer-0a6c3cbb.js} +1 -1
- package/dist/esm/{sub-state-observer-slimmer-1e9af9ec.js → sub-state-observer-slimmer-53eec5fb.js} +1 -1
- package/dist/esm/vega-accordion.entry.js +5 -5
- package/dist/esm/vega-app-header-button.entry.js +5 -5
- package/dist/esm/vega-box.entry.js +6 -6
- package/dist/esm/vega-button-circle.entry.js +5 -5
- package/dist/esm/vega-button-group_2.entry.js +3 -3
- package/dist/esm/vega-button.entry.js +4 -4
- package/dist/esm/vega-calendar_3.entry.js +200 -117
- package/dist/esm/vega-card.entry.js +5 -5
- package/dist/esm/vega-carousel.entry.js +4 -4
- package/dist/esm/vega-checkbox_2.entry.js +3 -3
- package/dist/esm/vega-chip.entry.js +5 -5
- package/dist/esm/vega-code-block.entry.js +3 -3
- package/dist/esm/vega-color-picker.entry.js +3 -3
- package/dist/esm/vega-combo-box.entry.js +3 -3
- package/dist/esm/vega-date-picker_2.entry.js +9 -9
- package/dist/esm/vega-dialog_2.entry.js +5 -5
- package/dist/esm/vega-divider.entry.js +5 -5
- package/dist/esm/vega-dropdown_5.entry.js +35 -11
- package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
- package/dist/esm/vega-file-uploader.entry.js +3 -3
- package/dist/esm/vega-flag-icon.entry.js +5 -5
- package/dist/esm/vega-flex.entry.js +6 -6
- package/dist/esm/vega-font.entry.js +5 -5
- package/dist/esm/vega-form.entry.js +4 -4
- package/dist/esm/vega-grid.entry.js +5 -5
- package/dist/esm/vega-icon.entry.js +5 -5
- package/dist/esm/vega-image-uploader.entry.js +6 -6
- package/dist/esm/vega-input-credit-card.entry.js +21 -117
- package/dist/esm/vega-input-numeric.entry.js +4 -4
- package/dist/esm/vega-input-phone-number.entry.js +6 -6
- package/dist/esm/vega-input-range.entry.js +3 -3
- package/dist/esm/vega-input-select.entry.js +12 -9
- package/dist/esm/vega-input.entry.js +198 -6
- package/dist/esm/{vega-internal-event-id-f0ea2bab.js → vega-internal-event-id-4072659b.js} +1 -1
- package/dist/esm/vega-left-nav_5.entry.js +7 -7
- package/dist/esm/vega-loader-wrapper_2.entry.js +4 -4
- package/dist/esm/vega-pagination-page-selector-mobile.entry.js +1 -1
- package/dist/esm/vega-pagination-page-size-selector-mobile.entry.js +1 -1
- package/dist/esm/vega-pagination.entry.js +4 -4
- package/dist/esm/vega-popover_2.entry.js +5 -5
- package/dist/esm/vega-radio_2.entry.js +3 -3
- package/dist/esm/vega-rich-text-content.entry.js +6 -6
- package/dist/esm/vega-rich-text-editor_4.entry.js +10 -10
- package/dist/esm/vega-selection-chip_2.entry.js +7 -7
- package/dist/esm/vega-selection-tile_2.entry.js +30 -6
- package/dist/esm/vega-sidenav_3.entry.js +6 -6
- package/dist/esm/vega-signature-capture.entry.js +7 -7
- package/dist/esm/vega-stepper.entry.js +3 -3
- package/dist/esm/vega-table_8.entry.js +6 -6
- package/dist/esm/vega-textarea.entry.js +3 -3
- package/dist/esm/vega-time-picker_2.entry.js +7 -7
- package/dist/esm/vega-toggle-switch.entry.js +3 -3
- package/dist/esm/vega-tooltip_2.entry.js +5 -5
- package/dist/esm/vega.js +6 -6
- package/dist/types/components/vega-calendar/slimmers/common/controllers/vega-calendar-post-operation-date-controller.d.ts +23 -0
- package/dist/types/components/vega-calendar/slimmers/common/renderers/vega-calendar-switch-panel.d.ts +2 -0
- package/dist/types/components/vega-calendar/vega-calendar.d.ts +15 -1
- package/dist/types/components/vega-dropdown/vega-dropdown-item/slimmers/renderers/vega-dropdown-item-renderer.d.ts +4 -0
- package/dist/types/components/vega-input/slimmers/controllers/vega-input-mask-config-controller.d.ts +7 -0
- package/dist/types/components/vega-input/types.d.ts +10 -1
- package/dist/types/components/vega-input-credit-card/vega-input-credit-card.d.ts +1 -13
- package/dist/types/components/vega-selection-tile/slimmers/controllers/vega-selection-tile-state-controller.d.ts +1 -0
- package/dist/types/components/vega-selection-tile/vega-selection-tile-group/vega-selection-tile-group.d.ts +8 -0
- package/dist/types/components/vega-selection-tile/vega-selection-tile.d.ts +4 -0
- package/dist/types/components/vega-table/interface.d.ts +18 -11
- package/dist/types/components/vega-table/vega-table-head-cell/vega-table-head-cell.d.ts +1 -1
- package/dist/types/components/vega-table/vega-table.d.ts +1 -1
- package/dist/types/components.d.ts +24 -4
- package/dist/types/helpers/calendar/calendar-period/calendar-period.abstract.d.ts +3 -3
- package/dist/types/helpers/calendar/calendar-period/month-period.d.ts +7 -1
- package/dist/types/helpers/formatter/string-formatter/credit-card-blur-mask-strategy.d.ts +28 -0
- package/dist/types/helpers/formatter/string-formatter/credit-card-input-mask-strategy.d.ts +21 -0
- package/dist/types/helpers/formatter/string-formatter/credit-card-mask-strategy.abstract.d.ts +36 -0
- package/dist/types/helpers/formatter/string-formatter/string-format-strategy.abstract.d.ts +1 -1
- package/dist/types/helpers/formatter/string-formatter/string-mask-strategy.d.ts +9 -3
- package/dist/types/helpers/slimmers/string-input-formatter-slimmer.d.ts +4 -0
- package/dist/types/types/public-api.d.ts +1 -0
- package/dist/vega/index.esm.js +1 -1
- package/dist/vega/{p-6acf0a51.entry.js → p-083af15f.entry.js} +1 -1
- package/dist/vega/{p-75ff12da.entry.js → p-091ab617.entry.js} +1 -1
- package/dist/vega/{p-47e89c0e.entry.js → p-0b5330e1.entry.js} +1 -1
- package/dist/vega/{p-f4a7acff.entry.js → p-1a4f77de.entry.js} +1 -1
- package/dist/vega/{p-21a7530c.entry.js → p-1a6dacc7.entry.js} +1 -1
- package/dist/vega/{p-2ebef70f.entry.js → p-1db2ba98.entry.js} +1 -1
- package/dist/vega/{p-e277ea73.entry.js → p-1f9a735a.entry.js} +1 -1
- package/dist/vega/{p-44880bdf.entry.js → p-24042f0c.entry.js} +1 -1
- package/dist/vega/{p-e28fcf04.entry.js → p-27a9ad35.entry.js} +1 -1
- package/dist/vega/{p-0496f1cb.entry.js → p-27ec0c07.entry.js} +1 -1
- package/dist/vega/{p-27dca371.entry.js → p-317920e6.entry.js} +1 -1
- package/dist/vega/{p-a2ef3429.entry.js → p-376b3ec7.entry.js} +1 -1
- package/dist/vega/{p-dc16e6ba.entry.js → p-394594e9.entry.js} +1 -1
- package/dist/vega/{p-8fb5bcb0.entry.js → p-42ec43ef.entry.js} +1 -1
- package/dist/vega/{p-6e1b5949.js → p-43263510.js} +1 -1
- package/dist/vega/{p-29f4cbed.entry.js → p-435451be.entry.js} +1 -1
- package/dist/vega/p-472108bd.entry.js +1 -0
- package/dist/vega/{p-6131f229.entry.js → p-48ae6f02.entry.js} +1 -1
- package/dist/vega/{p-1c4d05de.entry.js → p-48b24fd3.entry.js} +1 -1
- package/dist/vega/{p-fb8c99c5.js → p-4a237308.js} +1 -1
- package/dist/vega/{p-5dec9bd9.entry.js → p-4ab67150.entry.js} +1 -1
- package/dist/vega/{p-d82ceacf.entry.js → p-4c4ac1a5.entry.js} +1 -1
- package/dist/vega/p-4fb159d5.js +1 -0
- package/dist/vega/p-5bd3487e.js +1 -0
- package/dist/vega/p-5f377954.js +1 -1
- package/dist/vega/{p-39049341.entry.js → p-5fe47fe8.entry.js} +1 -1
- package/dist/vega/{p-d5ab867e.entry.js → p-61ea2d75.entry.js} +1 -1
- package/dist/vega/{p-e32efc2e.entry.js → p-63adca7b.entry.js} +1 -1
- package/dist/vega/{p-7c0004dc.entry.js → p-699032fc.entry.js} +1 -1
- package/dist/vega/{p-0b77c6c9.entry.js → p-710da484.entry.js} +1 -1
- package/dist/vega/{p-007bf7df.js → p-71c65f7e.js} +1 -1
- package/dist/vega/{p-a92a8172.entry.js → p-81279fea.entry.js} +1 -1
- package/dist/vega/{p-ecd032fc.js → p-8782abeb.js} +1 -1
- package/dist/vega/p-88e08a33.js +1 -0
- package/dist/vega/{p-4f5eb8d5.js → p-8c4f893b.js} +1 -1
- package/dist/vega/p-8e2b1dae.entry.js +1 -0
- package/dist/vega/{p-2873b600.entry.js → p-8f8de5ab.entry.js} +1 -1
- package/dist/vega/p-92355996.entry.js +1 -0
- package/dist/vega/p-9540e3ed.entry.js +1 -0
- package/dist/vega/p-997a2064.entry.js +1 -0
- package/dist/vega/{p-ce14af16.js → p-9a956a00.js} +1 -1
- package/dist/vega/{p-fcb04960.js → p-9afdcf65.js} +1 -1
- package/dist/vega/p-9b08ed46.entry.js +1 -0
- package/dist/vega/{p-b44ebc84.entry.js → p-9ce0bd82.entry.js} +1 -1
- package/dist/vega/{p-f8f8e7d2.entry.js → p-a04491cc.entry.js} +1 -1
- package/dist/vega/{p-99c4559e.entry.js → p-a1056063.entry.js} +1 -1
- package/dist/vega/{p-b449fe9a.entry.js → p-a4a0fcfd.entry.js} +1 -1
- package/dist/vega/{p-f79c82c7.entry.js → p-a7042a5a.entry.js} +1 -1
- package/dist/vega/p-acf7667e.entry.js +1 -0
- package/dist/vega/{p-8ba8a7cc.entry.js → p-b21b128c.entry.js} +1 -1
- package/dist/vega/{p-766ed063.entry.js → p-b75a8edb.entry.js} +1 -1
- package/dist/vega/{p-1e3f4007.entry.js → p-c21295cf.entry.js} +1 -1
- package/dist/vega/{p-5130bb06.entry.js → p-c69a6547.entry.js} +1 -1
- package/dist/vega/{p-79c2282c.entry.js → p-c9740710.entry.js} +1 -1
- package/dist/vega/{p-f4546425.entry.js → p-ce5a3589.entry.js} +1 -1
- package/dist/vega/{p-cd3d468c.js → p-d1355307.js} +1 -1
- package/dist/vega/{p-07927476.entry.js → p-d661a5aa.entry.js} +1 -1
- package/dist/vega/{p-8246f8ae.js → p-d7e0c57a.js} +1 -1
- package/dist/vega/p-e1ed78db.js +1 -0
- package/dist/vega/{p-34643550.entry.js → p-ef84dc90.entry.js} +1 -1
- package/dist/vega/{p-2458ad97.js → p-f229d6d1.js} +1 -1
- package/dist/vega/{p-fd2f699b.js → p-f25570f5.js} +1 -1
- package/dist/vega/{p-888dc143.entry.js → p-f27fcc7c.entry.js} +1 -1
- package/dist/vega/{p-f3f7d059.entry.js → p-f543e911.entry.js} +1 -1
- package/dist/vega/{p-65d8c2bc.js → p-f5ac60f5.js} +1 -1
- package/dist/vega/{p-bdaf1143.entry.js → p-f7b5833d.entry.js} +1 -1
- package/dist/vega/p-fc02a67a.js +1 -0
- package/dist/vega/{p-a33c6652.entry.js → p-fcb5b40f.entry.js} +1 -1
- package/dist/vega/{p-aed3320d.js → p-fda6f8bc.js} +1 -1
- package/dist/vega/{p-e5196440.entry.js → p-fe1512f9.entry.js} +1 -1
- package/dist/vega/vega.esm.js +1 -1
- package/package.json +1 -1
- package/dist/vega/p-0604563a.entry.js +0 -1
- package/dist/vega/p-3a7e897b.entry.js +0 -1
- package/dist/vega/p-51297b96.js +0 -1
- package/dist/vega/p-51a4dc20.entry.js +0 -1
- package/dist/vega/p-53e9595f.js +0 -1
- package/dist/vega/p-6ec338b0.entry.js +0 -1
- package/dist/vega/p-76818196.entry.js +0 -1
- package/dist/vega/p-79a0a06c.js +0 -1
- package/dist/vega/p-9481c073.entry.js +0 -1
- package/dist/vega/p-b8d7d4a9.js +0 -1
- package/dist/vega/p-f8e0e4f0.entry.js +0 -1
|
@@ -22,7 +22,6 @@ import { VegaInternalIconManager } from '../../helpers/icon/internal-icon-manage
|
|
|
22
22
|
import { FeatureFlag } from '../../helpers/feature-control/feature-flag-controller';
|
|
23
23
|
import { VegaComponentUsageRuntimeMetricsSlimmer } from '../../helpers/slimmers/component-usage-runtime-metrics';
|
|
24
24
|
import { VegaInputCreditCardRuntimeMetricsPayloadDefinition } from '../../constants/runtime-metrics-payload-definition/vega-input-credit-card/runtime-metrics-payload-definition';
|
|
25
|
-
import { VegaInternalPasteEvent } from '../../helpers/event-manager/event-id/vega-internal-event-id';
|
|
26
25
|
/**
|
|
27
26
|
* @vegaVersion 1.26.0
|
|
28
27
|
*/
|
|
@@ -51,17 +50,6 @@ export class VegaInputCreditCard {
|
|
|
51
50
|
this.focusEventEmitter = createEventEmitSlimmer(VegaInputCreditCard, VegaFocus);
|
|
52
51
|
this.inputCreditCardEventPrevent = new ChildNodesEventPreventSlimmer([VegaChange, VegaFocus, VegaBlur], () => this.host, true);
|
|
53
52
|
this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer(VegaInputCreditCardRuntimeMetricsPayloadDefinition);
|
|
54
|
-
this.maskConfig = {
|
|
55
|
-
type: 'custom',
|
|
56
|
-
options: {
|
|
57
|
-
mask: '',
|
|
58
|
-
slot: '9',
|
|
59
|
-
accept: /[\d\s]/,
|
|
60
|
-
insertMode: false,
|
|
61
|
-
triggerAtInit: FeatureFlag.isEnabled('VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD'),
|
|
62
|
-
},
|
|
63
|
-
trigger: 'blur',
|
|
64
|
-
};
|
|
65
53
|
/**
|
|
66
54
|
* Specifies whether a card number must be entered for
|
|
67
55
|
* this component to pass form validation.
|
|
@@ -149,7 +137,7 @@ export class VegaInputCreditCard {
|
|
|
149
137
|
this.renderInputContainer = () => {
|
|
150
138
|
var _a;
|
|
151
139
|
const iconName = ((_a = this.getCreditCardType(this.value)) === null || _a === void 0 ? void 0 : _a.iconName) || 'regular-credit-card';
|
|
152
|
-
return (h("vega-input", { label: this.label, type: "number", prefixIcon: VegaInternalIconManager.getIconKey(iconName), maskConfig: this.getMaskConfig(
|
|
140
|
+
return (h("vega-input", { label: this.label, type: "number", prefixIcon: VegaInternalIconManager.getIconKey(iconName), maskConfig: this.getMaskConfig(), placeholder: this.placeholder, disabled: this.disabled, size: this.size, value: this.value, hint: this.hint, required: this.required, showClearIcon: false, ref: (ref) => {
|
|
153
141
|
this.inputRef = ref;
|
|
154
142
|
DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaChange, (input) => {
|
|
155
143
|
this.handleVegaChange(input);
|
|
@@ -160,10 +148,6 @@ export class VegaInputCreditCard {
|
|
|
160
148
|
DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaFocus, () => {
|
|
161
149
|
this.handleVegaFocus();
|
|
162
150
|
});
|
|
163
|
-
DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, VegaInternalPasteEvent, (event) => {
|
|
164
|
-
const pastedValue = event.clipboardData.getData('text');
|
|
165
|
-
this.inputRef.maskConfig = this.getMaskConfig(pastedValue); // The mask should be updated before the value changed.
|
|
166
|
-
});
|
|
167
151
|
} }));
|
|
168
152
|
};
|
|
169
153
|
this.handleVegaChange = (e) => {
|
|
@@ -207,41 +191,18 @@ export class VegaInputCreditCard {
|
|
|
207
191
|
getCreditCardType(value) {
|
|
208
192
|
return CARDS_INFO.filter((card) => card.pattern.test(value))[0];
|
|
209
193
|
}
|
|
210
|
-
getMaskConfig(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* The below method is e2e-test covered in
|
|
224
|
-
* @see{module:vega-input-credit-card-dynamic-mask-e2e}
|
|
225
|
-
*/
|
|
226
|
-
/* istanbul ignore next */
|
|
227
|
-
/** Transform the input card number with dynamic card number mask, for example: '4111 2222 3333 44' will be transformed to 'XXXX XXXX XXXX 99' */
|
|
228
|
-
generateDynamicMask() {
|
|
229
|
-
const cardNumberSplit = this.value.trim().split(' ');
|
|
230
|
-
const cardNumberMask = this.maskCardNumber(cardNumberSplit).join(' ');
|
|
231
|
-
return cardNumberMask;
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* The below method is e2e-test covered in
|
|
235
|
-
* @see{module:vega-input-credit-card-dynamic-mask-e2e}
|
|
236
|
-
*/
|
|
237
|
-
/* istanbul ignore next */
|
|
238
|
-
maskCardNumber(cardNumberSplit) {
|
|
239
|
-
// Map through the array and replace each character with 'X' or '9' depending on the index
|
|
240
|
-
return cardNumberSplit.map((element, index) => {
|
|
241
|
-
// Replace each character in the string with 'X' except the last element, which uses '9'
|
|
242
|
-
const replacementChar = index === cardNumberSplit.length - 1 ? '9' : 'X';
|
|
243
|
-
return replacementChar.repeat(element.length);
|
|
244
|
-
});
|
|
194
|
+
getMaskConfig() {
|
|
195
|
+
return [
|
|
196
|
+
{
|
|
197
|
+
type: 'credit-card',
|
|
198
|
+
trigger: 'input',
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
type: 'credit-card',
|
|
202
|
+
trigger: 'blur',
|
|
203
|
+
hideCardNumberOnBlur: this.hideCardNumberOnBlur,
|
|
204
|
+
},
|
|
205
|
+
];
|
|
245
206
|
}
|
|
246
207
|
static get is() { return "vega-input-credit-card"; }
|
|
247
208
|
static get encapsulation() { return "shadow"; }
|
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
padding-right: 8px;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
.vega-input-phone-number-container vega-input-select {
|
|
19
|
+
white-space: nowrap;
|
|
20
|
+
}
|
|
21
|
+
|
|
18
22
|
:host .vega-input-phone-number-container.error vega-input::part(input-container) {
|
|
19
23
|
border: 1px solid rgba(var(--v-border-input-field-danger, 230, 50, 87, 1));
|
|
20
24
|
}
|
|
@@ -35,7 +35,9 @@ export class VegaInputSelectDropdownRenderer extends VegaSlimmer {
|
|
|
35
35
|
};
|
|
36
36
|
this.renderMultipleSelected = () => {
|
|
37
37
|
if (this.value.length > 0) {
|
|
38
|
-
|
|
38
|
+
const selectedLabelStr = this.selectedLabel(this.value);
|
|
39
|
+
return (h("span", { class: "vega-input-select-selected" },
|
|
40
|
+
h("vega-text", { overflow: "ellipsis", tooltip: { placement: 'bottom' }, key: selectedLabelStr }, selectedLabelStr)));
|
|
39
41
|
}
|
|
40
42
|
else {
|
|
41
43
|
return (h("div", { class: "vega-input-select-placeholder" }, this.translationSlimmer.t(this.placeholder)));
|
|
@@ -44,7 +46,8 @@ export class VegaInputSelectDropdownRenderer extends VegaSlimmer {
|
|
|
44
46
|
this.renderSingleSelected = () => {
|
|
45
47
|
const item = this.sourceController.getItem(this.value);
|
|
46
48
|
if (item) {
|
|
47
|
-
return (h("span", { class: "vega-input-select-selected", part: "selected-box" },
|
|
49
|
+
return (h("span", { class: "vega-input-select-selected", part: "selected-box" },
|
|
50
|
+
h("vega-text", { overflow: "ellipsis", tooltip: { placement: 'bottom' }, key: item.displayName }, item.displayName)));
|
|
48
51
|
}
|
|
49
52
|
else {
|
|
50
53
|
return (h("div", { class: "vega-input-select-placeholder", part: "placeholder" }, this.translationSlimmer.t(this.placeholder)));
|
|
@@ -49,6 +49,10 @@ export class VegaSelectionTileStateController extends SubStateObserverSlimmer {
|
|
|
49
49
|
: groupValue === this.value);
|
|
50
50
|
},
|
|
51
51
|
},
|
|
52
|
+
{
|
|
53
|
+
subStateName: 'distributeEvenly',
|
|
54
|
+
parentStateName: 'distributeEvenly',
|
|
55
|
+
},
|
|
52
56
|
],
|
|
53
57
|
});
|
|
54
58
|
}
|
|
@@ -71,3 +75,6 @@ __decorate([
|
|
|
71
75
|
__decorate([
|
|
72
76
|
MapToComponentField()
|
|
73
77
|
], VegaSelectionTileStateController.prototype, "checkedController", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
MapToComponentField({ writable: true })
|
|
80
|
+
], VegaSelectionTileStateController.prototype, "distributeEvenly", void 0);
|
|
@@ -47,6 +47,7 @@ export class VegaSelectionTileGroup {
|
|
|
47
47
|
this.selectTypeNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'selectType', 'watchSelectType');
|
|
48
48
|
this.disabledNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'disabled', 'watchDisabled');
|
|
49
49
|
this.valueNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'value', 'watchValue');
|
|
50
|
+
this.distributeEvenlyNotifySlimmer = createSubStateNotifySlimmer(VegaSelectionTileGroup, 'distributeEvenly', 'watchDistributeEvenly');
|
|
50
51
|
this.vegaComponentUsageRuntimeMetricsSlimmer = new VegaComponentUsageRuntimeMetricsSlimmer();
|
|
51
52
|
/**
|
|
52
53
|
* Specifies the label or title for the selection tile group.
|
|
@@ -56,6 +57,12 @@ export class VegaSelectionTileGroup {
|
|
|
56
57
|
* @vegaVersion 2.7.0
|
|
57
58
|
*/
|
|
58
59
|
this.label = '';
|
|
60
|
+
/**
|
|
61
|
+
* Distribute vega-selection-tile components evenly to always cover the entire available width of the vega-selection-tile-group
|
|
62
|
+
*
|
|
63
|
+
* @vegaVersion 2.58.0
|
|
64
|
+
*/
|
|
65
|
+
this.distributeEvenly = false;
|
|
59
66
|
/**
|
|
60
67
|
* Determines the selection method for the tile group. Options are:
|
|
61
68
|
*
|
|
@@ -96,6 +103,9 @@ export class VegaSelectionTileGroup {
|
|
|
96
103
|
/* eslint-disable-next-line @stencil/strict-mutable */
|
|
97
104
|
this.isValid = null;
|
|
98
105
|
}
|
|
106
|
+
watchDistributeEvenly() {
|
|
107
|
+
methodPlaceholder();
|
|
108
|
+
}
|
|
99
109
|
watchSelectType() {
|
|
100
110
|
methodPlaceholder();
|
|
101
111
|
}
|
|
@@ -161,6 +171,27 @@ export class VegaSelectionTileGroup {
|
|
|
161
171
|
"attribute": "hint",
|
|
162
172
|
"reflect": false
|
|
163
173
|
},
|
|
174
|
+
"distributeEvenly": {
|
|
175
|
+
"type": "boolean",
|
|
176
|
+
"mutable": false,
|
|
177
|
+
"complexType": {
|
|
178
|
+
"original": "boolean",
|
|
179
|
+
"resolved": "boolean",
|
|
180
|
+
"references": {}
|
|
181
|
+
},
|
|
182
|
+
"required": false,
|
|
183
|
+
"optional": false,
|
|
184
|
+
"docs": {
|
|
185
|
+
"tags": [{
|
|
186
|
+
"name": "vegaVersion",
|
|
187
|
+
"text": "2.58.0"
|
|
188
|
+
}],
|
|
189
|
+
"text": "Distribute vega-selection-tile components evenly to always cover the entire available width of the vega-selection-tile-group"
|
|
190
|
+
},
|
|
191
|
+
"attribute": "distribute-evenly",
|
|
192
|
+
"reflect": false,
|
|
193
|
+
"defaultValue": "false"
|
|
194
|
+
},
|
|
164
195
|
"selectType": {
|
|
165
196
|
"type": "string",
|
|
166
197
|
"mutable": false,
|
|
@@ -352,6 +383,9 @@ export class VegaSelectionTileGroup {
|
|
|
352
383
|
}]; }
|
|
353
384
|
static get elementRef() { return "host"; }
|
|
354
385
|
static get watchers() { return [{
|
|
386
|
+
"propName": "distributeEvenly",
|
|
387
|
+
"methodName": "watchDistributeEvenly"
|
|
388
|
+
}, {
|
|
355
389
|
"propName": "selectType",
|
|
356
390
|
"methodName": "watchSelectType"
|
|
357
391
|
}, {
|
|
@@ -398,6 +432,9 @@ __decorate([
|
|
|
398
432
|
__decorate([
|
|
399
433
|
InjectVegaSlimmer()
|
|
400
434
|
], VegaSelectionTileGroup.prototype, "valueNotifySlimmer", void 0);
|
|
435
|
+
__decorate([
|
|
436
|
+
InjectVegaSlimmer()
|
|
437
|
+
], VegaSelectionTileGroup.prototype, "distributeEvenlyNotifySlimmer", void 0);
|
|
401
438
|
__decorate([
|
|
402
439
|
InjectVegaSlimmer()
|
|
403
440
|
], VegaSelectionTileGroup.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
|
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
* Deprecated. Not for use in new websites.
|
|
4
4
|
* https://developer.mozilla.org/en-US/docs/Web/CSS/word-break#break-word
|
|
5
5
|
*/
|
|
6
|
+
:host::not(.distribute-evenly) {
|
|
7
|
+
display: block;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:host(.distribute-evenly) {
|
|
11
|
+
display: flex;
|
|
12
|
+
width: 100%;
|
|
13
|
+
}
|
|
14
|
+
:host(.distribute-evenly) .selection-tile {
|
|
15
|
+
flex: 1;
|
|
16
|
+
}
|
|
17
|
+
|
|
6
18
|
:host {
|
|
7
19
|
display: block;
|
|
8
20
|
}
|
|
@@ -40,6 +40,10 @@ export class VegaSelectionTile {
|
|
|
40
40
|
* Indicates whether the parent selection tile group shows error message.
|
|
41
41
|
*/
|
|
42
42
|
this.showError = false;
|
|
43
|
+
/**
|
|
44
|
+
* Distribute vega-selection-tile components evenly to always cover the entire available width of the parent
|
|
45
|
+
*/
|
|
46
|
+
this.distributeEvenly = false;
|
|
43
47
|
/**
|
|
44
48
|
* Specifies the text content of the title displayed
|
|
45
49
|
* within the selection tile.
|
|
@@ -68,7 +72,7 @@ export class VegaSelectionTile {
|
|
|
68
72
|
this.selectType = 'radio';
|
|
69
73
|
}
|
|
70
74
|
render() {
|
|
71
|
-
return sanitizeVegaComponent(h(Host,
|
|
75
|
+
return sanitizeVegaComponent(h(Host, { class: { 'distribute-evenly': this.distributeEvenly } }, this.renderer.render()), this.host);
|
|
72
76
|
}
|
|
73
77
|
static get is() { return "vega-selection-tile"; }
|
|
74
78
|
static get encapsulation() { return "shadow"; }
|
|
@@ -224,7 +228,8 @@ export class VegaSelectionTile {
|
|
|
224
228
|
}
|
|
225
229
|
}; }
|
|
226
230
|
static get states() { return {
|
|
227
|
-
"showError": {}
|
|
231
|
+
"showError": {},
|
|
232
|
+
"distributeEvenly": {}
|
|
228
233
|
}; }
|
|
229
234
|
static get events() { return [{
|
|
230
235
|
"method": "vegaChange",
|
|
@@ -6,7 +6,7 @@ export const CARDS_INFO = [
|
|
|
6
6
|
iconName: 'visa',
|
|
7
7
|
pattern: VisaRegex,
|
|
8
8
|
maskConfig: {
|
|
9
|
-
type: '
|
|
9
|
+
type: 'credit-card',
|
|
10
10
|
options: {
|
|
11
11
|
mask: '9999 9999 9999 9999 999',
|
|
12
12
|
slot: '9',
|
|
@@ -20,7 +20,7 @@ export const CARDS_INFO = [
|
|
|
20
20
|
iconName: 'mastercard',
|
|
21
21
|
pattern: MasterCardRegex,
|
|
22
22
|
maskConfig: {
|
|
23
|
-
type: '
|
|
23
|
+
type: 'credit-card',
|
|
24
24
|
options: {
|
|
25
25
|
mask: '9999 9999 9999 9999',
|
|
26
26
|
slot: '9',
|
|
@@ -34,7 +34,7 @@ export const CARDS_INFO = [
|
|
|
34
34
|
iconName: 'amex',
|
|
35
35
|
pattern: AmexRegex,
|
|
36
36
|
maskConfig: {
|
|
37
|
-
type: '
|
|
37
|
+
type: 'credit-card',
|
|
38
38
|
options: {
|
|
39
39
|
mask: '9999 999999 99999',
|
|
40
40
|
slot: '9',
|
|
@@ -48,7 +48,7 @@ export const CARDS_INFO = [
|
|
|
48
48
|
iconName: 'discover',
|
|
49
49
|
pattern: DiscoverRegex,
|
|
50
50
|
maskConfig: {
|
|
51
|
-
type: '
|
|
51
|
+
type: 'credit-card',
|
|
52
52
|
options: {
|
|
53
53
|
mask: '9999 9999 9999 9999',
|
|
54
54
|
slot: '9',
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { CalendarPeriod } from './calendar-period.abstract';
|
|
2
2
|
import { CalendarDate } from '../calendar-date';
|
|
3
|
+
import { getWeekdays } from '../utils';
|
|
3
4
|
/**
|
|
4
5
|
* Period of month
|
|
5
6
|
*/
|
|
6
7
|
export class MonthPeriod extends CalendarPeriod {
|
|
7
8
|
constructor(current, showWeekends) {
|
|
8
|
-
super(MonthPeriod.DISPLAY_DATE_COUNT,
|
|
9
|
+
super(MonthPeriod.DISPLAY_DATE_COUNT, current);
|
|
9
10
|
this._type = 'month';
|
|
10
11
|
this._showWeekends = true;
|
|
11
12
|
this._showWeekends = showWeekends === false ? false : true;
|
|
@@ -24,6 +25,19 @@ export class MonthPeriod extends CalendarPeriod {
|
|
|
24
25
|
const date = calendarDate || CalendarDate.from(new Date());
|
|
25
26
|
return new CalendarDate(date.year, date.month, 1);
|
|
26
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Calculate the period start date and end date.
|
|
30
|
+
*
|
|
31
|
+
* @param {CalendarDate} date - The date to calculate the period from.
|
|
32
|
+
*/
|
|
33
|
+
calculatePeriod(date) {
|
|
34
|
+
const firstDay = MonthPeriod.getMonthFirstDay(date);
|
|
35
|
+
const cursor = firstDay.toDate();
|
|
36
|
+
cursor.setDate(cursor.getDate() - getWeekdays().indexOf(cursor.getDay()));
|
|
37
|
+
this._startDate = CalendarDate.from(cursor);
|
|
38
|
+
cursor.setDate(cursor.getDate() + this.count - 1);
|
|
39
|
+
this._endDate = CalendarDate.from(cursor);
|
|
40
|
+
}
|
|
27
41
|
/**
|
|
28
42
|
* @inheritDoc
|
|
29
43
|
*/
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CalendarPeriod } from './calendar-period.abstract';
|
|
2
|
-
import { getWeekdays } from '../utils';
|
|
3
2
|
import { CalendarDate } from '../calendar-date';
|
|
4
3
|
/**
|
|
5
4
|
* Period of the week
|
|
@@ -15,17 +14,17 @@ export class WeekPeriod extends CalendarPeriod {
|
|
|
15
14
|
* @inheritDoc
|
|
16
15
|
*/
|
|
17
16
|
next() {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
return this.createBy(CalendarDate.from(
|
|
17
|
+
const currentDate = this.current.toDate();
|
|
18
|
+
currentDate.setDate(currentDate.getDate() + 7);
|
|
19
|
+
return this.createBy(CalendarDate.from(currentDate));
|
|
21
20
|
}
|
|
22
21
|
/**
|
|
23
22
|
* @inheritDoc
|
|
24
23
|
*/
|
|
25
24
|
previous() {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
return this.createBy(CalendarDate.from(
|
|
25
|
+
const currentDate = this.current.toDate();
|
|
26
|
+
currentDate.setDate(currentDate.getDate() - 7);
|
|
27
|
+
return this.createBy(CalendarDate.from(currentDate));
|
|
29
28
|
}
|
|
30
29
|
/**
|
|
31
30
|
* @inheritDoc
|
|
@@ -12,7 +12,7 @@ describe('month-period', () => {
|
|
|
12
12
|
const { current, count, startDate, endDate } = new MonthPeriod();
|
|
13
13
|
expect({ current, count, startDate, endDate }).toEqual({
|
|
14
14
|
count: 42,
|
|
15
|
-
current: new CalendarDate(2020, 4,
|
|
15
|
+
current: new CalendarDate(2020, 4, 3),
|
|
16
16
|
startDate: new CalendarDate(2020, 3, 29),
|
|
17
17
|
endDate: new CalendarDate(2020, 5, 9),
|
|
18
18
|
});
|
|
@@ -32,7 +32,7 @@ describe('month-period', () => {
|
|
|
32
32
|
const { current, count, startDate, endDate } = monthPeriod.now();
|
|
33
33
|
expect({ current, count, startDate, endDate }).toEqual({
|
|
34
34
|
count: 42,
|
|
35
|
-
current: new CalendarDate(2020, 4,
|
|
35
|
+
current: new CalendarDate(2020, 4, 3),
|
|
36
36
|
startDate: new CalendarDate(2020, 3, 29),
|
|
37
37
|
endDate: new CalendarDate(2020, 5, 9),
|
|
38
38
|
});
|
|
@@ -42,7 +42,7 @@ describe('month-period', () => {
|
|
|
42
42
|
const { current, count, startDate, endDate } = monthPeriod.next();
|
|
43
43
|
expect({ current, count, startDate, endDate }).toEqual({
|
|
44
44
|
count: 42,
|
|
45
|
-
current: new CalendarDate(2020, 5,
|
|
45
|
+
current: new CalendarDate(2020, 5, 3),
|
|
46
46
|
startDate: new CalendarDate(2020, 4, 26),
|
|
47
47
|
endDate: new CalendarDate(2020, 6, 6),
|
|
48
48
|
});
|
|
@@ -52,9 +52,17 @@ describe('month-period', () => {
|
|
|
52
52
|
const { current, count, startDate, endDate } = monthPeriod.previous();
|
|
53
53
|
expect({ current, count, startDate, endDate }).toEqual({
|
|
54
54
|
count: 42,
|
|
55
|
-
current: new CalendarDate(2020, 3,
|
|
55
|
+
current: new CalendarDate(2020, 3, 3),
|
|
56
56
|
startDate: new CalendarDate(2020, 3, 1),
|
|
57
57
|
endDate: new CalendarDate(2020, 4, 11),
|
|
58
58
|
});
|
|
59
59
|
});
|
|
60
|
+
it('should work when get month first day', () => {
|
|
61
|
+
const { year, month, date } = MonthPeriod.getMonthFirstDay();
|
|
62
|
+
expect({ year, month, date }).toEqual({
|
|
63
|
+
year: 2020,
|
|
64
|
+
month: 4,
|
|
65
|
+
date: 1,
|
|
66
|
+
});
|
|
67
|
+
});
|
|
60
68
|
});
|
|
@@ -42,7 +42,7 @@ describe('week-period', () => {
|
|
|
42
42
|
const { current, count, startDate, endDate } = weekPeriod.next();
|
|
43
43
|
expect({ current, count, startDate, endDate }).toEqual({
|
|
44
44
|
count: 7,
|
|
45
|
-
current: new CalendarDate(2020, 4,
|
|
45
|
+
current: new CalendarDate(2020, 4, 10),
|
|
46
46
|
startDate: new CalendarDate(2020, 4, 5),
|
|
47
47
|
endDate: new CalendarDate(2020, 4, 11),
|
|
48
48
|
});
|
|
@@ -52,7 +52,7 @@ describe('week-period', () => {
|
|
|
52
52
|
const { current, count, startDate, endDate } = weekPeriod.previous();
|
|
53
53
|
expect({ current, count, startDate, endDate }).toEqual({
|
|
54
54
|
count: 7,
|
|
55
|
-
current: new CalendarDate(2020, 3,
|
|
55
|
+
current: new CalendarDate(2020, 3, 27),
|
|
56
56
|
startDate: new CalendarDate(2020, 3, 22),
|
|
57
57
|
endDate: new CalendarDate(2020, 3, 28),
|
|
58
58
|
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { FeatureFlag } from '../../feature-control/feature-flag-controller';
|
|
2
|
+
import { CreditCardMaskStrategy } from './credit-card-mask-strategy.abstract';
|
|
3
|
+
/**
|
|
4
|
+
* A class for formatting string with the given mask format
|
|
5
|
+
*
|
|
6
|
+
* @augments StringFormatStrategy
|
|
7
|
+
*/
|
|
8
|
+
export class CreditCardBlurMaskStrategy extends CreditCardMaskStrategy {
|
|
9
|
+
/**
|
|
10
|
+
* It creates a new instance of the Mask class.
|
|
11
|
+
*
|
|
12
|
+
* @param {boolean} hideCardNumberOnBlur - boolean
|
|
13
|
+
*/
|
|
14
|
+
constructor(hideCardNumberOnBlur) {
|
|
15
|
+
super({
|
|
16
|
+
mask: '',
|
|
17
|
+
slot: '9',
|
|
18
|
+
accept: /[\d\s]/,
|
|
19
|
+
insertMode: false,
|
|
20
|
+
triggerAtInit: FeatureFlag.isEnabled('VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD'),
|
|
21
|
+
});
|
|
22
|
+
this.hideCardNumberOnBlur = hideCardNumberOnBlur;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @inheritDoc
|
|
26
|
+
*/
|
|
27
|
+
getCreditCardMaskConfig(value) {
|
|
28
|
+
let maskConfig;
|
|
29
|
+
const creditCardType = this.getCreditCardType(value);
|
|
30
|
+
if (creditCardType) {
|
|
31
|
+
if (this.hideCardNumberOnBlur && value.trim().includes(' ')) {
|
|
32
|
+
maskConfig = this.generateDynamicMask(value);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return maskConfig;
|
|
36
|
+
}
|
|
37
|
+
/*
|
|
38
|
+
* The below method is e2e-test covered in
|
|
39
|
+
*
|
|
40
|
+
* @see{module:vega-input-credit-card-dynamic-mask-e2e}
|
|
41
|
+
*/
|
|
42
|
+
/* istanbul ignore next */
|
|
43
|
+
/**
|
|
44
|
+
* Transform the input card number with dynamic card number mask, for example: '4111 2222 3333 44' will be transformed to 'XXXX XXXX XXXX 99'
|
|
45
|
+
*
|
|
46
|
+
* @param {string} value - card number string
|
|
47
|
+
* @returns {MaskConfigType} - mask config type
|
|
48
|
+
*/
|
|
49
|
+
generateDynamicMask(value) {
|
|
50
|
+
const maskConfig = {
|
|
51
|
+
type: 'credit-card',
|
|
52
|
+
options: {
|
|
53
|
+
mask: '',
|
|
54
|
+
slot: '9',
|
|
55
|
+
accept: /[\d\s]/,
|
|
56
|
+
insertMode: false,
|
|
57
|
+
triggerAtInit: FeatureFlag.isEnabled('VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD'),
|
|
58
|
+
},
|
|
59
|
+
trigger: 'blur',
|
|
60
|
+
};
|
|
61
|
+
const cardNumberSplit = value.trim().split(' ');
|
|
62
|
+
const cardNumberMask =
|
|
63
|
+
// Map through the array and replace each character with 'X' or '9' depending on the index
|
|
64
|
+
cardNumberSplit
|
|
65
|
+
.map((element, index) => {
|
|
66
|
+
// Replace each character in the string with 'X' except the last element, which uses '9'
|
|
67
|
+
const replacementChar = index === cardNumberSplit.length - 1 ? '9' : 'X';
|
|
68
|
+
return replacementChar.repeat(element.length);
|
|
69
|
+
})
|
|
70
|
+
.join(' ');
|
|
71
|
+
maskConfig.options.mask = cardNumberMask;
|
|
72
|
+
return maskConfig;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { FeatureFlag } from '../../feature-control/feature-flag-controller';
|
|
2
|
+
import { CreditCardMaskStrategy } from './credit-card-mask-strategy.abstract';
|
|
3
|
+
/**
|
|
4
|
+
* A class for formatting string with the given mask format
|
|
5
|
+
*
|
|
6
|
+
* @augments StringFormatStrategy
|
|
7
|
+
*/
|
|
8
|
+
export class CreditCardInputMaskStrategy extends CreditCardMaskStrategy {
|
|
9
|
+
/**
|
|
10
|
+
* It creates a new instance of the Mask class.
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
super({
|
|
14
|
+
mask: '',
|
|
15
|
+
slot: '9',
|
|
16
|
+
accept: /\d/,
|
|
17
|
+
triggerAtInit: FeatureFlag.isEnabled('VEGA_INPUT_CREDIT_CARD.ENABLE_HIDE_NUMBER_MASK_ON_FIRST_LOAD'),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* get credit card mask config
|
|
22
|
+
*
|
|
23
|
+
* @param {string} value - card number string
|
|
24
|
+
* @returns {Nullable<MaskConfigType>} - mask config type
|
|
25
|
+
*/
|
|
26
|
+
getCreditCardMaskConfig(value) {
|
|
27
|
+
let maskConfig;
|
|
28
|
+
const creditCardType = this.getCreditCardType(value);
|
|
29
|
+
if (creditCardType) {
|
|
30
|
+
maskConfig = creditCardType.maskConfig;
|
|
31
|
+
}
|
|
32
|
+
return maskConfig;
|
|
33
|
+
}
|
|
34
|
+
}
|
package/dist/collection/helpers/formatter/string-formatter/credit-card-mask-strategy.abstract.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { CARDS_INFO } from '../../../constants/card-config';
|
|
2
|
+
import { isNonNullable } from '../../../types/type-guard';
|
|
3
|
+
import { StringMaskStrategy } from './string-mask-strategy';
|
|
4
|
+
/**
|
|
5
|
+
* Credit card mask strategy abstract class
|
|
6
|
+
*/
|
|
7
|
+
export class CreditCardMaskStrategy extends StringMaskStrategy {
|
|
8
|
+
/* istanbul ignore next */
|
|
9
|
+
/**
|
|
10
|
+
* Get the position of caret
|
|
11
|
+
*
|
|
12
|
+
* @param {string} input - The input string
|
|
13
|
+
* @param {number} caretPosition - The current position of caret
|
|
14
|
+
* @returns {Nullable<number>} The new position of caret
|
|
15
|
+
*/
|
|
16
|
+
calculateCaretPosition(input, caretPosition) {
|
|
17
|
+
if (!isNonNullable(caretPosition))
|
|
18
|
+
return null;
|
|
19
|
+
const maskConfigType = this.getCreditCardMaskConfig(input);
|
|
20
|
+
if (maskConfigType) {
|
|
21
|
+
if (input.length > this.getLengthLimit()) {
|
|
22
|
+
const exceededLength = input.length - this.getLengthLimit();
|
|
23
|
+
return caretPosition - exceededLength;
|
|
24
|
+
}
|
|
25
|
+
const startValue = input.substring(0, caretPosition);
|
|
26
|
+
const maskedStartValue = this.format(startValue);
|
|
27
|
+
return caretPosition + (maskedStartValue.length - startValue.length);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return caretPosition;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/* istanbul ignore next */
|
|
34
|
+
/**
|
|
35
|
+
* @inheritDoc
|
|
36
|
+
*/
|
|
37
|
+
format(input, inputStatus) {
|
|
38
|
+
const maskConfigType = this.getCreditCardMaskConfig(input);
|
|
39
|
+
if (maskConfigType) {
|
|
40
|
+
this.setMaskConfig(maskConfigType.options);
|
|
41
|
+
const caretPosition = inputStatus === null || inputStatus === void 0 ? void 0 : inputStatus.caretPosition;
|
|
42
|
+
if (input.length > this.getLengthLimit() && isNonNullable(caretPosition)) {
|
|
43
|
+
const rawValueArr = [...input];
|
|
44
|
+
const exceededLength = input.length - this.getLengthLimit();
|
|
45
|
+
rawValueArr.splice(caretPosition - exceededLength, exceededLength);
|
|
46
|
+
return rawValueArr.join('');
|
|
47
|
+
}
|
|
48
|
+
return this.replaceMaskWithMatchedInputSlots(input, this.getMatchedInputSlotValue(input));
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return input;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* get credit card type
|
|
56
|
+
*
|
|
57
|
+
* @param {string} value - card number string
|
|
58
|
+
* @returns {CardConfigType} - card type config
|
|
59
|
+
*/
|
|
60
|
+
getCreditCardType(value) {
|
|
61
|
+
return CARDS_INFO.filter((card) => card.pattern.test(value))[0];
|
|
62
|
+
}
|
|
63
|
+
}
|
package/dist/collection/helpers/formatter/string-formatter/string-format-strategy.abstract.js
CHANGED
|
@@ -12,7 +12,7 @@ export class StringFormatStrategy {
|
|
|
12
12
|
* @returns {boolean} - Whether the format should be applied
|
|
13
13
|
*/
|
|
14
14
|
canFormat(triggeredBy, target, inputStatus) {
|
|
15
|
-
if (triggeredBy === 'init') {
|
|
15
|
+
if (triggeredBy === 'init' || triggeredBy === 'change') {
|
|
16
16
|
if (target === 'component' && isNonNullable(inputStatus === null || inputStatus === void 0 ? void 0 : inputStatus.isBlurred)) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
@@ -23,6 +23,9 @@ export class StringFormatStrategy {
|
|
|
23
23
|
if (triggeredBy === 'input' && target === 'native-input') {
|
|
24
24
|
return true;
|
|
25
25
|
}
|
|
26
|
+
if (triggeredBy === 'change' && (target === 'component' || target === 'native-input')) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
26
29
|
if (triggeredBy === 'blur' && (inputStatus === null || inputStatus === void 0 ? void 0 : inputStatus.isBlurred)) {
|
|
27
30
|
if (target === 'component' && this.shouldOverrideComponentValueAfterBlur()) {
|
|
28
31
|
return true;
|