@simai-studio/view 1.2.0 → 1.3.0
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 +1 -1
- package/dist/package-receipt.json +61 -61
- package/dist/smart/view-flow/component.json +10 -2
- package/dist/smart/view-flow/component.json.gz +0 -0
- package/dist/smart/view-flow/css/view-flow.css +367 -0
- package/dist/smart/view-flow/css/view-flow.css.gz +0 -0
- package/dist/smart/view-flow/css/view-flow.min.css +1 -0
- package/dist/smart/view-flow/css/view-flow.min.css.gz +0 -0
- package/dist/smart/view-flow/js/view-flow.js +1552 -4
- package/dist/smart/view-flow/js/view-flow.js.gz +0 -0
- package/dist/smart/view-flow/js/view-flow.min.js +248 -137
- package/dist/smart/view-flow/js/view-flow.min.js.gz +0 -0
- package/dist/smart/view-flow/smart.manifest.json +11 -3
- package/dist/smart/view-flow/smart.manifest.json.gz +0 -0
- package/dist/smart/view-properties/component.json +8 -1
- package/dist/smart/view-properties/component.json.gz +0 -0
- package/dist/smart/view-properties/css/view-properties.css +367 -0
- package/dist/smart/view-properties/css/view-properties.css.gz +0 -0
- package/dist/smart/view-properties/css/view-properties.min.css +1 -0
- package/dist/smart/view-properties/css/view-properties.min.css.gz +0 -0
- package/dist/smart/view-properties/js/view-properties.js +1552 -4
- package/dist/smart/view-properties/js/view-properties.js.gz +0 -0
- package/dist/smart/view-properties/js/view-properties.min.js +491 -380
- package/dist/smart/view-properties/js/view-properties.min.js.gz +0 -0
- package/dist/smart/view-properties/smart.manifest.json +34 -3
- package/dist/smart/view-properties/smart.manifest.json.gz +0 -0
- package/package.json +1 -1
|
@@ -4517,6 +4517,226 @@ function fieldConditions(field, values) {
|
|
|
4517
4517
|
|
|
4518
4518
|
/***/ },
|
|
4519
4519
|
|
|
4520
|
+
/***/ "f44b979883f0"
|
|
4521
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
4522
|
+
|
|
4523
|
+
__webpack_require__.r(__webpack_exports__);
|
|
4524
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4525
|
+
/* harmony export */ add: () => (/* binding */ add),
|
|
4526
|
+
/* harmony export */ compare: () => (/* binding */ compare),
|
|
4527
|
+
/* harmony export */ decimalString: () => (/* binding */ decimalString),
|
|
4528
|
+
/* harmony export */ editableDecimal: () => (/* binding */ editableDecimal),
|
|
4529
|
+
/* harmony export */ formatDecimal: () => (/* binding */ formatDecimal),
|
|
4530
|
+
/* harmony export */ fractionDigits: () => (/* binding */ fractionDigits),
|
|
4531
|
+
/* harmony export */ multiply: () => (/* binding */ multiply),
|
|
4532
|
+
/* harmony export */ readDecimal: () => (/* binding */ readDecimal),
|
|
4533
|
+
/* harmony export */ round: () => (/* binding */ round),
|
|
4534
|
+
/* harmony export */ share: () => (/* binding */ share),
|
|
4535
|
+
/* harmony export */ toDecimal: () => (/* binding */ toDecimal)
|
|
4536
|
+
/* harmony export */ });
|
|
4537
|
+
// Decimal numbers as strings, never as floats (Larena property types standard,
|
|
4538
|
+
// notes of 2026-11-03: «Arithmetic is on decimal digits, never on floats»;
|
|
4539
|
+
// «Never a float on the wire»). A money amount, a percent and every cell a row
|
|
4540
|
+
// computes are read, multiplied, summed and rounded here on BigInt units, so
|
|
4541
|
+
// 0.1 + 0.2 is 0.3 and 2 499,99 stays 2 499,99 however many rows add up to it.
|
|
4542
|
+
//
|
|
4543
|
+
// A decimal is {units, scale}: the value is units / 10^scale. The canonical
|
|
4544
|
+
// string has an optional minus, the integer digits without leading zeros and
|
|
4545
|
+
// the fraction digits as written ("1500.50", "0.5", "-3"); "-0" is "0".
|
|
4546
|
+
const TYPED = /^([+-]?)(\d*)(?:[.,](\d*))?$/u; // Spaces a person or a formatter puts between groups of digits: the plain
|
|
4547
|
+
// space, the no-break space and the narrow no-break space ru-RU writes.
|
|
4548
|
+
|
|
4549
|
+
const GROUP_SPACES = /[\s ']/gu;
|
|
4550
|
+
/**
|
|
4551
|
+
* What a person typed, read as a decimal: `{ok: true, value}` with the
|
|
4552
|
+
* canonical string (null for nothing typed), or `{ok: false}` for text that is
|
|
4553
|
+
* not a number. A comma and a point both separate the fraction; spaces between
|
|
4554
|
+
* groups go.
|
|
4555
|
+
*/
|
|
4556
|
+
|
|
4557
|
+
function readDecimal(text) {
|
|
4558
|
+
if (text === null || typeof text === 'undefined') return {
|
|
4559
|
+
ok: true,
|
|
4560
|
+
value: null
|
|
4561
|
+
};
|
|
4562
|
+
|
|
4563
|
+
if (typeof text === 'number') {
|
|
4564
|
+
// A JSON integer is taken as its digits (property types standard §5); a
|
|
4565
|
+
// float is not a decimal and is refused rather than guessed at.
|
|
4566
|
+
return Number.isSafeInteger(text) ? {
|
|
4567
|
+
ok: true,
|
|
4568
|
+
value: String(text)
|
|
4569
|
+
} : {
|
|
4570
|
+
ok: false
|
|
4571
|
+
};
|
|
4572
|
+
}
|
|
4573
|
+
|
|
4574
|
+
const plain = String(text).replace(GROUP_SPACES, '');
|
|
4575
|
+
if (plain === '') return {
|
|
4576
|
+
ok: true,
|
|
4577
|
+
value: null
|
|
4578
|
+
};
|
|
4579
|
+
const match = TYPED.exec(plain);
|
|
4580
|
+
if (!match) return {
|
|
4581
|
+
ok: false
|
|
4582
|
+
};
|
|
4583
|
+
const [, sign, whole, fraction] = match;
|
|
4584
|
+
if (whole === '' && (fraction ?? '') === '') return {
|
|
4585
|
+
ok: false
|
|
4586
|
+
};
|
|
4587
|
+
const integer = whole.replace(/^0+(?=\d)/u, '') || '0';
|
|
4588
|
+
const digits = fraction ?? '';
|
|
4589
|
+
const zero = /^0*$/u.test(integer + digits);
|
|
4590
|
+
const value = `${sign === '-' && !zero ? '-' : ''}${integer}${digits ? `.${digits}` : ''}`;
|
|
4591
|
+
return {
|
|
4592
|
+
ok: true,
|
|
4593
|
+
value
|
|
4594
|
+
};
|
|
4595
|
+
}
|
|
4596
|
+
/** The decimal of a canonical string or a JSON integer, or null. */
|
|
4597
|
+
|
|
4598
|
+
function toDecimal(value) {
|
|
4599
|
+
if (value && typeof value === 'object' && typeof value.units === 'bigint') return value;
|
|
4600
|
+
const read = readDecimal(value);
|
|
4601
|
+
if (!read.ok || read.value === null) return null;
|
|
4602
|
+
const negative = read.value.startsWith('-');
|
|
4603
|
+
const [whole, fraction = ''] = read.value.replace('-', '').split('.');
|
|
4604
|
+
const units = BigInt(whole + fraction) * (negative ? -1n : 1n);
|
|
4605
|
+
return {
|
|
4606
|
+
units,
|
|
4607
|
+
scale: fraction.length
|
|
4608
|
+
};
|
|
4609
|
+
}
|
|
4610
|
+
/** How many digits a decimal string has after its point. */
|
|
4611
|
+
|
|
4612
|
+
function fractionDigits(value) {
|
|
4613
|
+
const read = readDecimal(value);
|
|
4614
|
+
if (!read.ok || read.value === null) return 0;
|
|
4615
|
+
const at = read.value.indexOf('.');
|
|
4616
|
+
return at === -1 ? 0 : read.value.length - at - 1;
|
|
4617
|
+
}
|
|
4618
|
+
const POWERS = new Map();
|
|
4619
|
+
|
|
4620
|
+
const power = n => {
|
|
4621
|
+
if (!POWERS.has(n)) POWERS.set(n, 10n ** BigInt(n));
|
|
4622
|
+
return POWERS.get(n);
|
|
4623
|
+
};
|
|
4624
|
+
|
|
4625
|
+
function rescale(decimal, scale) {
|
|
4626
|
+
return decimal.scale === scale ? decimal : {
|
|
4627
|
+
units: decimal.units * power(scale - decimal.scale),
|
|
4628
|
+
scale
|
|
4629
|
+
};
|
|
4630
|
+
}
|
|
4631
|
+
|
|
4632
|
+
function multiply(a, b) {
|
|
4633
|
+
return {
|
|
4634
|
+
units: a.units * b.units,
|
|
4635
|
+
scale: a.scale + b.scale
|
|
4636
|
+
};
|
|
4637
|
+
}
|
|
4638
|
+
function add(a, b) {
|
|
4639
|
+
const scale = Math.max(a.scale, b.scale);
|
|
4640
|
+
return {
|
|
4641
|
+
units: rescale(a, scale).units + rescale(b, scale).units,
|
|
4642
|
+
scale
|
|
4643
|
+
};
|
|
4644
|
+
}
|
|
4645
|
+
/** A share: 20 percent is 0.2 (property types standard, rows: «A percent operand counts as its share»). */
|
|
4646
|
+
|
|
4647
|
+
function share(decimal) {
|
|
4648
|
+
return {
|
|
4649
|
+
units: decimal.units,
|
|
4650
|
+
scale: decimal.scale + 2
|
|
4651
|
+
};
|
|
4652
|
+
}
|
|
4653
|
+
/** Rounded half away from zero to `scale` digits after the point. */
|
|
4654
|
+
|
|
4655
|
+
function round(decimal, scale) {
|
|
4656
|
+
if (decimal.scale <= scale) return rescale(decimal, scale);
|
|
4657
|
+
const divisor = power(decimal.scale - scale);
|
|
4658
|
+
const negative = decimal.units < 0n;
|
|
4659
|
+
const magnitude = negative ? -decimal.units : decimal.units;
|
|
4660
|
+
let units = magnitude / divisor;
|
|
4661
|
+
if (magnitude % divisor * 2n >= divisor) units += 1n;
|
|
4662
|
+
return {
|
|
4663
|
+
units: negative ? -units : units,
|
|
4664
|
+
scale
|
|
4665
|
+
};
|
|
4666
|
+
}
|
|
4667
|
+
function compare(a, b) {
|
|
4668
|
+
const scale = Math.max(a.scale, b.scale);
|
|
4669
|
+
const left = rescale(a, scale).units;
|
|
4670
|
+
const right = rescale(b, scale).units;
|
|
4671
|
+
return left === right ? 0 : left < right ? -1 : 1;
|
|
4672
|
+
}
|
|
4673
|
+
/** The canonical string of a decimal, with exactly its scale's digits after the point. */
|
|
4674
|
+
|
|
4675
|
+
function decimalString(decimal) {
|
|
4676
|
+
const negative = decimal.units < 0n;
|
|
4677
|
+
const digits = (negative ? -decimal.units : decimal.units).toString().padStart(decimal.scale + 1, '0');
|
|
4678
|
+
const whole = decimal.scale ? digits.slice(0, -decimal.scale) : digits;
|
|
4679
|
+
const fraction = decimal.scale ? digits.slice(-decimal.scale) : '';
|
|
4680
|
+
const zero = decimal.units === 0n;
|
|
4681
|
+
return `${negative && !zero ? '-' : ''}${whole}${fraction ? `.${fraction}` : ''}`;
|
|
4682
|
+
} // The separators of a locale, read once from Intl and kept: a decimal is
|
|
4683
|
+
// formatted from its digits, so no amount passes through a float to be shown.
|
|
4684
|
+
|
|
4685
|
+
const SEPARATORS = new Map();
|
|
4686
|
+
|
|
4687
|
+
function separators(locale) {
|
|
4688
|
+
if (!SEPARATORS.has(locale)) {
|
|
4689
|
+
let group = ' ';
|
|
4690
|
+
let point = '.';
|
|
4691
|
+
|
|
4692
|
+
try {
|
|
4693
|
+
for (const part of new Intl.NumberFormat(locale).formatToParts(12345.6)) {
|
|
4694
|
+
if (part.type === 'group') group = part.value;
|
|
4695
|
+
if (part.type === 'decimal') point = part.value;
|
|
4696
|
+
}
|
|
4697
|
+
} catch {// An unknown locale keeps the defaults.
|
|
4698
|
+
}
|
|
4699
|
+
|
|
4700
|
+
SEPARATORS.set(locale, {
|
|
4701
|
+
group,
|
|
4702
|
+
point
|
|
4703
|
+
});
|
|
4704
|
+
}
|
|
4705
|
+
|
|
4706
|
+
return SEPARATORS.get(locale);
|
|
4707
|
+
}
|
|
4708
|
+
/**
|
|
4709
|
+
* A decimal string as a person reads it in `locale`: groups of three, the
|
|
4710
|
+
* locale's point, and at least `minFraction` digits after it («1 500,50»).
|
|
4711
|
+
* Groups start at four digits, as the standard reads money («1 500,50 ₽»).
|
|
4712
|
+
*/
|
|
4713
|
+
|
|
4714
|
+
|
|
4715
|
+
function formatDecimal(value, locale, {
|
|
4716
|
+
minFraction = 0
|
|
4717
|
+
} = {}) {
|
|
4718
|
+
const decimal = toDecimal(value);
|
|
4719
|
+
if (!decimal) return '';
|
|
4720
|
+
const text = decimalString(decimal.scale < minFraction ? rescale(decimal, minFraction) : decimal);
|
|
4721
|
+
const negative = text.startsWith('-');
|
|
4722
|
+
const [whole, fraction] = text.replace('-', '').split('.');
|
|
4723
|
+
const {
|
|
4724
|
+
group,
|
|
4725
|
+
point
|
|
4726
|
+
} = separators(locale);
|
|
4727
|
+
const grouped = whole.replace(/\B(?=(\d{3})+(?!\d))/gu, group);
|
|
4728
|
+
return `${negative ? '−' : ''}${grouped}${fraction ? `${point}${fraction}` : ''}`;
|
|
4729
|
+
}
|
|
4730
|
+
/** A decimal string as typed in an input: the locale's point, no groups («1500,5»). */
|
|
4731
|
+
|
|
4732
|
+
function editableDecimal(value, locale) {
|
|
4733
|
+
const read = readDecimal(value);
|
|
4734
|
+
if (!read.ok || read.value === null) return '';
|
|
4735
|
+
return read.value.replace('.', separators(locale).point);
|
|
4736
|
+
}
|
|
4737
|
+
|
|
4738
|
+
/***/ },
|
|
4739
|
+
|
|
4520
4740
|
/***/ "62c5c417c97d"
|
|
4521
4741
|
(module, __webpack_exports__, __webpack_require__) {
|
|
4522
4742
|
|
|
@@ -4527,10 +4747,12 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4527
4747
|
/* harmony export */ });
|
|
4528
4748
|
/* harmony import */ var lit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("2a080a730149");
|
|
4529
4749
|
/* harmony import */ var _field_renderers_index_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("e5483002f3ea");
|
|
4530
|
-
var
|
|
4531
|
-
([lit__WEBPACK_IMPORTED_MODULE_0__, _field_renderers_index_js__WEBPACK_IMPORTED_MODULE_1__]
|
|
4750
|
+
/* harmony import */ var _set_fields_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("db94c32f22be");
|
|
4751
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([lit__WEBPACK_IMPORTED_MODULE_0__, _field_renderers_index_js__WEBPACK_IMPORTED_MODULE_1__, _set_fields_js__WEBPACK_IMPORTED_MODULE_2__]);
|
|
4752
|
+
([lit__WEBPACK_IMPORTED_MODULE_0__, _field_renderers_index_js__WEBPACK_IMPORTED_MODULE_1__, _set_fields_js__WEBPACK_IMPORTED_MODULE_2__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
|
|
4532
4753
|
/* harmony import */ var lit__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lit__WEBPACK_IMPORTED_MODULE_0__);
|
|
4533
4754
|
|
|
4755
|
+
|
|
4534
4756
|
// One field's value, shown or edited, drawn by the SIMAI Framework field
|
|
4535
4757
|
// renderers. Moved out of the record component's template (sf-view-properties
|
|
4536
4758
|
// 1.10.0) so that every view of the set that draws a field draws it the same
|
|
@@ -4568,12 +4790,27 @@ function renderFieldValue(context, field, editing, {
|
|
|
4568
4790
|
setFieldOptionSearch: (target, text) => context.component.setFieldOptionSearch(target, text),
|
|
4569
4791
|
loadFieldOptions: (target, request) => context.component.loadFieldOptions(target, request)
|
|
4570
4792
|
} : {})
|
|
4571
|
-
}; //
|
|
4793
|
+
}; // Money, a percent, rows and the compound fields are the set's own
|
|
4794
|
+
// (js/set-fields.js, Larena addendum of 2026-11-03): drawn from Framework
|
|
4795
|
+
// controls, with the edit host above, before the Framework renderers are
|
|
4796
|
+
// asked for a type they do not draw.
|
|
4797
|
+
|
|
4798
|
+
const own = (0,_set_fields_js__WEBPACK_IMPORTED_MODULE_2__.renderSetField)(field, context.changed.has(key) && editing ? context.changed.get(key) : field.value, editing, editHost, {
|
|
4799
|
+
node: context.component,
|
|
4800
|
+
size: context.size,
|
|
4801
|
+
viewHost: context.viewHost,
|
|
4802
|
+
disabled
|
|
4803
|
+
});
|
|
4804
|
+
|
|
4805
|
+
if (own !== null) {
|
|
4806
|
+
return own === lit__WEBPACK_IMPORTED_MODULE_0__.nothing ? (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="sf-property-view-empty color-on-surface-variant">${context.emptyText}</span>` : own;
|
|
4807
|
+
} // A datetime and a time of day are the renderer set's: sf-input-date in
|
|
4572
4808
|
// mode datetime and time, one control each (SIMAI Framework duplication
|
|
4573
4809
|
// audit A-14). This view drew its own pair -- the day in a datepicker and
|
|
4574
4810
|
// the time in a masked field -- which cut the day short in a half-width
|
|
4575
4811
|
// field and held half-typed entries of its own.
|
|
4576
4812
|
|
|
4813
|
+
|
|
4577
4814
|
const content = editing ? (0,_field_renderers_index_js__WEBPACK_IMPORTED_MODULE_1__.renderEditField)(field, context.changed.has(key) ? context.changed.get(key) : field.value, editHost, // A field its condition turns off is drawn disabled where the set
|
|
4578
4815
|
// draws disabled apart from read-only (a choice as buttons).
|
|
4579
4816
|
{
|
|
@@ -4628,6 +4865,1308 @@ __webpack_async_result__();
|
|
|
4628
4865
|
|
|
4629
4866
|
/***/ },
|
|
4630
4867
|
|
|
4868
|
+
/***/ "d69ebe7e288e"
|
|
4869
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
4870
|
+
|
|
4871
|
+
__webpack_require__.r(__webpack_exports__);
|
|
4872
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4873
|
+
/* harmony export */ currencyOf: () => (/* binding */ currencyOf),
|
|
4874
|
+
/* harmony export */ formatMoney: () => (/* binding */ formatMoney),
|
|
4875
|
+
/* harmony export */ moneyParts: () => (/* binding */ moneyParts),
|
|
4876
|
+
/* harmony export */ percentText: () => (/* binding */ percentText)
|
|
4877
|
+
/* harmony export */ });
|
|
4878
|
+
/* harmony import */ var _decimal_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("f44b979883f0");
|
|
4879
|
+
// Money and percent as a person reads them, from decimal strings, never a
|
|
4880
|
+
// float: the currency's sign and minor units come from Intl, the digits from
|
|
4881
|
+
// ./decimal.js. Pure, so the unit suite reads it without a browser.
|
|
4882
|
+
|
|
4883
|
+
const CURRENCY = new Map();
|
|
4884
|
+
/** {sign, before, minor}: the sign a locale writes, whether before the amount, and the ISO 4217 minor units. */
|
|
4885
|
+
|
|
4886
|
+
function currencyOf(code, locale) {
|
|
4887
|
+
const id = `${code}|${locale}`;
|
|
4888
|
+
|
|
4889
|
+
if (!CURRENCY.has(id)) {
|
|
4890
|
+
let sign = code;
|
|
4891
|
+
let before = false;
|
|
4892
|
+
let minor = 2;
|
|
4893
|
+
|
|
4894
|
+
try {
|
|
4895
|
+
const format = new Intl.NumberFormat(locale, {
|
|
4896
|
+
style: 'currency',
|
|
4897
|
+
currency: code,
|
|
4898
|
+
currencyDisplay: 'narrowSymbol'
|
|
4899
|
+
});
|
|
4900
|
+
const parts = format.formatToParts(1);
|
|
4901
|
+
const at = parts.findIndex(part => part.type === 'currency');
|
|
4902
|
+
sign = parts[at]?.value ?? code;
|
|
4903
|
+
before = at < parts.findIndex(part => part.type === 'integer');
|
|
4904
|
+
minor = format.resolvedOptions().maximumFractionDigits;
|
|
4905
|
+
} catch {// A code Intl does not know keeps its letters and two minor digits.
|
|
4906
|
+
}
|
|
4907
|
+
|
|
4908
|
+
CURRENCY.set(id, {
|
|
4909
|
+
sign,
|
|
4910
|
+
before,
|
|
4911
|
+
minor
|
|
4912
|
+
});
|
|
4913
|
+
}
|
|
4914
|
+
|
|
4915
|
+
return CURRENCY.get(id);
|
|
4916
|
+
}
|
|
4917
|
+
/** An amount with its currency, as a person reads it: «1 500,50 ₽», «$1,500.50». */
|
|
4918
|
+
|
|
4919
|
+
function formatMoney(amount, code, locale) {
|
|
4920
|
+
if (!code) return (0,_decimal_js__WEBPACK_IMPORTED_MODULE_0__.formatDecimal)(amount, locale);
|
|
4921
|
+
const {
|
|
4922
|
+
sign,
|
|
4923
|
+
before,
|
|
4924
|
+
minor
|
|
4925
|
+
} = currencyOf(code, locale);
|
|
4926
|
+
const number = (0,_decimal_js__WEBPACK_IMPORTED_MODULE_0__.formatDecimal)(amount, locale, {
|
|
4927
|
+
minFraction: minor
|
|
4928
|
+
});
|
|
4929
|
+
if (!number) return '';
|
|
4930
|
+
return before ? `${sign}${number}` : `${number} ${sign}`;
|
|
4931
|
+
}
|
|
4932
|
+
/** A money value as {amount, currency}; a field that fixes the currency takes a bare amount. */
|
|
4933
|
+
|
|
4934
|
+
function moneyParts(value, fixed) {
|
|
4935
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
4936
|
+
return {
|
|
4937
|
+
amount: value.amount ?? null,
|
|
4938
|
+
currency: fixed || (value.currency ?? null)
|
|
4939
|
+
};
|
|
4940
|
+
}
|
|
4941
|
+
|
|
4942
|
+
if (value === null || typeof value === 'undefined' || value === '') return {
|
|
4943
|
+
amount: null,
|
|
4944
|
+
currency: fixed || null
|
|
4945
|
+
};
|
|
4946
|
+
return {
|
|
4947
|
+
amount: value,
|
|
4948
|
+
currency: fixed || null
|
|
4949
|
+
};
|
|
4950
|
+
}
|
|
4951
|
+
function percentText(value, locale) {
|
|
4952
|
+
const number = (0,_decimal_js__WEBPACK_IMPORTED_MODULE_0__.formatDecimal)(value, locale);
|
|
4953
|
+
if (!number) return ''; // ru-RU writes «12,5 %», en «12.5%»: the space is the locale's, read from Intl.
|
|
4954
|
+
|
|
4955
|
+
let spaced = false;
|
|
4956
|
+
|
|
4957
|
+
try {
|
|
4958
|
+
spaced = new Intl.NumberFormat(locale, {
|
|
4959
|
+
style: 'percent'
|
|
4960
|
+
}).formatToParts(0.5).some(part => part.type === 'literal' && /\s/u.test(part.value));
|
|
4961
|
+
} catch {
|
|
4962
|
+
spaced = false;
|
|
4963
|
+
}
|
|
4964
|
+
|
|
4965
|
+
return `${number}${spaced ? ' ' : ''}%`;
|
|
4966
|
+
}
|
|
4967
|
+
|
|
4968
|
+
/***/ },
|
|
4969
|
+
|
|
4970
|
+
/***/ "06dfc7b3b9d9"
|
|
4971
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
4972
|
+
|
|
4973
|
+
__webpack_require__.r(__webpack_exports__);
|
|
4974
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4975
|
+
/* harmony export */ REQUISITE_PARTS: () => (/* binding */ REQUISITE_PARTS),
|
|
4976
|
+
/* harmony export */ innValid: () => (/* binding */ innValid),
|
|
4977
|
+
/* harmony export */ ogrnValid: () => (/* binding */ ogrnValid),
|
|
4978
|
+
/* harmony export */ requisiteErrors: () => (/* binding */ requisiteErrors)
|
|
4979
|
+
/* harmony export */ });
|
|
4980
|
+
// The checks of Russian requisites (Larena property types standard, notes of
|
|
4981
|
+
// 2026-11-03, `ru.requisites@1`): each part on its own, and the parts that go
|
|
4982
|
+
// together, together. The server checks the same and is the authority; these
|
|
4983
|
+
// are here so a person sees a mistyped ИНН under the field instead of a refused
|
|
4984
|
+
// save after it.
|
|
4985
|
+
//
|
|
4986
|
+
// Every check answers the key of the words that explain the mistake, or null.
|
|
4987
|
+
const REQUISITE_PARTS = Object.freeze(['inn', 'kpp', 'ogrn', 'bik', 'account', 'corr_account']);
|
|
4988
|
+
|
|
4989
|
+
const digitsOf = text => [...text].map(Number);
|
|
4990
|
+
|
|
4991
|
+
const weighted = (digits, weights) => weights.reduce((sum, weight, index) => sum + weight * digits[index], 0);
|
|
4992
|
+
|
|
4993
|
+
function innValid(inn) {
|
|
4994
|
+
if (!/^\d{10}$|^\d{12}$/u.test(inn)) return false;
|
|
4995
|
+
const d = digitsOf(inn);
|
|
4996
|
+
if (inn.length === 10) return weighted(d, [2, 4, 10, 3, 5, 9, 4, 6, 8]) % 11 % 10 === d[9];
|
|
4997
|
+
const eleventh = weighted(d, [7, 2, 4, 10, 3, 5, 9, 4, 6, 8]) % 11 % 10;
|
|
4998
|
+
const twelfth = weighted(d, [3, 7, 2, 4, 10, 3, 5, 9, 4, 6, 8]) % 11 % 10;
|
|
4999
|
+
return eleventh === d[10] && twelfth === d[11];
|
|
5000
|
+
}
|
|
5001
|
+
function ogrnValid(ogrn) {
|
|
5002
|
+
if (!/^\d{13}$|^\d{15}$/u.test(ogrn)) return false;
|
|
5003
|
+
const body = BigInt(ogrn.slice(0, -1));
|
|
5004
|
+
const modulus = ogrn.length === 13 ? 11n : 13n;
|
|
5005
|
+
return Number(body % modulus % 10n) === Number(ogrn.at(-1));
|
|
5006
|
+
} // An account is checked with the БИК by the Bank of Russia key: the three
|
|
5007
|
+
// digits that come before it, then its twenty, weighted 7, 1, 3 in turn, add up
|
|
5008
|
+
// to a multiple of ten. A settlement account takes the БИК's last three digits;
|
|
5009
|
+
// a correspondent account takes «0» and the БИК's fifth and sixth.
|
|
5010
|
+
|
|
5011
|
+
function accountKeyValid(prefix, account) {
|
|
5012
|
+
const digits = digitsOf(prefix + account);
|
|
5013
|
+
const sum = digits.reduce((total, digit, index) => total + digit * [7, 1, 3][index % 3], 0);
|
|
5014
|
+
return sum % 10 === 0;
|
|
5015
|
+
}
|
|
5016
|
+
/** The mistakes of a requisites value, part by part: {inn: 'innWrong', …}. */
|
|
5017
|
+
|
|
5018
|
+
|
|
5019
|
+
function requisiteErrors(value, parts = REQUISITE_PARTS) {
|
|
5020
|
+
const errors = {};
|
|
5021
|
+
|
|
5022
|
+
const has = part => parts.includes(part);
|
|
5023
|
+
|
|
5024
|
+
const of = part => String(value?.[part] ?? '');
|
|
5025
|
+
|
|
5026
|
+
const inn = of('inn');
|
|
5027
|
+
const kpp = of('kpp');
|
|
5028
|
+
const ogrn = of('ogrn');
|
|
5029
|
+
const bik = of('bik');
|
|
5030
|
+
const account = of('account');
|
|
5031
|
+
const corr = of('corr_account');
|
|
5032
|
+
|
|
5033
|
+
if (has('inn')) {
|
|
5034
|
+
// The ИНН is required (the standard): a value without one is no value.
|
|
5035
|
+
if (!inn) errors.inn = 'innRequired';else if (!/^\d{10}$|^\d{12}$/u.test(inn)) errors.inn = 'innLength';else if (!innValid(inn)) errors.inn = 'innWrong';
|
|
5036
|
+
}
|
|
5037
|
+
|
|
5038
|
+
const person = inn.length === 12;
|
|
5039
|
+
const organization = inn.length === 10;
|
|
5040
|
+
|
|
5041
|
+
if (has('kpp') && kpp) {
|
|
5042
|
+
if (!/^\d{4}[\dA-Z]{2}\d{3}$/u.test(kpp)) errors.kpp = 'kppWrong';else if (person) errors.kpp = 'kppPerson';
|
|
5043
|
+
}
|
|
5044
|
+
|
|
5045
|
+
if (has('ogrn') && ogrn) {
|
|
5046
|
+
if (!/^\d{13}$|^\d{15}$/u.test(ogrn)) errors.ogrn = 'ogrnLength';else if (!ogrnValid(ogrn)) errors.ogrn = 'ogrnWrong';else if (organization && ogrn.length !== 13) errors.ogrn = 'ogrnOrganization';else if (person && ogrn.length !== 15) errors.ogrn = 'ogrnPerson';
|
|
5047
|
+
}
|
|
5048
|
+
|
|
5049
|
+
const bikRight = /^04\d{7}$/u.test(bik);
|
|
5050
|
+
if (has('bik') && bik && !bikRight) errors.bik = 'bikWrong';
|
|
5051
|
+
|
|
5052
|
+
if (has('account') && account) {
|
|
5053
|
+
if (!/^\d{20}$/u.test(account)) errors.account = 'accountLength';else if (bikRight && !accountKeyValid(bik.slice(-3), account)) errors.account = 'accountKey';
|
|
5054
|
+
}
|
|
5055
|
+
|
|
5056
|
+
if (has('corr_account') && corr) {
|
|
5057
|
+
if (!/^\d{20}$/u.test(corr)) errors.corr_account = 'accountLength';else if (!corr.startsWith('301')) errors.corr_account = 'corrStart';else if (bikRight && !accountKeyValid(`0${bik.slice(4, 6)}`, corr)) errors.corr_account = 'accountKey';
|
|
5058
|
+
}
|
|
5059
|
+
|
|
5060
|
+
return errors;
|
|
5061
|
+
}
|
|
5062
|
+
|
|
5063
|
+
/***/ },
|
|
5064
|
+
|
|
5065
|
+
/***/ "ebc72103d8b6"
|
|
5066
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
5067
|
+
|
|
5068
|
+
__webpack_require__.r(__webpack_exports__);
|
|
5069
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
5070
|
+
/* harmony export */ NUMERIC: () => (/* binding */ NUMERIC),
|
|
5071
|
+
/* harmony export */ cellDecimal: () => (/* binding */ cellDecimal),
|
|
5072
|
+
/* harmony export */ columnCurrency: () => (/* binding */ columnCurrency),
|
|
5073
|
+
/* harmony export */ columnOf: () => (/* binding */ columnOf),
|
|
5074
|
+
/* harmony export */ columnsOf: () => (/* binding */ columnsOf),
|
|
5075
|
+
/* harmony export */ computeRow: () => (/* binding */ computeRow),
|
|
5076
|
+
/* harmony export */ rowTotals: () => (/* binding */ rowTotals),
|
|
5077
|
+
/* harmony export */ rowsOf: () => (/* binding */ rowsOf)
|
|
5078
|
+
/* harmony export */ });
|
|
5079
|
+
/* harmony import */ var _decimal_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("f44b979883f0");
|
|
5080
|
+
/* harmony import */ var _money_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("d69ebe7e288e");
|
|
5081
|
+
|
|
5082
|
+
// Rows over columns (Larena property types standard, notes of 2026-11-03,
|
|
5083
|
+
// `items@1`): the columns as the set reads them, the computed cells of a row
|
|
5084
|
+
// and the totals under summed columns, on decimal strings. Pure, so the unit
|
|
5085
|
+
// suite reads it without a browser.
|
|
5086
|
+
|
|
5087
|
+
const NUMERIC = new Set(['integer', 'number', 'percent', 'money']); // A column as the set reads it: its settings beside its own keys, its type
|
|
5088
|
+
// under the name the renderers address (`propertyType`).
|
|
5089
|
+
|
|
5090
|
+
function columnOf(column) {
|
|
5091
|
+
const {
|
|
5092
|
+
settings,
|
|
5093
|
+
...own
|
|
5094
|
+
} = column ?? {};
|
|
5095
|
+
const type = own.propertyType || own.type;
|
|
5096
|
+
return { ...(settings && typeof settings === 'object' ? settings : {}),
|
|
5097
|
+
...own,
|
|
5098
|
+
propertyType: type,
|
|
5099
|
+
type
|
|
5100
|
+
};
|
|
5101
|
+
}
|
|
5102
|
+
function columnsOf(field) {
|
|
5103
|
+
return (Array.isArray(field.columns) ? field.columns : []).map(columnOf).filter(column => column.key);
|
|
5104
|
+
}
|
|
5105
|
+
function rowsOf(value) {
|
|
5106
|
+
return Array.isArray(value) ? value.map(row => row && typeof row === 'object' ? row : {}) : [];
|
|
5107
|
+
} // The decimal a numeric cell holds, or null.
|
|
5108
|
+
|
|
5109
|
+
function cellDecimal(column, cell) {
|
|
5110
|
+
if (cell === null || typeof cell === 'undefined' || cell === '') return null;
|
|
5111
|
+
if (column.propertyType === 'money') return (0,_decimal_js__WEBPACK_IMPORTED_MODULE_0__.toDecimal)((0,_money_js__WEBPACK_IMPORTED_MODULE_1__.moneyParts)(cell, column.currency).amount);
|
|
5112
|
+
return (0,_decimal_js__WEBPACK_IMPORTED_MODULE_0__.toDecimal)(cell);
|
|
5113
|
+
} // The currency a money column's cells are in: its own, else the one money
|
|
5114
|
+
// operand's when it is computed.
|
|
5115
|
+
|
|
5116
|
+
function columnCurrency(column, columns) {
|
|
5117
|
+
if (column.currency) return column.currency;
|
|
5118
|
+
|
|
5119
|
+
if (column.compute?.of) {
|
|
5120
|
+
const operand = columns.find(one => column.compute.of.includes(one.key) && one.propertyType === 'money');
|
|
5121
|
+
return operand?.currency ?? null;
|
|
5122
|
+
}
|
|
5123
|
+
|
|
5124
|
+
return null;
|
|
5125
|
+
}
|
|
5126
|
+
/**
|
|
5127
|
+
* A row with its computed cells worked out from the cells typed: a product of
|
|
5128
|
+
* two or three operands, a percent counting as its share, rounded half away
|
|
5129
|
+
* from zero to the currency's minor units or the column's `scale` (2 by
|
|
5130
|
+
* default). A computed cell whose operands are not all there is no cell. The
|
|
5131
|
+
* keys follow the columns, the computed ones last. The server works the same
|
|
5132
|
+
* out and is the authority.
|
|
5133
|
+
*/
|
|
5134
|
+
|
|
5135
|
+
function computeRow(row, columns, locale = 'en') {
|
|
5136
|
+
const typed = {};
|
|
5137
|
+
const computed = {};
|
|
5138
|
+
|
|
5139
|
+
for (const column of columns) {
|
|
5140
|
+
if (column.compute) continue;
|
|
5141
|
+
if (Object.hasOwn(row, column.key) && row[column.key] !== null && row[column.key] !== '') typed[column.key] = row[column.key];
|
|
5142
|
+
}
|
|
5143
|
+
|
|
5144
|
+
for (const column of columns) {
|
|
5145
|
+
if (!column.compute || column.compute.op !== 'multiply' || !Array.isArray(column.compute.of)) continue;
|
|
5146
|
+
let product = null;
|
|
5147
|
+
let currency = null;
|
|
5148
|
+
|
|
5149
|
+
for (const key of column.compute.of) {
|
|
5150
|
+
const operand = columns.find(one => one.key === key);
|
|
5151
|
+
const decimal = operand ? cellDecimal(operand, typed[key]) : null;
|
|
5152
|
+
|
|
5153
|
+
if (!decimal) {
|
|
5154
|
+
product = null;
|
|
5155
|
+
break;
|
|
5156
|
+
}
|
|
5157
|
+
|
|
5158
|
+
if (operand.propertyType === 'money') currency = (0,_money_js__WEBPACK_IMPORTED_MODULE_1__.moneyParts)(typed[key], operand.currency).currency;
|
|
5159
|
+
const factor = operand.propertyType === 'percent' ? (0,_decimal_js__WEBPACK_IMPORTED_MODULE_0__.share)(decimal) : decimal;
|
|
5160
|
+
product = product ? (0,_decimal_js__WEBPACK_IMPORTED_MODULE_0__.multiply)(product, factor) : factor;
|
|
5161
|
+
}
|
|
5162
|
+
|
|
5163
|
+
if (!product) continue;
|
|
5164
|
+
|
|
5165
|
+
if (column.propertyType === 'money') {
|
|
5166
|
+
const code = column.currency || currency;
|
|
5167
|
+
const scale = code ? (0,_money_js__WEBPACK_IMPORTED_MODULE_1__.currencyOf)(code, locale).minor : 2;
|
|
5168
|
+
computed[column.key] = {
|
|
5169
|
+
amount: (0,_decimal_js__WEBPACK_IMPORTED_MODULE_0__.decimalString)((0,_decimal_js__WEBPACK_IMPORTED_MODULE_0__.round)(product, scale)),
|
|
5170
|
+
currency: code
|
|
5171
|
+
};
|
|
5172
|
+
} else {
|
|
5173
|
+
const scale = column.propertyType === 'integer' ? 0 : Number.isInteger(column.scale) ? column.scale : 2;
|
|
5174
|
+
computed[column.key] = (0,_decimal_js__WEBPACK_IMPORTED_MODULE_0__.decimalString)((0,_decimal_js__WEBPACK_IMPORTED_MODULE_0__.round)(product, scale));
|
|
5175
|
+
}
|
|
5176
|
+
}
|
|
5177
|
+
|
|
5178
|
+
return { ...typed,
|
|
5179
|
+
...computed
|
|
5180
|
+
};
|
|
5181
|
+
}
|
|
5182
|
+
/** The sums of the columns marked `total: "sum"`, as decimals by key. */
|
|
5183
|
+
|
|
5184
|
+
function rowTotals(rows, columns) {
|
|
5185
|
+
const totals = {};
|
|
5186
|
+
|
|
5187
|
+
for (const column of columns) {
|
|
5188
|
+
if (column.total !== 'sum' || !NUMERIC.has(column.propertyType)) continue;
|
|
5189
|
+
let sum = {
|
|
5190
|
+
units: 0n,
|
|
5191
|
+
scale: 0
|
|
5192
|
+
};
|
|
5193
|
+
|
|
5194
|
+
for (const row of rows) {
|
|
5195
|
+
const decimal = cellDecimal(column, row[column.key]);
|
|
5196
|
+
if (decimal) sum = (0,_decimal_js__WEBPACK_IMPORTED_MODULE_0__.add)(sum, decimal);
|
|
5197
|
+
}
|
|
5198
|
+
|
|
5199
|
+
totals[column.key] = sum;
|
|
5200
|
+
}
|
|
5201
|
+
|
|
5202
|
+
return totals;
|
|
5203
|
+
}
|
|
5204
|
+
|
|
5205
|
+
/***/ },
|
|
5206
|
+
|
|
5207
|
+
/***/ "db94c32f22be"
|
|
5208
|
+
(module, __webpack_exports__, __webpack_require__) {
|
|
5209
|
+
|
|
5210
|
+
__webpack_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
|
|
5211
|
+
__webpack_require__.r(__webpack_exports__);
|
|
5212
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
5213
|
+
/* harmony export */ SET_FIELD_TYPES: () => (/* binding */ SET_FIELD_TYPES),
|
|
5214
|
+
/* harmony export */ drawsSetField: () => (/* binding */ drawsSetField),
|
|
5215
|
+
/* harmony export */ renderSetField: () => (/* binding */ renderSetField),
|
|
5216
|
+
/* harmony export */ setFieldText: () => (/* binding */ setFieldText)
|
|
5217
|
+
/* harmony export */ });
|
|
5218
|
+
/* harmony import */ var lit__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("2a080a730149");
|
|
5219
|
+
/* harmony import */ var _set_fields_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("f59c8bcdc90a");
|
|
5220
|
+
/* harmony import */ var _field_renderers_index_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("e5483002f3ea");
|
|
5221
|
+
/* harmony import */ var _core_js_page_language__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("43090d1c8307");
|
|
5222
|
+
/* harmony import */ var _decimal_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("f44b979883f0");
|
|
5223
|
+
/* harmony import */ var _money_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__("d69ebe7e288e");
|
|
5224
|
+
/* harmony import */ var _rows_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__("ebc72103d8b6");
|
|
5225
|
+
/* harmony import */ var _requisites_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__("06dfc7b3b9d9");
|
|
5226
|
+
var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([lit__WEBPACK_IMPORTED_MODULE_0__, _field_renderers_index_js__WEBPACK_IMPORTED_MODULE_2__, _core_js_page_language__WEBPACK_IMPORTED_MODULE_3__]);
|
|
5227
|
+
([lit__WEBPACK_IMPORTED_MODULE_0__, _field_renderers_index_js__WEBPACK_IMPORTED_MODULE_2__, _core_js_page_language__WEBPACK_IMPORTED_MODULE_3__] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__);
|
|
5228
|
+
/* harmony import */ var lit__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(lit__WEBPACK_IMPORTED_MODULE_0__);
|
|
5229
|
+
/* harmony import */ var _core_js_page_language__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_core_js_page_language__WEBPACK_IMPORTED_MODULE_3__);
|
|
5230
|
+
|
|
5231
|
+
|
|
5232
|
+
|
|
5233
|
+
|
|
5234
|
+
|
|
5235
|
+
|
|
5236
|
+
|
|
5237
|
+
// The property types the set draws itself, beside the SIMAI Framework field
|
|
5238
|
+
// renderers it draws every other type with (Larena addendum of 2026-11-03 to
|
|
5239
|
+
// the general components task, msg-bf1ad4f3ae00420bb752; Larena property types
|
|
5240
|
+
// standard, notes of 2026-11-03):
|
|
5241
|
+
//
|
|
5242
|
+
// money {amount, currency}: an amount and its ISO 4217 currency
|
|
5243
|
+
// percent a decimal with a % after it
|
|
5244
|
+
// items rows over the field's columns: a table editor, a card a row on a phone
|
|
5245
|
+
// compound a fixed set of parts with one value object, checked together
|
|
5246
|
+
// ru.requisites the compound of a Russian organisation's or person's requisites
|
|
5247
|
+
//
|
|
5248
|
+
// Each is drawn from Framework controls (sf-input with `text-end`, sf-dropdown,
|
|
5249
|
+
// sf-button-icon, sf-button) and, inside a row or a compound, by the Framework
|
|
5250
|
+
// renderers for the types they already draw. Every number is a decimal string
|
|
5251
|
+
// (./decimal.js): nothing here writes a float.
|
|
5252
|
+
//
|
|
5253
|
+
// A control writes what was typed. An entry that is not a value yet -- text
|
|
5254
|
+
// that is not a number, more digits after the point than the currency has, a
|
|
5255
|
+
// ИНН whose control digit is wrong -- is written as typed and reported through
|
|
5256
|
+
// setFieldError, which holds both saves while it stands (port 1.16.0, as a
|
|
5257
|
+
// masked string does), and the control says what is wrong under itself once
|
|
5258
|
+
// the person has left it.
|
|
5259
|
+
|
|
5260
|
+
const TEXT = {
|
|
5261
|
+
en: {
|
|
5262
|
+
currency: 'Currency',
|
|
5263
|
+
notNumber: 'Enter a number',
|
|
5264
|
+
fractionMax: 'At most {n} digits after the point',
|
|
5265
|
+
fractionNone: 'A whole amount, no digits after the point',
|
|
5266
|
+
chooseCurrency: 'Choose a currency',
|
|
5267
|
+
range: 'From {min} to {max}',
|
|
5268
|
+
atLeast: 'At least {min}',
|
|
5269
|
+
atMost: 'At most {max}',
|
|
5270
|
+
addRow: 'Add a row',
|
|
5271
|
+
removeRow: 'Remove the row',
|
|
5272
|
+
rowUp: 'Move the row up',
|
|
5273
|
+
rowDown: 'Move the row down',
|
|
5274
|
+
row: 'Row {n}',
|
|
5275
|
+
total: 'Total',
|
|
5276
|
+
cellsWrong: 'Some cells are not filled in correctly',
|
|
5277
|
+
rows: '{n} rows',
|
|
5278
|
+
row1: '1 row',
|
|
5279
|
+
inn: 'INN',
|
|
5280
|
+
kpp: 'KPP',
|
|
5281
|
+
ogrn: 'OGRN',
|
|
5282
|
+
bik: 'BIK',
|
|
5283
|
+
account: 'Account',
|
|
5284
|
+
corr_account: 'Correspondent account',
|
|
5285
|
+
innRequired: 'The INN is required',
|
|
5286
|
+
innLength: '10 digits for an organisation, 12 for a person',
|
|
5287
|
+
innWrong: 'The INN control digits do not match',
|
|
5288
|
+
kppWrong: 'Nine characters: four digits, two digits or letters, three digits',
|
|
5289
|
+
kppPerson: 'A person\'s INN has no KPP',
|
|
5290
|
+
ogrnLength: '13 digits (OGRN) or 15 (OGRNIP)',
|
|
5291
|
+
ogrnWrong: 'The control digit does not match',
|
|
5292
|
+
ogrnOrganization: 'An organisation has a 13-digit OGRN',
|
|
5293
|
+
ogrnPerson: 'A person has a 15-digit OGRNIP',
|
|
5294
|
+
bikWrong: 'Nine digits starting with 04',
|
|
5295
|
+
accountLength: '20 digits',
|
|
5296
|
+
accountKey: 'The account does not match the BIK',
|
|
5297
|
+
corrStart: 'A correspondent account starts with 301'
|
|
5298
|
+
},
|
|
5299
|
+
ru: {
|
|
5300
|
+
currency: 'Валюта',
|
|
5301
|
+
notNumber: 'Введите число',
|
|
5302
|
+
fractionMax: 'Не больше {n} знаков после запятой',
|
|
5303
|
+
fractionNone: 'Целая сумма, без знаков после запятой',
|
|
5304
|
+
chooseCurrency: 'Выберите валюту',
|
|
5305
|
+
range: 'От {min} до {max}',
|
|
5306
|
+
atLeast: 'Не меньше {min}',
|
|
5307
|
+
atMost: 'Не больше {max}',
|
|
5308
|
+
addRow: 'Добавить строку',
|
|
5309
|
+
removeRow: 'Удалить строку',
|
|
5310
|
+
rowUp: 'Поднять строку',
|
|
5311
|
+
rowDown: 'Опустить строку',
|
|
5312
|
+
row: 'Строка {n}',
|
|
5313
|
+
total: 'Итого',
|
|
5314
|
+
cellsWrong: 'Не все ячейки заполнены верно',
|
|
5315
|
+
rows: '{n} строк',
|
|
5316
|
+
row1: '1 строка',
|
|
5317
|
+
inn: 'ИНН',
|
|
5318
|
+
kpp: 'КПП',
|
|
5319
|
+
ogrn: 'ОГРН',
|
|
5320
|
+
bik: 'БИК',
|
|
5321
|
+
account: 'Расчётный счёт',
|
|
5322
|
+
corr_account: 'Корр. счёт',
|
|
5323
|
+
innRequired: 'ИНН обязателен',
|
|
5324
|
+
innLength: '10 цифр у организации, 12 у физлица',
|
|
5325
|
+
innWrong: 'Не сходятся контрольные цифры ИНН',
|
|
5326
|
+
kppWrong: 'Девять знаков: четыре цифры, две цифры или буквы, три цифры',
|
|
5327
|
+
kppPerson: 'У ИНН физлица нет КПП',
|
|
5328
|
+
ogrnLength: '13 цифр (ОГРН) или 15 (ОГРНИП)',
|
|
5329
|
+
ogrnWrong: 'Не сходится контрольная цифра',
|
|
5330
|
+
ogrnOrganization: 'У организации ОГРН из 13 цифр',
|
|
5331
|
+
ogrnPerson: 'У физлица ОГРНИП из 15 цифр',
|
|
5332
|
+
bikWrong: 'Девять цифр, начиная с 04',
|
|
5333
|
+
accountLength: '20 цифр',
|
|
5334
|
+
accountKey: 'Счёт не сходится с БИК',
|
|
5335
|
+
corrStart: 'Корр. счёт начинается с 301'
|
|
5336
|
+
}
|
|
5337
|
+
};
|
|
5338
|
+
const WORDS_OF = 'sf-view-properties';
|
|
5339
|
+
|
|
5340
|
+
function word(node, key, vars = {}) {
|
|
5341
|
+
let text = (0,_core_js_page_language__WEBPACK_IMPORTED_MODULE_3__.pageText)(TEXT, key, node, WORDS_OF);
|
|
5342
|
+
|
|
5343
|
+
for (const [name, value] of Object.entries(vars)) text = text.replaceAll(`{${name}}`, String(value));
|
|
5344
|
+
|
|
5345
|
+
return text;
|
|
5346
|
+
} // ru counts: 1 строка, 2–4 строки, 5+ строк.
|
|
5347
|
+
|
|
5348
|
+
|
|
5349
|
+
function rowsWord(node, count) {
|
|
5350
|
+
const locale = (0,_core_js_page_language__WEBPACK_IMPORTED_MODULE_3__.pageLocale)(node);
|
|
5351
|
+
if (count === 1) return word(node, 'row1');
|
|
5352
|
+
|
|
5353
|
+
if (locale.startsWith('ru')) {
|
|
5354
|
+
const tens = count % 100;
|
|
5355
|
+
const ones = count % 10;
|
|
5356
|
+
if (ones >= 2 && ones <= 4 && (tens < 12 || tens > 14)) return `${count} строки`;
|
|
5357
|
+
}
|
|
5358
|
+
|
|
5359
|
+
return word(node, 'rows', {
|
|
5360
|
+
n: count
|
|
5361
|
+
});
|
|
5362
|
+
}
|
|
5363
|
+
|
|
5364
|
+
const SET_FIELD_TYPES = Object.freeze(['money', 'percent', 'items', 'compound', 'ru.requisites']); // --- Currencies -------------------------------------------------------------
|
|
5365
|
+
// The currencies a money field offers when it does not fix one: the ones a
|
|
5366
|
+
// Russian-language business meets most, and the value's own currency first
|
|
5367
|
+
// when it is none of them. A field that fixes `currency` offers no choice.
|
|
5368
|
+
|
|
5369
|
+
const OFFERED_CURRENCIES = ['RUB', 'USD', 'EUR', 'CNY', 'KZT', 'BYN', 'AED', 'TRY', 'GBP', 'JPY']; // --- What a person is typing -------------------------------------------------
|
|
5370
|
+
// The text in a decimal input while it is being typed. The value written is
|
|
5371
|
+
// canonical («12.5»); drawn back as such it would move the caret under the
|
|
5372
|
+
// person typing «12,50». So the typed text is kept per control and shown while
|
|
5373
|
+
// it still reads as the value, and dropped when the control is left.
|
|
5374
|
+
|
|
5375
|
+
const DRAFTS = new WeakMap();
|
|
5376
|
+
|
|
5377
|
+
const draftsOf = node => {
|
|
5378
|
+
if (!DRAFTS.has(node)) DRAFTS.set(node, new Map());
|
|
5379
|
+
return DRAFTS.get(node);
|
|
5380
|
+
}; // The controls a person has left: a message stands under a control only then,
|
|
5381
|
+
// as a masked string's does.
|
|
5382
|
+
|
|
5383
|
+
|
|
5384
|
+
const LEFT = new WeakMap();
|
|
5385
|
+
|
|
5386
|
+
const leftOf = node => {
|
|
5387
|
+
if (!LEFT.has(node)) LEFT.set(node, new Set());
|
|
5388
|
+
return LEFT.get(node);
|
|
5389
|
+
};
|
|
5390
|
+
|
|
5391
|
+
const redraw = node => node?.requestComponentUpdate?.('changed');
|
|
5392
|
+
|
|
5393
|
+
function shownText(node, path, value, locale) {
|
|
5394
|
+
const draft = draftsOf(node).get(path);
|
|
5395
|
+
const read = (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.readDecimal)(value);
|
|
5396
|
+
if (!read.ok) return String(value ?? '');
|
|
5397
|
+
|
|
5398
|
+
if (typeof draft === 'string') {
|
|
5399
|
+
const typed = (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.readDecimal)(draft);
|
|
5400
|
+
if (typed.ok && typed.value === read.value) return draft;
|
|
5401
|
+
}
|
|
5402
|
+
|
|
5403
|
+
return (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.editableDecimal)(read.value, locale);
|
|
5404
|
+
} // The mistake of a typed decimal, or null: not a number, more digits after the
|
|
5405
|
+
// point than allowed, outside the bounds.
|
|
5406
|
+
|
|
5407
|
+
|
|
5408
|
+
function decimalError(node, raw, {
|
|
5409
|
+
maxFraction = null,
|
|
5410
|
+
min = null,
|
|
5411
|
+
max = null
|
|
5412
|
+
} = {}) {
|
|
5413
|
+
const read = (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.readDecimal)(raw);
|
|
5414
|
+
if (!read.ok) return word(node, 'notNumber');
|
|
5415
|
+
if (read.value === null) return null;
|
|
5416
|
+
|
|
5417
|
+
if (maxFraction !== null && (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.fractionDigits)(read.value) > maxFraction) {
|
|
5418
|
+
return maxFraction === 0 ? word(node, 'fractionNone') : word(node, 'fractionMax', {
|
|
5419
|
+
n: maxFraction
|
|
5420
|
+
});
|
|
5421
|
+
}
|
|
5422
|
+
|
|
5423
|
+
const value = (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.toDecimal)(read.value);
|
|
5424
|
+
const low = (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.toDecimal)(min);
|
|
5425
|
+
const high = (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.toDecimal)(max);
|
|
5426
|
+
const locale = (0,_core_js_page_language__WEBPACK_IMPORTED_MODULE_3__.pageLocale)(node);
|
|
5427
|
+
|
|
5428
|
+
if (low && (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.compare)(value, low) < 0 || high && (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.compare)(value, high) > 0) {
|
|
5429
|
+
if (low && high) return word(node, 'range', {
|
|
5430
|
+
min: (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.formatDecimal)(min, locale),
|
|
5431
|
+
max: (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.formatDecimal)(max, locale)
|
|
5432
|
+
});
|
|
5433
|
+
return low ? word(node, 'atLeast', {
|
|
5434
|
+
min: (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.formatDecimal)(min, locale)
|
|
5435
|
+
}) : word(node, 'atMost', {
|
|
5436
|
+
max: (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.formatDecimal)(max, locale)
|
|
5437
|
+
});
|
|
5438
|
+
}
|
|
5439
|
+
|
|
5440
|
+
return null;
|
|
5441
|
+
}
|
|
5442
|
+
/**
|
|
5443
|
+
* One decimal input: sf-input with the decimal keyboard and `text-end` (a % or
|
|
5444
|
+
* a currency sign). `write(text, error)` gets what was typed -- canonical when
|
|
5445
|
+
* it reads as a number -- and the mistake, or null.
|
|
5446
|
+
*/
|
|
5447
|
+
|
|
5448
|
+
|
|
5449
|
+
function decimalInput(node, {
|
|
5450
|
+
path,
|
|
5451
|
+
value,
|
|
5452
|
+
size,
|
|
5453
|
+
label,
|
|
5454
|
+
required,
|
|
5455
|
+
textEnd,
|
|
5456
|
+
placeholder,
|
|
5457
|
+
check,
|
|
5458
|
+
write
|
|
5459
|
+
}) {
|
|
5460
|
+
const locale = (0,_core_js_page_language__WEBPACK_IMPORTED_MODULE_3__.pageLocale)(node);
|
|
5461
|
+
const text = shownText(node, path, value, locale);
|
|
5462
|
+
const error = check(text);
|
|
5463
|
+
const shown = error && leftOf(node).has(path) ? error : '';
|
|
5464
|
+
|
|
5465
|
+
const typed = event => {
|
|
5466
|
+
const raw = event.target?.value ?? '';
|
|
5467
|
+
draftsOf(node).set(path, raw);
|
|
5468
|
+
const read = (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.readDecimal)(raw);
|
|
5469
|
+
write(read.ok ? read.value : raw, check(raw));
|
|
5470
|
+
};
|
|
5471
|
+
|
|
5472
|
+
return (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`
|
|
5473
|
+
<sf-input
|
|
5474
|
+
class="sf-view-fields-decimal"
|
|
5475
|
+
size=${size}
|
|
5476
|
+
appearance="bordered"
|
|
5477
|
+
inputmode="decimal"
|
|
5478
|
+
value=${text}
|
|
5479
|
+
text-end=${textEnd || lit__WEBPACK_IMPORTED_MODULE_0__.nothing}
|
|
5480
|
+
placeholder=${placeholder || lit__WEBPACK_IMPORTED_MODULE_0__.nothing}
|
|
5481
|
+
?required=${Boolean(required)}
|
|
5482
|
+
?invalid=${Boolean(shown)}
|
|
5483
|
+
error-message=${shown || lit__WEBPACK_IMPORTED_MODULE_0__.nothing}
|
|
5484
|
+
aria-label=${label || ''}
|
|
5485
|
+
data-path=${path}
|
|
5486
|
+
@input=${typed}
|
|
5487
|
+
@change=${typed}
|
|
5488
|
+
@focusout=${() => {
|
|
5489
|
+
draftsOf(node).delete(path);
|
|
5490
|
+
leftOf(node).add(path);
|
|
5491
|
+
redraw(node);
|
|
5492
|
+
}}
|
|
5493
|
+
></sf-input>
|
|
5494
|
+
`;
|
|
5495
|
+
} // --- percent -------------------------------------------------------------------
|
|
5496
|
+
|
|
5497
|
+
|
|
5498
|
+
function percentBounds(field) {
|
|
5499
|
+
// 0 and 100 when the field sets none (property types standard §2).
|
|
5500
|
+
return {
|
|
5501
|
+
min: field.min ?? '0',
|
|
5502
|
+
max: field.max ?? '100'
|
|
5503
|
+
};
|
|
5504
|
+
}
|
|
5505
|
+
|
|
5506
|
+
function renderPercentEdit(field, value, host, ctx) {
|
|
5507
|
+
const {
|
|
5508
|
+
min,
|
|
5509
|
+
max
|
|
5510
|
+
} = percentBounds(field);
|
|
5511
|
+
return decimalInput(ctx.node, {
|
|
5512
|
+
path: ctx.path ?? String(field.key ?? ''),
|
|
5513
|
+
value,
|
|
5514
|
+
size: ctx.size,
|
|
5515
|
+
label: field.label || field.key,
|
|
5516
|
+
required: field.required,
|
|
5517
|
+
textEnd: '%',
|
|
5518
|
+
placeholder: field.placeholder,
|
|
5519
|
+
check: text => decimalError(ctx.node, text, {
|
|
5520
|
+
min,
|
|
5521
|
+
max
|
|
5522
|
+
}),
|
|
5523
|
+
write: (next, error) => {
|
|
5524
|
+
host.setFieldValue(field, next);
|
|
5525
|
+
host.setFieldError?.(field, error);
|
|
5526
|
+
}
|
|
5527
|
+
});
|
|
5528
|
+
}
|
|
5529
|
+
|
|
5530
|
+
function renderPercentView(field, value, ctx) {
|
|
5531
|
+
const text = (0,_money_js__WEBPACK_IMPORTED_MODULE_5__.percentText)(value, (0,_core_js_page_language__WEBPACK_IMPORTED_MODULE_3__.pageLocale)(ctx.node));
|
|
5532
|
+
return text ? (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="sf-field-view">${text}</span>` : lit__WEBPACK_IMPORTED_MODULE_0__.nothing;
|
|
5533
|
+
} // --- money ---------------------------------------------------------------------
|
|
5534
|
+
|
|
5535
|
+
|
|
5536
|
+
function renderMoneyEdit(field, value, host, ctx) {
|
|
5537
|
+
const node = ctx.node;
|
|
5538
|
+
const locale = (0,_core_js_page_language__WEBPACK_IMPORTED_MODULE_3__.pageLocale)(node);
|
|
5539
|
+
const path = ctx.path ?? String(field.key ?? '');
|
|
5540
|
+
const fixed = typeof field.currency === 'string' && field.currency ? field.currency : null;
|
|
5541
|
+
const parts = (0,_money_js__WEBPACK_IMPORTED_MODULE_5__.moneyParts)(value, fixed); // A currency chosen before an amount is typed waits here: a value is an
|
|
5542
|
+
// amount and its currency, never a currency alone.
|
|
5543
|
+
|
|
5544
|
+
const currencyPath = `${path}#currency`;
|
|
5545
|
+
const currency = parts.currency || draftsOf(node).get(currencyPath) || null;
|
|
5546
|
+
const minor = currency ? (0,_money_js__WEBPACK_IMPORTED_MODULE_5__.currencyOf)(currency, locale).minor : null;
|
|
5547
|
+
|
|
5548
|
+
const check = text => {
|
|
5549
|
+
const error = decimalError(node, text, {
|
|
5550
|
+
maxFraction: minor,
|
|
5551
|
+
min: field.min ?? null,
|
|
5552
|
+
max: field.max ?? null
|
|
5553
|
+
});
|
|
5554
|
+
if (error) return error;
|
|
5555
|
+
return (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.readDecimal)(text).value !== null && !currency ? word(node, 'chooseCurrency') : null;
|
|
5556
|
+
};
|
|
5557
|
+
|
|
5558
|
+
const write = (amount, error, code = currency) => {
|
|
5559
|
+
host.setFieldValue(field, amount === null ? null : {
|
|
5560
|
+
amount,
|
|
5561
|
+
currency: code
|
|
5562
|
+
});
|
|
5563
|
+
host.setFieldError?.(field, error);
|
|
5564
|
+
};
|
|
5565
|
+
|
|
5566
|
+
const amount = decimalInput(node, {
|
|
5567
|
+
path,
|
|
5568
|
+
value: parts.amount,
|
|
5569
|
+
size: ctx.size,
|
|
5570
|
+
label: field.label || field.key,
|
|
5571
|
+
required: field.required,
|
|
5572
|
+
textEnd: fixed ? (0,_money_js__WEBPACK_IMPORTED_MODULE_5__.currencyOf)(fixed, locale).sign : '',
|
|
5573
|
+
placeholder: field.placeholder,
|
|
5574
|
+
check,
|
|
5575
|
+
write
|
|
5576
|
+
});
|
|
5577
|
+
if (fixed) return amount;
|
|
5578
|
+
const offered = [...new Set([...(currency ? [currency] : []), ...OFFERED_CURRENCIES])];
|
|
5579
|
+
return (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`
|
|
5580
|
+
<span class="sf-view-fields-money flex gap-1/3 min-w-0">
|
|
5581
|
+
${amount}
|
|
5582
|
+
<sf-dropdown
|
|
5583
|
+
class="sf-view-fields-currency"
|
|
5584
|
+
size=${ctx.size}
|
|
5585
|
+
appearance="outlined"
|
|
5586
|
+
mode="select"
|
|
5587
|
+
search="false"
|
|
5588
|
+
value=${currency ?? ''}
|
|
5589
|
+
placeholder=${word(node, 'currency')}
|
|
5590
|
+
aria-label=${word(node, 'currency')}
|
|
5591
|
+
.options=${offered.map(code => ({
|
|
5592
|
+
type: 'text',
|
|
5593
|
+
size: '1',
|
|
5594
|
+
value: code,
|
|
5595
|
+
text: `${code} ${(0,_money_js__WEBPACK_IMPORTED_MODULE_5__.currencyOf)(code, locale).sign === code ? '' : (0,_money_js__WEBPACK_IMPORTED_MODULE_5__.currencyOf)(code, locale).sign}`.trim(),
|
|
5596
|
+
selected: code === currency
|
|
5597
|
+
}))}
|
|
5598
|
+
@change=${event => {
|
|
5599
|
+
const code = event.detail?.value || null;
|
|
5600
|
+
draftsOf(node).set(currencyPath, code);
|
|
5601
|
+
const typed = parts.amount;
|
|
5602
|
+
|
|
5603
|
+
if (typed !== null && typed !== '') {
|
|
5604
|
+
const nextMinor = code ? (0,_money_js__WEBPACK_IMPORTED_MODULE_5__.currencyOf)(code, locale).minor : null;
|
|
5605
|
+
const error = decimalError(node, typed, {
|
|
5606
|
+
maxFraction: nextMinor,
|
|
5607
|
+
min: field.min ?? null,
|
|
5608
|
+
max: field.max ?? null
|
|
5609
|
+
}) || (code ? null : word(node, 'chooseCurrency'));
|
|
5610
|
+
write((0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.readDecimal)(typed).ok ? (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.readDecimal)(typed).value : typed, error, code);
|
|
5611
|
+
} else {
|
|
5612
|
+
redraw(node);
|
|
5613
|
+
}
|
|
5614
|
+
}}
|
|
5615
|
+
></sf-dropdown>
|
|
5616
|
+
</span>
|
|
5617
|
+
`;
|
|
5618
|
+
}
|
|
5619
|
+
|
|
5620
|
+
function moneyText(field, value, locale) {
|
|
5621
|
+
const fixed = typeof field.currency === 'string' && field.currency ? field.currency : null;
|
|
5622
|
+
const {
|
|
5623
|
+
amount,
|
|
5624
|
+
currency
|
|
5625
|
+
} = (0,_money_js__WEBPACK_IMPORTED_MODULE_5__.moneyParts)(value, fixed);
|
|
5626
|
+
return amount === null ? '' : (0,_money_js__WEBPACK_IMPORTED_MODULE_5__.formatMoney)(amount, currency, locale);
|
|
5627
|
+
}
|
|
5628
|
+
|
|
5629
|
+
function renderMoneyView(field, value, ctx) {
|
|
5630
|
+
const text = moneyText(field, value, (0,_core_js_page_language__WEBPACK_IMPORTED_MODULE_3__.pageLocale)(ctx.node));
|
|
5631
|
+
return text ? (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="sf-field-view sf-view-fields-amount">${text}</span>` : lit__WEBPACK_IMPORTED_MODULE_0__.nothing;
|
|
5632
|
+
} // --- number inside a row -----------------------------------------------------------
|
|
5633
|
+
// A number cell of a row is a decimal string as a money amount is: the
|
|
5634
|
+
// Framework's number editor writes a float, which the rows refuse. An integer
|
|
5635
|
+
// cell is the Framework's own.
|
|
5636
|
+
|
|
5637
|
+
|
|
5638
|
+
function renderDecimalEdit(field, value, host, ctx) {
|
|
5639
|
+
return decimalInput(ctx.node, {
|
|
5640
|
+
path: ctx.path ?? String(field.key ?? ''),
|
|
5641
|
+
value,
|
|
5642
|
+
size: ctx.size,
|
|
5643
|
+
label: field.label || field.key,
|
|
5644
|
+
required: field.required,
|
|
5645
|
+
textEnd: field.unit || '',
|
|
5646
|
+
placeholder: field.placeholder,
|
|
5647
|
+
check: text => decimalError(ctx.node, text, {
|
|
5648
|
+
min: field.min ?? null,
|
|
5649
|
+
max: field.max ?? null
|
|
5650
|
+
}),
|
|
5651
|
+
write: (next, error) => {
|
|
5652
|
+
host.setFieldValue(field, next);
|
|
5653
|
+
host.setFieldError?.(field, error);
|
|
5654
|
+
}
|
|
5655
|
+
});
|
|
5656
|
+
}
|
|
5657
|
+
|
|
5658
|
+
function decimalText(field, value, locale) {
|
|
5659
|
+
const text = (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.formatDecimal)(value, locale);
|
|
5660
|
+
return text && field.unit ? `${text} ${field.unit}` : text;
|
|
5661
|
+
} // --- items: rows over columns ------------------------------------------------------
|
|
5662
|
+
|
|
5663
|
+
|
|
5664
|
+
function cellText(column, cell, columns, locale, viewHost) {
|
|
5665
|
+
if (cell === null || typeof cell === 'undefined' || cell === '') return null;
|
|
5666
|
+
|
|
5667
|
+
switch (column.propertyType) {
|
|
5668
|
+
case 'money':
|
|
5669
|
+
{
|
|
5670
|
+
const {
|
|
5671
|
+
amount,
|
|
5672
|
+
currency
|
|
5673
|
+
} = (0,_money_js__WEBPACK_IMPORTED_MODULE_5__.moneyParts)(cell, (0,_rows_js__WEBPACK_IMPORTED_MODULE_6__.columnCurrency)(column, columns));
|
|
5674
|
+
return amount === null ? null : (0,_money_js__WEBPACK_IMPORTED_MODULE_5__.formatMoney)(amount, currency, locale);
|
|
5675
|
+
}
|
|
5676
|
+
|
|
5677
|
+
case 'percent':
|
|
5678
|
+
return (0,_money_js__WEBPACK_IMPORTED_MODULE_5__.percentText)(cell, locale);
|
|
5679
|
+
|
|
5680
|
+
case 'number':
|
|
5681
|
+
return decimalText(column, cell, locale);
|
|
5682
|
+
|
|
5683
|
+
default:
|
|
5684
|
+
{
|
|
5685
|
+
const shown = (0,_field_renderers_index_js__WEBPACK_IMPORTED_MODULE_2__.renderViewField)({ ...column,
|
|
5686
|
+
value: cell
|
|
5687
|
+
}, cell, viewHost, {
|
|
5688
|
+
size: '1'
|
|
5689
|
+
});
|
|
5690
|
+
return shown === null || shown === lit__WEBPACK_IMPORTED_MODULE_0__.nothing ? null : shown;
|
|
5691
|
+
}
|
|
5692
|
+
}
|
|
5693
|
+
}
|
|
5694
|
+
|
|
5695
|
+
function totalText(column, total, columns, locale) {
|
|
5696
|
+
if (column.propertyType === 'money') {
|
|
5697
|
+
const currency = (0,_rows_js__WEBPACK_IMPORTED_MODULE_6__.columnCurrency)(column, columns);
|
|
5698
|
+
return (0,_money_js__WEBPACK_IMPORTED_MODULE_5__.formatMoney)((0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.decimalString)(total), currency, locale);
|
|
5699
|
+
}
|
|
5700
|
+
|
|
5701
|
+
if (column.propertyType === 'percent') return (0,_money_js__WEBPACK_IMPORTED_MODULE_5__.percentText)((0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.decimalString)(total), locale);
|
|
5702
|
+
return decimalText(column, (0,_decimal_js__WEBPACK_IMPORTED_MODULE_4__.decimalString)(total), locale);
|
|
5703
|
+
} // A column's share of the row: text widest, a yes-or-no narrowest.
|
|
5704
|
+
|
|
5705
|
+
|
|
5706
|
+
function track(column) {
|
|
5707
|
+
switch (column.propertyType) {
|
|
5708
|
+
case 'boolean':
|
|
5709
|
+
return 'minmax(4rem, auto)';
|
|
5710
|
+
// Wide enough for the control's own padding, a suffix (% or a currency
|
|
5711
|
+
// sign) and the digits a person types: a 5.5rem percent showed «2 %» for 20.
|
|
5712
|
+
|
|
5713
|
+
case 'integer':
|
|
5714
|
+
return 'minmax(5.5rem, 0.6fr)';
|
|
5715
|
+
|
|
5716
|
+
case 'percent':
|
|
5717
|
+
return 'minmax(6.5rem, 0.6fr)';
|
|
5718
|
+
|
|
5719
|
+
case 'number':
|
|
5720
|
+
return 'minmax(6.5rem, 0.7fr)';
|
|
5721
|
+
|
|
5722
|
+
case 'money':
|
|
5723
|
+
return column.currency ? 'minmax(9rem, 0.9fr)' : 'minmax(13rem, 1.2fr)';
|
|
5724
|
+
|
|
5725
|
+
case 'date':
|
|
5726
|
+
return 'minmax(9rem, 0.8fr)';
|
|
5727
|
+
|
|
5728
|
+
case 'choice':
|
|
5729
|
+
return 'minmax(8rem, 1fr)';
|
|
5730
|
+
|
|
5731
|
+
default:
|
|
5732
|
+
return 'minmax(10rem, 2fr)';
|
|
5733
|
+
}
|
|
5734
|
+
}
|
|
5735
|
+
|
|
5736
|
+
function itemsSummary(field, rows, columns, ctx) {
|
|
5737
|
+
const locale = (0,_core_js_page_language__WEBPACK_IMPORTED_MODULE_3__.pageLocale)(ctx.node);
|
|
5738
|
+
const totals = (0,_rows_js__WEBPACK_IMPORTED_MODULE_6__.rowTotals)(rows, columns);
|
|
5739
|
+
const first = columns.find(column => Object.hasOwn(totals, column.key) && column.propertyType === 'money') ?? columns.find(column => Object.hasOwn(totals, column.key));
|
|
5740
|
+
const count = rowsWord(ctx.node, rows.length);
|
|
5741
|
+
return first ? `${count}, ${word(ctx.node, 'total').toLowerCase()} ${totalText(first, totals[first.key], columns, locale)}` : count;
|
|
5742
|
+
}
|
|
5743
|
+
|
|
5744
|
+
function renderItemsTable(field, rows, columns, ctx, {
|
|
5745
|
+
editing,
|
|
5746
|
+
host
|
|
5747
|
+
}) {
|
|
5748
|
+
const node = ctx.node;
|
|
5749
|
+
const locale = (0,_core_js_page_language__WEBPACK_IMPORTED_MODULE_3__.pageLocale)(node);
|
|
5750
|
+
const key = String(field.key ?? '');
|
|
5751
|
+
const minRows = Number.isInteger(field.minRows) ? field.minRows : 0;
|
|
5752
|
+
const maxRows = Number.isInteger(field.maxRows) ? field.maxRows : 1000; // Fewer rows than the field asks for are drawn as empty rows to fill in,
|
|
5753
|
+
// and written only once something is typed in them.
|
|
5754
|
+
|
|
5755
|
+
const drawn = editing ? [...rows, ...Array.from({
|
|
5756
|
+
length: Math.max(0, minRows - rows.length)
|
|
5757
|
+
}, () => ({}))] : rows;
|
|
5758
|
+
const totals = (0,_rows_js__WEBPACK_IMPORTED_MODULE_6__.rowTotals)(rows, columns);
|
|
5759
|
+
const hasTotals = Object.keys(totals).length > 0;
|
|
5760
|
+
const template = `${columns.map(track).join(' ')}${editing ? ' auto' : ''}`; // Every cell's mistake, by row and column, reported as one for the field:
|
|
5761
|
+
// the field holds the save while any cell does.
|
|
5762
|
+
|
|
5763
|
+
const errors = cellErrorsOf(node, key);
|
|
5764
|
+
|
|
5765
|
+
const reportCells = () => {
|
|
5766
|
+
const any = [...errors.values()].some(Boolean);
|
|
5767
|
+
host.setFieldError?.(field, any ? word(node, 'cellsWrong') : null);
|
|
5768
|
+
};
|
|
5769
|
+
|
|
5770
|
+
const writeRows = next => {
|
|
5771
|
+
const computed = next.map(row => (0,_rows_js__WEBPACK_IMPORTED_MODULE_6__.computeRow)(row, columns, locale));
|
|
5772
|
+
host.setFieldValue(field, computed.length ? computed : null);
|
|
5773
|
+
};
|
|
5774
|
+
|
|
5775
|
+
const writeCell = (index, column, cell) => {
|
|
5776
|
+
const next = drawn.map(row => ({ ...row
|
|
5777
|
+
}));
|
|
5778
|
+
if (cell === null || typeof cell === 'undefined' || cell === '') delete next[index][column.key];else next[index][column.key] = cell;
|
|
5779
|
+
writeRows(next.slice(0, Math.max(rows.length, index + 1)));
|
|
5780
|
+
}; // Rows move: what was typed in a cell and is not a value yet goes with the
|
|
5781
|
+
// cell's place, so the drafts of this field are dropped.
|
|
5782
|
+
|
|
5783
|
+
|
|
5784
|
+
const reshape = next => {
|
|
5785
|
+
for (const path of [...draftsOf(node).keys()]) if (path.startsWith(`${key}[`)) draftsOf(node).delete(path);
|
|
5786
|
+
|
|
5787
|
+
for (const path of [...leftOf(node)]) if (path.startsWith(`${key}[`)) leftOf(node).delete(path);
|
|
5788
|
+
|
|
5789
|
+
errors.clear();
|
|
5790
|
+
reportCells();
|
|
5791
|
+
writeRows(next);
|
|
5792
|
+
};
|
|
5793
|
+
|
|
5794
|
+
const cell = (row, index, column) => {
|
|
5795
|
+
const path = `${key}[${index}].${column.key}`;
|
|
5796
|
+
const value = row[column.key];
|
|
5797
|
+
|
|
5798
|
+
if (!editing || column.compute || field.readonly === true || column.readonly === true) {
|
|
5799
|
+
const text = cellText(column, column.compute && editing ? (0,_rows_js__WEBPACK_IMPORTED_MODULE_6__.computeRow)(row, columns, locale)[column.key] : value, columns, locale, ctx.viewHost);
|
|
5800
|
+
return (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="sf-view-items-text ${column.compute ? 'color-on-surface-variant' : ''}" data-computed=${column.compute ? 'true' : lit__WEBPACK_IMPORTED_MODULE_0__.nothing}>${text ?? (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="color-on-surface-variant">—</span>`}</span>`;
|
|
5801
|
+
}
|
|
5802
|
+
|
|
5803
|
+
const cellField = { ...column,
|
|
5804
|
+
key: path,
|
|
5805
|
+
label: column.label || column.key,
|
|
5806
|
+
value
|
|
5807
|
+
};
|
|
5808
|
+
const cellHost = {
|
|
5809
|
+
setFieldValue: (_target, next) => writeCell(index, column, next),
|
|
5810
|
+
setFieldError: (_target, message) => {
|
|
5811
|
+
errors.set(path, message || null);
|
|
5812
|
+
reportCells();
|
|
5813
|
+
}
|
|
5814
|
+
};
|
|
5815
|
+
const cellCtx = { ...ctx,
|
|
5816
|
+
path
|
|
5817
|
+
};
|
|
5818
|
+
|
|
5819
|
+
switch (column.propertyType) {
|
|
5820
|
+
case 'money':
|
|
5821
|
+
return renderMoneyEdit({ ...cellField,
|
|
5822
|
+
currency: column.currency
|
|
5823
|
+
}, value, cellHost, cellCtx);
|
|
5824
|
+
|
|
5825
|
+
case 'percent':
|
|
5826
|
+
return renderPercentEdit(cellField, value, cellHost, cellCtx);
|
|
5827
|
+
|
|
5828
|
+
case 'number':
|
|
5829
|
+
return renderDecimalEdit(cellField, value, cellHost, cellCtx);
|
|
5830
|
+
|
|
5831
|
+
default:
|
|
5832
|
+
{
|
|
5833
|
+
const control = (0,_field_renderers_index_js__WEBPACK_IMPORTED_MODULE_2__.renderEditField)(cellField, value, cellHost, {
|
|
5834
|
+
size: ctx.size
|
|
5835
|
+
});
|
|
5836
|
+
return control ?? (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="sf-view-items-text">${cellText(column, value, columns, locale, ctx.viewHost) ?? '—'}</span>`;
|
|
5837
|
+
}
|
|
5838
|
+
}
|
|
5839
|
+
};
|
|
5840
|
+
|
|
5841
|
+
const rowActions = index => (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`
|
|
5842
|
+
<span class="sf-view-items-actions flex items-cross-center gap-1/4" role="cell">
|
|
5843
|
+
<sf-button-icon size="1/2" appearance="link" scheme="secondary" icon="keyboard_arrow_up"
|
|
5844
|
+
data-action="row-up" ?disabled=${index === 0 || index >= rows.length}
|
|
5845
|
+
title=${word(node, 'rowUp')} aria-label=${word(node, 'rowUp')}
|
|
5846
|
+
@click=${() => {
|
|
5847
|
+
const next = rows.slice();
|
|
5848
|
+
[next[index - 1], next[index]] = [next[index], next[index - 1]];
|
|
5849
|
+
reshape(next);
|
|
5850
|
+
}}></sf-button-icon>
|
|
5851
|
+
<sf-button-icon size="1/2" appearance="link" scheme="secondary" icon="keyboard_arrow_down"
|
|
5852
|
+
data-action="row-down" ?disabled=${index >= rows.length - 1}
|
|
5853
|
+
title=${word(node, 'rowDown')} aria-label=${word(node, 'rowDown')}
|
|
5854
|
+
@click=${() => {
|
|
5855
|
+
const next = rows.slice();
|
|
5856
|
+
[next[index + 1], next[index]] = [next[index], next[index + 1]];
|
|
5857
|
+
reshape(next);
|
|
5858
|
+
}}></sf-button-icon>
|
|
5859
|
+
<sf-button-icon size="1/2" appearance="link" scheme="secondary" icon="delete"
|
|
5860
|
+
data-action="row-remove" ?disabled=${drawn.length <= minRows || index >= rows.length}
|
|
5861
|
+
title=${word(node, 'removeRow')} aria-label=${word(node, 'removeRow')}
|
|
5862
|
+
@click=${() => reshape(rows.filter((_row, at) => at !== index))}></sf-button-icon>
|
|
5863
|
+
</span>
|
|
5864
|
+
`;
|
|
5865
|
+
|
|
5866
|
+
return (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`
|
|
5867
|
+
<span class="sf-view-items-box">
|
|
5868
|
+
<span class="sf-view-items ${editing ? 'sf-view-items--edit' : ''}" data-items=${key} role="table"
|
|
5869
|
+
aria-label=${field.label || key} style=${`--sf-view-items-columns: ${template}`}>
|
|
5870
|
+
<span class="sf-view-items-head" role="row">
|
|
5871
|
+
${columns.map(column => (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="sf-view-items-heading ${_rows_js__WEBPACK_IMPORTED_MODULE_6__.NUMERIC.has(column.propertyType) ? 'sf-view-items-numeric' : ''}" role="columnheader">${column.label || column.key}${editing && column.required && !column.compute ? (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="color-error" aria-hidden="true"> *</span>` : lit__WEBPACK_IMPORTED_MODULE_0__.nothing}</span>`)}
|
|
5872
|
+
${editing ? (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="sf-view-items-heading" role="columnheader"></span>` : lit__WEBPACK_IMPORTED_MODULE_0__.nothing}
|
|
5873
|
+
</span>
|
|
5874
|
+
${drawn.map((row, index) => (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`
|
|
5875
|
+
<span class="sf-view-items-row" role="row" data-row=${index} aria-label=${word(node, 'row', {
|
|
5876
|
+
n: index + 1
|
|
5877
|
+
})}>
|
|
5878
|
+
${columns.map(column => (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`
|
|
5879
|
+
<span class="sf-view-items-cell ${_rows_js__WEBPACK_IMPORTED_MODULE_6__.NUMERIC.has(column.propertyType) ? 'sf-view-items-numeric' : ''}" role="cell" data-column=${column.key}>
|
|
5880
|
+
<span class="sf-view-items-cell-label color-on-surface-variant" aria-hidden="true">${column.label || column.key}</span>
|
|
5881
|
+
${cell(row, index, column)}
|
|
5882
|
+
</span>`)}
|
|
5883
|
+
${editing ? rowActions(index) : lit__WEBPACK_IMPORTED_MODULE_0__.nothing}
|
|
5884
|
+
</span>`)}
|
|
5885
|
+
${hasTotals && rows.length ? (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`
|
|
5886
|
+
<span class="sf-view-items-row sf-view-items-totals" role="row" data-totals="true">
|
|
5887
|
+
${columns.map((column, at) => (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`
|
|
5888
|
+
<span class="sf-view-items-cell ${_rows_js__WEBPACK_IMPORTED_MODULE_6__.NUMERIC.has(column.propertyType) ? 'sf-view-items-numeric' : ''} ${Object.hasOwn(totals, column.key) ? '' : 'sf-view-items-cell--blank'}" role="cell" data-column=${column.key}>
|
|
5889
|
+
${Object.hasOwn(totals, column.key) ? (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="sf-view-items-cell-label color-on-surface-variant" aria-hidden="true">${word(node, 'total')}: ${column.label || column.key}</span><span class="sf-view-items-text sf-view-items-total">${totalText(column, totals[column.key], columns, locale)}</span>` : at === 0 ? (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="sf-view-items-text sf-view-items-total-word">${word(node, 'total')}</span>` : lit__WEBPACK_IMPORTED_MODULE_0__.nothing}
|
|
5890
|
+
</span>`)}
|
|
5891
|
+
${editing ? (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span role="cell"></span>` : lit__WEBPACK_IMPORTED_MODULE_0__.nothing}
|
|
5892
|
+
</span>` : lit__WEBPACK_IMPORTED_MODULE_0__.nothing}
|
|
5893
|
+
${editing ? (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`
|
|
5894
|
+
<span class="sf-view-items-foot flex items-cross-center gap-1">
|
|
5895
|
+
<sf-button appearance="outline" size=${ctx.size} icon="add" text=${word(node, 'addRow')}
|
|
5896
|
+
data-action="row-add" ?disabled=${drawn.length >= maxRows}
|
|
5897
|
+
@click=${() => reshape([...drawn, {}])}></sf-button>
|
|
5898
|
+
</span>` : lit__WEBPACK_IMPORTED_MODULE_0__.nothing}
|
|
5899
|
+
</span>
|
|
5900
|
+
</span>
|
|
5901
|
+
`;
|
|
5902
|
+
}
|
|
5903
|
+
|
|
5904
|
+
const CELL_ERRORS = new WeakMap();
|
|
5905
|
+
|
|
5906
|
+
function cellErrorsOf(node, key) {
|
|
5907
|
+
if (!CELL_ERRORS.has(node)) CELL_ERRORS.set(node, new Map());
|
|
5908
|
+
const all = CELL_ERRORS.get(node);
|
|
5909
|
+
if (!all.has(key)) all.set(key, new Map());
|
|
5910
|
+
return all.get(key);
|
|
5911
|
+
}
|
|
5912
|
+
|
|
5913
|
+
function renderItemsEdit(field, value, host, ctx) {
|
|
5914
|
+
return renderItemsTable(field, (0,_rows_js__WEBPACK_IMPORTED_MODULE_6__.rowsOf)(value), (0,_rows_js__WEBPACK_IMPORTED_MODULE_6__.columnsOf)(field), ctx, {
|
|
5915
|
+
editing: true,
|
|
5916
|
+
host
|
|
5917
|
+
});
|
|
5918
|
+
}
|
|
5919
|
+
|
|
5920
|
+
function renderItemsView(field, value, ctx) {
|
|
5921
|
+
const rows = (0,_rows_js__WEBPACK_IMPORTED_MODULE_6__.rowsOf)(value);
|
|
5922
|
+
if (!rows.length) return lit__WEBPACK_IMPORTED_MODULE_0__.nothing;
|
|
5923
|
+
if (ctx.summary) return (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="sf-field-view">${itemsSummary(field, rows, (0,_rows_js__WEBPACK_IMPORTED_MODULE_6__.columnsOf)(field), ctx)}</span>`;
|
|
5924
|
+
return renderItemsTable(field, rows, (0,_rows_js__WEBPACK_IMPORTED_MODULE_6__.columnsOf)(field), ctx, {
|
|
5925
|
+
editing: false,
|
|
5926
|
+
host: null
|
|
5927
|
+
});
|
|
5928
|
+
} // --- compound: a fixed set of parts, one value --------------------------------------
|
|
5929
|
+
// The parts of a requisites field, in the standard's order, of those the field
|
|
5930
|
+
// names (`parts`; all six when it names none). Each is typed as digits, the КПП
|
|
5931
|
+
// as digits and capital letters.
|
|
5932
|
+
|
|
5933
|
+
|
|
5934
|
+
const REQUISITE_LENGTH = {
|
|
5935
|
+
inn: 12,
|
|
5936
|
+
kpp: 9,
|
|
5937
|
+
ogrn: 15,
|
|
5938
|
+
bik: 9,
|
|
5939
|
+
account: 20,
|
|
5940
|
+
corr_account: 20
|
|
5941
|
+
};
|
|
5942
|
+
|
|
5943
|
+
function requisiteParts(field) {
|
|
5944
|
+
const named = Array.isArray(field.parts) ? field.parts.map(String) : _requisites_js__WEBPACK_IMPORTED_MODULE_7__.REQUISITE_PARTS;
|
|
5945
|
+
return _requisites_js__WEBPACK_IMPORTED_MODULE_7__.REQUISITE_PARTS.filter(part => named.includes(part));
|
|
5946
|
+
}
|
|
5947
|
+
|
|
5948
|
+
function compoundParts(field) {
|
|
5949
|
+
return (Array.isArray(field.parts) ? field.parts : []).map(part => part && typeof part === 'object' ? { ...part,
|
|
5950
|
+
propertyType: part.propertyType || part.type
|
|
5951
|
+
} : null).filter(part => part?.key);
|
|
5952
|
+
}
|
|
5953
|
+
|
|
5954
|
+
function objectOf(value) {
|
|
5955
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
5956
|
+
} // The value written: the parts in their order, an empty part no key, and
|
|
5957
|
+
// nothing at all when every part is empty.
|
|
5958
|
+
|
|
5959
|
+
|
|
5960
|
+
function compoundValue(order, value) {
|
|
5961
|
+
const next = {};
|
|
5962
|
+
|
|
5963
|
+
for (const part of order) {
|
|
5964
|
+
const one = value[part];
|
|
5965
|
+
if (one !== null && typeof one !== 'undefined' && one !== '') next[part] = one;
|
|
5966
|
+
}
|
|
5967
|
+
|
|
5968
|
+
return Object.keys(next).length ? next : null;
|
|
5969
|
+
}
|
|
5970
|
+
|
|
5971
|
+
function renderRequisitesEdit(field, value, host, ctx) {
|
|
5972
|
+
const node = ctx.node;
|
|
5973
|
+
const key = String(field.key ?? '');
|
|
5974
|
+
const parts = requisiteParts(field);
|
|
5975
|
+
const held = objectOf(value);
|
|
5976
|
+
const errors = (0,_requisites_js__WEBPACK_IMPORTED_MODULE_7__.requisiteErrors)(held, parts);
|
|
5977
|
+
|
|
5978
|
+
const write = (part, text) => {
|
|
5979
|
+
const cleaned = part === 'kpp' ? text.replace(/\s/gu, '').toUpperCase() : text.replace(/\D/gu, '');
|
|
5980
|
+
const next = compoundValue(parts, { ...held,
|
|
5981
|
+
[part]: cleaned
|
|
5982
|
+
});
|
|
5983
|
+
const mistakes = (0,_requisites_js__WEBPACK_IMPORTED_MODULE_7__.requisiteErrors)(next ?? {}, parts); // Nothing typed in a field that is not required is no mistake.
|
|
5984
|
+
|
|
5985
|
+
const blank = next === null && field.required !== true;
|
|
5986
|
+
host.setFieldValue(field, next);
|
|
5987
|
+
host.setFieldError?.(field, !blank && Object.keys(mistakes).length ? word(node, mistakes[Object.keys(mistakes)[0]]) : null);
|
|
5988
|
+
};
|
|
5989
|
+
|
|
5990
|
+
return (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`
|
|
5991
|
+
<span class="sf-view-fields-compound grid gap-1 w-full min-w-0" data-compound=${key}>
|
|
5992
|
+
${parts.map(part => {
|
|
5993
|
+
const path = `${key}.${part}`;
|
|
5994
|
+
const left = leftOf(node).has(path);
|
|
5995
|
+
const blank = Object.keys(held).length === 0 && field.required !== true;
|
|
5996
|
+
const message = left && !blank && errors[part] ? word(node, errors[part]) : '';
|
|
5997
|
+
return (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`
|
|
5998
|
+
<span class="sf-view-fields-part flex flex-col gap-1/4 min-w-0 ${part === 'account' || part === 'corr_account' ? 'sf-view-fields-part--wide' : ''}" data-part=${part}>
|
|
5999
|
+
<span class="sf-view-fields-part-label color-on-surface-variant">${word(node, part)}${part === 'inn' && field.required ? (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="color-error" aria-hidden="true"> *</span>` : lit__WEBPACK_IMPORTED_MODULE_0__.nothing}</span>
|
|
6000
|
+
<sf-input
|
|
6001
|
+
size=${ctx.size}
|
|
6002
|
+
appearance="bordered"
|
|
6003
|
+
inputmode=${part === 'kpp' ? 'text' : 'numeric'}
|
|
6004
|
+
maxlength=${String(REQUISITE_LENGTH[part])}
|
|
6005
|
+
value=${String(held[part] ?? '')}
|
|
6006
|
+
?required=${part === 'inn' && field.required === true}
|
|
6007
|
+
?invalid=${Boolean(message)}
|
|
6008
|
+
error-message=${message || lit__WEBPACK_IMPORTED_MODULE_0__.nothing}
|
|
6009
|
+
aria-label=${`${field.label || key}: ${word(node, part)}`}
|
|
6010
|
+
@input=${event => write(part, String(event.target?.value ?? ''))}
|
|
6011
|
+
@change=${event => write(part, String(event.target?.value ?? ''))}
|
|
6012
|
+
@focusout=${() => {
|
|
6013
|
+
leftOf(node).add(path);
|
|
6014
|
+
redraw(node);
|
|
6015
|
+
}}
|
|
6016
|
+
></sf-input>
|
|
6017
|
+
</span>`;
|
|
6018
|
+
})}
|
|
6019
|
+
</span>
|
|
6020
|
+
`;
|
|
6021
|
+
}
|
|
6022
|
+
|
|
6023
|
+
function requisitesText(field, value, node) {
|
|
6024
|
+
const held = objectOf(value);
|
|
6025
|
+
return requisiteParts(field).filter(part => held[part]).map(part => `${word(node, part)} ${held[part]}`).join(', ');
|
|
6026
|
+
}
|
|
6027
|
+
|
|
6028
|
+
function renderRequisitesView(field, value, ctx) {
|
|
6029
|
+
const text = requisitesText(field, value, ctx.node);
|
|
6030
|
+
return text ? (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="sf-field-view">${text}</span>` : lit__WEBPACK_IMPORTED_MODULE_0__.nothing;
|
|
6031
|
+
}
|
|
6032
|
+
|
|
6033
|
+
function renderCompoundEdit(field, value, host, ctx) {
|
|
6034
|
+
const node = ctx.node;
|
|
6035
|
+
const key = String(field.key ?? '');
|
|
6036
|
+
const parts = compoundParts(field);
|
|
6037
|
+
const order = parts.map(part => part.key);
|
|
6038
|
+
const held = objectOf(value);
|
|
6039
|
+
const errors = cellErrorsOf(node, key);
|
|
6040
|
+
return (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`
|
|
6041
|
+
<span class="sf-view-fields-compound grid gap-1 w-full min-w-0" data-compound=${key}>
|
|
6042
|
+
${parts.map(part => {
|
|
6043
|
+
const path = `${key}.${part.key}`;
|
|
6044
|
+
const partField = { ...part,
|
|
6045
|
+
key: path,
|
|
6046
|
+
label: part.label || part.key,
|
|
6047
|
+
readonly: field.readonly === true || part.readonly === true
|
|
6048
|
+
};
|
|
6049
|
+
const partHost = {
|
|
6050
|
+
setFieldValue: (_target, next) => host.setFieldValue(field, compoundValue(order, { ...held,
|
|
6051
|
+
[part.key]: next
|
|
6052
|
+
})),
|
|
6053
|
+
setFieldError: (_target, message) => {
|
|
6054
|
+
errors.set(path, message || null);
|
|
6055
|
+
const first = [...errors.values()].find(Boolean);
|
|
6056
|
+
host.setFieldError?.(field, first ?? null);
|
|
6057
|
+
}
|
|
6058
|
+
};
|
|
6059
|
+
const partCtx = { ...ctx,
|
|
6060
|
+
path
|
|
6061
|
+
};
|
|
6062
|
+
const control = SET_CONTROLS[part.propertyType]?.edit(partField, held[part.key], partHost, partCtx) ?? (0,_field_renderers_index_js__WEBPACK_IMPORTED_MODULE_2__.renderEditField)(partField, held[part.key], partHost, {
|
|
6063
|
+
size: ctx.size
|
|
6064
|
+
});
|
|
6065
|
+
return (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`
|
|
6066
|
+
<span class="sf-view-fields-part flex flex-col gap-1/4 min-w-0 ${part.width === 'full' ? 'sf-view-fields-part--wide' : ''}" data-part=${part.key}>
|
|
6067
|
+
<span class="sf-view-fields-part-label color-on-surface-variant">${partField.label}${part.required ? (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="color-error" aria-hidden="true"> *</span>` : lit__WEBPACK_IMPORTED_MODULE_0__.nothing}</span>
|
|
6068
|
+
${control ?? lit__WEBPACK_IMPORTED_MODULE_0__.nothing}
|
|
6069
|
+
</span>`;
|
|
6070
|
+
})}
|
|
6071
|
+
</span>
|
|
6072
|
+
`;
|
|
6073
|
+
}
|
|
6074
|
+
|
|
6075
|
+
function renderCompoundView(field, value, ctx) {
|
|
6076
|
+
const held = objectOf(value);
|
|
6077
|
+
const shown = compoundParts(field).filter(part => held[part.key] !== null && typeof held[part.key] !== 'undefined' && held[part.key] !== '');
|
|
6078
|
+
if (!shown.length) return lit__WEBPACK_IMPORTED_MODULE_0__.nothing;
|
|
6079
|
+
return (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="sf-field-view sf-view-fields-compound-view">${shown.map((part, at) => {
|
|
6080
|
+
const own = SET_CONTROLS[part.propertyType]?.view({ ...part
|
|
6081
|
+
}, held[part.key], ctx);
|
|
6082
|
+
const content = own ?? (0,_field_renderers_index_js__WEBPACK_IMPORTED_MODULE_2__.renderViewField)({ ...part
|
|
6083
|
+
}, held[part.key], ctx.viewHost, {
|
|
6084
|
+
size: ctx.size
|
|
6085
|
+
}) ?? String(held[part.key]);
|
|
6086
|
+
return (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`${at ? ', ' : ''}<span class="color-on-surface-variant">${part.label || part.key}</span> ${content}`;
|
|
6087
|
+
})}</span>`;
|
|
6088
|
+
} // --- the map ---------------------------------------------------------------------
|
|
6089
|
+
|
|
6090
|
+
|
|
6091
|
+
const SET_CONTROLS = {
|
|
6092
|
+
money: {
|
|
6093
|
+
edit: renderMoneyEdit,
|
|
6094
|
+
view: renderMoneyView
|
|
6095
|
+
},
|
|
6096
|
+
percent: {
|
|
6097
|
+
edit: renderPercentEdit,
|
|
6098
|
+
view: renderPercentView
|
|
6099
|
+
},
|
|
6100
|
+
items: {
|
|
6101
|
+
edit: renderItemsEdit,
|
|
6102
|
+
view: renderItemsView
|
|
6103
|
+
},
|
|
6104
|
+
compound: {
|
|
6105
|
+
edit: renderCompoundEdit,
|
|
6106
|
+
view: renderCompoundView
|
|
6107
|
+
},
|
|
6108
|
+
'ru.requisites': {
|
|
6109
|
+
edit: renderRequisitesEdit,
|
|
6110
|
+
view: renderRequisitesView
|
|
6111
|
+
}
|
|
6112
|
+
};
|
|
6113
|
+
/** Whether the set draws this property type itself. */
|
|
6114
|
+
|
|
6115
|
+
function drawsSetField(field) {
|
|
6116
|
+
return Object.hasOwn(SET_CONTROLS, String(field?.propertyType || field?.type || ''));
|
|
6117
|
+
}
|
|
6118
|
+
/**
|
|
6119
|
+
* A field of a type the set draws, edited or shown. `ctx` is {node, size,
|
|
6120
|
+
* viewHost, disabled}: the element whose page language the words follow, the
|
|
6121
|
+
* size on the ladder, the host's formatFieldValue, and whether a condition
|
|
6122
|
+
* turns the field off. A field the person may not change is shown, as the
|
|
6123
|
+
* Framework renderers show one.
|
|
6124
|
+
*/
|
|
6125
|
+
|
|
6126
|
+
function renderSetField(field, value, editing, host, ctx) {
|
|
6127
|
+
const control = SET_CONTROLS[String(field.propertyType || field.type)];
|
|
6128
|
+
if (!control) return null;
|
|
6129
|
+
const formatted = !editing ? ctx.viewHost?.formatFieldValue?.(field, value) : null;
|
|
6130
|
+
if (typeof formatted === 'string' && formatted !== '') return (0,lit__WEBPACK_IMPORTED_MODULE_0__.html)`<span class="sf-field-view">${formatted}</span>`;
|
|
6131
|
+
|
|
6132
|
+
if (editing && field.readonly !== true && ctx.disabled !== true && host?.setFieldValue) {
|
|
6133
|
+
return control.edit(field, value, host, ctx);
|
|
6134
|
+
}
|
|
6135
|
+
|
|
6136
|
+
return control.view(field, value, ctx);
|
|
6137
|
+
}
|
|
6138
|
+
/** A field's value as one line of text: «1 500,50 ₽», «2 строки, итого 2 499,99 ₽». */
|
|
6139
|
+
|
|
6140
|
+
function setFieldText(field, value, node) {
|
|
6141
|
+
const locale = (0,_core_js_page_language__WEBPACK_IMPORTED_MODULE_3__.pageLocale)(node);
|
|
6142
|
+
|
|
6143
|
+
switch (String(field?.propertyType || field?.type || '')) {
|
|
6144
|
+
case 'money':
|
|
6145
|
+
return moneyText(field, value, locale);
|
|
6146
|
+
|
|
6147
|
+
case 'percent':
|
|
6148
|
+
return (0,_money_js__WEBPACK_IMPORTED_MODULE_5__.percentText)(value, locale);
|
|
6149
|
+
|
|
6150
|
+
case 'items':
|
|
6151
|
+
{
|
|
6152
|
+
const rows = (0,_rows_js__WEBPACK_IMPORTED_MODULE_6__.rowsOf)(value);
|
|
6153
|
+
return rows.length ? itemsSummary(field, rows, (0,_rows_js__WEBPACK_IMPORTED_MODULE_6__.columnsOf)(field), {
|
|
6154
|
+
node
|
|
6155
|
+
}) : '';
|
|
6156
|
+
}
|
|
6157
|
+
|
|
6158
|
+
case 'ru.requisites':
|
|
6159
|
+
return requisitesText(field, value, node);
|
|
6160
|
+
|
|
6161
|
+
default:
|
|
6162
|
+
return null;
|
|
6163
|
+
}
|
|
6164
|
+
}
|
|
6165
|
+
__webpack_async_result__();
|
|
6166
|
+
} catch(e) { __webpack_async_result__(e); } });
|
|
6167
|
+
|
|
6168
|
+
/***/ },
|
|
6169
|
+
|
|
4631
6170
|
/***/ "2f31b00ad99a"
|
|
4632
6171
|
(module, __webpack_exports__, __webpack_require__) {
|
|
4633
6172
|
|
|
@@ -4703,6 +6242,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4703
6242
|
// extracted by mini-css-extract-plugin
|
|
4704
6243
|
|
|
4705
6244
|
|
|
6245
|
+
/***/ },
|
|
6246
|
+
|
|
6247
|
+
/***/ "f59c8bcdc90a"
|
|
6248
|
+
(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
|
6249
|
+
|
|
6250
|
+
__webpack_require__.r(__webpack_exports__);
|
|
6251
|
+
// extracted by mini-css-extract-plugin
|
|
6252
|
+
|
|
6253
|
+
|
|
4706
6254
|
/***/ },
|
|
4707
6255
|
|
|
4708
6256
|
/***/ "5b7d7695b41b"
|
|
@@ -5665,7 +7213,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
5665
7213
|
/***/ "e4c87bda9c30"
|
|
5666
7214
|
(module) {
|
|
5667
7215
|
|
|
5668
|
-
module.exports = /*#__PURE__*/JSON.parse('{"id":"smart.view-flow","tag":"sf-view-flow","version":"1.
|
|
7216
|
+
module.exports = /*#__PURE__*/JSON.parse('{"id":"smart.view-flow","tag":"sf-view-flow","version":"1.1.0","kind":"leaf","settings":{"mode":{"type":"enum","values":["view","edit"],"default":"view"},"heading":{"type":"string","default":""},"heading-level":{"type":"enum","values":["2","3","4","5","6"],"default":"3"},"fields":{"type":"list","default":[],"of":{"key":"string","label":{"type":"string","optional":true},"propertyType":"string","value":{"type":"any","nullable":true,"optional":true},"required":{"type":"boolean","optional":true},"readonly":{"type":"boolean","optional":true},"width":{"type":"string","optional":true},"hint":{"type":"string","optional":true},"when":{"type":"object","optional":true}}},"groups":{"type":"list","default":[],"of":{"key":"string","label":{"type":"string","optional":true},"collapsible":{"type":"boolean","optional":true},"collapsed":{"type":"boolean","optional":true},"fields":"list"}},"state":{"type":"enum","values":["open","pending","accepted","declined","expired"],"default":"open"},"expires-at":{"type":"date","optional":true},"block-id":{"type":"id","default":""},"disabled":{"type":"boolean","default":false},"size":{"type":"enum","values":["1","1/2"],"default":"1/2"},"cancelable":{"type":"boolean","default":true},"submit-text":{"type":"string","default-from":"runtime.submit-text"},"cancel-text":{"type":"string","default-from":"runtime.cancel-text"},"empty-text":{"type":"string","default-from":"runtime.empty-text"},"required-text":{"type":"string","default-from":"runtime.required-text"},"invalid-text":{"type":"string","default-from":"runtime.invalid-text"}},"values":{},"events":{"answer":{"carries":{"id":{"type":"id"},"accepted":"boolean","values":{"type":"object","optional":true}},"cancelable":true},"expired":{"carries":{"id":{"type":"id"}},"own-verb":true},"open":{"carries":{"id":{"type":"id"},"field":"string","value":"object"}}},"actions":{"open":{},"answer":{"with":{"accepted":"boolean"},"emits":"answer"},"confirm":{},"cancel":{},"settle":{"with":{"result":"object"}}},"layer":{"kind":"surface","locks-page":false,"traps-focus":false},"host-states":{"data-state":"string"},"css-variables":{"--sf-view-flow-radius":{"type":"length","state":"default"},"--sf-view-flow-inset":{"type":"length","state":"default"},"--sf-view-flow-gap":{"type":"length","state":"default"},"--sf-view-flow-background-color":{"type":"color","state":"default"},"--sf-view-flow-border-color":{"type":"color","state":"default"}}}');
|
|
5669
7217
|
|
|
5670
7218
|
/***/ },
|
|
5671
7219
|
|