@pocketprep/ui-kit 2.0.40 → 3.0.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 (305) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +16 -17
  2. package/dist/@pocketprep/ui-kit.js +18856 -0
  3. package/dist/@pocketprep/ui-kit.js.map +1 -0
  4. package/dist/@pocketprep/ui-kit.umd.cjs +28 -0
  5. package/dist/@pocketprep/ui-kit.umd.cjs.map +1 -0
  6. package/dist/style.css +1 -0
  7. package/lib/SVGDefinitions.vue +85 -0
  8. package/lib/assets/emojis/tada.png +0 -0
  9. package/lib/assets/halftones/halftone-black.png +0 -0
  10. package/lib/assets/halftones/halftone-blue.png +0 -0
  11. package/lib/assets/halftones/halftone-green.png +0 -0
  12. package/lib/assets/halftones/halftone-purple.png +0 -0
  13. package/lib/assets/halftones/halftone-red.png +0 -0
  14. package/lib/assets/halftones/halftone-yellow.png +0 -0
  15. package/lib/assets/question/paywall-dark.png +0 -0
  16. package/lib/assets/question/paywall-light.png +0 -0
  17. package/lib/components/Banners/Banner.md +41 -0
  18. package/lib/components/Banners/Banner.vue +87 -0
  19. package/lib/components/BundleIcons/AMTA.vue +134 -0
  20. package/lib/components/BundleIcons/BundleIcon.md +60 -0
  21. package/lib/components/BundleIcons/BundleIcon.vue +111 -0
  22. package/lib/components/Bundles/BundleList.md +63 -0
  23. package/lib/components/Bundles/BundleList.vue +170 -0
  24. package/lib/components/Bundles/BundleSearch.md +195 -0
  25. package/lib/components/Bundles/BundleSearch.vue +573 -0
  26. package/lib/components/Bundles/PremiumPill.md +23 -0
  27. package/lib/components/Bundles/PremiumPill.vue +43 -0
  28. package/lib/components/Buttons/Button.md +99 -0
  29. package/lib/components/Buttons/Button.vue +496 -0
  30. package/lib/components/Buttons/Link.md +58 -0
  31. package/lib/components/Buttons/Link.vue +192 -0
  32. package/lib/components/Buttons/Tab.md +35 -0
  33. package/lib/components/Buttons/Tab.vue +103 -0
  34. package/lib/components/Calendar/Calendar.md +18 -0
  35. package/lib/components/Calendar/Calendar.vue +162 -0
  36. package/lib/components/Charts/Bar.md +123 -0
  37. package/lib/components/Charts/Bar.vue +364 -0
  38. package/lib/components/Charts/Pie.md +23 -0
  39. package/lib/components/Charts/Pie.vue +105 -0
  40. package/lib/components/Controls/SegmentControl.md +47 -0
  41. package/lib/components/Controls/SegmentControl.vue +117 -0
  42. package/lib/components/Controls/Slider.md +67 -0
  43. package/lib/components/Controls/Slider.vue +358 -0
  44. package/lib/components/Controls/ToggleSwitch.md +56 -0
  45. package/lib/components/Controls/ToggleSwitch.vue +160 -0
  46. package/lib/components/Exams/ExamCard.md +45 -0
  47. package/lib/components/Exams/ExamCard.vue +257 -0
  48. package/lib/components/Exams/ExamMenuCard.md +90 -0
  49. package/lib/components/Exams/ExamMenuCard.vue +218 -0
  50. package/lib/components/Filters/FilterDropdown.md +59 -0
  51. package/lib/components/Filters/FilterDropdown.vue +176 -0
  52. package/lib/components/Filters/FilterOptions.md +65 -0
  53. package/lib/components/Filters/FilterOptions.vue +265 -0
  54. package/lib/components/Filters/filterOptions.d.ts +10 -0
  55. package/lib/components/Forms/Checkbox.md +52 -0
  56. package/lib/components/Forms/Checkbox.vue +184 -0
  57. package/lib/components/Forms/CheckboxOption.md +37 -0
  58. package/lib/components/Forms/CheckboxOption.vue +173 -0
  59. package/lib/components/Forms/Errors.md +23 -0
  60. package/lib/components/Forms/Errors.vue +109 -0
  61. package/lib/components/Forms/Input.md +63 -0
  62. package/lib/components/Forms/Input.vue +310 -0
  63. package/lib/components/Forms/Radio.md +66 -0
  64. package/lib/components/Forms/Radio.vue +312 -0
  65. package/lib/components/Forms/Select.md +133 -0
  66. package/lib/components/Forms/Select.vue +670 -0
  67. package/lib/components/Forms/Textarea.md +57 -0
  68. package/lib/components/Forms/Textarea.vue +157 -0
  69. package/lib/components/Icons/Icon.md +146 -0
  70. package/lib/components/Icons/Icon.vue +192 -0
  71. package/lib/components/Icons/IconAccordionArrow.md +7 -0
  72. package/lib/components/Icons/IconAccordionArrow.vue +23 -0
  73. package/lib/components/Icons/IconActivity.md +7 -0
  74. package/lib/components/Icons/IconActivity.vue +21 -0
  75. package/lib/components/Icons/IconAdd.md +7 -0
  76. package/lib/components/Icons/IconAdd.vue +19 -0
  77. package/lib/components/Icons/IconAddCircle.md +7 -0
  78. package/lib/components/Icons/IconAddCircle.vue +22 -0
  79. package/lib/components/Icons/IconArrow.md +7 -0
  80. package/lib/components/Icons/IconArrow.vue +21 -0
  81. package/lib/components/Icons/IconBarChart.md +7 -0
  82. package/lib/components/Icons/IconBarChart.vue +23 -0
  83. package/lib/components/Icons/IconCalendar.md +7 -0
  84. package/lib/components/Icons/IconCalendar.vue +19 -0
  85. package/lib/components/Icons/IconCheck.md +7 -0
  86. package/lib/components/Icons/IconCheck.vue +21 -0
  87. package/lib/components/Icons/IconClose.md +7 -0
  88. package/lib/components/Icons/IconClose.vue +23 -0
  89. package/lib/components/Icons/IconCorrect.md +7 -0
  90. package/lib/components/Icons/IconCorrect.vue +19 -0
  91. package/lib/components/Icons/IconEdit.md +7 -0
  92. package/lib/components/Icons/IconEdit.vue +21 -0
  93. package/lib/components/Icons/IconExam.md +7 -0
  94. package/lib/components/Icons/IconExam.vue +34 -0
  95. package/lib/components/Icons/IconExternalLink.md +7 -0
  96. package/lib/components/Icons/IconExternalLink.vue +30 -0
  97. package/lib/components/Icons/IconEyeHide.md +7 -0
  98. package/lib/components/Icons/IconEyeHide.vue +21 -0
  99. package/lib/components/Icons/IconEyeShow.md +7 -0
  100. package/lib/components/Icons/IconEyeShow.vue +21 -0
  101. package/lib/components/Icons/IconFilter.md +7 -0
  102. package/lib/components/Icons/IconFilter.vue +19 -0
  103. package/lib/components/Icons/IconFilterActive.md +7 -0
  104. package/lib/components/Icons/IconFilterActive.vue +20 -0
  105. package/lib/components/Icons/IconFlag.md +7 -0
  106. package/lib/components/Icons/IconFlag.vue +25 -0
  107. package/lib/components/Icons/IconFlagFeedback.md +11 -0
  108. package/lib/components/Icons/IconFlagFeedback.vue +24 -0
  109. package/lib/components/Icons/IconFlagFilled.md +7 -0
  110. package/lib/components/Icons/IconFlagFilled.vue +22 -0
  111. package/lib/components/Icons/IconFullView.md +7 -0
  112. package/lib/components/Icons/IconFullView.vue +30 -0
  113. package/lib/components/Icons/IconFullViewActive.md +7 -0
  114. package/lib/components/Icons/IconFullViewActive.vue +28 -0
  115. package/lib/components/Icons/IconHandle.md +7 -0
  116. package/lib/components/Icons/IconHandle.vue +23 -0
  117. package/lib/components/Icons/IconHeart.md +7 -0
  118. package/lib/components/Icons/IconHeart.vue +19 -0
  119. package/lib/components/Icons/IconHelp.md +7 -0
  120. package/lib/components/Icons/IconHelp.vue +25 -0
  121. package/lib/components/Icons/IconHourglass.md +7 -0
  122. package/lib/components/Icons/IconHourglass.vue +22 -0
  123. package/lib/components/Icons/IconImage.md +7 -0
  124. package/lib/components/Icons/IconImage.vue +21 -0
  125. package/lib/components/Icons/IconIncorrect.md +7 -0
  126. package/lib/components/Icons/IconIncorrect.vue +21 -0
  127. package/lib/components/Icons/IconInfo.md +7 -0
  128. package/lib/components/Icons/IconInfo.vue +24 -0
  129. package/lib/components/Icons/IconKeyboard.md +7 -0
  130. package/lib/components/Icons/IconKeyboard.vue +25 -0
  131. package/lib/components/Icons/IconLaunch.md +7 -0
  132. package/lib/components/Icons/IconLaunch.vue +25 -0
  133. package/lib/components/Icons/IconLightning.md +7 -0
  134. package/lib/components/Icons/IconLightning.vue +21 -0
  135. package/lib/components/Icons/IconList.md +7 -0
  136. package/lib/components/Icons/IconList.vue +26 -0
  137. package/lib/components/Icons/IconLoading.md +7 -0
  138. package/lib/components/Icons/IconLoading.vue +65 -0
  139. package/lib/components/Icons/IconLoading2.md +7 -0
  140. package/lib/components/Icons/IconLoading2.vue +52 -0
  141. package/lib/components/Icons/IconLock.md +7 -0
  142. package/lib/components/Icons/IconLock.vue +23 -0
  143. package/lib/components/Icons/IconMissedQuestions.md +7 -0
  144. package/lib/components/Icons/IconMissedQuestions.vue +22 -0
  145. package/lib/components/Icons/IconMoon.md +7 -0
  146. package/lib/components/Icons/IconMoon.vue +25 -0
  147. package/lib/components/Icons/IconPaginationArrow.md +7 -0
  148. package/lib/components/Icons/IconPaginationArrow.vue +23 -0
  149. package/lib/components/Icons/IconPassage.md +7 -0
  150. package/lib/components/Icons/IconPassage.vue +22 -0
  151. package/lib/components/Icons/IconPencil.md +7 -0
  152. package/lib/components/Icons/IconPencil.vue +19 -0
  153. package/lib/components/Icons/IconPeople.md +7 -0
  154. package/lib/components/Icons/IconPeople.vue +25 -0
  155. package/lib/components/Icons/IconQuestions.md +7 -0
  156. package/lib/components/Icons/IconQuestions.vue +25 -0
  157. package/lib/components/Icons/IconQuick10.md +7 -0
  158. package/lib/components/Icons/IconQuick10.vue +23 -0
  159. package/lib/components/Icons/IconRemoveCircle.md +7 -0
  160. package/lib/components/Icons/IconRemoveCircle.vue +22 -0
  161. package/lib/components/Icons/IconReviewFlag.md +7 -0
  162. package/lib/components/Icons/IconReviewFlag.vue +32 -0
  163. package/lib/components/Icons/IconSearch.md +7 -0
  164. package/lib/components/Icons/IconSearch.vue +23 -0
  165. package/lib/components/Icons/IconShare.md +7 -0
  166. package/lib/components/Icons/IconShare.vue +31 -0
  167. package/lib/components/Icons/IconSideBar.md +7 -0
  168. package/lib/components/Icons/IconSideBar.vue +26 -0
  169. package/lib/components/Icons/IconSideBarActive.md +7 -0
  170. package/lib/components/Icons/IconSideBarActive.vue +28 -0
  171. package/lib/components/Icons/IconStopwatch.md +7 -0
  172. package/lib/components/Icons/IconStopwatch.vue +22 -0
  173. package/lib/components/Icons/IconStrike.md +60 -0
  174. package/lib/components/Icons/IconStrike.vue +23 -0
  175. package/lib/components/Icons/IconSubject.md +7 -0
  176. package/lib/components/Icons/IconSubject.vue +22 -0
  177. package/lib/components/Icons/IconText.md +7 -0
  178. package/lib/components/Icons/IconText.vue +22 -0
  179. package/lib/components/Icons/IconWarning.md +7 -0
  180. package/lib/components/Icons/IconWarning.vue +22 -0
  181. package/lib/components/Modal/Modal.md +31 -0
  182. package/lib/components/Modal/Modal.vue +133 -0
  183. package/lib/components/Modal/ModalContainer.md +96 -0
  184. package/lib/components/Modal/ModalContainer.vue +208 -0
  185. package/lib/components/Onboarding/EmailAuth.md +40 -0
  186. package/lib/components/Onboarding/EmailAuth.vue +218 -0
  187. package/lib/components/Onboarding/MagicCodeEntry.md +20 -0
  188. package/lib/components/Onboarding/MagicCodeEntry.vue +189 -0
  189. package/lib/components/PhonePerson/PhonePerson.md +36 -0
  190. package/lib/components/PhonePerson/PhonePerson.vue +48 -0
  191. package/lib/components/PhonePerson/phoneperson-IT@2x.png +0 -0
  192. package/lib/components/PhonePerson/phoneperson-auto@2x.png +0 -0
  193. package/lib/components/PhonePerson/phoneperson-behavioralhealth@2x.png +0 -0
  194. package/lib/components/PhonePerson/phoneperson-emt@2x.png +0 -0
  195. package/lib/components/PhonePerson/phoneperson-essentials@2x.png +0 -0
  196. package/lib/components/PhonePerson/phoneperson-finance@2x.png +0 -0
  197. package/lib/components/PhonePerson/phoneperson-fitness@2x.png +0 -0
  198. package/lib/components/PhonePerson/phoneperson-medical@2x.png +0 -0
  199. package/lib/components/PhonePerson/phoneperson-nursing@2x.png +0 -0
  200. package/lib/components/PhonePerson/phoneperson-nursingschool@2x.png +0 -0
  201. package/lib/components/PhonePerson/phoneperson-professional@2x.png +0 -0
  202. package/lib/components/PhonePerson/phoneperson-skilledtrades@2x.png +0 -0
  203. package/lib/components/Quiz/FlagToggle.md +37 -0
  204. package/lib/components/Quiz/FlagToggle.vue +124 -0
  205. package/lib/components/Quiz/GlobalMetricsToggle.md +46 -0
  206. package/lib/components/Quiz/GlobalMetricsToggle.vue +124 -0
  207. package/lib/components/Quiz/KeyboardShortcutsButton.md +18 -0
  208. package/lib/components/Quiz/KeyboardShortcutsButton.vue +102 -0
  209. package/lib/components/Quiz/KeyboardShortcutsModal.md +71 -0
  210. package/lib/components/Quiz/KeyboardShortcutsModal.vue +261 -0
  211. package/lib/components/Quiz/Question.md +579 -0
  212. package/lib/components/Quiz/Question.vue +3262 -0
  213. package/lib/components/Quiz/QuizContainer.md +91 -0
  214. package/lib/components/Quiz/QuizContainer.vue +207 -0
  215. package/lib/components/Quiz/QuizProgress.md +122 -0
  216. package/lib/components/Quiz/QuizProgress.vue +188 -0
  217. package/lib/components/Quiz/QuizProgressBar.md +131 -0
  218. package/lib/components/Quiz/QuizProgressBar.vue +96 -0
  219. package/lib/components/Search/Pill.md +37 -0
  220. package/lib/components/Search/Pill.vue +117 -0
  221. package/lib/components/Search/Search.md +44 -0
  222. package/lib/components/Search/Search.vue +341 -0
  223. package/lib/components/SidePanels/SidePanel.md +126 -0
  224. package/lib/components/SidePanels/SidePanel.vue +592 -0
  225. package/lib/components/Tables/StudyTable.md +136 -0
  226. package/lib/components/Tables/Table.vue +497 -0
  227. package/lib/components/Tables/TableActions.vue +199 -0
  228. package/lib/components/Tables/TablePagination.md +19 -0
  229. package/lib/components/Tables/TablePagination.vue +109 -0
  230. package/lib/components/Tables/TeachTable.md +696 -0
  231. package/lib/components/Toasts/Toast.md +35 -0
  232. package/lib/components/Toasts/Toast.vue +213 -0
  233. package/lib/components/Tooltips/OverflowTooltip.md +14 -0
  234. package/lib/components/Tooltips/OverflowTooltip.vue +68 -0
  235. package/lib/components/Tooltips/Tooltip.md +72 -0
  236. package/lib/components/Tooltips/Tooltip.vue +143 -0
  237. package/lib/directives.ts +213 -0
  238. package/lib/index.ts +108 -0
  239. package/{pocketprep-export.module.scss → lib/pocketprep-export.module.scss} +2 -2
  240. package/{pocketprep.scss → lib/pocketprep.scss} +16 -18
  241. package/{styles → lib/styles}/_colors.scss +1 -1
  242. package/lib/styles/fonts.css +149 -0
  243. package/lib/utils.ts +53 -0
  244. package/package.json +75 -56
  245. package/{stylelint.config.js → stylelint.config.cjs} +6 -3
  246. package/assets/Fonts.md +0 -114
  247. package/assets/Images.md +0 -2
  248. package/assets/Styleguidist.vue +0 -11
  249. package/dist/@pocketprep/ui-kit.common.js +0 -29726
  250. package/dist/@pocketprep/ui-kit.common.js.map +0 -1
  251. package/dist/@pocketprep/ui-kit.umd.js +0 -29745
  252. package/dist/@pocketprep/ui-kit.umd.js.map +0 -1
  253. package/dist/@pocketprep/ui-kit.umd.min.js +0 -33
  254. package/dist/@pocketprep/ui-kit.umd.min.js.map +0 -1
  255. package/dist/demo.html +0 -1
  256. package/index.d.ts +0 -63
  257. package/src/directives.d.ts +0 -2
  258. package/src/shims.d.ts +0 -19
  259. package/src/utils.d.ts +0 -51
  260. package/styles/Colors.md +0 -53
  261. package/styles/Styles.md +0 -4
  262. package/styles/_fonts.scss +0 -149
  263. package/tests/shims-test.d.ts +0 -9
  264. /package/{assets → lib/assets}/fonts/muli/muli-400.eot +0 -0
  265. /package/{assets → lib/assets}/fonts/muli/muli-400.svg +0 -0
  266. /package/{assets → lib/assets}/fonts/muli/muli-400.ttf +0 -0
  267. /package/{assets → lib/assets}/fonts/muli/muli-400.woff +0 -0
  268. /package/{assets → lib/assets}/fonts/muli/muli-400.woff2 +0 -0
  269. /package/{assets → lib/assets}/fonts/muli/muli-400italic.eot +0 -0
  270. /package/{assets → lib/assets}/fonts/muli/muli-400italic.svg +0 -0
  271. /package/{assets → lib/assets}/fonts/muli/muli-400italic.ttf +0 -0
  272. /package/{assets → lib/assets}/fonts/muli/muli-400italic.woff +0 -0
  273. /package/{assets → lib/assets}/fonts/muli/muli-400italic.woff2 +0 -0
  274. /package/{assets → lib/assets}/fonts/muli/muli-600.eot +0 -0
  275. /package/{assets → lib/assets}/fonts/muli/muli-600.svg +0 -0
  276. /package/{assets → lib/assets}/fonts/muli/muli-600.ttf +0 -0
  277. /package/{assets → lib/assets}/fonts/muli/muli-600.woff +0 -0
  278. /package/{assets → lib/assets}/fonts/muli/muli-600.woff2 +0 -0
  279. /package/{assets → lib/assets}/fonts/muli/muli-600italic.eot +0 -0
  280. /package/{assets → lib/assets}/fonts/muli/muli-600italic.svg +0 -0
  281. /package/{assets → lib/assets}/fonts/muli/muli-600italic.ttf +0 -0
  282. /package/{assets → lib/assets}/fonts/muli/muli-600italic.woff +0 -0
  283. /package/{assets → lib/assets}/fonts/muli/muli-600italic.woff2 +0 -0
  284. /package/{assets → lib/assets}/fonts/muli/muli-700.eot +0 -0
  285. /package/{assets → lib/assets}/fonts/muli/muli-700.svg +0 -0
  286. /package/{assets → lib/assets}/fonts/muli/muli-700.ttf +0 -0
  287. /package/{assets → lib/assets}/fonts/muli/muli-700.woff +0 -0
  288. /package/{assets → lib/assets}/fonts/muli/muli-700.woff2 +0 -0
  289. /package/{assets → lib/assets}/fonts/muli/muli-700italic.eot +0 -0
  290. /package/{assets → lib/assets}/fonts/muli/muli-700italic.svg +0 -0
  291. /package/{assets → lib/assets}/fonts/muli/muli-700italic.ttf +0 -0
  292. /package/{assets → lib/assets}/fonts/muli/muli-700italic.woff +0 -0
  293. /package/{assets → lib/assets}/fonts/muli/muli-700italic.woff2 +0 -0
  294. /package/{assets → lib/assets}/images/amta.svg +0 -0
  295. /package/{assets → lib/assets}/images/favicon.ico +0 -0
  296. /package/{assets → lib/assets}/images/thumb-large-dark.svg +0 -0
  297. /package/{assets → lib/assets}/images/thumb-large.svg +0 -0
  298. /package/{assets → lib/assets}/images/thumb-small-dark.svg +0 -0
  299. /package/{assets → lib/assets}/images/thumb-small.svg +0 -0
  300. /package/{src → lib}/components/BundleIcons/bundleIcon.d.ts +0 -0
  301. /package/{src → lib}/components/Icons/icon.d.ts +0 -0
  302. /package/{src → lib}/components/PhonePerson/phonePerson.d.ts +0 -0
  303. /package/{src → lib}/components/Tables/table.d.ts +0 -0
  304. /package/{styles → lib/styles}/_breakpoints.scss +0 -0
  305. /package/{styles/_normalize.scss → lib/styles/normalize.css} +0 -0
@@ -0,0 +1,670 @@
1
+ <template>
2
+ <div
3
+ class="uikit-select"
4
+ @mouseover="mouseOverSelect"
5
+ @mouseout="hover = false"
6
+ @keydown="keydownListener"
7
+ >
8
+ <label
9
+ v-if="label"
10
+ v-dark="isDarkMode"
11
+ class="uikit-select__label"
12
+ :class="{
13
+ 'uikit-select__label--hover': hover,
14
+ 'uikit-select__label--focus': focus,
15
+ 'uikit-select__label--error': error,
16
+ }"
17
+ >{{ label }}</label>
18
+ <div
19
+ ref="uikit-select__input-container"
20
+ class="uikit-select__input-container"
21
+ :tabindex="disabled || typeahead ? -1 : 0"
22
+ role="combobox"
23
+ :aria-label="label"
24
+ :aria-expanded="(showDropdown && !disabled) ? 'true' : 'false'"
25
+ @focus="focusSelect"
26
+ @blur="focus = false; showDropdown = false;"
27
+ @keydown.stop="keyPressedContainer"
28
+ >
29
+ <div
30
+ v-if="!typeahead"
31
+ v-dark="isDarkMode"
32
+ class="uikit-select__value"
33
+ :class="{
34
+ 'uikit-select__value--placeholder': !modelValue,
35
+ 'uikit-select__value--hover': hover,
36
+ 'uikit-select__value--focus': focus,
37
+ 'uikit-select__value--disabled': disabled,
38
+ 'uikit-select__value--subtext': subtext
39
+ }"
40
+ @click="showDropdown = !showDropdown"
41
+ >
42
+ {{ modelValue ? modelValue.label : placeholder }}
43
+
44
+ <div
45
+ v-if="subtext"
46
+ v-dark="isDarkMode"
47
+ class="uikit-select__subtext"
48
+ :class="{
49
+ 'uikit-select__subtext--placeholder': !subtext,
50
+ 'uikit-select__subtext--hover': hover,
51
+ 'uikit-select__subtext--focus': focus,
52
+ 'uikit-select__subtext--disabled': disabled,
53
+ }"
54
+ >
55
+ {{ modelValue ? modelValue.subtext : subtext }}
56
+ </div>
57
+ </div>
58
+ <input
59
+ v-else
60
+ v-model="searchText"
61
+ v-dark="isDarkMode"
62
+ type="text"
63
+ class="uikit-select__input"
64
+ :class="{
65
+ 'uikit-select__input--placeholder': !modelValue && !searchText,
66
+ 'uikit-select__input--hover': hover,
67
+ 'uikit-select__input--focus': focus,
68
+ 'uikit-select__input--disabled': disabled,
69
+ 'uikit-select__input--show-dropdown': showDropdown,
70
+ }"
71
+ :placeholder="placeholder"
72
+ :aria-label="label"
73
+ @focus="focusSelect"
74
+ @blur="blurMenu"
75
+ @keydown.stop="keyPressedContainer"
76
+ @click="showDropdown = true"
77
+ >
78
+ <Icon
79
+ v-dark="isDarkMode"
80
+ type="accordionArrow"
81
+ class="uikit-select__arrow"
82
+ :class="{
83
+ 'uikit-select__arrow--hover': hover,
84
+ 'uikit-select__arrow--focus': focus,
85
+ 'uikit-select__arrow--show-dropdown': showDropdown,
86
+ }"
87
+ @click="showDropdown = true"
88
+ />
89
+ <ul
90
+ v-show="showDropdown && !disabled"
91
+ ref="menu"
92
+ v-dark="isDarkMode"
93
+ :style="{ top: `${menuPositionTop}px` }"
94
+ class="uikit-select__list"
95
+ :class="{
96
+ 'uikit-select__list--subtext': subtext,
97
+ }"
98
+ >
99
+ <li
100
+ v-for="item in filteredData"
101
+ :key="JSON.stringify(item)"
102
+ ref="uikit-select__items"
103
+ v-dark="isDarkMode"
104
+ class="uikit-select__item"
105
+ :class="{
106
+ 'uikit-select__item--link': item.type === 'link',
107
+ 'uikit-select__item--subtext': item.subtext
108
+ }"
109
+ :value="item.value || undefined"
110
+ tabindex="0"
111
+ @click="selectItem(item)"
112
+ @keydown="keyPressedItem"
113
+ @mousedown.prevent
114
+ >
115
+ {{ item.label }}
116
+
117
+ <div
118
+ v-if="item.subtext"
119
+ v-dark="isDarkMode"
120
+ class="uikit-select__item-subtext"
121
+ >
122
+ {{ item.subtext }}
123
+ </div>
124
+ </li>
125
+ </ul>
126
+ </div>
127
+ </div>
128
+ </template>
129
+
130
+ <script lang="ts">
131
+ import { Component, Vue, Prop, Watch, Emit } from 'vue-facing-decorator'
132
+ import Icon from '../Icons/Icon.vue'
133
+ import { dark } from '../../directives'
134
+
135
+ interface IItem {
136
+ value?: string | null
137
+ label: string
138
+ type?: 'option' | 'link'
139
+ subtext?: string
140
+ }
141
+
142
+ /**
143
+ * @see [Designs for Inputs](https://marvelapp.com/adf8ab3/screen/70331421)
144
+ */
145
+ @Component({
146
+ components: {
147
+ Icon,
148
+ },
149
+ directives: {
150
+ dark,
151
+ },
152
+ })
153
+ export default class Select extends Vue {
154
+ @Prop() label?: string
155
+ @Prop() modelValue?: IItem
156
+ @Prop() subtext?: string
157
+ @Prop() placeholder?: string
158
+ @Prop() data!: IItem[]
159
+ @Prop() disabled?: boolean
160
+ @Prop() autoFocus?: boolean
161
+ @Prop() showEmptyOption?: boolean
162
+ @Prop() emptyOptionLabel?: string
163
+ @Prop() typeahead?: boolean
164
+ @Prop() error?: boolean
165
+ @Prop() openMenuAbove?: boolean
166
+ @Prop({ default: false }) isDarkMode!: boolean
167
+
168
+ hover = false
169
+ focus = false
170
+ showDropdown = false
171
+ searchText = ''
172
+ menuHeight: number | null = null
173
+
174
+ get filteredData () {
175
+ if (this.typeahead && this.searchText) {
176
+ return this.data.filter(item => item.label.toLowerCase().includes(this.searchText.toLowerCase()))
177
+ } else {
178
+ if (this.showEmptyOption && this.modelValue) {
179
+ return [{ value: null, label: this.emptyOptionLabel || '' }, ...this.data ]
180
+ }
181
+ return this.data
182
+ }
183
+ }
184
+
185
+ get menuPositionTop () {
186
+ if (this.menuHeight) return `-${this.menuHeight}`
187
+
188
+ if (this.subtext) return 60
189
+
190
+ return 36
191
+ }
192
+
193
+ mounted () {
194
+ if (this.autoFocus) {
195
+ (this.$refs['uikit-select__input-container'] as HTMLElement).focus()
196
+ }
197
+
198
+ if (this.typeahead && this.modelValue?.label) {
199
+ this.searchText = this.modelValue.label
200
+ }
201
+
202
+ this.updateMenuHeight()
203
+ }
204
+
205
+ keydownListener (e: Event | KeyboardEvent) {
206
+ if (this.focus && 'key' in e && e.key.match(/^[A-Za-z0-9\s\-_@]$/)) {
207
+ e.stopPropagation()
208
+ }
209
+ }
210
+
211
+ blurMenu (e?: FocusEvent) {
212
+ if ((e?.relatedTarget as Element)?.tagName === 'LI') {
213
+ return
214
+ }
215
+
216
+ this.focus = false
217
+ this.showDropdown = false
218
+
219
+ if (this.typeahead && !this.searchText) {
220
+ this.emitUpdateModelValue(null)
221
+ }
222
+ if (this.typeahead && this.searchText && this.filteredData.length !== 1) {
223
+ this.emitUpdateModelValue(null)
224
+ this.searchText = ''
225
+ } else if (this.typeahead && this.searchText && this.filteredData[0]) {
226
+ this.emitUpdateModelValue(this.filteredData[0])
227
+ }
228
+ }
229
+
230
+ updateMenuHeight () {
231
+ if (this.openMenuAbove) {
232
+ const originalShowDropdownValue = this.showDropdown
233
+ if (!this.showDropdown) {
234
+ this.showDropdown = true
235
+ }
236
+ this.$nextTick(() => {
237
+ const menu = this.$refs['menu'] as HTMLElement
238
+
239
+ if (menu) {
240
+ this.menuHeight = menu.getBoundingClientRect().height
241
+ }
242
+ if (!originalShowDropdownValue) {
243
+ this.showDropdown = false
244
+ }
245
+ })
246
+ }
247
+
248
+ this.menuHeight = null
249
+ }
250
+
251
+ keyPressedItem (e: KeyboardEvent) {
252
+ // select option on enter or space or tab (but not shift tab)
253
+ if (e.key === 'Enter' || e.key === ' ') {
254
+ e.preventDefault()
255
+ const itemValue = (e.target as HTMLElement).getAttribute('value')
256
+ const item = this.filteredData.find(i => itemValue ? String(i.value) === itemValue : i.value === null);
257
+ (this.$refs['uikit-select__input-container'] as HTMLElement).focus()
258
+ item && this.selectItem(item)
259
+ }
260
+ // close menu on tab
261
+ if (e.key === 'Tab' && !e.shiftKey) {
262
+ this.blurMenu()
263
+ }
264
+ // navigate items with up key
265
+ if (e.key === 'ArrowUp') {
266
+ e.preventDefault()
267
+ const itemValue = (e.target as HTMLElement).getAttribute('value')
268
+ const itemIndex = this.filteredData.findIndex(
269
+ i => itemValue ? String(i.value) === itemValue : i.value === null
270
+ )
271
+ const prevIndex = itemIndex < 1 ? 0 : itemIndex - 1
272
+ const prevValue = this.filteredData[prevIndex]?.value
273
+ const items = this.$refs['uikit-select__items'] as HTMLElement[]
274
+ const prevItem = items.find(
275
+ item => prevValue
276
+ ? String(prevValue) === item.getAttribute('value')
277
+ : item.getAttribute('value') === null
278
+ )
279
+ if (prevItem) {
280
+ prevItem.focus()
281
+ this.showDropdown = true
282
+ this.focus = true
283
+ }
284
+ }
285
+ // navigate items with down key
286
+ if (e.key === 'ArrowDown') {
287
+ e.preventDefault()
288
+ const data = this.filteredData
289
+ const itemValue = (e.target as HTMLElement).getAttribute('value')
290
+ const itemIndex = data.findIndex(i => itemValue ? String(i.value) === itemValue : i.value === null)
291
+ const nextIndex = itemIndex >= data.length - 1 ? data.length - 1 : itemIndex + 1
292
+ const nextValue = this.filteredData[nextIndex]?.value
293
+ const items = this.$refs['uikit-select__items'] as HTMLElement[]
294
+ const nextItem = items.find(
295
+ item => nextValue
296
+ ? String(nextValue) === item.getAttribute('value')
297
+ : item.getAttribute('value') === null
298
+ )
299
+ if (nextItem) {
300
+ nextItem.focus()
301
+ this.showDropdown = true
302
+ this.focus = true
303
+ }
304
+ }
305
+ }
306
+
307
+ keyPressedContainer (e: KeyboardEvent) {
308
+ if (!(e.target as HTMLElement).className.includes('uikit-select__input-container')
309
+ && !(e.target as HTMLElement).className.includes('uikit-select__input')
310
+ ) {
311
+ return
312
+ }
313
+
314
+ // open showDropdown on down arrow and select first item
315
+ if (e.key === 'ArrowDown'
316
+ || (e.key === 'Tab' && !e.shiftKey && this.typeahead && this.searchText && this.showDropdown)) {
317
+ e.preventDefault()
318
+ const firstValue = this.filteredData[0]?.value
319
+ const items = this.$refs['uikit-select__items'] as HTMLElement[]
320
+ const firstItem = items.find(
321
+ item => firstValue
322
+ ? String(firstValue) === item.getAttribute('value')
323
+ : item.getAttribute('value') === null
324
+ )
325
+ if (firstItem) {
326
+ firstItem.focus()
327
+ this.showDropdown = true
328
+ this.focus = true
329
+ }
330
+ }
331
+
332
+ // toggle showDropdown on enter or space + not typeahead
333
+ if (e.key === 'Enter' || (e.key === ' ' && !this.typeahead)) {
334
+ e.preventDefault()
335
+ this.showDropdown = !this.showDropdown
336
+ }
337
+
338
+ // escape to close dropdown
339
+ if (e.key === 'Escape') {
340
+ e.preventDefault()
341
+ e.stopPropagation()
342
+ this.showDropdown = false
343
+ }
344
+ }
345
+
346
+ mouseOverSelect () {
347
+ this.hover = this.disabled ? false : true
348
+ }
349
+
350
+ focusSelect () {
351
+ this.focus = this.disabled ? false : true
352
+ if (this.typeahead && !this.searchText) {
353
+ this.showDropdown = true
354
+ }
355
+ }
356
+
357
+ selectItem (item: IItem) {
358
+ if (item) {
359
+ this.showDropdown = false
360
+ }
361
+
362
+ if (item.type === 'link') {
363
+ this.emitLinkClick(item.value ? item : null)
364
+ } else {
365
+ this.emitUpdateModelValue(item.value ? item : null)
366
+ }
367
+ }
368
+
369
+ @Watch('showDropdown')
370
+ showDropdownChanged (newVal: boolean) {
371
+ this.emitOpenDropdown(newVal)
372
+ }
373
+
374
+ @Watch('modelValue')
375
+ valueChanged (newVal: IItem) {
376
+ if (this.typeahead) {
377
+ this.searchText = newVal?.label || ''
378
+ }
379
+ }
380
+
381
+ @Watch('searchText')
382
+ searchTextChanged (newVal: string) {
383
+ if (this.typeahead) {
384
+ const matchedItem = this.filteredData.find(item =>
385
+ item.label.toLowerCase() === newVal.toLowerCase()
386
+ )
387
+ if (!matchedItem) {
388
+ this.showDropdown = true
389
+ }
390
+ if (this.filteredData.length === 1 && matchedItem && this.modelValue?.label !== matchedItem.label) {
391
+ this.selectItem(matchedItem)
392
+ }
393
+
394
+ this.updateMenuHeight()
395
+ }
396
+ }
397
+
398
+ @Emit('update:modelValue')
399
+ emitUpdateModelValue (item: IItem | null) {
400
+ return item
401
+ }
402
+
403
+ @Emit('linkClick')
404
+ emitLinkClick (item: IItem | null) {
405
+ return item
406
+ }
407
+
408
+ @Emit('openDropdown')
409
+ emitOpenDropdown (open: boolean) {
410
+ return open
411
+ }
412
+ }
413
+ </script>
414
+
415
+ <style lang="scss">
416
+ @import '../../styles/colors';
417
+ @import '../../styles/breakpoints';
418
+
419
+ .uikit-select {
420
+ position: relative;
421
+
422
+ &__label {
423
+ font-size: 13px;
424
+ line-height: 14px;
425
+ margin: 0 0 6px 12px;
426
+ color: $slate-01;
427
+ display: block;
428
+
429
+ &--dark {
430
+ color: $fog;
431
+ }
432
+
433
+ &--hover {
434
+ color: $slate-03;
435
+
436
+ &--dark {
437
+ color: $fog;
438
+ }
439
+ }
440
+
441
+ &--focus {
442
+ color: $brand-blue;
443
+
444
+ &--dark {
445
+ color: $banana-bread;
446
+ }
447
+ }
448
+
449
+ &--error {
450
+ color: $red-pegasus;
451
+ }
452
+ }
453
+
454
+ &__input-container {
455
+ outline: none;
456
+ position: relative;
457
+ }
458
+
459
+ &__value,
460
+ &__input {
461
+ background-color: $white;
462
+ border: 1px solid rgba($pewter, 0.85);
463
+ color: $brand-black;
464
+ border-radius: 3px;
465
+ caret-color: $brand-blue;
466
+ padding: 9px 11px;
467
+ font-size: 15px;
468
+ line-height: 18px;
469
+ width: 100%;
470
+ height: 36px;
471
+ box-sizing: border-box;
472
+ cursor: default;
473
+ position: relative;
474
+ z-index: 1;
475
+ outline: none;
476
+ appearance: none;
477
+
478
+ &--dark {
479
+ background-color: $moonlit-ocean;
480
+ border-color: $pewter;
481
+ color: $white;
482
+ caret-color: $banana-bread;
483
+ }
484
+
485
+ &--placeholder,
486
+ &::placeholder {
487
+ color: $pewter;
488
+ }
489
+
490
+ &--hover {
491
+ border: 1px solid $baby-blue;
492
+
493
+ &--dark {
494
+ border: 0.5px solid $banana-bread;
495
+ }
496
+ }
497
+
498
+ &--focus {
499
+ border: 1px solid $brand-blue;
500
+
501
+ &--dark {
502
+ border-color: $banana-bread;
503
+ }
504
+ }
505
+
506
+ &--disabled {
507
+ background: $gray-background;
508
+ border: 1px solid $gray-background;
509
+ color: $slate-03;
510
+
511
+ &--dark {
512
+ border-color: $moonlit-ocean;
513
+ background-color: $moonlit-ocean;
514
+ }
515
+ }
516
+ }
517
+
518
+ &__input {
519
+ cursor: text !important;
520
+
521
+ &--error {
522
+ border: 1px solid $red-pegasus;
523
+ }
524
+
525
+ &--show-dropdown {
526
+ border-radius: 3px 3px 0 0;
527
+ }
528
+ }
529
+
530
+ &__value {
531
+ user-select: none;
532
+
533
+ &--subtext {
534
+ height: 60px;
535
+
536
+ &--dark {
537
+ background-color: $moonlit-ocean;
538
+ border-color: $pewter;
539
+ color: $fog;
540
+ caret-color: $banana-bread;
541
+ }
542
+ }
543
+ }
544
+
545
+ &__item-subtext,
546
+ &__subtext {
547
+ font-size: 13px;
548
+ line-height: 16px;
549
+ text-align: left;
550
+ color: $slate;
551
+ margin: 4px 0 0 0;
552
+
553
+ &--dark {
554
+ &--hover {
555
+ background-color: $charcoal;
556
+ }
557
+
558
+ border-color: $pewter;
559
+ color: $fog;
560
+ caret-color: $banana-bread;
561
+ }
562
+ }
563
+
564
+ &__arrow {
565
+ position: absolute;
566
+ right: 13px;
567
+ top: 14px;
568
+ color: $pewter;
569
+ width: 12px;
570
+ height: 7px;
571
+ z-index: 1;
572
+
573
+ &--hover {
574
+ color: $brand-blue;
575
+
576
+ &--dark {
577
+ color: $banana-bread;
578
+ }
579
+ }
580
+
581
+ &--focus {
582
+ color: $brand-blue;
583
+
584
+ &--dark {
585
+ color: $banana-bread;
586
+ }
587
+ }
588
+
589
+ &--show-dropdown {
590
+ color: $brand-blue;
591
+ transform: rotate(180deg);
592
+
593
+ &--dark {
594
+ color: $banana-bread;
595
+ }
596
+ }
597
+ }
598
+
599
+ &__list {
600
+ box-shadow: 0 4px 12px 0 rgba($brand-black, 0.1);
601
+ margin: 0;
602
+ padding: 10px 0;
603
+ list-style: none;
604
+ position: absolute;
605
+ left: 0;
606
+ width: 100%;
607
+ max-height: 187px;
608
+ overflow: auto;
609
+ background: $white;
610
+ z-index: 2;
611
+ border-radius: 0 0 6px 6px;
612
+
613
+ &--dark {
614
+ background-color: $moonlit-ocean;
615
+ box-shadow: 0 4px 12px 0 rgba($charcoal, 0.1);
616
+ color: $white;
617
+ }
618
+
619
+ &--subtext {
620
+ padding: 0 0;
621
+ }
622
+ }
623
+
624
+ &__item {
625
+ padding: 5px 11px;
626
+ font-size: 15px;
627
+ line-height: 20px;
628
+ cursor: default;
629
+ user-select: none;
630
+
631
+ &--link {
632
+ color: $brand-blue;
633
+ font-size: 15px;
634
+ padding: 9px 17px;
635
+ font-weight: 600;
636
+ cursor: pointer;
637
+
638
+ &--dark {
639
+ color: $banana-bread;
640
+ }
641
+ }
642
+
643
+ &:hover,
644
+ &:focus {
645
+ background: $gray-background;
646
+ outline: none;
647
+ }
648
+
649
+ &--dark {
650
+ &:hover,
651
+ &:focus {
652
+ background-color: $charcoal;
653
+ }
654
+ }
655
+
656
+ &--subtext {
657
+ padding: 9px 11px;
658
+ border-bottom: 1px solid $fog;
659
+
660
+ &:last-child {
661
+ border-bottom: none;
662
+ }
663
+
664
+ &--dark {
665
+ border-bottom: 1px solid $ash;
666
+ }
667
+ }
668
+ }
669
+ }
670
+ </style>