@globalbrain/sefirot 2.0.0-draft.8 → 2.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/README.md +6 -6
- package/lib/components/SAvatar.vue +17 -17
- package/lib/components/SButton.vue +512 -267
- package/lib/components/SButtonGroup.vue +149 -0
- package/lib/components/SDropdown.vue +26 -150
- package/lib/components/SDropdownSection.vue +48 -0
- package/lib/components/SDropdownSectionFilter.vue +189 -0
- package/lib/components/SDropdownSectionFilterItem.vue +21 -0
- package/lib/components/SDropdownSectionFilterItemAvatar.vue +31 -0
- package/lib/components/SDropdownSectionFilterItemText.vue +20 -0
- package/lib/components/SDropdownSectionMenu.vue +39 -0
- package/lib/components/SIcon.vue +13 -0
- package/lib/components/SInputBase.vue +31 -31
- package/lib/components/SInputCheckbox.vue +1 -1
- package/lib/components/SInputCheckboxes.vue +74 -0
- package/lib/components/SInputDate.vue +182 -0
- package/lib/components/SInputDropdown.vue +158 -157
- package/lib/components/SInputDropdownItem.vue +46 -48
- package/lib/components/{SInputDropdownItemUserTag.vue → SInputDropdownItemAvatar.vue} +43 -44
- package/lib/components/SInputDropdownItemText.vue +79 -16
- package/lib/components/SInputFile.vue +55 -60
- package/lib/components/SInputHMS.vue +120 -110
- package/lib/components/SInputNumber.vue +38 -9
- package/lib/components/SInputRadio.vue +39 -36
- package/lib/components/SInputRadios.vue +40 -53
- package/lib/components/SInputSelect.vue +3 -3
- package/lib/components/SInputSwitch.vue +193 -0
- package/lib/components/SInputSwitches.vue +88 -0
- package/lib/components/SInputText.vue +206 -62
- package/lib/components/SInputTextarea.vue +46 -32
- package/lib/components/SInputYMD.vue +123 -126
- package/lib/components/SMarkdown.vue +52 -0
- package/lib/components/SModal.vue +25 -63
- package/lib/components/SMount.vue +19 -0
- package/lib/components/SSheet.vue +49 -55
- package/lib/components/SSheetFooter.vue +1 -1
- package/lib/components/SSheetFooterAction.vue +24 -17
- package/lib/components/SSheetFooterActions.vue +1 -4
- package/lib/components/SSheetForm.vue +15 -0
- package/lib/components/SSheetMedium.vue +8 -10
- package/lib/components/SSheetTitle.vue +7 -14
- package/lib/components/SSnackbar.vue +55 -45
- package/lib/components/{SPortalSnackbars.vue → SSnackbars.vue} +17 -20
- package/lib/components/SStep.vue +106 -0
- package/lib/components/SSteps.vue +59 -0
- package/lib/components/STable.vue +241 -0
- package/lib/components/STableCell.vue +82 -0
- package/lib/components/STableCellAvatar.vue +69 -0
- package/lib/components/STableCellAvatars.vue +93 -0
- package/lib/components/STableCellDay.vue +40 -0
- package/lib/components/STableCellPill.vue +84 -0
- package/lib/components/STableCellText.vue +102 -0
- package/lib/components/STableColumn.vue +255 -0
- package/lib/components/STableFooter.vue +115 -0
- package/lib/components/STableHeader.vue +74 -0
- package/lib/components/STableItem.vue +38 -0
- package/lib/components/STooltip.vue +112 -0
- package/lib/composables/Dropdown.ts +40 -99
- package/lib/composables/Form.ts +21 -18
- package/lib/composables/Grid.ts +117 -0
- package/lib/composables/Markdown.ts +138 -0
- package/lib/composables/Step.ts +7 -0
- package/lib/composables/Table.ts +103 -0
- package/lib/composables/Tooltip.ts +91 -0
- package/lib/composables/Validation.ts +5 -9
- package/lib/composables/markdown/LinkPlugin.ts +45 -0
- package/lib/mixins/Sheet.ts +5 -3
- package/lib/stores/Snackbars.ts +48 -0
- package/lib/{assets/styles → styles}/base.css +0 -0
- package/lib/{assets/styles → styles}/bootstrap.css +1 -0
- package/lib/{assets/styles → styles}/variables.css +55 -48
- package/lib/support/Day.ts +8 -0
- package/lib/support/Num.ts +3 -0
- package/lib/support/Time.ts +5 -2
- package/lib/support/Utils.ts +4 -3
- package/lib/types/shims.d.ts +3 -0
- package/lib/validation/validators/requiredYmd.ts +1 -1
- package/lib/validation/validators/ymd.ts +4 -4
- package/package.json +57 -37
- package/CHANGELOG.md +0 -47
- package/lib/.DS_Store +0 -0
- package/lib/components/.DS_Store +0 -0
- package/lib/components/SDialog.vue +0 -140
- package/lib/components/SDropdownItem.vue +0 -78
- package/lib/components/SDropdownItemText.vue +0 -22
- package/lib/components/SDropdownItemUser.vue +0 -40
- package/lib/components/SInputDropdownItemTextTag.vue +0 -94
- package/lib/components/SInputDropdownItemUser.vue +0 -41
- package/lib/components/SPortalModals.vue +0 -74
- package/lib/components/icons/.DS_Store +0 -0
- package/lib/composables/Dialog.ts +0 -38
- package/lib/composables/Modal.ts +0 -34
- package/lib/composables/Snackbar.ts +0 -18
- package/lib/store/Sefirot.ts +0 -17
- package/lib/store/dialog/index.ts +0 -42
- package/lib/store/modal/index.ts +0 -61
- package/lib/store/snackbars/index.ts +0 -70
|
@@ -1,11 +1,38 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Validatable } from '../composables/Validation'
|
|
3
|
+
import SInputBase from './SInputBase.vue'
|
|
4
|
+
|
|
5
|
+
export type Size = 'mini' | 'small' | 'medium'
|
|
6
|
+
|
|
7
|
+
const props = defineProps<{
|
|
8
|
+
size?: Size
|
|
9
|
+
name?: string
|
|
10
|
+
label?: string
|
|
11
|
+
note?: string
|
|
12
|
+
help?: string
|
|
13
|
+
text: string
|
|
14
|
+
hideError?: boolean
|
|
15
|
+
modelValue: boolean
|
|
16
|
+
validation?: Validatable
|
|
17
|
+
}>()
|
|
18
|
+
|
|
19
|
+
const emit = defineEmits<{
|
|
20
|
+
(e: 'update:modelValue', value: boolean): void
|
|
21
|
+
}>()
|
|
22
|
+
|
|
23
|
+
function emitChange() {
|
|
24
|
+
emit('update:modelValue', !props.modelValue)
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
1
28
|
<template>
|
|
2
29
|
<SInputBase
|
|
3
30
|
class="SInputRadio"
|
|
4
|
-
:class="[size]"
|
|
31
|
+
:class="[size ?? 'small']"
|
|
5
32
|
:label="label"
|
|
6
33
|
:note="note"
|
|
7
34
|
:help="help"
|
|
8
|
-
:error
|
|
35
|
+
:hide-error="hideError"
|
|
9
36
|
:validation="validation"
|
|
10
37
|
>
|
|
11
38
|
<div class="container">
|
|
@@ -20,31 +47,6 @@
|
|
|
20
47
|
</SInputBase>
|
|
21
48
|
</template>
|
|
22
49
|
|
|
23
|
-
<script setup lang="ts">
|
|
24
|
-
import { PropType } from 'vue'
|
|
25
|
-
import { Validation } from '../composables/Validation'
|
|
26
|
-
import SInputBase from './SInputBase.vue'
|
|
27
|
-
|
|
28
|
-
type Size = 'mini' | 'small' | 'medium'
|
|
29
|
-
|
|
30
|
-
const props = defineProps({
|
|
31
|
-
size: { type: String as PropType<Size>, default: 'small' },
|
|
32
|
-
label: { type: String, default: null },
|
|
33
|
-
note: { type: String, default: null },
|
|
34
|
-
help: { type: String, default: null },
|
|
35
|
-
text: { type: String, required: true },
|
|
36
|
-
errorMessage: { type: Boolean, default: true },
|
|
37
|
-
modelValue: { type: Boolean, required: true },
|
|
38
|
-
validation: { type: Object as PropType<Validation>, default: null }
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
const emit = defineEmits(['update:modelValue'])
|
|
42
|
-
|
|
43
|
-
function emitChange() {
|
|
44
|
-
emit('update:modelValue', !props.modelValue)
|
|
45
|
-
}
|
|
46
|
-
</script>
|
|
47
|
-
|
|
48
50
|
<style lang="postcss" scoped>
|
|
49
51
|
.container {
|
|
50
52
|
display: flex;
|
|
@@ -58,14 +60,14 @@ function emitChange() {
|
|
|
58
60
|
|
|
59
61
|
&:hover {
|
|
60
62
|
.box {
|
|
61
|
-
border-color: var(--c-
|
|
63
|
+
border-color: var(--c-info);
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
.input.on {
|
|
67
69
|
.box {
|
|
68
|
-
border-color: var(--c-
|
|
70
|
+
border-color: var(--c-info);
|
|
69
71
|
box-shadow: var(--shadow-depth-3);
|
|
70
72
|
}
|
|
71
73
|
|
|
@@ -77,11 +79,12 @@ function emitChange() {
|
|
|
77
79
|
|
|
78
80
|
.box {
|
|
79
81
|
position: relative;
|
|
80
|
-
border:
|
|
82
|
+
border: 1px solid var(--c-divider);
|
|
81
83
|
border-radius: 50%;
|
|
82
|
-
width:
|
|
83
|
-
height:
|
|
84
|
-
|
|
84
|
+
width: 16px;
|
|
85
|
+
height: 16px;
|
|
86
|
+
background-color: var(--c-bg);
|
|
87
|
+
transition: border-color 0.25s, box-shadow 0.25s;
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
.check {
|
|
@@ -95,15 +98,15 @@ function emitChange() {
|
|
|
95
98
|
align-items: center;
|
|
96
99
|
border-radius: 50%;
|
|
97
100
|
width: 100%;
|
|
98
|
-
background-color: var(--c-
|
|
101
|
+
background-color: var(--c-info);
|
|
99
102
|
opacity: 0;
|
|
100
103
|
transform: scale(0);
|
|
101
|
-
transition: opacity .25s, transform .1s;
|
|
104
|
+
transition: opacity 0.25s, transform 0.1s;
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
.text {
|
|
105
108
|
margin: 0;
|
|
106
|
-
padding-left:
|
|
109
|
+
padding-left: 10px;
|
|
107
110
|
line-height: 20px;
|
|
108
111
|
font-size: 14px;
|
|
109
112
|
font-weight: 500;
|
|
@@ -1,54 +1,31 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<SInputBase
|
|
3
|
-
class="SInputRadios"
|
|
4
|
-
:class="[size]"
|
|
5
|
-
:label="label"
|
|
6
|
-
:note="note"
|
|
7
|
-
:help="help"
|
|
8
|
-
:error-message="errorMessage"
|
|
9
|
-
:validation="validation"
|
|
10
|
-
>
|
|
11
|
-
<div class="container">
|
|
12
|
-
<div class="row">
|
|
13
|
-
<div v-for="(option, index) in options" :key="index" class="col">
|
|
14
|
-
<SInputRadio
|
|
15
|
-
:text="option.label"
|
|
16
|
-
:model-value="isChecked(option.value)"
|
|
17
|
-
@update:model-value="handleChange(option.value)"
|
|
18
|
-
/>
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
22
|
-
</SInputBase>
|
|
23
|
-
</template>
|
|
24
|
-
|
|
25
1
|
<script setup lang="ts">
|
|
26
|
-
import { PropType } from 'vue'
|
|
27
2
|
import { Validatable } from '../composables/Validation'
|
|
28
3
|
import SInputBase from './SInputBase.vue'
|
|
29
4
|
import SInputRadio from './SInputRadio.vue'
|
|
30
5
|
|
|
31
|
-
type Size = 'mini' | 'small' | 'medium'
|
|
6
|
+
export type Size = 'mini' | 'small' | 'medium'
|
|
32
7
|
|
|
33
|
-
interface Option {
|
|
8
|
+
export interface Option {
|
|
34
9
|
label: string
|
|
35
10
|
value: string | number | boolean
|
|
36
11
|
}
|
|
37
12
|
|
|
38
|
-
const props = defineProps
|
|
39
|
-
size
|
|
40
|
-
name
|
|
41
|
-
label
|
|
42
|
-
note
|
|
43
|
-
help
|
|
44
|
-
nullable
|
|
45
|
-
options:
|
|
46
|
-
|
|
47
|
-
modelValue:
|
|
48
|
-
validation
|
|
49
|
-
})
|
|
13
|
+
const props = defineProps<{
|
|
14
|
+
size?: Size
|
|
15
|
+
name?: string
|
|
16
|
+
label?: string
|
|
17
|
+
note?: string
|
|
18
|
+
help?: string
|
|
19
|
+
nullable?: boolean
|
|
20
|
+
options: Option[]
|
|
21
|
+
hideError?: boolean
|
|
22
|
+
modelValue: string | number | boolean | null
|
|
23
|
+
validation?: Validatable
|
|
24
|
+
}>()
|
|
50
25
|
|
|
51
|
-
const emit = defineEmits
|
|
26
|
+
const emit = defineEmits<{
|
|
27
|
+
(e: 'update:modelValue', value: string | number | boolean | null): void
|
|
28
|
+
}>()
|
|
52
29
|
|
|
53
30
|
function isChecked(value: string | number | boolean) {
|
|
54
31
|
return value === props.modelValue
|
|
@@ -67,16 +44,26 @@ function handleChange(value: string | number | boolean) {
|
|
|
67
44
|
}
|
|
68
45
|
</script>
|
|
69
46
|
|
|
70
|
-
<
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
47
|
+
<template>
|
|
48
|
+
<SInputBase
|
|
49
|
+
class="SInputRadios"
|
|
50
|
+
:class="[size ?? 'small']"
|
|
51
|
+
:label="label"
|
|
52
|
+
:note="note"
|
|
53
|
+
:help="help"
|
|
54
|
+
:hide-error="hideError"
|
|
55
|
+
:validation="validation"
|
|
56
|
+
>
|
|
57
|
+
<div class="container">
|
|
58
|
+
<div class="row">
|
|
59
|
+
<div v-for="(option, index) in options" :key="index" class="col">
|
|
60
|
+
<SInputRadio
|
|
61
|
+
:text="option.label"
|
|
62
|
+
:model-value="isChecked(option.value)"
|
|
63
|
+
@update:model-value="handleChange(option.value)"
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</SInputBase>
|
|
69
|
+
</template>
|
|
@@ -47,10 +47,10 @@
|
|
|
47
47
|
|
|
48
48
|
<script setup lang="ts">
|
|
49
49
|
import { PropType, ref, computed } from 'vue'
|
|
50
|
-
import {
|
|
51
|
-
import SIconChevronUp from './icons/SIconChevronUp.vue'
|
|
52
|
-
import SIconChevronDown from './icons/SIconChevronDown.vue'
|
|
50
|
+
import { Validatable } from '../composables/Validation'
|
|
53
51
|
import SInputBase from './SInputBase.vue'
|
|
52
|
+
import SIconChevronDown from './icons/SIconChevronDown.vue'
|
|
53
|
+
import SIconChevronUp from './icons/SIconChevronUp.vue'
|
|
54
54
|
|
|
55
55
|
type Size = 'mini' | 'small' | 'medium'
|
|
56
56
|
|
|
@@ -0,0 +1,193 @@
|
|
|
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: modelValue }" 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 setup lang="ts">
|
|
25
|
+
import { computed, PropType } from 'vue'
|
|
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
|
+
const props = defineProps({
|
|
33
|
+
size: { type: String as PropType<Size>, default: 'small' },
|
|
34
|
+
mode: { type: String as PropType<Mode>, default: 'neutral' },
|
|
35
|
+
name: { type: String, default: null },
|
|
36
|
+
label: { type: String, default: null },
|
|
37
|
+
note: { type: String, default: null },
|
|
38
|
+
text: { type: String, default: null },
|
|
39
|
+
textAfter: { type: String, default: null },
|
|
40
|
+
textMode: { type: String as PropType<TextMode>, default: 'neutral' },
|
|
41
|
+
disabled: { type: Boolean, default: false },
|
|
42
|
+
help: { type: String, default: null },
|
|
43
|
+
modelValue: { type: Boolean, required: true }
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const emit = defineEmits(['update:modelValue'])
|
|
47
|
+
|
|
48
|
+
const classes = computed(() => ({
|
|
49
|
+
mini: props.size === 'mini',
|
|
50
|
+
small: props.size === 'small',
|
|
51
|
+
neutral: props.mode === 'neutral',
|
|
52
|
+
info: props.mode === 'info',
|
|
53
|
+
success: props.mode === 'success',
|
|
54
|
+
warning: props.mode === 'warning',
|
|
55
|
+
danger: props.mode === 'danger',
|
|
56
|
+
disabled: props.disabled
|
|
57
|
+
}))
|
|
58
|
+
|
|
59
|
+
function emitChange(): void {
|
|
60
|
+
!props.disabled && emit('update:modelValue', !props.modelValue)
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<style lang="postcss" scoped>
|
|
65
|
+
.SInputSwitch.mini {
|
|
66
|
+
.SInputSwitch-box {
|
|
67
|
+
margin: 1px 0 0;
|
|
68
|
+
border-radius: 9px;
|
|
69
|
+
width: 36px;
|
|
70
|
+
height: 18px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.SInputSwitch-check {
|
|
74
|
+
top: 2px;
|
|
75
|
+
left: 2px;
|
|
76
|
+
width: 12px;
|
|
77
|
+
height: 12px;
|
|
78
|
+
transition: background-color .25s, transform .25s;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.SInputSwitch.small {
|
|
83
|
+
.SInputSwitch-box {
|
|
84
|
+
margin: -1px 0 -1px;
|
|
85
|
+
border-radius: 11px;
|
|
86
|
+
width: 40px;
|
|
87
|
+
height: 22px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.SInputSwitch-check {
|
|
91
|
+
top: 2px;
|
|
92
|
+
left: 2px;
|
|
93
|
+
width: 16px;
|
|
94
|
+
height: 16px;
|
|
95
|
+
transition: background-color .25s, transform .25s;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.SInputSwitch.neutral .SInputSwitch-input.on .SInputSwitch-box {
|
|
100
|
+
border-color: var(--c-black);
|
|
101
|
+
background-color: var(--c-black);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.SInputSwitch.info .SInputSwitch-input.on .SInputSwitch-box {
|
|
105
|
+
border-color: var(--c-info);
|
|
106
|
+
background-color: var(--c-info);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.SInputSwitch.success .SInputSwitch-input.on .SInputSwitch-box {
|
|
110
|
+
border-color: var(--c-success);
|
|
111
|
+
background-color: var(--c-success);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.SInputSwitch.warning .SInputSwitch-input.on .SInputSwitch-box {
|
|
115
|
+
border-color: var(--c-warning);
|
|
116
|
+
background-color: var(--c-warning);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.SInputSwitch.danger .SInputSwitch-input.on .SInputSwitch-box {
|
|
120
|
+
border-color: var(--c-danger);
|
|
121
|
+
background-color: var(--c-danger);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.SInputSwitch.disabled .SInputSwitch-input {
|
|
125
|
+
.SInputSwitch-box {
|
|
126
|
+
cursor: not-allowed;
|
|
127
|
+
opacity: .6;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&:hover .SInputSwitch-box { border-color: var(--c-gray); }
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.SInputSwitch.disabled .SInputSwitch-input.on {
|
|
134
|
+
&:hover .SInputSwitch-box { border-color: transparent; }
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.SInputSwitch-container {
|
|
138
|
+
display: flex;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.SInputSwitch-input {
|
|
142
|
+
position: relative;
|
|
143
|
+
display: flex;
|
|
144
|
+
justify-content: space-between;
|
|
145
|
+
width: 100%;
|
|
146
|
+
|
|
147
|
+
&:hover {
|
|
148
|
+
.SInputSwitch-box { border-color: var(--c-black); }
|
|
149
|
+
.SInputSwitch-check { background-color: var(--c-black); }
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.SInputSwitch-input.on .SInputSwitch-check {
|
|
154
|
+
background-color: var(--c-white);
|
|
155
|
+
transform: translateX(18px);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.SInputSwitch-text {
|
|
159
|
+
flex-grow: 1;
|
|
160
|
+
margin: 0;
|
|
161
|
+
padding-right: 16px;
|
|
162
|
+
line-height: 20px;
|
|
163
|
+
font-size: 14px;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.SInputSwitch-text.mute {
|
|
167
|
+
color: var(--c-text-light-2);
|
|
168
|
+
font-weight: 500;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.SInputSwitch-text.info { color: var(--c-info); }
|
|
172
|
+
.SInputSwitch-text.success { color: var(--c-success); }
|
|
173
|
+
.SInputSwitch-text.warning { color: var(--c-warning); }
|
|
174
|
+
.SInputSwitch-text.danger { color: var(--c-danger); }
|
|
175
|
+
.SInputSwitch-text.after {
|
|
176
|
+
padding-left: 12px;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.SInputSwitch-box {
|
|
180
|
+
position: relative;
|
|
181
|
+
flex-shrink: 0;
|
|
182
|
+
border: 1px solid var(--c-gray);
|
|
183
|
+
background-color: var(--c-white-mute);
|
|
184
|
+
transition: border-color .25s, background-color .25s, box-shadow .25s;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.SInputSwitch-check {
|
|
188
|
+
position: absolute;
|
|
189
|
+
border-radius: 50%;
|
|
190
|
+
background-color: var(--c-black);
|
|
191
|
+
transition: background-color .25s, transform .25s;
|
|
192
|
+
}
|
|
193
|
+
</style>
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
:model-value="isChecked(option.value)"
|
|
18
|
+
@update:model-value="handleChange(option.value)"
|
|
19
|
+
/>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
</SInputBase>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
import { computed, PropType } from 'vue'
|
|
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
|
+
|
|
35
|
+
interface Option {
|
|
36
|
+
label: string
|
|
37
|
+
value: any
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const props = defineProps({
|
|
41
|
+
size: { type: String as PropType<Size>, default: 'small' },
|
|
42
|
+
mode: { type: String as PropType<Mode>, default: 'neutral' },
|
|
43
|
+
name: { type: String, default: null },
|
|
44
|
+
label: { type: String, default: null },
|
|
45
|
+
note: { type: String, default: null },
|
|
46
|
+
help: { type: String, default: null },
|
|
47
|
+
options: { type: Array as PropType<Option[]>, required: true },
|
|
48
|
+
modelValue: { type: Array as PropType<unknown[]>, required: true }
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
const emit = defineEmits(['update:modelValue'])
|
|
52
|
+
|
|
53
|
+
const classes = computed(() => [
|
|
54
|
+
props.size,
|
|
55
|
+
props.mode
|
|
56
|
+
])
|
|
57
|
+
|
|
58
|
+
function isChecked(value: unknown): boolean {
|
|
59
|
+
return props.modelValue.includes(value)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function handleChange(value: unknown): void {
|
|
63
|
+
const difference = props.modelValue
|
|
64
|
+
.filter(v => v !== value)
|
|
65
|
+
.concat(props.modelValue.includes(value) ? [] : [value])
|
|
66
|
+
emit('update:modelValue', difference)
|
|
67
|
+
}
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<style lang="postcss" scoped>
|
|
71
|
+
.SInputSwitches.mini {
|
|
72
|
+
.SInputSwitches-row { margin: -2px -8px; }
|
|
73
|
+
.SInputSwitches-col { padding: 2px 8px; }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.SInputSwitches.small {
|
|
77
|
+
.SInputSwitches-row { margin: -4px -8px; }
|
|
78
|
+
.SInputSwitches-col { padding: 4px 8px; }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.SInputSwitches-container {
|
|
82
|
+
display: flex;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.SInputSwitches-row {
|
|
86
|
+
width: 100%;
|
|
87
|
+
}
|
|
88
|
+
</style>
|