@eristack/form-ui
Version:
Native React form controls wired to @eristack money, percent, and timestamp
88 lines (85 loc) • 2.15 kB
JavaScript
// src/form-field.tsx
import { jsx, jsxs } from "react/jsx-runtime";
function FormField({ label, hint, error, children }) {
return /* @__PURE__ */ jsxs("label", { className: "erista-form-field", children: [
label ? /* @__PURE__ */ jsx("span", { className: "erista-form-field__label", children: label }) : null,
children,
hint ? /* @__PURE__ */ jsx("span", { className: "erista-form-field__hint", children: hint }) : null,
error ? /* @__PURE__ */ jsx("span", { className: "erista-form-field__error", children: error }) : null
] });
}
// src/money-input.tsx
import { submitAmountOnlyFormValue } from "@eristack/money/react";
import { jsx as jsx2 } from "react/jsx-runtime";
function MoneyInput({
amount,
currency,
onAmountChange,
onParsed,
round,
onBlur,
...rest
}) {
return /* @__PURE__ */ jsx2(
"input",
{
...rest,
type: "text",
inputMode: "decimal",
value: amount,
"data-currency": currency,
onChange: (event) => onAmountChange?.(event.target.value),
onBlur: (event) => {
onBlur?.(event);
const raw = event.target.value;
if (raw === "") return;
const money = submitAmountOnlyFormValue(raw, currency, { round });
const normalized = money.toJSON().amount;
onAmountChange?.(normalized);
onParsed?.(normalized);
}
}
);
}
// src/percent-input.tsx
import { jsx as jsx3 } from "react/jsx-runtime";
function PercentInput({
value,
onValueChange,
...rest
}) {
return /* @__PURE__ */ jsx3(
"input",
{
...rest,
type: "text",
inputMode: "decimal",
value,
onChange: (event) => onValueChange?.(event.target.value)
}
);
}
// src/timestamp-wall-input.tsx
import { jsx as jsx4 } from "react/jsx-runtime";
function TimestampWallInput({
value,
onValueChange,
...rest
}) {
return /* @__PURE__ */ jsx4(
"input",
{
...rest,
type: "date",
value,
onChange: (event) => onValueChange?.(event.target.value)
}
);
}
export {
FormField,
MoneyInput,
PercentInput,
TimestampWallInput
};
//# sourceMappingURL=index.js.map