@overmap-ai/core 1.0.38-component-fields.4 → 1.0.38-component-fields.5

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.
@@ -5449,7 +5449,6 @@ class UserFormService extends BaseApiService {
5449
5449
  ...componentType && { component_type: componentType },
5450
5450
  ...ownerAttrs
5451
5451
  };
5452
- console.log(retForm);
5453
5452
  const { payloadWithoutImage, images } = await separateImageFromFields(offlineRevisionPayload);
5454
5453
  const retRevision = {
5455
5454
  ...payloadWithoutImage,
@@ -10846,19 +10845,24 @@ const FieldBuilder = memo((props) => {
10846
10845
  const { parentPath, index: index2, initial, conditionalSourceFields } = props;
10847
10846
  const { values, setFieldValue, errors } = useFormikContext();
10848
10847
  const fieldTypeItems = useFieldTypeItems();
10848
+ const containerRef = useRef(null);
10849
10849
  const RADIX_SM_MIN_WIDTH = 576;
10850
- const [isLargeScreen, setIsLargeScreen] = useState(
10851
- window.matchMedia(`(min-width: ${RADIX_SM_MIN_WIDTH}px)`).matches
10850
+ const [isLargeContainer, setIsLargeContainer] = useState(
10851
+ containerRef.current && containerRef.current.getBoundingClientRect().width >= RADIX_SM_MIN_WIDTH
10852
10852
  );
10853
10853
  useEffect(() => {
10854
- const mediaQuery = window.matchMedia(`(min-width: ${RADIX_SM_MIN_WIDTH}px)`);
10855
- const handleMediaQueryChange = (event) => {
10856
- setIsLargeScreen(event.matches);
10857
- };
10858
- mediaQuery.addEventListener("change", handleMediaQueryChange);
10859
- return () => {
10860
- mediaQuery.removeEventListener("change", handleMediaQueryChange);
10861
- };
10854
+ const container = containerRef.current;
10855
+ if (container) {
10856
+ const observer = new ResizeObserver((entries) => {
10857
+ if (entries[0]) {
10858
+ setIsLargeContainer(entries[0].contentRect.width >= RADIX_SM_MIN_WIDTH);
10859
+ }
10860
+ });
10861
+ observer.observe(container);
10862
+ return () => {
10863
+ observer.disconnect();
10864
+ };
10865
+ }
10862
10866
  }, []);
10863
10867
  const [resolvedImage, setResolvedImage] = useState(void 0);
10864
10868
  const [showImagePreview, setShowImagePreview] = useState(false);
@@ -10935,7 +10939,7 @@ const FieldBuilder = memo((props) => {
10935
10939
  const fieldObject = fieldCls.getFieldCreationSchema(
10936
10940
  `${parentPath}.${index2}`
10937
10941
  );
10938
- if (isLargeScreen) {
10942
+ if (isLargeContainer) {
10939
10943
  directlyShownFields2 = [
10940
10944
  ...directlyShownFields2,
10941
10945
  ...fieldObject.filter((field) => field.showDirectly).map((field) => field.field)
@@ -10949,7 +10953,7 @@ const FieldBuilder = memo((props) => {
10949
10953
  }
10950
10954
  }
10951
10955
  return [directlyShownFields2, popoverFields2];
10952
- }, [fieldCls, conditionalSourceFields, parentPath, index2, isLargeScreen]);
10956
+ }, [fieldCls, conditionalSourceFields, parentPath, index2, isLargeContainer]);
10953
10957
  const directlyShownInputs = useFieldInputs(directlyShownFields, {
10954
10958
  formId,
10955
10959
  disabled: false,
@@ -10969,7 +10973,7 @@ const FieldBuilder = memo((props) => {
10969
10973
  });
10970
10974
  const deserializedField = useMemo(() => deserialize(initial), [initial]);
10971
10975
  const previewInput2 = useFieldInput(deserializedField, { formId, disabled: true, showInputOnly: true });
10972
- return /* @__PURE__ */ jsxs(Flex, { align: "center", grow: "1", children: [
10976
+ return /* @__PURE__ */ jsxs(Flex, { ref: containerRef, align: "center", grow: "1", children: [
10973
10977
  /* @__PURE__ */ jsxs(Flex, { direction: "column", width: "100%", children: [
10974
10978
  fieldCls === FieldSection && /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: "1", children: [
10975
10979
  directlyShownFields.length > 0 && directlyShownInputs,