@studio-west/component-sw 0.12.24 → 0.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.
Files changed (55) hide show
  1. package/README.md +143 -30
  2. package/dist/{SwAlert-CU7nEnO-.js → SwAlert-CKJhS25j.js} +2 -2
  3. package/dist/SwButton-B-Z8Fhdv.js +61 -0
  4. package/dist/{SwDropdownItem-CKOTwhTf.js → SwDropdownItem-9Bq9fExK.js} +1 -1
  5. package/dist/SwFile-CfoiKvHJ.js +497 -0
  6. package/dist/{SwGide-Ie6XCPUn.js → SwGide-C62de-t6.js} +2 -2
  7. package/dist/{SwIcon-D6FCTrgR.js → SwIcon-CyVWEZkk.js} +1 -1
  8. package/dist/{SwInput-u7kS3lQn.js → SwInput-BED_o0wD.js} +1 -1
  9. package/dist/{SwMessage-DRjFGSK3.js → SwMessage-CA8jo3G7.js} +2 -2
  10. package/dist/{SwSkeleton-Byvq4bjt.js → SwSkeleton-BIj8PPM_.js} +1 -1
  11. package/dist/component-sw.css +1 -1
  12. package/dist/index.cjs +6 -6
  13. package/dist/index.js +21 -20
  14. package/package.json +2 -5
  15. package/types/components.d.ts +3 -0
  16. package/types/index.d.ts +19 -0
  17. package/dist/SwButton-Bvn3JLcT.js +0 -61
  18. package/src/Alert.ts +0 -70
  19. package/src/components/SwAlert.vue +0 -70
  20. package/src/components/SwButton.vue +0 -57
  21. package/src/components/SwButtonGroup.vue +0 -68
  22. package/src/components/SwCollapse.vue +0 -13
  23. package/src/components/SwDatePicker.vue +0 -375
  24. package/src/components/SwDropdown.vue +0 -195
  25. package/src/components/SwDropdownItem.vue +0 -26
  26. package/src/components/SwDropdownNew.vue +0 -175
  27. package/src/components/SwFormItem.vue +0 -21
  28. package/src/components/SwGide.vue +0 -128
  29. package/src/components/SwIcon.vue +0 -36
  30. package/src/components/SwInput.vue +0 -106
  31. package/src/components/SwMenu.vue +0 -217
  32. package/src/components/SwMessage.vue +0 -53
  33. package/src/components/SwSection.vue +0 -17
  34. package/src/components/SwSelect.vue +0 -153
  35. package/src/components/SwSkeleton.vue +0 -13
  36. package/src/components/SwSkeletonItem.vue +0 -27
  37. package/src/components/SwSlider.vue +0 -281
  38. package/src/components/SwSwitch.vue +0 -53
  39. package/src/components/SwTable.vue +0 -481
  40. package/src/components/SwTableColumn.vue +0 -88
  41. package/src/components/SwTabs.vue +0 -42
  42. package/src/components/SwTabsPane.vue +0 -44
  43. package/src/index.ts +0 -38
  44. package/src/utils/index.ts +0 -149
  45. /package/dist/{SwFormItem-DQJohClb.js → SwFormItem-rn5iuIUv.js} +0 -0
  46. /package/dist/{SwMenu-eQSh_MlP.js → SwMenu-Bh4BtVif.js} +0 -0
  47. /package/dist/{SwSection-BN1U3KaZ.js → SwSection-Bl3H3D2G.js} +0 -0
  48. /package/dist/{SwSelect-CMDZWWEI.js → SwSelect-DyArzImF.js} +0 -0
  49. /package/dist/{SwSkeletonItem-BnXZXE54.js → SwSkeletonItem-BKeBIWXT.js} +0 -0
  50. /package/dist/{SwSlider-DrIc0Xna.js → SwSlider-4S5KNn6o.js} +0 -0
  51. /package/dist/{SwSwitch-BVbje0T9.js → SwSwitch-BqAIQmG3.js} +0 -0
  52. /package/dist/{SwTable-4kHapbYy.js → SwTable-BjYEVovB.js} +0 -0
  53. /package/dist/{SwTableColumn-DCxVGb9d.js → SwTableColumn-CpNTUOVF.js} +0 -0
  54. /package/dist/{SwTabs-x2bXZwz1.js → SwTabs-jUzYPw9X.js} +0 -0
  55. /package/dist/{SwTabsPane-DpkTKQH8.js → SwTabsPane-Bhi49paR.js} +0 -0
@@ -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
- }
File without changes
File without changes