@marianmeres/stuic 3.94.2 → 3.94.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.
@@ -10,6 +10,7 @@
10
10
  CheckoutValidationError,
11
11
  } from "./_internal/checkout-types.js";
12
12
  import type { NotificationsStack } from "../Notifications/notifications-stack.svelte.js";
13
+ import type { Props as CheckoutAddressFormProps } from "./CheckoutAddressForm.svelte";
13
14
 
14
15
  export interface Props extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
15
16
  /** Order data (for totals display in sidebar) */
@@ -94,6 +95,24 @@
94
95
  ]
95
96
  >;
96
97
 
98
+ /**
99
+ * Props forwarded to both inner `CheckoutAddressForm` instances (shipping
100
+ * and, when visible, billing). Use this to configure `phoneFieldProps`,
101
+ * `countryFieldProps`, `preferredCountries`, `countryList`, `countryNames`,
102
+ * `requiredFields`, or `fields` without replacing the entire left column
103
+ * via the `leftColumn` snippet.
104
+ *
105
+ * Structural props that `CheckoutShippingStep` owns (`address`, `errors`,
106
+ * `label`, `countryField`, `t`, `unstyled`, `el`) cannot be overridden via
107
+ * this object — they are applied after the spread.
108
+ */
109
+ addressFormProps?: Partial<
110
+ Omit<
111
+ CheckoutAddressFormProps,
112
+ "address" | "errors" | "label" | "countryField" | "t" | "unstyled" | "el"
113
+ >
114
+ >;
115
+
97
116
  /** Override left column entirely */
98
117
  leftColumn?: Snippet;
99
118
 
@@ -154,6 +173,7 @@
154
173
  continueLabel,
155
174
  continuingLabel,
156
175
  countryField,
176
+ addressFormProps,
157
177
  leftColumn,
158
178
  rightColumn,
159
179
  t: tProp,
@@ -267,6 +287,7 @@
267
287
  </CheckoutSectionHeader>
268
288
  <CheckoutAddressForm
269
289
  bind:this={shippingFormRef}
290
+ {...addressFormProps}
270
291
  bind:address={shippingAddress}
271
292
  label="shipping"
272
293
  errors={shippingErrors}
@@ -293,6 +314,7 @@
293
314
  </CheckoutSectionHeader>
294
315
  <CheckoutAddressForm
295
316
  bind:this={billingFormRef}
317
+ {...addressFormProps}
296
318
  bind:address={billingAddress}
297
319
  label="billing"
298
320
  errors={billingErrors}
@@ -3,6 +3,7 @@ import type { HTMLAttributes } from "svelte/elements";
3
3
  import type { TranslateFn } from "../../types.js";
4
4
  import type { CheckoutAddressData, CheckoutDeliveryOption, CheckoutOrderData, CheckoutStep, CheckoutValidationError } from "./_internal/checkout-types.js";
5
5
  import type { NotificationsStack } from "../Notifications/notifications-stack.svelte.js";
6
+ import type { Props as CheckoutAddressFormProps } from "./CheckoutAddressForm.svelte";
6
7
  export interface Props extends Omit<HTMLAttributes<HTMLDivElement>, "children"> {
7
8
  /** Order data (for totals display in sidebar) */
8
9
  order: CheckoutOrderData;
@@ -50,6 +51,18 @@ export interface Props extends Omit<HTMLAttributes<HTMLDivElement>, "children">
50
51
  id: string;
51
52
  }
52
53
  ]>;
54
+ /**
55
+ * Props forwarded to both inner `CheckoutAddressForm` instances (shipping
56
+ * and, when visible, billing). Use this to configure `phoneFieldProps`,
57
+ * `countryFieldProps`, `preferredCountries`, `countryList`, `countryNames`,
58
+ * `requiredFields`, or `fields` without replacing the entire left column
59
+ * via the `leftColumn` snippet.
60
+ *
61
+ * Structural props that `CheckoutShippingStep` owns (`address`, `errors`,
62
+ * `label`, `countryField`, `t`, `unstyled`, `el`) cannot be overridden via
63
+ * this object — they are applied after the spread.
64
+ */
65
+ addressFormProps?: Partial<Omit<CheckoutAddressFormProps, "address" | "errors" | "label" | "countryField" | "t" | "unstyled" | "el">>;
53
66
  /** Override left column entirely */
54
67
  leftColumn?: Snippet;
55
68
  /** Override right column entirely */
@@ -52,7 +52,11 @@
52
52
  const preferredSet = new Set(preferredCountries?.map((c) => c.toUpperCase()) ?? []);
53
53
 
54
54
  if (preferredSet.size > 0) {
55
- const preferred = countryList.filter((c) => preferredSet.has(c.iso));
55
+ // Preserve the order given in `preferredCountries`.
56
+ const order = preferredCountries!.map((c) => c.toUpperCase());
57
+ const preferred = order
58
+ .map((iso) => countryList.find((c) => c.iso === iso))
59
+ .filter((c): c is Country => !!c);
56
60
  preferred.forEach((c) => result.push(countryToItem(c)));
57
61
  if (preferred.length > 0) {
58
62
  result.push({ type: "divider" });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "3.94.2",
3
+ "version": "3.94.4",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && pnpm run prepack",