@propelinc/citrus-ui 1.0.5 → 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 +39 -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} +8 -6
- 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 +8 -3
- 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/types.ts +2 -0
- package/dist/index.cdn.css +0 -1
- package/dist/styles/utils.css +0 -2709
|
@@ -71,9 +71,10 @@
|
|
|
71
71
|
</div>
|
|
72
72
|
</template>
|
|
73
73
|
|
|
74
|
-
<script lang="ts">
|
|
74
|
+
<script setup lang="ts">
|
|
75
75
|
import dayjs from 'dayjs';
|
|
76
|
-
import
|
|
76
|
+
import type { VNode } from 'vue';
|
|
77
|
+
import { computed, ref, watch } from 'vue';
|
|
77
78
|
|
|
78
79
|
import CSelect from '@propelinc/citrus-ui/src/components/CSelect.vue';
|
|
79
80
|
import CValidationMessage from '@propelinc/citrus-ui/src/components/CValidationMessage.vue';
|
|
@@ -83,169 +84,166 @@ import {
|
|
|
83
84
|
useFormValidationSupport,
|
|
84
85
|
} from '@propelinc/citrus-ui/src/composables/validations';
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
yearOptions,
|
|
239
|
-
|
|
240
|
-
computedLabel,
|
|
241
|
-
hasError,
|
|
242
|
-
messages,
|
|
243
|
-
localValue,
|
|
244
|
-
message,
|
|
245
|
-
|
|
246
|
-
emitDate,
|
|
247
|
-
};
|
|
87
|
+
const props = withDefaults(
|
|
88
|
+
defineProps<{
|
|
89
|
+
dataTest?: string;
|
|
90
|
+
id?: string;
|
|
91
|
+
label?: string | null;
|
|
92
|
+
required?: boolean;
|
|
93
|
+
rules?: Rules<string>;
|
|
94
|
+
hideLabel?: boolean;
|
|
95
|
+
hideDetails?: boolean;
|
|
96
|
+
value?: string;
|
|
97
|
+
disabled?: boolean;
|
|
98
|
+
}>(),
|
|
99
|
+
{
|
|
100
|
+
dataTest: 'dob-select',
|
|
101
|
+
id: undefined,
|
|
102
|
+
label: null,
|
|
103
|
+
required: false,
|
|
104
|
+
rules: () => [],
|
|
105
|
+
hideLabel: false,
|
|
106
|
+
hideDetails: false,
|
|
107
|
+
value: '',
|
|
108
|
+
disabled: false,
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const emit = defineEmits<{
|
|
113
|
+
(e: 'input', value: string): void;
|
|
114
|
+
(e: 'focus'): void;
|
|
115
|
+
(e: 'blur'): void;
|
|
116
|
+
}>();
|
|
117
|
+
|
|
118
|
+
defineSlots<{
|
|
119
|
+
label?: () => VNode[];
|
|
120
|
+
}>();
|
|
121
|
+
|
|
122
|
+
const { t } = useTranslation();
|
|
123
|
+
|
|
124
|
+
const computedLabel = computed(() => props.label ?? t('Date of birth'));
|
|
125
|
+
|
|
126
|
+
const localMonth = ref('');
|
|
127
|
+
const localDay = ref('');
|
|
128
|
+
const localYear = ref('');
|
|
129
|
+
|
|
130
|
+
const hasError = ref(props.required && props.value === '');
|
|
131
|
+
const messages = ref<string[]>([]);
|
|
132
|
+
|
|
133
|
+
const localValue = computed(() => {
|
|
134
|
+
if (localDay.value && localMonth.value && localYear.value) {
|
|
135
|
+
return `${localYear.value}-${localMonth.value}-${localDay.value}`;
|
|
136
|
+
}
|
|
137
|
+
return '';
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const monthRules = computed(() => {
|
|
141
|
+
if (!props.required && !localMonth.value) {
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
return [(): boolean => localMonth.value !== ''];
|
|
145
|
+
});
|
|
146
|
+
const dayRules = computed(() => {
|
|
147
|
+
if (!props.required && !localDay.value) {
|
|
148
|
+
return [];
|
|
149
|
+
}
|
|
150
|
+
return [(): boolean => localDay.value !== ''];
|
|
151
|
+
});
|
|
152
|
+
const yearRules = computed(() => {
|
|
153
|
+
if (!props.required && !localYear.value) {
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
return [(): boolean => localYear.value !== ''];
|
|
157
|
+
});
|
|
158
|
+
const message = computed(() => messages.value[0] ?? '');
|
|
159
|
+
|
|
160
|
+
const monthOptions = Array.from({ length: 12 }, (_, i) => ({
|
|
161
|
+
value: (i + 1).toString().padStart(2, '0'),
|
|
162
|
+
label: dayjs().set('month', i).format('MMM'),
|
|
163
|
+
}));
|
|
164
|
+
|
|
165
|
+
const dayOptions = computed(() => {
|
|
166
|
+
const year = Number(localYear.value) || 2000;
|
|
167
|
+
const month = Number(localMonth.value) - 1 || 0;
|
|
168
|
+
const daysInMonth = dayjs().year(year).month(month).daysInMonth();
|
|
169
|
+
return Array.from({ length: daysInMonth }, (_, i) => {
|
|
170
|
+
const day = (i + 1).toString();
|
|
171
|
+
return { value: day.padStart(2, '0'), label: day };
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
const currentYear = dayjs().year();
|
|
176
|
+
const yearOptions = Array.from({ length: 120 }, (_, age) => {
|
|
177
|
+
const year = (currentYear - age).toString();
|
|
178
|
+
return { value: year, label: year };
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const validationMessage = t('Please enter a valid {inputLabel}', {
|
|
182
|
+
inputLabel: t('date of birth'),
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
const localRules = computed(() => {
|
|
186
|
+
if (!props.required && !localValue.value) {
|
|
187
|
+
return [];
|
|
188
|
+
}
|
|
189
|
+
const validDateRule = (v: string): boolean | string =>
|
|
190
|
+
dayjs(v, 'YYYY-MM-DD', true).isValid() || validationMessage;
|
|
191
|
+
return [validDateRule, ...props.rules];
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
const valid = computed(() => !hasError.value);
|
|
195
|
+
|
|
196
|
+
const validate = (): boolean => {
|
|
197
|
+
messages.value = localRules.value
|
|
198
|
+
.map((validation) => {
|
|
199
|
+
const validationResult = validation(localValue.value);
|
|
200
|
+
return typeof validationResult === 'string' ? validationResult : '';
|
|
201
|
+
})
|
|
202
|
+
.filter((message) => message !== '');
|
|
203
|
+
|
|
204
|
+
hasError.value = (props.required && localValue.value === '') || messages.value.length > 0;
|
|
205
|
+
return !hasError.value;
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const emitDate = (): void => {
|
|
209
|
+
if (!localValue.value) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (!validate()) {
|
|
214
|
+
// NOTE(ram): An invalid date can only be caused by the day being invalid.
|
|
215
|
+
localDay.value = '';
|
|
216
|
+
emit('input', '');
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
emit('input', localValue.value);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
watch(
|
|
224
|
+
() => props.value,
|
|
225
|
+
(value) => {
|
|
226
|
+
if (!value || value === localValue.value) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
const date = dayjs(value, 'YYYY-MM-DD', true);
|
|
231
|
+
if (!date.isValid()) {
|
|
232
|
+
console.error('Invalid date in CDobSelect', value);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
localMonth.value = date.format('MM');
|
|
237
|
+
localDay.value = date.format('DD');
|
|
238
|
+
localYear.value = date.format('YYYY');
|
|
248
239
|
},
|
|
240
|
+
{ immediate: true }
|
|
241
|
+
);
|
|
242
|
+
|
|
243
|
+
useFormValidationSupport({
|
|
244
|
+
id: props.id,
|
|
245
|
+
valid,
|
|
246
|
+
validate,
|
|
249
247
|
});
|
|
250
248
|
</script>
|
|
251
249
|
|
|
@@ -23,39 +23,51 @@
|
|
|
23
23
|
</CTextField>
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
|
-
<script lang="ts">
|
|
27
|
-
import
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
import type { VNode } from 'vue';
|
|
28
28
|
|
|
29
29
|
import CTextField from '@propelinc/citrus-ui/src/components/CTextField.vue';
|
|
30
30
|
import { useTranslation } from '@propelinc/citrus-ui/src/composables/i18n';
|
|
31
31
|
import type { Rules } from '@propelinc/citrus-ui/src/composables/validations';
|
|
32
32
|
import { isValidEmail } from '@propelinc/shared-utils';
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
34
|
+
withDefaults(
|
|
35
|
+
defineProps<{
|
|
36
|
+
dataTest?: string;
|
|
37
|
+
id?: string;
|
|
38
|
+
label?: string | null;
|
|
39
|
+
placeholder?: string | null;
|
|
40
|
+
rules?: Rules<string>;
|
|
41
|
+
value?: string;
|
|
42
|
+
}>(),
|
|
43
|
+
{
|
|
44
|
+
dataTest: 'email-field',
|
|
45
|
+
id: undefined,
|
|
46
|
+
label: null,
|
|
47
|
+
placeholder: null,
|
|
48
|
+
rules: (): Rules<string> => [],
|
|
49
|
+
value: '',
|
|
50
|
+
}
|
|
51
|
+
);
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
defineEmits<{
|
|
54
|
+
input: [value: string];
|
|
55
|
+
focus: [event: Event];
|
|
56
|
+
blur: [event: Event];
|
|
57
|
+
change: [value: string];
|
|
58
|
+
}>();
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
defineSlots<{
|
|
61
|
+
label?: () => VNode[];
|
|
62
|
+
message?: () => VNode[];
|
|
63
|
+
}>();
|
|
64
|
+
|
|
65
|
+
const { t } = useTranslation();
|
|
66
|
+
|
|
67
|
+
const defaultRules = [
|
|
68
|
+
(v: string): string | boolean =>
|
|
69
|
+
!v || isValidEmail(v)
|
|
70
|
+
? true
|
|
71
|
+
: t('Please enter a valid {inputLabel}', { inputLabel: t('email') }),
|
|
72
|
+
];
|
|
61
73
|
</script>
|
|
@@ -11,27 +11,24 @@
|
|
|
11
11
|
</div>
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
|
-
<script lang="ts">
|
|
15
|
-
import {
|
|
14
|
+
<script setup lang="ts">
|
|
15
|
+
import type { VNode } from 'vue';
|
|
16
|
+
import { computed, inject, ref } from 'vue';
|
|
16
17
|
|
|
17
18
|
import { useResizeObserver } from '@propelinc/citrus-ui/src/composables/elements';
|
|
18
19
|
import { ANIMATIONS_DISABLED } from '@propelinc/citrus-ui/src/services/injections/animations';
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
return { content, height, isDisabled };
|
|
34
|
-
},
|
|
21
|
+
defineSlots<{ default: () => VNode[] }>();
|
|
22
|
+
|
|
23
|
+
const props = withDefaults(defineProps<{ disabled?: boolean }>(), { disabled: false });
|
|
24
|
+
|
|
25
|
+
const injectedDisabled = inject(ANIMATIONS_DISABLED, ref(false));
|
|
26
|
+
const isDisabled = computed(() => props.disabled || injectedDisabled.value);
|
|
27
|
+
const content = ref<HTMLElement | null>(null);
|
|
28
|
+
const height = ref<string>('auto');
|
|
29
|
+
|
|
30
|
+
useResizeObserver(content, ([entry]) => {
|
|
31
|
+
height.value = `${entry.contentRect.height}px`;
|
|
35
32
|
});
|
|
36
33
|
</script>
|
|
37
34
|
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
</Transition>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
|
-
<script lang="ts">
|
|
8
|
-
import {
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import type { VNode } from 'vue';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
defineSlots<{ default: () => VNode[] }>();
|
|
11
11
|
</script>
|
|
12
12
|
|
|
13
13
|
<style lang="scss" scoped>
|
|
@@ -35,65 +35,72 @@
|
|
|
35
35
|
</label>
|
|
36
36
|
</template>
|
|
37
37
|
|
|
38
|
-
<script lang="ts">
|
|
39
|
-
import
|
|
38
|
+
<script setup lang="ts">
|
|
39
|
+
import type { VNode } from 'vue';
|
|
40
|
+
import { computed, toRefs } from 'vue';
|
|
40
41
|
|
|
41
42
|
import { useInternalValue } from '@propelinc/citrus-ui/src/composables/binding';
|
|
42
43
|
import { useId } from '@propelinc/citrus-ui/src/composables/id';
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
prompt: { type: String, required: true },
|
|
51
|
-
/** The input's value. Either one file or an array of files */
|
|
52
|
-
value: { type: [Array, Object, null] as PropType<File[] | File | null>, default: null },
|
|
45
|
+
const props = withDefaults(
|
|
46
|
+
defineProps<{
|
|
47
|
+
/** A custom data-test string applied to the form field, text field and hide icon */
|
|
48
|
+
dataTest?: string;
|
|
49
|
+
/** Controls whether the input is disabled */
|
|
50
|
+
disabled?: boolean;
|
|
53
51
|
/** A unique id for the input */
|
|
54
|
-
id:
|
|
52
|
+
id: string;
|
|
53
|
+
/** The input's label, both visual and screenreader-only */
|
|
54
|
+
label: string;
|
|
55
55
|
/** Allow the user to upload multiple files */
|
|
56
|
-
multiple
|
|
57
|
-
/**
|
|
58
|
-
|
|
56
|
+
multiple?: boolean;
|
|
57
|
+
/** Placholder text to display before a user has selected any files */
|
|
58
|
+
prompt: string;
|
|
59
59
|
/** Controls whether the input is required */
|
|
60
|
-
required
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return {
|
|
90
|
-
idWithFallback,
|
|
91
|
-
inputValue,
|
|
92
|
-
hasValue,
|
|
93
|
-
onFileChange,
|
|
94
|
-
};
|
|
60
|
+
required?: boolean;
|
|
61
|
+
/** The input's value. Either one file or an array of files */
|
|
62
|
+
value?: File[] | File | null;
|
|
63
|
+
}>(),
|
|
64
|
+
{
|
|
65
|
+
dataTest: 'file-input',
|
|
66
|
+
disabled: false,
|
|
67
|
+
multiple: false,
|
|
68
|
+
required: false,
|
|
69
|
+
value: null,
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const emit = defineEmits<{
|
|
74
|
+
(e: 'input', value: File[] | File | null): void;
|
|
75
|
+
}>();
|
|
76
|
+
|
|
77
|
+
defineSlots<{
|
|
78
|
+
label?: () => VNode[];
|
|
79
|
+
prompt?: () => VNode[];
|
|
80
|
+
}>();
|
|
81
|
+
|
|
82
|
+
const { id, value } = toRefs(props);
|
|
83
|
+
const idWithFallback = useId(id);
|
|
84
|
+
const inputValue = useInternalValue(value, {
|
|
85
|
+
onChange: (newValue) => {
|
|
86
|
+
emit('input', newValue);
|
|
95
87
|
},
|
|
96
88
|
});
|
|
89
|
+
const hasValue = computed(() => {
|
|
90
|
+
if (Array.isArray(inputValue.value)) {
|
|
91
|
+
return inputValue.value.length > 0;
|
|
92
|
+
}
|
|
93
|
+
return !!inputValue.value;
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
function onFileChange(event: Event): void {
|
|
97
|
+
const files = (event.target as HTMLInputElement).files;
|
|
98
|
+
if (!files) {
|
|
99
|
+
inputValue.value = null;
|
|
100
|
+
} else {
|
|
101
|
+
inputValue.value = props.multiple ? Array.from(files) : files[0];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
97
104
|
</script>
|
|
98
105
|
|
|
99
106
|
<style lang="scss" scoped>
|
|
@@ -12,29 +12,35 @@
|
|
|
12
12
|
</CButtonStack>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
|
-
<script lang="ts">
|
|
16
|
-
import {
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import type { VNode } from 'vue';
|
|
17
|
+
import { computed, onBeforeUnmount, ref } from 'vue';
|
|
17
18
|
|
|
18
19
|
import CButtonStack from '@propelinc/citrus-ui/src/components/CButtonStack.vue';
|
|
19
20
|
import { useResizeObserver } from '@propelinc/citrus-ui/src/composables/elements';
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
components: { CButtonStack },
|
|
24
|
-
props: {
|
|
22
|
+
withDefaults(
|
|
23
|
+
defineProps<{
|
|
25
24
|
/** The HTML tag to render as. Avoid changing this if possible. */
|
|
26
|
-
tag
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
tag?: string;
|
|
26
|
+
}>(),
|
|
27
|
+
{
|
|
28
|
+
tag: 'footer',
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const emit = defineEmits<{
|
|
33
|
+
'change:height': [height: number];
|
|
34
|
+
}>();
|
|
35
|
+
|
|
36
|
+
defineSlots<{
|
|
37
|
+
default?: () => VNode[];
|
|
38
|
+
}>();
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
const footer = ref<InstanceType<typeof CButtonStack> | null>(null);
|
|
41
|
+
const footerElement = computed(() => (footer.value?.$el as HTMLElement) ?? null);
|
|
42
|
+
useResizeObserver(footerElement, ([entry]) => emit('change:height', entry.contentRect.height));
|
|
43
|
+
onBeforeUnmount(() => emit('change:height', 0));
|
|
38
44
|
</script>
|
|
39
45
|
|
|
40
46
|
<style lang="scss" scoped>
|