Update new functions
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// components/Datepicker.js
|
||||
import { $, $html, $if } from "../sigpro.js";
|
||||
import { $, Tag, If } from "../sigpro.js";
|
||||
import { val, ui, getIcon } from "../core/utils.js";
|
||||
import { Input } from "./Input.js";
|
||||
|
||||
@@ -99,9 +99,9 @@ export const Datepicker = (props) => {
|
||||
};
|
||||
|
||||
const HourSlider = ({ value: hVal, onChange }) => {
|
||||
return $html("div", { class: "flex-1" }, [
|
||||
$html("div", { class: "flex gap-2 items-center" }, [
|
||||
$html("input", {
|
||||
return Tag("div", { class: "flex-1" }, [
|
||||
Tag("div", { class: "flex gap-2 items-center" }, [
|
||||
Tag("input", {
|
||||
type: "range",
|
||||
min: 0,
|
||||
max: 23,
|
||||
@@ -112,14 +112,14 @@ export const Datepicker = (props) => {
|
||||
onChange(newHour);
|
||||
},
|
||||
}),
|
||||
$html("span", { class: "text-sm font-mono min-w-[48px] text-center" },
|
||||
Tag("span", { class: "text-sm font-mono min-w-[48px] text-center" },
|
||||
() => String(val(hVal)).padStart(2, "0") + ":00"
|
||||
),
|
||||
]),
|
||||
]);
|
||||
};
|
||||
|
||||
return $html("div", { class: ui('relative w-full', className) }, [
|
||||
return Tag("div", { class: ui('relative w-full', className) }, [
|
||||
Input({
|
||||
label,
|
||||
placeholder: placeholder || (isRangeMode() ? "Seleccionar rango..." : "Seleccionar fecha..."),
|
||||
@@ -133,38 +133,38 @@ export const Datepicker = (props) => {
|
||||
...rest,
|
||||
}),
|
||||
|
||||
$if(isOpen, () =>
|
||||
$html(
|
||||
If(isOpen, () =>
|
||||
Tag(
|
||||
"div",
|
||||
{
|
||||
class: "absolute left-0 mt-2 p-4 bg-base-100 border border-base-300 shadow-2xl rounded-box z-[100] w-80 select-none",
|
||||
onclick: (e) => e.stopPropagation(),
|
||||
},
|
||||
[
|
||||
$html("div", { class: "flex justify-between items-center mb-4 gap-1" }, [
|
||||
$html("div", { class: "flex gap-0.5" }, [
|
||||
$html("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => moveYear(-1) },
|
||||
Tag("div", { class: "flex justify-between items-center mb-4 gap-1" }, [
|
||||
Tag("div", { class: "flex gap-0.5" }, [
|
||||
Tag("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => moveYear(-1) },
|
||||
getIcon("icon-[lucide--chevrons-left]")
|
||||
),
|
||||
$html("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => move(-1) },
|
||||
Tag("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => move(-1) },
|
||||
getIcon("icon-[lucide--chevron-left]")
|
||||
),
|
||||
]),
|
||||
$html("span", { class: "font-bold uppercase flex-1 text-center" }, [
|
||||
Tag("span", { class: "font-bold uppercase flex-1 text-center" }, [
|
||||
() => internalDate().toLocaleString("es-ES", { month: "short", year: "numeric" }),
|
||||
]),
|
||||
$html("div", { class: "flex gap-0.5" }, [
|
||||
$html("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => move(1) },
|
||||
Tag("div", { class: "flex gap-0.5" }, [
|
||||
Tag("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => move(1) },
|
||||
getIcon("icon-[lucide--chevron-right]")
|
||||
),
|
||||
$html("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => moveYear(1) },
|
||||
Tag("button", { type: "button", class: "btn btn-ghost btn-xs px-1", onclick: () => moveYear(1) },
|
||||
getIcon("icon-[lucide--chevrons-right]")
|
||||
),
|
||||
]),
|
||||
]),
|
||||
|
||||
$html("div", { class: "grid grid-cols-7 gap-1", onmouseleave: () => hoverDate(null) }, [
|
||||
...["L", "M", "X", "J", "V", "S", "D"].map((d) => $html("div", { class: "text-[10px] opacity-40 font-bold text-center" }, d)),
|
||||
Tag("div", { class: "grid grid-cols-7 gap-1", onmouseleave: () => hoverDate(null) }, [
|
||||
...["L", "M", "X", "J", "V", "S", "D"].map((d) => Tag("div", { class: "text-[10px] opacity-40 font-bold text-center" }, d)),
|
||||
() => {
|
||||
const d = internalDate();
|
||||
const year = d.getFullYear();
|
||||
@@ -174,14 +174,14 @@ export const Datepicker = (props) => {
|
||||
const daysInMonth = new Date(year, month + 1, 0).getDate();
|
||||
|
||||
const nodes = [];
|
||||
for (let i = 0; i < offset; i++) nodes.push($html("div"));
|
||||
for (let i = 0; i < offset; i++) nodes.push(Tag("div"));
|
||||
|
||||
for (let i = 1; i <= daysInMonth; i++) {
|
||||
const date = new Date(year, month, i);
|
||||
const dStr = formatDate(date);
|
||||
|
||||
nodes.push(
|
||||
$html(
|
||||
Tag(
|
||||
"button",
|
||||
{
|
||||
type: "button",
|
||||
@@ -218,9 +218,9 @@ export const Datepicker = (props) => {
|
||||
},
|
||||
]),
|
||||
|
||||
hour ? $html("div", { class: "mt-3 pt-2 border-t border-base-300" }, [
|
||||
hour ? Tag("div", { class: "mt-3 pt-2 border-t border-base-300" }, [
|
||||
isRangeMode()
|
||||
? $html("div", { class: "flex gap-4" }, [
|
||||
? Tag("div", { class: "flex gap-4" }, [
|
||||
HourSlider({
|
||||
value: startHour,
|
||||
onChange: (newHour) => {
|
||||
@@ -253,6 +253,6 @@ export const Datepicker = (props) => {
|
||||
),
|
||||
),
|
||||
|
||||
$if(isOpen, () => $html("div", { class: "fixed inset-0 z-[90]", onclick: () => isOpen(false) })),
|
||||
If(isOpen, () => Tag("div", { class: "fixed inset-0 z-[90]", onclick: () => isOpen(false) })),
|
||||
]);
|
||||
};
|
||||
Reference in New Issue
Block a user