add nanoid

This commit is contained in:
hufeixiong
2021-07-13 11:21:55 +08:00
parent 09e69a9239
commit 04ff764a82
12 changed files with 175 additions and 26 deletions

View File

@@ -2,13 +2,17 @@
* @Author: yehuozhili
* @Date: 2021-01-31 20:44:16
* @LastEditors: yehuozhili
* @LastEditTime: 2021-07-12 21:00:48
* @LastEditTime: 2021-07-13 11:10:00
* @FilePath: \dooringx\packages\dooringx-lib\README.md
-->
## Dooringx-lib
## changelog
- 0.3.1
1、由uuid更换为nanoid。
2、control组件增加标尺控制。
- 0.3.0
1、增加标尺ContainerWrapper需要传递config才可使用。
2、修改容器最小拖动667。修复画布缩放下拖拽时与鼠标距离不一致。
@@ -26,5 +30,4 @@
## todo
1、制作标尺
2、重构拖拽优化性能与config传递。
1、重构拖拽优化性能与config传递。

View File

@@ -1,5 +1,5 @@
{
"version": "0.3.0",
"version": "0.3.1",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
@@ -17,32 +17,33 @@
"prepare": "tsdx build"
},
"peerDependencies": {
"react": ">=16.8",
"animate.css": ">=4",
"antd": ">=4",
"animate.css": ">=4"
"react": ">=16.8"
},
"name": "dooringx-lib",
"author": "yehuozhili",
"devDependencies": {
"@ant-design/icons": "^4.6.2",
"@types/react": "^17.0.0",
"@types/react-color": "^3.0.4",
"@types/react-dom": "^17.0.0",
"@types/uuid": "^8.3.0",
"antd": "^4.15.2",
"postcss-modules": "^4.0.0",
"babel-plugin-import": "^1.13.3",
"babel-plugin-import-v2": "^1.0.0",
"@types/react-color": "^3.0.4",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"size-limit": "^4.10.1",
"tsdx": "^0.14.1",
"less": "^4.1.1",
"postcss": "^8.2.8",
"postcss-modules": "^4.0.0",
"react": "17.x",
"react-dom": "17.x",
"postcss": "^8.2.8",
"less": "^4.1.1",
"rollup-plugin-postcss": "^4.0.0",
"@types/uuid": "^8.3.0"
"size-limit": "^4.10.1",
"tsdx": "^0.14.1"
},
"dependencies": {
"deepcopy": "^2.1.0",
"nanoid": "^3.1.23",
"react-color": "^2.19.3",
"react-sortable-hoc": "^2.0.0",
"uuid": "^8.3.2"

View File

@@ -4,6 +4,7 @@ import {
FullscreenExitOutlined,
FullscreenOutlined,
GatewayOutlined,
LayoutOutlined,
MenuOutlined,
SyncOutlined,
UnorderedListOutlined,
@@ -13,7 +14,6 @@ import React, { CSSProperties, PropsWithChildren, useState } from 'react';
import { UserConfig } from '..';
import { IBlockType, IStoreData } from '../core/store/storetype';
import { deepCopy, arrayMove, changeItem, changeLayer, focusEle } from '../core/utils';
import { SortEnd, SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
import { wrapperMoveState } from './wrapperMove/event';
export interface ControlProps {
@@ -151,8 +151,13 @@ export function Control(props: PropsWithChildren<ControlProps>) {
<Popover style={{ minWidth: '208px' }} content={content} trigger="click">
<Button icon={<UnorderedListOutlined />}></Button>
</Popover>
{/* <Button icon={<FolderOpenOutlined />}></Button> */}
<Button
icon={<LayoutOutlined />}
onClick={() => {
props.config.ticker = !props.config.ticker;
props.config.getStore().forceUpdate();
}}
></Button>
<Popover
placement="left"
content={

View File

@@ -2,7 +2,7 @@
* @Author: yehuozhili
* @Date: 2021-03-14 04:29:09
* @LastEditors: yehuozhili
* @LastEditTime: 2021-07-12 19:47:39
* @LastEditTime: 2021-07-13 10:49:33
* @FilePath: \dooringx\packages\dooringx-lib\src\components\wrapperMove\index.tsx
*/
import { AllHTMLAttributes, CSSProperties, PropsWithChildren, useRef } from 'react';
@@ -21,6 +21,7 @@ export interface ContainerWrapperProps extends AllHTMLAttributes<HTMLDivElement>
function ContainerWrapper(props: PropsWithChildren<ContainerWrapperProps>) {
const { children, style, classNames, ...rest } = props;
const ref = useRef<HTMLDivElement>(null);
const ticker = props.config.ticker;
return (
<div
className={`ant-menu ${classNames ? classNames : ''}`}
@@ -41,7 +42,7 @@ function ContainerWrapper(props: PropsWithChildren<ContainerWrapperProps>) {
{...rest}
>
{children}
<Ticker config={props.config}></Ticker>
{ticker && <Ticker config={props.config}></Ticker>}
</div>
);
}

View File

@@ -2,7 +2,7 @@
* @Author: yehuozhili
* @Date: 2021-02-25 21:16:58
* @LastEditors: yehuozhili
* @LastEditTime: 2021-07-12 16:49:46
* @LastEditTime: 2021-07-13 10:48:14
* @FilePath: \dooringx\packages\dooringx-lib\src\config\index.tsx
*/
import { IBlockType, IStoreData } from '../core/store/storetype';
@@ -322,6 +322,7 @@ export class UserConfig {
public dataCenter: DataCenter;
public scaleState = scaleState;
public collapsed = false;
public ticker = true;
constructor(initConfig?: Partial<InitConfig>) {
const mergeConfig = userConfigMerge(defaultConfig, initConfig);
this.initConfig = mergeConfig;

View File

@@ -1,6 +1,6 @@
import { message } from 'antd';
import { RGBColor } from 'react-color';
import * as uuid from 'uuid';
import { nanoid } from 'nanoid';
import Store from '../store';
import { IBlockType, IStoreData } from '../store/storetype';
import { specialCoList } from './special';
@@ -31,9 +31,9 @@ export function rgba2Obj(rgba = '') {
export function createUid(name?: string) {
if (name) {
return name + '-' + uuid.v4();
return name + '-' + nanoid();
} else {
return uuid.v4();
return nanoid();
}
}