From ea9b261b60698f9314e0aae4d61025bae215cccf Mon Sep 17 00:00:00 2001 From: Nestor Orest Plysyuk Date: Thu, 13 Jul 2023 16:37:21 +0200 Subject: [PATCH] feat(ui-shell): add `preventCloseOnClickOutside` to `HeaderAction` (#1625) Closes #1624 --- COMPONENT_INDEX.md | 17 +++++++++-------- docs/src/COMPONENT_API.json | 12 ++++++++++++ src/UIShell/HeaderAction.svelte | 10 +++++++++- types/UIShell/HeaderAction.svelte.d.ts | 6 ++++++ 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md index 9daf766e..f7eb9e64 100644 --- a/COMPONENT_INDEX.md +++ b/COMPONENT_INDEX.md @@ -1601,14 +1601,15 @@ None. ### Props -| Prop name | Required | Kind | Reactive | Type | Default value | Description | -| :--------- | :------- | :--------------- | :------- | ----------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------- | -| ref | No | let | Yes | null | HTMLButtonElement | null | Obtain a reference to the button HTML element | -| isOpen | No | let | Yes | boolean | false | Set to `true` to open the panel | -| icon | No | let | No | typeof import("svelte").SvelteComponent | undefined | Specify the icon to render when the action panel is closed.
Defaults to `<Switcher size={20} />` | -| closeIcon | No | let | No | typeof import("svelte").SvelteComponent | undefined | Specify the icon to render when the action panel is open.
Defaults to `<Close size={20} />` | -| text | No | let | No | string | undefined | Specify the text
Alternatively, use the named slot "text" (e.g., <div slot="text">...</div>) | -| transition | No | let | No | false | import("svelte/transition").SlideParams | { duration: 200 } | Customize the panel transition (i.e., `transition:slide`).
Set to `false` to disable the transition | +| Prop name | Required | Kind | Reactive | Type | Default value | Description | +| :------------------------- | :------- | :--------------- | :------- | ----------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------------------------------------------------------- | +| ref | No | let | Yes | null | HTMLButtonElement | null | Obtain a reference to the button HTML element | +| isOpen | No | let | Yes | boolean | false | Set to `true` to open the panel | +| icon | No | let | No | typeof import("svelte").SvelteComponent | undefined | Specify the icon to render when the action panel is closed.
Defaults to `<Switcher size={20} />` | +| closeIcon | No | let | No | typeof import("svelte").SvelteComponent | undefined | Specify the icon to render when the action panel is open.
Defaults to `<Close size={20} />` | +| text | No | let | No | string | undefined | Specify the text
Alternatively, use the named slot "text" (e.g., <div slot="text">...</div>) | +| transition | No | let | No | false | import("svelte/transition").SlideParams | { duration: 200 } | Customize the panel transition (i.e., `transition:slide`).
Set to `false` to disable the transition | +| preventCloseOnClickOutside | No | let | No | boolean | false | Set to `true` to prevent the panel from closing when clicking outside | ### Slots diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json index fa22c7f2..8081cd3f 100644 --- a/docs/src/COMPONENT_API.json +++ b/docs/src/COMPONENT_API.json @@ -4923,6 +4923,18 @@ "isRequired": false, "constant": false, "reactive": false + }, + { + "name": "preventCloseOnClickOutside", + "kind": "let", + "description": "Set to `true` to prevent the panel from closing when clicking outside", + "type": "boolean", + "value": "false", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false } ], "moduleExports": [], diff --git a/src/UIShell/HeaderAction.svelte b/src/UIShell/HeaderAction.svelte index 59d749e5..b42597e7 100644 --- a/src/UIShell/HeaderAction.svelte +++ b/src/UIShell/HeaderAction.svelte @@ -38,6 +38,9 @@ */ export let transition = { duration: 200 }; + /** Set to `true` to prevent the panel from closing when clicking outside */ + export let preventCloseOnClickOutside = false; + import { createEventDispatcher } from "svelte"; import { slide } from "svelte/transition"; import Close from "../icons/Close.svelte"; @@ -50,7 +53,12 @@