utopia-ui 3.0.100 → 3.0.101

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.
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import React__default, { useState, useEffect, cloneElement, useRef, useCallback, useMemo, useReducer, forwardRef, useImperativeHandle, Fragment as Fragment$2, useDebugValue, useLayoutEffect, createContext, useContext } from 'react';
4
4
  import { useNavigate, Link as Link$3, useLocation } from 'react-router-dom';
5
5
  import { toast } from 'react-toastify';
6
- import { g as useAuth, R as MapOverlayPage, V as TextInput, a2 as hashTagRegex, a3 as randomColor, ab as encodeTag, j as useAppState, n as useItems, _ as StartEndView, B as TextView, b as useHasUserPermission, W as useGetItemTags, X as ForwardRef$c, ad as DialogModal, Z as HeaderView, Q as ForwardRef$d, p as useAddFilterTag, Y as timeAgo, a4 as TagView, a5 as useUpdateItem, t as useSelectPosition, a0 as useRemoveItem, m as useTags, v as useSetSelectPosition, x as useClusterRef, o as useLeafletRefs, u as useLayers, ae as ForwardRef$e, a1 as PopupStartEndInput, U as TextAreaInput, q as decodeTag, $ as useAddItem, H as useAddTag } from './TagView-BNJqfuzN.js';
6
+ import { g as useAuth, R as MapOverlayPage, V as TextInput, a2 as hashTagRegex, a3 as randomColor, ab as encodeTag, j as useAppState, n as useItems, _ as StartEndView, B as TextView, b as useHasUserPermission, W as useGetItemTags, X as ForwardRef$c, ad as DialogModal, Z as HeaderView, Q as ForwardRef$d, p as useAddFilterTag, Y as timeAgo, a4 as TagView, a5 as useUpdateItem, t as useSelectPosition, a0 as useRemoveItem, m as useTags, v as useSetSelectPosition, x as useClusterRef, o as useLeafletRefs, u as useLayers, ae as ForwardRef$e, a1 as PopupStartEndInput, U as TextAreaInput, q as decodeTag, $ as useAddItem, H as useAddTag } from './TagView-CUbZOg0C.js';
7
7
  import { LatLng } from 'leaflet';
8
8
  import axios from 'axios';
9
9
  import 'react-inlinesvg';
@@ -414,14 +414,24 @@ const CrowdfundingView = ({ item }) => {
414
414
  return (jsx("div", { className: 'tw:mx-6 tw:mb-6', children: jsxs("div", { className: 'tw:card tw:bg-base-200 tw:w-fit tw:max-w-full tw:shadow', children: [jsxs("div", { className: 'tw:stats tw:bg-base-200 tw:stats-horizontal tw:rounded-b-none', children: [jsxs("div", { className: 'tw:stat tw:p-3', children: [jsx("div", { className: 'tw:stat-title', children: "Current Balance" }), jsx("div", { className: 'tw:stat-value tw:text-xl lg:tw:text-3xl', children: formatCurrency(currentBalance, currency) })] }), jsxs("div", { className: 'tw:stat tw:p-3', children: [jsx("div", { className: 'tw:stat-title', children: "Received" }), jsx("div", { className: 'tw:stat-value tw:text-green-500 tw:text-xl lg:tw:text-3xl', children: formatCurrency(stats.totalAmountReceived.valueInCents, currency) })] }), jsxs("div", { className: 'tw:stat tw:p-3', children: [jsx("div", { className: 'tw:stat-title', children: "Spent" }), jsx("div", { className: 'tw:stat-value tw:text-red-500 tw:text-xl lg:tw:text-3xl', children: formatCurrency(stats.totalAmountReceived.valueInCents - currentBalance, currency) })] })] }), jsx("hr", { className: 'tw:border-1 tw:border-current/10 tw:border-dashed' }), jsxs("div", { className: 'tw:m-4 tw:items-center', children: [jsx("a", { href: `https://opencollective.com/${slug}/donate`, target: '_blank', rel: 'noreferrer', children: jsx("button", { className: 'tw:btn tw:btn-sm tw:btn-primary tw:float-right tw:ml-4', children: "Donate" }) }), jsxs("div", { className: 'tw:flex-1 tw:mr-4', children: ["Support", ' ', jsx("a", { className: 'tw:font-bold', href: `https://opencollective.com/${slug}`, target: '_blank', rel: 'noreferrer', children: data.account.name }), ' ', "on ", jsx("span", { className: 'tw:font-bold', children: "Open\u00A0Collective" })] })] })] }) }));
415
415
  };
416
416
 
417
+ const extensionMap = new Map([
418
+ ['image/jpeg', '.jpg'],
419
+ ['image/png', '.png'],
420
+ ]);
421
+ const getExtension = (type) => {
422
+ const extension = extensionMap.get(type);
423
+ if (extension)
424
+ return extension;
425
+ throw new Error(`Unsupported file type: ${type}`);
426
+ };
417
427
  const GalleryView = ({ item }) => {
418
428
  const [index, setIndex] = useState(-1);
419
429
  const appState = useAppState();
420
- const images = item.gallery?.map((i, j) => ({
421
- src: appState.assetsApi.url + `${i.directus_files_id.id}.jpg`,
422
- width: i.directus_files_id.width,
423
- height: i.directus_files_id.height,
424
- index: j,
430
+ const images = item.gallery?.map(({ directus_files_id: { id, type, width, height } }, index) => ({
431
+ src: `${appState.assetsApi.url}${id}${getExtension(type)}`,
432
+ width,
433
+ height,
434
+ index,
425
435
  })) ?? [];
426
436
  if (images.length > 0)
427
437
  return (jsxs("div", { className: 'tw:mx-6 tw:mb-6', children: [jsx(RowsPhotoAlbum, { photos: images, targetRowHeight: 150, onClick: ({ index: current }) => setIndex(current) }), jsx(ReactLightbox, { index: index, slides: images, open: index >= 0, close: () => setIndex(-1) })] }));
@@ -4085,6 +4095,7 @@ const GalleryForm = ({ state, setState }) => {
4085
4095
  height,
4086
4096
  asset: await appState.assetsApi.upload(compressedFile, file.name),
4087
4097
  name: file.name,
4098
+ type: file.type,
4088
4099
  };
4089
4100
  });
4090
4101
  for await (const upload of uploads) {
@@ -4098,6 +4109,7 @@ const GalleryForm = ({ state, setState }) => {
4098
4109
  id: upload.asset.id,
4099
4110
  width: upload.width,
4100
4111
  height: upload.height,
4112
+ type: upload.type,
4101
4113
  },
4102
4114
  },
4103
4115
  ],
@@ -4109,6 +4121,7 @@ const GalleryForm = ({ state, setState }) => {
4109
4121
  onDrop: upload,
4110
4122
  accept: {
4111
4123
  'image/jpeg': [],
4124
+ 'image/png': [],
4112
4125
  },
4113
4126
  });
4114
4127
  const images = state.gallery