@gct-paas/core-web 0.1.4-dev.6 → 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.
Files changed (183) hide show
  1. package/dist/index.esm.min.mjs +24964 -0
  2. package/dist/index.min.cjs +59 -12
  3. package/dist/index.min.css +1 -0
  4. package/dist/index.system.min.js +59 -12
  5. package/es/components/assets-svg-icon/assets-svg-icon.css +188 -0
  6. package/es/components/assets-svg-icon/assets-svg-icon.d.ts +134 -0
  7. package/es/components/assets-svg-icon/assets-svg-icon.mjs +238 -0
  8. package/es/components/assets-svg-icon/request.d.ts +2 -0
  9. package/es/components/assets-svg-icon/request.mjs +51 -0
  10. package/es/components/assets-svg-icon/utils.d.ts +9 -0
  11. package/es/components/assets-svg-icon/utils.mjs +21 -0
  12. package/es/components/assets-svg-icon/validate.d.ts +4 -0
  13. package/es/components/assets-svg-icon/validate.mjs +43 -0
  14. package/es/components/code-editor/code-editor.css +67 -0
  15. package/es/components/code-editor/code-editor.d.ts +35 -0
  16. package/es/components/code-editor/code-editor.mjs +15 -20
  17. package/es/components/index.d.ts +1 -0
  18. package/es/components/layout/flex-container/flex-container.css +67 -0
  19. package/es/components/layout/flex-container/flex-container.d.ts +4 -4
  20. package/es/components/layout/flex-item/flex-item.d.ts +4 -4
  21. package/es/components/layout/grid-container/grid-container.d.ts +4 -4
  22. package/es/components/layout/view-container/view-container.css +83 -0
  23. package/es/components/layout/view-container/view-container.d.ts +4 -4
  24. package/es/editor/gct-form-check-switch/gct-form-check-switch.d.ts +7 -7
  25. package/es/editor/gct-form-checkbox/gct-form-checkbox.d.ts +6 -6
  26. package/es/editor/gct-form-field-select/gct-form-field-select.d.ts +17 -7
  27. package/es/editor/gct-form-field-select/gct-model-select.vue.d.ts +3 -12
  28. package/es/editor/gct-form-i18n/gct-form-i18n.d.ts +8 -8
  29. package/es/editor/gct-form-icon-select/gct-form-icon-select.d.ts +8 -8
  30. package/es/editor/gct-form-info/gct-form-info.d.ts +7 -7
  31. package/es/editor/gct-form-length-unit/gct-form-length-unit.d.ts +6 -6
  32. package/es/editor/gct-form-modal-select/gct-form-modal-select.d.ts +8 -8
  33. package/es/editor/gct-form-number/gct-form-number.d.ts +7 -7
  34. package/es/editor/gct-form-picker/gct-form-picker.d.ts +8 -8
  35. package/es/editor/gct-form-radio/gct-form-radio.d.ts +7 -7
  36. package/es/editor/gct-form-select/gct-form-select.d.ts +7 -7
  37. package/es/editor/gct-form-span/gct-form-span.d.ts +5 -5
  38. package/es/editor/gct-form-switch/gct-form-switch.d.ts +6 -6
  39. package/es/editor/gct-form-text/gct-form-text.d.ts +7 -7
  40. package/es/editor/gct-form-textarea/gct-form-textarea.d.ts +7 -7
  41. package/es/hooks/index.d.ts +2 -0
  42. package/es/hooks/useLocale.d.ts +4 -0
  43. package/es/hooks/useLocale.mjs +32 -0
  44. package/es/hooks/useTheme.d.ts +8 -0
  45. package/es/hooks/useTheme.mjs +20 -0
  46. package/es/index.d.ts +5 -6
  47. package/es/index.mjs +19 -24
  48. package/es/modules/gct-dnd/components/gct-dnd-container/gct-dnd-container.css +72 -0
  49. package/es/modules/gct-dnd/components/gct-dnd-container/gct-dnd-container.d.ts +37 -0
  50. package/es/modules/gct-dnd/components/gct-dnd-container/gct-dnd-container.mjs +195 -0
  51. package/es/modules/gct-dnd/components/gct-dnd-drop-line/gct-dnd-drop-line.css +79 -0
  52. package/es/modules/gct-dnd/components/gct-dnd-drop-line/gct-dnd-drop-line.d.ts +29 -0
  53. package/es/modules/gct-dnd/components/gct-dnd-drop-line/gct-dnd-drop-line.mjs +98 -0
  54. package/es/modules/gct-dnd/components/gct-dnd-item/gct-dnd-item.css +70 -0
  55. package/es/modules/gct-dnd/components/gct-dnd-item/gct-dnd-item.d.ts +50 -0
  56. package/es/modules/gct-dnd/components/gct-dnd-item/gct-dnd-item.mjs +239 -0
  57. package/es/modules/gct-dnd/constants/index.d.ts +24 -0
  58. package/es/modules/gct-dnd/constants/index.mjs +9 -0
  59. package/es/modules/gct-dnd/index.d.ts +5 -0
  60. package/es/modules/gct-dnd/interface/i-gct-dnd-config.d.ts +101 -0
  61. package/es/modules/gct-dnd/interface/i-gct-dnd-data.d.ts +14 -0
  62. package/es/modules/gct-dnd/interface/i-gct-dnd-render-item-options.d.ts +28 -0
  63. package/es/modules/gct-dnd/interface/i-gct-drag-collect.d.ts +24 -0
  64. package/es/modules/gct-dnd/interface/i-gct-drag-dnd-data.d.ts +51 -0
  65. package/es/modules/gct-dnd/interface/i-gct-drop-collect.d.ts +32 -0
  66. package/es/modules/gct-dnd/interface/i-gct-drop-result.d.ts +47 -0
  67. package/es/modules/gct-dnd/interface/index.d.ts +7 -0
  68. package/es/types/index.d.ts +1 -1
  69. package/es/utils/with-install.mjs +0 -1
  70. package/es/widgets/gct-edit-form/gct-edit-form.d.ts +9 -9
  71. package/es/widgets/gct-form/gct-form-collapse/gct-form-collapse.d.ts +6 -6
  72. package/es/widgets/gct-form/gct-form-collapse-pane/gct-form-collapse-pane.d.ts +4 -4
  73. package/es/widgets/gct-form/gct-form-group/gct-form-group.d.ts +5 -5
  74. package/es/widgets/gct-form/gct-form-item/gct-form-item.d.ts +4 -4
  75. package/es/widgets/gct-form/gct-form-tab/gct-form-tab.d.ts +4 -4
  76. package/es/widgets/gct-form/gct-form-tab-pane/gct-form-tab-pane.d.ts +4 -4
  77. package/es/widgets/gct-form/gct-form-title-group/gct-form-title-group.d.ts +5 -5
  78. package/es/widgets/gct-form/gct-form.d.ts +5 -5
  79. package/package.json +15 -13
  80. package/dist/core-web.css +0 -1
  81. package/es/components/code-editor/code-editor.scss +0 -3
  82. package/es/components/index.mjs +0 -7
  83. package/es/components/layout/flex-container/flex-container.mjs +0 -90
  84. package/es/components/layout/flex-container/flex-container.scss +0 -3
  85. package/es/components/layout/flex-item/flex-item.mjs +0 -53
  86. package/es/components/layout/flex-item/flex-item.scss +0 -17
  87. package/es/components/layout/grid-container/grid-container.mjs +0 -47
  88. package/es/components/layout/view-container/view-container.mjs +0 -39
  89. package/es/components/layout/view-container/view-container.scss +0 -19
  90. package/es/editor/gct-form-check-switch/gct-form-check-switch.mjs +0 -53
  91. package/es/editor/gct-form-check-switch/gct-form-check-switch.provider.mjs +0 -6
  92. package/es/editor/gct-form-check-switch/gct-form-check-switch.scss +0 -10
  93. package/es/editor/gct-form-check-switch/index.mjs +0 -12
  94. package/es/editor/gct-form-checkbox/gct-form-checkbox.mjs +0 -70
  95. package/es/editor/gct-form-checkbox/gct-form-checkbox.scss +0 -56
  96. package/es/editor/gct-form-checkbox/index.mjs +0 -19
  97. package/es/editor/gct-form-color/gct-form-color.mjs +0 -45
  98. package/es/editor/gct-form-color/gct-form-color.provider.mjs +0 -6
  99. package/es/editor/gct-form-color/gct-form-color.scss +0 -3
  100. package/es/editor/gct-form-color/index.mjs +0 -17
  101. package/es/editor/gct-form-field-select/gct-form-field-select.mjs +0 -48
  102. package/es/editor/gct-form-field-select/gct-form-field-select.provider.mjs +0 -6
  103. package/es/editor/gct-form-field-select/gct-form-field-select.scss +0 -7
  104. package/es/editor/gct-form-field-select/gct-model-select.vue +0 -70
  105. package/es/editor/gct-form-field-select/index.mjs +0 -12
  106. package/es/editor/gct-form-i18n/gct-form-i18n.mjs +0 -62
  107. package/es/editor/gct-form-i18n/gct-form-i18n.provider.mjs +0 -6
  108. package/es/editor/gct-form-i18n/index.mjs +0 -12
  109. package/es/editor/gct-form-icon-select/gct-form-icon-select.mjs +0 -74
  110. package/es/editor/gct-form-icon-select/gct-form-icon-select.scss +0 -14
  111. package/es/editor/gct-form-icon-select/index.mjs +0 -14
  112. package/es/editor/gct-form-info/gct-form-info.mjs +0 -40
  113. package/es/editor/gct-form-info/gct-form-info.scss +0 -8
  114. package/es/editor/gct-form-info/index.mjs +0 -14
  115. package/es/editor/gct-form-length-unit/gct-form-length-unit.mjs +0 -43
  116. package/es/editor/gct-form-length-unit/gct-form-length-unit.provider.mjs +0 -6
  117. package/es/editor/gct-form-length-unit/index.mjs +0 -12
  118. package/es/editor/gct-form-modal-select/gct-form-modal-select.mjs +0 -99
  119. package/es/editor/gct-form-modal-select/gct-form-modal-select.provider.mjs +0 -6
  120. package/es/editor/gct-form-modal-select/gct-form-modal-select.scss +0 -7
  121. package/es/editor/gct-form-modal-select/index.mjs +0 -12
  122. package/es/editor/gct-form-number/gct-form-number.mjs +0 -44
  123. package/es/editor/gct-form-number/gct-form-number.provider.mjs +0 -6
  124. package/es/editor/gct-form-number/gct-form-number.scss +0 -3
  125. package/es/editor/gct-form-number/index.mjs +0 -17
  126. package/es/editor/gct-form-picker/gct-form-picker.mjs +0 -92
  127. package/es/editor/gct-form-picker/gct-form-picker.provider.mjs +0 -6
  128. package/es/editor/gct-form-picker/index.mjs +0 -12
  129. package/es/editor/gct-form-radio/gct-form-radio.mjs +0 -70
  130. package/es/editor/gct-form-radio/gct-form-radio.scss +0 -68
  131. package/es/editor/gct-form-radio/index.mjs +0 -19
  132. package/es/editor/gct-form-select/gct-form-select.mjs +0 -50
  133. package/es/editor/gct-form-select/gct-form-select.provider.mjs +0 -6
  134. package/es/editor/gct-form-select/index.mjs +0 -12
  135. package/es/editor/gct-form-span/gct-form-span.mjs +0 -89
  136. package/es/editor/gct-form-span/gct-form-span.provider.mjs +0 -6
  137. package/es/editor/gct-form-span/gct-form-span.scss +0 -10
  138. package/es/editor/gct-form-span/index.mjs +0 -12
  139. package/es/editor/gct-form-switch/gct-form-switch.mjs +0 -35
  140. package/es/editor/gct-form-switch/gct-form-switch.provider.mjs +0 -6
  141. package/es/editor/gct-form-switch/index.mjs +0 -17
  142. package/es/editor/gct-form-text/gct-form-text.mjs +0 -45
  143. package/es/editor/gct-form-text/gct-form-text.provider.mjs +0 -6
  144. package/es/editor/gct-form-text/index.mjs +0 -17
  145. package/es/editor/gct-form-textarea/gct-form-textarea.mjs +0 -40
  146. package/es/editor/gct-form-textarea/gct-form-textarea.provider.mjs +0 -6
  147. package/es/editor/gct-form-textarea/index.mjs +0 -12
  148. package/es/editor/index.mjs +0 -51
  149. package/es/utils/index.mjs +0 -3
  150. package/es/vite-env.d.ts +0 -1
  151. package/es/widgets/gct-edit-form/gct-edit-form.mjs +0 -126
  152. package/es/widgets/gct-edit-form/index.mjs +0 -10
  153. package/es/widgets/gct-form/gct-form-collapse/gct-form-collapse.mjs +0 -73
  154. package/es/widgets/gct-form/gct-form-collapse/gct-form-collapse.provider.mjs +0 -11
  155. package/es/widgets/gct-form/gct-form-collapse/gct-form-collapse.scss +0 -62
  156. package/es/widgets/gct-form/gct-form-collapse/index.mjs +0 -15
  157. package/es/widgets/gct-form/gct-form-collapse-pane/gct-form-collapse-pane.mjs +0 -71
  158. package/es/widgets/gct-form/gct-form-collapse-pane/gct-form-collapse-pane.provider.mjs +0 -13
  159. package/es/widgets/gct-form/gct-form-collapse-pane/gct-form-collapse-pane.scss +0 -23
  160. package/es/widgets/gct-form/gct-form-collapse-pane/index.mjs +0 -15
  161. package/es/widgets/gct-form/gct-form-group/gct-form-group.mjs +0 -88
  162. package/es/widgets/gct-form/gct-form-group/gct-form-group.provider.mjs +0 -11
  163. package/es/widgets/gct-form/gct-form-group/gct-form-group.scss +0 -28
  164. package/es/widgets/gct-form/gct-form-group/index.mjs +0 -15
  165. package/es/widgets/gct-form/gct-form-hidden-item/gct-form-hidden-item.provider.mjs +0 -13
  166. package/es/widgets/gct-form/gct-form-item/gct-form-item.mjs +0 -141
  167. package/es/widgets/gct-form/gct-form-item/gct-form-item.provider.mjs +0 -11
  168. package/es/widgets/gct-form/gct-form-item/gct-form-item.scss +0 -115
  169. package/es/widgets/gct-form/gct-form-tab/gct-form-tab.mjs +0 -53
  170. package/es/widgets/gct-form/gct-form-tab/gct-form-tab.provider.mjs +0 -11
  171. package/es/widgets/gct-form/gct-form-tab/gct-form-tab.scss +0 -63
  172. package/es/widgets/gct-form/gct-form-tab/index.mjs +0 -12
  173. package/es/widgets/gct-form/gct-form-tab-pane/gct-form-tab-pane.mjs +0 -65
  174. package/es/widgets/gct-form/gct-form-tab-pane/gct-form-tab-pane.provider.mjs +0 -11
  175. package/es/widgets/gct-form/gct-form-tab-pane/gct-form-tab-pane.scss +0 -16
  176. package/es/widgets/gct-form/gct-form-tab-pane/index.mjs +0 -15
  177. package/es/widgets/gct-form/gct-form-title-group/gct-form-title-group.mjs +0 -71
  178. package/es/widgets/gct-form/gct-form-title-group/gct-form-title-group.provider.mjs +0 -11
  179. package/es/widgets/gct-form/gct-form-title-group/gct-form-title-group.scss +0 -25
  180. package/es/widgets/gct-form/gct-form-title-group/index.mjs +0 -16
  181. package/es/widgets/gct-form/gct-form.mjs +0 -110
  182. package/es/widgets/gct-form/gct-form.scss +0 -11
  183. package/es/widgets/gct-form/index.mjs +0 -31
@@ -0,0 +1,195 @@
1
+ import { defineComponent, createVNode, ref, reactive, provide, toRef, watch } from 'vue';
2
+ import { useNamespace } from '@gct-paas/core';
3
+ import { useDrop } from 'vue3-dnd';
4
+ import { cloneDeep } from 'lodash-es';
5
+ import { GctDndItem } from '../gct-dnd-item/gct-dnd-item.mjs';
6
+ import { GctDndDropLine } from '../gct-dnd-drop-line/gct-dnd-drop-line.mjs';
7
+ import { GCT_DND_INSERT_POS } from '../../constants/index.mjs';
8
+ import './gct-dnd-container.css';/* empty css */
9
+
10
+ const GctDndContainer = /* @__PURE__ */ defineComponent({
11
+ name: 'GctDndContainer',
12
+ props: {
13
+ config: {
14
+ type: Object,
15
+ default: () => {
16
+ return {
17
+ group: 'GctDnd',
18
+ insertPos: GCT_DND_INSERT_POS.LAST
19
+ };
20
+ }
21
+ },
22
+ items: {
23
+ type: Array,
24
+ default: () => []
25
+ }
26
+ },
27
+ emits: ['update:items'],
28
+ setup(props, {
29
+ emit
30
+ }) {
31
+ const {
32
+ config
33
+ } = props;
34
+ const ns = useNamespace('dnd-container');
35
+ const rootRef = ref(null);
36
+ // 拖拽线状态
37
+ const dropLineState = reactive({
38
+ activeKey: '',
39
+ isBeforeHover: false
40
+ });
41
+ provide('vue3-dnd-drop-line-state', dropLineState);
42
+ const items = toRef(props.items);
43
+ const [collect, drop] = useDrop({
44
+ accept: config.group,
45
+ collect(monitor) {
46
+ return {
47
+ handlerId: monitor.getHandlerId(),
48
+ isOver: monitor.isOver(),
49
+ canDrop: monitor.canDrop(),
50
+ isShallowOver: monitor.isOver({
51
+ shallow: true
52
+ })
53
+ };
54
+ },
55
+ canDrop(item) {
56
+ if (config.isDrop === false) {
57
+ return false;
58
+ }
59
+ if (config.canDrop) {
60
+ return config.canDrop(item);
61
+ }
62
+ return true;
63
+ },
64
+ drop: (item, monitor) => {
65
+ if (collect.value.isShallowOver !== true || monitor.canDrop() === false) {
66
+ return;
67
+ }
68
+ const callback = async () => {
69
+ let data = item.data;
70
+ if (config.drop) {
71
+ data = await config.drop(item);
72
+ if (!data) {
73
+ return {
74
+ group: config.group,
75
+ success: false,
76
+ cfg: cloneDeep(props.config)
77
+ };
78
+ }
79
+ }
80
+ const i = items.value.findIndex(_ => _.id === item.data.id);
81
+ // 数据不存在才可以从容器拖入
82
+ if (i === -1) {
83
+ onDrop(props.config.insertPos, data);
84
+ }
85
+ emit('update:items', items.value);
86
+ return {
87
+ group: config.group,
88
+ success: true,
89
+ cfg: cloneDeep(props.config),
90
+ data
91
+ };
92
+ };
93
+ return {
94
+ asyncDrop: callback
95
+ };
96
+ }
97
+ });
98
+ if (config.isDrop !== false) {
99
+ drop(rootRef);
100
+ }
101
+ watch(collect, () => {
102
+ if (collect.value.isOver !== true) {
103
+ dropLineState.activeKey = '';
104
+ }
105
+ });
106
+
107
+ /**
108
+ * 拖拽结束放置逻辑
109
+ *
110
+ * @param {GCT_DND_INSERT_POS} insertPos
111
+ * @param {IGctDndData} data
112
+ * @param {number} [insertIndex=-1] 指定放置前后时,需要指定插入谁的前后
113
+ */
114
+ function onDrop(insertPos, data, insertIndex = -1) {
115
+ if (!data) {
116
+ console.error('data is required');
117
+ return;
118
+ }
119
+ if (insertPos === GCT_DND_INSERT_POS.FIRST) {
120
+ items.value.unshift(data);
121
+ } else if (insertPos === GCT_DND_INSERT_POS.LAST) {
122
+ items.value.push(data);
123
+ } else {
124
+ if (insertIndex === -1) {
125
+ console.error('insertIndex is required');
126
+ return;
127
+ }
128
+ const i = items.value.findIndex(item => item.id === data.id);
129
+ // 在原本位置不做任何操作
130
+ if (i === insertIndex) {
131
+ return;
132
+ }
133
+ // 新位置在前,先删除,再插入
134
+ if (i !== -1 && insertIndex < i) {
135
+ items.value.splice(i, 1);
136
+ }
137
+ if (insertPos === GCT_DND_INSERT_POS.AFTER) {
138
+ // 插入后,在指定位置 + 1
139
+ items.value.splice(insertIndex + 1, 0, data);
140
+ } else {
141
+ // 插入前,在指定位置
142
+ items.value.splice(insertIndex, 0, data);
143
+ }
144
+ // 新位置在后,先插入,再删除
145
+ if (i !== -1 && insertIndex > i) {
146
+ items.value.splice(i, 1);
147
+ }
148
+ }
149
+ emit('update:items', items.value);
150
+ }
151
+ return {
152
+ ns,
153
+ rootRef,
154
+ dropLineState,
155
+ collect,
156
+ onDrop
157
+ };
158
+ },
159
+ render() {
160
+ const last = this.items[this.items.length - 1];
161
+ return createVNode("div", {
162
+ "ref": "rootRef",
163
+ "class": [this.collect.handlerId, this.ns.b(), this.ns.is('over', this.collect.isOver && this.collect.canDrop), this.ns.is('not-drop', this.collect.canDrop === false && this.collect.isOver), this.ns.is('shallow-over', this.collect.isShallowOver && this.collect.canDrop)]
164
+ }, [this.$slots.before?.(), this.items.map((item, i) => {
165
+ const before = this.items[i - 1];
166
+ const contents = [];
167
+ if (this.config.isDrop !== false) {
168
+ contents.push(createVNode(GctDndDropLine, {
169
+ "key": item.id + '___line',
170
+ "config": this.config,
171
+ "active": this.dropLineState.isBeforeHover === true && this.dropLineState.activeKey === item.id || before && this.dropLineState.activeKey === before.id && this.dropLineState.isBeforeHover === false,
172
+ "onDrop": data => this.onDrop(GCT_DND_INSERT_POS.BEFORE, data, i)
173
+ }, null));
174
+ }
175
+ contents.push(createVNode(GctDndItem, {
176
+ "key": item.id,
177
+ "config": this.config,
178
+ "index": i,
179
+ "data": item,
180
+ "last": i === this.items.length - 1,
181
+ "onDrop": (pos, data) => this.onDrop(pos, data, i)
182
+ }, {
183
+ default: this.$slots.default
184
+ }));
185
+ return contents;
186
+ }), last ? createVNode(GctDndDropLine, {
187
+ "key": last.id + '___last-line',
188
+ "config": this.config,
189
+ "active": this.dropLineState.activeKey === last.id && this.dropLineState.isBeforeHover === false,
190
+ "onDrop": data => this.onDrop(GCT_DND_INSERT_POS.AFTER, data, this.items.length - 1)
191
+ }, null) : null, this.$slots.after?.()]);
192
+ }
193
+ });
194
+
195
+ export { GctDndContainer };
@@ -0,0 +1,79 @@
1
+ @charset "UTF-8";
2
+ /* stylelint-disable scss/no-global-function-names */
3
+ /* bem('block', 'element', 'modifier') => 'ibiz-block__element--modifier' */
4
+ /**
5
+ * 定义 Block 块
6
+ * @param {String} $block - Block 块名称
7
+ * @example
8
+ * @include b('button') {
9
+ * padding: 10px;
10
+ * }
11
+ */
12
+ /**
13
+ * 定义 Element 元素
14
+ * @param {String|List} $element - Element 元素名称,支持单个或多个
15
+ * @example
16
+ * @include b('button') {
17
+ * @include e('text') {
18
+ * color: #000;
19
+ * }
20
+ * }
21
+ * // 或传入多个元素
22
+ * @include b('button') {
23
+ * @include e(('text', 'icon')) {
24
+ * margin: 5px;
25
+ * }
26
+ * }
27
+ */
28
+ /**
29
+ * 定义 Modifier 修饰符
30
+ * @param {String|List} $modifier - Modifier 修饰符名称,支持单个或多个
31
+ * @example
32
+ * @include b('button') {
33
+ * @include m('primary') {
34
+ * background: blue;
35
+ * }
36
+ * }
37
+ * // 或传入多个修饰符
38
+ * @include b('button') {
39
+ * @include m(('primary', 'large')) {
40
+ * background: blue;
41
+ * font-size: 16px;
42
+ * }
43
+ * }
44
+ */
45
+ /**
46
+ * 定义状态选择器
47
+ * @param {String} $state - 状态名称
48
+ * @example
49
+ * @include b('button') {
50
+ * @include when('disabled') {
51
+ * opacity: 0.5;
52
+ * }
53
+ * }
54
+ */
55
+ /**
56
+ * 深色主题样式
57
+ * @param {String} $block - Block 块名称
58
+ * @example
59
+ * @include dark('button') {
60
+ * background: #333;
61
+ * color: #fff;
62
+ * }
63
+ */
64
+ /* stylelint-disable scss/no-global-function-names */
65
+ .gct-dnd-drop-line {
66
+ background-color: transparent;
67
+ padding: var(--gct-padding-1) 0;
68
+ }
69
+ .gct-dnd-drop-line__line {
70
+ border-top: 1px solid transparent;
71
+ }
72
+
73
+ .gct-dnd-drop-line.is-shallow-over .gct-dnd-drop-line__line {
74
+ border-color: var(--gct-color-primary);
75
+ }
76
+
77
+ .gct-dnd-drop-line.is-active .gct-dnd-drop-line__line {
78
+ border-color: var(--gct-color-primary);
79
+ }
@@ -0,0 +1,29 @@
1
+ import { PropType } from 'vue';
2
+ import { IGctDndConfig, IGctDropCollect } from '../../interface';
3
+ export declare const GctDndDropLine: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
4
+ config: {
5
+ type: PropType<IGctDndConfig>;
6
+ required: true;
7
+ };
8
+ active: {
9
+ type: BooleanConstructor;
10
+ default: boolean;
11
+ };
12
+ }>, {
13
+ ns: import('@gct-paas/core').Namespace;
14
+ rootRef: import('vue').Ref<HTMLDivElement | null, HTMLDivElement | null>;
15
+ collect: import('vue').Ref<IGctDropCollect, IGctDropCollect>;
16
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, "drop"[], "drop", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
17
+ config: {
18
+ type: PropType<IGctDndConfig>;
19
+ required: true;
20
+ };
21
+ active: {
22
+ type: BooleanConstructor;
23
+ default: boolean;
24
+ };
25
+ }>> & Readonly<{
26
+ onDrop?: ((...args: any[]) => any) | undefined;
27
+ }>, {
28
+ active: boolean;
29
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
@@ -0,0 +1,98 @@
1
+ import { defineComponent, createVNode, ref } from 'vue';
2
+ import { useNamespace } from '@gct-paas/core';
3
+ import { useDrop } from 'vue3-dnd';
4
+ import { cloneDeep } from 'lodash-es';
5
+ import './gct-dnd-drop-line.css';/* empty css */
6
+
7
+ const GctDndDropLine = /* @__PURE__ */ defineComponent({
8
+ name: 'GctDndDropLine',
9
+ props: {
10
+ config: {
11
+ type: Object,
12
+ required: true
13
+ },
14
+ // 特殊指定当前线激活
15
+ active: {
16
+ type: Boolean,
17
+ default: false
18
+ }
19
+ },
20
+ emits: ['drop'],
21
+ setup(props, {
22
+ emit
23
+ }) {
24
+ const {
25
+ config
26
+ } = props;
27
+ const ns = useNamespace('dnd-drop-line');
28
+ const rootRef = ref(null);
29
+ const [collect, drop] = useDrop({
30
+ accept: props.config.group,
31
+ collect: monitor => {
32
+ return {
33
+ handlerId: monitor.getHandlerId(),
34
+ isOver: monitor.isOver(),
35
+ canDrop: monitor.canDrop(),
36
+ isShallowOver: monitor.isOver({
37
+ shallow: true
38
+ })
39
+ };
40
+ },
41
+ canDrop(item) {
42
+ if (config.isDrop === false) {
43
+ return false;
44
+ }
45
+ if (config.canDrop) {
46
+ return config.canDrop(item);
47
+ }
48
+ return true;
49
+ },
50
+ drop: (item, monitor) => {
51
+ if (collect.value.isShallowOver !== true || monitor.canDrop() === false) {
52
+ return;
53
+ }
54
+ const callback = async () => {
55
+ let data = item.data;
56
+ if (config.drop) {
57
+ data = await config.drop(item);
58
+ if (!data) {
59
+ return {
60
+ group: config.group,
61
+ cfg: cloneDeep(props.config),
62
+ success: false
63
+ };
64
+ }
65
+ }
66
+ emit('drop', data);
67
+ return {
68
+ group: config.group,
69
+ success: true,
70
+ cfg: cloneDeep(props.config),
71
+ data
72
+ };
73
+ };
74
+ return {
75
+ asyncDrop: callback
76
+ };
77
+ }
78
+ });
79
+ if (config.isDrop !== false) {
80
+ drop(rootRef);
81
+ }
82
+ return {
83
+ ns,
84
+ rootRef,
85
+ collect
86
+ };
87
+ },
88
+ render() {
89
+ return createVNode("div", {
90
+ "ref": "rootRef",
91
+ "class": [this.collect.handlerId, this.ns.b(), this.ns.is('over', this.collect.isOver && this.collect.canDrop), this.ns.is('shallow-over', this.collect.isShallowOver && this.collect.canDrop), this.ns.is('not-drop', this.collect.canDrop === false && this.collect.isShallowOver), this.ns.is('active', this.active)]
92
+ }, [createVNode("div", {
93
+ "class": this.ns.e('line')
94
+ }, null)]);
95
+ }
96
+ });
97
+
98
+ export { GctDndDropLine };
@@ -0,0 +1,70 @@
1
+ @charset "UTF-8";
2
+ /* stylelint-disable scss/no-global-function-names */
3
+ /* bem('block', 'element', 'modifier') => 'ibiz-block__element--modifier' */
4
+ /**
5
+ * 定义 Block 块
6
+ * @param {String} $block - Block 块名称
7
+ * @example
8
+ * @include b('button') {
9
+ * padding: 10px;
10
+ * }
11
+ */
12
+ /**
13
+ * 定义 Element 元素
14
+ * @param {String|List} $element - Element 元素名称,支持单个或多个
15
+ * @example
16
+ * @include b('button') {
17
+ * @include e('text') {
18
+ * color: #000;
19
+ * }
20
+ * }
21
+ * // 或传入多个元素
22
+ * @include b('button') {
23
+ * @include e(('text', 'icon')) {
24
+ * margin: 5px;
25
+ * }
26
+ * }
27
+ */
28
+ /**
29
+ * 定义 Modifier 修饰符
30
+ * @param {String|List} $modifier - Modifier 修饰符名称,支持单个或多个
31
+ * @example
32
+ * @include b('button') {
33
+ * @include m('primary') {
34
+ * background: blue;
35
+ * }
36
+ * }
37
+ * // 或传入多个修饰符
38
+ * @include b('button') {
39
+ * @include m(('primary', 'large')) {
40
+ * background: blue;
41
+ * font-size: 16px;
42
+ * }
43
+ * }
44
+ */
45
+ /**
46
+ * 定义状态选择器
47
+ * @param {String} $state - 状态名称
48
+ * @example
49
+ * @include b('button') {
50
+ * @include when('disabled') {
51
+ * opacity: 0.5;
52
+ * }
53
+ * }
54
+ */
55
+ /**
56
+ * 深色主题样式
57
+ * @param {String} $block - Block 块名称
58
+ * @example
59
+ * @include dark('button') {
60
+ * background: #333;
61
+ * color: #fff;
62
+ * }
63
+ */
64
+ /* stylelint-disable scss/no-global-function-names */
65
+ .gct-dnd-item {
66
+ background-color: rgb(var(--gct-gray-2));
67
+ }
68
+ .gct-dnd-item.is-dragging {
69
+ background-color: var(--gct-color-bg-3) !important;
70
+ }
@@ -0,0 +1,50 @@
1
+ import { PropType } from 'vue';
2
+ import { IGctDragCollect, IGctDndData, IGctDndConfig } from '../../interface';
3
+ import { GCT_DND_INSERT_POS } from '../../constants';
4
+ export declare const GctDndItem: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
5
+ config: {
6
+ type: PropType<IGctDndConfig>;
7
+ required: true;
8
+ };
9
+ index: {
10
+ type: NumberConstructor;
11
+ required: true;
12
+ };
13
+ data: {
14
+ type: PropType<IGctDndData>;
15
+ required: true;
16
+ };
17
+ last: {
18
+ type: BooleanConstructor;
19
+ default: boolean;
20
+ };
21
+ }>, {
22
+ ns: import('@gct-paas/core').Namespace;
23
+ rootRef: import('vue').Ref<HTMLDivElement | null, HTMLDivElement | null>;
24
+ posState: import('vue').Ref<0 | 1 | -1, 0 | 1 | -1>;
25
+ collect: import('vue').Ref<IGctDragCollect, IGctDragCollect>;
26
+ onDrop: (insertPos: GCT_DND_INSERT_POS, data: IGctDndData) => void;
27
+ drag: import('vue3-dnd').ConnectDragSource<import('vue3-dnd').DragSourceOptions>;
28
+ }, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, "drop"[], "drop", import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
29
+ config: {
30
+ type: PropType<IGctDndConfig>;
31
+ required: true;
32
+ };
33
+ index: {
34
+ type: NumberConstructor;
35
+ required: true;
36
+ };
37
+ data: {
38
+ type: PropType<IGctDndData>;
39
+ required: true;
40
+ };
41
+ last: {
42
+ type: BooleanConstructor;
43
+ default: boolean;
44
+ };
45
+ }>> & Readonly<{
46
+ onDrop?: ((...args: any[]) => any) | undefined;
47
+ }>, {
48
+ last: boolean;
49
+ }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
50
+ export default GctDndItem;