diff --git a/.changeset/famous-toes-enjoy.md b/.changeset/famous-toes-enjoy.md deleted file mode 100644 index 235f451c4..000000000 --- a/.changeset/famous-toes-enjoy.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@saas-ui/core': patch -'@saas-ui/react': patch ---- - -Improved StructuredList with keyboard navigation support diff --git a/.changeset/flat-bobcats-tell.md b/.changeset/flat-bobcats-tell.md deleted file mode 100644 index feda9f471..000000000 --- a/.changeset/flat-bobcats-tell.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@saas-ui/hotkeys': patch ---- - -Fixed issue where custom target element would always be null diff --git a/.changeset/long-turtles-destroy.md b/.changeset/long-turtles-destroy.md deleted file mode 100644 index 35089d290..000000000 --- a/.changeset/long-turtles-destroy.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@saas-ui/hotkeys': patch ---- - -Fixed issue where holding keys would not trigger hotkey handlers diff --git a/.changeset/sharp-cobras-hammer.md b/.changeset/sharp-cobras-hammer.md deleted file mode 100644 index 7ca5fa86d..000000000 --- a/.changeset/sharp-cobras-hammer.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@saas-ui/core': patch -'@saas-ui/react': patch ---- - -Added long press support to ContextMenu diff --git a/apps/palette/CHANGELOG.md b/apps/palette/CHANGELOG.md index 6c7ed963e..eff3eb5ea 100644 --- a/apps/palette/CHANGELOG.md +++ b/apps/palette/CHANGELOG.md @@ -1,5 +1,14 @@ # palette +## 1.4.15 + +### Patch Changes + +- Updated dependencies [bbd692d4] +- Updated dependencies [781a1c26] + - @saas-ui/react@2.5.3 + - @saas-ui/theme-glass@0.5.2 + ## 1.4.14 ### Patch Changes diff --git a/apps/palette/package.json b/apps/palette/package.json index 7d200f077..bde4b61d4 100644 --- a/apps/palette/package.json +++ b/apps/palette/package.json @@ -1,6 +1,6 @@ { "name": "palette-docs", - "version": "1.4.14", + "version": "1.4.15", "private": true, "scripts": { "dev": "next dev", diff --git a/apps/website/CHANGELOG.md b/apps/website/CHANGELOG.md index 678d5a730..abccb8b59 100644 --- a/apps/website/CHANGELOG.md +++ b/apps/website/CHANGELOG.md @@ -1,5 +1,14 @@ # website +## 2.3.13 + +### Patch Changes + +- Updated dependencies [bbd692d4] +- Updated dependencies [781a1c26] + - @saas-ui/react@2.5.3 + - @saas-ui/forms@2.3.7 + ## 2.3.12 ### Patch Changes diff --git a/apps/website/package.json b/apps/website/package.json index a148aec57..7e3d02602 100644 --- a/apps/website/package.json +++ b/apps/website/package.json @@ -1,6 +1,6 @@ { "name": "website", - "version": "2.3.12", + "version": "2.3.13", "private": true, "author": "Eelco Wiersma ", "scripts": { diff --git a/apps/website/src/pages/docs/components/navigation/hotkeys/usage.mdx b/apps/website/src/pages/docs/components/navigation/hotkeys/usage.mdx index 3ce8b0fd9..e173cad36 100644 --- a/apps/website/src/pages/docs/components/navigation/hotkeys/usage.mdx +++ b/apps/website/src/pages/docs/components/navigation/hotkeys/usage.mdx @@ -163,7 +163,7 @@ export default function Search() { Use the `then` keyword to create a sequence of keys. -Press `A` then `S` to trigger the action. +Press `A` then `B` to trigger the action. ```jsx center=true inline=true import { Box, Tooltip, Button } from '@chakra-ui/react' @@ -172,7 +172,7 @@ import { useHotkeys } from '@saas-ui/react' export default function Dialog() { const [isLoading, setLoading] = React.useState() - const key = useHotkeys('A then S', () => { + const key = useHotkeys('A then B', () => { setLoading(true) setTimeout(() => setLoading(false), 2000) }) diff --git a/packages/saas-ui-auth/CHANGELOG.md b/packages/saas-ui-auth/CHANGELOG.md index e5dce412c..515707067 100644 --- a/packages/saas-ui-auth/CHANGELOG.md +++ b/packages/saas-ui-auth/CHANGELOG.md @@ -1,5 +1,14 @@ # @saas-ui/auth +## 2.4.3 + +### Patch Changes + +- Updated dependencies [bbd692d4] +- Updated dependencies [781a1c26] + - @saas-ui/core@2.3.2 + - @saas-ui/forms@2.3.7 + ## 2.4.2 ### Patch Changes diff --git a/packages/saas-ui-auth/package.json b/packages/saas-ui-auth/package.json index a31fed4f3..82d6678e2 100644 --- a/packages/saas-ui-auth/package.json +++ b/packages/saas-ui-auth/package.json @@ -1,6 +1,6 @@ { "name": "@saas-ui/auth", - "version": "2.4.2", + "version": "2.4.3", "description": "Authentication provider and components for Chakra UI", "source": "src/index.ts", "exports": { diff --git a/packages/saas-ui-clerk/CHANGELOG.md b/packages/saas-ui-clerk/CHANGELOG.md index 49fd3c606..87fed76a6 100644 --- a/packages/saas-ui-clerk/CHANGELOG.md +++ b/packages/saas-ui-clerk/CHANGELOG.md @@ -1,5 +1,11 @@ # @saas-ui/clerk +## 3.0.24 + +### Patch Changes + +- @saas-ui/auth@2.4.3 + ## 3.0.23 ### Patch Changes diff --git a/packages/saas-ui-clerk/package.json b/packages/saas-ui-clerk/package.json index 68eacf6e1..ec2227ac4 100644 --- a/packages/saas-ui-clerk/package.json +++ b/packages/saas-ui-clerk/package.json @@ -1,6 +1,6 @@ { "name": "@saas-ui/clerk", - "version": "3.0.23", + "version": "3.0.24", "description": "Clerk Authentication Service for Saas UI", "source": "src/index.ts", "exports": { diff --git a/packages/saas-ui-core/CHANGELOG.md b/packages/saas-ui-core/CHANGELOG.md index 1900da597..6f2e6081c 100644 --- a/packages/saas-ui-core/CHANGELOG.md +++ b/packages/saas-ui-core/CHANGELOG.md @@ -1,5 +1,12 @@ # @saas-ui/react +## 2.3.2 + +### Patch Changes + +- bbd692d4: Improved StructuredList with keyboard navigation support +- 781a1c26: Added long press support to ContextMenu + ## 2.3.1 ### Patch Changes diff --git a/packages/saas-ui-core/package.json b/packages/saas-ui-core/package.json index 35c81e205..3811c8abc 100644 --- a/packages/saas-ui-core/package.json +++ b/packages/saas-ui-core/package.json @@ -1,6 +1,6 @@ { "name": "@saas-ui/core", - "version": "2.3.1", + "version": "2.3.2", "description": "Saas UI - The React component library for startups.", "source": "src/index.ts", "exports": { diff --git a/packages/saas-ui-data-table/CHANGELOG.md b/packages/saas-ui-data-table/CHANGELOG.md index 89863b6a3..fc1594e33 100644 --- a/packages/saas-ui-data-table/CHANGELOG.md +++ b/packages/saas-ui-data-table/CHANGELOG.md @@ -1,5 +1,14 @@ # @saas-ui/data-table +## 7.0.3 + +### Patch Changes + +- Updated dependencies [bbd692d4] +- Updated dependencies [781a1c26] + - @saas-ui/core@2.3.2 + - @saas-ui/react@2.5.3 + ## 7.0.2 ### Patch Changes diff --git a/packages/saas-ui-data-table/package.json b/packages/saas-ui-data-table/package.json index 0b6a2e277..2c4cd0925 100644 --- a/packages/saas-ui-data-table/package.json +++ b/packages/saas-ui-data-table/package.json @@ -1,6 +1,6 @@ { "name": "@saas-ui/data-table", - "version": "7.0.2", + "version": "7.0.3", "description": "Data-table Component", "source": "src/index.ts", "exports": { diff --git a/packages/saas-ui-date-picker/CHANGELOG.md b/packages/saas-ui-date-picker/CHANGELOG.md index ef8ae2e55..60fdccc36 100644 --- a/packages/saas-ui-date-picker/CHANGELOG.md +++ b/packages/saas-ui-date-picker/CHANGELOG.md @@ -1,5 +1,14 @@ # @saas-ui/date-picker +## 0.12.16 + +### Patch Changes + +- Updated dependencies [bbd692d4] +- Updated dependencies [781a1c26] + - @saas-ui/core@2.3.2 + - @saas-ui/modals@2.1.15 + ## 0.12.15 ### Patch Changes diff --git a/packages/saas-ui-date-picker/package.json b/packages/saas-ui-date-picker/package.json index 25f70bee5..ed3b85c04 100644 --- a/packages/saas-ui-date-picker/package.json +++ b/packages/saas-ui-date-picker/package.json @@ -1,6 +1,6 @@ { "name": "@saas-ui/date-picker", - "version": "0.12.15", + "version": "0.12.16", "description": "Chakra UI - Date Picker Component", "source": "src/index.ts", "exports": { diff --git a/packages/saas-ui-forms/CHANGELOG.md b/packages/saas-ui-forms/CHANGELOG.md index 378633eae..305926075 100644 --- a/packages/saas-ui-forms/CHANGELOG.md +++ b/packages/saas-ui-forms/CHANGELOG.md @@ -1,5 +1,13 @@ # @saas-ui/forms +## 2.3.7 + +### Patch Changes + +- Updated dependencies [bbd692d4] +- Updated dependencies [781a1c26] + - @saas-ui/core@2.3.2 + ## 2.3.6 ### Patch Changes diff --git a/packages/saas-ui-forms/package.json b/packages/saas-ui-forms/package.json index e87bafd27..5243cc7ff 100644 --- a/packages/saas-ui-forms/package.json +++ b/packages/saas-ui-forms/package.json @@ -1,6 +1,6 @@ { "name": "@saas-ui/forms", - "version": "2.3.6", + "version": "2.3.7", "description": "Fully functional forms for Chakra UI.", "source": "src/index.ts", "exports": { diff --git a/packages/saas-ui-hotkeys/CHANGELOG.md b/packages/saas-ui-hotkeys/CHANGELOG.md index 49adf7f97..4053cd5d9 100644 --- a/packages/saas-ui-hotkeys/CHANGELOG.md +++ b/packages/saas-ui-hotkeys/CHANGELOG.md @@ -1,5 +1,15 @@ # @saas-ui/hotkeys +## 2.1.13 + +### Patch Changes + +- 029b9b1c: Fixed issue where custom target element would always be null +- 029b9b1c: Fixed issue where holding keys would not trigger hotkey handlers +- Updated dependencies [bbd692d4] +- Updated dependencies [781a1c26] + - @saas-ui/core@2.3.2 + ## 2.1.12 ### Patch Changes diff --git a/packages/saas-ui-hotkeys/package.json b/packages/saas-ui-hotkeys/package.json index 3f440f3bb..8b8e2fd4f 100644 --- a/packages/saas-ui-hotkeys/package.json +++ b/packages/saas-ui-hotkeys/package.json @@ -1,6 +1,6 @@ { "name": "@saas-ui/hotkeys", - "version": "2.1.12", + "version": "2.1.13", "description": "Easy manageable keyboard shortcuts for Chakra UI", "source": "src/index.ts", "exports": { @@ -60,7 +60,8 @@ "dependencies": { "@chakra-ui/react-utils": "^2.0.12", "@chakra-ui/utils": "^2.0.15", - "@saas-ui/core": "workspace:*" + "@saas-ui/core": "workspace:*", + "@saas-ui/use-hotkeys": "workspace:*" }, "peerDependencies": { "@chakra-ui/react": ">=2.4.9", diff --git a/packages/saas-ui-hotkeys/src/hotkeys.tsx b/packages/saas-ui-hotkeys/src/hotkeys.tsx index 98c35758d..e5fbcabe3 100644 --- a/packages/saas-ui-hotkeys/src/hotkeys.tsx +++ b/packages/saas-ui-hotkeys/src/hotkeys.tsx @@ -23,7 +23,7 @@ function escapeRegExp(value: string) { return value.replace(regExpSyntaxCharacter, '\\$&') } -import { splitKeys } from './use-hotkeys' +import { splitKeys } from '@saas-ui/use-hotkeys' export interface HotkeysItemOptions { /** diff --git a/packages/saas-ui-hotkeys/src/index.ts b/packages/saas-ui-hotkeys/src/index.ts index 7c6e4212b..7883ca579 100644 --- a/packages/saas-ui-hotkeys/src/index.ts +++ b/packages/saas-ui-hotkeys/src/index.ts @@ -2,7 +2,12 @@ export { HotkeysProvider, type HotkeysProviderProps, useHotkeysContext, -} from './provider' + type UseHotkeysOptions, + splitKeys, + useHotkeys, + useHotkeysShortcut, +} from '@saas-ui/use-hotkeys' + export { HotkeysCommand, HotkeysGroup, @@ -21,5 +26,3 @@ export { type UseHotkeysListReturn, useHotkeysSearch, } from './hotkeys' -export { type UseHotkeysOptions, splitKeys, useHotkeys } from './use-hotkeys' -export { useHotkeysShortcut } from './use-hotkeys-shortcut' diff --git a/packages/saas-ui-hotkeys/src/provider.tsx b/packages/saas-ui-hotkeys/src/provider.tsx deleted file mode 100644 index 002e33e19..000000000 --- a/packages/saas-ui-hotkeys/src/provider.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import * as React from 'react' - -import { HotkeysListOptions, HotkeysOptions } from './hotkeys' - -const { createContext, useContext } = React - -interface HotkeysContextValues { - hotkeys: HotkeysListOptions -} - -const HotkeysContext: any = createContext([]) - -export interface HotkeysProviderProps extends HotkeysOptions { - children: React.ReactNode -} - -export const HotkeysProvider = ({ - children, - hotkeys, -}: HotkeysProviderProps) => { - const value = { hotkeys } - - return ( - {children} - ) -} - -export const useHotkeysContext = (): HotkeysContextValues => { - return useContext(HotkeysContext) -} diff --git a/packages/saas-ui-hotkeys/src/use-hotkeys-shortcut.ts b/packages/saas-ui-hotkeys/src/use-hotkeys-shortcut.ts deleted file mode 100644 index e50a1ee55..000000000 --- a/packages/saas-ui-hotkeys/src/use-hotkeys-shortcut.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { useHotkeysContext } from './provider' -import { useHotkeys, UseHotkeysOptions } from './use-hotkeys' - -/** - * useHotkeysShortcut React Hook - * - * Accepts one key combination or a shortcut - * - * Shortcuts refer to a predefined hotkeys configuration. - * @see https://www.saas-ui.dev/docs/navigation/hotkeys - * - * For example: - * ctrl+f or general.search - * - * Supports shifted keys like ?, =, >. - * - * ⌥ ⇧ ⌃ ⌘ shorthands are supported. - * - * @param keyOrShortcut Key combinations or a hotkeys shortcut - * @param callback The function to execute when the keys are pressed - * @param deps Deps for the callback function - * @returns The key combination - */ -export const useHotkeysShortcut = ( - keyOrShortcut: string, - callback: (event: KeyboardEvent) => void, - options: UseHotkeysOptions | Array = [], - deps?: Array -): string => { - const { hotkeys } = useHotkeysContext() - - const [group, key] = keyOrShortcut.split('.') - - let keys - if (group && key) { - keys = hotkeys?.[group]?.hotkeys[key]?.command - } - - if (!keys) { - keys = keyOrShortcut - } - - useHotkeys(keys, callback, options, deps) - - return keys -} diff --git a/packages/saas-ui-hotkeys/src/use-hotkeys.ts b/packages/saas-ui-hotkeys/src/use-hotkeys.ts deleted file mode 100644 index eea7369a3..000000000 --- a/packages/saas-ui-hotkeys/src/use-hotkeys.ts +++ /dev/null @@ -1,236 +0,0 @@ -import * as React from 'react' - -const { useEffect, useCallback, useMemo, useRef } = React - -// Works best with US or UK keyboards -const shiftedKeys: Record = { - ')': '0', - '!': '1', - '@': "'", - '"': "'", - '#': '3', - '£': '3', - $: '4', - '%': '5', - '^': '6', - '&': '7', - '*': '8', - '(': '9', - '~': '#', - _: '-', - '+': '=', - ':': ';', - '<': ',', - '>': '.', - '?': '/', - '|': '\\', - '{': '[', - '}': ']', -} - -const modifiers: Record = { - '⌥': 'alt', - option: 'alt', - '⇧': 'shift', - '⌃': 'control', - ctrl: 'control', - '⌘': 'meta', - cmd: 'meta', - command: 'meta', - mod: 'meta', // ios - esc: 'escape', -} - -export const splitKeys = (keys: string) => { - return keys - .replace(/\+/g, (match, offset) => { - if (offset === 0) { - return match - } - return ' ' - }) - .split(/\s/) -} - -const parseKeys = (keys: string | string[]) => { - if (typeof keys === 'string') { - keys = [keys] - } - return keys.reduce((memo: Array, command: string) => { - memo.push( - splitKeys(command.toLowerCase()).reduce( - (keys: string[], key: string, i, command) => { - if (command.length === 1 && shiftedKeys[key]) { - memo.push(['shift', shiftedKeys[key]]) - } - if (modifiers[key]) { - keys.push(modifiers[key]) - } else if (key !== 'then') { - keys.push(key) - } - return keys - }, - [] - ) - ) - return memo - }, []) -} - -const keysMatch = ( - pressedKeys: Set, - targetKeys: Array> -): boolean => - targetKeys.some((b) => { - return ( - pressedKeys.size === b.size && - !Array.from(pressedKeys).some((v) => !b.has(v)) - ) - }) - -const getKeyFromEvent = (event: KeyboardEvent): string => { - const key = event.key.toLowerCase() - if (shiftedKeys[key]) { - return shiftedKeys[key] - } - - return key -} - -export interface UseHotkeysOptions { - /** - * Whether to prevent the default behavior of the event. - * Eg. to override browser hotkeys. - * @default false - **/ - preventDefault?: boolean - /** - * The element to attach the event listener to. - * @default window - */ - targetElement?: HTMLElement | null - /** - * Ignore hotkeys when the target is an input element. - * @default ['INPUT', 'TEXTAREA', 'SELECT'] - */ - ignoreTags?: string[] - /** - * Whether to enable hotkeys when the target is a content editable element. - * @default false - */ - enableOnContentEditable?: boolean -} - -/** - * useHotKeys React Hook - * - * Supports shifted keys like ?, =, >. - * - * ⌥ ⇧ ⌃ ⌘ shorthands are supported. - * - * @param keys The keys that trigger this hotkey - * @param callback The function to execute when the keys are pressed - * @param deps Deps for the callback function - */ -export const useHotkeys = ( - keys: string | string[], - callback: (event: KeyboardEvent) => void, - options: UseHotkeysOptions | Array = [], - deps?: Array -) => { - let _options: UseHotkeysOptions = {} - if (Array.isArray(options)) { - deps = options - _options = {} - } else { - _options = options - deps = deps || [] - } - - const { - ignoreTags = ['INPUT', 'TEXTAREA', 'SELECT'], - enableOnContentEditable, - preventDefault = false, - } = _options - - const targetElement = - _options.targetElement || (typeof window === 'undefined' ? null : window) - - const memoizedCallback = useCallback(callback, deps || []) - - const targetKeys: Array> = useMemo( - () => parseKeys(keys).map((k) => new Set(k)), - [] - ) - - const pressedKeys: Set = useMemo(() => new Set(), []) - const bufferKeys: Set = useMemo(() => new Set(), []) - const bufferTimeout = useRef | null>(null) - - const isInputEvent = (event: KeyboardEvent) => { - const target = event.target as HTMLElement - return ( - (target.isContentEditable && !enableOnContentEditable) || - (ignoreTags.includes(target.tagName) && - // @ts-ignore: This only exists on HTMLInputElements - !target.readOnly && - // @ts-ignore: when targetElement is this input, we should trigger - target !== targetElement) - ) - } - - function onKeyDown(event: Event) { - if (isInputEvent(event as KeyboardEvent)) { - return - } - - const key = getKeyFromEvent(event as KeyboardEvent) - - pressedKeys.add(key) - bufferKeys.add(key) - - if (bufferTimeout.current) { - clearTimeout(bufferTimeout.current) - bufferTimeout.current = null - } - bufferTimeout.current = setTimeout(() => { - bufferKeys.clear() - }, 400) - - if ( - keysMatch(pressedKeys, targetKeys) || - (bufferKeys.size > 1 && keysMatch(bufferKeys, targetKeys)) - ) { - if (preventDefault) { - event.preventDefault() - } - bufferKeys.clear() // make sure the buffer gets cleared - // execute on next tick to make sure the last keyup doesn't trigger in any focused field - setTimeout(() => memoizedCallback(event as KeyboardEvent), 0) - } - } - - function onKeyUp(event: Event) { - if (isInputEvent(event as KeyboardEvent)) { - pressedKeys.clear() - return - } - pressedKeys.delete(getKeyFromEvent(event as KeyboardEvent)) - } - - function onWindowBlur() { - pressedKeys.clear() - } - - useEffect(() => { - targetElement?.addEventListener('keydown', onKeyDown) - targetElement?.addEventListener('keyup', onKeyUp) - targetElement?.addEventListener('blur', onWindowBlur) - - return () => { - targetElement?.removeEventListener('keydown', onKeyDown) - targetElement?.removeEventListener('keyup', onKeyUp) - targetElement?.removeEventListener('blur', onWindowBlur) - } - }, [memoizedCallback, targetElement]) -} diff --git a/packages/saas-ui-modals/CHANGELOG.md b/packages/saas-ui-modals/CHANGELOG.md index 7353e2fa8..5060786b3 100644 --- a/packages/saas-ui-modals/CHANGELOG.md +++ b/packages/saas-ui-modals/CHANGELOG.md @@ -1,5 +1,11 @@ # @saas-ui/modals +## 2.1.15 + +### Patch Changes + +- @saas-ui/forms@2.3.7 + ## 2.1.14 ### Patch Changes diff --git a/packages/saas-ui-modals/package.json b/packages/saas-ui-modals/package.json index 34fb20946..76b46651f 100644 --- a/packages/saas-ui-modals/package.json +++ b/packages/saas-ui-modals/package.json @@ -1,6 +1,6 @@ { "name": "@saas-ui/modals", - "version": "2.1.14", + "version": "2.1.15", "description": "A modal manager for Chakra UI", "source": "src/index.ts", "exports": { diff --git a/packages/saas-ui-react/CHANGELOG.md b/packages/saas-ui-react/CHANGELOG.md index 2969b247e..c03428ee5 100644 --- a/packages/saas-ui-react/CHANGELOG.md +++ b/packages/saas-ui-react/CHANGELOG.md @@ -1,5 +1,21 @@ # @saas-ui/react +## 2.5.3 + +### Patch Changes + +- bbd692d4: Improved StructuredList with keyboard navigation support +- 781a1c26: Added long press support to ContextMenu +- Updated dependencies [bbd692d4] +- Updated dependencies [029b9b1c] +- Updated dependencies [029b9b1c] +- Updated dependencies [781a1c26] + - @saas-ui/core@2.3.2 + - @saas-ui/hotkeys@2.1.13 + - @saas-ui/data-table@7.0.3 + - @saas-ui/forms@2.3.7 + - @saas-ui/modals@2.1.15 + ## 2.5.2 ### Patch Changes diff --git a/packages/saas-ui-react/package.json b/packages/saas-ui-react/package.json index 6738692f7..8371f5f5c 100644 --- a/packages/saas-ui-react/package.json +++ b/packages/saas-ui-react/package.json @@ -1,6 +1,6 @@ { "name": "@saas-ui/react", - "version": "2.5.2", + "version": "2.5.3", "description": "Saas UI - The React component library for startups.", "source": "src/index.ts", "exports": { diff --git a/packages/saas-ui-use-hotkeys/CHANGELOG.md b/packages/saas-ui-use-hotkeys/CHANGELOG.md index e185fdd4e..70b263041 100644 --- a/packages/saas-ui-use-hotkeys/CHANGELOG.md +++ b/packages/saas-ui-use-hotkeys/CHANGELOG.md @@ -1,5 +1,20 @@ # @saas-ui/use-hotkeys +## 1.0.9 + +### Patch Changes + +- 029b9b1c: Fixed issue where custom target element would always be null +- 029b9b1c: Fixed issue where holding keys would not trigger hotkey handlers + +## 1.0.8 + +### Patch Changes + +- Updated dependencies [bbd692d4] +- Updated dependencies [781a1c26] + - @saas-ui/core@2.3.2 + ## 1.0.7 ### Patch Changes diff --git a/packages/saas-ui-use-hotkeys/package.json b/packages/saas-ui-use-hotkeys/package.json index 0108e8d36..3aa18b112 100644 --- a/packages/saas-ui-use-hotkeys/package.json +++ b/packages/saas-ui-use-hotkeys/package.json @@ -1,6 +1,6 @@ { "name": "@saas-ui/use-hotkeys", - "version": "1.0.7", + "version": "1.0.9", "description": "Easy to use and scalable keyboard shortcuts for React.", "source": "src/index.ts", "exports": { @@ -57,16 +57,7 @@ "title": "Saas UI", "url": "https://storybook.saas-ui.dev" }, - "dependencies": { - "@chakra-ui/react-utils": "^2.0.12", - "@chakra-ui/utils": "^2.0.15", - "@saas-ui/core": "workspace:*" - }, "peerDependencies": { - "@chakra-ui/react": ">=2.4.9", - "@emotion/react": ">=11.0.0", - "@emotion/styled": ">=11.0.0", - "framer-motion": ">=6.0.0", "react": ">=18.0.0", "react-dom": ">=18.0.0" } diff --git a/packages/saas-ui-use-hotkeys/src/use-hotkeys.ts b/packages/saas-ui-use-hotkeys/src/use-hotkeys.ts index 48839d3ae..eea7369a3 100644 --- a/packages/saas-ui-use-hotkeys/src/use-hotkeys.ts +++ b/packages/saas-ui-use-hotkeys/src/use-hotkeys.ts @@ -154,7 +154,7 @@ export const useHotkeys = ( } = _options const targetElement = - _options.targetElement || typeof window === 'undefined' ? null : window + _options.targetElement || (typeof window === 'undefined' ? null : window) const memoizedCallback = useCallback(callback, deps || []) @@ -185,6 +185,7 @@ export const useHotkeys = ( } const key = getKeyFromEvent(event as KeyboardEvent) + pressedKeys.add(key) bufferKeys.add(key) @@ -204,7 +205,6 @@ export const useHotkeys = ( event.preventDefault() } bufferKeys.clear() // make sure the buffer gets cleared - pressedKeys.clear() // make sure the pressed keys get cleared // execute on next tick to make sure the last keyup doesn't trigger in any focused field setTimeout(() => memoizedCallback(event as KeyboardEvent), 0) } diff --git a/packages/storybook/CHANGELOG.md b/packages/storybook/CHANGELOG.md index 013846541..c116c395f 100644 --- a/packages/storybook/CHANGELOG.md +++ b/packages/storybook/CHANGELOG.md @@ -1,5 +1,13 @@ # saas-ui-storybook +## 1.1.15 + +### Patch Changes + +- Updated dependencies [bbd692d4] +- Updated dependencies [781a1c26] + - @saas-ui/react@2.5.3 + ## 1.1.14 ### Patch Changes diff --git a/packages/storybook/package.json b/packages/storybook/package.json index eba425641..b0ab044de 100644 --- a/packages/storybook/package.json +++ b/packages/storybook/package.json @@ -1,7 +1,7 @@ { "name": "saas-ui-storybook", "type": "module", - "version": "1.1.14", + "version": "1.1.15", "scripts": { "dev": "sb dev -p 6006", "build": "sb build --debug --loglevel verbose" diff --git a/tooling/test-utils/CHANGELOG.md b/tooling/test-utils/CHANGELOG.md index 7d19f5df2..f83c8c815 100644 --- a/tooling/test-utils/CHANGELOG.md +++ b/tooling/test-utils/CHANGELOG.md @@ -1,5 +1,13 @@ # @saas-ui/test-utils +## 3.1.15 + +### Patch Changes + +- Updated dependencies [bbd692d4] +- Updated dependencies [781a1c26] + - @saas-ui/react@2.5.3 + ## 3.1.14 ### Patch Changes diff --git a/tooling/test-utils/package.json b/tooling/test-utils/package.json index 88e5c8c7d..b652ac0db 100644 --- a/tooling/test-utils/package.json +++ b/tooling/test-utils/package.json @@ -1,6 +1,6 @@ { "name": "@saas-ui/test-utils", - "version": "3.1.14", + "version": "3.1.15", "private": true, "description": "Testing utilities for Chakra UI's components", "keywords": [ diff --git a/yarn.lock b/yarn.lock index 7bb41f5f9..0fa686e57 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8422,6 +8422,7 @@ __metadata: "@chakra-ui/react-utils": "npm:^2.0.12" "@chakra-ui/utils": "npm:^2.0.15" "@saas-ui/core": "workspace:*" + "@saas-ui/use-hotkeys": "workspace:*" peerDependencies: "@chakra-ui/react": ">=2.4.9" "@emotion/react": ">=11.0.0" @@ -8689,18 +8690,10 @@ __metadata: languageName: unknown linkType: soft -"@saas-ui/use-hotkeys@workspace:packages/saas-ui-use-hotkeys": +"@saas-ui/use-hotkeys@workspace:*, @saas-ui/use-hotkeys@workspace:packages/saas-ui-use-hotkeys": version: 0.0.0-use.local resolution: "@saas-ui/use-hotkeys@workspace:packages/saas-ui-use-hotkeys" - dependencies: - "@chakra-ui/react-utils": "npm:^2.0.12" - "@chakra-ui/utils": "npm:^2.0.15" - "@saas-ui/core": "workspace:*" peerDependencies: - "@chakra-ui/react": ">=2.4.9" - "@emotion/react": ">=11.0.0" - "@emotion/styled": ">=11.0.0" - framer-motion: ">=6.0.0" react: ">=18.0.0" react-dom: ">=18.0.0" languageName: unknown