@fluid-app/portal-sdk 0.1.447 → 0.1.449

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.
@@ -15,6 +15,7 @@ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
15
15
  import { z } from "zod";
16
16
  import { AlignCenter, AlignJustify, AlignLeft, AlignRight, Calendar, Check, ChevronLeft, ChevronRight, CircleCheck, Copy, EllipsisVertical, List, ListOrdered, ListTodo, Loader, Mail, MapPin, MoreHorizontal, Paperclip, Pencil, Phone, Plus, Search, Settings, StickyNote, Trash2, Users, X } from "lucide-react";
17
17
  import { FormProvider, useFormContext, useWatch } from "react-hook-form";
18
+ import { MobileBottomSheet } from "@fluid-app/ui-components/components/MobileBottomSheet";
18
19
  import { Combobox } from "@fluid-app/ui-components/components/Combobox";
19
20
  //#region ../../platform/api-client-core/src/parse-api-errors.ts
20
21
  /**
@@ -198,6 +199,22 @@ function parseApiErrors(error, fallback) {
198
199
  return appendRequestId(description ?? fallback, requestId);
199
200
  }
200
201
  //#endregion
202
+ //#region ../react/src/shell/use-mobile.ts
203
+ const MOBILE_BREAKPOINT$1 = 768;
204
+ function useIsMobile$1() {
205
+ const [isMobile, setIsMobile] = useState(false);
206
+ useEffect(() => {
207
+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT$1 - 1}px)`);
208
+ const onChange = () => {
209
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT$1);
210
+ };
211
+ mql.addEventListener("change", onChange);
212
+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT$1);
213
+ return () => mql.removeEventListener("change", onChange);
214
+ }, []);
215
+ return isMobile;
216
+ }
217
+ //#endregion
201
218
  //#region ../../contacts/ui/src/portal/hooks/groups/invalidate-contact-caches.ts
202
219
  function invalidateContactCaches(queryClient) {
203
220
  queryClient.invalidateQueries({ queryKey: CONTACTS_QUERY_KEYS.all("contacts") });
@@ -1210,6 +1227,7 @@ const ContactDetailsForm = ({ className, countries = DEFAULT_COUNTRIES, renderAv
1210
1227
  }) }), /* @__PURE__ */ jsx(SelectContent, {
1211
1228
  position: "popper",
1212
1229
  sideOffset: 4,
1230
+ className: "z-[1060]",
1213
1231
  children: effectiveStatusOptions.map((opt) => /* @__PURE__ */ jsx(SelectItem, {
1214
1232
  value: opt.value,
1215
1233
  children: opt.name
@@ -1305,7 +1323,8 @@ const ContactDetailsForm = ({ className, countries = DEFAULT_COUNTRIES, renderAv
1305
1323
  })),
1306
1324
  value: field.value ?? "",
1307
1325
  onValueChange: field.onChange,
1308
- placeholder: t("placeholder_country")
1326
+ placeholder: t("placeholder_country"),
1327
+ zIndex: 1060
1309
1328
  }) }),
1310
1329
  /* @__PURE__ */ jsx(FormMessage, {})
1311
1330
  ] })
@@ -4586,7 +4605,8 @@ const CREATE_DEFAULT_VALUES = {
4586
4605
  metadata: {},
4587
4606
  affiliate: {}
4588
4607
  };
4589
- function ContactCreateView({ onNavigate, onCreateContact }) {
4608
+ function ContactCreateView({ onNavigate, onCreateContact, asSheet = false }) {
4609
+ const { t } = useContactsTranslation();
4590
4610
  const formRef = useRef(null);
4591
4611
  const { locale } = useActiveLocale();
4592
4612
  const countriesAdapter = useCountriesApi();
@@ -4619,13 +4639,42 @@ function ContactCreateView({ onNavigate, onCreateContact }) {
4619
4639
  if (affiliate && Object.keys(affiliate).length > 0) payload.affiliate = affiliate;
4620
4640
  mutate(payload);
4621
4641
  }, () => {}), [methods, mutate]);
4642
+ const handleNavigateToList = useCallback(() => {
4643
+ onNavigate({
4644
+ view: "browse",
4645
+ selectedContactId: null
4646
+ });
4647
+ }, [onNavigate]);
4648
+ if (asSheet) return /* @__PURE__ */ jsx(MobileBottomSheet, {
4649
+ open: true,
4650
+ onOpenChange: (nextOpen) => {
4651
+ if (!nextOpen) handleNavigateToList();
4652
+ },
4653
+ title: t("breadcrumb_new"),
4654
+ children: /* @__PURE__ */ jsx(FormProvider, {
4655
+ ...methods,
4656
+ children: /* @__PURE__ */ jsxs("form", {
4657
+ ref: formRef,
4658
+ onSubmit,
4659
+ className: "space-y-6 px-2 pb-2",
4660
+ children: [/* @__PURE__ */ jsx(ContactDetailsForm, { countries: countryOptions }), /* @__PURE__ */ jsxs("div", {
4661
+ className: "flex justify-end gap-2",
4662
+ children: [/* @__PURE__ */ jsx(Button, {
4663
+ type: "button",
4664
+ variant: "outline",
4665
+ onClick: handleNavigateToList,
4666
+ children: t("cancel")
4667
+ }), /* @__PURE__ */ jsx(Button, {
4668
+ type: "submit",
4669
+ disabled: mutation.isPending,
4670
+ children: mutation.isPending ? t("adding") : t("add_contact")
4671
+ })]
4672
+ })]
4673
+ })
4674
+ })
4675
+ });
4622
4676
  return /* @__PURE__ */ jsx(ContactCreateScreen, {
4623
- onNavigateToList: useCallback(() => {
4624
- onNavigate({
4625
- view: "browse",
4626
- selectedContactId: null
4627
- });
4628
- }, [onNavigate]),
4677
+ onNavigateToList: handleNavigateToList,
4629
4678
  onSubmit: () => formRef.current?.requestSubmit(),
4630
4679
  isPending: mutation.isPending,
4631
4680
  children: /* @__PURE__ */ jsx(FormProvider, {
@@ -4645,6 +4694,7 @@ function ContactCreateView({ onNavigate, onCreateContact }) {
4645
4694
  function ContactsScreen({ onContactSelect, onCreateContact, background, textColor, accentColor, padding, borderRadius, defaultViewMode, ...divProps }) {
4646
4695
  const { currentSlug, navigate } = useAppNavigation();
4647
4696
  const subPage = currentSlug.split("/")[1];
4697
+ const isMobile = useIsMobile$1();
4648
4698
  const [nav, setNav] = useState({
4649
4699
  view: "browse",
4650
4700
  selectedContactId: null
@@ -4668,6 +4718,10 @@ function ContactsScreen({ onContactSelect, onCreateContact, background, textColo
4668
4718
  const handleManageGroups = useCallback(() => {
4669
4719
  navigate("contacts/manage-groups");
4670
4720
  }, [navigate]);
4721
+ const handleCreateNavigate = useCallback((state) => {
4722
+ setNav(state);
4723
+ if (state.view === "browse" && state.selectedContactId) setHighlightContactId(state.selectedContactId);
4724
+ }, []);
4671
4725
  const [createGroupOpen, setCreateGroupOpen] = useState(false);
4672
4726
  const [highlightGroupName, setHighlightGroupName] = useState(null);
4673
4727
  useEffect(() => {
@@ -4690,21 +4744,22 @@ function ContactsScreen({ onContactSelect, onCreateContact, background, textColo
4690
4744
  });
4691
4745
  navigate("contacts");
4692
4746
  }
4693
- }) : nav.view === "new" ? /* @__PURE__ */ jsx(ContactCreateView, {
4694
- onNavigate: (state) => {
4695
- setNav(state);
4696
- if (state.view === "browse" && state.selectedContactId) setHighlightContactId(state.selectedContactId);
4697
- },
4747
+ }) : nav.view === "new" && !isMobile ? /* @__PURE__ */ jsx(ContactCreateView, {
4748
+ onNavigate: handleCreateNavigate,
4698
4749
  onCreateContact
4699
- }) : /* @__PURE__ */ jsx(ContactBrowseView, {
4700
- selectedContactId: nav.selectedContactId,
4750
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ContactBrowseView, {
4751
+ selectedContactId: nav.view === "browse" ? nav.selectedContactId : null,
4701
4752
  highlightContactId,
4702
4753
  onSelect: handleSelect,
4703
4754
  onAdd: handleAdd,
4704
4755
  onManageGroups: handleManageGroups,
4705
4756
  onCreateGroup: handleCreateGroup,
4706
4757
  highlightGroupName
4707
- }), /* @__PURE__ */ jsx(GroupDialog, {
4758
+ }), nav.view === "new" && isMobile ? /* @__PURE__ */ jsx(ContactCreateView, {
4759
+ asSheet: true,
4760
+ onNavigate: handleCreateNavigate,
4761
+ onCreateContact
4762
+ }) : null] }), /* @__PURE__ */ jsx(GroupDialog, {
4708
4763
  mode: "create",
4709
4764
  open: createGroupOpen,
4710
4765
  onOpenChange: (open) => setCreateGroupOpen(open),
@@ -4724,6 +4779,6 @@ const contactsScreenPropertySchema = {
4724
4779
  fields: []
4725
4780
  };
4726
4781
  //#endregion
4727
- export { ContactsScreen_exports as n, contactsScreenPropertySchema as r, ContactsScreen as t };
4782
+ export { useIsMobile$1 as i, ContactsScreen_exports as n, contactsScreenPropertySchema as r, ContactsScreen as t };
4728
4783
 
4729
- //# sourceMappingURL=ContactsScreen-Ds-J6GFM.mjs.map
4784
+ //# sourceMappingURL=ContactsScreen-DjMBu144.mjs.map