@sfxcode/nuxt-ui-formkit 1.2.2 → 1.2.4
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 +7 -0
- package/dist/module.json +1 -1
- package/dist/runtime/components/FUAutoFormOverlay.d.vue.ts +82 -0
- package/dist/runtime/components/FUAutoFormOverlay.vue +106 -0
- package/dist/runtime/components/FUAutoFormOverlay.vue.d.ts +82 -0
- package/dist/runtime/components/FUDataEdit.d.vue.ts +10 -0
- package/dist/runtime/components/FUDataEdit.vue +15 -3
- package/dist/runtime/components/FUDataEdit.vue.d.ts +10 -0
- package/dist/runtime/components/FUDataEditOverlay.d.vue.ts +64 -0
- package/dist/runtime/components/FUDataEditOverlay.vue +94 -0
- package/dist/runtime/components/FUDataEditOverlay.vue.d.ts +64 -0
- package/dist/runtime/components/inputs/FUCalendar.vue +3 -0
- package/dist/runtime/components/inputs/FUCheckbox.vue +2 -1
- package/dist/runtime/components/inputs/FUCheckboxGroup.vue +3 -0
- package/dist/runtime/components/inputs/FUEditor.vue +58 -54
- package/dist/runtime/components/inputs/FUFileUpload.vue +2 -1
- package/dist/runtime/components/inputs/FUInput.vue +2 -1
- package/dist/runtime/components/inputs/FUInputDate.vue +5 -1
- package/dist/runtime/components/inputs/FUInputMenu.vue +2 -1
- package/dist/runtime/components/inputs/FUInputNumber.vue +2 -1
- package/dist/runtime/components/inputs/FUInputTags.vue +2 -1
- package/dist/runtime/components/inputs/FUInputTime.vue +5 -1
- package/dist/runtime/components/inputs/FUListbox.vue +4 -0
- package/dist/runtime/components/inputs/FUPinInput.vue +8 -1
- package/dist/runtime/components/inputs/FURadioGroup.vue +3 -0
- package/dist/runtime/components/inputs/FUSwitch.vue +2 -1
- package/dist/runtime/components/inputs/FUTextarea.vue +2 -1
- package/dist/runtime/composables/useFormKitForm.d.ts +5 -1
- package/dist/runtime/composables/useFormKitForm.js +9 -3
- package/dist/runtime/composables/useFormKitOverlay.d.ts +20 -0
- package/dist/runtime/composables/useFormKitOverlay.js +42 -0
- package/dist/runtime/composables/useFormKitStandardSchema.d.ts +20 -0
- package/dist/runtime/composables/useFormKitStandardSchema.js +68 -0
- package/dist/runtime/utils/standardSchemaErrors.d.ts +14 -0
- package/dist/runtime/utils/standardSchemaErrors.js +15 -0
- package/dist/runtime/utils/useFormKitContainerBlur.d.ts +37 -0
- package/dist/runtime/utils/useFormKitContainerBlur.js +9 -0
- package/dist/runtime/utils/useOverlayCloseResolution.d.ts +20 -0
- package/dist/runtime/utils/useOverlayCloseResolution.js +17 -0
- package/package.json +2 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { FormKitFrameworkContext } from '@formkit/core';
|
|
2
|
+
/**
|
|
3
|
+
* For an input whose real focusable sub-elements live inside one container
|
|
4
|
+
* - a Reka UI `DateField`'s day/month/year segments, a checkbox/radio
|
|
5
|
+
* group's individual items, a listbox's options - `context.handlers.blur`
|
|
6
|
+
* must only fire once focus has genuinely left the whole container, not
|
|
7
|
+
* just moved between its own children. Native `blur` doesn't bubble, so a
|
|
8
|
+
* plain `@blur` on the container never sees a child's blur at all; this
|
|
9
|
+
* binds to `focusout` (which does bubble) instead, and uses
|
|
10
|
+
* `relatedTarget` to tell "moved to a sibling inside" apart from "left
|
|
11
|
+
* entirely."
|
|
12
|
+
*
|
|
13
|
+
* Discovered while wiring `FUInputDate`/`FUInputTime`: Nuxt UI's own
|
|
14
|
+
* `InputDate.vue`/`InputTime.vue` bind `@blur` on their internal
|
|
15
|
+
* `DateField.Root`, assuming Reka UI aggregates blur across segments the
|
|
16
|
+
* same way - it doesn't (`DateField.Root` doesn't declare `blur` as its own
|
|
17
|
+
* emit, so that binding is a native fallthrough on a never-focused
|
|
18
|
+
* container div, and silently never fires). This helper is what actually
|
|
19
|
+
* fixes it, bound to `@focusout` on the outer `<UInputDate>`/`<UInputTime>`
|
|
20
|
+
* component instead.
|
|
21
|
+
*
|
|
22
|
+
* Uses `event.currentTarget` (the element the listener is actually attached
|
|
23
|
+
* to) as the container, rather than a template ref to the component's own
|
|
24
|
+
* `$el` - `UInputDate`/`UInputTime` render a multi-root template (a
|
|
25
|
+
* `createReusableTemplate`-style definition block plus the real
|
|
26
|
+
* `DateField.Root`), so `$el` resolves to that definition block's own
|
|
27
|
+
* placeholder node, not the visible container (confirmed empirically).
|
|
28
|
+
* `currentTarget` has no such ambiguity: it's always the exact node the
|
|
29
|
+
* `focusout` listener is bound to.
|
|
30
|
+
*
|
|
31
|
+
* Returns a plain `(event: Event) => void`, not `(event: FocusEvent) =>
|
|
32
|
+
* void` - some Nuxt UI components (e.g. `UPinInput`) type their own `blur`
|
|
33
|
+
* emit as generic `Event`, and a stricter parameter type isn't assignable
|
|
34
|
+
* to a listener bound there. It's genuinely a `FocusEvent` at runtime
|
|
35
|
+
* (`focusout` always is), so it's cast internally.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createContainerBlurHandler(context: FormKitFrameworkContext): (event: Event) => void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function createContainerBlurHandler(context) {
|
|
2
|
+
return (event) => {
|
|
3
|
+
const focusEvent = event;
|
|
4
|
+
const container = focusEvent.currentTarget;
|
|
5
|
+
const related = focusEvent.relatedTarget;
|
|
6
|
+
if (!container || !related || !container.contains(related))
|
|
7
|
+
context.handlers.blur(focusEvent);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Shared by `FUDataEditOverlay.vue`/`FUAutoFormOverlay.vue`: both need to
|
|
4
|
+
* resolve their `useOverlay` `close` emit exactly once per open cycle, from
|
|
5
|
+
* whichever of several sources fires first - an explicit Save/Cancel button,
|
|
6
|
+
* or `UModal`/`USlideover`'s own Esc/backdrop dismissal, which only ever
|
|
7
|
+
* surfaces as their `open` v-model transitioning to `false` with no
|
|
8
|
+
* dedicated event of its own.
|
|
9
|
+
*
|
|
10
|
+
* `useOverlay` reuses the same wrapper instance across sequential `edit()`/
|
|
11
|
+
* `auto()` calls (its registered `id` is fixed at `.create()` time, not
|
|
12
|
+
* per-`open()` call), so "has this open cycle already resolved" has to reset
|
|
13
|
+
* on every reopen, not just be set once ever - otherwise a *later* call's
|
|
14
|
+
* Esc/backdrop dismissal would see the flag still `true` from a previous
|
|
15
|
+
* cycle's Save/Cancel and silently no-op, leaving that later promise pending
|
|
16
|
+
* forever.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useOverlayCloseResolution(open: Ref<boolean>, emit: (event: 'close', value: unknown) => void): {
|
|
19
|
+
resolveOnce: (value: unknown) => void;
|
|
20
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { watch } from "vue";
|
|
2
|
+
export function useOverlayCloseResolution(open, emit) {
|
|
3
|
+
let hasResolved = false;
|
|
4
|
+
function resolveOnce(value) {
|
|
5
|
+
if (hasResolved)
|
|
6
|
+
return;
|
|
7
|
+
hasResolved = true;
|
|
8
|
+
emit("close", value);
|
|
9
|
+
}
|
|
10
|
+
watch(open, (isOpen) => {
|
|
11
|
+
if (isOpen)
|
|
12
|
+
hasResolved = false;
|
|
13
|
+
else
|
|
14
|
+
resolveOnce(null);
|
|
15
|
+
});
|
|
16
|
+
return { resolveOnce };
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sfxcode/nuxt-ui-formkit",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "FormKit integration for Nuxt UI - Seamlessly connect FormKit form handling with Nuxt UI components",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Tom",
|
|
@@ -92,6 +92,7 @@
|
|
|
92
92
|
"@formkit/nuxt": "^2.1.0",
|
|
93
93
|
"@nuxt/kit": "4.4.8",
|
|
94
94
|
"@nuxt/ui": "^4.9.0",
|
|
95
|
+
"@standard-schema/spec": "^1.1.0",
|
|
95
96
|
"@vue/compiler-dom": "^3.5.39"
|
|
96
97
|
},
|
|
97
98
|
"devDependencies": {
|