@studio-west/component-sw 0.12.9 → 0.12.10
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/package.json +1 -1
- package/src/Alert.ts +2 -2
- package/src/components/SwAlert.vue +1 -1
- package/src/components/SwDatePicker.vue +1 -1
- package/src/components/SwDropdownItem.vue +1 -1
- package/src/components/SwGide.vue +3 -3
- package/src/components/SwIcon.vue +1 -1
- package/src/components/SwInput.vue +1 -1
- package/src/components/SwMenu.vue +6 -7
- package/src/components/SwMessage.vue +2 -2
- package/src/components/SwSelect.vue +8 -6
- package/src/components/SwSkeleton.vue +1 -1
- package/src/components/SwSlider.vue +1 -1
- package/src/index.ts +3 -9
- package/src/utils/index.ts +2 -2
- package/types/shims-vue.d.ts +5 -0
package/package.json
CHANGED
package/src/Alert.ts
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
<script setup>
|
|
15
15
|
import { ref, computed, onMounted, onUnmounted } from "vue"
|
|
16
|
-
import SwIcon from "
|
|
16
|
+
import SwIcon from "./SwIcon.vue"
|
|
17
17
|
const props = defineProps({
|
|
18
18
|
message: {type: String, default: "Default message"},
|
|
19
19
|
before: {type: String, default: ''},
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
</template>
|
|
31
31
|
|
|
32
32
|
<script setup>
|
|
33
|
-
import SwDropdown from "
|
|
34
|
-
import SwButton from "
|
|
33
|
+
import SwDropdown from "./SwDropdown.vue"
|
|
34
|
+
import SwButton from "./SwButton.vue"
|
|
35
35
|
import {watchEffect, ref, onMounted} from "vue"
|
|
36
|
-
import SwIcon from "
|
|
36
|
+
import SwIcon from "./SwIcon.vue"
|
|
37
37
|
const swGide = ref(null)
|
|
38
38
|
const visual = ref(true)
|
|
39
39
|
const block = ref(null)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed, ref, watch } from "vue"
|
|
3
3
|
import SwIcon from "./SwIcon.vue"
|
|
4
|
-
import { formatPhoneNumber } from "
|
|
4
|
+
import { formatPhoneNumber } from "../utils/index"
|
|
5
5
|
|
|
6
6
|
// Define prop types - separate model from props
|
|
7
7
|
interface InputProps {
|
|
@@ -38,10 +38,9 @@ const instance = getCurrentInstance()
|
|
|
38
38
|
const createComponentWithSlots = (
|
|
39
39
|
componentName: string | Component,
|
|
40
40
|
config: MenuItemConfig,
|
|
41
|
-
index: number | null = null
|
|
42
|
-
parentIndex: number | null = null
|
|
41
|
+
index: number | null = null
|
|
43
42
|
): VNode => {
|
|
44
|
-
let component: Component | string
|
|
43
|
+
let component: Component | string | undefined
|
|
45
44
|
let resolvedComponent: any = null
|
|
46
45
|
|
|
47
46
|
try {
|
|
@@ -89,7 +88,7 @@ const createComponentWithSlots = (
|
|
|
89
88
|
if (Array.isArray(compConfig)) {
|
|
90
89
|
return compConfig.map(item => createComponentWithSlots(compName, item))
|
|
91
90
|
} else {
|
|
92
|
-
return createComponentWithSlots(compName, compConfig)
|
|
91
|
+
return createComponentWithSlots(compName, compConfig as MenuItemConfig)
|
|
93
92
|
}
|
|
94
93
|
}).flat()
|
|
95
94
|
}
|
|
@@ -97,7 +96,7 @@ const createComponentWithSlots = (
|
|
|
97
96
|
return value.map(item => {
|
|
98
97
|
if (typeof item === 'object' && !Array.isArray(item)) {
|
|
99
98
|
const [nestedComponentName, nestedConfig] = Object.entries(item)[0]
|
|
100
|
-
return createComponentWithSlots(nestedComponentName, nestedConfig)
|
|
99
|
+
return createComponentWithSlots(nestedComponentName, nestedConfig as MenuItemConfig)
|
|
101
100
|
}
|
|
102
101
|
return item
|
|
103
102
|
})
|
|
@@ -118,7 +117,7 @@ const createComponentWithSlots = (
|
|
|
118
117
|
if (Array.isArray(compConfig)) {
|
|
119
118
|
return compConfig.map(item => createComponentWithSlots(compName, item))
|
|
120
119
|
} else {
|
|
121
|
-
return createComponentWithSlots(compName, compConfig)
|
|
120
|
+
return createComponentWithSlots(compName, compConfig as MenuItemConfig)
|
|
122
121
|
}
|
|
123
122
|
}).flat()
|
|
124
123
|
}
|
|
@@ -126,7 +125,7 @@ const createComponentWithSlots = (
|
|
|
126
125
|
return value.map(item => {
|
|
127
126
|
if (typeof item === 'object' && !Array.isArray(item)) {
|
|
128
127
|
const [nestedComponentName, nestedConfig] = Object.entries(item)[0]
|
|
129
|
-
return createComponentWithSlots(nestedComponentName, nestedConfig)
|
|
128
|
+
return createComponentWithSlots(nestedComponentName, nestedConfig as MenuItemConfig)
|
|
130
129
|
}
|
|
131
130
|
return item
|
|
132
131
|
})
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
<script setup>
|
|
10
10
|
import {nextTick, onUnmounted, ref, watch, useSlots} from "vue"
|
|
11
|
-
import SwButton from "
|
|
12
|
-
import SwIcon from "
|
|
11
|
+
import SwButton from "./SwButton.vue"
|
|
12
|
+
import SwIcon from "./SwIcon.vue"
|
|
13
13
|
|
|
14
14
|
const model = defineModel()
|
|
15
15
|
const props = defineProps({
|
|
@@ -43,7 +43,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
43
43
|
watch(() => model.value?.text, (newValue) => {
|
|
44
44
|
if (newValue && newValue.length > 3) address.value.fullText = newValue
|
|
45
45
|
})
|
|
46
|
-
watch(address.value.fullText,(newValue, oldValue) => {
|
|
46
|
+
watch(() => address.value.fullText, (newValue, oldValue) => {
|
|
47
47
|
visible.value = (newValue.length > 3 && newValue.length > oldValue.length)
|
|
48
48
|
if (newValue.length >3) getDadata()
|
|
49
49
|
})
|
|
@@ -71,13 +71,14 @@ const getDadata = () => {
|
|
|
71
71
|
console.log(error);
|
|
72
72
|
})
|
|
73
73
|
}
|
|
74
|
-
const clickLi = (item) => {
|
|
74
|
+
const clickLi = (item: Suggestion) => {
|
|
75
75
|
address.value.fullText = item.value
|
|
76
76
|
visible.value = false
|
|
77
|
-
const geo = {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
const geo: GeoData = {
|
|
78
|
+
text: item.value,
|
|
79
|
+
coords: [Number(item.data.geo_lat), Number(item.data.geo_lon)],
|
|
80
|
+
suggestion: item.data
|
|
81
|
+
}
|
|
81
82
|
model.value = geo
|
|
82
83
|
}
|
|
83
84
|
</script>
|
|
@@ -85,6 +86,7 @@ const clickLi = (item) => {
|
|
|
85
86
|
<template>
|
|
86
87
|
<div class="popup">
|
|
87
88
|
<sw-input
|
|
89
|
+
name="address"
|
|
88
90
|
:size="props.size"
|
|
89
91
|
v-model="address.fullText"
|
|
90
92
|
:placeholder="props.placeholder"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
|
|
34
34
|
<script setup>
|
|
35
35
|
import { ref, computed, onMounted, onUnmounted } from 'vue'
|
|
36
|
-
import { calculateTooltipPosition } from '
|
|
36
|
+
import { calculateTooltipPosition } from '../utils/index.js'
|
|
37
37
|
|
|
38
38
|
const model = defineModel({type: [Number, Array], required: true})
|
|
39
39
|
const props = defineProps({
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="vite/client" />
|
|
2
|
+
import { defineAsyncComponent, type App, type Component } from 'vue'
|
|
2
3
|
import './styles/main.scss'
|
|
3
4
|
import { Alert } from './Alert'
|
|
4
5
|
|
|
5
6
|
// Import all Vue components
|
|
6
|
-
const modules = import.meta.glob('./components/*.vue')
|
|
7
|
+
const modules = import.meta.glob<{ default: Component }>('./components/*.vue')
|
|
7
8
|
|
|
8
9
|
// Create components object with proper typing
|
|
9
10
|
const components: Record<string, ReturnType<typeof defineAsyncComponent>> = {}
|
|
@@ -33,12 +34,5 @@ const Library = {
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
// Type exports
|
|
37
|
-
export type { SwButtonProps } from '@/types'
|
|
38
|
-
export type { SwInputProps } from '@/types'
|
|
39
|
-
export type { SwSwitchProps } from '@/types'
|
|
40
|
-
export type { SwSelectProps } from '@/types'
|
|
41
|
-
export type { SwMenuProps } from '@/types'
|
|
42
|
-
|
|
43
37
|
// Named exports
|
|
44
38
|
export { components, Alert, Library }
|
package/src/utils/index.ts
CHANGED
|
@@ -95,13 +95,13 @@ export function formatPhoneNumber(value: string, oldValue?: string): string {
|
|
|
95
95
|
i = i < 5 ? 3 : i
|
|
96
96
|
new_value = new_value.slice(0, i)
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
const regPattern = matrix.slice(0, value.length)
|
|
99
99
|
.replace(
|
|
100
100
|
/_+/g,
|
|
101
101
|
(a) => `\\d{1,${a.length}}`
|
|
102
102
|
)
|
|
103
103
|
.replace(/[+()]/g, '\\$&')
|
|
104
|
-
reg = new RegExp(`^${
|
|
104
|
+
const reg = new RegExp(`^${regPattern}$`)
|
|
105
105
|
new_value = new_value.replace(/[-—]$|(\) )$/g, '')
|
|
106
106
|
|
|
107
107
|
if ((!reg.test(value) || value.length < 5)) return new_value
|