@ulu/frontend 0.2.0-beta.6 → 0.2.0-beta.8

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 (138) hide show
  1. package/dist/README.md +12 -0
  2. package/dist/{types → es}/core/component.d.ts +3 -9
  3. package/dist/es/core/component.d.ts.map +1 -0
  4. package/dist/es/core/component.js +134 -0
  5. package/dist/{types → es}/core/events.d.ts +1 -1
  6. package/dist/{types → es}/core/events.d.ts.map +1 -1
  7. package/dist/es/core/events.js +45 -0
  8. package/dist/es/core/index.d.ts +4 -0
  9. package/dist/{types → es}/core/settings.d.ts +1 -1
  10. package/dist/es/core/settings.d.ts.map +1 -0
  11. package/dist/es/core/settings.js +44 -0
  12. package/dist/es/index.d.ts +4 -0
  13. package/dist/es/index.js +123 -0
  14. package/dist/{types → es}/ui/breakpoints.d.ts +5 -3
  15. package/dist/es/ui/breakpoints.d.ts.map +1 -0
  16. package/dist/es/ui/breakpoints.js +194 -0
  17. package/dist/{types → es}/ui/collapsible.d.ts +28 -7
  18. package/dist/es/ui/collapsible.d.ts.map +1 -0
  19. package/dist/es/ui/collapsible.js +140 -0
  20. package/dist/{types → es}/ui/details-group.d.ts +1 -1
  21. package/dist/es/ui/details-group.js +49 -0
  22. package/dist/{types → es}/ui/dialog.d.ts +3 -3
  23. package/dist/es/ui/dialog.d.ts.map +1 -0
  24. package/dist/es/ui/dialog.js +112 -0
  25. package/dist/{types → es}/ui/flipcard.d.ts +1 -1
  26. package/dist/es/ui/flipcard.js +97 -0
  27. package/dist/{types → es}/ui/grid.d.ts +2 -2
  28. package/dist/{types → es}/ui/grid.d.ts.map +1 -1
  29. package/dist/es/ui/grid.js +18 -0
  30. package/dist/{types → es}/ui/index.d.ts +21 -21
  31. package/dist/{types → es}/ui/modal-builder.d.ts +21 -16
  32. package/dist/es/ui/modal-builder.d.ts.map +1 -0
  33. package/dist/es/ui/modal-builder.js +136 -0
  34. package/dist/es/ui/overflow-scroller-pager.js +28 -0
  35. package/dist/{types → es}/ui/overflow-scroller.d.ts +3 -3
  36. package/dist/{types → es}/ui/overflow-scroller.d.ts.map +1 -1
  37. package/dist/es/ui/overflow-scroller.js +90 -0
  38. package/dist/es/ui/page.js +7 -0
  39. package/dist/{types → es}/ui/popover.d.ts +3 -3
  40. package/dist/{types → es}/ui/popover.d.ts.map +1 -1
  41. package/dist/es/ui/popover.js +77 -0
  42. package/dist/es/ui/print-details.js +22 -0
  43. package/dist/es/ui/print.js +34 -0
  44. package/dist/{types → es}/ui/programmatic-modal.d.ts +1 -1
  45. package/dist/{types → es}/ui/programmatic-modal.d.ts.map +1 -1
  46. package/dist/{types → es}/ui/proxy-click.d.ts +4 -4
  47. package/dist/es/ui/proxy-click.d.ts.map +1 -0
  48. package/dist/es/ui/proxy-click.js +44 -0
  49. package/dist/{types → es}/ui/resizer.d.ts +16 -16
  50. package/dist/es/ui/resizer.d.ts.map +1 -0
  51. package/dist/es/ui/resizer.js +242 -0
  52. package/dist/{types → es}/ui/scroll-slider.d.ts +1 -1
  53. package/dist/es/ui/scroll-slider.js +29 -0
  54. package/dist/{types → es}/ui/scrollpoint.d.ts +79 -11
  55. package/dist/es/ui/scrollpoint.d.ts.map +1 -0
  56. package/dist/es/ui/scrollpoint.js +178 -0
  57. package/dist/{types → es}/ui/slider.d.ts +11 -8
  58. package/dist/es/ui/slider.d.ts.map +1 -0
  59. package/dist/es/ui/slider.js +292 -0
  60. package/dist/{types → es}/ui/tabs.d.ts +2 -2
  61. package/dist/{types → es}/ui/tabs.d.ts.map +1 -1
  62. package/dist/es/ui/tabs.js +64 -0
  63. package/dist/{types → es}/ui/theme-toggle.d.ts +4 -4
  64. package/dist/es/ui/theme-toggle.d.ts.map +1 -0
  65. package/dist/es/ui/theme-toggle.js +190 -0
  66. package/dist/{types → es}/ui/tooltip.d.ts +5 -5
  67. package/dist/es/ui/tooltip.d.ts.map +1 -0
  68. package/dist/es/ui/tooltip.js +184 -0
  69. package/dist/{types → es}/utils/class-logger.d.ts +4 -4
  70. package/dist/es/utils/class-logger.d.ts.map +1 -0
  71. package/dist/es/utils/class-logger.js +37 -0
  72. package/dist/es/utils/css.js +6 -0
  73. package/dist/{types → es}/utils/dom.d.ts +1 -1
  74. package/dist/{types → es}/utils/dom.d.ts.map +1 -1
  75. package/dist/es/utils/dom.js +29 -0
  76. package/dist/{types → es}/utils/file-save.d.ts.map +1 -1
  77. package/dist/es/utils/file-save.js +46 -0
  78. package/dist/{types → es}/utils/floating-ui.d.ts +1 -1
  79. package/dist/{types → es}/utils/floating-ui.d.ts.map +1 -1
  80. package/dist/es/utils/floating-ui.js +46 -0
  81. package/dist/es/utils/font-awesome.js +13 -0
  82. package/dist/es/utils/id.js +11 -0
  83. package/dist/{types → es}/utils/index.d.ts +7 -7
  84. package/dist/es/utils/pause-youtube-video.js +27 -0
  85. package/dist/umd/style.css +1 -0
  86. package/dist/{ulu-frontend.umd.js → umd/ulu-frontend.umd.js} +15 -15
  87. package/lib/js/ui/breakpoints.js +12 -12
  88. package/lib/js/ui/modal-builder.js +5 -3
  89. package/lib/js/ui/slider.js +19 -10
  90. package/lib/scss/_element.scss +10 -4
  91. package/lib/scss/components/_accordion.scss +1 -7
  92. package/lib/scss/components/_button.scss +11 -2
  93. package/lib/scss/components/_card.scss +0 -2
  94. package/lib/scss/components/_menu-stack.scss +1 -0
  95. package/lib/scss/components/_modal.scss +13 -13
  96. package/lib/scss/helpers/_utilities.scss +0 -3
  97. package/package.json +20 -16
  98. package/dist/style.css +0 -1
  99. package/dist/types/core/component.d.ts.map +0 -1
  100. package/dist/types/core/index.d.ts +0 -4
  101. package/dist/types/core/settings.d.ts.map +0 -1
  102. package/dist/types/index.d.ts +0 -4
  103. package/dist/types/ui/breakpoints.d.ts.map +0 -1
  104. package/dist/types/ui/collapsible.d.ts.map +0 -1
  105. package/dist/types/ui/dialog.d.ts.map +0 -1
  106. package/dist/types/ui/modal-builder.d.ts.map +0 -1
  107. package/dist/types/ui/proxy-click.d.ts.map +0 -1
  108. package/dist/types/ui/resizer.d.ts.map +0 -1
  109. package/dist/types/ui/scrollpoint.d.ts.map +0 -1
  110. package/dist/types/ui/slider.d.ts.map +0 -1
  111. package/dist/types/ui/theme-toggle.d.ts.map +0 -1
  112. package/dist/types/ui/tooltip.d.ts.map +0 -1
  113. package/dist/types/utils/class-logger.d.ts.map +0 -1
  114. package/dist/ulu-frontend.es.js +0 -5743
  115. /package/dist/{types → es}/core/index.d.ts.map +0 -0
  116. /package/dist/{types → es}/index.d.ts.map +0 -0
  117. /package/dist/{types → es}/ui/details-group.d.ts.map +0 -0
  118. /package/dist/{types → es}/ui/flipcard.d.ts.map +0 -0
  119. /package/dist/{types → es}/ui/index.d.ts.map +0 -0
  120. /package/dist/{types → es}/ui/overflow-scroller-pager.d.ts +0 -0
  121. /package/dist/{types → es}/ui/overflow-scroller-pager.d.ts.map +0 -0
  122. /package/dist/{types → es}/ui/page.d.ts +0 -0
  123. /package/dist/{types → es}/ui/page.d.ts.map +0 -0
  124. /package/dist/{types → es}/ui/print-details.d.ts +0 -0
  125. /package/dist/{types → es}/ui/print-details.d.ts.map +0 -0
  126. /package/dist/{types → es}/ui/print.d.ts +0 -0
  127. /package/dist/{types → es}/ui/print.d.ts.map +0 -0
  128. /package/dist/{types → es}/ui/scroll-slider.d.ts.map +0 -0
  129. /package/dist/{types → es}/utils/css.d.ts +0 -0
  130. /package/dist/{types → es}/utils/css.d.ts.map +0 -0
  131. /package/dist/{types → es}/utils/file-save.d.ts +0 -0
  132. /package/dist/{types → es}/utils/font-awesome.d.ts +0 -0
  133. /package/dist/{types → es}/utils/font-awesome.d.ts.map +0 -0
  134. /package/dist/{types → es}/utils/id.d.ts +0 -0
  135. /package/dist/{types → es}/utils/id.d.ts.map +0 -0
  136. /package/dist/{types → es}/utils/index.d.ts.map +0 -0
  137. /package/dist/{types → es}/utils/pause-youtube-video.d.ts +0 -0
  138. /package/dist/{types → es}/utils/pause-youtube-video.d.ts.map +0 -0
@@ -1,3 +1,4 @@
1
+ import { ComponentInitializer } from '../core/component.js';
1
2
  /**
2
3
  * Initialize all sliders based on data attribute selectors
3
4
  */
@@ -7,7 +8,7 @@ export function init(): void;
7
8
  * @param {Node} container The slide container to query children from
8
9
  * @param {Object} options Options for slider class
9
10
  */
10
- export function setupSlider(container: Node, options: any): void;
11
+ export function setupSlider(container: Node, options: Object): void;
11
12
  /**
12
13
  * Slider Component Initializer
13
14
  */
@@ -17,6 +18,9 @@ export const initializer: ComponentInitializer;
17
18
  */
18
19
  export class Slider {
19
20
  static instances: any[];
21
+ static globalsInitialized: boolean;
22
+ static reduceMotion: boolean;
23
+ static _initializeGlobals(): void;
20
24
  /**
21
25
  * Default options for slider
22
26
  */
@@ -30,8 +34,8 @@ export class Slider {
30
34
  transitionDurationExit: number;
31
35
  transitionTimingFunction: string;
32
36
  buttonClasses: string[];
33
- iconClassPrevious: any;
34
- iconClassNext: any;
37
+ iconClassPrevious: Object;
38
+ iconClassNext: Object;
35
39
  swipeEnabled: boolean;
36
40
  swipeOptions: {
37
41
  preventScroll: boolean;
@@ -43,11 +47,11 @@ export class Slider {
43
47
  element: any;
44
48
  index: number;
45
49
  number: number;
46
- };
50
+ } | null;
47
51
  index: any;
48
52
  swipeInstance: any;
49
- swipeListener: (event: any) => void;
50
- swipeImageListener: (event: any) => void;
53
+ swipeListener: ((event: any) => void) | null;
54
+ swipeImageListener: ((event: any) => void) | null;
51
55
  transitioning: boolean;
52
56
  slides: {
53
57
  element: any;
@@ -135,7 +139,7 @@ export class Slider {
135
139
  };
136
140
  createNav(container: any): {
137
141
  nav: HTMLUListElement;
138
- navButtons: any[];
142
+ navButtons: HTMLButtonElement[];
139
143
  navItems: HTMLLIElement[];
140
144
  };
141
145
  createNavButton(slide: any, index: any): HTMLButtonElement;
@@ -143,5 +147,4 @@ export class Slider {
143
147
  getNavContent(slide: any): string;
144
148
  emit(name: any, args: any): void;
145
149
  }
146
- import { ComponentInitializer } from "../core/component.js";
147
150
  //# sourceMappingURL=slider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../../lib/js/ui/slider.js"],"names":[],"mappings":"AAiEA;;GAEG;AACH,6BASC;AAED;;;;GAIG;AACH,uCAHW,IAAI,WACJ,MAAM,QAiBhB;AA1DD;;GAEG;AACH,+CAGG;AAsDH;;GAEG;AACH;IACE,wBAAsB;IACtB,mCAAkC;IAClC,6BAA4B;IAE5B,kCAYC;IACD;;OAEG;IACH;;;;;;;;;;;;;;;;MAgBC;IACD,wCAoCC;IAjCC,aAAsB;IACtB;;;;aAAiB;IACjB,WAAiB;IACjB,mBAAyB;IACzB,6CAAyB;IACzB,kDAA8B;IAC9B,uBAA0B;IAQ1B;;;;QAME;IACF,cAIC;IAED;;;wBACgF;IAMlF;;OAEG;IACH,qBAKC;IACD;;OAEG;IACH,2BAOC;IACD;;OAEG;IACH,uBAMC;IACD;;;;;;OAMG;IACH,8BAJW,MAAM,YACN,MAAM,2CAqChB;IACD;;OAEG;IACH,kDASC;IACD;;;OAGG;IACH,oDASC;IACD;;OAEG;IACH,kDAOC;IACD;;OAEG;IACH;;;;;;sBAoDC;IACD;;OAEG;IACH;;;sBAUC;IACD;;OAEG;IACH;;;sBAOC;IACD,qDA0CC;IACD,cAmBC;IACD,mBAsBC;IACD,0BAMC;IACD,+BAKC;IACD,qCAOC;IACD,mBAQC;IACD,mBASC;IACD,yCASC;IACD,oDAUC;IACD;;;;;;MAwBC;IACD;;;;MAmBC;IACD,2DAQC;IACD,uCAMC;IACD,kCAEC;IACD,iCAIC;CACF;qCA1iBoC,sBAAsB"}
@@ -0,0 +1,292 @@
1
+ var T = Object.defineProperty;
2
+ var x = (a, t, s) => t in a ? T(a, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[t] = s;
3
+ var m = (a, t, s) => x(a, typeof t != "symbol" ? t + "" : t, s);
4
+ import { ComponentInitializer as S } from "../core/component.js";
5
+ import { wrapSettingString as b } from "../core/settings.js";
6
+ import k from "ally.js/maintain/_maintain";
7
+ import { hasRequiredProps as $ } from "@ulu/utils/object.js";
8
+ import { trimWhitespace as v } from "@ulu/utils/string.js";
9
+ import { debounce as I } from "@ulu/utils/performance.js";
10
+ import { logError as y, log as A, logWarning as L } from "../utils/class-logger.js";
11
+ import z from "swipe-listener";
12
+ const f = new S({
13
+ type: "slider",
14
+ baseAttribute: "data-ulu-slider"
15
+ }), D = f.attributeSelector("track"), M = f.attributeSelector("track-container"), B = f.attributeSelector("control-context"), N = f.attributeSelector("slide"), q = [], h = { once: !0 }, E = (a) => `${a}ms`, P = [
16
+ "container",
17
+ "trackContainer",
18
+ "track",
19
+ "slides"
20
+ ];
21
+ function K() {
22
+ f.init({
23
+ withData: !0,
24
+ coreEvents: ["pageModified"],
25
+ setup({ element: a, data: t, initialize: s }) {
26
+ V(a, t), s();
27
+ }
28
+ });
29
+ }
30
+ function V(a, t) {
31
+ const s = Object.assign({}, t), e = {
32
+ container: a,
33
+ track: a.querySelector(D),
34
+ trackContainer: a.querySelector(M),
35
+ controlContext: a.querySelector(B),
36
+ slides: a.querySelectorAll(N)
37
+ };
38
+ e.slides.length && q.push(new g(e, s, !1));
39
+ }
40
+ const l = class l {
41
+ static _initializeGlobals() {
42
+ l.globalsInitialized || (addEventListener("load", () => {
43
+ addEventListener("resize", I(() => {
44
+ l.instances.forEach((t) => t.handleResize());
45
+ }, 250));
46
+ }), l.reduceMotion = matchMedia("(prefers-reduced-motion: reduce)").matches, l.globalsInitialized = !0);
47
+ }
48
+ constructor(t, s) {
49
+ l._initializeGlobals();
50
+ const e = Object.assign({}, l.defaults, s);
51
+ this.options = e, this.slide = null, this.index = null, this.swipeInstance = null, this.swipeListener = null, this.swipeImageListener = null, this.transitioning = !1, $(P) || y(this, "Missing a required Element"), t.slides.length || y(this, "Missing slides"), this.slides = [...t.slides].map((i, n) => ({
52
+ element: i,
53
+ index: n,
54
+ number: n + 1
55
+ })), this.elements = {
56
+ ...t,
57
+ ...this.createControls(t.controlContext || t.container),
58
+ ...this.createNav(t.navContext || t.container)
59
+ }, this.transition = e.transition ? e.transitionFade || l.reduceMotion ? this.fadeTransition : this.slideTransition : this.noTransition, this.setup(), this.goto(0, null, "init"), A(this, "Slider Instance Created", this), l.instances.push(this);
60
+ }
61
+ /**
62
+ * Sliding mechanism needs translate updated on resize
63
+ */
64
+ handleResize() {
65
+ const { slide: t, transition: s, slideTransition: e } = this;
66
+ s === e && t && this.translateTo(t.element.offsetLeft, 0);
67
+ }
68
+ /**
69
+ * Goto to the previous slide
70
+ */
71
+ previous(t) {
72
+ const { index: s, slides: e } = this, i = e.length - 1, n = s - 1, o = n < 0 ? i : n;
73
+ this.emit("previous", [t, o]), this.goto(o, t, "previous");
74
+ }
75
+ /**
76
+ * Goto to the next slide
77
+ */
78
+ next(t) {
79
+ const { index: s, slides: e } = this, i = s + 1, n = i > e.length - 1 ? 0 : i;
80
+ this.emit("next", [t, n]), this.goto(n, t, "next");
81
+ }
82
+ /**
83
+ * Makes sure that no matter what the callback is called if transition event
84
+ * doesn't start or fails to finish/cancel
85
+ * @param {number} element
86
+ * @param {number} duration Duration to wait for complete
87
+ * @param {Function} beginTransition Css changes to begin/start transtion
88
+ */
89
+ ensureTransitionEnds(t, s, e) {
90
+ return new Promise((i) => {
91
+ const n = {}, o = () => {
92
+ clearTimeout(n.start), n.end = setTimeout(r, s + 500);
93
+ }, r = () => {
94
+ clearTimeout(n.start), clearTimeout(n.end), t.removeEventListener("transitionrun", o, h), t.removeEventListener("transitionend", r, h), t.removeEventListener("transitioncancel", r, h), i();
95
+ };
96
+ t.addEventListener("transitionrun", o, h), t.addEventListener("transitionend", r, h), t.addEventListener("transitioncancel", r, h), n.start = setTimeout(r, s + 500), t.style.transitionDuration = E(s), e(), s || r();
97
+ });
98
+ }
99
+ /**
100
+ * Translate the track to X
101
+ */
102
+ translateTo(t, s) {
103
+ const { track: e } = this.elements, i = () => e.style.transform = `translateX(-${t}px)`;
104
+ return e.style.willChange = "transform", this.ensureTransitionEnds(e, s, i).then(() => {
105
+ e.style.willChange = "auto";
106
+ });
107
+ }
108
+ /**
109
+ * Show's a specifc slide and hides others, except when passing true to show all
110
+ * then all slides will visible
111
+ */
112
+ setVisibility(t, s) {
113
+ s || (t.element.style.visibility = "visible"), this.slides.forEach((e) => {
114
+ e !== t && (e.element.style.visibility = s ? "visible" : "hidden");
115
+ });
116
+ }
117
+ /**
118
+ * Perform a fade on a single slide
119
+ */
120
+ fadeSlide(t, s) {
121
+ const { options: e } = this, { element: i } = t, n = s ? e.transitionDuration : e.transitionDurationExit;
122
+ return this.ensureTransitionEnds(i, n, () => {
123
+ i.style.opacity = s ? "1" : "0";
124
+ });
125
+ }
126
+ /**
127
+ * Handler for the entire slide transtion
128
+ */
129
+ async slideTransition({ slide: t, index: s, old: e, oldIndex: i, triggerType: n }) {
130
+ const o = this.slides.length, r = n === "previous", C = o - 1, u = s === 0 && i === C, d = s === C && i === 0;
131
+ let c, p = this.options.transitionDuration;
132
+ i && !u && !d && (p = p * Math.abs(i - s)), o < 3 ? u && !r ? c = e : d && (c = r ? t : e) : u ? c = e : d && (c = t), this.setVisibility(null, !0), c && (c.element.style.order = "-1", await this.translateTo(u ? 0 : e.element.offsetLeft, 0)), await this.translateTo(t.element.offsetLeft, p), c && (c.element.style.order = "0", await this.translateTo(t.element.offsetLeft, 0)), this.setVisibility(t, !1);
133
+ }
134
+ /**
135
+ * Handler for the entire fade transtion
136
+ */
137
+ async fadeTransition({ slide: t, old: s }) {
138
+ this.setVisibility(null, !0), s && (await this.fadeSlide(s, !1), s.element.style.order = "0"), t.element.style.order = "-1", await this.fadeSlide(t, !0), this.setVisibility(t, !1);
139
+ }
140
+ /**
141
+ * Handler for the entire NO transtion
142
+ */
143
+ noTransition({ slide: t, old: s }) {
144
+ return this.setVisibility(t, !1), s && (s.element.style.order = "0"), t.element.style.order = "-1", Promise.resolve();
145
+ }
146
+ goto(t, s, e) {
147
+ const {
148
+ slide: i,
149
+ index: n,
150
+ slides: o,
151
+ elements: r
152
+ } = this, C = e === "init", u = o[t], d = this.getClass("nav-button--active"), c = this.getClass("transition", !0), p = { slide: u, index: t, old: i, oldIndex: n, triggerType: e };
153
+ if (t === n) {
154
+ L(this, "Could not goto slide, still performing transition");
155
+ return;
156
+ }
157
+ if (this.transitioning) {
158
+ L(this, "Cancel goto(), same slide index as current slide");
159
+ return;
160
+ }
161
+ const w = k.disabled({ context: this.elements.track });
162
+ this.transitioning = !0, i && i.navButton.classList.remove(d), u.navButton.classList.add(d), r.container.classList.add(c), this.transition(p).then(() => {
163
+ this.index = t, this.slide = u, this.transitioning = !1, r.container.classList.remove(c), w.disengage(), C || (u.element.focus(), this.emit("goto", [s, t, u]));
164
+ });
165
+ }
166
+ setup() {
167
+ const { container: t, track: s, trackContainer: e } = this.elements, i = v(this.trackCss()), n = v(this.trackContainerStyles()), o = v(this.slideCss());
168
+ s.setAttribute("style", i), e.setAttribute("style", n), this.slides.forEach((r) => {
169
+ r.element.setAttribute("style", o), r.element.setAttribute("tabindex", "-1");
170
+ }), t.classList.add(this.getClass()), this.options.swipeEnabled && this.setupSwipe();
171
+ }
172
+ setupSwipe() {
173
+ const t = this.elements.track.querySelectorAll("img");
174
+ this.swipeListener = (s) => {
175
+ this.onSwipe(s);
176
+ }, this.swipeImageListener = (s) => {
177
+ s.preventDefault();
178
+ }, this.slides.forEach((s) => {
179
+ const { element: e } = s;
180
+ s.swipeInstance = z(e, this.options.swipeOptions), e.addEventListener("swipe", this.swipeListener);
181
+ }), t.forEach((s) => {
182
+ s.addEventListener("dragstart", this.swipeImageListener);
183
+ });
184
+ }
185
+ onSwipe(t) {
186
+ const { directions: s } = t.detail, e = s.left ? "next" : s.right ? "previous" : null;
187
+ e && this[e](t);
188
+ }
189
+ trackContainerStyles() {
190
+ return `
191
+ overflow: hidden;
192
+ `;
193
+ }
194
+ transitionCss(t) {
195
+ const { transitionTimingFunction: s, transitionDuration: e } = this.options;
196
+ return `
197
+ transition-property: ${t};
198
+ transition-duration: ${E(e)};
199
+ transition-timing-function: ${s};
200
+ `;
201
+ }
202
+ trackCss() {
203
+ return `
204
+ display: flex;
205
+ position: relative;
206
+ list-style: none;
207
+ ${this.transition === this.slideTransition ? this.transitionCss("transform") : ""}
208
+ `;
209
+ }
210
+ slideCss() {
211
+ const t = this.transition === this.fadeTransition;
212
+ return `
213
+ width: 100%;
214
+ flex: 0 0 100%;
215
+ ${t ? this.transitionCss("opacity") : ""}
216
+ opacity: ${t ? "0" : "1"}
217
+ `;
218
+ }
219
+ getClass(t, s) {
220
+ const { namespace: e } = this.options;
221
+ return s ? `${e}--${t}` : t ? `${e}__${t}` : e;
222
+ }
223
+ createControlButton(t) {
224
+ const s = document.createElement("button");
225
+ return s.classList.add(this.getClass("control-button")), s.classList.add(this.getClass(`control-button--${t}`)), s.classList.add(...this.options.buttonClasses), s.setAttribute("data-slider-control", t), s.setAttribute("type", "button"), s.innerHTML = this.getControlContent(t), s;
226
+ }
227
+ createControls(t) {
228
+ const s = document.createElement("ul"), e = document.createElement("li"), i = document.createElement("li"), n = this.createControlButton("previous"), o = this.createControlButton("next");
229
+ return s.classList.add(this.getClass("controls")), e.appendChild(n), i.appendChild(o), s.appendChild(e), s.appendChild(i), n.addEventListener("click", this.previous.bind(this)), o.addEventListener("click", this.next.bind(this)), t.appendChild(s), {
230
+ controls: s,
231
+ previousItem: e,
232
+ nextItem: i,
233
+ previous: n,
234
+ next: o
235
+ };
236
+ }
237
+ createNav(t) {
238
+ const s = document.createElement("ul"), e = this.slides.map(this.createNavButton.bind(this)), i = e.map((n) => {
239
+ const o = document.createElement("li");
240
+ return o.appendChild(n), s.appendChild(o), o;
241
+ });
242
+ return s.classList.add(this.getClass("nav")), t.appendChild(s), {
243
+ nav: s,
244
+ navButtons: e,
245
+ navItems: i
246
+ };
247
+ }
248
+ createNavButton(t, s) {
249
+ const e = document.createElement("button");
250
+ return e.classList.add(this.getClass("nav-button")), e.setAttribute("type", "button"), e.innerHTML = this.getNavContent(t), t.navButton = e, e.addEventListener("click", this.goto.bind(this, s)), e;
251
+ }
252
+ getControlContent(t) {
253
+ const s = this.options[t === "next" ? "iconClassNext" : "iconClassPrevious"];
254
+ return `
255
+ <span class="${this.options.classAccessiblyHidden}">${t}</span>
256
+ <span class="${this.getClass("control-icon")} ${s}" aria-hidden="true"></span>
257
+ `;
258
+ }
259
+ getNavContent(t) {
260
+ return `<span class="${this.options.classAccessiblyHidden}">Item ${t.number}</span>`;
261
+ }
262
+ emit(t, s) {
263
+ this.options.events[t] && this.options.events[t].apply(this, s);
264
+ }
265
+ };
266
+ m(l, "instances", []), m(l, "globalsInitialized", !1), m(l, "reduceMotion", !1), /**
267
+ * Default options for slider
268
+ */
269
+ m(l, "defaults", {
270
+ classAccessiblyHidden: "hidden-visually",
271
+ namespace: "Slider",
272
+ events: {},
273
+ transition: !0,
274
+ transitionFade: !1,
275
+ transitionDuration: 700,
276
+ transitionDurationExit: 400,
277
+ transitionTimingFunction: "ease-in-out",
278
+ buttonClasses: ["button", "button--icon"],
279
+ iconClassPrevious: b("iconClassPrevious"),
280
+ iconClassNext: b("iconClassNext"),
281
+ swipeEnabled: !0,
282
+ swipeOptions: {
283
+ preventScroll: !0
284
+ }
285
+ });
286
+ let g = l;
287
+ export {
288
+ g as Slider,
289
+ K as init,
290
+ f as initializer,
291
+ V as setupSlider
292
+ };
@@ -1,3 +1,4 @@
1
+ import { ComponentInitializer } from '../core/component.js';
1
2
  /**
2
3
  * Init all instances currently in document
3
4
  */
@@ -8,7 +9,7 @@ export function init(): void;
8
9
  * @param {Node} options Options to set as defaults (can be overridden by element dataset options)
9
10
  * @return {Object} Instance object
10
11
  */
11
- export function setup(element: Node, options?: Node): any;
12
+ export function setup(element: Node, options?: Node): Object;
12
13
  /**
13
14
  * Array of current tab instances (exported if you need to interact with them)
14
15
  * @type {Array}
@@ -18,5 +19,4 @@ export const instances: any[];
18
19
  * Tabs Component Initializer
19
20
  */
20
21
  export const initializer: ComponentInitializer;
21
- import { ComponentInitializer } from "../core/component.js";
22
22
  //# sourceMappingURL=tabs.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../lib/js/ui/tabs.js"],"names":[],"mappings":"AA2BA;;GAEG;AACH,6BAoBC;AAED;;;;;GAKG;AACH,+BAJW,IAAI,YACJ,IAAI,OA2Bd;AArED;;;GAGG;AACH,8BAA4B;AAE5B;;GAEG;AACH,+CAGG;qCAdkC,sBAAsB"}
1
+ {"version":3,"file":"tabs.d.ts","sourceRoot":"","sources":["../../../lib/js/ui/tabs.js"],"names":[],"mappings":"AA2BA;;GAEG;AACH,6BAoBC;AAED;;;;;GAKG;AACH,+BAJW,IAAI,YACJ,IAAI,GACH,MAAM,CA0BjB;AArED;;;GAGG;AACH,8BAA4B;AAE5B;;GAEG;AACH,+CAGG;qCAdkC,sBAAsB"}
@@ -0,0 +1,64 @@
1
+ import f from "aria-tablist";
2
+ import { ComponentInitializer as u } from "../core/component.js";
3
+ const l = [], p = new u({
4
+ type: "tabs",
5
+ baseAttribute: "data-ulu-tablist"
6
+ });
7
+ function E() {
8
+ const e = () => {
9
+ p.init({
10
+ coreEvents: ["pageModified"],
11
+ withData: !0,
12
+ setup({ element: n, data: t, initialize: o }) {
13
+ m(n, t), o();
14
+ }
15
+ }), l.forEach(b);
16
+ };
17
+ document.readyState === "complete" ? e() : window.addEventListener("load", e);
18
+ }
19
+ function m(e, n = {}) {
20
+ const t = Object.assign({}, n);
21
+ t.vertical && (t.allArrows = !0);
22
+ const o = { element: e, options: n };
23
+ return o.ariaTablist = f(e, {
24
+ onOpen(...a) {
25
+ a.unshift(o), g.apply(null, a);
26
+ },
27
+ ...t
28
+ }), l.push(o), t.equalHeights && w(e), o;
29
+ }
30
+ function b({ options: e, ariaTablist: n }) {
31
+ if (e.openByUrlHash) {
32
+ const { hash: t } = window.location;
33
+ if (t && t.length > 1) {
34
+ const o = t.substring(1);
35
+ n.tabs.forEach((a) => {
36
+ o === a.id && n.open(a);
37
+ });
38
+ }
39
+ }
40
+ }
41
+ function g({ options: e }, n, t) {
42
+ e.openByUrlHash && window.history && window.history.replaceState(null, "", `#${t.id}`);
43
+ }
44
+ function w(e) {
45
+ const t = [...e.children].map((i) => document.querySelector(`[aria-labelledby="${i.id}"]`)), h = [...t[0].parentElement.querySelectorAll("img")].map((i) => d(i));
46
+ function d(i) {
47
+ return new Promise((r) => {
48
+ i.complete ? r(i) : (i.onload = r, i.onerror = r);
49
+ });
50
+ }
51
+ Promise.all(h).then(() => {
52
+ const i = t.map((s) => {
53
+ let c = s.offsetHeight;
54
+ return s.hidden && (s.hidden = !1, c = s.offsetHeight, s.setAttribute("hidden", "hidden")), c;
55
+ }), r = Math.max(...i);
56
+ t.forEach((s) => s.style.minHeight = `${r}px`);
57
+ });
58
+ }
59
+ export {
60
+ E as init,
61
+ p as initializer,
62
+ l as instances,
63
+ m as setup
64
+ };
@@ -1,7 +1,8 @@
1
+ import { ComponentInitializer } from '../core/component.js';
1
2
  /**
2
3
  * @param {Object} options Change options used as default for dialogs, can then be overridden by data attribute settings on element
3
4
  */
4
- export function setDefaults(options: any): void;
5
+ export function setDefaults(options: Object): void;
5
6
  /**
6
7
  * Initialize everything in document
7
8
  * - This will only initialize elements once, it is safe to call on page changes
@@ -17,7 +18,7 @@ export function setupToggle(toggle: HTMLElement, userOptions: any): {
17
18
  options: any;
18
19
  toggleState: (event: any) => void;
19
20
  setState(themeKey: any): void;
20
- };
21
+ } | undefined;
21
22
  /**
22
23
  * Theme Toggle Component Initializer
23
24
  */
@@ -43,7 +44,7 @@ export namespace defaults {
43
44
  }
44
45
  }
45
46
  let target: string;
46
- let group: any;
47
+ let group: null;
47
48
  /**
48
49
  * Optional callback to do something when the state changes
49
50
  */
@@ -54,5 +55,4 @@ export namespace defaults {
54
55
  let storagePrefix: string;
55
56
  let debug: boolean;
56
57
  }
57
- import { ComponentInitializer } from "../core/component.js";
58
58
  //# sourceMappingURL=theme-toggle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-toggle.d.ts","sourceRoot":"","sources":["../../../lib/js/ui/theme-toggle.js"],"names":[],"mappings":"AAmGA;;GAEG;AACH,qCAFW,MAAM,QAIhB;AAED;;;GAGG;AACH,6BASC;AAED;;;GAGG;AACH,oCAFW,WAAW;;;;;;cA+FrB;AAhND;;GAEG;AACH,+CAGG;;;;;;;;;;;;;;;;;;;;;;;IAmDD;;OAEG;IACH,mCAAiB;;;;;;;qCAlEkB,sBAAsB"}
@@ -0,0 +1,190 @@
1
+ import { ComponentInitializer as M } from "../core/component.js";
2
+ import { getCoreEventName as y } from "../core/events.js";
3
+ import { resolveClasses as b } from "../utils/dom.js";
4
+ import { hasRequiredProps as q } from "@ulu/utils/object.js";
5
+ import { getElements as I } from "@ulu/utils/browser/dom.js";
6
+ const c = new M({
7
+ type: "theme-toggle",
8
+ baseAttribute: "data-ulu-theme-toggle"
9
+ }), Q = c.attributeSelector("label"), $ = c.attributeSelector("icon"), L = c.getAttribute("remote"), v = c.getAttribute("init"), S = c.getAttribute("state"), j = (e) => document.querySelectorAll(
10
+ `[${L}="${e}"]`
11
+ ), C = (e) => document.querySelectorAll(
12
+ `[${L}="${e}"]:not([${v}])`
13
+ ), T = ["target"], O = q(T), E = (e, r) => e ? r() : null, P = {
14
+ /**
15
+ * Object of each theme that should be toggle/cycled through
16
+ */
17
+ themes: {
18
+ light: {
19
+ label: "Light",
20
+ value: "light",
21
+ iconClass: "fas fa-moon",
22
+ targetClass: "theme-light",
23
+ mediaQuery: "(prefers-color-scheme: light)"
24
+ },
25
+ dark: {
26
+ label: "Dark",
27
+ iconClass: "fas fa-sun",
28
+ targetClass: "theme-dark",
29
+ mediaQuery: "(prefers-color-scheme: dark)"
30
+ }
31
+ },
32
+ /**
33
+ * Required this is the element(s) that should be changed by a specific toggle
34
+ * - The element should have data-ulu-theme-toggle-target="SOME_IDENTIFIER"
35
+ */
36
+ target: "body",
37
+ /**
38
+ * Optional group to link remote toggles (toggles that follow the main one and can toggle too)
39
+ */
40
+ group: null,
41
+ /**
42
+ * Optional callback to do something when the state changes
43
+ */
44
+ onChange(e) {
45
+ },
46
+ /**
47
+ * The initial state for this component
48
+ * - May be overridden by saved preference or media query if options are enabled
49
+ */
50
+ initialState: "light",
51
+ /**
52
+ * Check the OS systems user preference via 'preferenceQuery' option
53
+ */
54
+ checkMediaQuery: !1,
55
+ /**
56
+ * Will store the preference in local storage so it persists between page loads
57
+ */
58
+ savePreference: !1,
59
+ /**
60
+ * The key that will be used to store the preference in local storage
61
+ * - This will be used as prefix in combination with group if defined
62
+ */
63
+ storagePrefix: "ulu-theme-",
64
+ /**
65
+ * Output information to console for debugging
66
+ */
67
+ debug: !1
68
+ };
69
+ let k = { ...P };
70
+ function G(e) {
71
+ k = Object.assign({}, k, e);
72
+ }
73
+ function H() {
74
+ c.init({
75
+ coreEvents: ["pageModified"],
76
+ withData: !0,
77
+ setup({ element: e, data: r, initialize: o }) {
78
+ R(e, r), o();
79
+ }
80
+ });
81
+ }
82
+ function R(e, r) {
83
+ const o = Object.assign({}, P, r);
84
+ if (!O(o)) {
85
+ console.error(`Missing a required option: ${T.join(", ")}`);
86
+ return;
87
+ }
88
+ const t = o.group, n = { toggle: e, options: o }, u = w(o);
89
+ if (!u) {
90
+ console.error("Unable to resolve initial key");
91
+ return;
92
+ }
93
+ p(u, n), e.addEventListener("click", a), l(), document.addEventListener(y("pageModified"), l);
94
+ function s(g) {
95
+ const d = I(o.target)[0].dataset.uluThemeToggleState, f = D(d, o);
96
+ if (!f) {
97
+ console.error("Issue getting next theme key");
98
+ return;
99
+ }
100
+ p(f, { ...n, event: g });
101
+ }
102
+ function a(g) {
103
+ s(g);
104
+ }
105
+ function l() {
106
+ if (!t) return;
107
+ C(t).forEach((i) => {
108
+ i.addEventListener("click", a), c.initializeElement(i);
109
+ });
110
+ }
111
+ function m() {
112
+ if (!t) return;
113
+ C(t).forEach((i) => {
114
+ i.removeEventListener("click", a), i.removeAttribute(v, "");
115
+ });
116
+ }
117
+ function h() {
118
+ e.removeEventListener("click", a), e.removeAttribute(v, ""), m(), document.removeEventListener(y("pageModified"), l);
119
+ }
120
+ return {
121
+ destroy: h,
122
+ toggle: e,
123
+ options: o,
124
+ toggleState: s,
125
+ setState(g) {
126
+ p(g, n);
127
+ }
128
+ };
129
+ }
130
+ function p(e, r) {
131
+ if (!e) {
132
+ console.error("Missing key");
133
+ return;
134
+ }
135
+ const { toggle: o, options: t } = r, { themes: n, group: u } = t, s = {
136
+ targets: I(t.target),
137
+ toggles: [o, ...u ? j(u) : []]
138
+ };
139
+ if (!s.targets.length || !s.toggles.length) {
140
+ console.error("Issue setting state, couldn't find needed elements", s);
141
+ return;
142
+ }
143
+ const a = n[e], l = z(e, n), m = {
144
+ ...r,
145
+ key: e,
146
+ elements: s,
147
+ theme: a,
148
+ otherThemes: l
149
+ };
150
+ t.debug && c.log("Set state context", m);
151
+ const h = x(l, "targetClass"), g = x(l, "iconClass");
152
+ s.targets.forEach((i) => {
153
+ i.setAttribute(S, e), i.classList.remove(...h), i.classList.add(...b(a.targetClass));
154
+ }), s.toggles.forEach((i) => {
155
+ const d = i.querySelector(Q), f = i.querySelector($);
156
+ d && (d.textContent = a.label), f && (f.classList.remove(...g), f.classList.add(...b(a.iconClass))), i.setAttribute(S, e);
157
+ }), t.onChange && t.onChange(m), t.savePreference && localStorage.setItem(A(t), e);
158
+ }
159
+ function w(e) {
160
+ const { savePreference: r, checkMediaQuery: o, themes: t, initialState: n } = e, u = A(e), s = E(r, () => localStorage.getItem(u)), a = E(o, () => K(t)), l = s || a || n;
161
+ return e.debug && (c.log("Preference Saved", s), c.log("Media Query Preference", a), c.log("Initial State:", n)), l || c.logError("Failed to resolve initial theme (pass 'initialState' to options)"), l;
162
+ }
163
+ function K(e) {
164
+ const r = Object.entries(e).find(([o, t]) => {
165
+ if (t.mediaQuery)
166
+ return window.matchMedia(t.mediaQuery).matches;
167
+ });
168
+ return r ? r[0] : null;
169
+ }
170
+ function D(e, r) {
171
+ const { themes: o } = r, t = Object.keys(o), n = t.findIndex((s) => s === e), u = n === -1 ? 0 : (n + 1) % t.length;
172
+ return t[u];
173
+ }
174
+ function z(e, r) {
175
+ return Object.entries(r).filter(([t]) => t !== e).map(([t, n]) => n);
176
+ }
177
+ function x(e, r) {
178
+ return e.reduce((o, t) => o.concat(b(t[r])), []);
179
+ }
180
+ function A(e) {
181
+ const { storagePrefix: r, group: o } = e;
182
+ return o ? `${r}${o}` : r;
183
+ }
184
+ export {
185
+ P as defaults,
186
+ H as init,
187
+ c as initializer,
188
+ G as setDefaults,
189
+ R as setupToggle
190
+ };