@kvman/kvcoder 0.1.0 → 0.1.1

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.
@@ -1,6 +1,6 @@
1
- import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createVNode as o, defineComponent as s, h as c, inject as l, normalizeClass as u, openBlock as d, ref as f, renderList as p, toDisplayString as m, vModelText as h, withDirectives as g, withKeys as _, withModifiers as v } from "vue";
1
+ import { Fragment as e, computed as t, createBlock as n, createCommentVNode as r, createElementBlock as i, createElementVNode as a, createVNode as o, defineComponent as s, h as c, inject as l, normalizeClass as u, openBlock as d, ref as f, renderList as p, toDisplayString as m, unref as h, vModelText as g, withDirectives as _, withKeys as v, withModifiers as y } from "vue";
2
2
  //#region ../../node_modules/.pnpm/@lucide+vue@1.49.0_vue@3.5.43_typescript@6.0.3_/node_modules/@lucide/vue/dist/esm/shared/src/build/defaultAttributes.mjs
3
- var y = {
3
+ var b = {
4
4
  xmlns: "http://www.w3.org/2000/svg",
5
5
  width: 24,
6
6
  height: 24,
@@ -10,25 +10,25 @@ var y = {
10
10
  "stroke-width": 2,
11
11
  "stroke-linecap": "round",
12
12
  "stroke-linejoin": "round"
13
- }, b = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim();
13
+ }, x = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim();
14
14
  //#endregion
15
15
  //#region ../../node_modules/.pnpm/@lucide+vue@1.49.0_vue@3.5.43_typescript@6.0.3_/node_modules/@lucide/vue/dist/esm/shared/src/build/buildLucideIconNode.mjs
16
- function x(e) {
16
+ function S(e) {
17
17
  return e != null;
18
18
  }
19
- function S(e, t = {}) {
20
- let n = t.attributeNames ?? {}, r = (e) => n[e] ?? e, i = e.size ?? e.width ?? y.width, a = e.size ?? e.height ?? y.height, o = e.aliases?.filter((e) => typeof e == "string" && e.trim() !== "").map((e) => `lucide-${e}`) ?? [], s = [...e.name ? [`lucide-${e.name}`] : [], ...o], c = t.className?.split(" ").filter(Boolean) ?? [], l = t.includeDefaultClasses === !1 ? b(...c) : b("lucide", ...s, ...c), u = t.absoluteStrokeWidth ? Number(t.strokeWidth ?? y["stroke-width"]) * Number(e.size ?? e.width ?? y.width) / Number(t.size ?? t.width ?? y.width) : t.strokeWidth ?? y["stroke-width"];
19
+ function C(e, t = {}) {
20
+ let n = t.attributeNames ?? {}, r = (e) => n[e] ?? e, i = e.size ?? e.width ?? b.width, a = e.size ?? e.height ?? b.height, o = e.aliases?.filter((e) => typeof e == "string" && e.trim() !== "").map((e) => `lucide-${e}`) ?? [], s = [...e.name ? [`lucide-${e.name}`] : [], ...o], c = t.className?.split(" ").filter(Boolean) ?? [], l = t.includeDefaultClasses === !1 ? x(...c) : x("lucide", ...s, ...c), u = t.absoluteStrokeWidth ? Number(t.strokeWidth ?? b["stroke-width"]) * Number(e.size ?? e.width ?? b.width) / Number(t.size ?? t.width ?? b.width) : t.strokeWidth ?? b["stroke-width"];
21
21
  return [
22
22
  "svg",
23
23
  {
24
- ...Object.entries(y).reduce((e, [t, n]) => (e[r(t)] = n, e), {}),
24
+ ...Object.entries(b).reduce((e, [t, n]) => (e[r(t)] = n, e), {}),
25
25
  ..."color" in t && t.color && { [r("stroke")]: t.color },
26
- ..."size" in t && x(t.size) && {
26
+ ..."size" in t && S(t.size) && {
27
27
  [r("width")]: t.size,
28
28
  [r("height")]: t.size
29
29
  },
30
- ..."width" in t && x(t.width) && { [r("width")]: t.width },
31
- ..."height" in t && x(t.height) && { [r("height")]: t.height },
30
+ ..."width" in t && S(t.width) && { [r("width")]: t.width },
31
+ ..."height" in t && S(t.height) && { [r("height")]: t.height },
32
32
  [r("stroke-width")]: u,
33
33
  ...l && { [r("class")]: l },
34
34
  [r("viewBox")]: `0 0 ${i} ${a}`,
@@ -50,49 +50,49 @@ function S(e, t = {}) {
50
50
  }
51
51
  //#endregion
52
52
  //#region ../../node_modules/.pnpm/@lucide+vue@1.49.0_vue@3.5.43_typescript@6.0.3_/node_modules/@lucide/vue/dist/esm/shared/src/utils/hasA11yProp.mjs
53
- var C = (e) => {
53
+ var w = (e) => {
54
54
  for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
55
55
  return !1;
56
- }, w = (e) => e === "", T = (e) => e?.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), E = /* @__PURE__ */ Symbol("lucide-icons");
57
- function D() {
58
- return l(E, {});
56
+ }, T = (e) => e === "", E = (e) => e?.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), D = /* @__PURE__ */ Symbol("lucide-icons");
57
+ function O() {
58
+ return l(D, {});
59
59
  }
60
60
  //#endregion
61
61
  //#region ../../node_modules/.pnpm/@lucide+vue@1.49.0_vue@3.5.43_typescript@6.0.3_/node_modules/@lucide/vue/dist/esm/Icon.mjs
62
- var O = ({ name: e, iconNode: t, "icon-node": n, icon: r = {
63
- name: e && T(e),
62
+ var k = ({ name: e, iconNode: t, "icon-node": n, icon: r = {
63
+ name: e && E(e),
64
64
  node: t ?? n ?? [],
65
65
  size: 24,
66
66
  aliases: []
67
67
  }, absoluteStrokeWidth: i, "absolute-stroke-width": a, nonScalingStroke: o, "non-scaling-stroke": s, strokeWidth: l, "stroke-width": u, size: d, width: f = d, height: p = d, color: m, ...h }, { slots: g }) => {
68
- let { size: _, color: v, strokeWidth: y = 2, absoluteStrokeWidth: b = !1, nonScalingStroke: x = !1, class: E = "" } = D(), O = w(i) || w(a) || i === !0 || a === !0 || b === !0, k = w(o) || w(s) || o === !0 || s === !0 || x === !0;
68
+ let { size: _, color: v, strokeWidth: y = 2, absoluteStrokeWidth: b = !1, nonScalingStroke: x = !1, class: S = "" } = O(), D = T(i) || T(a) || i === !0 || a === !0 || b === !0, k = T(o) || T(s) || o === !0 || s === !0 || x === !0;
69
69
  delete h.class;
70
- let A = g.default?.(), [, j, M = []] = S(r, {
70
+ let A = g.default?.(), [, j, M = []] = C(r, {
71
71
  color: m ?? v,
72
72
  width: f ?? d ?? _,
73
73
  height: p ?? d ?? _,
74
74
  strokeWidth: l ?? u ?? y,
75
- absoluteStrokeWidth: O,
75
+ absoluteStrokeWidth: D,
76
76
  nonScalingStroke: k,
77
- className: E,
78
- hasA11yProp: A != null && A.length > 0 || C(h),
77
+ className: S,
78
+ hasA11yProp: A != null && A.length > 0 || w(h),
79
79
  attributes: h
80
80
  });
81
81
  return c("svg", j, [...M.map(([e, t]) => c(e, t)), ...A ?? []]);
82
82
  };
83
83
  //#endregion
84
84
  //#region ../../node_modules/.pnpm/@lucide+vue@1.49.0_vue@3.5.43_typescript@6.0.3_/node_modules/@lucide/vue/dist/esm/createLucideIcon.mjs
85
- function k(e, t = []) {
85
+ function A(e, t = []) {
86
86
  let n = typeof e == "string" ? {
87
87
  name: e,
88
88
  node: t
89
89
  } : e;
90
- return (e, { slots: t }) => c(O, {
90
+ return (e, { slots: t }) => c(k, {
91
91
  ...e,
92
92
  icon: n
93
93
  }, t.default ? { default: t.default } : void 0);
94
94
  }
95
- var A = k({
95
+ var j = A({
96
96
  name: "circle-question-mark",
97
97
  size: 24,
98
98
  node: [
@@ -115,19 +115,19 @@ var A = k({
115
115
  });
116
116
  //#endregion
117
117
  //#region web/src/kvman.ts
118
- function j() {
118
+ function M() {
119
119
  let e = l("kvman");
120
120
  if (e === void 0) throw Error("kvcoder components run inside kvwebui, which provides kvman.");
121
121
  return e;
122
122
  }
123
- function M(e) {
123
+ function N(e) {
124
124
  return typeof e == "object" && e && !Array.isArray(e) ? Object.fromEntries(Object.entries(e)) : {};
125
125
  }
126
126
  //#endregion
127
127
  //#region web/src/question-options.ts
128
- function N(e) {
128
+ function P(e) {
129
129
  return (Array.isArray(e.options) ? e.options : []).map((e) => {
130
- let t = M(e);
130
+ let t = N(e);
131
131
  return {
132
132
  id: String(t.id),
133
133
  label: String(t.label),
@@ -137,185 +137,129 @@ function N(e) {
137
137
  }
138
138
  //#endregion
139
139
  //#region web/src/QuestionCard.vue?vue&type=script&setup=true&lang.ts
140
- var P = /*@__PURE__*/ s({
141
- __name: "QuestionCard",
142
- props: {
143
- questionId: {
144
- type: String,
145
- required: !0
146
- },
147
- question: {
148
- type: Object,
149
- required: !0
150
- }
151
- },
152
- emits: ["answer"],
153
- setup(e, { expose: n, emit: r }) {
154
- n();
155
- let i = e, a = r, o = j(), s = t(() => String(i.question.kind ?? "text")), c = t(() => String(i.question.prompt ?? "")), l = t(() => N(i.question)), u = t(() => i.question.multiple === !0), d = t(() => i.question.other === !0), p = f(""), m = f([]), h = f("");
156
- function g(e) {
157
- a("answer", {
158
- questionId: i.questionId,
159
- answer: e
160
- });
161
- }
162
- function _(e) {
163
- m.value = u.value ? m.value.includes(e) ? m.value.filter((t) => t !== e) : [...m.value, e] : [e], u.value || (h.value = "");
164
- }
165
- function v() {
166
- let e = h.value.trim();
167
- g({
168
- selected: e !== "" && !u.value ? [] : m.value,
169
- ...e === "" ? {} : { other: e }
170
- });
171
- }
172
- let y = {
173
- props: i,
174
- emit: a,
175
- kvman: o,
176
- kind: s,
177
- prompt: c,
178
- options: l,
179
- multiple: u,
180
- offersOther: d,
181
- text: p,
182
- selected: m,
183
- other: h,
184
- send: g,
185
- choose: _,
186
- answerChoice: v,
187
- get CircleHelp() {
188
- return A;
189
- }
190
- };
191
- return Object.defineProperty(y, "__isScriptSetup", {
192
- enumerable: !1,
193
- value: !0
194
- }), y;
195
- }
196
- }), F = (e, t) => {
197
- let n = e.__vccOpts || e;
198
- for (let [e, r] of t) n[e] = r;
199
- return n;
200
- }, I = ["aria-label"], L = {
140
+ var F = ["aria-label"], I = {
201
141
  class: "kvc-card-row",
202
142
  style: { "font-weight": "600" }
203
- }, R = { dir: "auto" }, z = { class: "kvc-card-body" }, B = ["placeholder", "aria-label"], V = { class: "kvc-actions" }, H = ["data-test"], U = [
143
+ }, L = { dir: "auto" }, R = { class: "kvc-card-body" }, z = ["placeholder", "aria-label"], B = { class: "kvc-actions" }, V = ["data-test"], H = [
204
144
  "type",
205
145
  "checked",
206
146
  "name",
207
147
  "onChange"
208
- ], W = { style: {
148
+ ], U = { style: {
209
149
  display: "flex",
210
150
  "flex-direction": "column"
211
- } }, G = { style: { "font-weight": "500" } }, K = {
151
+ } }, W = { style: { "font-weight": "500" } }, G = {
212
152
  key: 0,
213
153
  class: "kvc-muted"
214
- }, q = ["placeholder", "aria-label"], J = { class: "kvc-actions" }, Y = ["disabled"], X = {
154
+ }, K = ["placeholder", "aria-label"], q = { class: "kvc-actions" }, J = ["disabled"], Y = {
215
155
  key: 2,
216
156
  class: "kvc-actions"
217
- };
218
- function Z(t, n, s, c, l, f) {
219
- return d(), i("section", {
220
- class: "kvc-card kvc-ask",
221
- "data-test": "question-card",
222
- "aria-label": c.prompt
223
- }, [a("div", L, [o(c.CircleHelp, {
224
- size: 18,
225
- "aria-hidden": "true"
226
- }), a("span", R, m(c.prompt), 1)]), a("div", z, [c.kind === "text" ? (d(), i(e, { key: 0 }, [g(a("input", {
227
- "onUpdate:modelValue": n[0] ||= (e) => c.text = e,
228
- class: "kvc-field",
229
- dir: "auto",
230
- placeholder: String(c.props.question.placeholder ?? ""),
231
- "aria-label": c.prompt,
232
- "data-test": "answer-text",
233
- onKeydown: n[1] ||= _(v((e) => c.send({ text: c.text }), ["prevent"]), ["enter"])
234
- }, null, 40, B), [[h, c.text]]), a("div", V, [a("button", {
235
- type: "button",
236
- class: "kvc-button",
237
- "data-test": "skip",
238
- onClick: n[2] ||= (e) => c.send({ dismissed: !0 })
239
- }, m(c.kvman.t("kvcoder.ui.skip")), 1), a("button", {
240
- type: "button",
241
- class: "kvc-button kvc-primary",
242
- "data-test": "answer",
243
- onClick: n[3] ||= (e) => c.send({ text: c.text })
244
- }, m(c.kvman.t("kvcoder.ui.answer")), 1)])], 64)) : c.kind === "choice" ? (d(), i(e, { key: 1 }, [
245
- (d(!0), i(e, null, p(c.options, (e) => (d(), i("label", {
246
- key: e.id,
247
- class: "kvc-option",
248
- "data-test": `option-${e.id}`
249
- }, [a("input", {
250
- type: c.multiple ? "checkbox" : "radio",
251
- checked: c.selected.includes(e.id),
252
- name: c.props.questionId,
253
- onChange: (t) => c.choose(e.id)
254
- }, null, 40, U), a("span", W, [a("span", G, m(e.label), 1), e.description ? (d(), i("span", K, m(e.description), 1)) : r("v-if", !0)])], 8, H))), 128)),
255
- c.offersOther ? g((d(), i("input", {
256
- key: 0,
257
- "onUpdate:modelValue": n[4] ||= (e) => c.other = e,
157
+ }, X = /* @__PURE__ */ s({
158
+ __name: "QuestionCard",
159
+ props: {
160
+ questionId: {},
161
+ question: {}
162
+ },
163
+ emits: ["answer"],
164
+ setup(n, { emit: s }) {
165
+ let c = n, l = s, b = M(), x = t(() => String(c.question.kind ?? "text")), S = t(() => String(c.question.prompt ?? "")), C = t(() => P(c.question)), w = t(() => c.question.multiple === !0), T = t(() => c.question.other === !0), E = f(""), D = f([]), O = f("");
166
+ function k(e) {
167
+ l("answer", {
168
+ questionId: c.questionId,
169
+ answer: e
170
+ });
171
+ }
172
+ function A(e) {
173
+ D.value = w.value ? D.value.includes(e) ? D.value.filter((t) => t !== e) : [...D.value, e] : [e], w.value || (O.value = "");
174
+ }
175
+ function N() {
176
+ let e = O.value.trim();
177
+ k({
178
+ selected: e !== "" && !w.value ? [] : D.value,
179
+ ...e === "" ? {} : { other: e }
180
+ });
181
+ }
182
+ return (t, n) => (d(), i("section", {
183
+ class: "kvc-card kvc-ask",
184
+ "data-test": "question-card",
185
+ "aria-label": S.value
186
+ }, [a("div", I, [o(h(j), {
187
+ size: 18,
188
+ "aria-hidden": "true"
189
+ }), a("span", L, m(S.value), 1)]), a("div", R, [x.value === "text" ? (d(), i(e, { key: 0 }, [_(a("input", {
190
+ "onUpdate:modelValue": n[0] ||= (e) => E.value = e,
258
191
  class: "kvc-field",
259
- placeholder: c.kvman.t("kvcoder.ui.other"),
260
- "aria-label": c.kvman.t("kvcoder.ui.other"),
261
- "data-test": "answer-other"
262
- }, null, 8, q)), [[h, c.other]]) : r("v-if", !0),
263
- a("div", J, [a("button", {
192
+ dir: "auto",
193
+ placeholder: String(c.question.placeholder ?? ""),
194
+ "aria-label": S.value,
195
+ "data-test": "answer-text",
196
+ onKeydown: n[1] ||= v(y((e) => k({ text: E.value }), ["prevent"]), ["enter"])
197
+ }, null, 40, z), [[g, E.value]]), a("div", B, [a("button", {
264
198
  type: "button",
265
199
  class: "kvc-button",
266
200
  "data-test": "skip",
267
- onClick: n[5] ||= (e) => c.send({ dismissed: !0 })
268
- }, m(c.kvman.t("kvcoder.ui.skip")), 1), a("button", {
201
+ onClick: n[2] ||= (e) => k({ dismissed: !0 })
202
+ }, m(h(b).t("kvcoder.ui.skip")), 1), a("button", {
269
203
  type: "button",
270
204
  class: "kvc-button kvc-primary",
271
- disabled: c.selected.length === 0 && c.other.trim() === "",
272
205
  "data-test": "answer",
273
- onClick: c.answerChoice
274
- }, m(c.kvman.t("kvcoder.ui.answer")), 9, Y)])
275
- ], 64)) : (d(), i("div", X, [a("button", {
276
- type: "button",
277
- class: "kvc-button",
278
- "data-test": "answer-no",
279
- onClick: n[6] ||= (e) => c.send({ confirmed: !1 })
280
- }, m(c.kvman.t("kvcoder.ui.no")), 1), a("button", {
281
- type: "button",
282
- class: u(["kvc-button kvc-primary", { "kvc-danger": c.props.question.danger === !0 }]),
283
- "data-test": "answer-yes",
284
- onClick: n[7] ||= (e) => c.send({ confirmed: !0 })
285
- }, m(c.kvman.t("kvcoder.ui.yes")), 3)]))])], 8, I);
286
- }
287
- var Q = /*#__PURE__*/ F(P, [["render", Z], ["__file", "/home/runner/work/kvman/kvman/extensions/kvcoder/web/src/QuestionCard.vue"]]), $ = /*@__PURE__*/ s({
206
+ onClick: n[3] ||= (e) => k({ text: E.value })
207
+ }, m(h(b).t("kvcoder.ui.answer")), 1)])], 64)) : x.value === "choice" ? (d(), i(e, { key: 1 }, [
208
+ (d(!0), i(e, null, p(C.value, (e) => (d(), i("label", {
209
+ key: e.id,
210
+ class: "kvc-option",
211
+ "data-test": `option-${e.id}`
212
+ }, [a("input", {
213
+ type: w.value ? "checkbox" : "radio",
214
+ checked: D.value.includes(e.id),
215
+ name: c.questionId,
216
+ onChange: (t) => A(e.id)
217
+ }, null, 40, H), a("span", U, [a("span", W, m(e.label), 1), e.description ? (d(), i("span", G, m(e.description), 1)) : r("v-if", !0)])], 8, V))), 128)),
218
+ T.value ? _((d(), i("input", {
219
+ key: 0,
220
+ "onUpdate:modelValue": n[4] ||= (e) => O.value = e,
221
+ class: "kvc-field",
222
+ placeholder: h(b).t("kvcoder.ui.other"),
223
+ "aria-label": h(b).t("kvcoder.ui.other"),
224
+ "data-test": "answer-other"
225
+ }, null, 8, K)), [[g, O.value]]) : r("v-if", !0),
226
+ a("div", q, [a("button", {
227
+ type: "button",
228
+ class: "kvc-button",
229
+ "data-test": "skip",
230
+ onClick: n[5] ||= (e) => k({ dismissed: !0 })
231
+ }, m(h(b).t("kvcoder.ui.skip")), 1), a("button", {
232
+ type: "button",
233
+ class: "kvc-button kvc-primary",
234
+ disabled: D.value.length === 0 && O.value.trim() === "",
235
+ "data-test": "answer",
236
+ onClick: N
237
+ }, m(h(b).t("kvcoder.ui.answer")), 9, J)])
238
+ ], 64)) : (d(), i("div", Y, [a("button", {
239
+ type: "button",
240
+ class: "kvc-button",
241
+ "data-test": "answer-no",
242
+ onClick: n[6] ||= (e) => k({ confirmed: !1 })
243
+ }, m(h(b).t("kvcoder.ui.no")), 1), a("button", {
244
+ type: "button",
245
+ class: u(["kvc-button kvc-primary", { "kvc-danger": c.question.danger === !0 }]),
246
+ "data-test": "answer-yes",
247
+ onClick: n[7] ||= (e) => k({ confirmed: !0 })
248
+ }, m(h(b).t("kvcoder.ui.yes")), 3)]))])], 8, F));
249
+ }
250
+ }), Z = /* @__PURE__ */ s({
288
251
  __name: "question",
289
252
  props: {
290
- questionId: {
291
- type: String,
292
- required: !0
293
- },
294
- question: {
295
- type: Object,
296
- required: !0
297
- }
253
+ questionId: {},
254
+ question: {}
298
255
  },
299
- setup(e, { expose: t }) {
300
- t();
301
- let n = {
302
- props: e,
303
- QuestionCard: Q
304
- };
305
- return Object.defineProperty(n, "__isScriptSetup", {
306
- enumerable: !1,
307
- value: !0
308
- }), n;
256
+ setup(e) {
257
+ let t = e;
258
+ return (e, r) => (d(), n(X, {
259
+ "question-id": t.questionId,
260
+ question: t.question
261
+ }, null, 8, ["question-id", "question"]));
309
262
  }
310
263
  });
311
264
  //#endregion
312
- //#region web/components/question.vue
313
- function ee(e, t, r, i, a, o) {
314
- return d(), n(i.QuestionCard, {
315
- "question-id": i.props.questionId,
316
- question: i.props.question
317
- }, null, 8, ["question-id", "question"]);
318
- }
319
- var te = /*#__PURE__*/ F($, [["render", ee], ["__file", "/home/runner/work/kvman/kvman/extensions/kvcoder/web/components/question.vue"]]);
320
- //#endregion
321
- export { te as default };
265
+ export { Z as default };