@studio-west/component-sw 0.12.23 → 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.
Files changed (38) hide show
  1. package/README.md +0 -2
  2. package/dist/{SwAlert-DdNME1KV.js → SwAlert-CU7nEnO-.js} +1 -1
  3. package/dist/{SwDropdownItem-BQ0sWjy3.js → SwDropdownItem-CKOTwhTf.js} +1 -1
  4. package/dist/{SwGide-T8VMbn6F.js → SwGide-Ie6XCPUn.js} +1 -1
  5. package/dist/{SwIcon-jPY932qp.js → SwIcon-D6FCTrgR.js} +2 -2
  6. package/dist/{SwInput-BvqWmT5t.js → SwInput-u7kS3lQn.js} +1 -1
  7. package/dist/{SwMessage-T2PdfXm1.js → SwMessage-DRjFGSK3.js} +1 -1
  8. package/dist/component-sw.css +1 -1
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.js +7 -7
  11. package/package.json +2 -5
  12. package/src/Alert.ts +0 -70
  13. package/src/components/SwAlert.vue +0 -70
  14. package/src/components/SwButton.vue +0 -57
  15. package/src/components/SwButtonGroup.vue +0 -68
  16. package/src/components/SwCollapse.vue +0 -13
  17. package/src/components/SwDatePicker.vue +0 -375
  18. package/src/components/SwDropdown.vue +0 -195
  19. package/src/components/SwDropdownItem.vue +0 -26
  20. package/src/components/SwDropdownNew.vue +0 -175
  21. package/src/components/SwFormItem.vue +0 -21
  22. package/src/components/SwGide.vue +0 -128
  23. package/src/components/SwIcon.vue +0 -35
  24. package/src/components/SwInput.vue +0 -106
  25. package/src/components/SwMenu.vue +0 -217
  26. package/src/components/SwMessage.vue +0 -53
  27. package/src/components/SwSection.vue +0 -17
  28. package/src/components/SwSelect.vue +0 -153
  29. package/src/components/SwSkeleton.vue +0 -13
  30. package/src/components/SwSkeletonItem.vue +0 -27
  31. package/src/components/SwSlider.vue +0 -281
  32. package/src/components/SwSwitch.vue +0 -53
  33. package/src/components/SwTable.vue +0 -481
  34. package/src/components/SwTableColumn.vue +0 -88
  35. package/src/components/SwTabs.vue +0 -42
  36. package/src/components/SwTabsPane.vue +0 -44
  37. package/src/index.ts +0 -38
  38. package/src/utils/index.ts +0 -149
@@ -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>