sprintify-ui 0.1.14 → 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 +3487 -3535
- 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/BaseMenuItem.vue.d.ts +4 -3
- package/dist/types/src/components/BaseSwitch.vue.d.ts +0 -27
- 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/BaseMenuItem.vue +4 -3
- package/src/components/BaseSwitch.stories.js +5 -2
- package/src/components/BaseSwitch.vue +9 -36
- 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;
|
|
@@ -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,10 +24,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
24
24
|
default: boolean;
|
|
25
25
|
type: BooleanConstructor;
|
|
26
26
|
};
|
|
27
|
-
hasIcon: {
|
|
28
|
-
default: boolean;
|
|
29
|
-
type: BooleanConstructor;
|
|
30
|
-
};
|
|
31
27
|
checkedIcon: {
|
|
32
28
|
default: string;
|
|
33
29
|
type: StringConstructor;
|
|
@@ -36,14 +32,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
36
32
|
default: string;
|
|
37
33
|
type: StringConstructor;
|
|
38
34
|
};
|
|
39
|
-
checkedIconColor: {
|
|
40
|
-
default: string;
|
|
41
|
-
type: StringConstructor;
|
|
42
|
-
};
|
|
43
|
-
unCheckedIconColor: {
|
|
44
|
-
default: string;
|
|
45
|
-
type: StringConstructor;
|
|
46
|
-
};
|
|
47
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<{
|
|
48
36
|
modelValue: {
|
|
49
37
|
default: boolean;
|
|
@@ -69,10 +57,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
69
57
|
default: boolean;
|
|
70
58
|
type: BooleanConstructor;
|
|
71
59
|
};
|
|
72
|
-
hasIcon: {
|
|
73
|
-
default: boolean;
|
|
74
|
-
type: BooleanConstructor;
|
|
75
|
-
};
|
|
76
60
|
checkedIcon: {
|
|
77
61
|
default: string;
|
|
78
62
|
type: StringConstructor;
|
|
@@ -81,14 +65,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
81
65
|
default: string;
|
|
82
66
|
type: StringConstructor;
|
|
83
67
|
};
|
|
84
|
-
checkedIconColor: {
|
|
85
|
-
default: string;
|
|
86
|
-
type: StringConstructor;
|
|
87
|
-
};
|
|
88
|
-
unCheckedIconColor: {
|
|
89
|
-
default: string;
|
|
90
|
-
type: StringConstructor;
|
|
91
|
-
};
|
|
92
68
|
}>> & {
|
|
93
69
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
94
70
|
}, {
|
|
@@ -98,11 +74,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
|
98
74
|
modelValue: string | number | boolean | null | undefined;
|
|
99
75
|
hasError: boolean;
|
|
100
76
|
size: "base" | "xs" | "sm" | "lg" | "xl";
|
|
101
|
-
hasIcon: boolean;
|
|
102
77
|
checkedIcon: string;
|
|
103
78
|
unCheckedIcon: string;
|
|
104
|
-
checkedIconColor: string;
|
|
105
|
-
unCheckedIconColor: string;
|
|
106
79
|
}>, {
|
|
107
80
|
default: (_: {}) => any;
|
|
108
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>
|
|
@@ -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 '';
|
|
@@ -118,11 +118,14 @@ const Icons = (args) => ({
|
|
|
118
118
|
return { args, value };
|
|
119
119
|
},
|
|
120
120
|
template: `
|
|
121
|
-
<BaseSwitch v-model="value"
|
|
121
|
+
<BaseSwitch v-model="value" v-bind="args">
|
|
122
122
|
<span class="text-slate-600">Label</span>
|
|
123
123
|
</BaseSwitch>
|
|
124
124
|
`,
|
|
125
125
|
});
|
|
126
126
|
|
|
127
127
|
export const WithIcons = Icons.bind({});
|
|
128
|
-
WithIcons.args = {
|
|
128
|
+
WithIcons.args = {
|
|
129
|
+
checkedIcon: 'heroicons-solid:check',
|
|
130
|
+
unCheckedIcon: 'heroicons-solid:x',
|
|
131
|
+
};
|
|
@@ -20,12 +20,11 @@
|
|
|
20
20
|
height: sizePx + 'px',
|
|
21
21
|
width: sizePx + 'px',
|
|
22
22
|
transform: `translateX(${translateX}px)`,
|
|
23
|
-
color: iconColor,
|
|
24
23
|
fontSize: sizePx - 7 + 'px',
|
|
25
24
|
}"
|
|
26
|
-
class="flex items-center justify-center
|
|
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"
|
|
27
26
|
>
|
|
28
|
-
<BaseIcon v-if="
|
|
27
|
+
<BaseIcon v-if="icon" :icon="icon" />
|
|
29
28
|
</span>
|
|
30
29
|
</Switch>
|
|
31
30
|
<SwitchLabel v-if="$slots.default" class="cursor-pointer">
|
|
@@ -70,24 +69,12 @@ const props = defineProps({
|
|
|
70
69
|
default: false,
|
|
71
70
|
type: Boolean,
|
|
72
71
|
},
|
|
73
|
-
hasIcon: {
|
|
74
|
-
default: false,
|
|
75
|
-
type: Boolean,
|
|
76
|
-
},
|
|
77
72
|
checkedIcon: {
|
|
78
|
-
default: '
|
|
73
|
+
default: '',
|
|
79
74
|
type: String,
|
|
80
75
|
},
|
|
81
76
|
unCheckedIcon: {
|
|
82
|
-
default: '
|
|
83
|
-
type: String,
|
|
84
|
-
},
|
|
85
|
-
checkedIconColor: {
|
|
86
|
-
default: '#9ca3af',
|
|
87
|
-
type: String,
|
|
88
|
-
},
|
|
89
|
-
unCheckedIconColor: {
|
|
90
|
-
default: '#9ca3af',
|
|
77
|
+
default: '',
|
|
91
78
|
type: String,
|
|
92
79
|
},
|
|
93
80
|
});
|
|
@@ -206,26 +193,12 @@ const translateX = computed(() => {
|
|
|
206
193
|
return padding.value;
|
|
207
194
|
});
|
|
208
195
|
|
|
209
|
-
const iconColor = computed(() => {
|
|
210
|
-
if (props.hasIcon) {
|
|
211
|
-
if (props.modelValue) {
|
|
212
|
-
return props.checkedIconColor;
|
|
213
|
-
}
|
|
214
|
-
if (!props.modelValue) {
|
|
215
|
-
return props.unCheckedIconColor;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return '';
|
|
219
|
-
});
|
|
220
|
-
|
|
221
196
|
const icon = computed(() => {
|
|
222
|
-
if (props.
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
return props.unCheckedIcon;
|
|
228
|
-
}
|
|
197
|
+
if (props.modelValue && props.checkedIcon) {
|
|
198
|
+
return props.checkedIcon;
|
|
199
|
+
}
|
|
200
|
+
if (!props.modelValue && props.unCheckedIcon) {
|
|
201
|
+
return props.unCheckedIcon;
|
|
229
202
|
}
|
|
230
203
|
return null;
|
|
231
204
|
});
|
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[];
|