Skip to content

Commit

Permalink
feat(counter&number-input): #2537
Browse files Browse the repository at this point in the history
  • Loading branch information
zyprepare committed Jul 14, 2023
1 parent fa7faed commit ec2c785
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/orange-colts-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

Counter NumberInput feat: 支持 placeholder
6 changes: 6 additions & 0 deletions .changeset/slimy-walls-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@hi-ui/counter": patch
"@hi-ui/number-input": patch
---

feat: 支持 placeholder
21 changes: 12 additions & 9 deletions packages/ui/counter/src/use-counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const useCounter = ({
invalid = false,
formatter,
parser,
placeholder,
...rest
}: UseCounterProps) => {
const min = minProp ?? Number.MIN_SAFE_INTEGER
Expand Down Expand Up @@ -316,29 +317,31 @@ export const useCounter = ({
tabIndex,
autoFocus: autoFocus,
disabled: disabled,
placeholder: placeholder,
onChange: onInputChange,
onFocus: onInputFocus,
onBlur: onInputBlur,
onKeyDown: onInputKeyDown,
onWheel: onInputWheel,
}
}, [
autoFocus,
disabled,
formatter,
focused,
formattedValue,
formatter,
maxProp,
inputValue,
prefixCls,
parsedValue,
minProp,
onInputBlur,
maxProp,
tabIndex,
autoFocus,
disabled,
placeholder,
onInputChange,
onInputFocus,
onInputBlur,
onInputKeyDown,
onInputWheel,
parsedValue,
prefixCls,
tabIndex,
inputValue,
])

const getMinusButtonProps = useCallback(() => {
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/number-input/src/styles/number-input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ $prefix: '#{$component-prefix}-number-input' !default;
color: inherit;
text-align: left;
padding: 0 use-spacing(6);

&::placeholder {
color: use-color('gray', 400);
}
}

&__suffix {
Expand Down
1 change: 1 addition & 0 deletions packages/ui/number-input/stories/basic.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const Basic = () => {
autoFocus
defaultValue={5}
min={1}
placeholder="请输入数字"
onChange={(v) => console.log('onChange', v)}
/>
</div>
Expand Down

0 comments on commit ec2c785

Please sign in to comment.