@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
package/.eslintignore ADDED
@@ -0,0 +1,9 @@
1
+ # don't ever lint node_modules
2
+ node_modules
3
+ # don't lint build output (make sure it's set to your correct build folder name)
4
+ dist
5
+ .nuxt
6
+ .output
7
+ # don't lint coverage output
8
+ coverage
9
+ *.json
package/.eslintrc.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": ["../es-ds-docs/.eslintrc.json"]
3
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "printWidth": 119,
3
+ "useTabs": false,
4
+ "singleQuote": true,
5
+ "trailingComma": "all",
6
+ "bracketSpacing": true,
7
+ "bracketSameLine": true,
8
+ "singleAttributePerLine": true,
9
+ "tabWidth": 4
10
+ }
package/README.md CHANGED
@@ -8,9 +8,6 @@ An EnergySage Nuxt layer library with design system components
8
8
  npm install @energysage/es-ds-components
9
9
  ```
10
10
 
11
- _*Note: this library is in pre-release development, so the above command won't yet work, as this package
12
- is not yet published to NPM.*_
13
-
14
11
  Once the package is installed, you'll need to add a reference to it in your nuxt.config.ts like so:
15
12
 
16
13
  ```
@@ -0,0 +1,117 @@
1
+ <script setup lang="ts">
2
+ import Accordion from 'primevue/accordion';
3
+ import AccordionTab from 'primevue/accordiontab';
4
+
5
+ interface Props {
6
+ allowMultipleExpand?: boolean;
7
+ initialExpandedId?: string;
8
+ variant?: string;
9
+ }
10
+
11
+ const props = withDefaults(defineProps<Props>(), {
12
+ allowMultipleExpand: false,
13
+ initialExpandedId: '',
14
+ variant: 'default',
15
+ });
16
+
17
+ // eslint-disable-next-line vue/require-prop-types
18
+ const model = defineModel();
19
+
20
+ const children = useSlots().default?.() || [];
21
+
22
+ const activeIndex = ref();
23
+
24
+ watch(model, (newVal) => {
25
+ if (newVal) {
26
+ // @ts-expect-error not sure
27
+ activeIndex.value = children.findIndex((child) => child.props.id === newVal);
28
+ }
29
+ });
30
+
31
+ const accordionTabs = children.map((child, index) => {
32
+ // @ts-expect-error not sure
33
+ if (child.props.id === props.initialExpandedId || child.props.id === model.value) {
34
+ activeIndex.value = index;
35
+ }
36
+ return child.children;
37
+ });
38
+
39
+ const updateActiveIndex = (index: any) => {
40
+ if (model.value) {
41
+ // @ts-expect-error not sure
42
+ model.value = children[index]?.props.id || '';
43
+ }
44
+ };
45
+ </script>
46
+
47
+ <template>
48
+ <accordion
49
+ :multiple="allowMultipleExpand"
50
+ :active-index="activeIndex"
51
+ :pt="{
52
+ root: {
53
+ class: `es-accordion-list es-accordion-list--${variant}`,
54
+ },
55
+ }"
56
+ @update:active-index="updateActiveIndex">
57
+ <template #collapseicon> </template>
58
+ <template #expandicon> </template>
59
+ <accordion-tab
60
+ v-for="(tab, index) in accordionTabs"
61
+ :key="index"
62
+ :pt="{
63
+ root: ({ context }) => ({
64
+ class: [
65
+ `es-accordion es-accordion--${variant}`,
66
+ {
67
+ expanded: context.active,
68
+ },
69
+ ],
70
+ }),
71
+ header: {
72
+ class: 'position-relative d-block',
73
+ },
74
+ headerAction: ({ context }) => ({
75
+ class: [
76
+ // eslint-disable-next-line max-len
77
+ 'es-accordion-heading mb-0 align-items-center d-flex font-weight-bold justify-content-between py-100',
78
+ {
79
+ 'es-accordion-heading--visible': context.active,
80
+ 'font-size-100 px-100 px-sm-200': variant !== 'minimal',
81
+ 'h3 px-0': variant === 'minimal',
82
+ },
83
+ ],
84
+ }),
85
+ transition: {
86
+ name: 'v-transition',
87
+ },
88
+ content: {
89
+ class: [
90
+ 'es-accordion-content pb-25',
91
+ {
92
+ 'bg-white pt-100 px-100 px-sm-200': variant !== 'minimal',
93
+ },
94
+ ],
95
+ },
96
+ }">
97
+ <template #header>
98
+ <span
99
+ role="heading"
100
+ aria-level="3"
101
+ :class="{ 'h3 mb-0': variant === 'minimal' }">
102
+ <!-- @vue-expect-error -->
103
+ <component
104
+ :is="item"
105
+ v-for="item in tab.title()"
106
+ :key="item" />
107
+ </span>
108
+ <icon-chevron-down class="es-accordion-icon flex-shrink-0 ml-200" />
109
+ </template>
110
+ <!-- @vue-expect-error -->
111
+ <component
112
+ :is="item"
113
+ v-for="item in tab.default()"
114
+ :key="item" />
115
+ </accordion-tab>
116
+ </accordion>
117
+ </template>
@@ -0,0 +1,7 @@
1
+ <!-- eslint-disable vue/valid-template-root -->
2
+ <template>
3
+ <!--
4
+ While this file needs to exist to keep Nuxt happy, it doesn't actually do anything.
5
+ Instances of es-accordion are placed inside es-accordion-list, and es-accordion-list handles their display.
6
+ -->
7
+ </template>
@@ -0,0 +1,20 @@
1
+ <script setup lang="ts">
2
+ defineProps({
3
+ variant: {
4
+ type: String,
5
+ default: 'primary',
6
+ required: false,
7
+ },
8
+ });
9
+ </script>
10
+
11
+ <template>
12
+ <span
13
+ class="badge"
14
+ :class="`badge-${variant}`">
15
+ <!--
16
+ @slot Badge Content
17
+ -->
18
+ <slot />
19
+ </span>
20
+ </template>
@@ -1,17 +1,45 @@
1
+ <script setup lang="ts">
2
+ import Breadcrumb from 'primevue/breadcrumb';
3
+
4
+ const props = defineProps({
5
+ items: {
6
+ type: Array,
7
+ required: true,
8
+ },
9
+ });
10
+ const route = useRoute();
11
+ const model = computed(() => {
12
+ if (!props.items) {
13
+ return [];
14
+ }
15
+
16
+ return props.items.map((item: any) => ({
17
+ ...item,
18
+ // mark breadcrumb as active if manually set or if it matches this route
19
+ active: item.active || route.path === item.to || route.path === item.href,
20
+ label: item.text,
21
+ url: item.href,
22
+ }));
23
+ });
24
+ </script>
25
+
1
26
  <template>
2
27
  <breadcrumb
3
28
  :model="model"
4
29
  :pt="{
5
30
  menu: 'breadcrumb',
6
- menuitem: 'breadcrumb-item'
31
+ menuitem: 'breadcrumb-item',
7
32
  }">
8
- <template #item="{ item, props }">
33
+ <template #item="{ item }">
9
34
  <!--
10
35
  primevue breadcrumb doesn't support an active non-link state out of the box,
11
36
  so we have to implement it via this slot
12
37
  https://v3.primevue.org/breadcrumb/#api.options.MenuItem
13
38
  -->
14
- <span v-if="item.active" aria-current="location" class="font-weight-bold">
39
+ <span
40
+ v-if="item.active"
41
+ aria-current="location"
42
+ class="font-weight-bold">
15
43
  {{ item.label }}
16
44
  </span>
17
45
  <!--
@@ -19,10 +47,15 @@
19
47
  so we have to implement it via this slot
20
48
  https://v3.primevue.org/breadcrumb/#router
21
49
  -->
22
- <nuxt-link v-else-if="item.to" :to="item.to">
50
+ <nuxt-link
51
+ v-else-if="item.to"
52
+ :to="item.to">
23
53
  {{ item.label }}
24
54
  </nuxt-link>
25
- <a v-else-if="item.url" :href="item.url" :target="item.target">
55
+ <a
56
+ v-else-if="item.url"
57
+ :href="item.url"
58
+ :target="item.target">
26
59
  {{ item.label }}
27
60
  </a>
28
61
  <span v-else>
@@ -30,31 +63,11 @@
30
63
  </span>
31
64
  </template>
32
65
  <template #separator>
33
- <span aria-hidden class="mx-50">/</span>
66
+ <span
67
+ aria-hidden="true"
68
+ class="mx-50"
69
+ >/</span
70
+ >
34
71
  </template>
35
72
  </breadcrumb>
36
73
  </template>
37
-
38
- <script setup lang="ts">
39
- const props = defineProps({
40
- items: {
41
- type: Array,
42
- required: true
43
- }
44
- });
45
-
46
- const route = useRoute();
47
- const model = computed(() => {
48
- if (!props.items) {
49
- return [];
50
- }
51
-
52
- return props.items.map(item => ({
53
- ...item,
54
- // mark breadcrumb as active if manually set or if it matches this route
55
- active: item.active || route.path === item.to || route.path === item.href,
56
- label: item.text,
57
- url: item.href
58
- }));
59
- });
60
- </script>
@@ -0,0 +1,122 @@
1
+ <script setup lang="ts">
2
+ // Cannot import as Button due to issue with native element Button
3
+ import PrimeButton from 'primevue/button';
4
+
5
+ /*
6
+ severity:
7
+
8
+ Prime severity (variant="dark-bg" in particular) doesn't map to
9
+ "success" | "help" | "secondary" | "info" | "warning" | "danger" | "contrast"
10
+
11
+ size:
12
+ Prime size "small" | "large" doesn't map to our 3-sizes in the design-system
13
+
14
+ icon usage:
15
+ Prime provides icon & loadingIcon slots which can hook into the loading property,
16
+ currently we're not using this (but we may want to re-visit)
17
+ */
18
+
19
+ const props = defineProps({
20
+ /**
21
+ * Button Variant
22
+ *
23
+ */
24
+ variant: {
25
+ type: String,
26
+ default: 'primary',
27
+ required: false,
28
+ },
29
+ /**
30
+ * Outline only button
31
+ */
32
+ outline: {
33
+ type: Boolean,
34
+ default: false,
35
+ },
36
+ /**
37
+ * Size of button
38
+ */
39
+ size: {
40
+ type: String,
41
+ validator: (val) => ['lg', 'md', 'sm'].includes(String(val)),
42
+ default: 'md',
43
+ },
44
+ /**
45
+ * Only works for 'link' variant buttons.
46
+ * Removes the fixed height and padding so the button can fit nicely within a block of text.
47
+ */
48
+ inline: {
49
+ type: Boolean,
50
+ default: false,
51
+ },
52
+
53
+ // PrimeVue Arguments with es-ds defaults
54
+ rounded: {
55
+ type: Boolean,
56
+ default: true,
57
+ },
58
+ // Url when using button as a link
59
+ href: {
60
+ type: String,
61
+ default: null,
62
+ },
63
+ // Url when using button as a link to an internal page
64
+ to: {
65
+ type: String,
66
+ default: null,
67
+ },
68
+ });
69
+
70
+ const getRootClasses = computed(() => {
71
+ const withOutline = props.outline ? '-outline' : '';
72
+ // eslint-disable-next-line no-nested-ternary
73
+ const btnVariant =
74
+ props.variant === 'link'
75
+ ? 'btn-link'
76
+ : props.variant === 'dark-bg'
77
+ ? `btn${withOutline}-dark-bg`
78
+ : `btn${withOutline}-primary`;
79
+ const btnInline = props.inline ? 'inline' : '';
80
+ const btnSize = props.size ? `btn-${props.size}` : 'btn-md';
81
+ return `btn ${btnVariant} ${btnInline} ${btnSize}`;
82
+ });
83
+ </script>
84
+
85
+ <template>
86
+ <!--
87
+ <a> is needed for href because a root-relative link like /market/start/
88
+ that is passed to <nuxt-link :to="" /> will attempt to internally navigate
89
+ within a micro frontend, which will result in a 404
90
+ -->
91
+ <a
92
+ v-if="props.href"
93
+ :class="getRootClasses"
94
+ :href="props.href">
95
+ <slot />
96
+ </a>
97
+ <nuxt-link
98
+ v-else-if="props.to"
99
+ :to="props.to"
100
+ :class="getRootClasses">
101
+ <slot />
102
+ </nuxt-link>
103
+ <prime-button
104
+ v-else
105
+ :pt="{
106
+ root: { class: getRootClasses },
107
+ }">
108
+ <slot />
109
+ </prime-button>
110
+ </template>
111
+
112
+ <style lang="scss" scoped>
113
+ .btn-link.inline {
114
+ /* use normal CSS here so users can override with utility classes as necessary */
115
+ border: 0;
116
+ height: auto;
117
+ line-height: inherit;
118
+ margin: 0;
119
+ padding: 0;
120
+ vertical-align: baseline;
121
+ }
122
+ </style>
@@ -0,0 +1,64 @@
1
+ <script setup lang="ts">
2
+ // specific workaround for getting a reference to an auto-imported but not globally registered
3
+ // component like NuxtLink, so that it can be used in a <component :is=""> context.
4
+ // this resolves to an import statement, according to:
5
+ // https://github.com/nuxt/nuxt/issues/13659#issuecomment-1573568006
6
+ const NuxtLink = resolveComponent('NuxtLink');
7
+
8
+ const props = defineProps({
9
+ href: {
10
+ type: String,
11
+ default: undefined,
12
+ },
13
+ tag: {
14
+ type: String,
15
+ default: 'div',
16
+ },
17
+ to: {
18
+ type: String,
19
+ default: undefined,
20
+ },
21
+ variant: {
22
+ type: String,
23
+ default: 'display',
24
+ required: false,
25
+ },
26
+ });
27
+
28
+ const actualVariant = computed(() => {
29
+ // if href is specified, force variant to be interactive
30
+ if (props.href) {
31
+ return 'interactive';
32
+ }
33
+ // if no href provided, honor the specified variant
34
+ return props.variant;
35
+ });
36
+ const defaultTag = computed(() => {
37
+ // if an href is provided and no alternate link tag was provided (e.g. nuxt-link),
38
+ // force the tag to be a nuxt-link, no matter the variant
39
+ if (props.href && props.tag === 'div') {
40
+ return 'nuxt-link';
41
+ }
42
+
43
+ // otherwise, honor the tag passed in if it's display variant
44
+ // or something other than the default tag was provided
45
+ if (props.variant !== 'interactive' || props.tag !== 'div') {
46
+ return props.tag;
47
+ }
48
+
49
+ // if we reach this point, variant is interactive, tag is div, and no href was provided
50
+ // and any non-link clickable element should be a button
51
+ return 'button';
52
+ });
53
+ </script>
54
+
55
+ <template>
56
+ <component
57
+ :is="defaultTag == 'nuxt-link' ? NuxtLink : defaultTag"
58
+ class="es-card"
59
+ :class="actualVariant"
60
+ :to="to ? to : href"
61
+ v-bind="$attrs">
62
+ <slot />
63
+ </component>
64
+ </template>