Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/developer-hub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"katex": "catalog:",
"next": "catalog:",
"next-themes": "catalog:",
"nuqs": "catalog:",
"@pythnetwork/react-hooks": "workspace:",
"react": "catalog:",
"react-aria": "catalog:",
"react-dom": "catalog:",
Expand Down Expand Up @@ -72,4 +72,4 @@
"tailwindcss": "^4.1.6",
"vercel": "catalog:"
}
}
}
2 changes: 1 addition & 1 deletion apps/developer-hub/src/components/Root/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { RootProviders } from "@pythnetwork/component-library/AppShell";
import { NuqsAdapter } from "@pythnetwork/react-hooks/nuqs-adapters-next";
import { RootProvider as FumadocsRootProvider } from "fumadocs-ui/provider";
import { NuqsAdapter } from "nuqs/adapters/next/app";
import type { ReactNode } from "react";

import "./global.css";
Expand Down
4 changes: 2 additions & 2 deletions apps/entropy-explorer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@pythnetwork/component-library": "workspace:*",
"clsx": "catalog:",
"next": "catalog:",
"nuqs": "catalog:",
"@pythnetwork/react-hooks": "workspace:",
"react": "catalog:",
"react-aria": "catalog:",
"react-dom": "catalog:",
Expand Down Expand Up @@ -52,4 +52,4 @@
"stylelint-config-standard-scss": "catalog:",
"vercel": "catalog:"
}
}
}
2 changes: 1 addition & 1 deletion apps/entropy-explorer/src/components/Root/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppShell } from "@pythnetwork/component-library/AppShell";
import { NuqsAdapter } from "nuqs/adapters/next/app";
import { NuqsAdapter } from "@pythnetwork/react-hooks/nuqs-adapters-next";
import type { ReactNode } from "react";

import {
Expand Down
4 changes: 2 additions & 2 deletions apps/insights/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"motion": "catalog:",
"next": "catalog:",
"next-themes": "catalog:",
"nuqs": "catalog:",
"@pythnetwork/react-hooks": "workspace:",
"react": "catalog:",
"react-aria": "catalog:",
"react-dom": "catalog:",
Expand Down Expand Up @@ -73,4 +73,4 @@
"stylelint-config-standard-scss": "catalog:",
"vercel": "catalog:"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import type { Button as UnstyledButton } from "@pythnetwork/component-library/un
import { StateType, useData } from "@pythnetwork/component-library/useData";
import { useDrawer } from "@pythnetwork/component-library/useDrawer";
import { useLogger } from "@pythnetwork/component-library/useLogger";
import { parseAsString, useQueryState } from "@pythnetwork/react-hooks/nuqs";
import { useMountEffect } from "@react-hookz/web";
import dynamic from "next/dynamic";
import { useRouter } from "next/navigation";
import { parseAsString, useQueryState } from "nuqs";
import type { ReactNode } from "react";
import {
Suspense,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ import type {
import { Table } from "@pythnetwork/component-library/Table";
import { useLogger } from "@pythnetwork/component-library/useLogger";
import { useQueryParamFilterPagination } from "@pythnetwork/component-library/useQueryParamsPagination";
import {
useQueryState,
parseAsStringEnum,
parseAsBoolean,
} from "@pythnetwork/react-hooks/nuqs";
import clsx from "clsx";
import { useQueryState, parseAsStringEnum, parseAsBoolean } from "nuqs";
import type { ReactNode } from "react";
import { Fragment, Suspense, useMemo, useCallback } from "react";
import { useFilter, useCollator } from "react-aria";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { parseAsStringLiteral, useQueryState } from "nuqs";
import {
parseAsStringLiteral,
useQueryState,
} from "@pythnetwork/react-hooks/nuqs";

export const RESOLUTIONS = ["1s", "1m", "5m", "1H", "1D"] as const;
export type Resolution = (typeof RESOLUTIONS)[number];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { Switch } from "@pythnetwork/component-library/Switch";
import { useLogger } from "@pythnetwork/component-library/useLogger";
import { useQueryState, parseAsBoolean } from "nuqs";
import { useQueryState, parseAsBoolean } from "@pythnetwork/react-hooks/nuqs";
import { Suspense, useCallback, useMemo } from "react";

import { Cluster } from "../../services/pyth";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { Badge } from "@pythnetwork/component-library/Badge";
import { Table } from "@pythnetwork/component-library/Table";
import { useDrawer } from "@pythnetwork/component-library/useDrawer";
import { useLogger } from "@pythnetwork/component-library/useLogger";
import { usePathname } from "next/navigation";
import {
parseAsString,
parseAsInteger,
useQueryStates,
createSerializer,
} from "nuqs";
} from "@pythnetwork/react-hooks/nuqs";
import { usePathname } from "next/navigation";
import { useMemo } from "react";
import { useCollator } from "react-aria";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import type {
import { Table } from "@pythnetwork/component-library/Table";
import { useLogger } from "@pythnetwork/component-library/useLogger";
import { useQueryParamFilterPagination } from "@pythnetwork/component-library/useQueryParamsPagination";
import { parseAsString, useQueryState } from "@pythnetwork/react-hooks/nuqs";
import { matchSorter } from "match-sorter";
import { parseAsString, useQueryState } from "nuqs";
import type { ReactNode } from "react";
import { Suspense, useCallback, useMemo } from "react";
import { useCollator } from "react-aria";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ import type {
import { Table } from "@pythnetwork/component-library/Table";
import { useLogger } from "@pythnetwork/component-library/useLogger";
import { useQueryParamFilterPagination } from "@pythnetwork/component-library/useQueryParamsPagination";
import {
useQueryState,
parseAsStringEnum,
} from "@pythnetwork/react-hooks/nuqs";
import clsx from "clsx";
import { useQueryState, parseAsStringEnum } from "nuqs";
import type { ReactNode } from "react";
import { Suspense, useMemo, useCallback } from "react";
import { useFilter, useCollator } from "react-aria";
Expand Down
2 changes: 1 addition & 1 deletion apps/insights/src/components/Root/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AppShell } from "@pythnetwork/component-library/AppShell";
import { lookup as lookupPublisher } from "@pythnetwork/known-publishers";
import { NuqsAdapter } from "nuqs/adapters/next/app";
import { NuqsAdapter } from "@pythnetwork/react-hooks/nuqs-adapters-next";
import type { ReactNode } from "react";

import { SearchButton as SearchButtonImpl } from "./search-button";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
/* eslint-disable @typescript-eslint/no-deprecated */
/* eslint-disable @typescript-eslint/no-floating-promises */
import { Menu, Transition } from '@headlessui/react'
import {
useQueryState,
parseAsStringLiteral,
} from '@pythnetwork/react-hooks/nuqs'
import { useWallet } from '@solana/wallet-adapter-react'
import type { TransactionAccount } from '@sqds/mesh/lib/types'
import { useRouter } from 'next/router'
import { useQueryState, parseAsStringLiteral } from 'nuqs'
import { useContext, useEffect, useState, useMemo, Fragment } from 'react'

import { Proposal } from './Proposal'
Expand Down
4 changes: 2 additions & 2 deletions governance/xc_admin/packages/xc_admin_frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"message_buffer": "workspace:^",
"next": "catalog:",
"next-seo": "^5.15.0",
"nuqs": "catalog:",
"@pythnetwork/react-hooks": "workspace:",
"react": "catalog:",
"react-dom": "catalog:",
"react-hot-toast": "^2.4.0",
Expand All @@ -62,4 +62,4 @@
"tailwindcss": "^3.1.8",
"vercel": "^37.12.1"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable n/no-process-env */
import { NuqsAdapter } from '@pythnetwork/react-hooks/nuqs-adapters-next'
import { WalletAdapterNetwork } from '@solana/wallet-adapter-base'
import {
ConnectionProvider,
Expand All @@ -18,7 +19,6 @@ import { clusterApiUrl } from '@solana/web3.js'
import type { AppProps } from 'next/app'
import Head from 'next/head'
import { DefaultSeo } from 'next-seo'
import { NuqsAdapter } from 'nuqs/adapters/next/pages'
import { useMemo } from 'react'
import { Toaster } from 'react-hot-toast'

Expand Down
2 changes: 1 addition & 1 deletion packages/component-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
"modern-normalize": "catalog:",
"motion": "catalog:",
"next-themes": "catalog:",
"nuqs": "catalog:",
"@pythnetwork/react-hooks": "workspace:",
"pino": "catalog:",
"react-aria": "catalog:",
"react-aria-components": "catalog:",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"use client";

import { usePathname } from "next/navigation";
import {
parseAsString,
parseAsInteger,
parseAsBoolean,
useQueryStates,
createSerializer,
} from "nuqs";
} from "@pythnetwork/react-hooks/nuqs";
import { usePathname } from "next/navigation";
import { useCallback, useMemo } from "react";

import type { SortDescriptor } from "../unstyled/Table";
Expand Down
22 changes: 22 additions & 0 deletions packages/react-hooks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Coverage directory used by tools like istanbul
coverage

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# dotenv environment variables file
.env

# Build directory
dist/

tsconfig.tsbuildinfo
12 changes: 12 additions & 0 deletions packages/react-hooks/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.vscode/
coverage/
dist/
doc/
doc*/
node_modules/
dist/
lib/
build/
node_modules/
package.json
tsconfig*.json
1 change: 1 addition & 0 deletions packages/react-hooks/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { base as default } from "@cprussin/eslint-config";
47 changes: 47 additions & 0 deletions packages/react-hooks/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"private": true,
"name": "@pythnetwork/react-hooks",
"description": "collection of utility hooks used across react applications powering parts of the pyth network",
"version": "0.0.0",
"scripts": {
"build": "ts-duality --clean --noCjs",
"clean": "rm -rf ./dist",
"fix:format": "prettier --write .",
"fix:lint": "eslint --fix . --max-warnings 0",
"test:lint": "eslint . --max-warnings 0",
"test:format": "prettier --check .",
"test:types": "tsc"
},
"devDependencies": {
"@cprussin/eslint-config": "catalog:",
"@cprussin/tsconfig": "catalog:",
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"eslint": "catalog:"
},
"dependencies": {
"nuqs": "catalog:",
"react": "catalog:",
"react-dom": "catalog:"
},
"type": "module",
"exports": {
"./nuqs-adapters-next": {
"types": "./dist/nuqs-adapters-next.d.ts",
"default": "./dist/nuqs-adapters-next.mjs"
},
"./nuqs-server": {
"types": "./dist/nuqs-server.d.ts",
"default": "./dist/nuqs-server.mjs"
},
"./nuqs-testing": {
"types": "./dist/nuqs-testing.d.ts",
"default": "./dist/nuqs-testing.mjs"
},
"./nuqs": {
"types": "./dist/nuqs.d.ts",
"default": "./dist/nuqs.mjs"
},
"./package.json": "./package.json"
}
}
1 change: 1 addition & 0 deletions packages/react-hooks/src/nuqs-adapters-next.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "nuqs/adapters/next";
1 change: 1 addition & 0 deletions packages/react-hooks/src/nuqs-server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "nuqs/server";
1 change: 1 addition & 0 deletions packages/react-hooks/src/nuqs-testing.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "nuqs/testing";
9 changes: 9 additions & 0 deletions packages/react-hooks/src/nuqs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// this file exists as a way to export a single, unified instance of
// the nuqs library, to prevent the following error:
// https://nuqs.dev/NUQS-404
// solutions have been discussed here about using nuqs in a monorepo:
// https://github.com/47ng/nuqs/issues/798
// NOTE: this helps prevent mixed ESM and CJS usages of the hooks and context providers,
// which is likely what causes the issue in bundler environments that support both
// and aren't strictly opinionated about CJS vs ESM
export * from "nuqs";
7 changes: 7 additions & 0 deletions packages/react-hooks/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"incremental": false,
"noEmit": false
}
}
4 changes: 4 additions & 0 deletions packages/react-hooks/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "@cprussin/tsconfig/base.json",
"exclude": ["node_modules", "dist"]
}
Loading
Loading