@openlettermarketing/olc-react-sdk 2.1.6-beta.3 → 2.1.6-beta.4

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.
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const CheckboxChecked: (props: any) => React.JSX.Element;
3
+ export default CheckboxChecked;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const CheckboxUnchecked: (props: any) => React.JSX.Element;
3
+ export default CheckboxUnchecked;
@@ -18,6 +18,7 @@ interface DialogProps {
18
18
  currentTheme?: string | null | undefined;
19
19
  isQRCode?: boolean;
20
20
  hideButtons?: boolean;
21
+ submitDisabled?: boolean;
21
22
  }
22
23
  declare const DialogV2: React.FC<DialogProps>;
23
24
  export default DialogV2;
@@ -16,6 +16,7 @@ interface DialogProps {
16
16
  children?: ReactNode;
17
17
  isGallery?: boolean;
18
18
  currentTheme?: string | null | undefined;
19
+ submitDisabled?: boolean;
19
20
  }
20
21
  declare const Dialog: React.FC<DialogProps>;
21
22
  export default Dialog;
@@ -6,7 +6,7 @@ interface FieldValidationModalProps {
6
6
  currentTheme?: string | null | undefined;
7
7
  loading?: boolean;
8
8
  handleClose: () => void;
9
- handleContinue: () => void;
9
+ handleContinue: (acknowledged: boolean) => void;
10
10
  }
11
11
  declare const FieldValidationModal: React.FC<FieldValidationModalProps>;
12
12
  export default FieldValidationModal;
@@ -139,7 +139,8 @@ export declare const MESSAGES: {
139
139
  readonly FIELD_VALIDATION: {
140
140
  readonly TITLE: "Invalid Fields";
141
141
  readonly HEADING: "The following fields are not recognized";
142
- readonly DESCRIPTION: (fieldNames: string) => string;
142
+ readonly DESCRIPTION: "The following field(s) used in this template are not recognized by the system. You can save the template as is, but these fields will not populate with data. To resolve this, remove or replace them with valid field names.";
143
+ readonly ACKNOWLEDGE_LABEL: "I understand that saving now will preserve these invalid fields, but they will not be populated with data.";
143
144
  readonly CONTINUE_BUTTON: "Continue Saving";
144
145
  readonly CANCEL_BUTTON: "Cancel";
145
146
  };
@@ -1 +1 @@
1
- export const SDK_VERSION: "2.1.6-beta.3";
1
+ export const SDK_VERSION: "2.1.6-beta.4";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openlettermarketing/olc-react-sdk",
3
3
  "private": false,
4
- "version": "2.1.6-beta.3",
4
+ "version": "2.1.6-beta.4",
5
5
  "type": "module",
6
6
  "description": "Simplify template builder integration for any product.",
7
7
  "main": "build/index.js",
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+
3
+ const CheckboxChecked = (props: any) => {
4
+ const { fill = 'var(--primary-color)' } = props;
5
+
6
+ return (
7
+ <svg width="18" height="18" viewBox="0 0 14 15" fill="none" xmlns="http://www.w3.org/2000/svg">
8
+ <rect y="0.5" width="14" height="14" rx="2" fill={fill} />
9
+ <g clipPath="url(#clip0_checkbox_checked)">
10
+ <path
11
+ d="M11.7909 4.97078C11.5124 4.69194 11.0602 4.69212 10.7814 4.97078L6.23808 9.51428L4.21877 7.49498C3.93994 7.21615 3.48796 7.21615 3.20912 7.49498C2.93029 7.77381 2.93029 8.2258 3.20912 8.50463L5.73315 11.0287C5.87248 11.168 6.05518 11.2378 6.23789 11.2378C6.4206 11.2378 6.60347 11.1682 6.7428 11.0287L11.7909 5.98041C12.0697 5.70177 12.0697 5.24959 11.7909 4.97078Z"
12
+ fill="white"
13
+ />
14
+ </g>
15
+ <defs>
16
+ <clipPath id="clip0_checkbox_checked">
17
+ <rect width="9" height="9" fill="white" transform="translate(3 3.5)" />
18
+ </clipPath>
19
+ </defs>
20
+ </svg>
21
+ );
22
+ };
23
+
24
+ export default CheckboxChecked;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+
3
+ const CheckboxUnchecked = (props: any) => {
4
+ const { stroke = '#303030' } = props;
5
+
6
+ return (
7
+ <svg width="18" height="18" viewBox="0 0 14 15" fill="none" xmlns="http://www.w3.org/2000/svg">
8
+ <rect x="0.25" y="0.75" width="13.5" height="13.5" rx="1.75" stroke={stroke} strokeWidth="0.5" />
9
+ </svg>
10
+ );
11
+ };
12
+
13
+ export default CheckboxUnchecked;
@@ -28,6 +28,7 @@ interface DialogProps {
28
28
  currentTheme?: string | null | undefined;
29
29
  isQRCode?: boolean;
30
30
  hideButtons?: boolean;
31
+ submitDisabled?: boolean;
31
32
  }
32
33
 
33
34
  const buttonStyles: CSSProperties = {
@@ -82,7 +83,8 @@ const DialogV2: React.FC<DialogProps> = ({
82
83
  isGallery = false,
83
84
  currentTheme = "default",
84
85
  isQRCode = false,
85
- hideButtons = false
86
+ hideButtons = false,
87
+ submitDisabled = false,
86
88
  }) => {
87
89
  const contentAdjust = submitText.length > 6 ? "fit-content" : "100px";
88
90
 
@@ -164,7 +166,7 @@ const DialogV2: React.FC<DialogProps> = ({
164
166
  <div className="modal-footer">
165
167
  {(!isGallery || isQRCode) &&
166
168
  <>
167
- <button onClick={onSubmit} disabled={loading}>
169
+ <button onClick={onSubmit} disabled={loading || submitDisabled}>
168
170
  {loading ? <CircularProgress style={progressStyles} /> : submitText}
169
171
  </button>
170
172
  <button onClick={onCancel}>
@@ -208,7 +210,7 @@ const DialogV2: React.FC<DialogProps> = ({
208
210
  <div className="confirm-modal-footer">
209
211
  {!isGallery && !hideButtons &&
210
212
  <>
211
- <button onClick={onSubmit} disabled={loading}>
213
+ <button onClick={onSubmit} disabled={loading || submitDisabled}>
212
214
  {loading ? <CircularProgress style={progressStyles} /> : submitText}
213
215
  </button>
214
216
  <button onClick={onCancel}>
@@ -249,9 +249,14 @@
249
249
  justify-content: center;
250
250
  align-items: center;
251
251
 
252
- &:hover{
252
+ &:hover:not(:disabled){
253
253
  background-color: var(--primary-color-btn-hover);
254
254
  }
255
+
256
+ &:disabled{
257
+ opacity: 0.45;
258
+ cursor: not-allowed;
259
+ }
255
260
  }
256
261
 
257
262
  &:last-child{
@@ -28,6 +28,7 @@ interface DialogProps {
28
28
  children?: ReactNode;
29
29
  isGallery?: boolean;
30
30
  currentTheme?: string | null | undefined;
31
+ submitDisabled?: boolean;
31
32
  }
32
33
 
33
34
  const buttonStyles: CSSProperties = {
@@ -73,7 +74,8 @@ const Dialog: React.FC<DialogProps> = ({
73
74
  submitText = "",
74
75
  children = [],
75
76
  isGallery = false,
76
- currentTheme = "default"
77
+ currentTheme = "default",
78
+ submitDisabled = false,
77
79
  }) => {
78
80
  const contentAdjust = submitText.length > 6 ? "fit-content" : "100px";
79
81
 
@@ -170,7 +172,7 @@ const Dialog: React.FC<DialogProps> = ({
170
172
  <Button
171
173
  style={{ ...buttonStyles, border: 'none', maxWidth: contentAdjust }}
172
174
  onClick={onSubmit}
173
- disabled={loading}
175
+ disabled={loading || submitDisabled}
174
176
  >
175
177
  {loading ? <CircularProgress style={progressStyles} /> : submitText}
176
178
  </Button>
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useState, useEffect } from 'react';
2
2
 
3
3
  // Utils
4
4
  import { MESSAGES } from '../../../utils/message';
@@ -9,6 +9,10 @@ import DialogV2 from '../../GenericUIBlocks/Dialog/V2';
9
9
 
10
10
  // Icons
11
11
  import Warning from '../../../assets/images/modal-icons/warning';
12
+ // @ts-ignore
13
+ import CheckboxChecked from '../../../assets/images/modal-icons/checkbox-checked';
14
+ // @ts-ignore
15
+ import CheckboxUnchecked from '../../../assets/images/modal-icons/checkbox-unchecked';
12
16
 
13
17
  // Styles
14
18
  import './styles.scss';
@@ -19,7 +23,7 @@ interface FieldValidationModalProps {
19
23
  currentTheme?: string | null | undefined;
20
24
  loading?: boolean;
21
25
  handleClose: () => void;
22
- handleContinue: () => void;
26
+ handleContinue: (acknowledged: boolean) => void;
23
27
  }
24
28
 
25
29
  const modalStyles = {
@@ -41,8 +45,34 @@ const FieldValidationModal: React.FC<FieldValidationModalProps> = ({
41
45
  handleClose,
42
46
  handleContinue,
43
47
  }) => {
44
- const fieldNames = [...invalidFields].map(item => `"${item}"`).join(', ');
45
- const description = MESSAGES.TEMPLATE.FIELD_VALIDATION.DESCRIPTION(fieldNames);
48
+ const [acknowledged, setAcknowledged] = useState(false);
49
+
50
+ // Reset checkbox whenever the modal opens with a new set of fields
51
+ useEffect(() => {
52
+ if (open) {
53
+ setAcknowledged(false);
54
+ }
55
+ }, [open]);
56
+
57
+ const content = (
58
+ <div className="field-validation-content">
59
+ <p className="field-validation-description">
60
+ {MESSAGES.TEMPLATE.FIELD_VALIDATION.DESCRIPTION}
61
+ </p>
62
+ <ol className="field-validation-list">
63
+ {invalidFields.map((field, index) => (
64
+ <li key={index}>{field}</li>
65
+ ))}
66
+ </ol>
67
+ <label
68
+ className="field-validation-acknowledge"
69
+ onClick={() => setAcknowledged((prev) => !prev)}
70
+ >
71
+ {acknowledged ? <CheckboxChecked /> : <CheckboxUnchecked />}
72
+ {MESSAGES.TEMPLATE.FIELD_VALIDATION.ACKNOWLEDGE_LABEL}
73
+ </label>
74
+ </div>
75
+ );
46
76
 
47
77
  return currentTheme === 'v2' ? (
48
78
  <DialogV2
@@ -53,14 +83,16 @@ const FieldValidationModal: React.FC<FieldValidationModalProps> = ({
53
83
  handleClose={handleClose}
54
84
  title={MESSAGES.TEMPLATE.FIELD_VALIDATION.TITLE}
55
85
  subHeading=""
56
- description={description}
57
86
  currentTheme="v2"
58
87
  isGallery={false}
59
- onSubmit={handleContinue}
88
+ onSubmit={() => handleContinue(acknowledged)}
60
89
  submitText={MESSAGES.TEMPLATE.FIELD_VALIDATION.CONTINUE_BUTTON}
90
+ submitDisabled={!acknowledged}
61
91
  onCancel={handleClose}
62
92
  cancelText={MESSAGES.TEMPLATE.FIELD_VALIDATION.CANCEL_BUTTON}
63
- />
93
+ >
94
+ {content}
95
+ </DialogV2>
64
96
  ) : (
65
97
  <Dialog
66
98
  icon={<Warning fill="var(--primary-color)" />}
@@ -70,12 +102,14 @@ const FieldValidationModal: React.FC<FieldValidationModalProps> = ({
70
102
  handleClose={handleClose}
71
103
  title={MESSAGES.TEMPLATE.FIELD_VALIDATION.TITLE}
72
104
  subHeading=""
73
- description={description}
74
- onSubmit={handleContinue}
105
+ onSubmit={() => handleContinue(acknowledged)}
75
106
  submitText={MESSAGES.TEMPLATE.FIELD_VALIDATION.CONTINUE_BUTTON}
107
+ submitDisabled={!acknowledged}
76
108
  onCancel={handleClose}
77
109
  cancelText={MESSAGES.TEMPLATE.FIELD_VALIDATION.CANCEL_BUTTON}
78
- />
110
+ >
111
+ {content}
112
+ </Dialog>
79
113
  );
80
114
  };
81
115
 
@@ -1,39 +1,48 @@
1
1
  .field-validation-content {
2
- margin-top: 20px;
2
+ width: 100%;
3
+ margin-top: 12px;
4
+ text-align: left;
3
5
  }
4
6
 
5
- .field-validation-list {
6
- max-height: 300px;
7
- overflow-y: auto;
8
- padding: 10px;
9
- background-color: #f9f9f9;
10
- border-radius: 4px;
7
+ .field-validation-description {
8
+ font-size: 16px;
9
+ font-weight: 400;
10
+ color: var(--text-color);
11
+ line-height: 20px;
12
+ font-family: var(--font-family);
13
+ margin: 0 0 12px 0;
14
+ padding: 0;
11
15
  }
12
16
 
13
- .field-validation-item {
14
- margin-bottom: 15px;
15
- padding: 12px;
16
- background-color: #fff;
17
- border-left: 3px solid #ff9800;
18
- border-radius: 4px;
19
-
20
- .field-name {
21
- font-weight: 600;
22
- color: #333;
23
- margin-bottom: 5px;
24
- font-family: 'Courier New', monospace;
25
- font-size: 14px;
26
- }
27
-
28
- .field-error {
29
- color: #666;
30
- font-size: 13px;
31
- margin-bottom: 4px;
17
+ .field-validation-list {
18
+ margin: 0 0 16px 0;
19
+ padding-left: 20px;
20
+
21
+ li {
22
+ font-size: 16px;
23
+ font-weight: 400;
24
+ color: var(--text-color);
25
+ line-height: 20px;
26
+ margin-bottom: 6px;
27
+ word-break: break-all;
28
+ font-family: var(--font-family);
32
29
  }
33
-
34
- .field-location {
35
- color: #999;
36
- font-size: 12px;
37
- font-style: italic;
30
+ }
31
+
32
+ .field-validation-acknowledge {
33
+ display: flex;
34
+ align-items: flex-start;
35
+ gap: 8px;
36
+ font-size: 16px;
37
+ font-weight: 400;
38
+ color: var(--text-color);
39
+ line-height: 20px;
40
+ cursor: pointer;
41
+ user-select: none;
42
+ font-family: var(--font-family);
43
+
44
+ svg {
45
+ flex-shrink: 0;
46
+ margin-top: 1px;
38
47
  }
39
48
  }
@@ -430,9 +430,10 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
430
430
  }
431
431
  };
432
432
 
433
- const handleSave = async () => {
433
+ const handleSave = async (invalidFieldsAcknowledged: boolean = false) => {
434
434
  try {
435
435
  const formData = new FormData();
436
+ formData.append('invalidFieldsAcknowledged', String(invalidFieldsAcknowledged));
436
437
  const allFields = [
437
438
  ...defaultFields,
438
439
  ...customFields,
@@ -576,9 +577,9 @@ const TopNavigation: React.FC<TopNavigationProps> = ({
576
577
  }
577
578
  };
578
579
 
579
- const handleContinueAnyway = () => {
580
+ const handleContinueAnyway = (acknowledged: boolean) => {
580
581
  setIsShowModel((prev) => ({ ...prev, loading: true }));
581
- handleSave();
582
+ handleSave(acknowledged);
582
583
  };
583
584
 
584
585
  const handleChangeModel = (
@@ -146,7 +146,8 @@ export const MESSAGES = {
146
146
  FIELD_VALIDATION: {
147
147
  TITLE: "Invalid Fields",
148
148
  HEADING: "The following fields are not recognized",
149
- DESCRIPTION: (fieldNames: string) => `The following field(s) ${fieldNames} are not recognized.`,
149
+ DESCRIPTION: "The following field(s) used in this template are not recognized by the system. You can save the template as is, but these fields will not populate with data. To resolve this, remove or replace them with valid field names.",
150
+ ACKNOWLEDGE_LABEL: "I understand that saving now will preserve these invalid fields, but they will not be populated with data.",
150
151
  CONTINUE_BUTTON: "Continue Saving",
151
152
  CANCEL_BUTTON: "Cancel",
152
153
  },
package/version.js CHANGED
@@ -1 +1 @@
1
- export const SDK_VERSION = '2.1.6-beta.3';
1
+ export const SDK_VERSION = '2.1.6-beta.4';