nuxt-ui-tools 1.10.1 → 1.11.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/dist/module.json +1 -1
- package/dist/runtime/form/components/renderer/form-field-shell.vue +6 -5
- package/dist/runtime/form/fields/text/component.vue +17 -1
- package/dist/runtime/form/types/field-base.d.ts +6 -6
- package/dist/runtime/form/utils/text.d.ts +4 -2
- package/dist/runtime/form/utils/text.js +14 -11
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -14,7 +14,7 @@ import { getSchemaDirtyCheck } from "../../utils/controls";
|
|
|
14
14
|
import { createFormFieldInstance } from "../../utils/field-instance";
|
|
15
15
|
import { isFunction, isNumber, isString } from "../../utils/predicate";
|
|
16
16
|
import { resolveRequired } from "../../utils/state";
|
|
17
|
-
import { resolveFieldDescription, resolveFormText } from "../../utils/text";
|
|
17
|
+
import { resolveFieldDescription, resolveFieldText, resolveFormText } from "../../utils/text";
|
|
18
18
|
import { mergeFormUiClass } from "../../utils/ui";
|
|
19
19
|
const props = defineProps({
|
|
20
20
|
field: { type: null, required: true },
|
|
@@ -25,12 +25,13 @@ const form = useFormRuntimeContext();
|
|
|
25
25
|
const formUi = useFormUi();
|
|
26
26
|
const bare = useFormFieldBare();
|
|
27
27
|
const field = computed(() => createFormFieldInstance(props.field));
|
|
28
|
+
const params = computed(() => form.getFieldCallbackParams(props.path, props.field));
|
|
28
29
|
const label = computed(
|
|
29
30
|
() => field.value.capability.has("label") && "label" in props.field ? resolveFormText(props.field.label) : void 0
|
|
30
31
|
);
|
|
31
32
|
const { t } = useUiToolsLocale();
|
|
32
33
|
const descriptionConfig = computed(
|
|
33
|
-
() => field.value.capability.has("description") && "description" in props.field ? resolveFieldDescription(props.field.description) : void 0
|
|
34
|
+
() => field.value.capability.has("description") && "description" in props.field ? resolveFieldDescription(props.field.description, params.value) : void 0
|
|
34
35
|
);
|
|
35
36
|
const description = computed(
|
|
36
37
|
() => descriptionConfig.value?.display === "inline" ? descriptionConfig.value.text : void 0
|
|
@@ -59,7 +60,7 @@ const shellStyle = computed(
|
|
|
59
60
|
() => orientation.value === "horizontal" && labelWidth.value ? { "--nut-form-label-width": labelWidth.value } : void 0
|
|
60
61
|
);
|
|
61
62
|
const hint = computed(
|
|
62
|
-
() => field.value.capability.has("hint") && "hint" in props.field ?
|
|
63
|
+
() => field.value.capability.has("hint") && "hint" in props.field ? resolveFieldText(props.field.hint, params.value) : void 0
|
|
63
64
|
);
|
|
64
65
|
const labelExtra = computed(() => {
|
|
65
66
|
if (!field.value.capability.has("hint") || !("labelExtra" in props.field)) {
|
|
@@ -78,10 +79,10 @@ const required = computed(() => {
|
|
|
78
79
|
if (!field.value.capability.has("validation")) {
|
|
79
80
|
return false;
|
|
80
81
|
}
|
|
81
|
-
return resolveRequired(props.field,
|
|
82
|
+
return resolveRequired(props.field, params.value);
|
|
82
83
|
});
|
|
83
84
|
const help = computed(
|
|
84
|
-
() => field.value.capability.has("hint") && "help" in props.field ?
|
|
85
|
+
() => field.value.capability.has("hint") && "help" in props.field ? resolveFieldText(props.field.help, params.value) : void 0
|
|
85
86
|
);
|
|
86
87
|
const shellHelp = computed(() => props.inlineLabel ? void 0 : help.value);
|
|
87
88
|
const dirty = computed(
|
|
@@ -27,8 +27,24 @@ const model = computed({
|
|
|
27
27
|
});
|
|
28
28
|
const maskOptions = computed(() => maskDirectiveOptions(fieldProps.value.mask));
|
|
29
29
|
const vOptionalMaska = (element, binding, vnode, previousVnode) => {
|
|
30
|
-
if (
|
|
30
|
+
if (typeof vMaska !== "function") {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (binding.value !== void 0) {
|
|
31
34
|
vMaska(element, binding, vnode, previousVnode);
|
|
35
|
+
} else if (binding.oldValue !== void 0) {
|
|
36
|
+
vMaska(
|
|
37
|
+
element,
|
|
38
|
+
{
|
|
39
|
+
dir: {},
|
|
40
|
+
instance: binding.instance,
|
|
41
|
+
modifiers: {},
|
|
42
|
+
oldValue: binding.oldValue,
|
|
43
|
+
value: { mask: null }
|
|
44
|
+
},
|
|
45
|
+
vnode,
|
|
46
|
+
previousVnode
|
|
47
|
+
);
|
|
32
48
|
}
|
|
33
49
|
};
|
|
34
50
|
const prefix = computed(() => resolveFormText(fieldProps.value.prefix));
|
|
@@ -35,12 +35,12 @@ export interface FormStatefulFieldBase<TType extends FormFieldType, TValue, TCon
|
|
|
35
35
|
}>;
|
|
36
36
|
/** Label rendered by the field wrapper. */
|
|
37
37
|
label?: FormText;
|
|
38
|
-
/** Optional supporting copy rendered near the control, or a tooltip/modal variant. */
|
|
39
|
-
description?: FormText | FormFieldDescription
|
|
40
|
-
/** Optional right-side hint rendered by the field wrapper. */
|
|
41
|
-
hint?: FormText
|
|
42
|
-
/** Optional help text rendered under the control. */
|
|
43
|
-
help?: FormText
|
|
38
|
+
/** Optional supporting copy rendered near the control, or a tooltip/modal variant. Callbacks receive `{ ctx, deps, api }`. */
|
|
39
|
+
description?: FormText | FormFieldDescription | FormFieldCallback<FormText | FormFieldDescription, TContext, TDeps, TValue>;
|
|
40
|
+
/** Optional right-side hint rendered by the field wrapper. Callbacks receive `{ ctx, deps, api }`. */
|
|
41
|
+
hint?: FormText | FormFieldCallback<FormText, TContext, TDeps, TValue>;
|
|
42
|
+
/** Optional help text rendered under the control. Callbacks receive `{ ctx, deps, api }`. */
|
|
43
|
+
help?: FormText | FormFieldCallback<FormText, TContext, TDeps, TValue>;
|
|
44
44
|
/** Optional rich content rendered beside the label. Takes precedence over `hint`. */
|
|
45
45
|
labelExtra?: FormRenderable;
|
|
46
46
|
/** Placeholder forwarded to controls that support placeholders. Callbacks receive `{ ctx, deps, api }`. */
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FormText, FormValue } from '../types/index.js';
|
|
2
2
|
export declare function resolveFormText(text: FormText | undefined): string | undefined;
|
|
3
|
+
/** Resolves field copy that is static, lazy, or computed from the field callback parameters. */
|
|
4
|
+
export declare function resolveFieldText(text: FormValue, params: FormValue): string | undefined;
|
|
3
5
|
export declare function resolveFormBoundaryText(value: FormValue): string | undefined;
|
|
4
6
|
export interface ResolvedFieldDescription {
|
|
5
7
|
text: string;
|
|
6
8
|
display: 'inline' | 'tooltip' | 'modal';
|
|
7
9
|
title?: string;
|
|
8
10
|
}
|
|
9
|
-
export declare function resolveFieldDescription(
|
|
11
|
+
export declare function resolveFieldDescription(description: FormValue, params: FormValue): ResolvedFieldDescription | undefined;
|
|
@@ -9,6 +9,9 @@ export function resolveFormText(text) {
|
|
|
9
9
|
}
|
|
10
10
|
return text;
|
|
11
11
|
}
|
|
12
|
+
export function resolveFieldText(text, params) {
|
|
13
|
+
return resolveFormBoundaryText(isFunction(text) ? invokeFormFunction(text, [params]) : text);
|
|
14
|
+
}
|
|
12
15
|
export function resolveFormBoundaryText(value) {
|
|
13
16
|
if (isString(value)) {
|
|
14
17
|
return value;
|
|
@@ -21,20 +24,20 @@ export function resolveFormBoundaryText(value) {
|
|
|
21
24
|
return isString(resolved) || isNumber(resolved) ? String(resolved) : void 0;
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const text2 = resolveFormText(value.text);
|
|
27
|
+
const DESCRIPTION_DISPLAYS = ["inline", "tooltip", "modal"];
|
|
28
|
+
export function resolveFieldDescription(description, params) {
|
|
29
|
+
const value = isFunction(description) ? invokeFormFunction(description, [params]) : description;
|
|
30
|
+
if (isRecord(value) && "text" in value) {
|
|
31
|
+
const text2 = resolveFormBoundaryText(value.text);
|
|
30
32
|
if (!text2) {
|
|
31
33
|
return void 0;
|
|
32
34
|
}
|
|
33
|
-
return {
|
|
35
|
+
return {
|
|
36
|
+
display: DESCRIPTION_DISPLAYS.find((display) => display === value.display) ?? "inline",
|
|
37
|
+
text: text2,
|
|
38
|
+
title: resolveFormBoundaryText(value.title)
|
|
39
|
+
};
|
|
34
40
|
}
|
|
35
|
-
const text =
|
|
41
|
+
const text = resolveFormBoundaryText(value);
|
|
36
42
|
return text ? { display: "inline", text } : void 0;
|
|
37
43
|
}
|
|
38
|
-
function isDescriptionConfig(value) {
|
|
39
|
-
return isRecord(value) && "text" in value;
|
|
40
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-ui-tools",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "Nuxt module and runtime toolkit for UI-heavy Nuxt applications",
|
|
5
5
|
"homepage": "https://github.com/ChronicStone/nuxt-ui-tools#readme",
|
|
6
6
|
"bugs": "https://github.com/ChronicStone/nuxt-ui-tools/issues",
|