@globalbrain/sefirot 0.70.1 → 2.0.0-draft.2
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 +4 -802
- 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 -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 +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
|
@@ -12,49 +12,38 @@
|
|
|
12
12
|
:type="action.type"
|
|
13
13
|
:label="action.label"
|
|
14
14
|
inverse
|
|
15
|
-
@click="action
|
|
15
|
+
@click="handleCallback(action)"
|
|
16
16
|
/>
|
|
17
17
|
</div>
|
|
18
18
|
</div>
|
|
19
19
|
</div>
|
|
20
20
|
</template>
|
|
21
21
|
|
|
22
|
-
<script lang="ts">
|
|
23
|
-
import {
|
|
24
|
-
import { useStore } from '
|
|
22
|
+
<script setup lang="ts">
|
|
23
|
+
import { PropType } from 'vue'
|
|
24
|
+
import { useStore } from 'vuex'
|
|
25
25
|
import { Action } from '../store/snackbars'
|
|
26
26
|
import SIconX from './icons/SIconX.vue'
|
|
27
27
|
import SButton from './SButton.vue'
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
props: {
|
|
36
|
-
id: { type: Number, required: true },
|
|
37
|
-
text: { type: String, required: true },
|
|
38
|
-
actions: { type: Array as PropType<Action[]>, default: null }
|
|
39
|
-
},
|
|
29
|
+
const props = defineProps({
|
|
30
|
+
id: { type: Number, required: true },
|
|
31
|
+
text: { type: String, required: true },
|
|
32
|
+
actions: { type: Array as PropType<Action[]>, default: null }
|
|
33
|
+
})
|
|
40
34
|
|
|
41
|
-
|
|
42
|
-
const store = useStore()
|
|
35
|
+
const store = useStore()
|
|
43
36
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
37
|
+
function close() {
|
|
38
|
+
store.dispatch('snackbars/pop', props.id)
|
|
39
|
+
}
|
|
47
40
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
})
|
|
41
|
+
function handleCallback(action: Action) {
|
|
42
|
+
action.callback()
|
|
43
|
+
}
|
|
53
44
|
</script>
|
|
54
45
|
|
|
55
46
|
<style lang="postcss" scoped>
|
|
56
|
-
@import "@/assets/styles/variables";
|
|
57
|
-
|
|
58
47
|
.SSnackbar {
|
|
59
48
|
position: relative;
|
|
60
49
|
border: 1px solid transparent;
|
|
@@ -65,7 +54,7 @@ export default defineComponent({
|
|
|
65
54
|
box-shadow: var(--shadow-depth-5);
|
|
66
55
|
}
|
|
67
56
|
|
|
68
|
-
.dark
|
|
57
|
+
.dark .SSnackbar {
|
|
69
58
|
border-color: var(--c-divider-light);
|
|
70
59
|
}
|
|
71
60
|
|
|
@@ -113,3 +102,4 @@ export default defineComponent({
|
|
|
113
102
|
}
|
|
114
103
|
}
|
|
115
104
|
</style>
|
|
105
|
+
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
3
|
+
<path d="M23,1.9c0-0.1,0-0.2-0.1-0.3c0,0,0-0.1,0-0.1c0-0.1-0.1-0.2-0.2-0.3c-0.1-0.1-0.2-0.1-0.3-0.2c0,0-0.1,0-0.1,0c-0.1,0-0.2,0-0.3-0.1C22,1,22,1,22,1c-0.1,0-0.2,0-0.3,0.1l-20,7C1.3,8.2,1,8.5,1,9c0,0.4,0.2,0.8,0.6,1l8.6,3.8l3.8,8.6c0.2,0.4,0.5,0.6,0.9,0.6c0,0,0,0,0,0c0.4,0,0.8-0.3,0.9-0.7l7-20C23,2.2,23,2.1,23,1.9C23,2,23,2,23,1.9z M18.2,4.4l-7.4,7.4L4.7,9.1L18.2,4.4z M14.9,19.3l-2.7-6.1l7.4-7.4L14.9,19.3z" />
|
|
4
|
+
</svg>
|
|
5
|
+
</template>
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useModalUid } from './Modal'
|
|
1
|
+
import { useStore } from 'vuex'
|
|
2
|
+
import { useModalId } from './Modal'
|
|
4
3
|
|
|
5
4
|
export interface Dialog {
|
|
6
|
-
open(dialog?:
|
|
5
|
+
open(dialog?: Options): Promise<any>
|
|
7
6
|
close(): Promise<any>
|
|
8
7
|
}
|
|
9
8
|
|
|
10
|
-
export interface
|
|
11
|
-
type?:
|
|
9
|
+
export interface Options {
|
|
10
|
+
type?: 'confirm' | 'loading'
|
|
12
11
|
title?: string
|
|
13
12
|
text?: string
|
|
14
13
|
actions?: Action[]
|
|
@@ -20,23 +19,16 @@ export interface Action {
|
|
|
20
19
|
callback(): void
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
export type DialogType = Values<typeof DialogTypes>
|
|
24
|
-
|
|
25
|
-
export const DialogTypes = {
|
|
26
|
-
Confirm: 'confirm',
|
|
27
|
-
Loading: 'loading'
|
|
28
|
-
} as const
|
|
29
|
-
|
|
30
22
|
export function useDialog(): Dialog {
|
|
31
23
|
const store = useStore()
|
|
32
|
-
const
|
|
24
|
+
const id = useModalId()
|
|
33
25
|
|
|
34
|
-
function open(
|
|
35
|
-
return store.dispatch('dialog/open', { ...
|
|
26
|
+
function open(options?: Options) {
|
|
27
|
+
return store.dispatch('dialog/open', { ...options, id })
|
|
36
28
|
}
|
|
37
29
|
|
|
38
30
|
function close() {
|
|
39
|
-
return store.dispatch('dialog/close',
|
|
31
|
+
return store.dispatch('dialog/close', id)
|
|
40
32
|
}
|
|
41
33
|
|
|
42
34
|
return {
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import { ref } from '
|
|
1
|
+
import { ref, watch } from 'vue'
|
|
2
2
|
|
|
3
|
-
export function
|
|
3
|
+
export function useFlyout() {
|
|
4
4
|
const container = ref<any>(null)
|
|
5
5
|
|
|
6
6
|
const isOpen = ref(false)
|
|
7
7
|
|
|
8
8
|
function open(): void {
|
|
9
9
|
isOpen.value = true
|
|
10
|
-
document.addEventListener('click', closeOnClickOutside)
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
function close(): void {
|
|
14
13
|
isOpen.value = false
|
|
15
|
-
document.removeEventListener('click', closeOnClickOutside)
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
function toggle(): void {
|
|
@@ -29,6 +27,15 @@ export function useMenu() {
|
|
|
29
27
|
return !!el && !!(el.offsetWidth || el.offsetHeight || el.getClientRects().length)
|
|
30
28
|
}
|
|
31
29
|
|
|
30
|
+
watch(isOpen, (value) => {
|
|
31
|
+
if (value) {
|
|
32
|
+
document.addEventListener('click', closeOnClickOutside)
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
document.removeEventListener('click', closeOnClickOutside)
|
|
37
|
+
})
|
|
38
|
+
|
|
32
39
|
return {
|
|
33
40
|
container,
|
|
34
41
|
isOpen,
|
package/lib/composables/Form.ts
CHANGED
|
@@ -1,66 +1,64 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Ref, ToRefs, reactive, computed } from 'vue'
|
|
2
|
+
import { cloneDeep } from '../support/Utils'
|
|
3
|
+
import { useSnackbar } from './Snackbar'
|
|
4
|
+
import { Validation, ExtractState, ValidationArgs, useValidation } from './Validation'
|
|
4
5
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
data: Data<T>
|
|
9
|
-
validation?: Validation
|
|
6
|
+
export interface Form<D> {
|
|
7
|
+
data: D
|
|
8
|
+
validation: Ref<Validation>
|
|
10
9
|
init(): void
|
|
11
|
-
|
|
10
|
+
reset(): void
|
|
11
|
+
validate(): Promise<boolean>
|
|
12
|
+
validateAndNotify(): Promise<boolean>
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export interface UseFormOptions<
|
|
15
|
-
data:
|
|
16
|
-
rules?:
|
|
15
|
+
export interface UseFormOptions<D> {
|
|
16
|
+
data: D
|
|
17
|
+
rules?: Ref<any> | any
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
value: any
|
|
22
|
-
) => void
|
|
23
|
-
|
|
24
|
-
export type FormWithValidation<T, U extends Form<T> = Form<T>> = WithRequired<U, 'validation'>
|
|
25
|
-
|
|
26
|
-
export type UseFormOptionsWithRules<T, U extends UseFormOptions<T> = UseFormOptions<T>> = WithRequired<U, 'rules'>
|
|
27
|
-
|
|
28
|
-
type Data<T> = UnwrapRef<T>
|
|
20
|
+
export function useForm<D>(options: UseFormOptions<D>): Form<D> {
|
|
21
|
+
const snackbar = useSnackbar()
|
|
29
22
|
|
|
30
|
-
|
|
31
|
-
options: UseFormOptionsWithRules<T>
|
|
32
|
-
): FormWithValidation<T>
|
|
23
|
+
const initialData = cloneDeep(options.data)
|
|
33
24
|
|
|
34
|
-
|
|
35
|
-
options: UseFormOptions<T>
|
|
36
|
-
): Form<T>
|
|
25
|
+
const data = reactive(options.data as any)
|
|
37
26
|
|
|
38
|
-
|
|
39
|
-
options: UseFormOptions<T> | UseFormOptionsWithRules<T>
|
|
40
|
-
): Form<T> | FormWithValidation<T> {
|
|
41
|
-
const initialData = getData(options.data)
|
|
42
|
-
const rules = options.rules
|
|
27
|
+
const rules = options.rules ?? {}
|
|
43
28
|
|
|
44
|
-
const
|
|
45
|
-
const validation = rules ? useFormValidation(data, rules) : undefined
|
|
29
|
+
const validation = useValidation(data, rules as any)
|
|
46
30
|
|
|
47
31
|
function init(): void {
|
|
48
32
|
Object.assign(data, initialData)
|
|
49
|
-
|
|
33
|
+
reset()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function reset(): void {
|
|
37
|
+
validation.value.$reset()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function validate(): Promise<boolean> {
|
|
41
|
+
return validation.value.$validate()
|
|
50
42
|
}
|
|
51
43
|
|
|
52
|
-
function
|
|
53
|
-
|
|
44
|
+
async function validateAndNotify(): Promise<boolean> {
|
|
45
|
+
const result = await validate()
|
|
46
|
+
|
|
47
|
+
if (!result) {
|
|
48
|
+
snackbar.push({
|
|
49
|
+
text: 'Form contains errors. Please correct them and try again.'
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return result
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
return {
|
|
57
57
|
data,
|
|
58
|
-
validation,
|
|
59
58
|
init,
|
|
60
|
-
|
|
59
|
+
reset,
|
|
60
|
+
validation,
|
|
61
|
+
validate,
|
|
62
|
+
validateAndNotify
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
|
-
|
|
64
|
-
function getData<T extends Record<string, any>>(data: T | (() => T)): T {
|
|
65
|
-
return data instanceof Function ? data() : data
|
|
66
|
-
}
|
package/lib/composables/Modal.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { useStore } from 'vuex'
|
|
1
2
|
import { Options as ModalOptions } from '../store/modal'
|
|
2
|
-
import { useStore } from './Store'
|
|
3
3
|
|
|
4
4
|
export interface Modal {
|
|
5
5
|
open(item?: OpenOptions): Promise<any>
|
|
@@ -7,28 +7,28 @@ export interface Modal {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export interface OpenOptions {
|
|
10
|
+
id?: number
|
|
10
11
|
component?: any
|
|
11
|
-
uid?: number
|
|
12
12
|
data?: Record<string, any>
|
|
13
13
|
options?: ModalOptions
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
let
|
|
16
|
+
let modalId = 0
|
|
17
17
|
|
|
18
|
-
export function useModal(component
|
|
18
|
+
export function useModal(component: any): Modal {
|
|
19
19
|
const store = useStore()
|
|
20
|
-
const
|
|
20
|
+
const id = useModalId()
|
|
21
21
|
|
|
22
22
|
function open(item: OpenOptions = {}) {
|
|
23
23
|
return store.dispatch('modal/open', {
|
|
24
|
-
|
|
24
|
+
id,
|
|
25
25
|
component,
|
|
26
26
|
...item
|
|
27
27
|
})
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function close() {
|
|
31
|
-
return store.dispatch('modal/close',
|
|
31
|
+
return store.dispatch('modal/close', id)
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return {
|
|
@@ -37,6 +37,6 @@ export function useModal(component?: any): Modal {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export function
|
|
41
|
-
return ++
|
|
40
|
+
export function useModalId(): number {
|
|
41
|
+
return ++modalId
|
|
42
42
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useStore } from 'vuex'
|
|
2
|
+
import { Snackbar as SnackbarOptions } from '../store/snackbars'
|
|
3
|
+
|
|
4
|
+
export interface Snackbar {
|
|
5
|
+
push(options: SnackbarOptions): void
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function useSnackbar(): Snackbar {
|
|
9
|
+
const store = useStore()
|
|
10
|
+
|
|
11
|
+
function push(options: SnackbarOptions): void {
|
|
12
|
+
store.dispatch('snackbars/push', options)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
push
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Ref, ToRefs } from 'vue'
|
|
2
|
+
import useVuelidate, {
|
|
3
|
+
Validation,
|
|
4
|
+
ValidationArgs,
|
|
5
|
+
GlobalConfig,
|
|
6
|
+
ExtractState,
|
|
7
|
+
ErrorObject
|
|
8
|
+
} from '@vuelidate/core'
|
|
9
|
+
|
|
10
|
+
export type { Validation, ValidationArgs, GlobalConfig, ExtractState }
|
|
11
|
+
|
|
12
|
+
export interface Validatable {
|
|
13
|
+
readonly $dirty: boolean
|
|
14
|
+
readonly $errors: ErrorObject[]
|
|
15
|
+
readonly $invalid: boolean
|
|
16
|
+
readonly $touch: () => void
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function useValidation<
|
|
20
|
+
T extends ExtractState<A>,
|
|
21
|
+
A extends ValidationArgs
|
|
22
|
+
>(
|
|
23
|
+
state: T | Ref<T> | ToRefs<T>,
|
|
24
|
+
rules: Ref<A> | A,
|
|
25
|
+
config?: GlobalConfig
|
|
26
|
+
): Ref<Validation<A>> {
|
|
27
|
+
return useVuelidate(rules, state, config)
|
|
28
|
+
}
|
package/lib/mixins/Sheet.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { App } from 'vue'
|
|
2
2
|
import SSheet from '../components/SSheet.vue'
|
|
3
3
|
import SSheetHeader from '../components/SSheetHeader.vue'
|
|
4
4
|
import SSheetHeaderTitle from '../components/SSheetHeaderTitle.vue'
|
|
@@ -7,8 +7,8 @@ import SSheetFooter from '../components/SSheetFooter.vue'
|
|
|
7
7
|
import SSheetFooterActions from '../components/SSheetFooterActions.vue'
|
|
8
8
|
import SSheetFooterAction from '../components/SSheetFooterAction.vue'
|
|
9
9
|
|
|
10
|
-
export
|
|
11
|
-
|
|
10
|
+
export function mixin(app: App): void {
|
|
11
|
+
app.mixin({
|
|
12
12
|
components: {
|
|
13
13
|
SSheet,
|
|
14
14
|
SSheetHeader,
|
package/lib/store/Sefirot.ts
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { Store, Plugin } from 'vuex'
|
|
2
2
|
import modal, { State as ModalState } from './modal'
|
|
3
3
|
import dialog from './dialog'
|
|
4
|
-
import
|
|
5
|
-
import screen, { State as ScreenState } from './screen'
|
|
6
|
-
import snackbars, { State as SnackbarState } from './snackbars'
|
|
4
|
+
import snackbars, { State as SnackbarsState } from './snackbars'
|
|
7
5
|
|
|
8
6
|
export interface State {
|
|
9
7
|
modal: ModalState
|
|
10
|
-
|
|
11
|
-
snackbars: SnackbarState
|
|
8
|
+
snackbars: SnackbarsState
|
|
12
9
|
}
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
store
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
export function Sefirot<S = any>(): Plugin<S> {
|
|
12
|
+
return (store) => {
|
|
13
|
+
store.registerModule('modal', modal)
|
|
14
|
+
store.registerModule('dialog', dialog)
|
|
15
|
+
store.registerModule('snackbars', snackbars)
|
|
16
|
+
}
|
|
20
17
|
}
|
|
21
|
-
|
|
22
|
-
export default Sefirot
|
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
import { ActionTree, ActionContext } from 'vuex'
|
|
2
2
|
import SDialog from '../../components/SDialog.vue'
|
|
3
|
-
import { Dialog } from '../../composables/Dialog'
|
|
4
|
-
import { State as RootState } from '../Sefirot'
|
|
5
3
|
|
|
6
|
-
export
|
|
4
|
+
export interface OpenPayload {
|
|
5
|
+
id?: number
|
|
6
|
+
type?: 'confirm' | 'loading'
|
|
7
|
+
title?: string
|
|
8
|
+
text?: string
|
|
9
|
+
actions?: Action[]
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface Action {
|
|
13
|
+
type?: 'text' | 'mute'
|
|
14
|
+
label: string
|
|
15
|
+
callback(): void
|
|
16
|
+
}
|
|
7
17
|
|
|
8
|
-
export const actions: ActionTree<any,
|
|
9
|
-
open(context: ActionContext<any,
|
|
10
|
-
const {
|
|
18
|
+
export const actions: ActionTree<any, any> = {
|
|
19
|
+
open(context: ActionContext<any, any>, payload: OpenPayload): void {
|
|
20
|
+
const { id } = payload
|
|
11
21
|
|
|
12
|
-
delete
|
|
22
|
+
delete payload.id
|
|
13
23
|
|
|
14
24
|
context.dispatch('modal/open', {
|
|
15
|
-
|
|
25
|
+
id,
|
|
16
26
|
component: SDialog,
|
|
17
|
-
data:
|
|
27
|
+
data: payload,
|
|
18
28
|
options: {
|
|
19
29
|
closable: false
|
|
20
30
|
}
|
|
21
31
|
}, { root: true })
|
|
22
32
|
},
|
|
23
33
|
|
|
24
|
-
close(context: ActionContext<any,
|
|
34
|
+
close(context: ActionContext<any, any>, uid?: number): void {
|
|
25
35
|
context.dispatch('modal/close', uid, { root: true })
|
|
26
36
|
}
|
|
27
37
|
}
|
package/lib/store/modal/index.ts
CHANGED
|
@@ -1,44 +1,42 @@
|
|
|
1
|
-
import { shallowReactive, markRaw } from '
|
|
1
|
+
import { shallowReactive, markRaw } from 'vue'
|
|
2
2
|
import { ActionTree, ActionContext, MutationTree } from 'vuex'
|
|
3
|
-
import { State as RootState } from '../Sefirot'
|
|
4
3
|
|
|
5
4
|
export interface State {
|
|
6
5
|
items: Item[]
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
export interface Item {
|
|
9
|
+
id?: number
|
|
10
10
|
component: any
|
|
11
|
-
uid?: number
|
|
12
11
|
data?: Record<string, any>
|
|
13
12
|
options?: Options
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
export interface Options {
|
|
17
|
-
width?: string
|
|
18
16
|
closable?: boolean
|
|
19
17
|
}
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
function state(): State {
|
|
22
20
|
return {
|
|
23
21
|
items: []
|
|
24
22
|
}
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
|
|
28
|
-
open(context: ActionContext<State,
|
|
25
|
+
const actions: ActionTree<State, any> = {
|
|
26
|
+
open(context: ActionContext<State, any>, item: Item): void {
|
|
29
27
|
context.commit('push', item)
|
|
30
28
|
},
|
|
31
29
|
|
|
32
|
-
close(context: ActionContext<State,
|
|
33
|
-
|
|
30
|
+
close(context: ActionContext<State, any>, id?: number): void {
|
|
31
|
+
id ? context.commit('drop', id) : context.commit('pop')
|
|
34
32
|
},
|
|
35
33
|
|
|
36
|
-
closeAll(context: ActionContext<State,
|
|
34
|
+
closeAll(context: ActionContext<State, any>): void {
|
|
37
35
|
context.commit('flush')
|
|
38
36
|
}
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
|
|
39
|
+
const mutations: MutationTree<State> = {
|
|
42
40
|
push(state: State, item: Item): void {
|
|
43
41
|
state.items.push({
|
|
44
42
|
...item,
|
|
@@ -51,8 +49,8 @@ export const mutations: MutationTree<State> = {
|
|
|
51
49
|
state.items.pop()
|
|
52
50
|
},
|
|
53
51
|
|
|
54
|
-
drop(state: State,
|
|
55
|
-
state.items = state.items.filter(item => item.
|
|
52
|
+
drop(state: State, id: number) {
|
|
53
|
+
state.items = state.items.filter(item => item.id !== id)
|
|
56
54
|
},
|
|
57
55
|
|
|
58
56
|
flush(state: State): void {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ActionTree, ActionContext, MutationTree } from 'vuex'
|
|
2
|
-
import { State as RootState } from '../Sefirot'
|
|
3
2
|
|
|
4
3
|
let nextId: number = 0
|
|
5
4
|
|
|
@@ -31,8 +30,8 @@ export function state(): State {
|
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
export const actions: ActionTree<State,
|
|
35
|
-
push(context: ActionContext<State,
|
|
33
|
+
export const actions: ActionTree<State, any> = {
|
|
34
|
+
push(context: ActionContext<State, any>, payload: Snackbar): void {
|
|
36
35
|
const id = nextId++
|
|
37
36
|
|
|
38
37
|
context.commit('push', {
|
|
@@ -44,7 +43,7 @@ export const actions: ActionTree<State, RootState> = {
|
|
|
44
43
|
setTimeout(() => { context.commit('pop', id) }, payload.timeout ?? 10000)
|
|
45
44
|
},
|
|
46
45
|
|
|
47
|
-
pop(context: ActionContext<State,
|
|
46
|
+
pop(context: ActionContext<State, any>, id: number): void {
|
|
48
47
|
context.commit('pop', id)
|
|
49
48
|
}
|
|
50
49
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export { default as isEqual } from 'lodash-es/isEqual'
|
|
2
2
|
export { default as cloneDeep } from 'lodash-es/cloneDeep'
|
|
3
|
-
export { default as orderBy } from 'lodash-es/orderBy'
|
|
4
|
-
export { default as groupBy } from 'lodash-es/groupBy'
|
|
5
3
|
|
|
6
4
|
export function isNullish(value: unknown): value is undefined | null {
|
|
7
5
|
return value === null || value === undefined
|
package/lib/types/Utils.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export type Values<T> = T[keyof T]
|
|
2
|
-
|
|
3
|
-
export type OmitType<T> = Omit<T, 'type'>
|
|
4
|
-
|
|
5
|
-
export type WithRequired<T, K extends keyof T> = Exclude<T, K> & Required<Pick<T, K>>
|
|
6
|
-
export type WithOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>
|
|
7
|
-
|
|
8
1
|
export type SyntheticEvent<E extends Event, T extends Element> = E & { target: T }
|
|
9
2
|
export type SyntheticInputEvent<T extends Element = HTMLInputElement> = SyntheticEvent<InputEvent, T>
|
|
10
3
|
export type SyntheticMouseEvent<T extends Element = HTMLElement> = SyntheticEvent<MouseEvent, T>
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { helpers } from '@vuelidate/validators'
|
|
2
|
+
import { checked as baseChecked } from '../validators/checked'
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
optional: true,
|
|
9
|
-
validate: baseChecked
|
|
10
|
-
}
|
|
11
|
-
}
|
|
4
|
+
export const checked = helpers.withMessage(
|
|
5
|
+
'You must check the field.',
|
|
6
|
+
(value: boolean) => !helpers.req(value) || baseChecked(value)
|
|
7
|
+
)
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { helpers } from '@vuelidate/validators'
|
|
2
|
+
import { fileExtension as baseFileExtension } from '../validators/fileExtension'
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
return
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
export function fileExtension(extensions: string[], message?: string) {
|
|
5
|
+
return helpers.withMessage(
|
|
6
|
+
'The file extension is invalid.',
|
|
7
|
+
(value: File) => {
|
|
8
|
+
return !helpers.req(value) || baseFileExtension(value, extensions)
|
|
9
|
+
}
|
|
10
|
+
)
|
|
11
11
|
}
|