@globalpayments/vega 2.27.0 → 2.28.1
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/{app-globals-190595cc.js → app-globals-512d84f4.js} +1 -1
- package/dist/cjs/{form-field-controller-slimmer-ee984eb2.js → form-field-controller-slimmer-223f8ee3.js} +1 -1
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/{string-input-formatter-slimmer-fcfa5bb7.js → string-input-formatter-slimmer-79272527.js} +8 -13
- package/dist/cjs/{sub-state-observer-slimmer-832a4215.js → sub-state-observer-slimmer-36660092.js} +2 -2
- package/dist/cjs/{translation-slimmer-8ebf126d.js → translation-slimmer-83577cfd.js} +1 -1
- package/dist/cjs/vega-app-header-button.cjs.entry.js +1 -1
- package/dist/cjs/vega-button-circle.cjs.entry.js +1 -1
- package/dist/cjs/vega-button-group_2.cjs.entry.js +3 -3
- package/dist/cjs/vega-button.cjs.entry.js +1 -1
- package/dist/cjs/vega-calendar_3.cjs.entry.js +963 -838
- package/dist/cjs/vega-checkbox_2.cjs.entry.js +2 -2
- package/dist/cjs/vega-chip.cjs.entry.js +1 -1
- package/dist/cjs/vega-color-picker.cjs.entry.js +2 -2
- package/dist/cjs/vega-combo-box.cjs.entry.js +2 -2
- package/dist/cjs/vega-date-picker_2.cjs.entry.js +4 -4
- package/dist/cjs/vega-dropdown_5.cjs.entry.js +3 -3
- package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
- package/dist/cjs/vega-file-uploader.cjs.entry.js +3 -3
- package/dist/cjs/vega-form.cjs.entry.js +2 -2
- package/dist/cjs/vega-image-uploader.cjs.entry.js +3 -3
- package/dist/cjs/vega-input-credit-card.cjs.entry.js +2 -2
- package/dist/cjs/vega-input-phone-number.cjs.entry.js +2 -2
- package/dist/cjs/vega-input-range.cjs.entry.js +3 -3
- package/dist/cjs/vega-input-select.cjs.entry.js +3 -3
- package/dist/cjs/vega-input.cjs.entry.js +48 -16
- package/dist/cjs/vega-pagination.cjs.entry.js +2 -2
- package/dist/cjs/vega-radio_2.cjs.entry.js +2 -2
- package/dist/cjs/vega-selection-chip_2.cjs.entry.js +3 -3
- package/dist/cjs/vega-selection-tile_2.cjs.entry.js +3 -3
- package/dist/cjs/vega-signature-capture.cjs.entry.js +3 -3
- package/dist/cjs/vega-stepper.cjs.entry.js +2 -2
- package/dist/cjs/vega-table_8.cjs.entry.js +3 -3
- package/dist/cjs/vega-textarea.cjs.entry.js +2 -2
- package/dist/cjs/vega-time-picker_2.cjs.entry.js +3 -3
- package/dist/cjs/vega-toggle-switch.cjs.entry.js +2 -2
- package/dist/cjs/vega.cjs.js +3 -3
- package/dist/collection/components/vega-app-header-button/vega-app-header-button.css +7 -1
- package/dist/collection/components/vega-button/vega-button.css +1 -0
- package/dist/collection/components/vega-button-circle/vega-button-circle.css +4 -0
- package/dist/collection/components/vega-button-group/vega-button-group-item/vega-button-group-item.css +10 -0
- package/dist/collection/components/vega-button-group/vega-button-group.css +13 -0
- package/dist/collection/components/vega-calendar/slimmers/common/controllers/vega-calendar-current-period-controller.js +17 -3
- package/dist/collection/components/vega-calendar/slimmers/common/controllers/vega-calendar-event-responsive-controller.js +1 -1
- package/dist/collection/components/vega-calendar/slimmers/common/controllers/vega-calendar-view-controller.js +3 -0
- package/dist/collection/components/vega-calendar/slimmers/common/helpers/repeat-pattern/calendar-event-daily-repeat-pattern.js +7 -1
- package/dist/collection/components/vega-calendar/slimmers/common/helpers/repeat-pattern/calendar-event-monthly-repeat-pattern.js +7 -1
- package/dist/collection/components/vega-calendar/slimmers/common/helpers/repeat-pattern/calendar-event-weekly-repeat-pattern.js +9 -1
- package/dist/collection/components/vega-calendar/slimmers/common/helpers/repeat-pattern/calendar-event-yearly-repeat-pattern.js +7 -1
- package/dist/collection/components/vega-calendar/slimmers/common/helpers/test/calendar-event-repeat-pattern-factory.test.js +56 -0
- package/dist/collection/components/vega-calendar/slimmers/common/layout/full-day-event-layout-generator.js +1 -1
- package/dist/collection/components/vega-calendar/slimmers/common/renderers/vega-calendar-switch-panel.js +4 -3
- package/dist/collection/components/vega-calendar/slimmers/common/renderers/vega-calendar-view-renderer.js +4 -1
- package/dist/collection/components/vega-calendar/slimmers/day-view/renderers/timed-event/vega-calendar-day-event-layout-renderer.js +1 -1
- package/dist/collection/components/vega-calendar/slimmers/day-view/renderers/vega-calendar-time-line-renderer.js +1 -1
- package/dist/collection/components/vega-calendar/slimmers/day-view/renderers/vega-calendar-view-with-time-renderer.js +0 -3
- package/dist/collection/components/vega-calendar/slimmers/month-view/renderers/vega-calendar-month-event-renderer.js +3 -1
- package/dist/collection/components/vega-calendar/slimmers/month-view/renderers/vega-calendar-month-view-renderer.js +0 -3
- package/dist/collection/components/vega-calendar/utils/index.js +24 -0
- package/dist/collection/components/vega-calendar/vega-calendar-event/slimmers/renderers/vega-calendar-event-renderer.js +3 -2
- package/dist/collection/components/vega-calendar/vega-calendar.css +10 -6
- package/dist/collection/components/vega-calendar/vega-calendar.js +36 -0
- package/dist/collection/components/vega-chip/vega-chip.css +4 -0
- package/dist/collection/helpers/calendar/calendar-period/calendar-period.abstract.js +8 -0
- package/dist/collection/helpers/calendar/calendar-period/day-period.js +27 -4
- package/dist/collection/helpers/calendar/calendar-period/month-period.js +4 -2
- package/dist/collection/helpers/calendar/calendar-period/week-period.js +4 -2
- package/dist/collection/helpers/calendar/calendar-view-generator/month-view-generator.js +8 -2
- package/dist/collection/helpers/calendar/calendar-view-generator/week-view-generator.js +8 -1
- package/dist/collection/helpers/calendar/test/calendar-period/day-period.test.js +16 -0
- package/dist/collection/helpers/calendar/test/calendar-view-generator/month-view-generator.test.js +50 -0
- package/dist/collection/helpers/calendar/test/calendar-view-generator/week-view-generator.test.js +15 -0
- package/dist/collection/helpers/formatter/string-formatter/number-mask-strategy.js +36 -4
- package/dist/collection/helpers/formatter/string-formatter/number-thousand-comma-strategy.js +10 -9
- package/dist/collection/helpers/formatter/test/string-formatter/number-mask-strategy.test.js +11 -2
- package/dist/collection/helpers/formatter/test/string-formatter/number-thousand-comma-mask-strategy.test.js +10 -0
- package/dist/collection/helpers/slimmers/string-input-formatter-slimmer.js +8 -13
- package/dist/collection/helpers/slimmers/sub-state/sub-state-observer-slimmer.js +2 -2
- package/dist/collection/helpers/slimmers/test/string-input-formatter-slimmer.test.js +52 -20
- package/dist/collection/utils/spec-utils.js +28 -0
- package/dist/collection/utils/test-utils.js +21 -0
- package/dist/esm/{app-globals-d0b86358.js → app-globals-41797af8.js} +1 -1
- package/dist/esm/{form-field-controller-slimmer-2f9c871b.js → form-field-controller-slimmer-edbaaf7c.js} +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{string-input-formatter-slimmer-bfe3f5e5.js → string-input-formatter-slimmer-fc23bc9f.js} +8 -13
- package/dist/esm/{sub-state-observer-slimmer-af28076b.js → sub-state-observer-slimmer-8eff5559.js} +2 -2
- package/dist/esm/{translation-slimmer-c740a5f3.js → translation-slimmer-79f9a9c9.js} +1 -1
- package/dist/esm/vega-app-header-button.entry.js +1 -1
- package/dist/esm/vega-button-circle.entry.js +1 -1
- package/dist/esm/vega-button-group_2.entry.js +3 -3
- package/dist/esm/vega-button.entry.js +1 -1
- package/dist/esm/vega-calendar_3.entry.js +963 -838
- package/dist/esm/vega-checkbox_2.entry.js +2 -2
- package/dist/esm/vega-chip.entry.js +1 -1
- package/dist/esm/vega-color-picker.entry.js +2 -2
- package/dist/esm/vega-combo-box.entry.js +2 -2
- package/dist/esm/vega-date-picker_2.entry.js +4 -4
- package/dist/esm/vega-dropdown_5.entry.js +3 -3
- package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
- package/dist/esm/vega-file-uploader.entry.js +3 -3
- package/dist/esm/vega-form.entry.js +2 -2
- package/dist/esm/vega-image-uploader.entry.js +3 -3
- package/dist/esm/vega-input-credit-card.entry.js +2 -2
- package/dist/esm/vega-input-phone-number.entry.js +2 -2
- package/dist/esm/vega-input-range.entry.js +3 -3
- package/dist/esm/vega-input-select.entry.js +3 -3
- package/dist/esm/vega-input.entry.js +48 -16
- package/dist/esm/vega-pagination.entry.js +2 -2
- package/dist/esm/vega-radio_2.entry.js +2 -2
- package/dist/esm/vega-selection-chip_2.entry.js +3 -3
- package/dist/esm/vega-selection-tile_2.entry.js +3 -3
- package/dist/esm/vega-signature-capture.entry.js +3 -3
- package/dist/esm/vega-stepper.entry.js +2 -2
- package/dist/esm/vega-table_8.entry.js +3 -3
- package/dist/esm/vega-textarea.entry.js +2 -2
- package/dist/esm/vega-time-picker_2.entry.js +3 -3
- package/dist/esm/vega-toggle-switch.entry.js +2 -2
- package/dist/esm/vega.js +3 -3
- package/dist/types/components/vega-calendar/slimmers/common/controllers/vega-calendar-current-period-controller.d.ts +5 -0
- package/dist/types/components/vega-calendar/slimmers/common/controllers/vega-calendar-view-controller.d.ts +1 -0
- package/dist/types/components/vega-calendar/slimmers/common/renderers/vega-calendar-switch-panel.d.ts +1 -1
- package/dist/types/components/vega-calendar/slimmers/common/renderers/vega-calendar-view-renderer.d.ts +1 -0
- package/dist/types/components/vega-calendar/slimmers/day-view/renderers/vega-calendar-view-with-time-renderer.d.ts +0 -1
- package/dist/types/components/vega-calendar/slimmers/month-view/renderers/vega-calendar-month-view-renderer.d.ts +0 -1
- package/dist/types/components/vega-calendar/utils/index.d.ts +13 -0
- package/dist/types/components/vega-calendar/vega-calendar.d.ts +10 -0
- package/dist/types/components.d.ts +10 -0
- package/dist/types/helpers/calendar/calendar-period/calendar-period.abstract.d.ts +7 -0
- package/dist/types/helpers/calendar/calendar-period/day-period.d.ts +8 -1
- package/dist/types/helpers/calendar/calendar-period/month-period.d.ts +2 -1
- package/dist/types/helpers/calendar/calendar-period/week-period.d.ts +2 -1
- package/dist/types/helpers/formatter/string-formatter/number-mask-strategy.d.ts +20 -0
- package/dist/types/helpers/slimmers/sub-state/sub-state-observer-slimmer.d.ts +1 -1
- package/dist/types/utils/spec-utils.d.ts +8 -0
- package/dist/types/utils/test-utils.d.ts +10 -0
- package/dist/vega/index.esm.js +1 -1
- package/dist/vega/{p-f57454a6.js → p-0120ce7a.js} +1 -1
- package/dist/vega/{p-1dc80394.entry.js → p-0395e791.entry.js} +1 -1
- package/dist/vega/{p-8a1d8b99.entry.js → p-048a97d1.entry.js} +1 -1
- package/dist/vega/{p-963e8c45.entry.js → p-0dd750b0.entry.js} +1 -1
- package/dist/vega/{p-c31002d0.entry.js → p-128fbe13.entry.js} +1 -1
- package/dist/vega/p-1f38eef6.entry.js +1 -0
- package/dist/vega/{p-8912d5c9.entry.js → p-1fc5373a.entry.js} +1 -1
- package/dist/vega/{p-7f8db003.entry.js → p-22a85055.entry.js} +1 -1
- package/dist/vega/{p-351a0ea1.entry.js → p-34545d2d.entry.js} +1 -1
- package/dist/vega/{p-f37e6adf.entry.js → p-40f6add9.entry.js} +1 -1
- package/dist/vega/p-41784db1.js +1 -0
- package/dist/vega/{p-c9e3413b.entry.js → p-4bc042ec.entry.js} +1 -1
- package/dist/vega/{p-a7666db3.entry.js → p-5d231a82.entry.js} +1 -1
- package/dist/vega/p-5f377954.js +1 -1
- package/dist/vega/{p-ded47af0.entry.js → p-657df167.entry.js} +1 -1
- package/dist/vega/{p-28f6ead3.entry.js → p-6d015656.entry.js} +1 -1
- package/dist/vega/{p-8c2852c4.entry.js → p-6e3cc7f0.entry.js} +1 -1
- package/dist/vega/p-8843226a.entry.js +1 -0
- package/dist/vega/{p-09352107.entry.js → p-8c72aa56.entry.js} +1 -1
- package/dist/vega/{p-ba3db23b.entry.js → p-8f60c3ee.entry.js} +1 -1
- package/dist/vega/{p-bffaa859.entry.js → p-9a4ffc2c.entry.js} +1 -1
- package/dist/vega/p-9e6934fb.js +1 -0
- package/dist/vega/p-a10074a8.entry.js +1 -0
- package/dist/vega/{p-e7e19350.entry.js → p-a454acc4.entry.js} +1 -1
- package/dist/vega/p-a46329bb.js +1 -0
- package/dist/vega/{p-27b73500.entry.js → p-a8b1f19c.entry.js} +1 -1
- package/dist/vega/{p-14c0b4ea.js → p-bccacf42.js} +1 -1
- package/dist/vega/{p-8eadc60b.entry.js → p-d0a83562.entry.js} +1 -1
- package/dist/vega/{p-288b47f0.entry.js → p-d4fb2264.entry.js} +1 -1
- package/dist/vega/{p-fa78f87f.entry.js → p-d550fc66.entry.js} +1 -1
- package/dist/vega/p-d686dd96.entry.js +1 -0
- package/dist/vega/{p-0afaa0f3.entry.js → p-ead9a2b9.entry.js} +1 -1
- package/dist/vega/{p-54f5c773.entry.js → p-f0ad06bd.entry.js} +1 -1
- package/dist/vega/{p-8aaa9233.entry.js → p-f2019f70.entry.js} +1 -1
- package/dist/vega/{p-af71fe84.entry.js → p-fc746bae.entry.js} +1 -1
- package/dist/vega/vega.esm.js +1 -1
- package/package.json +1 -1
- package/dist/vega/p-15452727.js +0 -1
- package/dist/vega/p-38e3d50e.entry.js +0 -1
- package/dist/vega/p-8a646846.entry.js +0 -1
- package/dist/vega/p-bf557666.entry.js +0 -1
- package/dist/vega/p-d7bd2be5.entry.js +0 -1
- package/dist/vega/p-db120a1e.js +0 -1
- package/dist/vega/p-dee487f9.js +0 -1
- /package/dist/cjs/{translation-77e9ccce.js → translation-0dd74433.js} +0 -0
- /package/dist/esm/{translation-3b437b6d.js → translation-0fa7cf77.js} +0 -0
- /package/dist/vega/{p-05ebf5a3.js → p-be784f53.js} +0 -0
|
@@ -10,6 +10,13 @@ export class WeekViewGenerator extends CalendarViewGenerator {
|
|
|
10
10
|
*/
|
|
11
11
|
generate(period) {
|
|
12
12
|
const dates = this.generateDates(period);
|
|
13
|
-
|
|
13
|
+
const showWeekends = period.showWeekends;
|
|
14
|
+
let weekDays = this.generateWeekHead();
|
|
15
|
+
let dateItems = [dates.map(CalendarDate.from)];
|
|
16
|
+
if (showWeekends === false) {
|
|
17
|
+
weekDays = weekDays.slice(1, 6);
|
|
18
|
+
dateItems = dateItems.map((items) => items.slice(1, 6));
|
|
19
|
+
}
|
|
20
|
+
return new CalendarView(weekDays, dateItems);
|
|
14
21
|
}
|
|
15
22
|
}
|
|
@@ -62,4 +62,20 @@ describe('day-period', () => {
|
|
|
62
62
|
endDate: previousDate,
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
|
+
it('should go to closet workday when call the now method and the showWeekend set to false', () => {
|
|
66
|
+
// Sun
|
|
67
|
+
jest.setSystemTime(new Date(2024, 10, 10));
|
|
68
|
+
const dayPeriod = new DayPeriod(undefined, false);
|
|
69
|
+
const { current } = dayPeriod.now();
|
|
70
|
+
expect(current.date).toEqual(11);
|
|
71
|
+
});
|
|
72
|
+
it('should get closet workday when call the method and the showWeekend set to false', () => {
|
|
73
|
+
//Sat
|
|
74
|
+
const calendarDate = new CalendarDate(2024, 11, 9);
|
|
75
|
+
let dayPeriod = new DayPeriod(calendarDate, false);
|
|
76
|
+
dayPeriod = dayPeriod.next();
|
|
77
|
+
expect(dayPeriod.current.date).toEqual(11);
|
|
78
|
+
dayPeriod = dayPeriod.previous();
|
|
79
|
+
expect(dayPeriod.current.date).toEqual(8);
|
|
80
|
+
});
|
|
65
81
|
});
|
package/dist/collection/helpers/calendar/test/calendar-view-generator/month-view-generator.test.js
CHANGED
|
@@ -70,4 +70,54 @@ describe('month-view-generator', () => {
|
|
|
70
70
|
_weekdays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
|
71
71
|
});
|
|
72
72
|
});
|
|
73
|
+
it('should generate a month view calendar without weekends', () => {
|
|
74
|
+
const generator = new MonthViewGenerator();
|
|
75
|
+
expect(generator.generate(new MonthPeriod(undefined, false))).toEqual({
|
|
76
|
+
_dateItems: [
|
|
77
|
+
[
|
|
78
|
+
{ _date: 28, _month: 3, _year: 2022 },
|
|
79
|
+
{ _date: 29, _month: 3, _year: 2022 },
|
|
80
|
+
{ _date: 30, _month: 3, _year: 2022 },
|
|
81
|
+
{ _date: 31, _month: 3, _year: 2022 },
|
|
82
|
+
{ _date: 1, _month: 4, _year: 2022 },
|
|
83
|
+
],
|
|
84
|
+
[
|
|
85
|
+
{ _date: 4, _month: 4, _year: 2022 },
|
|
86
|
+
{ _date: 5, _month: 4, _year: 2022 },
|
|
87
|
+
{ _date: 6, _month: 4, _year: 2022 },
|
|
88
|
+
{ _date: 7, _month: 4, _year: 2022 },
|
|
89
|
+
{ _date: 8, _month: 4, _year: 2022 },
|
|
90
|
+
],
|
|
91
|
+
[
|
|
92
|
+
{ _date: 11, _month: 4, _year: 2022 },
|
|
93
|
+
{ _date: 12, _month: 4, _year: 2022 },
|
|
94
|
+
{ _date: 13, _month: 4, _year: 2022 },
|
|
95
|
+
{ _date: 14, _month: 4, _year: 2022 },
|
|
96
|
+
{ _date: 15, _month: 4, _year: 2022 },
|
|
97
|
+
],
|
|
98
|
+
[
|
|
99
|
+
{ _date: 18, _month: 4, _year: 2022 },
|
|
100
|
+
{ _date: 19, _month: 4, _year: 2022 },
|
|
101
|
+
{ _date: 20, _month: 4, _year: 2022 },
|
|
102
|
+
{ _date: 21, _month: 4, _year: 2022 },
|
|
103
|
+
{ _date: 22, _month: 4, _year: 2022 },
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
{ _date: 25, _month: 4, _year: 2022 },
|
|
107
|
+
{ _date: 26, _month: 4, _year: 2022 },
|
|
108
|
+
{ _date: 27, _month: 4, _year: 2022 },
|
|
109
|
+
{ _date: 28, _month: 4, _year: 2022 },
|
|
110
|
+
{ _date: 29, _month: 4, _year: 2022 },
|
|
111
|
+
],
|
|
112
|
+
[
|
|
113
|
+
{ _date: 2, _month: 5, _year: 2022 },
|
|
114
|
+
{ _date: 3, _month: 5, _year: 2022 },
|
|
115
|
+
{ _date: 4, _month: 5, _year: 2022 },
|
|
116
|
+
{ _date: 5, _month: 5, _year: 2022 },
|
|
117
|
+
{ _date: 6, _month: 5, _year: 2022 },
|
|
118
|
+
],
|
|
119
|
+
],
|
|
120
|
+
_weekdays: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
|
|
121
|
+
});
|
|
122
|
+
});
|
|
73
123
|
});
|
package/dist/collection/helpers/calendar/test/calendar-view-generator/week-view-generator.test.js
CHANGED
|
@@ -25,4 +25,19 @@ describe('week-view-generator', () => {
|
|
|
25
25
|
_weekdays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
+
it('should generate a week view calendar without weekends', () => {
|
|
29
|
+
const generator = new WeekViewGenerator();
|
|
30
|
+
expect(generator.generate(new WeekPeriod(undefined, false))).toEqual({
|
|
31
|
+
_dateItems: [
|
|
32
|
+
[
|
|
33
|
+
{ _date: 4, _month: 4, _year: 2022 },
|
|
34
|
+
{ _date: 5, _month: 4, _year: 2022 },
|
|
35
|
+
{ _date: 6, _month: 4, _year: 2022 },
|
|
36
|
+
{ _date: 7, _month: 4, _year: 2022 },
|
|
37
|
+
{ _date: 8, _month: 4, _year: 2022 },
|
|
38
|
+
],
|
|
39
|
+
],
|
|
40
|
+
_weekdays: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
|
|
41
|
+
});
|
|
42
|
+
});
|
|
28
43
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNonNullable } from '../../../types/type-guard';
|
|
1
2
|
/**
|
|
2
3
|
* A class for formatting number with the given mask format
|
|
3
4
|
*/
|
|
@@ -34,11 +35,12 @@ export class NumberMaskStrategy {
|
|
|
34
35
|
* @returns {string} The formatted number string.
|
|
35
36
|
*/
|
|
36
37
|
format(input) {
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
const redressedInput = this.redressAbnormalNumber(input);
|
|
39
|
+
if (this.skipFormat(redressedInput)) {
|
|
40
|
+
return redressedInput;
|
|
39
41
|
}
|
|
40
|
-
const resultStringBuilder = [...
|
|
41
|
-
for (let i =
|
|
42
|
+
const resultStringBuilder = [...redressedInput];
|
|
43
|
+
for (let i = redressedInput.length - 1; i >= 0; i--) {
|
|
42
44
|
const value = resultStringBuilder.join('');
|
|
43
45
|
if (this.inputNeedFormat(value)) {
|
|
44
46
|
resultStringBuilder.pop();
|
|
@@ -46,6 +48,19 @@ export class NumberMaskStrategy {
|
|
|
46
48
|
}
|
|
47
49
|
return resultStringBuilder.join('');
|
|
48
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Get the position of caret
|
|
53
|
+
*
|
|
54
|
+
* @param {string} input - input number
|
|
55
|
+
* @param {number} caretPosition - The current caret position
|
|
56
|
+
* @returns {number} The new position of caret
|
|
57
|
+
*/
|
|
58
|
+
calculateCaretPosition(input, caretPosition) {
|
|
59
|
+
if (isNonNullable(caretPosition)) {
|
|
60
|
+
const redressedInput = this.redressAbnormalNumber(input);
|
|
61
|
+
return caretPosition - (input.length - redressedInput.length);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
49
64
|
/**
|
|
50
65
|
* Whether the input string need delete the latest char
|
|
51
66
|
*
|
|
@@ -55,6 +70,23 @@ export class NumberMaskStrategy {
|
|
|
55
70
|
inputNeedFormat(value) {
|
|
56
71
|
return !this.mask.test(value);
|
|
57
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Remove zero of beginning, example:
|
|
75
|
+
* 00012 -> 12
|
|
76
|
+
* 000.12 -> 0.12
|
|
77
|
+
* 00123,456 -> 123,456
|
|
78
|
+
* .12 -> 0.12
|
|
79
|
+
*
|
|
80
|
+
* @param {string} input - the input value
|
|
81
|
+
* @returns {string} - redressed Number
|
|
82
|
+
*/
|
|
83
|
+
redressAbnormalNumber(input) {
|
|
84
|
+
let removedZeroBeginning = input.replace(/^0+(?!$)/, '');
|
|
85
|
+
if (removedZeroBeginning.startsWith('.')) {
|
|
86
|
+
removedZeroBeginning = `0${removedZeroBeginning}`;
|
|
87
|
+
}
|
|
88
|
+
return removedZeroBeginning;
|
|
89
|
+
}
|
|
58
90
|
/**
|
|
59
91
|
* Get the number RegExp
|
|
60
92
|
*
|
package/dist/collection/helpers/formatter/string-formatter/number-thousand-comma-strategy.js
CHANGED
|
@@ -18,11 +18,12 @@ export class NumberThousandCommaStrategy extends NumberMaskStrategy {
|
|
|
18
18
|
* @returns {string} The input string, but with commas as thousands separator.
|
|
19
19
|
*/
|
|
20
20
|
format(input) {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const redressedInput = this.redressAbnormalNumber(input);
|
|
22
|
+
if (this.skipFormat(redressedInput)) {
|
|
23
|
+
return redressedInput;
|
|
23
24
|
}
|
|
24
|
-
const resultStringBuilder = [...
|
|
25
|
-
for (let i =
|
|
25
|
+
const resultStringBuilder = [...redressedInput];
|
|
26
|
+
for (let i = redressedInput.length - 1; i >= 0; i--) {
|
|
26
27
|
const value = resultStringBuilder.join('');
|
|
27
28
|
if (this.inputNeedFormat(value.replace(/,/g, ''))) {
|
|
28
29
|
resultStringBuilder.pop();
|
|
@@ -38,12 +39,13 @@ export class NumberThousandCommaStrategy extends NumberMaskStrategy {
|
|
|
38
39
|
* @returns {number} The new position of caret
|
|
39
40
|
*/
|
|
40
41
|
calculateCaretPosition(input, caretPosition) {
|
|
41
|
-
const
|
|
42
|
+
const redressedInput = this.redressAbnormalNumber(input);
|
|
43
|
+
const formattedInput = this.format(input);
|
|
42
44
|
const oldFrontInput = input.substring(0, caretPosition);
|
|
43
|
-
const newFrontInput =
|
|
45
|
+
const newFrontInput = formattedInput.substring(0, caretPosition);
|
|
44
46
|
const oldFrontCommaCount = (oldFrontInput.match(/,/g) || []).length;
|
|
45
47
|
const newFrontCommaCount = (newFrontInput.match(/,/g) || []).length;
|
|
46
|
-
return caretPosition + (newFrontCommaCount - oldFrontCommaCount);
|
|
48
|
+
return (caretPosition + (newFrontCommaCount - oldFrontCommaCount) - (input.length - redressedInput.length));
|
|
47
49
|
}
|
|
48
50
|
/**
|
|
49
51
|
* The function `thousandCommaFormat` takes a string input, removes non-numeric characters, formats the number with thousand commas, and returns the result.
|
|
@@ -55,9 +57,8 @@ export class NumberThousandCommaStrategy extends NumberMaskStrategy {
|
|
|
55
57
|
if (!input.length)
|
|
56
58
|
return input;
|
|
57
59
|
const inputValue = input.replace(/[^\d.-]/g, '');
|
|
58
|
-
const { precision } = this.maskConfig;
|
|
59
60
|
const pointIndex = inputValue.indexOf('.');
|
|
60
|
-
const decimals =
|
|
61
|
+
const decimals = inputValue.length > 1 && pointIndex >= 1 ? inputValue.slice(pointIndex) : '';
|
|
61
62
|
const numValue = Number(inputValue.split('.')[0]);
|
|
62
63
|
if (!isNaN(numValue) && numValue <= Number.MAX_SAFE_INTEGER) {
|
|
63
64
|
return numValue.toLocaleString('en-US') + decimals;
|
package/dist/collection/helpers/formatter/test/string-formatter/number-mask-strategy.test.js
CHANGED
|
@@ -18,7 +18,9 @@ describe('numberStrategy', () => {
|
|
|
18
18
|
expect(numberStrategy.format('-0.1')).toBe('-0.1');
|
|
19
19
|
expect(numberStrategy.format('1q')).toBe('1');
|
|
20
20
|
expect(numberStrategy.format('1e')).toBe('1');
|
|
21
|
-
expect(numberStrategy.format('.')).toBe('');
|
|
21
|
+
expect(numberStrategy.format('.12')).toBe('0.12');
|
|
22
|
+
expect(numberStrategy.format('0012')).toBe('12');
|
|
23
|
+
expect(numberStrategy.format('00.12')).toBe('0.12');
|
|
22
24
|
});
|
|
23
25
|
it('format input allow 2 decimal places', () => {
|
|
24
26
|
const numberStrategy = new NumberMaskStrategy({ precision: 2 });
|
|
@@ -47,7 +49,7 @@ describe('numberStrategy', () => {
|
|
|
47
49
|
expect(numberStrategy.format('-123.456.1.1')).toBe('-123.45');
|
|
48
50
|
expect(numberStrategy.format('-123.4=')).toBe('-123.4');
|
|
49
51
|
expect(numberStrategy.format('-123.4')).toBe('-123.4');
|
|
50
|
-
expect(numberStrategy.format('.')).toBe('');
|
|
52
|
+
expect(numberStrategy.format('.12')).toBe('0.12');
|
|
51
53
|
});
|
|
52
54
|
it('format input allow 1 decimal places', () => {
|
|
53
55
|
const numberStrategy = new NumberMaskStrategy({ precision: 1 });
|
|
@@ -80,4 +82,11 @@ describe('numberStrategy', () => {
|
|
|
80
82
|
expect(numberStrategy.format('0')).toBe('0');
|
|
81
83
|
expect(numberStrategy.format('0.1')).toBe('0');
|
|
82
84
|
});
|
|
85
|
+
it('calculateCaretPosition work proper', () => {
|
|
86
|
+
const numberStrategy = new NumberMaskStrategy();
|
|
87
|
+
expect(numberStrategy.calculateCaretPosition('123', 3)).toBe(3);
|
|
88
|
+
expect(numberStrategy.calculateCaretPosition('00123', 5)).toBe(3);
|
|
89
|
+
expect(numberStrategy.calculateCaretPosition('00.123', 6)).toBe(5);
|
|
90
|
+
expect(numberStrategy.calculateCaretPosition('00.123', undefined)).toBe(undefined);
|
|
91
|
+
});
|
|
83
92
|
});
|
|
@@ -17,6 +17,8 @@ describe('NumberThousandCommaStrategy', () => {
|
|
|
17
17
|
expect(numberStrategy.format('a')).toBe('');
|
|
18
18
|
expect(numberStrategy.format(',')).toBe('');
|
|
19
19
|
expect(numberStrategy.format('9007199254740992')).toBe('9007199254740992');
|
|
20
|
+
expect(numberStrategy.format('0012')).toBe('12');
|
|
21
|
+
expect(numberStrategy.format('00123456')).toBe('123,456');
|
|
20
22
|
});
|
|
21
23
|
it('should method calculateCaretPosition run as expect', () => {
|
|
22
24
|
const numberStrategy = new NumberThousandCommaStrategy({
|
|
@@ -27,4 +29,12 @@ describe('NumberThousandCommaStrategy', () => {
|
|
|
27
29
|
expect(numberStrategy.calculateCaretPosition('1,23', 4)).toBe(3);
|
|
28
30
|
expect(numberStrategy.calculateCaretPosition('-123', 4)).toBe(4);
|
|
29
31
|
});
|
|
32
|
+
it('format thousand comma if set property thousandComma is true and not set precision', () => {
|
|
33
|
+
const numberStrategy = new NumberThousandCommaStrategy({});
|
|
34
|
+
expect(numberStrategy.format('123')).toBe('123');
|
|
35
|
+
expect(numberStrategy.format('0.12345')).toBe('0.12345');
|
|
36
|
+
expect(numberStrategy.format('12.12')).toBe('12.12');
|
|
37
|
+
expect(numberStrategy.format('123456.012')).toBe('123,456.012');
|
|
38
|
+
expect(numberStrategy.format('-123456.012')).toBe('-123,456.012');
|
|
39
|
+
});
|
|
30
40
|
});
|
|
@@ -57,7 +57,10 @@ export class StringInputFormatterSlimmer extends VegaSlimmer {
|
|
|
57
57
|
const rawValue = target.value;
|
|
58
58
|
const caretPosition = target.selectionStart; // selectionStart is nullable, link https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-textarea/input-selectionstart
|
|
59
59
|
if (this.inputFormatStrategy) {
|
|
60
|
-
const maskedValue = this.inputFormatStrategy.format(rawValue,
|
|
60
|
+
const maskedValue = this.inputFormatStrategy.format(rawValue,
|
|
61
|
+
// Paste input is difference with type input, it can set much characters at one time,
|
|
62
|
+
// so we should make caretPosition as undefined to format all value.
|
|
63
|
+
e.inputType === 'insertFromPaste' ? null : caretPosition);
|
|
61
64
|
this.updateInputValue(rawValue, maskedValue);
|
|
62
65
|
this.updateInputCaretPosition(rawValue, caretPosition);
|
|
63
66
|
}
|
|
@@ -68,12 +71,8 @@ export class StringInputFormatterSlimmer extends VegaSlimmer {
|
|
|
68
71
|
* @param {ClipboardEvent} e - paste event
|
|
69
72
|
*/
|
|
70
73
|
this.onPaste = (e) => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const rawValue = ((_a = e.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('text')) || '';
|
|
74
|
-
if (this.inputFormatStrategy) {
|
|
75
|
-
const maskedValue = this.inputFormatStrategy.format(rawValue);
|
|
76
|
-
this.updateInputValue(rawValue, maskedValue);
|
|
74
|
+
if (this.disableCopyPaste) {
|
|
75
|
+
e.preventDefault();
|
|
77
76
|
}
|
|
78
77
|
};
|
|
79
78
|
}
|
|
@@ -90,9 +89,7 @@ export class StringInputFormatterSlimmer extends VegaSlimmer {
|
|
|
90
89
|
this.onInit();
|
|
91
90
|
if (this.inputFormatStrategy) {
|
|
92
91
|
this.inputElement.addEventListener('input', this.onKeyDown, { capture: true });
|
|
93
|
-
|
|
94
|
-
this.inputElement.addEventListener('paste', this.onPaste, { capture: true });
|
|
95
|
-
}
|
|
92
|
+
this.inputElement.addEventListener('paste', this.onPaste, { capture: true });
|
|
96
93
|
}
|
|
97
94
|
if (this.blurFormatStrategy) {
|
|
98
95
|
this.inputElement.addEventListener('blur', this.onBlur, { capture: true });
|
|
@@ -107,9 +104,7 @@ export class StringInputFormatterSlimmer extends VegaSlimmer {
|
|
|
107
104
|
if (this.inputElement) {
|
|
108
105
|
if (this.inputFormatStrategy) {
|
|
109
106
|
this.inputElement.removeEventListener('input', this.onKeyDown, { capture: true });
|
|
110
|
-
|
|
111
|
-
this.inputElement.removeEventListener('paste', this.onPaste, { capture: true });
|
|
112
|
-
}
|
|
107
|
+
this.inputElement.removeEventListener('paste', this.onPaste, { capture: true });
|
|
113
108
|
}
|
|
114
109
|
if (this.blurFormatStrategy) {
|
|
115
110
|
this.inputElement.removeEventListener('blur', this.onBlur, { capture: true });
|
|
@@ -26,7 +26,7 @@ export class SubStateObserverSlimmer extends VegaSlimmer {
|
|
|
26
26
|
* @returns {boolean} a boolean value indicating whether the input is an acceptable observer payload.
|
|
27
27
|
*/
|
|
28
28
|
this.isAcceptableObserverPayload = (input) => {
|
|
29
|
-
return input['host'] === this.parent;
|
|
29
|
+
return typeof input === 'object' && !!input && input['host'] === this.parent;
|
|
30
30
|
};
|
|
31
31
|
this.observerEntry = observerEntry;
|
|
32
32
|
}
|
|
@@ -68,7 +68,7 @@ export class SubStateObserverSlimmer extends VegaSlimmer {
|
|
|
68
68
|
* The function `getParent` returns the parent element of a given host element, based on the observer
|
|
69
69
|
* entry and appender element.
|
|
70
70
|
*
|
|
71
|
-
* @returns {HTMLElement} the parent HTMLElement.
|
|
71
|
+
* @returns {Nullable<HTMLElement>} the parent HTMLElement.
|
|
72
72
|
*/
|
|
73
73
|
getParent() {
|
|
74
74
|
if (typeof this.observerEntry.parent === 'string') {
|
|
@@ -9,6 +9,7 @@ import { InjectVegaSlimmer } from 'vega-slimmer/core';
|
|
|
9
9
|
import { StringInputFormatterSlimmer } from '../string-input-formatter-slimmer';
|
|
10
10
|
import { StringMaskStrategy } from '../../formatter/string-formatter/string-mask-strategy';
|
|
11
11
|
import { ThousandCommaStrategy } from '../../formatter/string-formatter/thousand-comma-strategy';
|
|
12
|
+
import { dispatchPasteEvent } from '../../../utils/spec-utils';
|
|
12
13
|
const createMockedInput = () => {
|
|
13
14
|
const inputEl = document.createElement('input');
|
|
14
15
|
inputEl.setSelectionRange = jest.fn();
|
|
@@ -129,21 +130,25 @@ describe('StringInputFormatterSlimmer test suite', () => {
|
|
|
129
130
|
mockedComponent['stringFormatter']['inputRef'] = inputEl;
|
|
130
131
|
mockedComponent['stringFormatter']['inputStrategy'] = stringFormatStrategy;
|
|
131
132
|
mockedComponent['stringFormatter'].setup();
|
|
132
|
-
const pasteEvent =
|
|
133
|
-
const clipboardDataMock = {
|
|
134
|
-
getData: jest.fn().mockReturnValue('7777 is my lucky number'),
|
|
135
|
-
};
|
|
136
|
-
Object.defineProperty(pasteEvent, 'clipboardData', { value: clipboardDataMock });
|
|
133
|
+
const pasteEvent = dispatchPasteEvent(inputEl, '7777 is my lucky number');
|
|
137
134
|
const preventDefaultSpy = jest.spyOn(pasteEvent, 'preventDefault');
|
|
138
|
-
|
|
139
|
-
expect(preventDefaultSpy).toHaveBeenCalled();
|
|
140
|
-
expect(clipboardDataMock.getData).toHaveBeenCalledWith('text');
|
|
141
|
-
expect(clipboardDataMock.getData('text')).toEqual('7777 is my lucky number');
|
|
135
|
+
expect(preventDefaultSpy).not.toHaveBeenCalled();
|
|
142
136
|
expect(inputEl.value).toEqual('(777) 7');
|
|
143
137
|
jest.spyOn(inputEl, 'removeEventListener');
|
|
144
138
|
mockedComponent['stringFormatter'].destroy();
|
|
145
139
|
expect(inputEl.removeEventListener).toBeCalledWith('paste', expect.any(Function), { capture: true });
|
|
146
140
|
});
|
|
141
|
+
test('should handle paste content correctly when input a valid string', () => {
|
|
142
|
+
const mockedComponent = new MockedComponent();
|
|
143
|
+
mockedComponent.host = document.createElement('input');
|
|
144
|
+
const stringFormatStrategy = StringMaskStrategy.PHONE_MASK;
|
|
145
|
+
const inputEl = createMockedInput();
|
|
146
|
+
mockedComponent['stringFormatter']['inputRef'] = inputEl;
|
|
147
|
+
mockedComponent['stringFormatter']['inputStrategy'] = stringFormatStrategy;
|
|
148
|
+
mockedComponent['stringFormatter'].setup();
|
|
149
|
+
dispatchPasteEvent(inputEl, '(777');
|
|
150
|
+
expect(inputEl.value).toEqual('(777');
|
|
151
|
+
});
|
|
147
152
|
test('should not handle paste content if paste is disabled', () => {
|
|
148
153
|
const mockedComponent = new MockedComponent();
|
|
149
154
|
mockedComponent.host = document.createElement('input');
|
|
@@ -153,19 +158,13 @@ describe('StringInputFormatterSlimmer test suite', () => {
|
|
|
153
158
|
mockedComponent['stringFormatter']['disableCopyPaste'] = true;
|
|
154
159
|
mockedComponent['stringFormatter']['inputStrategy'] = stringFormatStrategy;
|
|
155
160
|
mockedComponent['stringFormatter'].setup();
|
|
156
|
-
|
|
157
|
-
Object.defineProperty(pasteEvent, 'clipboardData', {
|
|
158
|
-
value: {
|
|
159
|
-
getData: jest.fn().mockReturnValue('7777 is my lucky number'),
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
inputEl.dispatchEvent(pasteEvent);
|
|
161
|
+
dispatchPasteEvent(inputEl, '7777 is my lucky number');
|
|
163
162
|
expect(inputEl.value).toEqual('');
|
|
164
163
|
jest.spyOn(inputEl, 'addEventListener');
|
|
165
|
-
expect(inputEl.addEventListener).not.toBeCalledWith('
|
|
164
|
+
expect(inputEl.addEventListener).not.toBeCalledWith('input', expect.any(Function), { capture: true });
|
|
166
165
|
jest.spyOn(inputEl, 'removeEventListener');
|
|
167
166
|
mockedComponent['stringFormatter'].destroy();
|
|
168
|
-
expect(inputEl.removeEventListener).
|
|
167
|
+
expect(inputEl.removeEventListener).toBeCalledWith('paste', expect.any(Function), {
|
|
169
168
|
capture: true,
|
|
170
169
|
});
|
|
171
170
|
});
|
|
@@ -177,10 +176,43 @@ describe('StringInputFormatterSlimmer test suite', () => {
|
|
|
177
176
|
mockedComponent['stringFormatter']['inputRef'] = inputEl;
|
|
178
177
|
mockedComponent['stringFormatter']['inputStrategy'] = stringFormatStrategy;
|
|
179
178
|
mockedComponent['stringFormatter'].setup();
|
|
180
|
-
const pasteEvent = new Event('paste');
|
|
181
179
|
const formatSpy = jest.spyOn(stringFormatStrategy, 'format');
|
|
182
|
-
|
|
180
|
+
dispatchPasteEvent(inputEl, '');
|
|
183
181
|
expect(formatSpy).toHaveBeenCalledWith('');
|
|
184
182
|
expect(inputEl.value).toEqual('');
|
|
185
183
|
});
|
|
184
|
+
test('should handle paste content with not formatted value', () => {
|
|
185
|
+
const mockedComponent = new MockedComponent();
|
|
186
|
+
mockedComponent.host = document.createElement('input');
|
|
187
|
+
const stringFormatStrategy = StringMaskStrategy.PHONE_MASK;
|
|
188
|
+
const inputEl = createMockedInput();
|
|
189
|
+
mockedComponent['stringFormatter']['inputRef'] = inputEl;
|
|
190
|
+
mockedComponent['stringFormatter']['inputStrategy'] = stringFormatStrategy;
|
|
191
|
+
mockedComponent['stringFormatter'].setup();
|
|
192
|
+
dispatchPasteEvent(inputEl,
|
|
193
|
+
// should pick up numbers and then to format by this input string
|
|
194
|
+
// eslint-disable-next-line spellcheck/spell-checker
|
|
195
|
+
'nGLNBk1x1ZKVN5qfcwNpPvK9cLPiDrChJDMW0RnzDyUf2BaGSKqXMbj4ckbGmAZbH0V5Krhzv58vpALGFF8PXvqE6cdpUFJW0vApkYk82gUuf2CkPw4q92DQ7JJSacbFEdGFdRiAKfXzaHUBPQYLbkmAR8TmmSa87zPzFzBvdrYPVpQFD1DLLTPnM0WR0Qr8WGnHRF8P0K6b0d');
|
|
196
|
+
expect(inputEl.value).toEqual('(115) 902-4055');
|
|
197
|
+
});
|
|
198
|
+
test('should work proper while formatter have not implement calculateCaretPosition method', () => {
|
|
199
|
+
class FormatterSlimmer {
|
|
200
|
+
format(input) {
|
|
201
|
+
return input;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const mockedComponent = new MockedComponent();
|
|
205
|
+
mockedComponent.host = document.createElement('input');
|
|
206
|
+
const stringFormatStrategy = new FormatterSlimmer();
|
|
207
|
+
const inputEl = createMockedInput();
|
|
208
|
+
inputEl.value = '1111111111';
|
|
209
|
+
inputEl.selectionStart = inputEl.value.length;
|
|
210
|
+
mockedComponent['stringFormatter']['inputRef'] = inputEl;
|
|
211
|
+
mockedComponent['stringFormatter']['inputStrategy'] = stringFormatStrategy;
|
|
212
|
+
mockedComponent['stringFormatter'].setup();
|
|
213
|
+
const inputEvent = new Event('input');
|
|
214
|
+
inputEl.dispatchEvent(inputEvent);
|
|
215
|
+
expect(inputEl.value).toEqual('1111111111');
|
|
216
|
+
expect(inputEl.selectionStart).toEqual(10);
|
|
217
|
+
});
|
|
186
218
|
});
|
|
@@ -166,3 +166,31 @@ export function queryVegaDropdownItem(page, itemSelector = 'vega-dropdown-item')
|
|
|
166
166
|
const virtualScroll = dropdownBox.shadowRoot.querySelector('vega-virtual-scroll');
|
|
167
167
|
return virtualScroll.shadowRoot.querySelector(itemSelector);
|
|
168
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Dispatch paste event for a element.
|
|
171
|
+
*
|
|
172
|
+
* @param {HTMLElement} element - Content editable element, such as input, textarea.
|
|
173
|
+
* @param {string} data - data to paste.
|
|
174
|
+
* @returns {ClipboardEvent} - Paste event.
|
|
175
|
+
*/
|
|
176
|
+
export function dispatchPasteEvent(element, data) {
|
|
177
|
+
element.focus();
|
|
178
|
+
const pasteEvent = new Event('paste', {
|
|
179
|
+
bubbles: true,
|
|
180
|
+
cancelable: true,
|
|
181
|
+
});
|
|
182
|
+
const clipboardDataMock = {
|
|
183
|
+
getData: jest.fn().mockReturnValue(data),
|
|
184
|
+
};
|
|
185
|
+
Object.defineProperty(pasteEvent, 'clipboardData', { value: clipboardDataMock });
|
|
186
|
+
element.dispatchEvent(pasteEvent);
|
|
187
|
+
if (!pasteEvent.defaultPrevented) {
|
|
188
|
+
const inputEvent = new Event('input', { bubbles: true, cancelable: true });
|
|
189
|
+
Object.defineProperty(inputEvent, 'inputType', { value: 'insertFromPaste' });
|
|
190
|
+
Object.defineProperty(inputEvent, 'data', { value: data });
|
|
191
|
+
Object.defineProperty(element, 'selectionStart', { value: data.length });
|
|
192
|
+
element['value'] = data;
|
|
193
|
+
element.dispatchEvent(inputEvent);
|
|
194
|
+
}
|
|
195
|
+
return pasteEvent;
|
|
196
|
+
}
|
|
@@ -132,3 +132,24 @@ export function sleep(ms) {
|
|
|
132
132
|
setTimeout(resolve, ms);
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
|
+
/* istanbul ignore next */
|
|
136
|
+
/**
|
|
137
|
+
* NOTE: This const is only for **E2E** test cases.
|
|
138
|
+
* This method is to assert values of two arrays are close.
|
|
139
|
+
*
|
|
140
|
+
* @param {number[]} actualValue - The actualValue.
|
|
141
|
+
* @param {number[]} expectedValue - The expectedValue.
|
|
142
|
+
* @param {number} tolerance - The value difference tolerance of two arrays.
|
|
143
|
+
* @returns {boolean} - the return value
|
|
144
|
+
*/
|
|
145
|
+
export function ArrayComparing(actualValue, expectedValue, tolerance) {
|
|
146
|
+
if (actualValue.length !== expectedValue.length) {
|
|
147
|
+
throw new Error('Arrays must be of the same length');
|
|
148
|
+
}
|
|
149
|
+
actualValue.forEach((value, index) => {
|
|
150
|
+
if (Math.abs(value - expectedValue[index]) > tolerance) {
|
|
151
|
+
throw new Error(`actualValue: ${JSON.stringify(actualValue)} expectedValue: ${JSON.stringify(expectedValue)}`); // output values of two arrays if values are not close
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
return true; // values of two arrays are close
|
|
155
|
+
}
|
|
@@ -4,7 +4,7 @@ import { M as MapToComponentMethod, V as VegaSlimmer, s as setVegaLogLevel, G as
|
|
|
4
4
|
import { V as VegaDialog } from './vega-dialog-controller-3b905672.js';
|
|
5
5
|
import { v as vegaEnvManager } from './vega-env-manager-8f8dc473.js';
|
|
6
6
|
import { V as VegaIconManager } from './icon-manager-0f030f8a.js';
|
|
7
|
-
import { V as VegaInternalTranslation, a as VegaTranslation, s as staticTranslations } from './translation-
|
|
7
|
+
import { V as VegaInternalTranslation, a as VegaTranslation, s as staticTranslations } from './translation-0fa7cf77.js';
|
|
8
8
|
import { T as TypographyUrls } from './typography-a8fc4764.js';
|
|
9
9
|
import { V as ValidCreditCardNumberRule } from './valid-credit-card-number-rule-232f2986.js';
|
|
10
10
|
import { U as UPDATE_TRANSLATION } from './static-subject-title-6987a80b.js';
|
|
@@ -8,7 +8,7 @@ import { i as isAsyncFunction, g as generateUUID } from './create-public-api-run
|
|
|
8
8
|
import { c as createDynamicSlimmer } from './dynamic-slimmer-90b8af32.js';
|
|
9
9
|
import { d as domNodeSubjectFactory, D as DomNodeSubjectObserverFactory } from './dom-node-subject-observer-factory-9461cd67.js';
|
|
10
10
|
import { V as VegaInternalFieldErrorStateChange, a as VegaInternalValid } from './vega-internal-event-id-7e05cf4a.js';
|
|
11
|
-
import { V as VegaInternalTranslation } from './translation-
|
|
11
|
+
import { V as VegaInternalTranslation } from './translation-0fa7cf77.js';
|
|
12
12
|
import { P as PageResizeObserverSlimmer } from './page-resize-observer-slimmer-994c1e1b.js';
|
|
13
13
|
import { M as MutationObserverSlimmer } from './mutation-observer-slimmer-6cef9549.js';
|
|
14
14
|
import { A as AttributeOldValueMutationFilter } from './mutation-observer-filters-9086b5cc.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export { V as VegaDialog } from './vega-dialog-controller-3b905672.js';
|
|
|
13
13
|
export { B as VegaJQueryDelegatedEventStrategy } from './internal-vega-event-manager-722461c1.js';
|
|
14
14
|
export { V as VegaIconManager } from './icon-manager-0f030f8a.js';
|
|
15
15
|
export { V as ValidCreditCardNumberRule } from './valid-credit-card-number-rule-232f2986.js';
|
|
16
|
-
export { a as VegaTranslation, s as VegaTranslationResourceEN } from './translation-
|
|
16
|
+
export { a as VegaTranslation, s as VegaTranslationResourceEN } from './translation-0fa7cf77.js';
|
|
17
17
|
import './responsive-format-facade-5a1329a7.js';
|
|
18
18
|
import './number-e2519d1c.js';
|
|
19
19
|
import './pixel-f32c07ce.js';
|