@flanksource/clicky-ui
Version:
Flanksource Clicky UI — React component library built on shadcn/ui with light/dark and density theming.
64 lines (63 loc) • 1.89 kB
JavaScript
import { jsxs, jsx } from "react/jsx-runtime";
import { forwardRef, useRef } from "react";
import { Icon } from "../data/Icon.js";
import { cn } from "../lib/utils.js";
const DatePicker = forwardRef(
({
value = "",
onChange,
className,
inputClassName,
buttonClassName,
openButtonLabel = "Open date picker",
...props
}, ref) => {
const localRef = useRef(null);
function assignRef(node) {
localRef.current = node;
if (typeof ref === "function") {
ref(node);
} else if (ref) {
ref.current = node;
}
}
return /* @__PURE__ */ jsxs("div", { className: cn("relative", className), children: [
/* @__PURE__ */ jsx(
"input",
{
...props,
ref: assignRef,
type: "date",
value,
className: cn(
"h-8 w-full rounded-md border border-input bg-background px-2 pr-8 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring",
inputClassName
),
onChange: (event) => onChange == null ? void 0 : onChange(event.target.value)
}
),
/* @__PURE__ */ jsx(
"button",
{
type: "button",
"aria-label": openButtonLabel,
className: cn(
"absolute inset-y-0 right-1 inline-flex items-center text-muted-foreground",
buttonClassName
),
onClick: () => {
var _a, _b, _c;
(_a = localRef.current) == null ? void 0 : _a.focus();
(_c = (_b = localRef.current) == null ? void 0 : _b.showPicker) == null ? void 0 : _c.call(_b);
},
children: /* @__PURE__ */ jsx(Icon, { name: "codicon:calendar", className: "text-sm" })
}
)
] });
}
);
DatePicker.displayName = "DatePicker";
export {
DatePicker
};
//# sourceMappingURL=DatePicker.js.map