nuxt-ui-formwerk 0.1.13 → 0.1.15

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.d.mts CHANGED
@@ -1,4 +1,5 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
+ export * from '../dist/runtime/types/index.js';
2
3
 
3
4
  declare const _default: _nuxt_schema.NuxtModule<_nuxt_schema.ModuleOptions, _nuxt_schema.ModuleOptions, false>;
4
5
 
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-ui-formwerk",
3
3
  "configKey": "uiElements",
4
- "version": "0.1.13",
4
+ "version": "0.1.15",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -1,20 +1,30 @@
1
+ export type FieldProps = Omit<FormFieldProps, "validateOnInputDelay" | "errorPattern" | "eagerValidation" | "error">;
2
+ export interface FieldSlots {
3
+ default(props: {
4
+ model: {
5
+ modelValue: any;
6
+ "onUpdate:modelValue": (value: any) => void;
7
+ };
8
+ setValue: (value: any) => void;
9
+ value: any;
10
+ }): any;
11
+ }
1
12
  import type { FormFieldProps } from "@nuxt/ui";
2
- type __VLS_Props = Omit<FormFieldProps, "validateOnInputDelay" | "errorPattern" | "eagerValidation" | "error">;
3
- declare var __VLS_8: {
4
- model: {
5
- modelValue: any;
6
- "onUpdate:modelValue": (value: any) => void;
7
- };
8
- setValue: (value: any) => void;
9
- value: any;
10
- };
11
- type __VLS_Slots = {} & {
12
- default?: (props: typeof __VLS_8) => any;
13
- };
14
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
16
13
  declare const _default: typeof __VLS_export;
17
14
  export default _default;
15
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<FieldProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FieldProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
16
+ default?: (props: {
17
+ model: {
18
+ modelValue: any;
19
+ "onUpdate:modelValue": (value: any) => void;
20
+ };
21
+ setValue: (value: any) => void;
22
+ value: any;
23
+ isTouched: boolean;
24
+ isBlurred: boolean;
25
+ isDirty: boolean;
26
+ }) => any;
27
+ }>;
18
28
  type __VLS_WithSlots<T, S> = T & {
19
29
  new (): {
20
30
  $slots: S;
@@ -1,8 +1,11 @@
1
- <script setup>
2
- import { useCustomControl } from "@formwerk/core";
1
+ <script>
2
+ import { useCustomControl, useFormField } from "@formwerk/core";
3
3
  import { formBusInjectionKey } from "#imports";
4
4
  import { inject, watch, computed } from "vue";
5
- import { formwerkOptionsInjectionKey, formwerkBusInjectionKey } from "./Form.vue";
5
+ import { formwerkOptionsInjectionKey, formwerkBusInjectionKey } from "../types/form";
6
+ </script>
7
+
8
+ <script setup>
6
9
  const props = defineProps({
7
10
  as: { type: null, required: false },
8
11
  name: { type: String, required: false },
@@ -19,13 +22,19 @@ const props = defineProps({
19
22
  const formBus = inject(formBusInjectionKey, void 0);
20
23
  const formwerkBus = inject(formwerkBusInjectionKey, void 0);
21
24
  const formwerkOptions = inject(formwerkOptionsInjectionKey, void 0);
25
+ const field = useFormField({
26
+ path: props.name,
27
+ label: props.label,
28
+ description: props.description
29
+ });
22
30
  const {
23
31
  field: { errorMessage, fieldValue, setValue, setBlurred, setTouched, isTouched, isBlurred, isDirty }
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
32
  } = useCustomControl({
26
33
  name: props.name,
27
34
  required: props.required,
28
- disabled: formwerkOptions?.value?.disabled
35
+ disabled: formwerkOptions?.value?.disabled,
36
+ controlType: "NuxtUIInput",
37
+ _field: field
29
38
  });
30
39
  const emitFormEvent = (type, name, payload) => {
31
40
  if (formwerkBus && name) formwerkBus.emit(type, { name, payload });
@@ -35,12 +44,10 @@ watch(isBlurred, (newValue) => emitFormEvent("blur", props.name, newValue));
35
44
  watch(isDirty, (newValue) => emitFormEvent("dirty", props.name, newValue));
36
45
  const error = computed(() => {
37
46
  if (!formwerkOptions || !formwerkOptions.value) return errorMessage.value ? errorMessage.value : void 0;
38
- switch (formwerkOptions.value.validateOn) {
39
- case "blur":
40
- return isBlurred.value && errorMessage.value ? errorMessage.value : void 0;
41
- default:
42
- return errorMessage.value ? errorMessage.value : void 0;
47
+ if (formwerkOptions.value.validateOn === "blur") {
48
+ return isBlurred.value && errorMessage.value ? errorMessage.value : void 0;
43
49
  }
50
+ return errorMessage.value ? errorMessage.value : void 0;
44
51
  });
45
52
  const model = computed(() => ({
46
53
  modelValue: fieldValue.value,
@@ -48,6 +55,7 @@ const model = computed(() => ({
48
55
  }));
49
56
  if (formBus) {
50
57
  formBus.on(async (event) => {
58
+ if ("name" in event && event.name !== props.name) return;
51
59
  switch (event.type) {
52
60
  case "blur":
53
61
  setBlurred(true);
@@ -63,7 +71,15 @@ if (formBus) {
63
71
  </script>
64
72
 
65
73
  <template>
66
- <UFormField v-bind="props" :error="error">
67
- <slot :model="model" :set-value="setValue" :value="fieldValue" />
68
- </UFormField>
74
+ <div>
75
+ <UFormField v-bind="props" :error="error">
76
+ <slot
77
+ :model="model"
78
+ :set-value="setValue"
79
+ :value="fieldValue"
80
+ :is-touched="isTouched"
81
+ :is-blurred="isBlurred"
82
+ :is-dirty="isDirty" />
83
+ </UFormField>
84
+ </div>
69
85
  </template>
@@ -1,20 +1,30 @@
1
+ export type FieldProps = Omit<FormFieldProps, "validateOnInputDelay" | "errorPattern" | "eagerValidation" | "error">;
2
+ export interface FieldSlots {
3
+ default(props: {
4
+ model: {
5
+ modelValue: any;
6
+ "onUpdate:modelValue": (value: any) => void;
7
+ };
8
+ setValue: (value: any) => void;
9
+ value: any;
10
+ }): any;
11
+ }
1
12
  import type { FormFieldProps } from "@nuxt/ui";
2
- type __VLS_Props = Omit<FormFieldProps, "validateOnInputDelay" | "errorPattern" | "eagerValidation" | "error">;
3
- declare var __VLS_8: {
4
- model: {
5
- modelValue: any;
6
- "onUpdate:modelValue": (value: any) => void;
7
- };
8
- setValue: (value: any) => void;
9
- value: any;
10
- };
11
- type __VLS_Slots = {} & {
12
- default?: (props: typeof __VLS_8) => any;
13
- };
14
- declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
15
- declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
16
13
  declare const _default: typeof __VLS_export;
17
14
  export default _default;
15
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<FieldProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FieldProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
16
+ default?: (props: {
17
+ model: {
18
+ modelValue: any;
19
+ "onUpdate:modelValue": (value: any) => void;
20
+ };
21
+ setValue: (value: any) => void;
22
+ value: any;
23
+ isTouched: boolean;
24
+ isBlurred: boolean;
25
+ isDirty: boolean;
26
+ }) => any;
27
+ }>;
18
28
  type __VLS_WithSlots<T, S> = T & {
19
29
  new (): {
20
30
  $slots: S;
@@ -0,0 +1,25 @@
1
+ export interface FormSlots {
2
+ default(props: {
3
+ blurredFields: ReadonlySet<any>;
4
+ touchedFields: ReadonlySet<any>;
5
+ dirtyFields: ReadonlySet<any>;
6
+ }): any;
7
+ }
8
+ export interface Props {
9
+ validateOn?: "touched" | "blur" | "dirty";
10
+ disabled?: boolean;
11
+ }
12
+ declare const _default: typeof __VLS_export;
13
+ export default _default;
14
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
15
+ default?: (props: {
16
+ blurredFields: Set<any>;
17
+ touchedFields: Set<any>;
18
+ dirtyFields: Set<any>;
19
+ }) => any;
20
+ }>;
21
+ type __VLS_WithSlots<T, S> = T & {
22
+ new (): {
23
+ $slots: S;
24
+ };
25
+ };
@@ -3,8 +3,10 @@ import { provide, reactive, computed } from "vue";
3
3
  import { useEventBus } from "@vueuse/core";
4
4
  import { useFormContext } from "@formwerk/core";
5
5
  import { formBusInjectionKey, formOptionsInjectionKey } from "#imports";
6
- export const formwerkOptionsInjectionKey = /* @__PURE__ */ Symbol("nuxt-ui-formwerk.form-options");
7
- export const formwerkBusInjectionKey = /* @__PURE__ */ Symbol("nuxt-ui-formwerk.form-events");
6
+ import {
7
+ formwerkOptionsInjectionKey,
8
+ formwerkBusInjectionKey
9
+ } from "../types/form";
8
10
  </script>
9
11
 
10
12
  <script setup>
@@ -0,0 +1,25 @@
1
+ export interface FormSlots {
2
+ default(props: {
3
+ blurredFields: ReadonlySet<any>;
4
+ touchedFields: ReadonlySet<any>;
5
+ dirtyFields: ReadonlySet<any>;
6
+ }): any;
7
+ }
8
+ export interface Props {
9
+ validateOn?: "touched" | "blur" | "dirty";
10
+ disabled?: boolean;
11
+ }
12
+ declare const _default: typeof __VLS_export;
13
+ export default _default;
14
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
15
+ default?: (props: {
16
+ blurredFields: Set<any>;
17
+ touchedFields: Set<any>;
18
+ dirtyFields: Set<any>;
19
+ }) => any;
20
+ }>;
21
+ type __VLS_WithSlots<T, S> = T & {
22
+ new (): {
23
+ $slots: S;
24
+ };
25
+ };
@@ -0,0 +1,13 @@
1
+ import type { InjectionKey, ComputedRef } from "vue";
2
+ import type { UseEventBusReturn } from "@vueuse/core";
3
+ export interface FormInjectedOptions {
4
+ disabled?: boolean;
5
+ validateOn?: FormwerkInputEvents;
6
+ }
7
+ export type FormwerkInputEvent = {
8
+ name: string;
9
+ payload: unknown;
10
+ };
11
+ export type FormwerkInputEvents = "touched" | "blur" | "dirty";
12
+ export declare const formwerkOptionsInjectionKey: InjectionKey<ComputedRef<FormInjectedOptions>>;
13
+ export declare const formwerkBusInjectionKey: InjectionKey<UseEventBusReturn<FormwerkInputEvents, FormwerkInputEvent>>;
@@ -0,0 +1,2 @@
1
+ export const formwerkOptionsInjectionKey = Symbol("nuxt-ui-formwerk.form-options");
2
+ export const formwerkBusInjectionKey = Symbol("nuxt-ui-formwerk.form-events");
@@ -0,0 +1,4 @@
1
+ export * from "../components/Form.vue.js";
2
+ export * from "../components/Field.vue.js";
3
+ export * from "../components/Group.vue.js";
4
+ export * from "./form.js";
@@ -0,0 +1,4 @@
1
+ export * from "../components/Form.vue";
2
+ export * from "../components/Field.vue";
3
+ export * from "../components/Group.vue";
4
+ export * from "./form.js";
package/dist/types.d.mts CHANGED
@@ -5,3 +5,5 @@ import type { default as Module } from './module.mjs'
5
5
  export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
6
6
 
7
7
  export { default } from './module.mjs'
8
+
9
+ export * from '../dist/runtime/types/index.js'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-ui-formwerk",
3
- "version": "0.1.13",
3
+ "version": "0.1.15",
4
4
  "description": "A collection of beautiful, animated UI components for Nuxt applications",
5
5
  "license": "MIT",
6
6
  "repository": "https://github.com/genu/nuxt-ui-formwerk.git",
@@ -31,7 +31,7 @@
31
31
  "@nuxt/eslint-config": "^1.12.1",
32
32
  "@nuxt/module-builder": "^1.0.2",
33
33
  "@nuxt/schema": "^4.2.2",
34
- "@nuxt/test-utils": "^3.22.0",
34
+ "@nuxt/test-utils": "^3.23.0",
35
35
  "@types/culori": "^4.0.1",
36
36
  "@types/node": "latest",
37
37
  "changelogen": "^0.6.2",