123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456 |
- /*!
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
- * v1.0.0-beta.97
- */
- import { h } from "@stencil/core";
- import { CSS } from "./resources";
- import { updateHostInteraction } from "../../utils/interactive";
- /**
- * @slot - A slot for adding `calcite-dropdown` content.
- */
- export class SplitButton {
- constructor() {
- /** Specifies the appearance style of the component. */
- this.appearance = "solid";
- /** Specifies the color of the component. */
- this.color = "blue";
- /** When `true`, interaction is prevented and the component is displayed with lower opacity. */
- this.disabled = false;
- /**
- * When `true`, the component is active.
- *
- * @internal
- */
- this.active = false;
- /** Specifies the icon used for the dropdown menu. */
- this.dropdownIconType = "chevron";
- /**
- When `true`, a busy indicator is displayed on the primary button.
- */
- this.loading = false;
- /**
- * Determines the type of positioning to use for the overlaid content.
- *
- * Using `"absolute"` will work for most cases. The component will be positioned inside of overflowing parent containers and will affect the container's layout.
- *
- * `"fixed"` should be used to escape an overflowing parent container, or when the reference element's `position` CSS property is `"fixed"`.
- *
- */
- this.overlayPositioning = "absolute";
- /** Specifies the size of the component. */
- this.scale = "m";
- /** Specifies the width of the component. */
- this.width = "auto";
- this.calciteSplitButtonPrimaryClickHandler = (event) => this.calciteSplitButtonPrimaryClick.emit(event);
- this.calciteSplitButtonSecondaryClickHandler = (event) => this.calciteSplitButtonSecondaryClick.emit(event);
- }
- handleDisabledChange(value) {
- if (!value) {
- this.active = false;
- }
- }
- activeHandler() {
- if (this.disabled) {
- this.active = false;
- }
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentDidRender() {
- updateHostInteraction(this);
- }
- render() {
- const widthClasses = {
- [CSS.container]: true,
- [CSS.widthAuto]: this.width === "auto",
- [CSS.widthHalf]: this.width === "half",
- [CSS.widthFull]: this.width === "full"
- };
- const buttonWidth = this.width === "auto" ? "auto" : "full";
- return (h("div", { class: widthClasses }, h("calcite-button", { appearance: this.appearance, color: this.color, disabled: this.disabled, "icon-end": this.primaryIconEnd ? this.primaryIconEnd : null, "icon-start": this.primaryIconStart ? this.primaryIconStart : null, iconFlipRtl: this.primaryIconFlipRtl ? this.primaryIconFlipRtl : null, label: this.primaryLabel, loading: this.loading, onClick: this.calciteSplitButtonPrimaryClickHandler, scale: this.scale, splitChild: "primary", type: "button", width: buttonWidth }, this.primaryText), h("div", { class: CSS.dividerContainer }, h("div", { class: CSS.divider })), h("calcite-dropdown", { active: this.active, disabled: this.disabled, onClick: this.calciteSplitButtonSecondaryClickHandler, overlayPositioning: this.overlayPositioning, placement: "bottom-end", scale: this.scale, width: this.scale }, h("calcite-button", { appearance: this.appearance, color: this.color, disabled: this.disabled, "icon-start": this.dropdownIcon, label: this.dropdownLabel, scale: this.scale, slot: "dropdown-trigger", splitChild: "secondary", type: "button" }), h("slot", null))));
- }
- get dropdownIcon() {
- return this.dropdownIconType === "chevron"
- ? "chevronDown"
- : this.dropdownIconType === "caret"
- ? "caretDown"
- : this.dropdownIconType === "ellipsis"
- ? "ellipsis"
- : "handle-vertical";
- }
- static get is() { return "calcite-split-button"; }
- static get encapsulation() { return "shadow"; }
- static get originalStyleUrls() {
- return {
- "$": ["split-button.scss"]
- };
- }
- static get styleUrls() {
- return {
- "$": ["split-button.css"]
- };
- }
- static get properties() {
- return {
- "appearance": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "ButtonAppearance",
- "resolved": "\"clear\" | \"minimal\" | \"outline\" | \"solid\" | \"transparent\"",
- "references": {
- "ButtonAppearance": {
- "location": "import",
- "path": "../button/interfaces"
- }
- }
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Specifies the appearance style of the component."
- },
- "attribute": "appearance",
- "reflect": true,
- "defaultValue": "\"solid\""
- },
- "color": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "ButtonColor",
- "resolved": "\"blue\" | \"inverse\" | \"neutral\" | \"red\"",
- "references": {
- "ButtonColor": {
- "location": "import",
- "path": "../button/interfaces"
- }
- }
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Specifies the color of the component."
- },
- "attribute": "color",
- "reflect": true,
- "defaultValue": "\"blue\""
- },
- "disabled": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "When `true`, interaction is prevented and the component is displayed with lower opacity."
- },
- "attribute": "disabled",
- "reflect": true,
- "defaultValue": "false"
- },
- "active": {
- "type": "boolean",
- "mutable": true,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [{
- "name": "internal",
- "text": undefined
- }],
- "text": "When `true`, the component is active."
- },
- "attribute": "active",
- "reflect": true,
- "defaultValue": "false"
- },
- "dropdownIconType": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "DropdownIconType",
- "resolved": "\"caret\" | \"chevron\" | \"ellipsis\" | \"overflow\"",
- "references": {
- "DropdownIconType": {
- "location": "import",
- "path": "../button/interfaces"
- }
- }
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Specifies the icon used for the dropdown menu."
- },
- "attribute": "dropdown-icon-type",
- "reflect": true,
- "defaultValue": "\"chevron\""
- },
- "dropdownLabel": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "Accessible name for the dropdown menu."
- },
- "attribute": "dropdown-label",
- "reflect": true
- },
- "loading": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "When `true`, a busy indicator is displayed on the primary button."
- },
- "attribute": "loading",
- "reflect": true,
- "defaultValue": "false"
- },
- "overlayPositioning": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "OverlayPositioning",
- "resolved": "\"absolute\" | \"fixed\"",
- "references": {
- "OverlayPositioning": {
- "location": "import",
- "path": "../../utils/floating-ui"
- }
- }
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Determines the type of positioning to use for the overlaid content.\n\nUsing `\"absolute\"` will work for most cases. The component will be positioned inside of overflowing parent containers and will affect the container's layout.\n\n`\"fixed\"` should be used to escape an overflowing parent container, or when the reference element's `position` CSS property is `\"fixed\"`."
- },
- "attribute": "overlay-positioning",
- "reflect": true,
- "defaultValue": "\"absolute\""
- },
- "primaryIconEnd": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "Specifies an icon to display at the end of the primary button."
- },
- "attribute": "primary-icon-end",
- "reflect": true
- },
- "primaryIconFlipRtl": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "FlipContext",
- "resolved": "\"both\" | \"end\" | \"start\"",
- "references": {
- "FlipContext": {
- "location": "import",
- "path": "../interfaces"
- }
- }
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "When `true`, the primary button icon will be flipped when the element direction is right-to-left (`\"rtl\"`)."
- },
- "attribute": "primary-icon-flip-rtl",
- "reflect": true
- },
- "primaryIconStart": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "Specifies an icon to display at the start of the primary button."
- },
- "attribute": "primary-icon-start",
- "reflect": true
- },
- "primaryLabel": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "Accessible name for the primary button."
- },
- "attribute": "primary-label",
- "reflect": true
- },
- "primaryText": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Text displayed in the primary button."
- },
- "attribute": "primary-text",
- "reflect": true
- },
- "scale": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "Scale",
- "resolved": "\"l\" | \"m\" | \"s\"",
- "references": {
- "Scale": {
- "location": "import",
- "path": "../interfaces"
- }
- }
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Specifies the size of the component."
- },
- "attribute": "scale",
- "reflect": true,
- "defaultValue": "\"m\""
- },
- "width": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "Width",
- "resolved": "\"auto\" | \"full\" | \"half\"",
- "references": {
- "Width": {
- "location": "import",
- "path": "../interfaces"
- }
- }
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Specifies the width of the component."
- },
- "attribute": "width",
- "reflect": true,
- "defaultValue": "\"auto\""
- }
- };
- }
- static get events() {
- return [{
- "method": "calciteSplitButtonPrimaryClick",
- "name": "calciteSplitButtonPrimaryClick",
- "bubbles": true,
- "cancelable": false,
- "composed": true,
- "docs": {
- "tags": [],
- "text": "Fires when the primary button is clicked.\n\n**Note:** The event payload is deprecated, use separate mouse event listeners to get info about click."
- },
- "complexType": {
- "original": "DeprecatedEventPayload",
- "resolved": "any",
- "references": {
- "DeprecatedEventPayload": {
- "location": "import",
- "path": "../interfaces"
- }
- }
- }
- }, {
- "method": "calciteSplitButtonSecondaryClick",
- "name": "calciteSplitButtonSecondaryClick",
- "bubbles": true,
- "cancelable": false,
- "composed": true,
- "docs": {
- "tags": [],
- "text": "Fires when the dropdown menu is clicked.\n\n**Note:** The event payload is deprecated, use separate mouse event listeners to get info about click."
- },
- "complexType": {
- "original": "DeprecatedEventPayload",
- "resolved": "any",
- "references": {
- "DeprecatedEventPayload": {
- "location": "import",
- "path": "../interfaces"
- }
- }
- }
- }];
- }
- static get elementRef() { return "el"; }
- static get watchers() {
- return [{
- "propName": "disabled",
- "methodName": "handleDisabledChange"
- }, {
- "propName": "active",
- "methodName": "activeHandler"
- }];
- }
- }
|