diff --git a/packages/design-system/src/components/N8nColorPicker/ColorPicker.vue b/packages/design-system/src/components/N8nColorPicker/ColorPicker.vue index 99c18b2c89..74a5c7391b 100644 --- a/packages/design-system/src/components/N8nColorPicker/ColorPicker.vue +++ b/packages/design-system/src/components/N8nColorPicker/ColorPicker.vue @@ -3,6 +3,7 @@ import { computed, ref } from 'vue'; import { uid } from '../../utils'; import { ElColorPicker } from 'element-plus'; import N8nInput from '../N8nInput'; +import type { ElementPlusSizePropType } from '@/types'; export type ColorPickerProps = { disabled?: boolean; @@ -19,10 +20,12 @@ export type ColorPickerProps = { defineOptions({ name: 'N8nColorPicker' }); const props = withDefaults(defineProps(), { disabled: false, - size: 'medium', + size: 'default', showAlpha: false, colorFormat: 'hex', popperClass: '', + predefine: undefined, + modelValue: undefined, showInput: true, name: uid('color-picker'), }); @@ -30,7 +33,7 @@ const props = withDefaults(defineProps(), { const color = ref(props.modelValue); const colorPickerProps = computed(() => { - const { showInput, ...rest } = props; + const { showInput, modelValue, size, ...rest } = props; return rest; }); @@ -40,6 +43,8 @@ const emit = defineEmits<{ (event: 'active-change', value: string): void; }>(); +const resolvedSize = computed(() => props.size as ElementPlusSizePropType); + const onChange = (value: string) => { emit('change', value); }; @@ -61,7 +66,7 @@ const onColorSelect = (value: string) => { { v-if="showInput" :class="$style.input" :disabled="props.disabled" - :size="props.size" + :size="size" :model-value="color" :name="name" type="text" diff --git a/packages/design-system/src/components/N8nColorPicker/__tests__/__snapshots__/ColorPicker.spec.ts.snap b/packages/design-system/src/components/N8nColorPicker/__tests__/__snapshots__/ColorPicker.spec.ts.snap index 98c92ea40d..bc8bdfc5d4 100644 --- a/packages/design-system/src/components/N8nColorPicker/__tests__/__snapshots__/ColorPicker.spec.ts.snap +++ b/packages/design-system/src/components/N8nColorPicker/__tests__/__snapshots__/ColorPicker.spec.ts.snap @@ -64,7 +64,7 @@ exports[`components > N8nColorPicker > should render with input 1`] = `
@@ -79,7 +79,6 @@ exports[`components > N8nColorPicker > should render with input 1`] = ` @@ -17,7 +20,7 @@ {{ tooltipText }} ; - autocomplete?: string; + autocomplete?: InputAutocompletePropType; name?: string; focusInitially?: boolean; - labelSize?: 'small' | 'medium'; + labelSize?: 'small' | 'medium' | 'large'; disabled?: boolean; activeLabel?: string; activeColor?: string; @@ -206,7 +220,7 @@ function onBlur() { $emit('blur'); } -function onUpdateModelValue(value: FormState) { +function onUpdateModelValue(value: Validatable) { state.isTyping = true; $emit('update:modelValue', value); } @@ -225,9 +239,9 @@ const validationError = computed(() => { const error = getInputValidationError(); if (error) { - if (error.messageKey) { - return t(error.messageKey, error.options); - } else { + if ('messageKey' in error) { + return t(error.messageKey, error.options as object); + } else if ('message' in error) { return error.message; } } diff --git a/packages/design-system/src/components/N8nFormInput/validators.ts b/packages/design-system/src/components/N8nFormInput/validators.ts index 855c3ba6a2..990e6b083b 100644 --- a/packages/design-system/src/components/N8nFormInput/validators.ts +++ b/packages/design-system/src/components/N8nFormInput/validators.ts @@ -20,7 +20,7 @@ export const requiredValidator: IValidator<{}> = { }; export const minLengthValidator: IValidator<{ minimum: number }> = { - validate: (value: Validatable, config: { minimum: number }) => { + validate: (value: Validatable, config) => { if (typeof value === 'string' && value.length < config.minimum) { return { messageKey: 'formInput.validator.minCharactersRequired', @@ -76,7 +76,7 @@ export const emailValidator: IValidator<{}> = { }; export const containsUpperCaseValidator: IValidator<{ minimum: number }> = { - validate: (value: Validatable, config: { minimum: number }) => { + validate: (value: Validatable, config) => { if (typeof value !== 'string') { return false; } @@ -94,7 +94,7 @@ export const containsUpperCaseValidator: IValidator<{ minimum: number }> = { }; export const matchRegex: IValidator<{ regex: RegExp; message: string }> = { - validate: (value: Validatable, config: { regex: RegExp; message: string }) => { + validate: (value: Validatable, config) => { if (!config.regex.test(`${value as string}`)) { return { message: config.message, diff --git a/packages/design-system/src/components/N8nFormInputs/FormInputs.vue b/packages/design-system/src/components/N8nFormInputs/FormInputs.vue index 3060646dd5..293b78e854 100644 --- a/packages/design-system/src/components/N8nFormInputs/FormInputs.vue +++ b/packages/design-system/src/components/N8nFormInputs/FormInputs.vue @@ -75,7 +75,7 @@ export default defineComponent({ default: true, }, tagSize: { - type: String, + type: String as PropType<'small' | 'medium'>, default: 'small', validator: (value: string): boolean => ['small', 'medium'].includes(value), }, diff --git a/packages/design-system/src/components/N8nInput/Input.vue b/packages/design-system/src/components/N8nInput/Input.vue index d5419d2317..5de8253d22 100644 --- a/packages/design-system/src/components/N8nInput/Input.vue +++ b/packages/design-system/src/components/N8nInput/Input.vue @@ -1,11 +1,19 @@