asterui 0.12.61 → 0.12.63
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/Affix.d.ts +2 -0
- package/dist/components/Affix.js.map +1 -1
- package/dist/components/Alert.d.ts +2 -0
- package/dist/components/Alert.js.map +1 -1
- package/dist/components/Anchor.d.ts +2 -0
- package/dist/components/Anchor.js +79 -75
- package/dist/components/Anchor.js.map +1 -1
- package/dist/components/Autocomplete.d.ts +1 -0
- package/dist/components/Autocomplete.js +115 -110
- package/dist/components/Autocomplete.js.map +1 -1
- package/dist/components/Avatar.d.ts +4 -0
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Breadcrumb.d.ts +4 -2
- package/dist/components/Breadcrumb.js +54 -29
- package/dist/components/Breadcrumb.js.map +1 -1
- package/dist/components/Browser.d.ts +2 -0
- package/dist/components/Browser.js.map +1 -1
- package/dist/components/Button.d.ts +5 -1
- package/dist/components/Button.js +117 -107
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Chart.d.ts +1 -0
- package/dist/components/Chart.js +31 -30
- package/dist/components/Chart.js.map +1 -1
- package/dist/components/Chat.d.ts +1 -0
- package/dist/components/Chat.js +39 -28
- package/dist/components/Chat.js.map +1 -1
- package/dist/components/Code.d.ts +2 -0
- package/dist/components/Code.js.map +1 -1
- package/dist/components/Command.d.ts +5 -2
- package/dist/components/Command.js +262 -233
- package/dist/components/Command.js.map +1 -1
- package/dist/components/Container.d.ts +2 -0
- package/dist/components/Container.js.map +1 -1
- package/dist/components/ContextMenu.d.ts +4 -0
- package/dist/components/ContextMenu.js +157 -122
- package/dist/components/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton.d.ts +2 -0
- package/dist/components/CopyButton.js +9 -8
- package/dist/components/CopyButton.js.map +1 -1
- package/dist/components/Countdown.d.ts +3 -3
- package/dist/components/Countdown.js +49 -47
- package/dist/components/Countdown.js.map +1 -1
- package/dist/components/Diff.d.ts +3 -3
- package/dist/components/Diff.js +14 -10
- package/dist/components/Diff.js.map +1 -1
- package/dist/components/Divider.d.ts +2 -0
- package/dist/components/Divider.js.map +1 -1
- package/dist/components/Dock.d.ts +6 -0
- package/dist/components/Dock.js +75 -38
- package/dist/components/Dock.js.map +1 -1
- package/dist/components/Dropdown.js +110 -110
- package/dist/components/Dropdown.js.map +1 -1
- package/dist/components/Fieldset.d.ts +2 -0
- package/dist/components/Fieldset.js.map +1 -1
- package/dist/components/FileInput.d.ts +1 -0
- package/dist/components/FileInput.js +26 -26
- package/dist/components/FileInput.js.map +1 -1
- package/dist/components/Filter.d.ts +1 -0
- package/dist/components/Filter.js +43 -40
- package/dist/components/Filter.js.map +1 -1
- package/dist/components/Flex.d.ts +1 -0
- package/dist/components/Flex.js +43 -42
- package/dist/components/Flex.js.map +1 -1
- package/dist/components/FloatButton.d.ts +9 -0
- package/dist/components/FloatButton.js +211 -136
- package/dist/components/FloatButton.js.map +1 -1
- package/dist/components/Footer.d.ts +2 -0
- package/dist/components/Footer.js.map +1 -1
- package/dist/components/Grid.d.ts +4 -0
- package/dist/components/Grid.js.map +1 -1
- package/dist/components/Hero.d.ts +2 -0
- package/dist/components/Hero.js.map +1 -1
- package/dist/components/HoverGallery.d.ts +3 -3
- package/dist/components/HoverGallery.js +12 -10
- package/dist/components/HoverGallery.js.map +1 -1
- package/dist/components/Input.d.ts +1 -0
- package/dist/components/Input.js +201 -184
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Join.d.ts +2 -0
- package/dist/components/Join.js.map +1 -1
- package/dist/components/Kbd.d.ts +2 -0
- package/dist/components/Kbd.js.map +1 -1
- package/dist/components/Loading.d.ts +3 -0
- package/dist/components/Loading.js +58 -35
- package/dist/components/Loading.js.map +1 -1
- package/dist/components/Mask.d.ts +2 -2
- package/dist/components/Mask.js.map +1 -1
- package/dist/components/Masonry.d.ts +1 -0
- package/dist/components/Masonry.js +45 -42
- package/dist/components/Masonry.js.map +1 -1
- package/dist/components/Mention.d.ts +1 -0
- package/dist/components/Mention.js +95 -91
- package/dist/components/Mention.js.map +1 -1
- package/dist/components/MonthCalendar.d.ts +1 -0
- package/dist/components/MonthCalendar.js +104 -97
- package/dist/components/MonthCalendar.js.map +1 -1
- package/dist/components/Navbar.d.ts +2 -0
- package/dist/components/Navbar.js.map +1 -1
- package/dist/components/Notification.js +32 -18
- package/dist/components/Notification.js.map +1 -1
- package/dist/components/Phone.d.ts +3 -2
- package/dist/components/Phone.js +10 -8
- package/dist/components/Phone.js.map +1 -1
- package/dist/components/Popconfirm.js +110 -92
- package/dist/components/Popconfirm.js.map +1 -1
- package/dist/components/Popover.d.ts +2 -0
- package/dist/components/Popover.js.map +1 -1
- package/dist/components/Progress.d.ts +2 -0
- package/dist/components/Progress.js.map +1 -1
- package/dist/components/QRCode.d.ts +1 -0
- package/dist/components/QRCode.js +84 -55
- package/dist/components/QRCode.js.map +1 -1
- package/dist/components/RadialProgress.d.ts +1 -0
- package/dist/components/RadialProgress.js +19 -17
- package/dist/components/RadialProgress.js.map +1 -1
- package/dist/components/Radio.d.ts +6 -3
- package/dist/components/Radio.js +9 -9
- package/dist/components/Radio.js.map +1 -1
- package/dist/components/Range.d.ts +1 -0
- package/dist/components/Range.js +45 -43
- package/dist/components/Range.js.map +1 -1
- package/dist/components/Rating.d.ts +4 -2
- package/dist/components/Rating.js +83 -79
- package/dist/components/Rating.js.map +1 -1
- package/dist/components/Responsive.d.ts +4 -2
- package/dist/components/Responsive.js +10 -9
- package/dist/components/Responsive.js.map +1 -1
- package/dist/components/Result.d.ts +1 -0
- package/dist/components/Result.js +24 -22
- package/dist/components/Result.js.map +1 -1
- package/dist/components/Select.d.ts +1 -0
- package/dist/components/Select.js +72 -62
- package/dist/components/Select.js.map +1 -1
- package/dist/components/Skeleton.d.ts +2 -0
- package/dist/components/Skeleton.js.map +1 -1
- package/dist/components/Space.d.ts +2 -0
- package/dist/components/Space.js.map +1 -1
- package/dist/components/Splitter.d.ts +2 -0
- package/dist/components/Splitter.js +137 -131
- package/dist/components/Splitter.js.map +1 -1
- package/dist/components/Stat.d.ts +4 -2
- package/dist/components/Stat.js +19 -18
- package/dist/components/Stat.js.map +1 -1
- package/dist/components/Status.d.ts +3 -3
- package/dist/components/Status.js +27 -25
- package/dist/components/Status.js.map +1 -1
- package/dist/components/Steps.d.ts +4 -2
- package/dist/components/Steps.js +56 -52
- package/dist/components/Steps.js.map +1 -1
- package/dist/components/TextRotate.d.ts +1 -0
- package/dist/components/TextRotate.js +14 -12
- package/dist/components/TextRotate.js.map +1 -1
- package/dist/components/Textarea.d.ts +1 -0
- package/dist/components/Textarea.js +31 -30
- package/dist/components/Textarea.js.map +1 -1
- package/dist/components/ThemeController.d.ts +6 -3
- package/dist/components/ThemeController.js +101 -92
- package/dist/components/ThemeController.js.map +1 -1
- package/dist/components/Toggle.d.ts +2 -0
- package/dist/components/Toggle.js.map +1 -1
- package/dist/components/Tooltip.d.ts +2 -0
- package/dist/components/Tooltip.js +38 -32
- package/dist/components/Tooltip.js.map +1 -1
- package/dist/components/Typography.d.ts +10 -5
- package/dist/components/Typography.js +84 -81
- package/dist/components/Typography.js.map +1 -1
- package/dist/components/VirtualList.d.ts +2 -1
- package/dist/components/VirtualList.js +40 -36
- package/dist/components/VirtualList.js.map +1 -1
- package/dist/components/Watermark.d.ts +1 -0
- package/dist/components/Watermark.js +74 -71
- package/dist/components/Watermark.js.map +1 -1
- package/dist/components/WeekCalendar.d.ts +1 -0
- package/dist/components/WeekCalendar.js +91 -76
- package/dist/components/WeekCalendar.js.map +1 -1
- package/dist/components/Window.d.ts +3 -2
- package/dist/components/Window.js +9 -7
- package/dist/components/Window.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VirtualList.js","sources":["../../src/components/VirtualList.tsx"],"sourcesContent":["import React, { useRef } from 'react'\nimport { useVirtualizer } from '@tanstack/react-virtual'\n\nexport interface VirtualListProps<T> {\n /** Array of items to render */\n items: T[]\n /** Height of the scrollable container */\n height: number | string\n /** Height of each item, or function returning estimated height per item */\n itemHeight: number | ((item: T, index: number) => number)\n /** Render function for each item */\n renderItem: (item: T, index: number) => React.ReactNode\n /** Number of items to render outside visible area */\n overscan?: number\n /** Additional class for the scroll container */\n className?: string\n /** Additional class for the inner container */\n innerClassName?: string\n /** Additional class for each item wrapper */\n itemClassName?: string\n /** Width of the container */\n width?: number | string\n /** Gap between items */\n gap?: number\n /** Callback when scroll position changes */\n onScroll?: (scrollTop: number) => void\n}\n\nexport function VirtualList<T>({\n items,\n height,\n itemHeight,\n renderItem,\n overscan = 5,\n className = '',\n innerClassName = '',\n itemClassName = '',\n width,\n gap = 0,\n onScroll,\n}: VirtualListProps<T>) {\n const parentRef = useRef<HTMLDivElement>(null)\n const itemHeightRef = useRef(itemHeight)\n const itemsRef = useRef(items)\n itemHeightRef.current = itemHeight\n itemsRef.current = items\n\n const virtualizer = useVirtualizer({\n count: items.length,\n getScrollElement: () => parentRef.current,\n estimateSize: (index) => {\n const h = typeof itemHeightRef.current === 'function'\n ? itemHeightRef.current(itemsRef.current[index], index)\n : itemHeightRef.current\n return h + gap\n },\n overscan,\n })\n\n const virtualItems = virtualizer.getVirtualItems()\n\n const handleScroll = (e: React.UIEvent<HTMLDivElement>) => {\n onScroll?.(e.currentTarget.scrollTop)\n }\n\n return (\n <div\n ref={parentRef}\n className={`overflow-auto ${className}`}\n style={{ height, width }}\n onScroll={handleScroll}\n >\n <div\n className={innerClassName}\n style={{\n height: virtualizer.getTotalSize(),\n width: '100%',\n position: 'relative',\n }}\n >\n {virtualItems.map((virtualItem) => (\n <div\n key={virtualItem.key}\n className={itemClassName}\n data-index={virtualItem.index}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: virtualItem.size - gap,\n transform: `translateY(${virtualItem.start}px)`,\n }}\n >\n {renderItem(items[virtualItem.index], virtualItem.index)}\n </div>\n ))}\n </div>\n </div>\n )\n}\n\nVirtualList.displayName = 'VirtualList'\n"],"names":["VirtualList","items","height","itemHeight","renderItem","overscan","className","innerClassName","itemClassName","width","gap","onScroll","parentRef","useRef","itemHeightRef","itemsRef","virtualizer","useVirtualizer","index","virtualItems","handleScroll","e","jsx","virtualItem"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"VirtualList.js","sources":["../../src/components/VirtualList.tsx"],"sourcesContent":["import React, { useRef } from 'react'\nimport { useVirtualizer } from '@tanstack/react-virtual'\n\nexport interface VirtualListProps<T> {\n /** Array of items to render */\n items: T[]\n /** Height of the scrollable container */\n height: number | string\n /** Height of each item, or function returning estimated height per item */\n itemHeight: number | ((item: T, index: number) => number)\n /** Render function for each item */\n renderItem: (item: T, index: number) => React.ReactNode\n /** Number of items to render outside visible area */\n overscan?: number\n /** Additional class for the scroll container */\n className?: string\n /** Additional class for the inner container */\n innerClassName?: string\n /** Additional class for each item wrapper */\n itemClassName?: string\n /** Width of the container */\n width?: number | string\n /** Gap between items */\n gap?: number\n /** Callback when scroll position changes */\n onScroll?: (scrollTop: number) => void\n 'data-testid'?: string\n}\n\nexport function VirtualList<T>({\n items,\n height,\n itemHeight,\n renderItem,\n overscan = 5,\n className = '',\n innerClassName = '',\n itemClassName = '',\n width,\n gap = 0,\n onScroll,\n 'data-testid': testId,\n}: VirtualListProps<T>) {\n const parentRef = useRef<HTMLDivElement>(null)\n const itemHeightRef = useRef(itemHeight)\n const itemsRef = useRef(items)\n itemHeightRef.current = itemHeight\n itemsRef.current = items\n\n const virtualizer = useVirtualizer({\n count: items.length,\n getScrollElement: () => parentRef.current,\n estimateSize: (index) => {\n const h = typeof itemHeightRef.current === 'function'\n ? itemHeightRef.current(itemsRef.current[index], index)\n : itemHeightRef.current\n return h + gap\n },\n overscan,\n })\n\n const virtualItems = virtualizer.getVirtualItems()\n\n const handleScroll = (e: React.UIEvent<HTMLDivElement>) => {\n onScroll?.(e.currentTarget.scrollTop)\n }\n\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n\n return (\n <div\n ref={parentRef}\n className={`overflow-auto ${className}`}\n style={{ height, width }}\n onScroll={handleScroll}\n data-testid={testId}\n >\n <div\n className={innerClassName}\n style={{\n height: virtualizer.getTotalSize(),\n width: '100%',\n position: 'relative',\n }}\n data-testid={getTestId('inner')}\n >\n {virtualItems.map((virtualItem) => (\n <div\n key={virtualItem.key}\n className={itemClassName}\n data-index={virtualItem.index}\n style={{\n position: 'absolute',\n top: 0,\n left: 0,\n width: '100%',\n height: virtualItem.size - gap,\n transform: `translateY(${virtualItem.start}px)`,\n }}\n data-testid={getTestId(`item-${virtualItem.index}`)}\n >\n {renderItem(items[virtualItem.index], virtualItem.index)}\n </div>\n ))}\n </div>\n </div>\n )\n}\n\nVirtualList.displayName = 'VirtualList'\n"],"names":["VirtualList","items","height","itemHeight","renderItem","overscan","className","innerClassName","itemClassName","width","gap","onScroll","testId","parentRef","useRef","itemHeightRef","itemsRef","virtualizer","useVirtualizer","index","virtualItems","handleScroll","e","getTestId","suffix","jsx","virtualItem"],"mappings":";;;AA6BO,SAASA,EAAe;AAAA,EAC7B,OAAAC;AAAA,EACA,QAAAC;AAAA,EACA,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,WAAAC,IAAY;AAAA,EACZ,gBAAAC,IAAiB;AAAA,EACjB,eAAAC,IAAgB;AAAA,EAChB,OAAAC;AAAA,EACA,KAAAC,IAAM;AAAA,EACN,UAAAC;AAAA,EACA,eAAeC;AACjB,GAAwB;AACtB,QAAMC,IAAYC,EAAuB,IAAI,GACvCC,IAAgBD,EAAOX,CAAU,GACjCa,IAAWF,EAAOb,CAAK;AAC7B,EAAAc,EAAc,UAAUZ,GACxBa,EAAS,UAAUf;AAEnB,QAAMgB,IAAcC,EAAe;AAAA,IACjC,OAAOjB,EAAM;AAAA,IACb,kBAAkB,MAAMY,EAAU;AAAA,IAClC,cAAc,CAACM,OACH,OAAOJ,EAAc,WAAY,aACvCA,EAAc,QAAQC,EAAS,QAAQG,CAAK,G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|
|
36
36
|
font?: WatermarkFontOptions;
|
|
37
37
|
/** Content to protect with the watermark */
|
|
38
38
|
children?: React.ReactNode;
|
|
39
|
+
'data-testid'?: string;
|
|
39
40
|
}
|
|
40
41
|
export declare const Watermark: React.FC<WatermarkProps>;
|
|
@@ -1,121 +1,124 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { useTheme as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
const n = Math.round(
|
|
1
|
+
import { jsxs as D, jsx as M } from "react/jsx-runtime";
|
|
2
|
+
import { useState as U, useMemo as F, useEffect as B } from "react";
|
|
3
|
+
import { useTheme as X } from "../hooks/useTheme.js";
|
|
4
|
+
const _ = "asterui", K = 0.22;
|
|
5
|
+
function q(r, c) {
|
|
6
|
+
const n = Math.round(c * 255).toString(16).padStart(2, "0");
|
|
7
7
|
return r + n;
|
|
8
8
|
}
|
|
9
|
-
const
|
|
9
|
+
const G = (r, c) => {
|
|
10
10
|
const n = r?.fontSize ?? 16;
|
|
11
11
|
return {
|
|
12
|
-
color:
|
|
12
|
+
color: c,
|
|
13
13
|
fontSize: n,
|
|
14
14
|
fontWeight: r?.fontWeight ?? 600,
|
|
15
15
|
fontStyle: r?.fontStyle ?? "normal",
|
|
16
16
|
fontFamily: r?.fontFamily ?? "sans-serif",
|
|
17
17
|
lineHeight: r?.lineHeight ?? n * 1.2
|
|
18
18
|
};
|
|
19
|
-
},
|
|
19
|
+
}, J = ({
|
|
20
20
|
children: r,
|
|
21
|
-
className:
|
|
21
|
+
className: c = "",
|
|
22
22
|
style: n,
|
|
23
|
-
content:
|
|
24
|
-
image:
|
|
25
|
-
width:
|
|
23
|
+
content: d,
|
|
24
|
+
image: x,
|
|
25
|
+
width: s = 120,
|
|
26
26
|
height: i = 64,
|
|
27
|
-
gap:
|
|
27
|
+
gap: $,
|
|
28
28
|
offset: k,
|
|
29
|
-
rotate:
|
|
30
|
-
zIndex:
|
|
29
|
+
rotate: b = -22,
|
|
30
|
+
zIndex: H = 1e3,
|
|
31
31
|
font: y,
|
|
32
|
-
|
|
32
|
+
"data-testid": h,
|
|
33
|
+
...I
|
|
33
34
|
}) => {
|
|
34
|
-
const [
|
|
35
|
-
() => typeof
|
|
36
|
-
[
|
|
37
|
-
),
|
|
38
|
-
() =>
|
|
39
|
-
[y,
|
|
40
|
-
),
|
|
41
|
-
|
|
35
|
+
const [u, L] = U(null), f = $?.[0] ?? 120, m = $?.[1] ?? 120, N = k?.[0] ?? f / 2, P = k?.[1] ?? m / 2, { colors: j } = X(), S = F(
|
|
36
|
+
() => typeof d == "string" ? [d] : Array.isArray(d) ? d : [_],
|
|
37
|
+
[d]
|
|
38
|
+
), T = y?.color ?? q(j.foreground, K), a = F(
|
|
39
|
+
() => G(y, T),
|
|
40
|
+
[y, T]
|
|
41
|
+
), E = Math.PI / 180 * b, z = S.join("|");
|
|
42
|
+
B(() => {
|
|
42
43
|
if (typeof window > "u") return;
|
|
43
|
-
let
|
|
44
|
-
const o = window.devicePixelRatio || 1,
|
|
45
|
-
g.width =
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}),
|
|
44
|
+
let l = !1;
|
|
45
|
+
const o = window.devicePixelRatio || 1, W = s + f, w = i + m, g = document.createElement("canvas");
|
|
46
|
+
g.width = W * o, g.height = w * o;
|
|
47
|
+
const t = g.getContext("2d");
|
|
48
|
+
if (!t) return;
|
|
49
|
+
const A = () => {
|
|
50
|
+
const e = g.toDataURL();
|
|
51
|
+
l || L({ url: e, width: W, height: w });
|
|
52
|
+
}, R = () => {
|
|
53
|
+
t.save(), t.translate((f / 2 + s / 2) * o, (m / 2 + i / 2) * o), t.rotate(E), t.fillStyle = a.color, t.textAlign = "center", t.textBaseline = "middle", t.font = `${a.fontStyle} normal ${a.fontWeight} ${a.fontSize * o}px ${a.fontFamily}`;
|
|
54
|
+
const e = a.lineHeight * o, p = -((S.length - 1) * e) / 2;
|
|
55
|
+
S.forEach((v, Y) => {
|
|
56
|
+
t.fillText(v, 0, p + Y * e);
|
|
57
|
+
}), t.restore();
|
|
57
58
|
};
|
|
58
|
-
if (
|
|
59
|
-
const
|
|
60
|
-
|
|
59
|
+
if (x) {
|
|
60
|
+
const e = new Image();
|
|
61
|
+
e.crossOrigin = "anonymous", e.referrerPolicy = "no-referrer";
|
|
61
62
|
const p = () => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
-
|
|
63
|
+
t.save(), t.translate((f / 2 + s / 2) * o, (m / 2 + i / 2) * o), t.rotate(E), t.drawImage(
|
|
64
|
+
e,
|
|
65
|
+
-s / 2 * o,
|
|
65
66
|
-i / 2 * o,
|
|
66
|
-
|
|
67
|
+
s * o,
|
|
67
68
|
i * o
|
|
68
|
-
),
|
|
69
|
-
},
|
|
70
|
-
|
|
69
|
+
), t.restore(), A();
|
|
70
|
+
}, v = () => {
|
|
71
|
+
l || L(null);
|
|
71
72
|
};
|
|
72
|
-
return
|
|
73
|
-
|
|
73
|
+
return e.addEventListener("load", p), e.addEventListener("error", v), e.src = x, () => {
|
|
74
|
+
l = !0, e.removeEventListener("load", p), e.removeEventListener("error", v);
|
|
74
75
|
};
|
|
75
76
|
} else
|
|
76
|
-
|
|
77
|
+
R(), A();
|
|
77
78
|
return () => {
|
|
78
|
-
|
|
79
|
+
l = !0;
|
|
79
80
|
};
|
|
80
81
|
}, [
|
|
81
|
-
|
|
82
|
-
d,
|
|
82
|
+
a,
|
|
83
83
|
f,
|
|
84
|
+
m,
|
|
84
85
|
i,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
x,
|
|
87
|
+
E,
|
|
88
|
+
z,
|
|
89
|
+
s
|
|
89
90
|
]);
|
|
90
|
-
const
|
|
91
|
-
return /* @__PURE__ */
|
|
91
|
+
const C = ["relative", c].filter(Boolean).join(" "), O = (l) => h ? `${h}-${l}` : void 0;
|
|
92
|
+
return /* @__PURE__ */ D(
|
|
92
93
|
"div",
|
|
93
94
|
{
|
|
94
|
-
className:
|
|
95
|
+
className: C,
|
|
95
96
|
style: { position: n?.position ?? "relative", ...n },
|
|
96
|
-
|
|
97
|
+
"data-testid": h,
|
|
98
|
+
...I,
|
|
97
99
|
children: [
|
|
98
100
|
r,
|
|
99
|
-
|
|
101
|
+
u && /* @__PURE__ */ M(
|
|
100
102
|
"div",
|
|
101
103
|
{
|
|
102
104
|
"aria-hidden": !0,
|
|
103
105
|
className: "pointer-events-none absolute inset-0",
|
|
104
106
|
style: {
|
|
105
|
-
zIndex:
|
|
106
|
-
backgroundImage: `url(${
|
|
107
|
+
zIndex: H,
|
|
108
|
+
backgroundImage: `url(${u.url})`,
|
|
107
109
|
backgroundRepeat: "repeat",
|
|
108
|
-
backgroundSize: `${
|
|
109
|
-
backgroundPosition: `${
|
|
110
|
-
}
|
|
110
|
+
backgroundSize: `${u.width}px ${u.height}px`,
|
|
111
|
+
backgroundPosition: `${N}px ${P}px`
|
|
112
|
+
},
|
|
113
|
+
"data-testid": O("overlay")
|
|
111
114
|
}
|
|
112
115
|
)
|
|
113
116
|
]
|
|
114
117
|
}
|
|
115
118
|
);
|
|
116
119
|
};
|
|
117
|
-
|
|
120
|
+
J.displayName = "Watermark";
|
|
118
121
|
export {
|
|
119
|
-
|
|
122
|
+
J as Watermark
|
|
120
123
|
};
|
|
121
124
|
//# sourceMappingURL=Watermark.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Watermark.js","sources":["../../src/components/Watermark.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react'\nimport { useTheme } from '../hooks/useTheme'\n\nexport type WatermarkGap = [number, number]\nexport type WatermarkOffset = [number, number]\n\nexport interface WatermarkFontOptions {\n /** Text color for watermark content */\n color?: string\n /** Font size in pixels */\n fontSize?: number\n /** Font weight for watermark text */\n fontWeight?: number | 'normal' | 'bold' | 'bolder' | 'lighter'\n /** Font style for watermark text */\n fontStyle?: 'normal' | 'italic' | 'oblique'\n /** Font family for watermark text */\n fontFamily?: string\n /** Line height in pixels for multi-line content */\n lineHeight?: number\n}\n\nexport interface WatermarkProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'content'> {\n /** Text to render inside the watermark; falls back to \"asterui\" */\n content?: string | string[]\n /** Image source (URL or base64) to render instead of text */\n image?: string\n /** Width of a single watermark tile in pixels */\n width?: number\n /** Height of a single watermark tile in pixels */\n height?: number\n /** Horizontal/vertical gap between watermarks in pixels */\n gap?: WatermarkGap\n /** Offset for the first watermark tile from the top-left corner */\n offset?: WatermarkOffset\n /** Rotation angle in degrees */\n rotate?: number\n /** z-index for the overlay layer */\n zIndex?: number\n /** Font settings for text watermarks */\n font?: WatermarkFontOptions\n /** Content to protect with the watermark */\n children?: React.ReactNode\n}\n\ntype WatermarkImage = {\n url: string\n width: number\n height: number\n}\n\nconst DEFAULT_CONTENT = 'asterui'\nconst DEFAULT_OPACITY = 0.22\n\n// Add opacity to a hex color (returns #rrggbbaa format)\nfunction hexWithOpacity(hex: string, opacity: number): string {\n const alpha = Math.round(opacity * 255).toString(16).padStart(2, '0')\n return hex + alpha\n}\n\nconst getFontSettings = (font: WatermarkFontOptions | undefined, resolvedColor: string) => {\n const fontSize = font?.fontSize ?? 16\n\n return {\n color: resolvedColor,\n fontSize,\n fontWeight: font?.fontWeight ?? 600,\n fontStyle: font?.fontStyle ?? 'normal',\n fontFamily: font?.fontFamily ?? 'sans-serif',\n lineHeight: font?.lineHeight ?? fontSize * 1.2,\n }\n}\n\nexport const Watermark: React.FC<WatermarkProps> = ({\n children,\n className = '',\n style,\n content,\n image,\n width = 120,\n height = 64,\n gap,\n offset,\n rotate = -22,\n zIndex = 1000,\n font,\n ...rest\n}) => {\n const [watermark, setWatermark] = useState<WatermarkImage | null>(null)\n\n const gapX = gap?.[0] ?? 120\n const gapY = gap?.[1] ?? 120\n const offsetX = offset?.[0] ?? gapX / 2\n const offsetY = offset?.[1] ?? gapY / 2\n const { colors } = useTheme()\n const textLines = useMemo(\n () =>\n typeof content === 'string'\n ? [content]\n : Array.isArray(content)\n ? content\n : [DEFAULT_CONTENT],\n [content]\n )\n // Use provided color or theme foreground with opacity\n const resolvedColor = font?.color ?? hexWithOpacity(colors.foreground, DEFAULT_OPACITY)\n const fontSettings = useMemo(\n () => getFontSettings(font, resolvedColor),\n [font, resolvedColor]\n )\n const rotationInRadians = (Math.PI / 180) * rotate\n const textKey = textLines.join('|')\n\n useEffect(() => {\n if (typeof window === 'undefined') return\n\n let cancelled = false\n const ratio = window.devicePixelRatio || 1\n const tileWidth = width + gapX\n const tileHeight = height + gapY\n const canvas = document.createElement('canvas')\n canvas.width = tileWidth * ratio\n canvas.height = tileHeight * ratio\n const ctx = canvas.getContext('2d')\n\n if (!ctx) return\n\n const commitWatermark = () => {\n const url = canvas.toDataURL()\n if (!cancelled) {\n setWatermark({ url, width: tileWidth, height: tileHeight })\n }\n }\n\n const drawText = () => {\n ctx.save()\n ctx.translate((gapX / 2 + width / 2) * ratio, (gapY / 2 + height / 2) * ratio)\n ctx.rotate(rotationInRadians)\n ctx.fillStyle = fontSettings.color\n ctx.textAlign = 'center'\n ctx.textBaseline = 'middle'\n ctx.font = `${fontSettings.fontStyle} normal ${fontSettings.fontWeight} ${fontSettings.fontSize * ratio}px ${fontSettings.fontFamily}`\n\n const lineHeight = fontSettings.lineHeight * ratio\n const startY = -((textLines.length - 1) * lineHeight) / 2\n\n textLines.forEach((line, index) => {\n ctx.fillText(line, 0, startY + index * lineHeight)\n })\n\n ctx.restore()\n }\n\n if (image) {\n const img = new Image()\n img.crossOrigin = 'anonymous'\n img.referrerPolicy = 'no-referrer'\n\n const handleLoad = () => {\n ctx.save()\n ctx.translate((gapX / 2 + width / 2) * ratio, (gapY / 2 + height / 2) * ratio)\n ctx.rotate(rotationInRadians)\n ctx.drawImage(\n img,\n (-width / 2) * ratio,\n (-height / 2) * ratio,\n width * ratio,\n height * ratio\n )\n ctx.restore()\n commitWatermark()\n }\n\n const handleError = () => {\n if (!cancelled) setWatermark(null)\n }\n\n img.addEventListener('load', handleLoad)\n img.addEventListener('error', handleError)\n img.src = image\n\n return () => {\n cancelled = true\n img.removeEventListener('load', handleLoad)\n img.removeEventListener('error', handleError)\n }\n } else {\n drawText()\n commitWatermark()\n }\n\n return () => {\n cancelled = true\n }\n }, [\n fontSettings,\n gapX,\n gapY,\n height,\n image,\n rotationInRadians,\n textKey,\n width,\n ])\n\n const classes = ['relative', className].filter(Boolean).join(' ')\n\n return (\n <div\n className={classes}\n style={{ position: style?.position ?? 'relative', ...style }}\n {...rest}\n >\n {children}\n {watermark && (\n <div\n aria-hidden\n className=\"pointer-events-none absolute inset-0\"\n style={{\n zIndex,\n backgroundImage: `url(${watermark.url})`,\n backgroundRepeat: 'repeat',\n backgroundSize: `${watermark.width}px ${watermark.height}px`,\n backgroundPosition: `${offsetX}px ${offsetY}px`,\n }}\n />\n )}\n </div>\n )\n}\n\nWatermark.displayName = 'Watermark'\n"],"names":["DEFAULT_CONTENT","DEFAULT_OPACITY","hexWithOpacity","hex","opacity","alpha","getFontSettings","font","resolvedColor","fontSize","Watermark","children","className","style","content","image","width","height","gap","offset","rotate","zIndex","rest","watermark","setWatermark","useState","gapX","gapY","offsetX","offsetY","colors","useTheme","textLines","useMemo","fontSettings","rotationInRadians","textKey","useEffect","cancelled","ratio","tileWidth","tileHeight","canvas","ctx","commitWatermark","url","drawText","lineHeight","startY","line","index","img","handleLoad","handleError","classes","jsxs","jsx"],"mappings":";;;AAmDA,MAAMA,IAAkB,WAClBC,IAAkB;AAGxB,SAASC,EAAeC,GAAaC,GAAyB;AAC5D,QAAMC,IAAQ,KAAK,MAAMD,IAAU,GAAG,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AACpE,SAAOD,IAAME;AACf;AAEA,MAAMC,IAAkB,CAACC,GAAwCC,MAA0B;A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A,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAIR;AAEAnB,EAAU,cAAc;"}
|
|
1
|
+
{"version":3,"file":"Watermark.js","sources":["../../src/components/Watermark.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useState } from 'react'\nimport { useTheme } from '../hooks/useTheme'\n\nexport type WatermarkGap = [number, number]\nexport type WatermarkOffset = [number, number]\n\nexport interface WatermarkFontOptions {\n /** Text color for watermark content */\n color?: string\n /** Font size in pixels */\n fontSize?: number\n /** Font weight for watermark text */\n fontWeight?: number | 'normal' | 'bold' | 'bolder' | 'lighter'\n /** Font style for watermark text */\n fontStyle?: 'normal' | 'italic' | 'oblique'\n /** Font family for watermark text */\n fontFamily?: string\n /** Line height in pixels for multi-line content */\n lineHeight?: number\n}\n\nexport interface WatermarkProps\n extends Omit<React.HTMLAttributes<HTMLDivElement>, 'content'> {\n /** Text to render inside the watermark; falls back to \"asterui\" */\n content?: string | string[]\n /** Image source (URL or base64) to render instead of text */\n image?: string\n /** Width of a single watermark tile in pixels */\n width?: number\n /** Height of a single watermark tile in pixels */\n height?: number\n /** Horizontal/vertical gap between watermarks in pixels */\n gap?: WatermarkGap\n /** Offset for the first watermark tile from the top-left corner */\n offset?: WatermarkOffset\n /** Rotation angle in degrees */\n rotate?: number\n /** z-index for the overlay layer */\n zIndex?: number\n /** Font settings for text watermarks */\n font?: WatermarkFontOptions\n /** Content to protect with the watermark */\n children?: React.ReactNode\n 'data-testid'?: string\n}\n\ntype WatermarkImage = {\n url: string\n width: number\n height: number\n}\n\nconst DEFAULT_CONTENT = 'asterui'\nconst DEFAULT_OPACITY = 0.22\n\n// Add opacity to a hex color (returns #rrggbbaa format)\nfunction hexWithOpacity(hex: string, opacity: number): string {\n const alpha = Math.round(opacity * 255).toString(16).padStart(2, '0')\n return hex + alpha\n}\n\nconst getFontSettings = (font: WatermarkFontOptions | undefined, resolvedColor: string) => {\n const fontSize = font?.fontSize ?? 16\n\n return {\n color: resolvedColor,\n fontSize,\n fontWeight: font?.fontWeight ?? 600,\n fontStyle: font?.fontStyle ?? 'normal',\n fontFamily: font?.fontFamily ?? 'sans-serif',\n lineHeight: font?.lineHeight ?? fontSize * 1.2,\n }\n}\n\nexport const Watermark: React.FC<WatermarkProps> = ({\n children,\n className = '',\n style,\n content,\n image,\n width = 120,\n height = 64,\n gap,\n offset,\n rotate = -22,\n zIndex = 1000,\n font,\n 'data-testid': testId,\n ...rest\n}) => {\n const [watermark, setWatermark] = useState<WatermarkImage | null>(null)\n\n const gapX = gap?.[0] ?? 120\n const gapY = gap?.[1] ?? 120\n const offsetX = offset?.[0] ?? gapX / 2\n const offsetY = offset?.[1] ?? gapY / 2\n const { colors } = useTheme()\n const textLines = useMemo(\n () =>\n typeof content === 'string'\n ? [content]\n : Array.isArray(content)\n ? content\n : [DEFAULT_CONTENT],\n [content]\n )\n // Use provided color or theme foreground with opacity\n const resolvedColor = font?.color ?? hexWithOpacity(colors.foreground, DEFAULT_OPACITY)\n const fontSettings = useMemo(\n () => getFontSettings(font, resolvedColor),\n [font, resolvedColor]\n )\n const rotationInRadians = (Math.PI / 180) * rotate\n const textKey = textLines.join('|')\n\n useEffect(() => {\n if (typeof window === 'undefined') return\n\n let cancelled = false\n const ratio = window.devicePixelRatio || 1\n const tileWidth = width + gapX\n const tileHeight = height + gapY\n const canvas = document.createElement('canvas')\n canvas.width = tileWidth * ratio\n canvas.height = tileHeight * ratio\n const ctx = canvas.getContext('2d')\n\n if (!ctx) return\n\n const commitWatermark = () => {\n const url = canvas.toDataURL()\n if (!cancelled) {\n setWatermark({ url, width: tileWidth, height: tileHeight })\n }\n }\n\n const drawText = () => {\n ctx.save()\n ctx.translate((gapX / 2 + width / 2) * ratio, (gapY / 2 + height / 2) * ratio)\n ctx.rotate(rotationInRadians)\n ctx.fillStyle = fontSettings.color\n ctx.textAlign = 'center'\n ctx.textBaseline = 'middle'\n ctx.font = `${fontSettings.fontStyle} normal ${fontSettings.fontWeight} ${fontSettings.fontSize * ratio}px ${fontSettings.fontFamily}`\n\n const lineHeight = fontSettings.lineHeight * ratio\n const startY = -((textLines.length - 1) * lineHeight) / 2\n\n textLines.forEach((line, index) => {\n ctx.fillText(line, 0, startY + index * lineHeight)\n })\n\n ctx.restore()\n }\n\n if (image) {\n const img = new Image()\n img.crossOrigin = 'anonymous'\n img.referrerPolicy = 'no-referrer'\n\n const handleLoad = () => {\n ctx.save()\n ctx.translate((gapX / 2 + width / 2) * ratio, (gapY / 2 + height / 2) * ratio)\n ctx.rotate(rotationInRadians)\n ctx.drawImage(\n img,\n (-width / 2) * ratio,\n (-height / 2) * ratio,\n width * ratio,\n height * ratio\n )\n ctx.restore()\n commitWatermark()\n }\n\n const handleError = () => {\n if (!cancelled) setWatermark(null)\n }\n\n img.addEventListener('load', handleLoad)\n img.addEventListener('error', handleError)\n img.src = image\n\n return () => {\n cancelled = true\n img.removeEventListener('load', handleLoad)\n img.removeEventListener('error', handleError)\n }\n } else {\n drawText()\n commitWatermark()\n }\n\n return () => {\n cancelled = true\n }\n }, [\n fontSettings,\n gapX,\n gapY,\n height,\n image,\n rotationInRadians,\n textKey,\n width,\n ])\n\n const classes = ['relative', className].filter(Boolean).join(' ')\n\n const getTestId = (suffix: string) => (testId ? `${testId}-${suffix}` : undefined)\n\n return (\n <div\n className={classes}\n style={{ position: style?.position ?? 'relative', ...style }}\n data-testid={testId}\n {...rest}\n >\n {children}\n {watermark && (\n <div\n aria-hidden\n className=\"pointer-events-none absolute inset-0\"\n style={{\n zIndex,\n backgroundImage: `url(${watermark.url})`,\n backgroundRepeat: 'repeat',\n backgroundSize: `${watermark.width}px ${watermark.height}px`,\n backgroundPosition: `${offsetX}px ${offsetY}px`,\n }}\n data-testid={getTestId('overlay')}\n />\n )}\n </div>\n )\n}\n\nWatermark.displayName = 'Watermark'\n"],"names":["DEFAULT_CONTENT","DEFAULT_OPACITY","hexWithOpacity","hex","opacity","alpha","getFontSettings","font","resolvedColor","fontSize","Watermark","children","className","style","content","image","width","height","gap","offset","rotate","zIndex","testId","rest","watermark","setWatermark","useState","gapX","gapY","offsetX","offsetY","colors","useTheme","textLines","useMemo","fontSettings","rotationInRadians","textKey","useEffect","cancelled","ratio","tileWidth","tileHeight","canvas","ctx","commitWatermark","url","drawText","lineHeight","startY","line","index","img","handleLoad","handleError","classes","getTestId","suffix","jsxs","jsx"],"mappings":";;;AAoDA,MAAMA,IAAkB,WAClBC,IAAkB;AAGxB,SAASC,EAAeC,GAAaC,GAAyB;AAC5D,QAAMC,IAAQ,KAAK,MAAMD,IAAU,GAAG,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AACpE,SAAOD,IAAME;AACf;AAEA,MAAMC,IAAkB,CAACC,GAAwCC,MAA0B;AACzF,QAAMC,IAAWF,GAAM,YAAY;AAEnC,SAAO;AAAA,IACL,OAAOC;AAAA,IACP,UAAAC;AAAA,IACA,YAAYF,GAAM,cAAc;AAAA,IAChC,WAAWA,GAAM,aAAa;AAAA,IAC9B,YAAYA,GAAM,cAAc;AAAA,IAChC,YAAYA,GAAM,cAAcE,IAAW;AAAA,EAAA;AAE/C,GAEaC,IAAsC,CAAC;AAAA,EAClD,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,OAAAC;AAAA,EACA,SAAAC;AAAA,EACA,OAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,QAAAC,IAAS;AAAA,EACT,KAAAC;AAAA,EACA,QAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,QAAAC,IAAS;AAAA,EACT,MAAAd;AAAA,EACA,eAAee;AAAA,EACf,GAAGC;AACL,MAAM;AACJ,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAAgC,IAAI,GAEhEC,IAAOT,IAAM,CAAC,KAAK,KACnBU,IAAOV,IAAM,CAAC,KAAK,KACnBW,IAAUV,IAAS,CAAC,KAAKQ,IAAO,GAChCG,IAAUX,IAAS,CAAC,KAAKS,IAAO,GAChC,EAAE,QAAAG,EAAA,IAAWC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,MAAoBnC,IAAS,GAAGA,CAAM,IAAImC,CAAM,KAAK;AAExE,SACE,gBAAAC;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWH;AAAA,MACX,OAAO,EAAE,UAAU1C,GAAO,YAAY,YAAY,GAAGA,EAAA;AAAA,MACrD,eAAaS;AAAA,MACZ,GAAGC;AAAA,MAEH,UAAA;AAAA,QAAAZ;AAAA,QACAa,KACC,gBAAAmC;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,eAAW;AAAA,YACX,WAAU;AAAA,YACV,OAAO;AAAA,cACL,QAAAtC;AAAA,cACA,iBAAiB,OAAOG,EAAU,GAAG;AAAA,cACrC,kBAAkB;AAAA,cAClB,gBAAgB,GAAGA,EAAU,KAAK,MAAMA,EAAU,MAAM;AAAA,cACxD,oBAAoB,GAAGK,CAAO,MAAMC,CAAO;AAAA,YAAA;AAAA,YAE7C,eAAa0B,EAAU,SAAS;AAAA,UAAA;AAAA,QAAA;AAAA,MAClC;AAAA,IAAA;AAAA,EAAA;AAIR;AAEA9C,EAAU,cAAc;"}
|
|
@@ -29,6 +29,7 @@ export interface WeekCalendarProps<T extends CalendarEvent = CalendarEvent> exte
|
|
|
29
29
|
startHour?: number;
|
|
30
30
|
/** End hour for the time grid (0-23) */
|
|
31
31
|
endHour?: number;
|
|
32
|
+
'data-testid'?: string;
|
|
32
33
|
}
|
|
33
34
|
export declare const WeekCalendar: <T extends CalendarEvent = CalendarEvent>(props: WeekCalendarProps<T> & {
|
|
34
35
|
ref?: React.ForwardedRef<HTMLDivElement>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
const
|
|
1
|
+
import { jsxs as m, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as C, useRef as k, useEffect as F, useMemo as _ } from "react";
|
|
3
|
+
const J = {
|
|
4
4
|
locale: "en",
|
|
5
5
|
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
6
6
|
monthsLong: [
|
|
@@ -22,91 +22,95 @@ const F = {
|
|
|
22
22
|
const t = s.getHours();
|
|
23
23
|
return `${t === 0 ? 12 : t > 12 ? t - 12 : t}:00 ${t < 12 ? "AM" : "PM"}`.replace(" ", "").toLowerCase().replace(":00", "");
|
|
24
24
|
}
|
|
25
|
-
},
|
|
26
|
-
const n = new Date(s),
|
|
27
|
-
return n.setHours(0, 0, 0, 0),
|
|
28
|
-
},
|
|
25
|
+
}, N = (s) => O(s, /* @__PURE__ */ new Date()), O = (s, t) => {
|
|
26
|
+
const n = new Date(s), i = new Date(t);
|
|
27
|
+
return n.setHours(0, 0, 0, 0), i.setHours(0, 0, 0, 0), i.getTime() === n.getTime();
|
|
28
|
+
}, T = (s) => {
|
|
29
29
|
const t = /* @__PURE__ */ new Date(), n = new Date(s);
|
|
30
30
|
return t.setHours(0, 0, 0, 0), n.setHours(0, 0, 0, 0), n < t;
|
|
31
|
-
},
|
|
32
|
-
const t = new Date(s), n = t.getDay(),
|
|
33
|
-
return new Date(t.setDate(
|
|
34
|
-
},
|
|
31
|
+
}, P = (s) => {
|
|
32
|
+
const t = new Date(s), n = t.getDay(), i = t.getDate() - n;
|
|
33
|
+
return new Date(t.setDate(i));
|
|
34
|
+
}, z = (s, t) => {
|
|
35
35
|
const n = new Date(s);
|
|
36
36
|
return n.setDate(n.getDate() + t), n;
|
|
37
|
-
},
|
|
38
|
-
const n = s.getDate(),
|
|
39
|
-
return t === "YYYY-MM-DD" ? s.toISOString().split("T")[0] : t === "ddd" ?
|
|
40
|
-
},
|
|
37
|
+
}, f = (s, t) => {
|
|
38
|
+
const n = s.getDate(), i = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][s.getDay()];
|
|
39
|
+
return t === "YYYY-MM-DD" ? s.toISOString().split("T")[0] : t === "ddd" ? i : t === "D" ? n.toString() : s.toISOString();
|
|
40
|
+
}, q = C(
|
|
41
41
|
({
|
|
42
42
|
date: s = /* @__PURE__ */ new Date(),
|
|
43
43
|
events: t = [],
|
|
44
|
-
locale: n =
|
|
45
|
-
onEventClick:
|
|
46
|
-
onDayClick:
|
|
47
|
-
onSelectSlot:
|
|
48
|
-
allowPastInteraction:
|
|
49
|
-
fitContainer:
|
|
50
|
-
startHour:
|
|
51
|
-
endHour:
|
|
52
|
-
className:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
44
|
+
locale: n = J,
|
|
45
|
+
onEventClick: i,
|
|
46
|
+
onDayClick: Y,
|
|
47
|
+
onSelectSlot: w,
|
|
48
|
+
allowPastInteraction: b = !1,
|
|
49
|
+
fitContainer: p = !1,
|
|
50
|
+
startHour: v = 9,
|
|
51
|
+
endHour: S = 17,
|
|
52
|
+
className: E = "",
|
|
53
|
+
"data-testid": D,
|
|
54
|
+
...H
|
|
55
|
+
}, W) => {
|
|
56
|
+
const x = k(null), y = k(null);
|
|
57
|
+
F(() => {
|
|
57
58
|
const e = () => {
|
|
58
|
-
if (
|
|
59
|
-
const r =
|
|
60
|
-
o.style.paddingRight = `${
|
|
59
|
+
if (x.current && y.current) {
|
|
60
|
+
const r = x.current, o = y.current, c = r.offsetWidth - r.clientWidth;
|
|
61
|
+
o.style.paddingRight = `${c}px`;
|
|
61
62
|
}
|
|
62
63
|
};
|
|
63
64
|
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
64
65
|
}, []);
|
|
65
|
-
const
|
|
66
|
+
const A = P(s), $ = Array.from({ length: 7 }, (e, r) => z(A, r)), l = (e) => D ? `${D}-${e}` : void 0, j = _(() => {
|
|
66
67
|
const e = {};
|
|
67
68
|
return t.forEach((r) => {
|
|
68
|
-
const o =
|
|
69
|
+
const o = f(r.date, "YYYY-MM-DD");
|
|
69
70
|
e[o] || (e[o] = []), e[o].push(r);
|
|
70
71
|
}), e;
|
|
71
|
-
}, [t]),
|
|
72
|
-
return /* @__PURE__ */
|
|
72
|
+
}, [t]), M = Array.from({ length: S - v + 1 }, (e, r) => r + v), L = (e) => n.formatTime ? n.formatTime(new Date(2e3, 0, 1, e, 0)) : `${e === 0 ? 12 : e > 12 ? e - 12 : e}:00 ${e < 12 ? "AM" : "PM"}`, R = (e, r) => (j[e] || []).filter((c) => c.date.getHours() === r);
|
|
73
|
+
return /* @__PURE__ */ m(
|
|
73
74
|
"div",
|
|
74
75
|
{
|
|
75
|
-
ref:
|
|
76
|
-
className: `flex h-full flex-col overflow-hidden border-b border-base-200 bg-base-100 ${
|
|
77
|
-
|
|
76
|
+
ref: W,
|
|
77
|
+
className: `flex h-full flex-col overflow-hidden border-b border-base-200 bg-base-100 ${E}`,
|
|
78
|
+
"data-testid": D,
|
|
79
|
+
...H,
|
|
78
80
|
children: [
|
|
79
|
-
/* @__PURE__ */
|
|
81
|
+
/* @__PURE__ */ m(
|
|
80
82
|
"div",
|
|
81
83
|
{
|
|
82
|
-
ref:
|
|
84
|
+
ref: y,
|
|
83
85
|
className: "grid grid-cols-[80px_repeat(7,1fr)] border-b border-base-200 bg-base-100",
|
|
86
|
+
"data-testid": l("header"),
|
|
84
87
|
children: [
|
|
85
|
-
/* @__PURE__ */
|
|
86
|
-
|
|
87
|
-
const r =
|
|
88
|
-
return /* @__PURE__ */
|
|
88
|
+
/* @__PURE__ */ d("div", { className: "week-calendar-time-column" }),
|
|
89
|
+
$.map((e) => {
|
|
90
|
+
const r = T(e), o = N(e), c = f(e, "YYYY-MM-DD");
|
|
91
|
+
return /* @__PURE__ */ m(
|
|
89
92
|
"div",
|
|
90
93
|
{
|
|
91
94
|
className: `
|
|
92
95
|
cursor-pointer px-2 py-0.5 text-center transition-colors hover:bg-primary/5
|
|
93
|
-
${r && !
|
|
96
|
+
${r && !b ? "cursor-not-allowed" : ""}
|
|
94
97
|
`,
|
|
98
|
+
"data-testid": l(`header-day-${c}`),
|
|
95
99
|
onClick: () => {
|
|
96
|
-
r && !
|
|
100
|
+
r && !b || Y?.(e);
|
|
97
101
|
},
|
|
98
102
|
children: [
|
|
99
|
-
/* @__PURE__ */
|
|
103
|
+
/* @__PURE__ */ d(
|
|
100
104
|
"div",
|
|
101
105
|
{
|
|
102
106
|
className: `
|
|
103
107
|
text-xs font-medium uppercase
|
|
104
108
|
${r ? "text-base-content/40" : "text-base-content/60"}
|
|
105
109
|
`,
|
|
106
|
-
children:
|
|
110
|
+
children: f(e, "ddd")
|
|
107
111
|
}
|
|
108
112
|
),
|
|
109
|
-
/* @__PURE__ */
|
|
113
|
+
/* @__PURE__ */ d(
|
|
110
114
|
"div",
|
|
111
115
|
{
|
|
112
116
|
className: `
|
|
@@ -114,49 +118,59 @@ const F = {
|
|
|
114
118
|
${o ? "font-bold text-primary" : ""}
|
|
115
119
|
${r && !o ? "text-base-content/40" : "text-base-content"}
|
|
116
120
|
`,
|
|
117
|
-
children:
|
|
121
|
+
children: f(e, "D")
|
|
118
122
|
}
|
|
119
123
|
)
|
|
120
124
|
]
|
|
121
125
|
},
|
|
122
|
-
|
|
126
|
+
c
|
|
123
127
|
);
|
|
124
128
|
})
|
|
125
129
|
]
|
|
126
130
|
}
|
|
127
131
|
),
|
|
128
|
-
/* @__PURE__ */
|
|
132
|
+
/* @__PURE__ */ d(
|
|
129
133
|
"div",
|
|
130
134
|
{
|
|
131
|
-
ref:
|
|
132
|
-
className:
|
|
133
|
-
style:
|
|
134
|
-
|
|
135
|
+
ref: x,
|
|
136
|
+
className: p ? "grid flex-1" : "flex-1 overflow-y-auto",
|
|
137
|
+
style: p ? { gridTemplateRows: `repeat(${M.length}, 1fr)` } : void 0,
|
|
138
|
+
"data-testid": l("grid"),
|
|
139
|
+
children: M.map((e) => /* @__PURE__ */ m(
|
|
135
140
|
"div",
|
|
136
141
|
{
|
|
137
|
-
className: `grid grid-cols-[80px_repeat(7,1fr)] border-b border-base-200 last:border-b-0 ${
|
|
142
|
+
className: `grid grid-cols-[80px_repeat(7,1fr)] border-b border-base-200 last:border-b-0 ${p ? "min-h-10" : "h-20"}`,
|
|
143
|
+
"data-testid": l(`row-${e}`),
|
|
138
144
|
children: [
|
|
139
|
-
/* @__PURE__ */
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
145
|
+
/* @__PURE__ */ d(
|
|
146
|
+
"div",
|
|
147
|
+
{
|
|
148
|
+
className: "flex items-start justify-end border-l border-r border-base-200 bg-base-200/50 p-2 pt-1 text-xs text-base-content/50",
|
|
149
|
+
"data-testid": l(`time-${e}`),
|
|
150
|
+
children: L(e)
|
|
151
|
+
}
|
|
152
|
+
),
|
|
153
|
+
$.map((r) => {
|
|
154
|
+
const o = f(r, "YYYY-MM-DD"), c = R(o, e), h = T(r) && !N(r);
|
|
155
|
+
return /* @__PURE__ */ d(
|
|
143
156
|
"div",
|
|
144
157
|
{
|
|
145
158
|
className: `
|
|
146
159
|
relative flex cursor-pointer flex-col justify-start overflow-y-auto border-r border-base-200 p-1 last:border-r-0
|
|
147
160
|
hover:bg-primary/5
|
|
148
|
-
${
|
|
149
|
-
${h && !
|
|
161
|
+
${p ? "" : "h-20"}
|
|
162
|
+
${h && !b ? "cursor-not-allowed hover:cursor-not-allowed" : ""}
|
|
150
163
|
`,
|
|
164
|
+
"data-testid": l(`cell-${o}-${e}`),
|
|
151
165
|
onClick: (a) => {
|
|
152
|
-
if (!(h && !
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
const
|
|
156
|
-
|
|
166
|
+
if (!(h && !b) && w && (a.target === a.currentTarget || a.target.classList.contains("week-calendar-time-cell"))) {
|
|
167
|
+
const u = new Date(r);
|
|
168
|
+
u.setHours(e, 0, 0, 0);
|
|
169
|
+
const g = new Date(r);
|
|
170
|
+
g.setHours(e + 1, 0, 0, 0), w({ start: u, end: g });
|
|
157
171
|
}
|
|
158
172
|
},
|
|
159
|
-
children:
|
|
173
|
+
children: c.map((a, u) => /* @__PURE__ */ m(
|
|
160
174
|
"div",
|
|
161
175
|
{
|
|
162
176
|
className: `
|
|
@@ -166,21 +180,22 @@ const F = {
|
|
|
166
180
|
`,
|
|
167
181
|
style: a.style,
|
|
168
182
|
title: a.title,
|
|
169
|
-
|
|
170
|
-
|
|
183
|
+
"data-testid": l(`event-${o}-${e}-${u}`),
|
|
184
|
+
onClick: (g) => {
|
|
185
|
+
g.stopPropagation(), i?.(a);
|
|
171
186
|
},
|
|
172
187
|
children: [
|
|
173
|
-
/* @__PURE__ */
|
|
188
|
+
/* @__PURE__ */ d(
|
|
174
189
|
"div",
|
|
175
190
|
{
|
|
176
191
|
className: "mr-1.5 inline-block h-2 w-2 shrink-0 rounded-full",
|
|
177
192
|
style: { backgroundColor: a.color || "#bfbfbf" }
|
|
178
193
|
}
|
|
179
194
|
),
|
|
180
|
-
/* @__PURE__ */
|
|
195
|
+
/* @__PURE__ */ d("div", { className: "min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap", children: a.title })
|
|
181
196
|
]
|
|
182
197
|
},
|
|
183
|
-
|
|
198
|
+
u
|
|
184
199
|
))
|
|
185
200
|
},
|
|
186
201
|
`${o}-${e}`
|
|
@@ -197,8 +212,8 @@ const F = {
|
|
|
197
212
|
);
|
|
198
213
|
}
|
|
199
214
|
);
|
|
200
|
-
|
|
215
|
+
q.displayName = "WeekCalendar";
|
|
201
216
|
export {
|
|
202
|
-
|
|
217
|
+
q as WeekCalendar
|
|
203
218
|
};
|
|
204
219
|
//# sourceMappingURL=WeekCalendar.js.map
|