mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-16 10:51:06 +00:00
Alignment with Carbon version 10.31 (#571)
* chore(deps-dev): upgrade carbon-components to v10.31.0 * fix(slider): use CSS to hide input if hideTextInput is true * docs(slider): add hidden text input, invalid, disabled examples * feat(tabs): support "container" type for TabsSkeleton * chore(list-box): remove hotfix inline style to center dropdown chevron * fix(number-input): use add, subtract icons and update markup * feat(select): add warning state * docs(select): add invalid state example * docs(select): add helper text example * fix(structured-list): add "rowgroup" role to StructuredListBody * docs: release code snippet max-width * docs(select): add skeleton hidden label example * feat(popover): add Popover component * feat(pagination): dispatch button click events to be consistent with PaginationNav * fix(multi-select): type clear as a custom event * docs(radio-button): add disabled buttons example * chore(tabs): use absolute icon import * fix(link): remove line breaks within anchor link * docs(radio-button): adjust section copy verbiage * chore(deps-dev): upgrade carbon-icons-svelte to v10.27 v10.27 uses the SvelteComponentTyped interface * docs(accordion): adjust section title verbiage * test(types): fix warnings from svelte-check * fix(search): only set autofocus attribute if equals true * feat(popover): add closeOnOutsideClick prop * docs: style [data-outline] as relative positioned * feat(context-menu): add initial ContextMenu * feat(context-menu): annotate props, generate types * feat(context-menu): add initial focus logic * fix(context-menu): correctly tab in/out of nested menus * chore(context-menu): update types * fix(context-menu): obtain radio id from node directly * docs(context-menu): add examples and test * fix(context-menu): prevent default keydown behavior
This commit is contained in:
parent
afed4fa2fa
commit
5fad0cb3c7
52 changed files with 1758 additions and 103 deletions
68
src/Popover/Popover.svelte
Normal file
68
src/Popover/Popover.svelte
Normal file
|
@ -0,0 +1,68 @@
|
|||
<script>
|
||||
/** Set to `true` to display the popover */
|
||||
export let open = false;
|
||||
|
||||
/** Set to `true` to close the popover on an outside click */
|
||||
export let closeOnOutsideClick = false;
|
||||
|
||||
/** Set to `true` render a caret */
|
||||
export let caret = false;
|
||||
|
||||
/**
|
||||
* Specify the alignment of the caret
|
||||
* @type {"top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right" | "left" | "left-bottom" | "left-top" | "right" | "right-bottom" | "right-top"}
|
||||
*/
|
||||
export let align = "top";
|
||||
|
||||
/** Set to `true` to enable the light variant */
|
||||
export let light = false;
|
||||
|
||||
/** Set to `true` to enable the high contrast variant */
|
||||
export let highContrast = false;
|
||||
|
||||
/** Set to `true` to use a relative position */
|
||||
export let relative = false;
|
||||
|
||||
import { createEventDispatcher } from "svelte";
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
let ref = null;
|
||||
</script>
|
||||
|
||||
<svelte:window
|
||||
on:click="{(e) => {
|
||||
if (!open) return;
|
||||
if (e.target.contains(ref)) {
|
||||
dispatch('click:outside');
|
||||
if (closeOnOutsideClick) open = false;
|
||||
}
|
||||
}}"
|
||||
/>
|
||||
|
||||
<div
|
||||
bind:this="{ref}"
|
||||
class:bx--popover="{true}"
|
||||
class:bx--popover--caret="{caret}"
|
||||
class:bx--popover--light="{light}"
|
||||
class:bx--popover--high-contrast="{highContrast}"
|
||||
class:bx--popover--top="{align === 'top'}"
|
||||
class:bx--popover--top-left="{align === 'top-left'}"
|
||||
class:bx--popover--top-right="{align === 'top-right'}"
|
||||
class:bx--popover--bottom="{align === 'bottom'}"
|
||||
class:bx--popover--bottom-left="{align === 'bottom-left'}"
|
||||
class:bx--popover--bottom-right="{align === 'bottom-right'}"
|
||||
class:bx--popover--left="{align === 'left'}"
|
||||
class:bx--popover--left-bottom="{align === 'left-bottom'}"
|
||||
class:bx--popover--left-top="{align === 'left-top'}"
|
||||
class:bx--popover--right="{align === 'right'}"
|
||||
class:bx--popover--right-bottom="{align === 'right-bottom'}"
|
||||
class:bx--popover--right-top="{align === 'right-top'}"
|
||||
class:bx--popover--open="{open}"
|
||||
class:bx--popover--relative="{relative}"
|
||||
{...$$restProps}
|
||||
>
|
||||
<div class:bx--popover-contents="{true}">
|
||||
<slot />
|
||||
</div>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue