@pictogrammers/components 0.3.1

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 (379) hide show
  1. package/@types/css.d.ts +4 -0
  2. package/@types/html.d.ts +4 -0
  3. package/README.md +49 -0
  4. package/dist/main.js +3819 -0
  5. package/dist/pgAnnoy.js +116 -0
  6. package/dist/pgAvatar.js +136 -0
  7. package/dist/pgButton.js +116 -0
  8. package/dist/pgButtonGroup.js +116 -0
  9. package/dist/pgButtonLink.js +116 -0
  10. package/dist/pgButtonToggle.js +146 -0
  11. package/dist/pgCard.js +116 -0
  12. package/dist/pgCardUser.js +196 -0
  13. package/dist/pgColor.js +136 -0
  14. package/dist/pgDatabase.js +236 -0
  15. package/dist/pgDropdown.js +686 -0
  16. package/dist/pgGrid.js +126 -0
  17. package/dist/pgHeader.js +116 -0
  18. package/dist/pgIcon.js +116 -0
  19. package/dist/pgInputCheck.js +116 -0
  20. package/dist/pgInputCheckList.js +126 -0
  21. package/dist/pgInputFileLocal.js +116 -0
  22. package/dist/pgInputHexRgb.js +126 -0
  23. package/dist/pgInputRange.js +116 -0
  24. package/dist/pgInputSelect.js +116 -0
  25. package/dist/pgInputText.js +116 -0
  26. package/dist/pgInputTextIcon.js +176 -0
  27. package/dist/pgInputUserSelect.js +116 -0
  28. package/dist/pgListTag.js +136 -0
  29. package/dist/pgMarkdown.js +346 -0
  30. package/dist/pgMenuIcon.js +206 -0
  31. package/dist/pgModalAlert.js +126 -0
  32. package/dist/pgModification.js +396 -0
  33. package/dist/pgNav.js +116 -0
  34. package/dist/pgOverlay.js +96 -0
  35. package/dist/pgPicker.js +116 -0
  36. package/dist/pgPreview.js +116 -0
  37. package/dist/pgScroll.js +266 -0
  38. package/dist/pgSearch.js +146 -0
  39. package/dist/pgTab.js +116 -0
  40. package/dist/pgTabs.js +136 -0
  41. package/dist/pgToast.js +136 -0
  42. package/dist/pgToasts.js +136 -0
  43. package/dist/pgTooltip.js +126 -0
  44. package/index.html +302 -0
  45. package/package.json +25 -0
  46. package/pg/annoy/README.md +18 -0
  47. package/pg/annoy/__examples__/basic/basic.html +8 -0
  48. package/pg/annoy/__examples__/basic/basic.ts +11 -0
  49. package/pg/annoy/annoy.css +238 -0
  50. package/pg/annoy/annoy.html +59 -0
  51. package/pg/annoy/annoy.ts +48 -0
  52. package/pg/annoy/index.ts +3 -0
  53. package/pg/avatar/README.md +23 -0
  54. package/pg/avatar/__examples__/basic/basic.html +6 -0
  55. package/pg/avatar/__examples__/basic/basic.ts +41 -0
  56. package/pg/avatar/__examples__/basic/constants.ts +1 -0
  57. package/pg/avatar/avatar.css +45 -0
  58. package/pg/avatar/avatar.html +8 -0
  59. package/pg/avatar/avatar.spec.ts +51 -0
  60. package/pg/avatar/avatar.ts +37 -0
  61. package/pg/avatar/index.ts +3 -0
  62. package/pg/button/README.md +51 -0
  63. package/pg/button/__examples__/basic/basic.html +11 -0
  64. package/pg/button/__examples__/basic/basic.ts +11 -0
  65. package/pg/button/__examples__/states/states.html +8 -0
  66. package/pg/button/__examples__/states/states.ts +20 -0
  67. package/pg/button/button.css +91 -0
  68. package/pg/button/button.html +3 -0
  69. package/pg/button/button.ts +45 -0
  70. package/pg/button/index.ts +3 -0
  71. package/pg/buttonGroup/README.md +28 -0
  72. package/pg/buttonGroup/__examples__/basic/basic.html +12 -0
  73. package/pg/buttonGroup/__examples__/basic/basic.ts +11 -0
  74. package/pg/buttonGroup/buttonGroup.css +4 -0
  75. package/pg/buttonGroup/buttonGroup.html +1 -0
  76. package/pg/buttonGroup/buttonGroup.spec.ts +30 -0
  77. package/pg/buttonGroup/buttonGroup.ts +50 -0
  78. package/pg/buttonGroup/index.ts +3 -0
  79. package/pg/buttonLink/README.md +51 -0
  80. package/pg/buttonLink/__examples__/basic/basic.html +17 -0
  81. package/pg/buttonLink/__examples__/basic/basic.ts +11 -0
  82. package/pg/buttonLink/buttonLink.css +91 -0
  83. package/pg/buttonLink/buttonLink.html +3 -0
  84. package/pg/buttonLink/buttonLink.ts +46 -0
  85. package/pg/buttonLink/index.ts +3 -0
  86. package/pg/buttonToggle/README.md +54 -0
  87. package/pg/buttonToggle/__examples__/basic/basic.html +10 -0
  88. package/pg/buttonToggle/__examples__/basic/basic.ts +23 -0
  89. package/pg/buttonToggle/buttonToggle.css +8 -0
  90. package/pg/buttonToggle/buttonToggle.html +4 -0
  91. package/pg/buttonToggle/buttonToggle.ts +44 -0
  92. package/pg/buttonToggle/index.ts +3 -0
  93. package/pg/card/README.md +21 -0
  94. package/pg/card/__examples__/basic/basic.html +5 -0
  95. package/pg/card/__examples__/basic/basic.ts +11 -0
  96. package/pg/card/card.css +11 -0
  97. package/pg/card/card.html +3 -0
  98. package/pg/card/card.spec.ts +30 -0
  99. package/pg/card/card.ts +13 -0
  100. package/pg/card/index.ts +3 -0
  101. package/pg/cardUser/README.md +22 -0
  102. package/pg/cardUser/__examples__/basic/basic.html +3 -0
  103. package/pg/cardUser/__examples__/basic/basic.ts +30 -0
  104. package/pg/cardUser/__examples__/basic/constants.ts +1 -0
  105. package/pg/cardUser/cardUser.css +67 -0
  106. package/pg/cardUser/cardUser.html +23 -0
  107. package/pg/cardUser/cardUser.spec.ts +46 -0
  108. package/pg/cardUser/cardUser.ts +53 -0
  109. package/pg/cardUser/index.ts +3 -0
  110. package/pg/color/README.md +13 -0
  111. package/pg/color/__examples__/basic/basic.html +4 -0
  112. package/pg/color/__examples__/basic/basic.ts +20 -0
  113. package/pg/color/color.css +21 -0
  114. package/pg/color/color.html +1 -0
  115. package/pg/color/color.ts +97 -0
  116. package/pg/color/constants.ts +357 -0
  117. package/pg/color/index.ts +3 -0
  118. package/pg/color/utils.ts +27 -0
  119. package/pg/database/README.md +28 -0
  120. package/pg/database/__examples__/basic/basic.html +9 -0
  121. package/pg/database/__examples__/basic/basic.ts +37 -0
  122. package/pg/database/database.css +0 -0
  123. package/pg/database/database.html +0 -0
  124. package/pg/database/database.ts +42 -0
  125. package/pg/database/index.ts +3 -0
  126. package/pg/dropdown/README.md +13 -0
  127. package/pg/dropdown/__examples__/basic/basic.html +14 -0
  128. package/pg/dropdown/__examples__/basic/basic.ts +11 -0
  129. package/pg/dropdown/dropdown.css +46 -0
  130. package/pg/dropdown/dropdown.html +5 -0
  131. package/pg/dropdown/dropdown.ts +60 -0
  132. package/pg/dropdown/index.ts +3 -0
  133. package/pg/grid/README.md +97 -0
  134. package/pg/grid/__examples__/basic/basic.html +29 -0
  135. package/pg/grid/__examples__/basic/basic.ts +139 -0
  136. package/pg/grid/grid.css +68 -0
  137. package/pg/grid/grid.html +6 -0
  138. package/pg/grid/grid.spec.ts +66 -0
  139. package/pg/grid/grid.ts +417 -0
  140. package/pg/grid/index.ts +3 -0
  141. package/pg/header/README.md +23 -0
  142. package/pg/header/__examples__/basic/basic.html +8 -0
  143. package/pg/header/__examples__/basic/basic.ts +11 -0
  144. package/pg/header/header.css +42 -0
  145. package/pg/header/header.html +15 -0
  146. package/pg/header/header.ts +28 -0
  147. package/pg/header/index.ts +3 -0
  148. package/pg/icon/README.md +26 -0
  149. package/pg/icon/__examples__/basic/basic.html +16 -0
  150. package/pg/icon/__examples__/basic/basic.ts +34 -0
  151. package/pg/icon/__examples__/basic/constants.ts +2 -0
  152. package/pg/icon/icon.css +9 -0
  153. package/pg/icon/icon.html +3 -0
  154. package/pg/icon/icon.spec.ts +46 -0
  155. package/pg/icon/icon.ts +23 -0
  156. package/pg/icon/index.ts +3 -0
  157. package/pg/inputCheck/README.md +32 -0
  158. package/pg/inputCheck/__examples__/basic/basic.html +8 -0
  159. package/pg/inputCheck/__examples__/basic/basic.ts +23 -0
  160. package/pg/inputCheck/index.ts +3 -0
  161. package/pg/inputCheck/inputCheck.css +45 -0
  162. package/pg/inputCheck/inputCheck.html +6 -0
  163. package/pg/inputCheck/inputCheck.ts +42 -0
  164. package/pg/inputCheckList/README.md +35 -0
  165. package/pg/inputCheckList/__examples__/basic/basic.html +4 -0
  166. package/pg/inputCheckList/__examples__/basic/basic.ts +31 -0
  167. package/pg/inputCheckList/index.ts +3 -0
  168. package/pg/inputCheckList/inputCheckList.css +70 -0
  169. package/pg/inputCheckList/inputCheckList.html +1 -0
  170. package/pg/inputCheckList/inputCheckList.ts +103 -0
  171. package/pg/inputCheckList/templates/option.html +8 -0
  172. package/pg/inputFileLocal/README.md +30 -0
  173. package/pg/inputFileLocal/__examples__/basic/basic.html +4 -0
  174. package/pg/inputFileLocal/__examples__/basic/basic.ts +23 -0
  175. package/pg/inputFileLocal/index.ts +3 -0
  176. package/pg/inputFileLocal/inputFileLocal.css +80 -0
  177. package/pg/inputFileLocal/inputFileLocal.html +5 -0
  178. package/pg/inputFileLocal/inputFileLocal.ts +82 -0
  179. package/pg/inputHexRgb/README.md +15 -0
  180. package/pg/inputHexRgb/__examples__/basic/basic.html +4 -0
  181. package/pg/inputHexRgb/__examples__/basic/basic.ts +23 -0
  182. package/pg/inputHexRgb/index.ts +3 -0
  183. package/pg/inputHexRgb/inputHexRgb.css +96 -0
  184. package/pg/inputHexRgb/inputHexRgb.html +9 -0
  185. package/pg/inputHexRgb/inputHexRgb.ts +79 -0
  186. package/pg/inputHexRgb/utils.ts +27 -0
  187. package/pg/inputRange/README.md +18 -0
  188. package/pg/inputRange/__examples__/basic/basic.html +9 -0
  189. package/pg/inputRange/__examples__/basic/basic.ts +30 -0
  190. package/pg/inputRange/index.ts +3 -0
  191. package/pg/inputRange/inputRange.css +0 -0
  192. package/pg/inputRange/inputRange.html +1 -0
  193. package/pg/inputRange/inputRange.ts +53 -0
  194. package/pg/inputSelect/README.md +25 -0
  195. package/pg/inputSelect/__examples__/basic/basic.html +6 -0
  196. package/pg/inputSelect/__examples__/basic/basic.ts +30 -0
  197. package/pg/inputSelect/index.ts +3 -0
  198. package/pg/inputSelect/inputSelect.css +36 -0
  199. package/pg/inputSelect/inputSelect.html +4 -0
  200. package/pg/inputSelect/inputSelect.ts +57 -0
  201. package/pg/inputText/README.md +27 -0
  202. package/pg/inputText/__examples__/basic/basic.html +9 -0
  203. package/pg/inputText/__examples__/basic/basic.ts +30 -0
  204. package/pg/inputText/index.ts +3 -0
  205. package/pg/inputText/inputText.css +20 -0
  206. package/pg/inputText/inputText.html +1 -0
  207. package/pg/inputText/inputText.spec.ts +59 -0
  208. package/pg/inputText/inputText.ts +59 -0
  209. package/pg/inputTextIcon/README.md +26 -0
  210. package/pg/inputTextIcon/index.ts +3 -0
  211. package/pg/inputTextIcon/inputTextIcon.css +24 -0
  212. package/pg/inputTextIcon/inputTextIcon.html +4 -0
  213. package/pg/inputTextIcon/inputTextIcon.spec.ts +44 -0
  214. package/pg/inputTextIcon/inputTextIcon.ts +26 -0
  215. package/pg/inputUserSelect/README.md +31 -0
  216. package/pg/inputUserSelect/__examples__/basic/basic.html +4 -0
  217. package/pg/inputUserSelect/__examples__/basic/basic.ts +25 -0
  218. package/pg/inputUserSelect/__examples__/basic/constants.ts +33 -0
  219. package/pg/inputUserSelect/index.ts +3 -0
  220. package/pg/inputUserSelect/inputUserSelect.css +174 -0
  221. package/pg/inputUserSelect/inputUserSelect.html +18 -0
  222. package/pg/inputUserSelect/inputUserSelect.ts +266 -0
  223. package/pg/listTag/README.md +26 -0
  224. package/pg/listTag/__examples__/basic/basic.html +16 -0
  225. package/pg/listTag/__examples__/basic/basic.ts +53 -0
  226. package/pg/listTag/__examples__/basic/constants.ts +22 -0
  227. package/pg/listTag/index.ts +3 -0
  228. package/pg/listTag/listTag.css +9 -0
  229. package/pg/listTag/listTag.html +1 -0
  230. package/pg/listTag/listTag.ts +48 -0
  231. package/pg/listTag/partials/tag.html +3 -0
  232. package/pg/markdown/README.md +13 -0
  233. package/pg/markdown/__examples__/basic/basic.html +3 -0
  234. package/pg/markdown/__examples__/basic/basic.ts +51 -0
  235. package/pg/markdown/__examples__/basic/constants.ts +129 -0
  236. package/pg/markdown/index.ts +5 -0
  237. package/pg/markdown/markdown.css +760 -0
  238. package/pg/markdown/markdown.html +1 -0
  239. package/pg/markdown/markdown.md +123 -0
  240. package/pg/markdown/markdown.spec.ts +87 -0
  241. package/pg/markdown/markdown.ts +381 -0
  242. package/pg/markdown/markdownReplace.ts +7 -0
  243. package/pg/menuIcon/README.md +13 -0
  244. package/pg/menuIcon/__examples__/basic/basic.html +3 -0
  245. package/pg/menuIcon/__examples__/basic/basic.ts +15 -0
  246. package/pg/menuIcon/index.ts +3 -0
  247. package/pg/menuIcon/menuIcon.css +168 -0
  248. package/pg/menuIcon/menuIcon.html +64 -0
  249. package/pg/menuIcon/menuIcon.ts +271 -0
  250. package/pg/modalAlert/README.md +17 -0
  251. package/pg/modalAlert/__examples__/basic/basic.html +4 -0
  252. package/pg/modalAlert/__examples__/basic/basic.ts +27 -0
  253. package/pg/modalAlert/index.ts +3 -0
  254. package/pg/modalAlert/modalAlert.css +43 -0
  255. package/pg/modalAlert/modalAlert.html +22 -0
  256. package/pg/modalAlert/modalAlert.ts +45 -0
  257. package/pg/modification/README.md +34 -0
  258. package/pg/modification/__examples__/basic/basic.html +8 -0
  259. package/pg/modification/__examples__/basic/basic.ts +63 -0
  260. package/pg/modification/__examples__/basic/constants.ts +416 -0
  261. package/pg/modification/index.ts +3 -0
  262. package/pg/modification/modification.css +311 -0
  263. package/pg/modification/modification.html +1 -0
  264. package/pg/modification/modification.spec.ts +33 -0
  265. package/pg/modification/modification.ts +201 -0
  266. package/pg/modification/type/date.html +1 -0
  267. package/pg/modification/type/iconAliasCreated.html +13 -0
  268. package/pg/modification/type/iconAliasDeleted.html +13 -0
  269. package/pg/modification/type/iconAuthorModified.html +13 -0
  270. package/pg/modification/type/iconCreated.html +13 -0
  271. package/pg/modification/type/iconDeleted.html +13 -0
  272. package/pg/modification/type/iconDeprecated.html +13 -0
  273. package/pg/modification/type/iconDescriptionModified.html +10 -0
  274. package/pg/modification/type/iconModified.html +14 -0
  275. package/pg/modification/type/iconRenamed.html +13 -0
  276. package/pg/modification/type/iconTagCreated.html +13 -0
  277. package/pg/modification/type/iconTagDeleted.html +13 -0
  278. package/pg/modification/type/news.html +5 -0
  279. package/pg/nav/README.md +16 -0
  280. package/pg/nav/__examples__/basic/basic.html +5 -0
  281. package/pg/nav/__examples__/basic/basic.ts +11 -0
  282. package/pg/nav/index.ts +3 -0
  283. package/pg/nav/nav.css +14 -0
  284. package/pg/nav/nav.html +16 -0
  285. package/pg/nav/nav.ts +21 -0
  286. package/pg/overlay/README.md +37 -0
  287. package/pg/overlay/__examples__/basic/basic.css +3 -0
  288. package/pg/overlay/__examples__/basic/basic.html +3 -0
  289. package/pg/overlay/__examples__/basic/basic.ts +13 -0
  290. package/pg/overlay/index.ts +3 -0
  291. package/pg/overlay/overlay.ts +26 -0
  292. package/pg/picker/README.md +13 -0
  293. package/pg/picker/index.ts +3 -0
  294. package/pg/picker/picker.css +56 -0
  295. package/pg/picker/picker.html +8 -0
  296. package/pg/picker/picker.ts +66 -0
  297. package/pg/preview/README.md +19 -0
  298. package/pg/preview/__examples__/basic/basic.html +11 -0
  299. package/pg/preview/__examples__/basic/basic.ts +22 -0
  300. package/pg/preview/index.ts +3 -0
  301. package/pg/preview/preview.css +34 -0
  302. package/pg/preview/preview.html +5 -0
  303. package/pg/preview/preview.ts +38 -0
  304. package/pg/scroll/README.md +42 -0
  305. package/pg/scroll/__examples__/basic/basic.css +4 -0
  306. package/pg/scroll/__examples__/basic/basic.html +11 -0
  307. package/pg/scroll/__examples__/basic/basic.ts +88 -0
  308. package/pg/scroll/index.ts +3 -0
  309. package/pg/scroll/scroll.css +7 -0
  310. package/pg/scroll/scroll.html +3 -0
  311. package/pg/scroll/scroll.ts +158 -0
  312. package/pg/search/README.md +59 -0
  313. package/pg/search/__examples__/basic/basic.html +3 -0
  314. package/pg/search/__examples__/basic/basic.ts +29 -0
  315. package/pg/search/__examples__/basic/constants.ts +3 -0
  316. package/pg/search/index.ts +3 -0
  317. package/pg/search/search.css +188 -0
  318. package/pg/search/search.html +18 -0
  319. package/pg/search/search.ts +252 -0
  320. package/pg/search/utils.ts +12 -0
  321. package/pg/shared/README.md +28 -0
  322. package/pg/shared/copy.ts +25 -0
  323. package/pg/shared/database.ts +35 -0
  324. package/pg/shared/databaseService.ts +230 -0
  325. package/pg/shared/debounce.ts +12 -0
  326. package/pg/shared/enums/modificationType.ts +19 -0
  327. package/pg/shared/filter.ts +14 -0
  328. package/pg/shared/http.ts +83 -0
  329. package/pg/shared/iconFilter.spec.ts +61 -0
  330. package/pg/shared/iconFilter.ts +71 -0
  331. package/pg/shared/list.ts +34 -0
  332. package/pg/shared/models/alias.ts +40 -0
  333. package/pg/shared/models/font.ts +31 -0
  334. package/pg/shared/models/fontIcon.ts +25 -0
  335. package/pg/shared/models/fontVersion.ts +22 -0
  336. package/pg/shared/models/icon.ts +97 -0
  337. package/pg/shared/models/modification.ts +45 -0
  338. package/pg/shared/models/style.ts +12 -0
  339. package/pg/shared/models/tag.ts +37 -0
  340. package/pg/shared/models/user.ts +35 -0
  341. package/pg/shared/models/version.ts +20 -0
  342. package/pg/shared/removeDiacritics.ts +94 -0
  343. package/pg/shared/toast.ts +47 -0
  344. package/pg/shared/uuid.ts +6 -0
  345. package/pg/tab/README.md +18 -0
  346. package/pg/tab/index.ts +3 -0
  347. package/pg/tab/tab.css +13 -0
  348. package/pg/tab/tab.html +3 -0
  349. package/pg/tab/tab.ts +51 -0
  350. package/pg/tabs/README.md +31 -0
  351. package/pg/tabs/__examples__/basic/basic.html +13 -0
  352. package/pg/tabs/__examples__/basic/basic.ts +11 -0
  353. package/pg/tabs/index.ts +3 -0
  354. package/pg/tabs/partials/tab.html +3 -0
  355. package/pg/tabs/tabs.css +69 -0
  356. package/pg/tabs/tabs.html +4 -0
  357. package/pg/tabs/tabs.ts +102 -0
  358. package/pg/toast/README.md +13 -0
  359. package/pg/toast/index.ts +3 -0
  360. package/pg/toast/toast.css +112 -0
  361. package/pg/toast/toast.html +13 -0
  362. package/pg/toast/toast.ts +39 -0
  363. package/pg/toasts/README.md +37 -0
  364. package/pg/toasts/__examples__/basic/basic.html +11 -0
  365. package/pg/toasts/__examples__/basic/basic.ts +86 -0
  366. package/pg/toasts/index.ts +3 -0
  367. package/pg/toasts/toasts.css +8 -0
  368. package/pg/toasts/toasts.html +1 -0
  369. package/pg/toasts/toasts.ts +51 -0
  370. package/pg/tooltip/README.md +51 -0
  371. package/pg/tooltip/__examples__/basic/basic.css +38 -0
  372. package/pg/tooltip/__examples__/basic/basic.html +21 -0
  373. package/pg/tooltip/__examples__/basic/basic.ts +55 -0
  374. package/pg/tooltip/addTooltip.ts +31 -0
  375. package/pg/tooltip/index.ts +20 -0
  376. package/pg/tooltip/position.ts +15 -0
  377. package/pg/tooltip/tooltip.css +36 -0
  378. package/pg/tooltip/tooltip.html +4 -0
  379. package/pg/tooltip/tooltip.ts +170 -0
@@ -0,0 +1,3 @@
1
+ import PgScroll from './scroll';
2
+
3
+ export default PgScroll;
@@ -0,0 +1,7 @@
1
+ :host {
2
+ display: block;
3
+ }
4
+
5
+ div {
6
+ transform: translateY(0);
7
+ }
@@ -0,0 +1,3 @@
1
+ <div part="scroll">
2
+ <slot></slot>
3
+ </div>
@@ -0,0 +1,158 @@
1
+ import { Component, Prop, Part, Local } from '@pictogrammers/element';
2
+ import { throttle } from 'lodash-es';
3
+
4
+ import template from './scroll.html';
5
+ import style from './scroll.css';
6
+
7
+ declare const ResizeObserver;
8
+
9
+ @Component({
10
+ selector: 'pg-scroll',
11
+ style,
12
+ template
13
+ })
14
+ export default class PgScroll extends HTMLElement {
15
+
16
+ @Prop() height: string | number = 0;
17
+
18
+ @Part() $scroll: HTMLDivElement;
19
+
20
+ scrollElement;
21
+ currentHeight = -1;
22
+ columns = 10;
23
+ size = 44;
24
+ visible = false;
25
+ y = -1;
26
+ width = 0;
27
+
28
+ resizeObserver = new ResizeObserver(
29
+ throttle(
30
+ (entries) => {
31
+ const { width } = entries[0].contentRect;
32
+ this.columns = Math.floor(width / (this.size + 20));
33
+ this.y = -1;
34
+ this.width = width;
35
+ this.calculateScroll();
36
+ },
37
+ 100
38
+ )
39
+ );
40
+
41
+ connectedCallback() {
42
+ this.resizeObserver.observe(this.$scroll);
43
+ }
44
+
45
+ getInnerHeight() {
46
+ let parentElement = this.parentElement;
47
+ while (parentElement) {
48
+ if (parentElement.style.overflow === 'auto') {
49
+ return parentElement.getBoundingClientRect().height;
50
+ }
51
+ parentElement = parentElement.parentElement;
52
+ }
53
+ return window.innerHeight;
54
+ }
55
+
56
+ get isWindow() {
57
+ return this.scrollElement === window;
58
+ }
59
+
60
+ getView() {
61
+ const innerHeight = this.getInnerHeight();
62
+ const container = this.getBoundingClientRect();
63
+ const { y, height } = this.isWindow
64
+ ? { y: container.top, height: container.height }
65
+ : {
66
+ y: container.top - this.scrollElement.getBoundingClientRect().top,
67
+ height: container.height
68
+ };
69
+ const top = y < 0 ? -1 * y : 0;
70
+ const calcY = height - top - innerHeight < 0
71
+ ? height - innerHeight < 0 ? 0 : height - innerHeight
72
+ : top;
73
+ const calcHeight = height < innerHeight
74
+ ? height
75
+ : y + height - innerHeight > 0
76
+ ? innerHeight
77
+ : y + height - innerHeight;
78
+ return {
79
+ visible: (y < innerHeight && height + y > 0) || !this.isWindow,
80
+ y: calcY,
81
+ height: calcHeight < 0 ? innerHeight : calcHeight,
82
+ atEnd: calcHeight < 0
83
+ }
84
+ }
85
+
86
+ calculateScroll() {
87
+ const { visible, y, height } = this.getView();
88
+ if (visible) {
89
+ this.$scroll.style.transform = `translateY(${y}px)`;
90
+ this.$scroll.style.height = `${height}px`;
91
+ }
92
+ if (this.visible !== visible) {
93
+ this.visible = visible;
94
+ if (this.visible) {
95
+ this.enterView();
96
+ } else {
97
+ this.leaveView();
98
+ }
99
+ }
100
+ if (this.visible && this.y !== y) {
101
+ this.dispatchEvent(
102
+ new CustomEvent('calculate', {
103
+ detail: {
104
+ offsetY: y,
105
+ viewWidth: this.width,
106
+ viewHeight: height,
107
+ height: this.height
108
+ }
109
+ }
110
+ ));
111
+ this.y = y;
112
+ }
113
+ }
114
+
115
+ enterView() {
116
+ this.dispatchEvent(new CustomEvent('enter'));
117
+ }
118
+
119
+ leaveView() {
120
+ this.dispatchEvent(new CustomEvent('leave'));
121
+ }
122
+
123
+ getParentElement() {
124
+ let parentElement = this.parentElement;
125
+ while (parentElement) {
126
+ if (parentElement.style.overflow === 'auto') {
127
+ return parentElement;
128
+ }
129
+ parentElement = parentElement.parentElement;
130
+ }
131
+ return window;
132
+ }
133
+
134
+ updateHeight() {
135
+ this.scrollElement = this.getParentElement();
136
+ this.scrollElement.addEventListener('scroll',
137
+ throttle(
138
+ () => {
139
+ this.calculateScroll();
140
+ },
141
+ 100
142
+ )
143
+ );
144
+ this.style.height = `${this.currentHeight}px`;
145
+ this.y = -1;
146
+ this.calculateScroll();
147
+ }
148
+
149
+ render(changes) {
150
+ console.log('changes', changes)
151
+ const height = parseInt(`${this.height}`, 10);
152
+ console.log('set', this.height);
153
+ if (this.currentHeight !== height) {
154
+ this.currentHeight = height;
155
+ this.updateHeight();
156
+ }
157
+ }
158
+ }
@@ -0,0 +1,59 @@
1
+ # `<pg-search>`
2
+
3
+ The `pg-search` component allows a standard way to search all content on the site.
4
+
5
+ - Search Guides
6
+ - Search General Pages
7
+ - Search Icons by Name
8
+
9
+ ```typescript
10
+ import '@pictogrammers/components/pgSearch.js';
11
+ ```
12
+
13
+ ```html
14
+ <pg-search></pg-search>
15
+ ```
16
+
17
+ | Attribute | Required | Description |
18
+ | --------- | -------- | ----------- |
19
+ | icons | Required | Pass in icon array. |
20
+ | items | - | Pass in other items. |
21
+
22
+ | Events | Tested | Description |
23
+ | ---------- | -------- | ----------- |
24
+ | onsearch | | Called on enter key. |
25
+
26
+ ## Schemas
27
+
28
+ ### Icons
29
+
30
+ ```json
31
+ [
32
+ {
33
+ "id": "uuid1",
34
+ "name": "account",
35
+ "aliases": [
36
+ {
37
+ "name": "user"
38
+ }
39
+ ]
40
+ }
41
+ ]
42
+ ```
43
+
44
+ ### Items
45
+
46
+ ```json
47
+ [
48
+ {
49
+ "name": "Web Component",
50
+ "url": "/getting-started/web-component",
51
+ "type": "Documentation"
52
+ }
53
+ ]
54
+ ```
55
+
56
+ ## Accessibility
57
+
58
+ - Keyboard Navigation with Up/Down
59
+ - Focus States
@@ -0,0 +1,3 @@
1
+ <div class="example">
2
+ <pg-search part="search"></pg-search>
3
+ </div>
@@ -0,0 +1,29 @@
1
+ import { Component, Part, Prop } from '@pictogrammers/element';
2
+ import PgSearch from '../../search';
3
+ import { mdiAccount, mdiAccountBox, mdiAccountCircle } from './constants';
4
+
5
+ import template from './basic.html';
6
+
7
+ @Component({
8
+ selector: 'x-pg-search-basic',
9
+ template
10
+ })
11
+ export default class XPgSearchBasic extends HTMLElement {
12
+ @Part() $search: PgSearch;
13
+
14
+ connectedCallback() {
15
+ this.$search.items = [
16
+ { type: 'Documentation', name: 'Android', url: '/getting-started/android' },
17
+ { type: 'Documentation', name: 'Angular', url: '/getting-started/angular' },
18
+ { type: 'Documentation', name: 'AngularJS', url: '/getting-started/angularjs' },
19
+ { type: 'Documentation', name: 'Bootstrap', url: '/getting-started/bootstrap' },
20
+ { type: 'Documentation', name: 'How to Play Football', url: '/getting-started/football' },
21
+ { type: 'Documentation', name: 'Foo Angular Foo Angular', url: '/getting-started/bootstraps' }
22
+ ];
23
+ this.$search.icons = [
24
+ { name: 'account', data: mdiAccount, aliases: [{ name: 'user' }] },
25
+ { name: 'account-box', data: mdiAccountBox, aliases: [{ name: 'user-box' }] },
26
+ { name: 'account-circle', data: mdiAccountCircle, aliases: [{ name: 'user-circle' }] }
27
+ ] as any;
28
+ }
29
+ }
@@ -0,0 +1,3 @@
1
+ export const mdiAccount = 'M12,4A4,4 0 0,1 16,8A4,4 0 0,1 12,12A4,4 0 0,1 8,8A4,4 0 0,1 12,4M12,14C16.42,14 20,15.79 20,18V20H4V18C4,15.79 7.58,14 12,14Z';
2
+ export const mdiAccountBox = 'M6,17C6,15 10,13.9 12,13.9C14,13.9 18,15 18,17V18H6M15,9A3,3 0 0,1 12,12A3,3 0 0,1 9,9A3,3 0 0,1 12,6A3,3 0 0,1 15,9M3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3H5C3.89,3 3,3.9 3,5Z';
3
+ export const mdiAccountCircle = 'M12,19.2C9.5,19.2 7.29,17.92 6,16C6.03,14 10,12.9 12,12.9C14,12.9 17.97,14 18,16C16.71,17.92 14.5,19.2 12,19.2M12,5A3,3 0 0,1 15,8A3,3 0 0,1 12,11A3,3 0 0,1 9,8A3,3 0 0,1 12,5M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z';
@@ -0,0 +1,3 @@
1
+ import PgSearch from './search';
2
+
3
+ export default PgSearch;
@@ -0,0 +1,188 @@
1
+ :host {
2
+ display: block;
3
+ align-self: center;
4
+ font-family: var(--pg-font-family);
5
+ }
6
+
7
+ div {
8
+ display: grid;
9
+ grid-template-columns: 1fr 0;
10
+ grid-template-rows: 1fr 0;
11
+ }
12
+ input {
13
+ grid-row: 1;
14
+ grid-column: 1;
15
+ border-radius: 0.25rem;
16
+ border: 0;
17
+ padding: 0.25rem 0.5rem;
18
+ font-size: 1rem;
19
+ outline: none;
20
+ width: calc(100% - 1rem);
21
+ border: .0625rem solid var(--pg-search-border-color);
22
+ }
23
+ input:active {
24
+ box-shadow: 0 0 0 3px var(--pg-search-active-glow, rgb(79, 143, 249, 0.6));
25
+ }
26
+ input:focus {
27
+ box-shadow: 0 0 0 3px var(--pg-search-focus-glow, rgb(79, 143, 249, 0.5));
28
+ }
29
+ .active input + svg path {
30
+ fill: #453C4F;
31
+ }
32
+ svg {
33
+ grid-row: 1;
34
+ grid-column: 2;
35
+ width: 1.5rem;
36
+ height: 1.5rem;
37
+ justify-self: right;
38
+ margin-right: 0.25rem;
39
+ pointer-events: none;
40
+ align-self: center;
41
+ }
42
+ svg > path {
43
+ transition: fill 0.3s ease-in-out;
44
+ }
45
+ [part=menu] {
46
+ display: none;
47
+ background: #FFF;
48
+ grid-row: 2;
49
+ grid-column: 1 / span 2;
50
+ z-index: 1;
51
+ }
52
+ ul {
53
+ list-style: none;
54
+ display: flex;
55
+ flex-direction: column;
56
+ padding: 0;
57
+ margin: 0;
58
+ border-radius: 0.25rem;
59
+ box-shadow: 0 0.125rem 0.75rem rgba(0, 0, 0, 0.4);
60
+ }
61
+ ul > li {
62
+ color: #222;
63
+ }
64
+ ul > li > a {
65
+ display: flex;
66
+ padding: 0.25rem 0.5rem;
67
+ background: #FFF;
68
+ border-left: 1px solid #DDD;
69
+ border-right: 1px solid #DDD;
70
+ }
71
+ ul > li > a:hover,
72
+ ul > li > a:active,
73
+ ul > li > a:focus {
74
+ background: #DAF4FB;
75
+ }
76
+ ul > li.item:first-child > a {
77
+ border-top: 1px solid #DDD;
78
+ border-bottom: 1px solid #DDD;
79
+ border-radius: 0.25rem 0.25rem 0 0;
80
+ }
81
+ ul > li.item:not(:first-child) > a {
82
+ border-bottom: 1px solid #DDD;
83
+ }
84
+ ul > li.item:last-child > a {
85
+ border-radius: 0 0 0.25rem 0.25rem;
86
+ }
87
+ ul > li > a {
88
+ text-decoration: none;
89
+ color: #222;
90
+ }
91
+ ul > li > a strong {
92
+ color: #453C4F;
93
+ }
94
+ .section {
95
+ color: #FFF;
96
+ padding: 0.25rem 0.5rem;
97
+ font-weight: bold;
98
+ background: #453C4F;
99
+ border-radius: 0.25rem 0.25rem 0 0;
100
+ cursor: default;
101
+ }
102
+ .section + li a {
103
+ border-radius: 0;
104
+ }
105
+
106
+ li + .section {
107
+ border-radius: 0;
108
+ }
109
+
110
+ .type {
111
+ background-color: #453C4F;
112
+ border-radius: 0.25rem;
113
+ font-size: 0.75rem;
114
+ color: #fff;
115
+ padding-left: 0.25rem;
116
+ padding-right: 0.25rem;
117
+ margin: 0.125rem 0 0.125rem 0.25rem;
118
+ align-self: end;
119
+ }
120
+
121
+ .icon {
122
+ background-color: #453C4F;
123
+ padding-left: 0.25rem;
124
+ padding-right: 0.25rem;
125
+ }
126
+ .icon.first > a {
127
+ border-top-left-radius: 0.25rem;
128
+ border-top-right-radius: 0.25rem;
129
+ }
130
+ .icon.last {
131
+ padding-bottom: 0.25rem;
132
+ border-bottom-left-radius: 0.25rem;
133
+ border-bottom-right-radius: 0.25rem;
134
+ }
135
+ .icon.last > a {
136
+ border-radius: 0 0 0.25rem 0.25rem;
137
+ }
138
+ .icon svg {
139
+ color: #453C4F;
140
+ margin-right: 0.345rem;
141
+ margin-left: -0.25rem;
142
+ }
143
+
144
+ .all {
145
+ background-color: #453C4F;
146
+ padding: 0 0.25rem 0.25rem 0.25rem;
147
+ border-radius: 0 0 0.25rem 0.25rem;
148
+ }
149
+
150
+ .all a {
151
+ border-radius: 0.25rem;
152
+ }
153
+
154
+ [part~=empty] {
155
+ background: #453C4F;
156
+ border-radius: 0.25rem;
157
+ padding: 0.25rem;
158
+ box-shadow: 0 0.125rem 0.75rem rgba(0, 0, 0, 0.4);
159
+ }
160
+ [part~=empty] strong {
161
+ color: #fff;
162
+ padding: 0 0.25rem;
163
+ }
164
+ [part~=empty] a {
165
+ display: block;
166
+ background: #fff;
167
+ color: #453C4F;
168
+ text-decoration: none;
169
+ padding: 0.25rem 0.5rem;
170
+ border-radius: 0.25rem;
171
+ margin-top: 0.25rem;
172
+ }
173
+ [part~=empty] a:hover,
174
+ [part~=empty] a:active,
175
+ [part~=empty] a:focus {
176
+ background: #DAF4FB;
177
+ }
178
+ [part~=empty] a svg {
179
+ vertical-align: middle;
180
+ width: 1.5rem;
181
+ height: 1.5rem;
182
+ float: right;
183
+ margin: -0.125rem -0.25rem 0 0;
184
+ }
185
+
186
+ .hide {
187
+ display: none;
188
+ }
@@ -0,0 +1,18 @@
1
+ <div part="grid">
2
+ <input part="input" type="text" />
3
+ <svg viewBox="0 0 24 24"><path d="M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z" /></svg>
4
+ <div part="menu">
5
+ <ul part="list"></ul>
6
+ <section part="empty">
7
+ <strong>No Results</strong>
8
+ <a part="reqIcon" href="https://github.com/Templarian/MaterialDesign/issues/new?labels=Icon+Request&template=1_icon_request.md&title=" target="_blank">
9
+ Request an Icon
10
+ <svg viewBox="0 0 24 24"><path fill="currentColor" d="M10.59,13.41C11,13.8 11,14.44 10.59,14.83C10.2,15.22 9.56,15.22 9.17,14.83C7.22,12.88 7.22,9.71 9.17,7.76V7.76L12.71,4.22C14.66,2.27 17.83,2.27 19.78,4.22C21.73,6.17 21.73,9.34 19.78,11.29L18.29,12.78C18.3,11.96 18.17,11.14 17.89,10.36L18.36,9.88C19.54,8.71 19.54,6.81 18.36,5.64C17.19,4.46 15.29,4.46 14.12,5.64L10.59,9.17C9.41,10.34 9.41,12.24 10.59,13.41M13.41,9.17C13.8,8.78 14.44,8.78 14.83,9.17C16.78,11.12 16.78,14.29 14.83,16.24V16.24L11.29,19.78C9.34,21.73 6.17,21.73 4.22,19.78C2.27,17.83 2.27,14.66 4.22,12.71L5.71,11.22C5.7,12.04 5.83,12.86 6.11,13.65L5.64,14.12C4.46,15.29 4.46,17.19 5.64,18.36C6.81,19.54 8.71,19.54 9.88,18.36L13.41,14.83C14.59,13.66 14.59,11.76 13.41,10.59C13,10.2 13,9.56 13.41,9.17Z" /></svg>
11
+ </a>
12
+ <a part="reqDoc" href="https://github.com/Templarian/MaterialDesign/issues/new?labels=Documentation&template=6_doc_guide_request.md&title=" target="_blank">
13
+ Request Documentation
14
+ <svg viewBox="0 0 24 24"><path fill="currentColor" d="M10.59,13.41C11,13.8 11,14.44 10.59,14.83C10.2,15.22 9.56,15.22 9.17,14.83C7.22,12.88 7.22,9.71 9.17,7.76V7.76L12.71,4.22C14.66,2.27 17.83,2.27 19.78,4.22C21.73,6.17 21.73,9.34 19.78,11.29L18.29,12.78C18.3,11.96 18.17,11.14 17.89,10.36L18.36,9.88C19.54,8.71 19.54,6.81 18.36,5.64C17.19,4.46 15.29,4.46 14.12,5.64L10.59,9.17C9.41,10.34 9.41,12.24 10.59,13.41M13.41,9.17C13.8,8.78 14.44,8.78 14.83,9.17C16.78,11.12 16.78,14.29 14.83,16.24V16.24L11.29,19.78C9.34,21.73 6.17,21.73 4.22,19.78C2.27,17.83 2.27,14.66 4.22,12.71L5.71,11.22C5.7,12.04 5.83,12.86 6.11,13.65L5.64,14.12C4.46,15.29 4.46,17.19 5.64,18.36C6.81,19.54 8.71,19.54 9.88,18.36L13.41,14.83C14.59,13.66 14.59,11.76 13.41,10.59C13,10.2 13,9.56 13.41,9.17Z" /></svg>
15
+ </a>
16
+ </section>
17
+ </div>
18
+ </div>