utopia-ui 3.0.0-alpha.218 → 3.0.0-alpha.219

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
@@ -3678,7 +3678,7 @@ var Layer = function (_a) {
3678
3678
  return (jsxs(Fragment, { children: [items &&
3679
3679
  ((_c = (_b = items.
3680
3680
  filter(function (item) { var _a; return ((_a = item.layer) === null || _a === void 0 ? void 0 : _a.name) === name; })) === null || _b === void 0 ? void 0 : _b.filter(function (item) {
3681
- return filterTags.length == 0 ? item : filterTags.some(function (tag) { return getItemTags(item).some(function (filterTag) { return filterTag.name.toLocaleLowerCase() === tag.name.toLocaleLowerCase(); }); });
3681
+ return filterTags.length == 0 ? item : filterTags.every(function (tag) { return getItemTags(item).some(function (filterTag) { return filterTag.name.toLocaleLowerCase() === tag.name.toLocaleLowerCase(); }); });
3682
3682
  })) === null || _c === void 0 ? void 0 : _c.filter(function (item) { return item.layer && isLayerVisible(item.layer); }).filter(function (item) { return item.group_type && isGroupTypeVisible(item.group_type) || visibleGroupTypes.length == 0; }).map(function (item) {
3683
3683
  var _a;
3684
3684
  if (getValue(item, itemLongitudeField) && getValue(item, itemLatitudeField)) {
@@ -3994,7 +3994,7 @@ function SideBar(_a) {
3994
3994
  embedded != "true" && setEmbedded(false);
3995
3995
  }, [location]);
3996
3996
  var params = new URLSearchParams(window.location.search);
3997
- return (jsx("nav", __assign({ id: "sidenav", className: "group tw-fixed tw-left-0 ".concat(embedded ? 'tw-mt-0 tw-h-[100dvh]' : 'tw-mt-16 tw-h-[calc(100dvh-64px)]', " tw-top-0 tw-z-[10035] tw--translate-x-full tw-overflow-hidden tw-shadow-xl data-[te-sidenav-slim='true']:tw-hidden data-[te-sidenav-slim-collapsed='true']:tw-w-[56px] data-[te-sidenav-slim='true']:tw-w-[56px] data-[te-sidenav-hidden='false']:tw-translate-x-0 dark:tw-bg-zinc-800 [&[data-te-sidenav-slim-collapsed='true'][data-te-sidenav-slim='false']]:tw-hidden [&[data-te-sidenav-slim-collapsed='true'][data-te-sidenav-slim='true']]:[display:unset]"), "data-te-sidenav-init": true, "data-te-sidenav-hidden": "true", "data-te-sidenav-mode": "side", "data-te-sidenav-slim": "true", "data-te-sidenav-content": "#app-content", "data-te-sidenav-slim-collapsed": "true", "data-te-sidenav-slim-width": "56", "data-te-sidenav-width": "168" }, { children: jsxs("div", __assign({ className: "tw-flex tw-flex-col ".concat(embedded ? "tw-h-full" : "tw-h-[calc(100dvh-64px)]") }, { children: [jsx("ul", __assign({ className: "tw-menu tw-w-full tw-bg-base-100 tw-text-base-content tw-p-0", "data-te-sidenav-menu-ref": true }, { children: routes.map(function (route, k) {
3997
+ return (jsx("nav", __assign({ id: "sidenav", className: "group tw-fixed tw-left-0 ".concat(embedded ? 'tw-mt-0 tw-h-[100dvh]' : 'tw-mt-16 tw-h-[calc(100dvh-64px)]', " tw-top-0 tw-z-[10035] tw--translate-x-full tw-overflow-hidden tw-shadow-xl data-[te-sidenav-slim='true']:tw-hidden data-[te-sidenav-slim-collapsed='true']:tw-w-[56px] data-[te-sidenav-slim='true']:tw-w-[56px] data-[te-sidenav-hidden='false']:tw-translate-x-0 dark:tw-bg-zinc-800 [&[data-te-sidenav-slim-collapsed='true'][data-te-sidenav-slim='false']]:tw-hidden [&[data-te-sidenav-slim-collapsed='true'][data-te-sidenav-slim='true']]:[display:unset]"), "data-te-sidenav-init": true, "data-te-sidenav-hidden": "true", "data-te-sidenav-mode": "side", "data-te-sidenav-slim": "true", "data-te-sidenav-content": "#app-content", "data-te-sidenav-slim-collapsed": "true", "data-te-sidenav-slim-width": "56", "data-te-sidenav-width": "160" }, { children: jsxs("div", __assign({ className: "tw-flex tw-flex-col ".concat(embedded ? "tw-h-full" : "tw-h-[calc(100dvh-64px)]") }, { children: [jsx("ul", __assign({ className: "tw-menu tw-w-full tw-bg-base-100 tw-text-base-content tw-p-0", "data-te-sidenav-menu-ref": true }, { children: routes.map(function (route, k) {
3998
3998
  return (jsx("li", __assign({ className: "" }, { children: route.submenu ?
3999
3999
  jsx(SidebarSubmenu, __assign({}, route)) :
4000
4000
  (jsxs(NavLink, __assign({ end: true, target: route.blank ? "_blank" : "_self", to: "".concat(route.path).concat(params && '?' + params), className: function (_a) {
@@ -4255,6 +4255,7 @@ var SimpleView = function (_a) {
4255
4255
  return (jsx("div", __assign({ className: 'tw-mt-8 tw-h-full tw-overflow-y-auto fade tw-px-6' }, { children: jsx(TextView, { item: item }) })));
4256
4256
  };
4257
4257
 
4258
+ var sleep = function (ms) { return new Promise(function (resolve) { return setTimeout(resolve, ms); }); };
4258
4259
  var linkItem = function (id, item, updateItem) { return __awaiter(void 0, void 0, void 0, function () {
4259
4260
  var new_relations, updatedItem, success, error_2;
4260
4261
  var _a, _b;
@@ -4360,43 +4361,49 @@ var onUpdateItem = function (state, item, tags, addTag, setLoading, navigate, up
4360
4361
  changedItem = {};
4361
4362
  offer_updates = [];
4362
4363
  //check for new offers
4363
- (_a = state.offers) === null || _a === void 0 ? void 0 : _a.map(function (o) {
4364
- var _a;
4365
- var existingOffer = (_a = item === null || item === void 0 ? void 0 : item.offers) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.tags_id === o.id; });
4366
- existingOffer && offer_updates.push(existingOffer.id);
4367
- if (!existingOffer && !tags.some(function (t) { return t.id === o.id; }))
4368
- addTag(__assign(__assign({}, o), { offer_or_need: true }));
4369
- !existingOffer && offer_updates.push({ items_id: item === null || item === void 0 ? void 0 : item.id, tags_id: o.id });
4370
- });
4364
+ return [4 /*yield*/, ((_a = state.offers) === null || _a === void 0 ? void 0 : _a.map(function (o) {
4365
+ var _a;
4366
+ var existingOffer = (_a = item === null || item === void 0 ? void 0 : item.offers) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.tags_id === o.id; });
4367
+ existingOffer && offer_updates.push(existingOffer.id);
4368
+ if (!existingOffer && !tags.some(function (t) { return t.id === o.id; }))
4369
+ addTag(__assign(__assign({}, o), { offer_or_need: true }));
4370
+ !existingOffer && offer_updates.push({ items_id: item === null || item === void 0 ? void 0 : item.id, tags_id: o.id });
4371
+ }))];
4372
+ case 1:
4373
+ //check for new offers
4374
+ _m.sent();
4371
4375
  needs_updates = [];
4372
- (_b = state.needs) === null || _b === void 0 ? void 0 : _b.map(function (n) {
4373
- var _a;
4374
- var existingNeed = (_a = item === null || item === void 0 ? void 0 : item.needs) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.tags_id === n.id; });
4375
- existingNeed && needs_updates.push(existingNeed.id);
4376
- !existingNeed && needs_updates.push({ items_id: item === null || item === void 0 ? void 0 : item.id, tags_id: n.id });
4377
- !existingNeed && !tags.some(function (t) { return t.id === n.id; }) && addTag(__assign(__assign({}, n), { offer_or_need: true }));
4378
- });
4376
+ return [4 /*yield*/, ((_b = state.needs) === null || _b === void 0 ? void 0 : _b.map(function (n) {
4377
+ var _a;
4378
+ var existingNeed = (_a = item === null || item === void 0 ? void 0 : item.needs) === null || _a === void 0 ? void 0 : _a.find(function (t) { return t.tags_id === n.id; });
4379
+ existingNeed && needs_updates.push(existingNeed.id);
4380
+ !existingNeed && needs_updates.push({ items_id: item === null || item === void 0 ? void 0 : item.id, tags_id: n.id });
4381
+ !existingNeed && !tags.some(function (t) { return t.id === n.id; }) && addTag(__assign(__assign({}, n), { offer_or_need: true }));
4382
+ }))];
4383
+ case 2:
4384
+ _m.sent();
4379
4385
  // update profile item in current state
4380
4386
  changedItem = __assign(__assign(__assign(__assign(__assign({ id: state.id, group_type: state.groupType, status: state.status, name: state.name, subname: state.subname, text: state.text, color: state.color, position: item.position, contact: state.contact, telephone: state.telephone }, state.markerIcon && { markerIcon: state.markerIcon }), { next_appointment: state.nextAppointment }), state.image.length > 10 && { image: state.image }), state.offers.length > 0 && { offers: offer_updates }), state.needs.length > 0 && { needs: needs_updates });
4381
4387
  offers_state = [];
4382
4388
  needs_state = [];
4383
- return [4 /*yield*/, state.offers.map(function (o) {
4384
- offers_state.push({ items_id: item === null || item === void 0 ? void 0 : item.id, tags_id: o.id });
4385
- })];
4386
- case 1:
4387
- _m.sent();
4388
- return [4 /*yield*/, state.needs.map(function (n) {
4389
- needs_state.push({ items_id: item === null || item === void 0 ? void 0 : item.id, tags_id: n.id });
4390
- })];
4391
- case 2:
4392
- _m.sent();
4393
- changedItem = __assign(__assign({}, changedItem), { offers: offers_state, needs: needs_state });
4394
- (_c = state.text.toLocaleLowerCase().match(hashTagRegex)) === null || _c === void 0 ? void 0 : _c.map(function (tag) {
4395
- if (!tags.find(function (t) { return t.name.toLocaleLowerCase() === tag.slice(1).toLocaleLowerCase(); })) {
4396
- addTag({ id: crypto.randomUUID(), name: encodeTag(tag.slice(1).toLocaleLowerCase()), color: randomColor() });
4397
- }
4389
+ state.offers.map(function (o) {
4390
+ offers_state.push({ items_id: item === null || item === void 0 ? void 0 : item.id, tags_id: o.id });
4391
+ });
4392
+ state.needs.map(function (n) {
4393
+ needs_state.push({ items_id: item === null || item === void 0 ? void 0 : item.id, tags_id: n.id });
4398
4394
  });
4395
+ changedItem = __assign(__assign({}, changedItem), { offers: offers_state, needs: needs_state });
4399
4396
  setLoading(true);
4397
+ return [4 /*yield*/, ((_c = state.text.toLocaleLowerCase().match(hashTagRegex)) === null || _c === void 0 ? void 0 : _c.map(function (tag) {
4398
+ if (!tags.find(function (t) { return t.name.toLocaleLowerCase() === tag.slice(1).toLocaleLowerCase(); })) {
4399
+ addTag({ id: crypto.randomUUID(), name: encodeTag(tag.slice(1).toLocaleLowerCase()), color: randomColor() });
4400
+ }
4401
+ }))];
4402
+ case 3:
4403
+ _m.sent();
4404
+ return [4 /*yield*/, sleep(200)];
4405
+ case 4:
4406
+ _m.sent();
4400
4407
  if (!item.new) {
4401
4408
  ((_e = (_d = item === null || item === void 0 ? void 0 : item.layer) === null || _d === void 0 ? void 0 : _d.api) === null || _e === void 0 ? void 0 : _e.updateItem) && toast.promise((_g = (_f = item === null || item === void 0 ? void 0 : item.layer) === null || _f === void 0 ? void 0 : _f.api) === null || _g === void 0 ? void 0 : _g.updateItem(changedItem), {
4402
4409
  pending: 'updating Item ...',
@@ -4415,6 +4422,7 @@ var onUpdateItem = function (state, item, tags, addTag, setLoading, navigate, up
4415
4422
  });
4416
4423
  }
4417
4424
  else {
4425
+ item.new = false;
4418
4426
  ((_j = (_h = item.layer) === null || _h === void 0 ? void 0 : _h.api) === null || _j === void 0 ? void 0 : _j.createItem) && toast.promise((_l = (_k = item.layer) === null || _k === void 0 ? void 0 : _k.api) === null || _l === void 0 ? void 0 : _l.createItem(changedItem), {
4419
4427
  pending: 'updating Item ...',
4420
4428
  success: 'Item updated',