@progress/kendo-vue-buttons 8.2.0 → 8.3.0-develop.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,245 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2026 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ import { defineComponent as x, createVNode as g, isVNode as F } from "vue";
9
+ import { getDefaultSlots as v, getKendoPasteEventTarget as T, dispatchKendoPasteEvent as B, validatePackage as w } from "@progress/kendo-vue-common";
10
+ import { KendoSmartPaste as A } from "@progress/kendo-smartpaste-common";
11
+ import { Button as S } from "../Button.mjs";
12
+ import { pasteSparkleIcon as N } from "@progress/kendo-svg-icons";
13
+ import { packageMetadata as O } from "../package-metadata.mjs";
14
+ function $(e) {
15
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !F(e);
16
+ }
17
+ const L = [".k-input", ".k-picker", ".k-checkbox", ".k-radio", ".k-switch", ".k-rating", ".k-slider"], M = (e) => {
18
+ const t = e.querySelector("input, select, textarea");
19
+ return (t == null ? void 0 : t.getAttribute("name")) || (t == null ? void 0 : t.getAttribute("id")) || e.getAttribute("id") || null;
20
+ }, V = (e, t) => {
21
+ const r = e.element, n = r instanceof HTMLInputElement || r instanceof HTMLSelectElement || r instanceof HTMLTextAreaElement ? r : r.querySelector("input, select, textarea");
22
+ if (n) {
23
+ if (n instanceof HTMLSelectElement) {
24
+ const i = Array.from(n.querySelectorAll("option")), s = i.find((a) => a.textContent === t) || i.find((a) => {
25
+ var l;
26
+ return (l = a.textContent) == null ? void 0 : l.includes(t);
27
+ });
28
+ s && (n.selectedIndex = i.indexOf(s));
29
+ } else if (n instanceof HTMLInputElement && n.type === "date") {
30
+ const i = new Date(t);
31
+ n.value = isNaN(i.getTime()) ? t : i.toISOString().split("T")[0];
32
+ } else
33
+ n.value = t;
34
+ n.dispatchEvent(new CustomEvent("input", {
35
+ bubbles: !0,
36
+ detail: {
37
+ fromSmartComponents: !0
38
+ }
39
+ })), n.dispatchEvent(new CustomEvent("change", {
40
+ bubbles: !0,
41
+ detail: {
42
+ fromSmartComponents: !0
43
+ }
44
+ }));
45
+ }
46
+ }, R = /* @__PURE__ */ x({
47
+ name: "KendoSmartPasteButton",
48
+ emits: {
49
+ click: (e) => !0
50
+ },
51
+ props: {
52
+ disabled: {
53
+ type: Boolean,
54
+ default: void 0
55
+ },
56
+ fillMode: {
57
+ type: String,
58
+ default: "solid"
59
+ },
60
+ rounded: {
61
+ type: String,
62
+ default: "medium"
63
+ },
64
+ size: {
65
+ type: String,
66
+ default: "medium"
67
+ },
68
+ svgIcon: {
69
+ type: Object,
70
+ default: () => N
71
+ },
72
+ themeColor: String,
73
+ formFields: Array,
74
+ togglable: {
75
+ type: Boolean,
76
+ default: !1
77
+ },
78
+ selected: {
79
+ type: Boolean,
80
+ default: void 0
81
+ },
82
+ icon: String,
83
+ iconClass: String,
84
+ imageUrl: String,
85
+ imageAlt: String,
86
+ tabIndex: Number,
87
+ id: String,
88
+ type: {
89
+ type: String,
90
+ default: "button"
91
+ },
92
+ role: String,
93
+ ariaLabel: String,
94
+ ariaPressed: Boolean,
95
+ title: String,
96
+ dir: String,
97
+ iconSize: String
98
+ },
99
+ created() {
100
+ w(O), this.smartPasteInstance = null;
101
+ },
102
+ methods: {
103
+ getSmartPasteInstance() {
104
+ return this.getButtonElement() ? (this.smartPasteInstance || (this.smartPasteInstance = new A({
105
+ getElement: () => this.getButtonElement(),
106
+ customInputs: L.map((t) => ({
107
+ identifier: t
108
+ })),
109
+ getSmartPasteField: (t) => {
110
+ const r = M(t.element);
111
+ return r ? {
112
+ ...t,
113
+ field: r
114
+ } : t;
115
+ },
116
+ setKendoInputValue: V
117
+ })), this.smartPasteInstance) : null;
118
+ },
119
+ getButtonElement() {
120
+ var t;
121
+ const e = this.$refs.buttonRef;
122
+ return (t = e == null ? void 0 : e.$el) != null ? t : null;
123
+ },
124
+ extractFormConfig() {
125
+ const e = this.getSmartPasteInstance();
126
+ if (!e)
127
+ return this.$props.formFields;
128
+ const r = e.extractFormConfig().reduce((o, n) => o.some((i) => i.field === n.field) ? o : [...o, n], []);
129
+ return this.$props.formFields ? this.$props.formFields.map((o) => {
130
+ const n = r.find((i) => i.field === o.field);
131
+ if (n) {
132
+ const i = {
133
+ ...n,
134
+ ...o,
135
+ element: n.element
136
+ };
137
+ return n.type === "kendo-input" && (i.type = "kendo-input"), i;
138
+ }
139
+ return o;
140
+ }) : r;
141
+ },
142
+ async extractClipboard() {
143
+ try {
144
+ return await navigator.clipboard.readText();
145
+ } catch {
146
+ return "";
147
+ }
148
+ },
149
+ populateFormFieldsInternal(e, t) {
150
+ if (!e || !t)
151
+ return;
152
+ const r = Object.entries(e).reduce((i, [s, a]) => (a != null && (i[s] = a), i), {}), o = this.getButtonElement();
153
+ if (o) {
154
+ const i = T(o);
155
+ B(i, r);
156
+ }
157
+ const n = this.getSmartPasteInstance();
158
+ n && n.populateFormFields({
159
+ fieldValues: r
160
+ }, t);
161
+ },
162
+ async handleClick(e) {
163
+ if (this.$props.disabled)
164
+ return;
165
+ const t = await this.extractClipboard(), r = this.extractFormConfig(), o = r == null ? void 0 : r.map((s) => {
166
+ var c, u, m;
167
+ const {
168
+ element: a,
169
+ ...l
170
+ } = s, d = (c = this.$props.formFields) == null ? void 0 : c.find((f) => f.field === l.field);
171
+ return {
172
+ ...l,
173
+ type: (u = d == null ? void 0 : d.type) != null ? u : l.type,
174
+ field: l.field || "",
175
+ allowedValues: (m = l.allowedValues) != null ? m : []
176
+ };
177
+ }), i = {
178
+ event: e,
179
+ requestData: {
180
+ content: t,
181
+ formFields: o
182
+ },
183
+ setResponse: (s) => {
184
+ s != null && s.fieldValues && this.populateFormFieldsInternal(s.fieldValues, r);
185
+ }
186
+ };
187
+ this.$emit("click", i);
188
+ }
189
+ },
190
+ render() {
191
+ const e = v(this), {
192
+ disabled: t,
193
+ fillMode: r,
194
+ rounded: o,
195
+ size: n,
196
+ svgIcon: i,
197
+ themeColor: s,
198
+ togglable: a,
199
+ selected: l,
200
+ icon: d,
201
+ iconClass: c,
202
+ imageUrl: u,
203
+ imageAlt: m,
204
+ tabIndex: f,
205
+ id: h,
206
+ type: b,
207
+ role: y,
208
+ ariaLabel: E,
209
+ ariaPressed: I,
210
+ title: C,
211
+ dir: P,
212
+ iconSize: k
213
+ } = this.$props, p = {
214
+ ref: "buttonRef",
215
+ disabled: t,
216
+ fillMode: r,
217
+ rounded: o,
218
+ size: n,
219
+ svgIcon: i,
220
+ themeColor: s,
221
+ togglable: a,
222
+ selected: l,
223
+ icon: d,
224
+ iconClass: c,
225
+ imageUrl: u,
226
+ imageAlt: m,
227
+ tabIndex: f,
228
+ id: h,
229
+ type: b,
230
+ role: y,
231
+ ariaLabel: E,
232
+ ariaPressed: I,
233
+ title: C,
234
+ dir: P,
235
+ iconSize: k,
236
+ onClick: this.handleClick
237
+ };
238
+ return e ? g(S, p, $(e) ? e : {
239
+ default: () => [e]
240
+ }) : g(S, p, null);
241
+ }
242
+ });
243
+ export {
244
+ R as SmartPasteButton
245
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2026 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ export * from './interfaces';
9
+ export * from './SmartPasteButton';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2026 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ /**
9
+ * Represents the handle of the SmartPasteButton component.
10
+ */
11
+ export interface SmartPasteButtonHandle {
12
+ /**
13
+ * The root DOM element of the SmartPasteButton.
14
+ */
15
+ element: HTMLButtonElement | null;
16
+ /**
17
+ * Programmatically triggers a click on the SmartPasteButton.
18
+ */
19
+ click: () => void;
20
+ }
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2026 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ import { ButtonProps } from '../../Button';
9
+ import { SmartPasteFormField } from './SmartPasteFormField';
10
+ /**
11
+ * Represents the request data passed in the SmartPasteClickEvent.
12
+ */
13
+ export interface SmartPasteRequestData {
14
+ /**
15
+ * The clipboard content.
16
+ */
17
+ content: string;
18
+ /**
19
+ * The extracted form fields configuration.
20
+ */
21
+ formFields: SmartPasteFormField[];
22
+ }
23
+ /**
24
+ * Represents the response object used to populate form fields.
25
+ */
26
+ export interface SmartPasteResponse {
27
+ /**
28
+ * A record of field names to their values to populate.
29
+ */
30
+ fieldValues: Record<string, any>;
31
+ }
32
+ /**
33
+ * Represents the click event of the SmartPasteButton.
34
+ */
35
+ export interface SmartPasteClickEvent {
36
+ /**
37
+ * The original DOM event.
38
+ */
39
+ event: Event;
40
+ /**
41
+ * The request data containing clipboard content and form fields.
42
+ */
43
+ requestData: SmartPasteRequestData;
44
+ /**
45
+ * A callback function to set the response with field values to populate.
46
+ */
47
+ setResponse: (response: SmartPasteResponse) => void;
48
+ }
49
+ /**
50
+ * Represents the props of the SmartPasteButton component.
51
+ */
52
+ export interface SmartPasteButtonProps extends ButtonProps {
53
+ /**
54
+ * Configures the form fields for smart paste.
55
+ * When provided, the extracted form configuration is merged with these custom fields.
56
+ */
57
+ formFields?: SmartPasteFormField[];
58
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2026 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ /**
9
+ * Represents a form field configuration for the SmartPasteButton.
10
+ */
11
+ export interface SmartPasteFormField {
12
+ /**
13
+ * The field identifier.
14
+ */
15
+ field: string;
16
+ /**
17
+ * A description of the field.
18
+ */
19
+ description: string | null;
20
+ /**
21
+ * The type of the field.
22
+ *
23
+ * The available options are:
24
+ * - `string`
25
+ * - `boolean`
26
+ * - `number`
27
+ * - `fixed-choices`
28
+ * - `kendo-input`
29
+ */
30
+ type: 'string' | 'boolean' | 'number' | 'fixed-choices' | 'kendo-input';
31
+ /**
32
+ * The allowed values for the field when the type is `fixed-choices`.
33
+ */
34
+ allowedValues?: string[];
35
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2026 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ export * from './SmartPasteFormField';
9
+ export * from './SmartPasteButtonProps';
10
+ export * from './SmartPasteButtonHandle';