@featherk/ui 0.9.5 → 0.9.7

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
@@ -5,7 +5,7 @@ Vue UI component package for FeatherK.
5
5
  ## Components Overview
6
6
 
7
7
  - **Address**: `USAddress` - Presentational US address renderer driven by a parent-owned `useUSAddress` view model.
8
- - Guide: [docs/address/USAddress.md](https://github.com/NantHealth/featherk/blob/integration/packages/ui/docs/address/USAddress.md)
8
+ - Component guide: [docs/address/USAddress.md](https://github.com/NantHealth/featherk/blob/integration/packages/ui/docs/address/USAddress.md)
9
9
 
10
10
  ## Importing Components
11
11
 
@@ -14,73 +14,17 @@ import { USAddress } from "@featherk/ui";
14
14
  import { useUSAddress } from "@featherk/composables/address";
15
15
  ```
16
16
 
17
- ## Usage
18
-
19
- Component styles ship with `@featherk/ui` and are automatically loaded from the package ESM entry.
20
-
21
- ```vue
22
- <script setup lang="ts">
23
- import { ref, toRef } from "vue";
24
- import { USAddress } from "@featherk/ui";
25
- import { useUSAddress } from "@featherk/composables/address";
26
-
27
- const billingFieldsetRef = ref<HTMLFieldSetElement | null>(null);
28
- const isAddressRequired = ref(true);
29
-
30
- const billingAddress = useUSAddress({
31
- fieldsetRef: toRef(() => billingFieldsetRef.value),
32
- addressId: "billing-address",
33
- required: toRef(() => isAddressRequired.value),
34
- });
35
-
36
- const onFieldsetFocusout = (event: FocusEvent) => {
37
- billingAddress.onFieldsetFocusout(event);
38
- };
39
-
40
- function onReset() {
41
- billingAddress.reset();
42
- }
43
-
44
- async function onSubmit() {
45
- const result = await billingAddress.validateForSubmit();
46
- if (!result.isValid) return;
47
-
48
- console.log(result.payload);
49
- }
50
- </script>
51
-
52
- <template>
53
- <form @submit.prevent="onSubmit">
54
- <fieldset ref="billingFieldsetRef" @focusout="onFieldsetFocusout">
55
- <USAddress
56
- id="billing-address"
57
- :address="billingAddress"
58
- :required="isAddressRequired"
59
- />
60
-
61
- <label for="billing-attn">Attention</label>
62
- <input id="billing-attn" type="text" />
63
- </fieldset>
64
-
65
- <button type="submit">Submit</button>
66
- <button type="button" @click="onReset">Reset</button>
67
- </form>
68
- </template>
69
- ```
70
-
71
- `USAddress` is presentational. Parent components own composable orchestration.
72
-
73
- Required prop:
74
- - `address`: pass the object returned by `useUSAddress(...)`.
75
-
76
- Submission ownership:
77
- - Parent form components own submission orchestration, reset behavior, and payload handling.
17
+ For complete setup, behavior, and examples, use the component guide listed in Components Overview.
78
18
 
79
19
  ## Peer Dependencies
80
20
 
81
21
  - Required: `vue`
82
22
  - Required for `USAddress`: `@progress/kendo-vue-buttons`, `@progress/kendo-vue-dropdowns`, `@progress/kendo-vue-inputs`, `@progress/kendo-vue-labels`
83
23
 
24
+ ## Styling
25
+
26
+ Component styles ship with `@featherk/ui` and are automatically loaded from the package ESM entry.
27
+
84
28
  ## Build
85
29
 
86
30
  Run from repository root:
@@ -18,29 +18,49 @@ import { USAddress } from "@featherk/ui";
18
18
  import { useUSAddress } from "@featherk/composables/address";
19
19
  ```
20
20
 
21
+ ## Quick Start
22
+
23
+ 1. Call `useUSAddress({ fieldsetRef, addressId, required })` to get the composable API.
24
+ 2. Wrap `<USAddress>` inside a `<fieldset>` and bind its `ref` to `fieldsetRef`.
25
+ 3. Wire the fieldset's `@focusout` to `onFieldsetFocusout` — this activates
26
+ delayed validation, which stays suspended until the fieldset loses focus
27
+ or the form is submitted.
28
+ 4. On submit, call `await address.validateForSubmit()`. This sets internal
29
+ `submitted` state (activating error display) and returns
30
+ `{ isValid, payload }`, where `payload` is `null` when `isValid` is `false`.
31
+ 5. On reset, call `address.reset()`. **Use `type="button"` on the Reset
32
+ control** — the HTML default is `type="submit"`, which would immediately
33
+ re-trigger form submission and re-raise the error you just cleared.
34
+
21
35
  ## Basic Usage
22
36
 
23
37
  ```vue
24
38
  <script setup lang="ts">
25
- import { ref, toRef } from "vue";
39
+ import { ref } from "vue";
26
40
  import { USAddress } from "@featherk/ui";
27
41
  import { useUSAddress } from "@featherk/composables/address";
28
42
 
29
43
  const shippingFieldsetRef = ref<HTMLFieldSetElement | null>(null);
44
+ const isShippingAddressRequired = ref(true);
30
45
 
46
+ // Step 1: get the composable API; refs can be passed directly (no toRef needed)
31
47
  const shippingAddress = useUSAddress({
32
- fieldsetRef: toRef(() => shippingFieldsetRef.value),
48
+ fieldsetRef: shippingFieldsetRef,
33
49
  addressId: "shipping-address",
50
+ required: isShippingAddressRequired,
34
51
  });
35
52
 
53
+ // Step 3: activates delayed validation on fieldset blur
36
54
  const onFieldsetFocusout = (event: FocusEvent) => {
37
55
  shippingAddress.onFieldsetFocusout(event);
38
56
  };
39
57
 
58
+ // Step 5
40
59
  function onReset() {
41
60
  shippingAddress.reset();
42
61
  }
43
62
 
63
+ // Step 4
44
64
  async function onSubmit() {
45
65
  const result = await shippingAddress.validateForSubmit();
46
66
  if (!result.isValid) return;
@@ -51,14 +71,22 @@ async function onSubmit() {
51
71
 
52
72
  <template>
53
73
  <form @submit.prevent="onSubmit">
74
+ <!-- Step 2: fieldsetRef binds here -->
54
75
  <fieldset ref="shippingFieldsetRef" @focusout="onFieldsetFocusout">
55
- <USAddress id="shipping-address" :address="shippingAddress" />
76
+ <!-- required must match the same source passed to useUSAddress; messageScope defaults to "fieldset" -->
77
+ <USAddress
78
+ id="shipping-address"
79
+ :address="shippingAddress"
80
+ :required="isShippingAddressRequired"
81
+ messageScope="fieldset"
82
+ />
56
83
 
57
84
  <label for="shipping-attn">Attention</label>
58
85
  <input id="shipping-attn" type="text" />
59
86
  </fieldset>
60
87
 
61
88
  <button type="submit">Submit</button>
89
+ <!-- Step 5: type="button" required, see Quick Start -->
62
90
  <button type="button" @click="onReset">Reset</button>
63
91
  </form>
64
92
  </template>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@featherk/ui",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
4
4
  "main": "dist/featherk-ui.umd.js",
5
5
  "module": "dist/featherk-ui.es.js",
6
6
  "types": "dist/index.d.ts",