@micromerce/formbuilder-react 1.0.1019 → 1.0.1021

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/dist/index.d.ts CHANGED
@@ -18,13 +18,11 @@ import { queryControl } from "./components/QueryControl/data/defaultControls";
18
18
  import { FormBuilderConfig } from "./types";
19
19
  import { compactVatId, vatIdProblem } from "./components/controls/SubtypeInput/vatId";
20
20
  import type { VatIdProblem } from "./components/controls/SubtypeInput/vatId";
21
- import { DUE_SOON_DAYS, PAYMENT_PILLS, PAYMENT_TONES, formatAmount, formatPaymentDate, parseAmount, paymentFieldsOf, paymentLines, paymentState, paymentTotal, comparesWithAccount, DEFAULT_ACCOUNT_CURRENCY, transactionRefsOf } from "./utils/payment";
22
- import type { IPaymentValues, PaymentRole, PaymentState, PaymentTone } from "./utils/payment";
23
21
  import { getCountries, parsePhoneNumber } from "react-phone-number-input/max";
24
22
  import PHONE_FLAGS from "react-phone-number-input/flags";
25
23
  import { SOCIAL_NETWORKS, handleOf, isValidSocialLink, networkOf } from "./utils/subtypes/socialNetworks";
26
24
  import { FormBuilderThemeProvider, FORM_BUILDER_TOKENS, LEGACY_CSS_VARS, toCssVars } from "./theme";
27
25
  import type { FormBuilderTheme, FormBuilderThemeKey, FormBuilderThemePreset } from "./theme";
28
- export type { FormBuilderTheme, FormBuilderThemeKey, FormBuilderThemePreset, VatIdProblem, IPaymentValues, PaymentRole, PaymentState, PaymentTone, };
29
- export { FormBuilderThemeProvider, FORM_BUILDER_TOKENS, LEGACY_CSS_VARS, toCssVars, FormBuilder, FormBuilderConfig, queryControl, Select, MultiSelect, Checkbox, ControlWrapper, FormFooter, Input, InputFreeSolo, FormList, FormGroup, MrnInput, PasswordInput, Textarea, TrafficLightCardSelect, useValueGenerator, compactVatId, vatIdProblem, SOCIAL_NETWORKS, isValidSocialLink, networkOf, handleOf, parsePhoneNumber, getCountries, PHONE_FLAGS, DUE_SOON_DAYS, PAYMENT_PILLS, PAYMENT_TONES, formatAmount, formatPaymentDate, parseAmount, paymentFieldsOf, paymentLines, paymentState, paymentTotal, comparesWithAccount, DEFAULT_ACCOUNT_CURRENCY, transactionRefsOf, };
26
+ export type { FormBuilderTheme, FormBuilderThemeKey, FormBuilderThemePreset, VatIdProblem };
27
+ export { FormBuilderThemeProvider, FORM_BUILDER_TOKENS, LEGACY_CSS_VARS, toCssVars, FormBuilder, FormBuilderConfig, queryControl, Select, MultiSelect, Checkbox, ControlWrapper, FormFooter, Input, InputFreeSolo, FormList, FormGroup, MrnInput, PasswordInput, Textarea, TrafficLightCardSelect, useValueGenerator, compactVatId, vatIdProblem, SOCIAL_NETWORKS, isValidSocialLink, networkOf, handleOf, parsePhoneNumber, getCountries, PHONE_FLAGS, };
30
28
  export default FormBuilder;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromerce/formbuilder-react",
3
- "version": "1.0.1019",
3
+ "version": "1.0.1021",
4
4
  "description": "creates a form based on configuration",
5
5
  "main": "dist/formbuilder.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,22 +0,0 @@
1
- import React from "react";
2
- import type { controlProps } from "../../../types/controlProps";
3
- import { GroupFormControl } from "../../../types";
4
- export interface IProps {
5
- id: string;
6
- control: GroupFormControl;
7
- objectPathId?: string;
8
- groupIsRequired?: boolean;
9
- isInRequiredGroup?: boolean;
10
- isInGroup?: boolean;
11
- controlProps?: controlProps;
12
- helper?: string;
13
- }
14
- /**
15
- * The payment of an invoice as one block (`custom-attributes.type: "payment"` on a group, COP-4613): due
16
- * date, payment date and method side by side, the linked transactions below, any other child on a row of
17
- * its own. Each field keeps its name as a small caption above it (a date input shows no placeholder). The
18
- * group only lays out its fields; the state (paid, open, overdue, paid without a linked transaction) is
19
- * shown by service-entity's detail view, which reads the same roles.
20
- */
21
- declare const PaymentGroup: ({ id, control, objectPathId, groupIsRequired, isInRequiredGroup, isInGroup, controlProps, helper, }: IProps) => React.JSX.Element;
22
- export default PaymentGroup;
@@ -1,102 +0,0 @@
1
- /**
2
- * The payment type (COP-4613): the rules of an invoice's payment state, shared by the form (PaymentGroup's
3
- * live pill and hint) and service-entity's detail view (exported from the package), so the two never
4
- * judge a payment differently. Nothing here writes a value; it only reads what the invoice holds.
5
- */
6
- export declare const PAYMENT_ROLES: readonly ["due", "paidOn", "method", "transactions", "amount", "currency"];
7
- export type PaymentRole = (typeof PAYMENT_ROLES)[number];
8
- /** The field of each role: `custom-attributes.fields`, else the defaults of the form (anchor or group). */
9
- export declare const paymentFieldsOf: (customAttributes: unknown, isGroup?: boolean) => Partial<Record<PaymentRole, string>>;
10
- export interface IPaymentValues {
11
- due?: string;
12
- paidOn?: string;
13
- /** The stored value of the payment method. */
14
- method?: string;
15
- /** Its option text, for the lines. */
16
- methodText?: string;
17
- transactions: string[];
18
- /**
19
- * Whether a payment is expected to be linked to a transaction: false when the form has no field for the
20
- * transactions, or `custom-attributes.unlinkedPayment` is "ignore". Then a payment date alone means paid.
21
- */
22
- linksTransactions?: boolean;
23
- /** The invoice's currency (role "currency", an ISO code); another than the account's skips the total check. */
24
- currency?: string;
25
- }
26
- export type PaymentState = {
27
- kind: "paid";
28
- } | {
29
- kind: "paidUnlinked";
30
- } | {
31
- kind: "expected";
32
- } | {
33
- kind: "overdue";
34
- days: number;
35
- } | {
36
- kind: "dueSoon";
37
- days: number;
38
- } | {
39
- kind: "open";
40
- };
41
- export declare const isPaymentDate: (value?: string) => boolean;
42
- /** "27.11.2026"; empty for no date. */
43
- export declare const formatPaymentDate: (value?: string) => string;
44
- /** Days until the date (negative: past); undefined for no date. */
45
- export declare const daysUntil: (value: string | undefined, today?: Date) => number | undefined;
46
- /** An open invoice due within this many days (inclusive) is due soon. */
47
- export declare const DUE_SOON_DAYS = 7;
48
- /**
49
- * The state of a payment. Paid wins (a payment date is set): linked to a transaction or not — the unlinked
50
- * case is the one that made invoices look paid while the bank showed an unexplained payment. Without a
51
- * payment date a method listed in `paidAutomatically` (card, direct debit) is expected to pay itself;
52
- * otherwise the due date decides: overdue after it, due soon within `dueSoonDays`, else open.
53
- */
54
- export declare const paymentState: (values: IPaymentValues, paidAutomatically: string[], today?: Date, dueSoonDays?: number) => PaymentState;
55
- export type PaymentTone = "green" | "amber" | "blue" | "red" | "grey";
56
- /** The pill of a state: its text and its tone. */
57
- export declare const PAYMENT_PILLS: Record<PaymentState["kind"], {
58
- text: string;
59
- tone: PaymentTone;
60
- }>;
61
- /** The colours of a tone: background, text, dot. */
62
- export declare const PAYMENT_TONES: Record<PaymentTone, {
63
- background: string;
64
- color: string;
65
- dot: string;
66
- }>;
67
- export interface IPaymentLines {
68
- /** What the state is about, beside the pill: "Paid on 02.11.2026", "Due 27.11.2026", "Overdue by 12 days". */
69
- primary: string;
70
- /** The details below it, muted. */
71
- secondary: string[];
72
- /** Paid without a linked transaction: the warning below it. */
73
- warning?: string;
74
- }
75
- /** The lines of a state (English, as the detail view); the pill says the state, the lines the facts. */
76
- export declare const paymentLines: (state: PaymentState, values: IPaymentValues, today?: Date) => IPaymentLines;
77
- /** The MRNs of the linked transactions: a list of {transactionRef} (or of plain MRN strings), or one MRN. */
78
- export declare const transactionRefsOf: (value: unknown, refField?: string) => string[];
79
- /** An amount as stored ("1380.50", "1.380,50", 1380.5); undefined for anything else. */
80
- export declare const parseAmount: (value: unknown) => number | undefined;
81
- /** "1.380,50" — two decimals, German grouping, no currency (the invoice's currency is not known here). */
82
- export declare const formatAmount: (value: number) => string;
83
- /** The account currency a payment is compared in when `accountCurrency` is not set. */
84
- export declare const DEFAULT_ACCOUNT_CURRENCY = "EUR";
85
- /**
86
- * Whether an invoice in this currency can be compared with the bank account's transactions: yes without an
87
- * invoice currency (as before the currency role existed) and when both are the same ISO code, ignoring case.
88
- * A USD invoice paid from a EUR account books a different amount (271,10 USD as -248,02 EUR) and is no mismatch.
89
- */
90
- export declare const comparesWithAccount: (invoiceCurrency?: string, accountCurrency?: string) => boolean;
91
- /**
92
- * The linked transactions against the invoice: their total (by magnitude — an outgoing payment is negative
93
- * on the bank side) and whether it matches the invoice amount to the cent. `matches` is undefined without
94
- * an invoice amount, and when the invoice is in another currency than the account (`currency`).
95
- */
96
- export declare const paymentTotal: (transactionAmounts: number[], invoiceAmount?: number, currency?: {
97
- invoice?: string;
98
- account?: string;
99
- }) => {
100
- total: number;
101
- matches?: boolean;
102
- };