@saasquatch/mint-components 2.1.12 → 2.1.14-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.
Files changed (43) hide show
  1. package/dist/cjs/{ShadowViewAddon-229dd1c1.js → ShadowViewAddon-c97e80de.js} +1 -1
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/mint-components.cjs.js +1 -1
  4. package/dist/cjs/{sqm-big-stat_45.cjs.entry.js → sqm-big-stat_46.cjs.entry.js} +75 -3
  5. package/dist/cjs/sqm-stencilbook.cjs.entry.js +55 -1
  6. package/dist/collection/collection-manifest.json +1 -0
  7. package/dist/collection/components/sqm-checkbox-field/sqm-checkbox-field-view.js +1 -1
  8. package/dist/collection/components/sqm-checkbox-field/sqm-checkbox-field.js +3 -2
  9. package/dist/collection/components/sqm-stencilbook/sqm-stencilbook.js +2 -0
  10. package/dist/collection/components/sqm-user-attribute/UserAttribute.stories.js +43 -0
  11. package/dist/collection/components/sqm-user-attribute/sqm-user-attribute-view.js +19 -0
  12. package/dist/collection/components/sqm-user-attribute/sqm-user-attribute.js +175 -0
  13. package/dist/collection/components/sqm-user-attribute/useUserAttribute.js +30 -0
  14. package/dist/esm/{ShadowViewAddon-cc32bca2.js → ShadowViewAddon-33f1a8f7.js} +1 -1
  15. package/dist/esm/loader.js +1 -1
  16. package/dist/esm/mint-components.js +1 -1
  17. package/dist/esm/{sqm-big-stat_45.entry.js → sqm-big-stat_46.entry.js} +75 -4
  18. package/dist/esm/sqm-stencilbook.entry.js +55 -1
  19. package/dist/esm-es5/{ShadowViewAddon-cc32bca2.js → ShadowViewAddon-33f1a8f7.js} +1 -1
  20. package/dist/esm-es5/loader.js +1 -1
  21. package/dist/esm-es5/mint-components.js +1 -1
  22. package/dist/esm-es5/sqm-big-stat_46.entry.js +1 -0
  23. package/dist/esm-es5/sqm-stencilbook.entry.js +1 -1
  24. package/dist/mint-components/mint-components.esm.js +1 -1
  25. package/dist/mint-components/{p-8300e806.js → p-08930b83.js} +1 -1
  26. package/dist/mint-components/{p-b3f18de4.entry.js → p-7462403c.entry.js} +2 -2
  27. package/dist/mint-components/{p-e846e3bb.system.js → p-78b40f71.system.js} +1 -1
  28. package/dist/mint-components/{p-f611c11a.system.entry.js → p-9de4d6d1.system.entry.js} +1 -1
  29. package/dist/mint-components/p-ca098be1.system.js +1 -1
  30. package/dist/mint-components/{p-a3eefe38.entry.js → p-e43a8421.entry.js} +29 -21
  31. package/dist/mint-components/p-fb637e0a.system.entry.js +1 -0
  32. package/dist/types/components/sqm-checkbox-field/sqm-checkbox-field.d.ts +1 -1
  33. package/dist/types/components/sqm-user-attribute/UserAttribute.stories.d.ts +11 -0
  34. package/dist/types/components/sqm-user-attribute/sqm-user-attribute-view.d.ts +8 -0
  35. package/dist/types/components/sqm-user-attribute/sqm-user-attribute.d.ts +45 -0
  36. package/dist/types/components/sqm-user-attribute/useUserAttribute.d.ts +3 -0
  37. package/dist/types/components.d.ts +80 -2
  38. package/docs/docs.docx +0 -0
  39. package/docs/raisins.json +1 -1
  40. package/grapesjs/grapesjs.js +1 -1
  41. package/package.json +1 -1
  42. package/dist/esm-es5/sqm-big-stat_45.entry.js +0 -1
  43. package/dist/mint-components/p-7a673f14.system.entry.js +0 -1
@@ -33,7 +33,7 @@ require('./utilities-fcdb9504.js');
33
33
  const sqmPortalResetPasswordView = require('./sqm-portal-reset-password-view-a767b044.js');
34
34
  require('./ErrorView-ee7b0f36.js');
35
35
  const sqmQrCodeView = require('./sqm-qr-code-view-1f2daa76.js');
36
- const ShadowViewAddon = require('./ShadowViewAddon-229dd1c1.js');
36
+ const ShadowViewAddon = require('./ShadowViewAddon-c97e80de.js');
37
37
  const sqmPortalContainerView = require('./sqm-portal-container-view-757f921b.js');
38
38
  const sqmUserInfoFormView = require('./sqm-user-info-form-view-53306f6e.js');
39
39
  const data = require('./data-8c8a08f6.js');
@@ -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: A loading skeleton is shown while data is loading\n Given the component is loading user data\n When the component is rendered\n Then a loading skeleton 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",
@@ -60,7 +60,7 @@ export function CheckboxFieldView(props) {
60
60
  h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`, checked: states.checked, "onSl-change": (e) => {
61
61
  e.target.value = e.target.checked;
62
62
  callbacks.setChecked(e.target.value);
63
- } }, (!content.checkboxOptional ? { required: true } : []), { disabled: ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.loading) || ((_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.disabled), validationError: ({ value }) => {
63
+ } }, (!content.checkboxOptional ? { required: false } : []), { disabled: ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.loading) || ((_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.disabled), validationError: ({ value }) => {
64
64
  if (!value && !content.checkboxOptional) {
65
65
  return content.errorMessage;
66
66
  }
@@ -27,7 +27,7 @@ export class CheckboxField {
27
27
  */
28
28
  this.checkboxLabelLink = "https://example.com";
29
29
  /**
30
- * @uiName Checkbox label link text
30
+ * @uiName Checkbox label link lext
31
31
  */
32
32
  this.checkboxLabelLinkText = "Terms and Conditions";
33
33
  /**
@@ -60,6 +60,7 @@ export class CheckboxField {
60
60
  return (h(CheckboxFieldView, { states: states, content: content, callbacks: callbacks }));
61
61
  }
62
62
  static get is() { return "sqm-checkbox-field"; }
63
+ static get encapsulation() { return "shadow"; }
63
64
  static get properties() { return {
64
65
  "checkboxName": {
65
66
  "type": "string",
@@ -141,7 +142,7 @@ export class CheckboxField {
141
142
  "optional": true,
142
143
  "docs": {
143
144
  "tags": [{
144
- "text": "Checkbox label link text",
145
+ "text": "Checkbox label link lext",
145
146
  "name": "uiName"
146
147
  }],
147
148
  "text": ""
@@ -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": "string",
30
+ "mutable": false,
31
+ "complexType": {
32
+ "original": "string",
33
+ "resolved": "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
+ }
@@ -2301,7 +2301,7 @@ function CheckboxFieldView(props) {
2301
2301
  h("sl-checkbox", Object.assign({ exportparts: "label: input-label, base: input-base", name: `/${content.checkboxName}`, checked: states.checked, "onSl-change": (e) => {
2302
2302
  e.target.value = e.target.checked;
2303
2303
  callbacks.setChecked(e.target.value);
2304
- } }, (!content.checkboxOptional ? { required: true } : []), { disabled: ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.loading) || ((_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.disabled), validationError: ({ value }) => {
2304
+ } }, (!content.checkboxOptional ? { required: false } : []), { disabled: ((_b = states.registrationFormState) === null || _b === void 0 ? void 0 : _b.loading) || ((_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.disabled), validationError: ({ value }) => {
2305
2305
  if (!value && !content.checkboxOptional) {
2306
2306
  return content.errorMessage;
2307
2307
  }