renusify 1.4.2 → 1.4.3

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.
@@ -0,0 +1,172 @@
1
+ export default {
2
+ methods: {
3
+ pretty_html(text) {
4
+ text = text.replace(/ +(?= )/g, '');
5
+ text = text.replace(/[\r|\n|\t]/g, '');
6
+ let r = ''
7
+ text = text.split('<')
8
+ let numopen = 0
9
+ text.forEach((line) => {
10
+ if (line) {
11
+ const end = line.startsWith('/')
12
+ if (end) {
13
+ numopen -= 1
14
+ }
15
+ r += '\t'.repeat(numopen) + '<' + line + '\n'
16
+ if (!end) {
17
+ numopen += 1
18
+ }
19
+ }
20
+ })
21
+ return r
22
+ },
23
+ pretty_js(text) {
24
+ text = text.replace(/ +(?= )/g, '');
25
+ text = text.replace(/[\r|\n|\t]/g, '');
26
+ text = text.replace(/([,|;|{|(|\[])+[\s]/g, '$1');
27
+ let r = ''
28
+ text = text.split('')
29
+ let numopen = 0
30
+ const textLength = text.length
31
+ let inBracket = 0
32
+ let inprantez = 0
33
+ for (let i = 0; i < textLength; i++) {
34
+ const c = text[i]
35
+ const last = i > 0 ? text[i - 1] : ''
36
+ const next = i < textLength - 1 ? text[i + 1] : ''
37
+
38
+ if (c === '(') {
39
+ inprantez += 1
40
+ }
41
+ if (c === ')') {
42
+ inprantez -= 1
43
+ }
44
+ if (c === '[') {
45
+ inBracket += 1
46
+ }
47
+ if (c === ']') {
48
+ inBracket -= 1
49
+ }
50
+ if (c === '}') {
51
+ numopen -= 1
52
+ }
53
+ r += c
54
+ if (c === '}' && next !== ',' && next !== ';' && next !== '}' && next !== ')') {
55
+ r += '\n' + '\t'.repeat(numopen)
56
+ }
57
+ if (c === ',' && (!inprantez && !inBracket) && next !== '}') {
58
+ r += '\n' + '\t'.repeat(numopen)
59
+ }
60
+ if (c === ';' && next !== '}') {
61
+ r += '\n' + '\t'.repeat(numopen)
62
+ }
63
+ if (next === '}' && c !== '{') {
64
+ r += '\n' + '\t'.repeat(numopen - 1)
65
+ }
66
+
67
+ if (c === '{') {
68
+ numopen += 1
69
+ if (next !== '}') {
70
+ r += '\n' + '\t'.repeat(numopen)
71
+ }
72
+ }
73
+ }
74
+ r = r.replace(/\t /g, '\t');
75
+ r = r.replace(/^\s*\n/gm, '');
76
+ return r
77
+ },
78
+ setTab(event) {
79
+ if (event.key === "'" || event.key === '"' || event.key === '`') {
80
+ const end = event.target.selectionEnd;
81
+ event.preventDefault()
82
+ document.execCommand('insertText', false, event.key.repeat(2));
83
+ event.target.selectionEnd = end + 1;
84
+ return false;
85
+ }
86
+ if (event.key === "{") {
87
+ const end = event.target.selectionEnd;
88
+ event.preventDefault()
89
+ document.execCommand('insertText', false, '{}');
90
+ event.target.selectionEnd = end + 1;
91
+ return false;
92
+ }
93
+ if (event.key === "(") {
94
+ const end = event.target.selectionEnd;
95
+ event.preventDefault()
96
+ document.execCommand('insertText', false, '()');
97
+ event.target.selectionEnd = end + 1;
98
+ return false;
99
+ }
100
+ if (event.key === "[") {
101
+ const end = event.target.selectionEnd;
102
+ event.preventDefault()
103
+ document.execCommand('insertText', false, '[]');
104
+ event.target.selectionEnd = end + 1;
105
+ return false;
106
+ }
107
+ if (event.keyCode === 9) {
108
+ event.preventDefault()
109
+ document.execCommand('insertText', false, '\t');
110
+ return false;
111
+ }
112
+ if (event.keyCode === 13) {
113
+ event.preventDefault()
114
+ let n = event.target.value.substr(0, event.target.selectionStart).split('\n')
115
+ n = n[n.length - 1].split('')
116
+ let w = ''
117
+ for (let i = 0; i < n.length; i++) {
118
+ if (n[i] === ' ') {
119
+ w += ' '
120
+ } else {
121
+ break
122
+ }
123
+ }
124
+
125
+ document.execCommand('insertText', false, '\n' + w);
126
+ return false;
127
+ }
128
+ return true
129
+ },
130
+ re_quote(res) {
131
+ let regex = /"([^"]*)"/g;
132
+ res = res.replace(regex, '<span class="color-green code-editor-span">"$1"</span>');
133
+ regex = /'([^']*)'/g;
134
+ return res.replace(regex, "<span class=\"color-green code-editor-span\">'$1'</span>");
135
+ },
136
+ re_special(res, regex = /([{}\[\]])/g, color = "color-orange") {
137
+ return res.replace(regex, '<span class="' + color + ' code-editor-span">$1</span>')
138
+ },
139
+ re_number(res) {
140
+ return res.replace(/\b([0-9.]+)\b/g, '<span class="color-blue code-editor-span">$1</span>')
141
+ },
142
+ re_words(res, words) {
143
+ words.forEach((word) => {
144
+ res = res.replace(new RegExp("\\b(" + word + ")\\b", 'g'), '<span class="color-orange code-editor-span">$1</span>')
145
+ })
146
+
147
+ return res;
148
+ },
149
+ re_comment(res) {
150
+ //eslint-disable-next-line
151
+ let regex = /(\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*)$/gm;
152
+ return res.replace(regex, '<span class="color-comment code-editor-span">$1</span>')
153
+ },
154
+ re_func(res) {
155
+ //function like Date()
156
+ let regex = /([$a-zA-Z-0-9_\s]+)(?=\()/g;
157
+ res = res.replace(regex, '<span class="color-func2 code-editor-span">$1</span>')
158
+
159
+ // Object keys
160
+ regex = /([a-zA-Z-0-9_]+)(?=:)/g;
161
+ res = res.replace(regex, '<span class="color-purple code-editor-span">$1</span>')
162
+
163
+
164
+ //function like $r $d()
165
+ regex = /(\$([a-zA-z0-9]*)[.|(])/g;
166
+ res = res.replace(regex, '<span class="color-func code-editor-span">$1</span>')
167
+
168
+
169
+ return res;
170
+ },
171
+ }
172
+ }
@@ -61,6 +61,7 @@ export default {
61
61
  getBlob: Boolean,
62
62
  selectImg: {type: Boolean, default: true},
63
63
  },
64
+ emits: ['cropped', 'original'],
64
65
  data() {
65
66
  return {
66
67
  show: false,
@@ -172,7 +173,7 @@ export default {
172
173
  that.crop(e.target.result);
173
174
  };
174
175
 
175
- this.$emit("orginal", e.target.files[0]);
176
+ this.$emit("original", e.target.files[0]);
176
177
  reader.readAsDataURL(e.target.files[0]);
177
178
  },
178
179
  getDataURL() {
@@ -52,23 +52,29 @@
52
52
  <r-btn @click.prevent="add" class="ms-1 color-success" rounded>{{ $t('add', 'renusify') }}</r-btn>
53
53
  </div>
54
54
  </div>
55
- <textarea v-else :class="{'state-error':error}"
56
- :rows="modelValue?Object.keys(modelValue).length+5:5"
57
- autocapitalize="off"
58
- autocomplete="off"
59
- autocorrect="off"
60
- class="ltr w-full"
61
- spellcheck="false"
62
- @input="emitt"
63
- @keydown="setTab">{{ JSON.stringify(modelValue||{}, null, 4) }}</textarea>
55
+ <div v-else :class="{'state-error':error}" class="json-highlight ltr">
56
+ <textarea
57
+ v-model="lazyValue"
58
+ autocapitalize="off"
59
+ autocomplete="off"
60
+ autocorrect="off"
61
+ class="ltr w-full"
62
+ spellcheck="false"
63
+ :rows="modelValue?Object.keys(modelValue).length+5:5"
64
+ @keydown="setTab"
65
+ ></textarea>
66
+ <div class="text-preview" v-html="build"></div>
67
+ </div>
64
68
  </div>
65
69
  </template>
66
70
  <script>
67
71
  import JsonView from "./JsonView";
72
+ import mixin from 'renusify/components/codeEditor/mixin'
68
73
 
69
74
  export default {
70
75
  name: 'r-json',
71
76
  components: {JsonView},
77
+ mixins: [mixin],
72
78
  props: {
73
79
  label: String,
74
80
  keyLabel: {type: String, default: 'key'},
@@ -93,14 +99,49 @@ export default {
93
99
  emits: ['update:modelValue'],
94
100
  data() {
95
101
  return {
102
+ lazyValue: '',
96
103
  modeForm: true,
97
104
  error: false,
98
105
  show: false,
99
- info: {},
100
- color: `rgb(${this.$helper.randomInt(0, 255)},${this.$helper.randomInt(0, 255)},${this.$helper.randomInt(0, 255)})`
106
+ info: {}
101
107
  }
102
108
  },
109
+ watch: {
110
+ modeForm: function () {
111
+ this.lazyValue = JSON.stringify(this.modelValue || {}, null, 4)
112
+ },
113
+ modelValue: function () {
114
+ try {
115
+ this.error = false
116
+ if (JSON.stringify(JSON.parse(this.lazyValue)) !== JSON.stringify(this.modelValue)) {
117
+ this.lazyValue = JSON.stringify(this.modelValue || {}, null, 4)
118
+ }
119
+ } catch (er) {
120
+ this.error = true
121
+ }
122
+
123
+ },
124
+ lazyValue: function () {
125
+ try {
126
+ this.error = false
127
+ this.$emit('update:modelValue', JSON.parse(this.lazyValue))
128
+ } catch (er) {
129
+ this.error = true
130
+ }
131
+ },
132
+ },
103
133
  computed: {
134
+ build() {
135
+ if (!this.lazyValue) {
136
+ return "";
137
+ }
138
+ let res = this.lazyValue
139
+ res = this.re_quote(res);
140
+ res = this.re_words(res, [true, false, null]);
141
+ res = this.re_number(res);
142
+ res = this.re_special(res, /([{},:\[\]])/g, 'color-orange');
143
+ return res;
144
+ },
104
145
  is_array() {
105
146
  if (this.baseArray) {
106
147
  return true
@@ -109,51 +150,6 @@ export default {
109
150
  }
110
151
  },
111
152
  methods: {
112
- setTab(event) {
113
- if (event.key === '"') {
114
- const end = event.target.selectionEnd;
115
- event.preventDefault()
116
- document.execCommand('insertText', false, event.key.repeat(2));
117
- event.target.selectionEnd = end + 1;
118
- return false;
119
- }
120
- if (event.key === "{") {
121
- const end = event.target.selectionEnd;
122
- event.preventDefault()
123
- document.execCommand('insertText', false, '{}');
124
- event.target.selectionEnd = end + 1;
125
- return false;
126
- }
127
- if (event.key === "[") {
128
- const end = event.target.selectionEnd;
129
- event.preventDefault()
130
- document.execCommand('insertText', false, '[]');
131
- event.target.selectionEnd = end + 1;
132
- return false;
133
- }
134
- if (event.keyCode === 9) {
135
- event.preventDefault()
136
- document.execCommand('insertText', false, ' '.repeat(4));
137
- return false;
138
- }
139
- if (event.keyCode === 13) {
140
- event.preventDefault()
141
- let n = event.target.value.substr(0, event.target.selectionStart).split('\n')
142
- n = n[n.length - 1].split('')
143
- let w = ''
144
- for (let i = 0; i < n.length; i++) {
145
- if (n[i] === ' ') {
146
- w += ' '
147
- } else {
148
- break
149
- }
150
- }
151
-
152
- document.execCommand('insertText', false, '\n' + w);
153
- return false;
154
- }
155
- return true
156
- },
157
153
  open() {
158
154
  if (this.template) {
159
155
  let d = this.modelValue
@@ -169,15 +165,7 @@ export default {
169
165
  this.show = true
170
166
  }
171
167
  },
172
- emitt(e) {
173
- try {
174
- this.error = false
175
- e = JSON.parse(e.target.value)
176
- this.$emit('update:modelValue', e)
177
- } catch (er) {
178
- this.error = true
179
- }
180
- },
168
+
181
169
  emit(e) {
182
170
  this.$emit('update:modelValue', e)
183
171
  },
@@ -228,5 +216,65 @@ export default {
228
216
  .state-error {
229
217
  border: 1px solid var(--color-error);
230
218
  }
219
+
220
+ .json-highlight {
221
+ position: relative;
222
+ margin: -12px 0;
223
+
224
+ .text-preview {
225
+ white-space: pre-wrap;
226
+ word-break: keep-all;
227
+ overflow-wrap: break-word;
228
+ min-height: 40px;
229
+ font-size: 14px;
230
+ letter-spacing: 2px;
231
+ line-height: 20px;
232
+ margin: 0;
233
+ border: 0;
234
+ padding: 12px;
235
+ }
236
+
237
+ textarea {
238
+ &::selection {
239
+ background-color: var(--color-two);
240
+ -webkit-text-fill-color: var(--color-two-text);
241
+ color: var(--color-two-text);
242
+ }
243
+
244
+ padding: 12px;
245
+ margin: 0;
246
+ border: 0;
247
+ font-size: 14px;
248
+ letter-spacing: 2px;
249
+ line-height: 20px;
250
+ -webkit-font-smoothing: antialiased;
251
+ -webkit-text-fill-color: transparent;
252
+ outline: none;
253
+ width: 100%;
254
+ height: 100%;
255
+ min-height: 40px;
256
+ white-space: pre-wrap;
257
+ word-break: keep-all;
258
+ overflow-wrap: break-word;
259
+ position: absolute;
260
+ top: 0;
261
+ left: 0;
262
+ resize: none;
263
+ overflow: hidden;
264
+ }
265
+
266
+ .color-orange {
267
+ color: orange;
268
+ }
269
+
270
+ .color-green {
271
+ color: #0cde27;
272
+ }
273
+
274
+
275
+ .color-blue {
276
+ color: #7ad5ff;
277
+ }
278
+ }
231
279
  }
232
280
  </style>
@@ -14,11 +14,11 @@
14
14
  }"
15
15
  >{{ alt }}
16
16
  </div>
17
- <img v-if="load &&!isSvg" ref="img" :src="link" :alt="alt" draggable="false" :width="size.width>0?size.width:'auto'"
18
- :height="size.height>0?size.height:'auto'"
19
- :style="{'height':size.height>0?undefined:'auto',
17
+ <img v-if="load &&!isSvg" ref="img" :alt="alt" :height="size.height>0?size.height:'auto'" :src="link" :style="{'height':size.height>0?undefined:'auto',
20
18
  'width':size.width>0?undefined:'auto'
21
- }"/>
19
+ }"
20
+ :width="size.width>0?size.width:'auto'"
21
+ draggable="false"/>
22
22
  <svg-img v-else-if="load &&isSvg&&link" :link="link" :size="size">
23
23
  </svg-img>
24
24
  </div>
@@ -119,21 +119,21 @@ export default {
119
119
  if (this.height) {
120
120
  res["height"] = this.height
121
121
  }
122
- let wPH=this.wPH
123
- if(!wPH){
124
- const ls=this.src.split('/')
125
- if(ls.length>0){
126
- const p=ls[ls.length-1].split('_')
127
- if(p.length===3){
128
- const p0=parseInt(p[0])
129
- const p1=parseInt(p[1])
130
- if(p0&&p1){
131
- wPH=p0/p1
122
+ let wPH = this.wPH
123
+ if (!wPH) {
124
+ const ls = this.src.split('/')
125
+ if (ls.length > 0) {
126
+ const p = ls[ls.length - 1].split('_')
127
+ if (p.length === 3) {
128
+ const p0 = parseInt(p[0])
129
+ const p1 = parseInt(p[1])
130
+ if (p0 && p1) {
131
+ wPH = p0 / p1
132
132
  }
133
133
  }
134
134
  }
135
135
  }
136
- if(wPH) {
136
+ if (wPH) {
137
137
  if (res['width'] !== 0 && res['height'] === 0) {
138
138
  res['height'] = parseInt(res['width'] / wPH)
139
139
  }
@@ -142,7 +142,7 @@ export default {
142
142
  }
143
143
  }
144
144
 
145
- if (res['width'] !== 0||res['height']!== 0) {
145
+ if (res['width'] !== 0 || res['height'] !== 0) {
146
146
  return this.size = res
147
147
  }
148
148
 
@@ -153,7 +153,7 @@ export default {
153
153
  let w = parseInt(parseFloat(cs.getPropertyValue('width')) - paddingX - borderX);
154
154
  return this.size = {
155
155
  width: w,
156
- height: parseInt(wPH?w / wPH:0)
156
+ height: parseInt(wPH ? w / wPH : 0)
157
157
  }
158
158
  }
159
159
  return false
@@ -161,7 +161,7 @@ export default {
161
161
  },
162
162
  activate() {
163
163
  this.getSize()
164
- if (this.size.width !== 0||this.size.height) {
164
+ if (this.size.width !== 0 || this.size.height) {
165
165
  this.load = true
166
166
  } else {
167
167
  clearTimeout(this.time_id)
@@ -23,7 +23,7 @@ const list = {
23
23
  },
24
24
  'r-card': {'p': 'card/index.vue', 'c': [], 'd': ['ripple']},
25
25
  'r-chart': {'p': 'chart/chart.vue', 'c': [], 'd': []},
26
- 'r-world-map': {'p': 'chart/worldMap.vue', 'c': [], 'd': []},
26
+ 'r-world-map': {'p': 'chart/worldMap.vue', 'c': ['r-float'], 'd': []},
27
27
  'r-chat': {
28
28
  'p': 'chat/index.vue',
29
29
  'c': ['r-btn', 'r-icon', 'r-progress-circle', 'r-img'],
@@ -1,17 +1,16 @@
1
1
  <template>
2
2
  <teleport :to="`.${$r.prefix}app`">
3
3
  <transition :name="animate">
4
- <div v-bind="$attrs" :class="{
4
+ <div v-if="modelValue" :class="{
5
5
  [`${$r.prefix}modal`]:true,
6
6
  'h-end': bottom,
7
7
  'modal-no-overlay': noOverlay,
8
8
  'animate-modal-vibrate': run_animate,
9
- }" :style="{'height':$r.breakpoint.height+'px'}" @click.self="close"
10
- v-if="modelValue">
9
+ }" v-bind="$attrs" @click.self="close"
10
+ >
11
11
  <div class="modal-container" :style="{'max-width':maxWidth,'max-height':maxHeight}" :class="{
12
12
  'modal-bottom':bottom,
13
13
  [color]:color,
14
- ['animate-modal-' +animate]:animate,
15
14
  'modal-full-width':fullWidth,
16
15
  'modal-full-height':fullHeight,
17
16
  'modal-mini':minWidth,
@@ -54,30 +53,57 @@ export default {
54
53
  minWidth: {type: Boolean, default: true},
55
54
  flat: Boolean,
56
55
  closable: Boolean,
56
+ routeHistory: String,
57
57
  closebtn: {type: Boolean, default: true},
58
58
  color: String,
59
59
  animate: {
60
60
  type: String,
61
- default: 'slide-up'
61
+ default: 'scale'
62
62
  }
63
-
64
63
  },
65
- emits:['update:modelValue'],
64
+ emits: ['update:modelValue'],
66
65
  data() {
67
66
  return {
68
67
  state: null,
69
68
  run_animate: false
70
69
  }
71
70
  },
71
+ created() {
72
+ if (this.routeHistory) {
73
+ const h = this.$route.hash.replace('#', '').split('&')
74
+ if (h.includes(this.routeHistory)) {
75
+ this.$emit('update:modelValue', true)
76
+ }
77
+ }
78
+ },
72
79
  watch: {
80
+ '$route': function (n) {
81
+ let h = []
82
+ if (this.$route.hash) {
83
+ h = this.$route.hash.replace('#', '').split('&')
84
+ }
85
+ if (!h.includes(this.routeHistory)) {
86
+ this.$emit('update:modelValue', false)
87
+ } else {
88
+ this.$emit('update:modelValue', true)
89
+ }
90
+ },
73
91
  modelValue: {
74
92
  // immediate: true, watch at created component
75
93
  handler: function (newVal, oldVal) {
76
94
  if (newVal === true) {
77
95
  document.documentElement.style.overflow = 'hidden'
78
- const that = this
79
- window.onpopstate = function (event) {
80
- that.$emit('update:modelValue', false)
96
+ if (this.routeHistory) {
97
+ const routeHashs = this.$route.hash.replace('#', '').split('&')
98
+ if (!routeHashs.includes(this.routeHistory)) {
99
+ let h = ''
100
+ if (this.$route.hash) {
101
+ h = this.$route.hash + '&' + this.routeHistory
102
+ } else {
103
+ h = '#' + this.routeHistory
104
+ }
105
+ this.$router.push({path: this.$route.fullPath, hash: h})
106
+ }
81
107
  }
82
108
  } else {
83
109
  document.documentElement.style.overflow = null
@@ -88,7 +114,27 @@ export default {
88
114
  methods: {
89
115
  close(force = false) {
90
116
  if (this.closable || force === true) {
91
- this.$emit('update:modelValue', !this.modelValue)
117
+ if (this.routeHistory) {
118
+ if (history.state.back) {
119
+ this.$router.back()
120
+ } else {
121
+ let h = ''
122
+ if (this.$route.hash) {
123
+ h = this.$route.hash.replace('#', '').split('&')
124
+ h.splice(h.indexOf(this.routeHistory), 1)
125
+ let s = ''
126
+ let first = true
127
+ h.forEach((item) => {
128
+ if (item) {
129
+ s += (first ? '#' : '&') + item
130
+ }
131
+ })
132
+ h = s
133
+ }
134
+ this.$router.replace({'path': this.$route.fullPath, hash: h})
135
+ }
136
+ }
137
+ this.$emit('update:modelValue', false)
92
138
  } else {
93
139
  this.run_animate = true
94
140
  setTimeout(() => {
@@ -4,19 +4,21 @@
4
4
  align-items: center;
5
5
  flex-direction: column;
6
6
  display: flex;
7
- left: 0;
8
- width: 100vw;
7
+ left: -50%;
8
+ top: -50%;
9
+ width: 200%;
10
+ height: 200%;
9
11
  justify-content: center;
10
12
  position: fixed;
11
13
  z-index: map_get($z-index, 'important');
12
14
  outline: none;
13
- bottom: 0;
14
15
 
15
16
 
16
- &:not(.modal-no-overlay) {
17
- background-color: var(--color-overlay);
18
- }
19
- .modal-content {
17
+ &:not(.modal-no-overlay) {
18
+ background-color: var(--color-overlay);
19
+ }
20
+
21
+ .modal-content {
20
22
  border: 1px solid var(--color-border);
21
23
  }
22
24
 
@@ -43,8 +45,8 @@
43
45
 
44
46
  .modal-container {
45
47
  width: 95%;
46
- max-width: 95%;
47
- max-height: 90%;
48
+ max-width: 100vw;
49
+ max-height: 90vh;
48
50
  z-index: map_get($z-index, 'important');
49
51
  }
50
52
 
@@ -59,7 +61,7 @@
59
61
  @include media-breakpoint-up('md') {
60
62
  .modal-container {
61
63
  width: 75%;
62
- max-width: 75%;
64
+ max-width: 75vw;
63
65
  }
64
66
  }
65
67
 
@@ -73,7 +75,7 @@
73
75
 
74
76
  .modal-full-width {
75
77
  width: 100%;
76
- max-width: 100% !important;
78
+ max-width: 100vw !important;
77
79
  }
78
80
 
79
81
  .modal-full-height {
@@ -82,7 +82,7 @@ export default {
82
82
  },
83
83
  label: String,
84
84
  url: String,
85
- inputClass: String,
85
+ inputClass: [String, Object, Array],
86
86
  query: {
87
87
  type: String,
88
88
  default: "search",