@adapttable/element-plus 0.1.2 → 0.2.0
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 +14 -0
- package/dist/assistant-BcVKhdKt.cjs +328 -0
- package/dist/assistant-BcVKhdKt.cjs.map +1 -0
- package/dist/assistant-Dv4a3KEk.js +305 -0
- package/dist/assistant-Dv4a3KEk.js.map +1 -0
- package/dist/assistant.cjs +5 -300
- package/dist/assistant.d.cts.map +1 -1
- package/dist/assistant.d.ts.map +1 -1
- package/dist/assistant.js +1 -296
- package/dist/column-menu-BUiQUex0.d.cts +34 -0
- package/dist/column-menu-BUiQUex0.d.cts.map +1 -0
- package/dist/column-menu-C0YWdhRz.d.ts +34 -0
- package/dist/column-menu-C0YWdhRz.d.ts.map +1 -0
- package/dist/column-menu.d.cts +2 -34
- package/dist/column-menu.d.ts +2 -34
- package/dist/features.cjs +212 -0
- package/dist/features.d.cts +35 -0
- package/dist/features.d.ts +35 -0
- package/dist/features.js +31 -0
- package/dist/filters-BJDFrg_k.d.ts +54 -0
- package/dist/filters-BJDFrg_k.d.ts.map +1 -0
- package/dist/filters-BYHvvws9.d.cts +54 -0
- package/dist/filters-BYHvvws9.d.cts.map +1 -0
- package/dist/filters.d.cts +2 -54
- package/dist/filters.d.ts +2 -54
- package/dist/grouping-panel-B8gWD_90.js +146 -0
- package/dist/grouping-panel-B8gWD_90.js.map +1 -0
- package/dist/grouping-panel-B9AcU8lx.cjs +150 -0
- package/dist/grouping-panel-B9AcU8lx.cjs.map +1 -0
- package/dist/grouping-panel.cjs +3 -145
- package/dist/grouping-panel.js +2 -145
- package/dist/header-filters-B2B5RqQS.d.ts +24 -0
- package/dist/header-filters-B2B5RqQS.d.ts.map +1 -0
- package/dist/header-filters-hGm_7LFO.d.cts +24 -0
- package/dist/header-filters-hGm_7LFO.d.cts.map +1 -0
- package/dist/header-filters.d.cts +2 -23
- package/dist/header-filters.d.ts +2 -23
- package/dist/preset.cjs +7 -7
- package/dist/preset.js +7 -7
- package/dist/row-actions-VRa4T6oF.d.cts +7 -0
- package/dist/row-actions-VRa4T6oF.d.cts.map +1 -0
- package/dist/row-actions-VRa4T6oF.d.ts +7 -0
- package/dist/row-actions-VRa4T6oF.d.ts.map +1 -0
- package/dist/row-actions.d.cts +2 -7
- package/dist/row-actions.d.ts +2 -7
- package/dist/row-pinning-B0WfYDZD.d.ts +8 -0
- package/dist/row-pinning-B0WfYDZD.d.ts.map +1 -0
- package/dist/row-pinning-LzBZmZcZ.d.cts +8 -0
- package/dist/row-pinning-LzBZmZcZ.d.cts.map +1 -0
- package/dist/row-pinning.d.cts +2 -8
- package/dist/row-pinning.d.ts +2 -8
- package/dist/row-reorder-BNscjPNy.cjs +161 -0
- package/dist/row-reorder-BNscjPNy.cjs.map +1 -0
- package/dist/row-reorder-kuiFvbsM.js +157 -0
- package/dist/row-reorder-kuiFvbsM.js.map +1 -0
- package/dist/row-reorder.cjs +2 -155
- package/dist/row-reorder.js +1 -156
- package/dist/rows.d.cts +2 -2
- package/dist/rows.d.ts +2 -2
- package/dist/styles.css +57 -57
- package/package.json +14 -3
- package/dist/assistant.cjs.map +0 -1
- package/dist/assistant.js.map +0 -1
- package/dist/column-menu.d.cts.map +0 -1
- package/dist/column-menu.d.ts.map +0 -1
- package/dist/filters.d.cts.map +0 -1
- package/dist/filters.d.ts.map +0 -1
- package/dist/grouping-panel.cjs.map +0 -1
- package/dist/grouping-panel.js.map +0 -1
- package/dist/header-filters.d.cts.map +0 -1
- package/dist/header-filters.d.ts.map +0 -1
- package/dist/row-actions.d.cts.map +0 -1
- package/dist/row-actions.d.ts.map +0 -1
- package/dist/row-pinning.d.cts.map +0 -1
- package/dist/row-pinning.d.ts.map +0 -1
- package/dist/row-reorder.cjs.map +0 -1
- package/dist/row-reorder.js.map +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RowAction, RowMutationHandlers, TableFeature } from "@adapttable/vue";
|
|
2
|
+
//#region src/row-actions.d.ts
|
|
3
|
+
/** The host owns actions; the kit contributes their optional native presentation. */
|
|
4
|
+
declare function rowActions<TRow>(actions?: readonly RowAction<TRow>[], handlers?: RowMutationHandlers<TRow>): TableFeature<TRow>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { rowActions as t };
|
|
7
|
+
//# sourceMappingURL=row-actions-VRa4T6oF.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-actions-VRa4T6oF.d.cts","names":[],"sources":["../src/row-actions.ts"],"mappings":";;;iBAagB,WAAW,MACzB,mBAAmB,UAAU,SAC7B,WAAW,oBAAoB,QAC9B,aAAa"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RowAction, RowMutationHandlers, TableFeature } from "@adapttable/vue";
|
|
2
|
+
//#region src/row-actions.d.ts
|
|
3
|
+
/** The host owns actions; the kit contributes their optional native presentation. */
|
|
4
|
+
declare function rowActions<TRow>(actions?: readonly RowAction<TRow>[], handlers?: RowMutationHandlers<TRow>): TableFeature<TRow>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { rowActions as t };
|
|
7
|
+
//# sourceMappingURL=row-actions-VRa4T6oF.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-actions-VRa4T6oF.d.ts","names":[],"sources":["../src/row-actions.ts"],"mappings":";;;iBAagB,WAAW,MACzB,mBAAmB,UAAU,SAC7B,WAAW,oBAAoB,QAC9B,aAAa"}
|
package/dist/row-actions.d.cts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/** The host owns actions; the kit contributes their optional native presentation. */
|
|
4
|
-
declare function rowActions<TRow>(actions?: readonly RowAction<TRow>[], handlers?: RowMutationHandlers<TRow>): TableFeature<TRow>;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { rowActions };
|
|
7
|
-
//# sourceMappingURL=row-actions.d.cts.map
|
|
1
|
+
import { t as rowActions } from "./row-actions-VRa4T6oF.cjs";
|
|
2
|
+
export { rowActions };
|
package/dist/row-actions.d.ts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/** The host owns actions; the kit contributes their optional native presentation. */
|
|
4
|
-
declare function rowActions<TRow>(actions?: readonly RowAction<TRow>[], handlers?: RowMutationHandlers<TRow>): TableFeature<TRow>;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { rowActions };
|
|
7
|
-
//# sourceMappingURL=row-actions.d.ts.map
|
|
1
|
+
import { t as rowActions } from "./row-actions-VRa4T6oF.js";
|
|
2
|
+
export { rowActions };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RowPinningFeatureOptions } from "@adapttable/vue/features";
|
|
2
|
+
import { StaticTableFeature } from "@adapttable/vue";
|
|
3
|
+
//#region src/row-pinning.d.ts
|
|
4
|
+
/** Pin controls share the same single native action presentation as rowActions(). */
|
|
5
|
+
declare function rowPinning$1(options?: RowPinningFeatureOptions): StaticTableFeature;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { rowPinning$1 as t };
|
|
8
|
+
//# sourceMappingURL=row-pinning-B0WfYDZD.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-pinning-B0WfYDZD.d.ts","names":[],"sources":["../src/row-pinning.ts"],"mappings":";;;;iBAYgB,aACd,UAAS,2BACR"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { StaticTableFeature } from "@adapttable/vue";
|
|
2
|
+
import { RowPinningFeatureOptions } from "@adapttable/vue/features";
|
|
3
|
+
//#region src/row-pinning.d.ts
|
|
4
|
+
/** Pin controls share the same single native action presentation as rowActions(). */
|
|
5
|
+
declare function rowPinning(options?: RowPinningFeatureOptions): StaticTableFeature;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { rowPinning as t };
|
|
8
|
+
//# sourceMappingURL=row-pinning-LzBZmZcZ.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-pinning-LzBZmZcZ.d.cts","names":[],"sources":["../src/row-pinning.ts"],"mappings":";;;;iBAYgB,WACd,UAAS,2BACR"}
|
package/dist/row-pinning.d.cts
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/row-pinning.d.ts
|
|
4
|
-
/** Pin controls share the same single native action presentation as rowActions(). */
|
|
5
|
-
declare function rowPinning(options?: RowPinningFeatureOptions): StaticTableFeature;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { rowPinning };
|
|
8
|
-
//# sourceMappingURL=row-pinning.d.cts.map
|
|
1
|
+
import { t as rowPinning } from "./row-pinning-LzBZmZcZ.cjs";
|
|
2
|
+
export { rowPinning };
|
package/dist/row-pinning.d.ts
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/row-pinning.d.ts
|
|
4
|
-
/** Pin controls share the same single native action presentation as rowActions(). */
|
|
5
|
-
declare function rowPinning(options?: RowPinningFeatureOptions): StaticTableFeature;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { rowPinning };
|
|
8
|
-
//# sourceMappingURL=row-pinning.d.ts.map
|
|
1
|
+
import { t as rowPinning } from "./row-pinning-B0WfYDZD.js";
|
|
2
|
+
export { rowPinning };
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
const require_button = require("./button-BFjBL9m3.cjs");
|
|
2
|
+
let vue = require("vue");
|
|
3
|
+
let _adapttable_vue_adapter = require("@adapttable/vue/adapter");
|
|
4
|
+
let element_plus = require("element-plus");
|
|
5
|
+
let _adapttable_vue_features = require("@adapttable/vue/features");
|
|
6
|
+
require("@adapttable/vue");
|
|
7
|
+
//#region src/reorder/ElementRowMoveMenu.ts
|
|
8
|
+
/** The shared controller owns target selection and pending confirmation. */
|
|
9
|
+
const ElementRowMoveMenu = (0, vue.defineComponent)((props) => {
|
|
10
|
+
const active = (0, _adapttable_vue_adapter.useScopeActivity)();
|
|
11
|
+
let lifetime = 0;
|
|
12
|
+
(0, vue.watch)(active, () => lifetime++, { flush: "sync" });
|
|
13
|
+
const trigger = (0, vue.shallowRef)();
|
|
14
|
+
const description = `adapttable-row-move-${(0, vue.useId)()}`;
|
|
15
|
+
return () => {
|
|
16
|
+
const live = active.value;
|
|
17
|
+
const ticket = lifetime;
|
|
18
|
+
const items = props.items;
|
|
19
|
+
const owner = props.confirmation;
|
|
20
|
+
const isCurrent = () => live && active.value && ticket === lifetime;
|
|
21
|
+
const finish = (kind) => {
|
|
22
|
+
if (!isCurrent() || !owner) return;
|
|
23
|
+
if (props.confirmation?.onConfirm === owner.onConfirm && props.confirmation.onCancel === owner.onCancel) owner[kind]();
|
|
24
|
+
};
|
|
25
|
+
return (0, vue.h)("span", { "data-adapttable-part": "row-move-menu" }, [(0, vue.h)(element_plus.ElSelect, {
|
|
26
|
+
ref: trigger,
|
|
27
|
+
modelValue: "",
|
|
28
|
+
placeholder: props.label,
|
|
29
|
+
"aria-label": props.label,
|
|
30
|
+
"data-adapttable-part": "row-move-menu-trigger",
|
|
31
|
+
teleported: false,
|
|
32
|
+
disabled: props.items.every((item) => item.disabled),
|
|
33
|
+
validateEvent: false,
|
|
34
|
+
"onUpdate:modelValue": (value) => {
|
|
35
|
+
if (!isCurrent()) return;
|
|
36
|
+
const item = items.find((item) => item.id === value);
|
|
37
|
+
if (item && !item.disabled) item.onSelect();
|
|
38
|
+
(0, vue.nextTick)(() => {
|
|
39
|
+
if (isCurrent()) trigger.value?.$forceUpdate();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}, { default: () => props.items.map((item) => (0, vue.h)(element_plus.ElOption, {
|
|
43
|
+
key: item.id,
|
|
44
|
+
value: item.id,
|
|
45
|
+
label: item.label,
|
|
46
|
+
disabled: item.disabled,
|
|
47
|
+
title: item.disabledReason,
|
|
48
|
+
"data-adapttable-part": "row-move-menu-item"
|
|
49
|
+
})) }), owner ? (0, vue.h)(element_plus.ElDialog, {
|
|
50
|
+
modelValue: active.value,
|
|
51
|
+
title: owner.title,
|
|
52
|
+
showClose: false,
|
|
53
|
+
destroyOnClose: true,
|
|
54
|
+
"data-adapttable-part": "row-move-confirmation",
|
|
55
|
+
"aria-describedby": description,
|
|
56
|
+
width: "min(28rem, calc(100vw - 2rem))",
|
|
57
|
+
appendToBody: false,
|
|
58
|
+
beforeClose: () => finish("onCancel")
|
|
59
|
+
}, {
|
|
60
|
+
default: () => (0, vue.h)("p", { id: description }, owner.description),
|
|
61
|
+
footer: () => [require_button.elementButton({
|
|
62
|
+
type: "button",
|
|
63
|
+
"data-adapttable-part": "row-move-cancel",
|
|
64
|
+
onClick: () => finish("onCancel")
|
|
65
|
+
}, owner.cancelLabel), require_button.elementButton({
|
|
66
|
+
type: "button",
|
|
67
|
+
"data-adapttable-part": "row-move-confirm",
|
|
68
|
+
onClick: () => finish("onConfirm")
|
|
69
|
+
}, owner.confirmLabel)]
|
|
70
|
+
}) : null]);
|
|
71
|
+
};
|
|
72
|
+
}, {
|
|
73
|
+
name: "ElementRowMoveMenu",
|
|
74
|
+
props: {
|
|
75
|
+
label: { type: String },
|
|
76
|
+
items: { type: Array },
|
|
77
|
+
confirmation: { type: Object }
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/reorder/elementReorderControls.ts
|
|
82
|
+
const elementReorderControls = {
|
|
83
|
+
Handle: ({ label, pressed, dragging, disabled, dragProps, onKeyDown, className }) => require_button.elementButton({
|
|
84
|
+
type: "button",
|
|
85
|
+
"aria-label": label,
|
|
86
|
+
"aria-pressed": pressed,
|
|
87
|
+
"data-dragging": dragging ? "" : void 0,
|
|
88
|
+
"data-adapttable-part": "row-reorder-handle",
|
|
89
|
+
"data-adapttable-grip": "",
|
|
90
|
+
class: className,
|
|
91
|
+
disabled,
|
|
92
|
+
draggable: dragProps.draggable,
|
|
93
|
+
onDragstart: (event) => {
|
|
94
|
+
if (event.dataTransfer) dragProps.onDragStart({
|
|
95
|
+
...event,
|
|
96
|
+
dataTransfer: event.dataTransfer,
|
|
97
|
+
clientY: event.clientY,
|
|
98
|
+
currentTarget: event.currentTarget instanceof HTMLElement ? event.currentTarget : null,
|
|
99
|
+
preventDefault: () => event.preventDefault()
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
onDragend: dragProps.onDragEnd,
|
|
103
|
+
onKeydown: (event) => onKeyDown({
|
|
104
|
+
key: event.key,
|
|
105
|
+
currentTarget: event.currentTarget instanceof HTMLElement ? event.currentTarget : null,
|
|
106
|
+
preventDefault: () => event.preventDefault()
|
|
107
|
+
})
|
|
108
|
+
}, "↕"),
|
|
109
|
+
Button: ({ label, part, disabled, onClick, className }) => require_button.elementButton({
|
|
110
|
+
type: "button",
|
|
111
|
+
"aria-label": label,
|
|
112
|
+
"data-adapttable-part": part,
|
|
113
|
+
class: className,
|
|
114
|
+
disabled,
|
|
115
|
+
onClick
|
|
116
|
+
}, label),
|
|
117
|
+
Menu: (props) => (0, vue.h)(ElementRowMoveMenu, props)
|
|
118
|
+
};
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/reorder/ElementRowReorder.vue
|
|
121
|
+
const _sfc_main = /*@__PURE__*/ (0, vue.defineComponent)({
|
|
122
|
+
__name: "ElementRowReorder",
|
|
123
|
+
props: {
|
|
124
|
+
model: {},
|
|
125
|
+
labels: {},
|
|
126
|
+
mobile: { type: Boolean },
|
|
127
|
+
classNames: {},
|
|
128
|
+
rowId: {},
|
|
129
|
+
localIndex: {},
|
|
130
|
+
row: {},
|
|
131
|
+
windowStart: {},
|
|
132
|
+
rowCount: {}
|
|
133
|
+
},
|
|
134
|
+
setup(__props) {
|
|
135
|
+
const props = __props;
|
|
136
|
+
const names = (0, _adapttable_vue_adapter.useDataTableClassNames)();
|
|
137
|
+
const Render = () => (0, _adapttable_vue_adapter.RowReorderChrome)({
|
|
138
|
+
...props,
|
|
139
|
+
classNames: { ...names.value },
|
|
140
|
+
slots: elementReorderControls
|
|
141
|
+
});
|
|
142
|
+
Render.props = [];
|
|
143
|
+
return (_ctx, _cache) => {
|
|
144
|
+
return (0, vue.openBlock)(), (0, vue.createBlock)(Render);
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/row-reorder.ts
|
|
150
|
+
function rowReorder(onRowReorder, options) {
|
|
151
|
+
return (0, _adapttable_vue_adapter.extendFeature)((0, _adapttable_vue_features.rowReorder)(onRowReorder, options), [(0, _adapttable_vue_adapter.slotRender)((0, _adapttable_vue_adapter.rowReorderControlKey)(), (props) => (0, vue.h)(_sfc_main, { ...props }))]);
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
Object.defineProperty(exports, "rowReorder", {
|
|
155
|
+
enumerable: true,
|
|
156
|
+
get: function() {
|
|
157
|
+
return rowReorder;
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
//# sourceMappingURL=row-reorder-BNscjPNy.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-reorder-BNscjPNy.cjs","names":["defineComponent","useScopeActivity","shallowRef","useId","h","ElSelect","nextTick","ElOption","ElDialog","elementButton","elementButton","h","extendFeature","bindingRowReorder","slotRender","rowReorderControlKey","h","ElementRowReorder"],"sources":["../src/reorder/ElementRowMoveMenu.ts","../src/reorder/elementReorderControls.ts","../src/reorder/ElementRowReorder.vue","../src/row-reorder.ts"],"sourcesContent":["import {\n type RowMoveMenuSlotProps,\n useScopeActivity,\n} from \"@adapttable/vue/adapter\";\nimport {\n ElDialog,\n ElOption,\n ElSelect,\n type SelectInstance,\n} from \"element-plus\";\nimport {\n defineComponent,\n h,\n nextTick,\n type PropType,\n shallowRef,\n useId,\n watch,\n} from \"vue\";\n\nimport { elementButton } from \"../controls/button\";\n/** The shared controller owns target selection and pending confirmation. */\nexport const ElementRowMoveMenu = defineComponent(\n (props: RowMoveMenuSlotProps) => {\n const active = useScopeActivity();\n let lifetime = 0;\n watch(active, () => lifetime++, { flush: \"sync\" });\n const trigger = shallowRef<SelectInstance>();\n const description = `adapttable-row-move-${useId()}`;\n return () => {\n const live = active.value;\n const ticket = lifetime;\n const items = props.items;\n const owner = props.confirmation;\n const isCurrent = () => live && active.value && ticket === lifetime;\n const finish = (kind: \"onConfirm\" | \"onCancel\") => {\n if (!isCurrent() || !owner) return;\n if (\n props.confirmation?.onConfirm === owner.onConfirm &&\n props.confirmation.onCancel === owner.onCancel\n )\n owner[kind]();\n };\n return h(\"span\", { \"data-adapttable-part\": \"row-move-menu\" }, [\n h(\n ElSelect,\n {\n ref: trigger,\n modelValue: \"\",\n placeholder: props.label,\n \"aria-label\": props.label,\n \"data-adapttable-part\": \"row-move-menu-trigger\",\n teleported: false,\n disabled: props.items.every((item) => item.disabled),\n validateEvent: false,\n \"onUpdate:modelValue\": (value: unknown) => {\n if (!isCurrent()) return;\n const item = items.find((item) => item.id === value);\n if (item && !item.disabled) item.onSelect();\n void nextTick(() => {\n if (isCurrent()) trigger.value?.$forceUpdate();\n });\n },\n },\n {\n default: () =>\n props.items.map((item) =>\n h(ElOption, {\n key: item.id,\n value: item.id,\n label: item.label,\n disabled: item.disabled,\n title: item.disabledReason,\n \"data-adapttable-part\": \"row-move-menu-item\",\n })\n ),\n }\n ),\n owner\n ? h(\n ElDialog,\n {\n modelValue: active.value,\n title: owner.title,\n showClose: false,\n destroyOnClose: true,\n \"data-adapttable-part\": \"row-move-confirmation\",\n \"aria-describedby\": description,\n width: \"min(28rem, calc(100vw - 2rem))\",\n appendToBody: false,\n beforeClose: () => finish(\"onCancel\"),\n },\n {\n default: () => h(\"p\", { id: description }, owner.description),\n footer: () => [\n elementButton(\n {\n type: \"button\",\n \"data-adapttable-part\": \"row-move-cancel\",\n onClick: () => finish(\"onCancel\"),\n },\n owner.cancelLabel\n ),\n elementButton(\n {\n type: \"button\",\n \"data-adapttable-part\": \"row-move-confirm\",\n onClick: () => finish(\"onConfirm\"),\n },\n owner.confirmLabel\n ),\n ],\n }\n )\n : null,\n ]);\n };\n },\n {\n name: \"ElementRowMoveMenu\",\n props: {\n label: { type: String as PropType<RowMoveMenuSlotProps[\"label\"]> },\n items: { type: Array as PropType<RowMoveMenuSlotProps[\"items\"]> },\n confirmation: {\n type: Object as PropType<RowMoveMenuSlotProps[\"confirmation\"]>,\n },\n },\n }\n);\n","import type { RowReorderControlSlots } from \"@adapttable/vue/adapter\";\nimport { h } from \"vue\";\n\nimport { elementButton } from \"../controls/button\";\nimport { ElementRowMoveMenu } from \"./ElementRowMoveMenu\";\n\nexport const elementReorderControls: RowReorderControlSlots = {\n Handle: ({\n label,\n pressed,\n dragging,\n disabled,\n dragProps,\n onKeyDown,\n className,\n }) =>\n elementButton(\n {\n type: \"button\",\n \"aria-label\": label,\n \"aria-pressed\": pressed,\n \"data-dragging\": dragging ? \"\" : undefined,\n \"data-adapttable-part\": \"row-reorder-handle\",\n \"data-adapttable-grip\": \"\",\n class: className,\n disabled,\n draggable: dragProps.draggable,\n onDragstart: (event: DragEvent) => {\n if (event.dataTransfer)\n dragProps.onDragStart({\n ...event,\n dataTransfer: event.dataTransfer,\n clientY: event.clientY,\n currentTarget:\n event.currentTarget instanceof HTMLElement\n ? event.currentTarget\n : null,\n preventDefault: () => event.preventDefault(),\n });\n },\n onDragend: dragProps.onDragEnd,\n onKeydown: (event: KeyboardEvent) =>\n onKeyDown({\n key: event.key,\n currentTarget:\n event.currentTarget instanceof HTMLElement\n ? event.currentTarget\n : null,\n preventDefault: () => event.preventDefault(),\n }),\n },\n \"↕\"\n ),\n Button: ({ label, part, disabled, onClick, className }) =>\n elementButton(\n {\n type: \"button\",\n \"aria-label\": label,\n \"data-adapttable-part\": part,\n class: className,\n disabled,\n onClick,\n },\n label\n ),\n Menu: (props) => h(ElementRowMoveMenu, props),\n};\n","<script setup lang=\"ts\" generic=\"TRow\">\nimport {\n RowReorderChrome,\n type RowReorderControlProps,\n} from \"@adapttable/vue/adapter\";\n\nimport { useClassNames } from \"../classNamesContext\";\nimport { elementReorderControls } from \"./elementReorderControls\";\n\nconst props = defineProps<RowReorderControlProps<TRow>>();\nconst names = useClassNames();\nconst Render = () =>\n RowReorderChrome({\n ...props,\n classNames: { ...names.value },\n slots: elementReorderControls,\n });\n\n// Declare no props so Vue forwards all root attributes, including id and data-*.\nconst renderProps: string[] = [];\nRender.props = renderProps;\n</script>\n\n<template>\n <Render />\n</template>\n","import type {\n RowReorderHandler,\n RowReorderOptions,\n TableFeature,\n} from \"@adapttable/vue\";\nimport {\n extendFeature,\n rowReorderControlKey,\n slotRender,\n} from \"@adapttable/vue/adapter\";\nimport { rowReorder as bindingRowReorder } from \"@adapttable/vue/features\";\nimport { h } from \"vue\";\n\nimport ElementRowReorder from \"./reorder/ElementRowReorder.vue\";\nexport {\n type RowReorderHandler,\n type RowReorderOptions,\n useRowReorder,\n} from \"@adapttable/vue\";\nexport function rowReorder<TRow>(\n onRowReorder: RowReorderHandler<TRow>,\n options?: RowReorderOptions<TRow>\n): TableFeature<TRow> {\n return extendFeature(bindingRowReorder(onRowReorder, options), [\n slotRender(rowReorderControlKey<TRow>(), (props) =>\n h(ElementRowReorder<TRow>, { ...props })\n ),\n ]);\n}\n"],"mappings":";;;;;;;;AAsBA,MAAa,sBAAA,GAAqBA,IAAAA,gBAAAA,EAC/B,UAAgC;CAC/B,MAAM,UAAA,GAASC,wBAAAA,iBAAAA,CAAiB;CAChC,IAAI,WAAW;CACf,CAAA,GAAA,IAAA,MAAA,CAAM,cAAc,YAAY,EAAE,OAAO,OAAO,CAAC;CACjD,MAAM,WAAA,GAAUC,IAAAA,WAAAA,CAA2B;CAC3C,MAAM,cAAc,wBAAA,GAAuBC,IAAAA,MAAAA,CAAM;CACjD,aAAa;EACX,MAAM,OAAO,OAAO;EACpB,MAAM,SAAS;EACf,MAAM,QAAQ,MAAM;EACpB,MAAM,QAAQ,MAAM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AA,iBAAA,CAAiB;GACf,GAAG;GACH,YAAY,EAAE,GAAG,MAAM,MAAM;GAC7B,OAAO;EACT,CAAC;EAIH,OAAO,QAAQ,CAAA;;GAIb,QAAA,GAAA,IAAA,UAAA,CAAA,IAAA,GAAA,IAAA,YAAA,CAAU,MAAA;;;;;;ACLZ,SAAgB,WACd,cACA,SACoB;CACpB,QAAA,GAAOC,wBAAAA,cAAAA,EAAAA,GAAcC,yBAAAA,WAAAA,CAAkB,cAAc,OAAO,GAAG,EAAA,GAC7DC,wBAAAA,WAAAA,EAAAA,GAAWC,wBAAAA,qBAAAA,CAA2B,IAAI,WAAA,GACxCC,IAAAA,EAAAA,CAAEC,WAAyB,EAAE,GAAG,MAAM,CAAC,CACzC,CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { n as useClassNames } from "./classNamesContext-18Wbxy4F.js";
|
|
2
|
+
import { t as elementButton } from "./button-DwB4UxI2.js";
|
|
3
|
+
import { createBlock, defineComponent, h, nextTick, openBlock, shallowRef, useId, watch } from "vue";
|
|
4
|
+
import { RowReorderChrome, extendFeature, rowReorderControlKey, slotRender, useScopeActivity } from "@adapttable/vue/adapter";
|
|
5
|
+
import { ElDialog, ElOption, ElSelect } from "element-plus";
|
|
6
|
+
import { rowReorder } from "@adapttable/vue/features";
|
|
7
|
+
import { useRowReorder } from "@adapttable/vue";
|
|
8
|
+
//#region src/reorder/ElementRowMoveMenu.ts
|
|
9
|
+
/** The shared controller owns target selection and pending confirmation. */
|
|
10
|
+
const ElementRowMoveMenu = defineComponent((props) => {
|
|
11
|
+
const active = useScopeActivity();
|
|
12
|
+
let lifetime = 0;
|
|
13
|
+
watch(active, () => lifetime++, { flush: "sync" });
|
|
14
|
+
const trigger = shallowRef();
|
|
15
|
+
const description = `adapttable-row-move-${useId()}`;
|
|
16
|
+
return () => {
|
|
17
|
+
const live = active.value;
|
|
18
|
+
const ticket = lifetime;
|
|
19
|
+
const items = props.items;
|
|
20
|
+
const owner = props.confirmation;
|
|
21
|
+
const isCurrent = () => live && active.value && ticket === lifetime;
|
|
22
|
+
const finish = (kind) => {
|
|
23
|
+
if (!isCurrent() || !owner) return;
|
|
24
|
+
if (props.confirmation?.onConfirm === owner.onConfirm && props.confirmation.onCancel === owner.onCancel) owner[kind]();
|
|
25
|
+
};
|
|
26
|
+
return h("span", { "data-adapttable-part": "row-move-menu" }, [h(ElSelect, {
|
|
27
|
+
ref: trigger,
|
|
28
|
+
modelValue: "",
|
|
29
|
+
placeholder: props.label,
|
|
30
|
+
"aria-label": props.label,
|
|
31
|
+
"data-adapttable-part": "row-move-menu-trigger",
|
|
32
|
+
teleported: false,
|
|
33
|
+
disabled: props.items.every((item) => item.disabled),
|
|
34
|
+
validateEvent: false,
|
|
35
|
+
"onUpdate:modelValue": (value) => {
|
|
36
|
+
if (!isCurrent()) return;
|
|
37
|
+
const item = items.find((item) => item.id === value);
|
|
38
|
+
if (item && !item.disabled) item.onSelect();
|
|
39
|
+
nextTick(() => {
|
|
40
|
+
if (isCurrent()) trigger.value?.$forceUpdate();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}, { default: () => props.items.map((item) => h(ElOption, {
|
|
44
|
+
key: item.id,
|
|
45
|
+
value: item.id,
|
|
46
|
+
label: item.label,
|
|
47
|
+
disabled: item.disabled,
|
|
48
|
+
title: item.disabledReason,
|
|
49
|
+
"data-adapttable-part": "row-move-menu-item"
|
|
50
|
+
})) }), owner ? h(ElDialog, {
|
|
51
|
+
modelValue: active.value,
|
|
52
|
+
title: owner.title,
|
|
53
|
+
showClose: false,
|
|
54
|
+
destroyOnClose: true,
|
|
55
|
+
"data-adapttable-part": "row-move-confirmation",
|
|
56
|
+
"aria-describedby": description,
|
|
57
|
+
width: "min(28rem, calc(100vw - 2rem))",
|
|
58
|
+
appendToBody: false,
|
|
59
|
+
beforeClose: () => finish("onCancel")
|
|
60
|
+
}, {
|
|
61
|
+
default: () => h("p", { id: description }, owner.description),
|
|
62
|
+
footer: () => [elementButton({
|
|
63
|
+
type: "button",
|
|
64
|
+
"data-adapttable-part": "row-move-cancel",
|
|
65
|
+
onClick: () => finish("onCancel")
|
|
66
|
+
}, owner.cancelLabel), elementButton({
|
|
67
|
+
type: "button",
|
|
68
|
+
"data-adapttable-part": "row-move-confirm",
|
|
69
|
+
onClick: () => finish("onConfirm")
|
|
70
|
+
}, owner.confirmLabel)]
|
|
71
|
+
}) : null]);
|
|
72
|
+
};
|
|
73
|
+
}, {
|
|
74
|
+
name: "ElementRowMoveMenu",
|
|
75
|
+
props: {
|
|
76
|
+
label: { type: String },
|
|
77
|
+
items: { type: Array },
|
|
78
|
+
confirmation: { type: Object }
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/reorder/elementReorderControls.ts
|
|
83
|
+
const elementReorderControls = {
|
|
84
|
+
Handle: ({ label, pressed, dragging, disabled, dragProps, onKeyDown, className }) => elementButton({
|
|
85
|
+
type: "button",
|
|
86
|
+
"aria-label": label,
|
|
87
|
+
"aria-pressed": pressed,
|
|
88
|
+
"data-dragging": dragging ? "" : void 0,
|
|
89
|
+
"data-adapttable-part": "row-reorder-handle",
|
|
90
|
+
"data-adapttable-grip": "",
|
|
91
|
+
class: className,
|
|
92
|
+
disabled,
|
|
93
|
+
draggable: dragProps.draggable,
|
|
94
|
+
onDragstart: (event) => {
|
|
95
|
+
if (event.dataTransfer) dragProps.onDragStart({
|
|
96
|
+
...event,
|
|
97
|
+
dataTransfer: event.dataTransfer,
|
|
98
|
+
clientY: event.clientY,
|
|
99
|
+
currentTarget: event.currentTarget instanceof HTMLElement ? event.currentTarget : null,
|
|
100
|
+
preventDefault: () => event.preventDefault()
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
onDragend: dragProps.onDragEnd,
|
|
104
|
+
onKeydown: (event) => onKeyDown({
|
|
105
|
+
key: event.key,
|
|
106
|
+
currentTarget: event.currentTarget instanceof HTMLElement ? event.currentTarget : null,
|
|
107
|
+
preventDefault: () => event.preventDefault()
|
|
108
|
+
})
|
|
109
|
+
}, "↕"),
|
|
110
|
+
Button: ({ label, part, disabled, onClick, className }) => elementButton({
|
|
111
|
+
type: "button",
|
|
112
|
+
"aria-label": label,
|
|
113
|
+
"data-adapttable-part": part,
|
|
114
|
+
class: className,
|
|
115
|
+
disabled,
|
|
116
|
+
onClick
|
|
117
|
+
}, label),
|
|
118
|
+
Menu: (props) => h(ElementRowMoveMenu, props)
|
|
119
|
+
};
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/reorder/ElementRowReorder.vue
|
|
122
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
123
|
+
__name: "ElementRowReorder",
|
|
124
|
+
props: {
|
|
125
|
+
model: {},
|
|
126
|
+
labels: {},
|
|
127
|
+
mobile: { type: Boolean },
|
|
128
|
+
classNames: {},
|
|
129
|
+
rowId: {},
|
|
130
|
+
localIndex: {},
|
|
131
|
+
row: {},
|
|
132
|
+
windowStart: {},
|
|
133
|
+
rowCount: {}
|
|
134
|
+
},
|
|
135
|
+
setup(__props) {
|
|
136
|
+
const props = __props;
|
|
137
|
+
const names = useClassNames();
|
|
138
|
+
const Render = () => RowReorderChrome({
|
|
139
|
+
...props,
|
|
140
|
+
classNames: { ...names.value },
|
|
141
|
+
slots: elementReorderControls
|
|
142
|
+
});
|
|
143
|
+
Render.props = [];
|
|
144
|
+
return (_ctx, _cache) => {
|
|
145
|
+
return openBlock(), createBlock(Render);
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/row-reorder.ts
|
|
151
|
+
function rowReorder$1(onRowReorder, options) {
|
|
152
|
+
return extendFeature(rowReorder(onRowReorder, options), [slotRender(rowReorderControlKey(), (props) => h(_sfc_main, { ...props }))]);
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
155
|
+
export { useRowReorder as n, rowReorder$1 as t };
|
|
156
|
+
|
|
157
|
+
//# sourceMappingURL=row-reorder-kuiFvbsM.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-reorder-kuiFvbsM.js","names":["rowReorder","bindingRowReorder","ElementRowReorder"],"sources":["../src/reorder/ElementRowMoveMenu.ts","../src/reorder/elementReorderControls.ts","../src/reorder/ElementRowReorder.vue","../src/row-reorder.ts"],"sourcesContent":["import {\n type RowMoveMenuSlotProps,\n useScopeActivity,\n} from \"@adapttable/vue/adapter\";\nimport {\n ElDialog,\n ElOption,\n ElSelect,\n type SelectInstance,\n} from \"element-plus\";\nimport {\n defineComponent,\n h,\n nextTick,\n type PropType,\n shallowRef,\n useId,\n watch,\n} from \"vue\";\n\nimport { elementButton } from \"../controls/button\";\n/** The shared controller owns target selection and pending confirmation. */\nexport const ElementRowMoveMenu = defineComponent(\n (props: RowMoveMenuSlotProps) => {\n const active = useScopeActivity();\n let lifetime = 0;\n watch(active, () => lifetime++, { flush: \"sync\" });\n const trigger = shallowRef<SelectInstance>();\n const description = `adapttable-row-move-${useId()}`;\n return () => {\n const live = active.value;\n const ticket = lifetime;\n const items = props.items;\n const owner = props.confirmation;\n const isCurrent = () => live && active.value && ticket === lifetime;\n const finish = (kind: \"onConfirm\" | \"onCancel\") => {\n if (!isCurrent() || !owner) return;\n if (\n props.confirmation?.onConfirm === owner.onConfirm &&\n props.confirmation.onCancel === owner.onCancel\n )\n owner[kind]();\n };\n return h(\"span\", { \"data-adapttable-part\": \"row-move-menu\" }, [\n h(\n ElSelect,\n {\n ref: trigger,\n modelValue: \"\",\n placeholder: props.label,\n \"aria-label\": props.label,\n \"data-adapttable-part\": \"row-move-menu-trigger\",\n teleported: false,\n disabled: props.items.every((item) => item.disabled),\n validateEvent: false,\n \"onUpdate:modelValue\": (value: unknown) => {\n if (!isCurrent()) return;\n const item = items.find((item) => item.id === value);\n if (item && !item.disabled) item.onSelect();\n void nextTick(() => {\n if (isCurrent()) trigger.value?.$forceUpdate();\n });\n },\n },\n {\n default: () =>\n props.items.map((item) =>\n h(ElOption, {\n key: item.id,\n value: item.id,\n label: item.label,\n disabled: item.disabled,\n title: item.disabledReason,\n \"data-adapttable-part\": \"row-move-menu-item\",\n })\n ),\n }\n ),\n owner\n ? h(\n ElDialog,\n {\n modelValue: active.value,\n title: owner.title,\n showClose: false,\n destroyOnClose: true,\n \"data-adapttable-part\": \"row-move-confirmation\",\n \"aria-describedby\": description,\n width: \"min(28rem, calc(100vw - 2rem))\",\n appendToBody: false,\n beforeClose: () => finish(\"onCancel\"),\n },\n {\n default: () => h(\"p\", { id: description }, owner.description),\n footer: () => [\n elementButton(\n {\n type: \"button\",\n \"data-adapttable-part\": \"row-move-cancel\",\n onClick: () => finish(\"onCancel\"),\n },\n owner.cancelLabel\n ),\n elementButton(\n {\n type: \"button\",\n \"data-adapttable-part\": \"row-move-confirm\",\n onClick: () => finish(\"onConfirm\"),\n },\n owner.confirmLabel\n ),\n ],\n }\n )\n : null,\n ]);\n };\n },\n {\n name: \"ElementRowMoveMenu\",\n props: {\n label: { type: String as PropType<RowMoveMenuSlotProps[\"label\"]> },\n items: { type: Array as PropType<RowMoveMenuSlotProps[\"items\"]> },\n confirmation: {\n type: Object as PropType<RowMoveMenuSlotProps[\"confirmation\"]>,\n },\n },\n }\n);\n","import type { RowReorderControlSlots } from \"@adapttable/vue/adapter\";\nimport { h } from \"vue\";\n\nimport { elementButton } from \"../controls/button\";\nimport { ElementRowMoveMenu } from \"./ElementRowMoveMenu\";\n\nexport const elementReorderControls: RowReorderControlSlots = {\n Handle: ({\n label,\n pressed,\n dragging,\n disabled,\n dragProps,\n onKeyDown,\n className,\n }) =>\n elementButton(\n {\n type: \"button\",\n \"aria-label\": label,\n \"aria-pressed\": pressed,\n \"data-dragging\": dragging ? \"\" : undefined,\n \"data-adapttable-part\": \"row-reorder-handle\",\n \"data-adapttable-grip\": \"\",\n class: className,\n disabled,\n draggable: dragProps.draggable,\n onDragstart: (event: DragEvent) => {\n if (event.dataTransfer)\n dragProps.onDragStart({\n ...event,\n dataTransfer: event.dataTransfer,\n clientY: event.clientY,\n currentTarget:\n event.currentTarget instanceof HTMLElement\n ? event.currentTarget\n : null,\n preventDefault: () => event.preventDefault(),\n });\n },\n onDragend: dragProps.onDragEnd,\n onKeydown: (event: KeyboardEvent) =>\n onKeyDown({\n key: event.key,\n currentTarget:\n event.currentTarget instanceof HTMLElement\n ? event.currentTarget\n : null,\n preventDefault: () => event.preventDefault(),\n }),\n },\n \"↕\"\n ),\n Button: ({ label, part, disabled, onClick, className }) =>\n elementButton(\n {\n type: \"button\",\n \"aria-label\": label,\n \"data-adapttable-part\": part,\n class: className,\n disabled,\n onClick,\n },\n label\n ),\n Menu: (props) => h(ElementRowMoveMenu, props),\n};\n","<script setup lang=\"ts\" generic=\"TRow\">\nimport {\n RowReorderChrome,\n type RowReorderControlProps,\n} from \"@adapttable/vue/adapter\";\n\nimport { useClassNames } from \"../classNamesContext\";\nimport { elementReorderControls } from \"./elementReorderControls\";\n\nconst props = defineProps<RowReorderControlProps<TRow>>();\nconst names = useClassNames();\nconst Render = () =>\n RowReorderChrome({\n ...props,\n classNames: { ...names.value },\n slots: elementReorderControls,\n });\n\n// Declare no props so Vue forwards all root attributes, including id and data-*.\nconst renderProps: string[] = [];\nRender.props = renderProps;\n</script>\n\n<template>\n <Render />\n</template>\n","import type {\n RowReorderHandler,\n RowReorderOptions,\n TableFeature,\n} from \"@adapttable/vue\";\nimport {\n extendFeature,\n rowReorderControlKey,\n slotRender,\n} from \"@adapttable/vue/adapter\";\nimport { rowReorder as bindingRowReorder } from \"@adapttable/vue/features\";\nimport { h } from \"vue\";\n\nimport ElementRowReorder from \"./reorder/ElementRowReorder.vue\";\nexport {\n type RowReorderHandler,\n type RowReorderOptions,\n useRowReorder,\n} from \"@adapttable/vue\";\nexport function rowReorder<TRow>(\n onRowReorder: RowReorderHandler<TRow>,\n options?: RowReorderOptions<TRow>\n): TableFeature<TRow> {\n return extendFeature(bindingRowReorder(onRowReorder, options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CACF,GACA,KACF;CACF,OAAO,UAAU,EAAE,oBAAoB,KAAK;AAC9C;;;;;;;;;;;;;;;;;ECzDA,MAAM,QAAQ;EACd,MAAM,QAAQ,cAAc;EAC5B,MAAM,eACJ,iBAAiB;GACf,GAAG;GACH,YAAY,EAAE,GAAG,MAAM,MAAM;GAC7B,OAAO;EACT,CAAC;EAIH,OAAO,QAAQ,CAAA;;GAIb,OAAA,UAAA,GAAA,YAAU,MAAA;;;;;;ACLZ,SAAgBA,aACd,cACA,SACoB;CACpB,OAAO,cAAcC,WAAkB,cAAc,OAAO,GAAG,CAC7D,WAAW,qBAA2B,IAAI,UACxC,EAAEC,WAAyB,EAAE,GAAG,MAAM,CAAC,CACzC,CACF,CAAC;AACH"}
|
package/dist/row-reorder.cjs
CHANGED
|
@@ -1,163 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
let vue = require("vue");
|
|
4
|
-
let _adapttable_vue_adapter = require("@adapttable/vue/adapter");
|
|
5
|
-
let element_plus = require("element-plus");
|
|
6
|
-
let _adapttable_vue_features = require("@adapttable/vue/features");
|
|
2
|
+
const require_row_reorder = require("./row-reorder-BNscjPNy.cjs");
|
|
7
3
|
let _adapttable_vue = require("@adapttable/vue");
|
|
8
|
-
|
|
9
|
-
/** The shared controller owns target selection and pending confirmation. */
|
|
10
|
-
const ElementRowMoveMenu = (0, vue.defineComponent)((props) => {
|
|
11
|
-
const active = (0, _adapttable_vue_adapter.useScopeActivity)();
|
|
12
|
-
let lifetime = 0;
|
|
13
|
-
(0, vue.watch)(active, () => lifetime++, { flush: "sync" });
|
|
14
|
-
const trigger = (0, vue.shallowRef)();
|
|
15
|
-
const description = `adapttable-row-move-${(0, vue.useId)()}`;
|
|
16
|
-
return () => {
|
|
17
|
-
const live = active.value;
|
|
18
|
-
const ticket = lifetime;
|
|
19
|
-
const items = props.items;
|
|
20
|
-
const owner = props.confirmation;
|
|
21
|
-
const isCurrent = () => live && active.value && ticket === lifetime;
|
|
22
|
-
const finish = (kind) => {
|
|
23
|
-
if (!isCurrent() || !owner) return;
|
|
24
|
-
if (props.confirmation?.onConfirm === owner.onConfirm && props.confirmation.onCancel === owner.onCancel) owner[kind]();
|
|
25
|
-
};
|
|
26
|
-
return (0, vue.h)("span", { "data-adapttable-part": "row-move-menu" }, [(0, vue.h)(element_plus.ElSelect, {
|
|
27
|
-
ref: trigger,
|
|
28
|
-
modelValue: "",
|
|
29
|
-
placeholder: props.label,
|
|
30
|
-
"aria-label": props.label,
|
|
31
|
-
"data-adapttable-part": "row-move-menu-trigger",
|
|
32
|
-
teleported: false,
|
|
33
|
-
disabled: props.items.every((item) => item.disabled),
|
|
34
|
-
validateEvent: false,
|
|
35
|
-
"onUpdate:modelValue": (value) => {
|
|
36
|
-
if (!isCurrent()) return;
|
|
37
|
-
const item = items.find((item) => item.id === value);
|
|
38
|
-
if (item && !item.disabled) item.onSelect();
|
|
39
|
-
(0, vue.nextTick)(() => {
|
|
40
|
-
if (isCurrent()) trigger.value?.$forceUpdate();
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}, { default: () => props.items.map((item) => (0, vue.h)(element_plus.ElOption, {
|
|
44
|
-
key: item.id,
|
|
45
|
-
value: item.id,
|
|
46
|
-
label: item.label,
|
|
47
|
-
disabled: item.disabled,
|
|
48
|
-
title: item.disabledReason,
|
|
49
|
-
"data-adapttable-part": "row-move-menu-item"
|
|
50
|
-
})) }), owner ? (0, vue.h)(element_plus.ElDialog, {
|
|
51
|
-
modelValue: active.value,
|
|
52
|
-
title: owner.title,
|
|
53
|
-
showClose: false,
|
|
54
|
-
destroyOnClose: true,
|
|
55
|
-
"data-adapttable-part": "row-move-confirmation",
|
|
56
|
-
"aria-describedby": description,
|
|
57
|
-
width: "min(28rem, calc(100vw - 2rem))",
|
|
58
|
-
appendToBody: false,
|
|
59
|
-
beforeClose: () => finish("onCancel")
|
|
60
|
-
}, {
|
|
61
|
-
default: () => (0, vue.h)("p", { id: description }, owner.description),
|
|
62
|
-
footer: () => [require_button.elementButton({
|
|
63
|
-
type: "button",
|
|
64
|
-
"data-adapttable-part": "row-move-cancel",
|
|
65
|
-
onClick: () => finish("onCancel")
|
|
66
|
-
}, owner.cancelLabel), require_button.elementButton({
|
|
67
|
-
type: "button",
|
|
68
|
-
"data-adapttable-part": "row-move-confirm",
|
|
69
|
-
onClick: () => finish("onConfirm")
|
|
70
|
-
}, owner.confirmLabel)]
|
|
71
|
-
}) : null]);
|
|
72
|
-
};
|
|
73
|
-
}, {
|
|
74
|
-
name: "ElementRowMoveMenu",
|
|
75
|
-
props: {
|
|
76
|
-
label: { type: String },
|
|
77
|
-
items: { type: Array },
|
|
78
|
-
confirmation: { type: Object }
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
//#endregion
|
|
82
|
-
//#region src/reorder/elementReorderControls.ts
|
|
83
|
-
const elementReorderControls = {
|
|
84
|
-
Handle: ({ label, pressed, dragging, disabled, dragProps, onKeyDown, className }) => require_button.elementButton({
|
|
85
|
-
type: "button",
|
|
86
|
-
"aria-label": label,
|
|
87
|
-
"aria-pressed": pressed,
|
|
88
|
-
"data-dragging": dragging ? "" : void 0,
|
|
89
|
-
"data-adapttable-part": "row-reorder-handle",
|
|
90
|
-
"data-adapttable-grip": "",
|
|
91
|
-
class: className,
|
|
92
|
-
disabled,
|
|
93
|
-
draggable: dragProps.draggable,
|
|
94
|
-
onDragstart: (event) => {
|
|
95
|
-
if (event.dataTransfer) dragProps.onDragStart({
|
|
96
|
-
...event,
|
|
97
|
-
dataTransfer: event.dataTransfer,
|
|
98
|
-
clientY: event.clientY,
|
|
99
|
-
currentTarget: event.currentTarget instanceof HTMLElement ? event.currentTarget : null,
|
|
100
|
-
preventDefault: () => event.preventDefault()
|
|
101
|
-
});
|
|
102
|
-
},
|
|
103
|
-
onDragend: dragProps.onDragEnd,
|
|
104
|
-
onKeydown: (event) => onKeyDown({
|
|
105
|
-
key: event.key,
|
|
106
|
-
currentTarget: event.currentTarget instanceof HTMLElement ? event.currentTarget : null,
|
|
107
|
-
preventDefault: () => event.preventDefault()
|
|
108
|
-
})
|
|
109
|
-
}, "↕"),
|
|
110
|
-
Button: ({ label, part, disabled, onClick, className }) => require_button.elementButton({
|
|
111
|
-
type: "button",
|
|
112
|
-
"aria-label": label,
|
|
113
|
-
"data-adapttable-part": part,
|
|
114
|
-
class: className,
|
|
115
|
-
disabled,
|
|
116
|
-
onClick
|
|
117
|
-
}, label),
|
|
118
|
-
Menu: (props) => (0, vue.h)(ElementRowMoveMenu, props)
|
|
119
|
-
};
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/reorder/ElementRowReorder.vue
|
|
122
|
-
const _sfc_main = /*@__PURE__*/ (0, vue.defineComponent)({
|
|
123
|
-
__name: "ElementRowReorder",
|
|
124
|
-
props: {
|
|
125
|
-
model: {},
|
|
126
|
-
labels: {},
|
|
127
|
-
mobile: { type: Boolean },
|
|
128
|
-
classNames: {},
|
|
129
|
-
rowId: {},
|
|
130
|
-
localIndex: {},
|
|
131
|
-
row: {},
|
|
132
|
-
windowStart: {},
|
|
133
|
-
rowCount: {}
|
|
134
|
-
},
|
|
135
|
-
setup(__props) {
|
|
136
|
-
const props = __props;
|
|
137
|
-
const names = (0, _adapttable_vue_adapter.useDataTableClassNames)();
|
|
138
|
-
const Render = () => (0, _adapttable_vue_adapter.RowReorderChrome)({
|
|
139
|
-
...props,
|
|
140
|
-
classNames: { ...names.value },
|
|
141
|
-
slots: elementReorderControls
|
|
142
|
-
});
|
|
143
|
-
Render.props = [];
|
|
144
|
-
return (_ctx, _cache) => {
|
|
145
|
-
return (0, vue.openBlock)(), (0, vue.createBlock)(Render);
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
//#endregion
|
|
150
|
-
//#region src/row-reorder.ts
|
|
151
|
-
function rowReorder(onRowReorder, options) {
|
|
152
|
-
return (0, _adapttable_vue_adapter.extendFeature)((0, _adapttable_vue_features.rowReorder)(onRowReorder, options), [(0, _adapttable_vue_adapter.slotRender)((0, _adapttable_vue_adapter.rowReorderControlKey)(), (props) => (0, vue.h)(_sfc_main, { ...props }))]);
|
|
153
|
-
}
|
|
154
|
-
//#endregion
|
|
155
|
-
exports.rowReorder = rowReorder;
|
|
4
|
+
exports.rowReorder = require_row_reorder.rowReorder;
|
|
156
5
|
Object.defineProperty(exports, "useRowReorder", {
|
|
157
6
|
enumerable: true,
|
|
158
7
|
get: function() {
|
|
159
8
|
return _adapttable_vue.useRowReorder;
|
|
160
9
|
}
|
|
161
10
|
});
|
|
162
|
-
|
|
163
|
-
//# sourceMappingURL=row-reorder.cjs.map
|