@photon-ai/pho-ui 4.2.0 → 4.3.1

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.
Files changed (52) hide show
  1. package/dist/chunks/animated-height-I44sUq0n.js +48 -0
  2. package/dist/chunks/animated-height-I44sUq0n.js.map +1 -0
  3. package/dist/chunks/{basic-page-C3qjXfBe.js → basic-page-OrUVXKrx.js} +407 -407
  4. package/dist/chunks/basic-page-OrUVXKrx.js.map +1 -0
  5. package/dist/chunks/card-N-tvFsuV.js +64 -0
  6. package/dist/chunks/card-N-tvFsuV.js.map +1 -0
  7. package/dist/chunks/collapsible-Dv306QOT.js +40 -0
  8. package/dist/chunks/collapsible-Dv306QOT.js.map +1 -0
  9. package/dist/chunks/{command-CTYrSz9a.js → command-Cn000hMK.js} +3 -3
  10. package/dist/chunks/{command-CTYrSz9a.js.map → command-Cn000hMK.js.map} +1 -1
  11. package/dist/chunks/{data-table-BeUwsjmX.js → data-table-Mog6m3d9.js} +2 -2
  12. package/dist/chunks/{data-table-BeUwsjmX.js.map → data-table-Mog6m3d9.js.map} +1 -1
  13. package/dist/chunks/date-picker-CZbcNIe-.js +428 -0
  14. package/dist/chunks/date-picker-CZbcNIe-.js.map +1 -0
  15. package/dist/chunks/{dialog-BwfUFn6B.js → dialog-BOz_xOrn.js} +47 -51
  16. package/dist/chunks/{dialog-BwfUFn6B.js.map → dialog-BOz_xOrn.js.map} +1 -1
  17. package/dist/chunks/{filter-bar-D9lBBr4z.js → filter-bar-Cr_1zBFq.js} +2 -2
  18. package/dist/chunks/{filter-bar-D9lBBr4z.js.map → filter-bar-Cr_1zBFq.js.map} +1 -1
  19. package/dist/chunks/{sidebar-DRPe5CAh.js → sidebar-bLsjo_yb.js} +2 -2
  20. package/dist/chunks/{sidebar-DRPe5CAh.js.map → sidebar-bLsjo_yb.js.map} +1 -1
  21. package/dist/chunks/{trace-Hku-rImp.js → trace-CjOi3_IP.js} +2 -2
  22. package/dist/chunks/{trace-Hku-rImp.js.map → trace-CjOi3_IP.js.map} +1 -1
  23. package/dist/components/accordion.js +3 -3
  24. package/dist/components/accordion.js.map +1 -1
  25. package/dist/components/card.js +1 -1
  26. package/dist/components/collapsible.js +1 -1
  27. package/dist/components/command.js +1 -1
  28. package/dist/components/data-table.js +1 -1
  29. package/dist/components/date-picker.js +1 -1
  30. package/dist/components/dialog.js +1 -1
  31. package/dist/components/filter-bar.js +1 -1
  32. package/dist/components/trace.js +1 -1
  33. package/dist/index.js +8 -8
  34. package/dist/sections/basic-page.js +2 -2
  35. package/dist/sections/sidebar.js +1 -1
  36. package/dist/src/components/card/card.d.ts +20 -4
  37. package/dist/src/components/collapsible/collapsible.d.ts +1 -1
  38. package/dist/src/components/date-picker/date-picker.d.ts +25 -2
  39. package/dist/src/components/date-picker/index.d.ts +1 -1
  40. package/dist/src/index.d.ts +1 -1
  41. package/dist/src/sections/basic-page/basic-page.d.ts +5 -5
  42. package/dist/src/utils/animated-height.d.ts +6 -0
  43. package/package.json +1 -1
  44. package/dist/chunks/animated-height-CCO-Ocoz.js +0 -48
  45. package/dist/chunks/animated-height-CCO-Ocoz.js.map +0 -1
  46. package/dist/chunks/basic-page-C3qjXfBe.js.map +0 -1
  47. package/dist/chunks/card-DhDwtSi9.js +0 -56
  48. package/dist/chunks/card-DhDwtSi9.js.map +0 -1
  49. package/dist/chunks/collapsible-if7ncPbI.js +0 -28
  50. package/dist/chunks/collapsible-if7ncPbI.js.map +0 -1
  51. package/dist/chunks/date-picker-Ddeo1fNE.js +0 -422
  52. package/dist/chunks/date-picker-Ddeo1fNE.js.map +0 -1
@@ -1,56 +0,0 @@
1
- "use client";
2
- import { t as r } from "./cn-ChIgwEl3.js";
3
- import "react";
4
- import { jsx as s } from "react/jsx-runtime";
5
- var o = "border-pho-secondary bg-pho-primary rounded-lg border";
6
- function i({ className: t, ...a }) {
7
- return /* @__PURE__ */ s("div", {
8
- className: r(o, "flex flex-col gap-4 pt-5 pb-4", "has-[>[data-stat-group]:first-child]:pt-0 has-[>[data-stat]:first-child]:pt-0", "has-[>[data-stat-group]:last-child]:pb-0 has-[>[data-stat]:last-child]:pb-0", "has-[>:first-child:has([data-chart])]:pt-0", t),
9
- ...a
10
- });
11
- }
12
- function n({ className: t, ...a }) {
13
- return /* @__PURE__ */ s("div", {
14
- className: r("flex flex-col gap-0.5 px-5", t),
15
- ...a
16
- });
17
- }
18
- function p({ className: t, children: a, ...e }) {
19
- return /* @__PURE__ */ s("h3", {
20
- className: r("text-display-xs text-pho-primary font-medium", t),
21
- ...e,
22
- children: a
23
- });
24
- }
25
- function c({ className: t, ...a }) {
26
- return /* @__PURE__ */ s("p", {
27
- className: r("text-display-xs text-pho-description font-normal", t),
28
- ...a
29
- });
30
- }
31
- function l({ className: t, ...a }) {
32
- return /* @__PURE__ */ s("div", {
33
- className: r("px-5", t),
34
- ...a
35
- });
36
- }
37
- function d({ className: t, ...a }) {
38
- return /* @__PURE__ */ s("div", {
39
- className: r("flex items-center gap-2 px-5", t),
40
- ...a
41
- });
42
- }
43
- var u = {
44
- Root: i,
45
- Header: n,
46
- Title: p,
47
- Description: c,
48
- Content: l,
49
- Footer: d
50
- };
51
- export {
52
- u as n,
53
- o as t
54
- };
55
-
56
- //# sourceMappingURL=card-DhDwtSi9.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"card-DhDwtSi9.js","names":[],"sources":["../../src/components/card/card.tsx"],"sourcesContent":["import { type ComponentProps, type Ref } from \"react\";\nimport { cn } from \"../../utils/cn\";\n\n/**\n * Design notes:\n * - A card is a flat bordered panel on the page surface — hairline border,\n * primary background, no shadow. Elevation shadows stay on floating layers\n * (menus, dialogs); see the same rule on Input and Select.\n * - Radius sits at the `lg` stop (16px) like Dialog — a standalone content\n * panel reads bigger than a control, so it takes the panel radius rather\n * than the control default (`base`).\n * - Vertical rhythm: `pt-5` / `pb-4`, `gap-4` between parts. Parts carry\n * `px-5`, so a child without padding (an image, a table, a `Separator`)\n * runs edge-to-edge on its own. A `Stat` / `Stat.Group` already pads\n * its tiles — when it is the first or last child the matching inset\n * drops so the row sits flush on the card edge. A chart as the first\n * child drops the top inset the same way; the plot keeps its own\n * bottom band.\n * - No size or color axes. A card is chrome, not a signal — content sets the\n * tone. Sizing belongs to the layout that places the card.\n */\n\n/** Surface chrome — exported for hosts that need the look on another element. */\nexport const CARD_SURFACE =\n \"border-pho-secondary bg-pho-primary rounded-lg border\";\n\n/** The panel: bordered surface, vertical rhythm between parts. */\nfunction Root({\n className,\n ...props\n}: ComponentProps<\"div\"> & { ref?: Ref<HTMLDivElement> }) {\n return (\n <div\n className={cn(\n CARD_SURFACE,\n \"flex flex-col gap-4 pt-5 pb-4\",\n // Stat tiles pad themselves; a chart's plot already insets.\n \"has-[>[data-stat-group]:first-child]:pt-0 has-[>[data-stat]:first-child]:pt-0\",\n \"has-[>[data-stat-group]:last-child]:pb-0 has-[>[data-stat]:last-child]:pb-0\",\n \"has-[>:first-child:has([data-chart])]:pt-0\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/** Title + optional description pair, kept tight (`gap-0.5`). */\nfunction Header({\n className,\n ...props\n}: ComponentProps<\"div\"> & { ref?: Ref<HTMLDivElement> }) {\n return (\n <div className={cn(\"flex flex-col gap-0.5 px-5\", className)} {...props} />\n );\n}\n\n/**\n * Card heading — an `<h3>` so it nests under page (`h1`) and section (`h2`)\n * headings without skipping levels.\n */\nfunction Title({\n className,\n children,\n ...props\n}: ComponentProps<\"h3\"> & { ref?: Ref<HTMLHeadingElement> }) {\n return (\n <h3\n className={cn(\"text-display-xs text-pho-primary font-medium\", className)}\n {...props}\n >\n {children}\n </h3>\n );\n}\n\n/** Supporting copy under the title — same step, secondary tone. */\nfunction Description({\n className,\n ...props\n}: ComponentProps<\"p\"> & { ref?: Ref<HTMLParagraphElement> }) {\n return (\n <p\n className={cn(\n \"text-display-xs text-pho-description font-normal\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/** The card body. Carries the horizontal padding; bring your own layout. */\nfunction Content({\n className,\n ...props\n}: ComponentProps<\"div\"> & { ref?: Ref<HTMLDivElement> }) {\n return <div className={cn(\"px-5\", className)} {...props} />;\n}\n\n/**\n * Trailing row — actions, a status line. Unopinionated about justification;\n * add `justify-end` for a dialog-style action bar.\n */\nfunction Footer({\n className,\n ...props\n}: ComponentProps<\"div\"> & { ref?: Ref<HTMLDivElement> }) {\n return (\n <div className={cn(\"flex items-center gap-2 px-5\", className)} {...props} />\n );\n}\n\n/**\n * Card — a bordered content panel: header (title + description), body,\n * optional footer. It's static chrome with no interactivity of its own.\n * For a label/control list use `BasicPage.Card`; for a featured\n * block on the page surface use `BasicPage.Callout`.\n *\n * ```tsx\n * <Card.Root>\n * <Card.Header>\n * <Card.Title>Usage</Card.Title>\n * <Card.Description>Since Aug 1.</Card.Description>\n * </Card.Header>\n * <Card.Content>…</Card.Content>\n * <Card.Footer className=\"justify-end\">\n * <Button size=\"sm\">Upgrade</Button>\n * </Card.Footer>\n * </Card.Root>\n * ```\n */\nexport const Card = {\n Root,\n Header,\n Title,\n Description,\n Content,\n Footer,\n};\n"],"mappings":";;;;AAuBA,IAAa,IACX;AAGF,SAAS,EAAK,EACZ,WAAA,GACA,GAAG,EAAA,GACqD;AACxD,SACE,gBAAA,EAAC,OAAD;AAAA,IACE,WAAW,EACT,GACA,iCAEA,iFACA,+EACA,8CACA,CACF;AAAA,IACA,GAAI;AAAA,EACL,CAAA;AAEL;AAGA,SAAS,EAAO,EACd,WAAA,GACA,GAAG,EAAA,GACqD;AACxD,SACE,gBAAA,EAAC,OAAD;AAAA,IAAK,WAAW,EAAG,8BAA8B,CAAS;AAAA,IAAG,GAAI;AAAA,EAAQ,CAAA;AAE7E;AAMA,SAAS,EAAM,EACb,WAAA,GACA,UAAA,GACA,GAAG,EAAA,GACwD;AAC3D,SACE,gBAAA,EAAC,MAAD;AAAA,IACE,WAAW,EAAG,gDAAgD,CAAS;AAAA,IACvE,GAAI;AAAA,IAEH,UAAA;AAAA,EACC,CAAA;AAER;AAGA,SAAS,EAAY,EACnB,WAAA,GACA,GAAG,EAAA,GACyD;AAC5D,SACE,gBAAA,EAAC,KAAD;AAAA,IACE,WAAW,EACT,oDACA,CACF;AAAA,IACA,GAAI;AAAA,EACL,CAAA;AAEL;AAGA,SAAS,EAAQ,EACf,WAAA,GACA,GAAG,EAAA,GACqD;AACxD,SAAO,gBAAA,EAAC,OAAD;AAAA,IAAK,WAAW,EAAG,QAAQ,CAAS;AAAA,IAAG,GAAI;AAAA,EAAQ,CAAA;AAC5D;AAMA,SAAS,EAAO,EACd,WAAA,GACA,GAAG,EAAA,GACqD;AACxD,SACE,gBAAA,EAAC,OAAD;AAAA,IAAK,WAAW,EAAG,gCAAgC,CAAS;AAAA,IAAG,GAAI;AAAA,EAAQ,CAAA;AAE/E;AAqBA,IAAa,IAAO;AAAA,EAClB,MAAA;AAAA,EACA,QAAA;AAAA,EACA,OAAA;AAAA,EACA,aAAA;AAAA,EACA,SAAA;AAAA,EACA,QAAA;AACF"}
@@ -1,28 +0,0 @@
1
- "use client";
2
- import { t as r } from "./cn-ChIgwEl3.js";
3
- import "react";
4
- import { jsx as i } from "react/jsx-runtime";
5
- import { Collapsible as o } from "@base-ui/react/collapsible";
6
- var n = o.Root;
7
- function a({ className: e, ...t }) {
8
- return /* @__PURE__ */ i(o.Trigger, {
9
- className: r("outline-pho-brand text-pho-secondary hover:text-pho-secondary-hover flex w-full cursor-pointer items-center justify-between gap-2 rounded-sm text-base font-medium transition focus-visible:outline-2 focus-visible:outline-offset-2", "[&>svg]:size-4 [&>svg]:transition-transform [&>svg]:duration-150 data-[panel-open]:[&>svg]:rotate-180", e),
10
- ...t
11
- });
12
- }
13
- function s({ className: e, ...t }) {
14
- return /* @__PURE__ */ i(o.Panel, {
15
- className: r("h-[var(--collapsible-panel-height)] overflow-hidden transition-[height] duration-150 ease-out", "data-[ending-style]:h-0 data-[starting-style]:h-0", e),
16
- ...t
17
- });
18
- }
19
- var d = {
20
- Root: n,
21
- Trigger: a,
22
- Panel: s
23
- };
24
- export {
25
- d as t
26
- };
27
-
28
- //# sourceMappingURL=collapsible-if7ncPbI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"collapsible-if7ncPbI.js","names":[],"sources":["../../src/components/collapsible/collapsible.tsx"],"sourcesContent":["import { type ComponentProps, type ElementType } from \"react\";\nimport { Collapsible as BaseCollapsible } from \"@base-ui/react/collapsible\";\nimport { cn } from \"../../utils/cn\";\n\n/** Override Base UI's `string | (state) => string` className with plain string. */\ntype StyledProps<T extends ElementType> = Omit<\n ComponentProps<T>,\n \"className\"\n> & {\n className?: string;\n};\n\nconst Root = BaseCollapsible.Root;\n\nfunction Trigger({\n className,\n ...props\n}: StyledProps<typeof BaseCollapsible.Trigger>) {\n return (\n <BaseCollapsible.Trigger\n className={cn(\n \"outline-pho-brand text-pho-secondary hover:text-pho-secondary-hover flex w-full cursor-pointer items-center justify-between gap-2 rounded-sm text-base font-medium transition focus-visible:outline-2 focus-visible:outline-offset-2\",\n \"[&>svg]:size-4 [&>svg]:transition-transform [&>svg]:duration-150 data-[panel-open]:[&>svg]:rotate-180\",\n className,\n )}\n {...props}\n />\n );\n}\n\nfunction Panel({\n className,\n ...props\n}: StyledProps<typeof BaseCollapsible.Panel>) {\n return (\n <BaseCollapsible.Panel\n className={cn(\n \"h-[var(--collapsible-panel-height)] overflow-hidden transition-[height] duration-150 ease-out\",\n \"data-[ending-style]:h-0 data-[starting-style]:h-0\",\n className,\n )}\n {...props}\n />\n );\n}\n\n/**\n * Show/hide a region of content, built on Base UI `Collapsible` with a smooth\n * height animation. Control with `open` / `onOpenChange` or leave uncontrolled\n * via `defaultOpen`. For several sections where one expands at a time, use\n * `Accordion`.\n */\nexport const Collapsible = { Root, Trigger, Panel };\n"],"mappings":";;;;;AAYA,IAAM,IAAO,EAAgB;AAE7B,SAAS,EAAQ,EACf,WAAA,GACA,GAAG,EAAA,GAC2C;AAC9C,SACE,gBAAA,EAAC,EAAgB,SAAjB;AAAA,IACE,WAAW,EACT,wOACA,yGACA,CACF;AAAA,IACA,GAAI;AAAA,EACL,CAAA;AAEL;AAEA,SAAS,EAAM,EACb,WAAA,GACA,GAAG,EAAA,GACyC;AAC5C,SACE,gBAAA,EAAC,EAAgB,OAAjB;AAAA,IACE,WAAW,EACT,iGACA,qDACA,CACF;AAAA,IACA,GAAI;AAAA,EACL,CAAA;AAEL;AAQA,IAAa,IAAc;AAAA,EAAE,MAAA;AAAA,EAAM,SAAA;AAAA,EAAS,OAAA;AAAM"}
@@ -1,422 +0,0 @@
1
- "use client";
2
- import { t as p } from "./cn-ChIgwEl3.js";
3
- import { t as Ge } from "./createReactComponent-BqCmnqfX.js";
4
- import { t as le } from "./calendar-4OFiCLAv.js";
5
- import { t as L } from "./popover-BhBJO346.js";
6
- import { useCallback as ze, useId as He, useRef as J, useState as D, useSyncExternalStore as Ye } from "react";
7
- import { Fragment as X, jsx as f, jsxs as y } from "react/jsx-runtime";
8
- var qe = [
9
- ["path", {
10
- d: "M4 7a2 2 0 0 1 2 -2h12a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-12a2 2 0 0 1 -2 -2v-12",
11
- key: "svg-0"
12
- }],
13
- ["path", {
14
- d: "M16 3v4",
15
- key: "svg-1"
16
- }],
17
- ["path", {
18
- d: "M8 3v4",
19
- key: "svg-2"
20
- }],
21
- ["path", {
22
- d: "M4 11h16",
23
- key: "svg-3"
24
- }],
25
- ["path", {
26
- d: "M11 15h1",
27
- key: "svg-4"
28
- }],
29
- ["path", {
30
- d: "M12 15v3",
31
- key: "svg-5"
32
- }]
33
- ], ue = Ge("outline", "calendar", "Calendar", qe), ye = {
34
- hour: 3600,
35
- minute: 60,
36
- second: 1
37
- }, ce = {
38
- sm: "px-3 py-2 text-md md:text-base",
39
- md: "px-3 py-2 text-md",
40
- lg: "px-3.5 py-2.5 text-md"
41
- }, de = {
42
- sm: "rounded-base",
43
- md: "rounded-base",
44
- lg: "squircle rounded-base"
45
- }, fe = p("bg-pho-primary ring-pho-primary text-pho-primary relative flex cursor-pointer items-center gap-2 text-left ring-1 ring-inset", "transition-shadow duration-100 ease-linear focus-visible:outline-none", "data-[invalid]:ring-pho-error-subtle data-[invalid]:ring-[1.5px]"), Ke = p("has-[input:focus-visible]:ring-pho-brand data-[popup-open]:ring-pho-brand has-[input:focus-visible]:ring-2 data-[popup-open]:ring-2", "data-[invalid]:has-[input:focus-visible]:ring-pho-error data-[invalid]:data-[popup-open]:ring-pho-error", "has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50"), Be = p("has-[input:focus-visible]:ring-pho-brand has-[input:focus-visible]:ring-2", "data-[invalid]:has-[input:focus-visible]:ring-pho-error", "has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50"), Ue = p("flex shrink-0 cursor-pointer items-center rounded-sm px-2.5 py-1.5 text-left text-base whitespace-nowrap select-none", "text-pho-secondary transition-[color,background-color] duration-150 ease-out", "hover:bg-pho-ghost-hover hover:text-pho-primary", "outline-pho-brand focus-visible:outline-2 focus-visible:-outline-offset-1", "sm:w-full"), Ze = "bg-pho-ghost-hover text-pho-primary font-medium", Je = /[\u00a0\u2000-\u200a\u202f\u205f\u3000]/g, A = (e) => e.replace(Je, " "), xe = {
46
- year: "numeric",
47
- month: "2-digit",
48
- day: "2-digit"
49
- }, Qe = {
50
- hour: {
51
- hour: "2-digit",
52
- minute: "2-digit",
53
- hourCycle: "h23"
54
- },
55
- minute: {
56
- hour: "2-digit",
57
- minute: "2-digit",
58
- hourCycle: "h23"
59
- },
60
- second: {
61
- hour: "2-digit",
62
- minute: "2-digit",
63
- second: "2-digit",
64
- hourCycle: "h23"
65
- }
66
- }, P = "–", we = new Date(2026, 8, 12, 15, 4, 5);
67
- function De(e, t) {
68
- return new Intl.DateTimeFormat(e, {
69
- ...xe,
70
- ...t ? Qe[t] : {}
71
- });
72
- }
73
- var Me = (e) => e === "year" || e === "month" || e === "day";
74
- function We(e) {
75
- return new Intl.DateTimeFormat(e, xe).formatToParts(we).map((t) => t.type).filter(Me);
76
- }
77
- var Xe = {
78
- year: "yyyy",
79
- month: "mm",
80
- day: "dd"
81
- };
82
- function et(e, t) {
83
- return A(De(e, t).formatToParts(we).map((n) => Me(n.type) ? Xe[n.type] : n.type === "hour" ? "hh" : n.type === "minute" ? "mm" : n.type === "second" ? "ss" : n.value).join(""));
84
- }
85
- function tt(e, t, n) {
86
- if (e == null) return "";
87
- const c = De(t, n);
88
- return e instanceof Date ? A(c.format(e)) : e.from == null ? "" : e.to == null || n == null && e.from.getFullYear() === e.to.getFullYear() && e.from.getMonth() === e.to.getMonth() && e.from.getDate() === e.to.getDate() ? A(c.format(e.from)) : A(nt(c, e.from, e.to, n != null));
89
- }
90
- function nt(e, t, n, c) {
91
- const o = e.formatToParts(t), i = e.formatToParts(n), l = (d) => d.map((N) => N.value).join("");
92
- if (c || o.length !== i.length) return `${l(o)}${P}${l(i)}`;
93
- const h = (d) => o[d].type === i[d].type && o[d].value === i[d].value;
94
- if (o[0]?.type === "year") {
95
- let d = 0;
96
- for (; d < o.length && h(d); ) d += 1;
97
- for (; d > 0 && i[d - 1].type !== "literal"; ) d -= 1;
98
- return d > 0 && d < o.length ? `${l(o)}${P}${l(i.slice(d))}` : `${l(o)}${P}${l(i)}`;
99
- }
100
- let u = o.length;
101
- for (; u > 0 && h(u - 1); ) u -= 1;
102
- for (; u < o.length && o[u].type !== "literal"; ) u += 1;
103
- return u > 0 && u < o.length ? `${l(o.slice(0, u))}${P}${l(i)}` : `${l(o)}${P}${l(i)}`;
104
- }
105
- var O = (e) => String(e).padStart(2, "0");
106
- function M(e) {
107
- return `${e.getFullYear()}-${O(e.getMonth() + 1)}-${O(e.getDate())}`;
108
- }
109
- function Ne(e, t) {
110
- const n = `${O(e.getHours())}:${O(e.getMinutes())}`;
111
- return t === "second" ? `${n}:${O(e.getSeconds())}` : n;
112
- }
113
- function Q(e, t) {
114
- return `${M(e)}T${Ne(e, t)}`;
115
- }
116
- function j(e) {
117
- const t = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2}))?)?$/.exec(e);
118
- if (!t) return;
119
- const [, n, c, o, i, l, h] = t, u = new Date(Number(n), Number(c) - 1, Number(o), Number(i ?? 0), Number(l ?? 0), Number(h ?? 0), 0);
120
- return Number.isNaN(u.getTime()) ? void 0 : u;
121
- }
122
- function he(e, t, n, c) {
123
- const o = e < 100 ? 2e3 + e : e;
124
- if (t < 1 || t > 12 || n < 1 || n > 31) return;
125
- const [i = 0, l = 0, h = 0] = c;
126
- if (i > 23 || l > 59 || h > 59) return;
127
- const u = new Date(o, t - 1, n, i, l, h, 0);
128
- return u.getMonth() === t - 1 && u.getDate() === n ? u : void 0;
129
- }
130
- function rt(e, t) {
131
- const n = e.trim();
132
- if (n === "") return;
133
- const c = (n.match(/\d+/g) ?? []).map(Number);
134
- if (c.length >= 3) {
135
- const i = c.slice(3);
136
- if (/\bpm\b/i.test(n) && i[0] !== void 0 && i[0] < 12 ? i[0] += 12 : /\bam\b/i.test(n) && i[0] === 12 && (i[0] = 0), /^\d{4}\D/.test(n)) {
137
- const [h, u, d] = c;
138
- return he(h, u, d, i);
139
- }
140
- const l = {};
141
- if (We(t).forEach((h, u) => {
142
- l[h] = c[u];
143
- }), l.year != null && l.month != null && l.day != null) {
144
- const h = he(l.year, l.month, l.day, i);
145
- if (h) return h;
146
- }
147
- }
148
- if (!/[a-z]/i.test(n) || c.length < 2 || !/\b\d{4}\b/.test(n)) return;
149
- const o = new Date(n);
150
- return Number.isNaN(o.getTime()) ? void 0 : o;
151
- }
152
- function g(e, t) {
153
- const n = new Date(e);
154
- return n.setMilliseconds(0), t === "second" || (n.setSeconds(0), t === "minute") || (n.setMinutes(0), t === "hour") || n.setHours(0), n;
155
- }
156
- function me(e) {
157
- return e == null ? "" : e instanceof Date ? String(e.getTime()) : `${e.from?.getTime() ?? ""}-${e.to?.getTime() ?? ""}`;
158
- }
159
- function G(e, t) {
160
- const n = new Date(e);
161
- return t && n.setHours(t.getHours(), t.getMinutes(), t.getSeconds(), 0), n;
162
- }
163
- var ot = (e) => new Date(e.getFullYear(), e.getMonth(), 1), at = (e) => new Date(e.getFullYear(), e.getMonth() + 1, 0), it = (e) => new Date(e.getFullYear(), e.getMonth(), e.getDate()), pe = (e) => new Date(e.getFullYear(), e.getMonth(), e.getDate(), 23, 59, 59, 999), ge = (e, t) => e && e > t ? e : t, ve = (e, t) => e && e < t ? e : t;
164
- function st(e) {
165
- if (e?.hidden != null) return null;
166
- let t, n;
167
- const c = e?.disabled == null ? [] : Array.isArray(e.disabled) ? e.disabled : [e.disabled];
168
- for (const o of c) {
169
- if (o == null || typeof o != "object" || o instanceof Date || Object.keys(o).length !== 1) return null;
170
- if ("before" in o && o.before instanceof Date) t = ge(t, it(o.before));
171
- else if ("after" in o && o.after instanceof Date) n = ve(n, pe(o.after));
172
- else return null;
173
- }
174
- return e?.startMonth && (t = ge(t, ot(e.startMonth))), e?.endMonth && (n = ve(n, pe(at(e.endMonth)))), {
175
- min: t,
176
- max: n
177
- };
178
- }
179
- var be = "(pointer: coarse)";
180
- function lt() {
181
- const e = ze((t) => {
182
- if (typeof window > "u" || !window.matchMedia) return () => {
183
- };
184
- const n = window.matchMedia(be);
185
- return n.addEventListener("change", t), () => n.removeEventListener("change", t);
186
- }, []);
187
- return Ye(e, () => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(be).matches, () => !1);
188
- }
189
- function W({ label: e, value: t, time: n, disabled: c, onChange: o }) {
190
- return /* @__PURE__ */ y(X, { children: [/* @__PURE__ */ f("span", {
191
- className: "text-pho-description text-xs",
192
- children: e
193
- }), /* @__PURE__ */ f("label", {
194
- className: p("bg-pho-primary ring-pho-primary rounded-sm px-2 py-1 ring-1 ring-inset", "focus-within:ring-pho-brand transition-shadow duration-100 ease-linear focus-within:ring-2"),
195
- children: /* @__PURE__ */ f("input", {
196
- type: "time",
197
- step: ye[n],
198
- disabled: c,
199
- "aria-label": e,
200
- value: t ? Ne(t, n) : "",
201
- onChange: (i) => o(i.target.value),
202
- className: p("text-pho-primary w-full bg-transparent text-base tabular-nums outline-none", "[&::-webkit-calendar-picker-indicator]:hidden")
203
- })
204
- })] });
205
- }
206
- function ut(e) {
207
- const { mode: t = "single", defaultValue: n, onValueChange: c, label: o, hint: i, placeholder: l, invalid: h, disabled: u, required: d, size: N = "md", width: k = "fill", time: a, locales: z, calendarProps: S, id: $e, className: ee } = e, H = e.presets, { minDays: Ce, maxDays: ke } = e, te = "value" in e, [Se, Te] = D(n), _ = te ? e.value : Se, [$, C] = D(!1), T = J(0), Y = l ?? (t === "range" ? "Pick a date range" : et(z, a)), Ee = He(), E = $e ?? Ee, q = i ? `${E}-hint` : void 0, ne = `${E}-calendar`, [re, oe] = D(!1), K = (r = !1) => {
208
- $ || (T.current = 0, I(void 0), oe(r), C(!0));
209
- }, v = (r) => {
210
- te || Te(r), c?.(r);
211
- }, b = t === "single" ? _ : void 0, m = t === "range" ? _ : void 0, Fe = b ?? m?.from, [Ie, x] = D(null), [B, Re] = D(null), U = B && B.key === me(_) ? B.label : null, F = Ie ?? U ?? tt(_, z, a), Pe = Math.max(F.length, Y.length, 1), Ae = (r) => {
212
- const s = typeof r.value == "function" ? r.value() : r.value;
213
- Re({
214
- label: r.label,
215
- key: me(s)
216
- }), x(null), v(s), C(!1);
217
- }, [Oe, I] = D(void 0), [_e] = D(() => S?.today ?? /* @__PURE__ */ new Date()), ae = Oe ?? S?.defaultMonth ?? Fe ?? _e, Z = J(null), ie = J(null), Ve = lt(), w = st(S), Le = Ve && t === "single" && w != null && !H?.length, je = /* @__PURE__ */ y(X, { children: [/* @__PURE__ */ f(ue, { className: "text-pho-secondary size-4 shrink-0" }), /* @__PURE__ */ f("span", {
218
- className: p("min-w-0 flex-1 truncate", F === "" && "text-pho-placeholder"),
219
- children: F === "" ? Y : F
220
- })] });
221
- return /* @__PURE__ */ y("div", {
222
- className: p("flex flex-col gap-1.5", k === "hug" ? "w-fit" : "w-full"),
223
- children: [
224
- o ? /* @__PURE__ */ y("label", {
225
- htmlFor: E,
226
- className: "text-pho-secondary flex w-fit cursor-default items-center gap-0.5 text-base font-medium",
227
- children: [o, d ? /* @__PURE__ */ f("span", {
228
- className: "text-pho-brand",
229
- children: "*"
230
- }) : null]
231
- }) : null,
232
- Le ? /* @__PURE__ */ y("div", {
233
- "data-invalid": h || void 0,
234
- className: p(fe, Be, k === "hug" ? "w-fit" : "w-full", ce[N], de[N], ee),
235
- children: [je, /* @__PURE__ */ f("input", {
236
- id: E,
237
- type: a ? "datetime-local" : "date",
238
- step: a ? ye[a] : void 0,
239
- min: w?.min ? a ? Q(g(w.min, a), a) : M(w.min) : void 0,
240
- max: w?.max ? a ? Q(g(w.max, a), a) : M(w.max) : void 0,
241
- required: d,
242
- disabled: u,
243
- "aria-describedby": q,
244
- value: b ? a ? Q(b, a) : M(b) : "",
245
- onChange: (r) => {
246
- const s = j(r.target.value);
247
- v(s ? g(s, a) : void 0);
248
- },
249
- className: "absolute inset-0 size-full cursor-pointer opacity-0"
250
- })]
251
- }) : /* @__PURE__ */ y(L.Root, {
252
- open: $,
253
- onOpenChange: (r, s) => {
254
- !r && s.reason === "outside-press" && s.event.target instanceof Node && Z.current?.contains(s.event.target) || (r ? (T.current = 0, I(void 0)) : (x(null), oe(!1)), C(r));
255
- },
256
- children: [/* @__PURE__ */ y("div", {
257
- ref: Z,
258
- "data-invalid": h || void 0,
259
- "data-popup-open": $ || void 0,
260
- className: p(fe, Ke, k === "hug" ? "w-fit" : "w-full", ce[N], de[N], ee),
261
- children: [/* @__PURE__ */ f(ue, { className: "text-pho-secondary size-4 shrink-0" }), /* @__PURE__ */ f("input", {
262
- id: E,
263
- type: "text",
264
- readOnly: t === "range",
265
- disabled: u,
266
- required: d,
267
- placeholder: Y,
268
- "aria-describedby": q,
269
- role: "combobox",
270
- "aria-haspopup": "dialog",
271
- "aria-expanded": $,
272
- "aria-controls": $ ? ne : void 0,
273
- autoComplete: "off",
274
- spellCheck: !1,
275
- value: F,
276
- onFocus: () => K(),
277
- onMouseDown: () => K(),
278
- onChange: (r) => {
279
- const s = r.target.value;
280
- if (x(s), s.trim() === "") {
281
- v(void 0);
282
- return;
283
- }
284
- const R = rt(s, z);
285
- R && (v(g(R, a)), I(R));
286
- },
287
- onBlur: () => x(null),
288
- onKeyDown: (r) => {
289
- if (r.key === "Escape" && $) {
290
- r.preventDefault(), x(null), C(!1);
291
- return;
292
- }
293
- if (r.key === "ArrowDown") {
294
- r.preventDefault();
295
- const s = ie.current?.querySelector("td[data-day] button[tabindex='0']");
296
- if (s) {
297
- s.focus();
298
- return;
299
- }
300
- K(!0);
301
- }
302
- },
303
- size: k === "hug" ? Pe : void 0,
304
- className: p("text-pho-primary placeholder:text-pho-placeholder bg-transparent outline-none", k === "hug" ? "min-w-0" : "min-w-0 flex-1", t === "range" && "cursor-pointer")
305
- })]
306
- }), /* @__PURE__ */ f(L.Portal, { children: /* @__PURE__ */ f(L.Positioner, {
307
- anchor: Z,
308
- align: "start",
309
- sideOffset: 6,
310
- children: /* @__PURE__ */ f(L.Popup, {
311
- ref: ie,
312
- id: ne,
313
- initialFocus: !1,
314
- finalFocus: !1,
315
- className: "max-h-[var(--available-height)] overflow-y-auto p-3",
316
- children: /* @__PURE__ */ y("div", {
317
- className: "flex flex-col gap-3 sm:flex-row",
318
- children: [H?.length ? /* @__PURE__ */ f("div", {
319
- role: "group",
320
- "aria-label": "Presets",
321
- className: p("flex shrink-0 gap-1 overflow-x-auto", "sm:border-pho-secondary sm:w-36 sm:flex-col sm:gap-0.5 sm:overflow-visible sm:border-r sm:pr-3"),
322
- children: H.map((r) => /* @__PURE__ */ f("button", {
323
- type: "button",
324
- "aria-pressed": r.label === U,
325
- onClick: () => Ae(r),
326
- className: p(Ue, r.label === U && Ze),
327
- children: r.label
328
- }, r.label))
329
- }) : null, /* @__PURE__ */ y("div", { children: [t === "range" ? /* @__PURE__ */ f(le, {
330
- ...S,
331
- mode: "range",
332
- min: Ce,
333
- max: ke,
334
- month: ae,
335
- onMonthChange: I,
336
- autoFocus: re,
337
- selected: m,
338
- onSelect: (r, s) => {
339
- const R = T.current === 0;
340
- if (T.current += 1, R && m?.to) {
341
- const se = g(G(s, a ? m.from : void 0), a);
342
- v({
343
- from: se,
344
- to: new Date(se)
345
- }), x(null);
346
- return;
347
- }
348
- const V = r && {
349
- from: r.from && g(G(r.from, a ? m?.from : void 0), a),
350
- to: r.to && g(G(r.to, a ? m?.to : void 0), a)
351
- };
352
- v(V), x(null), !a && T.current >= 2 && (!V || V.from && V.to) && C(!1);
353
- }
354
- }) : /* @__PURE__ */ f(le, {
355
- ...S,
356
- mode: "single",
357
- month: ae,
358
- onMonthChange: I,
359
- autoFocus: re,
360
- selected: b,
361
- onSelect: (r) => {
362
- v(r && g(G(r, a ? b : void 0), a)), x(null), a || C(!1);
363
- }
364
- }), a ? /* @__PURE__ */ f("div", {
365
- className: "border-pho-secondary mt-3 grid grid-cols-[auto_1fr] items-center gap-x-3 gap-y-2 border-t pt-3",
366
- children: t === "range" ? /* @__PURE__ */ y(X, { children: [/* @__PURE__ */ f(W, {
367
- label: "From",
368
- value: m?.from,
369
- time: a,
370
- onChange: (r) => {
371
- if (!m?.from) return;
372
- const s = j(`${M(m.from)}T${r}`);
373
- s && v({
374
- ...m,
375
- from: g(s, a)
376
- });
377
- },
378
- disabled: !m?.from
379
- }), /* @__PURE__ */ f(W, {
380
- label: "To",
381
- value: m?.to,
382
- time: a,
383
- onChange: (r) => {
384
- if (!m?.to) return;
385
- const s = j(`${M(m.to)}T${r}`);
386
- s && v({
387
- ...m,
388
- to: g(s, a)
389
- });
390
- },
391
- disabled: !m?.to
392
- })] }) : /* @__PURE__ */ f(W, {
393
- label: "Time",
394
- value: b,
395
- time: a,
396
- onChange: (r) => {
397
- if (!b) return;
398
- const s = j(`${M(b)}T${r}`);
399
- s && v(g(s, a));
400
- },
401
- disabled: !b
402
- })
403
- }) : null] })]
404
- })
405
- })
406
- }) })]
407
- }),
408
- i ? /* @__PURE__ */ f("p", {
409
- id: q,
410
- className: p("text-pho-description text-base", h && "text-pho-error"),
411
- children: i
412
- }) : null
413
- ]
414
- });
415
- }
416
- ut.displayName = "DatePicker";
417
- export {
418
- tt as n,
419
- ut as t
420
- };
421
-
422
- //# sourceMappingURL=date-picker-Ddeo1fNE.js.map