All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.SegmentedButton.js.map Maven / Gradle / Ivy

The newest version!
{"version":3,"file":"SegmentedButton.js","sourceRoot":"","sources":["../src/SegmentedButton.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,UAAU,MAAM,4CAA4C,CAAC;AACpE,OAAO,aAAa,MAAM,0DAA0D,CAAC;AACrF,OAAO,QAAQ,MAAM,qDAAqD,CAAC;AAC3E,OAAO,KAAK,MAAM,kDAAkD,CAAC;AACrE,OAAO,IAAI,MAAM,iDAAiD,CAAC;AACnE,OAAO,cAAc,MAAM,yDAAyD,CAAC;AAErF,OAAO,SAAS,MAAM,sDAAsD,CAAC;AAE7E,OAAO,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AACvF,OAAO,EACN,OAAO,EACP,OAAO,GACP,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,gCAAgC,EAAE,gCAAgC,EAAE,MAAM,mCAAmC,CAAC;AACvH,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAC3D,OAAO,4BAA4B,MAAM,yCAAyC,CAAC;AAEnF,WAAW;AACX,OAAO,uBAAuB,MAAM,sDAAsD,CAAC;AAE3F,SAAS;AACT,OAAO,kBAAkB,MAAM,2CAA2C,CAAC;AAe3E;;;;;;;;;;;;;;;;;GAiBG;AAwBH,IAAM,eAAe,uBAArB,MAAM,eAAgB,SAAQ,UAAU;IAsCvC,MAAM,CAAC,KAAK,CAAC,QAAQ;QACpB,iBAAe,CAAC,UAAU,GAAG,MAAM,aAAa,CAAC,oBAAoB,CAAC,CAAC;IACxE,CAAC;IAED;QACC,KAAK,EAAE,CAAC;QAjCT;;;;;WAKG;QAEH,kBAAa,GAAsC,QAAQ,CAAC;QA4B3D,IAAI,CAAC,eAAe,GAAG,IAAI,cAAc,CAAC,IAAI,EAAE;YAC/C,gBAAgB,EAAE,GAAG,EAA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;YACvE,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;QACvB,CAAC,CAAC,CAAC;IACJ,CAAC;IAED,IAAI,eAAe;QAClB,OAAO,iBAAe,CAAC,UAAU,CAAC,OAAO,CAAC,gCAAgC,CAAC,CAAC;IAC7E,CAAC;IAED,IAAI,eAAe;QAClB,OAAO,iBAAe,CAAC,UAAU,CAAC,OAAO,CAAC,gCAAgC,CAAC,CAAC;IAC7E,CAAC;CACD,CAAA;AAnLA;IADC,QAAQ,EAAE;uDACa;AASxB;IADC,QAAQ,EAAE;sDACiD;AAW5D;IADC,IAAI,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,uBAAuB,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;8CACxC;AA5B/B,eAAe;IAvBpB,aAAa,CAAC;QACd,GAAG,EAAE,sBAAsB;QAC3B,aAAa,EAAE,IAAI;QACnB,QAAQ,EAAE,SAAS;QACnB,QAAQ,EAAE,uBAAuB;QACjC,MAAM,EAAE,kBAAkB;QAC1B,YAAY,EAAE,CAAC,mBAAmB,CAAC;KACnC,CAAC;IACF;;;;OAIG;;IACF,KAAK,CAA4C,kBAAkB,EAAE;QACrE,MAAM,EAAE;YACP;;;eAGG;YACH,aAAa,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;SAC9B;KACD,CAAC;GAEI,eAAe,CA2LpB;AAED,eAAe,CAAC,MAAM,EAAE,CAAC;AAEzB,eAAe,eAAe,CAAC","sourcesContent":["import UI5Element from \"@ui5/webcomponents-base/dist/UI5Element.js\";\nimport customElement from \"@ui5/webcomponents-base/dist/decorators/customElement.js\";\nimport property from \"@ui5/webcomponents-base/dist/decorators/property.js\";\nimport event from \"@ui5/webcomponents-base/dist/decorators/event.js\";\nimport slot from \"@ui5/webcomponents-base/dist/decorators/slot.js\";\nimport ItemNavigation from \"@ui5/webcomponents-base/dist/delegate/ItemNavigation.js\";\nimport type { ITabbable } from \"@ui5/webcomponents-base/dist/delegate/ItemNavigation.js\";\nimport litRender from \"@ui5/webcomponents-base/dist/renderer/LitRenderer.js\";\nimport type I18nBundle from \"@ui5/webcomponents-base/dist/i18nBundle.js\";\nimport { getI18nBundle } from \"@ui5/webcomponents-base/dist/i18nBundle.js\";\nimport { getScopedVarName } from \"@ui5/webcomponents-base/dist/CustomElementsScope.js\";\nimport {\n\tisSpace,\n\tisEnter,\n} from \"@ui5/webcomponents-base/dist/Keys.js\";\nimport { SEGMENTEDBUTTON_ARIA_DESCRIPTION, SEGMENTEDBUTTON_ARIA_DESCRIBEDBY } from \"./generated/i18n/i18n-defaults.js\";\nimport SegmentedButtonItem from \"./SegmentedButtonItem.js\";\nimport SegmentedButtonSelectionMode from \"./types/SegmentedButtonSelectionMode.js\";\n\n// Template\nimport SegmentedButtonTemplate from \"./generated/templates/SegmentedButtonTemplate.lit.js\";\n\n// Styles\nimport SegmentedButtonCss from \"./generated/themes/SegmentedButton.css.js\";\n\n/**\n * Interface for components that may be slotted inside `ui5-segmented-button` as items\n * @public\n */\ninterface ISegmentedButtonItem extends UI5Element, ITabbable {\n\tdisabled: boolean,\n\tselected: boolean,\n}\n\ntype SegmentedButtonSelectionChangeEventDetail = {\n\tselectedItems: Array,\n}\n\n/**\n * @class\n *\n * ### Overview\n *\n * The `ui5-segmented-button` shows a group of items. When the user clicks or taps\n * one of the items, it stays in a pressed state. It automatically resizes the items\n * to fit proportionally within the component. When no width is set, the component uses the available width.\n *\n *\n * ### ES6 Module Import\n *\n * `import \"@ui5/webcomponents/dist/SegmentedButton.js\";`\n * @constructor\n * @extends UI5Element\n * @since 1.0.0-rc.6\n * @public\n */\n@customElement({\n\ttag: \"ui5-segmented-button\",\n\tlanguageAware: true,\n\trenderer: litRender,\n\ttemplate: SegmentedButtonTemplate,\n\tstyles: SegmentedButtonCss,\n\tdependencies: [SegmentedButtonItem],\n})\n/**\n * Fired when the selected item changes.\n * @param {Array} selectedItems an array of selected items.\n * @public\n */\n@event(\"selection-change\", {\n\tdetail: {\n\t\t/**\n\t\t * @public\n\t\t * @since 1.14.0\n\t\t */\n\t\tselectedItems: { type: Array },\n\t},\n})\n\nclass SegmentedButton extends UI5Element {\n\t/**\n\t * Defines the accessible ARIA name of the component.\n\t * @default undefined\n\t * @public\n\t * @since 1.0.3\n\t */\n\t@property()\n\taccessibleName?: string;\n\n\t/**\n\t * Defines the component selection mode.\n\t * @default \"Single\"\n\t * @public\n\t * @since 1.14.0\n\t */\n\t@property()\n\tselectionMode: `${SegmentedButtonSelectionMode}` = \"Single\";\n\n\t/**\n\t * Defines the items of `ui5-segmented-button`.\n\t *\n\t * **Note:** Multiple items are allowed.\n\t *\n\t * **Note:** Use the `ui5-segmented-button-item` for the intended design.\n\t * @public\n\t */\n\t@slot({ type: HTMLElement, invalidateOnChildChange: true, \"default\": true })\n\titems!: Array;\n\n\tstatic i18nBundle: I18nBundle;\n\n\t_itemNavigation: ItemNavigation;\n\n\thasPreviouslyFocusedItem: boolean;\n\n\t_selectedItem?: ISegmentedButtonItem;\n\n\tstatic async onDefine() {\n\t\tSegmentedButton.i18nBundle = await getI18nBundle(\"@ui5/webcomponents\");\n\t}\n\n\tconstructor() {\n\t\tsuper();\n\n\t\tthis._itemNavigation = new ItemNavigation(this, {\n\t\t\tgetItemsCallback: () => this.navigatableItems,\n\t\t});\n\t\tthis.hasPreviouslyFocusedItem = false;\n\t}\n\n\tonBeforeRendering() {\n\t\tconst items = this.getSlottedNodes(\"items\");\n\n\t\titems.forEach((item, index, arr) => {\n\t\t\titem.posInSet = index + 1;\n\t\t\titem.sizeOfSet = arr.length;\n\t\t});\n\n\t\tthis.normalizeSelection();\n\n\t\tthis.style.setProperty(getScopedVarName(\"--_ui5_segmented_btn_items_count\"), `${items.length}`);\n\t}\n\n\tnormalizeSelection() {\n\t\tif (!this.items.length) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch (this.selectionMode) {\n\t\tcase SegmentedButtonSelectionMode.Single: {\n\t\t\tconst selectedItems = this.selectedItems;\n\t\t\tconst selectedItemIndex = this._selectedItem ? selectedItems.indexOf(this._selectedItem) : -1;\n\t\t\tif (this._selectedItem && selectedItems.length > 1) {\n\t\t\t\tselectedItems.splice(selectedItemIndex, 1);\n\t\t\t}\n\t\t\tconst selectedItem = selectedItems.pop() || this.items[0];\n\t\t\tthis._applySingleSelection(selectedItem);\n\t\t\tbreak;\n\t\t}\n\t\tdefault:\n\t\t}\n\t}\n\n\t_selectItem(e: MouseEvent | KeyboardEvent) {\n\t\tconst target = e.target as SegmentedButtonItem;\n\t\tconst isTargetSegmentedButtonItem = target.hasAttribute(\"ui5-segmented-button-item\");\n\n\t\tif (target.disabled || target === this.getDomRef() || !isTargetSegmentedButtonItem) {\n\t\t\treturn;\n\t\t}\n\n\t\tswitch (this.selectionMode) {\n\t\tcase SegmentedButtonSelectionMode.Multiple:\n\t\t\tif (e instanceof KeyboardEvent) {\n\t\t\t\ttarget.selected = !target.selected;\n\t\t\t}\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tthis._applySingleSelection(target);\n\t\t}\n\n\t\tthis.fireEvent(\"selection-change\", {\n\t\t\tselectedItems: this.selectedItems,\n\t\t});\n\n\t\tthis._itemNavigation.setCurrentItem(target);\n\n\t\treturn this;\n\t}\n\n\t_applySingleSelection(item: ISegmentedButtonItem) {\n\t\tthis.items.forEach(currentItem => {\n\t\t\tcurrentItem.selected = false;\n\t\t});\n\t\titem.selected = true;\n\t\tthis._selectedItem = item;\n\t}\n\n\t_onclick(e: MouseEvent) {\n\t\tthis._selectItem(e);\n\t}\n\n\t_onkeydown(e: KeyboardEvent) {\n\t\tif (isEnter(e)) {\n\t\t\tthis._selectItem(e);\n\t\t} else if (isSpace(e)) {\n\t\t\te.preventDefault();\n\t\t}\n\t}\n\n\t_onkeyup(e: KeyboardEvent) {\n\t\tif (isSpace(e)) {\n\t\t\tthis._selectItem(e);\n\t\t}\n\t}\n\n\t_onmousedown(e: MouseEvent) {\n\t\tconst eventTarget = e.target as SegmentedButtonItem;\n\t\tconst isTargetSegmentedButtonItem = eventTarget.hasAttribute(\"ui5-segmented-button-item\");\n\n\t\tif (isTargetSegmentedButtonItem) {\n\t\t\tthis._itemNavigation.setCurrentItem(eventTarget);\n\t\t\tthis.hasPreviouslyFocusedItem = true;\n\t\t}\n\t}\n\n\t_onfocusin(e: FocusEvent) {\n\t\t// If the component was previously focused,\n\t\t// update the ItemNavigation to sync the button's tabindex values\n\t\tif (this.hasPreviouslyFocusedItem) {\n\t\t\tthis._itemNavigation.setCurrentItem(e.target as SegmentedButtonItem);\n\t\t\treturn;\n\t\t}\n\n\t\t// If the component is focused for the first time\n\t\t// focus the selected item if such is present\n\t\tif (this.selectedItems.length) {\n\t\t\tthis._itemNavigation.setCurrentItem(this.selectedItems[0]);\n\t\t\tthis.selectedItems[0].focus();\n\t\t\tthis.hasPreviouslyFocusedItem = true;\n\t\t}\n\t}\n\n\t/**\n\t * Returns an array of the currently selected items.\n\t * @since 1.14.0\n\t * @public\n\t * @default []\n\t */\n\tget selectedItems(): Array {\n\t\treturn this.items.filter(item => item.selected);\n\t}\n\n\tget navigatableItems() {\n\t\treturn this.getSlottedNodes(\"items\").filter(item => {\n\t\t\treturn !item.disabled;\n\t\t});\n\t}\n\n\tget ariaDescribedBy() {\n\t\treturn SegmentedButton.i18nBundle.getText(SEGMENTEDBUTTON_ARIA_DESCRIBEDBY);\n\t}\n\n\tget ariaDescription() {\n\t\treturn SegmentedButton.i18nBundle.getText(SEGMENTEDBUTTON_ARIA_DESCRIPTION);\n\t}\n}\n\nSegmentedButton.define();\n\nexport default SegmentedButton;\nexport type {\n\tSegmentedButtonSelectionChangeEventDetail,\n\tISegmentedButtonItem,\n};\n"]}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy