utopia-ui 3.0.0-alpha.174 → 3.0.0-alpha.176

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
@@ -1128,13 +1128,36 @@ var DateUserInfo = function (_a) {
1128
1128
  jsx("p", __assign({ className: "!tw-my-0 tw-min-h-[21px] tw-font-bold tw-cursor-pointer tw-text-gray-500", onClick: function () { return setInfoExpanded(true); } }, { children: "\u24D8" })), jsx("div", { className: 'tw-grow ' })] })));
1129
1129
  };
1130
1130
 
1131
+ function getWindowDimensions() {
1132
+ var width = window.innerWidth, height = window.innerHeight;
1133
+ return {
1134
+ width: width,
1135
+ height: height
1136
+ };
1137
+ }
1138
+ function useWindowDimensions() {
1139
+ var _a = useState(getWindowDimensions()), windowDimensions = _a[0], setWindowDimensions = _a[1];
1140
+ useEffect(function () {
1141
+ function handleResize() {
1142
+ setWindowDimensions(getWindowDimensions());
1143
+ }
1144
+ window.addEventListener('resize', handleResize);
1145
+ return function () { return window.removeEventListener('resize', handleResize); };
1146
+ }, []);
1147
+ return windowDimensions;
1148
+ }
1149
+
1131
1150
  var ItemCard = function (_a) {
1132
1151
  var _b, _c, _d, _e, _f, _g, _h;
1133
1152
  var i = _a.i, loading = _a.loading, url = _a.url, parameterField = _a.parameterField, deleteCallback = _a.deleteCallback;
1134
1153
  var navigate = useNavigate();
1154
+ var windowDimensions = useWindowDimensions();
1135
1155
  return (jsxs("div", __assign({ className: 'tw-cursor-pointer tw-card tw-border-[1px] tw-border-base-300 tw-card-body tw-shadow-xl tw-bg-base-100 tw-text-base-content tw-p-4 tw-mb-4 tw-h-fit', onClick: function () {
1136
1156
  var params = new URLSearchParams(window.location.search);
1137
- navigate(url + getValue(i, parameterField) + "".concat(params ? "?".concat(params) : ""));
1157
+ if (windowDimensions.width < 786 && i.position)
1158
+ navigate("/" + getValue(i, parameterField) + "".concat(params ? "?".concat(params) : ""));
1159
+ else
1160
+ navigate(url + getValue(i, parameterField) + "".concat(params ? "?".concat(params) : ""));
1138
1161
  } }, { children: [jsx(HeaderView, { loading: loading, item: i, api: (_b = i.layer) === null || _b === void 0 ? void 0 : _b.api, itemAvatarField: (_c = i.layer) === null || _c === void 0 ? void 0 : _c.itemAvatarField, itemNameField: (_d = i.layer) === null || _d === void 0 ? void 0 : _d.itemNameField, itemSubnameField: (_e = i.layer) === null || _e === void 0 ? void 0 : _e.itemSubnameField, editCallback: function () { return navigate("/edit-item/" + i.id); }, deleteCallback: function () { return deleteCallback(i); } }), jsxs("div", __assign({ className: 'tw-overflow-y-auto tw-overflow-x-hidden tw-max-h-64 fade' }, { children: [((_f = i.layer) === null || _f === void 0 ? void 0 : _f.itemType.show_start_end) &&
1139
1162
  jsx(StartEndView, { item: i }), ((_g = i.layer) === null || _g === void 0 ? void 0 : _g.itemType.show_text) &&
1140
1163
  jsx(TextView, { truncate: true, item: i, itemTextField: (_h = i.layer) === null || _h === void 0 ? void 0 : _h.itemTextField })] })), jsx(DateUserInfo, { item: i })] })));
@@ -1191,6 +1214,7 @@ function useFilterManager(initialTags) {
1191
1214
  }, initialTags), filterTags = _a[0], dispatchTags = _a[1];
1192
1215
  var initialLayers = useLayers();
1193
1216
  var navigate = useNavigate();
1217
+ var windowDimensions = useWindowDimensions();
1194
1218
  var _b = useReducer(function (state, action) {
1195
1219
  switch (action.type) {
1196
1220
  case "ADD_LAYER":
@@ -1226,7 +1250,10 @@ function useFilterManager(initialTags) {
1226
1250
  var urlTags = params.get("tags");
1227
1251
  if (!(urlTags === null || urlTags === void 0 ? void 0 : urlTags.includes(tag.name)))
1228
1252
  params.set("tags", "".concat(urlTags ? urlTags : "").concat(urlTags ? ',' : '').concat(tag.name));
1229
- navigate(location.pathname + "".concat(params ? "?".concat(params) : ""));
1253
+ if (windowDimensions.width < 786 && location.pathname.split("/").length > 2)
1254
+ navigate("/" + "".concat(params ? "?".concat(params) : ""));
1255
+ else
1256
+ navigate(location.pathname + "".concat(params ? "?".concat(params) : ""));
1230
1257
  dispatchTags({
1231
1258
  type: "ADD_TAG",
1232
1259
  tag: tag,
@@ -1319,25 +1346,6 @@ var useIsLayerVisible = function () {
1319
1346
  return isLayerVisible;
1320
1347
  };
1321
1348
 
1322
- function getWindowDimensions() {
1323
- var width = window.innerWidth, height = window.innerHeight;
1324
- return {
1325
- width: width,
1326
- height: height
1327
- };
1328
- }
1329
- function useWindowDimensions() {
1330
- var _a = useState(getWindowDimensions()), windowDimensions = _a[0], setWindowDimensions = _a[1];
1331
- useEffect(function () {
1332
- function handleResize() {
1333
- setWindowDimensions(getWindowDimensions());
1334
- }
1335
- window.addEventListener('resize', handleResize);
1336
- return function () { return window.removeEventListener('resize', handleResize); };
1337
- }, []);
1338
- return windowDimensions;
1339
- }
1340
-
1341
1349
  var useTimeout = function (callback, delay) {
1342
1350
  var callbackRef = useRef(callback);
1343
1351
  var timeoutRef = useRef();
@@ -2534,7 +2542,7 @@ var SearchControl = function () {
2534
2542
  if (windowDimensions.width < 500)
2535
2543
  map.closePopup();
2536
2544
  }, onBlur: function () { return hide(); } }), value.length > 0 && jsx("button", __assign({ className: "tw-btn tw-btn-sm tw-btn-circle tw-absolute tw-right-2 tw-top-2", onClick: function () { return setValue(""); } }, { children: "\u2715" }))] })), jsx(LocateControl, {})] })), hideSuggestions || Array.from(geoResults).length == 0 && itemsResults.length == 0 && tagsResults.length == 0 && !isGeoCoordinate(value) || value.length == 0 ? "" :
2537
- jsxs("div", __assign({ className: 'tw-card tw-card-body tw-bg-base-100 tw-p-4 tw-mt-2 tw-shadow-xl tw-overflow-y-auto tw-max-h-[calc(100dvh-152px)]' }, { children: [tagsResults.length > 0 &&
2545
+ jsxs("div", __assign({ className: 'tw-card tw-card-body tw-bg-base-100 tw-p-4 tw-mt-2 tw-shadow-xl tw-overflow-y-auto tw-max-h-[calc(100dvh-152px)] tw-absolute tw-z-3000' }, { children: [tagsResults.length > 0 &&
2538
2546
  jsx("div", __assign({ className: 'tw-flex tw-flex-wrap' }, { children: tagsResults.slice(0, 3).map(function (tag) { return (jsx("div", __assign({ className: 'tw-rounded-2xl tw-text-white tw-p-1 tw-px-4 tw-shadow-md tw-card tw-mr-2 tw-mb-2 tw-cursor-pointer', style: { backgroundColor: tag.color }, onClick: function () {
2539
2547
  addFilterTag(tag);
2540
2548
  } }, { 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) {