fomantic-ui 2.9.4-beta.7 → 2.9.4-beta.70

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 (265) 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 +5 -5
  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 +15 -3
  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 +104 -33
  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 +1 -1
  51. package/dist/components/emoji.min.css +1 -1
  52. package/dist/components/feed.css +12 -1
  53. package/dist/components/feed.min.css +2 -2
  54. package/dist/components/flag.css +1 -1
  55. package/dist/components/flag.min.css +1 -1
  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 +1 -1
  77. package/dist/components/label.min.css +1 -1
  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 +1 -1
  133. package/dist/components/slider.js +4 -2
  134. package/dist/components/slider.min.css +1 -1
  135. package/dist/components/slider.min.js +2 -2
  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 +1 -1
  141. package/dist/components/step.min.css +1 -1
  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 +234 -132
  165. package/dist/semantic.js +385 -136
  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/globals/site.js +3 -1
  184. package/src/definitions/globals/site.less +17 -12
  185. package/src/definitions/modules/accordion.js +3 -1
  186. package/src/definitions/modules/calendar.js +14 -2
  187. package/src/definitions/modules/checkbox.js +9 -3
  188. package/src/definitions/modules/dimmer.js +3 -1
  189. package/src/definitions/modules/dimmer.less +8 -5
  190. package/src/definitions/modules/dropdown.js +103 -32
  191. package/src/definitions/modules/dropdown.less +43 -29
  192. package/src/definitions/modules/embed.js +16 -6
  193. package/src/definitions/modules/flyout.js +3 -1
  194. package/src/definitions/modules/modal.js +6 -2
  195. package/src/definitions/modules/nag.js +10 -4
  196. package/src/definitions/modules/popup.js +9 -3
  197. package/src/definitions/modules/progress.js +3 -1
  198. package/src/definitions/modules/progress.less +17 -5
  199. package/src/definitions/modules/rating.js +3 -1
  200. package/src/definitions/modules/search.js +66 -13
  201. package/src/definitions/modules/search.less +9 -2
  202. package/src/definitions/modules/shape.js +6 -4
  203. package/src/definitions/modules/sidebar.js +3 -1
  204. package/src/definitions/modules/slider.js +3 -1
  205. package/src/definitions/modules/sticky.js +3 -1
  206. package/src/definitions/modules/tab.js +3 -1
  207. package/src/definitions/modules/toast.js +6 -2
  208. package/src/definitions/modules/transition.js +6 -2
  209. package/src/definitions/views/feed.less +11 -0
  210. package/src/themes/basic/assets/fonts/LICENSE.txt +91 -0
  211. package/src/themes/default/assets/fonts/LICENSE_Lato.txt +94 -0
  212. package/src/themes/default/assets/fonts/LICENSE_icons.txt +165 -0
  213. package/src/themes/default/elements/button.variables +3 -0
  214. package/src/themes/default/globals/site.variables +3 -0
  215. package/src/themes/default/globals/variation.variables +3 -0
  216. package/src/themes/default/modules/dropdown.variables +3 -0
  217. package/src/themes/default/modules/progress.variables +1 -1
  218. package/src/themes/default/modules/search.variables +3 -0
  219. package/src/themes/default/views/feed.variables +3 -0
  220. package/src/themes/github/assets/fonts/LICENSE.txt +94 -0
  221. package/src/themes/material/assets/fonts/LICENSE.txt +202 -0
  222. package/tasks/admin/components/create.js +4 -4
  223. package/tasks/admin/components/init.js +2 -2
  224. package/tasks/admin/components/update.js +3 -3
  225. package/tasks/admin/distributions/create.js +3 -3
  226. package/tasks/admin/distributions/init.js +2 -2
  227. package/tasks/admin/distributions/update.js +4 -4
  228. package/tasks/build/assets.js +1 -1
  229. package/tasks/build/css.js +19 -10
  230. package/tasks/build/javascript.js +12 -5
  231. package/tasks/check-install.js +1 -1
  232. package/tasks/config/defaults.js +2 -0
  233. package/tasks/config/tasks.js +1 -1
  234. package/tasks/docs/build.js +3 -3
  235. package/tasks/docs/metadata.js +1 -1
  236. package/tasks/docs/serve.js +3 -1
  237. package/tasks/install.js +2 -2
  238. package/tasks/watch.js +1 -1
  239. package/types/fomantic-ui-accordion.d.ts +1 -1
  240. package/types/fomantic-ui-api.d.ts +9 -3
  241. package/types/fomantic-ui-calendar.d.ts +110 -9
  242. package/types/fomantic-ui-checkbox.d.ts +14 -4
  243. package/types/fomantic-ui-dimmer.d.ts +1 -1
  244. package/types/fomantic-ui-dropdown.d.ts +76 -44
  245. package/types/fomantic-ui-embed.d.ts +19 -2
  246. package/types/fomantic-ui-flyout.d.ts +25 -11
  247. package/types/fomantic-ui-form.d.ts +123 -15
  248. package/types/fomantic-ui-modal.d.ts +101 -5
  249. package/types/fomantic-ui-nag.d.ts +4 -4
  250. package/types/fomantic-ui-popup.d.ts +38 -12
  251. package/types/fomantic-ui-progress.d.ts +12 -6
  252. package/types/fomantic-ui-rating.d.ts +1 -1
  253. package/types/fomantic-ui-search.d.ts +138 -22
  254. package/types/fomantic-ui-shape.d.ts +2 -2
  255. package/types/fomantic-ui-sidebar.d.ts +4 -4
  256. package/types/fomantic-ui-slider.d.ts +2 -2
  257. package/types/fomantic-ui-sticky.d.ts +1 -1
  258. package/types/fomantic-ui-tab.d.ts +6 -6
  259. package/types/fomantic-ui-toast.d.ts +14 -2
  260. package/types/fomantic-ui-transition.d.ts +41 -7
  261. package/types/fomantic-ui-visibility.d.ts +3 -3
  262. package/types/index.d.ts +25 -25
  263. package/types/tests.ts +188 -0
  264. package/types/tsconfig.json +1 -1
  265. package/types/fomantic-ui-tests.ts +0 -25
@@ -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
@@ -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
 
@@ -126,6 +126,8 @@
126
126
  module.set.initialLoad();
127
127
  module.change.values(settings.values);
128
128
  module.remove.initialLoad();
129
+ } else if (module.get.placeholderText() !== '') {
130
+ module.set.placeholderText();
129
131
  }
130
132
 
131
133
  module.refreshData();
@@ -793,7 +795,7 @@
793
795
  }
794
796
  if (module.is.multiple()) {
795
797
  $.each(preSelected, function (index, value) {
796
- $item.filter('[data-value="' + value + '"]')
798
+ $item.filter('[data-' + metadata.value + '="' + value + '"]')
797
799
  .addClass(className.filtered)
798
800
  ;
799
801
  });
@@ -890,11 +892,13 @@
890
892
  ? query
891
893
  : module.get.query()
892
894
  ),
893
- results = null,
894
- escapedTerm = module.escape.string(searchTerm),
895
- regExpFlags = (settings.ignoreSearchCase ? 'i' : '') + 'gm',
895
+ results = null,
896
+ escapedTerm = module.escape.string(searchTerm),
897
+ regExpIgnore = settings.ignoreSearchCase ? 'i' : '',
898
+ regExpFlags = regExpIgnore + 'gm',
896
899
  beginsWithRegExp = new RegExp('^' + escapedTerm, regExpFlags)
897
900
  ;
901
+ module.remove.filteredItem();
898
902
  // avoid loop if we're matching nothing
899
903
  if (module.has.query()) {
900
904
  results = [];
@@ -938,12 +942,34 @@
938
942
  ;
939
943
  }
940
944
  module.debug('Showing only matched items', searchTerm);
941
- module.remove.filteredItem();
942
945
  if (results) {
943
946
  $item
944
947
  .not(results)
945
948
  .addClass(className.filtered)
946
949
  ;
950
+ if (settings.highlightMatches && (settings.match === 'both' || settings.match === 'text')) {
951
+ var querySplit = query.split(''),
952
+ diacriticReg = settings.ignoreDiacritics ? '[\u0300-\u036F]?' : '',
953
+ htmlReg = '(?![^<]*>)',
954
+ markedRegExp = new RegExp(htmlReg + '(' + querySplit.join(diacriticReg + ')(.*?)' + htmlReg + '(') + diacriticReg + ')', regExpIgnore),
955
+ markedReplacer = function () {
956
+ var args = [].slice.call(arguments, 1, querySplit.length * 2).map(function (x, i) {
957
+ return i & 1 ? x : '<mark>' + x + '</mark>'; // eslint-disable-line no-bitwise
958
+ });
959
+
960
+ return args.join('');
961
+ }
962
+ ;
963
+ $.each(results, function (index, result) {
964
+ var $result = $(result),
965
+ markedHTML = module.get.choiceText($result, true)
966
+ ;
967
+ if (settings.ignoreDiacritics) {
968
+ markedHTML = markedHTML.normalize('NFD');
969
+ }
970
+ $result.html(markedHTML.replace(markedRegExp, markedReplacer));
971
+ });
972
+ }
947
973
  }
948
974
 
949
975
  if (!module.has.query()) {
@@ -979,8 +1005,10 @@
979
1005
  termLength = term.length,
980
1006
  queryLength = query.length
981
1007
  ;
982
- query = settings.ignoreSearchCase ? query.toLowerCase() : query;
983
- term = settings.ignoreSearchCase ? term.toLowerCase() : term;
1008
+ if (settings.ignoreSearchCase) {
1009
+ query = query.toLowerCase();
1010
+ term = term.toLowerCase();
1011
+ }
984
1012
  if (queryLength > termLength) {
985
1013
  return false;
986
1014
  }
@@ -1187,7 +1215,7 @@
1187
1215
  if (!itemActivated && !pageLostFocus) {
1188
1216
  if (settings.forceSelection) {
1189
1217
  module.forceSelection();
1190
- } else if (!settings.allowAdditions) {
1218
+ } else if (!settings.allowAdditions && !settings.keepSearchTerm && !module.has.menuSearch()) {
1191
1219
  module.remove.searchTerm();
1192
1220
  }
1193
1221
  module.hide();
@@ -1236,7 +1264,9 @@
1236
1264
  module.set.filtered();
1237
1265
  }
1238
1266
  clearTimeout(module.timer);
1239
- module.timer = setTimeout(function () { module.search(); }, settings.delay.search);
1267
+ module.timer = setTimeout(function () {
1268
+ module.search();
1269
+ }, settings.delay.search);
1240
1270
  },
1241
1271
  label: {
1242
1272
  click: function (event) {
@@ -1413,7 +1443,9 @@
1413
1443
  module.remove.userAddition();
1414
1444
  }
1415
1445
  if (!settings.keepSearchTerm) {
1416
- module.remove.filteredItem();
1446
+ if (module.is.multiple()) {
1447
+ module.remove.filteredItem();
1448
+ }
1417
1449
  module.remove.searchTerm();
1418
1450
  }
1419
1451
  if (!module.is.visible() && $target.length > 0) {
@@ -2587,7 +2619,7 @@
2587
2619
  } else {
2588
2620
  $combo.text(text);
2589
2621
  }
2590
- } else if (settings.action === 'activate') {
2622
+ } else if (settings.action === 'activate' || isFunction(settings.action)) {
2591
2623
  if (text !== module.get.placeholderText() || isNotPlaceholder) {
2592
2624
  $text.removeClass(className.placeholder);
2593
2625
  }
@@ -2647,7 +2679,7 @@
2647
2679
  module.set.scrollPosition($nextValue);
2648
2680
  $selectedItem.removeClass(className.selected);
2649
2681
  $nextValue.addClass(className.selected);
2650
- if (settings.selectOnKeydown && module.is.single() && !$nextItem.hasClass(className.actionable)) {
2682
+ if (settings.selectOnKeydown && module.is.single() && (!$nextItem || !$nextItem.hasClass(className.actionable))) {
2651
2683
  module.set.selectedItem($nextValue);
2652
2684
  }
2653
2685
  }
@@ -2768,19 +2800,27 @@
2768
2800
  $selectedItem = settings.allowAdditions
2769
2801
  ? $selectedItem || module.get.itemWithAdditions(value)
2770
2802
  : $selectedItem || module.get.item(value);
2771
- if (!$selectedItem) {
2803
+ if (!$selectedItem && value !== undefined) {
2772
2804
  return false;
2773
2805
  }
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()) {
2806
+ if (isMultiple) {
2807
+ if (!keepSearchTerm) {
2808
+ module.remove.searchWidth();
2809
+ }
2810
+ if (settings.useLabels) {
2811
+ module.remove.selectedItem();
2812
+ if (value === undefined) {
2813
+ module.remove.labels($module.find(selector.label), true);
2814
+ }
2815
+ }
2816
+ } else {
2779
2817
  module.remove.activeItem();
2780
2818
  module.remove.selectedItem();
2781
- } else if (settings.useLabels) {
2782
- module.remove.selectedItem();
2783
2819
  }
2820
+ if (!$selectedItem) {
2821
+ return false;
2822
+ }
2823
+ module.debug('Setting selected menu item to', $selectedItem);
2784
2824
  // select each item
2785
2825
  $selectedItem
2786
2826
  .each(function () {
@@ -3080,6 +3120,12 @@
3080
3120
  $item.removeClass(className.active);
3081
3121
  },
3082
3122
  filteredItem: function () {
3123
+ if (settings.highlightMatches) {
3124
+ $.each($item, function (index, item) {
3125
+ var $markItem = $(item);
3126
+ $markItem.html($markItem.html().replace(/<\/?mark>/g, ''));
3127
+ });
3128
+ }
3083
3129
  if (settings.useLabels && module.has.maxSelections()) {
3084
3130
  return;
3085
3131
  }
@@ -3424,7 +3470,12 @@
3424
3470
  return $selectedMenu.hasClass(className.leftward);
3425
3471
  },
3426
3472
  clearable: function () {
3427
- return $module.hasClass(className.clearable) || settings.clearable;
3473
+ var hasClearableClass = $module.hasClass(className.clearable);
3474
+ if (!hasClearableClass && settings.clearable) {
3475
+ $module.addClass(className.clearable);
3476
+ }
3477
+
3478
+ return hasClearableClass || settings.clearable;
3428
3479
  },
3429
3480
  disabled: function () {
3430
3481
  return $module.hasClass(className.disabled);
@@ -3747,12 +3798,16 @@
3747
3798
  show: function () {
3748
3799
  module.verbose('Delaying show event to ensure user intent');
3749
3800
  clearTimeout(module.timer);
3750
- module.timer = setTimeout(function () { module.show(); }, settings.delay.show);
3801
+ module.timer = setTimeout(function () {
3802
+ module.show();
3803
+ }, settings.delay.show);
3751
3804
  },
3752
3805
  hide: function () {
3753
3806
  module.verbose('Delaying hide event to ensure user intent');
3754
3807
  clearTimeout(module.timer);
3755
- module.timer = setTimeout(function () { module.hide(); }, settings.delay.hide);
3808
+ module.timer = setTimeout(function () {
3809
+ module.hide();
3810
+ }, settings.delay.hide);
3756
3811
  },
3757
3812
  },
3758
3813
 
@@ -3785,6 +3840,7 @@
3785
3840
  return text.replace(regExp.escape, '\\$&');
3786
3841
  },
3787
3842
  htmlEntities: function (string, forceAmpersand) {
3843
+ forceAmpersand = typeof forceAmpersand === 'number' ? false : forceAmpersand;
3788
3844
  var
3789
3845
  badChars = /["'<>`]/g,
3790
3846
  shouldEscape = /["&'<>`]/,
@@ -3801,8 +3857,7 @@
3801
3857
  ;
3802
3858
  if (shouldEscape.test(string)) {
3803
3859
  string = string.replace(forceAmpersand ? /&/g : /&(?![\d#a-z]{1,12};)/gi, '&amp;');
3804
-
3805
- return string.replace(badChars, escapedChar);
3860
+ string = string.replace(badChars, escapedChar);
3806
3861
  }
3807
3862
 
3808
3863
  return string;
@@ -3878,7 +3933,9 @@
3878
3933
  });
3879
3934
  }
3880
3935
  clearTimeout(module.performance.timer);
3881
- module.performance.timer = setTimeout(function () { module.performance.display(); }, 500);
3936
+ module.performance.timer = setTimeout(function () {
3937
+ module.performance.display();
3938
+ }, 500);
3882
3939
  },
3883
3940
  display: function () {
3884
3941
  var
@@ -4005,6 +4062,7 @@
4005
4062
 
4006
4063
  match: 'both', // what to match against with search selection (both, text, or label)
4007
4064
  fullTextSearch: 'exact', // search anywhere in value (set to 'exact' to require exact matches)
4065
+ highlightMatches: false, // Whether search result should highlight matching strings
4008
4066
  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
4067
  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
4068
 
@@ -4120,9 +4178,11 @@
4120
4178
  descriptionVertical: 'descriptionVertical', // whether description should be vertical
4121
4179
  value: 'value', // actual dropdown value
4122
4180
  text: 'text', // displayed text when selected
4181
+ data: 'data', // custom data attributes
4123
4182
  type: 'type', // type of dropdown element
4124
4183
  image: 'image', // optional image path
4125
4184
  imageClass: 'imageClass', // optional individual class for image
4185
+ alt: 'alt', // optional alt text for image
4126
4186
  icon: 'icon', // optional icon name
4127
4187
  iconClass: 'iconClass', // optional individual class for icon (for example to use flag instead)
4128
4188
  class: 'class', // optional individual class for item/header
@@ -4229,8 +4289,7 @@
4229
4289
  ;
4230
4290
  if (shouldEscape.test(string)) {
4231
4291
  string = string.replace(/&(?![\d#a-z]{1,12};)/gi, '&amp;');
4232
-
4233
- return string.replace(badChars, escapedChar);
4292
+ string = string.replace(badChars, escapedChar);
4234
4293
  }
4235
4294
 
4236
4295
  return string;
@@ -4265,9 +4324,21 @@
4265
4324
  $.each(values, function (index, option) {
4266
4325
  var
4267
4326
  itemType = option[fields.type] || 'item',
4268
- isMenu = itemType.indexOf('menu') !== -1
4327
+ isMenu = itemType.indexOf('menu') !== -1,
4328
+ maybeData = '',
4329
+ dataObject = option[fields.data]
4269
4330
  ;
4270
-
4331
+ if (dataObject) {
4332
+ var dataKey,
4333
+ dataKeyEscaped
4334
+ ;
4335
+ for (dataKey in dataObject) {
4336
+ dataKeyEscaped = String(dataKey).replace(/\W/g, '');
4337
+ if (Object.prototype.hasOwnProperty.call(dataObject, dataKey) && ['text', 'value'].indexOf(dataKeyEscaped.toLowerCase()) === -1) {
4338
+ maybeData += ' data-' + dataKeyEscaped + '="' + deQuote(String(dataObject[dataKey])) + '"';
4339
+ }
4340
+ }
4341
+ }
4271
4342
  if (itemType === 'item' || isMenu) {
4272
4343
  var
4273
4344
  maybeText = option[fields.text]
@@ -4284,12 +4355,12 @@
4284
4355
  : '',
4285
4356
  hasDescription = escape(option[fields.description] || '', preserveHTML) !== ''
4286
4357
  ;
4287
- html += '<div class="' + deQuote(maybeActionable + maybeDisabled + maybeDescriptionVertical + (option[fields.class] || className.item)) + '" data-value="' + deQuote(option[fields.value], true) + '"' + maybeText + '>';
4358
+ html += '<div class="' + deQuote(maybeActionable + maybeDisabled + maybeDescriptionVertical + (option[fields.class] || className.item)) + '" data-value="' + deQuote(option[fields.value], true) + '"' + maybeText + maybeData + '>';
4288
4359
  if (isMenu) {
4289
4360
  html += '<i class="' + (itemType.indexOf('left') !== -1 ? 'left' : '') + ' dropdown icon"></i>';
4290
4361
  }
4291
4362
  if (option[fields.image]) {
4292
- html += '<img class="' + deQuote(option[fields.imageClass] || className.image) + '" src="' + deQuote(option[fields.image]) + '">';
4363
+ html += '<img class="' + deQuote(option[fields.imageClass] || className.image) + '" src="' + deQuote(option[fields.image]) + (option[fields.alt] ? '" alt="' + deQuote(option[fields.alt]) : '') + '">';
4293
4364
  }
4294
4365
  if (option[fields.icon]) {
4295
4366
  html += '<i class="' + deQuote(option[fields.icon] + ' ' + (option[fields.iconClass] || className.icon)) + '"></i>';