@atscript/vue-form 0.1.164 → 0.1.166
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/dist/{as-array-CqnBh3rv.mjs → as-array-B2axGw3v.mjs} +15 -12
- package/dist/{as-array-CxeMe9Dw.cjs → as-array-C97cLzdA.cjs} +16 -13
- package/dist/{as-array-clear-btn-COfRUzeb.cjs → as-array-clear-btn-BBFccQjO.cjs} +5 -3
- package/dist/{as-array-clear-btn-BY1IBwBP.mjs → as-array-clear-btn-DEH8a3_N.mjs} +6 -4
- package/dist/as-array.cjs +1 -1
- package/dist/as-array.mjs +1 -1
- package/dist/{as-checkbox-DosdhEuS.mjs → as-checkbox-BO8xW0OM.mjs} +36 -12
- package/dist/{as-checkbox-QO5Oh13K.cjs → as-checkbox-Wn-PmHi-.cjs} +35 -11
- package/dist/as-checkbox.cjs +1 -1
- package/dist/as-checkbox.mjs +1 -1
- package/dist/{as-collapsible-CQyuXwj9.cjs → as-collapsible-BGeuF2Bn.cjs} +4 -2
- package/dist/{as-collapsible-DHSlSMfY.mjs → as-collapsible-Cb9SgJh9.mjs} +5 -3
- package/dist/as-collapsible.cjs +1 -1
- package/dist/as-collapsible.mjs +1 -1
- package/dist/{as-date-DTUQP2Dc.cjs → as-date-B2dgUoau.cjs} +1 -1
- package/dist/{as-date-DyQsn7Mu.mjs → as-date-jQpwe6sr.mjs} +1 -1
- package/dist/as-date.cjs +1 -1
- package/dist/as-date.mjs +1 -1
- package/dist/{as-datetime-BDJtlZLz.cjs → as-datetime-CmBLyjgU.cjs} +1 -1
- package/dist/{as-datetime-CrstxtPJ.mjs → as-datetime-DYn9NndT.mjs} +1 -1
- package/dist/as-datetime.cjs +1 -1
- package/dist/as-datetime.mjs +1 -1
- package/dist/{as-decimal-Bimpnzo2.mjs → as-decimal-C-OJ8ygU.mjs} +4 -3
- package/dist/{as-decimal-BZWqiKXZ.cjs → as-decimal-C0Eqd9nM.cjs} +4 -3
- package/dist/as-decimal.cjs +1 -1
- package/dist/as-decimal.mjs +1 -1
- package/dist/{as-field-DQxlwJVM.mjs → as-field-BZpWLPcM.mjs} +16 -13
- package/dist/{as-field-8MDWK_jb.cjs → as-field-D0HgywQY.cjs} +15 -12
- package/dist/{as-field-shell-Bxqa_ZsU.mjs → as-field-shell-D7XovzgJ.mjs} +14 -7
- package/dist/{as-field-shell-BrJpCzIA.cjs → as-field-shell-DSj3CqN6.cjs} +14 -7
- package/dist/as-field-shell.cjs +1 -1
- package/dist/as-field-shell.mjs +1 -1
- package/dist/as-field.cjs +1 -1
- package/dist/as-field.mjs +1 -1
- package/dist/{as-form-C-CV5ezE.mjs → as-form-0VCxVsGo.mjs} +18 -10
- package/dist/{as-form-DLSFfuLR.cjs → as-form-ChyW9bj2.cjs} +18 -10
- package/dist/as-form.cjs +1 -1
- package/dist/as-form.d.cts +1 -1
- package/dist/as-form.d.mts +1 -1
- package/dist/as-form.mjs +1 -1
- package/dist/{as-form.vue-BA70Ib2m.d.cts → as-form.vue-BuRFHSK-.d.cts} +6 -10
- package/dist/{as-form.vue-D2SQ5VeJ.d.mts → as-form.vue-CHEkgO3k.d.mts} +6 -10
- package/dist/{as-input-UkZxRSD4.cjs → as-input-Bf94SAOY.cjs} +1 -1
- package/dist/{as-input-65rtLZt3.mjs → as-input-DlLLiAYI.mjs} +1 -1
- package/dist/as-input.cjs +1 -1
- package/dist/as-input.mjs +1 -1
- package/dist/{as-iterator-Bbyxog8g.cjs → as-iterator-Bty6f5Bq.cjs} +2 -2
- package/dist/{as-iterator-CaQ1TkIR.mjs → as-iterator-Dp1OiwU7.mjs} +2 -2
- package/dist/as-iterator.cjs +1 -1
- package/dist/as-iterator.mjs +1 -1
- package/dist/{as-multi-select-B7Nc2brD.mjs → as-multi-select-DT0M_1_O.mjs} +20 -17
- package/dist/{as-multi-select-BiUexFnY.cjs → as-multi-select-ZGBYoI48.cjs} +19 -16
- package/dist/as-multi-select.cjs +1 -1
- package/dist/as-multi-select.mjs +1 -1
- package/dist/{as-number-BMsgxGQw.cjs → as-number-DXQCnc9d.cjs} +2 -2
- package/dist/{as-number-6DTZnVfg.mjs → as-number-DkG5GuGW.mjs} +2 -2
- package/dist/as-number.cjs +1 -1
- package/dist/as-number.mjs +1 -1
- package/dist/{as-object-BjOUiVDG.cjs → as-object-DLdKOhxb.cjs} +14 -8
- package/dist/{as-object-0Qo0bPi5.mjs → as-object-mpRxIKVB.mjs} +14 -8
- package/dist/as-object.cjs +1 -1
- package/dist/as-object.mjs +1 -1
- package/dist/{as-radio-Dg9c4dGh.mjs → as-radio-CW9YWBnC.mjs} +3 -3
- package/dist/{as-radio-C06SIAFY.cjs → as-radio-D9sctKpc.cjs} +2 -2
- package/dist/as-radio.cjs +1 -1
- package/dist/as-radio.mjs +1 -1
- package/dist/{as-ref-BEhS_vo9.cjs → as-ref-CpHMAAJu.cjs} +5 -3
- package/dist/{as-ref-BWJlIf5G.mjs → as-ref-DaCGfshO.mjs} +5 -3
- package/dist/as-ref.cjs +1 -1
- package/dist/as-ref.mjs +1 -1
- package/dist/{as-select-CrTKlmhd.mjs → as-select-CrjlxcgR.mjs} +3 -3
- package/dist/{as-select-DzEUs8Od.cjs → as-select-DAbNosmB.cjs} +2 -2
- package/dist/as-select.cjs +1 -1
- package/dist/as-select.mjs +1 -1
- package/dist/{as-time-BQ6KXMyV.mjs → as-time-BmXXgfCZ.mjs} +1 -1
- package/dist/{as-time-Cu-8mKpR.cjs → as-time-NaICaSIj.cjs} +1 -1
- package/dist/as-time.cjs +1 -1
- package/dist/as-time.mjs +1 -1
- package/dist/{as-tuple-fwxeV71M.mjs → as-tuple-BBx6P6xb.mjs} +8 -6
- package/dist/{as-tuple-DKBOLriy.cjs → as-tuple-DkI9fp4G.cjs} +8 -6
- package/dist/as-tuple.cjs +1 -1
- package/dist/as-tuple.mjs +1 -1
- package/dist/{as-union-DT8XDZSt.cjs → as-union-BjmrvD80.cjs} +8 -6
- package/dist/{as-union-Gz8gEjmn.mjs → as-union-C3QiGYlE.mjs} +7 -5
- package/dist/as-union.cjs +1 -1
- package/dist/as-union.mjs +1 -1
- package/dist/{as-variant-picker-B3GLhKyt.mjs → as-variant-picker-BUF7Am9t.mjs} +13 -8
- package/dist/{as-variant-picker-JlEhh7YO.cjs → as-variant-picker-BcJx7Zt7.cjs} +14 -9
- package/dist/index.cjs +25 -25
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +24 -24
- package/dist/locale.cjs +5 -0
- package/dist/locale.d.cts +2 -0
- package/dist/locale.d.mts +2 -0
- package/dist/locale.mjs +2 -0
- package/dist/use-as-locale-1k9NBn-G.mjs +56 -0
- package/dist/use-as-locale-BVcC0l75.d.mts +35 -0
- package/dist/use-as-locale-C2tFUenv.cjs +73 -0
- package/dist/use-as-locale-CnGzoVWd.d.cts +35 -0
- package/dist/{use-as-value-help-CDmkz6A7.cjs → use-as-value-help-BE-fAZRP.cjs} +4 -2
- package/dist/{use-as-value-help-CYMlEubv.mjs → use-as-value-help-nIpEFMqD.mjs} +4 -2
- package/dist/{use-form-context-cDW2GW4-.mjs → use-form-context-C3FxL3eF.mjs} +4 -1
- package/dist/{use-form-context-B6ZnzfxG.cjs → use-form-context-CXsLnG7l.cjs} +4 -1
- package/dist/{use-as-dropdown-B2Shb7wn.mjs → variant-label-B065kts3.mjs} +13 -1
- package/dist/{use-as-dropdown-Bj9toVdw.cjs → variant-label-C-rLK7Z3.cjs} +18 -0
- package/package.json +14 -9
- package/dist/use-as-locale-BrFdAgnU.mjs +0 -23
- package/dist/use-as-locale-C4z5stwD.cjs +0 -34
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { _ as TYPES_KEY, a as CHANGE_HANDLER_KEY, c as ERRORS_KEY, d as FORM_PATCH_KEY, f as FORM_STATE_KEY, g as ROOT_DATA_KEY, h as PATH_PREFIX_KEY, i as ACTION_HANDLER_KEY, l as FORM_CONTEXT_KEY, m as LEVEL_KEY, o as COMPONENTS_KEY, p as HIDE_ROOT_TITLE_KEY, r as useFormContext, s as DISMISS_EXTERNAL_AT_KEY, u as FORM_DATA_KEY } from "./use-form-context-
|
|
2
|
-
import { n as useAsLocale } from "./use-as-locale-
|
|
1
|
+
import { _ as TYPES_KEY, a as CHANGE_HANDLER_KEY, c as ERRORS_KEY, d as FORM_PATCH_KEY, f as FORM_STATE_KEY, g as ROOT_DATA_KEY, h as PATH_PREFIX_KEY, i as ACTION_HANDLER_KEY, l as FORM_CONTEXT_KEY, m as LEVEL_KEY, o as COMPONENTS_KEY, p as HIDE_ROOT_TITLE_KEY, r as useFormContext, s as DISMISS_EXTERNAL_AT_KEY, u as FORM_DATA_KEY } from "./use-form-context-C3FxL3eF.mjs";
|
|
2
|
+
import { n as useAsLocale, r as useAsTexts } from "./use-as-locale-1k9NBn-G.mjs";
|
|
3
3
|
import { computed, createBlock, createElementBlock, defineComponent, inject, isRef, mergeProps, onUnmounted, openBlock, provide, ref, resolveDynamicComponent, toDisplayString, unref, useId, watch } from "vue";
|
|
4
|
-
import { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_UNIT, DB_UNIT_REF, EXPECT_MAX_LENGTH, META_DEFAULT, META_DESCRIPTION, META_LABEL, META_READONLY, META_REQUIRED, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_VALIDATE, WF_ACTION_WITH_DATA, buildGridClasses, createFieldValidator, createFormData, createFormValueResolver, getByPath, getCurrencyDecimals, getCurrencyDisplayParts, getFieldMeta, hasFieldMeta, isArrayField, isFieldHidden, isObjectField, isTupleField, isUnionField, joinPath, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, setByPath } from "@atscript/ui";
|
|
4
|
+
import { DB_AMOUNT_CURRENCY, DB_AMOUNT_CURRENCY_REF, DB_COLUMN_PRECISION, DB_UNIT, DB_UNIT_REF, EXPECT_MAX_LENGTH, META_DEFAULT, META_DESCRIPTION, META_LABEL, META_READONLY, META_REQUIRED, UI_FORM_ACTION, UI_FORM_ATTR, UI_FORM_AUTOCOMPLETE, UI_FORM_CLASSES, UI_FORM_COMPONENT, UI_FORM_DISABLED, UI_FORM_FN_CLASSES, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_DISABLED, UI_FORM_FN_HINT, UI_FORM_FN_LABEL, UI_FORM_FN_PLACEHOLDER, UI_FORM_FN_PREFIX, UI_FORM_FN_READONLY, UI_FORM_FN_STYLES, UI_FORM_FN_TITLE, UI_FORM_FN_VALUE, UI_FORM_GRID_COL_SPAN, UI_FORM_GRID_ROW_SPAN, UI_FORM_HIDDEN, UI_FORM_HINT, UI_FORM_LABEL_SINGULAR, UI_FORM_PLACEHOLDER, UI_FORM_PREFIX, UI_FORM_PREFIX_ICON, UI_FORM_PREFIX_REF, UI_FORM_STYLES, UI_FORM_SUFFIX, UI_FORM_SUFFIX_ICON, UI_FORM_SUFFIX_REF, UI_FORM_VALIDATE, WF_ACTION_WITH_DATA, buildGridClasses, createFieldValidator, createFormData, createFormValueResolver, getByPath, getCurrencyDecimals, getCurrencyDisplayParts, getFieldMeta, hasFieldMeta, isArrayField, isFieldHidden, isObjectField, isTupleField, isUnionField, joinPath, resolveAttrs, resolveFieldProp, resolveFormProp, resolveGridSpec, resolveOptions, resolveSingularLabel, setByPath } from "@atscript/ui";
|
|
5
5
|
import { buildFieldEntry } from "@atscript/ui-fns";
|
|
6
6
|
//#region src/composables/use-as-field.ts
|
|
7
7
|
function useAsField(opts) {
|
|
@@ -9,6 +9,7 @@ function useAsField(opts) {
|
|
|
9
9
|
const formData = inject(FORM_DATA_KEY);
|
|
10
10
|
const formContext = inject(FORM_CONTEXT_KEY);
|
|
11
11
|
const patch = inject(FORM_PATCH_KEY, void 0);
|
|
12
|
+
const { t } = useAsTexts();
|
|
12
13
|
const id = Symbol("form-field");
|
|
13
14
|
const submitError = ref();
|
|
14
15
|
const externalError = ref();
|
|
@@ -39,7 +40,7 @@ function useAsField(opts) {
|
|
|
39
40
|
function validate() {
|
|
40
41
|
if (opts.rules?.length) for (const rule of opts.rules) {
|
|
41
42
|
const result = rule(model.value, formData?.value, formContext?.value);
|
|
42
|
-
if (result !== true) return result || "
|
|
43
|
+
if (result !== true) return result || t("UI_FORM_WRONG_VALUE");
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
const error = computed(() => {
|
|
@@ -248,6 +249,7 @@ var as_field_default = /* @__PURE__ */ defineComponent({
|
|
|
248
249
|
const handleAction = inject(ACTION_HANDLER_KEY, () => {});
|
|
249
250
|
const handleChange = inject(CHANGE_HANDLER_KEY, () => {});
|
|
250
251
|
const dismissExternalAt = inject(DISMISS_EXTERNAL_AT_KEY, () => {});
|
|
252
|
+
const { t } = useAsTexts();
|
|
251
253
|
const { rootFormData, formContext, joinPath, buildPath, getByPath, setByPath, buildScope } = useFormContext("AsField");
|
|
252
254
|
const absolutePath = joinPath(() => props.field.path);
|
|
253
255
|
const isStructured = isObjectField(props.field) || isArrayField(props.field) || isTupleField(props.field);
|
|
@@ -340,10 +342,7 @@ var as_field_default = /* @__PURE__ */ defineComponent({
|
|
|
340
342
|
});
|
|
341
343
|
}
|
|
342
344
|
let singularLabel;
|
|
343
|
-
if (isArrayField(props.field))
|
|
344
|
-
const fromArray = resolveSingularLabel(prop);
|
|
345
|
-
singularLabel = fromArray !== "item" ? fromArray : resolveSingularLabel(props.field.itemField.prop);
|
|
346
|
-
}
|
|
345
|
+
if (isArrayField(props.field)) singularLabel = getFieldMeta(prop, UI_FORM_LABEL_SINGULAR) || resolveSingularLabel(props.field.itemField.prop, t);
|
|
347
346
|
const inputId = `as-field-${useId()}`;
|
|
348
347
|
const errorId = `${inputId}-err`;
|
|
349
348
|
const descId = `${inputId}-desc`;
|
|
@@ -358,7 +357,10 @@ var as_field_default = /* @__PURE__ */ defineComponent({
|
|
|
358
357
|
label: getFieldMeta(prop, META_LABEL) ?? props.field.name
|
|
359
358
|
} : void 0;
|
|
360
359
|
const gridClasses = buildGridClasses(resolveGridSpec(getFieldMeta(prop, UI_FORM_GRID_COL_SPAN), getFieldMeta(prop, UI_FORM_GRID_ROW_SPAN)));
|
|
361
|
-
const formValidate = createFieldValidator(prop,
|
|
360
|
+
const formValidate = createFieldValidator(prop, {
|
|
361
|
+
rootOnly: isStructured || isUnion,
|
|
362
|
+
t
|
|
363
|
+
});
|
|
362
364
|
function getModel() {
|
|
363
365
|
return getByPath(absolutePath.value);
|
|
364
366
|
}
|
|
@@ -401,9 +403,9 @@ var as_field_default = /* @__PURE__ */ defineComponent({
|
|
|
401
403
|
label = getFieldMeta(prop, META_LABEL) ?? props.field.name;
|
|
402
404
|
description = getFieldMeta(prop, META_DESCRIPTION);
|
|
403
405
|
hint = getFieldMeta(prop, UI_FORM_HINT);
|
|
404
|
-
placeholder = getFieldMeta(prop, UI_FORM_PLACEHOLDER) ?? (prop.metadata.has("db.writeOnly") ? "
|
|
406
|
+
placeholder = getFieldMeta(prop, UI_FORM_PLACEHOLDER) ?? (prop.metadata.has("db.writeOnly") ? t("UI_FORM_HIDDEN_PLACEHOLDER") : void 0);
|
|
405
407
|
styles = getFieldMeta(prop, UI_FORM_STYLES);
|
|
406
|
-
options = resolveOptions(prop, emptyScope);
|
|
408
|
+
options = resolveOptions(prop, emptyScope, props.field.labelsFrom, t);
|
|
407
409
|
attrs = getFieldMeta(prop, UI_FORM_ATTR) !== void 0 ? resolveAttrs(prop, emptyScope) : void 0;
|
|
408
410
|
title = isStructured || isUnion ? getFieldMeta(prop, META_LABEL) ?? props.field.name : void 0;
|
|
409
411
|
classesBase = buildFieldClasses(getFieldMeta(prop, UI_FORM_CLASSES), disabled, hasMetaRequired, optional);
|
|
@@ -440,7 +442,7 @@ var as_field_default = /* @__PURE__ */ defineComponent({
|
|
|
440
442
|
hint = maybeComputed(hasFn.has("hint"), () => resolveFieldProp(prop, UI_FORM_FN_HINT, UI_FORM_HINT, fs.value), getFieldMeta(prop, UI_FORM_HINT));
|
|
441
443
|
placeholder = maybeComputed(hasFn.has("placeholder"), () => resolveFieldProp(prop, UI_FORM_FN_PLACEHOLDER, UI_FORM_PLACEHOLDER, fs.value), getFieldMeta(prop, UI_FORM_PLACEHOLDER));
|
|
442
444
|
styles = maybeComputed(hasFn.has("styles"), () => resolveFieldProp(prop, UI_FORM_FN_STYLES, UI_FORM_STYLES, fs.value), getFieldMeta(prop, UI_FORM_STYLES));
|
|
443
|
-
options =
|
|
445
|
+
options = hasFn.has("options") ? computed(() => resolveOptions(prop, fs.value, props.field.labelsFrom, t)) : resolveOptions(prop, emptyScope, props.field.labelsFrom, t);
|
|
444
446
|
attrs = hasFn.has("attr") ? computed(() => resolveAttrs(prop, fs.value)) : getFieldMeta(prop, UI_FORM_ATTR) !== void 0 ? resolveAttrs(prop, emptyScope) : void 0;
|
|
445
447
|
title = isStructured || isUnion ? maybeComputed(hasFn.has("title"), () => resolveHeaderProp(UI_FORM_FN_TITLE, META_LABEL) ?? props.field.name, getFieldMeta(prop, META_LABEL) ?? props.field.name) : void 0;
|
|
446
448
|
const hasFnClasses = hasFn.has("classes");
|
|
@@ -455,7 +457,8 @@ var as_field_default = /* @__PURE__ */ defineComponent({
|
|
|
455
457
|
function formRule(v) {
|
|
456
458
|
return formValidate(v, {
|
|
457
459
|
data: rootFormData().value ?? {},
|
|
458
|
-
context: formContext.value
|
|
460
|
+
context: formContext.value,
|
|
461
|
+
t
|
|
459
462
|
});
|
|
460
463
|
}
|
|
461
464
|
const { model, error: formError, onBlur: _onBlur, isDirty } = useAsField({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_use_form_context = require("./use-form-context-
|
|
2
|
-
const require_use_as_locale = require("./use-as-locale-
|
|
1
|
+
const require_use_form_context = require("./use-form-context-CXsLnG7l.cjs");
|
|
2
|
+
const require_use_as_locale = require("./use-as-locale-C2tFUenv.cjs");
|
|
3
3
|
let vue = require("vue");
|
|
4
4
|
let _atscript_ui = require("@atscript/ui");
|
|
5
5
|
let _atscript_ui_fns = require("@atscript/ui-fns");
|
|
@@ -9,6 +9,7 @@ function useAsField(opts) {
|
|
|
9
9
|
const formData = (0, vue.inject)(require_use_form_context.FORM_DATA_KEY);
|
|
10
10
|
const formContext = (0, vue.inject)(require_use_form_context.FORM_CONTEXT_KEY);
|
|
11
11
|
const patch = (0, vue.inject)(require_use_form_context.FORM_PATCH_KEY, void 0);
|
|
12
|
+
const { t } = require_use_as_locale.useAsTexts();
|
|
12
13
|
const id = Symbol("form-field");
|
|
13
14
|
const submitError = (0, vue.ref)();
|
|
14
15
|
const externalError = (0, vue.ref)();
|
|
@@ -39,7 +40,7 @@ function useAsField(opts) {
|
|
|
39
40
|
function validate() {
|
|
40
41
|
if (opts.rules?.length) for (const rule of opts.rules) {
|
|
41
42
|
const result = rule(model.value, formData?.value, formContext?.value);
|
|
42
|
-
if (result !== true) return result || "
|
|
43
|
+
if (result !== true) return result || t("UI_FORM_WRONG_VALUE");
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
const error = (0, vue.computed)(() => {
|
|
@@ -248,6 +249,7 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
248
249
|
const handleAction = (0, vue.inject)(require_use_form_context.ACTION_HANDLER_KEY, () => {});
|
|
249
250
|
const handleChange = (0, vue.inject)(require_use_form_context.CHANGE_HANDLER_KEY, () => {});
|
|
250
251
|
const dismissExternalAt = (0, vue.inject)(require_use_form_context.DISMISS_EXTERNAL_AT_KEY, () => {});
|
|
252
|
+
const { t } = require_use_as_locale.useAsTexts();
|
|
251
253
|
const { rootFormData, formContext, joinPath, buildPath, getByPath, setByPath, buildScope } = require_use_form_context.useFormContext("AsField");
|
|
252
254
|
const absolutePath = joinPath(() => props.field.path);
|
|
253
255
|
const isStructured = (0, _atscript_ui.isObjectField)(props.field) || (0, _atscript_ui.isArrayField)(props.field) || (0, _atscript_ui.isTupleField)(props.field);
|
|
@@ -340,10 +342,7 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
340
342
|
});
|
|
341
343
|
}
|
|
342
344
|
let singularLabel;
|
|
343
|
-
if ((0, _atscript_ui.isArrayField)(props.field))
|
|
344
|
-
const fromArray = (0, _atscript_ui.resolveSingularLabel)(prop);
|
|
345
|
-
singularLabel = fromArray !== "item" ? fromArray : (0, _atscript_ui.resolveSingularLabel)(props.field.itemField.prop);
|
|
346
|
-
}
|
|
345
|
+
if ((0, _atscript_ui.isArrayField)(props.field)) singularLabel = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_LABEL_SINGULAR) || (0, _atscript_ui.resolveSingularLabel)(props.field.itemField.prop, t);
|
|
347
346
|
const inputId = `as-field-${(0, vue.useId)()}`;
|
|
348
347
|
const errorId = `${inputId}-err`;
|
|
349
348
|
const descId = `${inputId}-desc`;
|
|
@@ -358,7 +357,10 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
358
357
|
label: (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.META_LABEL) ?? props.field.name
|
|
359
358
|
} : void 0;
|
|
360
359
|
const gridClasses = (0, _atscript_ui.buildGridClasses)((0, _atscript_ui.resolveGridSpec)((0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_GRID_COL_SPAN), (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_GRID_ROW_SPAN)));
|
|
361
|
-
const formValidate = (0, _atscript_ui.createFieldValidator)(prop,
|
|
360
|
+
const formValidate = (0, _atscript_ui.createFieldValidator)(prop, {
|
|
361
|
+
rootOnly: isStructured || isUnion,
|
|
362
|
+
t
|
|
363
|
+
});
|
|
362
364
|
function getModel() {
|
|
363
365
|
return getByPath(absolutePath.value);
|
|
364
366
|
}
|
|
@@ -401,9 +403,9 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
401
403
|
label = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.META_LABEL) ?? props.field.name;
|
|
402
404
|
description = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.META_DESCRIPTION);
|
|
403
405
|
hint = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_HINT);
|
|
404
|
-
placeholder = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_PLACEHOLDER) ?? (prop.metadata.has("db.writeOnly") ? "
|
|
406
|
+
placeholder = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_PLACEHOLDER) ?? (prop.metadata.has("db.writeOnly") ? t("UI_FORM_HIDDEN_PLACEHOLDER") : void 0);
|
|
405
407
|
styles = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_STYLES);
|
|
406
|
-
options = (0, _atscript_ui.resolveOptions)(prop, emptyScope);
|
|
408
|
+
options = (0, _atscript_ui.resolveOptions)(prop, emptyScope, props.field.labelsFrom, t);
|
|
407
409
|
attrs = (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_ATTR) !== void 0 ? (0, _atscript_ui.resolveAttrs)(prop, emptyScope) : void 0;
|
|
408
410
|
title = isStructured || isUnion ? (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.META_LABEL) ?? props.field.name : void 0;
|
|
409
411
|
classesBase = buildFieldClasses((0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_CLASSES), disabled, hasMetaRequired, optional);
|
|
@@ -440,7 +442,7 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
440
442
|
hint = maybeComputed(hasFn.has("hint"), () => (0, _atscript_ui.resolveFieldProp)(prop, _atscript_ui.UI_FORM_FN_HINT, _atscript_ui.UI_FORM_HINT, fs.value), (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_HINT));
|
|
441
443
|
placeholder = maybeComputed(hasFn.has("placeholder"), () => (0, _atscript_ui.resolveFieldProp)(prop, _atscript_ui.UI_FORM_FN_PLACEHOLDER, _atscript_ui.UI_FORM_PLACEHOLDER, fs.value), (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_PLACEHOLDER));
|
|
442
444
|
styles = maybeComputed(hasFn.has("styles"), () => (0, _atscript_ui.resolveFieldProp)(prop, _atscript_ui.UI_FORM_FN_STYLES, _atscript_ui.UI_FORM_STYLES, fs.value), (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_STYLES));
|
|
443
|
-
options =
|
|
445
|
+
options = hasFn.has("options") ? (0, vue.computed)(() => (0, _atscript_ui.resolveOptions)(prop, fs.value, props.field.labelsFrom, t)) : (0, _atscript_ui.resolveOptions)(prop, emptyScope, props.field.labelsFrom, t);
|
|
444
446
|
attrs = hasFn.has("attr") ? (0, vue.computed)(() => (0, _atscript_ui.resolveAttrs)(prop, fs.value)) : (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.UI_FORM_ATTR) !== void 0 ? (0, _atscript_ui.resolveAttrs)(prop, emptyScope) : void 0;
|
|
445
447
|
title = isStructured || isUnion ? maybeComputed(hasFn.has("title"), () => resolveHeaderProp(_atscript_ui.UI_FORM_FN_TITLE, _atscript_ui.META_LABEL) ?? props.field.name, (0, _atscript_ui.getFieldMeta)(prop, _atscript_ui.META_LABEL) ?? props.field.name) : void 0;
|
|
446
448
|
const hasFnClasses = hasFn.has("classes");
|
|
@@ -455,7 +457,8 @@ var as_field_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
455
457
|
function formRule(v) {
|
|
456
458
|
return formValidate(v, {
|
|
457
459
|
data: rootFormData().value ?? {},
|
|
458
|
-
context: formContext.value
|
|
460
|
+
context: formContext.value,
|
|
461
|
+
t
|
|
459
462
|
});
|
|
460
463
|
}
|
|
461
464
|
const { model, error: formError, onBlur: _onBlur, isDirty } = useAsField({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { n as useAsUnionVariant, t as formatIndexedLabelParts } from "./use-form-context-
|
|
1
|
+
import { n as useAsUnionVariant, t as formatIndexedLabelParts } from "./use-form-context-C3FxL3eF.mjs";
|
|
2
|
+
import { r as useAsTexts } from "./use-as-locale-1k9NBn-G.mjs";
|
|
2
3
|
import { r as useAsFocusFirstAfter } from "./focus-after-toggle-Dtl3P6CS.mjs";
|
|
3
|
-
import { n as as_optional_clear_default, t as as_variant_picker_default } from "./as-variant-picker-
|
|
4
|
+
import { n as as_optional_clear_default, t as as_variant_picker_default } from "./as-variant-picker-BUF7Am9t.mjs";
|
|
4
5
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, ref, renderSlot, toDisplayString, unref, vShow, withDirectives, withKeys, withModifiers } from "vue";
|
|
5
6
|
//#region src/components/internal/as-no-data.vue?vue&type=script&setup=true&lang.ts
|
|
6
7
|
const _hoisted_1$1 = {
|
|
@@ -25,6 +26,7 @@ var as_no_data_default = /* @__PURE__ */ defineComponent({
|
|
|
25
26
|
},
|
|
26
27
|
setup(__props) {
|
|
27
28
|
const props = __props;
|
|
29
|
+
const { t } = useAsTexts();
|
|
28
30
|
const hovered = ref(false);
|
|
29
31
|
const rootClass = computed(() => props.kind === "textarea" ? "as-no-data-textarea" : "as-no-data");
|
|
30
32
|
return (_ctx, _cache) => {
|
|
@@ -36,7 +38,7 @@ var as_no_data_default = /* @__PURE__ */ defineComponent({
|
|
|
36
38
|
role: "button",
|
|
37
39
|
tabindex: "0",
|
|
38
40
|
onKeydown: [_cache[3] || (_cache[3] = withKeys((...args) => __props.onEdit && __props.onEdit(...args), ["enter"])), _cache[4] || (_cache[4] = withKeys(withModifiers((...args) => __props.onEdit && __props.onEdit(...args), ["prevent"]), ["space"]))]
|
|
39
|
-
}, [createElementVNode("span", _hoisted_1$1, [createElementVNode("span", { class: normalizeClass(hovered.value ? "i-as-field-fill" : "i-as-field-empty") }, null, 2)]), createElementVNode("span", _hoisted_2$1, toDisplayString(hovered.value ? "
|
|
41
|
+
}, [createElementVNode("span", _hoisted_1$1, [createElementVNode("span", { class: normalizeClass(hovered.value ? "i-as-field-fill" : "i-as-field-empty") }, null, 2)]), createElementVNode("span", _hoisted_2$1, toDisplayString(unref(t)(hovered.value ? "UI_FORM_CLICK_TO_EDIT" : "UI_FORM_NOT_SET")), 1)], 34);
|
|
40
42
|
};
|
|
41
43
|
}
|
|
42
44
|
});
|
|
@@ -57,7 +59,11 @@ const _hoisted_6 = {
|
|
|
57
59
|
key: 0,
|
|
58
60
|
class: "as-field-header-actions"
|
|
59
61
|
};
|
|
60
|
-
const _hoisted_7 = [
|
|
62
|
+
const _hoisted_7 = [
|
|
63
|
+
"disabled",
|
|
64
|
+
"aria-label",
|
|
65
|
+
"title"
|
|
66
|
+
];
|
|
61
67
|
const _hoisted_8 = ["id"];
|
|
62
68
|
const _hoisted_9 = { class: "as-field-input-row" };
|
|
63
69
|
const _hoisted_10 = {
|
|
@@ -293,6 +299,7 @@ var as_field_shell_default = /* @__PURE__ */ defineComponent({
|
|
|
293
299
|
const showOptionalClear = computed(() => !!props.optional && optionalEnabled.value && !props.chromeless);
|
|
294
300
|
const statusId = computed(() => props.statusId || `${props.inputId}-status`);
|
|
295
301
|
const showEmptyPlaceholder = computed(() => !!props.optional && !optionalEnabled.value && !props.chromeless && !props.hideEmptyPlaceholder);
|
|
302
|
+
const { t } = useAsTexts();
|
|
296
303
|
return (_ctx, _cache) => {
|
|
297
304
|
return withDirectives((openBlock(), createElementBlock("div", {
|
|
298
305
|
ref_key: "rootRef",
|
|
@@ -329,8 +336,8 @@ var as_field_shell_default = /* @__PURE__ */ defineComponent({
|
|
|
329
336
|
type: "button",
|
|
330
337
|
class: "as-field-remove-btn",
|
|
331
338
|
disabled: !__props.canRemove,
|
|
332
|
-
"aria-label": "
|
|
333
|
-
title: "
|
|
339
|
+
"aria-label": unref(t)("UI_REMOVE"),
|
|
340
|
+
title: unref(t)("UI_REMOVE"),
|
|
334
341
|
onClick: _cache[1] || (_cache[1] = (...args) => __props.onRemove && __props.onRemove(...args))
|
|
335
342
|
}, [..._cache[3] || (_cache[3] = [createElementVNode("span", {
|
|
336
343
|
class: "as-field-remove-btn-icon",
|
|
@@ -372,7 +379,7 @@ var as_field_shell_default = /* @__PURE__ */ defineComponent({
|
|
|
372
379
|
key: 2,
|
|
373
380
|
id: statusId.value,
|
|
374
381
|
class: "as-field-status"
|
|
375
|
-
}, "
|
|
382
|
+
}, toDisplayString(unref(t)("UI_FORM_MODIFIED")), 9, _hoisted_13)) : createCommentVNode("v-if", true)
|
|
376
383
|
]),
|
|
377
384
|
__props.formAction ? (openBlock(), createElementBlock("button", {
|
|
378
385
|
key: 0,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
const require_use_form_context = require("./use-form-context-
|
|
1
|
+
const require_use_form_context = require("./use-form-context-CXsLnG7l.cjs");
|
|
2
|
+
const require_use_as_locale = require("./use-as-locale-C2tFUenv.cjs");
|
|
2
3
|
const require_focus_after_toggle = require("./focus-after-toggle-CWxiPZWi.cjs");
|
|
3
|
-
const require_as_variant_picker = require("./as-variant-picker-
|
|
4
|
+
const require_as_variant_picker = require("./as-variant-picker-BcJx7Zt7.cjs");
|
|
4
5
|
let vue = require("vue");
|
|
5
6
|
//#region src/components/internal/as-no-data.vue?vue&type=script&setup=true&lang.ts
|
|
6
7
|
const _hoisted_1$1 = {
|
|
@@ -25,6 +26,7 @@ var as_no_data_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
25
26
|
},
|
|
26
27
|
setup(__props) {
|
|
27
28
|
const props = __props;
|
|
29
|
+
const { t } = require_use_as_locale.useAsTexts();
|
|
28
30
|
const hovered = (0, vue.ref)(false);
|
|
29
31
|
const rootClass = (0, vue.computed)(() => props.kind === "textarea" ? "as-no-data-textarea" : "as-no-data");
|
|
30
32
|
return (_ctx, _cache) => {
|
|
@@ -36,7 +38,7 @@ var as_no_data_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
36
38
|
role: "button",
|
|
37
39
|
tabindex: "0",
|
|
38
40
|
onKeydown: [_cache[3] || (_cache[3] = (0, vue.withKeys)((...args) => __props.onEdit && __props.onEdit(...args), ["enter"])), _cache[4] || (_cache[4] = (0, vue.withKeys)((0, vue.withModifiers)((...args) => __props.onEdit && __props.onEdit(...args), ["prevent"]), ["space"]))]
|
|
39
|
-
}, [(0, vue.createElementVNode)("span", _hoisted_1$1, [(0, vue.createElementVNode)("span", { class: (0, vue.normalizeClass)(hovered.value ? "i-as-field-fill" : "i-as-field-empty") }, null, 2)]), (0, vue.createElementVNode)("span", _hoisted_2$1, (0, vue.toDisplayString)(hovered.value ? "
|
|
41
|
+
}, [(0, vue.createElementVNode)("span", _hoisted_1$1, [(0, vue.createElementVNode)("span", { class: (0, vue.normalizeClass)(hovered.value ? "i-as-field-fill" : "i-as-field-empty") }, null, 2)]), (0, vue.createElementVNode)("span", _hoisted_2$1, (0, vue.toDisplayString)((0, vue.unref)(t)(hovered.value ? "UI_FORM_CLICK_TO_EDIT" : "UI_FORM_NOT_SET")), 1)], 34);
|
|
40
42
|
};
|
|
41
43
|
}
|
|
42
44
|
});
|
|
@@ -57,7 +59,11 @@ const _hoisted_6 = {
|
|
|
57
59
|
key: 0,
|
|
58
60
|
class: "as-field-header-actions"
|
|
59
61
|
};
|
|
60
|
-
const _hoisted_7 = [
|
|
62
|
+
const _hoisted_7 = [
|
|
63
|
+
"disabled",
|
|
64
|
+
"aria-label",
|
|
65
|
+
"title"
|
|
66
|
+
];
|
|
61
67
|
const _hoisted_8 = ["id"];
|
|
62
68
|
const _hoisted_9 = { class: "as-field-input-row" };
|
|
63
69
|
const _hoisted_10 = {
|
|
@@ -293,6 +299,7 @@ var as_field_shell_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
293
299
|
const showOptionalClear = (0, vue.computed)(() => !!props.optional && optionalEnabled.value && !props.chromeless);
|
|
294
300
|
const statusId = (0, vue.computed)(() => props.statusId || `${props.inputId}-status`);
|
|
295
301
|
const showEmptyPlaceholder = (0, vue.computed)(() => !!props.optional && !optionalEnabled.value && !props.chromeless && !props.hideEmptyPlaceholder);
|
|
302
|
+
const { t } = require_use_as_locale.useAsTexts();
|
|
296
303
|
return (_ctx, _cache) => {
|
|
297
304
|
return (0, vue.withDirectives)(((0, vue.openBlock)(), (0, vue.createElementBlock)("div", {
|
|
298
305
|
ref_key: "rootRef",
|
|
@@ -329,8 +336,8 @@ var as_field_shell_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
329
336
|
type: "button",
|
|
330
337
|
class: "as-field-remove-btn",
|
|
331
338
|
disabled: !__props.canRemove,
|
|
332
|
-
"aria-label": "
|
|
333
|
-
title: "
|
|
339
|
+
"aria-label": (0, vue.unref)(t)("UI_REMOVE"),
|
|
340
|
+
title: (0, vue.unref)(t)("UI_REMOVE"),
|
|
334
341
|
onClick: _cache[1] || (_cache[1] = (...args) => __props.onRemove && __props.onRemove(...args))
|
|
335
342
|
}, [..._cache[3] || (_cache[3] = [(0, vue.createElementVNode)("span", {
|
|
336
343
|
class: "as-field-remove-btn-icon",
|
|
@@ -372,7 +379,7 @@ var as_field_shell_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
372
379
|
key: 2,
|
|
373
380
|
id: statusId.value,
|
|
374
381
|
class: "as-field-status"
|
|
375
|
-
}, "
|
|
382
|
+
}, (0, vue.toDisplayString)((0, vue.unref)(t)("UI_FORM_MODIFIED")), 9, _hoisted_13)) : (0, vue.createCommentVNode)("v-if", true)
|
|
376
383
|
]),
|
|
377
384
|
__props.formAction ? ((0, vue.openBlock)(), (0, vue.createElementBlock)("button", {
|
|
378
385
|
key: 0,
|
package/dist/as-field-shell.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const require_as_field_shell = require("./as-field-shell-
|
|
1
|
+
const require_as_field_shell = require("./as-field-shell-DSj3CqN6.cjs");
|
|
2
2
|
module.exports = require_as_field_shell.as_field_shell_default;
|
package/dist/as-field-shell.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as as_field_shell_default } from "./as-field-shell-
|
|
1
|
+
import { t as as_field_shell_default } from "./as-field-shell-D7XovzgJ.mjs";
|
|
2
2
|
export { as_field_shell_default as default };
|
package/dist/as-field.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const require_as_field = require("./as-field-
|
|
1
|
+
const require_as_field = require("./as-field-D0HgywQY.cjs");
|
|
2
2
|
module.exports = require_as_field.as_field_default;
|
package/dist/as-field.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as as_field_default } from "./as-field-
|
|
1
|
+
import { t as as_field_default } from "./as-field-BZpWLPcM.mjs";
|
|
2
2
|
export { as_field_default as default };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { _ as TYPES_KEY, a as CHANGE_HANDLER_KEY, c as ERRORS_KEY, d as FORM_PATCH_KEY, f as FORM_STATE_KEY, g as ROOT_DATA_KEY, h as PATH_PREFIX_KEY, i as ACTION_HANDLER_KEY, l as FORM_CONTEXT_KEY, o as COMPONENTS_KEY, p as HIDE_ROOT_TITLE_KEY, s as DISMISS_EXTERNAL_AT_KEY, u as FORM_DATA_KEY } from "./use-form-context-
|
|
1
|
+
import { _ as TYPES_KEY, a as CHANGE_HANDLER_KEY, c as ERRORS_KEY, d as FORM_PATCH_KEY, f as FORM_STATE_KEY, g as ROOT_DATA_KEY, h as PATH_PREFIX_KEY, i as ACTION_HANDLER_KEY, l as FORM_CONTEXT_KEY, o as COMPONENTS_KEY, p as HIDE_ROOT_TITLE_KEY, s as DISMISS_EXTERNAL_AT_KEY, u as FORM_DATA_KEY } from "./use-form-context-C3FxL3eF.mjs";
|
|
2
2
|
import { i as useAsNestedSectionsStore, n as provideAsNestedSectionsStore, t as DESCENDANT_ERROR_COUNTS_KEY } from "./use-as-nested-sections-store-Dfo971PK.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import { t as
|
|
3
|
+
import { r as useAsTexts } from "./use-as-locale-1k9NBn-G.mjs";
|
|
4
|
+
import { t as CLIENT_FACTORY_KEY } from "./use-as-value-help-nIpEFMqD.mjs";
|
|
5
|
+
import { t as as_field_default } from "./as-field-BZpWLPcM.mjs";
|
|
6
|
+
import { t as as_iterator_default } from "./as-iterator-Dp1OiwU7.mjs";
|
|
6
7
|
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, guardReactiveProps, inject, isProxy, isRef, mergeProps, nextTick, normalizeProps, openBlock, provide, reactive, ref, renderSlot, shallowRef, toDisplayString, toRaw, toValue, unref, watch, watchEffect, withModifiers } from "vue";
|
|
7
8
|
import { FORM_ERROR_KEY, META_DESCRIPTION, META_LABEL, UI_FORM_FN_DESCRIPTION, UI_FORM_FN_SUBMIT_DISABLED, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_FN_TITLE, UI_FORM_SUBMIT_TEXT, buildDescendantErrorCounts, buildFormDiff, buildFormRebase, collectDirtyPaths, deepClone, getByPath, getDeclaredFormActions, getFormValidator, iteratePathAncestors, mergeErrorMaps, omitPaths, omitSkippedNavFields, resolveFormProp, setByPath, unionVariantChanged } from "@atscript/ui";
|
|
8
9
|
//#region src/composables/use-as-form-patch.ts
|
|
@@ -391,6 +392,7 @@ const EMPTY_IS_DIRTY_PATH = () => false;
|
|
|
391
392
|
* `provide()` calls that need an active component instance).
|
|
392
393
|
*/
|
|
393
394
|
function useAsForm(options) {
|
|
395
|
+
const { t } = useAsTexts();
|
|
394
396
|
const _data = ref({});
|
|
395
397
|
const data = computed(() => {
|
|
396
398
|
return options.formData?.() ?? _data.value;
|
|
@@ -406,13 +408,15 @@ function useAsForm(options) {
|
|
|
406
408
|
const domainData = () => toRaw(getDomainData());
|
|
407
409
|
const formContext = computed(() => options.formContext?.());
|
|
408
410
|
const formValidator = computed(() => getFormValidator(options.def(), { errorLimit: Number.MAX_SAFE_INTEGER }));
|
|
411
|
+
let submitting = {};
|
|
409
412
|
const { clearErrors: clearFieldErrors, reset: resetState, submit, setErrors, liveErrors, registeredPaths } = useAsState({
|
|
410
413
|
formData: data,
|
|
411
414
|
formContext,
|
|
412
415
|
firstValidation: computed(() => options.firstValidation?.()),
|
|
413
416
|
submitValidator: () => formValidator.value({
|
|
414
|
-
data:
|
|
415
|
-
context: formContext.value ?? {}
|
|
417
|
+
data: submitting,
|
|
418
|
+
context: formContext.value ?? {},
|
|
419
|
+
t
|
|
416
420
|
})
|
|
417
421
|
});
|
|
418
422
|
const remountKey = ref(0);
|
|
@@ -462,9 +466,10 @@ function useAsForm(options) {
|
|
|
462
466
|
v: void 0,
|
|
463
467
|
data: getDomainData(),
|
|
464
468
|
context: formContext.value ?? {},
|
|
465
|
-
entry: void 0
|
|
469
|
+
entry: void 0,
|
|
470
|
+
t
|
|
466
471
|
}));
|
|
467
|
-
const submitText = computed(() => resolveFormProp(options.def().type, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_SUBMIT_TEXT, ctx.value) ?? "
|
|
472
|
+
const submitText = computed(() => resolveFormProp(options.def().type, UI_FORM_FN_SUBMIT_TEXT, UI_FORM_SUBMIT_TEXT, ctx.value) ?? t("UI_FORM_SUBMIT"));
|
|
468
473
|
const submitDisabled = computed(() => options.loading?.() === true || (resolveFormProp(options.def().type, UI_FORM_FN_SUBMIT_DISABLED, void 0, ctx.value) ?? false));
|
|
469
474
|
const resolveRootProp = (fnKey, staticKey) => resolveFormProp(options.def().type, fnKey, staticKey, ctx.value);
|
|
470
475
|
const title = computed(() => resolveRootProp(UI_FORM_FN_TITLE, META_LABEL));
|
|
@@ -512,10 +517,12 @@ function useAsForm(options) {
|
|
|
512
517
|
provide(CHANGE_HANDLER_KEY, handleChange);
|
|
513
518
|
function onSubmit() {
|
|
514
519
|
rootErrorDismissed.value = false;
|
|
520
|
+
const data = formValidator.value.normalize(domainData());
|
|
521
|
+
submitting = data;
|
|
515
522
|
const result = submit();
|
|
516
523
|
if (result === true) {
|
|
517
524
|
internalErrors.value = {};
|
|
518
|
-
options.emits?.submit?.(omitSkippedNavFields(options.def(),
|
|
525
|
+
options.emits?.submit?.(omitSkippedNavFields(options.def(), data));
|
|
519
526
|
} else {
|
|
520
527
|
const errs = {};
|
|
521
528
|
for (const e of result) errs[e.path] = e.message;
|
|
@@ -667,6 +674,7 @@ var as_form_default = /* @__PURE__ */ defineComponent({
|
|
|
667
674
|
reapplied: []
|
|
668
675
|
})
|
|
669
676
|
});
|
|
677
|
+
const { t } = useAsTexts();
|
|
670
678
|
return (_ctx, _cache) => {
|
|
671
679
|
return openBlock(), createElementBlock("form", {
|
|
672
680
|
class: "as-form",
|
|
@@ -687,7 +695,7 @@ var as_form_default = /* @__PURE__ */ defineComponent({
|
|
|
687
695
|
type: "button",
|
|
688
696
|
class: "as-form-error-dismiss",
|
|
689
697
|
onClick: _cache[0] || (_cache[0] = (...args) => unref(form).dismissFormError && unref(form).dismissFormError(...args))
|
|
690
|
-
}, "
|
|
698
|
+
}, toDisplayString(unref(t)("UI_FORM_DISMISS")), 1)])]) : createCommentVNode("v-if", true),
|
|
691
699
|
!__props.hideSubmit ? renderSlot(_ctx.$slots, "form.submit", mergeProps({ key: 1 }, unref(form).slotProps.value, { text: unref(form).submitText.value }), () => [createElementVNode("button", {
|
|
692
700
|
type: "submit",
|
|
693
701
|
class: "as-submit-btn",
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
const require_use_form_context = require("./use-form-context-
|
|
1
|
+
const require_use_form_context = require("./use-form-context-CXsLnG7l.cjs");
|
|
2
2
|
const require_use_as_nested_sections_store = require("./use-as-nested-sections-store-u1VgBJAP.cjs");
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
const require_use_as_locale = require("./use-as-locale-C2tFUenv.cjs");
|
|
4
|
+
const require_use_as_value_help = require("./use-as-value-help-BE-fAZRP.cjs");
|
|
5
|
+
const require_as_field = require("./as-field-D0HgywQY.cjs");
|
|
6
|
+
const require_as_iterator = require("./as-iterator-Bty6f5Bq.cjs");
|
|
6
7
|
let vue = require("vue");
|
|
7
8
|
let _atscript_ui = require("@atscript/ui");
|
|
8
9
|
//#region src/composables/use-as-form-patch.ts
|
|
@@ -391,6 +392,7 @@ const EMPTY_IS_DIRTY_PATH = () => false;
|
|
|
391
392
|
* `provide()` calls that need an active component instance).
|
|
392
393
|
*/
|
|
393
394
|
function useAsForm(options) {
|
|
395
|
+
const { t } = require_use_as_locale.useAsTexts();
|
|
394
396
|
const _data = (0, vue.ref)({});
|
|
395
397
|
const data = (0, vue.computed)(() => {
|
|
396
398
|
return options.formData?.() ?? _data.value;
|
|
@@ -406,13 +408,15 @@ function useAsForm(options) {
|
|
|
406
408
|
const domainData = () => (0, vue.toRaw)(getDomainData());
|
|
407
409
|
const formContext = (0, vue.computed)(() => options.formContext?.());
|
|
408
410
|
const formValidator = (0, vue.computed)(() => (0, _atscript_ui.getFormValidator)(options.def(), { errorLimit: Number.MAX_SAFE_INTEGER }));
|
|
411
|
+
let submitting = {};
|
|
409
412
|
const { clearErrors: clearFieldErrors, reset: resetState, submit, setErrors, liveErrors, registeredPaths } = useAsState({
|
|
410
413
|
formData: data,
|
|
411
414
|
formContext,
|
|
412
415
|
firstValidation: (0, vue.computed)(() => options.firstValidation?.()),
|
|
413
416
|
submitValidator: () => formValidator.value({
|
|
414
|
-
data:
|
|
415
|
-
context: formContext.value ?? {}
|
|
417
|
+
data: submitting,
|
|
418
|
+
context: formContext.value ?? {},
|
|
419
|
+
t
|
|
416
420
|
})
|
|
417
421
|
});
|
|
418
422
|
const remountKey = (0, vue.ref)(0);
|
|
@@ -462,9 +466,10 @@ function useAsForm(options) {
|
|
|
462
466
|
v: void 0,
|
|
463
467
|
data: getDomainData(),
|
|
464
468
|
context: formContext.value ?? {},
|
|
465
|
-
entry: void 0
|
|
469
|
+
entry: void 0,
|
|
470
|
+
t
|
|
466
471
|
}));
|
|
467
|
-
const submitText = (0, vue.computed)(() => (0, _atscript_ui.resolveFormProp)(options.def().type, _atscript_ui.UI_FORM_FN_SUBMIT_TEXT, _atscript_ui.UI_FORM_SUBMIT_TEXT, ctx.value) ?? "
|
|
472
|
+
const submitText = (0, vue.computed)(() => (0, _atscript_ui.resolveFormProp)(options.def().type, _atscript_ui.UI_FORM_FN_SUBMIT_TEXT, _atscript_ui.UI_FORM_SUBMIT_TEXT, ctx.value) ?? t("UI_FORM_SUBMIT"));
|
|
468
473
|
const submitDisabled = (0, vue.computed)(() => options.loading?.() === true || ((0, _atscript_ui.resolveFormProp)(options.def().type, _atscript_ui.UI_FORM_FN_SUBMIT_DISABLED, void 0, ctx.value) ?? false));
|
|
469
474
|
const resolveRootProp = (fnKey, staticKey) => (0, _atscript_ui.resolveFormProp)(options.def().type, fnKey, staticKey, ctx.value);
|
|
470
475
|
const title = (0, vue.computed)(() => resolveRootProp(_atscript_ui.UI_FORM_FN_TITLE, _atscript_ui.META_LABEL));
|
|
@@ -512,10 +517,12 @@ function useAsForm(options) {
|
|
|
512
517
|
(0, vue.provide)(require_use_form_context.CHANGE_HANDLER_KEY, handleChange);
|
|
513
518
|
function onSubmit() {
|
|
514
519
|
rootErrorDismissed.value = false;
|
|
520
|
+
const data = formValidator.value.normalize(domainData());
|
|
521
|
+
submitting = data;
|
|
515
522
|
const result = submit();
|
|
516
523
|
if (result === true) {
|
|
517
524
|
internalErrors.value = {};
|
|
518
|
-
options.emits?.submit?.((0, _atscript_ui.omitSkippedNavFields)(options.def(),
|
|
525
|
+
options.emits?.submit?.((0, _atscript_ui.omitSkippedNavFields)(options.def(), data));
|
|
519
526
|
} else {
|
|
520
527
|
const errs = {};
|
|
521
528
|
for (const e of result) errs[e.path] = e.message;
|
|
@@ -667,6 +674,7 @@ var as_form_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
667
674
|
reapplied: []
|
|
668
675
|
})
|
|
669
676
|
});
|
|
677
|
+
const { t } = require_use_as_locale.useAsTexts();
|
|
670
678
|
return (_ctx, _cache) => {
|
|
671
679
|
return (0, vue.openBlock)(), (0, vue.createElementBlock)("form", {
|
|
672
680
|
class: "as-form",
|
|
@@ -687,7 +695,7 @@ var as_form_default = /* @__PURE__ */ (0, vue.defineComponent)({
|
|
|
687
695
|
type: "button",
|
|
688
696
|
class: "as-form-error-dismiss",
|
|
689
697
|
onClick: _cache[0] || (_cache[0] = (...args) => (0, vue.unref)(form).dismissFormError && (0, vue.unref)(form).dismissFormError(...args))
|
|
690
|
-
},
|
|
698
|
+
}, (0, vue.toDisplayString)((0, vue.unref)(t)("UI_FORM_DISMISS")), 1)])]) : (0, vue.createCommentVNode)("v-if", true),
|
|
691
699
|
!__props.hideSubmit ? (0, vue.renderSlot)(_ctx.$slots, "form.submit", (0, vue.mergeProps)({ key: 1 }, (0, vue.unref)(form).slotProps.value, { text: (0, vue.unref)(form).submitText.value }), () => [(0, vue.createElementVNode)("button", {
|
|
692
700
|
type: "submit",
|
|
693
701
|
class: "as-submit-btn",
|
package/dist/as-form.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const require_as_form = require("./as-form-
|
|
1
|
+
const require_as_form = require("./as-form-ChyW9bj2.cjs");
|
|
2
2
|
module.exports = require_as_form.as_form_default;
|
package/dist/as-form.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as _default, t as Props } from "./as-form.vue-
|
|
1
|
+
import { n as _default, t as Props } from "./as-form.vue-BuRFHSK-.cjs";
|
|
2
2
|
export { Props, _default as default };
|
package/dist/as-form.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as _default, t as Props } from "./as-form.vue-
|
|
1
|
+
import { n as _default, t as Props } from "./as-form.vue-CHEkgO3k.mjs";
|
|
2
2
|
export { Props, _default as default };
|
package/dist/as-form.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as as_form_default } from "./as-form-
|
|
1
|
+
import { t as as_form_default } from "./as-form-0VCxVsGo.mjs";
|
|
2
2
|
export { as_form_default as default };
|
|
@@ -352,7 +352,11 @@ interface UseAsFormReturn<TFormData = unknown, TFormContext = unknown> {
|
|
|
352
352
|
clearErrors: () => void;
|
|
353
353
|
/** Imperatively set external-error messages by path. */
|
|
354
354
|
setErrors: (errors: Record<string, string>) => void;
|
|
355
|
-
/**
|
|
355
|
+
/**
|
|
356
|
+
* Trigger submit. Applies the type's `@normalize.*` (trim, case) to the data,
|
|
357
|
+
* validates the result and emits it with `submit` on success, `error` on
|
|
358
|
+
* validation failure. The form data itself is left as typed.
|
|
359
|
+
*/
|
|
356
360
|
onSubmit: () => void;
|
|
357
361
|
/** Resolved submit-button text (`@ui.form.submit.text` / fn variant). */
|
|
358
362
|
submitText: ComputedRef<string>;
|
|
@@ -844,14 +848,6 @@ interface UseAsTriStateCheckboxReturn {
|
|
|
844
848
|
*/
|
|
845
849
|
declare function useAsTriStateCheckbox(options: UseAsTriStateCheckboxOptions): UseAsTriStateCheckboxReturn;
|
|
846
850
|
//#endregion
|
|
847
|
-
//#region src/composables/use-as-locale.d.ts
|
|
848
|
-
declare function provideAsLocale(getter: () => string | undefined): void;
|
|
849
|
-
interface UseAsLocaleReturn {
|
|
850
|
-
/** Resolved locale; `undefined` when no provider is present (runtime locale). */
|
|
851
|
-
locale: ComputedRef<string | undefined>;
|
|
852
|
-
}
|
|
853
|
-
declare function useAsLocale(): UseAsLocaleReturn;
|
|
854
|
-
//#endregion
|
|
855
851
|
//#region src/composables/use-as-decimal.d.ts
|
|
856
852
|
interface UseAsDecimalOptions {
|
|
857
853
|
/** Read the current value. Storage shape is preserved on commit. */
|
|
@@ -1385,4 +1381,4 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
|
|
|
1385
1381
|
declare const _default: typeof __VLS_export;
|
|
1386
1382
|
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
|
|
1387
1383
|
//#endregion
|
|
1388
|
-
export {
|
|
1384
|
+
export { useAsDescendantErrorCounts as $, useAsNumber as A, TFormFieldRegistration as At, focusFirstAfter as B, UseAsDateReturn as C, TFormSubmitValidator as Ct, useAsDualInput as D, UseAsFieldReturn as Dt, UseAsDualInputReturn as E, UseAsFieldOptions as Et, UseAsTriStateCheckboxReturn as F, useAsOptionalField as G, useAsFocusFirstAfter as H, useAsTriStateCheckbox as I, useAsFieldScope as J, TResolveFieldPropOptions as K, UseAsOptionalAddFlowOptions as L, UseAsDecimalReturn as M, TFormState as Mt, useAsDecimal as N, createDefaultTypes as Nt, UseAsNumberOptions as O, useAsField as Ot, UseAsTriStateCheckboxOptions as P, createAsFormDef as Pt, provideAsNestedSectionsStore as Q, UseAsOptionalAddFlowReturn as R, UseAsDateOptions as S, useAsFormPatch as St, UseAsDualInputOptions as T, useAsState as Tt, useAsVisibleFields as U, focusNewFocusableAfter as V, UseAsOptionalFieldReturn as W, useAsLevel as X, provideAsNestedLevel as Y, AsNestedSectionsStore as Z, useAsData as _, UseAsFormOptions as _t, FormFieldChange$1 as a, formatIndexedLabelParts as at, UseAsPathReturn as b, AsFormPatchHandle as bt, getDefaultClientFactory as c, useAsUnion as ct, joinPath as d, UseAsArrayReturn as dt, useAsNestedSectionsStore as et, resetDefaultClientFactory as f, useAsArray as ft, UseAsDataReturn as g, TAsFormValue as gt, useAsErrorDismiss as h, useAsExternalErrors as ht, FormDiffOptions$1 as i, useAsValueHelp as it, UseAsDecimalOptions as j, TFormRule as jt, UseAsNumberReturn as k, TFormFieldCallbacks as kt, hasFieldMeta as l, UseAsTupleReturn as lt, AsErrorDismiss as m, UseAsExternalErrorsReturn as mt, _default as n, UseAsValueHelpOptions as nt, FormRebaseOptions$1 as o, useAsUnionVariant as ot, setDefaultClientFactory as p, UseAsExternalErrorsOptions as pt, UseAsFieldScopeReturn as q, ClientFactory$1 as r, UseAsValueHelpReturn as rt, TypedClientFactory as s, UseAsUnionReturn as st, Props as t, useAsDropdown as tt, isFieldHidden as u, useAsTuple as ut, UseAsTypeMapReturn as v, UseAsFormReturn as vt, useAsDate as w, UseAsStateReturn as wt, useAsPath as x, RebaseOntoResult as xt, useAsTypeMap as y, useAsForm as yt, useAsOptionalAddFlow as z };
|
|
@@ -352,7 +352,11 @@ interface UseAsFormReturn<TFormData = unknown, TFormContext = unknown> {
|
|
|
352
352
|
clearErrors: () => void;
|
|
353
353
|
/** Imperatively set external-error messages by path. */
|
|
354
354
|
setErrors: (errors: Record<string, string>) => void;
|
|
355
|
-
/**
|
|
355
|
+
/**
|
|
356
|
+
* Trigger submit. Applies the type's `@normalize.*` (trim, case) to the data,
|
|
357
|
+
* validates the result and emits it with `submit` on success, `error` on
|
|
358
|
+
* validation failure. The form data itself is left as typed.
|
|
359
|
+
*/
|
|
356
360
|
onSubmit: () => void;
|
|
357
361
|
/** Resolved submit-button text (`@ui.form.submit.text` / fn variant). */
|
|
358
362
|
submitText: ComputedRef<string>;
|
|
@@ -844,14 +848,6 @@ interface UseAsTriStateCheckboxReturn {
|
|
|
844
848
|
*/
|
|
845
849
|
declare function useAsTriStateCheckbox(options: UseAsTriStateCheckboxOptions): UseAsTriStateCheckboxReturn;
|
|
846
850
|
//#endregion
|
|
847
|
-
//#region src/composables/use-as-locale.d.ts
|
|
848
|
-
declare function provideAsLocale(getter: () => string | undefined): void;
|
|
849
|
-
interface UseAsLocaleReturn {
|
|
850
|
-
/** Resolved locale; `undefined` when no provider is present (runtime locale). */
|
|
851
|
-
locale: ComputedRef<string | undefined>;
|
|
852
|
-
}
|
|
853
|
-
declare function useAsLocale(): UseAsLocaleReturn;
|
|
854
|
-
//#endregion
|
|
855
851
|
//#region src/composables/use-as-decimal.d.ts
|
|
856
852
|
interface UseAsDecimalOptions {
|
|
857
853
|
/** Read the current value. Storage shape is preserved on commit. */
|
|
@@ -1385,4 +1381,4 @@ declare const __VLS_export: <TFormData = any, TFormContext = any>(__VLS_props: N
|
|
|
1385
1381
|
declare const _default: typeof __VLS_export;
|
|
1386
1382
|
type __VLS_PrettifyLocal<T> = (T extends any ? { [K in keyof T]: T[K] } : { [K in keyof T as K]: T[K] }) & {};
|
|
1387
1383
|
//#endregion
|
|
1388
|
-
export {
|
|
1384
|
+
export { useAsDescendantErrorCounts as $, useAsNumber as A, TFormFieldRegistration as At, focusFirstAfter as B, UseAsDateReturn as C, TFormSubmitValidator as Ct, useAsDualInput as D, UseAsFieldReturn as Dt, UseAsDualInputReturn as E, UseAsFieldOptions as Et, UseAsTriStateCheckboxReturn as F, useAsOptionalField as G, useAsFocusFirstAfter as H, useAsTriStateCheckbox as I, useAsFieldScope as J, TResolveFieldPropOptions as K, UseAsOptionalAddFlowOptions as L, UseAsDecimalReturn as M, TFormState as Mt, useAsDecimal as N, createDefaultTypes as Nt, UseAsNumberOptions as O, useAsField as Ot, UseAsTriStateCheckboxOptions as P, createAsFormDef as Pt, provideAsNestedSectionsStore as Q, UseAsOptionalAddFlowReturn as R, UseAsDateOptions as S, useAsFormPatch as St, UseAsDualInputOptions as T, useAsState as Tt, useAsVisibleFields as U, focusNewFocusableAfter as V, UseAsOptionalFieldReturn as W, useAsLevel as X, provideAsNestedLevel as Y, AsNestedSectionsStore as Z, useAsData as _, UseAsFormOptions as _t, FormFieldChange$1 as a, formatIndexedLabelParts as at, UseAsPathReturn as b, AsFormPatchHandle as bt, getDefaultClientFactory as c, useAsUnion as ct, joinPath$1 as d, UseAsArrayReturn as dt, useAsNestedSectionsStore as et, resetDefaultClientFactory as f, useAsArray as ft, UseAsDataReturn as g, TAsFormValue as gt, useAsErrorDismiss as h, useAsExternalErrors as ht, FormDiffOptions$1 as i, useAsValueHelp as it, UseAsDecimalOptions as j, TFormRule as jt, UseAsNumberReturn as k, TFormFieldCallbacks as kt, hasFieldMeta$1 as l, UseAsTupleReturn as lt, AsErrorDismiss as m, UseAsExternalErrorsReturn as mt, _default as n, UseAsValueHelpOptions as nt, FormRebaseOptions$1 as o, useAsUnionVariant as ot, setDefaultClientFactory as p, UseAsExternalErrorsOptions as pt, UseAsFieldScopeReturn as q, ClientFactory$1 as r, UseAsValueHelpReturn as rt, TypedClientFactory as s, UseAsUnionReturn as st, Props as t, useAsDropdown as tt, isFieldHidden$1 as u, useAsTuple as ut, UseAsTypeMapReturn as v, UseAsFormReturn as vt, useAsDate as w, UseAsStateReturn as wt, useAsPath as x, RebaseOntoResult as xt, useAsTypeMap as y, useAsForm as yt, useAsOptionalAddFlow as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_as_field_shell = require("./as-field-shell-
|
|
1
|
+
const require_as_field_shell = require("./as-field-shell-DSj3CqN6.cjs");
|
|
2
2
|
const require_as_input_control = require("./as-input-control-Dtvrw_PS.cjs");
|
|
3
3
|
const require_as_adornment_shell = require("./as-adornment-shell-DptUMWNk.cjs");
|
|
4
4
|
let vue = require("vue");
|