diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 386acad21..1b3e1bf31 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,6 +3,7 @@ "dbaeumer.vscode-eslint", "esbenp.prettier-vscode", "orta.vscode-jest", - "tlent.jest-snapshot-language-support" + "tlent.jest-snapshot-language-support", + "vespa-dev-works.jestrunit" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 25fa6215f..000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "typescript.tsdk": "node_modules/typescript/lib" -} diff --git a/package.json b/package.json index d0f695c77..6071bc2a2 100644 --- a/package.json +++ b/package.json @@ -127,19 +127,19 @@ "@testing-library/dom": "^8.0.0", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^12.0.0", - "@testing-library/react-hooks": "^7.0.1", + "@testing-library/react-hooks": "^7.0.2", "@testing-library/user-event": "^13.2.1", "@types/jest": "27.0.1", "@types/jest-axe": "3.5.2", "@types/jest-in-case": "1.0.5", "@types/mockdate": "^3.0.0", - "@types/node": "^16.7.6", + "@types/node": "^16.7.10", "@types/react": "17.0.19", "@types/react-dom": "17.0.9", "@types/react-transition-group": "4.4.2", "@types/testing-library__jest-dom": "5.14.1", - "@typescript-eslint/eslint-plugin": "4.29.3", - "@typescript-eslint/parser": "4.29.3", + "@typescript-eslint/eslint-plugin": "4.30.0", + "@typescript-eslint/parser": "4.30.0", "all-contributors-cli": "^6.20.0", "ast-to-markdown": "^1.0.0", "autoprefixer": "^10.3.3", @@ -155,22 +155,22 @@ "eslint": "7.32.0", "eslint-config-prettier": "8.3.0", "eslint-config-react-app": "6.0.0", - "eslint-plugin-flowtype": "5.9.1", + "eslint-plugin-flowtype": "5.9.2", "eslint-plugin-import": "2.24.2", "eslint-plugin-jsx-a11y": "6.4.1", - "eslint-plugin-prettier": "3.4.1", + "eslint-plugin-prettier": "4.0.0", "eslint-plugin-react": "7.25.1", "eslint-plugin-react-hooks": "4.2.0", "gacp": "2.10.2", "glob": "^7.1.7", "glob-fs": "^0.1.7", "husky": "^7.0.2", - "jest": "27.1.0", - "jest-axe": "5.0.1", - "jest-in-case": "1.0.2", - "jest-matcher-utils": "27.1.0", - "lint-staged": "11.1.2", - "lodash": "4.17.21", + "jest": "^27.1.0", + "jest-axe": "^5.0.1", + "jest-in-case": "^1.0.2", + "jest-matcher-utils": "^27.1.0", + "lint-staged": "^11.1.2", + "lodash": "^4.17.21", "markdown-to-ast": "^6.0.3", "markdown-toc": "^1.2.0", "md-node-inject": "^1.0.1", @@ -181,18 +181,18 @@ "postcss": "^8.3.6", "postcss-import": "^14.0.2", "postcss-scopify": "^0.1.9", - "prettier": "2.2.1", + "prettier": "2.3.2", "raw-loader": "^4.0.2", - "react": "17.0.2", - "react-dom": "17.0.2", - "react-hook-form": "7.14.1", - "react-test-renderer": "17.0.2", - "react-transition-group": "4.4.2", + "react": "^17.0.2", + "react-dom": "^17.0.2", + "react-hook-form": "^7.14.2", + "react-test-renderer": "^17.0.2", + "react-transition-group": "^4.4.2", "react-virtual": "^2.8.1", - "reakit": "1.3.8", + "reakit": "^1.3.8", "reakit-test-utils": "^0.15.1", "release-it": "^14.11.5", - "rimraf": "3.0.2", + "rimraf": "^3.0.2", "sort-package-json": "^1.50.0", "storybook-addon-preview": "^2.1.2", "strip-comments": "^2.0.1", @@ -200,7 +200,7 @@ "ts-jest": "^27.0.5", "ts-morph": "^12.0.0", "ts-node": "^10.2.1", - "typescript": "4.4.2", + "typescript": "^4.4.2", "webpack": "^5.51.1", "yaml": "^1.10.2" }, diff --git a/scripts/utils/index.js b/scripts/utils/index.js index 85f41e402..ce34d3b99 100644 --- a/scripts/utils/index.js +++ b/scripts/utils/index.js @@ -83,9 +83,8 @@ function getPublicFiles(rootPath, prefix = "") { isDirectory(path) && getPublicFiles(path, join(prefix, filename)); return { ...(childFiles || { - [removeExt(normalizePath(join(prefix, filename)))]: normalizePath( - path, - ), + [removeExt(normalizePath(join(prefix, filename)))]: + normalizePath(path), }), ...acc, }; diff --git a/src/accordion/AccordionTrigger.ts b/src/accordion/AccordionTrigger.ts index 80f0309e5..e302c7ebc 100644 --- a/src/accordion/AccordionTrigger.ts +++ b/src/accordion/AccordionTrigger.ts @@ -62,9 +62,10 @@ export const useAccordionTrigger = createHook< select?.(id); }, [id, select]); - const onClick = React.useCallback(() => handleSelection(), [ - handleSelection, - ]); + const onClick = React.useCallback( + () => handleSelection(), + [handleSelection], + ); const onFocus = React.useCallback(() => { if (manual) return; diff --git a/src/accordion/stories/AccordionBasic.component.tsx b/src/accordion/stories/AccordionBasic.component.tsx index f21452f4a..c37651f78 100644 --- a/src/accordion/stories/AccordionBasic.component.tsx +++ b/src/accordion/stories/AccordionBasic.component.tsx @@ -5,7 +5,7 @@ import { AccordionPanel, AccordionTrigger, useAccordionState, -} from "../index"; +} from "../../index"; export function App(props: any) { const state = useAccordionState(props); diff --git a/src/accordion/stories/AccordionMulti.component.tsx b/src/accordion/stories/AccordionMulti.component.tsx index 21e005519..cd1886624 100644 --- a/src/accordion/stories/AccordionMulti.component.tsx +++ b/src/accordion/stories/AccordionMulti.component.tsx @@ -5,7 +5,7 @@ import { AccordionPanel, AccordionTrigger, useAccordionMultiState, -} from "../index"; +} from "../../index"; export function App(props: any) { const state = useAccordionMultiState(props); diff --git a/src/accordion/stories/AccordionStyled.component.tsx b/src/accordion/stories/AccordionStyled.component.tsx index 3280f519e..02fa57379 100644 --- a/src/accordion/stories/AccordionStyled.component.tsx +++ b/src/accordion/stories/AccordionStyled.component.tsx @@ -6,7 +6,7 @@ import { AccordionTrigger, useAccordionState, AccordionInitialState, -} from "../index"; +} from "../../index"; // Styled based on https://www.w3.org/TR/wai-aria-practices-1.2/examples/accordion/accordion.html export const App: React.FC = props => { diff --git a/src/accordion/stories/AccordionZAuto.component.tsx b/src/accordion/stories/AccordionZAuto.component.tsx index bd81d904c..26dca4a64 100644 --- a/src/accordion/stories/AccordionZAuto.component.tsx +++ b/src/accordion/stories/AccordionZAuto.component.tsx @@ -5,7 +5,7 @@ import { AccordionPanel, AccordionTrigger, useAccordionState, -} from "../index"; +} from "../../index"; export function App(props: any) { const initialProps = { diff --git a/src/breadcrumbs/stories/Breadcrumbs.component.tsx b/src/breadcrumbs/stories/Breadcrumbs.component.tsx index 4561dd967..a53358ce4 100644 --- a/src/breadcrumbs/stories/Breadcrumbs.component.tsx +++ b/src/breadcrumbs/stories/Breadcrumbs.component.tsx @@ -1,6 +1,6 @@ import * as React from "react"; -import { Breadcrumbs, BreadcrumbLink } from "../index"; +import { Breadcrumbs, BreadcrumbLink } from "../../index"; export const App: React.FC = props => { return ( diff --git a/src/calendar/stories/CalendarBase.component.tsx b/src/calendar/stories/CalendarBase.component.tsx index 206479a99..c3b1a8d15 100644 --- a/src/calendar/stories/CalendarBase.component.tsx +++ b/src/calendar/stories/CalendarBase.component.tsx @@ -10,7 +10,7 @@ import { CalendarHeader, CalendarWeekTitle, CalendarInitialState, -} from "../index"; +} from "../../index"; import { ChevronLeft, diff --git a/src/calendar/stories/CalendarRange.component.tsx b/src/calendar/stories/CalendarRange.component.tsx index ae5859485..b3797d81e 100644 --- a/src/calendar/stories/CalendarRange.component.tsx +++ b/src/calendar/stories/CalendarRange.component.tsx @@ -10,7 +10,7 @@ import { CalendarWeekTitle, useRangeCalendarState, RangeCalendarInitialState, -} from "../index"; +} from "../../index"; import { ChevronLeft, diff --git a/src/checkbox/stories/Checkbox.component.tsx b/src/checkbox/stories/Checkbox.component.tsx index 7776248a9..2bcf73db0 100644 --- a/src/checkbox/stories/Checkbox.component.tsx +++ b/src/checkbox/stories/Checkbox.component.tsx @@ -1,13 +1,13 @@ import * as React from "react"; import { - Checkbox as RenderlesskitCheckbox, - CheckboxProps as RenderlesskitCheckboxProps, useCheckboxState, CheckboxInitialState, -} from "../index"; -import { splitStateProps } from "../../utils/index"; -import { USE_CHECKBOX_STATE_KEYS } from "../__keys"; + Checkbox as RenderlesskitCheckbox, + CheckboxProps as RenderlesskitCheckboxProps, + USE_CHECKBOX_STATE_KEYS, + splitStateProps, +} from "../../index"; export type CheckboxProps = RenderlesskitCheckboxProps & CheckboxInitialState & {}; diff --git a/src/datepicker/stories/DatePickerBase.component.tsx b/src/datepicker/stories/DatePickerBase.component.tsx index 58cab404e..b5754209f 100644 --- a/src/datepicker/stories/DatePickerBase.component.tsx +++ b/src/datepicker/stories/DatePickerBase.component.tsx @@ -8,7 +8,7 @@ import { useDatePickerState, DatePickerSegmentField, DatePickerInitialState, -} from "../index"; +} from "../../index"; import { Calendar as CalendarWrapper, CalendarButton, diff --git a/src/datepicker/stories/DatePickerRange.component.tsx b/src/datepicker/stories/DatePickerRange.component.tsx index 1c40dda00..451f146ad 100644 --- a/src/datepicker/stories/DatePickerRange.component.tsx +++ b/src/datepicker/stories/DatePickerRange.component.tsx @@ -8,7 +8,7 @@ import { DatePickerSegmentField, useDateRangePickerState, DateRangePickerInitialState, -} from "../index"; +} from "../../index"; import { Calendar, CalendarCell, diff --git a/src/datepicker/stories/styled/Calendar.tsx b/src/datepicker/stories/styled/Calendar.tsx index ce38d6130..3562f4183 100644 --- a/src/datepicker/stories/styled/Calendar.tsx +++ b/src/datepicker/stories/styled/Calendar.tsx @@ -8,7 +8,7 @@ import { CalendarCellButton, CalendarStateReturn, Calendar as CalendarWrapper, -} from "../../../calendar/index"; +} from "../../../index"; import { ChevronLeft, diff --git a/src/datepicker/stories/styled/DatePicker.component.tsx b/src/datepicker/stories/styled/DatePicker.component.tsx index 2b0c8547b..b072a0bbc 100644 --- a/src/datepicker/stories/styled/DatePicker.component.tsx +++ b/src/datepicker/stories/styled/DatePicker.component.tsx @@ -8,7 +8,7 @@ import { DatePickerSegmentField, DatePickerInitialState, DatePicker as DatePickerWrapper, -} from "../../index"; +} from "../../../index"; import { Calendar, CalendarIcon } from "./Calendar"; export const DatePicker: React.FC = props => { diff --git a/src/datepicker/stories/styled/RangeDatePicker.component.tsx b/src/datepicker/stories/styled/RangeDatePicker.component.tsx index 1398404f0..055d730e2 100644 --- a/src/datepicker/stories/styled/RangeDatePicker.component.tsx +++ b/src/datepicker/stories/styled/RangeDatePicker.component.tsx @@ -8,7 +8,7 @@ import { DatePicker as DatePickerWrapper, useDateRangePickerState, DateRangePickerInitialState, -} from "../../index"; +} from "../../../index"; import { Calendar, CalendarIcon } from "./Calendar"; export const RangeDatePicker: React.FC = props => { diff --git a/src/drawer/stories/Drawer.component.tsx b/src/drawer/stories/Drawer.component.tsx index 8eb696967..e8106acda 100644 --- a/src/drawer/stories/Drawer.component.tsx +++ b/src/drawer/stories/Drawer.component.tsx @@ -8,7 +8,7 @@ import { DrawerBackdrop, DrawerCloseButton, DrawerDisclosure, -} from "../index"; +} from "../../index"; export const App = () => { const dialog = useDrawerState({ animated: true }); diff --git a/src/link/stories/Link.component.tsx b/src/link/stories/Link.component.tsx index 4ded71a2a..e05425e55 100644 --- a/src/link/stories/Link.component.tsx +++ b/src/link/stories/Link.component.tsx @@ -1,6 +1,6 @@ import * as React from "react"; -import { Link } from "../index"; +import { Link } from "../../index"; export interface AppProps { /** diff --git a/src/meter/stories/MeterBasic.component.tsx b/src/meter/stories/MeterBasic.component.tsx index 17cd22615..14e7321d3 100644 --- a/src/meter/stories/MeterBasic.component.tsx +++ b/src/meter/stories/MeterBasic.component.tsx @@ -1,6 +1,6 @@ import * as React from "react"; -import { Meter, useMeterState, MeterInitialState } from "../index"; +import { Meter, useMeterState, MeterInitialState } from "../../index"; export const App: React.FC = props => { const state = useMeterState(props); diff --git a/src/meter/stories/MeterStyled.component.tsx b/src/meter/stories/MeterStyled.component.tsx index 30260101d..c15b7c6de 100644 --- a/src/meter/stories/MeterStyled.component.tsx +++ b/src/meter/stories/MeterStyled.component.tsx @@ -6,7 +6,7 @@ import { useMeterState, MeterStateReturn, MeterInitialState, -} from "../index"; +} from "../../index"; export interface AppProps extends MeterInitialState { /** diff --git a/src/number-input/NumberInputDecrementButton.ts b/src/number-input/NumberInputDecrementButton.ts index dc757c6a2..4e86ebd26 100644 --- a/src/number-input/NumberInputDecrementButton.ts +++ b/src/number-input/NumberInputDecrementButton.ts @@ -15,8 +15,8 @@ export type NumberInputDecrementButtonOptions = ButtonOptions & export type NumberInputDecrementButtonHTMLProps = ButtonHTMLProps; -export type NumberInputDecrementButtonProps = NumberInputDecrementButtonOptions & - NumberInputDecrementButtonHTMLProps; +export type NumberInputDecrementButtonProps = + NumberInputDecrementButtonOptions & NumberInputDecrementButtonHTMLProps; export const useNumberInputDecrementButton = createHook< NumberInputDecrementButtonOptions, diff --git a/src/number-input/NumberInputIncrementButton.ts b/src/number-input/NumberInputIncrementButton.ts index e65af7e0d..c30afcfa9 100644 --- a/src/number-input/NumberInputIncrementButton.ts +++ b/src/number-input/NumberInputIncrementButton.ts @@ -15,8 +15,8 @@ export type NumberInputIncrementButtonOptions = ButtonOptions & export type NumberInputIncrementButtonHTMLProps = ButtonHTMLProps; -export type NumberInputIncrementButtonProps = NumberInputIncrementButtonOptions & - NumberInputIncrementButtonHTMLProps; +export type NumberInputIncrementButtonProps = + NumberInputIncrementButtonOptions & NumberInputIncrementButtonHTMLProps; export const useNumberInputIncrementButton = createHook< NumberInputIncrementButtonOptions, diff --git a/src/number-input/__keys.ts b/src/number-input/__keys.ts index ffdd1c8fe..de6e1fe6d 100644 --- a/src/number-input/__keys.ts +++ b/src/number-input/__keys.ts @@ -48,4 +48,5 @@ export const NUMBER_INPUT_KEYS = [ "allowMouseWheel", ] as const; export const NUMBER_INPUT_DECREMENT_BUTTON_KEYS = NUMBER_INPUT_STATE_KEYS; -export const NUMBER_INPUT_INCREMENT_BUTTON_KEYS = NUMBER_INPUT_DECREMENT_BUTTON_KEYS; +export const NUMBER_INPUT_INCREMENT_BUTTON_KEYS = + NUMBER_INPUT_DECREMENT_BUTTON_KEYS; diff --git a/src/number-input/stories/NumberInput.component.tsx b/src/number-input/stories/NumberInput.component.tsx index 0ef06a937..31cd41a90 100644 --- a/src/number-input/stories/NumberInput.component.tsx +++ b/src/number-input/stories/NumberInput.component.tsx @@ -6,7 +6,7 @@ import { NumberinputInitialState, NumberInputDecrementButton, NumberInputIncrementButton, -} from "../index"; +} from "../../index"; export interface AppProps extends NumberinputInitialState { /** diff --git a/src/pagination/__tests__/PaginationState.test.ts b/src/pagination/__tests__/PaginationState.test.ts index 49d6bd5e4..f7011b367 100644 --- a/src/pagination/__tests__/PaginationState.test.ts +++ b/src/pagination/__tests__/PaginationState.test.ts @@ -97,17 +97,15 @@ describe("usePaginationState", () => { }); it("has no ellipses when count <= 7", () => { - const { pages } = renderHook(() => - usePaginationState({ count: 7 }), - ).result.current; + const { pages } = renderHook(() => usePaginationState({ count: 7 })).result + .current; expect(pages).not.toContain("end-ellipsis"); }); it("should have end-ellipses when count >= 8", () => { - const { pages } = renderHook(() => - usePaginationState({ count: 8 }), - ).result.current; + const { pages } = renderHook(() => usePaginationState({ count: 8 })).result + .current; expect(pages).toContain("end-ellipsis"); }); diff --git a/src/pagination/stories/Pagination.component.tsx b/src/pagination/stories/Pagination.component.tsx index 1ae7b812a..868e28298 100644 --- a/src/pagination/stories/Pagination.component.tsx +++ b/src/pagination/stories/Pagination.component.tsx @@ -6,7 +6,7 @@ import { usePaginationState, PaginationInitialState, TGoto, -} from "../index"; +} from "../../index"; export const App: React.FC = props => { const state = usePaginationState({ count: 10, ...props }); diff --git a/src/picker-base/stories/PickerBase.component.tsx b/src/picker-base/stories/PickerBase.component.tsx index 5769fbcaa..7565a41cd 100644 --- a/src/picker-base/stories/PickerBase.component.tsx +++ b/src/picker-base/stories/PickerBase.component.tsx @@ -6,7 +6,7 @@ import { PickerBaseContent, usePickerBaseState, PickerBaseInitialState, -} from "../index"; +} from "../../index"; export const App: React.FC = props => { const state = usePickerBaseState(props); diff --git a/src/progress/stories/CircularProgress.component.tsx b/src/progress/stories/CircularProgress.component.tsx index 0baeb1c8a..186ae42b7 100644 --- a/src/progress/stories/CircularProgress.component.tsx +++ b/src/progress/stories/CircularProgress.component.tsx @@ -7,7 +7,7 @@ import { ProgressState, useProgressState, ProgressInitialState, -} from "../index"; +} from "../../index"; import { isNull } from "../../utils/index"; export interface AppProps extends ProgressInitialState { diff --git a/src/progress/stories/LinearProgress.component.tsx b/src/progress/stories/LinearProgress.component.tsx index 8d21694cf..3cc6c595d 100644 --- a/src/progress/stories/LinearProgress.component.tsx +++ b/src/progress/stories/LinearProgress.component.tsx @@ -7,7 +7,7 @@ import { ProgressState, useProgressState, ProgressInitialState, -} from "../index"; +} from "../../index"; import { cx, isNull } from "../../utils/index"; export interface AppProps extends ProgressInitialState { diff --git a/src/progress/stories/ProgressBasic.component.tsx b/src/progress/stories/ProgressBasic.component.tsx index 39d8d565f..3ef55dc6d 100644 --- a/src/progress/stories/ProgressBasic.component.tsx +++ b/src/progress/stories/ProgressBasic.component.tsx @@ -1,6 +1,6 @@ import * as React from "react"; -import { Progress, useProgressState, ProgressInitialState } from "../index"; +import { Progress, useProgressState, ProgressInitialState } from "../../index"; export const App: React.FC = props => { const state = useProgressState(props); diff --git a/src/segment/SegmentState.ts b/src/segment/SegmentState.ts index a1a27bb5b..d2068d940 100644 --- a/src/segment/SegmentState.ts +++ b/src/segment/SegmentState.ts @@ -85,9 +85,10 @@ export function useSegmentState(props: SegmentInitialState) { // https://stackoverflow.com/a/9893752/10629172 const dateFormatter = useDateFormatter(props.formatOptions); - const resolvedOptions = useMemo(() => dateFormatter.resolvedOptions(), [ - dateFormatter, - ]); + const resolvedOptions = useMemo( + () => dateFormatter.resolvedOptions(), + [dateFormatter], + ); // Determine how many editable segments there are for validation purposes. // The result is cached for performance. diff --git a/src/segment/stories/Segment.component.tsx b/src/segment/stories/Segment.component.tsx index 12c2ecee2..243509fa9 100644 --- a/src/segment/stories/Segment.component.tsx +++ b/src/segment/stories/Segment.component.tsx @@ -5,7 +5,7 @@ import { SegmentField, useSegmentState, SegmentInitialState, -} from "../index"; +} from "../../index"; export const App: React.FC = props => { const state = useSegmentState(props); diff --git a/src/select/Select.ts b/src/select/Select.ts index dcbd06b13..113f129f0 100644 --- a/src/select/Select.ts +++ b/src/select/Select.ts @@ -135,26 +135,25 @@ export const Select = createComponent({ useHook: useSelect, }); -const handleCharacterPress = (options: SelectOptions) => ( - character: string, -) => { - /** - * Typeahead: Based on current character pressed, - * find the next item to be selected - */ - const selectedValue = options.values.find(value => - options.selectedValue?.includes(value), - ); - - const nextItem = getNextItemFromSearch( - options.values, - character, - item => item ?? "", - selectedValue, - ); - - if (nextItem) options.setSelectedValue(nextItem); -}; +const handleCharacterPress = + (options: SelectOptions) => (character: string) => { + /** + * Typeahead: Based on current character pressed, + * find the next item to be selected + */ + const selectedValue = options.values.find(value => + options.selectedValue?.includes(value), + ); + + const nextItem = getNextItemFromSearch( + options.values, + character, + item => item ?? "", + selectedValue, + ); + + if (nextItem) options.setSelectedValue(nextItem); + }; const noop = () => {}; diff --git a/src/select/SelectBaseState.ts b/src/select/SelectBaseState.ts index 73ccabeff..fb508598a 100644 --- a/src/select/SelectBaseState.ts +++ b/src/select/SelectBaseState.ts @@ -44,9 +44,8 @@ export function useSelectBaseState( unregisterItem: compositeUnregisterItem, } = composite; - const [selectedValue, setSelectedValue] = React.useState( - initialSelectedValue, - ); + const [selectedValue, setSelectedValue] = + React.useState(initialSelectedValue); const selectedId = React.useMemo( () => getIdFromValue(valuesById.current, selectedValue), [valuesById.current, selectedValue], diff --git a/src/select/SelectListState.ts b/src/select/SelectListState.ts index c778739b4..fe7e40893 100644 --- a/src/select/SelectListState.ts +++ b/src/select/SelectListState.ts @@ -14,9 +14,11 @@ import { export function useSelectListState( initialState: SealedInitialState = {}, ): SelectListStateReturn { - const { orientation = "vertical", loop = true, ...sealed } = useSealedState( - initialState, - ); + const { + orientation = "vertical", + loop = true, + ...sealed + } = useSealedState(initialState); const composite = useCompositeState({ orientation, diff --git a/src/select/helpers/useTypeaheadShortcut.ts b/src/select/helpers/useTypeaheadShortcut.ts index 83b348401..172d50fcd 100644 --- a/src/select/helpers/useTypeaheadShortcut.ts +++ b/src/select/helpers/useTypeaheadShortcut.ts @@ -53,22 +53,21 @@ export function useTypeaheadShortcut({ }, [onCharacterPress]); } -const handleCharacterPress = (options: TypeAheadShortcutOption) => ( - character: string, -) => { - const selectedValue = options.values.find(value => - options.currentValue?.includes(value), - ); +const handleCharacterPress = + (options: TypeAheadShortcutOption) => (character: string) => { + const selectedValue = options.values.find(value => + options.currentValue?.includes(value), + ); - const nextItem = getNextItemFromSearch( - options.values, - character, - item => item ?? "", - selectedValue, - ); + const nextItem = getNextItemFromSearch( + options.values, + character, + item => item ?? "", + selectedValue, + ); - if (nextItem) { - const nextId = getIdFromValue(options.valuesById, nextItem); - options.move?.(nextId); - } -}; + if (nextItem) { + const nextId = getIdFromValue(options.valuesById, nextItem); + options.move?.(nextId); + } + }; diff --git a/src/select/stories/Select.component.tsx b/src/select/stories/Select.component.tsx index 7d3f974d6..e00d92a0a 100644 --- a/src/select/stories/Select.component.tsx +++ b/src/select/stories/Select.component.tsx @@ -6,7 +6,7 @@ import { SelectPopover, useSelectState, SelectInitialState, -} from "../index"; +} from "../../index"; export const App: React.FC = props => { const select = useSelectState({ gutter: 8, ...props }); diff --git a/src/select/stories/SelectControlled.component.tsx b/src/select/stories/SelectControlled.component.tsx index aced8146f..06283de8c 100644 --- a/src/select/stories/SelectControlled.component.tsx +++ b/src/select/stories/SelectControlled.component.tsx @@ -6,7 +6,7 @@ import { SelectPopover, useSelectState, SelectInitialState, -} from "../index"; +} from "../../index"; import { fruits } from "./Utils.component"; export const App: React.FC = () => { diff --git a/src/select/stories/SelectCustom.component.tsx b/src/select/stories/SelectCustom.component.tsx index 332cc2e3d..44624fa35 100644 --- a/src/select/stories/SelectCustom.component.tsx +++ b/src/select/stories/SelectCustom.component.tsx @@ -6,7 +6,7 @@ import { SelectPopover, useSelectState, SelectInitialState, -} from "../index"; +} from "../../index"; import { fruits } from "./Utils.component"; export const App: React.FC = props => { diff --git a/src/select/stories/SelectDynamic.component.tsx b/src/select/stories/SelectDynamic.component.tsx index a58c45d64..3cba0278d 100644 --- a/src/select/stories/SelectDynamic.component.tsx +++ b/src/select/stories/SelectDynamic.component.tsx @@ -6,7 +6,7 @@ import { SelectPopover, useSelectState, SelectInitialState, -} from "../index"; +} from "../../index"; import { fruits } from "./Utils.component"; export const App: React.FC = props => { diff --git a/src/select/stories/SelectFetch.component.tsx b/src/select/stories/SelectFetch.component.tsx index 1b410ddfa..f93d967f5 100644 --- a/src/select/stories/SelectFetch.component.tsx +++ b/src/select/stories/SelectFetch.component.tsx @@ -6,7 +6,7 @@ import { SelectPopover, useSelectState, SelectInitialState, -} from "../index"; +} from "../../index"; type User = { value: string; label: string }; diff --git a/src/select/stories/SelectMultiple.component.tsx b/src/select/stories/SelectMultiple.component.tsx index f41f13d71..b66b76935 100644 --- a/src/select/stories/SelectMultiple.component.tsx +++ b/src/select/stories/SelectMultiple.component.tsx @@ -6,7 +6,7 @@ import { SelectPopover, useSelectState, SelectInitialState, -} from "../index"; +} from "../../index"; import { fruits } from "./Utils.component"; export const App: React.FC = props => { diff --git a/src/select/stories/SelectStyled.component.tsx b/src/select/stories/SelectStyled.component.tsx index 9ad6baaf9..bc205c471 100644 --- a/src/select/stories/SelectStyled.component.tsx +++ b/src/select/stories/SelectStyled.component.tsx @@ -6,7 +6,7 @@ import { SelectPopover, useSelectState, SelectInitialState, -} from "../index"; +} from "../../index"; const people = [ "Wade Cooper", diff --git a/src/select/stories/SelectVirtual.component.tsx b/src/select/stories/SelectVirtual.component.tsx index a105039d8..601d3e964 100644 --- a/src/select/stories/SelectVirtual.component.tsx +++ b/src/select/stories/SelectVirtual.component.tsx @@ -7,7 +7,7 @@ import { SelectPopover, useSelectState, SelectInitialState, -} from "../index"; +} from "../../index"; import { fruits } from "./Utils.component"; export const App: React.FC = props => { diff --git a/src/select/stories/SelectWindows.component.tsx b/src/select/stories/SelectWindows.component.tsx index 2f6255b60..163bd0fd0 100644 --- a/src/select/stories/SelectWindows.component.tsx +++ b/src/select/stories/SelectWindows.component.tsx @@ -6,7 +6,7 @@ import { SelectPopover, useSelectState, SelectInitialState, -} from "../index"; +} from "../../index"; import { fruits } from "./Utils.component"; export const App: React.FC = props => { diff --git a/src/slider/SliderTrack.ts b/src/slider/SliderTrack.ts index e474116b8..8f697b157 100644 --- a/src/slider/SliderTrack.ts +++ b/src/slider/SliderTrack.ts @@ -124,9 +124,10 @@ export const useSliderTrack = createHook< ? options.trackRef.current.offsetHeight : options.trackRef.current.offsetWidth; // Find the closest thumb - const trackPosition = options.trackRef.current.getBoundingClientRect()[ - isVertical ? "top" : "left" - ]; + const trackPosition = + options.trackRef.current.getBoundingClientRect()[ + isVertical ? "top" : "left" + ]; const clickPosition = isVertical ? clientY : clientX; const offset = clickPosition - trackPosition; diff --git a/src/slider/__tests__/MultiSlider.test.tsx b/src/slider/__tests__/MultiSlider.test.tsx index b7dbff4b0..b88422b69 100644 --- a/src/slider/__tests__/MultiSlider.test.tsx +++ b/src/slider/__tests__/MultiSlider.test.tsx @@ -60,12 +60,8 @@ export const MultiSliderComponent = ( const state = useSliderState({ reversed: reversed, ...rest }); const origin = originProp ?? state.min ?? 0; - const { - values, - getValuePercent, - getThumbValueLabel, - getThumbPercent, - } = state; + const { values, getValuePercent, getThumbValueLabel, getThumbPercent } = + state; const isVertical = false; const isRange = values.length === 2; diff --git a/src/slider/__tests__/Slider.test.tsx b/src/slider/__tests__/Slider.test.tsx index db9daa893..7a536c3f8 100644 --- a/src/slider/__tests__/Slider.test.tsx +++ b/src/slider/__tests__/Slider.test.tsx @@ -55,12 +55,8 @@ export const SliderComponent = ( ) => { const state = useSliderState(props); const originProp = props.origin ?? state.min ?? 0; - const { - values, - getValuePercent, - getThumbPercent, - getThumbValueLabel, - } = state; + const { values, getValuePercent, getThumbPercent, getThumbValueLabel } = + state; const trackWidth = `${ (getValuePercent(Math.max(values[0], originProp)) - diff --git a/src/slider/stories/components/MultiSlider.component.tsx b/src/slider/stories/components/MultiSlider.component.tsx index c867e7687..5cf5e2e49 100644 --- a/src/slider/stories/components/MultiSlider.component.tsx +++ b/src/slider/stories/components/MultiSlider.component.tsx @@ -7,7 +7,7 @@ import { SliderInput, useSliderState, SliderInitialState, -} from "../../index"; +} from "../../../index"; interface AppProps extends SliderInitialState { /** diff --git a/src/slider/stories/components/RangeSlider.component.tsx b/src/slider/stories/components/RangeSlider.component.tsx index 686cc3bc8..ce520edee 100644 --- a/src/slider/stories/components/RangeSlider.component.tsx +++ b/src/slider/stories/components/RangeSlider.component.tsx @@ -7,7 +7,7 @@ import { SliderInput, useSliderState, SliderInitialState, -} from "../../index"; +} from "../../../index"; interface AppProps extends SliderInitialState { /** diff --git a/src/slider/stories/components/SingleOriginSlider.component.tsx b/src/slider/stories/components/SingleOriginSlider.component.tsx index 8e12c9660..640886896 100644 --- a/src/slider/stories/components/SingleOriginSlider.component.tsx +++ b/src/slider/stories/components/SingleOriginSlider.component.tsx @@ -7,7 +7,7 @@ import { SliderInput, useSliderState, SliderInitialState, -} from "../../index"; +} from "../../../index"; interface AppProps extends SliderInitialState { /** @@ -26,12 +26,8 @@ export const App: React.FC = args => { const { label, ...rest } = args; const state = useSliderState(rest); - const { - values, - getValuePercent, - getThumbValueLabel, - getThumbPercent, - } = state; + const { values, getValuePercent, getThumbValueLabel, getThumbPercent } = + state; const origin = 0; return ( diff --git a/src/slider/stories/components/SingleReversedSlider.component.tsx b/src/slider/stories/components/SingleReversedSlider.component.tsx index fa10be251..3d6cbb952 100644 --- a/src/slider/stories/components/SingleReversedSlider.component.tsx +++ b/src/slider/stories/components/SingleReversedSlider.component.tsx @@ -7,7 +7,7 @@ import { SliderInput, useSliderState, SliderInitialState, -} from "../../index"; +} from "../../../index"; interface AppProps extends SliderInitialState { /** @@ -26,12 +26,8 @@ export const App: React.FC = args => { const { label, ...rest } = args; const state = useSliderState(rest); - const { - values, - getValuePercent, - getThumbValueLabel, - getThumbPercent, - } = state; + const { values, getValuePercent, getThumbValueLabel, getThumbPercent } = + state; return (
= args => { const { label, ...rest } = args; const state = useSliderState(rest); - const { - values, - getValuePercent, - getThumbValueLabel, - getThumbPercent, - } = state; + const { values, getValuePercent, getThumbValueLabel, getThumbPercent } = + state; return (
= args => { const { label, ...rest } = args; const state = useSliderState(rest); - const { - values, - getValuePercent, - getThumbValueLabel, - getThumbPercent, - } = state; + const { values, getValuePercent, getThumbValueLabel, getThumbPercent } = + state; return (
= args => { const origin = originProp ?? args.min ?? 0; const state = useSliderState({ reversed: isReversed, ...rest }); - const { - values, - getValuePercent, - getThumbValueLabel, - getThumbPercent, - } = state; + const { values, getValuePercent, getThumbValueLabel, getThumbPercent } = + state; const isVertical = args.orientation === "vertical"; const isRange = values.length === 2; diff --git a/src/timepicker/stories/TimePicker.component.tsx b/src/timepicker/stories/TimePicker.component.tsx index 4130a0abd..149772b6d 100644 --- a/src/timepicker/stories/TimePicker.component.tsx +++ b/src/timepicker/stories/TimePicker.component.tsx @@ -10,7 +10,7 @@ import { TimePickerColumnValue, TimePickerSegmentField, TimePickerStateProps, -} from "../index"; +} from "../../index"; import { CalendarIcon } from "./Utils.component"; diff --git a/src/toast/CreateToastContext.tsx b/src/toast/CreateToastContext.tsx index c3dbd419e..777e65cc7 100644 --- a/src/toast/CreateToastContext.tsx +++ b/src/toast/CreateToastContext.tsx @@ -57,7 +57,7 @@ export function createToastStore( const createToast = React.useCallback( (content: Content, opts?: ToastOptions) => - (({ + ({ visible: false, reverseOrder: true, createdAt: Date.now(), @@ -66,7 +66,7 @@ export function createToastStore( ...opts, content, id: opts?.id || genId(), - } as unknown) as T), + } as unknown as T), // Since its only a few object https://twitter.com/dan_abramov/status/1104414272753487872 // eslint-disable-next-line react-hooks/exhaustive-deps [JSON.stringify(rest)], diff --git a/src/toast/__tests__/ToastState.test.tsx b/src/toast/__tests__/ToastState.test.tsx index 331a7e010..f2dd9b9cd 100644 --- a/src/toast/__tests__/ToastState.test.tsx +++ b/src/toast/__tests__/ToastState.test.tsx @@ -8,13 +8,13 @@ const createToast = ( content: Content, opts?: ToastOptions, ) => - (({ + ({ content, visible: true, reverseOrder: true, animationDuration: 100, ...opts, - } as unknown) as T); + } as unknown as T); describe("Toast State Reducer", () => { it("should pass smoke test", () => { diff --git a/src/toast/stories/ToastBasic.component.tsx b/src/toast/stories/ToastBasic.component.tsx index e14024d5d..518db9207 100644 --- a/src/toast/stories/ToastBasic.component.tsx +++ b/src/toast/stories/ToastBasic.component.tsx @@ -25,25 +25,24 @@ export const App = () => { export default App; -const alert = (content: any, type?: AlertType) => ({ - toast, - handlers, -}: ContentType) => { - const { pauseTimer, resumeTimer, removeToast } = handlers; +const alert = + (content: any, type?: AlertType) => + ({ toast, handlers }: ContentType) => { + const { pauseTimer, resumeTimer, removeToast } = handlers; - return ( - pauseTimer(toast.id)} - onMouseLeave={() => resumeTimer(toast.id)} - > - - - ); -}; + return ( + pauseTimer(toast.id)} + onMouseLeave={() => resumeTimer(toast.id)} + > + + + ); + }; function ToastTriggers() { const { addToast, removeToast } = useToastHandlers(); diff --git a/src/toast/stories/ToastCSSAnimated.component.tsx b/src/toast/stories/ToastCSSAnimated.component.tsx index 09b3a8ed2..714696bc4 100644 --- a/src/toast/stories/ToastCSSAnimated.component.tsx +++ b/src/toast/stories/ToastCSSAnimated.component.tsx @@ -25,27 +25,26 @@ export const App = () => { export default App; -const alert = (content: any, type?: AlertType) => ({ - toast, - handlers, -}: ContentType) => { - const { pauseTimer, resumeTimer, dismissToast } = handlers; +const alert = + (content: any, type?: AlertType) => + ({ toast, handlers }: ContentType) => { + const { pauseTimer, resumeTimer, dismissToast } = handlers; - return ( - - pauseTimer(toast.id)} - onMouseLeave={() => resumeTimer(toast.id)} - > - - - - ); -}; + return ( + + pauseTimer(toast.id)} + onMouseLeave={() => resumeTimer(toast.id)} + > + + + + ); + }; export function ToastTriggers() { const { showToast } = useToastHandlers(); diff --git a/src/toast/stories/ToastCSSTransition.component.tsx b/src/toast/stories/ToastCSSTransition.component.tsx index 57285fa0d..09d2f885a 100644 --- a/src/toast/stories/ToastCSSTransition.component.tsx +++ b/src/toast/stories/ToastCSSTransition.component.tsx @@ -13,7 +13,6 @@ import { getRandomContent, useToastHandlers, } from "./Utils.component"; -import {} from "../index"; export const App = () => { return ( @@ -26,32 +25,31 @@ export const App = () => { export default App; -const alert = (content: any, type?: AlertType) => ({ - toast, - handlers, -}: ContentType) => { - const { pauseTimer, resumeTimer, dismissToast } = handlers; +const alert = + (content: any, type?: AlertType) => + ({ toast, handlers }: ContentType) => { + const { pauseTimer, resumeTimer, dismissToast } = handlers; - return ( - - pauseTimer(toast.id)} - onMouseLeave={() => resumeTimer(toast.id)} + return ( + - - - - ); -}; + pauseTimer(toast.id)} + onMouseLeave={() => resumeTimer(toast.id)} + > + + + + ); + }; export function ToastTriggers() { const { showToast } = useToastHandlers(); diff --git a/src/toast/stories/ToastReactSpring.component.tsx b/src/toast/stories/ToastReactSpring.component.tsx index 25be03273..bbb3079a4 100644 --- a/src/toast/stories/ToastReactSpring.component.tsx +++ b/src/toast/stories/ToastReactSpring.component.tsx @@ -26,27 +26,26 @@ export const App = () => { export default App; -const alert = (content: any, type?: AlertType) => ({ - toast, - handlers, -}: ContentType) => { - const { pauseTimer, resumeTimer, dismissToast } = handlers; +const alert = + (content: any, type?: AlertType) => + ({ toast, handlers }: ContentType) => { + const { pauseTimer, resumeTimer, dismissToast } = handlers; - return ( - - pauseTimer(toast.id)} - onMouseLeave={() => resumeTimer(toast.id)} - > - - - - ); -}; + return ( + + pauseTimer(toast.id)} + onMouseLeave={() => resumeTimer(toast.id)} + > + + + + ); + }; export function ToastTriggers() { const { showToast } = useToastHandlers(); diff --git a/src/toast/stories/Utils.component.tsx b/src/toast/stories/Utils.component.tsx index 60eddf3da..2f90d1631 100644 --- a/src/toast/stories/Utils.component.tsx +++ b/src/toast/stories/Utils.component.tsx @@ -6,7 +6,7 @@ import { createToastStore, DefaultToastOptions, useToastTimer, -} from "../index"; +} from "../../index"; export interface Toast extends TimerToast { content?: Content; @@ -46,12 +46,8 @@ const defaultOptions: DefaultToastOptions = { dismissDuration: 3000, }; -const [ - ToastProvider, - useToastStore, - useCreateToast, - useToastHandlers, -] = createToastStore(defaultOptions); +const [ToastProvider, useToastStore, useCreateToast, useToastHandlers] = + createToastStore(defaultOptions); export { ToastProvider, useToastStore, useCreateToast, useToastHandlers }; @@ -78,45 +74,44 @@ export type useToastsReturnType = ReturnType; /* ========================================================================= Components - Trigger ========================================================================== */ -export const TriggerButton: React.FC< - React.HTMLAttributes -> = props => { - const { style, ...rest } = props; +export const TriggerButton: React.FC> = + props => { + const { style, ...rest } = props; - return ( -