From 97b7cf090a60b8d7865f7a5d406e357e562defa8 Mon Sep 17 00:00:00 2001 From: Matt Gallo Date: Tue, 3 Sep 2024 16:12:18 -0400 Subject: [PATCH] chore: cleanup gallery package dependencies --- packages/gallery/package.json | 6 -- packages/gallery/src/customTypings.d.ts | 18 ------ packages/gallery/src/main.tsx | 1 + packages/gallery/src/makeData.ts | 76 ------------------------- packages/gallery/tsconfig.app.json | 2 - packages/infiniteScroll/src/main.tsx | 20 ++++--- 6 files changed, 13 insertions(+), 110 deletions(-) delete mode 100644 packages/gallery/src/customTypings.d.ts delete mode 100644 packages/gallery/src/makeData.ts diff --git a/packages/gallery/package.json b/packages/gallery/package.json index 9cc66b3..2016918 100644 --- a/packages/gallery/package.json +++ b/packages/gallery/package.json @@ -10,14 +10,8 @@ "preview": "vite preview" }, "dependencies": { - "@carbon/ibm-products": "^2.47.0", "@carbon/react": "^1.64.1", - "@faker-js/faker": "^8.4.1", - "@tanstack/match-sorter-utils": "^8.19.4", "@tanstack/react-query": "^5.52.1", - "@tanstack/react-table": "^8.20.1", - "@tanstack/react-virtual": "^3.10.4", - "classnames": "^2.5.1", "batch-actions": "*", "customize-columns": "*", "editable-cells": "*", diff --git a/packages/gallery/src/customTypings.d.ts b/packages/gallery/src/customTypings.d.ts deleted file mode 100644 index cb1ad5d..0000000 --- a/packages/gallery/src/customTypings.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -/* eslint-disable @typescript-eslint/no-unused-vars */ -import "@tanstack/react-table"; - -declare module "@tanstack/table-core" { - interface TableOptions - extends PartialKeys, "state" | "onStateChange" | "renderFallbackValue"> { - filterFns?: FilterFns; - } - - interface FilterFns { - fuzzy: FilterFn; - } - - //allows us to define custom properties for our columns - interface ColumnMeta { - filterVariant?: 'text' | 'select' | 'checkbox' | 'number' - } -} diff --git a/packages/gallery/src/main.tsx b/packages/gallery/src/main.tsx index f0d0401..d758cb8 100644 --- a/packages/gallery/src/main.tsx +++ b/packages/gallery/src/main.tsx @@ -42,6 +42,7 @@ const renderUIShellHeader = () => ( createRoot(document.getElementById('root')!).render( + {renderUIShellHeader()} diff --git a/packages/gallery/src/makeData.ts b/packages/gallery/src/makeData.ts deleted file mode 100644 index 2751502..0000000 --- a/packages/gallery/src/makeData.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { faker } from '@faker-js/faker' - -export type Resource = { - id: string - name: string - rule: string - status: string - other: string - example: string - subRows?: Resource[] -} - -const range = (len: number) => { - const arr: number[] = [] - for (let i = 0; i < len; i++) { - arr.push(i) - } - return arr -} - -const newResource = (id: string, index: number): Resource => { - return { - id, - name: `Load balancer ${index}`, - rule: faker.helpers.shuffle([ - 'DNS delegation', - 'Round Robin' - ])[0], - status: faker.helpers.shuffle([ - 'starting', - 'active', - 'disabled', - ])[0]!, - other: 'Test', - example: faker.number.int(1000).toString(), - } -} - -export function makeData(...lens: number[]) { - const makeDataLevel = (depth = 0): Resource[] => { - const len = lens[depth]! - return range(len).map((index): Resource => { - return { - ...newResource(`load-balancer-${index}`, index), - subRows: lens[depth + 1] ? makeDataLevel(depth + 1) : undefined, - } - }) - } - - return makeDataLevel() -} - -//simulates a backend api -const data = makeData(1000) -export const fetchData = async ( - start: number, - size: number, -) => { - - //simulate a backend api - await new Promise(resolve => setTimeout(resolve, 2000)) - - return { - data: data.slice(start, start + size), - meta: { - totalRowCount: data.length, - }, - } -} - -export type ResourceApiResponse = { - data: Resource[] - meta: { - totalRowCount: number - } -} \ No newline at end of file diff --git a/packages/gallery/tsconfig.app.json b/packages/gallery/tsconfig.app.json index 4abf194..d097f62 100644 --- a/packages/gallery/tsconfig.app.json +++ b/packages/gallery/tsconfig.app.json @@ -20,8 +20,6 @@ "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, - - "types": [ "./src/customTypings.d.ts" ] }, "include": ["./src"] } diff --git a/packages/infiniteScroll/src/main.tsx b/packages/infiniteScroll/src/main.tsx index fac2fbc..81dea83 100644 --- a/packages/infiniteScroll/src/main.tsx +++ b/packages/infiniteScroll/src/main.tsx @@ -8,10 +8,12 @@ import { HeaderContainer, HeaderName, } from '@carbon/react' +import { QueryClient, QueryClientProvider, } from '@tanstack/react-query' import { InfiniteScroll } from './InfiniteScroll' import './index.scss' +const queryClient = new QueryClient() const renderUIShellHeader = () => ( ( ); createRoot(document.getElementById('root')!).render( - - {renderUIShellHeader()} - - - - - - + + + {renderUIShellHeader()} + + + + + + + )