@globalbrain/sefirot 0.72.0 → 2.0.0-draft.4

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.
Files changed (175) hide show
  1. package/CHANGELOG.md +8 -808
  2. package/README.md +1 -1
  3. package/lib/assets/styles/bootstrap.css +1 -2
  4. package/lib/assets/styles/variables.css +14 -47
  5. package/lib/components/SAvatar.vue +9 -18
  6. package/lib/components/SButton.vue +35 -48
  7. package/lib/components/SDialog.vue +16 -34
  8. package/lib/components/SDropdown.vue +36 -55
  9. package/lib/components/SDropdownItem.vue +27 -39
  10. package/lib/components/SDropdownItemText.vue +4 -9
  11. package/lib/components/SDropdownItemUser.vue +4 -12
  12. package/lib/components/SInputBase.vue +33 -45
  13. package/lib/components/SInputCheckbox.vue +17 -37
  14. package/lib/components/SInputDropdown.vue +109 -171
  15. package/lib/components/SInputDropdownItem.vue +26 -32
  16. package/lib/components/SInputDropdownItemText.vue +6 -11
  17. package/lib/components/SInputDropdownItemTextTag.vue +10 -17
  18. package/lib/components/SInputDropdownItemUser.vue +5 -13
  19. package/lib/components/SInputDropdownItemUserTag.vue +9 -16
  20. package/lib/components/SInputFile.vue +38 -53
  21. package/lib/components/SInputHMS.vue +91 -114
  22. package/lib/components/SInputNumber.vue +27 -106
  23. package/lib/components/SInputRadio.vue +21 -34
  24. package/lib/components/SInputRadios.vue +36 -46
  25. package/lib/components/SInputText.vue +72 -628
  26. package/lib/components/SInputTextarea.vue +54 -113
  27. package/lib/components/SInputYMD.vue +94 -105
  28. package/lib/components/SLink.vue +16 -52
  29. package/lib/components/SModal.vue +39 -98
  30. package/lib/components/SPortalModals.vue +37 -54
  31. package/lib/components/SPortalSnackbars.vue +9 -24
  32. package/lib/components/SSheet.vue +73 -28
  33. package/lib/components/SSheetFooter.vue +5 -3
  34. package/lib/components/SSheetFooterAction.vue +10 -15
  35. package/lib/components/SSheetFooterActions.vue +2 -4
  36. package/lib/components/SSheetMedium.vue +14 -22
  37. package/lib/components/SSheetTitle.vue +20 -0
  38. package/lib/components/SSnackbar.vue +18 -28
  39. package/lib/composables/Dialog.ts +9 -17
  40. package/lib/composables/Dropdown.ts +2 -2
  41. package/lib/composables/{Menu.ts → Flyout.ts} +11 -4
  42. package/lib/composables/Form.ts +42 -44
  43. package/lib/composables/Modal.ts +11 -19
  44. package/lib/composables/Snackbar.ts +18 -0
  45. package/lib/composables/Validation.ts +28 -0
  46. package/lib/mixins/Sheet.ts +5 -7
  47. package/lib/store/Sefirot.ts +8 -13
  48. package/lib/store/dialog/index.ts +20 -10
  49. package/lib/store/modal/index.ts +11 -18
  50. package/lib/store/snackbars/index.ts +3 -4
  51. package/lib/support/{Util.ts → Utils.ts} +0 -2
  52. package/lib/types/Utils.ts +0 -7
  53. package/lib/types/vue-shims.d.ts +7 -0
  54. package/lib/validation/rules/checked.ts +6 -10
  55. package/lib/validation/rules/fileExtension.ts +9 -9
  56. package/lib/validation/rules/hms.ts +9 -9
  57. package/lib/validation/rules/index.ts +10 -74
  58. package/lib/validation/rules/maxLength.ts +10 -9
  59. package/lib/validation/rules/minLength.ts +12 -0
  60. package/lib/validation/rules/required.ts +2 -10
  61. package/lib/validation/rules/requiredHms.ts +11 -0
  62. package/lib/validation/rules/requiredIf.ts +3 -11
  63. package/lib/validation/rules/requiredYmd.ts +11 -0
  64. package/lib/validation/rules/ymd.ts +11 -0
  65. package/lib/validation/validators/checked.ts +1 -1
  66. package/lib/validation/validators/fileExtension.ts +1 -1
  67. package/lib/validation/validators/hms.ts +5 -5
  68. package/lib/validation/validators/requiredHms.ts +17 -0
  69. package/lib/validation/validators/requiredYmd.ts +7 -0
  70. package/lib/validation/validators/ymd.ts +41 -0
  71. package/package.json +45 -50
  72. package/lib/components/SAction.vue +0 -37
  73. package/lib/components/SActionAvatar.vue +0 -25
  74. package/lib/components/SActionButton.vue +0 -40
  75. package/lib/components/SActionPill.vue +0 -35
  76. package/lib/components/SActionSwitch.vue +0 -37
  77. package/lib/components/SAlert.vue +0 -145
  78. package/lib/components/SButtonGroup.vue +0 -160
  79. package/lib/components/SCard.vue +0 -111
  80. package/lib/components/SCardFooter.vue +0 -74
  81. package/lib/components/SCardHeader.vue +0 -213
  82. package/lib/components/SGrid.vue +0 -237
  83. package/lib/components/SGridActionLink.vue +0 -53
  84. package/lib/components/SGridActionMulti.vue +0 -139
  85. package/lib/components/SGridActionSingle.vue +0 -64
  86. package/lib/components/SHeader.vue +0 -180
  87. package/lib/components/SInputCheckboxes.vue +0 -87
  88. package/lib/components/SInputDate.vue +0 -192
  89. package/lib/components/SInputDay.vue +0 -87
  90. package/lib/components/SInputMonth.vue +0 -86
  91. package/lib/components/SInputSelect.vue +0 -298
  92. package/lib/components/SInputSwitch.vue +0 -212
  93. package/lib/components/SInputSwitches.vue +0 -108
  94. package/lib/components/SInputTime.vue +0 -255
  95. package/lib/components/SInputYear.vue +0 -60
  96. package/lib/components/SMarkdown.vue +0 -56
  97. package/lib/components/SPlaceholderBlank.vue +0 -113
  98. package/lib/components/SPlaceholderImage.vue +0 -83
  99. package/lib/components/SPortalScreens.vue +0 -62
  100. package/lib/components/SProgressBar.vue +0 -89
  101. package/lib/components/SResponsive.vue +0 -46
  102. package/lib/components/SScreen.vue +0 -81
  103. package/lib/components/SSheetHeader.vue +0 -75
  104. package/lib/components/SSheetHeaderTitle.vue +0 -17
  105. package/lib/components/SStep.vue +0 -107
  106. package/lib/components/SSteps.vue +0 -75
  107. package/lib/components/STag.vue +0 -67
  108. package/lib/components/STooltip.vue +0 -134
  109. package/lib/components/SWindow.vue +0 -158
  110. package/lib/components/icons/SIconCopy.vue +0 -6
  111. package/lib/composables/Action.ts +0 -141
  112. package/lib/composables/Alert.ts +0 -50
  113. package/lib/composables/Card.ts +0 -46
  114. package/lib/composables/FormValidation.ts +0 -150
  115. package/lib/composables/Header.ts +0 -72
  116. package/lib/composables/InputDropdown.ts +0 -6
  117. package/lib/composables/Markdown.ts +0 -138
  118. package/lib/composables/Router.ts +0 -20
  119. package/lib/composables/Step.ts +0 -7
  120. package/lib/composables/Store.ts +0 -9
  121. package/lib/composables/Tag.ts +0 -32
  122. package/lib/composables/Tooltip.ts +0 -91
  123. package/lib/composables/Utils.ts +0 -115
  124. package/lib/composables/markdown/LinkPlugin.ts +0 -45
  125. package/lib/compositions/useForm.ts +0 -17
  126. package/lib/compositions/useResizeObserver.ts +0 -25
  127. package/lib/compositions/useTime.ts +0 -26
  128. package/lib/store/alert/index.ts +0 -32
  129. package/lib/store/screen/index.ts +0 -46
  130. package/lib/types/v-calendar.d.ts +0 -5
  131. package/lib/validation/Validation.ts +0 -151
  132. package/lib/validation/rules/day.ts +0 -11
  133. package/lib/validation/rules/email.ts +0 -11
  134. package/lib/validation/rules/every.ts +0 -38
  135. package/lib/validation/rules/include.ts +0 -11
  136. package/lib/validation/rules/includeSome.ts +0 -11
  137. package/lib/validation/rules/integer.ts +0 -11
  138. package/lib/validation/rules/maxValue.ts +0 -11
  139. package/lib/validation/rules/minValue.ts +0 -11
  140. package/lib/validation/rules/month.ts +0 -11
  141. package/lib/validation/rules/not.ts +0 -10
  142. package/lib/validation/rules/regex.ts +0 -11
  143. package/lib/validation/rules/requiredHMS.ts +0 -11
  144. package/lib/validation/rules/requiredMonthDate.ts +0 -11
  145. package/lib/validation/rules/requiredYearMonth.ts +0 -11
  146. package/lib/validation/rules/requiredYearMonthDate.ts +0 -11
  147. package/lib/validation/rules/rule.ts +0 -5
  148. package/lib/validation/rules/sameAs.ts +0 -11
  149. package/lib/validation/rules/url.ts +0 -11
  150. package/lib/validation/rules/validateIf.ts +0 -27
  151. package/lib/validation/rules/year.ts +0 -11
  152. package/lib/validation/rules/yearMonth.ts +0 -11
  153. package/lib/validation/rules/yearMonthDate.ts +0 -11
  154. package/lib/validation/validators/day.ts +0 -29
  155. package/lib/validation/validators/email.ts +0 -5
  156. package/lib/validation/validators/include.ts +0 -5
  157. package/lib/validation/validators/includeSome.ts +0 -5
  158. package/lib/validation/validators/index.ts +0 -51
  159. package/lib/validation/validators/integer.ts +0 -6
  160. package/lib/validation/validators/maxLength.ts +0 -3
  161. package/lib/validation/validators/maxValue.ts +0 -3
  162. package/lib/validation/validators/minValue.ts +0 -3
  163. package/lib/validation/validators/month.ts +0 -3
  164. package/lib/validation/validators/monthDate.ts +0 -20
  165. package/lib/validation/validators/regex.ts +0 -3
  166. package/lib/validation/validators/required.ts +0 -27
  167. package/lib/validation/validators/requiredHMS.ts +0 -17
  168. package/lib/validation/validators/requiredMonthDate.ts +0 -8
  169. package/lib/validation/validators/requiredYearMonth.ts +0 -8
  170. package/lib/validation/validators/requiredYearMonthDate.ts +0 -9
  171. package/lib/validation/validators/sameAs.ts +0 -5
  172. package/lib/validation/validators/url.ts +0 -5
  173. package/lib/validation/validators/year.ts +0 -3
  174. package/lib/validation/validators/yearMonth.ts +0 -20
  175. 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.callback"
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 { defineComponent, PropType } from '@vue/composition-api'
24
- import { useStore } from '../composables/Store'
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
- export default defineComponent({
30
- components: {
31
- SIconX,
32
- SButton
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
- setup(props) {
42
- const store = useStore()
35
+ const store = useStore()
43
36
 
44
- function close(): void {
45
- store.dispatch('snackbars/pop', props.id)
46
- }
37
+ function close() {
38
+ store.dispatch('snackbars/pop', props.id)
39
+ }
47
40
 
48
- return {
49
- close
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-mode .SSnackbar {
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
+
@@ -1,14 +1,13 @@
1
- import { Values } from '../types/Utils'
2
- import { useStore } from './Store'
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?: DialogOptions): Promise<any>
5
+ open(dialog?: Options): Promise<any>
7
6
  close(): Promise<any>
8
7
  }
9
8
 
10
- export interface DialogOptions {
11
- type?: DialogType
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 uid = useModalUid()
24
+ const id = useModalId()
33
25
 
34
- function open(dialog?: DialogOptions) {
35
- return store.dispatch('dialog/open', { ...dialog, uid })
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', uid)
31
+ return store.dispatch('dialog/close', id)
40
32
  }
41
33
 
42
34
  return {
@@ -1,5 +1,5 @@
1
1
  import Fuse from 'fuse.js'
2
- import { Ref, ComputedRef, ref, computed, isRef } from '@vue/composition-api'
2
+ import { Ref, ComputedRef, ref, computed, isRef } from 'vue'
3
3
 
4
4
  export interface Dropdown {
5
5
  title?: string
@@ -14,7 +14,7 @@ export interface Search {
14
14
  placeholder: string
15
15
  missing: string
16
16
  value: Ref<string>
17
- onInput (text: string): void
17
+ onInput (text: string | null): void
18
18
  }
19
19
 
20
20
  export type Item = TextItem | UserItem
@@ -1,18 +1,16 @@
1
- import { ref } from '@vue/composition-api'
1
+ import { ref, watch } from 'vue'
2
2
 
3
- export function useMenu() {
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,
@@ -1,66 +1,64 @@
1
- import { UnwrapRef, reactive } from '@vue/composition-api'
2
- import { WithRequired } from '../types/Utils'
3
- import { Validation, Rules, useFormValidation } from './FormValidation'
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 * from './FormValidation'
6
-
7
- export interface Form<T extends Record<string, any>> {
8
- data: Data<T>
9
- validation?: Validation
6
+ export interface Form<D> {
7
+ data: D
8
+ validation: Ref<Validation>
10
9
  init(): void
11
- update: UpdateFunction<T>
10
+ reset(): void
11
+ validate(): Promise<boolean>
12
+ validateAndNotify(): Promise<boolean>
12
13
  }
13
14
 
14
- export interface UseFormOptions<T> {
15
- data: T | (() => T)
16
- rules?: Rules
15
+ export interface UseFormOptions<D> {
16
+ data: D
17
+ rules?: Ref<any> | any
17
18
  }
18
19
 
19
- export type UpdateFunction<T extends Record<string, any> = Record<string, any>> = (
20
- model: keyof Data<T>,
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
- export function useForm<T extends Record<string, any>>(
31
- options: UseFormOptionsWithRules<T>
32
- ): FormWithValidation<T>
23
+ const initialData = cloneDeep(options.data)
33
24
 
34
- export function useForm<T extends Record<string, any>>(
35
- options: UseFormOptions<T>
36
- ): Form<T>
25
+ const data = reactive(options.data as any)
37
26
 
38
- export function useForm<T extends Record<string, any>>(
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 data = reactive(initialData)
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
- validation?.$reset()
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 update(model: keyof Data<T>, value: any): void {
53
- data[model] = value
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
- update
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
- }
@@ -1,34 +1,26 @@
1
- import { Options as ModalOptions } from '../store/modal'
2
- import { useStore } from './Store'
1
+ import { useStore } from 'vuex'
3
2
 
4
3
  export interface Modal {
5
- open(item?: OpenOptions): Promise<any>
4
+ open(data?: Record<string, any>): Promise<any>
6
5
  close(): Promise<any>
7
6
  }
8
7
 
9
- export interface OpenOptions {
10
- component?: any
11
- uid?: number
12
- data?: Record<string, any>
13
- options?: ModalOptions
14
- }
15
-
16
- let modalUid = 0
8
+ let modalId = 0
17
9
 
18
- export function useModal(component?: any): Modal {
10
+ export function useModal(component: any): Modal {
19
11
  const store = useStore()
20
- const uid = useModalUid()
12
+ const id = useModalId()
21
13
 
22
- function open(item: OpenOptions = {}) {
14
+ function open(data: Record<string, any> = {}): Promise<any> {
23
15
  return store.dispatch('modal/open', {
24
- uid,
16
+ id,
25
17
  component,
26
- ...item
18
+ data
27
19
  })
28
20
  }
29
21
 
30
22
  function close() {
31
- return store.dispatch('modal/close', uid)
23
+ return store.dispatch('modal/close', id)
32
24
  }
33
25
 
34
26
  return {
@@ -37,6 +29,6 @@ export function useModal(component?: any): Modal {
37
29
  }
38
30
  }
39
31
 
40
- export function useModalUid(): number {
41
- return ++modalUid
32
+ export function useModalId(): number {
33
+ return ++modalId
42
34
  }
@@ -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
+ }
@@ -1,18 +1,16 @@
1
- import { defineComponent } from '@vue/composition-api'
1
+ import { App } from 'vue'
2
2
  import SSheet from '../components/SSheet.vue'
3
- import SSheetHeader from '../components/SSheetHeader.vue'
4
- import SSheetHeaderTitle from '../components/SSheetHeaderTitle.vue'
3
+ import SSheetTitle from '../components/SSheetTitle.vue'
5
4
  import SSheetMedium from '../components/SSheetMedium.vue'
6
5
  import SSheetFooter from '../components/SSheetFooter.vue'
7
6
  import SSheetFooterActions from '../components/SSheetFooterActions.vue'
8
7
  import SSheetFooterAction from '../components/SSheetFooterAction.vue'
9
8
 
10
- export default function Sheet() {
11
- return defineComponent({
9
+ export function mixin(app: App): void {
10
+ app.mixin({
12
11
  components: {
13
12
  SSheet,
14
- SSheetHeader,
15
- SSheetHeaderTitle,
13
+ SSheetTitle,
16
14
  SSheetMedium,
17
15
  SSheetFooter,
18
16
  SSheetFooterActions,
@@ -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 alert from './alert'
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
- screen: ScreenState
11
- snackbars: SnackbarState
8
+ snackbars: SnackbarsState
12
9
  }
13
10
 
14
- const Sefirot: Plugin<State> = <S = any> (store: Store<S & State>): void => {
15
- store.registerModule('modal', modal)
16
- store.registerModule('dialog', dialog)
17
- store.registerModule('alert', alert)
18
- store.registerModule('screen', screen)
19
- store.registerModule('snackbars', snackbars)
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 type DialogPayload = Dialog & { uid?: number }
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, RootState> = {
9
- open(context: ActionContext<any, RootState>, dialog: DialogPayload): void {
10
- const { uid } = dialog
18
+ export const actions: ActionTree<any, any> = {
19
+ open(context: ActionContext<any, any>, payload: OpenPayload): void {
20
+ const { id } = payload
11
21
 
12
- delete dialog.uid
22
+ delete payload.id
13
23
 
14
24
  context.dispatch('modal/open', {
15
- uid,
25
+ id,
16
26
  component: SDialog,
17
- data: dialog,
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, RootState>, uid?: number): void {
34
+ close(context: ActionContext<any, any>, uid?: number): void {
25
35
  context.dispatch('modal/close', uid, { root: true })
26
36
  }
27
37
  }
@@ -1,44 +1,37 @@
1
- import { shallowReactive, markRaw } from '@vue/composition-api'
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
- options?: Options
14
12
  }
15
13
 
16
- export interface Options {
17
- width?: string
18
- closable?: boolean
19
- }
20
-
21
- export function state(): State {
14
+ function state(): State {
22
15
  return {
23
16
  items: []
24
17
  }
25
18
  }
26
19
 
27
- export const actions: ActionTree<State, RootState> = {
28
- open(context: ActionContext<State, RootState>, item: Item): void {
20
+ const actions: ActionTree<State, any> = {
21
+ open(context: ActionContext<State, any>, item: Item): void {
29
22
  context.commit('push', item)
30
23
  },
31
24
 
32
- close(context: ActionContext<State, RootState>, uid?: number): void {
33
- uid ? context.commit('drop', uid) : context.commit('pop')
25
+ close(context: ActionContext<State, any>, id?: number): void {
26
+ id ? context.commit('drop', id) : context.commit('pop')
34
27
  },
35
28
 
36
- closeAll(context: ActionContext<State, RootState>): void {
29
+ closeAll(context: ActionContext<State, any>): void {
37
30
  context.commit('flush')
38
31
  }
39
32
  }
40
33
 
41
- export const mutations: MutationTree<State> = {
34
+ const mutations: MutationTree<State> = {
42
35
  push(state: State, item: Item): void {
43
36
  state.items.push({
44
37
  ...item,
@@ -51,8 +44,8 @@ export const mutations: MutationTree<State> = {
51
44
  state.items.pop()
52
45
  },
53
46
 
54
- drop(state: State, uid: number) {
55
- state.items = state.items.filter(item => item.uid !== uid)
47
+ drop(state: State, id: number) {
48
+ state.items = state.items.filter(item => item.id !== id)
56
49
  },
57
50
 
58
51
  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, RootState> = {
35
- push(context: ActionContext<State, RootState>, payload: Snackbar): void {
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, RootState>, id: number): void {
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
@@ -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>
@@ -0,0 +1,7 @@
1
+ declare module '*.vue' {
2
+ import { DefineComponent } from 'vue'
3
+
4
+ const component: DefineComponent<{}, {}, any>
5
+
6
+ export default component
7
+ }
@@ -1,11 +1,7 @@
1
- import { checked as baseChecked } from '../validators'
2
- import { Rule } from './'
1
+ import { helpers } from '@vuelidate/validators'
2
+ import { checked as baseChecked } from '../validators/checked'
3
3
 
4
- export default function checked(message?: string): Rule {
5
- return {
6
- name: 'checked',
7
- message: message ?? 'You must check the field.',
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 { fileExtension as baseFileExtension } from '../validators'
2
- import { Rule } from './'
1
+ import { helpers } from '@vuelidate/validators'
2
+ import { fileExtension as baseFileExtension } from '../validators/fileExtension'
3
3
 
4
- export default function hms(extensions: string[], message?: string): Rule {
5
- return {
6
- name: 'fileExtension',
7
- message: message ?? 'The file extension is invalid.',
8
- optional: true,
9
- validate: v => baseFileExtension(v, extensions)
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
  }