UNPKG

@payfit/unity-components

Version:

84 lines (83 loc) • 2.61 kB
import { Spinner as e } from "../../spinner/Spinner.js"; import { CircularIconButton as t } from "../../icon-button/CircularIconButton.js"; import { dateInput as n, dateSegment as r } from "../../date-picker/parts/DateInput.js"; import { useContext as i } from "react"; import { uyTv as a } from "@payfit/unity-themes"; import { jsx as o, jsxs as s } from "react/jsx-runtime"; import { useTranslation as c } from "react-i18next"; import { Icon as l } from "@payfit/unity-icons"; import { DateInput as u, DateRangePickerStateContext as d, DateSegment as f } from "react-aria-components/DateRangePicker"; //#region src/core/components/date-range-picker/parts/DateRangeInput.tsx var p = a({ base: "uy:px-50 uy:flex uy:items-center", variants: { isDisabled: { true: "uy:text-content-form-disabled", false: ["uy:text-content-neutral-lowest"] } } }); function m({ isLoading: a, isInvalid: m, isReadOnly: h, isDisabled: g, onClearButtonPress: _ }) { let { t: v } = c("unity"), y = i(d), { value: b } = y, { base: x, input: S, state: C } = n({ isInvalid: !!m, isReadOnly: !!h, isDisabled: !!g }), w = b?.start && b?.end && !a && !h && !g; return /* @__PURE__ */ s("div", { className: x(), children: [/* @__PURE__ */ s("div", { className: S(), children: [ /* @__PURE__ */ o(u, { slot: "start", className: "uy:flex uy:gap-25", children: (e) => /* @__PURE__ */ o(f, { segment: e, className: r({ isPlaceholder: e.isPlaceholder, isLiteral: e.type === "literal" }) }) }), /* @__PURE__ */ o("span", { className: p({ isDisabled: !!g }), children: "→" }), /* @__PURE__ */ o(u, { slot: "end", className: "uy:flex uy:gap-25", children: (e) => /* @__PURE__ */ o(f, { segment: e, className: r({ isPlaceholder: e.isPlaceholder, isLiteral: e.type === "literal" }) }) }) ] }), /* @__PURE__ */ s("div", { className: C(), children: [ a && /* @__PURE__ */ o(e, { color: "inherit", size: "small", label: v((e) => e.unity.component.common.loading.label) }), m && /* @__PURE__ */ o(l, { src: "WarningCircleOutlined", color: "content.form.invalid", alt: v((e) => e.unity.component.formField.formInput.error.alt) }), w && /* @__PURE__ */ o(t, { slot: null, title: v((e) => e.unity.component.common.clear.title), icon: "CloseOutlined", onPress: () => { y?.setValue(null), _?.(); } }) ] })] }); } m.displayName = "DateRangeInput"; //#endregion export { m as DateRangeInput };