-
- 宽度
-
-
-
-
高度
-
+ {isShowWidthHeight && (
+
+
+ {layoutConfig.width}
+
+
+
+ {layoutConfig.height}
+
+
-
+ )}
);
diff --git a/src/setter/style-setter/pro/layout/layoutBox.tsx b/src/setter/style-setter/pro/layout/layoutBox.tsx
index 705ab20..38c9b1d 100644
--- a/src/setter/style-setter/pro/layout/layoutBox.tsx
+++ b/src/setter/style-setter/pro/layout/layoutBox.tsx
@@ -1,8 +1,9 @@
import * as React from 'react';
+import cls from 'classnames';
import './index.less';
-import { Input } from '@alifd/next';
import { StyleData, onStyleChange } from '../../utils/types';
-import { addUnit, removeUnit } from '../../utils';
+import { addUnit, isCssVarBind, removeUnit as originRemoveUnit } from '../../utils';
+import LayoutInput from './LayoutInput';
const KEY_ARROW_DOWN = 'ArrowDown';
const KEY_ARROW_UP = 'ArrowUp';
@@ -10,11 +11,20 @@ const KEY_ARROW_UP = 'ArrowUp';
interface layoutBoxProps {
styleData: StyleData | any;
onStyleChange: onStyleChange;
- unit?: 'px';
+ unit?: string;
+ layoutPropsConfig: any;
+}
+
+const removeUnit = (value: any) => {
+ if (isCssVarBind(value)) {
+ return value;
+ }
+ return originRemoveUnit(value);
}
export default (props: layoutBoxProps) => {
- const { onStyleChange, unit = 'px', styleData } = props;
+ const { onStyleChange, unit = 'px', styleData, layoutPropsConfig } = props;
+
const onInputChange = (styleKey: string, value: string) => {
if (value != '') {
// 判断是否是数字
@@ -58,88 +68,97 @@ export default (props: layoutBoxProps) => {
return (
-
- onInputChange('marginTop', val)}
- onKeyDown={(e) => onInputKeyDown(e.key, 'marginTop')}
- >
-
-
- onInputChange('marginRight', val)}
- onKeyDown={(e) => onInputKeyDown(e.key, 'marginRight')}
- >
-
-
- MARGIN
- onInputChange('marginBottom', val)}
- onKeyDown={(e) => onInputKeyDown(e.key, 'marginBottom')}
- >
-
-
- onInputChange('marginLeft', val)}
- onKeyDown={(e) => onInputKeyDown(e.key, 'marginLeft')}
- >
-
-
- onInputChange('paddingTop', val)}
- onKeyDown={(e) => onInputKeyDown(e.key, 'paddingTop')}
- >
-
-
- onInputChange('paddingRight', val)}
- onKeyDown={(e) => onInputKeyDown(e.key, 'paddingRight')}
- >
-
-
- PADDING
- onInputChange('paddingBottom', val)}
- onKeyDown={(e) => onInputKeyDown(e.key, 'paddingBottom')}
- >
-
-
- onInputChange('paddingLeft', val)}
- onKeyDown={(e) => onInputKeyDown(e.key, 'paddingLeft')}
- >
-
+ {layoutPropsConfig.isShowMargin && (
+ <>
+
+ onInputChange('marginTop', val)}
+ onKeyDown={(e) => onInputKeyDown(e.key, 'marginTop')}
+ />
+
+
+ onInputChange('marginRight', val)}
+ onKeyDown={(e) => onInputKeyDown(e.key, 'marginRight')}
+ />
+
+
+ MARGIN
+ onInputChange('marginBottom', val)}
+ onKeyDown={(e) => onInputKeyDown(e.key, 'marginBottom')}
+ />
+
+
+ onInputChange('marginLeft', val)}
+ onKeyDown={(e) => onInputKeyDown(e.key, 'marginLeft')}
+ />
+
+ >
+ )}
+
+ {layoutPropsConfig.isShowPadding && (
+ <>
+
+ onInputChange('paddingTop', val)}
+ onKeyDown={(e) => onInputKeyDown(e.key, 'paddingTop')}
+ />
+
+
+ onInputChange('paddingRight', val)}
+ onKeyDown={(e) => onInputKeyDown(e.key, 'paddingRight')}
+ />
+
+
+ PADDING
+ onInputChange('paddingBottom', val)}
+ onKeyDown={(e) => onInputKeyDown(e.key, 'paddingBottom')}
+ />
+
+
+ onInputChange('paddingLeft', val)}
+ onKeyDown={(e) => onInputKeyDown(e.key, 'paddingLeft')}
+ />
+
+ >
+ )}
);
};
diff --git a/src/setter/style-setter/pro/layout/locale/en-US.json b/src/setter/style-setter/pro/layout/locale/en-US.json
new file mode 100644
index 0000000..565327e
--- /dev/null
+++ b/src/setter/style-setter/pro/layout/locale/en-US.json
@@ -0,0 +1,140 @@
+{
+ "title": "Layout",
+ "width": "width",
+ "height": "height",
+ "display": {
+ "title": "display",
+ "dataList": [
+ {
+ "value": "inline",
+ "tips": "inline",
+ "icon": "icon-a-Displayinline"
+ },
+ {
+ "value": "flex",
+ "tips": "flex",
+ "icon": "icon-a-Displayflex"
+ },
+ {
+ "value": "block",
+ "tips": "block",
+ "icon": "icon-a-Displayblock"
+ },
+ {
+ "value": "inline-block",
+ "tips": "inline-block",
+ "icon": "icon-a-Displayinline-block"
+ },
+ {
+ "value": "none",
+ "tips": "none",
+ "icon": "icon-yincang"
+ }
+ ]
+ },
+ "flexDirection": {
+ "title": "flex direction",
+ "dataList": [
+ {
+ "value": "row",
+ "tips": "row",
+ "icon": "icon-a-Directionrow"
+ },
+ {
+ "value": "row-reverse",
+ "tips": "row-reverse",
+ "icon": "icon-a-Directionrow-reverse"
+ },
+ {
+ "value": "column",
+ "tips": "column",
+ "icon": "icon-a-Directioncolumn"
+ },
+ {
+ "value": "column-reverse",
+ "tips": "column-reverse",
+ "icon": "icon-a-Directioncolumn-reverse"
+ }
+ ]
+ },
+ "justifyContent": {
+ "title": "justify content",
+ "dataList": [
+ {
+ "value": "flex-start",
+ "tips": "flex-start",
+ "icon": "icon-a-Justifyflex-startrow"
+ },
+ {
+ "value": "flex-end",
+ "tips": "flex-end",
+ "icon": "icon-a-Justifyflex-endrow"
+ },
+ {
+ "value": "center",
+ "tips": "center",
+ "icon": "icon-a-Justifycenterrow"
+ },
+ {
+ "value": "space-between",
+ "tips": "space-between",
+ "icon": "icon-a-Justifyspace-betweenrow"
+ },
+ {
+ "value": "space-around",
+ "tips": "space-around",
+ "icon": "icon-a-Justifyspace-aroundrow"
+ }
+ ]
+ },
+ "alignItems": {
+ "title": "align items",
+ "dataList": [
+ {
+ "value": "flex-start",
+ "tips": "flex-start",
+ "icon": "icon-a-Alignflex-startrow"
+ },
+ {
+ "value": "flex-end",
+ "tips": "flex-end",
+ "icon": "icon-a-Alignflex-endrow"
+ },
+ {
+ "value": "center",
+ "tips": "center",
+ "icon": "icon-a-Aligncenterrow"
+ },
+ {
+ "value": "baseline",
+ "tips": "baselin",
+ "icon": "icon-a-Alignbaselinerow"
+ },
+ {
+ "value": "stretch",
+ "tips": "stretch",
+ "icon": "icon-a-Alignstretchrow"
+ }
+ ]
+ },
+ "flexWrap": {
+ "title": "flexWrap",
+ "dataList": [
+ {
+ "value": "nowrap",
+ "tips": "nowrap",
+ "title": "nowrap"
+ },
+ {
+ "value": "wrap",
+ "tips": "wrap",
+ "title": "wrap"
+ },
+ {
+ "value": "wrap-reverse",
+ "tips": "wrap-reverse",
+ "title": "wrap-reverse"
+ }
+ ]
+ }
+}
diff --git a/src/setter/style-setter/pro/layout/locale/index.ts b/src/setter/style-setter/pro/layout/locale/index.ts
new file mode 100644
index 0000000..2c5b1d0
--- /dev/null
+++ b/src/setter/style-setter/pro/layout/locale/index.ts
@@ -0,0 +1,16 @@
+import { common } from '@alilc/lowcode-engine';
+import enUS from './en-US.json';
+import zhCN from './zh-CN.json';
+
+const intlLocal = () => {
+ const { getLocale } = common.utils.createIntl?.() || {};
+ const locale: string = getLocale?.() || 'zh-CN';
+ const localeSource: any = {
+ 'en-US': enUS,
+ 'zh-CN': zhCN,
+ };
+ return localeSource[locale];
+}
+
+
+export { intlLocal };
diff --git a/src/setter/style-setter/pro/layout/config.json b/src/setter/style-setter/pro/layout/locale/zh-CN.json
similarity index 69%
rename from src/setter/style-setter/pro/layout/config.json
rename to src/setter/style-setter/pro/layout/locale/zh-CN.json
index f892272..d01d3dc 100644
--- a/src/setter/style-setter/pro/layout/config.json
+++ b/src/setter/style-setter/pro/layout/locale/zh-CN.json
@@ -1,30 +1,33 @@
{
+ "title": "布局",
+ "width": "宽度",
+ "height": "高度",
"display": {
"title": "布局模式",
"dataList": [
{
"value": "inline",
- "tips": "内联布局 inline",
+ "tips": "内联布局",
"icon": "icon-a-Displayinline"
},
{
"value": "flex",
- "tips": "弹性布局 flex",
+ "tips": "弹性布局",
"icon": "icon-a-Displayflex"
},
{
"value": "block",
- "tips": "块级布局 block",
+ "tips": "块级布局",
"icon": "icon-a-Displayblock"
},
{
"value": "inline-block",
- "tips": "内联块布局 inline-block",
+ "tips": "内联块布局",
"icon": "icon-a-Displayinline-block"
},
{
"value": "none",
- "tips": "隐藏 none",
+ "tips": "隐藏",
"icon": "icon-yincang"
}
]
@@ -34,22 +37,22 @@
"dataList": [
{
"value": "row",
- "tips": "水平方向,起点在左侧 row",
+ "tips": "水平方向,起点在左侧",
"icon": "icon-a-Directionrow"
},
{
"value": "row-reverse",
- "tips": "水平方向,起点在右侧 row-reverse",
+ "tips": "水平方向,起点在右侧",
"icon": "icon-a-Directionrow-reverse"
},
{
"value": "column",
- "tips": "垂直方向,起点在上沿 column",
+ "tips": "垂直方向,起点在上沿",
"icon": "icon-a-Directioncolumn"
},
{
"value": "column-reverse",
- "tips": "垂直方向,起点在下沿 column-reverse",
+ "tips": "垂直方向,起点在下沿",
"icon": "icon-a-Directioncolumn-reverse"
}
]
@@ -59,27 +62,27 @@
"dataList": [
{
"value": "flex-start",
- "tips": "左对齐 flex-start",
+ "tips": "左对齐",
"icon": "icon-a-Justifyflex-startrow"
},
{
"value": "flex-end",
- "tips": "右对齐 flex-end",
+ "tips": "右对齐",
"icon": "icon-a-Justifyflex-endrow"
},
{
"value": "center",
- "tips": "水平居中 center",
+ "tips": "水平居中",
"icon": "icon-a-Justifycenterrow"
},
{
"value": "space-between",
- "tips": "两端对齐 space-between",
+ "tips": "两端对齐",
"icon": "icon-a-Justifyspace-betweenrow"
},
{
"value": "space-around",
- "tips": "横向平分 space-around",
+ "tips": "横向平分",
"icon": "icon-a-Justifyspace-aroundrow"
}
]
@@ -89,27 +92,27 @@
"dataList": [
{
"value": "flex-start",
- "tips": "起点对齐 flex-start",
+ "tips": "起点对齐",
"icon": "icon-a-Alignflex-startrow"
},
{
"value": "flex-end",
- "tips": "终点对齐 flex-end",
+ "tips": "终点对齐",
"icon": "icon-a-Alignflex-endrow"
},
{
"value": "center",
- "tips": "水平居中 center",
+ "tips": "水平居中",
"icon": "icon-a-Aligncenterrow"
},
{
"value": "baseline",
- "tips": "项目第一行文字的基线对齐 baseline",
+ "tips": "项目第一行文字的基线对齐",
"icon": "icon-a-Alignbaselinerow"
},
{
"value": "stretch",
- "tips": "沾满整个容器的高度 stretch",
+ "tips": "沾满整个容器的高度",
"icon": "icon-a-Alignstretchrow"
}
]
@@ -119,17 +122,17 @@
"dataList": [
{
"value": "nowrap",
- "tips": "不换行 nowrap",
+ "tips": "不换行",
"title": "不换行"
},
{
"value": "wrap",
- "tips": "第一行在上方 wrap",
+ "tips": "第一行在上方",
"title": "正换行"
},
{
"value": "wrap-reverse",
- "tips": "第一行在下方 wrap-reverse",
+ "tips": "第一行在下方",
"title": "逆换行"
}
]
diff --git a/src/setter/style-setter/pro/position/index.tsx b/src/setter/style-setter/pro/position/index.tsx
index e274a16..5ca8d8d 100644
--- a/src/setter/style-setter/pro/position/index.tsx
+++ b/src/setter/style-setter/pro/position/index.tsx
@@ -4,18 +4,25 @@ import { Collapse, NumberPicker, Select } from '@alifd/next';
import { useEffect } from 'react';
import PositionBox from '../position/positionBox';
import { StyleData, onStyleChange } from '../../utils/types';
-import positionConfig from './config.json';
-const Panel = Collapse.Panel;
+import { intlLocal } from './locale';
+import { isCssVarBind } from '../../utils';
+
+const {Panel} = Collapse;
interface layoutProps {
styleData: StyleData | any;
onStyleChange?: onStyleChange;
+ positionPropsConfig?: any;
}
+const positionConfig = intlLocal();
+
export default (props: layoutProps) => {
const { float, clear, position } = positionConfig;
- const { onStyleChange, styleData } = props;
+ const { onStyleChange, styleData, positionPropsConfig } = props;
+
+ const { isShowFloat, isShowClear } = positionPropsConfig;
const onZIndexChange = (zIndex: number) => {
onStyleChange([{ styleKey: 'zIndex', value: zIndex }]);
@@ -29,43 +36,48 @@ export default (props: layoutProps) => {
return (
-
+
- {styleData['position'] && styleData['position'] != 'static' && (
+ {styleData.position && styleData.position != 'static' && (
)}
-
+
-
-
+ {isShowFloat && (
+
+ )}
+ {isShowClear && (
+
+ )}
);
diff --git a/src/setter/style-setter/pro/position/locale/en-US.json b/src/setter/style-setter/pro/position/locale/en-US.json
new file mode 100644
index 0000000..73dfda0
--- /dev/null
+++ b/src/setter/style-setter/pro/position/locale/en-US.json
@@ -0,0 +1,103 @@
+{
+ "title": "Position",
+ "position": {
+ "title": "position",
+ "dataList": [
+ {
+ "value": "static",
+ "tips": "static",
+ "icon": "icon-position"
+ },
+ {
+ "value": "relative",
+ "tips": "relative",
+ "icon": "icon-relative"
+ },
+ {
+ "value": "absolute",
+ "tips": "absolute",
+ "icon": "icon-absolute"
+ },
+ {
+ "value": "fixed",
+ "tips": "fixed",
+ "icon": "icon-fixed"
+ },
+ {
+ "value": "sticky",
+ "tips": "sticky",
+ "icon": "icon-Objectpositioninterface"
+ }
+ ]
+ },
+ "float": {
+ "title": "float",
+ "dataList": [
+ {
+ "value": "none",
+ "tips": "none",
+ "icon": "icon-close"
+ },
+ {
+ "value": "left",
+ "tips": "left",
+ "icon": "icon-formatfloatleft"
+ },
+ {
+ "value": "right",
+ "tips": "right",
+ "icon": "icon-formatfloatright"
+ }
+ ]
+ },
+ "clear": {
+ "title": "clear",
+ "dataList": [
+ {
+ "value": "none",
+ "tips": "none",
+ "icon": "icon-close"
+ },
+ {
+ "value": "left",
+ "tips": "left",
+ "icon": "icon-qingchuzuoce"
+ },
+ {
+ "value": "right",
+ "tips": "right",
+ "icon": "icon-qingchuyouce"
+ },
+ {
+ "value": "both",
+ "tips": "both",
+ "icon": "icon-qingchuliangce"
+ }
+ ]
+ },
+
+ "positionTemplete": {
+ "dataList": [
+ {
+ "value": "topLeft",
+ "tips": "topLeft",
+ "icon": "icon-zuoshangcopy"
+ },
+ {
+ "value": "topRight",
+ "tips": "topRight",
+ "icon": "icon-youshangcopy"
+ },
+ {
+ "value": "bottomLeft",
+ "tips": "bottomLeft",
+ "icon": "icon-zuoxiacopy"
+ },
+ {
+ "value": "bottomRight",
+ "tips": "bottomRight",
+ "icon": "icon-youxiacopy"
+ }
+ ]
+ }
+}
diff --git a/src/setter/style-setter/pro/position/locale/index.ts b/src/setter/style-setter/pro/position/locale/index.ts
new file mode 100644
index 0000000..2c5b1d0
--- /dev/null
+++ b/src/setter/style-setter/pro/position/locale/index.ts
@@ -0,0 +1,16 @@
+import { common } from '@alilc/lowcode-engine';
+import enUS from './en-US.json';
+import zhCN from './zh-CN.json';
+
+const intlLocal = () => {
+ const { getLocale } = common.utils.createIntl?.() || {};
+ const locale: string = getLocale?.() || 'zh-CN';
+ const localeSource: any = {
+ 'en-US': enUS,
+ 'zh-CN': zhCN,
+ };
+ return localeSource[locale];
+}
+
+
+export { intlLocal };
diff --git a/src/setter/style-setter/pro/position/config.json b/src/setter/style-setter/pro/position/locale/zh-CN.json
similarity index 77%
rename from src/setter/style-setter/pro/position/config.json
rename to src/setter/style-setter/pro/position/locale/zh-CN.json
index 5cf7345..3da449f 100644
--- a/src/setter/style-setter/pro/position/config.json
+++ b/src/setter/style-setter/pro/position/locale/zh-CN.json
@@ -1,30 +1,31 @@
{
+ "title": "位置",
"position": {
- "title": "定位类型",
+ "title": "定位",
"dataList": [
{
"value": "static",
- "tips": "无定位 static",
+ "tips": "无定位",
"icon": "icon-position"
},
{
"value": "relative",
- "tips": "相对定位 relative",
+ "tips": "相对定位",
"icon": "icon-relative"
},
{
"value": "absolute",
- "tips": "绝对定位 absolute",
+ "tips": "绝对定位",
"icon": "icon-absolute"
},
{
"value": "fixed",
- "tips": "固定定位 fixed",
+ "tips": "固定定位",
"icon": "icon-fixed"
},
{
"value": "sticky",
- "tips": "粘性定位 sticky",
+ "tips": "粘性定位",
"icon": "icon-Objectpositioninterface"
}
]
@@ -34,17 +35,17 @@
"dataList": [
{
"value": "none",
- "tips": "不浮动 none",
+ "tips": "不浮动",
"icon": "icon-close"
},
{
"value": "left",
- "tips": "左浮动 left",
+ "tips": "左浮动",
"icon": "icon-formatfloatleft"
},
{
"value": "right",
- "tips": "右浮动 right",
+ "tips": "右浮动",
"icon": "icon-formatfloatright"
}
]
@@ -54,22 +55,22 @@
"dataList": [
{
"value": "none",
- "tips": "不清除 none",
+ "tips": "不清除",
"icon": "icon-close"
},
{
"value": "left",
- "tips": "左清除 left",
+ "tips": "左清除",
"icon": "icon-qingchuzuoce"
},
{
"value": "right",
- "tips": "右清除 right",
+ "tips": "右清除",
"icon": "icon-qingchuyouce"
},
{
"value": "both",
- "tips": "两边清除 both",
+ "tips": "两边清除",
"icon": "icon-qingchuliangce"
}
]
diff --git a/src/setter/style-setter/pro/position/positionBox.tsx b/src/setter/style-setter/pro/position/positionBox.tsx
index ad3633a..8848399 100644
--- a/src/setter/style-setter/pro/position/positionBox.tsx
+++ b/src/setter/style-setter/pro/position/positionBox.tsx
@@ -1,7 +1,7 @@
import * as React from 'react';
import { Input } from '@alifd/next';
import { StyleData, onStyleChange } from '../../utils/types';
-import positionConfig from './config.json';
+import { intlLocal } from './locale';
import Row from '../../components/row';
import { addUnit, removeUnit } from '../../utils';
import './index.less';
@@ -14,6 +14,8 @@ interface positionBoxProps {
unit?: 'px';
}
+const positionConfig = intlLocal();
+
export default (props: positionBoxProps) => {
const { onStyleChange, styleData, unit } = props;
const { positionTemplete } = positionConfig;
diff --git a/src/setter/style-setter/utils/index.tsx b/src/setter/style-setter/utils/index.tsx
index 391b3d7..bb35d5e 100644
--- a/src/setter/style-setter/utils/index.tsx
+++ b/src/setter/style-setter/utils/index.tsx
@@ -64,7 +64,7 @@ export function toLine(styleKey: string) {
}
export function toHump(name: String) {
- return name.replace(/\-(\w)/g, function (all, letter) {
+ return name.replace(/\-(\w)/g, (all, letter) => {
return letter.toUpperCase();
});
}
@@ -84,10 +84,10 @@ export function hexify(color: string) {
const g = Math.floor(a * parseInt(values[1]) + (1 - a) * 255);
const b = Math.floor(a * parseInt(values[2]) + (1 - a) * 255);
return (
- '#' +
- ('0' + r.toString(16)).slice(-2) +
- ('0' + g.toString(16)).slice(-2) +
- ('0' + b.toString(16)).slice(-2)
+ `#${
+ (`0${ r.toString(16)}`).slice(-2)
+ }${(`0${ g.toString(16)}`).slice(-2)
+ }${(`0${ b.toString(16)}`).slice(-2)}`
);
}
@@ -124,3 +124,44 @@ export function parseToStyleData(cssCode: string) {
return styleData;
}
+// 多参数样式解析单个参数
+export const parseValue = (styleValue: String, valueIndex: number) => {
+ if (!styleValue) return;
+ const styleArray = styleValue?.split(' ') || [];
+ const value = styleArray[valueIndex];
+ const unifiedValue = unifyValue(value);
+ return unifiedValue === 'auto' ? null : unifiedValue;
+};
+
+// 去除一下单位
+export const unifyValue = (value: string) => {
+ if (/^-?\d+px$/.test(value)) {
+ return value.replace('px', '');
+ }
+ return value;
+};
+
+// 规范手动输入的css样式
+export const unifyStyle = (value: string) => {
+ if (!value) return;
+ // 首部空格去除
+ if (value.substring(0, 1) === ' ') {
+ value.replace(/\s+/, '');
+ }
+ // 多属性间重复字符串去除
+ value.replace(/\s+/g, ' ');
+ return value;
+};
+
+export const getUnit = (value: string) => {
+ if(typeof value !== 'string') return ''
+ if (value != undefined && value != null){
+ return value.replace(/^-?[0-9]\d*/g, '')
+ }
+}
+
+export function isCssVarBind(value: any) {
+ if (typeof value === 'string') {
+ return /var\(/.test(value);
+ }
+}
diff --git a/src/setter/title-setter/index.scss b/src/setter/title-setter/index.scss
new file mode 100644
index 0000000..aba0faa
--- /dev/null
+++ b/src/setter/title-setter/index.scss
@@ -0,0 +1,22 @@
+/* write style here */
+.setter-title {
+ width: 100%;
+
+ > .next-input {
+ flex: auto;
+ }
+}
+
+.next-input.next-small {
+ height: var(--form-element-small-height, 28px);
+ min-height: 28px;
+ border-radius: var(--form-element-small-corner, 3px);
+}
+
+.next-input.next-small input {
+ height: calc(var(--form-element-small-height, 28px) - var(--input-border-width, 1px) * 2);
+ min-height: 26px;
+ line-height: calc(var(--form-element-small-height, 28px) - var(--input-border-width, 1px) * 2) \0;
+ padding: 0 var(--input-s-padding, 8px);
+ font-size: var(--form-element-small-font-size, 12px);
+}
diff --git a/src/setter/title-setter/index.tsx b/src/setter/title-setter/index.tsx
new file mode 100644
index 0000000..caab6b2
--- /dev/null
+++ b/src/setter/title-setter/index.tsx
@@ -0,0 +1,38 @@
+import React, { useState } from 'react';
+import { Switch, Input, Box } from '@alifd/next';
+import { SettingTarget } from '@alilc/lowcode-types';
+
+import './index.scss';
+
+interface TitleSetterProps {
+ field?: SettingTarget;
+ prop?: SettingTarget;
+ value: string;
+ defaultValue: string;
+ defaultChecked?: boolean;
+ onChange: Function;
+}
+
+const TitleSetter = (props: TitleSetterProps) => {
+ const { value, defaultValue, defaultChecked, onChange, field, prop } = props;
+ const [checked, setChecked] = useState(defaultChecked);
+ const target = field || prop;
+ const theVal = target?.getHotValue?.() || defaultValue || value;
+
+ const handleToggle = (vis: boolean) => {
+ onChange?.(vis ? theVal : '');
+ setChecked(vis);
+ };
+ const handleChangeText = (text: string) => {
+ onChange?.(text);
+ };
+
+ return (
+
+
+ {checked && }
+
+ );
+};
+
+export default TitleSetter;
diff --git a/src/setter/variable-setter/index.tsx b/src/setter/variable-setter/index.tsx
index a5092a6..84823f3 100644
--- a/src/setter/variable-setter/index.tsx
+++ b/src/setter/variable-setter/index.tsx
@@ -6,8 +6,9 @@ export default class SetterVariable extends PureComponent {
static displayName = 'SetterVariable';
static isPopup = true;
- static show({ prop: field }) {
- event.emit('variableBindDialog.openDialog', { field });
+ static show(params: any) {
+ const { prop: field, ...res } = params;
+ event.emit('variableBindDialog.openDialog', { field, ...res });
}
render() {