@propelinc/citrus-ui 1.0.4 → 1.3.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 +51 -14
- package/dist/citrus-ui.cdn.css +1 -0
- package/dist/citrus-ui.css +1 -0
- package/dist/colors/colors.d.ts +31 -0
- package/dist/colors/theme.d.ts +3 -0
- package/dist/colors/util-classes.d.ts +11 -0
- package/dist/components/CAccordion.vue.d.ts +34 -0
- package/dist/components/CAccordionItem.vue.d.ts +39 -0
- package/dist/components/CAppBar.vue.d.ts +59 -0
- package/dist/components/CBadge.vue.d.ts +35 -0
- package/dist/components/CBottomSheet.vue.d.ts +90 -0
- package/dist/components/CButton/CButton.vue.d.ts +97 -0
- package/dist/components/CButton/types.d.ts +5 -0
- package/dist/components/CButtonStack.vue.d.ts +27 -0
- package/dist/components/CCard.vue.d.ts +53 -0
- package/dist/components/CCardFooter.vue.d.ts +20 -0
- package/dist/components/CCardHeader.vue.d.ts +22 -0
- package/dist/components/CCardSection.vue.d.ts +26 -0
- package/dist/components/CCheckbox.vue.d.ts +62 -0
- package/dist/components/CCol.vue.d.ts +30 -0
- package/dist/components/CDivider.vue.d.ts +9 -0
- package/dist/components/CDobField.vue.d.ts +60 -0
- package/dist/components/CDobSelect.vue.d.ts +50 -0
- package/dist/components/CEmailField.vue.d.ts +48 -0
- package/dist/components/CExpandTransition.vue.d.ts +29 -0
- package/dist/components/CFadeTransition.vue.d.ts +20 -0
- package/dist/components/CFileInput.vue.d.ts +50 -0
- package/dist/components/CFixedPageFooter.vue.d.ts +153 -0
- package/dist/components/CForm.vue.d.ts +44 -0
- package/dist/components/CFormFieldCounter.vue.d.ts +15 -0
- package/dist/components/CIconButton.vue.d.ts +97 -0
- package/dist/components/CLabel.vue.d.ts +36 -0
- package/dist/components/CListItem.vue.d.ts +56 -0
- package/dist/components/CListItemContent.vue.d.ts +27 -0
- package/dist/components/CListItemIcon.vue.d.ts +28 -0
- package/dist/components/CLoader.vue.d.ts +23 -0
- package/dist/components/CLogo.vue.d.ts +9 -0
- package/dist/components/CMaskedTextField.vue.d.ts +511 -0
- package/dist/components/CMenu.vue.d.ts +17 -0
- package/dist/components/CMenuItem.vue.d.ts +37 -0
- package/dist/components/CMenuLabel.vue.d.ts +20 -0
- package/dist/components/CModal.vue.d.ts +59 -0
- package/dist/components/CModalLoading.vue.d.ts +36 -0
- package/dist/components/CNotification.vue.d.ts +64 -0
- package/dist/components/CPhoneField.vue.d.ts +792 -0
- package/dist/components/CPill.vue.d.ts +41 -0
- package/dist/components/CPillGroup.vue.d.ts +39 -0
- package/dist/components/CPopup.vue.d.ts +37 -0
- package/dist/components/CProgressLinear.vue.d.ts +21 -0
- package/dist/components/CProgressRing.vue.d.ts +48 -0
- package/dist/components/CRadio.vue.d.ts +40 -0
- package/dist/components/CRadioGroup.vue.d.ts +54 -0
- package/dist/components/CRebrand.vue.d.ts +28 -0
- package/dist/components/CRow.vue.d.ts +41 -0
- package/dist/components/CSafeArea.vue.d.ts +18 -0
- package/dist/components/CSectionHeader.vue.d.ts +29 -0
- package/dist/components/CSelect.vue.d.ts +96 -0
- package/dist/components/CSkeleton.vue.d.ts +3 -0
- package/dist/components/CSkeletonLoaderCard.vue.d.ts +9 -0
- package/dist/components/CSkeletonLoaderCircle.vue.d.ts +3 -0
- package/dist/components/CSkeletonLoaderText.vue.d.ts +16 -0
- package/dist/components/CSlideFadeTransition.vue.d.ts +36 -0
- package/dist/components/CSplitInput.vue.d.ts +56 -0
- package/dist/components/CSquaredIcon.vue.d.ts +33 -0
- package/dist/components/CSsnField.vue.d.ts +798 -0
- package/dist/components/CStatusDot.vue.d.ts +10 -0
- package/dist/components/CSwitch.vue.d.ts +39 -0
- package/dist/components/CSwitchListItem.vue.d.ts +48 -0
- package/dist/components/CTextArea.vue.d.ts +96 -0
- package/dist/components/CTextField.vue.d.ts +129 -0
- package/dist/components/CTextLink.vue.d.ts +36 -0
- package/dist/components/CThirdPartyLogo.vue.d.ts +22 -0
- package/dist/components/CTimeago.vue.d.ts +12 -0
- package/dist/components/CToast.vue.d.ts +69 -0
- package/dist/components/CToastsList.vue.d.ts +3 -0
- package/dist/components/CValidationMessage.vue.d.ts +37 -0
- package/dist/components/CZipcodeField.vue.d.ts +796 -0
- package/dist/components/index.d.ts +66 -0
- 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 +10 -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/icons.cdn.mjs +3 -0
- package/dist/icons.cdn.mjs.map +1 -0
- package/dist/icons.d.ts +1 -0
- package/dist/icons.mjs +6 -0
- package/dist/icons.mjs.map +1 -0
- package/dist/index.cdn.mjs +9328 -12875
- package/dist/index.cdn.mjs.map +1 -1
- package/dist/index.cdn2.mjs +55255 -0
- package/dist/index.cdn2.mjs.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.mjs +3946 -0
- package/dist/index.mjs.map +1 -0
- package/dist/plugin.d.ts +3 -0
- 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 → styles.css} +40 -2
- package/dist/theme/icons.d.ts +36 -0
- package/dist/types/CForm.d.ts +12 -0
- package/dist/types/font-awesome.d.ts +5 -0
- package/dist/types.d.ts +13 -0
- package/package.json +11 -4
- package/src/colors/colors.ts +8 -3
- package/src/components/CAccordion.vue +31 -24
- package/src/components/CAccordionItem.vue +46 -45
- package/src/components/CAppBar.vue +108 -101
- package/src/components/CBadge.vue +33 -25
- package/src/components/CBottomSheet.vue +212 -199
- package/src/components/CButton/CButton.vue +135 -147
- package/src/components/CButtonStack.vue +21 -13
- package/src/components/CCard.vue +72 -69
- package/src/components/CCardFooter.vue +5 -5
- package/src/components/CCardHeader.vue +9 -7
- package/src/components/CCardSection.vue +15 -8
- package/src/components/CCheckbox.vue +68 -69
- package/src/components/CCol.vue +21 -22
- package/src/components/CDivider.vue +9 -8
- package/src/components/CDobField.vue +114 -105
- package/src/components/CDobSelect.vue +162 -164
- package/src/components/CEmailField.vue +39 -27
- package/src/components/CExpandTransition.vue +14 -17
- package/src/components/CFadeTransition.vue +3 -3
- package/src/components/CFileInput.vue +57 -50
- package/src/components/CFixedPageFooter.vue +23 -17
- package/src/components/CForm.vue +67 -60
- package/src/components/CFormFieldCounter.vue +25 -28
- package/src/components/CIconButton.vue +84 -65
- package/src/components/CLabel.vue +19 -13
- package/src/components/CListItem.vue +67 -66
- package/src/components/CListItemContent.vue +14 -16
- package/src/components/CListItemIcon.vue +18 -14
- package/src/components/CLoader.vue +47 -56
- package/src/components/CLogo.vue +13 -12
- package/src/components/CMaskedTextField.vue +80 -64
- package/src/components/CMenu.vue +14 -6
- package/src/components/CMenuItem.vue +28 -22
- package/src/components/CMenuLabel.vue +6 -5
- package/src/components/CModal.vue +76 -71
- package/src/components/CModalLoading.vue +24 -15
- package/src/components/CNotification.vue +77 -28
- package/src/components/CPhoneField.vue +34 -25
- package/src/components/CPill.vue +92 -88
- package/src/components/CPillGroup.vue +30 -21
- package/src/components/CPopup.vue +46 -37
- package/src/components/CProgressLinear.vue +17 -11
- package/src/components/CProgressRing.vue +33 -33
- package/src/components/CRadio.vue +57 -57
- package/src/components/CRadioGroup.vue +85 -72
- package/src/components/CRow.vue +22 -20
- package/src/components/CSectionHeader.vue +20 -12
- package/src/components/CSelect.vue +89 -73
- package/src/components/CSkeletonLoaderCard.vue +9 -15
- package/src/components/CSkeletonLoaderCircle.vue +1 -9
- package/src/components/CSkeletonLoaderText.vue +17 -18
- package/src/components/CSlideFadeTransition.vue +12 -34
- package/src/components/CSplitInput.vue +46 -45
- package/src/components/CSquaredIcon.vue +39 -29
- package/src/components/CSsnField.vue +48 -36
- package/src/components/CStatusDot.vue +16 -16
- package/src/components/CSwitch.vue +31 -22
- package/src/components/CSwitchListItem.vue +27 -28
- package/src/components/CTextArea.vue +116 -83
- package/src/components/CTextField.vue +194 -198
- package/src/components/CTextLink.vue +28 -25
- package/src/components/CThirdPartyLogo.vue +30 -59
- package/src/components/CToast.vue +135 -132
- package/src/components/CToastsList.vue +2 -15
- package/src/components/CValidationMessage.vue +31 -24
- package/src/components/CZipcodeField.vue +40 -27
- package/src/composables/elements.ts +1 -1
- package/src/composables/fields.ts +4 -4
- package/src/composables/router.ts +6 -5
- package/src/icons.ts +6 -0
- package/src/services/injections/buttons.ts +1 -1
- package/src/styles/_core.scss +1 -2
- package/src/styles/_reset.scss +1 -1
- package/src/styles/main.scss +2 -0
- package/src/types.ts +2 -0
- package/dist/index.cdn.css +0 -1
- package/dist/styles/utils.css +0 -2709
|
@@ -12,27 +12,27 @@
|
|
|
12
12
|
</div>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
|
-
<script lang="ts">
|
|
16
|
-
import
|
|
17
|
-
import { computed, defineComponent } from 'vue';
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import { computed } from 'vue';
|
|
18
17
|
|
|
19
18
|
import { useA11yLabelCheck } from '@propelinc/citrus-ui/src/composables/accessibility';
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
count
|
|
24
|
-
bordered
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
const props = withDefaults(
|
|
21
|
+
defineProps<{
|
|
22
|
+
count?: number | null;
|
|
23
|
+
bordered?: boolean;
|
|
24
|
+
}>(),
|
|
25
|
+
{
|
|
26
|
+
count: null,
|
|
27
|
+
bordered: false,
|
|
28
|
+
}
|
|
29
|
+
);
|
|
28
30
|
|
|
29
|
-
|
|
30
|
-
const displayCount = computed(() => {
|
|
31
|
-
return props.count && props.count > 9 ? '9+' : props.count;
|
|
32
|
-
});
|
|
31
|
+
useA11yLabelCheck('CStatusDot');
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const hasCount = computed(() => props.count !== null);
|
|
34
|
+
const displayCount = computed(() => {
|
|
35
|
+
return props.count && props.count > 9 ? '9+' : props.count;
|
|
36
36
|
});
|
|
37
37
|
</script>
|
|
38
38
|
|
|
@@ -18,34 +18,43 @@
|
|
|
18
18
|
</sl-switch>
|
|
19
19
|
</template>
|
|
20
20
|
|
|
21
|
-
<script lang="ts">
|
|
21
|
+
<script setup lang="ts">
|
|
22
22
|
import '@shoelace-style/shoelace/dist/components/switch/switch.js';
|
|
23
|
-
import {
|
|
23
|
+
import type { VNode } from 'vue';
|
|
24
|
+
import { toRefs } from 'vue';
|
|
24
25
|
|
|
25
26
|
import { useInternalValue } from '@propelinc/citrus-ui/src/composables/binding';
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
const props = withDefaults(
|
|
29
|
+
defineProps<{
|
|
30
|
+
/** Label for screen-readers. This hides and overrides the normal label. */
|
|
31
|
+
ariaLabel?: string;
|
|
32
|
+
/** Prevents the user from interacting with the switch */
|
|
33
|
+
disabled?: boolean;
|
|
29
34
|
/** When true, the slot label is visually rendered before the control (label left, switch right) */
|
|
30
|
-
labelFirst
|
|
35
|
+
labelFirst?: boolean;
|
|
31
36
|
/** Whether the switch is in an "on" or "off" state */
|
|
32
|
-
value
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
value?: boolean;
|
|
38
|
+
}>(),
|
|
39
|
+
{
|
|
40
|
+
ariaLabel: '',
|
|
41
|
+
disabled: false,
|
|
42
|
+
labelFirst: false,
|
|
43
|
+
value: false,
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const emit = defineEmits<{
|
|
48
|
+
(e: 'input', value: boolean): void;
|
|
49
|
+
}>();
|
|
50
|
+
|
|
51
|
+
defineSlots<{
|
|
52
|
+
default?: () => VNode[];
|
|
53
|
+
}>();
|
|
54
|
+
|
|
55
|
+
const { value } = toRefs(props);
|
|
56
|
+
const internalValue = useInternalValue(value, {
|
|
57
|
+
onChange: (newValue) => emit('input', newValue),
|
|
49
58
|
});
|
|
50
59
|
</script>
|
|
51
60
|
|
|
@@ -32,50 +32,49 @@
|
|
|
32
32
|
</CListItem>
|
|
33
33
|
</template>
|
|
34
34
|
|
|
35
|
-
<script lang="ts">
|
|
36
|
-
import
|
|
35
|
+
<script setup lang="ts">
|
|
36
|
+
import type { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
37
37
|
|
|
38
38
|
import CListItem from '@propelinc/citrus-ui/src/components/CListItem.vue';
|
|
39
39
|
import CListItemContent from '@propelinc/citrus-ui/src/components/CListItemContent.vue';
|
|
40
40
|
import CListItemIcon from '@propelinc/citrus-ui/src/components/CListItemIcon.vue';
|
|
41
41
|
import CSwitch from '@propelinc/citrus-ui/src/components/CSwitch.vue';
|
|
42
|
-
import type { FaPropType } from '@propelinc/citrus-ui/src/types/font-awesome';
|
|
43
42
|
|
|
44
43
|
import { useSlotHasContent } from '../composables/slots';
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
components: {
|
|
49
|
-
CSwitch,
|
|
50
|
-
CListItem,
|
|
51
|
-
CListItemContent,
|
|
52
|
-
CListItemIcon,
|
|
53
|
-
},
|
|
54
|
-
props: {
|
|
45
|
+
withDefaults(
|
|
46
|
+
defineProps<{
|
|
55
47
|
/** Alignment of the content */
|
|
56
|
-
align
|
|
48
|
+
align?: 'top' | 'center';
|
|
57
49
|
/** Prevents the user from interacting with the switch */
|
|
58
|
-
disabled
|
|
50
|
+
disabled?: boolean;
|
|
59
51
|
/** Font Awesome icon to render on the left side of the component */
|
|
60
|
-
icon
|
|
52
|
+
icon?: string | string[] | IconDefinition | null;
|
|
61
53
|
/** Color of the icon background */
|
|
62
|
-
iconColor
|
|
54
|
+
iconColor?: string;
|
|
63
55
|
/** Plain body copy. Overridden by the default slot. */
|
|
64
|
-
label
|
|
56
|
+
label?: string;
|
|
65
57
|
/** Emphasized text above body text. Overridden by the default slot. */
|
|
66
|
-
title
|
|
58
|
+
title?: string;
|
|
67
59
|
/** Whether the switch is in an "on" or "off" state */
|
|
68
|
-
value
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
60
|
+
value?: boolean;
|
|
61
|
+
}>(),
|
|
62
|
+
{
|
|
63
|
+
align: 'center',
|
|
64
|
+
disabled: false,
|
|
65
|
+
icon: null,
|
|
66
|
+
iconColor: 'gray-100',
|
|
67
|
+
label: undefined,
|
|
68
|
+
title: undefined,
|
|
69
|
+
value: false,
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
defineEmits<{
|
|
74
|
+
(e: 'input', value: boolean): void;
|
|
75
|
+
}>();
|
|
73
76
|
|
|
74
|
-
|
|
75
|
-
iconSlotHasContent,
|
|
76
|
-
};
|
|
77
|
-
},
|
|
78
|
-
});
|
|
77
|
+
const iconSlotHasContent = useSlotHasContent('icon');
|
|
79
78
|
</script>
|
|
80
79
|
|
|
81
80
|
<style lang="scss" scoped>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
class="d-flex flex-column gap-1"
|
|
4
4
|
:class="{
|
|
5
5
|
'c-text-area--disabled': disabled,
|
|
6
|
-
'c-text-area--invalid':
|
|
6
|
+
'c-text-area--invalid': isInvalid,
|
|
7
7
|
'c-text-area--hide-label': hideLabel,
|
|
8
8
|
}"
|
|
9
9
|
:data-test="dataTest"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
rows="4"
|
|
22
22
|
:aria-label="label || undefined"
|
|
23
23
|
:aria-describedby="`${idWithFallback}-message ${idWithFallback}-validation-message`"
|
|
24
|
-
:aria-invalid="
|
|
24
|
+
:aria-invalid="isInvalid ? 'true' : 'false'"
|
|
25
25
|
:data-test="`${dataTest}-textarea`"
|
|
26
26
|
:disabled="disabled"
|
|
27
27
|
:placeholder="placeholder"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
|
|
38
38
|
<CValidationMessage
|
|
39
39
|
:data-test="`${dataTest}-validation-message`"
|
|
40
|
-
:validation-message="validationMessage"
|
|
40
|
+
:validation-message="errorMessage || validationMessage"
|
|
41
41
|
:hide="hideDetails"
|
|
42
42
|
>
|
|
43
43
|
<template #append>
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
</div>
|
|
63
63
|
</template>
|
|
64
64
|
|
|
65
|
-
<script lang="ts">
|
|
66
|
-
import type {
|
|
67
|
-
import {
|
|
65
|
+
<script setup lang="ts">
|
|
66
|
+
import type { VNode } from 'vue';
|
|
67
|
+
import { computed, ref, toRefs } from 'vue';
|
|
68
68
|
|
|
69
69
|
import CFormFieldCounter from '@propelinc/citrus-ui/src/components/CFormFieldCounter.vue';
|
|
70
70
|
import CValidationMessage from '@propelinc/citrus-ui/src/components/CValidationMessage.vue';
|
|
@@ -74,86 +74,110 @@ import { useSlotHasContent } from '@propelinc/citrus-ui/src/composables/slots';
|
|
|
74
74
|
import type { Rules } from '@propelinc/citrus-ui/src/composables/validations';
|
|
75
75
|
import { useValidations } from '@propelinc/citrus-ui/src/composables/validations';
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
const props = withDefaults(
|
|
78
|
+
defineProps<{
|
|
79
|
+
/** Shows a character counter and sets its denominator. */
|
|
80
|
+
counter?: number | null;
|
|
81
|
+
/**
|
|
82
|
+
* Function or number that determines the numerator of the counter. If not
|
|
83
|
+
* set, the counter will be the length of the input value.
|
|
84
|
+
*/
|
|
85
|
+
counterValue?: number | (() => number | null) | null;
|
|
86
|
+
/** Adds a custom data test string to the form field and textarea elements */
|
|
87
|
+
dataTest?: string;
|
|
87
88
|
/** Controls whether the input is disabled */
|
|
88
|
-
disabled
|
|
89
|
-
/**
|
|
90
|
-
|
|
89
|
+
disabled?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Overrides the default validation message. If provided, this error message will always
|
|
92
|
+
* be shown, regardless of any other failing validation rules.
|
|
93
|
+
*/
|
|
94
|
+
errorMessage?: string | null;
|
|
91
95
|
/** Hides the label and instead labels the field with `aria-label` */
|
|
92
|
-
hideLabel
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/**
|
|
96
|
+
hideLabel?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Hides the validation message area. Defaults to `false` (show message area even when valid),
|
|
99
|
+
* so validations transition in gracefully.
|
|
100
|
+
*/
|
|
101
|
+
hideDetails?: boolean | 'auto';
|
|
102
|
+
/** The textarea element's id */
|
|
103
|
+
id?: string | null;
|
|
104
|
+
/** The textarea's label, both visual and screenreader-only */
|
|
105
|
+
label?: string | null;
|
|
106
|
+
/** Sets the maxlength attribute of the textarea */
|
|
107
|
+
maxlength?: number;
|
|
108
|
+
/** The textarea's placeholder */
|
|
109
|
+
placeholder?: string;
|
|
110
|
+
/** If true, the field is required */
|
|
111
|
+
required?: boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Accepts a mixed array of types function, boolean and string.
|
|
107
114
|
* Functions pass an input value as an argument and must return either true / false or
|
|
108
115
|
* a string containing an error message. The input field will enter an error state if a
|
|
109
|
-
*
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
116
|
+
* function returns (or any value in the array contains) false or is a string
|
|
117
|
+
*/
|
|
118
|
+
rules?: Rules<string>;
|
|
119
|
+
/** The textarea's value */
|
|
120
|
+
value?: string;
|
|
121
|
+
}>(),
|
|
122
|
+
{
|
|
123
|
+
counter: null,
|
|
124
|
+
counterValue: null,
|
|
125
|
+
dataTest: 'text-area',
|
|
126
|
+
disabled: false,
|
|
127
|
+
errorMessage: null,
|
|
128
|
+
hideDetails: false,
|
|
129
|
+
hideLabel: false,
|
|
130
|
+
id: null,
|
|
131
|
+
label: null,
|
|
132
|
+
maxlength: undefined,
|
|
133
|
+
placeholder: '',
|
|
134
|
+
required: false,
|
|
135
|
+
rules: () => [],
|
|
136
|
+
value: '',
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const emit = defineEmits<{
|
|
141
|
+
input: [value: string];
|
|
142
|
+
change: [value: string];
|
|
143
|
+
blur: [];
|
|
144
|
+
focus: [];
|
|
145
|
+
}>();
|
|
146
|
+
|
|
147
|
+
defineSlots<{
|
|
148
|
+
label?: () => VNode[];
|
|
149
|
+
message?: () => VNode[];
|
|
150
|
+
}>();
|
|
151
|
+
|
|
152
|
+
const { value, rules, required, id } = toRefs(props);
|
|
153
|
+
const idWithFallback = useId(id);
|
|
154
|
+
|
|
155
|
+
const internalValue = useInternalValue(value, {
|
|
156
|
+
onChange: (value) => emit('input', value),
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const messageSlotHasContent = useSlotHasContent('message');
|
|
160
|
+
|
|
161
|
+
const textarea = ref<HTMLTextAreaElement | null>(null);
|
|
162
|
+
|
|
163
|
+
const {
|
|
164
|
+
message: validationMessage,
|
|
165
|
+
valid: isValidationValid,
|
|
166
|
+
listeners: validationListeners,
|
|
167
|
+
} = useValidations({
|
|
168
|
+
id: idWithFallback,
|
|
169
|
+
value: internalValue,
|
|
170
|
+
rules,
|
|
171
|
+
required,
|
|
172
|
+
field: textarea,
|
|
156
173
|
});
|
|
174
|
+
|
|
175
|
+
const isInvalid = computed(() => !isValidationValid.value || !!props.errorMessage);
|
|
176
|
+
|
|
177
|
+
const onInput = (event: Event): void => {
|
|
178
|
+
const target = event.target as HTMLTextAreaElement;
|
|
179
|
+
internalValue.value = target.value;
|
|
180
|
+
};
|
|
157
181
|
</script>
|
|
158
182
|
|
|
159
183
|
<style lang="scss" scoped>
|
|
@@ -168,6 +192,10 @@ export default defineComponent({
|
|
|
168
192
|
margin-bottom: 4px;
|
|
169
193
|
transition: color $citrus-field-transition-duration ease;
|
|
170
194
|
|
|
195
|
+
.c-text-area--invalid & {
|
|
196
|
+
color: $color-status-error;
|
|
197
|
+
}
|
|
198
|
+
|
|
171
199
|
.c-text-area--disabled & {
|
|
172
200
|
color: $color-text-disabled;
|
|
173
201
|
}
|
|
@@ -186,12 +214,17 @@ export default defineComponent({
|
|
|
186
214
|
transition: border-color $citrus-field-transition-duration ease;
|
|
187
215
|
|
|
188
216
|
&:focus,
|
|
189
|
-
&:focus-within
|
|
190
|
-
.c-text-area--invalid & {
|
|
217
|
+
&:focus-within {
|
|
191
218
|
border-color: $color-black;
|
|
192
219
|
outline: none;
|
|
193
220
|
}
|
|
194
221
|
|
|
222
|
+
.c-text-area--invalid & {
|
|
223
|
+
border-color: $color-status-error;
|
|
224
|
+
color: $color-status-error;
|
|
225
|
+
outline: none;
|
|
226
|
+
}
|
|
227
|
+
|
|
195
228
|
&:disabled {
|
|
196
229
|
background-color: $color-gray-100;
|
|
197
230
|
color: $color-text-disabled;
|