@globalbrain/sefirot 0.70.0 → 2.0.0-draft.1
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 +2 -800
- 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 -632
- 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
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { regex as baseRegex } from '../validators'
|
|
2
|
-
import { Rule } from './'
|
|
3
|
-
|
|
4
|
-
export default function required(regExp: RegExp, message?: string): Rule {
|
|
5
|
-
return {
|
|
6
|
-
name: 'regex',
|
|
7
|
-
message: message ?? 'The value is invalid.',
|
|
8
|
-
optional: true,
|
|
9
|
-
validate: value => baseRegex(value, regExp)
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import baseRequiredHMS, { HMSType } from '../validators/requiredHMS'
|
|
2
|
-
import { Rule } from './'
|
|
3
|
-
|
|
4
|
-
export default function requiredHMS(required?: HMSType[], message?: string): Rule {
|
|
5
|
-
return {
|
|
6
|
-
name: 'requiredHMS',
|
|
7
|
-
message: message ?? 'The field is required.',
|
|
8
|
-
optional: true,
|
|
9
|
-
validate: v => baseRequiredHMS(v, required)
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { requiredMonthDate as baseRequiredMonthDate } from '../validators'
|
|
2
|
-
import { Rule } from './'
|
|
3
|
-
|
|
4
|
-
export default function requiredMonthDate(message?: string): Rule {
|
|
5
|
-
return {
|
|
6
|
-
name: 'requiredMonthDate',
|
|
7
|
-
message: message ?? 'The field is required.',
|
|
8
|
-
optional: true,
|
|
9
|
-
validate: baseRequiredMonthDate
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { requiredYearMonth as baseRequiredYearMonth } from '../validators'
|
|
2
|
-
import { Rule } from './'
|
|
3
|
-
|
|
4
|
-
export default function requiredYearMonth(message?: string): Rule {
|
|
5
|
-
return {
|
|
6
|
-
name: 'requiredYearMonth',
|
|
7
|
-
message: message ?? 'The field is required.',
|
|
8
|
-
optional: true,
|
|
9
|
-
validate: baseRequiredYearMonth
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { requiredYearMonthDate as baseRequiredYearMonthDate } from '../validators'
|
|
2
|
-
import { Rule } from './'
|
|
3
|
-
|
|
4
|
-
export default function requiredYearMonthDate(message?: string): Rule {
|
|
5
|
-
return {
|
|
6
|
-
name: 'requiredYearMonthDate',
|
|
7
|
-
message: message ?? 'The field is required.',
|
|
8
|
-
optional: true,
|
|
9
|
-
validate: baseRequiredYearMonthDate
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { sameAs as baseSameAs } from '../validators'
|
|
2
|
-
import { Rule } from './'
|
|
3
|
-
|
|
4
|
-
export default function required(other: string, message?: string): Rule {
|
|
5
|
-
return {
|
|
6
|
-
name: 'sameAs',
|
|
7
|
-
message: message ?? `The value must match ${other}.`,
|
|
8
|
-
optional: true,
|
|
9
|
-
validate: (value, data) => baseSameAs(value, data[other])
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { required } from '../validators'
|
|
2
|
-
import { Rule, Locator, locate } from './'
|
|
3
|
-
|
|
4
|
-
export default function validateIf(locator: Locator, rules: Rule[]): Rule {
|
|
5
|
-
return {
|
|
6
|
-
name: 'validateIf',
|
|
7
|
-
message: 'Default message.',
|
|
8
|
-
optional: false,
|
|
9
|
-
validate(value, data) {
|
|
10
|
-
if (!locate(data, locator)) {
|
|
11
|
-
return true
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return rules.every((rule) => {
|
|
15
|
-
if (rule.optional && !required(value)) {
|
|
16
|
-
return true
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const result = rule.validate(value, data)
|
|
20
|
-
|
|
21
|
-
this.message = rule.message
|
|
22
|
-
|
|
23
|
-
return result
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { yearMonth as baseYearMonth } from '../validators'
|
|
2
|
-
import { Rule } from './'
|
|
3
|
-
|
|
4
|
-
export default function yearMonth(message?: string): Rule {
|
|
5
|
-
return {
|
|
6
|
-
name: 'yearMonth',
|
|
7
|
-
message: message ?? 'The date is invalid.',
|
|
8
|
-
optional: true,
|
|
9
|
-
validate: baseYearMonth
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { yearMonthDate as baseYearMonthDate } from '../validators'
|
|
2
|
-
import { Rule } from './'
|
|
3
|
-
|
|
4
|
-
export default function year(message?: string): Rule {
|
|
5
|
-
return {
|
|
6
|
-
name: 'yearMonthDate',
|
|
7
|
-
message: message ?? 'The date is invalid.',
|
|
8
|
-
optional: true,
|
|
9
|
-
validate: baseYearMonthDate
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import dayjs from 'dayjs'
|
|
2
|
-
|
|
3
|
-
export default function day(value: number, year?: number, month?: number): boolean {
|
|
4
|
-
if (year && !month) {
|
|
5
|
-
return validateDateOnly(value)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
if (!year && month) {
|
|
9
|
-
return validateWithMonth(month, value)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (year && month) {
|
|
13
|
-
return validateWithYearMonth(year, month, value)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return validateDateOnly(value)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function validateDateOnly(date: number): boolean {
|
|
20
|
-
return date > 0 && date < 32
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function validateWithMonth(month: number, date: number): boolean {
|
|
24
|
-
return dayjs().year(2020).month(month - 1).date(date).date() === date
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function validateWithYearMonth(year: number, month: number, date: number): boolean {
|
|
28
|
-
return dayjs().year(year).month(month - 1).date(date).date() === date
|
|
29
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import checked from './checked'
|
|
2
|
-
import day from './day'
|
|
3
|
-
import email from './email'
|
|
4
|
-
import fileExtension from './fileExtension'
|
|
5
|
-
import hms from './hms'
|
|
6
|
-
import include from './include'
|
|
7
|
-
import includeSome from './includeSome'
|
|
8
|
-
import integer from './integer'
|
|
9
|
-
import maxLength from './maxLength'
|
|
10
|
-
import maxValue from './maxValue'
|
|
11
|
-
import minValue from './minValue'
|
|
12
|
-
import month from './month'
|
|
13
|
-
import monthDate from './monthDate'
|
|
14
|
-
import regex from './regex'
|
|
15
|
-
import required from './required'
|
|
16
|
-
import requiredHMS from './requiredHMS'
|
|
17
|
-
import requiredMonthDate from './requiredMonthDate'
|
|
18
|
-
import requiredYearMonth from './requiredYearMonth'
|
|
19
|
-
import requiredYearMonthDate from './requiredYearMonthDate'
|
|
20
|
-
import sameAs from './sameAs'
|
|
21
|
-
import url from './url'
|
|
22
|
-
import year from './year'
|
|
23
|
-
import yearMonthDate from './yearMonthDate'
|
|
24
|
-
import yearMonth from './yearMonth'
|
|
25
|
-
|
|
26
|
-
export {
|
|
27
|
-
checked,
|
|
28
|
-
day,
|
|
29
|
-
email,
|
|
30
|
-
fileExtension,
|
|
31
|
-
hms,
|
|
32
|
-
include,
|
|
33
|
-
includeSome,
|
|
34
|
-
integer,
|
|
35
|
-
maxLength,
|
|
36
|
-
maxValue,
|
|
37
|
-
minValue,
|
|
38
|
-
month,
|
|
39
|
-
monthDate,
|
|
40
|
-
regex,
|
|
41
|
-
required,
|
|
42
|
-
requiredHMS,
|
|
43
|
-
requiredMonthDate,
|
|
44
|
-
requiredYearMonth,
|
|
45
|
-
requiredYearMonthDate,
|
|
46
|
-
sameAs,
|
|
47
|
-
url,
|
|
48
|
-
year,
|
|
49
|
-
yearMonthDate,
|
|
50
|
-
yearMonth
|
|
51
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export default function integer(value: number): boolean {
|
|
2
|
-
// ^[0-9]*$ - for empty string and positive integer.
|
|
3
|
-
// ^-[0-9]+$ - only for negative integer (minus sign without at least
|
|
4
|
-
// 1 digit is not a number)
|
|
5
|
-
return /(^[0-9]*$)|(^-[0-9]+$)/.test(String(value))
|
|
6
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import day from 'dayjs'
|
|
2
|
-
|
|
3
|
-
export interface MonthDate {
|
|
4
|
-
month?: number
|
|
5
|
-
date?: number
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export default function monthDate(value: MonthDate): boolean {
|
|
9
|
-
if (value.month === undefined || value.date === undefined) {
|
|
10
|
-
return true
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const d = day(new Date(2020, value.month - 1, value.date))
|
|
14
|
-
|
|
15
|
-
if (d.month() + 1 !== value.month) {
|
|
16
|
-
return false
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return d.isValid()
|
|
20
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export default function required(value: any): boolean {
|
|
2
|
-
if (Array.isArray(value)) {
|
|
3
|
-
return !!value.length
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
if (value === undefined || value === null) {
|
|
7
|
-
return false
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
if (value === false) {
|
|
11
|
-
return true
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
if (value instanceof Date) {
|
|
15
|
-
return true
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (typeof value === 'object') {
|
|
19
|
-
for (const _ in value) {
|
|
20
|
-
return true
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return false
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return !!String(value).length
|
|
27
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export interface HMS {
|
|
2
|
-
hour?: string
|
|
3
|
-
minute?: string
|
|
4
|
-
second?: string
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export type HMSType = 'h' | 'm' | 's'
|
|
8
|
-
|
|
9
|
-
const HMSMap = {
|
|
10
|
-
h: 'hour',
|
|
11
|
-
m: 'minute',
|
|
12
|
-
s: 'second'
|
|
13
|
-
} as const
|
|
14
|
-
|
|
15
|
-
export default function requiredHMS(hms: HMS, required: HMSType[] = ['h', 'm', 's']): boolean {
|
|
16
|
-
return required.every(r => hms[HMSMap[r]] !== undefined)
|
|
17
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export interface YearMonthDate {
|
|
2
|
-
year?: number
|
|
3
|
-
month?: number
|
|
4
|
-
date?: number
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default function requiredYearMonthDate(value: YearMonthDate): boolean {
|
|
8
|
-
return !(value.year === undefined || value.month === undefined || value.date === undefined)
|
|
9
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
const regex = /^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00A1-\uFFFF0-9]-*)*[a-z\u00A1-\uFFFF0-9]+)(?:\.(?:[a-z\u00A1-\uFFFF0-9]-*)*[a-z\u00A1-\uFFFF0-9]+)*(?:\.(?:[a-z\u00A1-\uFFFF]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i
|
|
2
|
-
|
|
3
|
-
export default function url(value: any): boolean {
|
|
4
|
-
return regex.test(value)
|
|
5
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export interface YearMonth {
|
|
2
|
-
year?: number
|
|
3
|
-
month?: number
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export default function yearMonth(value: YearMonth): boolean {
|
|
7
|
-
if (value.year === undefined || value.month === undefined) {
|
|
8
|
-
return true
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (value.year < 0 || value.year > 9999) {
|
|
12
|
-
return false
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (value.month < 0 || value.month > 12) {
|
|
16
|
-
return false
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return true
|
|
20
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import day from 'dayjs'
|
|
2
|
-
|
|
3
|
-
export interface YearMonthDate {
|
|
4
|
-
year?: number
|
|
5
|
-
month?: number
|
|
6
|
-
date?: number
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export default function yearMonthDate(value: YearMonthDate): boolean {
|
|
10
|
-
if (value.year === undefined || value.month === undefined || value.date === undefined) {
|
|
11
|
-
return true
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const d = day(new Date(value.year, value.month - 1, value.date))
|
|
15
|
-
|
|
16
|
-
if (d.month() + 1 !== value.month) {
|
|
17
|
-
return false
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return d.isValid()
|
|
21
|
-
}
|