diff --git a/package.json b/package.json index c1f20ccd..e73f5764 100644 --- a/package.json +++ b/package.json @@ -113,8 +113,8 @@ "imports": { "#components/*": "./src/Components/*", "#utils/*": "./src/Utils/*", + "#types/*": "./src/types/*", "#src/*": "./src/*", - "#types/*": "./types/*", "#root/*": "./*" } } diff --git a/rollup.config.js b/rollup.config.js index 5f4a811b..0370b6cc 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -76,17 +76,16 @@ export default [ ], }, { - input: 'src/index.tsx', + input: 'dist/types/src/index.d.ts', output: [{ file: 'dist/index.d.ts', format: 'es' }], plugins: [ aliasConfig, dts({ - respectExternal: true, compilerOptions: { skipLibCheck: true, }, }), ], - external: [/\.css$/, /\.d\.ts$/], // ✅ `.d.ts` als extern behandeln + external: [/\.css$/], //, /\.d\.ts$/ }, ] diff --git a/src/Components/AppShell/AppShell.tsx b/src/Components/AppShell/AppShell.tsx index be88baba..9db9aadd 100644 --- a/src/Components/AppShell/AppShell.tsx +++ b/src/Components/AppShell/AppShell.tsx @@ -4,6 +4,8 @@ import { SetAppState } from './SetAppState' import type { AssetsApi } from '#types/AssetsApi' +export type { AssetsApi } from '#types/AssetsApi' + /** * @category AppShell */ diff --git a/src/Components/AppShell/NavBar.tsx b/src/Components/AppShell/NavBar.tsx index 08971877..36ecee76 100644 --- a/src/Components/AppShell/NavBar.tsx +++ b/src/Components/AppShell/NavBar.tsx @@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from 'react' import { Link, useLocation } from 'react-router-dom' import { toast } from 'react-toastify' -import { useAuth } from '#components/Auth' +import { useAuth } from '#components/Auth/useAuth' import { useItems } from '#components/Map/hooks/useItems' import type { Item } from '#types/Item' diff --git a/src/Components/AppShell/index.tsx b/src/Components/AppShell/index.tsx index 839a969c..72464ef5 100644 --- a/src/Components/AppShell/index.tsx +++ b/src/Components/AppShell/index.tsx @@ -1,4 +1,4 @@ -export { AppShell } from './AppShell' +export * from './AppShell' export { SideBar } from './SideBar' export { Content } from './Content' export { Sitemap } from './Sitemap' diff --git a/src/Components/Auth/index.tsx b/src/Components/Auth/index.tsx index 2a53f98d..c8fe3b90 100644 --- a/src/Components/Auth/index.tsx +++ b/src/Components/Auth/index.tsx @@ -1,4 +1,4 @@ -export { AuthProvider, useAuth } from './useAuth' +export { AuthProvider, UserApi, UserItem } from './useAuth' export { LoginPage } from './LoginPage' export { SignupPage } from './SignupPage' export { RequestPasswordPage } from './RequestPasswordPage' diff --git a/src/Components/Auth/useAuth.tsx b/src/Components/Auth/useAuth.tsx index 1cbba54c..ffde8af5 100644 --- a/src/Components/Auth/useAuth.tsx +++ b/src/Components/Auth/useAuth.tsx @@ -8,6 +8,9 @@ import { createContext, useState, useContext, useEffect } from 'react' import type { UserApi } from '#types/UserApi' import type { UserItem } from '#types/UserItem' +export type { UserApi } from '#types/UserApi' +export type { UserItem } from '#types/UserItem' + interface AuthProviderProps { userApi: UserApi children?: React.ReactNode diff --git a/src/Components/Gaming/Quests.tsx b/src/Components/Gaming/Quests.tsx index 07fa54c1..2d14488d 100644 --- a/src/Components/Gaming/Quests.tsx +++ b/src/Components/Gaming/Quests.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react' -import { useAuth } from '#components/Auth' +import { useAuth } from '#components/Auth/useAuth' import { useItems } from '#components/Map/hooks/useItems' import { useQuestsOpen, useSetQuestOpen } from './hooks/useQuests' diff --git a/src/Components/Map/Layer.tsx b/src/Components/Map/Layer.tsx index 01ce5946..a5071cb7 100644 --- a/src/Components/Map/Layer.tsx +++ b/src/Components/Map/Layer.tsx @@ -27,6 +27,11 @@ import type { Tag } from '#types/Tag' import type { Popup } from 'leaflet' import type { ReactElement, ReactNode } from 'react' +export type { Item } from '#types/Item' +export type { LayerProps } from '#types/LayerProps' +export type { Tag } from '#types/Tag' +export type { Popup } from 'leaflet' + /** * @category Map */ diff --git a/src/Components/Map/Permissions.tsx b/src/Components/Map/Permissions.tsx index 47a61a1c..4091319b 100644 --- a/src/Components/Map/Permissions.tsx +++ b/src/Components/Map/Permissions.tsx @@ -1,6 +1,6 @@ import { useEffect } from 'react' -import { useAuth } from '#components/Auth' +import { useAuth } from '#components/Auth/useAuth' import { useSetPermissionData, useSetPermissionApi, useSetAdminRole } from './hooks/usePermissions' @@ -8,17 +8,20 @@ import type { ItemsApi } from '#types/ItemsApi' import type { Permission } from '#types/Permission' /** - * @category Map + * @category Types */ -export function Permissions({ - data, - api, - adminRole, -}: { +export interface PermissionsProps { data?: Permission[] api?: ItemsApi adminRole?: string -}) { +} +export type { Permission } from '#types/Permission' +export type { ItemsApi } from '#types/ItemsApi' + +/** + * @category Map + */ +export function Permissions({ data, api, adminRole }: PermissionsProps) { const setPermissionData = useSetPermissionData() const setPermissionApi = useSetPermissionApi() const setAdminRole = useSetAdminRole() diff --git a/src/Components/Map/Subcomponents/Controls/GratitudeControl.tsx b/src/Components/Map/Subcomponents/Controls/GratitudeControl.tsx index 873c06e1..473151b0 100644 --- a/src/Components/Map/Subcomponents/Controls/GratitudeControl.tsx +++ b/src/Components/Map/Subcomponents/Controls/GratitudeControl.tsx @@ -1,6 +1,6 @@ import { useNavigate } from 'react-router-dom' -import { useAuth } from '#components/Auth' +import { useAuth } from '#components/Auth/useAuth' export const GratitudeControl = () => { const navigate = useNavigate() diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx index 27bb83a2..e33684d3 100644 --- a/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx @@ -27,12 +27,14 @@ export const TextView = ({ text, truncate = false, rawText, + itemTextField, }: { item?: Item - itemId: string + itemId?: string text?: string truncate?: boolean rawText?: string + itemTextField?: string }) => { if (item) { text = item.text @@ -40,6 +42,8 @@ export const TextView = ({ } const tags = useTags() const addFilterTag = useAddFilterTag() + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const itemTextFieldDummy = itemTextField let innerText = '' let replacedText = '' @@ -125,7 +129,7 @@ export const TextView = ({ }: { children: string tag: Tag - itemId: string + itemId?: string }) => { return ( { const [loading, setLoading] = useState(false) const [addItemPopupType, setAddItemPopupType] = useState('') + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const parameterFieldDummy = parameterField const tabRef = useRef(null) diff --git a/src/index.tsx b/src/index.tsx index 1446e5a5..0e6c5864 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,43 +1,12 @@ import './index.css' -export { - UtopiaMap, - Layer, - Tags, - Permissions, - ItemForm, - ItemView, - PopupTextAreaInput, - PopupStartEndInput, - PopupTextInput, - PopupButton, - TextView, - StartEndView, - PopupCheckboxInput, -} from './Components/Map' -export { AppShell, Content, SideBar, Sitemap } from './Components/AppShell' -export { - AuthProvider, - LoginPage, - SignupPage, - RequestPasswordPage, - SetNewPasswordPage, -} from './Components/Auth' -export { UserSettings, ProfileView, ProfileForm } from './Components/Profile' -export { Quests, Modal } from './Components/Gaming' -export { - TitleCard, - CardPage, - MapOverlayPage, - OverlayItemsIndexPage, - MoonCalendar, - SelectUser, - AttestationForm, - MarketView, -} from './Components/Templates' -export { TextInput, TextAreaInput, SelectBox } from './Components/Input' - -export * from './types' +export * from './Components/Map' +export * from './Components/AppShell' +export * from './Components/Auth' +export * from './Components/Profile' +export * from './Components/Gaming' +export * from './Components/Templates' +export * from './Components/Input' declare global { interface Window { diff --git a/src/types/AssetsApi.d.ts b/src/types/AssetsApi.d.ts index f2005016..7a8e9e77 100644 --- a/src/types/AssetsApi.d.ts +++ b/src/types/AssetsApi.d.ts @@ -1,3 +1,6 @@ +/** + * @category Types + */ export interface AssetsApi { upload(file: Blob, title: string): Promise<{ id: string }> url: string diff --git a/src/types/Item.d.ts b/src/types/Item.d.ts index 8723732c..4e84e992 100644 --- a/src/types/Item.d.ts +++ b/src/types/Item.d.ts @@ -15,6 +15,9 @@ interface GalleryItem { } } +/** + * @category Types + */ export interface Item { id: string name: string diff --git a/src/types/ItemType.d.ts b/src/types/ItemType.d.ts index 9a4f621c..df56aff7 100644 --- a/src/types/ItemType.d.ts +++ b/src/types/ItemType.d.ts @@ -2,14 +2,18 @@ import type { Key } from 'react' export interface ItemType { name: string + show_name_input: boolean + show_profile_button: boolean show_start_end: boolean + show_start_end_input: boolean show_text: boolean + show_text_input: boolean + custom_text: string // eslint-disable-next-line @typescript-eslint/no-explicit-any profileTemplate: { collection: string | number; id: Key | null | undefined; item: any }[] offers_and_needs: boolean icon_as_labels: unknown relations: boolean template: string - show_start_end_input: boolean questlog: boolean } diff --git a/src/types/ItemsApi.d.ts b/src/types/ItemsApi.d.ts index 54553c1e..e20b2ed8 100644 --- a/src/types/ItemsApi.d.ts +++ b/src/types/ItemsApi.d.ts @@ -1,3 +1,6 @@ +/** + * @category Types + */ export interface ItemsApi { getItems(): Promise getItem?(id: string): Promise diff --git a/src/types/LayerProps.d.ts b/src/types/LayerProps.d.ts index fef17678..e1b94b8b 100644 --- a/src/types/LayerProps.d.ts +++ b/src/types/LayerProps.d.ts @@ -3,6 +3,9 @@ import type { ItemFormPopupProps } from './ItemFormPopupProps' import type { ItemsApi } from './ItemsApi' import type { ItemType } from './ItemType' +/** + * @category Types + */ export interface LayerProps { id?: string data?: Item[] diff --git a/src/types/Permission.d.ts b/src/types/Permission.d.ts index 57067fee..871558a2 100644 --- a/src/types/Permission.d.ts +++ b/src/types/Permission.d.ts @@ -1,6 +1,9 @@ import type { PermissionAction } from './PermissionAction' import type { PermissionCondition } from './PermissionCondition' +/** + * @category Types + */ export interface Permission { id?: string policy?: { name: string } diff --git a/src/types/Tag.d.ts b/src/types/Tag.d.ts index 1dc7c5a9..0999d7cd 100644 --- a/src/types/Tag.d.ts +++ b/src/types/Tag.d.ts @@ -1,3 +1,6 @@ +/** + * @category Types + */ export interface Tag { color: string id: string diff --git a/src/types/UserApi.d.ts b/src/types/UserApi.d.ts index 6c36cd4e..a35e079d 100644 --- a/src/types/UserApi.d.ts +++ b/src/types/UserApi.d.ts @@ -1,5 +1,8 @@ import type { UserItem } from './UserItem' +/** + * @category Types + */ export interface UserApi { register(email: string, password: string, userName: string): Promise login(email: string, password: string): Promise diff --git a/src/types/UserItem.d.ts b/src/types/UserItem.d.ts index 1d28817e..68ccb8d7 100644 --- a/src/types/UserItem.d.ts +++ b/src/types/UserItem.d.ts @@ -1,5 +1,8 @@ import type { Profile } from './Profile' +/** + * @category Types + */ export interface UserItem { id?: string // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/src/types/index.ts b/src/types/index.ts deleted file mode 100644 index 42cb2117..00000000 --- a/src/types/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export type { ItemsApi } from './ItemsApi' -export type { Tag } from './Tag' -export type { Item } from './Item' -export type { Permission } from './Permission' -export type { LayerProps } from './LayerProps' -export type { UserApi } from './UserApi' -export type { UserItem } from './UserItem' -export type { UtopiaMapProps } from './UtopiaMapProps' -export type { AssetsApi } from './AssetsApi' diff --git a/tsconfig.json b/tsconfig.json index 69322b8e..2a66fedf 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,15 +22,15 @@ "paths": { "#components/*": ["./src/Components/*"], "#utils/*": ["./src/Utils/*"], - "#src/*": ["./src/*"], "#types/*": ["./src/types/*"], + "#src/*": ["./src/*"], "#root/*": ["./*"] } }, "include": ["src", "vite.config.ts", "setupTest.ts", "cypress.config.ts", "cypress/support/commands.ts", "cypress/support/component.ts"], "exclude": ["node_modules", "dist", "example", "rollup.config.mjss"], "typeRoots": [ - "./types", + "./src/types", "./node_modules/@types/" ] }