@ulu/frontend 0.1.0-beta.4 → 0.1.0-beta.40

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 (295) hide show
  1. package/CHANGELOG.md +332 -1
  2. package/dist/ulu-frontend.min.css +1 -1
  3. package/dist/ulu-frontend.min.js +28 -27
  4. package/docs-dev/assets/main.js +832 -421
  5. package/docs-dev/assets/placeholder/icon-calendar.svg +1 -0
  6. package/docs-dev/assets/placeholder/icon-check.svg +1 -0
  7. package/docs-dev/assets/style.css +629 -233
  8. package/docs-dev/changelog/index.html +6079 -0
  9. package/docs-dev/changelog/updates-and-changes/index.html +5109 -0
  10. package/docs-dev/demos/accordion/index.html +904 -321
  11. package/docs-dev/demos/basic-hero/index.html +111 -0
  12. package/docs-dev/demos/breakpoints-manager/index.html +5246 -0
  13. package/docs-dev/demos/button/index.html +916 -323
  14. package/docs-dev/demos/button-verbose/index.html +5238 -0
  15. package/docs-dev/demos/callout/index.html +951 -328
  16. package/docs-dev/demos/captioned-figure/index.html +904 -321
  17. package/docs-dev/demos/card/index.html +970 -748
  18. package/docs-dev/demos/card-grid/index.html +5357 -0
  19. package/docs-dev/demos/card-new/index.html +5088 -0
  20. package/docs-dev/demos/card-old/index.html +5223 -0
  21. package/docs-dev/demos/card.1/index.html +5223 -0
  22. package/docs-dev/demos/card.TRASH/index.html +5541 -0
  23. package/docs-dev/demos/counter-list/index.html +5224 -0
  24. package/docs-dev/demos/css-icons/index.html +904 -321
  25. package/docs-dev/demos/data-grid/index.html +1014 -511
  26. package/docs-dev/demos/data-table/index.html +1064 -348
  27. package/docs-dev/demos/details-group/index.html +5267 -0
  28. package/docs-dev/demos/file-save/index.html +904 -321
  29. package/docs-dev/demos/flipcard/index.html +904 -321
  30. package/docs-dev/demos/form-theme/index.html +922 -352
  31. package/docs-dev/demos/hero/index.html +12 -4
  32. package/docs-dev/demos/image-grid/index.html +12 -4
  33. package/docs-dev/demos/index.html +904 -321
  34. package/docs-dev/demos/list-inline/index.html +5220 -0
  35. package/docs-dev/demos/list-inline.1/index.html +4727 -0
  36. package/docs-dev/demos/list-lines/index.html +5210 -0
  37. package/docs-dev/demos/menu-stack/index.html +975 -377
  38. package/docs-dev/demos/modals/index.html +1010 -357
  39. package/docs-dev/demos/nav-strip/index.html +924 -377
  40. package/docs-dev/demos/overlay-section/index.html +979 -326
  41. package/docs-dev/demos/popovers/index.html +1152 -327
  42. package/docs-dev/demos/print/index.html +904 -321
  43. package/docs-dev/demos/pull-quote/index.html +904 -321
  44. package/docs-dev/demos/rule/index.html +952 -357
  45. package/docs-dev/demos/scroll-slider/index.html +72 -106
  46. package/docs-dev/demos/scrollpoints/index.html +905 -322
  47. package/docs-dev/demos/slider/index.html +12 -4
  48. package/docs-dev/demos/spoke-spinner/index.html +904 -321
  49. package/docs-dev/demos/sticky-list/index.html +5223 -0
  50. package/docs-dev/demos/tabs/index.html +944 -325
  51. package/docs-dev/demos/tag/index.html +904 -321
  52. package/docs-dev/demos/theme-toggle/index.html +5279 -0
  53. package/docs-dev/demos/tile-grid-overlay/index.html +12 -4
  54. package/docs-dev/demos/tiles/index.html +904 -321
  55. package/docs-dev/demos/tooltip/index.html +904 -321
  56. package/docs-dev/guide/building-stylesheet/index.html +904 -321
  57. package/docs-dev/guide/developing-ulu-scss-module/index.html +904 -321
  58. package/docs-dev/guide/index.html +904 -321
  59. package/docs-dev/guide/updates-and-changes/index.html +5033 -0
  60. package/docs-dev/index.html +904 -321
  61. package/docs-dev/javascript/events/index.html +901 -320
  62. package/docs-dev/javascript/index.html +904 -321
  63. package/docs-dev/javascript/settings/index.html +5400 -0
  64. package/docs-dev/javascript/ui-breakpoints/index.html +916 -335
  65. package/docs-dev/javascript/ui-collapsible/index.html +901 -320
  66. package/docs-dev/javascript/ui-details-group/index.html +5322 -0
  67. package/docs-dev/javascript/ui-dialog/index.html +967 -371
  68. package/docs-dev/javascript/ui-flipcard/index.html +964 -327
  69. package/docs-dev/javascript/ui-grid/index.html +913 -358
  70. package/docs-dev/javascript/ui-modal-builder/index.html +914 -354
  71. package/docs-dev/javascript/ui-overflow-scroller/index.html +901 -320
  72. package/docs-dev/javascript/ui-overflow-scroller-pager/index.html +901 -320
  73. package/docs-dev/javascript/ui-page/index.html +901 -320
  74. package/docs-dev/javascript/ui-popover/index.html +911 -334
  75. package/docs-dev/javascript/ui-print/index.html +901 -328
  76. package/docs-dev/javascript/ui-print-details/index.html +901 -320
  77. package/docs-dev/javascript/ui-programmatic-modal/index.html +901 -320
  78. package/docs-dev/javascript/ui-proxy-click/index.html +990 -324
  79. package/docs-dev/javascript/ui-resizer/index.html +901 -320
  80. package/docs-dev/javascript/ui-scroll-slider/index.html +941 -328
  81. package/docs-dev/javascript/ui-scrollpoint/index.html +907 -333
  82. package/docs-dev/javascript/ui-slider/index.html +1099 -327
  83. package/docs-dev/javascript/ui-tabs/index.html +914 -370
  84. package/docs-dev/javascript/ui-theme-toggle/index.html +5410 -0
  85. package/docs-dev/javascript/ui-tooltip/index.html +940 -363
  86. package/docs-dev/javascript/utils-class-logger/index.html +901 -320
  87. package/docs-dev/javascript/utils-css/index.html +5224 -0
  88. package/docs-dev/javascript/utils-dom/index.html +1037 -334
  89. package/docs-dev/javascript/utils-file-save/index.html +901 -320
  90. package/docs-dev/javascript/utils-floating-ui/index.html +901 -320
  91. package/docs-dev/javascript/utils-id/index.html +901 -320
  92. package/docs-dev/javascript/utils-pause-youtube-video/index.html +901 -320
  93. package/docs-dev/javascript/utils-system/index.html +5527 -0
  94. package/docs-dev/sass/base/color/index.html +901 -320
  95. package/docs-dev/sass/base/elements/index.html +973 -392
  96. package/docs-dev/sass/base/index/index.html +959 -378
  97. package/docs-dev/sass/base/index.html +904 -321
  98. package/docs-dev/sass/base/keyframes/index.html +901 -320
  99. package/docs-dev/sass/base/layout/index.html +966 -385
  100. package/docs-dev/sass/base/normalize/index.html +901 -320
  101. package/docs-dev/sass/base/print/index.html +901 -320
  102. package/docs-dev/sass/base/root/index.html +901 -320
  103. package/docs-dev/sass/base/typography/index.html +901 -320
  104. package/docs-dev/sass/components/accordion/index.html +1026 -445
  105. package/docs-dev/sass/components/adaptive-spacing/index.html +1027 -446
  106. package/docs-dev/sass/components/badge/index.html +1005 -424
  107. package/docs-dev/sass/components/basic-hero/index.html +5385 -0
  108. package/docs-dev/sass/components/button/index.html +952 -371
  109. package/docs-dev/sass/components/button-verbose/index.html +1089 -433
  110. package/docs-dev/sass/components/callout/index.html +1086 -482
  111. package/docs-dev/sass/components/captioned-figure/index.html +1070 -374
  112. package/docs-dev/sass/components/card/index.html +1121 -491
  113. package/docs-dev/sass/components/card-grid/index.html +973 -392
  114. package/docs-dev/sass/components/counter-list/index.html +5458 -0
  115. package/docs-dev/sass/components/css-icon/index.html +1052 -464
  116. package/docs-dev/sass/components/data-grid/index.html +1087 -499
  117. package/docs-dev/sass/components/data-table/index.html +1154 -381
  118. package/docs-dev/sass/components/fill-context/index.html +901 -320
  119. package/docs-dev/sass/components/flipcard/index.html +1071 -459
  120. package/docs-dev/sass/components/flipcard-grid/index.html +960 -379
  121. package/docs-dev/sass/components/form-theme/index.html +1349 -672
  122. package/docs-dev/sass/components/hero/index.html +1016 -387
  123. package/docs-dev/sass/components/horizontal-rule/index.html +959 -378
  124. package/docs-dev/sass/components/image-grid/index.html +966 -385
  125. package/docs-dev/sass/components/index/index.html +1004 -419
  126. package/docs-dev/sass/components/index.html +904 -321
  127. package/docs-dev/sass/components/links/index.html +901 -320
  128. package/docs-dev/sass/components/list-inline/index.html +5399 -0
  129. package/docs-dev/sass/components/list-lines/index.html +1009 -432
  130. package/docs-dev/sass/components/list-ordered/index.html +903 -322
  131. package/docs-dev/sass/components/list-unordered/index.html +901 -320
  132. package/docs-dev/sass/components/menu-stack/index.html +1050 -456
  133. package/docs-dev/sass/components/modal/index.html +1032 -444
  134. package/docs-dev/sass/components/nav-strip/index.html +1023 -442
  135. package/docs-dev/sass/components/overlay-section/index.html +1010 -429
  136. package/docs-dev/sass/components/pager/index.html +1017 -436
  137. package/docs-dev/sass/components/placeholder-block/index.html +1017 -436
  138. package/docs-dev/sass/components/popover/index.html +1068 -451
  139. package/docs-dev/sass/components/pull-quote/index.html +1017 -436
  140. package/docs-dev/sass/components/ratio-box/index.html +969 -388
  141. package/docs-dev/sass/components/rule/index.html +972 -391
  142. package/docs-dev/sass/components/scroll-slider/index.html +1019 -450
  143. package/docs-dev/sass/components/skip-link/index.html +961 -380
  144. package/docs-dev/sass/components/slider/index.html +1023 -442
  145. package/docs-dev/sass/components/spoke-spinner/index.html +961 -380
  146. package/docs-dev/sass/components/sticky-list/index.html +5603 -0
  147. package/docs-dev/sass/components/tabs/index.html +1020 -439
  148. package/docs-dev/sass/components/tag/index.html +1064 -483
  149. package/docs-dev/sass/components/tile-button/index.html +1004 -423
  150. package/docs-dev/sass/components/tile-grid/index.html +1045 -464
  151. package/docs-dev/sass/components/tile-grid-overlay/index.html +940 -359
  152. package/docs-dev/sass/components/vignette/index.html +965 -378
  153. package/docs-dev/sass/components/wysiwyg/index.html +968 -387
  154. package/docs-dev/sass/core/breakpoint/index.html +1045 -450
  155. package/docs-dev/sass/core/button/index.html +1438 -857
  156. package/docs-dev/sass/core/color/index.html +1084 -496
  157. package/docs-dev/sass/core/cssvar/index.html +950 -369
  158. package/docs-dev/sass/core/element/index.html +1504 -782
  159. package/docs-dev/sass/core/index.html +901 -320
  160. package/docs-dev/sass/core/layout/index.html +1062 -462
  161. package/docs-dev/sass/core/path/index.html +953 -372
  162. package/docs-dev/sass/core/selector/index.html +952 -371
  163. package/docs-dev/sass/core/typography/index.html +1171 -590
  164. package/docs-dev/sass/core/units/index.html +984 -403
  165. package/docs-dev/sass/core/utils/index.html +1941 -500
  166. package/docs-dev/sass/helpers/color/index.html +901 -320
  167. package/docs-dev/sass/helpers/display/index.html +902 -321
  168. package/docs-dev/sass/helpers/index/index.html +956 -375
  169. package/docs-dev/sass/helpers/index.html +904 -321
  170. package/docs-dev/sass/helpers/print/index.html +843 -292
  171. package/docs-dev/sass/helpers/typography/index.html +901 -320
  172. package/docs-dev/sass/helpers/units/index.html +950 -369
  173. package/docs-dev/sass/helpers/utilities/index.html +903 -322
  174. package/docs-dev/sass/index.html +904 -321
  175. package/js/index.js +1 -0
  176. package/js/settings.js +95 -0
  177. package/js/ui/breakpoints.js +19 -16
  178. package/js/ui/collapsible.js +8 -1
  179. package/js/ui/details-group.js +112 -0
  180. package/js/ui/dialog.js +90 -42
  181. package/js/ui/dialog.todo +2 -36
  182. package/js/ui/flipcard.js +37 -57
  183. package/js/ui/grid.js +15 -13
  184. package/js/ui/index.js +1 -0
  185. package/js/ui/modal-builder.js +45 -54
  186. package/js/ui/overflow-scroller.js +6 -4
  187. package/js/ui/popover.js +38 -38
  188. package/js/ui/print.js +16 -25
  189. package/js/ui/programmatic-modal.js +9 -3
  190. package/js/ui/proxy-click.js +50 -36
  191. package/js/ui/scroll-slider.js +24 -30
  192. package/js/ui/scrollpoint.js +28 -64
  193. package/js/ui/slider.js +61 -62
  194. package/js/ui/tabs.js +23 -36
  195. package/js/ui/theme-toggle.js +331 -94
  196. package/js/ui/tooltip.js +27 -32
  197. package/js/utils/css.js +13 -0
  198. package/js/utils/dom.js +69 -4
  199. package/js/utils/font-awesome.js +18 -0
  200. package/js/utils/index.js +2 -1
  201. package/js/utils/system.js +154 -0
  202. package/package.json +10 -7
  203. package/scss/_breakpoint.scss +16 -3
  204. package/scss/_color.scss +9 -2
  205. package/scss/_element.scss +91 -0
  206. package/scss/_layout.scss +7 -8
  207. package/scss/_utils.scss +248 -13
  208. package/scss/components/README.todos +14 -0
  209. package/scss/components/_accordion.scss +18 -20
  210. package/scss/components/_badge.scss +3 -2
  211. package/scss/components/_basic-hero.scss +112 -0
  212. package/scss/components/_button-verbose.scss +102 -20
  213. package/scss/components/_callout.scss +127 -79
  214. package/scss/components/_captioned-figure.scss +23 -5
  215. package/scss/components/_card-grid.scss +1 -1
  216. package/scss/components/_card.scss +242 -88
  217. package/scss/components/_counter-list.scss +133 -0
  218. package/scss/components/_css-icon.scss +33 -28
  219. package/scss/components/_data-grid.scss +38 -9
  220. package/scss/components/_data-table.scss +44 -4
  221. package/scss/components/_flipcard.scss +21 -15
  222. package/scss/components/_form-theme.scss +146 -135
  223. package/scss/components/_hero.scss +12 -10
  224. package/scss/components/_index.scss +24 -0
  225. package/scss/components/_list-inline.scss +80 -0
  226. package/scss/components/_list-lines.scss +44 -33
  227. package/scss/components/_list-ordered.scss +0 -1
  228. package/scss/components/_menu-stack.scss +42 -26
  229. package/scss/components/_modal.scss +29 -19
  230. package/scss/components/_nav-strip.scss +25 -16
  231. package/scss/components/_overlay-section.scss +4 -6
  232. package/scss/components/_pager.scss +6 -6
  233. package/scss/components/_placeholder-block.scss +4 -4
  234. package/scss/components/_popover.scss +174 -73
  235. package/scss/components/_pull-quote.scss +13 -13
  236. package/scss/components/_ratio-box.scss +2 -5
  237. package/scss/components/_rule.scss +1 -1
  238. package/scss/components/_scroll-slider.scss +2 -6
  239. package/scss/components/_skip-link.scss +2 -1
  240. package/scss/components/_slider.scss +17 -38
  241. package/scss/components/_spoke-spinner.scss +2 -2
  242. package/scss/components/_sticky-list.scss +206 -0
  243. package/scss/components/_tabs.scss +4 -2
  244. package/scss/components/_tag.scss +1 -1
  245. package/scss/components/_vignette.scss +3 -5
  246. package/scss/helpers/_display.scss +15 -18
  247. package/scss/helpers/_print.scss +12 -7
  248. package/scss/helpers/_utilities.scss +42 -32
  249. package/types/index.d.ts +1 -0
  250. package/types/settings.d.ts +66 -0
  251. package/types/settings.d.ts.map +1 -0
  252. package/types/ui/breakpoints.d.ts +14 -14
  253. package/types/ui/breakpoints.d.ts.map +1 -1
  254. package/types/ui/collapsible.d.ts.map +1 -1
  255. package/types/ui/details-group.d.ts +38 -0
  256. package/types/ui/details-group.d.ts.map +1 -0
  257. package/types/ui/dialog.d.ts +20 -14
  258. package/types/ui/dialog.d.ts.map +1 -1
  259. package/types/ui/flipcard.d.ts +16 -10
  260. package/types/ui/flipcard.d.ts.map +1 -1
  261. package/types/ui/grid.d.ts +4 -6
  262. package/types/ui/grid.d.ts.map +1 -1
  263. package/types/ui/index.d.ts +1 -0
  264. package/types/ui/modal-builder.d.ts +8 -11
  265. package/types/ui/modal-builder.d.ts.map +1 -1
  266. package/types/ui/overflow-scroller.d.ts +2 -2
  267. package/types/ui/overflow-scroller.d.ts.map +1 -1
  268. package/types/ui/popover.d.ts +6 -7
  269. package/types/ui/popover.d.ts.map +1 -1
  270. package/types/ui/print.d.ts +0 -4
  271. package/types/ui/print.d.ts.map +1 -1
  272. package/types/ui/programmatic-modal.d.ts.map +1 -1
  273. package/types/ui/proxy-click.d.ts +19 -3
  274. package/types/ui/proxy-click.d.ts.map +1 -1
  275. package/types/ui/scroll-slider.d.ts +5 -7
  276. package/types/ui/scroll-slider.d.ts.map +1 -1
  277. package/types/ui/scrollpoint.d.ts +3 -8
  278. package/types/ui/scrollpoint.d.ts.map +1 -1
  279. package/types/ui/slider.d.ts +24 -14
  280. package/types/ui/slider.d.ts.map +1 -1
  281. package/types/ui/tabs.d.ts +6 -8
  282. package/types/ui/tabs.d.ts.map +1 -1
  283. package/types/ui/theme-toggle.d.ts +51 -7
  284. package/types/ui/theme-toggle.d.ts.map +1 -1
  285. package/types/ui/tooltip.d.ts +3 -5
  286. package/types/ui/tooltip.d.ts.map +1 -1
  287. package/types/utils/css.d.ts +11 -0
  288. package/types/utils/css.d.ts.map +1 -0
  289. package/types/utils/dom.d.ts +36 -4
  290. package/types/utils/dom.d.ts.map +1 -1
  291. package/types/utils/font-awesome.d.ts +5 -0
  292. package/types/utils/font-awesome.d.ts.map +1 -0
  293. package/types/utils/index.d.ts +1 -0
  294. package/types/utils/system.d.ts +113 -0
  295. package/types/utils/system.d.ts.map +1 -0
@@ -1,26 +1,27 @@
1
1
  /**
2
2
  * @module ui/proxy-click
3
+ * @description Used for cards and things that look like they should be clickable
4
+ * even though the link in their content is the only clickable element. This way
5
+ * the entire cards content doesn't need to be in a link (which isn't accessible).
6
+ *
7
+ * The script allows only for clicks with a duration of 250ms to avoid conflict
8
+ * with a user selecting text. Works with either links or buttons because it just
9
+ * uses the elements .click(). Uses data-attributes for selection by default.
3
10
  */
4
11
 
12
+ import { ComponentInitializer } from "../utils/system.js";
5
13
 
6
- // Used for cards and things that look like they should be clickable even
7
- // though the link in their content is the only clickable element. This way the
8
- // entire cards content doesn't need to be in a link (which isn't accessible)
9
- // - The script allows only for clicks with a duration of 250ms to avoid
10
- // conflict with a user selecting text.
11
- // - Works with either links or buttons because it just uses the elements .click()
12
- // - Uses data-attributes for selection
13
- import { getName } from "../events/index.js";
14
- import { getDatasetOptionalJson } from "../utils/dom.js";
15
-
16
- const attrs = {
17
- trigger: "data-ulu-proxy-click",
18
- init: "data-ulu-proxy-click-init",
19
- };
20
-
21
- const attrSelector = key => `[${ attrs[key] }]`;
22
- const attrSelectorInitial = key => `${ attrSelector(key) }:not([${ attrs.init }])`;
14
+ /**
15
+ * Proxy Click Component Initializer
16
+ */
17
+ export const initializer = new ComponentInitializer({
18
+ type: "proxy-click",
19
+ baseAttribute: "data-ulu-proxy-click"
20
+ });
23
21
 
22
+ /**
23
+ * Default options
24
+ */
24
25
  export const defaults = {
25
26
  selector: "[data-ulu-proxy-click-source]",
26
27
  selectorPreventBase: "input, select, textarea, button, a, [tabindex='-1']",
@@ -32,7 +33,7 @@ export const defaults = {
32
33
  let currentDefaults = { ...defaults };
33
34
 
34
35
  /**
35
- * @param {Object} options Change options used as default for dialogs, can then be overriden by data attribute settings on element
36
+ * @param {Object} options Change options used as default for dialogs, can then be overridden by data attribute settings on element
36
37
  */
37
38
  export function setDefaults(options) {
38
39
  currentDefaults = Object.assign({}, currentDefaults, options);
@@ -42,26 +43,39 @@ export function setDefaults(options) {
42
43
  * - This will only initialize elements once, it is safe to call on page changes
43
44
  */
44
45
  export function init() {
45
- document.addEventListener(getName("pageModified"), () => setup());
46
- setup();
47
- }
48
-
49
- export function setup(context = document) {
50
- const proxies = context.querySelectorAll(attrSelectorInitial("trigger"));
51
- proxies.forEach(proxy => {
52
- const elOptions = getDatasetOptionalJson(proxy, "siteProxyClick");
53
- const options = Object.assign({}, currentDefaults, elOptions);
54
- const child = proxy.querySelector(options.selector);
55
- if (child) {
56
- attachHandlers(proxy, child, options);
57
- proxy.setAttribute(attrs.init, "");
58
- } else {
59
- console.error("Unable to locate proxy click source", options.selector);
46
+ initializer.init({
47
+ withData: true,
48
+ events: ["pageModified"],
49
+ setup({ element, data, initialize }) {
50
+ setupProxy(element, data);
51
+ initialize();
60
52
  }
61
53
  });
62
54
  }
63
- export function attachHandlers(proxy, child, options) {
64
- const { selectorPreventBase: spb, selectorPrevent: sp } = options;
55
+
56
+ /**
57
+ * Setup a single proxy click
58
+ * @param {Node} proxy The container who's click should proxy the click of inner element with options.selector (defaults to [data-ulu-proxy-click-source])
59
+ * @param {Object} userOptions Options to override defaults
60
+ */
61
+ export function setupProxy(proxy, userOptions) {
62
+ const options = Object.assign({}, currentDefaults, userOptions);
63
+ const child = proxy.querySelector(options.selector);
64
+ if (child) {
65
+ attachHandlers(proxy, child, options);
66
+ } else {
67
+ console.error("Unable to locate proxy click source", options.selector);
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Main function for attaching behaviors that enable proxy click
73
+ * @param {Node} proxy The container who's click should proxy the click of inner element with options.selector (defaults to [data-ulu-proxy-click-source])
74
+ * @param {Node} child The element who is being proxied and will get clicked if the proxy is clicked (as long as not an interactive element within proxy)
75
+ * @param {Object} config Merged/final options object
76
+ */
77
+ export function attachHandlers(proxy, child, config) {
78
+ const { selectorPreventBase: spb, selectorPrevent: sp } = config;
65
79
  const selectorPrevent = `${ spb }${ sp ? `, ${ sp }` : "" }`;
66
80
  let start, shouldProxy;
67
81
  proxy.addEventListener("mousedown", ({ target, timeStamp }) => {
@@ -72,7 +86,7 @@ export function attachHandlers(proxy, child, options) {
72
86
  }
73
87
  });
74
88
  proxy.addEventListener("mouseup", ({ timeStamp }) => {
75
- if (shouldProxy && timeStamp - start < options.mousedownDurationPrevent) {
89
+ if (shouldProxy && timeStamp - start < config.mousedownDurationPrevent) {
76
90
  child.click();
77
91
  }
78
92
  });
@@ -2,29 +2,21 @@
2
2
  * @module ui/scroll-slider
3
3
  */
4
4
 
5
+ import { ComponentInitializer } from "../utils/system.js";
5
6
  import { OverflowScroller } from "./overflow-scroller.js";
6
7
  import { createPager } from "./overflow-scroller-pager.js";
7
- import { getName } from "../events/index.js";
8
- import { getDatasetOptionalJson } from "../utils/dom.js";
9
-
10
8
 
11
9
  /**
12
- * Default data attributes
10
+ * Scroll Slider Component Initializer
13
11
  */
14
- export const attrs = {
15
- init: "data-ulu-scroll-slider-init",
16
- slider: "data-ulu-scroll-slider",
17
- track: "data-ulu-scroll-slider-track",
18
- controls: "data-ulu-scroll-slider-control-context"
19
- };
20
-
21
- // Utils for selecting things based on attributes
22
- const attrSelector = key => `[${ attrs[key] }]`;
23
- const attrSelectorInitial = key => `${ attrSelector(key) }:not([${ attrs.init }])`;
24
-
12
+ export const initializer = new ComponentInitializer({
13
+ type: "scroll-slider",
14
+ baseAttribute: "data-ulu-scroll-slider"
15
+ });
25
16
 
17
+ const attrSelectorTrack = initializer.attributeSelector("track");
18
+ const attrSelectorControls = initializer.attributeSelector("control-context");
26
19
  const instances = [];
27
-
28
20
  const defaults = {
29
21
  amount: createPager()
30
22
  };
@@ -34,23 +26,25 @@ const defaults = {
34
26
  * - This will only initialize elements once, it is safe to call on page changes
35
27
  */
36
28
  export function init() {
37
- document.addEventListener(getName("pageModified"), setup);
38
- setup();
29
+ initializer.init({
30
+ withData: true,
31
+ events: ["pageModified"],
32
+ setup({ element, data, initialize }) {
33
+ setupSlider(element, data);
34
+ initialize();
35
+ }
36
+ });
39
37
  }
40
38
 
41
- export function setup() {
42
- const builders = document.querySelectorAll(attrSelectorInitial("slider"));
43
- builders.forEach(setupSlider);
44
- }
45
-
46
- // getDatasetOptionalJson
47
- function setupSlider(container) {
48
- container.setAttribute(attrs.init, "");
49
- const options = getDatasetOptionalJson(container, "uluScrollSlider");
50
- const config = Object.assign({}, defaults, options);
39
+ /**
40
+ * Setup instance of scroll slider based on data-attributes
41
+ * @param {Node} container The scroll slider container
42
+ */
43
+ function setupSlider(container, userOptions) {
44
+ const config = Object.assign({}, defaults, userOptions);
51
45
  const elements = {
52
- track: container.querySelector(attrSelector("track")),
53
- controls: container.querySelector(attrSelector("controls"))
46
+ track: container.querySelector(attrSelectorTrack),
47
+ controls: container.querySelector(attrSelectorControls)
54
48
  };
55
49
  instances.push(new OverflowScroller(elements, config));
56
50
  }
@@ -1,81 +1,45 @@
1
1
  /**
2
2
  * @module ui/scrollpoint
3
+ * @description Module that uses intersection observer to add scrollpoint like behavior.
3
4
  */
4
5
 
5
- // Module that uses intersection observer to add scrollpoint like behavior.
6
- /**
7
- * TODO:
8
- * - Included a group option or attribute (on container)
9
- // for things like anchor menus (one active in group at a time).
10
- *
11
- * How to link elements of group
12
- * <div group={ groupName: test }>
13
- * <div point={ groupName: test, mirror: ["#menu-link-1"] }>
14
- * or
15
- * <div group={ groupName: test, children: [".selector"] }>
16
- * <div class=".selector">
17
- */
18
- import { getName } from "../events/index.js";
19
- import { getDatasetOptionalJson, getElement } from "../utils/dom.js";
6
+ import { ComponentInitializer } from "../utils/system.js";
20
7
  import { logError } from "../utils/class-logger.js";
21
8
 
9
+ // TODO:
10
+ // - Included a group option or attribute (on container), for things like anchor menus (one active in group at a time).
11
+ //
12
+ // How to link elements of group
13
+ // <div group={ groupName: test }>
14
+ // <div point={ groupName: test, mirror: ["#menu-link-1"] }>
15
+ // or
16
+ // <div group={ groupName: test, children: [".selector"] }>
17
+ // <div class=".selector">
18
+
22
19
  /**
23
- * Default data attributes
20
+ * Scrollpoint Component Initializer
24
21
  */
25
- export const attrs = {
26
- init: "data-ulu-scrollpoint-init",
27
- /**
28
- * Individual scrollpoint
29
- */
30
- point: "data-ulu-scrollpoint",
31
- group: "data-ulu-scrollpoint-group",
32
- groupAnchors: "data-ulu-scrollpoint-anchors"
33
- // Goes on container for all items
34
- // group: "data-ulu-scrollpoint-group"
35
- };
36
-
37
- // Utils for selecting things based on attributes
38
- const attrSelector = key => `[${ attrs[key] }]`;
39
- const attrSelectorInitial = key => `${ attrSelector(key) }:not([${ attrs.init }])`;
40
- const queryAllInitial = key => document.querySelectorAll(attrSelectorInitial(key));
22
+ export const initializer = new ComponentInitializer({
23
+ type: "scrollpoint",
24
+ baseAttribute: "data-ulu-scrollpoint"
25
+ });
41
26
 
42
27
  /**
43
28
  * Initialize everything in document
44
29
  * - This will only initialize elements once, it is safe to call on page changes
45
30
  */
46
31
  export function init() {
47
- document.addEventListener(getName("pageModified"), setup);
48
- setup();
49
- }
50
-
51
- /**
52
- * Setup all points and groups
53
- */
54
- export function setup() {
55
- const elements = queryAllInitial("point");
56
- // const points = Array.from(elements).map(resolve);
57
- // const groups = points
58
- // .filter(({ config }) => config.groupName)
59
- // .reduce((acc, point) => {
60
- // const { groupName } = point.config;
61
- // if (acc.has(groupName)) {
62
- // acc.get(groupName).push(point);
63
- // } else {
64
- // acc.set(groupName, [point]);
65
- // }
66
- // }, new Map());
67
- // const singles = points.filter(({ config }) => !config.groupName);
68
- // groups.forEach(setupGroup);
69
- elements.forEach(element => {
70
- const elOptions = getDatasetOptionalJson(element, "uluScrollpoint");
71
- const config = Object.assign({}, elOptions);
72
- element.setAttribute(attrs.init, "");
73
- new Scrollpoint(element, config);
32
+ initializer.init({
33
+ withData: true,
34
+ events: ["pageModified"],
35
+ setup({ element, data, initialize }) {
36
+ const config = Object.assign({}, data);
37
+ (new Scrollpoint(element, config));
38
+ initialize();
39
+ }
74
40
  });
75
41
  }
76
42
 
77
-
78
-
79
43
  /**
80
44
  * Single scrollpoint
81
45
  * - Note "forward" and "reverse" refer to scroll directions
@@ -141,7 +105,7 @@ export class Scrollpoint {
141
105
  /**
142
106
  * Attribute name to set state info in
143
107
  */
144
- attributeName: "data-scrollpoint-state",
108
+ attributeName: "data-ulu-scrollpoint-state",
145
109
  /**
146
110
  * Group multiple points, one active at a time (scroll menus)
147
111
  */
@@ -191,7 +155,7 @@ export class Scrollpoint {
191
155
  };
192
156
  this.setupObserver();
193
157
  if (options.debug) {
194
- console.log("Scrollpoint", this);
158
+ initializer.log(this);
195
159
  }
196
160
  }
197
161
  getClassname(suffix) {
@@ -233,7 +197,7 @@ export class Scrollpoint {
233
197
  };
234
198
  const config = this.getObserverOptions();
235
199
  if (this.options.debug) {
236
- console.log("Scrollpoint (IntersectionObserver)", config);
200
+ initializer.log("IntersectionObserver (options)", config);
237
201
  }
238
202
  this.observer = new IntersectionObserver(handler, config);
239
203
  this.observer.observe(this.element);
package/js/ui/slider.js CHANGED
@@ -5,19 +5,20 @@
5
5
  // Slider
6
6
  // =============================================================================
7
7
 
8
- // Version: 1.0.10
8
+ // Version: 1.0.11
9
9
 
10
10
  // Changes:
11
+ // 1.0.11 | Updates for ComponentInitializer
11
12
  // 1.0.10 | Fix bug when two and going in reverse
12
- // 1.0.9 | Fix bug when there are only 2 slides (not sliding correctly [revesers because of switchSlide])
13
- // this is addressed now and should slide infinitly between two slides
14
- // 1.0.8 | Change API, to elements object (from individaul arguments),
13
+ // 1.0.9 | Fix bug when there are only 2 slides (not sliding correctly [reverse because of switchSlide])
14
+ // this is addressed now and should slide infinity between two slides
15
+ // 1.0.8 | Change API, to elements object (from individual arguments),
15
16
  // Add the ability to specify the element to append controls within
16
17
  // 1.0.6 | Add transition class for changes during transition,
17
18
  // add will-change to the transition
18
- // 1.0.5 | Fix transtion event difference on windows, convert all
19
+ // 1.0.5 | Fix transition event difference on windows, convert all
19
20
  // async stuff to promises and simplify
20
- // 1.0.4 | Remove live region annoucement (only used if auto rotate)
21
+ // 1.0.4 | Remove live region announcement (only used if auto rotate)
21
22
 
22
23
  // Reference: https://www.w3.org/WAI/tutorials/carousels/working-example/
23
24
  // https://www.w3.org/TR/wai-aria-practices/examples/carousel/carousel-1.html#
@@ -27,16 +28,28 @@
27
28
  // https://dev.opera.com/articles/css-will-change-property/
28
29
  // * Will Change use
29
30
 
31
+ import { ComponentInitializer } from "../utils/system.js";
32
+ import { wrapSettingString } from "../settings.js";
30
33
  import maintain from 'ally.js/maintain/_maintain';
31
34
  import { hasRequiredProps } from '@ulu/utils/object.js';
32
35
  import { trimWhitespace } from "@ulu/utils/string.js";
33
36
  import { debounce } from "@ulu/utils/performance.js";
34
37
  import { log, logError, logWarning } from "../utils/class-logger.js";
35
- import { getDatasetOptionalJson } from "../utils/dom.js";
36
- import { createPager } from "./overflow-scroller-pager.js";
37
- import { getName } from "../events/index.js";
38
38
 
39
- const debugMode = false; // Global dev debug
39
+ /**
40
+ * Slider Component Initializer
41
+ */
42
+ export const initializer = new ComponentInitializer({
43
+ type: "slider",
44
+ baseAttribute: "data-ulu-slider"
45
+ });
46
+
47
+ const attrSelectorTrack = initializer.attributeSelector("track");
48
+ const attrSelectorTrackContainer = initializer.attributeSelector("track-container");
49
+ const attrSelectorControlContext = initializer.attributeSelector("control-context");
50
+ const attrSelectorSlide = initializer.attributeSelector("slide");
51
+
52
+ const instances = [];
40
53
  const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
41
54
  const eventOnce = { once: true };
42
55
  const cssDuration = d => `${ d }ms`;
@@ -56,52 +69,34 @@ const requiredElements = [
56
69
  ];
57
70
 
58
71
  /**
59
- * Default data attributes
72
+ * Initialize all sliders based on data attribute selectors
60
73
  */
61
- export const attrs = {
62
- init: "data-ulu-slider-init",
63
- slider: "data-ulu-slider",
64
- track: "data-ulu-slider-track",
65
- trackContainer: "data-ulu-slider-track-container",
66
- controls: "data-ulu-slider-control-context"
67
- };
68
-
69
- // Utils for selecting things based on attributes
70
- const attrSelector = key => `[${ attrs[key] }]`;
71
- const attrSelectorInitial = key => `${ attrSelector(key) }:not([${ attrs.init }])`;
72
-
73
- const defaults = {
74
- amount: createPager()
75
- };
76
-
77
- const instances = [];
78
-
79
74
  export function init() {
80
- document.addEventListener(getName("pageModified"), setup);
81
- setup();
82
- }
83
-
84
- export function setup() {
85
- const builders = document.querySelectorAll(attrSelectorInitial("slider"));
86
- builders.forEach(setupSlider);
75
+ initializer.init({
76
+ withData: true,
77
+ events: ["pageModified"],
78
+ setup({ element, data, initialize }) {
79
+ setupSlider(element, data);
80
+ initialize();
81
+ }
82
+ });
87
83
  }
88
84
 
89
- export function setupSlider(container) {
90
- container.setAttribute(attrs.init, "");
91
- const options = getDatasetOptionalJson(container, "uluScrollSlider");
92
- const config = Object.assign({}, defaults, options);
85
+ /**
86
+ * Setup single slider instance from querying via data attribute selectors
87
+ * @param {Node} container The slide container to query children from
88
+ * @param {Object} options Options for slider class
89
+ */
90
+ export function setupSlider(container, options) {
91
+ const config = Object.assign({}, options);
93
92
  const elements = {
94
93
  container,
95
- track: container.querySelector("[data-ulu-slider-track]"),
96
- trackContainer: container.querySelector("[data-ulu-slider-track-container]"),
97
- controlContext: container.querySelector("[data-ulu-slider-control-context]"),
98
- slides: container.querySelectorAll("[data-ulu-slider-slide]")
94
+ track: container.querySelector(attrSelectorTrack),
95
+ trackContainer: container.querySelector(attrSelectorTrackContainer),
96
+ controlContext: container.querySelector(attrSelectorControlContext),
97
+ slides: container.querySelectorAll(attrSelectorSlide)
99
98
  };
100
- // Add in any global settings
101
- // Object.assign(config, {
102
- // callbacks: {}
103
- // });
104
- // /
99
+
105
100
  // This was added because there was an issue on the new windows, need to test this
106
101
  // config.transitionFade = true;
107
102
  if (elements.slides.length) {
@@ -109,8 +104,14 @@ export function setupSlider(container) {
109
104
  }
110
105
  }
111
106
 
107
+ /**
108
+ * Class that controls slider
109
+ */
112
110
  export class Slider {
113
111
  static instances = [];
112
+ /**
113
+ * Default options for slider
114
+ */
114
115
  static defaults = {
115
116
  classAccessiblyHidden: "hidden-visually",
116
117
  namespace: "Slider",
@@ -120,15 +121,13 @@ export class Slider {
120
121
  transitionDuration: 700,
121
122
  transitionDurationExit: 400,
122
123
  transitionTimingFunction: "ease-in-out",
123
- buttonClasses: ["Slider__control-icon", "button", "button--icon"],
124
- iconClassesPrevious: ["css-icon", "css-icon--angle-left"],
125
- iconClassesNext: ["css-icon", "css-icon--angle-right"]
124
+ buttonClasses: ["button", "button--icon"],
125
+ iconClassPrevious: wrapSettingString("iconClassPrevious"),
126
+ iconClassNext: wrapSettingString("iconClassNext"),
126
127
  // transition: true
127
128
  }
128
- // constructor(container, title, trackContainer, track, slides, config, debug = false) {
129
- constructor(elements, config, debug = false) {
129
+ constructor(elements, config) {
130
130
  const options = Object.assign({}, Slider.defaults, config);
131
- this.debug = debugMode || debug;
132
131
  this.options = options;
133
132
  this.slide = null;
134
133
  this.index = null;
@@ -454,6 +453,7 @@ export class Slider {
454
453
  const button = document.createElement("button");
455
454
  button.classList.add(this.getClass("control-button"));
456
455
  button.classList.add(this.getClass(`control-button--${ action }`));
456
+
457
457
  button.classList.add(...this.options.buttonClasses);
458
458
  button.setAttribute("data-slider-control", action);
459
459
  button.setAttribute("type", "button");
@@ -509,21 +509,20 @@ export class Slider {
509
509
  const button = document.createElement("button");
510
510
  button.classList.add(this.getClass("nav-button"));
511
511
  button.setAttribute("type", "button");
512
- button.innerHTML = this.getNavContent(slide.number);
512
+ button.innerHTML = this.getNavContent(slide);
513
513
  slide.navButton = button; // Add reference to slide object
514
514
  button.addEventListener("click", this.goto.bind(this, index));
515
515
  return button;
516
516
  }
517
- // change to css-icon
518
517
  getControlContent(action) {
519
- const classes = this.options[action === "next" ? "iconClassesNext" : "iconClassesPrevious"];
518
+ const classes = this.options[action === "next" ? "iconClassNext" : "iconClassPrevious"];
520
519
  return `
521
- <span class="hidden-visually">${ action }</span>
522
- <span class="${ classes.join(' ') }" aria-hidden="true"></span>
520
+ <span class="${ this.options.classAccessiblyHidden }">${ action }</span>
521
+ <span class="${ this.getClass("control-icon") } ${ classes }" aria-hidden="true"></span>
523
522
  `;
524
523
  }
525
- getNavContent(number) {
526
- return `<span class="hidden-visually">Item ${ number }</span>`;
524
+ getNavContent(slide) {
525
+ return `<span class="${ this.options.classAccessiblyHidden }">Item ${ slide.number }</span>`;
527
526
  }
528
527
  emit(name, args) {
529
528
  if (this.options.events[name]) {
package/js/ui/tabs.js CHANGED
@@ -9,9 +9,7 @@
9
9
  // setting this up to destroy tab interface when ui layout changes?
10
10
 
11
11
  import AriaTablist from "aria-tablist";
12
-
13
- const initAttr = "data-ulu-tablist-init";
14
- const errorHeader = "[data-ulu-tablist] error:";
12
+ import { ComponentInitializer } from "../utils/system.js";
15
13
 
16
14
  /**
17
15
  * Array of current tab instances (exported if you need to interact with them)
@@ -19,13 +17,28 @@ const errorHeader = "[data-ulu-tablist] error:";
19
17
  */
20
18
  export const instances = [];
21
19
 
20
+ /**
21
+ * Tabs Component Initializer
22
+ */
23
+ export const initializer = new ComponentInitializer({
24
+ type: "tabs",
25
+ baseAttribute: "data-ulu-tablist"
26
+ });
27
+
22
28
  /**
23
29
  * Init all instances currently in document
24
- * @param {Object} options Options to serve as defaults
25
30
  */
26
- export function init(options = {}) {
31
+ export function init() {
27
32
  const initial = () => {
28
- initWithin(document, options);
33
+ initializer.init({
34
+ events: ["pageModified"],
35
+ withData: true,
36
+ setup({ element, data, initialize }) {
37
+ setup(element, data);
38
+ initialize();
39
+ }
40
+ });
41
+
29
42
  // Run this on page load, optionally exported for use when page is running
30
43
  instances.forEach(openByCurrentHash);
31
44
  };
@@ -35,22 +48,6 @@ export function init(options = {}) {
35
48
  } else {
36
49
  window.addEventListener("load", initial);
37
50
  }
38
- // Initialize when page updates/changes
39
- document.addEventListener("pageModified", e => initWithin(e.target, options));
40
- }
41
-
42
- /**
43
- * Init all tabs within a certain context
44
- * @param {Node} context Element to init within
45
- * @param {Object} options Options to serve as defaults
46
- */
47
- export function initWithin(context, options = {}) {
48
- if (!context) {
49
- console.warn("Missing context to initWithin, skipping init of tabs");
50
- return;
51
- }
52
- const tablists = context.querySelectorAll(`[data-ulu-tablist]:not([${ initAttr }])`);
53
- tablists.forEach(element => setup(element, options));
54
51
  }
55
52
 
56
53
  /**
@@ -60,17 +57,7 @@ export function initWithin(context, options = {}) {
60
57
  * @return {Object} Instance object
61
58
  */
62
59
  export function setup(element, options = {}) {
63
- let elementOptions = {};
64
-
65
- if (element.dataset.uluTablist) {
66
- try {
67
- elementOptions = JSON.parse(element.dataset.uluTablist);
68
- } catch(e) {
69
- console.error(errorHeader, "(JSON Parse for options)", element);
70
- }
71
- }
72
-
73
- const config = Object.assign({}, options, elementOptions);
60
+ const config = Object.assign({}, options);
74
61
 
75
62
  if (config.vertical) {
76
63
  config.allArrows = true;
@@ -91,8 +78,6 @@ export function setup(element, options = {}) {
91
78
  if (config.equalHeights) {
92
79
  setHeights(element);
93
80
  }
94
-
95
- element.setAttribute(initAttr, "");
96
81
 
97
82
  return instance;
98
83
  }
@@ -150,7 +135,9 @@ function setHeights(element) {
150
135
  if (panel.hidden) {
151
136
  panel.hidden = false;
152
137
  panelHeight = panel.offsetHeight;
153
- panel.hidden = true;
138
+ // This explicity needs "hidden" for aria-tablist (it checks this string value)
139
+ // Will break the initial window push state when using openWithUrlHash
140
+ panel.setAttribute("hidden", "hidden");
154
141
  }
155
142
  return panelHeight;
156
143
  });