UNPKG

@payfit/unity-components

Version:

95 lines (94 loc) • 3.09 kB
import { Spinner as e } from "../../spinner/Spinner.js"; import { CircularIconButton as t } from "../../icon-button/CircularIconButton.js"; import { useContext as n } from "react"; import { uyTv as r } from "@payfit/unity-themes"; import { jsx as i, jsxs as a } from "react/jsx-runtime"; import { useTranslation as o } from "react-i18next"; import { Icon as s } from "@payfit/unity-icons"; import { DateInput as c, DatePickerStateContext as l, DateSegment as u } from "react-aria-components/DatePicker"; //#region src/core/components/date-picker/parts/DateInput.tsx var d = r({ base: [ "uy:group uy:box-content uy:rounded-25 uy:px-25 uy:text-end uy:tabular-nums! uy:outline-none uy:typography-body uy:focus:bg-surface-form-active uy:focus:rounded-25", "uy:data-[disabled]:text-content-form-disabled", "uy:focus:text-content-form-active" ], variants: { isPlaceholder: { true: ["uy:text-content-neutral-lowest-enabled"], false: "uy:text-content-form-enabled" }, isLiteral: { true: "uy:text-content-neutral-lowest-enabled", false: "" } } }), f = r({ slots: { base: "uy:flex uy:gap-50 uy:flex-grow uy:py-125 uy:sm:py-100 uy:px-150 uy:rounded-100 uy:sm:rounded-75", input: "uy:flex uy:gap-25 uy:w-fit uy:grow", state: "uy:flex uy:gap-50 uy:items-center" }, variants: { isInvalid: { true: { base: "uy:bg-surface-form-error", state: "uy:text-content-form-error" } }, isReadOnly: { true: { base: "uy:border-border-form-disabled uy:bg-surface-form-disabled" } }, isDisabled: { true: { base: "uy:bg-surface-form-disabled uy:text-content-form-disabled" } } }, compoundVariants: [{ isInvalid: !1, isDisabled: !1, isReadOnly: !1, className: { base: "uy:border-border-form-enabled uy:bg-surface-form-enabled", state: "uy:text-content-neutral-disabled" } }] }); function p({ isLoading: r, isInvalid: p, isReadOnly: m, isDisabled: h, onClearButtonPress: g }) { let { t: _ } = o("unity"), v = n(l), { dateValue: y } = v, { base: b, input: x, state: S } = f({ isInvalid: !!p, isReadOnly: !!m, isDisabled: !!h }), C = y && !r && !m && !h; return /* @__PURE__ */ a("div", { className: b(), children: [/* @__PURE__ */ i(c, { className: x(), children: (e) => /* @__PURE__ */ i(u, { segment: e, className: d({ isPlaceholder: e.isPlaceholder, isLiteral: e.type === "literal" }) }) }), /* @__PURE__ */ a("div", { className: S(), children: [ r && /* @__PURE__ */ i(e, { color: "inherit", size: "small", label: _((e) => e.unity.component.common.loading.label) }), p && /* @__PURE__ */ i(s, { src: "WarningCircleOutlined", color: "content.form.invalid", alt: _((e) => e.unity.component.formField.formInput.error.alt) }), C && /* @__PURE__ */ i(t, { slot: null, title: _((e) => e.unity.component.common.clear.title), icon: "CloseOutlined", onPress: () => { v?.setValue(null), g?.(); } }) ] })] }); } p.displayName = "DateInput"; //#endregion export { p as DateInput, f as dateInput, d as dateSegment };