@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,305 @@
|
|
|
1
|
+
import { t as elementButton } from "./button-DwB4UxI2.js";
|
|
2
|
+
import { t as _sfc_main } from "./ElementInput-BsoAvPfO.js";
|
|
3
|
+
import { t as _sfc_main$1 } from "./ElementSelect-Cl5ZjuQM.js";
|
|
4
|
+
import { t as ElementCard } from "./ElementCard-DZdAU6x8.js";
|
|
5
|
+
import { defineComponent, h, shallowRef, watch } from "vue";
|
|
6
|
+
import { AgentApprovalChrome, TableAssistantChrome, createAdapterAgentApprovalFeature, createAdapterTableAssistantFeature, useScopeActivity } from "@adapttable/vue/adapter";
|
|
7
|
+
import { ElDrawer, ElDropdown, ElDropdownItem, ElDropdownMenu, ElTag } from "element-plus";
|
|
8
|
+
//#region src/assistant/ExamplesMenu.ts
|
|
9
|
+
/** One shortcut: its icon, title and optional description. */
|
|
10
|
+
function menuItem(item) {
|
|
11
|
+
return h(ElDropdownItem, {
|
|
12
|
+
key: item.id,
|
|
13
|
+
command: item.id,
|
|
14
|
+
"data-adapttable-part": item.part
|
|
15
|
+
}, { default: () => [item.icon, h("span", [h("strong", item.title), item.description ? h("small", item.description) : null])] });
|
|
16
|
+
}
|
|
17
|
+
/** The assistant's shortcuts in an Element Plus dropdown under its trigger. */
|
|
18
|
+
const ElementExamplesMenu = defineComponent((props) => {
|
|
19
|
+
const active = useScopeActivity();
|
|
20
|
+
const dropdown = shallowRef();
|
|
21
|
+
const trigger = shallowRef(null);
|
|
22
|
+
const open = shallowRef(false);
|
|
23
|
+
let generation = 0;
|
|
24
|
+
watch([
|
|
25
|
+
active,
|
|
26
|
+
() => props.disabled,
|
|
27
|
+
() => props.items,
|
|
28
|
+
() => props.onSelect
|
|
29
|
+
], () => {
|
|
30
|
+
generation++;
|
|
31
|
+
dropdown.value?.handleClose();
|
|
32
|
+
}, { flush: "sync" });
|
|
33
|
+
const keydown = (event) => {
|
|
34
|
+
if (event.key !== "Escape" || event.isComposing) return;
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
event.stopPropagation();
|
|
37
|
+
dropdown.value?.handleClose();
|
|
38
|
+
trigger.value?.focus({ preventScroll: true });
|
|
39
|
+
};
|
|
40
|
+
return () => {
|
|
41
|
+
if (!active.value) return null;
|
|
42
|
+
const ticket = generation;
|
|
43
|
+
const current = () => active.value && !props.disabled && ticket === generation;
|
|
44
|
+
return h(ElDropdown, {
|
|
45
|
+
ref: dropdown,
|
|
46
|
+
trigger: "click",
|
|
47
|
+
persistent: false,
|
|
48
|
+
hideTimeout: 0,
|
|
49
|
+
disabled: props.disabled,
|
|
50
|
+
maxHeight: props.maxHeight,
|
|
51
|
+
onVisibleChange: (value) => {
|
|
52
|
+
open.value = value;
|
|
53
|
+
},
|
|
54
|
+
onCommand: (id) => {
|
|
55
|
+
if (current() && typeof id === "string" && props.items.some((item) => item.id === id)) props.onSelect(id);
|
|
56
|
+
}
|
|
57
|
+
}, {
|
|
58
|
+
default: () => elementButton({
|
|
59
|
+
ref: (element) => {
|
|
60
|
+
trigger.value = element;
|
|
61
|
+
},
|
|
62
|
+
type: "button",
|
|
63
|
+
disabled: props.disabled,
|
|
64
|
+
"aria-label": props.label,
|
|
65
|
+
title: props.label,
|
|
66
|
+
class: props.className,
|
|
67
|
+
"data-adapttable-part": props.part,
|
|
68
|
+
onKeydown: (event) => {
|
|
69
|
+
if (open.value) keydown(event);
|
|
70
|
+
}
|
|
71
|
+
}, [props.icon ?? props.label]),
|
|
72
|
+
dropdown: () => h(ElDropdownMenu, {
|
|
73
|
+
"aria-label": props.label,
|
|
74
|
+
onKeydownCapture: keydown
|
|
75
|
+
}, { default: () => props.items.map(menuItem) })
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
}, {
|
|
79
|
+
name: "ElementExamplesMenu",
|
|
80
|
+
props: {
|
|
81
|
+
label: { type: String },
|
|
82
|
+
part: { type: String },
|
|
83
|
+
className: { type: String },
|
|
84
|
+
icon: {
|
|
85
|
+
type: [
|
|
86
|
+
String,
|
|
87
|
+
Number,
|
|
88
|
+
Boolean,
|
|
89
|
+
Array,
|
|
90
|
+
Object
|
|
91
|
+
],
|
|
92
|
+
default: void 0
|
|
93
|
+
},
|
|
94
|
+
disabled: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: void 0
|
|
97
|
+
},
|
|
98
|
+
items: { type: Array },
|
|
99
|
+
onSelect: { type: Function },
|
|
100
|
+
maxHeight: { type: String }
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/assistant/Sheet.ts
|
|
105
|
+
/**
|
|
106
|
+
* Chrome chooses initial and return focus; ElDrawer contains focus and owns
|
|
107
|
+
* the portal. Escape and backdrop dismissal become one close request to the
|
|
108
|
+
* host, and the drawer stays open until the host closes it.
|
|
109
|
+
*/
|
|
110
|
+
const ElementAssistantSheet = defineComponent((props) => {
|
|
111
|
+
const active = useScopeActivity();
|
|
112
|
+
const requestClose = () => {
|
|
113
|
+
if (active.value && props.open) props.onClose();
|
|
114
|
+
};
|
|
115
|
+
const preventDefault = (event) => event.preventDefault();
|
|
116
|
+
const keydown = (event) => {
|
|
117
|
+
if (event.key !== "Escape" || event.defaultPrevented || event.isComposing) return;
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
event.stopPropagation();
|
|
120
|
+
requestClose();
|
|
121
|
+
};
|
|
122
|
+
return () => {
|
|
123
|
+
if (!active.value) return null;
|
|
124
|
+
return h(ElDrawer, {
|
|
125
|
+
modelValue: props.open,
|
|
126
|
+
direction: props.dir === "rtl" ? "ltr" : "rtl",
|
|
127
|
+
size: "min(28rem, 100vw)",
|
|
128
|
+
withHeader: false,
|
|
129
|
+
showClose: false,
|
|
130
|
+
appendToBody: true,
|
|
131
|
+
destroyOnClose: true,
|
|
132
|
+
closeOnPressEscape: false,
|
|
133
|
+
title: props.label,
|
|
134
|
+
"aria-label": props.label,
|
|
135
|
+
dir: props.dir,
|
|
136
|
+
class: ["adapttable-element-plus-assistant-sheet", props.className],
|
|
137
|
+
"data-adapttable-part": props.part,
|
|
138
|
+
beforeClose: requestClose,
|
|
139
|
+
onKeydown: keydown,
|
|
140
|
+
"on:focus-trap.focus-after-trapped": preventDefault,
|
|
141
|
+
"on:focus-trap.focus-after-released": preventDefault
|
|
142
|
+
}, { default: () => props.children });
|
|
143
|
+
};
|
|
144
|
+
}, {
|
|
145
|
+
name: "ElementAssistantSheet",
|
|
146
|
+
props: {
|
|
147
|
+
label: { type: String },
|
|
148
|
+
part: { type: String },
|
|
149
|
+
className: { type: String },
|
|
150
|
+
dir: { type: String },
|
|
151
|
+
open: {
|
|
152
|
+
type: Boolean,
|
|
153
|
+
default: void 0
|
|
154
|
+
},
|
|
155
|
+
onClose: { type: Function },
|
|
156
|
+
children: {
|
|
157
|
+
type: [
|
|
158
|
+
String,
|
|
159
|
+
Number,
|
|
160
|
+
Boolean,
|
|
161
|
+
Array,
|
|
162
|
+
Object
|
|
163
|
+
],
|
|
164
|
+
default: void 0
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region src/assistant/controls.ts
|
|
170
|
+
/** Element Plus tag types for the assistant's status tones. */
|
|
171
|
+
const TAG_TYPE = {
|
|
172
|
+
neutral: "info",
|
|
173
|
+
busy: "primary",
|
|
174
|
+
warning: "warning",
|
|
175
|
+
danger: "danger"
|
|
176
|
+
};
|
|
177
|
+
const elementAssistantControls = {
|
|
178
|
+
Button: (props) => elementButton({
|
|
179
|
+
type: "button",
|
|
180
|
+
"data-adapttable-part": props.part,
|
|
181
|
+
"aria-label": props.label,
|
|
182
|
+
"aria-expanded": props.expanded,
|
|
183
|
+
title: props.tooltip,
|
|
184
|
+
class: props.className,
|
|
185
|
+
disabled: props.disabled,
|
|
186
|
+
onClick: props.onClick
|
|
187
|
+
}, [props.icon, props.iconOnly && props.icon ? null : props.children ?? props.label]),
|
|
188
|
+
Composer: (props) => h(_sfc_main, {
|
|
189
|
+
type: "textarea",
|
|
190
|
+
rows: 1,
|
|
191
|
+
value: props.value,
|
|
192
|
+
disabled: props.disabled,
|
|
193
|
+
"data-adapttable-part": props.part,
|
|
194
|
+
"aria-label": props.label,
|
|
195
|
+
placeholder: props.placeholder,
|
|
196
|
+
class: ["adapttable-element-plus-assistant-input", props.className],
|
|
197
|
+
onChange: props.onChange,
|
|
198
|
+
onKeydown: props.onKeyDown
|
|
199
|
+
}),
|
|
200
|
+
Badge: (props) => h(ElTag, {
|
|
201
|
+
"data-adapttable-part": props.part,
|
|
202
|
+
"data-tone": props.tone,
|
|
203
|
+
type: TAG_TYPE[props.tone],
|
|
204
|
+
size: "small",
|
|
205
|
+
effect: "light",
|
|
206
|
+
class: props.className
|
|
207
|
+
}, { default: () => props.label }),
|
|
208
|
+
Panel: (props) => h(ElementCard, { attrs: {
|
|
209
|
+
role: "region",
|
|
210
|
+
"data-adapttable-part": props.part,
|
|
211
|
+
"aria-label": props.label,
|
|
212
|
+
class: ["adapttable-element-plus-assistant-panel", props.className]
|
|
213
|
+
} }, { default: () => props.children }),
|
|
214
|
+
Window: (props) => h(ElementCard, { attrs: {
|
|
215
|
+
role: "region",
|
|
216
|
+
"data-adapttable-part": props.part,
|
|
217
|
+
"aria-label": props.label,
|
|
218
|
+
class: ["adapttable-element-plus-assistant-window", props.className],
|
|
219
|
+
style: props.style
|
|
220
|
+
} }, { default: () => props.children }),
|
|
221
|
+
Sheet: (props) => h(ElementAssistantSheet, {
|
|
222
|
+
...props,
|
|
223
|
+
key: props.part
|
|
224
|
+
}),
|
|
225
|
+
Menu: (props) => h(ElementExamplesMenu, props),
|
|
226
|
+
LanguageChip: (props) => h(_sfc_main$1, {
|
|
227
|
+
"data-adapttable-part": props.part,
|
|
228
|
+
"aria-label": props.label,
|
|
229
|
+
class: props.className,
|
|
230
|
+
disabled: props.disabled,
|
|
231
|
+
value: props.value,
|
|
232
|
+
options: props.options,
|
|
233
|
+
onChange: props.onChange
|
|
234
|
+
})
|
|
235
|
+
};
|
|
236
|
+
const elementApprovalControls = {
|
|
237
|
+
Approve: elementAssistantControls.Button,
|
|
238
|
+
Reject: elementAssistantControls.Button,
|
|
239
|
+
Action: elementAssistantControls.Button,
|
|
240
|
+
List: (props) => h("ul", {
|
|
241
|
+
"data-adapttable-part": props.part,
|
|
242
|
+
"aria-label": props.label,
|
|
243
|
+
class: ["adapttable-element-plus-approval-list", props.className]
|
|
244
|
+
}, [props.children])
|
|
245
|
+
};
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region src/assistant.ts
|
|
248
|
+
const TableAssistant = defineComponent((props) => () => h(TableAssistantChrome, {
|
|
249
|
+
...props,
|
|
250
|
+
accent: props.accent ?? "var(--el-color-primary)",
|
|
251
|
+
slots: elementAssistantControls
|
|
252
|
+
}), {
|
|
253
|
+
name: "ElementTableAssistant",
|
|
254
|
+
props: {
|
|
255
|
+
assistant: { type: Object },
|
|
256
|
+
speech: { type: Object },
|
|
257
|
+
open: {
|
|
258
|
+
type: Boolean,
|
|
259
|
+
default: void 0
|
|
260
|
+
},
|
|
261
|
+
onOpenChange: { type: Function },
|
|
262
|
+
presentation: { type: String },
|
|
263
|
+
labels: { type: Object },
|
|
264
|
+
accent: { type: String },
|
|
265
|
+
receipts: {
|
|
266
|
+
type: Boolean,
|
|
267
|
+
default: void 0
|
|
268
|
+
},
|
|
269
|
+
className: { type: String },
|
|
270
|
+
launcher: {
|
|
271
|
+
type: Boolean,
|
|
272
|
+
default: void 0
|
|
273
|
+
},
|
|
274
|
+
onSettings: { type: Function },
|
|
275
|
+
boundary: { type: [String, Object] },
|
|
276
|
+
note: { type: String },
|
|
277
|
+
greeting: { type: String },
|
|
278
|
+
avatars: { type: Object },
|
|
279
|
+
messageAction: { type: Function },
|
|
280
|
+
approval: { type: Object },
|
|
281
|
+
dir: { type: String }
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
const AgentApproval = defineComponent((props) => () => h(AgentApprovalChrome, {
|
|
285
|
+
...props,
|
|
286
|
+
slots: elementApprovalControls
|
|
287
|
+
}), {
|
|
288
|
+
name: "ElementAgentApproval",
|
|
289
|
+
props: {
|
|
290
|
+
pending: { type: Object },
|
|
291
|
+
labels: { type: Object },
|
|
292
|
+
className: { type: String },
|
|
293
|
+
buttonClassName: { type: String }
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
function tableAssistant() {
|
|
297
|
+
return createAdapterTableAssistantFeature((props) => h(TableAssistant, props));
|
|
298
|
+
}
|
|
299
|
+
function agentApproval() {
|
|
300
|
+
return createAdapterAgentApprovalFeature((props) => h(AgentApproval, props));
|
|
301
|
+
}
|
|
302
|
+
//#endregion
|
|
303
|
+
export { tableAssistant as i, TableAssistant as n, agentApproval as r, AgentApproval as t };
|
|
304
|
+
|
|
305
|
+
//# sourceMappingURL=assistant-Dv4a3KEk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant-Dv4a3KEk.js","names":["ElementInput","ElementSelect"],"sources":["../src/assistant/ExamplesMenu.ts","../src/assistant/Sheet.ts","../src/assistant/controls.ts","../src/assistant.ts"],"sourcesContent":["import {\n type TableAssistantMenuProps,\n useScopeActivity,\n} from \"@adapttable/vue/adapter\";\nimport {\n type DropdownInstance,\n ElDropdown,\n ElDropdownItem,\n ElDropdownMenu,\n} from \"element-plus\";\nimport { defineComponent, h, type PropType, shallowRef, watch } from \"vue\";\n\nimport { elementButton } from \"../controls/button\";\n\n/** One shortcut: its icon, title and optional description. */\nfunction menuItem(item: TableAssistantMenuProps[\"items\"][number]) {\n return h(\n ElDropdownItem,\n { key: item.id, command: item.id, \"data-adapttable-part\": item.part },\n {\n default: () => [\n item.icon,\n h(\"span\", [\n h(\"strong\", item.title),\n item.description ? h(\"small\", item.description) : null,\n ]),\n ],\n }\n );\n}\n\n/** The assistant's shortcuts in an Element Plus dropdown under its trigger. */\nexport const ElementExamplesMenu = defineComponent(\n (props: TableAssistantMenuProps) => {\n const active = useScopeActivity();\n const dropdown = shallowRef<DropdownInstance>();\n const trigger = shallowRef<HTMLElement | null>(null);\n const open = shallowRef(false);\n let generation = 0;\n watch(\n [active, () => props.disabled, () => props.items, () => props.onSelect],\n () => {\n generation++;\n dropdown.value?.handleClose();\n },\n { flush: \"sync\" }\n );\n // The menu closes itself on Escape and hands focus back to its trigger,\n // so an Escape inside it never reaches the surface around the trigger.\n const keydown = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\" || event.isComposing) return;\n event.preventDefault();\n event.stopPropagation();\n dropdown.value?.handleClose();\n trigger.value?.focus({ preventScroll: true });\n };\n return () => {\n if (!active.value) return null;\n const ticket = generation;\n const current = () =>\n active.value && !props.disabled && ticket === generation;\n return h(\n ElDropdown,\n {\n ref: dropdown,\n trigger: \"click\",\n persistent: false,\n hideTimeout: 0,\n disabled: props.disabled,\n maxHeight: props.maxHeight,\n onVisibleChange: (value: boolean) => {\n open.value = value;\n },\n onCommand: (id: unknown) => {\n if (\n current() &&\n typeof id === \"string\" &&\n props.items.some((item) => item.id === id)\n )\n props.onSelect(id);\n },\n },\n {\n default: () =>\n elementButton(\n {\n ref: (element: HTMLElement | null) => {\n trigger.value = element;\n },\n type: \"button\",\n disabled: props.disabled,\n \"aria-label\": props.label,\n title: props.label,\n class: props.className,\n \"data-adapttable-part\": props.part,\n onKeydown: (event: KeyboardEvent) => {\n if (open.value) keydown(event);\n },\n },\n [props.icon ?? props.label]\n ),\n dropdown: () =>\n h(\n ElDropdownMenu,\n // Captured on the list so an Escape from any item reaches it\n // before Element's own handling moves focus into the list.\n { \"aria-label\": props.label, onKeydownCapture: keydown },\n { default: () => props.items.map(menuItem) }\n ),\n }\n );\n };\n },\n {\n name: \"ElementExamplesMenu\",\n props: {\n label: { type: String as PropType<TableAssistantMenuProps[\"label\"]> },\n part: { type: String as PropType<TableAssistantMenuProps[\"part\"]> },\n className: {\n type: String as PropType<TableAssistantMenuProps[\"className\"]>,\n },\n icon: {\n type: [String, Number, Boolean, Array, Object] as PropType<\n TableAssistantMenuProps[\"icon\"]\n >,\n default: undefined,\n },\n disabled: {\n type: Boolean as PropType<TableAssistantMenuProps[\"disabled\"]>,\n default: undefined,\n },\n items: { type: Array as PropType<TableAssistantMenuProps[\"items\"]> },\n onSelect: {\n type: Function as PropType<TableAssistantMenuProps[\"onSelect\"]>,\n },\n maxHeight: {\n type: String as PropType<TableAssistantMenuProps[\"maxHeight\"]>,\n },\n },\n }\n);\n","import {\n type TableAssistantSheetProps,\n useScopeActivity,\n} from \"@adapttable/vue/adapter\";\nimport { ElDrawer } from \"element-plus\";\nimport { defineComponent, h, type PropType } from \"vue\";\n\n/**\n * Chrome chooses initial and return focus; ElDrawer contains focus and owns\n * the portal. Escape and backdrop dismissal become one close request to the\n * host, and the drawer stays open until the host closes it.\n */\nexport const ElementAssistantSheet = defineComponent(\n (props: TableAssistantSheetProps) => {\n const active = useScopeActivity();\n const requestClose = () => {\n if (active.value && props.open) props.onClose();\n };\n const preventDefault = (event: Event) => event.preventDefault();\n const keydown = (event: KeyboardEvent) => {\n if (event.key !== \"Escape\" || event.defaultPrevented || event.isComposing)\n return;\n event.preventDefault();\n event.stopPropagation();\n requestClose();\n };\n return () => {\n if (!active.value) return null;\n return h(\n ElDrawer,\n {\n modelValue: props.open,\n direction: props.dir === \"rtl\" ? \"ltr\" : \"rtl\",\n size: \"min(28rem, 100vw)\",\n withHeader: false,\n showClose: false,\n appendToBody: true,\n destroyOnClose: true,\n closeOnPressEscape: false,\n title: props.label,\n \"aria-label\": props.label,\n dir: props.dir,\n class: [\"adapttable-element-plus-assistant-sheet\", props.className],\n \"data-adapttable-part\": props.part,\n beforeClose: requestClose,\n onKeydown: keydown,\n // Chrome places the initial focus and returns it to the launcher;\n // the drawer's trap only keeps focus inside while open.\n \"on:focus-trap.focus-after-trapped\": preventDefault,\n \"on:focus-trap.focus-after-released\": preventDefault,\n },\n { default: () => props.children }\n );\n };\n },\n {\n name: \"ElementAssistantSheet\",\n props: {\n label: { type: String as PropType<TableAssistantSheetProps[\"label\"]> },\n part: { type: String as PropType<TableAssistantSheetProps[\"part\"]> },\n className: {\n type: String as PropType<TableAssistantSheetProps[\"className\"]>,\n },\n dir: { type: String as PropType<TableAssistantSheetProps[\"dir\"]> },\n open: {\n type: Boolean as PropType<TableAssistantSheetProps[\"open\"]>,\n default: undefined,\n },\n onClose: {\n type: Function as PropType<TableAssistantSheetProps[\"onClose\"]>,\n },\n children: {\n type: [String, Number, Boolean, Array, Object] as PropType<\n TableAssistantSheetProps[\"children\"]\n >,\n default: undefined,\n },\n },\n }\n);\n","import type {\n ApprovalReviewSlots,\n TableAssistantSlots,\n} from \"@adapttable/vue/adapter\";\nimport { ElTag } from \"element-plus\";\nimport { h } from \"vue\";\n\nimport { elementButton } from \"../controls/button\";\nimport ElementInput from \"../controls/ElementInput.vue\";\nimport ElementSelect from \"../controls/ElementSelect.vue\";\nimport { ElementCard } from \"../presentation/ElementCard\";\nimport { ElementExamplesMenu } from \"./ExamplesMenu\";\nimport { ElementAssistantSheet } from \"./Sheet\";\n\n/** Element Plus tag types for the assistant's status tones. */\nconst TAG_TYPE = {\n neutral: \"info\",\n busy: \"primary\",\n warning: \"warning\",\n danger: \"danger\",\n} as const;\n\nexport const elementAssistantControls: TableAssistantSlots = {\n Button: (props) =>\n elementButton(\n {\n type: \"button\",\n \"data-adapttable-part\": props.part,\n \"aria-label\": props.label,\n \"aria-expanded\": props.expanded,\n title: props.tooltip,\n class: props.className,\n disabled: props.disabled,\n onClick: props.onClick,\n },\n [\n props.icon,\n props.iconOnly && props.icon ? null : (props.children ?? props.label),\n ]\n ),\n Composer: (props) =>\n h(ElementInput, {\n type: \"textarea\",\n rows: 1,\n value: props.value,\n disabled: props.disabled,\n \"data-adapttable-part\": props.part,\n \"aria-label\": props.label,\n placeholder: props.placeholder,\n class: [\"adapttable-element-plus-assistant-input\", props.className],\n onChange: props.onChange,\n onKeydown: props.onKeyDown,\n }),\n Badge: (props) =>\n h(\n ElTag,\n {\n \"data-adapttable-part\": props.part,\n \"data-tone\": props.tone,\n type: TAG_TYPE[props.tone],\n size: \"small\",\n effect: \"light\",\n class: props.className,\n },\n { default: () => props.label }\n ),\n Panel: (props) =>\n h(\n ElementCard,\n {\n attrs: {\n role: \"region\",\n \"data-adapttable-part\": props.part,\n \"aria-label\": props.label,\n class: [\"adapttable-element-plus-assistant-panel\", props.className],\n },\n },\n { default: () => props.children }\n ),\n Window: (props) =>\n h(\n ElementCard,\n {\n attrs: {\n role: \"region\",\n \"data-adapttable-part\": props.part,\n \"aria-label\": props.label,\n class: [\"adapttable-element-plus-assistant-window\", props.className],\n style: props.style,\n },\n },\n { default: () => props.children }\n ),\n Sheet: (props) => h(ElementAssistantSheet, { ...props, key: props.part }),\n Menu: (props) => h(ElementExamplesMenu, props),\n LanguageChip: (props) =>\n h(ElementSelect, {\n \"data-adapttable-part\": props.part,\n \"aria-label\": props.label,\n class: props.className,\n disabled: props.disabled,\n value: props.value,\n options: props.options,\n onChange: props.onChange,\n }),\n};\n\nexport const elementApprovalControls: ApprovalReviewSlots = {\n Approve: elementAssistantControls.Button,\n Reject: elementAssistantControls.Button,\n Action: elementAssistantControls.Button,\n List: (props) =>\n h(\n \"ul\",\n {\n \"data-adapttable-part\": props.part,\n \"aria-label\": props.label,\n class: [\"adapttable-element-plus-approval-list\", props.className],\n },\n [props.children]\n ),\n};\n","/** Optional assistant presentation; all conversation and approval state stays in the binding. */\nimport \"./assistant/assistant.css\";\n\nimport type { StaticTableFeature } from \"@adapttable/vue\";\nimport {\n AgentApprovalChrome,\n type AgentApprovalProps,\n createAdapterAgentApprovalFeature,\n createAdapterTableAssistantFeature,\n TableAssistantChrome,\n type TableAssistantProps,\n} from \"@adapttable/vue/adapter\";\nimport { defineComponent, h, type PropType } from \"vue\";\n\nimport {\n elementApprovalControls,\n elementAssistantControls,\n} from \"./assistant/controls\";\n\nexport const TableAssistant = defineComponent(\n (props: TableAssistantProps) => () =>\n h(TableAssistantChrome, {\n ...props,\n accent: props.accent ?? \"var(--el-color-primary)\",\n slots: elementAssistantControls,\n }),\n {\n name: \"ElementTableAssistant\",\n props: {\n assistant: { type: Object as PropType<TableAssistantProps[\"assistant\"]> },\n speech: { type: Object as PropType<TableAssistantProps[\"speech\"]> },\n open: {\n type: Boolean as PropType<TableAssistantProps[\"open\"]>,\n default: undefined,\n },\n onOpenChange: {\n type: Function as PropType<TableAssistantProps[\"onOpenChange\"]>,\n },\n presentation: {\n type: String as PropType<TableAssistantProps[\"presentation\"]>,\n },\n labels: { type: Object as PropType<TableAssistantProps[\"labels\"]> },\n accent: { type: String as PropType<TableAssistantProps[\"accent\"]> },\n receipts: {\n type: Boolean as PropType<TableAssistantProps[\"receipts\"]>,\n default: undefined,\n },\n className: { type: String as PropType<TableAssistantProps[\"className\"]> },\n launcher: {\n type: Boolean as PropType<TableAssistantProps[\"launcher\"]>,\n default: undefined,\n },\n onSettings: {\n type: Function as PropType<TableAssistantProps[\"onSettings\"]>,\n },\n boundary: {\n type: [String, Object] as PropType<TableAssistantProps[\"boundary\"]>,\n },\n note: { type: String as PropType<TableAssistantProps[\"note\"]> },\n greeting: { type: String as PropType<TableAssistantProps[\"greeting\"]> },\n avatars: { type: Object as PropType<TableAssistantProps[\"avatars\"]> },\n messageAction: {\n type: Function as PropType<TableAssistantProps[\"messageAction\"]>,\n },\n approval: { type: Object as PropType<TableAssistantProps[\"approval\"]> },\n dir: { type: String as PropType<TableAssistantProps[\"dir\"]> },\n },\n }\n);\nexport const AgentApproval = defineComponent(\n (props: AgentApprovalProps) => () =>\n h(AgentApprovalChrome, { ...props, slots: elementApprovalControls }),\n {\n name: \"ElementAgentApproval\",\n props: {\n pending: { type: Object as PropType<AgentApprovalProps[\"pending\"]> },\n labels: { type: Object as PropType<AgentApprovalProps[\"labels\"]> },\n className: { type: String as PropType<AgentApprovalProps[\"className\"]> },\n buttonClassName: {\n type: String as PropType<AgentApprovalProps[\"buttonClassName\"]>,\n },\n },\n }\n);\nexport function tableAssistant(): StaticTableFeature {\n return createAdapterTableAssistantFeature((props) =>\n h(TableAssistant, props)\n );\n}\nexport function agentApproval(): StaticTableFeature {\n return createAdapterAgentApprovalFeature((props) => h(AgentApproval, props));\n}\nexport type {\n AgentApprovalProps,\n Table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,MAAM,OACR;EACA,QAAQ,EAAE,MAAM,OAAkD;EAClE,QAAQ,EAAE,MAAM,OAAkD;EAClE,UAAU;GACR,MAAM;GACN,SAAS,KAAA;EACX;EACA,WAAW,EAAE,MAAM,OAAqD;EACxE,UAAU;GACR,MAAM;GACN,SAAS,KAAA;EACX;EACA,YAAY,EACV,MAAM,SACR;EACA,UAAU,EACR,MAAM,CAAC,QAAQ,MAAM,EACvB;EACA,MAAM,EAAE,MAAM,OAAgD;EAC9D,UAAU,EAAE,MAAM,OAAoD;EACtE,SAAS,EAAE,MAAM,OAAmD;EACpE,eAAe,EACb,MAAM,SACR;EACA,UAAU,EAAE,MAAM,OAAoD;EACtE,KAAK,EAAE,MAAM,OAA+C;CAC9D;AACF,CACF;AACA,MAAa,gBAAgB,iBAC1B,gBACC,EAAE,qBAAqB;CAAE,GAAG;CAAO,OAAO;AAAwB,CAAC,GACrE;CACE,MAAM;CACN,OAAO;EACL,SAAS,EAAE,MAAM,OAAkD;EACnE,QAAQ,EAAE,MAAM,OAAiD;EACjE,WAAW,EAAE,MAAM,OAAoD;EACvE,iBAAiB,EACf,MAAM,OACR;CACF;AACF,CACF;AACA,SAAgB,iBAAqC;CACnD,OAAO,oCAAoC,UACzC,EAAE,gBAAgB,KAAK,CACzB;AACF;AACA,SAAgB,gBAAoC;CAClD,OAAO,mCAAmC,UAAU,EAAE,eAAe,KAAK,CAAC;AAC7E"}
|
package/dist/assistant.cjs
CHANGED
|
@@ -1,301 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
let _adapttable_vue_adapter = require("@adapttable/vue/adapter");
|
|
8
|
-
let element_plus = require("element-plus");
|
|
9
|
-
//#region src/assistant/ExamplesMenu.ts
|
|
10
|
-
/** One shortcut: its icon, title and optional description. */
|
|
11
|
-
function menuItem(item) {
|
|
12
|
-
return (0, vue.h)(element_plus.ElDropdownItem, {
|
|
13
|
-
key: item.id,
|
|
14
|
-
command: item.id,
|
|
15
|
-
"data-adapttable-part": item.part
|
|
16
|
-
}, { default: () => [item.icon, (0, vue.h)("span", [(0, vue.h)("strong", item.title), item.description ? (0, vue.h)("small", item.description) : null])] });
|
|
17
|
-
}
|
|
18
|
-
/** The assistant's shortcuts in an Element Plus dropdown under its trigger. */
|
|
19
|
-
const ElementExamplesMenu = (0, vue.defineComponent)((props) => {
|
|
20
|
-
const active = (0, _adapttable_vue_adapter.useScopeActivity)();
|
|
21
|
-
const dropdown = (0, vue.shallowRef)();
|
|
22
|
-
const trigger = (0, vue.shallowRef)(null);
|
|
23
|
-
let generation = 0;
|
|
24
|
-
(0, vue.watch)([
|
|
25
|
-
active,
|
|
26
|
-
() => props.disabled,
|
|
27
|
-
() => props.items,
|
|
28
|
-
() => props.onSelect
|
|
29
|
-
], () => {
|
|
30
|
-
generation++;
|
|
31
|
-
dropdown.value?.handleClose();
|
|
32
|
-
}, { flush: "sync" });
|
|
33
|
-
const keydown = (event) => {
|
|
34
|
-
if (event.key !== "Escape" || event.isComposing) return;
|
|
35
|
-
event.preventDefault();
|
|
36
|
-
event.stopPropagation();
|
|
37
|
-
dropdown.value?.handleClose();
|
|
38
|
-
trigger.value?.focus({ preventScroll: true });
|
|
39
|
-
};
|
|
40
|
-
return () => {
|
|
41
|
-
if (!active.value) return null;
|
|
42
|
-
const ticket = generation;
|
|
43
|
-
const current = () => active.value && !props.disabled && ticket === generation;
|
|
44
|
-
return (0, vue.h)(element_plus.ElDropdown, {
|
|
45
|
-
ref: dropdown,
|
|
46
|
-
trigger: "click",
|
|
47
|
-
persistent: false,
|
|
48
|
-
hideTimeout: 0,
|
|
49
|
-
disabled: props.disabled,
|
|
50
|
-
maxHeight: props.maxHeight,
|
|
51
|
-
onCommand: (id) => {
|
|
52
|
-
if (current() && typeof id === "string" && props.items.some((item) => item.id === id)) props.onSelect(id);
|
|
53
|
-
}
|
|
54
|
-
}, {
|
|
55
|
-
default: () => require_button.elementButton({
|
|
56
|
-
ref: (element) => {
|
|
57
|
-
trigger.value = element;
|
|
58
|
-
},
|
|
59
|
-
type: "button",
|
|
60
|
-
disabled: props.disabled,
|
|
61
|
-
"aria-label": props.label,
|
|
62
|
-
title: props.label,
|
|
63
|
-
class: props.className,
|
|
64
|
-
"data-adapttable-part": props.part
|
|
65
|
-
}, [props.icon, props.label]),
|
|
66
|
-
dropdown: () => (0, vue.h)(element_plus.ElDropdownMenu, {
|
|
67
|
-
"aria-label": props.label,
|
|
68
|
-
onKeydownCapture: keydown
|
|
69
|
-
}, { default: () => props.items.map(menuItem) })
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
}, {
|
|
73
|
-
name: "ElementExamplesMenu",
|
|
74
|
-
props: {
|
|
75
|
-
label: { type: String },
|
|
76
|
-
part: { type: String },
|
|
77
|
-
className: { type: String },
|
|
78
|
-
icon: {
|
|
79
|
-
type: [
|
|
80
|
-
String,
|
|
81
|
-
Number,
|
|
82
|
-
Boolean,
|
|
83
|
-
Array,
|
|
84
|
-
Object
|
|
85
|
-
],
|
|
86
|
-
default: void 0
|
|
87
|
-
},
|
|
88
|
-
disabled: {
|
|
89
|
-
type: Boolean,
|
|
90
|
-
default: void 0
|
|
91
|
-
},
|
|
92
|
-
items: { type: Array },
|
|
93
|
-
onSelect: { type: Function },
|
|
94
|
-
maxHeight: { type: String }
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
//#endregion
|
|
98
|
-
//#region src/assistant/Sheet.ts
|
|
99
|
-
/**
|
|
100
|
-
* Chrome chooses initial and return focus; ElDrawer contains focus and owns
|
|
101
|
-
* the portal. Escape and backdrop dismissal become one close request to the
|
|
102
|
-
* host, and the drawer stays open until the host closes it.
|
|
103
|
-
*/
|
|
104
|
-
const ElementAssistantSheet = (0, vue.defineComponent)((props) => {
|
|
105
|
-
const active = (0, _adapttable_vue_adapter.useScopeActivity)();
|
|
106
|
-
const requestClose = () => {
|
|
107
|
-
if (active.value && props.open) props.onClose();
|
|
108
|
-
};
|
|
109
|
-
const preventDefault = (event) => event.preventDefault();
|
|
110
|
-
const keydown = (event) => {
|
|
111
|
-
if (event.key !== "Escape" || event.defaultPrevented || event.isComposing) return;
|
|
112
|
-
event.preventDefault();
|
|
113
|
-
event.stopPropagation();
|
|
114
|
-
requestClose();
|
|
115
|
-
};
|
|
116
|
-
return () => {
|
|
117
|
-
if (!active.value) return null;
|
|
118
|
-
return (0, vue.h)(element_plus.ElDrawer, {
|
|
119
|
-
modelValue: props.open,
|
|
120
|
-
direction: props.dir === "rtl" ? "ltr" : "rtl",
|
|
121
|
-
size: "min(28rem, 100vw)",
|
|
122
|
-
withHeader: false,
|
|
123
|
-
showClose: false,
|
|
124
|
-
appendToBody: true,
|
|
125
|
-
destroyOnClose: true,
|
|
126
|
-
closeOnPressEscape: false,
|
|
127
|
-
title: props.label,
|
|
128
|
-
"aria-label": props.label,
|
|
129
|
-
dir: props.dir,
|
|
130
|
-
class: ["adapttable-element-plus-assistant-sheet", props.className],
|
|
131
|
-
"data-adapttable-part": props.part,
|
|
132
|
-
beforeClose: requestClose,
|
|
133
|
-
onKeydown: keydown,
|
|
134
|
-
"on:focus-trap.focus-after-trapped": preventDefault,
|
|
135
|
-
"on:focus-trap.focus-after-released": preventDefault
|
|
136
|
-
}, { default: () => props.children });
|
|
137
|
-
};
|
|
138
|
-
}, {
|
|
139
|
-
name: "ElementAssistantSheet",
|
|
140
|
-
props: {
|
|
141
|
-
label: { type: String },
|
|
142
|
-
part: { type: String },
|
|
143
|
-
className: { type: String },
|
|
144
|
-
dir: { type: String },
|
|
145
|
-
open: {
|
|
146
|
-
type: Boolean,
|
|
147
|
-
default: void 0
|
|
148
|
-
},
|
|
149
|
-
onClose: { type: Function },
|
|
150
|
-
children: {
|
|
151
|
-
type: [
|
|
152
|
-
String,
|
|
153
|
-
Number,
|
|
154
|
-
Boolean,
|
|
155
|
-
Array,
|
|
156
|
-
Object
|
|
157
|
-
],
|
|
158
|
-
default: void 0
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
//#endregion
|
|
163
|
-
//#region src/assistant/controls.ts
|
|
164
|
-
/** Element Plus tag types for the assistant's status tones. */
|
|
165
|
-
const TAG_TYPE = {
|
|
166
|
-
neutral: "info",
|
|
167
|
-
busy: "primary",
|
|
168
|
-
warning: "warning",
|
|
169
|
-
danger: "danger"
|
|
170
|
-
};
|
|
171
|
-
const elementAssistantControls = {
|
|
172
|
-
Button: (props) => require_button.elementButton({
|
|
173
|
-
type: "button",
|
|
174
|
-
"data-adapttable-part": props.part,
|
|
175
|
-
"aria-label": props.label,
|
|
176
|
-
"aria-expanded": props.expanded,
|
|
177
|
-
title: props.tooltip,
|
|
178
|
-
class: props.className,
|
|
179
|
-
disabled: props.disabled,
|
|
180
|
-
onClick: props.onClick
|
|
181
|
-
}, [props.icon, props.iconOnly && props.icon ? null : props.children ?? props.label]),
|
|
182
|
-
Composer: (props) => (0, vue.h)(require_ElementInput._sfc_main, {
|
|
183
|
-
type: "textarea",
|
|
184
|
-
rows: 2,
|
|
185
|
-
value: props.value,
|
|
186
|
-
disabled: props.disabled,
|
|
187
|
-
"data-adapttable-part": props.part,
|
|
188
|
-
"aria-label": props.label,
|
|
189
|
-
placeholder: props.placeholder,
|
|
190
|
-
class: ["adapttable-element-plus-assistant-input", props.className],
|
|
191
|
-
onChange: props.onChange,
|
|
192
|
-
onKeydown: props.onKeyDown
|
|
193
|
-
}),
|
|
194
|
-
Badge: (props) => (0, vue.h)(element_plus.ElTag, {
|
|
195
|
-
"data-adapttable-part": props.part,
|
|
196
|
-
"data-tone": props.tone,
|
|
197
|
-
type: TAG_TYPE[props.tone],
|
|
198
|
-
size: "small",
|
|
199
|
-
effect: "light",
|
|
200
|
-
class: props.className
|
|
201
|
-
}, { default: () => props.label }),
|
|
202
|
-
Panel: (props) => (0, vue.h)(require_ElementCard.ElementCard, { attrs: {
|
|
203
|
-
role: "region",
|
|
204
|
-
"data-adapttable-part": props.part,
|
|
205
|
-
"aria-label": props.label,
|
|
206
|
-
class: ["adapttable-element-plus-assistant-panel", props.className]
|
|
207
|
-
} }, { default: () => props.children }),
|
|
208
|
-
Window: (props) => (0, vue.h)(require_ElementCard.ElementCard, { attrs: {
|
|
209
|
-
role: "region",
|
|
210
|
-
"data-adapttable-part": props.part,
|
|
211
|
-
"aria-label": props.label,
|
|
212
|
-
class: ["adapttable-element-plus-assistant-window", props.className],
|
|
213
|
-
style: props.style
|
|
214
|
-
} }, { default: () => props.children }),
|
|
215
|
-
Sheet: (props) => (0, vue.h)(ElementAssistantSheet, {
|
|
216
|
-
...props,
|
|
217
|
-
key: props.part
|
|
218
|
-
}),
|
|
219
|
-
Menu: (props) => (0, vue.h)(ElementExamplesMenu, props),
|
|
220
|
-
LanguageChip: (props) => (0, vue.h)(require_ElementSelect._sfc_main, {
|
|
221
|
-
"data-adapttable-part": props.part,
|
|
222
|
-
"aria-label": props.label,
|
|
223
|
-
class: props.className,
|
|
224
|
-
disabled: props.disabled,
|
|
225
|
-
value: props.value,
|
|
226
|
-
options: props.options,
|
|
227
|
-
onChange: props.onChange
|
|
228
|
-
})
|
|
229
|
-
};
|
|
230
|
-
const elementApprovalControls = {
|
|
231
|
-
Approve: elementAssistantControls.Button,
|
|
232
|
-
Reject: elementAssistantControls.Button,
|
|
233
|
-
Action: elementAssistantControls.Button,
|
|
234
|
-
List: (props) => (0, vue.h)("ul", {
|
|
235
|
-
"data-adapttable-part": props.part,
|
|
236
|
-
"aria-label": props.label,
|
|
237
|
-
class: ["adapttable-element-plus-approval-list", props.className]
|
|
238
|
-
}, [props.children])
|
|
239
|
-
};
|
|
240
|
-
//#endregion
|
|
241
|
-
//#region src/assistant.ts
|
|
242
|
-
const TableAssistant = (0, vue.defineComponent)((props) => () => (0, vue.h)(_adapttable_vue_adapter.TableAssistantChrome, {
|
|
243
|
-
...props,
|
|
244
|
-
slots: elementAssistantControls
|
|
245
|
-
}), {
|
|
246
|
-
name: "ElementTableAssistant",
|
|
247
|
-
props: {
|
|
248
|
-
assistant: { type: Object },
|
|
249
|
-
speech: { type: Object },
|
|
250
|
-
open: {
|
|
251
|
-
type: Boolean,
|
|
252
|
-
default: void 0
|
|
253
|
-
},
|
|
254
|
-
onOpenChange: { type: Function },
|
|
255
|
-
presentation: { type: String },
|
|
256
|
-
labels: { type: Object },
|
|
257
|
-
accent: { type: String },
|
|
258
|
-
receipts: {
|
|
259
|
-
type: Boolean,
|
|
260
|
-
default: void 0
|
|
261
|
-
},
|
|
262
|
-
className: { type: String },
|
|
263
|
-
launcher: {
|
|
264
|
-
type: Boolean,
|
|
265
|
-
default: void 0
|
|
266
|
-
},
|
|
267
|
-
onSettings: { type: Function },
|
|
268
|
-
boundary: { type: [String, Object] },
|
|
269
|
-
note: { type: String },
|
|
270
|
-
greeting: { type: String },
|
|
271
|
-
avatars: { type: Object },
|
|
272
|
-
messageAction: { type: Function },
|
|
273
|
-
approval: { type: Object },
|
|
274
|
-
dir: { type: String }
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
const AgentApproval = (0, vue.defineComponent)((props) => () => (0, vue.h)(_adapttable_vue_adapter.AgentApprovalChrome, {
|
|
278
|
-
...props,
|
|
279
|
-
slots: elementApprovalControls
|
|
280
|
-
}), {
|
|
281
|
-
name: "ElementAgentApproval",
|
|
282
|
-
props: {
|
|
283
|
-
pending: { type: Object },
|
|
284
|
-
labels: { type: Object },
|
|
285
|
-
className: { type: String },
|
|
286
|
-
buttonClassName: { type: String }
|
|
287
|
-
}
|
|
288
|
-
});
|
|
289
|
-
function tableAssistant() {
|
|
290
|
-
return (0, _adapttable_vue_adapter.createAdapterTableAssistantFeature)((props) => (0, vue.h)(TableAssistant, props));
|
|
291
|
-
}
|
|
292
|
-
function agentApproval() {
|
|
293
|
-
return (0, _adapttable_vue_adapter.createAdapterAgentApprovalFeature)((props) => (0, vue.h)(AgentApproval, props));
|
|
294
|
-
}
|
|
295
|
-
//#endregion
|
|
296
|
-
exports.AgentApproval = AgentApproval;
|
|
297
|
-
exports.TableAssistant = TableAssistant;
|
|
298
|
-
exports.agentApproval = agentApproval;
|
|
299
|
-
exports.tableAssistant = tableAssistant;
|
|
300
|
-
|
|
301
|
-
//# sourceMappingURL=assistant.cjs.map
|
|
2
|
+
const require_assistant = require("./assistant-BcVKhdKt.cjs");
|
|
3
|
+
exports.AgentApproval = require_assistant.AgentApproval;
|
|
4
|
+
exports.TableAssistant = require_assistant.TableAssistant;
|
|
5
|
+
exports.agentApproval = require_assistant.agentApproval;
|
|
6
|
+
exports.tableAssistant = require_assistant.tableAssistant;
|
package/dist/assistant.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant.d.cts","names":[],"sources":["../src/assistant.ts"],"mappings":";;;cAmBa,8BAAc,uBAAA,+BAAA,0CAAA;
|
|
1
|
+
{"version":3,"file":"assistant.d.cts","names":[],"sources":["../src/assistant.ts"],"mappings":";;;cAmBa,8BAAc,uBAAA,+BAAA,0CAAA;cAkDd,6BAAa,uBAAA,8BAAA,yCAAA;iBAeV,kBAAkB;iBAKlB,iBAAiB"}
|
package/dist/assistant.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assistant.d.ts","names":[],"sources":["../src/assistant.ts"],"mappings":";;;cAmBa,8BAAc,uBAAA,+BAAA,0CAAA;
|
|
1
|
+
{"version":3,"file":"assistant.d.ts","names":[],"sources":["../src/assistant.ts"],"mappings":";;;cAmBa,8BAAc,uBAAA,+BAAA,0CAAA;cAkDd,6BAAa,uBAAA,8BAAA,yCAAA;iBAeV,kBAAkB;iBAKlB,iBAAiB"}
|