fomantic-ui 2.9.4-beta.9 → 2.9.4-beta.90

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 (273) hide show
  1. package/.all-contributorsrc +20 -1
  2. package/.eslintrc.js +17 -0
  3. package/.github/FUNDING.yml +1 -1
  4. package/.github/workflows/ci.yml +6 -6
  5. package/.github/workflows/depsreview.yml +14 -0
  6. package/.github/workflows/nightly.yml +1 -1
  7. package/.github/workflows/release.yml +1 -1
  8. package/CONTRIBUTORS.md +2 -0
  9. package/README.md +2 -12
  10. package/dist/components/accordion.css +1 -1
  11. package/dist/components/accordion.js +4 -2
  12. package/dist/components/accordion.min.css +1 -1
  13. package/dist/components/accordion.min.js +2 -2
  14. package/dist/components/ad.css +1 -1
  15. package/dist/components/ad.min.css +1 -1
  16. package/dist/components/api.js +7 -3
  17. package/dist/components/api.min.js +2 -2
  18. package/dist/components/breadcrumb.css +1 -1
  19. package/dist/components/breadcrumb.min.css +1 -1
  20. package/dist/components/button.css +21 -3
  21. package/dist/components/button.min.css +2 -2
  22. package/dist/components/calendar.css +1 -1
  23. package/dist/components/calendar.js +17 -4
  24. package/dist/components/calendar.min.css +1 -1
  25. package/dist/components/calendar.min.js +3 -3
  26. package/dist/components/card.css +1 -1
  27. package/dist/components/card.min.css +1 -1
  28. package/dist/components/checkbox.css +1 -1
  29. package/dist/components/checkbox.js +10 -4
  30. package/dist/components/checkbox.min.css +1 -1
  31. package/dist/components/checkbox.min.js +3 -3
  32. package/dist/components/comment.css +1 -1
  33. package/dist/components/comment.min.css +1 -1
  34. package/dist/components/container.css +1 -1
  35. package/dist/components/container.min.css +1 -1
  36. package/dist/components/dimmer.css +7 -3
  37. package/dist/components/dimmer.js +4 -2
  38. package/dist/components/dimmer.min.css +2 -2
  39. package/dist/components/dimmer.min.js +2 -2
  40. package/dist/components/divider.css +1 -1
  41. package/dist/components/divider.min.css +1 -1
  42. package/dist/components/dropdown.css +46 -38
  43. package/dist/components/dropdown.js +109 -34
  44. package/dist/components/dropdown.min.css +2 -2
  45. package/dist/components/dropdown.min.js +3 -3
  46. package/dist/components/embed.css +1 -1
  47. package/dist/components/embed.js +17 -7
  48. package/dist/components/embed.min.css +1 -1
  49. package/dist/components/embed.min.js +3 -3
  50. package/dist/components/emoji.css +4309 -3713
  51. package/dist/components/emoji.min.css +2 -2
  52. package/dist/components/feed.css +12 -1
  53. package/dist/components/feed.min.css +2 -2
  54. package/dist/components/flag.css +3 -1
  55. package/dist/components/flag.min.css +2 -2
  56. package/dist/components/flyout.css +1 -1
  57. package/dist/components/flyout.js +4 -2
  58. package/dist/components/flyout.min.css +1 -1
  59. package/dist/components/flyout.min.js +2 -2
  60. package/dist/components/form.css +15 -3
  61. package/dist/components/form.js +66 -23
  62. package/dist/components/form.min.css +2 -2
  63. package/dist/components/form.min.js +3 -3
  64. package/dist/components/grid.css +5 -5
  65. package/dist/components/grid.min.css +2 -2
  66. package/dist/components/header.css +1 -1
  67. package/dist/components/header.min.css +1 -1
  68. package/dist/components/icon.css +1 -1
  69. package/dist/components/icon.min.css +1 -1
  70. package/dist/components/image.css +1 -1
  71. package/dist/components/image.min.css +1 -1
  72. package/dist/components/input.css +1 -1
  73. package/dist/components/input.min.css +1 -1
  74. package/dist/components/item.css +1 -1
  75. package/dist/components/item.min.css +1 -1
  76. package/dist/components/label.css +7 -1
  77. package/dist/components/label.min.css +2 -2
  78. package/dist/components/list.css +1 -1
  79. package/dist/components/list.min.css +1 -1
  80. package/dist/components/loader.css +1 -1
  81. package/dist/components/loader.min.css +1 -1
  82. package/dist/components/menu.css +1 -1
  83. package/dist/components/menu.min.css +1 -1
  84. package/dist/components/message.css +2 -1
  85. package/dist/components/message.min.css +2 -2
  86. package/dist/components/modal.css +1 -1
  87. package/dist/components/modal.js +7 -3
  88. package/dist/components/modal.min.css +1 -1
  89. package/dist/components/modal.min.js +2 -2
  90. package/dist/components/nag.css +1 -1
  91. package/dist/components/nag.js +11 -5
  92. package/dist/components/nag.min.css +1 -1
  93. package/dist/components/nag.min.js +3 -3
  94. package/dist/components/placeholder.css +1 -1
  95. package/dist/components/placeholder.min.css +1 -1
  96. package/dist/components/popup.css +1 -1
  97. package/dist/components/popup.js +10 -4
  98. package/dist/components/popup.min.css +1 -1
  99. package/dist/components/popup.min.js +2 -2
  100. package/dist/components/progress.css +15 -6
  101. package/dist/components/progress.js +4 -2
  102. package/dist/components/progress.min.css +2 -2
  103. package/dist/components/progress.min.js +2 -2
  104. package/dist/components/rail.css +1 -1
  105. package/dist/components/rail.min.css +1 -1
  106. package/dist/components/rating.css +1 -1
  107. package/dist/components/rating.js +4 -2
  108. package/dist/components/rating.min.css +1 -1
  109. package/dist/components/rating.min.js +2 -2
  110. package/dist/components/reset.css +1 -1
  111. package/dist/components/reset.min.css +1 -1
  112. package/dist/components/reveal.css +1 -1
  113. package/dist/components/reveal.min.css +1 -1
  114. package/dist/components/search.css +1 -1
  115. package/dist/components/search.js +67 -14
  116. package/dist/components/search.min.css +1 -1
  117. package/dist/components/search.min.js +3 -3
  118. package/dist/components/segment.css +1 -1
  119. package/dist/components/segment.min.css +1 -1
  120. package/dist/components/shape.css +1 -1
  121. package/dist/components/shape.js +7 -5
  122. package/dist/components/shape.min.css +1 -1
  123. package/dist/components/shape.min.js +3 -3
  124. package/dist/components/sidebar.css +1 -1
  125. package/dist/components/sidebar.js +4 -2
  126. package/dist/components/sidebar.min.css +1 -1
  127. package/dist/components/sidebar.min.js +2 -2
  128. package/dist/components/site.css +14 -6
  129. package/dist/components/site.js +4 -2
  130. package/dist/components/site.min.css +2 -2
  131. package/dist/components/site.min.js +2 -2
  132. package/dist/components/slider.css +152 -2
  133. package/dist/components/slider.js +142 -44
  134. package/dist/components/slider.min.css +2 -2
  135. package/dist/components/slider.min.js +3 -3
  136. package/dist/components/state.js +4 -2
  137. package/dist/components/state.min.js +2 -2
  138. package/dist/components/statistic.css +1 -1
  139. package/dist/components/statistic.min.css +1 -1
  140. package/dist/components/step.css +992 -86
  141. package/dist/components/step.min.css +2 -2
  142. package/dist/components/sticky.css +1 -1
  143. package/dist/components/sticky.js +4 -2
  144. package/dist/components/sticky.min.css +1 -1
  145. package/dist/components/sticky.min.js +2 -2
  146. package/dist/components/tab.css +1 -1
  147. package/dist/components/tab.js +4 -2
  148. package/dist/components/tab.min.css +1 -1
  149. package/dist/components/tab.min.js +2 -2
  150. package/dist/components/table.css +32 -21
  151. package/dist/components/table.min.css +2 -2
  152. package/dist/components/text.css +1 -1
  153. package/dist/components/text.min.css +1 -1
  154. package/dist/components/toast.css +1 -1
  155. package/dist/components/toast.js +7 -3
  156. package/dist/components/toast.min.css +1 -1
  157. package/dist/components/toast.min.js +3 -3
  158. package/dist/components/transition.css +1 -1
  159. package/dist/components/transition.js +7 -3
  160. package/dist/components/transition.min.css +1 -1
  161. package/dist/components/transition.min.js +2 -2
  162. package/dist/components/visibility.js +4 -2
  163. package/dist/components/visibility.min.js +2 -2
  164. package/dist/semantic.css +6139 -3943
  165. package/dist/semantic.js +530 -180
  166. package/dist/semantic.min.css +3 -3
  167. package/dist/semantic.min.js +3 -3
  168. package/dist/themes/basic/assets/fonts/LICENSE.txt +91 -0
  169. package/dist/themes/default/assets/fonts/LICENSE_Lato.txt +94 -0
  170. package/dist/themes/default/assets/fonts/LICENSE_icons.txt +165 -0
  171. package/dist/themes/github/assets/fonts/LICENSE.txt +94 -0
  172. package/dist/themes/material/assets/fonts/LICENSE.txt +202 -0
  173. package/package.json +14 -14
  174. package/src/definitions/behaviors/api.js +6 -2
  175. package/src/definitions/behaviors/form.js +65 -22
  176. package/src/definitions/behaviors/state.js +3 -1
  177. package/src/definitions/behaviors/visibility.js +3 -1
  178. package/src/definitions/collections/form.less +9 -2
  179. package/src/definitions/collections/grid.less +4 -4
  180. package/src/definitions/collections/message.less +1 -0
  181. package/src/definitions/collections/table.less +69 -54
  182. package/src/definitions/elements/button.less +27 -3
  183. package/src/definitions/elements/label.less +5 -0
  184. package/src/definitions/elements/step.less +399 -85
  185. package/src/definitions/globals/site.js +3 -1
  186. package/src/definitions/globals/site.less +17 -12
  187. package/src/definitions/modules/accordion.js +3 -1
  188. package/src/definitions/modules/calendar.js +16 -3
  189. package/src/definitions/modules/checkbox.js +9 -3
  190. package/src/definitions/modules/dimmer.js +3 -1
  191. package/src/definitions/modules/dimmer.less +8 -5
  192. package/src/definitions/modules/dropdown.js +108 -33
  193. package/src/definitions/modules/dropdown.less +43 -29
  194. package/src/definitions/modules/embed.js +16 -6
  195. package/src/definitions/modules/flyout.js +3 -1
  196. package/src/definitions/modules/modal.js +6 -2
  197. package/src/definitions/modules/nag.js +10 -4
  198. package/src/definitions/modules/popup.js +9 -3
  199. package/src/definitions/modules/progress.js +3 -1
  200. package/src/definitions/modules/progress.less +17 -5
  201. package/src/definitions/modules/rating.js +3 -1
  202. package/src/definitions/modules/search.js +66 -13
  203. package/src/definitions/modules/search.less +9 -2
  204. package/src/definitions/modules/shape.js +6 -4
  205. package/src/definitions/modules/sidebar.js +3 -1
  206. package/src/definitions/modules/slider.js +141 -43
  207. package/src/definitions/modules/slider.less +103 -8
  208. package/src/definitions/modules/sticky.js +3 -1
  209. package/src/definitions/modules/tab.js +3 -1
  210. package/src/definitions/modules/toast.js +6 -2
  211. package/src/definitions/modules/transition.js +6 -2
  212. package/src/definitions/views/feed.less +11 -0
  213. package/src/themes/basic/assets/fonts/LICENSE.txt +91 -0
  214. package/src/themes/default/assets/fonts/LICENSE_Lato.txt +94 -0
  215. package/src/themes/default/assets/fonts/LICENSE_icons.txt +165 -0
  216. package/src/themes/default/elements/button.variables +3 -0
  217. package/src/themes/default/elements/emoji.variables +172 -23
  218. package/src/themes/default/elements/flag.variables +3 -3
  219. package/src/themes/default/elements/step.variables +33 -0
  220. package/src/themes/default/globals/site.variables +3 -0
  221. package/src/themes/default/globals/variation.variables +9 -0
  222. package/src/themes/default/modules/dropdown.variables +3 -0
  223. package/src/themes/default/modules/progress.variables +1 -1
  224. package/src/themes/default/modules/search.variables +3 -0
  225. package/src/themes/default/modules/slider.variables +10 -0
  226. package/src/themes/default/views/feed.variables +3 -0
  227. package/src/themes/github/assets/fonts/LICENSE.txt +94 -0
  228. package/src/themes/joypixels/elements/emoji.variables +183 -22
  229. package/src/themes/material/assets/fonts/LICENSE.txt +202 -0
  230. package/tasks/admin/components/create.js +4 -4
  231. package/tasks/admin/components/init.js +2 -2
  232. package/tasks/admin/components/update.js +3 -3
  233. package/tasks/admin/distributions/create.js +3 -3
  234. package/tasks/admin/distributions/init.js +2 -2
  235. package/tasks/admin/distributions/update.js +4 -4
  236. package/tasks/build/assets.js +1 -1
  237. package/tasks/build/css.js +19 -10
  238. package/tasks/build/javascript.js +12 -5
  239. package/tasks/check-install.js +1 -1
  240. package/tasks/config/defaults.js +2 -0
  241. package/tasks/config/tasks.js +1 -1
  242. package/tasks/docs/build.js +3 -3
  243. package/tasks/docs/metadata.js +1 -1
  244. package/tasks/docs/serve.js +3 -1
  245. package/tasks/install.js +2 -2
  246. package/tasks/watch.js +1 -1
  247. package/types/fomantic-ui-accordion.d.ts +1 -1
  248. package/types/fomantic-ui-api.d.ts +9 -3
  249. package/types/fomantic-ui-calendar.d.ts +110 -9
  250. package/types/fomantic-ui-checkbox.d.ts +14 -4
  251. package/types/fomantic-ui-dimmer.d.ts +1 -1
  252. package/types/fomantic-ui-dropdown.d.ts +82 -44
  253. package/types/fomantic-ui-embed.d.ts +19 -2
  254. package/types/fomantic-ui-flyout.d.ts +25 -11
  255. package/types/fomantic-ui-form.d.ts +123 -15
  256. package/types/fomantic-ui-modal.d.ts +101 -5
  257. package/types/fomantic-ui-nag.d.ts +4 -4
  258. package/types/fomantic-ui-popup.d.ts +38 -12
  259. package/types/fomantic-ui-progress.d.ts +12 -6
  260. package/types/fomantic-ui-rating.d.ts +1 -1
  261. package/types/fomantic-ui-search.d.ts +138 -22
  262. package/types/fomantic-ui-shape.d.ts +2 -2
  263. package/types/fomantic-ui-sidebar.d.ts +4 -4
  264. package/types/fomantic-ui-slider.d.ts +56 -4
  265. package/types/fomantic-ui-sticky.d.ts +1 -1
  266. package/types/fomantic-ui-tab.d.ts +6 -6
  267. package/types/fomantic-ui-toast.d.ts +14 -2
  268. package/types/fomantic-ui-transition.d.ts +41 -7
  269. package/types/fomantic-ui-visibility.d.ts +3 -3
  270. package/types/index.d.ts +25 -25
  271. package/types/tests.ts +188 -0
  272. package/types/tsconfig.json +1 -1
  273. package/types/fomantic-ui-tests.ts +0 -25
@@ -292,7 +292,9 @@
292
292
  });
293
293
  }
294
294
  clearTimeout(module.performance.timer);
295
- module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
295
+ module.performance.timer = setTimeout(function () {
296
+ module.performance.display();
297
+ }, 500);
296
298
  },
297
299
  display: function () {
298
300
  var
@@ -148,18 +148,21 @@ a:hover {
148
148
  body ::-webkit-scrollbar-thumb:hover {
149
149
  background: @thumbHoverBackground;
150
150
  }
151
- body .ui {
152
- & when (@supportIE) {
151
+ & when (@supportIE) {
152
+ body .ui {
153
153
  /* IE11 */
154
154
  scrollbar-face-color: @thumbBackgroundHex;
155
155
  scrollbar-shadow-color: @thumbBackgroundHex;
156
156
  scrollbar-track-color: @trackBackgroundHex;
157
157
  scrollbar-arrow-color: @trackBackgroundHex;
158
158
  }
159
-
160
- /* firefox: first color thumb, second track */
161
- scrollbar-color: @thumbBackground @trackBackground;
162
- scrollbar-width: thin;
159
+ }
160
+ @supports (-moz-appearance: none) {
161
+ body .ui {
162
+ /* firefox: first color thumb, second track */
163
+ scrollbar-color: @thumbBackground @trackBackground;
164
+ scrollbar-width: thin;
165
+ }
163
166
  }
164
167
 
165
168
  /* Inverted UI */
@@ -175,18 +178,20 @@ a:hover {
175
178
  body .ui.inverted:not(.dimmer)::-webkit-scrollbar-thumb:hover {
176
179
  background: @thumbInvertedHoverBackground;
177
180
  }
178
-
179
- body .ui.inverted:not(.dimmer) {
180
- & when (@supportIE) {
181
+ & when (@supportIE) {
182
+ body .ui.inverted:not(.dimmer) {
181
183
  /* IE11 */
182
184
  scrollbar-face-color: @thumbInvertedBackgroundHex;
183
185
  scrollbar-shadow-color: @thumbInvertedBackgroundHex;
184
186
  scrollbar-track-color: @trackInvertedBackgroundHex;
185
187
  scrollbar-arrow-color: @trackInvertedBackgroundHex;
186
188
  }
187
-
188
- /* firefox: first color thumb, second track */
189
- scrollbar-color: @thumbInvertedBackground @trackInvertedBackground;
189
+ }
190
+ @supports (-moz-appearance: none) {
191
+ body .ui.inverted:not(.dimmer) {
192
+ /* firefox: first color thumb, second track */
193
+ scrollbar-color: @thumbInvertedBackground @trackInvertedBackground;
194
+ }
190
195
  }
191
196
  }
192
197
 
@@ -438,7 +438,9 @@
438
438
  });
439
439
  }
440
440
  clearTimeout(module.performance.timer);
441
- module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
441
+ module.performance.timer = setTimeout(function () {
442
+ module.performance.display();
443
+ }, 500);
442
444
  },
443
445
  display: function () {
444
446
  var
@@ -102,7 +102,17 @@
102
102
 
103
103
  destroy: function () {
104
104
  module.verbose('Destroying previous calendar for', element);
105
- $module.removeData(moduleNamespace);
105
+ $module.removeData([
106
+ metadata.date,
107
+ metadata.focusDate,
108
+ metadata.startDate,
109
+ metadata.endDate,
110
+ metadata.minDate,
111
+ metadata.maxDate,
112
+ metadata.mode,
113
+ metadata.monthOffset,
114
+ moduleNamespace,
115
+ ]);
106
116
  module.unbind.events();
107
117
  module.disconnect.classObserver();
108
118
  },
@@ -1479,7 +1489,9 @@
1479
1489
  });
1480
1490
  }
1481
1491
  clearTimeout(module.performance.timer);
1482
- module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
1492
+ module.performance.timer = setTimeout(function () {
1493
+ module.performance.display();
1494
+ }, 500);
1483
1495
  },
1484
1496
  display: function () {
1485
1497
  var
@@ -1687,7 +1699,8 @@
1687
1699
  text = settings.monthFirst || !/^\d{1,2}[./-]/.test(text) ? text : text.replace(/[./-]/g, '/').replace(/(\d+)\/(\d+)/, '$2/$1');
1688
1700
  var textDate = new Date(text);
1689
1701
  var numberOnly = text.match(/^\d+$/) !== null;
1690
- if (!numberOnly && !isNaN(textDate.getDate())) {
1702
+ var isShortYear = text.match(/^(?:\d{1,2}[./-]){2}\d{1,2}$/) !== null;
1703
+ if (!isShortYear && !numberOnly && !isNaN(textDate.getDate())) {
1691
1704
  return textDate;
1692
1705
  }
1693
1706
  text = text.toLowerCase();
@@ -210,7 +210,7 @@
210
210
  ;
211
211
 
212
212
  var
213
- r = module.get.radios(),
213
+ r = module.get.radios().not(selector.disabled),
214
214
  rIndex = r.index($module),
215
215
  rLen = r.length,
216
216
  checkIndex = false
@@ -228,7 +228,10 @@
228
228
 
229
229
  return false;
230
230
  }
231
- if (settings.beforeChecked.apply($(r[checkIndex]).children(selector.input)[0]) === false) {
231
+ var nextOption = $(r[checkIndex]),
232
+ nextInput = nextOption.children(selector.input),
233
+ disallowOption = nextOption.hasClass(className.readOnly) || nextInput.prop('readonly');
234
+ if (disallowOption || settings.beforeChecked.apply(nextInput[0]) === false) {
232
235
  module.verbose('Next option should not allow check, cancelling key navigation');
233
236
 
234
237
  return false;
@@ -725,7 +728,9 @@
725
728
  });
726
729
  }
727
730
  clearTimeout(module.performance.timer);
728
- module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
731
+ module.performance.timer = setTimeout(function () {
732
+ module.performance.display();
733
+ }, 500);
729
734
  },
730
735
  display: function () {
731
736
  var
@@ -873,6 +878,7 @@
873
878
 
874
879
  selector: {
875
880
  checkbox: '.ui.checkbox',
881
+ disabled: '.disabled, :has(input[disabled])',
876
882
  label: 'label',
877
883
  input: 'input[type="checkbox"], input[type="radio"]',
878
884
  link: 'a[href]',
@@ -528,7 +528,9 @@
528
528
  });
529
529
  }
530
530
  clearTimeout(module.performance.timer);
531
- module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
531
+ module.performance.timer = setTimeout(function () {
532
+ module.performance.display();
533
+ }, 500);
532
534
  },
533
535
  display: function () {
534
536
  var
@@ -74,17 +74,20 @@
74
74
  .ui.dimmer:not(.inverted)::-webkit-scrollbar-thumb:hover {
75
75
  background: @thumbInvertedHoverBackground;
76
76
  }
77
- .ui.dimmer:not(.inverted) {
78
- & when (@supportIE) {
77
+ & when (@supportIE) {
78
+ .ui.dimmer:not(.inverted) {
79
79
  /* IE11 */
80
80
  scrollbar-face-color: @thumbInvertedBackgroundHex;
81
81
  scrollbar-shadow-color: @thumbInvertedBackgroundHex;
82
82
  scrollbar-track-color: @trackInvertedBackgroundHex;
83
83
  scrollbar-arrow-color: @trackInvertedBackgroundHex;
84
84
  }
85
-
86
- /* firefox: first color thumb, second track */
87
- scrollbar-color: @thumbInvertedBackground @trackInvertedBackground;
85
+ }
86
+ @supports (-moz-appearance: none) {
87
+ .ui.dimmer:not(.inverted) {
88
+ /* firefox: first color thumb, second track */
89
+ scrollbar-color: @thumbInvertedBackground @trackInvertedBackground;
90
+ }
88
91
  }
89
92
  }
90
93
 
@@ -127,6 +127,9 @@
127
127
  module.change.values(settings.values);
128
128
  module.remove.initialLoad();
129
129
  }
130
+ if (module.get.placeholderText() !== '') {
131
+ module.set.placeholderText();
132
+ }
130
133
 
131
134
  module.refreshData();
132
135
 
@@ -793,7 +796,7 @@
793
796
  }
794
797
  if (module.is.multiple()) {
795
798
  $.each(preSelected, function (index, value) {
796
- $item.filter('[data-value="' + value + '"]')
799
+ $item.filter('[data-' + metadata.value + '="' + value + '"]')
797
800
  .addClass(className.filtered)
798
801
  ;
799
802
  });
@@ -890,11 +893,13 @@
890
893
  ? query
891
894
  : module.get.query()
892
895
  ),
893
- results = null,
894
- escapedTerm = module.escape.string(searchTerm),
895
- regExpFlags = (settings.ignoreSearchCase ? 'i' : '') + 'gm',
896
+ results = null,
897
+ escapedTerm = module.escape.string(searchTerm),
898
+ regExpIgnore = settings.ignoreSearchCase ? 'i' : '',
899
+ regExpFlags = regExpIgnore + 'gm',
896
900
  beginsWithRegExp = new RegExp('^' + escapedTerm, regExpFlags)
897
901
  ;
902
+ module.remove.filteredItem();
898
903
  // avoid loop if we're matching nothing
899
904
  if (module.has.query()) {
900
905
  results = [];
@@ -938,12 +943,34 @@
938
943
  ;
939
944
  }
940
945
  module.debug('Showing only matched items', searchTerm);
941
- module.remove.filteredItem();
942
946
  if (results) {
943
947
  $item
944
948
  .not(results)
945
949
  .addClass(className.filtered)
946
950
  ;
951
+ if (settings.highlightMatches && (settings.match === 'both' || settings.match === 'text')) {
952
+ var querySplit = query.split(''),
953
+ diacriticReg = settings.ignoreDiacritics ? '[\u0300-\u036F]?' : '',
954
+ htmlReg = '(?![^<]*>)',
955
+ markedRegExp = new RegExp(htmlReg + '(' + querySplit.join(diacriticReg + ')(.*?)' + htmlReg + '(') + diacriticReg + ')', regExpIgnore),
956
+ markedReplacer = function () {
957
+ var args = [].slice.call(arguments, 1, querySplit.length * 2).map(function (x, i) {
958
+ return i & 1 ? x : '<mark>' + x + '</mark>'; // eslint-disable-line no-bitwise
959
+ });
960
+
961
+ return args.join('');
962
+ }
963
+ ;
964
+ $.each(results, function (index, result) {
965
+ var $result = $(result),
966
+ markedHTML = module.get.choiceText($result, true)
967
+ ;
968
+ if (settings.ignoreDiacritics) {
969
+ markedHTML = markedHTML.normalize('NFD');
970
+ }
971
+ $result.html(markedHTML.replace(markedRegExp, markedReplacer));
972
+ });
973
+ }
947
974
  }
948
975
 
949
976
  if (!module.has.query()) {
@@ -979,8 +1006,10 @@
979
1006
  termLength = term.length,
980
1007
  queryLength = query.length
981
1008
  ;
982
- query = settings.ignoreSearchCase ? query.toLowerCase() : query;
983
- term = settings.ignoreSearchCase ? term.toLowerCase() : term;
1009
+ if (settings.ignoreSearchCase) {
1010
+ query = query.toLowerCase();
1011
+ term = term.toLowerCase();
1012
+ }
984
1013
  if (queryLength > termLength) {
985
1014
  return false;
986
1015
  }
@@ -1187,7 +1216,7 @@
1187
1216
  if (!itemActivated && !pageLostFocus) {
1188
1217
  if (settings.forceSelection) {
1189
1218
  module.forceSelection();
1190
- } else if (!settings.allowAdditions) {
1219
+ } else if (!settings.allowAdditions && !settings.keepSearchTerm && !module.has.menuSearch()) {
1191
1220
  module.remove.searchTerm();
1192
1221
  }
1193
1222
  module.hide();
@@ -1202,7 +1231,9 @@
1202
1231
  if (module.is.searchSelection()) {
1203
1232
  module.remove.searchTerm();
1204
1233
  }
1205
- module.hide();
1234
+ if (settings.collapseOnClearable) {
1235
+ module.hide();
1236
+ }
1206
1237
  event.stopPropagation();
1207
1238
  },
1208
1239
  },
@@ -1236,7 +1267,9 @@
1236
1267
  module.set.filtered();
1237
1268
  }
1238
1269
  clearTimeout(module.timer);
1239
- module.timer = setTimeout(function () { module.search(); }, settings.delay.search);
1270
+ module.timer = setTimeout(function () {
1271
+ module.search();
1272
+ }, settings.delay.search);
1240
1273
  },
1241
1274
  label: {
1242
1275
  click: function (event) {
@@ -1413,7 +1446,9 @@
1413
1446
  module.remove.userAddition();
1414
1447
  }
1415
1448
  if (!settings.keepSearchTerm) {
1416
- module.remove.filteredItem();
1449
+ if (module.is.multiple()) {
1450
+ module.remove.filteredItem();
1451
+ }
1417
1452
  module.remove.searchTerm();
1418
1453
  }
1419
1454
  if (!module.is.visible() && $target.length > 0) {
@@ -2587,7 +2622,7 @@
2587
2622
  } else {
2588
2623
  $combo.text(text);
2589
2624
  }
2590
- } else if (settings.action === 'activate') {
2625
+ } else if (settings.action === 'activate' || isFunction(settings.action)) {
2591
2626
  if (text !== module.get.placeholderText() || isNotPlaceholder) {
2592
2627
  $text.removeClass(className.placeholder);
2593
2628
  }
@@ -2647,7 +2682,7 @@
2647
2682
  module.set.scrollPosition($nextValue);
2648
2683
  $selectedItem.removeClass(className.selected);
2649
2684
  $nextValue.addClass(className.selected);
2650
- if (settings.selectOnKeydown && module.is.single() && !$nextItem.hasClass(className.actionable)) {
2685
+ if (settings.selectOnKeydown && module.is.single() && (!$nextItem || !$nextItem.hasClass(className.actionable))) {
2651
2686
  module.set.selectedItem($nextValue);
2652
2687
  }
2653
2688
  }
@@ -2768,19 +2803,27 @@
2768
2803
  $selectedItem = settings.allowAdditions
2769
2804
  ? $selectedItem || module.get.itemWithAdditions(value)
2770
2805
  : $selectedItem || module.get.item(value);
2771
- if (!$selectedItem) {
2806
+ if (!$selectedItem && value !== undefined) {
2772
2807
  return false;
2773
2808
  }
2774
- module.debug('Setting selected menu item to', $selectedItem);
2775
- if (module.is.multiple() && !keepSearchTerm) {
2776
- module.remove.searchWidth();
2777
- }
2778
- if (module.is.single()) {
2809
+ if (isMultiple) {
2810
+ if (!keepSearchTerm) {
2811
+ module.remove.searchWidth();
2812
+ }
2813
+ if (settings.useLabels) {
2814
+ module.remove.selectedItem();
2815
+ if (value === undefined) {
2816
+ module.remove.labels($module.find(selector.label), true);
2817
+ }
2818
+ }
2819
+ } else {
2779
2820
  module.remove.activeItem();
2780
2821
  module.remove.selectedItem();
2781
- } else if (settings.useLabels) {
2782
- module.remove.selectedItem();
2783
2822
  }
2823
+ if (!$selectedItem) {
2824
+ return false;
2825
+ }
2826
+ module.debug('Setting selected menu item to', $selectedItem);
2784
2827
  // select each item
2785
2828
  $selectedItem
2786
2829
  .each(function () {
@@ -3080,6 +3123,12 @@
3080
3123
  $item.removeClass(className.active);
3081
3124
  },
3082
3125
  filteredItem: function () {
3126
+ if (settings.highlightMatches) {
3127
+ $.each($item, function (index, item) {
3128
+ var $markItem = $(item);
3129
+ $markItem.html($markItem.html().replace(/<\/?mark>/g, ''));
3130
+ });
3131
+ }
3083
3132
  if (settings.useLabels && module.has.maxSelections()) {
3084
3133
  return;
3085
3134
  }
@@ -3424,7 +3473,12 @@
3424
3473
  return $selectedMenu.hasClass(className.leftward);
3425
3474
  },
3426
3475
  clearable: function () {
3427
- return $module.hasClass(className.clearable) || settings.clearable;
3476
+ var hasClearableClass = $module.hasClass(className.clearable);
3477
+ if (!hasClearableClass && settings.clearable) {
3478
+ $module.addClass(className.clearable);
3479
+ }
3480
+
3481
+ return hasClearableClass || settings.clearable;
3428
3482
  },
3429
3483
  disabled: function () {
3430
3484
  return $module.hasClass(className.disabled);
@@ -3747,12 +3801,16 @@
3747
3801
  show: function () {
3748
3802
  module.verbose('Delaying show event to ensure user intent');
3749
3803
  clearTimeout(module.timer);
3750
- module.timer = setTimeout(function () { module.show(); }, settings.delay.show);
3804
+ module.timer = setTimeout(function () {
3805
+ module.show();
3806
+ }, settings.delay.show);
3751
3807
  },
3752
3808
  hide: function () {
3753
3809
  module.verbose('Delaying hide event to ensure user intent');
3754
3810
  clearTimeout(module.timer);
3755
- module.timer = setTimeout(function () { module.hide(); }, settings.delay.hide);
3811
+ module.timer = setTimeout(function () {
3812
+ module.hide();
3813
+ }, settings.delay.hide);
3756
3814
  },
3757
3815
  },
3758
3816
 
@@ -3785,6 +3843,7 @@
3785
3843
  return text.replace(regExp.escape, '\\$&');
3786
3844
  },
3787
3845
  htmlEntities: function (string, forceAmpersand) {
3846
+ forceAmpersand = typeof forceAmpersand === 'number' ? false : forceAmpersand;
3788
3847
  var
3789
3848
  badChars = /["'<>`]/g,
3790
3849
  shouldEscape = /["&'<>`]/,
@@ -3801,8 +3860,7 @@
3801
3860
  ;
3802
3861
  if (shouldEscape.test(string)) {
3803
3862
  string = string.replace(forceAmpersand ? /&/g : /&(?![\d#a-z]{1,12};)/gi, '&amp;');
3804
-
3805
- return string.replace(badChars, escapedChar);
3863
+ string = string.replace(badChars, escapedChar);
3806
3864
  }
3807
3865
 
3808
3866
  return string;
@@ -3878,7 +3936,9 @@
3878
3936
  });
3879
3937
  }
3880
3938
  clearTimeout(module.performance.timer);
3881
- module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
3939
+ module.performance.timer = setTimeout(function () {
3940
+ module.performance.display();
3941
+ }, 500);
3882
3942
  },
3883
3943
  display: function () {
3884
3944
  var
@@ -4005,6 +4065,7 @@
4005
4065
 
4006
4066
  match: 'both', // what to match against with search selection (both, text, or label)
4007
4067
  fullTextSearch: 'exact', // search anywhere in value (set to 'exact' to require exact matches)
4068
+ highlightMatches: false, // Whether search result should highlight matching strings
4008
4069
  ignoreDiacritics: false, // match results also if they contain diacritics of the same base character (for example searching for "a" will also match "á" or "â" or "à", etc...)
4009
4070
  hideDividers: false, // Whether to hide any divider elements (specified in selector.divider) that are sibling to any items when searched (set to true will hide all dividers, set to 'empty' will hide them when they are not followed by a visible item)
4010
4071
 
@@ -4038,6 +4099,7 @@
4038
4099
  headerDivider: true, // whether option headers should have an additional divider line underneath when converted from <select> <optgroup>
4039
4100
 
4040
4101
  collapseOnActionable: true, // whether the dropdown should collapse upon selection of an actionable item
4102
+ collapseOnClearable: false, // whether the dropdown should collapse upon clicking the clearable icon
4041
4103
 
4042
4104
  // label settings on multi-select
4043
4105
  label: {
@@ -4120,9 +4182,11 @@
4120
4182
  descriptionVertical: 'descriptionVertical', // whether description should be vertical
4121
4183
  value: 'value', // actual dropdown value
4122
4184
  text: 'text', // displayed text when selected
4185
+ data: 'data', // custom data attributes
4123
4186
  type: 'type', // type of dropdown element
4124
4187
  image: 'image', // optional image path
4125
4188
  imageClass: 'imageClass', // optional individual class for image
4189
+ alt: 'alt', // optional alt text for image
4126
4190
  icon: 'icon', // optional icon name
4127
4191
  iconClass: 'iconClass', // optional individual class for icon (for example to use flag instead)
4128
4192
  class: 'class', // optional individual class for item/header
@@ -4229,8 +4293,7 @@
4229
4293
  ;
4230
4294
  if (shouldEscape.test(string)) {
4231
4295
  string = string.replace(/&(?![\d#a-z]{1,12};)/gi, '&amp;');
4232
-
4233
- return string.replace(badChars, escapedChar);
4296
+ string = string.replace(badChars, escapedChar);
4234
4297
  }
4235
4298
 
4236
4299
  return string;
@@ -4265,9 +4328,21 @@
4265
4328
  $.each(values, function (index, option) {
4266
4329
  var
4267
4330
  itemType = option[fields.type] || 'item',
4268
- isMenu = itemType.indexOf('menu') !== -1
4331
+ isMenu = itemType.indexOf('menu') !== -1,
4332
+ maybeData = '',
4333
+ dataObject = option[fields.data]
4269
4334
  ;
4270
-
4335
+ if (dataObject) {
4336
+ var dataKey,
4337
+ dataKeyEscaped
4338
+ ;
4339
+ for (dataKey in dataObject) {
4340
+ dataKeyEscaped = String(dataKey).replace(/\W/g, '');
4341
+ if (Object.prototype.hasOwnProperty.call(dataObject, dataKey) && ['text', 'value'].indexOf(dataKeyEscaped.toLowerCase()) === -1) {
4342
+ maybeData += ' data-' + dataKeyEscaped + '="' + deQuote(String(dataObject[dataKey])) + '"';
4343
+ }
4344
+ }
4345
+ }
4271
4346
  if (itemType === 'item' || isMenu) {
4272
4347
  var
4273
4348
  maybeText = option[fields.text]
@@ -4284,12 +4359,12 @@
4284
4359
  : '',
4285
4360
  hasDescription = escape(option[fields.description] || '', preserveHTML) !== ''
4286
4361
  ;
4287
- html += '<div class="' + deQuote(maybeActionable + maybeDisabled + maybeDescriptionVertical + (option[fields.class] || className.item)) + '" data-value="' + deQuote(option[fields.value], true) + '"' + maybeText + '>';
4362
+ html += '<div class="' + deQuote(maybeActionable + maybeDisabled + maybeDescriptionVertical + (option[fields.class] || className.item)) + '" data-value="' + deQuote(option[fields.value], true) + '"' + maybeText + maybeData + '>';
4288
4363
  if (isMenu) {
4289
4364
  html += '<i class="' + (itemType.indexOf('left') !== -1 ? 'left' : '') + ' dropdown icon"></i>';
4290
4365
  }
4291
4366
  if (option[fields.image]) {
4292
- html += '<img class="' + deQuote(option[fields.imageClass] || className.image) + '" src="' + deQuote(option[fields.image]) + '">';
4367
+ html += '<img class="' + deQuote(option[fields.imageClass] || className.image) + '" src="' + deQuote(option[fields.image]) + (option[fields.alt] ? '" alt="' + deQuote(option[fields.alt]) : '') + '">';
4293
4368
  }
4294
4369
  if (option[fields.icon]) {
4295
4370
  html += '<i class="' + deQuote(option[fields.icon] + ' ' + (option[fields.iconClass] || className.icon)) + '"></i>';