@globalbrain/sefirot 0.70.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 -800
- 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 +19 -35
- 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 +23 -33
- package/lib/components/SInputRadios.vue +37 -47
- package/lib/components/SInputText.vue +59 -632
- 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 +1 -3
- package/lib/components/SSheetMedium.vue +13 -25
- package/lib/components/SSnackbar.vue +18 -28
- package/lib/components/icons/SIconSend.vue +5 -0
- 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 -83
- 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 -282
- 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/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
|
@@ -10,26 +10,19 @@
|
|
|
10
10
|
</div>
|
|
11
11
|
</template>
|
|
12
12
|
|
|
13
|
-
<script lang="ts">
|
|
14
|
-
import { PropType
|
|
15
|
-
import { Item } from '../composables/Dropdown'
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import { PropType } from 'vue'
|
|
16
15
|
import SIconX from './icons/SIconX.vue'
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
props: {
|
|
24
|
-
item: { type: Object as PropType<Item>, required: true },
|
|
25
|
-
disabled: { type: Boolean, default: false }
|
|
26
|
-
}
|
|
17
|
+
defineProps({
|
|
18
|
+
item: { type: Object as PropType<any>, required: true },
|
|
19
|
+
disabled: { type: Boolean, default: false }
|
|
27
20
|
})
|
|
21
|
+
|
|
22
|
+
defineEmits(['remove'])
|
|
28
23
|
</script>
|
|
29
24
|
|
|
30
25
|
<style lang="postcss" scoped>
|
|
31
|
-
@import "@/assets/styles/variables";
|
|
32
|
-
|
|
33
26
|
.SInputDropdownItemTextTag {
|
|
34
27
|
display: flex;
|
|
35
28
|
border-radius: 12px;
|
|
@@ -37,7 +30,7 @@ export default defineComponent({
|
|
|
37
30
|
background-color: var(--c-white-mute);
|
|
38
31
|
}
|
|
39
32
|
|
|
40
|
-
.dark
|
|
33
|
+
.dark .SInputDropdownItemTextTag {
|
|
41
34
|
background-color: var(--c-black-mute);
|
|
42
35
|
}
|
|
43
36
|
|
|
@@ -50,7 +43,7 @@ export default defineComponent({
|
|
|
50
43
|
}
|
|
51
44
|
}
|
|
52
45
|
|
|
53
|
-
.dark
|
|
46
|
+
.dark .SInputDropdownItemTextTag.disabled {
|
|
54
47
|
background-color: var(--c-gray-dark-2);
|
|
55
48
|
}
|
|
56
49
|
|
|
@@ -76,7 +69,7 @@ export default defineComponent({
|
|
|
76
69
|
}
|
|
77
70
|
}
|
|
78
71
|
|
|
79
|
-
.dark
|
|
72
|
+
.dark .remove {
|
|
80
73
|
&:hover .remove-box {
|
|
81
74
|
background-color: var(--c-gray-dark-2)
|
|
82
75
|
}
|
|
@@ -8,26 +8,18 @@
|
|
|
8
8
|
</div>
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
|
-
<script lang="ts">
|
|
12
|
-
import { PropType
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
import { PropType } from 'vue'
|
|
13
13
|
import { UserItem } from '../composables/Dropdown'
|
|
14
14
|
import SAvatar from './SAvatar.vue'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
props: {
|
|
22
|
-
item: { type: Object as PropType<UserItem>, required: true },
|
|
23
|
-
disabled: { type: Boolean, default: false }
|
|
24
|
-
}
|
|
16
|
+
defineProps({
|
|
17
|
+
item: { type: Object as PropType<UserItem>, required: true },
|
|
18
|
+
disabled: { type: Boolean, default: false }
|
|
25
19
|
})
|
|
26
20
|
</script>
|
|
27
21
|
|
|
28
22
|
<style lang="postcss" scoped>
|
|
29
|
-
@import "@/assets/styles/variables";
|
|
30
|
-
|
|
31
23
|
.SInputDropdownItemUser {
|
|
32
24
|
position: relative;
|
|
33
25
|
}
|
|
@@ -16,28 +16,21 @@
|
|
|
16
16
|
</div>
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
|
-
<script lang="ts">
|
|
20
|
-
import { PropType
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
import { PropType } from 'vue'
|
|
21
21
|
import { UserItem } from '../composables/Dropdown'
|
|
22
22
|
import SIconX from './icons/SIconX.vue'
|
|
23
23
|
import SAvatar from './SAvatar.vue'
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
SAvatar
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
props: {
|
|
32
|
-
item: { type: Object as PropType<UserItem>, required: true },
|
|
33
|
-
disabled: { type: Boolean, default: false }
|
|
34
|
-
}
|
|
25
|
+
defineProps({
|
|
26
|
+
item: { type: Object as PropType<UserItem>, required: true },
|
|
27
|
+
disabled: { type: Boolean, default: false }
|
|
35
28
|
})
|
|
29
|
+
|
|
30
|
+
defineEmits(['remove'])
|
|
36
31
|
</script>
|
|
37
32
|
|
|
38
33
|
<style lang="postcss" scoped>
|
|
39
|
-
@import "@/assets/styles/variables";
|
|
40
|
-
|
|
41
34
|
.SInputDropdownItemUserTag {
|
|
42
35
|
display: flex;
|
|
43
36
|
border-radius: 12px;
|
|
@@ -50,7 +43,7 @@ export default defineComponent({
|
|
|
50
43
|
background-color: var(--c-gray-light-4);
|
|
51
44
|
}
|
|
52
45
|
|
|
53
|
-
.dark
|
|
46
|
+
.dark .SInputDropdownItemUserTag {
|
|
54
47
|
background-color: var(--c-black-mute);
|
|
55
48
|
}
|
|
56
49
|
|
|
@@ -82,7 +75,7 @@ export default defineComponent({
|
|
|
82
75
|
}
|
|
83
76
|
}
|
|
84
77
|
|
|
85
|
-
.dark
|
|
78
|
+
.dark .remove {
|
|
86
79
|
&:hover .remove-box {
|
|
87
80
|
background-color: var(--c-gray-dark-2)
|
|
88
81
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
<SInputBase
|
|
3
3
|
class="SInputFile"
|
|
4
4
|
:class="classes"
|
|
5
|
-
:name="name"
|
|
6
5
|
:label="label"
|
|
7
6
|
:note="note"
|
|
8
7
|
:help="help"
|
|
@@ -13,7 +12,7 @@
|
|
|
13
12
|
ref="input"
|
|
14
13
|
class="input"
|
|
15
14
|
type="file"
|
|
16
|
-
@change="
|
|
15
|
+
@change="handleChange"
|
|
17
16
|
>
|
|
18
17
|
|
|
19
18
|
<div class="box" role="button" @click="open">
|
|
@@ -31,63 +30,49 @@
|
|
|
31
30
|
</SInputBase>
|
|
32
31
|
</template>
|
|
33
32
|
|
|
34
|
-
<script lang="ts">
|
|
35
|
-
import { PropType,
|
|
36
|
-
import { Validation } from '../
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import { PropType, ref, computed } from 'vue'
|
|
35
|
+
import { Validation, Validatable } from '../composables/Validation'
|
|
37
36
|
import SInputBase from './SInputBase.vue'
|
|
38
37
|
|
|
39
38
|
type Size = 'mini' | 'small' | 'medium'
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
help: { type: String, default: null },
|
|
53
|
-
placeholder: { type: String, default: null },
|
|
54
|
-
errorMessage: { type: Boolean, default: true },
|
|
55
|
-
value: { type: File, default: null },
|
|
56
|
-
validation: { type: Object as PropType<Validation>, default: null }
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
setup(props, { emit }) {
|
|
60
|
-
const input = ref<HTMLInputElement | null>(null)
|
|
61
|
-
|
|
62
|
-
const classes = computed(() => [props.size])
|
|
63
|
-
|
|
64
|
-
const fileName = computed(() => {
|
|
65
|
-
return props.value ? props.value.name : null
|
|
66
|
-
})
|
|
67
|
-
|
|
68
|
-
function open(): void {
|
|
69
|
-
input.value!.click()
|
|
70
|
-
}
|
|
40
|
+
const props = defineProps({
|
|
41
|
+
size: { type: String as PropType<Size>, default: 'small' },
|
|
42
|
+
label: { type: String, default: null },
|
|
43
|
+
note: { type: String, default: null },
|
|
44
|
+
text: { type: String, default: 'Choose File' },
|
|
45
|
+
help: { type: String, default: null },
|
|
46
|
+
placeholder: { type: String, default: null },
|
|
47
|
+
errorMessage: { type: Boolean, default: true },
|
|
48
|
+
modelValue: { type: Object as PropType<File | null>, default: null },
|
|
49
|
+
validation: { type: Object as PropType<Validatable>, default: null }
|
|
50
|
+
})
|
|
71
51
|
|
|
72
|
-
|
|
73
|
-
emit('input', file ?? null)
|
|
74
|
-
file && props.validation?.$touch()
|
|
75
|
-
}
|
|
52
|
+
const emit = defineEmits(['update:modelValue'])
|
|
76
53
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
}
|
|
54
|
+
const input = ref<HTMLInputElement | null>(null)
|
|
55
|
+
|
|
56
|
+
const classes = computed(() => [props.size])
|
|
57
|
+
|
|
58
|
+
const fileName = computed(() => {
|
|
59
|
+
return props.modelValue ? props.modelValue.name : null
|
|
85
60
|
})
|
|
61
|
+
|
|
62
|
+
function open(): void {
|
|
63
|
+
input.value!.click()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function handleChange(e: Event): void {
|
|
67
|
+
const file = (e.target as any).files[0]
|
|
68
|
+
|
|
69
|
+
emit('update:modelValue', file ?? null)
|
|
70
|
+
|
|
71
|
+
file && props.validation?.$touch()
|
|
72
|
+
}
|
|
86
73
|
</script>
|
|
87
74
|
|
|
88
75
|
<style lang="postcss" scoped>
|
|
89
|
-
@import "@/assets/styles/variables";
|
|
90
|
-
|
|
91
76
|
.SInputFile.mini {
|
|
92
77
|
.action {
|
|
93
78
|
padding: 2px 8px 2px 2px;
|
|
@@ -167,13 +152,13 @@ export default defineComponent({
|
|
|
167
152
|
|
|
168
153
|
.box {
|
|
169
154
|
display: flex;
|
|
170
|
-
border: 1px solid var(--input-
|
|
155
|
+
border: 1px solid var(--input-border);
|
|
171
156
|
border-radius: 4px;
|
|
172
157
|
cursor: pointer;
|
|
173
158
|
transition: border-color .25s;
|
|
174
159
|
|
|
175
160
|
&:hover {
|
|
176
|
-
border-color: var(--input-
|
|
161
|
+
border-color: var(--input-focus-border);
|
|
177
162
|
|
|
178
163
|
.button {
|
|
179
164
|
background-color: var(--c-gray-light-4);
|
|
@@ -181,7 +166,7 @@ export default defineComponent({
|
|
|
181
166
|
}
|
|
182
167
|
}
|
|
183
168
|
|
|
184
|
-
.dark
|
|
169
|
+
.dark .box {
|
|
185
170
|
&:hover {
|
|
186
171
|
.button {
|
|
187
172
|
background-color: var(--c-gray-dark-3);
|
|
@@ -201,7 +186,7 @@ export default defineComponent({
|
|
|
201
186
|
transition: background-color .25s;
|
|
202
187
|
}
|
|
203
188
|
|
|
204
|
-
.dark
|
|
189
|
+
.dark .button {
|
|
205
190
|
background-color: var(--c-black-mute);
|
|
206
191
|
transition: background-color .25s;
|
|
207
192
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<SInputBase
|
|
3
3
|
class="SInputHMS"
|
|
4
|
-
:class="[size,
|
|
5
|
-
:name="name"
|
|
4
|
+
:class="[size, { disabled }]"
|
|
6
5
|
:label="label"
|
|
7
6
|
:note="note"
|
|
8
7
|
:help="help"
|
|
@@ -13,7 +12,7 @@
|
|
|
13
12
|
<input
|
|
14
13
|
v-if="hour"
|
|
15
14
|
class="input hour"
|
|
16
|
-
:value="
|
|
15
|
+
:value="modelValue?.hour ?? null"
|
|
17
16
|
placeholder="00"
|
|
18
17
|
:disabled="disabled"
|
|
19
18
|
@blur="updateHour"
|
|
@@ -22,7 +21,7 @@
|
|
|
22
21
|
<input
|
|
23
22
|
v-if="minute"
|
|
24
23
|
class="input minute"
|
|
25
|
-
:value="
|
|
24
|
+
:value="modelValue?.minute ?? null"
|
|
26
25
|
placeholder="00"
|
|
27
26
|
:disabled="disabled"
|
|
28
27
|
@blur="updateMinute"
|
|
@@ -31,7 +30,7 @@
|
|
|
31
30
|
<input
|
|
32
31
|
v-if="second"
|
|
33
32
|
class="input second"
|
|
34
|
-
:value="
|
|
33
|
+
:value="modelValue?.second ?? null"
|
|
35
34
|
placeholder="00"
|
|
36
35
|
:disabled="disabled"
|
|
37
36
|
@blur="updateSecond"
|
|
@@ -44,14 +43,13 @@
|
|
|
44
43
|
</SInputBase>
|
|
45
44
|
</template>
|
|
46
45
|
|
|
47
|
-
<script lang="ts">
|
|
48
|
-
import { PropType
|
|
46
|
+
<script setup lang="ts">
|
|
47
|
+
import { PropType } from 'vue'
|
|
49
48
|
import { SyntheticInputEvent } from '../types/Utils'
|
|
50
|
-
import {
|
|
49
|
+
import { Validatable } from '../composables/Validation'
|
|
51
50
|
import SInputBase from './SInputBase.vue'
|
|
52
51
|
|
|
53
52
|
type Size = 'mini' | 'small' | 'medium'
|
|
54
|
-
type Mode = 'outlined'
|
|
55
53
|
|
|
56
54
|
interface Value {
|
|
57
55
|
hour?: string
|
|
@@ -67,120 +65,104 @@ export interface Fields {
|
|
|
67
65
|
second?: boolean
|
|
68
66
|
}
|
|
69
67
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
minute: { type: Boolean, default: true },
|
|
85
|
-
second: { type: Boolean, default: true },
|
|
86
|
-
disabled: { type: Boolean, default: false },
|
|
87
|
-
errorMessage: { type: Boolean, default: true },
|
|
88
|
-
value: { type: Object as PropType<Value>, default: null },
|
|
89
|
-
validation: { type: Object as PropType<Validation>, default: null }
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
setup(props, { emit }) {
|
|
93
|
-
const touched = {
|
|
94
|
-
hour: false,
|
|
95
|
-
minute: false,
|
|
96
|
-
second: false
|
|
97
|
-
}
|
|
68
|
+
const props = defineProps({
|
|
69
|
+
size: { type: String as PropType<Size>, default: 'small' },
|
|
70
|
+
label: { type: String, default: null },
|
|
71
|
+
note: { type: String, default: null },
|
|
72
|
+
help: { type: String, default: null },
|
|
73
|
+
placeholder: { type: String, default: null },
|
|
74
|
+
hour: { type: Boolean, default: true },
|
|
75
|
+
minute: { type: Boolean, default: true },
|
|
76
|
+
second: { type: Boolean, default: true },
|
|
77
|
+
disabled: { type: Boolean, default: false },
|
|
78
|
+
errorMessage: { type: Boolean, default: true },
|
|
79
|
+
modelValue: { type: Object as PropType<Value>, default: null },
|
|
80
|
+
validation: { type: Object as PropType<Validatable>, default: null }
|
|
81
|
+
})
|
|
98
82
|
|
|
99
|
-
|
|
100
|
-
const value = getValue(e.target.value)
|
|
83
|
+
const emit = defineEmits(['update:modelValue'])
|
|
101
84
|
|
|
102
|
-
|
|
103
|
-
|
|
85
|
+
const touched = {
|
|
86
|
+
hour: false,
|
|
87
|
+
minute: false,
|
|
88
|
+
second: false
|
|
89
|
+
}
|
|
104
90
|
|
|
105
|
-
|
|
106
|
-
|
|
91
|
+
function updateHour(e: FocusEvent): void {
|
|
92
|
+
const value = getValue((e.target as HTMLInputElement).value)
|
|
107
93
|
|
|
108
|
-
|
|
109
|
-
|
|
94
|
+
update('hour', value)
|
|
95
|
+
}
|
|
110
96
|
|
|
111
|
-
|
|
112
|
-
|
|
97
|
+
function updateMinute(e: FocusEvent): void {
|
|
98
|
+
const value = getValue((e.target as HTMLInputElement).value)
|
|
113
99
|
|
|
114
|
-
|
|
115
|
-
|
|
100
|
+
update('minute', value ? value.padStart(2, '0') : undefined)
|
|
101
|
+
}
|
|
116
102
|
|
|
117
|
-
|
|
118
|
-
|
|
103
|
+
function updateSecond(e: FocusEvent): void {
|
|
104
|
+
const value = getValue((e.target as HTMLInputElement).value)
|
|
119
105
|
|
|
120
|
-
|
|
106
|
+
update('second', value ? value.padStart(2, '0') : undefined)
|
|
107
|
+
}
|
|
121
108
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
: emit('input', data)
|
|
109
|
+
function update(type: ValueType, value?: string): void {
|
|
110
|
+
const data = { ...props.modelValue } as Value
|
|
125
111
|
|
|
126
|
-
|
|
127
|
-
}
|
|
112
|
+
setValue(data, type, value)
|
|
128
113
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}
|
|
114
|
+
data.hour === undefined && data.minute === undefined && data.second === undefined
|
|
115
|
+
? emit('update:modelValue', null)
|
|
116
|
+
: emit('update:modelValue', data)
|
|
133
117
|
|
|
134
|
-
|
|
118
|
+
emitTouch(type)
|
|
119
|
+
}
|
|
135
120
|
|
|
136
|
-
|
|
137
|
-
|
|
121
|
+
function getValue(value: string): string | undefined {
|
|
122
|
+
if (value === '') {
|
|
123
|
+
return undefined
|
|
124
|
+
}
|
|
138
125
|
|
|
139
|
-
|
|
140
|
-
if (value === undefined) {
|
|
141
|
-
delete data[type]
|
|
142
|
-
return
|
|
143
|
-
}
|
|
126
|
+
const input = Number(value)
|
|
144
127
|
|
|
145
|
-
|
|
146
|
-
|
|
128
|
+
return isNaN(input) ? undefined : String(input)
|
|
129
|
+
}
|
|
147
130
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
131
|
+
function setValue(data: Value, type: ValueType, value?: string): void {
|
|
132
|
+
if (value === undefined) {
|
|
133
|
+
delete data[type]
|
|
134
|
+
return
|
|
135
|
+
}
|
|
152
136
|
|
|
153
|
-
|
|
137
|
+
data[type] = value
|
|
138
|
+
}
|
|
154
139
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
140
|
+
function emitTouch(type: ValueType): void {
|
|
141
|
+
if (!props.validation || props.validation.$dirty) {
|
|
142
|
+
return
|
|
143
|
+
}
|
|
159
144
|
|
|
160
|
-
|
|
161
|
-
const requiredTouched = [] as boolean[]
|
|
145
|
+
touched[type] = true
|
|
162
146
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
147
|
+
if (createRequiredTouched().every(v => v)) {
|
|
148
|
+
props.validation.$touch()
|
|
149
|
+
}
|
|
150
|
+
}
|
|
168
151
|
|
|
169
|
-
|
|
170
|
-
|
|
152
|
+
function createRequiredTouched(): boolean[] {
|
|
153
|
+
const requiredTouched = [] as boolean[]
|
|
171
154
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
updateSecond
|
|
155
|
+
for (const key in touched) {
|
|
156
|
+
if ((props as any)[key]) {
|
|
157
|
+
requiredTouched.push((touched as any)[key])
|
|
176
158
|
}
|
|
177
159
|
}
|
|
178
|
-
|
|
160
|
+
|
|
161
|
+
return requiredTouched
|
|
162
|
+
}
|
|
179
163
|
</script>
|
|
180
164
|
|
|
181
165
|
<style lang="postcss" scoped>
|
|
182
|
-
@import "@/assets/styles/variables";
|
|
183
|
-
|
|
184
166
|
.SInputHMS.mini {
|
|
185
167
|
.container {
|
|
186
168
|
padding: 0 8px;
|
|
@@ -251,30 +233,18 @@ export default defineComponent({
|
|
|
251
233
|
}
|
|
252
234
|
}
|
|
253
235
|
|
|
254
|
-
.SInputHMS.
|
|
255
|
-
.container
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
transition: border-color .25s;
|
|
259
|
-
|
|
260
|
-
&:hover {
|
|
261
|
-
border-color: var(--input-focus-border);
|
|
262
|
-
}
|
|
236
|
+
.SInputHMS.disabled {
|
|
237
|
+
.container,
|
|
238
|
+
.input {
|
|
239
|
+
cursor: not-allowed;
|
|
263
240
|
}
|
|
264
|
-
}
|
|
265
241
|
|
|
266
|
-
.SInputHMS.outlined.disabled {
|
|
267
242
|
.container {
|
|
268
|
-
border-color: var(--input-
|
|
269
|
-
background-color: var(--input-
|
|
243
|
+
border-color: var(--input-border);
|
|
244
|
+
background-color: var(--input-disabled-bg);
|
|
270
245
|
}
|
|
271
246
|
}
|
|
272
247
|
|
|
273
|
-
.SInputHMS.disabled {
|
|
274
|
-
.container { cursor: not-allowed; }
|
|
275
|
-
.input { cursor: not-allowed; }
|
|
276
|
-
}
|
|
277
|
-
|
|
278
248
|
.SInputHMS.has-error {
|
|
279
249
|
.container {
|
|
280
250
|
border-color: var(--c-danger);
|
|
@@ -283,6 +253,13 @@ export default defineComponent({
|
|
|
283
253
|
|
|
284
254
|
.container {
|
|
285
255
|
display: inline-flex;
|
|
256
|
+
border: 1px solid var(--input-border);
|
|
257
|
+
border-radius: 4px;
|
|
258
|
+
transition: border-color .25s;
|
|
259
|
+
|
|
260
|
+
&:hover {
|
|
261
|
+
border-color: var(--input-focus-border);
|
|
262
|
+
}
|
|
286
263
|
}
|
|
287
264
|
|
|
288
265
|
.input {
|