-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop actions in favor of onBrowserMount (#15)
* fix: parent submenu closes because of rerender * use menu in docs sidebar * implement onBrowserMount on collapsible to get rid of the action * rework tabs and implement missing ids * cleanup tabs * update readme * udate accordion * use data attrs to target the root element * remove switch action in favor of onMount * remove action on button * remove link action * remove actions in popover * remove radiogroup action * remove tooltip action * remove tagGroup action * remove toggle button action * fix: remove action in switch example * remove action from listbox and add multiple example * avoid scrolling when setiing the 1st active desc * update listbox * remove action from calendar component * remove actions from select * remove actions from combobox * remove action from label * minor changes * remove action from toolbar * tooltip component now runs floating ui by itself * chore: format code * feat: focus trap * update docs * feat: update popover (trap focus and handles positioning) * feat: update menu component to handle properly submenus * chore: minor change * feat: remove checkbox action * chore: remove dangling actions in button tests * feat: remove action from carousel component * chore: remove already inferred types * fix: toggle btn tabindex * fix: tests * add space between button and popover content
- Loading branch information
Showing
98 changed files
with
1,522 additions
and
1,230 deletions.
There are no files selected for viewing
This file contains 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,33 @@ | ||
import { getFocusableElements } from '$lib/helpers/dom.js' | ||
import type { Action } from 'svelte/action' | ||
|
||
export const focusTrap: Action = (node: HTMLElement) => { | ||
const onKeyDown = (event: KeyboardEvent) => { | ||
const focusableElements = getFocusableElements(node) | ||
|
||
const firstFocusableElement = focusableElements[0] | ||
const lastFocusableElement = focusableElements[focusableElements.length - 1] | ||
|
||
if (event.key === 'Tab') { | ||
if (event.shiftKey) { | ||
if (document.activeElement === firstFocusableElement) { | ||
event.preventDefault() | ||
lastFocusableElement.focus() | ||
} | ||
} else { | ||
if (document.activeElement === lastFocusableElement) { | ||
event.preventDefault() | ||
firstFocusableElement.focus() | ||
} | ||
} | ||
} | ||
} | ||
|
||
node.addEventListener('keydown', onKeyDown, true) | ||
|
||
return { | ||
destroy() { | ||
node.removeEventListener('keydown', onKeyDown, true) | ||
}, | ||
} | ||
} |
This file contains 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 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 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 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 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 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,13 +1,11 @@ | ||
import type { HTMLAttributes } from '$lib/helpers/types.js' | ||
import type { Action } from 'svelte/action' | ||
import type { Readable } from 'svelte/store' | ||
import type { Readable, Writable } from 'svelte/store' | ||
|
||
export type ButtonConfig = { | ||
disabled?: boolean | ||
} | ||
|
||
export type Button = { | ||
disabled: Readable<boolean> | ||
disabled: Writable<boolean> | ||
buttonAttrs: Readable<HTMLAttributes> | ||
button: Action | ||
} |
This file contains 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 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
Oops, something went wrong.