@shwfed/config 2.3.0 → 2.3.2
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/module.json +1 -1
- package/dist/module.mjs +2 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/config.d.vue.ts +61 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/config.vue +187 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/config.vue.d.ts +61 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/runtime.d.vue.ts +8 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/runtime.vue +62 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/runtime.vue.d.ts +8 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/schema.d.ts +40 -0
- package/dist/runtime/components/actions/buttons/2026-05-21/com.shwfed.actions.button.http.download/schema.js +87 -0
- package/dist/runtime/components/config/blocks/2026-05-06/com.shwfed.block.table/config.d.vue.ts +2 -0
- package/dist/runtime/components/config/blocks/2026-05-06/com.shwfed.block.table/config.vue.d.ts +2 -0
- package/dist/runtime/components/config/blocks/2026-05-06/com.shwfed.block.table/runtime.d.vue.ts +2 -0
- package/dist/runtime/components/config/blocks/2026-05-06/com.shwfed.block.table/runtime.vue.d.ts +2 -0
- package/dist/runtime/components/config/blocks/2026-05-06/com.shwfed.block.table/schema.d.ts +2 -0
- package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/config.d.vue.ts +2 -0
- package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/config.vue.d.ts +2 -0
- package/dist/runtime/components/form/fields/2026-05-18/com.shwfed.form.field.table/schema.d.ts +2 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/config.d.vue.ts +10 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/config.vue +310 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/config.vue.d.ts +10 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/runtime.d.vue.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/runtime.vue +81 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/runtime.vue.d.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/schema.d.ts +57 -0
- package/dist/runtime/components/table/columns/2026-05-20/com.shwfed.table.column.switch/schema.js +59 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/config.d.vue.ts +10 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/config.vue +10 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/config.vue.d.ts +10 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/runtime.d.vue.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/runtime.vue +68 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/runtime.vue.d.ts +9 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/schema.d.ts +17 -0
- package/dist/runtime/components/table/columns/2026-05-21/com.shwfed.table.column.drag-handle/schema.js +31 -0
- package/dist/runtime/components/table/config.d.vue.ts +2 -2
- package/dist/runtime/components/table/config.vue +50 -0
- package/dist/runtime/components/table/config.vue.d.ts +2 -2
- package/dist/runtime/components/table/index.d.vue.ts +2 -0
- package/dist/runtime/components/table/index.vue +110 -4
- package/dist/runtime/components/table/index.vue.d.ts +2 -0
- package/dist/runtime/components/table/schema.d.ts +4 -0
- package/dist/runtime/components/table/schema.js +8 -1
- package/dist/runtime/components/table/utils/reorder.d.ts +10 -0
- package/dist/runtime/components/table/utils/reorder.js +8 -0
- package/dist/runtime/components/table/utils/row-key.d.ts +11 -0
- package/dist/runtime/components/table/utils/row-key.js +30 -0
- package/dist/runtime/components/table/utils/row-reorder.d.ts +12 -0
- package/dist/runtime/components/table/utils/row-reorder.js +162 -0
- package/package.json +1 -1
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { onBeforeUnmount, ref } from "vue";
|
|
2
|
+
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
3
|
+
import {
|
|
4
|
+
draggable,
|
|
5
|
+
dropTargetForElements
|
|
6
|
+
} from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
7
|
+
import { setCustomNativeDragPreview } from "@atlaskit/pragmatic-drag-and-drop/element/set-custom-native-drag-preview";
|
|
8
|
+
import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
|
|
9
|
+
import {
|
|
10
|
+
attachInstruction,
|
|
11
|
+
extractInstruction
|
|
12
|
+
} from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
|
|
13
|
+
export function applyReorder(rows, sourceIndex, targetIndex, position) {
|
|
14
|
+
if (sourceIndex === targetIndex) return rows;
|
|
15
|
+
if (sourceIndex < 0 || sourceIndex >= rows.length) return rows;
|
|
16
|
+
if (targetIndex < 0 || targetIndex >= rows.length) return rows;
|
|
17
|
+
let insertIdx = targetIndex + (position === "reorder-below" ? 1 : 0);
|
|
18
|
+
if (sourceIndex < targetIndex) insertIdx -= 1;
|
|
19
|
+
if (insertIdx === sourceIndex) return rows;
|
|
20
|
+
const next = rows.slice();
|
|
21
|
+
const [moved] = next.splice(sourceIndex, 1);
|
|
22
|
+
next.splice(insertIdx, 0, moved);
|
|
23
|
+
return next;
|
|
24
|
+
}
|
|
25
|
+
const SOURCE_KIND = "shwfed-table-row";
|
|
26
|
+
export function useRowReorder(options) {
|
|
27
|
+
const instruction = ref(null);
|
|
28
|
+
const regs = /* @__PURE__ */ new Map();
|
|
29
|
+
function rewire(rowId, reg) {
|
|
30
|
+
reg.cleanup?.();
|
|
31
|
+
if (!reg.rowEl || !reg.handleEl) {
|
|
32
|
+
reg.cleanup = null;
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const rowEl = reg.rowEl;
|
|
36
|
+
const handleEl = reg.handleEl;
|
|
37
|
+
reg.cleanup = combine(
|
|
38
|
+
draggable({
|
|
39
|
+
element: rowEl,
|
|
40
|
+
dragHandle: handleEl,
|
|
41
|
+
getInitialData: () => ({ kind: SOURCE_KIND, id: rowId }),
|
|
42
|
+
canDrag: () => options.isEnabled(),
|
|
43
|
+
// The row is full-table-width and most of its content trails off-
|
|
44
|
+
// screen on wide tables, so the default native preview (a snapshot
|
|
45
|
+
// of `element`) is a giant useless rectangle. We render a clone
|
|
46
|
+
// capped at ~360px and fade it out to the right via a CSS mask so
|
|
47
|
+
// the user sees just enough of the row's leading cells to identify
|
|
48
|
+
// it, with the trailing content gracefully dissolving.
|
|
49
|
+
onGenerateDragPreview: ({ nativeSetDragImage, location, source }) => {
|
|
50
|
+
setCustomNativeDragPreview({
|
|
51
|
+
nativeSetDragImage,
|
|
52
|
+
getOffset: preserveOffsetOnSource({
|
|
53
|
+
element: source.element,
|
|
54
|
+
input: location.current.input
|
|
55
|
+
}),
|
|
56
|
+
render: ({ container }) => {
|
|
57
|
+
const src = source.element;
|
|
58
|
+
const rect = src.getBoundingClientRect();
|
|
59
|
+
const clone = src.cloneNode(true);
|
|
60
|
+
clone.style.transform = "none";
|
|
61
|
+
clone.style.position = "relative";
|
|
62
|
+
clone.style.top = "0";
|
|
63
|
+
clone.style.left = "0";
|
|
64
|
+
clone.style.height = `${rect.height}px`;
|
|
65
|
+
clone.style.width = `${rect.width}px`;
|
|
66
|
+
clone.style.flexShrink = "0";
|
|
67
|
+
const wrapper = document.createElement("div");
|
|
68
|
+
wrapper.style.width = `${Math.min(rect.width, 360)}px`;
|
|
69
|
+
wrapper.style.maxWidth = "60vw";
|
|
70
|
+
wrapper.style.height = `${rect.height}px`;
|
|
71
|
+
wrapper.style.overflow = "hidden";
|
|
72
|
+
wrapper.style.background = "white";
|
|
73
|
+
wrapper.style.boxShadow = "0 6px 18px rgba(0,0,0,0.12)";
|
|
74
|
+
wrapper.style.borderRadius = "4px";
|
|
75
|
+
const fade = "linear-gradient(to right, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 55%, rgba(0,0,0,0) 100%)";
|
|
76
|
+
wrapper.style.maskImage = fade;
|
|
77
|
+
wrapper.style.webkitMaskImage = fade;
|
|
78
|
+
wrapper.appendChild(clone);
|
|
79
|
+
container.appendChild(wrapper);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}),
|
|
84
|
+
dropTargetForElements({
|
|
85
|
+
element: reg.rowEl,
|
|
86
|
+
canDrop: ({ source }) => {
|
|
87
|
+
if (!options.isEnabled()) return false;
|
|
88
|
+
return source.data.kind === SOURCE_KIND && source.data.id !== rowId;
|
|
89
|
+
},
|
|
90
|
+
getIsSticky: () => true,
|
|
91
|
+
getData: ({ input, element }) => attachInstruction(
|
|
92
|
+
{ kind: `${SOURCE_KIND}-target`, id: rowId },
|
|
93
|
+
{
|
|
94
|
+
input,
|
|
95
|
+
element,
|
|
96
|
+
currentLevel: 0,
|
|
97
|
+
indentPerLevel: 0,
|
|
98
|
+
mode: "standard",
|
|
99
|
+
block: ["make-child", "reparent"]
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
onDrag: ({ self }) => {
|
|
103
|
+
const inst = extractInstruction(self.data);
|
|
104
|
+
if (!inst || inst.type === "instruction-blocked") {
|
|
105
|
+
if (instruction.value?.id === rowId) instruction.value = null;
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (inst.type === "reorder-above" || inst.type === "reorder-below") {
|
|
109
|
+
instruction.value = { id: rowId, type: inst.type };
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
onDragLeave: () => {
|
|
113
|
+
if (instruction.value?.id === rowId) instruction.value = null;
|
|
114
|
+
},
|
|
115
|
+
onDrop: ({ source, self }) => {
|
|
116
|
+
instruction.value = null;
|
|
117
|
+
const inst = extractInstruction(self.data);
|
|
118
|
+
if (!inst) return;
|
|
119
|
+
if (inst.type !== "reorder-above" && inst.type !== "reorder-below") return;
|
|
120
|
+
const sourceId = typeof source.data.id === "string" ? source.data.id : null;
|
|
121
|
+
if (!sourceId || sourceId === rowId) return;
|
|
122
|
+
options.onReorder(sourceId, rowId, inst.type);
|
|
123
|
+
}
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
function getReg(rowId) {
|
|
128
|
+
let reg = regs.get(rowId);
|
|
129
|
+
if (!reg) {
|
|
130
|
+
reg = { rowEl: null, handleEl: null, cleanup: null };
|
|
131
|
+
regs.set(rowId, reg);
|
|
132
|
+
}
|
|
133
|
+
return reg;
|
|
134
|
+
}
|
|
135
|
+
function purgeIfEmpty(rowId, reg) {
|
|
136
|
+
if (!reg.rowEl && !reg.handleEl && !reg.cleanup) regs.delete(rowId);
|
|
137
|
+
if (instruction.value?.id === rowId && !reg.rowEl) instruction.value = null;
|
|
138
|
+
}
|
|
139
|
+
function setRow(rowId, el) {
|
|
140
|
+
const reg = getReg(rowId);
|
|
141
|
+
if (reg.rowEl === el) return;
|
|
142
|
+
reg.rowEl = el;
|
|
143
|
+
rewire(rowId, reg);
|
|
144
|
+
purgeIfEmpty(rowId, reg);
|
|
145
|
+
}
|
|
146
|
+
function setHandle(rowId, el) {
|
|
147
|
+
const reg = getReg(rowId);
|
|
148
|
+
if (reg.handleEl === el) return;
|
|
149
|
+
reg.handleEl = el;
|
|
150
|
+
rewire(rowId, reg);
|
|
151
|
+
purgeIfEmpty(rowId, reg);
|
|
152
|
+
}
|
|
153
|
+
function instructionFor(rowId) {
|
|
154
|
+
return instruction.value?.id === rowId ? instruction.value.type : null;
|
|
155
|
+
}
|
|
156
|
+
onBeforeUnmount(() => {
|
|
157
|
+
for (const reg of regs.values()) reg.cleanup?.();
|
|
158
|
+
regs.clear();
|
|
159
|
+
instruction.value = null;
|
|
160
|
+
});
|
|
161
|
+
return { setRow, setHandle, instructionFor };
|
|
162
|
+
}
|