sprintify-ui 0.1.13 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sprintify-ui.es.js +3995 -3993
- package/dist/types/src/components/BaseCounter.vue.d.ts +4 -3
- package/dist/types/src/components/BaseHeader.vue.d.ts +5 -0
- package/dist/types/src/components/BaseMediaPreview.vue.d.ts +9 -0
- package/dist/types/src/components/BaseMenuItem.vue.d.ts +4 -3
- package/dist/types/src/components/BaseSwitch.vue.d.ts +18 -0
- package/dist/types/src/types/index.d.ts +3 -2
- package/package.json +1 -1
- package/src/components/BaseActionItemButton.vue +2 -0
- package/src/components/BaseCounter.stories.js +1 -1
- package/src/components/BaseCounter.vue +5 -3
- package/src/components/BaseHeader.stories.js +12 -5
- package/src/components/BaseHeader.vue +73 -74
- package/src/components/BaseMediaPreview.vue +6 -2
- package/src/components/BaseMenuItem.vue +4 -3
- package/src/components/BaseSwitch.stories.js +23 -0
- package/src/components/BaseSwitch.vue +23 -2
- package/src/types/index.ts +11 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ActionColors } from '@/types';
|
|
1
2
|
import { PropType } from 'vue';
|
|
2
3
|
declare const _default: import("vue").DefineComponent<{
|
|
3
4
|
count: {
|
|
@@ -14,7 +15,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
14
15
|
};
|
|
15
16
|
color: {
|
|
16
17
|
default: string;
|
|
17
|
-
type: PropType<
|
|
18
|
+
type: PropType<ActionColors>;
|
|
18
19
|
};
|
|
19
20
|
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
20
21
|
count: {
|
|
@@ -31,10 +32,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
31
32
|
};
|
|
32
33
|
color: {
|
|
33
34
|
default: string;
|
|
34
|
-
type: PropType<
|
|
35
|
+
type: PropType<ActionColors>;
|
|
35
36
|
};
|
|
36
37
|
}>>, {
|
|
37
|
-
color:
|
|
38
|
+
color: ActionColors;
|
|
38
39
|
size: "xs" | "sm" | "md";
|
|
39
40
|
maxDigit: number;
|
|
40
41
|
}>;
|
|
@@ -14,6 +14,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
14
14
|
} | undefined;
|
|
15
15
|
layout?: "default" | "compact" | undefined;
|
|
16
16
|
breadcrumbs?: Breadcrumb[] | undefined;
|
|
17
|
+
maxActions?: number | undefined;
|
|
17
18
|
}>, {
|
|
18
19
|
subtitle: undefined;
|
|
19
20
|
attributes: undefined;
|
|
@@ -21,6 +22,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
21
22
|
badge: undefined;
|
|
22
23
|
layout: string;
|
|
23
24
|
breadcrumbs: undefined;
|
|
25
|
+
maxActions: number;
|
|
24
26
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
25
27
|
title: string;
|
|
26
28
|
subtitle?: string | undefined;
|
|
@@ -36,6 +38,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
36
38
|
} | undefined;
|
|
37
39
|
layout?: "default" | "compact" | undefined;
|
|
38
40
|
breadcrumbs?: Breadcrumb[] | undefined;
|
|
41
|
+
maxActions?: number | undefined;
|
|
39
42
|
}>, {
|
|
40
43
|
subtitle: undefined;
|
|
41
44
|
attributes: undefined;
|
|
@@ -43,6 +46,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
43
46
|
badge: undefined;
|
|
44
47
|
layout: string;
|
|
45
48
|
breadcrumbs: undefined;
|
|
49
|
+
maxActions: number;
|
|
46
50
|
}>>>, {
|
|
47
51
|
attributes: {
|
|
48
52
|
icon: string;
|
|
@@ -57,6 +61,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
57
61
|
label: string;
|
|
58
62
|
color: string;
|
|
59
63
|
};
|
|
64
|
+
maxActions: number;
|
|
60
65
|
}>;
|
|
61
66
|
export default _default;
|
|
62
67
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
@@ -10,6 +10,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
10
10
|
default: boolean;
|
|
11
11
|
type: BooleanConstructor;
|
|
12
12
|
};
|
|
13
|
+
previewImage: {
|
|
14
|
+
default: boolean;
|
|
15
|
+
type: BooleanConstructor;
|
|
16
|
+
};
|
|
13
17
|
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "delete"[], "delete", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
14
18
|
media: {
|
|
15
19
|
required: true;
|
|
@@ -19,9 +23,14 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
19
23
|
default: boolean;
|
|
20
24
|
type: BooleanConstructor;
|
|
21
25
|
};
|
|
26
|
+
previewImage: {
|
|
27
|
+
default: boolean;
|
|
28
|
+
type: BooleanConstructor;
|
|
29
|
+
};
|
|
22
30
|
}>> & {
|
|
23
31
|
onDelete?: ((...args: any[]) => any) | undefined;
|
|
24
32
|
}, {
|
|
25
33
|
showRemove: boolean;
|
|
34
|
+
previewImage: boolean;
|
|
26
35
|
}>;
|
|
27
36
|
export default _default;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PropType } from 'vue';
|
|
2
|
+
import { ActionColors } from '@/types';
|
|
2
3
|
declare const _default: import("vue").DefineComponent<{
|
|
3
4
|
label: {
|
|
4
5
|
default: undefined;
|
|
@@ -18,7 +19,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
18
19
|
};
|
|
19
20
|
color: {
|
|
20
21
|
default: string;
|
|
21
|
-
type: PropType<
|
|
22
|
+
type: PropType<ActionColors>;
|
|
22
23
|
};
|
|
23
24
|
size: {
|
|
24
25
|
default: string;
|
|
@@ -43,7 +44,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
43
44
|
};
|
|
44
45
|
color: {
|
|
45
46
|
default: string;
|
|
46
|
-
type: PropType<
|
|
47
|
+
type: PropType<ActionColors>;
|
|
47
48
|
};
|
|
48
49
|
size: {
|
|
49
50
|
default: string;
|
|
@@ -52,7 +53,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
52
53
|
}>>, {
|
|
53
54
|
label: string;
|
|
54
55
|
active: boolean;
|
|
55
|
-
color:
|
|
56
|
+
color: ActionColors;
|
|
56
57
|
icon: string;
|
|
57
58
|
count: number;
|
|
58
59
|
size: "xs" | "sm" | "md";
|
|
@@ -24,6 +24,14 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
24
24
|
default: boolean;
|
|
25
25
|
type: BooleanConstructor;
|
|
26
26
|
};
|
|
27
|
+
checkedIcon: {
|
|
28
|
+
default: string;
|
|
29
|
+
type: StringConstructor;
|
|
30
|
+
};
|
|
31
|
+
unCheckedIcon: {
|
|
32
|
+
default: string;
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
};
|
|
27
35
|
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "update:modelValue"[], "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
28
36
|
modelValue: {
|
|
29
37
|
default: boolean;
|
|
@@ -49,6 +57,14 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
49
57
|
default: boolean;
|
|
50
58
|
type: BooleanConstructor;
|
|
51
59
|
};
|
|
60
|
+
checkedIcon: {
|
|
61
|
+
default: string;
|
|
62
|
+
type: StringConstructor;
|
|
63
|
+
};
|
|
64
|
+
unCheckedIcon: {
|
|
65
|
+
default: string;
|
|
66
|
+
type: StringConstructor;
|
|
67
|
+
};
|
|
52
68
|
}>> & {
|
|
53
69
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
54
70
|
}, {
|
|
@@ -58,6 +74,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
58
74
|
modelValue: string | number | boolean | null | undefined;
|
|
59
75
|
hasError: boolean;
|
|
60
76
|
size: "base" | "xs" | "sm" | "lg" | "xl";
|
|
77
|
+
checkedIcon: string;
|
|
78
|
+
unCheckedIcon: string;
|
|
61
79
|
}>, {
|
|
62
80
|
default: (_: {}) => any;
|
|
63
81
|
}>;
|
|
@@ -50,6 +50,7 @@ export interface ResourceCollection {
|
|
|
50
50
|
export interface PaginatedCollection extends PaginationMetadata {
|
|
51
51
|
data: Collection;
|
|
52
52
|
}
|
|
53
|
+
export type ActionColors = 'dark' | 'light' | 'danger' | 'success' | 'warning' | 'primary' | 'secondary';
|
|
53
54
|
export interface MenuItemInterface {
|
|
54
55
|
label?: string;
|
|
55
56
|
href?: string;
|
|
@@ -57,7 +58,7 @@ export interface MenuItemInterface {
|
|
|
57
58
|
action?: () => Promise<void> | void;
|
|
58
59
|
icon?: string;
|
|
59
60
|
count?: number;
|
|
60
|
-
color?:
|
|
61
|
+
color?: ActionColors;
|
|
61
62
|
line?: boolean;
|
|
62
63
|
}
|
|
63
64
|
export interface ActionItem {
|
|
@@ -67,7 +68,7 @@ export interface ActionItem {
|
|
|
67
68
|
action?: () => Promise<void> | void;
|
|
68
69
|
icon?: string;
|
|
69
70
|
count?: number;
|
|
70
|
-
color?:
|
|
71
|
+
color?: ActionColors;
|
|
71
72
|
disabled?: boolean;
|
|
72
73
|
meta?: Record<string, any>;
|
|
73
74
|
actions?: ActionItem[];
|
package/package.json
CHANGED
|
@@ -36,6 +36,8 @@ const classes = computed(() => {
|
|
|
36
36
|
|
|
37
37
|
if (props.action.color == 'primary') {
|
|
38
38
|
classList.push('btn-primary');
|
|
39
|
+
} else if (props.action.color == 'secondary') {
|
|
40
|
+
classList.push('btn-secondary-outline');
|
|
39
41
|
} else if (props.action.color == 'danger') {
|
|
40
42
|
classList.push('btn-danger');
|
|
41
43
|
} else if (props.action.color == 'warning') {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script lang="ts" setup>
|
|
11
|
+
import { ActionColors } from '@/types';
|
|
11
12
|
import { padStart } from 'lodash';
|
|
12
13
|
import { PropType } from 'vue';
|
|
13
14
|
|
|
@@ -26,9 +27,7 @@ const props = defineProps({
|
|
|
26
27
|
},
|
|
27
28
|
color: {
|
|
28
29
|
default: 'danger',
|
|
29
|
-
type: String as PropType<
|
|
30
|
-
'danger' | 'primary' | 'success' | 'warning' | 'dark' | 'light' | 'white'
|
|
31
|
-
>,
|
|
30
|
+
type: String as PropType<ActionColors>,
|
|
32
31
|
},
|
|
33
32
|
});
|
|
34
33
|
|
|
@@ -69,6 +68,9 @@ const colorClass = computed((): string => {
|
|
|
69
68
|
if (props.color == 'primary') {
|
|
70
69
|
return 'bg-primary-500 text-white';
|
|
71
70
|
}
|
|
71
|
+
if (props.color == 'secondary') {
|
|
72
|
+
return 'bg-primary-200 text-primary-800';
|
|
73
|
+
}
|
|
72
74
|
if (props.color == 'dark') {
|
|
73
75
|
return 'bg-slate-900 text-white';
|
|
74
76
|
}
|
|
@@ -35,11 +35,6 @@ const attributes = [
|
|
|
35
35
|
];
|
|
36
36
|
|
|
37
37
|
const actions = [
|
|
38
|
-
{
|
|
39
|
-
label: 'Edit',
|
|
40
|
-
to: '/articles',
|
|
41
|
-
icon: 'heroicons:pencil-solid',
|
|
42
|
-
},
|
|
43
38
|
{
|
|
44
39
|
label: 'View',
|
|
45
40
|
icon: 'heroicons:link-solid',
|
|
@@ -47,6 +42,18 @@ const actions = [
|
|
|
47
42
|
alert('View');
|
|
48
43
|
},
|
|
49
44
|
},
|
|
45
|
+
{
|
|
46
|
+
label: 'Edit',
|
|
47
|
+
to: '/articles',
|
|
48
|
+
icon: 'heroicons:pencil-solid',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: 'Publish 2',
|
|
52
|
+
to: '/articles',
|
|
53
|
+
color: 'secondary',
|
|
54
|
+
icon: 'heroicons:check-solid',
|
|
55
|
+
},
|
|
56
|
+
|
|
50
57
|
{
|
|
51
58
|
label: 'Publish',
|
|
52
59
|
to: '/articles',
|
|
@@ -61,46 +61,38 @@
|
|
|
61
61
|
</div>
|
|
62
62
|
</div>
|
|
63
63
|
|
|
64
|
-
<div
|
|
65
|
-
<
|
|
66
|
-
|
|
67
|
-
:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
<BaseMenu
|
|
72
|
-
v-if="secondaryActions.length > 1"
|
|
73
|
-
:items="secondaryActions"
|
|
74
|
-
size="sm"
|
|
75
|
-
position="bottom-right"
|
|
64
|
+
<div class="mt-5">
|
|
65
|
+
<div
|
|
66
|
+
class="flex gap-2"
|
|
67
|
+
:class="{
|
|
68
|
+
'lg:mt-0 lg:ml-4': !compactLayout,
|
|
69
|
+
}"
|
|
76
70
|
>
|
|
77
|
-
<
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
size="sm"
|
|
103
|
-
/>
|
|
71
|
+
<BaseActionItemButton
|
|
72
|
+
v-for="(primaryAction, i) in primaryActions"
|
|
73
|
+
:key="i"
|
|
74
|
+
:action="primaryAction"
|
|
75
|
+
size="sm"
|
|
76
|
+
/>
|
|
77
|
+
<BaseMenu
|
|
78
|
+
v-if="secondaryActions.length"
|
|
79
|
+
:items="secondaryActions"
|
|
80
|
+
size="sm"
|
|
81
|
+
:position="compactLayout ? 'bottom-right' : 'bottom-left'"
|
|
82
|
+
>
|
|
83
|
+
<template #button="{ open }">
|
|
84
|
+
<div
|
|
85
|
+
class="btn btn-sm flex items-center rounded-full p-2 hover:border-slate-400"
|
|
86
|
+
:class="[open ? 'bg-slate-100' : '']"
|
|
87
|
+
>
|
|
88
|
+
<BaseIcon
|
|
89
|
+
icon="heroicons-outline:dots-horizontal"
|
|
90
|
+
class="h-4 w-4 text-slate-500"
|
|
91
|
+
/>
|
|
92
|
+
</div>
|
|
93
|
+
</template>
|
|
94
|
+
</BaseMenu>
|
|
95
|
+
</div>
|
|
104
96
|
</div>
|
|
105
97
|
</div>
|
|
106
98
|
</div>
|
|
@@ -113,6 +105,7 @@ import { BaseBreadcrumbs, BaseIcon } from '..';
|
|
|
113
105
|
import BaseActionItemButton from './BaseActionItemButton.vue';
|
|
114
106
|
import BaseBadge from './BaseBadge.vue';
|
|
115
107
|
import BaseMenu from './BaseMenu.vue';
|
|
108
|
+
import { cloneDeep } from 'lodash';
|
|
116
109
|
|
|
117
110
|
const props = withDefaults(
|
|
118
111
|
defineProps<{
|
|
@@ -123,6 +116,7 @@ const props = withDefaults(
|
|
|
123
116
|
badge?: { icon: string; label: string; color: string };
|
|
124
117
|
layout?: 'default' | 'compact';
|
|
125
118
|
breadcrumbs?: Breadcrumb[];
|
|
119
|
+
maxActions?: number;
|
|
126
120
|
}>(),
|
|
127
121
|
{
|
|
128
122
|
subtitle: undefined,
|
|
@@ -131,59 +125,64 @@ const props = withDefaults(
|
|
|
131
125
|
badge: undefined,
|
|
132
126
|
layout: 'default',
|
|
133
127
|
breadcrumbs: undefined,
|
|
128
|
+
maxActions: 3,
|
|
134
129
|
}
|
|
135
130
|
);
|
|
136
131
|
|
|
137
|
-
const
|
|
138
|
-
if (!props.actions || props.actions.length === 0) {
|
|
139
|
-
return undefined;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
if (props.actions?.length === 1) {
|
|
143
|
-
return 0;
|
|
144
|
-
}
|
|
132
|
+
const baseHeaderRef = ref<HTMLElement | null>(null);
|
|
145
133
|
|
|
146
|
-
|
|
134
|
+
const width = ref(800);
|
|
135
|
+
useResizeObserver(baseHeaderRef, () => {
|
|
136
|
+
width.value = baseHeaderRef.value?.clientWidth ?? 800;
|
|
137
|
+
});
|
|
147
138
|
|
|
148
|
-
|
|
149
|
-
|
|
139
|
+
const compactLayout = computed(() => {
|
|
140
|
+
if (props.layout === 'compact') {
|
|
141
|
+
return true;
|
|
150
142
|
}
|
|
151
|
-
|
|
152
|
-
return 0;
|
|
143
|
+
return width.value < 500;
|
|
153
144
|
});
|
|
154
145
|
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
157
|
-
return
|
|
146
|
+
const maxActionsInternal = computed(() => {
|
|
147
|
+
if (compactLayout.value) {
|
|
148
|
+
return 1;
|
|
158
149
|
}
|
|
150
|
+
return Math.max(1, props.maxActions);
|
|
151
|
+
});
|
|
159
152
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return props.actions[index];
|
|
153
|
+
const primaryActions = computed(() => {
|
|
154
|
+
if (!props.actions) {
|
|
155
|
+
return [];
|
|
164
156
|
}
|
|
165
157
|
|
|
166
|
-
return
|
|
158
|
+
return cloneDeep(props.actions)
|
|
159
|
+
.sort(sortByColor(false))
|
|
160
|
+
.slice(0, maxActionsInternal.value)
|
|
161
|
+
.sort(sortByColor(true));
|
|
167
162
|
});
|
|
168
163
|
|
|
164
|
+
function sortByColor(reverse = false) {
|
|
165
|
+
const sortingArr = ['secondary', 'primary'];
|
|
166
|
+
|
|
167
|
+
return (a: ActionItem, b: ActionItem) => {
|
|
168
|
+
if (!reverse) {
|
|
169
|
+
return (
|
|
170
|
+
sortingArr.indexOf(b.color ?? '') - sortingArr.indexOf(a.color ?? '')
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
return (
|
|
174
|
+
sortingArr.indexOf(a.color ?? '') - sortingArr.indexOf(b.color ?? '')
|
|
175
|
+
);
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
169
179
|
const secondaryActions = computed(() => {
|
|
170
180
|
if (!props.actions) {
|
|
171
181
|
return [];
|
|
172
182
|
}
|
|
173
|
-
return props.actions?.filter((a, i) => i !== primaryActionIndex.value);
|
|
174
|
-
});
|
|
175
183
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
useResizeObserver(baseHeaderRef, () => {
|
|
180
|
-
width.value = baseHeaderRef.value?.clientWidth ?? 800;
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
const compactLayout = computed(() => {
|
|
184
|
-
if (props.layout === 'compact') {
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
|
-
return width.value < 500;
|
|
184
|
+
return props.actions.filter(
|
|
185
|
+
(a) => !primaryActions.value.map((a) => a.label).includes(a.label)
|
|
186
|
+
);
|
|
188
187
|
});
|
|
189
188
|
</script>
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
:class="[url ? 'duration-100 hover:bg-slate-100' : 'bg-white']"
|
|
9
9
|
>
|
|
10
10
|
<img
|
|
11
|
-
v-if="type == 'image' && url"
|
|
11
|
+
v-if="type == 'image' && url && previewImage"
|
|
12
12
|
:src="url"
|
|
13
13
|
class="h-full w-full bg-black object-contain object-center"
|
|
14
14
|
:alt="name"
|
|
15
15
|
/>
|
|
16
16
|
<img
|
|
17
|
-
v-else-if="type == 'image' && 'data_url' in media"
|
|
17
|
+
v-else-if="type == 'image' && 'data_url' in media && previewImage"
|
|
18
18
|
:src="media.data_url"
|
|
19
19
|
class="h-full w-full bg-black object-contain object-center"
|
|
20
20
|
:alt="name"
|
|
@@ -71,6 +71,10 @@ const props = defineProps({
|
|
|
71
71
|
default: true,
|
|
72
72
|
type: Boolean,
|
|
73
73
|
},
|
|
74
|
+
previewImage: {
|
|
75
|
+
default: true,
|
|
76
|
+
type: Boolean,
|
|
77
|
+
},
|
|
74
78
|
});
|
|
75
79
|
|
|
76
80
|
const name = computed(() => {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
<script lang="ts" setup>
|
|
14
14
|
import { PropType } from 'vue';
|
|
15
15
|
import BaseCounter from './BaseCounter.vue';
|
|
16
|
+
import { ActionColors } from '@/types';
|
|
16
17
|
|
|
17
18
|
const props = defineProps({
|
|
18
19
|
label: {
|
|
@@ -33,9 +34,7 @@ const props = defineProps({
|
|
|
33
34
|
},
|
|
34
35
|
color: {
|
|
35
36
|
default: 'dark',
|
|
36
|
-
type: String as PropType<
|
|
37
|
-
'dark' | 'light' | 'danger' | 'success' | 'warning' | 'primary'
|
|
38
|
-
>,
|
|
37
|
+
type: String as PropType<ActionColors>,
|
|
39
38
|
},
|
|
40
39
|
size: {
|
|
41
40
|
default: 'md',
|
|
@@ -56,6 +55,8 @@ const textColor = computed((): string => {
|
|
|
56
55
|
return 'text-yellow-600';
|
|
57
56
|
} else if (props.color == 'primary') {
|
|
58
57
|
return 'text-primary-600';
|
|
58
|
+
} else if (props.color == 'secondary') {
|
|
59
|
+
return 'text-slate-600';
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
return '';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import BaseSwitch from './BaseSwitch.vue';
|
|
2
2
|
import BaseContainer from './BaseContainer.vue';
|
|
3
3
|
import { createFieldStory } from '../../.storybook/utils';
|
|
4
|
+
import { Icon } from '@iconify/vue';
|
|
4
5
|
|
|
5
6
|
export default {
|
|
6
7
|
title: 'Form/BaseSwitch',
|
|
@@ -106,3 +107,25 @@ export const Field = createFieldStory({
|
|
|
106
107
|
componentName: 'BaseSwitch',
|
|
107
108
|
label: 'Activate',
|
|
108
109
|
});
|
|
110
|
+
|
|
111
|
+
const Icons = (args) => ({
|
|
112
|
+
components: {
|
|
113
|
+
BaseSwitch,
|
|
114
|
+
BaseContainer,
|
|
115
|
+
},
|
|
116
|
+
setup() {
|
|
117
|
+
const value = ref(true);
|
|
118
|
+
return { args, value };
|
|
119
|
+
},
|
|
120
|
+
template: `
|
|
121
|
+
<BaseSwitch v-model="value" v-bind="args">
|
|
122
|
+
<span class="text-slate-600">Label</span>
|
|
123
|
+
</BaseSwitch>
|
|
124
|
+
`,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
export const WithIcons = Icons.bind({});
|
|
128
|
+
WithIcons.args = {
|
|
129
|
+
checkedIcon: 'heroicons-solid:check',
|
|
130
|
+
unCheckedIcon: 'heroicons-solid:x',
|
|
131
|
+
};
|
|
@@ -20,9 +20,12 @@
|
|
|
20
20
|
height: sizePx + 'px',
|
|
21
21
|
width: sizePx + 'px',
|
|
22
22
|
transform: `translateX(${translateX}px)`,
|
|
23
|
+
fontSize: sizePx - 7 + 'px',
|
|
23
24
|
}"
|
|
24
|
-
class="
|
|
25
|
-
|
|
25
|
+
class="flex items-center justify-center transition duration-200 ease-in-out bg-white rounded-full shadow pointer-events-none text-slate-500 ring-0"
|
|
26
|
+
>
|
|
27
|
+
<BaseIcon v-if="icon" :icon="icon" />
|
|
28
|
+
</span>
|
|
26
29
|
</Switch>
|
|
27
30
|
<SwitchLabel v-if="$slots.default" class="cursor-pointer">
|
|
28
31
|
<slot />
|
|
@@ -66,6 +69,14 @@ const props = defineProps({
|
|
|
66
69
|
default: false,
|
|
67
70
|
type: Boolean,
|
|
68
71
|
},
|
|
72
|
+
checkedIcon: {
|
|
73
|
+
default: '',
|
|
74
|
+
type: String,
|
|
75
|
+
},
|
|
76
|
+
unCheckedIcon: {
|
|
77
|
+
default: '',
|
|
78
|
+
type: String,
|
|
79
|
+
},
|
|
69
80
|
});
|
|
70
81
|
|
|
71
82
|
const emit = defineEmits(['update:modelValue']);
|
|
@@ -182,6 +193,16 @@ const translateX = computed(() => {
|
|
|
182
193
|
return padding.value;
|
|
183
194
|
});
|
|
184
195
|
|
|
196
|
+
const icon = computed(() => {
|
|
197
|
+
if (props.modelValue && props.checkedIcon) {
|
|
198
|
+
return props.checkedIcon;
|
|
199
|
+
}
|
|
200
|
+
if (!props.modelValue && props.unCheckedIcon) {
|
|
201
|
+
return props.unCheckedIcon;
|
|
202
|
+
}
|
|
203
|
+
return null;
|
|
204
|
+
});
|
|
205
|
+
|
|
185
206
|
function update(payload: any) {
|
|
186
207
|
emitUpdate(payload);
|
|
187
208
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -65,6 +65,15 @@ export interface PaginatedCollection extends PaginationMetadata {
|
|
|
65
65
|
data: Collection;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
export type ActionColors =
|
|
69
|
+
| 'dark'
|
|
70
|
+
| 'light'
|
|
71
|
+
| 'danger'
|
|
72
|
+
| 'success'
|
|
73
|
+
| 'warning'
|
|
74
|
+
| 'primary'
|
|
75
|
+
| 'secondary';
|
|
76
|
+
|
|
68
77
|
export interface MenuItemInterface {
|
|
69
78
|
label?: string;
|
|
70
79
|
href?: string;
|
|
@@ -72,7 +81,7 @@ export interface MenuItemInterface {
|
|
|
72
81
|
action?: () => Promise<void> | void;
|
|
73
82
|
icon?: string;
|
|
74
83
|
count?: number;
|
|
75
|
-
color?:
|
|
84
|
+
color?: ActionColors;
|
|
76
85
|
line?: boolean;
|
|
77
86
|
}
|
|
78
87
|
|
|
@@ -83,7 +92,7 @@ export interface ActionItem {
|
|
|
83
92
|
action?: () => Promise<void> | void;
|
|
84
93
|
icon?: string;
|
|
85
94
|
count?: number;
|
|
86
|
-
color?:
|
|
95
|
+
color?: ActionColors;
|
|
87
96
|
disabled?: boolean;
|
|
88
97
|
meta?: Record<string, any>;
|
|
89
98
|
actions?: ActionItem[];
|