@bzync/rui 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/components/aspect-ratio.cjs +1 -0
- package/dist/components/aspect-ratio.d.ts +5 -0
- package/dist/components/aspect-ratio.js +20 -0
- package/dist/components/avatar-group.cjs +1 -0
- package/dist/components/avatar-group.d.ts +14 -0
- package/dist/components/avatar-group.js +35 -0
- package/dist/components/blockquote.cjs +1 -0
- package/dist/components/blockquote.d.ts +10 -0
- package/dist/components/blockquote.js +32 -0
- package/dist/components/button-group.cjs +1 -0
- package/dist/components/button-group.d.ts +7 -0
- package/dist/components/button-group.js +26 -0
- package/dist/components/code.cjs +1 -1
- package/dist/components/code.d.ts +4 -4
- package/dist/components/code.js +59 -57
- package/dist/components/copy-button.cjs +1 -1
- package/dist/components/copy-button.js +3 -3
- package/dist/components/currency.cjs +1 -0
- package/dist/components/currency.d.ts +18 -0
- package/dist/components/currency.js +62 -0
- package/dist/components/description-list.cjs +1 -0
- package/dist/components/description-list.d.ts +14 -0
- package/dist/components/description-list.js +38 -0
- package/dist/components/divider.cjs +1 -0
- package/dist/components/divider.d.ts +12 -0
- package/dist/components/divider.js +45 -0
- package/dist/components/rating.cjs +1 -0
- package/dist/components/rating.d.ts +15 -0
- package/dist/components/rating.js +75 -0
- package/dist/components/scroll-area.cjs +1 -0
- package/dist/components/scroll-area.d.ts +8 -0
- package/dist/components/scroll-area.js +19 -0
- package/dist/components/time-picker.cjs +1 -0
- package/dist/components/time-picker.d.ts +29 -0
- package/dist/components/time-picker.js +336 -0
- package/dist/components/toggle.cjs +1 -0
- package/dist/components/toggle.d.ts +42 -0
- package/dist/components/toggle.js +116 -0
- package/dist/components/typography.cjs +1 -0
- package/dist/components/typography.d.ts +51 -0
- package/dist/components/typography.js +189 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +12 -0
- package/dist/index.js +102 -90
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { t as e } from "../cn-DpgY2leY.js";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/description-list.tsx
|
|
5
|
+
var r = {
|
|
6
|
+
1: "grid-cols-1",
|
|
7
|
+
2: "grid-cols-1 sm:grid-cols-2",
|
|
8
|
+
3: "grid-cols-1 sm:grid-cols-2 lg:grid-cols-3"
|
|
9
|
+
}, i = {
|
|
10
|
+
compact: "gap-x-4 gap-y-3",
|
|
11
|
+
default: "gap-x-6 gap-y-5",
|
|
12
|
+
relaxed: "gap-x-8 gap-y-7"
|
|
13
|
+
}, a = t(({ columns: t = 1, density: a = "default", className: o, ...s }, c) => /* @__PURE__ */ n("dl", {
|
|
14
|
+
ref: c,
|
|
15
|
+
className: e("grid min-w-0", r[t], i[a], o),
|
|
16
|
+
...s
|
|
17
|
+
}));
|
|
18
|
+
a.displayName = "DescriptionList";
|
|
19
|
+
var o = t(({ orientation: t = "stacked", className: r, ...i }, a) => /* @__PURE__ */ n("div", {
|
|
20
|
+
ref: a,
|
|
21
|
+
className: e("min-w-0", t === "inline" ? "flex flex-col gap-1 sm:flex-row sm:items-baseline sm:justify-between sm:gap-4" : "flex flex-col gap-1", r),
|
|
22
|
+
...i
|
|
23
|
+
}));
|
|
24
|
+
o.displayName = "DescriptionItem";
|
|
25
|
+
var s = t(({ className: t, ...r }, i) => /* @__PURE__ */ n("dt", {
|
|
26
|
+
ref: i,
|
|
27
|
+
className: e("text-xs font-medium text-muted-foreground", t),
|
|
28
|
+
...r
|
|
29
|
+
}));
|
|
30
|
+
s.displayName = "DescriptionTerm";
|
|
31
|
+
var c = t(({ className: t, ...r }, i) => /* @__PURE__ */ n("dd", {
|
|
32
|
+
ref: i,
|
|
33
|
+
className: e("min-w-0 break-words text-sm font-medium text-foreground", t),
|
|
34
|
+
...r
|
|
35
|
+
}));
|
|
36
|
+
c.displayName = "DescriptionDetails";
|
|
37
|
+
//#endregion
|
|
38
|
+
export { c as DescriptionDetails, o as DescriptionItem, a as DescriptionList, s as DescriptionTerm };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs");let t=require("react"),n=require("react/jsx-runtime");var r={solid:`border-solid`,dashed:`border-dashed`,dotted:`border-dotted`},i={none:`my-0`,sm:`my-2`,md:`my-4`,lg:`my-6`},a={none:`mx-0`,sm:`mx-2`,md:`mx-4`,lg:`mx-6`},o=(0,t.forwardRef)(({orientation:t=`horizontal`,variant:o=`solid`,spacing:s=`md`,label:c,decorative:l=!0,className:u,...d},f)=>{let p=t===`vertical`,m=e.t(`min-w-0 flex-1 border-border`,r[o],p?`w-0 border-l`:`h-0 border-t`);return(0,n.jsxs)(`div`,{ref:f,role:l?`presentation`:`separator`,"aria-orientation":l?void 0:t,className:e.t(`flex shrink-0 items-center`,p?`h-full min-h-4 self-stretch flex-col`:`w-full min-w-0 flex-row`,p?a[s]:i[s],u),...d,children:[(0,n.jsx)(`span`,{"aria-hidden":`true`,className:m}),c&&(0,n.jsx)(`span`,{className:e.t(`shrink-0 text-xs font-medium text-muted-foreground`,p?`my-2 [writing-mode:vertical-rl]`:`mx-3`),children:c}),c&&(0,n.jsx)(`span`,{"aria-hidden":`true`,className:m})]})});o.displayName=`Divider`,exports.Divider=o;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type DividerOrientation = "horizontal" | "vertical";
|
|
3
|
+
export type DividerVariant = "solid" | "dashed" | "dotted";
|
|
4
|
+
export type DividerSpacing = "none" | "sm" | "md" | "lg";
|
|
5
|
+
export interface DividerProps extends HTMLAttributes<HTMLDivElement> {
|
|
6
|
+
orientation?: DividerOrientation;
|
|
7
|
+
variant?: DividerVariant;
|
|
8
|
+
spacing?: DividerSpacing;
|
|
9
|
+
label?: ReactNode;
|
|
10
|
+
decorative?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare const Divider: import('react').ForwardRefExoticComponent<DividerProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { t as e } from "../cn-DpgY2leY.js";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
4
|
+
//#region src/components/divider.tsx
|
|
5
|
+
var i = {
|
|
6
|
+
solid: "border-solid",
|
|
7
|
+
dashed: "border-dashed",
|
|
8
|
+
dotted: "border-dotted"
|
|
9
|
+
}, a = {
|
|
10
|
+
none: "my-0",
|
|
11
|
+
sm: "my-2",
|
|
12
|
+
md: "my-4",
|
|
13
|
+
lg: "my-6"
|
|
14
|
+
}, o = {
|
|
15
|
+
none: "mx-0",
|
|
16
|
+
sm: "mx-2",
|
|
17
|
+
md: "mx-4",
|
|
18
|
+
lg: "mx-6"
|
|
19
|
+
}, s = t(({ orientation: t = "horizontal", variant: s = "solid", spacing: c = "md", label: l, decorative: u = !0, className: d, ...f }, p) => {
|
|
20
|
+
let m = t === "vertical", h = e("min-w-0 flex-1 border-border", i[s], m ? "w-0 border-l" : "h-0 border-t");
|
|
21
|
+
return /* @__PURE__ */ r("div", {
|
|
22
|
+
ref: p,
|
|
23
|
+
role: u ? "presentation" : "separator",
|
|
24
|
+
"aria-orientation": u ? void 0 : t,
|
|
25
|
+
className: e("flex shrink-0 items-center", m ? "h-full min-h-4 self-stretch flex-col" : "w-full min-w-0 flex-row", m ? o[c] : a[c], d),
|
|
26
|
+
...f,
|
|
27
|
+
children: [
|
|
28
|
+
/* @__PURE__ */ n("span", {
|
|
29
|
+
"aria-hidden": "true",
|
|
30
|
+
className: h
|
|
31
|
+
}),
|
|
32
|
+
l && /* @__PURE__ */ n("span", {
|
|
33
|
+
className: e("shrink-0 text-xs font-medium text-muted-foreground", m ? "my-2 [writing-mode:vertical-rl]" : "mx-3"),
|
|
34
|
+
children: l
|
|
35
|
+
}),
|
|
36
|
+
l && /* @__PURE__ */ n("span", {
|
|
37
|
+
"aria-hidden": "true",
|
|
38
|
+
className: h
|
|
39
|
+
})
|
|
40
|
+
]
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
s.displayName = "Divider";
|
|
44
|
+
//#endregion
|
|
45
|
+
export { s as Divider };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs"),t=require("../component-styles-DOUctc8_.cjs");let n=require("react"),r=require("react/jsx-runtime");var i={sm:`size-4`,md:`size-5`,lg:`size-6`},a={sm:`size-8`,md:`size-9`,lg:`size-10`},o=(0,n.forwardRef)(({label:o,value:s,defaultValue:c=0,onValueChange:l,max:u=5,name:d,size:f=`md`,readOnly:p=!1,showLabel:m=!0,showValue:h=!1,disabled:g,className:_,...v},y)=>{let b=(0,n.useId)(),x=d??b,S=Number.isFinite(u)?Math.max(1,Math.floor(u)):5,C=e=>Number.isFinite(e)?Math.max(0,Math.min(S,e)):0,[w,T]=(0,n.useState)(()=>C(c)),E=C(s??w);function D(e){g||p||(s===void 0&&T(e),l?.(e))}return(0,r.jsxs)(`fieldset`,{ref:y,role:`radiogroup`,"aria-readonly":p||void 0,disabled:g,className:e.t(`min-w-0`,_),...v,children:[(0,r.jsx)(`legend`,{className:e.t(t.a,!m&&`sr-only`),children:o}),(0,r.jsxs)(`div`,{className:`mt-1 flex w-fit max-w-full items-center overflow-x-auto overscroll-x-contain py-1 scrollbar-none`,children:[Array.from({length:S},(t,n)=>{let o=n+1,s=o<=E;return(0,r.jsxs)(`label`,{className:e.t(`relative inline-flex shrink-0 items-center justify-center rounded-sm`,a[f],g?`cursor-not-allowed opacity-40`:p?`cursor-default`:`cursor-pointer`),children:[(0,r.jsx)(`input`,{type:`radio`,name:x,value:o,checked:E===o,disabled:g,readOnly:p,"aria-label":`${o} ${o===1?`star`:`stars`}`,onChange:()=>D(o),className:`peer sr-only`}),(0,r.jsx)(`span`,{className:`block rounded-sm peer-focus-visible:ring-2 peer-focus-visible:ring-focus-ring/35 peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-bg`,children:(0,r.jsx)(`svg`,{viewBox:`0 0 24 24`,"aria-hidden":`true`,className:e.t(i[f],`transition-colors`,s?`fill-warning text-warning`:`fill-transparent text-border-strong`,!g&&!p&&`hover:text-warning`),children:(0,r.jsx)(`path`,{stroke:`currentColor`,strokeWidth:`1.75`,strokeLinejoin:`round`,d:`m12 2.8 2.75 5.57 6.15.9-4.45 4.33 1.05 6.12L12 16.83l-5.5 2.89 1.05-6.12L3.1 9.27l6.15-.9L12 2.8Z`})})})]},o)}),h&&(0,r.jsxs)(`output`,{className:`ml-2 text-xs tabular-nums text-muted-foreground`,"aria-live":`polite`,children:[E,`/`,S]})]})]})});o.displayName=`Rating`,exports.Rating=o;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FieldsetHTMLAttributes } from 'react';
|
|
2
|
+
export type RatingSize = "sm" | "md" | "lg";
|
|
3
|
+
export interface RatingProps extends Omit<FieldsetHTMLAttributes<HTMLFieldSetElement>, "onChange"> {
|
|
4
|
+
label: string;
|
|
5
|
+
value?: number;
|
|
6
|
+
defaultValue?: number;
|
|
7
|
+
onValueChange?: (value: number) => void;
|
|
8
|
+
max?: number;
|
|
9
|
+
name?: string;
|
|
10
|
+
size?: RatingSize;
|
|
11
|
+
readOnly?: boolean;
|
|
12
|
+
showLabel?: boolean;
|
|
13
|
+
showValue?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const Rating: import('react').ForwardRefExoticComponent<RatingProps & import('react').RefAttributes<HTMLFieldSetElement>>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as e } from "../cn-DpgY2leY.js";
|
|
3
|
+
import { a as t } from "../component-styles-Bgy44fc8.js";
|
|
4
|
+
import { forwardRef as n, useId as r, useState as i } from "react";
|
|
5
|
+
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/rating.tsx
|
|
7
|
+
var s = {
|
|
8
|
+
sm: "size-4",
|
|
9
|
+
md: "size-5",
|
|
10
|
+
lg: "size-6"
|
|
11
|
+
}, c = {
|
|
12
|
+
sm: "size-8",
|
|
13
|
+
md: "size-9",
|
|
14
|
+
lg: "size-10"
|
|
15
|
+
}, l = n(({ label: n, value: l, defaultValue: u = 0, onValueChange: d, max: f = 5, name: p, size: m = "md", readOnly: h = !1, showLabel: g = !0, showValue: _ = !1, disabled: v, className: y, ...b }, x) => {
|
|
16
|
+
let S = r(), C = p ?? S, w = Number.isFinite(f) ? Math.max(1, Math.floor(f)) : 5, T = (e) => Number.isFinite(e) ? Math.max(0, Math.min(w, e)) : 0, [E, D] = i(() => T(u)), O = T(l ?? E);
|
|
17
|
+
function k(e) {
|
|
18
|
+
v || h || (l === void 0 && D(e), d?.(e));
|
|
19
|
+
}
|
|
20
|
+
return /* @__PURE__ */ o("fieldset", {
|
|
21
|
+
ref: x,
|
|
22
|
+
role: "radiogroup",
|
|
23
|
+
"aria-readonly": h || void 0,
|
|
24
|
+
disabled: v,
|
|
25
|
+
className: e("min-w-0", y),
|
|
26
|
+
...b,
|
|
27
|
+
children: [/* @__PURE__ */ a("legend", {
|
|
28
|
+
className: e(t, !g && "sr-only"),
|
|
29
|
+
children: n
|
|
30
|
+
}), /* @__PURE__ */ o("div", {
|
|
31
|
+
className: "mt-1 flex w-fit max-w-full items-center overflow-x-auto overscroll-x-contain py-1 scrollbar-none",
|
|
32
|
+
children: [Array.from({ length: w }, (t, n) => {
|
|
33
|
+
let r = n + 1, i = r <= O;
|
|
34
|
+
return /* @__PURE__ */ o("label", {
|
|
35
|
+
className: e("relative inline-flex shrink-0 items-center justify-center rounded-sm", c[m], v ? "cursor-not-allowed opacity-40" : h ? "cursor-default" : "cursor-pointer"),
|
|
36
|
+
children: [/* @__PURE__ */ a("input", {
|
|
37
|
+
type: "radio",
|
|
38
|
+
name: C,
|
|
39
|
+
value: r,
|
|
40
|
+
checked: O === r,
|
|
41
|
+
disabled: v,
|
|
42
|
+
readOnly: h,
|
|
43
|
+
"aria-label": `${r} ${r === 1 ? "star" : "stars"}`,
|
|
44
|
+
onChange: () => k(r),
|
|
45
|
+
className: "peer sr-only"
|
|
46
|
+
}), /* @__PURE__ */ a("span", {
|
|
47
|
+
className: "block rounded-sm peer-focus-visible:ring-2 peer-focus-visible:ring-focus-ring/35 peer-focus-visible:ring-offset-2 peer-focus-visible:ring-offset-bg",
|
|
48
|
+
children: /* @__PURE__ */ a("svg", {
|
|
49
|
+
viewBox: "0 0 24 24",
|
|
50
|
+
"aria-hidden": "true",
|
|
51
|
+
className: e(s[m], "transition-colors", i ? "fill-warning text-warning" : "fill-transparent text-border-strong", !v && !h && "hover:text-warning"),
|
|
52
|
+
children: /* @__PURE__ */ a("path", {
|
|
53
|
+
stroke: "currentColor",
|
|
54
|
+
strokeWidth: "1.75",
|
|
55
|
+
strokeLinejoin: "round",
|
|
56
|
+
d: "m12 2.8 2.75 5.57 6.15.9-4.45 4.33 1.05 6.12L12 16.83l-5.5 2.89 1.05-6.12L3.1 9.27l6.15-.9L12 2.8Z"
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
})]
|
|
60
|
+
}, r);
|
|
61
|
+
}), _ && /* @__PURE__ */ o("output", {
|
|
62
|
+
className: "ml-2 text-xs tabular-nums text-muted-foreground",
|
|
63
|
+
"aria-live": "polite",
|
|
64
|
+
children: [
|
|
65
|
+
O,
|
|
66
|
+
"/",
|
|
67
|
+
w
|
|
68
|
+
]
|
|
69
|
+
})]
|
|
70
|
+
})]
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
l.displayName = "Rating";
|
|
74
|
+
//#endregion
|
|
75
|
+
export { l as Rating };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs");require("../component-styles-DOUctc8_.cjs");let t=require("react"),n=require("react/jsx-runtime");var r={vertical:`overflow-y-auto overflow-x-hidden`,horizontal:`overflow-x-auto overflow-y-hidden`,both:`overflow-auto`},i=(0,t.forwardRef)(({orientation:t=`vertical`,hideScrollbar:i=!1,keyboardNavigable:a=!0,className:o,tabIndex:s,...c},l)=>(0,n.jsx)(`div`,{ref:l,"data-orientation":t,tabIndex:s??(a?0:void 0),className:e.t(`relative overscroll-contain rounded-[var(--radius-sm)]`,a&&`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/35 focus-visible:ring-offset-2 focus-visible:ring-offset-bg`,r[t],i&&`scrollbar-none`,o),...c}));i.displayName=`ScrollArea`,exports.ScrollArea=i;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export type ScrollAreaOrientation = "vertical" | "horizontal" | "both";
|
|
3
|
+
export interface ScrollAreaProps extends HTMLAttributes<HTMLDivElement> {
|
|
4
|
+
orientation?: ScrollAreaOrientation;
|
|
5
|
+
hideScrollbar?: boolean;
|
|
6
|
+
keyboardNavigable?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const ScrollArea: import('react').ForwardRefExoticComponent<ScrollAreaProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { t as e } from "../cn-DpgY2leY.js";
|
|
2
|
+
import "../component-styles-Bgy44fc8.js";
|
|
3
|
+
import { forwardRef as t } from "react";
|
|
4
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/scroll-area.tsx
|
|
6
|
+
var r = {
|
|
7
|
+
vertical: "overflow-y-auto overflow-x-hidden",
|
|
8
|
+
horizontal: "overflow-x-auto overflow-y-hidden",
|
|
9
|
+
both: "overflow-auto"
|
|
10
|
+
}, i = t(({ orientation: t = "vertical", hideScrollbar: i = !1, keyboardNavigable: a = !0, className: o, tabIndex: s, ...c }, l) => /* @__PURE__ */ n("div", {
|
|
11
|
+
ref: l,
|
|
12
|
+
"data-orientation": t,
|
|
13
|
+
tabIndex: s ?? (a ? 0 : void 0),
|
|
14
|
+
className: e("relative overscroll-contain rounded-[var(--radius-sm)]", a && "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/35 focus-visible:ring-offset-2 focus-visible:ring-offset-bg", r[t], i && "scrollbar-none", o),
|
|
15
|
+
...c
|
|
16
|
+
}));
|
|
17
|
+
i.displayName = "ScrollArea";
|
|
18
|
+
//#endregion
|
|
19
|
+
export { i as ScrollArea };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs"),t=require("../component-styles-DOUctc8_.cjs");let n=require("react"),r=require("react/jsx-runtime");var i={sm:`h-8 px-2.5 text-xs`,md:`h-9 px-3 text-sm`,lg:`h-10 px-3.5 text-sm`},a={bottom:`top-full mt-1.5`,top:`bottom-full mb-1.5`},o=e=>String(e).padStart(2,`0`);function s(e){if(!e)return null;let t=/^(?:([01]\d|2[0-3])):([0-5]\d)(?::([0-5]\d))?$/.exec(e);return t?{hour:Number(t[1]),minute:Number(t[2]),second:Number(t[3]??0)}:null}function c(e){return e.hour*3600+e.minute*60+e.second}function l(e,t){let n=`${o(e.hour)}:${o(e.minute)}`;return t?`${n}:${o(e.second)}`:n}function u(e,t,n){let r=s(e);if(!r)return``;let i=o(r.minute),a=n?`:${o(r.second)}`:``;if(t===`24`)return`${o(r.hour)}:${i}${a}`;let c=r.hour>=12?`PM`:`AM`;return`${r.hour%12||12}:${i}${a} ${c}`}function d(e){let t=new Date,n=Math.floor(59/e)*e;return{hour:t.getHours(),minute:Math.min(n,Math.round(t.getMinutes()/e)*e),second:t.getSeconds()}}function f({label:n,name:i,options:a,value:o,onSelect:s}){let c=`${i}-label`;function l(e,t){if(![`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key))return;e.preventDefault();let n=e.key===`Home`?0:e.key===`End`?a.length-1:(t+(e.key===`ArrowDown`?1:-1)+a.length)%a.length,r=a[n];r&&(s(r.value),e.currentTarget.closest(`[data-time-column]`)?.querySelectorAll(`[role="option"]`)[n]?.focus())}return(0,r.jsxs)(`div`,{className:`min-w-0`,children:[(0,r.jsx)(`p`,{id:c,className:`mb-1.5 truncate text-center text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:n}),(0,r.jsx)(`div`,{role:`listbox`,"aria-labelledby":c,"data-time-column":i,className:`max-h-44 min-w-0 overflow-y-auto overscroll-contain rounded-[var(--radius-md)] border border-border bg-surface p-1 scrollbar-thin`,children:a.map((n,i)=>{let a=n.value===o;return(0,r.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":a,tabIndex:a?0:-1,onClick:()=>s(n.value),onKeyDown:e=>l(e,i),className:e.t(`flex h-9 w-full items-center justify-center rounded-[var(--radius-sm)] px-1 text-xs tabular-nums transition-colors`,t.s,a?`bg-primary font-semibold text-primary-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:n.label},n.value)})})]})}var p=(0,n.forwardRef)(({label:p,hint:m,error:h,value:g,defaultValue:ee=``,onValueChange:_,format:v=`12`,minuteStep:y=5,showSeconds:b=!1,min:te,max:ne,name:x,disabled:S=!1,required:C=!1,clearable:w=!0,placeholder:re=`Select time…`,size:ie=`md`,side:ae=`bottom`,triggerClassName:oe,panelClassName:se,labelClassName:T,messageClassName:E,className:ce,id:le,onBlur:D,...O},k)=>{let A=(0,n.useId)(),j=le??A,M=`${j}-panel`,N=`${j}-message`,P=(0,n.useRef)(null),F=(0,n.useRef)(null);(0,n.useImperativeHandle)(k,()=>F.current);let I=Number.isFinite(y)?Math.max(1,Math.min(30,Math.floor(y))):5,L=e=>{let t=s(e);return t?l(t,b):``},[R,z]=(0,n.useState)(()=>L(ee)),B=L(g??R),[V,H]=(0,n.useState)(!1),[U,W]=(0,n.useState)(()=>s(B)??d(I)),ue=Array.from({length:24},(e,t)=>({value:t,label:o(t)})),de=Array.from({length:12},(e,t)=>({value:t+1,label:o(t+1)})),fe=Array.from({length:Math.floor(59/I)+1},(e,t)=>{let n=t*I;return{value:n,label:o(n)}}),pe=Array.from({length:60},(e,t)=>({value:t,label:o(t)})),me=[{value:0,label:`AM`},{value:1,label:`PM`}],G=s(te),K=s(ne),q=c(U),J=G?q<c(G):!1,he=K?q>c(K):!1,Y=J||he,X=u(B,v,b);function Z(){S||(W(s(B)??d(I)),H(!0))}function Q(e=!1){H(!1),e&&F.current?.focus()}function $(e){g===void 0&&z(e),_?.(e),Q(!0)}return(0,n.useEffect)(()=>{if(!V)return;let e=e=>{P.current?.contains(e.target)||Q()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[V]),(0,n.useEffect)(()=>{V&&requestAnimationFrame(()=>{P.current?.querySelector(`[data-time-column="hour"] [aria-selected="true"]`)?.focus()})},[V]),(0,r.jsxs)(`div`,{ref:P,className:e.t(`relative`,t.o,ce),onBlur:e=>{D?.(e),e.currentTarget.contains(e.relatedTarget)||Q()},onKeyDown:e=>{e.key===`Escape`&&V&&(e.preventDefault(),Q(!0))},...O,children:[p&&(0,r.jsxs)(`label`,{htmlFor:j,className:e.t(`text-xs font-semibold leading-5 text-foreground`,T),children:[p,C&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(`span`,{"aria-hidden":`true`,className:`ml-1 text-destructive`,children:`*`}),(0,r.jsx)(`span`,{className:`sr-only`,children:` (required)`})]})]}),(0,r.jsxs)(`button`,{ref:F,id:j,type:`button`,disabled:S,"aria-expanded":V,"aria-haspopup":`dialog`,"aria-controls":M,"aria-invalid":h?!0:void 0,"aria-required":C||void 0,"aria-describedby":h||m?N:void 0,onClick:()=>V?Q():Z(),onKeyDown:e=>{e.key===`ArrowDown`&&!V&&(e.preventDefault(),Z())},className:e.t(`flex w-full min-w-0 items-center gap-2 rounded-[var(--radius-md)] text-left`,t.t,t.s,h&&`border-destructive/60 hover:border-destructive/70 focus-within:border-destructive focus-within:ring-destructive/20`,i[ie],oe),children:[(0,r.jsxs)(`svg`,{"aria-hidden":`true`,width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,className:`shrink-0 text-muted-foreground`,children:[(0,r.jsx)(`circle`,{cx:`12`,cy:`12`,r:`9`}),(0,r.jsx)(`path`,{d:`M12 7v5l3 2`})]}),(0,r.jsx)(`span`,{className:e.t(`min-w-0 flex-1 truncate`,X?`text-foreground`:`text-muted-foreground`),children:X||re}),(0,r.jsx)(`svg`,{"aria-hidden":`true`,width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:e.t(`shrink-0 text-muted-foreground transition-transform`,V&&`rotate-180`),children:(0,r.jsx)(`path`,{d:`m6 9 6 6 6-6`})})]}),x&&(0,r.jsx)(`input`,{type:`hidden`,name:x,value:B,disabled:S}),V&&(0,r.jsxs)(`div`,{id:M,role:`dialog`,"aria-label":p?`Choose ${p.toLowerCase()}`:`Choose time`,className:e.t(`absolute left-0 z-50 w-[min(22rem,calc(100vw-2rem))] max-h-[min(30rem,calc(100dvh-2rem))] overflow-y-auto rounded-[var(--radius-lg)] border border-border bg-surface-raised p-3 shadow-floating`,a[ae],se),children:[(0,r.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,r.jsxs)(`div`,{className:`min-w-0`,children:[(0,r.jsx)(`p`,{className:`truncate text-sm font-semibold text-foreground`,children:`Choose time`}),(0,r.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[v===`12`?`12-hour`:`24-hour`,` format`]})]}),(0,r.jsx)(`button`,{type:`button`,onClick:()=>W(d(I)),className:e.t(`h-8 rounded-md px-2.5 text-xs font-medium text-accent-700 hover:bg-muted dark:text-accent-300`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/35 focus-visible:ring-offset-2 focus-visible:ring-offset-bg`),children:`Now`})]}),(0,r.jsxs)(`div`,{className:e.t(`grid gap-2`,v===`12`&&b?`grid-cols-4`:b||v===`12`?`grid-cols-3`:`grid-cols-2`),children:[(0,r.jsx)(f,{label:`Hour`,name:`hour`,options:v===`24`?ue:de,value:v===`24`?U.hour:U.hour%12||12,onSelect:e=>W(t=>({...t,hour:v===`24`?e:e%12+(t.hour>=12?12:0)}))}),(0,r.jsx)(f,{label:`Minute`,name:`minute`,options:fe,value:U.minute,onSelect:e=>W(t=>({...t,minute:e}))}),b&&(0,r.jsx)(f,{label:`Second`,name:`second`,options:pe,value:U.second,onSelect:e=>W(t=>({...t,second:e}))}),v===`12`&&(0,r.jsx)(f,{label:`Period`,name:`period`,options:me,value:+(U.hour>=12),onSelect:e=>W(t=>({...t,hour:t.hour%12+e*12}))})]}),Y&&(0,r.jsxs)(`p`,{role:`status`,className:`mt-2 text-xs text-destructive`,children:[`Choose a time `,J?`at or after ${u(l(G,b),v,b)}`:`at or before ${u(l(K,b),v,b)}`,`.`]}),(0,r.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-end gap-2 border-t border-border pt-3`,children:[w&&!C&&B&&(0,r.jsx)(`button`,{type:`button`,onClick:()=>$(``),className:e.t(`mr-auto h-8 rounded-md px-2.5 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/35 focus-visible:ring-offset-2 focus-visible:ring-offset-bg`),children:`Clear`}),(0,r.jsx)(`button`,{type:`button`,onClick:()=>Q(!0),className:e.t(`h-8 rounded-md px-3 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/35 focus-visible:ring-offset-2 focus-visible:ring-offset-bg`),children:`Cancel`}),(0,r.jsx)(`button`,{type:`button`,disabled:Y,onClick:()=>$(l(U,b)),className:e.t(`h-8 rounded-md bg-primary px-3 text-xs font-semibold text-primary-foreground hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/35 focus-visible:ring-offset-2 focus-visible:ring-offset-bg`),children:`Apply`})]})]}),h&&(0,r.jsx)(`p`,{id:N,"aria-live":`polite`,className:e.t(`text-xs leading-5 text-destructive`,E),children:h}),m&&!h&&(0,r.jsx)(`p`,{id:N,className:e.t(`text-xs leading-5 text-muted-foreground`,E),children:m})]})});p.displayName=`TimePicker`,exports.TimePicker=p;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export type TimePickerSize = "sm" | "md" | "lg";
|
|
3
|
+
export type TimePickerFormat = "12" | "24";
|
|
4
|
+
export type TimePickerSide = "top" | "bottom";
|
|
5
|
+
export interface TimePickerProps extends Omit<HTMLAttributes<HTMLDivElement>, "defaultValue" | "onChange"> {
|
|
6
|
+
label?: string;
|
|
7
|
+
hint?: string;
|
|
8
|
+
error?: string;
|
|
9
|
+
value?: string;
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
onValueChange?: (value: string) => void;
|
|
12
|
+
format?: TimePickerFormat;
|
|
13
|
+
minuteStep?: number;
|
|
14
|
+
showSeconds?: boolean;
|
|
15
|
+
min?: string;
|
|
16
|
+
max?: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
required?: boolean;
|
|
20
|
+
clearable?: boolean;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
size?: TimePickerSize;
|
|
23
|
+
side?: TimePickerSide;
|
|
24
|
+
triggerClassName?: string;
|
|
25
|
+
panelClassName?: string;
|
|
26
|
+
labelClassName?: string;
|
|
27
|
+
messageClassName?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare const TimePicker: import('react').ForwardRefExoticComponent<TimePickerProps & import('react').RefAttributes<HTMLButtonElement>>;
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as e } from "../cn-DpgY2leY.js";
|
|
3
|
+
import { o as t, s as n, t as r } from "../component-styles-Bgy44fc8.js";
|
|
4
|
+
import { forwardRef as i, useEffect as a, useId as o, useImperativeHandle as s, useRef as c, useState as l } from "react";
|
|
5
|
+
import { Fragment as ee, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/time-picker.tsx
|
|
7
|
+
var te = {
|
|
8
|
+
sm: "h-8 px-2.5 text-xs",
|
|
9
|
+
md: "h-9 px-3 text-sm",
|
|
10
|
+
lg: "h-10 px-3.5 text-sm"
|
|
11
|
+
}, ne = {
|
|
12
|
+
bottom: "top-full mt-1.5",
|
|
13
|
+
top: "bottom-full mb-1.5"
|
|
14
|
+
}, f = (e) => String(e).padStart(2, "0");
|
|
15
|
+
function p(e) {
|
|
16
|
+
if (!e) return null;
|
|
17
|
+
let t = /^(?:([01]\d|2[0-3])):([0-5]\d)(?::([0-5]\d))?$/.exec(e);
|
|
18
|
+
return t ? {
|
|
19
|
+
hour: Number(t[1]),
|
|
20
|
+
minute: Number(t[2]),
|
|
21
|
+
second: Number(t[3] ?? 0)
|
|
22
|
+
} : null;
|
|
23
|
+
}
|
|
24
|
+
function m(e) {
|
|
25
|
+
return e.hour * 3600 + e.minute * 60 + e.second;
|
|
26
|
+
}
|
|
27
|
+
function h(e, t) {
|
|
28
|
+
let n = `${f(e.hour)}:${f(e.minute)}`;
|
|
29
|
+
return t ? `${n}:${f(e.second)}` : n;
|
|
30
|
+
}
|
|
31
|
+
function g(e, t, n) {
|
|
32
|
+
let r = p(e);
|
|
33
|
+
if (!r) return "";
|
|
34
|
+
let i = f(r.minute), a = n ? `:${f(r.second)}` : "";
|
|
35
|
+
if (t === "24") return `${f(r.hour)}:${i}${a}`;
|
|
36
|
+
let o = r.hour >= 12 ? "PM" : "AM";
|
|
37
|
+
return `${r.hour % 12 || 12}:${i}${a} ${o}`;
|
|
38
|
+
}
|
|
39
|
+
function _(e) {
|
|
40
|
+
let t = /* @__PURE__ */ new Date(), n = Math.floor(59 / e) * e;
|
|
41
|
+
return {
|
|
42
|
+
hour: t.getHours(),
|
|
43
|
+
minute: Math.min(n, Math.round(t.getMinutes() / e) * e),
|
|
44
|
+
second: t.getSeconds()
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function v({ label: t, name: r, options: i, value: a, onSelect: o }) {
|
|
48
|
+
let s = `${r}-label`;
|
|
49
|
+
function c(e, t) {
|
|
50
|
+
if (![
|
|
51
|
+
"ArrowUp",
|
|
52
|
+
"ArrowDown",
|
|
53
|
+
"Home",
|
|
54
|
+
"End"
|
|
55
|
+
].includes(e.key)) return;
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
let n = e.key === "Home" ? 0 : e.key === "End" ? i.length - 1 : (t + (e.key === "ArrowDown" ? 1 : -1) + i.length) % i.length, r = i[n];
|
|
58
|
+
r && (o(r.value), e.currentTarget.closest("[data-time-column]")?.querySelectorAll("[role=\"option\"]")[n]?.focus());
|
|
59
|
+
}
|
|
60
|
+
return /* @__PURE__ */ d("div", {
|
|
61
|
+
className: "min-w-0",
|
|
62
|
+
children: [/* @__PURE__ */ u("p", {
|
|
63
|
+
id: s,
|
|
64
|
+
className: "mb-1.5 truncate text-center text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",
|
|
65
|
+
children: t
|
|
66
|
+
}), /* @__PURE__ */ u("div", {
|
|
67
|
+
role: "listbox",
|
|
68
|
+
"aria-labelledby": s,
|
|
69
|
+
"data-time-column": r,
|
|
70
|
+
className: "max-h-44 min-w-0 overflow-y-auto overscroll-contain rounded-[var(--radius-md)] border border-border bg-surface p-1 scrollbar-thin",
|
|
71
|
+
children: i.map((t, r) => {
|
|
72
|
+
let i = t.value === a;
|
|
73
|
+
return /* @__PURE__ */ u("button", {
|
|
74
|
+
type: "button",
|
|
75
|
+
role: "option",
|
|
76
|
+
"aria-selected": i,
|
|
77
|
+
tabIndex: i ? 0 : -1,
|
|
78
|
+
onClick: () => o(t.value),
|
|
79
|
+
onKeyDown: (e) => c(e, r),
|
|
80
|
+
className: e("flex h-9 w-full items-center justify-center rounded-[var(--radius-sm)] px-1 text-xs tabular-nums transition-colors", n, i ? "bg-primary font-semibold text-primary-foreground" : "text-muted-foreground hover:bg-muted hover:text-foreground"),
|
|
81
|
+
children: t.label
|
|
82
|
+
}, t.value);
|
|
83
|
+
})
|
|
84
|
+
})]
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
var y = i(({ label: i, hint: y, error: b, value: x, defaultValue: S = "", onValueChange: C, format: w = "12", minuteStep: T = 5, showSeconds: E = !1, min: re, max: D, name: O, disabled: k = !1, required: A = !1, clearable: ie = !0, placeholder: ae = "Select time…", size: oe = "md", side: se = "bottom", triggerClassName: ce, panelClassName: le, labelClassName: ue, messageClassName: j, className: de, id: fe, onBlur: pe, ...me }, he) => {
|
|
88
|
+
let ge = o(), M = fe ?? ge, N = `${M}-panel`, P = `${M}-message`, F = c(null), I = c(null);
|
|
89
|
+
s(he, () => I.current);
|
|
90
|
+
let L = Number.isFinite(T) ? Math.max(1, Math.min(30, Math.floor(T))) : 5, R = (e) => {
|
|
91
|
+
let t = p(e);
|
|
92
|
+
return t ? h(t, E) : "";
|
|
93
|
+
}, [_e, ve] = l(() => R(S)), z = R(x ?? _e), [B, V] = l(!1), [H, U] = l(() => p(z) ?? _(L)), ye = Array.from({ length: 24 }, (e, t) => ({
|
|
94
|
+
value: t,
|
|
95
|
+
label: f(t)
|
|
96
|
+
})), be = Array.from({ length: 12 }, (e, t) => ({
|
|
97
|
+
value: t + 1,
|
|
98
|
+
label: f(t + 1)
|
|
99
|
+
})), xe = Array.from({ length: Math.floor(59 / L) + 1 }, (e, t) => {
|
|
100
|
+
let n = t * L;
|
|
101
|
+
return {
|
|
102
|
+
value: n,
|
|
103
|
+
label: f(n)
|
|
104
|
+
};
|
|
105
|
+
}), Se = Array.from({ length: 60 }, (e, t) => ({
|
|
106
|
+
value: t,
|
|
107
|
+
label: f(t)
|
|
108
|
+
})), W = [{
|
|
109
|
+
value: 0,
|
|
110
|
+
label: "AM"
|
|
111
|
+
}, {
|
|
112
|
+
value: 1,
|
|
113
|
+
label: "PM"
|
|
114
|
+
}], G = p(re), K = p(D), q = m(H), J = G ? q < m(G) : !1, Ce = K ? q > m(K) : !1, Y = J || Ce, X = g(z, w, E);
|
|
115
|
+
function Z() {
|
|
116
|
+
k || (U(p(z) ?? _(L)), V(!0));
|
|
117
|
+
}
|
|
118
|
+
function Q(e = !1) {
|
|
119
|
+
V(!1), e && I.current?.focus();
|
|
120
|
+
}
|
|
121
|
+
function $(e) {
|
|
122
|
+
x === void 0 && ve(e), C?.(e), Q(!0);
|
|
123
|
+
}
|
|
124
|
+
return a(() => {
|
|
125
|
+
if (!B) return;
|
|
126
|
+
let e = (e) => {
|
|
127
|
+
F.current?.contains(e.target) || Q();
|
|
128
|
+
};
|
|
129
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
130
|
+
}, [B]), a(() => {
|
|
131
|
+
B && requestAnimationFrame(() => {
|
|
132
|
+
F.current?.querySelector("[data-time-column=\"hour\"] [aria-selected=\"true\"]")?.focus();
|
|
133
|
+
});
|
|
134
|
+
}, [B]), /* @__PURE__ */ d("div", {
|
|
135
|
+
ref: F,
|
|
136
|
+
className: e("relative", t, de),
|
|
137
|
+
onBlur: (e) => {
|
|
138
|
+
pe?.(e), e.currentTarget.contains(e.relatedTarget) || Q();
|
|
139
|
+
},
|
|
140
|
+
onKeyDown: (e) => {
|
|
141
|
+
e.key === "Escape" && B && (e.preventDefault(), Q(!0));
|
|
142
|
+
},
|
|
143
|
+
...me,
|
|
144
|
+
children: [
|
|
145
|
+
i && /* @__PURE__ */ d("label", {
|
|
146
|
+
htmlFor: M,
|
|
147
|
+
className: e("text-xs font-semibold leading-5 text-foreground", ue),
|
|
148
|
+
children: [i, A && /* @__PURE__ */ d(ee, { children: [/* @__PURE__ */ u("span", {
|
|
149
|
+
"aria-hidden": "true",
|
|
150
|
+
className: "ml-1 text-destructive",
|
|
151
|
+
children: "*"
|
|
152
|
+
}), /* @__PURE__ */ u("span", {
|
|
153
|
+
className: "sr-only",
|
|
154
|
+
children: " (required)"
|
|
155
|
+
})] })]
|
|
156
|
+
}),
|
|
157
|
+
/* @__PURE__ */ d("button", {
|
|
158
|
+
ref: I,
|
|
159
|
+
id: M,
|
|
160
|
+
type: "button",
|
|
161
|
+
disabled: k,
|
|
162
|
+
"aria-expanded": B,
|
|
163
|
+
"aria-haspopup": "dialog",
|
|
164
|
+
"aria-controls": N,
|
|
165
|
+
"aria-invalid": b ? !0 : void 0,
|
|
166
|
+
"aria-required": A || void 0,
|
|
167
|
+
"aria-describedby": b || y ? P : void 0,
|
|
168
|
+
onClick: () => B ? Q() : Z(),
|
|
169
|
+
onKeyDown: (e) => {
|
|
170
|
+
e.key === "ArrowDown" && !B && (e.preventDefault(), Z());
|
|
171
|
+
},
|
|
172
|
+
className: e("flex w-full min-w-0 items-center gap-2 rounded-[var(--radius-md)] text-left", r, n, b && "border-destructive/60 hover:border-destructive/70 focus-within:border-destructive focus-within:ring-destructive/20", te[oe], ce),
|
|
173
|
+
children: [
|
|
174
|
+
/* @__PURE__ */ d("svg", {
|
|
175
|
+
"aria-hidden": "true",
|
|
176
|
+
width: "15",
|
|
177
|
+
height: "15",
|
|
178
|
+
viewBox: "0 0 24 24",
|
|
179
|
+
fill: "none",
|
|
180
|
+
stroke: "currentColor",
|
|
181
|
+
strokeWidth: "2",
|
|
182
|
+
strokeLinecap: "round",
|
|
183
|
+
strokeLinejoin: "round",
|
|
184
|
+
className: "shrink-0 text-muted-foreground",
|
|
185
|
+
children: [/* @__PURE__ */ u("circle", {
|
|
186
|
+
cx: "12",
|
|
187
|
+
cy: "12",
|
|
188
|
+
r: "9"
|
|
189
|
+
}), /* @__PURE__ */ u("path", { d: "M12 7v5l3 2" })]
|
|
190
|
+
}),
|
|
191
|
+
/* @__PURE__ */ u("span", {
|
|
192
|
+
className: e("min-w-0 flex-1 truncate", X ? "text-foreground" : "text-muted-foreground"),
|
|
193
|
+
children: X || ae
|
|
194
|
+
}),
|
|
195
|
+
/* @__PURE__ */ u("svg", {
|
|
196
|
+
"aria-hidden": "true",
|
|
197
|
+
width: "13",
|
|
198
|
+
height: "13",
|
|
199
|
+
viewBox: "0 0 24 24",
|
|
200
|
+
fill: "none",
|
|
201
|
+
stroke: "currentColor",
|
|
202
|
+
strokeWidth: "2.5",
|
|
203
|
+
strokeLinecap: "round",
|
|
204
|
+
strokeLinejoin: "round",
|
|
205
|
+
className: e("shrink-0 text-muted-foreground transition-transform", B && "rotate-180"),
|
|
206
|
+
children: /* @__PURE__ */ u("path", { d: "m6 9 6 6 6-6" })
|
|
207
|
+
})
|
|
208
|
+
]
|
|
209
|
+
}),
|
|
210
|
+
O && /* @__PURE__ */ u("input", {
|
|
211
|
+
type: "hidden",
|
|
212
|
+
name: O,
|
|
213
|
+
value: z,
|
|
214
|
+
disabled: k
|
|
215
|
+
}),
|
|
216
|
+
B && /* @__PURE__ */ d("div", {
|
|
217
|
+
id: N,
|
|
218
|
+
role: "dialog",
|
|
219
|
+
"aria-label": i ? `Choose ${i.toLowerCase()}` : "Choose time",
|
|
220
|
+
className: e("absolute left-0 z-50 w-[min(22rem,calc(100vw-2rem))] max-h-[min(30rem,calc(100dvh-2rem))] overflow-y-auto rounded-[var(--radius-lg)] border border-border bg-surface-raised p-3 shadow-floating", ne[se], le),
|
|
221
|
+
children: [
|
|
222
|
+
/* @__PURE__ */ d("div", {
|
|
223
|
+
className: "mb-3 flex items-center justify-between gap-3",
|
|
224
|
+
children: [/* @__PURE__ */ d("div", {
|
|
225
|
+
className: "min-w-0",
|
|
226
|
+
children: [/* @__PURE__ */ u("p", {
|
|
227
|
+
className: "truncate text-sm font-semibold text-foreground",
|
|
228
|
+
children: "Choose time"
|
|
229
|
+
}), /* @__PURE__ */ d("p", {
|
|
230
|
+
className: "text-[11px] text-muted-foreground",
|
|
231
|
+
children: [w === "12" ? "12-hour" : "24-hour", " format"]
|
|
232
|
+
})]
|
|
233
|
+
}), /* @__PURE__ */ u("button", {
|
|
234
|
+
type: "button",
|
|
235
|
+
onClick: () => U(_(L)),
|
|
236
|
+
className: e("h-8 rounded-md px-2.5 text-xs font-medium text-accent-700 hover:bg-muted dark:text-accent-300", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/35 focus-visible:ring-offset-2 focus-visible:ring-offset-bg"),
|
|
237
|
+
children: "Now"
|
|
238
|
+
})]
|
|
239
|
+
}),
|
|
240
|
+
/* @__PURE__ */ d("div", {
|
|
241
|
+
className: e("grid gap-2", w === "12" && E ? "grid-cols-4" : E || w === "12" ? "grid-cols-3" : "grid-cols-2"),
|
|
242
|
+
children: [
|
|
243
|
+
/* @__PURE__ */ u(v, {
|
|
244
|
+
label: "Hour",
|
|
245
|
+
name: "hour",
|
|
246
|
+
options: w === "24" ? ye : be,
|
|
247
|
+
value: w === "24" ? H.hour : H.hour % 12 || 12,
|
|
248
|
+
onSelect: (e) => U((t) => ({
|
|
249
|
+
...t,
|
|
250
|
+
hour: w === "24" ? e : e % 12 + (t.hour >= 12 ? 12 : 0)
|
|
251
|
+
}))
|
|
252
|
+
}),
|
|
253
|
+
/* @__PURE__ */ u(v, {
|
|
254
|
+
label: "Minute",
|
|
255
|
+
name: "minute",
|
|
256
|
+
options: xe,
|
|
257
|
+
value: H.minute,
|
|
258
|
+
onSelect: (e) => U((t) => ({
|
|
259
|
+
...t,
|
|
260
|
+
minute: e
|
|
261
|
+
}))
|
|
262
|
+
}),
|
|
263
|
+
E && /* @__PURE__ */ u(v, {
|
|
264
|
+
label: "Second",
|
|
265
|
+
name: "second",
|
|
266
|
+
options: Se,
|
|
267
|
+
value: H.second,
|
|
268
|
+
onSelect: (e) => U((t) => ({
|
|
269
|
+
...t,
|
|
270
|
+
second: e
|
|
271
|
+
}))
|
|
272
|
+
}),
|
|
273
|
+
w === "12" && /* @__PURE__ */ u(v, {
|
|
274
|
+
label: "Period",
|
|
275
|
+
name: "period",
|
|
276
|
+
options: W,
|
|
277
|
+
value: +(H.hour >= 12),
|
|
278
|
+
onSelect: (e) => U((t) => ({
|
|
279
|
+
...t,
|
|
280
|
+
hour: t.hour % 12 + e * 12
|
|
281
|
+
}))
|
|
282
|
+
})
|
|
283
|
+
]
|
|
284
|
+
}),
|
|
285
|
+
Y && /* @__PURE__ */ d("p", {
|
|
286
|
+
role: "status",
|
|
287
|
+
className: "mt-2 text-xs text-destructive",
|
|
288
|
+
children: [
|
|
289
|
+
"Choose a time ",
|
|
290
|
+
J ? `at or after ${g(h(G, E), w, E)}` : `at or before ${g(h(K, E), w, E)}`,
|
|
291
|
+
"."
|
|
292
|
+
]
|
|
293
|
+
}),
|
|
294
|
+
/* @__PURE__ */ d("div", {
|
|
295
|
+
className: "mt-3 flex flex-wrap items-center justify-end gap-2 border-t border-border pt-3",
|
|
296
|
+
children: [
|
|
297
|
+
ie && !A && z && /* @__PURE__ */ u("button", {
|
|
298
|
+
type: "button",
|
|
299
|
+
onClick: () => $(""),
|
|
300
|
+
className: e("mr-auto h-8 rounded-md px-2.5 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/35 focus-visible:ring-offset-2 focus-visible:ring-offset-bg"),
|
|
301
|
+
children: "Clear"
|
|
302
|
+
}),
|
|
303
|
+
/* @__PURE__ */ u("button", {
|
|
304
|
+
type: "button",
|
|
305
|
+
onClick: () => Q(!0),
|
|
306
|
+
className: e("h-8 rounded-md px-3 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/35 focus-visible:ring-offset-2 focus-visible:ring-offset-bg"),
|
|
307
|
+
children: "Cancel"
|
|
308
|
+
}),
|
|
309
|
+
/* @__PURE__ */ u("button", {
|
|
310
|
+
type: "button",
|
|
311
|
+
disabled: Y,
|
|
312
|
+
onClick: () => $(h(H, E)),
|
|
313
|
+
className: e("h-8 rounded-md bg-primary px-3 text-xs font-semibold text-primary-foreground hover:bg-primary-hover disabled:cursor-not-allowed disabled:opacity-40", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus-ring/35 focus-visible:ring-offset-2 focus-visible:ring-offset-bg"),
|
|
314
|
+
children: "Apply"
|
|
315
|
+
})
|
|
316
|
+
]
|
|
317
|
+
})
|
|
318
|
+
]
|
|
319
|
+
}),
|
|
320
|
+
b && /* @__PURE__ */ u("p", {
|
|
321
|
+
id: P,
|
|
322
|
+
"aria-live": "polite",
|
|
323
|
+
className: e("text-xs leading-5 text-destructive", j),
|
|
324
|
+
children: b
|
|
325
|
+
}),
|
|
326
|
+
y && !b && /* @__PURE__ */ u("p", {
|
|
327
|
+
id: P,
|
|
328
|
+
className: e("text-xs leading-5 text-muted-foreground", j),
|
|
329
|
+
children: y
|
|
330
|
+
})
|
|
331
|
+
]
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
y.displayName = "TimePicker";
|
|
335
|
+
//#endregion
|
|
336
|
+
export { y as TimePicker };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../cn-BdjraxxU.cjs"),t=require("../component-styles-DOUctc8_.cjs");let n=require("react"),r=require("react/jsx-runtime");var i={default:[`border border-transparent bg-transparent text-muted-foreground`,`hover:bg-muted hover:text-foreground`,`data-[state=on]:bg-accent-100 data-[state=on]:text-accent-800`,`dark:data-[state=on]:bg-accent-900/45 dark:data-[state=on]:text-accent-200`].join(` `),outline:[`border border-border bg-surface text-muted-foreground shadow-xs`,`hover:border-border-strong hover:bg-surface-muted hover:text-foreground`,`data-[state=on]:border-accent-300 data-[state=on]:bg-accent-50 data-[state=on]:text-accent-800`,`dark:data-[state=on]:border-accent-700 dark:data-[state=on]:bg-accent-900/35 dark:data-[state=on]:text-accent-200`].join(` `)},a={sm:`h-8 rounded-[var(--radius-md)] px-2.5 text-xs gap-1.5`,md:`h-9 rounded-[var(--radius-md)] px-3 text-sm gap-2`,lg:`h-10 rounded-[var(--radius-lg)] px-4 text-sm gap-2`,icon:`size-9 rounded-[var(--radius-md)] p-0`},o=[`inline-flex shrink-0 cursor-pointer select-none items-center justify-center font-medium`,`transition-[color,background-color,border-color,box-shadow] duration-150`,`disabled:pointer-events-none disabled:opacity-40`,t.s].join(` `),s=(0,n.forwardRef)(({pressed:t,defaultPressed:s=!1,onPressedChange:c,variant:l=`default`,size:u=`md`,className:d,type:f=`button`,onClick:p,...m},h)=>{let[g,_]=(0,n.useState)(s),v=t??g;return(0,r.jsx)(`button`,{ref:h,type:f,"aria-pressed":v,"data-state":v?`on`:`off`,className:e.t(o,i[l],a[u],d),onClick:e=>{if(p?.(e),e.defaultPrevented)return;let n=!v;t===void 0&&_(n),c?.(n)},...m})});s.displayName=`Toggle`;var c=(0,n.createContext)(null);function l(){let e=(0,n.useContext)(c);if(!e)throw Error(`ToggleGroupItem must be inside <ToggleGroup>`);return e}var u=(0,n.forwardRef)(({type:t=`single`,value:i,defaultValue:a,onValueChange:o,orientation:s=`horizontal`,variant:l=`default`,size:u=`md`,disabled:d=!1,loop:f=!0,className:p,children:m,...h},g)=>{let[_,v]=(0,n.useState)(()=>a??(t===`multiple`?[]:``)),y=i??_,b=o;function x(e){return t===`multiple`?Array.isArray(y)&&y.includes(e):y===e}function S(e){let n=t===`multiple`?(()=>{let t=Array.isArray(y)?y:[];return t.includes(e)?t.filter(t=>t!==e):[...t,e]})():y===e?``:e;i===void 0&&v(n),b?.(n)}return(0,r.jsx)(c.Provider,{value:{disabled:d,isPressed:x,loop:f,orientation:s,select:S,size:u,variant:l},children:(0,r.jsx)(`div`,{ref:g,role:`group`,"data-rui-toggle-group":``,"data-orientation":s,className:e.t(`inline-flex w-fit rounded-[var(--radius-lg)]`,s===`horizontal`?`max-w-full flex-row items-center gap-1 overflow-x-auto overscroll-x-contain p-0.5 scrollbar-none [&>*]:shrink-0`:`max-w-full flex-col items-stretch gap-1`,p),...h,children:m})})});u.displayName=`ToggleGroup`;var d=(0,n.forwardRef)(({value:t,variant:n,size:s,className:c,disabled:u,type:d=`button`,onClick:f,onKeyDown:p,...m},h)=>{let g=l(),_=g.isPressed(t),v=g.disabled||u;function y(e){if(p?.(e),e.defaultPrevented)return;let t=g.orientation===`horizontal`?`ArrowLeft`:`ArrowUp`,n=g.orientation===`horizontal`?`ArrowRight`:`ArrowDown`;if(e.key!==t&&e.key!==n&&e.key!==`Home`&&e.key!==`End`)return;let r=e.currentTarget.closest(`[data-rui-toggle-group]`),i=Array.from(r?.querySelectorAll(`[data-rui-toggle-item]:not(:disabled)`)??[]).filter(e=>e.closest(`[data-rui-toggle-group]`)===r),a=i.indexOf(e.currentTarget);if(a<0||i.length===0)return;e.preventDefault();let o=e.key===`Home`?0:e.key===`End`?i.length-1:a+(e.key===n?1:-1);o=g.loop?(o+i.length)%i.length:Math.max(0,Math.min(i.length-1,o)),i[o]?.focus()}return(0,r.jsx)(`button`,{ref:h,type:d,"aria-pressed":_,"data-rui-toggle-item":``,"data-state":_?`on`:`off`,disabled:v,className:e.t(o,i[n??g.variant],a[s??g.size],c),onClick:e=>{f?.(e),e.defaultPrevented||g.select(t)},onKeyDown:y,...m})});d.displayName=`ToggleGroupItem`,exports.Toggle=s,exports.ToggleGroup=u,exports.ToggleGroupItem=d,exports.toggleSizes=a,exports.toggleVariants=i;
|