sun-card-design 1.2.0 → 1.2.1

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/README.md CHANGED
@@ -74,10 +74,10 @@ import { PcPanel, MobilePanel } from 'sun-card-design'
74
74
  <template>
75
75
  <div class="container">
76
76
  <div class="pc-wrap">
77
- <PcPanel :record="record" />
77
+ <PcPanel :config="toolConfig" :record="record" @clickEvent="handleClickEvent" />
78
78
  </div>
79
79
  <div class="mb-wrap">
80
- <MobilePanel :record="record" />
80
+ <MobilePanel :config="toolConfig" :record="record" @clickEvent="handleClickEvent" />
81
81
  </div>
82
82
  </div>
83
83
  </template>
@@ -94,6 +94,24 @@ const record = ref({
94
94
  borderRadius: 12
95
95
  }
96
96
  })
97
+ const toolConfig = ref({
98
+ variableList: [
99
+ {
100
+ id: '1',
101
+ name: '字符串-Test1',
102
+ type: 'String',
103
+ },
104
+ {
105
+ id: '2',
106
+ name: '数组-Test1',
107
+ type: 'Array',
108
+ }
109
+ ]
110
+ })
111
+
112
+ const handleClickEvent = (record) => {
113
+ console.error(record)
114
+ }
97
115
  </script>
98
116
  ```
99
117
 
@@ -1,4 +1,4 @@
1
- import { resolveComponent, createElementBlock, openBlock, normalizeStyle, createVNode, withCtx, unref } from "vue";
1
+ import { ref, resolveComponent, createElementBlock, openBlock, normalizeStyle, createVNode, withCtx, unref } from "vue";
2
2
  import { renderTextByVariables } from "./sun-card-design-mobile.es26.js";
3
3
  /* empty css */
4
4
  import _export_sfc from "./sun-card-design-mobile.es28.js";
@@ -7,6 +7,7 @@ const _sfc_main = {
7
7
  props: ["record"],
8
8
  setup(__props) {
9
9
  const props = __props;
10
+ const value = ref(props.record.options?.defaultValue || null);
10
11
  return (_ctx, _cache) => {
11
12
  const _component_a_select = resolveComponent("a-select");
12
13
  const _component_a_form_item = resolveComponent("a-form-item");
@@ -24,8 +25,8 @@ const _sfc_main = {
24
25
  }, {
25
26
  default: withCtx(() => [
26
27
  createVNode(_component_a_select, {
27
- value: _ctx.value,
28
- "onUpdate:value": _cache[0] || (_cache[0] = ($event) => _ctx.value = $event),
28
+ value: value.value,
29
+ "onUpdate:value": _cache[0] || (_cache[0] = ($event) => value.value = $event),
29
30
  options: [],
30
31
  style: { "width": "100%" },
31
32
  placeholder: props.record.options.placeholder
@@ -40,7 +41,7 @@ const _sfc_main = {
40
41
  };
41
42
  }
42
43
  };
43
- const EnterpriseSearch = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-d616ad69"]]);
44
+ const EnterpriseSearch = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c4da076f"]]);
44
45
  export {
45
46
  EnterpriseSearch as default
46
47
  };
@@ -1,8 +1,9 @@
1
- import { resolveComponent, createElementBlock, openBlock, normalizeStyle, createVNode, withCtx, Fragment, renderList, createBlock, createElementVNode, normalizeClass } from "vue";
1
+ import { ref, computed, watch, resolveComponent, createElementBlock, openBlock, normalizeStyle, createElementVNode, createVNode, withCtx, TransitionGroup, Fragment, renderList, createBlock, Transition, createCommentVNode } from "vue";
2
2
  import FormItem from "./sun-card-design-mobile.es25.js";
3
3
  /* empty css */
4
4
  import _export_sfc from "./sun-card-design-mobile.es28.js";
5
- const _hoisted_1 = ["onClick"];
5
+ const _hoisted_1 = { class: "expand-list-container" };
6
+ const _hoisted_2 = ["onClick"];
6
7
  const _sfc_main = {
7
8
  __name: "multipleLine",
8
9
  props: ["record", "recordData", "columnsIndex"],
@@ -10,6 +11,42 @@ const _sfc_main = {
10
11
  setup(__props, { emit: __emit }) {
11
12
  const props = __props;
12
13
  const emit = __emit;
14
+ const currentDisplayCount = ref(0);
15
+ const collapse = computed(() => props.record.options?.style?.collapse ?? false);
16
+ const collapseLine = computed(() => props.record.options?.style?.collapseLine ?? 2);
17
+ const expandType = computed(() => props.record.options?.style?.expandType || "noRepeat");
18
+ const expandLine = computed(() => props.record.options?.style?.expandLine ?? 2);
19
+ const totalColumns = computed(() => props.record.columns?.length || 0);
20
+ watch([collapse, collapseLine, totalColumns], () => {
21
+ if (collapse.value) {
22
+ currentDisplayCount.value = Math.min(collapseLine.value, totalColumns.value);
23
+ } else {
24
+ currentDisplayCount.value = totalColumns.value;
25
+ }
26
+ if (currentDisplayCount.value > totalColumns.value) {
27
+ currentDisplayCount.value = totalColumns.value;
28
+ }
29
+ }, { immediate: true });
30
+ const displayedColumns = computed(() => {
31
+ if (!collapse.value) {
32
+ return props.record.columns || [];
33
+ }
34
+ return (props.record.columns || []).slice(0, currentDisplayCount.value);
35
+ });
36
+ const showExpandMore = computed(() => {
37
+ if (!collapse.value) return false;
38
+ return currentDisplayCount.value < totalColumns.value;
39
+ });
40
+ const handleExpandMore = () => {
41
+ if (expandType.value === "noRepeat") {
42
+ currentDisplayCount.value = totalColumns.value;
43
+ } else if (expandType.value === "repeat") {
44
+ currentDisplayCount.value = Math.min(
45
+ currentDisplayCount.value + expandLine.value,
46
+ totalColumns.value
47
+ );
48
+ }
49
+ };
13
50
  const getIndex = (index) => {
14
51
  if (index !== void 0) {
15
52
  return index;
@@ -26,73 +63,100 @@ const _sfc_main = {
26
63
  if (!record.options.clickEvent) return;
27
64
  emit("clickColumnsEvent", record);
28
65
  };
29
- const getBackground = () => {
66
+ function isGradientColor(color) {
67
+ return /^(linear|radial)-gradient\(.*\)$/.test(color);
68
+ }
69
+ const getBackground = computed(() => {
70
+ if (!props.recordData?.config?.background) {
71
+ return "transparent";
72
+ }
30
73
  if (isGradientColor(props.recordData.config.background)) {
31
74
  return "none";
32
75
  }
33
76
  return props.recordData.config.background;
34
- };
35
- function isGradientColor(color) {
36
- return /^(linear|radial)-gradient\(.*\)$/.test(color);
37
- }
77
+ });
38
78
  return (_ctx, _cache) => {
39
79
  const _component_a_col = resolveComponent("a-col");
40
80
  const _component_a_row = resolveComponent("a-row");
41
81
  return openBlock(), createElementBlock("div", {
42
82
  class: "main-grid",
43
- style: normalizeStyle({ background: getBackground() })
83
+ style: normalizeStyle({ background: getBackground.value })
44
84
  }, [
45
- createVNode(_component_a_row, {
46
- gutter: [props.record.options.style.lrGutter, props.record.options.style.tbGutter]
47
- }, {
48
- default: withCtx(() => [
49
- (openBlock(true), createElementBlock(Fragment, null, renderList(props.record.columns, (item, index) => {
50
- return openBlock(), createBlock(_component_a_col, {
51
- key: index.toString(),
52
- flex: props.record.columns[index]?.flex,
53
- span: 24,
54
- style: normalizeStyle({
55
- flex: _ctx.none
56
- })
85
+ createElementVNode("div", _hoisted_1, [
86
+ createVNode(_component_a_row, {
87
+ gutter: [props.record.options.style.lrGutter, props.record.options.style.tbGutter]
88
+ }, {
89
+ default: withCtx(() => [
90
+ createVNode(TransitionGroup, {
91
+ name: "expand-list",
92
+ tag: "div",
93
+ class: "expand-list-group"
57
94
  }, {
58
95
  default: withCtx(() => [
59
- createElementVNode("div", {
60
- class: normalizeClass(["box", { active: _ctx.currentUuid === item.uuid }]),
61
- style: normalizeStyle({
62
- background: props.record.options.style?.background,
63
- border: props.record.options.style?.borderColor === "none" ? "none" : "1px solid " + (props.record.options.style?.borderColor || "transparent"),
64
- borderRadius: props.record.options.style?.borderRadius + "px",
65
- padding: props.record.options.style?.tbPadding + "px " + props.record.options.style?.lrPadding + "px",
66
- justifyContent: props.record.options.style?.alignItems || "start",
67
- minHeight: props.record.options.style?.minHeight + "px" || "48px",
68
- boxShadow: props.record.options.style?.boxShadow || null
69
- }),
70
- onClick: ($event) => onClickColumns(item)
71
- }, [
72
- (openBlock(true), createElementBlock(Fragment, null, renderList(item.list, (element, index2) => {
73
- return openBlock(), createBlock(FormItem, {
74
- record: element,
75
- key: index2,
76
- recordData: props.recordData,
77
- columnsIndex: getIndex(item.index),
78
- onClickEvent: onClick,
79
- onFileUpdateEvent: onUpdate,
80
- onClickColumnsEvent: onClickColumns
81
- }, null, 8, ["record", "recordData", "columnsIndex"]);
82
- }), 128))
83
- ], 14, _hoisted_1)
96
+ (openBlock(true), createElementBlock(Fragment, null, renderList(displayedColumns.value, (item, index) => {
97
+ return openBlock(), createBlock(_component_a_col, {
98
+ key: item.uuid || `col-${index}`,
99
+ flex: item.flex,
100
+ span: 24,
101
+ style: normalizeStyle({
102
+ flex: _ctx.none
103
+ }),
104
+ class: "expand-col-item"
105
+ }, {
106
+ default: withCtx(() => [
107
+ createElementVNode("div", {
108
+ class: "box",
109
+ style: normalizeStyle({
110
+ background: props.record.options.style?.background,
111
+ border: props.record.options.style?.borderColor === "none" ? "none" : "1px solid " + (props.record.options.style?.borderColor || "transparent"),
112
+ borderRadius: props.record.options.style?.borderRadius + "px",
113
+ padding: props.record.options.style?.tbPadding + "px " + props.record.options.style?.lrPadding + "px",
114
+ justifyContent: props.record.options.style?.alignItems || "start",
115
+ minHeight: props.record.options.style?.minHeight + "px" || "48px",
116
+ boxShadow: props.record.options.style?.boxShadow || null
117
+ }),
118
+ onClick: ($event) => onClickColumns(item)
119
+ }, [
120
+ (openBlock(true), createElementBlock(Fragment, null, renderList(item.list, (element, index2) => {
121
+ return openBlock(), createBlock(FormItem, {
122
+ record: element,
123
+ key: index2,
124
+ recordData: props.recordData,
125
+ columnsIndex: getIndex(item.index),
126
+ onClickEvent: onClick,
127
+ onFileUpdateEvent: onUpdate,
128
+ onClickColumnsEvent: onClickColumns
129
+ }, null, 8, ["record", "recordData", "columnsIndex"]);
130
+ }), 128))
131
+ ], 12, _hoisted_2)
132
+ ]),
133
+ _: 2
134
+ }, 1032, ["flex", "style"]);
135
+ }), 128))
84
136
  ]),
85
- _: 2
86
- }, 1032, ["flex", "style"]);
87
- }), 128))
137
+ _: 1
138
+ })
139
+ ]),
140
+ _: 1
141
+ }, 8, ["gutter"])
142
+ ]),
143
+ createVNode(Transition, { name: "fade" }, {
144
+ default: withCtx(() => [
145
+ showExpandMore.value ? (openBlock(), createElementBlock("div", {
146
+ key: 0,
147
+ class: "expand-more",
148
+ onClick: handleExpandMore
149
+ }, [..._cache[0] || (_cache[0] = [
150
+ createElementVNode("span", null, "展开更多", -1)
151
+ ])])) : createCommentVNode("", true)
88
152
  ]),
89
153
  _: 1
90
- }, 8, ["gutter"])
154
+ })
91
155
  ], 4);
92
156
  };
93
157
  }
94
158
  };
95
- const MultipleLine = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c1ba89a8"]]);
159
+ const MultipleLine = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-dad6f574"]]);
96
160
  export {
97
161
  MultipleLine as default
98
162
  };
@@ -1,8 +1,9 @@
1
- import { resolveComponent, createElementBlock, openBlock, normalizeStyle, createVNode, withCtx, Fragment, renderList, createBlock, createElementVNode, normalizeClass } from "vue";
1
+ import { ref, computed, watch, resolveComponent, createElementBlock, openBlock, normalizeStyle, createElementVNode, createVNode, withCtx, TransitionGroup, Fragment, renderList, createBlock, Transition, createCommentVNode } from "vue";
2
2
  import FormItem from "./sun-card-design-mobile.es25.js";
3
3
  /* empty css */
4
4
  import _export_sfc from "./sun-card-design-mobile.es28.js";
5
- const _hoisted_1 = ["onClick"];
5
+ const _hoisted_1 = { class: "expand-list-container" };
6
+ const _hoisted_2 = ["onClick"];
6
7
  const _sfc_main = {
7
8
  __name: "gridList",
8
9
  props: ["record", "recordData", "columnsIndex"],
@@ -10,6 +11,42 @@ const _sfc_main = {
10
11
  setup(__props, { emit: __emit }) {
11
12
  const props = __props;
12
13
  const emit = __emit;
14
+ const currentDisplayRows = ref(0);
15
+ const collapse = computed(() => props.record.options?.style?.collapse ?? false);
16
+ const collapseLine = computed(() => props.record.options?.style?.collapseLine ?? 2);
17
+ const expandType = computed(() => props.record.options?.style?.expandType || "noRepeat");
18
+ const expandLine = computed(() => props.record.options?.style?.expandLine ?? 2);
19
+ const totalColumns = computed(() => props.record.columns?.length || 0);
20
+ const autoNumber = computed(() => props.record.options?.autoNumber || 2);
21
+ const totalRows = computed(() => Math.ceil(totalColumns.value / autoNumber.value));
22
+ watch([collapse, collapseLine, totalRows], () => {
23
+ if (collapse.value) {
24
+ currentDisplayRows.value = Math.min(collapseLine.value, totalRows.value);
25
+ } else {
26
+ currentDisplayRows.value = totalRows.value;
27
+ }
28
+ }, { immediate: true });
29
+ const displayedColumns = computed(() => {
30
+ if (!collapse.value) {
31
+ return props.record.columns || [];
32
+ }
33
+ const displayCount = currentDisplayRows.value * autoNumber.value;
34
+ return (props.record.columns || []).slice(0, displayCount);
35
+ });
36
+ const showExpandMore = computed(() => {
37
+ if (!collapse.value) return false;
38
+ return currentDisplayRows.value < totalRows.value;
39
+ });
40
+ const handleExpandMore = () => {
41
+ if (expandType.value === "noRepeat") {
42
+ currentDisplayRows.value = totalRows.value;
43
+ } else if (expandType.value === "repeat") {
44
+ currentDisplayRows.value = Math.min(
45
+ currentDisplayRows.value + expandLine.value,
46
+ totalRows.value
47
+ );
48
+ }
49
+ };
13
50
  const getIndex = (index) => {
14
51
  if (index !== void 0) {
15
52
  return index;
@@ -26,73 +63,100 @@ const _sfc_main = {
26
63
  if (!record.options.clickEvent) return;
27
64
  emit("clickColumnsEvent", record);
28
65
  };
29
- const getBackground = () => {
66
+ function isGradientColor(color) {
67
+ return /^(linear|radial)-gradient\(.*\)$/.test(color);
68
+ }
69
+ const getBackground = computed(() => {
70
+ if (!props.recordData?.config?.background) {
71
+ return "transparent";
72
+ }
30
73
  if (isGradientColor(props.recordData.config.background)) {
31
74
  return "none";
32
75
  }
33
76
  return props.recordData.config.background;
34
- };
35
- function isGradientColor(color) {
36
- return /^(linear|radial)-gradient\(.*\)$/.test(color);
37
- }
77
+ });
38
78
  return (_ctx, _cache) => {
39
79
  const _component_a_col = resolveComponent("a-col");
40
80
  const _component_a_row = resolveComponent("a-row");
41
81
  return openBlock(), createElementBlock("div", {
42
82
  class: "main-grid",
43
- style: normalizeStyle({ background: getBackground() })
83
+ style: normalizeStyle({ background: getBackground.value })
44
84
  }, [
45
- createVNode(_component_a_row, {
46
- gutter: [props.record.options.style.lrGutter, props.record.options.style.tbGutter]
47
- }, {
48
- default: withCtx(() => [
49
- (openBlock(true), createElementBlock(Fragment, null, renderList(props.record.columns, (item, index) => {
50
- return openBlock(), createBlock(_component_a_col, {
51
- key: index.toString(),
52
- flex: props.record.columns[index]?.flex,
53
- span: 24 / props.record.options.autoNumber,
54
- style: normalizeStyle({
55
- flex: _ctx.none
56
- })
85
+ createElementVNode("div", _hoisted_1, [
86
+ createVNode(_component_a_row, {
87
+ gutter: [props.record.options.style.lrGutter, props.record.options.style.tbGutter]
88
+ }, {
89
+ default: withCtx(() => [
90
+ createVNode(TransitionGroup, {
91
+ name: "expand-list",
92
+ tag: "div",
93
+ class: "expand-list-group"
57
94
  }, {
58
95
  default: withCtx(() => [
59
- createElementVNode("div", {
60
- class: normalizeClass(["box", { active: _ctx.currentUuid === item.uuid }]),
61
- style: normalizeStyle({
62
- background: props.record.options.style?.background,
63
- border: props.record.options.style?.borderColor === "none" ? "none" : "1px solid " + (props.record.options.style?.borderColor || "transparent"),
64
- borderRadius: props.record.options.style?.borderRadius + "px",
65
- padding: props.record.options.style?.tbPadding + "px " + props.record.options.style?.lrPadding + "px",
66
- justifyContent: props.record.options.style?.alignItems || "start",
67
- minHeight: props.record.options.style?.minHeight + "px" || "48px",
68
- boxShadow: props.record.options.style?.boxShadow || null
69
- }),
70
- onClick: ($event) => onClickColumns(item)
71
- }, [
72
- (openBlock(true), createElementBlock(Fragment, null, renderList(item.list, (element, index2) => {
73
- return openBlock(), createBlock(FormItem, {
74
- record: element,
75
- key: index2,
76
- recordData: props.recordData,
77
- columnsIndex: getIndex(item.index),
78
- onClickEvent: onClick,
79
- onFileUpdateEvent: onUpdate,
80
- onClickColumnsEvent: onClickColumns
81
- }, null, 8, ["record", "recordData", "columnsIndex"]);
82
- }), 128))
83
- ], 14, _hoisted_1)
96
+ (openBlock(true), createElementBlock(Fragment, null, renderList(displayedColumns.value, (item, index) => {
97
+ return openBlock(), createBlock(_component_a_col, {
98
+ key: item.uuid || `col-${index}`,
99
+ flex: item.flex,
100
+ span: 24 / props.record.options.autoNumber,
101
+ style: normalizeStyle({
102
+ flex: _ctx.none
103
+ }),
104
+ class: "expand-col-item"
105
+ }, {
106
+ default: withCtx(() => [
107
+ createElementVNode("div", {
108
+ class: "box",
109
+ style: normalizeStyle({
110
+ background: props.record.options.style?.background,
111
+ border: props.record.options.style?.borderColor === "none" ? "none" : "1px solid " + (props.record.options.style?.borderColor || "transparent"),
112
+ borderRadius: props.record.options.style?.borderRadius + "px",
113
+ padding: props.record.options.style?.tbPadding + "px " + props.record.options.style?.lrPadding + "px",
114
+ justifyContent: props.record.options.style?.alignItems || "start",
115
+ minHeight: props.record.options.style?.minHeight + "px" || "48px",
116
+ boxShadow: props.record.options.style?.boxShadow || null
117
+ }),
118
+ onClick: ($event) => onClickColumns(item)
119
+ }, [
120
+ (openBlock(true), createElementBlock(Fragment, null, renderList(item.list, (element, index2) => {
121
+ return openBlock(), createBlock(FormItem, {
122
+ record: element,
123
+ key: index2,
124
+ recordData: props.recordData,
125
+ columnsIndex: getIndex(item.index),
126
+ onClickEvent: onClick,
127
+ onFileUpdateEvent: onUpdate,
128
+ onClickColumnsEvent: onClickColumns
129
+ }, null, 8, ["record", "recordData", "columnsIndex"]);
130
+ }), 128))
131
+ ], 12, _hoisted_2)
132
+ ]),
133
+ _: 2
134
+ }, 1032, ["flex", "span", "style"]);
135
+ }), 128))
84
136
  ]),
85
- _: 2
86
- }, 1032, ["flex", "span", "style"]);
87
- }), 128))
137
+ _: 1
138
+ })
139
+ ]),
140
+ _: 1
141
+ }, 8, ["gutter"])
142
+ ]),
143
+ createVNode(Transition, { name: "fade" }, {
144
+ default: withCtx(() => [
145
+ showExpandMore.value ? (openBlock(), createElementBlock("div", {
146
+ key: 0,
147
+ class: "expand-more",
148
+ onClick: handleExpandMore
149
+ }, [..._cache[0] || (_cache[0] = [
150
+ createElementVNode("span", null, "展开更多", -1)
151
+ ])])) : createCommentVNode("", true)
88
152
  ]),
89
153
  _: 1
90
- }, 8, ["gutter"])
154
+ })
91
155
  ], 4);
92
156
  };
93
157
  }
94
158
  };
95
- const GridList = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c6c62c4f"]]);
159
+ const GridList = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-159c873b"]]);
96
160
  export {
97
161
  GridList as default
98
162
  };