@redneckz/wildless-cms-uni-blocks 0.14.564 → 0.14.566
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/bundle/bundle.umd.js +42 -38
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/CalculatorDeposit/{utils.d.ts → normalize.d.ts} +1 -0
- package/bundle/ui-kit/DatePicker/Calendar.d.ts +1 -0
- package/dist/components/CalculatorDeposit/CalculatorDeposit.js +5 -13
- package/dist/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
- package/dist/components/CalculatorDeposit/{utils.d.ts → normalize.d.ts} +1 -0
- package/{mobile/dist/components/CalculatorDeposit/utils.js → dist/components/CalculatorDeposit/normalize.js} +12 -2
- package/dist/components/CalculatorDeposit/normalize.js.map +1 -0
- package/dist/hooks/useForm.js +1 -1
- package/dist/hooks/useForm.js.map +1 -1
- package/dist/ui-kit/DatePicker/Calendar.d.ts +1 -0
- package/dist/ui-kit/DatePicker/Calendar.js +5 -2
- package/dist/ui-kit/DatePicker/Calendar.js.map +1 -1
- package/dist/ui-kit/DatePicker/DatePicker.js +1 -1
- package/dist/ui-kit/DatePicker/DatePicker.js.map +1 -1
- package/lib/common.css +1 -1
- package/lib/components/CalculatorDeposit/CalculatorDeposit.js +4 -12
- package/lib/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
- package/{mobile/bundle/components/CalculatorDeposit/utils.d.ts → lib/components/CalculatorDeposit/normalize.d.ts} +1 -0
- package/lib/components/CalculatorDeposit/{utils.js → normalize.js} +10 -1
- package/lib/components/CalculatorDeposit/normalize.js.map +1 -0
- package/lib/hooks/useForm.js +1 -1
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/ui-kit/DatePicker/Calendar.d.ts +1 -0
- package/lib/ui-kit/DatePicker/Calendar.js +5 -2
- package/lib/ui-kit/DatePicker/Calendar.js.map +1 -1
- package/lib/ui-kit/DatePicker/DatePicker.js +1 -1
- package/lib/ui-kit/DatePicker/DatePicker.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +42 -38
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/{lib/components/CalculatorDeposit/utils.d.ts → mobile/bundle/components/CalculatorDeposit/normalize.d.ts} +1 -0
- package/mobile/bundle/ui-kit/DatePicker/Calendar.d.ts +1 -0
- package/mobile/dist/components/CalculatorDeposit/CalculatorDeposit.js +5 -13
- package/mobile/dist/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
- package/mobile/dist/components/CalculatorDeposit/normalize.d.ts +18 -0
- package/{dist/components/CalculatorDeposit/utils.js → mobile/dist/components/CalculatorDeposit/normalize.js} +12 -2
- package/mobile/dist/components/CalculatorDeposit/normalize.js.map +1 -0
- package/mobile/dist/hooks/useForm.js +1 -1
- package/mobile/dist/hooks/useForm.js.map +1 -1
- package/mobile/dist/ui-kit/DatePicker/Calendar.d.ts +1 -0
- package/mobile/dist/ui-kit/DatePicker/Calendar.js +5 -2
- package/mobile/dist/ui-kit/DatePicker/Calendar.js.map +1 -1
- package/mobile/dist/ui-kit/DatePicker/DatePicker.js +1 -1
- package/mobile/dist/ui-kit/DatePicker/DatePicker.js.map +1 -1
- package/mobile/lib/common.css +1 -1
- package/mobile/lib/components/CalculatorDeposit/CalculatorDeposit.js +4 -12
- package/mobile/lib/components/CalculatorDeposit/CalculatorDeposit.js.map +1 -1
- package/mobile/lib/components/CalculatorDeposit/normalize.d.ts +18 -0
- package/mobile/lib/components/CalculatorDeposit/{utils.js → normalize.js} +10 -1
- package/mobile/lib/components/CalculatorDeposit/normalize.js.map +1 -0
- package/mobile/lib/hooks/useForm.js +1 -1
- package/mobile/lib/hooks/useForm.js.map +1 -1
- package/mobile/lib/ui-kit/DatePicker/Calendar.d.ts +1 -0
- package/mobile/lib/ui-kit/DatePicker/Calendar.js +5 -2
- package/mobile/lib/ui-kit/DatePicker/Calendar.js.map +1 -1
- package/mobile/lib/ui-kit/DatePicker/DatePicker.js +1 -1
- package/mobile/lib/ui-kit/DatePicker/DatePicker.js.map +1 -1
- package/mobile/src/components/CalculatorDeposit/CalculatorDeposit.tsx +5 -23
- package/mobile/src/components/CalculatorDeposit/{utils.tsx → normalize.tsx} +11 -0
- package/mobile/src/hooks/useForm.ts +1 -1
- package/mobile/src/ui-kit/DatePicker/Calendar.tsx +6 -2
- package/mobile/src/ui-kit/DatePicker/DatePicker.tsx +1 -1
- package/package.json +2 -2
- package/src/components/CalculatorDeposit/CalculatorDeposit.tsx +5 -23
- package/src/components/CalculatorDeposit/{utils.tsx → normalize.tsx} +11 -0
- package/src/hooks/useForm.ts +1 -1
- package/src/ui-kit/DatePicker/Calendar.tsx +6 -2
- package/src/ui-kit/DatePicker/DatePicker.tsx +1 -1
- package/dist/components/CalculatorDeposit/utils.js.map +0 -1
- package/lib/components/CalculatorDeposit/utils.js.map +0 -1
- package/mobile/dist/components/CalculatorDeposit/utils.d.ts +0 -17
- package/mobile/dist/components/CalculatorDeposit/utils.js.map +0 -1
- package/mobile/lib/components/CalculatorDeposit/utils.d.ts +0 -17
- package/mobile/lib/components/CalculatorDeposit/utils.js.map +0 -1
package/bundle/bundle.umd.js
CHANGED
|
@@ -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;
|
|
@@ -1382,8 +1382,11 @@
|
|
|
1382
1382
|
}, isDisabled ? 'text-gray hover:bg-transparent' : 'cursor-pointer');
|
|
1383
1383
|
|
|
1384
1384
|
const WEEK_DAYS = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'];
|
|
1385
|
-
const Calendar = JSX(({ today, currentMonth, currentYear, min, max, onDateSelect = noop }) => {
|
|
1386
|
-
const handleDateClick = useCallback((date) =>
|
|
1385
|
+
const Calendar = JSX(({ today, currentMonth, currentYear, min, max, onDateSelect = noop, setValue = noop }) => {
|
|
1386
|
+
const handleDateClick = useCallback((date) => {
|
|
1387
|
+
onDateSelect(date);
|
|
1388
|
+
setValue(false);
|
|
1389
|
+
}, []);
|
|
1387
1390
|
const { firstDayOfWeek, totalDays } = useMemo(() => ({
|
|
1388
1391
|
firstDayOfWeek: new Date(currentYear, currentMonth, 1).getDay() - 1,
|
|
1389
1392
|
totalDays: new Date(currentYear, currentMonth + 1, 0).getDate(),
|
|
@@ -1484,7 +1487,7 @@
|
|
|
1484
1487
|
selectedMonth,
|
|
1485
1488
|
showCalendar,
|
|
1486
1489
|
});
|
|
1487
|
-
return (jsxs("div", { className: style('space-y-xs', className), ref: ref, children: [renderLabel(label), jsxs("div", { className: "relative", children: [renderDatePickerForm(handleChangeVisibleCalendar, value, valid), showCalendar ? (jsxs("div", { className: "absolute bg-white z-20 select-none", children: [jsxs("div", { className: "flex gap-s", children: [jsx("div", { className: "my-auto", onClick: handlePrevMonth, children: jsx(Icon, { ...ICON_PROPS, className: "-rotate-90 cursor-pointer" }) }), jsx(Select, { onChange: handleSelectMonth, value: { key: months[selectedMonth] }, options: monthsOptions, ...SELECT_PROPS }), jsx(Select, { onChange: handleSelectYear, value: { key: String(selectedYear) }, options: yearsOptions, ...SELECT_PROPS }), jsx("div", { className: "my-auto", onClick: handleNextMonth, children: jsx(Icon, { ...ICON_PROPS, className: "rotate-90 cursor-pointer" }) })] }), jsx(Calendar, { today: value, currentMonth: selectedMonth, currentYear: selectedYear, onDateSelect: onChange, min: minDate, max: maxDate })] })) : null] })] }));
|
|
1490
|
+
return (jsxs("div", { className: style('space-y-xs', className), ref: ref, children: [renderLabel(label), jsxs("div", { className: "relative", children: [renderDatePickerForm(handleChangeVisibleCalendar, value, valid), showCalendar ? (jsxs("div", { className: "absolute bg-white z-20 select-none bottom-full", children: [jsxs("div", { className: "flex gap-s", children: [jsx("div", { className: "my-auto", onClick: handlePrevMonth, children: jsx(Icon, { ...ICON_PROPS, className: "-rotate-90 cursor-pointer" }) }), jsx(Select, { onChange: handleSelectMonth, value: { key: months[selectedMonth] }, options: monthsOptions, ...SELECT_PROPS }), jsx(Select, { onChange: handleSelectYear, value: { key: String(selectedYear) }, options: yearsOptions, ...SELECT_PROPS }), jsx("div", { className: "my-auto", onClick: handleNextMonth, children: jsx(Icon, { ...ICON_PROPS, className: "rotate-90 cursor-pointer" }) })] }), jsx(Calendar, { today: value, currentMonth: selectedMonth, currentYear: selectedYear, onDateSelect: onChange, min: minDate, max: maxDate })] })) : null] })] }));
|
|
1488
1491
|
});
|
|
1489
1492
|
const renderDatePickerForm = (handleChangeVisibleCalendar, value, valid) => (jsxs("div", { onClick: handleChangeVisibleCalendar, className: style(formStyle, valid ? 'border-gray' : 'border-error'), children: [jsx(Paragraph, { children: value && formatDate(value) }), jsx(Icon, { ...ICON_PROPS, name: "CalendarIcon" })] }));
|
|
1490
1493
|
|
|
@@ -3197,6 +3200,37 @@
|
|
|
3197
3200
|
|
|
3198
3201
|
const isRubles = (currency = 'rub') => currency === 'rub';
|
|
3199
3202
|
|
|
3203
|
+
const normalizeDepositParams = (rows) => (_) => !rows
|
|
3204
|
+
? _
|
|
3205
|
+
: {
|
|
3206
|
+
..._,
|
|
3207
|
+
...normalizeReplenishWithdrawn(_),
|
|
3208
|
+
...normalizeMoneyValue(_, rows),
|
|
3209
|
+
...normalizeMonthValue(_, rows),
|
|
3210
|
+
...normalizeCurrency(_, rows),
|
|
3211
|
+
};
|
|
3212
|
+
const normalizeMonthValue = (_, rows) => {
|
|
3213
|
+
const { minMonths, maxMonths } = getRangeByKeys(['minMonths', 'maxMonths'], getRows(rows, _?.currency));
|
|
3214
|
+
const monthsValue = _.monthsValue || Math.round((minMonths + maxMonths) / 2);
|
|
3215
|
+
return { monthsValue: clamp(monthsValue, minMonths, maxMonths) };
|
|
3216
|
+
};
|
|
3217
|
+
const normalizeMoneyValue = (_, rows) => {
|
|
3218
|
+
const { minSum, maxSum } = getRangeByKeys(['minSum', 'maxSum'], getRows(rows, _?.currency));
|
|
3219
|
+
const moneyValue = _.moneyValue || minSum;
|
|
3220
|
+
return { moneyValue: clamp(moneyValue, minSum, maxSum) };
|
|
3221
|
+
};
|
|
3222
|
+
const normalizeCurrency = (_, rows) => ({
|
|
3223
|
+
currency: _?.currency ?? rows?.map((row) => row.currency)?.[0],
|
|
3224
|
+
});
|
|
3225
|
+
const normalizeReplenishWithdrawn = (_) => {
|
|
3226
|
+
const _isRubles = isRubles(_?.currency?.key);
|
|
3227
|
+
return { isReplenish: _isRubles && _?.isReplenish, isWithdrawn: _isRubles && _?.isWithdrawn };
|
|
3228
|
+
};
|
|
3229
|
+
const getRows = (rows, currencyValue) => {
|
|
3230
|
+
const { rates } = rows?.find((_) => _?.currency.key === currencyValue?.key) ?? {};
|
|
3231
|
+
return rates ?? rows?.[0]?.rates;
|
|
3232
|
+
};
|
|
3233
|
+
|
|
3200
3234
|
const renderRegistrationType = (props) => renderBinaryRadioButtonGroup({
|
|
3201
3235
|
...props,
|
|
3202
3236
|
items: [
|
|
@@ -3249,28 +3283,6 @@
|
|
|
3249
3283
|
};
|
|
3250
3284
|
const renderSeparator = (isShow = false) => isShow ? jsx("div", { className: "border-b border-main-divider w-full" }) : null;
|
|
3251
3285
|
|
|
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
3286
|
const MAP = {
|
|
3275
3287
|
isMonthlyInterestPayment: 'isMonthlyInterestPayment',
|
|
3276
3288
|
isRemoteRegistration: 'isRemoteRegistration',
|
|
@@ -3287,15 +3299,7 @@
|
|
|
3287
3299
|
const CalculatorDeposit = UniBlock(({ className, title, calcSource, buttons = [], footnote = '', paramsViewSettings, defaultParams, ...rest }) => {
|
|
3288
3300
|
const { rows } = calcSource ?? {};
|
|
3289
3301
|
const currencyOptions = rows?.map((_) => _.currency) ?? [DEFAULT_CURRENCY];
|
|
3290
|
-
const normalize = useCallback((
|
|
3291
|
-
? _
|
|
3292
|
-
: {
|
|
3293
|
-
..._,
|
|
3294
|
-
...normalizeReplenishWithdrawn(_),
|
|
3295
|
-
...normalizeMoneyValue(_, rows),
|
|
3296
|
-
...normalizeMonthValue(_, rows),
|
|
3297
|
-
...normalizeCurrency(_, rows),
|
|
3298
|
-
}, [rows]);
|
|
3302
|
+
const normalize = useCallback(normalizeDepositParams(rows), [rows]);
|
|
3299
3303
|
const [userInputParams, { field }] = useForm({
|
|
3300
3304
|
moneyValue: getMoneyDefaultValue(defaultParams, DEPOSIT_DEFAULT_SUM),
|
|
3301
3305
|
monthsValue: getMonthsDefaultValue(defaultParams, DEPOSIT_DEFAULT_MONTHS),
|
|
@@ -3311,7 +3315,7 @@
|
|
|
3311
3315
|
const row = getRows(rows, currencyValue);
|
|
3312
3316
|
const calcParams = getDepositCalculatorParams(userInputParams, row, paramsViewSettings);
|
|
3313
3317
|
const { rate, income, finalSum, type = '' } = calcParams;
|
|
3314
|
-
const handleDefaultParamsCals = () => {
|
|
3318
|
+
const handleDefaultParamsCals = useCallback(() => {
|
|
3315
3319
|
setDefaultParamsCalc({
|
|
3316
3320
|
field,
|
|
3317
3321
|
defParams: getDefaultParamsMax(row, isNewClient),
|
|
@@ -3319,7 +3323,7 @@
|
|
|
3319
3323
|
monthsValue: 'minMonths',
|
|
3320
3324
|
map: MAP,
|
|
3321
3325
|
});
|
|
3322
|
-
};
|
|
3326
|
+
}, [field, rows]);
|
|
3323
3327
|
useEffect(() => {
|
|
3324
3328
|
if (!isDefaultParams(defaultParams) && row) {
|
|
3325
3329
|
handleDefaultParamsCals();
|
|
@@ -6565,7 +6569,7 @@
|
|
|
6565
6569
|
slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
|
|
6566
6570
|
});
|
|
6567
6571
|
|
|
6568
|
-
const packageVersion = "0.14.
|
|
6572
|
+
const packageVersion = "0.14.565";
|
|
6569
6573
|
|
|
6570
6574
|
exports.Blocks = Blocks;
|
|
6571
6575
|
exports.ContentPage = ContentPage;
|