@mptw/skylens-ui 1.0.0
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/.editorconfig +12 -0
- package/.eslintrc.cjs +4 -0
- package/.nuxtrc +1 -0
- package/.playground/app.config.ts +5 -0
- package/.playground/nuxt.config.ts +3 -0
- package/README.md +73 -0
- package/app.config.ts +5 -0
- package/app.vue +3 -0
- package/assets/css/fonts/MEShPlus-font-icon.eot +0 -0
- package/assets/css/fonts/MEShPlus-font-icon.svg +186 -0
- package/assets/css/fonts/MEShPlus-font-icon.ttf +0 -0
- package/assets/css/fonts/MEShPlus-font-icon.woff +0 -0
- package/assets/css/icons.css +555 -0
- package/assets/css/layout.styl +98 -0
- package/assets/css/tailwind.css +3 -0
- package/assets/images/commons/app-logo-white.png +0 -0
- package/assets/images/commons/app-logo.png +0 -0
- package/assets/images/commons/empty-box.png +0 -0
- package/assets/images/commons/watermark.svg +15 -0
- package/components/SLAlertModal.vue +99 -0
- package/components/SLBreadcrumbs.vue +42 -0
- package/components/SLButton.vue +301 -0
- package/components/SLCalendarButton.vue +259 -0
- package/components/SLCalendarPopup.vue +832 -0
- package/components/SLCard.vue +118 -0
- package/components/SLChart.vue +181 -0
- package/components/SLCheckbox.vue +179 -0
- package/components/SLCircleButton.vue +95 -0
- package/components/SLCollapsableBlock.vue +116 -0
- package/components/SLCollapsableMulitPillSelect.vue +92 -0
- package/components/SLConfirmModal.vue +122 -0
- package/components/SLDateInput.vue +460 -0
- package/components/SLDatePicker.vue +143 -0
- package/components/SLDistributor.vue +30 -0
- package/components/SLDownloadButton.vue +410 -0
- package/components/SLDraggable.vue +151 -0
- package/components/SLDropdown.vue +277 -0
- package/components/SLDropdownItem.vue +31 -0
- package/components/SLElementWithTitle.vue +181 -0
- package/components/SLEyeCheckbox.vue +162 -0
- package/components/SLFileInput.vue +101 -0
- package/components/SLGenderAgeSelect.vue +279 -0
- package/components/SLHeatMap.vue +151 -0
- package/components/SLHourRangeInput.vue +211 -0
- package/components/SLIOSSwitch.vue +235 -0
- package/components/SLIcon.vue +35 -0
- package/components/SLIconButton.vue +130 -0
- package/components/SLInfoTip.vue +221 -0
- package/components/SLInsightSitePage.vue +27 -0
- package/components/SLLegend.vue +76 -0
- package/components/SLLinearProgressBar.vue +35 -0
- package/components/SLLink.vue +162 -0
- package/components/SLLoading.vue +127 -0
- package/components/SLMapChart.vue +151 -0
- package/components/SLModal.vue +377 -0
- package/components/SLMonthCalendarButton.vue +378 -0
- package/components/SLMonthPicker.vue +151 -0
- package/components/SLMultiSelect.vue +121 -0
- package/components/SLNoData.vue +43 -0
- package/components/SLPageModal.vue +64 -0
- package/components/SLPagination.vue +192 -0
- package/components/SLPillCheckbox.vue +207 -0
- package/components/SLPillLabel.vue +101 -0
- package/components/SLPopupMenuButton.vue +158 -0
- package/components/SLProfileButton.vue +186 -0
- package/components/SLRadioButton.vue +97 -0
- package/components/SLRadioButtonGroup.vue +113 -0
- package/components/SLRadioGroup.vue +201 -0
- package/components/SLRangeInput.vue +209 -0
- package/components/SLRegionsMapChart.vue +151 -0
- package/components/SLRightSider.vue +242 -0
- package/components/SLSearchInput.vue +87 -0
- package/components/SLSelect.vue +545 -0
- package/components/SLSelectAllToggle.vue +118 -0
- package/components/SLSiderbarNav.vue +394 -0
- package/components/SLSiderbarNavItem.vue +204 -0
- package/components/SLSitePage.vue +96 -0
- package/components/SLSkyInsightSitePage.vue +27 -0
- package/components/SLSortByDropdown.vue +189 -0
- package/components/SLSpinIcon.vue +24 -0
- package/components/SLStayRangeInput.vue +306 -0
- package/components/SLTab.vue +159 -0
- package/components/SLTable.vue +409 -0
- package/components/SLTableTooltip.vue +111 -0
- package/components/SLTabs.vue +388 -0
- package/components/SLTextInput.vue +362 -0
- package/components/SLTextarea.vue +134 -0
- package/components/SLToast.vue +71 -0
- package/components/SLToggleButton.vue +78 -0
- package/components/SLTwoLayerMultiSelect.vue +428 -0
- package/components/SLTwoLayerSelect.vue +265 -0
- package/components/SLWarnModal.vue +75 -0
- package/interface/IDateRange.ts +5 -0
- package/interface/IHourRange.ts +4 -0
- package/interface/IInputOption.ts +6 -0
- package/interface/ILegendItem.ts +7 -0
- package/interface/IPopupMenuButton.ts +5 -0
- package/interface/IStayRange.ts +15 -0
- package/interface/ITableField.ts +19 -0
- package/interface/IWeb.ts +5 -0
- package/interface/NavConfigType.ts +14 -0
- package/interface/commons.ts +7 -0
- package/models/DateRange.ts +21 -0
- package/nuxt.config.ts +22 -0
- package/package.json +52 -0
- package/plugins/googlemaps.ts +17 -0
- package/plugins/v-calendar.ts +5 -0
- package/public/assets/files/taiwan-regions.json +7 -0
- package/public/assets/files/taiwan.json +24 -0
- package/public/assets/images/commons/default-favico.png +0 -0
- package/public/assets/images/dashboard/closure-button-icon.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-bar-chart-icon-disabled.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-bar-chart-icon-poi.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-bar-chart-icon-web.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-country-heatmap-chart-icon-disabled.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-country-heatmap-chart-icon.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-geo-list-icon-disabled.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-geo-list-icon-poi.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-geo-list-icon-web.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-heatmap-chart-icon-disabled.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-heatmap-chart-icon-web.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-line-chart-icon-disabled.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-line-chart-icon-poi.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-list-icon-disabled.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-list-icon-poi.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-list-icon-web.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-pie-chart-icon-disabled.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-pie-chart-icon-poi.png +0 -0
- package/public/assets/images/dashboard/dashboard-widget-pie-chart-icon-web.png +0 -0
- package/public/assets/images/dashboard/drag-hint-icon.svg +3 -0
- package/public/assets/images/dashboard/extend-button-icon.png +0 -0
- package/public/assets/images/dashboard/map-list-chart-icon.svg +17 -0
- package/public/assets/images/dashboard/map-marker-chart-icon.svg +32 -0
- package/public/assets/images/dashboard/pie-chart-icon.svg +4 -0
- package/public/assets/images/dashboard/poi-gender-age-chart-icon.svg +20 -0
- package/public/assets/images/dashboard/poi-nav-icon.png +0 -0
- package/public/assets/images/dashboard/web-gender-age-chart-icon.svg +20 -0
- package/public/assets/images/dashboard/web-nav-icon.png +0 -0
- package/tailwind.config.js +300 -0
- package/tsconfig.json +8 -0
- package/utils/constants.ts +160 -0
- package/utils/generateSheet.ts +36 -0
- package/utils/index.ts +539 -0
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
<template lang="pug">
|
|
2
|
+
.profile-button(ref='el')
|
|
3
|
+
a(
|
|
4
|
+
href="javascript:;"
|
|
5
|
+
@click.stop.prevent="onClickedToggle"
|
|
6
|
+
ref="toggleEl"
|
|
7
|
+
).btn.toggle-button {{ title }}
|
|
8
|
+
ClientOnly
|
|
9
|
+
Teleport(to="body")
|
|
10
|
+
.profile-nav-popup(ref="popupEl")
|
|
11
|
+
.profile-nav-popup-body
|
|
12
|
+
a(
|
|
13
|
+
v-if="showEditProfile"
|
|
14
|
+
href="javascript:;"
|
|
15
|
+
@click="onClickedEdit"
|
|
16
|
+
).profile-nav-item
|
|
17
|
+
SLIcon(icon="person-cog")
|
|
18
|
+
span 個人資料維護
|
|
19
|
+
.profile-nav-divider(v-if="showEditProfile")
|
|
20
|
+
a(href="javascript:;" @click="onClickedLogout").profile-nav-item
|
|
21
|
+
SLIcon(icon="sign-out-alt")
|
|
22
|
+
span 登出
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script lang="ts">
|
|
26
|
+
import { fromEvent } from "rxjs";
|
|
27
|
+
import { createPopper } from "@popperjs/core";
|
|
28
|
+
|
|
29
|
+
export default defineComponent({
|
|
30
|
+
name: "SLProfileButton",
|
|
31
|
+
components: {},
|
|
32
|
+
props: {
|
|
33
|
+
username: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: "SKYLENS",
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
emits: ["edit", "logout"],
|
|
39
|
+
setup(props, { emit }) {
|
|
40
|
+
const { username } = toRefs(props);
|
|
41
|
+
|
|
42
|
+
const el = shallowRef<HTMLElement | null>(null);
|
|
43
|
+
const toggleEl = shallowRef<HTMLElement | null>(null);
|
|
44
|
+
const popupEl = shallowRef<HTMLElement | null>(null);
|
|
45
|
+
|
|
46
|
+
let popperInstance: any = null;
|
|
47
|
+
let clickSubscriber: any = null;
|
|
48
|
+
|
|
49
|
+
const title = computed(() => {
|
|
50
|
+
if (username.value === "") {
|
|
51
|
+
return "";
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return username.value.slice(0, 1);
|
|
55
|
+
});
|
|
56
|
+
const showEditProfile = computed(() => {
|
|
57
|
+
// return $acl.can('/application/profile/edit');
|
|
58
|
+
return true;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
function onClickedToggle() {
|
|
62
|
+
if (!popupEl.value || popupEl.value.getAttribute("data-show") !== null) {
|
|
63
|
+
hide();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
show();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function subscribeClick() {
|
|
71
|
+
clickSubscriber = fromEvent(window, "click").subscribe((e) => {
|
|
72
|
+
const { target } = e;
|
|
73
|
+
if (el.value && !el.value.contains(target as HTMLElement)) {
|
|
74
|
+
hide();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function unsubscribeClick() {
|
|
80
|
+
if (clickSubscriber) {
|
|
81
|
+
clickSubscriber.unsubscribe();
|
|
82
|
+
}
|
|
83
|
+
clickSubscriber = null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function show() {
|
|
87
|
+
subscribeClick();
|
|
88
|
+
if (popupEl.value) {
|
|
89
|
+
popupEl.value.setAttribute("data-show", "");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
popperInstance.setOptions({
|
|
93
|
+
strategy: "fixed",
|
|
94
|
+
modifiers: [
|
|
95
|
+
{
|
|
96
|
+
name: "offset",
|
|
97
|
+
options: {
|
|
98
|
+
offset: [0, 8],
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{ name: "eventListeners", enabled: true },
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
popperInstance.update();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function hide() {
|
|
109
|
+
if (popupEl.value && popupEl.value.getAttribute("data-show") === null)
|
|
110
|
+
return;
|
|
111
|
+
|
|
112
|
+
unsubscribeClick();
|
|
113
|
+
|
|
114
|
+
if (popupEl.value) {
|
|
115
|
+
popupEl.value.removeAttribute("data-show");
|
|
116
|
+
}
|
|
117
|
+
popperInstance.setOptions({
|
|
118
|
+
modifiers: [{ name: "eventListeners", enabled: false }],
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function onClickedEdit() {
|
|
123
|
+
emit("edit");
|
|
124
|
+
hide();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function onClickedLogout() {
|
|
128
|
+
emit("logout");
|
|
129
|
+
hide();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
onMounted(() => {
|
|
133
|
+
nextTick(() => {
|
|
134
|
+
if (toggleEl.value && popupEl.value) {
|
|
135
|
+
popperInstance = createPopper(toggleEl.value, popupEl.value, {
|
|
136
|
+
placement: "bottom-end",
|
|
137
|
+
modifiers: [{ name: "eventListeners", enabled: false }],
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
onBeforeUnmount(() => {
|
|
143
|
+
if (popperInstance) {
|
|
144
|
+
popperInstance.destroy();
|
|
145
|
+
}
|
|
146
|
+
popperInstance = null;
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
el,
|
|
151
|
+
toggleEl,
|
|
152
|
+
popupEl,
|
|
153
|
+
title,
|
|
154
|
+
showEditProfile,
|
|
155
|
+
onClickedToggle,
|
|
156
|
+
subscribeClick,
|
|
157
|
+
unsubscribeClick,
|
|
158
|
+
show,
|
|
159
|
+
hide,
|
|
160
|
+
onClickedEdit,
|
|
161
|
+
onClickedLogout,
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
</script>
|
|
166
|
+
|
|
167
|
+
<style lang="stylus">
|
|
168
|
+
.profile-button
|
|
169
|
+
.toggle-button
|
|
170
|
+
@apply inline-flex items-center justify-center w-10 h-10 p-0 rounded-full s('bg-primary/80') s('text-2.67xl') s('leading-9.25') text-card-primary-light font-bold
|
|
171
|
+
|
|
172
|
+
.profile-nav-popup
|
|
173
|
+
@apply z-60 absolute s('min-w-[10.25rem]') p-4 border border-primary bg-bg-middle rounded shadow-popup-lg pointer-events-none invisible
|
|
174
|
+
|
|
175
|
+
&[data-show]
|
|
176
|
+
@apply visible pointer-events-auto
|
|
177
|
+
|
|
178
|
+
&-body
|
|
179
|
+
@apply flex flex-col space-y-2
|
|
180
|
+
|
|
181
|
+
.profile-nav-item
|
|
182
|
+
@apply inline-flex items-center space-x-2 text-base text-primary-hover s('hover:text-primary')
|
|
183
|
+
|
|
184
|
+
.profile-nav-divider
|
|
185
|
+
@apply w-full h-px bg-border
|
|
186
|
+
</style>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<template lang="pug">
|
|
2
|
+
.radio-button
|
|
3
|
+
input(
|
|
4
|
+
type="radio"
|
|
5
|
+
:id="uid"
|
|
6
|
+
:checked="isEqual(value, modelValue)"
|
|
7
|
+
:value="value"
|
|
8
|
+
:disabled="disabled"
|
|
9
|
+
@change="onChanged"
|
|
10
|
+
)
|
|
11
|
+
label(:for="uid")
|
|
12
|
+
SLIcon(icon="circle")
|
|
13
|
+
SLIcon(icon="dot-circle")
|
|
14
|
+
span(v-if="label !== ''") {{ label }}
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script lang="ts">
|
|
18
|
+
import { isEqual } from "lodash-es";
|
|
19
|
+
import { getUID } from "~ui/utils";
|
|
20
|
+
|
|
21
|
+
export default defineComponent({
|
|
22
|
+
name: "SLRadioButton",
|
|
23
|
+
components: {},
|
|
24
|
+
props: {
|
|
25
|
+
modelValue: {
|
|
26
|
+
type: [Number, String, Boolean, Object],
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
label: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: "",
|
|
32
|
+
},
|
|
33
|
+
value: {
|
|
34
|
+
type: [Number, String, Boolean, Object],
|
|
35
|
+
required: true,
|
|
36
|
+
},
|
|
37
|
+
disabled: {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
default: false,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
emits: ["update:modelValue"],
|
|
43
|
+
setup(props, { emit }) {
|
|
44
|
+
const { value } = toRefs(props);
|
|
45
|
+
const uid = ref<string | undefined>(undefined);
|
|
46
|
+
|
|
47
|
+
function onChanged() {
|
|
48
|
+
emit("update:modelValue", value.value);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
onMounted(() => {
|
|
52
|
+
uid.value = getUID();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
uid,
|
|
57
|
+
isEqual,
|
|
58
|
+
onChanged,
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<style lang="stylus">
|
|
65
|
+
.radio-button
|
|
66
|
+
@apply inline-block relative text-base overflow-hidden
|
|
67
|
+
|
|
68
|
+
input
|
|
69
|
+
@apply absolute s('-top-10') s('-left-10')
|
|
70
|
+
|
|
71
|
+
label
|
|
72
|
+
@apply relative inline-flex items-center text-base s('leading-4.5') text-gray-3 cursor-pointer
|
|
73
|
+
|
|
74
|
+
.icon
|
|
75
|
+
@apply hidden
|
|
76
|
+
|
|
77
|
+
span
|
|
78
|
+
@apply ml-1 text-base text-gray-2
|
|
79
|
+
|
|
80
|
+
input:not(:checked) + label
|
|
81
|
+
.icon-circle
|
|
82
|
+
@apply inline-block text-primary
|
|
83
|
+
|
|
84
|
+
input:checked + label
|
|
85
|
+
.icon-dot-circle
|
|
86
|
+
@apply inline-block text-primary
|
|
87
|
+
|
|
88
|
+
input:disabled + label
|
|
89
|
+
span
|
|
90
|
+
@apply text-gray-3
|
|
91
|
+
|
|
92
|
+
.icon-circle
|
|
93
|
+
@apply text-gray-3
|
|
94
|
+
|
|
95
|
+
.icon-dot-circle
|
|
96
|
+
@apply text-gray-3
|
|
97
|
+
</style>
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<template lang="pug">
|
|
2
|
+
.radio-button-group(:class='{ "radio-button-group--lg": size === "lg" }')
|
|
3
|
+
label(v-if="label !== ''") {{ label }}
|
|
4
|
+
.form-control(
|
|
5
|
+
:class="{ 'is-invalid': isInvalid !== null && isInvalid, 'is-valid': isInvalid !== null && !isInvalid, inline: radioInline }"
|
|
6
|
+
)
|
|
7
|
+
SLRadioButton(
|
|
8
|
+
v-for="option, i in options"
|
|
9
|
+
v-model="modelProxy"
|
|
10
|
+
:label="option.label"
|
|
11
|
+
:value="option.value"
|
|
12
|
+
:key="i"
|
|
13
|
+
:disabled='disabled || option.disabled'
|
|
14
|
+
)
|
|
15
|
+
.invalid-feedback
|
|
16
|
+
slot(name="invalid-feedback") {{ invalidFeedback }}
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script lang="ts">
|
|
20
|
+
import type { PropType } from "vue";
|
|
21
|
+
import type IInputOption from "~ui/interface/IInputOption";
|
|
22
|
+
|
|
23
|
+
export default defineComponent({
|
|
24
|
+
name: "SLRadioButtonGroup",
|
|
25
|
+
components: {},
|
|
26
|
+
props: {
|
|
27
|
+
modelValue: {
|
|
28
|
+
type: [Number, String, Boolean, Object],
|
|
29
|
+
required: true,
|
|
30
|
+
},
|
|
31
|
+
label: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: "",
|
|
34
|
+
},
|
|
35
|
+
options: {
|
|
36
|
+
type: Array as PropType<Array<IInputOption>>,
|
|
37
|
+
default: () => [],
|
|
38
|
+
},
|
|
39
|
+
inline: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: false,
|
|
42
|
+
},
|
|
43
|
+
radioInline: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: true,
|
|
46
|
+
},
|
|
47
|
+
isInvalid: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: false,
|
|
50
|
+
},
|
|
51
|
+
invalidFeedback: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: "",
|
|
54
|
+
},
|
|
55
|
+
disabled: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: false,
|
|
58
|
+
},
|
|
59
|
+
size: {
|
|
60
|
+
type: String as PropType<"" | "lg">,
|
|
61
|
+
default: "",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
emits: ["update:modelValue"],
|
|
65
|
+
setup(props, { emit }) {
|
|
66
|
+
const { modelValue } = toRefs(props);
|
|
67
|
+
|
|
68
|
+
const modelProxy = ref(modelValue.value);
|
|
69
|
+
|
|
70
|
+
watch(modelValue, () => {
|
|
71
|
+
modelProxy.value = modelValue.value;
|
|
72
|
+
});
|
|
73
|
+
watch(modelProxy, () => {
|
|
74
|
+
emit("update:modelValue", modelProxy.value);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
modelProxy,
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<style lang="stylus">
|
|
85
|
+
.radio-button-group
|
|
86
|
+
.is-invalid
|
|
87
|
+
.invalid-feedback
|
|
88
|
+
@apply block
|
|
89
|
+
|
|
90
|
+
& > label
|
|
91
|
+
@apply mb-2 text-base text-gray-2 align-top
|
|
92
|
+
|
|
93
|
+
.form-control
|
|
94
|
+
@apply flex flex-col space-y-1
|
|
95
|
+
|
|
96
|
+
&.inline
|
|
97
|
+
@apply flex flex-row flex-wrap space-x-6 space-y-0
|
|
98
|
+
|
|
99
|
+
.invalid-feedback
|
|
100
|
+
@apply hidden text-danger text-xs
|
|
101
|
+
|
|
102
|
+
&--lg
|
|
103
|
+
.form-control
|
|
104
|
+
&.inline
|
|
105
|
+
@apply space-x-8
|
|
106
|
+
|
|
107
|
+
.radio-button
|
|
108
|
+
label
|
|
109
|
+
@apply text-sm
|
|
110
|
+
|
|
111
|
+
span
|
|
112
|
+
@apply ml-2 text-sm
|
|
113
|
+
</style>
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
<template lang="pug">
|
|
2
|
+
SLElementWithTitle(:title='disabled ? disabledHint : ""')
|
|
3
|
+
.radio-group(:class='sizeClass')
|
|
4
|
+
.radio(v-for="option, i in options")
|
|
5
|
+
input(
|
|
6
|
+
type="radio"
|
|
7
|
+
:id="uids[i]"
|
|
8
|
+
:checked="modelValue === option.value"
|
|
9
|
+
:disabled="disabled"
|
|
10
|
+
)
|
|
11
|
+
label(@click="onClickedRadio(option.value)")
|
|
12
|
+
span(v-if='option.label') {{ option.label }}
|
|
13
|
+
SLIcon(v-if='option.icon' :icon='option.icon')
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
import type { PropType } from "vue";
|
|
18
|
+
import { getUID } from "~ui/utils";
|
|
19
|
+
import type IInputOption from "~ui/interface/IInputOption";
|
|
20
|
+
|
|
21
|
+
export default defineComponent({
|
|
22
|
+
name: "SLRadioGroup",
|
|
23
|
+
props: {
|
|
24
|
+
modelValue: {
|
|
25
|
+
type: [Number, String, Boolean],
|
|
26
|
+
default: null,
|
|
27
|
+
},
|
|
28
|
+
options: {
|
|
29
|
+
type: Array as PropType<Array<IInputOption>>,
|
|
30
|
+
default: () => [],
|
|
31
|
+
},
|
|
32
|
+
disabled: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: false,
|
|
35
|
+
},
|
|
36
|
+
disabledHint: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: "",
|
|
39
|
+
},
|
|
40
|
+
size: {
|
|
41
|
+
type: String,
|
|
42
|
+
default: "",
|
|
43
|
+
validator: (val: string) =>
|
|
44
|
+
["", "md", "sm", "xs", "xxs", "3xs"].includes(val),
|
|
45
|
+
},
|
|
46
|
+
color: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: "",
|
|
49
|
+
},
|
|
50
|
+
colorInvert: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
emits: ["update:modelValue"],
|
|
56
|
+
setup(props, { emit }) {
|
|
57
|
+
const { size, color, colorInvert, options, disabled } = toRefs(props);
|
|
58
|
+
|
|
59
|
+
const uids = ref<Array<string>>([]);
|
|
60
|
+
|
|
61
|
+
const sizeClass = computed(() => {
|
|
62
|
+
const classes = [];
|
|
63
|
+
if (size.value !== "") {
|
|
64
|
+
classes.push(`radio-group--${size.value}`);
|
|
65
|
+
}
|
|
66
|
+
if (color.value !== "") {
|
|
67
|
+
classes.push(`radio-group--${color.value}`);
|
|
68
|
+
}
|
|
69
|
+
if (colorInvert.value) {
|
|
70
|
+
classes.push("color-invert");
|
|
71
|
+
}
|
|
72
|
+
if (disabled.value) {
|
|
73
|
+
classes.push("disabled");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return classes.join(" ");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
function onChanged(e: Event, targetValue: any) {
|
|
80
|
+
const { target } = e;
|
|
81
|
+
if ((target as HTMLInputElement).checked) {
|
|
82
|
+
emit("update:modelValue", targetValue);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function onClickedRadio(targetValue: any) {
|
|
87
|
+
if (disabled.value) return;
|
|
88
|
+
|
|
89
|
+
emit("update:modelValue", targetValue);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
onMounted(() => {
|
|
93
|
+
uids.value = options.value.map(() => getUID());
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
uids,
|
|
98
|
+
sizeClass,
|
|
99
|
+
onChanged,
|
|
100
|
+
onClickedRadio,
|
|
101
|
+
};
|
|
102
|
+
},
|
|
103
|
+
});
|
|
104
|
+
</script>
|
|
105
|
+
|
|
106
|
+
<style lang="stylus">
|
|
107
|
+
.radio-group
|
|
108
|
+
@apply inline-flex s('p-0.5') bg-bg border border-line rounded
|
|
109
|
+
|
|
110
|
+
&.radio-group--sm
|
|
111
|
+
.radio
|
|
112
|
+
label
|
|
113
|
+
@apply min-w-0 px-2 s('py-1.5')
|
|
114
|
+
|
|
115
|
+
&.radio-group--xs
|
|
116
|
+
.radio
|
|
117
|
+
label
|
|
118
|
+
@apply min-w-0 px-4 s('py-0.5') text-sm
|
|
119
|
+
|
|
120
|
+
&.radio-group--xxs
|
|
121
|
+
@apply s('p-0.75')
|
|
122
|
+
|
|
123
|
+
.radio
|
|
124
|
+
label
|
|
125
|
+
@apply min-w-0 px-2 s('py-0.75') text-sm
|
|
126
|
+
|
|
127
|
+
&.radio-group--3xs
|
|
128
|
+
@apply s('p-0.75')
|
|
129
|
+
|
|
130
|
+
.radio
|
|
131
|
+
label
|
|
132
|
+
@apply min-w-0 px-2 py-px text-sm
|
|
133
|
+
|
|
134
|
+
&.radio-group--third-hover
|
|
135
|
+
@apply bg-third-hover border-third
|
|
136
|
+
|
|
137
|
+
.radio
|
|
138
|
+
label
|
|
139
|
+
@apply bg-third-hover text-white
|
|
140
|
+
|
|
141
|
+
input:checked + label
|
|
142
|
+
@apply text-third-7
|
|
143
|
+
|
|
144
|
+
&.radio-group--edit-purple
|
|
145
|
+
@apply bg-edit-purple border-primary
|
|
146
|
+
|
|
147
|
+
&.color-invert
|
|
148
|
+
@apply bg-card-lightpr-bg border-primary-lighter
|
|
149
|
+
|
|
150
|
+
.radio
|
|
151
|
+
label
|
|
152
|
+
@apply bg-card-lightpr-bg text-primary-light
|
|
153
|
+
|
|
154
|
+
input:checked + label
|
|
155
|
+
@apply bg-edit-purple text-white
|
|
156
|
+
|
|
157
|
+
.radio
|
|
158
|
+
label
|
|
159
|
+
@apply bg-edit-purple text-white
|
|
160
|
+
|
|
161
|
+
input:checked + label
|
|
162
|
+
@apply text-primary
|
|
163
|
+
|
|
164
|
+
&.radio-group--insight-title
|
|
165
|
+
@apply bg-bg border-bg
|
|
166
|
+
|
|
167
|
+
&.color-invert
|
|
168
|
+
@apply bg-card-lightpr-bg border-primary-lighter
|
|
169
|
+
|
|
170
|
+
.radio
|
|
171
|
+
label
|
|
172
|
+
@apply bg-card-lightpr-bg text-primary-light
|
|
173
|
+
|
|
174
|
+
input:checked + label
|
|
175
|
+
@apply bg-edit-purple text-white
|
|
176
|
+
|
|
177
|
+
.radio
|
|
178
|
+
label
|
|
179
|
+
@apply bg-bg text-primary
|
|
180
|
+
|
|
181
|
+
input:checked + label
|
|
182
|
+
@apply bg-insight-title text-white
|
|
183
|
+
|
|
184
|
+
&.disabled
|
|
185
|
+
@apply bg-gray-6 border-gray-6
|
|
186
|
+
|
|
187
|
+
.radio
|
|
188
|
+
@apply relative inline-flex
|
|
189
|
+
|
|
190
|
+
input
|
|
191
|
+
@apply absolute s('left-1/2') s('top-1/2') transform s('-translate-x-1/2') s('-translate-y-1/2')
|
|
192
|
+
|
|
193
|
+
label
|
|
194
|
+
@apply inline-flex justify-center items-center relative s('min-w-[4.5rem]') s('p-1.25') bg-bg rounded text-base leading-normal text-primary-hover cursor-pointer transition
|
|
195
|
+
|
|
196
|
+
input:checked + label
|
|
197
|
+
@apply bg-white text-primary shadow
|
|
198
|
+
|
|
199
|
+
input:disabled + label
|
|
200
|
+
@apply bg-gray-6 text-gray-4 cursor-default
|
|
201
|
+
</style>
|