@middag-io/react 0.35.1 → 0.35.3
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 +40 -147
- package/dist-lib/{DateField-CcRD2r-Z.js → DateField-CryguepA.js} +1 -1
- package/dist-lib/{DocumentField-DjnK9T7o.js → DocumentField-4wTGkMH-.js} +2 -2
- package/dist-lib/{FormPanelBlock-BYyMr-xN.js → FormPanelBlock-CbM3PiH7.js} +4 -4
- package/dist-lib/{MarkdownContent-C-X2QGA2.js → MarkdownContent-D0w3DYm6.js} +16 -16
- package/dist-lib/{PhoneField-BF70G_PS.js → PhoneField-BtLI699n.js} +2 -2
- package/dist-lib/base/theme/tailwind-theme.css +1 -1
- package/dist-lib/{combobox-BRe2Y-kB.js → combobox-oPnHtaA6.js} +1857 -1772
- package/dist-lib/components/reui/index.d.ts +1 -1
- package/dist-lib/contracts/block-data/data-display.d.ts +1 -1
- package/dist-lib/contracts/generated/contract-schema.d.ts +1 -1
- package/dist-lib/contracts/generated/contract-types.d.ts +3 -3
- package/dist-lib/contracts/generated/contract-types.d.ts.map +1 -1
- package/dist-lib/contracts/generated/index.d.ts +1 -1
- package/dist-lib/middag-react.js +2243 -3701
- package/dist-lib/{resolve-field-error-DLX1h_6J.js → resolve-field-error-DbMTg4Lj.js} +26 -26
- package/dist-lib/useTranslation-D-tjJhTn.js +48 -0
- package/package.json +5 -1
- package/dist-lib/MarkdownContent-D5FIjx_W.js +0 -2
- package/dist-lib/useTranslation-BuyMWJ9T.js +0 -321
- /package/dist-lib/{DateRangeField-DKZMfKB2.js → DateRangeField-o5tUrAR8.js} +0 -0
- /package/dist-lib/{dist-DdfRh_k3.js → dist-axU0pUop.js} +0 -0
- /package/dist-lib/{document-validation-DX0fB9cu.js → document-validation-BSjTDZhG.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as e, c as t, g as n, h as r, i, l as a, m as o, o as s, p as c, r as l, s as u, t as d, u as f } from "./button-Bm0X9WO5.js";
|
|
2
|
-
import { $ as p, A as m, B as h, C as g, D as _, E as v, F as y, G as b, H as x, I as S, J as C, K as w, L as T, M as E, N as D, O, P as k, Q as A, R as j, S as M, T as N, U as P, V as ee, W as F, X as I, Y as te, Z as ne, _ as re, at as ie, b as ae, et as oe, f as se, it as ce, j as le, k as ue, l as de, nt as fe, o as pe,
|
|
3
|
-
import {
|
|
2
|
+
import { $ as p, A as m, B as h, C as g, D as _, E as v, F as y, G as b, H as x, I as S, J as C, K as w, L as T, M as E, N as D, O, P as k, Q as A, R as j, S as M, T as N, U as P, V as ee, W as F, X as I, Y as te, Z as ne, _ as re, at as ie, b as ae, et as oe, f as se, it as ce, j as le, k as ue, l as de, nt as fe, o as pe, ot as me, q as he, rt as ge, s as _e, t as ve, tt as ye, u as be, v as xe, w as Se, x as Ce, y as we, z as Te } from "./combobox-oPnHtaA6.js";
|
|
3
|
+
import { t as Ee } from "./useTranslation-D-tjJhTn.js";
|
|
4
4
|
import { $ as De, C as Oe, G as L, J as ke, K as Ae, ft as je, l as Me, p as Ne, pt as Pe, st as Fe, t as R, u as Ie, v as Le } from "./HugeiconsIcon-CKqc2W1S.js";
|
|
5
5
|
import { t as z } from "./utils-CpaZ5_iF.js";
|
|
6
6
|
import { i as Re, n as ze, r as Be, t as Ve } from "./dist-DdgpZG8v.js";
|
|
@@ -3529,7 +3529,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${t.do
|
|
|
3529
3529
|
...e,
|
|
3530
3530
|
[t]: r
|
|
3531
3531
|
};
|
|
3532
|
-
}, {}), il =
|
|
3532
|
+
}, {}), il = ce();
|
|
3533
3533
|
function al() {
|
|
3534
3534
|
return (0, il.useSyncExternalStore)(ol, () => !0, () => !1);
|
|
3535
3535
|
}
|
|
@@ -5280,7 +5280,7 @@ function sp({ className: e, children: t, showCloseButton: n = !0, ...r }) {
|
|
|
5280
5280
|
children: [t, n && /* @__PURE__ */ U(nl, {
|
|
5281
5281
|
"data-slot": "dialog-close",
|
|
5282
5282
|
className: "absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
5283
|
-
children: [/* @__PURE__ */ H(
|
|
5283
|
+
children: [/* @__PURE__ */ H(ie, {}), /* @__PURE__ */ H("span", {
|
|
5284
5284
|
className: "sr-only",
|
|
5285
5285
|
children: "Close"
|
|
5286
5286
|
})]
|
|
@@ -5452,7 +5452,7 @@ function xp(e, t) {
|
|
|
5452
5452
|
}
|
|
5453
5453
|
//#endregion
|
|
5454
5454
|
//#region src/base/partials/EmptyPlaceholder/index.tsx
|
|
5455
|
-
var Sp = lt(() => import("./dist-
|
|
5455
|
+
var Sp = lt(() => import("./dist-axU0pUop.js").then((e) => ({ default: e.DotLottieReact }))), Cp = {
|
|
5456
5456
|
"first-use": {
|
|
5457
5457
|
iconSize: 56,
|
|
5458
5458
|
padding: "py-20",
|
|
@@ -5618,7 +5618,7 @@ function Np({ className: e, children: t, ...n }) {
|
|
|
5618
5618
|
children: [/* @__PURE__ */ H("span", {
|
|
5619
5619
|
"data-slot": "select-item-indicator",
|
|
5620
5620
|
className: "absolute right-2 flex size-3.5 items-center justify-center",
|
|
5621
|
-
children: /* @__PURE__ */ H(Ud, { children: /* @__PURE__ */ H(
|
|
5621
|
+
children: /* @__PURE__ */ H(Ud, { children: /* @__PURE__ */ H(me, { className: "size-4" }) })
|
|
5622
5622
|
}), /* @__PURE__ */ H(Hd, { children: t })]
|
|
5623
5623
|
});
|
|
5624
5624
|
}
|
|
@@ -5666,7 +5666,7 @@ function Rp({ className: e, ...t }) {
|
|
|
5666
5666
|
children: /* @__PURE__ */ H(Pl, {
|
|
5667
5667
|
"data-slot": "checkbox-indicator",
|
|
5668
5668
|
className: "grid place-content-center text-current transition-none",
|
|
5669
|
-
children: /* @__PURE__ */ H(
|
|
5669
|
+
children: /* @__PURE__ */ H(me, { className: "size-3.5" })
|
|
5670
5670
|
})
|
|
5671
5671
|
});
|
|
5672
5672
|
}
|
|
@@ -5781,7 +5781,7 @@ function Wp({ id: e, value: t, onChange: n, currency: r = "BRL", placeholder: i,
|
|
|
5781
5781
|
children: [/* @__PURE__ */ H(oe, {
|
|
5782
5782
|
align: "inline-start",
|
|
5783
5783
|
children: /* @__PURE__ */ H(fe, { children: x })
|
|
5784
|
-
}), /* @__PURE__ */ H(
|
|
5784
|
+
}), /* @__PURE__ */ H(ye, {
|
|
5785
5785
|
id: e,
|
|
5786
5786
|
inputMode: "decimal",
|
|
5787
5787
|
value: h ? _ : t == null ? "" : b.replace(x, "").trim(),
|
|
@@ -6057,7 +6057,7 @@ function Hm(e, { step: t, minWithDefault: n, maxWithDefault: r, minWithZeroDefau
|
|
|
6057
6057
|
//#endregion
|
|
6058
6058
|
//#region node_modules/@base-ui/react/esm/number-field/root/NumberFieldRoot.js
|
|
6059
6059
|
var Um = /* @__PURE__ */ B.forwardRef(function(e, t) {
|
|
6060
|
-
let { id: n, min: r, max: i, smallStep: a = .1, step: o = 1, largeStep: s = 10, required: c = !1, disabled: l = !1, readOnly: u = !1, form: d, name: f, defaultValue: p, value: h, onValueChange: g, onValueCommitted: _, allowWheelScrub: y = !1, snapOnStep: x = !1, allowOutOfRange: C = !1, format: T, locale: O, render: k, className: j, inputRef: M, style: P, ...ee } = e, { setDirty: F, validityData: ne, disabled: ie, setFilled: ae, invalid: oe, name: se, state: ce, validation: le, shouldValidateOnChange: de } =
|
|
6060
|
+
let { id: n, min: r, max: i, smallStep: a = .1, step: o = 1, largeStep: s = 10, required: c = !1, disabled: l = !1, readOnly: u = !1, form: d, name: f, defaultValue: p, value: h, onValueChange: g, onValueCommitted: _, allowWheelScrub: y = !1, snapOnStep: x = !1, allowOutOfRange: C = !1, format: T, locale: O, render: k, className: j, inputRef: M, style: P, ...ee } = e, { setDirty: F, validityData: ne, disabled: ie, setFilled: ae, invalid: oe, name: se, state: ce, validation: le, shouldValidateOnChange: de } = Ce(), fe = ie || l, pe = se ?? f, me = o === "any" ? 1 : o, [ge, _e] = B.useState(!1), ve = r ?? -(2 ** 53 - 1), ye = i ?? 2 ** 53 - 1, be = r ?? 0, xe = T?.style, we = B.useRef(null), Te = he(M, le.inputRef), Ee = re({ id: n }), [De, Oe] = A({
|
|
6061
6061
|
controlled: h,
|
|
6062
6062
|
default: p,
|
|
6063
6063
|
name: "NumberField",
|
|
@@ -6071,9 +6071,9 @@ var Um = /* @__PURE__ */ B.forwardRef(function(e, t) {
|
|
|
6071
6071
|
}), Pe = B.useRef(!0), Fe = B.useRef(null), [R, Ie] = B.useState(() => h === void 0 ? Qp(L, O, T) : Wm(L, O, T)), [Le, z] = B.useState("numeric"), Re = I(() => {
|
|
6072
6072
|
let { decimal: e, group: t, currency: n, literal: r } = Fm(O, T), i = /* @__PURE__ */ new Set();
|
|
6073
6073
|
Sm.forEach((e) => i.add(e)), e && i.add(e), t && (i.add(t), Cm.test(t) && i.add(" "));
|
|
6074
|
-
let a =
|
|
6075
|
-
return a && cm.forEach((e) => i.add(e)), o && lm.forEach((e) => i.add(e)),
|
|
6076
|
-
}), ze = I((e) => e?.altKey ? a : e?.shiftKey ? s :
|
|
6074
|
+
let a = xe === "percent" || xe === "unit" && T?.unit === "percent", o = xe === "percent" || xe === "unit" && T?.unit === "permille";
|
|
6075
|
+
return a && cm.forEach((e) => i.add(e)), o && lm.forEach((e) => i.add(e)), xe === "currency" && n && i.add(n), r && (Array.from(r).forEach((e) => i.add(e)), Cm.test(r) && i.add(" ")), wm.forEach((e) => i.add(e)), ve < 0 && Tm.forEach((e) => i.add(e)), i;
|
|
6076
|
+
}), ze = I((e) => e?.altKey ? a : e?.shiftKey ? s : me), Be = I((e, t) => {
|
|
6077
6077
|
let n = t.event, r = t.direction, i = t.reason, a = !C || !(i === "input-change" || i === "input-blur" || i === "input-paste" || i === "input-clear" || i === "none"), o = Hm(e, {
|
|
6078
6078
|
step: r ? ze(n) * r : void 0,
|
|
6079
6079
|
format: je.current,
|
|
@@ -6101,7 +6101,7 @@ var Um = /* @__PURE__ */ B.forwardRef(function(e, t) {
|
|
|
6101
6101
|
if (!D) return;
|
|
6102
6102
|
let e = "text";
|
|
6103
6103
|
ve >= 0 && (e = "decimal"), z(e);
|
|
6104
|
-
}, [ve,
|
|
6104
|
+
}, [ve, xe]), B.useEffect(function() {
|
|
6105
6105
|
let e = we.current;
|
|
6106
6106
|
if (fe || u || !y || !e) return;
|
|
6107
6107
|
function t(e) {
|
|
@@ -6118,7 +6118,7 @@ var Um = /* @__PURE__ */ B.forwardRef(function(e, t) {
|
|
|
6118
6118
|
fe,
|
|
6119
6119
|
u,
|
|
6120
6120
|
s,
|
|
6121
|
-
|
|
6121
|
+
me,
|
|
6122
6122
|
ze
|
|
6123
6123
|
]);
|
|
6124
6124
|
let He = B.useMemo(() => ({
|
|
@@ -6224,7 +6224,7 @@ var Um = /* @__PURE__ */ B.forwardRef(function(e, t) {
|
|
|
6224
6224
|
required: c,
|
|
6225
6225
|
"aria-hidden": !0,
|
|
6226
6226
|
tabIndex: -1,
|
|
6227
|
-
style: pe ? N :
|
|
6227
|
+
style: pe ? N : Se,
|
|
6228
6228
|
suppressHydrationWarning: !0
|
|
6229
6229
|
})]
|
|
6230
6230
|
});
|
|
@@ -6342,7 +6342,7 @@ function nh(e) {
|
|
|
6342
6342
|
return e === "touch" || e === "pen";
|
|
6343
6343
|
}
|
|
6344
6344
|
function rh(e) {
|
|
6345
|
-
let { allowInputSyncRef: t, disabled: n, formatOptionsRef: r, getStepAmount: i, id: a, incrementValue: o, inputRef: s, inputValue: c, isIncrement: l, locale: u, readOnly: d, setValue: f, valueRef: p, lastChangedValueRef: m, onValueCommitted: h } = e, g = l ?
|
|
6345
|
+
let { allowInputSyncRef: t, disabled: n, formatOptionsRef: r, getStepAmount: i, id: a, incrementValue: o, inputRef: s, inputValue: c, isIncrement: l, locale: u, readOnly: d, setValue: f, valueRef: p, lastChangedValueRef: m, onValueCommitted: h } = e, g = l ? Te : j;
|
|
6346
6346
|
function _(e) {
|
|
6347
6347
|
t.current = !0;
|
|
6348
6348
|
let n = Im(c, u, r.current);
|
|
@@ -6487,7 +6487,7 @@ var oh = {
|
|
|
6487
6487
|
"Enter",
|
|
6488
6488
|
"Escape"
|
|
6489
6489
|
]), ch = /* @__PURE__ */ B.forwardRef(function(e, t) {
|
|
6490
|
-
let { render: n, className: r, style: i, ...a } = e, { allowInputSyncRef: o, disabled: s, formatOptionsRef: c, getAllowedNonNumericKeys: l, getStepAmount: u, id: d, incrementValue: f, inputMode: p, inputValue: m, max: _, min: v, name: y, readOnly: b, required: C, setValue: E, state: D, setInputValue: O, locale: k, inputRef: A, value: j, onValueCommitted: M, lastChangedValueRef: N, hasPendingCommitRef: I, valueRef: te } = tm(), { clearErrors: ne } =
|
|
6490
|
+
let { render: n, className: r, style: i, ...a } = e, { allowInputSyncRef: o, disabled: s, formatOptionsRef: c, getAllowedNonNumericKeys: l, getStepAmount: u, id: d, incrementValue: f, inputMode: p, inputValue: m, max: _, min: v, name: y, readOnly: b, required: C, setValue: E, state: D, setInputValue: O, locale: k, inputRef: A, value: j, onValueCommitted: M, lastChangedValueRef: N, hasPendingCommitRef: I, valueRef: te } = tm(), { clearErrors: ne } = we(), { validationMode: re, setTouched: ie, setFocused: oe, invalid: se, shouldValidateOnChange: ce, validation: ue } = Ce(), { labelId: de } = xe(), fe = B.useRef(!1), pe = B.useRef(!1);
|
|
6491
6491
|
return ae(A, {
|
|
6492
6492
|
id: d,
|
|
6493
6493
|
value: j
|
|
@@ -6664,7 +6664,7 @@ function uh({ id: e, value: t, onChange: n, options: r, initialOption: i, autoco
|
|
|
6664
6664
|
]), A = V((e) => {
|
|
6665
6665
|
n(e ?? "");
|
|
6666
6666
|
}, [n]), j = b ? h("middag.ui.form.entity_loading") : g.length < o && C ? h("middag.ui.form.entity_min_chars").replace("{min}", String(o)) : h("middag.ui.form.entity_no_results"), M = !!s || O.some((e) => e.avatarUrl);
|
|
6667
|
-
return /* @__PURE__ */ U(
|
|
6667
|
+
return /* @__PURE__ */ U(ve, {
|
|
6668
6668
|
items: k,
|
|
6669
6669
|
value: t || null,
|
|
6670
6670
|
onValueChange: A,
|
|
@@ -6679,10 +6679,10 @@ function uh({ id: e, value: t, onChange: n, options: r, initialOption: i, autoco
|
|
|
6679
6679
|
showTrigger: !0,
|
|
6680
6680
|
value: g,
|
|
6681
6681
|
onChange: (e) => _(e.target.value)
|
|
6682
|
-
}), /* @__PURE__ */ U(pe, { children: [/* @__PURE__ */ H(
|
|
6682
|
+
}), /* @__PURE__ */ U(pe, { children: [/* @__PURE__ */ H(_e, {
|
|
6683
6683
|
className: "px-4 py-3 text-sm",
|
|
6684
6684
|
children: j
|
|
6685
|
-
}), /* @__PURE__ */ H(se, { children: k.map((e) => /* @__PURE__ */ U(
|
|
6685
|
+
}), /* @__PURE__ */ H(se, { children: k.map((e) => /* @__PURE__ */ U(be, {
|
|
6686
6686
|
value: e.value,
|
|
6687
6687
|
className: "flex items-center gap-2.5 px-3 py-2",
|
|
6688
6688
|
children: [M && /* @__PURE__ */ U(Gp, {
|
|
@@ -7124,7 +7124,7 @@ function bh({ id: e, options: t, selected: n, onChange: r, placeholder: i, disab
|
|
|
7124
7124
|
})
|
|
7125
7125
|
})]
|
|
7126
7126
|
}, e.value))
|
|
7127
|
-
}), /* @__PURE__ */ U(
|
|
7127
|
+
}), /* @__PURE__ */ U(ve, {
|
|
7128
7128
|
items: f,
|
|
7129
7129
|
value: null,
|
|
7130
7130
|
onValueChange: h,
|
|
@@ -7134,10 +7134,10 @@ function bh({ id: e, options: t, selected: n, onChange: r, placeholder: i, disab
|
|
|
7134
7134
|
showTrigger: !0,
|
|
7135
7135
|
value: u,
|
|
7136
7136
|
onChange: (e) => d(e.target.value)
|
|
7137
|
-
}), /* @__PURE__ */ U(pe, { children: [/* @__PURE__ */ H(
|
|
7137
|
+
}), /* @__PURE__ */ U(pe, { children: [/* @__PURE__ */ H(_e, {
|
|
7138
7138
|
className: "px-4 py-3 text-sm",
|
|
7139
7139
|
children: l("middag.ui.form.entity_no_results")
|
|
7140
|
-
}), /* @__PURE__ */ H(se, { children: f.map((e) => /* @__PURE__ */ U(
|
|
7140
|
+
}), /* @__PURE__ */ H(se, { children: f.map((e) => /* @__PURE__ */ U(be, {
|
|
7141
7141
|
value: e.value,
|
|
7142
7142
|
className: "flex items-center gap-2",
|
|
7143
7143
|
children: [/* @__PURE__ */ H(Rp, {
|
|
@@ -7995,7 +7995,7 @@ function Sg({ id: e, value: t, onChange: n, sourceValue: r, placeholder: i, disa
|
|
|
7995
7995
|
children: [/* @__PURE__ */ H(oe, {
|
|
7996
7996
|
align: "inline-start",
|
|
7997
7997
|
children: /* @__PURE__ */ H(fe, { children: u })
|
|
7998
|
-
}), /* @__PURE__ */ H(
|
|
7998
|
+
}), /* @__PURE__ */ H(ye, {
|
|
7999
7999
|
id: e,
|
|
8000
8000
|
type: "text",
|
|
8001
8001
|
value: t ?? "",
|
|
@@ -8008,7 +8008,7 @@ function Sg({ id: e, value: t, onChange: n, sourceValue: r, placeholder: i, disa
|
|
|
8008
8008
|
})]
|
|
8009
8009
|
}) : /* @__PURE__ */ H(p, {
|
|
8010
8010
|
"data-disabled": a || void 0,
|
|
8011
|
-
children: /* @__PURE__ */ H(
|
|
8011
|
+
children: /* @__PURE__ */ H(ye, {
|
|
8012
8012
|
id: e,
|
|
8013
8013
|
type: "text",
|
|
8014
8014
|
value: t ?? "",
|
|
@@ -8120,7 +8120,7 @@ function Eg({ id: e, value: t, onChange: n, placeholder: r, disabled: i, require
|
|
|
8120
8120
|
//#region src/base/form/fields/TextareaField.tsx
|
|
8121
8121
|
function Dg({ id: e, value: t, onChange: n, placeholder: r, rows: i = 4, disabled: a, readOnly: o, required: s, error: c, helpTextId: l, errorId: u }) {
|
|
8122
8122
|
let d = [c ? u : void 0, l].filter(Boolean).join(" ") || void 0;
|
|
8123
|
-
return /* @__PURE__ */ H(
|
|
8123
|
+
return /* @__PURE__ */ H(ge, {
|
|
8124
8124
|
id: e,
|
|
8125
8125
|
value: t ?? "",
|
|
8126
8126
|
onChange: (e) => n(e.target.value),
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useCallback as e, useMemo as t } from "react";
|
|
2
|
+
import { useTranslation as n } from "react-i18next";
|
|
3
|
+
//#region src/i18n/useTranslation.ts
|
|
4
|
+
var r = [
|
|
5
|
+
["year", 31536e3],
|
|
6
|
+
["month", 2592e3],
|
|
7
|
+
["week", 604800],
|
|
8
|
+
["day", 86400],
|
|
9
|
+
["hour", 3600],
|
|
10
|
+
["minute", 60],
|
|
11
|
+
["second", 1]
|
|
12
|
+
];
|
|
13
|
+
function i(e) {
|
|
14
|
+
return e instanceof Date ? e : new Date(e);
|
|
15
|
+
}
|
|
16
|
+
function a() {
|
|
17
|
+
let { t: a, i18n: o } = n(void 0, { useSuspense: !1 }), s = o.resolvedLanguage ?? o.language, c = e((e, t) => new Intl.DateTimeFormat(s, t ?? { dateStyle: "medium" }).format(i(e)), [s]), l = e((e, t) => new Intl.DateTimeFormat(s, t ?? {
|
|
18
|
+
dateStyle: "medium",
|
|
19
|
+
timeStyle: "short"
|
|
20
|
+
}).format(i(e)), [s]), u = e((e) => {
|
|
21
|
+
let t = Math.round((i(e).getTime() - Date.now()) / 1e3);
|
|
22
|
+
for (let [e, n] of r) if (Math.abs(t) >= n) return new Intl.RelativeTimeFormat(s, { numeric: "auto" }).format(Math.round(t / n), e);
|
|
23
|
+
return new Intl.RelativeTimeFormat(s, { numeric: "auto" }).format(0, "second");
|
|
24
|
+
}, [s]), d = e((e, t) => new Intl.NumberFormat(s, t).format(e), [s]), f = e((e, t = "BRL", n) => new Intl.NumberFormat(s, {
|
|
25
|
+
style: "currency",
|
|
26
|
+
currency: t,
|
|
27
|
+
...n
|
|
28
|
+
}).format(e), [s]);
|
|
29
|
+
return t(() => ({
|
|
30
|
+
t: a,
|
|
31
|
+
locale: s,
|
|
32
|
+
formatDate: c,
|
|
33
|
+
formatDateTime: l,
|
|
34
|
+
formatRelative: u,
|
|
35
|
+
formatNumber: d,
|
|
36
|
+
formatCurrency: f
|
|
37
|
+
}), [
|
|
38
|
+
a,
|
|
39
|
+
s,
|
|
40
|
+
c,
|
|
41
|
+
l,
|
|
42
|
+
u,
|
|
43
|
+
d,
|
|
44
|
+
f
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { a as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middag-io/react",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MIDDAG shared React UI library for Moodle, WordPress and other Inertia hosts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -77,5 +77,9 @@
|
|
|
77
77
|
"@inertiajs/react": "^3.0.0",
|
|
78
78
|
"react": "^19.0.0",
|
|
79
79
|
"react-dom": "^19.0.0"
|
|
80
|
+
},
|
|
81
|
+
"homepage": "https://ui-docs.middag.io",
|
|
82
|
+
"bugs": {
|
|
83
|
+
"url": "https://github.com/middag-io/middag-react/issues"
|
|
80
84
|
}
|
|
81
85
|
}
|
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
import { r as e, t } from "./chunk-DeC0fbbY.js";
|
|
2
|
-
import { createContext as n, useCallback as r, useContext as i, useEffect as a, useMemo as o, useRef as s, useState as c } from "react";
|
|
3
|
-
//#region node_modules/react-i18next/dist/es/utils.js
|
|
4
|
-
var l = (e, t, n, r) => {
|
|
5
|
-
let i = [n, {
|
|
6
|
-
code: t,
|
|
7
|
-
...r || {}
|
|
8
|
-
}];
|
|
9
|
-
if (e?.services?.logger?.forward) return e.services.logger.forward(i, "warn", "react-i18next::", !0);
|
|
10
|
-
g(i[0]) && (i[0] = `react-i18next:: ${i[0]}`), e?.services?.logger?.warn ? e.services.logger.warn(...i) : console?.warn && console.warn(...i);
|
|
11
|
-
}, u = {}, d = (e, t, n, r) => {
|
|
12
|
-
g(n) && u[n] || (g(n) && (u[n] = /* @__PURE__ */ new Date()), l(e, t, n, r));
|
|
13
|
-
}, f = (e, t) => () => {
|
|
14
|
-
if (e.isInitialized) t();
|
|
15
|
-
else {
|
|
16
|
-
let n = () => {
|
|
17
|
-
setTimeout(() => {
|
|
18
|
-
e.off("initialized", n);
|
|
19
|
-
}, 0), t();
|
|
20
|
-
};
|
|
21
|
-
e.on("initialized", n);
|
|
22
|
-
}
|
|
23
|
-
}, p = (e, t, n) => {
|
|
24
|
-
e.loadNamespaces(t, f(e, n));
|
|
25
|
-
}, m = (e, t, n, r) => {
|
|
26
|
-
if (g(n) && (n = [n]), e.options.preload && e.options.preload.indexOf(t) > -1) return p(e, n, r);
|
|
27
|
-
n.forEach((t) => {
|
|
28
|
-
e.options.ns.indexOf(t) < 0 && e.options.ns.push(t);
|
|
29
|
-
}), e.loadLanguages(t, f(e, r));
|
|
30
|
-
}, h = (e, t, n = {}) => !t.languages || !t.languages.length ? (d(t, "NO_LANGUAGES", "i18n.languages were undefined or empty", { languages: t.languages }), !0) : t.hasLoadedNamespace(e, {
|
|
31
|
-
lng: n.lng,
|
|
32
|
-
precheck: (t, r) => {
|
|
33
|
-
if (n.bindI18n && n.bindI18n.indexOf("languageChanging") > -1 && t.services.backendConnector.backend && t.isLanguageChangingTo && !r(t.isLanguageChangingTo, e)) return !1;
|
|
34
|
-
}
|
|
35
|
-
}), g = (e) => typeof e == "string", _ = (e) => typeof e == "object" && !!e, v = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g, y = {
|
|
36
|
-
"&": "&",
|
|
37
|
-
"&": "&",
|
|
38
|
-
"<": "<",
|
|
39
|
-
"<": "<",
|
|
40
|
-
">": ">",
|
|
41
|
-
">": ">",
|
|
42
|
-
"'": "'",
|
|
43
|
-
"'": "'",
|
|
44
|
-
""": "\"",
|
|
45
|
-
""": "\"",
|
|
46
|
-
" ": " ",
|
|
47
|
-
" ": " ",
|
|
48
|
-
"©": "©",
|
|
49
|
-
"©": "©",
|
|
50
|
-
"®": "®",
|
|
51
|
-
"®": "®",
|
|
52
|
-
"…": "…",
|
|
53
|
-
"…": "…",
|
|
54
|
-
"/": "/",
|
|
55
|
-
"/": "/"
|
|
56
|
-
}, b = (e) => y[e], x = {
|
|
57
|
-
bindI18n: "languageChanged",
|
|
58
|
-
bindI18nStore: "",
|
|
59
|
-
transEmptyNodeValue: "",
|
|
60
|
-
transSupportBasicHtmlNodes: !0,
|
|
61
|
-
transWrapTextNodes: "",
|
|
62
|
-
transKeepBasicHtmlNodesFor: [
|
|
63
|
-
"br",
|
|
64
|
-
"strong",
|
|
65
|
-
"i",
|
|
66
|
-
"p"
|
|
67
|
-
],
|
|
68
|
-
useSuspense: !0,
|
|
69
|
-
unescape: (e) => e.replace(v, b),
|
|
70
|
-
transDefaultProps: void 0
|
|
71
|
-
}, S = (e = {}) => {
|
|
72
|
-
x = {
|
|
73
|
-
...x,
|
|
74
|
-
...e
|
|
75
|
-
};
|
|
76
|
-
}, C = () => x, w, T = (e) => {
|
|
77
|
-
w = e;
|
|
78
|
-
}, E = () => w, D = {
|
|
79
|
-
type: "3rdParty",
|
|
80
|
-
init(e) {
|
|
81
|
-
S(e.options.react), T(e);
|
|
82
|
-
}
|
|
83
|
-
}, O = n(), k = class {
|
|
84
|
-
constructor() {
|
|
85
|
-
this.usedNamespaces = {};
|
|
86
|
-
}
|
|
87
|
-
addUsedNamespaces(e) {
|
|
88
|
-
e.forEach((e) => {
|
|
89
|
-
this.usedNamespaces[e] || (this.usedNamespaces[e] = !0);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
getUsedNamespaces() {
|
|
93
|
-
return Object.keys(this.usedNamespaces);
|
|
94
|
-
}
|
|
95
|
-
}, A = /* @__PURE__ */ t(((t) => {
|
|
96
|
-
var n = e("react");
|
|
97
|
-
function r(e, t) {
|
|
98
|
-
return e === t && (e !== 0 || 1 / e == 1 / t) || e !== e && t !== t;
|
|
99
|
-
}
|
|
100
|
-
var i = typeof Object.is == "function" ? Object.is : r, a = n.useState, o = n.useEffect, s = n.useLayoutEffect, c = n.useDebugValue;
|
|
101
|
-
function l(e, t) {
|
|
102
|
-
var n = t(), r = a({ inst: {
|
|
103
|
-
value: n,
|
|
104
|
-
getSnapshot: t
|
|
105
|
-
} }), i = r[0].inst, l = r[1];
|
|
106
|
-
return s(function() {
|
|
107
|
-
i.value = n, i.getSnapshot = t, u(i) && l({ inst: i });
|
|
108
|
-
}, [
|
|
109
|
-
e,
|
|
110
|
-
n,
|
|
111
|
-
t
|
|
112
|
-
]), o(function() {
|
|
113
|
-
return u(i) && l({ inst: i }), e(function() {
|
|
114
|
-
u(i) && l({ inst: i });
|
|
115
|
-
});
|
|
116
|
-
}, [e]), c(n), n;
|
|
117
|
-
}
|
|
118
|
-
function u(e) {
|
|
119
|
-
var t = e.getSnapshot;
|
|
120
|
-
e = e.value;
|
|
121
|
-
try {
|
|
122
|
-
var n = t();
|
|
123
|
-
return !i(e, n);
|
|
124
|
-
} catch {
|
|
125
|
-
return !0;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function d(e, t) {
|
|
129
|
-
return t();
|
|
130
|
-
}
|
|
131
|
-
var f = typeof window > "u" || window.document === void 0 || window.document.createElement === void 0 ? d : l;
|
|
132
|
-
t.useSyncExternalStore = n.useSyncExternalStore === void 0 ? f : n.useSyncExternalStore;
|
|
133
|
-
})), j = /* @__PURE__ */ t(((t) => {
|
|
134
|
-
process.env.NODE_ENV !== "production" && (function() {
|
|
135
|
-
function n(e, t) {
|
|
136
|
-
return e === t && (e !== 0 || 1 / e == 1 / t) || e !== e && t !== t;
|
|
137
|
-
}
|
|
138
|
-
function r(e, t) {
|
|
139
|
-
f || o.startTransition === void 0 || (f = !0, console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));
|
|
140
|
-
var n = t();
|
|
141
|
-
if (!p) {
|
|
142
|
-
var r = t();
|
|
143
|
-
s(n, r) || (console.error("The result of getSnapshot should be cached to avoid an infinite loop"), p = !0);
|
|
144
|
-
}
|
|
145
|
-
r = c({ inst: {
|
|
146
|
-
value: n,
|
|
147
|
-
getSnapshot: t
|
|
148
|
-
} });
|
|
149
|
-
var a = r[0].inst, m = r[1];
|
|
150
|
-
return u(function() {
|
|
151
|
-
a.value = n, a.getSnapshot = t, i(a) && m({ inst: a });
|
|
152
|
-
}, [
|
|
153
|
-
e,
|
|
154
|
-
n,
|
|
155
|
-
t
|
|
156
|
-
]), l(function() {
|
|
157
|
-
return i(a) && m({ inst: a }), e(function() {
|
|
158
|
-
i(a) && m({ inst: a });
|
|
159
|
-
});
|
|
160
|
-
}, [e]), d(n), n;
|
|
161
|
-
}
|
|
162
|
-
function i(e) {
|
|
163
|
-
var t = e.getSnapshot;
|
|
164
|
-
e = e.value;
|
|
165
|
-
try {
|
|
166
|
-
var n = t();
|
|
167
|
-
return !s(e, n);
|
|
168
|
-
} catch {
|
|
169
|
-
return !0;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
function a(e, t) {
|
|
173
|
-
return t();
|
|
174
|
-
}
|
|
175
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
176
|
-
var o = e("react"), s = typeof Object.is == "function" ? Object.is : n, c = o.useState, l = o.useEffect, u = o.useLayoutEffect, d = o.useDebugValue, f = !1, p = !1, m = typeof window > "u" || window.document === void 0 || window.document.createElement === void 0 ? a : r;
|
|
177
|
-
t.useSyncExternalStore = o.useSyncExternalStore === void 0 ? m : o.useSyncExternalStore, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
178
|
-
})();
|
|
179
|
-
})), M = /* @__PURE__ */ t(((e, t) => {
|
|
180
|
-
process.env.NODE_ENV === "production" ? t.exports = A() : t.exports = j();
|
|
181
|
-
})), N = M(), P = {
|
|
182
|
-
t: (e, t) => {
|
|
183
|
-
if (g(t)) return t;
|
|
184
|
-
if (_(t) && g(t.defaultValue)) return t.defaultValue;
|
|
185
|
-
if (typeof e == "function") return "";
|
|
186
|
-
if (Array.isArray(e)) {
|
|
187
|
-
let t = e[e.length - 1];
|
|
188
|
-
return typeof t == "function" ? "" : t;
|
|
189
|
-
}
|
|
190
|
-
return e;
|
|
191
|
-
},
|
|
192
|
-
ready: !1
|
|
193
|
-
}, F = () => () => {}, I = (e, t = {}) => {
|
|
194
|
-
let { i18n: n } = t, { i18n: l, defaultNS: u } = i(O) || {}, f = n || l || E();
|
|
195
|
-
f && !f.reportNamespaces && (f.reportNamespaces = new k()), f || d(f, "NO_I18NEXT_INSTANCE", "useTranslation: You will need to pass in an i18next instance by using initReactI18next");
|
|
196
|
-
let _ = o(() => ({
|
|
197
|
-
...C(),
|
|
198
|
-
...f?.options?.react,
|
|
199
|
-
...t
|
|
200
|
-
}), [f, t]), { useSuspense: v, keyPrefix: y } = _, b = e || u || f?.options?.defaultNS, x = g(b) ? [b] : b || ["translation"], S = o(() => x, x);
|
|
201
|
-
f?.reportNamespaces?.addUsedNamespaces?.(S);
|
|
202
|
-
let w = s(0), T = r((e) => {
|
|
203
|
-
if (!f) return F;
|
|
204
|
-
let { bindI18n: t, bindI18nStore: n } = _, r = () => {
|
|
205
|
-
w.current += 1, e();
|
|
206
|
-
};
|
|
207
|
-
return t && f.on(t, r), n && f.store.on(n, r), () => {
|
|
208
|
-
t && t.split(" ").forEach((e) => f.off(e, r)), n && n.split(" ").forEach((e) => f.store.off(e, r));
|
|
209
|
-
};
|
|
210
|
-
}, [f, _]), D = s(), A = r(() => {
|
|
211
|
-
if (!f) return P;
|
|
212
|
-
let e = !!(f.isInitialized || f.initializedStoreOnce) && S.every((e) => h(e, f, _)), n = t.lng || f.language, r = w.current, i = D.current;
|
|
213
|
-
if (i && i.ready === e && i.lng === n && i.keyPrefix === y && i.revision === r) return i;
|
|
214
|
-
let a = {
|
|
215
|
-
t: f.getFixedT(n, _.nsMode === "fallback" ? S : S[0], y, { scopeNs: S }),
|
|
216
|
-
ready: e,
|
|
217
|
-
lng: n,
|
|
218
|
-
keyPrefix: y,
|
|
219
|
-
revision: r
|
|
220
|
-
};
|
|
221
|
-
return D.current = a, a;
|
|
222
|
-
}, [
|
|
223
|
-
f,
|
|
224
|
-
S,
|
|
225
|
-
y,
|
|
226
|
-
_,
|
|
227
|
-
t.lng
|
|
228
|
-
]), [j, M] = c(0), { t: I, ready: L } = (0, N.useSyncExternalStore)(T, A, A);
|
|
229
|
-
a(() => {
|
|
230
|
-
if (f && !L && !v) {
|
|
231
|
-
let e = () => M((e) => e + 1);
|
|
232
|
-
t.lng ? m(f, t.lng, S, e) : p(f, S, e);
|
|
233
|
-
}
|
|
234
|
-
}, [
|
|
235
|
-
f,
|
|
236
|
-
t.lng,
|
|
237
|
-
S,
|
|
238
|
-
L,
|
|
239
|
-
v,
|
|
240
|
-
j
|
|
241
|
-
]);
|
|
242
|
-
let R = f || {}, z = s(null), B = s(), V = (e) => {
|
|
243
|
-
let t = Object.getOwnPropertyDescriptors(e);
|
|
244
|
-
t.__original && delete t.__original;
|
|
245
|
-
let n = Object.create(Object.getPrototypeOf(e), t);
|
|
246
|
-
if (!Object.prototype.hasOwnProperty.call(n, "__original")) try {
|
|
247
|
-
Object.defineProperty(n, "__original", {
|
|
248
|
-
value: e,
|
|
249
|
-
writable: !1,
|
|
250
|
-
enumerable: !1,
|
|
251
|
-
configurable: !1
|
|
252
|
-
});
|
|
253
|
-
} catch {}
|
|
254
|
-
return n;
|
|
255
|
-
}, H = o(() => {
|
|
256
|
-
let e = R, t = e?.language, n = e;
|
|
257
|
-
e && (z.current && z.current.__original === e && B.current === t ? n = z.current : (n = V(e), z.current = n, B.current = t));
|
|
258
|
-
let r = !L && !v ? (...e) => (d(f, "USE_T_BEFORE_READY", "useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."), I(...e)) : I, i = [
|
|
259
|
-
r,
|
|
260
|
-
n,
|
|
261
|
-
L
|
|
262
|
-
];
|
|
263
|
-
return i.t = r, i.i18n = n, i.ready = L, i;
|
|
264
|
-
}, [
|
|
265
|
-
I,
|
|
266
|
-
R,
|
|
267
|
-
L,
|
|
268
|
-
R.resolvedLanguage,
|
|
269
|
-
R.language,
|
|
270
|
-
R.languages
|
|
271
|
-
]);
|
|
272
|
-
if (f && v && !L) throw new Promise((e) => {
|
|
273
|
-
let n = () => e();
|
|
274
|
-
t.lng ? m(f, t.lng, S, n) : p(f, S, n);
|
|
275
|
-
});
|
|
276
|
-
return H;
|
|
277
|
-
}, L = [
|
|
278
|
-
["year", 31536e3],
|
|
279
|
-
["month", 2592e3],
|
|
280
|
-
["week", 604800],
|
|
281
|
-
["day", 86400],
|
|
282
|
-
["hour", 3600],
|
|
283
|
-
["minute", 60],
|
|
284
|
-
["second", 1]
|
|
285
|
-
];
|
|
286
|
-
function R(e) {
|
|
287
|
-
return e instanceof Date ? e : new Date(e);
|
|
288
|
-
}
|
|
289
|
-
function z() {
|
|
290
|
-
let { t: e, i18n: t } = I(void 0, { useSuspense: !1 }), n = t.resolvedLanguage ?? t.language, i = r((e, t) => new Intl.DateTimeFormat(n, t ?? { dateStyle: "medium" }).format(R(e)), [n]), a = r((e, t) => new Intl.DateTimeFormat(n, t ?? {
|
|
291
|
-
dateStyle: "medium",
|
|
292
|
-
timeStyle: "short"
|
|
293
|
-
}).format(R(e)), [n]), s = r((e) => {
|
|
294
|
-
let t = Math.round((R(e).getTime() - Date.now()) / 1e3);
|
|
295
|
-
for (let [e, r] of L) if (Math.abs(t) >= r) return new Intl.RelativeTimeFormat(n, { numeric: "auto" }).format(Math.round(t / r), e);
|
|
296
|
-
return new Intl.RelativeTimeFormat(n, { numeric: "auto" }).format(0, "second");
|
|
297
|
-
}, [n]), c = r((e, t) => new Intl.NumberFormat(n, t).format(e), [n]), l = r((e, t = "BRL", r) => new Intl.NumberFormat(n, {
|
|
298
|
-
style: "currency",
|
|
299
|
-
currency: t,
|
|
300
|
-
...r
|
|
301
|
-
}).format(e), [n]);
|
|
302
|
-
return o(() => ({
|
|
303
|
-
t: e,
|
|
304
|
-
locale: n,
|
|
305
|
-
formatDate: i,
|
|
306
|
-
formatDateTime: a,
|
|
307
|
-
formatRelative: s,
|
|
308
|
-
formatNumber: c,
|
|
309
|
-
formatCurrency: l
|
|
310
|
-
}), [
|
|
311
|
-
e,
|
|
312
|
-
n,
|
|
313
|
-
i,
|
|
314
|
-
a,
|
|
315
|
-
s,
|
|
316
|
-
c,
|
|
317
|
-
l
|
|
318
|
-
]);
|
|
319
|
-
}
|
|
320
|
-
//#endregion
|
|
321
|
-
export { D as a, O as i, I as n, M as r, z as t };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|