@redneckz/wildless-cms-uni-blocks 0.14.896 → 0.14.898

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 (94) hide show
  1. package/bundle/bundle.umd.js +37 -15
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/hooks/useForm/useForm.d.ts +2 -0
  4. package/bundle/retail/components/DraftDialog/utils.d.ts +0 -6
  5. package/bundle/ui-kit/FormField/RefWrapper.d.ts +7 -0
  6. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js +3 -2
  7. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  8. package/dist/hooks/useForm/useForm.d.ts +2 -0
  9. package/dist/hooks/useForm/useForm.js +17 -0
  10. package/dist/hooks/useForm/useForm.js.map +1 -1
  11. package/dist/retail/api/esiaRequestProfile.js +4 -2
  12. package/dist/retail/api/esiaRequestProfile.js.map +1 -1
  13. package/dist/retail/components/DraftDialog/parseDraftTask.js +1 -3
  14. package/dist/retail/components/DraftDialog/parseDraftTask.js.map +1 -1
  15. package/dist/retail/components/DraftDialog/utils.d.ts +0 -6
  16. package/dist/retail/components/DraftDialog/utils.js +1 -7
  17. package/dist/retail/components/DraftDialog/utils.js.map +1 -1
  18. package/dist/ui-kit/FormField/RefWrapper.d.ts +7 -0
  19. package/dist/ui-kit/FormField/RefWrapper.js +16 -0
  20. package/dist/ui-kit/FormField/RefWrapper.js.map +1 -0
  21. package/dist/ui-kit/FormField/getField.js +2 -1
  22. package/dist/ui-kit/FormField/getField.js.map +1 -1
  23. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js +3 -2
  24. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  25. package/lib/components/OfficesAtmsMap/OfficesAtmsMapLayout.d.ts +1 -1
  26. package/lib/hooks/useForm/useForm.d.ts +2 -0
  27. package/lib/hooks/useForm/useForm.js +17 -0
  28. package/lib/hooks/useForm/useForm.js.map +1 -1
  29. package/lib/retail/api/esiaRequestProfile.js +4 -2
  30. package/lib/retail/api/esiaRequestProfile.js.map +1 -1
  31. package/lib/retail/components/DraftDialog/parseDraftTask.js +2 -4
  32. package/lib/retail/components/DraftDialog/parseDraftTask.js.map +1 -1
  33. package/lib/retail/components/DraftDialog/utils.d.ts +0 -6
  34. package/lib/retail/components/DraftDialog/utils.js +0 -6
  35. package/lib/retail/components/DraftDialog/utils.js.map +1 -1
  36. package/lib/ui-kit/FormField/RefWrapper.d.ts +7 -0
  37. package/lib/ui-kit/FormField/RefWrapper.js +14 -0
  38. package/lib/ui-kit/FormField/RefWrapper.js.map +1 -0
  39. package/lib/ui-kit/FormField/getField.js +2 -1
  40. package/lib/ui-kit/FormField/getField.js.map +1 -1
  41. package/mobile/bundle/bundle.umd.js +37 -15
  42. package/mobile/bundle/bundle.umd.min.js +1 -1
  43. package/mobile/bundle/hooks/useForm/useForm.d.ts +2 -0
  44. package/mobile/bundle/retail/components/DraftDialog/utils.d.ts +0 -6
  45. package/mobile/bundle/ui-kit/FormField/RefWrapper.d.ts +7 -0
  46. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js +3 -2
  47. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  48. package/mobile/dist/hooks/useForm/useForm.d.ts +2 -0
  49. package/mobile/dist/hooks/useForm/useForm.js +17 -0
  50. package/mobile/dist/hooks/useForm/useForm.js.map +1 -1
  51. package/mobile/dist/retail/api/esiaRequestProfile.js +4 -2
  52. package/mobile/dist/retail/api/esiaRequestProfile.js.map +1 -1
  53. package/mobile/dist/retail/components/DraftDialog/parseDraftTask.js +1 -3
  54. package/mobile/dist/retail/components/DraftDialog/parseDraftTask.js.map +1 -1
  55. package/mobile/dist/retail/components/DraftDialog/utils.d.ts +0 -6
  56. package/mobile/dist/retail/components/DraftDialog/utils.js +1 -7
  57. package/mobile/dist/retail/components/DraftDialog/utils.js.map +1 -1
  58. package/mobile/dist/ui-kit/FormField/RefWrapper.d.ts +7 -0
  59. package/mobile/dist/ui-kit/FormField/RefWrapper.js +16 -0
  60. package/mobile/dist/ui-kit/FormField/RefWrapper.js.map +1 -0
  61. package/mobile/dist/ui-kit/FormField/getField.js +2 -1
  62. package/mobile/dist/ui-kit/FormField/getField.js.map +1 -1
  63. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js +3 -2
  64. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  65. package/mobile/lib/hooks/useForm/useForm.d.ts +2 -0
  66. package/mobile/lib/hooks/useForm/useForm.js +17 -0
  67. package/mobile/lib/hooks/useForm/useForm.js.map +1 -1
  68. package/mobile/lib/retail/api/esiaRequestProfile.js +4 -2
  69. package/mobile/lib/retail/api/esiaRequestProfile.js.map +1 -1
  70. package/mobile/lib/retail/components/DraftDialog/parseDraftTask.js +2 -4
  71. package/mobile/lib/retail/components/DraftDialog/parseDraftTask.js.map +1 -1
  72. package/mobile/lib/retail/components/DraftDialog/utils.d.ts +0 -6
  73. package/mobile/lib/retail/components/DraftDialog/utils.js +0 -6
  74. package/mobile/lib/retail/components/DraftDialog/utils.js.map +1 -1
  75. package/mobile/lib/ui-kit/FormField/RefWrapper.d.ts +7 -0
  76. package/mobile/lib/ui-kit/FormField/RefWrapper.js +14 -0
  77. package/mobile/lib/ui-kit/FormField/RefWrapper.js.map +1 -0
  78. package/mobile/lib/ui-kit/FormField/getField.js +2 -1
  79. package/mobile/lib/ui-kit/FormField/getField.js.map +1 -1
  80. package/mobile/src/components/ApplicationLeadForm/useInitApplicationLead.ts +3 -2
  81. package/mobile/src/hooks/useForm/useForm.ts +31 -2
  82. package/mobile/src/retail/api/esiaRequestProfile.ts +4 -2
  83. package/mobile/src/retail/components/DraftDialog/parseDraftTask.ts +0 -5
  84. package/mobile/src/retail/components/DraftDialog/utils.ts +0 -7
  85. package/mobile/src/ui-kit/FormField/RefWrapper.tsx +20 -0
  86. package/mobile/src/ui-kit/FormField/getField.tsx +3 -2
  87. package/package.json +1 -1
  88. package/src/components/ApplicationLeadForm/useInitApplicationLead.ts +3 -2
  89. package/src/hooks/useForm/useForm.ts +31 -2
  90. package/src/retail/api/esiaRequestProfile.ts +4 -2
  91. package/src/retail/components/DraftDialog/parseDraftTask.ts +0 -5
  92. package/src/retail/components/DraftDialog/utils.ts +0 -7
  93. package/src/ui-kit/FormField/RefWrapper.tsx +20 -0
  94. package/src/ui-kit/FormField/getField.tsx +3 -2
@@ -1244,6 +1244,7 @@
1244
1244
 
1245
1245
  function useForm(initialState, { resetOnSubmit, formValidator, normalizer, onChange, onSubmit } = {}) {
1246
1246
  const [formState, setFormState] = useNormalizedFormState(initialState, normalizer, onChange);
1247
+ const fieldRefs = useRef(getRefsObject(initialState));
1247
1248
  const [isDirtyForm, { setTrue: markAsDirty, setFalse: markAsClean }] = useBool(false);
1248
1249
  const dirtyFieldsMap = useRef({});
1249
1250
  const [fieldValidatorsMap, { isValid, errors }] = useFormValidator(formState, formValidator);
@@ -1254,6 +1255,12 @@
1254
1255
  const fieldValidator = options?.validator ?? fieldValidatorsMap[fieldName];
1255
1256
  const fieldErrors = isDirty && fieldValidator ? fieldValidator(value) : [];
1256
1257
  return {
1258
+ setFieldRef: (_) => {
1259
+ if (fieldRefs.current) {
1260
+ fieldRefs.current[fieldName] = _;
1261
+ }
1262
+ },
1263
+ fieldRef: fieldRefs.current?.[fieldName],
1257
1264
  value: format ? format(value) : value,
1258
1265
  isDirty,
1259
1266
  errors: fieldValidator && fieldErrors,
@@ -1283,11 +1290,21 @@
1283
1290
  onSubmit?.(formState, ev);
1284
1291
  }
1285
1292
  else {
1293
+ const errorFieldName = getErrorFieldName(formState, fieldValidatorsMap);
1286
1294
  markAsDirty();
1295
+ field(errorFieldName).fieldRef?.scrollIntoView({ behavior: 'smooth' });
1287
1296
  }
1288
1297
  }, [resetOnSubmit, formState, isValid, reset, onSubmit]);
1289
1298
  return [formState, { errors, field, update, reset, onSubmit: handleSubmit }];
1290
1299
  }
1300
+ const getRefsObject = (initialState) => Object.keys(initialState).reduce((acc, key) => ({ ...acc, [key]: null }), {});
1301
+ const getErrorFieldName = (formState, fieldValidatorsMap = {}) => {
1302
+ const [errorFieldName = ''] = Object.entries(formState).find(([fieldName, value]) => {
1303
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
1304
+ return fieldValidatorsMap[fieldName]?.(value)?.length;
1305
+ }) ?? [];
1306
+ return errorFieldName;
1307
+ };
1291
1308
 
1292
1309
  function copy(source, target) {
1293
1310
  for (const [k, v] of source.entries()) {
@@ -2939,6 +2956,16 @@
2939
2956
 
2940
2957
  const ConsentToReceiveMaterialsField = JSX(({ field, input }) => (jsx(Checkbox, { text: "\u0421\u043E\u0433\u043B\u0430\u0441\u0435\u043D \u043D\u0430 \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u0438\u0435 \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u043E\u043D\u043D\u044B\u0445 \u0438 \u0430\u043D\u0430\u043B\u0438\u0442\u0438\u0447\u0435\u0441\u043A\u0438\u0445 \u043C\u0430\u0442\u0435\u0440\u0438\u0430\u043B\u043E\u0432 \u043F\u043E \u044D\u043B\u0435\u043A\u0442\u0440\u043E\u043D\u043D\u043E\u0439 \u043F\u043E\u0447\u0442\u0435", ...field(input?.name ?? '') })));
2941
2958
 
2959
+ const RefWrapper = JSX(({ onFieldRef = noop, children }) => {
2960
+ const ref = useRef(null);
2961
+ useEffect(() => {
2962
+ if (ref.current) {
2963
+ onFieldRef(ref.current);
2964
+ }
2965
+ }, []);
2966
+ return jsx("div", { ref: ref, children: children });
2967
+ });
2968
+
2942
2969
  function shouldRenderField({ input, field, }) {
2943
2970
  const { condition } = input;
2944
2971
  const { value } = field(condition?.name || '');
@@ -2999,7 +3026,7 @@
2999
3026
  ...externalInputs,
3000
3027
  };
3001
3028
  const Component = fieldsRegister[String(input.name)];
3002
- return shouldRenderField({ input, field }) && Component ? (jsx("div", { children: jsx(Component, { field: field, input: input, params: params }) }, i)) : null;
3029
+ return shouldRenderField({ input, field }) && Component ? (jsx(RefWrapper, { onFieldRef: field(input.name ?? '').setFieldRef, children: jsx(Component, { field: field, input: input, params: params }) }, String(i))) : null;
3003
3030
  };
3004
3031
 
3005
3032
  const inputColumnStyles = (column) => column === 2 ? '@xl:grid-cols-2 gap-x-m' : '@xl:grid-cols-1 gap-x-0';
@@ -5824,12 +5851,6 @@
5824
5851
  WORK: 'Работаю',
5825
5852
  RETIREE: 'Пенсионер',
5826
5853
  };
5827
- const INCOME_CERTIFICATE = {
5828
- BANK_STATEMENT: 'Получаю зарплату на счет/карту в РСХБ',
5829
- BANK_STATEMENT_PENS: 'Получаю пенсию на счет/карту в РСХБ',
5830
- PFR_CERTIFICATE: 'Получаю зарплату на счет/карту в другом банке',
5831
- OTHER: 'Другое',
5832
- };
5833
5854
  const getParticipantIncomes = (participantIncomes) => {
5834
5855
  const wages = participantIncomes?.find((contact) => contact.incomeTypeCd.key === "WAGES" /* EIncomesType.WAGES */)?.value;
5835
5856
  const mandatoryPayments = participantIncomes?.find((contact) => contact.incomeTypeCd.key === "MANDATORY_PAYMENTS" /* EIncomesType.MANDATORY_PAYMENTS */)?.value;
@@ -5911,7 +5932,7 @@
5911
5932
  const participant = task.participants[0];
5912
5933
  const { classCard: cardCategory, codeWord, paymentSystemTypeCd: paymentSystem, currencyCode: currency, } = task;
5913
5934
  const { loanAmount: moneyValue, creditPeriod: monthsValue, paymentTypeCd } = task;
5914
- const { birthDate: limitedBirthday, midname: middleName, name, surname, birthPlace, dulIssueDate: dulIssueDate, dulIssuedBy, dulNumber, dulSerie, dulSubdivisionCode, educationLevelCd: education, registrationDate: participantDateRegistration, houseTypeCd: housing, genderCd, participantContacts = [], participantAddresses = [], employmentContractDate: beginDate, employmentTypeCd: employment, organizationName, organizationInn: inn, organizationActivityTypeCd: employerActivities, organizationTypeCd: organization, organizationKindCd: employerOrganization, employeesNumberCd: amountWorkers, opf: legalForm, seniority: generalSeniority, generalSeniority: experience5Years, jobsNumber, lastWorkDuration: lastJobExperience, positionCd: positionOrganization, maritalStatusCd: familyStatus, childrenDependents: children, totalDependents: familyMembers, otherDependents: dependents, militaryStatusCd: conscription, participantIncomes, snils, armyIdFlg, bankruptcyFlg, shareholderFlg, nameLegalEntity: legalEntityName, creditInRshbCd, payrollCardRshbFlg: isInsurance, consentInsuranceFlg: isSalaryClient, incomeCertificateCd, profile, } = participant;
5935
+ const { birthDate: limitedBirthday, midname: middleName, name, surname, birthPlace, dulIssueDate: dulIssueDate, dulIssuedBy, dulNumber, dulSerie, dulSubdivisionCode, educationLevelCd: education, registrationDate: participantDateRegistration, houseTypeCd: housing, genderCd, participantContacts = [], participantAddresses = [], employmentContractDate: beginDate, employmentTypeCd: employment, organizationName, organizationInn: inn, organizationActivityTypeCd: employerActivities, organizationTypeCd: organization, organizationKindCd: employerOrganization, employeesNumberCd: amountWorkers, opf: legalForm, seniority: generalSeniority, generalSeniority: experience5Years, jobsNumber, lastWorkDuration: lastJobExperience, positionCd: positionOrganization, maritalStatusCd: familyStatus, childrenDependents: children, totalDependents: familyMembers, otherDependents: dependents, militaryStatusCd: conscription, participantIncomes, snils, armyIdFlg, bankruptcyFlg, shareholderFlg, nameLegalEntity: legalEntityName, creditInRshbCd, payrollCardRshbFlg: isInsurance, consentInsuranceFlg: isSalaryClient, } = participant;
5915
5936
  return {
5916
5937
  currency: currency?.key,
5917
5938
  paymentSystem: getSelectValue(paymentSystem),
@@ -5949,7 +5970,6 @@
5949
5970
  familyMembers: familyMembers?.toString(),
5950
5971
  dependents: dependents?.toString(),
5951
5972
  conscription: getSelectValue(conscription),
5952
- confirmationIncome: getSelectValue(incomeCertificateCd, INCOME_CERTIFICATE),
5953
5973
  snils,
5954
5974
  armyIdFlg,
5955
5975
  bankruptcyFlg,
@@ -5963,7 +5983,6 @@
5963
5983
  monthsValue,
5964
5984
  isAnnuity: paymentTypeCd?.key === 'ANNUITY',
5965
5985
  },
5966
- esiaAccountTypeCd: profile?.esiaAccountTypeCd,
5967
5986
  ...getParticipantIncomes(participantIncomes),
5968
5987
  ...getParticipantAddresses(participantAddresses),
5969
5988
  ...getParticipantContacts(participantContacts),
@@ -6354,8 +6373,10 @@
6354
6373
  };
6355
6374
 
6356
6375
  const esiaRequestProfile = (body) => fetchRetailJSON('/esia/requestProfile', 'POST', body).then((res) => {
6357
- saveToken(res);
6358
- updateRefreshToken(true);
6376
+ if (res?.access_token && res?.refresh_token) {
6377
+ saveToken(res);
6378
+ updateRefreshToken(true);
6379
+ }
6359
6380
  return res;
6360
6381
  });
6361
6382
 
@@ -6615,8 +6636,9 @@
6615
6636
  const referalData = sessionStore.referalData;
6616
6637
  const marketingInfoFromStorage = sessionStore.marketingInfo;
6617
6638
  const queryStorage = new URLSearchParams(decodeURIComponent(queryFromStorage || ''));
6618
- const code = queryStorage.get('code');
6619
- const state = queryStorage.get('state');
6639
+ const params = new URLSearchParams(decodeURIComponent(globalThis.location?.search));
6640
+ const code = params.get('code');
6641
+ const state = params.get('state');
6620
6642
  const referalCode = code ? referalData?.referalCode : queryStorage.get('referalCode');
6621
6643
  const refererCode = code ? referalData?.refererCode : queryStorage.get('refererCode');
6622
6644
  const productId = code ? referalData?.productId : queryStorage.get('productId');
@@ -11671,7 +11693,7 @@
11671
11693
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
11672
11694
  });
11673
11695
 
11674
- const packageVersion = "0.14.895";
11696
+ const packageVersion = "0.14.897";
11675
11697
 
11676
11698
  exports.Blocks = Blocks;
11677
11699
  exports.ContentPage = ContentPage;