@dynamicforms/vuetify-inputs 0.11.6 → 0.12.1

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/index.d.ts CHANGED
@@ -16,6 +16,7 @@ import { DefaultInputSlot } from 'vuetify/lib/components/VField/VField';
16
16
  import { DefineComponent } from 'vue';
17
17
  import { Editor } from '../node_modules/@tiptap/vue-3/dist';
18
18
  import { Era } from 'date-fns';
19
+ import { FieldBase } from '@dynamicforms/vue-forms';
19
20
  import { FirstWeekContainsDate } from 'date-fns';
20
21
  import { FormatDistanceFn } from 'date-fns';
21
22
  import { FormatLongFn } from 'date-fns';
@@ -30,6 +31,7 @@ import { LocaleUnit } from 'date-fns';
30
31
  import { LocalizeFn } from 'date-fns';
31
32
  import { MatchFn } from 'date-fns';
32
33
  import { MaybeRef } from 'vue';
34
+ import { MaybeRefOrGetter } from 'vue';
33
35
  import { MdString } from '@dynamicforms/vue-forms';
34
36
  import { Month } from 'date-fns';
35
37
  import { PublicProps } from 'vue';
@@ -217,18 +219,12 @@ export declare type ActionBreakpointOptions = BreakpointsJSON<ActionRenderOption
217
219
  export declare type ActionBreakpointRenderOptions = Omit<ActionRenderOptions, 'name' | 'defaultConfirm' | 'defaultReject'>;
218
220
 
219
221
  /**
220
- * DisplayMode enum provides an enumeration for supported ways of rendering a particular object in the DOM
222
+ * How an action is rendered: `'button'` as a tonal `<v-btn>`, `'text'` as a text-variant `<v-btn>`.
221
223
  */
222
- export declare enum ActionDisplayStyle {
223
- BUTTON = 0,// action should render as a button
224
- TEXT = 1
225
- }
224
+ export declare type ActionDisplayStyle = 'button' | 'text';
226
225
 
227
- export declare namespace ActionDisplayStyle {
228
- export function fromString(mode: string): ActionDisplayStyle;
229
- export function fromAny(mode: any): ActionDisplayStyle;
230
- export function isDefined(mode: number | string): boolean;
231
- }
226
+ /** every display style */
227
+ export declare const actionDisplayStyles: readonly ActionDisplayStyle[];
232
228
 
233
229
  export declare interface ActionRenderOptions extends ActionValue {
234
230
  /** The text of the action, rendered when {@link showLabel} is set and the text is not empty. `ActionValue`
@@ -244,8 +240,7 @@ export declare interface ActionRenderOptions extends ActionValue {
244
240
  * `Form.Group`) - not this `name` field - is what the modal's promise actually resolves with; keeping them
245
241
  * in sync is what lets callers do e.g. `if (await modal.yesNo(...) === 'yes')`. */
246
242
  name?: string;
247
- /** How the action is rendered: {@link ActionDisplayStyle.BUTTON} for a tonal `<v-btn>`, or
248
- * {@link ActionDisplayStyle.TEXT} for a text-variant `<v-btn>`. */
243
+ /** How the action is rendered: `'button'` for a tonal `<v-btn>`, or `'text'` for a text-variant `<v-btn>`. */
249
244
  renderAs?: ActionDisplayStyle;
250
245
  /** Whether the label is shown. If `label` is empty, the label is never shown regardless of this flag. */
251
246
  showLabel?: boolean;
@@ -284,7 +279,7 @@ export declare interface BaseProps<T = any> {
284
279
  helpText?: string;
285
280
  hint?: string;
286
281
  enabled?: boolean;
287
- visibility?: default_2.DisplayMode | string;
282
+ visibility?: default_2.Visibility;
288
283
  cssClass?: string;
289
284
  clearable?: boolean;
290
285
  passthroughAttrs?: Record<string, any>;
@@ -375,7 +370,8 @@ export declare const defaultBaseProps: {
375
370
  clearable: boolean;
376
371
  };
377
372
 
378
- export declare const defaultDisplayStyle = ActionDisplayStyle.BUTTON;
373
+ /** What an action renders as where nothing states otherwise. */
374
+ export declare const defaultDisplayStyle: ActionDisplayStyle;
379
375
 
380
376
  export declare const DfActions: DefineComponent<DfActionsProps, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<DfActionsProps> & Readonly<{}>, {
381
377
  buttonSize: VuetifyButtonSize;
@@ -657,8 +653,8 @@ export declare const dfInputComponentsByTag: {
657
653
  "update:modelValue": (value: string) => any;
658
654
  }, PublicProps, {
659
655
  minHeight: string;
660
- modelValue: string;
661
656
  disabled: boolean;
657
+ modelValue: string;
662
658
  toolbarButtonSize: VuetifyButtonSize;
663
659
  fontFamily: string;
664
660
  }, false, {}, {}, GlobalComponents, GlobalDirectives, string, {
@@ -701,8 +697,8 @@ export declare const dfInputComponentsByTag: {
701
697
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
702
698
  }>, {}, {}, {}, {}, {
703
699
  minHeight: string;
704
- modelValue: string;
705
700
  disabled: boolean;
701
+ modelValue: string;
706
702
  toolbarButtonSize: VuetifyButtonSize;
707
703
  fontFamily: string;
708
704
  }> | null;
@@ -853,8 +849,8 @@ fontFamily?: string;
853
849
  "update:modelValue": (value: string) => any;
854
850
  }, PublicProps, {
855
851
  minHeight: string;
856
- modelValue: string;
857
852
  disabled: boolean;
853
+ modelValue: string;
858
854
  toolbarButtonSize: VuetifyButtonSize;
859
855
  fontFamily: string;
860
856
  }, false, {}, {}, GlobalComponents, GlobalDirectives, string, {
@@ -897,8 +893,8 @@ fontFamily?: string;
897
893
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
898
894
  }>, {}, {}, {}, {}, {
899
895
  minHeight: string;
900
- modelValue: string;
901
896
  disabled: boolean;
897
+ modelValue: string;
902
898
  toolbarButtonSize: VuetifyButtonSize;
903
899
  fontFamily: string;
904
900
  }> | null;
@@ -1029,6 +1025,9 @@ export declare function getRenderOptionsForBreakpoint(value: ActionValue, breakp
1029
1025
 
1030
1026
  export declare const InputBase: __VLS_WithTemplateSlots_2<typeof __VLS_component_2, __VLS_TemplateResult_2["slots"]>;
1031
1027
 
1028
+ /** Answers whether `value` is one of the display styles. */
1029
+ export declare function isActionDisplayStyle(value: unknown): value is ActionDisplayStyle;
1030
+
1032
1031
  export declare class Label {
1033
1032
  text: string;
1034
1033
  icon?: string | undefined;
@@ -1063,6 +1062,18 @@ export declare interface SelectChoice {
1063
1062
 
1064
1063
  export declare type SelectFetchChoices<T1 = any, T2 = any> = (queryValue?: T1, idValue?: T2) => Promise<SelectChoice[]>;
1065
1064
 
1065
+ /**
1066
+ * The errors of `errors` a component shows now. `errors` and `valid` state the verdict, which a submit needs at
1067
+ * once; what the user is shown waits for the user, because a form covered in errors before anything was typed tells
1068
+ * the user nothing they can act on.
1069
+ *
1070
+ * By default an error is shown where `control` is sent at all - its `effectiveAccess` is not `'disabled'` - and
1071
+ * either its `origin` is `'server'`, since the server answered something the user did, or the element is `touched`.
1072
+ * Without a control, `touched` is the component's own. The `shownErrors` setting replaces the rule with a condition
1073
+ * of the application's own, asked for each error with the default answer.
1074
+ */
1075
+ export declare function selectShownErrors(errors: readonly ValidationError[], control: FieldBase | undefined, touched: boolean, settings: VuetifyInputsSettings): ValidationError[];
1076
+
1066
1077
  /**
1067
1078
  * Reports a {@link FileGoneError}'s message on `control`, where one is bound. Kept outside the component's own
1068
1079
  * script so the write to `control.errors` isn't seen as a `.vue` component mutating its own prop — the write
@@ -1220,8 +1231,8 @@ export declare function useInputBase<T = any>(props: BaseProps<T>, emit: BaseEmi
1220
1231
  valid: ComputedRef<boolean>;
1221
1232
  enabled: ComputedRef<boolean>;
1222
1233
  errors: ComputedRef<default_2.ValidationError[]>;
1223
- showErrors: ComputedRef<default_2.ValidationError[] | undefined>;
1224
- visibility: ComputedRef<default_2.DisplayMode>;
1234
+ shownErrors: ComputedRef<default_2.ValidationError[]>;
1235
+ visibility: ComputedRef<default_2.Visibility>;
1225
1236
  isRendered: ComputedRef<boolean>;
1226
1237
  visibilityClass: ComputedRef< {
1227
1238
  'd-none': boolean;
@@ -1249,6 +1260,13 @@ export declare function useInputBase<T = any>(props: BaseProps<T>, emit: BaseEmi
1249
1260
  }>;
1250
1261
  };
1251
1262
 
1263
+ /**
1264
+ * The errors of `element` to show now, by the rule `selectShownErrors` states and the `shownErrors` setting the
1265
+ * application provided. It is what a template rendering errors of its own - a group's, say - binds, so that they
1266
+ * appear when the inputs' errors do. Call it in a component's setup, where the settings are injected.
1267
+ */
1268
+ export declare function useShownErrors(element: MaybeRefOrGetter<FieldBase | undefined>): ComputedRef<ValidationError[]>;
1269
+
1252
1270
  /** Vuetify's own `size` prop (`v-btn`, `v-icon`, ...) also accepts an arbitrary CSS length or number, so this
1253
1271
  * keeps that but still offers the named sizes for autocomplete: `(string & {})` is a plain `string` to the type
1254
1272
  * checker (any string is still assignable) but not to a union with string literals, which is what makes an IDE
@@ -1292,6 +1310,13 @@ export declare interface VuetifyInputsSettings {
1292
1310
  /** Milliseconds between `<df-file>`/`<df-image>` keep-alive touches; overridable per field by their
1293
1311
  * `touchInterval` prop. Defaults to 60000 when neither is set. */
1294
1312
  defaultTouchInterval?: number;
1313
+ /**
1314
+ * The condition that decides whether an error is shown, asked for each error a component would show, with the
1315
+ * answer the default rule gives (see `useShownErrors`); its answer stands. `control` is the element the component
1316
+ * is bound to, absent where the errors come from the `errors` prop. It runs while the errors are rendered, so it
1317
+ * is synchronous and changes nothing.
1318
+ */
1319
+ shownErrors?: (error: ValidationError, control: FieldBase | undefined, shownByDefault: boolean) => boolean;
1295
1320
  }
1296
1321
 
1297
1322
  export declare const vuetifyInputsSettingsKey: unique symbol;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dynamicforms/vuetify-inputs",
3
3
  "private": false,
4
- "version": "0.11.6",
4
+ "version": "0.12.1",
5
5
  "type": "module",
6
6
  "description": "Vuetify input components with guaranteed visual consistency across all form fields — unified density/variant system, globally configurable, with inline mode for table cells. Built for @dynamicforms/vue-forms.",
7
7
  "author": "Jure Erznožnik",
@@ -57,7 +57,7 @@
57
57
  },
58
58
  "peerDependencies": {
59
59
  "@dynamicforms/translatable": "^0.1.0",
60
- "@dynamicforms/vue-forms": "^1.0.0",
60
+ "@dynamicforms/vue-forms": "^2.0.2",
61
61
  "@mdi/font": "^7.4.47",
62
62
  "@tiptap/core": "^3.30.2",
63
63
  "@tiptap/extension-image": "^3.30.2",
package/readme.md CHANGED
@@ -56,9 +56,10 @@ consistent appearance.
56
56
  - **A control, a v-model, or neither**: a bound element owns the value, validity, touched, enabled and visibility;
57
57
  `v-model` reports changes to the parent; neither keeps the value internally
58
58
  - **Errors, hints and help text** in one row, rendered through vue-forms' `MessagesWidget`, so an error may be
59
- plain text, markdown or a component of its own
59
+ plain text, markdown or a component of its own; an error is shown by one rule an application can replace — the
60
+ server's at once, every other once the field is touched
60
61
  - **Labels with icons and markdown**, through the `Label` class and `MdString`
61
- - **Visibility through `DisplayMode`** — `FULL`, `HIDDEN`, `INVISIBLE`, `SUPPRESS` — and enablement that follows the
62
+ - **Visibility** — `'full'`, `'invisible'`, `'hidden'`, `'suppress'` — and enablement that follows the
62
63
  containing section
63
64
  - **`passthroughAttrs`**: any prop of the underlying Vuetify component, without this library declaring it
64
65
  - **Actions**: the `Action` class with render options, `defaultConfirm` / `defaultReject`, the ready-made