This repository was archived by the owner on Oct 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Convert folder Shared to TypeScript #445
Merged
Merged
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
51b6e9e
convert part of the shared folder
alexasselin008 f6b2961
couple more files converted to TS
alexasselin008 5af70f6
Merge branch 'menu' into conversion_ts
alexasselin008 3e7d8d5
keep converting shared folder
alexasselin008 4c663cb
conversion de plus de méthode helpers
alexasselin008 c7d8dce
couple more shared utils converted
alexasselin008 285b84a
creation of a size type, and converted couple of files
alexasselin008 165c868
convert semantic folder and add eslint exception for react files
alexasselin008 8376fef
convert focus manager, add options to tsconfig and modified some types
alexasselin008 c43e948
couple of conversion of shared files
alexasselin008 f8fe8f9
conversion de keyboard navigation
alexasselin008 5676590
treewalker
alexasselin008 b551fe2
Merge branch 'menu' into conversion_ts
alexasselin008 873ca86
convert merged refs
alexasselin008 9fa0680
more file conversion
alexasselin008 9176d20
converted rovingfocus
alexasselin008 0b4524c
converted the remaining files
alexasselin008 0509404
cleanup
alexasselin008 dec46b3
cleanup part 2
alexasselin008 cc43be8
Merge branch 'menu' into conversion_ts
alexasselin008 a4de2a3
code review fixes
alexasselin008 a0bfb41
more review fixes
alexasselin008 ab4a794
review fixes
alexasselin008 e1f9765
extracted a type
alexasselin008 0a1f7a2
remove as const, and more cr fixes
alexasselin008 ab87a32
review fixes
alexasselin008 5dc44bd
review fixes
alexasselin008 71fc034
fix eslint
alexasselin008 61fa8a9
fix eslint
alexasselin008 a8edbac
fix eslint
alexasselin008 4cfcd6e
added necessary dev dependancy and update eslint config
alexasselin008 338481f
add return types to functions
alexasselin008 67b8cdd
fixed the return type of the useHasChildren function
alexasselin008 cb21bf6
Merge branch 'conversion_ts' into explicit_returns
alexasselin008 410cd2d
add return types explicitly
alexasselin008 c0e7c09
added tsx files to babel transformation for tests
alexasselin008 b1ba4f1
Merge branch 'menu' into conversion_ts
alexasselin008 36113db
Merge branch 'conversion_ts' into explicit_returns
alexasselin008 daf64d6
Updated config so we don't have to import React on every tsx file
29ddb2e
Merge branch 'menu' into conversion_ts
alexasselin008 b32d4b4
fix of bad typing that caused jest issues
alexasselin008 621f3ba
Merge branch 'conversion_ts' into explicit_returns
alexasselin008 38281d0
Merge branch 'conversion_ts' of https://github.com/gsoft-inc/sg-orbit…
2e53b22
Merge pull request #446 from gsoft-inc/explicit_returns
alexasselin008 2d5b0c1
Merge pull request #447 from BobbyWhiskey/conversion_ts_react_import
alexasselin008 283e58d
Merge branch 'menu' into conversion_ts
alexasselin008 8f3a8e4
remove unnecessary typings
alexasselin008 b4bf658
review fixes
alexasselin008 7090992
Merge branch 'menu' into conversion_ts
alexasselin008 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
3 changes: 0 additions & 3 deletions
3
packages/react-components/src/shared/src/OLD_resolvePopperPosition.js
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
packages/react-components/src/shared/src/OLD_resolvePopperPosition.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| export function resolvePopperPosition(upward: boolean, direction: "left" | "right"): string { | ||
| return `${upward ? "top" : "bottom"}-${direction === "left" ? "end" : "start"}`; | ||
| } |
2 changes: 1 addition & 1 deletion
2
...act-components/src/shared/src/arrayify.js → ...act-components/src/shared/src/arrayify.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| export function arrayify(value) { | ||
| export function arrayify<T>(value: T | T[]): T[] { | ||
| return Array.isArray(value) ? value : [value]; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
packages/react-components/src/shared/src/augmentElement.js
This file was deleted.
Oops, something went wrong.
37 changes: 37 additions & 0 deletions
37
packages/react-components/src/shared/src/augmentElement.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { ElementType, HTMLAttributes, ReactElement, RefAttributes, cloneElement } from "react"; | ||
| import { isString } from "lodash"; | ||
alexasselin008 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { isValidElementType } from "react-is"; | ||
| import { mergeProps } from "./mergeProps"; | ||
| import { normalizeSize } from "./normalizeSize"; | ||
| import type { SizeAdapter } from "./createSizeAdapter"; | ||
|
|
||
| export function augmentElement(element: ReactElement & RefAttributes<any>, newProps: Record<string, any>): ReactElement { | ||
| const augmentedProps = mergeProps({ ...element.props, ref: element.ref }, newProps); | ||
|
|
||
| return cloneElement(element, augmentedProps); | ||
| } | ||
|
|
||
| export function createOrAugmentElement<T extends string, P extends HTMLAttributes<T>>(element: ReactElement<P, T> | ElementType, props: P): ReactElement { | ||
| if (isValidElementType(element) && !isString(element)) { | ||
| const Type = element; | ||
|
|
||
| return <Type {...props} />; | ||
| } | ||
|
|
||
| // The isString in the previous condition assume it can be possible that element is a string. however, if its the case, cloneElement does not support string, so it does not make sense | ||
| // Therefore, since we are only typing the code and i don't want to introduce regression bugs, i will disable the ts compiler for that line | ||
alexasselin008 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
| // @ts-ignore | ||
| return augmentElement(element, props); | ||
| } | ||
|
|
||
| export function createEmbeddableAdapter(sizeAdapter: SizeAdapter) { | ||
| return <P extends Record<string, any>>(element: ReactElement<P, any>, { size, ...props }: P) => { | ||
| const newProps = { | ||
| ...props, | ||
| size: sizeAdapter[normalizeSize(size)] | ||
| }; | ||
|
|
||
| return augmentElement(element, newProps); | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
packages/react-components/src/shared/src/createSizeAdapter.js
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
packages/react-components/src/shared/src/createSizeAdapter.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { normalizeSize } from "./normalizeSize"; | ||
| import type { Size } from "./size"; | ||
|
|
||
| export type SizeAdapter = Record<Size, Size>; | ||
|
|
||
| export function createSizeAdapter(adapter: SizeAdapter): (size: Size) => Size { | ||
| return (size: Size) => adapter[normalizeSize(size)]; | ||
| } | ||
|
|
||
| export function adaptSize(size: Size, adapter: SizeAdapter): Size { | ||
| return adapter[normalizeSize(size)]; | ||
| } |
2 changes: 1 addition & 1 deletion
2
...ct-components/src/shared/src/cssModule.js → ...ct-components/src/shared/src/cssModule.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| export enum FocusTarget { | ||
| first = "first", | ||
| last = "last" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| export enum Keys { | ||
| backspace = 8, | ||
| tab = 9, | ||
| enter = 13, | ||
| esc = 27, | ||
| space = 32, | ||
| end = 35, | ||
| home = 36, | ||
| left = 37, | ||
| up = 38, | ||
| right = 39, | ||
| down = 40, | ||
| delete = 46 | ||
| } |
2 changes: 1 addition & 1 deletion
2
.../react-components/src/shared/src/match.js → .../react-components/src/shared/src/match.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| export function mergeClasses(...values: (string | false)[]): string { | ||
| const deduped = (values | ||
| .filter(Boolean) as string[]) | ||
| .reduce((set, x) => { | ||
| x.split(" ").forEach(y => { | ||
| set.add(y); | ||
| }); | ||
|
|
||
| return set; | ||
| }, new Set<string>()); | ||
|
|
||
| return Array.from(deduped).join(" "); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.