@integry/sdk 4.6.64 → 4.6.66

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integry/sdk",
3
- "version": "4.6.64",
3
+ "version": "4.6.66",
4
4
  "description": "Integry SDK",
5
5
  "main": "dist/umd/index.umd.js",
6
6
  "module": "dist/esm/index.csm.js",
@@ -359,7 +359,8 @@ const FieldDropdown = (props: FieldMenuProps) => {
359
359
  <a
360
360
  className=${styles.optionsRefresh}
361
361
  href="#"
362
- onclick=${() => {
362
+ onclick=${(e: Event) => {
363
+ e.preventDefault();
363
364
  if (handleRefreshClick) {
364
365
  setisLoadingOptions(true);
365
366
  handleRefreshClick(() =>
@@ -1812,7 +1812,22 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1812
1812
  ><//>
1813
1813
  </div>
1814
1814
  `;
1815
- case 'DYNAMIC':
1815
+ case 'DYNAMIC': {
1816
+ let fieldVal = null;
1817
+ if (this.props.onFieldChangeCallback) {
1818
+ if (
1819
+ Object.prototype.hasOwnProperty.call(
1820
+ this.state.dynamicFieldsData || {},
1821
+ el.activity_field?.machine_name || '',
1822
+ )
1823
+ ) {
1824
+ fieldVal = this.state.dynamicFieldsData[
1825
+ el.activity_field?.machine_name || ''
1826
+ ];
1827
+ } else {
1828
+ fieldVal = el.default_value;
1829
+ }
1830
+ }
1816
1831
  return html`
1817
1832
  <div
1818
1833
  key=${el.id}
@@ -1824,6 +1839,7 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1824
1839
  <${DynamicField}
1825
1840
  stepId=${selectedStep.id}
1826
1841
  dynamicField=${el}
1842
+ objectValue=${fieldVal}
1827
1843
  endpointData=${JSON.stringify({
1828
1844
  authorization_id:
1829
1845
  (this.props.stepMapping &&
@@ -1867,9 +1883,28 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1867
1883
  .refreshRootStepData}
1868
1884
  parentFieldChanged=${this.state
1869
1885
  .parentFieldChanged}
1886
+ onChangeCallback=${this.props
1887
+ .onFieldChangeCallback
1888
+ ? (val: any) => {
1889
+ if (
1890
+ this.props.onFieldChangeCallback
1891
+ ) {
1892
+ this.onFieldChange({
1893
+ stepId: step.id,
1894
+ fieldId: el.id,
1895
+ value: val,
1896
+ isRequired: el.is_required,
1897
+ machineName:
1898
+ el.activity_field
1899
+ ?.machine_name,
1900
+ });
1901
+ }
1902
+ }
1903
+ : null}
1870
1904
  />
1871
1905
  </div>
1872
1906
  `;
1907
+ }
1873
1908
  case 'SECTION':
1874
1909
  return html`
1875
1910
  <div
@@ -1974,7 +2009,22 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1974
2009
  />
1975
2010
  </div>
1976
2011
  `;
1977
- case 'TEXTAREA':
2012
+ case 'TEXTAREA': {
2013
+ let fieldVal = null;
2014
+ if (this.props.onFieldChangeCallback) {
2015
+ if (
2016
+ Object.prototype.hasOwnProperty.call(
2017
+ this.state.dynamicFieldsData || {},
2018
+ el.activity_field?.machine_name || '',
2019
+ )
2020
+ ) {
2021
+ fieldVal = this.state.dynamicFieldsData[
2022
+ el.activity_field?.machine_name || ''
2023
+ ];
2024
+ } else {
2025
+ fieldVal = el.default_value;
2026
+ }
2027
+ }
1978
2028
  return html`
1979
2029
  <div key=${
1980
2030
  el.id
@@ -1992,6 +2042,7 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
1992
2042
  title=${el.title || el.activity_field?.title}
1993
2043
  description=${elDescription}
1994
2044
  value=${
2045
+ fieldVal ||
1995
2046
  (selectedStepData &&
1996
2047
  selectedStepData[el.id] &&
1997
2048
  selectedStepData[el.id].value &&
@@ -2021,10 +2072,14 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
2021
2072
  passesRegexTest?: boolean,
2022
2073
  ) => {
2023
2074
  if (this.props.onFieldChangeCallback) {
2024
- this.props.onFieldChangeCallback(
2025
- el.activity_field?.machine_name || '',
2026
- val,
2027
- );
2075
+ this.onFieldChange({
2076
+ stepId: step.id,
2077
+ fieldId: el.id,
2078
+ value: val,
2079
+ isRequired: el.is_required,
2080
+ machineName:
2081
+ el.activity_field?.machine_name,
2082
+ });
2028
2083
  } else {
2029
2084
  setStepFieldData({
2030
2085
  stepId: `${step.id}`,
@@ -2080,6 +2135,7 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
2080
2135
  </${ConfigureFieldWrapper}>
2081
2136
  </div>
2082
2137
  `;
2138
+ }
2083
2139
  case 'DATE':
2084
2140
  return html`
2085
2141
  <div
@@ -27,6 +27,8 @@ export type DynamicFieldsProps = {
27
27
  placeHolder?: string;
28
28
  refreshRootStepData?: (callback?: any) => void;
29
29
  parentFieldChanged?: boolean;
30
+ onChangeCallback?: (val: any) => void;
31
+ objectValue?: any;
30
32
  } & StoreType;
31
33
 
32
34
  interface DynamicDataItem {
@@ -52,9 +54,12 @@ const DynamicFields = (props: DynamicFieldsProps) => {
52
54
  placeHolder = '',
53
55
  refreshRootStepData,
54
56
  parentFieldChanged = false,
57
+ onChangeCallback = () => null,
58
+ objectValue = {},
55
59
  } = props;
56
60
  const [dynamicItems, setDynamicItems] = useState<DynamicDataItem[]>([]);
57
61
  const [loading, setLoading] = useState<boolean>(true);
62
+ const [customFieldsData, setCustomFieldsData] = useState<any>(objectValue);
58
63
  const [
59
64
  isErrorOnLoadingCustomFields,
60
65
  setIsErrorOnLoadingCustomFields,
@@ -149,12 +154,22 @@ const DynamicFields = (props: DynamicFieldsProps) => {
149
154
  });
150
155
  });
151
156
 
152
- props.setStepMappingData({
153
- stepId,
154
- fieldId: dynamicField.id,
155
- id: machineName,
156
- value: valSubstituded,
157
- });
157
+ if (onChangeCallback && objectValue) {
158
+ const data = {
159
+ ...customFieldsData,
160
+ [machineName]: val,
161
+ };
162
+ setCustomFieldsData(data);
163
+
164
+ onChangeCallback(data);
165
+ } else {
166
+ props.setStepMappingData({
167
+ stepId,
168
+ fieldId: dynamicField.id,
169
+ id: machineName,
170
+ value: valSubstituded,
171
+ });
172
+ }
158
173
  };
159
174
 
160
175
  return html`
@@ -171,10 +186,9 @@ const DynamicFields = (props: DynamicFieldsProps) => {
171
186
  ? props.stepDataMapping[stepId][dynamicField.id]
172
187
  : ({} as { objectValue: Record<string, string | number> });
173
188
  let fieldVal = '';
174
- const parsedVal = ele.objectValue as Record<
175
- string,
176
- string | number
177
- >;
189
+ const parsedVal =
190
+ objectValue ||
191
+ (ele.objectValue as Record<string, string | number>);
178
192
  if (parsedVal && parsedVal[el.id]) {
179
193
  fieldVal = `${parsedVal[el.id]}`;
180
194
  }