Skip to content

Commit

Permalink
update typings
Browse files Browse the repository at this point in the history
  • Loading branch information
CyberCookie committed Jan 16, 2025
1 parent eef9b6d commit d8a94ab
Show file tree
Hide file tree
Showing 25 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions client_core/hooks/did_update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ type EffectCB = Parameters<typeof useLayoutEffect>[0]

type ExtendedRef = {
[key in typeof symbolIsRendered]: undefined | boolean
} & React.MutableRefObject<undefined>
} & React.RefObject<null>


const symbolIsRendered = Symbol('rendered')
Expand All @@ -17,7 +17,7 @@ const symbolIsRendered = Symbol('rendered')
* @param dependencies React.useLayoutEffect's second parameter
* @param ref Optional reusable ref created with React.useRef
*/
function useDidUpdate(fn: EffectCB, dependencies: React.DependencyList, ref = useRef()) {
function useDidUpdate(fn: EffectCB, dependencies: React.DependencyList, ref = useRef(null)) {
useLayoutEffect(() => {
let retFn!: ReturnType<EffectCB>

Expand Down
4 changes: 2 additions & 2 deletions client_core/hooks/previous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useRef, useLayoutEffect } from 'react'

type ExtendedRef = {
[key in typeof symbolPrevValue]: any
} & React.MutableRefObject<undefined>
} & React.RefObject<null>


const symbolPrevValue = Symbol('prev_value')
Expand All @@ -15,7 +15,7 @@ const symbolPrevValue = Symbol('prev_value')
* @param ref Optional reusable ref created with React.useRef
* @returns previous value or undefined if it's first render
*/
function usePrevious(value: any, ref = useRef()) {
function usePrevious(value: any, ref = useRef(null)) {
useLayoutEffect(() => {
(ref as ExtendedRef)[symbolPrevValue] = value
}, [ value ])
Expand Down
4 changes: 2 additions & 2 deletions client_core/router/Router/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function Router(props: RouterProps) {
const lastIndex = childrenDepth - 1
if (prevChildrenArray[lastIndex].traversePath == childrenArray[lastIndex].traversePath) {
childrenArray.push({
El: () => '' as unknown as JSX.Element,
El: () => '' as unknown as React.JSX.Element,
traversePath: `${childrenArray[lastIndex].traversePath}/`,
historyState: null
})
Expand Down Expand Up @@ -163,7 +163,7 @@ function Router(props: RouterProps) {
}


return resultElement as JSX.Element
return resultElement as React.JSX.Element
}


Expand Down
2 changes: 1 addition & 1 deletion client_core/router/Router/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type GetPageParams = {
onEnter: ChildrenArrayEl['onEnter']
onLeave: ChildrenArrayEl['onLeave']
urlParams: URLparams
resultElement: JSX.Element | undefined
resultElement: React.JSX.Element | undefined
}


Expand Down
2 changes: 1 addition & 1 deletion client_core/ui/DataTable/helpers/apply_virtualization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function applyVirtualization(params: UseVirtualizationParams) {
} = params as VirtualizationMergedProps


rootAttributes.ref = useRef() as Ref
rootAttributes.ref = useRef(null)

const [ virtualizationState, setVirtualizationState ] = useState<ScrollTopState>( getDefaultState() )
const { scrollTop } = virtualizationState
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { MergedProps, State } from '../types'


type Ref = React.MutableRefObject<HTMLDivElement>
type Ref = React.RefObject<HTMLDivElement>

type Virtualization = NonNullable<MergedProps['virtualization']>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function getSearchOptions(props: MergedProps, state: State, onSelect: onSelectIn
const { searchString, arrowSelectIndex } = state
const searchLower = searchString?.toLowerCase()

const options: JSX.Element[] = []
const options: React.JSX.Element[] = []
let selectedOption, selectedOptionIndex
for (let i = 0; i < searchOptions.length; i++) {
const option = searchOptions[i]
Expand Down
2 changes: 1 addition & 1 deletion client_core/ui/DropdownSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const DropdownSearch = component<Props, DefaultProps>(
const isShowOptions = isFocused
&& (showOnFocus || (searchString ? searchString.length : 0) >= minInputLength)

let optionsElement: JSX.Element | undefined
let optionsElement: React.JSX.Element | undefined
let selectedOption: Option | undefined
let selectedOptionIndex: number | undefined
if (isShowOptions) {
Expand Down
2 changes: 1 addition & 1 deletion client_core/ui/Input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const Input = component<Props, DefaultProps>(
: value
}
if (autofocus || mask || prefixOrSuffix) {
inputProps.ref = useRef() as InputRef
inputProps.ref = useRef(null)

autofocus && useEffect(() => {
disabled || (inputProps.ref as InputRef).current.focus()
Expand Down
2 changes: 1 addition & 1 deletion client_core/ui/Input/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type InnerInputAttributes = {
onChange?(e: onChangeEventType): void
} & ReactTagAttributes<HTMLInputElement, React.InputHTMLAttributes<HTMLInputElement>>

type InputRef = React.MutableRefObject<HTMLInputElement>
type InputRef = React.RefObject<HTMLInputElement>

type DebounceStore = ReactStore<{
debounceValue: string | undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type GetStepperButtons = (
onPickerFocus: ComponentFocusEventHandler | undefined
}
) => {
stepperElement: JSX.Element
stepperElement: React.JSX.Element
isDisabledUp: boolean
isDisabledDown: boolean
}
Expand Down
6 changes: 3 additions & 3 deletions client_core/ui/NumberPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const NumberPicker = component<Props, DefaultProps>(
const numberMask = buildInputRegexp(min, max, precision, regexp)


const ref = useRef() as React.MutableRefObject<HTMLDivElement>
const ref = useRef(null)

const _inputStore = inputStore || useState(getDefaultInputStoreState())
const [{ isFocused }, setInputState ] = _inputStore
Expand All @@ -97,7 +97,7 @@ const NumberPicker = component<Props, DefaultProps>(
e.stopPropagation()

const { relatedTarget } = e.nativeEvent
if (!relatedTarget || !(ref.current.contains(relatedTarget as Node))) {
if (!relatedTarget || !((ref.current! as HTMLDivElement).contains(relatedTarget as Node))) {

onBlur?.(e)
e.defaultPrevented || setInputState({
Expand Down Expand Up @@ -199,7 +199,7 @@ const NumberPicker = component<Props, DefaultProps>(
disabled: disabled || disabledInput,
onBlur(event) {
const { relatedTarget } = event.nativeEvent
if (!relatedTarget || !ref.current.contains(relatedTarget as Node)) {
if (!relatedTarget || !(ref.current! as HTMLDivElement).contains(relatedTarget as Node)) {
if (!event.defaultPrevented) {

let newStringValue!: string
Expand Down
6 changes: 3 additions & 3 deletions client_core/ui/Pagination/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const getPageElement: GetPageElement = (page: number, { curPage, theme }) => (
key={ page } data-page={ page } children={ page } />
)

function fillGap(start: number, end: number, result: JSX.Element[], props: MergedProps, isLastGap?: boolean) {
function fillGap(start: number, end: number, result: React.JSX.Element[], props: MergedProps, isLastGap?: boolean) {
const { theme, separator } = props

const elementToPush = (start - end) == 1
Expand All @@ -69,7 +69,7 @@ function fillGap(start: number, end: number, result: JSX.Element[], props: Merge
result.push(elementToPush)
}

function getElementsRange(from: number, to: number, result: JSX.Element[], props: MergedProps) {
function getElementsRange(from: number, to: number, result: React.JSX.Element[], props: MergedProps) {
for (let i = from; i <= to; i++) {
result.push(getPageElement(i, props))
}
Expand All @@ -82,7 +82,7 @@ function getPaginationVisuals(mergedProps: MergedProps, numberOfPages: number) {

const middlePluseSide = elementsByMiddle + elementsBySide
const maxLength = middlePluseSide * 2 + 3
const result: JSX.Element[] = []
const result: React.JSX.Element[] = []


if (maxLength > numberOfPages) getElementsRange(1, numberOfPages, result, mergedProps)
Expand Down
2 changes: 1 addition & 1 deletion client_core/ui/Pagination/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
} from '../_internals/types'


type GetPageElement = (page: number, props: MergedProps) => JSX.Element
type GetPageElement = (page: number, props: MergedProps) => React.JSX.Element


type Theme = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ type GetRangeElement = (
className: string | undefined,
width: number,
isVertical: MergedProps['isVertical']
) => JSX.Element
) => React.JSX.Element

type GetRangePickerElement = (
key: string,
props: MergedProps,
width: number
) => JSX.Element
) => React.JSX.Element


export type { GetRangeElement, GetRangePickerElement }
4 changes: 2 additions & 2 deletions client_core/ui/Select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ const Select = component<Props, DefaultProps>(
[ theme._error, isError ],
[ theme._disabled, disabled ]
]),
ref: useRef() as RootRef
ref: useRef(null)
}


let optionsElement: JSX.Element
let optionsElement: React.JSX.Element
let selectedOption: Props['options'][number] | undefined
let selectedOptionIndex: number | undefined

Expand Down
2 changes: 1 addition & 1 deletion client_core/ui/Select/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type OnSelect = (
payload?: Option['payload']
) => void

type RootRef = React.MutableRefObject<HTMLDivElement>
type RootRef = React.RefObject<HTMLDivElement>

type Store = ReactStore<{
/** Whether select is in focus */
Expand Down
2 changes: 1 addition & 1 deletion client_core/ui/Slider/helpers/get_root_props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function getRootProps(mergedProps: MergedProps) {
const { className, rootTagAttributes } = mergedProps
let result = {
className,
ref: (useRef() as React.MutableRefObject<HTMLDivElement>)
ref: useRef(null)
}
applyRefApi(result, mergedProps)
result = resolveTagAttributes(result, rootTagAttributes)
Expand Down
2 changes: 1 addition & 1 deletion client_core/ui/Slider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const Slider: Component = component<Props, DefaultProps>(


useLayoutEffect(() => {
const rootElement = sliderRootProps.ref.current as HTMLDivElement
const rootElement = sliderRootProps.ref.current! as HTMLDivElement
rootElement.style.setProperty(
'--slide_width',
(
Expand Down
4 changes: 2 additions & 2 deletions client_core/ui/_internals/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from 'react'


type WithLabel = (
input: JSX.Element,
input: React.JSX.Element,
labelProps: ReactTagAttributes<HTMLLabelElement>,
labelTextProps: ReactTagAttributes<HTMLDivElement>
) => JSX.Element
) => React.JSX.Element


const withLabel: WithLabel = (input, labelProps, labelTextProps) => (
Expand Down
2 changes: 1 addition & 1 deletion client_core/ui/_internals/ref_apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function applyRefApi<
: undefined

useEffect(() => {
getRef((rootProps.ref as React.MutableRefObject<HTMLElement>).current, mergedProps)
getRef((rootProps.ref as React.RefObject<HTMLElement>).current, mergedProps)
}, trackDependencies)
}
}
Expand Down
2 changes: 1 addition & 1 deletion client_core/ui/_internals/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type CoreUIComponent<
> = {
defaults: _Defaults
ID: string
} & React.MemoExoticComponent<(props: _Props) => JSX.Element>
} & React.MemoExoticComponent<(props: _Props) => React.JSX.Element>

type CoreUIComponentWithDefaults<_Component extends CoreUIComponent<any, any>> = {
(...args: Parameters<_Component>): ReturnType<_Component>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ function getHeadLabelMenuTableCell<T extends Parameters<NonNullable<DemoDataTabl

function getSearch() {
const searchByField = dataGridHookState.searchByField
let searchElement: JSX.Element | JSX.Element[]
let searchElement: React.JSX.Element | React.JSX.Element[]

if (type == 'set') {
const resultCheckbox: JSX.Element[] = []
const resultCheckbox: React.JSX.Element[] = []
const searchSet = searchByField[ID] || new Set()
const uniqValues = new Set()
const { byID, sorted } = entities
Expand Down
2 changes: 1 addition & 1 deletion demo_app/client/main/pages/DemoComponents/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type SidebarItemProps = {


const _demoComponents: Obj<{
(): JSX.Element
(): React.JSX.Element
coreSrcDirName: string
}> = demoComponents

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "siegel",
"version": "0.15.5",
"version": "0.15.6",
"homepage": "https://siegel-qe3q.onrender.com",
"url": "https://github.com/CyberCookie/siegel",
"bugs": "https://github.com/CyberCookie/siegel/issues",
Expand Down

0 comments on commit d8a94ab

Please sign in to comment.