diff --git a/packages/editor-setters/CHANGELOG.md b/packages/editor-setters/CHANGELOG.md deleted file mode 100644 index 4cac84802..000000000 --- a/packages/editor-setters/CHANGELOG.md +++ /dev/null @@ -1,580 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - - -## [1.0.22](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.21...@ali/lowcode-editor-setters@1.0.22) (2020-11-16) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [1.0.21](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.20...@ali/lowcode-editor-setters@1.0.21) (2020-11-10) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [1.0.20](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.19...@ali/lowcode-editor-setters@1.0.20) (2020-11-10) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [1.0.19](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.18...@ali/lowcode-editor-setters@1.0.19) (2020-11-05) - - -### Bug Fixes - -* 修改style-setter报错,loadAsyncLib 判断 ([7fe793a](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7fe793a)) - - - - - -## [1.0.18](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.17...@ali/lowcode-editor-setters@1.0.18) (2020-11-05) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [1.0.17](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.16...@ali/lowcode-editor-setters@1.0.17) (2020-11-05) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [1.0.16](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.15...@ali/lowcode-editor-setters@1.0.16) (2020-11-04) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [1.0.15](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.13...@ali/lowcode-editor-setters@1.0.15) (2020-11-04) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [1.0.14](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.13...@ali/lowcode-editor-setters@1.0.14) (2020-11-04) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [1.0.13](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.12...@ali/lowcode-editor-setters@1.0.13) (2020-11-02) - - -### Bug Fixes - -* 修复编辑器转化bug,增加窗口最大最小化功能 ([05666af](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/05666af)) - - -### Features - -* style 迁移 ([6ce97da](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/6ce97da)) - - - - - -## [1.0.12](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.11...@ali/lowcode-editor-setters@1.0.12) (2020-10-20) - - -### Bug Fixes - -* 合并分支 ([add2f23](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/add2f23)) -* fix function bug ([ab151df](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ab151df)) - - - - - -## [1.0.11](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.10...@ali/lowcode-editor-setters@1.0.11) (2020-10-19) - - -### Bug Fixes - -* 将monaco基础包全部移除,采用cdn形式注入 ([510f1c0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/510f1c0)) - - - - - -## [1.0.10](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.9...@ali/lowcode-editor-setters@1.0.10) (2020-09-29) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [1.0.9](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.8...@ali/lowcode-editor-setters@1.0.9) (2020-09-28) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [1.0.8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.8-0...@ali/lowcode-editor-setters@1.0.8) (2020-09-28) - - -### Bug Fixes - -* source-editor bug & exp-setter bug ([5cd88d4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/5cd88d4)) - - -### Features - -* 新增class-name setter ([a9f1131](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/a9f1131)) - - - - - -## [1.0.8-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.21...@ali/lowcode-editor-setters@1.0.8-0) (2020-09-09) - - -### Bug Fixes - -* 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad)) -* 清理代码依赖及版本 ([0b15d30](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0b15d30)) -* 适配Nav组件 ([7e9829f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7e9829f)) -* fix function-setter bug ([dced647](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/dced647)) -* fix function-setter bug ([8fd77df](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/8fd77df)) -* fix NextTable callback function ([ce77375](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce77375)) - - -### Features - -* 新增事件入参功能 ([0614fa7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0614fa7)) -* 新增functionSetter ([9359ac6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/9359ac6)) -* add function setter ([114b6b0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/114b6b0)) -* add style-setters ([99b1d84](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/99b1d84)) -* setting-pane 新增removeProp 函数 ([b97c807](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b97c807)) -* tree 组件修改 ([7efa52f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7efa52f)) - - - - - -## [1.0.7-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.6-0...@ali/lowcode-editor-setters@1.0.7-0) (2020-09-02) - -**Note:** Version bump only for package @ali/lowcode-editor-setters - -## [1.0.6-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.19...@ali/lowcode-editor-setters@1.0.6-0) (2020-09-02) - - -## [0.9.21](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.20...@ali/lowcode-editor-setters@0.9.21) (2020-09-03) - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [0.9.20](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.19...@ali/lowcode-editor-setters@0.9.20) (2020-09-03) - - - -### Bug Fixes - -* 合并master分支 ([bd2c6ad](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/bd2c6ad)) -* 清理代码依赖及版本 ([0b15d30](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0b15d30)) -* 适配Nav组件 ([7e9829f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7e9829f)) -* fix function-setter bug ([dced647](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/dced647)) -* fix function-setter bug ([8fd77df](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/8fd77df)) -* fix NextTable callback function ([ce77375](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/ce77375)) - - -### Features - -* 新增事件入参功能 ([0614fa7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0614fa7)) -* 新增functionSetter ([9359ac6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/9359ac6)) -* add function setter ([114b6b0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/114b6b0)) -* add style-setters ([99b1d84](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/99b1d84)) -* setting-pane 新增removeProp 函数 ([b97c807](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b97c807)) -* tree 组件修改 ([7efa52f](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/7efa52f)) - - - - - -## [1.0.5-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.4-0...@ali/lowcode-editor-setters@1.0.5-0) (2020-08-20) - - -## [0.9.19](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.18...@ali/lowcode-editor-setters@0.9.19) (2020-08-27) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [0.9.18](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.17...@ali/lowcode-editor-setters@0.9.18) (2020-08-24) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [0.9.17](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.16...@ali/lowcode-editor-setters@0.9.17) (2020-08-20) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [1.0.4-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.3-0...@ali/lowcode-editor-setters@1.0.4-0) (2020-08-20) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [1.0.3-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.2-0...@ali/lowcode-editor-setters@1.0.3-0) (2020-08-20) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [1.0.2-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@1.0.1-0...@ali/lowcode-editor-setters@1.0.2-0) (2020-08-20) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [1.0.1-0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.16...@ali/lowcode-editor-setters@1.0.1-0) (2020-08-20) - - -### Bug Fixes - -* fix function-setter bug ([8fd77df](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/8fd77df)) - - -### Features - -* add function setter ([114b6b0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/114b6b0)) -* add style-setters ([99b1d84](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/99b1d84)) -* setting-pane 新增removeProp 函数 ([b97c807](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/b97c807)) -* 新增functionSetter ([9359ac6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/9359ac6)) - - - - - -# [1.0.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.14.0...@ali/lowcode-editor-setters@1.0.0) (2020-08-17) - -## [0.9.16](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.15...@ali/lowcode-editor-setters@0.9.16) (2020-08-19) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -# [0.14.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.13.0...@ali/lowcode-editor-setters@0.14.0) (2020-08-17) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -# [0.13.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.11.0...@ali/lowcode-editor-setters@0.13.0) (2020-08-17) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -# [0.12.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.11.0...@ali/lowcode-editor-setters@0.12.0) (2020-08-17) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -# [0.11.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.10.0...@ali/lowcode-editor-setters@0.11.0) (2020-08-16) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -# [0.10.0](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.14...@ali/lowcode-editor-setters@0.10.0) (2020-08-14) - - -### Features - -* add style-setters ([99b1d84](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/99b1d84)) - - - - - -## [0.9.14](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.13...@ali/lowcode-editor-setters@0.9.14) (2020-08-04) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [0.9.13](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.11...@ali/lowcode-editor-setters@0.9.13) (2020-08-04) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [0.9.12](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.11...@ali/lowcode-editor-setters@0.9.12) (2020-08-04) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [0.9.11](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.10...@ali/lowcode-editor-setters@0.9.11) (2020-07-28) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [0.9.10](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.9...@ali/lowcode-editor-setters@0.9.10) (2020-07-22) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [0.9.9](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.8...@ali/lowcode-editor-setters@0.9.9) (2020-07-21) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [0.9.8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.7...@ali/lowcode-editor-setters@0.9.8) (2020-07-21) - - -### Bug Fixes - -* rename MixinSetter to MixedSetter ([0e9a740](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/0e9a740)) - - - - - -## [0.9.7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.6...@ali/lowcode-editor-setters@0.9.7) (2020-07-13) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [0.9.6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.5...@ali/lowcode-editor-setters@0.9.6) (2020-07-12) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [0.9.5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.4...@ali/lowcode-editor-setters@0.9.5) (2020-06-23) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [0.9.4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.3...@ali/lowcode-editor-setters@0.9.4) (2020-06-23) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [0.9.3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.2...@ali/lowcode-editor-setters@0.9.3) (2020-06-15) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [0.9.2](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-editor-setters@0.9.1...@ali/lowcode-editor-setters@0.9.2) (2020-05-20) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## 0.9.1 (2020-05-18) - - - - -**Note:** Version bump only for package @ali/lowcode-editor-setters - - -## [0.8.15](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-setters@0.8.14...@ali/lowcode-setters@0.8.15) (2020-05-15) - - - - -**Note:** Version bump only for package @ali/lowcode-setters - - -## [0.8.14](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-setters@0.8.13...@ali/lowcode-setters@0.8.14) (2020-05-13) - - - - -**Note:** Version bump only for package @ali/lowcode-setters - - -## [0.8.13](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-setters@0.8.12...@ali/lowcode-setters@0.8.13) (2020-05-08) - - - - -**Note:** Version bump only for package @ali/lowcode-setters - - -## [0.8.12](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-setters@0.8.11...@ali/lowcode-setters@0.8.12) (2020-05-07) - - - - -**Note:** Version bump only for package @ali/lowcode-setters - - -## [0.8.11](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-setters@0.8.10...@ali/lowcode-setters@0.8.11) (2020-04-27) - - - - -**Note:** Version bump only for package @ali/lowcode-setters - - -## [0.8.10](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-setters@0.8.9...@ali/lowcode-setters@0.8.10) (2020-04-27) - - - - -**Note:** Version bump only for package @ali/lowcode-setters - - -## [0.8.9](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-setters@0.8.8...@ali/lowcode-setters@0.8.9) (2020-04-27) - - - - -**Note:** Version bump only for package @ali/lowcode-setters - - -## [0.8.8](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-setters@0.8.7...@ali/lowcode-setters@0.8.8) (2020-04-16) - - - - -**Note:** Version bump only for package @ali/lowcode-setters - - -## [0.8.7](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-setters@0.8.6...@ali/lowcode-setters@0.8.7) (2020-04-15) - - -### Features - -* mixin-setter get all setter ([eaa84d2](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/eaa84d2)) -* mixin-setter get all setter ([a5eb62d](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/a5eb62d)) - - - - - -## [0.8.6](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-setters@0.8.5...@ali/lowcode-setters@0.8.6) (2020-03-31) - - - - -**Note:** Version bump only for package @ali/lowcode-setters - - -## [0.8.5](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-setters@0.8.4...@ali/lowcode-setters@0.8.5) (2020-03-30) - - - - -**Note:** Version bump only for package @ali/lowcode-setters - - -## [0.8.4](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-setters@0.8.3...@ali/lowcode-setters@0.8.4) (2020-03-30) - - - - -**Note:** Version bump only for package @ali/lowcode-setters - - -## [0.8.3](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/compare/@ali/lowcode-setters@0.8.2...@ali/lowcode-setters@0.8.3) (2020-03-30) - - - - -**Note:** Version bump only for package @ali/lowcode-setters - - -## 0.8.2 (2020-03-30) - - -### Bug Fixes - -* ts type ([1732e7d](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1732e7d)) - - - - - -## 0.8.1 (2020-03-30) - - -### Bug Fixes - -* ts type ([1732e7d](https://gitlab.alibaba-inc.com/ali-lowcode/ali-lowcode-engine/commit/1732e7d)) diff --git a/packages/editor-setters/README.md b/packages/editor-setters/README.md deleted file mode 100644 index 54458bc05..000000000 --- a/packages/editor-setters/README.md +++ /dev/null @@ -1,140 +0,0 @@ -通用设置器 - -## 使用文档 -- name:绑定props属性key,类型为string -- setter:setter组件内容,类型可以为string或object,当为string时,指setter名,当为object时: - - componentName:setter名,类型为string - - props:setter属性,类型为object - -## 使用demo -``` -{ - "name": "TextAreaSetter", - "setter": "TextAreaSetter" -}, { - "name": "date", - "title": "测试日期", - "setter": "DateSetter" -}, { - "name": "date", - "title": "测试日期-年", - "setter": "DateYearSetter" -}, { - "name": "date", - "title": "测试日期-月", - "setter": "DateMonthSetter" -}, { - "name": "date", - "title": "测试日期-区间", - "setter": "DateRangeSetter" -}, { - "name": "mode", - "title": "选择器模式", - "setter": { - "componentName": "RadioGroupSetter", - "props": { - "defaultValue": "single", - "dataSource": [{ - "value": "single", - "label": "single" - }, { - "value": "multiple", - "label": "multiple" - }, { - "value": "tag", - "label": "tag" - }] - } - } -}, { - "name": "mode", - "title": "选择器模式", - "setter": { - "componentName": "SelectSetter", - "props": { - "defaultValue": "single", - "dataSource": [{ - "value": "single", - "label": "single" - }, { - "value": "multiple", - "label": "multiple" - }, { - "value": "tag", - "label": "tag" - }] - } - } -}, { - "name": "value", - "title": "受控值", - "setter": "StringSetter" -}, { - "name": "hasBorder", - "title": "是否有边框", - "setter": { - "componentName": "BoolSetter", - "props": { - "defaultValue": true - } - } -}, { - "name": "maxTagCount", - "title": "最多显示多少个 tag", - "setter": "NumberSetter" -}, { - "name": "maxTagCount", - "title": "最多显示多少个 tag", - "setter": "ExpressionSetter" -}, { - "name": "color", - "title": "颜色选择", - "setter": "ColorSetter" -}, { - "name": "json", - "title": "JSON设置", - "setter": "JsonSetter" -}, { - "name": "MixinSetter", - "placeholder": "混合", - "setter": { - "componentName": "MixinSetter", - "props": { - "types": [{ - "name": "StringSetter", - "props": {} - }, { - "name": "TextAreaSetter", - "props": {} - }, { - "name": "SelectSetter", - "props": { - "hasClear": true, - "dataSource": [{ - "label": "上", - "value": "t" - }, { - "label": "右", - "value": "r" - }, { - "label": "下", - "value": "b" - }, { - "label": "左", - "value": "l" - }], - "defaultValue": "l" - } - }, { - "name": "NumberSetter", - "props": { - "defaultValue": 5 - } - }, { - "name": "BoolSetter", - "props": {} - }], - "defaultType": "SelectSetter" - } - } -``` \ No newline at end of file diff --git a/packages/editor-setters/build.json b/packages/editor-setters/build.json deleted file mode 100644 index e791d5b6b..000000000 --- a/packages/editor-setters/build.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "plugins": [ - "build-plugin-component", - "build-plugin-fusion", - ["build-plugin-moment-locales", { - "locales": ["zh-cn"] - }] - ] -} diff --git a/packages/editor-setters/package.json b/packages/editor-setters/package.json deleted file mode 100644 index 611fd6d00..000000000 --- a/packages/editor-setters/package.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "@ali/lowcode-editor-setters", - "version": "1.0.22", - "description": "Builtin setters for Ali lowCode engine", - "files": [ - "es", - "lib" - ], - "main": "lib/index.js", - "module": "es/index.js", - "scripts": { - "build": "build-scripts build --skip-demo", - "test": "ava", - "test:snapshot": "ava --update-snapshots" - }, - "dependencies": { - "@ali/intl-universal": "^0.4.9", - "@ali/lc-style-setter": "0.0.2", - "@ali/lowcode-editor-core": "^1.0.22", - "@ali/ve-choice-control": "^4.0.0", - "@ali/ve-code-control": "^4.0.0", - "@ali/ve-color-control": "^4.0.0", - "@ali/ve-field": "^4.2.0-beta.8", - "@ali/ve-icons": "^4.1.9", - "@ali/ve-image-control": "^4.0.0", - "@ali/ve-less-variables": "^2.0.0", - "@ali/ve-number-control": "^4.0.0", - "@ali/ve-select-control": "^4.0.0", - "@ali/ve-text-control": "^4.0.0", - "@ali/vs-style-select": "0.0.1-beta.8", - "@ali/vu-css-style": "^1.0.2", - "@ali/vu-icon-base": "^1.0.2", - "@alifd/next": "^1.19.16", - "acorn": "^6.4.1", - "classnames": "^2.2.6", - "css-border-property": "^1.1.0", - "css-color-names": "0.0.4", - "intl-messageformat": "^9.3.1", - "lodash.curry": "^4.1.1", - "lodash.flow": "^3.5.0", - "lodash.throttle": "^4.1.1", - "lodash.zipobject": "^4.1.3", - "parse-css-font": "^2.0.2", - "postcss-value-parser": "^3.3.0", - "qs": "^6.9.1", - "react": "^16", - "react-dom": "^16.7.0", - "react-monaco-editor": "0.40.0" - }, - "devDependencies": { - "@alib/build-scripts": "^0.1.18", - "@types/classnames": "^2.2.7", - "@types/node": "^13.7.1", - "@types/react": "^16", - "@types/react-dom": "^16", - "build-plugin-component": "^0.2.10", - "build-plugin-fusion": "^0.1.0", - "build-plugin-moment-locales": "^0.1.0" - }, - "ava": { - "compileEnhancements": false, - "snapshotDir": "test/fixtures/__snapshots__", - "extensions": [ - "ts" - ], - "require": [ - "ts-node/register" - ] - }, - "publishConfig": { - "registry": "https://registry.npm.alibaba-inc.com" - } -} diff --git a/packages/editor-setters/src/classname-setter/index.tsx b/packages/editor-setters/src/classname-setter/index.tsx deleted file mode 100644 index 76f649059..000000000 --- a/packages/editor-setters/src/classname-setter/index.tsx +++ /dev/null @@ -1,90 +0,0 @@ -import React, { PureComponent } from 'react'; -import PropTypes from 'prop-types'; -import { Select } from '@alife/next'; - -interface Color { - rgb: any; - onChange: () => void; -} - -export interface PluginProps { - value: string; - onChange: any; -} - -export default class ClassNameView extends PureComponent { - static display = 'ClassName'; - - static propTypes = { - onChange: PropTypes.func, - value: PropTypes.string, - }; - - static defaultProps = { - onChange: () => {}, - value: '', - }; - - getClassNameList = () => { - const { editor } = this.props.field; - const schema = editor.get('designer').project.getSchema(); - const css = schema.componentsTree[0].css; - const classNameList = []; - const re = /\.?\w+[^{]+\{[^}]*\}/g; - const list = css.match(re); - list.map((item) => { - if (item[0] === '.') { - const className = item.substring(1, item.indexOf('{')); - classNameList.push(className); - } - - return item; - }); - - return classNameList; - }; - - - handleChange = (value) => { - const { onChange } = this.props; - onChange(value.join(' ')); - this.setState({ - selectValue: value, - }); - }; - - // eslint-disable-next-line react/no-deprecated - componentWillMount() { - const { value } = this.props; - const classnameList = this.getClassNameList(); - const dataSource = []; - classnameList.map((item) => { - dataSource.push({ - value: item, - label: item, - }); - - return item; - }); - - - let selectValue = []; - if (value && value !== '') { - selectValue = value.split(' '); - } - - - this.setState({ - dataSource, - selectValue, - }); - } - - - render() { - const { dataSource, selectValue } = this.state; - return ( - - ); - } -} diff --git a/packages/editor-setters/src/events-setter/index.scss b/packages/editor-setters/src/events-setter/index.scss deleted file mode 100644 index 375b2820f..000000000 --- a/packages/editor-setters/src/events-setter/index.scss +++ /dev/null @@ -1,90 +0,0 @@ -.event-body { - padding: 0 10px 0 10px; - position: relative; - min-height: 450px; - - .event-title { - height: 30px; - line-height: 30px; - margin-bottom: 10px; - } - - - .next-radio-group { - display: -webkit-box; - display: -webkit-flex; - display: -ms-flexbox; - display: flex; - } - - .next-table td .next-table-cell-wrapper{ - padding: 12px 10px; - overflow: hidden; - text-overflow: ellipsis; - word-break: break-all; - } - - .next-radio-group label { - -webkit-box-flex: 1; - -webkit-flex: auto; - -ms-flex: auto; - flex: auto; - text-align: center; - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; - } - - - .event-cell { - padding-left: 25px; - position: relative; - font-size: 12px; - } - - .event-type-tag { - position: absolute; - width: 20px; - height: 20px; - left: 0px; - top: -2px; - border-radius: 50%; - line-height: 20px; - text-align: center; - color: #ffffff; - background-color: #2077ff; - } - - .related-icon { - margin-right: 5px; - } - - .related-event-name { - color: #2077ff; - cursor: pointer; - } - - - .event-menu { - max-height: 300px; - width: 256px; - overflow-x: hidden; - position: absolute; - top: 67px; - left: 10px; - z-index: 10; - } - - .event-table { - margin-top: 20px; - } - - .event-operate-icon { - cursor: pointer; - } - - .event-operate-icon:hover { - color: #0079f2; - } -} - diff --git a/packages/editor-setters/src/events-setter/index.tsx b/packages/editor-setters/src/events-setter/index.tsx deleted file mode 100644 index b0d806ecb..000000000 --- a/packages/editor-setters/src/events-setter/index.tsx +++ /dev/null @@ -1,464 +0,0 @@ -import { Component } from 'react'; -import { Radio, Menu, Table, Icon } from '@alifd/next'; -import nativeEvents from './native-events'; - -import './index.scss'; - -const { Item, Group } = Menu; -const RadioGroup = Radio.Group; - -const EVENT_CONTENTS = { - COMPONENT_EVENT: 'componentEvent', - NATIVE_EVENT: 'nativeEvent', - LIFE_CYCLE_EVENT: 'lifeCycleEvent', -}; - -const DEFINITION_EVENT_TYPE = { - EVENTS: 'events', - NATIVE_EVENTS: 'nativeEvents', - LIFE_CYCLE_EVENT: 'lifeCycleEvent', -}; - -const SETTER_NAME = 'event-setter'; - -export default class EventsSetter extends Component<{ - value: any[]; - onChange: (eventList: any[]) => void; -}> { - state = { - eventBtns: [], - eventList: [], - selectType: null, - nativeEventList: [], - lifeCycleEventList: [], - eventDataList: (this.props?.value?.eventDataList ? this.props.value.eventDataList : this.props?.value) || [], - }; - - // constructor (){ - // super(); - // debugger; - // // if (!this.props || !this.props.value){ - // // this.setState({ - // // eventDataList:[] - // // }) - // // } - // } - - // static getDerivedStateFromProps(nextProps, prevState) { - // debugger; - // // const { value } = nextProps; - // // debugger; - // // if (value !== prevState.eventDataList) { - // // return { - // // value, - // // }; - // // } - // return null; - // } - - private bindEventName: string; - - componentDidMount() { - console.log(this.state.eventDataList); - - const { editor } = this.props.field; - this.initEventBtns(); - this.initEventList(); - editor.on(`${SETTER_NAME}.bindEvent`, (relatedEventName, paramStr) => { - this.bindEvent(relatedEventName, paramStr); - }); - } - - /** - * 初始化事件按钮 - */ - initEventBtns() { - const { definition } = this.props; - let isRoot = false; - let isCustom = false; - let eventBtns = []; - definition.map(item => { - if (item.type === DEFINITION_EVENT_TYPE.LIFE_CYCLE_EVENT) { - isRoot = true; - } - - if (item.type === DEFINITION_EVENT_TYPE.EVENTS) { - isCustom = true; - } - - return item; - }); - - if (isRoot) { - eventBtns = [ - { - value: EVENT_CONTENTS.LIFE_CYCLE_EVENT, - label: '生命周期', - }, - ]; - } else if (isCustom) { - eventBtns = [ - { - value: EVENT_CONTENTS.COMPONENT_EVENT, - label: '组件自带事件', - }, - ]; - } else { - eventBtns = [ - { - value: EVENT_CONTENTS.NATIVE_EVENT, - label: '原生事件', - }, - ]; - } - - this.setState({ - eventBtns, - }); - } - - initEventList() { - const { definition } = this.props; - let nativeEventList = []; - definition.map(item => { - if (item.type === DEFINITION_EVENT_TYPE.EVENTS) { - this.checkEventListStatus(item.list, DEFINITION_EVENT_TYPE.EVENTS); - this.setState({ - eventList: item.list, - }); - } - - if (item.type === DEFINITION_EVENT_TYPE.NATIVE_EVENTS) { - this.checkEventListStatus( - item.list, - DEFINITION_EVENT_TYPE.NATIVE_EVENTS, - ); - nativeEventList = item.list; - } - - if (item.type === DEFINITION_EVENT_TYPE.LIFE_CYCLE_EVENT) { - this.checkEventListStatus( - item.list, - DEFINITION_EVENT_TYPE.LIFE_CYCLE_EVENT, - ); - this.setState({ - lifeCycleEventList: item.list, - }); - } - - return item; - }); - - if (nativeEventList.length == 0) { - nativeEventList = nativeEvents; - this.setState({ - nativeEventList, - }); - } - } - - checkEventListStatus = (eventList: any[], eventType: string) => { - const { eventDataList } = this.state; - if ( - eventType === DEFINITION_EVENT_TYPE.EVENTS || - eventType === DEFINITION_EVENT_TYPE.LIFE_CYCLE_EVENT - ) { - eventList.map(item => { - item.disabled = false; - eventDataList.map(eventDataItem => { - if (item.name === eventDataItem.name) { - item.disabled = true; - } - - return eventDataItem; - }); - - return item; - }); - } else if (eventType === DEFINITION_EVENT_TYPE.NATIVE_EVENTS) { - eventDataList.map(eventDataItem => { - eventList.map(item => { - item.eventList.map(eventItem => { - if (eventItem.name === eventDataItem.name) { - item.disabled = true; - } else { - item.disabled = false; - } - return eventItem; - }); - return item; - }); - - return eventDataItem; - }); - } - }; - - /** - * 渲染事件信息 - */ - renderEventInfoCell = (value, index, record) => { - let eventTagText = ''; - if (record.type === EVENT_CONTENTS.NATIVE_EVENT) { - eventTagText = '原'; - } else if (record.type === EVENT_CONTENTS.COMPONENT_EVENT) { - eventTagText = '组'; - } else if (record.type === EVENT_CONTENTS.LIFE_CYCLE_EVENT) { - eventTagText = '生'; - } - return ( -
-
-
{eventTagText}
- {record.name} -
-
- - this.onRelatedEventNameClick(record.relatedEventName)}> - {record.relatedEventName || ''} - -
-
- ); - }; - - /** - * 渲染事件操作项 - */ - renderEventOperateCell = (eventName: string) => { - return ( -
- this.openDialog(eventName)} - /> - this.openDeleteEventDialog(eventName)} - /> -
- ); - }; - - updateEventListStatus = (eventName: string, unDisabled: boolean) => { - const { eventList, nativeEventList, lifeCycleEventList } = this.state; - eventList.map(item => { - if (item.name === eventName) { - item.disabled = !unDisabled; - } - return item; - }); - - lifeCycleEventList.map(item => { - if (item.name === eventName) { - item.disabled = !unDisabled; - } - return item; - }); - - nativeEventList.map(item => { - item.eventList.map(itemData => { - if (itemData.name === eventName) { - itemData.disabled = !unDisabled; - } - return itemData; - }); - - return item; - }); - }; - - onRadioChange = value => { - this.setState({ - selectType: value, - }); - }; - - - onEventMenuClick = (eventName: string) => { - const { selectType, eventDataList } = this.state; - eventDataList.push({ - type: selectType, - name: eventName, - }); - - this.setState({ - eventDataList, - }); - - this.updateEventListStatus(eventName); - this.closeEventMenu(); - this.openDialog(eventName); - }; - - onRelatedEventNameClick = (eventName: string) => { - const { editor } = this.props.field; - - editor.get('skeleton').getPanel('sourceEditor').show(); - - setTimeout(() => { - editor.emit('sourceEditor.focusByFunction', { - functionName: eventName, - }); - }, 300); - - - // editor.emit('sourceEditor.focusByFunction',{ - // functionName:eventName - // }) - }; - - closeEventMenu = () => { - if (this.state.selectType !== null) { - this.setState({ - selectType: null, - }); - } - }; - - openDeleteEventDialog = (eventName: string) => { - this.deleteEvent(eventName); - // Dialog.confirm({ - // title: '删除事件', - // content: '确定删除当前事件吗', - // onOk: () => this.deleteEvent(eventName), - // }); - }; - - deleteEvent = (eventName: string) => { - const { eventDataList, eventList } = this.state; - eventDataList.map((item, index) => { - if (item.name === eventName) { - eventDataList.splice(index, 1); - } - - return item; - }); - - this.setState({ - eventDataList, - }); - this.props.onChange({ eventDataList, eventList }); - this.updateEventListStatus(eventName, true); - }; - - openDialog = (bindEventName: string) => { - const { editor } = this.props.field; - const { eventDataList } = this.state; - let paramStr; - eventDataList.map((item) => { - if (item.name == bindEventName) { - paramStr = item.paramStr; - } - return item; - }); - this.bindEventName = bindEventName; - editor.emit('eventBindDialog.openDialog', bindEventName, SETTER_NAME, paramStr); - }; - - - bindEvent = (relatedEventName: string, paramStr: string) => { - const { eventDataList, eventList } = this.state; - eventDataList.map(item => { - if (item.name === this.bindEventName) { - item.relatedEventName = relatedEventName; - if (paramStr) { - item.paramStr = paramStr; - } - } - - return item; - }); - - this.setState({ - eventDataList, - }); - - - this.props.onChange({ eventDataList, eventList }); - - // this.closeDialog(); - }; - - render() { - const { - eventBtns, - eventList, - nativeEventList, - lifeCycleEventList, - selectType, - eventDataList, - } = this.state; - const showEventList = - lifeCycleEventList.length > 0 ? lifeCycleEventList : eventList; - return ( -
- -
- { - eventBtns.length > 1 ? 点击选择事件类型 : 点击绑定事件 - } -
- - - {selectType && selectType != EVENT_CONTENTS.NATIVE_EVENT && ( - - {showEventList.map((item) => ( - - {item.name} - - ))} - - )} - - {selectType && selectType === EVENT_CONTENTS.NATIVE_EVENT && ( - - {nativeEventList.map((item, index) => ( - - {item.eventList.map(groupItem => ( - - {groupItem.name} - - ))} - - ))} - - )} - -
- - - -
-
-
- ); - } -} diff --git a/packages/editor-setters/src/events-setter/native-events.ts b/packages/editor-setters/src/events-setter/native-events.ts deleted file mode 100644 index 9bf6c5ae5..000000000 --- a/packages/editor-setters/src/events-setter/native-events.ts +++ /dev/null @@ -1,56 +0,0 @@ -export default [ - { - category: 'commonlyEvent', - name: '常用事件', - eventList: [ - { name: 'onClick' }, - { name: 'onChange' }, - { name: 'onInput' }, - { name: 'onSelect' }, - { name: 'onSubmit' }, - { name: 'onReset' }, - { name: 'onFocus' }, - { name: 'onBlur' }, - { name: 'onScroll' }, - { name: 'onLoad' }, - { name: 'onError' }, - ], - }, - { - category: 'keybordEvent', - name: '键盘事件', - eventList: [{ name: 'onKeyDown' }, { name: 'onKeyPress' }, { name: 'onKeyUp' }], - }, - { - category: 'mouseEvent', - name: '鼠标事件', - eventList: [ - { name: 'onDoubleClick' }, - { name: 'onDrag' }, - { name: 'onDragEnd' }, - { name: 'onDragEnter' }, - { name: 'onDragExit' }, - { name: 'onDragLeave' }, - { name: 'onDragOver' }, - { name: 'onDragStart' }, - { name: 'onDrop' }, - { name: 'onMouseDown' }, - { name: 'onMouseEnter' }, - { name: 'onMouseLeave' }, - { name: 'onMouseMove' }, - { name: 'onMouseOut' }, - { name: 'onMouseOver' }, - { name: 'onMouseUp' }, - ], - }, - { - category: 'animateEvent', - name: '动画事件', - eventList: [ - { name: 'onAnimationStart' }, - { name: 'onAnimationEnd' }, - { name: 'onAnimationItration' }, - { name: 'onTransitionEnd' }, - ], - }, -]; diff --git a/packages/editor-setters/src/expression-setter/index.scss b/packages/editor-setters/src/expression-setter/index.scss deleted file mode 100644 index 0d12a5571..000000000 --- a/packages/editor-setters/src/expression-setter/index.scss +++ /dev/null @@ -1,17 +0,0 @@ -.expression-setter-item-inner { - .next-menu-item-text { - vertical-align: middle; - display: flex; - justify-content: space-between; - } - .next-menu-item { - padding: 0 10px; - } -} -.code-input-value { - float: left; -} -.code-input-help { - float: right; - color: #6897f2; -} diff --git a/packages/editor-setters/src/expression-setter/index.tsx b/packages/editor-setters/src/expression-setter/index.tsx deleted file mode 100644 index 040c6f5b1..000000000 --- a/packages/editor-setters/src/expression-setter/index.tsx +++ /dev/null @@ -1,349 +0,0 @@ -import React, { PureComponent } from 'react'; -import PropTypes from 'prop-types'; -import { Select, Balloon } from '@alife/next'; -import * as acorn from 'acorn'; - -import { isJSExpression, generateI18n } from './locale/utils'; -import zhCN from './locale/zh-CN'; - -import './index.scss'; - -const { Option, AutoComplete } = Select; -const { Tooltip } = Balloon; -const helpMap = { - this: '容器上下文对象', - state: '容器的state', - props: '容器的props', - context: '容器的context', - schema: '页面上下文对象', - component: '组件上下文对象', - constants: '应用常量对象', - utils: '应用工具对象', - dataSourceMap: '容器数据源Map', - field: '表单Field对象', -}; - -export default class ExpressionView extends PureComponent { - static displayName = 'Expression'; - - static propTypes = { - context: PropTypes.object, - dataSource: PropTypes.array, - locale: PropTypes.string, - messages: PropTypes.object, - onChange: PropTypes.func, - placeholder: PropTypes.string, - value: PropTypes.string, - }; - - static defaultProps = { - context: {}, - dataSource: [], - locale: 'zh-CN', - messages: zhCN, - onChange: () => {}, - placeholder: '', - value: '', - }; - - expression: React.RefObject; - - i18n: any; - - t: void; - - $input: any; - - listenerFun: ((event: any) => void) | undefined; - - static getInitValue(val: { value: any; match: (arg0: RegExp) => any; }) { - if (isJSExpression(val)) { - if (typeof val === 'object') { - return val.value; - } else if (typeof val === 'string') { - const arr = val.match(/^\{\{(.*?)\}\}$/); - if (arr) return arr[1]; - } - } - return val; - } - - constructor(props: any) { - super(props); - this.expression = React.createRef(); - this.i18n = generateI18n(props.locale, props.messages); - this.state = { - value: ExpressionView.getInitValue(props.value), - dataSource: props.dataSource || [], - }; - } - - static getDerivedStateFromProps(props: { value: any; }, state: { preValue: any; }) { - const curValue = ExpressionView.getInitValue(props.value); - if (curValue !== state.preValue) { - return { - preValue: curValue, - value: curValue, - }; - } - return null; - } - - onChange(value: string) { - const realInputValue = value; - const realDataSource = null; - let nextCursorIndex: number; - // 更新值 - // if (actionType === 'itemClick' || actionType === 'enter') { - // // const curValue = this.state.value; - // // if (curValue) { - // // realInputValue = curValue + realInputValue; - // // } - // } - // 更新数据源 - const newState = { - value: realInputValue, - }; - if (realDataSource !== null) newState.dataSource = realDataSource; - this.setState(newState, () => { - nextCursorIndex && this.setInputCursorPosition(nextCursorIndex); - }); - // 默认加上变量表达式 - this.t && clearTimeout(this.t); - this.t = setTimeout(() => { - const { onChange } = this.props; - // realInputValue = realInputValue ? `{{${realInputValue}}}` : undefined; - onChange && onChange({ - type: 'JSExpression', - value: realInputValue, - }); - }, 300); - } - - /** - * 获取AutoComplete数据源 - * @param {String} - * @return {Array} - */ - getDataSource(): any[] { - const { editor } = this.props.field; - const schema = editor.get('designer').project.getSchema(); - const stateMap = schema.componentsTree[0].state; - const dataSource = []; - - for (const key in stateMap) { - dataSource.push(`this.state.${key}`); - } - - return dataSource; - } - - /** - * 获取光标前的对象字符串,语法解析获取对象字符串 - * @param {String} str 模板字符串 - * @return {String} 光标前的对象字符串 - */ - getCurrentFiled(str: string | any[]) { - str += 'x'; // .后面加一个x字符,便于acorn解析 - try { - const astTree = acorn.parse(str); - const right = astTree.body[0].expression.right || astTree.body[0].expression; - if (right.type === 'MemberExpression') { - const { start, end } = right; - str = str.slice(start, end); - return { str, start, end }; - } - } catch (e) { - return null; - } - } - - /** - * 获取输入的上下文信息 - * @param {Array} - * @return {Array} - */ - getContextKeys(keys: []) { - const { editor } = this.props.field; - console.log(editor); - const limitKeys = ['schema', 'utils', 'constants']; - if (keys.length === 0) return limitKeys; - if (!limitKeys.includes(keys[0])) return []; - let result = []; - let keyValue = editor; - let assert = false; - keys.forEach(item => { - if (!keyValue[item] || typeof keyValue[item] !== 'object') { - assert = true; - } - if (keyValue[item]) { - keyValue = keyValue[item]; - } - }); - if (assert) return []; - result = Object.keys(keyValue); - return result; - // return utilsKeys.concat(constantsKeys).concat(schemaKeys); - } - - /* 过滤key */ - filterKey(obj: any, name: string) { - const filterKeys = [ - 'reloadDataSource', - 'REACT_HOT_LOADER_RENDERED_GENERATION', - 'refs', - 'updater', - 'appHelper', - 'isReactComponent', - 'forceUpdate', - 'setState', - 'isPureReactComponent', - ]; - const result = []; - for (const key in obj) { - if (key.indexOf('_') !== 0 && filterKeys.indexOf(key) === -1) { - result.push(`${name}.${key}`); - } - } - return result; - } - - /** - * 根据输入项进行筛选 - * @param {String} - * @param {String} - * @return {Boolen} - */ - filterOption(inputValue: string, item: { value: string | any[]; }) { - const cursorIndex = this.getInputCursorPosition(); - const preStr = inputValue.substr(0, cursorIndex); - const lastKey: string[] = preStr.split('.').slice(-1); - if (!lastKey) return true; - if (item.value.indexOf(lastKey) > -1) return true; - return false; - } - - // handleClick = () => { - // this.props.field.editor.emit('variableBindDialog.open'); - // } - - render() { - const { value, dataSource } = this.state; - const { placeholder } = this.props; - const isValObject = !!(value == '[object Object]'); - const title = isValObject - ? this.i18n('valueIllegal') - : (value || placeholder || this.i18n('jsExpression')).toString(); - const cursorIndex = this.getInputCursorPosition(); - const childNode = cursorIndex ? ( -
- {title.substr(0, cursorIndex)} - | - {title.substr(cursorIndex)} -
- ) : ( - title - ); - - return ( -
- - {'{{'}} - innerAfter={{'}}'}} - popupClassName="expression-setter-item-inner" - // eslint-disable-next-line no-shadow - itemRender={({ value }) => { - return ( - - ); - }} - onChange={this.onChange.bind(this)} - filter={this.filterOption.bind(this)} - /> -
- ) - } - > - {childNode} - - - ); - } - - componentDidMount() { - this.$input = this.findInputElement(); - if (this.$input) { - this.listenerFun = event => { - const isMoveKey = !!(event.type == 'keyup' && ~[37, 38, 39, 91].indexOf(event.keyCode)); - const isMouseup = event.type == 'mouseup'; - if (isMoveKey || isMouseup) { - // eslint-disable-next-line react/no-access-state-in-setstate - const dataSource = this.getDataSource(this.state.value) || []; - this.setState({ - dataSource, - }); - } - }; - this.$input.addEventListener('keyup', this.listenerFun, false); - this.$input.addEventListener('mouseup', this.listenerFun, false); - } - } - - componentWillUnmount() { - if (this.listenerFun && this.$input) { - this.$input.removeEventListener('keyup', this.listenerFun, false); - this.$input.removeEventListener('mouseup', this.listenerFun, false); - } - } - - /** - * 获取Input输入框DOM节点 - */ - findInputElement() { - return this.expression.current.children[0].getElementsByTagName('input')[0]; - } - - /** - * 获取光标位置 - * - */ - getInputCursorPosition() { - if (!this.$input) return; - return this.$input.selectionStart; - } - - /* - * 字符串取得对象keys - */ - getObjectKeys(str: string) { - let keys: string | any[] = []; - if (str) keys = str.split('.'); - return keys.slice(0, keys.length - 1); - } - - /* - * 设置input组件光标位置在闭合}前 - */ - setInputCursorPosition(idx: number) { - this.$input.setSelectionRange(idx, idx); - this.forceUpdate(); - } -} diff --git a/packages/editor-setters/src/expression-setter/locale/snippets.ts b/packages/editor-setters/src/expression-setter/locale/snippets.ts deleted file mode 100644 index 2bcb0dd00..000000000 --- a/packages/editor-setters/src/expression-setter/locale/snippets.ts +++ /dev/null @@ -1,242 +0,0 @@ -export default [ - { - label: 'constants', - kind: 'Class', - insertText: 'constants', - detail: '应用全局常量', - documentation: '应用范围定义的通用常量', - }, - { - label: 'utils', - kind: 'Class', - insertText: 'utils', - detail: '应用全局公共函数', - documentation: '应用范围扩展的公共函数', - }, - { - label: 'state', - kind: 'Enum', - insertText: 'state', - detail: '当前所在容器组件内部状态', - documentation: 'React Class内部状态state', - }, - { - label: 'setState', - kind: 'Function', - insertText: 'setState({\n\t$0\n})', - insertTextRules: 'InsertAsSnippet', - detail: '设置当前所在容器组件的state数据', - documentation: '原生React方法,会自动更新组件视图', - }, - { - label: 'reloadDataSource', - kind: 'Function', - insertText: 'reloadDataSource(${1:${2:namespace}, ${3:false}, ${4:callback}})', - insertTextRules: 'InsertAsSnippet', - detail: '刷新当前所在的容器组件', - documentation: '触发当前所在的容器组件,重新发送异步请求,并用最新数据更新视图', - }, - { - label: 'location', - kind: 'Class', - insertText: 'location', - detail: '路由解析对象', - }, - { - label: 'location.query', - kind: 'Value', - insertText: 'location.query.${1:xxxx}', - insertTextRules: 'InsertAsSnippet', - detail: '从路由解析对象中获取参数信息', - }, - { - label: 'history', - kind: 'Class', - insertText: 'history', - detail: '路由历史对象', - }, - { - label: 'React', - kind: 'Keyword', - insertText: 'React', - detail: 'React对象', - }, - { - label: 'ReactDOM', - kind: 'Keyword', - insertText: 'ReactDOM', - detail: 'ReactDom对象', - }, - { - label: 'ReactDOM.findDOMNode', - kind: 'Function', - insertText: 'ReactDOM.findDOMNode(${1:this.refs.xxxx})', - insertTextRules: 'InsertAsSnippet', - detail: 'ReactDom查找真实dom node', - }, - { - label: 'Dialog.alert', - kind: 'Method', - insertText: [ - 'Dialog.alert({', - "\tcontent: '${1:Alert content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: 'alert弹框 By Fusion', - }, - { - label: 'Dialog.confirm', - kind: 'Method', - insertText: [ - 'Dialog.confirm({', - "\tcontent: '${1:Confirm content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '确认弹出框 By Fusion', - }, - { - label: 'Message.success', - kind: 'Method', - insertText: 'Message.success(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: '成功反馈提示 By Fusion', - }, - { - label: 'Message.error', - kind: 'Method', - insertText: 'Message.error(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: '错误反馈提示 By Fusion', - }, - { - label: 'Message.help', - kind: 'Method', - insertText: 'Message.help(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: '帮助反馈提示 By Fusion', - }, - { - label: 'Message.loading', - kind: 'Method', - insertText: 'Message.loading(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: 'loading反馈提示 By Fusion', - }, - { - label: 'Message.notice', - kind: 'Method', - insertText: 'Message.notice(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: '注意反馈提示 By Fusion', - }, - { - label: 'Message.waining', - kind: 'Method', - insertText: 'Message.waining(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: '警告反馈提示 By Fusion', - }, - { - label: 'Modal.confirm', - kind: 'Method', - insertText: [ - 'Modal.confirm({', - "\tcontent: '${1:Confirm content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '确认弹出框 By Antd', - }, - { - label: 'Modal.info', - kind: 'Method', - insertText: [ - 'Modal.info({', - "\tcontent: '${1:Info content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '信息弹出框 By Antd', - }, - { - label: 'Modal.success', - kind: 'Method', - insertText: [ - 'Modal.success({', - "\tcontent: '${1:Success content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '成功弹出框 By Antd', - }, - { - label: 'Modal.error', - kind: 'Method', - insertText: [ - 'Modal.error({', - "\tcontent: '${1:Error content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '错误弹出框 By Antd', - }, - { - label: 'Modal.warning', - kind: 'Method', - insertText: [ - 'Modal.warning({', - "\tcontent: '${1:Warning content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '警告弹出框 By Antd', - }, -]; diff --git a/packages/editor-setters/src/expression-setter/locale/utils.ts b/packages/editor-setters/src/expression-setter/locale/utils.ts deleted file mode 100644 index d401ad511..000000000 --- a/packages/editor-setters/src/expression-setter/locale/utils.ts +++ /dev/null @@ -1,21 +0,0 @@ -import IntlMessageFormat from 'intl-messageformat'; - -export const isJSExpression = (obj = '') => { - if (obj && typeof obj === 'object' && obj.type === 'JSExpression') { - return true; - } - return false; -}; - -/** - * 用于构造国际化字符串处理函数 - * @param {*} locale 国际化标识,例如 zh-CN、en-US - * @param {*} messages 国际化语言包 - */ -export const generateI18n = (locale = 'zh-CN', messages = {}) => { - return function (key, values = {}) { - if (!messages || !messages[key]) return ''; - const formater = new IntlMessageFormat(messages[key], locale); - return formater.format(values); - }; -}; diff --git a/packages/editor-setters/src/expression-setter/locale/zh-CN.ts b/packages/editor-setters/src/expression-setter/locale/zh-CN.ts deleted file mode 100644 index f4f2e0630..000000000 --- a/packages/editor-setters/src/expression-setter/locale/zh-CN.ts +++ /dev/null @@ -1,36 +0,0 @@ -export default { - // function - setting: '点击设置', - edit: '编辑', - submitConfirm: '确认提交 cmd+s', - close: '关闭 esc', - fullScreen: '全屏', - cancelFullScreen: '取消全屏', - jsonIllegal: '非json格式', - functionIllegal: '非function格式', - objectIllegal: '非object格式', - circularRef: '对象中出现循环引用的对象', - formatError: '格式错误', - saved: '已保存', - // expression - valueIllegal: '值类型为对象类型,与当前组件属性设置的控件类型不匹配,请在属性“代码编辑模式”下进行编辑', - jsExpression: '请输入JS表达式', - // Mixin - input: '字符串Input', - textarea: '多行字符串Textarea', - expression: '变量控件Expression', - monacoEditor: '编辑器MonacoEditor', - numberPicker: '数字NumberPicker', - bool: '布尔Switch', - datePicker: '日期选择DatePicker', - select: '下拉选择Select', - radio: '单项选择RadioGroup', - date: '日期选择DatePicker', - dateYear: '年选择DatePicker', - dateMonth: '月选择DatePicker', - dateRange: '日期区间选择DatePicker', - list: '数组List', - object: '对象ObjectButton', - reactNode: '节点类型ReactNode', - typeError: 'Minix组件属性Types配置错误,存在不支持类型[{type}],请检查组件属性配置', -}; diff --git a/packages/editor-setters/src/function-setter/index.scss b/packages/editor-setters/src/function-setter/index.scss deleted file mode 100644 index c11b6beb9..000000000 --- a/packages/editor-setters/src/function-setter/index.scss +++ /dev/null @@ -1,30 +0,0 @@ -.lc-function-setter{ - - .function-container{ - position: relative; - - } - - .funtion-icon{ - float: left; - width: 25px; - height: 25px; - } - - .function-name{ - font-size: 14px; - color:#5584FF; - margin-left:5px; - cursor: pointer; - - } - - .funtion-operate-icon{ - font-size: 16px; - margin-left:5px; - cursor: pointer; - } -} - - - diff --git a/packages/editor-setters/src/function-setter/index.tsx b/packages/editor-setters/src/function-setter/index.tsx deleted file mode 100644 index a9adebd6c..000000000 --- a/packages/editor-setters/src/function-setter/index.tsx +++ /dev/null @@ -1,241 +0,0 @@ - -import React, { PureComponent } from 'react'; -// import PropTypes from 'prop-types'; -import { Button, Icon, Dialog } from '@alifd/next'; -import MonacoEditor from 'react-monaco-editor'; -import { js_beautify } from 'js-beautify'; -import './index.scss'; - -const SETTER_NAME = 'function-setter'; - -const defaultEditorOption = { - width: '100%', - height: '100%', - options: { - readOnly: false, - automaticLayout: true, - folding: true, // 默认开启折叠代码功能 - lineNumbers: 'on', - wordWrap: 'off', - formatOnPaste: true, - fontSize: 12, - tabSize: 2, - scrollBeyondLastLine: false, - fixedOverflowWidgets: false, - snippetSuggestions: 'top', - minimap: { - enabled: false, - }, - scrollbar: { - vertical: 'auto', - horizontal: 'auto', - }, - }, -}; - - -interface FunctionSetterProps { - value: string; - type: string; - defaultValue: string; - placeholder: string; - hasClear: boolean; - onChange: (icon: string) => undefined; - icons: string[]; -} -export default class FunctionSetter extends PureComponent { - static defaultProps = { - value: undefined, - type: 'string', - defaultValue: '', - hasClear: true, - placeholder: '请点击选择 Icon', - onChange: () => undefined, - }; - - private emitEventName = ''; - - state = { - isShowDialog: false, - }; - - componentDidMount() { - const { editor } = this.props.field; - this.emitEventName = `${SETTER_NAME}-${this.props.field.id}`; - editor.on(`${this.emitEventName}.bindEvent`, this.bindEvent); - } - - bindEvent = (eventName, paramStr) => { - this.bindEventCallback(eventName, paramStr); - }; - - - componentWillUnmount() { - const { editor } = this.props.field; - editor.off(`${this.emitEventName}.bindEvent`, this.bindEvent); - } - - - bindFunction = (isEdit) => { - const { field, value } = this.props; - - let paramStr; - - if (value) { - paramStr = this.parseFunctionParam(value.value); - } - - - field.editor.emit('eventBindDialog.openDialog', field.name, this.emitEventName, paramStr, isEdit); - }; - - openDialog = () => { - const { value = {} } = this.props; - this.setState({ - isShowDialog: true, - }); - - this.functionCode = value.value; - }; - - closeDialog = () => { - this.setState({ - isShowDialog: false, - }); - }; - - removeFunctionBind = () => { - const { removeProp } = this.props; - removeProp(); - }; - - parseFunctionName = (functionString: string) => { - // 因为函数格式是固定的,所以可以按照字符换去匹配获取函数名 - return functionString.split('this.')[1]?.split('.')[0]; - }; - - parseFunctionParam = (functionString:string) => { - // eslint-disable-next-line no-useless-escape - const matchList = functionString.match(/\[(\w|\s|\,|")*\]/); - if (matchList?.length) { - return matchList[0].substring(1, matchList[0].length - 1); - } - }; - - /** - * 渲染按钮(初始状态) - */ - renderButton = () => { - return ; - }; - - updateCode = (newCode) => { - this.functionCode = newCode; - }; - - onDialogOk = () => { - const { onChange } = this.props; - onChange({ - type: 'JSFunction', - value: this.functionCode, - }); - - this.closeDialog(); - }; - - focusFunctionName = (functionName) => { - const { editor } = this.props.field; - - editor.get('skeleton').getPanel('sourceEditor').show(); - - setTimeout(() => { - editor.emit('sourceEditor.focusByFunction', { - functionName, - }); - }, 300); - }; - - /** - * 渲染绑定函数 - */ - renderBindFunction = () => { - const { value } = this.props; - - // 解析函数名 - const functionName = this.parseFunctionName(value.value); - return ( -
- - this.focusFunctionName(functionName)}>{functionName} - this.bindFunction(true)} /> - -
- ); - }; - - - /** - * 渲染编辑函数按钮(可直接编辑函数内容) - */ - renderEditFunctionButton = () => { - return ( -
- -
- ); - }; - - - bindEventCallback = (eventName: string, paramStr:string) => { - const { onChange } = this.props; - - onChange({ - type: 'JSFunction', - value: `function(){ return this.${eventName}.apply(this,Array.prototype.slice.call(arguments).concat([${paramStr || ''}])) }`, - }); - }; - - - render() { - const { value } = this.props; - const { isShowDialog } = this.state; - - let functionName = ''; - if (value && value.value) { - functionName = this.parseFunctionName(value.value); - } - - let renderFunction; - if (value) { - if (functionName) { - renderFunction = this.renderBindFunction; - } else { - renderFunction = this.renderEditFunctionButton; - } - } else { - renderFunction = this.renderButton; - } - - return ( -
- { - renderFunction() - } - - { - value && value.value && - { this.closeDialog(); }}> -
- this.updateCode(newCode)} - /> -
-
- } -
- ); - } -} diff --git a/packages/editor-setters/src/icon-setter/index.scss b/packages/editor-setters/src/icon-setter/index.scss deleted file mode 100644 index 3638caf78..000000000 --- a/packages/editor-setters/src/icon-setter/index.scss +++ /dev/null @@ -1,36 +0,0 @@ -.lc-icon-setter{ - .next-input{ - width: auto !important; - } - i { - min-width: 12px; - } - i:hover { - cursor: pointer; - } - input:hover { - cursor: pointer; - } -} - - -.lowcode-icon-setter-popup{ - max-width: 354px; - .lowcode-icon-list{ - - overflow: auto; - li{ - float: left; - margin-bottom: 10px; - width: 40px; - color: #666; - cursor: pointer; - text-align: center; - - &:hover{ - color: #000; - } - } - } -} - diff --git a/packages/editor-setters/src/icon-setter/index.tsx b/packages/editor-setters/src/icon-setter/index.tsx deleted file mode 100644 index f61c32271..000000000 --- a/packages/editor-setters/src/icon-setter/index.tsx +++ /dev/null @@ -1,171 +0,0 @@ -import React, { PureComponent } from 'react'; -// import PropTypes from 'prop-types'; -import { Input, Icon, Balloon } from '@alifd/next'; - -import './index.scss'; - -const icons = [ - 'smile', - 'cry', - 'success', - 'warning', - 'prompt', - 'error', - 'help', - 'clock', - 'success-filling', - 'delete-filling', - 'favorites-filling', - 'add', - 'minus', - 'arrow-up', - 'arrow-down', - 'arrow-left', - 'arrow-right', - 'arrow-double-left', - 'arrow-double-right', - 'switch', - 'sorting', - 'descending', - 'ascending', - 'select', - 'semi-select', - 'loading', - 'search', - 'close', - 'ellipsis', - 'picture', - 'calendar', - 'ashbin', - 'upload', - 'download', - 'set', - 'edit', - 'refresh', - 'filter', - 'attachment', - 'account', - 'email', - 'atm', - 'copy', - 'exit', - 'eye', - 'eye-close', - 'toggle-left', - 'toggle-right', - 'lock', - 'unlock', - 'chart-pie', - 'chart-bar', - 'form', - 'detail', - 'list', - 'dashboard', -]; -interface IconSetterProps { - value: string; - type: string; - defaultValue: string; - placeholder: string; - hasClear: boolean; - onChange: (icon: string) => undefined; - icons: string[]; -} -export default class IconSetter extends PureComponent { - static defaultProps = { - value: undefined, - type: 'string', - defaultValue: '', - hasClear: true, - icons, - placeholder: '请点击选择 Icon', - onChange: () => undefined, - }; - - state = { - firstLoad: true, - }; - - _onChange = (icon: string) => { - const { onChange, type } = this.props; - if (type === 'string') { - onChange(icon); - } else if (type === 'node') { - onChange({ - componentName: 'Icon', - props: { - type: icon, - }, - }); - } - }; - - onInputChange = (icon: string) => { - this._onChange(icon); - }; - - onSelectIcon = (icon: string) => { - this._onChange(icon); - }; - - render() { - const { value, defaultValue, onChange, placeholder, hasClear } = this.props; - const { firstLoad } = this.state; - const _value = typeof value === 'object' ? value?.props?.type : value; - if (firstLoad && defaultValue && typeof value === 'undefined') { - onChange(defaultValue); - this.setState({ - firstLoad: false, - }); - } - const currentIcon = ; - const clearIcon = hasClear && ( - { - e.preventDefault(); - e.stopPropagation(); - this.onSelectIcon(''); - }} - /> - ); - - const triggerNode = ( -
- -
- ); - const InnerBeforeNode = ( - -
    - {icons.map((icon) => ( -
  • this.onSelectIcon(icon)}> - -
  • - ))} -
-
- ); - - return
{InnerBeforeNode}
; - } -} diff --git a/packages/editor-setters/src/index.tsx b/packages/editor-setters/src/index.tsx deleted file mode 100644 index 79a6a8217..000000000 --- a/packages/editor-setters/src/index.tsx +++ /dev/null @@ -1,139 +0,0 @@ -import React, { Component } from 'react'; -import { registerSetter } from '@ali/lowcode-editor-core'; -import { isJSExpression, isJSFunction } from '@ali/lowcode-types'; -import { DatePicker, TimePicker, Input, Radio, Select, Switch, NumberPicker } from '@alifd/next'; -import ExpressionSetter from './expression-setter'; -import ColorSetter from './color-setter'; -import JsonSetter from './json-setter'; -import EventsSetter from './events-setter'; -import StyleSetter from './style-setter'; -import IconSetter from './icon-setter'; -import FunctionSetter from './function-setter'; -import ClassNameSetter from './classname-setter'; -// import MixedSetter from './mixed-setter'; - -export const StringSetter = { - component: Input, - defaultProps: { placeholder: '请输入', style: { maxWidth: 180 } }, - title: 'StringSetter', - recommend: true, - condition: (field: any) => { - const v = field.getValue(); - return typeof v === 'string'; - }, -}; -export const NumberSetter = NumberPicker; -export class BoolSetter extends Component { - render() { - const { onChange, value, defaultValue } = this.props; - const props: Record = { - defaultChecked: defaultValue, - onChange, - }; - // Switch是通过 'checke' in props 来判断是否使用 defaultChecked - if (typeof value !== 'undefined') { - props.checked = value; - } - return ; - } -} -export const SelectSetter = Select; - -// suggest: 做成 SelectSetter 一种变体 -export const RadioGroupSetter = { - component: Radio.Group, - defaultProps: { - shape: 'button', - }, -}; -// suggest: 做成 StringSetter 的一个参数, -export const TextAreaSetter = { - component: Input.TextArea, - defaultProps: { placeholder: '请输入', style: { maxWidth: 180 } }, - title: 'TextAreaSetter', - recommend: true, - condition: (field: any) => { - const v = field.getValue(); - return typeof v === 'string'; - }, -}; -export const DateSetter = DatePicker; -export const DateYearSetter = DatePicker.YearPicker; -export const DateMonthSetter = DatePicker.MonthPicker; -export const DateRangeSetter = DatePicker.RangePicker; - -export { ExpressionSetter, EventsSetter, JsonSetter, IconSetter }; - -// eslint-disable-next-line react/no-multi-comp -class StringDateSetter extends Component { - render() { - const { onChange } = this.props; - return ( - { - onChange(val.format()); - }} - /> - ); - } -} - -// eslint-disable-next-line react/no-multi-comp -class StringTimePicker extends Component { - render() { - const { onChange } = this.props; - return ( - { - onChange(val.format('HH:mm:ss')); - }} - /> - ); - } -} - -const VariableSetter = { - component: ExpressionSetter, - condition: (field: any) => { - const v = field.getValue(); - return isJSExpression(v); - }, - defaultProps: { placeholder: '请输入表达式' }, - title: '表达式输入', - recommend: true, -}; - - -const FunctionBindSetter = { - component: FunctionSetter, - title: '函数绑定', - condition: (field: any) => { - const v = field.getValue(); - return v == isJSFunction(v); - }, -}; - -const builtinSetters: any = { - StringSetter, - NumberSetter, - BoolSetter, - SelectSetter, - VariableSetter, - ExpressionSetter: VariableSetter, - RadioGroupSetter, - TextAreaSetter, - DateSetter: StringDateSetter, - TimePicker: StringTimePicker, - DateYearSetter, - DateMonthSetter, - DateRangeSetter, - EventsSetter, - ColorSetter, - JsonSetter, - StyleSetter, - IconSetter, - ClassNameSetter, - FunctionSetter: FunctionBindSetter, -}; - -registerSetter(builtinSetters); diff --git a/packages/editor-setters/src/json-setter/index.tsx b/packages/editor-setters/src/json-setter/index.tsx deleted file mode 100644 index dd0dd3240..000000000 --- a/packages/editor-setters/src/json-setter/index.tsx +++ /dev/null @@ -1,121 +0,0 @@ - -import React, { PureComponent } from 'react'; -// import PropTypes from 'prop-types'; -import { Button, Icon, Dialog } from '@alifd/next'; -import MonacoEditor from 'react-monaco-editor'; -import { js_beautify } from 'js-beautify'; - -const defaultEditorOption = { - width: '100%', - height: '100%', - options: { - readOnly: false, - automaticLayout: true, - folding: true, // 默认开启折叠代码功能 - lineNumbers: 'on', - wordWrap: 'off', - formatOnPaste: true, - fontSize: 12, - tabSize: 2, - scrollBeyondLastLine: false, - fixedOverflowWidgets: false, - snippetSuggestions: 'top', - minimap: { - enabled: false, - }, - scrollbar: { - vertical: 'auto', - horizontal: 'auto', - }, - }, -}; - - -interface JsonSetterProps { - value: string; - type: string; - defaultValue: string; - placeholder: string; - hasClear: boolean; - onChange: (icon: string) => undefined; - icons: string[]; -} -export default class JsonSetter extends PureComponent { - - private datasourceCode = ''; - - state = { - isShowDialog: false, - value: JSON.stringify(this.props.value), - }; - - openDialog = () => { - const { value } = this.state; - this.setState({ - isShowDialog: true, - }); - - this.datasourceCode = value; - }; - - closeDialog = () => { - this.setState({ - isShowDialog: false, - }); - }; - - /** - * 渲染按钮 - */ - renderButton = (value) => { - return !value ? : ; - }; - - updateCode = (newCode) => { - this.datasourceCode = newCode; - }; - - onDialogOk = () => { - const { onChange } = this.props; - onChange(JSON.parse(this.datasourceCode)); - this.closeDialog(); - }; - - - /** - * 渲染编辑函数按钮(可直接编辑函数内容) - */ - renderEditFunctionButton = () => { - return ( -
- -
- ); - }; - - - render() { - const { value } = this.state; - const { isShowDialog } = this.state; - return ( -
- { - this.renderButton(value) - } - { - - { this.closeDialog(); }}> -
- this.updateCode(newCode)} - /> -
-
- } -
- ); - } -} diff --git a/packages/editor-setters/src/json-setter/locale/snippets.ts b/packages/editor-setters/src/json-setter/locale/snippets.ts deleted file mode 100644 index 2bcb0dd00..000000000 --- a/packages/editor-setters/src/json-setter/locale/snippets.ts +++ /dev/null @@ -1,242 +0,0 @@ -export default [ - { - label: 'constants', - kind: 'Class', - insertText: 'constants', - detail: '应用全局常量', - documentation: '应用范围定义的通用常量', - }, - { - label: 'utils', - kind: 'Class', - insertText: 'utils', - detail: '应用全局公共函数', - documentation: '应用范围扩展的公共函数', - }, - { - label: 'state', - kind: 'Enum', - insertText: 'state', - detail: '当前所在容器组件内部状态', - documentation: 'React Class内部状态state', - }, - { - label: 'setState', - kind: 'Function', - insertText: 'setState({\n\t$0\n})', - insertTextRules: 'InsertAsSnippet', - detail: '设置当前所在容器组件的state数据', - documentation: '原生React方法,会自动更新组件视图', - }, - { - label: 'reloadDataSource', - kind: 'Function', - insertText: 'reloadDataSource(${1:${2:namespace}, ${3:false}, ${4:callback}})', - insertTextRules: 'InsertAsSnippet', - detail: '刷新当前所在的容器组件', - documentation: '触发当前所在的容器组件,重新发送异步请求,并用最新数据更新视图', - }, - { - label: 'location', - kind: 'Class', - insertText: 'location', - detail: '路由解析对象', - }, - { - label: 'location.query', - kind: 'Value', - insertText: 'location.query.${1:xxxx}', - insertTextRules: 'InsertAsSnippet', - detail: '从路由解析对象中获取参数信息', - }, - { - label: 'history', - kind: 'Class', - insertText: 'history', - detail: '路由历史对象', - }, - { - label: 'React', - kind: 'Keyword', - insertText: 'React', - detail: 'React对象', - }, - { - label: 'ReactDOM', - kind: 'Keyword', - insertText: 'ReactDOM', - detail: 'ReactDom对象', - }, - { - label: 'ReactDOM.findDOMNode', - kind: 'Function', - insertText: 'ReactDOM.findDOMNode(${1:this.refs.xxxx})', - insertTextRules: 'InsertAsSnippet', - detail: 'ReactDom查找真实dom node', - }, - { - label: 'Dialog.alert', - kind: 'Method', - insertText: [ - 'Dialog.alert({', - "\tcontent: '${1:Alert content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: 'alert弹框 By Fusion', - }, - { - label: 'Dialog.confirm', - kind: 'Method', - insertText: [ - 'Dialog.confirm({', - "\tcontent: '${1:Confirm content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '确认弹出框 By Fusion', - }, - { - label: 'Message.success', - kind: 'Method', - insertText: 'Message.success(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: '成功反馈提示 By Fusion', - }, - { - label: 'Message.error', - kind: 'Method', - insertText: 'Message.error(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: '错误反馈提示 By Fusion', - }, - { - label: 'Message.help', - kind: 'Method', - insertText: 'Message.help(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: '帮助反馈提示 By Fusion', - }, - { - label: 'Message.loading', - kind: 'Method', - insertText: 'Message.loading(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: 'loading反馈提示 By Fusion', - }, - { - label: 'Message.notice', - kind: 'Method', - insertText: 'Message.notice(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: '注意反馈提示 By Fusion', - }, - { - label: 'Message.waining', - kind: 'Method', - insertText: 'Message.waining(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: '警告反馈提示 By Fusion', - }, - { - label: 'Modal.confirm', - kind: 'Method', - insertText: [ - 'Modal.confirm({', - "\tcontent: '${1:Confirm content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '确认弹出框 By Antd', - }, - { - label: 'Modal.info', - kind: 'Method', - insertText: [ - 'Modal.info({', - "\tcontent: '${1:Info content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '信息弹出框 By Antd', - }, - { - label: 'Modal.success', - kind: 'Method', - insertText: [ - 'Modal.success({', - "\tcontent: '${1:Success content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '成功弹出框 By Antd', - }, - { - label: 'Modal.error', - kind: 'Method', - insertText: [ - 'Modal.error({', - "\tcontent: '${1:Error content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '错误弹出框 By Antd', - }, - { - label: 'Modal.warning', - kind: 'Method', - insertText: [ - 'Modal.warning({', - "\tcontent: '${1:Warning content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '警告弹出框 By Antd', - }, -]; diff --git a/packages/editor-setters/src/json-setter/locale/utils.ts b/packages/editor-setters/src/json-setter/locale/utils.ts deleted file mode 100644 index d401ad511..000000000 --- a/packages/editor-setters/src/json-setter/locale/utils.ts +++ /dev/null @@ -1,21 +0,0 @@ -import IntlMessageFormat from 'intl-messageformat'; - -export const isJSExpression = (obj = '') => { - if (obj && typeof obj === 'object' && obj.type === 'JSExpression') { - return true; - } - return false; -}; - -/** - * 用于构造国际化字符串处理函数 - * @param {*} locale 国际化标识,例如 zh-CN、en-US - * @param {*} messages 国际化语言包 - */ -export const generateI18n = (locale = 'zh-CN', messages = {}) => { - return function (key, values = {}) { - if (!messages || !messages[key]) return ''; - const formater = new IntlMessageFormat(messages[key], locale); - return formater.format(values); - }; -}; diff --git a/packages/editor-setters/src/json-setter/locale/zh-CN.ts b/packages/editor-setters/src/json-setter/locale/zh-CN.ts deleted file mode 100644 index f4f2e0630..000000000 --- a/packages/editor-setters/src/json-setter/locale/zh-CN.ts +++ /dev/null @@ -1,36 +0,0 @@ -export default { - // function - setting: '点击设置', - edit: '编辑', - submitConfirm: '确认提交 cmd+s', - close: '关闭 esc', - fullScreen: '全屏', - cancelFullScreen: '取消全屏', - jsonIllegal: '非json格式', - functionIllegal: '非function格式', - objectIllegal: '非object格式', - circularRef: '对象中出现循环引用的对象', - formatError: '格式错误', - saved: '已保存', - // expression - valueIllegal: '值类型为对象类型,与当前组件属性设置的控件类型不匹配,请在属性“代码编辑模式”下进行编辑', - jsExpression: '请输入JS表达式', - // Mixin - input: '字符串Input', - textarea: '多行字符串Textarea', - expression: '变量控件Expression', - monacoEditor: '编辑器MonacoEditor', - numberPicker: '数字NumberPicker', - bool: '布尔Switch', - datePicker: '日期选择DatePicker', - select: '下拉选择Select', - radio: '单项选择RadioGroup', - date: '日期选择DatePicker', - dateYear: '年选择DatePicker', - dateMonth: '月选择DatePicker', - dateRange: '日期区间选择DatePicker', - list: '数组List', - object: '对象ObjectButton', - reactNode: '节点类型ReactNode', - typeError: 'Minix组件属性Types配置错误,存在不支持类型[{type}],请检查组件属性配置', -}; diff --git a/packages/editor-setters/src/locale/snippets.ts b/packages/editor-setters/src/locale/snippets.ts deleted file mode 100644 index 2bcb0dd00..000000000 --- a/packages/editor-setters/src/locale/snippets.ts +++ /dev/null @@ -1,242 +0,0 @@ -export default [ - { - label: 'constants', - kind: 'Class', - insertText: 'constants', - detail: '应用全局常量', - documentation: '应用范围定义的通用常量', - }, - { - label: 'utils', - kind: 'Class', - insertText: 'utils', - detail: '应用全局公共函数', - documentation: '应用范围扩展的公共函数', - }, - { - label: 'state', - kind: 'Enum', - insertText: 'state', - detail: '当前所在容器组件内部状态', - documentation: 'React Class内部状态state', - }, - { - label: 'setState', - kind: 'Function', - insertText: 'setState({\n\t$0\n})', - insertTextRules: 'InsertAsSnippet', - detail: '设置当前所在容器组件的state数据', - documentation: '原生React方法,会自动更新组件视图', - }, - { - label: 'reloadDataSource', - kind: 'Function', - insertText: 'reloadDataSource(${1:${2:namespace}, ${3:false}, ${4:callback}})', - insertTextRules: 'InsertAsSnippet', - detail: '刷新当前所在的容器组件', - documentation: '触发当前所在的容器组件,重新发送异步请求,并用最新数据更新视图', - }, - { - label: 'location', - kind: 'Class', - insertText: 'location', - detail: '路由解析对象', - }, - { - label: 'location.query', - kind: 'Value', - insertText: 'location.query.${1:xxxx}', - insertTextRules: 'InsertAsSnippet', - detail: '从路由解析对象中获取参数信息', - }, - { - label: 'history', - kind: 'Class', - insertText: 'history', - detail: '路由历史对象', - }, - { - label: 'React', - kind: 'Keyword', - insertText: 'React', - detail: 'React对象', - }, - { - label: 'ReactDOM', - kind: 'Keyword', - insertText: 'ReactDOM', - detail: 'ReactDom对象', - }, - { - label: 'ReactDOM.findDOMNode', - kind: 'Function', - insertText: 'ReactDOM.findDOMNode(${1:this.refs.xxxx})', - insertTextRules: 'InsertAsSnippet', - detail: 'ReactDom查找真实dom node', - }, - { - label: 'Dialog.alert', - kind: 'Method', - insertText: [ - 'Dialog.alert({', - "\tcontent: '${1:Alert content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: 'alert弹框 By Fusion', - }, - { - label: 'Dialog.confirm', - kind: 'Method', - insertText: [ - 'Dialog.confirm({', - "\tcontent: '${1:Confirm content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '确认弹出框 By Fusion', - }, - { - label: 'Message.success', - kind: 'Method', - insertText: 'Message.success(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: '成功反馈提示 By Fusion', - }, - { - label: 'Message.error', - kind: 'Method', - insertText: 'Message.error(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: '错误反馈提示 By Fusion', - }, - { - label: 'Message.help', - kind: 'Method', - insertText: 'Message.help(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: '帮助反馈提示 By Fusion', - }, - { - label: 'Message.loading', - kind: 'Method', - insertText: 'Message.loading(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: 'loading反馈提示 By Fusion', - }, - { - label: 'Message.notice', - kind: 'Method', - insertText: 'Message.notice(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: '注意反馈提示 By Fusion', - }, - { - label: 'Message.waining', - kind: 'Method', - insertText: 'Message.waining(${1:content})', - insertTextRules: 'InsertAsSnippet', - detail: '警告反馈提示 By Fusion', - }, - { - label: 'Modal.confirm', - kind: 'Method', - insertText: [ - 'Modal.confirm({', - "\tcontent: '${1:Confirm content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '确认弹出框 By Antd', - }, - { - label: 'Modal.info', - kind: 'Method', - insertText: [ - 'Modal.info({', - "\tcontent: '${1:Info content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '信息弹出框 By Antd', - }, - { - label: 'Modal.success', - kind: 'Method', - insertText: [ - 'Modal.success({', - "\tcontent: '${1:Success content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '成功弹出框 By Antd', - }, - { - label: 'Modal.error', - kind: 'Method', - insertText: [ - 'Modal.error({', - "\tcontent: '${1:Error content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '错误弹出框 By Antd', - }, - { - label: 'Modal.warning', - kind: 'Method', - insertText: [ - 'Modal.warning({', - "\tcontent: '${1:Warning content}',", - "\ttitle: '${2:Title}',", - '\tonOk: () => {', - '\t\t$3', - '\t},', - '\tonCancel: () => {', - '\t\t$4', - '\t}', - '})', - ].join('\n'), - insertTextRules: 'InsertAsSnippet', - detail: '警告弹出框 By Antd', - }, -]; diff --git a/packages/editor-setters/src/locale/utils.ts b/packages/editor-setters/src/locale/utils.ts deleted file mode 100644 index d401ad511..000000000 --- a/packages/editor-setters/src/locale/utils.ts +++ /dev/null @@ -1,21 +0,0 @@ -import IntlMessageFormat from 'intl-messageformat'; - -export const isJSExpression = (obj = '') => { - if (obj && typeof obj === 'object' && obj.type === 'JSExpression') { - return true; - } - return false; -}; - -/** - * 用于构造国际化字符串处理函数 - * @param {*} locale 国际化标识,例如 zh-CN、en-US - * @param {*} messages 国际化语言包 - */ -export const generateI18n = (locale = 'zh-CN', messages = {}) => { - return function (key, values = {}) { - if (!messages || !messages[key]) return ''; - const formater = new IntlMessageFormat(messages[key], locale); - return formater.format(values); - }; -}; diff --git a/packages/editor-setters/src/locale/zh-CN.ts b/packages/editor-setters/src/locale/zh-CN.ts deleted file mode 100644 index f4f2e0630..000000000 --- a/packages/editor-setters/src/locale/zh-CN.ts +++ /dev/null @@ -1,36 +0,0 @@ -export default { - // function - setting: '点击设置', - edit: '编辑', - submitConfirm: '确认提交 cmd+s', - close: '关闭 esc', - fullScreen: '全屏', - cancelFullScreen: '取消全屏', - jsonIllegal: '非json格式', - functionIllegal: '非function格式', - objectIllegal: '非object格式', - circularRef: '对象中出现循环引用的对象', - formatError: '格式错误', - saved: '已保存', - // expression - valueIllegal: '值类型为对象类型,与当前组件属性设置的控件类型不匹配,请在属性“代码编辑模式”下进行编辑', - jsExpression: '请输入JS表达式', - // Mixin - input: '字符串Input', - textarea: '多行字符串Textarea', - expression: '变量控件Expression', - monacoEditor: '编辑器MonacoEditor', - numberPicker: '数字NumberPicker', - bool: '布尔Switch', - datePicker: '日期选择DatePicker', - select: '下拉选择Select', - radio: '单项选择RadioGroup', - date: '日期选择DatePicker', - dateYear: '年选择DatePicker', - dateMonth: '月选择DatePicker', - dateRange: '日期区间选择DatePicker', - list: '数组List', - object: '对象ObjectButton', - reactNode: '节点类型ReactNode', - typeError: 'Minix组件属性Types配置错误,存在不支持类型[{type}],请检查组件属性配置', -}; diff --git a/packages/editor-setters/src/mixed-setter/index.scss b/packages/editor-setters/src/mixed-setter/index.scss deleted file mode 100644 index 9a9e3f086..000000000 --- a/packages/editor-setters/src/mixed-setter/index.scss +++ /dev/null @@ -1,13 +0,0 @@ -// mixed -.lowcode-setter-mixed > * { - vertical-align: middle; -} -.lowcode-setter-mixed { - width: 86%; -} -.lowcode-setter-mixed .next-input { - width: 100%; -} -.lowcode-setter-mixed .next-select-trigger { - width: 100%; -} \ No newline at end of file diff --git a/packages/editor-setters/src/mixed-setter/index.tsx b/packages/editor-setters/src/mixed-setter/index.tsx deleted file mode 100644 index f99c1bec3..000000000 --- a/packages/editor-setters/src/mixed-setter/index.tsx +++ /dev/null @@ -1,161 +0,0 @@ -import React, { PureComponent } from 'react'; -import PropTypes from 'prop-types'; -import classNames from 'classnames'; -import { Dropdown, Button, Menu, Icon } from '@alifd/next'; -import { getSetter } from '@ali/lowcode-editor-core'; - -import { generateI18n } from './locale/utils'; -import zhCN from './locale/zh-CN'; -import './index.scss'; - -export default class Mixed extends PureComponent { - static displayName = 'Mixed'; - - static propTypes = { - locale: PropTypes.string, - messages: PropTypes.object, - defaultType: PropTypes.string, - types: PropTypes.arrayOf(PropTypes.string), - inputProps: PropTypes.object, - expressionProps: PropTypes.object, - monacoEditorProps: PropTypes.object, - switchProps: PropTypes.object, - selectProps: PropTypes.object, - radioGroupProps: PropTypes.object, - }; - - static defaultProps = { - locale: 'zh-CN', - messages: zhCN, - types: [ - { - name: 'StringSetter', - props: {}, - }, - ], - }; - - typeMap: any; - - i18n: (key: any, values) => string | void | Array; - - constructor(props: Readonly) { - super(props); - const type = props.defaultType; // judgeTypeHandler(props, {}); - this.i18n = generateI18n(props.locale, props.messages); - this.state = { - type, - }; - } - - changeType(type: string) { - if (typeof type === 'object' || type === this.state.type) return; - const { onChange } = this.props; - let newValue; - const setterProps = this.typeMap[type].props; - if (setterProps) { - if (setterProps.value !== undefined) { - newValue = setterProps.value; - } else if (setterProps.defaultValue !== undefined) { - newValue = setterProps.defaultValue; - } - } - if (type === 'BoolSetter' && newValue === undefined) { - newValue = false; // 给切换到switch默认值为false - } - this.setState({ type }); - onChange && onChange(newValue); - } - - render() { - const { style = {}, className, locale, messages, types = [], defaultType, ...restProps } = this.props; - this.typeMap = {}; - const realTypes: any[] = []; - types.forEach((el: { name: any; props: any }) => { - const { name, props } = el; - const Setter = getSetter(name); - if (Setter) { - this.typeMap[name] = { - label: name, - component: Setter.component, - props, - }; - } - realTypes.push(name); - }); - let moreBtnNode = null; - // 如果只有2种,且有变量表达式,则直接展示变量按钮 - if (realTypes.length > 1) { - const isTwoType = !!(realTypes.length === 2 && ~realTypes.indexOf('ExpressionSetter')); - const btnProps = { - size: 'small', - text: true, - style: { - position: 'absolute', - left: '100%', - top: 0, - bottom: 0, - margin: 'auto 0 auto 8px', - padding: 0, - width: 16, - height: 16, - lineHeight: '16px', - textAlign: 'center', - }, - }; - if (isTwoType) { - btnProps.onClick = this.changeType.bind(this, realTypes.indexOf(this.state.type) ? realTypes[0] : realTypes[1]); - } - const triggerNode = ( - - ); - if (isTwoType) { - moreBtnNode = triggerNode; - } else { - // eslint-disable-next-line @typescript-eslint/ban-types - const MenuItems: {} | null | undefined = []; - realTypes.map((type) => { - if (this.typeMap[type]) { - MenuItems.push({this.typeMap[type].label}); - } else { - console.error( - this.i18n('typeError', { - type, - }), - ); - } - return type; - }); - const MenuNode = ( - - {MenuItems} - - ); - - moreBtnNode = ( - - {MenuNode} - - ); - } - } - const TargetNode = this.typeMap[this.state.type]?.component || 'div'; - const targetProps = this.typeMap[this.state.type]?.props || {}; - const tarStyle = { position: 'relative', ...style }; - const classes = classNames(className, 'lowcode-setter-mixin'); - - return ( -
- - {moreBtnNode} -
- ); - } -} diff --git a/packages/editor-setters/src/mixed-setter/locale/utils.ts b/packages/editor-setters/src/mixed-setter/locale/utils.ts deleted file mode 100644 index d401ad511..000000000 --- a/packages/editor-setters/src/mixed-setter/locale/utils.ts +++ /dev/null @@ -1,21 +0,0 @@ -import IntlMessageFormat from 'intl-messageformat'; - -export const isJSExpression = (obj = '') => { - if (obj && typeof obj === 'object' && obj.type === 'JSExpression') { - return true; - } - return false; -}; - -/** - * 用于构造国际化字符串处理函数 - * @param {*} locale 国际化标识,例如 zh-CN、en-US - * @param {*} messages 国际化语言包 - */ -export const generateI18n = (locale = 'zh-CN', messages = {}) => { - return function (key, values = {}) { - if (!messages || !messages[key]) return ''; - const formater = new IntlMessageFormat(messages[key], locale); - return formater.format(values); - }; -}; diff --git a/packages/editor-setters/src/mixed-setter/locale/zh-CN.ts b/packages/editor-setters/src/mixed-setter/locale/zh-CN.ts deleted file mode 100644 index f4f2e0630..000000000 --- a/packages/editor-setters/src/mixed-setter/locale/zh-CN.ts +++ /dev/null @@ -1,36 +0,0 @@ -export default { - // function - setting: '点击设置', - edit: '编辑', - submitConfirm: '确认提交 cmd+s', - close: '关闭 esc', - fullScreen: '全屏', - cancelFullScreen: '取消全屏', - jsonIllegal: '非json格式', - functionIllegal: '非function格式', - objectIllegal: '非object格式', - circularRef: '对象中出现循环引用的对象', - formatError: '格式错误', - saved: '已保存', - // expression - valueIllegal: '值类型为对象类型,与当前组件属性设置的控件类型不匹配,请在属性“代码编辑模式”下进行编辑', - jsExpression: '请输入JS表达式', - // Mixin - input: '字符串Input', - textarea: '多行字符串Textarea', - expression: '变量控件Expression', - monacoEditor: '编辑器MonacoEditor', - numberPicker: '数字NumberPicker', - bool: '布尔Switch', - datePicker: '日期选择DatePicker', - select: '下拉选择Select', - radio: '单项选择RadioGroup', - date: '日期选择DatePicker', - dateYear: '年选择DatePicker', - dateMonth: '月选择DatePicker', - dateRange: '日期区间选择DatePicker', - list: '数组List', - object: '对象ObjectButton', - reactNode: '节点类型ReactNode', - typeError: 'Minix组件属性Types配置错误,存在不支持类型[{type}],请检查组件属性配置', -}; diff --git a/packages/editor-setters/src/style-setter/index.tsx b/packages/editor-setters/src/style-setter/index.tsx deleted file mode 100644 index 004fe2bf1..000000000 --- a/packages/editor-setters/src/style-setter/index.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import './style.less'; -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import LowStyleSetter from '@ali/lc-style-setter'; -import { globalLocale } from '@ali/lowcode-editor-core'; - -export default class StyleSetter extends Component { - static displayName = 'StyleSetter'; - - static propTypes = { - value: PropTypes.object, - onChange: PropTypes.func, - placeholder: PropTypes.string, - locale: PropTypes.string, - }; - - static defaultProps = { - value: {}, - onChange: () => { }, - placeholder: '', - locale: globalLocale.getLocale() || 'en-US', - }; - - onChange = (val: any) => { - const { onChange } = this.props; - onChange(val.native); - }; - - render() { - const { value } = this.props; - return ( -
- -
- ); - } -} diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/background/attachment.js b/packages/editor-setters/src/style-setter/lc-style-setter/background/attachment.js deleted file mode 100644 index 73b10d9d0..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/background/attachment.js +++ /dev/null @@ -1,42 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import ChoiceControl from '@ali/ve-choice-control'; -import Icons from '@ali/ve-icons'; -import utils from '../utils'; - -const attchments = [{ - title: , - value: 'fixed', -}, { - title: , - value: 'scroll', -}]; - -class Attachment extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleBackgrounAttachmentSetter'; - - setAttachment(attachment) { - utils.setBackground(this.props, 'background-attachment', attachment); - } - - render() { - const className = classNames('vs-style-background-attachment', this.props.className); - const attachment = utils.getBackground(this.props, 'background-attachment').value; - - return ( - this.setAttachment(value)} - /> - ); - } -} - -export default Attachment; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/background/color.js b/packages/editor-setters/src/style-setter/lc-style-setter/background/color.js deleted file mode 100644 index 2100d7f50..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/background/color.js +++ /dev/null @@ -1,42 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import ColorControl from '@ali/ve-color-control'; -import utils from '../utils'; -class Color extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleBackgrounColorSetter'; - - static transducer = utils.transducer; - - componentWillMount() { - - } - - componentWillUnmount() { - - } - - setColor(color) { - utils.setBackground(this.props, 'background-color', color); - } - - render() { - const className = classNames('vs-style-background-color', this.props.className); - const { current, inherit } = utils.getBackground(this.props, 'background-color'); - - return ( - this.setColor(value)} - /> - ); - } -} - -export default Color; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/background/image.js b/packages/editor-setters/src/style-setter/lc-style-setter/background/image.js deleted file mode 100644 index 88c02a086..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/background/image.js +++ /dev/null @@ -1,56 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import ImageControl from '@ali/ve-image-control'; -import utils from '../utils'; -import $i18n from '../i18n/index'; - -class Image extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleBackgroundImageSetter'; - - static transducer = utils.transducer; - - componentWillMount() { - - } - - componentWillUnmount() { - - } - - setImage(image) { - if (image) { - image = image.trim(); - } - if (image && image !== 'none') { - image = `url("${image}")`; - } - utils.setBackground(this.props, 'background-image', image); - } - - render() { - const className = classNames('vs-style-background-image', this.props.className); - const { current, inherit } = utils.getBackground(this.props, 'background-image'); - const url = utils.getImageUrl(current); - - return ( - this.setImage(value)} - /> - ); - } -} - -export default Image; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/background/index.js b/packages/editor-setters/src/style-setter/lc-style-setter/background/index.js deleted file mode 100644 index ccde0fd8f..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/background/index.js +++ /dev/null @@ -1,117 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import Field from '@ali/ve-field'; -import Icons from '@ali/ve-icons'; -import Color from './color'; -import Image from './image'; -import Position from './position'; -import Size from './size'; -import Repeat from './repeat'; -import Attachment from './attachment'; -import utils from '../utils'; -import $i18n from '../i18n/index'; - -class Background extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleTypographySetter'; - - static transducer = utils.transducer; - - componentWillMount() { - - } - - // shouldComponentUpdate() { - // return false; - // } - - componentWillUnmount() { - - } - - render() { - const className = classNames('vs-style-background', this.props.className); - const image = utils.getBackground(this.props, 'background-image').value; - const imageUrl = utils.getImageUrl(image); - - return ( -
- - - -)} - > - - - - - -)} - > - - - {imageUrl && imageUrl !== 'none' ? ( -
- - - - - - - - - - -)} - > - - - - - -)} - > - - - -
- ) : null} -
- ); - } -} - -Background.Color = Color; - -Background.Image = Image; - -export default Background; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/background/parser.js b/packages/editor-setters/src/style-setter/lc-style-setter/background/parser.js deleted file mode 100644 index cefa4c657..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/background/parser.js +++ /dev/null @@ -1,245 +0,0 @@ -import valueParser, { stringify } from 'postcss-value-parser'; -import namedColors from 'css-color-names'; - -const RE_BOX = /^(border-box|padding-box|content-box|text)$/i; -const RE_LENGTH_PERCENTAGE = /^\d*(\.\d+)?(em|ex|ch|rem|vh|vw|vmin|vmax|px|mm|q|cm|in|pt|pc|%)?$/i; -const RE_POS_PRESET = /^(left|center|right|top|bottom)$/i; -const RE_SIZE_PRESET = /^(cover|contain)$/i; -const RE_IMAGE_FUNC = /^(url|image(-set)?|cross\-fade|element|((repeating-)?(linear|radial)\-)gradient)$/i; // eslint-disable-line -const RE_REPEAT = /^(repeat|repeat\-x|repeat\-y|no\-repeat|space|round)$/i; -const RE_COLOR_FUNC = /^(rgb|rgba|hsl|hsla)$/i; -const RE_COLOR_PRESET = /^(transparent|currentColor)$/i; -const RE_COLOR_HEX = /^#(?:[a-f0-9]{3})?(?:[a-f0-9]{3})$/; -const RE_ATTACHMENT = /^(scroll|fixed|local)$/i; - -function isColorValue(word) { - return namedColors.hasOwnProperty(word) || RE_COLOR_PRESET.test(word) || RE_COLOR_HEX.test(word); -} - -function isColorFunc(word) { - return RE_COLOR_FUNC.test(word); -} - -function isColorNode(node) { - if (node.type === 'word') { - return isColorValue(node.value); - } - if (node.type === 'function') { - return isColorFunc(node.value); - } - return false; -} - -function isImageFunc(word) { - return RE_IMAGE_FUNC.test(word); -} -function isImageNode(node) { - if (node.type === 'word') { - return node.value === 'none'; - } - if (node.type === 'function') { - return isImageFunc(node.value); - } - return false; -} - -function isRepeatNode(node) { - if (node.type === 'word') { - return RE_REPEAT.test(node.value); - } - return false; -} - -function isAttachmentNode(node) { - if (node.type === 'word') { - return RE_ATTACHMENT.test(node.value); - } - return false; -} - -function isBoxNode(node) { - if (node.type === 'word') { - return RE_BOX.test(node.value); - } - return false; -} - -function isPostionValue(word) { - return RE_LENGTH_PERCENTAGE.test(word) || RE_POS_PRESET.test(word); -} - -function isPositionNode(node) { - if (node.type === 'word') { - return isPostionValue(node.value); - } - return false; -} - -function isSizePreset(word) { - return RE_SIZE_PRESET.test(word); -} - -function isSizeValue(word) { - return RE_LENGTH_PERCENTAGE.test(word) || word === 'auto' || isSizePreset(word); -} - -function isSizeNode(node) { - if (node.type === 'word') { - return isSizeValue(node.value); - } - return false; -} - -function eatSpace(nodes, index) { - const node = nodes[index]; - if (!node || node.type !== 'space') { - return index; - } - return index + 1; -} - -function readValue(nodes, index, store) { - const node = nodes[index]; - // color - if (isColorNode(node)) { - store['background-color'] = stringify(node); - return index + 1; - } - // image - if (isImageNode(node)) { - store['background-image'] = stringify(node); - return index + 1; - } - // attchment - if (isAttachmentNode(node)) { - store['background-attachment'] = stringify(node); - return index + 1; - } - // repeat - if (isRepeatNode(node)) { - let repeat = stringify(node); - index = eatSpace(nodes, index + 1); - const sibling = nodes[index]; - if (sibling && isRepeatNode(sibling)) { - repeat = `${repeat} ${stringify(sibling)}`; - index += 1; - } - store['background-repeat'] = repeat; - return index; - } - // origin & clip - if (isBoxNode(node)) { - let origin = stringify(node); - let clip = null; - if (origin === 'text') { - clip = origin; - origin = null; - } - - index = eatSpace(nodes, index + 1); - const sibling = nodes[index]; - if (sibling && isBoxNode(sibling)) { - if (clip) { - origin = stringify(sibling); - } else { - clip = stringify(sibling); - } - index += 1; - } - - if (origin) { - store['background-origin'] = origin; - } - if (clip) { - store['background-clip'] = clip; - } - return index; - } - // position & size - if (isPositionNode(node)) { - let position = stringify(node); - let size = null; - index = eatSpace(nodes, index + 1); - let sibling = nodes[index]; - if (sibling && isPositionNode(sibling)) { - position = `${position} ${stringify(sibling)}`; - index = eatSpace(nodes, index + 1); - sibling = nodes[index]; - } - if (sibling && sibling.type === 'div' && sibling.value === '/') { - index = eatSpace(nodes, index + 1); - sibling = nodes[index]; - if (sibling && isSizeNode(sibling)) { - size = stringify(sibling); - if (!isSizePreset(size)) { - index = eatSpace(nodes, index + 1); - sibling = nodes[index]; - if (sibling && isSizeNode(sibling)) { - size = `${size} ${stringify(sibling)}`; - index += 1; - } - } - } - } - - store['background-position'] = position; - if (size) { - store['background-size'] = size; - } - - return index; - } - - return index + 1; -} - -function parser(bakcground) { - const nodes = valueParser(typeof bakcground === 'string' ? bakcground : '').nodes; - const l = nodes.length; - const items = []; - let item; - const append = () => { - item = {}; - items.push(item); - }; - append(); - - let node; - let type; - let value; - let i = 0; - while (i < l) { - node = nodes[i]; - type = node.type; - value = node.value; - if (type === 'word' || type === 'function') { - i = readValue(nodes, i, item); - continue; - } - i++; - // div = , - if (type === 'div' && value === ',') { - append(); - } - } - return items; -} - -function build(bg) { - if (Array.isArray(bg)) { - return bg.map(build).join(','); - } - - let pos = bg['background-position']; - if (pos && bg['background-size']) { - pos = `${pos}/${bg['background-size']}`; - } - - return ['image', 'repeat', 'attachment', 'position', 'origin', 'clip', 'color'].map(key => { - return (key === 'position' ? pos : bg[`background-${key}`]) || ''; - }).filter(item => item !== '').join(' '); -} - -parser.build = build; - -export default parser; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/background/position.js b/packages/editor-setters/src/style-setter/lc-style-setter/background/position.js deleted file mode 100644 index 9e1890672..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/background/position.js +++ /dev/null @@ -1,292 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import Field from '@ali/ve-field'; -import Icons from '@ali/ve-icons'; -import NumberControl from '@ali/ve-number-control'; - -import utils from '../utils'; -import $i18n from '../i18n/index'; - -function isZero(v) { - return v === 0 || /^0(em|ex|ch|rem|vh|vw|vmin|vmax|px|mm|q|cm|in|pt|pc|%)?$/.test(v); -} - -const offsetPresets = [ - { - title: 'left top', - value: { X: '0%', Y: '0%' }, - test({ x, y }) { - return (isZero(x) || x === 'left') && (isZero(y) || y === 'top'); - }, - }, - { - title: 'center top', - value: { X: '50%', Y: '0%' }, - test({ x, y }) { - return (x === '50%' || x === 'center') && (isZero(y) || y === 'top'); - }, - }, - { - title: 'right top', - value: { X: '100%', Y: '0%' }, - test({ x, y }) { - return (x === '100%' || x === 'right') && (isZero(y) || y === 'top'); - }, - }, - { - title: 'left center', - value: { X: '0%', Y: '50%' }, - test({ x, y }) { - return (isZero(x) || x === 'left') && (y === '50%' || y === 'center'); - }, - }, - { - title: 'center', - value: { X: '50%', Y: '50%' }, - test({ x, y }) { - return (x === '50%' || x === 'center') && (y === '50%' || y === 'center'); - }, - }, - { - title: 'right center', - value: { X: '100%', Y: '50%' }, - test({ x, y }) { - return (x === '100%' || x === 'right') && (y === '50%' || y === 'center'); - }, - }, - { - title: 'left bottom', - value: { X: '0%', Y: '100%' }, - test({ x, y }) { - return (isZero(x) || x === 'left') && (y === '100%' || y === 'bottom'); - }, - }, - { - title: 'center bottom', - value: { X: '50%', Y: '100%' }, - test({ x, y }) { - return (x === '50%' || x === 'center') && (y === '100%' || y === 'bottom'); - }, - }, - { - title: 'right bottom', - value: { X: '100%', Y: '100%' }, - test({ x, y }) { - return (x === '100%' || x === 'right') && (y === '100%' || y === 'bottom'); - }, - }, -]; - -class Presets extends Component { - static propTypes = { - value: PropTypes.object, - onChange: PropTypes.func, - }; - - render() { - const { value, onChange } = this.props; - - const presets = offsetPresets.map((item, index) => { - const className = classNames('vs-preset-item', `vs-preset-${item.title.replace(' ', '-')}`, { - 've-active': item.test(value), - }); - - return ( - onChange(item.value)} - > - - - ); - }); - - return
{presets}
; - } -} - -const RE_PERCENT = /^\d*(\.\d+)?%$/; - -function isPercent(val) { - return RE_PERCENT.test(val); -} - -function normalizePosition(pos, x, y) { - if (utils.isEmptyCssValue(pos) || pos === 'initial') { - return { - x, - y, - effects: { - x: utils.notEmptyValue(x, '0%'), - y: utils.notEmptyValue(y, '0%'), - }, - }; - } - - const xy = pos.split(/\s+/); - if (utils.isEmptyCssValue(x)) { - x = xy[0]; - } - if (utils.isEmptyCssValue(y)) { - y = xy[1]; - } - const effects = { x, y }; - const ret = { x, y, effects }; - - if (utils.isEmptyCssValue(y)) { - if (isPercent(x)) { - effects.y = '50%'; - } else if (x === 'left' || x === 'right' || x === 'center') { - effects.y = 'center'; - } else if (x === 'top' || x === 'bottom') { - effects.y = x; - effects.x = 'center'; - ret.y = x; - ret.x = ''; - } - } else if (x === 'top' || x === 'bottom' || y === 'left' || y === 'right') { - effects.y = x; - effects.x = y; - ret.y = x; - ret.x = y; - } - - return ret; -} - -class Offset extends Component { - static propTypes = { - current: PropTypes.any, - effects: PropTypes.any, - onChange: PropTypes.func, - }; - - render() { - return ( - - ); - } -} - -class Position extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleBackgrounPositionSetter'; - - setPosition(x, y) { - if (utils.isEmptyCssValue(x) || utils.isEmptyCssValue(y)) { - utils.setBackground(this.props, 'background-position', null); - utils.setPropertyValue(this.props, 'background-position-x', x); - utils.setPropertyValue(this.props, 'background-position-y', y); - } else { - utils.setBackground(this.props, 'background-position', `${x} ${y}`); - utils.setPropertyValue(this.props, 'background-position-x', null); - utils.setPropertyValue(this.props, 'background-position-y', null); - } - } - - render() { - const className = classNames('vs-style-background-position', this.props.className); - const { current, inherit } = utils.getBackground(this.props, 'background-position'); - const x = utils.getPropertyValue(this.props, 'background-position-x'); - const y = utils.getPropertyValue(this.props, 'background-position-y'); - - const currentXY = normalizePosition(current, x.current, y.current); - const inheritXY = normalizePosition(inherit, x.inherit, y.inherit); - - const effects = { - x: utils.notEmptyValue(currentXY.effects.x, inheritXY.effects.x), - y: utils.notEmptyValue(currentXY.effects.y, inheritXY.effects.y), - }; - - return ( -
- this.setPosition(X, Y)} /> - -
- - - -)} - > - this.setPosition(value, currentXY.y)} - /> - - - - -)} - > - this.setPosition(currentXY.x, value)} - /> - -
-
- ); - } -} - -export default Position; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/background/repeat.js b/packages/editor-setters/src/style-setter/lc-style-setter/background/repeat.js deleted file mode 100644 index 6696e18f2..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/background/repeat.js +++ /dev/null @@ -1,47 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import ChoiceControl from '@ali/ve-choice-control'; -import Icons from '@ali/ve-icons'; -import utils from '../utils'; -const repeats = [{ - title: , - value: 'repeat', -}, { - title: , - value: 'repeat-x', -}, { - title: , - value: 'repeat-y', -}, { - title: , - value: 'no-repeat', -}]; - -class Repeat extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleBackgrounRepeatSetter'; - - setRepeat(repeat) { - utils.setBackground(this.props, 'background-repeat', repeat); - } - - render() { - const className = classNames('vs-style-background-repeat', this.props.className); - const repeat = utils.getBackground(this.props, 'background-repeat').value; - - return ( - this.setRepeat(value)} - /> - ); - } -} - -export default Repeat; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/background/size.js b/packages/editor-setters/src/style-setter/lc-style-setter/background/size.js deleted file mode 100644 index 92362422e..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/background/size.js +++ /dev/null @@ -1,174 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import ChoiceControl from '@ali/ve-choice-control'; -import NumberControl from '@ali/ve-number-control'; -import Icons from '@ali/ve-icons'; -import Field from '@ali/ve-field'; -import utils from '../utils'; -import $i18n from '../i18n/index'; - -const RE_SIZE_PRESETS = /^(cover|contain)$/i; - -function getEffects(current, inherit) { - const size = utils.isEmptyCssValue(current) || current === 'initial' ? inherit : current; - - if (utils.isEmptyCssValue(size) || RE_SIZE_PRESETS.test(size)) { - return { x: 'auto', y: 'auto' }; - } - - const xy = size.split(/\s+/); - - return { - x: utils.isEmptyCssValue(xy[0]) ? 'auto' : xy[0], - y: utils.isEmptyCssValue(xy[1]) ? 'auto' : xy[1], - }; -} - -function normalizeCurrent(current) { - if (utils.isEmptyCssValue(current) || current === 'initial' || RE_SIZE_PRESETS.test(current)) { - return { - x: '', - y: '', - }; - } - - const xy = current.split(/\s+/); - - return { - x: utils.isEmptyCssValue(xy[0]) ? '' : xy[0], - y: utils.isEmptyCssValue(xy[1]) ? '' : xy[1], - }; -} - -class SizeItem extends Component { - static propTypes = { - current: PropTypes.any, - effects: PropTypes.any, - onChange: PropTypes.func, - }; - - render() { - return ( - - ); - } -} - -class Size extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleBackgrounSizeSetter'; - - setSize(sizeX, sizeY) { - let size; - if (utils.isEmptyCssValue(sizeX) && utils.isEmptyCssValue(sizeY)) { - size = ''; - } else if (RE_SIZE_PRESETS.test(sizeX) || utils.isEmptyCssValue(sizeY)) { - size = sizeX; - } else if (utils.isEmptyCssValue(sizeX) && !utils.isEmptyCssValue(sizeY)) { - size = `auto ${sizeY}`; - } else { - size = `${sizeX} ${sizeY}`; - } - utils.setBackground(this.props, 'background-size', size); - } - - render() { - const className = classNames('vs-style-background-size', this.props.className); - const { current, inherit, value } = utils.getBackground(this.props, 'background-size'); - - const currentXY = normalizeCurrent(current); - const effects = getEffects(current, inherit); - - return ( -
- , - value: 'cover', - }, - { - title: , - value: 'contain', - }, - ]} - value={value} - onChange={val => this.setSize(val, null)} - loose - /> - -
- - - -)} - > - this.setSize(val, currentXY.y)} - /> - - - - -)} - > - this.setSize(currentXY.x, val)} - /> - -
-
- ); - } -} - -export default Size; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/border/border.js b/packages/editor-setters/src/style-setter/lc-style-setter/border/border.js deleted file mode 100644 index 6d638ceac..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/border/border.js +++ /dev/null @@ -1,186 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import Field from '@ali/ve-field'; -import SelectControl from '@ali/ve-select-control'; -import NumberControl from '@ali/ve-number-control'; -import ColorControl from '@ali/ve-color-control'; -import borderParser from './borderParser'; -import utils from '../utils'; -import $i18n from '../i18n/index'; - -const BORDER_STYLES = { - none: $i18n.get({ id: 'styleNo', dm: '无' }), - solid: $i18n.get({ id: 'styleSolidLine', dm: '实线' }), - dotted: $i18n.get({ id: 'styleDottedLine', dm: '点线' }), - dashed: $i18n.get({ id: 'styleDottedLine.1', dm: '虚线' }), -}; - -const borderStyles = Object.keys(BORDER_STYLES).map(i => ({ - text: BORDER_STYLES[i], - value: i, -})); - -class BorderStyle extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleBorderSetter'; - - static transducer = utils.transducer; - - state = { - // state variable to indicate which border have use selected - // enum: border-left | border-right | border-top | border-bottom | border - currentSelected: 'border', - }; - - componentWillMount() { - - } - - componentWillUnmount() { - - } - - setValue(type, val, props) { - if (this.state.currentSelected === 'border') { - utils.setPropertyValue(props, `border-${type}`, val); - } else { - utils.setPropertyValue(props, `${this.state.currentSelected}-${type}`, val); - } - } - - changeSelectedBorder(type) { - this.setState({ currentSelected: type }); - } - - render() { - const className = classNames('vs-style-border-style', this.props.className); - const border = borderParser(this.props, this.state.currentSelected); - const { current, inherit } = border; - const borderWidth = current.width; - const borderColor = current.color; - const borderStyle = current.style; - - const inheritWidth = inherit.width || '0px'; - const inheritColor = inherit.color || '#000'; - const inheritStyle = inherit.style || 'none'; - - return ( -
-
-
-
- -
-
-
-
- -
-
- -
-
- -
-
-
-
- -
-
-
-
- - { - this.setValue('style', val, this.props); - }} - options={borderStyles} - /> - - - { - this.setValue('width', val, this.props); - }} - min={0} - units={[ - { - type: 'px', - list: true, - }, - { - type: '%', - list: true, - }, - { - type: 'em', - list: true, - }, - ]} - /> - - - { - this.setValue('color', val, this.props); - }} - /> - -
-
- ); - } -} - -export default BorderStyle; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/border/borderParser.js b/packages/editor-setters/src/style-setter/lc-style-setter/border/borderParser.js deleted file mode 100644 index 60a519b22..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/border/borderParser.js +++ /dev/null @@ -1,141 +0,0 @@ -import compose from 'lodash.flow'; -import curry from 'lodash.curry'; -import zipObject from 'lodash.zipobject'; -import { parse as parseBorder } from 'css-border-property'; -import utils from '../utils'; -// const logger = (val) => { -// console.log(val); -// return val; -// }; -const keys = Object.keys; -const getProp = p => (v => v[p]); -const stateMutator = { - setKey: (s, k, r) => { - s[k].c = r['border-color']; - s[k].s = r['border-style']; - s[k].w = r['border-width']; - }, - setKeyOnly: (s, k, k2, r, o) => { - s[k][k2] = r[o]; - }, - border: (s, r) => keys(s).forEach(k => stateMutator.setKey(s, k, r)), - 'border-left': (s, r) => stateMutator.setKey(s, 'l', r), - 'border-right': (s, r) => stateMutator.setKey(s, 'r', r), - 'border-top': (s, r) => stateMutator.setKey(s, 't', r), - 'border-bottom': (s, r) => stateMutator.setKey(s, 'b', r), - - 'border-style': (s, r) => keys(s).forEach(k => { s[k].s = r['border-style']; }), - 'border-width': (s, r) => keys(s).forEach(k => { s[k].w = r['border-width']; }), - 'border-color': (s, r) => keys(s).forEach(k => { s[k].c = r['border-color']; }), - - 'border-left-color': (s, r) => stateMutator.setKeyOnly(s, 'l', 'c', r, 'border-color'), - 'border-left-width': (s, r) => stateMutator.setKeyOnly(s, 'l', 'w', r, 'border-width'), - 'border-left-style': (s, r) => stateMutator.setKeyOnly(s, 'l', 's', r, 'border-style'), - - 'border-right-color': (s, r) => stateMutator.setKeyOnly(s, 'r', 'c', r, 'border-color'), - 'border-right-width': (s, r) => stateMutator.setKeyOnly(s, 'r', 'w', r, 'border-width'), - 'border-right-style': (s, r) => stateMutator.setKeyOnly(s, 'r', 's', r, 'border-style'), - - 'border-top-color': (s, r) => stateMutator.setKeyOnly(s, 't', 'c', r, 'border-color'), - 'border-top-width': (s, r) => stateMutator.setKeyOnly(s, 't', 'w', r, 'border-width'), - 'border-top-style': (s, r) => stateMutator.setKeyOnly(s, 't', 's', r, 'border-style'), - - 'border-bottom-color': (s, r) => stateMutator.setKeyOnly(s, 'b', 'c', r, 'border-color'), - 'border-bottom-width': (s, r) => stateMutator.setKeyOnly(s, 'b', 'w', r, 'border-width'), - 'border-bottom-style': (s, r) => stateMutator.setKeyOnly(s, 'b', 's', r, 'border-style'), -}; - -const mergeToObj = val => zipObject(val.map(getProp('property')), val.map(getProp('value'))); -const mapRuleToState = (rule, ruleState, applyFn) => { - const val = parseBorder(typeof rule === 'string' ? rule : ''); - const r = mergeToObj(val); - applyFn.call(null, ruleState, r); - return ruleState; -}; - -const mapStateToCurrentValue = (state, type) => { - switch (type) { - case 'border': - return { - // @todo consider to convert color to judge equal - color: keys(state).every(k => state[k].c === state.l.c) - ? state.l.c : '', - style: keys(state).every(k => state[k].s === state.l.s) - ? state.l.s : '', - width: keys(state).every(k => state[k].w === state.l.w) - ? state.l.w : '', - }; - case 'border-left': - return { - color: state.l.c, - style: state.l.s, - width: state.l.w, - }; - case 'border-right': - return { - color: state.r.c, - style: state.r.s, - width: state.r.w, - }; - case 'border-top': - return { - color: state.t.c, - style: state.t.s, - width: state.t.w, - }; - case 'border-bottom': - return { - color: state.b.c, - style: state.b.s, - width: state.b.w, - }; - default: - } - return { - color: '', - style: '', - width: '', - }; -}; - -const getEmptyRuleSet = () => ({ - l: { c: '', s: '', w: '' }, // left: color | style | width - r: { c: '', s: '', w: '' }, // right: color | style | width - t: { c: '', s: '', w: '' }, // top: color | style | width - b: { c: '', s: '', w: '' }, // bottom: color | style | width -}); - -export const parseToBorder = curry((type, mapfn, rules) => { - const ruleState = Object.assign({}, getEmptyRuleSet()); - rules.forEach(rule => mapRuleToState(rule[1], ruleState, stateMutator[rule[0]])); - return mapfn(ruleState, type); -}); - -const getRule = (rules, fn = v => v) => { - return fn(rules); -}; - -export const getRelatedRules = (rules, mutator) => { - const filterRules = ruleSet => keys(ruleSet) - .filter(v => !!mutator[v]) - .map(n => [n, getRule(rules)[n]]); - return getRule(rules, filterRules); -}; - -export default function borderParser(props, state, mutator = stateMutator) { - const rules = props.value || props.defaultValue || {}; - const current = compose( - getRelatedRules, - // logger, - parseToBorder(state, mapStateToCurrentValue), - )(rules, mutator); - const inheritStr = utils.getInheritPropertyValue( - rules, state, props.node); - const inheritValue = mergeToObj(parseBorder(typeof inheritStr !== 'string' ? '' : inheritStr)); - const inherit = { - color: inheritValue['border-color'], - style: inheritValue['border-style'], - width: inheritValue['border-width'], - }; - return { current, inherit, value: utils.notEmptyValue(current, inherit) }; -} diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/border/index.js b/packages/editor-setters/src/style-setter/lc-style-setter/border/index.js deleted file mode 100644 index 2a9f6e0a8..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/border/index.js +++ /dev/null @@ -1,33 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import BorderStyle from './border'; -import BorderRadius from './radius'; -import utils from '../utils'; -class Border extends Component { - - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - } - - static displayName = 'StyleBorderSetter'; - static transducer = utils.transducer; - - // shouldComponentUpdate() { - // return false; - // } - - - render() { - const className = classNames('vs-style-border', this.props.className); - - return ( -
- - -
- ); - } -} - -export default Border; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/border/radius.js b/packages/editor-setters/src/style-setter/lc-style-setter/border/radius.js deleted file mode 100644 index 8baef974b..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/border/radius.js +++ /dev/null @@ -1,141 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import Field from '@ali/ve-field'; -import NumberControl from '@ali/ve-number-control'; -import radiusParser from './radiusParser'; -import utils from '../utils'; -import $i18n from '../i18n/index'; - -class RadiusStyle extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'BorderRadiusStyleSetter'; - - static transducer = utils.transducer; - - state = { - // state variable to indicate which border have use selected - // enum: border-top-left | border-top-right - // border-bottom-left | border-bottom-right | border - currentSelected: 'border', - }; - - componentWillMount() { - - } - - componentWillUnmount() { - - } - - setValue(val, props) { - if (this.state.currentSelected === 'border') { - utils.setPropertyValue(props, 'border-radius', val); - } else { - utils.setPropertyValue(props, `${this.state.currentSelected}-radius`, val); - } - } - - changeSelectedRadius(type) { - this.setState({ currentSelected: type }); - } - - render() { - const className = classNames('vs-style-border-radius', this.props.className); - const radius = radiusParser(this.props, `${this.state.currentSelected}-radius`); - const radiusCurrent = radius.current; - const radiusInherit = radius.inherit; - - return ( -
-
-
-
- -
-
- -
-
-
-
- -
-
-
-
- -
-
- -
-
-
-
- - { - this.setValue(val, this.props); - }} - value={radiusCurrent || null} - min={0} - units={[ - { - type: 'px', - list: true, - }, - { - type: '%', - list: true, - }, - { - type: 'em', - list: true, - }, - ]} - /> - -
-
- ); - } -} - -export default RadiusStyle; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/border/radiusParser.js b/packages/editor-setters/src/style-setter/lc-style-setter/border/radiusParser.js deleted file mode 100644 index cad6b8a17..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/border/radiusParser.js +++ /dev/null @@ -1,54 +0,0 @@ -import compose from 'lodash.flow'; -import curry from 'lodash.curry'; -import { getRelatedRules } from './borderParser'; -import utils from '../utils'; -const keys = Object.keys; -const getRadiusEmptyState = () => ({ - tl: null, - tr: null, - bl: null, - br: null, -}); - -const stateMutator = { - 'border-radius': (s, r) => keys(s).forEach(k => { s[k] = r; }), - 'border-top-left-radius': (s, r) => { s.tl = r; }, - 'border-top-right-radius': (s, r) => { s.tr = r; }, - 'border-bottom-left-radius': (s, r) => { s.bl = r; }, - 'border-bottom-right-radius': (s, r) => { s.br = r; }, -}; - -const mapStateToCurrentValue = (state, type) => { - switch (type) { - case 'border-radius': - return keys(state).every(k => state[k] === state.tl) ? state.tl : null; - case 'border-top-left-radius': - return state.tl; - case 'border-top-right-radius': - return state.tr; - case 'border-bottom-left-radius': - return state.bl; - case 'border-bottom-right-radius': - return state.br; - default: - break; - } - return null; -}; - -const parseToRadius = curry((type, mapfn, rules) => { - const ruleState = Object.assign({}, getRadiusEmptyState()); - rules.forEach(rule => stateMutator[rule[0]](ruleState, rule[1])); - return mapfn(ruleState, type); -}); - -export default function radiusParser(props, state) { - const rules = props.value || props.defaultValue || {}; - const current = compose( - getRelatedRules, - parseToRadius(state, mapStateToCurrentValue) - )(rules, stateMutator); - const inherit = utils.getInheritPropertyValue( - rules, state, props.node); - return { current, inherit, value: utils.notEmptyValue(current, inherit) }; -} diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/effects/cursor.js b/packages/editor-setters/src/style-setter/lc-style-setter/effects/cursor.js deleted file mode 100644 index 9ec1bb1d5..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/effects/cursor.js +++ /dev/null @@ -1,46 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import SelectControl from '@ali/ve-select-control'; -import Icons from '@ali/ve-icons'; -import utils from '../utils'; -const CURSOR_TYPE = ['default', 'pointer']; - -class Cursor extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleOpacitySetter'; - static transducer = utils.transducer; - - componentWillMount() { - - } - - componentWillUnmount() { - - } - - render() { - const className = classNames('vs-style-cursor', this.props.className); - const cursor = utils.getPropertyValue(this.props, 'cursor'); - const options = CURSOR_TYPE.map((item, index) => ({ - text:
{item}
, - value: item, - })); - return ( - utils.setPropertyValue(this.props, 'cursor', val)} - min={0} - max={100} - syncTargetWidth - /> - ); - } -} - -export default Cursor; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/effects/index.js b/packages/editor-setters/src/style-setter/lc-style-setter/effects/index.js deleted file mode 100644 index 2a90c53ce..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/effects/index.js +++ /dev/null @@ -1,67 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import Icons from '@ali/ve-icons'; -import Field from '@ali/ve-field'; -import Opacity from './opacity'; -import Cursor from './cursor'; -import Shadow from './shadow'; - -import utils from '../utils'; -import $i18n from '../i18n/index'; - -class Effects extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleEffectsSetter'; - - static transducer = utils.transducer; - - componentWillMount() { - - } - - // shouldComponentUpdate() { - // return false; - // } - - componentWillUnmount() { - - } - - render() { - const className = classNames('vs-style-effects', this.props.className); - - return ( -
- - - -)} - > - - - - - -)} - > - - - -
- ); - } -} - -export default Effects; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/effects/opacity.js b/packages/editor-setters/src/style-setter/lc-style-setter/effects/opacity.js deleted file mode 100644 index f4e9b3ec4..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/effects/opacity.js +++ /dev/null @@ -1,47 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import NumberControl from '@ali/ve-number-control'; -import utils from '../utils'; -class Opacity extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleOpacitySetter'; - static transducer = utils.transducer; - - componentWillMount() { - - } - - componentWillUnmount() { - - } - - render() { - const className = classNames('vs-style-opacity', this.props.className); - const opacity = utils.getPropertyValue(this.props, 'opacity'); - const getFloat = v => parseFloat(v).toFixed(2); - const current = opacity.current ? `${parseInt(opacity.current * 100, 10)}%` : null; - return ( - { - const value = (parseFloat((val.split('%')[0])) / 100).toFixed(2); - utils.setPropertyValue(this.props, 'opacity', value); - }} - min={0} - max={100} - units={[{ - type: '%', - list: true, - }]} - /> - ); - } -} - -export default Opacity; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/effects/shadow.js b/packages/editor-setters/src/style-setter/lc-style-setter/effects/shadow.js deleted file mode 100644 index 775d5c3c4..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/effects/shadow.js +++ /dev/null @@ -1,210 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import Field from '@ali/ve-field'; -import Icons from '@ali/ve-icons'; -import NumberControl from '@ali/ve-number-control'; -import ColorControl from '@ali/ve-color-control'; - -import utils from '../utils'; -import $i18n from '../i18n/index'; - -const generateShadow = (c = 'rgba(0,0,0,0)', x = '0', y = '0', b = '0', s = '0') => `${c} ${x} ${y} ${b} ${s}`; - -class Shadow extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleShadowSetter'; - - static transducer = utils.transducer; - - componentWillMount() { - - } - - componentWillUnmount() { - - } - - render() { - const className = classNames('vs-style-shadow', this.props.className); - const shadow = utils.getPropertyValue(this.props, 'box-shadow').value; - - let c = ''; // color - let x = ''; // x - let y = ''; // y - let b = ''; // blur - let s = ''; // spread - - // @todo shadow parser 比较复杂考虑情况比较多,这里有明显的 Bug - // 由于时间问题,这里先留坑,满足可用性,后面有时间再来修复一下。 - if (shadow !== 'none' && !!shadow && typeof shadow === 'string') { - const res = shadow.split(' '); - s = res.pop(); - b = res.pop(); - y = res.pop(); - x = res.pop(); - c = res.join(' '); - } - - return ( -
-
- - - -)} - > - { - utils.setPropertyValue(this.props, 'box-shadow', generateShadow(val, x, y, b, s)); - }} - /> - -
-
- - { - utils.setPropertyValue(this.props, 'box-shadow', generateShadow(c, val, y, b, s)); - }} - min={0} - max={100} - units={[ - { - type: 'px', - list: true, - }, - { - type: '%', - list: true, - }, - { - type: 'em', - list: true, - }, - ]} - /> - - - { - utils.setPropertyValue(this.props, 'box-shadow', generateShadow(c, x, val, b, s)); - }} - min={0} - max={100} - units={[ - { - type: 'px', - list: true, - }, - { - type: '%', - list: true, - }, - { - type: 'em', - list: true, - }, - ]} - /> - -
-
- - - -)} - > - { - utils.setPropertyValue(this.props, 'box-shadow', generateShadow(c, x, y, val, s)); - }} - min={0} - max={100} - units={[ - { - type: 'px', - list: true, - }, - { - type: '%', - list: true, - }, - { - type: 'em', - list: true, - }, - ]} - /> - - - - -)} - > - { - utils.setPropertyValue(this.props, 'box-shadow', generateShadow(c, x, y, b, val)); - }} - min={0} - max={100} - units={[ - { - type: 'px', - list: true, - }, - { - type: '%', - list: true, - }, - { - type: 'em', - list: true, - }, - ]} - /> - -
-
- ); - } -} - -export default Shadow; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/i18n/index.js b/packages/editor-setters/src/style-setter/lc-style-setter/i18n/index.js deleted file mode 100644 index ed0ccb71e..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/i18n/index.js +++ /dev/null @@ -1,45 +0,0 @@ -const { provideIntl, destroyIntl } = require('@ali/intl-universal'); -const strings = require('./strings'); - -let intl; -const MEDUSA_APP_NAME = 'legao-designer'; -const PSEUDO_LANGUAGE_TAG = 'pd-KV'; -const CURRENT_LANGUAGE = (window.locale || window.localStorage.getItem('vdev-locale') || '').replace(/_/, '-') || 'zh-CN'; - -function update(language) { - destroyIntl(); - intl = provideIntl({ - locale: language, - messagesAIO: strings, - }); -} - -function get(id, variable) { - if (!intl) update(); - let string = ''; - let key = ''; - if (typeof id === 'string') { - key = id; - string = intl.formatMessage({ id }, variable); - } - if (typeof id === 'object' && id.dm) { - id.defaultMessage = id.dm; - } - key = id.id; - string = intl.formatMessage(id, variable); - if (CURRENT_LANGUAGE === PSEUDO_LANGUAGE_TAG) { - return `##@@@${key}##${MEDUSA_APP_NAME}@@@##${string}`; - } - return string; -} - -if (PSEUDO_LANGUAGE_TAG === CURRENT_LANGUAGE) { - update('en-US'); -} else { - update(CURRENT_LANGUAGE); -} - -module.exports = { - get, - update, -}; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/i18n/strings/en-US.json b/packages/editor-setters/src/style-setter/lc-style-setter/i18n/strings/en-US.json deleted file mode 100644 index 03a69fdf0..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/i18n/strings/en-US.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "styleImpactBlackBody": "Impact, black body", - "styleImpactMicrosoftYahei": "Impact, Microsoft Yahei", - "styleComicSansMSBlackbody": "Comic Sans MS, Blackbody", - "styleGeorgiaMicrosoftYahei": "Georgia, Microsoft Yahei", - "styleArialHelveticaBlackBody": "Arial, Helvetica, black body", - "styleLateralOffset": "Horizontal offset", - "styleAlign": "text-align", - "styleTrebuchetMSMicrosoftYahei": "Trebuchet MS, Microsoft Yahei", - "styleTrebuchetMSBlackBody": "Trebuchet MS, black body", - "styleArialHelveticaMicrosoftYahei": "Arial, Helvetica, Microsoft Yahei", - "styleLucidaSansUnicodeMicrosoft": "Lucida Sans Unicode, Microsoft Yahei", - "styleRowHeight": "line-height", - "styleFontColor": "font-color", - "styleSolidLine": "solid line", - "styleLinear": "style", - "styleLucidaConsoleBlackbody": "Lucida Console, Blackbody", - "styleStyle": "font-style", - "styleWordWeight": "font-width", - "styleLayout": "layout", - "styleSourceEditor": "Source editor", - "styleTopBorder": "Top border", - "styleStatus": "status", - "styleText": "Text", - "stylePleaseEnterAnAddress": "Please enter an address or paste upload", - "styleDefaultState": "Default state", - "styleRightBorder": "Right border", - "styleHigh": "high", - "styleBottomBorder": "Bottom border", - "styleTransparency": "opacity", - "styleBottomRightCorner": "Bottom right corner", - "styleUpperRightCorner": "Upper right corner", - "styleColour": "color", - "styleUnsupportedImage": "Unsupported image", - "styleTimesNewRomanBlackbody": "Times New Roman, Blackbody", - "styleLucidaConsoleMicrosoftYahei": "Lucida Console, Microsoft Yahei", - "styleDisplay": "display", - "styleFlexibleLayout": "Flexible layout", - "styleSize": "font-size", - "styleFillet": "radius", - "styleEffect": "effect", - "stylePositioning": "Positioning", - "styleLeftBorder": "Left border", - "styleBackground": "background", - "styleFillColor": "background-color", - "stylePalatinoLinotypeBlackBody": "Palatino Linotype, black body", - "styleFont": "font-family", - "styleMouseGesture": "cursor", - "styleAir": "empty", - "styleAll": "All", - "styleTimesNewRomanMicrosoft": "Times New Roman, Microsoft Yahei", - "styleUpperLeftCorner": "Upper left corner", - "styleCourierNewMicrosoftYahei": "Courier New, Microsoft Yahei", - "styleCourierNewBlackbody": "Courier New, Blackbody", - "styleFrame": "Border", - "styleImage": "background-image", - "styleComicSansMSMicrosoft": "Comic Sans MS, Microsoft Yahei", - "styleVerdanaBlackBody": "Verdana, black body", - "stylePalatinoLinotypeMicrosoftYahei": "Palatino Linotype, Microsoft Yahei", - "styleGeorgiaBlackbody": "Georgia, Blackbody", - "styleWidth": "width", - "styleVerticalOffset": "Vertical offset", - "styleModification": "text-decoration", - "styleHeight": "height", - "styleFixed": "fixed", - "styleLucidaSansUnicodeBlackbody": "Lucida Sans Unicode, Blackbody", - "styleVerdanaMicrosoftYahei": "Verdana, Microsoft Yahei", - "styleNo": "no", - "styleTile": "Tile", - "styleDottedLine": "dotted line", - "styleDottedLine.1": "dashed line" -} \ No newline at end of file diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/i18n/strings/index.js b/packages/editor-setters/src/style-setter/lc-style-setter/i18n/strings/index.js deleted file mode 100644 index 9b61c93e1..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/i18n/strings/index.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - 'en-US': require('./en-US.json'), - 'zh-CN': require('./zh-CN.json'), -}; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/i18n/strings/zh-CN.json b/packages/editor-setters/src/style-setter/lc-style-setter/i18n/strings/zh-CN.json deleted file mode 100644 index 599c944f8..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/i18n/strings/zh-CN.json +++ /dev/null @@ -1,72 +0,0 @@ -{ - "styleAir": "空", - "stylePalatinoLinotypeMicrosoftYahei": "Palatino Linotype, 微软雅黑", - "styleMouseGesture": "鼠标手势", - "styleAll": "全部", - "styleImpactBlackBody": "Impact, 黑体", - "styleFont": "字体", - "styleFrame": "边框", - "styleImage": "图片", - "styleRowHeight": "行高", - "styleArialHelveticaMicrosoftYahei": "Arial, Helvetica, 微软雅黑", - "styleUpperLeftCorner": "左上角", - "styleCourierNewMicrosoftYahei": "Courier New, 微软雅黑", - "styleTimesNewRomanMicrosoft": "Times New Roman, 微软雅黑", - "styleFixed": "固定", - "styleModification": "修饰", - "stylePleaseEnterAnAddress": "请输入地址或粘贴上传", - "styleText": "文字", - "styleVerticalOffset": "纵向偏移", - "styleComicSansMSMicrosoft": "Comic Sans MS, 微软雅黑", - "styleLinear": "线形", - "styleWidth": "宽", - "styleVerdanaBlackBody": "Verdana, 黑体", - "styleGeorgiaBlackbody": "Georgia, 黑体", - "styleTrebuchetMSBlackBody": "Trebuchet MS, 黑体", - "styleFillet": "圆角", - "styleFlexibleLayout": "弹性布局", - "styleDottedLine": "点线", - "styleLeftBorder": "左边框", - "styleNo": "无", - "styleLucidaSansUnicodeBlackbody": "Lucida Sans Unicode, 黑体", - "styleLucidaConsoleMicrosoftYahei": "Lucida Console, 微软雅黑", - "styleSize": "大小", - "styleLateralOffset": "横向偏移", - "styleAlign": "对齐", - "styleImpactMicrosoftYahei": "Impact, 微软雅黑", - "styleArialHelveticaBlackBody": "Arial, Helvetica, 黑体", - "styleComicSansMSBlackbody": "Comic Sans MS, 黑体", - "stylePalatinoLinotypeBlackBody": "Palatino Linotype, 黑体", - "styleGeorgiaMicrosoftYahei": "Georgia, 微软雅黑", - "styleDefaultState": "默认状态", - "styleFontColor": "字体颜色", - "styleSolidLine": "实线", - "styleTrebuchetMSMicrosoftYahei": "Trebuchet MS, 微软雅黑", - "styleLucidaSansUnicodeMicrosoft": "Lucida Sans Unicode, 微软雅黑", - "styleStyle": "样式", - "styleTransparency": "透明度", - "styleSourceEditor": "源码编辑", - "styleStatus": "状态", - "styleHigh": "高", - "styleTopBorder": "上边框", - "styleBottomBorder": "下边框", - "styleRightBorder": "右边框", - "styleHeight": "高度", - "styleLayout": "布局", - "styleUnsupportedImage": "暂未支持的图片", - "styleLucidaConsoleBlackbody": "Lucida Console, 黑体", - "styleWordWeight": "字重", - "styleCourierNewBlackbody": "Courier New, 黑体", - "styleFillColor": "填充色", - "styleTile": "平铺", - "styleBackground": "背景", - "stylePositioning": "定位", - "styleEffect": "效果", - "styleBottomRightCorner": "右下角", - "styleDottedLine.1": "虚线", - "styleColour": "颜色", - "styleTimesNewRomanBlackbody": "Times New Roman, 黑体", - "styleUpperRightCorner": "右上角", - "styleVerdanaMicrosoftYahei": "Verdana, 微软雅黑", - "styleDisplay": "显示" -} \ No newline at end of file diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/index.js b/packages/editor-setters/src/style-setter/lc-style-setter/index.js deleted file mode 100644 index 7eb21f3ae..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/index.js +++ /dev/null @@ -1,117 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import Field from '@ali/ve-field'; -import { registerDict } from '@ali/ve-icons'; -import { normalizeStyle } from '@ali/vu-css-style'; - -import Layout from './layout'; -import Typography from './typography'; -import Background from './background'; -import Border from './border'; -import Effects from './effects'; - -import utils from './utils'; -import SvgLib from './svglib'; -import './style.less'; -import $i18n from './i18n/index'; - -registerDict('style', SvgLib); - -/** - * state - * json: JSON模式 - * ---- - * layout - * display - * flexItem - * padding+margin - * size - * width - * height - * min+max advanced - * float advanced - * clear advanced - * overflow advanced - * position advanced - * background - * color - * image - * border - * border - * radius - * typography - * font-family - * color - * font-size - * text-align - * line-height - * font-weight - * text-decoration - * font-style - * letter-spacing advanced - * text-indent advanced - * text-transform advanced - * direction advanced - * effects - * opacity - * cursor - * svg - * fill - */ - -class StyleSetter extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleSetter'; - - static transducer = utils.transducer; - - static defaultProps = { - - }; - - render() { - const className = classNames( - 'vs-style', - 'vs-style-advanced', - this.props.className, - ); - // react style -> css style - const value = this.props.value ? normalizeStyle(this.props.value) : null; - const defaultValue = this.props.defaultValue ? normalizeStyle(this.props.defaultValue) : null; - const props = {...this.props, value, defaultValue}; - - return ( -
- - - - - - - - - - - - - - - -
- ); - } -} - -StyleSetter.Layout = Layout; -StyleSetter.Typography = Typography; -StyleSetter.Background = Background; -StyleSetter.Effects = Effects; -StyleSetter.Border = Border; - -// StyleSetter.Svg = Svg; - -export default StyleSetter; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/layout/display.js b/packages/editor-setters/src/style-setter/lc-style-setter/layout/display.js deleted file mode 100644 index 464abdf23..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/layout/display.js +++ /dev/null @@ -1,44 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import ChoiceControl from '@ali/ve-choice-control'; -import Icons from '@ali/ve-icons'; -import utils from '../utils'; -class Display extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleLayoutDisplaySetter'; - - render() { - const display = utils.getPropertyValue(this.props, 'display').value; - return ( - , - value: 'block', - }, { - title: , - value: 'inline-block', - }, { - title: , - value: 'inline', - }, { - title: , - value: 'flex', - }, - // { - // title: , - // value: 'none', - // } - ]} - onChange={val => utils.setPropertyValue(this.props, 'display', val)} - /> - ); - } -} - -export default Display; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/layout/flex.js b/packages/editor-setters/src/style-setter/lc-style-setter/layout/flex.js deleted file mode 100644 index 3e3e3addc..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/layout/flex.js +++ /dev/null @@ -1,176 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import ChoiceControl from '@ali/ve-choice-control'; -import Icons from '@ali/ve-icons'; -import Field from '@ali/ve-field'; -import utils from '../utils'; -class Flex extends Component { - static propTypes = { - prop: PropTypes.object, - }; - - static displayName = 'StyleLayoutFlexSetter'; - - render() { - // flex-direction - const direction = utils.getPropertyValue(this.props, 'flex-direction').value; - // align-items - const align = utils.getPropertyValue(this.props, 'align-items').value; - // justify-content - const justify = utils.getPropertyValue(this.props, 'justify-content').value; - /* - // flex-warp - const wrap = getPropertyValue(this.props, 'flex-wrap').value; - const isWrap = /^wrap/.test(wrap); - // align-content - const alignColumns = getPropertyValue(this.props, 'align-content').value; - */ - - const isVertical = /^column/.test(direction); - const v = isVertical ? '-v' : ''; - const reverseClass = /reverse$/.test(direction) - ? `vs-style-reverse${isVertical ? '-v' : '-h'}` : null; - - return ( -
- , - tip: 'Direction:row', - value: 'row', - }, { - title: , - tip: 'Direction:column', - value: 'column', - }, { - title: , - tip: 'Direction:row-reverse', - value: 'row-reverse', - }, { - title: (), - tip: 'Direction:column-reverse', - value: 'column-reverse', - }]} - onChange={(val) => utils.setPropertyValue(this.props, 'flex-direction', val)} - /> - - ), - tip: 'Align:flex-start', - value: 'flex-start', - }, { - title: ( - - ), - tip: 'Align:center', - value: 'center', - }, { - title: ( - - ), - tip: 'Align:flex-end', - value: 'flex-end', - }, { - title: ( - - ), - tip: 'Align:stretch', - value: 'stretch', - }, { - title: ( - - ), - tip: 'Align:baseline', - value: 'baseline', - }]} - onChange={(val) => utils.setPropertyValue(this.props, 'align-items', val)} - /> - - ), - tip: 'Justify:flex-start', - value: 'flex-start', - }, { - title: ( - - ), - tip: 'Justify:center', - value: 'center', - }, { - title: ( - - ), - tip: 'Justify:flex-end', - value: 'flex-end', - }, { - title: ( - - ), - tip: 'Justify:space-between', - value: 'space-between', - }, { - title: ( - - ), - tip: 'Justify:space-around', - value: 'space-around', - }]} - onChange={(val) => utils.setPropertyValue(this.props, 'justify-content', val)} - /> -
- ); - } -} - -export default Flex; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/layout/flexitem.js b/packages/editor-setters/src/style-setter/lc-style-setter/layout/flexitem.js deleted file mode 100644 index 0a432e05f..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/layout/flexitem.js +++ /dev/null @@ -1,10 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; - -class FlexItem extends Component { - render() { - return null; - } -} - -export default FlexItem; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/layout/height.js b/packages/editor-setters/src/style-setter/lc-style-setter/layout/height.js deleted file mode 100644 index 26e0afa45..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/layout/height.js +++ /dev/null @@ -1,19 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import Size from './size'; -import utils from '../utils'; -class Height extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleLayoutWidthSetter'; - - static transducer = utils.transducer; - - render() { - return ; - } -} - -export default Height; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/layout/index.js b/packages/editor-setters/src/style-setter/lc-style-setter/layout/index.js deleted file mode 100644 index 4a32635ca..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/layout/index.js +++ /dev/null @@ -1,107 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import Field from '@ali/ve-field'; -import Display from './display'; -import Flex from './flex'; -import FlexItem from './flexitem'; -import PaddingMargin from './padding+margin'; -import Width from './width'; -import Height from './height'; -import Position from './position'; // advanced -import utils from '../utils'; -import $i18n from '../i18n/index'; - -function inFlexBox(node) { - const nativeNode = node; - if (!nativeNode) return false; - const { parentNode } = nativeNode; - if (!parentNode) return false; - const display = window.getComputedStyle(parentNode).getPropertyValue('display'); - return /flex/.test(display); -} - -function isFlexBox(props) { - const display = utils.getPropertyValue(props, 'display').value; - return /flex$/.test(display); -} - -class Layout extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - }; - - static displayName = 'StyleLayoutSetter'; - - componentWillMount() { - - } - - // shouldComponentUpdate() { - // return false; - // } - - componentWillUnmount() { - - } - - render() { - const className = classNames('vs-style-layout', this.props.className); - const aFlexBox = isFlexBox(this.props); - const aFlexItem = inFlexBox(this.props.node); - - return ( -
- - - - {aFlexBox && ( - - - - )} - {/* todo: aFlexItem && - - */} - - - - - - - - - - - - {/* todo: - {advanced && - - } - */} -
- ); - } -} - -export default Layout; diff --git a/packages/editor-setters/src/style-setter/lc-style-setter/layout/padding+margin.js b/packages/editor-setters/src/style-setter/lc-style-setter/layout/padding+margin.js deleted file mode 100644 index a1d4a7b34..000000000 --- a/packages/editor-setters/src/style-setter/lc-style-setter/layout/padding+margin.js +++ /dev/null @@ -1,504 +0,0 @@ -import React, { Component, PropTypes } from 'react'; -import classNames from 'classnames'; -import Icons, { Button } from '@ali/ve-icons'; -import utils from '../utils'; -import $i18n from '../i18n/index'; - -function diplayValue(value) { - if (utils.isEmptyCssValue(value)) { - return $i18n.get({ id: 'styleAir', dm: '空' }); - } - - const m = /^(.+)px/.exec(value); - if (m) { - return m[1]; - } - - return value; -} - -class Input extends Component { - componentDidMount() { - if (this.input) { - this.input.select(); - } - } - - render() { - return ( - { - this.input = ref; - }} - {...this.props} - /> - ); - } -} - -class InlineInput extends Component { - static propTypes = { - className: PropTypes.string, - value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), - - inheritValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), - - onChange: PropTypes.func, - negtive: PropTypes.bool, - compute: PropTypes.func, - highlight: PropTypes.bool, - }; - - static defaultProps = { - compute() { - return '0px'; - }, - highlight: false, - }; - - constructor(props) { - super(props); - - this.state = { - value: '', - editing: false, - }; - - this.pattern = this.props.negtive - ? /^(-?\d+(?:\.\d+)?)(px|rem|em|%|pt)?$|^auto$/i - : /^(\d+(?:\.\d+)?)(px|rem|em|%|pt)?$|^auto$/i; - } - - componentWillReceiveProps(nextProps) { - if (nextProps.value !== this.props.value) { - this.setState({ value: utils.isEmptyCssValue(nextProps.value) ? '' : nextProps.value }); - } - } - - setValue(value) { - this.setState({ value }); - if (this.isValid(value) && this.props.onChange) { - this.props.onChange(value.trim()); - } - } - - isValid(value) { - return value.trim() === '' || this.pattern.test(value); - } - - keyDown(e) { - if (e.keyCode === 27 || e.keyCode === 13) { - this.exitEdit(); - e.preventDefault(); - return; - } - if (e.keyCode !== 38 && e.keyCode !== 40) { - return; - } - e.preventDefault(); - - const factor = e.keyCode === 40 ? -1 : 1; - let value = e.target.value.trim(); - if (!this.isValid(value)) { - value = utils.isEmptyCssValue(this.props.value) ? this.props.inheritValue : this.props.value; - } - - if (utils.isEmptyCssValue(value) || value.toLowerCase() === 'auto') { - value = this.props.compute(value); - } - - const m = this.pattern.exec(value); - if (!m[1]) return; - let n = parseFloat(m[1]) + factor; - if (!this.props.negtive && n < 0) { - n = 0; - } - this.setValue(`${n}${m[2] || 'px'}`); - } - - exitEdit() { - if (!/\D+$/.test(this.state.value)) { - this.setValue(`${this.state.value}px`); - } else if (!this.pattern.test(this.state.value)) { - this.setValue(`${/\d+/.exec(this.state.value)[0]}px`); - } - - this.setState({ - editing: false, - }); - } - - enterEdit() { - this.setState({ - editing: true, - value: utils.isEmptyCssValue(this.props.value) ? '' : this.props.value, - }); - } - - render() { - const { value, inheritValue, highlight } = this.props; - const className = classNames('vs-inline-input', this.props.className, { - 've-highlight': highlight, - }); - - const display = diplayValue(utils.isEmptyCssValue(value) ? inheritValue : value); - - return ( -
- {!this.state.editing && ( - - {display} - - )} - {this.state.editing && ( - this.setValue(e.target.value)} - onKeyDown={this.keyDown.bind(this)} - onBlur={this.exitEdit.bind(this)} - /> - )} -
- ); - } -} - -function spliteMargin(all) { - if (!all) { - return { - top: null, - right: null, - bottom: null, - left: null, - }; - } - let [top, right, bottom, left] = all.trim().split(/\s+/); // eslint-disable-line - if (utils.isEmptyCssValue(right)) { - right = top; - } - if (utils.isEmptyCssValue(bottom)) { - bottom = top; - } - if (utils.isEmptyCssValue(left)) { - left = right; - } - return { - top, right, bottom, left, - }; -} - -function compositeMargin(all, top, right, bottom, left) { - const ret = spliteMargin(all); - - if (!utils.isEmptyCssValue(top)) { - ret.top = top; - } - if (!utils.isEmptyCssValue(right)) { - ret.right = right; - } - if (!utils.isEmptyCssValue(bottom)) { - ret.bottom = bottom; - } - if (!utils.isEmptyCssValue(left)) { - ret.left = left; - } - - return ret; -} - -function isFull(box) { - return ( - !utils.isEmptyCssValue(box.top) - && !utils.isEmptyCssValue(box.right) - && !utils.isEmptyCssValue(box.bottom) - && !utils.isEmptyCssValue(box.left) - ); -} - -class LayoutBox extends Component { - static propTypes = { - prop: PropTypes.object, - className: PropTypes.string, - name: PropTypes.string, - negtive: PropTypes.bool, - }; - - constructor(props) { - super(props); - - this.pattern = this.props.negtive - ? /^(-?\d+(?:\.\d+)?)(px|rem|em|%|pt)?$|^auto$/i - : /^(\d+(?:\.\d+)?)(px|rem|em|%|pt)?$|^auto$/i; - } - - componentDidMount() { - this.shell.addEventListener('mousedown', (e) => { - // todo: dragging & interval add - const t = e.target; - if (t.dataset && t.dataset.handle) { - this.add(t.dataset.handle); - } - }); - } - - add(dir, factor = 1) { - if (!this.current || !this.inherit) return; - let value = utils.isEmptyCssValue(this.current[dir]) ? this.inherit[dir] : this.current[dir]; - - if (utils.isEmptyCssValue(value) || value.toLowerCase() === 'auto') { - value = this.compute(dir); - } - - const m = this.pattern.exec(value); - if (!m[1]) return; - let n = parseFloat(m[1]) + factor; - if (!this.props.negtive && n < 0) { - n = 0; - } - this.change(this.current, dir, `${n}${m[2] || 'px'}`); - } - - change(box, dir, val) { - const { name } = this.props; - box[dir] = val; - if (isFull(box)) { - utils.setPropertyValue( - this.props, - { - [name]: `${box.top} ${box.right} ${box.bottom} ${box.left}`, - [`${name}-top`]: null, - [`${name}-right`]: null, - [`${name}-bottom`]: null, - [`${name}-left`]: null, - }, - ); - } else { - utils.setPropertyValue( - this.props, - { - [name]: null, - [`${name}-top`]: box.top, - [`${name}-right`]: box.right, - [`${name}-bottom`]: box.bottom, - [`${name}-left`]: box.left, - }, - ); - } - } - - compute(dir) { - const { name, node } = this.props; - // if (external) { - // return getComputePropertyValue(node, `${name}-${dir}`); - // } - return '0px'; - } - - render() { - const { - name, negtive, - } = this.props; - - const all = utils.getPropertyValue(this.props, name); - const top = utils.getPropertyValue(this.props, `${name}-top`); - const right = utils.getPropertyValue(this.props, `${name}-right`); - const bottom = utils.getPropertyValue(this.props, `${name}-bottom`); - const left = utils.getPropertyValue(this.props, `${name}-left`); - - const current = compositeMargin( - all.current, - top.current, - right.current, - bottom.current, - left.current, - ); - - const inherit = compositeMargin( - all.inherit, - top.inherit, - right.inherit, - bottom.inherit, - left.inherit, - ); - - this.current = current; - this.inherit = inherit; - - return ( -
{ - this.shell = ref; - }} - > -
- -
- this.compute('top')} - negtive={negtive} - highlight={current.top != undefined} - onChange={val => this.change(current, 'top', val)} - /> - -
- -
- this.compute('right')} - onChange={val => this.change(current, 'right', val)} - /> - -
- {name} - -
- this.compute('bottom')} - onChange={val => this.change(current, 'bottom', val)} - /> - -
- -
- this.compute('left')} - onChange={val => this.change(current, 'left', val)} - /> -
- ); - } -} - -class MarginAuto extends Component { - static propTypes = { - prop: PropTypes.object, - }; - - setAuto(box) { - box.left = 'auto'; - box.right = 'auto'; - if (isFull(box)) { - utils.setPropertyValue( - this.props, - { - margin: `${box.top} ${box.right} ${box.bottom} ${box.left}`, - 'margin-top': null, - 'margin-right': null, - 'margin-bottom': null, - 'margin-left': null, - }, - ); - } else { - utils.setPropertyValue( - this.props, - { - margin: null, - 'margin-top': box.top, - 'margin-right': box.right, - 'margin-bottom': box.bottom, - 'margin-left': box.left, - }, - ); - } - } - - render() { - const all = utils.getPropertyValue(this.props, 'margin'); - const top = utils.getPropertyValue(this.props, 'margin-top'); - const bottom = utils.getPropertyValue(this.props, 'margin-bottom'); - const right = utils.getPropertyValue(this.props, 'margin-right'); - const left = utils.getPropertyValue(this.props, 'margin-left'); - - const current = compositeMargin( - all.current, - top.current, - right.current, - bottom.current, - left.current, - ); - - const inherit = compositeMargin( - all.inherit, - top.inherit, - right.inherit, - bottom.inherit, - left.inherit, - ); - - const eright = utils.isEmptyCssValue(current.right) ? inherit.right : current.right; - const eleft = utils.isEmptyCssValue(current.left) ? inherit.left : current.left; - - const className = classNames('vs-margin-auto', { - 've-active': eright === 'auto' && eleft === 'auto', - }); - - return ( -