@hulkapps/app-manager-vue 1.0.2 → 2.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.
- package/dist/app-manager-vue.esm.js +39044 -15119
- package/dist/app-manager-vue.min.js +9 -2
- package/dist/app-manager-vue.ssr.js +37559 -15018
- package/dist/hulkapps-app-manager.css +13284 -0
- package/dist/hulkapps-app-manager.min.css +1 -0
- package/package.json +9 -4
- package/src/components/Marketing/Banners.vue +43 -40
- package/src/components/Plans/AppManagerPlan.vue +518 -0
- package/src/components/Plans/PlanBanners.vue +50 -0
- package/src/components/Plans/YearlyPlanPromotion.vue +40 -0
- package/src/components/polaris-vue/src/components/PActionList/PActionList.vue +68 -0
- package/src/components/polaris-vue/src/components/PActionList/components/PActionListItem/PActionListItem.vue +91 -0
- package/src/components/polaris-vue/src/components/PActionList/components/PActionListSection/PActionListSection.vue +68 -0
- package/src/components/polaris-vue/src/components/PActionMenu/PActionMenu.vue +54 -0
- package/src/components/polaris-vue/src/components/PActionMenu/components/PActionMenuActions/PActionMenuActions.vue +197 -0
- package/src/components/polaris-vue/src/components/PActionMenu/components/PActionMenuMenuAction/PActionMenuMenuAction.vue +97 -0
- package/src/components/polaris-vue/src/components/PActionMenu/components/PActionMenuMenuGroup/PActionMenuMenuGroup.vue +54 -0
- package/src/components/polaris-vue/src/components/PActionMenu/components/PActionMenuRollupActions/PActionMenuRollupActions.vue +43 -0
- package/src/components/polaris-vue/src/components/PAvatar/PAvatar.vue +104 -0
- package/src/components/polaris-vue/src/components/PBadge/PBadge.vue +86 -0
- package/src/components/polaris-vue/src/components/PBanner/PBanner.vue +132 -0
- package/src/components/polaris-vue/src/components/PBreadcrumbs/PBreadcrumbs.vue +99 -0
- package/src/components/polaris-vue/src/components/PButton/PButton.vue +396 -0
- package/src/components/polaris-vue/src/components/PButton/components/PButtonsFrom/PButtonsFrom.vue +47 -0
- package/src/components/polaris-vue/src/components/PButton/components/PUnstyledButton/PUnstyledButton.vue +340 -0
- package/src/components/polaris-vue/src/components/PButtonGroup/PButtonGroup.vue +76 -0
- package/src/components/polaris-vue/src/components/PButtonGroup/components/PButtonGroupItem/PButtonGroupItem.vue +11 -0
- package/src/components/polaris-vue/src/components/PCaption/PCaption.vue +29 -0
- package/src/components/polaris-vue/src/components/PCard/PCard.vue +118 -0
- package/src/components/polaris-vue/src/components/PCard/components/PCardFooter/PCardFooter.vue +11 -0
- package/src/components/polaris-vue/src/components/PCard/components/PCardHeader/PCardHeader.vue +69 -0
- package/src/components/polaris-vue/src/components/PCard/components/PCardSection/PCardSection.vue +54 -0
- package/src/components/polaris-vue/src/components/PCard/components/PCardSubsection/PCardSubsection.vue +12 -0
- package/src/components/polaris-vue/src/components/PConnected/PConnected.vue +44 -0
- package/src/components/polaris-vue/src/components/PConnected/components/PConnectedItem/PConnectedItem.vue +41 -0
- package/src/components/polaris-vue/src/components/PDataTable/PDataTable.vue +541 -0
- package/src/components/polaris-vue/src/components/PDataTable/components/PDataTableCell/PDataTableCell.vue +213 -0
- package/src/components/polaris-vue/src/components/PDataTable/components/PDataTableCellNew/PDataTableCellNew.vue +162 -0
- package/src/components/polaris-vue/src/components/PDataTable/components/PDataTableCol/PDataTableCol.vue +75 -0
- package/src/components/polaris-vue/src/components/PDataTable/components/PDataTableRow/PDataTableRow.vue +15 -0
- package/src/components/polaris-vue/src/components/PDisplayText/PDisplayText.vue +56 -0
- package/src/components/polaris-vue/src/components/PEmptyState/PEmptyState.vue +154 -0
- package/src/components/polaris-vue/src/components/PFieldError/PFieldError.vue +41 -0
- package/src/components/polaris-vue/src/components/PFilter/PFilter.vue +252 -0
- package/src/components/polaris-vue/src/components/PFilter/components/PFilterItem/PFilterItem.vue +11 -0
- package/src/components/polaris-vue/src/components/PFilter/components/PFilterItemWrapper/PFilterItemWrapper.vue +32 -0
- package/src/components/polaris-vue/src/components/PHeading/PHeading.vue +33 -0
- package/src/components/polaris-vue/src/components/PIcon/PIcon.vue +121 -0
- package/src/components/polaris-vue/src/components/PIcon/ShopifyIcons.vue +217 -0
- package/src/components/polaris-vue/src/components/PImage/PImage.vue +49 -0
- package/src/components/polaris-vue/src/components/PLayout/PLayout.vue +42 -0
- package/src/components/polaris-vue/src/components/PLayout/components/PLayoutSection/PLayoutSection.vue +55 -0
- package/src/components/polaris-vue/src/components/PLink/PLink.vue +90 -0
- package/src/components/polaris-vue/src/components/POptionalTag/POptionalTag.vue +23 -0
- package/src/components/polaris-vue/src/components/PPage/PPage.vue +136 -0
- package/src/components/polaris-vue/src/components/PPage/components/PPageHeader/PPageHeader.vue +191 -0
- package/src/components/polaris-vue/src/components/PPage/components/PPageHeaderTitle/PPageHeaderTitle.vue +63 -0
- package/src/components/polaris-vue/src/components/PPagination/PPagination.vue +119 -0
- package/src/components/polaris-vue/src/components/PPopover/PPopover.vue +298 -0
- package/src/components/polaris-vue/src/components/PPopover/components/PPopoverOverlay/PPopoverOverlay.vue +66 -0
- package/src/components/polaris-vue/src/components/PPopover/components/PPositionedOverlay/PPositionedOverlay.vue +289 -0
- package/src/components/polaris-vue/src/components/PSpinner/PSpinner.vue +60 -0
- package/src/components/polaris-vue/src/components/PStack/PStack.vue +84 -0
- package/src/components/polaris-vue/src/components/PStack/components/PStackItem/PStackItem.vue +49 -0
- package/src/components/polaris-vue/src/components/PSubheading/PSubheading.vue +36 -0
- package/src/components/polaris-vue/src/components/PTag/PTag.vue +89 -0
- package/src/components/polaris-vue/src/components/PTextContainer/PTextContainer.vue +41 -0
- package/src/components/polaris-vue/src/components/PTextField/PTextField.vue +229 -0
- package/src/components/polaris-vue/src/components/PTextField/components/PFieldResizer/PFieldResizer.vue +79 -0
- package/src/components/polaris-vue/src/components/PTextField/components/PInput/PInput.vue +473 -0
- package/src/components/polaris-vue/src/components/PTextField/components/PSpinner/PSpinner.vue +47 -0
- package/src/components/polaris-vue/src/components/PTextStyle/PTextStyle.vue +60 -0
- package/src/components/polaris-vue/src/components/PThumbnail/PThumbnail.vue +71 -0
- package/src/components/polaris-vue/src/components/PToggle/PToggle.vue +81 -0
- package/src/components/polaris-vue/src/components/PUnstyledLink/PUnstyledLink.vue +67 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<PLayoutSection class="app-manager-plan-footer"
|
|
3
|
+
v-if="mappedStaticContentPlan && mappedStaticContentPlan.length">
|
|
4
|
+
<div v-for="(staticContent, key) in mappedStaticContentPlan" :key="key">
|
|
5
|
+
|
|
6
|
+
<PBanner
|
|
7
|
+
v-if="staticContent.type === 'banner'"
|
|
8
|
+
:id="`static-content-header-${key}`"
|
|
9
|
+
:status="staticContent.status"
|
|
10
|
+
@dismiss="() => dismissBanner(key)"
|
|
11
|
+
>
|
|
12
|
+
<div v-html="staticContent.content"></div>
|
|
13
|
+
</PBanner>
|
|
14
|
+
<div v-else v-html="staticContent.content"></div>
|
|
15
|
+
</div>
|
|
16
|
+
</PLayoutSection>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
|
|
21
|
+
import axios from 'axios'
|
|
22
|
+
import {PLayoutSection} from "../polaris-vue/src/components/PLayout/components/PLayoutSection";
|
|
23
|
+
import {PBanner} from "../polaris-vue/src/components/PBanner";
|
|
24
|
+
export default {
|
|
25
|
+
components: { PBanner, PLayoutSection },
|
|
26
|
+
name: "PlanBanners",
|
|
27
|
+
data() {
|
|
28
|
+
return {
|
|
29
|
+
staticContent: {}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
computed: {
|
|
33
|
+
mappedStaticContentPlan() {
|
|
34
|
+
return this.staticContent['plans'];
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
async mounted() {
|
|
38
|
+
|
|
39
|
+
const { data } = await axios.get(`${this.app_manager_config.baseUrl}/api/app-manager/marketing-banners`).catch(error => {
|
|
40
|
+
console.error(error)
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
this.staticContent = data.banners
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<style scoped>
|
|
49
|
+
|
|
50
|
+
</style>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<PLayoutSection class="app-manager-plan-footer" v-if="mappedStaticContent && mappedStaticContent.length">
|
|
3
|
+
<div v-for="(staticContent, key) in mappedStaticContent" :key="key">
|
|
4
|
+
<div v-html="staticContent.content"></div>
|
|
5
|
+
</div>
|
|
6
|
+
</PLayoutSection>
|
|
7
|
+
<span v-else>
|
|
8
|
+
<p style="font-size: 17px; font-weight: 500" slot="default">{{('Annually')}}</p>
|
|
9
|
+
</span>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
import axios from 'axios'
|
|
14
|
+
import {PLayoutSection} from "../polaris-vue/src/components/PLayout/components/PLayoutSection";
|
|
15
|
+
|
|
16
|
+
export default {
|
|
17
|
+
components: { PLayoutSection },
|
|
18
|
+
name: "YearlyPlanPromotion",
|
|
19
|
+
data() {
|
|
20
|
+
return {
|
|
21
|
+
staticContent: {}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
computed: {
|
|
25
|
+
mappedStaticContent() {
|
|
26
|
+
return this.staticContent['yearlyPlanPromotions'];
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
async mounted() {
|
|
30
|
+
const { data } = await axios.get(`${this.app_manager_config.baseUrl}/api/app-manager/marketing-banners`).catch(error => {
|
|
31
|
+
console.error(error)
|
|
32
|
+
});
|
|
33
|
+
this.staticContent = data.banners
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
</script>
|
|
37
|
+
|
|
38
|
+
<style scoped>
|
|
39
|
+
|
|
40
|
+
</style>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="(hasMultipleSections ? 'ul' : 'div')" :class="className">
|
|
3
|
+
<PActionListSection v-for="(section, key) in finalSections" :key="key" :section="section"
|
|
4
|
+
@itemAction="onItemAction"
|
|
5
|
+
:hasMultipleSections="hasMultipleSections" />
|
|
6
|
+
</component>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
import { classNames} from '../../utilities/css';
|
|
11
|
+
import { PActionListSection } from '../../components/PActionList/components/PActionListSection';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* <br/>
|
|
15
|
+
* <h4 style="font-family: -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue,
|
|
16
|
+
* sans-serif;">Action lists render a list of actions or selectable options. This component is usually placed inside a
|
|
17
|
+
* <a href="https://polaris-vue.hulkapps.com/?path=/docs/overlays-popover--popover">popover</a>
|
|
18
|
+
* container to create a dropdown menu or to let merchants select from a list of options.</h4>
|
|
19
|
+
*/
|
|
20
|
+
export default {
|
|
21
|
+
name: 'PActionList',
|
|
22
|
+
components: {
|
|
23
|
+
PActionListSection,
|
|
24
|
+
},
|
|
25
|
+
props: {
|
|
26
|
+
/**
|
|
27
|
+
* Collection of actions for list
|
|
28
|
+
*/
|
|
29
|
+
items: {
|
|
30
|
+
type: Array,
|
|
31
|
+
default: () => ([]),
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* Collection of sectioned action items
|
|
35
|
+
*/
|
|
36
|
+
sections: {
|
|
37
|
+
type: Array,
|
|
38
|
+
default: () => ([]),
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
computed: {
|
|
42
|
+
className() {
|
|
43
|
+
return classNames(
|
|
44
|
+
'Polaris-ActionList',
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
finalSections() {
|
|
48
|
+
/* tslint:disable-next-line */
|
|
49
|
+
if (typeof this.items != 'undefined' && this.items !== null && this.items.length != null
|
|
50
|
+
&& this.items.length > 0) {
|
|
51
|
+
return [{items: this.items}, ...this.sections];
|
|
52
|
+
}
|
|
53
|
+
return this.sections;
|
|
54
|
+
},
|
|
55
|
+
hasMultipleSections() {
|
|
56
|
+
return this.finalSections.length > 1;
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
methods: {
|
|
60
|
+
onItemAction(action) {
|
|
61
|
+
/**
|
|
62
|
+
* Triggers when the item is selected/clicked
|
|
63
|
+
*/
|
|
64
|
+
this.$emit('item-action', action);
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
}
|
|
68
|
+
</script>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<li>
|
|
3
|
+
<button
|
|
4
|
+
@click="handleAction(action)"
|
|
5
|
+
:disabled="disabled"
|
|
6
|
+
:class="className">
|
|
7
|
+
<template v-if="icon || image">
|
|
8
|
+
<span class="Polaris-ActionList__Content">
|
|
9
|
+
<span
|
|
10
|
+
role="presentation"
|
|
11
|
+
class="Polaris-ActionList__Prefix"
|
|
12
|
+
:style="{ backgroundImage: icon ? null : 'url('+image+')'}">
|
|
13
|
+
<PIcon v-if="icon" :source="icon"/>
|
|
14
|
+
</span>
|
|
15
|
+
<span class="Polaris-ActionList__Text">
|
|
16
|
+
<slot>
|
|
17
|
+
<slot name="content">
|
|
18
|
+
<span>{{ content }}</span>
|
|
19
|
+
<slot name="helpText">
|
|
20
|
+
<span class="Polaris-TextStyle--variationSubdued"
|
|
21
|
+
v-if="helpText">{{ helpText }}</span>
|
|
22
|
+
</slot>
|
|
23
|
+
</slot>
|
|
24
|
+
</slot>
|
|
25
|
+
</span>
|
|
26
|
+
</span>
|
|
27
|
+
</template>
|
|
28
|
+
<template v-else>
|
|
29
|
+
<slot>
|
|
30
|
+
<slot name="content">
|
|
31
|
+
<span>{{ content }}</span>
|
|
32
|
+
<slot name="helpText">
|
|
33
|
+
<span class="Polaris-TextStyle--variationSubdued" v-if="helpText">{{ helpText }}</span>
|
|
34
|
+
</slot>
|
|
35
|
+
</slot>
|
|
36
|
+
</slot>
|
|
37
|
+
</template>
|
|
38
|
+
</button>
|
|
39
|
+
</li>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script>
|
|
43
|
+
import { classNames } from '../../../../utilities/css';
|
|
44
|
+
import { PUnstyledLink } from '../../../../components/PUnstyledLink';
|
|
45
|
+
import { PIcon } from '../../../../components/PIcon';
|
|
46
|
+
|
|
47
|
+
export default {
|
|
48
|
+
name: 'PActionListItem',
|
|
49
|
+
components: {
|
|
50
|
+
PUnstyledLink, PIcon,
|
|
51
|
+
},
|
|
52
|
+
props: {
|
|
53
|
+
content: {
|
|
54
|
+
type: String,
|
|
55
|
+
},
|
|
56
|
+
helpText: {
|
|
57
|
+
type: String,
|
|
58
|
+
},
|
|
59
|
+
action: {
|
|
60
|
+
type: Object,
|
|
61
|
+
},
|
|
62
|
+
icon: {
|
|
63
|
+
type: String,
|
|
64
|
+
},
|
|
65
|
+
image: {
|
|
66
|
+
type: String,
|
|
67
|
+
},
|
|
68
|
+
disabled: {
|
|
69
|
+
type: Boolean,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
computed: {
|
|
73
|
+
className() {
|
|
74
|
+
return classNames(
|
|
75
|
+
'Polaris-ActionList__Item',
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
methods: {
|
|
80
|
+
handleAction(action) {
|
|
81
|
+
let res = true;
|
|
82
|
+
if (action.onAction) {
|
|
83
|
+
res = action.onAction();
|
|
84
|
+
}
|
|
85
|
+
if (res && action.url) {
|
|
86
|
+
window.location.href = action.url;
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
</script>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<POptionalTag tag="li" :active="hasMultipleSections" class="Polaris-ActionList__Section">
|
|
3
|
+
<div :class="className">
|
|
4
|
+
<p v-if="section.title" class="Polaris-ActionList__Title">
|
|
5
|
+
{{ section.title }}
|
|
6
|
+
</p>
|
|
7
|
+
<ul class="Polaris-ActionList__Actions">
|
|
8
|
+
<PActionListItem
|
|
9
|
+
v-for="(item, key) in section.items"
|
|
10
|
+
:key="key"
|
|
11
|
+
:content="item.content"
|
|
12
|
+
:icon="item.icon"
|
|
13
|
+
:helpText="item.helpText"
|
|
14
|
+
:action="wrapAction(item)"
|
|
15
|
+
/>
|
|
16
|
+
</ul>
|
|
17
|
+
</div>
|
|
18
|
+
</POptionalTag>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script>
|
|
22
|
+
import { classNames } from '../../../../utilities/css';
|
|
23
|
+
import { POptionalTag } from '../../../../components/POptionalTag';
|
|
24
|
+
import { PActionListItem } from '../../../../components/PActionList/components/PActionListItem';
|
|
25
|
+
import ObjectValidator from '../../../../utilities/validators/ObjectValidator';
|
|
26
|
+
|
|
27
|
+
const SectionInterface = {
|
|
28
|
+
title: String,
|
|
29
|
+
items: Array,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default {
|
|
33
|
+
name: 'PActionListSection',
|
|
34
|
+
components: {
|
|
35
|
+
PActionListItem, POptionalTag,
|
|
36
|
+
},
|
|
37
|
+
props: {
|
|
38
|
+
section: {
|
|
39
|
+
type: Object,
|
|
40
|
+
default: () => ({}),
|
|
41
|
+
...ObjectValidator('actions', SectionInterface),
|
|
42
|
+
},
|
|
43
|
+
hasMultipleSections: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
computed: {
|
|
48
|
+
className() {
|
|
49
|
+
return classNames(
|
|
50
|
+
!this.section.title && 'Polaris-ActionList__Section--withoutTitle',
|
|
51
|
+
);
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
methods: {
|
|
55
|
+
wrapAction(action) {
|
|
56
|
+
const old = action.onAction;
|
|
57
|
+
const newAction = Object.assign({}, action);
|
|
58
|
+
if (old) {
|
|
59
|
+
newAction.onAction = () => {
|
|
60
|
+
old();
|
|
61
|
+
this.$emit('item-action', action);
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return newAction;
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
</script>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="actionMenuClassNames">
|
|
3
|
+
<PActionMenuRollupActions v-if="rollup" :items="actions" :sections="rollupSections" />
|
|
4
|
+
<PActionMenuActions v-else :actions="actions" :groups="groups" />
|
|
5
|
+
</div>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import {classNames} from '../../utilities/css';
|
|
10
|
+
import {MenuActionDescriptor, MenuGroupDescriptor} from '../../types';
|
|
11
|
+
import {PActionMenuRollupActions} from '../../components/PActionMenu/components/PActionMenuRollupActions';
|
|
12
|
+
import {PActionMenuActions} from '../../components/PActionMenu/components/PActionMenuActions';
|
|
13
|
+
import ArrayValidator from '../../utilities/validators/ArrayValidator';
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
name: 'PActionMenu',
|
|
17
|
+
components: {
|
|
18
|
+
PActionMenuActions, PActionMenuRollupActions,
|
|
19
|
+
},
|
|
20
|
+
props: {
|
|
21
|
+
actions: {
|
|
22
|
+
type: Array,
|
|
23
|
+
...ArrayValidator('actions', MenuActionDescriptor)
|
|
24
|
+
},
|
|
25
|
+
groups: {
|
|
26
|
+
type: Array,
|
|
27
|
+
...ArrayValidator('groups', MenuGroupDescriptor)
|
|
28
|
+
},
|
|
29
|
+
rollup: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
computed: {
|
|
35
|
+
rollupSections() {
|
|
36
|
+
return this.groups.map((group) => this.convertGroupToSection(group));
|
|
37
|
+
},
|
|
38
|
+
actionMenuClassNames() {
|
|
39
|
+
return classNames(
|
|
40
|
+
'Polaris-ActionMenu',
|
|
41
|
+
this.rollup && 'Polaris-ActionMenu--rollup',
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
methods: {
|
|
46
|
+
convertGroupToSection(MenuGroupDescriptor) {
|
|
47
|
+
return {
|
|
48
|
+
title: MenuGroupDescriptor.title,
|
|
49
|
+
items: MenuGroupDescriptor.actions,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :ref="id" class="Polaris-ActionMenu-Actions__ActionsLayout">
|
|
3
|
+
<template v-for="(action, index) in overriddenActions">
|
|
4
|
+
<template v-if="'title' in action">
|
|
5
|
+
<div v-if="action.actions.length > 0" :key="`MenuGroup-${index}`">
|
|
6
|
+
<PActionMenuMenuGroup
|
|
7
|
+
:title="action.title"
|
|
8
|
+
:active="action.title === computedActiveMenuGroup"
|
|
9
|
+
:actions="[...computedHiddenActions, ...action.actions]"
|
|
10
|
+
v-bind="action"
|
|
11
|
+
:onAction="handleMenuGroupClose"
|
|
12
|
+
@open="handleMenuGroupToggle"
|
|
13
|
+
@close="handleMenuGroupClose"
|
|
14
|
+
:getOffsetWidth="handleActionsOffsetWidth"
|
|
15
|
+
/>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
<PActionMenuMenuAction v-else-if="!computedHiddenActions.includes(action)" :key="`MenuAction-${index}`"
|
|
19
|
+
:getOffsetWidth="handleActionsOffsetWidth" :content="action.content" v-bind="action"/>
|
|
20
|
+
</template>
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import {MenuActionDescriptor, MenuGroupDescriptor} from '../../../../types';
|
|
26
|
+
import {sortAndOverrideActionOrder} from '../../../../components/PActionMenu/utilities';
|
|
27
|
+
import { PActionMenuMenuGroup } from '../../../../components/PActionMenu/components/PActionMenuMenuGroup';
|
|
28
|
+
import { PActionMenuMenuAction } from '../../../../components/PActionMenu/components/PActionMenuMenuAction';
|
|
29
|
+
import ArrayValidator from '../../../../utilities/validators/ArrayValidator';
|
|
30
|
+
|
|
31
|
+
const Props = {
|
|
32
|
+
actions: {
|
|
33
|
+
type: Object,
|
|
34
|
+
properties: MenuActionDescriptor
|
|
35
|
+
},
|
|
36
|
+
groups: {
|
|
37
|
+
type: Object,
|
|
38
|
+
properties: MenuGroupDescriptor
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const ACTION_SPACING = 8;
|
|
43
|
+
|
|
44
|
+
export default {
|
|
45
|
+
name: 'PActionMenuActions',
|
|
46
|
+
components: {
|
|
47
|
+
PActionMenuMenuGroup, PActionMenuMenuAction,
|
|
48
|
+
},
|
|
49
|
+
props: {
|
|
50
|
+
id: {
|
|
51
|
+
type: [String, Number],
|
|
52
|
+
default: `ActionMenuLayout${new Date().getUTCMilliseconds()}`,
|
|
53
|
+
},
|
|
54
|
+
actions: {
|
|
55
|
+
type: Array,
|
|
56
|
+
...ArrayValidator('actions', MenuActionDescriptor)
|
|
57
|
+
},
|
|
58
|
+
groups: {
|
|
59
|
+
type: Array,
|
|
60
|
+
...ArrayValidator('actions', MenuGroupDescriptor)
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
data() {
|
|
64
|
+
return {
|
|
65
|
+
activeMenuGroup: '',
|
|
66
|
+
hiddenActions: [],
|
|
67
|
+
showableActions: [],
|
|
68
|
+
availableWidthRef: 0,
|
|
69
|
+
timesMeasured: 0,
|
|
70
|
+
actionsAndGroupsLengthRef: 0,
|
|
71
|
+
actionWidthsRef: [],
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
computed: {
|
|
75
|
+
lastMenuGroupWidth() {
|
|
76
|
+
return [...this.actionWidthsRef].pop() || 0;
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
lastMenuGroup() {
|
|
80
|
+
return [...this.groups].pop();
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
/* Measure Variables End*/
|
|
84
|
+
|
|
85
|
+
computedShowableActions: {
|
|
86
|
+
get() {
|
|
87
|
+
return this.showableActions;
|
|
88
|
+
},
|
|
89
|
+
set(value) {
|
|
90
|
+
this.showableActions = value;
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
computedHiddenActions: {
|
|
95
|
+
get() {
|
|
96
|
+
return this.hiddenActions;
|
|
97
|
+
},
|
|
98
|
+
set(value) {
|
|
99
|
+
this.hiddenActions = value;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
computedActiveMenuGroup: {
|
|
104
|
+
get() {
|
|
105
|
+
return this.activeMenuGroup;
|
|
106
|
+
},
|
|
107
|
+
set(value) {
|
|
108
|
+
this.activeMenuGroup = value;
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
menuActions() {
|
|
113
|
+
return [...this.actions, ...this.groups];
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
overriddenActions() {
|
|
117
|
+
return sortAndOverrideActionOrder(this.menuActions);
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
methods: {
|
|
121
|
+
handleMenuGroupToggle(group) {
|
|
122
|
+
if(typeof group === 'string') {
|
|
123
|
+
this.computedActiveMenuGroup = this.computedActiveMenuGroup ? undefined : group;
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
handleMenuGroupClose() {
|
|
127
|
+
this.computedActiveMenuGroup = undefined;
|
|
128
|
+
},
|
|
129
|
+
handleResize() {
|
|
130
|
+
const actionsLayoutRef = this.$refs[this.id];
|
|
131
|
+
this.availableWidthRef = actionsLayoutRef.offsetWidth;
|
|
132
|
+
|
|
133
|
+
// // Set timesMeasured to 0 to allow re-measuring
|
|
134
|
+
this.timesMeasured = 0;
|
|
135
|
+
this.measureActions();
|
|
136
|
+
},
|
|
137
|
+
handleActionsOffsetWidth(width) {
|
|
138
|
+
this.actionWidthsRef = [...this.actionWidthsRef, width];
|
|
139
|
+
},
|
|
140
|
+
measureActions() {
|
|
141
|
+
if (
|
|
142
|
+
this.actionWidthsRef.length === 0 ||
|
|
143
|
+
this.availableWidthRef === 0
|
|
144
|
+
) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const actionsAndGroups = [...this.actions, ...this.groups];
|
|
149
|
+
|
|
150
|
+
if (actionsAndGroups.length === 1) {
|
|
151
|
+
this.showableActions = actionsAndGroups;
|
|
152
|
+
this.hiddenActions = [];
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
let currentAvailableWidth = this.availableWidthRef;
|
|
157
|
+
let newShowableActions = [];
|
|
158
|
+
let newRolledUpActions = [];
|
|
159
|
+
|
|
160
|
+
actionsAndGroups.forEach((action, index) => {
|
|
161
|
+
const canFitAction =
|
|
162
|
+
this.actionWidthsRef[index] +
|
|
163
|
+
0 + // menuGroupWidthRef.current
|
|
164
|
+
ACTION_SPACING +
|
|
165
|
+
this.lastMenuGroupWidth <=
|
|
166
|
+
currentAvailableWidth;
|
|
167
|
+
|
|
168
|
+
if (canFitAction) {
|
|
169
|
+
currentAvailableWidth -=
|
|
170
|
+
this.actionWidthsRef[index] + ACTION_SPACING * 2;
|
|
171
|
+
newShowableActions = [...newShowableActions, action];
|
|
172
|
+
} else {
|
|
173
|
+
currentAvailableWidth = 0;
|
|
174
|
+
// Find last group if it exists and always render it as a rolled up action below
|
|
175
|
+
if (action === this.lastMenuGroup) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
newRolledUpActions = [...newRolledUpActions, action];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
this.showableActions = newShowableActions;
|
|
183
|
+
this.computedHiddenActions = newRolledUpActions;
|
|
184
|
+
|
|
185
|
+
this.timesMeasured += 1;
|
|
186
|
+
this.actionsAndGroupsLengthRef = actionsAndGroups.length;
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
mounted() {
|
|
190
|
+
window.addEventListener('resize', this.handleResize);
|
|
191
|
+
this.handleResize();
|
|
192
|
+
},
|
|
193
|
+
destroyed() {
|
|
194
|
+
window.removeEventListener('resize', this.handleResize);
|
|
195
|
+
},
|
|
196
|
+
}
|
|
197
|
+
</script>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<PUnstyledLink :ref="id" v-if="url" :class="menuActionClassNames" :url="url" :external="external">
|
|
3
|
+
<span v-if="icon || disclosure" class="Polaris-ActionMenu-MenuAction__ContentWrapper">
|
|
4
|
+
<span v-if="icon" class="Polaris-ActionMenu-MenuAction__IconWrapper">
|
|
5
|
+
<PIcon :source="icon" />
|
|
6
|
+
</span>
|
|
7
|
+
<span class="Polaris-ActionMenu-MenuAction__Content">{{content}}</span>
|
|
8
|
+
<span v-if="disclosure" class="Polaris-ActionMenu-MenuAction__IconWrapper">
|
|
9
|
+
<PIcon source="CaretDownMinor" />
|
|
10
|
+
</span>
|
|
11
|
+
</span>
|
|
12
|
+
<template v-else>{{content}}</template>
|
|
13
|
+
</PUnstyledLink>
|
|
14
|
+
<button :ref="id" v-else type="button" :class="menuActionClassNames" :disabled="disabled" @click.stop="onAction()">
|
|
15
|
+
<span v-if="icon || disclosure" class="Polaris-ActionMenu-MenuAction__ContentWrapper">
|
|
16
|
+
<span v-if="icon" class="Polaris-ActionMenu-MenuAction__IconWrapper">
|
|
17
|
+
<PIcon :source="icon" />
|
|
18
|
+
</span>
|
|
19
|
+
<span class="Polaris-ActionMenu-MenuAction__Content">{{content}}</span>
|
|
20
|
+
<span v-if="disclosure" class="Polaris-ActionMenu-MenuAction__IconWrapper">
|
|
21
|
+
<PIcon source="CaretDownMinor" />
|
|
22
|
+
</span>
|
|
23
|
+
</span>
|
|
24
|
+
<template v-else>{{content}}</template>
|
|
25
|
+
</button>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script>
|
|
29
|
+
import {classNames} from '../../../../utilities/css';
|
|
30
|
+
import {ComplexAction, MenuActionDescriptor} from '../../../../types';
|
|
31
|
+
import {PIcon} from '../../../../components/PIcon';
|
|
32
|
+
import {PUnstyledLink} from '../../../../components/PUnstyledLink';
|
|
33
|
+
|
|
34
|
+
export const MenuActionProps = {
|
|
35
|
+
...ComplexAction,
|
|
36
|
+
disclosure: Boolean,
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default {
|
|
40
|
+
name: 'PActionMenuMenuAction',
|
|
41
|
+
components: {
|
|
42
|
+
PUnstyledLink, PIcon,
|
|
43
|
+
},
|
|
44
|
+
props: {
|
|
45
|
+
id: {
|
|
46
|
+
type: [String, Number],
|
|
47
|
+
default: `ActionMenuMenuAction${new Date().getUTCMilliseconds()}`,
|
|
48
|
+
},
|
|
49
|
+
content: {
|
|
50
|
+
type: String,
|
|
51
|
+
},
|
|
52
|
+
url: {
|
|
53
|
+
type: String,
|
|
54
|
+
},
|
|
55
|
+
external: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
},
|
|
58
|
+
icon: {
|
|
59
|
+
type: String,
|
|
60
|
+
},
|
|
61
|
+
disclosure: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
},
|
|
64
|
+
disabled: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
},
|
|
67
|
+
onAction: {
|
|
68
|
+
type: Function,
|
|
69
|
+
default: () => {
|
|
70
|
+
return 0
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
getOffsetWidth: {
|
|
74
|
+
type: Function,
|
|
75
|
+
default: () => {
|
|
76
|
+
return 0
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
computed: {
|
|
81
|
+
menuActionClassNames() {
|
|
82
|
+
return classNames(
|
|
83
|
+
'Polaris-ActionMenu-MenuAction',
|
|
84
|
+
this.disabled && 'Polaris-ActionMenu-MenuAction--disabled',
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
mounted() {
|
|
89
|
+
const actionsLayoutRef = this.$refs[this.id];
|
|
90
|
+
if (typeof this.getOffsetWidth === 'function' && actionsLayoutRef) {
|
|
91
|
+
if(actionsLayoutRef.offsetWidth) {
|
|
92
|
+
this.getOffsetWidth(actionsLayoutRef.offsetWidth);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
</script>
|