@marianmeres/stuic 3.83.3 → 3.84.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.
@@ -28,6 +28,7 @@
28
28
  name?: boolean;
29
29
  street?: boolean;
30
30
  city?: boolean;
31
+ state_or_region?: boolean;
31
32
  postal_code?: boolean;
32
33
  country?: boolean;
33
34
  phone?: boolean;
@@ -163,8 +164,8 @@
163
164
  />
164
165
  {/if}
165
166
 
166
- <!-- City + Postal Code (2-column grid) -->
167
- {#if fields?.city !== false || fields?.postal_code !== false}
167
+ <!-- City + State/Region + Postal Code (responsive 2- or 3-column grid) -->
168
+ {#if fields?.city !== false || fields?.state_or_region !== false || fields?.postal_code !== false}
168
169
  <div class={unstyled ? undefined : "stuic-checkout-address-row"}>
169
170
  {#if fields?.city !== false}
170
171
  <!-- svelte-ignore binding_property_non_reactive -->
@@ -183,6 +184,23 @@
183
184
  }}
184
185
  />
185
186
  {/if}
187
+ {#if fields?.state_or_region !== false}
188
+ <!-- svelte-ignore binding_property_non_reactive -->
189
+ <FieldInput
190
+ bind:value={address.state_or_region}
191
+ label={t("checkout.address.state_or_region_label")}
192
+ labelLeftBreakpoint={0}
193
+ placeholder={t("checkout.address.state_or_region_placeholder")}
194
+ required={isRequired("state_or_region")}
195
+ name="{label}-state_or_region"
196
+ id="{label}-state_or_region"
197
+ validate={{
198
+ customValidator(val) {
199
+ return fieldError("state_or_region") || "";
200
+ },
201
+ }}
202
+ />
203
+ {/if}
186
204
  {#if fields?.postal_code !== false}
187
205
  <!-- svelte-ignore binding_property_non_reactive -->
188
206
  <FieldInput
@@ -238,7 +256,9 @@
238
256
  {#if fields?.phone !== false}
239
257
  <FieldPhoneNumber
240
258
  value={address.phone ?? ""}
241
- onChange={(v) => { address.phone = v; }}
259
+ onChange={(v) => {
260
+ address.phone = v;
261
+ }}
242
262
  label={t("checkout.address.phone_label")}
243
263
  placeholder={t("checkout.address.phone_placeholder")}
244
264
  required={isRequired("phone")}
@@ -20,6 +20,7 @@ export interface Props extends Omit<HTMLAttributes<HTMLFieldSetElement>, "childr
20
20
  name?: boolean;
21
21
  street?: boolean;
22
22
  city?: boolean;
23
+ state_or_region?: boolean;
23
24
  postal_code?: boolean;
24
25
  country?: boolean;
25
26
  phone?: boolean;
@@ -22,6 +22,10 @@
22
22
  grid-template-columns: 1fr;
23
23
  }
24
24
 
25
+ .stuic-checkout-address-row:has(> :nth-child(3)) {
26
+ grid-template-columns: repeat(3, 1fr);
27
+ }
28
+
25
29
  .stuic-checkout-guest-form[data-small] .stuic-checkout-guest-row,
26
30
  .stuic-checkout-address[data-small] .stuic-checkout-address-row {
27
31
  grid-template-columns: 1fr;
@@ -64,6 +64,8 @@ const DEFAULTS = {
64
64
  "checkout.address.street_placeholder": "",
65
65
  "checkout.address.city_label": "City",
66
66
  "checkout.address.city_placeholder": "",
67
+ "checkout.address.state_or_region_label": "State / Region",
68
+ "checkout.address.state_or_region_placeholder": "",
67
69
  "checkout.address.postal_code_label": "Postal Code",
68
70
  "checkout.address.postal_code_placeholder": "",
69
71
  "checkout.address.country_label": "Country",
@@ -14,6 +14,7 @@ export interface CheckoutAddressData {
14
14
  name: string;
15
15
  street: string;
16
16
  city: string;
17
+ state_or_region?: string;
17
18
  postal_code: string;
18
19
  country: string;
19
20
  phone?: string;
@@ -48,6 +48,7 @@ const ALL_ADDRESS_FIELDS = [
48
48
  "name",
49
49
  "street",
50
50
  "city",
51
+ "state_or_region",
51
52
  "postal_code",
52
53
  "country",
53
54
  "phone",
@@ -106,7 +107,15 @@ export function validateLoginForm(data, t) {
106
107
  // Empty data factories
107
108
  // ====================================================================
108
109
  export function createEmptyAddress() {
109
- return { name: "", street: "", city: "", postal_code: "", country: "", phone: "" };
110
+ return {
111
+ name: "",
112
+ street: "",
113
+ city: "",
114
+ state_or_region: "",
115
+ postal_code: "",
116
+ country: "",
117
+ phone: "",
118
+ };
110
119
  }
111
120
  export function createEmptyCustomerFormData() {
112
121
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/stuic",
3
- "version": "3.83.3",
3
+ "version": "3.84.0",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && pnpm run prepack",
@@ -88,7 +88,7 @@
88
88
  "@marianmeres/parse-boolean": "^2.1.0",
89
89
  "@marianmeres/ticker": "^1.17.1",
90
90
  "@marianmeres/tree": "^2.3.0",
91
- "libphonenumber-js": "^1.13.1",
91
+ "libphonenumber-js": "^1.13.2",
92
92
  "runed": "^0.23.4",
93
93
  "tailwind-merge": "^3.6.0"
94
94
  }