UI for Zipcoin Blue

item.js 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = Object.setPrototypeOf ||
  3. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  4. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5. return function (d, b) {
  6. extendStatics(d, b);
  7. function __() { this.constructor = d; }
  8. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9. };
  10. })();
  11. import { ChangeDetectionStrategy, Component, ContentChild, ContentChildren, ElementRef, Optional, Renderer, ViewChild, ViewEncapsulation } from '@angular/core';
  12. import { Button } from '../button/button';
  13. import { Config } from '../../config/config';
  14. import { Form } from '../../util/form';
  15. import { Icon } from '../icon/icon';
  16. import { Ion } from '../ion';
  17. import { Label } from '../label/label';
  18. import { ItemReorder } from './item-reorder';
  19. /**
  20. * @name Item
  21. * @description
  22. * An item can contain text, images, and anything else. Generally it is placed in a list with other
  23. * items. It can easily be swiped, deleted, reordered, edited, and more. An item is only required to
  24. * be in a [List](../../list/List) if manipulating the item via gestures is required. It requires an
  25. * [ItemSliding](../ItemSliding) wrapper element in order to be swiped.
  26. *
  27. *
  28. * ## Common Usage
  29. * There are a few elements that are considered items, but not all of them are styled to look the same.
  30. * The basic item can be written as an `<ion-item>` element or it can be added to any element by adding
  31. * `ion-item` as an attribute. List headers and item dividers, although styled differently, are also items
  32. * and can be written as `<ion-list-header>` and `<ion-item-divider>`, respectively.
  33. *
  34. * ### As an Element
  35. * A basic item should be written as a `<ion-item>` element when it is not clickable.
  36. *
  37. * ```html
  38. * <ion-item>
  39. * Item
  40. * </ion-item>
  41. * ```
  42. *
  43. * A list header should be written as `<ion-list-header>`.
  44. *
  45. * ```html
  46. * <ion-list-header>
  47. * List Header
  48. * </ion-list-header>
  49. * ```
  50. *
  51. * An item divider should be written as `<ion-item-divider>`.
  52. *
  53. * ```html
  54. * <ion-item-divider>
  55. * Item Divider
  56. * </ion-item-divider>
  57. * ```
  58. *
  59. * ### As an Attribute
  60. * The attribute `ion-item` should be added to a `<button>` when the item can be clicked or tapped. It
  61. * should be added to an `<a>` element when the item needs to contain a `href`. It can be added as an
  62. * attribute to any element to take on the item styling.
  63. *
  64. * ```html
  65. * <button ion-item (click)="buttonClick()">
  66. * Button Item
  67. * </button>
  68. *
  69. * <a ion-item href="https://www.ionicframework.com">
  70. * Anchor Item
  71. * </a>
  72. * ```
  73. *
  74. * Note: do not add `ion-item` as an attribute to an `<ion-list-header>` or `<ion-item-divider>` element
  75. * as they are already items and their styling will be changed to look like a basic item.
  76. *
  77. * ## Detail Arrows
  78. * By default, `<button>` and `<a>` elements with the `ion-item` attribute will display a right arrow icon
  79. * on `ios` mode. To hide the right arrow icon on either of these elements, add the `detail-none` attribute
  80. * to the item. To show the right arrow icon on an element that doesn't display it naturally, add the
  81. * `detail-push` attribute to the item.
  82. *
  83. * ```html
  84. * <ion-item detail-push>
  85. * Item with Detail Arrow
  86. * </ion-item>
  87. *
  88. * <button ion-item (click)="buttonClick()">
  89. * Button Item with Detail Arrow
  90. * </button>
  91. *
  92. * <a ion-item detail-none href="https://www.ionicframework.com">
  93. * Anchor Item with no Detail Arrow
  94. * </a>
  95. * ```
  96. *
  97. * This feature is not enabled by default for `md` and `wp` modes, but it can be enabled by setting the
  98. * Sass variables `$item-md-detail-push-show` and `$item-wp-detail-push-show`, respectively, to `true`.
  99. * It can also be disabled for ios by setting `$item-ios-detail-push-show` to `false`. See the
  100. * [theming documentation](http://ionicframework.com/docs/theming/overriding-ionic-variables/) for
  101. * more information on overriding Sass variables.
  102. *
  103. *
  104. * ## Item Placement
  105. * Items rely heavily on content projection to position content. The item grabs content based on the
  106. * element or attribute and positions it that way. This logic makes it possible to write a complex
  107. * item with simple, understandable markup without having to worry about styling and positioning
  108. * the elements.
  109. *
  110. * The below chart details the attributes item looks for and where it will place the element with
  111. * that attribute inside of the item:
  112. *
  113. * | Attribute | Description |
  114. * |----------------|----------------------------------------------------------------------------------------------------- |
  115. * | `item-start` | Placed to the left of all other elements, outside of the inner item. |
  116. * | `item-end` | Placed to the right of all other elements, inside of the inner item, outside of the input wrapper. |
  117. * | `item-content` | Placed to the right of any `ion-label`, inside of the input wrapper. |
  118. *
  119. * ### Checkboxes, Radios and Toggles
  120. * [Checkboxes](../../checkbox/Checkbox) are positioned in the same place as the `item-start` attribute.
  121. * [Radios](../../radio/RadioButton) and [Toggles](../../toggle/Toggle) are positioned in the same place
  122. * as the `item-end` attribute. All of these components can be positioned differently by adding the
  123. * `item-start` or `item-end` attribute.
  124. *
  125. * ### Content and Inputs
  126. * A [Label](../../label/Label) is placed inside of the item to the left of all content and inputs. The
  127. * following components are all placed in the same position as the `item-content` attribute: [Select](../../select/Select),
  128. * [Input](../../input/Input), [TextArea](../../input/TextArea), [DateTime](../../datetime/DateTime), and
  129. * [Range](../../range/Range).
  130. *
  131. * Any element directly placed inside of an `<ion-item>` that does not have one of the previously mentioned
  132. * attributes and isn't one of the above elements will be placed inside of a [Label](../../label/Label).
  133. *
  134. * ### Text Alignment
  135. * By default, Items will align text to the left and add an ellipsis when the text is wider than the item.
  136. * See the [Utility Attributes Documentation](../../../../theming/css-utilities/) for attributes that can
  137. * be added to `ion-item` to transform the text.
  138. *
  139. * @usage
  140. *
  141. * ```html
  142. * <ion-list>
  143. *
  144. * <ion-list-header>
  145. * Header
  146. * </ion-list-header>
  147. *
  148. * <ion-item>
  149. * Item
  150. * </ion-item>
  151. *
  152. * <ion-item detail-push>
  153. * Item with Detail Arrow
  154. * </ion-item>
  155. *
  156. * <button ion-item (click)="buttonClick()">
  157. * Button Item
  158. * </button>
  159. *
  160. * <ion-item-divider>
  161. * Item Divider
  162. * </ion-item-divider>
  163. *
  164. * <button ion-item detail-none (click)="buttonClick()">
  165. * Button Item with no Detail Arrow
  166. * </button>
  167. *
  168. * <a ion-item href="https://www.ionicframework.com">
  169. * Anchor Item
  170. * </a>
  171. *
  172. * <ion-item no-lines>
  173. * Item with no border
  174. * </ion-item>
  175. *
  176. * <ion-item text-wrap>
  177. * Multiline text that should wrap when it is too long
  178. * to fit on one line in the item.
  179. * </ion-item>
  180. *
  181. * </ion-list>
  182. * ```
  183. *
  184. *
  185. * @advanced
  186. *
  187. * ```html
  188. * <ion-list>
  189. *
  190. * <!-- List header with buttons on each side -->
  191. * <ion-list-header>
  192. * <button ion-button item-start (click)="buttonClick()">Button</button>
  193. * List Header
  194. * <button ion-button outline item-end (click)="buttonClick()">Outline</button>
  195. * </ion-list-header>
  196. *
  197. * <!-- Loops through and creates multiple items -->
  198. * <ion-item *ngFor="let item of items">
  199. * Item {% raw %}{{item}}{% endraw %}
  200. * </ion-item>
  201. *
  202. * <!-- Button item with an icon on the left -->
  203. * <button ion-item>
  204. * <ion-icon name="star" item-start></ion-icon>
  205. * Button Item
  206. * </button>
  207. *
  208. * <!-- Item with a label and content -->
  209. * <ion-item>
  210. * <ion-label>
  211. * Item Label
  212. * </ion-label>
  213. * <div item-content>
  214. * Item Content next to the label
  215. * </div>
  216. * </ion-item>
  217. *
  218. * <!-- Item with left and right buttons -->
  219. * <ion-item>
  220. * <button ion-button item-start (click)="buttonClick()">Button</button>
  221. * Item
  222. * <button ion-button outline item-end (click)="buttonClick()">Outline</button>
  223. * </ion-item>
  224. *
  225. * <!-- Item divider with a right button -->
  226. * <ion-item-divider>
  227. * Item Divider
  228. * <button ion-button item-end>Button</button>
  229. * </ion-item-divider>
  230. *
  231. * <!-- Disabled button item with left and right buttons -->
  232. * <button ion-item disabled>
  233. * <button ion-button item-start (click)="buttonClick()">
  234. * <ion-icon name="home"></ion-icon>
  235. * Left Icon
  236. * </button>
  237. * Disabled Button Item
  238. * <button ion-button outline item-end (click)="buttonClick()">
  239. * <ion-icon name="star"></ion-icon>
  240. * Left Icon
  241. * </button>
  242. * </button>
  243. *
  244. * <!-- Item with an avatar on the left and button on the right -->
  245. * <ion-item>
  246. * <ion-avatar item-start>
  247. * <img src="img/my-avatar.png">
  248. * </ion-avatar>
  249. * Avatar Item
  250. * <button ion-button outline item-end>View</button>
  251. * </ion-item>
  252. *
  253. * <!-- Item with a thumbnail on the right -->
  254. * <ion-item>
  255. * <h2>Item</h2>
  256. * <p>Item Paragraph</p>
  257. * <ion-thumbnail item-end>
  258. * <img src="img/my-thumbnail.png">
  259. * </ion-thumbnail>
  260. * </ion-item>
  261. *
  262. * <!-- Sliding item -->
  263. * <ion-item-sliding>
  264. * <ion-item>
  265. * Item
  266. * </ion-item>
  267. * <ion-item-options>
  268. * <button ion-button color="primary" (click)="archive()">Archive</button>
  269. * </ion-item-options>
  270. * </ion-item-sliding>
  271. *
  272. * </ion-list>
  273. * ```
  274. *
  275. *
  276. * @demo /docs/demos/src/item/
  277. * @see {@link /docs/components#lists List Component Docs}
  278. * @see {@link ../../list/List List API Docs}
  279. * @see {@link ../ItemSliding ItemSliding API Docs}
  280. */
  281. var Item = (function (_super) {
  282. __extends(Item, _super);
  283. function Item(form, config, elementRef, renderer, reorder) {
  284. var _this = _super.call(this, config, elementRef, renderer, 'item') || this;
  285. _this._ids = -1;
  286. _this._inputs = [];
  287. _this._viewLabel = true;
  288. _this._name = 'item';
  289. /**
  290. * @hidden
  291. */
  292. _this.labelId = null;
  293. _this._setName(elementRef);
  294. _this._hasReorder = !!reorder;
  295. _this.id = form.nextId().toString();
  296. _this.labelId = 'lbl-' + _this.id;
  297. // auto add "tappable" attribute to ion-item components that have a click listener
  298. if (!renderer.orgListen) {
  299. renderer.orgListen = renderer.listen;
  300. renderer.listen = function (renderElement, name, callback) {
  301. if (name === 'click' && renderElement.setAttribute) {
  302. renderElement.setAttribute('tappable', '');
  303. }
  304. return renderer.orgListen(renderElement, name, callback);
  305. };
  306. }
  307. return _this;
  308. }
  309. /**
  310. * @hidden
  311. */
  312. Item.prototype.registerInput = function (type) {
  313. this._inputs.push(type);
  314. return this.id + '-' + (++this._ids);
  315. };
  316. /**
  317. * @hidden
  318. */
  319. Item.prototype.ngAfterContentInit = function () {
  320. if (this._viewLabel && this._inputs.length) {
  321. var labelText = this.getLabelText().trim();
  322. this._viewLabel = (labelText.length > 0);
  323. }
  324. if (this._inputs.length > 1) {
  325. this.setElementClass('item-multiple-inputs', true);
  326. }
  327. };
  328. /**
  329. * @hidden
  330. */
  331. Item.prototype._updateColor = function (newColor, componentName) {
  332. componentName = componentName || 'item'; // item-radio
  333. this._setColor(newColor, componentName);
  334. };
  335. /**
  336. * @hidden
  337. */
  338. Item.prototype._setName = function (elementRef) {
  339. var nodeName = elementRef.nativeElement.nodeName.replace('ION-', '');
  340. if (nodeName === 'LIST-HEADER' || nodeName === 'ITEM-DIVIDER') {
  341. this._name = nodeName;
  342. }
  343. };
  344. /**
  345. * @hidden
  346. */
  347. Item.prototype.getLabelText = function () {
  348. return this._label ? this._label.text : '';
  349. };
  350. Object.defineProperty(Item.prototype, "contentLabel", {
  351. /**
  352. * @hidden
  353. */
  354. set: function (label) {
  355. if (label) {
  356. this._label = label;
  357. label.id = this.labelId;
  358. if (label.type) {
  359. this.setElementClass('item-label-' + label.type, true);
  360. }
  361. this._viewLabel = false;
  362. }
  363. },
  364. enumerable: true,
  365. configurable: true
  366. });
  367. Object.defineProperty(Item.prototype, "viewLabel", {
  368. /**
  369. * @hidden
  370. */
  371. set: function (label) {
  372. if (!this._label) {
  373. this._label = label;
  374. }
  375. },
  376. enumerable: true,
  377. configurable: true
  378. });
  379. Object.defineProperty(Item.prototype, "_buttons", {
  380. /**
  381. * @hidden
  382. */
  383. set: function (buttons) {
  384. buttons.forEach(function (button) {
  385. if (!button._size) {
  386. button.setElementClass('item-button', true);
  387. }
  388. });
  389. },
  390. enumerable: true,
  391. configurable: true
  392. });
  393. Object.defineProperty(Item.prototype, "_icons", {
  394. /**
  395. * @hidden
  396. */
  397. set: function (icons) {
  398. icons.forEach(function (icon) {
  399. icon.setElementClass('item-icon', true);
  400. });
  401. },
  402. enumerable: true,
  403. configurable: true
  404. });
  405. Item.decorators = [
  406. { type: Component, args: [{
  407. selector: 'ion-list-header,ion-item,[ion-item],ion-item-divider',
  408. template: '<ng-content select="[item-start],[item-left],ion-checkbox:not([item-end]):not([item-right])"></ng-content>' +
  409. '<div class="item-inner">' +
  410. '<div class="input-wrapper">' +
  411. '<ng-content select="ion-label"></ng-content>' +
  412. '<ion-label *ngIf="_viewLabel">' +
  413. '<ng-content></ng-content>' +
  414. '</ion-label>' +
  415. '<ng-content select="ion-select,ion-input,ion-textarea,ion-datetime,ion-range,[item-content]"></ng-content>' +
  416. '</div>' +
  417. '<ng-content select="[item-end],[item-right],ion-radio,ion-toggle"></ng-content>' +
  418. '<ion-reorder *ngIf="_hasReorder"></ion-reorder>' +
  419. '</div>' +
  420. '<div class="button-effect"></div>',
  421. host: {
  422. 'class': 'item'
  423. },
  424. changeDetection: ChangeDetectionStrategy.OnPush,
  425. encapsulation: ViewEncapsulation.None,
  426. },] },
  427. ];
  428. /** @nocollapse */
  429. Item.ctorParameters = function () { return [
  430. { type: Form, },
  431. { type: Config, },
  432. { type: ElementRef, },
  433. { type: Renderer, },
  434. { type: ItemReorder, decorators: [{ type: Optional },] },
  435. ]; };
  436. Item.propDecorators = {
  437. 'contentLabel': [{ type: ContentChild, args: [Label,] },],
  438. 'viewLabel': [{ type: ViewChild, args: [Label,] },],
  439. '_buttons': [{ type: ContentChildren, args: [Button,] },],
  440. '_icons': [{ type: ContentChildren, args: [Icon,] },],
  441. };
  442. return Item;
  443. }(Ion));
  444. export { Item };
  445. //# sourceMappingURL=item.js.map