@drawbridge/components 0.0.71 → 0.0.73

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.
@@ -1098,7 +1098,7 @@ var Advertisement = ({
1098
1098
  "span",
1099
1099
  {
1100
1100
  ...{
1101
- className: "block relative aspect-square overflow-hidden" + ((file == null ? void 0 : file.sizes) ? "" : " bg-gray-light"),
1101
+ className: "block relative aspect-square overflow-hidden" + (assetNode ? "" : " bg-gray-light"),
1102
1102
  style: {
1103
1103
  borderRadius: imageRadius
1104
1104
  }
@@ -1185,8 +1185,9 @@ var Advertisement = ({
1185
1185
  )
1186
1186
  );
1187
1187
  }
1188
+ const src = (0, import_cdn2.cdnSrc)(file, "400x400", file == null ? void 0 : file.updatedAt);
1188
1189
  return card(
1189
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1190
+ src ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1190
1191
  ImageComponent,
1191
1192
  {
1192
1193
  ...{
@@ -1195,11 +1196,11 @@ var Advertisement = ({
1195
1196
  fill: true,
1196
1197
  priority: false,
1197
1198
  sizes: "100%",
1198
- src: (0, import_cdn2.cdnSrc)(file, "400x400", file == null ? void 0 : file.updatedAt)
1199
+ src
1199
1200
  }
1200
1201
  },
1201
1202
  file == null ? void 0 : file.id
1202
- )
1203
+ ) : null
1203
1204
  );
1204
1205
  };
1205
1206
  var advertisement_default = Advertisement;
@@ -115,7 +115,7 @@ var Advertisement = ({
115
115
  "span",
116
116
  {
117
117
  ...{
118
- className: "block relative aspect-square overflow-hidden" + ((file == null ? void 0 : file.sizes) ? "" : " bg-gray-light"),
118
+ className: "block relative aspect-square overflow-hidden" + (assetNode ? "" : " bg-gray-light"),
119
119
  style: {
120
120
  borderRadius: imageRadius
121
121
  }
@@ -202,8 +202,9 @@ var Advertisement = ({
202
202
  )
203
203
  );
204
204
  }
205
+ const src = cdnSrc(file, "400x400", file == null ? void 0 : file.updatedAt);
205
206
  return card(
206
- /* @__PURE__ */ jsx(
207
+ src ? /* @__PURE__ */ jsx(
207
208
  ImageComponent,
208
209
  {
209
210
  ...{
@@ -212,11 +213,11 @@ var Advertisement = ({
212
213
  fill: true,
213
214
  priority: false,
214
215
  sizes: "100%",
215
- src: cdnSrc(file, "400x400", file == null ? void 0 : file.updatedAt)
216
+ src
216
217
  }
217
218
  },
218
219
  file == null ? void 0 : file.id
219
- )
220
+ ) : null
220
221
  );
221
222
  };
222
223
  var advertisement_default = Advertisement;
@@ -104,12 +104,18 @@ var InputPhone = ({
104
104
  (0, import_react.useEffect)(
105
105
  () => {
106
106
  if (value == null ? void 0 : value.country) return;
107
+ const detected = (0, import_phone.detectCountry)(value == null ? void 0 : value.number);
108
+ if (detected && countries.includes(detected)) {
109
+ setCountry(detected);
110
+ return;
111
+ }
112
+ ;
107
113
  const tags = [navigator.language, ...navigator.languages || []];
108
- const detected = tags.map((tag) => {
114
+ const locale = tags.map((tag) => {
109
115
  var _a2, _b2;
110
116
  return (_b2 = (_a2 = tag == null ? void 0 : tag.split("-")) == null ? void 0 : _a2[1]) == null ? void 0 : _b2.toUpperCase();
111
117
  }).find((code) => code && countries.includes(code));
112
- if (detected) setCountry(detected);
118
+ if (locale) setCountry(locale);
113
119
  },
114
120
  []
115
121
  );
@@ -221,9 +227,19 @@ var InputPhone = ({
221
227
  ...{
222
228
  "aria-label": "Phone Number",
223
229
  className: "input w-full border-none focus:outline-none focus:ring-0 focus:border-inherit",
224
- onChange: (val) => setNumber(val),
230
+ onChange: (val) => {
231
+ setNumber(val);
232
+ const detected = (0, import_phone.detectCountry)(val);
233
+ if (detected && countries.includes(detected)) setCountry(detected);
234
+ },
225
235
  style: inputPhoneStyle(style),
226
236
  value: number,
237
+ // country-mode pins the input to the selected calling code, so
238
+ // detection can only follow countries SHARING that code (US/CA
239
+ // on +1) — any other '+xx' the visitor types is discarded by the
240
+ // library before it reaches onChange. Reaching every country
241
+ // needs defaultCountry mode instead, which unpins the prefix but
242
+ // changes the field to national-format display.
227
243
  ...country && {
228
244
  country,
229
245
  international: true,
@@ -9,7 +9,7 @@ import {
9
9
  // components/input-phone.js
10
10
  import { useEffect, useState } from "react";
11
11
  import Input from "react-phone-number-input/input";
12
- import { isValid } from "@drawbridge/drawbridge-utils/phone";
12
+ import { detectCountry, isValid } from "@drawbridge/drawbridge-utils/phone";
13
13
  import { jsx, jsxs } from "react/jsx-runtime";
14
14
  var isValidPhone = (number = "", country = "") => {
15
15
  const valid = isValid(number, country);
@@ -27,12 +27,18 @@ var InputPhone = ({
27
27
  useEffect(
28
28
  () => {
29
29
  if (value == null ? void 0 : value.country) return;
30
+ const detected = detectCountry(value == null ? void 0 : value.number);
31
+ if (detected && countries.includes(detected)) {
32
+ setCountry(detected);
33
+ return;
34
+ }
35
+ ;
30
36
  const tags = [navigator.language, ...navigator.languages || []];
31
- const detected = tags.map((tag) => {
37
+ const locale = tags.map((tag) => {
32
38
  var _a2, _b2;
33
39
  return (_b2 = (_a2 = tag == null ? void 0 : tag.split("-")) == null ? void 0 : _a2[1]) == null ? void 0 : _b2.toUpperCase();
34
40
  }).find((code) => code && countries.includes(code));
35
- if (detected) setCountry(detected);
41
+ if (locale) setCountry(locale);
36
42
  },
37
43
  []
38
44
  );
@@ -144,9 +150,19 @@ var InputPhone = ({
144
150
  ...{
145
151
  "aria-label": "Phone Number",
146
152
  className: "input w-full border-none focus:outline-none focus:ring-0 focus:border-inherit",
147
- onChange: (val) => setNumber(val),
153
+ onChange: (val) => {
154
+ setNumber(val);
155
+ const detected = detectCountry(val);
156
+ if (detected && countries.includes(detected)) setCountry(detected);
157
+ },
148
158
  style: inputPhoneStyle(style),
149
159
  value: number,
160
+ // country-mode pins the input to the selected calling code, so
161
+ // detection can only follow countries SHARING that code (US/CA
162
+ // on +1) — any other '+xx' the visitor types is discarded by the
163
+ // library before it reaches onChange. Reaching every country
164
+ // needs defaultCountry mode instead, which unpins the prefix but
165
+ // changes the field to national-format display.
150
166
  ...country && {
151
167
  country,
152
168
  international: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drawbridge/components",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "exports": {
5
5
  "./advertisement": {
6
6
  "types": "./types/advertisement.d.ts",
@@ -407,7 +407,7 @@
407
407
  "build": ". \"$HOME/.nvm/nvm.sh\" && nvm use && tsup && node --test && npm publish"
408
408
  },
409
409
  "peerDependencies": {
410
- "@drawbridge/drawbridge-utils": ">=0.0.61",
410
+ "@drawbridge/drawbridge-utils": ">=0.0.118",
411
411
  "@drawbridge/shopify": ">=0.0.8",
412
412
  "next": ">=14",
413
413
  "react": ">=18"
@@ -415,7 +415,7 @@
415
415
  "devDependencies": {
416
416
  "@types/react": "18.0.0",
417
417
  "tsup": "8.5.1",
418
- "@drawbridge/drawbridge-agents": "0.1.33"
418
+ "@drawbridge/drawbridge-agents": "0.1.40"
419
419
  },
420
420
  "dependencies": {
421
421
  "embla-carousel-fade": "8.6.0",