utopia-ui 3.0.0-alpha.240 → 3.0.0-alpha.242

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
@@ -4136,36 +4136,37 @@ var TabsView = function (_a) {
4136
4136
  var addFilterTag = useAddFilterTag();
4137
4137
  var _e = useState(1), activeTab = _e[0], setActiveTab = _e[1];
4138
4138
  var navigate = useNavigate();
4139
+ var location = useLocation();
4140
+ var tabRef = useRef(null);
4139
4141
  var _f = useState(""), addItemPopupType = _f[0]; _f[1];
4140
4142
  useEffect(function () {
4141
4143
  scroll();
4142
4144
  }, [addItemPopupType]);
4143
- function scroll() {
4145
+ var scroll = useCallback(function () {
4144
4146
  var _a;
4145
4147
  (_a = tabRef.current) === null || _a === void 0 ? void 0 : _a.scrollIntoView();
4146
- }
4147
- var tabRef = useRef(null);
4148
- var updateActiveTab = function (id) {
4148
+ }, []);
4149
+ var updateActiveTab = useCallback(function (id) {
4149
4150
  setActiveTab(id);
4150
4151
  var params = new URLSearchParams(window.location.search);
4151
4152
  var urlTab = params.get("tab");
4152
- if (!(urlTab === null || urlTab === void 0 ? void 0 : urlTab.includes(id.toString())))
4153
+ if (!(urlTab === null || urlTab === void 0 ? void 0 : urlTab.includes(id.toString()))) {
4153
4154
  params.set("tab", "".concat(id ? id : ""));
4154
- navigate(location.pathname + "?" + params.toString());
4155
- };
4155
+ navigate(location.pathname + "?" + params.toString(), { replace: true });
4156
+ }
4157
+ }, [navigate, location.pathname]);
4156
4158
  useEffect(function () {
4157
4159
  var params = new URLSearchParams(location.search);
4158
4160
  var urlTab = params.get("tab");
4159
4161
  urlTab ? setActiveTab(Number(urlTab)) : setActiveTab(1);
4160
4162
  }, [location]);
4161
- return (jsxs("div", __assign({ role: "tablist", className: "tw-tabs tw-tabs-lifted tw-mt-2 tw-mb-2 tw-px-6" }, { children: [jsx("input", { type: "radio", name: "my_tabs_2", role: "tab", className: "tw-tab [--tab-border-color:var(--fallback-bc,oklch(var(--bc)/0.2))]", "aria-label": "Info", checked: activeTab == 1 && true, onChange: function () { return updateActiveTab(1); } }), jsxs("div", __assign({ role: "tabpanel", className: "tw-tab-content tw-bg-base-100 tw-rounded-box tw-h-[calc(100dvh-280px)] tw-overflow-y-auto fade tw-pt-2 tw-pb-4 tw-mb-4 tw-overflow-x-hidden" }, { children: [((_b = item.layer) === null || _b === void 0 ? void 0 : _b.itemType.show_start_end) &&
4162
- jsx("div", __assign({ className: 'tw-max-w-xs' }, { children: jsx(StartEndView, { item: item }) })), jsx(TextView, { item: item }), jsx("div", { className: 'tw-h-4' }), jsx(TextView, { item: item, itemTextField: 'contact' })] })), ((_c = item.layer) === null || _c === void 0 ? void 0 : _c.itemType.offers_and_needs) &&
4163
- jsxs(Fragment, { children: [jsx("input", { type: "radio", name: "my_tabs_2", role: "tab", className: "tw-tab tw-min-w-[10em] [--tab-border-color:var(--fallback-bc,oklch(var(--bc)/0.2))]", "aria-label": "Offers & Needs", checked: activeTab == 3 && true, onChange: function () { return updateActiveTab(3); } }), jsx("div", __assign({ role: "tabpanel", className: "tw-tab-content tw-bg-base-100 tw-rounded-box tw-h-[calc(100dvh-268px)] tw-overflow-y-auto fade tw-pt-4 tw-pb-1" }, { children: jsx("div", __assign({ className: 'tw-h-full' }, { children: jsxs("div", __assign({ className: 'tw-grid tw-grid-cols-1' }, { children: [offers.length > 0 ?
4164
- jsxs("div", __assign({ className: 'tw-col-span-1' }, { children: [jsx("h3", __assign({ className: '-tw-mb-2' }, { children: "Offers" })), jsx("div", __assign({ className: 'tw-flex tw-flex-wrap tw-mb-4' }, { children: offers.map(function (o) { return jsx(TagView, { tag: o, onClick: function () {
4165
- addFilterTag(o);
4166
- } }, o === null || o === void 0 ? void 0 : o.id); }) }))] })) : "", needs.length > 0 ?
4167
- jsxs("div", __assign({ className: 'tw-col-span-1' }, { children: [jsx("h3", __assign({ className: '-tw-mb-2 tw-col-span-1' }, { children: "Needs" })), jsx("div", __assign({ className: 'tw-flex tw-flex-wrap tw-mb-4' }, { children: needs.map(function (n) { return jsx(TagView, { tag: n, onClick: function () { return addFilterTag(n); } }, n === null || n === void 0 ? void 0 : n.id); }) }))] })) : ""] })) })) }))] }), ((_d = item.layer) === null || _d === void 0 ? void 0 : _d.itemType.relations) &&
4168
- jsxs(Fragment, { children: [jsx("input", { type: "radio", name: "my_tabs_2", role: "tab", className: "tw-tab [--tab-border-color:var(--fallback-bc,oklch(var(--bc)/0.2))]", "aria-label": "Relations", checked: activeTab == 7 && true, onChange: function () { return updateActiveTab(7); } }), jsx("div", __assign({ role: "tabpanel", className: "tw-tab-content tw-bg-base-100 tw-rounded-box tw-h-[calc(100dvh-280px)] tw-overflow-y-auto tw-pt-4 tw-pb-1 -tw-mr-4 -tw-mb-4 tw-overflow-x-hidden" }, { children: jsx("div", __assign({ className: 'tw-h-full' }, { children: jsxs("div", __assign({ className: 'tw-grid tw-grid-cols-1 sm:tw-grid-cols-2 md:tw-grid-cols-1 lg:tw-grid-cols-1 xl:tw-grid-cols-1 2xl:tw-grid-cols-2 tw-pb-4' }, { children: [relations && relations.map(function (i) {
4163
+ return (jsxs("div", __assign({ role: "tablist", className: "tw-tabs tw-tabs-lifted tw-mt-2 tw-mb-2 tw-px-6" }, { children: [jsx("input", { type: "radio", name: "my_tabs_2", role: "tab", className: "tw-tab [--tab-border-color:var(--fallback-bc,oklch(var(--bc)/0.2))]", "aria-label": "Info", checked: activeTab === 1, onChange: function () { return updateActiveTab(1); } }), activeTab === 1 &&
4164
+ jsxs("div", __assign({ role: "tabpanel", className: "tw-tab-content tw-bg-base-100 tw-rounded-box tw-h-[calc(100dvh-280px)] tw-overflow-y-auto fade tw-pt-2 tw-pb-4 tw-mb-4 tw-overflow-x-hidden" }, { children: [((_b = item.layer) === null || _b === void 0 ? void 0 : _b.itemType.show_start_end) &&
4165
+ jsx("div", __assign({ className: 'tw-max-w-xs' }, { children: jsx(StartEndView, { item: item }) })), jsx(TextView, { item: item }), jsx("div", { className: 'tw-h-4' }), jsx(TextView, { item: item, itemTextField: 'contact' })] })), ((_c = item.layer) === null || _c === void 0 ? void 0 : _c.itemType.offers_and_needs) && jsxs(Fragment, { children: [jsx("input", { type: "radio", name: "my_tabs_2", role: "tab", className: "tw-tab tw-min-w-[10em] [--tab-border-color:var(--fallback-bc,oklch(var(--bc)/0.2))]", "aria-label": "Offers & Needs", checked: activeTab === 3, onChange: function () { return updateActiveTab(3); } }), activeTab === 3 &&
4166
+ jsx("div", __assign({ role: "tabpanel", className: "tw-tab-content tw-bg-base-100 tw-rounded-box tw-h-[calc(100dvh-268px)] tw-overflow-y-auto fade tw-pt-4 tw-pb-1" }, { children: jsx("div", __assign({ className: 'tw-h-full' }, { children: jsxs("div", __assign({ className: 'tw-grid tw-grid-cols-1' }, { children: [offers.length > 0 &&
4167
+ jsxs("div", __assign({ className: 'tw-col-span-1' }, { children: [jsx("h3", __assign({ className: '-tw-mb-2' }, { children: "Offers" })), jsx("div", __assign({ className: 'tw-flex tw-flex-wrap tw-mb-4' }, { children: offers.map(function (o) { return jsx(TagView, { tag: o, onClick: function () { return addFilterTag(o); } }, o === null || o === void 0 ? void 0 : o.id); }) }))] })), needs.length > 0 &&
4168
+ jsxs("div", __assign({ className: 'tw-col-span-1' }, { children: [jsx("h3", __assign({ className: '-tw-mb-2 tw-col-span-1' }, { children: "Needs" })), jsx("div", __assign({ className: 'tw-flex tw-flex-wrap tw-mb-4' }, { children: needs.map(function (n) { return jsx(TagView, { tag: n, onClick: function () { return addFilterTag(n); } }, n === null || n === void 0 ? void 0 : n.id); }) }))] }))] })) })) }))] }), ((_d = item.layer) === null || _d === void 0 ? void 0 : _d.itemType.relations) && jsxs(Fragment, { children: [jsx("input", { type: "radio", name: "my_tabs_2", role: "tab", className: "tw-tab [--tab-border-color:var(--fallback-bc,oklch(var(--bc)/0.2))]", "aria-label": "Relations", checked: activeTab === 7, onChange: function () { return updateActiveTab(7); } }), activeTab === 7 &&
4169
+ jsx("div", __assign({ role: "tabpanel", className: "tw-tab-content tw-bg-base-100 tw-rounded-box tw-h-[calc(100dvh-280px)] tw-overflow-y-auto tw-pt-4 tw-pb-1 -tw-mr-4 -tw-mb-4 tw-overflow-x-hidden" }, { children: jsx("div", __assign({ className: 'tw-h-full' }, { children: jsxs("div", __assign({ className: 'tw-grid tw-grid-cols-1 sm:tw-grid-cols-2 md:tw-grid-cols-1 lg:tw-grid-cols-1 xl:tw-grid-cols-1 2xl:tw-grid-cols-2 tw-pb-4' }, { children: [relations && relations.map(function (i) {
4169
4170
  return jsxs("div", __assign({ className: 'tw-cursor-pointer tw-card tw-bg-base-200 tw-border-[1px] tw-border-base-300 tw-card-body tw-shadow-xl tw-text-base-content tw-p-6 tw-mr-4 tw-mb-4', onClick: function () { return navigate('/item/' + i.id); } }, { children: [jsx(LinkedItemsHeaderView, { unlinkPermission: updatePermission, item: i, unlinkCallback: unlinkItem, loading: loading }), jsx("div", __assign({ className: 'tw-overflow-y-auto tw-overflow-x-hidden tw-max-h-64 fade' }, { children: jsx(TextView, { truncate: true, item: i }) }))] }), i.id);
4170
4171
  }), updatePermission && jsx(ActionButton, { collection: "items", item: item, existingRelations: relations, triggerItemSelected: linkItem, colorField: item.layer.itemColorField })] })) })) }))] })] })));
4171
4172
  };