@featherk/composables 0.8.1 → 0.9.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/README.md CHANGED
@@ -18,6 +18,12 @@ Vue 3 composables that improve Kendo UI for Vue behavior and accessibility.
18
18
  - Guide: [docs/trap/usePopupTrap.md](https://github.com/NantHealth/featherk/blob/integration/packages/composables/docs/trap/usePopupTrap.md)
19
19
  - **Address**: `useZipTextBox` — Dynamic multi-mask ZIP code input (5-digit and ZIP+4) for Kendo Vue `TextBox`, with caret preservation, submit-gated validation, and focus-on-error support.
20
20
  - Guide: [docs/address/useZipTextBox.md](https://github.com/NantHealth/featherk/blob/integration/packages/composables/docs/address/useZipTextBox.md)
21
+ - **Address**: `useUSAddress` — Orchestrates full US address form behavior, including delayed validation (via `useFieldsetValidationKit`), state options, ZIP integration, and normalized submit payloads.
22
+ - Guide: [docs/address/useUSAddress.md](https://github.com/NantHealth/featherk/blob/integration/packages/composables/docs/address/useUSAddress.md)
23
+ - **Form**: `useFieldsetValidationKit` — Delayed fieldset validation kit with submit/touch gating, field helpers, invalid-focus targeting, and reset handling.
24
+ - Guide: [docs/form/useFieldsetValidationKit.md](https://github.com/NantHealth/featherk/blob/integration/packages/composables/docs/form/useFieldsetValidationKit.md)
25
+ - **Form (Low-level)**: `useFieldsetTouchTracker` — Primitive focus-leave touch tracker that powers the validation kit.
26
+ - Guide: [docs/form/useFieldsetTouchTracker.md](https://github.com/NantHealth/featherk/blob/integration/packages/composables/docs/form/useFieldsetTouchTracker.md)
21
27
 
22
28
  ## Importing Composables
23
29
 
@@ -42,7 +48,10 @@ import { useMaskedTimeInput, type TimeChangePayload } from '@featherk/composable
42
48
  import { usePopupTrap } from '@featherk/composables/trap';
43
49
 
44
50
  // Address utilities
45
- import { useZipTextBox } from '@featherk/composables/address';
51
+ import { useZipTextBox, useUSAddress, type USAddressSubmitPayload } from '@featherk/composables/address';
52
+
53
+ // Form utilities
54
+ import { useFieldsetValidationKit, useFieldsetTouchTracker } from '@featherk/composables/form';
46
55
  ```
47
56
 
48
57
  Root imports (types are aliased to avoid name collisions):
@@ -59,6 +68,9 @@ import {
59
68
  type TimeChangePayload,
60
69
  usePopupTrap,
61
70
  useZipTextBox,
71
+ useUSAddress,
72
+ useFieldsetValidationKit,
73
+ useFieldsetTouchTracker,
62
74
  } from '@featherk/composables';
63
75
  ```
64
76
 
@@ -0,0 +1,29 @@
1
+ export interface USAddressFormData {
2
+ address1: string;
3
+ address2: string;
4
+ city: string;
5
+ state: string | null;
6
+ zip: string;
7
+ }
8
+ /**
9
+ * Manages the form data model for a US address.
10
+ *
11
+ * Note: this is internal UI data state, not just the US "state" (AL, CA, etc.) field.
12
+ * @returns An object containing form data and field event handlers.
13
+ */
14
+ export declare function useUSAddressFormData(): {
15
+ formData: {
16
+ address1: string;
17
+ address2: string;
18
+ city: string;
19
+ state: string | null;
20
+ zip: string;
21
+ };
22
+ onAddress1Input: (...args: unknown[]) => void;
23
+ onAddress2Input: (...args: unknown[]) => void;
24
+ onCityInput: (...args: unknown[]) => void;
25
+ onStateChange: (event: {
26
+ value: string | null;
27
+ }) => void;
28
+ resetFormData: () => void;
29
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ import { type MaybeRefOrGetter } from "vue";
2
+ import type { USAddressFormData } from "./_useUSAddressFormData";
3
+ interface UseUSAddressValidationOptions {
4
+ formData: USAddressFormData;
5
+ isZipValid: MaybeRefOrGetter<boolean>;
6
+ }
7
+ /**
8
+ * Manages the validation state for a US address.
9
+ * @param options - The options object containing form data and ZIP code validity.
10
+ * @returns An object containing validation state for each field and the overall address.
11
+ */
12
+ export declare function useUSAddressValidation(options: UseUSAddressValidationOptions): {
13
+ strictAddress1Valid: import("vue").ComputedRef<boolean>;
14
+ strictCityValid: import("vue").ComputedRef<boolean>;
15
+ strictStateValid: import("vue").ComputedRef<boolean>;
16
+ strictZipValid: import("vue").ComputedRef<boolean>;
17
+ strictAddressValid: import("vue").ComputedRef<boolean>;
18
+ };
19
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { USAddressFormData } from "./_useUSAddressFormData";
2
+ /**
3
+ * Manages the ZIP code field for a US address.
4
+ * @param formData - The form data object containing the ZIP code.
5
+ * @returns An object containing ZIP code display, validity, wrapper class, input handler, and reset function.
6
+ */
7
+ export declare function useUSAddressZip(formData: USAddressFormData): {
8
+ zipDisplay: import("vue").Ref<string, string>;
9
+ isZipValid: import("vue").ComputedRef<boolean>;
10
+ zipWrapperClass: string;
11
+ onZipInput: (...args: unknown[]) => void;
12
+ resetZip: () => void;
13
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,4 @@
1
1
  export { useZipTextBox } from "./useZipTextBox";
2
2
  export type { ZipPayload, UseZipTextBoxOptions, UseZipTextBoxState, UseZipTextBoxBindings, UseZipTextBoxDerived, UseZipTextBoxActions, UseZipTextBoxApi, } from "./useZipTextBox";
3
+ export { useUSAddress } from "./useUSAddress";
4
+ export type { USAddressSubmitPayload } from "./useUSAddress";
@@ -0,0 +1,5 @@
1
+ export type UsStateOption = {
2
+ label: string;
3
+ value: string;
4
+ };
5
+ export declare const US_STATES_BY_ABBREVIATION: UsStateOption[];
@@ -0,0 +1,62 @@
1
+ import { type Ref } from "vue";
2
+ interface UseUSAddressOptions {
3
+ formRef: Ref<HTMLFormElement | null>;
4
+ fieldsetRef: Ref<HTMLFieldSetElement | null>;
5
+ }
6
+ export interface USAddressSubmitPayload {
7
+ address1: string;
8
+ address2: string;
9
+ city: string;
10
+ state: string;
11
+ zip: string;
12
+ }
13
+ /**
14
+ * Composable for managing a US address form.
15
+ * @param options - The options object containing form and fieldset references.
16
+ * @returns An object containing form state, validation state, and handlers.
17
+ */
18
+ export declare function useUSAddress(options: UseUSAddressOptions): {
19
+ formData: {
20
+ address1: string;
21
+ address2: string;
22
+ city: string;
23
+ state: string | null;
24
+ zip: string;
25
+ };
26
+ submitted: Ref<boolean, boolean>;
27
+ touched: Ref<boolean, boolean>;
28
+ addressValidate: import("vue").ComputedRef<boolean>;
29
+ address1Valid: import("vue").ComputedRef<boolean>;
30
+ cityValid: import("vue").ComputedRef<boolean>;
31
+ stateValid: import("vue").ComputedRef<boolean>;
32
+ zipValid: import("vue").ComputedRef<boolean>;
33
+ addressValid: import("vue").ComputedRef<boolean>;
34
+ stateDefaultItem: {
35
+ value: any;
36
+ label: string;
37
+ };
38
+ stateOptions: {
39
+ label: string;
40
+ value: string;
41
+ }[];
42
+ zipDisplay: Ref<string, string>;
43
+ zipWrapperClass: string;
44
+ onAddress1Input: (...args: unknown[]) => void;
45
+ onAddress2Input: (...args: unknown[]) => void;
46
+ onCityInput: (...args: unknown[]) => void;
47
+ onStateChange: (event: {
48
+ value: string | null;
49
+ }) => void;
50
+ onZipInput: (...args: unknown[]) => void;
51
+ onFieldsetFocusout: (event: FocusEvent) => void;
52
+ normalizedPayload: import("vue").ComputedRef<USAddressSubmitPayload>;
53
+ submit: () => Promise<{
54
+ isValid: false;
55
+ payload: any;
56
+ } | {
57
+ isValid: true;
58
+ payload: USAddressSubmitPayload;
59
+ }>;
60
+ reset: () => void;
61
+ };
62
+ export {};
@@ -0,0 +1 @@
1
+ export {};