@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
@@ -1,138 +0,0 @@
1
- import MarkdownIt from 'markdown-it'
2
- import { onUnmounted, Ref } from '@vue/composition-api'
3
- import { isCallbackUrl, isExternalUrl, LinkAttrs, linkPlugin } from './markdown/LinkPlugin'
4
- import { useRouter } from './Router'
5
-
6
- export type UseMarkdown = (source: string, inline: boolean) => string
7
-
8
- export interface UseMarkdownOptions extends MarkdownIt.Options {
9
- linkAttrs?: LinkAttrs
10
- config?: (md: MarkdownIt) => void
11
- }
12
-
13
- export function useMarkdown(options: UseMarkdownOptions = {}): UseMarkdown {
14
- const md = new MarkdownIt({
15
- linkify: true,
16
- ...options
17
- })
18
-
19
- md.use(linkPlugin, {
20
- target: '_blank',
21
- rel: 'noopener noreferrer',
22
- ...options.linkAttrs
23
- })
24
-
25
- if (options.config) {
26
- options.config(md)
27
- }
28
-
29
- return (source, inline) => {
30
- return inline ? md.renderInline(source) : md.render(source)
31
- }
32
- }
33
-
34
- export interface UseLink {
35
- addListeners(): void
36
- removeListeners(): void
37
- subscribe(cb: LinkSubscriber): () => void
38
- }
39
-
40
- export interface UseLinkOptions {
41
- container: Ref<Element | null>
42
- callbacks?: LinkCallback[]
43
- }
44
-
45
- export interface LinkSubscriberPayload {
46
- event: Event
47
- target: HTMLAnchorElement
48
- isExternal: boolean
49
- isCallback: boolean
50
- }
51
-
52
- export type LinkSubscriber = (payload: LinkSubscriberPayload) => void
53
-
54
- export type LinkCallback = () => void
55
-
56
- export function useLink({ container, callbacks }: UseLinkOptions): UseLink {
57
- const router = useRouter()
58
- const subscribers: LinkSubscriber[] = []
59
-
60
- onUnmounted(() => removeListeners())
61
-
62
- function handler(event: Event): void {
63
- const target = event.target as HTMLAnchorElement
64
- const href = target.getAttribute('href')!
65
-
66
- if (!href) {
67
- return
68
- }
69
-
70
- const isExternal = isExternalUrl(href)
71
- const isCallback = isCallbackUrl(href)
72
-
73
- subscribers.forEach(sub => sub({
74
- event,
75
- target,
76
- isExternal,
77
- isCallback
78
- }))
79
-
80
- if (isExternal) {
81
- return
82
- }
83
-
84
- if (!event.defaultPrevented) {
85
- event.preventDefault()
86
- }
87
-
88
- if (isCallback) {
89
- const idx = parseInt(target.dataset.callbackId || '')
90
- const callback = (callbacks ?? [])[idx]
91
-
92
- if (!callback) {
93
- throw new Error(`Callback not found at index: ${idx}`)
94
- }
95
-
96
- return callback()
97
- }
98
-
99
- router.push(href)
100
- }
101
-
102
- function addListeners(): void {
103
- removeListeners()
104
-
105
- if (container.value) {
106
- findLinks(container.value).forEach((element) => {
107
- element.addEventListener('click', handler)
108
- })
109
- }
110
- }
111
-
112
- function removeListeners(): void {
113
- if (container.value) {
114
- findLinks(container.value).forEach((element) => {
115
- element.removeEventListener('click', handler)
116
- })
117
- }
118
- }
119
-
120
- function subscribe(fn: LinkSubscriber): () => void {
121
- subscribers.push(fn)
122
-
123
- return () => {
124
- const idx = subscribers.indexOf(fn)
125
- idx > -1 && subscribers.splice(idx, 1)
126
- }
127
- }
128
-
129
- return {
130
- addListeners,
131
- removeListeners,
132
- subscribe
133
- }
134
- }
135
-
136
- function findLinks(target: Element) {
137
- return target.querySelectorAll('a.SMarkdown-link')
138
- }
@@ -1,20 +0,0 @@
1
- import { computed, ComputedRef, getCurrentInstance } from '@vue/composition-api'
2
- import VueRouter, { Route } from 'vue-router'
3
-
4
- export function useRouter(): VueRouter {
5
- const { proxy } = getCurrentInstance()!
6
-
7
- return proxy.$router
8
- }
9
-
10
- export function useRoute(): ComputedRef<Route> {
11
- const { proxy } = getCurrentInstance()!
12
-
13
- return computed(() => proxy.$route)
14
- }
15
-
16
- export function useParams(): ComputedRef<Record<string, string>> {
17
- const { proxy } = getCurrentInstance()!
18
-
19
- return computed(() => proxy.$route.params)
20
- }
@@ -1,7 +0,0 @@
1
- export interface Step {
2
- status: StepStatus
3
- text?: string
4
- }
5
-
6
- export type StepStatus = 'upcoming' | 'active' | 'done' | 'failed'
7
- export type BarMode = 'mute' | 'active'
@@ -1,9 +0,0 @@
1
- import { getCurrentInstance } from '@vue/composition-api'
2
- import { Store } from 'vuex'
3
- import { State } from '../store/Sefirot'
4
-
5
- export function useStore(): Store<State> {
6
- const { proxy } = getCurrentInstance()!
7
-
8
- return proxy.$store
9
- }
@@ -1,32 +0,0 @@
1
- import { Values } from '../types/Utils'
2
-
3
- export interface Tag {
4
- size?: Size
5
- mode?: Mode
6
- icon?: any
7
- text?: string
8
- link?: string
9
- }
10
-
11
- export type Size = Values<typeof Sizes>
12
-
13
- export const Sizes = {
14
- Small: 'small',
15
- Medium: 'medium',
16
- Large: 'large'
17
- } as const
18
-
19
- export type Mode = Values<typeof Modes>
20
-
21
- export const Modes = {
22
- Neutral: 'neutral',
23
- Info: 'info',
24
- Success: 'success',
25
- Warning: 'warning',
26
- Danger: 'danger',
27
- Mute: 'mute'
28
- } as const
29
-
30
- export function useTag(tag: Tag): Tag {
31
- return tag
32
- }
@@ -1,91 +0,0 @@
1
- import { Ref, ref } from '@vue/composition-api'
2
-
3
- export type Position = 'top' | 'right' | 'bottom' | 'left'
4
-
5
- const SCREEN_PADDING = 16
6
-
7
- /**
8
- * Prevent tooltip going off-screen by adjusting the position depending on
9
- * the current window size. This only applies to position `top` and
10
- * `bottom` since we only care about left and right of the screen.
11
- */
12
- export function useTooltip(
13
- content: Ref<HTMLElement | null>,
14
- tip: Ref<HTMLElement | null>,
15
- position: Position
16
- ) {
17
- const on = ref(false)
18
-
19
- function show(): void {
20
- setPosition()
21
- setTimeout(() => { on.value = true })
22
- }
23
-
24
- function hide(): void {
25
- setTimeout(() => { on.value = false })
26
- }
27
-
28
- function setPosition(): void {
29
- if (shouldPosition()) {
30
- doSetPosition()
31
- }
32
- }
33
-
34
- function doSetPosition(): void {
35
- // Reset position first so that we can get the original position.
36
- resetPosition()
37
-
38
- // Temporally show tip to get its size.
39
- tip.value!.style.display = 'block'
40
-
41
- const contentRect = content.value!.getBoundingClientRect()
42
- const tipRect = tip.value!.getBoundingClientRect()
43
-
44
- const contentRightX = contentRect.x + contentRect.width
45
- const tipRightX = tipRect.x + tipRect.width
46
-
47
- if (tipRect.x < 0) {
48
- adjustLeftPosition(contentRect.x)
49
- } else if (tipRightX > window.outerWidth) {
50
- adjustRightPosition(contentRightX)
51
- }
52
-
53
- tip.value!.style.display = 'none'
54
- }
55
-
56
- function adjustLeftPosition(contentRectX: number): void {
57
- tip.value!.style.left = '0'
58
- tip.value!.style.right = 'auto'
59
- setTransform(-contentRectX + SCREEN_PADDING)
60
- }
61
-
62
- function adjustRightPosition(contentRightX: number): void {
63
- tip.value!.style.left = 'auto'
64
- tip.value!.style.right = '0'
65
- setTransform((window.outerWidth - contentRightX) - SCREEN_PADDING)
66
- }
67
-
68
- function resetPosition(): void {
69
- tip.value!.style.left = ''
70
- tip.value!.style.right = ''
71
- tip.value!.style.transform = ''
72
- }
73
-
74
- function setTransform(x: number): void {
75
- tip.value!.style.transform = `translate(${x}px, ${position === 'top' ? -100 : 100}%)`
76
- }
77
-
78
- function shouldPosition(): boolean {
79
- if (!tip.value || !content.value) {
80
- return false
81
- }
82
-
83
- return position === 'top' || position === 'bottom'
84
- }
85
-
86
- return {
87
- on,
88
- show,
89
- hide
90
- }
91
- }
@@ -1,115 +0,0 @@
1
- import {
2
- Ref,
3
- ComputedRef,
4
- WatchSource,
5
- shallowRef,
6
- computed,
7
- watch,
8
- isRef
9
- } from '@vue/composition-api'
10
-
11
- export type Refish<T = any> = T | Ref<T> | ComputedRef<T>
12
-
13
- export type Source<S> = Ref<S> | ComputedRef<S>
14
-
15
- export function get<T>(refish: Refish<T> | (() => T)): T {
16
- if (isRef(refish)) {
17
- return refish.value
18
- }
19
-
20
- if (refish instanceof Function) {
21
- return refish()
22
- }
23
-
24
- return refish
25
- }
26
-
27
- export function computedOnly<T, S>(
28
- source: WatchSource<S>,
29
- fn: (value: S, oldValue?: S) => T
30
- ): Ref<T> {
31
- const value = shallowRef() as Ref<T>
32
-
33
- watch(source, (newValue, oldValue) => {
34
- value.value = fn(newValue, oldValue)
35
- }, { immediate: true })
36
-
37
- return value
38
- }
39
-
40
- export function computedIf<T, R, E>(
41
- refish: Refish<T | null>,
42
- callback: (value: T) => R,
43
- empty: E
44
- ): ComputedRef<R | E> {
45
- return computed(() => {
46
- const value = get(refish)
47
-
48
- return value ? callback(value) : empty
49
- })
50
- }
51
-
52
- export function computedIfOnly<T, E, S>(
53
- source: WatchSource<S>,
54
- fn: (value: Exclude<S, undefined | null | false>) => T,
55
- empty: E
56
- ): Ref<T | E> {
57
- return computedOnly(source, (value) => {
58
- return value
59
- ? fn(value as Exclude<S, undefined | null | false>)
60
- : empty
61
- })
62
- }
63
-
64
- export function computedArray<T>(callback: (carry: T) => void): ComputedRef<T> {
65
- return computed(() => {
66
- const carry = [] as any
67
-
68
- callback(carry)
69
-
70
- return carry
71
- })
72
- }
73
-
74
- export function computedArrayOnly<T extends any[], S>(
75
- source: Source<S>,
76
- callback: (carry: T) => void
77
- ): Ref<T> {
78
- return computedOnly(source, () => {
79
- const carry = [] as any
80
-
81
- callback(carry)
82
-
83
- return carry
84
- })
85
- }
86
-
87
- export function computedArrayIf<T, D extends any[]>(
88
- refish: Refish<T | null>,
89
- callback: (carry: D, value: T) => void
90
- ): ComputedRef<D> {
91
- return computed(() => {
92
- const carry = [] as any
93
-
94
- const value = get(refish)
95
-
96
- value && callback(carry, value)
97
-
98
- return carry
99
- })
100
- }
101
-
102
- export function computedArrayIfNot<T, D extends any[]>(
103
- refish: Refish<T | null>,
104
- callback: (carry: D) => void
105
- ): ComputedRef<D> {
106
- return computed(() => {
107
- const carry = [] as any
108
-
109
- const value = get(refish)
110
-
111
- value || callback(carry)
112
-
113
- return carry
114
- })
115
- }
@@ -1,45 +0,0 @@
1
- import MarkdownIt from 'markdown-it'
2
-
3
- export type LinkAttrs = Record<string, string>
4
-
5
- const EXTERNAL_REGEX = /^https?:/
6
- const CALLBACK_REGEX = /\{([\d}]+)\}/
7
- const CALLBACK_HREF = '#callback'
8
-
9
- export function linkPlugin(md: MarkdownIt, linkAttrs: LinkAttrs = {}): void {
10
- md.renderer.rules.link_open = (tokens, idx, options, _env, self) => {
11
- const token = tokens[idx]
12
- const hrefIndex = token.attrIndex('href')
13
-
14
- if (hrefIndex >= 0) {
15
- const hrefAttr = token.attrs![hrefIndex]
16
- const url = decodeURIComponent(hrefAttr[1])
17
-
18
- if (isExternalUrl(url)) {
19
- Object.entries(linkAttrs).forEach(([key, val]) => {
20
- token.attrSet(key, val)
21
- })
22
- }
23
-
24
- if (isCallbackUrl(url)) {
25
- const matched = url.match(CALLBACK_REGEX)![1]
26
-
27
- token.attrSet('data-callback-id', matched)
28
-
29
- hrefAttr[1] = CALLBACK_HREF
30
- }
31
-
32
- token.attrSet('class', 'SMarkdown-link')
33
- }
34
-
35
- return self.renderToken(tokens, idx, options)
36
- }
37
- }
38
-
39
- export function isExternalUrl(url: string): boolean {
40
- return EXTERNAL_REGEX.test(url)
41
- }
42
-
43
- export function isCallbackUrl(url: string): boolean {
44
- return url === CALLBACK_HREF || CALLBACK_REGEX.test(decodeURIComponent(url))
45
- }
@@ -1,17 +0,0 @@
1
- import { reactive, markRaw } from '@vue/composition-api'
2
- import { createValidation, Data, Rules } from '../validation/Validation'
3
-
4
- export interface FormDefinition {
5
- data: Data
6
- rules: Rules
7
- }
8
-
9
- export default function useForm(definition: FormDefinition) {
10
- const data = reactive(definition.data)
11
- const validation = markRaw(createValidation(data, definition.rules))
12
-
13
- return {
14
- data,
15
- validation
16
- }
17
- }
@@ -1,25 +0,0 @@
1
- import { ResizeObserver } from '@juggle/resize-observer'
2
- import { reactive, toRefs, onMounted, onUnmounted, Ref } from '@vue/composition-api'
3
-
4
- export interface EL {
5
- w: number
6
- h: number
7
- }
8
-
9
- export default function useResizeObserver(target: Ref<HTMLElement | null>) {
10
- const el = reactive({ w: 0, h: 0 })
11
-
12
- const ro = new ResizeObserver((entries) => {
13
- const entry = entries[0]
14
- el.w = entry.contentBoxSize[0].inlineSize
15
- el.h = entry.contentBoxSize[0].blockSize
16
- })
17
-
18
- onMounted(() => { ro.observe(target.value!) })
19
- onUnmounted(() => { ro.disconnect() })
20
-
21
- return {
22
- el: toRefs(el),
23
- ro
24
- }
25
- }
@@ -1,26 +0,0 @@
1
- function pad(n: number, width: number): string {
2
- const number = String(n)
3
- return number.length >= width ? number : new Array(width - number.length + 1).join('0') + number
4
- }
5
-
6
- function createTimes(from: number, to: number): string[] {
7
- const hours: string[] = []
8
-
9
- for (let h = from; h <= to; h++) {
10
- hours.push(pad(h, 2))
11
- }
12
-
13
- return hours
14
- }
15
-
16
- export default function useTime() {
17
- const hours = createTimes(0, 23)
18
- const minutes = createTimes(0, 59)
19
- const seconds = createTimes(0, 59)
20
-
21
- return {
22
- hours,
23
- minutes,
24
- seconds
25
- }
26
- }
@@ -1,32 +0,0 @@
1
- import { ActionTree, ActionContext } from 'vuex'
2
- import SAlert from '../../components/SAlert.vue'
3
- import { Alert } from '../../composables/Alert'
4
- import { State as RootState } from '../Sefirot'
5
-
6
- export type AlertPayload = Alert & { uid?: number }
7
-
8
- export const actions: ActionTree<any, RootState> = {
9
- open(context: ActionContext<any, RootState>, alert: AlertPayload): void {
10
- const { uid } = alert
11
-
12
- delete alert.uid
13
-
14
- context.dispatch('modal/open', {
15
- uid,
16
- component: SAlert,
17
- data: alert,
18
- options: {
19
- closable: false
20
- }
21
- }, { root: true })
22
- },
23
-
24
- close(context: ActionContext<any, RootState>, uid?: number): void {
25
- context.dispatch('modal/close', uid, { root: true })
26
- }
27
- }
28
-
29
- export default {
30
- namespaced: true,
31
- actions
32
- }
@@ -1,46 +0,0 @@
1
- import { ActionTree, ActionContext, MutationTree } from 'vuex'
2
- import { State as RootState } from '../Sefirot'
3
-
4
- export interface State {
5
- name: string | null
6
- data: Record<string, any>
7
- }
8
-
9
- export interface PayloadOpen {
10
- name: string
11
- data?: Record<string, any>
12
- }
13
-
14
- export function state(): State {
15
- return {
16
- name: null,
17
- data: {}
18
- }
19
- }
20
-
21
- export const actions: ActionTree<State, RootState> = {
22
- open(context: ActionContext<State, RootState>, { name, data }: PayloadOpen): void {
23
- context.commit('set', { name, data })
24
- },
25
-
26
- close(context: ActionContext<State, RootState>): void {
27
- context.commit('set', {
28
- name: null,
29
- data: {}
30
- })
31
- }
32
- }
33
-
34
- export const mutations: MutationTree<State> = {
35
- set(state: State, { name, data = {} }: PayloadOpen): void {
36
- state.name = name
37
- state.data = data
38
- }
39
- }
40
-
41
- export default {
42
- namespaced: true,
43
- state,
44
- actions,
45
- mutations
46
- }
@@ -1,5 +0,0 @@
1
- declare module 'v-calendar' {
2
- const VCalendar: any
3
-
4
- export default VCalendar
5
- }