@xenknight/framework7-vue 0.0.2

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 (199) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +33 -0
  3. package/components/accordion-content.d.ts +46 -0
  4. package/components/accordion-content.js +22 -0
  5. package/components/accordion-item.d.ts +51 -0
  6. package/components/accordion-item.js +77 -0
  7. package/components/accordion-toggle.d.ts +46 -0
  8. package/components/accordion-toggle.js +22 -0
  9. package/components/accordion.d.ts +50 -0
  10. package/components/accordion.js +23 -0
  11. package/components/actions-button.d.ts +56 -0
  12. package/components/actions-button.js +58 -0
  13. package/components/actions-group.d.ts +46 -0
  14. package/components/actions-group.js +22 -0
  15. package/components/actions-label.d.ts +51 -0
  16. package/components/actions-label.js +36 -0
  17. package/components/actions.d.ts +109 -0
  18. package/components/actions.js +157 -0
  19. package/components/app.d.ts +310 -0
  20. package/components/app.js +267 -0
  21. package/components/area-chart.d.ts +88 -0
  22. package/components/area-chart.js +364 -0
  23. package/components/badge.d.ts +54 -0
  24. package/components/badge.js +29 -0
  25. package/components/block-footer.d.ts +46 -0
  26. package/components/block-footer.js +22 -0
  27. package/components/block-header.d.ts +46 -0
  28. package/components/block-header.js +22 -0
  29. package/components/block-title.d.ts +54 -0
  30. package/components/block-title.js +35 -0
  31. package/components/block.d.ts +163 -0
  32. package/components/block.js +123 -0
  33. package/components/breadcrumbs-collapsed.d.ts +19 -0
  34. package/components/breadcrumbs-collapsed.js +21 -0
  35. package/components/breadcrumbs-item.d.ts +22 -0
  36. package/components/breadcrumbs-item.js +24 -0
  37. package/components/breadcrumbs-separator.d.ts +19 -0
  38. package/components/breadcrumbs-separator.js +20 -0
  39. package/components/breadcrumbs.d.ts +19 -0
  40. package/components/breadcrumbs.js +20 -0
  41. package/components/button.d.ts +371 -0
  42. package/components/button.js +182 -0
  43. package/components/card-content.d.ts +51 -0
  44. package/components/card-content.js +28 -0
  45. package/components/card-footer.d.ts +46 -0
  46. package/components/card-footer.js +22 -0
  47. package/components/card-header.d.ts +46 -0
  48. package/components/card-header.js +22 -0
  49. package/components/card.d.ts +145 -0
  50. package/components/card.js +192 -0
  51. package/components/checkbox.d.ts +72 -0
  52. package/components/checkbox.js +70 -0
  53. package/components/chip.d.ts +107 -0
  54. package/components/chip.js +81 -0
  55. package/components/fab-backdrop.d.ts +46 -0
  56. package/components/fab-backdrop.js +22 -0
  57. package/components/fab-button.d.ts +67 -0
  58. package/components/fab-button.js +52 -0
  59. package/components/fab-buttons.d.ts +51 -0
  60. package/components/fab-buttons.js +26 -0
  61. package/components/fab.d.ts +76 -0
  62. package/components/fab.js +78 -0
  63. package/components/gauge.d.ts +91 -0
  64. package/components/gauge.js +151 -0
  65. package/components/icon.d.ts +78 -0
  66. package/components/icon.js +100 -0
  67. package/components/input.d.ts +226 -0
  68. package/components/input.js +409 -0
  69. package/components/link.d.ts +287 -0
  70. package/components/link.js +129 -0
  71. package/components/list-button.d.ts +239 -0
  72. package/components/list-button.js +71 -0
  73. package/components/list-group.d.ts +71 -0
  74. package/components/list-group.js +53 -0
  75. package/components/list-index.d.ts +81 -0
  76. package/components/list-index.js +96 -0
  77. package/components/list-input.d.ts +245 -0
  78. package/components/list-input.js +415 -0
  79. package/components/list-item.d.ts +370 -0
  80. package/components/list-item.js +451 -0
  81. package/components/list.d.ts +236 -0
  82. package/components/list.js +222 -0
  83. package/components/login-screen-title.d.ts +46 -0
  84. package/components/login-screen-title.js +22 -0
  85. package/components/login-screen.d.ts +61 -0
  86. package/components/login-screen.js +104 -0
  87. package/components/message.d.ts +116 -0
  88. package/components/message.js +169 -0
  89. package/components/messagebar-attachment.d.ts +56 -0
  90. package/components/messagebar-attachment.js +52 -0
  91. package/components/messagebar-attachments.d.ts +46 -0
  92. package/components/messagebar-attachments.js +22 -0
  93. package/components/messagebar-sheet-image.d.ts +55 -0
  94. package/components/messagebar-sheet-image.js +48 -0
  95. package/components/messagebar-sheet-item.d.ts +46 -0
  96. package/components/messagebar-sheet-item.js +22 -0
  97. package/components/messagebar-sheet.d.ts +46 -0
  98. package/components/messagebar-sheet.js +22 -0
  99. package/components/messagebar.d.ts +117 -0
  100. package/components/messagebar.js +193 -0
  101. package/components/messages-title.d.ts +46 -0
  102. package/components/messages-title.js +22 -0
  103. package/components/messages.d.ts +116 -0
  104. package/components/messages.js +134 -0
  105. package/components/nav-left.d.ts +68 -0
  106. package/components/nav-left.js +66 -0
  107. package/components/nav-right.d.ts +50 -0
  108. package/components/nav-right.js +25 -0
  109. package/components/nav-title-large.d.ts +46 -0
  110. package/components/nav-title-large.js +25 -0
  111. package/components/nav-title.d.ts +58 -0
  112. package/components/nav-title.js +31 -0
  113. package/components/navbar.d.ts +110 -0
  114. package/components/navbar.js +248 -0
  115. package/components/page-content.d.ts +113 -0
  116. package/components/page-content.js +147 -0
  117. package/components/page.d.ts +150 -0
  118. package/components/page.js +331 -0
  119. package/components/panel.d.ts +139 -0
  120. package/components/panel.js +198 -0
  121. package/components/photo-browser.d.ts +164 -0
  122. package/components/photo-browser.js +181 -0
  123. package/components/pie-chart.d.ts +37 -0
  124. package/components/pie-chart.js +172 -0
  125. package/components/popover.d.ts +101 -0
  126. package/components/popover.js +157 -0
  127. package/components/popup.d.ts +99 -0
  128. package/components/popup.js +161 -0
  129. package/components/preloader.d.ts +50 -0
  130. package/components/preloader.js +65 -0
  131. package/components/progressbar.d.ts +54 -0
  132. package/components/progressbar.js +44 -0
  133. package/components/radio.d.ts +68 -0
  134. package/components/radio.js +59 -0
  135. package/components/range.d.ts +141 -0
  136. package/components/range.js +139 -0
  137. package/components/routable-modals.d.ts +19 -0
  138. package/components/routable-modals.js +58 -0
  139. package/components/searchbar.d.ts +182 -0
  140. package/components/searchbar.js +285 -0
  141. package/components/segmented.d.ts +87 -0
  142. package/components/segmented.js +53 -0
  143. package/components/sheet.d.ts +132 -0
  144. package/components/sheet.js +213 -0
  145. package/components/skeleton-avatar.d.ts +6 -0
  146. package/components/skeleton-avatar.js +3 -0
  147. package/components/skeleton-block.d.ts +6 -0
  148. package/components/skeleton-block.js +3 -0
  149. package/components/skeleton-image.d.ts +6 -0
  150. package/components/skeleton-image.js +3 -0
  151. package/components/skeleton-text.d.ts +6 -0
  152. package/components/skeleton-text.js +3 -0
  153. package/components/stepper.d.ts +197 -0
  154. package/components/stepper.js +230 -0
  155. package/components/subnavbar.d.ts +59 -0
  156. package/components/subnavbar.js +40 -0
  157. package/components/swipeout-actions.d.ts +58 -0
  158. package/components/swipeout-actions.js +33 -0
  159. package/components/swipeout-button.d.ts +75 -0
  160. package/components/swipeout-button.js +48 -0
  161. package/components/tab.d.ts +51 -0
  162. package/components/tab.js +128 -0
  163. package/components/tabs.d.ts +63 -0
  164. package/components/tabs.js +59 -0
  165. package/components/text-editor.d.ts +95 -0
  166. package/components/text-editor.js +147 -0
  167. package/components/toggle.d.ts +80 -0
  168. package/components/toggle.js +89 -0
  169. package/components/toolbar.d.ts +108 -0
  170. package/components/toolbar.js +135 -0
  171. package/components/treeview-item.d.ts +265 -0
  172. package/components/treeview-item.js +140 -0
  173. package/components/treeview.d.ts +46 -0
  174. package/components/treeview.js +22 -0
  175. package/components/use-icon.d.ts +19 -0
  176. package/components/use-icon.js +27 -0
  177. package/components/view.d.ts +296 -0
  178. package/components/view.js +373 -0
  179. package/components/views.d.ts +50 -0
  180. package/components/views.js +25 -0
  181. package/framework7-vue-bundle.js +190 -0
  182. package/framework7-vue.d.ts +121 -0
  183. package/framework7-vue.js +108 -0
  184. package/package.json +65 -0
  185. package/shared/components-router.js +203 -0
  186. package/shared/f7.js +71 -0
  187. package/shared/get-router-initial-component.js +35 -0
  188. package/shared/mixins.js +233 -0
  189. package/shared/modal-state-classes.js +10 -0
  190. package/shared/plugin.js +37 -0
  191. package/shared/router-open-in.js +105 -0
  192. package/shared/use-icon.js +37 -0
  193. package/shared/use-route-props.js +18 -0
  194. package/shared/use-smart-select.js +24 -0
  195. package/shared/use-store.js +24 -0
  196. package/shared/use-tab.js +24 -0
  197. package/shared/use-theme.js +11 -0
  198. package/shared/use-tooltip.js +43 -0
  199. package/shared/utils.js +110 -0
@@ -0,0 +1,267 @@
1
+ import { renderSlot as _renderSlot, resolveComponent as _resolveComponent, createVNode as _createVNode, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue";
2
+ function render(_ctx, _cache) {
3
+ const _component_routable_modals = _resolveComponent("routable-modals");
4
+ return _openBlock(), _createElementBlock("div", {
5
+ id: "framework7-root",
6
+ ref: "elRef",
7
+ class: _normalizeClass(_ctx.classes)
8
+ }, [_renderSlot(_ctx.$slots, "default"), _createVNode(_component_routable_modals)], 2);
9
+ }
10
+ import { ref, onMounted, computed, toRaw } from 'vue';
11
+ import { classNames, noUndefinedProps } from '../shared/utils.js';
12
+ import { colorClasses, colorProps } from '../shared/mixins.js';
13
+ import RoutableModals from './routable-modals.js';
14
+ import { f7init, f7 } from '../shared/f7.js';
15
+ export default {
16
+ name: 'f7-app',
17
+ render,
18
+ components: {
19
+ RoutableModals
20
+ },
21
+ inheritAttrs: false,
22
+ props: {
23
+ name: {
24
+ type: String,
25
+ default: undefined
26
+ },
27
+ theme: {
28
+ type: String,
29
+ default: undefined
30
+ },
31
+ routes: {
32
+ type: Array,
33
+ default: () => []
34
+ },
35
+ store: Object,
36
+ darkMode: {
37
+ type: [Boolean, String],
38
+ default: false
39
+ },
40
+ colors: {
41
+ type: Object,
42
+ default: () => undefined
43
+ },
44
+ lazyModulesPath: {
45
+ type: String,
46
+ default: undefined
47
+ },
48
+ initOnDeviceReady: {
49
+ type: Boolean,
50
+ default: undefined
51
+ },
52
+ iosTranslucentBars: {
53
+ type: Boolean,
54
+ default: undefined
55
+ },
56
+ iosTranslucentModals: {
57
+ type: Boolean,
58
+ default: undefined
59
+ },
60
+ userAgent: {
61
+ type: String,
62
+ default: undefined
63
+ },
64
+ url: {
65
+ type: String,
66
+ default: undefined
67
+ },
68
+ // components
69
+ accordion: {
70
+ type: Object,
71
+ default: () => undefined
72
+ },
73
+ actions: {
74
+ type: Object,
75
+ default: () => undefined
76
+ },
77
+ areaChart: {
78
+ type: Object,
79
+ default: () => undefined
80
+ },
81
+ autocomplete: {
82
+ type: Object,
83
+ default: () => undefined
84
+ },
85
+ calendar: {
86
+ type: Object,
87
+ default: () => undefined
88
+ },
89
+ card: {
90
+ type: Object,
91
+ default: () => undefined
92
+ },
93
+ colorPicker: {
94
+ type: Object,
95
+ default: () => undefined
96
+ },
97
+ dialog: {
98
+ type: Object,
99
+ default: () => undefined
100
+ },
101
+ form: {
102
+ type: Object,
103
+ default: () => undefined
104
+ },
105
+ gauge: {
106
+ type: Object,
107
+ default: () => undefined
108
+ },
109
+ infiniteScroll: {
110
+ type: Object,
111
+ default: () => undefined
112
+ },
113
+ input: {
114
+ type: Object,
115
+ default: () => undefined
116
+ },
117
+ listIndex: {
118
+ type: Object,
119
+ default: () => undefined
120
+ },
121
+ loginScreen: {
122
+ type: Object,
123
+ default: () => undefined
124
+ },
125
+ messagebar: {
126
+ type: Object,
127
+ default: () => undefined
128
+ },
129
+ messages: {
130
+ type: Object,
131
+ default: () => undefined
132
+ },
133
+ navbar: {
134
+ type: Object,
135
+ default: () => undefined
136
+ },
137
+ notification: {
138
+ type: Object,
139
+ default: () => undefined
140
+ },
141
+ panel: {
142
+ type: Object,
143
+ default: () => undefined
144
+ },
145
+ photoBrowser: {
146
+ type: Object,
147
+ default: () => undefined
148
+ },
149
+ picker: {
150
+ type: Object,
151
+ default: () => undefined
152
+ },
153
+ pieChart: {
154
+ type: Object,
155
+ default: () => undefined
156
+ },
157
+ popover: {
158
+ type: Object,
159
+ default: () => undefined
160
+ },
161
+ popup: {
162
+ type: Object,
163
+ default: () => undefined
164
+ },
165
+ range: {
166
+ type: Object,
167
+ default: () => undefined
168
+ },
169
+ searchbar: {
170
+ type: Object,
171
+ default: () => undefined
172
+ },
173
+ sheet: {
174
+ type: Object,
175
+ default: () => undefined
176
+ },
177
+ smartSelect: {
178
+ type: Object,
179
+ default: () => undefined
180
+ },
181
+ sortable: {
182
+ type: Object,
183
+ default: () => undefined
184
+ },
185
+ statusbar: {
186
+ type: Object,
187
+ default: () => undefined
188
+ },
189
+ stepper: {
190
+ type: Object,
191
+ default: () => undefined
192
+ },
193
+ swipeout: {
194
+ type: Object,
195
+ default: () => undefined
196
+ },
197
+ textEditor: {
198
+ type: Object,
199
+ default: () => undefined
200
+ },
201
+ toast: {
202
+ type: Object,
203
+ default: () => undefined
204
+ },
205
+ toolbar: {
206
+ type: Object,
207
+ default: () => undefined
208
+ },
209
+ tooltip: {
210
+ type: Object,
211
+ default: () => undefined
212
+ },
213
+ view: {
214
+ type: Object,
215
+ default: () => undefined
216
+ },
217
+ virtualList: {
218
+ type: Object,
219
+ default: () => undefined
220
+ },
221
+ // modules
222
+ clicks: {
223
+ type: Object,
224
+ default: () => undefined
225
+ },
226
+ serviceWorker: {
227
+ type: Object,
228
+ default: () => undefined
229
+ },
230
+ touch: {
231
+ type: Object,
232
+ default: () => undefined
233
+ },
234
+ ...colorProps
235
+ },
236
+ setup(props) {
237
+ const elRef = ref(null);
238
+ const routes = toRaw(props.routes);
239
+ if (!f7 || typeof window === 'undefined') {
240
+ f7init(elRef.value, noUndefinedProps({
241
+ ...props,
242
+ routes
243
+ }), false);
244
+ }
245
+ onMounted(() => {
246
+ const parentEl = elRef.value && elRef.value.parentNode;
247
+ /* eslint-disable no-restricted-globals */
248
+ if (typeof document !== 'undefined' && parentEl && parentEl !== document.body && parentEl.parentNode === document.body) {
249
+ parentEl.style.height = '100%';
250
+ }
251
+ /* eslint-enable no-restricted-globals */
252
+ if (f7) {
253
+ f7.init(elRef.value);
254
+ return;
255
+ }
256
+ f7init(elRef.value, noUndefinedProps({
257
+ ...props,
258
+ routes
259
+ }), true);
260
+ });
261
+ const classes = computed(() => classNames('framework7-root', colorClasses(props)));
262
+ return {
263
+ classes,
264
+ elRef
265
+ };
266
+ }
267
+ };
@@ -0,0 +1,88 @@
1
+
2
+ import { ComponentOptionsMixin, DefineComponent, PropType } from 'vue';
3
+
4
+
5
+ declare const AreaChart: DefineComponent<
6
+ {
7
+
8
+ lineChart: {
9
+ type: BooleanConstructor;
10
+ },
11
+
12
+ axis: {
13
+ type: BooleanConstructor;
14
+ },
15
+
16
+ tooltip: {
17
+ type: BooleanConstructor;
18
+ },
19
+
20
+ legend: {
21
+ type: BooleanConstructor;
22
+ },
23
+
24
+ toggleDatasets: {
25
+ type: BooleanConstructor;
26
+ },
27
+
28
+ formatAxisLabel: {
29
+ type: FunctionConstructor;
30
+ },
31
+
32
+ formatLegendLabel: {
33
+ type: FunctionConstructor;
34
+ },
35
+
36
+ formatTooltip: {
37
+ type: FunctionConstructor;
38
+ },
39
+
40
+ formatTooltipAxisLabel: {
41
+ type: FunctionConstructor;
42
+ },
43
+
44
+ formatTooltipTotal: {
45
+ type: FunctionConstructor;
46
+ },
47
+
48
+ formatTooltipDataset: {
49
+ type: FunctionConstructor;
50
+ },
51
+
52
+ datasets: {
53
+ type: ArrayConstructor;
54
+ default: () => [];
55
+ },
56
+
57
+ axisLabels: {
58
+ type: ArrayConstructor;
59
+ default: () => [];
60
+ },
61
+
62
+ width: {
63
+ type: NumberConstructor;
64
+ default: number;
65
+ },
66
+
67
+ height: {
68
+ type: NumberConstructor;
69
+ default: number;
70
+ },
71
+
72
+ maxAxisLabels: {
73
+ type: NumberConstructor;
74
+ default: number;
75
+ }
76
+ },
77
+ () => JSX.Element,
78
+ unknown,
79
+ {},
80
+ {},
81
+ ComponentOptionsMixin,
82
+ ComponentOptionsMixin,
83
+ ("select")[],
84
+ "select"
85
+ >;
86
+
87
+ export default AreaChart;
88
+
@@ -0,0 +1,364 @@
1
+ import { renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, resolveDynamicComponent as _resolveDynamicComponent, createBlock as _createBlock, normalizeClass as _normalizeClass, toDisplayString as _toDisplayString, createCommentVNode as _createCommentVNode, normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, createTextVNode as _createTextVNode, withCtx as _withCtx, renderSlot as _renderSlot } from "vue";
2
+ const _hoisted_1 = ["width", "height", "viewBox"];
3
+ const _hoisted_2 = ["data-index", "x1", "x2", "y2"];
4
+ const _hoisted_3 = {
5
+ key: 0,
6
+ class: "area-chart-axis"
7
+ };
8
+ const _hoisted_4 = {
9
+ key: 0
10
+ };
11
+ const _hoisted_5 = {
12
+ key: 1,
13
+ class: "area-chart-legend"
14
+ };
15
+ function render(_ctx, _cache) {
16
+ return _openBlock(), _createElementBlock("div", {
17
+ ref: "elRef",
18
+ class: _normalizeClass(_ctx.classes)
19
+ }, [(_openBlock(), _createElementBlock("svg", {
20
+ ref: "svgElRef",
21
+ xmlns: "http://www.w3.org/2000/svg",
22
+ width: _ctx.width,
23
+ height: _ctx.height,
24
+ viewBox: `0 0 ${_ctx.width} ${_ctx.height}`,
25
+ preserveAspectRatio: "none"
26
+ }, [(_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.chartData, (data, index) => {
27
+ return _openBlock(), _createBlock(_resolveDynamicComponent(_ctx.ChartTag), {
28
+ key: `${_ctx.ChartTag}-${index}`,
29
+ fill: _ctx.lineChart ? undefined : data.color,
30
+ stroke: _ctx.lineChart ? data.color : undefined,
31
+ "fill-rule": "evenodd",
32
+ points: _ctx.lineChart ? undefined : data.points,
33
+ d: _ctx.lineChart ? data.points : undefined
34
+ }, null, 8, ["fill", "stroke", "points", "d"]);
35
+ }), 128)), (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.verticalLines, (line, index) => {
36
+ return _openBlock(), _createElementBlock("line", {
37
+ key: `line-${index}`,
38
+ "data-index": index,
39
+ fill: "#000",
40
+ x1: line,
41
+ y1: 0,
42
+ x2: line,
43
+ y2: _ctx.height,
44
+ class: _normalizeClass(_ctx.classNames({
45
+ 'area-chart-current-line': _ctx.currentIndex === index
46
+ }))
47
+ }, null, 10, _hoisted_2);
48
+ }), 128))], 8, _hoisted_1)), _ctx.axis ? (_openBlock(), _createElementBlock("div", _hoisted_3, [(_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.axisLabels, (label, index) => {
49
+ return _openBlock(), _createElementBlock("span", {
50
+ key: index
51
+ }, [_ctx.visibleLegends.includes(label) ? (_openBlock(), _createElementBlock("span", _hoisted_4, _toDisplayString(_ctx.formatAxisLabelMethod(label)), 1)) : _createCommentVNode("", true)]);
52
+ }), 128))])) : _createCommentVNode("", true), _ctx.legend ? (_openBlock(), _createElementBlock("div", _hoisted_5, [(_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.datasets, (dataset, index) => {
53
+ return _openBlock(), _createBlock(_resolveDynamicComponent(_ctx.LegendItemTag), {
54
+ key: index,
55
+ class: _normalizeClass(_ctx.classNames('area-chart-legend-item', {
56
+ 'area-chart-legend-item-hidden': _ctx.hiddenDatasets.includes(index),
57
+ 'area-chart-legend-button': _ctx.toggleDatasets
58
+ })),
59
+ type: _ctx.toggleDatasets ? 'button' : undefined,
60
+ onClick: $event => _ctx.toggleDataset(index)
61
+ }, {
62
+ default: _withCtx(() => [_createElementVNode("span", {
63
+ style: _normalizeStyle({
64
+ backgroundColor: dataset.color
65
+ })
66
+ }, null, 4), _createTextVNode(" " + _toDisplayString(_ctx.formatLegendLabelMethod(dataset.label)), 1)]),
67
+ _: 2
68
+ }, 1032, ["class", "type", "onClick"]);
69
+ }), 128))])) : _createCommentVNode("", true), _renderSlot(_ctx.$slots, "default")], 2);
70
+ }
71
+ import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
72
+ import { classNames } from '../shared/utils.js';
73
+ import { f7 } from '../shared/f7.js';
74
+ export default {
75
+ name: 'f7-area-chart',
76
+ render,
77
+ props: {
78
+ lineChart: Boolean,
79
+ datasets: {
80
+ type: Array,
81
+ default: () => []
82
+ },
83
+ axis: Boolean,
84
+ axisLabels: {
85
+ type: Array,
86
+ default: () => []
87
+ },
88
+ tooltip: Boolean,
89
+ legend: Boolean,
90
+ toggleDatasets: Boolean,
91
+ width: {
92
+ type: Number,
93
+ default: 640
94
+ },
95
+ height: {
96
+ type: Number,
97
+ default: 320
98
+ },
99
+ maxAxisLabels: {
100
+ type: Number,
101
+ default: 8
102
+ },
103
+ formatAxisLabel: Function,
104
+ formatLegendLabel: Function,
105
+ formatTooltip: Function,
106
+ formatTooltipAxisLabel: Function,
107
+ formatTooltipTotal: Function,
108
+ formatTooltipDataset: Function
109
+ },
110
+ emits: ['select'],
111
+ setup(props, _ref) {
112
+ let {
113
+ emit
114
+ } = _ref;
115
+ let f7Tooltip = null;
116
+ const currentIndex = ref(null);
117
+ const hiddenDatasets = ref([]);
118
+ const elRef = ref(null);
119
+ const svgElRef = ref(null);
120
+ const linesOffsets = ref(null);
121
+ const visibleLegends = computed(() => {
122
+ if (!props.maxAxisLabels || props.axisLabels.length <= props.maxAxisLabels) return props.axisLabels;
123
+ const skipStep = Math.ceil(props.axisLabels.length / props.maxAxisLabels);
124
+ const filtered = props.axisLabels.filter((label, index) => index % skipStep === 0);
125
+ return filtered;
126
+ });
127
+ const summValues = computed(() => {
128
+ const summ = [];
129
+ props.datasets.filter((dataset, index) => !hiddenDatasets.value.includes(index)).forEach(_ref2 => {
130
+ let {
131
+ values
132
+ } = _ref2;
133
+ values.forEach((value, valueIndex) => {
134
+ if (!summ[valueIndex]) summ[valueIndex] = 0;
135
+ summ[valueIndex] += value;
136
+ });
137
+ });
138
+ return summ;
139
+ });
140
+ const chartData = computed(() => {
141
+ const {
142
+ datasets,
143
+ lineChart,
144
+ width,
145
+ height
146
+ } = props;
147
+ const data = [];
148
+ if (!datasets.length) {
149
+ return data;
150
+ }
151
+ const lastValues = datasets[0].values.map(() => 0);
152
+ let maxValue = 0;
153
+ if (lineChart) {
154
+ datasets.forEach(_ref3 => {
155
+ let {
156
+ values
157
+ } = _ref3;
158
+ const datasetMaxValue = Math.max(...values);
159
+ if (datasetMaxValue > maxValue) maxValue = datasetMaxValue;
160
+ });
161
+ } else {
162
+ maxValue = Math.max(...summValues.value);
163
+ }
164
+ datasets.filter((dataset, index) => !hiddenDatasets.value.includes(index)).forEach(_ref4 => {
165
+ let {
166
+ label,
167
+ values,
168
+ color
169
+ } = _ref4;
170
+ const points = values.map((originalValue, valueIndex) => {
171
+ lastValues[valueIndex] += originalValue;
172
+ const value = lineChart ? originalValue : lastValues[valueIndex];
173
+ const x = valueIndex / (values.length - 1) * width;
174
+ const y = height - value / maxValue * height;
175
+ if (lineChart) {
176
+ return `${valueIndex === 0 ? 'M' : 'L'}${x},${y}`;
177
+ }
178
+ return `${x} ${y}`;
179
+ });
180
+ if (!lineChart) {
181
+ points.push(`${width} ${height} 0 ${height}`);
182
+ }
183
+ data.push({
184
+ label,
185
+ points: points.join(' '),
186
+ color
187
+ });
188
+ });
189
+ return data.reverse();
190
+ });
191
+ const verticalLines = computed(() => {
192
+ const lines = [];
193
+ if (!props.datasets.length) {
194
+ return lines;
195
+ }
196
+ const values = props.datasets[0].values;
197
+ values.forEach((value, valueIndex) => {
198
+ const x = valueIndex / (values.length - 1) * props.width;
199
+ lines.push(x);
200
+ });
201
+ return lines;
202
+ });
203
+ const toggleDataset = index => {
204
+ if (!props.toggleDatasets) return;
205
+ if (hiddenDatasets.value.includes(index)) {
206
+ hiddenDatasets.value.splice(hiddenDatasets.value.indexOf(index), 1);
207
+ } else {
208
+ hiddenDatasets.value.push(index);
209
+ }
210
+ hiddenDatasets.value = [...hiddenDatasets.value];
211
+ };
212
+ const formatAxisLabelMethod = label => {
213
+ if (props.formatAxisLabel) return props.formatAxisLabel(label);
214
+ return label;
215
+ };
216
+ const formatLegendLabelMethod = label => {
217
+ if (props.formatLegendLabel) return props.formatLegendLabel(label);
218
+ return label;
219
+ };
220
+ const calcLinesOffsets = () => {
221
+ const lines = svgElRef.value.querySelectorAll('line');
222
+ linesOffsets.value = [];
223
+ for (let i = 0; i < lines.length; i += 1) {
224
+ linesOffsets.value.push(lines[i].getBoundingClientRect().left);
225
+ }
226
+ };
227
+ const formatTooltip = () => {
228
+ const index = currentIndex.value;
229
+ if (index === null) return '';
230
+ let total = 0;
231
+ const currentValues = props.datasets.filter((dataset, i) => !hiddenDatasets.value.includes(i)).map(dataset => ({
232
+ color: dataset.color,
233
+ label: dataset.label,
234
+ value: dataset.values[index]
235
+ }));
236
+ currentValues.forEach(dataset => {
237
+ total += dataset.value;
238
+ });
239
+ if (props.formatTooltip) {
240
+ return props.formatTooltip({
241
+ index,
242
+ total,
243
+ datasets: currentValues
244
+ });
245
+ }
246
+ let labelText = props.formatTooltipAxisLabel ? props.formatTooltipAxisLabel(props.axisLabels[index]) : formatAxisLabelMethod(props.axisLabels[index]);
247
+ if (!labelText) labelText = '';
248
+ const totalText = props.formatTooltipTotal ? props.formatTooltipTotal(total) : total;
249
+ // prettier-ignore
250
+ const datasetsText = currentValues.length > 0 ? `
251
+ <ul class="area-chart-tooltip-list">
252
+ ${currentValues.map(_ref5 => {
253
+ let {
254
+ label,
255
+ color,
256
+ value
257
+ } = _ref5;
258
+ const valueText = props.formatTooltipDataset ? props.formatTooltipDataset(label, value, color) : `${label}: ${value}`;
259
+ return `
260
+ <li><span style="background-color: ${color};"></span>${valueText}</li>
261
+ `;
262
+ }).join('')}
263
+ </ul>` : '';
264
+ // prettier-ignore
265
+ return `
266
+ <div class="area-chart-tooltip-label">${labelText}</div>
267
+ <div class="area-chart-tooltip-total">${totalText}</div>
268
+ ${datasetsText}
269
+ `;
270
+ };
271
+ const setTooltip = () => {
272
+ const {
273
+ tooltip,
274
+ datasets
275
+ } = props;
276
+ const index = currentIndex.value;
277
+ if (!tooltip) return;
278
+ const hasVisibleDataSets = datasets.filter((dataset, i) => !hiddenDatasets.value.includes(i)).length > 0;
279
+ if (!hasVisibleDataSets) {
280
+ if (f7Tooltip && f7Tooltip.hide) f7Tooltip.hide();
281
+ return;
282
+ }
283
+ if (index !== null && !f7Tooltip) {
284
+ f7Tooltip = f7.tooltip.create({
285
+ trigger: 'manual',
286
+ containerEl: elRef.value,
287
+ targetEl: svgElRef.value.querySelector(`line[data-index="${index}"]`),
288
+ text: formatTooltip(),
289
+ cssClass: 'area-chart-tooltip'
290
+ });
291
+ if (f7Tooltip && f7Tooltip.show) {
292
+ f7Tooltip.show();
293
+ }
294
+ return;
295
+ }
296
+ if (!f7Tooltip || !f7Tooltip.hide || !f7Tooltip.show) {
297
+ return;
298
+ }
299
+ if (index !== null) {
300
+ f7Tooltip.setText(formatTooltip());
301
+ f7Tooltip.setTargetEl(svgElRef.value.querySelector(`line[data-index="${index}"]`));
302
+ f7Tooltip.show();
303
+ } else {
304
+ f7Tooltip.hide();
305
+ }
306
+ };
307
+ const onMouseEnter = () => {
308
+ calcLinesOffsets();
309
+ };
310
+ const onMouseMove = e => {
311
+ if (!linesOffsets.value) {
312
+ calcLinesOffsets();
313
+ }
314
+ let currentLeft = e.pageX;
315
+ if (typeof currentLeft === 'undefined') currentLeft = 0;
316
+ const distances = linesOffsets.value.map(left => Math.abs(currentLeft - left));
317
+ const minDistance = Math.min(...distances);
318
+ const closestIndex = distances.indexOf(minDistance);
319
+ currentIndex.value = closestIndex;
320
+ };
321
+ const onMouseLeave = () => {
322
+ currentIndex.value = null;
323
+ };
324
+ watch(() => currentIndex.value, () => {
325
+ emit('select', currentIndex.value);
326
+ setTooltip();
327
+ });
328
+ onMounted(() => {
329
+ if (!svgElRef.value) return;
330
+ svgElRef.value.addEventListener('mouseenter', onMouseEnter);
331
+ svgElRef.value.addEventListener('mousemove', onMouseMove);
332
+ svgElRef.value.addEventListener('mouseleave', onMouseLeave);
333
+ });
334
+ onBeforeUnmount(() => {
335
+ if (f7Tooltip && f7Tooltip.destroy) {
336
+ f7Tooltip.destroy();
337
+ }
338
+ f7Tooltip = null;
339
+ if (!svgElRef.value) return;
340
+ svgElRef.value.removeEventListener('mouseenter', onMouseEnter);
341
+ svgElRef.value.removeEventListener('mousemove', onMouseMove);
342
+ svgElRef.value.removeEventListener('mouseleave', onMouseLeave);
343
+ });
344
+ const classes = computed(() => classNames('area-chart'));
345
+ const LegendItemTag = computed(() => props.toggleDatasets ? 'button' : 'span');
346
+ const ChartTag = computed(() => props.lineChart ? 'path' : 'polygon');
347
+ return {
348
+ currentIndex,
349
+ hiddenDatasets,
350
+ visibleLegends,
351
+ chartData,
352
+ verticalLines,
353
+ elRef,
354
+ svgElRef,
355
+ classes,
356
+ toggleDataset,
357
+ formatAxisLabelMethod,
358
+ formatLegendLabelMethod,
359
+ LegendItemTag,
360
+ ChartTag,
361
+ classNames
362
+ };
363
+ }
364
+ };