utopia-ui 3.0.0-alpha.175 → 3.0.0-alpha.177
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 +49 -29
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -1154,8 +1154,10 @@ var ItemCard = function (_a) {
|
|
1154
1154
|
var windowDimensions = useWindowDimensions();
|
1155
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 () {
|
1156
1156
|
var params = new URLSearchParams(window.location.search);
|
1157
|
-
windowDimensions.width
|
1158
|
-
|
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) : ""));
|
1159
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) &&
|
1160
1162
|
jsx(StartEndView, { item: i }), ((_g = i.layer) === null || _g === void 0 ? void 0 : _g.itemType.show_text) &&
|
1161
1163
|
jsx(TextView, { truncate: true, item: i, itemTextField: (_h = i.layer) === null || _h === void 0 ? void 0 : _h.itemTextField })] })), jsx(DateUserInfo, { item: i })] })));
|
@@ -2540,7 +2542,7 @@ var SearchControl = function () {
|
|
2540
2542
|
if (windowDimensions.width < 500)
|
2541
2543
|
map.closePopup();
|
2542
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 ? "" :
|
2543
|
-
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 &&
|
2544
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 () {
|
2545
2547
|
addFilterTag(tag);
|
2546
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) {
|
@@ -2697,16 +2699,16 @@ var OverlayItemsIndexPage = function (_a) {
|
|
2697
2699
|
}
|
2698
2700
|
});
|
2699
2701
|
}); };
|
2700
|
-
return (jsxs(Fragment, { children: [jsx(MapOverlayPage, __assign({ className: 'tw-rounded-none tw-overflow-y-auto tw-bg-base-200 !tw-p-4' }, { children: jsxs("div", __assign({ className: 'tw-flex tw-flex-col tw-h-full' }, { children: [jsx("div", __assign({ className: 'tw-flex-none' }, { children: jsxs(Control, __assign({ position: 'topLeft', zIndex: "1000", absolute: false }, { children: [jsx(SearchControl, {}), jsx(TagsControl, {})] })) })), jsxs("div", __assign({ className: "tw-overflow-scroll fade tw-flex-1 tw-grid tw-grid-cols-1 md:tw-grid-cols-2 lg:tw-grid-cols-3 2xl:tw-grid-cols-4 tw-gap-6 tw-pt-4
|
2701
|
-
|
2702
|
-
|
2703
|
-
|
2704
|
-
|
2705
|
-
|
2706
|
-
|
2707
|
-
|
2708
|
-
|
2709
|
-
|
2702
|
+
return (jsxs(Fragment, { children: [jsx(MapOverlayPage, __assign({ className: 'tw-rounded-none tw-overflow-y-auto tw-bg-base-200 !tw-p-4' }, { children: jsxs("div", __assign({ className: 'tw-flex tw-flex-col tw-h-full' }, { children: [jsx("div", __assign({ className: 'tw-flex-none' }, { children: jsxs(Control, __assign({ position: 'topLeft', zIndex: "1000", absolute: false }, { children: [jsx(SearchControl, {}), jsx(TagsControl, {})] })) })), jsxs("div", __assign({ className: "tw-overflow-scroll fade tw-flex-1" }, { children: [jsx("div", __assign({ className: 'tw-grid tw-grid-cols-1 md:tw-grid-cols-2 lg:tw-grid-cols-3 2xl:tw-grid-cols-4 tw-gap-6 tw-pt-4' }, { children: (_c = (_b = items === null || items === void 0 ? void 0 : items.filter(function (i) { var _a; return ((_a = i.layer) === null || _a === void 0 ? void 0 : _a.name) === layerName; }).filter(function (item) {
|
2703
|
+
return filterTags.length == 0 ? item : filterTags.every(function (tag) { return getItemTags(item).some(function (filterTag) { return filterTag.name.toLocaleLowerCase() === tag.name.toLocaleLowerCase(); }); });
|
2704
|
+
})) === null || _b === void 0 ? void 0 : _b.sort(function (a, b) {
|
2705
|
+
// Convert date_created to milliseconds, handle undefined by converting to lowest possible date (0 milliseconds)
|
2706
|
+
var dateA = a.date_updated ? new Date(a.date_updated).getTime() : a.date_created ? new Date(a.date_created).getTime() : 0;
|
2707
|
+
var dateB = b.date_updated ? new Date(b.date_updated).getTime() : b.date_created ? new Date(b.date_created).getTime() : 0;
|
2708
|
+
return dateB - dateA; // Subtracts milliseconds which are numbers
|
2709
|
+
})) === null || _c === void 0 ? void 0 : _c.map(function (i, k) {
|
2710
|
+
return (jsx(ItemCard, { i: i, loading: loading, url: url, parameterField: parameterField, deleteCallback: function () { return deleteItem(i); } }, k));
|
2711
|
+
}) })), addItemPopupType == "place" ?
|
2710
2712
|
jsx("form", __assign({ ref: tabRef, autoComplete: 'off', onSubmit: function (e) { return submitNewItem(e); } }, { children: 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-6 tw-mb-10' }, { children: [jsx("label", __assign({ className: "tw-btn tw-btn-sm tw-rounded-2xl tw-btn-circle tw-btn-ghost hover:tw-bg-transparent tw-absolute tw-right-0 tw-top-0 tw-text-gray-600", onClick: function () {
|
2711
2713
|
setAddItemPopupType("");
|
2712
2714
|
} }, { children: jsx("p", __assign({ className: 'tw-text-center ' }, { children: "\u2715" })) })), jsx(TextInput, { type: "text", placeholder: "Name", dataField: "name", defaultValue: "", inputStyle: '' }), (layer === null || layer === void 0 ? void 0 : layer.itemType.show_start_end_input) &&
|
@@ -3331,7 +3333,7 @@ var TextView = function (_a) {
|
|
3331
3333
|
else
|
3332
3334
|
text = ((_b = item === null || item === void 0 ? void 0 : item.layer) === null || _b === void 0 ? void 0 : _b.itemTextField) && item ? getValue(item, (_c = item.layer) === null || _c === void 0 ? void 0 : _c.itemTextField) : "";
|
3333
3335
|
if (item && text && truncate)
|
3334
|
-
text =
|
3336
|
+
text = truncateText(removeMarkdownKeepLinksAndParagraphs(text), 100);
|
3335
3337
|
var replacedText;
|
3336
3338
|
item && text ? replacedText = fixUrls(text) : "";
|
3337
3339
|
replacedText ? replacedText = replacedText.replace(/(?<!\]?\()https?:\/\/[^\s\)]+(?!\))/g, function (url) {
|
@@ -3403,25 +3405,20 @@ var TextView = function (_a) {
|
|
3403
3405
|
return (jsx("a", __assign({ style: { color: tag ? tag.color : '#faa', fontWeight: 'bold', cursor: 'pointer' }, onClick: function (e) {
|
3404
3406
|
e.stopPropagation();
|
3405
3407
|
addFilterTag(tag);
|
3406
|
-
// map.fitBounds(items)
|
3407
|
-
// map.closePopup();
|
3408
3408
|
} }, { children: decodeTag(children) }), tag ? tag.name + item.id : item.id));
|
3409
3409
|
};
|
3410
|
-
return (
|
3411
|
-
//@ts-ignore
|
3412
|
-
jsx(Markdown, __assign({ className: "tw-text-map tw-leading-map ", remarkPlugins: [remarkBreaks], components: {
|
3410
|
+
return (jsx(Markdown, __assign({ className: "tw-text-map tw-leading-map ", remarkPlugins: [remarkBreaks], components: {
|
3413
3411
|
p: CustomParagraph,
|
3414
3412
|
a: function (_a) {
|
3415
3413
|
var href = _a.href, children = _a.children;
|
3416
|
-
// Prüft, ob der Link ein YouTube-Video ist
|
3417
3414
|
var isYouTubeVideo = href === null || href === void 0 ? void 0 : href.startsWith('https://www.youtube.com/watch?v=');
|
3418
3415
|
if (isYouTubeVideo) {
|
3419
|
-
var videoId = href === null || href === void 0 ? void 0 : href.split('v=')[1].split('&')[0];
|
3416
|
+
var videoId = href === null || href === void 0 ? void 0 : href.split('v=')[1].split('&')[0];
|
3420
3417
|
var youtubeEmbedUrl = "https://www.youtube-nocookie.com/embed/".concat(videoId);
|
3421
3418
|
return (jsx("iframe", { className: 'tw-w-full', src: youtubeEmbedUrl, allowFullScreen: true }));
|
3422
3419
|
}
|
3423
3420
|
if (href === null || href === void 0 ? void 0 : href.startsWith("#")) {
|
3424
|
-
var tag = tags.find(function (t) { return t.name.toLowerCase()
|
3421
|
+
var tag = tags.find(function (t) { return t.name.toLowerCase() === decodeURI(href).slice(1).toLowerCase(); });
|
3425
3422
|
return jsx(CustomHashTagLink, __assign({ tag: tag, item: item }, { children: children }));
|
3426
3423
|
}
|
3427
3424
|
else {
|
@@ -3440,14 +3437,37 @@ var TextView = function (_a) {
|
|
3440
3437
|
h6: CustomH6,
|
3441
3438
|
} }, { children: replacedText })));
|
3442
3439
|
};
|
3443
|
-
function
|
3444
|
-
|
3445
|
-
|
3440
|
+
function removeMarkdownKeepLinksAndParagraphs(text) {
|
3441
|
+
// Remove Markdown syntax using regular expressions but keep links and paragraphs
|
3442
|
+
return text
|
3443
|
+
.replace(/!\[.*?\]\(.*?\)/g, '') // Remove images
|
3444
|
+
.replace(/(`{1,3})(.*?)\1/g, '$2') // Remove inline code
|
3445
|
+
.replace(/(\*{1,2}|_{1,2})(.*?)\1/g, '$2') // Remove bold and italic
|
3446
|
+
.replace(/(#+)\s+(.*)/g, '$2') // Remove headers
|
3447
|
+
.replace(/>\s+(.*)/g, '$1') // Remove blockquotes
|
3448
|
+
.replace(/^\s*\n/gm, '\n') // Preserve empty lines
|
3449
|
+
.replace(/(\r\n|\n|\r)/gm, '\n'); // Preserve line breaks
|
3450
|
+
}
|
3451
|
+
function truncateText(text, limit) {
|
3452
|
+
if (text.length <= limit) {
|
3453
|
+
return text;
|
3454
|
+
}
|
3455
|
+
var truncated = "";
|
3456
|
+
var length = 0;
|
3457
|
+
// Split the text by paragraphs
|
3458
|
+
var paragraphs = text.split('\n');
|
3459
|
+
for (var _i = 0, paragraphs_1 = paragraphs; _i < paragraphs_1.length; _i++) {
|
3460
|
+
var paragraph = paragraphs_1[_i];
|
3461
|
+
if (length + paragraph.length > limit) {
|
3462
|
+
truncated += paragraph.slice(0, limit - length) + '...';
|
3463
|
+
break;
|
3464
|
+
}
|
3465
|
+
else {
|
3466
|
+
truncated += paragraph + '\n';
|
3467
|
+
length += paragraph.length;
|
3468
|
+
}
|
3446
3469
|
}
|
3447
|
-
|
3448
|
-
return (useWordBoundary
|
3449
|
-
? subString.slice(0, subString.lastIndexOf(" "))
|
3450
|
-
: subString) + "…";
|
3470
|
+
return truncated.trim();
|
3451
3471
|
}
|
3452
3472
|
|
3453
3473
|
var ItemViewPopup = React.forwardRef(function (props, ref) {
|