@studio-west/component-sw 0.12.24 → 0.12.25
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/README.md +0 -2
- package/package.json +2 -5
- package/src/Alert.ts +0 -70
- package/src/components/SwAlert.vue +0 -70
- package/src/components/SwButton.vue +0 -57
- package/src/components/SwButtonGroup.vue +0 -68
- package/src/components/SwCollapse.vue +0 -13
- package/src/components/SwDatePicker.vue +0 -375
- package/src/components/SwDropdown.vue +0 -195
- package/src/components/SwDropdownItem.vue +0 -26
- package/src/components/SwDropdownNew.vue +0 -175
- package/src/components/SwFormItem.vue +0 -21
- package/src/components/SwGide.vue +0 -128
- package/src/components/SwIcon.vue +0 -36
- package/src/components/SwInput.vue +0 -106
- package/src/components/SwMenu.vue +0 -217
- package/src/components/SwMessage.vue +0 -53
- package/src/components/SwSection.vue +0 -17
- package/src/components/SwSelect.vue +0 -153
- package/src/components/SwSkeleton.vue +0 -13
- package/src/components/SwSkeletonItem.vue +0 -27
- package/src/components/SwSlider.vue +0 -281
- package/src/components/SwSwitch.vue +0 -53
- package/src/components/SwTable.vue +0 -481
- package/src/components/SwTableColumn.vue +0 -88
- package/src/components/SwTabs.vue +0 -42
- package/src/components/SwTabsPane.vue +0 -44
- package/src/index.ts +0 -38
- package/src/utils/index.ts +0 -149
package/src/utils/index.ts
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if a path is external (http, mailto, tel)
|
|
3
|
-
* @param path - Path to check
|
|
4
|
-
* @returns Boolean indicating if path is external
|
|
5
|
-
*/
|
|
6
|
-
export function isExternal(path: string): boolean {
|
|
7
|
-
return /^(https?:|mailto:|tel:)/.test(path)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Parse time according to format
|
|
12
|
-
* @param time - Time to parse (Date object, string, or number)
|
|
13
|
-
* @param cFormat - Format string, defaults to '{Y}-{m}-{d} {G}:{i}:{s}'
|
|
14
|
-
* @returns Formatted time string
|
|
15
|
-
*/
|
|
16
|
-
export function parseTime(time: Date | string | number, cFormat?: string): string | null {
|
|
17
|
-
if (arguments.length === 0 || !time) {
|
|
18
|
-
return null
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const format = cFormat || '{Y}-{m}-{d} {G}:{i}:{s}'
|
|
22
|
-
let date: Date
|
|
23
|
-
|
|
24
|
-
if (typeof time === 'object') {
|
|
25
|
-
date = time
|
|
26
|
-
} else {
|
|
27
|
-
if (typeof time === 'string') {
|
|
28
|
-
if (/^[0-9]+$/.test(time)) {
|
|
29
|
-
// support "1548221490638"
|
|
30
|
-
time = parseInt(time, 10)
|
|
31
|
-
} else {
|
|
32
|
-
// support safari
|
|
33
|
-
// https://stackoverflow.com/questions/4310953/invalid-date-in-safari
|
|
34
|
-
time = time.replace(new RegExp(/-/gm), '/')
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (typeof time === 'number' && time.toString().length === 10) {
|
|
39
|
-
time = time * 1000
|
|
40
|
-
}
|
|
41
|
-
date = new Date(time)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const locale = 'ru-RU'
|
|
45
|
-
|
|
46
|
-
const formatObj: Record<string, string | number> = {
|
|
47
|
-
Y: date.getFullYear(),
|
|
48
|
-
m: (date.getMonth() + 1).toString().padStart(2, '0'),
|
|
49
|
-
d: date.getDate(),
|
|
50
|
-
dd: date.getDate().toString().padStart(2, '0'),
|
|
51
|
-
G: date.getHours(),
|
|
52
|
-
H: date.getHours().toString().padStart(2, '0'),
|
|
53
|
-
i: date.getMinutes().toString().padStart(2, '0'),
|
|
54
|
-
s: date.getSeconds().toString().padStart(2, '0'),
|
|
55
|
-
D: new Intl.DateTimeFormat(locale, { weekday: 'short' }).format(date),
|
|
56
|
-
F: new Intl.DateTimeFormat(locale, { month: 'long' }).format(date),
|
|
57
|
-
M: new Intl.DateTimeFormat(locale, { month: 'short' }).format(date)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return format.replace(/{(dd|[YmdGHisDFM])+}/g, (result, key) => {
|
|
61
|
-
return formatObj[key]?.toString() || result
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Parse a date string into a standardized format for date operations
|
|
67
|
-
* @param date - Date string to parse
|
|
68
|
-
* @returns Formatted date string
|
|
69
|
-
*/
|
|
70
|
-
export function parseDateString(date: string): string {
|
|
71
|
-
const separator = date.match(/\D.*?\D?/)
|
|
72
|
-
if (!separator) return date + 'T00:00:01'
|
|
73
|
-
|
|
74
|
-
const parts = date.split(separator[0])
|
|
75
|
-
return (parts[0].length > 2) ? parts.join('-') + 'T00:00:01' : parts.reverse().join('-') + 'T00:00:01'
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Format phone number according to a template
|
|
80
|
-
* @param value - Phone number to format
|
|
81
|
-
* @param oldValue - Previous phone number value
|
|
82
|
-
* @returns Formatted phone number
|
|
83
|
-
*/
|
|
84
|
-
export function formatPhoneNumber(value: string, oldValue?: string): string {
|
|
85
|
-
if (oldValue && /^\+[0-9]\s/.test(oldValue) && value.length === 2 || /^\+0\s/.test(value)) return ''
|
|
86
|
-
if (typeof value === 'undefined' || value.length === 0) return value
|
|
87
|
-
|
|
88
|
-
const matrix = '+0 (___) ___-__-__'
|
|
89
|
-
let i = 0
|
|
90
|
-
const def = matrix.replace(/\D/g, '')
|
|
91
|
-
const val = value.replace(/\D/g, '')
|
|
92
|
-
let new_value = matrix.replace(/[_\d]/g, (a) => (i < val.length ? val.charAt(i++) || def.charAt(i) : a))
|
|
93
|
-
i = new_value.indexOf('_')
|
|
94
|
-
if (i !== -1) {
|
|
95
|
-
i = i < 5 ? 3 : i
|
|
96
|
-
new_value = new_value.slice(0, i)
|
|
97
|
-
}
|
|
98
|
-
const regPattern = matrix.slice(0, value.length)
|
|
99
|
-
.replace(
|
|
100
|
-
/_+/g,
|
|
101
|
-
(a) => `\\d{1,${a.length}}`
|
|
102
|
-
)
|
|
103
|
-
.replace(/[+()]/g, '\\$&')
|
|
104
|
-
const reg = new RegExp(`^${regPattern}$`)
|
|
105
|
-
new_value = new_value.replace(/[-—]$|(\) )$/g, '')
|
|
106
|
-
|
|
107
|
-
if ((!reg.test(value) || value.length < 5)) return new_value
|
|
108
|
-
return value
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Check if a given element is visible in the viewport
|
|
113
|
-
* @param element - Element to check
|
|
114
|
-
* @returns True if element is in viewport
|
|
115
|
-
*/
|
|
116
|
-
export function isInViewport(element: HTMLElement): boolean {
|
|
117
|
-
const rect = element.getBoundingClientRect()
|
|
118
|
-
return (
|
|
119
|
-
rect.top >= 0 &&
|
|
120
|
-
rect.left >= 0 &&
|
|
121
|
-
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
|
|
122
|
-
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Calculate tooltip position based on available space
|
|
128
|
-
* @param element - Element to position tooltip relative to
|
|
129
|
-
* @param vertical - Whether the element is vertically oriented
|
|
130
|
-
* @returns CSS styles for tooltip positioning
|
|
131
|
-
*/
|
|
132
|
-
export function calculateTooltipPosition(element: HTMLElement, vertical = false): Record<string, string> {
|
|
133
|
-
const rect = element.getBoundingClientRect()
|
|
134
|
-
|
|
135
|
-
if (vertical) {
|
|
136
|
-
// For vertical slider, position tooltip to the left or right
|
|
137
|
-
// Check if there's space on the left
|
|
138
|
-
if (rect.left > 50) {
|
|
139
|
-
// Position to the left
|
|
140
|
-
return { right: '100%', marginRight: '10px' }
|
|
141
|
-
} else {
|
|
142
|
-
// Position to the right
|
|
143
|
-
return { left: '100%', marginLeft: '10px' }
|
|
144
|
-
}
|
|
145
|
-
} else {
|
|
146
|
-
// For horizontal slider, position tooltip above
|
|
147
|
-
return { bottom: '100%', marginBottom: '10px' }
|
|
148
|
-
}
|
|
149
|
-
}
|