@mptw/skylens-ui 1.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 (143) hide show
  1. package/.editorconfig +12 -0
  2. package/.eslintrc.cjs +4 -0
  3. package/.nuxtrc +1 -0
  4. package/.playground/app.config.ts +5 -0
  5. package/.playground/nuxt.config.ts +3 -0
  6. package/README.md +73 -0
  7. package/app.config.ts +5 -0
  8. package/app.vue +3 -0
  9. package/assets/css/fonts/MEShPlus-font-icon.eot +0 -0
  10. package/assets/css/fonts/MEShPlus-font-icon.svg +186 -0
  11. package/assets/css/fonts/MEShPlus-font-icon.ttf +0 -0
  12. package/assets/css/fonts/MEShPlus-font-icon.woff +0 -0
  13. package/assets/css/icons.css +555 -0
  14. package/assets/css/layout.styl +98 -0
  15. package/assets/css/tailwind.css +3 -0
  16. package/assets/images/commons/app-logo-white.png +0 -0
  17. package/assets/images/commons/app-logo.png +0 -0
  18. package/assets/images/commons/empty-box.png +0 -0
  19. package/assets/images/commons/watermark.svg +15 -0
  20. package/components/SLAlertModal.vue +99 -0
  21. package/components/SLBreadcrumbs.vue +42 -0
  22. package/components/SLButton.vue +301 -0
  23. package/components/SLCalendarButton.vue +259 -0
  24. package/components/SLCalendarPopup.vue +832 -0
  25. package/components/SLCard.vue +118 -0
  26. package/components/SLChart.vue +181 -0
  27. package/components/SLCheckbox.vue +179 -0
  28. package/components/SLCircleButton.vue +95 -0
  29. package/components/SLCollapsableBlock.vue +116 -0
  30. package/components/SLCollapsableMulitPillSelect.vue +92 -0
  31. package/components/SLConfirmModal.vue +122 -0
  32. package/components/SLDateInput.vue +460 -0
  33. package/components/SLDatePicker.vue +143 -0
  34. package/components/SLDistributor.vue +30 -0
  35. package/components/SLDownloadButton.vue +410 -0
  36. package/components/SLDraggable.vue +151 -0
  37. package/components/SLDropdown.vue +277 -0
  38. package/components/SLDropdownItem.vue +31 -0
  39. package/components/SLElementWithTitle.vue +181 -0
  40. package/components/SLEyeCheckbox.vue +162 -0
  41. package/components/SLFileInput.vue +101 -0
  42. package/components/SLGenderAgeSelect.vue +279 -0
  43. package/components/SLHeatMap.vue +151 -0
  44. package/components/SLHourRangeInput.vue +211 -0
  45. package/components/SLIOSSwitch.vue +235 -0
  46. package/components/SLIcon.vue +35 -0
  47. package/components/SLIconButton.vue +130 -0
  48. package/components/SLInfoTip.vue +221 -0
  49. package/components/SLInsightSitePage.vue +27 -0
  50. package/components/SLLegend.vue +76 -0
  51. package/components/SLLinearProgressBar.vue +35 -0
  52. package/components/SLLink.vue +162 -0
  53. package/components/SLLoading.vue +127 -0
  54. package/components/SLMapChart.vue +151 -0
  55. package/components/SLModal.vue +377 -0
  56. package/components/SLMonthCalendarButton.vue +378 -0
  57. package/components/SLMonthPicker.vue +151 -0
  58. package/components/SLMultiSelect.vue +121 -0
  59. package/components/SLNoData.vue +43 -0
  60. package/components/SLPageModal.vue +64 -0
  61. package/components/SLPagination.vue +192 -0
  62. package/components/SLPillCheckbox.vue +207 -0
  63. package/components/SLPillLabel.vue +101 -0
  64. package/components/SLPopupMenuButton.vue +158 -0
  65. package/components/SLProfileButton.vue +186 -0
  66. package/components/SLRadioButton.vue +97 -0
  67. package/components/SLRadioButtonGroup.vue +113 -0
  68. package/components/SLRadioGroup.vue +201 -0
  69. package/components/SLRangeInput.vue +209 -0
  70. package/components/SLRegionsMapChart.vue +151 -0
  71. package/components/SLRightSider.vue +242 -0
  72. package/components/SLSearchInput.vue +87 -0
  73. package/components/SLSelect.vue +545 -0
  74. package/components/SLSelectAllToggle.vue +118 -0
  75. package/components/SLSiderbarNav.vue +394 -0
  76. package/components/SLSiderbarNavItem.vue +204 -0
  77. package/components/SLSitePage.vue +96 -0
  78. package/components/SLSkyInsightSitePage.vue +27 -0
  79. package/components/SLSortByDropdown.vue +189 -0
  80. package/components/SLSpinIcon.vue +24 -0
  81. package/components/SLStayRangeInput.vue +306 -0
  82. package/components/SLTab.vue +159 -0
  83. package/components/SLTable.vue +409 -0
  84. package/components/SLTableTooltip.vue +111 -0
  85. package/components/SLTabs.vue +388 -0
  86. package/components/SLTextInput.vue +362 -0
  87. package/components/SLTextarea.vue +134 -0
  88. package/components/SLToast.vue +71 -0
  89. package/components/SLToggleButton.vue +78 -0
  90. package/components/SLTwoLayerMultiSelect.vue +428 -0
  91. package/components/SLTwoLayerSelect.vue +265 -0
  92. package/components/SLWarnModal.vue +75 -0
  93. package/interface/IDateRange.ts +5 -0
  94. package/interface/IHourRange.ts +4 -0
  95. package/interface/IInputOption.ts +6 -0
  96. package/interface/ILegendItem.ts +7 -0
  97. package/interface/IPopupMenuButton.ts +5 -0
  98. package/interface/IStayRange.ts +15 -0
  99. package/interface/ITableField.ts +19 -0
  100. package/interface/IWeb.ts +5 -0
  101. package/interface/NavConfigType.ts +14 -0
  102. package/interface/commons.ts +7 -0
  103. package/models/DateRange.ts +21 -0
  104. package/nuxt.config.ts +22 -0
  105. package/package.json +52 -0
  106. package/plugins/googlemaps.ts +17 -0
  107. package/plugins/v-calendar.ts +5 -0
  108. package/public/assets/files/taiwan-regions.json +7 -0
  109. package/public/assets/files/taiwan.json +24 -0
  110. package/public/assets/images/commons/default-favico.png +0 -0
  111. package/public/assets/images/dashboard/closure-button-icon.png +0 -0
  112. package/public/assets/images/dashboard/dashboard-widget-bar-chart-icon-disabled.png +0 -0
  113. package/public/assets/images/dashboard/dashboard-widget-bar-chart-icon-poi.png +0 -0
  114. package/public/assets/images/dashboard/dashboard-widget-bar-chart-icon-web.png +0 -0
  115. package/public/assets/images/dashboard/dashboard-widget-country-heatmap-chart-icon-disabled.png +0 -0
  116. package/public/assets/images/dashboard/dashboard-widget-country-heatmap-chart-icon.png +0 -0
  117. package/public/assets/images/dashboard/dashboard-widget-geo-list-icon-disabled.png +0 -0
  118. package/public/assets/images/dashboard/dashboard-widget-geo-list-icon-poi.png +0 -0
  119. package/public/assets/images/dashboard/dashboard-widget-geo-list-icon-web.png +0 -0
  120. package/public/assets/images/dashboard/dashboard-widget-heatmap-chart-icon-disabled.png +0 -0
  121. package/public/assets/images/dashboard/dashboard-widget-heatmap-chart-icon-web.png +0 -0
  122. package/public/assets/images/dashboard/dashboard-widget-line-chart-icon-disabled.png +0 -0
  123. package/public/assets/images/dashboard/dashboard-widget-line-chart-icon-poi.png +0 -0
  124. package/public/assets/images/dashboard/dashboard-widget-list-icon-disabled.png +0 -0
  125. package/public/assets/images/dashboard/dashboard-widget-list-icon-poi.png +0 -0
  126. package/public/assets/images/dashboard/dashboard-widget-list-icon-web.png +0 -0
  127. package/public/assets/images/dashboard/dashboard-widget-pie-chart-icon-disabled.png +0 -0
  128. package/public/assets/images/dashboard/dashboard-widget-pie-chart-icon-poi.png +0 -0
  129. package/public/assets/images/dashboard/dashboard-widget-pie-chart-icon-web.png +0 -0
  130. package/public/assets/images/dashboard/drag-hint-icon.svg +3 -0
  131. package/public/assets/images/dashboard/extend-button-icon.png +0 -0
  132. package/public/assets/images/dashboard/map-list-chart-icon.svg +17 -0
  133. package/public/assets/images/dashboard/map-marker-chart-icon.svg +32 -0
  134. package/public/assets/images/dashboard/pie-chart-icon.svg +4 -0
  135. package/public/assets/images/dashboard/poi-gender-age-chart-icon.svg +20 -0
  136. package/public/assets/images/dashboard/poi-nav-icon.png +0 -0
  137. package/public/assets/images/dashboard/web-gender-age-chart-icon.svg +20 -0
  138. package/public/assets/images/dashboard/web-nav-icon.png +0 -0
  139. package/tailwind.config.js +300 -0
  140. package/tsconfig.json +8 -0
  141. package/utils/constants.ts +160 -0
  142. package/utils/generateSheet.ts +36 -0
  143. package/utils/index.ts +539 -0
@@ -0,0 +1,388 @@
1
+ <template lang="pug">
2
+ .tabs(:class='tabsClass')
3
+ .tabs-nav(
4
+ v-show="!tabItemsOversize"
5
+ :class="{ show: !tabItemsOversize }"
6
+ )
7
+ .tabs-nav-left(ref='tabsNavLeftEl')
8
+ SLDistributor(
9
+ tag='ul',
10
+ :header='true',
11
+ :changeTabTo='changeTabTo',
12
+ ref='navComp'
13
+ )
14
+ slot
15
+ .tabs-nav-right(v-if='type === 1 && $slots["tabs-nav-right"]')
16
+ slot(name='tabs-nav-right')
17
+ .tabs-content
18
+ SLDistributor
19
+ .tabs-content-header(v-show="tabItemsOversize")
20
+ .tabs-content-header-left
21
+ SLDropdown.tabs-dropdown(
22
+ :title='currentTab',
23
+ v-model:showDropdown='showDropdown',
24
+ :class='{ active: showDropdown }',
25
+ )
26
+ SLDropdownItem(
27
+ v-for='(tabTitle, i) in tabTitles',
28
+ :title='tabTitle',
29
+ :class='{ active: i === activeTabIndex }',
30
+ @click='onClickedTab(i)',
31
+ :key='`${tabTitle}-${i}`'
32
+ )
33
+ .tabs-content-header-right(v-if='$slots["tabs-nav-right"]')
34
+ slot(name='tabs-nav-right')
35
+ .tabs-content-body(ref='tabsContentBody')
36
+ slot
37
+ </template>
38
+
39
+ <script lang="ts">
40
+ import { fromEvent, interval, Subscription } from "rxjs";
41
+ import { debounce, startWith } from "rxjs/operators";
42
+ import { SLDistributor } from "#components";
43
+
44
+ type SLDistributorType = InstanceType<typeof SLDistributor>;
45
+
46
+ export default defineComponent({
47
+ name: "SLTabs",
48
+ components: {},
49
+ props: {
50
+ size: {
51
+ type: String,
52
+ default: "",
53
+ validator: (value: string) => ["", "xs", "sm"].includes(value),
54
+ },
55
+ navMode: {
56
+ type: String,
57
+ default: "",
58
+ },
59
+ type: {
60
+ type: Number,
61
+ default: 1,
62
+ validator: (value: number) => [1, 2, 3, 4].includes(value),
63
+ },
64
+ activeTab: {
65
+ type: Number,
66
+ default: 0,
67
+ },
68
+ },
69
+ emits: ["update:activeTab"],
70
+ setup(props, { emit }) {
71
+ const { activeTab, size, type, navMode } = toRefs(props);
72
+
73
+ const tabsContentBody = shallowRef<HTMLElement | null>(null);
74
+ const tabsNavLeftEl = shallowRef<HTMLElement | null>(null);
75
+ const navComp = shallowRef<SLDistributorType | null>(null);
76
+ const activeTabIndex = ref(activeTab.value || 0);
77
+ const tabTitles = ref<Array<string>>([]);
78
+ const showDropdown = ref(false);
79
+ const tabItemsOversizeProxy = ref(false);
80
+
81
+ let observer: MutationObserver | null = null;
82
+ let resizeSubscriber: Subscription | null = null;
83
+
84
+ const tabsClass = computed(() => {
85
+ const classes: Array<string> = [`tabs-type-${type.value}`];
86
+
87
+ if (size.value !== "") {
88
+ classes.push(`tabs-${size.value}`);
89
+ }
90
+
91
+ return classes.join(" ");
92
+ });
93
+ const currentTab = computed(() => {
94
+ return tabTitles.value[activeTabIndex.value];
95
+ });
96
+ const tabItemsOversize = computed({
97
+ get: () => {
98
+ return (
99
+ type.value !== 4 &&
100
+ (tabItemsOversizeProxy.value || navMode.value === "dropdown")
101
+ );
102
+ },
103
+ set: (newValue: boolean) => {
104
+ tabItemsOversizeProxy.value = newValue;
105
+ },
106
+ });
107
+
108
+ provide("activeTab", readonly(activeTabIndex));
109
+ provide("initialTab", readonly(activeTab));
110
+
111
+ function caculateTabs() {
112
+ nextTick(() => {
113
+ const tabLinks =
114
+ navComp.value?.$el.querySelectorAll(".tab-nav-item-link");
115
+ const tabLinkTitles = [];
116
+ if (tabLinks) {
117
+ for (let i = 0; i < tabLinks.length; i += 1) {
118
+ tabLinkTitles.push((tabLinks[i] as HTMLElement).innerText);
119
+ }
120
+ }
121
+ tabTitles.value = tabLinkTitles;
122
+
123
+ const tabsNavLeftRect = tabsNavLeftEl.value?.getBoundingClientRect();
124
+ const navRect = navComp.value?.$el?.getBoundingClientRect();
125
+
126
+ if (tabsNavLeftRect && navRect) {
127
+ tabItemsOversizeProxy.value = navRect.width > tabsNavLeftRect.width;
128
+ }
129
+ });
130
+ }
131
+
132
+ function changeTabTo(newTab: number) {
133
+ activeTabIndex.value = newTab;
134
+ emit("update:activeTab", newTab);
135
+ }
136
+
137
+ function onClickedTab(i: number) {
138
+ changeTabTo(i);
139
+ }
140
+
141
+ watch(activeTab, () => {
142
+ activeTabIndex.value = activeTab.value || 0;
143
+ });
144
+
145
+ onMounted(() => {
146
+ resizeSubscriber = fromEvent(window, "resize")
147
+ .pipe(debounce(() => interval(500)))
148
+ .pipe(startWith(0))
149
+ .subscribe(() => {
150
+ caculateTabs();
151
+ });
152
+
153
+ if (navComp.value) {
154
+ observer = new MutationObserver(caculateTabs);
155
+ observer.observe(navComp.value.$el, {
156
+ characterData: true,
157
+ attributes: false,
158
+ childList: true,
159
+ subtree: true,
160
+ });
161
+ }
162
+ });
163
+
164
+ onBeforeUnmount(() => {
165
+ if (resizeSubscriber) {
166
+ resizeSubscriber.unsubscribe();
167
+ }
168
+ if (observer) {
169
+ observer.disconnect();
170
+ }
171
+ resizeSubscriber = null;
172
+ observer = null;
173
+ });
174
+
175
+ return {
176
+ tabsContentBody,
177
+ tabsNavLeftEl,
178
+ navComp,
179
+ activeTabIndex,
180
+ tabTitles,
181
+ showDropdown,
182
+ tabItemsOversize,
183
+ tabsClass,
184
+ currentTab,
185
+ changeTabTo,
186
+ onClickedTab,
187
+ };
188
+ },
189
+ });
190
+ </script>
191
+
192
+ <style lang="stylus">
193
+ .tabs
194
+ &.tabs-sm
195
+ &.tabs-type-1
196
+ & > .tabs-nav
197
+ ul
198
+ .tab-nav-item
199
+ &-link
200
+ @apply text-sm
201
+
202
+ &.tabs-xs
203
+ &.tabs-type-1
204
+ & > .tabs-nav
205
+ ul
206
+ .tab-nav-item
207
+ &.active
208
+ &:before
209
+ @apply hidden
210
+
211
+ &-link
212
+ @apply s("py-0.75") text-base
213
+
214
+ &.tabs-type-1
215
+ & > .tabs-nav
216
+ @apply flex items-start justify-between h-0 space-x-8 overflow-hidden
217
+ @apply s('lg:space-x-30')
218
+
219
+ &.show
220
+ @apply h-auto s("-mb-1.5")
221
+
222
+ .tabs-nav-left
223
+ @apply flex-grow overflow-hidden
224
+
225
+ .tabs-nav-right
226
+ @apply flex-grow-0 flex-shrink-0
227
+
228
+ ul
229
+ @apply inline-flex items-start s("-space-x-px")
230
+
231
+ .tab-nav-item
232
+ @apply relative rounded-t bg-white
233
+
234
+ &:first-child
235
+ .tab-nav-item-link
236
+ &:after
237
+ content ""
238
+ @apply absolute bottom-0 left-0 w-px h-3 s("-mb-3") s("-ml-px") bg-border
239
+
240
+ &.active
241
+ @apply s("pb-1.75")
242
+
243
+ &:before
244
+ content ""
245
+ @apply block absolute s("top-0.5") s("right-0.75") s("left-0.75") h-1 bg-secondary-hover
246
+
247
+ .tab-nav-item-link
248
+ @apply text-primary cursor-default
249
+
250
+ &-link
251
+ @apply relative block s("py-1.75") s("px-3.75") border-t border-r border-l border-border rounded-t text-lg text-primary-light
252
+
253
+ &-title
254
+ @apply truncate
255
+
256
+ .tab-pane
257
+ @apply space-y-8
258
+
259
+ & > .tabs-content
260
+ @apply p-4 border border-border rounded-lg bg-white overflow-hidden
261
+
262
+ .tabs-content-header
263
+ @apply flex items-start justify-between mb-4
264
+
265
+ &.tabs-type-2
266
+ & > .tabs-nav
267
+ @apply mb-0
268
+
269
+ ul
270
+ @apply flex px-8 pb-5 space-x-8
271
+ @apply s('lg:px-6') s('lg:space-x-14')
272
+
273
+ .tab-nav-item
274
+ @apply relative flex-grow s('py-6') rounded bg-bg text-lg text-primary-hover text-center
275
+ @apply s('lg:py-5.5')
276
+
277
+ &:before
278
+ content ""
279
+ @apply absolute s('top-0.5') s('left-0.5') block rounded bg-white
280
+ width calc(100% - theme('spacing.1'))
281
+ height calc(100% - theme('spacing.1'))
282
+
283
+ &:after
284
+ content ""
285
+ @apply absolute left-0 bottom-0 s('-ml-4') s('-mb-5') block w-full h-3 rounded-t bg-primary-lighter opacity-0
286
+ width calc(100% + theme('spacing.4') * 2)
287
+
288
+ &.active
289
+ @apply text-primary font-bold
290
+
291
+ &:after
292
+ @apply opacity-100
293
+
294
+ &:nth-child(odd)
295
+ @apply bg-transparent s('bg-gradient-to-r') s('from-insight-web-title-start') s('to-insight-web-title-end')
296
+
297
+ &:after
298
+ @apply bg-transparent s('bg-gradient-to-r') s('from-insight-web-title-start') s('to-insight-web-title-end')
299
+
300
+ &:nth-child(even)
301
+ @apply bg-transparent s('bg-gradient-to-r') s('from-insight-poi-title-start') s('to-insight-poi-title-end')
302
+
303
+ &:after
304
+ @apply bg-transparent s('bg-gradient-to-r') s('from-insight-poi-title-start') s('to-insight-poi-title-end')
305
+
306
+ .tab-nav-item-link
307
+ @apply cursor-default
308
+
309
+ &-link
310
+ @apply relative
311
+
312
+ &.tabs-type-3
313
+ & > .tabs-nav
314
+ @apply flex items-start justify-between h-0 space-x-8 overflow-hidden
315
+ @apply s('lg:space-x-30')
316
+
317
+ &.show
318
+ @apply h-auto mb-1
319
+
320
+ .tabs-nav-left
321
+ @apply flex-grow overflow-hidden
322
+
323
+ .tabs-nav-right
324
+ @apply flex-grow-0 flex-shrink-0
325
+
326
+ ul
327
+ @apply inline-flex items-start space-x-2
328
+
329
+ .tab-nav-item
330
+ @apply relative rounded-t bg-bg
331
+
332
+ &.active
333
+ @apply bg-primary
334
+
335
+ .tab-nav-item-link
336
+ @apply text-white cursor-default
337
+
338
+ &-link
339
+ @apply relative block py-2 px-8 rounded-t text-base text-primary
340
+
341
+ &-title
342
+ @apply truncate
343
+
344
+ .tab-pane
345
+ @apply space-y-8
346
+
347
+ & > .tabs-content
348
+ @apply p-6 rounded-tr-lg rounded-b-lg bg-white shadow overflow-hidden
349
+
350
+ .tabs-content-header
351
+ @apply flex items-start justify-between
352
+
353
+ .tabs-dropdown
354
+ @apply mb-4
355
+
356
+ &.tabs-type-4
357
+ @apply flex
358
+
359
+ & > .tabs-nav
360
+ @apply flex-grow-0 flex-shrink-0
361
+
362
+ .tabs-nav-left
363
+ ul
364
+ @apply flex flex-col s('space-y-0.5')
365
+
366
+ .tab-nav-item
367
+ @apply flex justify-between s('w-[184px]') py-3 pl-3 pr-5 bg-bg-middle rounded-l-lg text-xs
368
+
369
+ &.active
370
+ @apply bg-primary-hover text-white font-bold shadow-md
371
+
372
+ &-link
373
+ @apply block w-full
374
+
375
+ .tabs-content
376
+ @apply flex-grow s('-ml-2') p-4 bg-white border border-border rounded-lg shadow-md
377
+
378
+ & > div
379
+ @apply flex min-h-full
380
+
381
+ .tabs-content-body
382
+ @apply w-full
383
+
384
+ & > .tabs-content
385
+ .tabs
386
+ & > .tabs-content
387
+ @apply shadow-md
388
+ </style>