@cypress-design/vue-alert 0.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/Alert.rootstory.tsx +110 -0
- package/Alert.stories.mdx +76 -0
- package/Alert.vue +142 -0
- package/AlertVue.cy.tsx +9 -0
- package/CHANGELOG.md +10 -0
- package/ReadMe.md +68 -0
- package/dist/constants.d.ts +13 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/index.es.js +223 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +225 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/vue/Alert.vue.d.ts +81 -0
- package/dist/vue/Alert.vue.d.ts.map +1 -0
- package/dist/vue/index.d.ts +2 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/index.ts +1 -0
- package/package.json +25 -0
- package/rollup.config.js +48 -0
- package/tsconfig.build.json +7 -0
- package/tsconfig.json +10 -0
- package/vue-shim.d.ts +5 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { IconArrowRight } from '@cypress-design/vue-icon'
|
|
2
|
+
import dedent from 'dedent'
|
|
3
|
+
import { ref } from 'vue'
|
|
4
|
+
import Alert from './Alert.vue'
|
|
5
|
+
|
|
6
|
+
export default (() => ({
|
|
7
|
+
setup() {
|
|
8
|
+
const displayTimedAlert = ref(false)
|
|
9
|
+
return () => (
|
|
10
|
+
<div class="flex flex-col p-4 gap-16px">
|
|
11
|
+
<Alert type="error" detailsTitle="Stack trace" data-cy="alert-1">
|
|
12
|
+
{{
|
|
13
|
+
default: () => 'Spec not found',
|
|
14
|
+
body: () => (
|
|
15
|
+
<>
|
|
16
|
+
There is no spec matching the following location:
|
|
17
|
+
<code class="bg-red-100 m-8px rounded px-2px">
|
|
18
|
+
path/to/spec.cy.js
|
|
19
|
+
</code>
|
|
20
|
+
<br />
|
|
21
|
+
<br />
|
|
22
|
+
It is possible that the file has since been moved or deleted.
|
|
23
|
+
Please choose from the list of specs below
|
|
24
|
+
</>
|
|
25
|
+
),
|
|
26
|
+
details: () => (
|
|
27
|
+
<pre class="bg-white rounded border border-red-500 px-16px py-8px overflow-x-auto">
|
|
28
|
+
{dedent`Uncaught Error: Error occurred in defineConfig()
|
|
29
|
+
Trace: add called with 2 and 3
|
|
30
|
+
at sum (/home/dev/Documents/stacktrace.js:2:13)
|
|
31
|
+
at start (/home/dev/Documents/stacktrace.js:11:13)
|
|
32
|
+
at Object. (/home/dev/Documents/stacktrace.js:16:1)
|
|
33
|
+
at Module._compile (internal/modules/cjs/loader.js:959:30)
|
|
34
|
+
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
|
|
35
|
+
at Module.load (internal/modules/cjs/loader.js:815:32)
|
|
36
|
+
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
|
|
37
|
+
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
|
|
38
|
+
at internal/main/run_main_module.js:17:11
|
|
39
|
+
Trace: add called with 8 and 11
|
|
40
|
+
at sum (/home/dev/Documents/stacktrace.js:2:13)
|
|
41
|
+
at calc (/home/dev/Documents/stacktrace.js:7:12)
|
|
42
|
+
at start (/home/dev/Documents/stacktrace.js:12:13)
|
|
43
|
+
at Object. (/home/dev/Documents/stacktrace.js:16:1)
|
|
44
|
+
at Module._compile (internal/modules/cjs/loader.js:959:30)
|
|
45
|
+
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
|
|
46
|
+
at Module.load (internal/modules/cjs/loader.js:815:32)
|
|
47
|
+
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
|
|
48
|
+
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
|
|
49
|
+
at internal/main/run_main_module.js:17:11
|
|
50
|
+
Trace: add called with 9 and 14
|
|
51
|
+
at sum (/home/dev/Documents/stacktrace.js:2:13)
|
|
52
|
+
at calc (/home/dev/Documents/stacktrace.js:7:25)
|
|
53
|
+
at start (/home/dev/Documents/stacktrace.js:12:13)
|
|
54
|
+
at Object. (/home/dev/Documents/stacktrace.js:16:1)
|
|
55
|
+
at Module._compile (internal/modules/cjs/loader.js:959:30)
|
|
56
|
+
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
|
|
57
|
+
at Module.load (internal/modules/cjs/loader.js:815:32)
|
|
58
|
+
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
|
|
59
|
+
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
|
|
60
|
+
at internal/main/run_main_module.js:17:11`}
|
|
61
|
+
</pre>
|
|
62
|
+
),
|
|
63
|
+
}}
|
|
64
|
+
</Alert>
|
|
65
|
+
<button
|
|
66
|
+
class="border rounded p-8px"
|
|
67
|
+
onClick={() => (displayTimedAlert.value = true)}
|
|
68
|
+
>
|
|
69
|
+
open alert for 5 seconds
|
|
70
|
+
</button>
|
|
71
|
+
{displayTimedAlert.value && (
|
|
72
|
+
<Alert
|
|
73
|
+
duration={5000}
|
|
74
|
+
onDismiss={() => (displayTimedAlert.value = false)}
|
|
75
|
+
dismissible
|
|
76
|
+
data-cy="alert-2"
|
|
77
|
+
>
|
|
78
|
+
Wait 5 seconds please
|
|
79
|
+
</Alert>
|
|
80
|
+
)}
|
|
81
|
+
<Alert type="success" dismissible data-cy="alert-3">
|
|
82
|
+
{{
|
|
83
|
+
default: () => 'Success with body',
|
|
84
|
+
body: () => 'Success body',
|
|
85
|
+
}}
|
|
86
|
+
</Alert>
|
|
87
|
+
<Alert type="warning" not-rounded>
|
|
88
|
+
Warning
|
|
89
|
+
</Alert>
|
|
90
|
+
<Alert type="neutral">Neutral</Alert>
|
|
91
|
+
<Alert type="error" dismissible class="text-justify" data-cy="alert-4">
|
|
92
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
|
|
93
|
+
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
|
|
94
|
+
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
|
|
95
|
+
aliquip ex ea commodo consequat. Duis aute irure dolor in
|
|
96
|
+
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
97
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
98
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
|
99
|
+
</Alert>
|
|
100
|
+
<Alert type="info">Info</Alert>
|
|
101
|
+
<Alert type="info">
|
|
102
|
+
{{
|
|
103
|
+
default: () => 'Info',
|
|
104
|
+
icon: (props: any) => <IconArrowRight {...props} />,
|
|
105
|
+
}}
|
|
106
|
+
</Alert>
|
|
107
|
+
</div>
|
|
108
|
+
)
|
|
109
|
+
},
|
|
110
|
+
}))()
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ArgsTable, Canvas, Meta, Story, Description } from '@storybook/addon-docs'
|
|
2
|
+
import { version } from "./package.json"
|
|
3
|
+
import changelog from "./CHANGELOG.md?raw"
|
|
4
|
+
|
|
5
|
+
import Alert from './Alert.vue'
|
|
6
|
+
|
|
7
|
+
import AlertStory from './Alert.rootstory'
|
|
8
|
+
|
|
9
|
+
<h1>Alert<span className="text-lg font-normal"> - v{version}</span></h1>
|
|
10
|
+
|
|
11
|
+
<Meta title="Alert" component={Alert} parameters={{
|
|
12
|
+
design: {
|
|
13
|
+
type: "figma",
|
|
14
|
+
url: "https://www.figma.com/file/1WJ3GVQyMV5e7xVxPg3yID/Design-System?node-id=1035%3A9923",
|
|
15
|
+
}
|
|
16
|
+
}} />
|
|
17
|
+
|
|
18
|
+
<Canvas withSource="none">
|
|
19
|
+
<Story name="Alert">
|
|
20
|
+
{AlertStory()}
|
|
21
|
+
</Story>
|
|
22
|
+
</Canvas>
|
|
23
|
+
|
|
24
|
+
<ArgsTable />
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
The simplest is to use with plain text. By default, type is `info`.
|
|
29
|
+
|
|
30
|
+
```vue
|
|
31
|
+
<script setup>
|
|
32
|
+
import Alert from '@cypress-design/vue-alert'
|
|
33
|
+
</script>
|
|
34
|
+
<template>
|
|
35
|
+
<Alert type="error">Great Scott!!</Alert>
|
|
36
|
+
</template>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
One can also have rich text in both the title and the body.
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<template>
|
|
43
|
+
<Alert>
|
|
44
|
+
This is an <code>info</code> message
|
|
45
|
+
<template #body>
|
|
46
|
+
<p>This is the body of the alert.</p>
|
|
47
|
+
</template>
|
|
48
|
+
</Alert>
|
|
49
|
+
</template>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If you want the alert to be dismissible, you can add the `dismissible` prop. Don't forget to add the `@dismiss` prop to handle the dismiss event.
|
|
53
|
+
|
|
54
|
+
```vue
|
|
55
|
+
<template>
|
|
56
|
+
<Alert
|
|
57
|
+
title="This is an info message"
|
|
58
|
+
dismissible
|
|
59
|
+
@dismiss="() => setDismissed(true)"
|
|
60
|
+
/>
|
|
61
|
+
</template>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
You can also remove the rounded corners and the icon of the alert by adding the `notRounded` and the `noIcon` props.
|
|
65
|
+
|
|
66
|
+
```vue
|
|
67
|
+
<template>
|
|
68
|
+
<Alert type="warning" title="This is an info message" notRounded noIcon />
|
|
69
|
+
</template>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
<Description>
|
|
74
|
+
{changelog.replace(/^# .+/, '## Changelog')}
|
|
75
|
+
</Description>
|
|
76
|
+
|
package/Alert.vue
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="!dismissed" class="overflow-hidden text-left" :class="props.notRounded ? undefined : 'rounded'">
|
|
3
|
+
<div class="flex p-16px" :class="typeClasses.headerClass">
|
|
4
|
+
<!-- @slot replace the default left icon here -->
|
|
5
|
+
<slot name="icon" v-bind="computedIconProps">
|
|
6
|
+
<component v-if="!props.noIcon && icon" :is="icon" v-bind="computedIconProps" />
|
|
7
|
+
</slot>
|
|
8
|
+
<div class="flex-1 font-medium">
|
|
9
|
+
<!-- @slot title of the alert -->
|
|
10
|
+
<slot />
|
|
11
|
+
</div>
|
|
12
|
+
<button v-if="dismissible" class="m-4px ml-8px h-16px" @click="dismiss" aria-label="Dismiss">
|
|
13
|
+
<IconActionDeleteLarge :stroke-color="typeClasses.iconCloseColor" />
|
|
14
|
+
</button>
|
|
15
|
+
</div>
|
|
16
|
+
<div v-if="slots.body" class="p-16px" :class="typeClasses.bodyClass">
|
|
17
|
+
<!-- @slot body/details of the alert -->
|
|
18
|
+
<slot name="body" />
|
|
19
|
+
</div>
|
|
20
|
+
<details v-if="slots.details" class="p-16px border-t-1" :class="[typeClasses.bodyClass, typeClasses.borderClass]">
|
|
21
|
+
<summary class="flex font-medium cursor-pointer" :class="typeClasses.detailsHeaderClass">
|
|
22
|
+
<IconChevronDownSmall :strokeColor="typeClasses.iconChevronColor" class="icon my-4px mr-8px" />
|
|
23
|
+
{{ props.detailsTitle }}
|
|
24
|
+
</summary>
|
|
25
|
+
<div class="mt-16px">
|
|
26
|
+
<!--@slot Togglable additional details-->
|
|
27
|
+
<slot name="details" />
|
|
28
|
+
</div>
|
|
29
|
+
</details>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script lang="ts" setup>
|
|
34
|
+
import { computed, useSlots, h, type FunctionalComponent, ref, onMounted, onUnmounted, type ComputedRef } from 'vue'
|
|
35
|
+
import {
|
|
36
|
+
IconChevronDownSmall, IconActionDeleteLarge,
|
|
37
|
+
IconWarningCircle, IconCheckmarkOutline,
|
|
38
|
+
} from '@cypress-design/vue-icon'
|
|
39
|
+
import type { AlertType } from '../constants'
|
|
40
|
+
import { alertClasses } from '../constants'
|
|
41
|
+
|
|
42
|
+
const dismissed = ref(false)
|
|
43
|
+
|
|
44
|
+
const slots = useSlots()
|
|
45
|
+
|
|
46
|
+
const emit = defineEmits<{
|
|
47
|
+
/**
|
|
48
|
+
* Clicking on the dismiss button or dismissed after a timeout
|
|
49
|
+
*/
|
|
50
|
+
(event: 'dismiss'): void,
|
|
51
|
+
}>()
|
|
52
|
+
|
|
53
|
+
const props = withDefaults(defineProps<{
|
|
54
|
+
/**
|
|
55
|
+
* Color scheme
|
|
56
|
+
*/
|
|
57
|
+
type?: AlertType
|
|
58
|
+
/**
|
|
59
|
+
* If details are provided,text used in the toggle button
|
|
60
|
+
*/
|
|
61
|
+
detailsTitle?: string
|
|
62
|
+
/**
|
|
63
|
+
* Show the dismiss button
|
|
64
|
+
*/
|
|
65
|
+
dismissible?: boolean
|
|
66
|
+
/**
|
|
67
|
+
* When an icon is displayed by default, use this to remove it
|
|
68
|
+
*/
|
|
69
|
+
noIcon?: boolean
|
|
70
|
+
/**
|
|
71
|
+
* If you need square corners
|
|
72
|
+
*/
|
|
73
|
+
notRounded?: boolean
|
|
74
|
+
/**
|
|
75
|
+
* Dismiss the alert after a delay (in ms)
|
|
76
|
+
*/
|
|
77
|
+
duration?: number
|
|
78
|
+
}>(), {
|
|
79
|
+
type: 'info',
|
|
80
|
+
detailsTitle: 'Additional details',
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
const typeClasses = computed(() => {
|
|
84
|
+
return alertClasses[props.type]
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
let timeout: number | undefined
|
|
88
|
+
|
|
89
|
+
onMounted(() => {
|
|
90
|
+
if (props.duration) {
|
|
91
|
+
timeout = setTimeout(dismiss, props.duration) as any
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
onUnmounted(() => {
|
|
96
|
+
if (timeout) {
|
|
97
|
+
clearTimeout(timeout)
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
function dismiss() {
|
|
102
|
+
dismissed.value = true
|
|
103
|
+
emit('dismiss')
|
|
104
|
+
if (timeout) {
|
|
105
|
+
clearTimeout(timeout)
|
|
106
|
+
timeout = undefined
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const computedIconProps = computed(() => {
|
|
111
|
+
return {
|
|
112
|
+
strokeColor: alertClasses[props.type].iconColor,
|
|
113
|
+
class: 'my-4px mr-8px'
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
const icon: ComputedRef<FunctionalComponent | null> = computed(() => {
|
|
118
|
+
switch (props.type) {
|
|
119
|
+
case 'info':
|
|
120
|
+
return null;
|
|
121
|
+
case 'success':
|
|
122
|
+
return () => h(IconCheckmarkOutline, computedIconProps.value)
|
|
123
|
+
case 'warning':
|
|
124
|
+
return () => h(IconWarningCircle, computedIconProps.value)
|
|
125
|
+
case 'error':
|
|
126
|
+
return () => h(IconWarningCircle, computedIconProps.value)
|
|
127
|
+
default:
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
</script>
|
|
133
|
+
|
|
134
|
+
<style scoped>
|
|
135
|
+
details summary .icon {
|
|
136
|
+
transform: rotate(-90deg);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
details[open] summary .icon {
|
|
140
|
+
transform: rotate(0);
|
|
141
|
+
}
|
|
142
|
+
</style>
|
package/AlertVue.cy.tsx
ADDED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# @cypress-design/vue-alert
|
|
2
|
+
|
|
3
|
+
## 0.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#39](https://github.com/cypress-io/cypress-design/pull/39) [`1b383f3`](https://github.com/cypress-io/cypress-design/commit/1b383f3d149948bf2cc062d3baa17d5ce032f07e) Thanks [@elevatebart](https://github.com/elevatebart)! - create alert component
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`4259026`](https://github.com/cypress-io/cypress-design/commit/4259026314464260e89bcd88690c8a60ad2f0459)]:
|
|
10
|
+
- @cypress-design/vue-icon@0.4.0
|
package/ReadMe.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Alert
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
Use the alert when you need a banner of some kind.
|
|
6
|
+
Examples:
|
|
7
|
+
|
|
8
|
+
- To give temporary information to the user.
|
|
9
|
+
- To attract attention to a specific note on the page.
|
|
10
|
+
- To inform the user of a change in the system.
|
|
11
|
+
|
|
12
|
+
## install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @cypress-design/vue-alert
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
or with yarn
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
yarn add @cypress-design/vue-alert
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
The simplest is to use with plain text. By default, type is `info`.
|
|
27
|
+
|
|
28
|
+
```vue
|
|
29
|
+
<script setup>
|
|
30
|
+
import Alert from '@cypress-design/vue-alert'
|
|
31
|
+
</script>
|
|
32
|
+
<template>
|
|
33
|
+
<Alert type="error">Great Scott!!</Alert>
|
|
34
|
+
</template>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
One can also have rich text in both the title and the body.
|
|
38
|
+
|
|
39
|
+
```vue
|
|
40
|
+
<template>
|
|
41
|
+
<Alert>
|
|
42
|
+
This is an <code>info</code> message
|
|
43
|
+
<template #body>
|
|
44
|
+
<p>This is the body of the alert.</p>
|
|
45
|
+
</template>
|
|
46
|
+
</Alert>
|
|
47
|
+
</template>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
If you want the alert to be dismissible, you can add the `dismissible` prop. Don't forget to add the `@dismiss` prop to handle the dismiss event.
|
|
51
|
+
|
|
52
|
+
```vue
|
|
53
|
+
<template>
|
|
54
|
+
<Alert
|
|
55
|
+
title="This is an info message"
|
|
56
|
+
dismissible
|
|
57
|
+
@dismiss="() => setDismissed(true)"
|
|
58
|
+
/>
|
|
59
|
+
</template>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
You can also remove the rounded corners and the icon of the alert by adding the `notRounded` and the `noIcon` props.
|
|
63
|
+
|
|
64
|
+
```vue
|
|
65
|
+
<template>
|
|
66
|
+
<Alert type="warning" title="This is an info message" notRounded noIcon />
|
|
67
|
+
</template>
|
|
68
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { WindiColor } from '@cypress-design/icon-registry';
|
|
2
|
+
export declare type AlertType = 'info' | 'success' | 'error' | 'warning' | 'neutral';
|
|
3
|
+
export declare type AlertClasses = {
|
|
4
|
+
headerClass: string;
|
|
5
|
+
bodyClass: string;
|
|
6
|
+
borderClass: string;
|
|
7
|
+
detailsHeaderClass: string;
|
|
8
|
+
iconCloseColor: WindiColor;
|
|
9
|
+
iconColor?: WindiColor;
|
|
10
|
+
iconChevronColor: WindiColor;
|
|
11
|
+
};
|
|
12
|
+
export declare const alertClasses: Record<AlertType, AlertClasses>;
|
|
13
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAE/D,oBAAY,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAA;AAE5E,oBAAY,YAAY,GAAG;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,cAAc,EAAE,UAAU,CAAA;IAC1B,SAAS,CAAC,EAAE,UAAU,CAAA;IACtB,gBAAgB,EAAE,UAAU,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,SAAS,EAAE,YAAY,CA6DxD,CAAA"}
|
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { defineComponent, ref, useSlots, computed, onMounted, onUnmounted, h, openBlock, createElementBlock, normalizeClass, createElementVNode, unref, createCommentVNode, renderSlot, normalizeProps, guardReactiveProps, createBlock, resolveDynamicComponent, mergeProps, createVNode, createTextVNode, toDisplayString } from 'vue';
|
|
2
|
+
import { IconWarningCircle, IconCheckmarkOutline, IconActionDeleteLarge, IconChevronDownSmall } from '@cypress-design/vue-icon';
|
|
3
|
+
|
|
4
|
+
const alertClasses = {
|
|
5
|
+
neutral: {
|
|
6
|
+
headerClass: 'text-gray-800 bg-gray-100',
|
|
7
|
+
bodyClass: 'bg-gray-50 text-gray-500',
|
|
8
|
+
borderClass: 'border-gray-100',
|
|
9
|
+
detailsHeaderClass: 'text-gray-600',
|
|
10
|
+
/* <windi-keep strokeColor="gray-600"/> */
|
|
11
|
+
iconCloseColor: 'gray-600',
|
|
12
|
+
/* <windi-keep strokeColor="gray-500"/> */
|
|
13
|
+
iconColor: 'gray-500',
|
|
14
|
+
/* <windi-keep strokeColor="gray-300"/> */
|
|
15
|
+
iconChevronColor: 'gray-300',
|
|
16
|
+
},
|
|
17
|
+
info: {
|
|
18
|
+
headerClass: 'text-indigo-700 bg-indigo-100',
|
|
19
|
+
bodyClass: 'bg-indigo-50 text-indigo-500',
|
|
20
|
+
borderClass: 'border-indigo-100',
|
|
21
|
+
detailsHeaderClass: 'text-indigo-600',
|
|
22
|
+
/* <windi-keep strokeColor="indigo-500"/> */
|
|
23
|
+
iconCloseColor: 'indigo-500',
|
|
24
|
+
/* <windi-keep strokeColor="indigo-500"/> */
|
|
25
|
+
iconColor: 'indigo-500',
|
|
26
|
+
/* <windi-keep strokeColor="indigo-300"/> */
|
|
27
|
+
iconChevronColor: 'indigo-300',
|
|
28
|
+
},
|
|
29
|
+
warning: {
|
|
30
|
+
headerClass: 'text-orange-700 bg-orange-100',
|
|
31
|
+
bodyClass: 'bg-orange-50 text-orange-500',
|
|
32
|
+
borderClass: 'border-orange-100',
|
|
33
|
+
detailsHeaderClass: 'text-orange-600',
|
|
34
|
+
/* <windi-keep strokeColor="orange-500"/> */
|
|
35
|
+
iconCloseColor: 'orange-500',
|
|
36
|
+
/* <windi-keep strokeColor="orange-400"/> */
|
|
37
|
+
iconColor: 'orange-400',
|
|
38
|
+
/* <windi-keep strokeColor="orange-300"/> */
|
|
39
|
+
iconChevronColor: 'orange-300',
|
|
40
|
+
},
|
|
41
|
+
error: {
|
|
42
|
+
headerClass: 'text-red-700 bg-red-100',
|
|
43
|
+
bodyClass: 'bg-red-50 text-red-500',
|
|
44
|
+
borderClass: 'border-red-100',
|
|
45
|
+
detailsHeaderClass: 'text-red-600',
|
|
46
|
+
/* <windi-keep strokeColor="red-500"/> */
|
|
47
|
+
iconCloseColor: 'red-500',
|
|
48
|
+
/* <windi-keep strokeColor="red-400"/> */
|
|
49
|
+
iconColor: 'red-400',
|
|
50
|
+
/* <windi-keep strokeColor="red-300"/> */
|
|
51
|
+
iconChevronColor: 'red-300',
|
|
52
|
+
},
|
|
53
|
+
success: {
|
|
54
|
+
headerClass: 'text-jade-700 bg-jade-100',
|
|
55
|
+
bodyClass: 'bg-jade-50 text-jade-600',
|
|
56
|
+
borderClass: 'border-jade-100',
|
|
57
|
+
detailsHeaderClass: 'text-jade-600',
|
|
58
|
+
/* <windi-keep strokeColor="jade-600"/> */
|
|
59
|
+
iconCloseColor: 'jade-600',
|
|
60
|
+
/* <windi-keep strokeColor="jade-500"/> */
|
|
61
|
+
iconColor: 'jade-500',
|
|
62
|
+
/* <windi-keep strokeColor="jade-300"/> */
|
|
63
|
+
iconChevronColor: 'jade-300',
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
function styleInject(css, ref) {
|
|
68
|
+
if ( ref === void 0 ) ref = {};
|
|
69
|
+
var insertAt = ref.insertAt;
|
|
70
|
+
|
|
71
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
72
|
+
|
|
73
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
74
|
+
var style = document.createElement('style');
|
|
75
|
+
style.type = 'text/css';
|
|
76
|
+
|
|
77
|
+
if (insertAt === 'top') {
|
|
78
|
+
if (head.firstChild) {
|
|
79
|
+
head.insertBefore(style, head.firstChild);
|
|
80
|
+
} else {
|
|
81
|
+
head.appendChild(style);
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
head.appendChild(style);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (style.styleSheet) {
|
|
88
|
+
style.styleSheet.cssText = css;
|
|
89
|
+
} else {
|
|
90
|
+
style.appendChild(document.createTextNode(css));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
var css_248z = "\ndetails summary .icon[data-v-836252c4] {\n transform: rotate(-90deg);\n}\ndetails[open] summary .icon[data-v-836252c4] {\n transform: rotate(0);\n}\n";
|
|
95
|
+
styleInject(css_248z);
|
|
96
|
+
|
|
97
|
+
var _export_sfc = (sfc, props) => {
|
|
98
|
+
const target = sfc.__vccOpts || sfc;
|
|
99
|
+
for (const [key, val] of props) {
|
|
100
|
+
target[key] = val;
|
|
101
|
+
}
|
|
102
|
+
return target;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const _hoisted_1 = { class: "flex-1 font-medium" };
|
|
106
|
+
const _hoisted_2 = { class: "mt-16px" };
|
|
107
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
108
|
+
__name: "Alert",
|
|
109
|
+
props: {
|
|
110
|
+
type: { type: null, required: false, default: "info" },
|
|
111
|
+
detailsTitle: { type: String, required: false, default: "Additional details" },
|
|
112
|
+
dismissible: { type: Boolean, required: false },
|
|
113
|
+
noIcon: { type: Boolean, required: false },
|
|
114
|
+
notRounded: { type: Boolean, required: false },
|
|
115
|
+
duration: { type: Number, required: false }
|
|
116
|
+
},
|
|
117
|
+
emits: ["dismiss"],
|
|
118
|
+
setup(__props, { emit }) {
|
|
119
|
+
const props = __props;
|
|
120
|
+
const dismissed = ref(false);
|
|
121
|
+
const slots = useSlots();
|
|
122
|
+
const typeClasses = computed(() => {
|
|
123
|
+
return alertClasses[props.type];
|
|
124
|
+
});
|
|
125
|
+
let timeout;
|
|
126
|
+
onMounted(() => {
|
|
127
|
+
if (props.duration) {
|
|
128
|
+
timeout = setTimeout(dismiss, props.duration);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
onUnmounted(() => {
|
|
132
|
+
if (timeout) {
|
|
133
|
+
clearTimeout(timeout);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
function dismiss() {
|
|
137
|
+
dismissed.value = true;
|
|
138
|
+
emit("dismiss");
|
|
139
|
+
if (timeout) {
|
|
140
|
+
clearTimeout(timeout);
|
|
141
|
+
timeout = void 0;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const computedIconProps = computed(() => {
|
|
145
|
+
return {
|
|
146
|
+
strokeColor: alertClasses[props.type].iconColor,
|
|
147
|
+
class: "my-4px mr-8px"
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
const icon = computed(() => {
|
|
151
|
+
switch (props.type) {
|
|
152
|
+
case "info":
|
|
153
|
+
return null;
|
|
154
|
+
case "success":
|
|
155
|
+
return () => h(IconCheckmarkOutline, computedIconProps.value);
|
|
156
|
+
case "warning":
|
|
157
|
+
return () => h(IconWarningCircle, computedIconProps.value);
|
|
158
|
+
case "error":
|
|
159
|
+
return () => h(IconWarningCircle, computedIconProps.value);
|
|
160
|
+
default:
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
return (_ctx, _cache) => {
|
|
165
|
+
return !dismissed.value ? (openBlock(), createElementBlock("div", {
|
|
166
|
+
key: 0,
|
|
167
|
+
class: normalizeClass(["overflow-hidden text-left", props.notRounded ? void 0 : "rounded"])
|
|
168
|
+
}, [
|
|
169
|
+
createElementVNode("div", {
|
|
170
|
+
class: normalizeClass(["flex p-16px", unref(typeClasses).headerClass])
|
|
171
|
+
}, [
|
|
172
|
+
createCommentVNode(" @slot replace the default left icon here "),
|
|
173
|
+
renderSlot(_ctx.$slots, "icon", normalizeProps(guardReactiveProps(unref(computedIconProps))), () => [
|
|
174
|
+
!props.noIcon && unref(icon) ? (openBlock(), createBlock(resolveDynamicComponent(unref(icon)), normalizeProps(mergeProps({ key: 0 }, unref(computedIconProps))), null, 16)) : createCommentVNode("v-if", true)
|
|
175
|
+
], true),
|
|
176
|
+
createElementVNode("div", _hoisted_1, [
|
|
177
|
+
createCommentVNode(" @slot title of the alert "),
|
|
178
|
+
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
179
|
+
]),
|
|
180
|
+
__props.dismissible ? (openBlock(), createElementBlock("button", {
|
|
181
|
+
key: 0,
|
|
182
|
+
class: "m-4px ml-8px h-16px",
|
|
183
|
+
onClick: dismiss,
|
|
184
|
+
"aria-label": "Dismiss"
|
|
185
|
+
}, [
|
|
186
|
+
createVNode(unref(IconActionDeleteLarge), {
|
|
187
|
+
"stroke-color": unref(typeClasses).iconCloseColor
|
|
188
|
+
}, null, 8, ["stroke-color"])
|
|
189
|
+
])) : createCommentVNode("v-if", true)
|
|
190
|
+
], 2),
|
|
191
|
+
unref(slots).body ? (openBlock(), createElementBlock("div", {
|
|
192
|
+
key: 0,
|
|
193
|
+
class: normalizeClass(["p-16px", unref(typeClasses).bodyClass])
|
|
194
|
+
}, [
|
|
195
|
+
createCommentVNode(" @slot body/details of the alert "),
|
|
196
|
+
renderSlot(_ctx.$slots, "body", {}, void 0, true)
|
|
197
|
+
], 2)) : createCommentVNode("v-if", true),
|
|
198
|
+
unref(slots).details ? (openBlock(), createElementBlock("details", {
|
|
199
|
+
key: 1,
|
|
200
|
+
class: normalizeClass(["p-16px border-t-1", [unref(typeClasses).bodyClass, unref(typeClasses).borderClass]])
|
|
201
|
+
}, [
|
|
202
|
+
createElementVNode("summary", {
|
|
203
|
+
class: normalizeClass(["flex font-medium cursor-pointer", unref(typeClasses).detailsHeaderClass])
|
|
204
|
+
}, [
|
|
205
|
+
createVNode(unref(IconChevronDownSmall), {
|
|
206
|
+
strokeColor: unref(typeClasses).iconChevronColor,
|
|
207
|
+
class: "icon my-4px mr-8px"
|
|
208
|
+
}, null, 8, ["strokeColor"]),
|
|
209
|
+
createTextVNode(" " + toDisplayString(props.detailsTitle), 1)
|
|
210
|
+
], 2),
|
|
211
|
+
createElementVNode("div", _hoisted_2, [
|
|
212
|
+
createCommentVNode("@slot Togglable additional details"),
|
|
213
|
+
renderSlot(_ctx.$slots, "details", {}, void 0, true)
|
|
214
|
+
])
|
|
215
|
+
], 2)) : createCommentVNode("v-if", true)
|
|
216
|
+
], 2)) : createCommentVNode("v-if", true);
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
var Alert = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-836252c4"], ["__file", "/home/runner/work/cypress-design/cypress-design/components/Alert/vue/Alert.vue"]]);
|
|
221
|
+
|
|
222
|
+
export { Alert as default };
|
|
223
|
+
//# sourceMappingURL=index.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../../../constants.ts","../../../../node_modules/style-inject/dist/style-inject.es.js","../plugin-vue:export-helper","../Alert.vue"],"sourcesContent":[null,"function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","\nexport default (sfc, props) => {\n const target = sfc.__vccOpts || sfc;\n for (const [key, val] of props) {\n target[key] = val;\n }\n return target;\n}\n","<template>\n <div v-if=\"!dismissed\" class=\"overflow-hidden text-left\" :class=\"props.notRounded ? undefined : 'rounded'\">\n <div class=\"flex p-16px\" :class=\"typeClasses.headerClass\">\n <!-- @slot replace the default left icon here -->\n <slot name=\"icon\" v-bind=\"computedIconProps\">\n <component v-if=\"!props.noIcon && icon\" :is=\"icon\" v-bind=\"computedIconProps\" />\n </slot>\n <div class=\"flex-1 font-medium\">\n <!-- @slot title of the alert -->\n <slot />\n </div>\n <button v-if=\"dismissible\" class=\"m-4px ml-8px h-16px\" @click=\"dismiss\" aria-label=\"Dismiss\">\n <IconActionDeleteLarge :stroke-color=\"typeClasses.iconCloseColor\" />\n </button>\n </div>\n <div v-if=\"slots.body\" class=\"p-16px\" :class=\"typeClasses.bodyClass\">\n <!-- @slot body/details of the alert -->\n <slot name=\"body\" />\n </div>\n <details v-if=\"slots.details\" class=\"p-16px border-t-1\" :class=\"[typeClasses.bodyClass, typeClasses.borderClass]\">\n <summary class=\"flex font-medium cursor-pointer\" :class=\"typeClasses.detailsHeaderClass\">\n <IconChevronDownSmall :strokeColor=\"typeClasses.iconChevronColor\" class=\"icon my-4px mr-8px\" />\n {{ props.detailsTitle }}\n </summary>\n <div class=\"mt-16px\">\n <!--@slot Togglable additional details-->\n <slot name=\"details\" />\n </div>\n </details>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, useSlots, h, type FunctionalComponent, ref, onMounted, onUnmounted, type ComputedRef } from 'vue'\nimport {\n IconChevronDownSmall, IconActionDeleteLarge,\n IconWarningCircle, IconCheckmarkOutline,\n} from '@cypress-design/vue-icon'\nimport type { AlertType } from '../constants'\nimport { alertClasses } from '../constants'\n\nconst dismissed = ref(false)\n\nconst slots = useSlots()\n\nconst emit = defineEmits<{\n /**\n * Clicking on the dismiss button or dismissed after a timeout\n */\n (event: 'dismiss'): void,\n}>()\n\nconst props = withDefaults(defineProps<{\n /**\n * Color scheme\n */\n type?: AlertType\n /**\n * If details are provided,text used in the toggle button\n */\n detailsTitle?: string\n /**\n * Show the dismiss button\n */\n dismissible?: boolean\n /**\n * When an icon is displayed by default, use this to remove it\n */\n noIcon?: boolean\n /**\n * If you need square corners\n */\n notRounded?: boolean\n /**\n * Dismiss the alert after a delay (in ms)\n */\n duration?: number\n}>(), {\n type: 'info',\n detailsTitle: 'Additional details',\n})\n\nconst typeClasses = computed(() => {\n return alertClasses[props.type]\n})\n\nlet timeout: number | undefined\n\nonMounted(() => {\n if (props.duration) {\n timeout = setTimeout(dismiss, props.duration) as any\n }\n})\n\nonUnmounted(() => {\n if (timeout) {\n clearTimeout(timeout)\n }\n})\n\nfunction dismiss() {\n dismissed.value = true\n emit('dismiss')\n if (timeout) {\n clearTimeout(timeout)\n timeout = undefined\n }\n}\n\nconst computedIconProps = computed(() => {\n return {\n strokeColor: alertClasses[props.type].iconColor,\n class: 'my-4px mr-8px'\n }\n})\n\nconst icon: ComputedRef<FunctionalComponent | null> = computed(() => {\n switch (props.type) {\n case 'info':\n return null;\n case 'success':\n return () => h(IconCheckmarkOutline, computedIconProps.value)\n case 'warning':\n return () => h(IconWarningCircle, computedIconProps.value)\n case 'error':\n return () => h(IconWarningCircle, computedIconProps.value)\n default:\n return null;\n }\n})\n\n</script>\n\n<style scoped>\ndetails summary .icon {\n transform: rotate(-90deg);\n}\n\ndetails[open] summary .icon {\n transform: rotate(0);\n}\n</style>\n"],"names":[],"mappings":";;;AAcO,MAAM,YAAY,GAAoC;AAC3D,IAAA,OAAO,EAAE;AACP,QAAA,WAAW,EAAE,2BAA2B;AACxC,QAAA,SAAS,EAAE,0BAA0B;AACrC,QAAA,WAAW,EAAE,iBAAiB;AAC9B,QAAA,kBAAkB,EAAE,eAAe;;AAEnC,QAAA,cAAc,EAAE,UAAU;;AAE1B,QAAA,SAAS,EAAE,UAAU;;AAErB,QAAA,gBAAgB,EAAE,UAAU;AAC7B,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,WAAW,EAAE,+BAA+B;AAC5C,QA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,OAAO,MAAM,CAAA,CAAE,iBAAmB,EAAA,iBAAA,CAAkB,KAAK,CAAA,CAAA;AAAA,QACtD,KAAA,OAAA;AACH,UAAA,OAAO,MAAM,CAAA,CAAE,iBAAmB,EAAA,iBAAA,CAAkB,KAAK,CAAA,CAAA;AAAA,QAAA;AAEzD,UAAO,OAAA,IAAA,CAAA;AAAA,OAAA;AAAA,KAEZ,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var vue = require('vue');
|
|
4
|
+
var vueIcon = require('@cypress-design/vue-icon');
|
|
5
|
+
|
|
6
|
+
const alertClasses = {
|
|
7
|
+
neutral: {
|
|
8
|
+
headerClass: 'text-gray-800 bg-gray-100',
|
|
9
|
+
bodyClass: 'bg-gray-50 text-gray-500',
|
|
10
|
+
borderClass: 'border-gray-100',
|
|
11
|
+
detailsHeaderClass: 'text-gray-600',
|
|
12
|
+
/* <windi-keep strokeColor="gray-600"/> */
|
|
13
|
+
iconCloseColor: 'gray-600',
|
|
14
|
+
/* <windi-keep strokeColor="gray-500"/> */
|
|
15
|
+
iconColor: 'gray-500',
|
|
16
|
+
/* <windi-keep strokeColor="gray-300"/> */
|
|
17
|
+
iconChevronColor: 'gray-300',
|
|
18
|
+
},
|
|
19
|
+
info: {
|
|
20
|
+
headerClass: 'text-indigo-700 bg-indigo-100',
|
|
21
|
+
bodyClass: 'bg-indigo-50 text-indigo-500',
|
|
22
|
+
borderClass: 'border-indigo-100',
|
|
23
|
+
detailsHeaderClass: 'text-indigo-600',
|
|
24
|
+
/* <windi-keep strokeColor="indigo-500"/> */
|
|
25
|
+
iconCloseColor: 'indigo-500',
|
|
26
|
+
/* <windi-keep strokeColor="indigo-500"/> */
|
|
27
|
+
iconColor: 'indigo-500',
|
|
28
|
+
/* <windi-keep strokeColor="indigo-300"/> */
|
|
29
|
+
iconChevronColor: 'indigo-300',
|
|
30
|
+
},
|
|
31
|
+
warning: {
|
|
32
|
+
headerClass: 'text-orange-700 bg-orange-100',
|
|
33
|
+
bodyClass: 'bg-orange-50 text-orange-500',
|
|
34
|
+
borderClass: 'border-orange-100',
|
|
35
|
+
detailsHeaderClass: 'text-orange-600',
|
|
36
|
+
/* <windi-keep strokeColor="orange-500"/> */
|
|
37
|
+
iconCloseColor: 'orange-500',
|
|
38
|
+
/* <windi-keep strokeColor="orange-400"/> */
|
|
39
|
+
iconColor: 'orange-400',
|
|
40
|
+
/* <windi-keep strokeColor="orange-300"/> */
|
|
41
|
+
iconChevronColor: 'orange-300',
|
|
42
|
+
},
|
|
43
|
+
error: {
|
|
44
|
+
headerClass: 'text-red-700 bg-red-100',
|
|
45
|
+
bodyClass: 'bg-red-50 text-red-500',
|
|
46
|
+
borderClass: 'border-red-100',
|
|
47
|
+
detailsHeaderClass: 'text-red-600',
|
|
48
|
+
/* <windi-keep strokeColor="red-500"/> */
|
|
49
|
+
iconCloseColor: 'red-500',
|
|
50
|
+
/* <windi-keep strokeColor="red-400"/> */
|
|
51
|
+
iconColor: 'red-400',
|
|
52
|
+
/* <windi-keep strokeColor="red-300"/> */
|
|
53
|
+
iconChevronColor: 'red-300',
|
|
54
|
+
},
|
|
55
|
+
success: {
|
|
56
|
+
headerClass: 'text-jade-700 bg-jade-100',
|
|
57
|
+
bodyClass: 'bg-jade-50 text-jade-600',
|
|
58
|
+
borderClass: 'border-jade-100',
|
|
59
|
+
detailsHeaderClass: 'text-jade-600',
|
|
60
|
+
/* <windi-keep strokeColor="jade-600"/> */
|
|
61
|
+
iconCloseColor: 'jade-600',
|
|
62
|
+
/* <windi-keep strokeColor="jade-500"/> */
|
|
63
|
+
iconColor: 'jade-500',
|
|
64
|
+
/* <windi-keep strokeColor="jade-300"/> */
|
|
65
|
+
iconChevronColor: 'jade-300',
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
function styleInject(css, ref) {
|
|
70
|
+
if ( ref === void 0 ) ref = {};
|
|
71
|
+
var insertAt = ref.insertAt;
|
|
72
|
+
|
|
73
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
74
|
+
|
|
75
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
76
|
+
var style = document.createElement('style');
|
|
77
|
+
style.type = 'text/css';
|
|
78
|
+
|
|
79
|
+
if (insertAt === 'top') {
|
|
80
|
+
if (head.firstChild) {
|
|
81
|
+
head.insertBefore(style, head.firstChild);
|
|
82
|
+
} else {
|
|
83
|
+
head.appendChild(style);
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
head.appendChild(style);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (style.styleSheet) {
|
|
90
|
+
style.styleSheet.cssText = css;
|
|
91
|
+
} else {
|
|
92
|
+
style.appendChild(document.createTextNode(css));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var css_248z = "\ndetails summary .icon[data-v-836252c4] {\n transform: rotate(-90deg);\n}\ndetails[open] summary .icon[data-v-836252c4] {\n transform: rotate(0);\n}\n";
|
|
97
|
+
styleInject(css_248z);
|
|
98
|
+
|
|
99
|
+
var _export_sfc = (sfc, props) => {
|
|
100
|
+
const target = sfc.__vccOpts || sfc;
|
|
101
|
+
for (const [key, val] of props) {
|
|
102
|
+
target[key] = val;
|
|
103
|
+
}
|
|
104
|
+
return target;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const _hoisted_1 = { class: "flex-1 font-medium" };
|
|
108
|
+
const _hoisted_2 = { class: "mt-16px" };
|
|
109
|
+
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
110
|
+
__name: "Alert",
|
|
111
|
+
props: {
|
|
112
|
+
type: { type: null, required: false, default: "info" },
|
|
113
|
+
detailsTitle: { type: String, required: false, default: "Additional details" },
|
|
114
|
+
dismissible: { type: Boolean, required: false },
|
|
115
|
+
noIcon: { type: Boolean, required: false },
|
|
116
|
+
notRounded: { type: Boolean, required: false },
|
|
117
|
+
duration: { type: Number, required: false }
|
|
118
|
+
},
|
|
119
|
+
emits: ["dismiss"],
|
|
120
|
+
setup(__props, { emit }) {
|
|
121
|
+
const props = __props;
|
|
122
|
+
const dismissed = vue.ref(false);
|
|
123
|
+
const slots = vue.useSlots();
|
|
124
|
+
const typeClasses = vue.computed(() => {
|
|
125
|
+
return alertClasses[props.type];
|
|
126
|
+
});
|
|
127
|
+
let timeout;
|
|
128
|
+
vue.onMounted(() => {
|
|
129
|
+
if (props.duration) {
|
|
130
|
+
timeout = setTimeout(dismiss, props.duration);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
vue.onUnmounted(() => {
|
|
134
|
+
if (timeout) {
|
|
135
|
+
clearTimeout(timeout);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
function dismiss() {
|
|
139
|
+
dismissed.value = true;
|
|
140
|
+
emit("dismiss");
|
|
141
|
+
if (timeout) {
|
|
142
|
+
clearTimeout(timeout);
|
|
143
|
+
timeout = void 0;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
const computedIconProps = vue.computed(() => {
|
|
147
|
+
return {
|
|
148
|
+
strokeColor: alertClasses[props.type].iconColor,
|
|
149
|
+
class: "my-4px mr-8px"
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
const icon = vue.computed(() => {
|
|
153
|
+
switch (props.type) {
|
|
154
|
+
case "info":
|
|
155
|
+
return null;
|
|
156
|
+
case "success":
|
|
157
|
+
return () => vue.h(vueIcon.IconCheckmarkOutline, computedIconProps.value);
|
|
158
|
+
case "warning":
|
|
159
|
+
return () => vue.h(vueIcon.IconWarningCircle, computedIconProps.value);
|
|
160
|
+
case "error":
|
|
161
|
+
return () => vue.h(vueIcon.IconWarningCircle, computedIconProps.value);
|
|
162
|
+
default:
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
return (_ctx, _cache) => {
|
|
167
|
+
return !dismissed.value ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
168
|
+
key: 0,
|
|
169
|
+
class: vue.normalizeClass(["overflow-hidden text-left", props.notRounded ? void 0 : "rounded"])
|
|
170
|
+
}, [
|
|
171
|
+
vue.createElementVNode("div", {
|
|
172
|
+
class: vue.normalizeClass(["flex p-16px", vue.unref(typeClasses).headerClass])
|
|
173
|
+
}, [
|
|
174
|
+
vue.createCommentVNode(" @slot replace the default left icon here "),
|
|
175
|
+
vue.renderSlot(_ctx.$slots, "icon", vue.normalizeProps(vue.guardReactiveProps(vue.unref(computedIconProps))), () => [
|
|
176
|
+
!props.noIcon && vue.unref(icon) ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(icon)), vue.normalizeProps(vue.mergeProps({ key: 0 }, vue.unref(computedIconProps))), null, 16)) : vue.createCommentVNode("v-if", true)
|
|
177
|
+
], true),
|
|
178
|
+
vue.createElementVNode("div", _hoisted_1, [
|
|
179
|
+
vue.createCommentVNode(" @slot title of the alert "),
|
|
180
|
+
vue.renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
181
|
+
]),
|
|
182
|
+
__props.dismissible ? (vue.openBlock(), vue.createElementBlock("button", {
|
|
183
|
+
key: 0,
|
|
184
|
+
class: "m-4px ml-8px h-16px",
|
|
185
|
+
onClick: dismiss,
|
|
186
|
+
"aria-label": "Dismiss"
|
|
187
|
+
}, [
|
|
188
|
+
vue.createVNode(vue.unref(vueIcon.IconActionDeleteLarge), {
|
|
189
|
+
"stroke-color": vue.unref(typeClasses).iconCloseColor
|
|
190
|
+
}, null, 8, ["stroke-color"])
|
|
191
|
+
])) : vue.createCommentVNode("v-if", true)
|
|
192
|
+
], 2),
|
|
193
|
+
vue.unref(slots).body ? (vue.openBlock(), vue.createElementBlock("div", {
|
|
194
|
+
key: 0,
|
|
195
|
+
class: vue.normalizeClass(["p-16px", vue.unref(typeClasses).bodyClass])
|
|
196
|
+
}, [
|
|
197
|
+
vue.createCommentVNode(" @slot body/details of the alert "),
|
|
198
|
+
vue.renderSlot(_ctx.$slots, "body", {}, void 0, true)
|
|
199
|
+
], 2)) : vue.createCommentVNode("v-if", true),
|
|
200
|
+
vue.unref(slots).details ? (vue.openBlock(), vue.createElementBlock("details", {
|
|
201
|
+
key: 1,
|
|
202
|
+
class: vue.normalizeClass(["p-16px border-t-1", [vue.unref(typeClasses).bodyClass, vue.unref(typeClasses).borderClass]])
|
|
203
|
+
}, [
|
|
204
|
+
vue.createElementVNode("summary", {
|
|
205
|
+
class: vue.normalizeClass(["flex font-medium cursor-pointer", vue.unref(typeClasses).detailsHeaderClass])
|
|
206
|
+
}, [
|
|
207
|
+
vue.createVNode(vue.unref(vueIcon.IconChevronDownSmall), {
|
|
208
|
+
strokeColor: vue.unref(typeClasses).iconChevronColor,
|
|
209
|
+
class: "icon my-4px mr-8px"
|
|
210
|
+
}, null, 8, ["strokeColor"]),
|
|
211
|
+
vue.createTextVNode(" " + vue.toDisplayString(props.detailsTitle), 1)
|
|
212
|
+
], 2),
|
|
213
|
+
vue.createElementVNode("div", _hoisted_2, [
|
|
214
|
+
vue.createCommentVNode("@slot Togglable additional details"),
|
|
215
|
+
vue.renderSlot(_ctx.$slots, "details", {}, void 0, true)
|
|
216
|
+
])
|
|
217
|
+
], 2)) : vue.createCommentVNode("v-if", true)
|
|
218
|
+
], 2)) : vue.createCommentVNode("v-if", true);
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
var Alert = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-836252c4"], ["__file", "/home/runner/work/cypress-design/cypress-design/components/Alert/vue/Alert.vue"]]);
|
|
223
|
+
|
|
224
|
+
module.exports = Alert;
|
|
225
|
+
//# sourceMappingURL=index.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../../../../constants.ts","../../../../node_modules/style-inject/dist/style-inject.es.js","../plugin-vue:export-helper","../Alert.vue"],"sourcesContent":[null,"function styleInject(css, ref) {\n if ( ref === void 0 ) ref = {};\n var insertAt = ref.insertAt;\n\n if (!css || typeof document === 'undefined') { return; }\n\n var head = document.head || document.getElementsByTagName('head')[0];\n var style = document.createElement('style');\n style.type = 'text/css';\n\n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild);\n } else {\n head.appendChild(style);\n }\n } else {\n head.appendChild(style);\n }\n\n if (style.styleSheet) {\n style.styleSheet.cssText = css;\n } else {\n style.appendChild(document.createTextNode(css));\n }\n}\n\nexport default styleInject;\n","\nexport default (sfc, props) => {\n const target = sfc.__vccOpts || sfc;\n for (const [key, val] of props) {\n target[key] = val;\n }\n return target;\n}\n","<template>\n <div v-if=\"!dismissed\" class=\"overflow-hidden text-left\" :class=\"props.notRounded ? undefined : 'rounded'\">\n <div class=\"flex p-16px\" :class=\"typeClasses.headerClass\">\n <!-- @slot replace the default left icon here -->\n <slot name=\"icon\" v-bind=\"computedIconProps\">\n <component v-if=\"!props.noIcon && icon\" :is=\"icon\" v-bind=\"computedIconProps\" />\n </slot>\n <div class=\"flex-1 font-medium\">\n <!-- @slot title of the alert -->\n <slot />\n </div>\n <button v-if=\"dismissible\" class=\"m-4px ml-8px h-16px\" @click=\"dismiss\" aria-label=\"Dismiss\">\n <IconActionDeleteLarge :stroke-color=\"typeClasses.iconCloseColor\" />\n </button>\n </div>\n <div v-if=\"slots.body\" class=\"p-16px\" :class=\"typeClasses.bodyClass\">\n <!-- @slot body/details of the alert -->\n <slot name=\"body\" />\n </div>\n <details v-if=\"slots.details\" class=\"p-16px border-t-1\" :class=\"[typeClasses.bodyClass, typeClasses.borderClass]\">\n <summary class=\"flex font-medium cursor-pointer\" :class=\"typeClasses.detailsHeaderClass\">\n <IconChevronDownSmall :strokeColor=\"typeClasses.iconChevronColor\" class=\"icon my-4px mr-8px\" />\n {{ props.detailsTitle }}\n </summary>\n <div class=\"mt-16px\">\n <!--@slot Togglable additional details-->\n <slot name=\"details\" />\n </div>\n </details>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { computed, useSlots, h, type FunctionalComponent, ref, onMounted, onUnmounted, type ComputedRef } from 'vue'\nimport {\n IconChevronDownSmall, IconActionDeleteLarge,\n IconWarningCircle, IconCheckmarkOutline,\n} from '@cypress-design/vue-icon'\nimport type { AlertType } from '../constants'\nimport { alertClasses } from '../constants'\n\nconst dismissed = ref(false)\n\nconst slots = useSlots()\n\nconst emit = defineEmits<{\n /**\n * Clicking on the dismiss button or dismissed after a timeout\n */\n (event: 'dismiss'): void,\n}>()\n\nconst props = withDefaults(defineProps<{\n /**\n * Color scheme\n */\n type?: AlertType\n /**\n * If details are provided,text used in the toggle button\n */\n detailsTitle?: string\n /**\n * Show the dismiss button\n */\n dismissible?: boolean\n /**\n * When an icon is displayed by default, use this to remove it\n */\n noIcon?: boolean\n /**\n * If you need square corners\n */\n notRounded?: boolean\n /**\n * Dismiss the alert after a delay (in ms)\n */\n duration?: number\n}>(), {\n type: 'info',\n detailsTitle: 'Additional details',\n})\n\nconst typeClasses = computed(() => {\n return alertClasses[props.type]\n})\n\nlet timeout: number | undefined\n\nonMounted(() => {\n if (props.duration) {\n timeout = setTimeout(dismiss, props.duration) as any\n }\n})\n\nonUnmounted(() => {\n if (timeout) {\n clearTimeout(timeout)\n }\n})\n\nfunction dismiss() {\n dismissed.value = true\n emit('dismiss')\n if (timeout) {\n clearTimeout(timeout)\n timeout = undefined\n }\n}\n\nconst computedIconProps = computed(() => {\n return {\n strokeColor: alertClasses[props.type].iconColor,\n class: 'my-4px mr-8px'\n }\n})\n\nconst icon: ComputedRef<FunctionalComponent | null> = computed(() => {\n switch (props.type) {\n case 'info':\n return null;\n case 'success':\n return () => h(IconCheckmarkOutline, computedIconProps.value)\n case 'warning':\n return () => h(IconWarningCircle, computedIconProps.value)\n case 'error':\n return () => h(IconWarningCircle, computedIconProps.value)\n default:\n return null;\n }\n})\n\n</script>\n\n<style scoped>\ndetails summary .icon {\n transform: rotate(-90deg);\n}\n\ndetails[open] summary .icon {\n transform: rotate(0);\n}\n</style>\n"],"names":["ref","useSlots","computed","onMounted","onUnmounted","h","IconCheckmarkOutline","IconWarningCircle"],"mappings":";;;;;AAcO,MAAM,YAAY,GAAoC;AAC3D,IAAA,OAAO,EAAE;AACP,QAAA,WAAW,EAAE,2BAA2B;AACxC,QAAA,SAAS,EAAE,0BAA0B;AACrC,QAAA,WAAW,EAAE,iBAAiB;AAC9B,QAAA,kBAAkB,EAAE,eAAe;;AAEnC,QAAA,cAAc,EAAE,UAAU;;AAE1B,QAAA,SAAS,EAAE,UAAU;;AAErB,QAAA,gBAAgB,EAAE,UAAU;AAC7B,KAAA;AACD,IAAA,IAAI,EAAE;AACJ,QAAA,WAAW,EAAE,+BAA+B;AAC5C,QAAA,SAAS,EAAE,8BAA8B;AACzC,QAAA,WAAW,EAAE,mBAAmB;AAChC,QAAA,kBAAkB,EAAE,iBAAiB;;AAErC,QAAA,cAAc,EAAE,YAAY;;AAE5B,QAAA,SAAS,EAAE,YAAY;;AAEvB,QAAA,gBAAgB,EAAE,YAAY;AAC/B,KAAA;AACD,IAAA,OAAO,EAAE;AACP,QAAA,WAAW,EAAE,+BAA+B;AAC5C,QAAA,SAAS,EAAE,8BAA8B;AACzC,QAAA,WAAW,EAAE,mBAAmB;AAChC,QAAA,kBAAkB,EAAE,iBAAiB;;AAErC,QAAA,cAAc,EAAE,YAAY;;AAE5B,QAAA,SAAS,EAAE,YAAY;;AAEvB,QAAA,gBAAgB,EAAE,YAAY;AAC/B,KAAA;AACD,IAAA,KAAK,EAAE;AACL,QAAA,WAAW,EAAE,yBAAyB;AACtC,QAAA,SAAS,EAAE,wBAAwB;AACnC,QAAA,WAAW,EAAE,gBAAgB;AAC7B,QAAA,kBAAkB,EAAE,cAAc;;AAElC,QAAA,cAAc,EAAE,SAAS;;AAEzB,QAAA,SAAS,EAAE,SAAS;;AAEpB,QAAA,gBAAgB,E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AAA,GAAA,KAAA,CAAA,CAAA;AAAA,OACZ;AAAA,KACF;AAEA,IAAM,MAAA,iBAAA,GAAoBF,aAAS,MAAM;AACvC,MAAO,OAAA;AAAA,QACL,WAAA,EAAa,YAAa,CAAA,KAAA,CAAM,IAAM,CAAA,CAAA,SAAA;AAAA,QACtC,KAAO,EAAA,eAAA;AAAA,OACT,CAAA;AAAA,KACD,CAAA,CAAA;AAED,IAAM,MAAA,IAAA,GAAgDA,aAAS,MAAM;AACnE,MAAA,QAAQ,KAAM,CAAA,IAAA;AAAA,QACP,KAAA,MAAA;AACH,UAAO,OAAA,IAAA,CAAA;AAAA,QACJ,KAAA,SAAA;AACH,UAAA,OAAO,MAAMG,KAAA,CAAEC,4BAAsB,EAAA,iBAAA,CAAkB,KAAK,CAAA,CAAA;AAAA,QACzD,KAAA,SAAA;AACH,UAAA,OAAO,MAAMD,KAAA,CAAEE,yBAAmB,EAAA,iBAAA,CAAkB,KAAK,CAAA,CAAA;AAAA,QACtD,KAAA,OAAA;AACH,UAAA,OAAO,MAAMF,KAAA,CAAEE,yBAAmB,EAAA,iBAAA,CAAkB,KAAK,CAAA,CAAA;AAAA,QAAA;AAEzD,UAAO,OAAA,IAAA,CAAA;AAAA,OAAA;AAAA,KAEZ,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { AlertType } from '../constants';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
3
|
+
/**
|
|
4
|
+
* Color scheme
|
|
5
|
+
*/
|
|
6
|
+
type?: AlertType | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* If details are provided,text used in the toggle button
|
|
9
|
+
*/
|
|
10
|
+
detailsTitle?: string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Show the dismiss button
|
|
13
|
+
*/
|
|
14
|
+
dismissible?: boolean | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* When an icon is displayed by default, use this to remove it
|
|
17
|
+
*/
|
|
18
|
+
noIcon?: boolean | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* If you need square corners
|
|
21
|
+
*/
|
|
22
|
+
notRounded?: boolean | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Dismiss the alert after a delay (in ms)
|
|
25
|
+
*/
|
|
26
|
+
duration?: number | undefined;
|
|
27
|
+
}>, {
|
|
28
|
+
type: string;
|
|
29
|
+
detailsTitle: string;
|
|
30
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
31
|
+
dismiss: () => void;
|
|
32
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
33
|
+
/**
|
|
34
|
+
* Color scheme
|
|
35
|
+
*/
|
|
36
|
+
type?: AlertType | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* If details are provided,text used in the toggle button
|
|
39
|
+
*/
|
|
40
|
+
detailsTitle?: string | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Show the dismiss button
|
|
43
|
+
*/
|
|
44
|
+
dismissible?: boolean | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* When an icon is displayed by default, use this to remove it
|
|
47
|
+
*/
|
|
48
|
+
noIcon?: boolean | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* If you need square corners
|
|
51
|
+
*/
|
|
52
|
+
notRounded?: boolean | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Dismiss the alert after a delay (in ms)
|
|
55
|
+
*/
|
|
56
|
+
duration?: number | undefined;
|
|
57
|
+
}>, {
|
|
58
|
+
type: string;
|
|
59
|
+
detailsTitle: string;
|
|
60
|
+
}>>> & {
|
|
61
|
+
onDismiss?: (() => any) | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
type: AlertType;
|
|
64
|
+
detailsTitle: string;
|
|
65
|
+
}>;
|
|
66
|
+
export default _default;
|
|
67
|
+
declare type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
68
|
+
declare type __VLS_TypePropsToRuntimeProps<T> = {
|
|
69
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
70
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
71
|
+
} : {
|
|
72
|
+
type: import('vue').PropType<T[K]>;
|
|
73
|
+
required: true;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
declare type __VLS_WithDefaults<P, D> = {
|
|
77
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? P[K] & {
|
|
78
|
+
default: D[K];
|
|
79
|
+
} : P[K];
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=Alert.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Alert.vue.d.ts","sourceRoot":"","sources":["../../Alert.vue.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;;IAoG3C;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;;;;;;;IAtBH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;OAEG;;;;;;;;UAnBI,SAAS;kBAID,MAAM;;AAxGvB,wBA+MK;AACL,aAAK,sBAAsB,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,GAAG,KAAK,GAAG,CAAC,CAAC;AACjE,aAAK,6BAA6B,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,SAAS,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,OAAO,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE;CAAE,CAAC;AAC9M,aAAK,kBAAkB,CAAC,CAAC,EAAE,CAAC,IAAI;KAE5B,CAAC,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG;QACzD,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;KACb,GAAG,CAAC,CAAC,CAAC,CAAC;CACR,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA"}
|
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './Alert.vue'
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cypress-design/vue-alert",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"files": [
|
|
5
|
+
"*"
|
|
6
|
+
],
|
|
7
|
+
"typings": "./dist/vue/index.d.ts",
|
|
8
|
+
"main": "./dist/index.umd.js",
|
|
9
|
+
"module": "./dist/index.es.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.es.js",
|
|
13
|
+
"require": "./dist/index.umd.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "yarn build:module && yarn build:types",
|
|
18
|
+
"build:module": "rollup -c ./rollup.config.js",
|
|
19
|
+
"build:types": "vue-tsc --project ./tsconfig.build.json"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@cypress-design/vue-icon": "*"
|
|
23
|
+
},
|
|
24
|
+
"license": "MIT"
|
|
25
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import commonjs from '@rollup/plugin-commonjs'
|
|
2
|
+
import resolve from '@rollup/plugin-node-resolve'
|
|
3
|
+
import typescript from '@rollup/plugin-typescript'
|
|
4
|
+
import vue from '@vitejs/plugin-vue'
|
|
5
|
+
import postcss from 'rollup-plugin-postcss'
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
input: './index.ts',
|
|
9
|
+
output: [
|
|
10
|
+
{
|
|
11
|
+
file: './dist/index.umd.js',
|
|
12
|
+
format: 'cjs',
|
|
13
|
+
exports: 'auto',
|
|
14
|
+
sourcemap: true,
|
|
15
|
+
sourcemapPathTransform: (sourcePath) =>
|
|
16
|
+
sourcePath.includes('node_modules')
|
|
17
|
+
? sourcePath
|
|
18
|
+
: sourcePath.replace(/^\.\.\/\.\.\/(\w)/, `../../vue/$1`),
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
file: './dist/index.es.js',
|
|
22
|
+
format: 'esm',
|
|
23
|
+
sourcemap: true,
|
|
24
|
+
sourcemapPathTransform: (sourcePath) =>
|
|
25
|
+
sourcePath.includes('node_modules')
|
|
26
|
+
? sourcePath
|
|
27
|
+
: sourcePath.replace(/^\.\.\/\.\.\/(\w)/, `../../vue/$1`),
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
plugins: [
|
|
31
|
+
resolve(),
|
|
32
|
+
commonjs(),
|
|
33
|
+
vue(),
|
|
34
|
+
postcss(),
|
|
35
|
+
typescript({
|
|
36
|
+
tsconfig: './tsconfig.build.json',
|
|
37
|
+
include: ['./*.ts', '../*.ts', './*.vue'],
|
|
38
|
+
declaration: false,
|
|
39
|
+
declarationMap: false,
|
|
40
|
+
sourceMap: true,
|
|
41
|
+
}),
|
|
42
|
+
],
|
|
43
|
+
external: [
|
|
44
|
+
'vue',
|
|
45
|
+
'@cypress-design/icon-registry',
|
|
46
|
+
'@cypress-design/vue-icon',
|
|
47
|
+
],
|
|
48
|
+
}
|
package/tsconfig.json
ADDED