@easy-editor/materials-dashboard-text 0.0.9 → 0.0.11

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.
package/dist/index.esm.js CHANGED
@@ -1,59 +1,160 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
 
3
+ function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
4
+
5
+ function cn(...inputs) {
6
+ return clsx(inputs);
7
+ }
8
+
3
9
  const MaterialGroup = {
4
10
  BASIC: 'basic'};
5
11
 
6
- const COMPONENT_NAME = 'EasyEditorMaterialsText';
7
- const PACKAGE_NAME = '@easy-editor/materials-dashboard-text';
12
+ function styleInject(css, ref) {
13
+ if (ref === void 0) ref = {};
14
+ var insertAt = ref.insertAt;
15
+ if (typeof document === 'undefined') {
16
+ return;
17
+ }
18
+ var head = document.head || document.getElementsByTagName('head')[0];
19
+ var style = document.createElement('style');
20
+ style.type = 'text/css';
21
+ if (insertAt === 'top') {
22
+ if (head.firstChild) {
23
+ head.insertBefore(style, head.firstChild);
24
+ } else {
25
+ head.appendChild(style);
26
+ }
27
+ } else {
28
+ head.appendChild(style);
29
+ }
30
+ if (style.styleSheet) {
31
+ style.styleSheet.cssText = css;
32
+ } else {
33
+ style.appendChild(document.createTextNode(css));
34
+ }
35
+ }
8
36
 
9
- const Text = props => {
10
- const {
11
- ref,
12
- text = 'Text',
13
- fontSize = 14,
14
- color = '#ffffff',
15
- fontWeight = 'normal',
16
- textAlign = 'left',
17
- lineHeight = 1.5,
18
- className = '',
19
- style: externalStyle
20
- } = props;
21
- const internalStyle = {
22
- width: '100%',
23
- height: '100%',
24
- fontSize: typeof fontSize === 'number' ? `${fontSize}px` : fontSize,
25
- color,
37
+ var css_248z = ".component-module__container___VbZSk{display:flex;height:100%;width:100%}.component-module__text___nFUOn{display:inline-block;word-break:break-word}.component-module__link___20asF{cursor:pointer;text-decoration:none;transition:opacity .2s ease}.component-module__link___20asF:hover{opacity:.8}.component-module__underline___0oAJz{text-decoration:underline}.component-module__alignLeft___IOvpO{justify-content:flex-start;text-align:left}.component-module__alignCenter___EIwIC{justify-content:center;text-align:center}.component-module__alignRight___p3ReL{justify-content:flex-end;text-align:right}.component-module__valignTop___-5DmK{align-items:flex-start}.component-module__valignMiddle___i0are{align-items:center}.component-module__valignBottom___97zzw{align-items:flex-end}";
38
+ var styles = {"container":"component-module__container___VbZSk","text":"component-module__text___nFUOn","link":"component-module__link___20asF","underline":"component-module__underline___0oAJz","alignLeft":"component-module__alignLeft___IOvpO","alignCenter":"component-module__alignCenter___EIwIC","alignRight":"component-module__alignRight___p3ReL","valignTop":"component-module__valignTop___-5DmK","valignMiddle":"component-module__valignMiddle___i0are","valignBottom":"component-module__valignBottom___97zzw"};
39
+ styleInject(css_248z);
40
+
41
+ /**
42
+ * Text Component
43
+ * 文本组件 - 支持普通文本、链接、标题、发光效果
44
+ */
45
+
46
+ const getAlignClass = align => {
47
+ switch (align) {
48
+ case 'left':
49
+ return styles.alignLeft;
50
+ case 'center':
51
+ return styles.alignCenter;
52
+ case 'right':
53
+ return styles.alignRight;
54
+ default:
55
+ return styles.alignLeft;
56
+ }
57
+ };
58
+ const getValignClass = align => {
59
+ switch (align) {
60
+ case 'top':
61
+ return styles.valignTop;
62
+ case 'middle':
63
+ return styles.valignMiddle;
64
+ case 'bottom':
65
+ return styles.valignBottom;
66
+ default:
67
+ return styles.valignMiddle;
68
+ }
69
+ };
70
+ const Text = ({
71
+ ref,
72
+ content = '文本内容',
73
+ fontSize = 16,
74
+ fontWeight = 'normal',
75
+ fontFamily = 'inherit',
76
+ color = '#ffffff',
77
+ textAlign = 'left',
78
+ verticalAlign = 'middle',
79
+ lineHeight = 1.5,
80
+ letterSpacing = 0,
81
+ isLink = false,
82
+ href = '',
83
+ target = '_blank',
84
+ underline = false,
85
+ glowEnable = false,
86
+ glowColor = '#00d4ff',
87
+ glowIntensity = 1,
88
+ style: externalStyle
89
+ }) => {
90
+ // 计算发光效果
91
+ const textShadow = glowEnable ? `0 0 ${10 * glowIntensity}px ${glowColor}, 0 0 ${20 * glowIntensity}px ${glowColor}, 0 0 ${30 * glowIntensity}px ${glowColor}` : undefined;
92
+ const textStyle = {
93
+ fontSize,
26
94
  fontWeight,
27
- textAlign,
95
+ fontFamily,
96
+ color,
28
97
  lineHeight,
29
- wordBreak: 'break-word',
30
- whiteSpace: 'pre-wrap'
31
- };
32
- const mergedStyle = {
33
- ...internalStyle,
34
- ...externalStyle
98
+ letterSpacing,
99
+ textShadow
35
100
  };
101
+ const containerClass = cn(styles.container, getAlignClass(textAlign), getValignClass(verticalAlign));
102
+ const textClass = cn(styles.text, isLink && styles.link, underline && styles.underline);
103
+
104
+ // 链接模式
105
+ if (isLink && href) {
106
+ const relValue = target === '_blank' ? 'noopener noreferrer' : '';
107
+ return /*#__PURE__*/jsx("div", {
108
+ className: containerClass,
109
+ ref: ref,
110
+ style: externalStyle,
111
+ children: /*#__PURE__*/jsx("a", {
112
+ className: textClass,
113
+ href: href,
114
+ rel: relValue,
115
+ style: textStyle,
116
+ target: target,
117
+ children: content
118
+ })
119
+ });
120
+ }
121
+
122
+ // 普通文本
36
123
  return /*#__PURE__*/jsx("div", {
37
- className: className,
124
+ className: containerClass,
38
125
  ref: ref,
39
- style: mergedStyle,
40
- children: text
126
+ style: externalStyle,
127
+ children: /*#__PURE__*/jsx("span", {
128
+ className: textClass,
129
+ style: textStyle,
130
+ children: content
131
+ })
41
132
  });
42
133
  };
43
134
 
44
135
  const configure = {
45
136
  props: [{
46
137
  type: 'group',
47
- title: '功能',
138
+ title: '属性',
48
139
  setter: 'TabSetter',
49
140
  items: [{
50
141
  type: 'group',
51
- key: 'basic',
52
- title: '基本',
53
- items: [{
142
+ key: 'config',
143
+ title: '配置',
144
+ setter: {
145
+ componentName: 'CollapseSetter',
146
+ props: {
147
+ icon: false
148
+ }
149
+ },
150
+ items: [
151
+ {
54
152
  name: 'id',
55
153
  title: 'ID',
56
- setter: 'NodeIdSetter'
154
+ setter: 'NodeIdSetter',
155
+ extraProps: {
156
+ label: false
157
+ }
57
158
  }, {
58
159
  name: 'title',
59
160
  title: '标题',
@@ -88,13 +189,56 @@ const configure = {
88
189
  }
89
190
  }
90
191
  }]
91
- }, {
92
- name: 'text',
93
- title: '文本内容',
94
- setter: 'StringSetter'
192
+ },
193
+ {
194
+ type: 'group',
195
+ title: '内容',
196
+ setter: {
197
+ componentName: 'CollapseSetter',
198
+ props: {
199
+ icon: false
200
+ }
201
+ },
202
+ items: [{
203
+ name: 'content',
204
+ title: '文本内容',
205
+ setter: 'TextAreaSetter',
206
+ extraProps: {
207
+ defaultValue: '文本内容'
208
+ }
209
+ }, {
210
+ name: 'isLink',
211
+ title: '作为链接',
212
+ setter: 'SwitchSetter',
213
+ extraProps: {
214
+ defaultValue: false
215
+ }
216
+ }, {
217
+ name: 'href',
218
+ title: '链接地址',
219
+ setter: 'StringSetter'
220
+ }, {
221
+ name: 'target',
222
+ title: '打开方式',
223
+ setter: {
224
+ componentName: 'SelectSetter',
225
+ props: {
226
+ options: [{
227
+ label: '新窗口',
228
+ value: '_blank'
229
+ }, {
230
+ label: '当前窗口',
231
+ value: '_self'
232
+ }]
233
+ }
234
+ },
235
+ extraProps: {
236
+ defaultValue: '_blank'
237
+ }
238
+ }]
95
239
  }, {
96
240
  type: 'group',
97
- title: '字体样式',
241
+ title: '字体',
98
242
  setter: {
99
243
  componentName: 'CollapseSetter',
100
244
  props: {
@@ -106,14 +250,7 @@ const configure = {
106
250
  title: '字体大小',
107
251
  setter: 'NumberSetter',
108
252
  extraProps: {
109
- defaultValue: 14
110
- }
111
- }, {
112
- name: 'color',
113
- title: '文字颜色',
114
- setter: 'ColorSetter',
115
- extraProps: {
116
- defaultValue: '#000000'
253
+ defaultValue: 16
117
254
  }
118
255
  }, {
119
256
  name: 'fontWeight',
@@ -127,39 +264,19 @@ const configure = {
127
264
  }, {
128
265
  label: '粗体',
129
266
  value: 'bold'
130
- }, {
131
- label: '100',
132
- value: '100'
133
- }, {
134
- label: '200',
135
- value: '200'
136
- }, {
137
- label: '300',
138
- value: '300'
139
- }, {
140
- label: '400',
141
- value: '400'
142
- }, {
143
- label: '500',
144
- value: '500'
145
- }, {
146
- label: '600',
147
- value: '600'
148
- }, {
149
- label: '700',
150
- value: '700'
151
- }, {
152
- label: '800',
153
- value: '800'
154
- }, {
155
- label: '900',
156
- value: '900'
157
267
  }]
158
268
  }
159
269
  },
160
270
  extraProps: {
161
271
  defaultValue: 'normal'
162
272
  }
273
+ }, {
274
+ name: 'color',
275
+ title: '颜色',
276
+ setter: 'ColorSetter',
277
+ extraProps: {
278
+ defaultValue: '#ffffff'
279
+ }
163
280
  }, {
164
281
  name: 'lineHeight',
165
282
  title: '行高',
@@ -167,39 +284,62 @@ const configure = {
167
284
  extraProps: {
168
285
  defaultValue: 1.5
169
286
  }
170
- }, {
287
+ }]
288
+ }, {
289
+ type: 'group',
290
+ title: '对齐',
291
+ setter: {
292
+ componentName: 'CollapseSetter',
293
+ props: {
294
+ icon: false
295
+ }
296
+ },
297
+ items: [{
171
298
  name: 'textAlign',
172
- title: '文本对齐',
299
+ title: '水平对齐',
173
300
  setter: {
174
- componentName: 'RadioGroupSetter',
301
+ componentName: 'SegmentedSetter',
175
302
  props: {
176
303
  options: [{
177
- label: '左对齐',
304
+ label: '',
178
305
  value: 'left'
179
306
  }, {
180
- label: '居中',
307
+ label: '',
181
308
  value: 'center'
182
309
  }, {
183
- label: '右对齐',
310
+ label: '',
184
311
  value: 'right'
185
- }, {
186
- label: '两端对齐',
187
- value: 'justify'
188
312
  }]
189
313
  }
190
314
  },
191
315
  extraProps: {
192
316
  defaultValue: 'left'
193
317
  }
318
+ }, {
319
+ name: 'verticalAlign',
320
+ title: '垂直对齐',
321
+ setter: {
322
+ componentName: 'SegmentedSetter',
323
+ props: {
324
+ options: [{
325
+ label: '上',
326
+ value: 'top'
327
+ }, {
328
+ label: '中',
329
+ value: 'middle'
330
+ }, {
331
+ label: '下',
332
+ value: 'bottom'
333
+ }]
334
+ }
335
+ },
336
+ extraProps: {
337
+ defaultValue: 'middle'
338
+ }
194
339
  }]
195
- }]
196
- }, {
197
- type: 'group',
198
- key: 'advanced',
199
- title: '高级',
200
- items: [{
340
+ }, {
201
341
  type: 'group',
202
- title: '高级设置',
342
+ title: '效果',
203
343
  setter: {
204
344
  componentName: 'CollapseSetter',
205
345
  props: {
@@ -207,38 +347,69 @@ const configure = {
207
347
  }
208
348
  },
209
349
  items: [{
210
- title: '显隐',
350
+ name: 'underline',
351
+ title: '下划线',
211
352
  setter: 'SwitchSetter',
212
353
  extraProps: {
213
- supportVariable: true,
214
- getValue(target) {
215
- return target.getExtraPropValue('condition');
216
- },
217
- setValue(target, value) {
218
- target.setExtraPropValue('condition', value);
219
- }
354
+ defaultValue: false
355
+ }
356
+ }, {
357
+ name: 'glowEnable',
358
+ title: '发光效果',
359
+ setter: 'SwitchSetter',
360
+ extraProps: {
361
+ defaultValue: false
362
+ }
363
+ }, {
364
+ name: 'glowColor',
365
+ title: '发光颜色',
366
+ setter: 'ColorSetter',
367
+ extraProps: {
368
+ defaultValue: '#00d4ff'
220
369
  }
221
370
  }]
222
371
  }]
372
+ }, {
373
+ type: 'group',
374
+ key: 'data',
375
+ title: '数据',
376
+ items: [{
377
+ name: 'dataBinding',
378
+ title: '数据绑定',
379
+ setter: 'DataBindingSetter'
380
+ }]
381
+ }, {
382
+ type: 'group',
383
+ key: 'advanced',
384
+ title: '高级',
385
+ items: [{
386
+ name: 'condition',
387
+ title: '显隐控制',
388
+ setter: 'SwitchSetter',
389
+ extraProps: {
390
+ defaultValue: true,
391
+ supportVariable: true
392
+ }
393
+ }]
223
394
  }]
224
395
  }],
225
396
  component: {},
226
397
  supports: {},
227
- advanced: {
228
- view: Text
229
- }
398
+ advanced: {}
230
399
  };
231
400
 
401
+ const COMPONENT_NAME = 'EasyEditorMaterialsText';
402
+ const PACKAGE_NAME = '@easy-editor/materials-dashboard-text';
403
+
232
404
  const snippets = [{
233
- title: 'Text',
234
- screenshot: 'https://img.alicdn.com/imgextra/i3/O1CN01n5wpxc1bi862KuXFz_!!6000000003498-55-tps-50-50.svg',
405
+ title: '普通文本',
406
+ screenshot: '',
235
407
  schema: {
236
408
  componentName: COMPONENT_NAME,
237
409
  props: {
238
- text: 'Text Text Text',
239
- fontSize: 14,
240
- color: '#ffffff',
241
- textAlign: 'left'
410
+ content: '这是一段普通文本',
411
+ fontSize: 16,
412
+ color: '#ffffff'
242
413
  },
243
414
  $dashboard: {
244
415
  rect: {
@@ -248,39 +419,87 @@ const snippets = [{
248
419
  }
249
420
  }
250
421
  }, {
251
- title: 'Heading',
252
- screenshot: 'https://img.alicdn.com/imgextra/i3/O1CN01n5wpxc1bi862KuXFz_!!6000000003498-55-tps-50-50.svg',
422
+ title: '标题文本',
423
+ screenshot: '',
253
424
  schema: {
254
425
  componentName: COMPONENT_NAME,
255
426
  props: {
256
- text: 'Heading',
257
- fontSize: 24,
258
- color: '#ffffff',
427
+ content: '标题文本',
428
+ fontSize: 32,
259
429
  fontWeight: 'bold',
430
+ color: '#ffffff',
260
431
  textAlign: 'center'
261
432
  },
262
433
  $dashboard: {
263
434
  rect: {
264
435
  width: 200,
265
- height: 50
436
+ height: 60
437
+ }
438
+ }
439
+ }
440
+ }, {
441
+ title: '发光标题',
442
+ screenshot: '',
443
+ schema: {
444
+ componentName: COMPONENT_NAME,
445
+ props: {
446
+ content: '发光标题',
447
+ fontSize: 36,
448
+ fontWeight: 'bold',
449
+ color: '#00d4ff',
450
+ textAlign: 'center',
451
+ glowEnable: true,
452
+ glowColor: '#00d4ff',
453
+ glowIntensity: 1.5
454
+ },
455
+ $dashboard: {
456
+ rect: {
457
+ width: 240,
458
+ height: 80
459
+ }
460
+ }
461
+ }
462
+ }, {
463
+ title: '链接文本',
464
+ screenshot: '',
465
+ schema: {
466
+ componentName: COMPONENT_NAME,
467
+ props: {
468
+ content: '点击跳转',
469
+ fontSize: 16,
470
+ color: '#00d4ff',
471
+ isLink: true,
472
+ href: 'https://easy-editor-docs.vercel.app/',
473
+ target: '_blank',
474
+ underline: true
475
+ },
476
+ $dashboard: {
477
+ rect: {
478
+ width: 120,
479
+ height: 40
266
480
  }
267
481
  }
268
482
  }
269
483
  }];
270
484
 
485
+ var version = "0.0.10";
486
+ var pkg = {
487
+ version: version};
488
+
271
489
  const meta = {
272
490
  componentName: COMPONENT_NAME,
273
- title: 'Text',
491
+ title: '文本',
492
+ category: 'dashboard',
274
493
  group: MaterialGroup.BASIC,
275
494
  devMode: 'proCode',
276
495
  npm: {
277
496
  package: PACKAGE_NAME,
278
- version: 'latest',
497
+ version: pkg.version,
279
498
  globalName: COMPONENT_NAME,
280
499
  componentName: COMPONENT_NAME
281
500
  },
282
- snippets,
283
- configure
501
+ configure,
502
+ snippets
284
503
  };
285
504
 
286
505
  export { Text as component, meta };