tembro 6.1.0 → 6.1.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.
- package/dist/components/actions/action-menu.d.ts +11 -1
- package/dist/components/display/index.d.ts +0 -2
- package/dist/components/filters/index.d.ts +0 -1
- package/dist/components/inputs/time-picker.d.ts +11 -3
- package/dist/components/modern/file-manager.d.ts +1 -1
- package/dist/components/modern/index.d.ts +3 -1
- package/dist/components/modern/map.cjs +1 -0
- package/dist/components/modern/map.d.ts +29 -0
- package/dist/components/modern/map.js +1 -0
- package/dist/components/modern/media-player.cjs +1 -0
- package/dist/components/modern/media-player.d.ts +21 -0
- package/dist/components/modern/media-player.js +1 -0
- package/dist/components/modern/spreadsheet.cjs +1 -0
- package/dist/components/modern/spreadsheet.d.ts +35 -0
- package/dist/components/modern/spreadsheet.js +1 -0
- package/dist/components/overlay/drawer.d.ts +3 -1
- package/dist/index.d.ts +0 -2
- package/dist/src/components/actions/action-menu.cjs +1 -1
- package/dist/src/components/actions/action-menu.js +47 -39
- package/dist/src/components/actions/copy-button.cjs +1 -1
- package/dist/src/components/actions/copy-button.js +4 -1
- package/dist/src/components/calendar/date-picker.cjs +1 -1
- package/dist/src/components/calendar/date-picker.js +5 -8
- package/dist/src/components/calendar/date-range-picker.cjs +1 -1
- package/dist/src/components/calendar/date-range-picker.js +12 -27
- package/dist/src/components/data-table/data-table.cjs +1 -1
- package/dist/src/components/data-table/data-table.js +172 -171
- package/dist/src/components/display/index.cjs +1 -1
- package/dist/src/components/display/index.js +9 -11
- package/dist/src/components/filters/index.cjs +1 -1
- package/dist/src/components/filters/index.js +2 -3
- package/dist/src/components/inputs/color-picker.cjs +1 -1
- package/dist/src/components/inputs/color-picker.js +63 -46
- package/dist/src/components/inputs/slider.cjs +1 -1
- package/dist/src/components/inputs/slider.js +3 -3
- package/dist/src/components/inputs/tag-input.cjs +1 -1
- package/dist/src/components/inputs/tag-input.js +7 -4
- package/dist/src/components/inputs/time-picker.cjs +1 -1
- package/dist/src/components/inputs/time-picker.js +90 -34
- package/dist/src/components/modern/index.cjs +1 -1
- package/dist/src/components/modern/index.js +6 -4
- package/dist/src/components/modern/map.cjs +1 -0
- package/dist/src/components/modern/map.js +158 -0
- package/dist/src/components/modern/media-player.cjs +1 -0
- package/dist/src/components/modern/media-player.js +176 -0
- package/dist/src/components/modern/resizable-panel.cjs +1 -1
- package/dist/src/components/modern/resizable-panel.js +39 -32
- package/dist/src/components/modern/spreadsheet.cjs +1 -0
- package/dist/src/components/modern/spreadsheet.js +97 -0
- package/dist/src/components/navigation/pagination.cjs +1 -1
- package/dist/src/components/navigation/pagination.js +5 -5
- package/dist/src/components/notifications/toast.cjs +1 -1
- package/dist/src/components/notifications/toast.js +68 -63
- package/dist/src/components/overlay/alert-dialog.cjs +1 -1
- package/dist/src/components/overlay/alert-dialog.js +8 -6
- package/dist/src/components/overlay/drawer.cjs +1 -1
- package/dist/src/components/overlay/drawer.js +38 -20
- package/dist/src/components/ui/checkbox/index.cjs +1 -1
- package/dist/src/components/ui/checkbox/index.js +2 -1
- package/dist/src/components/ui/dialog/index.cjs +1 -1
- package/dist/src/components/ui/dialog/index.js +8 -8
- package/dist/src/components/ui/dropdown-menu/index.cjs +1 -1
- package/dist/src/components/ui/dropdown-menu/index.js +21 -19
- package/dist/src/components/ui/popover/index.cjs +1 -1
- package/dist/src/components/ui/popover/index.js +10 -10
- package/dist/src/components/ui/tabs/index.cjs +1 -1
- package/dist/src/components/ui/tabs/index.js +6 -6
- package/dist/src/components/ui/toggle-group/index.cjs +1 -1
- package/dist/src/components/ui/toggle-group/index.js +2 -2
- package/dist/src/index.cjs +1 -1
- package/dist/src/index.js +80 -83
- package/dist/src/public-component-surface.cjs +1 -1
- package/dist/src/public-component-surface.js +15 -20
- package/package.json +1 -2
- package/packages/cli/dist/index.cjs +58 -178
- package/packages/cli/vendor/src/components/actions/action-menu.tsx +47 -19
- package/packages/cli/vendor/src/components/actions/copy-button.tsx +2 -2
- package/packages/cli/vendor/src/components/calendar/date-picker.tsx +2 -5
- package/packages/cli/vendor/src/components/calendar/date-range-picker.tsx +5 -12
- package/packages/cli/vendor/src/components/data-table/data-table.tsx +45 -34
- package/packages/cli/vendor/src/components/display/index.ts +3 -5
- package/packages/cli/vendor/src/components/filters/index.ts +0 -1
- package/packages/cli/vendor/src/components/inputs/color-picker.tsx +15 -1
- package/packages/cli/vendor/src/components/inputs/slider.tsx +3 -3
- package/packages/cli/vendor/src/components/inputs/tag-input.tsx +4 -4
- package/packages/cli/vendor/src/components/inputs/time-picker.tsx +91 -38
- package/packages/cli/vendor/src/components/modern/file-manager.tsx +1 -1
- package/packages/cli/vendor/src/components/modern/index.ts +3 -1
- package/packages/cli/vendor/src/components/modern/map.tsx +146 -0
- package/packages/cli/vendor/src/components/modern/media-player.tsx +182 -0
- package/packages/cli/vendor/src/components/modern/resizable-panel.tsx +15 -5
- package/packages/cli/vendor/src/components/modern/spreadsheet.tsx +155 -0
- package/packages/cli/vendor/src/components/navigation/pagination.tsx +9 -5
- package/packages/cli/vendor/src/components/notifications/toast.tsx +20 -10
- package/packages/cli/vendor/src/components/overlay/alert-dialog.tsx +3 -5
- package/packages/cli/vendor/src/components/overlay/drawer.tsx +22 -11
- package/packages/cli/vendor/src/components/ui/checkbox/index.tsx +3 -1
- package/packages/cli/vendor/src/components/ui/dialog/index.tsx +4 -4
- package/packages/cli/vendor/src/components/ui/dropdown-menu/index.tsx +18 -22
- package/packages/cli/vendor/src/components/ui/popover/index.tsx +4 -4
- package/packages/cli/vendor/src/components/ui/tabs/index.tsx +8 -3
- package/packages/cli/vendor/src/components/ui/toggle-group/index.tsx +6 -6
- package/packages/cli/vendor/src/index.ts +0 -2
- package/packages/cli/vendor/src/public-component-surface.ts +3 -4
- package/packages/cli/vendor/templates/showcase/src/showcase/data/registry.ts +6 -6
- package/packages/cli/vendor/templates/showcase/src/showcase/layout/HeroSection.tsx +23 -8
- package/packages/cli/vendor/templates/showcase/src/showcase/layout/WorkbenchSidebar.tsx +1 -1
- package/packages/cli/vendor/templates/showcase/src/showcase/sections/PatternsSection.tsx +1 -1
- package/packages/cli/vendor/templates/styles/globals.css +0 -120
- package/registry.json +74 -141
- package/dist/components/display/info-card.cjs +0 -1
- package/dist/components/display/info-card.d.ts +0 -51
- package/dist/components/display/info-card.js +0 -1
- package/dist/components/display/statistic.cjs +0 -1
- package/dist/components/display/statistic.d.ts +0 -25
- package/dist/components/display/statistic.js +0 -1
- package/dist/components/filters/filter-bar.cjs +0 -1
- package/dist/components/filters/filter-bar.d.ts +0 -28
- package/dist/components/filters/filter-bar.js +0 -1
- package/dist/components/modern/image-cropper.cjs +0 -1
- package/dist/components/modern/image-cropper.d.ts +0 -39
- package/dist/components/modern/image-cropper.js +0 -1
- package/dist/components/ui/number-field/index.cjs +0 -1
- package/dist/components/ui/number-field/index.d.ts +0 -18
- package/dist/components/ui/number-field/index.js +0 -1
- package/dist/components/ui/toolbar/index.cjs +0 -1
- package/dist/components/ui/toolbar/index.d.ts +0 -14
- package/dist/components/ui/toolbar/index.js +0 -1
- package/dist/src/components/display/info-card.cjs +0 -1
- package/dist/src/components/display/info-card.js +0 -124
- package/dist/src/components/display/statistic.cjs +0 -1
- package/dist/src/components/display/statistic.js +0 -104
- package/dist/src/components/filters/filter-bar.cjs +0 -1
- package/dist/src/components/filters/filter-bar.js +0 -103
- package/dist/src/components/modern/image-cropper.cjs +0 -1
- package/dist/src/components/modern/image-cropper.js +0 -143
- package/dist/src/components/ui/number-field/index.cjs +0 -1
- package/dist/src/components/ui/number-field/index.js +0 -73
- package/dist/src/components/ui/toolbar/index.cjs +0 -1
- package/dist/src/components/ui/toolbar/index.js +0 -50
- package/packages/cli/vendor/src/components/display/info-card.tsx +0 -195
- package/packages/cli/vendor/src/components/display/statistic.tsx +0 -114
- package/packages/cli/vendor/src/components/filters/filter-bar.tsx +0 -163
- package/packages/cli/vendor/src/components/modern/image-cropper.tsx +0 -226
- package/packages/cli/vendor/src/components/ui/number-field/index.tsx +0 -89
- package/packages/cli/vendor/src/components/ui/toolbar/index.tsx +0 -67
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { Button as t } from "../ui/button/index.js";
|
|
4
|
+
import { Badge as n } from "../ui/badge/index.js";
|
|
5
|
+
import * as r from "react";
|
|
6
|
+
import { ExternalLinkIcon as i, LocateFixedIcon as a, MapPinIcon as o, MinusIcon as s, PlusIcon as c } from "lucide-react";
|
|
7
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/modern/map.tsx
|
|
9
|
+
function d(e) {
|
|
10
|
+
return Math.max(1, Math.min(19, e));
|
|
11
|
+
}
|
|
12
|
+
function f(e) {
|
|
13
|
+
return Number.isFinite(e) ? e : 0;
|
|
14
|
+
}
|
|
15
|
+
function p(e, t, n) {
|
|
16
|
+
let r = f(n?.latitude ?? e.latitude), i = f(n?.longitude ?? e.longitude), a = .012 * (20 - d(t));
|
|
17
|
+
return `https://www.openstreetmap.org/export/embed.html?bbox=${[
|
|
18
|
+
i - a,
|
|
19
|
+
r - a,
|
|
20
|
+
i + a,
|
|
21
|
+
r + a
|
|
22
|
+
].map((e) => e.toFixed(6)).join("%2C")}&layer=mapnik&marker=${r.toFixed(6)}%2C${i.toFixed(6)}`;
|
|
23
|
+
}
|
|
24
|
+
function m(e, t, n) {
|
|
25
|
+
let r = f(n?.latitude ?? e.latitude), i = f(n?.longitude ?? e.longitude);
|
|
26
|
+
return `https://www.openstreetmap.org/?mlat=${r.toFixed(6)}&mlon=${i.toFixed(6)}#map=${d(t)}/${r.toFixed(6)}/${i.toFixed(6)}`;
|
|
27
|
+
}
|
|
28
|
+
function h({ center: f = {
|
|
29
|
+
latitude: 41.311081,
|
|
30
|
+
longitude: 69.240562
|
|
31
|
+
}, zoom: h = 13, markers: g = [], title: _ = "Map", description: v, height: y = 420, showMarkerList: b = !0, showControls: x = !0, iframeTitle: S = "Interactive map", mapUrl: C, onMarkerSelect: w, selectedMarkerKey: T, defaultSelectedMarkerKey: E, className: D, ...O }) {
|
|
32
|
+
let [k, A] = r.useState(d(h)), [j, M] = r.useState(E ?? g[0]?.key), N = T ?? j, P = g.find((e) => e.key === N), F = C ?? p(f, k, P), I = m(f, k, P);
|
|
33
|
+
r.useEffect(() => {
|
|
34
|
+
A(d(h));
|
|
35
|
+
}, [h]);
|
|
36
|
+
let L = (e) => {
|
|
37
|
+
T === void 0 && M(e.key), w?.(e);
|
|
38
|
+
};
|
|
39
|
+
return /* @__PURE__ */ u("section", {
|
|
40
|
+
"data-slot": "map-view",
|
|
41
|
+
className: e("grid min-w-0 gap-3 rounded-lg border bg-card p-3 shadow-sm", D),
|
|
42
|
+
...O,
|
|
43
|
+
children: [/* @__PURE__ */ u("div", {
|
|
44
|
+
className: "flex flex-wrap items-start justify-between gap-3",
|
|
45
|
+
children: [/* @__PURE__ */ u("div", {
|
|
46
|
+
className: "min-w-0",
|
|
47
|
+
children: [_ ? /* @__PURE__ */ l("h3", {
|
|
48
|
+
className: "text-base font-semibold tracking-tight",
|
|
49
|
+
children: _
|
|
50
|
+
}) : null, v ? /* @__PURE__ */ l("p", {
|
|
51
|
+
className: "mt-1 text-sm text-muted-foreground",
|
|
52
|
+
children: v
|
|
53
|
+
}) : null]
|
|
54
|
+
}), x ? /* @__PURE__ */ u("div", {
|
|
55
|
+
className: "flex items-center gap-1",
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ l(t, {
|
|
58
|
+
type: "button",
|
|
59
|
+
size: "icon-sm",
|
|
60
|
+
variant: "outline",
|
|
61
|
+
iconOnly: !0,
|
|
62
|
+
"aria-label": "Zoom out",
|
|
63
|
+
onClick: () => A((e) => d(e - 1)),
|
|
64
|
+
children: /* @__PURE__ */ l(s, {})
|
|
65
|
+
}),
|
|
66
|
+
/* @__PURE__ */ u(n, {
|
|
67
|
+
variant: "outline",
|
|
68
|
+
tone: "muted",
|
|
69
|
+
children: [k, "x"]
|
|
70
|
+
}),
|
|
71
|
+
/* @__PURE__ */ l(t, {
|
|
72
|
+
type: "button",
|
|
73
|
+
size: "icon-sm",
|
|
74
|
+
variant: "outline",
|
|
75
|
+
iconOnly: !0,
|
|
76
|
+
"aria-label": "Zoom in",
|
|
77
|
+
onClick: () => A((e) => d(e + 1)),
|
|
78
|
+
children: /* @__PURE__ */ l(c, {})
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ l(t, {
|
|
81
|
+
type: "button",
|
|
82
|
+
size: "icon-sm",
|
|
83
|
+
variant: "outline",
|
|
84
|
+
iconOnly: !0,
|
|
85
|
+
"aria-label": "Open in OpenStreetMap",
|
|
86
|
+
onClick: () => window.open(I, "_blank", "noopener,noreferrer"),
|
|
87
|
+
children: /* @__PURE__ */ l(i, {})
|
|
88
|
+
})
|
|
89
|
+
]
|
|
90
|
+
}) : null]
|
|
91
|
+
}), /* @__PURE__ */ u("div", {
|
|
92
|
+
className: e("grid gap-3", b && g.length ? "lg:grid-cols-[minmax(0,1fr)_18rem]" : ""),
|
|
93
|
+
children: [/* @__PURE__ */ u("div", {
|
|
94
|
+
className: "relative overflow-hidden rounded-lg border bg-muted",
|
|
95
|
+
style: { height: y },
|
|
96
|
+
children: [/* @__PURE__ */ l("iframe", {
|
|
97
|
+
title: S,
|
|
98
|
+
src: F,
|
|
99
|
+
className: "absolute inset-0 size-full border-0",
|
|
100
|
+
loading: "lazy",
|
|
101
|
+
referrerPolicy: "no-referrer-when-downgrade"
|
|
102
|
+
}), P ? /* @__PURE__ */ u("div", {
|
|
103
|
+
className: "absolute left-3 top-3 max-w-[calc(100%-1.5rem)] rounded-lg border bg-background/95 p-3 text-sm shadow-lg backdrop-blur",
|
|
104
|
+
children: [/* @__PURE__ */ u("div", {
|
|
105
|
+
className: "flex items-center gap-2 font-medium",
|
|
106
|
+
children: [/* @__PURE__ */ l(a, { className: "size-4 text-primary" }), P.label]
|
|
107
|
+
}), P.description ? /* @__PURE__ */ l("p", {
|
|
108
|
+
className: "mt-1 text-xs text-muted-foreground",
|
|
109
|
+
children: P.description
|
|
110
|
+
}) : null]
|
|
111
|
+
}) : null]
|
|
112
|
+
}), b && g.length ? /* @__PURE__ */ l("div", {
|
|
113
|
+
"data-slot": "map-marker-list",
|
|
114
|
+
className: "grid content-start gap-2",
|
|
115
|
+
children: g.map((e) => {
|
|
116
|
+
let t = e.key === N;
|
|
117
|
+
return /* @__PURE__ */ u("button", {
|
|
118
|
+
type: "button",
|
|
119
|
+
"aria-pressed": t,
|
|
120
|
+
className: "grid gap-1 rounded-lg border bg-background p-3 text-left text-sm outline-none transition hover:bg-muted/50 focus-visible:ring-2 focus-visible:ring-ring aria-pressed:border-primary aria-pressed:bg-primary/5",
|
|
121
|
+
onClick: () => L(e),
|
|
122
|
+
children: [
|
|
123
|
+
/* @__PURE__ */ u("span", {
|
|
124
|
+
className: "flex items-center justify-between gap-2",
|
|
125
|
+
children: [/* @__PURE__ */ u("span", {
|
|
126
|
+
className: "flex min-w-0 items-center gap-2 font-medium",
|
|
127
|
+
children: [/* @__PURE__ */ l(o, { className: "size-4 shrink-0 text-primary" }), /* @__PURE__ */ l("span", {
|
|
128
|
+
className: "truncate",
|
|
129
|
+
children: e.label
|
|
130
|
+
})]
|
|
131
|
+
}), /* @__PURE__ */ l(n, {
|
|
132
|
+
size: "sm",
|
|
133
|
+
tone: e.tone ?? "muted",
|
|
134
|
+
showDot: !0,
|
|
135
|
+
children: t ? "selected" : "marker"
|
|
136
|
+
})]
|
|
137
|
+
}),
|
|
138
|
+
e.description ? /* @__PURE__ */ l("span", {
|
|
139
|
+
className: "text-xs text-muted-foreground",
|
|
140
|
+
children: e.description
|
|
141
|
+
}) : null,
|
|
142
|
+
/* @__PURE__ */ u("span", {
|
|
143
|
+
className: "text-[11px] text-muted-foreground",
|
|
144
|
+
children: [
|
|
145
|
+
e.latitude.toFixed(4),
|
|
146
|
+
", ",
|
|
147
|
+
e.longitude.toFixed(4)
|
|
148
|
+
]
|
|
149
|
+
})
|
|
150
|
+
]
|
|
151
|
+
}, e.key);
|
|
152
|
+
})
|
|
153
|
+
}) : null]
|
|
154
|
+
})]
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
//#endregion
|
|
158
|
+
export { h as MapView };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/utils.cjs"),n=require("../ui/button/index.cjs"),r=require("../ui/badge/index.cjs");let i=require("react");i=e.__toESM(i,1);let a=require("lucide-react"),o=require("react/jsx-runtime");function s(e){return!Number.isFinite(e)||e<0?`0:00`:`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,`0`)}`}function c(e){return e===`video`?`aspect-video`:e===`square`?`aspect-square`:e===`wide`?`aspect-[21/9]`:``}function l({src:e,title:l,description:u,tracks:d=[],actions:f,aspectRatio:p=`video`,showMeta:m=!0,poster:h,autoPlay:g,muted:_,loop:v,playsInline:y=!0,preload:b=`metadata`,onTimeChange:x,onVolumeValueChange:S,className:C,...w}){let T=i.useRef(null),[E,D]=i.useState(!!g),[O,k]=i.useState(0),[A,j]=i.useState(0),[M,N]=i.useState(1),[P,F]=i.useState(!!_),[I,L]=i.useState(!1),R=i.useCallback(()=>{let e=T.current;e&&(D(!e.paused),k(e.duration||0),j(e.currentTime||0),N(e.volume),F(e.muted),x?.(e.currentTime||0,e.duration||0))},[x]),z=async()=>{let e=T.current;e&&(e.paused?await e.play():e.pause(),R())},B=e=>{let t=T.current;t&&(t.currentTime=e,j(e),x?.(e,O))},V=e=>{let t=T.current,n=Math.max(0,Math.min(1,e));t&&(t.volume=n,t.muted=n===0?!0:P),N(n);let r=n===0?!0:P;F(r),S?.(n,r)},H=()=>{let e=T.current,t=!P;e&&(e.muted=t),F(t),S?.(M,t)},U=P||M===0?a.VolumeXIcon:M<.6?a.Volume1Icon:a.Volume2Icon;return(0,o.jsxs)(`section`,{"data-slot":`media-player`,className:t.cn(`overflow-hidden rounded-lg border bg-card shadow-sm`,C),children:[(0,o.jsxs)(`div`,{className:t.cn(`relative bg-black`,c(p)),style:[`video`,`square`,`wide`].includes(String(p))?void 0:{aspectRatio:String(p)},children:[(0,o.jsx)(`video`,{ref:T,src:e,poster:h,autoPlay:g,muted:P,loop:v,playsInline:y,preload:b,className:`size-full object-cover`,onLoadedMetadata:()=>{L(!0),R()},onPlay:()=>D(!0),onPause:()=>D(!1),onTimeUpdate:R,onVolumeChange:R,...w,children:d.map(e=>(0,o.jsx)(`track`,{...e},`${e.src}-${e.srcLang??``}`))}),(0,o.jsx)(`button`,{type:`button`,"aria-label":E?`Pause media`:`Play media`,className:`absolute inset-0 grid place-items-center bg-black/0 text-white opacity-0 transition hover:bg-black/20 hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>void z(),children:(0,o.jsx)(`span`,{className:`grid size-14 place-items-center rounded-full bg-black/55 backdrop-blur`,children:E?(0,o.jsx)(a.PauseIcon,{className:`size-6`}):(0,o.jsx)(a.PlayIcon,{className:`size-6 translate-x-0.5`})})})]}),(0,o.jsxs)(`div`,{className:`grid gap-3 p-3`,children:[m&&(l||u||f)?(0,o.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,o.jsxs)(`div`,{className:`min-w-0`,children:[l?(0,o.jsx)(`h3`,{className:`truncate text-sm font-semibold`,children:l}):null,u?(0,o.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:u}):null]}),(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[I?null:(0,o.jsx)(r.Badge,{tone:`muted`,variant:`soft`,children:`loading`}),f]})]}):null,(0,o.jsxs)(`div`,{className:`grid gap-2`,children:[(0,o.jsx)(`input`,{"aria-label":`Media progress`,type:`range`,min:0,max:O||0,step:.1,value:Math.min(A,O||A),onChange:e=>B(Number(e.target.value)),className:`h-2 w-full cursor-pointer accent-primary`}),(0,o.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,o.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,o.jsx)(n.Button,{type:`button`,size:`icon-sm`,variant:`outline`,iconOnly:!0,"aria-label":E?`Pause`:`Play`,onClick:()=>void z(),children:E?(0,o.jsx)(a.PauseIcon,{}):(0,o.jsx)(a.PlayIcon,{})}),(0,o.jsx)(n.Button,{type:`button`,size:`icon-sm`,variant:`ghost`,iconOnly:!0,"aria-label":`Restart`,onClick:()=>B(0),children:(0,o.jsx)(a.RotateCcwIcon,{})}),(0,o.jsxs)(`span`,{className:`min-w-20 text-xs tabular-nums text-muted-foreground`,children:[s(A),` / `,s(O)]})]}),(0,o.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,o.jsx)(n.Button,{type:`button`,size:`icon-sm`,variant:`ghost`,iconOnly:!0,"aria-label":P?`Unmute`:`Mute`,onClick:H,children:(0,o.jsx)(U,{})}),(0,o.jsx)(`input`,{"aria-label":`Volume`,type:`range`,min:0,max:1,step:.01,value:P?0:M,onChange:e=>V(Number(e.target.value)),className:`h-2 w-24 cursor-pointer accent-primary`}),(0,o.jsx)(n.Button,{type:`button`,size:`icon-sm`,variant:`ghost`,iconOnly:!0,"aria-label":`Fullscreen`,onClick:()=>T.current?.requestFullscreen?.(),children:(0,o.jsx)(a.MaximizeIcon,{})})]})]})]})]})]})}exports.MediaPlayer=l;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { Button as t } from "../ui/button/index.js";
|
|
4
|
+
import { Badge as n } from "../ui/badge/index.js";
|
|
5
|
+
import * as r from "react";
|
|
6
|
+
import { MaximizeIcon as i, PauseIcon as a, PlayIcon as o, RotateCcwIcon as s, Volume1Icon as c, Volume2Icon as l, VolumeXIcon as u } from "lucide-react";
|
|
7
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/modern/media-player.tsx
|
|
9
|
+
function p(e) {
|
|
10
|
+
return !Number.isFinite(e) || e < 0 ? "0:00" : `${Math.floor(e / 60)}:${Math.floor(e % 60).toString().padStart(2, "0")}`;
|
|
11
|
+
}
|
|
12
|
+
function m(e) {
|
|
13
|
+
return e === "video" ? "aspect-video" : e === "square" ? "aspect-square" : e === "wide" ? "aspect-[21/9]" : "";
|
|
14
|
+
}
|
|
15
|
+
function h({ src: h, title: g, description: _, tracks: v = [], actions: y, aspectRatio: b = "video", showMeta: x = !0, poster: S, autoPlay: C, muted: w, loop: T, playsInline: E = !0, preload: D = "metadata", onTimeChange: O, onVolumeValueChange: k, className: A, ...j }) {
|
|
16
|
+
let M = r.useRef(null), [N, P] = r.useState(!!C), [F, I] = r.useState(0), [L, R] = r.useState(0), [z, B] = r.useState(1), [V, H] = r.useState(!!w), [U, W] = r.useState(!1), G = r.useCallback(() => {
|
|
17
|
+
let e = M.current;
|
|
18
|
+
e && (P(!e.paused), I(e.duration || 0), R(e.currentTime || 0), B(e.volume), H(e.muted), O?.(e.currentTime || 0, e.duration || 0));
|
|
19
|
+
}, [O]), K = async () => {
|
|
20
|
+
let e = M.current;
|
|
21
|
+
e && (e.paused ? await e.play() : e.pause(), G());
|
|
22
|
+
}, q = (e) => {
|
|
23
|
+
let t = M.current;
|
|
24
|
+
t && (t.currentTime = e, R(e), O?.(e, F));
|
|
25
|
+
}, J = (e) => {
|
|
26
|
+
let t = M.current, n = Math.max(0, Math.min(1, e));
|
|
27
|
+
t && (t.volume = n, t.muted = n === 0 ? !0 : V), B(n);
|
|
28
|
+
let r = n === 0 ? !0 : V;
|
|
29
|
+
H(r), k?.(n, r);
|
|
30
|
+
}, Y = () => {
|
|
31
|
+
let e = M.current, t = !V;
|
|
32
|
+
e && (e.muted = t), H(t), k?.(z, t);
|
|
33
|
+
}, X = V || z === 0 ? u : z < .6 ? c : l;
|
|
34
|
+
return /* @__PURE__ */ f("section", {
|
|
35
|
+
"data-slot": "media-player",
|
|
36
|
+
className: e("overflow-hidden rounded-lg border bg-card shadow-sm", A),
|
|
37
|
+
children: [/* @__PURE__ */ f("div", {
|
|
38
|
+
className: e("relative bg-black", m(b)),
|
|
39
|
+
style: [
|
|
40
|
+
"video",
|
|
41
|
+
"square",
|
|
42
|
+
"wide"
|
|
43
|
+
].includes(String(b)) ? void 0 : { aspectRatio: String(b) },
|
|
44
|
+
children: [/* @__PURE__ */ d("video", {
|
|
45
|
+
ref: M,
|
|
46
|
+
src: h,
|
|
47
|
+
poster: S,
|
|
48
|
+
autoPlay: C,
|
|
49
|
+
muted: V,
|
|
50
|
+
loop: T,
|
|
51
|
+
playsInline: E,
|
|
52
|
+
preload: D,
|
|
53
|
+
className: "size-full object-cover",
|
|
54
|
+
onLoadedMetadata: () => {
|
|
55
|
+
W(!0), G();
|
|
56
|
+
},
|
|
57
|
+
onPlay: () => P(!0),
|
|
58
|
+
onPause: () => P(!1),
|
|
59
|
+
onTimeUpdate: G,
|
|
60
|
+
onVolumeChange: G,
|
|
61
|
+
...j,
|
|
62
|
+
children: v.map((e) => /* @__PURE__ */ d("track", { ...e }, `${e.src}-${e.srcLang ?? ""}`))
|
|
63
|
+
}), /* @__PURE__ */ d("button", {
|
|
64
|
+
type: "button",
|
|
65
|
+
"aria-label": N ? "Pause media" : "Play media",
|
|
66
|
+
className: "absolute inset-0 grid place-items-center bg-black/0 text-white opacity-0 transition hover:bg-black/20 hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
67
|
+
onClick: () => void K(),
|
|
68
|
+
children: /* @__PURE__ */ d("span", {
|
|
69
|
+
className: "grid size-14 place-items-center rounded-full bg-black/55 backdrop-blur",
|
|
70
|
+
children: N ? /* @__PURE__ */ d(a, { className: "size-6" }) : /* @__PURE__ */ d(o, { className: "size-6 translate-x-0.5" })
|
|
71
|
+
})
|
|
72
|
+
})]
|
|
73
|
+
}), /* @__PURE__ */ f("div", {
|
|
74
|
+
className: "grid gap-3 p-3",
|
|
75
|
+
children: [x && (g || _ || y) ? /* @__PURE__ */ f("div", {
|
|
76
|
+
className: "flex flex-wrap items-start justify-between gap-3",
|
|
77
|
+
children: [/* @__PURE__ */ f("div", {
|
|
78
|
+
className: "min-w-0",
|
|
79
|
+
children: [g ? /* @__PURE__ */ d("h3", {
|
|
80
|
+
className: "truncate text-sm font-semibold",
|
|
81
|
+
children: g
|
|
82
|
+
}) : null, _ ? /* @__PURE__ */ d("p", {
|
|
83
|
+
className: "mt-1 text-xs text-muted-foreground",
|
|
84
|
+
children: _
|
|
85
|
+
}) : null]
|
|
86
|
+
}), /* @__PURE__ */ f("div", {
|
|
87
|
+
className: "flex items-center gap-2",
|
|
88
|
+
children: [U ? null : /* @__PURE__ */ d(n, {
|
|
89
|
+
tone: "muted",
|
|
90
|
+
variant: "soft",
|
|
91
|
+
children: "loading"
|
|
92
|
+
}), y]
|
|
93
|
+
})]
|
|
94
|
+
}) : null, /* @__PURE__ */ f("div", {
|
|
95
|
+
className: "grid gap-2",
|
|
96
|
+
children: [/* @__PURE__ */ d("input", {
|
|
97
|
+
"aria-label": "Media progress",
|
|
98
|
+
type: "range",
|
|
99
|
+
min: 0,
|
|
100
|
+
max: F || 0,
|
|
101
|
+
step: .1,
|
|
102
|
+
value: Math.min(L, F || L),
|
|
103
|
+
onChange: (e) => q(Number(e.target.value)),
|
|
104
|
+
className: "h-2 w-full cursor-pointer accent-primary"
|
|
105
|
+
}), /* @__PURE__ */ f("div", {
|
|
106
|
+
className: "flex flex-wrap items-center justify-between gap-3",
|
|
107
|
+
children: [/* @__PURE__ */ f("div", {
|
|
108
|
+
className: "flex items-center gap-1",
|
|
109
|
+
children: [
|
|
110
|
+
/* @__PURE__ */ d(t, {
|
|
111
|
+
type: "button",
|
|
112
|
+
size: "icon-sm",
|
|
113
|
+
variant: "outline",
|
|
114
|
+
iconOnly: !0,
|
|
115
|
+
"aria-label": N ? "Pause" : "Play",
|
|
116
|
+
onClick: () => void K(),
|
|
117
|
+
children: d(N ? a : o, {})
|
|
118
|
+
}),
|
|
119
|
+
/* @__PURE__ */ d(t, {
|
|
120
|
+
type: "button",
|
|
121
|
+
size: "icon-sm",
|
|
122
|
+
variant: "ghost",
|
|
123
|
+
iconOnly: !0,
|
|
124
|
+
"aria-label": "Restart",
|
|
125
|
+
onClick: () => q(0),
|
|
126
|
+
children: /* @__PURE__ */ d(s, {})
|
|
127
|
+
}),
|
|
128
|
+
/* @__PURE__ */ f("span", {
|
|
129
|
+
className: "min-w-20 text-xs tabular-nums text-muted-foreground",
|
|
130
|
+
children: [
|
|
131
|
+
p(L),
|
|
132
|
+
" / ",
|
|
133
|
+
p(F)
|
|
134
|
+
]
|
|
135
|
+
})
|
|
136
|
+
]
|
|
137
|
+
}), /* @__PURE__ */ f("div", {
|
|
138
|
+
className: "flex items-center gap-2",
|
|
139
|
+
children: [
|
|
140
|
+
/* @__PURE__ */ d(t, {
|
|
141
|
+
type: "button",
|
|
142
|
+
size: "icon-sm",
|
|
143
|
+
variant: "ghost",
|
|
144
|
+
iconOnly: !0,
|
|
145
|
+
"aria-label": V ? "Unmute" : "Mute",
|
|
146
|
+
onClick: Y,
|
|
147
|
+
children: /* @__PURE__ */ d(X, {})
|
|
148
|
+
}),
|
|
149
|
+
/* @__PURE__ */ d("input", {
|
|
150
|
+
"aria-label": "Volume",
|
|
151
|
+
type: "range",
|
|
152
|
+
min: 0,
|
|
153
|
+
max: 1,
|
|
154
|
+
step: .01,
|
|
155
|
+
value: V ? 0 : z,
|
|
156
|
+
onChange: (e) => J(Number(e.target.value)),
|
|
157
|
+
className: "h-2 w-24 cursor-pointer accent-primary"
|
|
158
|
+
}),
|
|
159
|
+
/* @__PURE__ */ d(t, {
|
|
160
|
+
type: "button",
|
|
161
|
+
size: "icon-sm",
|
|
162
|
+
variant: "ghost",
|
|
163
|
+
iconOnly: !0,
|
|
164
|
+
"aria-label": "Fullscreen",
|
|
165
|
+
onClick: () => M.current?.requestFullscreen?.(),
|
|
166
|
+
children: /* @__PURE__ */ d(i, {})
|
|
167
|
+
})
|
|
168
|
+
]
|
|
169
|
+
})]
|
|
170
|
+
})]
|
|
171
|
+
})]
|
|
172
|
+
})]
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
//#endregion
|
|
176
|
+
export { h as MediaPlayer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/utils.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("lucide-react"),i=require("react/jsx-runtime");var a=n.createContext(null);function o(e){if(typeof e==`number`)return e;if(typeof e==`string`){let t=Number.parseFloat(e.replace(`%`,``));return Number.isFinite(t)?t:void 0}}function s({direction:e=`horizontal`,className:r,children:s,...u}){let d=n.useRef(null),f=n.Children.toArray(s).filter(e=>n.isValidElement(e)&&e.type===c),p=f.length,m=n.useMemo(()=>{let e=f.map(e=>o(e.props.defaultSize)),t=e.reduce((e,t)=>e+(t??0),0),n=e.filter(e=>e===void 0).length,r=Math.max(100-t,0),i=n>0?r/n:p>0?100/p:100;return e.map(e=>e??i)},[p,f]),h=n.useMemo(()=>f.map(e=>e.props.minSize??15),[f]),[g,_]=n.useState(m);n.useEffect(()=>{_(m)},[m]);let v=n.useCallback((t,n)=>{let r=d.current;if(!r||t<0||t>=p-1)return;let i=e===`horizontal`?r.getBoundingClientRect().width:r.getBoundingClientRect().height;if(!i)return;let a=n/i*100;_(e=>{let n=[...e],r=n[t]??0,i=n[t+1]??0,o=h[t]??15,s=h[t+1]??15,c=r+a,l=Math.min(Math.max(c,o),r+i-s),u=l-r;return n[t]=l,n[t+1]=i-u,n})},[e,h,p]),y=n.Children.map(s,e=>{if(!n.isValidElement(e))return e;if(e.type===c){let t=f.findIndex(t=>t===e);return n.cloneElement(e,{"data-panel-index":t})}if(e.type===l){let t=n.Children.toArray(s).slice(0,n.Children.toArray(s).indexOf(e)).filter(e=>n.isValidElement(e)&&e.type===c).length-1;return n.cloneElement(e,{"data-handle-index":t})}return e});return(0,i.jsx)(a.Provider,{value:{direction:e,getSize:e=>g[e]??100/Math.max(p,1),resizePanels:v},children:(0,i.jsx)(`div`,{ref:d,"data-slot":`resizable-panel-group`,"data-direction":e,className:t.cn(`flex
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/utils.cjs");let n=require("react");n=e.__toESM(n,1);let r=require("lucide-react"),i=require("react/jsx-runtime");var a=n.createContext(null);function o(e){if(typeof e==`number`)return e;if(typeof e==`string`){let t=Number.parseFloat(e.replace(`%`,``));return Number.isFinite(t)?t:void 0}}function s({direction:e=`horizontal`,className:r,children:s,...u}){let d=n.useRef(null),f=n.Children.toArray(s).filter(e=>n.isValidElement(e)&&e.type===c),p=f.length,m=n.useMemo(()=>{let e=f.map(e=>o(e.props.defaultSize)),t=e.reduce((e,t)=>e+(t??0),0),n=e.filter(e=>e===void 0).length,r=Math.max(100-t,0),i=n>0?r/n:p>0?100/p:100;return e.map(e=>e??i)},[p,f]),h=n.useMemo(()=>f.map(e=>e.props.minSize??15),[f]),[g,_]=n.useState(m);n.useEffect(()=>{_(m)},[m]);let v=n.useCallback((t,n)=>{let r=d.current;if(!r||t<0||t>=p-1)return;let i=e===`horizontal`?r.getBoundingClientRect().width:r.getBoundingClientRect().height;if(!i)return;let a=n/i*100;_(e=>{let n=[...e],r=n[t]??0,i=n[t+1]??0,o=h[t]??15,s=h[t+1]??15,c=r+a,l=Math.min(Math.max(c,o),r+i-s),u=l-r;return n[t]=l,n[t+1]=i-u,n})},[e,h,p]),y=n.Children.map(s,e=>{if(!n.isValidElement(e))return e;if(e.type===c){let t=f.findIndex(t=>t===e);return n.cloneElement(e,{"data-panel-index":t})}if(e.type===l){let t=n.Children.toArray(s).slice(0,n.Children.toArray(s).indexOf(e)).filter(e=>n.isValidElement(e)&&e.type===c).length-1;return n.cloneElement(e,{"data-handle-index":t})}return e});return(0,i.jsx)(a.Provider,{value:{direction:e,getSize:e=>g[e]??100/Math.max(p,1),resizePanels:v},children:(0,i.jsx)(`div`,{ref:d,"data-slot":`resizable-panel-group`,"data-direction":e,className:t.cn(`flex`,e===`horizontal`?`flex-row items-stretch`:`flex-col`,r),...u,children:y})})}function c({className:e,style:r,defaultSize:s,minSize:c,...l}){let u=n.useContext(a),d=Number(l[`data-panel-index`]??0),f=u?u.getSize(d):o(s)??100;return(0,i.jsx)(`div`,{"data-slot":`resizable-panel`,className:t.cn(`min-h-24 min-w-0 overflow-auto rounded-[var(--aui-card-radius,var(--radius-lg))] border border-[color:var(--aui-card-border,var(--border))] bg-card p-3 shadow-[var(--aui-card-shadow,0_10px_24px_rgba(15,23,42,0.07))]`,e),style:{flexBasis:`${f}%`,flexGrow:0,flexShrink:0,...r},...l})}function l({className:e,...o}){let s=n.useContext(a),c=Number(o[`data-handle-index`]??0),l=n.useRef(null);return(0,i.jsxs)(`button`,{type:`button`,"data-slot":`resizable-handle`,"aria-label":`Resize panels`,"aria-orientation":s?.direction??`horizontal`,className:t.cn(`group relative flex shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring`,s?.direction===`horizontal`?`w-4 cursor-col-resize px-1`:`h-4 cursor-row-resize py-1`,e),onPointerDown:e=>{s&&(l.current={pointerId:e.pointerId,axis:s.direction===`horizontal`?e.clientX:e.clientY},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{if(!s||!l.current||l.current.pointerId!==e.pointerId)return;let t=s.direction===`horizontal`?e.clientX:e.clientY,n=t-l.current.axis;n!==0&&(l.current.axis=t,s.resizePanels(c,n))},onPointerUp:e=>{l.current?.pointerId===e.pointerId&&(l.current=null)},onPointerCancel:()=>{l.current=null},onKeyDown:e=>{if(!s)return;let t=e.shiftKey?24:12;s.direction===`horizontal`&&e.key===`ArrowLeft`&&(e.preventDefault(),s.resizePanels(c,-t)),s.direction===`horizontal`&&e.key===`ArrowRight`&&(e.preventDefault(),s.resizePanels(c,t)),s.direction===`vertical`&&e.key===`ArrowUp`&&(e.preventDefault(),s.resizePanels(c,-t)),s.direction===`vertical`&&e.key===`ArrowDown`&&(e.preventDefault(),s.resizePanels(c,t))},...o,children:[(0,i.jsx)(`span`,{"aria-hidden":`true`,className:t.cn(`absolute rounded-full bg-border transition-colors group-hover:bg-ring/55`,s?.direction===`horizontal`?`inset-y-2 left-1/2 w-px -translate-x-1/2`:`inset-x-2 top-1/2 h-px -translate-y-1/2`)}),(0,i.jsx)(`span`,{className:`relative grid size-5 place-items-center rounded-full border border-border/75 bg-background shadow-sm transition-colors group-hover:border-ring/45`,children:(0,i.jsx)(r.GripVerticalIcon,{className:t.cn(`size-3`,s?.direction===`vertical`&&`rotate-90`)})})]})}exports.ResizableHandle=l,exports.ResizablePanel=c,exports.ResizablePanelGroup=s;
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
import { cn as e } from "../../lib/utils.js";
|
|
3
3
|
import * as t from "react";
|
|
4
4
|
import { GripVerticalIcon as n } from "lucide-react";
|
|
5
|
-
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
6
6
|
//#region src/components/modern/resizable-panel.tsx
|
|
7
|
-
var
|
|
8
|
-
function
|
|
7
|
+
var a = t.createContext(null);
|
|
8
|
+
function o(e) {
|
|
9
9
|
if (typeof e == "number") return e;
|
|
10
10
|
if (typeof e == "string") {
|
|
11
11
|
let t = Number.parseFloat(e.replace("%", ""));
|
|
12
12
|
return Number.isFinite(t) ? t : void 0;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
let d = t.useRef(null), f = t.Children.toArray(
|
|
17
|
-
let e = f.map((e) =>
|
|
15
|
+
function s({ direction: n = "horizontal", className: i, children: s, ...u }) {
|
|
16
|
+
let d = t.useRef(null), f = t.Children.toArray(s).filter((e) => t.isValidElement(e) && e.type === c), p = f.length, m = t.useMemo(() => {
|
|
17
|
+
let e = f.map((e) => o(e.props.defaultSize)), t = e.reduce((e, t) => e + (t ?? 0), 0), n = e.filter((e) => e === void 0).length, r = Math.max(100 - t, 0), i = n > 0 ? r / n : p > 0 ? 100 / p : 100;
|
|
18
18
|
return e.map((e) => e ?? i);
|
|
19
19
|
}, [p, f]), h = t.useMemo(() => f.map((e) => e.props.minSize ?? 15), [f]), [g, _] = t.useState(m);
|
|
20
20
|
t.useEffect(() => {
|
|
@@ -34,19 +34,19 @@ function o({ direction: n = "horizontal", className: o, children: l, ...u }) {
|
|
|
34
34
|
n,
|
|
35
35
|
h,
|
|
36
36
|
p
|
|
37
|
-
]), y = t.Children.map(
|
|
37
|
+
]), y = t.Children.map(s, (e) => {
|
|
38
38
|
if (!t.isValidElement(e)) return e;
|
|
39
|
-
if (e.type ===
|
|
39
|
+
if (e.type === c) {
|
|
40
40
|
let n = f.findIndex((t) => t === e);
|
|
41
41
|
return t.cloneElement(e, { "data-panel-index": n });
|
|
42
42
|
}
|
|
43
|
-
if (e.type ===
|
|
44
|
-
let n = t.Children.toArray(
|
|
43
|
+
if (e.type === l) {
|
|
44
|
+
let n = t.Children.toArray(s).slice(0, t.Children.toArray(s).indexOf(e)).filter((e) => t.isValidElement(e) && e.type === c).length - 1;
|
|
45
45
|
return t.cloneElement(e, { "data-handle-index": n });
|
|
46
46
|
}
|
|
47
47
|
return e;
|
|
48
48
|
});
|
|
49
|
-
return /* @__PURE__ */ r(
|
|
49
|
+
return /* @__PURE__ */ r(a.Provider, {
|
|
50
50
|
value: {
|
|
51
51
|
direction: n,
|
|
52
52
|
getSize: (e) => g[e] ?? 100 / Math.max(p, 1),
|
|
@@ -56,58 +56,65 @@ function o({ direction: n = "horizontal", className: o, children: l, ...u }) {
|
|
|
56
56
|
ref: d,
|
|
57
57
|
"data-slot": "resizable-panel-group",
|
|
58
58
|
"data-direction": n,
|
|
59
|
-
className: e("flex
|
|
59
|
+
className: e("flex", n === "horizontal" ? "flex-row items-stretch" : "flex-col", i),
|
|
60
60
|
...u,
|
|
61
61
|
children: y
|
|
62
62
|
})
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
function
|
|
66
|
-
let u = t.useContext(
|
|
65
|
+
function c({ className: n, style: i, defaultSize: s, minSize: c, ...l }) {
|
|
66
|
+
let u = t.useContext(a), d = Number(l["data-panel-index"] ?? 0), f = u ? u.getSize(d) : o(s) ?? 100;
|
|
67
67
|
return /* @__PURE__ */ r("div", {
|
|
68
68
|
"data-slot": "resizable-panel",
|
|
69
|
-
className: e("min-h-24 overflow-auto rounded-lg border bg-card p-3", n),
|
|
69
|
+
className: e("min-h-24 min-w-0 overflow-auto rounded-[var(--aui-card-radius,var(--radius-lg))] border border-[color:var(--aui-card-border,var(--border))] bg-card p-3 shadow-[var(--aui-card-shadow,0_10px_24px_rgba(15,23,42,0.07))]", n),
|
|
70
70
|
style: {
|
|
71
71
|
flexBasis: `${f}%`,
|
|
72
72
|
flexGrow: 0,
|
|
73
73
|
flexShrink: 0,
|
|
74
|
-
...
|
|
74
|
+
...i
|
|
75
75
|
},
|
|
76
76
|
...l
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
-
function
|
|
80
|
-
let
|
|
81
|
-
return /* @__PURE__ */
|
|
79
|
+
function l({ className: o, ...s }) {
|
|
80
|
+
let c = t.useContext(a), l = Number(s["data-handle-index"] ?? 0), u = t.useRef(null);
|
|
81
|
+
return /* @__PURE__ */ i("button", {
|
|
82
82
|
type: "button",
|
|
83
83
|
"data-slot": "resizable-handle",
|
|
84
84
|
"aria-label": "Resize panels",
|
|
85
|
-
|
|
85
|
+
"aria-orientation": c?.direction ?? "horizontal",
|
|
86
|
+
className: e("group relative flex shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring", c?.direction === "horizontal" ? "w-4 cursor-col-resize px-1" : "h-4 cursor-row-resize py-1", o),
|
|
86
87
|
onPointerDown: (e) => {
|
|
87
|
-
|
|
88
|
+
c && (u.current = {
|
|
88
89
|
pointerId: e.pointerId,
|
|
89
|
-
axis:
|
|
90
|
+
axis: c.direction === "horizontal" ? e.clientX : e.clientY
|
|
90
91
|
}, e.currentTarget.setPointerCapture(e.pointerId));
|
|
91
92
|
},
|
|
92
93
|
onPointerMove: (e) => {
|
|
93
|
-
if (!
|
|
94
|
-
let t =
|
|
95
|
-
n !== 0 && (
|
|
94
|
+
if (!c || !u.current || u.current.pointerId !== e.pointerId) return;
|
|
95
|
+
let t = c.direction === "horizontal" ? e.clientX : e.clientY, n = t - u.current.axis;
|
|
96
|
+
n !== 0 && (u.current.axis = t, c.resizePanels(l, n));
|
|
96
97
|
},
|
|
97
98
|
onPointerUp: (e) => {
|
|
98
|
-
|
|
99
|
+
u.current?.pointerId === e.pointerId && (u.current = null);
|
|
99
100
|
},
|
|
100
101
|
onPointerCancel: () => {
|
|
101
|
-
|
|
102
|
+
u.current = null;
|
|
102
103
|
},
|
|
103
104
|
onKeyDown: (e) => {
|
|
104
|
-
if (!
|
|
105
|
+
if (!c) return;
|
|
105
106
|
let t = e.shiftKey ? 24 : 12;
|
|
106
|
-
|
|
107
|
+
c.direction === "horizontal" && e.key === "ArrowLeft" && (e.preventDefault(), c.resizePanels(l, -t)), c.direction === "horizontal" && e.key === "ArrowRight" && (e.preventDefault(), c.resizePanels(l, t)), c.direction === "vertical" && e.key === "ArrowUp" && (e.preventDefault(), c.resizePanels(l, -t)), c.direction === "vertical" && e.key === "ArrowDown" && (e.preventDefault(), c.resizePanels(l, t));
|
|
107
108
|
},
|
|
108
|
-
...
|
|
109
|
-
children: /* @__PURE__ */ r(
|
|
109
|
+
...s,
|
|
110
|
+
children: [/* @__PURE__ */ r("span", {
|
|
111
|
+
"aria-hidden": "true",
|
|
112
|
+
className: e("absolute rounded-full bg-border transition-colors group-hover:bg-ring/55", c?.direction === "horizontal" ? "inset-y-2 left-1/2 w-px -translate-x-1/2" : "inset-x-2 top-1/2 h-px -translate-y-1/2")
|
|
113
|
+
}), /* @__PURE__ */ r("span", {
|
|
114
|
+
className: "relative grid size-5 place-items-center rounded-full border border-border/75 bg-background shadow-sm transition-colors group-hover:border-ring/45",
|
|
115
|
+
children: /* @__PURE__ */ r(n, { className: e("size-3", c?.direction === "vertical" && "rotate-90") })
|
|
116
|
+
})]
|
|
110
117
|
});
|
|
111
118
|
}
|
|
112
119
|
//#endregion
|
|
113
|
-
export {
|
|
120
|
+
export { l as ResizableHandle, c as ResizablePanel, s as ResizablePanelGroup };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/utils.cjs"),n=require("../ui/button/index.cjs");let r=require("react");r=e.__toESM(r,1);let i=require("lucide-react"),a=require("react/jsx-runtime");function o(e){return e===`center`?`text-center`:e===`right`?`text-right`:`text-left`}function s(e,t){return{key:`row-${Date.now()}-${t}`,cells:Object.fromEntries(e.map(e=>[e.key,``]))}}function c({columns:e,rows:c,defaultRows:l=[],onRowsChange:u,onCellChange:d,selectedCell:f,defaultSelectedCell:p,onSelectedCellChange:m,readOnly:h=!1,showRowNumbers:g=!0,showAddRow:_=!0,addRowLabel:v=`Add row`,empty:y=`No rows yet.`,className:b,...x}){let[S,C]=r.useState(l),[w,T]=r.useState(p),E=c??S,D=f??w,O=(e,t)=>{c===void 0&&C(e),u?.(e,t)},k=e=>{f===void 0&&T(e),m?.(e)},A=(e,t)=>{let n=E.map(n=>n.key===e.rowKey?{...n,cells:{...n.cells,[e.columnKey]:t}}:n);O(n,e),d?.(t,e,n)},j=()=>{O([...E,s(e,E.length+1)])};return(0,a.jsxs)(`div`,{"data-slot":`spreadsheet`,className:t.cn(`grid min-w-0 gap-3 rounded-lg border bg-card p-3 shadow-sm`,b),...x,children:[(0,a.jsx)(`div`,{className:`overflow-auto rounded-lg border`,children:(0,a.jsxs)(`table`,{className:`w-full min-w-[48rem] border-collapse text-sm`,children:[(0,a.jsx)(`thead`,{className:`sticky top-0 z-10 bg-muted/80 backdrop-blur`,children:(0,a.jsxs)(`tr`,{children:[g?(0,a.jsx)(`th`,{className:`w-12 border-b border-r px-3 py-2 text-left text-xs font-medium text-muted-foreground`,children:`#`}):null,e.map(e=>(0,a.jsx)(`th`,{className:t.cn(`border-b border-r px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground last:border-r-0`,o(e.align)),style:{width:e.width},children:e.label},e.key))]})}),(0,a.jsx)(`tbody`,{children:E.length?E.map((n,r)=>(0,a.jsxs)(`tr`,{"data-readonly":n.readOnly||void 0,className:`odd:bg-background even:bg-muted/18`,children:[g?(0,a.jsx)(`th`,{className:`border-r px-3 py-1.5 text-left text-xs font-medium text-muted-foreground`,children:r+1}):null,e.map(e=>{let i={rowKey:n.key,columnKey:e.key},s=D?.rowKey===n.key&&D.columnKey===e.key,c=n.cells[e.key]??``,l=h||n.readOnly||e.readOnly;return(0,a.jsx)(`td`,{"data-selected":s||void 0,className:`border-r border-t p-0 last:border-r-0 data-[selected=true]:ring-2 data-[selected=true]:ring-inset data-[selected=true]:ring-primary/55`,children:l&&e.formatter?(0,a.jsx)(`div`,{className:t.cn(`min-h-10 px-3 py-2`,o(e.align)),children:e.formatter(c,n)}):(0,a.jsx)(`input`,{"aria-label":`${String(e.label)} row ${r+1}`,value:c,readOnly:l,className:t.cn(`h-10 w-full bg-transparent px-3 outline-none transition focus:bg-background read-only:cursor-default`,o(e.align)),onFocus:()=>k(i),onChange:e=>A(i,e.target.value)})},e.key)})]},n.key)):(0,a.jsx)(`tr`,{children:(0,a.jsx)(`td`,{colSpan:e.length+ +!!g,className:`h-32 text-center text-sm text-muted-foreground`,children:y})})})]})}),_&&!h?(0,a.jsx)(n.Button,{type:`button`,className:`w-fit`,variant:`outline`,size:`sm`,leftIcon:(0,a.jsx)(i.PlusIcon,{}),onClick:j,children:v}):null]})}exports.Spreadsheet=c;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { Button as t } from "../ui/button/index.js";
|
|
4
|
+
import * as n from "react";
|
|
5
|
+
import { PlusIcon as r } from "lucide-react";
|
|
6
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/modern/spreadsheet.tsx
|
|
8
|
+
function o(e) {
|
|
9
|
+
return e === "center" ? "text-center" : e === "right" ? "text-right" : "text-left";
|
|
10
|
+
}
|
|
11
|
+
function s(e, t) {
|
|
12
|
+
return {
|
|
13
|
+
key: `row-${Date.now()}-${t}`,
|
|
14
|
+
cells: Object.fromEntries(e.map((e) => [e.key, ""]))
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function c({ columns: c, rows: l, defaultRows: u = [], onRowsChange: d, onCellChange: f, selectedCell: p, defaultSelectedCell: m, onSelectedCellChange: h, readOnly: g = !1, showRowNumbers: _ = !0, showAddRow: v = !0, addRowLabel: y = "Add row", empty: b = "No rows yet.", className: x, ...S }) {
|
|
18
|
+
let [C, w] = n.useState(u), [T, E] = n.useState(m), D = l ?? C, O = p ?? T, k = (e, t) => {
|
|
19
|
+
l === void 0 && w(e), d?.(e, t);
|
|
20
|
+
}, A = (e) => {
|
|
21
|
+
p === void 0 && E(e), h?.(e);
|
|
22
|
+
}, j = (e, t) => {
|
|
23
|
+
let n = D.map((n) => n.key === e.rowKey ? {
|
|
24
|
+
...n,
|
|
25
|
+
cells: {
|
|
26
|
+
...n.cells,
|
|
27
|
+
[e.columnKey]: t
|
|
28
|
+
}
|
|
29
|
+
} : n);
|
|
30
|
+
k(n, e), f?.(t, e, n);
|
|
31
|
+
}, M = () => {
|
|
32
|
+
k([...D, s(c, D.length + 1)]);
|
|
33
|
+
};
|
|
34
|
+
return /* @__PURE__ */ a("div", {
|
|
35
|
+
"data-slot": "spreadsheet",
|
|
36
|
+
className: e("grid min-w-0 gap-3 rounded-lg border bg-card p-3 shadow-sm", x),
|
|
37
|
+
...S,
|
|
38
|
+
children: [/* @__PURE__ */ i("div", {
|
|
39
|
+
className: "overflow-auto rounded-lg border",
|
|
40
|
+
children: /* @__PURE__ */ a("table", {
|
|
41
|
+
className: "w-full min-w-[48rem] border-collapse text-sm",
|
|
42
|
+
children: [/* @__PURE__ */ i("thead", {
|
|
43
|
+
className: "sticky top-0 z-10 bg-muted/80 backdrop-blur",
|
|
44
|
+
children: /* @__PURE__ */ a("tr", { children: [_ ? /* @__PURE__ */ i("th", {
|
|
45
|
+
className: "w-12 border-b border-r px-3 py-2 text-left text-xs font-medium text-muted-foreground",
|
|
46
|
+
children: "#"
|
|
47
|
+
}) : null, c.map((t) => /* @__PURE__ */ i("th", {
|
|
48
|
+
className: e("border-b border-r px-3 py-2 text-xs font-medium uppercase tracking-wide text-muted-foreground last:border-r-0", o(t.align)),
|
|
49
|
+
style: { width: t.width },
|
|
50
|
+
children: t.label
|
|
51
|
+
}, t.key))] })
|
|
52
|
+
}), /* @__PURE__ */ i("tbody", { children: D.length ? D.map((t, n) => /* @__PURE__ */ a("tr", {
|
|
53
|
+
"data-readonly": t.readOnly || void 0,
|
|
54
|
+
className: "odd:bg-background even:bg-muted/18",
|
|
55
|
+
children: [_ ? /* @__PURE__ */ i("th", {
|
|
56
|
+
className: "border-r px-3 py-1.5 text-left text-xs font-medium text-muted-foreground",
|
|
57
|
+
children: n + 1
|
|
58
|
+
}) : null, c.map((r) => {
|
|
59
|
+
let a = {
|
|
60
|
+
rowKey: t.key,
|
|
61
|
+
columnKey: r.key
|
|
62
|
+
}, s = O?.rowKey === t.key && O.columnKey === r.key, c = t.cells[r.key] ?? "", l = g || t.readOnly || r.readOnly;
|
|
63
|
+
return /* @__PURE__ */ i("td", {
|
|
64
|
+
"data-selected": s || void 0,
|
|
65
|
+
className: "border-r border-t p-0 last:border-r-0 data-[selected=true]:ring-2 data-[selected=true]:ring-inset data-[selected=true]:ring-primary/55",
|
|
66
|
+
children: l && r.formatter ? /* @__PURE__ */ i("div", {
|
|
67
|
+
className: e("min-h-10 px-3 py-2", o(r.align)),
|
|
68
|
+
children: r.formatter(c, t)
|
|
69
|
+
}) : /* @__PURE__ */ i("input", {
|
|
70
|
+
"aria-label": `${String(r.label)} row ${n + 1}`,
|
|
71
|
+
value: c,
|
|
72
|
+
readOnly: l,
|
|
73
|
+
className: e("h-10 w-full bg-transparent px-3 outline-none transition focus:bg-background read-only:cursor-default", o(r.align)),
|
|
74
|
+
onFocus: () => A(a),
|
|
75
|
+
onChange: (e) => j(a, e.target.value)
|
|
76
|
+
})
|
|
77
|
+
}, r.key);
|
|
78
|
+
})]
|
|
79
|
+
}, t.key)) : /* @__PURE__ */ i("tr", { children: /* @__PURE__ */ i("td", {
|
|
80
|
+
colSpan: c.length + +!!_,
|
|
81
|
+
className: "h-32 text-center text-sm text-muted-foreground",
|
|
82
|
+
children: b
|
|
83
|
+
}) }) })]
|
|
84
|
+
})
|
|
85
|
+
}), v && !g ? /* @__PURE__ */ i(t, {
|
|
86
|
+
type: "button",
|
|
87
|
+
className: "w-fit",
|
|
88
|
+
variant: "outline",
|
|
89
|
+
size: "sm",
|
|
90
|
+
leftIcon: /* @__PURE__ */ i(r, {}),
|
|
91
|
+
onClick: M,
|
|
92
|
+
children: y
|
|
93
|
+
}) : null]
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
export { c as Spreadsheet };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/utils.cjs"),n=require("../ui/button/index.cjs");let r=require("react");r=e.__toESM(r,1);let i=require("lucide-react"),a=require("react/jsx-runtime");function o(e,t){let n=Math.max(t-e+1,0);return Array.from({length:n},(t,n)=>n+e)}function s(e,t,n=1){if(t<=n*2+5)return o(1,t);let r=Math.max(e-n,1),i=Math.min(e+n,t),a=r>2,s=i<t-1;return!a&&s?[...o(1,n*2+3),`ellipsis`,t]:a&&!s?[1,`ellipsis`,...o(t-(n*2+3)+1,t)]:[1,`ellipsis`,...o(r,i),`ellipsis`,t]}function c({className:e,page:r,pageCount:o,onPageChange:c,siblingCount:l=1,showEdges:u=!0,disabled:d=!1,labels:f,compact:p=!1,totalCount:m,pageSize:h,pageSizeOptions:g,onPageSizeChange:_,showSummary:v=!1,...y}){let b=Math.max(o,1),x=Math.min(Math.max(r,1),b),S=s(x,b,l),C=e=>{let t=Math.min(Math.max(e,1),b);t!==x&&c(t)};return(0,a.jsxs)(`nav`,{"data-slot":`pagination`,"aria-label":`Pagination`,className:t.cn(`flex flex-wrap items-center justify-center gap-1 rounded-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../lib/utils.cjs"),n=require("../ui/button/index.cjs");let r=require("react");r=e.__toESM(r,1);let i=require("lucide-react"),a=require("react/jsx-runtime");function o(e,t){let n=Math.max(t-e+1,0);return Array.from({length:n},(t,n)=>n+e)}function s(e,t,n=1){if(t<=n*2+5)return o(1,t);let r=Math.max(e-n,1),i=Math.min(e+n,t),a=r>2,s=i<t-1;return!a&&s?[...o(1,n*2+3),`ellipsis`,t]:a&&!s?[1,`ellipsis`,...o(t-(n*2+3)+1,t)]:[1,`ellipsis`,...o(r,i),`ellipsis`,t]}function c({className:e,page:r,pageCount:o,onPageChange:c,siblingCount:l=1,showEdges:u=!0,disabled:d=!1,labels:f,compact:p=!1,totalCount:m,pageSize:h,pageSizeOptions:g,onPageSizeChange:_,showSummary:v=!1,...y}){let b=Math.max(o,1),x=Math.min(Math.max(r,1),b),S=s(x,b,l),C=e=>{let t=Math.min(Math.max(e,1),b);t!==x&&c(t)};return(0,a.jsxs)(`nav`,{"data-slot":`pagination`,"aria-label":`Pagination`,className:t.cn(`flex flex-wrap items-center justify-center gap-1.5 rounded-[var(--radius-lg)] border border-border/72 bg-background/84 p-1.5 shadow-[0_1px_2px_rgba(15,23,42,0.04)] backdrop-blur`,e),...y,children:[v&&m!==void 0&&h?(0,a.jsxs)(`div`,{className:`mr-1 rounded-[var(--radius-md)] bg-muted/55 px-2.5 py-1.5 text-xs font-medium text-muted-foreground`,children:[Math.min((x-1)*h+1,m),`-`,Math.min(x*h,m),` of `,m]}):null,u&&(0,a.jsx)(n.Button,{type:`button`,variant:`outline`,size:p?`icon-xs`:`icon-sm`,disabled:d||x<=1,"aria-label":f?.first??`First page`,onClick:()=>C(1),children:(0,a.jsx)(i.ChevronFirstIcon,{})}),(0,a.jsx)(n.Button,{type:`button`,variant:`outline`,size:p?`icon-xs`:`icon-sm`,disabled:d||x<=1,"aria-label":f?.previous??`Previous page`,onClick:()=>C(x-1),children:(0,a.jsx)(i.ChevronLeftIcon,{})}),S.map((e,r)=>e===`ellipsis`?(0,a.jsxs)(`span`,{"data-slot":`pagination-ellipsis`,className:`flex size-8 items-center justify-center text-muted-foreground`,children:[(0,a.jsx)(i.MoreHorizontalIcon,{className:`size-4`}),(0,a.jsx)(`span`,{className:`sr-only`,children:`More pages`})]},`ellipsis-${r}`):(0,a.jsx)(n.Button,{type:`button`,variant:e===x?`default`:`outline`,size:p?`icon-xs`:`icon-sm`,disabled:d,"aria-current":e===x?`page`:void 0,"aria-label":f?.page?.(e)??`Page ${e}`,onClick:()=>C(e),className:t.cn(`tabular-nums`,e===x&&`shadow-[0_8px_20px_rgba(15,23,42,0.14)]`,e!==x&&`border-border/70 bg-background/80 shadow-none hover:bg-muted/70`),children:e},e)),(0,a.jsx)(n.Button,{type:`button`,variant:`outline`,size:p?`icon-xs`:`icon-sm`,disabled:d||x>=b,"aria-label":f?.next??`Next page`,onClick:()=>C(x+1),children:(0,a.jsx)(i.ChevronRightIcon,{})}),u&&(0,a.jsx)(n.Button,{type:`button`,variant:`outline`,size:p?`icon-xs`:`icon-sm`,disabled:d||x>=b,"aria-label":f?.last??`Last page`,onClick:()=>C(b),children:(0,a.jsx)(i.ChevronLastIcon,{})}),g&&h&&_?(0,a.jsxs)(`label`,{className:`ml-1 inline-flex h-9 items-center gap-2 rounded-[var(--radius-md)] border border-border/70 bg-background/90 px-3 text-xs font-medium text-muted-foreground`,children:[(0,a.jsx)(`span`,{children:`Rows`}),(0,a.jsx)(`select`,{className:`rounded-sm bg-transparent text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring`,value:h,onChange:e=>_(Number(e.target.value)),disabled:d,children:g.map(e=>(0,a.jsx)(`option`,{value:e,children:e},e))})]}):null]})}exports.Pagination=c,exports.getPaginationItems=s;
|