├── .commitlintrc.js ├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ └── release_checklist.md └── PULL_REQUEST_TEMPLATE │ ├── pr_cn.md │ └── pr_en.md ├── .gitignore ├── .prettierignore ├── .prettierrc ├── .stylelintrc.js ├── .travis.yml ├── .umirc.ts ├── .vscode └── settings.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── components ├── alert │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── index.test.tsx.snap │ │ └── index.test.tsx │ ├── alert.tsx │ ├── demos │ │ ├── closable.tsx │ │ ├── description.tsx │ │ └── type.tsx │ ├── index.md │ ├── index.tsx │ └── style │ │ ├── _mixins.scss │ │ ├── index.scss │ │ └── index.tsx ├── auto-complete │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── index.test.tsx.snap │ │ └── index.test.tsx │ ├── autoComplete.tsx │ ├── demos │ │ ├── ajaxSearch.tsx │ │ ├── base.tsx │ │ └── renderOption.tsx │ ├── index.md │ ├── index.tsx │ └── style │ │ └── index.scss ├── button │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── index.test.tsx.snap │ │ └── index.test.tsx │ ├── button.tsx │ ├── demos │ │ ├── block.tsx │ │ ├── disabled.tsx │ │ ├── size.tsx │ │ └── type.tsx │ ├── index.md │ ├── index.tsx │ └── style │ │ ├── _mixins.scss │ │ ├── index.scss │ │ └── index.tsx ├── hooks │ ├── useClickOutside.ts │ └── useDebounce.ts ├── index.tsx ├── input │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── index.test.tsx.snap │ │ └── index.test.tsx │ ├── demos │ │ ├── base.tsx │ │ ├── disabled.tsx │ │ ├── icon.tsx │ │ ├── prefix-suffix.tsx │ │ └── size.tsx │ ├── index.md │ ├── index.tsx │ ├── input.tsx │ └── style │ │ └── index.scss ├── menu │ ├── MenuContext.ts │ ├── MenuItem.tsx │ ├── SubMenu.tsx │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── index.test.tsx.snap │ │ └── index.test.tsx │ ├── demos │ │ ├── defaultOpenKeys.tsx │ │ ├── horizontal.tsx │ │ ├── inline.tsx │ │ └── mode.tsx │ ├── index.md │ ├── index.tsx │ ├── menu.tsx │ └── style │ │ ├── index.scss │ │ └── index.tsx ├── select │ ├── Option.tsx │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── index.test.tsx.snap │ │ └── index.test.tsx │ ├── demos │ │ ├── base.tsx │ │ ├── disabled.tsx │ │ └── multiple.tsx │ ├── index.md │ ├── index.tsx │ ├── select.tsx │ └── style │ │ ├── index.scss │ │ └── index.tsx ├── style │ ├── core │ │ ├── _motion.scss │ │ ├── _normalize.scss │ │ └── index.scss │ ├── index.scss │ ├── index.tsx │ ├── mixins │ │ ├── _animation.scss │ │ ├── _clearfix.scss │ │ ├── _common.scss │ │ └── index.scss │ └── theme │ │ ├── _default.scss │ │ └── index.scss ├── tabs │ ├── TabPane.tsx │ ├── Tabs.tsx │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── index.test.tsx.snap │ │ └── index.test.tsx │ ├── demos │ │ ├── base.tsx │ │ ├── disabled.tsx │ │ └── type.tsx │ ├── index.md │ ├── index.tsx │ └── style │ │ ├── index.scss │ │ └── index.tsx ├── tag │ ├── __tests__ │ │ ├── __snapshots__ │ │ │ └── index.test.tsx.snap │ │ └── index.test.tsx │ ├── demos │ │ ├── base.tsx │ │ ├── color.tsx │ │ └── size.tsx │ ├── index.md │ ├── index.tsx │ ├── style │ │ ├── _mixins.scss │ │ ├── index.scss │ │ └── index.tsx │ └── tag.tsx └── transition │ ├── index.tsx │ └── transition.tsx ├── docs ├── guide │ ├── README.md │ └── contribute.md └── index.md ├── jest.config.js ├── package.json ├── scripts └── jest │ └── setup.ts ├── tests └── utils.ts ├── tsconfig.build.json ├── tsconfig.json ├── typings.d.ts └── yarn.lock /.commitlintrc.js: -------------------------------------------------------------------------------- 1 | /** 2 | * build : 改变了build工具 3 | * ci : 持续集成 4 | * chore : 构建过程或辅助工具的变动 5 | * feat : 新功能 6 | * docs : 仅文档新增/改动 7 | * fix : 修复bug 8 | * perf : 性能优化 9 | * refactor : 某个已有功能重构 10 | * revert : 撤销上一次的 commit 11 | * style : 代码格式改变 12 | * test : 增加测试 13 | */ 14 | module.exports = { 15 | extends: ['@commitlint/config-conventional'], 16 | rules: { 17 | 'type-enum': [ 18 | 2, 19 | 'always', 20 | [ 21 | 'build', 22 | 'ci', 23 | 'chore', 24 | 'docs', 25 | 'feat', 26 | 'fix', 27 | 'perf', 28 | 'refactor', 29 | 'revert', 30 | 'style', 31 | 'test', 32 | ], 33 | ], 34 | }, 35 | } 36 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [Makefile] 16 | indent_style = tab 17 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /dist 3 | /doc-list 4 | /src 5 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | browser: true, 4 | es2021: true, 5 | jest: true, 6 | }, 7 | extends: ['airbnb', 'plugin:react/recommended', 'prettier/react'], 8 | parser: '@typescript-eslint/parser', 9 | parserOptions: { 10 | ecmaFeatures: { 11 | jsx: true, 12 | }, 13 | ecmaVersion: 12, 14 | sourceType: 'module', 15 | }, 16 | plugins: ['react', '@typescript-eslint', 'react-hooks'], 17 | rules: { 18 | semi: 0, 19 | 'react/jsx-filename-extension': 0, 20 | 'react/prop-types': 0, 21 | 'react/button-has-type': 0, 22 | 'react/display-name': 0, 23 | 'react/jsx-props-no-spreading': 0, 24 | 25 | 'jsx-a11y/click-events-have-key-events': 0, 26 | 'jsx-a11y/no-static-element-interactions': 0, 27 | 'jsx-a11y/no-noninteractive-element-interactions': 0, 28 | 29 | indent: 0, 30 | 'no-use-before-define': 0, 31 | 'no-unused-vars': 0, 32 | 'implicit-arrow-linebreak': 0, 33 | 'consistent-return': 0, 34 | 'arrow-parens': 0, 35 | 'object-curly-newline': 0, 36 | 'operator-linebreak': 0, 37 | 'import/no-extraneous-dependencies': 0, 38 | 'import/extensions': 0, 39 | 'import/no-unresolved': 0, 40 | 'import/prefer-default-export': 0, 41 | }, 42 | } 43 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # 参与共建 2 | 3 | 想要给 Monki UI 贡献自己的一份力量? 4 | 5 | 我写了一份 **[贡献指南](https://jacky-summer.github.io/monki-ui/guide/contribute)** 来帮助你开始。 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/release_checklist.md: -------------------------------------------------------------------------------- 1 | # Release Checklist ✍️ 2 | 3 | > These steps should be performed when making a new release on [monki-ui](https://github.com/Jacky-Summer/monki-ui). 4 | 5 | ## Deploy to Prod 6 | 7 | - [ ] Create `release/${version-number}` from development branch and push to origin. 8 | - [ ] Create `chore/bump-${version-number}` from above created `release/${version-number}`. 9 | - [ ] Execute `yarn bump-version` to generate CHANGELOG in the `chore/bump-${version-number}` branch and push it to origin. 10 | - [ ] Create a PR to merge `chore/bump-${version-number}` into `release/${version-number}`. ( if have Staging site, the release branch should automatically deployed to the Stag. This personal open source project —— [monki-ui](https://github.com/Jacky-Summer/monki-ui) doesn't have Staging site. ) 11 | - [ ] Create a PR to merge `release/${version-number}` into master branch, it will be automatically deployed in Prod. 12 | 13 | ## Post-release 14 | 15 | - [ ] PR to merge back master to development. 16 | - [ ] Create a release in GitHub, tag release version on the master branch and fill the content from corresponding CHANGELOG. 17 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/pr_cn.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | [[English Template / 英文模板](https://github.com/Jacky-Summer/monki-ui/blob/development/.github/PULL_REQUEST_TEMPLATE/pr_en.md)] 9 | 10 | ### 🤔 这个变动的性质是? 11 | 12 | - [ ] 新特性提交 13 | - [ ] 日常 bug 修复 14 | - [ ] 站点、文档改进 15 | - [ ] 演示代码改进 16 | - [ ] 组件样式/交互改进 17 | - [ ] TypeScript 定义更新 18 | - [ ] 包体积优化 19 | - [ ] 性能优化 20 | - [ ] 功能增强 21 | - [ ] 重构 22 | - [ ] 代码风格优化 23 | - [ ] 测试用例 24 | - [ ] 其他改动(是关于什么的改动?) 25 | 26 | ### 🔗 相关 Issue 27 | 28 | 31 | 32 | ### 💡 需求背景和解决方案 33 | 34 | 39 | 40 | ### 📝 更新日志 41 | 42 | 45 | 46 | | 语言 | 更新描述 | 47 | | ------- | -------- | 48 | | 🇺🇸 英文 | | 49 | | 🇨🇳 中文 | | 50 | 51 | ### PR 标题与 commit 信息开头请遵循如下规范: 52 | 53 | - ✨ feat:新功能 54 | - 🔧 chore:构建过程或辅助工具的变动 55 | - 📝 docs:仅文档新增/改动 56 | - 🐛 fix:修复 bug 57 | - 🚀 perf:性能优化 58 | - 🔨 refactor:某个已有功能重构 59 | - ⏪ revert:代码回滚 60 | - 🎨 style:代码格式改变 61 | - ✅ test:添加缺失的测试或更正现有的测试 62 | - 📦 build:改变了 build 工具 63 | - 👷 ci:持续集成 64 | 65 | 🎉 release(只适用于分支标题):发布版本提交 66 | 67 | ### ☑️ 请求合并前的自查清单 68 | 69 | ⚠️ 请自检并全部**勾选全部选项**。⚠️ 70 | 71 | - [ ] 文档已补充或无须补充 72 | - [ ] 代码演示已提供或无须提供 73 | - [ ] TypeScript 定义已补充或无须补充 74 | - [ ] Changelog 已提供或无须提供 75 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE/pr_en.md: -------------------------------------------------------------------------------- 1 | 7 | 8 | [[中文版模板 / Chinese template](https://github.com/Jacky-Summer/monki-ui/blob/development/.github/PULL_REQUEST_TEMPLATE/pr_cn.md)] 9 | 10 | ### 🤔 This is a ... 11 | 12 | - [ ] New feature 13 | - [ ] Bug fix 14 | - [ ] Site / documentation update 15 | - [ ] Demo update 16 | - [ ] Component style update 17 | - [ ] TypeScript definition update 18 | - [ ] Bundle size optimization 19 | - [ ] Performance optimization 20 | - [ ] Enhancement feature 21 | - [ ] Refactoring 22 | - [ ] Code style optimization 23 | - [ ] Test Case 24 | - [ ] Other (about what?) 25 | 26 | ### 🔗 Related issue link 27 | 28 | 31 | 32 | ### 💡 Background and solution 33 | 34 | 39 | 40 | ### 📝 Changelog 41 | 42 | 45 | 46 | | Language | Changelog | 47 | | ---------- | --------- | 48 | | 🇺🇸 English | | 49 | | 🇨🇳 Chinese | | 50 | 51 | ### At the begining of PR title and commit message, please follow below standard: 52 | 53 | - ✨ feat:A new feature 54 | - 🔧 chore:updating chore tasks etc 55 | - 📝 docs:Documentation only changes 56 | - 🐛 fix:A bug fix 57 | - 🚀 perf:A code change that improves performance 58 | - 🔨 refactor:A code change that neither fixes a bug nor adds a feature 59 | - ⏪ revert:code revert to specific commit or version 60 | - 🎨 style:Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) 61 | - ✅ test:Adding missing tests or correcting existing tests 62 | - 📦 build:Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm) 63 | - 👷 ci:Changes to our CI configuration files and scripts (example scopes: Travis, Circle) 64 | 65 | 🎉 release(only used in PR title):submit release version 66 | 67 | ### ☑️ Self Check before Merge 68 | 69 | ⚠️ Please check all items below before review. ⚠️ 70 | 71 | - [ ] Doc is updated/provided or not needed 72 | - [ ] Demo is updated/provided or not needed 73 | - [ ] TypeScript definition is updated/provided or not needed 74 | - [ ] Changelog is provided or not needed 75 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /npm-debug.log* 6 | /yarn-error.log 7 | /package-lock.json 8 | 9 | # production 10 | /dist 11 | /docs-dist 12 | 13 | # misc 14 | .DS_Store 15 | 16 | # umi 17 | .umi 18 | .umi-production 19 | .umi-test 20 | .env.local 21 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | **/*.svg 2 | **/*.ejs 3 | **/*.html 4 | package.json 5 | .umi 6 | .umi-production 7 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "tabWidth": 2, 4 | "endOfLine": "lf", 5 | "trailingComma": "all", 6 | "printWidth": 90, 7 | "arrowParens": "avoid", 8 | "semi": false, 9 | "bracketSpacing": true, 10 | "overrides": [ 11 | { 12 | "files": ".prettierrc", 13 | "options": { "parser": "json" } 14 | } 15 | ] 16 | } 17 | -------------------------------------------------------------------------------- /.stylelintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [ 3 | 'stylelint-config-standard', 4 | 'stylelint-config-rational-order', 5 | 'stylelint-config-prettier', 6 | ], 7 | plugins: [ 8 | 'stylelint-order', 9 | 'stylelint-config-rational-order/plugin', 10 | 'stylelint-scss', 11 | ], 12 | rules: { 13 | indentation: 2, // 缩进2个空格 14 | 'string-quotes': 'single', 15 | 'number-leading-zero': 'never', 16 | 'declaration-block-trailing-semicolon': 'always', 17 | 'max-empty-lines': 1, 18 | 'block-closing-brace-empty-line-before': ['never'], 19 | 'declaration-empty-line-before': ['never', { ignore: ['after-declaration'] }], 20 | 'length-zero-no-unit': true, 21 | 'no-eol-whitespace': true, 22 | 'no-missing-end-of-source-newline': true, 23 | 'comment-whitespace-inside': 'always', 24 | 'selector-combinator-space-before': 'always', 25 | 'block-opening-brace-space-before': 'always', 26 | 'comment-whitespace-inside': 'always', 27 | 'declaration-colon-space-after': 'always', 28 | 'declaration-colon-space-before': 'never', 29 | 'declaration-block-semicolon-space-before': 'never', 30 | 'function-comma-space-after': 'always', 31 | 'selector-combinator-space-before': 'always', 32 | 'selector-combinator-space-after': 'always', 33 | 'selector-list-comma-space-after': 'always', 34 | 'selector-descendant-combinator-no-non-space': true, 35 | 'at-rule-no-unknown': null, 36 | 'scss/at-rule-no-unknown': true, 37 | }, 38 | syntax: 'scss', 39 | ignoreFiles: [ 40 | 'src/**/*', 41 | 'node_modules/**/*', 42 | 'dist/**/*', 43 | 'docs-dist/**/*', 44 | 'docs/**/*', 45 | 'tests/**/*', 46 | '**/*.png', 47 | '**/*.jpg', 48 | '**/*.jpeg', 49 | '**/*.PNG', 50 | '**/*.JPG', 51 | '**/*.JPEG', 52 | '**/*.svg', 53 | '**/*.eot', 54 | '**/*.svg', 55 | '**/*.ttf', 56 | '**/*.woff', 57 | '**/*.woff2', 58 | '**/*.otf', 59 | '**/*.txt', 60 | '**/*.js', 61 | '**/*.json', 62 | '**/*.font', 63 | '**/*.md', 64 | '**/*.min.*', 65 | '.*', 66 | ], 67 | } 68 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | node_js: 4 | - 12 5 | 6 | cache: yarn 7 | 8 | install: 9 | - yarn 10 | script: 11 | - yarn test 12 | - yarn build 13 | 14 | jobs: 15 | include: 16 | - stage: general 17 | if: branch = development AND commit_message !~ /\[skip publish\]/ 18 | 19 | before_deploy: 20 | - yarn bump-version:prerelease 21 | - yarn build 22 | 23 | deploy: 24 | - provider: npm 25 | email: $NPM_EMAIL 26 | api_key: $NPM_TOKEN 27 | skip_cleanup: true 28 | on: 29 | branch: development 30 | tag: next 31 | 32 | - stage: general 33 | if: branch = master AND commit_message !~ /\[skip publish\]/ 34 | 35 | before_deploy: 36 | - > 37 | if ! [ "${BEFORE_DEPLOY_RUN}" ]; then 38 | export BEFORE_DEPLOY_RUN=1; 39 | git config user.email "builds@travis-ci.com" 40 | git config user.name "Travis CI" 41 | yarn bump-version 42 | git push --verbose --no-verify --follow-tags ${OWNER}${GH_TOKEN}@${GH_REF} HEAD:master 43 | yarn build 44 | fi 45 | deploy: 46 | - provider: pages 47 | github_token: $GH_TOKEN 48 | skip_cleanup: true 49 | keep_history: true 50 | local_dir: docs-dist 51 | on: 52 | branch: master 53 | 54 | - provider: npm 55 | email: $NPM_EMAIL 56 | api_key: $NPM_TOKEN 57 | skip_cleanup: true 58 | keep_history: true 59 | on: 60 | branch: master 61 | -------------------------------------------------------------------------------- /.umirc.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'dumi' 2 | 3 | export default defineConfig({ 4 | title: 'Monki UI', 5 | favicon: 'https://img.icons8.com/ultraviolet/2x/year-of-monkey.png', 6 | logo: 'https://img.icons8.com/ultraviolet/2x/year-of-monkey.png', 7 | base: '/monki-ui', 8 | publicPath: '/monki-ui/', 9 | outputPath: 'docs-dist', 10 | mode: 'site', 11 | exportStatic: {}, // 将所有路由输出为 HTML 目录结构,以免刷新页面时 404 12 | resolve: { 13 | includes: ['docs', 'components'], 14 | }, 15 | navs: [ 16 | null, 17 | { 18 | title: 'Github', 19 | path: 'https://github.com/Jacky-Summer/monki-ui', 20 | }, 21 | ], 22 | // more config: https://d.umijs.org/config 23 | }) 24 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "search.exclude": { 3 | "**/node_modules": true, 4 | "dist": true, 5 | "docs-dist": true, 6 | "yarn.lock": true, 7 | "src/.umi": true 8 | }, 9 | "editor.formatOnSave": true, 10 | "eslint.validate": [ 11 | "javascript", 12 | "javascriptreact", 13 | "typescript", 14 | "typescriptreact" 15 | ], 16 | "css.validate": false, 17 | "less.validate": false, 18 | "editor.codeActionsOnSave": { 19 | "source.fixAll.eslint": true, 20 | "source.fixAll.stylelint": true 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | ### [1.9.1](https://github.com/Jacky-Summer/monki-ui/compare/v1.9.0...v1.9.1) (2021-06-12) 6 | 7 | 8 | ### Bug Fixes 9 | 10 | * no need module ([#79](https://github.com/Jacky-Summer/monki-ui/issues/79)) ([c997dbe](https://github.com/Jacky-Summer/monki-ui/commit/c997dbe514feb0e082dc330c3e51c26df490d820)) 11 | 12 | ## [1.9.0](https://github.com/Jacky-Summer/monki-ui/compare/v1.8.0...v1.9.0) (2021-04-07) 13 | 14 | 15 | ### Features 16 | 17 | * add select component ([#74](https://github.com/Jacky-Summer/monki-ui/issues/74)) ([cd002b6](https://github.com/Jacky-Summer/monki-ui/commit/cd002b6d2146ab6434f02c1515c01440e8e99aa2)) 18 | 19 | 20 | ### Bug Fixes 21 | 22 | * select component export name typo ([#76](https://github.com/Jacky-Summer/monki-ui/issues/76)) ([d34d279](https://github.com/Jacky-Summer/monki-ui/commit/d34d2799ea9ee939e05dce89bbf7caeb1812c1f2)) 23 | 24 | ## [1.8.0](https://github.com/Jacky-Summer/monki-ui/compare/v1.7.2...v1.8.0) (2021-03-14) 25 | 26 | 27 | ### Features 28 | 29 | * tag component ([#70](https://github.com/Jacky-Summer/monki-ui/issues/70)) ([c1bd1eb](https://github.com/Jacky-Summer/monki-ui/commit/c1bd1ebcddea4b525df8dfef4659517ee2ee03b7)) 30 | 31 | ### [1.7.2](https://github.com/Jacky-Summer/monki-ui/compare/v1.7.1...v1.7.2) (2021-02-28) 32 | 33 | 34 | ### Bug Fixes 35 | 36 | * before deploy exec twice ([#68](https://github.com/Jacky-Summer/monki-ui/issues/68)) ([e009221](https://github.com/Jacky-Summer/monki-ui/commit/e00922158a4e223b34e69b039d2dbc149e55c7b6)) 37 | 38 | ### [1.7.1](https://github.com/Jacky-Summer/monki-ui/compare/v1.7.0...v1.7.1) (2021-02-28) 39 | 40 | ## [1.7.0](https://github.com/Jacky-Summer/monki-ui/compare/v1.6.0...v1.7.0) (2021-02-28) 41 | 42 | 43 | ### Features 44 | 45 | * add AutoComplete component ([#57](https://github.com/Jacky-Summer/monki-ui/issues/57)) ([b3523d3](https://github.com/Jacky-Summer/monki-ui/commit/b3523d38303411bbb86d5fc5b0ea9c381470a01a)) 46 | 47 | ## [1.6.0](https://github.com/Jacky-Summer/monki-ui/compare/v1.5.0...v1.6.0) (2021-01-30) 48 | 49 | ### Features 50 | 51 | - add input component ([#52](https://github.com/Jacky-Summer/monki-ui/issues/52)) ([1cab7a1](https://github.com/Jacky-Summer/monki-ui/commit/1cab7a1d5b4708f5b1e55dfd2b8c78a74efff480)) 52 | 53 | ### Bug Fixes 54 | 55 | - stylelint scss strict rules to check ([#51](https://github.com/Jacky-Summer/monki-ui/issues/51)) ([603d0b7](https://github.com/Jacky-Summer/monki-ui/commit/603d0b7a81c391c988d0eb1c7136fd0f8f113c98)) 56 | 57 | ## [1.5.0](https://github.com/Jacky-Summer/monki-ui/compare/v1.4.0...v1.5.0) (2021-01-01) 58 | 59 | ### Features 60 | 61 | - tabs component ([#45](https://github.com/Jacky-Summer/monki-ui/issues/45)) ([d806994](https://github.com/Jacky-Summer/monki-ui/commit/d806994daa07afc50cb2d926033c183d0f253ff8)) 62 | 63 | ## [1.4.0](https://github.com/Jacky-Summer/monki-ui/compare/v1.2.0...v1.4.0) (2020-12-05) 64 | 65 | ### Features 66 | 67 | - menu component ([#34](https://github.com/Jacky-Summer/monki-ui/issues/34)) ([0ebaf77](https://github.com/Jacky-Summer/monki-ui/commit/0ebaf77d6402eab075e61a3f06984b052042c24a)) 68 | - upgrade react16 to react17 version ([#28](https://github.com/Jacky-Summer/monki-ui/issues/28)) ([695c6e4](https://github.com/Jacky-Summer/monki-ui/commit/695c6e4c8d3d7036ceae2683dd52a487cc36eeb9)) 69 | 70 | ## [1.3.0](https://github.com/Jacky-Summer/monki-ui/compare/v1.2.0...v1.3.0) (2020-11-29) 71 | 72 | ### Features 73 | 74 | - upgrade react16 to react17 version ([#28](https://github.com/Jacky-Summer/monki-ui/issues/28)) ([695c6e4](https://github.com/Jacky-Summer/monki-ui/commit/695c6e4c8d3d7036ceae2683dd52a487cc36eeb9)) 75 | 76 | ## [1.2.0](https://github.com/Jacky-Summer/monki-ui/compare/v1.0.0...v1.1.0) (2020-11-21) 77 | 78 | ### Features 79 | 80 | - add alert component ([#16](https://github.com/Jacky-Summer/monki-ui/issues/16)) ([561b52c](https://github.com/Jacky-Summer/monki-ui/commit/561b52cc1e4c13519e9651c477c9a6224bd39afd)) 81 | 82 | ## 1.0.0 (2020-11-14) 83 | 84 | ### Features 85 | 86 | - init project ([a828595](https://github.com/Jacky-Summer/monki-ui/commit/a828595a7124ff585062957035e17c35a8b903d4)) 87 | - style structure and whole ui style ([0ef134b](https://github.com/Jacky-Summer/monki-ui/commit/0ef134b3ce9943b57fd09eab3c7ba47c01f6ead5)) 88 | - basic button component ([aacfa5f](https://github.com/Jacky-Summer/monki-ui/commit/aacfa5f078e4b74a18fb99a9dfe7a9259d6afa30)) 89 | - complete the button component ([ad23dda](https://github.com/Jacky-Summer/monki-ui/commit/ad23dda6e26617f5a69dc35f4348bc2841d4d4d1)) 90 | - monki ui lib entry ([699331d](https://github.com/Jacky-Summer/monki-ui/commit/699331d204b637f1cdc395a619af4738ae09f1e5)) 91 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 monki-ui 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
51 | This is some desc about the Alert 52 |
53 |{description}
} 41 | {closable && ( 42 | 43 |
17 |
18 | ## 含有辅助性文字介绍的警告提示
19 |
20 | 通过设置`description`属性。
21 |
22 |
23 |
24 | ## 可关闭的警告提示
25 |
26 | 设置`closable`属性和添加`onClose`方法可显示关闭按钮,点击并可关闭警告提示。
27 |
28 |
29 |
30 | ## API
31 |
32 | | 参数 | 说明 | 类型 | 默认值 |
33 | | ----------- | -------------------------------------------------------------------- | ----------------------- | --------- |
34 | | closable | 默认不显示关闭按钮 | boolean | - |
35 | | description | 警告提示的辅助性文字介绍 | ReactNode | - |
36 | | message | 警告提示内容 | ReactNode | - |
37 | | type | 指定警告提示的样式,有四种选择 `success`、`info`、`warning`、`error` | string | `warning` |
38 | | onClose | 关闭时触发的回调函数 | (e: MouseEvent) => void | - |
39 |
--------------------------------------------------------------------------------
/components/alert/index.tsx:
--------------------------------------------------------------------------------
1 | import Alert from './alert'
2 |
3 | export default Alert
4 |
--------------------------------------------------------------------------------
/components/alert/style/_mixins.scss:
--------------------------------------------------------------------------------
1 | @mixin alert-style($background, $border, $color) {
2 | color: $color;
3 | background: $background;
4 | border-color: $border;
5 | }
6 |
--------------------------------------------------------------------------------
/components/alert/style/index.scss:
--------------------------------------------------------------------------------
1 | @import 'mixins';
2 |
3 | $alert-colors: (
4 | 'success': $success-100,
5 | 'info': $blue-100,
6 | 'warning': $warning-100,
7 | 'error': $danger-100,
8 | );
9 | .mk-alert {
10 | position: relative;
11 | margin-bottom: $alert-margin-bottom;
12 | padding: $alert-padding-y $alert-padding-x;
13 | border: $alert-border-width solid transparent;
14 | border-radius: $alert-border-radius;
15 | .mk-alert-close {
16 | position: absolute;
17 | top: 0;
18 | right: 0;
19 | padding: $alert-close-padding-y $alert-close-padding-x;
20 | color: $font-color-normal;
21 | font-size: $alert-description-font-size;
22 | cursor: pointer;
23 | }
24 |
25 | .mk-alert-desc {
26 | margin: $alert-description-top-margin 0 0;
27 | font-size: $alert-description-font-size;
28 | }
29 | }
30 | @each $color, $value in $alert-colors {
31 | .mk-alert-#{$color} {
32 | @include alert-style($value, darken($value, 5%), $font-color-normal);
33 |
34 | > p {
35 | color: $font-color-light;
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/components/alert/style/index.tsx:
--------------------------------------------------------------------------------
1 | import './index.scss'
2 |
--------------------------------------------------------------------------------
/components/auto-complete/__tests__/__snapshots__/index.test.tsx.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`AutoComplete test basic AutoComplete behavior 1`] = `
4 |
27 |
28 | ### 自定义渲染下拉选项
29 |
30 |
31 |
32 | ### ajax 请求下拉选项
33 |
34 |
35 |
36 | ### API
37 |
38 | | 参数 | 说明 | 类型 |
39 | | ------------ | ------------------------------------- | --------------- |
40 | | onSearch | 搜索补全项的时候调用 | function(value) |
41 | | onSelect | 被选中时调用,参数为选中项的 value 值 | function(value) |
42 | | renderOption | 自定义渲染下拉选项 | function(value) |
43 |
--------------------------------------------------------------------------------
/components/auto-complete/index.tsx:
--------------------------------------------------------------------------------
1 | import AutoComplete from './autoComplete'
2 |
3 | export default AutoComplete
4 |
--------------------------------------------------------------------------------
/components/auto-complete/style/index.scss:
--------------------------------------------------------------------------------
1 | .mk-auto-complete {
2 | position: relative;
3 | }
4 | .mk-suggestion-list {
5 | position: absolute;
6 | top: calc(100% + 8px);
7 | left: 0;
8 | z-index: 100;
9 | width: 100%;
10 | padding-left: 0;
11 | white-space: nowrap;
12 | list-style: none;
13 | background: $white;
14 | border: $menu-border-width solid $menu-border-color;
15 | box-shadow: $submenu-box-shadow;
16 | .suggestion-loading-icon {
17 | display: flex;
18 | align-items: center;
19 | justify-content: center;
20 | min-height: 75px;
21 |
22 | .anticon {
23 | font-size: 40px;
24 | }
25 | }
26 | .suggestion-item {
27 | padding: $menu-item-padding-y $menu-item-padding-x;
28 | color: $body-color;
29 | cursor: pointer;
30 | transition: $menu-transition;
31 | &.is-active {
32 | color: $white !important;
33 | background: $menu-item-active-color !important;
34 | }
35 | &:hover {
36 | color: $menu-item-active-color !important;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/components/button/__tests__/__snapshots__/index.test.tsx.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`Button component should render Buttons of different size correctly 1`] = `
4 |
17 |
18 | ### 按钮尺寸
19 |
20 | 尺寸`size`分为大、中、小,默认尺寸是中。
21 |
22 | `lg` | `md` | `sm`
23 |
24 |
25 |
26 | ### 不可用状态
27 |
28 | 添加 `disabled` 属性即可让按钮处于不可用状态,同时按钮样式也会改变。
29 |
30 |
31 |
32 | ### Block 按钮
33 |
34 | `block`属性将使按钮适合其父宽度,默认不设置。
35 |
36 |
37 |
38 | ### API
39 |
40 | 通过设置 Button 的属性来产生不同的按钮样式,推荐顺序为:`type` > `size` -> `disabled`。
41 |
42 | 按钮的属性说明如下:
43 |
44 | | 属性 | 说明 | 类型 | 默认值 |
45 | | -------- | ----------------------------------------------------- | ----------------------------------------------------------------------------------------- | --------- |
46 | | block | 将按钮宽度调整为其父宽度的选项 | boolean | false |
47 | | disabled | 按钮失效状态 | boolean | false |
48 | | href | 点击跳转的地址,指定此属性 button 的行为和 a 链接一致 | string | - |
49 | | htmlType | 设置 `button` 原生的 `type` 值 | string | `button` |
50 | | size | 设置按钮大小 | `lg` \| `md` \| `sm` | `md` |
51 | | type | 设置按钮类型 | `primary` \| `info` \| `warning` \| `danger` \| `dashed` \| `link` \| `text` \| `default` | `default` |
52 | | onClick | 点击按钮时的回调 | (event) => void | - |
53 |
54 | 支持原生 button 的其他所有属性。
55 |
--------------------------------------------------------------------------------
/components/button/index.tsx:
--------------------------------------------------------------------------------
1 | import Button from './button'
2 |
3 | export default Button
4 |
--------------------------------------------------------------------------------
/components/button/style/_mixins.scss:
--------------------------------------------------------------------------------
1 | @mixin button-size($padding-y, $padding-x, $font-size, $border-radius) {
2 | padding: $padding-y $padding-x;
3 | font-size: $font-size;
4 | border-radius: $border-radius;
5 | }
6 |
7 | @mixin button-style(
8 | $background,
9 | $border,
10 | $color,
11 | $hover-background: lighten($background, 7.5%),
12 | $hover-border: lighten($border, 10%),
13 | $hover-color: $color
14 | ) {
15 | color: $color;
16 | background: $background;
17 | border-color: $border;
18 | &:hover {
19 | color: $hover-color;
20 | background: $hover-background;
21 | border-color: $hover-border;
22 | }
23 | &:focus, &.focus {
24 | color: $hover-color;
25 | background: $hover-background;
26 | border-color: $hover-border;
27 | }
28 | &:disabled, &.disabled {
29 | color: $color;
30 | background: $background;
31 | border-color: $border;
32 | }
33 | }
34 |
35 | [id^='components-button-demo-'] .mk-btn {
36 | margin-right: 8px;
37 | margin-bottom: 12px;
38 | }
39 |
--------------------------------------------------------------------------------
/components/button/style/index.scss:
--------------------------------------------------------------------------------
1 | @import 'mixins';
2 |
3 | .mk-btn {
4 | position: relative;
5 | display: inline-block;
6 | color: $body-color;
7 | font-weight: $btn-font-weight;
8 | line-height: $btn-line-height;
9 | white-space: nowrap;
10 | text-align: center;
11 | vertical-align: middle;
12 | background-image: none;
13 | border: $btn-border-width solid transparent;
14 | box-shadow: $btn-box-shadow;
15 | cursor: pointer;
16 | transition: $btn-transition;
17 | @include button-size($btn-padding-y, $btn-padding-x, $btn-font-size, $border-radius);
18 | &.disabled, &[disabled] {
19 | box-shadow: none;
20 | cursor: not-allowed;
21 | opacity: $btn-disabled-opacity;
22 | > * {
23 | pointer-events: none;
24 | }
25 | }
26 | }
27 | // type
28 | .mk-btn-default {
29 | @include button-style($white, $gray-400, $body-color, $white, $primary, $primary);
30 | }
31 |
32 | .mk-btn-primary {
33 | @include button-style($primary, $primary, $white);
34 | }
35 |
36 | .mk-btn-info {
37 | @include button-style($info, $info, $white);
38 | }
39 |
40 | .mk-btn-warning {
41 | @include button-style($warning, $warning, $white);
42 | }
43 |
44 | .mk-btn-danger {
45 | @include button-style($danger, $danger, $white);
46 | }
47 |
48 | .mk-btn-text {
49 | @include button-style(transparent, transparent, $body-color);
50 | box-shadow: none;
51 | }
52 |
53 | .mk-btn-dashed {
54 | @include button-style($white, $gray-400, $body-color, $white, $primary, $primary);
55 | border-style: dotted;
56 | }
57 |
58 | .mk-btn-link {
59 | color: $btn-link-color;
60 | font-weight: $font-weight-normal;
61 | text-decoration: $link-decoration;
62 | background-color: transparent;
63 | box-shadow: none;
64 | &:hover {
65 | color: $btn-link-hover-color;
66 | text-decoration: $link-hover-decoration;
67 | }
68 | &:focus, &.focus {
69 | text-decoration: $link-hover-decoration;
70 | box-shadow: none;
71 | }
72 | &:disabled, &.disabled {
73 | color: $btn-link-disabled-color;
74 | pointer-events: none;
75 | }
76 | }
77 |
78 | // size
79 | .mk-btn-lg {
80 | @include button-size(
81 | $btn-padding-y-lg,
82 | $btn-padding-x-lg,
83 | $btn-font-size-lg,
84 | $btn-border-radius-lg
85 | );
86 | }
87 |
88 | .mk-btn-md {
89 | @include button-size(
90 | $btn-padding-y-md,
91 | $btn-padding-x-md,
92 | $btn-font-size-md,
93 | $btn-border-radius-md
94 | );
95 | }
96 |
97 | .mk-btn-sm {
98 | @include button-size(
99 | $btn-padding-y-sm,
100 | $btn-padding-x-sm,
101 | $btn-font-size-sm,
102 | $btn-border-radius-sm
103 | );
104 | }
105 |
106 | // shape
107 | .mk-btn-circle {
108 | min-width: 32px;
109 | padding-right: 0;
110 | padding-left: 0;
111 | text-align: center;
112 | border-radius: 50%;
113 | }
114 |
115 | .mk-btn-round {
116 | border-radius: 30%;
117 | }
118 |
119 | // block
120 | .mk-btn-block {
121 | width: 100%;
122 | }
123 |
124 | // icon
125 | // .mk-btn-icon-only {
126 | // width: 32px;
127 | // height: 32px;
128 | // padding: 2.4px 0;
129 | // font-size: 16px;
130 | // border-radius: 2px;
131 | // }
132 |
133 | // .mk-btn > .anticon + span,
134 | // .mk-btn > span + .anticon {
135 | // margin-left: 8px;
136 | // }
137 |
--------------------------------------------------------------------------------
/components/button/style/index.tsx:
--------------------------------------------------------------------------------
1 | import './index.scss'
2 |
--------------------------------------------------------------------------------
/components/hooks/useClickOutside.ts:
--------------------------------------------------------------------------------
1 | import { RefObject, useEffect } from 'react'
2 |
3 | function useClickOutside(ref: RefObject
20 |
21 | ### 三种大小
22 |
23 | 输入框定义了三种尺寸 size(大`lg`、默认`md`、小`sm`)
24 |
25 |
26 |
27 | ### 禁用
28 |
29 | 设置禁用状态 `disabled`,默认为 false
30 |
31 |
32 |
33 | ### 前缀与后缀
34 |
35 | 在输入框上添加前缀`prefix`或后缀`suffix`图标。
36 |
37 |
38 |
39 | ### 图标
40 |
41 | 如添加一个向下箭头的图标
42 |
43 |
44 |
45 | ### API
46 |
47 | | 参数 | 说明 | 类型 | 默认值 |
48 | | -------- | ---------------------------------------------- | -------------------- | ------ |
49 | | disabled | 是否禁用状态,默认为 false | boolean | false |
50 | | id | 输入框的 id | string | - |
51 | | prefix | 带有前缀图标的 input | ReactNode | - |
52 | | size | 控件大小。 | `lg` \| `md` \| `sm` | - |
53 | | suffix | 带有后缀图标的 input | ReactNode | - | |
54 | | type | 声明 input 类型,同原生 input 标签的 type 属性 | string | `text` |
55 | | value | 输入框内容 | string | - |
56 | | icon | 图标 | ReactNode | - |
57 | | onChange | 输入框内容变化时的回调 | function(e) | - |
58 |
59 | Input 的其他属性和 React 自带的 [input](https://facebook.github.io/react/docs/events.html#supported-events) 一致。
60 |
--------------------------------------------------------------------------------
/components/input/index.tsx:
--------------------------------------------------------------------------------
1 | import Input from './input'
2 |
3 | export default Input
4 |
--------------------------------------------------------------------------------
/components/input/input.tsx:
--------------------------------------------------------------------------------
1 | import React, { InputHTMLAttributes, ReactNode, forwardRef } from 'react'
2 | import classNames from 'classnames'
3 |
4 | export type InputSize = 'lg' | 'md' | 'sm'
5 |
6 | export interface InputProps
7 | extends Omit
15 |
16 | ### 内嵌菜单
17 |
18 | 垂直菜单,子菜单内嵌在菜单区域。`mode`值为`inline`。
19 |
20 |
21 |
22 | ### 只展开当前父级菜单
23 |
24 | 通过`defaultOpenKeys`设置当前展开的 SubMenu 菜单项 key 数组
25 |
26 | 点击菜单,收起其他展开的所有菜单,保持菜单聚焦简洁。
27 |
28 |
29 |
30 | ### 切换菜单类型
31 |
32 | 展示动态切换模式。
33 |
34 |
35 |
36 | ### API
37 |
38 | #### Menu
39 |
40 | | 参数 | 说明 | 类型 | 默认值 |
41 | | ------------------- | -------------------------------------- | ------------------------------------------ | -------- |
42 | | defaultOpenKeys | 初始展开的 SubMenu 菜单项 key 数组 | string\[] | - |
43 | | defaultSelectedKeys | 初始选中的菜单项 key 数组 | string | - |
44 | | mode | 菜单类型,现在支持水平、和内嵌模式三种 | `horizontal` \| `inline` | `inline` |
45 | | style | 根节点样式 | CSSProperties | - |
46 | | onClick | 点击 MenuItem 调用此函数 | function({ item, key, keyPath, domEvent }) | - |
47 |
48 | #### Menu.Item
49 |
50 | | 参数 | 说明 | 类型 | 默认值 |
51 | | -------- | --------------- | ------- | ------ |
52 | | disabled | 是否禁用 | boolean | false |
53 | | index | item 的唯一标志 | string | - |
54 |
55 | #### Menu.SubMenu
56 |
57 | | 参数 | 说明 | 类型 | 默认值 |
58 | | -------- | -------------- | ----------------------------- | ------ |
59 | | children | 子菜单的菜单项 | Array<MenuItem \| SubMenu> | - |
60 | | index | 唯一标志 | string | - |
61 | | title | 子菜单项值 | ReactNode | - |
62 |
--------------------------------------------------------------------------------
/components/menu/index.tsx:
--------------------------------------------------------------------------------
1 | import Menu from './menu'
2 |
3 | export default Menu
4 |
--------------------------------------------------------------------------------
/components/menu/menu.tsx:
--------------------------------------------------------------------------------
1 | import React, { FC, useState, CSSProperties } from 'react'
2 | import classNames from 'classnames'
3 | import MenuContext, { IMenuContext } from './MenuContext'
4 | import MenuItem, { MenuItemProps } from './MenuItem'
5 | import SubMenu, { SubMenuProps } from './SubMenu'
6 |
7 | export type MenuMode = 'horizontal' | 'inline' // 水平 | 内嵌
8 | export type SelectCallback = (selectedKey: string) => void
9 |
10 | export interface MenuProps {
11 | className?: string
12 | style?: CSSProperties
13 | mode?: MenuMode // 菜单类型
14 | onClick?: SelectCallback // 点击 MenuItem 调用此函数
15 | defaultSelectedKey?: string // 初始选中的菜单项 key
16 | defaultOpenKeys?: string[] // 初始展开的 SubMenu 菜单项 key 数组 只在纵向模式下生效
17 | }
18 |
19 | const RootMenu: FC
18 |
19 | ### 多选
20 |
21 | 多选,从已有条目中选择。设置`multiple`属性
22 |
23 |
24 |
25 | ### 禁用
26 |
27 |
28 |
29 | ### API
30 |
31 | #### Select
32 |
33 | | 参数 | 说明 | 类型 | 默认值 |
34 | | --------------- | --------------------- | ------------------------------------------------ | ------- |
35 | | defaultValue | 默认选中的选项 | string \| string\[] | - |
36 | | placeholder | 选择框默认文本 | string | - |
37 | | disabled | 是否禁用 | boolean | `false` |
38 | | multiple | 是否支持多选 | boolean | - |
39 | | onChange | 选中值发生变化时触发 | function(value:string, selectedValues:string\[]) | - |
40 | | onVisibleChange | 下拉框出现/隐藏时触发 | function(visible:boolean) | - |
41 |
42 | #### Select.Option
43 |
44 | | 参数 | 说明 | 类型 | 默认值 |
45 | | -------- | --------------------------------------- | ------- | ------ |
46 | | index | item 的唯一标志 | string | - |
47 | | value | 默认根据此属性值进行筛选,该值不能相同 | string | - |
48 | | label | 选项的标签,若不设置则默认与 value 相同 | string | - |
49 | | disabled | 是否禁用 | boolean | false |
50 |
--------------------------------------------------------------------------------
/components/select/index.tsx:
--------------------------------------------------------------------------------
1 | import Select from './select'
2 |
3 | export default Select
4 |
--------------------------------------------------------------------------------
/components/select/select.tsx:
--------------------------------------------------------------------------------
1 | import React, {
2 | FC,
3 | useState,
4 | ChangeEvent,
5 | createContext,
6 | useRef,
7 | FunctionComponentElement,
8 | useEffect,
9 | } from 'react'
10 | import classNames from 'classnames'
11 | import { DownOutlined } from '@ant-design/icons'
12 | import Input from '../input'
13 | import Tag from '../tag'
14 | import useClickOutside from '../hooks/useClickOutside'
15 | import Transition from '../transition'
16 | import Option, { SelectOptionProps } from './Option'
17 |
18 | export interface SelectProps {
19 | /** 默认选中的选项 可以是字符串或者字符串数组 */
20 | defaultValue?: string | string[]
21 | placeholder?: string
22 | /** 是否禁用 */
23 | disabled?: boolean
24 | /** 是否支持多选 */
25 | multiple?: boolean
26 | /** input 的 name 属性 */
27 | name?: string
28 | /** 选中值发生变化时触发 */
29 | onChange?: (selectedValue: string, selectedValues: string[]) => void
30 | /** 下拉框出现/隐藏时触发 */
31 | onVisibleChange?: (visible: boolean) => void
32 | }
33 |
34 | export interface ISelectContext {
35 | onSelect?: (value: string, isSelected?: boolean) => void
36 | selectedValues: string[]
37 | multiple?: boolean
38 | }
39 |
40 | export const SelectContext = createContext`s get reset. However, we also reset the 117 | // bottom margin to use `rem` units instead of `em`. 118 | 119 | p { 120 | margin-top: 0; 121 | margin-bottom: $paragraph-margin-bottom; 122 | } 123 | 124 | // Abbreviations 125 | // 126 | // 1. Duplicate behavior to the data-* attribute for our tooltip plugin 127 | // 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari. 128 | // 3. Add explicit cursor to indicate changed behavior. 129 | // 4. Prevent the text-decoration to be skipped. 130 | 131 | abbr[title], abbr[data-original-title] { 132 | // 1 133 | text-decoration: underline; // 2 134 | text-decoration: underline dotted; // 2 135 | cursor: help; // 3 136 | text-decoration-skip-ink: none; // 4 137 | } 138 | 139 | address { 140 | margin-bottom: 1rem; 141 | font-style: normal; 142 | line-height: inherit; 143 | } 144 | 145 | ol, ul { 146 | padding-left: 2rem; 147 | } 148 | 149 | ol, ul, dl { 150 | margin-top: 0; 151 | margin-bottom: 1rem; 152 | } 153 | 154 | ol ol, ul ul, ol ul, ul ol { 155 | margin-bottom: 0; 156 | } 157 | 158 | dt { 159 | font-weight: $dt-font-weight; 160 | } 161 | 162 | // 1. Undo browser default 163 | 164 | dd { 165 | margin-bottom: .5rem; 166 | margin-left: 0; // 1 167 | } 168 | 169 | blockquote { 170 | margin: 0 0 1rem; 171 | } 172 | 173 | // Add the correct font weight in Chrome, Edge, and Safari 174 | 175 | b, strong { 176 | font-weight: $font-weight-bolder; 177 | } 178 | 179 | // Add the correct font size in all browsers 180 | 181 | small { 182 | font-size: $small-font-size; 183 | } 184 | 185 | // Prevent `sub` and `sup` elements from affecting the line height in 186 | // all browsers. 187 | 188 | sub, sup { 189 | position: relative; 190 | font-size: $sub-sup-font-size; 191 | line-height: 0; 192 | vertical-align: baseline; 193 | } 194 | 195 | sub { 196 | bottom: -.25em; 197 | } 198 | sup { 199 | top: -.5em; 200 | } 201 | 202 | // Links 203 | 204 | a { 205 | color: $link-color; 206 | text-decoration: $link-decoration; 207 | 208 | &:hover { 209 | color: $link-hover-color; 210 | text-decoration: $link-hover-decoration; 211 | } 212 | } 213 | 214 | // And undo these styles for placeholder links/named anchors (without href). 215 | // It would be more straightforward to just use a[href] in previous block, but that 216 | // causes specificity issues in many other styles that are too complex to fix. 217 | // See https://github.com/twbs/bootstrap/issues/19402 218 | 219 | a:not([href]) { 220 | &, &:hover { 221 | color: inherit; 222 | text-decoration: none; 223 | } 224 | } 225 | 226 | // Code 227 | 228 | pre, code, kbd, samp { 229 | font-size: 1em; // Correct the odd `em` font sizing in all browsers. 230 | font-family: $font-family-monospace; 231 | } 232 | 233 | // 1. Remove browser default top margin 234 | // 2. Reset browser default of `1em` to use `rem`s 235 | // 3. Don't allow content to break outside 236 | 237 | code { 238 | color: $code-color; 239 | font-size: $code-font-size; 240 | word-wrap: break-word; 241 | 242 | // Streamline the style when inside anchors to avoid broken underline and more 243 | a > & { 244 | color: inherit; 245 | } 246 | } 247 | 248 | pre { 249 | display: block; 250 | margin-top: 0; // 1 251 | margin-bottom: 1rem; // 2 252 | overflow: auto; // 3 253 | color: $pre-color; 254 | font-size: $code-font-size; 255 | 256 | // Account for some code outputs that place code tags in pre tags 257 | code { 258 | color: inherit; 259 | font-size: inherit; 260 | word-break: normal; 261 | } 262 | } 263 | 264 | // Figures 265 | 266 | // Apply a consistent margin strategy (matches our type styles). 267 | 268 | figure { 269 | margin: 0 0 1rem; 270 | } 271 | 272 | // Images and content 273 | 274 | img { 275 | vertical-align: middle; 276 | } 277 | 278 | // 1. Workaround for the SVG overflow bug in IE 11 is still required. 279 | // See https://github.com/twbs/bootstrap/issues/26878 280 | 281 | svg { 282 | overflow: hidden; // 1 283 | vertical-align: middle; 284 | } 285 | 286 | // Tables 287 | 288 | // Prevent double borders 289 | 290 | table { 291 | border-collapse: collapse; 292 | } 293 | 294 | caption { 295 | padding-top: .5rem; 296 | padding-bottom: .5rem; 297 | color: $text-muted; 298 | text-align: left; 299 | caption-side: bottom; 300 | } 301 | 302 | // Matches default `
15 |
16 | ### 禁用
17 |
18 | 禁用某一项。
19 |
20 |
21 |
22 | ### 卡片式页签
23 |
24 | 另一种样式的页签,不提供对应的垂直样式。
25 |
26 |
27 |
28 | ### API
29 |
30 | #### Tabs
31 |
32 | | 参数 | 说明 | 类型 | 默认值 |
33 | | ---------------- | -------------------------------------------- | --------------------- | ------ |
34 | | defaultActiveKey | 初始化选中面板的 key,如果没有设置 activeKey | number | 0 |
35 | | type | 页签的基本样式,可选 line、card 类型 | string | `line` |
36 | | onTabClick | tab 被点击的回调 | function(key: number) | - |
37 |
38 | #### Tabs.TabPane
39 |
40 | | 参数 | 说明 | 类型 | 默认值 |
41 | | -------- | ---------------- | --------- | ------ |
42 | | disabled | 是否禁用 | boolean | false |
43 | | tab | 选项卡头显示文字 | ReactNode | - |
44 |
--------------------------------------------------------------------------------
/components/tabs/index.tsx:
--------------------------------------------------------------------------------
1 | import Tabs from './Tabs'
2 |
3 | export default Tabs
4 |
--------------------------------------------------------------------------------
/components/tabs/style/index.scss:
--------------------------------------------------------------------------------
1 | .mk-tabs-nav {
2 | display: flex;
3 | flex-wrap: wrap;
4 | margin-bottom: 0;
5 | padding-left: 0;
6 | list-style: none;
7 | border-bottom: $nav-tabs-border-width solid $nav-tabs-border-color;
8 | }
9 | .mk-tabs-nav-item {
10 | display: block;
11 | padding: $nav-link-padding-y $nav-link-padding-x;
12 | cursor: pointer;
13 | &:hover, &:focus {
14 | color: $nav-tabs-link-hover-color;
15 | }
16 | &.disabled {
17 | color: $nav-link-disabled-color;
18 | background-color: transparent;
19 | border-color: transparent;
20 | cursor: default;
21 | pointer-events: none;
22 | }
23 | &.is-active {
24 | color: $nav-tabs-link-active-color;
25 | }
26 | }
27 | .nav-line {
28 | .mk-tabs-nav-item {
29 | &.is-active {
30 | border-bottom: $nav-tabs-border-width * 2 solid $nav-tabs-link-active-color;
31 | }
32 | }
33 | }
34 |
35 | .nav-card {
36 | .mk-tabs-nav-item {
37 | margin-bottom: -$nav-tabs-border-width;
38 | border: $nav-tabs-border-width solid transparent;
39 | &.is-active {
40 | @include border-top-radius($nav-tabs-border-radius);
41 | background-color: $nav-tabs-link-active-bg;
42 | border-color: $nav-tabs-link-active-border-color;
43 | }
44 | }
45 | }
46 |
47 | .mk-tabs-content {
48 | margin-top: $nav-tabs-content-margin;
49 | }
50 |
--------------------------------------------------------------------------------
/components/tabs/style/index.tsx:
--------------------------------------------------------------------------------
1 | import './index.scss'
2 |
--------------------------------------------------------------------------------
/components/tag/__tests__/__snapshots__/index.test.tsx.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`Tag render normal Tag correctly 1`] = `
4 |
20 |
21 | ## 颜色
22 |
23 |
24 |
25 | ## 尺寸
26 |
27 |
28 |
29 | ## API
30 |
31 | | 参数 | 说明 | 类型 | 默认值 |
32 | | -------- | ---------------- | ---------- | ------ |
33 | | closable | 标签是否可以关闭 | boolean | false |
34 | | color | 标签色 | string | - |
35 | | text | Tag 的文本 | string | - |
36 | | size | Tag 的尺寸 | string | - |
37 | | onClose | 关闭时的回调 | () => void | - |
38 |
--------------------------------------------------------------------------------
/components/tag/index.tsx:
--------------------------------------------------------------------------------
1 | import Tag from './tag'
2 |
3 | export default Tag
4 |
--------------------------------------------------------------------------------
/components/tag/style/_mixins.scss:
--------------------------------------------------------------------------------
1 | @mixin tag-size($padding-y, $padding-x, $font-size) {
2 | padding: $padding-y $padding-x;
3 | font-size: $font-size;
4 | }
5 |
--------------------------------------------------------------------------------
/components/tag/style/index.scss:
--------------------------------------------------------------------------------
1 | @import 'mixins';
2 |
3 | .mk-tag {
4 | display: inline-block;
5 | box-sizing: border-box;
6 | vertical-align: middle;
7 | border-radius: 3px;
8 | @include tag-size($tag-padding-y, $tag-padding-x, $tag-font-size);
9 |
10 | .tag-text {
11 | vertical-align: middle;
12 | }
13 |
14 | .tag-close-icon {
15 | margin-left: 4px;
16 | vertical-align: middle;
17 | }
18 | }
19 |
20 | .tag-lg {
21 | @include tag-size($tag-padding-y-lg, $tag-padding-x-lg, $tag-font-size-lg);
22 | }
23 | .tag-sm {
24 | @include tag-size($tag-padding-y-sm, $tag-padding-x-sm, $tag-font-size-sm);
25 | }
26 |
27 | @each $key, $val in $theme-colors {
28 | .tag-#{$key} {
29 | color: $val;
30 | background-color: rgba($val, .1);
31 | border: 1px solid rgba($val, .2);
32 |
33 | .mk-icon {
34 | &:hover {
35 | color: darken($val, 10%);
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/components/tag/style/index.tsx:
--------------------------------------------------------------------------------
1 | import './index.scss'
2 |
--------------------------------------------------------------------------------
/components/tag/tag.tsx:
--------------------------------------------------------------------------------
1 | import React, { FC, useState } from 'react'
2 | import classNames from 'classnames'
3 | import CloseOutlined from '@ant-design/icons/CloseOutlined'
4 | import Transition from '../transition'
5 |
6 | export type ColorProps = 'primary' | 'success' | 'warning' | 'danger'
7 |
8 | export interface TagProps {
9 | /** 自定义类名 */
10 | className?: string
11 | /** Tag的主题色 */
12 | color?: ColorProps
13 | /** Tag的尺寸 */
14 | size?: 'lg' | 'sm'
15 | /** Tag的文本 */
16 | text: string
17 | /** 关闭Tag */
18 | onClose?: () => void
19 | /** 是否显示关闭图标 */
20 | closable?: boolean
21 | }
22 |
23 | export const Tag: FC