@globalpayments/vega 2.20.0 → 2.21.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/{app-globals-c199ea5e.js → app-globals-f7f3c776.js} +2 -2
- package/dist/cjs/{child-nodes-event-prevent-slimmer-1a9ac556.js → child-nodes-event-prevent-slimmer-18814356.js} +1 -1
- package/dist/cjs/{event-emit-slimmer-69a0ae5b.js → event-emit-slimmer-95dfc7c2.js} +1 -1
- package/dist/cjs/{form-field-controller-slimmer-8e71addd.js → form-field-controller-slimmer-db68a8da.js} +10 -4
- package/dist/cjs/index-1299d729.js +4 -0
- package/dist/cjs/index.cjs.js +3 -3
- package/dist/cjs/{internal-vega-event-manager-908ef630.js → internal-vega-event-manager-6ba0e3ab.js} +1 -1
- package/dist/cjs/loader.cjs.js +5 -5
- package/dist/cjs/static-remote-invocation-call-registry-d231186a.js +64 -0
- package/dist/cjs/{static-subject-title-35e2a92c.js → static-subject-title-41c88385.js} +4 -0
- package/dist/cjs/vega-accordion.cjs.entry.js +5 -5
- package/dist/cjs/vega-app-header-button.cjs.entry.js +4 -4
- package/dist/cjs/vega-banner.cjs.entry.js +3 -3
- package/dist/cjs/vega-breadcrumb.cjs.entry.js +6 -8
- package/dist/cjs/vega-button-circle.cjs.entry.js +5 -5
- package/dist/cjs/vega-button-group_2.cjs.entry.js +4 -4
- package/dist/cjs/vega-button-link.cjs.entry.js +4 -4
- package/dist/cjs/vega-button.cjs.entry.js +5 -5
- package/dist/cjs/vega-calendar_3.cjs.entry.js +52 -16
- package/dist/cjs/vega-carousel.cjs.entry.js +3 -3
- package/dist/cjs/vega-checkbox_2.cjs.entry.js +6 -6
- package/dist/cjs/vega-chip.cjs.entry.js +4 -4
- package/dist/cjs/vega-color-picker.cjs.entry.js +5 -5
- package/dist/cjs/vega-combo-box.cjs.entry.js +6 -6
- package/dist/cjs/vega-date-picker_2.cjs.entry.js +6 -6
- package/dist/cjs/vega-dialog_2.cjs.entry.js +4 -4
- package/dist/cjs/vega-dropdown_5.cjs.entry.js +23 -5
- package/dist/cjs/vega-env-manager-23b8b23c.js +2 -2
- package/dist/cjs/{vega-event-id-a05199e1.js → vega-event-id-99d9343f.js} +1 -1
- package/dist/cjs/vega-field-error.cjs.entry.js +1 -1
- package/dist/cjs/vega-field-label.cjs.entry.js +4 -4
- package/dist/cjs/vega-form.cjs.entry.js +6 -6
- package/dist/cjs/vega-hint.cjs.entry.js +38 -0
- package/dist/cjs/vega-image-uploader.cjs.entry.js +6 -6
- package/dist/cjs/vega-input-credit-card.cjs.entry.js +6 -6
- package/dist/cjs/vega-input-phone-number.cjs.entry.js +46 -50
- package/dist/cjs/vega-input-range.cjs.entry.js +6 -6
- package/dist/cjs/vega-input-select.cjs.entry.js +6 -6
- package/dist/cjs/vega-input.cjs.entry.js +22 -11
- package/dist/cjs/vega-item-toggle.cjs.entry.js +3 -3
- package/dist/cjs/vega-left-nav_5.cjs.entry.js +4 -4
- package/dist/cjs/vega-page-notification_2.cjs.entry.js +1 -1
- package/dist/cjs/vega-pagination.cjs.entry.js +10 -6
- package/dist/cjs/vega-popover_2.cjs.entry.js +3 -3
- package/dist/cjs/vega-progress-tracker.cjs.entry.js +3 -3
- package/dist/cjs/vega-radio_2.cjs.entry.js +8 -8
- package/dist/cjs/vega-segment-control.cjs.entry.js +3 -3
- package/dist/cjs/vega-selection-tile_2.cjs.entry.js +6 -6
- package/dist/cjs/vega-signature-capture.cjs.entry.js +5 -5
- package/dist/cjs/{vega-skeleton-loader-controller-38ab6039.js → vega-skeleton-loader-controller-aa3e09d6.js} +1 -1
- package/dist/cjs/vega-stepper.cjs.entry.js +6 -6
- package/dist/cjs/vega-tab-group_2.cjs.entry.js +5 -5
- package/dist/cjs/vega-table_8.cjs.entry.js +69 -37
- package/dist/cjs/vega-textarea.cjs.entry.js +6 -6
- package/dist/cjs/vega-time-picker_2.cjs.entry.js +6 -6
- package/dist/cjs/vega-toggle-switch.cjs.entry.js +3 -3
- package/dist/cjs/vega.cjs.js +5 -5
- package/dist/collection/collection-manifest.json +6 -0
- package/dist/collection/components/vega-accordion/vega-accordion.js +1 -1
- package/dist/collection/components/vega-breadcrumb/slimmers/controllers/vega-breadcrumb-click-controller.js +2 -4
- package/dist/collection/components/vega-calendar/vega-calendar-event/slimmers/controllers/vega-calendar-sub-state-controller.js +15 -1
- package/dist/collection/components/vega-calendar/vega-calendar-event/slimmers/renderers/vega-calendar-event-renderer.js +15 -10
- package/dist/collection/components/vega-calendar/vega-calendar-event/vega-calendar-event.js +3 -1
- package/dist/collection/components/vega-calendar/vega-calendar.js +37 -0
- package/dist/collection/components/vega-dropdown/slimmers/controllers/vega-dropdown-search-controller.js +6 -0
- package/dist/collection/components/vega-dropdown/slimmers/renderers/vega-dropdown-item-level-renderer.js +15 -0
- package/dist/collection/components/vega-hint/vega-hint.js +38 -0
- package/dist/collection/components/vega-input/slimmers/controllers/vega-input-mask-config-controller.js +1 -1
- package/dist/collection/components/vega-input/vega-input.js +1 -1
- package/dist/collection/components/vega-input-phone-number/slimmers/controllers/country-select-controller.js +18 -8
- package/dist/collection/components/vega-input-phone-number/slimmers/renderers/country-select-renderer.js +26 -36
- package/dist/collection/components/vega-input-phone-number/slimmers/renderers/phone-number-input-renderer.js +1 -0
- package/dist/collection/components/vega-input-phone-number/vega-input-phone-number.js +0 -2
- package/dist/collection/components/vega-input-select/vega-input-select.js +1 -1
- package/dist/collection/components/vega-pagination/vega-pagination.js +6 -2
- package/dist/collection/components/vega-table/slimmers/controllers/vega-table-data-source-controller.js +1 -3
- package/dist/collection/components/vega-table/slimmers/controllers/vega-table-sort-controller.js +30 -29
- package/dist/collection/components/vega-table/slimmers/controllers/vega-table-sorter.js +33 -0
- package/dist/collection/components/vega-table/test/vega-table-sorter.test.js +508 -0
- package/dist/collection/constants/ui.js +1 -0
- package/dist/collection/helpers/change-manager/subject/static-remote-invocation-subject/static-remote-invocation-call-registry.js +3 -3
- package/dist/collection/helpers/change-manager/subject/static-subject/static-subject-title.js +1 -0
- package/dist/collection/helpers/change-manager/test/static-remote-invocation-subject.test.js +3 -3
- package/dist/collection/helpers/event-manager/event-id/vega-event-id.js +1 -1
- package/dist/collection/helpers/formatter/string-formatter/custom-formatter-strategy.js +16 -4
- package/dist/collection/helpers/formatter/test/string-formatter/custom-formatter-strategy.test.js +7 -2
- package/dist/collection/helpers/slimmers/form-field-controller-slimmer.js +9 -3
- package/dist/collection/helpers/slimmers/test/form-field-controller-slimmer.test.js +17 -0
- package/dist/collection/helpers/vega-telemetry-helper/test/vega-env-manager.test.js +1 -1
- package/dist/collection/helpers/vega-telemetry-helper/vega-env-manager.js +2 -2
- package/dist/collection/utils/e2e-utils.js +6 -2
- package/dist/esm/{app-globals-f06cad68.js → app-globals-565328e2.js} +2 -2
- package/dist/esm/{array-8c82516c.js → array-506b88b9.js} +1 -1
- package/dist/esm/{child-nodes-event-prevent-slimmer-64aa84be.js → child-nodes-event-prevent-slimmer-75851864.js} +1 -1
- package/dist/esm/{event-emit-slimmer-61856017.js → event-emit-slimmer-929b3e70.js} +1 -1
- package/dist/esm/{form-field-controller-slimmer-f8f42321.js → form-field-controller-slimmer-b237bb58.js} +11 -5
- package/dist/esm/index-c3505689.js +4 -0
- package/dist/esm/index.js +3 -3
- package/dist/esm/{internal-vega-event-manager-16ece1ab.js → internal-vega-event-manager-b0d04798.js} +1 -1
- package/dist/esm/{legend-input-processor-ea4840cb.js → legend-input-processor-abb0b4f4.js} +1 -1
- package/dist/esm/loader.js +5 -5
- package/dist/esm/{mutation-observer-filters-8e5cb1e0.js → mutation-observer-filters-a484f098.js} +1 -1
- package/dist/esm/static-remote-invocation-call-registry-56d7e6b2.js +62 -0
- package/dist/esm/{static-subject-title-2a4d6602.js → static-subject-title-2e153754.js} +3 -1
- package/dist/esm/vega-accordion.entry.js +5 -5
- package/dist/esm/vega-app-header-button.entry.js +4 -4
- package/dist/esm/vega-banner.entry.js +3 -3
- package/dist/esm/vega-bar-chart.entry.js +3 -3
- package/dist/esm/vega-breadcrumb.entry.js +6 -8
- package/dist/esm/vega-button-circle.entry.js +5 -5
- package/dist/esm/vega-button-group_2.entry.js +4 -4
- package/dist/esm/vega-button-link.entry.js +4 -4
- package/dist/esm/vega-button.entry.js +5 -5
- package/dist/esm/vega-calendar_3.entry.js +53 -17
- package/dist/esm/vega-carousel.entry.js +3 -3
- package/dist/esm/vega-checkbox_2.entry.js +8 -8
- package/dist/esm/vega-chip.entry.js +4 -4
- package/dist/esm/vega-color-picker.entry.js +7 -7
- package/dist/esm/vega-combo-box.entry.js +8 -8
- package/dist/esm/vega-date-picker_2.entry.js +8 -8
- package/dist/esm/vega-dialog_2.entry.js +4 -4
- package/dist/esm/vega-dropdown_5.entry.js +24 -6
- package/dist/esm/vega-env-manager-8f8dc473.js +2 -2
- package/dist/esm/{vega-event-id-e2ea4301.js → vega-event-id-13e22d1e.js} +1 -1
- package/dist/esm/vega-field-error.entry.js +1 -1
- package/dist/esm/vega-field-label.entry.js +4 -4
- package/dist/esm/vega-form.entry.js +8 -8
- package/dist/esm/vega-hint.entry.js +34 -0
- package/dist/esm/vega-image-uploader.entry.js +8 -8
- package/dist/esm/vega-input-credit-card.entry.js +8 -8
- package/dist/esm/vega-input-phone-number.entry.js +48 -52
- package/dist/esm/vega-input-range.entry.js +8 -8
- package/dist/esm/vega-input-select.entry.js +8 -8
- package/dist/esm/vega-input.entry.js +24 -13
- package/dist/esm/vega-item-toggle.entry.js +3 -3
- package/dist/esm/vega-left-nav_5.entry.js +4 -4
- package/dist/esm/vega-line-chart.entry.js +3 -3
- package/dist/esm/vega-page-notification_2.entry.js +1 -1
- package/dist/esm/vega-pagination.entry.js +10 -6
- package/dist/esm/vega-pie-chart.entry.js +2 -2
- package/dist/esm/vega-popover_2.entry.js +3 -3
- package/dist/esm/vega-progress-tracker.entry.js +3 -3
- package/dist/esm/vega-radio_2.entry.js +9 -9
- package/dist/esm/vega-segment-control.entry.js +3 -3
- package/dist/esm/vega-selection-tile_2.entry.js +8 -8
- package/dist/esm/vega-signature-capture.entry.js +7 -7
- package/dist/esm/{vega-skeleton-loader-controller-5ac7211f.js → vega-skeleton-loader-controller-7378a2e4.js} +1 -1
- package/dist/esm/vega-stepper.entry.js +8 -8
- package/dist/esm/vega-tab-group_2.entry.js +5 -5
- package/dist/esm/vega-table_8.entry.js +71 -39
- package/dist/esm/vega-textarea.entry.js +8 -8
- package/dist/esm/vega-time-picker_2.entry.js +8 -8
- package/dist/esm/vega-toggle-switch.entry.js +3 -3
- package/dist/esm/vega.js +5 -5
- package/dist/esm/{y-axis-input-processor-1d9192ae.js → y-axis-input-processor-08c89594.js} +2 -2
- package/dist/types/components/vega-calendar/vega-calendar-event/slimmers/controllers/vega-calendar-sub-state-controller.d.ts +1 -0
- package/dist/types/components/vega-calendar/vega-calendar-event/slimmers/renderers/vega-calendar-event-renderer.d.ts +2 -1
- package/dist/types/components/vega-calendar/vega-calendar-event/vega-calendar-event.d.ts +1 -0
- package/dist/types/components/vega-calendar/vega-calendar.d.ts +11 -0
- package/dist/types/components/vega-dropdown/slimmers/renderers/vega-dropdown-item-level-renderer.d.ts +3 -0
- package/dist/types/components/vega-hint/vega-hint.d.ts +11 -0
- package/dist/types/components/vega-input/types.d.ts +1 -0
- package/dist/types/components/vega-input-phone-number/slimmers/controllers/country-select-controller.d.ts +9 -5
- package/dist/types/components/vega-input-phone-number/slimmers/renderers/country-select-renderer.d.ts +3 -13
- package/dist/types/components/vega-input-phone-number/vega-input-phone-number.d.ts +0 -1
- package/dist/types/components/vega-input-select/types.d.ts +1 -0
- package/dist/types/components/vega-table/slimmers/controllers/vega-table-sort-controller.d.ts +3 -3
- package/dist/types/components/vega-table/slimmers/controllers/vega-table-sorter.d.ts +27 -0
- package/dist/types/components/vega-table/test/vega-table-sorter.test.d.ts +1 -0
- package/dist/types/components/vega-table/vega-table.d.ts +3 -2
- package/dist/types/components.d.ts +21 -0
- package/dist/types/constants/ui.d.ts +1 -1
- package/dist/types/helpers/change-manager/subject/static-remote-invocation-subject/static-remote-invocation-call-registry.d.ts +3 -3
- package/dist/types/helpers/change-manager/subject/static-subject/static-subject-title.d.ts +2 -1
- package/dist/types/helpers/formatter/string-formatter/custom-formatter-strategy.d.ts +6 -3
- package/dist/types/helpers/slimmers/form-field-controller-slimmer.d.ts +4 -1
- package/dist/types/utils/e2e-utils.d.ts +2 -0
- package/dist/vega/index.esm.js +1 -1
- package/dist/vega/{p-b0cbbf88.entry.js → p-0629c827.entry.js} +1 -1
- package/dist/vega/{p-2a08269c.entry.js → p-0a157187.entry.js} +1 -1
- package/dist/vega/{p-9eef4b8c.entry.js → p-0fdbffc4.entry.js} +1 -1
- package/dist/vega/{p-ce48be2b.entry.js → p-10456650.entry.js} +1 -1
- package/dist/vega/{p-4b1ed9e1.entry.js → p-1496ae4a.entry.js} +1 -1
- package/dist/vega/{p-72f38014.entry.js → p-15604d96.entry.js} +1 -1
- package/dist/vega/{p-0776022d.entry.js → p-1e7118b1.entry.js} +1 -1
- package/dist/vega/p-1f52fbdc.entry.js +1 -0
- package/dist/vega/{p-a2c10ac6.entry.js → p-2113e8a0.entry.js} +1 -1
- package/dist/vega/{p-52171abe.entry.js → p-21688c09.entry.js} +1 -1
- package/dist/vega/p-22cffbcc.entry.js +1 -0
- package/dist/vega/{p-f8975f50.js → p-33596687.js} +1 -1
- package/dist/vega/{p-96fda429.entry.js → p-394a4289.entry.js} +1 -1
- package/dist/vega/{p-27327fc6.js → p-3f20d9f0.js} +1 -1
- package/dist/vega/{p-91077f54.entry.js → p-4c919221.entry.js} +1 -1
- package/dist/vega/{p-75a78fcb.entry.js → p-4cf6fea1.entry.js} +1 -1
- package/dist/vega/p-4d4648f8.js +1 -0
- package/dist/vega/{p-88b42b8e.js → p-4dc711c1.js} +1 -1
- package/dist/vega/p-507d3a25.js +1 -0
- package/dist/vega/p-5f136969.entry.js +1 -0
- package/dist/vega/p-5f377954.js +1 -1
- package/dist/vega/{p-dcf93050.entry.js → p-68ead15a.entry.js} +1 -1
- package/dist/vega/{p-f155aba3.entry.js → p-6aab349d.entry.js} +1 -1
- package/dist/vega/{p-59373fa3.entry.js → p-6d7fa33c.entry.js} +1 -1
- package/dist/vega/p-7b2315b5.entry.js +1 -0
- package/dist/vega/{p-f7236eef.entry.js → p-8f13530c.entry.js} +1 -1
- package/dist/vega/{p-9e0314dd.entry.js → p-9c3ed69a.entry.js} +1 -1
- package/dist/vega/{p-1951d74f.entry.js → p-9d58efb1.entry.js} +1 -1
- package/dist/vega/{p-fbc0f4fd.js → p-9fc2882a.js} +1 -1
- package/dist/vega/{p-0477bb3e.entry.js → p-a1557df0.entry.js} +1 -1
- package/dist/vega/{p-beaeeaaf.entry.js → p-a8b216c0.entry.js} +1 -1
- package/dist/vega/{p-122dd21c.entry.js → p-a8f406e3.entry.js} +1 -1
- package/dist/vega/p-ae403881.entry.js +1 -0
- package/dist/vega/p-af4e1120.entry.js +1 -0
- package/dist/vega/{p-9ddfbe02.entry.js → p-b211ca98.entry.js} +1 -1
- package/dist/vega/{p-8250b935.js → p-b32611f0.js} +1 -1
- package/dist/vega/p-b8a63b73.js +1 -0
- package/dist/vega/{p-37e34b11.entry.js → p-b8e45e21.entry.js} +1 -1
- package/dist/vega/p-bb63021c.entry.js +1 -0
- package/dist/vega/{p-d77148c0.entry.js → p-bc37ab37.entry.js} +1 -1
- package/dist/vega/{p-d87980fe.js → p-c216dfc3.js} +1 -1
- package/dist/vega/{p-5ebb355b.js → p-c4542d96.js} +1 -1
- package/dist/vega/{p-6f62b38f.entry.js → p-ca905ecc.entry.js} +1 -1
- package/dist/vega/{p-11e7deae.entry.js → p-cbb1c0a7.entry.js} +1 -1
- package/dist/vega/{p-516b24fc.entry.js → p-cee7b0e6.entry.js} +1 -1
- package/dist/vega/{p-9d75e265.entry.js → p-cf0c2937.entry.js} +1 -1
- package/dist/vega/{p-bd19100b.entry.js → p-d5e0c79c.entry.js} +1 -1
- package/dist/vega/{p-1c1ebbbf.entry.js → p-d7b21179.entry.js} +1 -1
- package/dist/vega/{p-0d7d26a1.entry.js → p-db129cbf.entry.js} +1 -1
- package/dist/vega/{p-7d2ef81d.js → p-ddc70a7b.js} +1 -1
- package/dist/vega/{p-8b4e8250.entry.js → p-e48c71be.entry.js} +1 -1
- package/dist/vega/p-e66d54c5.entry.js +1 -0
- package/dist/vega/{p-f9dc62a3.entry.js → p-e9851b18.entry.js} +1 -1
- package/dist/vega/{p-f3f22a96.entry.js → p-ed0d4be8.entry.js} +1 -1
- package/dist/vega/{p-69b28805.js → p-ee68920f.js} +1 -1
- package/dist/vega/{p-be57a828.entry.js → p-f58e4e4a.entry.js} +1 -1
- package/dist/vega/p-f5ebc64a.js +1 -0
- package/dist/vega/{p-4aa84e12.entry.js → p-faf4cfd8.entry.js} +1 -1
- package/dist/vega/{p-2295b3e5.entry.js → p-fb7ca3e4.entry.js} +1 -1
- package/dist/vega/{p-dcde7c0f.entry.js → p-fbd75ce7.entry.js} +1 -1
- package/dist/vega/vega.esm.js +1 -1
- package/package.json +1 -1
- package/dist/vega/p-08c6ec82.entry.js +0 -1
- package/dist/vega/p-277e29a4.entry.js +0 -1
- package/dist/vega/p-53f24899.entry.js +0 -1
- package/dist/vega/p-6ddc92df.entry.js +0 -1
- package/dist/vega/p-b07f0e8c.entry.js +0 -1
- package/dist/vega/p-bb491bed.js +0 -1
- package/dist/vega/p-cbeb3e3c.entry.js +0 -1
- package/dist/vega/p-d165d4b7.js +0 -1
- package/dist/vega/p-dd9e0b55.entry.js +0 -1
- package/dist/vega/p-ec045268.js +0 -1
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
import { VegaTableSortController } from '../slimmers/controllers/vega-table-sort-controller';
|
|
2
|
+
import { VegaTableSorter } from '../slimmers/controllers/vega-table-sorter';
|
|
3
|
+
describe('VegaTableSorter', () => {
|
|
4
|
+
const sortController = new VegaTableSortController();
|
|
5
|
+
function sortData(data, sorters) {
|
|
6
|
+
const updatedSorters = sorters.map((s) => {
|
|
7
|
+
return new VegaTableSorter(s.prop, s.order, s.sorter);
|
|
8
|
+
});
|
|
9
|
+
return sortController.sortData([...data], updatedSorters);
|
|
10
|
+
}
|
|
11
|
+
describe('should handle single sorting as expected', () => {
|
|
12
|
+
it('should sort by amount in desc', () => {
|
|
13
|
+
const data = [
|
|
14
|
+
{
|
|
15
|
+
amount: 100,
|
|
16
|
+
balance: 100,
|
|
17
|
+
date: '01/01/2022',
|
|
18
|
+
key: '1',
|
|
19
|
+
name: 'A',
|
|
20
|
+
status: 'In Progress',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
amount: 300,
|
|
24
|
+
balance: 200,
|
|
25
|
+
date: '01/02/2022',
|
|
26
|
+
key: '2',
|
|
27
|
+
name: 'D',
|
|
28
|
+
status: 'In Progress',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
amount: 400,
|
|
32
|
+
balance: 300,
|
|
33
|
+
date: '01/03/2022',
|
|
34
|
+
key: '3',
|
|
35
|
+
name: 'B',
|
|
36
|
+
status: 'Not Started',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
amount: 200,
|
|
40
|
+
balance: 400,
|
|
41
|
+
date: '01/04/2022',
|
|
42
|
+
key: '4',
|
|
43
|
+
name: 'C',
|
|
44
|
+
status: 'Pending',
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
const sorters = [
|
|
48
|
+
{
|
|
49
|
+
prop: 'amount',
|
|
50
|
+
order: 'desc',
|
|
51
|
+
sorter: (a, b) => {
|
|
52
|
+
return a['amount'] - b['amount'];
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
];
|
|
56
|
+
expect(sortData(data, sorters)).toEqual([
|
|
57
|
+
{
|
|
58
|
+
amount: 400,
|
|
59
|
+
balance: 300,
|
|
60
|
+
date: '01/03/2022',
|
|
61
|
+
key: '3',
|
|
62
|
+
name: 'B',
|
|
63
|
+
status: 'Not Started',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
amount: 300,
|
|
67
|
+
balance: 200,
|
|
68
|
+
date: '01/02/2022',
|
|
69
|
+
key: '2',
|
|
70
|
+
name: 'D',
|
|
71
|
+
status: 'In Progress',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
amount: 200,
|
|
75
|
+
balance: 400,
|
|
76
|
+
date: '01/04/2022',
|
|
77
|
+
key: '4',
|
|
78
|
+
name: 'C',
|
|
79
|
+
status: 'Pending',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
amount: 100,
|
|
83
|
+
balance: 100,
|
|
84
|
+
date: '01/01/2022',
|
|
85
|
+
key: '1',
|
|
86
|
+
name: 'A',
|
|
87
|
+
status: 'In Progress',
|
|
88
|
+
},
|
|
89
|
+
]);
|
|
90
|
+
});
|
|
91
|
+
it('should sort by balance in desc', () => {
|
|
92
|
+
const data = [
|
|
93
|
+
{
|
|
94
|
+
amount: 100,
|
|
95
|
+
balance: 100,
|
|
96
|
+
date: '01/01/2022',
|
|
97
|
+
key: '1',
|
|
98
|
+
name: 'A',
|
|
99
|
+
status: 'In Progress',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
amount: 300,
|
|
103
|
+
balance: 200,
|
|
104
|
+
date: '01/02/2022',
|
|
105
|
+
key: '2',
|
|
106
|
+
name: 'D',
|
|
107
|
+
status: 'In Progress',
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
amount: 400,
|
|
111
|
+
balance: 300,
|
|
112
|
+
date: '01/03/2022',
|
|
113
|
+
key: '3',
|
|
114
|
+
name: 'B',
|
|
115
|
+
status: 'Not Started',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
amount: 200,
|
|
119
|
+
balance: 400,
|
|
120
|
+
date: '01/04/2022',
|
|
121
|
+
key: '4',
|
|
122
|
+
name: 'C',
|
|
123
|
+
status: 'Pending',
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
const sorters = [
|
|
127
|
+
{
|
|
128
|
+
prop: 'balance',
|
|
129
|
+
order: 'desc',
|
|
130
|
+
sorter: (a, b) => {
|
|
131
|
+
return a['balance'] - b['balance'];
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
];
|
|
135
|
+
expect(sortData(data, sorters)).toEqual([
|
|
136
|
+
{
|
|
137
|
+
amount: 200,
|
|
138
|
+
balance: 400,
|
|
139
|
+
date: '01/04/2022',
|
|
140
|
+
key: '4',
|
|
141
|
+
name: 'C',
|
|
142
|
+
status: 'Pending',
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
amount: 400,
|
|
146
|
+
balance: 300,
|
|
147
|
+
date: '01/03/2022',
|
|
148
|
+
key: '3',
|
|
149
|
+
name: 'B',
|
|
150
|
+
status: 'Not Started',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
amount: 300,
|
|
154
|
+
balance: 200,
|
|
155
|
+
date: '01/02/2022',
|
|
156
|
+
key: '2',
|
|
157
|
+
name: 'D',
|
|
158
|
+
status: 'In Progress',
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
amount: 100,
|
|
162
|
+
balance: 100,
|
|
163
|
+
date: '01/01/2022',
|
|
164
|
+
key: '1',
|
|
165
|
+
name: 'A',
|
|
166
|
+
status: 'In Progress',
|
|
167
|
+
},
|
|
168
|
+
]);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
describe('should handle multi-sorting sorting as expected', () => {
|
|
172
|
+
it('should sort by age, then by score and where age is the same, sort by score', () => {
|
|
173
|
+
const data = [
|
|
174
|
+
{ age: 25, score: 90 },
|
|
175
|
+
{ age: 20, score: 85 },
|
|
176
|
+
{ age: 25, score: 95 },
|
|
177
|
+
{ age: 30, score: 85 },
|
|
178
|
+
{ age: 20, score: 80 },
|
|
179
|
+
{ age: 20, score: 100 },
|
|
180
|
+
{ age: 25, score: 85 },
|
|
181
|
+
{ age: 25, score: 85 },
|
|
182
|
+
{ age: 30, score: 90 },
|
|
183
|
+
{ age: 30, score: 90 },
|
|
184
|
+
{ age: 30, score: 85 },
|
|
185
|
+
];
|
|
186
|
+
const sorters = [
|
|
187
|
+
{
|
|
188
|
+
prop: 'age',
|
|
189
|
+
order: 'asc',
|
|
190
|
+
sorter: (a, b) => {
|
|
191
|
+
return a['age'] - b['age'];
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
prop: 'score',
|
|
196
|
+
order: 'asc',
|
|
197
|
+
sorter: (a, b) => {
|
|
198
|
+
return a['score'] - b['score'];
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
];
|
|
202
|
+
expect(sortData(data, sorters)).toEqual([
|
|
203
|
+
{ age: 20, score: 80 },
|
|
204
|
+
{ age: 20, score: 85 },
|
|
205
|
+
{ age: 20, score: 100 },
|
|
206
|
+
{ age: 25, score: 85 },
|
|
207
|
+
{ age: 25, score: 85 },
|
|
208
|
+
{ age: 25, score: 90 },
|
|
209
|
+
{ age: 25, score: 95 },
|
|
210
|
+
{ age: 30, score: 85 },
|
|
211
|
+
{ age: 30, score: 85 },
|
|
212
|
+
{ age: 30, score: 90 },
|
|
213
|
+
{ age: 30, score: 90 },
|
|
214
|
+
]);
|
|
215
|
+
});
|
|
216
|
+
it('should sort by name, age and where name is the same, sort by age', () => {
|
|
217
|
+
const data = [
|
|
218
|
+
{ name: 'Alice', age: 25, score: 88 },
|
|
219
|
+
{ name: 'Bob', age: 22, score: 95 },
|
|
220
|
+
{ name: 'Charlie', age: 25, score: 82 },
|
|
221
|
+
{ name: 'Alice', age: 28, score: 78 },
|
|
222
|
+
{ name: 'Bob', age: 22, score: 90 },
|
|
223
|
+
];
|
|
224
|
+
const sorters = [
|
|
225
|
+
{
|
|
226
|
+
prop: 'name',
|
|
227
|
+
order: 'asc',
|
|
228
|
+
sorter: (a, b) => {
|
|
229
|
+
return a.name.localeCompare(b.name);
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
prop: 'age',
|
|
234
|
+
order: 'asc',
|
|
235
|
+
sorter: (a, b) => {
|
|
236
|
+
return a['age'] - b['age'];
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
];
|
|
240
|
+
expect(sortData(data, sorters)).toEqual([
|
|
241
|
+
{ name: 'Alice', age: 25, score: 88 },
|
|
242
|
+
{ name: 'Alice', age: 28, score: 78 },
|
|
243
|
+
{ name: 'Bob', age: 22, score: 95 },
|
|
244
|
+
{ name: 'Bob', age: 22, score: 90 },
|
|
245
|
+
{ name: 'Charlie', age: 25, score: 82 },
|
|
246
|
+
]);
|
|
247
|
+
});
|
|
248
|
+
it('should sort by age, score and where age is the same, sort by score', () => {
|
|
249
|
+
const data = [
|
|
250
|
+
{ age: 25, score: 88 },
|
|
251
|
+
{ age: 22, score: 95 },
|
|
252
|
+
{ age: 25, score: 82 },
|
|
253
|
+
{ age: 28, score: 78 },
|
|
254
|
+
{ age: 22, score: 90 },
|
|
255
|
+
];
|
|
256
|
+
const sorters = [
|
|
257
|
+
{
|
|
258
|
+
prop: 'age',
|
|
259
|
+
order: 'asc',
|
|
260
|
+
sorter: (a, b) => {
|
|
261
|
+
return a['age'] - b['age'];
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
prop: 'score',
|
|
266
|
+
order: 'asc',
|
|
267
|
+
sorter: (a, b) => {
|
|
268
|
+
return a['score'] - b['score'];
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
];
|
|
272
|
+
expect(sortData(data, sorters)).toEqual([
|
|
273
|
+
{ age: 22, score: 90 },
|
|
274
|
+
{ age: 22, score: 95 },
|
|
275
|
+
{ age: 25, score: 82 },
|
|
276
|
+
{ age: 25, score: 88 },
|
|
277
|
+
{ age: 28, score: 78 },
|
|
278
|
+
]);
|
|
279
|
+
});
|
|
280
|
+
it('should sort by name, age, score and where name is the same, sort by age, and where age is the same, sort by score', () => {
|
|
281
|
+
const data = [
|
|
282
|
+
{ name: 'Alice', age: 25, score: 88 },
|
|
283
|
+
{ name: 'Bob', age: 22, score: 95 },
|
|
284
|
+
{ name: 'Charlie', age: 25, score: 82 },
|
|
285
|
+
{ name: 'Alice', age: 28, score: 78 },
|
|
286
|
+
{ name: 'Bob', age: 22, score: 90 },
|
|
287
|
+
];
|
|
288
|
+
const sorters = [
|
|
289
|
+
{
|
|
290
|
+
prop: 'name',
|
|
291
|
+
order: 'asc',
|
|
292
|
+
sorter: (a, b) => {
|
|
293
|
+
return a.name.localeCompare(b.name);
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
prop: 'age',
|
|
298
|
+
order: 'asc',
|
|
299
|
+
sorter: (a, b) => {
|
|
300
|
+
return a['age'] - b['age'];
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
prop: 'score',
|
|
305
|
+
order: 'asc',
|
|
306
|
+
sorter: (a, b) => {
|
|
307
|
+
return a['score'] - b['score'];
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
];
|
|
311
|
+
expect(sortData(data, sorters)).toEqual([
|
|
312
|
+
{ name: 'Alice', age: 25, score: 88 },
|
|
313
|
+
{ name: 'Alice', age: 28, score: 78 },
|
|
314
|
+
{ name: 'Bob', age: 22, score: 90 },
|
|
315
|
+
{ name: 'Bob', age: 22, score: 95 },
|
|
316
|
+
{ name: 'Charlie', age: 25, score: 82 },
|
|
317
|
+
]);
|
|
318
|
+
});
|
|
319
|
+
it('should primarily sort by amount in desc order and if no tie in amount, secondary sorting of balance should not change sorted amount in desc', () => {
|
|
320
|
+
const data = [
|
|
321
|
+
{
|
|
322
|
+
amount: 100,
|
|
323
|
+
balance: 100,
|
|
324
|
+
date: '01/01/2022',
|
|
325
|
+
key: '1',
|
|
326
|
+
name: 'A',
|
|
327
|
+
status: 'In Progress',
|
|
328
|
+
},
|
|
329
|
+
{
|
|
330
|
+
amount: 300,
|
|
331
|
+
balance: 200,
|
|
332
|
+
date: '01/02/2022',
|
|
333
|
+
key: '2',
|
|
334
|
+
name: 'D',
|
|
335
|
+
status: 'In Progress',
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
amount: 400,
|
|
339
|
+
balance: 300,
|
|
340
|
+
date: '01/03/2022',
|
|
341
|
+
key: '3',
|
|
342
|
+
name: 'B',
|
|
343
|
+
status: 'Not Started',
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
amount: 200,
|
|
347
|
+
balance: 400,
|
|
348
|
+
date: '01/04/2022',
|
|
349
|
+
key: '4',
|
|
350
|
+
name: 'C',
|
|
351
|
+
status: 'Pending',
|
|
352
|
+
},
|
|
353
|
+
];
|
|
354
|
+
const sorters = [
|
|
355
|
+
{
|
|
356
|
+
prop: 'amount',
|
|
357
|
+
order: 'desc',
|
|
358
|
+
sorter: (a, b) => {
|
|
359
|
+
return a['amount'] - b['amount'];
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
prop: 'balance',
|
|
364
|
+
order: 'desc',
|
|
365
|
+
sorter: (a, b) => {
|
|
366
|
+
return a['balance'] - b['balance'];
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
];
|
|
370
|
+
expect(sortData(data, sorters)).toEqual([
|
|
371
|
+
{
|
|
372
|
+
amount: 400,
|
|
373
|
+
balance: 300,
|
|
374
|
+
date: '01/03/2022',
|
|
375
|
+
key: '3',
|
|
376
|
+
name: 'B',
|
|
377
|
+
status: 'Not Started',
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
amount: 300,
|
|
381
|
+
balance: 200,
|
|
382
|
+
date: '01/02/2022',
|
|
383
|
+
key: '2',
|
|
384
|
+
name: 'D',
|
|
385
|
+
status: 'In Progress',
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
amount: 200,
|
|
389
|
+
balance: 400,
|
|
390
|
+
date: '01/04/2022',
|
|
391
|
+
key: '4',
|
|
392
|
+
name: 'C',
|
|
393
|
+
status: 'Pending',
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
amount: 100,
|
|
397
|
+
balance: 100,
|
|
398
|
+
date: '01/01/2022',
|
|
399
|
+
key: '1',
|
|
400
|
+
name: 'A',
|
|
401
|
+
status: 'In Progress',
|
|
402
|
+
},
|
|
403
|
+
]);
|
|
404
|
+
});
|
|
405
|
+
it('should sort by name A-Z then by amount from largest to smallest', () => {
|
|
406
|
+
const data = [
|
|
407
|
+
{
|
|
408
|
+
key: '1',
|
|
409
|
+
date: '01/03/2022',
|
|
410
|
+
name: 'C',
|
|
411
|
+
amount: 30,
|
|
412
|
+
amount2: 30,
|
|
413
|
+
balance: '$300',
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
key: '2',
|
|
417
|
+
date: '01/06/2022',
|
|
418
|
+
name: 'C',
|
|
419
|
+
amount: 20,
|
|
420
|
+
amount2: 20,
|
|
421
|
+
balance: '$400',
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
key: '3',
|
|
425
|
+
date: '01/05/2022',
|
|
426
|
+
name: 'C',
|
|
427
|
+
amount: 20,
|
|
428
|
+
amount2: 30,
|
|
429
|
+
balance: '$401',
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
key: '4',
|
|
433
|
+
date: '01/02/2022',
|
|
434
|
+
name: 'B',
|
|
435
|
+
amount: 20,
|
|
436
|
+
amount2: 125,
|
|
437
|
+
balance: '$200',
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
key: '5',
|
|
441
|
+
date: '01/04/2022',
|
|
442
|
+
name: 'D',
|
|
443
|
+
amount: 300,
|
|
444
|
+
amount2: 130,
|
|
445
|
+
balance: '$402',
|
|
446
|
+
},
|
|
447
|
+
];
|
|
448
|
+
const sorters = [
|
|
449
|
+
{
|
|
450
|
+
prop: 'name',
|
|
451
|
+
order: 'asc',
|
|
452
|
+
sorter: (a, b) => {
|
|
453
|
+
return a.name.localeCompare(b.name);
|
|
454
|
+
},
|
|
455
|
+
},
|
|
456
|
+
{
|
|
457
|
+
prop: 'amount',
|
|
458
|
+
order: 'desc',
|
|
459
|
+
sorter: (a, b) => {
|
|
460
|
+
return a['amount'] - b['amount'];
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
];
|
|
464
|
+
expect(sortData(data, sorters)).toEqual([
|
|
465
|
+
{
|
|
466
|
+
key: '4',
|
|
467
|
+
date: '01/02/2022',
|
|
468
|
+
name: 'B',
|
|
469
|
+
amount: 20,
|
|
470
|
+
amount2: 125,
|
|
471
|
+
balance: '$200',
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
key: '1',
|
|
475
|
+
date: '01/03/2022',
|
|
476
|
+
name: 'C',
|
|
477
|
+
amount: 30,
|
|
478
|
+
amount2: 30,
|
|
479
|
+
balance: '$300',
|
|
480
|
+
},
|
|
481
|
+
{
|
|
482
|
+
key: '2',
|
|
483
|
+
date: '01/06/2022',
|
|
484
|
+
name: 'C',
|
|
485
|
+
amount: 20,
|
|
486
|
+
amount2: 20,
|
|
487
|
+
balance: '$400',
|
|
488
|
+
},
|
|
489
|
+
{
|
|
490
|
+
key: '3',
|
|
491
|
+
date: '01/05/2022',
|
|
492
|
+
name: 'C',
|
|
493
|
+
amount: 20,
|
|
494
|
+
amount2: 30,
|
|
495
|
+
balance: '$401',
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
key: '5',
|
|
499
|
+
date: '01/04/2022',
|
|
500
|
+
name: 'D',
|
|
501
|
+
amount: 300,
|
|
502
|
+
amount2: 130,
|
|
503
|
+
balance: '$402',
|
|
504
|
+
},
|
|
505
|
+
]);
|
|
506
|
+
});
|
|
507
|
+
});
|
|
508
|
+
});
|
|
@@ -12,7 +12,7 @@ export class StaticRemoteInvocationCallRegistry {
|
|
|
12
12
|
* @param {unknown[]} args - The `args` parameter of specific method.
|
|
13
13
|
* @returns {unknown} The result of call `remoteInvocation`.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
call(subject, ...args) {
|
|
16
16
|
let result = null;
|
|
17
17
|
changeManager.notify(subject, {
|
|
18
18
|
args,
|
|
@@ -30,7 +30,7 @@ export class StaticRemoteInvocationCallRegistry {
|
|
|
30
30
|
* @param {Subject} subject - A static subject.
|
|
31
31
|
* @param {Function}remoteInvocationHandler - The method that is ultimately called.
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
register(subject, remoteInvocationHandler) {
|
|
34
34
|
const observer = new Observer(this.isAcceptableObserver.bind(this), (payload) => {
|
|
35
35
|
const result = remoteInvocationHandler(...payload.args);
|
|
36
36
|
payload.resultCallback(result);
|
|
@@ -42,7 +42,7 @@ export class StaticRemoteInvocationCallRegistry {
|
|
|
42
42
|
*
|
|
43
43
|
* @param {Subject} subject - A static subject.
|
|
44
44
|
*/
|
|
45
|
-
|
|
45
|
+
unRegister(subject) {
|
|
46
46
|
changeManager.clearObserversBySubject(subject);
|
|
47
47
|
}
|
|
48
48
|
/**
|
package/dist/collection/helpers/change-manager/subject/static-subject/static-subject-title.js
CHANGED
|
@@ -24,3 +24,4 @@ export const FIELD_ERROR_STATE_CHANGE = new StaticSubject('FIELD_ERROR_STATE_CHA
|
|
|
24
24
|
export const VEGA_VIRTUAL_SCROLL_TO_BOTTOM = new StaticSubject('VEGA_VIRTUAL_SCROLL_TO_BOTTOM');
|
|
25
25
|
export const SELECTION_TILE_VALUE_CHANGE = new StaticSubject('SELECTION_TILE_VALUE_CHANGE');
|
|
26
26
|
export const DROPDOWN_RENDER_ITEM_INTERNAL_OVERRIDEN = new StaticSubject('DROPDOWN_RENDER_ITEM_INTERNAL_OVERRIDEN');
|
|
27
|
+
export const DROPDOWN_SEARCH_INTERNAL_OVERRIDEN = new StaticSubject('DROPDOWN_SEARCH_INTERNAL_OVERRIDEN');
|
package/dist/collection/helpers/change-manager/test/static-remote-invocation-subject.test.js
CHANGED
|
@@ -4,11 +4,11 @@ import { DROPDOWN_RENDER_ITEM_INTERNAL_OVERRIDEN } from '../subject/static-subje
|
|
|
4
4
|
test('StaticRemoteInvocationCallRegistry', () => {
|
|
5
5
|
const length = changeManager['pubSubMap'].size;
|
|
6
6
|
const mockFun = jest.fn();
|
|
7
|
-
RemoteInvocationCallRegistry.
|
|
7
|
+
RemoteInvocationCallRegistry.register(DROPDOWN_RENDER_ITEM_INTERNAL_OVERRIDEN, mockFun);
|
|
8
8
|
expect(changeManager['pubSubMap'].size).toEqual(length + 1);
|
|
9
|
-
RemoteInvocationCallRegistry.
|
|
9
|
+
RemoteInvocationCallRegistry.call(DROPDOWN_RENDER_ITEM_INTERNAL_OVERRIDEN, 'a', 'b');
|
|
10
10
|
expect(mockFun).toBeCalledTimes(1);
|
|
11
11
|
expect(mockFun).toBeCalledWith('a', 'b');
|
|
12
|
-
RemoteInvocationCallRegistry.
|
|
12
|
+
RemoteInvocationCallRegistry.unRegister(DROPDOWN_RENDER_ITEM_INTERNAL_OVERRIDEN);
|
|
13
13
|
expect(changeManager['pubSubMap'].size).toEqual(length);
|
|
14
14
|
});
|
|
@@ -80,7 +80,7 @@ export const VegaToggleStatus = new VegaEventID('vegaToggleStatus', 'toggleStatu
|
|
|
80
80
|
export const VegaStateUpdate = new VegaEventID('vegaStateUpdate', 'stateUpdate');
|
|
81
81
|
export const VegaGroupClick = new VegaEventID('vegaGroupClick', 'groupClick');
|
|
82
82
|
export const VegaMenuClick = new VegaEventID('vegaMenuClick', 'menuClick');
|
|
83
|
-
export const VegaExpand = new VegaEventID('vegaExpand', '
|
|
83
|
+
export const VegaExpand = new VegaEventID('vegaExpand', 'expand');
|
|
84
84
|
export const VegaDropdownShow = new VegaEventID('vegaShow', 'dropdownShow');
|
|
85
85
|
export const VegaDropdownHide = new VegaEventID('vegaHide', 'dropdownHide');
|
|
86
86
|
export const VegaDropdownSearch = new VegaEventID('vegaSearch', 'dropdownSearch');
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNonNullable } from '../../../types/type-guard';
|
|
1
2
|
/**
|
|
2
3
|
* Used to format a string using a custom formatter.
|
|
3
4
|
*/
|
|
@@ -10,9 +11,12 @@ export class CustomFormatterStrategy {
|
|
|
10
11
|
* string formatter class that you are passing to the constructor of the class. This custom string
|
|
11
12
|
* formatter class likely contains methods or properties related to formatting strings in a specific
|
|
12
13
|
* way according to your requirements.
|
|
14
|
+
* @param {boolean} resetCaretPosition - The caret position should update to the last or keep the current position after format
|
|
13
15
|
*/
|
|
14
|
-
constructor(formatter) {
|
|
16
|
+
constructor(formatter, resetCaretPosition = false) {
|
|
17
|
+
this.resetCaretPositionFlag = false;
|
|
15
18
|
this.formatter = formatter;
|
|
19
|
+
this.resetCaretPositionFlag = resetCaretPosition;
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
18
22
|
* The format function in TypeScript takes a string input and returns the formatted output using a
|
|
@@ -31,16 +35,24 @@ export class CustomFormatterStrategy {
|
|
|
31
35
|
*
|
|
32
36
|
* @param {string} input - The `input` parameter in the `calculateCaretPosition` function is a string
|
|
33
37
|
* that represents the text input where you want to calculate the caret position.
|
|
38
|
+
* @param {number} caretPosition - The current position of caret
|
|
34
39
|
* @returns {Nullable<number>} The `calculateCaretPosition` function is returning the length of the formatted input
|
|
35
40
|
* string.
|
|
36
41
|
*/
|
|
37
|
-
calculateCaretPosition(input) {
|
|
38
|
-
|
|
42
|
+
calculateCaretPosition(input, caretPosition) {
|
|
43
|
+
if (this.resetCaretPositionFlag === true) {
|
|
44
|
+
return this.format(input).length;
|
|
45
|
+
}
|
|
46
|
+
else if (isNonNullable(caretPosition)) {
|
|
47
|
+
const startValue = input.substring(0, caretPosition);
|
|
48
|
+
const maskedStartValue = this.format(startValue);
|
|
49
|
+
return caretPosition + (maskedStartValue.length - startValue.length);
|
|
50
|
+
}
|
|
39
51
|
}
|
|
40
52
|
/**
|
|
41
53
|
* Trigger the formatter at init
|
|
42
54
|
*
|
|
43
|
-
* @returns {boolean} true
|
|
55
|
+
* @returns {boolean} true or false
|
|
44
56
|
*/
|
|
45
57
|
shouldTriggerAtInit() {
|
|
46
58
|
return true;
|
package/dist/collection/helpers/formatter/test/string-formatter/custom-formatter-strategy.test.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { CustomFormatterStrategy } from '../../string-formatter/custom-formatter-strategy';
|
|
2
2
|
test('custom formatter strategy is working as expected', () => {
|
|
3
|
-
const customFormatterStrategy = new CustomFormatterStrategy((value) => value.toUpperCase());
|
|
3
|
+
const customFormatterStrategy = new CustomFormatterStrategy((value) => value.toUpperCase(), true);
|
|
4
4
|
expect(customFormatterStrategy.format('test')).toBe('TEST');
|
|
5
|
-
expect(customFormatterStrategy.calculateCaretPosition('test')).toBe(4);
|
|
5
|
+
expect(customFormatterStrategy.calculateCaretPosition('test', null)).toBe(4);
|
|
6
6
|
expect(customFormatterStrategy.shouldTriggerAtInit()).toBe(true);
|
|
7
7
|
});
|
|
8
|
+
test('custom formatter strategy method calculateCaretPosition is working as expected', () => {
|
|
9
|
+
const customFormatterStrategy = new CustomFormatterStrategy((value) => value.toUpperCase());
|
|
10
|
+
expect(customFormatterStrategy.calculateCaretPosition('test', null)).toBe(undefined);
|
|
11
|
+
expect(customFormatterStrategy.calculateCaretPosition('test', 3)).toBe(3);
|
|
12
|
+
});
|
|
@@ -13,6 +13,7 @@ import { FORM_ELEMENT_VALIDATE } from '../change-manager/subject/static-subject/
|
|
|
13
13
|
import { FormFieldValidInvokeSlimmer } from './form-field-valid-invoke-slimmer';
|
|
14
14
|
import { MutationObserverSlimmer } from './mutation-observer/mutation-observer-slimmer';
|
|
15
15
|
import { AttributeOldValueMutationFilter } from './mutation-observer/mutation-observer-filters';
|
|
16
|
+
import { isArrayEqual } from '../../utils/array';
|
|
16
17
|
/**
|
|
17
18
|
* The `FormFieldControllerSlimmer` class is a TypeScript class that extends `VegaSlimmer` and provides functionality for managing form field components.
|
|
18
19
|
* TODO:
|
|
@@ -76,10 +77,15 @@ export class FormFieldControllerSlimmer extends VegaSlimmer {
|
|
|
76
77
|
/**
|
|
77
78
|
* watch the prop validationRules and call the valid method
|
|
78
79
|
* some components has not a prop validationRules
|
|
80
|
+
*
|
|
81
|
+
* @param {FormFieldValidationRule<unknown>[]} newRules the component property validationRules new value
|
|
82
|
+
* @param {FormFieldValidationRule<unknown>[]} oldRules the component property validationRules old value
|
|
79
83
|
*/
|
|
80
|
-
watchValidationRulesByFormControllerSlimmer() {
|
|
81
|
-
|
|
82
|
-
|
|
84
|
+
watchValidationRulesByFormControllerSlimmer(newRules, oldRules) {
|
|
85
|
+
if (!isArrayEqual(newRules, oldRules)) {
|
|
86
|
+
this.setAdditionalRules();
|
|
87
|
+
this.internalValidate();
|
|
88
|
+
}
|
|
83
89
|
}
|
|
84
90
|
/**
|
|
85
91
|
* inject form file help when componentWillLoad method call
|
|
@@ -247,6 +247,23 @@ describe('FormFieldControllerSlimmer test suite', () => {
|
|
|
247
247
|
mockedComponent['formFieldController']['getPropertyRules']();
|
|
248
248
|
expect(mockRule).toBeCalledWith(false, true);
|
|
249
249
|
});
|
|
250
|
+
test('should invoke validate method correct when validationRules change', () => {
|
|
251
|
+
const mockedComponent = new MockedComponent();
|
|
252
|
+
const internalValidate = jest.fn();
|
|
253
|
+
mockedComponent['formFieldController']['internalValidate'] = internalValidate;
|
|
254
|
+
const mockRule = {
|
|
255
|
+
evaluate: jest.fn(),
|
|
256
|
+
canEvaluate: jest.fn(),
|
|
257
|
+
shouldShowError: jest.fn(),
|
|
258
|
+
};
|
|
259
|
+
const mockRules = [mockRule];
|
|
260
|
+
mockedComponent['formFieldController']['watchValidationRulesByFormControllerSlimmer'](mockRules, mockRules);
|
|
261
|
+
expect(internalValidate).toBeCalledTimes(0);
|
|
262
|
+
mockedComponent['formFieldController']['watchValidationRulesByFormControllerSlimmer']([mockRule], [mockRule]);
|
|
263
|
+
expect(internalValidate).toBeCalledTimes(0);
|
|
264
|
+
mockedComponent['formFieldController']['watchValidationRulesByFormControllerSlimmer']([Object.assign({}, mockRule)], [mockRule]);
|
|
265
|
+
expect(internalValidate).toBeCalledTimes(1);
|
|
266
|
+
});
|
|
250
267
|
});
|
|
251
268
|
});
|
|
252
269
|
describe('FormFieldControllerSlimmer#isValidFormField', () => {
|