Skip to content

Commit bc42675

Browse files
authored
Merge branch 'master' into master
2 parents c25fd57 + 357d0a5 commit bc42675

File tree

9 files changed

+33
-126
lines changed

9 files changed

+33
-126
lines changed
Lines changed: 5 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,6 @@
1-
name: CI
2-
3-
on:
4-
push:
5-
branches: [ master ]
6-
pull_request:
7-
branches: [ master ]
8-
1+
name: ✅ test
2+
on: [push, pull_request]
93
jobs:
10-
setup:
11-
runs-on: ubuntu-latest
12-
steps:
13-
- name: checkout
14-
uses: actions/checkout@master
15-
16-
- uses: actions/setup-node@v1
17-
with:
18-
node-version: '12'
19-
20-
- name: cache package-lock.json
21-
uses: actions/cache@v2
22-
with:
23-
path: package-temp-dir
24-
key: lock-${{ github.sha }}
25-
26-
- name: create package-lock.json
27-
run: npm i --package-lock-only
28-
29-
- name: hack for singe file
30-
run: |
31-
if [ ! -d "package-temp-dir" ]; then
32-
mkdir package-temp-dir
33-
fi
34-
cp package-lock.json package-temp-dir
35-
36-
- name: cache node_modules
37-
id: node_modules_cache_id
38-
uses: actions/cache@v2
39-
with:
40-
path: node_modules
41-
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
42-
43-
- name: install
44-
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
45-
run: npm ci
46-
47-
lint:
48-
runs-on: ubuntu-latest
49-
steps:
50-
- name: checkout
51-
uses: actions/checkout@master
52-
53-
- name: restore cache from package-lock.json
54-
uses: actions/cache@v2
55-
with:
56-
path: package-temp-dir
57-
key: lock-${{ github.sha }}
58-
59-
- name: restore cache from node_modules
60-
uses: actions/cache@v2
61-
with:
62-
path: node_modules
63-
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
64-
65-
- name: lint
66-
run: npm run lint
67-
68-
needs: setup
69-
70-
compile:
71-
runs-on: ubuntu-latest
72-
steps:
73-
- name: checkout
74-
uses: actions/checkout@master
75-
76-
- name: restore cache from package-lock.json
77-
uses: actions/cache@v2
78-
with:
79-
path: package-temp-dir
80-
key: lock-${{ github.sha }}
81-
82-
- name: restore cache from node_modules
83-
uses: actions/cache@v2
84-
with:
85-
path: node_modules
86-
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
87-
88-
- name: compile
89-
run: npm run compile
90-
91-
needs: setup
92-
93-
coverage:
94-
runs-on: ubuntu-latest
95-
steps:
96-
- name: checkout
97-
uses: actions/checkout@master
98-
99-
- name: restore cache from package-lock.json
100-
uses: actions/cache@v2
101-
with:
102-
path: package-temp-dir
103-
key: lock-${{ github.sha }}
104-
105-
- name: restore cache from node_modules
106-
uses: actions/cache@v2
107-
with:
108-
path: node_modules
109-
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
110-
111-
- name: coverage
112-
run: npm test -- --coverage && bash <(curl -s https://codecov.io/bash)
113-
114-
needs: setup
4+
test:
5+
uses: react-component/rc-test/.github/workflows/test.yml@main
6+
secrets: inherit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ docs-dist/
4040
.dumi/tmp
4141
.dumi/tmp-production
4242

43+
bun.lockb

bunfig.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[install]
2+
peer = false

docs/demo/input-control.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* eslint no-console:0 */
22
import React from 'react';
3+
import type { ValueType} from 'rc-input-number'
34
import InputNumber from 'rc-input-number';
45
import '../../assets/index.less';
56

@@ -9,7 +10,7 @@ export default () => {
910

1011
return (
1112
<div>
12-
<InputNumber
13+
<InputNumber<ValueType>
1314
value={value}
1415
max={999}
1516
onChange={(newValue) => {

docs/demo/simple.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default () => {
2929
readOnly={readOnly}
3030
disabled={disabled}
3131
keyboard={keyboard}
32-
wheel={wheel}
32+
changeOnWheel={wheel}
3333
stringMode={stringMode}
3434
/>
3535
<p>

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rc-input-number",
3-
"version": "9.0.0",
3+
"version": "9.2.0",
44
"description": "React input-number component",
55
"keywords": [
66
"react",
@@ -49,14 +49,14 @@
4949
"@babel/runtime": "^7.10.1",
5050
"@rc-component/mini-decimal": "^1.0.1",
5151
"classnames": "^2.2.5",
52-
"rc-input": "~1.5.0",
52+
"rc-input": "~1.6.0",
5353
"rc-util": "^5.40.1"
5454
},
5555
"devDependencies": {
5656
"@rc-component/father-plugin": "^1.0.1",
5757
"@swc-node/jest": "^1.5.5",
5858
"@testing-library/jest-dom": "^6.1.5",
59-
"@testing-library/react": "^14.0.0",
59+
"@testing-library/react": "^16.0.0",
6060
"@types/classnames": "^2.2.9",
6161
"@types/jest": "^29.2.4",
6262
"@types/react": "^18.0.26",
@@ -67,16 +67,16 @@
6767
"cross-env": "^7.0.3",
6868
"dumi": "^2.0.13",
6969
"eslint": "^8.54.0",
70-
"eslint-plugin-jest": "^27.6.0",
71-
"eslint-plugin-unicorn": "^50.0.1",
70+
"eslint-plugin-jest": "^27.2.1",
71+
"eslint-plugin-unicorn": "^55.0.0",
7272
"expect.js": "~0.3.1",
7373
"father": "^4.1.1",
7474
"glob": "^9.2.1",
7575
"husky": "^8.0.3",
7676
"jest-environment-jsdom": "^29.3.1",
7777
"less": "^4.1.3",
7878
"lint-staged": "^15.1.0",
79-
"np": "^9.2.0",
79+
"np": "^10.0.5",
8080
"rc-test": "^7.0.14",
8181
"rc-tooltip": "^6.0.1",
8282
"react": "^18.2.0",

src/hooks/useCursor.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ export default function useCursor(
5050

5151
let startPos = value.length;
5252

53-
if (value.endsWith(afterTxt)) {
54-
startPos = value.length - selectionRef.current.afterTxt.length;
55-
} else if (value.startsWith(beforeTxt)) {
53+
if (value.startsWith(beforeTxt)) {
5654
startPos = beforeTxt.length;
55+
} else if (value.endsWith(afterTxt)) {
56+
startPos = value.length - selectionRef.current.afterTxt.length;
5757
} else {
5858
const beforeLastChar = beforeTxt[start - 1];
5959
const newIndex = value.indexOf(beforeLastChar, start - 1);

tests/cursor.test.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,14 @@ describe('InputNumber.Cursor', () => {
107107
});
108108
});
109109
});
110+
111+
describe('append string', () => {
112+
it('position caret before appended characters', () => {
113+
const { container } = render(<InputNumber formatter={(value) => `${value}%`} parser={(value) => value.replace('%', '')} />);
114+
const input = container.querySelector('input');
115+
fireEvent.focus(input);
116+
fireEvent.change(input,{ target: { value: '5' } });
117+
expect(cursorInput(input)).toEqual(1);
118+
});
119+
});
110120
});

tests/props.test.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react';
22
import '@testing-library/jest-dom';
33
import { render, fireEvent } from '@testing-library/react';
44
import KeyCode from 'rc-util/lib/KeyCode';
5+
import type { ValueType } from '../src'
56
import InputNumber from '../src';
67

78
describe('InputNumber.Props', () => {
@@ -275,7 +276,7 @@ describe('InputNumber.Props', () => {
275276
});
276277

277278
it('default value can be a string greater than 16 characters', () => {
278-
const { container } = render(<InputNumber max={10} defaultValue='-3.637978807091713e-12' />);
279+
const { container } = render(<InputNumber<ValueType> max={10} defaultValue='-3.637978807091713e-12' />);
279280
const input = container.querySelector('input');
280281
expect(input.value).toEqual('-0.000000000003637978807091713');
281282
});
@@ -303,7 +304,7 @@ describe('InputNumber.Props', () => {
303304
});
304305

305306
it('value can be a string greater than 16 characters', () => {
306-
const { container } = render(<InputNumber max={10} value='-3.637978807091713e-12' />);
307+
const { container } = render(<InputNumber<ValueType> max={10} value='-3.637978807091713e-12' />);
307308
const input = container.querySelector('input');
308309
expect(input.value).toEqual('-0.000000000003637978807091713');
309310
});

0 commit comments

Comments
 (0)