renusify 2.5.2 → 3.0.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.
Files changed (212) hide show
  1. package/components/app/index.vue +74 -22
  2. package/components/app/toast/index.vue +76 -71
  3. package/components/app/toast/toast.vue +62 -44
  4. package/components/avatar/index.vue +207 -84
  5. package/components/button/buttonConfirm.vue +53 -26
  6. package/components/button/buttonGroup.js +0 -2
  7. package/components/button/buttonGroup.vue +310 -62
  8. package/components/button/index.vue +584 -100
  9. package/components/calendar/index.js +0 -2
  10. package/components/calendar/index.vue +326 -262
  11. package/components/calendar/month.vue +64 -55
  12. package/components/calendar/year.vue +30 -25
  13. package/components/card/index.vue +139 -59
  14. package/components/codeEditor/highlightCss.vue +38 -39
  15. package/components/codeEditor/highlightHtml.vue +64 -64
  16. package/components/codeEditor/highlightJs.vue +37 -38
  17. package/components/codeEditor/index.vue +129 -79
  18. package/components/codeEditor/run.vue +225 -39
  19. package/components/codeEditor/useCodeFormatter.js +150 -0
  20. package/components/confirm/index.vue +139 -80
  21. package/components/container/col.vue +5 -4
  22. package/components/container/divider.vue +28 -19
  23. package/components/container/index.vue +34 -15
  24. package/components/container/row.vue +26 -9
  25. package/components/container/spacer.vue +2 -4
  26. package/components/container/style.scss +3 -0
  27. package/components/content/index.vue +49 -32
  28. package/components/cropper/index.vue +401 -244
  29. package/components/float/index.vue +542 -415
  30. package/components/form/addressInput/index.vue +184 -109
  31. package/components/form/camInput/index.vue +370 -244
  32. package/components/form/checkInput/index.vue +138 -71
  33. package/components/form/checkboxInput/index.vue +93 -49
  34. package/components/form/colorInput/Alpha.vue +81 -83
  35. package/components/form/colorInput/Hue.vue +91 -68
  36. package/components/form/colorInput/Preview.vue +43 -47
  37. package/components/form/colorInput/Saturation.vue +101 -86
  38. package/components/form/colorInput/index.vue +71 -39
  39. package/components/form/colorInput/picker.vue +111 -106
  40. package/components/form/colorInput/useColor.js +153 -0
  41. package/components/form/dateInput/index.vue +691 -356
  42. package/components/form/dateInput/month.vue +63 -54
  43. package/components/form/dateInput/year.vue +35 -25
  44. package/components/form/fileInput/index.js +0 -1
  45. package/components/form/fileInput/index.vue +263 -106
  46. package/components/form/fileInput/single.vue +332 -168
  47. package/components/form/groupInput/index.vue +199 -101
  48. package/components/form/index.vue +189 -83
  49. package/components/form/input/index.vue +416 -377
  50. package/components/form/jsonInput/JsonView.vue +54 -56
  51. package/components/form/jsonInput/index.vue +247 -165
  52. package/components/form/maskInput/index.vue +252 -132
  53. package/components/form/numberInput/index.js +0 -1
  54. package/components/form/numberInput/index.vue +226 -117
  55. package/components/form/passwordInput/index.js +2 -1
  56. package/components/form/passwordInput/index.vue +269 -102
  57. package/components/form/radioInput/index.vue +143 -72
  58. package/components/form/rangeInput/index.vue +280 -167
  59. package/components/form/ratingInput/index.vue +57 -57
  60. package/components/form/selectInput/index.js +1 -3
  61. package/components/form/selectInput/index.vue +584 -296
  62. package/components/form/switchInput/index.vue +73 -59
  63. package/components/form/telInput/index.js +0 -1
  64. package/components/form/telInput/index.vue +238 -135
  65. package/components/form/textArea/index.vue +72 -35
  66. package/components/form/textEditor/index.vue +739 -0
  67. package/components/form/{text-editor → textEditor}/style.scss +8 -16
  68. package/components/form/textInput/index.vue +54 -32
  69. package/components/form/timeInput/index.vue +82 -55
  70. package/components/form/timeInput/range.vue +115 -94
  71. package/components/form/timeInput/timepicker.vue +382 -449
  72. package/components/form/uniqueInput/index.vue +105 -48
  73. package/components/form/unitInput/index.vue +139 -84
  74. package/components/formCreator/index.js +0 -1
  75. package/components/formCreator/index.vue +314 -148
  76. package/components/highlight/index.vue +41 -25
  77. package/components/highlight/style.scss +2 -2
  78. package/components/highlight/{mixin.js → useHighlight.js} +181 -160
  79. package/components/icon/index.vue +79 -33
  80. package/components/img/index.vue +250 -147
  81. package/components/img/preview.vue +180 -198
  82. package/components/img/svgImg.vue +42 -39
  83. package/components/index.js +5 -20
  84. package/components/infinite/index.js +3 -3
  85. package/components/infinite/index.vue +290 -66
  86. package/components/map/index.vue +428 -261
  87. package/components/map/route.vue +794 -487
  88. package/components/map/select.vue +118 -58
  89. package/components/menu/index.vue +206 -94
  90. package/components/meta/meta.js +26 -3
  91. package/components/modal/index.vue +382 -156
  92. package/components/notify/index.vue +204 -86
  93. package/components/notify/notification.vue +38 -55
  94. package/components/progress/circle.vue +189 -70
  95. package/components/progress/line.vue +266 -46
  96. package/components/searchBox/index.js +1 -3
  97. package/components/searchBox/index.vue +194 -101
  98. package/components/skeleton/index.vue +45 -20
  99. package/components/slider/index.vue +319 -156
  100. package/components/swiper/index.vue +237 -108
  101. package/components/table/crud/footer.vue +77 -53
  102. package/components/table/crud/header.vue +71 -72
  103. package/components/table/crud/index.vue +629 -399
  104. package/components/table/index.vue +721 -278
  105. package/components/timeAgo/index.vue +145 -96
  106. package/components/tour/index.vue +338 -235
  107. package/components/tree/index.vue +235 -89
  108. package/components/tree/tree-element.vue +106 -106
  109. package/directive/animate/index.js +77 -0
  110. package/directive/clickOutSide/index.js +98 -0
  111. package/directive/drag/index.js +153 -0
  112. package/directive/index.js +11 -13
  113. package/directive/intersect/index.js +263 -0
  114. package/directive/mask/index.js +67 -0
  115. package/directive/parallax/index.js +78 -0
  116. package/directive/ripple/index.js +14 -0
  117. package/directive/scroll/index.js +272 -24
  118. package/directive/sortable/index.js +274 -0
  119. package/directive/title/index.js +75 -0
  120. package/directive/touch/index.js +268 -0
  121. package/index.js +11 -19
  122. package/package.json +5 -2
  123. package/plugins/validation/Validate.js +88 -79
  124. package/scripts/generate-docs.mjs +226 -0
  125. package/scripts/menu.mjs +240 -0
  126. package/scripts/parser.mjs +1086 -0
  127. package/style/_index.scss +7 -0
  128. package/style/app.scss +13 -65
  129. package/style/colors.scss +5 -22
  130. package/style/functions/index.scss +8 -0
  131. package/style/mixins/index.scss +17 -5
  132. package/style/variables/base.scss +155 -178
  133. package/style/variables/color.scss +0 -12
  134. package/style/variables/utilities.scss +0 -180
  135. package/tools/helper.js +0 -8
  136. package/tools/icons.js +7 -2
  137. package/tools/root.js +71 -0
  138. package/components/app/style.scss +0 -41
  139. package/components/app/toast/style.scss +0 -20
  140. package/components/avatar/style.scss +0 -32
  141. package/components/bar/bottomNav.js +0 -1
  142. package/components/bar/bottomNav.vue +0 -28
  143. package/components/bar/bottomNavigationCircle.js +0 -2
  144. package/components/bar/bottomNavigationCircle.vue +0 -99
  145. package/components/bar/scss/bottomNav.scss +0 -67
  146. package/components/bar/scss/toolbar.scss +0 -174
  147. package/components/bar/toolbar/index.js +0 -8
  148. package/components/bar/toolbar/index.vue +0 -35
  149. package/components/bar/toolbar/laptop.vue +0 -33
  150. package/components/bar/toolbar/menuChilds.vue +0 -41
  151. package/components/bar/toolbar/menuLaptop.vue +0 -41
  152. package/components/bar/toolbar/menuMob.vue +0 -39
  153. package/components/bar/toolbar/mixin.js +0 -43
  154. package/components/bar/toolbar/mobile.vue +0 -34
  155. package/components/breadcrumb/bredcrumbItem.vue +0 -39
  156. package/components/breadcrumb/index.js +0 -3
  157. package/components/breadcrumb/index.vue +0 -71
  158. package/components/breadcrumb/style.scss +0 -51
  159. package/components/button/style.scss +0 -411
  160. package/components/card/style.scss +0 -86
  161. package/components/chart/chart.js +0 -1
  162. package/components/chart/chart.vue +0 -69
  163. package/components/chart/worldMap.js +0 -2
  164. package/components/chart/worldMap.vue +0 -1112
  165. package/components/chat/MessageList.vue +0 -163
  166. package/components/chat/chatInput.vue +0 -150
  167. package/components/chat/chatMsg.vue +0 -276
  168. package/components/chat/index.js +0 -11
  169. package/components/chat/index.vue +0 -113
  170. package/components/chip/index.js +0 -3
  171. package/components/chip/index.vue +0 -77
  172. package/components/chip/style.scss +0 -199
  173. package/components/codeEditor/mixin.js +0 -145
  174. package/components/countdown/index.js +0 -1
  175. package/components/countdown/index.vue +0 -105
  176. package/components/form/colorInput/mixin.js +0 -132
  177. package/components/form/fileInput/file.js +0 -148
  178. package/components/form/telInput/assets/flags.png +0 -0
  179. package/components/form/telInput/assets/flags@2x.png +0 -0
  180. package/components/form/text-editor/index.vue +0 -705
  181. package/components/icon/style.scss +0 -17
  182. package/components/infinite/div.js +0 -6
  183. package/components/infinite/div.vue +0 -193
  184. package/components/infinite/page.js +0 -3
  185. package/components/infinite/page.vue +0 -105
  186. package/components/list/index.js +0 -3
  187. package/components/list/index.vue +0 -122
  188. package/components/list/style.scss +0 -66
  189. package/components/message/index.js +0 -4
  190. package/components/message/index.vue +0 -40
  191. package/components/modal/style.scss +0 -146
  192. package/components/nestable/NestableItem.vue +0 -307
  193. package/components/nestable/editable.js +0 -44
  194. package/components/nestable/index.js +0 -1
  195. package/components/nestable/index.vue +0 -226
  196. package/components/nestable/methods.js +0 -416
  197. package/components/progress/style.scss +0 -229
  198. package/components/table/style.scss +0 -338
  199. package/components/tabs/index.js +0 -3
  200. package/components/tabs/index.vue +0 -151
  201. package/components/timeline/index.js +0 -6
  202. package/components/timeline/index.vue +0 -76
  203. package/directive/resize/index.js +0 -30
  204. package/directive/skeleton/index.js +0 -27
  205. package/directive/skeleton/style.scss +0 -37
  206. package/plugins/request/Request.js +0 -68
  207. package/style/animation.scss +0 -94
  208. package/style/style.scss +0 -8
  209. package/tools/rootable.js +0 -75
  210. /package/components/form/{text-editor → textEditor}/index.js +0 -0
  211. /package/components/form/{text-editor → textEditor}/preview.js +0 -0
  212. /package/components/form/{text-editor → textEditor}/preview.vue +0 -0
@@ -4,26 +4,18 @@
4
4
 
5
5
 
6
6
  .#{base.$prefix}text-editor {
7
- &:not(.text-editor-preview) {
8
- background-color: var(--color-sheet-container);
9
- margin-top: 20px;
7
+ > .input-control {
8
+ height: auto;
10
9
  }
11
10
 
12
- &.input-tile {
13
- border-radius: map.get(base.$borders, 'sm');
14
- }
15
-
16
- &:not(.input-tile) {
17
- border-radius: map.get(base.$borders, 'xl');
18
-
19
- .editor-content {
20
- border-radius: map.get(base.$borders, 'lg');
21
- }
11
+ .#{base.$prefix}button-group {
12
+ box-shadow: none;
13
+ border: 1px solid var(--color-sheet-low);
22
14
  }
23
15
 
24
- .editor-content, .input-control {
16
+ .editor-content, .class-select .input-control {
25
17
  border: 1px solid var(--color-sheet-low);
26
- background-color: var(--color-sheet-container-low);
18
+ background-color: var(--color-sheet);
27
19
  }
28
20
 
29
21
  @include mixins.typography(base.$headings, 'body-2');
@@ -62,7 +54,7 @@
62
54
  .img-holder {
63
55
  display: inline-block;
64
56
  position: relative;
65
-
57
+ border: 1px solid var(--color-sheet-low);
66
58
  .#{base.$prefix}btn {
67
59
  position: absolute;
68
60
  top: 0;
@@ -1,50 +1,72 @@
1
1
  <template>
2
2
  <r-input :active="active"
3
3
  v-model="lazyValue"
4
- @update:model-value="emit"
4
+ @update:model-value="emitValue"
5
5
  @click.prevent="handleClick">
6
- <input :autofocus="autofocus"
6
+ <input :autofocus="$attrs.autofocus"
7
+ :placeholder="$attrs.placeholder"
7
8
  :type="type"
8
9
  @focusin="active=true"
9
10
  @focusout="active=false"
10
- @input="emit"
11
+ @input="emitValue"
11
12
  autocomplete="no"
12
13
  ref="input"
13
14
  v-model="lazyValue"
14
15
  />
15
16
  </r-input>
16
17
  </template>
17
- <script>
18
- export default {
19
- name: 'r-text-input',
20
- props: {
21
- type: {
22
- type: String,
23
- default: 'text'
24
- },
25
- modelValue: [String, Number],
26
- autofocus: Boolean,
27
- },
28
- emits:['update:modelValue'],
29
- data () {
30
- return {
31
- lazyValue: this.modelValue,
32
- active: false
33
- }
34
- },
35
- watch: {
36
- modelValue () {
37
- this.lazyValue = this.modelValue
38
- }
18
+ <script setup>
19
+ import {ref, watch} from 'vue'
20
+
21
+ const props = defineProps({
22
+ /**
23
+ * Input type (text, number, email, etc.)
24
+ * @type {String}
25
+ * @default 'text'
26
+ */
27
+ type: {
28
+ type: String,
29
+ default: 'text'
39
30
  },
40
- methods: {
41
- handleClick (e) {
42
- this.$refs.input.focus()
43
- },
44
- emit(){
45
- this.$emit('update:modelValue', this.lazyValue)
46
- }
31
+ /**
32
+ * The model value of the input
33
+ * @type {String|Number}
34
+ */
35
+ modelValue: [String, Number]
36
+ })
37
+
38
+ const emit = defineEmits([
39
+ /**
40
+ * Emitted when the input value changes
41
+ * @param {String|Number} value - The updated input value
42
+ */
43
+ 'update:modelValue'
44
+ ])
45
+
46
+ // Reactive data
47
+ const lazyValue = ref(props.modelValue)
48
+ const active = ref(false)
49
+ const input = ref(null)
50
+
51
+ // Watchers
52
+ watch(() => props.modelValue, (newValue) => {
53
+ lazyValue.value = newValue
54
+ })
55
+
56
+ // Methods
57
+ /**
58
+ * Focuses the input element
59
+ */
60
+ const handleClick = () => {
61
+ if (input.value) {
62
+ input.value.focus()
47
63
  }
48
64
  }
49
65
 
66
+ /**
67
+ * Emits the updated value to the parent component
68
+ */
69
+ const emitValue = () => {
70
+ emit('update:modelValue', lazyValue.value)
71
+ }
50
72
  </script>
@@ -1,21 +1,20 @@
1
1
  <template>
2
- <div :class="`${$r.prefix}timepicker`">
3
- <r-input
4
- v-bind="$attrs"
5
- :active="active"
6
- :model-value="lazyValue"
7
- @click.prevent="show_modal = true"
8
- >
9
- <input
10
- type="text"
11
- @focusin="active = true"
12
- @focusout="active = false"
13
- @input="emit"
14
- autocomplete="no"
15
- ref="input"
16
- v-model="lazyValue"
17
- />
18
- </r-input>
2
+ <r-input
3
+ :active="active"
4
+ :class="`${$r.prefix}timepicker`"
5
+ :model-value="lazyValue"
6
+ @click.prevent="show_modal = true"
7
+ >
8
+ <input
9
+ ref="inputRef"
10
+ v-model="lazyValue"
11
+ :placeholder="$attrs.placeholder"
12
+ autocomplete="no"
13
+ readonly
14
+ type="text"
15
+ @focusin="active = true"
16
+ @focusout="active = false"
17
+ />
19
18
  <r-modal
20
19
  class="modal-timepicker"
21
20
  v-model="show_modal"
@@ -34,7 +33,7 @@
34
33
  <r-btn
35
34
  class="color-success-text"
36
35
  outlined
37
- @click.prevent="show_modal = false,emit()"
36
+ @click.prevent="show_modal = false,emitValue()"
38
37
  >
39
38
  {{ $t('accept', 'renusify') }}
40
39
  </r-btn
@@ -42,7 +41,7 @@
42
41
  <r-btn
43
42
  class="color-warning-text"
44
43
  outlined
45
- @click.prevent="(show_modal = false), (lazyValue = null),emit()"
44
+ @click.prevent="(show_modal = false), (lazyValue = null),emitValue()"
46
45
  >
47
46
  {{ $t('cancel', 'renusify') }}
48
47
  </r-btn
@@ -50,52 +49,80 @@
50
49
  </div>
51
50
  </div>
52
51
  </r-modal>
53
- </div>
52
+ </r-input>
53
+
54
54
  </template>
55
55
 
56
- <script>
57
- import {defineAsyncComponent} from 'vue'
56
+ <script setup>
57
+ import {ref, watch} from 'vue'
58
+ import Timepicker from "./timepicker.vue"
58
59
 
59
- export default {
60
- name: "r-time-picker",
61
- components: {Timepicker:defineAsyncComponent(()=>import('./timepicker.vue'))},
62
- props: {
63
- disableTime: {
64
- type: Function, default: () => {
65
- return false
66
- }
67
- },
68
- withSec: Boolean,
69
- is24Hour: {type: Boolean, default: true},
70
- noOverlay: Boolean,
71
- modelValue: String
72
- },
73
- emits: ['update:modelValue'],
74
- data() {
75
- return {
76
- active: false,
77
- show_modal: false,
78
- lazyValue: this.modelValue
79
- };
60
+ const props = defineProps({
61
+ /**
62
+ * Function to disable specific times
63
+ * @type {Function}
64
+ * @default () => false
65
+ */
66
+ disableTime: {
67
+ type: Function,
68
+ default: () => false
80
69
  },
81
- watch: {
82
- modelValue: function () {
83
- this.lazyValue = this.modelValue
84
- }
70
+ /**
71
+ * Show seconds picker in addition to hours and minutes
72
+ * @type {Boolean}
73
+ */
74
+ withSec: Boolean,
75
+ /**
76
+ * Use 24-hour format instead of 12-hour AM/PM format
77
+ * @type {Boolean}
78
+ * @default true
79
+ */
80
+ is24Hour: {
81
+ type: Boolean,
82
+ default: true
85
83
  },
86
- methods: {
87
- emit() {
88
- this.$emit("update:modelValue", this.lazyValue);
89
- }
90
- }
91
- };
84
+ /**
85
+ * Disable the overlay background when picker is open
86
+ * @type {Boolean}
87
+ */
88
+ noOverlay: Boolean,
89
+ /**
90
+ * The model value in time string format (HH:MM or HH:MM:SS)
91
+ * @type {String}
92
+ */
93
+ modelValue: String
94
+ })
95
+
96
+ const emit = defineEmits([
97
+ /**
98
+ * Emitted when the time value changes
99
+ * @param {String} value - The updated time value
100
+ */
101
+ 'update:modelValue'
102
+ ])
103
+
104
+ // Reactive data
105
+ const active = ref(false)
106
+ const show_modal = ref(false)
107
+ const lazyValue = ref(props.modelValue || '')
108
+
109
+ // Methods
110
+ /**
111
+ * Emits the updated time value to the parent component
112
+ */
113
+ const emitValue = () => {
114
+ emit('update:modelValue', lazyValue.value)
115
+ }
116
+
117
+ // Watchers
118
+ watch(() => props.modelValue, (newValue) => {
119
+ lazyValue.value = newValue || ''
120
+ })
92
121
  </script>
93
122
 
94
123
  <style lang="scss">
95
124
  .modal-timepicker {
96
125
  .modal-mini {
97
- background-color: var(--color-sheet-container-high);
98
- color: var(--color-on-sheet);
99
126
  max-width: 285px !important;
100
127
  }
101
128
  }
@@ -1,28 +1,27 @@
1
1
  <template>
2
- <div :class="`${$r.prefix}timepicker-range`">
3
2
  <r-input
4
- v-bind="$attrs"
3
+ :class="`${$r.prefix}timepicker-range`"
5
4
  :active="active"
6
5
  :model-value="lazyValue[1]"
7
- @click.prevent="show_modal = true"
6
+ @click.prevent="openPicker('from')"
8
7
  >
9
8
  <input
10
9
  type="text"
10
+ :placeholder="$attrs.placeholder"
11
11
  @focusin="active = true"
12
12
  @focusout="active = false"
13
13
  autocomplete="no"
14
14
  ref="input"
15
15
  :value="strVal"
16
16
  />
17
- </r-input>
18
- <r-modal
17
+ <r-modal
19
18
  class="modal-timepicker"
20
19
  v-model="show_modal"
21
20
  no-close-btn
22
21
  :no-overlay="noOverlay"
23
22
  >
24
23
  <div class="pt-3">
25
- <div class="px-2 title">
24
+ <div class="pa-2 title-1 text-center">
26
25
  <span>{{ $t('from', 'renusify') }}: </span>
27
26
  <span v-if="lazyValue[0]">{{ lazyValue[0] }} - </span>
28
27
  <span>{{ $t('to', 'renusify') }}: </span>
@@ -43,119 +42,141 @@
43
42
  :disableTime="disableTime"
44
43
  v-model="lazyValue[1]"
45
44
  ></timepicker>
46
- <div class="mt-3 d-flex h-space-between">
45
+
46
+ <div class="my-3 d-flex h-space-between px-3">
47
47
  <r-btn
48
48
  class="color-success-text"
49
49
  outlined
50
50
  @click.prevent="accept"
51
51
  >
52
- {{ $t('accept', 'renusify') }}
52
+ {{ $t(state === 'to' ? 'accept' : 'next', 'renusify') }}
53
53
  </r-btn>
54
54
  <r-btn
55
55
  class="color-warning-text"
56
56
  outlined
57
- @click.prevent="(show_modal = false), (lazyValue = []),emit()"
57
+ @click.prevent="(show_modal = false),clear()"
58
58
  >
59
59
  {{ $t('cancel', 'renusify') }}
60
60
  </r-btn>
61
61
  </div>
62
62
  </div>
63
63
  </r-modal>
64
- </div>
64
+ </r-input>
65
65
  </template>
66
66
 
67
- <script>
68
- import {defineAsyncComponent} from 'vue'
69
-
70
- export default {
71
- name: "r-time-picker-range",
72
- components: {Timepicker:defineAsyncComponent(()=>import('./timepicker.vue'))},
73
- props: {
74
- withSec: Boolean,
75
- noOverlay: Boolean,
76
- modelValue: Array
77
- },
78
- emits:['update:modelValue'],
79
- data() {
80
- return {
81
- state: 'from',
82
- active: false,
83
- show_modal: false,
84
- lazyValue: this.modelValue || []
85
- };
86
- },
87
- watch: {
88
- modelValue: function () {
89
- this.lazyValue = this.modelValue
90
- }
91
- },
92
- computed: {
93
- strVal() {
94
- if (this.lazyValue.length > 0) {
95
- return this.lazyValue[0] + ' - ' + this.lazyValue[1]
96
- }
97
- return ''
98
- },
99
- fromH() {
100
- if (!this.lazyValue[0]) {
101
- return 0
102
- }
103
- return this.lazyValue[0].split(':')[0]
104
- },
105
- fromM() {
106
- if (!this.lazyValue[0]) {
107
- return 0
108
- }
109
- return this.lazyValue[0].split(':')[1]
110
- },
111
- fromS() {
112
- if (!this.lazyValue[0]) {
113
- return 0
67
+ <script setup>
68
+ import {ref, watch, computed} from 'vue'
69
+ import Timepicker from "./timepicker.vue";
70
+
71
+ const props = defineProps({
72
+ withSec: Boolean,
73
+ noOverlay: Boolean,
74
+ modelValue: {
75
+ type: Array,
76
+ default: () => []
77
+ }
78
+ })
79
+
80
+ const emit = defineEmits(['update:modelValue'])
81
+
82
+ const state = ref('from') // 'from' or 'to'
83
+ const active = ref(false)
84
+ const show_modal = ref(false)
85
+ const lazyValue = ref(props.modelValue || [])
86
+
87
+
88
+ const strVal = computed(() => {
89
+ if (lazyValue.value.length >= 2) {
90
+ return `${lazyValue.value[0] || ''} - ${lazyValue.value[1] || ''}`
91
+ }
92
+ return ''
93
+ })
94
+
95
+ const fromH = computed(() => {
96
+ if (!lazyValue.value[0]) return 0
97
+ return parseInt(lazyValue.value[0].split(':')[0]) || 0
98
+ })
99
+
100
+ const fromM = computed(() => {
101
+ if (!lazyValue.value[0]) return 0
102
+ return parseInt(lazyValue.value[0].split(':')[1]) || 0
103
+ })
104
+
105
+ const fromS = computed(() => {
106
+ if (!lazyValue.value[0]) return 0
107
+ return parseInt(lazyValue.value[0].split(':')[2]) || 0
108
+ })
109
+
110
+ const str2int = (s) => {
111
+ if (!s) return 0
112
+ return parseInt(s.replace(/:/g, '')) || 0
113
+ }
114
+
115
+ const disableTime = (n, t, h, m) => {
116
+ if (state.value !== 'to') return false
117
+
118
+ if (t === 'hours24') {
119
+ return n < fromH.value
120
+ }
121
+
122
+ if (t === 'mins') {
123
+ if (h.toString() === fromH.value.toString()) {
124
+ if (props.withSec) {
125
+ return n < fromM.value
126
+ } else {
127
+ return n <= fromM.value
114
128
  }
115
- return this.lazyValue[0].split(':')[2]
116
129
  }
117
- },
118
- methods: {
119
- disableTime(n, t, h, m) {
120
- if (t === 'hours24' && n < this.fromH && n > 0) {
121
- return true
122
- }
130
+ }
123
131
 
124
- if (t === 'mins' && h.toString() === this.fromH && (this.withSec ? n < this.fromM : n <= this.fromM)) {
125
- return true
126
- }
132
+ if (props.withSec && t === 'seconds') {
133
+ if (h.toString() === fromH.value.toString() && m.toString() === fromM.value.toString()) {
134
+ return n <= fromS.value
135
+ }
136
+ }
127
137
 
128
- if (this.withSec) {
129
- if (t === 'seconds' && h.toString() === this.fromH && m.toString() === this.fromM && n <= this.fromS) {
130
- return true
131
- }
132
- }
133
- },
134
- str2int(s) {
135
- if (!s) {
136
- return 0
137
- }
138
- return parseInt(this.$helper.replacer(s, ':', ''))
139
- },
140
- accept() {
141
- if (this.state === 'to') {
142
- if (this.lazyValue.length === 2 && this.str2int(this.lazyValue[0]) < this.str2int(this.lazyValue[1])) {
143
- this.state = 'from'
144
- this.show_modal = false
145
- this.emit()
146
- } else {
147
- console.error(`from:${this.str2int(this.lazyValue[0])} > to:${this.str2int(this.lazyValue[1])}`)
148
- }
138
+ return false
139
+ }
140
+
141
+ const accept = () => {
142
+ if (state.value === 'to') {
143
+ if (lazyValue.value.length >= 2) {
144
+ const fromTimeInt = str2int(lazyValue.value[0])
145
+ const toTimeInt = str2int(lazyValue.value[1])
146
+
147
+ if (fromTimeInt < toTimeInt) {
148
+ state.value = 'from'
149
+ show_modal.value = false
150
+ emitValue()
149
151
  } else {
150
- this.state = 'to'
152
+ console.error(`From time (${fromTimeInt}) must be before To time (${toTimeInt})`)
151
153
  }
152
-
153
- },
154
- emit() {
155
- this.$emit("update:modelValue", this.lazyValue);
156
154
  }
155
+ } else {
156
+ state.value = 'to'
157
157
  }
158
- };
158
+ }
159
+
160
+ const emitValue = () => {
161
+ emit('update:modelValue', lazyValue.value)
162
+ }
163
+
164
+ const openPicker = (type = 'from') => {
165
+ state.value = type
166
+ show_modal.value = true
167
+ active.value = true
168
+ }
169
+
170
+ const clear = () => {
171
+ lazyValue.value = []
172
+ state.value = 'from'
173
+ emitValue()
174
+ }
175
+
176
+ watch(() => props.modelValue, (newValue) => {
177
+ lazyValue.value = newValue || []
178
+ }, {deep: true})
179
+
159
180
  </script>
160
181
 
161
182
  <style lang="scss">