@energysage/es-ds-components 3.0.0-alpha.9 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -3
- package/components/es-accordion-list.vue +29 -12
- package/components/es-carousel.vue +524 -69
- package/components/es-col.vue +5 -5
- package/components/es-container.vue +10 -1
- package/components/es-data-table-column.vue +20 -0
- package/components/es-data-table.vue +35 -88
- package/components/es-error-page.vue +33 -24
- package/components/es-footer.vue +32 -3
- package/components/es-segmented-control.vue +237 -0
- package/components/es-tabs.vue +10 -3
- package/components/icon/ccpa-opt-out.vue +61 -0
- package/nuxt.config.ts +6 -0
- package/package.json +2 -2
- package/types/es-carousel.ts +12 -0
- package/types/index.ts +1 -0
- package/utils/get-es-footer-content.ts +1 -0
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
|
```
|
|
@@ -14,37 +14,56 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
14
14
|
variant: 'default',
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
const model = defineModel();
|
|
17
|
+
const model = defineModel<string>();
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
// get the list of elements provided as children to the default slot
|
|
20
|
+
const initialChildren = useSlots().default?.() || [];
|
|
21
|
+
const children: any[] = [];
|
|
22
|
+
initialChildren.forEach((child) => {
|
|
23
|
+
// unless this has a v-for element and we instead need to access its children
|
|
24
|
+
if (typeof child.type === 'symbol' && Array.isArray(child.children)) {
|
|
25
|
+
children.push(...child.children);
|
|
26
|
+
} else {
|
|
27
|
+
children.push(child);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
type ActiveChildren = null | number | number[];
|
|
21
32
|
|
|
22
|
-
const activeIndex = ref();
|
|
33
|
+
const activeIndex: Ref<ActiveChildren> = ref(null);
|
|
23
34
|
|
|
24
35
|
watch(model, (newVal) => {
|
|
25
36
|
if (newVal) {
|
|
26
|
-
// @ts-expect-error not sure
|
|
27
37
|
activeIndex.value = children.findIndex((child) => child.props.id === newVal);
|
|
28
38
|
}
|
|
29
39
|
});
|
|
30
40
|
|
|
31
41
|
const accordionTabs = children.map((child, index) => {
|
|
32
|
-
// @ts-expect-error not sure
|
|
33
42
|
if (child.props.id === props.initialExpandedId || child.props.id === model.value) {
|
|
34
|
-
|
|
43
|
+
if (props.allowMultipleExpand) {
|
|
44
|
+
activeIndex.value = [index];
|
|
45
|
+
} else {
|
|
46
|
+
activeIndex.value = index;
|
|
47
|
+
}
|
|
35
48
|
}
|
|
36
49
|
return child.children;
|
|
37
50
|
});
|
|
38
51
|
|
|
39
|
-
const updateActiveIndex = (index:
|
|
52
|
+
const updateActiveIndex = (index: ActiveChildren) => {
|
|
40
53
|
if (model.value) {
|
|
41
|
-
|
|
42
|
-
|
|
54
|
+
if (typeof index === 'number') {
|
|
55
|
+
model.value = children[index]?.props.id || '';
|
|
56
|
+
} else if (index === null) {
|
|
57
|
+
model.value = '';
|
|
58
|
+
}
|
|
59
|
+
// There's another case where index will be an array. In that case, v-model is unsupported as specified
|
|
60
|
+
// in the documentation, so no update is made
|
|
43
61
|
}
|
|
44
62
|
};
|
|
45
63
|
</script>
|
|
46
64
|
|
|
47
65
|
<template>
|
|
66
|
+
<!-- @vue-expect-error PrimeVue's type information is wrong -->
|
|
48
67
|
<accordion
|
|
49
68
|
:multiple="allowMultipleExpand"
|
|
50
69
|
:active-index="activeIndex"
|
|
@@ -99,7 +118,6 @@ const updateActiveIndex = (index: any) => {
|
|
|
99
118
|
role="heading"
|
|
100
119
|
aria-level="3"
|
|
101
120
|
:class="{ 'h3 mb-0': variant === 'minimal' }">
|
|
102
|
-
<!-- @vue-expect-error -->
|
|
103
121
|
<component
|
|
104
122
|
:is="item"
|
|
105
123
|
v-for="item in tab.title()"
|
|
@@ -107,7 +125,6 @@ const updateActiveIndex = (index: any) => {
|
|
|
107
125
|
</span>
|
|
108
126
|
<icon-chevron-down class="es-accordion-icon flex-shrink-0 ml-200" />
|
|
109
127
|
</template>
|
|
110
|
-
<!-- @vue-expect-error -->
|
|
111
128
|
<component
|
|
112
129
|
:is="item"
|
|
113
130
|
v-for="item in tab.default()"
|