luda 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/assets/javascripts/luda-degradation.js +10 -4
  3. data/assets/javascripts/luda-degradation.js.map +1 -1
  4. data/assets/javascripts/luda-degradation.min.js +2 -2
  5. data/assets/javascripts/luda-degradation.min.js.map +1 -1
  6. data/assets/javascripts/luda-sprockets.js +2 -0
  7. data/assets/javascripts/luda.js +4003 -2083
  8. data/assets/javascripts/luda.js.map +1 -1
  9. data/assets/javascripts/luda.min.js +2 -2
  10. data/assets/javascripts/luda.min.js.map +1 -1
  11. data/assets/javascripts/luda/behaviors/disabled.js +24 -0
  12. data/assets/javascripts/luda/behaviors/enter.js +24 -33
  13. data/assets/javascripts/luda/behaviors/focus.js +98 -95
  14. data/assets/javascripts/luda/behaviors/readonly.js +20 -58
  15. data/assets/javascripts/luda/behaviors/tabulate.js +42 -62
  16. data/assets/javascripts/luda/behaviors/toggle.js +98 -144
  17. data/assets/javascripts/luda/degradation.js +9 -3
  18. data/assets/javascripts/luda/elements/form-file.js +62 -109
  19. data/assets/javascripts/luda/elements/form-select.js +101 -208
  20. data/assets/javascripts/luda/index.js +4 -2
  21. data/assets/javascripts/luda/kernel/index.js +3095 -0
  22. data/assets/javascripts/luda/mixins/disable.js +34 -0
  23. data/assets/javascripts/luda/mixins/resetable.js +46 -0
  24. data/assets/javascripts/luda/mixins/tabable.js +274 -0
  25. data/assets/javascripts/luda/mixins/toggleable.js +185 -0
  26. data/assets/javascripts/luda/patterns/carousel.js +115 -333
  27. data/assets/javascripts/luda/patterns/dropdown.js +132 -271
  28. data/assets/javascripts/luda/patterns/form-dropdown.js +59 -104
  29. data/assets/javascripts/luda/patterns/tab.js +49 -150
  30. data/assets/stylesheets/luda/default/_banner.sass +1 -1
  31. data/assets/stylesheets/luda/default/_base.sass +1 -1
  32. data/assets/stylesheets/luda/default/_functions.sass +1 -1
  33. data/assets/stylesheets/luda/default/_mixins.sass +12 -12
  34. data/assets/stylesheets/luda/default/_variables.sass +747 -1
  35. data/assets/stylesheets/luda/default/behaviors/_disabled.sass +1 -1
  36. data/assets/stylesheets/luda/default/behaviors/_focus.sass +1 -1
  37. data/assets/stylesheets/luda/default/behaviors/_readonly.sass +1 -1
  38. data/assets/stylesheets/luda/default/behaviors/_toggle.sass +1 -1
  39. data/assets/stylesheets/luda/default/elements/_badge.sass +1 -1
  40. data/assets/stylesheets/luda/default/elements/_baseline.sass +1 -1
  41. data/assets/stylesheets/luda/default/elements/_button.sass +1 -1
  42. data/assets/stylesheets/luda/default/elements/_container.sass +1 -1
  43. data/assets/stylesheets/luda/default/elements/_grid.sass +1 -1
  44. data/assets/stylesheets/luda/default/elements/_icon.sass +1 -1
  45. data/assets/stylesheets/luda/default/elements/_media.sass +1 -1
  46. data/assets/stylesheets/luda/default/elements/_overlay.sass +1 -1
  47. data/assets/stylesheets/luda/default/elements/_progress.sass +1 -1
  48. data/assets/stylesheets/luda/default/elements/_scrollbar.sass +1 -1
  49. data/assets/stylesheets/luda/default/elements/_table.sass +1 -1
  50. data/assets/stylesheets/luda/default/elements/_turbolinks-progress-bar.sass +1 -1
  51. data/assets/stylesheets/luda/default/elements/form/_form-check-radio.sass +1 -1
  52. data/assets/stylesheets/luda/default/elements/form/_form-element.sass +1 -1
  53. data/assets/stylesheets/luda/default/elements/form/_form-helper.sass +1 -1
  54. data/assets/stylesheets/luda/default/elements/form/_form-label.sass +1 -1
  55. data/assets/stylesheets/luda/default/elements/form/_form-range.sass +1 -1
  56. data/assets/stylesheets/luda/default/elements/form/_form-row.sass +1 -1
  57. data/assets/stylesheets/luda/default/elements/typography/_code.sass +1 -1
  58. data/assets/stylesheets/luda/default/elements/typography/_heading.sass +1 -1
  59. data/assets/stylesheets/luda/default/elements/typography/_link.sass +1 -1
  60. data/assets/stylesheets/luda/default/elements/typography/_list.sass +1 -1
  61. data/assets/stylesheets/luda/default/elements/typography/_mark.sass +1 -1
  62. data/assets/stylesheets/luda/default/elements/typography/_paragraph.sass +1 -1
  63. data/assets/stylesheets/luda/default/elements/typography/_quote.sass +1 -1
  64. data/assets/stylesheets/luda/default/elements/typography/_sub-sup.sass +1 -1
  65. data/assets/stylesheets/luda/default/elements/typography/_typography.sass +1 -1
  66. data/assets/stylesheets/luda/default/patterns/_alert.sass +1 -1
  67. data/assets/stylesheets/luda/default/patterns/_article.sass +1 -1
  68. data/assets/stylesheets/luda/default/patterns/_avatar.sass +1 -1
  69. data/assets/stylesheets/luda/default/patterns/_breadcrumb.sass +1 -1
  70. data/assets/stylesheets/luda/default/patterns/_button-group.sass +1 -1
  71. data/assets/stylesheets/luda/default/patterns/_button-icon.sass +1 -1
  72. data/assets/stylesheets/luda/default/patterns/_carousel.sass +1 -1
  73. data/assets/stylesheets/luda/default/patterns/_dropdown.sass +1 -1
  74. data/assets/stylesheets/luda/default/patterns/_form-dropdown.sass +1 -1
  75. data/assets/stylesheets/luda/default/patterns/_form-group.sass +1 -1
  76. data/assets/stylesheets/luda/default/patterns/_form-icon.sass +1 -1
  77. data/assets/stylesheets/luda/default/patterns/_modal.sass +1 -1
  78. data/assets/stylesheets/luda/default/patterns/_navigation.sass +1 -1
  79. data/assets/stylesheets/luda/default/patterns/_search-bar.sass +1 -1
  80. data/assets/stylesheets/luda/default/patterns/_tab.sass +1 -1
  81. data/assets/stylesheets/luda/default/utilities/_alignment.sass +1 -1
  82. data/assets/stylesheets/luda/default/utilities/_background.sass +1 -1
  83. data/assets/stylesheets/luda/default/utilities/_border.sass +1 -1
  84. data/assets/stylesheets/luda/default/utilities/_color.sass +1 -1
  85. data/assets/stylesheets/luda/default/utilities/_display.sass +1 -1
  86. data/assets/stylesheets/luda/default/utilities/_flex.sass +1 -1
  87. data/assets/stylesheets/luda/default/utilities/_float.sass +1 -1
  88. data/assets/stylesheets/luda/default/utilities/_opacity.sass +1 -1
  89. data/assets/stylesheets/luda/default/utilities/_overflow.sass +1 -1
  90. data/assets/stylesheets/luda/default/utilities/_position.sass +1 -1
  91. data/assets/stylesheets/luda/default/utilities/_shadow.sass +1 -1
  92. data/assets/stylesheets/luda/default/utilities/_shape.sass +1 -1
  93. data/assets/stylesheets/luda/default/utilities/_size.sass +1 -1
  94. data/assets/stylesheets/luda/default/utilities/_spacing.sass +1 -1
  95. data/assets/stylesheets/luda/default/utilities/_text.sass +1 -1
  96. data/assets/stylesheets/luda/default/utilities/_visibility.sass +1 -1
  97. data/assets/stylesheets/luda/default/utilities/_z-index.sass +1 -1
  98. data/assets/stylesheets/luda/{_core → kernel}/_base.sass +1 -1
  99. data/assets/stylesheets/luda/{_core → kernel}/_functions.sass +23 -0
  100. data/assets/stylesheets/luda/kernel/behaviors/_disabled.sass +7 -0
  101. data/assets/stylesheets/luda/kernel/behaviors/_focus.sass +7 -0
  102. data/assets/stylesheets/luda/kernel/behaviors/_readonly.sass +7 -0
  103. data/assets/stylesheets/luda/kernel/behaviors/_toggle.sass +4 -0
  104. data/assets/stylesheets/luda/{_core → kernel}/elements/_badge.sass +1 -1
  105. data/assets/stylesheets/luda/{_core → kernel}/elements/_baseline.sass +1 -1
  106. data/assets/stylesheets/luda/{_core → kernel}/elements/_button.sass +1 -1
  107. data/assets/stylesheets/luda/{_core → kernel}/elements/_container.sass +1 -1
  108. data/assets/stylesheets/luda/{_core → kernel}/elements/_grid.sass +1 -1
  109. data/assets/stylesheets/luda/{_core → kernel}/elements/_icon.sass +1 -1
  110. data/assets/stylesheets/luda/{_core → kernel}/elements/_media.sass +1 -1
  111. data/assets/stylesheets/luda/{_core → kernel}/elements/_overlay.sass +1 -1
  112. data/assets/stylesheets/luda/{_core → kernel}/elements/_progress.sass +1 -1
  113. data/assets/stylesheets/luda/{_core → kernel}/elements/_scrollbar.sass +7 -1
  114. data/assets/stylesheets/luda/{_core → kernel}/elements/_table.sass +1 -1
  115. data/assets/stylesheets/luda/kernel/elements/_turbolinks-progress-bar.sass +5 -0
  116. data/assets/stylesheets/luda/{_core → kernel}/elements/form/_form-check-radio.sass +1 -1
  117. data/assets/stylesheets/luda/{_core → kernel}/elements/form/_form-element.sass +1 -1
  118. data/assets/stylesheets/luda/{_core → kernel}/elements/form/_form-helper.sass +1 -1
  119. data/assets/stylesheets/luda/{_core → kernel}/elements/form/_form-label.sass +1 -1
  120. data/assets/stylesheets/luda/{_core → kernel}/elements/form/_form-range.sass +1 -1
  121. data/assets/stylesheets/luda/{_core → kernel}/elements/form/_form-row.sass +13 -28
  122. data/assets/stylesheets/luda/{_core → kernel}/elements/typography/_code.sass +1 -1
  123. data/assets/stylesheets/luda/{_core → kernel}/elements/typography/_heading.sass +1 -1
  124. data/assets/stylesheets/luda/{_core → kernel}/elements/typography/_link.sass +1 -1
  125. data/assets/stylesheets/luda/{_core → kernel}/elements/typography/_list.sass +1 -1
  126. data/assets/stylesheets/luda/{_core → kernel}/elements/typography/_mark.sass +1 -1
  127. data/assets/stylesheets/luda/{_core → kernel}/elements/typography/_paragraph.sass +1 -1
  128. data/assets/stylesheets/luda/{_core → kernel}/elements/typography/_quote.sass +1 -1
  129. data/assets/stylesheets/luda/{_core → kernel}/elements/typography/_sub-sup.sass +1 -1
  130. data/assets/stylesheets/luda/kernel/elements/typography/_typography.sass +6 -0
  131. data/assets/stylesheets/luda/{_core → kernel}/mixins/_base.sass +0 -0
  132. data/assets/stylesheets/luda/{_core → kernel}/mixins/_browser.sass +0 -0
  133. data/assets/stylesheets/luda/{_core → kernel}/mixins/_button.sass +0 -0
  134. data/assets/stylesheets/luda/{_core → kernel}/mixins/_disabled.sass +1 -0
  135. data/assets/stylesheets/luda/{_core → kernel}/mixins/_dropdown.sass +0 -0
  136. data/assets/stylesheets/luda/{_core → kernel}/mixins/_focus.sass +0 -0
  137. data/assets/stylesheets/luda/{_core → kernel}/mixins/_form.sass +0 -0
  138. data/assets/stylesheets/luda/{_core → kernel}/mixins/_install.sass +0 -0
  139. data/assets/stylesheets/luda/{_core → kernel}/mixins/_media-query.sass +0 -0
  140. data/assets/stylesheets/luda/{_core → kernel}/mixins/_overlay.sass +0 -0
  141. data/assets/stylesheets/luda/{_core → kernel}/mixins/_sass-lint-fix.sass +0 -0
  142. data/assets/stylesheets/luda/{_core → kernel}/mixins/_typography.sass +0 -0
  143. data/assets/stylesheets/luda/{_core → kernel}/patterns/_alert.sass +1 -1
  144. data/assets/stylesheets/luda/{_core → kernel}/patterns/_article.sass +1 -1
  145. data/assets/stylesheets/luda/{_core → kernel}/patterns/_avatar.sass +1 -1
  146. data/assets/stylesheets/luda/{_core → kernel}/patterns/_breadcrumb.sass +1 -1
  147. data/assets/stylesheets/luda/{_core → kernel}/patterns/_button-group.sass +1 -1
  148. data/assets/stylesheets/luda/{_core → kernel}/patterns/_button-icon.sass +1 -1
  149. data/assets/stylesheets/luda/{_core → kernel}/patterns/_carousel.sass +2 -2
  150. data/assets/stylesheets/luda/{_core → kernel}/patterns/_dropdown.sass +1 -1
  151. data/assets/stylesheets/luda/{_core → kernel}/patterns/_form-dropdown.sass +6 -1
  152. data/assets/stylesheets/luda/{_core → kernel}/patterns/_form-group.sass +1 -1
  153. data/assets/stylesheets/luda/{_core → kernel}/patterns/_form-icon.sass +1 -1
  154. data/assets/stylesheets/luda/{_core → kernel}/patterns/_modal.sass +1 -1
  155. data/assets/stylesheets/luda/{_core → kernel}/patterns/_navigation.sass +1 -1
  156. data/assets/stylesheets/luda/{_core → kernel}/patterns/_search-bar.sass +1 -1
  157. data/assets/stylesheets/luda/{_core → kernel}/patterns/_tab.sass +1 -1
  158. data/assets/stylesheets/luda/{_core → kernel}/utilities/_alignment.sass +1 -1
  159. data/assets/stylesheets/luda/{_core → kernel}/utilities/_background.sass +1 -1
  160. data/assets/stylesheets/luda/{_core → kernel}/utilities/_border.sass +1 -1
  161. data/assets/stylesheets/luda/{_core → kernel}/utilities/_color.sass +1 -1
  162. data/assets/stylesheets/luda/{_core → kernel}/utilities/_display.sass +1 -1
  163. data/assets/stylesheets/luda/{_core → kernel}/utilities/_flex.sass +1 -1
  164. data/assets/stylesheets/luda/{_core → kernel}/utilities/_float.sass +1 -1
  165. data/assets/stylesheets/luda/{_core → kernel}/utilities/_opacity.sass +1 -1
  166. data/assets/stylesheets/luda/{_core → kernel}/utilities/_overflow.sass +1 -1
  167. data/assets/stylesheets/luda/{_core → kernel}/utilities/_position.sass +1 -1
  168. data/assets/stylesheets/luda/{_core → kernel}/utilities/_shadow.sass +1 -1
  169. data/assets/stylesheets/luda/{_core → kernel}/utilities/_shape.sass +1 -1
  170. data/assets/stylesheets/luda/{_core → kernel}/utilities/_size.sass +1 -1
  171. data/assets/stylesheets/luda/{_core → kernel}/utilities/_spacing.sass +1 -1
  172. data/assets/stylesheets/luda/{_core → kernel}/utilities/_text.sass +1 -1
  173. data/assets/stylesheets/luda/{_core → kernel}/utilities/_visibility.sass +1 -1
  174. data/assets/stylesheets/luda/{_core → kernel}/utilities/_z-index.sass +1 -1
  175. data/lib/luda/version.rb +1 -1
  176. metadata +86 -89
  177. data/assets/javascripts/luda/constants.js +0 -18
  178. data/assets/javascripts/luda/dom.js +0 -143
  179. data/assets/javascripts/luda/event.js +0 -201
  180. data/assets/javascripts/luda/factory.js +0 -334
  181. data/assets/javascripts/luda/install.js +0 -75
  182. data/assets/javascripts/luda/static.js +0 -224
  183. data/assets/javascripts/luda/utilities.js +0 -16
  184. data/assets/stylesheets/luda/_core/_variables.sass +0 -742
  185. data/assets/stylesheets/luda/_core/behaviors/_disabled.sass +0 -7
  186. data/assets/stylesheets/luda/_core/behaviors/_focus.sass +0 -7
  187. data/assets/stylesheets/luda/_core/behaviors/_readonly.sass +0 -14
  188. data/assets/stylesheets/luda/_core/behaviors/_toggle.sass +0 -4
  189. data/assets/stylesheets/luda/_core/elements/_turbolinks-progress-bar.sass +0 -5
  190. data/assets/stylesheets/luda/_core/elements/typography/_typography.sass +0 -6
@@ -1,216 +1,109 @@
1
- //= require ../install
2
- //= require ../dom
3
- //= require ../event
4
- //= require ../factory
1
+ //= require ../kernel/index
2
+ //= require ../mixins/resetable
5
3
  (function (global, factory) {
6
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../install.js'), require('../dom.js'), require('../event.js'), require('../factory.js')) :
7
- typeof define === 'function' && define.amd ? define(['../install.js', '../dom.js', '../event.js', '../factory.js'], factory) :
4
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../kernel/index.js'), require('../mixins/resetable.js')) :
5
+ typeof define === 'function' && define.amd ? define(['../kernel/index.js', '../mixins/resetable.js'], factory) :
8
6
  (factory());
9
7
  }(this, (function () { 'use strict';
10
8
 
11
- luda((function() {
12
- var _Class;
13
-
14
- _Class = class extends luda.Factory {
15
- select(indexOrIndexArray) {
16
- var selectedIndexes;
17
- if (this._$select.multiple) {
18
- if (this._$multipleSelectPlaceholder) {
19
- selectedIndexes = indexOrIndexArray;
20
- } else {
21
- selectedIndexes = indexOrIndexArray.map(function(index) {
22
- return index + 1;
23
- });
24
- }
25
- Array.from(this._$select.options).forEach(function($option, index) {
26
- return $option.selected = selectedIndexes.includes(index);
27
- });
28
- return this._markSelectedOption();
9
+ luda.component('fmSelect').protect({
10
+ selector: {
11
+ select: 'select',
12
+ options: 'option',
13
+ simulator: 'input'
14
+ },
15
+ data: {
16
+ default: 'data-fm-select_default-selected',
17
+ defaultMarked: 'data-fm-select_default-marked'
18
+ }
19
+ }).protect({
20
+ tryEmpty: function() {
21
+ var select, selected;
22
+ select = this.select.els[0];
23
+ selected = Array.from(select.options).some(function(o) {
24
+ return luda(o).hasAttr('selected');
25
+ });
26
+ return !selected && (select.selectedIndex = -1);
27
+ },
28
+ markSelected: function(markDefault) {
29
+ markDefault = markDefault === true;
30
+ if (markDefault && this.root.hasData(this.data.defaultMarked)) {
31
+ return;
32
+ }
33
+ if (markDefault) {
34
+ this.root.data(this.data.defaultMarked, '');
35
+ }
36
+ return Array.from(this.select.els[0].options).forEach((o) => {
37
+ var option, val;
38
+ option = luda(o);
39
+ if (markDefault) {
40
+ val = option.hasAttr('selected') ? '' : null;
41
+ return option.data(this.data.default, val);
29
42
  } else {
30
- this._$select.selectedIndex = indexOrIndexArray;
31
- this._setSingleSelectSimulatorValue();
32
- return this._markSelectedOption();
33
- }
34
- }
35
-
36
- _getConfig() {
37
- var _$defaultSelectedOptions, _$multipleSelectPlaceholder, _$select, _$singleSelectSimulator, _defaultSelectedOptionMarked;
38
- _$select = luda.$child(this.constructor._SELECT_SELECTOR, this._$component);
39
- _$singleSelectSimulator = luda.$child(this.constructor._SINGLE_SELECT_SIMULATOR_SELECTOR, this._$component);
40
- _$multipleSelectPlaceholder = luda.$child(`.${this.constructor._MULTIPLE_SELECT_PLACEHOLDER_CSS_CLASS}`, this._$component);
41
- _$defaultSelectedOptions = luda.$children(`[${this.constructor._DEFAULT_SELECTED_OPTION_ATTRIBUTE}]`, this._$component);
42
- _defaultSelectedOptionMarked = this._$component.hasAttribute(this.constructor._INITED_ATTRIBUTE);
43
- return {_$select, _$singleSelectSimulator, _$multipleSelectPlaceholder, _$defaultSelectedOptions, _defaultSelectedOptionMarked};
44
- }
45
-
46
- _constructor() {
47
- ({_$select: this._$select, _$singleSelectSimulator: this._$singleSelectSimulator, _$multipleSelectPlaceholder: this._$multipleSelectPlaceholder, _$defaultSelectedOptions: this._$defaultSelectedOptions, _defaultSelectedOptionMarked: this._defaultSelectedOptionMarked} = this._getConfig());
48
- if (this._$select) {
49
- if (this._$select.multiple) {
50
- return this._initMultipleSelect();
51
- } else {
52
- return this._initSingleSelect();
53
- }
54
- }
55
- }
56
-
57
- _onMutations() {
58
- return this._constructor();
59
- }
60
-
61
- _markSelectedOption() {
62
- if (this._observer) {
63
- this._disconnect();
64
- }
65
- Array.from(this._$select.options).forEach(function($option) {
66
- if ($option.selected) {
67
- return $option.setAttribute('selected', 'selected');
68
- } else {
69
- return $option.removeAttribute('selected');
70
- }
71
- });
72
- if (!this._observer) {
73
- return this._observe();
74
- }
75
- }
76
-
77
- _markDefaultSelectedOption() {
78
- this._$component.setAttribute(this.constructor._INITED_ATTRIBUTE, '');
79
- return Array.from(this._$select.options).forEach(($option) => {
80
- if ($option.selected) {
81
- return $option.setAttribute(this.constructor._DEFAULT_SELECTED_OPTION_ATTRIBUTE, '');
82
- }
83
- });
84
- }
85
-
86
- _setSingleSelectedDefaultSelectedOption() {
87
- var hasSelected;
88
- hasSelected = Array.from(this._$select.options).some(function($option) {
89
- return $option.getAttribute('selected') === 'selected';
90
- });
91
- if (!hasSelected) {
92
- return this._$select.selectedIndex = -1;
93
- }
94
- }
95
-
96
- _insertSingleSelectSimulator() {
97
- this._$singleSelectSimulator = document.createElement('input');
98
- this._$singleSelectSimulator.tabIndex = -1;
99
- return luda.$after(this._$singleSelectSimulator, this._$select);
100
- }
101
-
102
- _setSingleSelectPlaceholderValue() {
103
- return this._$singleSelectSimulator.placeholder = this._$select.getAttribute(this.constructor._PLACEHOLDER_ATTRIBUTE);
104
- }
105
-
106
- _setSingleSelectSimulatorValue() {
107
- var $selectedOption;
108
- if ($selectedOption = this._$select.options[this._$select.selectedIndex]) {
109
- return this._$singleSelectSimulator.value = $selectedOption.innerText;
110
- } else {
111
- return this._$singleSelectSimulator.value = '';
112
- }
113
- }
114
-
115
- _initSingleSelect() {
116
- if (!this._$singleSelectSimulator) {
117
- this._insertSingleSelectSimulator();
118
- }
119
- if (this._$select.hasAttribute(this.constructor._PLACEHOLDER_ATTRIBUTE)) {
120
- this._setSingleSelectedDefaultSelectedOption();
121
- this._setSingleSelectPlaceholderValue();
43
+ val = o.selected ? '' : null;
44
+ return option.attr('selected', val);
122
45
  }
123
- if (!this._defaultSelectedOptionMarked) {
124
- this._markDefaultSelectedOption();
125
- }
126
- this._setSingleSelectSimulatorValue();
127
- return this._markSelectedOption();
128
- }
129
-
130
- _insertMultipleSelectBlankOption() {
131
- this._$multipleSelectPlaceholder = document.createElement('option');
132
- this._$multipleSelectPlaceholder.className = this.constructor._MULTIPLE_SELECT_PLACEHOLDER_CSS_CLASS;
133
- this._$multipleSelectPlaceholder.disabled = true;
134
- return luda.$prepend(this._$multipleSelectPlaceholder, this._$select);
135
- }
136
-
137
- _setMultipleSelectPlaceholderValue() {
138
- return this._$multipleSelectPlaceholder.innerText = this._$select.getAttribute(this.constructor._PLACEHOLDER_ATTRIBUTE);
139
- }
140
-
141
- _initMultipleSelect() {
142
- if (!this._$multipleSelectPlaceholder) {
143
- if (this._$select.hasAttribute(this.constructor._PLACEHOLDER_ATTRIBUTE)) {
144
- this._insertMultipleSelectBlankOption();
145
- this._setMultipleSelectPlaceholderValue();
146
- }
147
- }
148
- if (!this._defaultSelectedOptionMarked) {
149
- return this._markDefaultSelectedOption();
150
- }
151
- }
152
-
153
- _reset() {
154
- if (this._$select) {
155
- Array.from(this._$select.options).forEach(($option) => {
156
- return $option.selected = this._$defaultSelectedOptions.includes($option);
157
- });
158
- if (!this._$select.multiple) {
159
- this._setSingleSelectSimulatorValue();
160
- }
161
- return this._markSelectedOption();
162
- }
163
- }
164
-
165
- static select($select, indexOrIndexArray) {
166
- return this.query($select).select(indexOrIndexArray);
167
- }
168
-
169
- static _init() {
170
- var self;
171
- self = this;
172
- luda.on('change', `${this._SELECTOR} ${this._SELECT_SELECTOR}`, function(e) {
173
- var instance;
174
- instance = self.query(luda.$parent(self._SELECTOR, this));
175
- if (!this.multiple) {
176
- instance._setSingleSelectSimulatorValue();
177
- }
178
- return instance._markSelectedOption();
179
- });
180
- return luda.on(luda._FORM_RESET, this._SELECTOR, function(e) {
181
- return setTimeout(() => {
182
- return self.query(this)._reset();
183
- });
184
- });
185
- }
186
-
187
- };
188
-
189
- _Class._SCOPE = 'fmSelect';
190
-
191
- _Class._SELECTOR = '.fm-select';
192
-
193
- _Class._SELECT_SELECTOR = 'select';
194
-
195
- _Class._SINGLE_SELECT_SIMULATOR_SELECTOR = 'input';
196
-
197
- _Class._PLACEHOLDER_ATTRIBUTE = 'placeholder';
198
-
199
- _Class._MULTIPLE_SELECT_PLACEHOLDER_CSS_CLASS = 'fm-select-multiple-placeholder';
200
-
201
- _Class._DEFAULT_SELECTED_OPTION_ATTRIBUTE = 'data-fm-select-default-selected';
202
-
203
- _Class._INITED_ATTRIBUTE = 'data-fm-select-inited';
204
-
205
- _Class._observerConfig = {
206
- childList: true,
207
- attributes: true,
208
- subtree: true,
209
- attributeFilter: ['selected']
210
- };
211
-
212
- return _Class;
213
-
214
- }).call(this));
46
+ });
47
+ },
48
+ initSimulator: function() {
49
+ var simulator;
50
+ if (this.select.els[0].multiple) {
51
+ return this.simulator.remove();
52
+ }
53
+ if (this.simulator.length) {
54
+ return;
55
+ }
56
+ simulator = luda('<input>');
57
+ simulator.els[0].tabIndex = -1;
58
+ simulator.insertAfter(this.select);
59
+ this.updatePlaceholder();
60
+ return this.updateValue();
61
+ },
62
+ updatePlaceholder: function() {
63
+ if (this.select.els[0].multiple) {
64
+ return;
65
+ }
66
+ return this.simulator.attr('placeholder', this.select.attr('placeholder'));
67
+ },
68
+ updateValue: function() {
69
+ var select, selected, val;
70
+ select = this.select.els[0];
71
+ if (select.multiple) {
72
+ return;
73
+ }
74
+ selected = select.options[select.selectedIndex];
75
+ val = selected ? luda(selected).text() : '';
76
+ return this.simulator.attr('value', val);
77
+ },
78
+ reset: function() {
79
+ this.select.els[0].selectedIndex = -1;
80
+ Array.from(this.select.els[0].options).forEach((o) => {
81
+ return o.selected = luda(o).hasData(this.data.default);
82
+ });
83
+ return this.markSelected();
84
+ }
85
+ }).help({
86
+ find: function() {
87
+ return {
88
+ select: this.selector.select,
89
+ simulator: this.selector.simulator
90
+ };
91
+ },
92
+ create: function() {
93
+ this.tryEmpty();
94
+ this.markSelected(true);
95
+ return this.initSimulator();
96
+ },
97
+ watch: function() {
98
+ return {
99
+ dom: [[this.selector.options, this.tryEmpty, this.updateValue]],
100
+ attr: [['selected', this.selector.options, this.updateValue], ['multiple', this.selector.select, this.initSimulator]]
101
+ };
102
+ },
103
+ listen: function() {
104
+ luda.mixin('resetable').get('listen').call(this, this.reset);
105
+ return [['change', this.selector.select, this.markSelected]];
106
+ }
107
+ });
215
108
 
216
109
  })));
@@ -1,3 +1,5 @@
1
+ //= require ./kernel/index
2
+ //= require ./behaviors/disabled
1
3
  //= require ./behaviors/enter
2
4
  //= require ./behaviors/focus
3
5
  //= require ./behaviors/readonly
@@ -10,8 +12,8 @@
10
12
  //= require ./patterns/form-dropdown
11
13
  //= require ./patterns/tab
12
14
  (function (global, factory) {
13
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('./behaviors/enter.js'), require('./behaviors/focus.js'), require('./behaviors/readonly.js'), require('./behaviors/tabulate.js'), require('./behaviors/toggle.js'), require('./elements/form-file.js'), require('./elements/form-select.js'), require('./patterns/carousel.js'), require('./patterns/dropdown.js'), require('./patterns/form-dropdown.js'), require('./patterns/tab.js')) :
14
- typeof define === 'function' && define.amd ? define(['./behaviors/enter.js', './behaviors/focus.js', './behaviors/readonly.js', './behaviors/tabulate.js', './behaviors/toggle.js', './elements/form-file.js', './elements/form-select.js', './patterns/carousel.js', './patterns/dropdown.js', './patterns/form-dropdown.js', './patterns/tab.js'], factory) :
15
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('./kernel/index.js'), require('./behaviors/disabled.js'), require('./behaviors/enter.js'), require('./behaviors/focus.js'), require('./behaviors/readonly.js'), require('./behaviors/tabulate.js'), require('./behaviors/toggle.js'), require('./elements/form-file.js'), require('./elements/form-select.js'), require('./patterns/carousel.js'), require('./patterns/dropdown.js'), require('./patterns/form-dropdown.js'), require('./patterns/tab.js')) :
16
+ typeof define === 'function' && define.amd ? define(['./kernel/index.js', './behaviors/disabled.js', './behaviors/enter.js', './behaviors/focus.js', './behaviors/readonly.js', './behaviors/tabulate.js', './behaviors/toggle.js', './elements/form-file.js', './elements/form-select.js', './patterns/carousel.js', './patterns/dropdown.js', './patterns/form-dropdown.js', './patterns/tab.js'], factory) :
15
17
  (factory());
16
18
  }(this, (function () { 'use strict';
17
19
 
@@ -0,0 +1,3095 @@
1
+ /*!
2
+ * Luda 0.3.0 | https://oatw.github.io/luda
3
+ * Copyright 2019 Oatw | https://oatw.blog
4
+ * MIT license | http://opensource.org/licenses/MIT
5
+ */
6
+ (function (global, factory) {
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
8
+ typeof define === 'function' && define.amd ? define(factory) :
9
+ (factory());
10
+ }(this, (function () { 'use strict';
11
+
12
+ var Type = {
13
+ isArray: Array.isArray,
14
+ isString: function(x) {
15
+ return typeof x === 'string';
16
+ },
17
+ isFunction: function(x) {
18
+ return typeof x === 'function';
19
+ },
20
+ isObject: function(x) {
21
+ return typeof x === 'object';
22
+ },
23
+ isBool: function(x) {
24
+ return typeof x === 'boolean';
25
+ },
26
+ isNumeric: function(x) {
27
+ return !isNaN(parseFloat(x)) && isFinite(x);
28
+ },
29
+ isDecimalism: function(x) {
30
+ return /^\d*\.?\d+$/.test(x && !/^0+\d+\.?/.test(x));
31
+ },
32
+ isId: function(x) {
33
+ return /^#[\w-]*$/.test(x);
34
+ },
35
+ isClass: function(x) {
36
+ return /^\.[\w-]*$/.test(x);
37
+ },
38
+ isTag: function(x) {
39
+ return /^\w+$/.test(x);
40
+ },
41
+ isSingleTag: function(x) {
42
+ return /^\s*<(\w+)\s*\/?>(?:<\/\1>)?\s*$/.test(x);
43
+ },
44
+ isHtml: function(x) {
45
+ return /<.+>/.test(x);
46
+ },
47
+ isScript: function(x) {
48
+ return x.tagName === 'SCRIPT' && /^$|^module$|\/(?:java|ecma)script/i.test(x.type);
49
+ },
50
+ isFragment: function(x) {
51
+ return /^\s*<(\w+)[^>]*>/.test(x);
52
+ },
53
+ isWindow: function(x) {
54
+ return x && x === window;
55
+ },
56
+ isDocument: function(x) {
57
+ return x && x.nodeType === 9;
58
+ },
59
+ isElement: function(x) {
60
+ return x && x.nodeType === 1;
61
+ }
62
+ };
63
+
64
+ function createMounter(target, messagePrefix, handler) {
65
+ var mount;
66
+ return mount = function(name, val) {
67
+ var msg, n, v;
68
+ if (Type.isString(name)) {
69
+ if (name in target) {
70
+ msg = `Namespace '${name}' is occupied, `;
71
+ msg += `skip ${messagePrefix || 'mounting'}.`;
72
+ console.warn(msg);
73
+ } else {
74
+ target[name] = handler ? handler(name, val) : val;
75
+ }
76
+ } else {
77
+ for (n in name) {
78
+ v = name[n];
79
+ mount(n, v);
80
+ }
81
+ }
82
+ return this;
83
+ };
84
+ }
85
+
86
+ var getEnv;
87
+
88
+ getEnv = function() {
89
+ if (typeof document !== 'undefined') {
90
+ if (typeof window !== 'undefined') {
91
+ return window;
92
+ }
93
+ if (typeof global !== 'undefined') {
94
+ return global;
95
+ }
96
+ }
97
+ throw new Error('Unsupported environment!');
98
+ };
99
+
100
+ var environment = getEnv();
101
+
102
+ function find(selector, ctx = document) {
103
+ if (!(Type.isDocument(ctx) || Type.isElement(ctx))) {
104
+ return [];
105
+ }
106
+ return Array.from((function() {
107
+ switch (false) {
108
+ case !Type.isClass(selector):
109
+ return ctx.getElementsByClassName(selector.slice(1));
110
+ case !Type.isTag(selector):
111
+ return ctx.getElementsByTagName(selector);
112
+ default:
113
+ // when Type.isId selector
114
+ // if el = ctx.getElementById selector.slice(1) then [el] else []
115
+ return ctx.querySelectorAll(selector);
116
+ }
117
+ })());
118
+ }
119
+
120
+ var containers, containersMap;
121
+
122
+ containersMap = null;
123
+
124
+ containers = function(type) {
125
+ var div, table, tr;
126
+ if (containersMap) {
127
+ return containersMap[type] || containersMap['*'];
128
+ }
129
+ div = document.createElement('div');
130
+ table = document.createElement('table');
131
+ tr = document.createElement('tr');
132
+ containersMap = {
133
+ '*': div,
134
+ thead: table,
135
+ tbody: table,
136
+ tfoot: table,
137
+ tr: document.createElement('tbody'),
138
+ th: tr,
139
+ td: tr
140
+ };
141
+ return containers(type);
142
+ };
143
+
144
+ function parseHTML(html) {
145
+ var container;
146
+ if (!Type.isString(html)) {
147
+ return [];
148
+ }
149
+ if (Type.isSingleTag(html)) {
150
+ return [document.createElement(RegExp.$1)];
151
+ }
152
+ container = containers(Type.isFragment(html && RegExp.$1));
153
+ container.innerHTML = html;
154
+ return Array.from(container.childNodes).map(function(node) {
155
+ if (node.parentNode) {
156
+ return node.parentNode.removeChild(node);
157
+ }
158
+ });
159
+ }
160
+
161
+ var Luda, luda;
162
+
163
+ Luda = class Luda {
164
+ constructor(selector, ctx = document) {
165
+ this.els = [];
166
+ this.length = 0;
167
+ if (!selector) {
168
+ return;
169
+ }
170
+ if (selector instanceof Luda) {
171
+ return selector;
172
+ }
173
+ this.els = (function() {
174
+ switch (false) {
175
+ case !Type.isString(selector):
176
+ if (Type.isHtml(selector)) {
177
+ return parseHTML(selector);
178
+ } else {
179
+ if (ctx instanceof Luda) {
180
+ ctx = ctx.els[0];
181
+ }
182
+ return find(selector, ctx);
183
+ }
184
+ break;
185
+ case !(selector.nodeType || Type.isWindow(selector)):
186
+ return [selector];
187
+ case !Type.isArray(selector):
188
+ return selector;
189
+ default:
190
+ return Array.from(selector);
191
+ }
192
+ })();
193
+ this.length = this.els.length;
194
+ }
195
+
196
+ };
197
+
198
+ if (!(luda = environment.luda)) {
199
+ environment.luda = luda = function(selector, ctx) {
200
+ return new Luda(selector, ctx);
201
+ };
202
+ luda.include = createMounter(Luda.prototype, 'including');
203
+ luda.extend = createMounter(luda, 'extending');
204
+ }
205
+
206
+ var ValuesMap = {
207
+ 'false': false,
208
+ 'true': true,
209
+ 'Infinity': 2e308,
210
+ 'NaN': 0/0,
211
+ 'null': void 0,
212
+ 'undefined': void 0
213
+ };
214
+
215
+ function readValue(value) {
216
+ if (value === null || value === 'null') {
217
+ return;
218
+ }
219
+ if (!Type.isString(value)) {
220
+ return value;
221
+ }
222
+ try {
223
+ return JSON.parse(value);
224
+ } catch (error) {
225
+ if (Type.isDecimalism(value)) {
226
+ return Number(value);
227
+ } else if (value in ValuesMap) {
228
+ return ValuesMap[value];
229
+ } else {
230
+ return value;
231
+ }
232
+ }
233
+ }
234
+
235
+ function parseValue(value) {
236
+ if (!Type.isObject(value)) {
237
+ return value;
238
+ }
239
+ try {
240
+ return JSON.stringify(value);
241
+ } catch (error) {
242
+ return value;
243
+ }
244
+ }
245
+
246
+ function splitValues(str) {
247
+ if (Type.isString(str)) {
248
+ return str.match(/\S+/g) || [];
249
+ } else {
250
+ return [];
251
+ }
252
+ }
253
+
254
+ luda.include({
255
+ each: function(callback) {
256
+ this.els.some(function(el, index) {
257
+ return callback.call(el, el, index) === false;
258
+ });
259
+ return this;
260
+ }
261
+ });
262
+
263
+ luda.include({
264
+ removeAttr: function(attr) {
265
+ var attrs;
266
+ attrs = splitValues(attr);
267
+ if (!attrs.length) {
268
+ return this;
269
+ }
270
+ this.els.forEach(function(el) {
271
+ return attrs.forEach(function(att) {
272
+ return el.removeAttribute(att);
273
+ });
274
+ });
275
+ return this;
276
+ }
277
+ });
278
+
279
+ luda.include({
280
+ attr: function(attr, value) {
281
+ var key, val;
282
+ if (!attr) {
283
+ return;
284
+ }
285
+ if (Type.isString(attr)) {
286
+ if (arguments.length >= 2) {
287
+ if (value === void 0) {
288
+ return this;
289
+ }
290
+ if (value === null) {
291
+ return this.removeAttr(attr);
292
+ }
293
+ this.els.forEach(function(el) {
294
+ return el.setAttribute(attr, parseValue(value));
295
+ });
296
+ return this;
297
+ }
298
+ if (!this.els[0]) {
299
+ return;
300
+ }
301
+ return readValue(this.els[0].getAttribute(attr));
302
+ }
303
+ for (key in attr) {
304
+ val = attr[key];
305
+ this.attr(key, val);
306
+ }
307
+ return this;
308
+ }
309
+ });
310
+
311
+ luda.include({
312
+ hasAttr: function(attr) {
313
+ if (!attr) {
314
+ return false;
315
+ }
316
+ return this.els.some(function(el) {
317
+ return el.hasAttribute(attr);
318
+ });
319
+ }
320
+ });
321
+
322
+ var pattern, replacer;
323
+
324
+ pattern = /-([a-z])/g;
325
+
326
+ replacer = function(match, letter) {
327
+ return letter.toUpperCase();
328
+ };
329
+
330
+ function camelCase(str) {
331
+ return str.replace(pattern, replacer);
332
+ }
333
+
334
+ var pattern$1, replacer$1;
335
+
336
+ pattern$1 = /([A-Z])/g;
337
+
338
+ replacer$1 = function(match, letter) {
339
+ return `-${letter.toLowerCase()}`;
340
+ };
341
+
342
+ function dashCase(str) {
343
+ return `${str[0].toLowerCase()}${str.slice(1).replace(pattern$1, replacer$1)}`;
344
+ }
345
+
346
+ var guid;
347
+
348
+ guid = 0;
349
+
350
+ function guid$1() {
351
+ return guid += 1;
352
+ }
353
+
354
+ function pluck(arr, prop, deep) {
355
+ var plucked;
356
+ plucked = [];
357
+ arr.forEach(function(item) {
358
+ var results, val;
359
+ val = item[prop];
360
+ results = [];
361
+ while (val !== null) {
362
+ plucked.push(val);
363
+ if (!deep) {
364
+ break;
365
+ }
366
+ results.push(val = val[prop]);
367
+ }
368
+ return results;
369
+ });
370
+ return plucked;
371
+ }
372
+
373
+ function unique(arr) {
374
+ if (!(arr.length > 1)) {
375
+ return arr;
376
+ }
377
+ return arr.filter(function(item, index) {
378
+ return arr.indexOf(item) === index;
379
+ });
380
+ }
381
+
382
+ ['isString', 'isFunction', 'isArray', 'isObject', 'isBool', 'isNumeric', 'isDecimalism', 'isElement'].forEach(function(key) {
383
+ return luda.extend(key, Type[key]);
384
+ });
385
+
386
+ luda.extend({
387
+ camelCase: camelCase,
388
+ dashCase: dashCase,
389
+ guid: guid$1,
390
+ pluck: pluck,
391
+ unique: unique
392
+ });
393
+
394
+ var _cache, cache, cacheFactory, privateCache, publicCache;
395
+
396
+ publicCache = {};
397
+
398
+ privateCache = {};
399
+
400
+ cacheFactory = function(cache) {
401
+ return function(guid, key, value) {
402
+ if (!guid) {
403
+ return cache;
404
+ }
405
+ if (key === null) {
406
+ return delete cache[guid];
407
+ } else if (value === null) {
408
+ if (!(guid in cache)) {
409
+ return;
410
+ }
411
+ delete cache[guid][key];
412
+ if (!Object.keys(cache[guid]).length) {
413
+ return delete cache[guid];
414
+ }
415
+ } else if (value === void 0) {
416
+ if (key === void 0) {
417
+ return cache[guid];
418
+ }
419
+ if (Type.isObject(key)) {
420
+ return cache[guid] = key;
421
+ }
422
+ if (!(guid in cache)) {
423
+ return;
424
+ }
425
+ return cache[guid][key];
426
+ } else {
427
+ if (key === void 0) {
428
+ return;
429
+ }
430
+ cache[guid] || (cache[guid] = {});
431
+ return cache[guid][key] = value;
432
+ }
433
+ };
434
+ };
435
+
436
+ cache = cacheFactory(publicCache);
437
+
438
+ _cache = cacheFactory(privateCache);
439
+
440
+ var expando = '__luda_guid';
441
+
442
+ var _access, access, accessFactory, clean;
443
+
444
+ accessFactory = function(c) {
445
+ return function(owner, key, value) {
446
+ var uid;
447
+ if (!arguments.length) {
448
+ return c();
449
+ }
450
+ uid = owner[expando] || (owner[expando] = guid$1());
451
+ return c(uid, key, value);
452
+ };
453
+ };
454
+
455
+ access = accessFactory(cache);
456
+
457
+ _access = accessFactory(_cache);
458
+
459
+ clean = function(owner) {
460
+ if (owner[expando]) {
461
+ _access(owner, null);
462
+ return access(owner, null);
463
+ }
464
+ };
465
+
466
+ luda.include({
467
+ removeCache: function(key) {
468
+ var keys;
469
+ if (arguments.length) {
470
+ keys = splitValues(key).map(function(k) {
471
+ return camelCase(k);
472
+ });
473
+ if (!keys.length) {
474
+ return this;
475
+ }
476
+ this.els.forEach(function(el) {
477
+ return keys.forEach(function(k) {
478
+ return access(el, k, null);
479
+ });
480
+ });
481
+ } else {
482
+ this.els.forEach(function(el) {
483
+ return access(el, null);
484
+ });
485
+ }
486
+ return this;
487
+ }
488
+ });
489
+
490
+ luda.extend({
491
+ cache: function(isPrivate) {
492
+ if (isPrivate) {
493
+ return _access();
494
+ } else {
495
+ return access();
496
+ }
497
+ }
498
+ });
499
+
500
+ luda.include({
501
+ cache: function(key, value) {
502
+ var k, v;
503
+ if (!key) {
504
+ if (!this.els[0]) {
505
+ return;
506
+ }
507
+ return access(this.els[0]) || access(this.els[0], {});
508
+ }
509
+ if (Type.isString(key)) {
510
+ key = camelCase(key);
511
+ if (arguments.length < 2) {
512
+ if (!this.els[0]) {
513
+ return;
514
+ }
515
+ if (!access(this.els[0])) {
516
+ access(this.els[0], {});
517
+ }
518
+ return access(this.els[0], key);
519
+ }
520
+ if (value === void 0) {
521
+ return this;
522
+ }
523
+ if (value === null) {
524
+ return this.removeCache(key);
525
+ }
526
+ this.els.forEach(function(el) {
527
+ if (!access(el)) {
528
+ access(el, {});
529
+ }
530
+ return access(el, key, value);
531
+ });
532
+ return this;
533
+ }
534
+ for (k in key) {
535
+ v = key[k];
536
+ this.cache(k, v);
537
+ }
538
+ return this;
539
+ }
540
+ });
541
+
542
+ var parse, pattern$2;
543
+
544
+ pattern$2 = /^\./;
545
+
546
+ parse = function(cls) {
547
+ if (Type.isString(cls)) {
548
+ return cls.replace(pattern$2, '');
549
+ } else {
550
+ return cls;
551
+ }
552
+ };
553
+
554
+ var parseClass = parse;
555
+
556
+ luda.include({
557
+ toggleClass: function(cls, force) {
558
+ var classes, isForce;
559
+ classes = splitValues(cls);
560
+ isForce = force !== void 0;
561
+ if (!classes.length) {
562
+ return this;
563
+ }
564
+ classes = classes.map(function(c) {
565
+ return parseClass(c);
566
+ });
567
+ this.els.forEach(function(el) {
568
+ return classes.forEach(function(c) {
569
+ if (isForce) {
570
+ if (force) {
571
+ return el.classList.add(c);
572
+ } else {
573
+ return el.classList.remove(c);
574
+ }
575
+ } else {
576
+ return el.classList.toggle(c);
577
+ }
578
+ });
579
+ });
580
+ return this;
581
+ }
582
+ });
583
+
584
+ luda.include({
585
+ addClass: function(cls) {
586
+ return this.toggleClass(cls, true);
587
+ }
588
+ });
589
+
590
+ luda.include({
591
+ hasClass: function(cls) {
592
+ if (!cls) {
593
+ return false;
594
+ }
595
+ cls = parseClass(cls);
596
+ return this.els.some(function(el) {
597
+ return el.classList.contains(cls);
598
+ });
599
+ }
600
+ });
601
+
602
+ luda.include({
603
+ removeClass: function(cls) {
604
+ if (arguments.length) {
605
+ return this.toggleClass(cls, false);
606
+ } else {
607
+ return this.attr('class', '');
608
+ }
609
+ }
610
+ });
611
+
612
+ luda.include({
613
+ add: function(selector, context) {
614
+ return luda(unique(this.els.concat(luda(selector, context).els)));
615
+ }
616
+ });
617
+
618
+ luda.include({
619
+ get: function(index) {
620
+ if (index === void 0) {
621
+ return this.els;
622
+ }
623
+ return this.els[index < 0 ? index + this.els.length : index];
624
+ }
625
+ });
626
+
627
+ luda.include({
628
+ eq: function(index) {
629
+ return luda(this.get(index));
630
+ }
631
+ });
632
+
633
+ function matches(el, selector) {
634
+ return el && el.matches && el.matches(selector);
635
+ }
636
+
637
+ function collect(els, comparator, oppsite) {
638
+ if (!comparator || !(els != null ? els.length : void 0)) {
639
+ return els;
640
+ }
641
+ return els.filter(function(el, index) {
642
+ var match;
643
+ match = (function() {
644
+ switch (false) {
645
+ case !Type.isString(comparator):
646
+ return matches(el, comparator);
647
+ case !Type.isFunction(comparator):
648
+ return comparator.call(el, el, index);
649
+ case !(comparator instanceof Luda):
650
+ return comparator.els.includes(el);
651
+ default:
652
+ return el === comparator;
653
+ }
654
+ })();
655
+ if (oppsite) {
656
+ return !match;
657
+ } else {
658
+ return match;
659
+ }
660
+ });
661
+ }
662
+
663
+ luda.include({
664
+ filter: function(comparator) {
665
+ if (!comparator) {
666
+ return luda();
667
+ }
668
+ return luda(collect(this.els, comparator));
669
+ }
670
+ });
671
+
672
+ luda.include({
673
+ first: function() {
674
+ return this.eq(0);
675
+ }
676
+ });
677
+
678
+ luda.include({
679
+ has: function(selector) {
680
+ var comparator;
681
+ if (Type.isString(selector)) {
682
+ comparator = function(el) {
683
+ return find(selector, el).length > 0;
684
+ };
685
+ } else {
686
+ comparator = function(el) {
687
+ return el.contains(selector);
688
+ };
689
+ }
690
+ return this.filter(comparator);
691
+ }
692
+ });
693
+
694
+ luda.include({
695
+ children: function(comparator) {
696
+ var all;
697
+ all = [];
698
+ this.els.forEach(function(el) {
699
+ return [].push.apply(all, el.children);
700
+ });
701
+ return luda(collect(unique(all), comparator));
702
+ }
703
+ });
704
+
705
+ luda.include({
706
+ parent: function(comparator) {
707
+ var parents;
708
+ if (!comparator) {
709
+ return luda(unique(pluck(this.els, 'parentNode')));
710
+ }
711
+ parents = [];
712
+ this.els.forEach(function(el) {
713
+ var matched, parent;
714
+ while (parent = el.parentNode) {
715
+ matched = collect([parent], comparator)[0];
716
+ if (matched) {
717
+ return parents.push(matched);
718
+ }
719
+ el = parent;
720
+ }
721
+ });
722
+ return luda(unique(parents));
723
+ }
724
+ });
725
+
726
+ luda.include({
727
+ index: function(selector) {
728
+ var child, collection;
729
+ child = selector ? luda(selector).els[0] : this.els[0];
730
+ collection = selector ? this.els : luda(child).parent().children().els;
731
+ return collection.indexOf(child);
732
+ }
733
+ });
734
+
735
+ luda.include({
736
+ is: function(comparator) {
737
+ if (!comparator || !this.els.length) {
738
+ return false;
739
+ }
740
+ return collect(this.els, comparator).length > 0;
741
+ }
742
+ });
743
+
744
+ luda.include({
745
+ last: function() {
746
+ return this.eq(-1);
747
+ }
748
+ });
749
+
750
+ luda.include({
751
+ map: function(callback) {
752
+ var collection;
753
+ collection = this.els.map(function(el, index) {
754
+ return callback.call(el, el, index);
755
+ });
756
+ return luda(collection);
757
+ }
758
+ });
759
+
760
+ luda.include({
761
+ not: function(comparator) {
762
+ if (!comparator || !this.els.length) {
763
+ return this;
764
+ }
765
+ return luda(collect(this.els, comparator, true));
766
+ }
767
+ });
768
+
769
+ luda.include({
770
+ slice: function() {
771
+ return luda([].slice.apply(this.els, arguments));
772
+ }
773
+ });
774
+
775
+ luda.extend({
776
+ ready: function(callback) {
777
+ var handler;
778
+ if (document.readyState === 'loading') {
779
+ handler = function() {
780
+ callback(luda);
781
+ return document.removeEventListener('DOMContentLoaded', handler);
782
+ };
783
+ document.addEventListener('DOMContentLoaded', handler);
784
+ } else {
785
+ handler = function() {
786
+ return callback(luda);
787
+ };
788
+ setTimeout(handler);
789
+ }
790
+ return this;
791
+ }
792
+ });
793
+
794
+ function findAll(selector, ctx) {
795
+ var all;
796
+ all = find(selector, ctx);
797
+ if (matches(ctx, selector)) {
798
+ all.push(ctx);
799
+ }
800
+ return all;
801
+ }
802
+
803
+ var Components, autoCreateAndDestroy, autoable, config, disAutoSelector, observer;
804
+
805
+ disAutoSelector = '[data-auto=false]';
806
+
807
+ Components = [];
808
+
809
+ observer = null;
810
+
811
+ config = {
812
+ childList: true,
813
+ subtree: true,
814
+ attributes: true
815
+ };
816
+
817
+ autoCreateAndDestroy = function(Component) {
818
+ if (Components.includes(Component)) {
819
+ return;
820
+ }
821
+ Components.push(Component);
822
+ if (observer) {
823
+ return;
824
+ }
825
+ observer = new MutationObserver(function(mus) {
826
+ var attrNodes, nodes;
827
+ nodes = [];
828
+ attrNodes = [];
829
+ mus.forEach(function(mu) {
830
+ nodes = nodes.concat(Array.from(mu.addedNodes)).concat(Array.from(mu.removedNodes));
831
+ if (mu.type === 'attributes') {
832
+ return attrNodes.push(mu.target);
833
+ }
834
+ });
835
+ nodes = unique(nodes);
836
+ attrNodes = unique(attrNodes);
837
+ return Components.forEach(function(C) {
838
+ var els;
839
+ els = [];
840
+ nodes.forEach(function(node) {
841
+ return els = els.concat(findAll(C.root, node));
842
+ });
843
+ unique(els).forEach(function(el) {
844
+ if (matches(el, disAutoSelector)) {
845
+ return;
846
+ }
847
+ if (document.contains(el)) {
848
+ return C.create(el);
849
+ } else {
850
+ return C.destroy(el);
851
+ }
852
+ });
853
+ return attrNodes.forEach(function(el) {
854
+ if (matches(el, disAutoSelector)) {
855
+ return;
856
+ }
857
+ if (matches(el, C.root)) {
858
+ return C.create(el);
859
+ } else if (C.instances[el[expando]]) {
860
+ return C.destroy(el);
861
+ }
862
+ });
863
+ });
864
+ });
865
+ observer.observe(document, config);
866
+ return _access(document, 'ComponentsAutomation', {
867
+ Components: Components,
868
+ watcher: observer
869
+ });
870
+ };
871
+
872
+ autoable = function(selector) {
873
+ return `${selector}:not(${disAutoSelector})`;
874
+ };
875
+
876
+ var print;
877
+
878
+ print = function(msg, style) {
879
+ if (Type.isString(msg)) {
880
+ return console.log(`%c${msg}`, style);
881
+ }
882
+ return console.log(msg);
883
+ };
884
+
885
+ var print$1 = print;
886
+
887
+ var active, factory, infoStyle, prvLabelStyle, pubLabelStyle;
888
+
889
+ active = false;
890
+
891
+ pubLabelStyle = 'color:#0085ff;font-weight:bold';
892
+
893
+ prvLabelStyle = 'color:#f8427f;font-weight:bold';
894
+
895
+ infoStyle = 'color:#383838;font-weight:bold';
896
+
897
+ factory = function(style, label) {
898
+ var log;
899
+ return log = function() {
900
+ var msg, time;
901
+ if (!arguments.length) {
902
+ return active;
903
+ }
904
+ if (arguments.length === 1 && Type.isBool(arguments[0])) {
905
+ active = arguments[0];
906
+ msg = `Luda log ${(active ? 'opened' : 'closed')}.`;
907
+ return log(msg);
908
+ }
909
+ if (!active) {
910
+ return;
911
+ }
912
+ time = Date.now();
913
+ print$1(`\n\n\n${label}LOG ${guid$1()} ${time}`, style.label);
914
+ return Array.from(arguments).forEach(function(arg) {
915
+ return print$1(arg, style.info);
916
+ });
917
+ };
918
+ };
919
+
920
+ luda.extend('log', factory({
921
+ info: infoStyle,
922
+ label: pubLabelStyle
923
+ }, ''));
924
+
925
+ var log = factory({
926
+ info: infoStyle,
927
+ label: prvLabelStyle
928
+ }, 'LUDA ');
929
+
930
+ function eventPath(event) {
931
+ if (event.composedPath) {
932
+ return event.composedPath();
933
+ } else if (event.path) {
934
+ return event.path;
935
+ } else {
936
+ return [event.target].concat(pluck([event.target], 'parentNode', true));
937
+ }
938
+ }
939
+
940
+ var LudaEvent;
941
+
942
+ LudaEvent = class LudaEvent {
943
+ constructor(event) {
944
+ this.originalEvent = event;
945
+ }
946
+
947
+ isDefaultPrevented() {
948
+ return this.originalEvent.defaultPrevented;
949
+ }
950
+
951
+ isPropagationStopped() {
952
+ return !this.originalEvent.bubbles || this._propagationStopped;
953
+ }
954
+
955
+ isImmediatePropagationStopped() {
956
+ return this._immediatePropagationStopped;
957
+ }
958
+
959
+ preventDefault() {
960
+ return this.originalEvent.preventDefault();
961
+ }
962
+
963
+ stopPropagation() {
964
+ this.originalEvent.stopPropagation();
965
+ return this._propagationStopped = true;
966
+ }
967
+
968
+ stopImmediatePropagation() {
969
+ this.originalEvent.stopImmediatePropagation();
970
+ return this._immediatePropagationStopped = true;
971
+ }
972
+
973
+ eventPath() {
974
+ return eventPath(this.originalEvent);
975
+ }
976
+
977
+ };
978
+
979
+ function ludaEvent(event) {
980
+ var ludaEvent;
981
+ ludaEvent = new LudaEvent(event);
982
+ return new Proxy(ludaEvent, {
983
+ get: function(target, key) {
984
+ if (key in target) {
985
+ return target[key];
986
+ } else {
987
+ return target.originalEvent[key];
988
+ }
989
+ }
990
+ });
991
+ }
992
+
993
+ function nMatches(definedNamespace, namespace) {
994
+ return namespace.every(function(n) {
995
+ return definedNamespace.includes(n);
996
+ });
997
+ }
998
+
999
+ var Variables = {
1000
+ expando: 'event',
1001
+ focusEvents: {
1002
+ focus: 'focusin',
1003
+ blur: 'focusout'
1004
+ },
1005
+ hoverEvents: {
1006
+ mouseenter: 'mouseover',
1007
+ mouseleave: 'mouseout'
1008
+ },
1009
+ swipeEvents: {
1010
+ left: 'swipeleft',
1011
+ right: 'swiperight',
1012
+ up: 'swipeup',
1013
+ down: 'swipedown'
1014
+ },
1015
+ swipeDistance: 10,
1016
+ keyCodes: {
1017
+ enter: 13,
1018
+ tab: 9,
1019
+ ctrl: 17,
1020
+ alt: 18,
1021
+ shift: 16,
1022
+ esc: 27,
1023
+ back: 8,
1024
+ space: 32,
1025
+ cap: 20,
1026
+ up: 38,
1027
+ down: 40,
1028
+ left: 37,
1029
+ right: 39,
1030
+ del: 46,
1031
+ end: 35,
1032
+ home: 36,
1033
+ ins: 45,
1034
+ pgUp: 33,
1035
+ pgDown: 34
1036
+ }
1037
+ };
1038
+
1039
+ function parseEventName(name) {
1040
+ var keysRe, preventRe, stopRe;
1041
+ stopRe = /(&stop)+/ig;
1042
+ preventRe = /(&prevent)+/ig;
1043
+ keysRe = new RegExp(`@(${Object.keys(Variables.keyCodes).join('|')})`, 'g');
1044
+ return splitValues(name).map(function(n) {
1045
+ var evtName, keyCodes, matchedKeys, preventDefault, splited, stopPropagation, type;
1046
+ stopPropagation = stopRe.test(n);
1047
+ preventDefault = preventRe.test(n);
1048
+ splited = n.replace(stopRe, '').replace(preventRe, '').replace(keysRe, '').split('.');
1049
+ evtName = splited[0];
1050
+ type = Variables.focusEvents[evtName] || Variables.hoverEvents[evtName] || evtName;
1051
+ keyCodes = [];
1052
+ matchedKeys = n.match(keysRe);
1053
+ matchedKeys && matchedKeys.forEach(function(key) {
1054
+ var k, keyCode;
1055
+ k = key.replace(/@/g, '');
1056
+ if (keyCode = Variables.keyCodes[k]) {
1057
+ return keyCodes.push(keyCode);
1058
+ }
1059
+ });
1060
+ return {
1061
+ type: type,
1062
+ stop: stopPropagation,
1063
+ prevent: preventDefault,
1064
+ namespace: splited.slice(1),
1065
+ key: keyCodes
1066
+ };
1067
+ });
1068
+ }
1069
+
1070
+ luda.include({
1071
+ trigger: function(name, detail, afterTrigger) {
1072
+ var handledEvts;
1073
+ if (afterTrigger && !Type.isFunction(afterTrigger)) {
1074
+ handledEvts = [];
1075
+ }
1076
+ this.els.forEach(function(el) {
1077
+ var events;
1078
+ if (Type.isString(name)) {
1079
+ events = parseEventName(name).map(function(evt) {
1080
+ var event;
1081
+ event = new CustomEvent(evt.type, {
1082
+ bubbles: true,
1083
+ cancelable: true,
1084
+ composed: true,
1085
+ detail: detail
1086
+ });
1087
+ event.namespace = evt.namespace;
1088
+ return event;
1089
+ });
1090
+ } else {
1091
+ events = Type.isArray(name) ? name : [name];
1092
+ }
1093
+ return events.forEach(function(e) {
1094
+ var isFocusEvent;
1095
+ e.ludaEvent = ludaEvent(e);
1096
+ isFocusEvent = Object.values(Variables.focusEvents).includes(e.type);
1097
+ if (isFocusEvent && Type.isFunction(el[e.type])) {
1098
+ el[e.type]();
1099
+ } else {
1100
+ el.dispatchEvent(e);
1101
+ }
1102
+ if (Type.isFunction(afterTrigger)) {
1103
+ return afterTrigger(e.ludaEvent, e.ludaEvent.detail, el);
1104
+ } else if (afterTrigger) {
1105
+ return handledEvts.push(e.ludaEvent);
1106
+ }
1107
+ });
1108
+ });
1109
+ return handledEvts || this;
1110
+ }
1111
+ });
1112
+
1113
+ var createEvent, startX, startY, touchMoveHandler, touchStartHandler, triggered;
1114
+
1115
+ startX = startY = 0/0;
1116
+
1117
+ triggered = false;
1118
+
1119
+ touchStartHandler = function(e) {
1120
+ if (e.defaultPrevented) {
1121
+ return;
1122
+ }
1123
+ if (e.touches.length !== 1) {
1124
+ return;
1125
+ }
1126
+ startX = e.touches[0].screenX;
1127
+ startY = e.touches[0].screenY;
1128
+ return triggered = false;
1129
+ };
1130
+
1131
+ touchMoveHandler = function(e) {
1132
+ var direction, endX, endY, xMoved, yMoved;
1133
+ if (e.defaultPrevented) {
1134
+ return;
1135
+ }
1136
+ if (e.touches.length !== 1) {
1137
+ return;
1138
+ }
1139
+ if (triggered) {
1140
+ return;
1141
+ }
1142
+ endX = e.touches[0].screenX;
1143
+ xMoved = endX - startX;
1144
+ if (Math.abs(xMoved) >= Variables.swipeDistance) {
1145
+ triggered = true;
1146
+ direction = xMoved > 0 ? 'right' : 'left';
1147
+ return luda(e.target).trigger(createEvent(direction, startX, endX, xMoved));
1148
+ }
1149
+ endY = e.touches[0].screenY;
1150
+ yMoved = endY - startY;
1151
+ if (Math.abs(yMoved) >= Variables.swipeDistance) {
1152
+ triggered = true;
1153
+ direction = yMoved > 0 ? 'down' : 'up';
1154
+ return luda(e.target).trigger(createEvent(direction, startY, endY, yMoved));
1155
+ }
1156
+ };
1157
+
1158
+ createEvent = function(direction, start, end, moved) {
1159
+ var event;
1160
+ event = new CustomEvent(Variables.swipeEvents[direction], {
1161
+ bubbles: true,
1162
+ cancelable: true,
1163
+ composed: true
1164
+ });
1165
+ event.start = start;
1166
+ event.end = end;
1167
+ event.distance = Math.abs(moved);
1168
+ return event;
1169
+ };
1170
+
1171
+ var swipeEvent = {
1172
+ add: function(el) {
1173
+ el.addEventListener('touchstart', touchStartHandler);
1174
+ return el.addEventListener('touchmove', touchMoveHandler);
1175
+ },
1176
+ remove: function(el) {
1177
+ el.removeEventListener('touchstart', touchStartHandler);
1178
+ return el.removeEventListener('touchmove', touchMoveHandler);
1179
+ }
1180
+ };
1181
+
1182
+ var removeEvent;
1183
+
1184
+ var removeEvent$1 = removeEvent = function(el, type, selector, callback, namespace) {
1185
+ var evtCache, length, swipeTypes, typeCache;
1186
+ evtCache = _access(el, Variables.expando);
1187
+ if (!evtCache) {
1188
+ return;
1189
+ }
1190
+ if (!type) {
1191
+ for (type in evtCache) {
1192
+ typeCache = evtCache[type];
1193
+ removeEvent(el, type, selector, callback, namespace);
1194
+ }
1195
+ } else if (type !== 'handler' && (typeCache = evtCache[type])) {
1196
+ typeCache.quene || (typeCache.quene = []);
1197
+ typeCache.quene = typeCache.quene.filter(function(item) {
1198
+ if (callback && callback !== item.callback) {
1199
+ return true;
1200
+ }
1201
+ if (selector && selector !== item.selector) {
1202
+ return true;
1203
+ }
1204
+ if (namespace && !nMatches(item.namespace, namespace)) {
1205
+ return true;
1206
+ }
1207
+ });
1208
+ if (!typeCache.quene.length && typeCache.binded && evtCache.handler) {
1209
+ el.removeEventListener(type, evtCache.handler);
1210
+ delete evtCache[type];
1211
+ }
1212
+ swipeTypes = Object.values(Variables.swipeEvents);
1213
+ if (swipeTypes.includes(type) && swipeTypes.every(function(t) {
1214
+ return !evtCache[t];
1215
+ })) {
1216
+ swipeEvent.remove(el);
1217
+ }
1218
+ }
1219
+ length = Object.keys(evtCache).length;
1220
+ if (!length || (length === 1 && 'handler' in evtCache)) {
1221
+ return _access(el, Variables.expando, null);
1222
+ }
1223
+ };
1224
+
1225
+ var addEvent;
1226
+
1227
+ addEvent = function(el, type, selector, callback, namespace, kc, stop, prevent, _one) {
1228
+ var evtCache, expando, handler, quene, swipeBinded, swipeTypes, typeCache;
1229
+ if (type === 'handler') {
1230
+ throw new Error('handler cannot be used as event type');
1231
+ }
1232
+ expando = Variables.expando;
1233
+ evtCache = _access(el, expando) || _access(el, expando, {});
1234
+ typeCache = evtCache[type] || (evtCache[type] = {});
1235
+ quene = typeCache.quene || (typeCache.quene = []);
1236
+ quene.push({
1237
+ selector: selector,
1238
+ callback: callback,
1239
+ namespace: namespace,
1240
+ key: kc,
1241
+ stop: stop,
1242
+ prevent: prevent,
1243
+ one: _one
1244
+ });
1245
+ handler = evtCache.handler || (evtCache.handler = function(event) {
1246
+ var cached, collection, eType, self;
1247
+ self = this;
1248
+ cached = _access(self, Variables.expando);
1249
+ eType = event.type;
1250
+ if (!(cached && cached[eType])) {
1251
+ return;
1252
+ }
1253
+ collection = eventPath(event);
1254
+ collection = collection.slice(0, collection.indexOf(self) + 1);
1255
+ event = event.ludaEvent || ludaEvent(event);
1256
+ // simulate event bubble behaviors
1257
+ // to make sure quene callbacks triggered from event.target to self
1258
+ return collection.every(function(node) {
1259
+ cached[eType].quene.every(function(it) {
1260
+ var returnValue;
1261
+ if (((selector = it.selector) && matches(node, selector)) || (!it.selector && node === self)) {
1262
+ if (event.namespace && !nMatches(it.namespace, event.namespace)) {
1263
+ return true;
1264
+ }
1265
+ if (event.keyCode && it.key.length && !it.key.includes(event.keyCode)) {
1266
+ return true;
1267
+ }
1268
+ event.currentTarget = node;
1269
+ returnValue = it.callback.call(node, event, event.detail);
1270
+ if (it.one) {
1271
+ removeEvent$1(self, eType, it.selector, it.callback, it.namespace);
1272
+ }
1273
+ if (it.stop || returnValue === false) {
1274
+ event.stopPropagation();
1275
+ }
1276
+ if (it.prevent || returnValue === false) {
1277
+ event.preventDefault();
1278
+ }
1279
+ }
1280
+ // make sure callbacks in front called but callbacks behind not called
1281
+ // if immediate propagation called
1282
+ return !event.isImmediatePropagationStopped();
1283
+ });
1284
+ // make sure same level callbacks called
1285
+ // but parents level callbacks not called if propagation stoped
1286
+ return !event.isPropagationStopped();
1287
+ });
1288
+ });
1289
+ swipeTypes = Object.values(Variables.swipeEvents);
1290
+ if (swipeTypes.includes(type)) {
1291
+ swipeBinded = swipeTypes.some(function(type) {
1292
+ var ref;
1293
+ return (ref = evtCache[type]) != null ? ref.binded : void 0;
1294
+ });
1295
+ if (!swipeBinded) {
1296
+ swipeEvent.add(el);
1297
+ }
1298
+ }
1299
+ if (!typeCache.binded) {
1300
+ typeCache.binded = true;
1301
+ return el.addEventListener(type, handler);
1302
+ }
1303
+ };
1304
+
1305
+ var addEvent$1 = addEvent;
1306
+
1307
+ luda.include({
1308
+ on: function(name, selector, callback, _one) {
1309
+ var key, keyCallback, self;
1310
+ self = this;
1311
+ if (!Type.isString(name)) {
1312
+ for (key in name) {
1313
+ keyCallback = name[key];
1314
+ this.on(key, selector, keyCallback);
1315
+ }
1316
+ return this;
1317
+ }
1318
+ if (Type.isFunction(selector)) {
1319
+ callback = selector;
1320
+ selector = '';
1321
+ }
1322
+ parseEventName(name).forEach(function(option) {
1323
+ return self.els.forEach(function(el) {
1324
+ return addEvent$1(el, option.type, selector, callback, option.namespace, option.key, option.stop, option.prevent, _one);
1325
+ });
1326
+ });
1327
+ return this;
1328
+ }
1329
+ });
1330
+
1331
+ luda.include({
1332
+ off: function(name, selector, callback) {
1333
+ var self;
1334
+ self = this;
1335
+ if (name === void 0) {
1336
+ this.els.forEach(function(el) {
1337
+ return removeEvent$1(el);
1338
+ });
1339
+ return this;
1340
+ }
1341
+ if (Type.isFunction(selector)) {
1342
+ callback = selector;
1343
+ selector = '';
1344
+ }
1345
+ parseEventName(name).forEach(function(option) {
1346
+ return self.els.forEach(function(el) {
1347
+ return removeEvent$1(el, option.type, selector, callback, option.namespace);
1348
+ });
1349
+ });
1350
+ return this;
1351
+ }
1352
+ });
1353
+
1354
+ var addEvents, findRoot, isntPropagation, namespace, removeEvents;
1355
+
1356
+ namespace = function(C) {
1357
+ return `.${C.id}`;
1358
+ };
1359
+
1360
+ findRoot = function(C, event) {
1361
+ var rootEl;
1362
+ if (Type.isDocument(C.root)) {
1363
+ return C.root;
1364
+ }
1365
+ rootEl = null;
1366
+ event.eventPath().some(function(el) {
1367
+ if (!matches(el, C.root)) {
1368
+ return;
1369
+ }
1370
+ return rootEl = el;
1371
+ });
1372
+ return rootEl;
1373
+ };
1374
+
1375
+ isntPropagation = function(C, event, rootEl) {
1376
+ if (Type.isDocument(C.root)) {
1377
+ return true;
1378
+ }
1379
+ if (event.currentTarget === rootEl) {
1380
+ return true;
1381
+ }
1382
+ return luda(event.currentTarget).parent(C.root).els[0] === rootEl;
1383
+ };
1384
+
1385
+ addEvents = function(C) {
1386
+ var events;
1387
+ events = C.helpers.listen.call(C.prototype);
1388
+ return events.forEach(function(evt) {
1389
+ var callbacks, evtSelector, name, selector;
1390
+ if (!evt[0]) {
1391
+ return;
1392
+ }
1393
+ name = `${evt[0]}${namespace(C)}`;
1394
+ selector = Type.isFunction(evt[1]) ? '' : evt[1];
1395
+ callbacks = Type.isFunction(evt[1]) ? evt.slice(1) : evt.slice(2);
1396
+ evtSelector = selector;
1397
+ return callbacks.forEach(function(callback) {
1398
+ var handler;
1399
+ if (!Type.isFunction(callback)) {
1400
+ return;
1401
+ }
1402
+ if (Object.values(C.prototype).includes(callback)) {
1403
+ if (Type.isString(C.root) && selector.replace(C.root, '') === selector) {
1404
+ evtSelector = selector ? `${C.root} ${selector}` : C.root;
1405
+ }
1406
+ handler = function(event, data) {
1407
+ var rootEl;
1408
+ if (!(rootEl = findRoot(C, event))) {
1409
+ return;
1410
+ }
1411
+ if (!isntPropagation(C, event, rootEl)) {
1412
+ return;
1413
+ }
1414
+ return callback.call(C.create(rootEl)[0], event, data);
1415
+ };
1416
+ } else {
1417
+ handler = function(event, data) {
1418
+ return callback.call(this, event, data);
1419
+ };
1420
+ }
1421
+ return luda(document).on(name, evtSelector, handler);
1422
+ });
1423
+ });
1424
+ };
1425
+
1426
+ removeEvents = function(C) {
1427
+ return luda(document).off(namespace(C));
1428
+ };
1429
+
1430
+ luda.include({
1431
+ parents: function(comparator) {
1432
+ return luda(collect(unique(pluck(this.els, 'parentElement', true)), comparator));
1433
+ }
1434
+ });
1435
+
1436
+ function unnested(instance, els) {
1437
+ var rootEl, rootSelector;
1438
+ rootEl = instance.root.els[0];
1439
+ rootSelector = instance.constructor.root;
1440
+ return els.filter(function(el) {
1441
+ var rootParent;
1442
+ if (el === rootEl) {
1443
+ return true;
1444
+ }
1445
+ if (matches(el, rootSelector)) {
1446
+ return false;
1447
+ }
1448
+ rootParent = luda(el).parent(rootSelector).els[0];
1449
+ if (document.contains(el)) {
1450
+ return rootParent === rootEl;
1451
+ } else {
1452
+ return !rootParent;
1453
+ }
1454
+ });
1455
+ }
1456
+
1457
+ var addTraversal, cleanTraversal, createGetter;
1458
+
1459
+ createGetter = function(C, name, selector, nestable, cacheable) {
1460
+ return Object.defineProperty(C.prototype, name, {
1461
+ get: function() {
1462
+ var cache, collection, matched, rootEl;
1463
+ if (!selector) {
1464
+ return luda();
1465
+ }
1466
+ if (selector instanceof Luda) {
1467
+ return selector;
1468
+ }
1469
+ if (Type.isFunction(selector)) {
1470
+ return selector.call(this);
1471
+ }
1472
+ if (!Type.isString(selector)) {
1473
+ return luda(selector);
1474
+ }
1475
+ if (!(rootEl = this.root.els[0])) {
1476
+ return luda();
1477
+ }
1478
+ cacheable && (cache = C.instances[this.id].traversal);
1479
+ if (cache && name in cache) {
1480
+ return cache[name];
1481
+ }
1482
+ matched = luda(selector, rootEl).els;
1483
+ !nestable && (matched = unnested(this, matched));
1484
+ collection = luda(unique(matched));
1485
+ if (!cache) {
1486
+ return collection;
1487
+ }
1488
+ if (collection.length) {
1489
+ return cache[name] = collection;
1490
+ } else {
1491
+ return collection;
1492
+ }
1493
+ }
1494
+ });
1495
+ };
1496
+
1497
+ addTraversal = function(C) {
1498
+ var cacheable, msg, name, nestable, selector, traversals;
1499
+ traversals = C.helpers.find.call(C.prototype);
1500
+ nestable = Type.isDocument(C.root);
1501
+ cacheable = Type.isString(C.root);
1502
+ for (name in traversals) {
1503
+ selector = traversals[name];
1504
+ if (name in C.prototype) {
1505
+ msg = `'${name}' was defined on prototype`;
1506
+ msg = `${msg}, skip adding traversal getter.`;
1507
+ console.warn(msg);
1508
+ } else {
1509
+ createGetter(C, name, selector, nestable, cacheable);
1510
+ }
1511
+ }
1512
+ return cacheable && (C.prototype.cleanTraversal = function(name) {
1513
+ var cached, traversal;
1514
+ if (!(cached = this.constructor.instances[this.id])) {
1515
+ return;
1516
+ }
1517
+ if (!(traversal = cached.traversal)) {
1518
+ return;
1519
+ }
1520
+ return cleanTraversal(traversal, name);
1521
+ });
1522
+ };
1523
+
1524
+ cleanTraversal = function(cache, name) {
1525
+ var names;
1526
+ if (!cache) {
1527
+ return;
1528
+ }
1529
+ if (!Type.isString(name)) {
1530
+ name = '';
1531
+ }
1532
+ names = name ? splitValues(name) : Object.keys(cache);
1533
+ return names.forEach(function(n) {
1534
+ return delete cache[n];
1535
+ });
1536
+ };
1537
+
1538
+ var config$1, createObserver, cur, executeMutations, findSameMutation, nodesEqual, runAttrCallbacks, runDomCallbacks, stopWatch, watch;
1539
+
1540
+ config$1 = {
1541
+ childList: true,
1542
+ subtree: true,
1543
+ attributes: true,
1544
+ attributeOldValue: true
1545
+ };
1546
+
1547
+ cur = function(ins, callback, target) {
1548
+ var isInProto, proto;
1549
+ proto = ins.constructor.prototype;
1550
+ isInProto = Object.values(proto).includes(callback);
1551
+ if (isInProto) {
1552
+ return ins;
1553
+ } else {
1554
+ return target;
1555
+ }
1556
+ };
1557
+
1558
+ runDomCallbacks = function(type, mutation, watches, nestable) {
1559
+ var C, ins, mu, nodes;
1560
+ ins = mutation.ins;
1561
+ C = ins.constructor;
1562
+ mu = mutation.mu;
1563
+ nodes = Array.from(mu[`${type}Nodes`]);
1564
+ return watches.dom.forEach(function(dom) {
1565
+ var els;
1566
+ els = [];
1567
+ nodes.forEach(function(n) {
1568
+ return els = els.concat(findAll(dom.selector, n));
1569
+ });
1570
+ if (!els.length) {
1571
+ return;
1572
+ }
1573
+ !nestable && (els = unnested(ins, unique(els)));
1574
+ return els.length && dom.callbacks.forEach(function(callback) {
1575
+ var ctx;
1576
+ ctx = cur(ins, callback, els);
1577
+ if (callback !== C.prototype.cleanTraversal) {
1578
+ log(`${C.id} ID: ${ins.id} executes nodes ${type} callback.`, 'Root element', ins.root.els[0], 'Cache', C.instances[ins.id], `Nodes ${type}`, els, `Callback ${callback.name || ''}`, callback, 'Context', ctx, 'Arguments', [els, type]);
1579
+ }
1580
+ return callback.call(ctx, els, type);
1581
+ });
1582
+ });
1583
+ };
1584
+
1585
+ runAttrCallbacks = function(mutation, watches, nestable) {
1586
+ var C, ins, mu, name, oldVal, target;
1587
+ ins = mutation.ins;
1588
+ mu = mutation.mu;
1589
+ C = ins.constructor;
1590
+ name = mu.attributeName;
1591
+ target = mu.target;
1592
+ oldVal = mu.oldValue;
1593
+ return name && watches.attr.forEach(function(attr) {
1594
+ if (name !== attr.name) {
1595
+ return;
1596
+ }
1597
+ if (!matches(target, attr.selector)) {
1598
+ return;
1599
+ }
1600
+ if (!nestable && !unnested(ins, [target]).length) {
1601
+ return;
1602
+ }
1603
+ return attr.callbacks.forEach(function(callback) {
1604
+ var ctx;
1605
+ ctx = cur(ins, callback, target);
1606
+ log(`${C.id} ID: ${ins.id} executes ${name} changed callback.`, 'Root element', ins.root.els[0], 'Cache', C.instances[ins.id], 'Changed target', target, `Callback ${callback.name || ''}`, callback, 'Context', ctx, 'Arguments', [target, oldVal]);
1607
+ return callback.call(ctx, target, oldVal);
1608
+ });
1609
+ });
1610
+ };
1611
+
1612
+ executeMutations = function(C, mutations, nestable) {
1613
+ return mutations.forEach(function(mutation) {
1614
+ runDomCallbacks('added', mutation, C.watches, nestable);
1615
+ runDomCallbacks('removed', mutation, C.watches, nestable);
1616
+ return runAttrCallbacks(mutation, C.watches, nestable);
1617
+ });
1618
+ };
1619
+
1620
+ nodesEqual = function(nodesOne, nodesTwo) {
1621
+ var itemsOne, itemsTwo;
1622
+ if (nodesOne.length !== nodesTwo.length) {
1623
+ return false;
1624
+ }
1625
+ if (nodesOne.length === 0 && nodesTwo.length === 0) {
1626
+ return true;
1627
+ }
1628
+ itemsOne = Array.from(nodesOne);
1629
+ itemsTwo = Array.from(nodesTwo);
1630
+ return !itemsOne.some(function(node, index) {
1631
+ return node !== itemsTwo[index];
1632
+ });
1633
+ };
1634
+
1635
+ findSameMutation = function(mutations, mu) {
1636
+ var theSameMutation;
1637
+ theSameMutation = null;
1638
+ mutations.some(function(mutation) {
1639
+ if (mu === mutation.mu) {
1640
+ return theSameMutation = mutation;
1641
+ }
1642
+ if (mu.type !== mutation.mu.type) {
1643
+ return;
1644
+ }
1645
+ if (mu.target !== mutation.mu.target) {
1646
+ return;
1647
+ }
1648
+ if (mu.attributeName !== mutation.mu.attributeName) {
1649
+ return;
1650
+ }
1651
+ if (mu.oldValue !== mutation.mu.oldValue) {
1652
+ return;
1653
+ }
1654
+ if (!nodesEqual(mu.addedNodes, mutation.mu.addedNodes)) {
1655
+ return;
1656
+ }
1657
+ if (!nodesEqual(mu.removedNodes, mutation.mu.removedNodes)) {
1658
+ return;
1659
+ }
1660
+ return theSameMutation = mutation;
1661
+ });
1662
+ return theSameMutation;
1663
+ };
1664
+
1665
+ createObserver = function(C, instance) {
1666
+ var inses, nestable, observer, rootEl;
1667
+ inses = C.instances;
1668
+ rootEl = instance.root.els[0];
1669
+ nestable = Type.isDocument(C.root);
1670
+ observer = new MutationObserver(function(mus) {
1671
+ var mutations;
1672
+ mutations = mus.map(function(mu) {
1673
+ return {
1674
+ ins: instance,
1675
+ mu: mu
1676
+ };
1677
+ });
1678
+ !nestable && find(C.root, rootEl).forEach(function(el) {
1679
+ var cached, ins, watcher;
1680
+ if (!(cached = inses[el[expando]])) {
1681
+ return;
1682
+ }
1683
+ if (!(ins = cached.instance)) {
1684
+ return;
1685
+ }
1686
+ if (!(watcher = cached.watcher)) {
1687
+ return;
1688
+ }
1689
+ return watcher.takeRecords().forEach(function(mu) {
1690
+ var nestedMutation;
1691
+ nestedMutation = findSameMutation(mutations, mu);
1692
+ if (nestedMutation) {
1693
+ return nestedMutation.ins = ins;
1694
+ }
1695
+ });
1696
+ });
1697
+ return executeMutations(C, mutations, nestable);
1698
+ });
1699
+ observer.observe(rootEl, config$1);
1700
+ return observer;
1701
+ };
1702
+
1703
+ watch = function(C, ins) {
1704
+ var conf;
1705
+ if (!C.watches) {
1706
+ conf = C.helpers.watch.call(C.prototype);
1707
+ C.watches = {
1708
+ dom: (conf.dom || []).map(function(d) {
1709
+ return {
1710
+ selector: Type.isFunction(d[0]) ? '*' : d[0],
1711
+ callbacks: Type.isFunction(d[0]) ? d : d.slice(1)
1712
+ };
1713
+ }),
1714
+ attr: (conf.attr || []).map(function(a) {
1715
+ return {
1716
+ name: a[0],
1717
+ selector: Type.isFunction(a[1]) ? '*' : a[1],
1718
+ callbacks: Type.isFunction(a[1]) ? a.slice(1) : a.slice(2)
1719
+ };
1720
+ })
1721
+ };
1722
+ }
1723
+ return createObserver(C, ins);
1724
+ };
1725
+
1726
+ stopWatch = function(ins, watcher) {
1727
+ return watcher.disconnect();
1728
+ };
1729
+
1730
+ var Base;
1731
+
1732
+ Base = (function() {
1733
+ class Base {
1734
+ constructor(root) {
1735
+ var C, create, definedWatch, find, inses, listen, proto, rootEl, traversal, watcher;
1736
+ C = this.constructor;
1737
+ proto = C.prototype;
1738
+ inses = C.instances;
1739
+ if (!(Type.isString(C.root) || Type.isDocument(C.root))) {
1740
+ throw new Error('Component root can only be selectors or document');
1741
+ }
1742
+ if (root instanceof C) {
1743
+ return root;
1744
+ }
1745
+ if (Type.isDocument(C.root)) {
1746
+ root = C.root;
1747
+ }
1748
+ this.root = luda(root);
1749
+ if (!(rootEl = this.root.els[0])) {
1750
+ return;
1751
+ }
1752
+ if (this.root.length > 1) {
1753
+ this.root = luda(rootEl);
1754
+ }
1755
+ this.id = rootEl[expando] || (rootEl[expando] = guid$1());
1756
+ if (this.id in inses) {
1757
+ return inses[this.id].instance;
1758
+ }
1759
+ if ((listen = C.helpers.listen) && !C.eventsBinded) {
1760
+ addEvents(C);
1761
+ C.eventsBinded = true;
1762
+ }
1763
+ if ((find = C.helpers.find) && !C.traversalAdded) {
1764
+ addTraversal(C);
1765
+ C.traversalAdded = true;
1766
+ }
1767
+ if (proto.cleanTraversal) {
1768
+ traversal = {};
1769
+ }
1770
+ if (traversal && !C.watches) {
1771
+ if (definedWatch = C.helpers.watch) {
1772
+ C.helpers.watch = function() {
1773
+ var watches;
1774
+ watches = definedWatch.call(this);
1775
+ watches.dom || (watches.dom = []);
1776
+ watches.dom.unshift([proto.cleanTraversal]);
1777
+ return watches;
1778
+ };
1779
+ } else {
1780
+ C.helpers.watch = function() {
1781
+ return {
1782
+ dom: [[proto.cleanTraversal]]
1783
+ };
1784
+ };
1785
+ }
1786
+ }
1787
+ if (C.helpers.watch) {
1788
+ watcher = watch(C, this);
1789
+ }
1790
+ inses[this.id] = {
1791
+ instance: this,
1792
+ traversal: traversal,
1793
+ watcher: watcher
1794
+ };
1795
+ _access(rootEl, C.id, inses[this.id]);
1796
+ if (create = C.helpers.create) {
1797
+ create.call(this);
1798
+ }
1799
+ log(`${C.id} ID: ${this.id} created.`, 'Root element', rootEl, 'Cache', inses[this.id]);
1800
+ }
1801
+
1802
+ static create(selector, ctx) {
1803
+ var C;
1804
+ C = this;
1805
+ if (Type.isDocument(this.root) || !selector) {
1806
+ selector = this.root;
1807
+ }
1808
+ return luda(selector, ctx).els.map(function(el) {
1809
+ return new C(el);
1810
+ });
1811
+ }
1812
+
1813
+ static destroy(selector, ctx) {
1814
+ var C, hasInstances, inses;
1815
+ C = this;
1816
+ inses = this.instances;
1817
+ if (Type.isDocument(this.root) || !selector) {
1818
+ selector = this.root;
1819
+ }
1820
+ luda(selector, ctx).els.forEach(function(rootEl) {
1821
+ var destroy, id, instance, watcher;
1822
+ if (!(id = rootEl[expando])) {
1823
+ return;
1824
+ }
1825
+ if (!(id in inses)) {
1826
+ return;
1827
+ }
1828
+ instance = inses[id].instance;
1829
+ watcher = inses[id].watcher;
1830
+ if (destroy = C.helpers.destroy) {
1831
+ destroy.call(instance);
1832
+ }
1833
+ if (watcher) {
1834
+ stopWatch(instance, watcher);
1835
+ }
1836
+ delete inses[id];
1837
+ _access(rootEl, C.id, null);
1838
+ return log(`${C.id} ID: ${id} destroied.`, 'Root element', rootEl, 'Cache', inses[id]);
1839
+ });
1840
+ hasInstances = Object.keys(inses).length;
1841
+ if (!hasInstances && C.eventsBinded) {
1842
+ removeEvents(C);
1843
+ C.eventsBinded = false;
1844
+ }
1845
+ return this;
1846
+ }
1847
+
1848
+ static help(key, val) {
1849
+ this.help = createMounter(this.helpers, 'helping');
1850
+ return this.help(key, val);
1851
+ }
1852
+
1853
+ static include(key, val) {
1854
+ var C, fn;
1855
+ C = this;
1856
+ fn = function(name, value) {
1857
+ C.included.push(name);
1858
+ return value;
1859
+ };
1860
+ this.include = createMounter(this.prototype, 'including', fn);
1861
+ return this.include(key, val);
1862
+ }
1863
+
1864
+ static protect(key, val) {
1865
+ this.protect = createMounter(this.prototype, 'protecting');
1866
+ return this.protect(key, val);
1867
+ }
1868
+
1869
+ static contains(selector, ctx) {
1870
+ var inses;
1871
+ inses = this.instances;
1872
+ return luda(selector, ctx).els.some(function(el) {
1873
+ var id;
1874
+ return (id = el[expando]) && inses[id];
1875
+ });
1876
+ }
1877
+
1878
+ static each(callback) {
1879
+ Object.values(this.instances).some(function(cache, index) {
1880
+ var instance, rootEl;
1881
+ instance = cache.instance;
1882
+ rootEl = instance.root.els[0];
1883
+ return callback(instance, rootEl, index, cache) === false;
1884
+ });
1885
+ return this;
1886
+ }
1887
+
1888
+ }
1889
+ Base.prototype.win = luda(window);
1890
+
1891
+ Base.prototype.doc = luda(document);
1892
+
1893
+ Object.defineProperty(Base.prototype, 'html', {
1894
+ get: function() {
1895
+ return luda(document.documentElement);
1896
+ }
1897
+ });
1898
+
1899
+ Object.defineProperty(Base.prototype, 'body', {
1900
+ get: function() {
1901
+ return luda(document.body);
1902
+ }
1903
+ });
1904
+
1905
+ Object.defineProperty(Base.prototype, 'con', {
1906
+ get: function() {
1907
+ return this.constructor;
1908
+ }
1909
+ });
1910
+
1911
+ return Base;
1912
+
1913
+ }).call(this);
1914
+
1915
+ var Base$1 = Base;
1916
+
1917
+ var constructorAccessWarn, createComponentProxy, createInstancesCallProxy, createInstancesProxy, instanceAccessWarn;
1918
+
1919
+ constructorAccessWarn = function(action, C, key) {
1920
+ var msg;
1921
+ if (!(key in C && !C.extended.includes(key))) {
1922
+ return;
1923
+ }
1924
+ msg = `${action} private property '${key}' of ${C.id}`;
1925
+ return console.warn(msg);
1926
+ };
1927
+
1928
+ createComponentProxy = function(C) {
1929
+ var proxy;
1930
+ return proxy = new Proxy(C, {
1931
+ get: function(target, key) {
1932
+ constructorAccessWarn('Getting', C, key);
1933
+ return C[key];
1934
+ },
1935
+ set: function(target, key, val) {
1936
+ constructorAccessWarn('Setting', C, key);
1937
+ return C[key] = val;
1938
+ },
1939
+ apply: function(target, ctx, args) {
1940
+ var inses;
1941
+ inses = C.create.apply(C, args);
1942
+ return createInstancesProxy(inses);
1943
+ }
1944
+ });
1945
+ };
1946
+
1947
+ instanceAccessWarn = function(action, ins, key) {
1948
+ var msg;
1949
+ if (!(key in ins && !ins.con.included.includes(key))) {
1950
+ return;
1951
+ }
1952
+ msg = `${action} private property '${key}' of ${ins.con.id} ${ins.id}`;
1953
+ return console.warn(msg);
1954
+ };
1955
+
1956
+ createInstancesProxy = function(inses) {
1957
+ var proxy;
1958
+ return proxy = new Proxy(inses, {
1959
+ set: function(target, key, val) {
1960
+ return inses.map(function(ins) {
1961
+ instanceAccessWarn('Setting', ins, key);
1962
+ return ins[key] = val;
1963
+ });
1964
+ },
1965
+ get: function(target, key) {
1966
+ var vals;
1967
+ vals = inses.map(function(ins) {
1968
+ instanceAccessWarn('Getting', ins, key);
1969
+ return ins[key];
1970
+ });
1971
+ return createInstancesCallProxy(inses, vals, key, proxy);
1972
+ }
1973
+ });
1974
+ };
1975
+
1976
+ createInstancesCallProxy = function(inses, vals, key, instancesProxy) {
1977
+ var proxy;
1978
+ return proxy = new Proxy(new Function(), {
1979
+ get: function(target, k) {
1980
+ if (!Type.isFunction(vals[k])) {
1981
+ return vals[k];
1982
+ }
1983
+ return vals[k].bind(vals);
1984
+ },
1985
+ apply: function(target, ctx, args) {
1986
+ var option, returns;
1987
+ returns = inses.map(function(ins) {
1988
+ return ins[key].apply(ins, args);
1989
+ });
1990
+ option = args[args.length - 1];
1991
+ if (Type.isObject(option) && option.chain === false) {
1992
+ return returns;
1993
+ } else {
1994
+ return instancesProxy;
1995
+ }
1996
+ }
1997
+ });
1998
+ };
1999
+
2000
+ function createProxy(Component) {
2001
+ return createComponentProxy(Component);
2002
+ }
2003
+
2004
+ var factory$1;
2005
+
2006
+ luda.extend('component', factory$1 = function(name, root) {
2007
+ var Component;
2008
+ Component = (function() {
2009
+ class Component extends Base$1 {}
2010
+ Component.id = camelCase(`Component${(name ? '-' + name : '_' + guid$1())}`);
2011
+
2012
+ Component.root = root ? root : name ? `.${dashCase(name)}` : document;
2013
+
2014
+ Component.instances = {};
2015
+
2016
+ Component.helpers = {};
2017
+
2018
+ Component.included = ['toString'];
2019
+
2020
+ Component.extended = ['toString'];
2021
+
2022
+ Component.eventsBinded = false;
2023
+
2024
+ Component.autoEnabled = false;
2025
+
2026
+ Component.traversalAdded = false;
2027
+
2028
+ Component.watches = null;
2029
+
2030
+ return Component;
2031
+
2032
+ }).call(this);
2033
+ if (name) {
2034
+ luda.extend(name, createProxy(Component));
2035
+ }
2036
+ luda.ready(function() {
2037
+ if (Type.isDocument(Component.root)) {
2038
+ Component.create(Component.root);
2039
+ }
2040
+ if (!Type.isString(Component.root)) {
2041
+ return;
2042
+ }
2043
+ Component.create(autoable(Component.root));
2044
+ autoCreateAndDestroy(Component);
2045
+ return Component.autoEnabled = true;
2046
+ });
2047
+ return Component;
2048
+ });
2049
+
2050
+ function computeStyle(el, prop, isVar) {
2051
+ var style;
2052
+ if (!Type.isElement(el) || !prop) {
2053
+ return;
2054
+ }
2055
+ style = window.getComputedStyle(el, null);
2056
+ if (prop) {
2057
+ if (isVar) {
2058
+ return style.getPropertyValue(prop) || void 0;
2059
+ } else {
2060
+ return style[prop];
2061
+ }
2062
+ } else {
2063
+ return style;
2064
+ }
2065
+ }
2066
+
2067
+ function isVariable(prop) {
2068
+ return /^--/.test(prop);
2069
+ }
2070
+
2071
+ function readProp(prop, isVar) {
2072
+ if (isVar === void 0) {
2073
+ isVar = isVariable(prop);
2074
+ }
2075
+ if (isVar) {
2076
+ return prop;
2077
+ } else {
2078
+ return camelCase(prop);
2079
+ }
2080
+ }
2081
+
2082
+ var numericProps;
2083
+
2084
+ numericProps = ['animationIterationCount', 'columnCount', 'flexGrow', 'flexShrink', 'fontWeight', 'lineHeight', 'opacity', 'order', 'orphans', 'widows', 'zIndex'];
2085
+
2086
+ function parseValue$1(prop, value, isVar) {
2087
+ if (isVar === void 0) {
2088
+ isVar = isVariable(prop);
2089
+ }
2090
+ if (isVar || numericProps.includes(prop)) {
2091
+ return value;
2092
+ }
2093
+ if (Type.isNumeric(value)) {
2094
+ return `${value}px`;
2095
+ } else {
2096
+ return value;
2097
+ }
2098
+ }
2099
+
2100
+ luda.include({
2101
+ css: function(prop, value) {
2102
+ var isVar, key, val;
2103
+ if (Type.isString(prop)) {
2104
+ isVar = isVariable(prop);
2105
+ prop = readProp(prop, isVar);
2106
+ if (arguments.length < 2) {
2107
+ return this.els[0] && computeStyle(this.els[0], prop, isVar);
2108
+ }
2109
+ if (!prop) {
2110
+ return this;
2111
+ }
2112
+ value = parseValue$1(prop, value, isVar);
2113
+ this.els.forEach(function(el) {
2114
+ if (!Type.isElement(el)) {
2115
+ return;
2116
+ }
2117
+ if (isVar) {
2118
+ return el.style.setProperty(prop, value);
2119
+ } else {
2120
+ return el.style[prop] = value;
2121
+ }
2122
+ });
2123
+ return this;
2124
+ }
2125
+ for (key in prop) {
2126
+ val = prop[key];
2127
+ this.css(key, val);
2128
+ }
2129
+ return this;
2130
+ }
2131
+ });
2132
+
2133
+ luda.include({
2134
+ removeCss: function(prop) {
2135
+ return this.css(prop, '');
2136
+ }
2137
+ });
2138
+
2139
+ var parse$1, pattern$3;
2140
+
2141
+ pattern$3 = /^data-/i;
2142
+
2143
+ parse$1 = function(name) {
2144
+ return camelCase(name.replace(pattern$3, ''));
2145
+ };
2146
+
2147
+ var parseName = parse$1;
2148
+
2149
+ luda.include({
2150
+ removeData: function(name) {
2151
+ var names;
2152
+ if (arguments.length) {
2153
+ names = splitValues(name);
2154
+ if (!names.length) {
2155
+ return this;
2156
+ }
2157
+ names = names.map(function(n) {
2158
+ return parseName(n);
2159
+ });
2160
+ this.els.forEach(function(el) {
2161
+ return names.forEach(function(n) {
2162
+ return delete el.dataset[n];
2163
+ });
2164
+ });
2165
+ } else {
2166
+ this.els.forEach(function(el) {
2167
+ var n, ref, results, val;
2168
+ ref = el.dataset;
2169
+ results = [];
2170
+ for (n in ref) {
2171
+ val = ref[n];
2172
+ results.push(delete el.dataset[n]);
2173
+ }
2174
+ return results;
2175
+ });
2176
+ }
2177
+ return this;
2178
+ }
2179
+ });
2180
+
2181
+ luda.include({
2182
+ data: function(name, value) {
2183
+ var datas, key, ref, val;
2184
+ if (!name) {
2185
+ if (!this.els[0]) {
2186
+ return;
2187
+ }
2188
+ datas = {};
2189
+ ref = this.els[0].dataset;
2190
+ for (key in ref) {
2191
+ val = ref[key];
2192
+ datas[key] = readValue(val);
2193
+ }
2194
+ return datas;
2195
+ }
2196
+ if (Type.isString(name)) {
2197
+ name = parseName(name);
2198
+ if (arguments.length >= 2) {
2199
+ if (value === void 0) {
2200
+ return this;
2201
+ }
2202
+ if (value === null) {
2203
+ return this.removeData(name);
2204
+ }
2205
+ val = parseValue(value);
2206
+ this.els.forEach(function(el) {
2207
+ return el.dataset[name] = val;
2208
+ });
2209
+ return this;
2210
+ }
2211
+ if (!this.els[0]) {
2212
+ return;
2213
+ }
2214
+ return readValue(this.els[0].dataset[name]);
2215
+ }
2216
+ for (key in name) {
2217
+ val = name[key];
2218
+ this.data(key, val);
2219
+ }
2220
+ return this;
2221
+ }
2222
+ });
2223
+
2224
+ luda.include({
2225
+ hasData: function(key) {
2226
+ if (!key) {
2227
+ return false;
2228
+ }
2229
+ key = parseName(key);
2230
+ return this.els.some(function(el) {
2231
+ return el.dataset && key in el.dataset;
2232
+ });
2233
+ }
2234
+ });
2235
+
2236
+ var factory$3;
2237
+
2238
+ factory$3 = function(prop) {
2239
+ return function() {
2240
+ var el;
2241
+ if (!(el = this.els[0])) {
2242
+ return;
2243
+ }
2244
+ if (Type.isWindow(el)) {
2245
+ return window[`inner${prop}`];
2246
+ }
2247
+ return el[`client${prop}`];
2248
+ };
2249
+ };
2250
+
2251
+ luda.include({
2252
+ innerWidth: factory$3('Width'),
2253
+ innerHeight: factory$3('Height')
2254
+ });
2255
+
2256
+ function computeStyleInt(el, prop) {
2257
+ return parseInt(computeStyle(el, prop), 10) || 0;
2258
+ }
2259
+
2260
+ function getExtraSpace(el, xAxis) {
2261
+ return computeStyleInt(el, `border${(xAxis ? 'Left' : 'Top')}Width`) + computeStyleInt(el, `padding${(xAxis ? 'Left' : 'Top')}`) + computeStyleInt(el, `padding${(xAxis ? 'Right' : 'Bottom')}`) + computeStyleInt(el, `border${(xAxis ? 'Right' : 'Bottom')}Width`);
2262
+ }
2263
+
2264
+ var factory$4;
2265
+
2266
+ factory$4 = function(prop) {
2267
+ return function(value) {
2268
+ var e, valNumber;
2269
+ if (!(e = this.els[0])) {
2270
+ if (value === void 0) {
2271
+ return void 0;
2272
+ } else {
2273
+ return this;
2274
+ }
2275
+ }
2276
+ if (!arguments.length) {
2277
+ if (Type.isWindow(e)) {
2278
+ return e[camelCase(`outer-${prop}`)];
2279
+ }
2280
+ return e.getBoundingClientRect()[prop] - getExtraSpace(e, prop === 'width');
2281
+ }
2282
+ valNumber = parseInt(value, 10);
2283
+ this.els.forEach(function(el) {
2284
+ var boxSizing, extra;
2285
+ if (!Type.isElement(el)) {
2286
+ return;
2287
+ }
2288
+ boxSizing = computeStyle(el, 'boxSizing');
2289
+ extra = 0;
2290
+ if (boxSizing === 'border-box') {
2291
+ extra = getExtraSpace(el, prop === 'width');
2292
+ }
2293
+ return el.style[prop] = parseValue$1(prop, valNumber + extra);
2294
+ });
2295
+ return this;
2296
+ };
2297
+ };
2298
+
2299
+ luda.include({
2300
+ width: factory$4('width'),
2301
+ height: factory$4('height')
2302
+ });
2303
+
2304
+ var factory$5;
2305
+
2306
+ factory$5 = function(prop) {
2307
+ return function(includeMargins) {
2308
+ var el, marginOne, marginTwo, offsetSize;
2309
+ if (!(el = this.els[0])) {
2310
+ return;
2311
+ }
2312
+ if (Type.isWindow(el)) {
2313
+ return window[`outer${prop}`];
2314
+ }
2315
+ offsetSize = el[`offset${prop}`];
2316
+ if (!includeMargins) {
2317
+ return offsetSize;
2318
+ }
2319
+ marginOne = computeStyleInt(el, `margin${(prop === 'Width' ? 'Left' : 'Top')}`);
2320
+ marginTwo = computeStyleInt(el, `margin${(prop === 'Width' ? 'Right' : 'Bottom')}`);
2321
+ return offsetSize + marginOne + marginTwo;
2322
+ };
2323
+ };
2324
+
2325
+ luda.include({
2326
+ outerWidth: factory$5('Width'),
2327
+ outerHeight: factory$5('Height')
2328
+ });
2329
+
2330
+ luda.include({
2331
+ one: function(name, selector, callback) {
2332
+ return this.on(name, selector, callback, true);
2333
+ }
2334
+ });
2335
+
2336
+ function getValue(el) {
2337
+ var val;
2338
+ if (el.multiple && el.options) {
2339
+ val = [];
2340
+ [].forEach.call(el.options, function(option) {
2341
+ var optionValue;
2342
+ if (option.selected && !option.disabled && !option.parentNode.disabled) {
2343
+ optionValue = readValue(option.value);
2344
+ if (optionValue === void 0 || optionValue === null) {
2345
+ optionValue = '';
2346
+ }
2347
+ return val.push(optionValue);
2348
+ }
2349
+ });
2350
+ return val;
2351
+ }
2352
+ val = readValue(el.value);
2353
+ if (val === void 0 || val === null) {
2354
+ return '';
2355
+ } else {
2356
+ return val;
2357
+ }
2358
+ }
2359
+
2360
+ luda.include({
2361
+ val: function(value) {
2362
+ if (value === void 0) {
2363
+ return this.els[0] && getValue(this.els[0]);
2364
+ }
2365
+ this.els.forEach(function(el) {
2366
+ var val;
2367
+ if (el.tagName === 'SELECT') {
2368
+ if (Type.isArray(value)) {
2369
+ val = value;
2370
+ } else if (value === null) {
2371
+ val = [];
2372
+ } else {
2373
+ val = [value];
2374
+ }
2375
+ return [].forEach.call(el.options, function(option) {
2376
+ var selected;
2377
+ selected = val.includes(readValue(option.value));
2378
+ luda(option).attr('selected', selected ? '' : null);
2379
+ return option.selected = selected;
2380
+ });
2381
+ } else {
2382
+ val = value === null ? '' : parseValue(value);
2383
+ luda(el).attr('value', val);
2384
+ return el.value = val;
2385
+ }
2386
+ });
2387
+ return this;
2388
+ }
2389
+ });
2390
+
2391
+ var Variables$1 = {
2392
+ scriptExpando: 'script'
2393
+ };
2394
+
2395
+ function clone(el, cacheAndEvts, deep) {
2396
+ var cloned, clonedScripts, clones, nodes, scripts;
2397
+ cloned = el.cloneNode(true);
2398
+ // track script execute status,
2399
+ // no matter the cloned or the original script executed,
2400
+ // the other should not be executed again.
2401
+ scripts = findAll('script', el);
2402
+ clonedScripts = findAll('script', cloned);
2403
+ scripts.forEach(function(script, i) {
2404
+ var cache;
2405
+ if (!Type.isScript(script)) {
2406
+ return;
2407
+ }
2408
+ if (script.src) {
2409
+ return;
2410
+ }
2411
+ cache = _access(script, Variables$1.scriptExpando);
2412
+ cache || (cache = {
2413
+ executed: false
2414
+ });
2415
+ _access(script, Variables$1.scriptExpando, cache);
2416
+ return _access(clonedScripts[i], Variables$1.scriptExpando, cache);
2417
+ });
2418
+ if (!cacheAndEvts) {
2419
+ return cloned;
2420
+ }
2421
+ if (deep) {
2422
+ nodes = findAll('*', el);
2423
+ clones = findAll('*', cloned);
2424
+ } else {
2425
+ nodes = [el];
2426
+ clones = [cloned];
2427
+ }
2428
+ nodes.forEach(function(node, i) {
2429
+ var _evt, cache, config, type;
2430
+ // copy events for the cloned node
2431
+ // if the original node has events
2432
+ if (_evt = _access(node, Variables.expando)) {
2433
+ for (type in _evt) {
2434
+ config = _evt[type];
2435
+ config.quene && config.quene.forEach(function(it) {
2436
+ return addEvent$1(clones[i], type, it.selector, it.callback, it.namespace, it.key, it.stop, it.prevent, it._one);
2437
+ });
2438
+ }
2439
+ }
2440
+ if (cache = access(node)) {
2441
+ // copy pub cache if the original node has pub cache
2442
+ return access(clones[i], Object.assign({}, cache));
2443
+ }
2444
+ });
2445
+ return cloned;
2446
+ }
2447
+
2448
+ luda.include({
2449
+ find: function(selector) {
2450
+ var all;
2451
+ all = [];
2452
+ this.els.forEach(function(el) {
2453
+ var found;
2454
+ found = find(selector, el);
2455
+ if (found.length) {
2456
+ return [].push.apply(all, found);
2457
+ }
2458
+ });
2459
+ return luda(unique(all));
2460
+ }
2461
+ });
2462
+
2463
+ var CDATARe, geval;
2464
+
2465
+ CDATARe = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
2466
+
2467
+ geval = eval;
2468
+
2469
+ function evalScripts(node) {
2470
+ var collection, scripts;
2471
+ collection = luda(node);
2472
+ scripts = collection.filter('script').add(collection.find('script')).els;
2473
+ return scripts.forEach(function(el) {
2474
+ var scriptCache;
2475
+ if (!(!el.src && Type.isScript(el))) {
2476
+ return;
2477
+ }
2478
+ if (!el.ownerDocument.documentElement.contains(el)) {
2479
+ return;
2480
+ }
2481
+ scriptCache = _access(el, Variables$1.scriptExpando);
2482
+ if (scriptCache && scriptCache.executed) {
2483
+ return;
2484
+ }
2485
+ geval(el.textContent.replace(CDATARe, ''));
2486
+ if (scriptCache) {
2487
+ return scriptCache.executed = true;
2488
+ } else {
2489
+ return _access(el, Variables$1.scriptExpando, {
2490
+ executed: true
2491
+ });
2492
+ }
2493
+ });
2494
+ }
2495
+
2496
+ function insertElement(anchor, child, prepend, prependTarget) {
2497
+ if (prepend) {
2498
+ anchor.insertBefore(child, prependTarget);
2499
+ } else {
2500
+ anchor.appendChild(child);
2501
+ }
2502
+ return evalScripts(child);
2503
+ }
2504
+
2505
+ luda.include({
2506
+ insertAfter: function(selector) {
2507
+ var els;
2508
+ els = this.els;
2509
+ luda(selector).els.forEach(function(target, index) {
2510
+ var parent;
2511
+ parent = target.parentNode;
2512
+ return parent && els.forEach(function(child) {
2513
+ var childToBeInserted;
2514
+ childToBeInserted = index ? clone(child, true, true) : child;
2515
+ return insertElement(parent, childToBeInserted, true, target.nextSibling);
2516
+ });
2517
+ });
2518
+ return this;
2519
+ }
2520
+ });
2521
+
2522
+ luda.include({
2523
+ after: function() {
2524
+ var argReverse, handler, self;
2525
+ self = this;
2526
+ argReverse = [].reverse.apply(arguments);
2527
+ handler = function(selector) {
2528
+ var els;
2529
+ els = luda(selector).els.slice().reverse();
2530
+ return luda(els).insertAfter(self);
2531
+ };
2532
+ [].forEach.call(argReverse, handler);
2533
+ return this;
2534
+ }
2535
+ });
2536
+
2537
+ function insertContent(parent, child, prepend) {
2538
+ return parent.forEach(function(p, parentIndex) {
2539
+ return child.forEach(function(c) {
2540
+ var childToBeInserted;
2541
+ childToBeInserted = parentIndex ? clone(c, true, true) : c;
2542
+ return insertElement(p, childToBeInserted, prepend, prepend && p.firstChild);
2543
+ });
2544
+ });
2545
+ }
2546
+
2547
+ luda.include({
2548
+ appendTo: function(selector) {
2549
+ insertContent(luda(selector).els, this.els);
2550
+ return this;
2551
+ }
2552
+ });
2553
+
2554
+ luda.include({
2555
+ append: function() {
2556
+ var els, handler;
2557
+ els = this.els;
2558
+ handler = function(selector) {
2559
+ return insertContent(els, luda(selector).els);
2560
+ };
2561
+ [].forEach.call(arguments, handler);
2562
+ return this;
2563
+ }
2564
+ });
2565
+
2566
+ luda.include({
2567
+ insertBefore: function(selector) {
2568
+ var els;
2569
+ els = this.els;
2570
+ luda(selector).els.forEach(function(target, index) {
2571
+ var parent;
2572
+ parent = target.parentNode;
2573
+ return parent && els.forEach(function(child) {
2574
+ var childToBeInserted;
2575
+ childToBeInserted = index ? clone(child, true, true) : child;
2576
+ return insertElement(parent, childToBeInserted, true, target);
2577
+ });
2578
+ });
2579
+ return this;
2580
+ }
2581
+ });
2582
+
2583
+ luda.include({
2584
+ before: function() {
2585
+ var handler, self;
2586
+ self = this;
2587
+ handler = function(selector) {
2588
+ return luda(selector).insertBefore(self);
2589
+ };
2590
+ [].forEach.call(arguments, handler);
2591
+ return this;
2592
+ }
2593
+ });
2594
+
2595
+ luda.include({
2596
+ clone: function(cacheAndEvents, deep) {
2597
+ var collection;
2598
+ if (deep === void 0) {
2599
+ deep = cacheAndEvents;
2600
+ }
2601
+ collection = this.els.map(function(el) {
2602
+ return clone(el, cacheAndEvents, deep);
2603
+ });
2604
+ return luda(collection);
2605
+ }
2606
+ });
2607
+
2608
+ luda.include({
2609
+ detach: function() {
2610
+ this.els.forEach(function(el) {
2611
+ var parent;
2612
+ if (parent = el.parentNode) {
2613
+ return parent.removeChild(el);
2614
+ }
2615
+ });
2616
+ return this;
2617
+ }
2618
+ });
2619
+
2620
+ function clean$1(ctx) {
2621
+ return findAll('*', ctx).forEach(function(el) {
2622
+ removeEvent$1(el);
2623
+ return clean(el);
2624
+ });
2625
+ }
2626
+
2627
+ luda.include({
2628
+ empty: function() {
2629
+ this.els.forEach(function(el) {
2630
+ var child, i, len, ref;
2631
+ ref = el.children;
2632
+ for (i = 0, len = ref.length; i < len; i++) {
2633
+ child = ref[i];
2634
+ clean$1(child);
2635
+ }
2636
+ return el.textContent = '';
2637
+ });
2638
+ return this;
2639
+ }
2640
+ });
2641
+
2642
+ luda.include({
2643
+ html: function(html) {
2644
+ if (html === void 0 && this.els.length) {
2645
+ return this.els[0].innerHTML;
2646
+ }
2647
+ this.els.forEach(function(el) {
2648
+ var child, i, len, ref;
2649
+ ref = el.children;
2650
+ for (i = 0, len = ref.length; i < len; i++) {
2651
+ child = ref[i];
2652
+ clean$1(child);
2653
+ }
2654
+ return el.innerHTML = html;
2655
+ });
2656
+ return this;
2657
+ }
2658
+ });
2659
+
2660
+ luda.include({
2661
+ prependTo: function(selector) {
2662
+ insertContent(luda(selector).els, this.els.reverse(), true);
2663
+ return this;
2664
+ }
2665
+ });
2666
+
2667
+ luda.include({
2668
+ prepend: function() {
2669
+ var els, handler;
2670
+ els = this.els;
2671
+ handler = function(selector) {
2672
+ return insertContent(els, luda(selector).els, true);
2673
+ };
2674
+ [].forEach.call(arguments, handler);
2675
+ return this;
2676
+ }
2677
+ });
2678
+
2679
+ luda.include({
2680
+ remove: function() {
2681
+ this.els.forEach(function(el) {
2682
+ var parent;
2683
+ clean$1(el);
2684
+ if (parent = el.parentNode) {
2685
+ return parent.removeChild(el);
2686
+ }
2687
+ });
2688
+ return this;
2689
+ }
2690
+ });
2691
+
2692
+ luda.include({
2693
+ replaceWith: function(selector) {
2694
+ return this.before(selector).remove();
2695
+ }
2696
+ });
2697
+
2698
+ luda.include({
2699
+ replaceAll: function(selector) {
2700
+ luda(selector).replaceWith(this);
2701
+ return this;
2702
+ }
2703
+ });
2704
+
2705
+ luda.include({
2706
+ text: function(text) {
2707
+ if (text === void 0) {
2708
+ if (this.els[0]) {
2709
+ return this.els[0].textContent;
2710
+ } else {
2711
+ return '';
2712
+ }
2713
+ }
2714
+ this.els.forEach(function(el) {
2715
+ var child, i, len, ref;
2716
+ ref = el.children;
2717
+ for (i = 0, len = ref.length; i < len; i++) {
2718
+ child = ref[i];
2719
+ clean$1(child);
2720
+ }
2721
+ return el.textContent = text;
2722
+ });
2723
+ return this;
2724
+ }
2725
+ });
2726
+
2727
+ luda.include({
2728
+ unwrap: function() {
2729
+ this.parent().els.forEach(function(el) {
2730
+ var collection;
2731
+ collection = luda(el);
2732
+ return collection.replaceWith(collection.children());
2733
+ });
2734
+ return this;
2735
+ }
2736
+ });
2737
+
2738
+ luda.include({
2739
+ wrapAll: function(selector) {
2740
+ var structure, wrapper;
2741
+ if (!this.els.length) {
2742
+ return this;
2743
+ }
2744
+ structure = luda(selector);
2745
+ this.first().before(structure);
2746
+ wrapper = structure.els[0];
2747
+ while (wrapper.children.length) {
2748
+ wrapper = wrapper.firstElementChild;
2749
+ }
2750
+ return this.appendTo(wrapper);
2751
+ }
2752
+ });
2753
+
2754
+ luda.include({
2755
+ contents: function() {
2756
+ var all;
2757
+ all = [];
2758
+ this.els.forEach(function(el) {
2759
+ var content;
2760
+ if (el.tagName === 'IFRAME') {
2761
+ content = [el.contentDocument];
2762
+ } else {
2763
+ content = el.childNodes;
2764
+ }
2765
+ return [].push.apply(all, content);
2766
+ });
2767
+ return luda(unique(all));
2768
+ }
2769
+ });
2770
+
2771
+ luda.include({
2772
+ wrapInner: function(selector) {
2773
+ this.els.forEach(function(el) {
2774
+ var contents, target;
2775
+ target = luda(el);
2776
+ contents = target.contents();
2777
+ if (contents.els.length) {
2778
+ return contents.wrapAll(selector);
2779
+ } else {
2780
+ return target.append(selector);
2781
+ }
2782
+ });
2783
+ return this;
2784
+ }
2785
+ });
2786
+
2787
+ luda.include({
2788
+ wrap: function(selector) {
2789
+ this.els.forEach(function(el, index) {
2790
+ var wrapper;
2791
+ wrapper = luda(selector).els[0];
2792
+ return luda(el).wrapAll(index ? clone(wrapper, true, true) : wrapper);
2793
+ });
2794
+ return this;
2795
+ }
2796
+ });
2797
+
2798
+ luda.include({
2799
+ matches: function(selector) {
2800
+ if (!this.els.length) {
2801
+ return false;
2802
+ }
2803
+ if (!selector) {
2804
+ return false;
2805
+ }
2806
+ return this.els.some(function(el) {
2807
+ return matches(el, selector);
2808
+ });
2809
+ }
2810
+ });
2811
+
2812
+ var Mixin;
2813
+
2814
+ var Mixin$1 = Mixin = class Mixin {
2815
+ constructor(conf) {
2816
+ this.conf = conf;
2817
+ }
2818
+
2819
+ get(key) {
2820
+ return this.conf[key];
2821
+ }
2822
+
2823
+ all() {
2824
+ return Object.assign({}, this.conf);
2825
+ }
2826
+
2827
+ only(keys) {
2828
+ var picked;
2829
+ picked = {};
2830
+ if (!(arguments.length === 1 && Type.isArray(keys))) {
2831
+ keys = Array.from(arguments);
2832
+ }
2833
+ keys.forEach((k) => {
2834
+ if (k in this.conf) {
2835
+ return picked[k] = this.conf[k];
2836
+ }
2837
+ });
2838
+ return picked;
2839
+ }
2840
+
2841
+ except(keys) {
2842
+ var k, picked, ref, v;
2843
+ picked = {};
2844
+ if (!(arguments.length === 1 && Type.isArray(keys))) {
2845
+ keys = Array.from(arguments);
2846
+ }
2847
+ ref = this.conf;
2848
+ for (k in ref) {
2849
+ v = ref[k];
2850
+ if (!keys.includes(k)) {
2851
+ picked[k] = v;
2852
+ }
2853
+ }
2854
+ return picked;
2855
+ }
2856
+
2857
+ alias(newName, name) {
2858
+ var k, picked, v;
2859
+ picked = {};
2860
+ if (arguments.length === 1 && Type.isObject(newName)) {
2861
+ for (k in newName) {
2862
+ v = newName[k];
2863
+ if (v in this.conf) {
2864
+ picked[k] = this.conf[v];
2865
+ }
2866
+ }
2867
+ } else {
2868
+ if (name in this.conf) {
2869
+ picked[newName] = this.conf[name];
2870
+ }
2871
+ }
2872
+ return picked;
2873
+ }
2874
+
2875
+ };
2876
+
2877
+ var get, mount, named, unmount;
2878
+
2879
+ named = {};
2880
+
2881
+ mount = createMounter(named, 'mixing');
2882
+
2883
+ unmount = function(name) {
2884
+ return delete named[name];
2885
+ };
2886
+
2887
+ get = function(name) {
2888
+ return named[name] || {};
2889
+ };
2890
+
2891
+ luda.extend({
2892
+ mixin: function(name, conf) {
2893
+ var mixin;
2894
+ if (arguments.length === 1) {
2895
+ if (Type.isString(name)) {
2896
+ return get(name);
2897
+ } else {
2898
+ return new Mixin$1(conf);
2899
+ }
2900
+ } else {
2901
+ if (conf === null) {
2902
+ unmount(name);
2903
+ return this;
2904
+ } else {
2905
+ mixin = new Mixin$1(conf);
2906
+ mount(name, mixin);
2907
+ return this;
2908
+ }
2909
+ }
2910
+ }
2911
+ });
2912
+
2913
+ luda.mixin.named = named;
2914
+
2915
+ luda.include({
2916
+ offsetParent: function() {
2917
+ return luda(this.els[0] && this.els[0].offsetParent);
2918
+ }
2919
+ });
2920
+
2921
+ luda.include({
2922
+ offset: function() {
2923
+ var docEl, el, rect;
2924
+ el = this.els[0];
2925
+ if (!el) {
2926
+ return;
2927
+ }
2928
+ docEl = document.documentElement;
2929
+ rect = el.getBoundingClientRect();
2930
+ return {
2931
+ top: rect.top + window.pageYOffset - docEl.clientTop,
2932
+ left: rect.left + window.pageXOffset - docEl.clientLeft
2933
+ };
2934
+ }
2935
+ });
2936
+
2937
+ luda.include({
2938
+ position: function() {
2939
+ var el;
2940
+ el = this.els[0];
2941
+ if (!el) {
2942
+ return;
2943
+ }
2944
+ return {
2945
+ left: el.offsetLeft,
2946
+ top: el.offsetTop
2947
+ };
2948
+ }
2949
+ });
2950
+
2951
+ luda.include({
2952
+ prop: function(prop, value) {
2953
+ var key, val;
2954
+ if (!prop) {
2955
+ return;
2956
+ }
2957
+ if (Type.isString(prop)) {
2958
+ if (arguments.length < 2) {
2959
+ return this.els[0] && this.els[0][prop];
2960
+ }
2961
+ this.els.forEach(function(el) {
2962
+ return el[prop] = value;
2963
+ });
2964
+ return this;
2965
+ }
2966
+ for (key in prop) {
2967
+ val = prop[key];
2968
+ this.prop(key, val);
2969
+ }
2970
+ return this;
2971
+ }
2972
+ });
2973
+
2974
+ luda.include({
2975
+ removeProp: function(prop) {
2976
+ var props;
2977
+ props = splitValues(prop);
2978
+ if (!props.length) {
2979
+ return this;
2980
+ }
2981
+ this.els.forEach(function(el) {
2982
+ return props.forEach(function(p) {
2983
+ return delete el[p];
2984
+ });
2985
+ });
2986
+ return this;
2987
+ }
2988
+ });
2989
+
2990
+ luda.include({
2991
+ reflow: function() {
2992
+ this.els.forEach(function(el) {
2993
+ return el.offsetHeight;
2994
+ });
2995
+ return this;
2996
+ }
2997
+ });
2998
+
2999
+ function getDurations(style, propertyLength) {
3000
+ var durationArray;
3001
+ durationArray = style.split(',');
3002
+ while (durationArray.length < propertyLength) {
3003
+ durationArray = durationArray.concat(durationArray);
3004
+ }
3005
+ if (durationArray.length > propertyLength) {
3006
+ durationArray = durationArray.slice(0, propertyLength);
3007
+ }
3008
+ return durationArray.map(function(durationStr) {
3009
+ var duration;
3010
+ duration = parseFloat(durationStr);
3011
+ if (!duration) {
3012
+ return 0;
3013
+ }
3014
+ if (durationStr.match('ms')) {
3015
+ return duration;
3016
+ } else {
3017
+ return duration * 1000;
3018
+ }
3019
+ });
3020
+ }
3021
+
3022
+ luda.include({
3023
+ transitionDuration: function() {
3024
+ var delays, durations, el, finalDurations, length, styles;
3025
+ if (!(el = this.els[0])) {
3026
+ return;
3027
+ }
3028
+ styles = window.getComputedStyle(el);
3029
+ length = styles.transitionProperty.split(',').length;
3030
+ if (!length) {
3031
+ return 0;
3032
+ }
3033
+ delays = getDurations(styles.transitionDelay, length);
3034
+ durations = getDurations(styles.transitionDuration, length);
3035
+ finalDurations = durations.map(function(duration, index) {
3036
+ return duration + delays[index];
3037
+ });
3038
+ return Math.max.apply(null, finalDurations);
3039
+ }
3040
+ });
3041
+
3042
+ luda.include({
3043
+ closest: function(comparator) {
3044
+ var filtered;
3045
+ if (!comparator || !this.els.length) {
3046
+ return luda();
3047
+ }
3048
+ filtered = this.filter(comparator);
3049
+ if (filtered.els.length) {
3050
+ return filtered;
3051
+ }
3052
+ return this.parent().closest(comparator);
3053
+ }
3054
+ });
3055
+
3056
+ luda.include({
3057
+ next: function(comparator, _all) {
3058
+ return luda(collect(unique(pluck(this.els, 'nextElementSibling', _all)), comparator));
3059
+ }
3060
+ });
3061
+
3062
+ luda.include({
3063
+ nextAll: function(comparator) {
3064
+ return this.next(comparator, true);
3065
+ }
3066
+ });
3067
+
3068
+ luda.include({
3069
+ prev: function(comparator, _al) {
3070
+ return luda(collect(unique(pluck(this.els, 'previousElementSibling', _al)), comparator));
3071
+ }
3072
+ });
3073
+
3074
+ luda.include({
3075
+ prevAll: function(comparator) {
3076
+ return this.prev(comparator, true);
3077
+ }
3078
+ });
3079
+
3080
+ luda.include({
3081
+ siblings: function(comparator) {
3082
+ var all;
3083
+ all = [];
3084
+ this.els.forEach(function(el) {
3085
+ var sibs;
3086
+ sibs = luda(el).parent().children(function(child) {
3087
+ return child !== el;
3088
+ }).els;
3089
+ return [].push.apply(all, sibs);
3090
+ });
3091
+ return luda(collect(unique(all), comparator));
3092
+ }
3093
+ });
3094
+
3095
+ })));