@globalbrain/sefirot 2.22.0 → 2.23.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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { IconifyIcon } from '@iconify/vue/dist/offline'
|
|
3
|
-
import IconCheck from '@iconify-icons/ph/check'
|
|
4
|
-
import
|
|
3
|
+
import IconCheck from '@iconify-icons/ph/check-bold'
|
|
4
|
+
import { computed } from 'vue'
|
|
5
5
|
import type { Validatable } from '../composables/Validation'
|
|
6
6
|
import SIcon from './SIcon.vue'
|
|
7
7
|
import SInputBase from './SInputBase.vue'
|
|
@@ -9,31 +9,46 @@ import SInputBase from './SInputBase.vue'
|
|
|
9
9
|
export type Size = 'mini' | 'small' | 'medium'
|
|
10
10
|
export type Color = 'neutral' | 'mute' | 'info' | 'success' | 'warning' | 'danger'
|
|
11
11
|
|
|
12
|
-
const props = defineProps
|
|
13
|
-
size
|
|
14
|
-
label
|
|
15
|
-
info
|
|
16
|
-
note
|
|
17
|
-
help
|
|
18
|
-
checkIcon
|
|
19
|
-
checkText
|
|
20
|
-
checkColor
|
|
21
|
-
text
|
|
22
|
-
|
|
23
|
-
|
|
12
|
+
const props = withDefaults(defineProps<{
|
|
13
|
+
size?: Size
|
|
14
|
+
label?: string
|
|
15
|
+
info?: string
|
|
16
|
+
note?: string
|
|
17
|
+
help?: string
|
|
18
|
+
checkIcon?: IconifyIcon
|
|
19
|
+
checkText?: string
|
|
20
|
+
checkColor?: Color
|
|
21
|
+
text?: string
|
|
22
|
+
value?: boolean
|
|
23
|
+
modelValue?: boolean
|
|
24
|
+
validation?: Validatable
|
|
25
|
+
hideError?: boolean
|
|
26
|
+
}>(), {
|
|
27
|
+
value: undefined,
|
|
28
|
+
modelValue: undefined
|
|
24
29
|
})
|
|
25
30
|
|
|
26
|
-
const emit = defineEmits
|
|
31
|
+
const emit = defineEmits<{
|
|
32
|
+
(e: 'update:model-value', value: boolean): void
|
|
33
|
+
(e: 'change', value: boolean): void
|
|
34
|
+
}>()
|
|
27
35
|
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
const _value = computed(() => {
|
|
37
|
+
return props.modelValue !== undefined
|
|
38
|
+
? props.modelValue
|
|
39
|
+
: props.value !== undefined ? props.value : false
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
function onClick() {
|
|
43
|
+
emit('update:model-value', !_value.value)
|
|
44
|
+
emit('change', !_value.value)
|
|
30
45
|
}
|
|
31
46
|
</script>
|
|
32
47
|
|
|
33
48
|
<template>
|
|
34
49
|
<SInputBase
|
|
35
50
|
class="SInputCheckbox"
|
|
36
|
-
:class="[size]"
|
|
51
|
+
:class="[size ?? 'small']"
|
|
37
52
|
:label="label"
|
|
38
53
|
:note="note"
|
|
39
54
|
:info="info"
|
|
@@ -44,21 +59,21 @@ function emitChange() {
|
|
|
44
59
|
:validation="validation"
|
|
45
60
|
>
|
|
46
61
|
<div class="container">
|
|
47
|
-
<div class="input" :class="{ on:
|
|
62
|
+
<div class="input" :class="{ on: _value }" role="button" @click="onClick">
|
|
48
63
|
<div class="box">
|
|
49
64
|
<div class="check">
|
|
50
65
|
<SIcon :icon="IconCheck" class="check-icon" />
|
|
51
66
|
</div>
|
|
52
67
|
</div>
|
|
53
68
|
|
|
54
|
-
<p class="text">{{ text }}</p>
|
|
69
|
+
<p v-if="text" class="text">{{ text }}</p>
|
|
55
70
|
</div>
|
|
56
71
|
</div>
|
|
57
72
|
<template v-if="$slots.info" #info><slot name="info" /></template>
|
|
58
73
|
</SInputBase>
|
|
59
74
|
</template>
|
|
60
75
|
|
|
61
|
-
<style lang="postcss"
|
|
76
|
+
<style scoped lang="postcss">
|
|
62
77
|
.container {
|
|
63
78
|
display: flex;
|
|
64
79
|
}
|
|
@@ -68,19 +83,19 @@ function emitChange() {
|
|
|
68
83
|
display: flex;
|
|
69
84
|
align-items: center;
|
|
70
85
|
height: 32px;
|
|
86
|
+
cursor: pointer;
|
|
71
87
|
|
|
72
88
|
&:hover {
|
|
73
89
|
.box {
|
|
74
|
-
border-color: var(--c-
|
|
90
|
+
border-color: var(--c-info-light);
|
|
75
91
|
}
|
|
76
92
|
}
|
|
77
93
|
}
|
|
78
94
|
|
|
79
95
|
.input.on {
|
|
80
96
|
.box {
|
|
81
|
-
border-color: var(--c-
|
|
82
|
-
background-color: var(--c-
|
|
83
|
-
box-shadow: var(--shadow-depth-3);
|
|
97
|
+
border-color: var(--c-info-light);
|
|
98
|
+
background-color: var(--c-info-light);
|
|
84
99
|
}
|
|
85
100
|
|
|
86
101
|
.check {
|
|
@@ -91,11 +106,12 @@ function emitChange() {
|
|
|
91
106
|
|
|
92
107
|
.box {
|
|
93
108
|
position: relative;
|
|
94
|
-
border:
|
|
95
|
-
border-radius:
|
|
96
|
-
width:
|
|
97
|
-
height:
|
|
98
|
-
|
|
109
|
+
border: 1px solid var(--c-divider-1);
|
|
110
|
+
border-radius: 4px;
|
|
111
|
+
width: 16px;
|
|
112
|
+
height: 16px;
|
|
113
|
+
background-color: var(--input-bg-color);
|
|
114
|
+
transition: border-color 0.25s, background-color 0.25s;
|
|
99
115
|
}
|
|
100
116
|
|
|
101
117
|
.check {
|
|
@@ -118,9 +134,9 @@ function emitChange() {
|
|
|
118
134
|
|
|
119
135
|
.text {
|
|
120
136
|
margin: 0;
|
|
121
|
-
padding-left:
|
|
137
|
+
padding-left: 10px;
|
|
122
138
|
line-height: 20px;
|
|
123
139
|
font-size: 14px;
|
|
124
|
-
font-weight:
|
|
140
|
+
font-weight: 400;
|
|
125
141
|
}
|
|
126
142
|
</style>
|
|
@@ -1,50 +1,73 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type { IconifyIcon } from '@iconify/vue/dist/offline'
|
|
3
|
-
import
|
|
3
|
+
import { computed } from 'vue'
|
|
4
|
+
import type { Validatable } from '../composables/Validation'
|
|
4
5
|
import SInputBase from './SInputBase.vue'
|
|
5
6
|
import SInputCheckbox from './SInputCheckbox.vue'
|
|
6
7
|
|
|
7
8
|
export type Size = 'mini' | 'small' | 'medium'
|
|
8
9
|
export type Color = 'neutral' | 'mute' | 'info' | 'success' | 'warning' | 'danger'
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
export type Value = string | number | boolean
|
|
12
|
+
|
|
13
|
+
export interface Option {
|
|
11
14
|
label: string
|
|
12
|
-
value:
|
|
15
|
+
value: Value
|
|
13
16
|
}
|
|
14
17
|
|
|
15
|
-
const props = defineProps
|
|
16
|
-
size
|
|
17
|
-
name
|
|
18
|
-
label
|
|
19
|
-
info
|
|
20
|
-
note
|
|
21
|
-
help
|
|
22
|
-
checkIcon
|
|
23
|
-
checkText
|
|
24
|
-
checkColor
|
|
25
|
-
options:
|
|
26
|
-
|
|
18
|
+
const props = withDefaults(defineProps<{
|
|
19
|
+
size?: Size
|
|
20
|
+
name?: string
|
|
21
|
+
label?: string
|
|
22
|
+
info?: string
|
|
23
|
+
note?: string
|
|
24
|
+
help?: string
|
|
25
|
+
checkIcon?: IconifyIcon
|
|
26
|
+
checkText?: string
|
|
27
|
+
checkColor?: Color
|
|
28
|
+
options: Option[]
|
|
29
|
+
nullable?: boolean
|
|
30
|
+
value?: Value[]
|
|
31
|
+
modelValue?: Value[]
|
|
32
|
+
validation?: Validatable
|
|
33
|
+
hideError?: boolean
|
|
34
|
+
}>(), {
|
|
35
|
+
nullable: true
|
|
27
36
|
})
|
|
28
37
|
|
|
29
|
-
const emit = defineEmits
|
|
38
|
+
const emit = defineEmits<{
|
|
39
|
+
(e: 'update:model-value', value: Value[]): void
|
|
40
|
+
(e: 'change', value: Value[]): void
|
|
41
|
+
}>()
|
|
42
|
+
|
|
43
|
+
const _value = computed(() => {
|
|
44
|
+
return props.modelValue !== undefined
|
|
45
|
+
? props.modelValue
|
|
46
|
+
: props.value !== undefined ? props.value : []
|
|
47
|
+
})
|
|
30
48
|
|
|
31
|
-
function isChecked(value:
|
|
32
|
-
return
|
|
49
|
+
function isChecked(value: Value): boolean {
|
|
50
|
+
return _value.value.includes(value)
|
|
33
51
|
}
|
|
34
52
|
|
|
35
|
-
function handleChange(value:
|
|
36
|
-
const distinct =
|
|
53
|
+
function handleChange(value: Value): void {
|
|
54
|
+
const distinct = _value.value
|
|
37
55
|
.filter((v) => v !== value)
|
|
38
|
-
.concat(
|
|
56
|
+
.concat(_value.value.includes(value) ? [] : [value])
|
|
39
57
|
|
|
40
|
-
|
|
58
|
+
if (distinct.length === 0 && !props.nullable) {
|
|
59
|
+
return
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
emit('update:model-value', distinct)
|
|
63
|
+
emit('change', distinct)
|
|
41
64
|
}
|
|
42
65
|
</script>
|
|
43
66
|
|
|
44
67
|
<template>
|
|
45
68
|
<SInputBase
|
|
46
69
|
class="SInputCheckboxes"
|
|
47
|
-
:class="[size]"
|
|
70
|
+
:class="[size ?? 'small']"
|
|
48
71
|
:name="name"
|
|
49
72
|
:label="label"
|
|
50
73
|
:note="note"
|
|
@@ -56,7 +79,7 @@ function handleChange(value: unknown): void {
|
|
|
56
79
|
>
|
|
57
80
|
<div class="container">
|
|
58
81
|
<div class="row">
|
|
59
|
-
<div v-for="option in options" :key="option.value" class="col">
|
|
82
|
+
<div v-for="option in options" :key="String(option.value)" class="col">
|
|
60
83
|
<SInputCheckbox
|
|
61
84
|
:text="option.label"
|
|
62
85
|
:model-value="isChecked(option.value)"
|
|
@@ -68,17 +91,3 @@ function handleChange(value: unknown): void {
|
|
|
68
91
|
<template v-if="$slots.info" #info><slot name="info" /></template>
|
|
69
92
|
</SInputBase>
|
|
70
93
|
</template>
|
|
71
|
-
|
|
72
|
-
<style lang="postcss" scoped>
|
|
73
|
-
.container {
|
|
74
|
-
display: flex;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.row {
|
|
78
|
-
margin: -2px -8px;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.col {
|
|
82
|
-
padding: 2px 8px;
|
|
83
|
-
}
|
|
84
|
-
</style>
|
|
@@ -111,7 +111,7 @@ function onChange(e: Event) {
|
|
|
111
111
|
.placeholder {
|
|
112
112
|
line-height: 30px;
|
|
113
113
|
font-size: var(--input-font-size, var(--input-mini-font-size));
|
|
114
|
-
font-weight:
|
|
114
|
+
font-weight: 400;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -123,7 +123,7 @@ function onChange(e: Event) {
|
|
|
123
123
|
.button {
|
|
124
124
|
padding: 0 8px;
|
|
125
125
|
line-height: 26px;
|
|
126
|
-
font-size:
|
|
126
|
+
font-size: 13px;
|
|
127
127
|
font-weight: 500;
|
|
128
128
|
}
|
|
129
129
|
|
|
@@ -133,10 +133,6 @@ function onChange(e: Event) {
|
|
|
133
133
|
font-size: var(--input-font-size, var(--input-small-font-size));
|
|
134
134
|
font-weight: 400;
|
|
135
135
|
}
|
|
136
|
-
|
|
137
|
-
.placeholder {
|
|
138
|
-
font-weight: 500;
|
|
139
|
-
}
|
|
140
136
|
}
|
|
141
137
|
|
|
142
138
|
.SInputFile.medium {
|
|
@@ -157,10 +153,6 @@ function onChange(e: Event) {
|
|
|
157
153
|
font-size: var(--input-font-size, var(--input-medium-font-size));
|
|
158
154
|
font-weight: 400;
|
|
159
155
|
}
|
|
160
|
-
|
|
161
|
-
.placeholder {
|
|
162
|
-
font-weight: 500;
|
|
163
|
-
}
|
|
164
156
|
}
|
|
165
157
|
|
|
166
158
|
.SInputFile.has-error {
|
|
@@ -112,7 +112,7 @@ function onClick() {
|
|
|
112
112
|
align-items: center;
|
|
113
113
|
border-radius: 50%;
|
|
114
114
|
width: 100%;
|
|
115
|
-
background-color: var(--c-info-
|
|
115
|
+
background-color: var(--c-info-light);
|
|
116
116
|
opacity: 0;
|
|
117
117
|
transform: scale(0);
|
|
118
118
|
transition: opacity 0.25s, transform 0.1s;
|