@globalbrain/sefirot 2.13.0 → 2.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/lib/components/SInputBase.vue +75 -32
- package/lib/components/SInputCheckbox.vue +3 -0
- package/lib/components/SInputCheckboxes.vue +3 -0
- package/lib/components/SInputDate.vue +3 -0
- package/lib/components/SInputDropdown.vue +3 -0
- package/lib/components/SInputFile.vue +39 -34
- package/lib/components/SInputHMS.vue +4 -3
- package/lib/components/SInputNumber.vue +5 -1
- package/lib/components/SInputRadio.vue +19 -14
- package/lib/components/SInputRadios.vue +38 -12
- package/lib/components/SInputSelect.vue +10 -12
- package/lib/components/SInputSwitch.vue +3 -0
- package/lib/components/SInputSwitches.vue +3 -0
- package/lib/components/SInputText.vue +3 -0
- package/lib/components/SInputTextarea.vue +3 -0
- package/lib/components/SInputYMD.vue +3 -0
- package/lib/components/STable.vue +39 -10
- package/lib/components/STableColumn.vue +20 -5
- package/lib/components/STableFooter.vue +14 -8
- package/lib/components/STableHeader.vue +13 -7
- package/lib/components/STooltip.vue +51 -52
- package/lib/composables/Table.ts +5 -0
- package/lib/composables/Tooltip.ts +3 -3
- package/lib/composables/Utils.ts +26 -0
- package/lib/composables/Validation.ts +5 -2
- package/lib/styles/variables.css +13 -1
- package/lib/validation/rules/index.ts +6 -6
- package/lib/validation/rules/maxFileSize.ts +16 -0
- package/lib/validation/validators/maxFileSize.ts +10 -0
- package/package.json +10 -10
|
@@ -1,112 +1,111 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { computed, ref } from 'vue'
|
|
3
3
|
import { Position, useTooltip } from '../composables/Tooltip'
|
|
4
4
|
import SMarkdown from './SMarkdown.vue'
|
|
5
5
|
|
|
6
|
-
const props = defineProps
|
|
7
|
-
tag
|
|
8
|
-
text
|
|
9
|
-
position
|
|
10
|
-
})
|
|
6
|
+
const props = defineProps<{
|
|
7
|
+
tag?: string
|
|
8
|
+
text?: string
|
|
9
|
+
position?: Position
|
|
10
|
+
}>()
|
|
11
11
|
|
|
12
12
|
const tip = ref<HTMLElement | null>(null)
|
|
13
13
|
const content = ref<HTMLElement | null>(null)
|
|
14
|
-
const classes = computed(() => [props.position])
|
|
15
|
-
|
|
14
|
+
const classes = computed(() => [props.position ?? 'top'])
|
|
15
|
+
|
|
16
|
+
const { on, show, hide } = useTooltip(
|
|
17
|
+
content,
|
|
18
|
+
tip,
|
|
19
|
+
computed(() => props.position ?? 'top')
|
|
20
|
+
)
|
|
16
21
|
</script>
|
|
17
22
|
|
|
18
23
|
<template>
|
|
19
|
-
<component :is="tag" class="STooltip" @mouseenter="show" @mouseleave="hide">
|
|
20
|
-
<
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<
|
|
26
|
-
<span v-
|
|
27
|
-
|
|
28
|
-
</span>
|
|
29
|
-
</transition>
|
|
30
|
-
</template>
|
|
31
|
-
|
|
32
|
-
<template v-else>
|
|
33
|
-
<span class="STooltip-content">
|
|
34
|
-
<slot />
|
|
24
|
+
<component :is="tag ?? 'span'" class="STooltip" @mouseenter="show" @mouseleave="hide">
|
|
25
|
+
<span class="content" ref="content">
|
|
26
|
+
<slot />
|
|
27
|
+
</span>
|
|
28
|
+
|
|
29
|
+
<transition name="fade">
|
|
30
|
+
<span v-show="on" class="container" :class="classes" ref="tip">
|
|
31
|
+
<span v-if="$slots.text" class="tip"><slot name="text" /></span>
|
|
32
|
+
<SMarkdown v-else-if="text" tag="span" class="tip" :content="text" inline />
|
|
35
33
|
</span>
|
|
36
|
-
</
|
|
34
|
+
</transition>
|
|
37
35
|
</component>
|
|
38
36
|
</template>
|
|
39
37
|
|
|
40
|
-
<style lang="postcss"
|
|
38
|
+
<style scoped lang="postcss">
|
|
41
39
|
.STooltip {
|
|
42
40
|
position: relative;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
.
|
|
43
|
+
.content {
|
|
44
|
+
white-space: nowrap;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.container {
|
|
46
48
|
position: absolute;
|
|
47
|
-
display: block;
|
|
48
|
-
transition: opacity .25s;
|
|
49
49
|
z-index: var(--z-index-tooltip);
|
|
50
|
+
display: block;
|
|
51
|
+
transition: opacity 0.25s;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
.
|
|
53
|
-
.
|
|
54
|
+
.container.fade-enter-from,
|
|
55
|
+
.container.fade-leave-to {
|
|
54
56
|
opacity: 0;
|
|
55
|
-
&.top .
|
|
56
|
-
&.right .
|
|
57
|
-
&.bottom .
|
|
58
|
-
&.left .
|
|
57
|
+
&.top .tip { transform: translateY(8px); }
|
|
58
|
+
&.right .tip { transform: translateX(-8px); }
|
|
59
|
+
&.bottom .tip { transform: translateY(-8px); }
|
|
60
|
+
&.left .tip { transform: translateX(8px); }
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
.
|
|
63
|
+
.container.top {
|
|
62
64
|
top: 0;
|
|
63
65
|
left: 50%;
|
|
64
66
|
padding-bottom: 8px;
|
|
65
67
|
transform: translate(-50%, -100%);
|
|
66
68
|
}
|
|
67
69
|
|
|
68
|
-
.
|
|
70
|
+
.container.right {
|
|
69
71
|
top: 50%;
|
|
70
72
|
left: 100%;
|
|
71
73
|
transform: translate(8px, -50%);
|
|
72
74
|
}
|
|
73
75
|
|
|
74
|
-
.
|
|
76
|
+
.container.bottom {
|
|
75
77
|
bottom: 0;
|
|
76
78
|
left: 50%;
|
|
77
79
|
padding-top: 8px;
|
|
78
80
|
transform: translate(-50%, 100%);
|
|
79
81
|
}
|
|
80
82
|
|
|
81
|
-
.
|
|
83
|
+
.container.left {
|
|
82
84
|
top: 50%;
|
|
83
85
|
right: 100%;
|
|
84
86
|
transform: translate(-8px, -50%);
|
|
85
87
|
}
|
|
86
88
|
|
|
87
|
-
.
|
|
89
|
+
.tip {
|
|
88
90
|
display: block;
|
|
89
|
-
border
|
|
91
|
+
border: 1px solid var(--tooltip-border-color);
|
|
92
|
+
border-radius: 6px;
|
|
90
93
|
padding: 12px;
|
|
91
94
|
width: max-content;
|
|
92
|
-
max-width:
|
|
95
|
+
max-width: var(--tooltip-max-width);
|
|
93
96
|
line-height: 18px;
|
|
94
97
|
font-size: 12px;
|
|
95
98
|
font-weight: 500;
|
|
96
|
-
color: var(--
|
|
97
|
-
background-color:
|
|
98
|
-
transition: transform .25s;
|
|
99
|
+
color: var(--tooltip-text-color);
|
|
100
|
+
background-color: var(--tooltip-bg-color);
|
|
101
|
+
transition: transform 0.25s;
|
|
99
102
|
}
|
|
100
103
|
|
|
101
|
-
.
|
|
102
|
-
color: var(--c-info);
|
|
104
|
+
.tip :deep(a) {
|
|
105
|
+
color: var(--c-info-text);
|
|
103
106
|
|
|
104
107
|
&:hover {
|
|
105
|
-
color: var(--c-info-dark);
|
|
108
|
+
color: var(--c-info-text-dark);
|
|
106
109
|
}
|
|
107
110
|
}
|
|
108
|
-
|
|
109
|
-
.STooltip-content {
|
|
110
|
-
white-space: nowrap;
|
|
111
|
-
}
|
|
112
111
|
</style>
|
package/lib/composables/Table.ts
CHANGED
|
@@ -6,6 +6,8 @@ export interface Table {
|
|
|
6
6
|
orders: string[]
|
|
7
7
|
columns: TableColumns
|
|
8
8
|
records?: Record<string, any>[] | null
|
|
9
|
+
header?: boolean
|
|
10
|
+
footer?: boolean
|
|
9
11
|
total?: number | null
|
|
10
12
|
page?: number | null
|
|
11
13
|
perPage?: number | null
|
|
@@ -25,6 +27,7 @@ export interface TableColumn {
|
|
|
25
27
|
label: string
|
|
26
28
|
className?: string
|
|
27
29
|
dropdown?: DropdownSection[]
|
|
30
|
+
resizable?: boolean
|
|
28
31
|
cell?: TableCell | ((value: any, record: any) => TableCell)
|
|
29
32
|
}
|
|
30
33
|
|
|
@@ -115,6 +118,8 @@ export interface UseTableOptions {
|
|
|
115
118
|
orders: MaybeRef<string[]>
|
|
116
119
|
columns: MaybeRef<TableColumns>
|
|
117
120
|
records?: MaybeRef<Record<string, any>[] | null | undefined>
|
|
121
|
+
header?: MaybeRef<boolean | undefined>
|
|
122
|
+
footer?: MaybeRef<boolean | undefined>
|
|
118
123
|
total?: MaybeRef<number | null | undefined>
|
|
119
124
|
page?: MaybeRef<number | null | undefined>
|
|
120
125
|
perPage?: MaybeRef<number | null | undefined>
|
|
@@ -12,7 +12,7 @@ const SCREEN_PADDING = 16
|
|
|
12
12
|
export function useTooltip(
|
|
13
13
|
content: Ref<HTMLElement | null>,
|
|
14
14
|
tip: Ref<HTMLElement | null>,
|
|
15
|
-
position: Position
|
|
15
|
+
position: Ref<Position>
|
|
16
16
|
) {
|
|
17
17
|
const on = ref(false)
|
|
18
18
|
|
|
@@ -72,7 +72,7 @@ export function useTooltip(
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
function setTransform(x: number): void {
|
|
75
|
-
tip.value!.style.transform = `translate(${x}px, ${position === 'top' ? -100 : 100}%)`
|
|
75
|
+
tip.value!.style.transform = `translate(${x}px, ${position.value === 'top' ? -100 : 100}%)`
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
function shouldPosition(): boolean {
|
|
@@ -80,7 +80,7 @@ export function useTooltip(
|
|
|
80
80
|
return false
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
return position === 'top' || position === 'bottom'
|
|
83
|
+
return position.value === 'top' || position.value === 'bottom'
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
return {
|
package/lib/composables/Utils.ts
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
|
+
import { MaybeComputedRef, resolveUnref } from '@vueuse/core'
|
|
1
2
|
import { ComputedRef, computed } from 'vue'
|
|
2
3
|
|
|
4
|
+
export type WhenCondition<T> = MaybeComputedRef<T>
|
|
5
|
+
|
|
6
|
+
export function computedWhen<T, C>(
|
|
7
|
+
condition: WhenCondition<C>,
|
|
8
|
+
fn: (item: NonNullable<C>) => T
|
|
9
|
+
): ComputedRef<T | undefined>
|
|
10
|
+
|
|
11
|
+
export function computedWhen<T, C, D>(
|
|
12
|
+
condition: WhenCondition<C>,
|
|
13
|
+
fn: (item: NonNullable<C>) => T,
|
|
14
|
+
whenFalse: D
|
|
15
|
+
): ComputedRef<T | D>
|
|
16
|
+
|
|
17
|
+
export function computedWhen<T, C, D>(
|
|
18
|
+
condition: WhenCondition<C>,
|
|
19
|
+
fn: (item: NonNullable<C>) => T,
|
|
20
|
+
whenFalse?: D
|
|
21
|
+
): ComputedRef<T | D> {
|
|
22
|
+
return computed(() => {
|
|
23
|
+
const c = resolveUnref(condition)
|
|
24
|
+
|
|
25
|
+
return c ? fn(c) : whenFalse as D
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
3
29
|
export function computedArray<T = any>(fn: (arr: T[]) => void): ComputedRef<T[]> {
|
|
4
30
|
return computed(() => {
|
|
5
31
|
const arr = [] as T[]
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ErrorObject,
|
|
3
2
|
GlobalConfig,
|
|
4
3
|
Validation,
|
|
5
4
|
ValidationArgs,
|
|
@@ -11,11 +10,15 @@ export type { Validation, ValidationArgs, GlobalConfig }
|
|
|
11
10
|
|
|
12
11
|
export interface Validatable {
|
|
13
12
|
readonly $dirty: boolean
|
|
14
|
-
readonly $errors: ErrorObject[]
|
|
15
13
|
readonly $invalid: boolean
|
|
14
|
+
readonly $errors: ValidatableError[]
|
|
16
15
|
readonly $touch: () => void
|
|
17
16
|
}
|
|
18
17
|
|
|
18
|
+
export interface ValidatableError {
|
|
19
|
+
readonly $message: string | Ref<string>
|
|
20
|
+
}
|
|
21
|
+
|
|
19
22
|
export function useValidation<
|
|
20
23
|
T extends { [key in keyof R]: any },
|
|
21
24
|
R extends ValidationArgs = ValidationArgs
|
package/lib/styles/variables.css
CHANGED
|
@@ -287,6 +287,7 @@
|
|
|
287
287
|
* -------------------------------------------------------------------------- */
|
|
288
288
|
|
|
289
289
|
:root {
|
|
290
|
+
--z-index-tooltip: 10;
|
|
290
291
|
--z-index-dropdown: 1000;
|
|
291
292
|
--z-index-backdrop: 2000;
|
|
292
293
|
}
|
|
@@ -594,6 +595,17 @@
|
|
|
594
595
|
--pill-fill-danger-active-bg-color: var(--c-danger-bg-darker);
|
|
595
596
|
}
|
|
596
597
|
|
|
598
|
+
/**
|
|
599
|
+
* Component: Tooltip
|
|
600
|
+
* -------------------------------------------------------------------------- */
|
|
601
|
+
|
|
602
|
+
:root {
|
|
603
|
+
--tooltip-max-width: 288px;
|
|
604
|
+
--tooltip-border-color: var(--c-divider-2);
|
|
605
|
+
--tooltip-text-color: var(--c-text-1);
|
|
606
|
+
--tooltip-bg-color: var(--c-bg-elv-3);
|
|
607
|
+
}
|
|
608
|
+
|
|
597
609
|
/**
|
|
598
610
|
* Component: Dropdown
|
|
599
611
|
* -------------------------------------------------------------------------- */
|
|
@@ -611,7 +623,7 @@
|
|
|
611
623
|
* -------------------------------------------------------------------------- */
|
|
612
624
|
|
|
613
625
|
:root {
|
|
614
|
-
--table-border: 1px solid var(--c-divider-
|
|
626
|
+
--table-border: 1px solid var(--c-divider-2);
|
|
615
627
|
--table-border-top: var(--table-border);
|
|
616
628
|
--table-border-right: var(--table-border);
|
|
617
629
|
--table-border-bottom: var(--table-border);
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export {
|
|
2
|
-
|
|
1
|
+
export { and, not, or } from '@vuelidate/validators'
|
|
3
2
|
export * from './checked'
|
|
3
|
+
export * from './decimal'
|
|
4
4
|
export * from './email'
|
|
5
5
|
export * from './fileExtension'
|
|
6
6
|
export * from './hms'
|
|
7
|
+
export * from './maxFileSize'
|
|
7
8
|
export * from './maxLength'
|
|
8
|
-
export * from './minLength'
|
|
9
9
|
export * from './maxValue'
|
|
10
|
+
export * from './minLength'
|
|
10
11
|
export * from './minValue'
|
|
12
|
+
export * from './month'
|
|
11
13
|
export * from './required'
|
|
12
14
|
export * from './requiredHms'
|
|
13
15
|
export * from './requiredIf'
|
|
14
16
|
export * from './requiredYmd'
|
|
17
|
+
export * from './rule'
|
|
15
18
|
export * from './url'
|
|
16
|
-
export * from './decimal'
|
|
17
|
-
export * from './month'
|
|
18
19
|
export * from './ymd'
|
|
19
|
-
export * from './rule'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { helpers } from '@vuelidate/validators'
|
|
2
|
+
import { maxFileSize as baseMaxFileSize } from '../validators/maxFileSize'
|
|
3
|
+
|
|
4
|
+
export function maxFileSize(size: string, msg?: string) {
|
|
5
|
+
return helpers.withParams(
|
|
6
|
+
{ size },
|
|
7
|
+
helpers.withMessage(
|
|
8
|
+
({ $params }) => {
|
|
9
|
+
return msg ?? `The file must be smaller than ${$params.size}.`
|
|
10
|
+
},
|
|
11
|
+
(value: File) => {
|
|
12
|
+
return !helpers.req(value) || baseMaxFileSize(value, size)
|
|
13
|
+
}
|
|
14
|
+
)
|
|
15
|
+
)
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@globalbrain/sefirot",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"description": "Vue Components for Global Brain Design System.",
|
|
5
5
|
"author": "Kia Ishii <ka.ishii@globalbrains.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"@types/body-scroll-lock": "^3.1.0",
|
|
53
53
|
"@types/lodash-es": "^4.17.6",
|
|
54
54
|
"@types/markdown-it": "^12.2.3",
|
|
55
|
-
"@types/node": "^18.11.
|
|
56
|
-
"@vitejs/plugin-vue": "^
|
|
57
|
-
"@vitest/coverage-c8": "^0.
|
|
55
|
+
"@types/node": "^18.11.18",
|
|
56
|
+
"@vitejs/plugin-vue": "^4.0.0",
|
|
57
|
+
"@vitest/coverage-c8": "^0.27.2",
|
|
58
58
|
"@vue/test-utils": "^2.2.7",
|
|
59
59
|
"@vuelidate/core": "^2.0.0",
|
|
60
60
|
"@vuelidate/validators": "^2.0.0",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
"chalk": "^4.1.2",
|
|
64
64
|
"conventional-changelog-cli": "^2.2.2",
|
|
65
65
|
"enquirer": "^2.3.6",
|
|
66
|
-
"eslint": "^8.
|
|
66
|
+
"eslint": "^8.32.0",
|
|
67
67
|
"execa": "^5.1.1",
|
|
68
68
|
"fuse.js": "^6.6.2",
|
|
69
|
-
"happy-dom": "^8.1.
|
|
69
|
+
"happy-dom": "^8.1.4",
|
|
70
70
|
"histoire": "^0.12.4",
|
|
71
71
|
"lodash-es": "^4.17.21",
|
|
72
72
|
"markdown-it": "^13.0.1",
|
|
@@ -77,12 +77,12 @@
|
|
|
77
77
|
"semver": "^7.3.8",
|
|
78
78
|
"typescript": "^4.9.4",
|
|
79
79
|
"v-calendar": "3.0.0-alpha.8",
|
|
80
|
-
"vite": "^
|
|
81
|
-
"vitepress": "1.0.0-alpha.
|
|
82
|
-
"vitest": "^0.
|
|
80
|
+
"vite": "^4.0.4",
|
|
81
|
+
"vitepress": "1.0.0-alpha.38",
|
|
82
|
+
"vitest": "^0.27.2",
|
|
83
83
|
"vue": "^3.2.45",
|
|
84
84
|
"vue-router": "^4.1.6",
|
|
85
|
-
"vue-tsc": "^1.0.
|
|
85
|
+
"vue-tsc": "^1.0.24"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
88
|
"docs": "vitepress dev docs --port 4000",
|