utopia-ui 3.0.0-alpha.124 → 3.0.0-alpha.126

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.
package/dist/index.js CHANGED
@@ -2757,27 +2757,6 @@ function encodeTag(string) {
2757
2757
  return string.replace(/\s+/g, "_");
2758
2758
  }
2759
2759
 
2760
- var ClusterRefContext = createContext({
2761
- clusterRef: {},
2762
- setClusterRef: function () { },
2763
- });
2764
- function useClusterRefManager() {
2765
- var _a = useState({}), clusterRef = _a[0], setClusterRef = _a[1];
2766
- return { clusterRef: clusterRef, setClusterRef: setClusterRef };
2767
- }
2768
- var ClusterRefProvider = function (_a) {
2769
- var children = _a.children;
2770
- return (jsx(ClusterRefContext.Provider, __assign({ value: useClusterRefManager() }, { children: children })));
2771
- };
2772
- var useClusterRef = function () {
2773
- var clusterRef = useContext(ClusterRefContext).clusterRef;
2774
- return clusterRef;
2775
- };
2776
- var useSetClusterRef = function () {
2777
- var setClusterRef = useContext(ClusterRefContext).setClusterRef;
2778
- return setClusterRef;
2779
- };
2780
-
2781
2760
  var SearchControl = function () {
2782
2761
  var windowDimensions = useWindowDimensions();
2783
2762
  var _a = useState(false), popupOpen = _a[0], setPopupOpen = _a[1];
@@ -2791,9 +2770,6 @@ var SearchControl = function () {
2791
2770
  var items = useItems();
2792
2771
  var leafletRefs = useLeafletRefs();
2793
2772
  var addFilterTag = useAddFilterTag();
2794
- useResetFilterTags();
2795
- useFilterTags();
2796
- useClusterRef();
2797
2773
  useMapEvents({
2798
2774
  popupopen: function () {
2799
2775
  setPopupOpen(true);
@@ -2830,7 +2806,7 @@ var SearchControl = function () {
2830
2806
  item.name = getValue(item, item.layer.itemNameField);
2831
2807
  if ((_b = item.layer) === null || _b === void 0 ? void 0 : _b.itemTextField)
2832
2808
  item.text = getValue(item, item.layer.itemTextField);
2833
- return ((_c = item.name) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes(value.toLowerCase())) || ((_d = item.text) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes(value.toLowerCase()));
2809
+ return value.length > 2 && (((_c = item.name) === null || _c === void 0 ? void 0 : _c.toLowerCase().includes(value.toLowerCase())) || ((_d = item.text) === null || _d === void 0 ? void 0 : _d.toLowerCase().includes(value.toLowerCase())));
2834
2810
  }));
2835
2811
  var phrase = value;
2836
2812
  if (value.startsWith("#"))
@@ -2845,6 +2821,9 @@ var SearchControl = function () {
2845
2821
  return [2 /*return*/];
2846
2822
  });
2847
2823
  }); };
2824
+ useEffect(function () {
2825
+ console.log(value);
2826
+ }, [value]);
2848
2827
  var searchInput = useRef(null);
2849
2828
  return (jsx(Fragment, { children: !(windowDimensions.height < 500 && popupOpen && hideSuggestions) &&
2850
2829
  jsxs("div", __assign({ className: 'tw-w-[calc(100vw-2rem)] tw-max-w-[22rem] ' }, { children: [jsxs("div", __assign({ className: 'flex tw-flex-row' }, { children: [jsx("input", { type: "text", placeholder: "search ...", autoComplete: "off", value: value, className: "tw-input tw-input-bordered tw-w-full tw-shadow-xl tw-rounded-lg tw-mr-2", ref: searchInput, onChange: function (e) { return setValue(e.target.value); }, onFocus: function () {
@@ -2857,16 +2836,19 @@ var SearchControl = function () {
2857
2836
  addFilterTag(tag);
2858
2837
  var params = new URLSearchParams(window.location.search);
2859
2838
  window.history.pushState({}, "", "/" + "".concat(params ? "?".concat(params) : ""));
2860
- } }, { children: jsxs("b", { children: ["#", decodeTag(tag.name)] }) }), tag.name)); }) })), itemsResults.length > 0 && tagsResults.length > 0 && jsx("hr", { className: 'tw-opacity-50' }), itemsResults.slice(0, 5).map(function (item) { return (jsx("div", __assign({ className: 'tw-cursor-pointer hover:tw-font-bold', onClick: function () {
2861
- var _a;
2862
- var marker = (_a = Object.entries(leafletRefs).find(function (r) { return r[1].item == item; })) === null || _a === void 0 ? void 0 : _a[1].marker;
2863
- if (marker) {
2864
- navigate("/".concat(item.layer.name, "/").concat(item.id, "?").concat(new URLSearchParams(window.location.search)));
2865
- }
2866
- else {
2867
- navigate("item/" + item.id + "?" + new URLSearchParams(window.location.search));
2868
- }
2869
- } }, { children: jsxs("div", __assign({ className: 'tw-flex tw-flex-row' }, { children: [jsx(item.layer.menuIcon, { className: "tw-text-current tw-w-5 tw-mr-2 tw-mt-0" }), jsxs("div", { children: [jsx("div", __assign({ className: 'tw-text-sm tw-overflow-hidden tw-text-ellipsis tw-whitespace-nowrap tw-max-w-[17rem]' }, { children: item.name })), jsx("div", __assign({ className: 'tw-text-xs tw-overflow-hidden tw-text-ellipsis tw-whitespace-nowrap tw-max-w-[17rem]' }, { children: item.text }))] })] })) }), item.id)); }), Array.from(geoResults).length > 0 && (itemsResults.length > 0 || tagsResults.length > 0) && jsx("hr", { className: 'tw-opacity-50' }), Array.from(geoResults).map(function (geo) {
2839
+ } }, { children: jsxs("b", { children: ["#", decodeTag(tag.name)] }) }), tag.name)); }) })), itemsResults.length > 0 && tagsResults.length > 0 && jsx("hr", { className: 'tw-opacity-50' }), itemsResults.slice(0, 5).map(function (item) {
2840
+ var _a;
2841
+ return (jsx("div", __assign({ className: 'tw-cursor-pointer hover:tw-font-bold', onClick: function () {
2842
+ var _a;
2843
+ var marker = (_a = Object.entries(leafletRefs).find(function (r) { return r[1].item == item; })) === null || _a === void 0 ? void 0 : _a[1].marker;
2844
+ if (marker) {
2845
+ navigate("/".concat(item.id, "?").concat(new URLSearchParams(window.location.search)));
2846
+ }
2847
+ else {
2848
+ navigate("item/" + item.id + "?" + new URLSearchParams(window.location.search));
2849
+ }
2850
+ } }, { children: jsxs("div", __assign({ className: 'tw-flex tw-flex-row' }, { children: [jsx("img", { src: (_a = item.layer) === null || _a === void 0 ? void 0 : _a.menuIcon, className: "tw-text-current tw-w-5 tw-mr-2 tw-mt-0" }), jsxs("div", { children: [jsx("div", __assign({ className: 'tw-text-sm tw-overflow-hidden tw-text-ellipsis tw-whitespace-nowrap tw-max-w-[17rem]' }, { children: item.name })), jsx("div", __assign({ className: 'tw-text-xs tw-overflow-hidden tw-text-ellipsis tw-whitespace-nowrap tw-max-w-[17rem]' }, { children: item.text }))] })] })) }), item.id));
2851
+ }), Array.from(geoResults).length > 0 && (itemsResults.length > 0 || tagsResults.length > 0) && jsx("hr", { className: 'tw-opacity-50' }), Array.from(geoResults).map(function (geo) {
2870
2852
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2871
2853
  return (jsxs("div", __assign({ className: 'tw-flex tw-flex-row hover:tw-font-bold tw-cursor-pointer', onClick: function () {
2872
2854
  var _a, _b;
@@ -3087,6 +3069,27 @@ var useSetMarkerClicked = function () {
3087
3069
  return setMarkerClicked;
3088
3070
  };
3089
3071
 
3072
+ var ClusterRefContext = createContext({
3073
+ clusterRef: {},
3074
+ setClusterRef: function () { },
3075
+ });
3076
+ function useClusterRefManager() {
3077
+ var _a = useState({}), clusterRef = _a[0], setClusterRef = _a[1];
3078
+ return { clusterRef: clusterRef, setClusterRef: setClusterRef };
3079
+ }
3080
+ var ClusterRefProvider = function (_a) {
3081
+ var children = _a.children;
3082
+ return (jsx(ClusterRefContext.Provider, __assign({ value: useClusterRefManager() }, { children: children })));
3083
+ };
3084
+ var useClusterRef = function () {
3085
+ var clusterRef = useContext(ClusterRefContext).clusterRef;
3086
+ return clusterRef;
3087
+ };
3088
+ var useSetClusterRef = function () {
3089
+ var setClusterRef = useContext(ClusterRefContext).setClusterRef;
3090
+ return setClusterRef;
3091
+ };
3092
+
3090
3093
  // for refreshing map on resize (needs to be implemented)
3091
3094
  var mapDivRef = React.createRef();
3092
3095
  function UtopiaMap(_a) {
@@ -3561,6 +3564,7 @@ var Layer = function (_a) {
3561
3564
  var allTagsLoaded = useAllTagsLoaded();
3562
3565
  var allItemsLoaded = useAllItemsLoaded();
3563
3566
  var setMarkerClicked = useSetMarkerClicked();
3567
+ var selectPosition = useSelectPosition();
3564
3568
  var tags = useTags();
3565
3569
  var addTag = useAddTag();
3566
3570
  var _r = useState([]), newTagsToAdd = _r[0], setNewTagsToAdd = _r[1];
@@ -3674,7 +3678,7 @@ var Layer = function (_a) {
3674
3678
  r && addMarker(item, r);
3675
3679
  }, eventHandlers: {
3676
3680
  click: function () {
3677
- setMarkerClicked(item);
3681
+ selectPosition && setMarkerClicked(item);
3678
3682
  },
3679
3683
  }, icon: MarkerIconFactory(markerShape, color1, color2, markerIcon), position: [latitude, longitude] }, { children: [(children && React.Children.toArray(children).some(function (child) { return React.isValidElement(child) && child.props.__TYPE === "ItemView"; }) ?
3680
3684
  React.Children.toArray(children).map(function (child) {
@@ -4964,7 +4968,7 @@ function Quests() {
4964
4968
  var _b = useState(), profile = _b[0], setProfie = _b[1];
4965
4969
  var items = useItems();
4966
4970
  useEffect(function () {
4967
- setProfie(items.find(function (i) { var _a, _b; return ((_a = i.user_created) === null || _a === void 0 ? void 0 : _a.id) === (user === null || user === void 0 ? void 0 : user.id) && ((_b = i.layer) === null || _b === void 0 ? void 0 : _b.itemType.name) == "user" && i.user_created.id != null; }));
4971
+ setProfie(items.find(function (i) { var _a, _b, _c; return ((_a = i.user_created) === null || _a === void 0 ? void 0 : _a.id) === (user === null || user === void 0 ? void 0 : user.id) && ((_b = i.layer) === null || _b === void 0 ? void 0 : _b.itemType.name) == "user" && ((_c = i.user_created) === null || _c === void 0 ? void 0 : _c.id) != null; }));
4968
4972
  }, [items, user]);
4969
4973
  return (jsx(Fragment, { children: questsOpen ?
4970
4974
  jsx("div", __assign({ className: "tw-card tw-w-48 tw-bg-base-100 tw-shadow-xl tw-absolute tw-bottom-4 tw-left-4 tw-z-[2000]" }, { children: jsxs("div", __assign({ className: "tw-card-body tw-p-4 tw-pt-0" }, { children: [jsx("div", __assign({ className: "tw-card-actions tw-justify-end" }, { children: jsx("label", __assign({ className: "tw-btn tw-btn-sm tw-btn-circle tw-btn-ghost tw-absolute tw-right-1 tw-top-1", onClick: function () { return setQuestsOpen(false); } }, { children: "\u2715" })) })), jsxs("h2", __assign({ className: "tw-card-title tw-m-auto " }, { children: ["Level 1", jsx("svg", __assign({ xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "#aaa", className: "tw-w-5 tw-h-5 tw-cursor-pointer" }, { children: jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z" }) }))] })), jsxs("ul", __assign({ className: 'tw-flex-row' }, { children: [jsx("li", { children: jsxs("label", __assign({ className: "tw-label tw-justify-normal tw-pt-1 tw-pb-0" }, { children: [jsx("input", { type: "checkbox", readOnly: true, className: "tw-checkbox tw-checkbox-xs tw-checkbox-success", checked: isAuthenticated ? isAuthenticated : false }), jsx("span", __assign({ className: 'tw-text-sm tw-label-text tw-mx-2' }, { children: "Sign Up" }))] })) }), jsx("li", { children: jsxs("label", __assign({ className: "tw-label tw-justify-normal tw-pt-1 tw-pb-0" }, { children: [jsx("input", { type: "checkbox", readOnly: true, className: "tw-checkbox tw-checkbox-xs tw-checkbox-success", checked: (profile === null || profile === void 0 ? void 0 : profile.text) ? true : false }), jsx("span", __assign({ className: 'tw-text-sm tw-label-text tw-mx-2' }, { children: "Fill Profile" }))] })) }), jsx("li", { children: jsxs("label", __assign({ className: "tw-label tw-justify-normal tw-pt-1 tw-pb-0" }, { children: [jsx("input", { type: "checkbox", readOnly: true, className: "tw-checkbox tw-checkbox-xs tw-checkbox-success", checked: (profile === null || profile === void 0 ? void 0 : profile.image) ? true : false }), jsx("span", __assign({ className: 'tw-text-sm tw-label-text tw-mx-2' }, { children: "Upload Avatar" }))] })) })] })), " "] })) }))