@mixd-id/web-scaffold 0.1.2301231369 → 0.2.240702

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 (249) hide show
  1. package/LICENSE +1 -0
  2. package/docs/components/Header2.md +16 -0
  3. package/docs/components/TreeView.md +0 -0
  4. package/package.json +22 -5
  5. package/src/App.vue +9 -1
  6. package/src/components/Ahref.vue +175 -9
  7. package/src/components/Alert.vue +181 -75
  8. package/src/components/Article.vue +393 -0
  9. package/src/components/Block.vue +31 -0
  10. package/src/components/Box.vue +34 -0
  11. package/src/components/Button.vue +208 -129
  12. package/src/components/Carousel.vue +194 -124
  13. package/src/components/Chart.vue +485 -0
  14. package/src/components/ChartBar.vue +193 -0
  15. package/src/components/Checkbox.vue +95 -55
  16. package/src/components/CodeEditor.vue +61 -0
  17. package/src/components/ColorPicker.vue +158 -0
  18. package/src/components/ColorPicker2.vue +164 -0
  19. package/src/components/Confirm.vue +178 -0
  20. package/src/components/ContextMenu.vue +164 -76
  21. package/src/components/ConversationBuilder.vue +161 -0
  22. package/src/components/CopyToClipboard.vue +6 -31
  23. package/src/components/Countdown.vue +104 -53
  24. package/src/components/DGrid.vue +21 -0
  25. package/src/components/DGridItem.vue +263 -0
  26. package/src/components/DataList.vue +92 -0
  27. package/src/components/Datepicker.vue +65 -41
  28. package/src/components/DayTimeRange.vue +125 -0
  29. package/src/components/Dropdown.vue +32 -9
  30. package/src/components/ErrorText.vue +30 -9
  31. package/src/components/FBLogin.vue +194 -0
  32. package/src/components/Flex.vue +70 -0
  33. package/src/components/GSignIn.vue +166 -0
  34. package/src/components/Gmaps.vue +35 -11
  35. package/src/components/Grid.vue +24 -20
  36. package/src/components/HTMLEditor.vue +258 -79
  37. package/src/components/IconMenu.vue +95 -0
  38. package/src/components/IconMenu2.vue +89 -0
  39. package/src/components/IconPlus.vue +89 -0
  40. package/src/components/Image.vue +161 -59
  41. package/src/components/Image360.vue +2 -2
  42. package/src/components/ImagePreview.vue +23 -11
  43. package/src/components/ImportModal.vue +27 -14
  44. package/src/components/Link.vue +39 -0
  45. package/src/components/List.vue +1177 -0
  46. package/src/components/ListItem.vue +32 -21
  47. package/src/components/ListPage1.vue +88 -17
  48. package/src/components/ListPage1Filter.vue +2 -2
  49. package/src/components/ListView.vue +962 -0
  50. package/src/components/ListViewBarSummary.vue +81 -0
  51. package/src/components/ListViewLineSummary.vue +75 -0
  52. package/src/components/ListViewLiveBarSummary.vue +52 -0
  53. package/src/components/ListViewMapSummary.vue +56 -0
  54. package/src/components/ListViewSettings.vue +514 -0
  55. package/src/components/ListViewTableSummary.vue +77 -0
  56. package/src/components/LogViewerItem.vue +116 -0
  57. package/src/components/Modal.vue +274 -122
  58. package/src/components/MultilineText.vue +177 -0
  59. package/src/components/OTPField.vue +5 -6
  60. package/src/components/ObjectTree.vue +105 -0
  61. package/src/components/PageBuilder.vue +449 -0
  62. package/src/components/Paragraph.vue +41 -0
  63. package/src/components/PresetSelectorFilterItem.vue +178 -0
  64. package/src/components/Radio.vue +62 -87
  65. package/src/components/SearchButton.vue +1 -1
  66. package/src/components/Slider.vue +107 -75
  67. package/src/components/Svg.vue +33 -0
  68. package/src/components/Switch.vue +15 -5
  69. package/src/components/TabView.vue +0 -1
  70. package/src/components/Table.vue +56 -0
  71. package/src/components/TableViewHead.vue +2 -2
  72. package/src/components/Tabs.vue +68 -11
  73. package/src/components/Test.vue +23 -0
  74. package/src/components/Testimonial.vue +86 -0
  75. package/src/components/Text.vue +49 -0
  76. package/src/components/TextBlock.vue +50 -0
  77. package/src/components/TextWithTag.vue +225 -0
  78. package/src/components/Textarea.vue +22 -16
  79. package/src/components/Textbox.vue +83 -62
  80. package/src/components/Thumbnail.vue +27 -0
  81. package/src/components/Timepicker.vue +15 -8
  82. package/src/components/Toast.vue +60 -38
  83. package/src/components/TreeView.vue +101 -0
  84. package/src/components/TreeViewItem.vue +424 -0
  85. package/src/components/TreeViewItem1.vue +282 -0
  86. package/src/components/VirtualGrid.vue +284 -0
  87. package/src/components/VirtualScroll.vue +88 -21
  88. package/src/components/VirtualTable.vue +277 -71
  89. package/src/components/YoutubeVideo.vue +196 -0
  90. package/src/configs/icons-fa.json +12 -0
  91. package/src/events/event.js +2 -0
  92. package/src/index.js +477 -53
  93. package/src/main.js +0 -9
  94. package/src/middleware/http/trim-string.js +20 -0
  95. package/src/mixin/component.js +222 -0
  96. package/src/mixin/website.js +121 -0
  97. package/src/stores/components.js +36 -0
  98. package/src/themes/default/index.js +178 -34
  99. package/src/utils/helpers.js +378 -7
  100. package/src/utils/helpers.mjs +274 -16
  101. package/src/utils/importer.js +60 -26
  102. package/src/utils/listpage1.js +403 -267
  103. package/src/utils/listview.js +1287 -0
  104. package/src/utils/preset-selector.js +1055 -0
  105. package/src/utils/preset-selector.mjs +185 -0
  106. package/src/utils/selection.js +15 -36
  107. package/src/utils/web.js +50 -0
  108. package/src/utils/wss.js +294 -0
  109. package/src/utils/wss.mjs +280 -0
  110. package/src/widgets/AhrefSetting.vue +94 -0
  111. package/src/widgets/ArticleSetting.vue +469 -0
  112. package/src/widgets/BackgroundSetting.vue +132 -0
  113. package/src/widgets/BlockSetting.vue +49 -0
  114. package/src/widgets/BorderSetting.vue +201 -0
  115. package/src/widgets/BoxSetting.vue +53 -0
  116. package/src/widgets/ButtonSetting.vue +114 -0
  117. package/src/widgets/CarouselSetting.vue +193 -0
  118. package/src/widgets/ColumnSelector.vue +80 -0
  119. package/src/widgets/ComponentPropertyLabel.vue +35 -0
  120. package/src/widgets/ComponentPropertySelector.vue +115 -0
  121. package/src/widgets/ComponentSetting.vue +2220 -0
  122. package/src/widgets/ComponentSetting2.vue +1018 -0
  123. package/src/widgets/ComponentSetting3.vue +231 -0
  124. package/src/widgets/ContactForm.vue +193 -0
  125. package/src/widgets/ContactFormSetting.vue +384 -0
  126. package/src/widgets/CountdownSetting.vue +76 -0
  127. package/src/widgets/DataListSetting.vue +102 -0
  128. package/src/widgets/EffectSetting.vue +94 -0
  129. package/src/widgets/EmbeddedVideo.vue +60 -0
  130. package/src/widgets/EmbeddedVideoSetting.vue +48 -0
  131. package/src/widgets/FAQ.vue +85 -0
  132. package/src/widgets/FAQSetting.vue +88 -0
  133. package/src/widgets/FeatureList.vue +128 -0
  134. package/src/widgets/FeatureListSetting.vue +223 -0
  135. package/src/widgets/FiltersSetting.vue +88 -0
  136. package/src/widgets/FlexSetting.vue +197 -0
  137. package/src/widgets/GridSetting.vue +290 -0
  138. package/src/widgets/Header.vue +15 -0
  139. package/src/widgets/Header1.vue +41 -0
  140. package/src/widgets/Header1Setting.vue +75 -0
  141. package/src/widgets/Header2.vue +102 -0
  142. package/src/widgets/Header2Setting.vue +277 -0
  143. package/src/widgets/HeaderSetting.vue +104 -0
  144. package/src/widgets/IconList.vue +51 -0
  145. package/src/widgets/IconListSetting.vue +184 -0
  146. package/src/widgets/ImageSetting.vue +146 -0
  147. package/src/widgets/LayoutSetting.vue +251 -0
  148. package/src/widgets/LinkSetting.vue +186 -0
  149. package/src/widgets/LogViewer.vue +85 -0
  150. package/src/widgets/MarginPaddingSetting.vue +58 -0
  151. package/src/widgets/MarginSetting.vue +142 -0
  152. package/src/widgets/MenuEditor.vue +256 -0
  153. package/src/widgets/MobileMenu.vue +182 -0
  154. package/src/widgets/ModalSetting.vue +96 -0
  155. package/src/widgets/MultiValueSetting.vue +121 -0
  156. package/src/widgets/MultiValueSetting2.vue +114 -0
  157. package/src/widgets/PaddingSetting.vue +142 -0
  158. package/src/widgets/ParagraphSetting.vue +86 -0
  159. package/src/widgets/PresetBar.vue +880 -0
  160. package/src/widgets/PresetBarPivotColumnEdit.vue +197 -0
  161. package/src/widgets/PresetSelector.vue +673 -0
  162. package/src/widgets/Review.vue +131 -0
  163. package/src/widgets/ReviewSetting.vue +201 -0
  164. package/src/widgets/Share.vue +165 -0
  165. package/src/widgets/ShareSetting.vue +92 -0
  166. package/src/widgets/SizingSetting.vue +306 -0
  167. package/src/widgets/SpacingSetting.vue +77 -0
  168. package/src/widgets/StyleSetting.vue +328 -0
  169. package/src/widgets/StyleSetting2.vue +90 -0
  170. package/src/widgets/SvgSetting.vue +133 -0
  171. package/src/widgets/TableSetting.vue +172 -0
  172. package/src/widgets/TestimonialSetting.vue +152 -0
  173. package/src/widgets/TextBlockSetting.vue +78 -0
  174. package/src/widgets/ThumbnailSetting.vue +49 -0
  175. package/src/widgets/TransitionSetting.vue +64 -0
  176. package/src/widgets/TypographySetting.vue +334 -0
  177. package/src/widgets/UserActionBuilder/UserActionItem.vue +165 -0
  178. package/src/widgets/UserActionBuilder/UserActionOutput.vue +126 -0
  179. package/src/widgets/UserActionBuilder.vue +457 -0
  180. package/src/widgets/WebComponentSelector.vue +201 -0
  181. package/src/widgets/WebDatasourceSelector.vue +153 -0
  182. package/src/widgets/WebLayoutSelector.vue +376 -0
  183. package/src/widgets/WebPageBuilder.vue +1849 -0
  184. package/src/widgets/WebPageBuilder2.vue +1091 -0
  185. package/src/widgets/WebPageBuilder3.vue +411 -0
  186. package/src/widgets/WebPageBuilder4/ActionSetting.vue +158 -0
  187. package/src/widgets/WebPageBuilder4/BackgroundColorSetting.vue +54 -0
  188. package/src/widgets/WebPageBuilder4/BackgroundPositionSetting.vue +75 -0
  189. package/src/widgets/WebPageBuilder4/BackgroundRepeatSetting.vue +72 -0
  190. package/src/widgets/WebPageBuilder4/BackgroundSizeSetting.vue +72 -0
  191. package/src/widgets/WebPageBuilder4/BlurSetting.vue +72 -0
  192. package/src/widgets/WebPageBuilder4/BorderColorSetting.vue +64 -0
  193. package/src/widgets/WebPageBuilder4/BorderRadiusSetting.vue +75 -0
  194. package/src/widgets/WebPageBuilder4/BorderSizeSetting.vue +69 -0
  195. package/src/widgets/WebPageBuilder4/BorderStyleSetting.vue +72 -0
  196. package/src/widgets/WebPageBuilder4/BoxShadowSetting.vue +73 -0
  197. package/src/widgets/WebPageBuilder4/ButtonSetting.vue +73 -0
  198. package/src/widgets/WebPageBuilder4/CarouselSetting.vue +122 -0
  199. package/src/widgets/WebPageBuilder4/ColorSetting.vue +63 -0
  200. package/src/widgets/WebPageBuilder4/DataSetting.vue +92 -0
  201. package/src/widgets/WebPageBuilder4/DisplaySetting.vue +76 -0
  202. package/src/widgets/WebPageBuilder4/FlexAlignSetting.vue +71 -0
  203. package/src/widgets/WebPageBuilder4/FlexDirectionSetting.vue +70 -0
  204. package/src/widgets/WebPageBuilder4/FlexJustifySetting.vue +74 -0
  205. package/src/widgets/WebPageBuilder4/FlexPropertySetting.vue +71 -0
  206. package/src/widgets/WebPageBuilder4/FlexSetting.vue +105 -0
  207. package/src/widgets/WebPageBuilder4/FlexWrapSetting.vue +69 -0
  208. package/src/widgets/WebPageBuilder4/FontSizeSetting.vue +76 -0
  209. package/src/widgets/WebPageBuilder4/GapSetting.vue +75 -0
  210. package/src/widgets/WebPageBuilder4/GrayscaleSetting.vue +68 -0
  211. package/src/widgets/WebPageBuilder4/GridSetting.vue +166 -0
  212. package/src/widgets/WebPageBuilder4/HeightSetting.vue +95 -0
  213. package/src/widgets/WebPageBuilder4/ImageSetting.vue +102 -0
  214. package/src/widgets/WebPageBuilder4/LinkSetting.vue +68 -0
  215. package/src/widgets/WebPageBuilder4/MarginSetting.vue +70 -0
  216. package/src/widgets/WebPageBuilder4/MaxHeightSetting.vue +82 -0
  217. package/src/widgets/WebPageBuilder4/MaxWidthSetting.vue +90 -0
  218. package/src/widgets/WebPageBuilder4/MinHeightSetting.vue +81 -0
  219. package/src/widgets/WebPageBuilder4/MinWidthSetting.vue +101 -0
  220. package/src/widgets/WebPageBuilder4/MobileMenuSetting.vue +106 -0
  221. package/src/widgets/WebPageBuilder4/MultiValueSetting.vue +155 -0
  222. package/src/widgets/WebPageBuilder4/OpacitySetting.vue +77 -0
  223. package/src/widgets/WebPageBuilder4/OverflowSetting.vue +81 -0
  224. package/src/widgets/WebPageBuilder4/PaddingSetting.vue +53 -0
  225. package/src/widgets/WebPageBuilder4/PositionSetting.vue +191 -0
  226. package/src/widgets/WebPageBuilder4/PropertySetting.vue +183 -0
  227. package/src/widgets/WebPageBuilder4/Setting.vue +73 -0
  228. package/src/widgets/WebPageBuilder4/StyleSetting.vue +77 -0
  229. package/src/widgets/WebPageBuilder4/SvgSetting.vue +207 -0
  230. package/src/widgets/WebPageBuilder4/TextSetting.vue +72 -0
  231. package/src/widgets/WebPageBuilder4/TextTransformSetting.vue +70 -0
  232. package/src/widgets/WebPageBuilder4/TreeView.vue +43 -0
  233. package/src/widgets/WebPageBuilder4/TreeViewItem.vue +329 -0
  234. package/src/widgets/WebPageBuilder4/WebPageComponentSelector.vue +147 -0
  235. package/src/widgets/WebPageBuilder4/WebPageDataEdit.vue +121 -0
  236. package/src/widgets/WebPageBuilder4/WebPagePropertySelector.vue +172 -0
  237. package/src/widgets/WebPageBuilder4/WidthSetting.vue +105 -0
  238. package/src/widgets/WebPageBuilder4/ZIndexSetting.vue +72 -0
  239. package/src/widgets/WebPageBuilder4.vue +1084 -0
  240. package/src/widgets/WebPagePreview.vue +295 -0
  241. package/src/widgets/WebPageSelector.vue +173 -0
  242. package/src/widgets/WebTemplateCreator.vue +156 -0
  243. package/src/widgets/YoutubeVideoSetting.vue +65 -0
  244. package/tailwind.config.js +513 -0
  245. package/test.json +22 -0
  246. package/public/images/mixd-logo2.png +0 -0
  247. package/src/components/ButtonGroup.vue +0 -101
  248. package/src/components/DynamicTemplate.vue +0 -44
  249. package/src/components/GridColumn.vue +0 -31
@@ -1,43 +1,31 @@
1
1
  <template>
2
- <div :class="$style.carousel" @mousedown.prevent.capture="mouseDown" @touchstart.passive.capture="mouseDown">
3
- <div :class="$style.inner">
4
- <span v-if="images && images.length && images.length > 0" v-for="image in images" :key="image">
5
- <a v-if="image.target && image.target.indexOf('://') >= 0" :href="image.target" @click="checkClick">
6
- <Image :src="image.imageUrl" :class="imageClass" />
7
- </a>
8
- <router-link v-if="image.target" :to="scrolling ? '' : image.target">
9
- <Image :src="image.imageUrl" :class="imageClass"/>
10
- </router-link>
11
- <Image v-else :src="image.imageUrl" :class="imageClass" />
12
- </span>
13
- <div v-else :class="imageClass" class="bg-gray-200 animate-pulse"></div>
2
+ <div :class="$style.comp"
3
+ @mousedown="mouseDown"
4
+ @touchstart.passive="mouseDown"
5
+ :style="computedStyle">
6
+
7
+ <div ref="inner" :class="computedContainerClass">
8
+ <div v-for="item in cItems" :class="computedItemClass">
9
+ <slot v-if="$slots['default']" :item="item"></slot>
10
+ <component v-else :is="item.type" :="item" />
11
+ </div>
14
12
  </div>
15
- <div v-if="images && images.length > 1" class="carousel-next" @click="next(false, true)">
16
- <slot name="next">
17
- <div class="w-10 h-10 rounded-full bg-black/10 hover:bg-black/60 group cursor-pointer flex items-center justify-center">
18
- <svg width="24" height="24" viewBox="0 0 24 24" class="fill-white/30 group-hover:fill-white/60" xmlns="http://www.w3.org/2000/svg">
19
- <g clip-path="url(#clip0)">
20
- <path fill-rule="evenodd" clip-rule="evenodd" d="M8.04289 19.2071C7.65237 18.8166 7.65237 18.1834 8.04289 17.7929L13.8358 12L8.04289 6.20711C7.65237 5.81658 7.65237 5.18342 8.04289 4.79289C8.43342 4.40237 9.06658 4.40237 9.45711 4.79289L15.25 10.5858C16.031 11.3668 16.031 12.6332 15.25 13.4142L9.45711 19.2071C9.06658 19.5976 8.43342 19.5976 8.04289 19.2071Z"/>
21
- </g>
22
- </svg>
23
- </div>
24
- </slot>
13
+
14
+ <div v-if="cItems && cItems.length > 1" :class="$style.carouselNext" @click="next(true)">
15
+ <slot name="next"></slot>
25
16
  </div>
26
- <div v-if="images && images.length > 1" class="carousel-prev" @click="prev">
17
+
18
+ <div v-if="cItems && cItems.length > 1" :class="$style.carouselPrev" @click="prev">
27
19
  <slot name="prev">
28
- <div class="w-10 h-10 rounded-full bg-black/10 cursor-pointer flex items-center justify-center">
29
- <svg width="24" height="24" viewBox="0 0 24 24" class="fill-white/30" xmlns="http://www.w3.org/2000/svg">
30
- <path fill-rule="evenodd" clip-rule="evenodd" d="M15.7071 19.2071C16.0976 18.8166 16.0976 18.1834 15.7071 17.7929L9.91421 12L15.7071 6.20711C16.0976 5.81658 16.0976 5.18342 15.7071 4.79289C15.3166 4.40237 14.6834 4.40237 14.2929 4.79289L8.5 10.5858C7.71895 11.3668 7.71895 12.6332 8.5 13.4142L14.2929 19.2071C14.6834 19.5976 15.3166 19.5976 15.7071 19.2071Z"/>
31
- </svg>
32
- </div>
33
20
  </slot>
34
21
  </div>
35
- <div v-if="images && images.length > 1" class="carousel-legend">
36
- <div v-if="images && images.length && images.length > 0" v-for="_index in images.length"
37
- :class="'legend-item ' + (index === _index - 1 ? 'active' : '')" :key="_index"
22
+
23
+ <div v-if="useLegend && cItems && cItems.length > 1" :class="$style.legend">
24
+ <div v-for="_index in cItems.length"
25
+ :class="$style.legendItem + (index === _index - 1 ? ` ${$style.legendItemActive}` : '')"
38
26
  @click="index = _index - 1">
39
27
  <slot name="legend">
40
- <span></span>
28
+ <div></div>
41
29
  </slot>
42
30
  </div>
43
31
  </div>
@@ -46,82 +34,126 @@
46
34
 
47
35
  <script>
48
36
 
49
- import { parseBoolean } from "../utils/helpers.mjs";
37
+ import {componentMixin} from "../mixin/component";
50
38
 
51
39
  export default{
52
40
 
53
- props:{
41
+ computed: {
42
+
43
+ cItems(){
44
+
45
+ if(!this.dataKey)
46
+ return this.items
47
+
48
+ const page = this.getPage()
49
+ const obj = page.data?.find(_ => _.key === this.dataKey)
50
+ return obj ?
51
+ obj.value.map(_ => ({
52
+ ...this.items[0],
53
+ data: _
54
+ })) :
55
+ []
56
+ },
54
57
 
55
- images: {
56
- type: Array,
57
- default: []
58
+ computedContainerClass(){
59
+ return [
60
+ this.$style.inner,
61
+ this.containerClass
62
+ ]
63
+ .filter(_ => _)
64
+ .join(' ')
58
65
  },
59
66
 
67
+ computedItemClass(){
68
+ return [
69
+ this.$style.item,
70
+ this.itemClass
71
+ ]
72
+ .filter(_ => _)
73
+ .join(' ')
74
+ }
75
+
76
+ },
77
+
78
+ mixins: [ componentMixin ],
79
+
80
+ props:{
81
+
82
+ data: Object,
83
+
84
+ dataKey: String,
85
+
86
+ items: Array,
87
+
60
88
  infinite: {
61
- type: [ Boolean, String, Number ],
89
+ type: undefined,
62
90
  default: false
63
91
  },
64
92
 
65
- ratioMobile: String,
66
- ratioDesktop: String,
93
+ ratio: Array,
67
94
 
68
- imageClass:{
69
- type: String,
70
- default: "w-full"
71
- }
95
+ autoPlay: [ Number, String ],
72
96
 
73
- },
97
+ useLegend: [ Boolean, Number ],
74
98
 
75
- emits: [ 'changed' ],
76
-
77
- computed: {
99
+ },
78
100
 
79
- },
101
+ emits: [ 'change' ],
80
102
 
81
103
  data(){
82
104
  return {
83
- count: 0,
84
105
  index: 0,
85
- scrolling:0
106
+ timeoutId: null,
107
+ scrollPosition: null,
108
+ swiping: false,
86
109
  }
87
110
  },
88
111
 
89
112
  mounted(){
90
- this.count = this.$el.querySelectorAll('img').length
113
+ window.addEventListener('touchmove', this.onTouchMove, { passive: false });
114
+ if(this.autoPlay > 0)
115
+ this.play()
116
+ },
117
+
118
+ unmounted() {
119
+ window.removeEventListener('touchmove', this.onTouchMove, { passive: false });
91
120
  },
92
121
 
93
122
  watch:{
94
123
 
95
- index(to, from){
96
- this.setPosition()
97
- this.$emit('changed', to)
124
+ index(to){
125
+ this.$emit('change', to)
98
126
  },
99
127
 
100
- images(to){
128
+ items(){
101
129
  this.index = 0
102
- }
130
+ },
103
131
 
104
132
  },
105
133
 
106
134
  methods:{
107
135
 
108
- checkClick(e){
109
- if(this.scrolling){
110
- e.preventDefault()
111
- e.stopPropagation()
136
+ onTouchMove(e){
137
+ if(this.swiping && e.cancelable) {
138
+ e.preventDefault();
139
+ e.returnValue = false;
140
+ return false;
112
141
  }
113
142
  },
114
143
 
115
- setPosition(noAnimation){
144
+ setPosition(noAnimation) {
145
+ if(!this.$refs.inner) return
116
146
 
117
- const index = this.index
147
+ const index = this.index
148
+ let left = 0
149
+ const gapPx = parseInt(window.getComputedStyle(this.$refs.inner).getPropertyValue('column-gap'))
150
+ for(let curIndex = 0 ; curIndex < this.cItems.length ; curIndex++){
151
+ const item = this.$refs.inner.children[curIndex]
152
+ if(curIndex < index)
153
+ left += (item.clientWidth + (!isNaN(gapPx) ? gapPx : 0))
154
+ }
118
155
 
119
- let left = 0
120
- this.$el.querySelectorAll('img').forEach((img, curIndex) => {
121
- if(curIndex < index)
122
- left += img.clientWidth
123
- })
124
- left *= -1
156
+ left *= -1
125
157
 
126
158
  if(!noAnimation){
127
159
  this.$el.firstElementChild.addEventListener('transitionend', function(){
@@ -130,22 +162,30 @@ export default{
130
162
  this.$el.firstElementChild.classList.add('transition-carousel')
131
163
  }
132
164
 
133
- this.$el.firstElementChild.style.transform = `translate3d(${left}px, 0, 0)`
134
- },
165
+ window.requestAnimationFrame(() => {
166
+ this.$el.firstElementChild.style.transform = `translate3d(${left}px, 0, 0)`
167
+ })
168
+ },
135
169
 
136
- next(setPosition, useBack){
170
+ setIndex(index){
171
+ if(index >= 0 && index < this.cItems.length){
172
+ this.index = index
173
+ this.setPosition()
174
+ }
175
+ },
137
176
 
177
+ next(useBack){
138
178
  let index = this.index + 1
139
179
 
140
- if(index >= this._props['count'])
141
- index = typeof useBack !== 'undefined' && useBack === true && parseBoolean(this.infinite) ? 0 : this._props['count'] - 1
180
+ if(index >= this.cItems.length)
181
+ index = useBack === true ? 0 : this.cItems.length - 1
142
182
 
143
183
  this.index = index
144
184
 
145
- if(setPosition) this.setPosition()
185
+ this.setPosition()
146
186
  },
147
187
 
148
- prev(setPosition){
188
+ prev(){
149
189
 
150
190
  let index = this.index - 1;
151
191
 
@@ -153,44 +193,68 @@ export default{
153
193
 
154
194
  this.index = index
155
195
 
156
- if(setPosition) this.setPosition()
196
+ this.setPosition()
157
197
  },
158
198
 
159
- mouseMove(e){
199
+ play(){
200
+ if(this.autoPlay > 0)
201
+ this.timeoutId = window.setTimeout(() => { this.next(true); this.play() }, this.autoPlay)
202
+ },
160
203
 
161
- this.scrolling = true
204
+ stop(){
205
+ if(this.timeoutId)
206
+ window.clearTimeout(this.timeoutId)
207
+ },
162
208
 
209
+ mouseMove(e){
163
210
  const sx = typeof e.touches !== 'undefined' ? e.touches[0].clientX : e.clientX
211
+ const sy = typeof e.touches !== 'undefined' ? e.touches[0].clientY : e.clientY
164
212
  const dx = sx - this._props['sx']
165
- const ix = parseInt(this._props['ix'] + dx)
213
+ const dy = sy - this._props['sy']
214
+
215
+ if(!this._props['direction']){
216
+ if(Math.abs(dx) > 3){
217
+ this._props['direction'] = 'horizontal'
218
+ this.swiping = true
219
+ }
220
+ else if(Math.abs(dy) > 3){
221
+ this._props['direction'] = 'vertical'
222
+ }
223
+ }
224
+ else if(this._props['direction'] === 'horizontal'){
225
+ let ix
226
+ if((this.index === this.cItems.length - 1 && dx < 0) ||
227
+ (this.index === 0 && dx > 0)){
228
+ ix = parseInt(this._props['ix'] + (dx * .19812))
229
+ }
230
+ else{
231
+ ix = parseInt(this._props['ix'] + dx)
232
+ }
166
233
 
167
- //console.warn('mousemove', dx, ix)
234
+ this.$el.firstElementChild.style.transform = `translate3d(${ix}px, 0, 0)`
235
+ }
168
236
 
169
- this.$el.firstElementChild.style.transform = `translate3d(${ix}px, 0, 0)`
170
237
  },
171
238
 
172
239
  mouseUp(e){
173
-
174
- window.setTimeout(() => {
175
- this.scrolling = false
176
- }, 50)
177
-
178
- const tn = e.timeStamp - this._props['t0']
179
- const sx = typeof e.changedTouches !== 'undefined' ? e.changedTouches[0].clientX : e.clientX
180
- const dx = sx - this._props['sx']
181
-
182
- //console.warn('mouseup', tn, dx, dx)
183
-
184
- if (Math.abs(dx) > 10) {
185
- if (tn < 1200){
186
- dx < 0 ? this.next(true) : this.prev(true)
240
+ if(this._props['direction'] === 'horizontal'){
241
+ const tn = e.timeStamp - this._props['t0']
242
+ const sx = typeof e.changedTouches !== 'undefined' ? e.changedTouches[0].clientX : e.clientX
243
+ const dx = sx - this._props['sx']
244
+
245
+ if (Math.abs(dx) > 10) {
246
+ if (tn < 1200){
247
+ dx < 0 ? this.next() : this.prev()
248
+ }
249
+ else{
250
+ this.setPosition()
251
+ }
187
252
  }
188
253
  else{
189
254
  this.setPosition()
190
255
  }
191
- }
192
- else{
193
- this.setPosition()
256
+
257
+ this.swiping = false
194
258
  }
195
259
 
196
260
  window.removeEventListener('mousemove', this.mouseMove)
@@ -198,25 +262,28 @@ export default{
198
262
  window.removeEventListener('mouseout', this.mouseUp)
199
263
  window.removeEventListener('touchmove', this.mouseMove)
200
264
  window.removeEventListener('touchend', this.mouseUp)
265
+
266
+ if(this.autoPlay > 0)
267
+ this.play()
201
268
  },
202
269
 
203
270
  mouseDown(e){
204
-
205
- if(!this.images || this.images.length <= 1)
271
+ if(!this.cItems || this.cItems.length <= 1)
206
272
  return
207
273
 
274
+ this.stop()
275
+
208
276
  var matches = this.$el.firstElementChild.style.transform.match(/translate3d\((.*?)(?=\,)/)
209
277
  var ix = matches != null && typeof matches[1] != 'undefined' ? parseInt(matches[1].replace('px', '')) : 0
210
278
 
211
279
  this._props = {
212
280
  sx:typeof e.touches !== 'undefined' ? e.touches[0].clientX : e.clientX,
281
+ sy:typeof e.touches !== 'undefined' ? e.touches[0].clientY : e.clientY,
213
282
  ix:ix,
214
283
  t0:e.timeStamp,
215
- count: this.$el.querySelectorAll('img').length,
284
+ direction: null
216
285
  }
217
286
 
218
- //console.log('mousedown', this._props, this.count)
219
-
220
287
  window.addEventListener('mousemove', this.mouseMove)
221
288
  window.addEventListener('mouseup', this.mouseUp)
222
289
  window.addEventListener('mouseout', this.mouseUp)
@@ -250,44 +317,47 @@ export default{
250
317
 
251
318
  <style module>
252
319
 
253
- .carousel{
320
+ .comp{
254
321
  white-space: nowrap;
255
322
  overflow: hidden;
256
323
  position: relative;
257
- touch-action: none;
324
+ }
325
+
326
+ .comp img{
327
+ pointer-events: none;
328
+ }
329
+
330
+ .carouselNext{
331
+ @apply absolute top-0 bottom-0 right-0 w-[20px];
332
+ }
333
+
334
+ .carouselPrev{
335
+ @apply absolute top-0 bottom-0 left-0 w-[20px];
258
336
  }
259
337
 
260
338
  .inner{
261
339
  white-space: nowrap;
262
340
  will-change: transform;
263
- touch-action: none;
341
+ @apply flex flex-row items-stretch;
264
342
  }
265
343
  .inner>*{
266
344
  display: inline-block;
267
345
  width: 100%;
268
- touch-action: none;
346
+ min-width: 100%;
269
347
  vertical-align: top;
270
348
  }
271
349
 
272
350
  .legend{
273
- position: absolute;
274
- bottom: 6px;
275
- left: 50%;
276
- transform: translate3d(-50%, 0, 0);
351
+ @apply flex justify-center gap-2 py-1;
277
352
  }
278
- .legend .legend-item{
279
- display: inline-block;
353
+ .legend .legendItem{
280
354
  }
281
- .legend .legend-item>*{
282
- width: 12px;
283
- height: 12px;
284
- border-radius: 100%;
285
- background: rgba(0, 0, 0, .2);
286
- margin: 0 3px;
287
- display: inline-block;
355
+ .legend .legendItem>*{
356
+ @apply w-2 h-2 rounded-full bg-gray-100;
288
357
  }
289
- .legend .legend-item.active>*{
290
- background: rgba(0, 0, 0, .6);
358
+ .legend .legendItemActive>*{
359
+ @apply bg-primary-500;
291
360
  }
292
361
 
293
- </style>
362
+
363
+ </style>