Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
afc163 authored Nov 29, 2024
2 parents 3686094 + c0dd6ed commit 6379138
Show file tree
Hide file tree
Showing 19 changed files with 975 additions and 375 deletions.
6 changes: 6 additions & 0 deletions .dumirc.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { defineConfig } from 'dumi';

const basePath = process.env.GH_PAGES ? '/input/' : '/';
const publicPath = process.env.GH_PAGES ? '/input/' : '/';

export default defineConfig({
mfsu: false,
favicons: ['https://avatars0.githubusercontent.com/u/9441414?s=200&v=4'],
themeConfig: {
name: 'Input',
logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
},
outputPath: '.doc',
base: basePath,
publicPath,
});
118 changes: 5 additions & 113 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,114 +1,6 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

name: ✅ test
on: [push, pull_request]
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@master

- uses: actions/setup-node@v1
with:
node-version: '12'

- name: cache package-lock.json
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: create package-lock.json
run: npm i --package-lock-only

- name: hack for singe file
run: |
if [ ! -d "package-temp-dir" ]; then
mkdir package-temp-dir
fi
cp package-lock.json package-temp-dir
- name: cache node_modules
id: node_modules_cache_id
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: install
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
run: npm ci

lint:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@master

- name: restore cache from package-lock.json
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: lint
run: npm run lint

needs: setup

compile:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@master

- name: restore cache from package-lock.json
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: compile
run: npm run compile

needs: setup

coverage:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@master

- name: restore cache from package-lock.json
uses: actions/cache@v2
with:
path: package-temp-dir
key: lock-${{ github.sha }}

- name: restore cache from node_modules
uses: actions/cache@v2
with:
path: node_modules
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}

- name: coverage
run: npm test -- --coverage && bash <(curl -s https://codecov.io/bash)

needs: setup
test:
uses: react-component/rc-test/.github/workflows/test.yml@main
secrets: inherit
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ dist/
# dumi
.dumi/tmp
.dumi/tmp-production
.node
bun.lockb
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
# rc-input ⌨️

[![NPM version][npm-image]][npm-url] [![npm download][download-image]][download-url] [![dumi](https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square)](https://github.com/umijs/dumi) [![build status][github-actions-image]][github-actions-url] [![Codecov][codecov-image]][codecov-url] [![Dependencies][david-image]](david-url) [![DevDependencies][david-dev-image]][david-dev-url] [![bundle size][bundlephobia-image]][bundlephobia-url]
[![NPM version][npm-image]][npm-url]
[![npm download][download-image]][download-url]
[![build status][github-actions-image]][github-actions-url]
[![Codecov][codecov-image]][codecov-url]
[![bundle size][bundlephobia-image]][bundlephobia-url]
[![dumi][dumi-image]][dumi-url]

[npm-image]: http://img.shields.io/npm/v/rc-input.svg?style=flat-square
[npm-url]: http://npmjs.org/package/rc-input
[npm-url]: http://npmjs.org/package/rc-select
[travis-image]: https://img.shields.io/travis/react-component/input/master?style=flat-square
[travis-url]: https://travis-ci.com/react-component/input
[github-actions-image]: https://github.com/react-component/input/workflows/CI/badge.svg
[github-actions-url]: https://github.com/react-component/input/actions
[codecov-image]: https://img.shields.io/codecov/c/github/react-component/input/master.svg?style=flat-square
[codecov-url]: https://codecov.io/gh/react-component/input/branch/master
[codecov-url]: https://app.codecov.io/gh/react-component/input
[david-url]: https://david-dm.org/react-component/input
[david-image]: https://david-dm.org/react-component/input/status.svg?style=flat-square
[david-dev-url]: https://david-dm.org/react-component/input?type=dev
[david-dev-image]: https://david-dm.org/react-component/input/dev-status.svg?style=flat-square
[download-image]: https://img.shields.io/npm/dm/rc-input.svg?style=flat-square
[download-url]: https://npmjs.org/package/rc-input
[bundlephobia-url]: https://bundlephobia.com/result?p=rc-input
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-input
[download-image]: https://img.shields.io/npm/dm/rc-select.svg?style=flat-square
[download-url]: https://npmjs.org/package/rc-select
[bundlephobia-url]: https://bundlephobia.com/package/rc-select
[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/rc-select
[dumi-url]: https://github.com/umijs/dumi
[dumi-image]: https://img.shields.io/badge/docs%20by-dumi-blue?style=flat-square

## Install

Expand Down
4 changes: 4 additions & 0 deletions assets/index.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.rc-input {
&-out-of-range {
color: red;
}

&-affix-wrapper {
padding: 2px 8px;
overflow: hidden;
Expand Down
2 changes: 2 additions & 0 deletions bunfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[install]
peer = false
2 changes: 1 addition & 1 deletion docs/examples/addon.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Input from 'rc-input';
import type { FC } from 'react';
import React from 'react';
import '../../assets/index.less';
import Input from 'rc-input';

const Demo: FC = () => {
return (
Expand Down
62 changes: 60 additions & 2 deletions docs/examples/show-count.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,68 @@
import Input from 'rc-input';
import type { FC } from 'react';
import React from 'react';
import '../../assets/index.less';
import Input from 'rc-input';

const sharedHeadStyle: React.CSSProperties = {
margin: 0,
padding: 0,
};

const Demo: FC = () => {
return <Input prefixCls="rc-input" showCount />;
return (
<div
style={{
display: 'flex',
flexDirection: 'column',
gap: 16,
alignItems: 'start',
}}
>
<h3 style={sharedHeadStyle}>Native</h3>
<Input prefixCls="rc-input" showCount defaultValue="👨‍👩‍👧‍👦" />
<Input prefixCls="rc-input" showCount defaultValue="👨‍👩‍👧‍👦" maxLength={20} />
<h3 style={sharedHeadStyle}>Count</h3>
<h4 style={sharedHeadStyle}>Only Max</h4>
<Input
placeholder="count.max"
prefixCls="rc-input"
defaultValue="🔥"
count={{
show: true,
max: 5,
}}
/>
<h4 style={sharedHeadStyle}>Customize strategy</h4>
<Input
placeholder="Emoji count 1"
prefixCls="rc-input"
defaultValue="🔥"
count={{
show: true,
max: 5,
strategy: (val) => [...new Intl.Segmenter().segment(val)].length,
}}
/>
<h4 style={sharedHeadStyle}>Customize exceedFormatter</h4>
<Input
placeholder="Emoji count 1"
prefixCls="rc-input"
defaultValue="🔥"
count={{
show: true,
max: 5,
exceedFormatter: (val, { max }) => {
const segments = [...new Intl.Segmenter().segment(val)];

return segments
.filter((seg) => seg.index + seg.segment.length <= max)
.map((seg) => seg.segment)
.join('');
},
}}
/>
</div>
);
};

export default Demo;
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-input",
"version": "1.1.0",
"version": "1.6.4",
"description": "React input component",
"keywords": [
"react",
Expand Down Expand Up @@ -32,15 +32,15 @@
"docs:build": "dumi build",
"docs:deploy": "gh-pages -d .doc",
"compile": "father build && lessc assets/index.less assets/index.css",
"gh-pages": "npm run docs:build && npm run docs:deploy",
"gh-pages": "GH_PAGES=1 npm run docs:build && npm run docs:deploy",
"prepublishOnly": "npm run compile && np --yolo --no-publish",
"postpublish": "npm run gh-pages",
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
"pretty-quick": "pretty-quick",
"lint-staged": "lint-staged",
"test": "umi-test test",
"coverage": "father test --coverage",
"test": "rc-test",
"coverage": "rc-test --coverage",
"prepare": "husky install"
},
"dependencies": {
Expand All @@ -61,7 +61,7 @@
"cross-env": "^7.0.2",
"dumi": "^2.1.14",
"eslint": "^7.0.0",
"father": "^4",
"father": "^4.3.7",
"gh-pages": "^3.1.0",
"husky": "^8.0.1",
"less": "^3.10.3",
Expand All @@ -70,10 +70,10 @@
"prettier": "^2.0.5",
"pretty-quick": "^3.0.0",
"rc-dialog": "^9.1.0",
"rc-test": "^7.0.15",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"typescript": "^4.0.5",
"umi-test": "^1.9.7"
"typescript": "^4.0.5"
},
"peerDependencies": {
"react": ">=16.0.0",
Expand Down
Loading

0 comments on commit 6379138

Please sign in to comment.