@gct-paas/schema 0.1.4-dev.7 → 0.1.4-dev.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { BorderStyle as o, TagTypeEnum as l, TextDecoration as t } from "@gct-paas/core";
2
- import { has as i } from "lodash-es";
3
- const b = {
1
+ import { BorderStyle as i, TagTypeEnum as b, TextDecoration as g } from "@gct-paas/core";
2
+ import { has as m, isEmpty as a, pick as u, isNil as l } from "lodash-es";
3
+ const B = {
4
4
  position: "",
5
5
  top: "",
6
6
  left: "",
@@ -24,7 +24,7 @@ const b = {
24
24
  fontSize: "",
25
25
  bold: !1,
26
26
  italic: !1,
27
- textDecoration: t.NONE,
27
+ textDecoration: g.NONE,
28
28
  color: ""
29
29
  },
30
30
  contentFont: {
@@ -32,36 +32,36 @@ const b = {
32
32
  fontSize: "",
33
33
  bold: !1,
34
34
  italic: !1,
35
- textDecoration: t.NONE,
35
+ textDecoration: g.NONE,
36
36
  color: ""
37
37
  },
38
38
  tagStyle: {
39
39
  color: "",
40
- tagType: l.RADIUS
40
+ tagType: b.RADIUS
41
41
  },
42
42
  tagStyleOpen: !1,
43
43
  borderAll: {
44
- borderStyle: o.NONE,
44
+ borderStyle: i.NONE,
45
45
  borderColor: "#F0F0F0",
46
46
  borderWidth: "1"
47
47
  },
48
48
  borderLeft: {
49
- borderStyle: o.NONE,
49
+ borderStyle: i.NONE,
50
50
  borderColor: "#F0F0F0",
51
51
  borderWidth: "1"
52
52
  },
53
53
  borderRight: {
54
- borderStyle: o.NONE,
54
+ borderStyle: i.NONE,
55
55
  borderColor: "#F0F0F0",
56
56
  borderWidth: "1"
57
57
  },
58
58
  borderBottom: {
59
- borderStyle: o.NONE,
59
+ borderStyle: i.NONE,
60
60
  borderColor: "#F0F0F0",
61
61
  borderWidth: "1"
62
62
  },
63
63
  borderTop: {
64
- borderStyle: o.NONE,
64
+ borderStyle: i.NONE,
65
65
  borderColor: "#F0F0F0",
66
66
  borderWidth: "1"
67
67
  },
@@ -70,7 +70,7 @@ const b = {
70
70
  borderBottomRightRadius: "0",
71
71
  borderBottomLeftRadius: "0",
72
72
  borderAllRadius: "0"
73
- }, g = [
73
+ }, E = [
74
74
  "position",
75
75
  "backgroundColor",
76
76
  "bold",
@@ -80,16 +80,158 @@ const b = {
80
80
  "borderStyle",
81
81
  "borderColor"
82
82
  ];
83
- function p(r, e, d) {
84
- return r.type === d && i(r, "preLocation") && new RegExp(`^${e}_`).test(r.preLocation);
83
+ function O(t, r, e) {
84
+ return t.type === e && m(t, "preLocation") && new RegExp(`^${r}_`).test(t.preLocation);
85
85
  }
86
- const c = {
86
+ function h(t) {
87
+ return t + "px";
88
+ }
89
+ function o(t) {
90
+ return a(t) ? "" : `${t}px !important`;
91
+ }
92
+ function f(t) {
93
+ return a(t) ? "" : `${t} !important`;
94
+ }
95
+ function p(t) {
96
+ return !t || a(t.borderWidth) ? "" : `${t.borderWidth}px ${t.borderStyle || "solid"} ${t.borderColor || "transparent"} !important`;
97
+ }
98
+ const s = {
99
+ fontAttrs: [
100
+ "fontWeight",
101
+ "fontSize",
102
+ "color",
103
+ "textDecorationLine",
104
+ "textAlign"
105
+ ],
106
+ mapAttrs: {
107
+ bold: {
108
+ attr: "fontWeight",
109
+ callback: (t) => t ? 700 : 400
110
+ },
111
+ italic: {
112
+ attr: "fontStyle",
113
+ callback: (t) => t ? "italic" : "normal"
114
+ },
115
+ textDecoration: {
116
+ attr: "textDecorationLine"
117
+ },
118
+ fontSize: {
119
+ attr: "fontSize",
120
+ callback: (t) => t ? h(t) : ""
121
+ },
122
+ align: {
123
+ attr: "textAlign"
124
+ }
125
+ }
126
+ };
127
+ function C(t, r = s) {
128
+ if (!t) return {};
129
+ const e = {};
130
+ return Object.assign(e, u(t, r.fontAttrs)), typeof r.mapAttrs == "object" && Object.keys(r.mapAttrs).forEach((n) => {
131
+ const { attr: d, callback: c } = r.mapAttrs[n];
132
+ e[d] = typeof c == "function" ? c(t[n]) : t[n];
133
+ }), e;
134
+ }
135
+ function D(t = {}) {
136
+ const r = {};
137
+ for (const e in t)
138
+ r[e] = R(e, t[e]);
139
+ return r;
140
+ }
141
+ const S = [
142
+ "opacity",
143
+ "zIndex",
144
+ "fontWeight",
145
+ "lineHeight",
146
+ "letterSpacing",
147
+ "wordSpacing",
148
+ "textAlign",
149
+ "textDecoration",
150
+ "textTransform",
151
+ "fontStyle",
152
+ "textDecorationLine"
153
+ ];
154
+ function R(t, r) {
155
+ return l(r) || a(r) ? "" : S.includes(t) ? r + " !important" : r + "px !important";
156
+ }
157
+ const x = {
158
+ left: "flex-start",
159
+ center: "center",
160
+ right: "flex-end",
161
+ justify: "space-between"
162
+ };
163
+ function W(t) {
164
+ return x[t] || t;
165
+ }
166
+ function T(t) {
167
+ return {
168
+ position: f(t.position),
169
+ top: o(t.top),
170
+ left: o(t.left),
171
+ right: o(t.right),
172
+ bottom: o(t.bottom),
173
+ width: o(t.width),
174
+ height: o(t.height)
175
+ };
176
+ }
177
+ function L(t) {
178
+ return {
179
+ backgroundColor: f(t.backgroundColor),
180
+ marginTop: o(t.marginTop),
181
+ marginRight: o(t.marginRight),
182
+ marginBottom: o(t.marginBottom),
183
+ marginLeft: o(t.marginLeft),
184
+ paddingTop: o(t.paddingTop),
185
+ paddingRight: o(t.paddingRight),
186
+ paddingBottom: o(t.paddingBottom),
187
+ paddingLeft: o(t.paddingLeft)
188
+ };
189
+ }
190
+ function F(t) {
191
+ return {
192
+ borderLeft: p(t.borderLeft),
193
+ borderRight: p(t.borderRight),
194
+ borderBottom: p(t.borderBottom),
195
+ borderTop: p(t.borderTop),
196
+ borderTopRightRadius: o(t.borderTopRightRadius),
197
+ borderTopLeftRadius: o(t.borderTopLeftRadius),
198
+ borderBottomRightRadius: o(t.borderBottomRightRadius),
199
+ borderBottomLeftRadius: o(t.borderBottomLeftRadius)
200
+ };
201
+ }
202
+ function k(t, r = []) {
203
+ const e = {
204
+ ...T(t),
205
+ ...L(t),
206
+ ...F(t)
207
+ };
208
+ return r.forEach((n) => {
209
+ delete e[n];
210
+ }), Object.keys(e).forEach((n) => {
211
+ const d = e[n];
212
+ (l(d) || a(d)) && delete e[n];
213
+ }), e;
214
+ }
215
+ const _ = {
87
216
  install() {
88
217
  }
89
218
  };
90
219
  export {
91
- b as commonStyle,
92
- c as default,
93
- p as getCompPos,
94
- g as notNeedPxStyle
220
+ x as ALIGN_TO_FLEX_MAP,
221
+ f as addImportant,
222
+ o as addPxUnit,
223
+ B as commonStyle,
224
+ _ as default,
225
+ C as extractFontStyle,
226
+ p as formatBorder,
227
+ F as generateBorderStyles,
228
+ T as generatePositionStyles,
229
+ L as generateSpacingStyles,
230
+ k as generateWrapperStyle,
231
+ O as getCompPos,
232
+ R as makeStyleProp,
233
+ E as notNeedPxStyle,
234
+ D as propsToStyle,
235
+ h as pxToVw,
236
+ W as transAlign2flex
95
237
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o=require("@gct-paas/core"),d=require("lodash-es"),l={position:"",top:"",left:"",right:"",bottom:"",width:"",height:"",backgroundColor:"",marginAll:"",marginTop:"",marginRight:"",marginBottom:"",marginLeft:"",paddingAll:"",paddingTop:"",paddingRight:"",paddingBottom:"",paddingLeft:"",labelFont:{align:"left",fontSize:"",bold:!1,italic:!1,textDecoration:o.TextDecoration.NONE,color:""},contentFont:{align:"left",fontSize:"",bold:!1,italic:!1,textDecoration:o.TextDecoration.NONE,color:""},tagStyle:{color:"",tagType:o.TagTypeEnum.RADIUS},tagStyleOpen:!1,borderAll:{borderStyle:o.BorderStyle.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderLeft:{borderStyle:o.BorderStyle.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderRight:{borderStyle:o.BorderStyle.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderBottom:{borderStyle:o.BorderStyle.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderTop:{borderStyle:o.BorderStyle.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderTopRightRadius:"0",borderTopLeftRadius:"0",borderBottomRightRadius:"0",borderBottomLeftRadius:"0",borderAllRadius:"0"},i=["position","backgroundColor","bold","italic","textDecoration","color","borderStyle","borderColor"];function n(e,r,t){return e.type===t&&d.has(e,"preLocation")&&new RegExp(`^${r}_`).test(e.preLocation)}const a={install(){}};exports.commonStyle=l;exports.default=a;exports.getCompPos=n;exports.notNeedPxStyle=i;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("@gct-paas/core"),n=require("lodash-es"),S={position:"",top:"",left:"",right:"",bottom:"",width:"",height:"",backgroundColor:"",marginAll:"",marginTop:"",marginRight:"",marginBottom:"",marginLeft:"",paddingAll:"",paddingTop:"",paddingRight:"",paddingBottom:"",paddingLeft:"",labelFont:{align:"left",fontSize:"",bold:!1,italic:!1,textDecoration:a.TextDecoration.NONE,color:""},contentFont:{align:"left",fontSize:"",bold:!1,italic:!1,textDecoration:a.TextDecoration.NONE,color:""},tagStyle:{color:"",tagType:a.TagTypeEnum.RADIUS},tagStyleOpen:!1,borderAll:{borderStyle:a.BorderStyle.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderLeft:{borderStyle:a.BorderStyle.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderRight:{borderStyle:a.BorderStyle.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderBottom:{borderStyle:a.BorderStyle.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderTop:{borderStyle:a.BorderStyle.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderTopRightRadius:"0",borderTopLeftRadius:"0",borderBottomRightRadius:"0",borderBottomLeftRadius:"0",borderAllRadius:"0"},h=["position","backgroundColor","bold","italic","textDecoration","color","borderStyle","borderColor"];function x(t,r,e){return t.type===e&&n.has(t,"preLocation")&&new RegExp(`^${r}_`).test(t.preLocation)}function g(t){return t+"px"}function o(t){return n.isEmpty(t)?"":`${t}px !important`}function p(t){return n.isEmpty(t)?"":`${t} !important`}function d(t){return!t||n.isEmpty(t.borderWidth)?"":`${t.borderWidth}px ${t.borderStyle||"solid"} ${t.borderColor||"transparent"} !important`}const T={fontAttrs:["fontWeight","fontSize","color","textDecorationLine","textAlign"],mapAttrs:{bold:{attr:"fontWeight",callback:t=>t?700:400},italic:{attr:"fontStyle",callback:t=>t?"italic":"normal"},textDecoration:{attr:"textDecorationLine"},fontSize:{attr:"fontSize",callback:t=>t?g(t):""},align:{attr:"textAlign"}}};function R(t,r=T){if(!t)return{};const e={};return Object.assign(e,n.pick(t,r.fontAttrs)),typeof r.mapAttrs=="object"&&Object.keys(r.mapAttrs).forEach(i=>{const{attr:l,callback:c}=r.mapAttrs[i];e[l]=typeof c=="function"?c(t[i]):t[i]}),e}function y(t={}){const r={};for(const e in t)r[e]=f(e,t[e]);return r}const L=["opacity","zIndex","fontWeight","lineHeight","letterSpacing","wordSpacing","textAlign","textDecoration","textTransform","fontStyle","textDecorationLine"];function f(t,r){return n.isNil(r)||n.isEmpty(r)?"":L.includes(t)?r+" !important":r+"px !important"}const b={left:"flex-start",center:"center",right:"flex-end",justify:"space-between"};function B(t){return b[t]||t}function m(t){return{position:p(t.position),top:o(t.top),left:o(t.left),right:o(t.right),bottom:o(t.bottom),width:o(t.width),height:o(t.height)}}function s(t){return{backgroundColor:p(t.backgroundColor),marginTop:o(t.marginTop),marginRight:o(t.marginRight),marginBottom:o(t.marginBottom),marginLeft:o(t.marginLeft),paddingTop:o(t.paddingTop),paddingRight:o(t.paddingRight),paddingBottom:o(t.paddingBottom),paddingLeft:o(t.paddingLeft)}}function u(t){return{borderLeft:d(t.borderLeft),borderRight:d(t.borderRight),borderBottom:d(t.borderBottom),borderTop:d(t.borderTop),borderTopRightRadius:o(t.borderTopRightRadius),borderTopLeftRadius:o(t.borderTopLeftRadius),borderBottomRightRadius:o(t.borderBottomRightRadius),borderBottomLeftRadius:o(t.borderBottomLeftRadius)}}function E(t,r=[]){const e={...m(t),...s(t),...u(t)};return r.forEach(i=>{delete e[i]}),Object.keys(e).forEach(i=>{const l=e[i];(n.isNil(l)||n.isEmpty(l))&&delete e[i]}),e}const F={install(){}};exports.ALIGN_TO_FLEX_MAP=b;exports.addImportant=p;exports.addPxUnit=o;exports.commonStyle=S;exports.default=F;exports.extractFontStyle=R;exports.formatBorder=d;exports.generateBorderStyles=u;exports.generatePositionStyles=m;exports.generateSpacingStyles=s;exports.generateWrapperStyle=E;exports.getCompPos=x;exports.makeStyleProp=f;exports.notNeedPxStyle=h;exports.propsToStyle=y;exports.pxToVw=g;exports.transAlign2flex=B;
@@ -1 +1 @@
1
- System.register(["@gct-paas/core","lodash-es"],(function(e,c){"use strict";var o,l,r,i;return{setters:[t=>{o=t.BorderStyle,l=t.TagTypeEnum,r=t.TextDecoration},t=>{i=t.has}],execute:(function(){e("getCompPos",n);const t=e("commonStyle",{position:"",top:"",left:"",right:"",bottom:"",width:"",height:"",backgroundColor:"",marginAll:"",marginTop:"",marginRight:"",marginBottom:"",marginLeft:"",paddingAll:"",paddingTop:"",paddingRight:"",paddingBottom:"",paddingLeft:"",labelFont:{align:"left",fontSize:"",bold:!1,italic:!1,textDecoration:r.NONE,color:""},contentFont:{align:"left",fontSize:"",bold:!1,italic:!1,textDecoration:r.NONE,color:""},tagStyle:{color:"",tagType:l.RADIUS},tagStyleOpen:!1,borderAll:{borderStyle:o.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderLeft:{borderStyle:o.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderRight:{borderStyle:o.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderBottom:{borderStyle:o.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderTop:{borderStyle:o.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderTopRightRadius:"0",borderTopLeftRadius:"0",borderBottomRightRadius:"0",borderBottomLeftRadius:"0",borderAllRadius:"0"}),g=e("notNeedPxStyle",["position","backgroundColor","bold","italic","textDecoration","color","borderStyle","borderColor"]);function n(d,a,b){return d.type===b&&i(d,"preLocation")&&new RegExp(`^${a}_`).test(d.preLocation)}const s=e("default",{install(){}})})}}));
1
+ System.register(["@gct-paas/core","lodash-es"],(function(c,D){"use strict";var a,m,l,s,d,u,f;return{setters:[n=>{a=n.BorderStyle,m=n.TagTypeEnum,l=n.TextDecoration},n=>{s=n.has,d=n.isEmpty,u=n.pick,f=n.isNil}],execute:(function(){c({addImportant:b,addPxUnit:o,extractFontStyle:y,formatBorder:p,generateBorderStyles:R,generatePositionStyles:T,generateSpacingStyles:x,generateWrapperStyle:C,getCompPos:F,makeStyleProp:S,propsToStyle:A,pxToVw:h,transAlign2flex:O});const n=c("commonStyle",{position:"",top:"",left:"",right:"",bottom:"",width:"",height:"",backgroundColor:"",marginAll:"",marginTop:"",marginRight:"",marginBottom:"",marginLeft:"",paddingAll:"",paddingTop:"",paddingRight:"",paddingBottom:"",paddingLeft:"",labelFont:{align:"left",fontSize:"",bold:!1,italic:!1,textDecoration:l.NONE,color:""},contentFont:{align:"left",fontSize:"",bold:!1,italic:!1,textDecoration:l.NONE,color:""},tagStyle:{color:"",tagType:m.RADIUS},tagStyleOpen:!1,borderAll:{borderStyle:a.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderLeft:{borderStyle:a.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderRight:{borderStyle:a.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderBottom:{borderStyle:a.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderTop:{borderStyle:a.NONE,borderColor:"#F0F0F0",borderWidth:"1"},borderTopRightRadius:"0",borderTopLeftRadius:"0",borderBottomRightRadius:"0",borderBottomLeftRadius:"0",borderAllRadius:"0"}),P=c("notNeedPxStyle",["position","backgroundColor","bold","italic","textDecoration","color","borderStyle","borderColor"]);function F(t,r,e){return t.type===e&&s(t,"preLocation")&&new RegExp(`^${r}_`).test(t.preLocation)}function h(t){return t+"px"}function o(t){return d(t)?"":`${t}px !important`}function b(t){return d(t)?"":`${t} !important`}function p(t){return!t||d(t.borderWidth)?"":`${t.borderWidth}px ${t.borderStyle||"solid"} ${t.borderColor||"transparent"} !important`}const N={fontAttrs:["fontWeight","fontSize","color","textDecorationLine","textAlign"],mapAttrs:{bold:{attr:"fontWeight",callback:t=>t?700:400},italic:{attr:"fontStyle",callback:t=>t?"italic":"normal"},textDecoration:{attr:"textDecorationLine"},fontSize:{attr:"fontSize",callback:t=>t?h(t):""},align:{attr:"textAlign"}}};function y(t,r=N){if(!t)return{};const e={};return Object.assign(e,u(t,r.fontAttrs)),typeof r.mapAttrs=="object"&&Object.keys(r.mapAttrs).forEach(i=>{const{attr:g,callback:L}=r.mapAttrs[i];e[g]=typeof L=="function"?L(t[i]):t[i]}),e}function A(t={}){const r={};for(const e in t)r[e]=S(e,t[e]);return r}const B=["opacity","zIndex","fontWeight","lineHeight","letterSpacing","wordSpacing","textAlign","textDecoration","textTransform","fontStyle","textDecorationLine"];function S(t,r){return f(r)||d(r)?"":B.includes(t)?r+" !important":r+"px !important"}const E=c("ALIGN_TO_FLEX_MAP",{left:"flex-start",center:"center",right:"flex-end",justify:"space-between"});function O(t){return E[t]||t}function T(t){return{position:b(t.position),top:o(t.top),left:o(t.left),right:o(t.right),bottom:o(t.bottom),width:o(t.width),height:o(t.height)}}function x(t){return{backgroundColor:b(t.backgroundColor),marginTop:o(t.marginTop),marginRight:o(t.marginRight),marginBottom:o(t.marginBottom),marginLeft:o(t.marginLeft),paddingTop:o(t.paddingTop),paddingRight:o(t.paddingRight),paddingBottom:o(t.paddingBottom),paddingLeft:o(t.paddingLeft)}}function R(t){return{borderLeft:p(t.borderLeft),borderRight:p(t.borderRight),borderBottom:p(t.borderBottom),borderTop:p(t.borderTop),borderTopRightRadius:o(t.borderTopRightRadius),borderTopLeftRadius:o(t.borderTopLeftRadius),borderBottomRightRadius:o(t.borderBottomRightRadius),borderBottomLeftRadius:o(t.borderBottomLeftRadius)}}function C(t,r=[]){const e={...T(t),...x(t),...R(t)};return r.forEach(i=>{delete e[i]}),Object.keys(e).forEach(i=>{const g=e[i];(f(g)||d(g))&&delete e[i]}),e}const W=c("default",{install(){}})})}}));
package/es/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  export { commonStyle, notNeedPxStyle } from './schema/common-config/common-style.mjs';
2
2
  export { getCompPos } from './utils/schema/index.mjs';
3
+ export { ALIGN_TO_FLEX_MAP, addImportant, addPxUnit, extractFontStyle, formatBorder, generateBorderStyles, generatePositionStyles, generateSpacingStyles, generateWrapperStyle, makeStyleProp, propsToStyle, pxToVw, transAlign2flex } from './utils/schema-style/index.mjs';
3
4
 
4
5
  const index = {
5
6
  install() {
@@ -1,8 +1,9 @@
1
1
  import { pageLayoutModeEnum } from '@gct-paas/core';
2
- import { LowCodeWidget } from './widget';
3
2
  import { LowCodeModal } from './modal';
3
+ import { LowCodeWidget } from './widget';
4
4
  export interface PageJson {
5
5
  id: string;
6
+ key?: string;
6
7
  keepAlive: boolean;
7
8
  /**页面事件 */
8
9
  pageEvents: {
@@ -2,6 +2,7 @@ import { CategoryTypeEnum, Platform, FormComponents, DisplayEnums, MaterialEnum,
2
2
  import { IBasicStyle } from './i-styles';
3
3
  import { ICommonProps, IWidgetProps, IFormItemProps } from './i-props';
4
4
  import { IBasicEvents } from './i-events';
5
+ import { PagePlugin } from '../designer';
5
6
  /**
6
7
  * 单个组件节点描述
7
8
  *
@@ -58,8 +59,14 @@ export interface IBasicSchema {
58
59
  isReadonlyWidget?: boolean;
59
60
  /** 部分组件嵌套在某个父组件内部 */
60
61
  parentComponent?: FormComponents;
61
- /** 如果是插件,此处是拖入时插件的配置信息 */
62
- _plugin?: IObject;
62
+ /** 拖拽放置容器的无子项提示 */
63
+ dropPlaceholder?: string;
64
+ /**
65
+ * 如果是插件过如,保存插件快照信息
66
+ *
67
+ * @type {PagePlugin}
68
+ */
69
+ _plugin?: PagePlugin;
63
70
  }
64
71
  /**
65
72
  * 字段类型组件
@@ -1,4 +1,4 @@
1
- import { TextDecoration, TagTypeEnum, ProgressTypeEnum, tableColumnWidthEnum, tagEnum } from '@gct-paas/core';
1
+ import { ProgressTypeEnum, tableColumnWidthEnum, tagEnum, TagTypeEnum, TextDecoration } from '@gct-paas/core';
2
2
  /**
3
3
  * Font样式
4
4
  *
@@ -110,4 +110,5 @@ export interface IBasicStyle {
110
110
  tableheight?: number;
111
111
  /** 表格高度样式 */
112
112
  tableheightConfigure?: tableColumnWidthEnum;
113
+ enableHeaderBGColor?: boolean;
113
114
  }
@@ -1 +1,2 @@
1
1
  export { getCompPos } from './schema';
2
+ export { pxToVw, addPxUnit, addImportant, formatBorder, extractFontStyle, propsToStyle, makeStyleProp, ALIGN_TO_FLEX_MAP, transAlign2flex, generatePositionStyles, generateSpacingStyles, generateBorderStyles, generateWrapperStyle, } from './schema-style';
@@ -0,0 +1,108 @@
1
+ /**
2
+ * 样式计算工具类
3
+ * 提供样式单位转换、属性映射、样式属性处理等公共方法
4
+ */
5
+ /**
6
+ * 将像素值转换为对应单位
7
+ * 在移动环境下转换为 vw,其他环境保持 px
8
+ *
9
+ * @param pxValue - 像素值
10
+ * @returns 转换后的单位值字符串
11
+ */
12
+ export declare function pxToVw(pxValue: number): string;
13
+ /**
14
+ * 添加 px 单位到样式值
15
+ *
16
+ * @param value - 样式值
17
+ * @returns 带 px 单位和 !important 的样式字符串
18
+ */
19
+ export declare function addPxUnit(value?: string): string;
20
+ /**
21
+ * 添加 !important 标志到样式值(不添加单位)
22
+ *
23
+ * @param value - 样式值
24
+ * @returns 带 !important 的样式字符串
25
+ */
26
+ export declare function addImportant(value?: string): string;
27
+ /**
28
+ * 格式化边框样式对象
29
+ *
30
+ * @param border - 边框配置对象,包含 borderWidth、borderStyle、borderColor
31
+ * @returns 格式化后的边框样式字符串
32
+ */
33
+ export declare function formatBorder(border?: IObject): string;
34
+ /**
35
+ * 字体样式处理配置
36
+ */
37
+ interface IFontConfig {
38
+ fontAttrs: string[];
39
+ mapAttrs: Record<string, {
40
+ attr: string;
41
+ callback?: (value: any) => any;
42
+ }>;
43
+ }
44
+ /**
45
+ * 从字体配置对象中提取并转换字体样式
46
+ *
47
+ * @param font - 字体配置对象
48
+ * @param config - 字体样式处理配置(可选,使用默认配置)
49
+ * @returns 转换后的样式对象
50
+ */
51
+ export declare function extractFontStyle(font: IObject, config?: IFontConfig): IObject;
52
+ /**
53
+ * 将样式属性对象转换为 CSS 样式字符串格式
54
+ *
55
+ * @param styleProps - 样式属性对象
56
+ * @returns 转换后的样式对象(含单位和 !important)
57
+ */
58
+ export declare function propsToStyle(styleProps?: IObject): IObject;
59
+ /**
60
+ * 将单个样式属性值转换为带单位的 CSS 字符串
61
+ *
62
+ * @param prop - 属性名
63
+ * @param value - 属性值
64
+ * @returns 转换后的样式值字符串
65
+ */
66
+ export declare function makeStyleProp(prop: string, value: string): string;
67
+ /**
68
+ * 对齐方式到 Flex 对齐值的映射
69
+ */
70
+ export declare const ALIGN_TO_FLEX_MAP: Record<string, string>;
71
+ /**
72
+ * 将对齐属性值转换为 Flex 对齐值
73
+ *
74
+ * @param align - 对齐方式(left、center、right、justify)
75
+ * @returns 对应的 Flex 对齐值
76
+ */
77
+ export declare function transAlign2flex(align: string): string;
78
+ /**
79
+ * 生成位置和尺寸样式对象
80
+ *
81
+ * @param style - 样式配置对象
82
+ * @returns 位置和尺寸样式对象
83
+ */
84
+ export declare function generatePositionStyles(style: IObject): IObject;
85
+ /**
86
+ * 生成背景和间距样式对象
87
+ *
88
+ * @param style - 样式配置对象
89
+ * @returns 背景和间距样式对象
90
+ */
91
+ export declare function generateSpacingStyles(style: IObject): IObject;
92
+ /**
93
+ * 生成边框样式对象
94
+ *
95
+ * @param style - 样式配置对象
96
+ * @returns 边框样式对象
97
+ */
98
+ export declare function generateBorderStyles(style: IObject): IObject;
99
+ /**
100
+ * 生成完整的包装样式对象
101
+ * 合并位置、间距、边框等所有样式
102
+ *
103
+ * @param style - 样式配置对象
104
+ * @param ignoringStyle - 需要忽略的样式属性数组
105
+ * @returns 合并后的完整样式对象
106
+ */
107
+ export declare function generateWrapperStyle(style: IObject, ignoringStyle?: string[]): IObject;
108
+ export {};
@@ -0,0 +1,155 @@
1
+ import { isEmpty, pick, isNil } from 'lodash-es';
2
+
3
+ function pxToVw(pxValue) {
4
+ return pxValue + "px";
5
+ }
6
+ function addPxUnit(value) {
7
+ return isEmpty(value) ? "" : `${value}px !important`;
8
+ }
9
+ function addImportant(value) {
10
+ return isEmpty(value) ? "" : `${value} !important`;
11
+ }
12
+ function formatBorder(border) {
13
+ if (!border || isEmpty(border.borderWidth)) return "";
14
+ return `${border.borderWidth}px ${border.borderStyle || "solid"} ${border.borderColor || "transparent"} !important`;
15
+ }
16
+ const DEFAULT_FONT_CONFIG = {
17
+ fontAttrs: [
18
+ "fontWeight",
19
+ "fontSize",
20
+ "color",
21
+ "textDecorationLine",
22
+ "textAlign"
23
+ ],
24
+ mapAttrs: {
25
+ bold: {
26
+ attr: "fontWeight",
27
+ callback: (value) => {
28
+ return value ? 700 : 400;
29
+ }
30
+ },
31
+ italic: {
32
+ attr: "fontStyle",
33
+ callback: (value) => {
34
+ return value ? "italic" : "normal";
35
+ }
36
+ },
37
+ textDecoration: {
38
+ attr: "textDecorationLine"
39
+ },
40
+ fontSize: {
41
+ attr: "fontSize",
42
+ callback: (value) => {
43
+ return value ? pxToVw(value) : "";
44
+ }
45
+ },
46
+ align: {
47
+ attr: "textAlign"
48
+ }
49
+ }
50
+ };
51
+ function extractFontStyle(font, config = DEFAULT_FONT_CONFIG) {
52
+ if (!font) return {};
53
+ const result = {};
54
+ Object.assign(result, pick(font, config.fontAttrs));
55
+ if (typeof config.mapAttrs === "object") {
56
+ Object.keys(config.mapAttrs).forEach((k) => {
57
+ const { attr, callback } = config.mapAttrs[k];
58
+ result[attr] = typeof callback === "function" ? callback(font[k]) : font[k];
59
+ });
60
+ }
61
+ return result;
62
+ }
63
+ function propsToStyle(styleProps = {}) {
64
+ const wStyle = {};
65
+ for (const prop in styleProps) {
66
+ wStyle[prop] = makeStyleProp(prop, styleProps[prop]);
67
+ }
68
+ return wStyle;
69
+ }
70
+ const NOT_NEED_PX_STYLE = [
71
+ "opacity",
72
+ "zIndex",
73
+ "fontWeight",
74
+ "lineHeight",
75
+ "letterSpacing",
76
+ "wordSpacing",
77
+ "textAlign",
78
+ "textDecoration",
79
+ "textTransform",
80
+ "fontStyle",
81
+ "textDecorationLine"
82
+ ];
83
+ function makeStyleProp(prop, value) {
84
+ if (isNil(value) || isEmpty(value)) {
85
+ return "";
86
+ }
87
+ if (NOT_NEED_PX_STYLE.includes(prop)) {
88
+ return value + " !important";
89
+ }
90
+ return value + "px !important";
91
+ }
92
+ const ALIGN_TO_FLEX_MAP = {
93
+ left: "flex-start",
94
+ center: "center",
95
+ right: "flex-end",
96
+ justify: "space-between"
97
+ };
98
+ function transAlign2flex(align) {
99
+ return ALIGN_TO_FLEX_MAP[align] || align;
100
+ }
101
+ function generatePositionStyles(style) {
102
+ return {
103
+ position: addImportant(style.position),
104
+ top: addPxUnit(style.top),
105
+ left: addPxUnit(style.left),
106
+ right: addPxUnit(style.right),
107
+ bottom: addPxUnit(style.bottom),
108
+ width: addPxUnit(style.width),
109
+ height: addPxUnit(style.height)
110
+ };
111
+ }
112
+ function generateSpacingStyles(style) {
113
+ return {
114
+ backgroundColor: addImportant(style.backgroundColor),
115
+ marginTop: addPxUnit(style.marginTop),
116
+ marginRight: addPxUnit(style.marginRight),
117
+ marginBottom: addPxUnit(style.marginBottom),
118
+ marginLeft: addPxUnit(style.marginLeft),
119
+ paddingTop: addPxUnit(style.paddingTop),
120
+ paddingRight: addPxUnit(style.paddingRight),
121
+ paddingBottom: addPxUnit(style.paddingBottom),
122
+ paddingLeft: addPxUnit(style.paddingLeft)
123
+ };
124
+ }
125
+ function generateBorderStyles(style) {
126
+ return {
127
+ borderLeft: formatBorder(style.borderLeft),
128
+ borderRight: formatBorder(style.borderRight),
129
+ borderBottom: formatBorder(style.borderBottom),
130
+ borderTop: formatBorder(style.borderTop),
131
+ borderTopRightRadius: addPxUnit(style.borderTopRightRadius),
132
+ borderTopLeftRadius: addPxUnit(style.borderTopLeftRadius),
133
+ borderBottomRightRadius: addPxUnit(style.borderBottomRightRadius),
134
+ borderBottomLeftRadius: addPxUnit(style.borderBottomLeftRadius)
135
+ };
136
+ }
137
+ function generateWrapperStyle(style, ignoringStyle = []) {
138
+ const styleData = {
139
+ ...generatePositionStyles(style),
140
+ ...generateSpacingStyles(style),
141
+ ...generateBorderStyles(style)
142
+ };
143
+ ignoringStyle.forEach((key) => {
144
+ delete styleData[key];
145
+ });
146
+ Object.keys(styleData).forEach((key) => {
147
+ const val = styleData[key];
148
+ if (isNil(val) || isEmpty(val)) {
149
+ delete styleData[key];
150
+ }
151
+ });
152
+ return styleData;
153
+ }
154
+
155
+ export { ALIGN_TO_FLEX_MAP, addImportant, addPxUnit, extractFontStyle, formatBorder, generateBorderStyles, generatePositionStyles, generateSpacingStyles, generateWrapperStyle, makeStyleProp, propsToStyle, pxToVw, transAlign2flex };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/schema",
3
- "version": "0.1.4-dev.7",
3
+ "version": "0.1.4-dev.8",
4
4
  "type": "module",
5
5
  "description": "paas 平台 schema 架构包",
6
6
  "main": "dist/index.min.cjs",
@@ -51,12 +51,13 @@
51
51
  "gen-api:platform": "gct-paas gen-api --url=http://paas.paasdev.gct-paas.com --tag=platform -t ../cli/hbs-temp -o ./src/service/gct-platform && prettier './src/service/gct-platform' --write"
52
52
  },
53
53
  "dependencies": {
54
- "@gct-paas/api": "0.1.0-dev.6",
55
- "@gct-paas/core": "workspace:*",
54
+ "@gct-paas/api": "0.1.0-dev.8",
55
+ "@gct-paas/core": "0.1.4-dev.8",
56
56
  "vue": "^3.5.28"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@gct-paas/build": "^0.1.5-dev.6",
60
60
  "vitest": "^4.0.18"
61
- }
61
+ },
62
+ "gitHead": "bf7f4f9672c3906ec834e6d58b999ce78f7cad08"
62
63
  }