diff --git a/.changeset/good-books-live.md b/.changeset/good-books-live.md new file mode 100644 index 000000000..9215642b3 --- /dev/null +++ b/.changeset/good-books-live.md @@ -0,0 +1,86 @@ +--- +"@hi-ui/env": patch +"@hi-ui/icons": patch +"@hi-ui/alert": patch +"@hi-ui/anchor": patch +"@hi-ui/avatar": patch +"@hi-ui/back-top": patch +"@hi-ui/badge": patch +"@hi-ui/breadcrumb": patch +"@hi-ui/button": patch +"@hi-ui/card": patch +"@hi-ui/carousel": patch +"@hi-ui/cascader": patch +"@hi-ui/check-cascader": patch +"@hi-ui/check-select": patch +"@hi-ui/check-tree-select": patch +"@hi-ui/checkbox": patch +"@hi-ui/collapse": patch +"@hi-ui/counter": patch +"@hi-ui/date-picker": patch +"@hi-ui/descriptions": patch +"@hi-ui/drawer": patch +"@hi-ui/dropdown": patch +"@hi-ui/ellipsis-tooltip": patch +"@hi-ui/empty-state": patch +"@hi-ui/file-select": patch +"@hi-ui/filter": patch +"@hi-ui/form": patch +"@hi-ui/grid": patch +"@hi-ui/highlighter": patch +"@hi-ui/hiui": patch +"@hi-ui/icon-button": patch +"@hi-ui/input": patch +"@hi-ui/input-group": patch +"@hi-ui/list": patch +"@hi-ui/loading": patch +"@hi-ui/locale-context": patch +"@hi-ui/menu": patch +"@hi-ui/message": patch +"@hi-ui/modal": patch +"@hi-ui/notification": patch +"@hi-ui/number-input": patch +"@hi-ui/pagination": patch +"@hi-ui/picker": patch +"@hi-ui/pop-confirm": patch +"@hi-ui/popover": patch +"@hi-ui/popper": patch +"@hi-ui/portal": patch +"@hi-ui/preview": patch +"@hi-ui/progress": patch +"@hi-ui/provider": patch +"@hi-ui/radio": patch +"@hi-ui/rating": patch +"@hi-ui/resize-box": patch +"@hi-ui/result": patch +"@hi-ui/scrollbar": patch +"@hi-ui/search": patch +"@hi-ui/select": patch +"@hi-ui/slider": patch +"@hi-ui/space": patch +"@hi-ui/spinner": patch +"@hi-ui/stepper": patch +"@hi-ui/svg-icon": patch +"@hi-ui/switch": patch +"@hi-ui/table": patch +"@hi-ui/tabs": patch +"@hi-ui/tag": patch +"@hi-ui/tag-input": patch +"@hi-ui/textarea": patch +"@hi-ui/time-picker": patch +"@hi-ui/timeline": patch +"@hi-ui/toast": patch +"@hi-ui/tooltip": patch +"@hi-ui/transfer": patch +"@hi-ui/tree": patch +"@hi-ui/tree-select": patch +"@hi-ui/upload": patch +"@hi-ui/virtual-list": patch +"@hi-ui/watermark": patch +"@hi-ui/zen-mode": patch +"@hi-ui/array-utils": patch +"@hi-ui/classname": patch +"@hi-ui/container": patch +--- + +build: style-inject(node 环境下有问题) 替换为 @hi-ui/style-inject diff --git a/package.json b/package.json index dd45e07e3..5a320d0ef 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "@babel/preset-typescript": "~7.12.7", "@changesets/changelog-github": "^0.4.7", "@changesets/cli": "^2.25.0", - "@hi-ui/hi-build": "4.1.1", + "@hi-ui/hi-build": "4.1.2", "@storybook/addon-actions": "^6.3.12", "@storybook/addon-essentials": "^6.3.12", "@storybook/addon-links": "^6.3.12", diff --git a/packages/others/style-inject/README.md b/packages/others/style-inject/README.md new file mode 100644 index 000000000..a12c0f54e --- /dev/null +++ b/packages/others/style-inject/README.md @@ -0,0 +1,11 @@ +# `@hi-ui/style-inject` + +> TODO: description + +## Usage + +``` +const styleInject = require('@hi-ui/style-inject'); + +// TODO: DEMONSTRATE API +``` diff --git a/packages/others/style-inject/__tests__/style-inject.test.js b/packages/others/style-inject/__tests__/style-inject.test.js new file mode 100644 index 000000000..8531ac374 --- /dev/null +++ b/packages/others/style-inject/__tests__/style-inject.test.js @@ -0,0 +1,5 @@ +const styleInject = require('../src') + +describe('@hi-ui/style-inject', () => { + it('needs tests', () => {}) +}) diff --git a/packages/others/style-inject/jest.config.js b/packages/others/style-inject/jest.config.js new file mode 100644 index 000000000..e33c14b5d --- /dev/null +++ b/packages/others/style-inject/jest.config.js @@ -0,0 +1 @@ +module.exports = require('../../../jest.config') diff --git a/packages/others/style-inject/package.json b/packages/others/style-inject/package.json new file mode 100644 index 000000000..f347e821e --- /dev/null +++ b/packages/others/style-inject/package.json @@ -0,0 +1,47 @@ +{ + "name": "@hi-ui/styleinject", + "version": "4.0.0", + "description": "A sub-package for @hi-ui/utils.", + "keywords": [], + "author": "HiUI ", + "homepage": "https://github.com/XiaoMi/hiui/tree/master/packages/utils/style-inject#readme", + "license": "MIT", + "directories": { + "lib": "lib", + "test": "__tests__" + }, + "files": [ + "lib" + ], + "main": "lib/cjs/index.js", + "module": "lib/esm/index.js", + "types": "lib/types/index.d.ts", + "typings": "lib/types/index.d.ts", + "exports": { + ".": { + "require": "./lib/cjs/index.js", + "default": "./lib/esm/index.js" + } + }, + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/XiaoMi/hiui.git" + }, + "scripts": { + "test": "jest", + "clean": "rimraf lib", + "prebuild": "yarn clean", + "build:esm": "hi-build ./src/index.ts --format esm -d ./lib/esm", + "build:cjs": "hi-build ./src/index.ts --format cjs -d ./lib/cjs", + "build:types": "tsc --emitDeclarationOnly --declaration --declarationDir lib/types", + "build": "concurrently yarn:build:*" + }, + "bugs": { + "url": "https://github.com/XiaoMi/hiui/issues" + }, + "devDependencies": { + } +} diff --git a/packages/others/style-inject/src/index.ts b/packages/others/style-inject/src/index.ts new file mode 100644 index 000000000..e9d4a0f97 --- /dev/null +++ b/packages/others/style-inject/src/index.ts @@ -0,0 +1,21 @@ +const isBrowser = !!( + typeof window !== 'undefined' && + window.document && + window.document.createElement +) + +/** + * TODO: What is styleInject + */ +const styleInject = (css: string) => { + if (!css || !isBrowser) return + + const head = document.head || document.getElementsByTagName('head')[0] + const style = document.createElement('style') + + head.appendChild(style) + style.appendChild(document.createTextNode(css)) +} + +export default styleInject +export { styleInject } diff --git a/packages/others/style-inject/tsconfig.json b/packages/others/style-inject/tsconfig.json new file mode 100644 index 000000000..f7bbdb2fe --- /dev/null +++ b/packages/others/style-inject/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../../tsconfig.json", + "include": ["./src"] +} diff --git a/packages/utils/env/package.json b/packages/utils/env/package.json index e2cd6c9c8..5ac29c8a7 100644 --- a/packages/utils/env/package.json +++ b/packages/utils/env/package.json @@ -36,7 +36,6 @@ }, "homepage": "https://github.com/XiaoMi/hiui#readme", "dependencies": { - "inject-head-style": "^1.0.0", - "style-inject": "^0.3.0" + "@hi-ui/style-inject": "^4.0.0" } } diff --git a/scripts/hi-build/lib/build.js b/scripts/hi-build/lib/build.js index 973f255b5..7d269bfee 100644 --- a/scripts/hi-build/lib/build.js +++ b/scripts/hi-build/lib/build.js @@ -155,9 +155,9 @@ const getRollupConfig = (input, outputPath, options, pkg) => { // Extract styleInject as a external module inject: !cssExtract ? (variableName) => { if (isESM) { - return `;import __styleInject__ from 'style-inject';__styleInject__(${variableName});` + return `;import __styleInject__ from '@hi-ui/style-inject';__styleInject__(${variableName});` } - return `;var __styleInject__=require('style-inject').default;__styleInject__(${variableName});` + return `;var __styleInject__=require('@hi-ui/style-inject').default;__styleInject__(${variableName});` } : false, extract: cssExtract, modules: cssModules, diff --git a/scripts/hi-build/package.json b/scripts/hi-build/package.json index 41ed77d7b..e1e0899eb 100644 --- a/scripts/hi-build/package.json +++ b/scripts/hi-build/package.json @@ -1,6 +1,6 @@ { "name": "@hi-ui/hi-build", - "version": "4.1.1", + "version": "4.1.2", "description": "Now I’m the model of a modern major general / The venerated Virginian veteran whose men are all / Lining up, to put me up on a pedestal / Writin’ letters to relatives / Embellishin’ my elegance and eloquence / But the elephant is in the room / The truth is in ya face when ya hear the British cannons go / BOOM", "keywords": [], "author": "Flcwl ", @@ -64,8 +64,5 @@ }, "peerDependencies": { "typescript": "^4.6.2" - }, - "devDependencies": { - "@hi-ui/hi-build": "^4.1.1" } } diff --git a/yarn.lock b/yarn.lock index 2d8dce585..ae381f32f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2680,10 +2680,10 @@ minimatch "^3.0.4" strip-json-comments "^3.1.1" -"@hi-ui/hi-build@4.1.1": - version "4.1.1" - resolved "https://registry.npmmirror.com/@hi-ui/hi-build/-/hi-build-4.1.1.tgz#1b586ca597c358ebb9c974433e488f02b61ef7bf" - integrity sha512-cXMJVsdhTjZizcSvH8fl9w2M5zUdBFUO/cEobzUTK2aKY4ia+ZVQ8OPSKbR5vbYn2d+j/7YwdXVg9novdnu9uw== +"@hi-ui/hi-build@4.1.2": + version "4.1.2" + resolved "https://registry.npmjs.org/@hi-ui/hi-build/-/hi-build-4.1.2.tgz#0125cac22a7b53a92146a405fe0eb3c33da08a0e" + integrity sha512-el7cyqRt6CRUAe6X/RzWImAppdDJtnIIzlxol1Oc1AwIXrwPfYzSjtVsibE5IeuATRhlhzEVswem9hngqn5jJQ== dependencies: "@babel/core" "^7.17.8" "@babel/plugin-transform-runtime" "^7.17.0" @@ -2715,6 +2715,11 @@ rollup-plugin-terser "^7.0.2" rollup-plugin-visualizer "^5.9.2" +"@hi-ui/style-inject@^4.0.0": + version "4.0.0" + resolved "https://registry.npmjs.org/@hi-ui/style-inject/-/style-inject-4.0.0.tgz#62e3ecff2654e5149cd310db8ba8fbe078020bd3" + integrity sha512-f/WDX/a10y08gYY9UaSwX0V0CbLDxlzf/6UrwD8fZIyIPdlyrR3Jld8X18vz5zywxPTpOPwBQLf9PYZ9YdFMPA== + "@humanwhocodes/config-array@^0.5.0": version "0.5.0" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.5.0.tgz#1407967d4c6eecd7388f83acf1eaf4d0c6e58ef9" @@ -10601,11 +10606,6 @@ init-package-json@^2.0.2: validate-npm-package-license "^3.0.4" validate-npm-package-name "^3.0.0" -inject-head-style@^1.0.0: - version "1.0.0" - resolved "https://registry.npmmirror.com/inject-head-style/-/inject-head-style-1.0.0.tgz#159f843900d3f473fb691c67fce52b5d088f5f68" - integrity sha512-J6eyVFIiY3SgvguiUx/XXBZWTIxMryhiSosH2fan5+FhfA4LlNJkybUcYsINInM+zvsBmcrIHVWJxvi4lvjwqA== - inline-style-parser@0.1.1: version "0.1.1" resolved "https://registry.npm.taobao.org/inline-style-parser/download/inline-style-parser-0.1.1.tgz#ec8a3b429274e9c0a1f1c4ffa9453a7fef72cea1"