@zengenti/contensis-react-base 3.2.1-beta.6 → 3.2.1-beta.8

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/README.md CHANGED
@@ -126,6 +126,13 @@ https://www.conventionalcommits.org/en/v1.0.0/#summary
126
126
 
127
127
  # Changelog
128
128
 
129
+ #### 3.2.1 (2024-06-24)
130
+
131
+ ##### Bug Fixes
132
+
133
+ * use `cms` uri in user-based operations for DR scenario (135ccb54)
134
+ * update CachedDeliveryAPI to access the 'fields' query param (#11) (1110bf43)
135
+
129
136
  #### 3.2.0 (2024-04-26)
130
137
 
131
138
  ##### New Features
package/cjs/forms.js CHANGED
@@ -556,31 +556,35 @@ const doCreateMessage = (type, minLength, maxLength, currentLength, defaultLangu
556
556
  }
557
557
  };
558
558
  const getFieldType = field => {
559
- var _field$editor, _field$editor$propert;
559
+ var _editor$properties, _editor$properties2;
560
560
  if (!field) return null;
561
- if (field.id === 'country' && field.dataType === 'string') {
562
- return 'country';
563
- }
564
- if (field.dataType === 'string' && field.editor && field.editor.id === 'multiline') {
565
- return 'textarea';
566
- } else if (field.dataType === 'string' && field.editor && field.editor.id === 'list-dropdown') {
567
- return 'dropdown';
568
- } else if (field.dataType === 'stringArray' || field.dataType === 'boolean') {
569
- return 'checkbox';
570
- } else if (field.dataType === 'string' && field.validations && field.validations.allowedValues) {
571
- return 'radio';
572
- } else if (field.dataType === 'integer') {
573
- return 'number';
574
- } else if (field.dataType === 'dateTime') {
575
- return 'date';
576
- } else if (field.dataFormat === 'daterange') {
577
- return 'dateRange';
578
- } else if (field.dataFormat === 'entry') {
579
- return 'entryPicker';
561
+ const {
562
+ dataType,
563
+ dataFormat,
564
+ editor,
565
+ validations,
566
+ id,
567
+ groupId
568
+ } = field || {};
569
+ if (groupId === 'private' || groupId === 'settings') return 'hidden';
570
+ if (editor !== null && editor !== void 0 && (_editor$properties = editor.properties) !== null && _editor$properties !== void 0 && _editor$properties.readOnly && dataFormat !== 'quote') return 'hidden';
571
+ if (dataFormat === 'quote') return 'content';
572
+ if (dataFormat === 'quote' && editor !== null && editor !== void 0 && (_editor$properties2 = editor.properties) !== null && _editor$properties2 !== void 0 && _editor$properties2.readOnly) return 'content';
573
+ if (dataType === 'string') {
574
+ if ((editor === null || editor === void 0 ? void 0 : editor.id) === 'multiline') return 'textarea';
575
+ if ((editor === null || editor === void 0 ? void 0 : editor.id) === 'list-dropdown') return 'dropdown';
576
+ if (validations !== null && validations !== void 0 && validations.allowedValues) return 'radio';
577
+ if (id === 'country') return 'country';
578
+ return 'textfield'; // Default string type
580
579
  }
581
- if (field.dataFormat === 'quote') return 'content';else if (field !== null && field !== void 0 && (_field$editor = field.editor) !== null && _field$editor !== void 0 && (_field$editor$propert = _field$editor.properties) !== null && _field$editor$propert !== void 0 && _field$editor$propert.readOnly || (field === null || field === void 0 ? void 0 : field.groupId) === 'private' || (field === null || field === void 0 ? void 0 : field.groupId) === 'settings') {
582
- return 'hidden';
583
- } else return 'textfield';
580
+
581
+ if (dataType === 'stringArray' || dataType === 'boolean') return 'checkbox';
582
+ if (dataType === 'integer') return 'number';
583
+ if (dataType === 'dateTime') return 'date';
584
+ if (dataFormat === 'daterange') return 'dateRange';
585
+ if (dataFormat === 'entry') return 'entryPicker';
586
+ if (groupId === 'private' || groupId === 'settings') return 'hidden';
587
+ return 'textfield'; // Default fallback
584
588
  };
585
589
 
586
590
  const sagas = [effects.takeEvery(SUBMIT_FORM_SUCCESS, onFormSuccess), effects.takeEvery(SUBMIT_FORM_FOR_VALIDATION, doValidateForm), effects.takeEvery(SUBMIT_FORM, onSubmitForm), effects.takeEvery(SET_FORM_ID, doFetchForm),
@@ -1020,7 +1024,69 @@ CharacterLimit.propTypes = {
1020
1024
  useDefaultTheme: PropTypes__default["default"].bool
1021
1025
  };
1022
1026
 
1023
- // import Markdown from 'markdown-to-jsx';
1027
+ const doParse = markdown => {
1028
+ const LINES = markdown.split('\n');
1029
+ const ELEMENTS = [];
1030
+ let inList = false; // Track if we are currently inside a list
1031
+ let inNestedList = false; // Track if we are inside a nested list
1032
+
1033
+ LINES.forEach((LINE, INDEX) => {
1034
+ LINE = LINE.trim(); // Trim whitespace from the beginning and end of the line
1035
+
1036
+ if (LINE.startsWith('* ')) {
1037
+ // Top-level list item
1038
+ if (!inList) {
1039
+ ELEMENTS.push('<ul>'); // Start the outermost list
1040
+ inList = true;
1041
+ }
1042
+ if (inNestedList) {
1043
+ // Close the previous nested list
1044
+ ELEMENTS.push('</ul>');
1045
+ inNestedList = false;
1046
+ }
1047
+ ELEMENTS.push(`<li key=${INDEX}>${LINE.substring(2)}</li>`);
1048
+ } else if (LINE.startsWith('**')) {
1049
+ // Nested list item
1050
+ if (!inNestedList) {
1051
+ ELEMENTS.push('<ul>'); // Start a nested list
1052
+ inNestedList = true;
1053
+ }
1054
+ ELEMENTS.push(`<li key=${INDEX}>${LINE.substring(2)}</li>`);
1055
+ } else {
1056
+ // Non-list item
1057
+ if (inList) {
1058
+ if (inNestedList) {
1059
+ ELEMENTS.push('</ul>'); // Close any open nested list
1060
+ inNestedList = false;
1061
+ }
1062
+ ELEMENTS.push('</ul>'); // Close the outermost list
1063
+ inList = false;
1064
+ }
1065
+ ELEMENTS.push(`<span key=${INDEX}>${LINE}</span>`);
1066
+ }
1067
+ });
1068
+ if (inNestedList) {
1069
+ ELEMENTS.push('</ul>'); // Close any remaining open nested list
1070
+ } else if (inList) {
1071
+ ELEMENTS.push('</ul>'); // Close the outermost list
1072
+ }
1073
+
1074
+ return ELEMENTS.join(''); // Join all elements into a single string
1075
+ };
1076
+
1077
+ const MarkdownRenderer = ({
1078
+ className,
1079
+ markdown
1080
+ }) => {
1081
+ if (!markdown) return null;
1082
+ const elements = doParse(markdown);
1083
+ return /*#__PURE__*/React__default["default"].createElement("div", {
1084
+ className: className,
1085
+ dangerouslySetInnerHTML: {
1086
+ __html: elements
1087
+ }
1088
+ });
1089
+ };
1024
1090
 
1025
1091
  const TextfieldStyled = styled__default["default"].div.withConfig({
1026
1092
  displayName: "textfield__TextfieldStyled",
@@ -1121,7 +1187,10 @@ const Textfield = ({
1121
1187
  }, /*#__PURE__*/React__default["default"].createElement("path", {
1122
1188
  fill: "#333",
1123
1189
  d: "m2 8 4.418 4.667L14 4.659l-1.246-1.326-6.336 6.692-3.18-3.332L2 8Z"
1124
- }))), id === 'password' && /*#__PURE__*/React__default["default"].createElement("button", {
1190
+ }))), instructions && /*#__PURE__*/React__default["default"].createElement(MarkdownRenderer, {
1191
+ className: "text-field__input--markdown",
1192
+ markdown: instructions
1193
+ }), id === 'password' && /*#__PURE__*/React__default["default"].createElement("button", {
1125
1194
  className: "text-input__button--pw",
1126
1195
  type: "button",
1127
1196
  onClick: () => setVisible(!isVisible),
@@ -1135,8 +1204,8 @@ const Textfield = ({
1135
1204
  }, /*#__PURE__*/React__default["default"].createElement("path", {
1136
1205
  d: "M13.3536 2.35355C13.5488 2.15829 13.5488 1.84171 13.3536 1.64645C13.1583 1.45118 12.8417 1.45118 12.6464 1.64645L10.6828 3.61012C9.70652 3.21671 8.63759 3 7.5 3C4.30786 3 1.65639 4.70638 0.0760002 7.23501C-0.0253338 7.39715 -0.0253334 7.60288 0.0760014 7.76501C0.902945 9.08812 2.02314 10.1861 3.36061 10.9323L1.64645 12.6464C1.45118 12.8417 1.45118 13.1583 1.64645 13.3536C1.84171 13.5488 2.15829 13.5488 2.35355 13.3536L4.31723 11.3899C5.29348 11.7833 6.36241 12 7.5 12C10.6921 12 13.3436 10.2936 14.924 7.76501C15.0253 7.60288 15.0253 7.39715 14.924 7.23501C14.0971 5.9119 12.9769 4.81391 11.6394 4.06771L13.3536 2.35355ZM9.90428 4.38861C9.15332 4.1361 8.34759 4 7.5 4C4.80285 4 2.52952 5.37816 1.09622 7.50001C1.87284 8.6497 2.89609 9.58106 4.09974 10.1931L9.90428 4.38861ZM5.09572 10.6114L10.9003 4.80685C12.1039 5.41894 13.1272 6.35031 13.9038 7.50001C12.4705 9.62183 10.1971 11 7.5 11C6.65241 11 5.84668 10.8639 5.09572 10.6114Z",
1137
1206
  fill: "currentColor",
1138
- "fill-rule": "evenodd",
1139
- "clip-rule": "evenodd"
1207
+ fillRule: "evenodd",
1208
+ clipRule: "evenodd"
1140
1209
  })) : /*#__PURE__*/React__default["default"].createElement("svg", {
1141
1210
  width: "15",
1142
1211
  height: "15",
@@ -1146,8 +1215,8 @@ const Textfield = ({
1146
1215
  }, /*#__PURE__*/React__default["default"].createElement("path", {
1147
1216
  d: "M7.5 11C4.80285 11 2.52952 9.62184 1.09622 7.50001C2.52952 5.37816 4.80285 4 7.5 4C10.1971 4 12.4705 5.37816 13.9038 7.50001C12.4705 9.62183 10.1971 11 7.5 11ZM7.5 3C4.30786 3 1.65639 4.70638 0.0760002 7.23501C-0.0253338 7.39715 -0.0253334 7.60288 0.0760014 7.76501C1.65639 10.2936 4.30786 12 7.5 12C10.6921 12 13.3436 10.2936 14.924 7.76501C15.0253 7.60288 15.0253 7.39715 14.924 7.23501C13.3436 4.70638 10.6921 3 7.5 3ZM7.5 9.5C8.60457 9.5 9.5 8.60457 9.5 7.5C9.5 6.39543 8.60457 5.5 7.5 5.5C6.39543 5.5 5.5 6.39543 5.5 7.5C5.5 8.60457 6.39543 9.5 7.5 9.5Z",
1148
1217
  fill: "currentColor",
1149
- "fill-rule": "evenodd",
1150
- "clip-rule": "evenodd"
1218
+ fillRule: "evenodd",
1219
+ clipRule: "evenodd"
1151
1220
  }))));
1152
1221
  };
1153
1222
  Textfield.propTypes = {
@@ -5128,8 +5197,6 @@ const CountrySelectStyled = styled__default["default"].div.withConfig({
5128
5197
  return styled.css(["display:flex;flex-direction:column;--semantic-type-1:#01010c;--semantic-background-1:#fff;--semantic-active-background-1:#efefef;--semantic-border-1:#949494;.input__label{margin-bottom:4px;}.input__wrapper{position:relative;}.input__listbox{display:none;position:absolute;top:40px;left:0;width:100%;padding:8px;background:var(--semantic-background-1);z-index:99;text-align:left;overflow-y:auto;border:1px solid var(--semantic-border-1);max-height:400px;}.input__listbox.open{display:block;}.input__listbox .option{padding:8px;cursor:default;display:flex;align-items:center;border:none;width:100%;}.input__listbox .option.selected{color:var(--semantic-type-1);background-color:var(--semantic-active-background-1);}.input__listbox .option.active{color:var(--semantic-type-1);background-color:var(--semantic-active-background-1);}"]);
5129
5198
  });
5130
5199
 
5131
- // import Markdown from 'markdown-to-jsx';
5132
-
5133
5200
  const FormComposer = ({
5134
5201
  fields,
5135
5202
  formData,
@@ -5306,7 +5373,7 @@ const FormComposer = ({
5306
5373
  name,
5307
5374
  editor
5308
5375
  } = field || {};
5309
- editor === null || editor === void 0 ? void 0 : (_editor$instructions = editor.instructions) === null || _editor$instructions === void 0 ? void 0 : _editor$instructions[defaultLanguage];
5376
+ const instructions = editor === null || editor === void 0 ? void 0 : (_editor$instructions = editor.instructions) === null || _editor$instructions === void 0 ? void 0 : _editor$instructions[defaultLanguage];
5310
5377
  return /*#__PURE__*/React__default["default"].createElement("span", {
5311
5378
  className: "form__content",
5312
5379
  "data-form": "title",
@@ -5316,7 +5383,10 @@ const FormComposer = ({
5316
5383
  key: `${field.id}-${idx}`
5317
5384
  }, /*#__PURE__*/React__default["default"].createElement("span", {
5318
5385
  className: "form__content--title"
5319
- }, name === null || name === void 0 ? void 0 : name[defaultLanguage]));
5386
+ }, name === null || name === void 0 ? void 0 : name[defaultLanguage]), instructions && /*#__PURE__*/React__default["default"].createElement(MarkdownRenderer, {
5387
+ className: "form__content--markdown",
5388
+ markdown: instructions
5389
+ }));
5320
5390
  }
5321
5391
  }
5322
5392
  });
@@ -5487,7 +5557,7 @@ const Form = ({
5487
5557
  useDefaultTheme: useDefaultTheme,
5488
5558
  entries: entries,
5489
5559
  setDateRangeValues: _setDateRangeValues
5490
- }), pagingInfo.pageCount >= 2 && /*#__PURE__*/React__default["default"].createElement("div", {
5560
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
5491
5561
  className: "form__btns"
5492
5562
  }, pagingInfo.pageIndex > 0 && /*#__PURE__*/React__default["default"].createElement(Button, {
5493
5563
  className: "form__btn--prev",
@@ -5550,7 +5620,9 @@ const Form = ({
5550
5620
  errors: errors,
5551
5621
  useDefaultTheme: useDefaultTheme,
5552
5622
  entries: entries
5553
- }), /*#__PURE__*/React__default["default"].createElement(Button, {
5623
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
5624
+ className: "form__btns"
5625
+ }, /*#__PURE__*/React__default["default"].createElement(Button, {
5554
5626
  className: "form__btn--submit",
5555
5627
  loading: status === null || status === void 0 ? void 0 : status.isSubmitting,
5556
5628
  text: (settings === null || settings === void 0 ? void 0 : settings.submitButtonText) || "Submit",
@@ -5560,7 +5632,7 @@ const Form = ({
5560
5632
  if (onCustomSubmit) onCustomSubmit();
5561
5633
  },
5562
5634
  useDefaultTheme: useDefaultTheme
5563
- })), (status === null || status === void 0 ? void 0 : status.isLoading) && !(status !== null && status !== void 0 && status.hasSuccess) && /*#__PURE__*/React__default["default"].createElement(Loader, {
5635
+ }))), (status === null || status === void 0 ? void 0 : status.isLoading) && !(status !== null && status !== void 0 && status.hasSuccess) && /*#__PURE__*/React__default["default"].createElement(Loader, {
5564
5636
  className: "loading",
5565
5637
  height: 24,
5566
5638
  width: 24,