123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549 |
- /*!
- * 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, Host } from "@stencil/core";
- import { getElementDir } from "../../utils/dom";
- import { CSS, ICONS, TEXT, SLOTS } from "./resources";
- import { SLOTS as PANEL_SLOTS } from "../panel/resources";
- import { updateHostInteraction } from "../../utils/interactive";
- /**
- * @slot - A slot for adding custom content.
- * @slot header-actions-start - A slot for adding actions or content to the start side of the header.
- * @slot header-actions-end - A slot for adding actions or content to the end side of the header.
- * @slot header-content - A slot for adding custom content to the header.
- * @slot header-menu-actions - A slot for adding an overflow menu with actions inside a `calcite-dropdown`.
- * @slot fab - A slot for adding a `calcite-fab` (floating action button) to perform an action.
- * @slot footer-actions - A slot for adding buttons to the footer.
- * @slot footer - A slot for adding custom content to the footer.
- */
- export class FlowItem {
- constructor() {
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /** When true, displays a close button in the trailing side of the header */
- this.closable = false;
- /** When true, flow-item will be hidden */
- this.closed = false;
- /**
- * When true, interaction is prevented and the component is displayed with lower opacity.
- */
- this.disabled = false;
- /**
- * When true, a busy indicator is displayed.
- */
- this.loading = false;
- /**
- * When true, the action menu items in the `header-menu-actions` slot are open.
- */
- this.menuOpen = false;
- /**
- * When true, displays a back button in the header.
- */
- this.showBackButton = false;
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- this.handlePanelScroll = (event) => {
- event.stopPropagation();
- this.calciteFlowItemScroll.emit();
- };
- this.handlePanelClose = (event) => {
- event.stopPropagation();
- this.calciteFlowItemClose.emit();
- };
- this.backButtonClick = () => {
- this.calciteFlowItemBackClick.emit();
- this.calciteFlowItemBack.emit();
- };
- this.setBackRef = (node) => {
- this.backButtonEl = node;
- };
- this.setContainerRef = (node) => {
- this.containerEl = node;
- };
- this.getBackLabel = () => {
- return this.intlBack || TEXT.back;
- };
- }
- //--------------------------------------------------------------------------
- //
- // Lifecycle
- //
- //--------------------------------------------------------------------------
- componentDidRender() {
- updateHostInteraction(this);
- }
- // --------------------------------------------------------------------------
- //
- // Methods
- //
- // --------------------------------------------------------------------------
- /**
- * Sets focus on the component.
- */
- async setFocus() {
- const { backButtonEl, containerEl } = this;
- if (backButtonEl) {
- backButtonEl.setFocus();
- return;
- }
- containerEl === null || containerEl === void 0 ? void 0 : containerEl.setFocus();
- }
- /**
- * Scrolls the component's content to a specified set of coordinates.
- *
- * @example
- * myCalciteFlowItem.scrollContentTo({
- * left: 0, // Specifies the number of pixels along the X axis to scroll the window or element.
- * top: 0, // Specifies the number of pixels along the Y axis to scroll the window or element
- * behavior: "auto" // Specifies whether the scrolling should animate smoothly (smooth), or happen instantly in a single jump (auto, the default value).
- * });
- * @param options
- */
- async scrollContentTo(options) {
- var _a;
- await ((_a = this.containerEl) === null || _a === void 0 ? void 0 : _a.scrollContentTo(options));
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- renderBackButton() {
- const { el } = this;
- const rtl = getElementDir(el) === "rtl";
- const { showBackButton, backButtonClick } = this;
- const label = this.getBackLabel();
- const icon = rtl ? ICONS.backRight : ICONS.backLeft;
- return showBackButton ? (h("calcite-action", { "aria-label": label, class: CSS.backButton, icon: icon, key: "flow-back-button", onClick: backButtonClick, ref: this.setBackRef, scale: "s", slot: "header-actions-start", text: label })) : null;
- }
- render() {
- const { closable, closed, description, disabled, heading, headingLevel, heightScale, intlBack, intlClose, intlOptions, loading, menuOpen, widthScale, backButtonEl } = this;
- const label = this.getBackLabel();
- return (h(Host, null, h("calcite-panel", { closable: closable, closed: closed, description: description, disabled: disabled, heading: heading, headingLevel: headingLevel, heightScale: heightScale, intlBack: intlBack, intlClose: intlClose, intlOptions: intlOptions, loading: loading, menuOpen: menuOpen, onCalcitePanelClose: this.handlePanelClose, onCalcitePanelScroll: this.handlePanelScroll, ref: this.setContainerRef, widthScale: widthScale }, this.renderBackButton(), h("slot", { name: SLOTS.headerActionsStart, slot: PANEL_SLOTS.headerActionsStart }), h("slot", { name: SLOTS.headerActionsEnd, slot: PANEL_SLOTS.headerActionsEnd }), h("slot", { name: SLOTS.headerContent, slot: PANEL_SLOTS.headerContent }), h("slot", { name: SLOTS.headerMenuActions, slot: PANEL_SLOTS.headerMenuActions }), h("slot", { name: SLOTS.fab, slot: PANEL_SLOTS.fab }), h("slot", { name: SLOTS.footerActions, slot: PANEL_SLOTS.footerActions }), h("slot", { name: SLOTS.footer, slot: PANEL_SLOTS.footer }), h("slot", null)), backButtonEl ? (h("calcite-tooltip", { label: label, placement: "auto", referenceElement: backButtonEl }, label)) : null));
- }
- static get is() { return "calcite-flow-item"; }
- static get encapsulation() { return "shadow"; }
- static get originalStyleUrls() {
- return {
- "$": ["flow-item.scss"]
- };
- }
- static get styleUrls() {
- return {
- "$": ["flow-item.css"]
- };
- }
- static get properties() {
- return {
- "closable": {
- "type": "boolean",
- "mutable": true,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "When true, displays a close button in the trailing side of the header"
- },
- "attribute": "closable",
- "reflect": true,
- "defaultValue": "false"
- },
- "closed": {
- "type": "boolean",
- "mutable": true,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "When true, flow-item will be hidden"
- },
- "attribute": "closed",
- "reflect": true,
- "defaultValue": "false"
- },
- "beforeBack": {
- "type": "unknown",
- "mutable": false,
- "complexType": {
- "original": "() => Promise<void>",
- "resolved": "() => Promise<void>",
- "references": {
- "Promise": {
- "location": "global"
- }
- }
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "When provided, this method will be called before it is removed from the parent flow."
- }
- },
- "description": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "A description for the component."
- },
- "attribute": "description",
- "reflect": false
- },
- "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"
- },
- "heading": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "The component header text."
- },
- "attribute": "heading",
- "reflect": false
- },
- "headingLevel": {
- "type": "number",
- "mutable": false,
- "complexType": {
- "original": "HeadingLevel",
- "resolved": "1 | 2 | 3 | 4 | 5 | 6",
- "references": {
- "HeadingLevel": {
- "location": "import",
- "path": "../functional/Heading"
- }
- }
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "Specifies the number at which section headings should start."
- },
- "attribute": "heading-level",
- "reflect": true
- },
- "heightScale": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "Scale",
- "resolved": "\"l\" | \"m\" | \"s\"",
- "references": {
- "Scale": {
- "location": "import",
- "path": "../interfaces"
- }
- }
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "Specifies the maximum height of the component."
- },
- "attribute": "height-scale",
- "reflect": true
- },
- "intlBack": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "Accessible name for the component's back button. The back button will only be shown when 'showBackButton' is true."
- },
- "attribute": "intl-back",
- "reflect": false
- },
- "intlClose": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "Accessible name for the component's close button. The close button will only be shown when 'dismissible' is true."
- },
- "attribute": "intl-close",
- "reflect": false
- },
- "intlOptions": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "string",
- "resolved": "string",
- "references": {}
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "Accessible name for the component's actions menu."
- },
- "attribute": "intl-options",
- "reflect": false
- },
- "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."
- },
- "attribute": "loading",
- "reflect": true,
- "defaultValue": "false"
- },
- "menuOpen": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "When true, the action menu items in the `header-menu-actions` slot are open."
- },
- "attribute": "menu-open",
- "reflect": true,
- "defaultValue": "false"
- },
- "showBackButton": {
- "type": "boolean",
- "mutable": false,
- "complexType": {
- "original": "boolean",
- "resolved": "boolean",
- "references": {}
- },
- "required": false,
- "optional": false,
- "docs": {
- "tags": [],
- "text": "When true, displays a back button in the header."
- },
- "attribute": "show-back-button",
- "reflect": true,
- "defaultValue": "false"
- },
- "widthScale": {
- "type": "string",
- "mutable": false,
- "complexType": {
- "original": "Scale",
- "resolved": "\"l\" | \"m\" | \"s\"",
- "references": {
- "Scale": {
- "location": "import",
- "path": "../interfaces"
- }
- }
- },
- "required": false,
- "optional": true,
- "docs": {
- "tags": [],
- "text": "Specifies the width of the component."
- },
- "attribute": "width-scale",
- "reflect": true
- }
- };
- }
- static get states() {
- return {
- "backButtonEl": {}
- };
- }
- static get events() {
- return [{
- "method": "calciteFlowItemBack",
- "name": "calciteFlowItemBack",
- "bubbles": true,
- "cancelable": false,
- "composed": true,
- "docs": {
- "tags": [],
- "text": "Fires when the back button is clicked."
- },
- "complexType": {
- "original": "void",
- "resolved": "void",
- "references": {}
- }
- }, {
- "method": "calciteFlowItemBackClick",
- "name": "calciteFlowItemBackClick",
- "bubbles": true,
- "cancelable": false,
- "composed": true,
- "docs": {
- "tags": [{
- "name": "deprecated",
- "text": "use calciteFlowItemBack instead."
- }],
- "text": "Fires when the back button is clicked."
- },
- "complexType": {
- "original": "void",
- "resolved": "void",
- "references": {}
- }
- }, {
- "method": "calciteFlowItemScroll",
- "name": "calciteFlowItemScroll",
- "bubbles": true,
- "cancelable": false,
- "composed": true,
- "docs": {
- "tags": [],
- "text": "Fires when the content is scrolled."
- },
- "complexType": {
- "original": "void",
- "resolved": "void",
- "references": {}
- }
- }, {
- "method": "calciteFlowItemClose",
- "name": "calciteFlowItemClose",
- "bubbles": true,
- "cancelable": false,
- "composed": true,
- "docs": {
- "tags": [],
- "text": "Fires when the close button is clicked."
- },
- "complexType": {
- "original": "void",
- "resolved": "void",
- "references": {}
- }
- }];
- }
- static get methods() {
- return {
- "setFocus": {
- "complexType": {
- "signature": "() => Promise<void>",
- "parameters": [],
- "references": {
- "Promise": {
- "location": "global"
- }
- },
- "return": "Promise<void>"
- },
- "docs": {
- "text": "Sets focus on the component.",
- "tags": []
- }
- },
- "scrollContentTo": {
- "complexType": {
- "signature": "(options?: ScrollToOptions) => Promise<void>",
- "parameters": [{
- "tags": [{
- "name": "param",
- "text": "options"
- }],
- "text": ""
- }],
- "references": {
- "Promise": {
- "location": "global"
- },
- "ScrollToOptions": {
- "location": "global"
- }
- },
- "return": "Promise<void>"
- },
- "docs": {
- "text": "Scrolls the component's content to a specified set of coordinates.",
- "tags": [{
- "name": "example",
- "text": "myCalciteFlowItem.scrollContentTo({\n left: 0, // Specifies the number of pixels along the X axis to scroll the window or element.\n top: 0, // Specifies the number of pixels along the Y axis to scroll the window or element\n behavior: \"auto\" // Specifies whether the scrolling should animate smoothly (smooth), or happen instantly in a single jump (auto, the default value).\n});"
- }, {
- "name": "param",
- "text": "options"
- }]
- }
- }
- };
- }
- static get elementRef() { return "el"; }
- }
|