@saasquatch/mint-components 2.1.13 → 2.1.14-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/cjs/loader.cjs.js +1 -1
- package/dist/cjs/mint-components.cjs.js +1 -1
- package/dist/cjs/{sqm-big-stat_45.cjs.entry.js → sqm-big-stat_46.cjs.entry.js} +73 -1
- package/dist/cjs/sqm-stencilbook.cjs.entry.js +54 -0
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/sqm-stencilbook/sqm-stencilbook.js +2 -0
- package/dist/collection/components/sqm-user-attribute/UserAttribute.stories.js +43 -0
- package/dist/collection/components/sqm-user-attribute/sqm-user-attribute-view.js +19 -0
- package/dist/collection/components/sqm-user-attribute/sqm-user-attribute.js +175 -0
- package/dist/collection/components/sqm-user-attribute/useUserAttribute.js +30 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/mint-components.js +1 -1
- package/dist/esm/{sqm-big-stat_45.entry.js → sqm-big-stat_46.entry.js} +73 -2
- package/dist/esm/sqm-stencilbook.entry.js +54 -0
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/mint-components.js +1 -1
- package/dist/esm-es5/sqm-big-stat_46.entry.js +1 -0
- package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
- package/dist/mint-components/mint-components.esm.js +1 -1
- package/dist/mint-components/{p-b4fa20ce.entry.js → p-8285869e.entry.js} +2 -2
- package/dist/mint-components/{p-bbbd6e44.entry.js → p-be12607e.entry.js} +29 -21
- package/dist/mint-components/{p-3ca77515.system.entry.js → p-bf188b72.system.entry.js} +1 -1
- package/dist/mint-components/p-ca098be1.system.js +1 -1
- package/dist/mint-components/p-fb804001.system.entry.js +1 -0
- package/dist/types/components/sqm-user-attribute/UserAttribute.stories.d.ts +11 -0
- package/dist/types/components/sqm-user-attribute/sqm-user-attribute-view.d.ts +8 -0
- package/dist/types/components/sqm-user-attribute/sqm-user-attribute.d.ts +45 -0
- package/dist/types/components/sqm-user-attribute/useUserAttribute.d.ts +3 -0
- package/dist/types/components.d.ts +78 -0
- package/docs/docs.docx +0 -0
- package/docs/raisins.json +1 -1
- package/grapesjs/grapesjs.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/sqm-big-stat_45.entry.js +0 -1
- package/dist/mint-components/p-37883f0c.system.entry.js +0 -1
|
@@ -18844,6 +18844,59 @@ const UserInfoFormView = /*#__PURE__*/Object.freeze({
|
|
|
18844
18844
|
DisabledForm: DisabledForm
|
|
18845
18845
|
});
|
|
18846
18846
|
|
|
18847
|
+
const scenario$G = "@owner:zach @author:zach\nFeature: User Attribute\n Displays a user's custom field value.\n\n Background: A user exists\n Given a user is logged in\n And the user has custom fields\n\n @motivating\n Scenario: A custom field value is displayed\n Given the component has prop \"value\" with value \"firstName\"\n And the user has a custom field \"firstName\" with value \"John\"\n When the component is rendered\n Then the text \"John\" is displayed\n\n @landmine\n Scenario: Nothing is rendered when the custom field does not exist\n Given the component has prop \"value\" with value \"nonExistentField\"\n And the user does not have a custom field \"nonExistentField\"\n Then component is not rendered\n And nothing is displayed\n\n @motivating\n Scenario: Nothing is rendered while user data is loading\n Given the component is loading user data\n When the component is rendered\n Then component is not rendered\n And nothing is displayed\n\n @motivating\n Scenario Outline: Optional styling props can be applied to customize the text appearance\n Given the component has prop <prop> with value <value>\n When the component is rendered\n Then the text is displayed with <cssProperty> set to <value>\n\n Examples:\n | prop | value | cssProperty |\n | fontSize | 24 | font-size |\n | color | #E91E63 | color |\n | fontWeight | 700 | font-weight |\n\n @minutia\n Scenario: Style props are optional and default to no custom styling\n Given the component has no style props set\n When the component is rendered\n Then the text is displayed with default browser styles\n";
|
|
18848
|
+
|
|
18849
|
+
const UserAttribute_stories = {
|
|
18850
|
+
title: "Components/User Attribute",
|
|
18851
|
+
parameters: {
|
|
18852
|
+
scenario: scenario$G,
|
|
18853
|
+
},
|
|
18854
|
+
};
|
|
18855
|
+
const Default$x = () => {
|
|
18856
|
+
return (index.h("sqm-user-attribute", { demoData: {
|
|
18857
|
+
loading: false,
|
|
18858
|
+
value: "impact.com",
|
|
18859
|
+
} }));
|
|
18860
|
+
};
|
|
18861
|
+
/*
|
|
18862
|
+
Verifies that an sqm-user-attribute with no valid value
|
|
18863
|
+
collapses completely and does not create extra space
|
|
18864
|
+
(e.g. a double gap) in a flex layout.
|
|
18865
|
+
*/
|
|
18866
|
+
const InvalidValue = () => {
|
|
18867
|
+
return (index.h("div", { style: { display: "flex", flexDirection: "column", gap: "16px" } },
|
|
18868
|
+
index.h("div", { style: { background: "#e0e0e0", padding: "8px" } }, "Above"),
|
|
18869
|
+
index.h("sqm-user-attribute", { demoData: {
|
|
18870
|
+
loading: false,
|
|
18871
|
+
value: null,
|
|
18872
|
+
} }),
|
|
18873
|
+
index.h("div", { style: { background: "#e0e0e0", padding: "8px" } }, "Below")));
|
|
18874
|
+
};
|
|
18875
|
+
const Loading$h = () => {
|
|
18876
|
+
return (index.h("sqm-user-attribute", { demoData: {
|
|
18877
|
+
loading: true,
|
|
18878
|
+
value: "impact.com",
|
|
18879
|
+
} }));
|
|
18880
|
+
};
|
|
18881
|
+
const WithCustomStyles = () => {
|
|
18882
|
+
return (index.h("sqm-user-attribute", { demoData: {
|
|
18883
|
+
loading: false,
|
|
18884
|
+
value: "impact.com",
|
|
18885
|
+
fontSize: 24,
|
|
18886
|
+
color: "#4CAF50",
|
|
18887
|
+
fontWeight: 700,
|
|
18888
|
+
} }));
|
|
18889
|
+
};
|
|
18890
|
+
|
|
18891
|
+
const UserAttribute = /*#__PURE__*/Object.freeze({
|
|
18892
|
+
__proto__: null,
|
|
18893
|
+
'default': UserAttribute_stories,
|
|
18894
|
+
Default: Default$x,
|
|
18895
|
+
InvalidValue: InvalidValue,
|
|
18896
|
+
Loading: Loading$h,
|
|
18897
|
+
WithCustomStyles: WithCustomStyles
|
|
18898
|
+
});
|
|
18899
|
+
|
|
18847
18900
|
function deepFreeze(obj) {
|
|
18848
18901
|
if (obj instanceof Map) {
|
|
18849
18902
|
obj.clear = obj.delete = obj.set = function () {
|
|
@@ -21537,6 +21590,7 @@ const stories = [
|
|
|
21537
21590
|
TaxAndCashRewardsTable,
|
|
21538
21591
|
TaxAndCashReferralTableRewardsCell,
|
|
21539
21592
|
TaxAndCashReferralTable$1,
|
|
21593
|
+
UserAttribute,
|
|
21540
21594
|
];
|
|
21541
21595
|
const StencilStorybook = class {
|
|
21542
21596
|
constructor(hostRef) {
|
|
@@ -121,6 +121,7 @@
|
|
|
121
121
|
"./components/sqm-timeline/sqm-timeline-entry.js",
|
|
122
122
|
"./components/sqm-timeline/sqm-timeline.js",
|
|
123
123
|
"./components/sqm-titled-section/sqm-titled-section.js",
|
|
124
|
+
"./components/sqm-user-attribute/sqm-user-attribute.js",
|
|
124
125
|
"./components/sqm-user-name/sqm-user-name.js",
|
|
125
126
|
"./components/sqm-widget-verification/sqm-widget-verification-controller.js",
|
|
126
127
|
"./components/sqm-widget-verification/sqm-widget-verification.js",
|
|
@@ -107,6 +107,7 @@ import * as LeadFormDropdownField from "../sqm-lead-form/LeadFormDropdownField.s
|
|
|
107
107
|
import * as LeadCheckboxField from "../sqm-lead-form/LeadCheckboxField.stories";
|
|
108
108
|
import * as Skeleton from "../sqm-skeleton/Skeleton.stories";
|
|
109
109
|
import * as UserInfoFormView from "../tax-and-cash/sqm-user-info-form/UserInfoFormView.stories";
|
|
110
|
+
import * as UserAttribute from "../sqm-user-attribute/UserAttribute.stories";
|
|
110
111
|
import { ShadowViewAddon } from "../../ShadowViewAddon";
|
|
111
112
|
import { CucumberAddon } from "./CucumberAddon";
|
|
112
113
|
import { HookStoryAddon } from "./HookStoryAddon";
|
|
@@ -218,6 +219,7 @@ const stories = [
|
|
|
218
219
|
TaxAndCashRewardsTable,
|
|
219
220
|
TaxAndCashReferralTableRewardsCell,
|
|
220
221
|
TaxAndCashReferralTable,
|
|
222
|
+
UserAttribute,
|
|
221
223
|
];
|
|
222
224
|
/**
|
|
223
225
|
* For internal documentation
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
import scenario from "./user-attribute.feature";
|
|
3
|
+
export default {
|
|
4
|
+
title: "Components/User Attribute",
|
|
5
|
+
parameters: {
|
|
6
|
+
scenario,
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
export const Default = () => {
|
|
10
|
+
return (h("sqm-user-attribute", { demoData: {
|
|
11
|
+
loading: false,
|
|
12
|
+
value: "impact.com",
|
|
13
|
+
} }));
|
|
14
|
+
};
|
|
15
|
+
/*
|
|
16
|
+
Verifies that an sqm-user-attribute with no valid value
|
|
17
|
+
collapses completely and does not create extra space
|
|
18
|
+
(e.g. a double gap) in a flex layout.
|
|
19
|
+
*/
|
|
20
|
+
export const InvalidValue = () => {
|
|
21
|
+
return (h("div", { style: { display: "flex", flexDirection: "column", gap: "16px" } },
|
|
22
|
+
h("div", { style: { background: "#e0e0e0", padding: "8px" } }, "Above"),
|
|
23
|
+
h("sqm-user-attribute", { demoData: {
|
|
24
|
+
loading: false,
|
|
25
|
+
value: null,
|
|
26
|
+
} }),
|
|
27
|
+
h("div", { style: { background: "#e0e0e0", padding: "8px" } }, "Below")));
|
|
28
|
+
};
|
|
29
|
+
export const Loading = () => {
|
|
30
|
+
return (h("sqm-user-attribute", { demoData: {
|
|
31
|
+
loading: true,
|
|
32
|
+
value: "impact.com",
|
|
33
|
+
} }));
|
|
34
|
+
};
|
|
35
|
+
export const WithCustomStyles = () => {
|
|
36
|
+
return (h("sqm-user-attribute", { demoData: {
|
|
37
|
+
loading: false,
|
|
38
|
+
value: "impact.com",
|
|
39
|
+
fontSize: 24,
|
|
40
|
+
color: "#4CAF50",
|
|
41
|
+
fontWeight: 700,
|
|
42
|
+
} }));
|
|
43
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { h, Host } from "@stencil/core";
|
|
2
|
+
import { createStyleSheet } from "../../styling/JSS";
|
|
3
|
+
export function UserAttributeView(props) {
|
|
4
|
+
const style = {
|
|
5
|
+
P: {
|
|
6
|
+
margin: "0",
|
|
7
|
+
padding: "0",
|
|
8
|
+
fontSize: props.fontSize ? `${props.fontSize}px` : "inherit",
|
|
9
|
+
fontWeight: props.fontWeight || "inherit",
|
|
10
|
+
color: props.color || "var(--sqm-text)",
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
const sheet = createStyleSheet(style);
|
|
14
|
+
const styleString = sheet.toString();
|
|
15
|
+
const loadingSkeleton = (h("sqm-skeleton", { width: "200px", height: "20px" }));
|
|
16
|
+
return (h(Host, null,
|
|
17
|
+
h("style", null, styleString),
|
|
18
|
+
h("p", { class: sheet.classes.P, part: "sqm-base" }, props.loading ? loadingSkeleton : props.value)));
|
|
19
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { isDemo } from "@saasquatch/component-boilerplate";
|
|
2
|
+
import { withHooks } from "@saasquatch/stencil-hooks";
|
|
3
|
+
import { Component, h, Host, Prop, State } from "@stencil/core";
|
|
4
|
+
import deepmerge from "deepmerge";
|
|
5
|
+
import { UserAttributeView, } from "./sqm-user-attribute-view";
|
|
6
|
+
import { useUserAttribute } from "./useUserAttribute";
|
|
7
|
+
/**
|
|
8
|
+
* @uiName User Attribute
|
|
9
|
+
* @exampleGroup Advanced
|
|
10
|
+
* @example User Attribute - <sqm-user-attribute value="lastSeenDate"></sqm-user-attribute>
|
|
11
|
+
*/
|
|
12
|
+
export class UserAttribute {
|
|
13
|
+
constructor() {
|
|
14
|
+
this.ignored = true;
|
|
15
|
+
withHooks(this);
|
|
16
|
+
}
|
|
17
|
+
disconnectedCallback() { }
|
|
18
|
+
render() {
|
|
19
|
+
const props = isDemo() ? useCustomFieldsDemo(this) : useUserAttribute(this);
|
|
20
|
+
if (props.value == null) {
|
|
21
|
+
return h(Host, { style: { display: "none" } });
|
|
22
|
+
}
|
|
23
|
+
return h(UserAttributeView, Object.assign({}, props));
|
|
24
|
+
}
|
|
25
|
+
static get is() { return "sqm-user-attribute"; }
|
|
26
|
+
static get encapsulation() { return "shadow"; }
|
|
27
|
+
static get properties() { return {
|
|
28
|
+
"value": {
|
|
29
|
+
"type": "any",
|
|
30
|
+
"mutable": false,
|
|
31
|
+
"complexType": {
|
|
32
|
+
"original": "string | number",
|
|
33
|
+
"resolved": "number | string",
|
|
34
|
+
"references": {}
|
|
35
|
+
},
|
|
36
|
+
"required": false,
|
|
37
|
+
"optional": false,
|
|
38
|
+
"docs": {
|
|
39
|
+
"tags": [{
|
|
40
|
+
"text": "Custom field key",
|
|
41
|
+
"name": "uiName"
|
|
42
|
+
}, {
|
|
43
|
+
"text": "customFieldSelector",
|
|
44
|
+
"name": "uiWidget"
|
|
45
|
+
}],
|
|
46
|
+
"text": "The custom field key to display."
|
|
47
|
+
},
|
|
48
|
+
"attribute": "value",
|
|
49
|
+
"reflect": false
|
|
50
|
+
},
|
|
51
|
+
"fontSize": {
|
|
52
|
+
"type": "number",
|
|
53
|
+
"mutable": false,
|
|
54
|
+
"complexType": {
|
|
55
|
+
"original": "number",
|
|
56
|
+
"resolved": "number",
|
|
57
|
+
"references": {}
|
|
58
|
+
},
|
|
59
|
+
"required": false,
|
|
60
|
+
"optional": true,
|
|
61
|
+
"docs": {
|
|
62
|
+
"tags": [{
|
|
63
|
+
"text": "Font size",
|
|
64
|
+
"name": "uiName"
|
|
65
|
+
}, {
|
|
66
|
+
"text": "Style",
|
|
67
|
+
"name": "uiGroup"
|
|
68
|
+
}],
|
|
69
|
+
"text": "Number in pixels."
|
|
70
|
+
},
|
|
71
|
+
"attribute": "font-size",
|
|
72
|
+
"reflect": false
|
|
73
|
+
},
|
|
74
|
+
"color": {
|
|
75
|
+
"type": "string",
|
|
76
|
+
"mutable": false,
|
|
77
|
+
"complexType": {
|
|
78
|
+
"original": "string",
|
|
79
|
+
"resolved": "string",
|
|
80
|
+
"references": {}
|
|
81
|
+
},
|
|
82
|
+
"required": false,
|
|
83
|
+
"optional": true,
|
|
84
|
+
"docs": {
|
|
85
|
+
"tags": [{
|
|
86
|
+
"text": "Color",
|
|
87
|
+
"name": "uiName"
|
|
88
|
+
}, {
|
|
89
|
+
"text": "color",
|
|
90
|
+
"name": "uiWidget"
|
|
91
|
+
}, {
|
|
92
|
+
"text": "color",
|
|
93
|
+
"name": "format"
|
|
94
|
+
}, {
|
|
95
|
+
"text": "Style",
|
|
96
|
+
"name": "uiGroup"
|
|
97
|
+
}],
|
|
98
|
+
"text": ""
|
|
99
|
+
},
|
|
100
|
+
"attribute": "color",
|
|
101
|
+
"reflect": false
|
|
102
|
+
},
|
|
103
|
+
"fontWeight": {
|
|
104
|
+
"type": "number",
|
|
105
|
+
"mutable": false,
|
|
106
|
+
"complexType": {
|
|
107
|
+
"original": "number",
|
|
108
|
+
"resolved": "number",
|
|
109
|
+
"references": {}
|
|
110
|
+
},
|
|
111
|
+
"required": false,
|
|
112
|
+
"optional": true,
|
|
113
|
+
"docs": {
|
|
114
|
+
"tags": [{
|
|
115
|
+
"text": "Font weight",
|
|
116
|
+
"name": "uiName"
|
|
117
|
+
}, {
|
|
118
|
+
"text": "Style",
|
|
119
|
+
"name": "uiGroup"
|
|
120
|
+
}, {
|
|
121
|
+
"text": "[100, 200, 300, 400, 500, 600, 700, 800, 900]",
|
|
122
|
+
"name": "uiEnum"
|
|
123
|
+
}, {
|
|
124
|
+
"text": "[\"Thin\", \"Extra Light\", \"Light\", \"Normal\", \"Medium\", \"Semi Bold\", \"Bold\", \"Extra Bold\", \"Heavy\"]",
|
|
125
|
+
"name": "uiEnumNames"
|
|
126
|
+
}],
|
|
127
|
+
"text": "Font weight"
|
|
128
|
+
},
|
|
129
|
+
"attribute": "font-weight",
|
|
130
|
+
"reflect": false
|
|
131
|
+
},
|
|
132
|
+
"demoData": {
|
|
133
|
+
"type": "unknown",
|
|
134
|
+
"mutable": false,
|
|
135
|
+
"complexType": {
|
|
136
|
+
"original": "DemoData<UserAttributeViewProps>",
|
|
137
|
+
"resolved": "{ loading?: boolean; value?: string; fontSize?: number; color?: string; fontWeight?: number; }",
|
|
138
|
+
"references": {
|
|
139
|
+
"DemoData": {
|
|
140
|
+
"location": "import",
|
|
141
|
+
"path": "../../global/demo"
|
|
142
|
+
},
|
|
143
|
+
"UserAttributeViewProps": {
|
|
144
|
+
"location": "import",
|
|
145
|
+
"path": "./sqm-user-attribute-view"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"required": false,
|
|
150
|
+
"optional": true,
|
|
151
|
+
"docs": {
|
|
152
|
+
"tags": [{
|
|
153
|
+
"text": undefined,
|
|
154
|
+
"name": "undocumented"
|
|
155
|
+
}, {
|
|
156
|
+
"text": "object",
|
|
157
|
+
"name": "uiType"
|
|
158
|
+
}],
|
|
159
|
+
"text": ""
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}; }
|
|
163
|
+
static get states() { return {
|
|
164
|
+
"ignored": {}
|
|
165
|
+
}; }
|
|
166
|
+
}
|
|
167
|
+
function useCustomFieldsDemo(props) {
|
|
168
|
+
return deepmerge({
|
|
169
|
+
loading: false,
|
|
170
|
+
value: "Custom Field Value",
|
|
171
|
+
fontSize: props.fontSize,
|
|
172
|
+
color: props.color,
|
|
173
|
+
fontWeight: props.fontWeight,
|
|
174
|
+
}, props.demoData || {}, { arrayMerge: (_, a) => a });
|
|
175
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useQuery, useUserIdentity } from "@saasquatch/component-boilerplate";
|
|
2
|
+
import { gql } from "graphql-request";
|
|
3
|
+
import { DateTime } from "luxon";
|
|
4
|
+
const GET_CUSTOM_FIELDS = gql `
|
|
5
|
+
query getCustomFields {
|
|
6
|
+
viewer {
|
|
7
|
+
... on User {
|
|
8
|
+
customFields
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
export function useUserAttribute(props) {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const user = useUserIdentity();
|
|
16
|
+
const res = useQuery(GET_CUSTOM_FIELDS, {}, !(user === null || user === void 0 ? void 0 : user.jwt));
|
|
17
|
+
const loading = res.loading;
|
|
18
|
+
const customFields = (_b = (_a = res.data) === null || _a === void 0 ? void 0 : _a.viewer) === null || _b === void 0 ? void 0 : _b.customFields;
|
|
19
|
+
let value = customFields === null || customFields === void 0 ? void 0 : customFields[props.value];
|
|
20
|
+
if (props.value === "lastSeenDate" && typeof value === "number") {
|
|
21
|
+
value = DateTime.fromMillis(value).toLocaleString(DateTime.DATE_MED);
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
loading,
|
|
25
|
+
value,
|
|
26
|
+
fontSize: props.fontSize,
|
|
27
|
+
color: props.color,
|
|
28
|
+
fontWeight: props.fontWeight,
|
|
29
|
+
};
|
|
30
|
+
}
|