renusify 1.3.2 → 1.4.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.
@@ -16,11 +16,12 @@
16
16
  ref="input"
17
17
  />
18
18
  <r-btn size="small"
19
+ :class="{'color-success-text':pass!==null && pass!==false,'color-error-text':pass===false}"
19
20
  :rounded="$attrs.tile===undefined||$attrs.tile===false"
20
21
  :loading="loading" @click.prevent="check()" class="elevation-none mx-1">
21
22
  {{ $t('check', 'renusify') }}
22
- <r-icon v-if="pass!==null && pass!==false" v-html="$r.icons.check" exact width="20" height="20"></r-icon>
23
- <r-icon v-if=" pass===false" v-html="$r.icons.close" width="20" height="20"></r-icon>
23
+ <r-icon class="color-success-text" v-if="pass!==null && pass!==false" v-html="$r.icons.check" exact width="20" height="20"></r-icon>
24
+ <r-icon class="color-error-text" v-if=" pass===false" v-html="$r.icons.close" width="20" height="20"></r-icon>
24
25
  </r-btn>
25
26
  </div>
26
27
  </r-input>
@@ -9,7 +9,7 @@
9
9
  <slot :item="item" :index="i" :disableDel="disDel">
10
10
  <div v-if="template" class="d-flex flex-wrap pt-5 v-start">
11
11
  <template v-for="(v,k) in item" :key="i+'-'+k">
12
- <component :is="template[k]['type']" v-model="item[k]" :label="t(k)"
12
+ <component v-if="template[k]&&template[k]['type']" :is="template[k]['type']" v-model="item[k]" :label="t(k)"
13
13
  class="flex-grow-0 me-1" v-bind="template[k]['props']"></component>
14
14
  </template>
15
15
  </div>
@@ -3,7 +3,7 @@
3
3
  :class="{
4
4
  [`${$r.prefix}input-container`]:true,
5
5
  [c_color]:c_color&&!isDisabled,
6
- 'color-error-text':hasError&&validations.length>0,
6
+ 'color-error-text':hasError||validations.length>0,
7
7
  'hide-detail':c_hide,
8
8
  'input-focused':active,
9
9
  'input-disabled':isDisabled,
@@ -72,7 +72,7 @@ export default {
72
72
  uid: 'input_' + this.$helper.uniqueId(),
73
73
  lazyValue: this.modelValue,
74
74
  focused: false,
75
- errorBucket: this.error || [],
75
+ errorBucket: [],
76
76
  hasColor: false,
77
77
  hasFocused: false,
78
78
  hasInput: false,
@@ -25,10 +25,10 @@
25
25
  <r-text-input
26
26
  v-if="!is_array"
27
27
  v-model="info.key"
28
- :label="$t('key','renusify')"
28
+ :label="keyLabel||$t('key','renusify')"
29
29
  :tile="tile"
30
30
  class="w-30 pe-1"></r-text-input>
31
- <div class="w-20" >
31
+ <div class="w-20" v-if="!valueType">
32
32
  <r-select-input v-model="info.type"
33
33
  :tile="tile"
34
34
  class="me-1"
@@ -41,26 +41,26 @@
41
41
  </div>
42
42
  <r-text-input v-if="info.type==='text'"
43
43
  :tile="tile"
44
- :label="$t('value','renusify')"
44
+ :label="valueLabel||$t('value','renusify')"
45
45
  v-model="info.value"></r-text-input>
46
46
  <r-number-input v-else-if="info.type==='number'"
47
47
  :tile="tile"
48
- :label="$t('value','renusify')" v-model="info.value"></r-number-input>
48
+ :label="valueLabel||$t('value','renusify')" v-model="info.value"></r-number-input>
49
49
  <r-switch-input v-else-if="info.type==='boolean'"
50
50
  :tile="tile"
51
- :label="$t('value','renusify')" v-model="info.value"></r-switch-input>
51
+ :label="valueLabel||$t('value','renusify')" v-model="info.value"></r-switch-input>
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
55
  <textarea v-else :class="{'state-error':error}"
56
- :rows="Object.keys(modelValue).length+5"
56
+ :rows="modelValue?Object.keys(modelValue).length+5:5"
57
57
  autocapitalize="off"
58
58
  autocomplete="off"
59
59
  autocorrect="off"
60
60
  class="ltr w-full"
61
61
  spellcheck="false"
62
62
  @input="emitt"
63
- @keydown="setTab">{{ JSON.stringify(modelValue, null, 4) }}</textarea>
63
+ @keydown="setTab">{{ JSON.stringify(modelValue||{}, null, 4) }}</textarea>
64
64
  </div>
65
65
  </template>
66
66
  <script>
@@ -71,9 +71,17 @@ export default {
71
71
  components: {JsonView},
72
72
  props: {
73
73
  label: String,
74
+ keyLabel: {type: String, default: 'key'},
75
+ valueLabel: {type: String, default: 'value'},
74
76
  modelValue: {
75
77
  type: Object, Array
76
78
  },
79
+ valueType: {
80
+ type: String,
81
+ validator: function (value) {
82
+ return ['text', 'number', 'boolean'].indexOf(value) !== -1
83
+ }
84
+ },
77
85
  template: Object,
78
86
  baseArray: Boolean,
79
87
  disableAdd: Boolean,
@@ -155,6 +163,9 @@ export default {
155
163
  d.push(Object.assign({}, {}, this.template))
156
164
  this.$emit('update:modelValue', d)
157
165
  } else {
166
+ if(this.valueType){
167
+ this.info.type=this.valueType
168
+ }
158
169
  this.show = true
159
170
  }
160
171
  },
@@ -1,8 +1,7 @@
1
1
  <template>
2
- <div :class="`${$r.prefix}rating `">
2
+ <div :class="`${$r.prefix}rating size-${size} ms-n1`">
3
3
  <r-btn :class="`${Math.round(modelValue)>=i?'color-warning-text':''}`" :key="i"
4
4
  :readonly="readonly"
5
- :size="size"
6
5
  @click="select(i)"
7
6
  icon
8
7
  text
@@ -34,7 +33,7 @@ export default {
34
33
  emits:['update:modelValue'],
35
34
  created(){
36
35
  if(!this.$r.icons.star) {
37
- this.$r.icons.star = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.62L12 2L9.19 8.62L2 9.24l5.45 4.73L5.82 21L12 17.27Z"/></svg>'
36
+ this.$r.icons.star = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill="currentColor" d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.62L12 2L9.19 8.62L2 9.24l5.45 4.73L5.82 21L12 17.27Z"/></svg>'
38
37
  }
39
38
  },
40
39
  methods: {
@@ -46,13 +45,31 @@ export default {
46
45
  </script>
47
46
  <style lang="scss">
48
47
  @import "../../style/include";
49
-
50
-
48
+ $btn-sizes: (
49
+ 'x-small': 20,
50
+ 'small': 25,
51
+ 'default': 30,
52
+ 'large': 35,
53
+ 'x-large': 40
54
+ ) !default;
51
55
  .#{$prefix}rating {
52
56
  max-width: 100%;
53
57
  white-space: nowrap;
54
58
  transition: 1s $primary-transition;
55
59
  color: var(--color-disabled);
60
+
61
+ @each $name, $size in $btn-sizes {
62
+ &.size-#{$name} {
63
+ .#{$prefix}btn{
64
+ height: #{$size}px;
65
+ width: #{$size}px
66
+ }
67
+ .#{$prefix}icon{
68
+ height: #{$size - 4px};
69
+ width: #{$size - 4px}
70
+ }
71
+ }
72
+ }
56
73
  }
57
74
 
58
75
  </style>
@@ -10,7 +10,7 @@
10
10
  :key="i"
11
11
  class="number"
12
12
  :class="['number' + i,{'number-disabled':disableTime(parseInt(i),show,hour,min,sec)}]"
13
- :ref="'number' + i"
13
+ ref="number"
14
14
  @click="set(i)"
15
15
  >
16
16
  {{ num }}
@@ -349,7 +349,7 @@ export default {
349
349
  set(h, next = true) {
350
350
  h = parseInt(h);
351
351
  const circle = this.$refs.circle;
352
- const cl = this.$refs["number" + h];
352
+ const cl = this.$refs["number"][h];
353
353
  const hand = this.$refs.hand;
354
354
  const clock = this.$refs.clock.getBoundingClientRect();
355
355
 
@@ -440,7 +440,7 @@ export default {
440
440
  let cl = null;
441
441
  let po = null;
442
442
  for (let i = 1; i <= 12; i++) {
443
- cl = this.$refs["number" + i];
443
+ cl = this.$refs["number"][i];
444
444
  po = this.print_point(i, 110);
445
445
  cl.style.left = po[0] - 10 + "px";
446
446
  cl.style.top = po[1] - 10 + "px";
@@ -448,13 +448,13 @@ export default {
448
448
  }
449
449
  if (this.is24Hour) {
450
450
  for (let i = 13; i <= 23; i++) {
451
- cl = this.$refs["number" + i];
451
+ cl = this.$refs["number"][i];
452
452
  po = this.print_point(i, 70);
453
453
  cl.style.left = po[0] - 10 + "px";
454
454
  cl.style.top = po[1] - 10 + "px";
455
455
  cl.classList.add('number-show')
456
456
  }
457
- cl = this.$refs["number0"];
457
+ cl = this.$refs["number"][0];
458
458
  po = this.print_point(0, 70);
459
459
  cl.style.left = po[0] - 10 + "px";
460
460
  cl.style.top = po[1] - 10 + "px";
@@ -473,7 +473,7 @@ export default {
473
473
  let cl = null;
474
474
  let po = null;
475
475
  for (let i = 0; i <= 59; i++) {
476
- cl = this.$refs["number" + i];
476
+ cl = this.$refs["number"][i];
477
477
  po = this.print_point(i, 110, 60);
478
478
  cl.style.left = po[0] - 10 + "px";
479
479
  cl.style.top = po[1] - 10 + "px";
@@ -14,8 +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"
18
- :height="size.height"/>
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',
20
+ 'width':size.width>0?undefined:'auto'
21
+ }"/>
19
22
  <svg-img v-else-if="load &&isSvg&&link" :link="link" :size="size">
20
23
  </svg-img>
21
24
  </div>
@@ -61,10 +64,7 @@ export default {
61
64
  titleVe: Boolean,
62
65
  isSvg: Boolean,
63
66
  svgCache: {type: Number, default: 86400},
64
- wPH: {
65
- type: Number,
66
- default: 1
67
- },
67
+ wPH: Number
68
68
  },
69
69
  data() {
70
70
  return {
@@ -97,7 +97,10 @@ export default {
97
97
  res += 'c=' + this.svgCache
98
98
  }
99
99
  if (!this.isSvg && ((this.autoSize && this.size.width > 0) || this.width)) {
100
- res += `&w=${this.size.width}&h=${this.size.height}`
100
+ res += `&w=${this.size.width}`
101
+ }
102
+ if (!this.isSvg && ((this.autoSize && this.size.height > 0) || this.height)) {
103
+ res += `&h=${this.size.height}`
101
104
  }
102
105
  return res
103
106
  }
@@ -116,13 +119,29 @@ export default {
116
119
  if (this.height) {
117
120
  res["height"] = this.height
118
121
  }
119
- if (res['width'] !== 0 && res['height'] === 0) {
120
- res['height'] = res['width'] / this.wPH
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
+ }
133
+ }
134
+ }
121
135
  }
122
- if (res['width'] === 0 && res['height'] !== 0) {
123
- res['width'] = res['height'] * this.wPH
136
+ if(wPH) {
137
+ if (res['width'] !== 0 && res['height'] === 0) {
138
+ res['height'] = res['width'] / wPH
139
+ }
140
+ if (res['width'] === 0 && res['height'] !== 0) {
141
+ res['width'] = res['height'] * wPH
142
+ }
124
143
  }
125
- if (res['width'] !== 0) {
144
+ if (res['width'] !== 0||res['height']!== 0) {
126
145
  return this.size = res
127
146
  }
128
147
 
@@ -133,7 +152,7 @@ export default {
133
152
  let w = parseFloat((parseFloat(cs.getPropertyValue('width')) - paddingX - borderX).toFixed(2));
134
153
  return this.size = {
135
154
  width: w,
136
- height: w / this.wPH
155
+ height: wPH?w / wPH:0
137
156
  }
138
157
  }
139
158
  return false
@@ -141,7 +160,7 @@ export default {
141
160
  },
142
161
  activate() {
143
162
  this.getSize()
144
- if (this.size.width !== 0) {
163
+ if (this.size.width !== 0||this.size.height) {
145
164
  this.load = true
146
165
  } else {
147
166
  clearTimeout(this.time_id)
@@ -229,4 +248,4 @@ export default {
229
248
 
230
249
  }
231
250
  }
232
- </style>
251
+ </style>
@@ -7,7 +7,7 @@ function mounted(el, binding) {
7
7
  const duration = value.duration || .5
8
8
  const timing = value.timing || null
9
9
  const delay = value.delay + 50 || 50
10
- el.classList.add(`${window.app.$r.prefix}animate`)
10
+ el.classList.add(`r-directive-animate`)
11
11
  names.forEach((name) => {
12
12
  el.classList.add(name)
13
13
  })
@@ -1,6 +1,6 @@
1
1
  @import '../../style/include';
2
2
 
3
- .#{$prefix}animate{
3
+ .r-directive-animate{
4
4
  transition-timing-function: map_get($transition,'swing');
5
5
  transition-property: opacity,transform;
6
6
  &.fade{
@@ -134,7 +134,7 @@ function mounted(el, binding) {
134
134
  end: value.end,
135
135
  grab: value.grab
136
136
  }
137
- el.classList.add(`${window.app.$r.prefix}sortable`);
137
+ el.classList.add(`r-directive-sortable`);
138
138
  el.eventsHandler = {
139
139
  mousedown: e => mousestart(e, wrapper),
140
140
  touchstart: e => mousestart(e, wrapper)
@@ -169,7 +169,7 @@ function unmounted(el, binding) {
169
169
  let wrapper = {
170
170
  grab: value.grab
171
171
  }
172
- el.classList.remove(`${window.app.$r.prefix}sortable`);
172
+ el.classList.remove(`r-directive-sortable`);
173
173
  const lng=children.length
174
174
  for(let i=0;i<lng;i++){
175
175
  let child=children[i]
@@ -1,6 +1,6 @@
1
1
  @import "../../style/include";
2
2
 
3
- .#{$prefix}sortable {
3
+ .r-directive-sortable {
4
4
  position: relative;
5
5
  .dragable{
6
6
  .grab{
@@ -8,10 +8,10 @@ function mousestart(el, binding) {
8
8
  d = binding.arg
9
9
  }
10
10
 
11
- let $title = document.getElementById(`${window.app.$r.prefix}title`)
11
+ let $title = document.getElementById(`r-directive-title`)
12
12
  if (!$title) {
13
13
  $title = document.createElement('div')
14
- $title.setAttribute('id', `${window.app.$r.prefix}title`)
14
+ $title.setAttribute('id', `r-directive-title`)
15
15
  } else {
16
16
  mouseleave(el, binding)
17
17
  mousestart(el, binding)
@@ -21,8 +21,7 @@ function mousestart(el, binding) {
21
21
  var $titleDimension = el.getBoundingClientRect()
22
22
  $title.innerHTML = binding.value
23
23
  $title.style.opacity = 1
24
- const app=document.getElementsByClassName(`${window.app.$r.prefix}app`)
25
- app[0].appendChild($title)
24
+ document.body.appendChild($title)
26
25
  const h = $title.getBoundingClientRect().height + 5
27
26
  const w = $title.getBoundingClientRect().width + 5
28
27
 
@@ -48,7 +47,7 @@ function mouseleave(el, binding) {
48
47
  if (['left', 'right', 'top', 'bottom'].includes(binding.arg)) {
49
48
  d = binding.arg
50
49
  }
51
- let elm = document.getElementById(`${window.app.$r.prefix}title`)
50
+ let elm = document.getElementById(`r-directive-title`)
52
51
 
53
52
  if (elm === null) {
54
53
  return null
@@ -65,12 +64,11 @@ function mouseleave(el, binding) {
65
64
  elm.style.left = $titleDimension.left + $titleDimension.width + 'px'
66
65
  }
67
66
 
68
- elm = document.getElementById(`${window.app.$r.prefix}title`)
67
+ elm = document.getElementById(`r-directive-title`)
69
68
  if (elm === null) {
70
69
  return null
71
70
  }
72
- const app=document.getElementsByClassName(`${window.app.$r.prefix}app`)
73
- app[0].removeChild(elm)
71
+ document.body.removeChild(elm)
74
72
  }
75
73
 
76
74
  function createHandlers(el, binding) {
@@ -1,6 +1,6 @@
1
1
  @import "../../style/include";
2
2
 
3
- ##{$prefix}title {
3
+ #r-directive-title {
4
4
  transition: all .2s ease-in-out;
5
5
  padding: 4px 8px;
6
6
  white-space: nowrap;
@@ -9,7 +9,7 @@
9
9
  position: fixed;
10
10
  border-radius: map-get($borders, 'sm');
11
11
  font-size: 14px;
12
- font-family: inherit;
12
+ font-family: fontOne;
13
13
  transform: translateX(-50%);
14
14
  z-index: 50;
15
15
  opacity: 0;
package/index.js CHANGED
@@ -101,17 +101,21 @@ export default {
101
101
  app.config.globalProperties.$toast = function (message, options) {
102
102
  Toast.show(message, options);
103
103
  }
104
+ // renusify storage
105
+ app.config.globalProperties.$storage = Storage
106
+
104
107
  // renusify helper
105
108
  app.config.globalProperties.$helper = helper
106
109
  // renusify translate
107
- app.config.globalProperties.$translate = Translate
108
- DateTime.langs = app.config.globalProperties.$r.langs
109
- app.config.globalProperties.$dateTime = DateTime
110
- app.config.globalProperties.$t = (key, package_name = null, lang = null) => Translate.get(key, package_name, lang)
111
- app.config.globalProperties.$d = (value, key = 'long', local = null) => DateTime.formatLocal(value, key, local)
112
- app.config.globalProperties.$n = (value) => Currency.formatLocal(value)
110
+ app.config.globalProperties.$translate = new Translate(app.config.globalProperties.$r,app.config.globalProperties.$storage)
111
+ app.config.globalProperties.$dateTime = new DateTime(app.config.globalProperties.$r,app.config.globalProperties.$r.langs)
112
+ app.config.globalProperties.$t = (key, package_name = null, lang = null) => app.config.globalProperties.$translate.get(key, package_name, lang)
113
+ app.config.globalProperties.$d = (value, key = 'long', local = null) => app.config.globalProperties.$dateTime.formatLocal(value, key, local)
114
+ const c=new Currency(app.config.globalProperties.$r)
115
+ app.config.globalProperties.$n = (value) => c.formatLocal(value)
113
116
  // renusify validation
114
- app.config.globalProperties.$v = (names) => valid.checkType(names)
117
+ const v=new valid(app.config.globalProperties.$t)
118
+ app.config.globalProperties.$v = (names) => v.checkType(names)
115
119
 
116
120
  // install components
117
121
  let required_directive = register(app, options['components'] || []);
@@ -125,8 +129,6 @@ export default {
125
129
  // install directives
126
130
  registers(app, required_directive);
127
131
 
128
- // renusify storage
129
- app.config.globalProperties.$storage = Storage
130
132
 
131
133
  // renusify breakpoint
132
134
  function resize() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "renusify",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "description": "Vue3 Framework",
5
5
  "keywords": [
6
6
  "vuejs",
@@ -1,14 +1,13 @@
1
- import Translate from './Translate';
2
-
3
- class Currency {
1
+ export default class Currency {
2
+ constructor($r) {
3
+ this.$r=$r
4
+ }
4
5
  formatLocal (value) {
5
6
  try {
6
- return new Intl.NumberFormat(Translate._local).format(value);
7
+ return new Intl.NumberFormat(this.$r.lang).format(value);
7
8
  }catch (e) {
8
9
  console.error(e)
9
10
  return value
10
11
  }
11
12
  }
12
13
  }
13
-
14
- export default new Currency();
@@ -1,5 +1,6 @@
1
- class DateTime {
2
- constructor() {
1
+ export default class DateTime {
2
+ constructor($r,langs) {
3
+ this.$r=$r
3
4
  this.format = {
4
5
  narrow: {
5
6
  weekday: 'narrow'
@@ -33,7 +34,7 @@ class DateTime {
33
34
  }
34
35
  }
35
36
 
36
- this.langs = {};
37
+ this.langs = langs;
37
38
  }
38
39
 
39
40
  set_lang(name, lang) {
@@ -54,8 +55,8 @@ class DateTime {
54
55
  };
55
56
 
56
57
  formatLocal(value, type = 'long', local = null) {
57
- if (local === null && window.app) {
58
- local = window.app.$r.lang
58
+ if (local === null) {
59
+ local = this.$r.lang
59
60
  }
60
61
  if (!(local in this.langs)) {
61
62
  console.warn('set local:' + local + ' with this.$dateTime.set_lang("' + local + '",{\n' +
@@ -79,4 +80,3 @@ class DateTime {
79
80
  };
80
81
  }
81
82
 
82
- export default new DateTime();
@@ -1,152 +1,161 @@
1
1
  import Axios from 'axios';
2
2
 
3
- class Translate {
4
- constructor() {
5
- this._count = 0;
6
- this._messages = {};
7
- this._local = 'en';
8
- this._package = null;
9
- this._store = []
10
- }
3
+ export default class Translate {
4
+ constructor($r,$storage) {
5
+ this.$r=$r
6
+ this.$storage=$storage
7
+ this._count = 0;
8
+ this._failed_messages = {};
9
+ this._messages = {};
10
+ this._local = 'en';
11
+ this._package = null;
12
+ this._store = []
13
+ }
11
14
 
12
- get messages() {
13
- return this._messages;
14
- }
15
+ get messages() {
16
+ return this._messages;
17
+ }
15
18
 
16
- get local() {
17
- return this._local;
18
- }
19
+ get failed_messages() {
20
+ return Object.keys(this._failed_messages);
21
+ }
19
22
 
20
- set local(value) {
21
- this._local = value;
22
- }
23
+ get local() {
24
+ return this._local;
25
+ }
23
26
 
24
- set package(value) {
25
- this._package = value;
26
- }
27
+ set local(value) {
28
+ this._local = value;
29
+ }
27
30
 
28
- setMessages(obj, local) {
29
- this._messages[local||this._local] = Object.assign({}, this._messages[local||this._local], obj);
30
- }
31
+ set package(value) {
32
+ this._package = value;
33
+ }
31
34
 
32
- add(key, value) {
33
- if (!this._messages[this._local]) {
34
- this._messages[this._local] = {}
35
- }
36
- this._messages[this._local][key] = value;
37
- }
35
+ setMessages(obj, local) {
36
+ this._messages[local || this._local] = Object.assign({}, this._messages[local || this._local], obj);
37
+ }
38
38
 
39
- replaceAll(string, search, replace) {
40
- return string.split(search).join(replace);
39
+ add(key, value) {
40
+ if (!this._messages[this._local]) {
41
+ this._messages[this._local] = {}
41
42
  }
43
+ this._messages[this._local][key] = value;
44
+ }
42
45
 
43
- get(key, package_name = null,lang = null) {
44
- if(key===undefined||key===null){
45
- return ''
46
- }
47
- let variable=[]
48
- if (typeof key ==='object'){
49
- variable=key[1]
50
- key=key[0]
51
- if(!variable){
52
- console.error(
53
- 'object key must have variables. key:'+key+' variable:'+variable
54
- )
55
- return key
56
- }
57
- }
46
+ replaceAll(string, search, replace) {
47
+ return string.split(search).join(replace);
48
+ }
58
49
 
59
- if (package_name && typeof package_name !== 'string') {
60
- console.error(
61
- 'package name must be string. key:' + key + ' package_name:' + package_name
62
- )
63
- return key
64
- }
65
- if (typeof key !== 'string') {
66
- return key
67
- }
68
- key = key.toLowerCase()
50
+ get(key, package_name = null, lang = null) {
51
+ if (key === undefined || key === null) {
52
+ return ''
53
+ }
54
+ let variable = []
55
+ if (typeof key === 'object') {
56
+ variable = key[1]
57
+ key = key[0]
58
+ if (!variable) {
59
+ console.error(
60
+ 'object key must have variables. key:' + key + ' variable:' + variable
61
+ )
62
+ this._failed_messages[key] = true
63
+ return key
64
+ }
65
+ }
69
66
 
70
- const local = lang !== null ? lang : this._local
71
- const pack = package_name !== null ? package_name : this._package
72
- if (!local) {
73
- return key;
74
- }
75
- if (!this._messages[local]) {
76
- return key;
77
- }
78
- if (this._messages[local][key]) {
79
- let val = this._messages[local][key];
80
- const lng = variable.length
81
- for (let i = 0; i < lng; i++) {
82
- val = this.replaceAll(val, '{' + i + '}', variable[i]);
83
- }
67
+ if (package_name && typeof package_name !== 'string') {
68
+ console.error(
69
+ 'package name must be string. key:' + key + ' package_name:' + package_name
70
+ )
71
+ this._failed_messages[key] = true
72
+ return key
73
+ }
74
+ if (typeof key !== 'string') {
75
+ this._failed_messages[key] = true
76
+ return key
77
+ }
78
+ key = key.toLowerCase()
84
79
 
85
- if (val === null || val === '') {
86
- return key;
87
- }
88
- return val;
89
- } else if (window.app.$r && window.app.$r.autoAddTranslate && pack && this._count < 100 && /^([a-z_.])*$/.test(key)) {
90
- if (!this._store.includes(key)) {
91
- let url = '/translate/' + pack + '/' + key + '?v=';
92
- const lng = variable.length
93
- for (let i = 0; i < lng; i++) {
94
- url += '{' + i + '}';
95
- }
96
- Axios.post(url);
97
- this._count++;
98
- this._store.push(key)
99
- }
80
+ const local = lang !== null ? lang : this._local
81
+ const pack = package_name !== null ? package_name : this._package
82
+ if (!local) {
83
+ this._failed_messages[key] = true
84
+ return key;
85
+ }
86
+ if (!this._messages[local]) {
87
+ this._failed_messages[key] = true
88
+ return key;
89
+ }
90
+ if (this._messages[local][key]) {
91
+ let val = this._messages[local][key];
92
+ const lng = variable.length
93
+ for (let i = 0; i < lng; i++) {
94
+ val = this.replaceAll(val, '{' + i + '}', variable[i]);
95
+ }
100
96
 
101
- return key;
102
- } else {
103
- return key;
97
+ if (val === null || val === '') {
98
+ this._failed_messages[key] = true
99
+ return key;
100
+ }
101
+ return val;
102
+ } else if (this.$r && this.$r.autoAddTranslate && pack && this._count < 100 && /^([a-z_.])*$/.test(key)) {
103
+ if (!this._store.includes(key)) {
104
+ let url = '/translate/' + pack + '/' + key + '?v=';
105
+ const lng = variable.length
106
+ for (let i = 0; i < lng; i++) {
107
+ url += '{' + i + '}';
104
108
  }
109
+ Axios.post(url);
110
+ this._count++;
111
+ this._store.push(key)
112
+ }
113
+ this._failed_messages[key] = true
114
+ return key;
115
+ } else {
116
+ this._failed_messages[key] = true
117
+ return key;
105
118
  }
119
+ }
120
+
121
+ loads(packages = []) {
122
+ packages.forEach((p) => {
123
+ this.load(p)
124
+ })
125
+ }
106
126
 
107
- loads(packages=[]){
108
- packages.forEach((p)=>{
109
- this.load(p)
110
- })
127
+ load(p) {
128
+ const pack = p || this.$r.package;
129
+ if (!p) {
130
+ this.package = pack;
111
131
  }
112
- load(p) {
113
- if(!window.app||!window.app.$r){
114
- console.error('need define window.app=vue Application')
115
- return
116
- }
117
- const pack = p||window.app.$r.package;
118
- if(!p){
119
- this.package = pack;
120
- }
121
- if(!window.app.$r.store['langs_loaded']){
122
- window.app.$r.store['langs_loaded']={}
123
- }
124
- window.app.$r.store['langs_loaded'][pack] = false;
125
- let locale = window.app.$r.lang;
126
- if (window.app.$storage.get("lang")) {
127
- locale = window.app.$storage.get("lang");
128
- }
129
- Axios.get(`/translate/${pack}/${locale}`).then(
130
- res => {
131
- if (res.data.length !== 0) {
132
- const lang = {};
133
- const lng=res.data.length
134
- for (let i = 0; i < lng; i++) {
135
- lang[res.data[i].key] = res.data[i][locale];
136
- }
137
- this.local = locale;
138
- this.setMessages(lang);
139
- } else {
140
- this.local = locale;
141
- this.setMessages({});
142
- }
143
- window.app.$r.store['langs_loaded'][pack] = true;
144
- },
145
- () => {
146
- window.app.$r.store['langs_loaded'][pack] = true;
147
- }
148
- );
132
+ if (!this.$r.store['langs_loaded']) {
133
+ this.$r.store['langs_loaded'] = {}
134
+ }
135
+ this.$r.store['langs_loaded'][pack] = false;
136
+ let locale = this.$r.lang;
137
+ if (this.$storage.get("lang")) {
138
+ locale = this.$storage.get("lang");
149
139
  }
140
+ Axios.get(`/translate/${pack}/${locale}`).then(
141
+ res => {
142
+ if (res.data.length !== 0) {
143
+ const lang = {};
144
+ const lng = res.data.length
145
+ for (let i = 0; i < lng; i++) {
146
+ lang[res.data[i].key] = res.data[i][locale];
147
+ }
148
+ this.local = locale;
149
+ this.setMessages(lang);
150
+ } else {
151
+ this.local = locale;
152
+ this.setMessages({});
153
+ }
154
+ this.$r.store['langs_loaded'][pack] = true;
155
+ },
156
+ () => {
157
+ this.$r.store['langs_loaded'][pack] = true;
158
+ }
159
+ );
160
+ }
150
161
  }
151
-
152
- export default new Translate();
@@ -1,22 +1,22 @@
1
- /* eslint-disable */
2
- import Translate from '../trans/Translate'
3
-
4
- class Validate {
1
+ export default class Validate {
2
+ constructor($t) {
3
+ this.$t=$t
4
+ }
5
5
  required() {
6
- let msg = Translate.get('required_error','renusify');
6
+ let msg = this.$t('required_error','renusify');
7
7
  return (v) => !!(v !== undefined && v !== null && v !== '') || msg
8
8
  }
9
9
 
10
10
  requiredArray() {
11
- return (v) => (v !== undefined && v !== null && v.length > 0) || Translate.get('required_error','renusify');
11
+ return (v) => (v !== undefined && v !== null && v.length > 0) || this.$t('required_error','renusify');
12
12
  }
13
13
 
14
14
  email() {
15
- return (v) => (v && v.length > 0 ? /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(v) : true) || Translate.get('validate_email','renusify');
15
+ return (v) => (v && v.length > 0 ? /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(v) : true) || this.$t('validate_email','renusify');
16
16
  }
17
17
 
18
18
  url() {
19
- return (v) => (v && v.length > 0 ? /^((https?|ftp|smtp):\/\/)?(www.)?[a-z0-9]+\.[a-z]+(\/[a-zA-Z0-9#]+\/?)*$/.test(v) : true) || Translate.get('validate_url','renusify');
19
+ return (v) => (v && v.length > 0 ? /^((https?|ftp|smtp):\/\/)?(www.)?[a-z0-9]+\.[a-z]+(\/[a-zA-Z0-9#]+\/?)*$/.test(v) : true) || this.$t('validate_url','renusify');
20
20
  }
21
21
 
22
22
  match(val) {
@@ -24,49 +24,49 @@ class Validate {
24
24
  if (v == val) {
25
25
  return true
26
26
  } else {
27
- return Translate.get(['validate_match', [val]],'renusify');
27
+ return this.$t(['validate_match', [val]],'renusify');
28
28
  }
29
29
  }
30
30
  }
31
31
 
32
32
  phone() {
33
- return (v) => (v && v.length > 0 ? /^[+]?[(]?[0-9]{3}[)]?[-\s.]?[0-9]{3}[-\s.]?[0-9]{4}$/.test(v) : true) || Translate.get('validate_phone','renusify');
33
+ return (v) => (v && v.length > 0 ? /^[+]?[(]?[0-9]{3}[)]?[-\s.]?[0-9]{3}[-\s.]?[0-9]{4}$/.test(v) : true) || this.$t('validate_phone','renusify');
34
34
  }
35
35
 
36
36
  number() {
37
- return (v) => (v && v.length > 0 ? /^([0-9.])*$/.test(v) : true) || Translate.get('numeric_error','renusify');
37
+ return (v) => (v && v.length > 0 ? /^([0-9.])*$/.test(v) : true) || this.$t('numeric_error','renusify');
38
38
  }
39
39
 
40
40
  english() {
41
- return (v) => (v && v.length > 0 ? /^([0-9a-zA-Z])*$/.test(v) : true) || Translate.get('english_error','renusify');
41
+ return (v) => (v && v.length > 0 ? /^([0-9a-zA-Z])*$/.test(v) : true) || this.$t('english_error','renusify');
42
42
  }
43
43
 
44
44
  min_len(num) {
45
- return v => (v && v.length > 0 ? v.length >= parseInt(num)?true: Translate.get(['min_len_error', [num,v.length]],'renusify') : true)
45
+ return v => (v && v.length > 0 ? v.length >= parseInt(num)?true: this.$t(['min_len_error', [num,v.length]],'renusify') : true)
46
46
  }
47
47
 
48
48
  max_len(num) {
49
- return v => (v && v.length > 0 ? v.length <= parseInt(num)?true: Translate.get(['max_len_error', [num,v.length]],'renusify') : true)
49
+ return v => (v && v.length > 0 ? v.length <= parseInt(num)?true: this.$t(['max_len_error', [num,v.length]],'renusify') : true)
50
50
  }
51
51
 
52
52
  len(num) {
53
- return v => (v && v.length > 0 ? v.length === parseInt(num)?true: Translate.get(['len_error', [num,v.length]],'renusify') : true) || msg
53
+ return v => (v && v.length > 0 ? v.length === parseInt(num)?true: this.$t(['len_error', [num,v.length]],'renusify') : true) || msg
54
54
  }
55
55
 
56
56
  min(num) {
57
- return v => (v ? parseFloat(v) >= parseFloat(num)?true: Translate.get(['min_error', [num,parseFloat(v)]],'renusify') : true)
57
+ return v => (v ? parseFloat(v) >= parseFloat(num)?true: this.$t(['min_error', [num,parseFloat(v)]],'renusify') : true)
58
58
  }
59
59
 
60
60
  max(num) {
61
- return v => (v ? parseFloat(v) <= parseFloat(num)?true: Translate.get(['max_error', [num,parseFloat(v)]],'renusify') : true)
61
+ return v => (v ? parseFloat(v) <= parseFloat(num)?true: this.$t(['max_error', [num,parseFloat(v)]],'renusify') : true)
62
62
  }
63
63
 
64
64
  eq(num) {
65
- return v => (v ? parseFloat(v) === parseFloat(num) : true) || Translate.get(['validate_eq', [num]],'renusify');
65
+ return v => (v ? parseFloat(v) === parseFloat(num) : true) || this.$t(['validate_eq', [num]],'renusify');
66
66
  }
67
67
 
68
68
  notDefined(name) {
69
- return v => Translate.get(['validate_notDefined', [name]],'renusify');
69
+ return v => this.$t(['validate_notDefined', [name]],'renusify');
70
70
  }
71
71
 
72
72
  checkType(names) {
@@ -92,6 +92,4 @@ class Validate {
92
92
  }
93
93
  return filters
94
94
  }
95
- }
96
-
97
- export default new Validate()
95
+ }
package/tools/helper.js CHANGED
@@ -1,3 +1,5 @@
1
+ import Toast from "../components/app/toast/toast";
2
+
1
3
  export function clearProxy(obj) {
2
4
  return JSON.parse(JSON.stringify(typeof obj === 'object' ? obj : {}))
3
5
  }
@@ -33,9 +35,9 @@ export function copy(text, msg = null) {
33
35
  }
34
36
 
35
37
  navigator.clipboard.writeText(text).then(function () {
36
- window.app.$toast(msg || window.app.$t('copy_text_to_clipboard', 'renusify'), {type: 'success'})
38
+ Toast.show(msg ||'copy_text_to_clipboard', {type: 'success'});
37
39
  }, function () {
38
- window.app.$toast(window.app.$t('text_not_copied!', 'renusify'), {type: 'error'})
40
+ Toast.show(msg ||'text_not_copied', {type: 'error'});
39
41
  })
40
42
  }
41
43
 
@@ -1,10 +0,0 @@
1
- import valid from './Validate'
2
-
3
- export default {
4
-
5
- // The install method will be called with the Vue constructor as the first argument, along with possible options
6
- install (app, options) {
7
- // Add $plugin instance method directly to Vue components
8
- app.config.globalProperties.$v = (names) => valid.checkType(names)
9
- }
10
- }