|
1 | 1 | <script setup> |
2 | | -import { ref, computed, nextTick, onMounted } from "vue"; |
3 | | -import { treeShake, palette, opacity, convertConfigColors, makeXls, shiftHue } from '../lib'; |
| 2 | +import { ref, computed, nextTick } from "vue"; |
| 3 | +import { opacity, makeXls, shiftHue } from '../lib'; |
4 | 4 | import pdf from "../pdf"; |
5 | 5 | import mainConfig from "../default_configs.json"; |
6 | 6 | import { useMouse } from "../useMouse"; |
7 | 7 | import { calcTooltipPosition } from "../calcTooltipPosition"; |
8 | 8 | import { useNestedProp } from "../useNestedProp"; |
9 | 9 | import Title from "../atoms/Title.vue"; |
| 10 | +import UserOptions from "../atoms/UserOptions.vue"; |
10 | 11 |
|
11 | 12 | const props = defineProps({ |
12 | 13 | config: { |
@@ -237,12 +238,6 @@ function generateXls() { |
237 | 238 | }); |
238 | 239 | } |
239 | 240 |
|
240 | | -function closeDetails(){ |
241 | | - if(details.value) { |
242 | | - details.value.removeAttribute("open") |
243 | | - } |
244 | | -} |
245 | | -
|
246 | 241 | defineExpose({ |
247 | 242 | generatePdf, |
248 | 243 | generateXls |
@@ -275,39 +270,33 @@ defineExpose({ |
275 | 270 | </div> |
276 | 271 |
|
277 | 272 | <!-- OPTIONS --> |
278 | | - <details class="vue-ui-age-pyramid-user-options" :style="`background:${agePyramidConfig.style.backgroundColor};color:${agePyramidConfig.style.color}`" data-html2canvas-ignore v-if="agePyramidConfig.userOptions.show" ref="details"> |
279 | | - <summary :style="`background:${agePyramidConfig.style.backgroundColor};color:${agePyramidConfig.style.color}`">{{ agePyramidConfig.userOptions.title }}</summary> |
280 | | - |
281 | | - <div class="vue-ui-age-pyramid-user-options-items" :style="`background:${agePyramidConfig.style.backgroundColor};color:${agePyramidConfig.style.color}`"> |
282 | | - <div class="vue-ui-age-pyramid-user-option-item"> |
| 273 | + <UserOptions |
| 274 | + ref="details" |
| 275 | + v-if="agePyramidConfig.userOptions.show" |
| 276 | + :backgroundColor="agePyramidConfig.style.backgroundColor" |
| 277 | + :color="agePyramidConfig.style.color" |
| 278 | + :isPrinting="isPrinting" |
| 279 | + :title="agePyramidConfig.userOptions.title" |
| 280 | + :uid="uid" |
| 281 | + @generatePdf="generatePdf" |
| 282 | + @generateXls="generateXls" |
| 283 | + > |
| 284 | + <template #checkboxes> |
| 285 | + <div class="vue-ui-options-item"> |
283 | 286 | <input type="checkbox" :id="`vue-ui-age-pyramid-option-title_${uid}`" :name="`vue-ui-age-pyramid-option-title_${uid}`" |
284 | 287 | v-model="mutableConfig.inside"> |
285 | 288 | <label :for="`vue-ui-age-pyramid-option-title_${uid}`">{{ agePyramidConfig.userOptions.labels.useDiv }}</label> |
286 | 289 | </div> |
287 | | - <div class="vue-ui-age-pyramid-user-option-item"> |
| 290 | + <div class="vue-ui-options-item"> |
288 | 291 | <input type="checkbox" :id="`vue-ui-age-pyramid-option-table_${uid}`" :name="`vue-ui-age-pyramid-option-table_${uid}`" |
289 | 292 | v-model="mutableConfig.showTable"> |
290 | 293 | <label :for="`vue-ui-age-pyramid-option-table_${uid}`">{{ agePyramidConfig.userOptions.labels.showTable }}</label> |
291 | 294 | </div> |
292 | | - <button class="vue-ui-age-pyramid-button" @click="generatePdf" :disabled="isPrinting" style="margin-top:12px" :style="`background:${agePyramidConfig.style.backgroundColor};color:${agePyramidConfig.style.color}`"> |
293 | | - <svg class="vue-ui-age-pyramid-print-icon" xmlns="http://www.w3.org/2000/svg" v-if="isPrinting" width="20" height="20" viewBox="0 0 24 24" stroke-width="1.5" :stroke="agePyramidConfig.style.color" fill="none" stroke-linecap="round" stroke-linejoin="round"> |
294 | | - <path stroke="none" d="M0 0h24v24H0z" fill="none"/> |
295 | | - <path d="M18 16v.01" /> |
296 | | - <path d="M6 16v.01" /> |
297 | | - <path d="M12 5v.01" /> |
298 | | - <path d="M12 12v.01" /> |
299 | | - <path d="M12 1a4 4 0 0 1 2.001 7.464l.001 .072a3.998 3.998 0 0 1 1.987 3.758l.22 .128a3.978 3.978 0 0 1 1.591 -.417l.2 -.005a4 4 0 1 1 -3.994 3.77l-.28 -.16c-.522 .25 -1.108 .39 -1.726 .39c-.619 0 -1.205 -.14 -1.728 -.391l-.279 .16l.007 .231a4 4 0 1 1 -2.212 -3.579l.222 -.129a3.998 3.998 0 0 1 1.988 -3.756l.002 -.071a4 4 0 0 1 -1.995 -3.265l-.005 -.2a4 4 0 0 1 4 -4z" /> |
300 | | - </svg> |
301 | | - <span v-else>PDF</span> |
302 | | - </button> |
303 | | - <button class="vue-ui-age-pyramid-button" @click="generateXls" :style="`background:${agePyramidConfig.style.backgroundColor};color:${agePyramidConfig.style.color}`"> |
304 | | - XLSX |
305 | | - </button> |
306 | | - </div> |
307 | | - </details> |
| 295 | + </template> |
| 296 | + </UserOptions> |
308 | 297 |
|
309 | 298 | <!-- CHART --> |
310 | | - <svg :viewBox="`0 0 ${svg.width} ${svg.height}`" :style="`max-width:100%;overflow:visible;background:${agePyramidConfig.style.backgroundColor};color:${agePyramidConfig.style.color}`" @click="closeDetails"> |
| 299 | + <svg :viewBox="`0 0 ${svg.width} ${svg.height}`" :style="`max-width:100%;overflow:visible;background:${agePyramidConfig.style.backgroundColor};color:${agePyramidConfig.style.color}`" > |
311 | 300 |
|
312 | 301 | <defs> |
313 | 302 | <linearGradient |
@@ -539,7 +528,7 @@ defineExpose({ |
539 | 528 | /> |
540 | 529 |
|
541 | 530 | <!-- DATA TABLE --> |
542 | | - <div @click="closeDetails" :style="`${isPrinting ? '' : 'max-height:400px'};overflow:auto;width:100%;margin-top:${mutableConfig.inside ? '48px' : ''}`" v-if="mutableConfig.showTable"> |
| 531 | + <div :style="`${isPrinting ? '' : 'max-height:400px'};overflow:auto;width:100%;margin-top:${mutableConfig.inside ? '48px' : ''}`" v-if="mutableConfig.showTable"> |
543 | 532 | <table> |
544 | 533 | <thead> |
545 | 534 | <tr v-if="agePyramidConfig.style.title.text"> |
@@ -628,61 +617,6 @@ defineExpose({ |
628 | 617 | z-index:1; |
629 | 618 | font-variant-numeric: tabular-nums; |
630 | 619 | } |
631 | | -.vue-ui-age-pyramid-user-options { |
632 | | - border-radius: 4px; |
633 | | - padding: 6px 12px; |
634 | | - position: absolute; |
635 | | - right:0; |
636 | | - top:0px; |
637 | | - max-width: 300px; |
638 | | - text-align:left; |
639 | | -} |
640 | | -.vue-ui-age-pyramid-user-options[open] { |
641 | | - border: 1px solid #e1e5e8; |
642 | | - box-shadow: 0 6px 12px -6px rgba(0,0,0,0.2); |
643 | | -} |
644 | | -.vue-ui-age-pyramid summary { |
645 | | - text-align: right; |
646 | | - direction: rtl; |
647 | | -} |
648 | | -.vue-ui-age-pyramid-user-options-items { |
649 | | - width: 100%; |
650 | | - display: flex; |
651 | | - flex-direction: column; |
652 | | - margin-top: 6px; |
653 | | -} |
654 | | -.vue-ui-age-pyramid-user-options-item { |
655 | | - width: 100%; |
656 | | - display: flex; |
657 | | - flex-direction: row; |
658 | | - gap: 5px; |
659 | | - align-items:center; |
660 | | -} |
661 | | -
|
662 | | -.vue-ui-age-pyramid-button { |
663 | | - margin: 6px 0; |
664 | | - border-radius: 3px; |
665 | | - height: 30px; |
666 | | - border: 1px solid #b9bfc4; |
667 | | - background: inherit; |
668 | | - display: flex; |
669 | | - align-items:center; |
670 | | - justify-content: center; |
671 | | -} |
672 | | -.vue-ui-age-pyramid-button:hover { |
673 | | - background: rgba(0,0,0,0.05); |
674 | | -} |
675 | | -.vue-ui-age-pyramid-print-icon { |
676 | | - animation: smartspin 0.5s infinite linear; |
677 | | -} |
678 | | -@keyframes smartspin { |
679 | | - from { |
680 | | - transform: rotate(0deg); |
681 | | - } |
682 | | - to { |
683 | | - transform: rotate(360deg); |
684 | | - } |
685 | | -} |
686 | 620 |
|
687 | 621 | .vue-ui-age-pyramid table { |
688 | 622 | width: 100%; |
|
0 commit comments