No Description

ons-list-header.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of';
  2. import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
  3. import _createClass from 'babel-runtime/helpers/createClass';
  4. import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
  5. import _inherits from 'babel-runtime/helpers/inherits';
  6. /*
  7. Copyright 2013-2015 ASIAL CORPORATION
  8. Licensed under the Apache License, Version 2.0 (the "License");
  9. you may not use this file except in compliance with the License.
  10. You may obtain a copy of the License at
  11. http://www.apache.org/licenses/LICENSE-2.0
  12. Unless required by applicable law or agreed to in writing, software
  13. distributed under the License is distributed on an "AS IS" BASIS,
  14. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. See the License for the specific language governing permissions and
  16. limitations under the License.
  17. */
  18. import onsElements from '../ons/elements';
  19. import util from '../ons/util';
  20. import autoStyle from '../ons/autostyle';
  21. import ModifierUtil from '../ons/internal/modifier-util';
  22. import BaseElement from './base/base-element';
  23. var defaultClassName = 'list-header';
  24. var scheme = { '': 'list-header--*' };
  25. /**
  26. * @element ons-list-header
  27. * @category list
  28. * @description
  29. * [en]Header element for list items. Must be put inside the `<ons-list>` component.[/en]
  30. * [ja]リスト要素に使用するヘッダー用コンポーネント。ons-listと共に使用します。[/ja]
  31. * @seealso ons-list
  32. * [en]The `<ons-list>` component[/en]
  33. * [ja]ons-listコンポーネント[/ja]
  34. * @seealso ons-list-item
  35. * [en]The `<ons-list-item>` component[/en]
  36. * [ja]ons-list-itemコンポーネント[/ja]
  37. * @codepen yxcCt
  38. * @tutorial vanilla/Reference/list
  39. * @modifier material
  40. * [en]Display a Material Design list header.[/en]
  41. * [ja][/ja]
  42. * @example
  43. * <ons-list>
  44. * <ons-list-header>Header Text</ons-list-header>
  45. * <ons-list-item>Item</ons-list-item>
  46. * <ons-list-item>Item</ons-list-item>
  47. * </ons-list>
  48. */
  49. var ListHeaderElement = function (_BaseElement) {
  50. _inherits(ListHeaderElement, _BaseElement);
  51. /**
  52. * @attribute modifier
  53. * @type {String}
  54. * @description
  55. * [en]The appearance of the list header.[/en]
  56. * [ja]ヘッダーの表現を指定します。[/ja]
  57. */
  58. function ListHeaderElement() {
  59. _classCallCheck(this, ListHeaderElement);
  60. var _this = _possibleConstructorReturn(this, (ListHeaderElement.__proto__ || _Object$getPrototypeOf(ListHeaderElement)).call(this));
  61. _this._compile();
  62. return _this;
  63. }
  64. _createClass(ListHeaderElement, [{
  65. key: '_compile',
  66. value: function _compile() {
  67. autoStyle.prepare(this);
  68. this.classList.add(defaultClassName);
  69. ModifierUtil.initModifier(this, scheme);
  70. }
  71. }, {
  72. key: 'attributeChangedCallback',
  73. value: function attributeChangedCallback(name, last, current) {
  74. switch (name) {
  75. case 'class':
  76. util.restoreClass(this, defaultClassName, scheme);
  77. break;
  78. case 'modifier':
  79. ModifierUtil.onModifierChanged(last, current, this, scheme);
  80. break;
  81. }
  82. }
  83. }], [{
  84. key: 'observedAttributes',
  85. get: function get() {
  86. return ['modifier', 'class'];
  87. }
  88. }]);
  89. return ListHeaderElement;
  90. }(BaseElement);
  91. export default ListHeaderElement;
  92. onsElements.ListHeader = ListHeaderElement;
  93. customElements.define('ons-list-header', ListHeaderElement);