@mixd-id/web-scaffold 0.1.240411018 → 0.1.240411020

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.240411018",
4
+ "version": "0.1.240411020",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -10,7 +10,7 @@
10
10
 
11
11
  <script>
12
12
 
13
- import { componentMixin } from '../mixin/component';
13
+ import {componentMixin} from '../mixin/component';
14
14
  import {getSelection, restoreSelection, saveSelection} from "../utils/selection";
15
15
 
16
16
  export default{
@@ -37,8 +37,8 @@
37
37
 
38
38
  <script>
39
39
 
40
- import { componentMixin } from "../mixin/component";
41
- import { applyDatasourceReplacer } from "../utils/helpers";
40
+ import {componentMixin} from "../mixin/component";
41
+ import {applyDatasourceReplacer} from "../utils/helpers";
42
42
 
43
43
  export default{
44
44
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  <script setup>
12
12
 
13
- import { defineComponent } from "vue";
13
+ import {defineComponent} from "vue";
14
14
  import {componentMixin} from "../mixin/component";
15
15
 
16
16
  defineComponent({
@@ -22,7 +22,6 @@
22
22
  <script>
23
23
 
24
24
  import TreeViewItem from "./TreeViewItem.vue";
25
- import {copyToClipboard, getClipboardData} from "../utils/helpers.mjs";
26
25
 
27
26
  export default{
28
27
 
@@ -1,7 +1,27 @@
1
1
  import {inject} from 'vue'
2
- import {parseBoolean} from "../utils/helpers.mjs";
3
2
 
4
- let guide
3
+ let guide, guide2
4
+ let selectedUid
5
+
6
+ function scrollIntoViewIfNeededWithOffset(elem, offset = 100) {
7
+ const rect = elem.getBoundingClientRect();
8
+
9
+ const isVisible = (
10
+ rect.top >= 0 &&
11
+ rect.bottom <= (window.innerHeight || document.documentElement.clientHeight)
12
+ );
13
+
14
+ if (!isVisible) {
15
+ const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
16
+ const targetScroll = rect.top + scrollTop - offset;
17
+
18
+ window.scrollTo({
19
+ top: targetScroll,
20
+ behavior: 'smooth'
21
+ });
22
+ }
23
+ }
24
+
5
25
 
6
26
  export const componentMixin = {
7
27
 
@@ -165,7 +185,10 @@ export const componentMixin = {
165
185
  e.stopPropagation()
166
186
  e.preventDefault()
167
187
 
188
+ selectedUid = this.uid
189
+
168
190
  this.editModeClick ? this.editModeClick(this.uid) : null
191
+ this.select2()
169
192
  },
170
193
 
171
194
  componentMouseOver(e){
@@ -174,15 +197,22 @@ export const componentMixin = {
174
197
  e.stopPropagation()
175
198
  e.preventDefault()
176
199
 
177
- this.lastStyle.position = this.$el.style.position
178
- this.$el.style.position = 'relative'
200
+ const offset = this.$el.getBoundingClientRect()
201
+ const top = offset.top + window.scrollY + 1
202
+ const left = offset.left + window.scrollX + 1
203
+ const width = offset.width - 2
204
+ const height = offset.height - 2
179
205
 
180
- this.$el.appendChild(this.getGuide())
206
+ const guide = this.getGuide()
207
+ guide.style.top = `${top}px`
208
+ guide.style.left = `${left}px`
209
+ guide.style.width = `${width}px`
210
+ guide.style.height = `${height}px`
211
+ document.body.appendChild(guide)
181
212
  },
182
213
 
183
214
  componentMouseOut(){
184
215
  if(this.editMode !== 1) return
185
- this.$el.style.position = this.lastStyle.position
186
216
 
187
217
  const guide = this.getGuide()
188
218
  if(guide.parentNode){
@@ -193,22 +223,64 @@ export const componentMixin = {
193
223
  getGuide(){
194
224
  if(!guide){
195
225
  guide = document.createElement('div')
196
- guide.className = "absolute top-0 left-0 right-0 bottom-0 border-[3px] border-blue-600" +
226
+ guide.className = "absolute border-[2px] border-blue-600" +
197
227
  " pointer-events-none"
198
228
  }
199
229
 
200
230
  return guide
201
231
  },
202
232
 
233
+ getGuide2(){
234
+ if(!guide2){
235
+ console.log('create')
236
+ guide2 = document.createElement('div')
237
+ guide2.className = "absolute border-[2px] border-blue-600 pointer-events-none"
238
+ }
239
+
240
+ return guide2
241
+ },
242
+
203
243
  select(){
244
+ const offset = this.$el.getBoundingClientRect()
245
+ const top = offset.top + window.scrollY + 1
246
+ const left = offset.left + window.scrollX + 1
247
+ const width = offset.width - 2
248
+ const height = offset.height - 2
249
+
250
+ const guide = this.getGuide2()
251
+ guide.style.top = `${top}px`
252
+ guide.style.left = `${left}px`
253
+ guide.style.width = `${width}px`
254
+ guide.style.height = `${height}px`
255
+ document.body.appendChild(guide)
256
+
257
+ scrollIntoViewIfNeededWithOffset(this.$el, 100)
204
258
  },
205
259
 
206
- },
260
+ select2(){
261
+ const offset = this.$el.getBoundingClientRect()
262
+ const top = offset.top + window.scrollY + 1
263
+ const left = offset.left + window.scrollX + 1
264
+ const width = offset.width - 2
265
+ const height = offset.height - 2
266
+
267
+ const guide = this.getGuide2()
268
+ guide.style.top = `${top}px`
269
+ guide.style.left = `${left}px`
270
+ guide.style.width = `${width}px`
271
+ guide.style.height = `${height}px`
272
+ document.body.appendChild(guide)
273
+ },
207
274
 
208
- data(){
209
- return {
210
- lastStyle: {}
275
+ imageSrc(url){
276
+ if(typeof url === 'string'){
277
+ if(url.indexOf('://') < 0 && url.substring(0, 1) !== '/'){
278
+ url = ((import.meta.env.VITE_IMAGE_HOST ?? '') + '/' + url)
279
+ }
280
+ }
281
+ return url
211
282
  }
283
+
212
284
  },
213
285
 
214
286
  mounted(){
@@ -287,6 +287,15 @@ export default{
287
287
  [ 'overflow-y-scroll', 'Y Scroll' ],
288
288
  ]},
289
289
 
290
+ { text:'Z Index', key:'zIndex', values: [
291
+ [ 'z-0', '0' ],
292
+ [ 'z-10', '10' ],
293
+ [ 'z-20', '20' ],
294
+ [ 'z-30', '30' ],
295
+ [ 'z-40', '40' ],
296
+ [ 'z-50', '50' ],
297
+ ]},
298
+
290
299
  ]},
291
300
 
292
301
  { text:'Flexbox & Grid', items: [
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div :class="$style.comp">
2
+ <div :class="$style.comp" :data-uid="uid">
3
3
  <strong v-if="title" class="mr-6">{{ title }}</strong>
4
4
 
5
5
  <div v-if="direction === 'vertical'" class="flex-1 flex flex-col divide-y divide-text-100 self-stretch">
@@ -110,7 +110,6 @@ export default{
110
110
  },
111
111
 
112
112
  waShareUrl(){
113
- if(typeof window === 'undefined') return
114
113
  return `https://wa.me/send?text=` + encodeURIComponent(this.currentUrl)
115
114
  },
116
115
 
@@ -558,7 +558,7 @@
558
558
 
559
559
  import throttle from "lodash/throttle";
560
560
  import md5 from "md5";
561
- import {copyToClipboard, createFormData, invokeAfterIdle} from "../utils/helpers.mjs";
561
+ import {createFormData, invokeAfterIdle} from "../utils/helpers.mjs";
562
562
  import {ref} from 'vue'
563
563
  import {useManualRefHistory} from "@vueuse/core";
564
564
  import axios from "axios";