@propelinc/citrus-ui 0.6.0 → 1.0.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/README.md +54 -60
- package/dist/colors/colors.d.ts +31 -0
- package/dist/colors/theme.d.ts +2 -11
- package/dist/colors/util-classes.d.ts +11 -0
- package/dist/components/CAccordion.vue.d.ts +21 -0
- package/dist/components/CAccordionItem.vue.d.ts +41 -0
- package/dist/components/CAppBar.vue.d.ts +156 -0
- package/dist/components/CBadge.vue.d.ts +52 -0
- package/dist/components/CBottomSheet.vue.d.ts +226 -0
- package/dist/components/CButton/CButton.vue.d.ts +231 -0
- package/dist/components/CButton/types.d.ts +5 -0
- package/dist/components/CButtonStack.vue.d.ts +24 -0
- package/dist/components/CCard.vue.d.ts +107 -0
- package/dist/components/CCardFooter.vue.d.ts +26 -0
- package/dist/components/CCardHeader.vue.d.ts +3 -0
- package/dist/components/CCardSection.vue.d.ts +17 -0
- package/dist/components/CCheckbox.vue.d.ts +145 -0
- package/dist/components/CCol.vue.d.ts +21 -0
- package/dist/components/CDivider.vue.d.ts +17 -0
- package/dist/components/CDobField.vue.d.ts +2109 -0
- package/dist/components/CDobSelect.vue.d.ts +398 -0
- package/dist/components/CEmailField.vue.d.ts +699 -0
- package/dist/components/CExpandTransition.vue.d.ts +19 -0
- package/dist/components/CFadeTransition.vue.d.ts +3 -0
- package/dist/components/CFileInput.vue.d.ts +98 -0
- package/dist/components/CFixedPageFooter.vue.d.ts +106 -0
- package/dist/components/CForm.vue.d.ts +29 -0
- package/dist/components/CFormFieldCounter.vue.d.ts +42 -0
- package/dist/components/CIconButton.vue.d.ts +390 -0
- package/dist/components/CLabel.vue.d.ts +32 -0
- package/dist/components/CListItem.vue.d.ts +208 -0
- package/dist/components/CListItemContent.vue.d.ts +27 -0
- package/dist/components/CListItemIcon.vue.d.ts +54 -0
- package/dist/components/CLoader.vue.d.ts +73 -0
- package/dist/components/CLogo.vue.d.ts +19 -0
- package/dist/components/CMaskedTextField.vue.d.ts +2012 -0
- package/dist/components/CMenu.vue.d.ts +6 -0
- package/dist/components/CMenuItem.vue.d.ts +170 -0
- package/dist/components/CMenuLabel.vue.d.ts +3 -0
- package/dist/components/CModal.vue.d.ts +206 -0
- package/dist/components/CModalLoading.vue.d.ts +230 -0
- package/dist/components/CNotification.vue.d.ts +589 -0
- package/dist/components/CPhoneField.vue.d.ts +2088 -0
- package/dist/components/CPill.vue.d.ts +42 -0
- package/dist/components/CPillGroup.vue.d.ts +70 -0
- package/dist/components/CPopup.vue.d.ts +21 -0
- package/dist/components/CProgressLinear.vue.d.ts +61 -0
- package/dist/components/CProgressRing.vue.d.ts +103 -0
- package/dist/components/CRadio.vue.d.ts +73 -0
- package/dist/components/CRadioGroup.vue.d.ts +123 -0
- package/dist/components/CRebrand.vue.d.ts +28 -0
- package/dist/components/CRow.vue.d.ts +67 -0
- package/dist/components/CSafeArea.vue.d.ts +18 -0
- package/dist/components/CSectionHeader.vue.d.ts +28 -0
- package/dist/components/CSelect.vue.d.ts +293 -0
- package/dist/components/CSkeleton.vue.d.ts +3 -0
- package/dist/components/CSkeletonLoaderCard.vue.d.ts +21 -0
- package/dist/components/CSkeletonLoaderCircle.vue.d.ts +5 -0
- package/dist/components/CSkeletonLoaderText.vue.d.ts +44 -0
- package/dist/components/CSlideFadeTransition.vue.d.ts +58 -0
- package/dist/components/CSplitInput.vue.d.ts +2131 -0
- package/dist/components/CSquaredIcon.vue.d.ts +47 -0
- package/dist/components/CSsnField.vue.d.ts +2083 -0
- package/dist/components/CStatusDot.vue.d.ts +27 -0
- package/dist/components/CSwitch.vue.d.ts +54 -0
- package/dist/components/CSwitchListItem.vue.d.ts +392 -0
- package/dist/components/CTextArea.vue.d.ts +240 -0
- package/dist/components/CTextField.vue.d.ts +647 -0
- package/dist/components/CTextLink.vue.d.ts +55 -0
- package/dist/components/CThirdPartyLogo.vue.d.ts +128 -0
- package/dist/components/CTimeago.vue.d.ts +12 -0
- package/dist/components/CToast.vue.d.ts +458 -0
- package/dist/components/CToastsList.vue.d.ts +430 -0
- package/dist/components/CValidationMessage.vue.d.ts +45 -0
- package/dist/components/CZipcodeField.vue.d.ts +2080 -0
- package/dist/components/index.d.ts +66 -25
- package/dist/components/internal/CCloseButton.vue.d.ts +14 -0
- package/dist/composables/accessibility.d.ts +1 -0
- package/dist/composables/animation.d.ts +12 -0
- package/dist/composables/binding.d.ts +19 -0
- package/dist/composables/colors.d.ts +13 -0
- package/dist/composables/elements.d.ts +3 -0
- package/dist/composables/fields.d.ts +9 -0
- package/dist/composables/gestures.d.ts +53 -0
- package/dist/composables/i18n.d.ts +3 -0
- package/dist/composables/id.d.ts +11 -0
- package/dist/composables/input-mask.d.ts +18 -0
- package/dist/composables/router.d.ts +30 -0
- package/dist/composables/slots.d.ts +2 -0
- package/dist/composables/toast.d.ts +21 -0
- package/dist/composables/validations.d.ts +77 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +5 -4
- package/dist/index.mjs +11738 -0
- package/dist/index.mjs.map +1 -0
- package/dist/plugin.d.ts +2 -2
- package/dist/services/animation.d.ts +17 -0
- package/dist/services/directives/index.d.ts +2 -0
- package/dist/services/directives/scroll-into-view.d.ts +7 -0
- package/dist/services/directives/tap-animation.d.ts +6 -0
- package/dist/services/id.d.ts +22 -0
- package/dist/services/injections/accordions.d.ts +3 -0
- package/dist/services/injections/animations.d.ts +2 -0
- package/dist/services/injections/buttons.d.ts +4 -0
- package/dist/services/injections/forms.d.ts +6 -0
- package/dist/services/injections/icon-buttons.d.ts +3 -0
- package/dist/services/injections/pills.d.ts +4 -0
- package/dist/services/injections/radio.d.ts +10 -0
- package/dist/styles/main.css +3002 -0
- package/dist/styles/utils.css +2319 -0
- package/dist/theme/icons.d.ts +35 -2
- package/dist/types/CForm.d.ts +12 -0
- package/dist/types/font-awesome.d.ts +5 -0
- package/dist/types.d.ts +12 -0
- package/index.ts +2 -0
- package/package.json +60 -45
- package/src/assets/fonts/grenette-regular.woff2 +0 -0
- package/src/assets/fonts/grenette-semibold.woff2 +0 -0
- package/src/assets/fonts/polymath.woff2 +0 -0
- package/src/assets/logos/propel/icon.svg +15 -0
- package/src/assets/logos/propel/lockup.svg +11 -0
- package/src/colors/colors.ts +173 -0
- package/src/colors/theme.ts +8 -14
- package/src/colors/util-classes.ts +49 -0
- package/src/componentResolver.js +33 -0
- package/src/components/CAccordion.vue +32 -7
- package/src/components/CAccordionItem.vue +109 -36
- package/src/components/CAppBar.vue +237 -0
- package/src/components/CBadge.vue +74 -0
- package/src/components/CBottomSheet.vue +430 -0
- package/src/components/CButton/CButton.vue +347 -0
- package/src/components/CButton/types.ts +5 -0
- package/src/components/CButtonStack.vue +36 -0
- package/src/components/CCard.vue +149 -41
- package/src/components/CCardFooter.vue +11 -27
- package/src/components/CCardHeader.vue +30 -21
- package/src/components/CCardSection.vue +23 -12
- package/src/components/CCheckbox.vue +191 -21
- package/src/components/CCol.vue +55 -0
- package/src/components/CDivider.vue +46 -0
- package/src/components/CDobField.vue +153 -0
- package/src/components/CDobSelect.vue +274 -0
- package/src/components/CEmailField.vue +61 -0
- package/src/components/CExpandTransition.vue +55 -0
- package/src/components/CFadeTransition.vue +23 -0
- package/src/components/CFileInput.vue +186 -0
- package/src/components/CFixedPageFooter.vue +76 -0
- package/src/components/CForm.vue +86 -0
- package/src/components/CFormFieldCounter.vue +40 -0
- package/src/components/CIconButton.vue +175 -59
- package/src/components/CLabel.vue +52 -0
- package/src/components/CListItem.vue +149 -45
- package/src/components/CListItemContent.vue +60 -0
- package/src/components/CListItemIcon.vue +27 -31
- package/src/components/CLoader.vue +156 -0
- package/src/components/CLogo.vue +23 -0
- package/src/components/CMaskedTextField.vue +118 -0
- package/src/components/CMenu.vue +24 -0
- package/src/components/CMenuItem.vue +106 -0
- package/src/components/CMenuLabel.vue +26 -0
- package/src/components/CModal.vue +198 -79
- package/src/components/CModalLoading.vue +27 -9
- package/src/components/CNotification.vue +86 -53
- package/src/components/CPhoneField.vue +69 -0
- package/src/components/CPill.vue +162 -0
- package/src/components/CPillGroup.vue +73 -0
- package/src/components/CPopup.vue +66 -0
- package/src/components/CProgressLinear.vue +52 -0
- package/src/components/CProgressRing.vue +126 -0
- package/src/components/CRadio.vue +138 -0
- package/src/components/CRadioGroup.vue +142 -0
- package/src/components/CRebrand.vue +28 -0
- package/src/components/CRow.vue +62 -0
- package/src/components/CSafeArea.vue +23 -0
- package/src/components/CSectionHeader.vue +50 -0
- package/src/components/CSelect.vue +223 -74
- package/src/components/CSkeleton.vue +65 -0
- package/src/components/CSkeletonLoaderCard.vue +29 -0
- package/src/components/CSkeletonLoaderCircle.vue +18 -14
- package/src/components/CSkeletonLoaderText.vue +127 -17
- package/src/components/CSlideFadeTransition.vue +100 -0
- package/src/components/CSplitInput.vue +111 -0
- package/src/components/CSquaredIcon.vue +83 -0
- package/src/components/CSsnField.vue +86 -0
- package/src/components/CStatusDot.vue +70 -0
- package/src/components/CSwitch.vue +125 -0
- package/src/components/CSwitchListItem.vue +110 -0
- package/src/components/CTextArea.vue +193 -47
- package/src/components/CTextField.vue +450 -93
- package/src/components/CTextLink.vue +48 -38
- package/src/components/CThirdPartyLogo.vue +127 -0
- package/src/components/CTimeago.vue +63 -0
- package/src/components/CToast.vue +259 -0
- package/src/components/CToastsList.vue +32 -0
- package/src/components/CValidationMessage.vue +70 -0
- package/src/components/CZipcodeField.vue +69 -0
- package/src/components/index.ts +66 -25
- package/src/components/internal/CCloseButton.vue +57 -0
- package/src/composables/accessibility.ts +29 -0
- package/src/composables/animation.ts +95 -0
- package/src/composables/binding.ts +34 -0
- package/src/composables/colors.ts +59 -0
- package/src/composables/elements.ts +72 -0
- package/src/composables/fields.ts +19 -0
- package/src/composables/gestures.ts +197 -0
- package/src/composables/i18n.ts +13 -0
- package/src/composables/id.ts +23 -0
- package/src/composables/input-mask.ts +139 -0
- package/src/composables/router.ts +64 -0
- package/src/composables/slots.ts +57 -0
- package/src/composables/toast.ts +64 -0
- package/src/composables/validations.ts +214 -0
- package/src/index.ts +7 -7
- package/src/plugin.ts +13 -6
- package/src/services/animation.ts +101 -0
- package/src/services/directives/index.ts +2 -0
- package/src/services/directives/scroll-into-view.ts +86 -0
- package/src/services/directives/tap-animation.ts +71 -0
- package/src/services/id.ts +31 -0
- package/src/services/injections/accordions.ts +4 -0
- package/src/services/injections/animations.ts +3 -0
- package/src/services/injections/buttons.ts +5 -0
- package/src/services/injections/forms.ts +8 -0
- package/src/services/injections/icon-buttons.ts +4 -0
- package/src/services/injections/pills.ts +7 -0
- package/src/services/injections/radio.ts +12 -0
- package/src/shims-vue.d.ts +6 -3
- package/src/styles/_animation.scss +19 -0
- package/src/styles/_button.scss +61 -0
- package/src/styles/_colors.scss +58 -11
- package/src/styles/_core.scss +248 -87
- package/src/styles/_form-fields.scss +68 -15
- package/src/styles/_grenette.scss +13 -0
- package/src/styles/_polymath.scss +14 -0
- package/src/styles/_reset.scss +105 -0
- package/src/styles/_shoelace.scss +46 -0
- package/src/styles/_typography.scss +40 -10
- package/src/styles/main.scss +6 -3
- package/src/styles/utils/a11y.scss +18 -0
- package/src/styles/utils/typography.scss +13 -0
- package/src/styles/utils.scss +560 -0
- package/src/styles/variables.scss +27 -15
- package/src/theme/icons.ts +16 -5
- package/src/types/CForm.ts +15 -0
- package/src/types/font-awesome.ts +6 -0
- package/src/types.ts +15 -0
- package/.browserslistrc +0 -3
- package/.eslintrc.js +0 -4
- package/.stylelintrc.js +0 -3
- package/babel.config.js +0 -3
- package/dist/citrus-ui.common.js +0 -43434
- package/dist/citrus-ui.common.js.map +0 -1
- package/dist/citrus-ui.css +0 -1
- package/dist/citrus-ui.umd.js +0 -43444
- package/dist/citrus-ui.umd.js.map +0 -1
- package/dist/citrus-ui.umd.min.js +0 -27
- package/dist/citrus-ui.umd.min.js.map +0 -1
- package/dist/demo.html +0 -10
- package/dist/fonts/Blitz-Script.85ed9abe.woff2 +0 -0
- package/dist/fonts/ObjectSans-Bold.5492f3d5.woff2 +0 -0
- package/dist/fonts/ObjectSans-BoldSlanted.29e2a87e.woff2 +0 -0
- package/dist/fonts/ObjectSans-Heavy.d0b2f035.woff2 +0 -0
- package/dist/fonts/ObjectSans-HeavySlanted.45e9c063.woff2 +0 -0
- package/dist/fonts/ObjectSans-Light.f885dec3.woff2 +0 -0
- package/dist/fonts/ObjectSans-LightSlanted.b8eb7c12.woff2 +0 -0
- package/dist/fonts/ObjectSans-Regular.e4ea0b90.woff2 +0 -0
- package/dist/fonts/ObjectSans-Slanted.57a90be9.woff2 +0 -0
- package/dist/fonts/ObjectSans-Thin.86d44227.woff2 +0 -0
- package/dist/fonts/ObjectSans-ThinSlanted.20342160.woff2 +0 -0
- package/jest.config.js +0 -9
- package/plopfile.js +0 -67
- package/project.json +0 -69
- package/src/assets/fonts/Blitz-Script.woff2 +0 -0
- package/src/assets/fonts/ObjectSans-Bold.woff2 +0 -0
- package/src/assets/fonts/ObjectSans-BoldSlanted.woff2 +0 -0
- package/src/assets/fonts/ObjectSans-Heavy.woff2 +0 -0
- package/src/assets/fonts/ObjectSans-HeavySlanted.woff2 +0 -0
- package/src/assets/fonts/ObjectSans-Light.woff2 +0 -0
- package/src/assets/fonts/ObjectSans-LightSlanted.woff2 +0 -0
- package/src/assets/fonts/ObjectSans-Regular.woff2 +0 -0
- package/src/assets/fonts/ObjectSans-Slanted.woff2 +0 -0
- package/src/assets/fonts/ObjectSans-Thin.woff2 +0 -0
- package/src/assets/fonts/ObjectSans-ThinSlanted.woff2 +0 -0
- package/src/components/CAlert.vue +0 -78
- package/src/components/CBanner.vue +0 -47
- package/src/components/CButton.vue +0 -146
- package/src/components/CListItemAction.vue +0 -29
- package/src/components/CSegmentedButton.vue +0 -47
- package/src/components/CSegmentedButtonOption.vue +0 -42
- package/src/components/helpers/FormField.vue +0 -48
- package/src/components/helpers/SelectInput.vue +0 -115
- package/src/shims-scss.d.ts +0 -4
- package/src/shims-vuetify.d.ts +0 -4
- package/src/styles/_blitz.scss +0 -8
- package/src/styles/_object-sans.scss +0 -23
- package/storybook-static/0.799c368cbe88266827ba.manager.bundle.js +0 -1
- package/storybook-static/0.a9f0a9ad.iframe.bundle.js +0 -3
- package/storybook-static/0.a9f0a9ad.iframe.bundle.js.LICENSE.txt +0 -8
- package/storybook-static/0.a9f0a9ad.iframe.bundle.js.map +0 -1
- package/storybook-static/1.0438fd8d.iframe.bundle.js +0 -3
- package/storybook-static/1.0438fd8d.iframe.bundle.js.LICENSE.txt +0 -17
- package/storybook-static/1.0438fd8d.iframe.bundle.js.map +0 -1
- package/storybook-static/1.9ebd2fb519f6726108de.manager.bundle.js +0 -1
- package/storybook-static/10.348d8814.iframe.bundle.js +0 -3
- package/storybook-static/10.348d8814.iframe.bundle.js.LICENSE.txt +0 -30
- package/storybook-static/10.348d8814.iframe.bundle.js.map +0 -1
- package/storybook-static/10.a85ea1a67689be8e19ff.manager.bundle.js +0 -1
- package/storybook-static/11.f4e922583ae35da460f3.manager.bundle.js +0 -2
- package/storybook-static/11.f4e922583ae35da460f3.manager.bundle.js.LICENSE.txt +0 -12
- package/storybook-static/12.1415460941f0bdcb8fa8.manager.bundle.js +0 -1
- package/storybook-static/2.75a17459.iframe.bundle.js +0 -3
- package/storybook-static/2.75a17459.iframe.bundle.js.LICENSE.txt +0 -26
- package/storybook-static/2.75a17459.iframe.bundle.js.map +0 -1
- package/storybook-static/5.f459d151315e6780c20f.manager.bundle.js +0 -2
- package/storybook-static/5.f459d151315e6780c20f.manager.bundle.js.LICENSE.txt +0 -8
- package/storybook-static/6.3bd64d820f3745f262ff.manager.bundle.js +0 -1
- package/storybook-static/6.ce8d99b4.iframe.bundle.js +0 -1
- package/storybook-static/7.3d04765dbf3f1dcd706c.manager.bundle.js +0 -1
- package/storybook-static/7.6633a922.iframe.bundle.js +0 -3
- package/storybook-static/7.6633a922.iframe.bundle.js.LICENSE.txt +0 -12
- package/storybook-static/7.6633a922.iframe.bundle.js.map +0 -1
- package/storybook-static/8.b541eadfcb9164835dfc.manager.bundle.js +0 -1
- package/storybook-static/8.fc5e1ebf.iframe.bundle.js +0 -1
- package/storybook-static/9.411ac8e451bbb10926c7.manager.bundle.js +0 -1
- package/storybook-static/9.724ac3ed.iframe.bundle.js +0 -3
- package/storybook-static/9.724ac3ed.iframe.bundle.js.LICENSE.txt +0 -15
- package/storybook-static/9.724ac3ed.iframe.bundle.js.map +0 -1
- package/storybook-static/css/main.95216119.css +0 -1
- package/storybook-static/css/vendors~main.02dc89bf.css +0 -1
- package/storybook-static/favicon.ico +0 -0
- package/storybook-static/fonts/Blitz-Script.85ed9abe.woff2 +0 -0
- package/storybook-static/fonts/ObjectSans-Bold.5492f3d5.woff2 +0 -0
- package/storybook-static/fonts/ObjectSans-BoldSlanted.29e2a87e.woff2 +0 -0
- package/storybook-static/fonts/ObjectSans-Heavy.d0b2f035.woff2 +0 -0
- package/storybook-static/fonts/ObjectSans-HeavySlanted.45e9c063.woff2 +0 -0
- package/storybook-static/fonts/ObjectSans-Light.f885dec3.woff2 +0 -0
- package/storybook-static/fonts/ObjectSans-LightSlanted.b8eb7c12.woff2 +0 -0
- package/storybook-static/fonts/ObjectSans-Regular.e4ea0b90.woff2 +0 -0
- package/storybook-static/fonts/ObjectSans-Slanted.57a90be9.woff2 +0 -0
- package/storybook-static/fonts/ObjectSans-Thin.86d44227.woff2 +0 -0
- package/storybook-static/fonts/ObjectSans-ThinSlanted.20342160.woff2 +0 -0
- package/storybook-static/iframe.html +0 -348
- package/storybook-static/index.html +0 -51
- package/storybook-static/main.7b4aec9c4352d4bb535b.manager.bundle.js +0 -1
- package/storybook-static/main.9e8c64c7.iframe.bundle.js +0 -1
- package/storybook-static/runtime~main.91a0c7330ab317d35c4a.manager.bundle.js +0 -1
- package/storybook-static/runtime~main.e4da100f.iframe.bundle.js +0 -1
- package/storybook-static/vendors~main.6660eda6.iframe.bundle.js +0 -7
- package/storybook-static/vendors~main.6660eda6.iframe.bundle.js.LICENSE.txt +0 -80
- package/storybook-static/vendors~main.6660eda6.iframe.bundle.js.map +0 -1
- package/storybook-static/vendors~main.f7f16cebbf3aa96a4f89.manager.bundle.js +0 -2
- package/storybook-static/vendors~main.f7f16cebbf3aa96a4f89.manager.bundle.js.LICENSE.txt +0 -110
- package/tsconfig.dist.json +0 -7
- package/tsconfig.json +0 -24
- package/vue.config.js +0 -5
|
@@ -1,115 +1,472 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
<div
|
|
3
|
+
class="c-text-field"
|
|
4
|
+
:class="[
|
|
5
|
+
{
|
|
6
|
+
'c-text-field--disabled': disabled,
|
|
7
|
+
'c-text-field--invalid': !isValidationValid,
|
|
8
|
+
'c-text-field--hide-label': hideLabel,
|
|
9
|
+
'c-text-field--focused': isFocused,
|
|
10
|
+
'c-text-field--medium': size === 'medium',
|
|
11
|
+
'c-text-field--large': size === 'large',
|
|
12
|
+
},
|
|
13
|
+
$attrs.class,
|
|
14
|
+
]"
|
|
15
|
+
:data-test="dataTest"
|
|
16
|
+
:style="rootStyles"
|
|
17
|
+
>
|
|
18
|
+
<label class="c-text-field__label" :for="idWithFallback" :data-test="`${dataTest}-label`">
|
|
19
|
+
<slot name="label">
|
|
20
|
+
{{ label }}
|
|
21
|
+
</slot>
|
|
22
|
+
</label>
|
|
23
|
+
|
|
24
|
+
<div class="c-text-field__container">
|
|
25
|
+
<div
|
|
26
|
+
v-if="prefixSlotHasContent"
|
|
27
|
+
class="c-text-field__prefix"
|
|
28
|
+
:data-test="`${dataTest}-prefix`"
|
|
29
|
+
>
|
|
30
|
+
<slot name="prepend-inner" />
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<input
|
|
34
|
+
v-bind="fallthroughAttrs"
|
|
35
|
+
:id="idWithFallback"
|
|
36
|
+
ref="input"
|
|
37
|
+
class="c-text-field__input"
|
|
38
|
+
:class="{
|
|
39
|
+
'c-text-field__input--has-prefix': prefixSlotHasContent,
|
|
40
|
+
'c-text-field__input--has-suffix': suffixSlotHasContent,
|
|
41
|
+
'c-text-field__input--clearable': clearable && value,
|
|
42
|
+
'c-text-field__input--hideable': hideable,
|
|
43
|
+
}"
|
|
44
|
+
:data-test="`${dataTest}-input`"
|
|
45
|
+
:aria-label="ariaLabel || label || undefined"
|
|
46
|
+
:aria-describedby="`${idWithFallback}-validation-message ${idWithFallback}-message`"
|
|
47
|
+
:aria-invalid="isValidationValid ? 'false' : 'true'"
|
|
48
|
+
:type="inputType"
|
|
49
|
+
:placeholder="placeholder"
|
|
50
|
+
:minlength="minlength"
|
|
51
|
+
:maxlength="maxlength"
|
|
52
|
+
:disabled="disabled"
|
|
53
|
+
:value="inputValue"
|
|
54
|
+
:inputmode="inputmode"
|
|
55
|
+
:required="required"
|
|
56
|
+
@keyup="$emit('keyup', $event)"
|
|
57
|
+
@keydown="$emit('keydown', $event)"
|
|
58
|
+
@keypress="$emit('keypress', $event)"
|
|
59
|
+
@click="$emit('click', $event)"
|
|
60
|
+
@input="onInput"
|
|
61
|
+
@change="onChange"
|
|
62
|
+
@focus="onFocus"
|
|
63
|
+
@blur="onBlur"
|
|
64
|
+
/>
|
|
65
|
+
|
|
66
|
+
<CIconButton
|
|
67
|
+
v-if="clearable && value"
|
|
68
|
+
:aria-label="$t('Clear')"
|
|
69
|
+
:data-test="`${dataTest}-clear`"
|
|
70
|
+
class="c-text-field__clear-btn c-text-field__suffix-btn"
|
|
71
|
+
type="button"
|
|
72
|
+
tertiary
|
|
73
|
+
:icon="faXmark"
|
|
74
|
+
@click="clearInput"
|
|
75
|
+
/>
|
|
76
|
+
|
|
77
|
+
<CIconButton
|
|
78
|
+
v-if="hideable"
|
|
79
|
+
:aria-label="hideToggleAriaLabel"
|
|
80
|
+
:data-test="`${dataTest}-hide-toggle`"
|
|
81
|
+
:data-hidden="inputHidden || undefined"
|
|
82
|
+
class="c-text-field__suffix-btn"
|
|
83
|
+
type="button"
|
|
84
|
+
tertiary
|
|
85
|
+
:icon="inputHidden ? faEye : faEyeSlash"
|
|
86
|
+
@click="toggleHidden"
|
|
87
|
+
/>
|
|
88
|
+
|
|
89
|
+
<div
|
|
90
|
+
v-if="suffixSlotHasContent"
|
|
91
|
+
class="c-text-field__suffix"
|
|
92
|
+
:data-test="`${dataTest}-suffix`"
|
|
93
|
+
>
|
|
94
|
+
<slot name="append" />
|
|
95
|
+
</div>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<CValidationMessage
|
|
99
|
+
:id="`${idWithFallback}-validation-message`"
|
|
100
|
+
class="c-text-field__validation-message"
|
|
101
|
+
:data-test="`${dataTest}-validation-message`"
|
|
102
|
+
:validation-message="errorMessage || validationMessage"
|
|
103
|
+
:hide="hideDetails"
|
|
27
104
|
>
|
|
28
105
|
<template #append>
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<font-awesome-icon v-if="hideInput" :icon="faEye" />
|
|
37
|
-
<font-awesome-icon v-else :icon="faEyeSlash" />
|
|
38
|
-
</button>
|
|
39
|
-
</slot>
|
|
40
|
-
</template>
|
|
41
|
-
<template #message>
|
|
42
|
-
<slot name="message" />
|
|
106
|
+
<CFormFieldCounter
|
|
107
|
+
v-if="counter"
|
|
108
|
+
:data-test="`${dataTest}-counter`"
|
|
109
|
+
:counter="counter"
|
|
110
|
+
:counter-value="counterValue !== null ? counterValue : undefined"
|
|
111
|
+
:value="inputValue"
|
|
112
|
+
/>
|
|
43
113
|
</template>
|
|
44
|
-
</
|
|
45
|
-
|
|
114
|
+
</CValidationMessage>
|
|
115
|
+
|
|
116
|
+
<div
|
|
117
|
+
v-if="messageSlotHasContent"
|
|
118
|
+
:id="`${idWithFallback}-message`"
|
|
119
|
+
class="c-text-field__message"
|
|
120
|
+
:data-test="`${dataTest}-message`"
|
|
121
|
+
>
|
|
122
|
+
<slot name="message" />
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
46
125
|
</template>
|
|
47
126
|
|
|
48
127
|
<script lang="ts">
|
|
49
|
-
import { faEye, faEyeSlash } from '@fortawesome/pro-
|
|
50
|
-
import {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
128
|
+
import { faEye, faEyeSlash, faXmark } from '@fortawesome/pro-regular-svg-icons';
|
|
129
|
+
import {
|
|
130
|
+
type PropType,
|
|
131
|
+
type Ref,
|
|
132
|
+
type StyleValue,
|
|
133
|
+
computed,
|
|
134
|
+
defineComponent,
|
|
135
|
+
onMounted,
|
|
136
|
+
ref,
|
|
137
|
+
toRefs,
|
|
138
|
+
} from 'vue';
|
|
139
|
+
|
|
140
|
+
import CFormFieldCounter from '@propelinc/citrus-ui/src/components/CFormFieldCounter.vue';
|
|
141
|
+
import CIconButton from '@propelinc/citrus-ui/src/components/CIconButton.vue';
|
|
142
|
+
import CValidationMessage from '@propelinc/citrus-ui/src/components/CValidationMessage.vue';
|
|
143
|
+
import { useInternalValue } from '@propelinc/citrus-ui/src/composables/binding';
|
|
144
|
+
import { useTranslation } from '@propelinc/citrus-ui/src/composables/i18n';
|
|
145
|
+
import { useId } from '@propelinc/citrus-ui/src/composables/id';
|
|
146
|
+
import { useSlotHasContent } from '@propelinc/citrus-ui/src/composables/slots';
|
|
147
|
+
import type { Rules } from '@propelinc/citrus-ui/src/composables/validations';
|
|
148
|
+
import { useValidations } from '@propelinc/citrus-ui/src/composables/validations';
|
|
149
|
+
|
|
150
|
+
// Export the interface for what this component exposes
|
|
151
|
+
export interface CTextFieldExposed {
|
|
152
|
+
input: Ref<HTMLInputElement | null>;
|
|
153
|
+
focus: () => void;
|
|
154
|
+
blur: () => void;
|
|
155
|
+
startValidating: () => void;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export default defineComponent({
|
|
159
|
+
name: 'CTextField',
|
|
160
|
+
components: { CFormFieldCounter, CIconButton, CValidationMessage },
|
|
161
|
+
inheritAttrs: false,
|
|
162
|
+
props: {
|
|
163
|
+
id: { type: String as PropType<string | null>, default: null },
|
|
164
|
+
label: { type: String as PropType<string | null>, default: null },
|
|
165
|
+
ariaLabel: { type: String as PropType<string | null>, default: null },
|
|
166
|
+
placeholder: { type: String, default: '' },
|
|
167
|
+
type: {
|
|
168
|
+
type: String as PropType<
|
|
169
|
+
'text' | 'password' | 'email' | 'tel' | 'url' | 'search' | 'number' | 'decimal' | 'numeric'
|
|
170
|
+
>,
|
|
171
|
+
default: 'text',
|
|
172
|
+
},
|
|
173
|
+
clearable: { type: Boolean, default: false },
|
|
174
|
+
size: { type: String as PropType<'medium' | 'large'>, default: 'medium' },
|
|
175
|
+
inputmode: {
|
|
176
|
+
type: String as PropType<
|
|
177
|
+
'text' | 'search' | 'none' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal'
|
|
178
|
+
>,
|
|
179
|
+
default: undefined,
|
|
180
|
+
},
|
|
181
|
+
minlength: { type: [Number, String], default: undefined },
|
|
182
|
+
maxlength: { type: [Number, String], default: undefined },
|
|
183
|
+
disabled: { type: Boolean, default: false },
|
|
184
|
+
hideable: { type: Boolean, default: false },
|
|
185
|
+
hideLabel: { type: Boolean, default: false },
|
|
186
|
+
hideDetails: { type: [Boolean, String] as PropType<boolean | 'auto'>, default: false },
|
|
187
|
+
value: { type: String, default: '' },
|
|
188
|
+
dataTest: { type: String, default: 'text-field' },
|
|
189
|
+
counter: { type: Number as PropType<number | null>, default: null },
|
|
190
|
+
counterValue: {
|
|
191
|
+
type: [Number, Function] as PropType<number | (() => number | null)>,
|
|
192
|
+
default: null,
|
|
193
|
+
},
|
|
194
|
+
rules: { type: Array as PropType<Rules<string>>, default: () => [] },
|
|
195
|
+
validateOnBlur: { type: Boolean, default: true },
|
|
196
|
+
required: { type: Boolean, default: false },
|
|
197
|
+
/**
|
|
198
|
+
* Overrides the default validation message. If provided, this error message will always
|
|
199
|
+
* be shown, regardless of any other failing validation rules.
|
|
200
|
+
*/
|
|
201
|
+
errorMessage: { type: String, default: null },
|
|
202
|
+
},
|
|
203
|
+
emits: [
|
|
204
|
+
'keyup',
|
|
205
|
+
'keydown',
|
|
206
|
+
'keypress',
|
|
207
|
+
'input',
|
|
208
|
+
'focus',
|
|
209
|
+
'blur',
|
|
210
|
+
'change',
|
|
211
|
+
'click',
|
|
212
|
+
'click:hide',
|
|
213
|
+
],
|
|
214
|
+
setup(props, { attrs, emit, slots, expose }) {
|
|
215
|
+
const { t } = useTranslation();
|
|
216
|
+
|
|
217
|
+
const isFocused = ref(false);
|
|
218
|
+
const inputHidden = ref(true);
|
|
219
|
+
const inputType = computed(() =>
|
|
220
|
+
props.hideable && inputHidden.value ? 'password' : props.type
|
|
221
|
+
);
|
|
222
|
+
const hideToggleAriaLabel = computed(() => {
|
|
223
|
+
return props.hideable && inputHidden.value ? t('Show input value') : t('Hide input value');
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const { id, value, rules, required } = toRefs(props);
|
|
227
|
+
|
|
228
|
+
const idWithFallback = useId(id);
|
|
229
|
+
|
|
230
|
+
const inputValue = useInternalValue(value, {
|
|
231
|
+
onChange: (newValue) => {
|
|
232
|
+
emit('input', newValue);
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
const input: Ref<HTMLInputElement | null> = ref(null);
|
|
237
|
+
const {
|
|
238
|
+
message: validationMessage,
|
|
239
|
+
valid: isValidationValid,
|
|
240
|
+
listeners: validationListeners,
|
|
241
|
+
startValidating,
|
|
242
|
+
} = useValidations({
|
|
243
|
+
id: idWithFallback,
|
|
244
|
+
value: inputValue,
|
|
245
|
+
rules,
|
|
246
|
+
required,
|
|
247
|
+
validateOn: computed(() => (props.validateOnBlur ? 'blur' : 'input')),
|
|
248
|
+
field: input,
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
const prefixSlotHasContent = useSlotHasContent('prepend-inner');
|
|
252
|
+
const suffixSlotHasContent = useSlotHasContent('append');
|
|
253
|
+
const messageSlotHasContent = useSlotHasContent('message');
|
|
254
|
+
|
|
255
|
+
const toggleHidden = (): void => {
|
|
256
|
+
inputHidden.value = !inputHidden.value;
|
|
257
|
+
emit('click:hide', inputHidden.value);
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
const onInput = (event: Event): void => {
|
|
261
|
+
const target = event.target as HTMLInputElement;
|
|
262
|
+
if (target.value !== inputValue.value) {
|
|
263
|
+
inputValue.value = target.value;
|
|
264
|
+
validationListeners.input(event);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
const onChange = (event: Event): void => {
|
|
269
|
+
validationListeners.change(event);
|
|
270
|
+
const target = event.target as HTMLInputElement;
|
|
271
|
+
emit('change', target.value);
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
const onFocus = (event: Event): void => {
|
|
275
|
+
isFocused.value = true;
|
|
276
|
+
emit('focus', event);
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const onBlur = (event: Event): void => {
|
|
280
|
+
isFocused.value = false;
|
|
281
|
+
validationListeners.blur(event);
|
|
282
|
+
emit('blur', event);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const clearInput = (): void => {
|
|
286
|
+
emit('input', '');
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
const focus = (): void => {
|
|
290
|
+
input.value?.focus();
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
const blur = (): void => {
|
|
294
|
+
input.value?.blur();
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
onMounted(() => {
|
|
298
|
+
if (!props.label && !slots.label && !props.ariaLabel) {
|
|
299
|
+
console.error(
|
|
300
|
+
'Missing CTextField label. Please provide a label prop, an ariaLabel prop or pass a label via the label slot.'
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
const exposedAPI: CTextFieldExposed = { input, focus, blur, startValidating };
|
|
306
|
+
expose(exposedAPI);
|
|
307
|
+
|
|
308
|
+
const fallthroughAttrs = computed(() => {
|
|
309
|
+
const { class: _, style: __, ...rest } = attrs;
|
|
310
|
+
return rest;
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
// Need to compute these to cast the type to avoid type errors
|
|
314
|
+
const rootStyles = computed(() => attrs.style as StyleValue);
|
|
315
|
+
|
|
316
|
+
return {
|
|
317
|
+
faXmark,
|
|
318
|
+
faEye,
|
|
319
|
+
faEyeSlash,
|
|
320
|
+
|
|
321
|
+
fallthroughAttrs,
|
|
322
|
+
hideToggleAriaLabel,
|
|
323
|
+
idWithFallback,
|
|
324
|
+
input,
|
|
325
|
+
inputHidden,
|
|
326
|
+
inputType,
|
|
327
|
+
inputValue,
|
|
328
|
+
isFocused,
|
|
329
|
+
messageSlotHasContent,
|
|
330
|
+
prefixSlotHasContent,
|
|
331
|
+
rootStyles,
|
|
332
|
+
suffixSlotHasContent,
|
|
333
|
+
isValidationValid,
|
|
334
|
+
validationMessage,
|
|
335
|
+
|
|
336
|
+
clearInput,
|
|
337
|
+
onBlur,
|
|
338
|
+
onChange,
|
|
339
|
+
onFocus,
|
|
340
|
+
onInput,
|
|
341
|
+
toggleHidden,
|
|
342
|
+
};
|
|
343
|
+
},
|
|
344
|
+
});
|
|
345
|
+
</script>
|
|
346
|
+
|
|
347
|
+
<style lang="scss" scoped>
|
|
348
|
+
@import '@propelinc/citrus-ui/src/styles/core';
|
|
349
|
+
@import '@propelinc/citrus-ui/src/styles/utils/a11y';
|
|
350
|
+
@import '@propelinc/citrus-ui/src/styles/form-fields';
|
|
351
|
+
|
|
352
|
+
.c-text-field__label {
|
|
353
|
+
@include body-emphasized;
|
|
354
|
+
|
|
355
|
+
display: inline-block;
|
|
356
|
+
margin-bottom: 8px;
|
|
357
|
+
transition: color $citrus-field-transition-duration ease;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
.c-text-field__container {
|
|
361
|
+
align-items: center;
|
|
362
|
+
background-color: $color-background;
|
|
363
|
+
border: $border-width solid $color-gray-200;
|
|
364
|
+
border-radius: $border-radius-next;
|
|
365
|
+
display: flex;
|
|
366
|
+
transition: border-color $citrus-field-transition-duration ease;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
.c-text-field--focused .c-text-field__container,
|
|
370
|
+
.c-text-field--invalid .c-text-field__container {
|
|
371
|
+
border-color: $color-black;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
.c-text-field--invalid .c-text-field__container {
|
|
375
|
+
color: $color-status-error;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
.c-text-field--hide-label .c-text-field__label {
|
|
379
|
+
@include sr-only;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.c-text-field--disabled .c-text-field__label {
|
|
383
|
+
color: $color-text-disabled;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
.c-text-field--disabled .c-text-field__container {
|
|
387
|
+
background-color: $color-gray-100;
|
|
388
|
+
color: $color-text-disabled;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
.c-text-field__input {
|
|
392
|
+
background-color: transparent;
|
|
393
|
+
border: none;
|
|
394
|
+
border-radius: $border-radius-next;
|
|
395
|
+
flex: 1 1 0%;
|
|
396
|
+
outline: none;
|
|
397
|
+
width: 100%;
|
|
398
|
+
|
|
399
|
+
&--has-prefix {
|
|
400
|
+
border-bottom-left-radius: 0;
|
|
401
|
+
border-top-left-radius: 0;
|
|
84
402
|
}
|
|
85
403
|
|
|
86
|
-
|
|
87
|
-
|
|
404
|
+
&--has-suffix {
|
|
405
|
+
border-bottom-right-radius: 0;
|
|
406
|
+
border-top-right-radius: 0;
|
|
88
407
|
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
.c-text-field__suffix-btn {
|
|
411
|
+
margin-right: 4px;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.c-text-field__clear-btn {
|
|
415
|
+
background: none;
|
|
416
|
+
border: none;
|
|
417
|
+
cursor: pointer;
|
|
418
|
+
font-size: 1rem;
|
|
419
|
+
margin-left: 0.5rem;
|
|
420
|
+
}
|
|
89
421
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
422
|
+
/* Size Variants */
|
|
423
|
+
.c-text-field--medium .c-text-field__input {
|
|
424
|
+
padding: 12px 16px;
|
|
94
425
|
|
|
95
|
-
|
|
96
|
-
|
|
426
|
+
&--clearable,
|
|
427
|
+
&--hideable {
|
|
428
|
+
padding-right: 0;
|
|
97
429
|
}
|
|
98
430
|
|
|
99
|
-
|
|
100
|
-
|
|
431
|
+
&--has-suffix {
|
|
432
|
+
padding-right: 8px;
|
|
101
433
|
}
|
|
102
434
|
}
|
|
103
|
-
</script>
|
|
104
435
|
|
|
105
|
-
|
|
106
|
-
|
|
436
|
+
.c-text-field--large .c-text-field__input {
|
|
437
|
+
padding: 24px;
|
|
438
|
+
|
|
439
|
+
&--clearable,
|
|
440
|
+
&--hideable {
|
|
441
|
+
padding-right: 0;
|
|
442
|
+
}
|
|
107
443
|
|
|
108
|
-
|
|
109
|
-
|
|
444
|
+
&--has-suffix {
|
|
445
|
+
padding-right: 8px;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.c-text-field__prefix {
|
|
450
|
+
flex: 0 0 auto;
|
|
451
|
+
margin-left: 16px;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
.c-text-field__suffix {
|
|
455
|
+
align-items: center;
|
|
456
|
+
display: flex;
|
|
457
|
+
flex: 0 0 auto;
|
|
458
|
+
gap: 12px;
|
|
459
|
+
margin-right: 16px;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
.c-text-field__validation-message {
|
|
463
|
+
margin-top: 4px;
|
|
110
464
|
}
|
|
111
465
|
|
|
112
|
-
.text-
|
|
113
|
-
@include
|
|
466
|
+
.c-text-field__message {
|
|
467
|
+
@include caption;
|
|
468
|
+
|
|
469
|
+
color: $color-gray-500;
|
|
470
|
+
margin-bottom: 16px;
|
|
114
471
|
}
|
|
115
472
|
</style>
|
|
@@ -1,53 +1,63 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
:to="to"
|
|
5
|
-
:href="href"
|
|
2
|
+
<a
|
|
3
|
+
v-bind="$attrs"
|
|
6
4
|
:target="target"
|
|
7
|
-
:
|
|
8
|
-
:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
:href="routerDestinationOrHref"
|
|
6
|
+
:tabindex="isRoleButton ? 0 : undefined"
|
|
7
|
+
:role="isRoleButton ? 'button' : undefined"
|
|
8
|
+
class="c-text-link"
|
|
9
|
+
:class="{ 'c-text-link--underline': underline }"
|
|
10
|
+
@click="navigate"
|
|
12
11
|
>
|
|
13
12
|
<slot />
|
|
14
|
-
</
|
|
13
|
+
</a>
|
|
15
14
|
</template>
|
|
16
15
|
|
|
17
16
|
<script lang="ts">
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
@Component({ name: 'CTextLink' })
|
|
22
|
-
export default class CTextLink extends Vue {
|
|
23
|
-
@Prop([String, Object]) to?: RawLocation;
|
|
24
|
-
@Prop(String) href?: string;
|
|
25
|
-
@Prop(String) target?: string;
|
|
26
|
-
@Prop({ type: Boolean, default: false }) light!: boolean;
|
|
27
|
-
|
|
28
|
-
get component(): string {
|
|
29
|
-
if (this.to) {
|
|
30
|
-
return 'router-link';
|
|
31
|
-
} else {
|
|
32
|
-
return 'a';
|
|
33
|
-
}
|
|
34
|
-
}
|
|
17
|
+
import type { PropType } from 'vue';
|
|
18
|
+
import { computed, defineComponent } from 'vue';
|
|
19
|
+
import type { RouteLocationRaw } from 'vue-router';
|
|
35
20
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
21
|
+
import { useRouterLink } from '@propelinc/citrus-ui/src/composables/router';
|
|
22
|
+
|
|
23
|
+
export default defineComponent({
|
|
24
|
+
props: {
|
|
25
|
+
/** Controls whether the text link functions as a router-link */
|
|
26
|
+
to: { type: [String, Object] as PropType<RouteLocationRaw>, default: undefined },
|
|
27
|
+
/** Designates the text link as an anchor and applies the href attribute */
|
|
28
|
+
href: { type: String, default: undefined },
|
|
29
|
+
/** Designates the target attribute. Only use with the href prop. */
|
|
30
|
+
target: { type: String, default: undefined },
|
|
31
|
+
/** Toggles whether the link should have an underline */
|
|
32
|
+
underline: { type: Boolean, default: true },
|
|
33
|
+
},
|
|
34
|
+
setup(props) {
|
|
35
|
+
const to = computed(() => props.to);
|
|
36
|
+
const { href: routerDestination, navigate } = useRouterLink(to);
|
|
37
|
+
const routerDestinationOrHref = computed(() => routerDestination.value ?? props.href);
|
|
38
|
+
|
|
39
|
+
const isRoleButton = computed(() => {
|
|
40
|
+
return !props.to && !props.href;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
isRoleButton,
|
|
45
|
+
navigate,
|
|
46
|
+
routerDestinationOrHref,
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
});
|
|
40
50
|
</script>
|
|
41
51
|
|
|
42
52
|
<style lang="scss" scoped>
|
|
43
|
-
@import '
|
|
53
|
+
@import '@propelinc/citrus-ui/src/styles/core';
|
|
44
54
|
|
|
45
|
-
.text-link {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
55
|
+
.c-text-link {
|
|
56
|
+
color: $color-black;
|
|
57
|
+
font-weight: $font-weight-semibold;
|
|
49
58
|
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
&--underline {
|
|
60
|
+
@include link-underline;
|
|
61
|
+
}
|
|
52
62
|
}
|
|
53
63
|
</style>
|