renusify 2.5.0 → 2.5.1

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.
@@ -2,20 +2,24 @@ export const color = {
2
2
  methods: {
3
3
  setColorValue(color) {
4
4
  let rgba = {r: 0, g: 0, b: 0, a: 1}
5
- if (/#/.test(color)) {
5
+ const rgbRegex = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*([01]?\.\d+)?\s*)?\)$/;
6
+ const hexRegex = /^#([a-f0-9]{6}|[a-f0-9]{8})$/i;
7
+ if (hexRegex.test(color)) {
6
8
  rgba = this.hex2rgba(color)
7
- } else if (/rgb/.test(color)) {
9
+ } else if (rgbRegex.test(color)) {
8
10
  rgba = this.rgb2rgba(color)
9
11
  } else if (Object.prototype.toString.call(color) === '[object Object]') {
10
12
  rgba = color
13
+ } else {
14
+ return
11
15
  }
12
16
  this.r = rgba.r
13
17
  this.g = rgba.g
14
18
  this.b = rgba.b
15
- if (rgba.a >= 0) {
19
+ if (rgba.a >= 0 && rgba.a <= 1) {
16
20
  this.a = rgba.a
17
21
  } else {
18
- this.a = rgba.a || 1
22
+ this.a = 1
19
23
  }
20
24
 
21
25
  this.set_hsv(rgba)
@@ -56,20 +60,35 @@ export const color = {
56
60
  ctx.fillStyle = gradient
57
61
  ctx.fillRect(0, 0, width, height)
58
62
  },
59
- rgb2hex({r, g, b}, toUpper) {
60
- const change = (val) => ('0' + Number(val).toString(16)).slice(-2)
61
- const color = `#${change(r)}${change(g)}${change(b)}`
62
- return toUpper ? color.toUpperCase() : color
63
+ rgb2hex({r, g, b, a}, toUpper = false) {
64
+ const change = (val) => {
65
+ const hex = Math.round(val).toString(16);
66
+ return hex.length === 1 ? '0' + hex : hex;
67
+ };
68
+
69
+ let color = `#${change(r)}${change(g)}${change(b)}`;
70
+
71
+ if (a !== undefined && a !== 1) {
72
+ const alpha = Math.round(a * 255);
73
+ color += change(alpha);
74
+ }
75
+
76
+ return toUpper ? color.toUpperCase() : color;
63
77
  },
64
78
  hex2rgba(hex) {
65
79
  hex = hex.slice(1)
66
- const change = (val) => parseInt(val, 16) || 0 // Avoid NaN situations
67
- return {
68
- r: change(hex.slice(0, 2)),
69
- g: change(hex.slice(2, 4)),
70
- b: change(hex.slice(4, 6)),
71
- a: 1
80
+ const change = (val) => parseInt(val, 16) || 0;
81
+ const r = change(hex.slice(0, 2));
82
+ const g = change(hex.slice(2, 4));
83
+ const b = change(hex.slice(4, 6));
84
+
85
+ let a = 1;
86
+ if (hex.length === 8) {
87
+ const alphaHex = hex.slice(6, 8);
88
+ a = parseFloat((parseInt(alphaHex, 16) / 255).toFixed(2));
72
89
  }
90
+
91
+ return {r, g, b, a};
73
92
  },
74
93
  rgb2rgba(rgba) {
75
94
  rgba = (/rgba?\((.*?)\)/.exec(rgba) || ['', '0,0,0,1'])[1].split(',')
@@ -129,9 +129,6 @@ export default {
129
129
  },
130
130
  inputHex(color) {
131
131
  const value = color.target.value
132
- if (value.length !== 7) {
133
- return
134
- }
135
132
  this.setColorValue(value)
136
133
  this.$nextTick(() => {
137
134
 
@@ -5,7 +5,7 @@
5
5
  :active="active"
6
6
  inputControlClass="v-center"
7
7
  >
8
- <r-btn @click.prevent.stop="minus" class="minus" icon :text="btnText">
8
+ <r-btn :disabled="min!==undefined&&number<=min" :text="btnText" class="minus" icon @click.prevent.stop="minus">
9
9
  <r-icon v-html="$r.icons.minus"></r-icon>
10
10
  </r-btn>
11
11
  <input @input="emit"
@@ -18,7 +18,7 @@
18
18
  autocomplete="no"
19
19
  v-model="number"
20
20
  />
21
- <r-btn @click.prevent.stop="plus" class="plus" icon :text="btnText">
21
+ <r-btn :disabled="max!==undefined&&number>=max" :text="btnText" class="plus" icon @click.prevent.stop="plus">
22
22
  <r-icon v-html="$r.icons.plus"></r-icon>
23
23
  </r-btn>
24
24
  </r-input>
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div :class="`${$r.prefix}input-tel`">
3
3
  <r-btn :disabled="!select||readonly"
4
- :rounded="!c_tile" class="btn-country ltr ms-1" outlined @click.stop="toggleDropdown">
4
+ :rounded="!c_tile" class="btn-country ltr mr-1" outlined @click.stop="toggleDropdown">
5
5
  <div :class="activeCountry.iso2.toLowerCase()" class="iti-flag"></div>
6
6
  <span class="country-code pa-1"> +{{ activeCountry.dialCode }} </span>
7
7
  <span class="dropdown-arrow">{{ open ? "▲" : "▼" }}</span>
@@ -152,7 +152,7 @@ export default {
152
152
 
153
153
  .#{base.$prefix}input-tel {
154
154
  display: flex;
155
- align-items: baseline;
155
+ align-items: end;
156
156
  direction: ltr;
157
157
  flex-wrap: wrap;
158
158
  .btn-country {
@@ -1,5 +1,6 @@
1
1
  <template>
2
2
  <div ref="container"
3
+ class="ltr"
3
4
  :class="{ [$r.prefix+'img-preview-container']:true}">
4
5
  <div
5
6
  :style="wrapperStyle"
@@ -1,34 +1,35 @@
1
1
  <template>
2
- <teleport v-if="show" :to="`.${$r.prefix}app`">
3
- <div v-if="modelValue&&!noOverlay" :class="{
4
- [`${$r.prefix}modal-overlay`]:true
5
- }"></div>
6
- <transition :name="c_animate">
7
- <div v-if="modelValue" :class="{
8
- [`${$r.prefix}modal`]:true,
9
- 'h-end': bottom||fullHeight,
10
- 'animate-modal-vibrate': run_animate,
11
- }" v-bind="$attrs" @click.self="close"
12
- >
13
- <div class="modal-container" :style="{'max-width':maxWidth,'max-height':maxHeight}" :class="{
14
- 'modal-bottom':bottom,
15
- [color]:color,
16
- 'modal-full-width':fullWidth,
17
- 'modal-full-height':fullHeight,
18
- 'modal-mini':minWidth,
19
- 'modal-flat':flat
2
+ <teleport v-if="mounted" :to="`.${$r.prefix}app`">
3
+ <div
4
+ v-if="modelValue && !noOverlay"
5
+ :class="`${$r.prefix}modal-overlay`"
6
+ ></div>
20
7
 
21
- }">
8
+ <transition :name="computedAnimation">
9
+ <div
10
+ v-if="modelValue"
11
+ :class="modalClasses"
12
+ v-bind="$attrs"
13
+ @click.self="!noCloseOnClickOutside && close()"
14
+ >
15
+ <div
16
+ :class="containerClasses"
17
+ :style="containerStyles"
18
+ class="modal-container"
19
+ >
22
20
  <div class="modal-btn text-end">
23
- <r-btn class="color-error-text"
24
- text
25
- @click.prevent="close(true)"
26
- fab
27
- size="small"
28
- v-if="closebtn">
21
+ <r-btn
22
+ v-if="!noCloseBtn"
23
+ class="color-error-text"
24
+ fab
25
+ size="small"
26
+ text
27
+ @click.prevent="close(true)"
28
+ >
29
29
  <r-icon v-html="$r.icons.close"></r-icon>
30
30
  </r-btn>
31
31
  </div>
32
+
32
33
  <div class="modal-content">
33
34
  <slot></slot>
34
35
  </div>
@@ -45,123 +46,170 @@ export default {
45
46
  name: 'r-modal',
46
47
  inheritAttrs: false,
47
48
  props: {
48
- modelValue: Boolean,
49
- bottom: Boolean,
49
+ modelValue: {
50
+ type: Boolean,
51
+ required: true
52
+ },
53
+ position: {
54
+ type: String,
55
+ default: 'center',
56
+ validator: (value) => ['center', 'bottom', 'start', 'end', 'top'].includes(value)
57
+ },
50
58
  noOverlay: Boolean,
51
59
  fullWidth: Boolean,
52
60
  fullHeight: Boolean,
53
- maxWidth: String,
54
- maxHeight: String,
55
- minWidth: {type: Boolean, default: true},
56
- flat: Boolean,
57
- closable: Boolean,
61
+ maxWidth: {
62
+ type: String,
63
+ default: null
64
+ },
65
+ maxHeight: {
66
+ type: String,
67
+ default: null
68
+ },
69
+ minWidth: {
70
+ type: Boolean,
71
+ default: true
72
+ },
73
+ noClosable: Boolean,
74
+ noCloseBtn: Boolean,
75
+ noCloseOnClickOutside: Boolean,
58
76
  routeHistory: String,
59
- closebtn: {type: Boolean, default: true},
60
77
  color: String,
61
- animate: String
78
+ animation: String
62
79
  },
63
80
  emits: ['update:modelValue'],
64
81
  data() {
65
82
  return {
66
- state: null,
67
- run_animate: false,
68
- show: false,
83
+ mounted: false,
84
+ runAnimation: false
69
85
  }
70
86
  },
71
87
  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
- setTimeout(()=>{
79
- this.show=true
80
- },10)
88
+ this.initFromRoute();
89
+ setTimeout(() => {
90
+ this.mounted = true;
91
+ }, 10);
81
92
  },
82
93
  watch: {
83
- '$route': function (n) {
84
- let h = []
85
- if (this.$route.hash) {
86
- h = this.$route.hash.replace('#', '').split('&')
87
- }
88
- if (!h.includes(this.routeHistory)) {
89
- this.$emit('update:modelValue', false)
90
- } else {
91
- this.$emit('update:modelValue', true)
94
+ '$route': 'handleRouteChange',
95
+ modelValue: 'handleModelValueChange'
96
+ },
97
+ computed: {
98
+ computedAnimation() {
99
+ if (this.animation) return this.animation;
100
+
101
+ switch (this.position) {
102
+ case 'bottom':
103
+ return 'slide-up';
104
+ case 'top':
105
+ return 'slide-down';
106
+ case 'start':
107
+ return 'slide-end';
108
+ case 'end':
109
+ return 'slide-start';
110
+ default:
111
+ return 'scale';
92
112
  }
93
113
  },
94
- modelValue: {
95
- // immediate: true, watch at created component
96
- handler: function (newVal, oldVal) {
97
- if (newVal === true) {
98
- document.documentElement.style.overflow = 'hidden'
99
- if (this.routeHistory) {
100
- const routeHashs = this.$route.hash.replace('#', '').split('&')
101
- if (!routeHashs.includes(this.routeHistory)) {
102
- let h = ''
103
- if (this.$route.hash) {
104
- h = this.$route.hash + '&' + this.routeHistory
105
- } else {
106
- h = '#' + this.routeHistory
107
- }
108
- this.$router.push({path: this.$route.fullPath, hash: h})
109
- }
110
- }
111
- } else {
112
- document.documentElement.style.overflow = null
114
+ modalClasses() {
115
+ return [
116
+ `${this.$r.prefix}modal`,
117
+ `modal-${this.position}`,
118
+ {
119
+ 'animate-modal-vibrate': this.runAnimation
113
120
  }
114
- }
121
+ ];
122
+ },
123
+ containerClasses() {
124
+ return [
125
+ this.color,
126
+ {
127
+ 'modal-full-width': this.fullWidth,
128
+ 'modal-full-height': this.fullHeight,
129
+ 'modal-mini': this.minWidth,
130
+ [`modal-${this.position}`]: this.position !== 'center'
131
+ }
132
+ ];
133
+ },
134
+ containerStyles() {
135
+ return {
136
+ 'max-width': this.maxWidth,
137
+ 'max-height': this.maxHeight
138
+ };
115
139
  }
116
140
  },
117
- computed: {
118
- c_animate() {
119
- if (this.animate) {
120
- return this.animate
141
+ methods: {
142
+ initFromRoute() {
143
+ if (!this.routeHistory) return;
144
+
145
+ const hashValues = this.$route.hash.replace('#', '').split('&');
146
+ if (hashValues.includes(this.routeHistory)) {
147
+ this.$emit('update:modelValue', true);
121
148
  }
122
- if (this.bottom) {
123
- return 'slide-up'
149
+ },
150
+ handleRouteChange(newRoute) {
151
+ if (!this.routeHistory) return;
152
+
153
+ const hashValues = newRoute.hash.replace('#', '').split('&');
154
+ this.$emit('update:modelValue', hashValues.includes(this.routeHistory));
155
+ },
156
+ handleModelValueChange(isOpen) {
157
+ if (isOpen) {
158
+ document.documentElement.style.overflow = 'hidden';
159
+ this.handleOpenState();
160
+ } else {
161
+ document.documentElement.style.overflow = null;
124
162
  }
125
- if (this.fullHeight) {
126
- return 'slide-up'
163
+ },
164
+ handleOpenState() {
165
+ if (!this.routeHistory) return;
166
+
167
+ const hashValues = this.$route.hash.replace('#', '').split('&');
168
+ if (!hashValues.includes(this.routeHistory)) {
169
+ const newHash = this.$route.hash
170
+ ? `${this.$route.hash}&${this.routeHistory}`
171
+ : `#${this.routeHistory}`;
172
+
173
+ this.$router.push({
174
+ path: this.$route.fullPath,
175
+ hash: newHash
176
+ });
127
177
  }
128
- return 'scale'
129
- }
130
- },
131
- methods: {
178
+ },
132
179
  close(force = false) {
133
- if (this.closable || force === true) {
134
- if (this.routeHistory) {
135
- if (history.state.back) {
136
- this.$router.back()
137
- } else {
138
- let h = ''
139
- if (this.$route.hash) {
140
- h = this.$route.hash.replace('#', '').split('&')
141
- h.splice(h.indexOf(this.routeHistory), 1)
142
- let s = ''
143
- let first = true
144
- h.forEach((item) => {
145
- if (item) {
146
- s += (first ? '#' : '&') + item
147
- }
148
- })
149
- h = s
150
- }
151
- this.$router.replace({'path': this.$route.fullPath, hash: h})
152
- }
153
- }
154
- this.$emit('update:modelValue', false)
155
- } else {
156
- this.run_animate = true
157
- setTimeout(() => {
158
- this.run_animate = false
159
- }, 300)
180
+ if (this.noClosable && !force) {
181
+ this.runAnimation = true;
182
+ setTimeout(() => this.runAnimation = false, 300);
183
+ return;
160
184
  }
185
+
186
+ if (this.routeHistory) {
187
+ this.handleRouteClose();
188
+ }
189
+
190
+ this.$emit('update:modelValue', false);
191
+ },
192
+ handleRouteClose() {
193
+ if (history.state.back) {
194
+ this.$router.back();
195
+ return;
196
+ }
197
+
198
+ let hashValues = this.$route.hash.replace('#', '').split('&');
199
+ hashValues = hashValues.filter(val => val !== this.routeHistory);
200
+
201
+ const newHash = hashValues.length
202
+ ? `#${hashValues.join('&')}`
203
+ : '';
204
+
205
+ this.$router.replace({
206
+ path: this.$route.fullPath,
207
+ hash: newHash
208
+ });
161
209
  }
162
210
  },
163
211
  beforeUnmount() {
164
- document.documentElement.style.overflow = null
212
+ document.documentElement.style.overflow = null;
165
213
  }
166
214
  }
167
- </script>
215
+ </script>
@@ -5,36 +5,45 @@
5
5
 
6
6
 
7
7
  .#{base.$prefix}modal-overlay {
8
- width: 100%;
9
- height: 100%;
10
8
  position: fixed;
11
- left: 0;
12
- right: 0;
13
- top:0;
9
+ inset: 0;
14
10
  z-index: map.get(base.$z-index, 'important');
15
11
  background-color: var(--color-overlay);
16
12
  backdrop-filter: blur(3px) grayscale(30%);
17
13
  }
18
14
 
19
15
  .#{base.$prefix}modal {
20
- align-items: center;
21
- flex-direction: column;
22
- display: flex;
23
- left: 0;
24
- top: 0;
25
- width: 100%;
26
- height: 100%;
27
- justify-content: center;
28
16
  position: fixed;
17
+ inset: 0;
18
+ display: flex;
29
19
  z-index: map.get(base.$z-index, 'important');
30
20
  outline: none;
31
21
 
32
- .modal-content {
33
- border: 1px solid var(--color-sheet-container-low);
34
- background-color: var(--color-sheet-container-low);
35
- color: var(--color-on-sheet)
22
+ // Position variants
23
+ &.modal-center {
24
+ align-items: center;
25
+ justify-content: center;
26
+ }
27
+
28
+ &.modal-bottom {
29
+ align-items: flex-end;
30
+ justify-content: center;
31
+ }
32
+
33
+ &.modal-top {
34
+ align-items: flex-start;
35
+ justify-content: center;
36
+ }
37
+
38
+ &.modal-start {
39
+ align-items: center;
40
+ justify-content: flex-start;
36
41
  }
37
42
 
43
+ &.modal-end {
44
+ align-items: center;
45
+ justify-content: flex-end;
46
+ }
38
47
 
39
48
  .modal-btn {
40
49
  width: 100%;
@@ -43,10 +52,12 @@
43
52
  .#{base.$prefix}btn {
44
53
  position: absolute;
45
54
  bottom: -40px;
46
- z-index: map.get(base.$z-index, 'important')+1;
55
+ z-index: map.get(base.$z-index, 'important') + 1;
56
+
47
57
  @include mixins.rtl() {
48
58
  left: 5px;
49
59
  }
60
+
50
61
  @include mixins.ltr() {
51
62
  right: 5px;
52
63
  }
@@ -58,18 +69,48 @@
58
69
  max-width: 100vw;
59
70
  max-height: 90vh;
60
71
  z-index: map.get(base.$z-index, 'important');
72
+ background-color: var(--color-sheet-container-low);
73
+ color: var(--color-on-sheet);
74
+ border: 1px solid var(--color-sheet-container-low);
75
+ border-radius: base.$border-modal;
76
+ overflow: hidden;
77
+ display: flex;
78
+ flex-direction: column;
79
+
80
+ &.modal-bottom,
81
+ &.modal-top {
82
+ width: 100%;
83
+ border-radius: base.$border-modal base.$border-modal 0 0;
84
+
85
+ &:not(.modal-full-width) {
86
+ max-width: map.get(base.$container-max-widths, 'lg');
87
+ }
88
+ }
89
+
90
+ &.modal-start,
91
+ &.modal-end {
92
+ height: 100%;
93
+ max-height: 100vh;
94
+ border-radius: 0 base.$border-modal base.$border-modal 0;
95
+
96
+ &:not(.modal-full-height) {
97
+ max-height: 90vh;
98
+ }
99
+ }
100
+
101
+ &.modal-start {
102
+ border-radius: base.$border-modal 0 0 base.$border-modal;
103
+ }
61
104
  }
62
105
 
63
106
  .modal-content {
64
- position: relative;
65
- border-radius: base.$border-modal;
107
+ flex: 1;
66
108
  overflow-y: auto;
67
109
  overflow-x: hidden;
68
- height: 100%;
69
110
  }
70
111
 
71
112
  @include mixins2.media-breakpoint-up('md') {
72
- .modal-container {
113
+ .modal-container:not(.modal-full-width):not(.modal-mini) {
73
114
  width: 75%;
74
115
  max-width: 75vw;
75
116
  }
@@ -79,44 +120,27 @@
79
120
  max-width: 500px;
80
121
  }
81
122
 
82
- .modal-flat {
83
- border-radius: 0;
84
- }
85
-
86
123
  .modal-full-width {
87
124
  width: 100%;
88
- max-width: 100vw !important;
125
+ max-width: 100vw;
89
126
  }
90
127
 
91
128
  .modal-full-height {
92
129
  height: 100%;
93
- }
94
-
95
- .modal-bottom {
96
- border-radius: base.$border-modal base.$border-modal 0 0;
97
-
98
- &:not(.modal-full-width) {
99
- max-width: map.get(base.$container-max-widths, 'lg');
100
- }
130
+ max-height: 100vh;
101
131
  }
102
132
  }
103
133
 
134
+ // Animations
104
135
  .animate-modal-vibrate {
105
- animation-duration: .15s !important;
106
- animation-name: animate-modal-vibrate !important;
107
- animation-timing-function: map.get(base.$transition, 'fast-in-fast-out') !important;
136
+ animation: animate-modal-vibrate 0.15s map.get(base.$transition, 'fast-in-fast-out');
137
+
108
138
  @keyframes animate-modal-vibrate {
109
- 0% {
110
- transform: scale(1)
139
+ 0%, 100% {
140
+ transform: scale(1);
111
141
  }
112
142
  50% {
113
- transform: scale(1.03)
114
- }
115
- 100% {
116
- transform: scale(1)
143
+ transform: scale(1.03);
117
144
  }
118
145
  }
119
- }
120
-
121
-
122
-
146
+ }
@@ -205,10 +205,15 @@ export default {
205
205
  line-height: 20px;
206
206
  padding: 12px;
207
207
  max-width: 100%;
208
- min-width: 0px;
208
+ min-width: 0;
209
209
  caret-color: var(--color-on-sheet);
210
210
  }
211
211
 
212
+ input::placeholder {
213
+ color: var(--color-on-sheet);
214
+ opacity: 1;
215
+ }
216
+
212
217
  .card-search {
213
218
  position: absolute;
214
219
  left: 0;
@@ -1,118 +1,123 @@
1
1
  <template>
2
- <r-container ref="tree" :class="classes" full-width>
3
- <r-row v-if="searchLink">
4
- <r-col>
5
- <r-select-input
6
- :label="$t('search','renusify')"
7
- :model-value="search"
8
- :searchLink="searchLink"
9
- @update:model-value="change($event)"
10
- ></r-select-input>
11
- </r-col>
12
- </r-row>
13
- <r-float v-if="show" :minZoom="0.01" :zoom="0.7" bordered>
14
- <template v-slot="{move,ease,transform}">
15
- <div :class="{
2
+ <r-container ref="tree" :class="classes" full-width>
3
+ <r-row v-if="searchLink">
4
+ <r-col>
5
+ <r-select-input
6
+ :label="$t('search','renusify')"
7
+ :model-value="search"
8
+ :searchLink="searchLink"
9
+ @update:model-value="change($event)"
10
+ ></r-select-input>
11
+ </r-col>
12
+ </r-row>
13
+ <r-float v-if="show" :minZoom="0.01" :zoom="0.7" bordered>
14
+ <template v-slot="{move,ease,transform}">
15
+ <div :class="{
16
16
  'tree-rotate':rotate
17
17
  }">
18
- <r-tree-element @update:model-value="$emit('update:modelValue',$event)"
19
- :link="link"
20
- :model-value="node"
21
- @expand="handleExpand(ease,move,transform,$event)"
22
- :expand="expand"
23
- :openAll="openAll"
24
- @select="handleSelect"
25
- >
26
- <template v-slot="{ item,nodeKey }">
27
- <slot :item="item" :nodeKey="nodeKey">{{item}}</slot>
28
- </template>
29
- </r-tree-element>
30
- </div>
18
+ <r-tree-element :expand="expand"
19
+ :link="link"
20
+ :model-value="node"
21
+ :openAll="openAll"
22
+ :sortBy="sortBy"
23
+ @expand="handleExpand(ease,move,transform,$event)"
24
+ @select="handleSelect"
25
+ @update:model-value="$emit('update:modelValue',$event)"
26
+ >
27
+ <template v-slot="{ item,nodeKey }">
28
+ <slot :item="item" :nodeKey="nodeKey">{{ item }}</slot>
31
29
  </template>
32
- </r-float>
33
- </r-container>
30
+ </r-tree-element>
31
+ </div>
32
+ </template>
33
+ </r-float>
34
+ </r-container>
34
35
 
35
36
  </template>
36
37
  <script>
37
38
 
38
39
  export default {
39
- name: 'r-tree',
40
- props: {
41
- modelValue: Object,
42
- link: String,
43
- searchLink: String,
44
- gen: String,
45
- selected: String,
46
- rotate: Boolean,
47
- expand: {
48
- type: Boolean,
49
- default: false
50
- },
51
- childsName: {
52
- type: String,
53
- default: 'childs'
54
- },
55
- openAll: Boolean,
56
- headers: Object
40
+ name: 'r-tree',
41
+ props: {
42
+ modelValue: Object,
43
+ link: String,
44
+ searchLink: String,
45
+ sortBy: {
46
+ type: String,
47
+ default: 'gen'
57
48
  },
58
- emits: ['update:modelValue', 'select-node'],
59
- data() {
60
- return {
61
- show: false,
62
- search: null,
63
- nodeParent: this.gen,
64
- node: this.modelValue
65
- }
49
+ gen: String,
50
+ selected: String,
51
+ rotate: Boolean,
52
+ expand: {
53
+ type: Boolean,
54
+ default: false
66
55
  },
67
- created() {
68
- if (this.modelValue) {
69
- this.show = true
70
- } else if (this.link) {
71
- this.get()
72
- }
56
+ childsName: {
57
+ type: String,
58
+ default: 'childs'
73
59
  },
74
- watch: {
75
- modelValue: function (newVal) {
76
- this.node = newVal
77
- }
60
+ openAll: Boolean,
61
+ headers: Object
62
+ },
63
+ emits: ['update:modelValue', 'select-node'],
64
+ data() {
65
+ return {
66
+ show: false,
67
+ search: null,
68
+ nodeParent: this.gen,
69
+ node: this.modelValue
70
+ }
71
+ },
72
+ created() {
73
+ if (this.modelValue) {
74
+ this.show = true
75
+ } else if (this.link) {
76
+ this.get()
77
+ }
78
+ },
79
+ watch: {
80
+ modelValue: function (newVal) {
81
+ this.node = newVal
82
+ }
83
+ },
84
+ computed: {
85
+ classes() {
86
+ let a = {'tree-searchable': this.searchLink}
87
+ a[`${this.$r.prefix}tree`] = true
88
+ return a
89
+ }
90
+ },
91
+ methods: {
92
+ change(e) {
93
+ if (e && "value" in e) {
94
+ this.nodeParent = e.value
95
+ this.show = false
96
+ this.get()
97
+ }
78
98
  },
79
- computed: {
80
- classes() {
81
- let a = {'tree-searchable': this.searchLink}
82
- a[`${this.$r.prefix}tree`] = true
83
- return a
84
- }
99
+ get() {
100
+ this.$axios.get(this.link + this.nodeParent, {headers: this.headers})
101
+ .then(({data}) => {
102
+ this.node = data
103
+ this.show = true
104
+ })
105
+ },
106
+ handleExpand(ease, move, transform, $event) {
107
+ const el = $event[1].getBoundingClientRect()
108
+ ease()
109
+ const node_info = $event[1].querySelector('.node-info').getBoundingClientRect()
110
+ const card_h = node_info.height
111
+ const card_w = node_info.width
112
+ const parent = this.$refs.tree.$el
113
+ const bb = this.$refs.tree.$el.getBoundingClientRect()
114
+ move(parent.offsetWidth / 2 - (el.left - bb.left + ($event[0] ? el.width / 2 : el.width - card_w / 2)),
115
+ parent.offsetHeight / 2 - (el.top - bb.top + (this.rotate ? el.height - card_h : card_h / 2)))
85
116
  },
86
- methods: {
87
- change(e) {
88
- if (e && "value" in e) {
89
- this.nodeParent = e.value
90
- this.show = false
91
- this.get()
92
- }
93
- },
94
- get() {
95
- this.$axios.get(this.link + this.nodeParent, {headers: this.headers})
96
- .then(({data}) => {
97
- this.node = data
98
- this.show = true
99
- })
100
- },
101
- handleExpand(ease, move, transform, $event) {
102
- const el = $event[1].getBoundingClientRect()
103
- ease()
104
- const node_info = $event[1].querySelector('.node-info').getBoundingClientRect()
105
- const card_h = node_info.height
106
- const card_w = node_info.width
107
- const parent = this.$refs.tree.$el
108
- const bb = this.$refs.tree.$el.getBoundingClientRect()
109
- move(parent.offsetWidth / 2 - (el.left - bb.left + ($event[0] ? el.width / 2 : el.width - card_w / 2)),
110
- parent.offsetHeight / 2 - (el.top - bb.top + (this.rotate ? el.height - card_h : card_h / 2)))
111
- },
112
- handleSelect(e) {
113
- this.$emit('select-node', e)
114
- }
117
+ handleSelect(e) {
118
+ this.$emit('select-node', e)
115
119
  }
120
+ }
116
121
  }
117
122
  </script>
118
123
  <style lang="scss">
@@ -120,31 +125,31 @@ export default {
120
125
 
121
126
  $distance: 20px;
122
127
  .#{base.$prefix}tree {
123
- position: relative;
124
- width: 100%;
125
- height: 100%;
128
+ position: relative;
129
+ width: 100%;
130
+ height: 100%;
126
131
 
127
- &.tree-searchable {
128
- .#{base.$prefix}float {
129
- height: calc(100% - 70px)
130
- }
132
+ &.tree-searchable {
133
+ .#{base.$prefix}float {
134
+ height: calc(100% - 70px)
131
135
  }
136
+ }
132
137
 
133
138
  .#{base.$prefix}float {
134
- direction: ltr;
135
- }
139
+ direction: ltr;
140
+ }
136
141
 
137
- .tree-rotate {
138
- transform: rotateX(180deg);
142
+ .tree-rotate {
143
+ transform: rotateX(180deg);
139
144
 
140
- .node-info {
141
- transform: rotateX(-180deg);
142
- }
145
+ .node-info {
146
+ transform: rotateX(-180deg);
147
+ }
143
148
 
144
- .tree-btn-expand {
145
- transform: rotateX(-180deg);
146
- }
149
+ .tree-btn-expand {
150
+ transform: rotateX(-180deg);
147
151
  }
152
+ }
148
153
 
149
154
  }
150
155
  </style>
@@ -107,10 +107,17 @@ export default {
107
107
  }
108
108
  const sortBy = this.sortBy
109
109
  s.sort(function (a, b) {
110
- if (a['value'][sortBy]) {
111
- return a['value'][sortBy].localeCompare(b['value'][sortBy]);
110
+ if (a['value'][sortBy] !== undefined) {
111
+ if (b['value'][sortBy] !== undefined) {
112
+ if (typeof a['value'][sortBy] === 'number' && typeof b['value'][sortBy] === 'number') {
113
+ return a['value'][sortBy] - b['value'][sortBy];
114
+ } else {
115
+ return String(a['value'][sortBy]).localeCompare(String(b['value'][sortBy]));
116
+ }
117
+ }
118
+ return -1;
112
119
  }
113
- return 1
120
+ return b['value'][sortBy] !== undefined ? 1 : 0;
114
121
  });
115
122
  const lng = s.length
116
123
  for (let i = 0; i < lng; i++) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "renusify",
3
- "version": "2.5.0",
3
+ "version": "2.5.1",
4
4
  "description": "Vue3 Framework",
5
5
  "keywords": [
6
6
  "vuejs",