@redneckz/wildless-cms-uni-blocks 0.14.564 → 0.14.565

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 (47) hide show
  1. package/bundle/bundle.umd.js +36 -35
  2. package/bundle/bundle.umd.min.js +1 -1
  3. package/bundle/components/CalculatorDeposit/{utils.d.ts → normalize.d.ts} +1 -0
  4. package/dist/components/CalculatorDeposit/CalculatorDeposit.js +5 -13
  5. package/dist/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
  6. package/dist/components/CalculatorDeposit/{utils.d.ts → normalize.d.ts} +1 -0
  7. package/{mobile/dist/components/CalculatorDeposit/utils.js → dist/components/CalculatorDeposit/normalize.js} +12 -2
  8. package/dist/components/CalculatorDeposit/normalize.js.map +1 -0
  9. package/dist/hooks/useForm.js +1 -1
  10. package/dist/hooks/useForm.js.map +1 -1
  11. package/lib/components/CalculatorDeposit/CalculatorDeposit.js +4 -12
  12. package/lib/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
  13. package/{mobile/bundle/components/CalculatorDeposit/utils.d.ts → lib/components/CalculatorDeposit/normalize.d.ts} +1 -0
  14. package/lib/components/CalculatorDeposit/{utils.js → normalize.js} +10 -1
  15. package/lib/components/CalculatorDeposit/normalize.js.map +1 -0
  16. package/lib/hooks/useForm.js +1 -1
  17. package/lib/hooks/useForm.js.map +1 -1
  18. package/mobile/bundle/bundle.umd.js +36 -35
  19. package/mobile/bundle/bundle.umd.min.js +1 -1
  20. package/{lib/components/CalculatorDeposit/utils.d.ts → mobile/bundle/components/CalculatorDeposit/normalize.d.ts} +1 -0
  21. package/mobile/dist/components/CalculatorDeposit/CalculatorDeposit.js +5 -13
  22. package/mobile/dist/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
  23. package/mobile/dist/components/CalculatorDeposit/normalize.d.ts +18 -0
  24. package/{dist/components/CalculatorDeposit/utils.js → mobile/dist/components/CalculatorDeposit/normalize.js} +12 -2
  25. package/mobile/dist/components/CalculatorDeposit/normalize.js.map +1 -0
  26. package/mobile/dist/hooks/useForm.js +1 -1
  27. package/mobile/dist/hooks/useForm.js.map +1 -1
  28. package/mobile/lib/components/CalculatorDeposit/CalculatorDeposit.js +4 -12
  29. package/mobile/lib/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
  30. package/mobile/lib/components/CalculatorDeposit/normalize.d.ts +18 -0
  31. package/mobile/lib/components/CalculatorDeposit/{utils.js → normalize.js} +10 -1
  32. package/mobile/lib/components/CalculatorDeposit/normalize.js.map +1 -0
  33. package/mobile/lib/hooks/useForm.js +1 -1
  34. package/mobile/lib/hooks/useForm.js.map +1 -1
  35. package/mobile/src/components/CalculatorDeposit/CalculatorDeposit.tsx +5 -23
  36. package/mobile/src/components/CalculatorDeposit/{utils.tsx → normalize.tsx} +11 -0
  37. package/mobile/src/hooks/useForm.ts +1 -1
  38. package/package.json +2 -2
  39. package/src/components/CalculatorDeposit/CalculatorDeposit.tsx +5 -23
  40. package/src/components/CalculatorDeposit/{utils.tsx → normalize.tsx} +11 -0
  41. package/src/hooks/useForm.ts +1 -1
  42. package/dist/components/CalculatorDeposit/utils.js.map +0 -1
  43. package/lib/components/CalculatorDeposit/utils.js.map +0 -1
  44. package/mobile/dist/components/CalculatorDeposit/utils.d.ts +0 -17
  45. package/mobile/dist/components/CalculatorDeposit/utils.js.map +0 -1
  46. package/mobile/lib/components/CalculatorDeposit/utils.d.ts +0 -17
  47. package/mobile/lib/components/CalculatorDeposit/utils.js.map +0 -1
@@ -1100,7 +1100,7 @@
1100
1100
  },
1101
1101
  ];
1102
1102
  };
1103
- const shellowCompare = (a, b) => Object.keys({ ...a, ...b }).every((key) => a[key] === b[key]);
1103
+ const shellowCompare = (a, b) => a && b && Object.keys({ ...a, ...b }).every((key) => a[key] === b[key]);
1104
1104
 
1105
1105
  const ApplicationFormLayout = JSX((props) => {
1106
1106
  const { className, title, children, ...rest } = props;
@@ -3197,6 +3197,37 @@
3197
3197
 
3198
3198
  const isRubles = (currency = 'rub') => currency === 'rub';
3199
3199
 
3200
+ const normalizeDepositParams = (rows) => (_) => !rows
3201
+ ? _
3202
+ : {
3203
+ ..._,
3204
+ ...normalizeReplenishWithdrawn(_),
3205
+ ...normalizeMoneyValue(_, rows),
3206
+ ...normalizeMonthValue(_, rows),
3207
+ ...normalizeCurrency(_, rows),
3208
+ };
3209
+ const normalizeMonthValue = (_, rows) => {
3210
+ const { minMonths, maxMonths } = getRangeByKeys(['minMonths', 'maxMonths'], getRows(rows, _?.currency));
3211
+ const monthsValue = _.monthsValue || Math.round((minMonths + maxMonths) / 2);
3212
+ return { monthsValue: clamp(monthsValue, minMonths, maxMonths) };
3213
+ };
3214
+ const normalizeMoneyValue = (_, rows) => {
3215
+ const { minSum, maxSum } = getRangeByKeys(['minSum', 'maxSum'], getRows(rows, _?.currency));
3216
+ const moneyValue = _.moneyValue || minSum;
3217
+ return { moneyValue: clamp(moneyValue, minSum, maxSum) };
3218
+ };
3219
+ const normalizeCurrency = (_, rows) => ({
3220
+ currency: _?.currency ?? rows?.map((row) => row.currency)?.[0],
3221
+ });
3222
+ const normalizeReplenishWithdrawn = (_) => {
3223
+ const _isRubles = isRubles(_?.currency?.key);
3224
+ return { isReplenish: _isRubles && _?.isReplenish, isWithdrawn: _isRubles && _?.isWithdrawn };
3225
+ };
3226
+ const getRows = (rows, currencyValue) => {
3227
+ const { rates } = rows?.find((_) => _?.currency.key === currencyValue?.key) ?? {};
3228
+ return rates ?? rows?.[0]?.rates;
3229
+ };
3230
+
3200
3231
  const renderRegistrationType = (props) => renderBinaryRadioButtonGroup({
3201
3232
  ...props,
3202
3233
  items: [
@@ -3249,28 +3280,6 @@
3249
3280
  };
3250
3281
  const renderSeparator = (isShow = false) => isShow ? jsx("div", { className: "border-b border-main-divider w-full" }) : null;
3251
3282
 
3252
- const normalizeMonthValue = (_, rows) => {
3253
- const { minMonths, maxMonths } = getRangeByKeys(['minMonths', 'maxMonths'], getRows(rows, _?.currency));
3254
- const monthsValue = _.monthsValue || Math.round((minMonths + maxMonths) / 2);
3255
- return { monthsValue: clamp(monthsValue, minMonths, maxMonths) };
3256
- };
3257
- const normalizeMoneyValue = (_, rows) => {
3258
- const { minSum, maxSum } = getRangeByKeys(['minSum', 'maxSum'], getRows(rows, _?.currency));
3259
- const moneyValue = _.moneyValue || minSum;
3260
- return { moneyValue: clamp(moneyValue, minSum, maxSum) };
3261
- };
3262
- const normalizeCurrency = (_, rows) => ({
3263
- currency: _?.currency ?? rows?.map((row) => row.currency)?.[0],
3264
- });
3265
- const normalizeReplenishWithdrawn = (_) => {
3266
- const _isRubles = isRubles(_?.currency?.key);
3267
- return { isReplenish: _isRubles && _?.isReplenish, isWithdrawn: _isRubles && _?.isWithdrawn };
3268
- };
3269
- const getRows = (rows, currencyValue) => {
3270
- const { rates } = rows?.find((_) => _?.currency.key === currencyValue?.key) ?? {};
3271
- return rates ?? rows?.[0]?.rates;
3272
- };
3273
-
3274
3283
  const MAP = {
3275
3284
  isMonthlyInterestPayment: 'isMonthlyInterestPayment',
3276
3285
  isRemoteRegistration: 'isRemoteRegistration',
@@ -3287,15 +3296,7 @@
3287
3296
  const CalculatorDeposit = UniBlock(({ className, title, calcSource, buttons = [], footnote = '', paramsViewSettings, defaultParams, ...rest }) => {
3288
3297
  const { rows } = calcSource ?? {};
3289
3298
  const currencyOptions = rows?.map((_) => _.currency) ?? [DEFAULT_CURRENCY];
3290
- const normalize = useCallback((_) => !rows
3291
- ? _
3292
- : {
3293
- ..._,
3294
- ...normalizeReplenishWithdrawn(_),
3295
- ...normalizeMoneyValue(_, rows),
3296
- ...normalizeMonthValue(_, rows),
3297
- ...normalizeCurrency(_, rows),
3298
- }, [rows]);
3299
+ const normalize = useCallback(normalizeDepositParams(rows), [rows]);
3299
3300
  const [userInputParams, { field }] = useForm({
3300
3301
  moneyValue: getMoneyDefaultValue(defaultParams, DEPOSIT_DEFAULT_SUM),
3301
3302
  monthsValue: getMonthsDefaultValue(defaultParams, DEPOSIT_DEFAULT_MONTHS),
@@ -3311,7 +3312,7 @@
3311
3312
  const row = getRows(rows, currencyValue);
3312
3313
  const calcParams = getDepositCalculatorParams(userInputParams, row, paramsViewSettings);
3313
3314
  const { rate, income, finalSum, type = '' } = calcParams;
3314
- const handleDefaultParamsCals = () => {
3315
+ const handleDefaultParamsCals = useCallback(() => {
3315
3316
  setDefaultParamsCalc({
3316
3317
  field,
3317
3318
  defParams: getDefaultParamsMax(row, isNewClient),
@@ -3319,7 +3320,7 @@
3319
3320
  monthsValue: 'minMonths',
3320
3321
  map: MAP,
3321
3322
  });
3322
- };
3323
+ }, [field, rows]);
3323
3324
  useEffect(() => {
3324
3325
  if (!isDefaultParams(defaultParams) && row) {
3325
3326
  handleDefaultParamsCals();
@@ -6565,7 +6566,7 @@
6565
6566
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
6566
6567
  });
6567
6568
 
6568
- const packageVersion = "0.14.563";
6569
+ const packageVersion = "0.14.564";
6569
6570
 
6570
6571
  exports.Blocks = Blocks;
6571
6572
  exports.ContentPage = ContentPage;