-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(editor): Fix design system typecheck errors (no-changelog) #9447
Changes from 3 commits
f236862
9ec2ef8
479045b
7291312
f592c5b
c9d6d3d
969a835
bb9874d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
<template> | ||
<ElInput | ||
ref="innerInput" | ||
:size="computedSize" | ||
:model-value="modelValue" | ||
:size="resolvedSize" | ||
:class="['n8n-input', ...classes]" | ||
:autocomplete="autocomplete" | ||
:name="name" | ||
v-bind="{ ...$props, ...$attrs }" | ||
:placeholder="placeholder" | ||
:disabled="disabled" | ||
:readonly="readonly" | ||
:clearable="clearable" | ||
:rows="rows" | ||
:title="title" | ||
v-bind="$attrs" | ||
> | ||
<template v-if="$slots.prepend" #prepend> | ||
<slot name="prepend" /> | ||
|
@@ -27,6 +34,7 @@ | |
import { ElInput } from 'element-plus'; | ||
import { uid } from '../../utils'; | ||
import type { InputSize, InputType } from '@/types/input'; | ||
import { InputAutocompletePropType } from '@/types'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lint issue here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. Updated. |
||
|
||
interface InputProps { | ||
modelValue?: string | number; | ||
|
@@ -40,12 +48,13 @@ | |
maxlength?: number; | ||
title?: string; | ||
name?: string; | ||
autocomplete?: 'off' | 'autocomplete'; | ||
autocomplete?: InputAutocompletePropType; | ||
} | ||
|
||
defineOptions({ name: 'N8nInput' }); | ||
const props = withDefaults(defineProps<InputProps>(), { | ||
modelValue: '', | ||
type: 'text', | ||
size: 'large', | ||
placeholder: '', | ||
disabled: false, | ||
|
@@ -58,7 +67,15 @@ | |
autocomplete: 'off', | ||
}); | ||
|
||
const computedSize = computed(() => (props.size === 'xlarge' ? undefined : props.size)); | ||
const resolvedSize = computed( | ||
() => | ||
(props.size === 'xlarge' ? undefined : props.size) as | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is type coercion needed here if we already set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ElementPlus components have a different type declared. Technically they accept any value for the prop and will generate a class based on it, but There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it makes sense here or too complicated feel free to keep. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure I can fix it in a more elegant way other than casting unfortunately. |
||
| '' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe this size type could be an imported type? since it's the same as in ColorPicker and InputNumber There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great point. Updated. |
||
| 'small' | ||
| 'large' | ||
| 'default' | ||
| undefined, | ||
); | ||
|
||
const classes = computed(() => { | ||
const applied: string[] = []; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,12 @@ | |
<template #content>{{ nodeTypeName }}</template> | ||
<div v-if="type !== 'unknown'" :class="$style.icon"> | ||
<img v-if="type === 'file'" :src="src" :class="$style.nodeIconImage" /> | ||
<FontAwesomeIcon v-else :icon="name" :class="$style.iconFa" :style="fontStyleData" /> | ||
<FontAwesomeIcon | ||
v-else | ||
:icon="name as string" | ||
:class="$style.iconFa" | ||
:style="fontStyleData" | ||
/> | ||
</div> | ||
<div v-else :class="$style.nodeIconPlaceholder"> | ||
{{ nodeTypeName ? nodeTypeName.charAt(0) : '?' }} | ||
|
@@ -22,7 +27,7 @@ | |
<template v-else> | ||
<div v-if="type !== 'unknown'" :class="$style.icon"> | ||
<img v-if="type === 'file'" :src="src" :class="$style.nodeIconImage" /> | ||
<FontAwesomeIcon v-else :icon="name" :style="fontStyleData" /> | ||
<FontAwesomeIcon :icon="name as string" :style="fontStyleData" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we avoid type coercion here? and above? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
<div v-if="badge" :class="$style.badge" :style="badgeStyleData"> | ||
<n8n-node-icon :type="badge.type" :src="badge.src" :size="badgeSize"></n8n-node-icon> | ||
</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<template> | ||
<router-link v-if="useRouterLink" :to="to" v-bind="$attrs"> | ||
<router-link v-if="useRouterLink && to" :to="to" v-bind="$attrs"> | ||
<slot></slot> | ||
</router-link> | ||
<a v-else :href="to" :target="openNewWindow ? '_blank' : '_self'" v-bind="$attrs"> | ||
<a v-else :href="to as string" :target="openNewWindow ? '_blank' : '_self'" v-bind="$attrs"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could we avoid type coercion? maybe check if it's a string in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
<slot></slot> | ||
</a> | ||
</template> | ||
|
@@ -12,7 +12,7 @@ import { computed } from 'vue'; | |
import { type RouteLocationRaw } from 'vue-router'; | ||
|
||
interface RouteProps { | ||
to?: RouteLocationRaw; | ||
to?: RouteLocationRaw | string; | ||
newWindow?: boolean; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,13 +86,16 @@ export default defineComponent({ | |
}, | ||
computed: { | ||
listeners() { | ||
return Object.entries(this.$attrs).reduce<Record<string, () => {}>>((acc, [key, value]) => { | ||
if (/^on[A-Z]/.test(key)) { | ||
acc[key] = value; | ||
} | ||
return Object.entries(this.$attrs).reduce<Record<string, (...args: unknown[]) => {}>>( | ||
(acc, [key, value]) => { | ||
if (/^on[A-Z]/.test(key)) { | ||
acc[key] = value as (...args: unknown[]) => {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same question here. could we refactor this to avoid type coercion? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. |
||
} | ||
|
||
return acc; | ||
}, {}); | ||
return acc; | ||
}, | ||
{}, | ||
); | ||
}, | ||
computedSize(): InnerSelectRef['$props']['size'] { | ||
if (this.size === 'medium') { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint issue here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Updated.