@ouestfrance/sipa-bms-ui 7.14.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/README.md +280 -0
- package/dist/assets/animated-icons/AnimatedActivityIcon.vue.d.ts +133 -0
- package/dist/assets/animated-icons/AnimatedCircleHelpIcon.vue.d.ts +133 -0
- package/dist/assets/animated-icons/AnimatedHomeIcon.vue.d.ts +133 -0
- package/dist/components/button/BmsButton.spec.d.ts +1 -0
- package/dist/components/button/BmsButton.vue.d.ts +24 -0
- package/dist/components/button/BmsIconButton.vue.d.ts +23 -0
- package/dist/components/button/UiButton.vue.d.ts +26 -0
- package/dist/components/button/UiButtonLink.vue.d.ts +20 -0
- package/dist/components/feedback/BmsAlert.vue.d.ts +24 -0
- package/dist/components/feedback/BmsBadge.vue.d.ts +18 -0
- package/dist/components/feedback/BmsCaption.vue.d.ts +6 -0
- package/dist/components/feedback/BmsCircularProgress.spec.d.ts +1 -0
- package/dist/components/feedback/BmsCircularProgress.vue.d.ts +6 -0
- package/dist/components/feedback/BmsLoader.spec.d.ts +1 -0
- package/dist/components/feedback/BmsLoader.vue.d.ts +9 -0
- package/dist/components/feedback/BmsTooltip.vue.d.ts +28 -0
- package/dist/components/feedback/UiTooltip.spec.d.ts +1 -0
- package/dist/components/feedback/UiTooltip.vue.d.ts +27 -0
- package/dist/components/feedback/tooltip.helper.d.ts +45 -0
- package/dist/components/feedback/tooltip.helper.spec.d.ts +1 -0
- package/dist/components/form/BmsAutocomplete.vue.d.ts +31 -0
- package/dist/components/form/BmsBetweenInput.vue.d.ts +32 -0
- package/dist/components/form/BmsChip.vue.d.ts +15 -0
- package/dist/components/form/BmsFilePicker.spec.d.ts +1 -0
- package/dist/components/form/BmsFilePicker.vue.d.ts +12 -0
- package/dist/components/form/BmsInputBooleanCheckbox.vue.d.ts +30 -0
- package/dist/components/form/BmsInputCheckboxCaption.spec.d.ts +1 -0
- package/dist/components/form/BmsInputCheckboxCaption.vue.d.ts +31 -0
- package/dist/components/form/BmsInputCheckboxCaptionGroup.vue.d.ts +25 -0
- package/dist/components/form/BmsInputCheckboxGroup.vue.d.ts +24 -0
- package/dist/components/form/BmsInputCode.vue.d.ts +27 -0
- package/dist/components/form/BmsInputDateTime.vue.d.ts +24 -0
- package/dist/components/form/BmsInputFile.spec.d.ts +1 -0
- package/dist/components/form/BmsInputFile.vue.d.ts +27 -0
- package/dist/components/form/BmsInputNumber.spec.d.ts +1 -0
- package/dist/components/form/BmsInputNumber.vue.d.ts +26 -0
- package/dist/components/form/BmsInputRadio.vue.d.ts +28 -0
- package/dist/components/form/BmsInputRadioCaption.vue.d.ts +30 -0
- package/dist/components/form/BmsInputRadioCaptionGroup.vue.d.ts +30 -0
- package/dist/components/form/BmsInputRadioGroup.vue.d.ts +30 -0
- package/dist/components/form/BmsInputText.spec.d.ts +1 -0
- package/dist/components/form/BmsInputText.vue.d.ts +128 -0
- package/dist/components/form/BmsInputToggle.vue.d.ts +15 -0
- package/dist/components/form/BmsSearch.spec.d.ts +1 -0
- package/dist/components/form/BmsSearch.vue.d.ts +187 -0
- package/dist/components/form/BmsSelect.spec.d.ts +1 -0
- package/dist/components/form/BmsSelect.vue.d.ts +34 -0
- package/dist/components/form/BmsTag.vue.d.ts +25 -0
- package/dist/components/form/BmsTextArea.spec.d.ts +1 -0
- package/dist/components/form/BmsTextArea.vue.d.ts +26 -0
- package/dist/components/form/RawAutocomplete.spec.d.ts +1 -0
- package/dist/components/form/RawAutocomplete.vue.d.ts +130 -0
- package/dist/components/form/RawInputText.vue.d.ts +42 -0
- package/dist/components/form/UiBmsInputCheckbox.vue.d.ts +28 -0
- package/dist/components/form/UiBmsSwitch.vue.d.ts +14 -0
- package/dist/components/layout/BmsCard.vue.d.ts +21 -0
- package/dist/components/layout/BmsContentPageLayout.vue.d.ts +17 -0
- package/dist/components/layout/BmsForm.vue.d.ts +7 -0
- package/dist/components/layout/BmsHeader.vue.d.ts +9 -0
- package/dist/components/layout/BmsHeaderTitle.vue.d.ts +22 -0
- package/dist/components/layout/BmsModal.spec.d.ts +1 -0
- package/dist/components/layout/BmsModal.vue.d.ts +60 -0
- package/dist/components/layout/BmsOverlay.vue.d.ts +13 -0
- package/dist/components/layout/BmsSection.vue.d.ts +15 -0
- package/dist/components/layout/BmsStep.vue.d.ts +27 -0
- package/dist/components/layout/BmsStepper.vue.d.ts +13 -0
- package/dist/components/layout/UiPopoverMenu.vue.d.ts +23 -0
- package/dist/components/navigation/BmsBackButton.vue.d.ts +13 -0
- package/dist/components/navigation/BmsBreadcrumb.vue.d.ts +12 -0
- package/dist/components/navigation/BmsLink.spec.d.ts +1 -0
- package/dist/components/navigation/BmsLink.vue.d.ts +22 -0
- package/dist/components/navigation/BmsMenu.spec.d.ts +1 -0
- package/dist/components/navigation/BmsMenu.vue.d.ts +21 -0
- package/dist/components/navigation/BmsMenuNav.spec.d.ts +1 -0
- package/dist/components/navigation/BmsMenuNav.vue.d.ts +23 -0
- package/dist/components/navigation/BmsShortLinkMenu.vue.d.ts +20 -0
- package/dist/components/navigation/BmsTabs.vue.d.ts +7 -0
- package/dist/components/navigation/BmsTenantSwitcher.vue.d.ts +22 -0
- package/dist/components/navigation/UiMenuItem.vue.d.ts +11 -0
- package/dist/components/navigation/UiTab.vue.d.ts +15 -0
- package/dist/components/navigation/UiTenantImage.vue.d.ts +6 -0
- package/dist/components/navigation/UiTenantLabel.vue.d.ts +12 -0
- package/dist/components/navigation/UiTenantSwitcher.spec.d.ts +1 -0
- package/dist/components/navigation/UiTenantSwitcher.vue.d.ts +189 -0
- package/dist/components/table/BmsEmptyScreen.vue.d.ts +6 -0
- package/dist/components/table/BmsPagination.spec.d.ts +1 -0
- package/dist/components/table/BmsPagination.vue.d.ts +35 -0
- package/dist/components/table/BmsServerTable.vue.d.ts +74 -0
- package/dist/components/table/BmsTable.spec.d.ts +1 -0
- package/dist/components/table/BmsTable.vue.d.ts +53 -0
- package/dist/components/table/BmsTableFilters.spec.d.ts +1 -0
- package/dist/components/table/BmsTableFilters.vue.d.ts +188 -0
- package/dist/components/table/DraggableList.vue.d.ts +26 -0
- package/dist/components/table/UiBmsTable.spec.d.ts +1 -0
- package/dist/components/table/UiBmsTable.vue.d.ts +66 -0
- package/dist/components/table/UiFilterButton.vue.d.ts +13 -0
- package/dist/components/utils/BmsCocarde.vue.d.ts +11 -0
- package/dist/components/utils/BmsProblem.vue.d.ts +9 -0
- package/dist/components/utils/BmsRelativeTime.spec.d.ts +1 -0
- package/dist/components/utils/BmsRelativeTime.vue.d.ts +11 -0
- package/dist/composables/clipboard.composable.d.ts +3 -0
- package/dist/composables/index.d.ts +5 -0
- package/dist/composables/pagination.composable.d.ts +14 -0
- package/dist/composables/pagination.composable.spec.d.ts +1 -0
- package/dist/composables/search.composable.d.ts +52 -0
- package/dist/composables/search.composable.spec.d.ts +1 -0
- package/dist/composables/search.helper.d.ts +7 -0
- package/dist/composables/search.helper.spec.d.ts +1 -0
- package/dist/composables/sort.composable.d.ts +10 -0
- package/dist/composables/sort.composable.spec.d.ts +1 -0
- package/dist/composables/userPref.composable.d.ts +6 -0
- package/dist/composables/userPref.composable.spec.d.ts +1 -0
- package/dist/favicon.ico +0 -0
- package/dist/helpers/cocarde.helper.d.ts +1 -0
- package/dist/helpers/cocarde.helper.spec.d.ts +1 -0
- package/dist/helpers/date.helper.d.ts +26 -0
- package/dist/helpers/date.helper.spec.d.ts +1 -0
- package/dist/helpers/file.helper.d.ts +5 -0
- package/dist/helpers/file.helper.spec.d.ts +1 -0
- package/dist/helpers/index.d.ts +6 -0
- package/dist/helpers/location.helper.d.ts +10 -0
- package/dist/helpers/location.helper.spec.d.ts +1 -0
- package/dist/helpers/problem.helper.d.ts +1 -0
- package/dist/helpers/problem.helper.spec.d.ts +1 -0
- package/dist/helpers/string.helper.d.ts +9 -0
- package/dist/helpers/string.helper.spec.d.ts +1 -0
- package/dist/helpers/table.helper.d.ts +16 -0
- package/dist/helpers/table.helper.spec.d.ts +1 -0
- package/dist/index.d.ts +72 -0
- package/dist/logo.png +0 -0
- package/dist/main.d.ts +0 -0
- package/dist/mockServiceWorker.js +344 -0
- package/dist/models/breadcrumb.model.d.ts +5 -0
- package/dist/models/caption.model.d.ts +6 -0
- package/dist/models/chip.model.d.ts +8 -0
- package/dist/models/cocarde.model.d.ts +4 -0
- package/dist/models/form.model.d.ts +25 -0
- package/dist/models/index.d.ts +14 -0
- package/dist/models/menu.model.d.ts +18 -0
- package/dist/models/modal.model.d.ts +8 -0
- package/dist/models/problem.model.d.ts +14 -0
- package/dist/models/sort.model.d.ts +11 -0
- package/dist/models/status-type.model.d.ts +7 -0
- package/dist/models/tab.model.d.ts +7 -0
- package/dist/models/table.model.d.ts +53 -0
- package/dist/models/tenant.model.d.ts +7 -0
- package/dist/models/tooltip.model.d.ts +6 -0
- package/dist/plugins/confirm/index.d.ts +9 -0
- package/dist/plugins/feature-flipper/FeatureFlipper.vue.d.ts +9 -0
- package/dist/plugins/feature-flipper/FeatureFlipperIndicator.vue.d.ts +6 -0
- package/dist/plugins/feature-flipper/FeatureFlipperModal.vue.d.ts +16 -0
- package/dist/plugins/feature-flipper/featureFlipper.composable.d.ts +10 -0
- package/dist/plugins/feature-flipper/featureFlipper.composable.spec.d.ts +1 -0
- package/dist/plugins/feature-flipper/featureFlipper.model.d.ts +3 -0
- package/dist/plugins/feature-flipper/index.d.ts +4 -0
- package/dist/plugins/field/FieldComponent.spec.d.ts +1 -0
- package/dist/plugins/field/FieldComponent.vue.d.ts +25 -0
- package/dist/plugins/field/FieldDatalist.vue.d.ts +27 -0
- package/dist/plugins/field/index.d.ts +2 -0
- package/dist/plugins/keycloak-auth-adapter/index.d.ts +20 -0
- package/dist/plugins/notifications/NotificationItem.vue.d.ts +12 -0
- package/dist/plugins/notifications/NotificationWidget.vue.d.ts +2 -0
- package/dist/plugins/notifications/index.d.ts +11 -0
- package/dist/plugins/notifications/notification.model.d.ts +20 -0
- package/dist/plugins/router-history/index.d.ts +6 -0
- package/dist/plugins/router-history/router-history.composable.d.ts +7 -0
- package/dist/plugins/router-history/router-history.composable.spec.d.ts +1 -0
- package/dist/plugins/runtime-env/index.d.ts +7 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/services/konami.service.d.ts +2 -0
- package/dist/showroom/App.vue.d.ts +2 -0
- package/dist/showroom/router.d.ts +8 -0
- package/dist/sipa-bms-ui.css +3024 -0
- package/dist/sipa-bms-ui.es.js +102694 -0
- package/dist/sipa-bms-ui.es.js.map +1 -0
- package/dist/sipa-bms-ui.umd.js +102815 -0
- package/dist/sipa-bms-ui.umd.js.map +1 -0
- package/package.json +126 -0
- package/src/assets/animated-icons/AnimatedActivityIcon.vue +77 -0
- package/src/assets/animated-icons/AnimatedCircleHelpIcon.vue +67 -0
- package/src/assets/animated-icons/AnimatedHomeIcon.vue +69 -0
- package/src/assets/empty.svg +1 -0
- package/src/assets/scss/_conf.scss +203 -0
- package/src/assets/scss/_formkit.scss +353 -0
- package/src/assets/scss/app.scss +11 -0
- package/src/assets/scss/global-variables.scss +56 -0
- package/src/components/button/BmsAllButtons.stories.js +56 -0
- package/src/components/button/BmsButton.spec.ts +37 -0
- package/src/components/button/BmsButton.stories.js +84 -0
- package/src/components/button/BmsButton.vue +50 -0
- package/src/components/button/BmsIconButton.stories.js +67 -0
- package/src/components/button/BmsIconButton.vue +34 -0
- package/src/components/button/UiButton.stories.js +131 -0
- package/src/components/button/UiButton.vue +37 -0
- package/src/components/button/UiButtonLink.vue +186 -0
- package/src/components/feedback/BmsAlert.stories.js +75 -0
- package/src/components/feedback/BmsAlert.vue +91 -0
- package/src/components/feedback/BmsBadge.stories.js +34 -0
- package/src/components/feedback/BmsBadge.vue +76 -0
- package/src/components/feedback/BmsCaption.stories.js +59 -0
- package/src/components/feedback/BmsCaption.vue +88 -0
- package/src/components/feedback/BmsCircularProgress.spec.ts +14 -0
- package/src/components/feedback/BmsCircularProgress.stories.js +45 -0
- package/src/components/feedback/BmsCircularProgress.vue +64 -0
- package/src/components/feedback/BmsLoader.spec.ts +7 -0
- package/src/components/feedback/BmsLoader.stories.js +31 -0
- package/src/components/feedback/BmsLoader.vue +82 -0
- package/src/components/feedback/BmsTooltip.stories.js +65 -0
- package/src/components/feedback/BmsTooltip.vue +102 -0
- package/src/components/feedback/Notification.stories.js +37 -0
- package/src/components/feedback/UiTooltip.spec.ts +62 -0
- package/src/components/feedback/UiTooltip.stories.js +71 -0
- package/src/components/feedback/UiTooltip.vue +219 -0
- package/src/components/feedback/tooltip.helper.spec.ts +92 -0
- package/src/components/feedback/tooltip.helper.ts +121 -0
- package/src/components/form/BmsAutocomplete.stories.js +90 -0
- package/src/components/form/BmsAutocomplete.vue +100 -0
- package/src/components/form/BmsBetweenInput.stories.js +69 -0
- package/src/components/form/BmsBetweenInput.vue +146 -0
- package/src/components/form/BmsChip.stories.js +65 -0
- package/src/components/form/BmsChip.vue +92 -0
- package/src/components/form/BmsFilePicker.spec.ts +94 -0
- package/src/components/form/BmsFilePicker.stories.js +53 -0
- package/src/components/form/BmsFilePicker.vue +186 -0
- package/src/components/form/BmsInputBooleanCheckbox.stories.js +90 -0
- package/src/components/form/BmsInputBooleanCheckbox.vue +70 -0
- package/src/components/form/BmsInputCheckboxCaption.spec.ts +45 -0
- package/src/components/form/BmsInputCheckboxCaption.stories.js +92 -0
- package/src/components/form/BmsInputCheckboxCaption.vue +126 -0
- package/src/components/form/BmsInputCheckboxCaptionGroup.stories.js +153 -0
- package/src/components/form/BmsInputCheckboxCaptionGroup.vue +81 -0
- package/src/components/form/BmsInputCheckboxGroup.stories.js +94 -0
- package/src/components/form/BmsInputCheckboxGroup.vue +94 -0
- package/src/components/form/BmsInputCode.stories.js +43 -0
- package/src/components/form/BmsInputCode.vue +71 -0
- package/src/components/form/BmsInputDateTime.stories.js +71 -0
- package/src/components/form/BmsInputDateTime.vue +55 -0
- package/src/components/form/BmsInputFile.spec.ts +90 -0
- package/src/components/form/BmsInputFile.stories.js +156 -0
- package/src/components/form/BmsInputFile.vue +310 -0
- package/src/components/form/BmsInputNumber.spec.ts +40 -0
- package/src/components/form/BmsInputNumber.stories.js +79 -0
- package/src/components/form/BmsInputNumber.vue +67 -0
- package/src/components/form/BmsInputRadio.stories.js +79 -0
- package/src/components/form/BmsInputRadio.vue +121 -0
- package/src/components/form/BmsInputRadioCaption.stories.js +98 -0
- package/src/components/form/BmsInputRadioCaption.vue +110 -0
- package/src/components/form/BmsInputRadioCaptionGroup.stories.js +166 -0
- package/src/components/form/BmsInputRadioCaptionGroup.vue +81 -0
- package/src/components/form/BmsInputRadioGroup.stories.js +108 -0
- package/src/components/form/BmsInputRadioGroup.vue +93 -0
- package/src/components/form/BmsInputText.spec.ts +37 -0
- package/src/components/form/BmsInputText.stories.js +78 -0
- package/src/components/form/BmsInputText.vue +79 -0
- package/src/components/form/BmsInputToggle.stories.js +37 -0
- package/src/components/form/BmsInputToggle.vue +66 -0
- package/src/components/form/BmsSearch.spec.ts +41 -0
- package/src/components/form/BmsSearch.stories.js +70 -0
- package/src/components/form/BmsSearch.vue +62 -0
- package/src/components/form/BmsSelect.spec.ts +57 -0
- package/src/components/form/BmsSelect.stories.js +131 -0
- package/src/components/form/BmsSelect.vue +225 -0
- package/src/components/form/BmsTag.stories.js +64 -0
- package/src/components/form/BmsTag.vue +109 -0
- package/src/components/form/BmsTextArea.spec.ts +37 -0
- package/src/components/form/BmsTextArea.stories.js +74 -0
- package/src/components/form/BmsTextArea.vue +112 -0
- package/src/components/form/Form.stories.js +35 -0
- package/src/components/form/RawAutocomplete.spec.ts +103 -0
- package/src/components/form/RawAutocomplete.vue +218 -0
- package/src/components/form/RawInputText.vue +173 -0
- package/src/components/form/UiBmsInputCheckbox.stories.js +77 -0
- package/src/components/form/UiBmsInputCheckbox.vue +126 -0
- package/src/components/form/UiBmsSwitch.stories.js +40 -0
- package/src/components/form/UiBmsSwitch.vue +80 -0
- package/src/components/layout/BmsCard.stories.js +77 -0
- package/src/components/layout/BmsCard.vue +133 -0
- package/src/components/layout/BmsContentPageLayout.vue +92 -0
- package/src/components/layout/BmsForm.stories.js +30 -0
- package/src/components/layout/BmsForm.vue +42 -0
- package/src/components/layout/BmsHeader.stories.js +29 -0
- package/src/components/layout/BmsHeader.vue +16 -0
- package/src/components/layout/BmsHeaderTitle.stories.js +68 -0
- package/src/components/layout/BmsHeaderTitle.vue +76 -0
- package/src/components/layout/BmsModal.spec.ts +174 -0
- package/src/components/layout/BmsModal.stories.js +153 -0
- package/src/components/layout/BmsModal.vue +359 -0
- package/src/components/layout/BmsOverlay.stories.js +34 -0
- package/src/components/layout/BmsOverlay.vue +28 -0
- package/src/components/layout/BmsSection.stories.js +45 -0
- package/src/components/layout/BmsSection.vue +35 -0
- package/src/components/layout/BmsStep.stories.js +71 -0
- package/src/components/layout/BmsStep.vue +60 -0
- package/src/components/layout/BmsStepper.stories.js +57 -0
- package/src/components/layout/BmsStepper.vue +195 -0
- package/src/components/layout/UiPopoverMenu.vue +167 -0
- package/src/components/navigation/BmsBackButton.stories.js +27 -0
- package/src/components/navigation/BmsBackButton.vue +38 -0
- package/src/components/navigation/BmsBreadcrumb.stories.js +80 -0
- package/src/components/navigation/BmsBreadcrumb.vue +45 -0
- package/src/components/navigation/BmsLink.spec.ts +45 -0
- package/src/components/navigation/BmsLink.vue +59 -0
- package/src/components/navigation/BmsMenu.spec.ts +95 -0
- package/src/components/navigation/BmsMenu.stories.js +85 -0
- package/src/components/navigation/BmsMenu.vue +148 -0
- package/src/components/navigation/BmsMenuNav.spec.ts +140 -0
- package/src/components/navigation/BmsMenuNav.stories.js +187 -0
- package/src/components/navigation/BmsMenuNav.vue +217 -0
- package/src/components/navigation/BmsShortLinkMenu.stories.js +55 -0
- package/src/components/navigation/BmsShortLinkMenu.vue +59 -0
- package/src/components/navigation/BmsTabs.stories.js +30 -0
- package/src/components/navigation/BmsTabs.vue +46 -0
- package/src/components/navigation/BmsTenantSwitcher.stories.js +89 -0
- package/src/components/navigation/BmsTenantSwitcher.vue +135 -0
- package/src/components/navigation/UiMenuItem.stories.js +73 -0
- package/src/components/navigation/UiMenuItem.vue +116 -0
- package/src/components/navigation/UiMenuItemStatus.stories.js +58 -0
- package/src/components/navigation/UiTab.stories.js +56 -0
- package/src/components/navigation/UiTab.vue +71 -0
- package/src/components/navigation/UiTenantImage.vue +22 -0
- package/src/components/navigation/UiTenantLabel.vue +94 -0
- package/src/components/navigation/UiTenantSwitcher.spec.ts +167 -0
- package/src/components/navigation/UiTenantSwitcher.stories.js +70 -0
- package/src/components/navigation/UiTenantSwitcher.vue +161 -0
- package/src/components/table/BmsEmptyScreen.stories.js +32 -0
- package/src/components/table/BmsEmptyScreen.vue +54 -0
- package/src/components/table/BmsPagination.spec.ts +73 -0
- package/src/components/table/BmsPagination.stories.js +34 -0
- package/src/components/table/BmsPagination.vue +154 -0
- package/src/components/table/BmsServerTable.stories.js +422 -0
- package/src/components/table/BmsServerTable.vue +402 -0
- package/src/components/table/BmsTable.spec.ts +309 -0
- package/src/components/table/BmsTable.stories.js +930 -0
- package/src/components/table/BmsTable.vue +308 -0
- package/src/components/table/BmsTableFilters.spec.ts +494 -0
- package/src/components/table/BmsTableFilters.stories.js +114 -0
- package/src/components/table/BmsTableFilters.vue +268 -0
- package/src/components/table/DraggableList.stories.js +29 -0
- package/src/components/table/DraggableList.vue +179 -0
- package/src/components/table/UiBmsTable.spec.ts +373 -0
- package/src/components/table/UiBmsTable.stories.js +563 -0
- package/src/components/table/UiBmsTable.vue +617 -0
- package/src/components/table/UiFilterButton.stories.js +37 -0
- package/src/components/table/UiFilterButton.vue +85 -0
- package/src/components/utils/BmsCocarde.stories.js +47 -0
- package/src/components/utils/BmsCocarde.vue +66 -0
- package/src/components/utils/BmsProblem.stories.js +82 -0
- package/src/components/utils/BmsProblem.vue +223 -0
- package/src/components/utils/BmsRelativeTime.spec.ts +41 -0
- package/src/components/utils/BmsRelativeTime.stories.js +48 -0
- package/src/components/utils/BmsRelativeTime.vue +57 -0
- package/src/composables/clipboard.composable.ts +14 -0
- package/src/composables/index.ts +5 -0
- package/src/composables/pagination.composable.spec.ts +258 -0
- package/src/composables/pagination.composable.ts +111 -0
- package/src/composables/search.composable.spec.ts +1296 -0
- package/src/composables/search.composable.ts +316 -0
- package/src/composables/search.helper.spec.ts +339 -0
- package/src/composables/search.helper.ts +103 -0
- package/src/composables/sort.composable.spec.ts +349 -0
- package/src/composables/sort.composable.ts +129 -0
- package/src/composables/userPref.composable.spec.ts +115 -0
- package/src/composables/userPref.composable.ts +43 -0
- package/src/documentation/ColorTile.vue +23 -0
- package/src/documentation/assets/BmsIcon.png +0 -0
- package/src/documentation/assets/CoverBmsUI.png +0 -0
- package/src/documentation/assets/button/CoverPrimaryButton.png +0 -0
- package/src/documentation/assets/button/CoverSecondaryButton.png +0 -0
- package/src/documentation/assets/button/DoButtonLabel.png +0 -0
- package/src/documentation/assets/button/DontButtonLabel.png +0 -0
- package/src/documentation/assets/button/PrimaryButtonRepresentation.png +0 -0
- package/src/documentation/assets/cards/CardRepresentation.png +0 -0
- package/src/documentation/assets/cards/CoverCard.png +0 -0
- package/src/documentation/assets/chip/ChipRepresentation.png +0 -0
- package/src/documentation/assets/chip/CoverChips.png +0 -0
- package/src/documentation/assets/fields/Anatomy.png +0 -0
- package/src/documentation/assets/fields/CaptionRepresentation.png +0 -0
- package/src/documentation/assets/fields/CaptionTextRepresentation.png +0 -0
- package/src/documentation/assets/fields/CoverFieldsAnatomy.png +0 -0
- package/src/documentation/assets/fields/CoverInputFile.png +0 -0
- package/src/documentation/assets/fields/CoverInputText.png +0 -0
- package/src/documentation/assets/fields/CoverRadioCaptionGroup.png +0 -0
- package/src/documentation/assets/fields/CoverRadioGroup.png +0 -0
- package/src/documentation/assets/fields/CoverSearch.png +0 -0
- package/src/documentation/assets/fields/CoverSelect.png +0 -0
- package/src/documentation/assets/fields/CoverTextArea.png +0 -0
- package/src/documentation/assets/fields/FieldLabel.png +0 -0
- package/src/documentation/assets/fields/InputMediaRepresentation.png +0 -0
- package/src/documentation/assets/fields/InputRepresentation.png +0 -0
- package/src/documentation/assets/fields/InputSearchRepresentation.png +0 -0
- package/src/documentation/assets/fields/InputText.png +0 -0
- package/src/documentation/assets/fields/InputTextAreaRepresentation.png +0 -0
- package/src/documentation/assets/fields/LabelDo.png +0 -0
- package/src/documentation/assets/fields/LabelDont.png +0 -0
- package/src/documentation/assets/fields/LabelRepresentation.png +0 -0
- package/src/documentation/assets/fields/RadioCaptionGroupRepresentation.png +0 -0
- package/src/documentation/assets/fields/RadioGroupRepresentation.png +0 -0
- package/src/documentation/assets/fields/SelectRepresentation.png +0 -0
- package/src/documentation/assets/tag/CoverTag.png +0 -0
- package/src/documentation/assets/tag/TagRepresentation.png +0 -0
- package/src/documentation/button.mdx +24 -0
- package/src/documentation/card.mdx +28 -0
- package/src/documentation/chip.mdx +28 -0
- package/src/documentation/colors.mdx +118 -0
- package/src/documentation/fields.mdx +52 -0
- package/src/documentation/fields_text.mdx +31 -0
- package/src/documentation/icons.mdx +33 -0
- package/src/documentation/inputFile.mdx +28 -0
- package/src/documentation/primaryButton.mdx +20 -0
- package/src/documentation/principles.mdx +23 -0
- package/src/documentation/radioCaptionGroup.mdx +34 -0
- package/src/documentation/radioGroup.mdx +34 -0
- package/src/documentation/search.mdx +28 -0
- package/src/documentation/secondaryButton.mdx +17 -0
- package/src/documentation/select.mdx +31 -0
- package/src/documentation/tag.mdx +28 -0
- package/src/documentation/template_field_dependency.mdx +19 -0
- package/src/documentation/textArea.mdx +27 -0
- package/src/documentation/typography.mdx +93 -0
- package/src/documentation/typography.stories.js +26 -0
- package/src/helpers/cocarde.helper.spec.ts +14 -0
- package/src/helpers/cocarde.helper.ts +22 -0
- package/src/helpers/date.helper.spec.ts +91 -0
- package/src/helpers/date.helper.ts +105 -0
- package/src/helpers/file.helper.spec.ts +60 -0
- package/src/helpers/file.helper.ts +24 -0
- package/src/helpers/index.ts +6 -0
- package/src/helpers/location.helper.spec.ts +195 -0
- package/src/helpers/location.helper.ts +53 -0
- package/src/helpers/problem.helper.spec.ts +21 -0
- package/src/helpers/problem.helper.ts +4 -0
- package/src/helpers/string.helper.spec.ts +186 -0
- package/src/helpers/string.helper.ts +83 -0
- package/src/helpers/table.helper.spec.ts +141 -0
- package/src/helpers/table.helper.ts +88 -0
- package/src/index.ts +203 -0
- package/src/main.ts +25 -0
- package/src/models/breadcrumb.model.ts +6 -0
- package/src/models/caption.model.ts +7 -0
- package/src/models/chip.model.ts +8 -0
- package/src/models/cocarde.model.ts +4 -0
- package/src/models/form.model.ts +30 -0
- package/src/models/index.ts +14 -0
- package/src/models/menu.model.ts +20 -0
- package/src/models/modal.model.ts +9 -0
- package/src/models/problem.model.ts +10 -0
- package/src/models/sort.model.ts +13 -0
- package/src/models/status-type.model.ts +7 -0
- package/src/models/tab.model.ts +7 -0
- package/src/models/table.model.ts +58 -0
- package/src/models/tenant.model.ts +7 -0
- package/src/models/tooltip.model.ts +6 -0
- package/src/pages/Form.stories.js +83 -0
- package/src/pages/List.stories.js +88 -0
- package/src/plugins/confirm/index.ts +109 -0
- package/src/plugins/feature-flipper/FeatureFlipper.vue +23 -0
- package/src/plugins/feature-flipper/FeatureFlipperIndicator.vue +27 -0
- package/src/plugins/feature-flipper/FeatureFlipperModal.vue +68 -0
- package/src/plugins/feature-flipper/featureFlipper.composable.spec.ts +107 -0
- package/src/plugins/feature-flipper/featureFlipper.composable.ts +68 -0
- package/src/plugins/feature-flipper/featureFlipper.model.ts +1 -0
- package/src/plugins/feature-flipper/index.ts +15 -0
- package/src/plugins/field/FieldComponent.spec.ts +34 -0
- package/src/plugins/field/FieldComponent.stories.js +78 -0
- package/src/plugins/field/FieldComponent.vue +208 -0
- package/src/plugins/field/FieldDatalist.stories.js +35 -0
- package/src/plugins/field/FieldDatalist.vue +68 -0
- package/src/plugins/field/index.ts +31 -0
- package/src/plugins/keycloak-auth-adapter/index.ts +102 -0
- package/src/plugins/notifications/NotificationItem.stories.js +60 -0
- package/src/plugins/notifications/NotificationItem.vue +116 -0
- package/src/plugins/notifications/NotificationWidget.vue +129 -0
- package/src/plugins/notifications/index.ts +83 -0
- package/src/plugins/notifications/notification.model.ts +24 -0
- package/src/plugins/notifications/notifications.spec.js +78 -0
- package/src/plugins/router-history/index.ts +23 -0
- package/src/plugins/router-history/router-history.composable.spec.ts +323 -0
- package/src/plugins/router-history/router-history.composable.ts +47 -0
- package/src/plugins/runtime-env/index.ts +19 -0
- package/src/services/index.ts +1 -0
- package/src/services/konami.service.ts +28 -0
- package/src/showroom/App.vue +109 -0
- package/src/showroom/db.json +1967 -0
- package/src/showroom/pages/autocomplete.vue +54 -0
- package/src/showroom/pages/draggable-list.vue +20 -0
- package/src/showroom/pages/file-picker.vue +74 -0
- package/src/showroom/pages/forms.vue +389 -0
- package/src/showroom/pages/index.vue +209 -0
- package/src/showroom/pages/paginated-cards.vue +48 -0
- package/src/showroom/pages/server-table.vue +160 -0
- package/src/showroom/pages/stepper.vue +37 -0
- package/src/showroom/pages/table.vue +192 -0
- package/src/showroom/pages/tabs/[tabName].vue +28 -0
- package/src/showroom/router.ts +15 -0
- package/src/showroom/server.js +45 -0
- package/src/vite-env.d.ts +9 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Filter, InputType } from '@/models';
|
|
2
|
+
import { isEmptyStringOrNotDefined } from '@/helpers';
|
|
3
|
+
|
|
4
|
+
export const isBetweenFilter = (filter: Filter): boolean =>
|
|
5
|
+
filter.type === 'betweenDate' ||
|
|
6
|
+
filter.type === 'betweenNumber' ||
|
|
7
|
+
filter.type === 'betweenDateTime';
|
|
8
|
+
|
|
9
|
+
export const defaultNumberFilterFunction = (
|
|
10
|
+
itemNumber: number,
|
|
11
|
+
search: number,
|
|
12
|
+
isAfterSearch: boolean,
|
|
13
|
+
) => {
|
|
14
|
+
if (
|
|
15
|
+
isEmptyStringOrNotDefined(itemNumber) ||
|
|
16
|
+
isEmptyStringOrNotDefined(search)
|
|
17
|
+
) {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return isAfterSearch ? itemNumber >= search : itemNumber <= search;
|
|
21
|
+
};
|
|
22
|
+
export const defaultIsAfterDateFilterFunction = (
|
|
23
|
+
dateItem: Date,
|
|
24
|
+
search: Date,
|
|
25
|
+
isGreaterThan: boolean,
|
|
26
|
+
) => {
|
|
27
|
+
if (!dateItem || !search) {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return isGreaterThan
|
|
31
|
+
? dateItem.getTime() >= search.getTime()
|
|
32
|
+
: dateItem.getTime() <= search.getTime();
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const dateFilterCompare = (
|
|
36
|
+
itemDate: string,
|
|
37
|
+
filter: Filter,
|
|
38
|
+
isGreaterThan = true,
|
|
39
|
+
) => {
|
|
40
|
+
const sanitizedItemDate = new Date(itemDate);
|
|
41
|
+
const searchDate = isEmptyStringOrNotDefined(filter.value)
|
|
42
|
+
? null
|
|
43
|
+
: new Date(filter.value);
|
|
44
|
+
|
|
45
|
+
// in date mode, we are more tolerant for search on time (for "locale" purpose)
|
|
46
|
+
if (filter.inputType === InputType.DATE) {
|
|
47
|
+
sanitizedItemDate.setHours(+2, 0, 0, 0);
|
|
48
|
+
searchDate?.setHours(0, 0, 0, 0);
|
|
49
|
+
}
|
|
50
|
+
const applyFilter = filter.customFilter
|
|
51
|
+
? filter.customFilter
|
|
52
|
+
: defaultIsAfterDateFilterFunction;
|
|
53
|
+
|
|
54
|
+
return applyFilter(sanitizedItemDate, searchDate, isGreaterThan);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const dateIsBetween = (itemDate: string, filter: Filter) => {
|
|
58
|
+
const sanitizedItemDate = new Date(itemDate);
|
|
59
|
+
const fromDate = isEmptyStringOrNotDefined(filter.valueFrom)
|
|
60
|
+
? null
|
|
61
|
+
: new Date(filter.valueFrom);
|
|
62
|
+
const toDate = isEmptyStringOrNotDefined(filter.valueTo)
|
|
63
|
+
? null
|
|
64
|
+
: new Date(filter.valueTo);
|
|
65
|
+
// in date mode, we are more tolerant for search on time (for "locale" purpose)
|
|
66
|
+
if (filter.type === 'betweenDate') {
|
|
67
|
+
if (fromDate) fromDate.setHours(-2, 0, 0, 0);
|
|
68
|
+
if (toDate) toDate.setHours(+2, 0, 0, 0);
|
|
69
|
+
if (toDate) toDate.setHours(23, 59, 59, 0);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const applyFilter = filter.customFilter
|
|
73
|
+
? filter.customFilter
|
|
74
|
+
: defaultIsAfterDateFilterFunction;
|
|
75
|
+
|
|
76
|
+
//we have at least one of the 2 fields from/to with a value
|
|
77
|
+
const isValidFrom = fromDate
|
|
78
|
+
? applyFilter(sanitizedItemDate, fromDate, true)
|
|
79
|
+
: true;
|
|
80
|
+
const isValidTo = toDate
|
|
81
|
+
? applyFilter(sanitizedItemDate, toDate, false)
|
|
82
|
+
: true;
|
|
83
|
+
return isValidFrom && isValidTo;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const numberIsBetween = (itemValue: any, filter: Filter) => {
|
|
87
|
+
if (Number.isNaN(itemValue)) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
const applyFilter = filter.customFilter
|
|
91
|
+
? filter.customFilter
|
|
92
|
+
: defaultNumberFilterFunction;
|
|
93
|
+
//we have at least one of the 2 fields from/to with a value
|
|
94
|
+
const isValidFrom =
|
|
95
|
+
filter.valueFrom === null ||
|
|
96
|
+
filter.valueFrom === undefined ||
|
|
97
|
+
applyFilter(Number(itemValue), Number(filter.valueFrom), true);
|
|
98
|
+
const isValidTo =
|
|
99
|
+
filter.valueTo === null ||
|
|
100
|
+
filter.valueTo === undefined ||
|
|
101
|
+
applyFilter(Number(itemValue), Number(filter.valueTo), false);
|
|
102
|
+
return isValidFrom && isValidTo;
|
|
103
|
+
};
|
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
import { defaultSortFunction, useSort } from './sort.composable';
|
|
2
|
+
import { SortValue } from '..';
|
|
3
|
+
import { defineComponent, nextTick } from 'vue';
|
|
4
|
+
import { mount } from '@vue/test-utils';
|
|
5
|
+
|
|
6
|
+
let previous: any;
|
|
7
|
+
let replaceStateSpy: any;
|
|
8
|
+
|
|
9
|
+
const factory = (props?: any) => {
|
|
10
|
+
return mount(
|
|
11
|
+
defineComponent({
|
|
12
|
+
props: {
|
|
13
|
+
persistent: Object as any,
|
|
14
|
+
tableHeaders: Object as any,
|
|
15
|
+
defaultSort: Object as any,
|
|
16
|
+
},
|
|
17
|
+
setup(props) {
|
|
18
|
+
return useSort(
|
|
19
|
+
props.persistent || undefined,
|
|
20
|
+
props.tableHeaders || undefined,
|
|
21
|
+
props.defaultSort || undefined,
|
|
22
|
+
);
|
|
23
|
+
},
|
|
24
|
+
template: '<div/>',
|
|
25
|
+
}),
|
|
26
|
+
{ props: props },
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
describe('sort composable', () => {
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
vi.resetAllMocks();
|
|
33
|
+
previous = global.window.location;
|
|
34
|
+
//@ts-ignore
|
|
35
|
+
delete global.window.location;
|
|
36
|
+
replaceStateSpy = vi
|
|
37
|
+
.spyOn(global.window.history, 'replaceState')
|
|
38
|
+
.mockImplementation(() => {});
|
|
39
|
+
global.window.location = {
|
|
40
|
+
...previous,
|
|
41
|
+
protocol: 'https:',
|
|
42
|
+
host: 'localhost/',
|
|
43
|
+
pathname: 'path',
|
|
44
|
+
search: '',
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
afterEach(() => {
|
|
48
|
+
global.window.location = previous;
|
|
49
|
+
});
|
|
50
|
+
describe('defaultSortFunction', () => {
|
|
51
|
+
test.each([
|
|
52
|
+
['a', 'b', 'asc', -1],
|
|
53
|
+
['a', 'b', 'desc', 1],
|
|
54
|
+
['a', 'a', 'desc', 0],
|
|
55
|
+
[0, 1, 'asc', -1],
|
|
56
|
+
[0, 1, 'desc', 1],
|
|
57
|
+
[0, 0, 'asc', 0],
|
|
58
|
+
[true, false, 'asc', 1],
|
|
59
|
+
[true, false, 'desc', -1],
|
|
60
|
+
[true, true, 'asc', 0],
|
|
61
|
+
['é', 'e', 'asc', 0],
|
|
62
|
+
['E', 'e', 'asc', 0],
|
|
63
|
+
[1, 'b', 'asc', 0],
|
|
64
|
+
[null, 'b', 'asc', 0],
|
|
65
|
+
[undefined, 'b', 'asc', -1],
|
|
66
|
+
[undefined, 'b', 'desc', 1],
|
|
67
|
+
])('with %o and %o and sort %o, should return %o', (a, b, sort, result) => {
|
|
68
|
+
expect(defaultSortFunction(a, b, sort as SortValue)).toEqual(result);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe('changeSort', () => {
|
|
72
|
+
test('should set a sort if no sort already set', () => {
|
|
73
|
+
const wrapper = factory();
|
|
74
|
+
wrapper.vm.changeSort({ key: 'key', label: 'label', sortable: true });
|
|
75
|
+
expect(wrapper.vm.sort).toEqual({ key: 'key', value: 'asc' });
|
|
76
|
+
});
|
|
77
|
+
test('should set a sort if new header selected', () => {
|
|
78
|
+
const wrapper = factory();
|
|
79
|
+
wrapper.vm.sort = { key: 'otherKey', value: SortValue.desc };
|
|
80
|
+
wrapper.vm.changeSort({ key: 'key', label: 'label', sortable: true });
|
|
81
|
+
expect(wrapper.vm.sort).toEqual({ key: 'key', value: 'asc' });
|
|
82
|
+
});
|
|
83
|
+
test('should not set a sort if new header selected but can not be sorted', () => {
|
|
84
|
+
const wrapper = factory();
|
|
85
|
+
wrapper.vm.sort = { key: 'otherKey', value: SortValue.desc };
|
|
86
|
+
wrapper.vm.changeSort({ key: 'key', label: 'label', sortable: false });
|
|
87
|
+
expect(wrapper.vm.sort).toEqual({ key: 'otherKey', value: 'desc' });
|
|
88
|
+
});
|
|
89
|
+
test('should change sort if same header selected', () => {
|
|
90
|
+
const wrapper = factory();
|
|
91
|
+
wrapper.vm.sort = { key: 'key', value: SortValue.asc };
|
|
92
|
+
wrapper.vm.changeSort({ key: 'key', label: 'label', sortable: true });
|
|
93
|
+
expect(wrapper.vm.sort).toEqual({ key: 'key', value: 'desc' });
|
|
94
|
+
});
|
|
95
|
+
test('should cycle sort if same header selected', () => {
|
|
96
|
+
const wrapper = factory();
|
|
97
|
+
wrapper.vm.sort = { key: 'key', value: SortValue.desc };
|
|
98
|
+
wrapper.vm.changeSort({ key: 'key', label: 'label', sortable: true });
|
|
99
|
+
expect(wrapper.vm.sort).toEqual({ key: 'key', value: 'asc' });
|
|
100
|
+
});
|
|
101
|
+
test('should save sort value in path if reflect', async () => {
|
|
102
|
+
const wrapper = factory();
|
|
103
|
+
wrapper.vm.changeSort({ key: 'key', label: 'label', sortable: true });
|
|
104
|
+
await nextTick();
|
|
105
|
+
expect(replaceStateSpy).toHaveBeenCalled();
|
|
106
|
+
expect(replaceStateSpy).toHaveBeenLastCalledWith(
|
|
107
|
+
{
|
|
108
|
+
path: 'https://localhost/path?table-sort-target=key&table-sort-value=asc',
|
|
109
|
+
},
|
|
110
|
+
'',
|
|
111
|
+
'https://localhost/path?table-sort-target=key&table-sort-value=asc',
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
describe('sortItems', () => {
|
|
116
|
+
test('should not sort if no sort', () => {
|
|
117
|
+
const wrapper = factory();
|
|
118
|
+
wrapper.vm.sort = { key: null, value: SortValue.default };
|
|
119
|
+
expect(
|
|
120
|
+
wrapper.vm.sortItems([
|
|
121
|
+
{ column: 'value1' },
|
|
122
|
+
{ column: 'value0' },
|
|
123
|
+
{ column: 'value2' },
|
|
124
|
+
]),
|
|
125
|
+
).toStrictEqual([
|
|
126
|
+
{ column: 'value1' },
|
|
127
|
+
{ column: 'value0' },
|
|
128
|
+
{ column: 'value2' },
|
|
129
|
+
]);
|
|
130
|
+
});
|
|
131
|
+
test('should not sort if sort is default', () => {
|
|
132
|
+
const wrapper = factory();
|
|
133
|
+
wrapper.vm.sort = { key: 'column', value: SortValue.default };
|
|
134
|
+
expect(
|
|
135
|
+
wrapper.vm.sortItems([
|
|
136
|
+
{ column: 'value1' },
|
|
137
|
+
{ column: 'value0' },
|
|
138
|
+
{ column: 'value2' },
|
|
139
|
+
]),
|
|
140
|
+
).toStrictEqual([
|
|
141
|
+
{ column: 'value1' },
|
|
142
|
+
{ column: 'value0' },
|
|
143
|
+
{ column: 'value2' },
|
|
144
|
+
]);
|
|
145
|
+
});
|
|
146
|
+
test('should not sort if no key in sort', () => {
|
|
147
|
+
const wrapper = factory();
|
|
148
|
+
wrapper.vm.sort = { key: null, value: SortValue.default };
|
|
149
|
+
expect(
|
|
150
|
+
wrapper.vm.sortItems([
|
|
151
|
+
{ column: 'value1' },
|
|
152
|
+
{ column: 'value0' },
|
|
153
|
+
{ column: 'value2' },
|
|
154
|
+
]),
|
|
155
|
+
).toStrictEqual([
|
|
156
|
+
{ column: 'value1' },
|
|
157
|
+
{ column: 'value0' },
|
|
158
|
+
{ column: 'value2' },
|
|
159
|
+
]);
|
|
160
|
+
});
|
|
161
|
+
test('should sort if sort is asc', () => {
|
|
162
|
+
const wrapper = factory();
|
|
163
|
+
wrapper.vm.sort = { key: 'column', value: SortValue.asc };
|
|
164
|
+
expect(
|
|
165
|
+
wrapper.vm.sortItems([
|
|
166
|
+
{ column: 'value1' },
|
|
167
|
+
{ column: 'value0' },
|
|
168
|
+
{ column: 'value2' },
|
|
169
|
+
]),
|
|
170
|
+
).toStrictEqual([
|
|
171
|
+
{ column: 'value0' },
|
|
172
|
+
{ column: 'value1' },
|
|
173
|
+
{ column: 'value2' },
|
|
174
|
+
]);
|
|
175
|
+
});
|
|
176
|
+
test('should sort complex items if sort is asc', () => {
|
|
177
|
+
const wrapper = factory();
|
|
178
|
+
wrapper.vm.sort = { key: 'column.val', value: SortValue.asc };
|
|
179
|
+
expect(
|
|
180
|
+
wrapper.vm.sortItems([
|
|
181
|
+
{ column: { val: 'value1' } },
|
|
182
|
+
{ column: { val: 'value0' } },
|
|
183
|
+
{ column: { val: 'value2' } },
|
|
184
|
+
]),
|
|
185
|
+
).toStrictEqual([
|
|
186
|
+
{ column: { val: 'value0' } },
|
|
187
|
+
{ column: { val: 'value1' } },
|
|
188
|
+
{ column: { val: 'value2' } },
|
|
189
|
+
]);
|
|
190
|
+
});
|
|
191
|
+
test('should sort if sort is desc', () => {
|
|
192
|
+
const wrapper = factory();
|
|
193
|
+
wrapper.vm.sort = { key: 'column', value: SortValue.desc };
|
|
194
|
+
expect(
|
|
195
|
+
wrapper.vm.sortItems([
|
|
196
|
+
{ column: 'value1' },
|
|
197
|
+
{ column: 'value0' },
|
|
198
|
+
{ column: 'value2' },
|
|
199
|
+
]),
|
|
200
|
+
).toStrictEqual([
|
|
201
|
+
{ column: 'value2' },
|
|
202
|
+
{ column: 'value1' },
|
|
203
|
+
{ column: 'value0' },
|
|
204
|
+
]);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
describe('customSort', () => {
|
|
208
|
+
test('should use custom sort if set', () => {
|
|
209
|
+
const wrapper = factory();
|
|
210
|
+
wrapper.vm.sort = {
|
|
211
|
+
key: 'column',
|
|
212
|
+
value: SortValue.desc,
|
|
213
|
+
overridenSortFunction: (a, b, value) => {
|
|
214
|
+
if (a.column > b.column) {
|
|
215
|
+
return value === SortValue.asc ? -1 : 1;
|
|
216
|
+
}
|
|
217
|
+
if (a.column < b.column) {
|
|
218
|
+
return value === SortValue.asc ? 1 : -1;
|
|
219
|
+
}
|
|
220
|
+
return 0;
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
expect(
|
|
224
|
+
wrapper.vm.sortItems([
|
|
225
|
+
{ column: 'value1' },
|
|
226
|
+
{ column: 'value0' },
|
|
227
|
+
{ column: 'value2' },
|
|
228
|
+
]),
|
|
229
|
+
).toStrictEqual([
|
|
230
|
+
{ column: 'value0' },
|
|
231
|
+
{ column: 'value1' },
|
|
232
|
+
{ column: 'value2' },
|
|
233
|
+
]);
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
describe('isSortPresentInPath', () => {
|
|
237
|
+
it('should return false if none is in path', () => {
|
|
238
|
+
global.window.location = {
|
|
239
|
+
...previous,
|
|
240
|
+
protocol: 'https:',
|
|
241
|
+
host: 'localhost/',
|
|
242
|
+
pathname: 'path',
|
|
243
|
+
search: '',
|
|
244
|
+
};
|
|
245
|
+
const wrapper = factory();
|
|
246
|
+
expect(wrapper.vm.isSortPresentInPath()).toEqual(false);
|
|
247
|
+
});
|
|
248
|
+
it('should return false if only one is in path', () => {
|
|
249
|
+
global.window.location = {
|
|
250
|
+
...previous,
|
|
251
|
+
protocol: 'https:',
|
|
252
|
+
host: 'localhost/',
|
|
253
|
+
pathname: 'path',
|
|
254
|
+
search: '?table-sort-target=key',
|
|
255
|
+
};
|
|
256
|
+
const wrapper = factory();
|
|
257
|
+
expect(wrapper.vm.isSortPresentInPath()).toEqual(false);
|
|
258
|
+
});
|
|
259
|
+
it('should return true if both are in path', () => {
|
|
260
|
+
global.window.location = {
|
|
261
|
+
...previous,
|
|
262
|
+
protocol: 'https:',
|
|
263
|
+
host: 'localhost/',
|
|
264
|
+
pathname: 'path',
|
|
265
|
+
search: '?table-sort-target=key&table-sort-value=val',
|
|
266
|
+
};
|
|
267
|
+
const wrapper = factory();
|
|
268
|
+
expect(wrapper.vm.isSortPresentInPath()).toEqual(true);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
describe('initSort', () => {
|
|
272
|
+
it('should use default if not persistent', async () => {
|
|
273
|
+
const wrapper = factory({
|
|
274
|
+
peristent: false,
|
|
275
|
+
tableHeaders: [{ key: 'key0', label: 'label' }],
|
|
276
|
+
defaultSort: { key: 'key', value: SortValue.asc },
|
|
277
|
+
});
|
|
278
|
+
await nextTick();
|
|
279
|
+
expect(wrapper.vm.sort).toEqual({
|
|
280
|
+
key: 'key',
|
|
281
|
+
value: SortValue.asc,
|
|
282
|
+
});
|
|
283
|
+
});
|
|
284
|
+
it('should use default if no sort present in path', async () => {
|
|
285
|
+
global.window.location = {
|
|
286
|
+
...previous,
|
|
287
|
+
protocol: 'https:',
|
|
288
|
+
host: 'localhost/',
|
|
289
|
+
pathname: 'path',
|
|
290
|
+
search: '',
|
|
291
|
+
};
|
|
292
|
+
const wrapper = factory({
|
|
293
|
+
peristent: true,
|
|
294
|
+
tableHeaders: [{ key: 'key0', label: 'label' }],
|
|
295
|
+
defaultSort: { key: 'key', value: SortValue.asc },
|
|
296
|
+
});
|
|
297
|
+
await nextTick();
|
|
298
|
+
expect(wrapper.vm.sort).toEqual({ key: 'key', value: SortValue.asc });
|
|
299
|
+
});
|
|
300
|
+
it('should use default if sort in path but does not have correct target', async () => {
|
|
301
|
+
global.window.location = {
|
|
302
|
+
...previous,
|
|
303
|
+
protocol: 'https:',
|
|
304
|
+
host: 'localhost/',
|
|
305
|
+
pathname: 'path',
|
|
306
|
+
search: '?table-sort-target=NotFoundKey&table-sort-value=asc',
|
|
307
|
+
};
|
|
308
|
+
const wrapper = factory({
|
|
309
|
+
peristent: true,
|
|
310
|
+
tableHeaders: [{ key: 'key0', label: 'label' }],
|
|
311
|
+
defaultSort: { key: 'key', value: SortValue.asc },
|
|
312
|
+
});
|
|
313
|
+
await nextTick();
|
|
314
|
+
expect(wrapper.vm.sort).toEqual({ key: 'key', value: SortValue.asc });
|
|
315
|
+
});
|
|
316
|
+
it('should use default if sort in path but does not have correct value', async () => {
|
|
317
|
+
global.window.location = {
|
|
318
|
+
...previous,
|
|
319
|
+
protocol: 'https:',
|
|
320
|
+
host: 'localhost/',
|
|
321
|
+
pathname: 'path',
|
|
322
|
+
search: '?table-sort-target=key0&table-sort-value=val',
|
|
323
|
+
};
|
|
324
|
+
const wrapper = factory({
|
|
325
|
+
peristent: true,
|
|
326
|
+
tableHeaders: [{ key: 'key0', label: 'label' }],
|
|
327
|
+
defaultSort: { key: 'key', value: SortValue.asc },
|
|
328
|
+
});
|
|
329
|
+
await nextTick();
|
|
330
|
+
expect(wrapper.vm.sort).toEqual({ key: 'key', value: SortValue.asc });
|
|
331
|
+
});
|
|
332
|
+
it('should use path sort if sort in path', async () => {
|
|
333
|
+
global.window.location = {
|
|
334
|
+
...previous,
|
|
335
|
+
protocol: 'https:',
|
|
336
|
+
host: 'localhost/',
|
|
337
|
+
pathname: 'path',
|
|
338
|
+
search: '?table-sort-target=key0&table-sort-value=asc',
|
|
339
|
+
};
|
|
340
|
+
const wrapper = factory({
|
|
341
|
+
peristent: true,
|
|
342
|
+
tableHeaders: [{ key: 'key0', label: 'label' }],
|
|
343
|
+
defaultSort: { key: 'key', value: SortValue.asc },
|
|
344
|
+
});
|
|
345
|
+
await nextTick();
|
|
346
|
+
expect(wrapper.vm.sort).toEqual({ key: 'key0', value: SortValue.asc });
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
});
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { sanitizeString } from '@/helpers/string.helper';
|
|
2
|
+
import { Sort, SortValue, TableHeader } from '@/models';
|
|
3
|
+
import { Ref, onMounted, ref, unref, watch } from 'vue';
|
|
4
|
+
import _get from 'lodash/get';
|
|
5
|
+
import {
|
|
6
|
+
getStringFromPathQuery,
|
|
7
|
+
saveValuesToPathQuery,
|
|
8
|
+
} from '@/helpers/location.helper';
|
|
9
|
+
|
|
10
|
+
const SORT_TARGET_KEY = 'table-sort-target';
|
|
11
|
+
const SORT_VALUE_KEY = 'table-sort-value';
|
|
12
|
+
|
|
13
|
+
export const useSort = (
|
|
14
|
+
persistent: boolean | Ref<boolean> = true,
|
|
15
|
+
tableHeaders: TableHeader[] | Ref<TableHeader[]> = [],
|
|
16
|
+
defaultSort: Sort | Ref<Sort> = {
|
|
17
|
+
key: null,
|
|
18
|
+
value: SortValue.default,
|
|
19
|
+
overridenSortFunction: undefined,
|
|
20
|
+
},
|
|
21
|
+
) => {
|
|
22
|
+
const reflect = ref<boolean>(unref(persistent));
|
|
23
|
+
const headers = ref<TableHeader[]>(unref(tableHeaders));
|
|
24
|
+
const sort: Ref<Sort> = ref(unref(defaultSort));
|
|
25
|
+
const isMounting: Ref<boolean> = ref(true);
|
|
26
|
+
|
|
27
|
+
const changeSort = (header: TableHeader) => {
|
|
28
|
+
if (!header.sortable) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (sort.value.key !== header.key) {
|
|
32
|
+
sort.value = {
|
|
33
|
+
key: header.key,
|
|
34
|
+
value: SortValue.asc,
|
|
35
|
+
overridenSortFunction: header.sortFunction || undefined,
|
|
36
|
+
};
|
|
37
|
+
} else {
|
|
38
|
+
sort.value.value =
|
|
39
|
+
sort.value.value === SortValue.asc ? SortValue.desc : SortValue.asc;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const sortItems = (items: any[]): any[] => {
|
|
44
|
+
if (!sort.value.key || sort.value.value === SortValue.default) {
|
|
45
|
+
return items;
|
|
46
|
+
}
|
|
47
|
+
return items.sort((a: any, b: any) => {
|
|
48
|
+
if (sort.value.overridenSortFunction) {
|
|
49
|
+
return sort.value.overridenSortFunction(a, b, sort.value.value);
|
|
50
|
+
}
|
|
51
|
+
if (sort.value.key) {
|
|
52
|
+
return defaultSortFunction(
|
|
53
|
+
_get(a, sort.value.key),
|
|
54
|
+
_get(b, sort.value.key),
|
|
55
|
+
sort.value.value,
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return 0;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
onMounted(() => {
|
|
63
|
+
if (reflect.value && isSortPresentInPath()) {
|
|
64
|
+
const target = getStringFromPathQuery(SORT_TARGET_KEY);
|
|
65
|
+
const requestedSortValue = getStringFromPathQuery(SORT_VALUE_KEY);
|
|
66
|
+
const foundHeader = headers.value.find((header) => header.key === target);
|
|
67
|
+
if (
|
|
68
|
+
foundHeader &&
|
|
69
|
+
Object.values(SortValue).includes(requestedSortValue as SortValue)
|
|
70
|
+
) {
|
|
71
|
+
sort.value = {
|
|
72
|
+
key: target,
|
|
73
|
+
value: requestedSortValue as SortValue,
|
|
74
|
+
overridenSortFunction: foundHeader.sortFunction || undefined,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
isMounting.value = false;
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const isSortPresentInPath = (): boolean => {
|
|
82
|
+
return (
|
|
83
|
+
!!getStringFromPathQuery(SORT_TARGET_KEY) &&
|
|
84
|
+
!!getStringFromPathQuery(SORT_VALUE_KEY)
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
watch(
|
|
89
|
+
() => sort.value,
|
|
90
|
+
() => {
|
|
91
|
+
if (reflect.value && sort.value.key) {
|
|
92
|
+
saveValuesToPathQuery([
|
|
93
|
+
{ key: SORT_TARGET_KEY, value: sort.value.key },
|
|
94
|
+
{ key: SORT_VALUE_KEY, value: sort.value.value },
|
|
95
|
+
]);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{ deep: true },
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
sort,
|
|
103
|
+
isMounting,
|
|
104
|
+
changeSort,
|
|
105
|
+
sortItems,
|
|
106
|
+
isSortPresentInPath,
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export const defaultSortFunction = (
|
|
111
|
+
valA: any,
|
|
112
|
+
valB: any,
|
|
113
|
+
value: SortValue,
|
|
114
|
+
): number => {
|
|
115
|
+
if (typeof valA === 'string') {
|
|
116
|
+
valA = sanitizeString(valA);
|
|
117
|
+
}
|
|
118
|
+
if (typeof valB === 'string') {
|
|
119
|
+
valB = sanitizeString(valB);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (valA < valB || (valA === undefined && valB !== undefined)) {
|
|
123
|
+
return value === SortValue.asc ? -1 : 1;
|
|
124
|
+
}
|
|
125
|
+
if (valA > valB || (valA !== undefined && valB === undefined)) {
|
|
126
|
+
return value === SortValue.asc ? 1 : -1;
|
|
127
|
+
}
|
|
128
|
+
return 0;
|
|
129
|
+
};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { useUserPref } from '@/composables/userPref.composable';
|
|
2
|
+
|
|
3
|
+
describe('userPref Composable', () => {
|
|
4
|
+
beforeEach(() => {
|
|
5
|
+
vi.resetAllMocks();
|
|
6
|
+
vi.resetModules();
|
|
7
|
+
vi.stubGlobal('localStorage', {
|
|
8
|
+
getItem: vi.fn(),
|
|
9
|
+
setItem: vi.fn(),
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
describe('getUserPref', () => {
|
|
13
|
+
const { getUserPref } = useUserPref();
|
|
14
|
+
it('should return undefined if no localStorage available', () => {
|
|
15
|
+
(localStorage.getItem as any).mockReturnValueOnce(null);
|
|
16
|
+
expect(getUserPref('key')).toEqual(undefined);
|
|
17
|
+
});
|
|
18
|
+
it('should return undefined if localStorage has no value for searched path', () => {
|
|
19
|
+
(localStorage.getItem as any).mockReturnValueOnce(
|
|
20
|
+
'{"path1": false, "path2": true}',
|
|
21
|
+
);
|
|
22
|
+
expect(getUserPref('key', 'path3')).toEqual(undefined);
|
|
23
|
+
});
|
|
24
|
+
it('should return undefined if localStorage is not correctly formated', () => {
|
|
25
|
+
(localStorage.getItem as any).mockReturnValueOnce(
|
|
26
|
+
'{"path1": {"key": "value"}, "path2": true',
|
|
27
|
+
);
|
|
28
|
+
expect(getUserPref('key', 'path1')).toEqual(undefined);
|
|
29
|
+
});
|
|
30
|
+
it('should return undefined if localStorage does not have key for path', () => {
|
|
31
|
+
(localStorage.getItem as any).mockReturnValueOnce(
|
|
32
|
+
'{"path1": {"key": "value"}, "path2": true}',
|
|
33
|
+
);
|
|
34
|
+
expect(getUserPref('keyNotExisting', 'path1')).toEqual(undefined);
|
|
35
|
+
});
|
|
36
|
+
it('should return the value if localStorage has key for path', () => {
|
|
37
|
+
(localStorage.getItem as any).mockReturnValueOnce(
|
|
38
|
+
'{"path1": {"key": "value"}, "path2": true}',
|
|
39
|
+
);
|
|
40
|
+
expect(getUserPref('key', 'path1')).toEqual('value');
|
|
41
|
+
});
|
|
42
|
+
it('should return the value if localStorage has key for global', () => {
|
|
43
|
+
(localStorage.getItem as any).mockReturnValueOnce(
|
|
44
|
+
'{"path1": {}, "path2": true, "global": {"key": "value"}}',
|
|
45
|
+
);
|
|
46
|
+
expect(getUserPref('key')).toEqual('value');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('saveUserPref', () => {
|
|
51
|
+
const { saveUserPref } = useUserPref();
|
|
52
|
+
it('should create a new entry in localStorage if there is no pref saved', () => {
|
|
53
|
+
(localStorage.getItem as any).mockReturnValueOnce(null);
|
|
54
|
+
saveUserPref('key', 'value', 'path');
|
|
55
|
+
expect(localStorage.setItem).toHaveBeenCalled();
|
|
56
|
+
expect(localStorage.setItem).toHaveBeenCalledWith(
|
|
57
|
+
'userPref',
|
|
58
|
+
'{"path":{"key":"value"}}',
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
it('should create a new entry in localStorage in global if there is no pref saved', () => {
|
|
62
|
+
(localStorage.getItem as any).mockReturnValueOnce(null);
|
|
63
|
+
saveUserPref('key', 'value');
|
|
64
|
+
expect(localStorage.setItem).toHaveBeenCalled();
|
|
65
|
+
expect(localStorage.setItem).toHaveBeenCalledWith(
|
|
66
|
+
'userPref',
|
|
67
|
+
'{"global":{"key":"value"}}',
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
it('should add a new entry in localStorage if there is no pref saved', () => {
|
|
71
|
+
(localStorage.getItem as any).mockReturnValueOnce(
|
|
72
|
+
'{"path1": {"key": "value"}, "path2": true}',
|
|
73
|
+
);
|
|
74
|
+
saveUserPref('key', 'value', 'path3');
|
|
75
|
+
expect(localStorage.setItem).toHaveBeenCalled();
|
|
76
|
+
expect(localStorage.setItem).toHaveBeenCalledWith(
|
|
77
|
+
'userPref',
|
|
78
|
+
'{"path1":{"key":"value"},"path2":true,"path3":{"key":"value"}}',
|
|
79
|
+
);
|
|
80
|
+
});
|
|
81
|
+
it('should add a new entry in localStorage in global if there is no pref saved', () => {
|
|
82
|
+
(localStorage.getItem as any).mockReturnValueOnce(
|
|
83
|
+
'{"path1": {"key": "value"}, "path2": true}',
|
|
84
|
+
);
|
|
85
|
+
saveUserPref('key', 'value');
|
|
86
|
+
expect(localStorage.setItem).toHaveBeenCalled();
|
|
87
|
+
expect(localStorage.setItem).toHaveBeenCalledWith(
|
|
88
|
+
'userPref',
|
|
89
|
+
'{"path1":{"key":"value"},"path2":true,"global":{"key":"value"}}',
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
it('should edit a entry in localStorage if there is pref saved', () => {
|
|
93
|
+
(localStorage.getItem as any).mockReturnValueOnce(
|
|
94
|
+
'{"path1": {"key": "value","key2":"value3"}, "path2": true}',
|
|
95
|
+
);
|
|
96
|
+
saveUserPref('key', 'value2', 'path1');
|
|
97
|
+
expect(localStorage.setItem).toHaveBeenCalled();
|
|
98
|
+
expect(localStorage.setItem).toHaveBeenCalledWith(
|
|
99
|
+
'userPref',
|
|
100
|
+
'{"path1":{"key":"value2","key2":"value3"},"path2":true}',
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
it('should edit a global entry in localStorage if there is pref saved', () => {
|
|
104
|
+
(localStorage.getItem as any).mockReturnValueOnce(
|
|
105
|
+
'{"path1": {"key": "value","key2":"value3"}, "path2": true,"global":{"key":"value"}}',
|
|
106
|
+
);
|
|
107
|
+
saveUserPref('key', 'value2');
|
|
108
|
+
expect(localStorage.setItem).toHaveBeenCalled();
|
|
109
|
+
expect(localStorage.setItem).toHaveBeenCalledWith(
|
|
110
|
+
'userPref',
|
|
111
|
+
'{"path1":{"key":"value","key2":"value3"},"path2":true,"global":{"key":"value2"}}',
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
});
|