@gct-paas/core-web 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.
- package/dist/index.esm.min.mjs +24472 -7434
- package/dist/index.min.cjs +59 -12
- package/dist/index.min.css +1 -0
- package/dist/index.system.min.js +59 -12
- package/es/components/assets-svg-icon/assets-svg-icon.css +188 -0
- package/es/components/assets-svg-icon/assets-svg-icon.d.ts +134 -0
- package/es/components/assets-svg-icon/assets-svg-icon.mjs +238 -0
- package/es/components/assets-svg-icon/request.d.ts +2 -0
- package/es/components/assets-svg-icon/request.mjs +51 -0
- package/es/components/assets-svg-icon/utils.d.ts +9 -0
- package/es/components/assets-svg-icon/utils.mjs +21 -0
- package/es/components/assets-svg-icon/validate.d.ts +4 -0
- package/es/components/assets-svg-icon/validate.mjs +43 -0
- package/es/components/code-editor/code-editor.css +67 -0
- package/es/components/code-editor/code-editor.mjs +9 -10
- package/es/components/index.d.ts +1 -0
- package/es/components/layout/flex-container/flex-container.css +67 -0
- package/es/components/layout/view-container/view-container.css +83 -0
- package/es/editor/gct-form-check-switch/gct-form-check-switch.d.ts +1 -1
- package/es/editor/gct-form-i18n/gct-form-i18n.d.ts +1 -1
- package/es/editor/gct-form-info/gct-form-info.d.ts +1 -1
- package/es/editor/gct-form-length-unit/gct-form-length-unit.d.ts +1 -1
- package/es/editor/gct-form-number/gct-form-number.d.ts +1 -1
- package/es/editor/gct-form-radio/gct-form-radio.d.ts +1 -1
- package/es/editor/gct-form-select/gct-form-select.d.ts +1 -1
- package/es/editor/gct-form-switch/gct-form-switch.d.ts +1 -1
- package/es/editor/gct-form-textarea/gct-form-textarea.d.ts +1 -1
- package/es/hooks/index.d.ts +2 -0
- package/es/hooks/useLocale.d.ts +4 -0
- package/es/hooks/useLocale.mjs +32 -0
- package/es/hooks/useTheme.d.ts +8 -0
- package/es/hooks/useTheme.mjs +20 -0
- package/es/index.d.ts +5 -6
- package/es/index.mjs +19 -24
- package/es/modules/gct-dnd/components/gct-dnd-container/gct-dnd-container.css +72 -0
- package/es/modules/gct-dnd/components/gct-dnd-container/gct-dnd-container.d.ts +37 -0
- package/es/modules/gct-dnd/components/gct-dnd-container/gct-dnd-container.mjs +195 -0
- package/es/modules/gct-dnd/components/gct-dnd-drop-line/gct-dnd-drop-line.css +79 -0
- package/es/modules/gct-dnd/components/gct-dnd-drop-line/gct-dnd-drop-line.d.ts +29 -0
- package/es/modules/gct-dnd/components/gct-dnd-drop-line/gct-dnd-drop-line.mjs +98 -0
- package/es/modules/gct-dnd/components/gct-dnd-item/gct-dnd-item.css +70 -0
- package/es/modules/gct-dnd/components/gct-dnd-item/gct-dnd-item.d.ts +50 -0
- package/es/modules/gct-dnd/components/gct-dnd-item/gct-dnd-item.mjs +239 -0
- package/es/modules/gct-dnd/constants/index.d.ts +24 -0
- package/es/modules/gct-dnd/constants/index.mjs +9 -0
- package/es/modules/gct-dnd/index.d.ts +5 -0
- package/es/modules/gct-dnd/interface/i-gct-dnd-config.d.ts +101 -0
- package/es/modules/gct-dnd/interface/i-gct-dnd-data.d.ts +14 -0
- package/es/modules/gct-dnd/interface/i-gct-dnd-render-item-options.d.ts +28 -0
- package/es/modules/gct-dnd/interface/i-gct-drag-collect.d.ts +24 -0
- package/es/modules/gct-dnd/interface/i-gct-drag-dnd-data.d.ts +51 -0
- package/es/modules/gct-dnd/interface/i-gct-drop-collect.d.ts +32 -0
- package/es/modules/gct-dnd/interface/i-gct-drop-result.d.ts +47 -0
- package/es/modules/gct-dnd/interface/index.d.ts +7 -0
- package/es/utils/with-install.mjs +0 -1
- package/package.json +11 -8
- package/dist/index.min.css.css +0 -1
- package/es/components/code-editor/code-editor.scss +0 -3
- package/es/components/index.mjs +0 -7
- package/es/components/layout/flex-container/flex-container.mjs +0 -90
- package/es/components/layout/flex-container/flex-container.scss +0 -3
- package/es/components/layout/flex-item/flex-item.mjs +0 -53
- package/es/components/layout/flex-item/flex-item.scss +0 -17
- package/es/components/layout/grid-container/grid-container.mjs +0 -47
- package/es/components/layout/view-container/view-container.mjs +0 -39
- package/es/components/layout/view-container/view-container.scss +0 -19
- package/es/editor/gct-form-check-switch/gct-form-check-switch.mjs +0 -53
- package/es/editor/gct-form-check-switch/gct-form-check-switch.provider.mjs +0 -6
- package/es/editor/gct-form-check-switch/gct-form-check-switch.scss +0 -10
- package/es/editor/gct-form-check-switch/index.mjs +0 -12
- package/es/editor/gct-form-checkbox/gct-form-checkbox.mjs +0 -70
- package/es/editor/gct-form-checkbox/gct-form-checkbox.scss +0 -56
- package/es/editor/gct-form-checkbox/index.mjs +0 -19
- package/es/editor/gct-form-color/gct-form-color.mjs +0 -45
- package/es/editor/gct-form-color/gct-form-color.provider.mjs +0 -6
- package/es/editor/gct-form-color/gct-form-color.scss +0 -3
- package/es/editor/gct-form-color/index.mjs +0 -17
- package/es/editor/gct-form-field-select/gct-form-field-select.mjs +0 -48
- package/es/editor/gct-form-field-select/gct-form-field-select.provider.mjs +0 -6
- package/es/editor/gct-form-field-select/gct-form-field-select.scss +0 -7
- package/es/editor/gct-form-field-select/gct-model-select.vue +0 -70
- package/es/editor/gct-form-field-select/index.mjs +0 -12
- package/es/editor/gct-form-i18n/gct-form-i18n.mjs +0 -62
- package/es/editor/gct-form-i18n/gct-form-i18n.provider.mjs +0 -6
- package/es/editor/gct-form-i18n/index.mjs +0 -12
- package/es/editor/gct-form-icon-select/gct-form-icon-select.mjs +0 -74
- package/es/editor/gct-form-icon-select/gct-form-icon-select.scss +0 -14
- package/es/editor/gct-form-icon-select/index.mjs +0 -14
- package/es/editor/gct-form-info/gct-form-info.mjs +0 -40
- package/es/editor/gct-form-info/gct-form-info.scss +0 -8
- package/es/editor/gct-form-info/index.mjs +0 -14
- package/es/editor/gct-form-length-unit/gct-form-length-unit.mjs +0 -43
- package/es/editor/gct-form-length-unit/gct-form-length-unit.provider.mjs +0 -6
- package/es/editor/gct-form-length-unit/index.mjs +0 -12
- package/es/editor/gct-form-modal-select/gct-form-modal-select.mjs +0 -99
- package/es/editor/gct-form-modal-select/gct-form-modal-select.provider.mjs +0 -6
- package/es/editor/gct-form-modal-select/gct-form-modal-select.scss +0 -7
- package/es/editor/gct-form-modal-select/index.mjs +0 -12
- package/es/editor/gct-form-number/gct-form-number.mjs +0 -44
- package/es/editor/gct-form-number/gct-form-number.provider.mjs +0 -6
- package/es/editor/gct-form-number/gct-form-number.scss +0 -3
- package/es/editor/gct-form-number/index.mjs +0 -17
- package/es/editor/gct-form-picker/gct-form-picker.mjs +0 -92
- package/es/editor/gct-form-picker/gct-form-picker.provider.mjs +0 -6
- package/es/editor/gct-form-picker/index.mjs +0 -12
- package/es/editor/gct-form-radio/gct-form-radio.mjs +0 -70
- package/es/editor/gct-form-radio/gct-form-radio.scss +0 -68
- package/es/editor/gct-form-radio/index.mjs +0 -19
- package/es/editor/gct-form-select/gct-form-select.mjs +0 -50
- package/es/editor/gct-form-select/gct-form-select.provider.mjs +0 -6
- package/es/editor/gct-form-select/index.mjs +0 -12
- package/es/editor/gct-form-span/gct-form-span.mjs +0 -89
- package/es/editor/gct-form-span/gct-form-span.provider.mjs +0 -6
- package/es/editor/gct-form-span/gct-form-span.scss +0 -10
- package/es/editor/gct-form-span/index.mjs +0 -12
- package/es/editor/gct-form-switch/gct-form-switch.mjs +0 -35
- package/es/editor/gct-form-switch/gct-form-switch.provider.mjs +0 -6
- package/es/editor/gct-form-switch/index.mjs +0 -17
- package/es/editor/gct-form-text/gct-form-text.mjs +0 -45
- package/es/editor/gct-form-text/gct-form-text.provider.mjs +0 -6
- package/es/editor/gct-form-text/index.mjs +0 -17
- package/es/editor/gct-form-textarea/gct-form-textarea.mjs +0 -40
- package/es/editor/gct-form-textarea/gct-form-textarea.provider.mjs +0 -6
- package/es/editor/gct-form-textarea/index.mjs +0 -12
- package/es/editor/index.mjs +0 -51
- package/es/utils/index.mjs +0 -3
- package/es/vite-env.d.ts +0 -1
- package/es/widgets/gct-edit-form/gct-edit-form.mjs +0 -126
- package/es/widgets/gct-edit-form/index.mjs +0 -10
- package/es/widgets/gct-form/gct-form-collapse/gct-form-collapse.mjs +0 -73
- package/es/widgets/gct-form/gct-form-collapse/gct-form-collapse.provider.mjs +0 -11
- package/es/widgets/gct-form/gct-form-collapse/gct-form-collapse.scss +0 -62
- package/es/widgets/gct-form/gct-form-collapse/index.mjs +0 -15
- package/es/widgets/gct-form/gct-form-collapse-pane/gct-form-collapse-pane.mjs +0 -71
- package/es/widgets/gct-form/gct-form-collapse-pane/gct-form-collapse-pane.provider.mjs +0 -13
- package/es/widgets/gct-form/gct-form-collapse-pane/gct-form-collapse-pane.scss +0 -23
- package/es/widgets/gct-form/gct-form-collapse-pane/index.mjs +0 -15
- package/es/widgets/gct-form/gct-form-group/gct-form-group.mjs +0 -88
- package/es/widgets/gct-form/gct-form-group/gct-form-group.provider.mjs +0 -11
- package/es/widgets/gct-form/gct-form-group/gct-form-group.scss +0 -28
- package/es/widgets/gct-form/gct-form-group/index.mjs +0 -15
- package/es/widgets/gct-form/gct-form-hidden-item/gct-form-hidden-item.provider.mjs +0 -13
- package/es/widgets/gct-form/gct-form-item/gct-form-item.mjs +0 -141
- package/es/widgets/gct-form/gct-form-item/gct-form-item.provider.mjs +0 -11
- package/es/widgets/gct-form/gct-form-item/gct-form-item.scss +0 -115
- package/es/widgets/gct-form/gct-form-tab/gct-form-tab.mjs +0 -53
- package/es/widgets/gct-form/gct-form-tab/gct-form-tab.provider.mjs +0 -11
- package/es/widgets/gct-form/gct-form-tab/gct-form-tab.scss +0 -63
- package/es/widgets/gct-form/gct-form-tab/index.mjs +0 -12
- package/es/widgets/gct-form/gct-form-tab-pane/gct-form-tab-pane.mjs +0 -65
- package/es/widgets/gct-form/gct-form-tab-pane/gct-form-tab-pane.provider.mjs +0 -11
- package/es/widgets/gct-form/gct-form-tab-pane/gct-form-tab-pane.scss +0 -16
- package/es/widgets/gct-form/gct-form-tab-pane/index.mjs +0 -15
- package/es/widgets/gct-form/gct-form-title-group/gct-form-title-group.mjs +0 -71
- package/es/widgets/gct-form/gct-form-title-group/gct-form-title-group.provider.mjs +0 -11
- package/es/widgets/gct-form/gct-form-title-group/gct-form-title-group.scss +0 -25
- package/es/widgets/gct-form/gct-form-title-group/index.mjs +0 -16
- package/es/widgets/gct-form/gct-form.mjs +0 -112
- package/es/widgets/gct-form/gct-form.scss +0 -11
- 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;
|