@saasquatch/vanilla-components 1.3.0-1 → 1.4.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/LICENSE +21 -21
- package/dist/cjs/{WidgetHost-d7b870ce.js → WidgetHost-71b013eb.js} +615 -615
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sqh-close-button.cjs.entry.js +25 -25
- package/dist/cjs/sqh-copy-button_12.cjs.entry.js +1015 -1148
- package/dist/cjs/sqh-referral-code.cjs.entry.js +22 -22
- package/dist/cjs/sqh-rewards-actions.cjs.entry.js +26 -26
- package/dist/cjs/widget-components.cjs.js +1 -1
- package/dist/collection/components/close-button/close-button.js +68 -67
- package/dist/collection/components/copy-button/copy-button.js +380 -332
- package/dist/collection/components/copy-link-button/copy-link-button.js +230 -203
- package/dist/collection/components/global-container/global-container.js +158 -144
- package/dist/collection/components/image-component/image-component.js +175 -153
- package/dist/collection/components/partner-stat-component/partner-stat-component.js +196 -173
- package/dist/collection/components/referral-code/referral-code.js +36 -33
- package/dist/collection/components/referral-component/referral-component.js +255 -254
- package/dist/collection/components/referral-list/referral-list.js +911 -818
- package/dist/collection/components/rewards-actions/rewards-actions.js +105 -104
- package/dist/collection/components/share-button/share-button.js +301 -291
- package/dist/collection/components/share-button-container/share-button-container.js +2384 -2194
- package/dist/collection/components/stat-component/stat-component.js +196 -173
- package/dist/collection/components/stats-container/stats-container.js +210 -197
- package/dist/collection/components/text-component/text-component.js +304 -264
- package/dist/collection/entrypoint.js +34 -32
- package/dist/collection/global/global.js +4 -4
- package/dist/collection/services/FormatJs.js +15 -15
- package/dist/collection/services/WidgetHost.js +621 -621
- package/dist/collection/utilities.js +81 -81
- package/dist/esm/{WidgetHost-a27e693d.js → WidgetHost-9c337319.js} +615 -615
- package/dist/esm/loader.mjs +1 -1
- package/dist/esm/polyfills/core-js.js +0 -0
- package/dist/esm/polyfills/dom.js +0 -0
- package/dist/esm/polyfills/es5-html-element.js +0 -0
- package/dist/esm/polyfills/index.js +0 -0
- package/dist/esm/polyfills/system.js +0 -0
- package/dist/esm/sqh-close-button.entry.js +25 -25
- package/dist/esm/sqh-copy-button_12.entry.js +1015 -1148
- package/dist/esm/sqh-referral-code.entry.js +22 -22
- package/dist/esm/sqh-rewards-actions.entry.js +26 -26
- package/dist/esm/widget-components.mjs +1 -1
- package/dist/esm-es5/{WidgetHost-a27e693d.js → WidgetHost-9c337319.js} +9432 -9432
- package/dist/esm-es5/_commonjsHelpers-1d681858.js +17 -17
- package/dist/esm-es5/css-shim-a659079f.js +122 -122
- package/dist/esm-es5/dom-4061ceba.js +468 -468
- package/dist/esm-es5/en-be593af0.js +1471 -1471
- package/dist/esm-es5/index-8ea8b6d8.js +1758 -1758
- package/dist/esm-es5/loader.mjs +11 -11
- package/dist/esm-es5/sqh-close-button.entry.js +35 -35
- package/dist/esm-es5/sqh-copy-button_12.entry.js +9535 -9657
- package/dist/esm-es5/sqh-referral-code.entry.js +29 -29
- package/dist/esm-es5/sqh-rewards-actions.entry.js +31 -31
- package/dist/esm-es5/widget-components.mjs +6 -6
- package/dist/types/components/close-button/close-button.d.ts +16 -15
- package/dist/types/components/copy-button/copy-button.d.ts +90 -86
- package/dist/types/components/copy-link-button/copy-link-button.d.ts +53 -50
- package/dist/types/components/global-container/global-container.d.ts +39 -37
- package/dist/types/components/image-component/image-component.d.ts +45 -42
- package/dist/types/components/partner-stat-component/partner-stat-component.d.ts +51 -44
- package/dist/types/components/referral-code/referral-code.d.ts +12 -9
- package/dist/types/components/referral-component/referral-component.d.ts +46 -45
- package/dist/types/components/referral-list/referral-list.d.ts +234 -211
- package/dist/types/components/rewards-actions/rewards-actions.d.ts +25 -24
- package/dist/types/components/share-button/share-button.d.ts +77 -75
- package/dist/types/components/share-button-container/share-button-container.d.ts +593 -591
- package/dist/types/components/stat-component/stat-component.d.ts +48 -44
- package/dist/types/components/stats-container/stats-container.d.ts +47 -41
- package/dist/types/components/text-component/text-component.d.ts +74 -73
- package/dist/types/components.d.ts +722 -536
- package/dist/types/global/global.d.ts +4 -4
- package/dist/types/saasquatch.d.ts +105 -103
- package/dist/types/services/FormatJs.d.ts +7 -7
- package/dist/types/services/WidgetHost.d.ts +45 -45
- package/dist/types/utilities.d.ts +7 -7
- package/dist/widget-components/entrypoint.js +34 -32
- package/dist/widget-components/p-24fc4ba9.js +1 -1
- package/dist/widget-components/{p-d4b27c72.entry.js → p-366f1663.entry.js} +1 -1
- package/dist/widget-components/p-46109683.js +3 -3
- package/dist/widget-components/{p-650d012d.entry.js → p-54ea7a00.entry.js} +1 -1
- package/dist/widget-components/p-58be1132.system.js +1 -1
- package/dist/widget-components/{p-d7059393.entry.js → p-95fe9766.entry.js} +17 -16
- package/dist/widget-components/{p-c0cdba77.system.entry.js → p-b17efca4.system.entry.js} +1 -1
- package/dist/widget-components/p-c8bc8c77.system.entry.js +1 -0
- package/dist/widget-components/p-d1f56be8.system.entry.js +8 -0
- package/dist/widget-components/widget-components.esm.js +1 -1
- package/docs/raisins.json +1 -0
- package/package.json +97 -93
- package/readme.md +52 -52
- package/CHANGELOG.md +0 -143
- package/dist/widget-components/p-908068c2.system.entry.js +0 -1
- package/dist/widget-components/p-fba5ea7f.system.entry.js +0 -8
- /package/dist/widget-components/{p-9adc7c50.system.js → p-8e232564.system.js} +0 -0
- /package/dist/widget-components/{p-9525bf4a.js → p-edd43dbc.js} +0 -0
|
@@ -1,197 +1,210 @@
|
|
|
1
|
-
import { h, Component, Prop, State, Element, Listen } from "@stencil/core";
|
|
2
|
-
import { API } from "../../services/WidgetHost";
|
|
3
|
-
import { pathToRegexp } from "path-to-regexp";
|
|
4
|
-
import { css } from "emotion";
|
|
5
|
-
/**
|
|
6
|
-
* @uiName Stats Container
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
static get
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
"
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
"
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
"
|
|
147
|
-
"
|
|
148
|
-
"
|
|
149
|
-
"
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
"
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
"
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
"
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
"
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
"
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
"
|
|
189
|
-
"
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
1
|
+
import { h, Component, Prop, State, Element, Listen } from "@stencil/core";
|
|
2
|
+
import { API } from "../../services/WidgetHost";
|
|
3
|
+
import { pathToRegexp } from "path-to-regexp";
|
|
4
|
+
import { css } from "emotion";
|
|
5
|
+
/**
|
|
6
|
+
* @uiName Stats Container
|
|
7
|
+
* @canvasRenderer always-replace
|
|
8
|
+
* @slots [{"name":"","title":"Stats"}]
|
|
9
|
+
* @exampleGroup Statistics
|
|
10
|
+
* @example Referral Stat Group - <sqh-stats-container ishidden="false" paddingtop="0" paddingbottom="0"><sqh-stat-component ishidden="false" statcolor="#4caf50" stattype="/referralsCount" statdescription="Friends Referred" paddingtop="10" paddingbottom="10"></sqh-stat-component><sqh-stat-component ishidden="false" stattype="/rewardsCount" statdescription="Total Rewards" paddingtop="10" paddingbottom="10" statcolor="#000000"></sqh-stat-component><sqh-stat-component ishidden="false" stattype="/rewardBalance/CREDIT/CENTS/prettyAssignedCredit" statdescription="Credit earned" paddingtop="10" paddingbottom="10" statcolor="#000000"></sqh-stat-component></sqh-stats-container>
|
|
11
|
+
* @example Partner Stat Group - <sqh-stats-container ishidden="false" paddingtop="0" paddingbottom="0"><sqh-partner-stat-component ishidden="false" statcolor="#000000" stattype="/rewardBalance/CREDIT/CASH_CAD/prettyPendingCredit" statdescription="Pending Balance" paddingtop="10" paddingbottom="10"></sqh-partner-stat-component><sqh-partner-stat-component ishidden="false" stattype="/rewardBalance/CREDIT/CASH_CAD/prettyValue" statdescription="Available Balance" paddingtop="10" paddingbottom="10" statcolor="#4caf50"></sqh-partner-stat-component><sqh-partner-stat-component ishidden="false" stattype="/rewardBalance/CREDIT/CASH_CAD/prettyRedeemedCredit" statdescription="Redeemed Balance" paddingtop="10" paddingbottom="10" statcolor="#000000"></sqh-partner-stat-component></sqh-stats-container>
|
|
12
|
+
*/
|
|
13
|
+
export class StatsContainer {
|
|
14
|
+
constructor() {
|
|
15
|
+
/**
|
|
16
|
+
* @undocumented
|
|
17
|
+
* @uiName Hide stats
|
|
18
|
+
*/
|
|
19
|
+
this.ishidden = false;
|
|
20
|
+
this.statPaths = [
|
|
21
|
+
"/rewardBalance/:type/:unit/:valuetype?/:isGlobal?",
|
|
22
|
+
"/:statName",
|
|
23
|
+
];
|
|
24
|
+
this.statPathRegexp = this.statPaths.map((path) => {
|
|
25
|
+
const keys = [];
|
|
26
|
+
const regexp = pathToRegexp(path, keys);
|
|
27
|
+
return { regexp, keys };
|
|
28
|
+
});
|
|
29
|
+
this.loading = true;
|
|
30
|
+
}
|
|
31
|
+
componentWillLoad() {
|
|
32
|
+
if (!this.ishidden) {
|
|
33
|
+
return API.graphql
|
|
34
|
+
.getStats()
|
|
35
|
+
.then((res) => {
|
|
36
|
+
this.stats = {
|
|
37
|
+
referralsCount: res.referralsCount.totalCount,
|
|
38
|
+
referralsMonth: res.referralsMonth.totalCount,
|
|
39
|
+
referralsWeek: res.referralsWeek.totalCount,
|
|
40
|
+
rewardsCount: res.rewardsCount.totalCount,
|
|
41
|
+
rewardsMonth: res.rewardsMonth.totalCount,
|
|
42
|
+
rewardsWeek: res.rewardsWeek.totalCount,
|
|
43
|
+
rewardBalance: res.rewardBalances,
|
|
44
|
+
rewardBalanceGlobal: res.rewardBalancesGlobal,
|
|
45
|
+
};
|
|
46
|
+
this.loading = false;
|
|
47
|
+
})
|
|
48
|
+
.then(() => {
|
|
49
|
+
const children = Array.from(this.container.querySelectorAll("[stattype]"));
|
|
50
|
+
children.map((child) => {
|
|
51
|
+
this.setStatValue(child);
|
|
52
|
+
});
|
|
53
|
+
})
|
|
54
|
+
.catch((e) => {
|
|
55
|
+
this.onError(e);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
statTypeUpdatedHandler(event) {
|
|
60
|
+
this.setStatValue(event.detail);
|
|
61
|
+
}
|
|
62
|
+
statAddedHandler(event) {
|
|
63
|
+
if (this.stats)
|
|
64
|
+
this.setStatValue(event.detail);
|
|
65
|
+
}
|
|
66
|
+
setStatValue(child) {
|
|
67
|
+
const path = child.getAttribute("stattype");
|
|
68
|
+
const stat = this.getStatFromPath(path);
|
|
69
|
+
child.setAttribute("statvalue", `${stat}`);
|
|
70
|
+
return child;
|
|
71
|
+
}
|
|
72
|
+
getStatFromPath(path) {
|
|
73
|
+
const statPath = this.statPathRegexp.find((stat) => stat.regexp.test(path));
|
|
74
|
+
if (!statPath)
|
|
75
|
+
return 0;
|
|
76
|
+
const { keys, regexp } = statPath;
|
|
77
|
+
const res = regexp.exec(path);
|
|
78
|
+
const statVariables = {};
|
|
79
|
+
keys.forEach((k, i) => (statVariables[k.name] = res[i + 1]));
|
|
80
|
+
return this.getStatValue(statVariables);
|
|
81
|
+
}
|
|
82
|
+
getStatValue(statVariables) {
|
|
83
|
+
if (statVariables.statName)
|
|
84
|
+
return this.stats[statVariables.statName] || 0;
|
|
85
|
+
return this.getRewardBalance(statVariables);
|
|
86
|
+
}
|
|
87
|
+
getRewardBalance(statVariables) {
|
|
88
|
+
const { type, unit, valuetype, isGlobal } = statVariables;
|
|
89
|
+
// passing in CASH/USD as CASH_USD into this webcomponent so pathToRegexp doesn't split it and it stays all in unit.
|
|
90
|
+
// this converts the _ back to / so it matches the unit from the backend.
|
|
91
|
+
// possibly change the unit in the backend to avoid this?
|
|
92
|
+
const newUnit = unit.replace(/_/, "/");
|
|
93
|
+
const rewardBalance = this.stats[isGlobal ? "rewardBalanceGlobal" : "rewardBalance"].find((rb) => rb.type === type && rb.unit === newUnit);
|
|
94
|
+
if (!rewardBalance)
|
|
95
|
+
return 0;
|
|
96
|
+
if (valuetype)
|
|
97
|
+
return rewardBalance[valuetype];
|
|
98
|
+
return rewardBalance.value;
|
|
99
|
+
}
|
|
100
|
+
onError(e) {
|
|
101
|
+
console.log("Error loading via GraphQL.", e);
|
|
102
|
+
this.loading = false;
|
|
103
|
+
}
|
|
104
|
+
render() {
|
|
105
|
+
const containerStyle = css `
|
|
106
|
+
display: ${this.ishidden ? "none" : "inherit"};
|
|
107
|
+
padding-top: ${this.paddingtop}px;
|
|
108
|
+
padding-bottom: ${this.paddingbottom}px;
|
|
109
|
+
`;
|
|
110
|
+
return (h("div", { class: containerStyle },
|
|
111
|
+
h("slot", null)));
|
|
112
|
+
}
|
|
113
|
+
static get is() { return "sqh-stats-container"; }
|
|
114
|
+
static get originalStyleUrls() { return {
|
|
115
|
+
"$": ["stats-container.scss"]
|
|
116
|
+
}; }
|
|
117
|
+
static get styleUrls() { return {
|
|
118
|
+
"$": ["stats-container.css"]
|
|
119
|
+
}; }
|
|
120
|
+
static get properties() { return {
|
|
121
|
+
"ishidden": {
|
|
122
|
+
"type": "boolean",
|
|
123
|
+
"mutable": false,
|
|
124
|
+
"complexType": {
|
|
125
|
+
"original": "boolean",
|
|
126
|
+
"resolved": "boolean",
|
|
127
|
+
"references": {}
|
|
128
|
+
},
|
|
129
|
+
"required": false,
|
|
130
|
+
"optional": false,
|
|
131
|
+
"docs": {
|
|
132
|
+
"tags": [{
|
|
133
|
+
"text": undefined,
|
|
134
|
+
"name": "undocumented"
|
|
135
|
+
}, {
|
|
136
|
+
"text": "Hide stats",
|
|
137
|
+
"name": "uiName"
|
|
138
|
+
}],
|
|
139
|
+
"text": ""
|
|
140
|
+
},
|
|
141
|
+
"attribute": "ishidden",
|
|
142
|
+
"reflect": false,
|
|
143
|
+
"defaultValue": "false"
|
|
144
|
+
},
|
|
145
|
+
"paddingtop": {
|
|
146
|
+
"type": "string",
|
|
147
|
+
"mutable": false,
|
|
148
|
+
"complexType": {
|
|
149
|
+
"original": "string",
|
|
150
|
+
"resolved": "string",
|
|
151
|
+
"references": {}
|
|
152
|
+
},
|
|
153
|
+
"required": false,
|
|
154
|
+
"optional": false,
|
|
155
|
+
"docs": {
|
|
156
|
+
"tags": [{
|
|
157
|
+
"text": "Padding Top",
|
|
158
|
+
"name": "uiName"
|
|
159
|
+
}, {
|
|
160
|
+
"text": "0",
|
|
161
|
+
"name": "default"
|
|
162
|
+
}],
|
|
163
|
+
"text": "Define the bottom padding of the container with a pixel amount."
|
|
164
|
+
},
|
|
165
|
+
"attribute": "paddingtop",
|
|
166
|
+
"reflect": false
|
|
167
|
+
},
|
|
168
|
+
"paddingbottom": {
|
|
169
|
+
"type": "string",
|
|
170
|
+
"mutable": false,
|
|
171
|
+
"complexType": {
|
|
172
|
+
"original": "string",
|
|
173
|
+
"resolved": "string",
|
|
174
|
+
"references": {}
|
|
175
|
+
},
|
|
176
|
+
"required": false,
|
|
177
|
+
"optional": false,
|
|
178
|
+
"docs": {
|
|
179
|
+
"tags": [{
|
|
180
|
+
"text": "Padding Bottom",
|
|
181
|
+
"name": "uiName"
|
|
182
|
+
}, {
|
|
183
|
+
"text": "0",
|
|
184
|
+
"name": "default"
|
|
185
|
+
}],
|
|
186
|
+
"text": "Define the top padding of the container with a pixel amount."
|
|
187
|
+
},
|
|
188
|
+
"attribute": "paddingbottom",
|
|
189
|
+
"reflect": false
|
|
190
|
+
}
|
|
191
|
+
}; }
|
|
192
|
+
static get states() { return {
|
|
193
|
+
"loading": {},
|
|
194
|
+
"stats": {}
|
|
195
|
+
}; }
|
|
196
|
+
static get elementRef() { return "container"; }
|
|
197
|
+
static get listeners() { return [{
|
|
198
|
+
"name": "statTypeUpdated",
|
|
199
|
+
"method": "statTypeUpdatedHandler",
|
|
200
|
+
"target": undefined,
|
|
201
|
+
"capture": false,
|
|
202
|
+
"passive": false
|
|
203
|
+
}, {
|
|
204
|
+
"name": "statAdded",
|
|
205
|
+
"method": "statAddedHandler",
|
|
206
|
+
"target": undefined,
|
|
207
|
+
"capture": false,
|
|
208
|
+
"passive": false
|
|
209
|
+
}]; }
|
|
210
|
+
}
|