renusify 2.5.1 → 3.0.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.
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 +208 -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 +140 -81
  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 +87 -47
  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 +72 -40
  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 +323 -164
  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 +83 -56
  70. package/components/form/timeInput/range.vue +116 -95
  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 +249 -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 +1 -2
  85. package/components/infinite/index.vue +248 -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 +201 -91
  90. package/components/meta/meta.js +26 -3
  91. package/components/modal/index.vue +383 -158
  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 +318 -156
  100. package/components/swiper/index.vue +254 -106
  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 +631 -401
  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 +107 -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 +244 -0
  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 +10 -8
  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 +154 -175
  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 +6 -1
  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 -710
  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
@@ -2,66 +2,75 @@
2
2
  <div class="d-flex flex-wrap h-space-around">
3
3
  <r-btn v-for="i in ls"
4
4
  :key="i"
5
- outlined
6
- class="w-25 ma-1"
5
+ class="btn-month ma-1"
7
6
  :class="{'color-one':i===modelValue}"
8
- @click.prevent="emit(i)">
7
+ @click.prevent="emitValue(i)">
9
8
  {{
10
- $d(new Date(year, i, 1, 0, timezoneOffset), 'month', locale)
9
+ $d(new Date(year, i, 1, 0, timezoneOffset), 'month', locale)
11
10
  }}
12
11
  </r-btn>
13
12
  </div>
14
13
  </template>
15
- <script>
16
- export default {
17
- name: 'month-tab',
18
- props: {
19
- modelValue: Number,
20
- timezoneOffset: Number,
21
- locale: String,
22
- month: Number,
23
- year: Number
24
- },
25
- emits: ['update:modelValue'],
26
- data() {
27
- return {
28
- ls: []
29
- }
30
- },
31
- beforeMount() {
32
- const year = this.$d(new Date(this.year, this.month, 5, 0, this.timezoneOffset), 'ye', this.locale)
33
- let ls = []
34
- let first = 0
35
- let n = 0
36
- while (true) {
37
- n++
38
- if (n > 100) {
39
- break
40
- }
41
- const y = this.$d(new Date(this.year, first, 5, 0, this.timezoneOffset), 'ye', this.locale)
42
- const m = parseInt(this.$d(new Date(this.year, first, 5, 0, this.timezoneOffset), 'me', this.locale))
43
- if (y === year && m === 1) {
44
- break
45
- }
46
- if (y > year) {
47
- first--
48
- } else if (y < year) {
49
- first++
50
- } else if (m > 1) {
51
- first--
52
- } else {
53
- first++
54
- }
55
- }
56
- for (let i = 0; i < 12; i++) {
57
- ls.push(first + i)
58
- }
59
- this.ls = ls
60
- },
61
- methods: {
62
- emit(n) {
63
- this.$emit('update:modelValue', n)
64
- }
14
+ <script setup>
15
+ import {ref, inject, onBeforeMount} from 'vue'
16
+
17
+ const props = defineProps({
18
+ modelValue: Number,
19
+ timezoneOffset: Number,
20
+ locale: String,
21
+ month: Number,
22
+ year: Number
23
+ })
24
+
25
+ const emit = defineEmits(['update:modelValue'])
26
+
27
+ const $d = inject('renusify').$d
28
+
29
+ const ls = ref([])
30
+
31
+ const emitValue = (n) => {
32
+ emit('update:modelValue', n)
33
+ }
34
+
35
+ const yearValue = $d(new Date(props.year, props.month, 5, 0, props.timezoneOffset), 'ye', props.locale)
36
+ let list = []
37
+ let first = 0
38
+ let n = 0
39
+
40
+ while (true) {
41
+ n++
42
+ if (n > 100) {
43
+ break
44
+ }
45
+
46
+ const y = $d(new Date(props.year, first, 5, 0, props.timezoneOffset), 'ye', props.locale)
47
+ const m = parseInt($d(new Date(props.year, first, 5, 0, props.timezoneOffset), 'me', props.locale))
48
+
49
+ if (y === yearValue && m === 1) {
50
+ break
51
+ }
52
+
53
+ if (y > yearValue) {
54
+ first--
55
+ } else if (y < yearValue) {
56
+ first++
57
+ } else if (m > 1) {
58
+ first--
59
+ } else {
60
+ first++
65
61
  }
66
62
  }
67
- </script>
63
+
64
+ for (let i = 0; i < 12; i++) {
65
+ list.push(first + i)
66
+ }
67
+
68
+ ls.value = list
69
+ </script>
70
+ <style lang="scss">
71
+ .btn-month {
72
+ width: 25%;
73
+ background-color: var(--color-sheet-container);
74
+ border: 1px solid var(--color-border-low);
75
+ }
76
+ </style>
@@ -2,41 +2,46 @@
2
2
  <div class="calendar-year-tab d-flex flex-wrap h-space-around">
3
3
  <r-btn v-for="i in 200"
4
4
  :key="i"
5
- class="w-25 ma-1"
5
+ class="btn-year ma-1"
6
6
  :class="{'color-one year-select':modelValue+i-100===modelValue}"
7
- outlined
8
- @click.prevent="emit(modelValue+i-100)">
7
+ @click.prevent="emitValue(modelValue+i-100)">
9
8
  {{
10
9
  $d(new Date(modelValue + i - 100, month, 5, 0, timezoneOffset), 'year', locale)
11
10
  }}
12
11
  </r-btn>
13
12
  </div>
14
13
  </template>
15
- <script>
16
- export default {
17
- name: 'year-tab',
18
- props: {
19
- modelValue: Number,
20
- timezoneOffset: Number,
21
- locale: String,
22
- month: Number
23
- },
24
- emits: ['update:modelValue'],
25
- mounted() {
26
- let el = document.querySelector('.year-select')
27
- if (el) {
28
- el.scrollIntoView(true)
29
- }
30
- },
31
- methods: {
32
- emit(n) {
33
- this.$emit('update:modelValue', n - this.modelValue)
34
- }
35
- }
14
+ <script setup>
15
+ import {onMounted} from 'vue'
16
+
17
+ const props = defineProps({
18
+ modelValue: Number,
19
+ timezoneOffset: Number,
20
+ locale: String,
21
+ month: Number
22
+ })
23
+
24
+ const emit = defineEmits(['update:modelValue'])
25
+
26
+ const emitValue = (n) => {
27
+ emit('update:modelValue', n - props.modelValue)
36
28
  }
29
+
30
+ onMounted(() => {
31
+ let el = document.querySelector('.year-select')
32
+ if (el) {
33
+ el.scrollIntoView(true)
34
+ }
35
+ })
37
36
  </script>
38
- <style>
37
+ <style lang="scss">
39
38
  .calendar-year-tab {
40
39
  max-height: 300px;
41
40
  }
41
+
42
+ .btn-year {
43
+ width: 25%;
44
+ background-color: var(--color-sheet-container);
45
+ border: 1px solid var(--color-border-low);
46
+ }
42
47
  </style>
@@ -2,69 +2,149 @@
2
2
  <component v-bind="att"
3
3
  :is="isClickable?route.tag:'div'"
4
4
  v-ripple="isClickable&&isRipple">
5
+ <!-- Default slot for card content
6
+ @example
7
+ <div class=pa-5>
8
+ <div class="title-1 color-one">title</div>
9
+ <div class="mt-5">body description</div>
10
+ </div>
11
+ -->
5
12
  <slot></slot>
6
13
  </component>
7
14
  </template>
8
15
 
9
- <script>
10
- import {roots} from '../../tools/rootable.js';
11
- import './style.scss';
12
-
13
- export default {
14
- name: 'r-card',
15
- mixins: [roots],
16
- props: {
17
- flat: Boolean,
18
- hover: Boolean,
19
- tile: Boolean,
20
- outlined: Boolean,
21
- isRipple: {
22
- type: Boolean,
23
- default: true
24
- },
25
- draggable: {
26
- type: Boolean,
27
- default: false
28
- }
29
- },
30
- computed: {
31
- att() {
32
- let res = {'class': this.genClass}
33
- if (this.href) {
34
- res['href'] = this.route.data.attrs.href
35
- }
36
-
37
- if (this.target) {
38
- res['rel'] = 'noreferrer'
39
- res['target'] = this.route.data.attrs.target
40
- }
41
- if (this.to) {
42
- res['to'] = this.route.data.props.to
43
- }
44
- return res
45
- },
46
- genClass() {
47
- let c = this.$r.prefix + 'card';
48
- if (this.flat) {
49
- c += ' card-flat';
50
- } else {
51
- c += ' card-sheet';
52
- }
53
- if (this.hover) {
54
- c += ' card-hover';
55
- }
56
- if (this.outlined) {
57
- c += ' card-outlined';
58
- }
59
- if (this.tile) {
60
- c += ' card-tile';
61
- }
62
- if (this.isClickable) {
63
- c += ' card-link';
64
- }
65
- return c;
66
- },
16
+ <script setup>
17
+ import {computed, inject, useAttrs} from 'vue'
18
+ import {useRootable} from '../../tools/root.js'
19
+
20
+ const $r = inject('renusify').$r;
21
+
22
+ const props = defineProps({
23
+ /**
24
+ * Removes elevation and background color
25
+ * @type {Boolean}
26
+ */
27
+ flat: Boolean,
28
+
29
+ /**
30
+ * Applies outlined border style
31
+ * @type {Boolean}
32
+ */
33
+ outlined: Boolean,
34
+
35
+ /**
36
+ * Enables ripple effect on click
37
+ * @type {Boolean}
38
+ * @default true
39
+ */
40
+ isRipple: {
41
+ type: Boolean,
42
+ default: true
67
43
  },
68
44
 
69
- };
45
+ /**
46
+ * Custom class for active state
47
+ * @type {String}
48
+ */
49
+ activeClass: String,
50
+
51
+ /**
52
+ * Disables the card
53
+ * @type {Boolean}
54
+ */
55
+ disabled: Boolean,
56
+
57
+ /**
58
+ * Custom class for exact active state
59
+ * @type {String}
60
+ */
61
+ exactActiveClass: String,
62
+
63
+ /**
64
+ * Applies link styling
65
+ * @type {Boolean}
66
+ */
67
+ link: Boolean,
68
+
69
+ /**
70
+ * URL for link card
71
+ * @type {String|Object}
72
+ */
73
+ href: [String, Object],
74
+
75
+ /**
76
+ * Route location for vue-router
77
+ * @type {String|Object}
78
+ */
79
+ to: [String, Object],
80
+
81
+ /**
82
+ * HTML tag to use for card element
83
+ * @type {String}
84
+ */
85
+ tag: String,
86
+
87
+ /**
88
+ * Target attribute for links
89
+ * @type {String}
90
+ */
91
+ target: String
92
+ })
93
+
94
+ const {route, isClickable} = useRootable(props, useAttrs())
95
+
96
+ const att = computed(() => {
97
+ let res = {
98
+ 'class': [$r.prefix + 'card', {
99
+ 'card-sheet': !props.flat && !props.outlined,
100
+ 'card-outlined': props.outlined
101
+ }]
102
+ }
103
+
104
+ if (props.href) {
105
+ res['href'] = route.value.data.attrs.href
106
+ }
107
+
108
+ if (props.target) {
109
+ res['rel'] = 'noreferrer'
110
+ res['target'] = route.value.data.attrs.target
111
+ }
112
+
113
+ if (props.to) {
114
+ res['to'] = route.value.data.props.to
115
+ }
116
+
117
+ return res
118
+ })
70
119
  </script>
120
+ <style lang="scss">
121
+ @use "sass:map";
122
+ @use "../../style" as *;
123
+
124
+
125
+ .#{$prefix}card {
126
+ display: block;
127
+ position: relative;
128
+ max-width: 100%;
129
+ outline: none;
130
+ text-decoration: none;
131
+ word-break: break-word;
132
+ overflow-wrap: break-word;
133
+ white-space: normal;
134
+ transition: $primary-transition;
135
+ transition-property: box-shadow, opacity;
136
+ border-radius: map.get($borders, 'sm');
137
+
138
+ &.card-sheet {
139
+ background-color: var(--color-sheet-container);
140
+ border: 1px solid var(--color-sheet-container-low);
141
+ color: var(--color-on-sheet);
142
+ }
143
+
144
+ &.card-outlined {
145
+ border: 1px solid var(--color-border-low);
146
+ }
147
+
148
+ @include states();
149
+ }
150
+ </style>
@@ -12,44 +12,43 @@
12
12
  </div>
13
13
  </template>
14
14
 
15
- <script>
16
- import mixin from './mixin.js'
17
- import mixin_h from '../highlight/mixin.js'
18
-
19
- export default {
20
- name: "highlight-css",
21
- props: {
22
- modelValue: String,
23
- },
24
- mixins: [mixin, mixin_h],
25
- data() {
26
- return {
27
- d: this.modelValue,
28
- code: "",
29
- };
30
- },
31
- async created() {
32
- if (this.modelValue) {
33
- await this.build_code()
34
- }
35
- },
36
- watch: {
37
- modelValue: function () {
38
- this.d = this.modelValue;
39
- },
40
- d: async function () {
41
- await this.build_code()
42
- this.$emit("update:modelValue", this.d);
43
- },
44
- },
45
- methods: {
46
- async build_code() {
47
- this.code = await this.highlight(this.d, "css", true)
48
- }
49
- },
50
- };
51
- </script>
15
+ <script setup>
16
+ import {ref, watch, onMounted} from 'vue'
17
+ import {useHighlight} from '../highlight/useHighlight.js'
18
+ import {useCodeFormatter} from './useCodeFormatter.js'
19
+
20
+ const props = defineProps({
21
+ modelValue: String
22
+ })
23
+
24
+ const emit = defineEmits(['update:modelValue'])
25
+
26
+ const {highlight} = useHighlight()
27
+ const {setTab} = useCodeFormatter()
52
28
 
53
- <style lang="scss">
29
+ const d = ref(props.modelValue || '')
30
+ const code = ref('')
54
31
 
55
- </style>
32
+ const build_code = async () => {
33
+ if (d.value) {
34
+ code.value = await highlight(d.value, "css", true)
35
+ } else {
36
+ code.value = ''
37
+ }
38
+ }
39
+
40
+ watch(() => props.modelValue, (newValue) => {
41
+ d.value = newValue
42
+ })
43
+
44
+ watch(d, async (newValue) => {
45
+ await build_code()
46
+ emit('update:modelValue', newValue)
47
+ }, {immediate: true})
48
+
49
+ onMounted(async () => {
50
+ if (props.modelValue) {
51
+ await build_code()
52
+ }
53
+ })
54
+ </script>
@@ -12,70 +12,70 @@
12
12
  </div>
13
13
  </template>
14
14
 
15
- <script>
16
- import mixin from './mixin.js'
17
- import mixin_h from '../highlight/mixin.js'
15
+ <script setup>
16
+ import {ref, watch, onMounted} from 'vue'
17
+ import {useHighlight} from '../highlight/useHighlight.js'
18
+ import {useCodeFormatter} from './useCodeFormatter.js'
18
19
 
19
- export default {
20
- name: "highlight-html",
21
- props: {
22
- modelValue: String,
23
- },
24
- mixins: [mixin, mixin_h],
25
- data() {
26
- return {
27
- d: this.modelValue,
28
- code: ""
29
- };
30
- },
31
- async created() {
32
- if (this.modelValue) {
33
- await this.build_code()
34
- }
35
- },
36
- watch: {
37
- modelValue: function () {
38
- this.d = this.modelValue;
39
- },
40
- d: async function () {
41
- await this.build_code()
42
- this.$emit("update:modelValue", this.d);
43
- },
44
- },
45
- methods: {
46
- async build_code() {
47
- this.code = await this.highlight(this.d, "html", true)
48
- },
49
- setKey(event) {
50
- if (event.key === "<") {
51
- this.openTag = event.target.selectionEnd
52
- return false
53
- } else if (event.key === "/" && this.openTag !== null && this.openTag + 1 === event.target.selectionEnd) {
54
- this.openTag = null
55
- return false
56
- } else if (event.key === ">" && this.openTag !== null) {
57
- const end = event.target.selectionEnd;
58
- const sel = event.target.value.substring(this.openTag + 1, end).trim().split(' ')[0];
59
- const t = `></${sel}>`
60
- event.preventDefault()
61
- document.execCommand('insertText', false, t);
62
- event.target.selectionEnd = end + 1;
63
- this.openTag = null
64
- return false
65
- }
66
- if (event.key === "=") {
67
- const end = event.target.selectionEnd;
68
- event.preventDefault()
69
- document.execCommand('insertText', false, '=""');
70
- event.target.selectionEnd = end + 2;
71
- return false;
72
- }
73
- return this.setTab(event)
74
- }
75
- },
76
- };
77
- </script>
20
+ const props = defineProps({
21
+ modelValue: String
22
+ })
23
+
24
+ const emit = defineEmits(['update:modelValue'])
25
+
26
+ const {highlight} = useHighlight()
27
+ const {setTab} = useCodeFormatter()
28
+
29
+ const d = ref(props.modelValue || '')
30
+ const code = ref('')
31
+ const openTag = ref(null)
32
+ const build_code = async () => {
33
+ if (d.value) {
34
+ code.value = await highlight(d.value, "html", true)
35
+ } else {
36
+ code.value = ''
37
+ }
38
+ }
78
39
 
79
- <style lang="scss">
40
+ const setKey = (event) => {
41
+ if (event.key === "<") {
42
+ openTag.value = event.target.selectionEnd
43
+ return false
44
+ } else if (event.key === "/" && openTag.value !== null && openTag.value + 1 === event.target.selectionEnd) {
45
+ openTag.value = null
46
+ return false
47
+ } else if (event.key === ">" && openTag.value !== null) {
48
+ const end = event.target.selectionEnd;
49
+ const sel = event.target.value.substring(openTag.value + 1, end).trim().split(' ')[0];
50
+ const t = `></${sel}>`
51
+ event.preventDefault()
52
+ document.execCommand('insertText', false, t);
53
+ event.target.selectionEnd = end + 1;
54
+ openTag.value = null
55
+ return false
56
+ }
57
+ if (event.key === "=") {
58
+ const end = event.target.selectionEnd;
59
+ event.preventDefault()
60
+ document.execCommand('insertText', false, '=""');
61
+ event.target.selectionEnd = end + 2;
62
+ return false;
63
+ }
64
+ return setTab(event)
65
+ }
80
66
 
81
- </style>
67
+ watch(() => props.modelValue, (newValue) => {
68
+ d.value = newValue
69
+ })
70
+
71
+ watch(d, async (newValue) => {
72
+ await build_code()
73
+ emit('update:modelValue', newValue)
74
+ }, {immediate: true})
75
+
76
+ onMounted(async () => {
77
+ if (props.modelValue) {
78
+ await build_code()
79
+ }
80
+ })
81
+ </script>