UNPKG

@api-components/http-method-selector

Version:
115 lines (109 loc) 5.01 kB
<!-- @license Copyright 2017 The Advanced REST client authors <arc@mulesoft.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <link rel="import" href="../polymer/polymer.html"> <link rel="import" href="../paper-dropdown-menu/paper-dropdown-menu.html"> <link rel="import" href="../paper-listbox/paper-listbox.html"> <link rel="import" href="../paper-item/paper-item.html"> <link rel="import" href="../paper-input/paper-input.html"> <link rel="import" href="../paper-icon-button/paper-icon-button.html"> <link rel="import" href="../arc-icons/arc-icons.html"> <link rel="import" href="../events-target-behavior/events-target-behavior.html"> <link rel="import" href="http-method-selector-mixin.html"> <dom-module id="http-method-selector-mini"> <template> <style> :host { display: block; @apply --http-method-selector-mini; } paper-dropdown-menu { width: var(--http-method-selector-mini-dropdown-width, 100px); @apply --http-method-selector-mini-dropdown; } .custom-name { display: inline-block; width: var(--http-method-selector-mini-input-width, 100px); @apply --http-method-selector-mini-input; } #closeCustom { padding: 0; width: 24px; height: 24px; color: var(--from-row-action-icon-color, var(--icon-button-color, rgba(0, 0, 0, 0.74))); transition: color 0.2s linear; @apply --http-method-selector-custom-close-button; } #closeCustom:hover { color: var(--from-row-action-icon-color-hover, var(--accent-color, rgba(0, 0, 0, 0.74))); } [hidden] { display: none !important; } </style> <paper-dropdown-menu label="Method" opened="{{methodMenuOpened}}" hidden$="[[showCustom]]"> <paper-listbox slot="dropdown-content" selected="{{method}}" attr-for-selected="data-method"> <paper-item data-method="GET">GET</paper-item> <paper-item data-method="POST">POST</paper-item> <paper-item data-method="PUT">PUT</paper-item> <paper-item data-method="DELETE">DELETE</paper-item> <paper-item data-method="PATCH">PATCH</paper-item> <paper-item data-method="HEAD">HEAD</paper-item> <paper-item data-method="CONNECT">CONNECT</paper-item> <paper-item data-method="OPTIONS">OPTIONS</paper-item> <paper-item data-method="TRACE">TRACE</paper-item> <paper-item data-method="">Custom</paper-item> </paper-listbox> </paper-dropdown-menu> <paper-input class="custom-name" label="Method" required auto-validate inline hidden$="[[!showCustom]]" value="{{method}}"> <paper-icon-button slot="suffix" icon="arc:close" on-tap="closeCustom" title="Clear and opend standard dropdown"></paper-icon-button> </paper-input> </template> <script> /** * A HTTP method selector in a dropdown list of predefined HTTP methods. * * ### Example * * ```html * <http-method-selector-mini></http-method-selector-mini> * ``` * * ### Styling * * `<http-method-selector>` provides the following custom properties and mixins for styling: * * Custom property | Description | Default * ----------------|-------------|---------- * `--http-method-selector-mini` | Mixin applied to the element | `{}` * `--http-method-selector-mini-dropdown-width` | Width of the dropdown field | `100px` * `--http-method-selector-mini-input-width` | Width of the custom input field | `100px` * `--http-method-selector-mini-dropdown` | Mixin applied to the dropdown field | `{}` * `--http-method-selector-mini-input` | Mixin applied to the custom input field | `{}` * `--http-method-selector-custom-close-button` | Mixin applied to the custom input close button | `{}` * `--from-row-action-icon-color` | Theme variable, color of the custom input close button | `--icon-button-color` or `rgba(0, 0, 0, 0.74)` * `--from-row-action-icon-color-hover` | Theme variable, color of the custom input close button when hovering | `--accent-color` or `rgba(0, 0, 0, 0.74)` * * @customElement * @polymer * demo/mini.html * @memberof UiElements * @appliesMixin ArcBehaviors.EventsTargetBehavior * @appliesMixin ArcBehaviors.HttpMethodSelectorMixin */ class HttpMethodSelectorMini extends ArcBehaviors.HttpMethodSelectorMixin(ArcBehaviors.EventsTargetBehavior(Polymer.Element)) { static get is() { return 'http-method-selector-mini'; } } window.customElements.define(HttpMethodSelectorMini.is, HttpMethodSelectorMini); </script> </dom-module>