@energysage/es-ds-components 3.0.0-alpha.0 → 3.0.0-alpha.11

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 (236) hide show
  1. package/.eslintignore +9 -0
  2. package/.eslintrc.json +3 -0
  3. package/.prettierrc.json +10 -0
  4. package/README.md +0 -3
  5. package/components/es-accordion-list.vue +117 -0
  6. package/components/es-accordion.vue +7 -0
  7. package/components/es-badge.vue +20 -0
  8. package/components/es-breadcrumbs.vue +43 -30
  9. package/components/es-button.vue +122 -0
  10. package/components/es-card.vue +64 -0
  11. package/components/es-carousel.vue +582 -0
  12. package/components/es-col.vue +27 -0
  13. package/components/es-collapse.vue +42 -38
  14. package/components/es-container.vue +14 -0
  15. package/components/es-cta-banner.vue +95 -0
  16. package/components/es-cta-card.vue +60 -0
  17. package/components/es-data-table-simple.vue +73 -0
  18. package/components/es-data-table.vue +128 -0
  19. package/components/es-error-page.vue +120 -0
  20. package/components/es-file-input.vue +334 -0
  21. package/components/es-file-preview-modal.vue +61 -0
  22. package/components/es-footer.vue +163 -0
  23. package/components/es-form-checkbox.vue +40 -0
  24. package/components/es-form-input.vue +130 -0
  25. package/components/es-form-msg.vue +81 -0
  26. package/components/es-form-radio-card.vue +57 -0
  27. package/components/es-form-radio-cards.vue +78 -0
  28. package/components/es-form-textarea.vue +124 -0
  29. package/components/es-form.vue +16 -0
  30. package/components/es-modal.vue +103 -0
  31. package/components/es-nav-bar-account-menu.vue +70 -0
  32. package/components/es-nav-bar-featured-article.vue +60 -0
  33. package/components/es-nav-bar-link.vue +27 -0
  34. package/components/es-nav-bar-product-menu.vue +219 -0
  35. package/components/es-nav-bar-top-level-menu.vue +194 -0
  36. package/components/es-nav-bar-topic-menu.vue +197 -0
  37. package/components/es-nav-bar.vue +411 -0
  38. package/components/es-pagination.vue +67 -0
  39. package/components/es-popover.vue +113 -0
  40. package/components/es-progress-circle.vue +81 -0
  41. package/components/es-progress.vue +36 -0
  42. package/components/es-radio-button-group.vue +53 -0
  43. package/components/es-radio-button.vue +57 -0
  44. package/components/es-rating.vue +120 -0
  45. package/components/es-reviews-io-card-carousel.vue +279 -0
  46. package/components/es-segmented-control.vue +237 -0
  47. package/components/es-skeleton-img.vue +38 -0
  48. package/components/es-skeleton-wrapper.vue +17 -0
  49. package/components/es-skeleton.vue +97 -0
  50. package/components/es-slider.vue +218 -0
  51. package/components/es-spinner.vue +22 -0
  52. package/components/es-support-card.vue +150 -0
  53. package/components/es-support.vue +66 -0
  54. package/components/es-tab.vue +7 -0
  55. package/components/es-tabs.vue +70 -0
  56. package/components/es-verification-code.vue +94 -0
  57. package/components/es-video.vue +60 -0
  58. package/components/es-view-more.vue +64 -0
  59. package/components/es-zip-code-form.vue +204 -0
  60. package/components/icon/arrow-clockwise.vue +51 -0
  61. package/components/icon/arrow-counter-clockwise.vue +37 -0
  62. package/components/icon/arrow-cycle.vue +43 -0
  63. package/components/icon/arrow-left.vue +39 -0
  64. package/components/icon/arrow-right.vue +39 -0
  65. package/components/icon/arrow-up.vue +39 -0
  66. package/components/icon/arrow.vue +68 -0
  67. package/components/icon/bank.vue +38 -0
  68. package/components/icon/battery.vue +40 -0
  69. package/components/icon/bell.vue +42 -0
  70. package/components/icon/block.vue +46 -0
  71. package/components/icon/bolt.vue +38 -0
  72. package/components/icon/business.vue +42 -0
  73. package/components/icon/calculator.vue +37 -0
  74. package/components/icon/calendar.vue +46 -0
  75. package/components/icon/cart.vue +46 -0
  76. package/components/icon/chat-add.vue +44 -0
  77. package/components/icon/chat-approve.vue +42 -0
  78. package/components/icon/chat-bubble.vue +40 -0
  79. package/components/icon/chat-dots.vue +42 -0
  80. package/components/icon/check.vue +39 -0
  81. package/components/{icon-chevron-down.vue → icon/chevron-down.vue} +17 -17
  82. package/components/icon/chevron-horizontal.vue +39 -0
  83. package/components/icon/chevron-left.vue +39 -0
  84. package/components/{icon-chevron-right.vue → icon/chevron-right.vue} +17 -17
  85. package/components/icon/chevron-up.vue +39 -0
  86. package/components/icon/circle-alert.vue +46 -0
  87. package/components/icon/circle-check.vue +46 -0
  88. package/components/icon/circle-chevron-down.vue +47 -0
  89. package/components/icon/circle-chevron-left.vue +46 -0
  90. package/components/icon/circle-chevron-right.vue +46 -0
  91. package/components/icon/circle-chevron-up.vue +46 -0
  92. package/components/icon/circle-minus.vue +46 -0
  93. package/components/icon/circle-plus.vue +46 -0
  94. package/components/icon/circle-x.vue +46 -0
  95. package/components/icon/circle.vue +42 -0
  96. package/components/icon/clock.vue +46 -0
  97. package/components/icon/community-solar.vue +37 -0
  98. package/components/icon/companies.vue +43 -0
  99. package/components/icon/contact-us.vue +37 -0
  100. package/components/icon/copy.vue +45 -0
  101. package/components/icon/credit-card.vue +37 -0
  102. package/components/icon/document.vue +45 -0
  103. package/components/icon/electric-vehicle.vue +37 -0
  104. package/components/icon/electricity-circle.vue +39 -0
  105. package/components/icon/envelope.vue +45 -0
  106. package/components/icon/es-leaf.vue +39 -0
  107. package/components/icon/eye.vue +41 -0
  108. package/components/icon/facebook.vue +41 -0
  109. package/components/icon/file-doc.vue +72 -0
  110. package/components/icon/file-docx.vue +72 -0
  111. package/components/icon/file-pdf.vue +72 -0
  112. package/components/icon/flag.vue +37 -0
  113. package/components/icon/folder.vue +41 -0
  114. package/components/icon/gear.vue +37 -0
  115. package/components/icon/gift.vue +37 -0
  116. package/components/icon/hamburger.vue +38 -0
  117. package/components/icon/heart.vue +39 -0
  118. package/components/icon/heat-pump.vue +41 -0
  119. package/components/icon/image.vue +45 -0
  120. package/components/icon/info-blog-post.vue +47 -0
  121. package/components/icon/info.vue +45 -0
  122. package/components/icon/instagram.vue +49 -0
  123. package/components/icon/light-bulb.vue +36 -0
  124. package/components/icon/link-out.vue +38 -0
  125. package/components/icon/linkedin.vue +41 -0
  126. package/components/icon/location.vue +45 -0
  127. package/components/icon/lock-off.vue +45 -0
  128. package/components/icon/lock-on.vue +48 -0
  129. package/components/icon/marketplace.vue +43 -0
  130. package/components/icon/minus.vue +38 -0
  131. package/components/icon/money-bag.vue +37 -0
  132. package/components/icon/money.vue +35 -0
  133. package/components/icon/open-envelope.vue +45 -0
  134. package/components/icon/paper.vue +45 -0
  135. package/components/icon/payback.vue +37 -0
  136. package/components/icon/pencil.vue +45 -0
  137. package/components/icon/person-add.vue +41 -0
  138. package/components/icon/person-check.vue +41 -0
  139. package/components/icon/person-cross.vue +41 -0
  140. package/components/icon/person.vue +41 -0
  141. package/components/icon/phone.vue +41 -0
  142. package/components/icon/play.vue +41 -0
  143. package/components/icon/plus.vue +38 -0
  144. package/components/icon/roof.vue +37 -0
  145. package/components/icon/rooftop-solar.vue +37 -0
  146. package/components/icon/saving.vue +37 -0
  147. package/components/icon/search.vue +43 -0
  148. package/components/icon/settings-horizontal.vue +57 -0
  149. package/components/icon/settings-vertical.vue +57 -0
  150. package/components/icon/shield-with-check.vue +38 -0
  151. package/components/icon/shield.vue +41 -0
  152. package/components/icon/shopping-bag.vue +39 -0
  153. package/components/icon/solar.vue +37 -0
  154. package/components/icon/sound-down.vue +45 -0
  155. package/components/icon/sound-off.vue +41 -0
  156. package/components/icon/sound-on.vue +41 -0
  157. package/components/icon/sound-up.vue +41 -0
  158. package/components/icon/star-empty.vue +38 -0
  159. package/components/icon/star-full.vue +36 -0
  160. package/components/icon/star-half.vue +55 -0
  161. package/components/icon/state-ak.vue +53 -0
  162. package/components/icon/state-al.vue +38 -0
  163. package/components/icon/state-ar.vue +38 -0
  164. package/components/icon/state-az.vue +38 -0
  165. package/components/icon/state-ca.vue +38 -0
  166. package/components/icon/state-co.vue +38 -0
  167. package/components/icon/state-ct.vue +38 -0
  168. package/components/icon/state-dc.vue +52 -0
  169. package/components/icon/state-de.vue +38 -0
  170. package/components/icon/state-fl.vue +38 -0
  171. package/components/icon/state-ga.vue +38 -0
  172. package/components/icon/state-hi.vue +59 -0
  173. package/components/icon/state-ia.vue +38 -0
  174. package/components/icon/state-id.vue +38 -0
  175. package/components/icon/state-il.vue +38 -0
  176. package/components/icon/state-in.vue +38 -0
  177. package/components/icon/state-ks.vue +38 -0
  178. package/components/icon/state-ky.vue +38 -0
  179. package/components/icon/state-la.vue +38 -0
  180. package/components/icon/state-ma.vue +38 -0
  181. package/components/icon/state-md.vue +39 -0
  182. package/components/icon/state-me.vue +38 -0
  183. package/components/icon/state-mi.vue +38 -0
  184. package/components/icon/state-mn.vue +38 -0
  185. package/components/icon/state-mo.vue +38 -0
  186. package/components/icon/state-ms.vue +38 -0
  187. package/components/icon/state-mt.vue +38 -0
  188. package/components/icon/state-nc.vue +38 -0
  189. package/components/icon/state-nd.vue +38 -0
  190. package/components/icon/state-ne.vue +38 -0
  191. package/components/icon/state-nh.vue +38 -0
  192. package/components/icon/state-nj.vue +37 -0
  193. package/components/icon/state-nm.vue +38 -0
  194. package/components/icon/state-nv.vue +38 -0
  195. package/components/icon/state-ny.vue +41 -0
  196. package/components/icon/state-oh.vue +38 -0
  197. package/components/icon/state-ok.vue +38 -0
  198. package/components/icon/state-or.vue +38 -0
  199. package/components/icon/state-pa.vue +38 -0
  200. package/components/icon/state-ri.vue +38 -0
  201. package/components/icon/state-sc.vue +38 -0
  202. package/components/icon/state-sd.vue +38 -0
  203. package/components/icon/state-tn.vue +38 -0
  204. package/components/icon/state-tx.vue +38 -0
  205. package/components/icon/state-ut.vue +38 -0
  206. package/components/icon/state-va.vue +38 -0
  207. package/components/icon/state-vt.vue +38 -0
  208. package/components/icon/state-wa.vue +38 -0
  209. package/components/icon/state-wi.vue +38 -0
  210. package/components/icon/state-wv.vue +38 -0
  211. package/components/icon/state-wy.vue +38 -0
  212. package/components/icon/thumbs-up.vue +39 -0
  213. package/components/icon/trash-can.vue +41 -0
  214. package/components/icon/tree.vue +37 -0
  215. package/components/icon/twitter.vue +43 -0
  216. package/components/icon/upload.vue +41 -0
  217. package/components/icon/verified.vue +40 -0
  218. package/components/icon/video-play.vue +41 -0
  219. package/components/icon/wifi.vue +38 -0
  220. package/components/icon/x.vue +38 -0
  221. package/components/icon/youtube.vue +45 -0
  222. package/composables/forms.ts +124 -0
  223. package/nuxt.config.ts +84 -1
  224. package/package.json +47 -13
  225. package/tsconfig.json +4 -0
  226. package/types/es-carousel.ts +12 -0
  227. package/types/index.ts +1 -0
  228. package/utils/forms.ts +120 -0
  229. package/utils/get-es-footer-content.ts +90 -0
  230. package/utils/get-es-nav-bar-account-content.ts +55 -0
  231. package/utils/get-es-nav-bar-global-content.ts +482 -0
  232. package/utils/mime-type-finder.ts +48 -0
  233. package/utils/vuelidate-keys.ts +39 -0
  234. package/components/b-col.vue +0 -25
  235. package/components/b-container.vue +0 -5
  236. /package/components/{b-row.vue → es-row.vue} +0 -0
@@ -0,0 +1,582 @@
1
+ <script setup lang="ts">
2
+ /*
3
+ TODO:
4
+ - circular has quirky behavior when numVisible doesn't match numScroll
5
+ - you can see this in the circular autoplay example
6
+ - i'm not sure if this is fixable
7
+ - figure out peek behavior
8
+ - prop to position the arrows at the bottom two corners of a full-width slide, like homepage
9
+ */
10
+
11
+ import Carousel from 'primevue/carousel';
12
+ import sassBreakpoints from '@energysage/es-ds-styles/scss/modules/breakpoints.module.scss';
13
+ import type { EsCarouselBreakpointsInterface } from '../types';
14
+
15
+ // this isn't set in a SASS variable so we can't import it, but it's
16
+ // defined as a constant here so we can easily change it if we need to
17
+ const BASE_FONT_SIZE = 16;
18
+
19
+ // constants that contribute to dots and arrows positioning
20
+ const DOT_SIZE = 14;
21
+ const DOT_SPACING = 16;
22
+ const ARROW_BUTTON_PADDING = 8;
23
+
24
+ // the number of "dots" apart the arrows should be when dots are hidden
25
+ const ARROW_SPACING_WHEN_NO_DOTS = 1;
26
+
27
+ interface IProps {
28
+ arrowSize?: 'sm' | 'lg';
29
+ autoPlay?: boolean;
30
+ autoPlayInterval?: number;
31
+ breakpoints?: EsCarouselBreakpointsInterface;
32
+ circular?: boolean;
33
+ controlGap?: number;
34
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
+ items: Array<any>;
36
+ numScroll?: number;
37
+ numVisible?: number;
38
+ showArrows?: boolean;
39
+ showDots?: boolean;
40
+ slideGap?: number;
41
+ variant?: 'default' | 'brand';
42
+ }
43
+ const props = withDefaults(defineProps<IProps>(), {
44
+ arrowSize: 'sm',
45
+ autoPlay: false,
46
+ autoPlayInterval: 4000,
47
+ breakpoints: () => ({}),
48
+ circular: false,
49
+ controlGap: 24,
50
+ items: () => [],
51
+ numScroll: 1,
52
+ numVisible: 1,
53
+ showArrows: true,
54
+ showDots: true,
55
+ slideGap: 16,
56
+ variant: 'default',
57
+ });
58
+
59
+ const emit = defineEmits<{
60
+ update: [value: number];
61
+ }>();
62
+
63
+ // get the breakpoint pixel numbers from the SASS variables in es-ds-styles
64
+ const parseSassBreakpoint = (breakpoint: string) => parseInt(breakpoint.replace('px', ''), 10);
65
+ const BREAKPOINTS = {
66
+ SM: parseSassBreakpoint(sassBreakpoints.sm),
67
+ MD: parseSassBreakpoint(sassBreakpoints.md),
68
+ LG: parseSassBreakpoint(sassBreakpoints.lg),
69
+ XL: parseSassBreakpoint(sassBreakpoints.xl),
70
+ XXL: parseSassBreakpoint(sassBreakpoints.xxl),
71
+ };
72
+
73
+ // lower breakpoint values propagate to higher breakpoints unless overridden
74
+ const numVisibleXs = computed(() => props.numVisible);
75
+ const numVisibleSm = computed(() => props.breakpoints?.sm?.numVisible || numVisibleXs.value);
76
+ const numVisibleMd = computed(() => props.breakpoints?.md?.numVisible || numVisibleSm.value);
77
+ const numVisibleLg = computed(() => props.breakpoints?.lg?.numVisible || numVisibleMd.value);
78
+ const numVisibleXl = computed(() => props.breakpoints?.xl?.numVisible || numVisibleLg.value);
79
+ const numVisibleXxl = computed(() => props.breakpoints?.xxl?.numVisible || numVisibleXl.value);
80
+
81
+ // lower breakpoint values propagate to higher breakpoints unless overridden
82
+ const numScrollXs = computed(() => props.numScroll);
83
+ const numScrollSm = computed(() => props.breakpoints?.sm?.numScroll || numScrollXs.value);
84
+ const numScrollMd = computed(() => props.breakpoints?.md?.numScroll || numScrollSm.value);
85
+ const numScrollLg = computed(() => props.breakpoints?.lg?.numScroll || numScrollMd.value);
86
+ const numScrollXl = computed(() => props.breakpoints?.xl?.numScroll || numScrollLg.value);
87
+ const numScrollXxl = computed(() => props.breakpoints?.xxl?.numScroll || numScrollXl.value);
88
+
89
+ // allow customizable spacing between slides
90
+ // but since that's done as side padding around each slide, which moves them in from the container edge
91
+ // to get slides to left and right align with page content
92
+ // we apply a negative margin to either side to bring the container edges back out to match
93
+ const sidePadding = computed(() => `${props.slideGap / 2 / BASE_FONT_SIZE}rem`);
94
+ const negativeMargin = computed(() => `-${sidePadding.value}`);
95
+
96
+ // size of dots and spacing between dots
97
+ const dotSize = `${DOT_SIZE / BASE_FONT_SIZE}rem`;
98
+ const dotSpacing = `${DOT_SPACING / BASE_FONT_SIZE}rem`;
99
+
100
+ // arrow padding
101
+ const arrowPadding = `${ARROW_BUTTON_PADDING / BASE_FONT_SIZE}rem`;
102
+
103
+ // arrow size
104
+ const arrowSize = computed(() => (props.arrowSize === 'lg' ? 32 : 24));
105
+ const arrowSizePx = computed(() => `${arrowSize.value}px`);
106
+ const arrowButtonSize = computed(() => arrowSize.value + ARROW_BUTTON_PADDING * 2);
107
+
108
+ // vertical positioning for the arrows
109
+ const distanceFromCarouselBottomToCenterOfDots = computed(() => props.controlGap + DOT_SIZE / 2);
110
+ const arrowPositionBottom = computed(
111
+ () => `-${distanceFromCarouselBottomToCenterOfDots.value + arrowButtonSize.value / 2}px`,
112
+ );
113
+ const dotsMarginTop = computed(() => `${props.controlGap / BASE_FONT_SIZE}rem`);
114
+
115
+ // the number of dots visible at each breakpoint
116
+ const numDotsXs = computed(() =>
117
+ props.showDots ? Math.ceil(props.items.length / numVisibleXs.value) : ARROW_SPACING_WHEN_NO_DOTS,
118
+ );
119
+ const numDotsSm = computed(() =>
120
+ props.showDots ? Math.ceil(props.items.length / numVisibleSm.value) : ARROW_SPACING_WHEN_NO_DOTS,
121
+ );
122
+ const numDotsMd = computed(() =>
123
+ props.showDots ? Math.ceil(props.items.length / numVisibleMd.value) : ARROW_SPACING_WHEN_NO_DOTS,
124
+ );
125
+ const numDotsLg = computed(() =>
126
+ props.showDots ? Math.ceil(props.items.length / numVisibleLg.value) : ARROW_SPACING_WHEN_NO_DOTS,
127
+ );
128
+ const numDotsXl = computed(() =>
129
+ props.showDots ? Math.ceil(props.items.length / numVisibleXl.value) : ARROW_SPACING_WHEN_NO_DOTS,
130
+ );
131
+ const numDotsXxl = computed(() =>
132
+ props.showDots ? Math.ceil(props.items.length / numVisibleXxl.value) : ARROW_SPACING_WHEN_NO_DOTS,
133
+ );
134
+
135
+ // calculate the arrow position from center based on the number of dots
136
+ const calculateArrowPosition = (numDots: number): number =>
137
+ (numDots * DOT_SIZE) / 2 + (numDots * DOT_SPACING) / 2 + DOT_SPACING;
138
+
139
+ // determine how much from center we need to move the arrow buttons, based on how many dots there are
140
+ const arrowPositionXs = computed(() => calculateArrowPosition(numDotsXs.value));
141
+ const arrowPositionSm = computed(() => calculateArrowPosition(numDotsSm.value));
142
+ const arrowPositionMd = computed(() => calculateArrowPosition(numDotsMd.value));
143
+ const arrowPositionLg = computed(() => calculateArrowPosition(numDotsLg.value));
144
+ const arrowPositionXl = computed(() => calculateArrowPosition(numDotsXl.value));
145
+ const arrowPositionXxl = computed(() => calculateArrowPosition(numDotsXxl.value));
146
+
147
+ // prev button horizontal position
148
+ const prevArrowTranslateXs = computed(() => `-${arrowPositionXs.value + arrowButtonSize.value}px`);
149
+ const prevArrowTranslateSm = computed(() => `-${arrowPositionSm.value + arrowButtonSize.value}px`);
150
+ const prevArrowTranslateMd = computed(() => `-${arrowPositionMd.value + arrowButtonSize.value}px`);
151
+ const prevArrowTranslateLg = computed(() => `-${arrowPositionLg.value + arrowButtonSize.value}px`);
152
+ const prevArrowTranslateXl = computed(() => `-${arrowPositionXl.value + arrowButtonSize.value}px`);
153
+ const prevArrowTranslateXxl = computed(() => `-${arrowPositionXxl.value + arrowButtonSize.value}px`);
154
+
155
+ // next arrow horizontal position
156
+ const nextArrowTranslateXs = computed(() => `${arrowPositionXs.value}px`);
157
+ const nextArrowTranslateSm = computed(() => `${arrowPositionSm.value}px`);
158
+ const nextArrowTranslateMd = computed(() => `${arrowPositionMd.value}px`);
159
+ const nextArrowTranslateLg = computed(() => `${arrowPositionLg.value}px`);
160
+ const nextArrowTranslateXl = computed(() => `${arrowPositionXl.value}px`);
161
+ const nextArrowTranslateXxl = computed(() => `${arrowPositionXxl.value}px`);
162
+
163
+ // extra space to add below the carousel for the arrows when arrows are on but dots are off
164
+ const arrowsOnlyBottomSpacing = computed(() => `${props.controlGap + arrowButtonSize.value}px`);
165
+
166
+ const responsiveOptions = computed(() => {
167
+ // if no special breakpoints are defined, don't pass in any responsive options
168
+ if (!Object.keys(props.breakpoints).length) {
169
+ return undefined;
170
+ }
171
+
172
+ return [
173
+ // XXL breakpoint
174
+ {
175
+ // max width of XXL is infinite, so let's use 9999px
176
+ breakpoint: '9999px',
177
+ numScroll: numScrollXxl.value,
178
+ numVisible: numVisibleXxl.value,
179
+ },
180
+ // XL breakpoint
181
+ {
182
+ // max width of XL is XXL minus one
183
+ breakpoint: `${BREAKPOINTS.XXL - 1}px`,
184
+ numScroll: numScrollXl.value,
185
+ numVisible: numVisibleXl.value,
186
+ },
187
+ // LG breakpoint
188
+ {
189
+ // max width of LG is XL minus one
190
+ breakpoint: `${BREAKPOINTS.XL - 1}px`,
191
+ numScroll: numScrollLg.value,
192
+ numVisible: numVisibleLg.value,
193
+ },
194
+ // MD breakpoint
195
+ {
196
+ // max width of MD is LG minus one
197
+ breakpoint: `${BREAKPOINTS.LG - 1}px`,
198
+ numScroll: numScrollMd.value,
199
+ numVisible: numVisibleMd.value,
200
+ },
201
+ // SM breakpoint
202
+ {
203
+ // max width of SM is MD minus one
204
+ breakpoint: `${BREAKPOINTS.MD - 1}px`,
205
+ numScroll: numScrollSm.value,
206
+ numVisible: numVisibleSm.value,
207
+ },
208
+ // XS breakpoint
209
+ // (this is necessary to avoid weird behavior on mobile)
210
+ {
211
+ // max width of XS is SM minus one
212
+ breakpoint: `${BREAKPOINTS.SM - 1}px`,
213
+ numScroll: props.numScroll,
214
+ numVisible: props.numVisible,
215
+ },
216
+ ];
217
+ });
218
+
219
+ const autoplayInterval = ref(props.autoPlay ? props.autoPlayInterval : 0);
220
+ const isMounted = ref(false);
221
+ const key = ref('');
222
+
223
+ const stopAutoplay = () => {
224
+ if (autoplayInterval.value > 0) {
225
+ autoplayInterval.value = 0;
226
+ key.value = 'stopAutoplay';
227
+ }
228
+ };
229
+
230
+ onMounted(() => {
231
+ /**
232
+ * avoids an unavoidable SSR issue with responsive carousels (SSR can't know the breakpoint
233
+ * and therefore how many items need to be displayed per page) where circular carousels have
234
+ * their last few items cloned and inserted before the first item in the list, meaning on initial
235
+ * page render, you see those cloned last items listed first rather than the first item.
236
+ *
237
+ * then, upon hydration, the items change and the first item is then listed first.
238
+ *
239
+ * this workaround disables circular functionality for SSR, and swaps to the user-provided
240
+ * setting for it on mount.
241
+ *
242
+ * this flag is also used to hide the extra dots from the mobile view on larger breakpoints
243
+ * before hydration occurs and the number of dots is adjusted to the breakpoint.
244
+ */
245
+ isMounted.value = true;
246
+
247
+ document.addEventListener('keyup', (e) => {
248
+ if (e.key === 'Escape') {
249
+ // Stop carousel when user presses Escape key, in lieu of pause button
250
+ // https://www.w3.org/WAI/WCAG22/Techniques/general/G187.html
251
+ stopAutoplay();
252
+ }
253
+ });
254
+ });
255
+ </script>
256
+
257
+ <template>
258
+ <carousel
259
+ :key="key"
260
+ :autoplay-interval="autoplayInterval"
261
+ :circular="isMounted && circular"
262
+ class="es-carousel"
263
+ :class="{
264
+ 'es-carousel--brand': variant === 'brand',
265
+ 'arrows-only': showArrows && !showDots,
266
+ 'before-mount': !isMounted,
267
+ circular: circular,
268
+ dots: showDots,
269
+ [`num-dots-sm-${numDotsSm}`]: true,
270
+ [`num-dots-md-${numDotsMd}`]: true,
271
+ [`num-dots-lg-${numDotsLg}`]: true,
272
+ [`num-dots-xl-${numDotsXl}`]: true,
273
+ [`num-dots-xxl-${numDotsXxl}`]: true,
274
+ }"
275
+ :num-scroll="numScroll"
276
+ :num-visible="numVisible"
277
+ :responsive-options="responsiveOptions"
278
+ :show-indicators="showDots"
279
+ :show-navigators="showArrows"
280
+ :value="items"
281
+ :pt="{
282
+ container: {
283
+ class: 'es-carousel-container d-flex position-relative',
284
+ },
285
+ indicator: {
286
+ class: 'es-carousel-dot',
287
+ },
288
+ indicators: {
289
+ class: 'es-carousel-dots d-flex justify-content-center',
290
+ },
291
+ indicatorButton: {
292
+ class: 'd-block',
293
+ },
294
+ itemsContent: {
295
+ class: 'w-100 overflow-hidden',
296
+ },
297
+ itemsContainer: {
298
+ class: 'd-flex',
299
+ },
300
+ item: {
301
+ class: 'es-carousel-item',
302
+ },
303
+ itemCloned: {
304
+ class: 'es-carousel-item',
305
+ },
306
+ previousButton: {
307
+ class: 'es-carousel-arrow es-carousel-prev-arrow btn btn-outline-primary position-absolute px-sm-50',
308
+ },
309
+ nextButton: {
310
+ class: 'es-carousel-arrow es-carousel-next-arrow btn btn-outline-primary position-absolute px-sm-50',
311
+ },
312
+ }"
313
+ @update:page="(value: number) => emit('update', value)">
314
+ <template #item="item">
315
+ <slot
316
+ name="item"
317
+ :item="item.data" />
318
+ </template>
319
+ <template #previousicon>
320
+ <icon-chevron-left />
321
+ </template>
322
+ <template #nexticon>
323
+ <icon-chevron-right />
324
+ </template>
325
+ </carousel>
326
+ </template>
327
+
328
+ <style lang="scss" scoped>
329
+ @use '@energysage/es-ds-styles/scss/variables' as variables;
330
+ @use '@energysage/es-ds-styles/scss/mixins/breakpoints' as breakpoints;
331
+ @use 'sass:map';
332
+
333
+ /**
334
+ solution for PrimeVue initially displaying the mobile breakpoint's number of dots on page load
335
+ until hydration, when it then adjusts to the actual breakpoint and corrects the number of dots
336
+
337
+ generate CSS classes for each breakpoint that hide the dots that should be hidden before mount
338
+ */
339
+ $num-dots-supported: 8;
340
+ .es-carousel.before-mount {
341
+ @each $breakpoint in map.keys(variables.$grid-breakpoints) {
342
+ @include breakpoints.media-breakpoint-up($breakpoint) {
343
+ $infix: breakpoints.breakpoint-infix($breakpoint, variables.$grid-breakpoints);
344
+ @for $i from 1 through $num-dots-supported {
345
+ &.num-dots#{$infix}-#{$i} :deep(.es-carousel-dot:nth-child(#{$i}) ~ .es-carousel-dot) {
346
+ display: none;
347
+ }
348
+ }
349
+ }
350
+ }
351
+ }
352
+
353
+ /* prevent the prev arrow from looking disabled on circular carousels on first paint */
354
+ .es-carousel.before-mount.circular :deep(.es-carousel-prev-arrow:disabled) {
355
+ color: variables.$gray-900;
356
+ }
357
+ .es-carousel.es-carousel--brand.before-mount.circular :deep(.es-carousel-prev-arrow:disabled) {
358
+ color: variables.$blue-900;
359
+ }
360
+
361
+ /* arrows are positioned absolutely, so when arrows are shown but dots are not, we need to reserve space for them */
362
+ .es-carousel.arrows-only {
363
+ padding-bottom: v-bind(arrowsOnlyBottomSpacing);
364
+ }
365
+
366
+ /* ensure there's enough space between the dots (when present) and the next content on the page */
367
+ .es-carousel.dots {
368
+ padding-bottom: 0.25rem;
369
+ }
370
+
371
+ /* make the carousel card edges align with page content */
372
+ :deep(.es-carousel-container) {
373
+ margin-left: v-bind(negativeMargin);
374
+ margin-right: v-bind(negativeMargin);
375
+ }
376
+
377
+ /* card sizing, based on num visible at each breakpoint */
378
+ :deep(.es-carousel-item) {
379
+ flex: 1 0 calc(100% / v-bind(numVisibleXs));
380
+ padding: 0 v-bind(sidePadding);
381
+
382
+ @include breakpoints.media-breakpoint-up(sm) {
383
+ flex: 1 0 calc(100% / v-bind(numVisibleSm));
384
+ }
385
+
386
+ @include breakpoints.media-breakpoint-up(md) {
387
+ flex: 1 0 calc(100% / v-bind(numVisibleMd));
388
+ }
389
+
390
+ @include breakpoints.media-breakpoint-up(lg) {
391
+ flex: 1 0 calc(100% / v-bind(numVisibleLg));
392
+ }
393
+
394
+ @include breakpoints.media-breakpoint-up(xl) {
395
+ flex: 1 0 calc(100% / v-bind(numVisibleXl));
396
+ }
397
+
398
+ @include breakpoints.media-breakpoint-up(xxl) {
399
+ flex: 1 0 calc(100% / v-bind(numVisibleXxl));
400
+ }
401
+ }
402
+
403
+ /* previous arrow horizontal positioning at each breakpoint */
404
+ :deep(.es-carousel-prev-arrow) {
405
+ transform: translateX(v-bind(prevArrowTranslateXs));
406
+
407
+ /* keep the "shift 1px down on click" transform from removing our transform */
408
+ &:not(:disabled):not(.disabled):active {
409
+ transform: translateX(v-bind(prevArrowTranslateXs)) translateY(1px);
410
+ }
411
+
412
+ @include breakpoints.media-breakpoint-up(sm) {
413
+ transform: translateX(v-bind(prevArrowTranslateSm));
414
+
415
+ &:not(:disabled):not(.disabled):active {
416
+ transform: translateX(v-bind(prevArrowTranslateSm)) translateY(1px);
417
+ }
418
+ }
419
+
420
+ @include breakpoints.media-breakpoint-up(md) {
421
+ transform: translateX(v-bind(prevArrowTranslateMd));
422
+
423
+ &:not(:disabled):not(.disabled):active {
424
+ transform: translateX(v-bind(prevArrowTranslateMd)) translateY(1px);
425
+ }
426
+ }
427
+
428
+ @include breakpoints.media-breakpoint-up(lg) {
429
+ transform: translateX(v-bind(prevArrowTranslateLg));
430
+
431
+ &:not(:disabled):not(.disabled):active {
432
+ transform: translateX(v-bind(prevArrowTranslateLg)) translateY(1px);
433
+ }
434
+ }
435
+
436
+ @include breakpoints.media-breakpoint-up(xl) {
437
+ transform: translateX(v-bind(prevArrowTranslateXl));
438
+
439
+ &:not(:disabled):not(.disabled):active {
440
+ transform: translateX(v-bind(prevArrowTranslateXl)) translateY(1px);
441
+ }
442
+ }
443
+
444
+ @include breakpoints.media-breakpoint-up(xxl) {
445
+ transform: translateX(v-bind(prevArrowTranslateXxl));
446
+
447
+ &:not(:disabled):not(.disabled):active {
448
+ transform: translateX(v-bind(prevArrowTranslateXxl)) translateY(1px);
449
+ }
450
+ }
451
+ }
452
+
453
+ /* next arrow horizontal positioning at each breakpoint */
454
+ :deep(.es-carousel-next-arrow) {
455
+ transform: translateX(v-bind(nextArrowTranslateXs));
456
+
457
+ /* keep the "shift 1px down on click" transform from removing our transform */
458
+ &:not(:disabled):not(.disabled):active {
459
+ transform: translateX(v-bind(nextArrowTranslateXs)) translateY(1px);
460
+ }
461
+
462
+ @include breakpoints.media-breakpoint-up(sm) {
463
+ transform: translateX(v-bind(nextArrowTranslateSm));
464
+
465
+ &:not(:disabled):not(.disabled):active {
466
+ transform: translateX(v-bind(nextArrowTranslateSm)) translateY(1px);
467
+ }
468
+ }
469
+
470
+ @include breakpoints.media-breakpoint-up(md) {
471
+ transform: translateX(v-bind(nextArrowTranslateMd));
472
+
473
+ &:not(:disabled):not(.disabled):active {
474
+ transform: translateX(v-bind(nextArrowTranslateMd)) translateY(1px);
475
+ }
476
+ }
477
+
478
+ @include breakpoints.media-breakpoint-up(lg) {
479
+ transform: translateX(v-bind(nextArrowTranslateLg));
480
+
481
+ &:not(:disabled):not(.disabled):active {
482
+ transform: translateX(v-bind(nextArrowTranslateLg)) translateY(1px);
483
+ }
484
+ }
485
+
486
+ @include breakpoints.media-breakpoint-up(xl) {
487
+ transform: translateX(v-bind(nextArrowTranslateXl));
488
+
489
+ &:not(:disabled):not(.disabled):active {
490
+ transform: translateX(v-bind(nextArrowTranslateXl)) translateY(1px);
491
+ }
492
+ }
493
+
494
+ @include breakpoints.media-breakpoint-up(xxl) {
495
+ transform: translateX(v-bind(nextArrowTranslateXxl));
496
+
497
+ &:not(:disabled):not(.disabled):active {
498
+ transform: translateX(v-bind(nextArrowTranslateXxl)) translateY(1px);
499
+ }
500
+ }
501
+ }
502
+
503
+ /* prev/next arrow button styling */
504
+ :deep(.es-carousel-arrow) {
505
+ background: unset;
506
+ border: unset;
507
+ bottom: v-bind(arrowPositionBottom);
508
+ box-shadow: none;
509
+ color: variables.$gray-900;
510
+ height: auto;
511
+ left: 50%;
512
+ padding: v-bind(arrowPadding);
513
+
514
+ &:hover {
515
+ color: variables.$gray-700;
516
+ }
517
+ &:focus {
518
+ color: variables.$gray-900;
519
+ }
520
+ &:not(:disabled):not(.disabled):active {
521
+ background: unset;
522
+ box-shadow: none;
523
+ color: variables.$gray-700;
524
+ }
525
+ &:disabled {
526
+ color: variables.$gray-400;
527
+ }
528
+
529
+ svg {
530
+ /* use !important to override the inline style on svg icons */
531
+ height: v-bind(arrowSizePx) !important;
532
+ width: v-bind(arrowSizePx) !important;
533
+ }
534
+ }
535
+
536
+ /* prev/next arrow button styling for the "brand" variant */
537
+ .es-carousel--brand {
538
+ :deep(.es-carousel-arrow) {
539
+ color: variables.$blue-600;
540
+
541
+ &:hover {
542
+ color: variables.$blue-700;
543
+ }
544
+ &:not(:disabled):not(.disabled):active {
545
+ color: variables.$blue-800;
546
+ }
547
+ &:disabled {
548
+ color: variables.$gray-400;
549
+ }
550
+ }
551
+ }
552
+
553
+ /* dots container */
554
+ :deep(.es-carousel-dots) {
555
+ gap: v-bind(dotSpacing);
556
+ padding-left: 0;
557
+ margin-top: v-bind(dotsMarginTop);
558
+ }
559
+
560
+ /* each individual dot */
561
+ :deep(.es-carousel-dot) {
562
+ list-style-type: none;
563
+ margin-bottom: 0;
564
+
565
+ &[data-p-highlight='true'] button {
566
+ background-color: variables.$orange-800;
567
+ }
568
+
569
+ button {
570
+ background-color: variables.$gray-100;
571
+ border: none;
572
+ border-radius: 50%;
573
+ height: v-bind(dotSize);
574
+ padding: 0;
575
+ width: v-bind(dotSize);
576
+
577
+ &:hover {
578
+ opacity: 0.8;
579
+ }
580
+ }
581
+ }
582
+ </style>
@@ -0,0 +1,27 @@
1
+ <script setup lang="ts">
2
+ const props = defineProps<{
3
+ cols?: string;
4
+ sm?: string;
5
+ md?: string;
6
+ lg?: string;
7
+ xl?: string;
8
+ xxl?: string;
9
+ }>();
10
+
11
+ const undefinedSize = !(props.cols || props.sm || props.md || props.lg || props.xl || props.xxl);
12
+ </script>
13
+
14
+ <template>
15
+ <div
16
+ :class="{
17
+ col: undefinedSize,
18
+ [`col-${cols}`]: cols,
19
+ [`col-sm${sm ? `-${sm}` : ''}`]: sm !== undefined,
20
+ [`col-md${md ? `-${md}` : ''}`]: md !== undefined,
21
+ [`col-lg${lg ? `-${lg}` : ''}`]: lg !== undefined,
22
+ [`col-xl${xl ? `-${xl}` : ''}`]: xl !== undefined,
23
+ [`col-xxl${xxl ? `-${xxl}` : ''}`]: xxl !== undefined,
24
+ }">
25
+ <slot />
26
+ </div>
27
+ </template>