@adapttable/naive-ui 0.5.0 → 0.6.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 +5 -5
- package/dist/{NaiveRowActions-BR140413.cjs → NaiveRowActions-DUlkorWa.cjs} +2 -2
- package/dist/NaiveRowActions-DUlkorWa.cjs.map +1 -0
- package/dist/{NaiveRowActions-DVyMXQJq.js → NaiveRowActions-DdHuWGCQ.js} +2 -2
- package/dist/NaiveRowActions-DdHuWGCQ.js.map +1 -0
- package/dist/assistant.cjs +360 -5
- package/dist/assistant.cjs.map +1 -0
- package/dist/assistant.js +356 -1
- package/dist/assistant.js.map +1 -0
- package/dist/batch-editing.cjs +1 -1
- package/dist/batch-editing.d.cts +1 -1
- package/dist/batch-editing.d.ts +1 -1
- package/dist/batch-editing.js +1 -1
- package/dist/cell-navigation.cjs.map +1 -1
- package/dist/cell-navigation.d.cts +1 -1
- package/dist/cell-navigation.d.cts.map +1 -1
- package/dist/cell-navigation.d.ts +1 -1
- package/dist/cell-navigation.d.ts.map +1 -1
- package/dist/cell-navigation.js.map +1 -1
- package/dist/column-layout.cjs +24 -0
- package/dist/column-layout.cjs.map +1 -0
- package/dist/column-layout.d.cts +12 -0
- package/dist/column-layout.d.cts.map +1 -0
- package/dist/column-layout.d.ts +12 -0
- package/dist/column-layout.d.ts.map +1 -0
- package/dist/column-layout.js +22 -0
- package/dist/column-layout.js.map +1 -0
- package/dist/{column-menu-GUeADLrH.cjs → column-menu-B-EhL5Ih.cjs} +3 -3
- package/dist/{column-menu-GUeADLrH.cjs.map → column-menu-B-EhL5Ih.cjs.map} +1 -1
- package/dist/{column-menu-BeNblq2u.js → column-menu-BwKtCGEo.js} +3 -3
- package/dist/{column-menu-BeNblq2u.js.map → column-menu-BwKtCGEo.js.map} +1 -1
- package/dist/column-menu.cjs +1 -1
- package/dist/column-menu.d.cts +24 -2
- package/dist/column-menu.d.cts.map +1 -0
- package/dist/column-menu.d.ts +24 -2
- package/dist/column-menu.d.ts.map +1 -0
- package/dist/column-menu.js +1 -1
- package/dist/command-palette.cjs +112 -2
- package/dist/command-palette.cjs.map +1 -0
- package/dist/command-palette.js +111 -1
- package/dist/command-palette.js.map +1 -0
- package/dist/context-menu.cjs +140 -2
- package/dist/context-menu.cjs.map +1 -0
- package/dist/context-menu.js +139 -1
- package/dist/context-menu.js.map +1 -0
- package/dist/{editing-DTOBwNI6.js → editing-Btr52gcG.js} +19 -5
- package/dist/{editing-DTOBwNI6.js.map → editing-Btr52gcG.js.map} +1 -1
- package/dist/{editing-BAUOl5Ox.cjs → editing-CIvf43jv.cjs} +23 -3
- package/dist/editing-CIvf43jv.cjs.map +1 -0
- package/dist/{editing-Dho3Y2RK.d.ts → editing-dN16BK0k.d.ts} +10 -2
- package/dist/{editing-Dho3Y2RK.d.ts.map → editing-dN16BK0k.d.ts.map} +1 -1
- package/dist/{editing-CdIoFGiK.d.cts → editing-xDGCcasQ.d.cts} +10 -2
- package/dist/{editing-CdIoFGiK.d.cts.map → editing-xDGCcasQ.d.cts.map} +1 -1
- package/dist/editing.cjs +4 -13
- package/dist/editing.d.cts +2 -2
- package/dist/editing.d.ts +2 -2
- package/dist/editing.js +2 -2
- package/dist/export-DLLCc4Lb.js +10 -0
- package/dist/export-DLLCc4Lb.js.map +1 -0
- package/dist/{export-csv.cjs → export-fT_9Xp5t.cjs} +7 -3
- package/dist/export-fT_9Xp5t.cjs.map +1 -0
- package/dist/export.cjs +2 -2
- package/dist/export.d.cts +9 -2
- package/dist/export.d.cts.map +1 -0
- package/dist/export.d.ts +9 -2
- package/dist/export.d.ts.map +1 -0
- package/dist/export.js +1 -1
- package/dist/filtering.cjs +22 -0
- package/dist/filtering.cjs.map +1 -0
- package/dist/filtering.d.cts +13 -0
- package/dist/filtering.d.cts.map +1 -0
- package/dist/filtering.d.ts +13 -0
- package/dist/filtering.d.ts.map +1 -0
- package/dist/filtering.js +21 -0
- package/dist/filtering.js.map +1 -0
- package/dist/{filters-Cy170_qU.js → filters-BxRu0r4j.js} +6 -5
- package/dist/filters-BxRu0r4j.js.map +1 -0
- package/dist/{filters-DIlfaXQJ.cjs → filters-U0LYOQjA.cjs} +5 -4
- package/dist/filters-U0LYOQjA.cjs.map +1 -0
- package/dist/filters.cjs +1 -1
- package/dist/filters.d.cts +90 -2
- package/dist/filters.d.cts.map +1 -0
- package/dist/filters.d.ts +90 -2
- package/dist/filters.d.ts.map +1 -0
- package/dist/filters.js +1 -1
- package/dist/grouping-panel.cjs +146 -3
- package/dist/grouping-panel.cjs.map +1 -0
- package/dist/grouping-panel.js +145 -2
- package/dist/grouping-panel.js.map +1 -0
- package/dist/header-filters.d.cts +52 -2
- package/dist/header-filters.d.cts.map +1 -0
- package/dist/header-filters.d.ts +52 -2
- package/dist/header-filters.d.ts.map +1 -0
- package/dist/index.cjs +2 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -27
- package/dist/index.js.map +1 -1
- package/dist/preset.cjs +8 -9
- package/dist/preset.cjs.map +1 -1
- package/dist/preset.js +7 -8
- package/dist/preset.js.map +1 -1
- package/dist/row-actions.cjs +1 -1
- package/dist/row-actions.js +1 -1
- package/dist/row-pinning.cjs +1 -1
- package/dist/row-pinning.js +1 -1
- package/dist/row-reorder.cjs +185 -2
- package/dist/row-reorder.cjs.map +1 -0
- package/dist/row-reorder.d.cts +2 -1
- package/dist/row-reorder.d.cts.map +1 -1
- package/dist/row-reorder.d.ts +2 -1
- package/dist/row-reorder.d.ts.map +1 -1
- package/dist/row-reorder.js +185 -1
- package/dist/row-reorder.js.map +1 -0
- package/dist/selection.cjs +8 -0
- package/dist/selection.d.cts +2 -0
- package/dist/selection.d.ts +2 -0
- package/dist/selection.js +2 -0
- package/dist/side-panel.cjs +59 -2
- package/dist/side-panel.cjs.map +1 -0
- package/dist/side-panel.js +58 -1
- package/dist/side-panel.js.map +1 -0
- package/dist/styles.css +39 -39
- package/package.json +33 -23
- package/dist/NaiveRowActions-BR140413.cjs.map +0 -1
- package/dist/NaiveRowActions-DVyMXQJq.js.map +0 -1
- package/dist/assistant-DppW6EN1.cjs +0 -380
- package/dist/assistant-DppW6EN1.cjs.map +0 -1
- package/dist/assistant-_SYRZCOi.js +0 -357
- package/dist/assistant-_SYRZCOi.js.map +0 -1
- package/dist/column-menu-DdWVP1hz.d.cts +0 -23
- package/dist/column-menu-DdWVP1hz.d.cts.map +0 -1
- package/dist/column-menu-DdWVP1hz.d.ts +0 -23
- package/dist/column-menu-DdWVP1hz.d.ts.map +0 -1
- package/dist/command-palette-4qS9viir.cjs +0 -117
- package/dist/command-palette-4qS9viir.cjs.map +0 -1
- package/dist/command-palette-CSI-tgcP.js +0 -112
- package/dist/command-palette-CSI-tgcP.js.map +0 -1
- package/dist/context-menu-CsbLaMcR.js +0 -140
- package/dist/context-menu-CsbLaMcR.js.map +0 -1
- package/dist/context-menu-qVwE9S2V.cjs +0 -145
- package/dist/context-menu-qVwE9S2V.cjs.map +0 -1
- package/dist/editing-BAUOl5Ox.cjs.map +0 -1
- package/dist/export-csv-BU39yRSN.d.ts +0 -9
- package/dist/export-csv-BU39yRSN.d.ts.map +0 -1
- package/dist/export-csv-DRDjZuQj.d.cts +0 -9
- package/dist/export-csv-DRDjZuQj.d.cts.map +0 -1
- package/dist/export-csv.cjs.map +0 -1
- package/dist/export-csv.d.cts +0 -2
- package/dist/export-csv.d.ts +0 -2
- package/dist/export-csv.js +0 -10
- package/dist/export-csv.js.map +0 -1
- package/dist/features.cjs +0 -225
- package/dist/features.d.cts +0 -41
- package/dist/features.d.ts +0 -41
- package/dist/features.js +0 -37
- package/dist/filters-ClqB1_n4.d.cts +0 -90
- package/dist/filters-ClqB1_n4.d.cts.map +0 -1
- package/dist/filters-Cy170_qU.js.map +0 -1
- package/dist/filters-DIlfaXQJ.cjs.map +0 -1
- package/dist/filters-b2ZuVZPI.d.ts +0 -90
- package/dist/filters-b2ZuVZPI.d.ts.map +0 -1
- package/dist/grouping-panel-BPaPG49S.cjs +0 -151
- package/dist/grouping-panel-BPaPG49S.cjs.map +0 -1
- package/dist/grouping-panel-CYUPSa0u.js +0 -146
- package/dist/grouping-panel-CYUPSa0u.js.map +0 -1
- package/dist/header-filters-CQg6clum.d.cts +0 -52
- package/dist/header-filters-CQg6clum.d.cts.map +0 -1
- package/dist/header-filters-CQg6clum.d.ts +0 -52
- package/dist/header-filters-CQg6clum.d.ts.map +0 -1
- package/dist/row-reorder-2Ztn7QRu.cjs +0 -191
- package/dist/row-reorder-2Ztn7QRu.cjs.map +0 -1
- package/dist/row-reorder-DBzbJ20V.js +0 -186
- package/dist/row-reorder-DBzbJ20V.js.map +0 -1
- package/dist/side-panel-Bf4zBlYZ.cjs +0 -64
- package/dist/side-panel-Bf4zBlYZ.cjs.map +0 -1
- package/dist/side-panel-CLTgXUnb.js +0 -59
- package/dist/side-panel-CLTgXUnb.js.map +0 -1
package/dist/row-reorder.cjs
CHANGED
|
@@ -1,10 +1,193 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
2
|
+
const require_button = require("./button-CaakTzYM.cjs");
|
|
3
|
+
const require_select = require("./select-C8UKnsWO.cjs");
|
|
4
|
+
const require_modalEscape = require("./modalEscape-Dgmkd7NP.cjs");
|
|
3
5
|
let _adapttable_vue = require("@adapttable/vue");
|
|
4
|
-
|
|
6
|
+
let _adapttable_vue_adapter = require("@adapttable/vue/adapter");
|
|
7
|
+
let _adapttable_vue_features = require("@adapttable/vue/features");
|
|
8
|
+
let vue = require("vue");
|
|
9
|
+
let naive_ui = require("naive-ui");
|
|
10
|
+
//#region src/reorder/NaiveRowMoveMenu.ts
|
|
11
|
+
const NaiveRowMoveMenu = /*#__PURE__*/ (0, vue.defineComponent)((props) => {
|
|
12
|
+
const active = (0, _adapttable_vue_adapter.useScopeActivity)();
|
|
13
|
+
const container = (0, vue.shallowRef)(null);
|
|
14
|
+
const trigger = (0, vue.shallowRef)(null);
|
|
15
|
+
const card = (0, vue.shallowRef)(null);
|
|
16
|
+
const escape = require_modalEscape.useNaiveModalEscape(() => card.value ? require_button.htmlRoot(card.value) : null);
|
|
17
|
+
const descriptionId = (0, vue.useId)();
|
|
18
|
+
let revision = 0;
|
|
19
|
+
(0, vue.watch)([
|
|
20
|
+
active,
|
|
21
|
+
() => props.items,
|
|
22
|
+
() => props.confirmation
|
|
23
|
+
], () => {
|
|
24
|
+
revision++;
|
|
25
|
+
}, { flush: "sync" });
|
|
26
|
+
const restore = () => {
|
|
27
|
+
(0, _adapttable_vue_adapter.scheduleTick)(() => {
|
|
28
|
+
if (active.value && !props.confirmation && trigger.value?.isConnected) trigger.value.focus();
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
return () => {
|
|
32
|
+
const ticket = revision;
|
|
33
|
+
const live = active.value;
|
|
34
|
+
const current = () => live && active.value && ticket === revision;
|
|
35
|
+
const confirmation = props.confirmation;
|
|
36
|
+
const finish = (accept) => {
|
|
37
|
+
if (!current() || !confirmation || props.confirmation !== confirmation) return;
|
|
38
|
+
if (accept) confirmation.onConfirm();
|
|
39
|
+
else confirmation.onCancel();
|
|
40
|
+
restore();
|
|
41
|
+
};
|
|
42
|
+
const content = confirmation ? [
|
|
43
|
+
(0, vue.h)("p", { id: descriptionId }, confirmation.description),
|
|
44
|
+
require_button.naiveButton({
|
|
45
|
+
"data-adapttable-part": "row-move-cancel",
|
|
46
|
+
onClick: () => finish(false)
|
|
47
|
+
}, confirmation.cancelLabel),
|
|
48
|
+
require_button.naiveButton({
|
|
49
|
+
"data-adapttable-part": "row-move-confirm",
|
|
50
|
+
onClick: () => finish(true)
|
|
51
|
+
}, confirmation.confirmLabel)
|
|
52
|
+
] : [];
|
|
53
|
+
return (0, vue.h)("span", {
|
|
54
|
+
"data-adapttable-part": "row-move-menu",
|
|
55
|
+
ref: (0, _adapttable_vue_adapter.elementRef)((element) => {
|
|
56
|
+
container.value = element;
|
|
57
|
+
})
|
|
58
|
+
}, [(0, vue.h)("span", { "data-adapttable-part": "row-move-menu-content" }, [require_select.naiveSelect({
|
|
59
|
+
attrs: {
|
|
60
|
+
ref: (element) => {
|
|
61
|
+
trigger.value = element;
|
|
62
|
+
},
|
|
63
|
+
"aria-label": props.label,
|
|
64
|
+
placeholder: props.label,
|
|
65
|
+
"data-adapttable-part": "row-move-menu-trigger",
|
|
66
|
+
disabled: props.items.every((item) => item.disabled)
|
|
67
|
+
},
|
|
68
|
+
value: "",
|
|
69
|
+
optionPart: "row-move-menu-item",
|
|
70
|
+
virtualScroll: false,
|
|
71
|
+
options: props.items.map((item) => ({
|
|
72
|
+
value: item.id,
|
|
73
|
+
label: item.label,
|
|
74
|
+
disabled: item.disabled,
|
|
75
|
+
title: item.disabledReason
|
|
76
|
+
})),
|
|
77
|
+
onChange: (key) => {
|
|
78
|
+
if (!current()) return;
|
|
79
|
+
const item = props.items.find((entry) => entry.id === key);
|
|
80
|
+
if (item && !item.disabled) item.onSelect();
|
|
81
|
+
}
|
|
82
|
+
})]), confirmation && container.value ? (0, vue.h)(naive_ui.NModal, {
|
|
83
|
+
show: live,
|
|
84
|
+
to: container.value,
|
|
85
|
+
autoFocus: true,
|
|
86
|
+
trapFocus: true,
|
|
87
|
+
maskClosable: false,
|
|
88
|
+
"onUpdate:show": (show) => {
|
|
89
|
+
if (!show && escape.allow()) finish(false);
|
|
90
|
+
}
|
|
91
|
+
}, { default: () => (0, vue.h)(naive_ui.NCard, {
|
|
92
|
+
ref: card,
|
|
93
|
+
role: "alertdialog",
|
|
94
|
+
onKeydownCapture: escape.capture,
|
|
95
|
+
"aria-modal": true,
|
|
96
|
+
"aria-label": confirmation.title,
|
|
97
|
+
"aria-describedby": descriptionId,
|
|
98
|
+
"data-adapttable-part": "row-move-confirmation",
|
|
99
|
+
title: confirmation.title,
|
|
100
|
+
style: { width: "min(28rem,calc(100vw - 2rem))" }
|
|
101
|
+
}, { default: () => content }) }) : null]);
|
|
102
|
+
};
|
|
103
|
+
}, {
|
|
104
|
+
name: "NaiveRowMoveMenu",
|
|
105
|
+
props: {
|
|
106
|
+
label: { type: String },
|
|
107
|
+
items: { type: Array },
|
|
108
|
+
confirmation: { type: Object }
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/reorder/naiveReorderControls.ts
|
|
113
|
+
const naiveReorderControls = {
|
|
114
|
+
Handle: ({ label, pressed, dragging, disabled, dragProps, onKeyDown, className }) => require_button.naiveButton({
|
|
115
|
+
type: "button",
|
|
116
|
+
"aria-label": label,
|
|
117
|
+
"aria-pressed": pressed,
|
|
118
|
+
"data-dragging": dragging ? "" : void 0,
|
|
119
|
+
"data-adapttable-part": "row-reorder-handle",
|
|
120
|
+
"data-adapttable-grip": "",
|
|
121
|
+
class: className,
|
|
122
|
+
disabled,
|
|
123
|
+
draggable: dragProps.draggable,
|
|
124
|
+
onDragstart: (event) => {
|
|
125
|
+
if (event.dataTransfer) dragProps.onDragStart({
|
|
126
|
+
...event,
|
|
127
|
+
dataTransfer: event.dataTransfer,
|
|
128
|
+
clientY: event.clientY,
|
|
129
|
+
currentTarget: event.currentTarget instanceof HTMLElement ? event.currentTarget : null,
|
|
130
|
+
preventDefault: () => event.preventDefault()
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
onDragend: dragProps.onDragEnd,
|
|
134
|
+
onKeydown: (event) => onKeyDown({
|
|
135
|
+
key: event.key,
|
|
136
|
+
currentTarget: event.currentTarget instanceof HTMLElement ? event.currentTarget : null,
|
|
137
|
+
preventDefault: () => event.preventDefault()
|
|
138
|
+
})
|
|
139
|
+
}, "↕"),
|
|
140
|
+
Button: ({ label, part, disabled, onClick, className }) => require_button.naiveButton({
|
|
141
|
+
type: "button",
|
|
142
|
+
"aria-label": label,
|
|
143
|
+
"data-adapttable-part": part,
|
|
144
|
+
class: className,
|
|
145
|
+
disabled,
|
|
146
|
+
onClick
|
|
147
|
+
}, label),
|
|
148
|
+
Menu: (props) => (0, vue.h)(NaiveRowMoveMenu, props)
|
|
149
|
+
};
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/reorder/NaiveRowReorder.vue
|
|
152
|
+
const _sfc_main = /*@__PURE__*/ (0, vue.defineComponent)({
|
|
153
|
+
__name: "NaiveRowReorder",
|
|
154
|
+
props: {
|
|
155
|
+
model: {},
|
|
156
|
+
labels: {},
|
|
157
|
+
mobile: { type: Boolean },
|
|
158
|
+
classNames: {},
|
|
159
|
+
rowId: {},
|
|
160
|
+
localIndex: {},
|
|
161
|
+
row: {},
|
|
162
|
+
windowStart: {},
|
|
163
|
+
rowCount: {}
|
|
164
|
+
},
|
|
165
|
+
setup(__props) {
|
|
166
|
+
const props = __props;
|
|
167
|
+
const names = (0, _adapttable_vue_adapter.useDataTableClassNames)();
|
|
168
|
+
const Render = () => (0, _adapttable_vue_adapter.RowReorderChrome)({
|
|
169
|
+
...props,
|
|
170
|
+
classNames: { ...names.value },
|
|
171
|
+
slots: naiveReorderControls
|
|
172
|
+
});
|
|
173
|
+
Render.props = [];
|
|
174
|
+
return (_ctx, _cache) => {
|
|
175
|
+
return (0, vue.openBlock)(), (0, vue.createBlock)(Render);
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/row-reorder.ts
|
|
181
|
+
function rowReorder(onRowReorder, options) {
|
|
182
|
+
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 }))]);
|
|
183
|
+
}
|
|
184
|
+
//#endregion
|
|
185
|
+
exports.rowReorder = rowReorder;
|
|
5
186
|
Object.defineProperty(exports, "useRowReorder", {
|
|
6
187
|
enumerable: true,
|
|
7
188
|
get: function() {
|
|
8
189
|
return _adapttable_vue.useRowReorder;
|
|
9
190
|
}
|
|
10
191
|
});
|
|
192
|
+
|
|
193
|
+
//# sourceMappingURL=row-reorder.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-reorder.cjs","names":["useScopeActivity","shallowRef","useNaiveModalEscape","htmlRoot","useId","h","naiveButton","elementRef","naiveSelect","NModal","NCard","naiveButton","h","extendFeature","bindingRowReorder","slotRender","rowReorderControlKey","h","NaiveRowReorder"],"sources":["../src/reorder/NaiveRowMoveMenu.ts","../src/reorder/naiveReorderControls.ts","../src/reorder/NaiveRowReorder.vue","../src/row-reorder.ts"],"sourcesContent":["import {\n elementRef,\n type RowMoveMenuSlotProps,\n scheduleTick,\n useScopeActivity,\n} from \"@adapttable/vue/adapter\";\nimport { NCard, NModal } from \"naive-ui\";\nimport {\n type ComponentPublicInstance,\n defineComponent,\n h,\n type PropType,\n shallowRef,\n useId,\n watch,\n} from \"vue\";\n\nimport { naiveButton } from \"../controls/button\";\nimport { htmlRoot } from \"../controls/elementTarget\";\nimport { useNaiveModalEscape } from \"../controls/modalEscape\";\nimport { naiveSelect } from \"../controls/select\";\n\nexport const NaiveRowMoveMenu = /*#__PURE__*/ defineComponent(\n (props: RowMoveMenuSlotProps) => {\n const active = useScopeActivity();\n const container = shallowRef<HTMLElement | null>(null);\n const trigger = shallowRef<HTMLElement | null>(null);\n const card = shallowRef<ComponentPublicInstance | null>(null);\n const escape = useNaiveModalEscape(() =>\n card.value ? htmlRoot(card.value) : null\n );\n const descriptionId = useId();\n let revision = 0;\n watch(\n [active, () => props.items, () => props.confirmation],\n () => {\n revision++;\n },\n { flush: \"sync\" }\n );\n const restore = () => {\n scheduleTick(() => {\n if (active.value && !props.confirmation && trigger.value?.isConnected)\n trigger.value.focus();\n });\n };\n return () => {\n const ticket = revision;\n // Read activity on every render, even while no confirmation is visible.\n const live = active.value;\n const current = () => live && active.value && ticket === revision;\n const confirmation = props.confirmation;\n const finish = (accept: boolean) => {\n if (!current() || !confirmation || props.confirmation !== confirmation)\n return;\n if (accept) confirmation.onConfirm();\n else confirmation.onCancel();\n restore();\n };\n const content = confirmation\n ? [\n h(\"p\", { id: descriptionId }, confirmation.description),\n // Native modal autofocus begins on the non-destructive choice.\n naiveButton(\n {\n \"data-adapttable-part\": \"row-move-cancel\",\n onClick: () => finish(false),\n },\n confirmation.cancelLabel\n ),\n naiveButton(\n {\n \"data-adapttable-part\": \"row-move-confirm\",\n onClick: () => finish(true),\n },\n confirmation.confirmLabel\n ),\n ]\n : [];\n return h(\n \"span\",\n {\n \"data-adapttable-part\": \"row-move-menu\",\n ref: elementRef<HTMLElement>((element) => {\n container.value = element;\n }),\n },\n [\n h(\"span\", { \"data-adapttable-part\": \"row-move-menu-content\" }, [\n naiveSelect({\n attrs: {\n ref: (element: HTMLElement | null) => {\n trigger.value = element;\n },\n \"aria-label\": props.label,\n placeholder: props.label,\n \"data-adapttable-part\": \"row-move-menu-trigger\",\n disabled: props.items.every((item) => item.disabled),\n },\n value: \"\",\n optionPart: \"row-move-menu-item\",\n // A destination list keeps disabled choices and their reasons visible.\n virtualScroll: false,\n options: props.items.map((item) => ({\n value: item.id,\n label: item.label,\n disabled: item.disabled,\n title: item.disabledReason,\n })),\n onChange: (key) => {\n if (!current()) return;\n const item = props.items.find((entry) => entry.id === key);\n if (item && !item.disabled) item.onSelect();\n },\n }),\n ]),\n confirmation && container.value\n ? h(\n NModal,\n {\n show: live,\n to: container.value,\n autoFocus: true,\n trapFocus: true,\n maskClosable: false,\n \"onUpdate:show\": (show: boolean) => {\n if (!show && escape.allow()) finish(false);\n },\n },\n {\n default: () =>\n h(\n NCard,\n {\n ref: card,\n role: \"alertdialog\",\n onKeydownCapture: escape.capture,\n \"aria-modal\": true,\n \"aria-label\": confirmation.title,\n \"aria-describedby\": descriptionId,\n \"data-adapttable-part\": \"row-move-confirmation\",\n title: confirmation.title,\n style: { width: \"min(28rem,calc(100vw - 2rem))\" },\n },\n { default: () => content }\n ),\n }\n )\n : null,\n ]\n );\n };\n },\n {\n name: \"NaiveRowMoveMenu\",\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 { naiveButton } from \"../controls/button\";\nimport { NaiveRowMoveMenu } from \"./NaiveRowMoveMenu\";\n\nexport const naiveReorderControls: RowReorderControlSlots = {\n Handle: ({\n label,\n pressed,\n dragging,\n disabled,\n dragProps,\n onKeyDown,\n className,\n }) =>\n naiveButton(\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 naiveButton(\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(NaiveRowMoveMenu, props),\n};\n","<script setup lang=\"ts\" generic=\"TRow\">\nimport {\n RowReorderChrome,\n type RowReorderControlProps,\n useDataTableClassNames,\n} from \"@adapttable/vue/adapter\";\n\nimport { naiveReorderControls } from \"./naiveReorderControls\";\n\nconst props = defineProps<RowReorderControlProps<TRow>>();\nconst names = useDataTableClassNames();\nconst Render = () =>\n RowReorderChrome({\n ...props,\n classNames: { ...names.value },\n slots: naiveReorderControls,\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, type MaybeRefOrGetter } from \"vue\";\n\nimport NaiveRowReorder from \"./reorder/NaiveRowReorder.vue\";\nexport {\n type RowReorderHandler,\n type RowReorderOptions,\n useRowReorder,\n} from \"@adapttable/vue\";\nexport function rowReorder<TRow>(\n onRowReorder: RowReorderHandler<TRow>,\n options?: MaybeRefOrGetter<RowReorderOptions<TRow> | undefined>\n): TableFeature<TRow> {\n return extendFeature(bindingRowReorder(onRowReorder, options), [\n slotRender(rowReorderControlKey<TRow>(), (props) =>\n h(NaiveRowReorder<TRow>, { ...props })\n ),\n ]);\n}\n"],"mappings":";;;;;;;;;;AAsBA,MAAa,mBAAiC,eAAA,GAAA,IAAA,gBAAA,EAC3C,UAAgC;CAC/B,MAAM,UAAA,GAASA,wBAAAA,iBAAAA,CAAiB;CAChC,MAAM,aAAA,GAAYC,IAAAA,WAAAA,CAA+B,IAAI;CACrD,MAAM,WAAA,GAAUA,IAAAA,WAAAA,CAA+B,IAAI;CACnD,MAAM,QAAA,GAAOA,IAAAA,WAAAA,CAA2C,IAAI;CAC5D,MAAM,SAASC,oBAAAA,0BACb,KAAK,QAAQC,eAAAA,SAAS,KAAK,KAAK,IAAI,IACtC;CACA,MAAM,iBAAA,GAAgBC,IAAAA,MAAAA,CAAM;CAC5B,IAAI,W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AY;IACpB,GAAG;IACH,cAAc,MAAM;IACpB,SAAS,MAAM;IACf,eACE,MAAM,yBAAyB,cAC3B,MAAM,gBACN;IACN,sBAAsB,MAAM,eAAe;GAC7C,CAAC;EACL;EACA,WAAW,UAAU;EACrB,YAAY,UACV,UAAU;GACR,KAAK,MAAM;GACX,eACE,MAAM,yBAAyB,cAC3B,MAAM,gBACN;GACN,sBAAsB,MAAM,eAAe;EAC7C,CAAC;CACL,GACA,GACF;CACF,SAAS,EAAE,OAAO,MAAM,UAAU,SAAS,gBACzCA,eAAAA,YACE;EACE,MAAM;EACN,cAAc;EACd,wBAAwB;EACxB,OAAO;EACP;EACA;CACF,GACA,KACF;CACF,OAAO,WAAA,GAAUC,IAAAA,EAAAA,CAAE,kBAAkB,KAAK;AAC5C;;;;;;;;;;;;;;;;;ECzDA,MAAM,QAAQ;EACd,MAAM,SAAA,GAAQ,wBAAA,uBAAA,CAAuB;EACrC,MAAM,gBAAA,GACJ,wBAAA,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,WAAuB,EAAE,GAAG,MAAM,CAAC,CACvC,CACF,CAAC;AACH"}
|
package/dist/row-reorder.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RowReorderHandler, RowReorderHandler as RowReorderHandler$1, RowReorderOptions, RowReorderOptions as RowReorderOptions$1, TableFeature, useRowReorder } from "@adapttable/vue";
|
|
2
|
+
import { MaybeRefOrGetter } from "vue";
|
|
2
3
|
//#region src/row-reorder.d.ts
|
|
3
|
-
declare function rowReorder<TRow>(onRowReorder: RowReorderHandler$1<TRow>, options?: RowReorderOptions$1<TRow>): TableFeature<TRow>;
|
|
4
|
+
declare function rowReorder<TRow>(onRowReorder: RowReorderHandler$1<TRow>, options?: MaybeRefOrGetter<RowReorderOptions$1<TRow> | undefined>): TableFeature<TRow>;
|
|
4
5
|
//#endregion
|
|
5
6
|
export { type RowReorderHandler, type RowReorderOptions, rowReorder, useRowReorder };
|
|
6
7
|
//# sourceMappingURL=row-reorder.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-reorder.d.cts","names":[],"sources":["../src/row-reorder.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"row-reorder.d.cts","names":[],"sources":["../src/row-reorder.ts"],"mappings":";;;iBAmBgB,WAAW,MACzB,cAAc,oBAAkB,OAChC,UAAU,iBAAiB,oBAAkB,qBAC5C,aAAa"}
|
package/dist/row-reorder.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RowReorderHandler, RowReorderHandler as RowReorderHandler$1, RowReorderOptions, RowReorderOptions as RowReorderOptions$1, TableFeature, useRowReorder } from "@adapttable/vue";
|
|
2
|
+
import { MaybeRefOrGetter } from "vue";
|
|
2
3
|
//#region src/row-reorder.d.ts
|
|
3
|
-
declare function rowReorder<TRow>(onRowReorder: RowReorderHandler$1<TRow>, options?: RowReorderOptions$1<TRow>): TableFeature<TRow>;
|
|
4
|
+
declare function rowReorder<TRow>(onRowReorder: RowReorderHandler$1<TRow>, options?: MaybeRefOrGetter<RowReorderOptions$1<TRow> | undefined>): TableFeature<TRow>;
|
|
4
5
|
//#endregion
|
|
5
6
|
export { type RowReorderHandler, type RowReorderOptions, rowReorder, useRowReorder };
|
|
6
7
|
//# sourceMappingURL=row-reorder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-reorder.d.ts","names":[],"sources":["../src/row-reorder.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"row-reorder.d.ts","names":[],"sources":["../src/row-reorder.ts"],"mappings":";;;iBAmBgB,WAAW,MACzB,cAAc,oBAAkB,OAChC,UAAU,iBAAiB,oBAAkB,qBAC5C,aAAa"}
|
package/dist/row-reorder.js
CHANGED
|
@@ -1,2 +1,186 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { r as htmlRoot, t as naiveButton } from "./button-BxXdDW7A.js";
|
|
2
|
+
import { t as naiveSelect } from "./select-Bgc5ttop.js";
|
|
3
|
+
import { t as useNaiveModalEscape } from "./modalEscape-BIm9yvam.js";
|
|
4
|
+
import { useRowReorder } from "@adapttable/vue";
|
|
5
|
+
import { RowReorderChrome, elementRef, extendFeature, rowReorderControlKey, scheduleTick, slotRender, useDataTableClassNames, useScopeActivity } from "@adapttable/vue/adapter";
|
|
6
|
+
import { rowReorder as rowReorder$1 } from "@adapttable/vue/features";
|
|
7
|
+
import { createBlock, defineComponent, h, openBlock, shallowRef, useId, watch } from "vue";
|
|
8
|
+
import { NCard, NModal } from "naive-ui";
|
|
9
|
+
//#region src/reorder/NaiveRowMoveMenu.ts
|
|
10
|
+
const NaiveRowMoveMenu = /*#__PURE__*/ defineComponent((props) => {
|
|
11
|
+
const active = useScopeActivity();
|
|
12
|
+
const container = shallowRef(null);
|
|
13
|
+
const trigger = shallowRef(null);
|
|
14
|
+
const card = shallowRef(null);
|
|
15
|
+
const escape = useNaiveModalEscape(() => card.value ? htmlRoot(card.value) : null);
|
|
16
|
+
const descriptionId = useId();
|
|
17
|
+
let revision = 0;
|
|
18
|
+
watch([
|
|
19
|
+
active,
|
|
20
|
+
() => props.items,
|
|
21
|
+
() => props.confirmation
|
|
22
|
+
], () => {
|
|
23
|
+
revision++;
|
|
24
|
+
}, { flush: "sync" });
|
|
25
|
+
const restore = () => {
|
|
26
|
+
scheduleTick(() => {
|
|
27
|
+
if (active.value && !props.confirmation && trigger.value?.isConnected) trigger.value.focus();
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
return () => {
|
|
31
|
+
const ticket = revision;
|
|
32
|
+
const live = active.value;
|
|
33
|
+
const current = () => live && active.value && ticket === revision;
|
|
34
|
+
const confirmation = props.confirmation;
|
|
35
|
+
const finish = (accept) => {
|
|
36
|
+
if (!current() || !confirmation || props.confirmation !== confirmation) return;
|
|
37
|
+
if (accept) confirmation.onConfirm();
|
|
38
|
+
else confirmation.onCancel();
|
|
39
|
+
restore();
|
|
40
|
+
};
|
|
41
|
+
const content = confirmation ? [
|
|
42
|
+
h("p", { id: descriptionId }, confirmation.description),
|
|
43
|
+
naiveButton({
|
|
44
|
+
"data-adapttable-part": "row-move-cancel",
|
|
45
|
+
onClick: () => finish(false)
|
|
46
|
+
}, confirmation.cancelLabel),
|
|
47
|
+
naiveButton({
|
|
48
|
+
"data-adapttable-part": "row-move-confirm",
|
|
49
|
+
onClick: () => finish(true)
|
|
50
|
+
}, confirmation.confirmLabel)
|
|
51
|
+
] : [];
|
|
52
|
+
return h("span", {
|
|
53
|
+
"data-adapttable-part": "row-move-menu",
|
|
54
|
+
ref: elementRef((element) => {
|
|
55
|
+
container.value = element;
|
|
56
|
+
})
|
|
57
|
+
}, [h("span", { "data-adapttable-part": "row-move-menu-content" }, [naiveSelect({
|
|
58
|
+
attrs: {
|
|
59
|
+
ref: (element) => {
|
|
60
|
+
trigger.value = element;
|
|
61
|
+
},
|
|
62
|
+
"aria-label": props.label,
|
|
63
|
+
placeholder: props.label,
|
|
64
|
+
"data-adapttable-part": "row-move-menu-trigger",
|
|
65
|
+
disabled: props.items.every((item) => item.disabled)
|
|
66
|
+
},
|
|
67
|
+
value: "",
|
|
68
|
+
optionPart: "row-move-menu-item",
|
|
69
|
+
virtualScroll: false,
|
|
70
|
+
options: props.items.map((item) => ({
|
|
71
|
+
value: item.id,
|
|
72
|
+
label: item.label,
|
|
73
|
+
disabled: item.disabled,
|
|
74
|
+
title: item.disabledReason
|
|
75
|
+
})),
|
|
76
|
+
onChange: (key) => {
|
|
77
|
+
if (!current()) return;
|
|
78
|
+
const item = props.items.find((entry) => entry.id === key);
|
|
79
|
+
if (item && !item.disabled) item.onSelect();
|
|
80
|
+
}
|
|
81
|
+
})]), confirmation && container.value ? h(NModal, {
|
|
82
|
+
show: live,
|
|
83
|
+
to: container.value,
|
|
84
|
+
autoFocus: true,
|
|
85
|
+
trapFocus: true,
|
|
86
|
+
maskClosable: false,
|
|
87
|
+
"onUpdate:show": (show) => {
|
|
88
|
+
if (!show && escape.allow()) finish(false);
|
|
89
|
+
}
|
|
90
|
+
}, { default: () => h(NCard, {
|
|
91
|
+
ref: card,
|
|
92
|
+
role: "alertdialog",
|
|
93
|
+
onKeydownCapture: escape.capture,
|
|
94
|
+
"aria-modal": true,
|
|
95
|
+
"aria-label": confirmation.title,
|
|
96
|
+
"aria-describedby": descriptionId,
|
|
97
|
+
"data-adapttable-part": "row-move-confirmation",
|
|
98
|
+
title: confirmation.title,
|
|
99
|
+
style: { width: "min(28rem,calc(100vw - 2rem))" }
|
|
100
|
+
}, { default: () => content }) }) : null]);
|
|
101
|
+
};
|
|
102
|
+
}, {
|
|
103
|
+
name: "NaiveRowMoveMenu",
|
|
104
|
+
props: {
|
|
105
|
+
label: { type: String },
|
|
106
|
+
items: { type: Array },
|
|
107
|
+
confirmation: { type: Object }
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/reorder/naiveReorderControls.ts
|
|
112
|
+
const naiveReorderControls = {
|
|
113
|
+
Handle: ({ label, pressed, dragging, disabled, dragProps, onKeyDown, className }) => naiveButton({
|
|
114
|
+
type: "button",
|
|
115
|
+
"aria-label": label,
|
|
116
|
+
"aria-pressed": pressed,
|
|
117
|
+
"data-dragging": dragging ? "" : void 0,
|
|
118
|
+
"data-adapttable-part": "row-reorder-handle",
|
|
119
|
+
"data-adapttable-grip": "",
|
|
120
|
+
class: className,
|
|
121
|
+
disabled,
|
|
122
|
+
draggable: dragProps.draggable,
|
|
123
|
+
onDragstart: (event) => {
|
|
124
|
+
if (event.dataTransfer) dragProps.onDragStart({
|
|
125
|
+
...event,
|
|
126
|
+
dataTransfer: event.dataTransfer,
|
|
127
|
+
clientY: event.clientY,
|
|
128
|
+
currentTarget: event.currentTarget instanceof HTMLElement ? event.currentTarget : null,
|
|
129
|
+
preventDefault: () => event.preventDefault()
|
|
130
|
+
});
|
|
131
|
+
},
|
|
132
|
+
onDragend: dragProps.onDragEnd,
|
|
133
|
+
onKeydown: (event) => onKeyDown({
|
|
134
|
+
key: event.key,
|
|
135
|
+
currentTarget: event.currentTarget instanceof HTMLElement ? event.currentTarget : null,
|
|
136
|
+
preventDefault: () => event.preventDefault()
|
|
137
|
+
})
|
|
138
|
+
}, "↕"),
|
|
139
|
+
Button: ({ label, part, disabled, onClick, className }) => naiveButton({
|
|
140
|
+
type: "button",
|
|
141
|
+
"aria-label": label,
|
|
142
|
+
"data-adapttable-part": part,
|
|
143
|
+
class: className,
|
|
144
|
+
disabled,
|
|
145
|
+
onClick
|
|
146
|
+
}, label),
|
|
147
|
+
Menu: (props) => h(NaiveRowMoveMenu, props)
|
|
148
|
+
};
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/reorder/NaiveRowReorder.vue
|
|
151
|
+
const _sfc_main = /*@__PURE__*/ defineComponent({
|
|
152
|
+
__name: "NaiveRowReorder",
|
|
153
|
+
props: {
|
|
154
|
+
model: {},
|
|
155
|
+
labels: {},
|
|
156
|
+
mobile: { type: Boolean },
|
|
157
|
+
classNames: {},
|
|
158
|
+
rowId: {},
|
|
159
|
+
localIndex: {},
|
|
160
|
+
row: {},
|
|
161
|
+
windowStart: {},
|
|
162
|
+
rowCount: {}
|
|
163
|
+
},
|
|
164
|
+
setup(__props) {
|
|
165
|
+
const props = __props;
|
|
166
|
+
const names = useDataTableClassNames();
|
|
167
|
+
const Render = () => RowReorderChrome({
|
|
168
|
+
...props,
|
|
169
|
+
classNames: { ...names.value },
|
|
170
|
+
slots: naiveReorderControls
|
|
171
|
+
});
|
|
172
|
+
Render.props = [];
|
|
173
|
+
return (_ctx, _cache) => {
|
|
174
|
+
return openBlock(), createBlock(Render);
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
//#endregion
|
|
179
|
+
//#region src/row-reorder.ts
|
|
180
|
+
function rowReorder(onRowReorder, options) {
|
|
181
|
+
return extendFeature(rowReorder$1(onRowReorder, options), [slotRender(rowReorderControlKey(), (props) => h(_sfc_main, { ...props }))]);
|
|
182
|
+
}
|
|
183
|
+
//#endregion
|
|
2
184
|
export { rowReorder, useRowReorder };
|
|
185
|
+
|
|
186
|
+
//# sourceMappingURL=row-reorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row-reorder.js","names":["bindingRowReorder","NaiveRowReorder"],"sources":["../src/reorder/NaiveRowMoveMenu.ts","../src/reorder/naiveReorderControls.ts","../src/reorder/NaiveRowReorder.vue","../src/row-reorder.ts"],"sourcesContent":["import {\n elementRef,\n type RowMoveMenuSlotProps,\n scheduleTick,\n useScopeActivity,\n} from \"@adapttable/vue/adapter\";\nimport { NCard, NModal } from \"naive-ui\";\nimport {\n type ComponentPublicInstance,\n defineComponent,\n h,\n type PropType,\n shallowRef,\n useId,\n watch,\n} from \"vue\";\n\nimport { naiveButton } from \"../controls/button\";\nimport { htmlRoot } from \"../controls/elementTarget\";\nimport { useNaiveModalEscape } from \"../controls/modalEscape\";\nimport { naiveSelect } from \"../controls/select\";\n\nexport const NaiveRowMoveMenu = /*#__PURE__*/ defineComponent(\n (props: RowMoveMenuSlotProps) => {\n const active = useScopeActivity();\n const container = shallowRef<HTMLElement | null>(null);\n const trigger = shallowRef<HTMLElement | null>(null);\n const card = shallowRef<ComponentPublicInstance | null>(null);\n const escape = useNaiveModalEscape(() =>\n card.value ? htmlRoot(card.value) : null\n );\n const descriptionId = useId();\n let revision = 0;\n watch(\n [active, () => props.items, () => props.confirmation],\n () => {\n revision++;\n },\n { flush: \"sync\" }\n );\n const restore = () => {\n scheduleTick(() => {\n if (active.value && !props.confirmation && trigger.value?.isConnected)\n trigger.value.focus();\n });\n };\n return () => {\n const ticket = revision;\n // Read activity on every render, even while no confirmation is visible.\n const live = active.value;\n const current = () => live && active.value && ticket === revision;\n const confirmation = props.confirmation;\n const finish = (accept: boolean) => {\n if (!current() || !confirmation || props.confirmation !== confirmation)\n return;\n if (accept) confirmation.onConfirm();\n else confirmation.onCancel();\n restore();\n };\n const content = confirmation\n ? [\n h(\"p\", { id: descriptionId }, confirmation.description),\n // Native modal autofocus begins on the non-destructive choice.\n naiveButton(\n {\n \"data-adapttable-part\": \"row-move-cancel\",\n onClick: () => finish(false),\n },\n confirmation.cancelLabel\n ),\n naiveButton(\n {\n \"data-adapttable-part\": \"row-move-confirm\",\n onClick: () => finish(true),\n },\n confirmation.confirmLabel\n ),\n ]\n : [];\n return h(\n \"span\",\n {\n \"data-adapttable-part\": \"row-move-menu\",\n ref: elementRef<HTMLElement>((element) => {\n container.value = element;\n }),\n },\n [\n h(\"span\", { \"data-adapttable-part\": \"row-move-menu-content\" }, [\n naiveSelect({\n attrs: {\n ref: (element: HTMLElement | null) => {\n trigger.value = element;\n },\n \"aria-label\": props.label,\n placeholder: props.label,\n \"data-adapttable-part\": \"row-move-menu-trigger\",\n disabled: props.items.every((item) => item.disabled),\n },\n value: \"\",\n optionPart: \"row-move-menu-item\",\n // A destination list keeps disabled choices and their reasons visible.\n virtualScroll: false,\n options: props.items.map((item) => ({\n value: item.id,\n label: item.label,\n disabled: item.disabled,\n title: item.disabledReason,\n })),\n onChange: (key) => {\n if (!current()) return;\n const item = props.items.find((entry) => entry.id === key);\n if (item && !item.disabled) item.onSelect();\n },\n }),\n ]),\n confirmation && container.value\n ? h(\n NModal,\n {\n show: live,\n to: container.value,\n autoFocus: true,\n trapFocus: true,\n maskClosable: false,\n \"onUpdate:show\": (show: boolean) => {\n if (!show && escape.allow()) finish(false);\n },\n },\n {\n default: () =>\n h(\n NCard,\n {\n ref: card,\n role: \"alertdialog\",\n onKeydownCapture: escape.capture,\n \"aria-modal\": true,\n \"aria-label\": confirmation.title,\n \"aria-describedby\": descriptionId,\n \"data-adapttable-part\": \"row-move-confirmation\",\n title: confirmation.title,\n style: { width: \"min(28rem,calc(100vw - 2rem))\" },\n },\n { default: () => content }\n ),\n }\n )\n : null,\n ]\n );\n };\n },\n {\n name: \"NaiveRowMoveMenu\",\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 { naiveButton } from \"../controls/button\";\nimport { NaiveRowMoveMenu } from \"./NaiveRowMoveMenu\";\n\nexport const naiveReorderControls: RowReorderControlSlots = {\n Handle: ({\n label,\n pressed,\n dragging,\n disabled,\n dragProps,\n onKeyDown,\n className,\n }) =>\n naiveButton(\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 naiveButton(\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(NaiveRowMoveMenu, props),\n};\n","<script setup lang=\"ts\" generic=\"TRow\">\nimport {\n RowReorderChrome,\n type RowReorderControlProps,\n useDataTableClassNames,\n} from \"@adapttable/vue/adapter\";\n\nimport { naiveReorderControls } from \"./naiveReorderControls\";\n\nconst props = defineProps<RowReorderControlProps<TRow>>();\nconst names = useDataTableClassNames();\nconst Render = () =>\n RowReorderChrome({\n ...props,\n classNames: { ...names.value },\n slots: naiveReorderControls,\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, type MaybeRefOrGetter } from \"vue\";\n\nimport NaiveRowReorder from \"./reorder/NaiveRowReorder.vue\";\nexport {\n type RowReorderHandler,\n type RowReorderOptions,\n useRowReorder,\n} from \"@adapttable/vue\";\nexport function rowReorder<TRow>(\n onRowReorder: RowReorderHandler<TRow>,\n options?: MaybeRefOrGetter<RowReorderOptions<TRow> | undefined>\n): TableFeature<TRow> {\n return extendFeature(bindingRowReorder(onRowReorder, options), [\n slotRender(rowReorderControlKey<TRow>(), (props) =>\n h(NaiveRowReorder<TRow>, { ...props })\n ),\n ]);\n}\n"],"mappings":";;;;;;;;;AAsBA,MAAa,mBAAiC,+BAC3C,UAAgC;CAC/B,MAAM,SAAS,iBAAiB;CAChC,MAAM,YAAY,WAA+B,IAAI;CACrD,MAAM,UAAU,WAA+B,IAAI;CACnD,MAAM,OAAO,WAA2C,IA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C7C,CAAC;EACL;EACA,WAAW,UAAU;EACrB,YAAY,UACV,UAAU;GACR,KAAK,MAAM;GACX,eACE,MAAM,yBAAyB,cAC3B,MAAM,gBACN;GACN,sBAAsB,MAAM,eAAe;EAC7C,CAAC;CACL,GACA,GACF;CACF,SAAS,EAAE,OAAO,MAAM,UAAU,SAAS,gBACzC,YACE;EACE,MAAM;EACN,cAAc;EACd,wBAAwB;EACxB,OAAO;EACP;EACA;CACF,GACA,KACF;CACF,OAAO,UAAU,EAAE,kBAAkB,KAAK;AAC5C;;;;;;;;;;;;;;;;;ECzDA,MAAM,QAAQ;EACd,MAAM,QAAQ,uBAAuB;EACrC,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,SAAgB,WACd,cACA,SACoB;CACpB,OAAO,cAAcA,aAAkB,cAAc,OAAO,GAAG,CAC7D,WAAW,qBAA2B,IAAI,UACxC,EAAEC,WAAuB,EAAE,GAAG,MAAM,CAAC,CACvC,CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _adapttable_vue_features = require("@adapttable/vue/features");
|
|
3
|
+
Object.defineProperty(exports, "selection", {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
get: function() {
|
|
6
|
+
return _adapttable_vue_features.selection;
|
|
7
|
+
}
|
|
8
|
+
});
|
package/dist/side-panel.cjs
CHANGED
|
@@ -1,3 +1,60 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
|
|
2
|
+
const require_button = require("./button-CaakTzYM.cjs");
|
|
3
|
+
require("@adapttable/vue");
|
|
4
|
+
let _adapttable_vue_adapter = require("@adapttable/vue/adapter");
|
|
5
|
+
let _adapttable_vue_features = require("@adapttable/vue/features");
|
|
6
|
+
let vue = require("vue");
|
|
7
|
+
let naive_ui = require("naive-ui");
|
|
8
|
+
//#region src/actions/sidePanelControls.ts
|
|
9
|
+
const naiveSidePanelSlots = (names = {}) => ({
|
|
10
|
+
Frame: (props) => (0, vue.h)(naive_ui.NCard, {
|
|
11
|
+
tag: "aside",
|
|
12
|
+
size: "small",
|
|
13
|
+
"data-adapttable-part": "side-panel",
|
|
14
|
+
class: props.className,
|
|
15
|
+
"data-side": props.side,
|
|
16
|
+
style: {
|
|
17
|
+
minWidth: "min(18rem,100%)",
|
|
18
|
+
maxWidth: "100%"
|
|
19
|
+
}
|
|
20
|
+
}, { default: () => props.children }),
|
|
21
|
+
Tab: (props) => require_button.naiveButton({
|
|
22
|
+
...(0, _adapttable_vue_adapter.toVueAttrs)(props.buttonProps),
|
|
23
|
+
class: names.sidePanelTab
|
|
24
|
+
}, props.panel.label),
|
|
25
|
+
Close: (props) => require_button.naiveButton({
|
|
26
|
+
"aria-label": props.label,
|
|
27
|
+
"data-adapttable-part": "side-panel-close",
|
|
28
|
+
class: names.sidePanelClose,
|
|
29
|
+
onClick: props.onClose
|
|
30
|
+
}, props.label)
|
|
31
|
+
});
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/side-panel.ts
|
|
34
|
+
const NaiveSidePanel = /*#__PURE__*/ (0, vue.defineComponent)((props) => {
|
|
35
|
+
const slots = {
|
|
36
|
+
Frame: (control) => naiveSidePanelSlots(props.classNames).Frame(control),
|
|
37
|
+
Tab: (control) => naiveSidePanelSlots(props.classNames).Tab(control),
|
|
38
|
+
Close: (control) => naiveSidePanelSlots(props.classNames).Close(control)
|
|
39
|
+
};
|
|
40
|
+
return () => (0, vue.h)(_adapttable_vue_adapter.SidePanelChrome, {
|
|
41
|
+
...props,
|
|
42
|
+
slots
|
|
43
|
+
});
|
|
44
|
+
}, {
|
|
45
|
+
name: "NaiveSidePanel",
|
|
46
|
+
props: {
|
|
47
|
+
model: { type: Object },
|
|
48
|
+
labels: { type: Object },
|
|
49
|
+
dir: { type: String },
|
|
50
|
+
classNames: { type: Object },
|
|
51
|
+
container: { type: Object }
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
function sidePanel(options) {
|
|
55
|
+
return (0, _adapttable_vue_adapter.extendFeature)((0, _adapttable_vue_features.sidePanel)(options), [(0, _adapttable_vue_adapter.slotRender)(_adapttable_vue_adapter.SIDE_PANEL_CONTROL, (props) => (0, vue.h)(NaiveSidePanel, { ...props }))]);
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
exports.sidePanel = sidePanel;
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=side-panel.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"side-panel.cjs","names":["h","NCard","naiveButton","toVueAttrs","h","SidePanelChrome","extendFeature","bindingSidePanel","slotRender","SIDE_PANEL_CONTROL"],"sources":["../src/actions/sidePanelControls.ts","../src/side-panel.ts"],"sourcesContent":["import { type SidePanelSlots, toVueAttrs } from \"@adapttable/vue/adapter\";\nimport { NCard } from \"naive-ui\";\nimport { h } from \"vue\";\n\nimport { naiveButton } from \"../controls/button\";\n\nexport const naiveSidePanelSlots = (\n names: Readonly<Record<string, string | undefined>> = {}\n): SidePanelSlots => ({\n Frame: (props) =>\n h(\n NCard,\n {\n tag: \"aside\",\n size: \"small\",\n \"data-adapttable-part\": \"side-panel\",\n class: props.className,\n \"data-side\": props.side,\n style: { minWidth: \"min(18rem,100%)\", maxWidth: \"100%\" },\n },\n { default: () => props.children }\n ),\n Tab: (props) =>\n naiveButton(\n { ...toVueAttrs(props.buttonProps), class: names.sidePanelTab },\n props.panel.label\n ),\n Close: (props) =>\n naiveButton(\n {\n \"aria-label\": props.label,\n \"data-adapttable-part\": \"side-panel-close\",\n class: names.sidePanelClose,\n onClick: props.onClose,\n },\n props.label\n ),\n});\n","import { type StaticTableFeature } from \"@adapttable/vue\";\nimport {\n extendFeature,\n SIDE_PANEL_CONTROL,\n SidePanelChrome,\n type SidePanelChromeProps,\n type SidePanelSlots,\n slotRender,\n} from \"@adapttable/vue/adapter\";\nimport { sidePanel as bindingSidePanel } from \"@adapttable/vue/features\";\nimport { defineComponent, h, type PropType } from \"vue\";\n\nimport { naiveSidePanelSlots } from \"./actions/sidePanelControls\";\nconst NaiveSidePanel = /*#__PURE__*/ defineComponent(\n (props: Omit<SidePanelChromeProps, \"slots\" | \"presentation\">) => {\n const slots: SidePanelSlots = {\n Frame: (control) => naiveSidePanelSlots(props.classNames).Frame(control),\n Tab: (control) => naiveSidePanelSlots(props.classNames).Tab(control),\n Close: (control) => naiveSidePanelSlots(props.classNames).Close(control),\n };\n return () => h(SidePanelChrome, { ...props, slots });\n },\n {\n name: \"NaiveSidePanel\",\n props: {\n model: {\n type: Object as PropType<\n Omit<SidePanelChromeProps, \"slots\" | \"presentation\">[\"model\"]\n >,\n },\n labels: {\n type: Object as PropType<\n Omit<SidePanelChromeProps, \"slots\" | \"presentation\">[\"labels\"]\n >,\n },\n dir: {\n type: String as PropType<\n Omit<SidePanelChromeProps, \"slots\" | \"presentation\">[\"dir\"]\n >,\n },\n classNames: {\n type: Object as PropType<\n Omit<SidePanelChromeProps, \"slots\" | \"presentation\">[\"classNames\"]\n >,\n },\n container: {\n type: Object as PropType<\n Omit<SidePanelChromeProps, \"slots\" | \"presentation\">[\"container\"]\n >,\n },\n },\n }\n);\nexport function sidePanel(\n options: Parameters<typeof bindingSidePanel>[0]\n): StaticTableFeature {\n return extendFeature(bindingSidePanel(options), [\n slotRender(SIDE_PANEL_CONTROL, (props) => h(NaiveSidePanel, { ...props })),\n ]);\n}\nexport type {\n SidePanelOptions,\n SidePanelPanel,\n} from \"@adapttable/vue/features\";\n"],"mappings":";;;;;;;;AAMA,MAAa,uBACX,QAAsD,CAAC,OACnC;CACpB,QAAQ,WAAA,GACNA,IAAAA,EAAAA,CACEC,SAAAA,OACA;EACE,K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|
@@ -1,2 +1,59 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { t as naiveButton } from "./button-BxXdDW7A.js";
|
|
2
|
+
import "@adapttable/vue";
|
|
3
|
+
import { SIDE_PANEL_CONTROL, SidePanelChrome, extendFeature, slotRender, toVueAttrs } from "@adapttable/vue/adapter";
|
|
4
|
+
import { sidePanel as sidePanel$1 } from "@adapttable/vue/features";
|
|
5
|
+
import { defineComponent, h } from "vue";
|
|
6
|
+
import { NCard } from "naive-ui";
|
|
7
|
+
//#region src/actions/sidePanelControls.ts
|
|
8
|
+
const naiveSidePanelSlots = (names = {}) => ({
|
|
9
|
+
Frame: (props) => h(NCard, {
|
|
10
|
+
tag: "aside",
|
|
11
|
+
size: "small",
|
|
12
|
+
"data-adapttable-part": "side-panel",
|
|
13
|
+
class: props.className,
|
|
14
|
+
"data-side": props.side,
|
|
15
|
+
style: {
|
|
16
|
+
minWidth: "min(18rem,100%)",
|
|
17
|
+
maxWidth: "100%"
|
|
18
|
+
}
|
|
19
|
+
}, { default: () => props.children }),
|
|
20
|
+
Tab: (props) => naiveButton({
|
|
21
|
+
...toVueAttrs(props.buttonProps),
|
|
22
|
+
class: names.sidePanelTab
|
|
23
|
+
}, props.panel.label),
|
|
24
|
+
Close: (props) => naiveButton({
|
|
25
|
+
"aria-label": props.label,
|
|
26
|
+
"data-adapttable-part": "side-panel-close",
|
|
27
|
+
class: names.sidePanelClose,
|
|
28
|
+
onClick: props.onClose
|
|
29
|
+
}, props.label)
|
|
30
|
+
});
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/side-panel.ts
|
|
33
|
+
const NaiveSidePanel = /*#__PURE__*/ defineComponent((props) => {
|
|
34
|
+
const slots = {
|
|
35
|
+
Frame: (control) => naiveSidePanelSlots(props.classNames).Frame(control),
|
|
36
|
+
Tab: (control) => naiveSidePanelSlots(props.classNames).Tab(control),
|
|
37
|
+
Close: (control) => naiveSidePanelSlots(props.classNames).Close(control)
|
|
38
|
+
};
|
|
39
|
+
return () => h(SidePanelChrome, {
|
|
40
|
+
...props,
|
|
41
|
+
slots
|
|
42
|
+
});
|
|
43
|
+
}, {
|
|
44
|
+
name: "NaiveSidePanel",
|
|
45
|
+
props: {
|
|
46
|
+
model: { type: Object },
|
|
47
|
+
labels: { type: Object },
|
|
48
|
+
dir: { type: String },
|
|
49
|
+
classNames: { type: Object },
|
|
50
|
+
container: { type: Object }
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
function sidePanel(options) {
|
|
54
|
+
return extendFeature(sidePanel$1(options), [slotRender(SIDE_PANEL_CONTROL, (props) => h(NaiveSidePanel, { ...props }))]);
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
2
57
|
export { sidePanel };
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=side-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"side-panel.js","names":["bindingSidePanel"],"sources":["../src/actions/sidePanelControls.ts","../src/side-panel.ts"],"sourcesContent":["import { type SidePanelSlots, toVueAttrs } from \"@adapttable/vue/adapter\";\nimport { NCard } from \"naive-ui\";\nimport { h } from \"vue\";\n\nimport { naiveButton } from \"../controls/button\";\n\nexport const naiveSidePanelSlots = (\n names: Readonly<Record<string, string | undefined>> = {}\n): SidePanelSlots => ({\n Frame: (props) =>\n h(\n NCard,\n {\n tag: \"aside\",\n size: \"small\",\n \"data-adapttable-part\": \"side-panel\",\n class: props.className,\n \"data-side\": props.side,\n style: { minWidth: \"min(18rem,100%)\", maxWidth: \"100%\" },\n },\n { default: () => props.children }\n ),\n Tab: (props) =>\n naiveButton(\n { ...toVueAttrs(props.buttonProps), class: names.sidePanelTab },\n props.panel.label\n ),\n Close: (props) =>\n naiveButton(\n {\n \"aria-label\": props.label,\n \"data-adapttable-part\": \"side-panel-close\",\n class: names.sidePanelClose,\n onClick: props.onClose,\n },\n props.label\n ),\n});\n","import { type StaticTableFeature } from \"@adapttable/vue\";\nimport {\n extendFeature,\n SIDE_PANEL_CONTROL,\n SidePanelChrome,\n type SidePanelChromeProps,\n type SidePanelSlots,\n slotRender,\n} from \"@adapttable/vue/adapter\";\nimport { sidePanel as bindingSidePanel } from \"@adapttable/vue/features\";\nimport { defineComponent, h, type PropType } from \"vue\";\n\nimport { naiveSidePanelSlots } from \"./actions/sidePanelControls\";\nconst NaiveSidePanel = /*#__PURE__*/ defineComponent(\n (props: Omit<SidePanelChromeProps, \"slots\" | \"presentation\">) => {\n const slots: SidePanelSlots = {\n Frame: (control) => naiveSidePanelSlots(props.classNames).Frame(control),\n Tab: (control) => naiveSidePanelSlots(props.classNames).Tab(control),\n Close: (control) => naiveSidePanelSlots(props.classNames).Close(control),\n };\n return () => h(SidePanelChrome, { ...props, slots });\n },\n {\n name: \"NaiveSidePanel\",\n props: {\n model: {\n type: Object as PropType<\n Omit<SidePanelChromeProps, \"slots\" | \"presentation\">[\"model\"]\n >,\n },\n labels: {\n type: Object as PropType<\n Omit<SidePanelChromeProps, \"slots\" | \"presentation\">[\"labels\"]\n >,\n },\n dir: {\n type: String as PropType<\n Omit<SidePanelChromeProps, \"slots\" | \"presentation\">[\"dir\"]\n >,\n },\n classNames: {\n type: Object as PropType<\n Omit<SidePanelChromeProps, \"slots\" | \"presentation\">[\"classNames\"]\n >,\n },\n container: {\n type: Object as PropType<\n Omit<SidePanelChromeProps, \"slots\" | \"presentation\">[\"container\"]\n >,\n },\n },\n }\n);\nexport function sidePanel(\n options: Parameters<typeof bindingSidePanel>[0]\n): StaticTableFeature {\n return extendFeature(bindingSidePanel(options), [\n slotRender(SIDE_PANEL_CONTROL, (props) => h(NaiveSidePanel, { ...props })),\n ]);\n}\nexport type {\n SidePanelOptions,\n SidePanelPanel,\n} from \"@adapttable/vue/features\";\n"],"mappings":";;;;;;;AAMA,MAAa,uBACX,QAAsD,CAAC,OACnC;CACpB,QAAQ,UACN,EACE,OACA;EACE,KAAK;EACL,MAAM;EACN,wBAAwB;EACxB,OAAO,MAAM;EACb,aAAa,MAAM;EACnB,OAAO;GAAE,UAAU;GAAmB,UAAU;EAAO;CACzD,GACA,EAAE,eAAe,MAAM,SAAS,CAClC;CACF,MAAM,UACJ,YACE;EAAE,GAAG,WAAW,MAAM,WAAW;EAAG,OAAO,MAAM;CAAa,GAC9D,MAAM,MAAM,KACd;CACF,QAAQ,UACN,YACE;EACE,cAAc,MAAM;EACpB,wBAAwB;EACxB,OAAO,MAAM;EACb,SAAS,MAAM;CACjB,GACA,MAAM,KACR;AACJ;;;ACxBA,MAAM,iBAA+B,+BAClC,UAAgE;CAC/D,MAAM,QAAwB;EAC5B,QAAQ,YAAY,oBAAoB,MAAM,UAAU,CAAC,CAAC,MAAM,OAAO;EACvE,MAAM,YAAY,oBAAoB,MAAM,UAAU,CAAC,CAAC,IAAI,OAAO;EACnE,QAAQ,YAAY,oBAAoB,MAAM,UAAU,CAAC,CAAC,MAAM,OAAO;CACzE;CACA,aAAa,EAAE,iBAAiB;EAAE,GAAG;EAAO;CAAM,CAAC;AACrD,GACA;CACE,MAAM;CACN,OAAO;EACL,OAAO,EACL,MAAM,OAGR;EACA,QAAQ,EACN,MAAM,OAGR;EACA,KAAK,EACH,MAAM,OAGR;EACA,YAAY,EACV,MAAM,OAGR;EACA,WAAW,EACT,MAAM,OAGR;CACF;AACF,CACF;AACA,SAAgB,UACd,SACoB;CACpB,OAAO,cAAcA,YAAiB,OAAO,GAAG,CAC9C,WAAW,qBAAqB,UAAU,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAC,CAAC,CAC3E,CAAC;AACH"}
|