@globalbrain/sefirot 0.72.0 → 2.0.0-draft.1
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/CHANGELOG.md +2 -820
- package/README.md +1 -1
- package/lib/assets/styles/bootstrap.css +1 -2
- package/lib/assets/styles/variables.css +14 -47
- package/lib/components/SAvatar.vue +9 -18
- package/lib/components/SButton.vue +35 -48
- package/lib/components/SDialog.vue +16 -34
- package/lib/components/SDropdown.vue +36 -55
- package/lib/components/SDropdownItem.vue +27 -39
- package/lib/components/SDropdownItemText.vue +4 -9
- package/lib/components/SDropdownItemUser.vue +4 -12
- package/lib/components/SInputBase.vue +33 -45
- package/lib/components/SInputCheckbox.vue +17 -37
- package/lib/components/SInputDropdown.vue +109 -171
- package/lib/components/SInputDropdownItem.vue +26 -32
- package/lib/components/SInputDropdownItemText.vue +6 -11
- package/lib/components/SInputDropdownItemTextTag.vue +10 -17
- package/lib/components/SInputDropdownItemUser.vue +5 -13
- package/lib/components/SInputDropdownItemUserTag.vue +9 -16
- package/lib/components/SInputFile.vue +38 -53
- package/lib/components/SInputHMS.vue +91 -114
- package/lib/components/SInputNumber.vue +27 -106
- package/lib/components/SInputRadio.vue +21 -34
- package/lib/components/SInputRadios.vue +36 -46
- package/lib/components/SInputText.vue +59 -633
- package/lib/components/SInputTextarea.vue +54 -113
- package/lib/components/SInputYMD.vue +94 -105
- package/lib/components/SLink.vue +16 -52
- package/lib/components/SModal.vue +53 -90
- package/lib/components/SPortalModals.vue +37 -53
- package/lib/components/SPortalSnackbars.vue +9 -24
- package/lib/components/SSheet.vue +10 -23
- package/lib/components/SSheetFooter.vue +0 -2
- package/lib/components/SSheetFooterAction.vue +9 -14
- package/lib/components/SSheetFooterActions.vue +1 -3
- package/lib/components/SSheetHeader.vue +9 -24
- package/lib/components/SSheetHeaderTitle.vue +0 -2
- package/lib/components/SSheetMedium.vue +12 -14
- package/lib/components/SSnackbar.vue +18 -28
- package/lib/composables/Dialog.ts +9 -17
- package/lib/composables/Dropdown.ts +1 -1
- package/lib/composables/{Menu.ts → Flyout.ts} +11 -4
- package/lib/composables/Form.ts +42 -44
- package/lib/composables/Modal.ts +9 -9
- package/lib/composables/Snackbar.ts +18 -0
- package/lib/composables/Validation.ts +28 -0
- package/lib/mixins/Sheet.ts +3 -3
- package/lib/store/Sefirot.ts +8 -13
- package/lib/store/dialog/index.ts +20 -10
- package/lib/store/modal/index.ts +11 -13
- package/lib/store/snackbars/index.ts +3 -4
- package/lib/support/{Util.ts → Utils.ts} +0 -2
- package/lib/types/Utils.ts +0 -7
- package/lib/types/vue-shims.d.ts +7 -0
- package/lib/validation/rules/checked.ts +6 -10
- package/lib/validation/rules/fileExtension.ts +9 -9
- package/lib/validation/rules/hms.ts +9 -9
- package/lib/validation/rules/index.ts +10 -74
- package/lib/validation/rules/maxLength.ts +10 -9
- package/lib/validation/rules/minLength.ts +12 -0
- package/lib/validation/rules/required.ts +2 -10
- package/lib/validation/rules/requiredHms.ts +11 -0
- package/lib/validation/rules/requiredIf.ts +3 -11
- package/lib/validation/rules/requiredYmd.ts +11 -0
- package/lib/validation/rules/ymd.ts +11 -0
- package/lib/validation/validators/checked.ts +1 -1
- package/lib/validation/validators/fileExtension.ts +1 -1
- package/lib/validation/validators/hms.ts +5 -5
- package/lib/validation/validators/requiredHms.ts +17 -0
- package/lib/validation/validators/requiredYmd.ts +7 -0
- package/lib/validation/validators/ymd.ts +41 -0
- package/package.json +45 -50
- package/lib/components/SAction.vue +0 -37
- package/lib/components/SActionAvatar.vue +0 -25
- package/lib/components/SActionButton.vue +0 -40
- package/lib/components/SActionPill.vue +0 -35
- package/lib/components/SActionSwitch.vue +0 -37
- package/lib/components/SAlert.vue +0 -145
- package/lib/components/SButtonGroup.vue +0 -160
- package/lib/components/SCard.vue +0 -111
- package/lib/components/SCardFooter.vue +0 -74
- package/lib/components/SCardHeader.vue +0 -213
- package/lib/components/SGrid.vue +0 -237
- package/lib/components/SGridActionLink.vue +0 -53
- package/lib/components/SGridActionMulti.vue +0 -139
- package/lib/components/SGridActionSingle.vue +0 -64
- package/lib/components/SHeader.vue +0 -180
- package/lib/components/SInputCheckboxes.vue +0 -87
- package/lib/components/SInputDate.vue +0 -192
- package/lib/components/SInputDay.vue +0 -87
- package/lib/components/SInputMonth.vue +0 -86
- package/lib/components/SInputSelect.vue +0 -298
- package/lib/components/SInputSwitch.vue +0 -212
- package/lib/components/SInputSwitches.vue +0 -108
- package/lib/components/SInputTime.vue +0 -255
- package/lib/components/SInputYear.vue +0 -60
- package/lib/components/SMarkdown.vue +0 -56
- package/lib/components/SPlaceholderBlank.vue +0 -113
- package/lib/components/SPlaceholderImage.vue +0 -83
- package/lib/components/SPortalScreens.vue +0 -62
- package/lib/components/SProgressBar.vue +0 -89
- package/lib/components/SResponsive.vue +0 -46
- package/lib/components/SScreen.vue +0 -81
- package/lib/components/SStep.vue +0 -107
- package/lib/components/SSteps.vue +0 -75
- package/lib/components/STag.vue +0 -67
- package/lib/components/STooltip.vue +0 -134
- package/lib/components/SWindow.vue +0 -158
- package/lib/components/icons/SIconCopy.vue +0 -6
- package/lib/composables/Action.ts +0 -141
- package/lib/composables/Alert.ts +0 -50
- package/lib/composables/Card.ts +0 -46
- package/lib/composables/FormValidation.ts +0 -150
- package/lib/composables/Header.ts +0 -72
- package/lib/composables/InputDropdown.ts +0 -6
- package/lib/composables/Markdown.ts +0 -138
- package/lib/composables/Router.ts +0 -20
- package/lib/composables/Step.ts +0 -7
- package/lib/composables/Store.ts +0 -9
- package/lib/composables/Tag.ts +0 -32
- package/lib/composables/Tooltip.ts +0 -91
- package/lib/composables/Utils.ts +0 -115
- package/lib/composables/markdown/LinkPlugin.ts +0 -45
- package/lib/compositions/useForm.ts +0 -17
- package/lib/compositions/useResizeObserver.ts +0 -25
- package/lib/compositions/useTime.ts +0 -26
- package/lib/store/alert/index.ts +0 -32
- package/lib/store/screen/index.ts +0 -46
- package/lib/types/v-calendar.d.ts +0 -5
- package/lib/validation/Validation.ts +0 -151
- package/lib/validation/rules/day.ts +0 -11
- package/lib/validation/rules/email.ts +0 -11
- package/lib/validation/rules/every.ts +0 -38
- package/lib/validation/rules/include.ts +0 -11
- package/lib/validation/rules/includeSome.ts +0 -11
- package/lib/validation/rules/integer.ts +0 -11
- package/lib/validation/rules/maxValue.ts +0 -11
- package/lib/validation/rules/minValue.ts +0 -11
- package/lib/validation/rules/month.ts +0 -11
- package/lib/validation/rules/not.ts +0 -10
- package/lib/validation/rules/regex.ts +0 -11
- package/lib/validation/rules/requiredHMS.ts +0 -11
- package/lib/validation/rules/requiredMonthDate.ts +0 -11
- package/lib/validation/rules/requiredYearMonth.ts +0 -11
- package/lib/validation/rules/requiredYearMonthDate.ts +0 -11
- package/lib/validation/rules/rule.ts +0 -5
- package/lib/validation/rules/sameAs.ts +0 -11
- package/lib/validation/rules/url.ts +0 -11
- package/lib/validation/rules/validateIf.ts +0 -27
- package/lib/validation/rules/year.ts +0 -11
- package/lib/validation/rules/yearMonth.ts +0 -11
- package/lib/validation/rules/yearMonthDate.ts +0 -11
- package/lib/validation/validators/day.ts +0 -29
- package/lib/validation/validators/email.ts +0 -5
- package/lib/validation/validators/include.ts +0 -5
- package/lib/validation/validators/includeSome.ts +0 -5
- package/lib/validation/validators/index.ts +0 -51
- package/lib/validation/validators/integer.ts +0 -6
- package/lib/validation/validators/maxLength.ts +0 -3
- package/lib/validation/validators/maxValue.ts +0 -3
- package/lib/validation/validators/minValue.ts +0 -3
- package/lib/validation/validators/month.ts +0 -3
- package/lib/validation/validators/monthDate.ts +0 -20
- package/lib/validation/validators/regex.ts +0 -3
- package/lib/validation/validators/required.ts +0 -27
- package/lib/validation/validators/requiredHMS.ts +0 -17
- package/lib/validation/validators/requiredMonthDate.ts +0 -8
- package/lib/validation/validators/requiredYearMonth.ts +0 -8
- package/lib/validation/validators/requiredYearMonthDate.ts +0 -9
- package/lib/validation/validators/sameAs.ts +0 -5
- package/lib/validation/validators/url.ts +0 -5
- package/lib/validation/validators/year.ts +0 -3
- package/lib/validation/validators/yearMonth.ts +0 -20
- package/lib/validation/validators/yearMonthDate.ts +0 -21
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<SInputBase
|
|
3
|
-
class="SInputSelect"
|
|
4
|
-
:class="classes"
|
|
5
|
-
:name="name"
|
|
6
|
-
:label="label"
|
|
7
|
-
:note="note"
|
|
8
|
-
:help="help"
|
|
9
|
-
:validation="validation"
|
|
10
|
-
:error-message="errorMessage"
|
|
11
|
-
>
|
|
12
|
-
<div class="box" :class="{ focus: isFocused }">
|
|
13
|
-
<select
|
|
14
|
-
:id="name"
|
|
15
|
-
class="select"
|
|
16
|
-
:class="{ 'is-not-selected': isNotSelected }"
|
|
17
|
-
:disabled="disabled"
|
|
18
|
-
@focus="focus"
|
|
19
|
-
@blur="blur"
|
|
20
|
-
@change="emitChange"
|
|
21
|
-
>
|
|
22
|
-
<option
|
|
23
|
-
v-if="placeholder || nullable"
|
|
24
|
-
:value="JSON.stringify({ value: null })"
|
|
25
|
-
:selected="isNotSelected"
|
|
26
|
-
:disabled="!nullable"
|
|
27
|
-
>
|
|
28
|
-
{{ placeholder || 'Please select' }}
|
|
29
|
-
</option>
|
|
30
|
-
|
|
31
|
-
<option
|
|
32
|
-
v-for="option in options"
|
|
33
|
-
:key="option.value"
|
|
34
|
-
:style="{ display: option.disabled ? 'none' : null }"
|
|
35
|
-
:value="JSON.stringify(option)"
|
|
36
|
-
:selected="isSelectedOption(option)"
|
|
37
|
-
>
|
|
38
|
-
{{ option.label }}
|
|
39
|
-
</option>
|
|
40
|
-
</select>
|
|
41
|
-
|
|
42
|
-
<div class="icon" role="button">
|
|
43
|
-
<SIconChevronUp class="icon-svg up" />
|
|
44
|
-
<SIconChevronDown class="icon-svg down" />
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
</SInputBase>
|
|
48
|
-
</template>
|
|
49
|
-
|
|
50
|
-
<script lang="ts">
|
|
51
|
-
import { PropType, defineComponent, ref, computed } from '@vue/composition-api'
|
|
52
|
-
import { SyntheticInputEvent } from '../types/Utils'
|
|
53
|
-
import SIconChevronUp from './icons/SIconChevronUp.vue'
|
|
54
|
-
import SIconChevronDown from './icons/SIconChevronDown.vue'
|
|
55
|
-
import SInputBase from './SInputBase.vue'
|
|
56
|
-
|
|
57
|
-
type Size = 'mini' | 'small' | 'medium'
|
|
58
|
-
type Mode = 'outlined' | 'filled'
|
|
59
|
-
|
|
60
|
-
interface Option {
|
|
61
|
-
label: string
|
|
62
|
-
value: boolean | number | string
|
|
63
|
-
disabled?: boolean
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export default defineComponent({
|
|
67
|
-
components: {
|
|
68
|
-
SIconChevronUp,
|
|
69
|
-
SIconChevronDown,
|
|
70
|
-
SInputBase
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
model: {
|
|
74
|
-
prop: 'value',
|
|
75
|
-
event: 'change'
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
props: {
|
|
79
|
-
size: { type: String as PropType<Size>, default: 'small' },
|
|
80
|
-
mode: { type: String as PropType<Mode>, default: 'outlined' },
|
|
81
|
-
name: { type: String, default: null },
|
|
82
|
-
label: { type: String, default: null },
|
|
83
|
-
note: { type: String, default: null },
|
|
84
|
-
help: { type: String, default: null },
|
|
85
|
-
placeholder: { type: String, default: null },
|
|
86
|
-
options: { type: Array as PropType<Option[]>, required: true },
|
|
87
|
-
nullable: { type: Boolean, default: false },
|
|
88
|
-
disabled: { type: Boolean, default: false },
|
|
89
|
-
errorMessage: { type: Boolean, default: true },
|
|
90
|
-
value: { type: [String, Number, Boolean], default: null },
|
|
91
|
-
validation: { type: Object, default: null }
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
setup(props, { emit }) {
|
|
95
|
-
const isFocused = ref(false)
|
|
96
|
-
|
|
97
|
-
const classes = computed(() => [
|
|
98
|
-
props.size,
|
|
99
|
-
props.mode,
|
|
100
|
-
{ disabled: props.disabled }
|
|
101
|
-
])
|
|
102
|
-
|
|
103
|
-
const isNotSelected = computed(() => {
|
|
104
|
-
return props.value === undefined || props.value === null || props.value === ''
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
function isSelectedOption(option: Option): boolean {
|
|
108
|
-
return option.value === props.value
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function focus() {
|
|
112
|
-
isFocused.value = true
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function blur() {
|
|
116
|
-
isFocused.value = false
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function emitChange(e: SyntheticInputEvent): void {
|
|
120
|
-
props.validation?.$touch()
|
|
121
|
-
|
|
122
|
-
const option = JSON.parse(e.target.value)
|
|
123
|
-
|
|
124
|
-
emit('change', option.value)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return {
|
|
128
|
-
isFocused,
|
|
129
|
-
classes,
|
|
130
|
-
isNotSelected,
|
|
131
|
-
isSelectedOption,
|
|
132
|
-
focus,
|
|
133
|
-
blur,
|
|
134
|
-
emitChange
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
})
|
|
138
|
-
</script>
|
|
139
|
-
|
|
140
|
-
<style lang="postcss" scoped>
|
|
141
|
-
@import "@/assets/styles/variables";
|
|
142
|
-
|
|
143
|
-
.SInputSelect.mini {
|
|
144
|
-
.box {
|
|
145
|
-
height: 32px;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.select {
|
|
149
|
-
padding: 3px 30px 3px 12px;
|
|
150
|
-
line-height: 24px;
|
|
151
|
-
font-size: 14px;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
.icon {
|
|
155
|
-
top: 3px;
|
|
156
|
-
right: 8px;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
.SInputSelect.small {
|
|
161
|
-
.box {
|
|
162
|
-
height: 40px;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
.select {
|
|
166
|
-
padding: 7px 30px 5px 12px;
|
|
167
|
-
line-height: 24px;
|
|
168
|
-
font-size: 16px;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
.icon {
|
|
172
|
-
top: 7px;
|
|
173
|
-
right: 10px;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
.SInputSelect.medium {
|
|
178
|
-
.box {
|
|
179
|
-
height: 48px;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
.select {
|
|
183
|
-
padding: 11px 44px 11px 16px;
|
|
184
|
-
line-height: 24px;
|
|
185
|
-
font-size: 16px;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
.icon {
|
|
189
|
-
top: 11px;
|
|
190
|
-
right: 12px;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
.SInputSelect.filled {
|
|
195
|
-
.box {
|
|
196
|
-
background-color: var(--input-filled-bg);
|
|
197
|
-
|
|
198
|
-
&:hover,
|
|
199
|
-
&.focus {
|
|
200
|
-
border-color: var(--input-focus-border);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
&.disabled .box:hover {
|
|
205
|
-
border-color: transparent;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
&.disabled .select {
|
|
209
|
-
background-color: var(--input-filled-bg-disabled);
|
|
210
|
-
opacity: 1;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
.SInputSelect.outlined {
|
|
215
|
-
&.has-error {
|
|
216
|
-
.box {
|
|
217
|
-
border-color: var(--c-danger);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
.box {
|
|
222
|
-
border-color: var(--input-outlined-border);
|
|
223
|
-
|
|
224
|
-
&:hover,
|
|
225
|
-
&.focus {
|
|
226
|
-
border-color: var(--input-focus-border);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
&:focus:not(:focus-visible) {
|
|
230
|
-
border-color: var(--input-focus-border);
|
|
231
|
-
outline: 0;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
&.disabled .box:hover {
|
|
236
|
-
border-color: var(--input-outlined-border);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
&.disabled .select {
|
|
240
|
-
background-color: var(--input-outlined-bg-disabled);
|
|
241
|
-
opacity: 1;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
.SInputSelect.disabled {
|
|
246
|
-
.box:hover .select {
|
|
247
|
-
cursor: not-allowed;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
.SInputSelect.has-error {
|
|
252
|
-
.select {
|
|
253
|
-
border-color: var(--c-danger);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
.box {
|
|
258
|
-
position: relative;
|
|
259
|
-
border: 1px solid transparent;
|
|
260
|
-
border-radius: 4px;
|
|
261
|
-
width: 100%;
|
|
262
|
-
color: var(--input-text);
|
|
263
|
-
cursor: pointer;
|
|
264
|
-
transition: border-color .25s, background-color .25s;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
.select {
|
|
268
|
-
position: relative;
|
|
269
|
-
z-index: 20;
|
|
270
|
-
display: block;
|
|
271
|
-
border: 0;
|
|
272
|
-
border-radius: 4px;
|
|
273
|
-
width: 100%;
|
|
274
|
-
background-color: transparent;
|
|
275
|
-
cursor: pointer;
|
|
276
|
-
|
|
277
|
-
&.select.is-not-selected {
|
|
278
|
-
color: var(--input-placeholder);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
.icon {
|
|
283
|
-
position: absolute;
|
|
284
|
-
z-index: 10;
|
|
285
|
-
cursor: pointer;
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
.icon-svg {
|
|
289
|
-
display: block;
|
|
290
|
-
width: 14px;
|
|
291
|
-
height: 14px;
|
|
292
|
-
fill: var(--input-placeholder);
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
.icon-svg.up {
|
|
296
|
-
margin-bottom: -4px;
|
|
297
|
-
}
|
|
298
|
-
</style>
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<SInputBase
|
|
3
|
-
class="SInputSwitch"
|
|
4
|
-
:class="classes"
|
|
5
|
-
:name="name"
|
|
6
|
-
:label="label"
|
|
7
|
-
:note="note"
|
|
8
|
-
:help="help"
|
|
9
|
-
>
|
|
10
|
-
<div class="SInputSwitch-container">
|
|
11
|
-
<div class="SInputSwitch-input" :class="{ on: value }" role="button" @click="emitChange">
|
|
12
|
-
<p v-if="text" class="SInputSwitch-text" :class="[textMode]">{{ text }}</p>
|
|
13
|
-
|
|
14
|
-
<div class="SInputSwitch-box">
|
|
15
|
-
<div class="SInputSwitch-check" />
|
|
16
|
-
</div>
|
|
17
|
-
|
|
18
|
-
<p v-if="textAfter" class="SInputSwitch-text after" :class="[textMode]">{{ textAfter }}</p>
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
</SInputBase>
|
|
22
|
-
</template>
|
|
23
|
-
|
|
24
|
-
<script lang="ts">
|
|
25
|
-
import { PropType, defineComponent, computed } from '@vue/composition-api'
|
|
26
|
-
import SInputBase from './SInputBase.vue'
|
|
27
|
-
|
|
28
|
-
type Size = 'mini' | 'small'
|
|
29
|
-
type Mode = 'neutral' | 'info' | 'success' | 'warning' | 'danger'
|
|
30
|
-
type TextMode = 'neutral' | 'mute' | 'info' | 'success' | 'warning' | 'danger'
|
|
31
|
-
|
|
32
|
-
export default defineComponent({
|
|
33
|
-
components: {
|
|
34
|
-
SInputBase
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
model: {
|
|
38
|
-
prop: 'value',
|
|
39
|
-
event: 'change'
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
props: {
|
|
43
|
-
size: { type: String as PropType<Size>, default: 'small' },
|
|
44
|
-
mode: { type: String as PropType<Mode>, default: 'neutral' },
|
|
45
|
-
name: { type: String, default: null },
|
|
46
|
-
label: { type: String, default: null },
|
|
47
|
-
note: { type: String, default: null },
|
|
48
|
-
text: { type: String, default: null },
|
|
49
|
-
textAfter: { type: String, default: null },
|
|
50
|
-
textMode: { type: String as PropType<TextMode>, default: 'neutral' },
|
|
51
|
-
disabled: { type: Boolean, default: false },
|
|
52
|
-
help: { type: String, default: null },
|
|
53
|
-
value: { type: Boolean, required: true }
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
setup(props, { emit }) {
|
|
57
|
-
const classes = computed(() => ({
|
|
58
|
-
mini: props.size === 'mini',
|
|
59
|
-
small: props.size === 'small',
|
|
60
|
-
neutral: props.mode === 'neutral',
|
|
61
|
-
info: props.mode === 'info',
|
|
62
|
-
success: props.mode === 'success',
|
|
63
|
-
warning: props.mode === 'warning',
|
|
64
|
-
danger: props.mode === 'danger',
|
|
65
|
-
disabled: props.disabled
|
|
66
|
-
}))
|
|
67
|
-
|
|
68
|
-
function emitChange(): void {
|
|
69
|
-
!props.disabled && emit('change', !props.value)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
classes,
|
|
74
|
-
emitChange
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
</script>
|
|
79
|
-
|
|
80
|
-
<style lang="postcss" scoped>
|
|
81
|
-
@import "@/assets/styles/variables";
|
|
82
|
-
|
|
83
|
-
.SInputSwitch.mini {
|
|
84
|
-
.SInputSwitch-box {
|
|
85
|
-
margin: 1px 0 0;
|
|
86
|
-
border-radius: 9px;
|
|
87
|
-
width: 36px;
|
|
88
|
-
height: 18px;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
.SInputSwitch-check {
|
|
92
|
-
top: 2px;
|
|
93
|
-
left: 2px;
|
|
94
|
-
width: 12px;
|
|
95
|
-
height: 12px;
|
|
96
|
-
transition: background-color .25s, transform .25s;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.SInputSwitch.small {
|
|
101
|
-
.SInputSwitch-box {
|
|
102
|
-
margin: -1px 0 -1px;
|
|
103
|
-
border-radius: 11px;
|
|
104
|
-
width: 40px;
|
|
105
|
-
height: 22px;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
.SInputSwitch-check {
|
|
109
|
-
top: 2px;
|
|
110
|
-
left: 2px;
|
|
111
|
-
width: 16px;
|
|
112
|
-
height: 16px;
|
|
113
|
-
transition: background-color .25s, transform .25s;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.SInputSwitch.neutral .SInputSwitch-input.on .SInputSwitch-box {
|
|
118
|
-
border-color: var(--c-black);
|
|
119
|
-
background-color: var(--c-black);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.SInputSwitch.info .SInputSwitch-input.on .SInputSwitch-box {
|
|
123
|
-
border-color: var(--c-info);
|
|
124
|
-
background-color: var(--c-info);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
.SInputSwitch.success .SInputSwitch-input.on .SInputSwitch-box {
|
|
128
|
-
border-color: var(--c-success);
|
|
129
|
-
background-color: var(--c-success);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.SInputSwitch.warning .SInputSwitch-input.on .SInputSwitch-box {
|
|
133
|
-
border-color: var(--c-warning);
|
|
134
|
-
background-color: var(--c-warning);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
.SInputSwitch.danger .SInputSwitch-input.on .SInputSwitch-box {
|
|
138
|
-
border-color: var(--c-danger);
|
|
139
|
-
background-color: var(--c-danger);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
.SInputSwitch.disabled .SInputSwitch-input {
|
|
143
|
-
.SInputSwitch-box {
|
|
144
|
-
cursor: not-allowed;
|
|
145
|
-
opacity: .6;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
&:hover .SInputSwitch-box { border-color: var(--c-gray); }
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
.SInputSwitch.disabled .SInputSwitch-input.on {
|
|
152
|
-
&:hover .SInputSwitch-box { border-color: transparent; }
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.SInputSwitch-container {
|
|
156
|
-
display: flex;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.SInputSwitch-input {
|
|
160
|
-
position: relative;
|
|
161
|
-
display: flex;
|
|
162
|
-
justify-content: space-between;
|
|
163
|
-
width: 100%;
|
|
164
|
-
|
|
165
|
-
&:hover {
|
|
166
|
-
.SInputSwitch-box { border-color: var(--c-black); }
|
|
167
|
-
.SInputSwitch-check { background-color: var(--c-black); }
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
.SInputSwitch-input.on .SInputSwitch-check {
|
|
172
|
-
background-color: var(--c-white);
|
|
173
|
-
transform: translateX(18px);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
.SInputSwitch-text {
|
|
177
|
-
flex-grow: 1;
|
|
178
|
-
margin: 0;
|
|
179
|
-
padding-right: 16px;
|
|
180
|
-
line-height: 20px;
|
|
181
|
-
font-size: 14px;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
.SInputSwitch-text.mute {
|
|
185
|
-
color: var(--c-text-light-2);
|
|
186
|
-
font-weight: 500;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.SInputSwitch-text.info { color: var(--c-info); }
|
|
190
|
-
.SInputSwitch-text.success { color: var(--c-success); }
|
|
191
|
-
.SInputSwitch-text.warning { color: var(--c-warning); }
|
|
192
|
-
.SInputSwitch-text.danger { color: var(--c-danger); }
|
|
193
|
-
|
|
194
|
-
.SInputSwitch-text.after {
|
|
195
|
-
padding-left: 12px;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
.SInputSwitch-box {
|
|
199
|
-
position: relative;
|
|
200
|
-
flex-shrink: 0;
|
|
201
|
-
border: 1px solid var(--c-gray);
|
|
202
|
-
background-color: var(--c-white-mute);
|
|
203
|
-
transition: border-color .25s, background-color .25s, box-shadow .25s;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
.SInputSwitch-check {
|
|
207
|
-
position: absolute;
|
|
208
|
-
border-radius: 50%;
|
|
209
|
-
background-color: var(--c-black);
|
|
210
|
-
transition: background-color .25s, transform .25s;
|
|
211
|
-
}
|
|
212
|
-
</style>
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<SInputBase
|
|
3
|
-
class="SInputSwitches"
|
|
4
|
-
:class="classes"
|
|
5
|
-
:name="name"
|
|
6
|
-
:label="label"
|
|
7
|
-
:note="note"
|
|
8
|
-
:help="help"
|
|
9
|
-
>
|
|
10
|
-
<div class="SInputSwitches-container">
|
|
11
|
-
<div class="SInputSwitches-row">
|
|
12
|
-
<div v-for="option in options" :key="option.value" class="SInputSwitches-col">
|
|
13
|
-
<SInputSwitch
|
|
14
|
-
:size="size"
|
|
15
|
-
:mode="mode"
|
|
16
|
-
:text="option.label"
|
|
17
|
-
:value="isChecked(option.value)"
|
|
18
|
-
@change="handleChange(option.value)"
|
|
19
|
-
/>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
23
|
-
</SInputBase>
|
|
24
|
-
</template>
|
|
25
|
-
|
|
26
|
-
<script lang="ts">
|
|
27
|
-
import { PropType, defineComponent, computed } from '@vue/composition-api'
|
|
28
|
-
import SInputBase from './SInputBase.vue'
|
|
29
|
-
import SInputSwitch from './SInputSwitch.vue'
|
|
30
|
-
|
|
31
|
-
type Size = 'mini' | 'small'
|
|
32
|
-
type Mode = 'neutral' | 'info' | 'success' | 'warning' | 'danger'
|
|
33
|
-
|
|
34
|
-
interface Option {
|
|
35
|
-
label: string
|
|
36
|
-
value: unknown
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export default defineComponent({
|
|
40
|
-
components: {
|
|
41
|
-
SInputBase,
|
|
42
|
-
SInputSwitch
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
model: {
|
|
46
|
-
prop: 'value',
|
|
47
|
-
event: 'change'
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
props: {
|
|
51
|
-
size: { type: String as PropType<Size>, default: 'small' },
|
|
52
|
-
mode: { type: String as PropType<Mode>, default: 'neutral' },
|
|
53
|
-
name: { type: String, default: null },
|
|
54
|
-
label: { type: String, default: null },
|
|
55
|
-
note: { type: String, default: null },
|
|
56
|
-
help: { type: String, default: null },
|
|
57
|
-
options: { type: Array as PropType<Option[]>, required: true },
|
|
58
|
-
value: { type: Array as PropType<unknown[]>, required: true }
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
setup(props, { emit }) {
|
|
62
|
-
const classes = computed(() => [
|
|
63
|
-
props.size,
|
|
64
|
-
props.mode
|
|
65
|
-
])
|
|
66
|
-
|
|
67
|
-
function isChecked(value: unknown): boolean {
|
|
68
|
-
return props.value.includes(value)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function handleChange(value: unknown): void {
|
|
72
|
-
const difference = props.value
|
|
73
|
-
.filter(v => v !== value)
|
|
74
|
-
.concat(props.value.includes(value) ? [] : [value])
|
|
75
|
-
|
|
76
|
-
emit('change', difference)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
classes,
|
|
81
|
-
isChecked,
|
|
82
|
-
handleChange
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
</script>
|
|
87
|
-
|
|
88
|
-
<style lang="postcss" scoped>
|
|
89
|
-
@import "@/assets/styles/variables";
|
|
90
|
-
|
|
91
|
-
.SInputSwitches.mini {
|
|
92
|
-
.SInputSwitches-row { margin: -2px -8px; }
|
|
93
|
-
.SInputSwitches-col { padding: 2px 8px; }
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.SInputSwitches.small {
|
|
97
|
-
.SInputSwitches-row { margin: -4px -8px; }
|
|
98
|
-
.SInputSwitches-col { padding: 4px 8px; }
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.SInputSwitches-container {
|
|
102
|
-
display: flex;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.SInputSwitches-row {
|
|
106
|
-
width: 100%;
|
|
107
|
-
}
|
|
108
|
-
</style>
|