vueless 0.0.513 → 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/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,3 +1,85 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
import { merge } from "lodash-es";
|
|
4
|
+
|
|
5
|
+
import { getDefault } from "../utils/ui.ts";
|
|
6
|
+
|
|
7
|
+
import UButton from "../ui.button/UButton.vue";
|
|
8
|
+
import UModal from "../ui.container-modal/UModal.vue";
|
|
9
|
+
|
|
10
|
+
import defaultConfig from "./config.ts";
|
|
11
|
+
import { UModalConfirm } from "./constants.ts";
|
|
12
|
+
import useAttrs from "./useAttrs.ts";
|
|
13
|
+
import { useLocale } from "../composables/useLocale.ts";
|
|
14
|
+
|
|
15
|
+
import type { UModalConfirmProps } from "./types.ts";
|
|
16
|
+
|
|
17
|
+
defineOptions({ inheritAttrs: false });
|
|
18
|
+
|
|
19
|
+
const props = withDefaults(defineProps<UModalConfirmProps>(), {
|
|
20
|
+
confirmColor: getDefault<UModalConfirmProps>(defaultConfig, UModalConfirm).confirmColor,
|
|
21
|
+
confirmDisabled: getDefault<UModalConfirmProps>(defaultConfig, UModalConfirm).confirmDisabled,
|
|
22
|
+
cancelHidden: getDefault<UModalConfirmProps>(defaultConfig, UModalConfirm).cancelHidden,
|
|
23
|
+
size: getDefault<UModalConfirmProps>(defaultConfig, UModalConfirm).size,
|
|
24
|
+
closeOnCross: getDefault<UModalConfirmProps>(defaultConfig, UModalConfirm).closeOnCross,
|
|
25
|
+
closeOnOverlay: getDefault<UModalConfirmProps>(defaultConfig, UModalConfirm).closeOnOverlay,
|
|
26
|
+
closeOnEsc: getDefault<UModalConfirmProps>(defaultConfig, UModalConfirm).closeOnEsc,
|
|
27
|
+
inner: getDefault<UModalConfirmProps>(defaultConfig, UModalConfirm).inner,
|
|
28
|
+
mobileStickBottom: getDefault<UModalConfirmProps>(defaultConfig, UModalConfirm).mobileStickBottom,
|
|
29
|
+
dataTest: "",
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const emit = defineEmits([
|
|
33
|
+
/**
|
|
34
|
+
* Triggers when the modal is toggled.
|
|
35
|
+
* @property {Boolean} value
|
|
36
|
+
*/
|
|
37
|
+
"update:modelValue",
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Triggers when the action is confirmed.
|
|
41
|
+
*/
|
|
42
|
+
"confirm",
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Triggers when the action is declined or modal is closed.
|
|
46
|
+
*/
|
|
47
|
+
"close",
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
const { tm } = useLocale();
|
|
51
|
+
|
|
52
|
+
const {
|
|
53
|
+
hasSlotContent,
|
|
54
|
+
footerLeftFallbackAttrs,
|
|
55
|
+
confirmModalAttrs,
|
|
56
|
+
confirmButtonAttrs,
|
|
57
|
+
cancelButtonAttrs,
|
|
58
|
+
} = useAttrs(props);
|
|
59
|
+
|
|
60
|
+
const isShownModal = computed({
|
|
61
|
+
get: () => props.modelValue,
|
|
62
|
+
set: (value) => emit("update:modelValue", value),
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const i18nGlobal = tm(UModalConfirm);
|
|
66
|
+
const currentLocale = computed(() => merge(defaultConfig.i18n, i18nGlobal, props?.config?.i18n));
|
|
67
|
+
|
|
68
|
+
function closeModal() {
|
|
69
|
+
isShownModal.value = false;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function onCloseModal() {
|
|
73
|
+
emit("close");
|
|
74
|
+
closeModal();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function emitConfirmAction() {
|
|
78
|
+
emit("confirm");
|
|
79
|
+
closeModal();
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
|
|
1
83
|
<template>
|
|
2
84
|
<UModal
|
|
3
85
|
:id="id"
|
|
@@ -78,202 +160,3 @@
|
|
|
78
160
|
</template>
|
|
79
161
|
</UModal>
|
|
80
162
|
</template>
|
|
81
|
-
|
|
82
|
-
<script setup>
|
|
83
|
-
import { computed } from "vue";
|
|
84
|
-
import { merge } from "lodash-es";
|
|
85
|
-
|
|
86
|
-
import { getDefault } from "../utils/ui.ts";
|
|
87
|
-
|
|
88
|
-
import UButton from "../ui.button/UButton.vue";
|
|
89
|
-
import UModal from "../ui.container-modal/UModal.vue";
|
|
90
|
-
|
|
91
|
-
import defaultConfig from "./config.js";
|
|
92
|
-
import { UModalConfirm } from "./constants.js";
|
|
93
|
-
import useAttrs from "./useAttrs.js";
|
|
94
|
-
import { useLocale } from "../composables/useLocale.ts";
|
|
95
|
-
|
|
96
|
-
defineOptions({ inheritAttrs: false });
|
|
97
|
-
|
|
98
|
-
const props = defineProps({
|
|
99
|
-
/**
|
|
100
|
-
* Set modal state (hidden / shown).
|
|
101
|
-
*/
|
|
102
|
-
modelValue: {
|
|
103
|
-
type: Boolean,
|
|
104
|
-
default: false,
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* Modal title.
|
|
109
|
-
*/
|
|
110
|
-
title: {
|
|
111
|
-
type: String,
|
|
112
|
-
default: "",
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Modal description.
|
|
117
|
-
*/
|
|
118
|
-
description: {
|
|
119
|
-
type: String,
|
|
120
|
-
default: "",
|
|
121
|
-
},
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Confirm button label.
|
|
125
|
-
*/
|
|
126
|
-
confirmLabel: {
|
|
127
|
-
type: String,
|
|
128
|
-
default: "",
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Confirm button color.
|
|
133
|
-
* @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose
|
|
134
|
-
*/
|
|
135
|
-
confirmColor: {
|
|
136
|
-
type: String,
|
|
137
|
-
default: getDefault(defaultConfig, UModalConfirm).confirmColor,
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Set the disabled accept-button.
|
|
142
|
-
*/
|
|
143
|
-
confirmDisabled: {
|
|
144
|
-
type: Boolean,
|
|
145
|
-
default: getDefault(defaultConfig, UModalConfirm).confirmDisabled,
|
|
146
|
-
},
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Hide cancel button.
|
|
150
|
-
*/
|
|
151
|
-
cancelHidden: {
|
|
152
|
-
type: Boolean,
|
|
153
|
-
default: getDefault(defaultConfig, UModalConfirm).cancelHidden,
|
|
154
|
-
},
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Modal size (width).
|
|
158
|
-
* @values xs, sm, md, lg, xl, 2xl, 3xl, 4xl, 5xl
|
|
159
|
-
*/
|
|
160
|
-
size: {
|
|
161
|
-
type: String,
|
|
162
|
-
default: getDefault(defaultConfig, UModalConfirm).size,
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Allow closing modal by clicking on close cross.
|
|
167
|
-
*/
|
|
168
|
-
closeOnCross: {
|
|
169
|
-
type: Boolean,
|
|
170
|
-
default: getDefault(defaultConfig, UModalConfirm).closeOnCross,
|
|
171
|
-
},
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Allow closing modal by clicking on overlay.
|
|
175
|
-
*/
|
|
176
|
-
closeOnOverlay: {
|
|
177
|
-
type: Boolean,
|
|
178
|
-
default: getDefault(defaultConfig, UModalConfirm).closeOnOverlay,
|
|
179
|
-
},
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Allow closing modal by pressing escape (esc) on the keyboard.
|
|
183
|
-
*/
|
|
184
|
-
closeOnEsc: {
|
|
185
|
-
type: Boolean,
|
|
186
|
-
default: getDefault(defaultConfig, UModalConfirm).closeOnEsc,
|
|
187
|
-
},
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Add extra top margin for modal inside another modal.
|
|
191
|
-
*/
|
|
192
|
-
inner: {
|
|
193
|
-
type: Boolean,
|
|
194
|
-
default: getDefault(defaultConfig, UModalConfirm).inner,
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Attach small modal to the bottom of the screen (mobile version only).
|
|
199
|
-
*/
|
|
200
|
-
mobileStickBottom: {
|
|
201
|
-
type: Boolean,
|
|
202
|
-
default: getDefault(defaultConfig, UModalConfirm).mobileStickBottom,
|
|
203
|
-
},
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Unique element id.
|
|
207
|
-
*/
|
|
208
|
-
id: {
|
|
209
|
-
type: String,
|
|
210
|
-
default: "",
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Component config object.
|
|
215
|
-
*/
|
|
216
|
-
config: {
|
|
217
|
-
type: Object,
|
|
218
|
-
default: () => ({}),
|
|
219
|
-
},
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Data-test attribute for automated testing.
|
|
223
|
-
*/
|
|
224
|
-
dataTest: {
|
|
225
|
-
type: String,
|
|
226
|
-
default: "",
|
|
227
|
-
},
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
const emit = defineEmits([
|
|
231
|
-
/**
|
|
232
|
-
* Triggers when the modal is toggled.
|
|
233
|
-
* @property {Boolean} value
|
|
234
|
-
*/
|
|
235
|
-
"update:modelValue",
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Triggers when the action is confirmed.
|
|
239
|
-
*/
|
|
240
|
-
"confirm",
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Triggers when the action is declined or modal is closed.
|
|
244
|
-
*/
|
|
245
|
-
"close",
|
|
246
|
-
]);
|
|
247
|
-
|
|
248
|
-
const { tm } = useLocale();
|
|
249
|
-
|
|
250
|
-
const {
|
|
251
|
-
hasSlotContent,
|
|
252
|
-
footerLeftFallbackAttrs,
|
|
253
|
-
confirmModalAttrs,
|
|
254
|
-
confirmButtonAttrs,
|
|
255
|
-
cancelButtonAttrs,
|
|
256
|
-
} = useAttrs(props);
|
|
257
|
-
|
|
258
|
-
const isShownModal = computed({
|
|
259
|
-
get: () => props.modelValue,
|
|
260
|
-
set: (value) => emit("update:modelValue", value),
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
const i18nGlobal = tm(UModalConfirm);
|
|
264
|
-
const currentLocale = computed(() => merge(defaultConfig.i18n, i18nGlobal, props.config.i18n));
|
|
265
|
-
|
|
266
|
-
function closeModal() {
|
|
267
|
-
isShownModal.value = false;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function onCloseModal() {
|
|
271
|
-
emit("close");
|
|
272
|
-
closeModal();
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
function emitConfirmAction() {
|
|
276
|
-
emit("confirm");
|
|
277
|
-
closeModal();
|
|
278
|
-
}
|
|
279
|
-
</script>
|
|
@@ -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} />
|
|
@@ -6,6 +6,14 @@ import UHeader from "../../ui.text-header/UHeader.vue";
|
|
|
6
6
|
import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
7
7
|
import URow from "../../ui.container-row/URow.vue";
|
|
8
8
|
|
|
9
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
10
|
+
import type { UModalConfirmProps } from "../types.ts";
|
|
11
|
+
|
|
12
|
+
interface UModalConfirmArgs extends UModalConfirmProps {
|
|
13
|
+
slotTemplate?: string;
|
|
14
|
+
enum: "size" | "confirmColor";
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
/**
|
|
10
18
|
* The `UModalConfirm` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.container-modal-confirm)
|
|
11
19
|
*/
|
|
@@ -28,14 +36,14 @@ export default {
|
|
|
28
36
|
},
|
|
29
37
|
},
|
|
30
38
|
},
|
|
31
|
-
};
|
|
39
|
+
} as Meta;
|
|
32
40
|
|
|
33
41
|
const defaultTemplate = `
|
|
34
42
|
It looks like you going to complete the transaction before the process will finished.
|
|
35
43
|
All unsaved data will be lost.
|
|
36
44
|
`;
|
|
37
45
|
|
|
38
|
-
const DefaultTemplate = (args) => ({
|
|
46
|
+
const DefaultTemplate: StoryFn<UModalConfirmArgs> = (args: UModalConfirmArgs) => ({
|
|
39
47
|
components: { UModalConfirm, UButton, UHeader, UIcon },
|
|
40
48
|
setup() {
|
|
41
49
|
function onClick() {
|
|
@@ -57,7 +65,10 @@ const DefaultTemplate = (args) => ({
|
|
|
57
65
|
`,
|
|
58
66
|
});
|
|
59
67
|
|
|
60
|
-
const EnumVariantTemplate = (
|
|
68
|
+
const EnumVariantTemplate: StoryFn<UModalConfirmArgs> = (
|
|
69
|
+
args: UModalConfirmArgs,
|
|
70
|
+
{ argTypes },
|
|
71
|
+
) => ({
|
|
61
72
|
components: { UModalConfirm, UButton, URow },
|
|
62
73
|
setup() {
|
|
63
74
|
function onClick(value) {
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import defaultConfig from "./config.ts";
|
|
2
|
+
|
|
3
|
+
export type Config = Partial<typeof defaultConfig>;
|
|
4
|
+
|
|
5
|
+
export interface UModalConfirmProps {
|
|
6
|
+
/**
|
|
7
|
+
* Modal state (shown / hidden).
|
|
8
|
+
*/
|
|
9
|
+
modelValue?: boolean;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Modal title.
|
|
13
|
+
*/
|
|
14
|
+
title?: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Modal description.
|
|
18
|
+
*/
|
|
19
|
+
description?: string;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Confirm button label.
|
|
23
|
+
*/
|
|
24
|
+
confirmLabel?: string;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Confirm button color.
|
|
28
|
+
*/
|
|
29
|
+
confirmColor?:
|
|
30
|
+
| "brand"
|
|
31
|
+
| "grayscale"
|
|
32
|
+
| "gray"
|
|
33
|
+
| "red"
|
|
34
|
+
| "orange"
|
|
35
|
+
| "amber"
|
|
36
|
+
| "yellow"
|
|
37
|
+
| "lime"
|
|
38
|
+
| "green"
|
|
39
|
+
| "emerald"
|
|
40
|
+
| "teal"
|
|
41
|
+
| "cyan"
|
|
42
|
+
| "sky"
|
|
43
|
+
| "blue"
|
|
44
|
+
| "indigo"
|
|
45
|
+
| "violet"
|
|
46
|
+
| "purple"
|
|
47
|
+
| "fuchsia"
|
|
48
|
+
| "pink"
|
|
49
|
+
| "rose"
|
|
50
|
+
| "white";
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Set the disabled accept-button.
|
|
54
|
+
*/
|
|
55
|
+
confirmDisabled?: boolean;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Hide cancel button.
|
|
59
|
+
*/
|
|
60
|
+
cancelHidden?: boolean;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Modal size (width).
|
|
64
|
+
*/
|
|
65
|
+
size?: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl";
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Allow closing modal by clicking on close cross.
|
|
69
|
+
*/
|
|
70
|
+
closeOnCross?: boolean;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Allow closing modal by clicking on overlay.
|
|
74
|
+
*/
|
|
75
|
+
closeOnOverlay?: boolean;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Allow closing modal by pressing escape (esc) on the keyboard.
|
|
79
|
+
*/
|
|
80
|
+
closeOnEsc?: boolean;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Add extra top margin for modal inside another modal.
|
|
84
|
+
*/
|
|
85
|
+
inner?: boolean;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Attach small modal to the bottom of the screen (mobile version only).
|
|
89
|
+
*/
|
|
90
|
+
mobileStickBottom?: boolean;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Unique element id.
|
|
94
|
+
*/
|
|
95
|
+
id?: string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Component config object.
|
|
99
|
+
*/
|
|
100
|
+
config?: Partial<typeof defaultConfig>;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Data-test attribute for automated testing.
|
|
104
|
+
*/
|
|
105
|
+
dataTest?: string;
|
|
106
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 { UModalConfirmProps, Config } from "./types.ts";
|
|
7
|
+
|
|
8
|
+
export default function useAttrs(props: UModalConfirmProps): UseAttrs<Config> {
|
|
9
|
+
const { config, getKeysAttrs, hasSlotContent } = useUI<Config>(defaultConfig, () => props.config);
|
|
10
|
+
|
|
11
|
+
const keysAttrs = getKeysAttrs();
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
config,
|
|
15
|
+
...keysAttrs,
|
|
16
|
+
hasSlotContent,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -1,3 +1,82 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { computed, useSlots, onMounted } from "vue";
|
|
3
|
+
|
|
4
|
+
import useBreakpoint from "../composables/useBreakpoint.ts";
|
|
5
|
+
|
|
6
|
+
import ULink from "../ui.button-link/ULink.vue";
|
|
7
|
+
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
8
|
+
import UHeader from "../ui.text-header/UHeader.vue";
|
|
9
|
+
|
|
10
|
+
import { getDefault } from "../utils/ui.ts";
|
|
11
|
+
|
|
12
|
+
import defaultConfig from "./config.ts";
|
|
13
|
+
import { UPage } from "./constants.ts";
|
|
14
|
+
import useAttrs from "./useAttrs.ts";
|
|
15
|
+
|
|
16
|
+
import type { UPageProps } from "./types.ts";
|
|
17
|
+
|
|
18
|
+
const slots = useSlots();
|
|
19
|
+
|
|
20
|
+
defineOptions({ inheritAttrs: false });
|
|
21
|
+
|
|
22
|
+
const props = withDefaults(defineProps<UPageProps>(), {
|
|
23
|
+
size: getDefault<UPageProps>(defaultConfig, UPage).size,
|
|
24
|
+
titleSize: getDefault<UPageProps>(defaultConfig, UPage).titleSize,
|
|
25
|
+
gray: getDefault<UPageProps>(defaultConfig, UPage).gray,
|
|
26
|
+
fixedRounding: getDefault<UPageProps>(defaultConfig, UPage).fixedRounding,
|
|
27
|
+
dataTest: "",
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const { isMobileBreakpoint } = useBreakpoint();
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
config,
|
|
34
|
+
wrapperAttrs,
|
|
35
|
+
pageAttrs,
|
|
36
|
+
rightRoundingAttrs,
|
|
37
|
+
titleAttrs,
|
|
38
|
+
backLinkAttrs,
|
|
39
|
+
backLinkIconAttrs,
|
|
40
|
+
headerAttrs,
|
|
41
|
+
headerLeftFallbackAttrs,
|
|
42
|
+
descriptionAttrs,
|
|
43
|
+
headerLeftAttrs,
|
|
44
|
+
headerRightAttrs,
|
|
45
|
+
bodyAttrs,
|
|
46
|
+
footerAttrs,
|
|
47
|
+
footerLeftAttrs,
|
|
48
|
+
footerRightAttrs,
|
|
49
|
+
rightRoundingWrapperAttrs,
|
|
50
|
+
hasSlotContent,
|
|
51
|
+
} = useAttrs(props, { isMobileBreakpoint });
|
|
52
|
+
|
|
53
|
+
const isExistHeader = computed(() => {
|
|
54
|
+
return (
|
|
55
|
+
props.title ||
|
|
56
|
+
hasSlotContent(slots["header-left"]) ||
|
|
57
|
+
hasSlotContent(slots["header-right"]) ||
|
|
58
|
+
hasSlotContent(slots["before-title"]) ||
|
|
59
|
+
hasSlotContent(slots["after-title"])
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const isExistFooter = computed(() => {
|
|
64
|
+
return hasSlotContent(slots["footer-left"]) || hasSlotContent(slots["footer-right"]);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const isShownArrowButton = computed(() => {
|
|
68
|
+
return Object.keys(props.backTo || {}).length > 0;
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
onMounted(() => {
|
|
72
|
+
const classes = props.gray
|
|
73
|
+
? config.value.htmlBody.split(" ").filter((item) => Boolean(item))
|
|
74
|
+
: "";
|
|
75
|
+
|
|
76
|
+
document.querySelector("body").classList.add(...classes);
|
|
77
|
+
});
|
|
78
|
+
</script>
|
|
79
|
+
|
|
1
80
|
<template>
|
|
2
81
|
<div :data-test="dataTest" v-bind="wrapperAttrs">
|
|
3
82
|
<div v-bind="pageAttrs">
|
|
@@ -79,156 +158,3 @@
|
|
|
79
158
|
</div>
|
|
80
159
|
</div>
|
|
81
160
|
</template>
|
|
82
|
-
|
|
83
|
-
<script setup>
|
|
84
|
-
import { computed, useSlots, onMounted } from "vue";
|
|
85
|
-
|
|
86
|
-
import useBreakpoint from "../composables/useBreakpoint.ts";
|
|
87
|
-
|
|
88
|
-
import ULink from "../ui.button-link/ULink.vue";
|
|
89
|
-
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
90
|
-
import UHeader from "../ui.text-header/UHeader.vue";
|
|
91
|
-
|
|
92
|
-
import { getDefault } from "../utils/ui.ts";
|
|
93
|
-
|
|
94
|
-
import defaultConfig from "./config.js";
|
|
95
|
-
import { UPage } from "./constants.js";
|
|
96
|
-
import useAttrs from "./useAttrs.js";
|
|
97
|
-
|
|
98
|
-
const slots = useSlots();
|
|
99
|
-
|
|
100
|
-
defineOptions({ inheritAttrs: false });
|
|
101
|
-
|
|
102
|
-
const props = defineProps({
|
|
103
|
-
/**
|
|
104
|
-
* Page size (width).
|
|
105
|
-
* @values xs, sm, md, lg, xl, 2xl, 3xl, 4xl, 5xl, wide
|
|
106
|
-
*/
|
|
107
|
-
size: {
|
|
108
|
-
type: String,
|
|
109
|
-
default: getDefault(defaultConfig, UPage).size,
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Page title.
|
|
114
|
-
*/
|
|
115
|
-
title: {
|
|
116
|
-
type: String,
|
|
117
|
-
default: "",
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Page title size.
|
|
122
|
-
* @values xs, sm, md, lg, xl, 2xl
|
|
123
|
-
*/
|
|
124
|
-
titleSize: {
|
|
125
|
-
type: String,
|
|
126
|
-
default: getDefault(defaultConfig, UPage).titleSize,
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Set page description.
|
|
131
|
-
*/
|
|
132
|
-
description: {
|
|
133
|
-
type: String,
|
|
134
|
-
default: "",
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Back link vue-router route object.
|
|
139
|
-
*/
|
|
140
|
-
backTo: {
|
|
141
|
-
type: Object,
|
|
142
|
-
default: () => ({}),
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Back link label.
|
|
147
|
-
*/
|
|
148
|
-
backLabel: {
|
|
149
|
-
type: String,
|
|
150
|
-
default: "",
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Sets background light gray (useful if the page contains nested cards).
|
|
155
|
-
*/
|
|
156
|
-
gray: {
|
|
157
|
-
type: Boolean,
|
|
158
|
-
default: getDefault(defaultConfig, UPage).gray,
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Stick right page rounding.
|
|
163
|
-
*/
|
|
164
|
-
fixedRounding: {
|
|
165
|
-
type: Boolean,
|
|
166
|
-
default: getDefault(defaultConfig, UPage).fixedRounding,
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Component config object.
|
|
171
|
-
*/
|
|
172
|
-
config: {
|
|
173
|
-
type: Object,
|
|
174
|
-
default: () => ({}),
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Data-test attribute for automated testing.
|
|
179
|
-
*/
|
|
180
|
-
dataTest: {
|
|
181
|
-
type: String,
|
|
182
|
-
default: "",
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
const { isMobileBreakpoint } = useBreakpoint();
|
|
187
|
-
|
|
188
|
-
const {
|
|
189
|
-
config,
|
|
190
|
-
wrapperAttrs,
|
|
191
|
-
pageAttrs,
|
|
192
|
-
rightRoundingAttrs,
|
|
193
|
-
titleAttrs,
|
|
194
|
-
backLinkAttrs,
|
|
195
|
-
backLinkIconAttrs,
|
|
196
|
-
headerAttrs,
|
|
197
|
-
headerLeftFallbackAttrs,
|
|
198
|
-
descriptionAttrs,
|
|
199
|
-
headerLeftAttrs,
|
|
200
|
-
headerRightAttrs,
|
|
201
|
-
bodyAttrs,
|
|
202
|
-
footerAttrs,
|
|
203
|
-
footerLeftAttrs,
|
|
204
|
-
footerRightAttrs,
|
|
205
|
-
rightRoundingWrapperAttrs,
|
|
206
|
-
hasSlotContent,
|
|
207
|
-
} = useAttrs(props, { isMobileBreakpoint });
|
|
208
|
-
|
|
209
|
-
const isExistHeader = computed(() => {
|
|
210
|
-
return (
|
|
211
|
-
props.title ||
|
|
212
|
-
hasSlotContent(slots["header-left"]) ||
|
|
213
|
-
hasSlotContent(slots["header-right"]) ||
|
|
214
|
-
hasSlotContent(slots["before-title"]) ||
|
|
215
|
-
hasSlotContent(slots["after-title"])
|
|
216
|
-
);
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
const isExistFooter = computed(() => {
|
|
220
|
-
return hasSlotContent(slots["footer-left"]) || hasSlotContent(slots["footer-right"]);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
const isShownArrowButton = computed(() => {
|
|
224
|
-
return Boolean(Object.keys(props.backTo).length);
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
onMounted(() => {
|
|
228
|
-
const classes = props.gray
|
|
229
|
-
? config.value.htmlBody.split(" ").filter((item) => Boolean(item))
|
|
230
|
-
: "";
|
|
231
|
-
|
|
232
|
-
document.querySelector("body").classList.add(...classes);
|
|
233
|
-
});
|
|
234
|
-
</script>
|
|
@@ -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} />
|