Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/ccui/ui/input/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import type { App } from 'vue'
import Input from './src/input'

Input.install = function (app: App): void {
app.component(Input.name, Input)
}

export { Input }

export default {
title: 'Input 输入框',
category: '数据录入',
status: '100%',
install(app: App): void {
app.component(Input.name, Input)
},
}
49 changes: 49 additions & 0 deletions packages/ccui/ui/input/src/input-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import type { ExtractPropTypes, PropType } from 'vue'

export type InputType = 'text' | 'password'
export type InputSize = 'large' | 'default' | 'small'

export const inputProps = {
type: {
type: String as PropType<InputType>,
default: 'text',
},
size: {
type: String as PropType<InputSize>,
default: 'default',
},
placeholder: {
type: String,
default: '',
},
disabled: {
type: Boolean,
default: false,
},
readonly: {
type: Boolean,
default: false,
},
clearable: {
type: Boolean,
default: false,
},
showPassword: {
type: Boolean,
default: false,
},
prepend: {
type: String,
default: '',
},
append: {
type: String,
default: '',
},
modelValue: {
type: String,
default: '',
},
} as const

export type InputProps = ExtractPropTypes<typeof inputProps>
177 changes: 177 additions & 0 deletions packages/ccui/ui/input/src/input.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
@use '../../style-var/index.scss' as *;

.#{$cls-prefix}-input {
display: flex;
align-items: center;
width: 100%;
box-sizing: border-box;
background-color: $ccui-base-bg;
border: 1px solid $ccui-line;
border-radius: $ccui-border-radius;
color: $ccui-text;
font-size: 14px;
transition:
border-color $ccui-animation-duration-base,
box-shadow $ccui-animation-duration-base;

&:hover {
border-color: $ccui-brand-hover;
}

&:focus-within {
border-color: $ccui-brand;
box-shadow: 0 0 0 2px rgba($ccui-brand, 0.2);
}

&--disabled {
background-color: $ccui-disabled-bg;
border-color: $ccui-disabled-line;
color: $ccui-disabled-text;
cursor: not-allowed;

&:hover {
border-color: $ccui-disabled-line;
}
}

&--large {
height: $ccui-size-lg;
font-size: $ccui-font-size-lg;

&.#{$cls-prefix}-input--prefix {
.#{$cls-prefix}-input__inner {
padding-left: 24px;
}
}

&.#{$cls-prefix}-input--suffix,
&.#{$cls-prefix}-input--clearable {
.#{$cls-prefix}-input__inner {
padding-right: 24px;
}
}
}

&--default {
height: $ccui-size-md;
font-size: $ccui-font-size-md;

&.#{$cls-prefix}-input--prefix {
.#{$cls-prefix}-input__inner {
padding-left: 24px;
}
}

&.#{$cls-prefix}-input--suffix,
&.#{$cls-prefix}-input--clearable {
.#{$cls-prefix}-input__inner {
padding-right: 24px;
}
}
}

&--small {
height: $ccui-size-sm;
font-size: $ccui-font-size-sm;

&.#{$cls-prefix}-input--prefix {
.#{$cls-prefix}-input__inner {
padding-left: 20px;
}
}

&.#{$cls-prefix}-input--suffix,
&.#{$cls-prefix}-input--clearable {
.#{$cls-prefix}-input__inner {
padding-right: 20px;
}
}
}
Comment on lines +37 to +89
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Size‑based padding rules expect block modifiers, not element modifiers

The selectors like:

&--large {
  ...
  &.#{$cls-prefix}-input--prefix { ... }
  &.#{$cls-prefix}-input--suffix,
  &.#{$cls-prefix}-input--clearable { ... }
}

compile to .ccui-input--large.ccui-input--prefix .ccui-input__inner { ... } etc., i.e. they assume --prefix/--suffix/--clearable are applied on the block element.

Currently, in input.tsx these modifiers are added to the input element via inputClass, not to the block container, so these padding rules won’t ever match. After you fix the TSX to put these modifiers on the block (see comment in input.tsx), these SCSS rules will start working as intended.


&__wrapper {
position: relative;
width: 100%;
padding: 0 8px;
}

&__prepend,
&__append {
display: flex;
align-items: center;
white-space: nowrap;
background-color: $ccui-area;
color: $ccui-text;
font-size: inherit;
line-height: 1;
height: 100%;
padding: 0 10px;
}

&__prepend {
border-radius: $ccui-border-radius 0 0 $ccui-border-radius;
border-right: 1px solid $ccui-line;
}

&__append {
border-radius: 0 $ccui-border-radius $ccui-border-radius 0;
border-left: 1px solid $ccui-line;
}

&__inner {
width: 100%;
height: 100%;
background: transparent;
border: none;
outline: none;
color: inherit;
font-size: inherit;
font-family: inherit;
position: relative;
z-index: 0;
box-sizing: border-box;
padding: 4px 0;

&::placeholder {
color: $ccui-placeholder;
}

&:disabled {
cursor: not-allowed;
color: $ccui-disabled-text;
}
}

&__prefix,
&__suffix {
position: absolute;
top: 0;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
color: $ccui-placeholder;
pointer-events: none;
z-index: 1;
}

&__prefix {
left: 8px;
}

&__suffix {
right: 8px;
}

&__clear,
&__password-visible,
&__password-hidden {
cursor: pointer;
pointer-events: auto;
color: $ccui-placeholder;
transition: color $ccui-animation-duration-base;

&:hover {
color: $ccui-text;
}
}
}
Loading