diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md index c2630a84..843fd102 100644 --- a/COMPONENT_INDEX.md +++ b/COMPONENT_INDEX.md @@ -1,6 +1,6 @@ # Component Index -> 163 components exported from carbon-components-svelte@0.80.0. +> 164 components exported from carbon-components-svelte@0.80.0. ## Components @@ -95,6 +95,7 @@ - [`PaginationSkeleton`](#paginationskeleton) - [`PasswordInput`](#passwordinput) - [`Popover`](#popover) +- [`PopoverContent`](#popovercontent) - [`ProgressBar`](#progressbar) - [`ProgressIndicator`](#progressindicator) - [`ProgressIndicatorSkeleton`](#progressindicatorskeleton) @@ -2797,15 +2798,15 @@ None. ### Props -| Prop name | Required | Kind | Reactive | Type | Default value | Description | -| :------------------ | :------- | :--------------- | :------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ------------------------------------------------------ | -| open | No | let | Yes | boolean | false | Set to `true` to display the popover | -| closeOnOutsideClick | No | let | No | boolean | false | Set to `true` to close the popover on an outside click | -| caret | No | let | No | boolean | false | Set to `true` render a caret | -| align | No | let | No | "top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right" | "left" | "left-bottom" | "left-top" | "right" | "right-bottom" | "right-top" | "top" | Specify the alignment of the caret | -| light | No | let | No | boolean | false | Set to `true` to enable the light variant | -| highContrast | No | let | No | boolean | false | Set to `true` to enable the high contrast variant | -| relative | No | let | No | boolean | false | Set to `true` to use a relative position | +| Prop name | Required | Kind | Reactive | Type | Default value | Description | +| :------------------ | :------- | :--------------- | :------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------- | ------------------------------------------------------ | +| open | No | let | Yes | boolean | false | Set to `true` to display the popover | +| closeOnOutsideClick | No | let | No | boolean | false | Set to `true` to close the popover on an outside click | +| isTabTip | No | let | No | boolean | false | Set to `true` to render the tab tip variant | +| caret | No | let | No | boolean | undefined | Set to `true` render a caret | +| align | No | let | No | "top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right" | "left" | "left-bottom" | "left-top" | "right" | "right-bottom" | "right-top" | undefined | Specify the alignment of the caret | +| dropShadow | No | let | No | boolean | true | Set to `false` to omit the drop shadow | +| highContrast | No | let | No | boolean | false | Set to `true` to enable the high contrast variant | ### Slots @@ -2819,6 +2820,25 @@ None. | :------------ | :--------- | :------------------------------------ | | click:outside | dispatched | { target: HTMLElement; } | +## `PopoverContent` + +### Props + +| Prop name | Required | Kind | Reactive | Type | Default value | Description | +| :----------- | :------- | :--------------- | :------- | --------------- | ----------------- | ----------- | +| className | No | let | No | -- | null | -- | +| contentProps | No | let | No | {} | {} | -- | + +### Slots + +| Slot name | Default | Props | Fallback | +| :-------- | :------ | :---- | :------- | +| -- | Yes | -- | -- | + +### Events + +None. + ## `ProgressBar` ### Props diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json index 2337f25a..4bf660c7 100644 --- a/docs/src/COMPONENT_API.json +++ b/docs/src/COMPONENT_API.json @@ -1,5 +1,5 @@ { - "total": 163, + "total": 164, "components": [ { "moduleName": "Accordion", @@ -8911,12 +8911,23 @@ "constant": false, "reactive": false }, + { + "name": "isTabTip", + "kind": "let", + "description": "Set to `true` to render the tab tip variant", + "type": "boolean", + "value": "false", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, { "name": "caret", "kind": "let", "description": "Set to `true` render a caret", "type": "boolean", - "value": "false", "isFunction": false, "isFunctionDeclaration": false, "isRequired": false, @@ -8928,7 +8939,6 @@ "kind": "let", "description": "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\"", - "value": "\"top\"", "isFunction": false, "isFunctionDeclaration": false, "isRequired": false, @@ -8936,11 +8946,11 @@ "reactive": false }, { - "name": "light", + "name": "dropShadow", "kind": "let", - "description": "Set to `true` to enable the light variant", + "description": "Set to `false` to omit the drop shadow", "type": "boolean", - "value": "false", + "value": "true", "isFunction": false, "isFunctionDeclaration": false, "isRequired": false, @@ -8958,18 +8968,6 @@ "isRequired": false, "constant": false, "reactive": false - }, - { - "name": "relative", - "kind": "let", - "description": "Set to `true` to use a relative position", - "type": "boolean", - "value": "false", - "isFunction": false, - "isFunctionDeclaration": false, - "isRequired": false, - "constant": false, - "reactive": false } ], "moduleExports": [], @@ -8982,7 +8980,39 @@ } ], "typedefs": [], - "rest_props": { "type": "Element", "name": "div" } + "rest_props": { "type": "Element", "name": "span" } + }, + { + "moduleName": "PopoverContent", + "filePath": "src/Popover/PopoverContent.svelte", + "props": [ + { + "name": "className", + "kind": "let", + "value": "null", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + }, + { + "name": "contentProps", + "kind": "let", + "type": "{}", + "value": "{}", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false + } + ], + "moduleExports": [], + "slots": [{ "name": "__default__", "default": true, "slot_props": "{}" }], + "events": [], + "typedefs": [], + "rest_props": { "type": "Element", "name": "span" } }, { "moduleName": "ProgressBar", diff --git a/docs/src/global.css b/docs/src/global.css index 1b09a049..e9a590e7 100644 --- a/docs/src/global.css +++ b/docs/src/global.css @@ -121,6 +121,10 @@ html[theme="g90"] .code-override { margin-bottom: var(--bx-spacing-05); } +.p-05 { + padding: var(--bx-spacing-05); +} + .table { position: sticky; max-height: calc(100vh - 3rem); diff --git a/docs/src/pages/components/Popover.svx b/docs/src/pages/components/Popover.svx index 40089d01..d2b850f0 100644 --- a/docs/src/pages/components/Popover.svx +++ b/docs/src/pages/components/Popover.svx @@ -1,153 +1,128 @@ +--- +components: ["Popover", "PopoverContent"] +--- + ## Default -By default, the position of the popover component is absolute. +By default, the alignment of the popover is at the bottom. -
- Parent - -
Content
-
-
- -## Relative position - -Set `relative` to `true` to use a relative position. - -
- Parent - -
Content
-
-
- -## Close on outside click - -Set `closeOnOutsideClick` to set `open` to `false` when clicking outside of the popover. - -
- Parent - {console.log('on:click:outside')}}> -
Content
-
-
+ +
Parent
+ Content +
## Popover alignment Customize the popover alignment using the `align` prop. Valid values include: `"top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right" | "left" | "left-bottom" | "left-top" | "right" | "right-bottom" | "right-top"`. -The default `align` value is `"top"`. +The default `align` value is `"bottom"`. -
- Parent - -
top-left
-
-
-
- Parent - -
top-right
-
-
-
- Parent +**At the bottom** + +
-
bottom
+
Parent
+ bottom
-
-
- Parent -
bottom-left
+
Parent
+ bottom-left
-
-
- Parent -
bottom-right
+
Parent
+ bottom-right
-
- Parent + +**To the left** + +
-
left
+
Parent
+ left
-
-
- Parent -
left-bottom
+
Parent
+ left-bottom +
+ +
Parent
+ left-top
-
- Parent - -
left-right
-
-
-
- Parent + +**To the right** + +
-
right
+
Parent
+ right
-
-
- Parent -
right-bottom
+
Parent
+ right-bottom
-
-
- Parent -
right-top
+
Parent
+ right-top
-## With caret +**At the top** -
- Parent - -
Content
+
+ +
Parent
+ top-left +
+ +
Parent
+ top +
+ +
Parent
+ top-right
-## Custom caret alignment -By default, the caret is aligned "top". +## Without caret -Possible `align` values include `"top"`, `"top-left"`, `"top-right"`, `"bottom"`, `"bottom-left"`, `"bottom-right"`, `"left"`, `"left-bottom"`, `"left-top"`, `"right"`, `"right-bottom"` or `"right-top"`. + +
Parent
+ Content +
-
- Parent - -
Content
-
-
+## Tab tip variant -## Light variant - -
- Parent - -
Content
-
-
+ + +
-
Content
+ + Content
diff --git a/src/Popover/Popover.svelte b/src/Popover/Popover.svelte index 2249cc9c..39c56117 100644 --- a/src/Popover/Popover.svelte +++ b/src/Popover/Popover.svelte @@ -9,24 +9,27 @@ /** 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; + /** Set to `true` to render the tab tip variant */ + export let isTabTip = false; + + /** + * Set to `true` render a caret + * @type {boolean} + * */ + export let caret = isTabTip ? false : true; /** * 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"; + export let align = isTabTip ? "bottom-left" : "bottom"; - /** Set to `true` to enable the light variant */ - export let light = false; + /** Set to `false` to omit the drop shadow */ + export let dropShadow = true; /** 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(); @@ -44,11 +47,11 @@ }}" /> -
-
- -
-
+ + diff --git a/src/Popover/PopoverContent.svelte b/src/Popover/PopoverContent.svelte new file mode 100644 index 00000000..68d04119 --- /dev/null +++ b/src/Popover/PopoverContent.svelte @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/src/Popover/index.js b/src/Popover/index.js index 6ffabfa1..5d0144b7 100644 --- a/src/Popover/index.js +++ b/src/Popover/index.js @@ -1 +1,2 @@ export { default as Popover } from "./Popover.svelte"; +export { default as PopoverContent } from "./PopoverContent.svelte"; diff --git a/src/index.js b/src/index.js index fc289bf6..16fba2b6 100644 --- a/src/index.js +++ b/src/index.js @@ -84,7 +84,7 @@ export { OrderedList } from "./OrderedList"; export { OverflowMenu, OverflowMenuItem } from "./OverflowMenu"; export { Pagination, PaginationSkeleton } from "./Pagination"; export { PaginationNav } from "./PaginationNav"; -export { Popover } from "./Popover"; +export { Popover, PopoverContent } from "./Popover"; export { ProgressBar } from "./ProgressBar"; export { ProgressIndicator, diff --git a/tests/Popover.test.svelte b/tests/Popover.test.svelte index d56ec71c..49fbfb67 100644 --- a/tests/Popover.test.svelte +++ b/tests/Popover.test.svelte @@ -1,5 +1,5 @@ @@ -9,12 +9,10 @@ closeOnOutsideClick align="right" caret - relative - light highContrast on:click:outside="{() => { console.log('on:click:outside'); }}" > -
Content
+ Content
diff --git a/types/Popover/Popover.svelte.d.ts b/types/Popover/Popover.svelte.d.ts index 674a8b3c..88ca7ea6 100644 --- a/types/Popover/Popover.svelte.d.ts +++ b/types/Popover/Popover.svelte.d.ts @@ -1,7 +1,7 @@ import type { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; -type RestProps = SvelteHTMLElements["div"]; +type RestProps = SvelteHTMLElements["span"]; export interface PopoverProps extends RestProps { /** @@ -17,14 +17,20 @@ export interface PopoverProps extends RestProps { closeOnOutsideClick?: boolean; /** - * Set to `true` render a caret + * Set to `true` to render the tab tip variant * @default false */ + isTabTip?: boolean; + + /** + * Set to `true` render a caret + * @default undefined + */ caret?: boolean; /** * Specify the alignment of the caret - * @default "top" + * @default undefined */ align?: | "top" @@ -41,10 +47,10 @@ export interface PopoverProps extends RestProps { | "right-top"; /** - * Set to `true` to enable the light variant - * @default false + * Set to `false` to omit the drop shadow + * @default true */ - light?: boolean; + dropShadow?: boolean; /** * Set to `true` to enable the high contrast variant @@ -52,12 +58,6 @@ export interface PopoverProps extends RestProps { */ highContrast?: boolean; - /** - * Set to `true` to use a relative position - * @default false - */ - relative?: boolean; - [key: `data-${string}`]: any; } diff --git a/types/Popover/PopoverContent.svelte.d.ts b/types/Popover/PopoverContent.svelte.d.ts new file mode 100644 index 00000000..614d57a2 --- /dev/null +++ b/types/Popover/PopoverContent.svelte.d.ts @@ -0,0 +1,24 @@ +import type { SvelteComponentTyped } from "svelte"; +import type { SvelteHTMLElements } from "svelte/elements"; + +type RestProps = SvelteHTMLElements["span"]; + +export interface PopoverContentProps extends RestProps { + /** + * @default null + */ + className?: undefined; + + /** + * @default {} + */ + contentProps?: {}; + + [key: `data-${string}`]: any; +} + +export default class PopoverContent extends SvelteComponentTyped< + PopoverContentProps, + Record, + { default: {} } +> {} diff --git a/types/index.d.ts b/types/index.d.ts index 360753c1..8f06b22c 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -91,6 +91,7 @@ export { default as Pagination } from "./Pagination/Pagination.svelte"; export { default as PaginationSkeleton } from "./Pagination/PaginationSkeleton.svelte"; export { default as PaginationNav } from "./PaginationNav/PaginationNav.svelte"; export { default as Popover } from "./Popover/Popover.svelte"; +export { default as PopoverContent } from "./Popover/PopoverContent.svelte"; export { default as ProgressBar } from "./ProgressBar/ProgressBar.svelte"; export { default as ProgressIndicator } from "./ProgressIndicator/ProgressIndicator.svelte"; export { default as ProgressIndicatorSkeleton } from "./ProgressIndicator/ProgressIndicatorSkeleton.svelte";