From e98c38b859b31eef940c441010170946ef67fdd9 Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Sun, 7 Apr 2024 17:24:54 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat(style-inject):=20=E5=A2=9E=E5=8A=A0=20?= =?UTF-8?q?style-inject=20=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/utils/style-inject/README.md | 11 +++++ .../__tests__/style-inject.test.js | 5 ++ packages/utils/style-inject/jest.config.js | 1 + packages/utils/style-inject/package.json | 47 +++++++++++++++++++ packages/utils/style-inject/src/index.ts | 17 +++++++ packages/utils/style-inject/tsconfig.json | 4 ++ 6 files changed, 85 insertions(+) create mode 100644 packages/utils/style-inject/README.md create mode 100644 packages/utils/style-inject/__tests__/style-inject.test.js create mode 100644 packages/utils/style-inject/jest.config.js create mode 100644 packages/utils/style-inject/package.json create mode 100644 packages/utils/style-inject/src/index.ts create mode 100644 packages/utils/style-inject/tsconfig.json diff --git a/packages/utils/style-inject/README.md b/packages/utils/style-inject/README.md new file mode 100644 index 000000000..a12c0f54e --- /dev/null +++ b/packages/utils/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/utils/style-inject/__tests__/style-inject.test.js b/packages/utils/style-inject/__tests__/style-inject.test.js new file mode 100644 index 000000000..8531ac374 --- /dev/null +++ b/packages/utils/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/utils/style-inject/jest.config.js b/packages/utils/style-inject/jest.config.js new file mode 100644 index 000000000..e33c14b5d --- /dev/null +++ b/packages/utils/style-inject/jest.config.js @@ -0,0 +1 @@ +module.exports = require('../../../jest.config') diff --git a/packages/utils/style-inject/package.json b/packages/utils/style-inject/package.json new file mode 100644 index 000000000..f748dfb15 --- /dev/null +++ b/packages/utils/style-inject/package.json @@ -0,0 +1,47 @@ +{ + "name": "@hi-ui/style-inject", + "version": "4.0.0-beta.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/utils/style-inject/src/index.ts b/packages/utils/style-inject/src/index.ts new file mode 100644 index 000000000..1a08248a6 --- /dev/null +++ b/packages/utils/style-inject/src/index.ts @@ -0,0 +1,17 @@ +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/utils/style-inject/tsconfig.json b/packages/utils/style-inject/tsconfig.json new file mode 100644 index 000000000..f7bbdb2fe --- /dev/null +++ b/packages/utils/style-inject/tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../../tsconfig.json", + "include": ["./src"] +} From cc8744c7c9f8bb5bce3f16e2c4d4568ffbeb98a9 Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Sun, 7 Apr 2024 20:24:12 +0800 Subject: [PATCH 2/5] =?UTF-8?q?chore(style-inject):=20style-inject=20?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2=E4=B8=BA=20@hi-ui/style-inject?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/utils/env/package.json | 3 +-- packages/utils/style-inject/package.json | 4 ++-- packages/utils/style-inject/src/index.ts | 16 ++++++++++------ scripts/hi-build/lib/build.js | 4 ++-- scripts/hi-build/package.json | 5 +---- yarn.lock | 10 +++++----- 6 files changed, 21 insertions(+), 21 deletions(-) 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/packages/utils/style-inject/package.json b/packages/utils/style-inject/package.json index f748dfb15..f347e821e 100644 --- a/packages/utils/style-inject/package.json +++ b/packages/utils/style-inject/package.json @@ -1,6 +1,6 @@ { - "name": "@hi-ui/style-inject", - "version": "4.0.0-beta.0", + "name": "@hi-ui/styleinject", + "version": "4.0.0", "description": "A sub-package for @hi-ui/utils.", "keywords": [], "author": "HiUI ", diff --git a/packages/utils/style-inject/src/index.ts b/packages/utils/style-inject/src/index.ts index 1a08248a6..e9d4a0f97 100644 --- a/packages/utils/style-inject/src/index.ts +++ b/packages/utils/style-inject/src/index.ts @@ -1,16 +1,20 @@ -const isBrowser = !!(typeof window !== 'undefined' && window.document && window.document.createElement); +const isBrowser = !!( + typeof window !== 'undefined' && + window.document && + window.document.createElement +) /** * TODO: What is styleInject */ const styleInject = (css: string) => { - if (!css || !isBrowser) return; + if (!css || !isBrowser) return - const head = document.head || document.getElementsByTagName('head')[0]; - const style = document.createElement('style'); + const head = document.head || document.getElementsByTagName('head')[0] + const style = document.createElement('style') - head.appendChild(style); - style.appendChild(document.createTextNode(css)); + head.appendChild(style) + style.appendChild(document.createTextNode(css)) } export default styleInject 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..3a0356b1e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" From dd77f9d6d2ff6c30944142e40dc61e11b284806b Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Sun, 7 Apr 2024 20:27:11 +0800 Subject: [PATCH 3/5] =?UTF-8?q?chore:=20=E5=8D=87=E7=BA=A7=E5=88=B0=20@hi-?= =?UTF-8?q?ui/build@4.1.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) 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/yarn.lock b/yarn.lock index 3a0356b1e..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" From 1a00f9fc4a44619059d7852e846b54fedbd56715 Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Mon, 8 Apr 2024 10:37:34 +0800 Subject: [PATCH 4/5] =?UTF-8?q?chore(style-inject):=20=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E8=AE=B0=E5=BD=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/good-books-live.md | 86 +++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .changeset/good-books-live.md 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 From 69c8aed4a0a4d3d2f6fdc05546dcb0feb8203631 Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Mon, 8 Apr 2024 11:17:16 +0800 Subject: [PATCH 5/5] =?UTF-8?q?chore(style-inject):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/{utils => others}/style-inject/README.md | 0 .../{utils => others}/style-inject/__tests__/style-inject.test.js | 0 packages/{utils => others}/style-inject/jest.config.js | 0 packages/{utils => others}/style-inject/package.json | 0 packages/{utils => others}/style-inject/src/index.ts | 0 packages/{utils => others}/style-inject/tsconfig.json | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename packages/{utils => others}/style-inject/README.md (100%) rename packages/{utils => others}/style-inject/__tests__/style-inject.test.js (100%) rename packages/{utils => others}/style-inject/jest.config.js (100%) rename packages/{utils => others}/style-inject/package.json (100%) rename packages/{utils => others}/style-inject/src/index.ts (100%) rename packages/{utils => others}/style-inject/tsconfig.json (100%) diff --git a/packages/utils/style-inject/README.md b/packages/others/style-inject/README.md similarity index 100% rename from packages/utils/style-inject/README.md rename to packages/others/style-inject/README.md diff --git a/packages/utils/style-inject/__tests__/style-inject.test.js b/packages/others/style-inject/__tests__/style-inject.test.js similarity index 100% rename from packages/utils/style-inject/__tests__/style-inject.test.js rename to packages/others/style-inject/__tests__/style-inject.test.js diff --git a/packages/utils/style-inject/jest.config.js b/packages/others/style-inject/jest.config.js similarity index 100% rename from packages/utils/style-inject/jest.config.js rename to packages/others/style-inject/jest.config.js diff --git a/packages/utils/style-inject/package.json b/packages/others/style-inject/package.json similarity index 100% rename from packages/utils/style-inject/package.json rename to packages/others/style-inject/package.json diff --git a/packages/utils/style-inject/src/index.ts b/packages/others/style-inject/src/index.ts similarity index 100% rename from packages/utils/style-inject/src/index.ts rename to packages/others/style-inject/src/index.ts diff --git a/packages/utils/style-inject/tsconfig.json b/packages/others/style-inject/tsconfig.json similarity index 100% rename from packages/utils/style-inject/tsconfig.json rename to packages/others/style-inject/tsconfig.json