From 8c454cf0ae4650d8dfe6c8a427b8fba80b5a2c24 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Sun, 13 Dec 2020 01:49:13 -0700 Subject: [PATCH] continue typescript & chakra v1 migrations [skip ci] --- hyperglass/ui/components/buttons/reset.tsx | 2 +- .../ui/components/form/queryLocation.tsx | 11 +- hyperglass/ui/components/layout/frame.tsx | 4 +- hyperglass/ui/components/lookingGlass.tsx | 143 +++--------------- hyperglass/ui/components/output/types.ts | 6 +- hyperglass/ui/components/results/group.tsx | 14 +- hyperglass/ui/components/results/header.tsx | 12 +- .../ui/components/results/individual.tsx | 2 +- hyperglass/ui/components/select/select.tsx | 4 +- hyperglass/ui/components/select/types.ts | 2 +- hyperglass/ui/hooks/index.ts | 1 + hyperglass/ui/hooks/useDevice.ts | 15 ++ hyperglass/ui/package.json | 4 +- hyperglass/ui/types/common.ts | 10 +- hyperglass/ui/types/config.ts | 4 +- hyperglass/ui/types/data.ts | 3 +- hyperglass/ui/types/guards.ts | 16 ++ hyperglass/ui/types/index.ts | 1 + hyperglass/ui/util/common.ts | 6 + hyperglass/ui/yarn.lock | 16 +- 20 files changed, 119 insertions(+), 157 deletions(-) create mode 100644 hyperglass/ui/hooks/useDevice.ts create mode 100644 hyperglass/ui/types/guards.ts diff --git a/hyperglass/ui/components/buttons/reset.tsx b/hyperglass/ui/components/buttons/reset.tsx index 306ec6d..b2bc661 100644 --- a/hyperglass/ui/components/buttons/reset.tsx +++ b/hyperglass/ui/components/buttons/reset.tsx @@ -19,7 +19,7 @@ export const ResetButton = forwardRef((props, re aria-label="Reset Form" opacity={isSubmitting.value ? 1 : 0} {...props}> - + ); }); diff --git a/hyperglass/ui/components/form/queryLocation.tsx b/hyperglass/ui/components/form/queryLocation.tsx index 5c64a4d..cfd60df 100644 --- a/hyperglass/ui/components/form/queryLocation.tsx +++ b/hyperglass/ui/components/form/queryLocation.tsx @@ -2,7 +2,7 @@ import { useMemo } from 'react'; import { Select } from '~/components'; import { useConfig } from '~/context'; -import type { TNetwork, TSelectOption } from '~/types'; +import type { TNetwork, TSelectOptionMulti } from '~/types'; import type { TQuerySelectField } from './types'; function buildOptions(networks: TNetwork[]) { @@ -23,11 +23,12 @@ export const QueryLocation = (props: TQuerySelectField) => { const { networks } = useConfig(); const options = useMemo(() => buildOptions(networks), [networks.length]); - function handleChange(e: TSelectOption): void { - if (Array.isArray(e?.value) && e !== null) { - const value = e.value.map(sel => sel); - onChange({ field: 'query_location', value }); + function handleChange(e: TSelectOptionMulti): void { + if (e === null) { + e = []; } + const value = e.map(sel => sel.value); + onChange({ field: 'query_location', value }); } return ( diff --git a/hyperglass/ui/components/layout/frame.tsx b/hyperglass/ui/components/layout/frame.tsx index 9e4dad9..cda345b 100644 --- a/hyperglass/ui/components/layout/frame.tsx +++ b/hyperglass/ui/components/layout/frame.tsx @@ -42,9 +42,9 @@ export const Frame = (props: TFrame) => { {...props} />