@nice2dev/ui-erp 1.0.12 → 1.0.14

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.cjs CHANGED
@@ -1476,13 +1476,30 @@ const NiceInvoiceView = React.forwardRef(
1476
1476
  }
1477
1477
  );
1478
1478
  function colorFor(occ, colors) {
1479
- if (occ <= 0.01) return colors.low;
1480
- if (occ < 0.5) return colors.low;
1481
- if (occ < 0.85) return colors.mid;
1479
+ if (occ <= 0.01) {
1480
+ return colors.low;
1481
+ }
1482
+ if (occ < 0.5) {
1483
+ return colors.low;
1484
+ }
1485
+ if (occ < 0.85) {
1486
+ return colors.mid;
1487
+ }
1482
1488
  return colors.high;
1483
1489
  }
1484
1490
  const NiceWarehouseView = React.forwardRef(
1485
- function NiceWarehouseView2({ warehouseName, cells, colors = { low: "#dcfce7", mid: "#fde68a", high: "#fecaca" }, onCellClick, showLegend = true, cellSize = 48, aisleEvery = 4, className, style, id }, ref) {
1491
+ function NiceWarehouseView2({
1492
+ warehouseName,
1493
+ cells,
1494
+ colors = { low: "#dcfce7", mid: "#fde68a", high: "#fecaca" },
1495
+ onCellClick,
1496
+ showLegend = true,
1497
+ cellSize = 48,
1498
+ aisleEvery = 4,
1499
+ className,
1500
+ style,
1501
+ id
1502
+ }, ref) {
1486
1503
  const [hovered, setHovered] = React.useState(null);
1487
1504
  const grid = React.useMemo(() => {
1488
1505
  const rows = /* @__PURE__ */ new Map();
@@ -1575,17 +1592,36 @@ const STATUS_TINT = {
1575
1592
  function fmtMoney(amount, currency, locale) {
1576
1593
  const code = typeof currency === "string" ? currency : currency.code;
1577
1594
  const decimals = typeof currency === "string" ? 2 : currency.decimalPlaces ?? 2;
1578
- return new Intl.NumberFormat(locale, { style: "currency", currency: code }).format(amount / Math.pow(10, decimals));
1595
+ return new Intl.NumberFormat(locale, { style: "currency", currency: code }).format(
1596
+ amount / Math.pow(10, decimals)
1597
+ );
1579
1598
  }
1580
1599
  function fmtDate(d, locale) {
1581
- if (!d) return "—";
1600
+ if (!d) {
1601
+ return "—";
1602
+ }
1582
1603
  const dt = d instanceof Date ? d : new Date(d);
1583
1604
  return new Intl.DateTimeFormat(locale, { dateStyle: "medium" }).format(dt);
1584
1605
  }
1585
1606
  const NicePurchaseOrder = React.forwardRef(
1586
- function NicePurchaseOrder2({ orders, selectable = true, initialSelectedId, locale, labels, readOnly, onOrderApprove, onReceiveItems, onOrderUpdate, className, style, id }, ref) {
1607
+ function NicePurchaseOrder2({
1608
+ orders,
1609
+ selectable = true,
1610
+ initialSelectedId,
1611
+ locale,
1612
+ labels,
1613
+ readOnly,
1614
+ onOrderApprove,
1615
+ onReceiveItems,
1616
+ onOrderUpdate,
1617
+ className,
1618
+ style,
1619
+ id
1620
+ }, ref) {
1587
1621
  var _a;
1588
- const [selectedId, setSelectedId] = React.useState(initialSelectedId ?? ((_a = orders[0]) == null ? void 0 : _a.id));
1622
+ const [selectedId, setSelectedId] = React.useState(
1623
+ initialSelectedId ?? ((_a = orders[0]) == null ? void 0 : _a.id)
1624
+ );
1589
1625
  const L = {
1590
1626
  orderNumber: "PO #",
1591
1627
  supplier: "Supplier",
@@ -1639,57 +1675,77 @@ const NicePurchaseOrder = React.forwardRef(
1639
1675
  o.id
1640
1676
  )) })
1641
1677
  ] }),
1642
- selectable && selected && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "nice-purchase-order__detail", "aria-label": `${L.orderNumber} ${selected.orderNumber}`, children: [
1643
- /* @__PURE__ */ jsxRuntime.jsxs("header", { children: [
1644
- /* @__PURE__ */ jsxRuntime.jsxs("h3", { children: [
1645
- selected.orderNumber,
1646
- " ",
1647
- selected.supplier.name
1648
- ] }),
1649
- !readOnly && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-purchase-order__actions", children: [
1650
- selected.status === "pending-approval" && onOrderApprove && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => onOrderApprove(selected.id), children: L.approve }),
1651
- (selected.status === "ordered" || selected.status === "partially-received") && onReceiveItems && /* @__PURE__ */ jsxRuntime.jsx(
1652
- "button",
1653
- {
1654
- type: "button",
1655
- onClick: () => onReceiveItems(selected.id, selected.items.map((it) => ({ itemId: it.itemId, quantity: it.quantity - (it.receivedQuantity ?? 0) }))),
1656
- children: L.receive
1657
- }
1658
- ),
1659
- onOrderUpdate && selected.status === "draft" && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => onOrderUpdate({ ...selected, status: "pending-approval" }), children: "Submit" })
1660
- ] })
1661
- ] }),
1662
- /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "nice-purchase-order__items", children: [
1663
- /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1664
- /* @__PURE__ */ jsxRuntime.jsx("th", { children: L.sku }),
1665
- /* @__PURE__ */ jsxRuntime.jsx("th", { children: L.name }),
1666
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "nice-num", children: L.qty }),
1667
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "nice-num", children: L.received }),
1668
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "nice-num", children: L.unitPrice }),
1669
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "nice-num", children: L.lineTotal })
1670
- ] }) }),
1671
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: selected.items.map((it) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1672
- /* @__PURE__ */ jsxRuntime.jsx("td", { children: it.sku }),
1673
- /* @__PURE__ */ jsxRuntime.jsx("td", { children: it.itemName }),
1674
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "nice-num", children: it.quantity }),
1675
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "nice-num", children: it.receivedQuantity ?? 0 }),
1676
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "nice-num", children: fmtMoney(it.unitPrice.amount, it.unitPrice.currency, locale) }),
1677
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "nice-num", children: fmtMoney(it.lineTotal.amount, it.lineTotal.currency, locale) })
1678
- ] }, it.itemId)) }),
1679
- /* @__PURE__ */ jsxRuntime.jsx("tfoot", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1680
- /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: 5, className: "nice-num", children: L.total }),
1681
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "nice-num", children: /* @__PURE__ */ jsxRuntime.jsx("strong", { children: fmtMoney(selected.total.amount, selected.total.currency, locale) }) })
1682
- ] }) })
1683
- ] }),
1684
- selected.notes && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "nice-purchase-order__notes", children: [
1685
- /* @__PURE__ */ jsxRuntime.jsxs("strong", { children: [
1686
- L.notes,
1687
- ":"
1688
- ] }),
1689
- " ",
1690
- selected.notes
1691
- ] })
1692
- ] })
1678
+ selectable && selected && /* @__PURE__ */ jsxRuntime.jsxs(
1679
+ "section",
1680
+ {
1681
+ className: "nice-purchase-order__detail",
1682
+ "aria-label": `${L.orderNumber} ${selected.orderNumber}`,
1683
+ children: [
1684
+ /* @__PURE__ */ jsxRuntime.jsxs("header", { children: [
1685
+ /* @__PURE__ */ jsxRuntime.jsxs("h3", { children: [
1686
+ selected.orderNumber,
1687
+ " ",
1688
+ selected.supplier.name
1689
+ ] }),
1690
+ !readOnly && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "nice-purchase-order__actions", children: [
1691
+ selected.status === "pending-approval" && onOrderApprove && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => onOrderApprove(selected.id), children: L.approve }),
1692
+ (selected.status === "ordered" || selected.status === "partially-received") && onReceiveItems && /* @__PURE__ */ jsxRuntime.jsx(
1693
+ "button",
1694
+ {
1695
+ type: "button",
1696
+ onClick: () => onReceiveItems(
1697
+ selected.id,
1698
+ selected.items.map((it) => ({
1699
+ itemId: it.itemId,
1700
+ quantity: it.quantity - (it.receivedQuantity ?? 0)
1701
+ }))
1702
+ ),
1703
+ children: L.receive
1704
+ }
1705
+ ),
1706
+ onOrderUpdate && selected.status === "draft" && /* @__PURE__ */ jsxRuntime.jsx(
1707
+ "button",
1708
+ {
1709
+ type: "button",
1710
+ onClick: () => onOrderUpdate({ ...selected, status: "pending-approval" }),
1711
+ children: "Submit"
1712
+ }
1713
+ )
1714
+ ] })
1715
+ ] }),
1716
+ /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "nice-purchase-order__items", children: [
1717
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1718
+ /* @__PURE__ */ jsxRuntime.jsx("th", { children: L.sku }),
1719
+ /* @__PURE__ */ jsxRuntime.jsx("th", { children: L.name }),
1720
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "nice-num", children: L.qty }),
1721
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "nice-num", children: L.received }),
1722
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "nice-num", children: L.unitPrice }),
1723
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "nice-num", children: L.lineTotal })
1724
+ ] }) }),
1725
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: selected.items.map((it) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1726
+ /* @__PURE__ */ jsxRuntime.jsx("td", { children: it.sku }),
1727
+ /* @__PURE__ */ jsxRuntime.jsx("td", { children: it.itemName }),
1728
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "nice-num", children: it.quantity }),
1729
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "nice-num", children: it.receivedQuantity ?? 0 }),
1730
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "nice-num", children: fmtMoney(it.unitPrice.amount, it.unitPrice.currency, locale) }),
1731
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "nice-num", children: fmtMoney(it.lineTotal.amount, it.lineTotal.currency, locale) })
1732
+ ] }, it.itemId)) }),
1733
+ /* @__PURE__ */ jsxRuntime.jsx("tfoot", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1734
+ /* @__PURE__ */ jsxRuntime.jsx("td", { colSpan: 5, className: "nice-num", children: L.total }),
1735
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "nice-num", children: /* @__PURE__ */ jsxRuntime.jsx("strong", { children: fmtMoney(selected.total.amount, selected.total.currency, locale) }) })
1736
+ ] }) })
1737
+ ] }),
1738
+ selected.notes && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "nice-purchase-order__notes", children: [
1739
+ /* @__PURE__ */ jsxRuntime.jsxs("strong", { children: [
1740
+ L.notes,
1741
+ ":"
1742
+ ] }),
1743
+ " ",
1744
+ selected.notes
1745
+ ] })
1746
+ ]
1747
+ }
1748
+ )
1693
1749
  ] });
1694
1750
  }
1695
1751
  );
@@ -1799,19 +1855,26 @@ function useMockErpApi(options = {}) {
1799
1855
  setLoading(false);
1800
1856
  }, [latencyMs, errorRate]);
1801
1857
  React.useEffect(() => {
1802
- if (settledRef.current) return;
1858
+ if (settledRef.current) {
1859
+ return;
1860
+ }
1803
1861
  settledRef.current = true;
1804
1862
  void refresh();
1805
1863
  }, [refresh]);
1806
1864
  const writeWith = React.useCallback(
1807
1865
  async (key, item) => {
1808
1866
  await wait(latencyMs);
1809
- if (Math.random() < errorRate) throw new Error("Mock ERP API: write failed");
1867
+ if (Math.random() < errorRate) {
1868
+ throw new Error("Mock ERP API: write failed");
1869
+ }
1810
1870
  setData((d) => {
1811
1871
  const arr = [...d[key]];
1812
1872
  const idx = arr.findIndex((i) => i.id === item.id);
1813
- if (idx >= 0) arr[idx] = item;
1814
- else arr.push(item);
1873
+ if (idx >= 0) {
1874
+ arr[idx] = item;
1875
+ } else {
1876
+ arr.push(item);
1877
+ }
1815
1878
  return { ...d, [key]: arr };
1816
1879
  });
1817
1880
  },
@@ -1836,60 +1899,111 @@ function useMockErpApi(options = {}) {
1836
1899
  [loading, error, data, refresh, writeWith]
1837
1900
  );
1838
1901
  }
1839
- const NiceVatTable = React.forwardRef(
1840
- function NiceVatTable2({ country = "PL", rates, editable = false, onChange, onRemove, locale, labels, density = "comfortable", className, style, id }, ref) {
1841
- const [internal, setInternal] = React.useState(rates ?? NICE_VAT_PRESETS[country]);
1842
- const L = { code: "Code", rate: "Rate", label: "Label", description: "Description", add: "+ Add", remove: "Remove", ...labels };
1843
- const update = React.useCallback(
1844
- (next) => {
1845
- setInternal(next);
1846
- onChange == null ? void 0 : onChange(next);
1847
- },
1848
- [onChange]
1849
- );
1850
- const onCellEdit = (idx, key, raw) => {
1851
- const next = [...internal];
1852
- const r = { ...next[idx] };
1853
- if (key === "rate") {
1854
- const n = Number(raw.replace(",", "."));
1855
- if (!Number.isFinite(n)) return;
1856
- r.rate = n > 1 ? n / 100 : n;
1857
- } else if (key === "code" || key === "label" || key === "description") {
1858
- r[key] = raw;
1902
+ const NiceVatTable = React.forwardRef(function NiceVatTable2({
1903
+ country = "PL",
1904
+ rates,
1905
+ editable = false,
1906
+ onChange,
1907
+ onRemove,
1908
+ locale,
1909
+ labels,
1910
+ density = "comfortable",
1911
+ className,
1912
+ style,
1913
+ id
1914
+ }, ref) {
1915
+ const [internal, setInternal] = React.useState(rates ?? NICE_VAT_PRESETS[country]);
1916
+ const L = {
1917
+ code: "Code",
1918
+ rate: "Rate",
1919
+ label: "Label",
1920
+ description: "Description",
1921
+ add: "+ Add",
1922
+ remove: "Remove",
1923
+ ...labels
1924
+ };
1925
+ const update = React.useCallback(
1926
+ (next) => {
1927
+ setInternal(next);
1928
+ onChange == null ? void 0 : onChange(next);
1929
+ },
1930
+ [onChange]
1931
+ );
1932
+ const onCellEdit = (idx, key, raw) => {
1933
+ const next = [...internal];
1934
+ const r = { ...next[idx] };
1935
+ if (key === "rate") {
1936
+ const n = Number(raw.replace(",", "."));
1937
+ if (!Number.isFinite(n)) {
1938
+ return;
1859
1939
  }
1860
- next[idx] = r;
1861
- update(next);
1862
- };
1863
- const addRow = () => {
1864
- update([...internal, { code: `NEW-${internal.length + 1}`, rate: 0, label: "0%" }]);
1865
- };
1866
- const removeRow = (idx) => {
1867
- const code = internal[idx].code;
1868
- const next = internal.filter((_, i) => i !== idx);
1869
- update(next);
1870
- onRemove == null ? void 0 : onRemove(code);
1871
- };
1872
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, id, className: `nice-vat-table nice-vat-table--${density} ${className ?? ""}`, style, children: [
1873
- /* @__PURE__ */ jsxRuntime.jsxs("table", { children: [
1874
- /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1875
- /* @__PURE__ */ jsxRuntime.jsx("th", { children: L.code }),
1876
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "nice-num", children: L.rate }),
1877
- /* @__PURE__ */ jsxRuntime.jsx("th", { children: L.label }),
1878
- /* @__PURE__ */ jsxRuntime.jsx("th", { children: L.description }),
1879
- editable && /* @__PURE__ */ jsxRuntime.jsx("th", { "aria-label": L.remove })
1880
- ] }) }),
1881
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: internal.map((r, idx) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1882
- /* @__PURE__ */ jsxRuntime.jsx("td", { children: editable ? /* @__PURE__ */ jsxRuntime.jsx("input", { value: r.code, onChange: (e) => onCellEdit(idx, "code", e.target.value) }) : r.code }),
1883
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "nice-num", children: editable ? /* @__PURE__ */ jsxRuntime.jsx("input", { type: "number", step: "0.01", min: 0, max: 1, value: r.rate, onChange: (e) => onCellEdit(idx, "rate", e.target.value) }) : `${(r.rate * 100).toLocaleString(locale, { maximumFractionDigits: 2 })}%` }),
1884
- /* @__PURE__ */ jsxRuntime.jsx("td", { children: editable ? /* @__PURE__ */ jsxRuntime.jsx("input", { value: r.label ?? "", onChange: (e) => onCellEdit(idx, "label", e.target.value) }) : r.label ?? "" }),
1885
- /* @__PURE__ */ jsxRuntime.jsx("td", { children: editable ? /* @__PURE__ */ jsxRuntime.jsx("input", { value: r.description ?? "", onChange: (e) => onCellEdit(idx, "description", e.target.value) }) : r.description ?? "" }),
1886
- editable && /* @__PURE__ */ jsxRuntime.jsx("td", { children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => removeRow(idx), "aria-label": L.remove, children: "×" }) })
1887
- ] }, r.code)) })
1888
- ] }),
1889
- editable && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "nice-vat-table__add", onClick: addRow, children: L.add })
1890
- ] });
1891
- }
1892
- );
1940
+ r.rate = n > 1 ? n / 100 : n;
1941
+ } else if (key === "code" || key === "label" || key === "description") {
1942
+ r[key] = raw;
1943
+ }
1944
+ next[idx] = r;
1945
+ update(next);
1946
+ };
1947
+ const addRow = () => {
1948
+ update([...internal, { code: `NEW-${internal.length + 1}`, rate: 0, label: "0%" }]);
1949
+ };
1950
+ const removeRow = (idx) => {
1951
+ const code = internal[idx].code;
1952
+ const next = internal.filter((_, i) => i !== idx);
1953
+ update(next);
1954
+ onRemove == null ? void 0 : onRemove(code);
1955
+ };
1956
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1957
+ "div",
1958
+ {
1959
+ ref,
1960
+ id,
1961
+ className: `nice-vat-table nice-vat-table--${density} ${className ?? ""}`,
1962
+ style,
1963
+ children: [
1964
+ /* @__PURE__ */ jsxRuntime.jsxs("table", { children: [
1965
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1966
+ /* @__PURE__ */ jsxRuntime.jsx("th", { children: L.code }),
1967
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "nice-num", children: L.rate }),
1968
+ /* @__PURE__ */ jsxRuntime.jsx("th", { children: L.label }),
1969
+ /* @__PURE__ */ jsxRuntime.jsx("th", { children: L.description }),
1970
+ editable && /* @__PURE__ */ jsxRuntime.jsx("th", { "aria-label": L.remove })
1971
+ ] }) }),
1972
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: internal.map((r, idx) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1973
+ /* @__PURE__ */ jsxRuntime.jsx("td", { children: editable ? /* @__PURE__ */ jsxRuntime.jsx("input", { value: r.code, onChange: (e) => onCellEdit(idx, "code", e.target.value) }) : r.code }),
1974
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "nice-num", children: editable ? /* @__PURE__ */ jsxRuntime.jsx(
1975
+ "input",
1976
+ {
1977
+ type: "number",
1978
+ step: "0.01",
1979
+ min: 0,
1980
+ max: 1,
1981
+ value: r.rate,
1982
+ onChange: (e) => onCellEdit(idx, "rate", e.target.value)
1983
+ }
1984
+ ) : `${(r.rate * 100).toLocaleString(locale, { maximumFractionDigits: 2 })}%` }),
1985
+ /* @__PURE__ */ jsxRuntime.jsx("td", { children: editable ? /* @__PURE__ */ jsxRuntime.jsx(
1986
+ "input",
1987
+ {
1988
+ value: r.label ?? "",
1989
+ onChange: (e) => onCellEdit(idx, "label", e.target.value)
1990
+ }
1991
+ ) : r.label ?? "" }),
1992
+ /* @__PURE__ */ jsxRuntime.jsx("td", { children: editable ? /* @__PURE__ */ jsxRuntime.jsx(
1993
+ "input",
1994
+ {
1995
+ value: r.description ?? "",
1996
+ onChange: (e) => onCellEdit(idx, "description", e.target.value)
1997
+ }
1998
+ ) : r.description ?? "" }),
1999
+ editable && /* @__PURE__ */ jsxRuntime.jsx("td", { children: /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: () => removeRow(idx), "aria-label": L.remove, children: "×" }) })
2000
+ ] }, r.code)) })
2001
+ ] }),
2002
+ editable && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "nice-vat-table__add", onClick: addRow, children: L.add })
2003
+ ]
2004
+ }
2005
+ );
2006
+ });
1893
2007
  function pad(n) {
1894
2008
  return n < 10 ? `0${n}` : String(n);
1895
2009
  }
@@ -1912,14 +2026,20 @@ function defaultBuildXml(opts) {
1912
2026
  lines.push(" <Podmiot1>");
1913
2027
  lines.push(` <NIP>${escapeXml(taxpayer.nip)}</NIP>`);
1914
2028
  lines.push(` <PelnaNazwa>${escapeXml(taxpayer.name)}</PelnaNazwa>`);
1915
- if (taxpayer.regon) lines.push(` <REGON>${escapeXml(taxpayer.regon)}</REGON>`);
2029
+ if (taxpayer.regon) {
2030
+ lines.push(` <REGON>${escapeXml(taxpayer.regon)}</REGON>`);
2031
+ }
1916
2032
  lines.push(" </Podmiot1>");
1917
2033
  for (const inv of invoices) {
1918
2034
  lines.push(" <Faktura>");
1919
2035
  lines.push(` <NumerFaktury>${escapeXml(inv.invoiceNumber)}</NumerFaktury>`);
1920
- lines.push(` <DataWystawienia>${isoDate(inv.issueDate instanceof Date ? inv.issueDate : new Date(inv.issueDate))}</DataWystawienia>`);
2036
+ lines.push(
2037
+ ` <DataWystawienia>${isoDate(inv.issueDate instanceof Date ? inv.issueDate : new Date(inv.issueDate))}</DataWystawienia>`
2038
+ );
1921
2039
  lines.push(` <NazwaNabywcy>${escapeXml(inv.buyer.name)}</NazwaNabywcy>`);
1922
- if (inv.buyer.vatId) lines.push(` <NIPNabywcy>${escapeXml(inv.buyer.vatId)}</NIPNabywcy>`);
2040
+ if (inv.buyer.vatId) {
2041
+ lines.push(` <NIPNabywcy>${escapeXml(inv.buyer.vatId)}</NIPNabywcy>`);
2042
+ }
1923
2043
  let net = 0;
1924
2044
  let vat = 0;
1925
2045
  for (const ln of inv.lines) {
@@ -1937,12 +2057,34 @@ function defaultBuildXml(opts) {
1937
2057
  return lines.join("\n");
1938
2058
  }
1939
2059
  const NiceJpkExporter = React.forwardRef(
1940
- function NiceJpkExporter2({ invoices, taxpayer, defaultFormat = "JPK_V7M", defaultPeriod, buildXml = defaultBuildXml, onExport, filenameFor, labels, className, style, id }, ref) {
2060
+ function NiceJpkExporter2({
2061
+ invoices,
2062
+ taxpayer,
2063
+ defaultFormat = "JPK_V7M",
2064
+ defaultPeriod,
2065
+ buildXml = defaultBuildXml,
2066
+ onExport,
2067
+ filenameFor,
2068
+ labels,
2069
+ className,
2070
+ style,
2071
+ id
2072
+ }, ref) {
1941
2073
  const today = /* @__PURE__ */ new Date();
1942
2074
  const [format, setFormat] = React.useState(defaultFormat);
1943
- const [from, setFrom] = React.useState(isoDate((defaultPeriod == null ? void 0 : defaultPeriod.from) ?? new Date(today.getFullYear(), today.getMonth(), 1)));
1944
- const [to, setTo] = React.useState(isoDate((defaultPeriod == null ? void 0 : defaultPeriod.to) ?? new Date(today.getFullYear(), today.getMonth() + 1, 0)));
1945
- const L = { format: "Format", from: "From", to: "To", export: "Export", ...labels };
2075
+ const [from, setFrom] = React.useState(
2076
+ isoDate((defaultPeriod == null ? void 0 : defaultPeriod.from) ?? new Date(today.getFullYear(), today.getMonth(), 1))
2077
+ );
2078
+ const [to, setTo] = React.useState(
2079
+ isoDate((defaultPeriod == null ? void 0 : defaultPeriod.to) ?? new Date(today.getFullYear(), today.getMonth() + 1, 0))
2080
+ );
2081
+ const L = {
2082
+ format: "Format",
2083
+ from: "From",
2084
+ to: "To",
2085
+ export: "Export",
2086
+ ...labels
2087
+ };
1946
2088
  const exportNow = React.useCallback(() => {
1947
2089
  const opts = {
1948
2090
  format,
@@ -1968,11 +2110,18 @@ const NiceJpkExporter = React.forwardRef(
1968
2110
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, id, className: `nice-jpk-exporter ${className ?? ""}`, style, children: [
1969
2111
  /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
1970
2112
  L.format,
1971
- /* @__PURE__ */ jsxRuntime.jsxs("select", { value: format, onChange: (e) => setFormat(e.target.value), children: [
1972
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "JPK_V7M", children: "JPK_V7M" }),
1973
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "JPK_V7K", children: "JPK_V7K" }),
1974
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "JPK_FA", children: "JPK_FA" })
1975
- ] })
2113
+ /* @__PURE__ */ jsxRuntime.jsxs(
2114
+ "select",
2115
+ {
2116
+ value: format,
2117
+ onChange: (e) => setFormat(e.target.value),
2118
+ children: [
2119
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "JPK_V7M", children: "JPK_V7M" }),
2120
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "JPK_V7K", children: "JPK_V7K" }),
2121
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "JPK_FA", children: "JPK_FA" })
2122
+ ]
2123
+ }
2124
+ )
1976
2125
  ] }),
1977
2126
  /* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
1978
2127
  L.from,