@aheart-ui/ai 0.0.0-stage → 1.1.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 (205) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +30 -2
  3. package/es/actions/index.d.ts +2 -0
  4. package/es/actions/index.js +5 -0
  5. package/es/actions/style.css +36 -0
  6. package/es/actions.vue.d.ts +34 -0
  7. package/es/actions.vue.js +27 -0
  8. package/es/actions.vue2.js +4 -0
  9. package/es/agent/index.d.ts +5 -0
  10. package/es/agent/index.js +12 -0
  11. package/es/agent/style.css +308 -0
  12. package/es/agent-execution.vue.d.ts +106 -0
  13. package/es/agent-execution.vue.js +441 -0
  14. package/es/agent-execution.vue2.js +4 -0
  15. package/es/agent-workbench/index.d.ts +2 -0
  16. package/es/agent-workbench/index.js +5 -0
  17. package/es/agent-workbench/style.css +1332 -0
  18. package/es/agent-workbench.vue.d.ts +186 -0
  19. package/es/agent-workbench.vue.js +537 -0
  20. package/es/agent-workbench.vue2.js +4 -0
  21. package/es/attachments/index.d.ts +2 -0
  22. package/es/attachments/index.js +5 -0
  23. package/es/attachments/style.css +62 -0
  24. package/es/attachments.vue.d.ts +39 -0
  25. package/es/attachments.vue.js +39 -0
  26. package/es/attachments.vue2.js +4 -0
  27. package/es/bubble/index.d.ts +2 -0
  28. package/es/bubble/index.js +5 -0
  29. package/es/bubble/style.css +241 -0
  30. package/es/bubble.vue.d.ts +27 -0
  31. package/es/bubble.vue.js +82 -0
  32. package/es/bubble.vue2.js +4 -0
  33. package/es/chat/index.d.ts +11 -0
  34. package/es/chat/index.js +23 -0
  35. package/es/chat/style.css +595 -0
  36. package/es/chat-panel/index.d.ts +3 -0
  37. package/es/chat-panel/index.js +8 -0
  38. package/es/chat-panel/style.css +595 -0
  39. package/es/chat-panel.vue.d.ts +108 -0
  40. package/es/chat-panel.vue.js +330 -0
  41. package/es/chat-panel.vue2.js +4 -0
  42. package/es/conversations/index.d.ts +2 -0
  43. package/es/conversations/index.js +5 -0
  44. package/es/conversations/style.css +48 -0
  45. package/es/conversations.vue.d.ts +39 -0
  46. package/es/conversations.vue.js +29 -0
  47. package/es/conversations.vue2.js +4 -0
  48. package/es/form/index.d.ts +3 -0
  49. package/es/form/index.js +9 -0
  50. package/es/form/style.css +242 -0
  51. package/es/form-field.vue.d.ts +28 -0
  52. package/es/form-field.vue.js +176 -0
  53. package/es/form-field.vue2.js +4 -0
  54. package/es/form-schema.d.ts +73 -0
  55. package/es/form-schema.js +105 -0
  56. package/es/form.vue.d.ts +81 -0
  57. package/es/form.vue.js +376 -0
  58. package/es/form.vue2.js +4 -0
  59. package/es/index.d.ts +20 -0
  60. package/es/index.js +42 -0
  61. package/es/package.json +3 -0
  62. package/es/process/index.d.ts +2 -0
  63. package/es/process/index.js +5 -0
  64. package/es/process/style.css +77 -0
  65. package/es/process.vue.d.ts +30 -0
  66. package/es/process.vue.js +29 -0
  67. package/es/process.vue2.js +4 -0
  68. package/es/prompts/index.d.ts +2 -0
  69. package/es/prompts/index.js +5 -0
  70. package/es/prompts/style.css +76 -0
  71. package/es/prompts.vue.d.ts +39 -0
  72. package/es/prompts.vue.js +33 -0
  73. package/es/prompts.vue2.js +4 -0
  74. package/es/safe-markdown.d.ts +3 -0
  75. package/es/safe-markdown.js +23 -0
  76. package/es/sender/index.d.ts +2 -0
  77. package/es/sender/index.js +5 -0
  78. package/es/sender/style.css +88 -0
  79. package/es/sender.vue.d.ts +52 -0
  80. package/es/sender.vue.js +46 -0
  81. package/es/sender.vue2.js +4 -0
  82. package/es/sources/index.d.ts +2 -0
  83. package/es/sources/index.js +5 -0
  84. package/es/sources/style.css +54 -0
  85. package/es/sources.vue.d.ts +30 -0
  86. package/es/sources.vue.js +34 -0
  87. package/es/sources.vue2.js +4 -0
  88. package/es/stream-reducer.d.ts +35 -0
  89. package/es/stream-reducer.js +85 -0
  90. package/es/style.css +1586 -0
  91. package/es/thought-chain/index.d.ts +2 -0
  92. package/es/thought-chain/index.js +5 -0
  93. package/es/thought-chain/style.css +77 -0
  94. package/es/thought-chain.vue.d.ts +30 -0
  95. package/es/thought-chain.vue.js +15 -0
  96. package/es/thought-chain.vue2.js +4 -0
  97. package/es/types.d.ts +203 -0
  98. package/es/welcome/index.d.ts +2 -0
  99. package/es/welcome/index.js +5 -0
  100. package/es/welcome/style.css +33 -0
  101. package/es/welcome.vue.d.ts +41 -0
  102. package/es/welcome.vue.js +27 -0
  103. package/es/welcome.vue2.js +4 -0
  104. package/lib/actions/index.d.ts +2 -0
  105. package/lib/actions/index.js +1 -0
  106. package/lib/actions/style.css +36 -0
  107. package/lib/actions.vue.d.ts +34 -0
  108. package/lib/actions.vue.js +1 -0
  109. package/lib/actions.vue2.js +1 -0
  110. package/lib/agent/index.d.ts +5 -0
  111. package/lib/agent/index.js +1 -0
  112. package/lib/agent/style.css +308 -0
  113. package/lib/agent-execution.vue.d.ts +106 -0
  114. package/lib/agent-execution.vue.js +1 -0
  115. package/lib/agent-execution.vue2.js +1 -0
  116. package/lib/agent-workbench/index.d.ts +2 -0
  117. package/lib/agent-workbench/index.js +1 -0
  118. package/lib/agent-workbench/style.css +1332 -0
  119. package/lib/agent-workbench.vue.d.ts +186 -0
  120. package/lib/agent-workbench.vue.js +1 -0
  121. package/lib/agent-workbench.vue2.js +1 -0
  122. package/lib/attachments/index.d.ts +2 -0
  123. package/lib/attachments/index.js +1 -0
  124. package/lib/attachments/style.css +62 -0
  125. package/lib/attachments.vue.d.ts +39 -0
  126. package/lib/attachments.vue.js +1 -0
  127. package/lib/attachments.vue2.js +1 -0
  128. package/lib/bubble/index.d.ts +2 -0
  129. package/lib/bubble/index.js +1 -0
  130. package/lib/bubble/style.css +241 -0
  131. package/lib/bubble.vue.d.ts +27 -0
  132. package/lib/bubble.vue.js +1 -0
  133. package/lib/bubble.vue2.js +1 -0
  134. package/lib/chat/index.d.ts +11 -0
  135. package/lib/chat/index.js +1 -0
  136. package/lib/chat/style.css +595 -0
  137. package/lib/chat-panel/index.d.ts +3 -0
  138. package/lib/chat-panel/index.js +1 -0
  139. package/lib/chat-panel/style.css +595 -0
  140. package/lib/chat-panel.vue.d.ts +108 -0
  141. package/lib/chat-panel.vue.js +1 -0
  142. package/lib/chat-panel.vue2.js +1 -0
  143. package/lib/conversations/index.d.ts +2 -0
  144. package/lib/conversations/index.js +1 -0
  145. package/lib/conversations/style.css +48 -0
  146. package/lib/conversations.vue.d.ts +39 -0
  147. package/lib/conversations.vue.js +1 -0
  148. package/lib/conversations.vue2.js +1 -0
  149. package/lib/form/index.d.ts +3 -0
  150. package/lib/form/index.js +1 -0
  151. package/lib/form/style.css +242 -0
  152. package/lib/form-field.vue.d.ts +28 -0
  153. package/lib/form-field.vue.js +1 -0
  154. package/lib/form-field.vue2.js +1 -0
  155. package/lib/form-schema.d.ts +73 -0
  156. package/lib/form-schema.js +1 -0
  157. package/lib/form.vue.d.ts +81 -0
  158. package/lib/form.vue.js +1 -0
  159. package/lib/form.vue2.js +1 -0
  160. package/lib/index.d.ts +20 -0
  161. package/lib/index.js +1 -0
  162. package/lib/package.json +3 -0
  163. package/lib/process/index.d.ts +2 -0
  164. package/lib/process/index.js +1 -0
  165. package/lib/process/style.css +77 -0
  166. package/lib/process.vue.d.ts +30 -0
  167. package/lib/process.vue.js +1 -0
  168. package/lib/process.vue2.js +1 -0
  169. package/lib/prompts/index.d.ts +2 -0
  170. package/lib/prompts/index.js +1 -0
  171. package/lib/prompts/style.css +76 -0
  172. package/lib/prompts.vue.d.ts +39 -0
  173. package/lib/prompts.vue.js +1 -0
  174. package/lib/prompts.vue2.js +1 -0
  175. package/lib/safe-markdown.d.ts +3 -0
  176. package/lib/safe-markdown.js +2 -0
  177. package/lib/sender/index.d.ts +2 -0
  178. package/lib/sender/index.js +1 -0
  179. package/lib/sender/style.css +88 -0
  180. package/lib/sender.vue.d.ts +52 -0
  181. package/lib/sender.vue.js +1 -0
  182. package/lib/sender.vue2.js +1 -0
  183. package/lib/sources/index.d.ts +2 -0
  184. package/lib/sources/index.js +1 -0
  185. package/lib/sources/style.css +54 -0
  186. package/lib/sources.vue.d.ts +30 -0
  187. package/lib/sources.vue.js +1 -0
  188. package/lib/sources.vue2.js +1 -0
  189. package/lib/stream-reducer.d.ts +35 -0
  190. package/lib/stream-reducer.js +1 -0
  191. package/lib/style.css +1586 -0
  192. package/lib/thought-chain/index.d.ts +2 -0
  193. package/lib/thought-chain/index.js +1 -0
  194. package/lib/thought-chain/style.css +77 -0
  195. package/lib/thought-chain.vue.d.ts +30 -0
  196. package/lib/thought-chain.vue.js +1 -0
  197. package/lib/thought-chain.vue2.js +1 -0
  198. package/lib/types.d.ts +203 -0
  199. package/lib/welcome/index.d.ts +2 -0
  200. package/lib/welcome/index.js +1 -0
  201. package/lib/welcome/style.css +33 -0
  202. package/lib/welcome.vue.d.ts +41 -0
  203. package/lib/welcome.vue.js +1 -0
  204. package/lib/welcome.vue2.js +1 -0
  205. package/package.json +172 -3
@@ -0,0 +1,242 @@
1
+ :root {
2
+ --aheart-ai-cyan: #0e7490;
3
+ --aheart-ai-cyan-strong: #0e7490;
4
+ --aheart-ai-brand-strong: #0958d9;
5
+ --aheart-ai-cyan-soft: #ecfeff;
6
+ --aheart-ai-line: #e4e7ec;
7
+ --aheart-ai-surface: #ffffff;
8
+ --aheart-ai-surface-subtle: #f8fafc;
9
+ --aheart-ai-text: #182230;
10
+ --aheart-ai-text-secondary: #667085;
11
+ }
12
+
13
+ .aheart-ai-visually-hidden {
14
+ position: absolute;
15
+ width: 1px;
16
+ height: 1px;
17
+ padding: 0;
18
+ margin: -1px;
19
+ overflow: hidden;
20
+ clip: rect(0, 0, 0, 0);
21
+ white-space: nowrap;
22
+ border: 0;
23
+ }
24
+
25
+ .aheart-ai-form {
26
+ box-sizing: border-box;
27
+ color: var(--aheart-color-text, var(--aheart-ai-text));
28
+ letter-spacing: 0;
29
+ }
30
+
31
+ .aheart-ai-form * {
32
+ box-sizing: border-box;
33
+ }
34
+
35
+ .aheart-ai-form {
36
+ display: grid;
37
+ gap: 20px;
38
+ inline-size: min(100%, 760px);
39
+ padding: clamp(18px, 4vw, 32px);
40
+ border: 1px solid var(--aheart-ai-line);
41
+ border-radius: 8px;
42
+ background: var(--aheart-ai-surface);
43
+ }
44
+
45
+ .aheart-ai-form__header {
46
+ display: grid;
47
+ gap: 5px;
48
+ padding-block-end: 18px;
49
+ border-block-end: 1px solid var(--aheart-ai-line);
50
+ }
51
+
52
+ .aheart-ai-form__header h2,
53
+ .aheart-ai-form__header p {
54
+ margin: 0;
55
+ }
56
+
57
+ .aheart-ai-form__header h2 {
58
+ color: var(--aheart-ai-text);
59
+ font-size: 20px;
60
+ line-height: 1.4;
61
+ }
62
+
63
+ .aheart-ai-form__header p {
64
+ color: var(--aheart-ai-text-secondary);
65
+ line-height: 1.6;
66
+ }
67
+
68
+ .aheart-ai-form__group {
69
+ display: grid;
70
+ gap: 16px;
71
+ min-inline-size: 0;
72
+ margin: 0;
73
+ padding: 0;
74
+ border: 0;
75
+ }
76
+
77
+ fieldset.aheart-ai-form__group {
78
+ padding-block-start: 16px;
79
+ border-block-start: 1px solid var(--aheart-ai-line);
80
+ }
81
+
82
+ .aheart-ai-form__group legend {
83
+ display: grid;
84
+ gap: 3px;
85
+ inline-size: 100%;
86
+ padding: 0;
87
+ color: var(--aheart-ai-text);
88
+ }
89
+
90
+ .aheart-ai-form__group legend span {
91
+ font-weight: 650;
92
+ }
93
+
94
+ .aheart-ai-form__group legend small,
95
+ .aheart-ai-form__field-description {
96
+ color: var(--aheart-ai-text-secondary);
97
+ font-size: 12px;
98
+ line-height: 1.5;
99
+ }
100
+
101
+ .aheart-ai-form__field {
102
+ display: grid;
103
+ grid-template-columns: minmax(140px, 190px) minmax(0, 1fr);
104
+ column-gap: 18px;
105
+ row-gap: 6px;
106
+ align-items: start;
107
+ padding: 3px 0;
108
+ border-radius: 5px;
109
+ outline: none;
110
+ }
111
+
112
+ .aheart-ai-form__field:focus-visible {
113
+ box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.15);
114
+ }
115
+
116
+ .aheart-ai-form__field > label {
117
+ grid-column: 1;
118
+ grid-row: 1;
119
+ padding-block-start: 7px;
120
+ color: #344054;
121
+ font-weight: 550;
122
+ line-height: 1.5;
123
+ }
124
+
125
+ .aheart-ai-form__field-description {
126
+ grid-column: 1;
127
+ grid-row: 2;
128
+ margin: 0;
129
+ }
130
+
131
+ .aheart-ai-form__field > :not(label):not(.aheart-ai-form__field-description):not(.aheart-ai-form__field-error):not(.aheart-switch) {
132
+ grid-column: 2;
133
+ grid-row: 1 / span 2;
134
+ inline-size: 100%;
135
+ }
136
+
137
+ .aheart-ai-form__field > .aheart-switch {
138
+ grid-column: 2;
139
+ grid-row: 1 / span 2;
140
+ justify-self: start;
141
+ inline-size: fit-content;
142
+ }
143
+
144
+ .aheart-ai-form__required {
145
+ margin-inline-start: 3px;
146
+ color: var(--aheart-color-danger, #d92d20);
147
+ }
148
+
149
+ .aheart-ai-form__field-error {
150
+ grid-column: 2;
151
+ margin: 0;
152
+ color: var(--aheart-color-danger, #d92d20);
153
+ font-size: 12px;
154
+ }
155
+
156
+ .aheart-ai-form__field.is-error {
157
+ padding: 8px;
158
+ background: #fff7f6;
159
+ }
160
+
161
+ .aheart-ai-form__error-summary,
162
+ .aheart-ai-form__submit-error,
163
+ .aheart-ai-form__error {
164
+ border-inline-start: 3px solid var(--aheart-color-danger, #d92d20);
165
+ background: #fff7f6;
166
+ color: #912018;
167
+ }
168
+
169
+ .aheart-ai-form__error-summary {
170
+ display: grid;
171
+ gap: 8px;
172
+ padding: 12px 14px;
173
+ }
174
+
175
+ .aheart-ai-form__error-summary ul,
176
+ .aheart-ai-form__error ul {
177
+ display: grid;
178
+ gap: 4px;
179
+ margin: 0;
180
+ padding-inline-start: 20px;
181
+ }
182
+
183
+ .aheart-ai-form__error-summary button {
184
+ padding: 0;
185
+ border: 0;
186
+ background: transparent;
187
+ color: inherit;
188
+ font: inherit;
189
+ text-decoration: underline;
190
+ cursor: pointer;
191
+ }
192
+
193
+ .aheart-ai-form__submit-error {
194
+ margin: 0;
195
+ padding: 9px 12px;
196
+ }
197
+
198
+ .aheart-ai-form__footer {
199
+ display: flex;
200
+ justify-content: flex-end;
201
+ padding-block-start: 16px;
202
+ border-block-start: 1px solid var(--aheart-ai-line);
203
+ }
204
+
205
+ .aheart-ai-form__error {
206
+ display: grid;
207
+ gap: 8px;
208
+ max-inline-size: 760px;
209
+ padding: 16px;
210
+ }
211
+
212
+ @media (max-width: 760px) {
213
+
214
+ .aheart-ai-form {
215
+ padding: 18px 14px;
216
+ }
217
+
218
+ .aheart-ai-form__field {
219
+ grid-template-columns: minmax(0, 1fr);
220
+ }
221
+
222
+ .aheart-ai-form__field > label,
223
+ .aheart-ai-form__field-description,
224
+ .aheart-ai-form__field > :not(label):not(.aheart-ai-form__field-description):not(.aheart-ai-form__field-error):not(.aheart-switch),
225
+ .aheart-ai-form__field > .aheart-switch,
226
+ .aheart-ai-form__field-error {
227
+ grid-column: 1;
228
+ grid-row: auto;
229
+ }
230
+
231
+ .aheart-ai-form__field > label {
232
+ padding-block-start: 0;
233
+ }
234
+ }
235
+
236
+ @media (prefers-reduced-motion: reduce) {
237
+ .aheart-ai-form * {
238
+ scroll-behavior: auto !important;
239
+ transition-duration: 0.01ms !important;
240
+ animation-duration: 0.01ms !important;
241
+ }
242
+ }
@@ -0,0 +1,28 @@
1
+ import type { AIFormFieldV1 } from './form-schema';
2
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
3
+ field: AIFormFieldV1;
4
+ value: unknown;
5
+ disabled?: boolean | undefined;
6
+ error?: string | undefined;
7
+ }>>, {
8
+ focus: () => void;
9
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
10
+ update: (value: unknown) => void;
11
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
12
+ field: AIFormFieldV1;
13
+ value: unknown;
14
+ disabled?: boolean | undefined;
15
+ error?: string | undefined;
16
+ }>>> & Readonly<{
17
+ onUpdate?: ((value: unknown) => any) | undefined;
18
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
19
+ export default _default;
20
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
21
+ type __VLS_TypePropsToRuntimeProps<T> = {
22
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
23
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
24
+ } : {
25
+ type: import('vue').PropType<T[K]>;
26
+ required: true;
27
+ };
28
+ };
@@ -0,0 +1,176 @@
1
+ import { defineComponent as x, ref as k, computed as f, openBlock as a, createElementBlock as y, normalizeClass as g, createElementVNode as B, createTextVNode as C, toDisplayString as m, createCommentVNode as v, createBlock as t, unref as u } from "vue";
2
+ import { Textarea as S, TreeSelect as T, Upload as h, RadioGroup as D, CheckboxGroup as E, Select as N, Switch as P, InputNumber as q, DatePicker as I, DateRangePicker as R, TimePicker as w, TimeRangePicker as A, Input as G } from "aheart-ui";
3
+ const j = ["data-field-key", "aria-invalid", "aria-describedby"], z = ["id", "for"], L = {
4
+ key: 0,
5
+ class: "aheart-ai-form__required",
6
+ "aria-hidden": "true"
7
+ }, F = ["id"], H = ["id"], M = /* @__PURE__ */ x({
8
+ __name: "form-field",
9
+ props: {
10
+ field: {},
11
+ value: {},
12
+ disabled: { type: Boolean },
13
+ error: {}
14
+ },
15
+ emits: ["update"],
16
+ setup(e, { expose: c, emit: V }) {
17
+ const b = e, i = V, s = k(), n = k(), U = f(
18
+ () => (b.field.options ?? []).map((r) => ({
19
+ key: r.value,
20
+ title: r.label,
21
+ disabled: r.disabled
22
+ }))
23
+ ), o = f(
24
+ () => [b.field.description && `${b.field.key}-description`, b.error && `${b.field.key}-error`].filter(Boolean).join(" ") || void 0
25
+ ), $ = f(
26
+ () => b.field.type === "date-range" || b.field.type === "time-range" ? `${b.field.key}-start` : b.field.key
27
+ );
28
+ return c({
29
+ focus: () => {
30
+ var r, l;
31
+ if (n.value) {
32
+ n.value.focus("start");
33
+ return;
34
+ }
35
+ (l = (r = s.value) == null ? void 0 : r.querySelector('input, button, [role="combobox"], [tabindex="0"]')) == null || l.focus({ preventScroll: !0 });
36
+ }
37
+ }), (r, l) => (a(), y("div", {
38
+ ref_key: "fieldElement",
39
+ ref: s,
40
+ class: g(["aheart-ai-form__field", { "is-error": !!e.error, "is-disabled": e.disabled }]),
41
+ "data-field-key": e.field.key,
42
+ "aria-invalid": e.error ? "true" : void 0,
43
+ "aria-describedby": o.value,
44
+ tabindex: "-1"
45
+ }, [
46
+ B("label", {
47
+ id: `${e.field.key}-label`,
48
+ for: $.value
49
+ }, [
50
+ C(m(e.field.label) + " ", 1),
51
+ e.field.required ? (a(), y("span", L, "*")) : v("", !0)
52
+ ], 8, z),
53
+ e.field.description ? (a(), y("p", {
54
+ key: 0,
55
+ id: `${e.field.key}-description`,
56
+ class: "aheart-ai-form__field-description"
57
+ }, m(e.field.description), 9, F)) : v("", !0),
58
+ e.field.type === "textarea" ? (a(), t(u(S), {
59
+ key: 1,
60
+ id: e.field.key,
61
+ "aria-labelledby": `${e.field.key}-label`,
62
+ "aria-describedby": o.value,
63
+ "model-value": e.value,
64
+ placeholder: e.field.placeholder,
65
+ disabled: e.disabled,
66
+ "onUpdate:modelValue": l[0] || (l[0] = (d) => i("update", d))
67
+ }, null, 8, ["id", "aria-labelledby", "aria-describedby", "model-value", "placeholder", "disabled"])) : e.field.type === "tree-select" ? (a(), t(u(T), {
68
+ key: 2,
69
+ id: e.field.key,
70
+ "labelled-by": `${e.field.key}-label`,
71
+ "model-value": e.value,
72
+ "tree-data": U.value,
73
+ multiple: Array.isArray(e.value),
74
+ disabled: e.disabled,
75
+ "onUpdate:modelValue": l[1] || (l[1] = (d) => i("update", d))
76
+ }, null, 8, ["id", "labelled-by", "model-value", "tree-data", "multiple", "disabled"])) : e.field.type === "upload" ? (a(), t(u(h), {
77
+ key: 3,
78
+ "file-list": e.value,
79
+ disabled: e.disabled,
80
+ "onUpdate:fileList": l[2] || (l[2] = (d) => i("update", d))
81
+ }, null, 8, ["file-list", "disabled"])) : e.field.type === "radio" ? (a(), t(u(D), {
82
+ key: 4,
83
+ "model-value": e.value,
84
+ options: e.field.options,
85
+ disabled: e.disabled,
86
+ "onUpdate:modelValue": l[3] || (l[3] = (d) => i("update", d))
87
+ }, null, 8, ["model-value", "options", "disabled"])) : e.field.type === "checkbox" ? (a(), t(u(E), {
88
+ key: 5,
89
+ "model-value": e.value,
90
+ options: e.field.options,
91
+ disabled: e.disabled,
92
+ "onUpdate:modelValue": l[4] || (l[4] = (d) => i("update", d))
93
+ }, null, 8, ["model-value", "options", "disabled"])) : e.field.type === "select" ? (a(), t(u(N), {
94
+ key: 6,
95
+ id: e.field.key,
96
+ "labelled-by": `${e.field.key}-label`,
97
+ "model-value": e.value,
98
+ disabled: e.disabled,
99
+ options: e.field.options,
100
+ "onUpdate:modelValue": l[5] || (l[5] = (d) => i("update", d))
101
+ }, null, 8, ["id", "labelled-by", "model-value", "disabled", "options"])) : e.field.type === "switch" ? (a(), t(u(P), {
102
+ key: 7,
103
+ id: e.field.key,
104
+ "model-value": !!e.value,
105
+ disabled: e.disabled,
106
+ "onUpdate:modelValue": l[6] || (l[6] = (d) => i("update", d))
107
+ }, null, 8, ["id", "model-value", "disabled"])) : e.field.type === "number" ? (a(), t(u(q), {
108
+ key: 8,
109
+ id: e.field.key,
110
+ "model-value": e.value,
111
+ placeholder: e.field.placeholder,
112
+ disabled: e.disabled,
113
+ "onUpdate:modelValue": l[7] || (l[7] = (d) => i("update", d))
114
+ }, null, 8, ["id", "model-value", "placeholder", "disabled"])) : e.field.type === "date" ? (a(), t(u(I), {
115
+ key: 9,
116
+ id: e.field.key,
117
+ "labelled-by": `${e.field.key}-label`,
118
+ "described-by": o.value,
119
+ status: e.error ? "error" : void 0,
120
+ "model-value": e.value,
121
+ placeholder: e.field.placeholder,
122
+ disabled: e.disabled,
123
+ "onUpdate:modelValue": l[8] || (l[8] = (d) => i("update", d))
124
+ }, null, 8, ["id", "labelled-by", "described-by", "status", "model-value", "placeholder", "disabled"])) : e.field.type === "date-range" ? (a(), t(u(R), {
125
+ key: 10,
126
+ ref_key: "rangeControl",
127
+ ref: n,
128
+ id: e.field.key,
129
+ "labelled-by": `${e.field.key}-label`,
130
+ "described-by": o.value,
131
+ status: e.error ? "error" : void 0,
132
+ "model-value": e.value,
133
+ disabled: e.disabled,
134
+ "onUpdate:modelValue": l[9] || (l[9] = (d) => i("update", d))
135
+ }, null, 8, ["id", "labelled-by", "described-by", "status", "model-value", "disabled"])) : e.field.type === "time" ? (a(), t(u(w), {
136
+ key: 11,
137
+ id: e.field.key,
138
+ "labelled-by": `${e.field.key}-label`,
139
+ "described-by": o.value,
140
+ status: e.error ? "error" : void 0,
141
+ "model-value": e.value,
142
+ placeholder: e.field.placeholder,
143
+ disabled: e.disabled,
144
+ "onUpdate:modelValue": l[10] || (l[10] = (d) => i("update", d))
145
+ }, null, 8, ["id", "labelled-by", "described-by", "status", "model-value", "placeholder", "disabled"])) : e.field.type === "time-range" ? (a(), t(u(A), {
146
+ key: 12,
147
+ ref_key: "rangeControl",
148
+ ref: n,
149
+ id: e.field.key,
150
+ "labelled-by": `${e.field.key}-label`,
151
+ "described-by": o.value,
152
+ status: e.error ? "error" : void 0,
153
+ "model-value": e.value,
154
+ disabled: e.disabled,
155
+ "onUpdate:modelValue": l[11] || (l[11] = (d) => i("update", d))
156
+ }, null, 8, ["id", "labelled-by", "described-by", "status", "model-value", "disabled"])) : (a(), t(u(G), {
157
+ key: 13,
158
+ id: e.field.key,
159
+ "model-value": e.value,
160
+ placeholder: e.field.placeholder,
161
+ disabled: e.disabled,
162
+ "aria-describedby": o.value,
163
+ "onUpdate:modelValue": l[12] || (l[12] = (d) => i("update", d))
164
+ }, null, 8, ["id", "model-value", "placeholder", "disabled", "aria-describedby"])),
165
+ e.error ? (a(), y("p", {
166
+ key: 14,
167
+ id: `${e.field.key}-error`,
168
+ class: "aheart-ai-form__field-error",
169
+ role: "alert"
170
+ }, m(e.error), 9, H)) : v("", !0)
171
+ ], 10, j));
172
+ }
173
+ });
174
+ export {
175
+ M as default
176
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./form-field.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,73 @@
1
+ export declare const AI_FORM_FIELD_TYPES: readonly ["input", "textarea", "number", "select", "checkbox", "radio", "switch", "date", "date-range", "time", "time-range", "upload", "tree-select"];
2
+ export declare const AI_FORM_CONDITION_OPERATORS: readonly ["equals", "not-equals", "includes", "not-includes", "is-empty", "is-not-empty"];
3
+ export type AIFormFieldType = (typeof AI_FORM_FIELD_TYPES)[number];
4
+ export type AIFormConditionOperator = (typeof AI_FORM_CONDITION_OPERATORS)[number];
5
+ export interface AIFormCondition {
6
+ field: string;
7
+ operator: AIFormConditionOperator;
8
+ value?: string | number | boolean | string[];
9
+ }
10
+ export interface AIFormOption {
11
+ label: string;
12
+ value: string | number;
13
+ disabled?: boolean;
14
+ }
15
+ export interface AIFormGroupV1 {
16
+ key: string;
17
+ title: string;
18
+ description?: string;
19
+ }
20
+ export interface AIFormFieldV1 {
21
+ key: string;
22
+ label: string;
23
+ type: AIFormFieldType;
24
+ defaultValue?: unknown;
25
+ placeholder?: string;
26
+ description?: string;
27
+ group?: string;
28
+ required?: boolean;
29
+ options?: AIFormOption[];
30
+ visibleWhen?: AIFormCondition;
31
+ disabledWhen?: AIFormCondition;
32
+ rules?: AIFormRuleV1[];
33
+ dependencies?: string[];
34
+ preserve?: boolean;
35
+ }
36
+ export type AIFormRuleV1 = {
37
+ kind: 'range';
38
+ valueType: 'number' | 'length';
39
+ min?: number;
40
+ max?: number;
41
+ message?: string;
42
+ } | {
43
+ kind: 'format';
44
+ format: 'email' | 'url' | 'date' | 'time';
45
+ message?: string;
46
+ } | {
47
+ kind: 'compare';
48
+ field: string;
49
+ operator: 'equals' | 'not-equals' | 'greater-than' | 'greater-than-or-equal' | 'less-than' | 'less-than-or-equal';
50
+ message?: string;
51
+ } | {
52
+ kind: 'async';
53
+ validator: string;
54
+ message?: string;
55
+ };
56
+ export type AIFormAsyncValidator = (value: unknown, context: {
57
+ values: Readonly<Record<string, unknown>>;
58
+ field: AIFormFieldV1;
59
+ signal: AbortSignal;
60
+ }) => void | boolean | string | Promise<void | boolean | string>;
61
+ export interface AIFormSchemaV1 {
62
+ version: '1';
63
+ title?: string;
64
+ description?: string;
65
+ groups?: AIFormGroupV1[];
66
+ fields: AIFormFieldV1[];
67
+ }
68
+ export interface AIFormSchemaValidation {
69
+ valid: boolean;
70
+ errors: string[];
71
+ schema?: AIFormSchemaV1;
72
+ }
73
+ export declare const validateAIFormSchema: (schema: unknown) => AIFormSchemaValidation;
@@ -0,0 +1,105 @@
1
+ const $ = [
2
+ "input",
3
+ "textarea",
4
+ "number",
5
+ "select",
6
+ "checkbox",
7
+ "radio",
8
+ "switch",
9
+ "date",
10
+ "date-range",
11
+ "time",
12
+ "time-range",
13
+ "upload",
14
+ "tree-select"
15
+ ], b = ["equals", "not-equals", "includes", "not-includes", "is-empty", "is-not-empty"], a = (e) => typeof e == "object" && e !== null && !Array.isArray(e), u = (e) => typeof e == "string" || typeof e == "number", c = (e) => Array.isArray(e) && e.every(u), k = (e) => a(e) && typeof e.uid == "string" && typeof e.name == "string", l = (e) => {
16
+ if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e)) return !1;
17
+ const [t, i, o] = e.split("-").map(Number), r = new Date(Date.UTC(t, i - 1, o));
18
+ return r.getUTCFullYear() === t && r.getUTCMonth() === i - 1 && r.getUTCDate() === o;
19
+ }, h = (e) => {
20
+ if (typeof e != "string" || !/^\d{2}:\d{2}:\d{2}$/.test(e)) return !1;
21
+ const [t, i, o] = e.split(":").map(Number);
22
+ return t <= 23 && i <= 59 && o <= 59;
23
+ }, m = (e, t) => Array.isArray(e) && e.length === 2 && e.every(t), A = /* @__PURE__ */ new Set(["version", "title", "description", "groups", "fields"]), S = /* @__PURE__ */ new Set(["key", "title", "description"]), O = /* @__PURE__ */ new Set([
24
+ "key",
25
+ "label",
26
+ "type",
27
+ "defaultValue",
28
+ "placeholder",
29
+ "description",
30
+ "group",
31
+ "required",
32
+ "options",
33
+ "visibleWhen",
34
+ "disabledWhen",
35
+ "rules",
36
+ "dependencies",
37
+ "preserve"
38
+ ]), w = /* @__PURE__ */ new Set(["label", "value", "disabled"]), T = /* @__PURE__ */ new Set(["field", "operator", "value"]), E = /* @__PURE__ */ new Set(["select", "checkbox", "radio", "tree-select"]), d = (e, t, i, o) => {
39
+ const r = Object.keys(e).filter((p) => !t.has(p));
40
+ r.length && o.push(`${i} 包含不支持的属性:${r.join("、")}`);
41
+ }, _ = (e, t) => t === void 0 ? !0 : e === "switch" ? typeof t == "boolean" : e === "number" ? typeof t == "number" : e === "checkbox" ? c(t) : e === "upload" ? Array.isArray(t) && t.every(k) : e === "date" ? l(t) : e === "time" ? h(t) : e === "date-range" ? m(t, l) : e === "time-range" ? m(t, h) : e === "tree-select" ? u(t) || c(t) : e === "select" || e === "radio" ? u(t) : typeof t == "string", g = (e, t, i) => !a(e) || typeof e.field != "string" || !e.field.trim() ? (i.push(`${t} 必须包含字段名`), !1) : (d(e, T, t, i), typeof e.operator != "string" || !b.includes(e.operator) ? (i.push(`${t} 包含不支持的条件操作符`), !1) : e.value !== void 0 && !u(e.value) && typeof e.value != "boolean" && !Array.isArray(e.value) ? (i.push(`${t}.value 类型不安全`), !1) : Array.isArray(e.value) && !e.value.every((o) => typeof o == "string") ? (i.push(`${t}.value 数组只能包含字符串`), !1) : !0), D = (e) => {
42
+ const t = [];
43
+ if (!a(e) || e.version !== "1" || !Array.isArray(e.fields))
44
+ return { valid: !1, errors: ["AIForm schema 必须是 version 为 1 的 fields 数组"] };
45
+ d(e, A, "schema", t), e.title !== void 0 && typeof e.title != "string" && t.push("schema.title 必须是字符串"), e.description !== void 0 && typeof e.description != "string" && t.push("schema.description 必须是字符串");
46
+ const i = /* @__PURE__ */ new Set();
47
+ e.groups !== void 0 && (Array.isArray(e.groups) ? e.groups.forEach((r, p) => {
48
+ const s = `groups[${p}]`;
49
+ if (!a(r)) {
50
+ t.push(`${s} 必须是对象`);
51
+ return;
52
+ }
53
+ d(r, S, s, t), typeof r.key != "string" || !r.key.trim() ? t.push(`${s}.key 必须是非空字符串`) : i.has(r.key) ? t.push(`${s}.key 不能重复`) : i.add(r.key), (typeof r.title != "string" || !r.title.trim()) && t.push(`${s}.title 必须是非空字符串`), r.description !== void 0 && typeof r.description != "string" && t.push(`${s}.description 必须是字符串`);
54
+ }) : t.push("schema.groups 必须是数组"));
55
+ const o = /* @__PURE__ */ new Set();
56
+ return e.fields.forEach((r, p) => {
57
+ const s = `fields[${p}]`;
58
+ if (!a(r) || typeof r.key != "string" || !r.key.trim()) {
59
+ t.push(`${s}.key 必须是非空字符串`);
60
+ return;
61
+ }
62
+ d(r, O, s, t), o.has(r.key) && t.push(`${s}.key 不能重复`), o.add(r.key), typeof r.label != "string" && t.push(`${s}.label 必须是字符串`), (typeof r.type != "string" || !$.includes(r.type)) && t.push(`${s}.type 不受支持`), r.required !== void 0 && typeof r.required != "boolean" && t.push(`${s}.required 必须是布尔值`), r.placeholder !== void 0 && typeof r.placeholder != "string" && t.push(`${s}.placeholder 必须是字符串`), r.description !== void 0 && typeof r.description != "string" && t.push(`${s}.description 必须是字符串`), r.group !== void 0 && (typeof r.group != "string" || !i.has(r.group)) && t.push(`${s}.group 必须引用已声明的分组`), _(r.type, r.defaultValue) || t.push(`${s}.defaultValue 与字段类型不兼容`), r.visibleWhen !== void 0 && g(r.visibleWhen, `${s}.visibleWhen`, t), r.disabledWhen !== void 0 && g(r.disabledWhen, `${s}.disabledWhen`, t), r.dependencies !== void 0 && (!Array.isArray(r.dependencies) || !r.dependencies.every((n) => typeof n == "string" && n.trim())) && t.push(`${s}.dependencies 必须是非空字段名数组`), r.preserve !== void 0 && typeof r.preserve != "boolean" && t.push(`${s}.preserve 必须是布尔值`), r.rules !== void 0 && (Array.isArray(r.rules) ? r.rules.forEach((n, f) => q(n, `${s}.rules[${f}]`, t)) : t.push(`${s}.rules 必须是数组`)), r.options !== void 0 && (Array.isArray(r.options) ? r.options.forEach((n, f) => {
63
+ !a(n) || typeof n.label != "string" || !u(n.value) || n.disabled !== void 0 && typeof n.disabled != "boolean" ? t.push(`${s}.options[${f}] 不合法`) : d(n, w, `${s}.options[${f}]`, t);
64
+ }) : t.push(`${s}.options 必须是数组`)), r.required === !0 && E.has(r.type) && (!Array.isArray(r.options) || !r.options.some((n) => a(n) && n.disabled !== !0)) && t.push(`${s}.options 必须为必填字段提供至少一个可用选项`);
65
+ }), e.fields.forEach((r, p) => {
66
+ if (a(r)) {
67
+ for (const s of ["visibleWhen", "disabledWhen"]) {
68
+ const n = r[s];
69
+ a(n) && typeof n.field == "string" && !o.has(n.field) && t.push(`fields[${p}].${s}.field 必须引用已声明的字段`);
70
+ }
71
+ if (Array.isArray(r.dependencies))
72
+ for (const s of r.dependencies) typeof s == "string" && !o.has(s) && t.push(`fields[${p}].dependencies 必须引用已声明的字段`);
73
+ if (Array.isArray(r.rules))
74
+ for (const s of r.rules) a(s) && s.kind === "compare" && typeof s.field == "string" && !o.has(s.field) && t.push(`fields[${p}].rules.compare.field 必须引用已声明的字段`);
75
+ if (Array.isArray(r.rules)) {
76
+ for (const s of r.rules) if (a(s) && (s.kind === "range" && (s.valueType === "number" && r.type !== "number" || s.valueType === "length" && !["input", "textarea", "checkbox"].includes(String(r.type))) && t.push(`fields[${p}].rules.range 与字段类型组合不合法`), s.kind === "format" && ((s.format === "email" || s.format === "url" ? ["input", "textarea"] : s.format === "date" ? ["date"] : ["time"]).includes(String(r.type)) || t.push(`fields[${p}].rules.format 与字段类型组合不合法`)), s.kind === "compare" && typeof s.field == "string")) {
77
+ const n = e.fields.find((f) => a(f) && f.key === s.field);
78
+ n && ["greater-than", "greater-than-or-equal", "less-than", "less-than-or-equal"].includes(String(s.operator)) && (r.type === "number" && n.type === "number" || ["date", "time"].includes(String(r.type)) && r.type === n.type || t.push(`fields[${p}].rules.compare 有序比较类型不兼容`));
79
+ }
80
+ }
81
+ }
82
+ }), t.length ? { valid: !1, errors: t } : { valid: !0, errors: [], schema: e };
83
+ }, y = /* @__PURE__ */ Object.create(null);
84
+ Object.assign(y, {
85
+ range: /* @__PURE__ */ new Set(["kind", "valueType", "min", "max", "message"]),
86
+ format: /* @__PURE__ */ new Set(["kind", "format", "message"]),
87
+ compare: /* @__PURE__ */ new Set(["kind", "field", "operator", "message"]),
88
+ async: /* @__PURE__ */ new Set(["kind", "validator", "message"])
89
+ });
90
+ const q = (e, t, i) => {
91
+ if (!a(e) || typeof e.kind != "string" || !Object.prototype.hasOwnProperty.call(y, e.kind)) {
92
+ i.push(`${t} kind 不受支持`);
93
+ return;
94
+ }
95
+ if (d(e, y[e.kind], t, i), e.message !== void 0 && typeof e.message != "string" && i.push(`${t}.message 必须是字符串`), e.kind === "range") {
96
+ e.valueType !== "number" && e.valueType !== "length" && i.push(`${t}.valueType 不受支持`), e.min === void 0 && e.max === void 0 && i.push(`${t} 至少需要一个范围边界`);
97
+ for (const o of ["min", "max"]) e[o] !== void 0 && (typeof e[o] != "number" || !Number.isFinite(e[o])) && i.push(`${t}.${o} 必须是有限数字`);
98
+ typeof e.min == "number" && typeof e.max == "number" && e.min > e.max && i.push(`${t} min 不能大于 max`);
99
+ } else e.kind === "format" ? ["email", "url", "date", "time"].includes(String(e.format)) || i.push(`${t}.format 不受支持`) : e.kind === "compare" ? ((typeof e.field != "string" || !e.field.trim()) && i.push(`${t}.field 必须是字段名`), ["equals", "not-equals", "greater-than", "greater-than-or-equal", "less-than", "less-than-or-equal"].includes(String(e.operator)) || i.push(`${t}.operator 不受支持`)) : (typeof e.validator != "string" || !/^[A-Za-z][A-Za-z0-9_-]*$/.test(e.validator)) && i.push(`${t}.validator 必须是安全名称`);
100
+ };
101
+ export {
102
+ b as AI_FORM_CONDITION_OPERATORS,
103
+ $ as AI_FORM_FIELD_TYPES,
104
+ D as validateAIFormSchema
105
+ };