@fluid-app/portal-sdk 0.1.351 → 0.1.352

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.
Files changed (51) hide show
  1. package/dist/{AddressAutocompleteInput-C2Wx9yrV.cjs → AddressAutocompleteInput-BQz2jaUO.cjs} +127 -72
  2. package/dist/AddressAutocompleteInput-BQz2jaUO.cjs.map +1 -0
  3. package/dist/{AddressAutocompleteInput-CgOFJKwF.mjs → AddressAutocompleteInput-Dds2GjGt.mjs} +127 -72
  4. package/dist/AddressAutocompleteInput-Dds2GjGt.mjs.map +1 -0
  5. package/dist/{FluidProvider-DvHJZkGi.cjs → FluidProvider-CMfpLju8.cjs} +38 -12
  6. package/dist/FluidProvider-CMfpLju8.cjs.map +1 -0
  7. package/dist/{FluidProvider-B4Za_Bnw.mjs → FluidProvider-tPt9UpYz.mjs} +34 -14
  8. package/dist/FluidProvider-tPt9UpYz.mjs.map +1 -0
  9. package/dist/{MessagingScreen-CCVF9paI.mjs → MessagingScreen-8hyxHThw.mjs} +2 -2
  10. package/dist/{MessagingScreen-CCVF9paI.mjs.map → MessagingScreen-8hyxHThw.mjs.map} +1 -1
  11. package/dist/{MessagingScreen-B6kMcx8v.cjs → MessagingScreen-CaSUJhJc.cjs} +2 -2
  12. package/dist/{MessagingScreen-B3LmRgr4.mjs → MessagingScreen-CpMlE96f.mjs} +2 -2
  13. package/dist/{MessagingScreen-DQYJZhz6.cjs → MessagingScreen-CvyQL50O.cjs} +2 -2
  14. package/dist/{MessagingScreen-DQYJZhz6.cjs.map → MessagingScreen-CvyQL50O.cjs.map} +1 -1
  15. package/dist/{OrdersScreen-DCbX1m9M.cjs → OrdersScreen-BGVPWrEg.cjs} +2 -2
  16. package/dist/{OrdersScreen-ze31P1y2.mjs → OrdersScreen-BZ2iBfWQ.mjs} +2 -2
  17. package/dist/{OrdersScreen-BY3EQX7P.cjs → OrdersScreen-Ckt7uChL.cjs} +2 -2
  18. package/dist/{OrdersScreen-BY3EQX7P.cjs.map → OrdersScreen-Ckt7uChL.cjs.map} +1 -1
  19. package/dist/{OrdersScreen-D9ztzvIZ.mjs → OrdersScreen-DsKspc_8.mjs} +2 -2
  20. package/dist/{OrdersScreen-D9ztzvIZ.mjs.map → OrdersScreen-DsKspc_8.mjs.map} +1 -1
  21. package/dist/{ProfileScreen-C8oqPt_i.cjs → ProfileScreen-21MnRuNH.cjs} +7 -3
  22. package/dist/ProfileScreen-21MnRuNH.cjs.map +1 -0
  23. package/dist/{ProfileScreen-BKAjNpTa.mjs → ProfileScreen-DA3vl5EU.mjs} +7 -3
  24. package/dist/ProfileScreen-DA3vl5EU.mjs.map +1 -0
  25. package/dist/{ProfileScreen-BDVGVcuz.cjs → ProfileScreen-DzxUqJJD.cjs} +3 -3
  26. package/dist/{ProfileScreen-DYQklavp.mjs → ProfileScreen-Uw_6u6Ew.mjs} +3 -3
  27. package/dist/{ShopScreen-IJalLKdV.mjs → ShopScreen-CbeH9wRR.mjs} +2 -2
  28. package/dist/{ShopScreen-IJalLKdV.mjs.map → ShopScreen-CbeH9wRR.mjs.map} +1 -1
  29. package/dist/{ShopScreen-BO1eOqyu.cjs → ShopScreen-Cme3j61f.cjs} +2 -2
  30. package/dist/{ShopScreen-BO1eOqyu.cjs.map → ShopScreen-Cme3j61f.cjs.map} +1 -1
  31. package/dist/{ShopScreen-DY10zu6I.mjs → ShopScreen-D2LDk2xr.mjs} +2 -2
  32. package/dist/{ShopScreen-PMwvVuff.cjs → ShopScreen-D6xtA_0b.cjs} +2 -2
  33. package/dist/{SubscriptionsScreen-d527tZfc.mjs → SubscriptionsScreen-Br_gugTG.mjs} +8 -3
  34. package/dist/SubscriptionsScreen-Br_gugTG.mjs.map +1 -0
  35. package/dist/{SubscriptionsScreen-BbUhL-zf.mjs → SubscriptionsScreen-CG3OldGE.mjs} +3 -3
  36. package/dist/{SubscriptionsScreen-DBbYVWWt.cjs → SubscriptionsScreen-CvM68asd.cjs} +3 -3
  37. package/dist/{SubscriptionsScreen-CihWk-dF.cjs → SubscriptionsScreen-HbrDZhaX.cjs} +8 -3
  38. package/dist/SubscriptionsScreen-HbrDZhaX.cjs.map +1 -0
  39. package/dist/index.cjs +17 -17
  40. package/dist/index.d.cts.map +1 -1
  41. package/dist/index.d.mts.map +1 -1
  42. package/dist/index.mjs +17 -17
  43. package/package.json +16 -15
  44. package/dist/AddressAutocompleteInput-C2Wx9yrV.cjs.map +0 -1
  45. package/dist/AddressAutocompleteInput-CgOFJKwF.mjs.map +0 -1
  46. package/dist/FluidProvider-B4Za_Bnw.mjs.map +0 -1
  47. package/dist/FluidProvider-DvHJZkGi.cjs.map +0 -1
  48. package/dist/ProfileScreen-BKAjNpTa.mjs.map +0 -1
  49. package/dist/ProfileScreen-C8oqPt_i.cjs.map +0 -1
  50. package/dist/SubscriptionsScreen-CihWk-dF.cjs.map +0 -1
  51. package/dist/SubscriptionsScreen-d527tZfc.mjs.map +0 -1
@@ -1,4 +1,4 @@
1
- import { z as useAddressAutocompleteApi } from "./FluidProvider-B4Za_Bnw.mjs";
1
+ import { B as useAddressAutocompleteApi, z as useAddressFieldsApiOptional } from "./FluidProvider-tPt9UpYz.mjs";
2
2
  import { a as useActiveLocale, n as createDomainTranslations, r as useDomainDict, t as createStaticDictAdapter } from "./static-dict-adapter-DRBq3ndO.mjs";
3
3
  import { t as createTranslationContext } from "./translation-api-context-factory-DFr9yJ6Q.mjs";
4
4
  import { B as DropdownMenuContent, C as SelectContent, E as SelectValue, G as DropdownMenuSeparator, On as useZodForm, Q as DialogContent, R as Label, S as Select, T as SelectTrigger, V as DropdownMenuItem, X as Dialog, Y as DropdownMenuTrigger, Z as DialogClose, a as Textarea, et as DialogFooter, it as DialogTitle, k as Input, kn as cn, tt as DialogHeader, w as SelectItem, wn as Button, z as DropdownMenu } from "./src-CJw6JbdS.mjs";
@@ -1284,8 +1284,58 @@ const addressFormSchema = z.object({
1284
1284
  country_code: z.string().min(1, "Country is required"),
1285
1285
  default: z.boolean()
1286
1286
  });
1287
- function AddressFormDialog({ isOpen, onClose, selectedAddress, onSubmit, isSubmitting, countries = [], error, renderAddressAutocomplete, fetchStates, t, onDelete, isDeleting = false, defaultCountry = "US" }) {
1287
+ const STATIC_FIELD_ORDER = [
1288
+ "first_name",
1289
+ "last_name",
1290
+ "address1",
1291
+ "address2",
1292
+ "city",
1293
+ "state",
1294
+ "postal_code"
1295
+ ];
1296
+ const STATIC_LABELS = {
1297
+ first_name: "first_name",
1298
+ last_name: "last_name",
1299
+ address1: "address_line_1",
1300
+ address2: "address_line_2",
1301
+ city: "city",
1302
+ state: "state",
1303
+ postal_code: "zip_code"
1304
+ };
1305
+ function groupFields(fields) {
1306
+ const groups = [];
1307
+ let i = 0;
1308
+ while (i < fields.length) {
1309
+ const current = fields[i];
1310
+ const next = fields[i + 1];
1311
+ if (current === "first_name" && next === "last_name" || current === "last_name" && next === "first_name") {
1312
+ groups.push([current, next]);
1313
+ i += 2;
1314
+ continue;
1315
+ }
1316
+ const locationFields = new Set([
1317
+ "city",
1318
+ "state",
1319
+ "postal_code"
1320
+ ]);
1321
+ if (locationFields.has(current)) {
1322
+ const group = [current];
1323
+ while (i + group.length < fields.length && locationFields.has(fields[i + group.length])) group.push(fields[i + group.length]);
1324
+ if (group.length > 1) {
1325
+ groups.push(group);
1326
+ i += group.length;
1327
+ continue;
1328
+ }
1329
+ }
1330
+ groups.push([current]);
1331
+ i++;
1332
+ }
1333
+ return groups;
1334
+ }
1335
+ function AddressFormDialog({ isOpen, onClose, selectedAddress, onSubmit, isSubmitting, countries = [], error, renderAddressAutocomplete, fetchStates, t, onDelete, isDeleting = false, defaultCountry = "US", languageIso }) {
1288
1336
  const [confirmDelete, setConfirmDelete] = useState(false);
1337
+ const addressFieldsApi = useAddressFieldsApiOptional();
1338
+ const [bffFields, setBffFields] = useState(null);
1289
1339
  useEffect(() => {
1290
1340
  if (!isOpen) setConfirmDelete(false);
1291
1341
  }, [isOpen]);
@@ -1323,6 +1373,40 @@ function AddressFormDialog({ isOpen, onClose, selectedAddress, onSubmit, isSubmi
1323
1373
  name: "default"
1324
1374
  });
1325
1375
  const { stateOptions, config, handleCountryChange } = useCountryStates();
1376
+ useEffect(() => {
1377
+ if (!addressFieldsApi || !selectedCountryCode) return;
1378
+ let cancelled = false;
1379
+ setBffFields(null);
1380
+ addressFieldsApi.fetchAddressFields(selectedCountryCode, languageIso).then((response) => {
1381
+ if (!cancelled) setBffFields([...response.address_fields.fields]);
1382
+ }).catch(() => {
1383
+ if (!cancelled) setBffFields(null);
1384
+ });
1385
+ return () => {
1386
+ cancelled = true;
1387
+ };
1388
+ }, [
1389
+ addressFieldsApi,
1390
+ selectedCountryCode,
1391
+ languageIso
1392
+ ]);
1393
+ const fieldOrder = useMemo(() => {
1394
+ if (!bffFields) return STATIC_FIELD_ORDER;
1395
+ const bffOrder = bffFields.map((f) => f.field).filter((f) => STATIC_FIELD_ORDER.includes(f));
1396
+ const missing = STATIC_FIELD_ORDER.filter((f) => !bffOrder.includes(f));
1397
+ return [...bffOrder, ...missing];
1398
+ }, [bffFields]);
1399
+ const fieldGroups = useMemo(() => groupFields(fieldOrder), [fieldOrder]);
1400
+ const getFieldLabel = (fieldName) => {
1401
+ if (bffFields) {
1402
+ const bffField = bffFields.find((f) => f.field === fieldName);
1403
+ if (bffField) return bffField.label;
1404
+ }
1405
+ if (fieldName === "state" && config?.regionLabel) return t(config.regionLabel);
1406
+ if (fieldName === "postal_code" && config?.postalLabel) return t(config.postalLabel);
1407
+ const key = STATIC_LABELS[fieldName];
1408
+ return key ? t(key) : fieldName;
1409
+ };
1326
1410
  const countrySelectOptions = [...countries].map((country) => ({
1327
1411
  name: country.name,
1328
1412
  value: country.iso
@@ -1391,6 +1475,33 @@ function AddressFormDialog({ isOpen, onClose, selectedAddress, onSubmit, isSubmi
1391
1475
  default: data.default
1392
1476
  } });
1393
1477
  });
1478
+ const renderField = (fieldName, containerClassName) => {
1479
+ const label = getFieldLabel(fieldName);
1480
+ if (fieldName === "state" && stateSelectOptions.length > 0) return /* @__PURE__ */ jsx(FormComboboxField, {
1481
+ control,
1482
+ name: "state",
1483
+ label,
1484
+ placeholder: t("select_state"),
1485
+ options: stateSelectOptions,
1486
+ containerClassName,
1487
+ disabled: isSubmitting
1488
+ }, fieldName);
1489
+ if (fieldName === "address1" && renderAddressAutocomplete) return /* @__PURE__ */ jsx("div", {
1490
+ className: containerClassName,
1491
+ children: renderAddressAutocomplete({
1492
+ control,
1493
+ setValue,
1494
+ countryCode: selectedCountryCode
1495
+ })
1496
+ }, fieldName);
1497
+ return /* @__PURE__ */ jsx(FormTextField, {
1498
+ control,
1499
+ name: fieldName,
1500
+ label,
1501
+ containerClassName,
1502
+ disabled: isSubmitting
1503
+ }, fieldName);
1504
+ };
1394
1505
  return /* @__PURE__ */ jsx(Dialog, {
1395
1506
  open: isOpen,
1396
1507
  onOpenChange: (open) => !open && onClose(),
@@ -1403,76 +1514,20 @@ function AddressFormDialog({ isOpen, onClose, selectedAddress, onSubmit, isSubmi
1403
1514
  }) }),
1404
1515
  /* @__PURE__ */ jsxs("div", {
1405
1516
  className: "space-y-3 pt-2",
1406
- children: [
1407
- /* @__PURE__ */ jsx(FormComboboxField, {
1408
- control,
1409
- name: "country_code",
1410
- label: t("country"),
1411
- placeholder: t("select_an_option"),
1412
- options: countrySelectOptions,
1413
- disabled: isSubmitting
1414
- }),
1415
- /* @__PURE__ */ jsxs("div", {
1416
- className: "flex gap-3",
1417
- children: [/* @__PURE__ */ jsx(FormTextField, {
1418
- control,
1419
- name: "first_name",
1420
- label: t("first_name"),
1421
- containerClassName: "flex-1",
1422
- disabled: isSubmitting
1423
- }), /* @__PURE__ */ jsx(FormTextField, {
1424
- control,
1425
- name: "last_name",
1426
- label: t("last_name"),
1427
- containerClassName: "flex-1",
1428
- disabled: isSubmitting
1429
- })]
1430
- }),
1431
- renderAddressAutocomplete ? renderAddressAutocomplete({
1432
- control,
1433
- setValue,
1434
- countryCode: selectedCountryCode
1435
- }) : /* @__PURE__ */ jsx(FormTextField, {
1436
- control,
1437
- name: "address1",
1438
- label: t("address_line_1"),
1439
- disabled: isSubmitting
1440
- }),
1441
- /* @__PURE__ */ jsx(FormTextField, {
1442
- control,
1443
- name: "address2",
1444
- label: t("address_line_2"),
1445
- disabled: isSubmitting
1446
- }),
1447
- /* @__PURE__ */ jsxs("div", {
1517
+ children: [/* @__PURE__ */ jsx(FormComboboxField, {
1518
+ control,
1519
+ name: "country_code",
1520
+ label: t("country"),
1521
+ placeholder: t("select_an_option"),
1522
+ options: countrySelectOptions,
1523
+ disabled: isSubmitting
1524
+ }), fieldGroups.map((group) => {
1525
+ if (group.length === 1) return renderField(group[0]);
1526
+ return /* @__PURE__ */ jsx("div", {
1448
1527
  className: "flex gap-3",
1449
- children: [
1450
- /* @__PURE__ */ jsx(FormTextField, {
1451
- control,
1452
- name: "city",
1453
- label: t("city"),
1454
- containerClassName: "flex-1",
1455
- disabled: isSubmitting
1456
- }),
1457
- /* @__PURE__ */ jsx(FormComboboxField, {
1458
- control,
1459
- name: "state",
1460
- label: config?.regionLabel ? t(config.regionLabel) : t("state"),
1461
- placeholder: t("select_state"),
1462
- options: stateSelectOptions,
1463
- containerClassName: "flex-1",
1464
- disabled: isSubmitting
1465
- }),
1466
- /* @__PURE__ */ jsx(FormTextField, {
1467
- control,
1468
- name: "postal_code",
1469
- label: config?.postalLabel ? t(config.postalLabel) : t("zip_code"),
1470
- containerClassName: "flex-1",
1471
- disabled: isSubmitting
1472
- })
1473
- ]
1474
- })
1475
- ]
1528
+ children: group.map((fieldName) => renderField(fieldName, "flex-1"))
1529
+ }, group.join("-"));
1530
+ })]
1476
1531
  }),
1477
1532
  /* @__PURE__ */ jsxs("div", {
1478
1533
  className: "mt-4 flex flex-wrap items-center justify-between gap-3",
@@ -2375,4 +2430,4 @@ function AddressAutocompleteInput({ control, setValue, countryIso, addressLineFi
2375
2430
  //#endregion
2376
2431
  export { AddressFormDialog as a, PaymentIcon as c, UserInfoDialog as d, ConfirmActionDialog as f, useProfileTranslation as h, CreditCardFormDialog as i, getCardDisplayName as l, ProfileTranslationBridge as m, createFluidPayApiAdapter as n, EditPaymentMethodDialog as o, EllipsesDropdown as p, mapToFluidPayPaymentMethod as r, FluidPayCoreProvider as s, AddressAutocompleteInput as t, getCardExpiry as u };
2377
2432
 
2378
- //# sourceMappingURL=AddressAutocompleteInput-CgOFJKwF.mjs.map
2433
+ //# sourceMappingURL=AddressAutocompleteInput-Dds2GjGt.mjs.map