@leaflink/stash 51.9.3 → 51.11.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/assets/icons/cloud-share.svg +1 -0
- package/assets/spritesheet.svg +1 -1
- package/dist/Accordion.js.map +1 -1
- package/dist/Accordion.vue.d.ts +7 -38
- package/dist/ActionsDropdown.js +2 -2
- package/dist/ActionsDropdown.js.map +1 -1
- package/dist/ActionsDropdown.vue.d.ts +0 -74
- package/dist/AddressSelect.js +56 -60
- package/dist/AddressSelect.js.map +1 -1
- package/dist/AddressSelect.vue.d.ts +8 -65
- package/dist/Alert.js.map +1 -1
- package/dist/Alert.vue.d.ts +4 -41
- package/dist/AppNavigationItem.js.map +1 -1
- package/dist/AppNavigationItem.vue.d.ts +5 -32
- package/dist/AppSidebar.js.map +1 -1
- package/dist/AppSidebar.vue.d.ts +8 -35
- package/dist/AppTopbar.js +1 -1
- package/dist/AppTopbar.js.map +1 -1
- package/dist/AppTopbar.vue.d.ts +4 -33
- package/dist/Avatar.js.map +1 -1
- package/dist/Avatar.vue.d.ts +5 -44
- package/dist/Backdrop.js.map +1 -1
- package/dist/Backdrop.vue.d.ts +1 -1
- package/dist/Badge.js.map +1 -1
- package/dist/Badge.vue.d.ts +6 -55
- package/dist/Box.vue.d.ts +3 -36
- package/dist/Box.vue_vue_type_script_setup_true_lang-rFnvwLVY.js.map +1 -1
- package/dist/Button.js.map +1 -1
- package/dist/Button.vue.d.ts +5 -50
- package/dist/ButtonGroup.js +33 -37
- package/dist/ButtonGroup.js.map +1 -1
- package/dist/ButtonGroup.vue.d.ts +6 -39
- package/dist/Card.js.map +1 -1
- package/dist/Card.vue.d.ts +5 -32
- package/dist/CardContent.js.map +1 -1
- package/dist/CardContent.vue.d.ts +1 -1
- package/dist/CardFooter.js.map +1 -1
- package/dist/CardFooter.vue.d.ts +1 -1
- package/dist/CardHeader.js.map +1 -1
- package/dist/CardHeader.vue.d.ts +2 -15
- package/dist/CardMedia.js.map +1 -1
- package/dist/CardMedia.vue.d.ts +2 -15
- package/dist/Carousel.js +66 -72
- package/dist/Carousel.js.map +1 -1
- package/dist/Carousel.vue.d.ts +10 -10
- package/dist/Checkbox.js.map +1 -1
- package/dist/Checkbox.vue.d.ts +8 -53
- package/dist/ChevronToggle.vue.d.ts +7 -34
- package/dist/ChevronToggle.vue_vue_type_script_setup_true_lang-Ce_qOXfR.js.map +1 -1
- package/dist/Chip.js.map +1 -1
- package/dist/Chip.vue.d.ts +10 -52
- package/dist/ConfirmationCodeInput.js +40 -44
- package/dist/ConfirmationCodeInput.js.map +1 -1
- package/dist/ConfirmationCodeInput.vue.d.ts +8 -43
- package/dist/ContextSwitcher.js.map +1 -1
- package/dist/ContextSwitcher.vue.d.ts +6 -41
- package/dist/Copy.js.map +1 -1
- package/dist/Copy.vue.d.ts +3 -34
- package/dist/CurrencyInput.js +20 -21
- package/dist/CurrencyInput.js.map +1 -1
- package/dist/CurrencyInput.vue.d.ts +125 -46
- package/dist/CustomRender.js.map +1 -1
- package/dist/DataView.js +94 -96
- package/dist/DataView.js.map +1 -1
- package/dist/DataView.keys-aSOnA4AD.js.map +1 -1
- package/dist/DataView.vue.d.ts +15 -57
- package/dist/DataViewFilters.js +127 -139
- package/dist/DataViewFilters.js.map +1 -1
- package/dist/DataViewFilters.keys-BLu07FiP.js.map +1 -1
- package/dist/DataViewFilters.vue.d.ts +9 -54
- package/dist/DataViewSortButton.js +2 -2
- package/dist/DataViewSortButton.js.map +1 -1
- package/dist/DataViewSortButton.vue.d.ts +3 -30
- package/dist/DataViewToolbar.js +146 -71
- package/dist/DataViewToolbar.js.map +1 -1
- package/dist/DataViewToolbar.vue.d.ts +106 -40
- package/dist/DatePicker.js +4524 -4636
- package/dist/DatePicker.js.map +1 -1
- package/dist/DatePicker.vue.d.ts +32 -81
- package/dist/DescriptionList.js.map +1 -1
- package/dist/DescriptionList.vue.d.ts +3 -32
- package/dist/DescriptionListDetail.js.map +1 -1
- package/dist/DescriptionListDetail.vue.d.ts +1 -1
- package/dist/DescriptionListGroup.js.map +1 -1
- package/dist/DescriptionListGroup.vue.d.ts +1 -1
- package/dist/DescriptionListTerm.js.map +1 -1
- package/dist/DescriptionListTerm.vue.d.ts +1 -1
- package/dist/Dialog.js.map +1 -1
- package/dist/Dialog.vue.d.ts +10 -53
- package/dist/Divider.js.map +1 -1
- package/dist/Dropdown.js +89 -95
- package/dist/Dropdown.js.map +1 -1
- package/dist/Dropdown.vue.d.ts +12 -48
- package/dist/EmptyState.js +1 -1
- package/dist/EmptyState.js.map +1 -1
- package/dist/EmptyState.vue.d.ts +5 -62
- package/dist/Expand.vue.d.ts +10 -40
- package/dist/Expand.vue_vue_type_script_setup_true_lang-CiONJfAp.js.map +1 -1
- package/dist/Field.vue.d.ts +4 -53
- package/dist/Field.vue_vue_type_script_setup_true_lang-DI6z3AE9.js.map +1 -1
- package/dist/FileUpload.js +72 -74
- package/dist/FileUpload.js.map +1 -1
- package/dist/FileUpload.vue.d.ts +10 -44
- package/dist/FilterChip.js.map +1 -1
- package/dist/FilterChip.vue.d.ts +6 -41
- package/dist/FilterDrawerItem.js +21 -21
- package/dist/FilterDrawerItem.js.map +1 -1
- package/dist/FilterDrawerItem.vue.d.ts +6 -23
- package/dist/FilterDropdown.js +63 -69
- package/dist/FilterDropdown.js.map +1 -1
- package/dist/FilterDropdown.vue.d.ts +122 -35
- package/dist/FilterSelect.js.map +1 -1
- package/dist/FilterSelect.vue.d.ts +4 -31
- package/dist/Filters.js +157 -164
- package/dist/Filters.js.map +1 -1
- package/dist/Filters.vue.d.ts +0 -2190
- package/dist/HttpError.js +7 -7
- package/dist/HttpError.js.map +1 -1
- package/dist/HttpError.vue.d.ts +4 -41
- package/dist/Icon.js +16 -15
- package/dist/Icon.js.map +1 -1
- package/dist/Icon.vue.d.ts +4 -37
- package/dist/IconLabel.js.map +1 -1
- package/dist/IconLabel.vue.d.ts +6 -41
- package/dist/Illustration.js +2 -2
- package/dist/Illustration.vue.d.ts +3 -42
- package/dist/{Illustration.vue_vue_type_script_setup_true_lang-BrqEF8xe.js → Illustration.vue_vue_type_script_setup_true_lang-BVzzNsRt.js} +11 -11
- package/dist/{Illustration.vue_vue_type_script_setup_true_lang-BrqEF8xe.js.map → Illustration.vue_vue_type_script_setup_true_lang-BVzzNsRt.js.map} +1 -1
- package/dist/Image.js +2 -2
- package/dist/Image.vue.d.ts +5 -40
- package/dist/{Image.vue_vue_type_script_setup_true_lang-D5u4av0_.js → Image.vue_vue_type_script_setup_true_lang-Dg2Zk2r2.js} +37 -41
- package/dist/{Image.vue_vue_type_script_setup_true_lang-D5u4av0_.js.map → Image.vue_vue_type_script_setup_true_lang-Dg2Zk2r2.js.map} +1 -1
- package/dist/InlineEdit.js.map +1 -1
- package/dist/InlineEdit.vue.d.ts +126 -47
- package/dist/Input.js.map +1 -1
- package/dist/Input.vue.d.ts +12 -45
- package/dist/InputOptions.js +66 -69
- package/dist/InputOptions.js.map +1 -1
- package/dist/InputOptions.vue.d.ts +10 -55
- package/dist/IntegrationIcon.js +7 -7
- package/dist/IntegrationIcon.js.map +1 -1
- package/dist/IntegrationIcon.vue.d.ts +3 -36
- package/dist/Label.vue.d.ts +3 -42
- package/dist/Label.vue_vue_type_script_setup_true_lang-CNquF3AP.js.map +1 -1
- package/dist/LicenseChip.js.map +1 -1
- package/dist/LicenseChip.vue.d.ts +3 -30
- package/dist/ListItem.js.map +1 -1
- package/dist/ListItem.vue.d.ts +0 -294
- package/dist/ListItemCell.js.map +1 -1
- package/dist/ListItemCell.vue.d.ts +0 -21
- package/dist/ListView.js +4 -7
- package/dist/ListView.js.map +1 -1
- package/dist/ListView.types.d.ts +0 -29
- package/dist/ListView.vue.d.ts +0 -5496
- package/dist/Loading.js +2 -2
- package/dist/Loading.js.map +1 -1
- package/dist/Loading.vue.d.ts +1 -1
- package/dist/Logo.js +1 -1
- package/dist/Logo.vue.d.ts +6 -41
- package/dist/{Logo.vue_vue_type_script_setup_true_lang-Dz8c98sc.js → Logo.vue_vue_type_script_setup_true_lang-Y3iE9utm.js} +17 -17
- package/dist/Logo.vue_vue_type_script_setup_true_lang-Y3iE9utm.js.map +1 -0
- package/dist/Menu.js.map +1 -1
- package/dist/Menu.vue.d.ts +1 -1
- package/dist/MenuItem.js.map +1 -1
- package/dist/MenuItem.vue.d.ts +1 -1
- package/dist/MenusPlugin-B4jpNe7x.js +12 -0
- package/dist/{MenusPlugin-Bk6UW6o9.js.map → MenusPlugin-B4jpNe7x.js.map} +1 -1
- package/dist/Metric.js.map +1 -1
- package/dist/Metric.vue.d.ts +3 -34
- package/dist/Modal.js +62 -64
- package/dist/Modal.js.map +1 -1
- package/dist/Modal.vue.d.ts +13 -60
- package/dist/Modals.js +17 -18
- package/dist/Modals.js.map +1 -1
- package/dist/ModalsPlugin.js +11 -11
- package/dist/ModalsPlugin.js.map +1 -1
- package/dist/Module.js.map +1 -1
- package/dist/Module.keys-CEsrW2f0.js.map +1 -1
- package/dist/Module.types-B1FfGGac.js.map +1 -1
- package/dist/Module.vue.d.ts +2 -29
- package/dist/ModuleContent.js.map +1 -1
- package/dist/ModuleContent.vue.d.ts +3 -3
- package/dist/ModuleFooter.js.map +1 -1
- package/dist/ModuleFooter.vue.d.ts +1 -1
- package/dist/ModuleHeader.js.map +1 -1
- package/dist/ModuleHeader.vue.d.ts +5 -39
- package/dist/MoreActions.js +489 -0
- package/dist/MoreActions.js.map +1 -0
- package/dist/MoreActions.vue.d.ts +203 -0
- package/dist/ObfuscateText.js.map +1 -1
- package/dist/ObfuscateText.vue.d.ts +3 -40
- package/dist/PageContent.js.map +1 -1
- package/dist/PageContent.vue.d.ts +3 -30
- package/dist/PageHeader.js.map +1 -1
- package/dist/PageHeader.vue.d.ts +6 -35
- package/dist/PageNavigation.js +50 -50
- package/dist/PageNavigation.js.map +1 -1
- package/dist/PageNavigation.vue.d.ts +7 -36
- package/dist/Paginate.js.map +1 -1
- package/dist/Paginate.vue.d.ts +5 -40
- package/dist/PlaidLink.js.map +1 -1
- package/dist/PlaidLink.vue.d.ts +12 -49
- package/dist/QuickAction.js.map +1 -1
- package/dist/QuickAction.vue.d.ts +3 -16
- package/dist/Radio.js.map +1 -1
- package/dist/Radio.vue.d.ts +0 -93
- package/dist/RadioGroup.js +94 -101
- package/dist/RadioGroup.js.map +1 -1
- package/dist/RadioGroup.vue.d.ts +116 -42
- package/dist/RadioNew.js +96 -99
- package/dist/RadioNew.js.map +1 -1
- package/dist/RadioNew.vue.d.ts +7 -48
- package/dist/RangeInput.js.map +1 -1
- package/dist/RangeInput.vue.d.ts +1 -1
- package/dist/SearchBar.js +38 -39
- package/dist/SearchBar.js.map +1 -1
- package/dist/SearchBar.vue.d.ts +127 -44
- package/dist/SectionHeader.js.map +1 -1
- package/dist/SectionHeader.vue.d.ts +6 -37
- package/dist/Select.js +171 -183
- package/dist/Select.js.map +1 -1
- package/dist/Select.vue.d.ts +23 -102
- package/dist/SelectStatus.js +38 -38
- package/dist/SelectStatus.js.map +1 -1
- package/dist/SelectStatus.vue.d.ts +227 -47
- package/dist/Skeleton.js.map +1 -1
- package/dist/Skeleton.vue.d.ts +3 -34
- package/dist/Step.js +44 -44
- package/dist/Step.js.map +1 -1
- package/dist/Step.vue.d.ts +4 -43
- package/dist/Stepper.js.map +1 -1
- package/dist/Stepper.vue.d.ts +9 -44
- package/dist/Switch.js.map +1 -1
- package/dist/Switch.vue.d.ts +8 -47
- package/dist/Tab.js +9 -9
- package/dist/Tab.js.map +1 -1
- package/dist/Tab.vue.d.ts +2 -15
- package/dist/TabPanel.js.map +1 -1
- package/dist/TabPanel.vue.d.ts +3 -30
- package/dist/Table.js +53 -59
- package/dist/Table.js.map +1 -1
- package/dist/Table.keys-LHQf6FEH.js.map +1 -1
- package/dist/Table.vue.d.ts +3 -50
- package/dist/TableCell.js +1 -1
- package/dist/TableCell.js.map +1 -1
- package/dist/TableCell.vue.d.ts +3 -32
- package/dist/TableHeaderCell.js +1 -1
- package/dist/TableHeaderCell.js.map +1 -1
- package/dist/TableHeaderCell.vue.d.ts +3 -30
- package/dist/TableHeaderRow.js +47 -45
- package/dist/TableHeaderRow.js.map +1 -1
- package/dist/TableHeaderRow.vue.d.ts +5 -34
- package/dist/TableRow.js +60 -61
- package/dist/TableRow.js.map +1 -1
- package/dist/TableRow.vue.d.ts +7 -48
- package/dist/Tabs.js +2 -2
- package/dist/Tabs.vue.d.ts +4 -31
- package/dist/Tabs.vue_vue_type_script_setup_true_lang-BlJVDr7o.js +78 -0
- package/dist/Tabs.vue_vue_type_script_setup_true_lang-BlJVDr7o.js.map +1 -0
- package/dist/TextEditor.js +2414 -2420
- package/dist/TextEditor.js.map +1 -1
- package/dist/TextEditor.vue.d.ts +9 -40
- package/dist/Textarea.js +69 -69
- package/dist/Textarea.js.map +1 -1
- package/dist/Textarea.vue.d.ts +9 -44
- package/dist/Thumbnail.js +1 -1
- package/dist/Thumbnail.js.map +1 -1
- package/dist/Thumbnail.vue.d.ts +4 -4
- package/dist/ThumbnailEmpty.js.map +1 -1
- package/dist/ThumbnailEmpty.vue.d.ts +1 -1
- package/dist/ThumbnailGroup.js.map +1 -1
- package/dist/ThumbnailGroup.keys-EJ4qFNhx.js.map +1 -1
- package/dist/ThumbnailGroup.vue.d.ts +26 -22
- package/dist/Timeline.js.map +1 -1
- package/dist/Timeline.vue.d.ts +3 -32
- package/dist/TimelineItem.js.map +1 -1
- package/dist/TimelineItem.vue.d.ts +1 -1
- package/dist/Toast.js.map +1 -1
- package/dist/Toast.vue.d.ts +3 -30
- package/dist/Toasts.js.map +1 -1
- package/dist/ToastsPlugin.js +11 -11
- package/dist/ToastsPlugin.js.map +1 -1
- package/dist/Tooltip.js +29 -30
- package/dist/Tooltip.js.map +1 -1
- package/dist/Tooltip.vue.d.ts +11 -43
- package/dist/colors-DDDVvqfQ.js.map +1 -1
- package/dist/components.css +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/directives/autofocus.js.map +1 -1
- package/dist/directives/clickoutside.js.map +1 -1
- package/dist/directives/observe.js.map +1 -1
- package/dist/directives/sticky.js.map +1 -1
- package/dist/directives/tooltip.js +3 -3
- package/dist/directives/tooltip.js.map +1 -1
- package/dist/directives/viewable.js +39 -44
- package/dist/directives/viewable.js.map +1 -1
- package/dist/{floating-ui.vue-pzUuloyX.js → floating-ui.vue-CL01Y9ER.js} +2 -2
- package/dist/{floating-ui.vue-pzUuloyX.js.map → floating-ui.vue-CL01Y9ER.js.map} +1 -1
- package/dist/formatDateTime-DG7kBc2T.js +1414 -0
- package/dist/{formatDateTime-Dz8bXV0R.js.map → formatDateTime-DG7kBc2T.js.map} +1 -1
- package/dist/index-D6bxWkZ1.js.map +1 -1
- package/dist/index-XZqpB2_R.js +294 -0
- package/dist/{index-ConQ3o31.js.map → index-XZqpB2_R.js.map} +1 -1
- package/dist/index.js +99 -104
- package/dist/index.js.map +1 -1
- package/dist/isDefined-DzVx0B6k.js.map +1 -1
- package/dist/keys-BEdEsanp.js.map +1 -1
- package/dist/keys-C8Zfr_By.js.map +1 -1
- package/dist/locale.js.map +1 -1
- package/dist/misc-CHQs-G03.js.map +1 -1
- package/dist/obfuscateText.d.ts +1 -1
- package/dist/parseISO-wlfIB_QJ.js.map +1 -1
- package/dist/searchFuzzy-DBDE6jkd.js +408 -0
- package/dist/{searchFuzzy-DRasJ33G.js.map → searchFuzzy-DBDE6jkd.js.map} +1 -1
- package/dist/statusLevels-D8EgtE_L.js.map +1 -1
- package/dist/storage.js.map +1 -1
- package/dist/tailwind-base.d.ts +18 -0
- package/dist/tailwind-base.js +19 -9
- package/dist/tailwind-base.js.map +1 -1
- package/dist/toTimeZone-Coq1oPTt.js.map +1 -1
- package/dist/useConfirmBeforeClosing.js.map +1 -1
- package/dist/useDialog.d.ts +2 -2
- package/dist/useDialog.js +21 -25
- package/dist/useDialog.js.map +1 -1
- package/dist/useGoogleMaps.js +108 -110
- package/dist/useGoogleMaps.js.map +1 -1
- package/dist/useMediaQuery.d.ts +0 -6
- package/dist/useMediaQuery.js +11 -15
- package/dist/useMediaQuery.js.map +1 -1
- package/dist/useModals.d.ts +1 -1
- package/dist/useModals.js.map +1 -1
- package/dist/usePaginationStats-d_q39naC.js.map +1 -1
- package/dist/usePlaidLink.js +20 -27
- package/dist/usePlaidLink.js.map +1 -1
- package/dist/useScriptTag.js.map +1 -1
- package/dist/useSearch.js +13 -13
- package/dist/useSearch.js.map +1 -1
- package/dist/useSelection.js +56 -56
- package/dist/useSelection.js.map +1 -1
- package/dist/useSortable.js +54 -63
- package/dist/useSortable.js.map +1 -1
- package/dist/useStepper.d.ts +2 -2
- package/dist/useStepper.js +36 -40
- package/dist/useStepper.js.map +1 -1
- package/dist/useToasts.js +23 -23
- package/dist/useToasts.js.map +1 -1
- package/dist/useValidation.js +96 -100
- package/dist/useValidation.js.map +1 -1
- package/dist/utils/calculateElementOverflow.js +4 -4
- package/dist/utils/calculateElementOverflow.js.map +1 -1
- package/dist/utils/colorScheme.js +2 -2
- package/dist/utils/colorScheme.js.map +1 -1
- package/dist/utils/createQueryString.js.map +1 -1
- package/dist/utils/createValidDate.js.map +1 -1
- package/dist/utils/formatDateTime.js +1 -1
- package/dist/utils/getContrastingTextColor.js.map +1 -1
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/i18n.js.map +1 -1
- package/dist/utils/normalizeDate.js.map +1 -1
- package/dist/utils/obfuscateText.js +6 -6
- package/dist/utils/obfuscateText.js.map +1 -1
- package/dist/utils/searchFuzzy.js +1 -1
- package/dist/utils/storage.js +23 -23
- package/dist/utils/storage.js.map +1 -1
- package/package.json +12 -13
- package/tailwind-base.ts +12 -1
- package/types/vite.d.ts +7 -0
- package/types/vitest.d.ts +7 -0
- package/dist/Logo.vue_vue_type_script_setup_true_lang-Dz8c98sc.js.map +0 -1
- package/dist/MenusPlugin-Bk6UW6o9.js +0 -12
- package/dist/Tabs.vue_vue_type_script_setup_true_lang-CmnBP4i1.js +0 -159
- package/dist/Tabs.vue_vue_type_script_setup_true_lang-CmnBP4i1.js.map +0 -1
- package/dist/formatDateTime-Dz8bXV0R.js +0 -1418
- package/dist/index-ConQ3o31.js +0 -128
- package/dist/searchFuzzy-DRasJ33G.js +0 -409
package/dist/useStepper.js
CHANGED
|
@@ -1,70 +1,66 @@
|
|
|
1
|
-
import { ref as f, computed as p, readonly as
|
|
2
|
-
function
|
|
1
|
+
import { ref as f, computed as p, readonly as A } from "vue";
|
|
2
|
+
function C(v = {
|
|
3
3
|
linear: !1,
|
|
4
4
|
activeStep: -1,
|
|
5
5
|
activeSubstep: -1,
|
|
6
6
|
steps: []
|
|
7
7
|
}) {
|
|
8
|
-
const
|
|
8
|
+
const u = f(v.steps ? v.steps : []), n = p(() => u.value.length), e = f(
|
|
9
9
|
v.activeStep !== null && v.activeStep !== void 0 ? v.activeStep : -1
|
|
10
10
|
), l = f(
|
|
11
11
|
v.activeSubstep !== null && v.activeSubstep !== void 0 ? v.activeSubstep : -1
|
|
12
|
-
), S = p(() =>
|
|
13
|
-
|
|
14
|
-
return
|
|
15
|
-
}), m = p(() => S.value[e.value]);
|
|
16
|
-
function s(u) {
|
|
17
|
-
return !!a.value[u].substeps.length;
|
|
12
|
+
), o = p(() => Array.from(v.ref?.value?.children || [])), S = p(() => o.value[e.value]);
|
|
13
|
+
function s(a) {
|
|
14
|
+
return !!u.value[a].substeps.length;
|
|
18
15
|
}
|
|
19
|
-
function
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
16
|
+
function m() {
|
|
17
|
+
const a = e.value === -1, t = e.value === u.value.length - 1;
|
|
18
|
+
if (a)
|
|
22
19
|
e.value++, s(e.value) && l.value++;
|
|
23
20
|
else if (t)
|
|
24
21
|
if (s(e.value)) {
|
|
25
|
-
const
|
|
26
|
-
|
|
22
|
+
const c = l.value === -1, r = l.value === u.value[e.value].substeps.length - 1;
|
|
23
|
+
c ? l.value++ : r ? (u.value[e.value].substeps[l.value].completed = !0, l.value = -1, u.value[e.value].completed = !0, e.value = -1) : (u.value[e.value].substeps[l.value].completed = !0, l.value++);
|
|
27
24
|
} else
|
|
28
|
-
|
|
25
|
+
u.value[e.value].completed = !0, e.value = -1;
|
|
29
26
|
else if (s(e.value)) {
|
|
30
|
-
const
|
|
31
|
-
|
|
27
|
+
const c = l.value === -1, r = l.value === u.value[e.value].substeps.length - 1;
|
|
28
|
+
c ? l.value++ : r ? (u.value[e.value].substeps[l.value].completed = !0, l.value = -1, u.value[e.value].completed = !0, e.value++, s(e.value) && l.value === -1 && l.value++) : (u.value[e.value].substeps[l.value].completed = !0, l.value++);
|
|
32
29
|
} else
|
|
33
|
-
|
|
30
|
+
u.value[e.value].completed = !0, e.value++, s(e.value) && l.value === -1 && l.value++;
|
|
34
31
|
}
|
|
35
|
-
function
|
|
36
|
-
e.value !== -1 && (s(e.value) ? l.value === 0 ? (e.value--, l.value--, e.value >= 0 && s(e.value) && (l.value =
|
|
32
|
+
function b() {
|
|
33
|
+
e.value !== -1 && (s(e.value) ? l.value === 0 ? (e.value--, l.value--, e.value >= 0 && s(e.value) && (l.value = u.value[e.value].substeps.length - 1)) : l.value-- : (e.value--, e.value >= 0 && s(e.value) && (l.value = u.value[e.value].substeps.length - 1)));
|
|
37
34
|
}
|
|
38
|
-
function
|
|
39
|
-
v.linear ? (
|
|
35
|
+
function h(a, t = -1) {
|
|
36
|
+
v.linear ? (i(a - 1) || a === 0) && (s(a) && (t <= 0 ? l.value = 0 : i(a, t - 1) && (l.value = t)), e.value = a) : (e.value = a, s(a) && (t < 0 ? l.value = 0 : l.value = t));
|
|
40
37
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
return t >= 0 ? (c = (i = a.value[u]) == null ? void 0 : i.substeps[t]) == null ? void 0 : c.completed : (n = a.value[u]) == null ? void 0 : n.completed;
|
|
38
|
+
function i(a, t = -1) {
|
|
39
|
+
return t >= 0 ? u.value[a]?.substeps[t]?.completed : u.value[a]?.completed;
|
|
44
40
|
}
|
|
45
|
-
function
|
|
46
|
-
return t >= 0 ? e.value ===
|
|
41
|
+
function g(a, t = -1) {
|
|
42
|
+
return t >= 0 ? e.value === a && l.value === t : e.value === a;
|
|
47
43
|
}
|
|
48
|
-
function
|
|
49
|
-
if (
|
|
44
|
+
function d(a = !1) {
|
|
45
|
+
if (a && !u.value.length)
|
|
50
46
|
throw new Error("Cannot register a substep without a parent step.");
|
|
51
|
-
|
|
47
|
+
a ? u.value[u.value.length - 1].substeps.push({ completed: !1 }) : u.value.push({ completed: !1, substeps: [] });
|
|
52
48
|
}
|
|
53
49
|
return {
|
|
54
|
-
steps:
|
|
55
|
-
stepCount:
|
|
56
|
-
activeStepElement:
|
|
50
|
+
steps: A(u),
|
|
51
|
+
stepCount: n,
|
|
52
|
+
activeStepElement: S,
|
|
57
53
|
activeStepIndex: e,
|
|
58
54
|
activeSubstepIndex: l,
|
|
59
|
-
registerStep:
|
|
60
|
-
next:
|
|
61
|
-
back:
|
|
62
|
-
goTo:
|
|
63
|
-
isStepActive:
|
|
64
|
-
isStepCompleted:
|
|
55
|
+
registerStep: d,
|
|
56
|
+
next: m,
|
|
57
|
+
back: b,
|
|
58
|
+
goTo: h,
|
|
59
|
+
isStepActive: g,
|
|
60
|
+
isStepCompleted: i
|
|
65
61
|
};
|
|
66
62
|
}
|
|
67
63
|
export {
|
|
68
|
-
|
|
64
|
+
C as default
|
|
69
65
|
};
|
|
70
66
|
//# sourceMappingURL=useStepper.js.map
|
package/dist/useStepper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStepper.js","sources":["../src/composables/useStepper/useStepper.ts"],"sourcesContent":["import { computed, readonly, Ref, ref } from 'vue';\n\nexport interface StepDefinition {\n completed: boolean;\n substeps: Array<Omit<StepDefinition, 'substeps'>>;\n}\n\nexport interface StepperOptions {\n /**\n * If true, the stepper will prevent skipping steps\n */\n linear?: boolean;\n /**\n * The index of the active step\n */\n activeStep?: number;\n /**\n * The index of the active substep\n */\n activeSubstep?: number;\n /**\n * The stepper representation as an array of steps and substeps\n */\n steps?: Array<StepDefinition>;\n /**\n * A ref to the stepper element\n */\n ref?: Ref<HTMLUListElement | null>;\n}\n\nexport default function useStepper(\n options: StepperOptions = {\n linear: false,\n activeStep: -1,\n activeSubstep: -1,\n steps: [],\n },\n) {\n /**\n * The steps and substeps of the stepper, so we can keep track of their state.\n * Can be populated with the `steps` option, or via the `registerStep` function.\n */\n const steps = ref<Array<StepDefinition>>(options.steps ? options.steps : []);\n\n const stepCount = computed(() => steps.value.length);\n\n const activeStepIndex = ref(\n options.activeStep !== null && options.activeStep !== undefined ? options.activeStep : -1,\n );\n const activeSubstepIndex = ref(\n options.activeSubstep !== null && options.activeSubstep !== undefined ? options.activeSubstep : -1,\n );\n\n const stepElements = computed(() => {\n return Array.from((options.ref?.value?.children || []) as HTMLCollectionOf<HTMLLIElement>);\n });\n\n const activeStepElement = computed(() => stepElements.value[activeStepIndex.value]);\n\n /**\n * Returns true if the step at the given index has substeps\n * @param stepIndex The index of the step to check\n */\n function stepHasSubsteps(stepIndex: number): boolean {\n return !!steps.value[stepIndex].substeps.length;\n }\n\n /**\n * Goes to the next step or substep, while flagging the current one as completed.\n * If the current step has substeps, it will go to the next substep if there are any, or to the next substep.\n * And if the next step has substeps, automatically goes to the first substep\n */\n function next(): void {\n const hasNoActiveStep = activeStepIndex.value === -1;\n const isLastStep = activeStepIndex.value === steps.value.length - 1;\n\n // If there is no active step, we want to activate the first step\n if (hasNoActiveStep) {\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep\n if (stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value++;\n }\n } else if (isLastStep) {\n if (stepHasSubsteps(activeStepIndex.value)) {\n const hasNoActiveSubstep = activeSubstepIndex.value === -1;\n const isLastSubstep = activeSubstepIndex.value === steps.value[activeStepIndex.value].substeps.length - 1;\n\n // if there are no active substeps, we want to activate the first substep\n if (hasNoActiveSubstep) {\n activeSubstepIndex.value++;\n // if the active substep is the last one, we want to reset the step and substep to -1\n } else if (isLastSubstep) {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value = -1;\n\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value = -1;\n // if there are more substeps, we want to complete the current one and proceed to the next substep\n } else {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value++;\n }\n // If there are no substeps, we want to complete the current step and reset the step to -1\n } else {\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value = -1;\n }\n } else {\n if (stepHasSubsteps(activeStepIndex.value)) {\n const hasNoActiveSubstep = activeSubstepIndex.value === -1;\n const isLastSubstep = activeSubstepIndex.value === steps.value[activeStepIndex.value].substeps.length - 1;\n\n // if there are no active substeps, we want to activate the first substep\n if (hasNoActiveSubstep) {\n activeSubstepIndex.value++;\n // if the active substep is the last one, we want to go to the next step\n } else if (isLastSubstep) {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value = -1;\n\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep right away\n if (stepHasSubsteps(activeStepIndex.value) && activeSubstepIndex.value === -1) {\n activeSubstepIndex.value++;\n }\n // if there are more substeps, we want to complete the current one and proceed to the next substep\n } else {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value++;\n }\n } else {\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep right away\n if (stepHasSubsteps(activeStepIndex.value) && activeSubstepIndex.value === -1) {\n activeSubstepIndex.value++;\n }\n }\n }\n }\n\n function back(): void {\n // We don't want to go back if there is no active step\n if (activeStepIndex.value === -1) {\n return;\n }\n\n if (stepHasSubsteps(activeStepIndex.value)) {\n // If the active substep is the first one, we want to go back to the previous step\n if (activeSubstepIndex.value === 0) {\n activeStepIndex.value--;\n activeSubstepIndex.value--;\n\n // If the step that we just navigated to has substeps, we want to navigate to the last substep\n if (activeStepIndex.value >= 0 && stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value = steps.value[activeStepIndex.value].substeps.length - 1;\n }\n } else {\n activeSubstepIndex.value--;\n }\n } else {\n activeStepIndex.value--;\n\n // If the step that we just navigated to has substeps, we want to navigate to the last substep\n if (activeStepIndex.value >= 0 && stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value = steps.value[activeStepIndex.value].substeps.length - 1;\n }\n }\n }\n\n /**\n * Navigates to a specific step and substep.\n */\n function goTo(stepIndex: number, substepIndex = -1): void {\n // A linear stepper prevents navigation to incomplete steps\n if (options.linear) {\n if (isStepCompleted(stepIndex - 1) || stepIndex === 0) {\n if (stepHasSubsteps(stepIndex)) {\n if (substepIndex <= 0) {\n activeSubstepIndex.value = 0;\n } else if (isStepCompleted(stepIndex, substepIndex - 1)) {\n activeSubstepIndex.value = substepIndex;\n }\n }\n activeStepIndex.value = stepIndex;\n }\n } else {\n activeStepIndex.value = stepIndex;\n\n if (stepHasSubsteps(stepIndex)) {\n if (substepIndex < 0) {\n activeSubstepIndex.value = 0;\n } else {\n activeSubstepIndex.value = substepIndex;\n }\n }\n }\n }\n\n /**\n * Returns true if the step is completed.\n * if the substep index is provided, check if the substep is completed.\n */\n function isStepCompleted(stepIndex: number, substepIndex = -1): boolean {\n if (substepIndex >= 0) {\n return steps.value[stepIndex]?.substeps[substepIndex]?.completed;\n } else {\n return steps.value[stepIndex]?.completed;\n }\n }\n\n /**\n * Returns true if the step is active.\n * if the substep index is provided, check both if the step and the substep are active.\n */\n function isStepActive(stepIndex: number, substepIndex = -1): boolean {\n if (substepIndex >= 0) {\n return activeStepIndex.value === stepIndex && activeSubstepIndex.value === substepIndex;\n } else {\n return activeStepIndex.value === stepIndex;\n }\n }\n\n /**\n * Registers a new step or substep into the steps array\n */\n function registerStep(nested = false): void {\n if (nested && !steps.value.length) {\n throw new Error('Cannot register a substep without a parent step.');\n }\n\n if (nested) {\n steps.value[steps.value.length - 1].substeps.push({ completed: false });\n } else {\n steps.value.push({ completed: false, substeps: [] });\n }\n }\n\n return {\n steps: readonly(steps),\n stepCount,\n activeStepElement,\n activeStepIndex,\n activeSubstepIndex,\n registerStep,\n next,\n back,\n goTo,\n isStepActive,\n isStepCompleted,\n };\n}\n"],"names":["useStepper","options","steps","ref","stepCount","computed","activeStepIndex","activeSubstepIndex","stepElements","_b","_a","activeStepElement","stepHasSubsteps","stepIndex","next","hasNoActiveStep","isLastStep","hasNoActiveSubstep","isLastSubstep","back","goTo","substepIndex","isStepCompleted","_c","isStepActive","registerStep","nested","readonly"],"mappings":";AA8BA,SAAwBA,EACtBC,IAA0B;AAAA,EACxB,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,OAAO,CAAA;AACT,GACA;AAKA,QAAMC,IAAQC,EAA2BF,EAAQ,QAAQA,EAAQ,QAAQ,EAAE,GAErEG,IAAYC,EAAS,MAAMH,EAAM,MAAM,MAAM,GAE7CI,IAAkBH;AAAA,IACtBF,EAAQ,eAAe,QAAQA,EAAQ,eAAe,SAAYA,EAAQ,aAAa;AAAA,EACzF,GACMM,IAAqBJ;AAAA,IACzBF,EAAQ,kBAAkB,QAAQA,EAAQ,kBAAkB,SAAYA,EAAQ,gBAAgB;AAAA,EAClG,GAEMO,IAAeH,EAAS,MAAM;;AAClC,WAAO,MAAM,OAAMI,KAAAC,IAAAT,EAAQ,QAAR,gBAAAS,EAAa,UAAb,gBAAAD,EAAoB,aAAY,EAAsC;AAAA,EAAA,CAC1F,GAEKE,IAAoBN,EAAS,MAAMG,EAAa,MAAMF,EAAgB,KAAK,CAAC;AAMlF,WAASM,EAAgBC,GAA4B;AACnD,WAAO,CAAC,CAACX,EAAM,MAAMW,CAAS,EAAE,SAAS;AAAA,EAAA;AAQ3C,WAASC,IAAa;AACd,UAAAC,IAAkBT,EAAgB,UAAU,IAC5CU,IAAaV,EAAgB,UAAUJ,EAAM,MAAM,SAAS;AAGlE,Q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kDAAkD;AAGpE,IAAIwB,IACIxB,EAAA,MAAMA,EAAM,MAAM,SAAS,CAAC,EAAE,SAAS,KAAK,EAAE,WAAW,GAAA,CAAO,IAEhEA,EAAA,MAAM,KAAK,EAAE,WAAW,IAAO,UAAU,CAAA,GAAI;AAAA,EACrD;AAGK,SAAA;AAAA,IACL,OAAOyB,EAASzB,CAAK;AAAA,IACrB,WAAAE;AAAA,IACA,mBAAAO;AAAA,IACA,iBAAAL;AAAA,IACA,oBAAAC;AAAA,IACA,cAAAkB;AAAA,IACA,MAAAX;AAAA,IACA,MAAAK;AAAA,IACA,MAAAC;AAAA,IACA,cAAAI;AAAA,IACA,iBAAAF;AAAA,EACF;AACF;"}
|
|
1
|
+
{"version":3,"file":"useStepper.js","sources":["../src/composables/useStepper/useStepper.ts"],"sourcesContent":["import { computed, readonly, Ref, ref } from 'vue';\n\nexport interface StepDefinition {\n completed: boolean;\n substeps: Array<Omit<StepDefinition, 'substeps'>>;\n}\n\nexport interface StepperOptions {\n /**\n * If true, the stepper will prevent skipping steps\n */\n linear?: boolean;\n /**\n * The index of the active step\n */\n activeStep?: number;\n /**\n * The index of the active substep\n */\n activeSubstep?: number;\n /**\n * The stepper representation as an array of steps and substeps\n */\n steps?: Array<StepDefinition>;\n /**\n * A ref to the stepper element\n */\n ref?: Ref<HTMLUListElement | null>;\n}\n\nexport default function useStepper(\n options: StepperOptions = {\n linear: false,\n activeStep: -1,\n activeSubstep: -1,\n steps: [],\n },\n) {\n /**\n * The steps and substeps of the stepper, so we can keep track of their state.\n * Can be populated with the `steps` option, or via the `registerStep` function.\n */\n const steps = ref<Array<StepDefinition>>(options.steps ? options.steps : []);\n\n const stepCount = computed(() => steps.value.length);\n\n const activeStepIndex = ref(\n options.activeStep !== null && options.activeStep !== undefined ? options.activeStep : -1,\n );\n const activeSubstepIndex = ref(\n options.activeSubstep !== null && options.activeSubstep !== undefined ? options.activeSubstep : -1,\n );\n\n const stepElements = computed(() => {\n return Array.from((options.ref?.value?.children || []) as HTMLCollectionOf<HTMLLIElement>);\n });\n\n const activeStepElement = computed(() => stepElements.value[activeStepIndex.value]);\n\n /**\n * Returns true if the step at the given index has substeps\n * @param stepIndex The index of the step to check\n */\n function stepHasSubsteps(stepIndex: number): boolean {\n return !!steps.value[stepIndex].substeps.length;\n }\n\n /**\n * Goes to the next step or substep, while flagging the current one as completed.\n * If the current step has substeps, it will go to the next substep if there are any, or to the next substep.\n * And if the next step has substeps, automatically goes to the first substep\n */\n function next(): void {\n const hasNoActiveStep = activeStepIndex.value === -1;\n const isLastStep = activeStepIndex.value === steps.value.length - 1;\n\n // If there is no active step, we want to activate the first step\n if (hasNoActiveStep) {\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep\n if (stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value++;\n }\n } else if (isLastStep) {\n if (stepHasSubsteps(activeStepIndex.value)) {\n const hasNoActiveSubstep = activeSubstepIndex.value === -1;\n const isLastSubstep = activeSubstepIndex.value === steps.value[activeStepIndex.value].substeps.length - 1;\n\n // if there are no active substeps, we want to activate the first substep\n if (hasNoActiveSubstep) {\n activeSubstepIndex.value++;\n // if the active substep is the last one, we want to reset the step and substep to -1\n } else if (isLastSubstep) {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value = -1;\n\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value = -1;\n // if there are more substeps, we want to complete the current one and proceed to the next substep\n } else {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value++;\n }\n // If there are no substeps, we want to complete the current step and reset the step to -1\n } else {\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value = -1;\n }\n } else {\n if (stepHasSubsteps(activeStepIndex.value)) {\n const hasNoActiveSubstep = activeSubstepIndex.value === -1;\n const isLastSubstep = activeSubstepIndex.value === steps.value[activeStepIndex.value].substeps.length - 1;\n\n // if there are no active substeps, we want to activate the first substep\n if (hasNoActiveSubstep) {\n activeSubstepIndex.value++;\n // if the active substep is the last one, we want to go to the next step\n } else if (isLastSubstep) {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value = -1;\n\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep right away\n if (stepHasSubsteps(activeStepIndex.value) && activeSubstepIndex.value === -1) {\n activeSubstepIndex.value++;\n }\n // if there are more substeps, we want to complete the current one and proceed to the next substep\n } else {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value++;\n }\n } else {\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep right away\n if (stepHasSubsteps(activeStepIndex.value) && activeSubstepIndex.value === -1) {\n activeSubstepIndex.value++;\n }\n }\n }\n }\n\n function back(): void {\n // We don't want to go back if there is no active step\n if (activeStepIndex.value === -1) {\n return;\n }\n\n if (stepHasSubsteps(activeStepIndex.value)) {\n // If the active substep is the first one, we want to go back to the previous step\n if (activeSubstepIndex.value === 0) {\n activeStepIndex.value--;\n activeSubstepIndex.value--;\n\n // If the step that we just navigated to has substeps, we want to navigate to the last substep\n if (activeStepIndex.value >= 0 && stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value = steps.value[activeStepIndex.value].substeps.length - 1;\n }\n } else {\n activeSubstepIndex.value--;\n }\n } else {\n activeStepIndex.value--;\n\n // If the step that we just navigated to has substeps, we want to navigate to the last substep\n if (activeStepIndex.value >= 0 && stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value = steps.value[activeStepIndex.value].substeps.length - 1;\n }\n }\n }\n\n /**\n * Navigates to a specific step and substep.\n */\n function goTo(stepIndex: number, substepIndex = -1): void {\n // A linear stepper prevents navigation to incomplete steps\n if (options.linear) {\n if (isStepCompleted(stepIndex - 1) || stepIndex === 0) {\n if (stepHasSubsteps(stepIndex)) {\n if (substepIndex <= 0) {\n activeSubstepIndex.value = 0;\n } else if (isStepCompleted(stepIndex, substepIndex - 1)) {\n activeSubstepIndex.value = substepIndex;\n }\n }\n activeStepIndex.value = stepIndex;\n }\n } else {\n activeStepIndex.value = stepIndex;\n\n if (stepHasSubsteps(stepIndex)) {\n if (substepIndex < 0) {\n activeSubstepIndex.value = 0;\n } else {\n activeSubstepIndex.value = substepIndex;\n }\n }\n }\n }\n\n /**\n * Returns true if the step is completed.\n * if the substep index is provided, check if the substep is completed.\n */\n function isStepCompleted(stepIndex: number, substepIndex = -1): boolean {\n if (substepIndex >= 0) {\n return steps.value[stepIndex]?.substeps[substepIndex]?.completed;\n } else {\n return steps.value[stepIndex]?.completed;\n }\n }\n\n /**\n * Returns true if the step is active.\n * if the substep index is provided, check both if the step and the substep are active.\n */\n function isStepActive(stepIndex: number, substepIndex = -1): boolean {\n if (substepIndex >= 0) {\n return activeStepIndex.value === stepIndex && activeSubstepIndex.value === substepIndex;\n } else {\n return activeStepIndex.value === stepIndex;\n }\n }\n\n /**\n * Registers a new step or substep into the steps array\n */\n function registerStep(nested = false): void {\n if (nested && !steps.value.length) {\n throw new Error('Cannot register a substep without a parent step.');\n }\n\n if (nested) {\n steps.value[steps.value.length - 1].substeps.push({ completed: false });\n } else {\n steps.value.push({ completed: false, substeps: [] });\n }\n }\n\n return {\n steps: readonly(steps),\n stepCount,\n activeStepElement,\n activeStepIndex,\n activeSubstepIndex,\n registerStep,\n next,\n back,\n goTo,\n isStepActive,\n isStepCompleted,\n };\n}\n"],"names":["useStepper","options","steps","ref","stepCount","computed","activeStepIndex","activeSubstepIndex","stepElements","activeStepElement","stepHasSubsteps","stepIndex","next","hasNoActiveStep","isLastStep","hasNoActiveSubstep","isLastSubstep","back","goTo","substepIndex","isStepCompleted","isStepActive","registerStep","nested","readonly"],"mappings":";AA8BA,SAAwBA,EACtBC,IAA0B;AAAA,EACxB,QAAQ;AAAA,EACR,YAAY;AAA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h, reactive as y, readonly as b } from "vue";
|
|
4
4
|
const w = 5e3, n = h([]);
|
|
5
|
-
function M(
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
if (!
|
|
5
|
+
function M(c = { timeout: w }) {
|
|
6
|
+
function s(o) {
|
|
7
|
+
const e = typeof o == "string" ? o : void 0, { group: i = void 0, status: t = void 0 } = typeof o == "object" ? o : {};
|
|
8
|
+
if (!e && (!i || !t))
|
|
9
9
|
throw new Error("Must provide either a toast ID or both group and type");
|
|
10
|
-
const r = i && t ? `toast-${t}-${i}` : String(
|
|
10
|
+
const r = i && t ? `toast-${t}-${i}` : String(e), f = n.value.findIndex(({ id: g }) => g === r);
|
|
11
11
|
f !== -1 && n.value.splice(f, 1);
|
|
12
12
|
}
|
|
13
|
-
function u(
|
|
14
|
-
const t = l({},
|
|
15
|
-
if (!(t
|
|
13
|
+
function u(o, e, i) {
|
|
14
|
+
const t = l({}, c, i), r = t?.group ? `toast-${e}-${t.group}` : T("toast-");
|
|
15
|
+
if (!(t?.group && n.value.some(({ id: f }) => f === r)))
|
|
16
16
|
return n.value.push({
|
|
17
|
-
text:
|
|
17
|
+
text: o,
|
|
18
18
|
id: r,
|
|
19
|
-
status:
|
|
19
|
+
status: e,
|
|
20
20
|
offsetTop: t.offsetTop
|
|
21
|
-
}), typeof t.timeout == "number" && setTimeout(() =>
|
|
21
|
+
}), typeof t.timeout == "number" && setTimeout(() => s(r), Math.abs(t.timeout)), r;
|
|
22
22
|
}
|
|
23
23
|
function a() {
|
|
24
24
|
n.value = [];
|
|
25
25
|
}
|
|
26
|
-
function m(
|
|
27
|
-
return u(
|
|
26
|
+
function m(o, e) {
|
|
27
|
+
return u(o, "error", e);
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
return u(
|
|
29
|
+
function p(o, e) {
|
|
30
|
+
return u(o, "info", e);
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
return u(
|
|
32
|
+
function v(o, e) {
|
|
33
|
+
return u(o, "success", e);
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
return u(
|
|
35
|
+
function d(o, e) {
|
|
36
|
+
return u(o, "warning", e);
|
|
37
37
|
}
|
|
38
38
|
return y({
|
|
39
39
|
/**
|
|
@@ -43,7 +43,7 @@ function M(s = { timeout: w }) {
|
|
|
43
43
|
/**
|
|
44
44
|
* Removes an active/visible toast by id or by group and type.
|
|
45
45
|
*/
|
|
46
|
-
remove:
|
|
46
|
+
remove: s,
|
|
47
47
|
/**
|
|
48
48
|
* Creates a new toast and makes it active/visible.
|
|
49
49
|
*/
|
|
@@ -59,15 +59,15 @@ function M(s = { timeout: w }) {
|
|
|
59
59
|
/**
|
|
60
60
|
* Creates a new "info" toast.
|
|
61
61
|
*/
|
|
62
|
-
info:
|
|
62
|
+
info: p,
|
|
63
63
|
/**
|
|
64
64
|
* Creates a new "success" toast.
|
|
65
65
|
*/
|
|
66
|
-
success:
|
|
66
|
+
success: v,
|
|
67
67
|
/**
|
|
68
68
|
* Creates a new "warning" toast.
|
|
69
69
|
*/
|
|
70
|
-
warning:
|
|
70
|
+
warning: d
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
export {
|
package/dist/useToasts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useToasts.js","sources":["../src/composables/useToasts/useToasts.ts"],"sourcesContent":["import merge from 'lodash-es/merge';\nimport uniqueId from 'lodash-es/uniqueId';\nimport { reactive, readonly, ref, RenderFunction } from 'vue';\n\nimport { StatusSeverity } from '../../../types/statusLevels';\n\nexport const DEFAULT_TIMEOUT = 5000;\n\nexport type Toast = {\n id: string;\n text: string | RenderFunction;\n status: StatusSeverity;\n offsetTop?: string;\n};\n\nexport interface ToastOptions {\n /**\n * The timeout in milliseconds before the toast is automatically dismissed. If set to `false`, the toast will persist until the user clicks on it.\n * @default DEFAULT_TIMEOUT\n */\n timeout?: number | boolean;\n /**\n * A group name ensures only one toast with the same group and status is visible at any given time.\n * Toasts with the same group but different statuses will be treated as separate and will display concurrently.\n */\n group?: string;\n /**\n * The container distance from the top of the viewport.\n */\n offsetTop?: string;\n}\n\ntype ToastIdOrUndefined<O extends ToastOptions | undefined> = O extends { id: string }\n ? Toast['id'] | undefined\n : Toast['id'];\n\nconst active = ref<Toast[]>([]);\n\nexport default function useToasts(globalOptions: Omit<ToastOptions, 'group'> = { timeout: DEFAULT_TIMEOUT }) {\n // method overloads\n function remove(toastId: Toast['id']): void;\n function remove(options: { group: string; status: StatusSeverity }): void;\n function remove(toastIdOrOptions: Toast['id'] | { group: string; status: StatusSeverity }) {\n const toastId = typeof toastIdOrOptions === 'string' ? toastIdOrOptions : undefined;\n const { group = undefined, status = undefined } = typeof toastIdOrOptions === 'object' ? toastIdOrOptions : {};\n\n if (!toastId && (!group || !status)) {\n throw new Error('Must provide either a toast ID or both group and type');\n }\n\n const idToRemove = group && status ? `toast-${status}-${group}` : String(toastId);\n const index = active.value.findIndex(({ id }) => id === idToRemove);\n if (index === -1) {\n return;\n }\n\n active.value.splice(index, 1);\n }\n\n // method overloads\n function create(text: Toast['text'], status: StatusSeverity, options?: Omit<ToastOptions, 'group'>): Toast['id'];\n function create(\n text: Toast['text'],\n status: StatusSeverity,\n options: ToastOptions & { id: string },\n ): Toast['id'] | undefined;\n function create(text: Toast['text'], status: StatusSeverity, localOptions?: ToastOptions): Toast['id'] | undefined {\n const options = merge({}, globalOptions, localOptions);\n\n const id = options?.group ? `toast-${status}-${options.group}` : uniqueId('toast-');\n if (options?.group && active.value.some(({ id: existingId }) => existingId === id)) {\n return;\n }\n\n active.value.push({\n text,\n id,\n status,\n offsetTop: options.offsetTop,\n });\n\n if (typeof options.timeout === 'number') {\n setTimeout(() => remove(id), Math.abs(options.timeout));\n }\n\n return id;\n }\n\n function removeAll() {\n active.value = [];\n }\n\n function error<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'error', options);\n }\n\n function info<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'info', options);\n }\n\n function success<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'success', options);\n }\n\n function warning<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'warning', options);\n }\n\n return reactive({\n /**\n * The list of toasts that are currently visible.\n */\n active: readonly(active),\n\n /**\n * Removes an active/visible toast by id or by group and type.\n */\n remove,\n\n /**\n * Creates a new toast and makes it active/visible.\n */\n create,\n\n /**\n * Removes all active/visible toasts.\n */\n removeAll,\n\n /**\n * Creates a new \"error\" toast.\n */\n error,\n\n /**\n * Creates a new \"info\" toast.\n */\n info,\n\n /**\n * Creates a new \"success\" toast.\n */\n success,\n\n /**\n * Creates a new \"warning\" toast.\n */\n warning,\n });\n}\n"],"names":["DEFAULT_TIMEOUT","active","ref","useToasts","globalOptions","remove","toastIdOrOptions","toastId","group","status","idToRemove","index","id","create","text","localOptions","options","merge","uniqueId","existingId","removeAll","error","info","success","warning","reactive","readonly"],"mappings":";;;AAMO,MAAMA,IAAkB,KA8BzBC,IAASC,EAAa,EAAE;AAE9B,SAAwBC,EAAUC,IAA6C,EAAE,SAASJ,KAAmB;AAI3G,WAASK,EAAOC,GAA2E;AACzF,UAAMC,IAAU,OAAOD,KAAqB,WAAWA,IAAmB,QACpE,EAAE,OAAAE,IAAQ,QAAW,QAAAC,IAAS,
|
|
1
|
+
{"version":3,"file":"useToasts.js","sources":["../src/composables/useToasts/useToasts.ts"],"sourcesContent":["import merge from 'lodash-es/merge';\nimport uniqueId from 'lodash-es/uniqueId';\nimport { reactive, readonly, ref, RenderFunction } from 'vue';\n\nimport { StatusSeverity } from '../../../types/statusLevels';\n\nexport const DEFAULT_TIMEOUT = 5000;\n\nexport type Toast = {\n id: string;\n text: string | RenderFunction;\n status: StatusSeverity;\n offsetTop?: string;\n};\n\nexport interface ToastOptions {\n /**\n * The timeout in milliseconds before the toast is automatically dismissed. If set to `false`, the toast will persist until the user clicks on it.\n * @default DEFAULT_TIMEOUT\n */\n timeout?: number | boolean;\n /**\n * A group name ensures only one toast with the same group and status is visible at any given time.\n * Toasts with the same group but different statuses will be treated as separate and will display concurrently.\n */\n group?: string;\n /**\n * The container distance from the top of the viewport.\n */\n offsetTop?: string;\n}\n\ntype ToastIdOrUndefined<O extends ToastOptions | undefined> = O extends { id: string }\n ? Toast['id'] | undefined\n : Toast['id'];\n\nconst active = ref<Toast[]>([]);\n\nexport default function useToasts(globalOptions: Omit<ToastOptions, 'group'> = { timeout: DEFAULT_TIMEOUT }) {\n // method overloads\n function remove(toastId: Toast['id']): void;\n function remove(options: { group: string; status: StatusSeverity }): void;\n function remove(toastIdOrOptions: Toast['id'] | { group: string; status: StatusSeverity }) {\n const toastId = typeof toastIdOrOptions === 'string' ? toastIdOrOptions : undefined;\n const { group = undefined, status = undefined } = typeof toastIdOrOptions === 'object' ? toastIdOrOptions : {};\n\n if (!toastId && (!group || !status)) {\n throw new Error('Must provide either a toast ID or both group and type');\n }\n\n const idToRemove = group && status ? `toast-${status}-${group}` : String(toastId);\n const index = active.value.findIndex(({ id }) => id === idToRemove);\n if (index === -1) {\n return;\n }\n\n active.value.splice(index, 1);\n }\n\n // method overloads\n function create(text: Toast['text'], status: StatusSeverity, options?: Omit<ToastOptions, 'group'>): Toast['id'];\n function create(\n text: Toast['text'],\n status: StatusSeverity,\n options: ToastOptions & { id: string },\n ): Toast['id'] | undefined;\n function create(text: Toast['text'], status: StatusSeverity, localOptions?: ToastOptions): Toast['id'] | undefined {\n const options = merge({}, globalOptions, localOptions);\n\n const id = options?.group ? `toast-${status}-${options.group}` : uniqueId('toast-');\n if (options?.group && active.value.some(({ id: existingId }) => existingId === id)) {\n return;\n }\n\n active.value.push({\n text,\n id,\n status,\n offsetTop: options.offsetTop,\n });\n\n if (typeof options.timeout === 'number') {\n setTimeout(() => remove(id), Math.abs(options.timeout));\n }\n\n return id;\n }\n\n function removeAll() {\n active.value = [];\n }\n\n function error<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'error', options);\n }\n\n function info<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'info', options);\n }\n\n function success<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'success', options);\n }\n\n function warning<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'warning', options);\n }\n\n return reactive({\n /**\n * The list of toasts that are currently visible.\n */\n active: readonly(active),\n\n /**\n * Removes an active/visible toast by id or by group and type.\n */\n remove,\n\n /**\n * Creates a new toast and makes it active/visible.\n */\n create,\n\n /**\n * Removes all active/visible toasts.\n */\n removeAll,\n\n /**\n * Creates a new \"error\" toast.\n */\n error,\n\n /**\n * Creates a new \"info\" toast.\n */\n info,\n\n /**\n * Creates a new \"success\" toast.\n */\n success,\n\n /**\n * Creates a new \"warning\" toast.\n */\n warning,\n });\n}\n"],"names":["DEFAULT_TIMEOUT","active","ref","useToasts","globalOptions","remove","toastIdOrOptions","toastId","group","status","idToRemove","index","id","create","text","localOptions","options","merge","uniqueId","existingId","removeAll","error","info","success","warning","reactive","readonly"],"mappings":";;;AAMO,MAAMA,IAAkB,KA8BzBC,IAASC,EAAa,EAAE;AAE9B,SAAwBC,EAAUC,IAA6C,EAAE,SAASJ,KAAmB;AAI3G,WAASK,EAAOC,GAA2E;AACzF,UAAMC,IAAU,OAAOD,KAAqB,WAAWA,IAAmB,QACpE,EAAE,OAAAE,IAAQ,QAAW,QAAAC,IAAS,OAAA,IAAc,OAAOH,KAAqB,WAAWA,IAAmB,CAAA;AAE5G,QAAI,CAACC,MAAY,CAACC,KAAS,CAACC;AAC1B,YAAM,IAAI,MAAM,uDAAuD;AAGzE,UAAMC,IAAaF,KAASC,IAAS,SAASA,CAAM,IAAID,CAAK,KAAK,OAAOD,CAAO,GAC1EI,IAAQV,EAAO,MAAM,UAAU,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AO;AAAA;AAAA;AAAA;AAAA,IAKA,OAAAC;AAAA;AAAA;AAAA;AAAA,IAKA,MAAAC;AAAA;AAAA;AAAA;AAAA,IAKA,SAAAC;AAAA;AAAA;AAAA;AAAA,IAKA,SAAAC;AAAA,EAAA,CACD;AACH;"}
|
package/dist/useValidation.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
import O from "lodash-es/debounce";
|
|
2
|
-
import
|
|
3
|
-
import { toValue as u, computed as c, ref as
|
|
4
|
-
import { DECIMAL_PRECISION as
|
|
2
|
+
import E from "lodash-es/get";
|
|
3
|
+
import { toValue as u, computed as c, ref as V, watch as F, reactive as I, nextTick as w, readonly as S } from "vue";
|
|
4
|
+
import { DECIMAL_PRECISION as L, DEBOUNCE as A } from "./constants.js";
|
|
5
5
|
import { t as f } from "./locale.js";
|
|
6
6
|
import { i as l } from "./isDefined-DzVx0B6k.js";
|
|
7
|
-
import
|
|
8
|
-
function
|
|
7
|
+
import q from "lodash-es/round";
|
|
8
|
+
function D(e) {
|
|
9
9
|
return e && e.constructor && typeof e.constructor.isBuffer == "function" && e.constructor.isBuffer(e);
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function j(e) {
|
|
12
12
|
return e;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function C(e, t) {
|
|
15
15
|
t = t || {};
|
|
16
|
-
const i = t.delimiter || ".",
|
|
17
|
-
function v
|
|
18
|
-
g = g || 1, Object.keys(
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
21
|
-
return
|
|
22
|
-
m[d] =
|
|
16
|
+
const i = t.delimiter || ".", s = t.maxDepth, a = t.transformKey || j, m = {};
|
|
17
|
+
function h(v, y, g) {
|
|
18
|
+
g = g || 1, Object.keys(v).forEach(function(p) {
|
|
19
|
+
const n = v[p], N = t.safe && Array.isArray(n), r = Object.prototype.toString.call(n), o = D(n), b = r === "[object Object]" || r === "[object Array]", d = y ? y + i + a(p) : a(p);
|
|
20
|
+
if (!N && !o && b && Object.keys(n).length && (!t.maxDepth || g < s))
|
|
21
|
+
return h(n, d, g + 1);
|
|
22
|
+
m[d] = n;
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
return
|
|
25
|
+
return h(e), m;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function P(e = {}) {
|
|
28
28
|
return {
|
|
29
29
|
name: "email",
|
|
30
30
|
validator(t) {
|
|
@@ -33,20 +33,20 @@ function Y(e = {}) {
|
|
|
33
33
|
message: e.message || f("ll.validation.email")
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function Y(e) {
|
|
37
37
|
return {
|
|
38
38
|
name: "maxLength",
|
|
39
39
|
validator(t) {
|
|
40
|
-
const i = u(e.max),
|
|
41
|
-
if (!l(
|
|
40
|
+
const i = u(e.max), s = u(t);
|
|
41
|
+
if (!l(s))
|
|
42
42
|
return !0;
|
|
43
|
-
let
|
|
44
|
-
return e.trim && (
|
|
43
|
+
let a = String(s);
|
|
44
|
+
return e.trim && (a = a.trim()), a.length <= i;
|
|
45
45
|
},
|
|
46
46
|
message: e.message || (() => f("ll.validation.maxLength", { max: String(u(e.max)) }))
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function _(e) {
|
|
50
50
|
return {
|
|
51
51
|
name: "maxValue",
|
|
52
52
|
validator(t) {
|
|
@@ -56,20 +56,20 @@ function z(e) {
|
|
|
56
56
|
message: e.message || (() => f("ll.validation.maxValue", { max: String(u(e.max)) }))
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function z(e) {
|
|
60
60
|
return {
|
|
61
61
|
name: "minLength",
|
|
62
62
|
validator(t) {
|
|
63
|
-
const i = u(e.min),
|
|
64
|
-
if (!l(
|
|
63
|
+
const i = u(e.min), s = u(t);
|
|
64
|
+
if (!l(s))
|
|
65
65
|
return !0;
|
|
66
|
-
let
|
|
67
|
-
return e.trim && (
|
|
66
|
+
let a = String(s);
|
|
67
|
+
return e.trim && (a = a.trim()), a.length >= i;
|
|
68
68
|
},
|
|
69
69
|
message: e.message || (() => f("ll.validation.minLength", { min: String(u(e.min)) }))
|
|
70
70
|
};
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function G(e) {
|
|
73
73
|
return {
|
|
74
74
|
name: "minValue",
|
|
75
75
|
validator(t) {
|
|
@@ -79,7 +79,7 @@ function H(e) {
|
|
|
79
79
|
message: e.message || (() => f("ll.validation.minValue", { min: String(u(e.min)) }))
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function H(e) {
|
|
83
83
|
return {
|
|
84
84
|
name: "pattern",
|
|
85
85
|
validator(t) {
|
|
@@ -95,7 +95,7 @@ function J(e) {
|
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98
|
-
function
|
|
98
|
+
function J(e = {}) {
|
|
99
99
|
return {
|
|
100
100
|
name: "positiveNumber",
|
|
101
101
|
validator(t) {
|
|
@@ -104,17 +104,17 @@ function Q(e = {}) {
|
|
|
104
104
|
message: e.message || f("ll.validation.positiveNumber")
|
|
105
105
|
};
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function Q(e = {}) {
|
|
108
108
|
return {
|
|
109
109
|
name: "price",
|
|
110
110
|
validator(t) {
|
|
111
111
|
const i = Number(t);
|
|
112
|
-
return !l(t) || i !== 1 / 0 && i >= 0 && i ===
|
|
112
|
+
return !l(t) || i !== 1 / 0 && i >= 0 && i === q(i, L.CURRENCY);
|
|
113
113
|
},
|
|
114
114
|
message: e.message || f("ll.validation.price")
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function X(e = {}) {
|
|
118
118
|
return {
|
|
119
119
|
name: "required",
|
|
120
120
|
validator(t) {
|
|
@@ -123,7 +123,7 @@ function Z(e = {}) {
|
|
|
123
123
|
message: e.message || f("ll.validation.required")
|
|
124
124
|
};
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function Z(e = {}) {
|
|
127
127
|
return {
|
|
128
128
|
name: "wholeNumber",
|
|
129
129
|
validator(t) {
|
|
@@ -136,97 +136,93 @@ function ee({
|
|
|
136
136
|
rules: e,
|
|
137
137
|
values: t
|
|
138
138
|
}) {
|
|
139
|
-
const
|
|
140
|
-
(
|
|
141
|
-
const b =
|
|
142
|
-
b.value =
|
|
143
|
-
},
|
|
144
|
-
d(
|
|
145
|
-
},
|
|
146
|
-
return
|
|
147
|
-
() =>
|
|
139
|
+
const s = c(() => Object.keys(C(e, { safe: !0 }))).value.reduce(
|
|
140
|
+
(r, o) => {
|
|
141
|
+
const b = V(E(u(t), o)), d = (T) => {
|
|
142
|
+
b.value = E(u(t), T);
|
|
143
|
+
}, x = O(() => {
|
|
144
|
+
d(o);
|
|
145
|
+
}, A.FAST);
|
|
146
|
+
return F(
|
|
147
|
+
() => E(u(t), o),
|
|
148
148
|
() => {
|
|
149
|
-
|
|
149
|
+
x();
|
|
150
150
|
}
|
|
151
|
-
),
|
|
152
|
-
fieldName:
|
|
151
|
+
), r[o] = B({
|
|
152
|
+
fieldName: o,
|
|
153
153
|
fieldValue: b,
|
|
154
154
|
flush: () => {
|
|
155
|
-
|
|
155
|
+
x.cancel(), d(o);
|
|
156
156
|
},
|
|
157
|
-
rules:
|
|
158
|
-
}),
|
|
157
|
+
rules: E(e, o)
|
|
158
|
+
}), r;
|
|
159
159
|
},
|
|
160
160
|
{}
|
|
161
|
-
),
|
|
161
|
+
), a = c(() => Object.values(s)), m = c(() => a.value.some((r) => r.errors.length > 0)), h = c(() => a.value.some((r) => r.isTouched)), v = c(() => a.value.filter((r) => r.isDirty));
|
|
162
162
|
return I({
|
|
163
|
-
validate: async function({ preventScroll:
|
|
164
|
-
if (
|
|
165
|
-
|
|
166
|
-
}), await w(), m.value && !
|
|
167
|
-
const
|
|
163
|
+
validate: async function({ preventScroll: r } = {}) {
|
|
164
|
+
if (a.value.forEach((o) => {
|
|
165
|
+
o.setTouched(!1), o.setTouched(!0);
|
|
166
|
+
}), await w(), m.value && !r) {
|
|
167
|
+
const b = Object.entries(s).find(([, x]) => x.errorMessage)?.[0] || "", d = document?.querySelector(`[name=${b}]`);
|
|
168
168
|
d && d.scrollIntoView({ behavior: "smooth" });
|
|
169
169
|
}
|
|
170
170
|
return !m.value;
|
|
171
171
|
},
|
|
172
|
-
getError: function(
|
|
173
|
-
|
|
174
|
-
return ((a = o[n]) == null ? void 0 : a.errorMessage) || "";
|
|
172
|
+
getError: function(r) {
|
|
173
|
+
return s[r]?.errorMessage || "";
|
|
175
174
|
},
|
|
176
|
-
touch: function(
|
|
177
|
-
if (!
|
|
178
|
-
throw new Error(`In touch: fieldName "${
|
|
179
|
-
|
|
175
|
+
touch: function(r) {
|
|
176
|
+
if (!s[r])
|
|
177
|
+
throw new Error(`In touch: fieldName "${r}" does not exist in the validation fields.`);
|
|
178
|
+
s[r].setTouched();
|
|
180
179
|
},
|
|
181
180
|
setAllUntouched: async function() {
|
|
182
|
-
await w(),
|
|
183
|
-
|
|
181
|
+
await w(), a.value.forEach((r) => {
|
|
182
|
+
r.setTouched(!1);
|
|
184
183
|
});
|
|
185
184
|
},
|
|
186
|
-
setInitialValues: function(
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
setInitialValues: function(r) {
|
|
186
|
+
a.value.forEach((o) => {
|
|
187
|
+
o.setInitialValue(r[o.name]);
|
|
189
188
|
});
|
|
190
189
|
},
|
|
191
|
-
fields:
|
|
192
|
-
dirtyFields:
|
|
190
|
+
fields: s,
|
|
191
|
+
dirtyFields: v,
|
|
193
192
|
hasErrors: m,
|
|
194
|
-
someTouched:
|
|
193
|
+
someTouched: h
|
|
195
194
|
});
|
|
196
195
|
}
|
|
197
196
|
function B({
|
|
198
197
|
fieldName: e,
|
|
199
198
|
fieldValue: t,
|
|
200
199
|
rules: i,
|
|
201
|
-
flush:
|
|
200
|
+
flush: s
|
|
202
201
|
}) {
|
|
203
|
-
const
|
|
202
|
+
const a = V(t.value), m = V(!1), h = c(() => (t.value ?? "") !== (a.value ?? "")), v = c(() => m.value ? i.map((n) => ({
|
|
204
203
|
fieldName: e,
|
|
205
|
-
ruleName:
|
|
206
|
-
isValid:
|
|
207
|
-
message: typeof
|
|
204
|
+
ruleName: n.name,
|
|
205
|
+
isValid: n.validator(t.value),
|
|
206
|
+
message: typeof n.message == "function" ? n.message(t.value) : n.message
|
|
208
207
|
})) : []), y = c(
|
|
209
|
-
() =>
|
|
210
|
-
ruleName:
|
|
211
|
-
message:
|
|
208
|
+
() => v.value.filter((n) => !n.isValid).map((n) => ({
|
|
209
|
+
ruleName: n.ruleName,
|
|
210
|
+
message: n.message
|
|
212
211
|
}))
|
|
213
212
|
);
|
|
214
|
-
function g(
|
|
215
|
-
|
|
213
|
+
function g(n = !0) {
|
|
214
|
+
s(), m.value = n;
|
|
216
215
|
}
|
|
217
|
-
function p(
|
|
218
|
-
|
|
216
|
+
function p(n) {
|
|
217
|
+
a.value = n;
|
|
219
218
|
}
|
|
220
219
|
return I({
|
|
221
220
|
name: e,
|
|
222
|
-
currentValue:
|
|
223
|
-
initialValue:
|
|
224
|
-
isTouched:
|
|
225
|
-
isDirty:
|
|
226
|
-
errorMessage: c(() =>
|
|
227
|
-
var r, x;
|
|
228
|
-
return ((x = (r = y.value) == null ? void 0 : r[0]) == null ? void 0 : x.message) || "";
|
|
229
|
-
}),
|
|
221
|
+
currentValue: S(t),
|
|
222
|
+
initialValue: S(a),
|
|
223
|
+
isTouched: S(m),
|
|
224
|
+
isDirty: S(h),
|
|
225
|
+
errorMessage: c(() => y.value?.[0]?.message || ""),
|
|
230
226
|
errors: y,
|
|
231
227
|
setInitialValue: p,
|
|
232
228
|
setTouched: g
|
|
@@ -234,16 +230,16 @@ function B({
|
|
|
234
230
|
}
|
|
235
231
|
export {
|
|
236
232
|
ee as default,
|
|
237
|
-
|
|
233
|
+
P as email,
|
|
238
234
|
l as isDefined,
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
235
|
+
Y as maxLength,
|
|
236
|
+
_ as maxValue,
|
|
237
|
+
z as minLength,
|
|
238
|
+
G as minValue,
|
|
239
|
+
H as pattern,
|
|
240
|
+
J as positiveNumber,
|
|
241
|
+
Q as price,
|
|
242
|
+
X as required,
|
|
243
|
+
Z as wholeNumber
|
|
248
244
|
};
|
|
249
245
|
//# sourceMappingURL=useValidation.js.map
|