@thinkpixellab-public/px-vue 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.
- package/.eslintrc.js +14 -0
- package/.prettierrc.js +10 -0
- package/LICENSE.md +9 -0
- package/README.md +83 -0
- package/assets/feather/activity.svg +1 -0
- package/assets/feather/airplay.svg +1 -0
- package/assets/feather/alert-circle.svg +1 -0
- package/assets/feather/alert-octagon.svg +1 -0
- package/assets/feather/alert-triangle.svg +1 -0
- package/assets/feather/align-center.svg +1 -0
- package/assets/feather/align-justify.svg +1 -0
- package/assets/feather/align-left.svg +1 -0
- package/assets/feather/align-right.svg +1 -0
- package/assets/feather/anchor.svg +1 -0
- package/assets/feather/aperture.svg +1 -0
- package/assets/feather/archive.svg +1 -0
- package/assets/feather/arrow-down-circle.svg +1 -0
- package/assets/feather/arrow-down-left.svg +1 -0
- package/assets/feather/arrow-down-right.svg +1 -0
- package/assets/feather/arrow-down.svg +1 -0
- package/assets/feather/arrow-left-circle.svg +1 -0
- package/assets/feather/arrow-left.svg +1 -0
- package/assets/feather/arrow-right-circle.svg +1 -0
- package/assets/feather/arrow-right.svg +1 -0
- package/assets/feather/arrow-up-circle.svg +1 -0
- package/assets/feather/arrow-up-left.svg +1 -0
- package/assets/feather/arrow-up-right.svg +1 -0
- package/assets/feather/arrow-up.svg +1 -0
- package/assets/feather/at-sign.svg +1 -0
- package/assets/feather/award.svg +1 -0
- package/assets/feather/bar-chart-2.svg +1 -0
- package/assets/feather/bar-chart.svg +1 -0
- package/assets/feather/battery-charging.svg +1 -0
- package/assets/feather/battery.svg +1 -0
- package/assets/feather/bell-off.svg +1 -0
- package/assets/feather/bell.svg +1 -0
- package/assets/feather/bluetooth.svg +1 -0
- package/assets/feather/bold.svg +1 -0
- package/assets/feather/book-open.svg +1 -0
- package/assets/feather/book.svg +1 -0
- package/assets/feather/bookmark.svg +1 -0
- package/assets/feather/box.svg +1 -0
- package/assets/feather/briefcase.svg +1 -0
- package/assets/feather/calendar.svg +1 -0
- package/assets/feather/camera-off.svg +1 -0
- package/assets/feather/camera.svg +1 -0
- package/assets/feather/cast.svg +1 -0
- package/assets/feather/check-circle.svg +1 -0
- package/assets/feather/check-square.svg +1 -0
- package/assets/feather/check.svg +1 -0
- package/assets/feather/chevron-down.svg +1 -0
- package/assets/feather/chevron-left.svg +1 -0
- package/assets/feather/chevron-right.svg +1 -0
- package/assets/feather/chevron-up.svg +1 -0
- package/assets/feather/chevrons-down.svg +1 -0
- package/assets/feather/chevrons-left.svg +1 -0
- package/assets/feather/chevrons-right.svg +1 -0
- package/assets/feather/chevrons-up.svg +1 -0
- package/assets/feather/chrome.svg +1 -0
- package/assets/feather/circle.svg +1 -0
- package/assets/feather/clipboard.svg +1 -0
- package/assets/feather/clock.svg +1 -0
- package/assets/feather/cloud-drizzle.svg +1 -0
- package/assets/feather/cloud-lightning.svg +1 -0
- package/assets/feather/cloud-off.svg +1 -0
- package/assets/feather/cloud-rain.svg +1 -0
- package/assets/feather/cloud-snow.svg +1 -0
- package/assets/feather/cloud.svg +1 -0
- package/assets/feather/code.svg +1 -0
- package/assets/feather/codepen.svg +1 -0
- package/assets/feather/codesandbox.svg +1 -0
- package/assets/feather/coffee.svg +1 -0
- package/assets/feather/columns.svg +1 -0
- package/assets/feather/command.svg +1 -0
- package/assets/feather/compass.svg +1 -0
- package/assets/feather/copy.svg +1 -0
- package/assets/feather/corner-down-left.svg +1 -0
- package/assets/feather/corner-down-right.svg +1 -0
- package/assets/feather/corner-left-down.svg +1 -0
- package/assets/feather/corner-left-up.svg +1 -0
- package/assets/feather/corner-right-down.svg +1 -0
- package/assets/feather/corner-right-up.svg +1 -0
- package/assets/feather/corner-up-left.svg +1 -0
- package/assets/feather/corner-up-right.svg +1 -0
- package/assets/feather/cpu.svg +1 -0
- package/assets/feather/credit-card.svg +1 -0
- package/assets/feather/crop.svg +1 -0
- package/assets/feather/crosshair.svg +1 -0
- package/assets/feather/database.svg +1 -0
- package/assets/feather/delete.svg +1 -0
- package/assets/feather/disc.svg +1 -0
- package/assets/feather/divide-circle.svg +1 -0
- package/assets/feather/divide-square.svg +1 -0
- package/assets/feather/divide.svg +1 -0
- package/assets/feather/dollar-sign.svg +1 -0
- package/assets/feather/download-cloud.svg +1 -0
- package/assets/feather/download.svg +1 -0
- package/assets/feather/dribbble.svg +1 -0
- package/assets/feather/droplet.svg +1 -0
- package/assets/feather/edit-2.svg +1 -0
- package/assets/feather/edit-3.svg +1 -0
- package/assets/feather/edit.svg +1 -0
- package/assets/feather/external-link.svg +1 -0
- package/assets/feather/eye-off.svg +1 -0
- package/assets/feather/eye.svg +1 -0
- package/assets/feather/facebook.svg +1 -0
- package/assets/feather/fast-forward.svg +1 -0
- package/assets/feather/feather.svg +1 -0
- package/assets/feather/figma.svg +1 -0
- package/assets/feather/file-minus.svg +1 -0
- package/assets/feather/file-plus.svg +1 -0
- package/assets/feather/file-text.svg +1 -0
- package/assets/feather/file.svg +1 -0
- package/assets/feather/film.svg +1 -0
- package/assets/feather/filter.svg +1 -0
- package/assets/feather/flag.svg +1 -0
- package/assets/feather/folder-minus.svg +1 -0
- package/assets/feather/folder-plus.svg +1 -0
- package/assets/feather/folder.svg +1 -0
- package/assets/feather/framer.svg +1 -0
- package/assets/feather/frown.svg +1 -0
- package/assets/feather/gift.svg +1 -0
- package/assets/feather/git-branch.svg +1 -0
- package/assets/feather/git-commit.svg +1 -0
- package/assets/feather/git-merge.svg +1 -0
- package/assets/feather/git-pull-request.svg +1 -0
- package/assets/feather/github.svg +1 -0
- package/assets/feather/gitlab.svg +1 -0
- package/assets/feather/globe.svg +1 -0
- package/assets/feather/grid.svg +1 -0
- package/assets/feather/hard-drive.svg +1 -0
- package/assets/feather/hash.svg +1 -0
- package/assets/feather/headphones.svg +1 -0
- package/assets/feather/heart.svg +1 -0
- package/assets/feather/help-circle.svg +1 -0
- package/assets/feather/hexagon.svg +1 -0
- package/assets/feather/home.svg +1 -0
- package/assets/feather/image.svg +1 -0
- package/assets/feather/inbox.svg +1 -0
- package/assets/feather/info.svg +1 -0
- package/assets/feather/instagram.svg +1 -0
- package/assets/feather/italic.svg +1 -0
- package/assets/feather/key.svg +1 -0
- package/assets/feather/layers.svg +1 -0
- package/assets/feather/layout.svg +1 -0
- package/assets/feather/life-buoy.svg +1 -0
- package/assets/feather/link-2.svg +1 -0
- package/assets/feather/link.svg +1 -0
- package/assets/feather/linkedin.svg +1 -0
- package/assets/feather/list.svg +1 -0
- package/assets/feather/loader.svg +1 -0
- package/assets/feather/lock.svg +1 -0
- package/assets/feather/log-in.svg +1 -0
- package/assets/feather/log-out.svg +1 -0
- package/assets/feather/mail.svg +1 -0
- package/assets/feather/map-pin.svg +1 -0
- package/assets/feather/map.svg +1 -0
- package/assets/feather/maximize-2.svg +1 -0
- package/assets/feather/maximize.svg +1 -0
- package/assets/feather/meh.svg +1 -0
- package/assets/feather/menu.svg +1 -0
- package/assets/feather/message-circle.svg +1 -0
- package/assets/feather/message-square.svg +1 -0
- package/assets/feather/mic-off.svg +1 -0
- package/assets/feather/mic.svg +1 -0
- package/assets/feather/minimize-2.svg +1 -0
- package/assets/feather/minimize.svg +1 -0
- package/assets/feather/minus-circle.svg +1 -0
- package/assets/feather/minus-square.svg +1 -0
- package/assets/feather/minus.svg +1 -0
- package/assets/feather/monitor.svg +1 -0
- package/assets/feather/moon.svg +1 -0
- package/assets/feather/more-horizontal.svg +1 -0
- package/assets/feather/more-vertical.svg +1 -0
- package/assets/feather/mouse-pointer.svg +1 -0
- package/assets/feather/move.svg +1 -0
- package/assets/feather/music.svg +1 -0
- package/assets/feather/navigation-2.svg +1 -0
- package/assets/feather/navigation.svg +1 -0
- package/assets/feather/octagon.svg +1 -0
- package/assets/feather/package.svg +1 -0
- package/assets/feather/paperclip.svg +1 -0
- package/assets/feather/pause-circle.svg +1 -0
- package/assets/feather/pause.svg +1 -0
- package/assets/feather/pen-tool.svg +1 -0
- package/assets/feather/percent.svg +1 -0
- package/assets/feather/phone-call.svg +1 -0
- package/assets/feather/phone-forwarded.svg +1 -0
- package/assets/feather/phone-incoming.svg +1 -0
- package/assets/feather/phone-missed.svg +1 -0
- package/assets/feather/phone-off.svg +1 -0
- package/assets/feather/phone-outgoing.svg +1 -0
- package/assets/feather/phone.svg +1 -0
- package/assets/feather/pie-chart.svg +1 -0
- package/assets/feather/play-circle.svg +1 -0
- package/assets/feather/play.svg +1 -0
- package/assets/feather/plus-circle.svg +1 -0
- package/assets/feather/plus-square.svg +1 -0
- package/assets/feather/plus.svg +1 -0
- package/assets/feather/pocket.svg +1 -0
- package/assets/feather/power.svg +1 -0
- package/assets/feather/printer.svg +1 -0
- package/assets/feather/radio.svg +1 -0
- package/assets/feather/refresh-ccw.svg +1 -0
- package/assets/feather/refresh-cw.svg +1 -0
- package/assets/feather/repeat.svg +1 -0
- package/assets/feather/rewind.svg +1 -0
- package/assets/feather/rotate-ccw.svg +1 -0
- package/assets/feather/rotate-cw.svg +1 -0
- package/assets/feather/rss.svg +1 -0
- package/assets/feather/save.svg +1 -0
- package/assets/feather/scissors.svg +1 -0
- package/assets/feather/search.svg +1 -0
- package/assets/feather/send.svg +1 -0
- package/assets/feather/server.svg +1 -0
- package/assets/feather/settings.svg +1 -0
- package/assets/feather/share-2.svg +1 -0
- package/assets/feather/share.svg +1 -0
- package/assets/feather/shield-off.svg +1 -0
- package/assets/feather/shield.svg +1 -0
- package/assets/feather/shopping-bag.svg +1 -0
- package/assets/feather/shopping-cart.svg +1 -0
- package/assets/feather/shuffle.svg +1 -0
- package/assets/feather/sidebar.svg +1 -0
- package/assets/feather/skip-back.svg +1 -0
- package/assets/feather/skip-forward.svg +1 -0
- package/assets/feather/slack.svg +1 -0
- package/assets/feather/slash.svg +1 -0
- package/assets/feather/sliders.svg +1 -0
- package/assets/feather/smartphone.svg +1 -0
- package/assets/feather/smile.svg +1 -0
- package/assets/feather/speaker.svg +1 -0
- package/assets/feather/square.svg +1 -0
- package/assets/feather/star.svg +1 -0
- package/assets/feather/stop-circle.svg +1 -0
- package/assets/feather/sun.svg +1 -0
- package/assets/feather/sunrise.svg +1 -0
- package/assets/feather/sunset.svg +1 -0
- package/assets/feather/table.svg +1 -0
- package/assets/feather/tablet.svg +1 -0
- package/assets/feather/tag.svg +1 -0
- package/assets/feather/target.svg +1 -0
- package/assets/feather/terminal.svg +1 -0
- package/assets/feather/thermometer.svg +1 -0
- package/assets/feather/thumbs-down.svg +1 -0
- package/assets/feather/thumbs-up.svg +1 -0
- package/assets/feather/toggle-left.svg +1 -0
- package/assets/feather/toggle-right.svg +1 -0
- package/assets/feather/tool.svg +1 -0
- package/assets/feather/trash-2.svg +1 -0
- package/assets/feather/trash.svg +1 -0
- package/assets/feather/trello.svg +1 -0
- package/assets/feather/trending-down.svg +1 -0
- package/assets/feather/trending-up.svg +1 -0
- package/assets/feather/triangle.svg +1 -0
- package/assets/feather/truck.svg +1 -0
- package/assets/feather/tv.svg +1 -0
- package/assets/feather/twitch.svg +1 -0
- package/assets/feather/twitter.svg +1 -0
- package/assets/feather/type.svg +1 -0
- package/assets/feather/umbrella.svg +1 -0
- package/assets/feather/underline.svg +1 -0
- package/assets/feather/unlock.svg +1 -0
- package/assets/feather/upload-cloud.svg +1 -0
- package/assets/feather/upload.svg +1 -0
- package/assets/feather/user-check.svg +1 -0
- package/assets/feather/user-minus.svg +1 -0
- package/assets/feather/user-plus.svg +1 -0
- package/assets/feather/user-x.svg +1 -0
- package/assets/feather/user.svg +1 -0
- package/assets/feather/users.svg +1 -0
- package/assets/feather/video-off.svg +1 -0
- package/assets/feather/video.svg +1 -0
- package/assets/feather/voicemail.svg +1 -0
- package/assets/feather/volume-1.svg +1 -0
- package/assets/feather/volume-2.svg +1 -0
- package/assets/feather/volume-x.svg +1 -0
- package/assets/feather/volume.svg +1 -0
- package/assets/feather/watch.svg +1 -0
- package/assets/feather/wifi-off.svg +1 -0
- package/assets/feather/wifi.svg +1 -0
- package/assets/feather/wind.svg +1 -0
- package/assets/feather/x-circle.svg +1 -0
- package/assets/feather/x-octagon.svg +1 -0
- package/assets/feather/x-square.svg +1 -0
- package/assets/feather/x.svg +1 -0
- package/assets/feather/youtube.svg +1 -0
- package/assets/feather/zap-off.svg +1 -0
- package/assets/feather/zap.svg +1 -0
- package/assets/feather/zoom-in.svg +1 -0
- package/assets/feather/zoom-out.svg +1 -0
- package/assets/icons/calendar.svg +6 -0
- package/assets/icons/check.svg +1 -0
- package/assets/icons/close-sm.svg +1 -0
- package/assets/icons/close.svg +1 -0
- package/assets/icons/copy.svg +1 -0
- package/assets/icons/dropdown.svg +8 -0
- package/assets/icons/invalid.svg +1 -0
- package/assets/icons/menu.svg +1 -0
- package/assets/icons/nav-next.svg +1 -0
- package/assets/icons/nav-prev.svg +1 -0
- package/assets/icons/sort-asc.svg +1 -0
- package/assets/icons/sort-desc.svg +1 -0
- package/assets/test/README.md +1 -0
- package/assets/test/trash.svg +8 -0
- package/babel.config.js +16 -0
- package/components/PxAspect.vue +127 -0
- package/components/PxAutoClamp.vue +75 -0
- package/components/PxBalancedText.vue +118 -0
- package/components/PxBase.vue +15 -0
- package/components/PxBaseDate.vue +27 -0
- package/components/PxBaseItems.vue +72 -0
- package/components/PxBaseItemsSelect.vue +230 -0
- package/components/PxBaseResize.vue +60 -0
- package/components/PxBaseToggle.vue +56 -0
- package/components/PxBaseVariants.vue +62 -0
- package/components/PxBaseVisible.vue +40 -0
- package/components/PxCalendar.vue +385 -0
- package/components/PxCard.vue +47 -0
- package/components/PxCardGrid.vue +386 -0
- package/components/PxClock.vue +510 -0
- package/components/PxCopyText.vue +78 -0
- package/components/PxDatePicker.vue +249 -0
- package/components/PxDropdown.vue +181 -0
- package/components/PxExpander.vue +46 -0
- package/components/PxFeatherIcon.vue +29 -0
- package/components/PxFeatherIconButton.vue +19 -0
- package/components/PxFit.vue +274 -0
- package/components/PxFlex.vue +93 -0
- package/components/PxFloat.vue +32 -0
- package/components/PxIcon.vue +43 -0
- package/components/PxIconButton.vue +115 -0
- package/components/PxIdUniquer.vue +59 -0
- package/components/PxModal.vue +365 -0
- package/components/PxNineGrid.vue +94 -0
- package/components/PxPivot.vue +207 -0
- package/components/PxPopup.vue +230 -0
- package/components/PxPortal.vue +138 -0
- package/components/PxPortalTarget.vue +25 -0
- package/components/PxProgressCircle.vue +73 -0
- package/components/PxRadioButton.vue +83 -0
- package/components/PxSideDrawer.vue +164 -0
- package/components/PxSlideTransition.vue +116 -0
- package/components/PxSlides.vue +217 -0
- package/components/PxStylesPreview.vue +129 -0
- package/components/PxSvg.vue +157 -0
- package/components/PxSwiper.vue +271 -0
- package/components/PxSwiperSlide.vue +42 -0
- package/components/PxSyncHeight.vue +137 -0
- package/components/PxTable.vue +323 -0
- package/components/PxTabs.vue +1 -0
- package/components/PxTextbox.vue +90 -0
- package/components/PxToggle.vue +125 -0
- package/components/PxToggleButton.vue +139 -0
- package/components/PxToggleButtonList.vue +131 -0
- package/components/PxTransitionExpand.vue +100 -0
- package/components/PxValidator.vue +431 -0
- package/components/PxVueTest.vue +761 -0
- package/components/README.md +0 -0
- package/dev/data/fruits.js +59 -0
- package/dev/data/random.js +13 -0
- package/dev/demos/Demo-PxBaseDrag.vue +94 -0
- package/dev/demos/Demo-PxCardGrid.vue +53 -0
- package/dev/demos/Demo-PxPivot.vue +58 -0
- package/dev/demos/Demo-PxSideDrawer.vue +72 -0
- package/dev/demos/Demo-PxSlideTransition.vue +86 -0
- package/dev/demos/Demo-PxSlides.vue +142 -0
- package/dev/demos/Demo-PxStylesPreview.vue +46 -0
- package/dev/demos/Demo-PxSwiper.vue +44 -0
- package/dev/demos/DemoPicker.vue +79 -0
- package/dev/dev.vue +56 -0
- package/dev/serve.js +17 -0
- package/package.json +45 -0
- package/plugins/common-client.js +13 -0
- package/plugins/common-lib.js +4 -0
- package/plugins/common.js +39 -0
- package/plugins/filters/aspect.js +14 -0
- package/plugins/filters/date.js +26 -0
- package/plugins/filters/kebab.js +9 -0
- package/plugins/filters/phone.js +7 -0
- package/plugins/filters/slug.js +26 -0
- package/plugins/filters/spacenator.js +11 -0
- package/plugins/filters/stringToItems.js +28 -0
- package/plugins/filters/striphtml.js +10 -0
- package/plugins/mixins/eventBus.js +23 -0
- package/px-styles.config.scss +12 -0
- package/styles/helpers.scss +14 -0
- package/styles/px.scss +6 -0
- package/utils/balanceText.js +123 -0
- package/utils/bem.js +99 -0
- package/utils/cardGrid.js +383 -0
- package/utils/cssStr.js +45 -0
- package/utils/drag.js +363 -0
- package/utils/fit.js +73 -0
- package/utils/tween.js +129 -0
- package/utils/utils.js +167 -0
- package/utils/variants.js +33 -0
- package/vue.config.js +12 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="tag"
|
|
4
|
+
class="px-balanced-text"
|
|
5
|
+
:style="{ opacity: elementOpacity, color: debugColor }"
|
|
6
|
+
>
|
|
7
|
+
<!-- html -->
|
|
8
|
+
<component v-if="hasHtml" :class="bem('inner')" :is="innerTag" ref="text" v-html="html" />
|
|
9
|
+
|
|
10
|
+
<!-- slot -->
|
|
11
|
+
<component v-else :class="bem('inner')" :is="innerTag" ref="text">
|
|
12
|
+
<slot />
|
|
13
|
+
</component>
|
|
14
|
+
</component>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
import PxBaseResize from './PxBaseResize.vue';
|
|
19
|
+
import balanceText from '../utils/balanceText.js';
|
|
20
|
+
|
|
21
|
+
export default {
|
|
22
|
+
mixins: [PxBaseResize],
|
|
23
|
+
props: {
|
|
24
|
+
// the outer tag element
|
|
25
|
+
tag: { type: String, default: 'p' },
|
|
26
|
+
|
|
27
|
+
// the inner tag element
|
|
28
|
+
innerTag: { type: String, default: 'span' },
|
|
29
|
+
|
|
30
|
+
// html that gets set on the inner tag element
|
|
31
|
+
html: { type: String, default: null },
|
|
32
|
+
|
|
33
|
+
// set to false to disable the balancing alorithm
|
|
34
|
+
enabled: { type: Boolean, default: true },
|
|
35
|
+
|
|
36
|
+
// when true opacity will be set to 0 if balancing is enabled but text is unbalanced (as a
|
|
37
|
+
// precaution, we also show if balancing fails for some reason)
|
|
38
|
+
hideUnbalanced: { type: Boolean, default: true },
|
|
39
|
+
|
|
40
|
+
// enable to get debug color (blue: balanced html, green: balance slot, red: disabled)
|
|
41
|
+
debug: { type: Boolean, default: false },
|
|
42
|
+
},
|
|
43
|
+
data() {
|
|
44
|
+
return {
|
|
45
|
+
balanced: false,
|
|
46
|
+
balanceFailed: false,
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
computed: {
|
|
50
|
+
hasHtml() {
|
|
51
|
+
return !!this.htmlValue;
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
htmlValue() {
|
|
55
|
+
return this.html?.trim();
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
elementOpacity() {
|
|
59
|
+
if (this.enabled && !this.balanceFailed && !this.balanced) {
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
},
|
|
64
|
+
debugColor() {
|
|
65
|
+
if (this.debug) {
|
|
66
|
+
if (!this.enabled) {
|
|
67
|
+
return 'red';
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (this.balanced && this.hasHtml) {
|
|
71
|
+
return 'blue';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (this.balanced) {
|
|
75
|
+
return 'green';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
watch: {
|
|
82
|
+
enabled() {
|
|
83
|
+
this.balanced = false;
|
|
84
|
+
if (!process.server) {
|
|
85
|
+
this.$nextTick(() => {
|
|
86
|
+
this.resize();
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
methods: {
|
|
92
|
+
resize() {
|
|
93
|
+
if (this.enabled && !process.server) {
|
|
94
|
+
try {
|
|
95
|
+
this.balanceFailed = false;
|
|
96
|
+
if (this.$refs.text && this.$refs.text.offsetWidth > 0) {
|
|
97
|
+
balanceText(this.$refs.text);
|
|
98
|
+
}
|
|
99
|
+
this.balanced = true;
|
|
100
|
+
} catch (error) {
|
|
101
|
+
console.error('balanceText failed');
|
|
102
|
+
console.error(error);
|
|
103
|
+
this.balanceFailed = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
</script>
|
|
110
|
+
|
|
111
|
+
<style lang="scss">
|
|
112
|
+
.px-balanced-text {
|
|
113
|
+
width: 100%;
|
|
114
|
+
&__inner {
|
|
115
|
+
display: inline-block;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
</style>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export default {
|
|
3
|
+
methods: {
|
|
4
|
+
/*
|
|
5
|
+
Get a unique id derived from vue's unique component identifier (this._uid) for use when an
|
|
6
|
+
id is required for an inputs, labels, etc.
|
|
7
|
+
uniqueId('label') => 'label-0003'
|
|
8
|
+
*/
|
|
9
|
+
uniqueId(prefix = null) {
|
|
10
|
+
let id = ('000000' + Number(this._uid).toString(16).toLowerCase()).slice(-4);
|
|
11
|
+
return prefix ? prefix + '-' + id : id;
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
</script>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export default {
|
|
3
|
+
model: {
|
|
4
|
+
prop: 'date',
|
|
5
|
+
event: 'changed',
|
|
6
|
+
},
|
|
7
|
+
props: {
|
|
8
|
+
date: { type: Date, default: null },
|
|
9
|
+
},
|
|
10
|
+
data() {
|
|
11
|
+
return {
|
|
12
|
+
dateValue: this.date,
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
watch: {
|
|
16
|
+
date: {
|
|
17
|
+
handler(nv) {
|
|
18
|
+
this.dateValue = nv;
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
dateValue(nv) {
|
|
22
|
+
this.$emit('update:date', nv);
|
|
23
|
+
this.$emit('changed', nv);
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
</script>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
Provides basic items services for controls that maintain lists of items.
|
|
4
|
+
|
|
5
|
+
-->
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
export default {
|
|
9
|
+
props: {
|
|
10
|
+
items: { type: Array },
|
|
11
|
+
itemsKeyProperty: { type: String, default: 'id' },
|
|
12
|
+
itemsValueProperty: { type: String, default: 'value' },
|
|
13
|
+
itemsLabelProperty: { type: String, default: 'label' },
|
|
14
|
+
itemsDisabledProperty: { type: String, default: 'disabled' },
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
computed: {
|
|
18
|
+
itemKeys() {
|
|
19
|
+
if (this.items) {
|
|
20
|
+
return this.items.map(item => this.getItemKey(item));
|
|
21
|
+
}
|
|
22
|
+
return [];
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
methods: {
|
|
26
|
+
isValidItemKey(key) {
|
|
27
|
+
this.itemKeys.includes(key);
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
getItem(key) {
|
|
31
|
+
if (typeof key !== 'undefined') {
|
|
32
|
+
return this.items.find(item => this.getItemKey(item) === key);
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
getItemKey(item) {
|
|
38
|
+
if (item && this.itemsKeyProperty) {
|
|
39
|
+
if (!(this.itemsKeyProperty in item)) {
|
|
40
|
+
console.warn(
|
|
41
|
+
`Key value property "${this.itemsKeyProperty}" could not be found.`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
return item[this.itemsKeyProperty];
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
getItemLabel(item) {
|
|
50
|
+
if (item && this.itemsLabelProperty && item[this.itemsLabelProperty]) {
|
|
51
|
+
return item[this.itemsLabelProperty];
|
|
52
|
+
}
|
|
53
|
+
// fallback to value
|
|
54
|
+
return this.getItemValue(item);
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
getItemValue(item) {
|
|
58
|
+
if (item && this.itemsValueProperty) {
|
|
59
|
+
return item[this.itemsValueProperty];
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
getItemDisabled(item) {
|
|
65
|
+
if (item && this.itemsDisabledProperty) {
|
|
66
|
+
return item[this.itemsDisabledProperty];
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
</script>
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Extends PxBaseItems to include selection. Selection is managed via item key.
|
|
3
|
+
|
|
4
|
+
@change: Fired whenever selection changes. The event argument is the array of selected keys.
|
|
5
|
+
@update:selected: Same as @change (duplicated so that .sync scenarios work)
|
|
6
|
+
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
import PxBaseItems from './PxBaseItems.vue';
|
|
11
|
+
import utils from '../utils/utils.js';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
mixins: [PxBaseItems],
|
|
15
|
+
|
|
16
|
+
model: {
|
|
17
|
+
prop: 'selected',
|
|
18
|
+
event: 'update:selected',
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
props: {
|
|
22
|
+
// whether to allow multiple items to be selected (note: this effects the expeected type for selected)
|
|
23
|
+
multiSelect: { type: Boolean, default: false },
|
|
24
|
+
|
|
25
|
+
// can be either a single value (the selected key) or an array of keys (if multiselect is enabled or selectionIsArray)
|
|
26
|
+
selected: { default: null },
|
|
27
|
+
|
|
28
|
+
// set this to manage selection as an array evne in multiSelect is true
|
|
29
|
+
selectedIsArray: { type: Boolean, default: false },
|
|
30
|
+
|
|
31
|
+
// if true, then an empty selection state will return a value of null instead of an empty array []
|
|
32
|
+
emptySelectionIsNull: { type: Boolean, default: false },
|
|
33
|
+
|
|
34
|
+
// if true, the first item in a collection will be automatically set when items is updated
|
|
35
|
+
// if no other item is selected
|
|
36
|
+
autoSelectFirst: { type: Boolean, default: false },
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
data() {
|
|
40
|
+
return {
|
|
41
|
+
syncSelected: this.ensureCorrectValue(this.selected),
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
computed: {
|
|
46
|
+
selectedIndex() {
|
|
47
|
+
if (!this.syncSelected) {
|
|
48
|
+
return -1;
|
|
49
|
+
}
|
|
50
|
+
return this.itemKeys.indexOf(this.syncSelected);
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
selectedItem() {
|
|
54
|
+
if (this.selectedIndex > -1) {
|
|
55
|
+
return this.items[this.selectedIndex];
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
watch: {
|
|
62
|
+
selected(nv) {
|
|
63
|
+
this.syncSelected = this.ensureCorrectValue(nv);
|
|
64
|
+
},
|
|
65
|
+
syncSelected(nv) {
|
|
66
|
+
this.emitUpdate(nv);
|
|
67
|
+
},
|
|
68
|
+
multiSelect() {
|
|
69
|
+
this.syncSelected = this.ensureCorrectValue(this.syncSelected);
|
|
70
|
+
},
|
|
71
|
+
items() {
|
|
72
|
+
this.tryAutoSelect();
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
mounted() {
|
|
77
|
+
this.$nextTick(() => {
|
|
78
|
+
this.tryAutoSelect();
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
methods: {
|
|
83
|
+
// general purpose method that converts a value to the appropriate type (array or value)
|
|
84
|
+
// based on whether multiselect is enabled
|
|
85
|
+
ensureCorrectValue(value) {
|
|
86
|
+
if (this.multiSelect || this.selectedIsArray) {
|
|
87
|
+
if (Array.isArray(value)) {
|
|
88
|
+
return value;
|
|
89
|
+
} else {
|
|
90
|
+
return value == null || typeof value == 'undefined' ? [] : [value];
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
if (Array.isArray(value)) {
|
|
94
|
+
return value.length ? value[0] : null;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return value;
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
// emit the change event (as a method so that it can be overriden)
|
|
101
|
+
emitUpdate(nv) {
|
|
102
|
+
nv = this.ensureCorrectValue(nv);
|
|
103
|
+
this.$emit('change', nv);
|
|
104
|
+
this.$emit('update:selected', nv);
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
// select the first non-disabled item if nothing else is selected
|
|
108
|
+
tryAutoSelect() {
|
|
109
|
+
if (this.items?.length && this.autoSelectFirst && !this.syncSelected) {
|
|
110
|
+
const firstSelectable = this.items.find(item => !this.getItemDisabled(item));
|
|
111
|
+
if (firstSelectable) {
|
|
112
|
+
this.selectItemOnly(firstSelectable);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
// key based methods
|
|
118
|
+
|
|
119
|
+
// check if a key is selected
|
|
120
|
+
isSelected(key) {
|
|
121
|
+
if (this.multiSelect || this.selectedIsArray) {
|
|
122
|
+
return this.syncSelected?.includes(key);
|
|
123
|
+
} else {
|
|
124
|
+
return this.syncSelected == key;
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
// add the keys to the current selection (for single select, we set the first item in the addKeys array)
|
|
129
|
+
selectKeys(addKeys) {
|
|
130
|
+
if (!addKeys || (Array.isArray(addKeys) && addKeys.length == 0)) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
addKeys = this.ensureCorrectValue(addKeys);
|
|
135
|
+
|
|
136
|
+
if (this.multiSelect) {
|
|
137
|
+
addKeys.forEach(key => {
|
|
138
|
+
if (!this.syncSelected.includes(key)) {
|
|
139
|
+
this.syncSelected.push(key);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
} else {
|
|
143
|
+
if (this.selectedIsArray) {
|
|
144
|
+
this.syncSelected = [addKeys];
|
|
145
|
+
} else {
|
|
146
|
+
this.syncSelected = addKeys;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
unselectKeys(removeKeys) {
|
|
152
|
+
if (this.multiSelect || this.selectedIsArray) {
|
|
153
|
+
if (Array.isArray(removeKeys)) {
|
|
154
|
+
this.syncSelected = this.syncSelected.filter(k => {
|
|
155
|
+
return !removeKeys.includes(k);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
if (removeKeys.includes(this.selected)) {
|
|
160
|
+
this.syncSelected = this.ensureCorrectValue(null);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
selectKeyOnly(key) {
|
|
166
|
+
this.syncSelected = this.ensureCorrectValue(key);
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
toggleKey(key) {
|
|
170
|
+
if (this.isSelected[key]) {
|
|
171
|
+
this.selectKeys([key]);
|
|
172
|
+
} else {
|
|
173
|
+
this.unselectKeys([key]);
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
// item based methods
|
|
178
|
+
|
|
179
|
+
isItemSelected(item) {
|
|
180
|
+
return this.isSelected(this.getItemKey(item));
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
selectItems(addItems) {
|
|
184
|
+
if (Array.isArray(addItems)) {
|
|
185
|
+
let keys = addItems.map(item => this.getItemKey(item));
|
|
186
|
+
this.selectKeys(keys);
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
unselectItems(removeItems) {
|
|
191
|
+
if (Array.isArray(removeItems)) {
|
|
192
|
+
let keys = removeItems.map(item => this.getItemKey(item));
|
|
193
|
+
this.unselectKeys(keys);
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
selectItemOnly(item) {
|
|
198
|
+
this.selectKeyOnly(this.getItemKey(item));
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
toggleItem(item) {
|
|
202
|
+
this.toggleKey(this.getItemKey(item));
|
|
203
|
+
},
|
|
204
|
+
|
|
205
|
+
// other
|
|
206
|
+
|
|
207
|
+
selectIndexSafe(index, wrap = true) {
|
|
208
|
+
const idx = utils.arraySafeIndex(this.items, index, 0, wrap);
|
|
209
|
+
if (idx > -1) {
|
|
210
|
+
this.selectItemOnly(this.items[idx]);
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
selectOffsetSafe(offset, wrap = true) {
|
|
215
|
+
const idx = utils.arraySafeIndex(this.items, this.selectedIndex, offset, wrap);
|
|
216
|
+
if (idx > -1) {
|
|
217
|
+
this.selectItemOnly(this.items[idx]);
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
selectAll() {
|
|
222
|
+
this.selectKeys(this.itemKeys);
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
selectNone() {
|
|
226
|
+
this.syncSelected = [];
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
</script>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import debounce from 'debounce';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
data() {
|
|
6
|
+
return {
|
|
7
|
+
resizing: false,
|
|
8
|
+
};
|
|
9
|
+
},
|
|
10
|
+
computed: {
|
|
11
|
+
// return something other than 0 to enable debounced resize (only evaluated in mounted in
|
|
12
|
+
// the current implementation)
|
|
13
|
+
resizeDebounceValue() {
|
|
14
|
+
return 0;
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
// the element to observe for size changes, defaults to this.$el (only evaluated in mounted
|
|
18
|
+
// in the current implementation)
|
|
19
|
+
observeElementValue() {
|
|
20
|
+
return this.$el;
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
mounted() {
|
|
24
|
+
const resizeDebouncedFn =
|
|
25
|
+
this.resizeDebounceValue && this.resize
|
|
26
|
+
? debounce(e => {
|
|
27
|
+
this.resize(e);
|
|
28
|
+
this.resizing = false;
|
|
29
|
+
}, this.resizeDebounceValue)
|
|
30
|
+
: null;
|
|
31
|
+
|
|
32
|
+
const resizeFn = entries => {
|
|
33
|
+
// debounced version
|
|
34
|
+
if (resizeDebouncedFn) {
|
|
35
|
+
if (!this.resizing) {
|
|
36
|
+
this.resizing = true;
|
|
37
|
+
if (this.resizeStarted) {
|
|
38
|
+
this.resizeStarted(entries[0]);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
resizeDebouncedFn(entries[0]);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// regular version
|
|
45
|
+
else {
|
|
46
|
+
if (this.resize) {
|
|
47
|
+
this.resize(entries[0]);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
this.resizeObserver = new ResizeObserver(resizeFn);
|
|
53
|
+
this.resizeObserver.observe(this.observeElementValue);
|
|
54
|
+
},
|
|
55
|
+
beforeDestroy() {
|
|
56
|
+
this.resizeObserver.disconnect();
|
|
57
|
+
delete this.resizeObserver;
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
</script>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
Base class for classes that manage a checked state. In order to simplify the data synchronization
|
|
4
|
+
with the input, we enable v-model binding by also providing a data property (syncChecked) that
|
|
5
|
+
mirrors the checked prop. The intention is that this property will only be used internally as
|
|
6
|
+
v-model.
|
|
7
|
+
|
|
8
|
+
-->
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import PxBase from './PxBase.vue';
|
|
12
|
+
export default {
|
|
13
|
+
mixins: [PxBase],
|
|
14
|
+
model: {
|
|
15
|
+
prop: 'checked',
|
|
16
|
+
event: 'update:checked',
|
|
17
|
+
},
|
|
18
|
+
props: {
|
|
19
|
+
// the value of the checked property
|
|
20
|
+
checked: { type: Boolean, default: false },
|
|
21
|
+
|
|
22
|
+
// class that should be set on the component when checked
|
|
23
|
+
checkedClass: { type: String, default: null },
|
|
24
|
+
|
|
25
|
+
// disabled interaction
|
|
26
|
+
disabled: { type: Boolean, default: false },
|
|
27
|
+
},
|
|
28
|
+
data() {
|
|
29
|
+
return {
|
|
30
|
+
syncChecked: this.checked,
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
watch: {
|
|
34
|
+
syncChecked(nv) {
|
|
35
|
+
this.$emit('update:checked', nv);
|
|
36
|
+
if (nv) {
|
|
37
|
+
this.$emit('checked');
|
|
38
|
+
}
|
|
39
|
+
if (!nv) {
|
|
40
|
+
this.$emit('unchecked');
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
checked(nv) {
|
|
44
|
+
this.syncChecked = nv;
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
methods: {
|
|
48
|
+
toggleChecked() {
|
|
49
|
+
if (this.disabled) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
this.syncChecked = !this.syncChecked;
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
</script>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
|
|
3
|
+
Provides a standardized way of specifying variants of a component. Variants are typically css-based
|
|
4
|
+
modifications to a component and might be defined by the component or declared in the app. Typical
|
|
5
|
+
usage might look like:
|
|
6
|
+
|
|
7
|
+
Component code:
|
|
8
|
+
<div :class="'bem(variantsMap)'" />
|
|
9
|
+
|
|
10
|
+
User code:
|
|
11
|
+
<my-control variant="one two" />
|
|
12
|
+
|
|
13
|
+
This would produce:
|
|
14
|
+
<div class="my-component my-component--one my-component--two" />
|
|
15
|
+
|
|
16
|
+
-->
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
import variants from '../utils/variants.js';
|
|
20
|
+
export default {
|
|
21
|
+
props: {
|
|
22
|
+
variant: { type: String, default: 'default' },
|
|
23
|
+
},
|
|
24
|
+
computed: {
|
|
25
|
+
// get the value for variant (allows derived classes to provide a different source)
|
|
26
|
+
variantValue() {
|
|
27
|
+
return this.variant;
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
// all variants as an array
|
|
31
|
+
variants() {
|
|
32
|
+
return this.stringToVariants(this.variantValue);
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
// variants as a map like {one: true, two: true}
|
|
36
|
+
variantsMap() {
|
|
37
|
+
return this.stringToVariantsMap(this.variantValue);
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
methods: {
|
|
41
|
+
// true if the given variant is present
|
|
42
|
+
isVariant(variantName) {
|
|
43
|
+
return this.variants?.includes(variantName);
|
|
44
|
+
},
|
|
45
|
+
// find the first matching variant key in a map and return the correspond value
|
|
46
|
+
variantsToValue(valueMap, fallback) {
|
|
47
|
+
for (let key in valueMap) {
|
|
48
|
+
if (this.isVariant(key)) {
|
|
49
|
+
return valueMap[key];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return fallback;
|
|
53
|
+
},
|
|
54
|
+
stringToVariants: str => {
|
|
55
|
+
return variants.stringToVariants(str);
|
|
56
|
+
},
|
|
57
|
+
stringToVariantsMap: str => {
|
|
58
|
+
return variants.stringToVariantsMap(str);
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
</script>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Base class that provides a single visible property / data value this is sync capable. Also
|
|
3
|
+
provides show/hide/toggle methods. Override the visible prop to change the default state.
|
|
4
|
+
-->
|
|
5
|
+
|
|
6
|
+
<script>
|
|
7
|
+
export default {
|
|
8
|
+
props: {
|
|
9
|
+
visible: { default: false },
|
|
10
|
+
},
|
|
11
|
+
data() {
|
|
12
|
+
return {
|
|
13
|
+
// mirrors visible
|
|
14
|
+
visibleValue: this.visible,
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
watch: {
|
|
18
|
+
visible(nv) {
|
|
19
|
+
// update visibleValue when visible changes
|
|
20
|
+
this.visibleValue = nv;
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
visibleValue(nv) {
|
|
24
|
+
// emit update when visibleValue changes (enables .sync on parent)
|
|
25
|
+
this.$emit('update:visible', nv);
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
methods: {
|
|
29
|
+
show() {
|
|
30
|
+
this.visibleValue = true;
|
|
31
|
+
},
|
|
32
|
+
hide() {
|
|
33
|
+
this.visibleValue = false;
|
|
34
|
+
},
|
|
35
|
+
toggle() {
|
|
36
|
+
this.visibleValue = !this.visibleValue;
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
</script>
|