@hulkapps/app-manager-vue 1.0.2 → 2.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.
- package/dist/app-manager-vue.esm.js +38998 -15123
- package/dist/app-manager-vue.min.js +9 -2
- package/dist/app-manager-vue.ssr.js +37511 -15019
- package/dist/hulkapps-app-manager.css +13284 -0
- package/dist/hulkapps-app-manager.min.css +1 -0
- package/package.json +9 -5
- package/src/components/Marketing/Banners.vue +43 -40
- package/src/components/Plans/AppManagerPlan.vue +494 -0
- package/src/components/Plans/PlanBanners.vue +50 -0
- package/src/components/Plans/YearlyPlanPromotion.vue +37 -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,41 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="Polaris-Labelled__Error">
|
|
3
|
+
<div id="PolarisTextField6Error" class="Polaris-InlineError">
|
|
4
|
+
<div class="Polaris-InlineError__Icon">
|
|
5
|
+
<PIcon source="AlertMinor"/>
|
|
6
|
+
</div>
|
|
7
|
+
{{ error }}
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
import { PIcon } from '../../components/PIcon';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* <br/>
|
|
17
|
+
* <h4 style="font-family: -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue,
|
|
18
|
+
* sans-serif;">Field errors are brief, in-context messages that tell merchants something went wrong with a single
|
|
19
|
+
* or group of inputs in a form. Use field errors to help merchants understand why a form input may not be valid and
|
|
20
|
+
* how to fix it.</h4>
|
|
21
|
+
*/
|
|
22
|
+
export default {
|
|
23
|
+
name: 'PFieldError',
|
|
24
|
+
components: {
|
|
25
|
+
PIcon,
|
|
26
|
+
},
|
|
27
|
+
props: {
|
|
28
|
+
/**
|
|
29
|
+
* Content briefly explaining how to resolve the invalid form field input
|
|
30
|
+
*/
|
|
31
|
+
error: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: null,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<style scoped>
|
|
40
|
+
|
|
41
|
+
</style>
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<div class="Polaris-Filters">
|
|
4
|
+
<div class="Polaris-Filters-ConnectedFilterControl__Wrapper">
|
|
5
|
+
<div class="Polaris-Filters-ConnectedFilterControl Polaris-Filters-ConnectedFilterControl--right">
|
|
6
|
+
<PFilterItemWrapper position="center" v-if="!hideQueryField">
|
|
7
|
+
<PTextField
|
|
8
|
+
id="Polaris-Input-Filter"
|
|
9
|
+
connected
|
|
10
|
+
labelHidden
|
|
11
|
+
showPrefix
|
|
12
|
+
showClearButton
|
|
13
|
+
:placeholder="queryPlaceholder || resourceTitle || resource"
|
|
14
|
+
@input="handleQueryChange"
|
|
15
|
+
@blur="handleQueryBlur"
|
|
16
|
+
@focus="handleQueryFocus"
|
|
17
|
+
:value="queryValue || inputFilter"
|
|
18
|
+
:autoFocus="focused"
|
|
19
|
+
:label="queryPlaceholder || resourceTitle || resource"
|
|
20
|
+
clearable
|
|
21
|
+
:disabled="disabled"
|
|
22
|
+
v-on="$listeners"
|
|
23
|
+
>
|
|
24
|
+
<PIcon source="SearchMinor" slot="prefix"/>
|
|
25
|
+
</PTextField>
|
|
26
|
+
</PFilterItemWrapper>
|
|
27
|
+
<PFilterItemWrapper v-if="$slots.hasOwnProperty('default')" position="right">
|
|
28
|
+
<!-- @slot The content to display inline with the controls -->
|
|
29
|
+
<slot/>
|
|
30
|
+
</PFilterItemWrapper>
|
|
31
|
+
</div>
|
|
32
|
+
<div class="Polaris-Filters-ConnectedFilterControl__AuxiliaryContainer">
|
|
33
|
+
<!-- @slot Add extra elements -->
|
|
34
|
+
<slot name="auxiliaryContainer"/>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
<div class="Polaris-Filters__TagsContainer" v-if="!hideTags">
|
|
38
|
+
<PTag v-for="(filter, key) in appliedFilters" :key="key" v-on="$listeners" removable :tag="filter"/>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
import { PTextField } from '../../components/PTextField';
|
|
46
|
+
import { PIcon } from '../../components/PIcon';
|
|
47
|
+
import { PTag } from '../../components/PTag';
|
|
48
|
+
import { PFilterItemWrapper } from '../../components/PFilter/components/PFilterItemWrapper';
|
|
49
|
+
import ObjectValidator from '../../utilities/validators/ObjectValidator';
|
|
50
|
+
import ArrayValidator from '../../utilities/validators/ArrayValidator';
|
|
51
|
+
|
|
52
|
+
const ResourceNameInterface = {
|
|
53
|
+
singular: {
|
|
54
|
+
type: String,
|
|
55
|
+
required: true,
|
|
56
|
+
},
|
|
57
|
+
plural: {
|
|
58
|
+
type: String,
|
|
59
|
+
required: true,
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const FilterInterface = {
|
|
64
|
+
/** A unique key used to identify the filter */
|
|
65
|
+
key: {
|
|
66
|
+
type: String,
|
|
67
|
+
required: true,
|
|
68
|
+
},
|
|
69
|
+
/** The label for the filter */
|
|
70
|
+
label: {
|
|
71
|
+
type: String,
|
|
72
|
+
required: true,
|
|
73
|
+
},
|
|
74
|
+
/** The markup for the given filter */
|
|
75
|
+
filter: {
|
|
76
|
+
type: String,
|
|
77
|
+
required: true,
|
|
78
|
+
},
|
|
79
|
+
/** Whether or not the filter should have a shortcut popover displayed */
|
|
80
|
+
shortcut: Boolean,
|
|
81
|
+
/** Whether or not the filter is disabled */
|
|
82
|
+
disabled: Boolean,
|
|
83
|
+
/**
|
|
84
|
+
* @default false
|
|
85
|
+
* Whether or not the clear button is displayed
|
|
86
|
+
*/
|
|
87
|
+
hideClearButton: Boolean,
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* <br/>
|
|
92
|
+
* <h4 style="font-family: -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue,
|
|
93
|
+
* sans-serif;">Filter is a composite component that filters the items of a list or table.</h4>
|
|
94
|
+
*/
|
|
95
|
+
export default {
|
|
96
|
+
name: 'PFilter',
|
|
97
|
+
components: {
|
|
98
|
+
PTextField, PIcon, PTag, PFilterItemWrapper,
|
|
99
|
+
},
|
|
100
|
+
props: {
|
|
101
|
+
/**
|
|
102
|
+
* Title or placeholder for the element
|
|
103
|
+
*/
|
|
104
|
+
resourceName: {
|
|
105
|
+
type: Object,
|
|
106
|
+
default: () => ({}),
|
|
107
|
+
...ObjectValidator('resourceName', ResourceNameInterface),
|
|
108
|
+
},
|
|
109
|
+
/**
|
|
110
|
+
* Title or placeholder for the element. **Deprecated** ResourceTitle will be removed in version 4.0.0
|
|
111
|
+
*/
|
|
112
|
+
resourceTitle: {
|
|
113
|
+
type: String,
|
|
114
|
+
default: null,
|
|
115
|
+
},
|
|
116
|
+
/**
|
|
117
|
+
* Add default value to filter
|
|
118
|
+
*/
|
|
119
|
+
inputFilter: {
|
|
120
|
+
type: String,
|
|
121
|
+
default: null,
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* Applied filters which are rendered as tags. The remove callback is called with respective key
|
|
125
|
+
*/
|
|
126
|
+
appliedFilters: {
|
|
127
|
+
type: Array,
|
|
128
|
+
default: () => ([]),
|
|
129
|
+
},
|
|
130
|
+
/**
|
|
131
|
+
* Currently entered text in the query field
|
|
132
|
+
*/
|
|
133
|
+
queryValue: {
|
|
134
|
+
type: String,
|
|
135
|
+
default: null,
|
|
136
|
+
},
|
|
137
|
+
/**
|
|
138
|
+
* Placeholder text for the query field
|
|
139
|
+
*/
|
|
140
|
+
queryPlaceholder: {
|
|
141
|
+
type: String,
|
|
142
|
+
default: null,
|
|
143
|
+
},
|
|
144
|
+
/**
|
|
145
|
+
* Whether the query field is focused
|
|
146
|
+
*/
|
|
147
|
+
focused: {
|
|
148
|
+
type: Boolean,
|
|
149
|
+
default: false,
|
|
150
|
+
},
|
|
151
|
+
/**
|
|
152
|
+
* Available filters added to the sheet. Shortcut filters are exposed outside of the sheet.
|
|
153
|
+
*/
|
|
154
|
+
filters: {
|
|
155
|
+
type: Array,
|
|
156
|
+
default: () => ([]),
|
|
157
|
+
...ArrayValidator('filters', FilterInterface),
|
|
158
|
+
},
|
|
159
|
+
/**
|
|
160
|
+
* Disable all filters
|
|
161
|
+
*/
|
|
162
|
+
disabled: {
|
|
163
|
+
type: Boolean,
|
|
164
|
+
default: false,
|
|
165
|
+
},
|
|
166
|
+
/**
|
|
167
|
+
* Additional hint text to display below the filters
|
|
168
|
+
*/
|
|
169
|
+
helpText: {
|
|
170
|
+
type: String,
|
|
171
|
+
default: null
|
|
172
|
+
},
|
|
173
|
+
/**
|
|
174
|
+
* Hide tags for applied filters
|
|
175
|
+
*/
|
|
176
|
+
hideTags: {
|
|
177
|
+
type: Boolean,
|
|
178
|
+
default: false,
|
|
179
|
+
},
|
|
180
|
+
/**
|
|
181
|
+
* Hide the query field
|
|
182
|
+
*/
|
|
183
|
+
hideQueryField: {
|
|
184
|
+
type: Boolean,
|
|
185
|
+
default: false,
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
data() {
|
|
189
|
+
return {
|
|
190
|
+
appliedFiltersCount: this.appliedFilters ? this.appliedFilters.length : 0,
|
|
191
|
+
};
|
|
192
|
+
},
|
|
193
|
+
computed: {
|
|
194
|
+
prefix() {
|
|
195
|
+
if(this.resourceName.plural) {
|
|
196
|
+
return `${this.resourceName.plural.toLowerCase()}`;
|
|
197
|
+
} else {
|
|
198
|
+
return this.resourceName.plural;
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
resource() {
|
|
202
|
+
const resourceName = this.resourceName;
|
|
203
|
+
return resourceName.plural ? 'Filter ' + resourceName.plural.toLowerCase() :
|
|
204
|
+
(resourceName.singular ? 'Filter ' + resourceName.singular.toLowerCase() : '');
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
methods: {
|
|
208
|
+
handleQueryChange(queryValue) {
|
|
209
|
+
/**
|
|
210
|
+
* Callback when the query field is changed
|
|
211
|
+
*/
|
|
212
|
+
this.$emit('queryChange', queryValue);
|
|
213
|
+
},
|
|
214
|
+
handleQueryClear() {
|
|
215
|
+
/**
|
|
216
|
+
* Callback when the clear button is triggered
|
|
217
|
+
*/
|
|
218
|
+
this.$emit('queryClear');
|
|
219
|
+
},
|
|
220
|
+
handleQueryClearAll() {
|
|
221
|
+
/**
|
|
222
|
+
* Callback when the reset all button is pressed
|
|
223
|
+
*/
|
|
224
|
+
this.$emit('queryClearAll');
|
|
225
|
+
},
|
|
226
|
+
handleQueryBlur() {
|
|
227
|
+
/**
|
|
228
|
+
* Callback when the query field is blurred
|
|
229
|
+
*/
|
|
230
|
+
this.$emit('queryBlur');
|
|
231
|
+
},
|
|
232
|
+
handleQueryFocus() {
|
|
233
|
+
/**
|
|
234
|
+
* Callback when the query field is focused
|
|
235
|
+
*/
|
|
236
|
+
this.$emit('queryFocus');
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
mounted() {
|
|
240
|
+
if (this.resourceTitle != null) {
|
|
241
|
+
// tslint:disable-next-line:no-console
|
|
242
|
+
console.error('Deprecation Notice: `resourceTitle` will be removed in version 4.0.0, use `resourceName` ' +
|
|
243
|
+
'instead.');
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (this.inputFilter != null) {
|
|
247
|
+
// tslint:disable-next-line:no-console
|
|
248
|
+
console.error('Deprecation Notice: `inputFilter` will be removed in version 4.0.0, use `queryValue` instead.');
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
</script>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import { classNames } from '../../../../utilities/css';
|
|
3
|
+
import ComponentHelpers from '../../../../ComponentHelpers';
|
|
4
|
+
import { PFilterItem } from '../../../../components/PFilter/components/PFilterItem';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
name: 'PFilterItemWrapper',
|
|
8
|
+
props: {
|
|
9
|
+
position: {
|
|
10
|
+
type: String,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
computed: {
|
|
14
|
+
className() {
|
|
15
|
+
return classNames(
|
|
16
|
+
this.position === 'center' && 'Polaris-Filters-ConnectedFilterControl__CenterContainer',
|
|
17
|
+
this.position === 'right' && 'Polaris-Filters-ConnectedFilterControl__RightContainer',
|
|
18
|
+
);
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
render(createElement) {
|
|
22
|
+
return createElement('div', {
|
|
23
|
+
class: this.className,
|
|
24
|
+
}, ComponentHelpers.wrapNodesWithComponent(
|
|
25
|
+
createElement,
|
|
26
|
+
this.$slots.default,
|
|
27
|
+
PFilterItem
|
|
28
|
+
),
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
</script>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="element" class="Polaris-Heading">
|
|
3
|
+
<!-- @slot The content to display inside the heading -->
|
|
4
|
+
<slot/>
|
|
5
|
+
</component>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import StringValidator from '../../utilities/validators/StringValidator';
|
|
10
|
+
|
|
11
|
+
const HeadingTagName = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p'];
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* <br/>
|
|
15
|
+
* <h4 style="font-family: -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue,
|
|
16
|
+
* sans-serif;">Headings are used as the titles of each major section of a page in the interface. For example,
|
|
17
|
+
* <a href="https://polaris-vue.hulkapps.com/?path=/docs/structure-card--card">card components</a>
|
|
18
|
+
* generally use headings as their title.</h4>
|
|
19
|
+
*/
|
|
20
|
+
export default {
|
|
21
|
+
name: 'PHeading',
|
|
22
|
+
props: {
|
|
23
|
+
/**
|
|
24
|
+
* The element name to use for the heading
|
|
25
|
+
*/
|
|
26
|
+
element: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: 'h2',
|
|
29
|
+
...StringValidator('element', HeadingTagName)
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
</script>
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span :class="className" :aria-label="accessibilityLabel" @click="handleClick" :style="clickable">
|
|
3
|
+
<div v-if="sourceType === 'placeholder'" class="Polaris-Icon__Placeholder"/>
|
|
4
|
+
<img
|
|
5
|
+
v-else-if="sourceType === 'external'"
|
|
6
|
+
class="Polaris-Icon__Img"
|
|
7
|
+
:src="`data:image/svg+xml;utf8,${encodedSource}`"
|
|
8
|
+
alt=""
|
|
9
|
+
aria-hidden="true"
|
|
10
|
+
/>
|
|
11
|
+
<div
|
|
12
|
+
v-else
|
|
13
|
+
v-html="enhancedSource"
|
|
14
|
+
/>
|
|
15
|
+
</span>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script>
|
|
19
|
+
import { DeprecatedIcons } from './index';
|
|
20
|
+
import * as Icon from '../../assets/shopify-polaris-icons';
|
|
21
|
+
import { classNames, variationName } from '../../utilities/css';
|
|
22
|
+
import { encode as encodeSVG } from '../../utilities/svg';
|
|
23
|
+
import StringValidator from '../../utilities/validators/StringValidator';
|
|
24
|
+
|
|
25
|
+
const Color = ['base', 'subdued', 'critical', 'interactive', 'warning', 'highlight', 'success', 'primary', null, ''];
|
|
26
|
+
|
|
27
|
+
export default {
|
|
28
|
+
name: 'PIcon',
|
|
29
|
+
props: {
|
|
30
|
+
/**
|
|
31
|
+
* Icon to display
|
|
32
|
+
* @see https://polaris-icons.shopify.com/?icon=AbandonedCartMajor available icon list.
|
|
33
|
+
*/
|
|
34
|
+
source: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: null
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Icon color
|
|
41
|
+
*/
|
|
42
|
+
color: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: null,
|
|
45
|
+
...StringValidator('color', Color),
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Show a backdrop behind the icon
|
|
50
|
+
*/
|
|
51
|
+
backdrop: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: false
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Descriptive text to be read to screenreaders
|
|
58
|
+
*/
|
|
59
|
+
accessibilityLabel: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: null
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
data() {
|
|
65
|
+
return {
|
|
66
|
+
clickable: {}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
computed: {
|
|
70
|
+
className() {
|
|
71
|
+
return classNames(
|
|
72
|
+
'Polaris-Icon',
|
|
73
|
+
this.color && (typeof this.color === 'string') && `Polaris-Icon--${variationName('color', this.color)}`,
|
|
74
|
+
this.color && 'Polaris-Icon--applyColor',
|
|
75
|
+
this.backdrop && 'Polaris-Icon--hasBackdrop',
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
encodedSource() {
|
|
79
|
+
return encodeSVG(this.source);
|
|
80
|
+
},
|
|
81
|
+
sourceType() {
|
|
82
|
+
if (this.source === 'function' || Object.keys(Icon).filter((icon) => icon === this.source).length > 0) {
|
|
83
|
+
return 'function';
|
|
84
|
+
} else if (this.source === 'placeholder') {
|
|
85
|
+
return 'placeholder';
|
|
86
|
+
} else {
|
|
87
|
+
return 'external';
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
enhancedSource() {
|
|
91
|
+
if (DeprecatedIcons.indexOf(this.source) > -1) {
|
|
92
|
+
// tslint:disable-next-line:no-console
|
|
93
|
+
console.error(this.source + '` this icon has been removed, please use new ' +
|
|
94
|
+
'instead of this. Refer this link to get updated icons ' +
|
|
95
|
+
'https://polaris-vue.hulkapps.com/?path=/story/images-icons-icon--icon');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const sourceIcon = Icon[this.source];
|
|
99
|
+
if (!sourceIcon) {
|
|
100
|
+
return this.source.replace('<svg', '<svg class="Polaris-Icon__Svg"');
|
|
101
|
+
}
|
|
102
|
+
return sourceIcon.replace('<svg', '<svg class="Polaris-Icon__Svg" focusable="false" aria-hidden="true"');
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
methods: {
|
|
106
|
+
handleClick() {
|
|
107
|
+
/**
|
|
108
|
+
* Handle click event
|
|
109
|
+
*/
|
|
110
|
+
this.$emit('click', event);
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
mounted() {
|
|
114
|
+
if (this.$listeners.click) {
|
|
115
|
+
this.clickable = {
|
|
116
|
+
cursor: 'pointer',
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
</script>
|