@evanschleret/formforgeclient 1.2.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/dist/module.cjs +1 -0
- package/dist/module.d.cts +1 -0
- package/dist/module.d.mts +1 -0
- package/dist/module.d.ts +1 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -0
- package/dist/runtime/api/client.js +4 -2
- package/dist/runtime/api/request.d.ts +1 -0
- package/dist/runtime/api/schema.js +4 -4
- package/dist/runtime/assets/formforge.css +1 -0
- package/dist/runtime/composables/index.d.ts +1 -1
- package/dist/runtime/composables/useFormForgeBuilder.d.ts +24 -2
- package/dist/runtime/composables/useFormForgeBuilder.js +299 -43
- package/dist/runtime/composables/useFormForgeClient.js +3 -5
- package/dist/runtime/composables/useFormForgeForm.js +15 -5
- package/dist/runtime/composables/useFormForgeI18n.d.ts +245 -19
- package/dist/runtime/composables/useFormForgeI18n.js +245 -19
- package/dist/runtime/composables/useFormForgeSubmit.js +31 -9
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/renderers/default/FormForgeBuilder.d.vue.ts +21 -2
- package/dist/runtime/renderers/default/FormForgeBuilder.vue +689 -738
- package/dist/runtime/renderers/default/FormForgeBuilder.vue.d.ts +21 -2
- package/dist/runtime/renderers/default/FormForgeBuilderBlockSettingsModal.d.vue.ts +17 -0
- package/dist/runtime/renderers/default/FormForgeBuilderBlockSettingsModal.vue +32 -0
- package/dist/runtime/renderers/default/FormForgeBuilderBlockSettingsModal.vue.d.ts +17 -0
- package/dist/runtime/renderers/default/FormForgeRenderer.d.vue.ts +3 -4
- package/dist/runtime/renderers/default/FormForgeRenderer.vue +344 -294
- package/dist/runtime/renderers/default/FormForgeRenderer.vue.d.ts +3 -4
- package/dist/runtime/renderers/default/FormForgeRendererField.d.vue.ts +22 -0
- package/dist/runtime/renderers/default/FormForgeRendererField.vue +237 -0
- package/dist/runtime/renderers/default/FormForgeRendererField.vue.d.ts +22 -0
- package/dist/runtime/renderers/default/FormForgeRendererPage.d.vue.ts +18 -0
- package/dist/runtime/renderers/default/FormForgeRendererPage.vue +31 -0
- package/dist/runtime/renderers/default/FormForgeRendererPage.vue.d.ts +18 -0
- package/dist/runtime/renderers/default/FormForgeResponse.vue +4 -3
- package/dist/runtime/renderers/default/builder/FormForgeBuilderAddressFieldsCard.d.vue.ts +11 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderAddressFieldsCard.vue +118 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderAddressFieldsCard.vue.d.ts +11 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderBlockCard.d.vue.ts +46 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderBlockCard.vue +205 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderBlockCard.vue.d.ts +46 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderChoiceDisplayField.d.vue.ts +11 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderChoiceDisplayField.vue +37 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderChoiceDisplayField.vue.d.ts +11 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderChoiceOptionsField.d.vue.ts +11 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderChoiceOptionsField.vue +195 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderChoiceOptionsField.vue.d.ts +11 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderDescriptionField.d.vue.ts +14 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderDescriptionField.vue +91 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderDescriptionField.vue.d.ts +14 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderLogicPanel.d.vue.ts +13 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderLogicPanel.vue +387 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderLogicPanel.vue.d.ts +13 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderQuestionRow.d.vue.ts +44 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderQuestionRow.vue +328 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderQuestionRow.vue.d.ts +44 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderTemporalModeField.d.vue.ts +11 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderTemporalModeField.vue +47 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderTemporalModeField.vue.d.ts +11 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderValidationRulesSection.d.vue.ts +14 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderValidationRulesSection.vue +595 -0
- package/dist/runtime/renderers/default/builder/FormForgeBuilderValidationRulesSection.vue.d.ts +14 -0
- package/dist/runtime/renderers/default/builder/builderFieldHelpers.d.ts +3 -0
- package/dist/runtime/renderers/default/builder/builderFieldHelpers.js +4 -0
- package/dist/runtime/types/index.d.ts +1 -1
- package/dist/runtime/types/management.d.ts +12 -0
- package/dist/runtime/types/schema.d.ts +72 -4
- package/dist/runtime/utils/defaults.d.ts +7 -0
- package/dist/runtime/utils/defaults.js +86 -0
- package/dist/runtime/utils/page-logic.d.ts +24 -0
- package/dist/runtime/utils/page-logic.js +351 -0
- package/dist/runtime/utils/rich-text.d.ts +3 -0
- package/dist/runtime/utils/rich-text.js +72 -0
- package/dist/runtime/utils/schema.d.ts +1 -1
- package/dist/runtime/utils/schema.js +70 -16
- package/dist/runtime/utils/temporal.d.ts +10 -0
- package/dist/runtime/utils/temporal.js +28 -0
- package/dist/runtime/utils/validation.d.ts +5 -0
- package/dist/runtime/utils/validation.js +36 -0
- package/dist/runtime/validation/zod.d.ts +5 -2
- package/dist/runtime/validation/zod.js +563 -54
- package/dist/types.d.mts +2 -0
- package/package.json +18 -14
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useFormForgeI18n } from "../../../composables/useFormForgeI18n";
|
|
3
|
+
import {
|
|
4
|
+
createPageLogicRule,
|
|
5
|
+
createPageLogicThen,
|
|
6
|
+
ensurePageLogic,
|
|
7
|
+
findFieldByKey,
|
|
8
|
+
getFuturePageQuestions,
|
|
9
|
+
isChoiceFieldType,
|
|
10
|
+
isConsentFieldType,
|
|
11
|
+
pageLogicOperatorRequiresValue,
|
|
12
|
+
pageLogicOperatorsForFieldType
|
|
13
|
+
} from "../../../utils/page-logic";
|
|
14
|
+
const props = defineProps({
|
|
15
|
+
page: { type: Object, required: true },
|
|
16
|
+
pages: { type: Array, required: true },
|
|
17
|
+
pageIndex: { type: Number, required: true },
|
|
18
|
+
readonly: { type: Boolean, required: false, default: false }
|
|
19
|
+
});
|
|
20
|
+
const logic = ensurePageLogic(props.page);
|
|
21
|
+
const { t } = useFormForgeI18n();
|
|
22
|
+
function logicMatchItems() {
|
|
23
|
+
return [
|
|
24
|
+
{ label: t("builder.logic.match.all"), value: "all" },
|
|
25
|
+
{ label: t("builder.logic.match.any"), value: "any" }
|
|
26
|
+
];
|
|
27
|
+
}
|
|
28
|
+
function logicFallbackActionItems() {
|
|
29
|
+
return [
|
|
30
|
+
{ label: t("builder.logic.fallback.next"), value: "next" },
|
|
31
|
+
{ label: t("builder.logic.fallback.goto"), value: "goto_block" }
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
function fieldItems() {
|
|
35
|
+
return props.page.fields.map((field) => ({
|
|
36
|
+
label: field.label === void 0 || field.label === "" ? field.field_key : field.label,
|
|
37
|
+
value: field.field_key
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
function futureQuestionItems() {
|
|
41
|
+
return getFuturePageQuestions(props.pages, props.pageIndex).map((field) => ({
|
|
42
|
+
label: field.label === void 0 || field.label === "" ? field.field_key : field.label,
|
|
43
|
+
value: field.field_key
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
function futureBlockItems() {
|
|
47
|
+
return props.pages.slice(props.pageIndex + 1).map((page, index) => ({
|
|
48
|
+
label: t("builder.logic.destinationBlockLabel", {
|
|
49
|
+
index: props.pageIndex + index + 2
|
|
50
|
+
}),
|
|
51
|
+
value: props.pageIndex + index + 2
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
function logicRuleOperatorItems(field) {
|
|
55
|
+
if (field === void 0) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
return pageLogicOperatorsForFieldType(field.type).map((operator) => ({
|
|
59
|
+
label: logicOperatorLabel(operator),
|
|
60
|
+
value: operator
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
function logicClauseOperator(field, operator) {
|
|
64
|
+
const items = logicRuleOperatorItems(field);
|
|
65
|
+
const available = new Set(items.map((item) => item.value));
|
|
66
|
+
if (available.has(operator)) {
|
|
67
|
+
return operator;
|
|
68
|
+
}
|
|
69
|
+
return items[0]?.value ?? operator;
|
|
70
|
+
}
|
|
71
|
+
function defaultLogicOperatorForField(field) {
|
|
72
|
+
return logicRuleOperatorItems(field)[0]?.value ?? "eq";
|
|
73
|
+
}
|
|
74
|
+
function logicOperatorLabel(operator) {
|
|
75
|
+
const labels = {
|
|
76
|
+
eq: t("builder.logic.operator.eq"),
|
|
77
|
+
neq: t("builder.logic.operator.neq"),
|
|
78
|
+
contains: t("builder.logic.operator.contains"),
|
|
79
|
+
not_contains: t("builder.logic.operator.not_contains"),
|
|
80
|
+
starts_with: t("builder.logic.operator.starts_with"),
|
|
81
|
+
not_starts_with: t("builder.logic.operator.not_starts_with"),
|
|
82
|
+
ends_with: t("builder.logic.operator.ends_with"),
|
|
83
|
+
not_ends_with: t("builder.logic.operator.not_ends_with"),
|
|
84
|
+
is_submitted: t("builder.logic.operator.is_submitted"),
|
|
85
|
+
is_not_submitted: t("builder.logic.operator.is_not_submitted"),
|
|
86
|
+
accepted: t("builder.logic.operator.accepted"),
|
|
87
|
+
ignored: t("builder.logic.operator.ignored")
|
|
88
|
+
};
|
|
89
|
+
return labels[operator] ?? operator;
|
|
90
|
+
}
|
|
91
|
+
function logicClauseRequiresValue(clause) {
|
|
92
|
+
const field = findFieldByKey(props.page, clause.field_key);
|
|
93
|
+
if (field === void 0) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
return pageLogicOperatorRequiresValue(field.type, clause.operator);
|
|
97
|
+
}
|
|
98
|
+
function logicClauseChoiceItems(clause) {
|
|
99
|
+
const field = findFieldByKey(props.page, clause.field_key);
|
|
100
|
+
if (field === void 0 || !Array.isArray(field.options)) {
|
|
101
|
+
return [];
|
|
102
|
+
}
|
|
103
|
+
return field.options.map((option, index) => ({
|
|
104
|
+
label: typeof option === "object" && option !== null && "label" in option && typeof option.label === "string" && option.label !== "" ? option.label : t("builder.optionPlaceholder", { index: index + 1 }),
|
|
105
|
+
value: typeof option === "object" && option !== null && "value" in option ? option.value : option
|
|
106
|
+
}));
|
|
107
|
+
}
|
|
108
|
+
function logicClauseConsentItems() {
|
|
109
|
+
return [
|
|
110
|
+
{ label: t("builder.logic.consent.accepted"), value: true },
|
|
111
|
+
{ label: t("builder.logic.consent.ignored"), value: false }
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
function thenActionItems() {
|
|
115
|
+
return [
|
|
116
|
+
{ label: t("builder.logic.then.require"), value: "require" },
|
|
117
|
+
{ label: t("builder.logic.then.goto"), value: "goto_block" }
|
|
118
|
+
];
|
|
119
|
+
}
|
|
120
|
+
function addLogicRule() {
|
|
121
|
+
logic.rules.push(createPageLogicRule());
|
|
122
|
+
}
|
|
123
|
+
function addThenAction(rule) {
|
|
124
|
+
rule.then.push(createPageLogicThen());
|
|
125
|
+
}
|
|
126
|
+
function removeThenAction(rule, thenIndex) {
|
|
127
|
+
if (rule.then.length <= 1) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
rule.then.splice(thenIndex, 1);
|
|
131
|
+
}
|
|
132
|
+
function setThenAction(rule, thenIndex, action) {
|
|
133
|
+
const thenAction = rule.then[thenIndex];
|
|
134
|
+
if (thenAction === void 0) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
thenAction.action = action;
|
|
138
|
+
if (action === "require") {
|
|
139
|
+
thenAction.block_index = null;
|
|
140
|
+
if (typeof thenAction.field_key !== "string") {
|
|
141
|
+
thenAction.field_key = null;
|
|
142
|
+
}
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
thenAction.field_key = null;
|
|
146
|
+
}
|
|
147
|
+
function thenTargetItems(action) {
|
|
148
|
+
return action === "require" ? futureQuestionItems() : futureBlockItems();
|
|
149
|
+
}
|
|
150
|
+
function thenTargetPlaceholder(action) {
|
|
151
|
+
return action === "require" ? t("builder.logic.requireQuestionPlaceholder") : t("builder.logic.gotoBlockPlaceholder");
|
|
152
|
+
}
|
|
153
|
+
function usedRequiredFieldKeys(rule, excludeIndex) {
|
|
154
|
+
const keys = /* @__PURE__ */ new Set();
|
|
155
|
+
for (const [index, thenAction] of rule.then.entries()) {
|
|
156
|
+
if (index === excludeIndex) {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (thenAction.action === "require" && typeof thenAction.field_key === "string" && thenAction.field_key !== "") {
|
|
160
|
+
keys.add(thenAction.field_key);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return keys;
|
|
164
|
+
}
|
|
165
|
+
function availableThenQuestionItems(rule, thenIndex) {
|
|
166
|
+
const usedKeys = usedRequiredFieldKeys(rule, thenIndex);
|
|
167
|
+
return futureQuestionItems().filter((item) => !usedKeys.has(item.value));
|
|
168
|
+
}
|
|
169
|
+
function addLogicClause(rule) {
|
|
170
|
+
rule.when.push({
|
|
171
|
+
field_key: "",
|
|
172
|
+
operator: "eq",
|
|
173
|
+
value: null
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function removeLogicClause(rule, clauseIndex) {
|
|
177
|
+
if (rule.when.length <= 1) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
rule.when.splice(clauseIndex, 1);
|
|
181
|
+
}
|
|
182
|
+
</script>
|
|
183
|
+
|
|
184
|
+
<template>
|
|
185
|
+
<div class="grid gap-4">
|
|
186
|
+
<div class="flex items-center justify-between gap-3">
|
|
187
|
+
<div class="text-sm">
|
|
188
|
+
{{ logic.rules.length === 0 ? t("builder.logic.empty") : t("builder.logic.rulesCount", { count: logic.rules.length }) }}
|
|
189
|
+
</div>
|
|
190
|
+
<UButton
|
|
191
|
+
color="neutral"
|
|
192
|
+
variant="soft"
|
|
193
|
+
icon="i-lucide-plus"
|
|
194
|
+
:disabled="readonly"
|
|
195
|
+
@click="addLogicRule"
|
|
196
|
+
>
|
|
197
|
+
{{ t("builder.logic.addRule") }}
|
|
198
|
+
</UButton>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
<UCard
|
|
202
|
+
v-for="rule in logic.rules"
|
|
203
|
+
:key="rule.rule_key"
|
|
204
|
+
:ui="{
|
|
205
|
+
body: 'grid gap-4'
|
|
206
|
+
}"
|
|
207
|
+
>
|
|
208
|
+
<div class="grid gap-2">
|
|
209
|
+
<span class="text-sm font-bold text-default">
|
|
210
|
+
{{ t("builder.logic.rule") }}
|
|
211
|
+
</span>
|
|
212
|
+
<div class="grid gap-3 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-center">
|
|
213
|
+
<USelect
|
|
214
|
+
v-model="rule.match"
|
|
215
|
+
:items="logicMatchItems()"
|
|
216
|
+
:disabled="readonly"
|
|
217
|
+
/>
|
|
218
|
+
<UButton
|
|
219
|
+
color="neutral"
|
|
220
|
+
variant="ghost"
|
|
221
|
+
icon="i-lucide-trash-2"
|
|
222
|
+
:disabled="readonly"
|
|
223
|
+
@click="logic.rules = logic.rules.filter((candidate) => candidate.rule_key !== rule.rule_key)"
|
|
224
|
+
/>
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
|
|
228
|
+
<div class="grid gap-3">
|
|
229
|
+
<div
|
|
230
|
+
v-for="(clause, clauseIndex) in rule.when"
|
|
231
|
+
:key="`${rule.rule_key}-${clauseIndex}`"
|
|
232
|
+
class="grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_minmax(0,1.2fr)_auto] lg:items-center"
|
|
233
|
+
>
|
|
234
|
+
<USelect
|
|
235
|
+
:model-value="clause.field_key"
|
|
236
|
+
:items="fieldItems()"
|
|
237
|
+
:disabled="readonly"
|
|
238
|
+
@update:model-value="(value) => {
|
|
239
|
+
const field = findFieldByKey(props.page, value);
|
|
240
|
+
clause.field_key = value;
|
|
241
|
+
clause.operator = defaultLogicOperatorForField(field);
|
|
242
|
+
clause.value = null;
|
|
243
|
+
}"
|
|
244
|
+
/>
|
|
245
|
+
<USelect
|
|
246
|
+
:model-value="logicClauseOperator(findFieldByKey(props.page, clause.field_key), clause.operator)"
|
|
247
|
+
:items="logicRuleOperatorItems(findFieldByKey(props.page, clause.field_key))"
|
|
248
|
+
:disabled="readonly"
|
|
249
|
+
@update:model-value="(value) => {
|
|
250
|
+
clause.operator = value;
|
|
251
|
+
if (!logicClauseRequiresValue(clause)) {
|
|
252
|
+
clause.value = null;
|
|
253
|
+
}
|
|
254
|
+
}"
|
|
255
|
+
/>
|
|
256
|
+
<USelectMenu
|
|
257
|
+
v-if="logicClauseRequiresValue(clause) && findFieldByKey(props.page, clause.field_key) !== void 0 && isChoiceFieldType(findFieldByKey(props.page, clause.field_key).type)"
|
|
258
|
+
:model-value="clause.value"
|
|
259
|
+
:items="logicClauseChoiceItems(clause)"
|
|
260
|
+
:disabled="readonly"
|
|
261
|
+
@update:model-value="(value) => {
|
|
262
|
+
clause.value = value;
|
|
263
|
+
}"
|
|
264
|
+
/>
|
|
265
|
+
<USelect
|
|
266
|
+
v-else-if="logicClauseRequiresValue(clause) && findFieldByKey(props.page, clause.field_key) !== void 0 && isConsentFieldType(findFieldByKey(props.page, clause.field_key).type)"
|
|
267
|
+
:model-value="clause.value"
|
|
268
|
+
:items="logicClauseConsentItems()"
|
|
269
|
+
:disabled="readonly"
|
|
270
|
+
@update:model-value="(value) => {
|
|
271
|
+
clause.value = value;
|
|
272
|
+
}"
|
|
273
|
+
/>
|
|
274
|
+
<UInput
|
|
275
|
+
v-else-if="logicClauseRequiresValue(clause)"
|
|
276
|
+
:model-value="typeof clause.value === 'string' ? clause.value : String(clause.value ?? '')"
|
|
277
|
+
:disabled="readonly"
|
|
278
|
+
:placeholder="t('builder.logic.valuePlaceholder')"
|
|
279
|
+
@update:model-value="(value) => {
|
|
280
|
+
clause.value = value;
|
|
281
|
+
}"
|
|
282
|
+
/>
|
|
283
|
+
<div v-else />
|
|
284
|
+
|
|
285
|
+
<UButton
|
|
286
|
+
color="neutral"
|
|
287
|
+
variant="soft"
|
|
288
|
+
:disabled="readonly || rule.when.length <= 1"
|
|
289
|
+
@click="removeLogicClause(rule, clauseIndex)"
|
|
290
|
+
>
|
|
291
|
+
{{ t("builder.remove") }}
|
|
292
|
+
</UButton>
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
295
|
+
|
|
296
|
+
<div class="flex flex-wrap gap-2">
|
|
297
|
+
<UButton
|
|
298
|
+
color="neutral"
|
|
299
|
+
variant="soft"
|
|
300
|
+
icon="i-lucide-plus"
|
|
301
|
+
:disabled="readonly"
|
|
302
|
+
@click="addLogicClause(rule)"
|
|
303
|
+
>
|
|
304
|
+
{{ t("builder.logic.addClause") }}
|
|
305
|
+
</UButton>
|
|
306
|
+
</div>
|
|
307
|
+
|
|
308
|
+
<div class="grid gap-2">
|
|
309
|
+
<span class="text-sm font-bold text-default">{{ t("builder.logic.then") }}</span>
|
|
310
|
+
<div class="grid gap-3">
|
|
311
|
+
<div
|
|
312
|
+
v-for="(thenAction, thenIndex) in rule.then"
|
|
313
|
+
:key="`${rule.rule_key}-${thenIndex}`"
|
|
314
|
+
class="grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] lg:items-center"
|
|
315
|
+
>
|
|
316
|
+
<USelect
|
|
317
|
+
:model-value="thenAction.action"
|
|
318
|
+
:items="thenActionItems()"
|
|
319
|
+
:disabled="readonly"
|
|
320
|
+
@update:model-value="(value) => setThenAction(rule, thenIndex, value)"
|
|
321
|
+
/>
|
|
322
|
+
<USelectMenu
|
|
323
|
+
v-if="thenAction.action === 'require'"
|
|
324
|
+
v-model="thenAction.field_key"
|
|
325
|
+
:items="availableThenQuestionItems(rule, thenIndex)"
|
|
326
|
+
value-key="value"
|
|
327
|
+
label-key="label"
|
|
328
|
+
:search-input="false"
|
|
329
|
+
:disabled="readonly"
|
|
330
|
+
:placeholder="thenTargetPlaceholder('require')"
|
|
331
|
+
/>
|
|
332
|
+
<USelectMenu
|
|
333
|
+
v-else
|
|
334
|
+
v-model="thenAction.block_index"
|
|
335
|
+
:items="thenTargetItems('goto_block')"
|
|
336
|
+
value-key="value"
|
|
337
|
+
label-key="label"
|
|
338
|
+
:search-input="false"
|
|
339
|
+
:disabled="readonly"
|
|
340
|
+
:placeholder="thenTargetPlaceholder('goto_block')"
|
|
341
|
+
/>
|
|
342
|
+
<UButton
|
|
343
|
+
color="neutral"
|
|
344
|
+
variant="soft"
|
|
345
|
+
:disabled="readonly || rule.then.length <= 1"
|
|
346
|
+
@click="removeThenAction(rule, thenIndex)"
|
|
347
|
+
>
|
|
348
|
+
{{ t("builder.remove") }}
|
|
349
|
+
</UButton>
|
|
350
|
+
</div>
|
|
351
|
+
</div>
|
|
352
|
+
<div class="flex flex-wrap gap-2">
|
|
353
|
+
<UButton
|
|
354
|
+
color="neutral"
|
|
355
|
+
variant="soft"
|
|
356
|
+
icon="i-lucide-plus"
|
|
357
|
+
:disabled="readonly"
|
|
358
|
+
@click="addThenAction(rule)"
|
|
359
|
+
>
|
|
360
|
+
{{ t("builder.logic.then.addAction") }}
|
|
361
|
+
</UButton>
|
|
362
|
+
</div>
|
|
363
|
+
</div>
|
|
364
|
+
|
|
365
|
+
<div class="grid gap-2">
|
|
366
|
+
<span class="text-sm font-bold text-default">{{ t("builder.logic.fallback") }}</span>
|
|
367
|
+
<div class="grid gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)] lg:items-center">
|
|
368
|
+
<USelect
|
|
369
|
+
v-model="rule.fallback.action"
|
|
370
|
+
:items="logicFallbackActionItems()"
|
|
371
|
+
:disabled="readonly"
|
|
372
|
+
/>
|
|
373
|
+
<USelectMenu
|
|
374
|
+
v-if="rule.fallback.action === 'goto_block'"
|
|
375
|
+
v-model="rule.fallback.block_index"
|
|
376
|
+
:items="futureBlockItems()"
|
|
377
|
+
value-key="value"
|
|
378
|
+
label-key="label"
|
|
379
|
+
:search-input="false"
|
|
380
|
+
:disabled="readonly"
|
|
381
|
+
:placeholder="t('builder.logic.gotoBlockPlaceholder')"
|
|
382
|
+
/>
|
|
383
|
+
</div>
|
|
384
|
+
</div>
|
|
385
|
+
</UCard>
|
|
386
|
+
</div>
|
|
387
|
+
</template>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FormForgePageSchema } from '../../../types/index.js';
|
|
2
|
+
interface Props {
|
|
3
|
+
page: FormForgePageSchema;
|
|
4
|
+
pages: FormForgePageSchema[];
|
|
5
|
+
pageIndex: number;
|
|
6
|
+
readonly?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
|
|
9
|
+
readonly: boolean;
|
|
10
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
11
|
+
declare const _default: typeof __VLS_export;
|
|
12
|
+
export default _default;
|
|
13
|
+
//# sourceMappingURL=FormForgeBuilderLogicPanel.vue.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { FormForgeFieldSchema, FormForgeFieldType, FormForgePageSchema } from '../../../types/index.js';
|
|
2
|
+
interface QuestionTypeItem {
|
|
3
|
+
label: string;
|
|
4
|
+
value: FormForgeFieldType;
|
|
5
|
+
icon?: string;
|
|
6
|
+
}
|
|
7
|
+
interface FutureBlockItem {
|
|
8
|
+
label: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}
|
|
11
|
+
interface Props {
|
|
12
|
+
page: FormForgePageSchema;
|
|
13
|
+
field: FormForgeFieldSchema;
|
|
14
|
+
index: number;
|
|
15
|
+
readonly?: boolean;
|
|
16
|
+
selected?: boolean;
|
|
17
|
+
fieldTypeItems: QuestionTypeItem[];
|
|
18
|
+
futureBlockItems: FutureBlockItem[];
|
|
19
|
+
}
|
|
20
|
+
declare const __VLS_export: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
21
|
+
select: () => any;
|
|
22
|
+
"move-up": () => any;
|
|
23
|
+
"move-down": () => any;
|
|
24
|
+
duplicate: () => any;
|
|
25
|
+
remove: () => any;
|
|
26
|
+
"change-type": (value: FormForgeFieldType) => any;
|
|
27
|
+
"add-below": (value: FormForgeFieldType) => any;
|
|
28
|
+
"move-to-block": (value: string) => any;
|
|
29
|
+
}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{
|
|
30
|
+
onSelect?: (() => any) | undefined;
|
|
31
|
+
"onMove-up"?: (() => any) | undefined;
|
|
32
|
+
"onMove-down"?: (() => any) | undefined;
|
|
33
|
+
onDuplicate?: (() => any) | undefined;
|
|
34
|
+
onRemove?: (() => any) | undefined;
|
|
35
|
+
"onChange-type"?: ((value: FormForgeFieldType) => any) | undefined;
|
|
36
|
+
"onAdd-below"?: ((value: FormForgeFieldType) => any) | undefined;
|
|
37
|
+
"onMove-to-block"?: ((value: string) => any) | undefined;
|
|
38
|
+
}>, {
|
|
39
|
+
readonly: boolean;
|
|
40
|
+
selected: boolean;
|
|
41
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
42
|
+
declare const _default: typeof __VLS_export;
|
|
43
|
+
export default _default;
|
|
44
|
+
//# sourceMappingURL=FormForgeBuilderQuestionRow.vue.d.ts.map
|