@meistrari/chat-ui-lang 0.3.0 → 0.4.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.
Files changed (122) hide show
  1. package/README.md +105 -13
  2. package/dist/actions.d.ts +9 -0
  3. package/dist/answers.d.ts +16 -0
  4. package/dist/components/actions.d.ts +47 -0
  5. package/dist/components/chart.d.ts +23 -0
  6. package/dist/components/chat.d.ts +55 -0
  7. package/dist/components/data.d.ts +31 -0
  8. package/dist/components/form.d.ts +42 -0
  9. package/dist/components/layout.d.ts +1179 -0
  10. package/dist/components/text.d.ts +14 -0
  11. package/dist/define.d.ts +8 -0
  12. package/dist/index.d.ts +25 -0
  13. package/dist/index.js +935 -0
  14. package/dist/library.d.ts +6 -0
  15. package/dist/nuxt/module.d.mts +9 -0
  16. package/dist/nuxt/module.json +9 -0
  17. package/dist/nuxt/module.mjs +31 -0
  18. package/dist/nuxt/runtime/actions.d.ts +15 -0
  19. package/dist/nuxt/runtime/actions.js +40 -0
  20. package/dist/nuxt/runtime/components/openui-widget.d.vue.ts +21 -0
  21. package/dist/nuxt/runtime/components/openui-widget.vue +72 -0
  22. package/dist/nuxt/runtime/components/openui-widget.vue.d.ts +21 -0
  23. package/dist/nuxt/runtime/components/plain-prose.d.vue.ts +7 -0
  24. package/dist/nuxt/runtime/components/plain-prose.vue +12 -0
  25. package/dist/nuxt/runtime/components/plain-prose.vue.d.ts +7 -0
  26. package/dist/nuxt/runtime/components/widgets/bar-chart.d.vue.ts +10 -0
  27. package/dist/nuxt/runtime/components/widgets/bar-chart.vue +39 -0
  28. package/dist/nuxt/runtime/components/widgets/bar-chart.vue.d.ts +10 -0
  29. package/dist/nuxt/runtime/components/widgets/bar.d.vue.ts +10 -0
  30. package/dist/nuxt/runtime/components/widgets/bar.vue +12 -0
  31. package/dist/nuxt/runtime/components/widgets/bar.vue.d.ts +10 -0
  32. package/dist/nuxt/runtime/components/widgets/button.d.vue.ts +11 -0
  33. package/dist/nuxt/runtime/components/widgets/button.vue +30 -0
  34. package/dist/nuxt/runtime/components/widgets/button.vue.d.ts +11 -0
  35. package/dist/nuxt/runtime/components/widgets/buttons.d.vue.ts +8 -0
  36. package/dist/nuxt/runtime/components/widgets/buttons.vue +14 -0
  37. package/dist/nuxt/runtime/components/widgets/buttons.vue.d.ts +8 -0
  38. package/dist/nuxt/runtime/components/widgets/callout.d.vue.ts +11 -0
  39. package/dist/nuxt/runtime/components/widgets/callout.vue +27 -0
  40. package/dist/nuxt/runtime/components/widgets/callout.vue.d.ts +11 -0
  41. package/dist/nuxt/runtime/components/widgets/card.d.vue.ts +9 -0
  42. package/dist/nuxt/runtime/components/widgets/card.vue +19 -0
  43. package/dist/nuxt/runtime/components/widgets/card.vue.d.ts +9 -0
  44. package/dist/nuxt/runtime/components/widgets/checkbox.d.vue.ts +9 -0
  45. package/dist/nuxt/runtime/components/widgets/checkbox.vue +26 -0
  46. package/dist/nuxt/runtime/components/widgets/checkbox.vue.d.ts +9 -0
  47. package/dist/nuxt/runtime/components/widgets/citation.d.vue.ts +9 -0
  48. package/dist/nuxt/runtime/components/widgets/citation.vue +9 -0
  49. package/dist/nuxt/runtime/components/widgets/citation.vue.d.ts +9 -0
  50. package/dist/nuxt/runtime/components/widgets/col.d.vue.ts +10 -0
  51. package/dist/nuxt/runtime/components/widgets/col.vue +16 -0
  52. package/dist/nuxt/runtime/components/widgets/col.vue.d.ts +10 -0
  53. package/dist/nuxt/runtime/components/widgets/file-card.d.vue.ts +9 -0
  54. package/dist/nuxt/runtime/components/widgets/file-card.vue +9 -0
  55. package/dist/nuxt/runtime/components/widgets/file-card.vue.d.ts +9 -0
  56. package/dist/nuxt/runtime/components/widgets/form.d.vue.ts +10 -0
  57. package/dist/nuxt/runtime/components/widgets/form.vue +60 -0
  58. package/dist/nuxt/runtime/components/widgets/form.vue.d.ts +10 -0
  59. package/dist/nuxt/runtime/components/widgets/image.d.vue.ts +10 -0
  60. package/dist/nuxt/runtime/components/widgets/image.vue +34 -0
  61. package/dist/nuxt/runtime/components/widgets/image.vue.d.ts +10 -0
  62. package/dist/nuxt/runtime/components/widgets/input.d.vue.ts +10 -0
  63. package/dist/nuxt/runtime/components/widgets/input.vue +23 -0
  64. package/dist/nuxt/runtime/components/widgets/input.vue.d.ts +10 -0
  65. package/dist/nuxt/runtime/components/widgets/markdown.d.vue.ts +9 -0
  66. package/dist/nuxt/runtime/components/widgets/markdown.vue +14 -0
  67. package/dist/nuxt/runtime/components/widgets/markdown.vue.d.ts +9 -0
  68. package/dist/nuxt/runtime/components/widgets/metric.d.vue.ts +11 -0
  69. package/dist/nuxt/runtime/components/widgets/metric.vue +20 -0
  70. package/dist/nuxt/runtime/components/widgets/metric.vue.d.ts +11 -0
  71. package/dist/nuxt/runtime/components/widgets/option.d.vue.ts +10 -0
  72. package/dist/nuxt/runtime/components/widgets/option.vue +12 -0
  73. package/dist/nuxt/runtime/components/widgets/option.vue.d.ts +10 -0
  74. package/dist/nuxt/runtime/components/widgets/question.d.vue.ts +11 -0
  75. package/dist/nuxt/runtime/components/widgets/question.vue +15 -0
  76. package/dist/nuxt/runtime/components/widgets/question.vue.d.ts +11 -0
  77. package/dist/nuxt/runtime/components/widgets/questions.d.vue.ts +9 -0
  78. package/dist/nuxt/runtime/components/widgets/questions.vue +91 -0
  79. package/dist/nuxt/runtime/components/widgets/questions.vue.d.ts +9 -0
  80. package/dist/nuxt/runtime/components/widgets/select.d.vue.ts +10 -0
  81. package/dist/nuxt/runtime/components/widgets/select.vue +27 -0
  82. package/dist/nuxt/runtime/components/widgets/select.vue.d.ts +10 -0
  83. package/dist/nuxt/runtime/components/widgets/stack.d.vue.ts +9 -0
  84. package/dist/nuxt/runtime/components/widgets/stack.vue +18 -0
  85. package/dist/nuxt/runtime/components/widgets/stack.vue.d.ts +9 -0
  86. package/dist/nuxt/runtime/components/widgets/table.d.vue.ts +9 -0
  87. package/dist/nuxt/runtime/components/widgets/table.vue +41 -0
  88. package/dist/nuxt/runtime/components/widgets/table.vue.d.ts +9 -0
  89. package/dist/nuxt/runtime/context.d.ts +30 -0
  90. package/dist/nuxt/runtime/context.js +4 -0
  91. package/dist/nuxt/runtime/form-fields.d.ts +10 -0
  92. package/dist/nuxt/runtime/form-fields.js +30 -0
  93. package/dist/nuxt/runtime/program.d.ts +15 -0
  94. package/dist/nuxt/runtime/program.js +74 -0
  95. package/dist/nuxt/runtime/registry.d.ts +4 -0
  96. package/dist/nuxt/runtime/registry.js +44 -0
  97. package/dist/nuxt/runtime/render.d.ts +21 -0
  98. package/dist/nuxt/runtime/render.js +48 -0
  99. package/dist/nuxt/runtime/use-openui-context.d.ts +2 -0
  100. package/dist/nuxt/runtime/use-openui-context.js +8 -0
  101. package/dist/nuxt/types.d.mts +9 -0
  102. package/dist/profiles.d.ts +10 -0
  103. package/dist/prompt.d.ts +5 -0
  104. package/dist/safe-url.d.ts +2 -0
  105. package/dist/segments.d.ts +16 -0
  106. package/dist/slack.d.ts +28 -0
  107. package/dist/version.d.ts +2 -0
  108. package/dist/widget-context.d.ts +13 -0
  109. package/package.json +72 -31
  110. package/src/actions.ts +0 -12
  111. package/src/components/actions.ts +0 -21
  112. package/src/components/chart.ts +0 -22
  113. package/src/components/chat.ts +0 -60
  114. package/src/components/data.ts +0 -32
  115. package/src/components/form.ts +0 -41
  116. package/src/components/layout.ts +0 -30
  117. package/src/components/text.ts +0 -20
  118. package/src/define.ts +0 -9
  119. package/src/index.ts +0 -14
  120. package/src/library.ts +0 -64
  121. package/src/prompt.ts +0 -54
  122. package/src/version.ts +0 -2
@@ -0,0 +1,10 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ label: string;
4
+ values: Array<string | number>;
5
+ align?: 'left' | 'right';
6
+ };
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,16 @@
1
+ <script setup>
2
+ const props = defineProps({
3
+ props: { type: Object, required: true }
4
+ });
5
+ </script>
6
+
7
+ <template>
8
+ <dl flex flex-col gap-4px data-openui="col">
9
+ <dt body-12-medium text-secondary>
10
+ {{ props.props.label }}
11
+ </dt>
12
+ <dd v-for="(value, index) in props.props.values" :key="index" body-14-regular text-primary>
13
+ {{ value }}
14
+ </dd>
15
+ </dl>
16
+ </template>
@@ -0,0 +1,10 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ label: string;
4
+ values: Array<string | number>;
5
+ align?: 'left' | 'right';
6
+ };
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ vaultRef: string;
4
+ name: string;
5
+ };
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ <script setup>
2
+ const props = defineProps({
3
+ props: { type: Object, required: true }
4
+ });
5
+ </script>
6
+
7
+ <template>
8
+ <span body-14-regular text-secondary data-openui="file-card">{{ props.props.name }}</span>
9
+ </template>
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ vaultRef: string;
4
+ name: string;
5
+ };
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,10 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ name: string;
4
+ fields: unknown[];
5
+ submitLabel?: string;
6
+ };
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,60 @@
1
+ <script setup>
2
+ import { OPENUI_ERROR_REPORTER_KEY, OPENUI_FORM_KEY } from "../../context";
3
+ import { collectFormFields } from "../../form-fields";
4
+ import { useOpenuiContext } from "../../use-openui-context";
5
+ const props = defineProps({
6
+ props: { type: Object, required: true }
7
+ });
8
+ const { renderNode, interactive, triggerAction } = useOpenuiContext();
9
+ const reportErrors = inject(OPENUI_ERROR_REPORTER_KEY, null);
10
+ const values = reactive(/* @__PURE__ */ Object.create(null));
11
+ const sending = ref(false);
12
+ const refused = ref(false);
13
+ provide(OPENUI_FORM_KEY, {
14
+ get: (name) => values[name],
15
+ set: (name, value) => {
16
+ values[name] = value;
17
+ }
18
+ });
19
+ const collected = computed(() => collectFormFields(props.props.fields));
20
+ const fields = computed(() => collected.value.fields);
21
+ watch(() => collected.value.duplicates.join(","), (duplicates) => {
22
+ if (duplicates)
23
+ reportErrors?.([{ source: "runtime", code: "runtime-error", component: "Form", message: `Form ${props.props.name} repeats field names: ${duplicates}` }], "");
24
+ }, { immediate: true });
25
+ const Fields = () => renderNode(props.props.fields);
26
+ function formatValue(field, value) {
27
+ if (field.type === "Checkbox")
28
+ return value === true ? "sim" : "n\xE3o";
29
+ const text = typeof value === "string" ? value.trim() : "";
30
+ return text || "n\xE3o informado";
31
+ }
32
+ async function submit() {
33
+ if (!interactive.value || sending.value)
34
+ return;
35
+ sending.value = true;
36
+ refused.value = false;
37
+ try {
38
+ const lines = fields.value.map((field) => `${field.label}: ${formatValue(field, values[field.name])}`);
39
+ const accepted = await triggerAction(props.props.submitLabel ?? "Enviar", {
40
+ steps: [{ type: "continue_conversation", message: `Dados (${props.props.name}):
41
+ ${lines.join("\n")}` }]
42
+ });
43
+ refused.value = !accepted && interactive.value;
44
+ } finally {
45
+ sending.value = false;
46
+ }
47
+ }
48
+ </script>
49
+
50
+ <template>
51
+ <form flex flex-col gap-12px rounded-12px border-0.5px border p-16px data-openui="form" @submit.prevent="submit">
52
+ <Fields />
53
+ <div flex items-center justify-end gap-12px>
54
+ <span v-if="refused" body-12-regular text-error role="alert">Não foi possível enviar. Tente novamente.</span>
55
+ <TelaButton type="submit" :disabled="!interactive" :loading="sending">
56
+ {{ props.props.submitLabel ?? "Enviar" }}
57
+ </TelaButton>
58
+ </div>
59
+ </form>
60
+ </template>
@@ -0,0 +1,10 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ name: string;
4
+ fields: unknown[];
5
+ submitLabel?: string;
6
+ };
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,10 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ src: string;
4
+ alt: string;
5
+ caption?: string;
6
+ };
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,34 @@
1
+ <script setup>
2
+ const props = defineProps({
3
+ props: { type: Object, required: true }
4
+ });
5
+ const src = computed(() => String(props.props.src ?? ""));
6
+ const httpsHost = computed(() => {
7
+ if (!/^https:\/\/[^\s<>"']+$/.test(src.value))
8
+ return "";
9
+ try {
10
+ return new URL(src.value).host;
11
+ } catch {
12
+ return "";
13
+ }
14
+ });
15
+ </script>
16
+
17
+ <template>
18
+ <figure flex flex-col gap-8px m-0 data-openui="image">
19
+ <a
20
+ v-if="httpsHost"
21
+ :href="src"
22
+ target="_blank"
23
+ rel="noopener noreferrer"
24
+ inline-flex items-center gap-6px body-14-regular text-primary underline
25
+ >
26
+ <TelaIcon name="i-ph-image" size="14px" shrink-0 />
27
+ {{ props.props.alt || "Imagem" }} ({{ httpsHost }})
28
+ </a>
29
+ <span v-else body-14-regular text-secondary>{{ props.props.alt }}</span>
30
+ <figcaption v-if="props.props.caption" body-12-regular text-secondary>
31
+ {{ props.props.caption }}
32
+ </figcaption>
33
+ </figure>
34
+ </template>
@@ -0,0 +1,10 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ src: string;
4
+ alt: string;
5
+ caption?: string;
6
+ };
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,10 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ name: string;
4
+ label: string;
5
+ placeholder?: string;
6
+ };
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,23 @@
1
+ <script setup>
2
+ import { OPENUI_FORM_KEY } from "../../context";
3
+ import { useOpenuiContext } from "../../use-openui-context";
4
+ const props = defineProps({
5
+ props: { type: Object, required: true }
6
+ });
7
+ const form = inject(OPENUI_FORM_KEY, null);
8
+ const local = ref("");
9
+ const { interactive } = useOpenuiContext();
10
+ const value = computed({
11
+ get: () => String((form ? form.get(props.props.name) : local.value) ?? ""),
12
+ set: (next) => {
13
+ if (form)
14
+ form.set(props.props.name, next);
15
+ else
16
+ local.value = next;
17
+ }
18
+ });
19
+ </script>
20
+
21
+ <template>
22
+ <TelaInput v-model="value" :label="props.props.label" :placeholder="props.props.placeholder" :disabled="!interactive" w-full data-openui="input" />
23
+ </template>
@@ -0,0 +1,10 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ name: string;
4
+ label: string;
5
+ placeholder?: string;
6
+ };
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ text: string;
4
+ };
5
+ partial?: boolean;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,14 @@
1
+ <script setup>
2
+ import { OPENUI_HOST_KEY } from "../../context";
3
+ import OpenuiPlainProse from "../plain-prose.vue";
4
+ const props = defineProps({
5
+ props: { type: Object, required: true },
6
+ partial: { type: Boolean, required: false }
7
+ });
8
+ const host = inject(OPENUI_HOST_KEY, ref({}));
9
+ const prose = computed(() => host.value.prose ?? OpenuiPlainProse);
10
+ </script>
11
+
12
+ <template>
13
+ <component :is="prose" :text="props.props.text" :partial="partial" data-openui="markdown" />
14
+ </template>
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ text: string;
4
+ };
5
+ partial?: boolean;
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,11 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ label: string;
4
+ value: string;
5
+ delta?: string;
6
+ tone?: 'neutral' | 'positive' | 'negative';
7
+ };
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,20 @@
1
+ <script setup>
2
+ const props = defineProps({
3
+ props: { type: Object, required: true }
4
+ });
5
+ const deltaClass = computed(() => ({
6
+ neutral: "text-secondary",
7
+ positive: "text-success",
8
+ negative: "text-error"
9
+ })[props.props.tone ?? "neutral"]);
10
+ </script>
11
+
12
+ <template>
13
+ <div flex flex-col gap-12px rounded-12px border-0.5px border p-16px bg-subtle data-openui="metric">
14
+ <span body-12-medium text-secondary>{{ props.props.label }}</span>
15
+ <div flex items-baseline gap-8px>
16
+ <span heading-h3-semibold text-contrast>{{ props.props.value }}</span>
17
+ <span v-if="props.props.delta" body-12-medium :class="deltaClass">{{ props.props.delta }}</span>
18
+ </div>
19
+ </div>
20
+ </template>
@@ -0,0 +1,11 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ label: string;
4
+ value: string;
5
+ delta?: string;
6
+ tone?: 'neutral' | 'positive' | 'negative';
7
+ };
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,10 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ id: string;
4
+ label: string;
5
+ description?: string;
6
+ };
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,12 @@
1
+ <script setup>
2
+ const props = defineProps({
3
+ props: { type: Object, required: true }
4
+ });
5
+ </script>
6
+
7
+ <template>
8
+ <div flex flex-col data-openui="option">
9
+ <span body-14-regular text-primary>{{ props.props.label }}</span>
10
+ <span v-if="props.props.description" body-12-regular text-secondary>{{ props.props.description }}</span>
11
+ </div>
12
+ </template>
@@ -0,0 +1,10 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ id: string;
4
+ label: string;
5
+ description?: string;
6
+ };
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,11 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ id: string;
4
+ title: string;
5
+ options: unknown[];
6
+ multiple?: boolean;
7
+ };
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,15 @@
1
+ <script setup>
2
+ import { useOpenuiContext } from "../../use-openui-context";
3
+ const props = defineProps({
4
+ props: { type: Object, required: true }
5
+ });
6
+ const { renderNode } = useOpenuiContext();
7
+ const Options = () => renderNode(props.props.options);
8
+ </script>
9
+
10
+ <template>
11
+ <div flex flex-col gap-8px data-openui="question">
12
+ <span body-14-medium text-primary>{{ props.props.title }}</span>
13
+ <Options />
14
+ </div>
15
+ </template>
@@ -0,0 +1,11 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ id: string;
4
+ title: string;
5
+ options: unknown[];
6
+ multiple?: boolean;
7
+ };
8
+ };
9
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
+ declare const _default: typeof __VLS_export;
11
+ export default _default;
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ requestId: string;
4
+ questions: unknown[];
5
+ };
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,91 @@
1
+ <script setup>
2
+ import { formatQuestionAnswers } from "@meistrari/chat-ui-lang";
3
+ import { OPENUI_ERROR_REPORTER_KEY } from "../../context";
4
+ import { useOpenuiContext } from "../../use-openui-context";
5
+ const props = defineProps({
6
+ props: { type: Object, required: true }
7
+ });
8
+ const { interactive, triggerAction } = useOpenuiContext();
9
+ const reportErrors = inject(OPENUI_ERROR_REPORTER_KEY, null);
10
+ function toQuestion(node) {
11
+ const question = node;
12
+ if (question?.typeName !== "Question" || !question.props || typeof question.props.id !== "string" || typeof question.props.title !== "string")
13
+ return null;
14
+ const options = (Array.isArray(question.props.options) ? question.props.options : []).map((option) => option).filter((option) => option?.typeName === "Option" && typeof option.props?.id === "string" && typeof option.props.label === "string").map((option) => ({
15
+ id: option.props.id,
16
+ label: option.props.label,
17
+ ...typeof option.props.description === "string" ? { description: option.props.description } : {}
18
+ }));
19
+ if (options.length === 0)
20
+ return null;
21
+ return {
22
+ id: question.props.id,
23
+ title: question.props.title,
24
+ type: question.props.multiple === true ? "multiple" : "single",
25
+ options
26
+ };
27
+ }
28
+ const parsedQuestions = computed(() => (Array.isArray(props.props.questions) ? props.props.questions : []).map(toQuestion).filter((question) => question !== null));
29
+ const hasRepeatedIds = computed(() => new Set(parsedQuestions.value.map((question) => question.id)).size !== parsedQuestions.value.length || parsedQuestions.value.some((question) => new Set(question.options.map((option) => option.id)).size !== question.options.length));
30
+ const questions = computed(() => hasRepeatedIds.value ? [] : parsedQuestions.value);
31
+ watch(hasRepeatedIds, (repeated) => {
32
+ if (repeated)
33
+ reportErrors?.([{ source: "runtime", code: "runtime-error", component: "Questions", message: `Questions ${props.props.requestId} repeats question or option IDs` }], "");
34
+ }, { immediate: true });
35
+ const answers = reactive(/* @__PURE__ */ new Map());
36
+ const sending = ref(false);
37
+ watch(questions, (list) => {
38
+ for (const question of list) {
39
+ if (!answers.has(question.id))
40
+ answers.set(question.id, { selected: [] });
41
+ }
42
+ }, { immediate: true });
43
+ function toggle(question, optionId) {
44
+ if (!interactive.value)
45
+ return;
46
+ if (!answers.has(question.id))
47
+ answers.set(question.id, { selected: [] });
48
+ const answer = answers.get(question.id);
49
+ if (question.type === "single") {
50
+ answer.selected = [optionId];
51
+ return;
52
+ }
53
+ answer.selected = answer.selected.includes(optionId) ? answer.selected.filter((id) => id !== optionId) : [...answer.selected, optionId];
54
+ }
55
+ const message = computed(() => formatQuestionAnswers(props.props.requestId, questions.value, Object.fromEntries(answers)));
56
+ async function submit() {
57
+ if (!interactive.value || !message.value || sending.value)
58
+ return;
59
+ sending.value = true;
60
+ try {
61
+ await triggerAction("Enviar respostas", { steps: [{ type: "continue_conversation", message: message.value }] });
62
+ } finally {
63
+ sending.value = false;
64
+ }
65
+ }
66
+ </script>
67
+
68
+ <template>
69
+ <div v-if="questions.length" flex flex-col gap-16px rounded-12px border-0.5px border p-16px data-openui="questions">
70
+ <div v-for="question in questions" :key="question.id" flex flex-col gap-8px>
71
+ <span body-14-medium text-primary>{{ question.title }}</span>
72
+ <div flex flex-wrap gap-8px>
73
+ <TelaButton
74
+ v-for="option in question.options"
75
+ :key="option.id"
76
+ :variant="answers.get(question.id)?.selected.includes(option.id) ? 'primary' : 'secondary'"
77
+ :disabled="!interactive"
78
+ :title="option.description"
79
+ @click="toggle(question, option.id)"
80
+ >
81
+ {{ option.label }}
82
+ </TelaButton>
83
+ </div>
84
+ </div>
85
+ <div flex justify-end>
86
+ <TelaButton :disabled="!interactive || !message" :loading="sending" @click="submit">
87
+ Enviar respostas
88
+ </TelaButton>
89
+ </div>
90
+ </div>
91
+ </template>
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ requestId: string;
4
+ questions: unknown[];
5
+ };
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,10 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ name: string;
4
+ label: string;
5
+ options: string[];
6
+ };
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,27 @@
1
+ <script setup>
2
+ import { OPENUI_FORM_KEY } from "../../context";
3
+ import { useOpenuiContext } from "../../use-openui-context";
4
+ const props = defineProps({
5
+ props: { type: Object, required: true }
6
+ });
7
+ const form = inject(OPENUI_FORM_KEY, null);
8
+ const local = ref("");
9
+ const { interactive } = useOpenuiContext();
10
+ const options = computed(() => (Array.isArray(props.props.options) ? props.props.options : []).filter((option) => typeof option === "string").map((option) => ({ value: option, label: option })));
11
+ const value = computed({
12
+ get: () => String((form ? form.get(props.props.name) : local.value) ?? ""),
13
+ set: (next) => {
14
+ if (form)
15
+ form.set(props.props.name, next);
16
+ else
17
+ local.value = next;
18
+ }
19
+ });
20
+ </script>
21
+
22
+ <template>
23
+ <div flex flex-col gap-4px data-openui="select">
24
+ <span body-12-medium text-secondary>{{ props.props.label }}</span>
25
+ <TelaSelectMenu v-model="value" :options="options" :disabled="!interactive" trigger-class="w-full" />
26
+ </div>
27
+ </template>
@@ -0,0 +1,10 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ name: string;
4
+ label: string;
5
+ options: string[];
6
+ };
7
+ };
8
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
9
+ declare const _default: typeof __VLS_export;
10
+ export default _default;
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ children: unknown[];
4
+ direction?: 'column' | 'row';
5
+ };
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;
@@ -0,0 +1,18 @@
1
+ <script setup>
2
+ import { useOpenuiContext } from "../../use-openui-context";
3
+ const props = defineProps({
4
+ props: { type: Object, required: true }
5
+ });
6
+ const { renderNode } = useOpenuiContext();
7
+ const Children = () => renderNode(props.props.children);
8
+ </script>
9
+
10
+ <template>
11
+ <div
12
+ flex gap-12px w-full
13
+ :class="props.props.direction === 'row' ? 'flex-row flex-wrap items-stretch [&>*]:flex-1 [&>*]:min-w-160px' : 'flex-col'"
14
+ data-openui="stack"
15
+ >
16
+ <Children />
17
+ </div>
18
+ </template>
@@ -0,0 +1,9 @@
1
+ type __VLS_Props = {
2
+ props: {
3
+ children: unknown[];
4
+ direction?: 'column' | 'row';
5
+ };
6
+ };
7
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
8
+ declare const _default: typeof __VLS_export;
9
+ export default _default;