utopia-ui 3.0.51 → 3.0.53
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.d.ts +208 -0
- package/dist/index.js +20 -5
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/dist/types.d.ts +0 -337
package/dist/index.d.ts
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
import { LatLng } from 'leaflet';
|
2
|
+
import { Geometry, Point, GeoJsonObject } from 'geojson';
|
3
|
+
|
4
|
+
interface AssetsApi {
|
5
|
+
upload(file: Blob, title: string): Promise<{ id: string }>
|
6
|
+
url: string
|
7
|
+
}
|
8
|
+
|
9
|
+
interface ItemsApi<T> {
|
10
|
+
getItems(): Promise<T[]>
|
11
|
+
getItem?(id: string): Promise<T>
|
12
|
+
createItem?(item: T): Promise<T>
|
13
|
+
updateItem?(item: T): Promise<T>
|
14
|
+
deleteItem?(id: string): Promise<boolean>
|
15
|
+
collectionName?: string
|
16
|
+
}
|
17
|
+
|
18
|
+
interface ItemFormPopupProps {
|
19
|
+
position: LatLng
|
20
|
+
layer: LayerProps
|
21
|
+
item?: Item
|
22
|
+
children?: React.ReactNode
|
23
|
+
setItemFormPopup?: React.Dispatch<React.SetStateAction<ItemFormPopupProps | null>>
|
24
|
+
}
|
25
|
+
|
26
|
+
interface ItemType {
|
27
|
+
name: string
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
29
|
+
[key: string]: any
|
30
|
+
}
|
31
|
+
|
32
|
+
interface LayerProps {
|
33
|
+
id?: string
|
34
|
+
data?: Item[]
|
35
|
+
children?: React.ReactNode
|
36
|
+
name: string
|
37
|
+
menuIcon: string
|
38
|
+
menuColor: string
|
39
|
+
menuText: string
|
40
|
+
markerIcon: string
|
41
|
+
markerShape: string
|
42
|
+
markerDefaultColor: string
|
43
|
+
markerDefaultColor2?: string
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
45
|
+
api?: ItemsApi<any>
|
46
|
+
itemType: ItemType
|
47
|
+
itemNameField?: string
|
48
|
+
itemSubnameField?: string
|
49
|
+
itemTextField?: string
|
50
|
+
itemAvatarField?: string
|
51
|
+
itemColorField?: string
|
52
|
+
itemOwnerField?: string
|
53
|
+
itemTagsField?: string
|
54
|
+
itemLatitudeField?: string
|
55
|
+
itemLongitudeField?: string
|
56
|
+
itemOffersField?: string
|
57
|
+
itemNeedsField?: string
|
58
|
+
onlyOnePerOwner?: boolean
|
59
|
+
customEditLink?: string
|
60
|
+
customEditParameter?: string
|
61
|
+
public_edit_items?: boolean
|
62
|
+
listed?: boolean
|
63
|
+
item_presets?: Record<string, unknown>
|
64
|
+
setItemFormPopup?: React.Dispatch<React.SetStateAction<ItemFormPopupProps | null>>
|
65
|
+
itemFormPopup?: ItemFormPopupProps | null
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
67
|
+
clusterRef?: any
|
68
|
+
}
|
69
|
+
|
70
|
+
interface Relation {
|
71
|
+
related_items_id: string
|
72
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
73
|
+
[key: string]: any
|
74
|
+
}
|
75
|
+
|
76
|
+
interface Profile {
|
77
|
+
id?: string
|
78
|
+
avatar?: string
|
79
|
+
color?: string
|
80
|
+
name: string
|
81
|
+
text: string
|
82
|
+
geoposition?: Geometry
|
83
|
+
}
|
84
|
+
|
85
|
+
interface UserItem {
|
86
|
+
id?: string
|
87
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
88
|
+
role?: any
|
89
|
+
email?: string
|
90
|
+
password?: string
|
91
|
+
profile?: Profile
|
92
|
+
first_name?: string
|
93
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
94
|
+
[key: string]: any
|
95
|
+
}
|
96
|
+
|
97
|
+
interface Item {
|
98
|
+
id: string
|
99
|
+
name: string
|
100
|
+
text: string
|
101
|
+
position?: Point
|
102
|
+
date_created?: string
|
103
|
+
date_updated?: string | null
|
104
|
+
start?: string
|
105
|
+
end?: string
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
107
|
+
api?: ItemsApi<any>
|
108
|
+
tags?: string[]
|
109
|
+
layer?: LayerProps
|
110
|
+
relations?: Relation[]
|
111
|
+
parent?: string
|
112
|
+
subname?: string
|
113
|
+
public_edit?: boolean
|
114
|
+
slug?: string
|
115
|
+
user_created?: UserItem
|
116
|
+
image?: string
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
118
|
+
[key: string]: any
|
119
|
+
/* constructor(
|
120
|
+
id: string,
|
121
|
+
name: string,
|
122
|
+
text: string,
|
123
|
+
position: Geometry,
|
124
|
+
layer?: LayerProps,
|
125
|
+
api?: ItemsApi<any>,
|
126
|
+
) {
|
127
|
+
this.id = id
|
128
|
+
this.name = name
|
129
|
+
this.text = text
|
130
|
+
this.position = position
|
131
|
+
this.layer = layer
|
132
|
+
this.api = api
|
133
|
+
} */
|
134
|
+
}
|
135
|
+
|
136
|
+
interface Tag {
|
137
|
+
color: string
|
138
|
+
id: string
|
139
|
+
name: string
|
140
|
+
offer_or_need?: boolean
|
141
|
+
}
|
142
|
+
|
143
|
+
interface FormState {
|
144
|
+
color: string
|
145
|
+
id: string
|
146
|
+
group_type: string
|
147
|
+
status: string
|
148
|
+
name: string
|
149
|
+
subname: string
|
150
|
+
text: string
|
151
|
+
contact: string
|
152
|
+
telephone: string
|
153
|
+
next_appointment: string
|
154
|
+
image: string
|
155
|
+
marker_icon: string
|
156
|
+
offers: Tag[]
|
157
|
+
needs: Tag[]
|
158
|
+
relations: Item[]
|
159
|
+
}
|
160
|
+
|
161
|
+
type PermissionAction = 'create' | 'read' | 'update' | 'delete'
|
162
|
+
|
163
|
+
interface PermissionCondition {
|
164
|
+
user_created?: {
|
165
|
+
_eq: string // Erwartet den speziellen Wert "$CURRENT_USER" oder eine spezifische UUID
|
166
|
+
}
|
167
|
+
public_edit?: {
|
168
|
+
_eq: boolean // Erwartet den speziellen Wert "$CURRENT_USER" oder eine spezifische UUID
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
interface Permission {
|
173
|
+
id?: string
|
174
|
+
policy?: { name: string }
|
175
|
+
collection: string
|
176
|
+
action: PermissionAction
|
177
|
+
permissions?: {
|
178
|
+
// Optional, für spezifische Bedingungen wie `user_created`
|
179
|
+
_and: PermissionCondition[]
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
interface UserApi {
|
184
|
+
register(email: string, password: string, userName: string): Promise<void>
|
185
|
+
login(email: string, password: string): Promise<UserItem | undefined>
|
186
|
+
logout(): Promise<void>
|
187
|
+
getUser(): Promise<UserItem>
|
188
|
+
getToken(): Promise<string | null>
|
189
|
+
updateUser(user: UserItem): Promise<void>
|
190
|
+
requestPasswordReset(email: string, reset_url?: string)
|
191
|
+
passwordReset(token: string, new_password: string)
|
192
|
+
}
|
193
|
+
|
194
|
+
interface UtopiaMapProps {
|
195
|
+
height?: string
|
196
|
+
width?: string
|
197
|
+
center?: [number, number]
|
198
|
+
zoom?: number
|
199
|
+
tags?: Tag[]
|
200
|
+
children?: React.ReactNode
|
201
|
+
geo?: GeoJsonObject
|
202
|
+
showFilterControl?: boolean
|
203
|
+
showLayerControl?: boolean
|
204
|
+
showGratitudeControl?: boolean
|
205
|
+
infoText?: string
|
206
|
+
}
|
207
|
+
|
208
|
+
export type { AssetsApi, FormState, Item, ItemFormPopupProps, ItemType, ItemsApi, LayerProps, Permission, PermissionAction, PermissionCondition, Profile, Relation, Tag, UserApi, UserItem, UtopiaMapProps };
|
package/dist/index.js
CHANGED
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { DomEvent, divIcon, Point, control, marker, LatLng, LatLngBounds } from 'leaflet';
|
3
3
|
import { useMap, useMapEvents, TileLayer, GeoJSON, MapContainer, Popup, Marker, Tooltip } from 'react-leaflet';
|
4
4
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
5
|
-
import { createContext, useContext, useState, useCallback, useReducer, useEffect, createRef, useRef, memo, Children,
|
5
|
+
import { createContext, useContext, useState, useCallback, useReducer, useEffect, createRef, useRef, memo, Children, cloneElement, isValidElement, forwardRef } from 'react';
|
6
6
|
import { useNavigate, useLocation, BrowserRouter, Link, Outlet, NavLink } from 'react-router-dom';
|
7
7
|
import { toast, ToastContainer } from 'react-toastify';
|
8
8
|
import 'leaflet/dist/leaflet.css';
|
@@ -12,7 +12,7 @@ import 'leaflet.locatecontrol/dist/L.Control.Locate.css';
|
|
12
12
|
import Markdown from 'react-markdown';
|
13
13
|
import remarkBreaks from 'remark-breaks';
|
14
14
|
import 'react-toastify/dist/ReactToastify.css';
|
15
|
-
import {
|
15
|
+
import { string, node } from 'prop-types';
|
16
16
|
import InformationCircleIcon from '@heroicons/react/24/outline/InformationCircleIcon';
|
17
17
|
import QuestionMarkIcon from '@heroicons/react/24/outline/QuestionMarkCircleIcon';
|
18
18
|
import ChevronRightIcon from '@heroicons/react/24/outline/ChevronRightIcon';
|
@@ -1147,9 +1147,6 @@ function AddButton({ triggerAction, }) {
|
|
1147
1147
|
hasUserPermission(layer.api.collectionName, 'create', undefined, layer) &&
|
1148
1148
|
layer.listed && (jsx("li", { children: jsx("a", { children: jsx("div", { className: 'tw-tooltip tw-tooltip-left', "data-tip": layer.menuText, children: jsx("button", { tabIndex: 0, className: 'tw-z-500 tw-border-0 tw-pl-2 tw-p-0 tw-mb-3 tw-w-10 tw-h-10 tw-cursor-pointer tw-rounded-full tw-mouse tw-drop-shadow-md tw-transition tw-ease-in tw-duration-200 focus:tw-outline-none', style: { backgroundColor: layer.menuColor || '#777' }, onClick: () => {
|
1149
1149
|
triggerAction(layer);
|
1150
|
-
}, onTouchEnd: (e) => {
|
1151
|
-
triggerAction(layer);
|
1152
|
-
e.preventDefault();
|
1153
1150
|
}, children: jsx("img", { src: layer.menuIcon, className: 'tw-h-6 tw-w-6 tw-text-white', style: { filter: 'invert(100%) brightness(200%)' } }) }) }) }) }, layer.name))) })] })) : ('') }));
|
1154
1151
|
}
|
1155
1152
|
|
@@ -1373,6 +1370,10 @@ function LayerControl() {
|
|
1373
1370
|
}
|
1374
1371
|
|
1375
1372
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
1373
|
+
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
1374
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
1375
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
1376
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
1376
1377
|
const useTimeout = (callback, delay) => {
|
1377
1378
|
const callbackRef = useRef(callback);
|
1378
1379
|
const timeoutRef = useRef();
|
@@ -1413,6 +1414,7 @@ function encodeTag(string) {
|
|
1413
1414
|
}
|
1414
1415
|
|
1415
1416
|
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
1417
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
1416
1418
|
const createSvg = (shape, markerColor, borderColor) => {
|
1417
1419
|
const svgMap = {
|
1418
1420
|
circle: '<svg width="32" height="44" viewBox="0 0 35 45" xmlns="http://www.w3.org/2000/svg"><path d="M17.5 2.746c-8.284 0-15 6.853-15 15.307 0 .963.098 1.902.265 2.816a15.413 15.413 0 002.262 5.684l.134.193 12.295 17.785 12.439-17.863.056-.08a15.422 15.422 0 002.343-6.112c.123-.791.206-1.597.206-2.423 0-8.454-6.716-15.307-15-15.307" fill="' +
|
@@ -4187,6 +4189,16 @@ function UserSettings() {
|
|
4187
4189
|
}
|
4188
4190
|
|
4189
4191
|
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
4192
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
4193
|
+
/* eslint-disable @typescript-eslint/prefer-optional-chain */
|
4194
|
+
/* eslint-disable @typescript-eslint/restrict-plus-operands */
|
4195
|
+
/* eslint-disable @typescript-eslint/restrict-template-expressions */
|
4196
|
+
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
4197
|
+
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
4198
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
4199
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
4200
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
4201
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
4190
4202
|
// eslint-disable-next-line promise/avoid-new
|
4191
4203
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
4192
4204
|
const linkItem = async (id, item, updateItem) => {
|
@@ -4835,6 +4847,9 @@ var css_248z = ".picker {\n position: relative;\n }\n \n .swatch {\n wi
|
|
4835
4847
|
styleInject(css_248z);
|
4836
4848
|
|
4837
4849
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
4850
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
4851
|
+
/* eslint-disable @typescript-eslint/prefer-optional-chain */
|
4852
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
4838
4853
|
// Improved version of https://usehooks.com/useOnClickOutside/
|
4839
4854
|
const useClickOutside = (ref, handler) => {
|
4840
4855
|
useEffect(() => {
|