@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,53 +0,0 @@
1
- <template>
2
- <dialog :class="'sw-message ' + props.class" ref="messageRef" >
3
- <header v-if="props.name.length > 0 || !!slots?.header" ><slot name="header">{{ props.name }} <sw-button link type="primary" @click="model = false"><sw-icon :icon-class="props.iconAfter" /></sw-button></slot></header>
4
- <slot></slot>
5
- <footer><slot name="footer"></slot></footer>
6
- </dialog>
7
- </template>
8
-
9
- <script setup>
10
- import {nextTick, onUnmounted, ref, watch, useSlots} from "vue"
11
- import SwButton from "./SwButton.vue"
12
- import SwIcon from "./SwIcon.vue"
13
-
14
- const model = defineModel()
15
- const props = defineProps({
16
- name: {type: String, default: ''},
17
- class: {type:String, default: ''},
18
- iconAfter: {type:String, default: ''}
19
- })
20
- const messageRef = ref(null)
21
- const slots = useSlots();
22
- const handleClickOutside = (e) => {
23
- if (messageRef.value && model.value) {
24
- const dialogRect = messageRef.value.getBoundingClientRect()
25
- const isClickInsideDialog = (
26
- e.clientX >= dialogRect.left &&
27
- e.clientX <= dialogRect.right &&
28
- e.clientY >= dialogRect.top &&
29
- e.clientY <= dialogRect.bottom
30
- )
31
-
32
- // Если клик вне диалога, закрываем его
33
- if (!isClickInsideDialog) {
34
- model.value = false
35
- }
36
- }
37
- }
38
- // Когда модель становится true — добавляем обработчик
39
- watch(() => model.value, (newVal) => {
40
- if (newVal) {
41
- messageRef.value.showModal()
42
-
43
- nextTick() // ждём, пока DOM обновится
44
- window.addEventListener('click', handleClickOutside, true)
45
- } else {
46
- messageRef.value.close()
47
- window.removeEventListener('click', handleClickOutside)
48
- }
49
- })
50
- onUnmounted(() => {
51
- window.removeEventListener('click', handleClickOutside)
52
- })
53
- </script>
@@ -1,17 +0,0 @@
1
- <script setup>
2
- const props = defineProps({
3
- name: {type: String, default: ''},
4
- class: {type:String, default: ''},
5
- iconAfter: {type:String, default: ''}
6
- })
7
- const emit = defineEmits(['header'])
8
- const header = () => {emit('header')}
9
- </script>
10
-
11
- <template>
12
- <section :class="'sw-section ' + props.class">
13
- <header @click="header"><slot name="header">{{ props.name }} <svg-icon :icon-class="props.iconAfter" /></slot></header>
14
- <slot></slot>
15
- <footer><slot name="footer"></slot></footer>
16
- </section>
17
- </template>
@@ -1,153 +0,0 @@
1
- <script setup lang="ts">
2
- import { ref, watch } from "vue"
3
- import axios from 'axios'
4
-
5
- // Define types
6
- interface AddressData {
7
- fullText: string
8
- }
9
-
10
- interface Suggestion {
11
- value: string
12
- data: {
13
- geo_lat: string
14
- geo_lon: string
15
- }
16
- }
17
-
18
- interface GeoData {
19
- text: string
20
- coords: [number, number]
21
- suggestion: any
22
- }
23
-
24
- const address = ref<AddressData>({ fullText: '' })
25
- const visible = ref<boolean>(false)
26
- const options = ref<Suggestion[]>([])
27
-
28
- const model = defineModel<GeoData>()
29
-
30
- interface Props {
31
- class?: string
32
- size?: 'large' | 'small'
33
- placeholder?: string
34
- token?: string
35
- }
36
-
37
- const props = withDefaults(defineProps<Props>(), {
38
- class: '',
39
- size: 'large',
40
- placeholder: '',
41
- token: ''
42
- })
43
- watch(() => model.value?.text, (newValue) => {
44
- if (newValue && newValue.length > 3) address.value.fullText = newValue
45
- })
46
- watch(() => address.value.fullText, (newValue, oldValue) => {
47
- visible.value = (newValue.length > 3 && newValue.length > oldValue.length)
48
- if (newValue.length >3) getDadata()
49
- })
50
- const getDadata = () => {
51
- let url='https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/address'
52
- console.log(address.value.fullText)
53
- axios.post(url, {
54
- query: address.value.fullText },
55
- {
56
- headers: {
57
- "Content-Type": "application/json",
58
- "Accept": "application/json",
59
- "Authorization": 'Token ' + props.token
60
- }
61
- })
62
- .then(response => {
63
- console.log(response.data.suggestions)
64
- options.value = response.data.suggestions
65
- // this.visible = (this.options.length > 1)
66
- if (options.value.length === 1) clickLi(options.value[0])
67
- // this.geo.coords = [Number(response.data.result[0]), Number(response.data.result[1])]
68
- })
69
- .catch(error => {
70
- // handle error
71
- console.log(error);
72
- })
73
- }
74
- const clickLi = (item: Suggestion) => {
75
- address.value.fullText = item.value
76
- visible.value = false
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
- }
82
- model.value = geo
83
- }
84
- </script>
85
-
86
- <template>
87
- <div class="popup">
88
- <sw-input
89
- name="address"
90
- :size="props.size"
91
- v-model="address.fullText"
92
- :placeholder="props.placeholder"
93
- />
94
- <div class="wrapper" v-show="visible">
95
- <ul class="scrollbar">
96
- <li tabindex="1" v-for="(item, key) in options" :key="key" @click="clickLi(item)">{{ item.value }}</li>
97
- </ul>
98
- </div>
99
- </div>
100
- </template>
101
-
102
- <style lang="scss">
103
- .popup{
104
- position: relative;
105
- .wrapper{
106
- position: absolute;
107
- z-index: 1;
108
- list-style: none;
109
- font-size: .8rem;
110
- line-height: 1.2;
111
- word-break: break-word;
112
- padding: 0;
113
- margin: 10px 0 0;
114
- :before{
115
- content: '';
116
- border-bottom-color: transparent !important;
117
- border-left-color: transparent !important;
118
- border: 1px solid var(--el-border-color-light);
119
- background: var(--el-bg-color-overlay);
120
- right: 50%;
121
- top: -6px;
122
- position: absolute;
123
- width: 10px;
124
- height: 10px;
125
- z-index: 1;
126
- transform: rotate(-45deg);
127
- }
128
- }
129
- .scrollbar {
130
- box-shadow: 0 0 0 1px var(--el-border-color);
131
- border-radius: var(--el-border-radius-base);
132
- background: #ffffff;
133
- padding: .5rem 0;
134
- margin: 0;
135
- li{display: flex;
136
- align-items: start;
137
- white-space: nowrap;
138
- list-style: none;
139
- line-height: 22px;
140
- padding: 5px 16px;
141
- margin:0;
142
- font-size: var(--sw-font-size);
143
- color: var(--sw-text-color-secondary);
144
- cursor:pointer;
145
- outline: none;
146
- &:not(.is-disabled):focus{
147
- background: var(--el-dropdown-menuItem-hover-fill);
148
- color:var(--el-dropdown-menuItem-hover-color);
149
- }
150
- }
151
- }
152
- }
153
- </style>
@@ -1,13 +0,0 @@
1
- <template>
2
- <slot v-if="props.visual"></slot>
3
- <div v-else class="sw-skeleton" :class="props.class"><slot name="skeleton" ><sw-skeleton-item animate size="small"/></slot></div>
4
-
5
- </template>
6
-
7
- <script setup>
8
- import SwSkeletonItem from "./SwSkeletonItem.vue"
9
- const props = defineProps({
10
- class: {type:String, default: ''},
11
- visual: {type:Boolean, default: false}
12
- })
13
- </script>
@@ -1,27 +0,0 @@
1
- <template>
2
- <div :class="c" :style="s"><template v-if="props.animate"><div /></template></div>
3
- </template>
4
-
5
- <script setup>
6
- import {computed} from "vue";
7
-
8
- const props = defineProps({
9
- width: {type: String, default: '100'},
10
- class: {type:String, default: ''},
11
- animate: {type:Boolean, default: false},
12
- size: {type:String, default: ''}
13
- })
14
- const c = computed(() =>{
15
- let s = ['sw-skeleton-item']
16
- if(props.size.length > 0) s.push('sw-' + props.size)
17
- if(props.animate) s.push('sw-animate')
18
- if(props.class.length > 0) s.push(props.class)
19
- return s
20
- }
21
- )
22
- const s = computed(() =>{
23
- return {
24
- width: props.width + '%'
25
- }
26
- })
27
- </script>
@@ -1,281 +0,0 @@
1
- <template>
2
- <div :class="style">
3
- <div class="track"
4
- @click="onTrackClick"
5
- @mousedown.prevent="(e) => onStartDrag(e, 0)"
6
- @touchstart.prevent="(e) => onStartDrag(e.touches[0], 0)">
7
- <div class="fill" :style="fillStyle"></div>
8
- </div>
9
- <!-- Multiple thumbs -->
10
- <div v-for="(value, index) in values"
11
- class="thumb"
12
- :key="index"
13
- :style="thumbStyles[index]"
14
- @mouseenter="showTooltip(index)"
15
- @mouseleave="hideTooltip(index)"
16
- @focus="showTooltip(index)"
17
- @blur="hideTooltip(index)"
18
- @mousedown.prevent="(e) => onStartDrag(e, index)"
19
- @touchstart.prevent="(e) => onStartDrag(e.touches[0], index)"
20
- >
21
- <slot :index="index" :value="value"></slot>
22
- <div
23
- v-if="tooltipVisible[index] && showValue"
24
- class="tooltip"
25
- :class="{ 'tooltip-vertical': props.vertical }"
26
- :style="tooltipStyle(index)"
27
- >
28
- {{ value }}
29
- </div>
30
- </div>
31
- </div>
32
- </template>
33
-
34
- <script setup>
35
- import { ref, computed, onMounted, onUnmounted } from 'vue'
36
- import { calculateTooltipPosition } from '../utils/index.js'
37
-
38
- const model = defineModel({type: [Number, Array], required: true})
39
- const props = defineProps({
40
- class: { type: String, default: ''},
41
- size: {type:String, default: ''},
42
- min: {type: Number, default: 0},
43
- max: {type: Number, default: 100},
44
- step: {type: Number, default: 1},
45
- vertical: {type: Boolean, default: false},
46
- showValue: {type: Boolean, default: false}
47
- })
48
-
49
- const tooltipVisible = ref([])
50
- const tooltipPositions = ref([])
51
-
52
- const style = computed(() =>{
53
- let s = ['sw-slider']
54
- if(props.size.length > 0) s.push('sw-' + props.size)
55
- if(props.class.length > 0) s.push(props.class)
56
- if(props.vertical) s.push('vertical')
57
- return s
58
- }
59
- )
60
-
61
- const showTooltip = (index) => {
62
- const newVisibility = [...tooltipVisible.value]
63
- newVisibility[index] = true
64
- tooltipVisible.value = newVisibility
65
- }
66
-
67
- const hideTooltip = (index) => {
68
- const newVisibility = [...tooltipVisible.value]
69
- newVisibility[index] = false
70
- tooltipVisible.value = newVisibility
71
- }
72
-
73
- const tooltipStyle = (index) => {
74
- const sliderElement = typeof document !== 'undefined' ? document.querySelector('.sw-slider') : null
75
- if (sliderElement) {
76
- return calculateTooltipPosition(sliderElement, props.vertical)
77
- }
78
- // Fallback positions
79
- if (props.vertical) {
80
- return { right: '100%', marginRight: '10px' }
81
- } else {
82
- return { bottom: '100%', marginBottom: '10px' }
83
- }
84
- }
85
-
86
- // Determine ifwe're dealing with an array (multiple thumbs)
87
- const isArray = computed(() => Array.isArray(model.value))
88
-
89
- // Get values as array for uniform treatment
90
- const values = computed({
91
- get() {
92
- return isArray.value ? [...model.value] : [model.value]
93
- },
94
- set(newValues) {
95
- if (isArray.value) {
96
- // Sort values for display purposes
97
- model.value = [...newValues].sort((a, b) => a - b)
98
- } else {
99
- model.value = newValues[0]
100
- }
101
- }
102
- })
103
-
104
- // Calculate percentages for each thumb
105
- const percentages = computed(() => {
106
- const range= props.max - props.min
107
- return values.value.map(value => {
108
- return range === 0 ? 0 : ((value - props.min) / range) * 100
109
- })
110
- })
111
-
112
- // Style for the fill between first and last thumbs
113
- const fillStyle = computed(() => {
114
- if (props.vertical) {
115
- if(isArray.value) {
116
- const firstPercent = percentages.value[0] || 0
117
- const lastPercent = percentages.value[percentages.value.length - 1] || 0
118
- const minPercent = Math.min(firstPercent, lastPercent)
119
- const maxPercent = Math.max(firstPercent, lastPercent)
120
- return {
121
- height: `${maxPercent - minPercent}%`,
122
- top: `${minPercent}%`,
123
- left: '0',
124
- width: '100%'
125
- }
126
- } else {
127
- // For single value, start from 0
128
- const percent = percentages.value[0] || 0
129
- return {
130
- height: `${percent}%`,
131
- top: '0',
132
- left: '0',
133
- width: '100%'
134
- }
135
- }
136
- } else {
137
- if (isArray.value) {
138
- const firstPercent = percentages.value[0] || 0
139
- const lastPercent= percentages.value[percentages.value.length - 1] || 0
140
- const minPercent = Math.min(firstPercent, lastPercent)
141
- const maxPercent = Math.max(firstPercent, lastPercent)
142
-
143
- return {
144
- width: `${maxPercent - minPercent}%`,
145
- left: `${minPercent}%`,
146
- top: '0',
147
- height: '100%'
148
- }
149
- } else {
150
- // For single value, start from 0
151
- const percent = percentages.value[0] || 0
152
- return {
153
- width: `${percent}%`,
154
- left: '0',
155
- top: '0',
156
- height: '100%'
157
- }
158
- }
159
- }
160
- })
161
-
162
- // Stylesfor each thumb
163
- const thumbStyles = computed(() => {
164
- return percentages.value.map((percent, index) => {
165
- return props.vertical
166
- ? { top: `${percent}%`, zIndex: values.value.length - index }
167
- : { left: `${percent}%`, zIndex: values.value.length - index }
168
- })
169
- })
170
-
171
- // === Track click handler ===
172
- function onTrackClick(e) {
173
- // Only for single thumb sliders
174
- if (isArray.value) return
175
-
176
- const slider = e.currentTarget.closest('.sw-slider')
177
- if (!slider) return
178
-
179
- const rect = slider.getBoundingClientRect()
180
- const ratio = props.vertical
181
- ? (e.clientY - rect.top) / rect.height
182
- : (e.clientX - rect.left) / rect.width
183
-
184
- const clampedRatio = Math.max(0, Math.min(1, ratio))
185
- const range = props.max - props.min
186
- let value = props.min + clampedRatio * range
187
-
188
- // Apply step
189
- const steps = Math.round((value - props.min) / props.step)
190
- value = props.min + steps * props.step
191
- value = Math.max(props.min, Math.min(props.max, value))
192
-
193
- // Update the value
194
- values.value = [value]
195
-
196
- // Update tooltip position
197
- setTimeout(() => {
198
- const newPositions = [...tooltipPositions.value]
199
- newPositions[0] = tooltipStyle(0)
200
- tooltipPositions.value = newPositions
201
- }, 0)
202
- }
203
-
204
- // === Dragging ===
205
- const isDragging = ref(false)
206
- const draggingIndex = ref(null)
207
- const sliderRect = ref(null)
208
-
209
- function onStartDrag(e, index) {
210
- // For single thumb sliders, also handle track clicks
211
- // if (!isArray.value && index !== 0) return
212
-
213
- const slider = e.target.closest('.sw-slider')
214
- if (!slider) return
215
- sliderRect.value = slider.getBoundingClientRect()
216
- draggingIndex.value = index
217
- isDragging.value = true
218
- updateValueFromClient(e.clientX || e.touches?.[0]?.clientX, e.clientY|| e.touches?.[0]?.clientY)
219
- }
220
-
221
- function onDrag(e) {
222
- if (!isDragging.value) return
223
- e.preventDefault?.()
224
- const clientX = e.clientX || e.touches?.[0]?.clientX
225
- const clientY = e.clientY ||e.touches?.[0]?.clientY
226
- updateValueFromClient(clientX, clientY)
227
- }
228
-
229
- function stopDragging() {
230
- isDragging.value = false
231
- draggingIndex.value = null
232
- }
233
-
234
- function updateValueFromClient(clientX, clientY) {
235
- if (!sliderRect.value || draggingIndex.value === null) return
236
-
237
- const rect = sliderRect.value
238
- const ratio = props.vertical
239
- ? (clientY - rect.top) / rect.height
240
- : (clientX - rect.left) / rect.width
241
-
242
- const clampedRatio = Math.max(0, Math.min(1, ratio))
243
- const range= props.max - props.min
244
- let value = props.min + clampedRatio * range
245
-
246
- // Apply step
247
- const steps = Math.round((value - props.min) / props.step)
248
- value = props.min + steps * props.step
249
- value = Math.max(props.min, Math.min(props.max,value))
250
-
251
- // Update the specific thumb value
252
- const newValues = [...values.value]
253
- newValues[draggingIndex.value] = value
254
- values.value = newValues
255
-
256
- // Update tooltip position
257
- setTimeout(() => {
258
- const newPositions = [...tooltipPositions.value]
259
- newPositions[draggingIndex.value] = tooltipStyle(draggingIndex.value)
260
- tooltipPositions.value = newPositions
261
- }, 0)
262
- }
263
-
264
- // Global listeners
265
- onMounted(() => {
266
- window.addEventListener('mousemove', onDrag)
267
- window.addEventListener('mouseup', stopDragging)
268
- window.addEventListener('touchmove', onDrag, { passive: false })
269
- window.addEventListener('touchend', stopDragging)
270
-
271
- // Initialize tooltip visibility array
272
- tooltipVisible.value = new Array(values.value.length).fill(false)
273
- })
274
-
275
- onUnmounted(() => {
276
- window.removeEventListener('mousemove', onDrag)
277
- window.removeEventListener('mouseup', stopDragging)
278
- window.removeEventListener('touchmove', onDrag)
279
- window.removeEventListener('touchend', stopDragging)
280
- })
281
- </script>
@@ -1,53 +0,0 @@
1
- <template>
2
- <div :class="style">
3
- <!--input type="checkbox" :name="props.name" class="sw-control" :id="props.id" v-model="model"-->
4
- <input
5
- type="checkbox"
6
- :name="props.name"
7
- class="sw-control"
8
- :id="props.id"
9
- :checked="model"
10
- @change="handleChange"
11
- >
12
- <label :for="props.id" class="sw-label" :data-onlabel="props.on" :data-offlabel="props.off" />
13
- <slot></slot>
14
- </div>
15
- </template>
16
-
17
- <script setup lang="ts">
18
- import { computed } from "vue"
19
-
20
- // Define prop types
21
- interface Props {
22
- id?: string
23
- class?: string
24
- name?: string
25
- on?: string
26
- off?: string
27
- size?: string
28
- checkbox?: boolean
29
- }
30
-
31
- const model = defineModel<boolean>()
32
- const props = withDefaults(defineProps<Props>(), {
33
- id: 'checkbox',
34
- class: '',
35
- name: '',
36
- on: '',
37
- off: '',
38
- size: '',
39
- checkbox: false
40
- })
41
- const style = computed(() =>{
42
- let s = ['sw-switch']
43
- if(props.size.length > 0) s.push('sw-' + props.size)
44
- if(props.checkbox) s.push('sw-checkbox')
45
- if(props.class.length > 0) s.push(props.class)
46
- return s
47
- })
48
-
49
- const handleChange = (event: Event) => {
50
- const target = event.target as HTMLInputElement
51
- model.value = target.checked
52
- }
53
- </script>