tide-design-system 2.4.4 → 2.4.5
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/dist/style.css +1 -1
- package/dist/tide-design-system.cjs +2 -2
- package/dist/tide-design-system.esm.d.ts +23 -5
- package/dist/tide-design-system.esm.js +778 -727
- package/index.ts +2 -0
- package/package.json +1 -1
- package/src/components/TideAlert.vue +46 -3
- package/src/stories/TideAlert.stories.ts +37 -1
package/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ import TideChipFilter from '@/components/TideChipFilter.vue';
|
|
|
15
15
|
import TideChipInput from '@/components/TideChipInput.vue';
|
|
16
16
|
import TideColumns from '@/components/TideColumns.vue';
|
|
17
17
|
import TideDivider from '@/components/TideDivider.vue';
|
|
18
|
+
import TideForm from '@/components/TideForm.vue';
|
|
18
19
|
import TideIcon from '@/components/TideIcon.vue';
|
|
19
20
|
import TideImage from '@/components/TideImage.vue';
|
|
20
21
|
import TideImageBackground from '@/components/TideImageBackground.vue';
|
|
@@ -159,6 +160,7 @@ export {
|
|
|
159
160
|
TideChipInput,
|
|
160
161
|
TideColumns,
|
|
161
162
|
TideDivider,
|
|
163
|
+
TideForm,
|
|
162
164
|
TideIcon,
|
|
163
165
|
TideImage,
|
|
164
166
|
TideImageBackground,
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed } from 'vue';
|
|
2
|
+
import { Comment, computed, useSlots } from 'vue';
|
|
3
3
|
|
|
4
4
|
import TideButtonIcon from '@/components/TideButtonIcon.vue';
|
|
5
5
|
import TideIcon from '@/components/TideIcon.vue';
|
|
6
|
+
import TideLink from '@/components/TideLink.vue';
|
|
6
7
|
import { ALERT } from '@/types/Alert';
|
|
8
|
+
import { ELEMENT } from '@/types/Element';
|
|
7
9
|
import { ICON } from '@/types/Icon';
|
|
8
10
|
import { PRIORITY } from '@/types/Priority';
|
|
9
11
|
import { SIZE } from '@/types/Size';
|
|
@@ -13,6 +15,7 @@
|
|
|
13
15
|
|
|
14
16
|
type Props = {
|
|
15
17
|
heading?: string;
|
|
18
|
+
ctaLabel?: string;
|
|
16
19
|
isDismissible?: boolean;
|
|
17
20
|
isToast?: boolean;
|
|
18
21
|
type?: Alert;
|
|
@@ -20,9 +23,11 @@
|
|
|
20
23
|
|
|
21
24
|
type Emits = {
|
|
22
25
|
(event: 'close'): void;
|
|
26
|
+
(event: 'ctaClick'): void;
|
|
23
27
|
};
|
|
24
28
|
|
|
25
29
|
const props = withDefaults(defineProps<Props>(), {
|
|
30
|
+
ctaLabel: undefined,
|
|
26
31
|
heading: undefined,
|
|
27
32
|
isDismissible: true,
|
|
28
33
|
isToast: false,
|
|
@@ -30,6 +35,15 @@
|
|
|
30
35
|
});
|
|
31
36
|
|
|
32
37
|
const emit = defineEmits<Emits>();
|
|
38
|
+
const slots = useSlots();
|
|
39
|
+
const hasBody = computed(() => {
|
|
40
|
+
const nodes = slots.default?.();
|
|
41
|
+
if (!nodes) return false;
|
|
42
|
+
|
|
43
|
+
return nodes.some(
|
|
44
|
+
(node) => node.type !== Comment && (typeof node.children !== 'string' || node.children.trim().length > 0)
|
|
45
|
+
);
|
|
46
|
+
});
|
|
33
47
|
|
|
34
48
|
const iconType = computed(() => {
|
|
35
49
|
if (props.type === ALERT.ERROR) return ICON.PRIORITY_HIGH;
|
|
@@ -78,8 +92,24 @@
|
|
|
78
92
|
/>
|
|
79
93
|
</div>
|
|
80
94
|
|
|
81
|
-
<div
|
|
82
|
-
|
|
95
|
+
<div
|
|
96
|
+
:class="[
|
|
97
|
+
'tide-alert-heading',
|
|
98
|
+
CSS.DISPLAY.FLEX,
|
|
99
|
+
CSS.AXIS2.CENTER,
|
|
100
|
+
CSS.FLEX.DIRECTION.ROW,
|
|
101
|
+
!hasBody ? [CSS.AXIS1.BETWEEN, CSS.MARGIN.RIGHT.HALF] : '',
|
|
102
|
+
]"
|
|
103
|
+
>
|
|
104
|
+
<span :class="CSS.FONT.ROLE.LABEL_2_SEMIBOLD">{{ props.heading }}</span>
|
|
105
|
+
|
|
106
|
+
<TideLink
|
|
107
|
+
:class="[CSS.FONT.ROLE.LINK_2]"
|
|
108
|
+
:element="ELEMENT.BUTTON"
|
|
109
|
+
:label="props.ctaLabel"
|
|
110
|
+
@click="emit('ctaClick')"
|
|
111
|
+
v-if="props.ctaLabel && !hasBody"
|
|
112
|
+
/>
|
|
83
113
|
</div>
|
|
84
114
|
|
|
85
115
|
<TideButtonIcon
|
|
@@ -93,6 +123,19 @@
|
|
|
93
123
|
|
|
94
124
|
<div :class="['tide-alert-body', CSS.FONT.ROLE.BODY_2, !props.isToast && CSS.FONT.COLOR.SURFACE.DEFAULT]">
|
|
95
125
|
<slot />
|
|
126
|
+
|
|
127
|
+
<div
|
|
128
|
+
:class="[CSS.MARGIN.TOP.HALF]"
|
|
129
|
+
v-if="props.ctaLabel && hasBody"
|
|
130
|
+
>
|
|
131
|
+
<TideLink
|
|
132
|
+
:class="[CSS.FONT.ROLE.LINK_2]"
|
|
133
|
+
:element="ELEMENT.BUTTON"
|
|
134
|
+
:label="props.ctaLabel"
|
|
135
|
+
@click="emit('ctaClick')"
|
|
136
|
+
v-if="props.ctaLabel"
|
|
137
|
+
/>
|
|
138
|
+
</div>
|
|
96
139
|
</div>
|
|
97
140
|
</div>
|
|
98
141
|
</template>
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
|
|
15
15
|
type Args = InstanceType<typeof TideAlert>['$props'] & {
|
|
16
16
|
handleClose: string;
|
|
17
|
+
handleCtaClick: string;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
const render = (args: Args) => ({
|
|
@@ -33,16 +34,38 @@ const render = (args: Args) => ({
|
|
|
33
34
|
alert('Please specify a valid handler in the "close" control.');
|
|
34
35
|
}
|
|
35
36
|
},
|
|
37
|
+
handleCtaClick: () => {
|
|
38
|
+
action('TideAlert "Action" CTA clicked')({});
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
const callback = eval(args.handleCtaClick);
|
|
42
|
+
|
|
43
|
+
if (callback) {
|
|
44
|
+
callback();
|
|
45
|
+
}
|
|
46
|
+
} catch {
|
|
47
|
+
alert('Please specify a valid handler in the "ctaClick" control.');
|
|
48
|
+
}
|
|
49
|
+
},
|
|
36
50
|
},
|
|
37
51
|
setup: () => ({ args }),
|
|
38
|
-
template: `<TideAlert @close="handleClose" v-bind="args">{{ args.default }}</TideAlert>`,
|
|
52
|
+
template: `<TideAlert @close="handleClose" @click="handleCtaClick" v-bind="args">{{ args.default }}</TideAlert>`,
|
|
39
53
|
});
|
|
40
54
|
|
|
41
55
|
const ALERT = prependNoneAsUndefined(STANDARD_ALERT.ALERT);
|
|
42
56
|
|
|
43
57
|
export default {
|
|
44
58
|
argTypes: {
|
|
59
|
+
click: disabledArgType,
|
|
45
60
|
close: disabledArgType,
|
|
61
|
+
ctaLabel: {
|
|
62
|
+
control: 'text',
|
|
63
|
+
description: 'Call To Action that renders as a TideLink; clicking emits a separate `click` event',
|
|
64
|
+
table: {
|
|
65
|
+
defaultValue: { summary: 'None' },
|
|
66
|
+
type: { summary: 'string' },
|
|
67
|
+
},
|
|
68
|
+
},
|
|
46
69
|
dataTrack,
|
|
47
70
|
default: {
|
|
48
71
|
control: 'text',
|
|
@@ -63,6 +86,17 @@ export default {
|
|
|
63
86
|
type: { summary: '() => void' },
|
|
64
87
|
},
|
|
65
88
|
},
|
|
89
|
+
handleCtaClick: {
|
|
90
|
+
control: 'text',
|
|
91
|
+
description: 'JS code or function to execute on CTA click event',
|
|
92
|
+
isEmit: true,
|
|
93
|
+
name: 'click',
|
|
94
|
+
table: {
|
|
95
|
+
category: 'Events',
|
|
96
|
+
defaultValue: { summary: 'None' },
|
|
97
|
+
type: { summary: '() => void' },
|
|
98
|
+
},
|
|
99
|
+
},
|
|
66
100
|
heading: {
|
|
67
101
|
control: 'text',
|
|
68
102
|
description: 'Heading text',
|
|
@@ -88,9 +122,11 @@ export default {
|
|
|
88
122
|
},
|
|
89
123
|
},
|
|
90
124
|
args: {
|
|
125
|
+
ctaLabel: '',
|
|
91
126
|
dataTrack: '',
|
|
92
127
|
default: '',
|
|
93
128
|
handleClose: 'doSomething',
|
|
129
|
+
handleCtaClick: 'doSomething',
|
|
94
130
|
heading: 'Heading',
|
|
95
131
|
isDismissible: undefined,
|
|
96
132
|
isToast: undefined,
|