From 00e5eb2ea216ded960b46429187d093621f73990 Mon Sep 17 00:00:00 2001 From: frzyc Date: Wed, 31 Jul 2024 20:24:49 -0700 Subject: [PATCH] move pando Document react components (#2355) * move pando Document react components * no d.ts i guess --- .../src/app/teams/[teamId]/CalcWrapper.tsx | 2 +- .../src/app/teams/[teamId]/TalentContent.tsx | 2 +- .../src/app/teams/[teamId]/TeamCharacter.tsx | 3 +-- apps/gi-frontend/tsconfig.json | 6 +++++- libs/pando/ui-sheet/project.json | 12 ++--------- .../src/components}/DocumentDisplay.tsx | 7 +------ .../ui-sheet/src/components}/FieldDisplay.tsx | 9 ++------ libs/pando/ui-sheet/src/components/index.ts | 2 ++ .../ui-sheet/src/context}/CalcContext.ts | 0 .../ui-sheet/src/context}/MemberContext.ts | 0 libs/pando/ui-sheet/src/context/index.ts | 2 ++ libs/pando/ui-sheet/src/index.ts | 8 +++---- .../ui-sheet/src/{ => types}/conditional.ts | 0 .../ui-sheet/src/{ => types}/document.ts | 0 libs/pando/ui-sheet/src/{ => types}/field.ts | 0 libs/pando/ui-sheet/src/{ => types}/header.ts | 0 libs/pando/ui-sheet/src/types/index.ts | 5 +++++ libs/pando/ui-sheet/src/{ => types}/sheet.ts | 0 libs/pando/ui-sheet/tsconfig.json | 9 +++++--- libs/pando/ui-sheet/tsconfig.lib.json | 21 ++++++++++++++++--- 20 files changed, 49 insertions(+), 39 deletions(-) rename {apps/gi-frontend/src/app/teams/[teamId] => libs/pando/ui-sheet/src/components}/DocumentDisplay.tsx (96%) rename {apps/gi-frontend/src/app/teams/[teamId] => libs/pando/ui-sheet/src/components}/FieldDisplay.tsx (97%) create mode 100644 libs/pando/ui-sheet/src/components/index.ts rename {apps/gi-frontend/src/app/teams/[teamId] => libs/pando/ui-sheet/src/context}/CalcContext.ts (100%) rename {apps/gi-frontend/src/app/teams/[teamId] => libs/pando/ui-sheet/src/context}/MemberContext.ts (100%) create mode 100644 libs/pando/ui-sheet/src/context/index.ts rename libs/pando/ui-sheet/src/{ => types}/conditional.ts (100%) rename libs/pando/ui-sheet/src/{ => types}/document.ts (100%) rename libs/pando/ui-sheet/src/{ => types}/field.ts (100%) rename libs/pando/ui-sheet/src/{ => types}/header.ts (100%) create mode 100644 libs/pando/ui-sheet/src/types/index.ts rename libs/pando/ui-sheet/src/{ => types}/sheet.ts (100%) diff --git a/apps/gi-frontend/src/app/teams/[teamId]/CalcWrapper.tsx b/apps/gi-frontend/src/app/teams/[teamId]/CalcWrapper.tsx index 4b650b652c..6eb3fd3923 100644 --- a/apps/gi-frontend/src/app/teams/[teamId]/CalcWrapper.tsx +++ b/apps/gi-frontend/src/app/teams/[teamId]/CalcWrapper.tsx @@ -12,9 +12,9 @@ import { } from '@genshin-optimizer/gi/formula' import type { IWeapon } from '@genshin-optimizer/gi/good' import { getMainStatValue } from '@genshin-optimizer/gi/util' +import { CalcContext } from '@genshin-optimizer/pando/ui-sheet' import type { ReactNode } from 'react' import { useContext, useMemo } from 'react' -import { CalcContext } from './CalcContext' import { TeamContext } from './TeamContext' import { TeamLoadoutCharacterToICharacter } from './teamUtil' diff --git a/apps/gi-frontend/src/app/teams/[teamId]/TalentContent.tsx b/apps/gi-frontend/src/app/teams/[teamId]/TalentContent.tsx index 1866917134..623858cb00 100644 --- a/apps/gi-frontend/src/app/teams/[teamId]/TalentContent.tsx +++ b/apps/gi-frontend/src/app/teams/[teamId]/TalentContent.tsx @@ -14,6 +14,7 @@ import { import { uiSheets } from '@genshin-optimizer/gi/formula-ui' import { type TalentSheetElementKey } from '@genshin-optimizer/gi/sheets' import type { UISheetElement } from '@genshin-optimizer/pando/ui-sheet' +import { DocumentDisplay } from '@genshin-optimizer/pando/ui-sheet' import { Box, CardActionArea, @@ -27,7 +28,6 @@ import { import type { ReactNode } from 'react' import { useCallback } from 'react' import { useTranslation } from 'react-i18next' -import { DocumentDisplay } from './DocumentDisplay' import type { TeamLoadoutCharacter } from './getTeam' const talentSpacing = { diff --git a/apps/gi-frontend/src/app/teams/[teamId]/TeamCharacter.tsx b/apps/gi-frontend/src/app/teams/[teamId]/TeamCharacter.tsx index 1767529e8a..11637df9bd 100644 --- a/apps/gi-frontend/src/app/teams/[teamId]/TeamCharacter.tsx +++ b/apps/gi-frontend/src/app/teams/[teamId]/TeamCharacter.tsx @@ -2,11 +2,10 @@ import { CardThemed } from '@genshin-optimizer/common/ui' import { convert, selfTag } from '@genshin-optimizer/gi/formula' +import { CalcContext, MemberContext } from '@genshin-optimizer/pando/ui-sheet' import { CardContent, CardHeader, Stack, Typography } from '@mui/material' import { useContext, useMemo, useState } from 'react' -import { CalcContext } from './CalcContext' import { CalcWrapper } from './CalcWrapper' -import { MemberContext } from './MemberContext' import CharacterTalentPane from './TalentContent' import { TeamContext } from './TeamContext' import type { TeamLoadoutCharacter } from './getTeam' diff --git a/apps/gi-frontend/tsconfig.json b/apps/gi-frontend/tsconfig.json index 1936ad9657..e412006d98 100644 --- a/apps/gi-frontend/tsconfig.json +++ b/apps/gi-frontend/tsconfig.json @@ -29,7 +29,11 @@ "../../apps/gi-frontend/.next/types/**/*.ts", "../../dist/apps/gi-frontend/.next/types/**/*.ts", "next-env.d.ts", - ".next/types/**/*.ts" + ".next/types/**/*.ts", + "../../libs/pando/ui-sheet/src/components/DocumentDisplay.tsx", + "../../libs/pando/ui-sheet/src/components/FieldDisplay.tsx", + "../../libs/pando/ui-sheet/src/context/CalcContext.ts", + "../../libs/pando/ui-sheet/src/MemberContext.ts" ], "exclude": ["node_modules", "jest.config.ts", "**/*.spec.ts", "**/*.test.ts"] } diff --git a/libs/pando/ui-sheet/project.json b/libs/pando/ui-sheet/project.json index e99430781b..c83bc22aba 100644 --- a/libs/pando/ui-sheet/project.json +++ b/libs/pando/ui-sheet/project.json @@ -3,14 +3,6 @@ "$schema": "../../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "libs/pando/ui-sheet/src", "projectType": "library", - "targets": { - "lint": { - "executor": "@nx/linter:eslint", - "outputs": ["{options.outputFile}"], - "options": { - "lintFilePatterns": ["libs/pando/ui-sheet/**/*.ts"] - } - } - }, - "tags": [] + "tags": [], + "targets": {} } diff --git a/apps/gi-frontend/src/app/teams/[teamId]/DocumentDisplay.tsx b/libs/pando/ui-sheet/src/components/DocumentDisplay.tsx similarity index 96% rename from apps/gi-frontend/src/app/teams/[teamId]/DocumentDisplay.tsx rename to libs/pando/ui-sheet/src/components/DocumentDisplay.tsx index 8e45506c0a..aaca536c25 100644 --- a/apps/gi-frontend/src/app/teams/[teamId]/DocumentDisplay.tsx +++ b/libs/pando/ui-sheet/src/components/DocumentDisplay.tsx @@ -1,15 +1,10 @@ 'use client' import type { CardBackgroundColor } from '@genshin-optimizer/common/ui' import { CardHeaderCustom, CardThemed } from '@genshin-optimizer/common/ui' -import type { - Document, - FieldsDocument, - Header, - TextDocument, -} from '@genshin-optimizer/pando/ui-sheet' import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown' import { Box, Collapse, Divider } from '@mui/material' import { useState } from 'react' +import type { Document, FieldsDocument, Header, TextDocument } from '../types' import { FieldsDisplay } from './FieldDisplay' export function DocumentDisplay({ diff --git a/apps/gi-frontend/src/app/teams/[teamId]/FieldDisplay.tsx b/libs/pando/ui-sheet/src/components/FieldDisplay.tsx similarity index 97% rename from apps/gi-frontend/src/app/teams/[teamId]/FieldDisplay.tsx rename to libs/pando/ui-sheet/src/components/FieldDisplay.tsx index 3c422766eb..73b9e8cac3 100644 --- a/apps/gi-frontend/src/app/teams/[teamId]/FieldDisplay.tsx +++ b/libs/pando/ui-sheet/src/components/FieldDisplay.tsx @@ -4,18 +4,13 @@ import { type CardBackgroundColor, } from '@genshin-optimizer/common/ui' import { valueString } from '@genshin-optimizer/common/util' -import type { - Field, - TagField, - TextField, -} from '@genshin-optimizer/pando/ui-sheet' import GroupsIcon from '@mui/icons-material/Groups' import type { ListProps, Palette, PaletteColor } from '@mui/material' import { Box, List, ListItem, Typography, styled } from '@mui/material' import type { ReactNode } from 'react' import React, { useContext } from 'react' -import { CalcContext } from './CalcContext' -import { MemberContext } from './MemberContext' +import { CalcContext, MemberContext } from '../context' +import type { Field, TagField, TextField } from '../types' export function FieldsDisplay({ fields, diff --git a/libs/pando/ui-sheet/src/components/index.ts b/libs/pando/ui-sheet/src/components/index.ts new file mode 100644 index 0000000000..c60240978f --- /dev/null +++ b/libs/pando/ui-sheet/src/components/index.ts @@ -0,0 +1,2 @@ +export * from './DocumentDisplay' +export * from './FieldDisplay' diff --git a/apps/gi-frontend/src/app/teams/[teamId]/CalcContext.ts b/libs/pando/ui-sheet/src/context/CalcContext.ts similarity index 100% rename from apps/gi-frontend/src/app/teams/[teamId]/CalcContext.ts rename to libs/pando/ui-sheet/src/context/CalcContext.ts diff --git a/apps/gi-frontend/src/app/teams/[teamId]/MemberContext.ts b/libs/pando/ui-sheet/src/context/MemberContext.ts similarity index 100% rename from apps/gi-frontend/src/app/teams/[teamId]/MemberContext.ts rename to libs/pando/ui-sheet/src/context/MemberContext.ts diff --git a/libs/pando/ui-sheet/src/context/index.ts b/libs/pando/ui-sheet/src/context/index.ts new file mode 100644 index 0000000000..1a54b56ac6 --- /dev/null +++ b/libs/pando/ui-sheet/src/context/index.ts @@ -0,0 +1,2 @@ +export * from './CalcContext' +export * from './MemberContext' diff --git a/libs/pando/ui-sheet/src/index.ts b/libs/pando/ui-sheet/src/index.ts index 0be5ed3191..0ef726ff89 100644 --- a/libs/pando/ui-sheet/src/index.ts +++ b/libs/pando/ui-sheet/src/index.ts @@ -1,5 +1,3 @@ -export * from './conditional' -export * from './document' -export * from './field' -export * from './header' -export * from './sheet' +export * from './components' +export * from './context' +export * from './types' diff --git a/libs/pando/ui-sheet/src/conditional.ts b/libs/pando/ui-sheet/src/types/conditional.ts similarity index 100% rename from libs/pando/ui-sheet/src/conditional.ts rename to libs/pando/ui-sheet/src/types/conditional.ts diff --git a/libs/pando/ui-sheet/src/document.ts b/libs/pando/ui-sheet/src/types/document.ts similarity index 100% rename from libs/pando/ui-sheet/src/document.ts rename to libs/pando/ui-sheet/src/types/document.ts diff --git a/libs/pando/ui-sheet/src/field.ts b/libs/pando/ui-sheet/src/types/field.ts similarity index 100% rename from libs/pando/ui-sheet/src/field.ts rename to libs/pando/ui-sheet/src/types/field.ts diff --git a/libs/pando/ui-sheet/src/header.ts b/libs/pando/ui-sheet/src/types/header.ts similarity index 100% rename from libs/pando/ui-sheet/src/header.ts rename to libs/pando/ui-sheet/src/types/header.ts diff --git a/libs/pando/ui-sheet/src/types/index.ts b/libs/pando/ui-sheet/src/types/index.ts new file mode 100644 index 0000000000..0be5ed3191 --- /dev/null +++ b/libs/pando/ui-sheet/src/types/index.ts @@ -0,0 +1,5 @@ +export * from './conditional' +export * from './document' +export * from './field' +export * from './header' +export * from './sheet' diff --git a/libs/pando/ui-sheet/src/sheet.ts b/libs/pando/ui-sheet/src/types/sheet.ts similarity index 100% rename from libs/pando/ui-sheet/src/sheet.ts rename to libs/pando/ui-sheet/src/types/sheet.ts diff --git a/libs/pando/ui-sheet/tsconfig.json b/libs/pando/ui-sheet/tsconfig.json index f2400abede..64e79128e9 100644 --- a/libs/pando/ui-sheet/tsconfig.json +++ b/libs/pando/ui-sheet/tsconfig.json @@ -1,13 +1,16 @@ { "extends": "../../../tsconfig.base.json", "compilerOptions": { - "module": "commonjs", + "jsx": "react-jsx", + "jsxImportSource": "@emotion/react", "forceConsistentCasingInFileNames": true, "strict": true, "noImplicitOverride": true, - "noPropertyAccessFromIndexSignature": true, + "noPropertyAccessFromIndexSignature": false, "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + "exactOptionalPropertyTypes": false, + "allowSyntheticDefaultImports": true }, "files": [], "include": [], diff --git a/libs/pando/ui-sheet/tsconfig.lib.json b/libs/pando/ui-sheet/tsconfig.lib.json index 4befa7f099..7f269c46bc 100644 --- a/libs/pando/ui-sheet/tsconfig.lib.json +++ b/libs/pando/ui-sheet/tsconfig.lib.json @@ -3,8 +3,23 @@ "compilerOptions": { "outDir": "../../../dist/out-tsc", "declaration": true, - "types": ["node"] + "types": [ + "node", + "object-overrides", + "@nx/react/typings/cssmodule.d.ts", + "@nx/react/typings/image.d.ts" + ] }, - "include": ["src/**/*.ts"], - "exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] + "exclude": [ + "jest.config.ts", + "src/**/*.spec.ts", + "src/**/*.test.ts", + "src/**/*.spec.tsx", + "src/**/*.test.tsx", + "src/**/*.spec.js", + "src/**/*.test.js", + "src/**/*.spec.jsx", + "src/**/*.test.jsx" + ], + "include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"] }