vueless 0.0.512 → 0.0.514
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/package.json +1 -1
- package/types.ts +18 -0
- package/ui.button-link/types.ts +3 -1
- package/ui.container-accordion/UAccordion.vue +33 -69
- package/ui.container-accordion/storybook/Docs.mdx +2 -2
- package/ui.container-accordion/storybook/{stories.js → stories.ts} +10 -3
- package/ui.container-accordion/types.ts +35 -0
- package/ui.container-accordion/{useAttrs.js → useAttrs.ts} +14 -3
- package/ui.container-card/UCard.vue +43 -71
- package/ui.container-card/storybook/Docs.mdx +2 -2
- package/ui.container-card/storybook/{stories.js → stories.ts} +9 -2
- package/ui.container-card/types.ts +25 -0
- package/ui.container-card/useAttrs.ts +18 -0
- package/ui.container-col/UCol.vue +21 -79
- package/ui.container-col/storybook/Docs.mdx +2 -2
- package/ui.container-col/storybook/{stories.js → stories.ts} +9 -2
- package/ui.container-col/types.ts +54 -0
- package/ui.container-col/useAttrs.ts +18 -0
- package/ui.container-divider/UDivider.vue +22 -94
- package/ui.container-divider/storybook/Docs.mdx +2 -2
- package/ui.container-divider/storybook/{stories.js → stories.ts} +13 -5
- package/ui.container-divider/types.ts +55 -0
- package/ui.container-divider/useAttrs.ts +23 -0
- package/ui.container-group/UGroup.vue +31 -73
- package/ui.container-group/storybook/Docs.mdx +2 -2
- package/ui.container-group/storybook/{stories.js → stories.ts} +9 -2
- package/ui.container-group/types.ts +36 -0
- package/ui.container-group/useAttrs.ts +18 -0
- package/ui.container-modal/UModal.vue +122 -232
- package/ui.container-modal/storybook/Docs.mdx +2 -2
- package/ui.container-modal/storybook/{stories.js → stories.ts} +16 -6
- package/ui.container-modal/types.ts +82 -0
- package/ui.container-modal/useAttrs.ts +22 -0
- package/ui.container-modal-confirm/UModalConfirm.vue +82 -199
- package/ui.container-modal-confirm/storybook/Docs.mdx +2 -2
- package/ui.container-modal-confirm/storybook/{stories.js → stories.ts} +14 -3
- package/ui.container-modal-confirm/types.ts +106 -0
- package/ui.container-modal-confirm/useAttrs.ts +18 -0
- package/ui.container-page/UPage.vue +79 -153
- package/ui.container-page/storybook/Docs.mdx +2 -2
- package/ui.container-page/storybook/{stories.js → stories.ts} +9 -2
- package/ui.container-page/types.ts +57 -0
- package/ui.container-page/{useAttrs.js → useAttrs.ts} +14 -3
- package/ui.container-row/URow.vue +22 -87
- package/ui.container-row/storybook/Docs.mdx +2 -2
- package/ui.container-row/storybook/{stories.js → stories.ts} +11 -3
- package/ui.container-row/types.ts +59 -0
- package/ui.container-row/useAttrs.ts +18 -0
- package/ui.form-input/config.js +3 -3
- package/ui.form-label/config.js +1 -1
- package/ui.form-select/config.js +3 -0
- package/ui.form-textarea/config.js +5 -2
- package/web-types.json +182 -92
- package/ui.container-card/useAttrs.js +0 -15
- package/ui.container-col/useAttrs.js +0 -15
- package/ui.container-divider/useAttrs.js +0 -20
- package/ui.container-group/useAttrs.js +0 -15
- package/ui.container-modal/useAttrs.js +0 -19
- package/ui.container-modal-confirm/useAttrs.js +0 -15
- package/ui.container-row/useAttrs.js +0 -15
- /package/ui.container-accordion/{config.js → config.ts} +0 -0
- /package/ui.container-accordion/{constants.js → constants.ts} +0 -0
- /package/ui.container-card/{config.js → config.ts} +0 -0
- /package/ui.container-card/{constants.js → constants.ts} +0 -0
- /package/ui.container-col/{config.js → config.ts} +0 -0
- /package/ui.container-col/{constants.js → constants.ts} +0 -0
- /package/ui.container-divider/{config.js → config.ts} +0 -0
- /package/ui.container-divider/{constants.js → constants.ts} +0 -0
- /package/ui.container-group/{config.js → config.ts} +0 -0
- /package/ui.container-group/{constants.js → constants.ts} +0 -0
- /package/ui.container-modal/{config.js → config.ts} +0 -0
- /package/ui.container-modal/{constants.js → constants.ts} +0 -0
- /package/ui.container-modal-confirm/{config.js → config.ts} +0 -0
- /package/ui.container-modal-confirm/{constants.js → constants.ts} +0 -0
- /package/ui.container-page/{config.js → config.ts} +0 -0
- /package/ui.container-page/{constants.js → constants.ts} +0 -0
- /package/ui.container-row/{config.js → config.ts} +0 -0
- /package/ui.container-row/{constants.js → constants.ts} +0 -0
|
@@ -1,110 +1,4 @@
|
|
|
1
|
-
<
|
|
2
|
-
<transition v-bind="config.overlayTransition">
|
|
3
|
-
<div v-if="isShownModal" v-bind="overlayAttrs" />
|
|
4
|
-
</transition>
|
|
5
|
-
|
|
6
|
-
<transition v-bind="config.wrapperTransition">
|
|
7
|
-
<div
|
|
8
|
-
v-if="isShownModal"
|
|
9
|
-
:id="elementId"
|
|
10
|
-
ref="wrapperRef"
|
|
11
|
-
tabindex="0"
|
|
12
|
-
v-bind="wrapperAttrs"
|
|
13
|
-
:data-test="dataTest"
|
|
14
|
-
@keydown.self.esc="onKeydownEsc"
|
|
15
|
-
>
|
|
16
|
-
<div v-bind="innerWrapperAttrs" @click.self="onClickOutside">
|
|
17
|
-
<div v-bind="modalAttrs">
|
|
18
|
-
<div v-if="isExistHeader" v-bind="headerAttrs">
|
|
19
|
-
<div v-bind="headerLeftAttrs">
|
|
20
|
-
<!-- @slot Use it to add something to the left side of the header. -->
|
|
21
|
-
<slot name="header-left">
|
|
22
|
-
<!-- @slot Use it to add something before the header title. -->
|
|
23
|
-
<slot name="before-title" />
|
|
24
|
-
|
|
25
|
-
<div v-bind="headerLeftFallbackAttrs">
|
|
26
|
-
<ULink
|
|
27
|
-
v-if="isShownArrowButton"
|
|
28
|
-
size="sm"
|
|
29
|
-
color="gray"
|
|
30
|
-
:to="backTo"
|
|
31
|
-
:label="backLabel"
|
|
32
|
-
v-bind="backLinkAttrs"
|
|
33
|
-
@click="onClickBackLink"
|
|
34
|
-
>
|
|
35
|
-
<template #left>
|
|
36
|
-
<UIcon
|
|
37
|
-
internal
|
|
38
|
-
size="xs"
|
|
39
|
-
color="gray"
|
|
40
|
-
:name="config.defaults.backIcon"
|
|
41
|
-
v-bind="backLinkIconAttrs"
|
|
42
|
-
/>
|
|
43
|
-
</template>
|
|
44
|
-
</ULink>
|
|
45
|
-
|
|
46
|
-
<UHeader :label="title" size="sm" v-bind="titleAttrs" />
|
|
47
|
-
<div v-if="description" v-bind="descriptionAttrs" v-text="description" />
|
|
48
|
-
</div>
|
|
49
|
-
|
|
50
|
-
<!-- @slot Use it to add something after the header title. -->
|
|
51
|
-
<slot name="after-title" />
|
|
52
|
-
</slot>
|
|
53
|
-
</div>
|
|
54
|
-
|
|
55
|
-
<div v-bind="headerRightAttrs">
|
|
56
|
-
<!-- @slot Use it to add something to the right side of the header. -->
|
|
57
|
-
<slot name="header-right" />
|
|
58
|
-
</div>
|
|
59
|
-
|
|
60
|
-
<div v-if="closeOnCross" v-bind="closeIconAttrs">
|
|
61
|
-
<!--
|
|
62
|
-
@slot Use it to add something instead of the close button.
|
|
63
|
-
@binding {string} icon-name
|
|
64
|
-
-->
|
|
65
|
-
<slot name="close-button" :icon-name="config.defaults.closeIcon">
|
|
66
|
-
<UIcon
|
|
67
|
-
internal
|
|
68
|
-
interactive
|
|
69
|
-
size="sm"
|
|
70
|
-
:name="config.defaults.closeIcon"
|
|
71
|
-
v-bind="closeIconAttrs"
|
|
72
|
-
:data-test="`${dataTest}-close`"
|
|
73
|
-
@click="onClickCloseModal"
|
|
74
|
-
/>
|
|
75
|
-
</slot>
|
|
76
|
-
</div>
|
|
77
|
-
</div>
|
|
78
|
-
|
|
79
|
-
<div v-bind="bodyAttrs">
|
|
80
|
-
<!-- @slot Use it to add something into the modal body. -->
|
|
81
|
-
<slot />
|
|
82
|
-
</div>
|
|
83
|
-
|
|
84
|
-
<UDivider v-if="!isExistFooter || !noDivider" no-border v-bind="dividerSpacingAttrs" />
|
|
85
|
-
|
|
86
|
-
<template v-if="isExistFooter">
|
|
87
|
-
<UDivider v-if="!noDivider" variant="dark" padding="none" v-bind="dividerAttrs" />
|
|
88
|
-
|
|
89
|
-
<div v-bind="footerAttrs">
|
|
90
|
-
<div v-if="hasSlotContent($slots['footer-left'])" v-bind="footerLeftAttrs">
|
|
91
|
-
<!-- @slot Use it to add something to the left side of the footer. -->
|
|
92
|
-
<slot name="footer-left" />
|
|
93
|
-
</div>
|
|
94
|
-
|
|
95
|
-
<div v-if="hasSlotContent($slots['footer-right'])" v-bind="footerRightAttrs">
|
|
96
|
-
<!-- @slot Use it to add something to the right side of the footer. -->
|
|
97
|
-
<slot name="footer-right" />
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
</template>
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
</transition>
|
|
105
|
-
</template>
|
|
106
|
-
|
|
107
|
-
<script setup>
|
|
1
|
+
<script lang="ts" setup>
|
|
108
2
|
import { computed, useSlots, watch, ref, useId } from "vue";
|
|
109
3
|
|
|
110
4
|
import { getDefault } from "../utils/ui.ts";
|
|
@@ -114,136 +8,26 @@ import UIcon from "../ui.image-icon/UIcon.vue";
|
|
|
114
8
|
import UHeader from "../ui.text-header/UHeader.vue";
|
|
115
9
|
import UDivider from "../ui.container-divider/UDivider.vue";
|
|
116
10
|
|
|
117
|
-
import defaultConfig from "./config.
|
|
118
|
-
import { UModal } from "./constants.
|
|
119
|
-
import useAttrs from "./useAttrs.
|
|
11
|
+
import defaultConfig from "./config.ts";
|
|
12
|
+
import { UModal } from "./constants.ts";
|
|
13
|
+
import useAttrs from "./useAttrs.ts";
|
|
14
|
+
|
|
15
|
+
import type { UModalProps } from "./types.ts";
|
|
120
16
|
|
|
121
17
|
defineOptions({ inheritAttrs: false });
|
|
122
18
|
const slots = useSlots();
|
|
123
19
|
|
|
124
20
|
const wrapperRef = ref(null);
|
|
125
21
|
|
|
126
|
-
const props = defineProps({
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Modal title.
|
|
137
|
-
*/
|
|
138
|
-
title: {
|
|
139
|
-
type: String,
|
|
140
|
-
default: "",
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Modal description.
|
|
145
|
-
*/
|
|
146
|
-
description: {
|
|
147
|
-
type: String,
|
|
148
|
-
default: "",
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Modal size (width).
|
|
153
|
-
* @values xs, sm, md, lg, xl, 2xl, 3xl, 4xl, 5xl
|
|
154
|
-
*/
|
|
155
|
-
size: {
|
|
156
|
-
type: String,
|
|
157
|
-
default: getDefault(defaultConfig, UModal).size,
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Back link vue-router route object.
|
|
162
|
-
*/
|
|
163
|
-
backTo: {
|
|
164
|
-
type: Object,
|
|
165
|
-
default: () => ({}),
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Back link label.
|
|
170
|
-
*/
|
|
171
|
-
backLabel: {
|
|
172
|
-
type: String,
|
|
173
|
-
default: "",
|
|
174
|
-
},
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* Allow closing modal by clicking on close cross.
|
|
178
|
-
*/
|
|
179
|
-
closeOnCross: {
|
|
180
|
-
type: Boolean,
|
|
181
|
-
default: getDefault(defaultConfig, UModal).closeOnCross,
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Allow closing modal by clicking on overlay.
|
|
186
|
-
*/
|
|
187
|
-
closeOnOverlay: {
|
|
188
|
-
type: Boolean,
|
|
189
|
-
default: getDefault(defaultConfig, UModal).closeOnOverlay,
|
|
190
|
-
},
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Allow closing modal by pressing escape (esc) on the keyboard.
|
|
194
|
-
*/
|
|
195
|
-
closeOnEsc: {
|
|
196
|
-
type: Boolean,
|
|
197
|
-
default: getDefault(defaultConfig, UModal).closeOnEsc,
|
|
198
|
-
},
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Add extra top margin for modal inside another modal.
|
|
202
|
-
*/
|
|
203
|
-
inner: {
|
|
204
|
-
type: Boolean,
|
|
205
|
-
default: getDefault(defaultConfig, UModal).inner,
|
|
206
|
-
},
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Hide divider between content end footer.
|
|
210
|
-
*/
|
|
211
|
-
noDivider: {
|
|
212
|
-
type: Boolean,
|
|
213
|
-
default: getDefault(defaultConfig, UModal).noDivider,
|
|
214
|
-
},
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Attach small modal to the bottom of the screen (mobile version only).
|
|
218
|
-
*/
|
|
219
|
-
mobileStickBottom: {
|
|
220
|
-
type: Boolean,
|
|
221
|
-
default: getDefault(defaultConfig, UModal).mobileStickBottom,
|
|
222
|
-
},
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* Unique element id.
|
|
226
|
-
*/
|
|
227
|
-
id: {
|
|
228
|
-
type: String,
|
|
229
|
-
default: "",
|
|
230
|
-
},
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* Component config object.
|
|
234
|
-
*/
|
|
235
|
-
config: {
|
|
236
|
-
type: Object,
|
|
237
|
-
default: () => ({}),
|
|
238
|
-
},
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Set data-test attribute for automated testing.
|
|
242
|
-
*/
|
|
243
|
-
dataTest: {
|
|
244
|
-
type: String,
|
|
245
|
-
default: "",
|
|
246
|
-
},
|
|
22
|
+
const props = withDefaults(defineProps<UModalProps>(), {
|
|
23
|
+
size: getDefault<UModalProps>(defaultConfig, UModal).size,
|
|
24
|
+
closeOnCross: getDefault<UModalProps>(defaultConfig, UModal).closeOnCross,
|
|
25
|
+
closeOnOverlay: getDefault<UModalProps>(defaultConfig, UModal).closeOnOverlay,
|
|
26
|
+
closeOnEsc: getDefault<UModalProps>(defaultConfig, UModal).closeOnEsc,
|
|
27
|
+
inner: getDefault<UModalProps>(defaultConfig, UModal).inner,
|
|
28
|
+
noDivider: getDefault<UModalProps>(defaultConfig, UModal).noDivider,
|
|
29
|
+
mobileStickBottom: getDefault<UModalProps>(defaultConfig, UModal).mobileStickBottom,
|
|
30
|
+
dataTest: "",
|
|
247
31
|
});
|
|
248
32
|
|
|
249
33
|
const emit = defineEmits([
|
|
@@ -291,7 +75,7 @@ const isShownModal = computed({
|
|
|
291
75
|
});
|
|
292
76
|
|
|
293
77
|
const isShownArrowButton = computed(() => {
|
|
294
|
-
return
|
|
78
|
+
return Object.keys(props.backTo || {}).length > 0;
|
|
295
79
|
});
|
|
296
80
|
|
|
297
81
|
const isExistHeader = computed(() => {
|
|
@@ -342,3 +126,109 @@ function closeModal() {
|
|
|
342
126
|
isShownModal.value = false;
|
|
343
127
|
}
|
|
344
128
|
</script>
|
|
129
|
+
|
|
130
|
+
<template>
|
|
131
|
+
<transition v-bind="config.overlayTransition">
|
|
132
|
+
<div v-if="isShownModal" v-bind="overlayAttrs" />
|
|
133
|
+
</transition>
|
|
134
|
+
|
|
135
|
+
<transition v-bind="config.wrapperTransition">
|
|
136
|
+
<div
|
|
137
|
+
v-if="isShownModal"
|
|
138
|
+
:id="elementId"
|
|
139
|
+
ref="wrapperRef"
|
|
140
|
+
tabindex="0"
|
|
141
|
+
v-bind="wrapperAttrs"
|
|
142
|
+
:data-test="dataTest"
|
|
143
|
+
@keydown.self.esc="onKeydownEsc"
|
|
144
|
+
>
|
|
145
|
+
<div v-bind="innerWrapperAttrs" @click.self="onClickOutside">
|
|
146
|
+
<div v-bind="modalAttrs">
|
|
147
|
+
<div v-if="isExistHeader" v-bind="headerAttrs">
|
|
148
|
+
<div v-bind="headerLeftAttrs">
|
|
149
|
+
<!-- @slot Use it to add something to the left side of the header. -->
|
|
150
|
+
<slot name="header-left">
|
|
151
|
+
<!-- @slot Use it to add something before the header title. -->
|
|
152
|
+
<slot name="before-title" />
|
|
153
|
+
|
|
154
|
+
<div v-bind="headerLeftFallbackAttrs">
|
|
155
|
+
<ULink
|
|
156
|
+
v-if="isShownArrowButton"
|
|
157
|
+
size="sm"
|
|
158
|
+
color="gray"
|
|
159
|
+
:to="backTo"
|
|
160
|
+
:label="backLabel"
|
|
161
|
+
v-bind="backLinkAttrs"
|
|
162
|
+
@click="onClickBackLink"
|
|
163
|
+
>
|
|
164
|
+
<template #left>
|
|
165
|
+
<UIcon
|
|
166
|
+
internal
|
|
167
|
+
size="xs"
|
|
168
|
+
color="gray"
|
|
169
|
+
:name="config.defaults.backIcon"
|
|
170
|
+
v-bind="backLinkIconAttrs"
|
|
171
|
+
/>
|
|
172
|
+
</template>
|
|
173
|
+
</ULink>
|
|
174
|
+
|
|
175
|
+
<UHeader :label="title" size="sm" v-bind="titleAttrs" />
|
|
176
|
+
<div v-if="description" v-bind="descriptionAttrs" v-text="description" />
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<!-- @slot Use it to add something after the header title. -->
|
|
180
|
+
<slot name="after-title" />
|
|
181
|
+
</slot>
|
|
182
|
+
</div>
|
|
183
|
+
|
|
184
|
+
<div v-bind="headerRightAttrs">
|
|
185
|
+
<!-- @slot Use it to add something to the right side of the header. -->
|
|
186
|
+
<slot name="header-right" />
|
|
187
|
+
</div>
|
|
188
|
+
|
|
189
|
+
<div v-if="closeOnCross" v-bind="closeIconAttrs">
|
|
190
|
+
<!--
|
|
191
|
+
@slot Use it to add something instead of the close button.
|
|
192
|
+
@binding {string} icon-name
|
|
193
|
+
-->
|
|
194
|
+
<slot name="close-button" :icon-name="config.defaults.closeIcon">
|
|
195
|
+
<UIcon
|
|
196
|
+
internal
|
|
197
|
+
interactive
|
|
198
|
+
size="sm"
|
|
199
|
+
:name="config.defaults.closeIcon"
|
|
200
|
+
v-bind="closeIconAttrs"
|
|
201
|
+
:data-test="`${dataTest}-close`"
|
|
202
|
+
@click="onClickCloseModal"
|
|
203
|
+
/>
|
|
204
|
+
</slot>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
|
|
208
|
+
<div v-bind="bodyAttrs">
|
|
209
|
+
<!-- @slot Use it to add something into the modal body. -->
|
|
210
|
+
<slot />
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
<UDivider v-if="!isExistFooter || !noDivider" no-border v-bind="dividerSpacingAttrs" />
|
|
214
|
+
|
|
215
|
+
<template v-if="isExistFooter">
|
|
216
|
+
<UDivider v-if="!noDivider" variant="dark" padding="none" v-bind="dividerAttrs" />
|
|
217
|
+
|
|
218
|
+
<div v-bind="footerAttrs">
|
|
219
|
+
<div v-if="hasSlotContent($slots['footer-left'])" v-bind="footerLeftAttrs">
|
|
220
|
+
<!-- @slot Use it to add something to the left side of the footer. -->
|
|
221
|
+
<slot name="footer-left" />
|
|
222
|
+
</div>
|
|
223
|
+
|
|
224
|
+
<div v-if="hasSlotContent($slots['footer-right'])" v-bind="footerRightAttrs">
|
|
225
|
+
<!-- @slot Use it to add something to the right side of the footer. -->
|
|
226
|
+
<slot name="footer-right" />
|
|
227
|
+
</div>
|
|
228
|
+
</div>
|
|
229
|
+
</template>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
</div>
|
|
233
|
+
</transition>
|
|
234
|
+
</template>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Meta, Title, Subtitle, Description, Primary, Controls, Stories, Source } from "@storybook/blocks";
|
|
2
2
|
import { getSource } from "../../utils/storybook.ts";
|
|
3
3
|
|
|
4
|
-
import * as stories from "./stories.
|
|
5
|
-
import defaultConfig from "../config.
|
|
4
|
+
import * as stories from "./stories.ts";
|
|
5
|
+
import defaultConfig from "../config.ts?raw"
|
|
6
6
|
|
|
7
7
|
<Meta of={stories} />
|
|
8
8
|
<Title of={stories} />
|
|
@@ -8,6 +8,14 @@ import UInput from "../../ui.form-input/UInput.vue";
|
|
|
8
8
|
import UTextarea from "../../ui.form-textarea/UTextarea.vue";
|
|
9
9
|
import URow from "../../ui.container-row/URow.vue";
|
|
10
10
|
|
|
11
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
12
|
+
import type { UModalProps } from "../types.ts";
|
|
13
|
+
|
|
14
|
+
interface UModalArgs extends UModalProps {
|
|
15
|
+
slotTemplate?: string;
|
|
16
|
+
enum: "size";
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
/**
|
|
12
20
|
* The `UModal` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.container-modal)
|
|
13
21
|
*/
|
|
@@ -29,7 +37,7 @@ export default {
|
|
|
29
37
|
},
|
|
30
38
|
},
|
|
31
39
|
},
|
|
32
|
-
};
|
|
40
|
+
} as Meta;
|
|
33
41
|
|
|
34
42
|
const defaultTemplate = `
|
|
35
43
|
<URow>
|
|
@@ -40,7 +48,7 @@ const defaultTemplate = `
|
|
|
40
48
|
<UTextarea class="mb-7" label="Comments" rows="3" />
|
|
41
49
|
`;
|
|
42
50
|
|
|
43
|
-
const DefaultTemplate = (args) => ({
|
|
51
|
+
const DefaultTemplate: StoryFn<UModalArgs> = (args: UModalArgs) => ({
|
|
44
52
|
components: { UModal, URow, UButton, UIcon, UHeader, UInput, UTextarea },
|
|
45
53
|
setup() {
|
|
46
54
|
function onClick() {
|
|
@@ -62,17 +70,19 @@ const DefaultTemplate = (args) => ({
|
|
|
62
70
|
`,
|
|
63
71
|
});
|
|
64
72
|
|
|
65
|
-
const EnumVariantTemplate = (args, { argTypes }) => ({
|
|
73
|
+
const EnumVariantTemplate: StoryFn<UModalArgs> = (args: UModalArgs, { argTypes }) => ({
|
|
66
74
|
components: { UModal, UButton, URow, UInput, UTextarea },
|
|
67
75
|
setup() {
|
|
68
|
-
|
|
76
|
+
type ModalSize = "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl";
|
|
77
|
+
|
|
78
|
+
function onClick(value: ModalSize) {
|
|
69
79
|
args.size = value;
|
|
70
80
|
args.modelValue = true;
|
|
71
81
|
}
|
|
72
82
|
|
|
73
83
|
return {
|
|
74
84
|
args,
|
|
75
|
-
options: argTypes[args.enum]
|
|
85
|
+
options: argTypes?.[args.enum]?.options,
|
|
76
86
|
onClick,
|
|
77
87
|
};
|
|
78
88
|
},
|
|
@@ -105,7 +115,7 @@ BackLink.args = {
|
|
|
105
115
|
backLabel: "back",
|
|
106
116
|
backTo: {
|
|
107
117
|
path: "/",
|
|
108
|
-
|
|
118
|
+
query: {},
|
|
109
119
|
},
|
|
110
120
|
};
|
|
111
121
|
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import defaultConfig from "./config.ts";
|
|
2
|
+
|
|
3
|
+
import type { RouteLocationRaw } from "vue-router";
|
|
4
|
+
|
|
5
|
+
export type Config = Partial<typeof defaultConfig>;
|
|
6
|
+
|
|
7
|
+
export interface UModalProps {
|
|
8
|
+
/**
|
|
9
|
+
* Modal state (shown / hidden).
|
|
10
|
+
*/
|
|
11
|
+
modelValue?: boolean;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Modal title.
|
|
15
|
+
*/
|
|
16
|
+
title?: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Modal description.
|
|
20
|
+
*/
|
|
21
|
+
description?: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Modal size (width).
|
|
25
|
+
*/
|
|
26
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Back link vue-router route object.
|
|
30
|
+
*/
|
|
31
|
+
backTo?: RouteLocationRaw;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Back link label.
|
|
35
|
+
*/
|
|
36
|
+
backLabel?: string;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Allow closing modal by clicking on close cross.
|
|
40
|
+
*/
|
|
41
|
+
closeOnCross?: boolean;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Allow closing modal by clicking on overlay.
|
|
45
|
+
*/
|
|
46
|
+
closeOnOverlay?: boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Allow closing modal by pressing escape (esc) on the keyboard.
|
|
50
|
+
*/
|
|
51
|
+
closeOnEsc?: boolean;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Add extra top margin for modal inside another modal.
|
|
55
|
+
*/
|
|
56
|
+
inner?: boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Hide divider between content end footer.
|
|
60
|
+
*/
|
|
61
|
+
noDivider?: boolean;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Attach small modal to the bottom of the screen (mobile version only).
|
|
65
|
+
*/
|
|
66
|
+
mobileStickBottom?: boolean;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Unique element id.
|
|
70
|
+
*/
|
|
71
|
+
id?: string;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Component config object.
|
|
75
|
+
*/
|
|
76
|
+
config?: Partial<typeof defaultConfig>;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Data-test attribute for automated testing.
|
|
80
|
+
*/
|
|
81
|
+
dataTest?: string;
|
|
82
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import useUI from "../composables/useUI.ts";
|
|
2
|
+
|
|
3
|
+
import defaultConfig from "./config.ts";
|
|
4
|
+
|
|
5
|
+
import type { UseAttrs } from "../types.ts";
|
|
6
|
+
import type { UModalProps, Config } from "./types.ts";
|
|
7
|
+
|
|
8
|
+
export default function useAttrs(props: UModalProps): UseAttrs<Config> {
|
|
9
|
+
const { config, getKeysAttrs, hasSlotContent } = useUI<Config>(
|
|
10
|
+
defaultConfig,
|
|
11
|
+
() => props.config,
|
|
12
|
+
"wrapper",
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const keysAttrs = getKeysAttrs();
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
config,
|
|
19
|
+
...keysAttrs,
|
|
20
|
+
hasSlotContent,
|
|
21
|
+
};
|
|
22
|
+
}
|