@flyanra/vue-core 1.4.0 → 1.5.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/dist/types/components/form/input-renderers/country-input/FlyCountryCitySelect.vue.d.ts +1 -0
- package/dist/types/components/form/input-renderers/country-input/FlyCountryStatesSelect.vue.d.ts +1 -0
- package/dist/types/components/form/input-renderers/index.d.ts +3 -0
- package/dist/types/components/form/input-renderers/otp-input/FlyOTPInput.vue.d.ts +15 -0
- package/dist/types/components/form/input-renderers/otp-input/index.d.ts +3 -0
- package/dist/types/components/form/input-renderers/regional-tenant-form-renderer/FlyRegionalTenantFormRenderer.types.d.ts +8 -1
- package/dist/types/components/form/input-renderers/regional-tenant-form-renderer/FlyRegionalTenantFormRenderer.vue.d.ts +8 -4
- package/dist/types/components/form/input-renderers/regional-tenant-form-renderer/index.d.ts +4 -0
- package/package.json +1 -1
- package/src/components/form/input-renderers/country-input/FlyCountryCitySelect.vue +2 -1
- package/src/components/form/input-renderers/country-input/FlyCountryStatesSelect.vue +2 -1
- package/src/components/form/input-renderers/index.ts +12 -0
- package/src/components/form/input-renderers/otp-input/FlyOTPInput.scss +27 -0
- package/src/components/form/input-renderers/otp-input/FlyOTPInput.vue +98 -0
- package/src/components/form/input-renderers/otp-input/index.ts +4 -0
- package/src/components/form/input-renderers/phone-number/FlyPhoneNumberInput.vue +0 -1
- package/src/components/form/input-renderers/regional-tenant-form-renderer/FlyRegionalTenantFormRenderer.types.ts +13 -1
- package/src/components/form/input-renderers/regional-tenant-form-renderer/FlyRegionalTenantFormRenderer.vue +18 -19
- package/src/components/form/input-renderers/regional-tenant-form-renderer/index.ts +10 -0
- package/src/styles/element/overrides/date-time.scss +4 -0
- package/src/styles/element/overrides/form.scss +13 -0
|
@@ -2,4 +2,7 @@ export * from './form-item-renderer';
|
|
|
2
2
|
export * from './input-renderer';
|
|
3
3
|
export * from './country-input';
|
|
4
4
|
export * from './phone-number';
|
|
5
|
+
export * from './otp-input';
|
|
6
|
+
export * from './regional-tenant-form-renderer';
|
|
5
7
|
export type { T_InputRendererBase } from './input-renderer.types';
|
|
8
|
+
export type { T_FormSchemaLookupData, T_InputSchema, T_InputSchemaText, T_InputSchemaNumber, T_InputSchemaBoolean, T_InputSchemaSelect, T_InputSchemaValueUnit, T_InputSchemaDateTime } from './form-schema.types';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import './FlyOTPInput.scss';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
modelValue: string;
|
|
4
|
+
length?: number;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
8
|
+
"update:modelValue": (value: string) => any;
|
|
9
|
+
complete: (value: string) => any;
|
|
10
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
11
|
+
"onUpdate:modelValue"?: ((value: string) => any) | undefined;
|
|
12
|
+
onComplete?: ((value: string) => any) | undefined;
|
|
13
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { T_FormSchemaLookupData, T_InputSchema } from '../form-schema.types';
|
|
2
|
+
import type FlyRegionalTenantFormRenderer from './FlyRegionalTenantFormRenderer.vue';
|
|
3
|
+
export type T_FlyRegionalTenantFormRendererInstance = InstanceType<typeof FlyRegionalTenantFormRenderer> | null;
|
|
4
|
+
export type T_TenantRegionalFormMainSection = {
|
|
5
|
+
key: string;
|
|
6
|
+
title: string;
|
|
7
|
+
};
|
|
2
8
|
export type T_TenantRegionalFormSection = {
|
|
3
9
|
key: string;
|
|
4
10
|
fields: T_InputSchema[];
|
|
@@ -8,6 +14,7 @@ export type T_TenantRegionalFormSection = {
|
|
|
8
14
|
modelValue?: Record<string, unknown>;
|
|
9
15
|
};
|
|
10
16
|
export type T_TenantRegionalFormProps = {
|
|
11
|
-
|
|
17
|
+
mainSections: T_TenantRegionalFormMainSection[];
|
|
12
18
|
sections?: T_TenantRegionalFormSection[];
|
|
19
|
+
activeSection?: string | number;
|
|
13
20
|
};
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import '../../../../styles/element/overrides/collapse.scss';
|
|
2
2
|
import type { T_TenantRegionalFormProps } from './FlyRegionalTenantFormRenderer.types';
|
|
3
3
|
declare function validateForms(): Promise<true | undefined>;
|
|
4
|
-
declare var
|
|
4
|
+
declare var __VLS_20: string, __VLS_21: {}, __VLS_40: {};
|
|
5
5
|
type __VLS_Slots = {} & {
|
|
6
|
-
|
|
6
|
+
[K in NonNullable<typeof __VLS_20>]?: (props: typeof __VLS_21) => any;
|
|
7
7
|
} & {
|
|
8
|
-
default?: (props: typeof
|
|
8
|
+
default?: (props: typeof __VLS_40) => any;
|
|
9
9
|
};
|
|
10
10
|
declare const __VLS_base: import("vue").DefineComponent<T_TenantRegionalFormProps, {
|
|
11
11
|
validateForms: typeof validateForms;
|
|
12
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
12
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
13
|
+
"update:activeSection": (value: string | number) => any;
|
|
14
|
+
}, string, import("vue").PublicProps, Readonly<T_TenantRegionalFormProps> & Readonly<{
|
|
15
|
+
"onUpdate:activeSection"?: ((value: string | number) => any) | undefined;
|
|
16
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
17
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
14
18
|
declare const _default: typeof __VLS_export;
|
|
15
19
|
export default _default;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import FlyRegionalTenantFormRenderer from './FlyRegionalTenantFormRenderer.vue';
|
|
2
|
+
export default FlyRegionalTenantFormRenderer;
|
|
3
|
+
export { FlyRegionalTenantFormRenderer };
|
|
4
|
+
export type { T_TenantRegionalFormMainSection, T_TenantRegionalFormSection, T_TenantRegionalFormProps, T_FlyRegionalTenantFormRendererInstance } from './FlyRegionalTenantFormRenderer.types';
|
package/package.json
CHANGED
|
@@ -28,11 +28,12 @@
|
|
|
28
28
|
<script setup lang="ts">
|
|
29
29
|
import { computed, watch } from 'vue'
|
|
30
30
|
|
|
31
|
-
import { ElOption, ElSelect } from 'element-plus'
|
|
31
|
+
import { ElInput, ElOption, ElSelect } from 'element-plus'
|
|
32
32
|
|
|
33
33
|
import { City } from 'country-state-city'
|
|
34
34
|
|
|
35
35
|
import '../select/FlySelect.scss'
|
|
36
|
+
import '../text/FlyText.scss'
|
|
36
37
|
|
|
37
38
|
const emit = defineEmits<{
|
|
38
39
|
(e: 'update:modelValue', value: string | undefined): void
|
|
@@ -33,11 +33,12 @@
|
|
|
33
33
|
<script setup lang="ts">
|
|
34
34
|
import { computed, watch } from 'vue'
|
|
35
35
|
|
|
36
|
-
import { ElOption, ElSelect } from 'element-plus'
|
|
36
|
+
import { ElInput, ElOption, ElSelect } from 'element-plus'
|
|
37
37
|
|
|
38
38
|
import { State } from 'country-state-city'
|
|
39
39
|
|
|
40
40
|
import '../select/FlySelect.scss'
|
|
41
|
+
import '../text/FlyText.scss'
|
|
41
42
|
|
|
42
43
|
const emit = defineEmits<{
|
|
43
44
|
(e: 'update:modelValue', value: string | undefined): void
|
|
@@ -3,5 +3,17 @@ export * from './input-renderer'
|
|
|
3
3
|
|
|
4
4
|
export * from './country-input'
|
|
5
5
|
export * from './phone-number'
|
|
6
|
+
export * from './otp-input'
|
|
7
|
+
export * from './regional-tenant-form-renderer'
|
|
6
8
|
|
|
7
9
|
export type { T_InputRendererBase } from './input-renderer.types'
|
|
10
|
+
export type {
|
|
11
|
+
T_FormSchemaLookupData,
|
|
12
|
+
T_InputSchema,
|
|
13
|
+
T_InputSchemaText,
|
|
14
|
+
T_InputSchemaNumber,
|
|
15
|
+
T_InputSchemaBoolean,
|
|
16
|
+
T_InputSchemaSelect,
|
|
17
|
+
T_InputSchemaValueUnit,
|
|
18
|
+
T_InputSchemaDateTime
|
|
19
|
+
} from './form-schema.types'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@use 'element-plus/theme-chalk/src/input.scss';
|
|
2
|
+
|
|
3
|
+
.fly-otp-input-group {
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
align-self: center;
|
|
7
|
+
flex-wrap: wrap;
|
|
8
|
+
gap: 1rem; // tw:gap-4
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.fly-otp-input-slot {
|
|
12
|
+
width: 3rem; // tw:w-12
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.fly-otp-input {
|
|
16
|
+
.el-input__wrapper {
|
|
17
|
+
aspect-ratio: 1 / 1; // tw:aspect-square
|
|
18
|
+
padding: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.el-input__inner {
|
|
22
|
+
text-align: center; // tw:text-center
|
|
23
|
+
font-weight: 700; // tw:font-bold
|
|
24
|
+
font-size: 1.5rem; // tw:text-2xl
|
|
25
|
+
line-height: 2rem;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="fly-otp-input-group">
|
|
3
|
+
<div v-for="(_, index) in slots" :key="index" class="fly-otp-input-slot">
|
|
4
|
+
<el-input
|
|
5
|
+
:ref="(el) => (inputRefs[index] = el as InstanceType<typeof ElInput> | null)"
|
|
6
|
+
v-model="slots[index]"
|
|
7
|
+
:disabled="disabled"
|
|
8
|
+
:maxlength="1"
|
|
9
|
+
class="fly-otp-input"
|
|
10
|
+
@input="handleInput(index)"
|
|
11
|
+
@keydown="(e: KeyboardEvent | Event) => handleKeydown(e, index)"
|
|
12
|
+
@paste.prevent="handlePaste"
|
|
13
|
+
/>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
import { ref, watch } from 'vue'
|
|
20
|
+
|
|
21
|
+
import { ElInput } from 'element-plus'
|
|
22
|
+
|
|
23
|
+
import './FlyOTPInput.scss'
|
|
24
|
+
|
|
25
|
+
const props = defineProps<{
|
|
26
|
+
modelValue: string
|
|
27
|
+
length?: number
|
|
28
|
+
disabled?: boolean
|
|
29
|
+
}>()
|
|
30
|
+
|
|
31
|
+
const emit = defineEmits<{
|
|
32
|
+
(e: 'update:modelValue', value: string): void
|
|
33
|
+
(e: 'complete', value: string): void
|
|
34
|
+
}>()
|
|
35
|
+
|
|
36
|
+
const resolvedLength = props.length ?? 4
|
|
37
|
+
|
|
38
|
+
const slots = ref<string[]>(Array(resolvedLength).fill(''))
|
|
39
|
+
const inputRefs = ref<(InstanceType<typeof ElInput> | null)[]>([])
|
|
40
|
+
|
|
41
|
+
const emitValue = () => {
|
|
42
|
+
const joined = slots.value.join('')
|
|
43
|
+
emit('update:modelValue', joined)
|
|
44
|
+
if (joined.length === resolvedLength && slots.value.every((s) => s.length === 1)) {
|
|
45
|
+
emit('complete', joined)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const handleInput = (index: number) => {
|
|
50
|
+
const val = slots.value[index]
|
|
51
|
+
if (!val) return
|
|
52
|
+
// Only keep the last character in case browser allows more than 1
|
|
53
|
+
slots.value[index] = val.slice(-1).replace(/\D/, '')
|
|
54
|
+
if (!slots.value[index]) return
|
|
55
|
+
inputRefs.value[index + 1]?.focus()
|
|
56
|
+
emitValue()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const handleKeydown = (event: KeyboardEvent | Event, index: number) => {
|
|
60
|
+
if (!(event instanceof KeyboardEvent)) return
|
|
61
|
+
if (event.key === 'Backspace') {
|
|
62
|
+
if (slots.value[index]) {
|
|
63
|
+
slots.value[index] = ''
|
|
64
|
+
emitValue()
|
|
65
|
+
} else {
|
|
66
|
+
inputRefs.value[index - 1]?.focus()
|
|
67
|
+
}
|
|
68
|
+
} else if (event.key === 'ArrowLeft') {
|
|
69
|
+
inputRefs.value[index - 1]?.focus()
|
|
70
|
+
} else if (event.key === 'ArrowRight') {
|
|
71
|
+
inputRefs.value[index + 1]?.focus()
|
|
72
|
+
} else if (event.key === 'Enter') {
|
|
73
|
+
emit('complete', slots.value.join(''))
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const handlePaste = (event: ClipboardEvent) => {
|
|
78
|
+
const pasted = event.clipboardData?.getData('text') ?? ''
|
|
79
|
+
const digits = pasted.replace(/\D/g, '').slice(0, resolvedLength).split('')
|
|
80
|
+
digits.forEach((d, i) => {
|
|
81
|
+
slots.value[i] = d
|
|
82
|
+
})
|
|
83
|
+
const lastFilled = Math.min(digits.length, resolvedLength - 1)
|
|
84
|
+
inputRefs.value[lastFilled]?.focus()
|
|
85
|
+
emitValue()
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
watch(
|
|
89
|
+
() => props.modelValue,
|
|
90
|
+
(value) => {
|
|
91
|
+
const incoming = (value ?? '').slice(0, resolvedLength).split('')
|
|
92
|
+
slots.value = Array(resolvedLength)
|
|
93
|
+
.fill('')
|
|
94
|
+
.map((_, i) => incoming[i] ?? '')
|
|
95
|
+
},
|
|
96
|
+
{ immediate: true }
|
|
97
|
+
)
|
|
98
|
+
</script>
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import type { T_FormSchemaLookupData, T_InputSchema } from '../form-schema.types'
|
|
2
2
|
|
|
3
|
+
import type FlyRegionalTenantFormRenderer from './FlyRegionalTenantFormRenderer.vue'
|
|
4
|
+
|
|
5
|
+
export type T_FlyRegionalTenantFormRendererInstance = InstanceType<
|
|
6
|
+
typeof FlyRegionalTenantFormRenderer
|
|
7
|
+
> | null
|
|
8
|
+
|
|
9
|
+
export type T_TenantRegionalFormMainSection = {
|
|
10
|
+
key: string
|
|
11
|
+
title: string
|
|
12
|
+
}
|
|
13
|
+
|
|
3
14
|
export type T_TenantRegionalFormSection = {
|
|
4
15
|
key: string
|
|
5
16
|
fields: T_InputSchema[]
|
|
@@ -10,6 +21,7 @@ export type T_TenantRegionalFormSection = {
|
|
|
10
21
|
}
|
|
11
22
|
|
|
12
23
|
export type T_TenantRegionalFormProps = {
|
|
13
|
-
|
|
24
|
+
mainSections: T_TenantRegionalFormMainSection[]
|
|
14
25
|
sections?: T_TenantRegionalFormSection[]
|
|
26
|
+
activeSection?: string | number
|
|
15
27
|
}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="fly-regional-tenant-form-renderer">
|
|
3
3
|
<el-collapse v-if="sections?.length" v-model="activeNames" accordion>
|
|
4
|
-
<
|
|
5
|
-
<
|
|
6
|
-
<
|
|
7
|
-
|
|
4
|
+
<template v-for="mainSection in mainSections" :key="mainSection.key">
|
|
5
|
+
<el-collapse-item :name="mainSection.key">
|
|
6
|
+
<template #title>
|
|
7
|
+
<FlyCollapseTitleRenderer :title="mainSection.title" />
|
|
8
|
+
</template>
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
<div style="padding: 1rem">
|
|
11
|
+
<slot :name="mainSection.key"></slot>
|
|
12
|
+
</div>
|
|
13
|
+
</el-collapse-item>
|
|
14
|
+
</template>
|
|
13
15
|
|
|
14
16
|
<template v-for="section in sections">
|
|
15
17
|
<el-collapse-item v-if="section.fields?.length" :key="section.key" :name="section.key">
|
|
@@ -19,7 +21,7 @@
|
|
|
19
21
|
<div style="padding: 1rem">
|
|
20
22
|
<div v-if="section.description" style="margin-bottom: 1.25rem">
|
|
21
23
|
<p style="font-size: 0.875; line-height: 1.25rem">
|
|
22
|
-
{{
|
|
24
|
+
{{ section.description }}
|
|
23
25
|
</p>
|
|
24
26
|
</div>
|
|
25
27
|
|
|
@@ -42,11 +44,10 @@
|
|
|
42
44
|
</template>
|
|
43
45
|
|
|
44
46
|
<script setup lang="ts">
|
|
45
|
-
import { type ComponentPublicInstance,
|
|
47
|
+
import { type ComponentPublicInstance, computed, reactive } from 'vue'
|
|
46
48
|
|
|
47
49
|
import { ElCollapse, ElCollapseItem } from 'element-plus'
|
|
48
50
|
|
|
49
|
-
import { useLocaleInjector } from '../../../../composables/useLocaleInjector/useLocaleInjector'
|
|
50
51
|
import '../../../../styles/element/overrides/collapse.scss'
|
|
51
52
|
import FlyCollapseTitleRenderer from '../../../basic/typography/FlyCollapseTitleRenderer.vue'
|
|
52
53
|
import type { T_FlyFormSchemaRendererInstance } from '../form-schema-renderer/FlyFormSchemaRenderer.types'
|
|
@@ -54,15 +55,13 @@ import FlyFormSchemaRenderer from '../form-schema-renderer/FlyFormSchemaRenderer
|
|
|
54
55
|
|
|
55
56
|
import type { T_TenantRegionalFormProps } from './FlyRegionalTenantFormRenderer.types'
|
|
56
57
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
defineProps<T_TenantRegionalFormProps>()
|
|
58
|
+
const props = defineProps<T_TenantRegionalFormProps>()
|
|
59
|
+
const emit = defineEmits<{ 'update:activeSection': [value: string | number] }>()
|
|
62
60
|
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
const activeNames = computed<string | number>({
|
|
62
|
+
get: () => props.activeSection ?? props.mainSections[0]?.key ?? '',
|
|
63
|
+
set: (val) => emit('update:activeSection', val)
|
|
64
|
+
})
|
|
66
65
|
const formRefs = reactive<{ [K: string]: T_FlyFormSchemaRendererInstance }>({})
|
|
67
66
|
|
|
68
67
|
function setFormRef(formRef: Element | ComponentPublicInstance | null, key: string) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import FlyRegionalTenantFormRenderer from './FlyRegionalTenantFormRenderer.vue'
|
|
2
|
+
|
|
3
|
+
export default FlyRegionalTenantFormRenderer
|
|
4
|
+
export { FlyRegionalTenantFormRenderer }
|
|
5
|
+
export type {
|
|
6
|
+
T_TenantRegionalFormMainSection,
|
|
7
|
+
T_TenantRegionalFormSection,
|
|
8
|
+
T_TenantRegionalFormProps,
|
|
9
|
+
T_FlyRegionalTenantFormRendererInstance
|
|
10
|
+
} from './FlyRegionalTenantFormRenderer.types'
|
|
@@ -117,3 +117,16 @@
|
|
|
117
117
|
line-height: 1px;
|
|
118
118
|
font-weight: bolder;
|
|
119
119
|
}
|
|
120
|
+
|
|
121
|
+
.el-input-group--prepend .el-input-group__prepend .el-select .el-select__wrapper.is-disabled {
|
|
122
|
+
--el-input-border-color: var(--el-disabled-border-color);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.el-tag {
|
|
126
|
+
&.el-tag--info {
|
|
127
|
+
&.el-tag--light {
|
|
128
|
+
--el-tag-text-color: var(--default-text-color);
|
|
129
|
+
--el-tag-bg-color: var(--el-color-info-light-7);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|