@globalbrain/sefirot 2.12.0 → 2.13.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/lib/components/SButton.vue +4 -2
- package/lib/components/SInputSelect.vue +5 -5
- package/lib/support/Day.ts +23 -0
- package/lib/support/Time.ts +2 -6
- package/package.json +1 -1
- package/lib/support/Day/Constant.ts +0 -32
- package/lib/support/Day/index.ts +0 -11
- package/lib/support/Day/plugins/RelativeTime.ts +0 -124
|
@@ -84,7 +84,9 @@ function handleClick(): void {
|
|
|
84
84
|
<style lang="postcss" scoped>
|
|
85
85
|
.SButton {
|
|
86
86
|
position: relative;
|
|
87
|
-
display: inline-
|
|
87
|
+
display: inline-flex;
|
|
88
|
+
align-items: center;
|
|
89
|
+
letter-spacing: 0;
|
|
88
90
|
text-align: center;
|
|
89
91
|
border: 1px solid transparent;
|
|
90
92
|
border-radius: 6px;
|
|
@@ -590,7 +592,7 @@ function handleClick(): void {
|
|
|
590
592
|
}
|
|
591
593
|
|
|
592
594
|
.SButton.block {
|
|
593
|
-
display:
|
|
595
|
+
display: flex;
|
|
594
596
|
width: 100%;
|
|
595
597
|
}
|
|
596
598
|
|
|
@@ -49,7 +49,7 @@ const classes = computed(() => [
|
|
|
49
49
|
])
|
|
50
50
|
|
|
51
51
|
const isNotSelected = computed(() => {
|
|
52
|
-
return _value.value
|
|
52
|
+
return _value.value == null || _value.value === ''
|
|
53
53
|
})
|
|
54
54
|
|
|
55
55
|
function isSelectedOption(option: Option): boolean {
|
|
@@ -69,7 +69,7 @@ function emitChange(e: any): void {
|
|
|
69
69
|
props.validation?.$touch()
|
|
70
70
|
|
|
71
71
|
const input = e.target.value
|
|
72
|
-
const value = input
|
|
72
|
+
const value = props.options[input]?.value ?? null
|
|
73
73
|
|
|
74
74
|
emit('update:model-value', value)
|
|
75
75
|
emit('change', value)
|
|
@@ -99,7 +99,7 @@ function emitChange(e: any): void {
|
|
|
99
99
|
<option
|
|
100
100
|
v-if="placeholder || nullable"
|
|
101
101
|
class="option"
|
|
102
|
-
value="
|
|
102
|
+
value="-1"
|
|
103
103
|
:selected="isNotSelected"
|
|
104
104
|
:disabled="!nullable"
|
|
105
105
|
>
|
|
@@ -107,11 +107,11 @@ function emitChange(e: any): void {
|
|
|
107
107
|
</option>
|
|
108
108
|
|
|
109
109
|
<option
|
|
110
|
-
v-for="option in options"
|
|
110
|
+
v-for="option, index in options"
|
|
111
111
|
:key="JSON.stringify(option)"
|
|
112
112
|
:style="{ display: option.disabled ? 'none' : undefined }"
|
|
113
113
|
class="option"
|
|
114
|
-
:value="
|
|
114
|
+
:value="index"
|
|
115
115
|
:selected="isSelectedOption(option)"
|
|
116
116
|
>
|
|
117
117
|
{{ option.label }}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import dayjs, { ConfigType, Dayjs } from 'dayjs'
|
|
2
|
+
import PluginRelativeTime from 'dayjs/plugin/relativeTime'
|
|
3
|
+
import PluginTimezone from 'dayjs/plugin/timezone'
|
|
4
|
+
import PluginUtc from 'dayjs/plugin/utc'
|
|
5
|
+
|
|
6
|
+
export type Day = Dayjs
|
|
7
|
+
export type Input = ConfigType
|
|
8
|
+
|
|
9
|
+
dayjs.extend(PluginUtc)
|
|
10
|
+
dayjs.extend(PluginTimezone)
|
|
11
|
+
dayjs.extend(PluginRelativeTime)
|
|
12
|
+
|
|
13
|
+
export function day(input?: Input): Day {
|
|
14
|
+
return dayjs(input)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function utc(input?: Input): Day {
|
|
18
|
+
return dayjs.utc(input)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function tz(input?: Input, timezone?: string): Day {
|
|
22
|
+
return dayjs.tz(input, timezone)
|
|
23
|
+
}
|
package/lib/support/Time.ts
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
type Awaited<T> = T extends undefined
|
|
2
|
-
? T
|
|
3
|
-
: T extends PromiseLike<infer U> ? U : T
|
|
4
|
-
|
|
5
1
|
export function sleep(ms = 500): Promise<undefined> {
|
|
6
2
|
return new Promise<undefined>((resolve) => setTimeout(resolve, ms))
|
|
7
3
|
}
|
|
8
4
|
|
|
9
|
-
export function delay<T extends
|
|
10
|
-
iterable: T,
|
|
5
|
+
export function delay<T extends unknown[]>(
|
|
6
|
+
iterable: [...T],
|
|
11
7
|
ms?: number
|
|
12
8
|
): Promise<{ [P in keyof T]: Awaited<T[P]> }> {
|
|
13
9
|
return Promise.all([...iterable, sleep(ms)]) as any
|
package/package.json
CHANGED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// This file is copied from the source to avoid plugin resolution problem.
|
|
2
|
-
|
|
3
|
-
export const SECONDS_A_MINUTE = 60
|
|
4
|
-
export const SECONDS_A_HOUR = SECONDS_A_MINUTE * 60
|
|
5
|
-
export const SECONDS_A_DAY = SECONDS_A_HOUR * 24
|
|
6
|
-
export const SECONDS_A_WEEK = SECONDS_A_DAY * 7
|
|
7
|
-
|
|
8
|
-
export const MILLISECONDS_A_SECOND = 1e3
|
|
9
|
-
export const MILLISECONDS_A_MINUTE = SECONDS_A_MINUTE * MILLISECONDS_A_SECOND
|
|
10
|
-
export const MILLISECONDS_A_HOUR = SECONDS_A_HOUR * MILLISECONDS_A_SECOND
|
|
11
|
-
export const MILLISECONDS_A_DAY = SECONDS_A_DAY * MILLISECONDS_A_SECOND
|
|
12
|
-
export const MILLISECONDS_A_WEEK = SECONDS_A_WEEK * MILLISECONDS_A_SECOND
|
|
13
|
-
|
|
14
|
-
// English locales
|
|
15
|
-
export const MS = 'millisecond'
|
|
16
|
-
export const S = 'second'
|
|
17
|
-
export const MIN = 'minute'
|
|
18
|
-
export const H = 'hour'
|
|
19
|
-
export const D = 'day'
|
|
20
|
-
export const W = 'week'
|
|
21
|
-
export const M = 'month'
|
|
22
|
-
export const Q = 'quarter'
|
|
23
|
-
export const Y = 'year'
|
|
24
|
-
export const DATE = 'date'
|
|
25
|
-
|
|
26
|
-
export const FORMAT_DEFAULT = 'YYYY-MM-DDTHH:mm:ssZ'
|
|
27
|
-
|
|
28
|
-
export const INVALID_DATE_STRING = 'Invalid Date'
|
|
29
|
-
|
|
30
|
-
// Regex
|
|
31
|
-
export const REGEX_PARSE = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/
|
|
32
|
-
export const REGEX_FORMAT = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g
|
package/lib/support/Day/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import dayjs, { ConfigType, Dayjs } from 'dayjs'
|
|
2
|
-
import { relativeTime } from './plugins/RelativeTime'
|
|
3
|
-
|
|
4
|
-
export type Day = Dayjs
|
|
5
|
-
export type Input = ConfigType
|
|
6
|
-
|
|
7
|
-
dayjs.extend(relativeTime)
|
|
8
|
-
|
|
9
|
-
export function day(input?: Input): Day {
|
|
10
|
-
return dayjs(input)
|
|
11
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
// This file is copied from the source to avoid plugin resolution problem.
|
|
2
|
-
|
|
3
|
-
import { PluginFunc } from 'dayjs'
|
|
4
|
-
import * as C from '../Constant'
|
|
5
|
-
|
|
6
|
-
declare module 'dayjs' {
|
|
7
|
-
interface Dayjs {
|
|
8
|
-
fromNow(withoutSuffix?: boolean): string
|
|
9
|
-
from(compared: ConfigType, withoutSuffix?: boolean): string
|
|
10
|
-
toNow(withoutSuffix?: boolean): string
|
|
11
|
-
to(compared: ConfigType, withoutSuffix?: boolean): string
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface RelativeTimeOptions {
|
|
16
|
-
rounding?: (num: number) => number
|
|
17
|
-
thresholds?: RelativeTimeThreshold[]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface RelativeTimeThreshold {
|
|
21
|
-
l: string
|
|
22
|
-
r?: number
|
|
23
|
-
d?: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const relativeTime: PluginFunc<RelativeTimeOptions> = (o, c, d) => {
|
|
27
|
-
o = o || {}
|
|
28
|
-
|
|
29
|
-
const proto = c.prototype
|
|
30
|
-
|
|
31
|
-
const relObj = {
|
|
32
|
-
future: 'in %s',
|
|
33
|
-
past: '%s ago',
|
|
34
|
-
s: 'a few seconds',
|
|
35
|
-
m: 'a minute',
|
|
36
|
-
mm: '%d minutes',
|
|
37
|
-
h: 'an hour',
|
|
38
|
-
hh: '%d hours',
|
|
39
|
-
d: 'a day',
|
|
40
|
-
dd: '%d days',
|
|
41
|
-
M: 'a month',
|
|
42
|
-
MM: '%d months',
|
|
43
|
-
y: 'a year',
|
|
44
|
-
yy: '%d years'
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
;(d as any).en.relativeTime = relObj
|
|
48
|
-
|
|
49
|
-
;(proto as any).fromToBase = (input: any, withoutSuffix: any, instance: any, isFrom: any, postFormat: any) => {
|
|
50
|
-
const loc = instance.$locale().relativeTime || relObj
|
|
51
|
-
|
|
52
|
-
const T = o.thresholds || [
|
|
53
|
-
{ l: 's', r: 44, d: C.S },
|
|
54
|
-
{ l: 'm', r: 89 },
|
|
55
|
-
{ l: 'mm', r: 44, d: C.MIN },
|
|
56
|
-
{ l: 'h', r: 89 },
|
|
57
|
-
{ l: 'hh', r: 21, d: C.H },
|
|
58
|
-
{ l: 'd', r: 35 },
|
|
59
|
-
{ l: 'dd', r: 25, d: C.D },
|
|
60
|
-
{ l: 'M', r: 45 },
|
|
61
|
-
{ l: 'MM', r: 10, d: C.M },
|
|
62
|
-
{ l: 'y', r: 17 },
|
|
63
|
-
{ l: 'yy', d: C.Y }
|
|
64
|
-
]
|
|
65
|
-
|
|
66
|
-
const Tl = T.length
|
|
67
|
-
|
|
68
|
-
let result
|
|
69
|
-
let out
|
|
70
|
-
let isFuture
|
|
71
|
-
|
|
72
|
-
for (let i = 0; i < Tl; i += 1) {
|
|
73
|
-
let t = T[i]
|
|
74
|
-
if (t.d) {
|
|
75
|
-
result = isFrom
|
|
76
|
-
? d(input).diff(instance, (t as any).d, true)
|
|
77
|
-
: instance.diff(input, t.d, true)
|
|
78
|
-
}
|
|
79
|
-
let abs = (o.rounding || Math.round)(Math.abs(result))
|
|
80
|
-
isFuture = result > 0
|
|
81
|
-
if (abs <= (t as any).r || !t.r) {
|
|
82
|
-
if (abs <= 1 && i > 0) { t = T[i - 1] } // 1 minutes -> a minute, 0 seconds -> 0 second
|
|
83
|
-
const format = loc[t.l]
|
|
84
|
-
if (postFormat) {
|
|
85
|
-
abs = postFormat(`${abs}`)
|
|
86
|
-
}
|
|
87
|
-
if (typeof format === 'string') {
|
|
88
|
-
out = (format as any).replace('%d', abs)
|
|
89
|
-
} else {
|
|
90
|
-
out = format(abs, withoutSuffix, t.l, isFuture)
|
|
91
|
-
}
|
|
92
|
-
break
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
if (withoutSuffix) { return out }
|
|
96
|
-
const pastOrFuture = isFuture ? loc.future : loc.past
|
|
97
|
-
if (typeof pastOrFuture === 'function') {
|
|
98
|
-
return pastOrFuture(out)
|
|
99
|
-
}
|
|
100
|
-
return pastOrFuture.replace('%s', out)
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function fromTo(input: any, withoutSuffix: any, instance: any, isFrom?: any) {
|
|
104
|
-
return (proto as any).fromToBase(input, withoutSuffix, instance, isFrom)
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
proto.to = function (input, withoutSuffix) {
|
|
108
|
-
return fromTo(input, withoutSuffix, this, true)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
proto.from = function (input, withoutSuffix) {
|
|
112
|
-
return fromTo(input, withoutSuffix, this)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const makeNow = (thisDay: any) => (thisDay.$u ? (d as any).utc() : d())
|
|
116
|
-
|
|
117
|
-
proto.toNow = function (withoutSuffix?: boolean) {
|
|
118
|
-
return this.to(makeNow(this), withoutSuffix)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
proto.fromNow = function (withoutSuffix) {
|
|
122
|
-
return this.from(makeNow(this), withoutSuffix)
|
|
123
|
-
}
|
|
124
|
-
}
|