-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…3061) * feat(container-context): add container package (#3060) * chore(container-context): 规范代码 (#3060) * chore(portal-context): 改写名字代码 (#3060) * chore(portal-context): 规范记录(#3060) * chore(portal-context): 删除多余代码(#3060) * chore(portal-context): 删除多余空格(#3060) --------- Co-authored-by: wanjinping <[email protected]>
- Loading branch information
Showing
19 changed files
with
209 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"@hi-ui/core": minor | ||
"@hi-ui/container-context": minor | ||
"@hi-ui/drawer": minor | ||
"@hi-ui/hiui": minor | ||
"@hi-ui/loading": minor | ||
"@hi-ui/modal": minor | ||
"@hi-ui/preview": minor | ||
"@hi-ui/provider": minor | ||
--- | ||
|
||
feat(portal-context): Provider 增加 portal 参数,支持配置全局 container (#3060) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# `@hi-ui/portal-context` | ||
|
||
> TODO: description | ||
## Usage | ||
|
||
``` | ||
const PortalContext = require('@hi-ui/portal-context'); | ||
// TODO: DEMONSTRATE API | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const PortalContext = require('../src') | ||
|
||
describe('@hi-ui/portal-context', () => { | ||
it('needs tests', () => {}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# PortalContext 上下文 | ||
|
||
容器设置上下文。 | ||
|
||
## 何时使用 | ||
|
||
组件使用场景中文介绍 | ||
|
||
## 使用示例 | ||
|
||
<!-- Inject Stories --> | ||
|
||
## Props | ||
|
||
<!-- Inject Props --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('../../../jest.config') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "@hi-ui/portal-context", | ||
"version": "4.0.0", | ||
"description": "A sub-package for @hi-ui/hiui.", | ||
"keywords": [], | ||
"author": "HiUI <[email protected]>", | ||
"homepage": "https://github.com/XiaoMi/hiui/tree/master/packages/ui/container-context#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" | ||
}, | ||
"dependencies": {}, | ||
"peerDependencies": { | ||
"react": ">=16.8.6", | ||
"react-dom": ">=16.8.6" | ||
}, | ||
"devDependencies": { | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createContext, useContext } from 'react' | ||
|
||
export const PortalContext = createContext<UsePortalContext>(null) | ||
|
||
export const usePortalContext = () => { | ||
const context = useContext(PortalContext) | ||
|
||
return context | ||
} | ||
|
||
export type UsePortalContext = { container?: HTMLElement | null | undefined } | null | undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react' | ||
import { PortalContext, UsePortalContext } from './PortalContext' | ||
import { __DEV__ } from '@hi-ui/env' | ||
|
||
export const PortalProvider: React.FC<PortalProviderProps> = ({ children, portal }) => { | ||
return <PortalContext.Provider value={portal}>{children}</PortalContext.Provider> | ||
} | ||
|
||
export interface PortalProviderProps { | ||
/** | ||
* 指定 portal 的容器 | ||
*/ | ||
portal?: UsePortalContext | ||
} | ||
|
||
if (__DEV__) { | ||
PortalProvider.displayName = 'PortalProvider' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './PortalContext' | ||
export * from './PortalProvider' | ||
|
||
export { PortalProvider as default } from './PortalProvider' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React, { useContext } from 'react' | ||
import { PortalContext } from '../src' | ||
|
||
/** | ||
* @title 基础用法 | ||
*/ | ||
export const Basic = () => { | ||
useContext(PortalContext) | ||
|
||
return ( | ||
<> | ||
<h1>Basic</h1> | ||
<div className="portal-context-basic__wrap"></div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react' | ||
|
||
export * from './basic.stories' | ||
|
||
export default { | ||
title: 'Private(暂不对外)/PortalContext', | ||
decorators: [(story: Function) => <div>{story()}</div>], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../../tsconfig.json", | ||
"include": ["./src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters