@forgedevstack/bear 1.0.8 → 1.0.9
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/ActivityItem/ActivityItem.cjs +1 -1
- package/dist/components/ActivityItem/ActivityItem.js +1 -0
- package/dist/components/Alert/Alert.const.cjs +1 -1
- package/dist/components/Alert/Alert.const.js +3 -2
- package/dist/components/AppBar/AppBar.cjs +1 -1
- package/dist/components/AppBar/AppBar.js +3 -2
- package/dist/components/Badge/Badge.cjs +1 -1
- package/dist/components/Badge/Badge.js +15 -14
- package/dist/components/BearLogo/EmberLogo.cjs +1 -1
- package/dist/components/BearLogo/EmberLogo.js +3 -2
- package/dist/components/BottomNavigation/BottomNavigation.cjs +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.js +3 -2
- package/dist/components/Carousel/Carousel.cjs +1 -1
- package/dist/components/Carousel/Carousel.const.cjs +1 -0
- package/dist/components/Carousel/Carousel.const.d.ts +12 -0
- package/dist/components/Carousel/Carousel.const.js +9 -0
- package/dist/components/Carousel/Carousel.d.ts +14 -3
- package/dist/components/Carousel/Carousel.js +222 -75
- package/dist/components/Carousel/Carousel.types.d.ts +32 -2
- package/dist/components/Carousel/index.d.ts +1 -1
- package/dist/components/Chip/Chip.cjs +1 -1
- package/dist/components/Chip/Chip.js +3 -2
- package/dist/components/CodeEditor/CodeEditor.cjs +5 -0
- package/dist/components/CodeEditor/CodeEditor.const.cjs +1 -0
- package/dist/components/CodeEditor/CodeEditor.const.d.ts +21 -0
- package/dist/components/CodeEditor/CodeEditor.const.js +119 -0
- package/dist/components/CodeEditor/CodeEditor.d.ts +22 -0
- package/dist/components/CodeEditor/CodeEditor.js +250 -0
- package/dist/components/CodeEditor/CodeEditor.types.d.ts +80 -0
- package/dist/components/CodeEditor/CodeEditor.utils.cjs +1 -0
- package/dist/components/CodeEditor/CodeEditor.utils.d.ts +6 -0
- package/dist/components/CodeEditor/CodeEditor.utils.js +75 -0
- package/dist/components/CodeEditor/index.d.ts +2 -0
- package/dist/components/Columns/Columns.cjs +1 -1
- package/dist/components/Columns/Columns.js +9 -8
- package/dist/components/CountdownTimer/CountdownTimer.cjs +1 -0
- package/dist/components/CountdownTimer/CountdownTimer.const.cjs +1 -0
- package/dist/components/CountdownTimer/CountdownTimer.const.d.ts +27 -0
- package/dist/components/CountdownTimer/CountdownTimer.const.js +35 -0
- package/dist/components/CountdownTimer/CountdownTimer.d.ts +7 -0
- package/dist/components/CountdownTimer/CountdownTimer.js +115 -0
- package/dist/components/CountdownTimer/CountdownTimer.types.d.ts +56 -0
- package/dist/components/CountdownTimer/index.d.ts +2 -0
- package/dist/components/Cropper/Cropper.cjs +1 -0
- package/dist/components/Cropper/Cropper.const.cjs +1 -0
- package/dist/components/Cropper/Cropper.const.d.ts +31 -0
- package/dist/components/Cropper/Cropper.const.js +33 -0
- package/dist/components/Cropper/Cropper.d.ts +21 -0
- package/dist/components/Cropper/Cropper.js +362 -0
- package/dist/components/Cropper/Cropper.types.d.ts +72 -0
- package/dist/components/Cropper/index.d.ts +2 -0
- package/dist/components/DataTable/DataTable.cjs +1 -1
- package/dist/components/DataTable/DataTable.js +5 -4
- package/dist/components/Divider/Divider.cjs +1 -1
- package/dist/components/Divider/Divider.js +15 -14
- package/dist/components/Dock/Dock.cjs +1 -0
- package/dist/components/Dock/Dock.const.cjs +1 -0
- package/dist/components/Dock/Dock.const.d.ts +25 -0
- package/dist/components/Dock/Dock.const.js +22 -0
- package/dist/components/Dock/Dock.d.ts +7 -0
- package/dist/components/Dock/Dock.js +144 -0
- package/dist/components/Dock/Dock.types.d.ts +42 -0
- package/dist/components/Dock/index.d.ts +2 -0
- package/dist/components/EmptyState/EmptyState.cjs +1 -1
- package/dist/components/EmptyState/EmptyState.js +7 -6
- package/dist/components/GradientText/GradientText.cjs +1 -0
- package/dist/components/GradientText/GradientText.const.cjs +1 -0
- package/dist/components/GradientText/GradientText.const.d.ts +15 -0
- package/dist/components/GradientText/GradientText.const.js +36 -0
- package/dist/components/GradientText/GradientText.d.ts +7 -0
- package/dist/components/GradientText/GradientText.js +52 -0
- package/dist/components/GradientText/GradientText.types.d.ts +27 -0
- package/dist/components/GradientText/index.d.ts +2 -0
- package/dist/components/Highlight/Highlight.cjs +1 -1
- package/dist/components/Highlight/Highlight.const.cjs +1 -0
- package/dist/components/Highlight/Highlight.const.d.ts +8 -0
- package/dist/components/Highlight/Highlight.const.js +15 -0
- package/dist/components/Highlight/Highlight.d.ts +4 -0
- package/dist/components/Highlight/Highlight.js +32 -24
- package/dist/components/Highlight/Highlight.types.d.ts +9 -1
- package/dist/components/Highlight/index.d.ts +1 -1
- package/dist/components/Icon/Icon.cjs +1 -1
- package/dist/components/Icon/Icon.js +17 -16
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.js +12 -11
- package/dist/components/Kbd/Kbd.cjs +1 -1
- package/dist/components/Kbd/Kbd.js +17 -16
- package/dist/components/Map/Map.cjs +1 -0
- package/dist/components/Map/Map.const.cjs +1 -0
- package/dist/components/Map/Map.const.d.ts +20 -0
- package/dist/components/Map/Map.const.js +26 -0
- package/dist/components/Map/Map.d.ts +20 -0
- package/dist/components/Map/Map.js +259 -0
- package/dist/components/Map/Map.types.d.ts +81 -0
- package/dist/components/Map/index.d.ts +2 -0
- package/dist/components/Marquee/Marquee.cjs +1 -0
- package/dist/components/Marquee/Marquee.const.cjs +1 -0
- package/dist/components/Marquee/Marquee.const.d.ts +11 -0
- package/dist/components/Marquee/Marquee.const.js +12 -0
- package/dist/components/Marquee/Marquee.d.ts +7 -0
- package/dist/components/Marquee/Marquee.js +106 -0
- package/dist/components/Marquee/Marquee.types.d.ts +32 -0
- package/dist/components/Marquee/index.d.ts +2 -0
- package/dist/components/Masonry/Masonry.cjs +1 -0
- package/dist/components/Masonry/Masonry.const.cjs +1 -0
- package/dist/components/Masonry/Masonry.const.d.ts +9 -0
- package/dist/components/Masonry/Masonry.const.js +9 -0
- package/dist/components/Masonry/Masonry.d.ts +7 -0
- package/dist/components/Masonry/Masonry.js +51 -0
- package/dist/components/Masonry/Masonry.types.d.ts +21 -0
- package/dist/components/Masonry/index.d.ts +2 -0
- package/dist/components/NavigableSelect/NavigableSelect.cjs +1 -0
- package/dist/components/NavigableSelect/NavigableSelect.const.cjs +1 -0
- package/dist/components/NavigableSelect/NavigableSelect.const.d.ts +23 -0
- package/dist/components/NavigableSelect/NavigableSelect.const.js +33 -0
- package/dist/components/NavigableSelect/NavigableSelect.d.ts +7 -0
- package/dist/components/NavigableSelect/NavigableSelect.js +361 -0
- package/dist/components/NavigableSelect/NavigableSelect.types.d.ts +56 -0
- package/dist/components/NavigableSelect/index.d.ts +2 -0
- package/dist/components/Progress/Progress.cjs +1 -1
- package/dist/components/Progress/Progress.js +3 -2
- package/dist/components/RichEditor/components/ToolbarButton/ToolbarButton.cjs +1 -1
- package/dist/components/RichEditor/components/ToolbarButton/ToolbarButton.js +3 -2
- package/dist/components/ScrollArea/ScrollArea.cjs +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +3 -2
- package/dist/components/Sidebar/Sidebar.cjs +1 -1
- package/dist/components/Sidebar/Sidebar.js +13 -12
- package/dist/components/Spinner/Spinner.cjs +1 -1
- package/dist/components/Spinner/Spinner.js +3 -2
- package/dist/components/Spotlight/Spotlight.cjs +1 -0
- package/dist/components/Spotlight/Spotlight.const.cjs +1 -0
- package/dist/components/Spotlight/Spotlight.const.d.ts +18 -0
- package/dist/components/Spotlight/Spotlight.const.js +9 -0
- package/dist/components/Spotlight/Spotlight.d.ts +7 -0
- package/dist/components/Spotlight/Spotlight.js +220 -0
- package/dist/components/Spotlight/Spotlight.types.d.ts +51 -0
- package/dist/components/Spotlight/index.d.ts +2 -0
- package/dist/components/StatCard/StatCard.cjs +1 -1
- package/dist/components/StatCard/StatCard.js +9 -8
- package/dist/components/Statistic/Statistic.cjs +1 -1
- package/dist/components/Statistic/Statistic.js +7 -6
- package/dist/components/Switch/Switch.cjs +1 -1
- package/dist/components/Switch/Switch.js +11 -10
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.cjs +1 -1
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.js +16 -15
- package/dist/components/TimePicker/helpers/ClockFaceSvg.cjs +1 -1
- package/dist/components/TimePicker/helpers/ClockFaceSvg.js +13 -12
- package/dist/components/Transition/Transition.cjs +1 -0
- package/dist/components/Transition/Transition.const.cjs +1 -0
- package/dist/components/Transition/Transition.const.d.ts +15 -0
- package/dist/components/Transition/Transition.const.js +73 -0
- package/dist/components/Transition/Transition.d.ts +37 -0
- package/dist/components/Transition/Transition.js +107 -0
- package/dist/components/Transition/Transition.types.d.ts +69 -0
- package/dist/components/Transition/index.d.ts +2 -0
- package/dist/components/Typewriter/Typewriter.cjs +1 -0
- package/dist/components/Typewriter/Typewriter.const.cjs +1 -0
- package/dist/components/Typewriter/Typewriter.const.d.ts +22 -0
- package/dist/components/Typewriter/Typewriter.const.js +11 -0
- package/dist/components/Typewriter/Typewriter.d.ts +7 -0
- package/dist/components/Typewriter/Typewriter.js +88 -0
- package/dist/components/Typewriter/Typewriter.types.d.ts +32 -0
- package/dist/components/Typewriter/index.d.ts +2 -0
- package/dist/components/Watermark/Watermark.cjs +1 -0
- package/dist/components/Watermark/Watermark.const.cjs +1 -0
- package/dist/components/Watermark/Watermark.const.d.ts +30 -0
- package/dist/components/Watermark/Watermark.const.js +18 -0
- package/dist/components/Watermark/Watermark.d.ts +7 -0
- package/dist/components/Watermark/Watermark.js +96 -0
- package/dist/components/Watermark/Watermark.types.d.ts +35 -0
- package/dist/components/Watermark/index.d.ts +2 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +27 -1
- package/dist/components/index.js +231 -204
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.js +24 -19
- package/dist/hooks/useAnimate.cjs +1 -0
- package/dist/hooks/useAnimate.d.ts +61 -0
- package/dist/hooks/useAnimate.js +125 -0
- package/dist/hooks/useResponsive.cjs +1 -0
- package/dist/hooks/useResponsive.d.ts +35 -0
- package/dist/hooks/useResponsive.js +74 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +324 -290
- package/dist/styles.css +1 -1
- package/dist/utils/createSlots.cjs +1 -0
- package/dist/utils/createSlots.d.ts +70 -0
- package/dist/utils/createSlots.js +65 -0
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +4 -2
- package/package.json +1 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { LANGUAGE_KEYWORDS as i, BUILTIN_FUNCTIONS as m } from "./CodeEditor.const.js";
|
|
2
|
+
const d = (s, f) => {
|
|
3
|
+
if (f === "plaintext" || f === "markdown")
|
|
4
|
+
return [{ type: "default", value: s }];
|
|
5
|
+
const r = [], h = i[f] ?? [];
|
|
6
|
+
let t = 0;
|
|
7
|
+
const c = (e, o) => {
|
|
8
|
+
o && r.push({ type: e, value: o });
|
|
9
|
+
};
|
|
10
|
+
for (; t < s.length; ) {
|
|
11
|
+
if (s[t] === "/" && s[t + 1] === "/") {
|
|
12
|
+
c("comment", s.slice(t));
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
if (s[t] === "/" && s[t + 1] === "*") {
|
|
16
|
+
const e = s.indexOf("*/", t + 2), o = e === -1 ? s.slice(t) : s.slice(t, e + 2);
|
|
17
|
+
c("comment", o), t += o.length;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (s[t] === "#" && (f === "python" || f === "shell" || f === "yaml")) {
|
|
21
|
+
c("comment", s.slice(t));
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
if (s[t] === '"' || s[t] === "'" || s[t] === "`") {
|
|
25
|
+
const e = s[t];
|
|
26
|
+
let o = t + 1;
|
|
27
|
+
for (; o < s.length && s[o] !== e; )
|
|
28
|
+
s[o] === "\\" && o++, o++;
|
|
29
|
+
c("string", s.slice(t, o + 1)), t = o + 1;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (/[0-9]/.test(s[t]) && (t === 0 || /[^a-zA-Z_$]/.test(s[t - 1]))) {
|
|
33
|
+
let e = t;
|
|
34
|
+
for (; e < s.length && /[0-9.xXa-fA-F_eEn]/.test(s[e]); ) e++;
|
|
35
|
+
c("number", s.slice(t, e)), t = e;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (/[a-zA-Z_$]/.test(s[t])) {
|
|
39
|
+
let e = t;
|
|
40
|
+
for (; e < s.length && /[a-zA-Z0-9_$]/.test(s[e]); ) e++;
|
|
41
|
+
const o = s.slice(t, e);
|
|
42
|
+
o === "true" || o === "false" ? c("boolean", o) : o === "null" || o === "undefined" || o === "None" || o === "NaN" ? c("null", o) : h.includes(o) ? c("keyword", o) : m.includes(o) ? c("builtin", o) : e < s.length && s[e] === "(" ? c("function", o) : t > 0 && s[t - 1] === "." ? c("property", o) : c("variable", o), t = e;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (s[t] === "<" && (f === "html" || f === "jsx" || f === "tsx" || f === "xml")) {
|
|
46
|
+
s[t + 1] === "/" ? (c("tag", "</"), t += 2) : (c("tag", "<"), t += 1);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (s[t] === ">" && (f === "html" || f === "jsx" || f === "tsx" || f === "xml")) {
|
|
50
|
+
c("tag", ">"), t += 1;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
if (/[+\-*/%=!<>&|^~?:]/.test(s[t])) {
|
|
54
|
+
let e = t;
|
|
55
|
+
for (; e < s.length && /[+\-*/%=!<>&|^~?:]/.test(s[e]); ) e++;
|
|
56
|
+
c("operator", s.slice(t, e)), t = e;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (/[(){}[\],;.]/.test(s[t])) {
|
|
60
|
+
c("punctuation", s[t]), t++;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (/\s/.test(s[t])) {
|
|
64
|
+
let e = t;
|
|
65
|
+
for (; e < s.length && /\s/.test(s[e]); ) e++;
|
|
66
|
+
c("default", s.slice(t, e)), t = e;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
c("default", s[t]), t++;
|
|
70
|
+
}
|
|
71
|
+
return r;
|
|
72
|
+
};
|
|
73
|
+
export {
|
|
74
|
+
d as tokenizeLine
|
|
75
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),a=require("../../utils/cn.cjs")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),a=require("../../utils/cn.cjs");require("react");const c={none:"0",xs:"0.5rem",sm:"1rem",md:"1.5rem",lg:"2rem",xl:"3rem"},b=({children:l,count:e="auto",gap:n="md",fill:r=!1,minWidth:o,className:s,style:m})=>{const t={columnCount:e==="auto"?"auto":e,columnGap:c[n],columnFill:r?"balance":"auto",...o&&{columnWidth:typeof o=="number"?`${o}px`:o},...m};return u.jsx("div",{className:a.cn("bear-w-full",s),style:t,children:l})},i=({children:l,span:e="avoid",className:n,style:r})=>u.jsx("div",{className:a.cn("bear-inline-block bear-w-full bear-mb-4",e==="avoid"&&"bear-break-inside-avoid",n),style:r,children:l});exports.Column=i;exports.Columns=b;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as m } from "react/jsx-runtime";
|
|
2
2
|
import { cn as n } from "../../utils/cn.js";
|
|
3
|
+
import "react";
|
|
3
4
|
const c = {
|
|
4
5
|
none: "0",
|
|
5
6
|
xs: "0.5rem",
|
|
@@ -10,16 +11,16 @@ const c = {
|
|
|
10
11
|
}, d = ({
|
|
11
12
|
children: l,
|
|
12
13
|
count: o = "auto",
|
|
13
|
-
gap:
|
|
14
|
-
fill:
|
|
14
|
+
gap: r = "md",
|
|
15
|
+
fill: a = !1,
|
|
15
16
|
minWidth: e,
|
|
16
17
|
className: u,
|
|
17
18
|
style: s
|
|
18
19
|
}) => {
|
|
19
20
|
const t = {
|
|
20
21
|
columnCount: o === "auto" ? "auto" : o,
|
|
21
|
-
columnGap: c[
|
|
22
|
-
columnFill:
|
|
22
|
+
columnGap: c[r],
|
|
23
|
+
columnFill: a ? "balance" : "auto",
|
|
23
24
|
...e && { columnWidth: typeof e == "number" ? `${e}px` : e },
|
|
24
25
|
...s
|
|
25
26
|
};
|
|
@@ -34,17 +35,17 @@ const c = {
|
|
|
34
35
|
}, f = ({
|
|
35
36
|
children: l,
|
|
36
37
|
span: o = "avoid",
|
|
37
|
-
className:
|
|
38
|
-
style:
|
|
38
|
+
className: r,
|
|
39
|
+
style: a
|
|
39
40
|
}) => /* @__PURE__ */ m(
|
|
40
41
|
"div",
|
|
41
42
|
{
|
|
42
43
|
className: n(
|
|
43
44
|
"bear-inline-block bear-w-full bear-mb-4",
|
|
44
45
|
o === "avoid" && "bear-break-inside-avoid",
|
|
45
|
-
|
|
46
|
+
r
|
|
46
47
|
),
|
|
47
|
-
style:
|
|
48
|
+
style: a,
|
|
48
49
|
children: l
|
|
49
50
|
}
|
|
50
51
|
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),s=require("react"),b=require("../../utils/cn.cjs"),e=require("./CountdownTimer.const.cjs"),S=n=>String(n).padStart(e.PAD_LENGTH,"0"),y=(n,o)=>{const r=Math.max(0,n-o);return{days:Math.floor(r/e.MS_PER_DAY),hours:Math.floor(r%e.MS_PER_DAY/e.MS_PER_HOUR),minutes:Math.floor(r%e.MS_PER_HOUR/e.MS_PER_MINUTE),seconds:Math.floor(r%e.MS_PER_MINUTE/e.MS_PER_SECOND),totalSeconds:Math.floor(r/e.MS_PER_SECOND),isComplete:r<=0}},Z=n=>{const{targetDate:o,duration:r,variant:f="default",size:m="md",showDays:M=!0,showHours:R=!0,showMinutes:D=!0,showSeconds:I=!0,showLabels:L=!0,showSeparator:P=!0,separator:v=e.DEFAULT_SEPARATOR,labels:p,onComplete:d,onTick:u,paused:w=!1,render:C,className:N,style:j,testId:k}=n,c=s.useMemo(()=>({...e.DEFAULT_LABELS,...p}),[p]),x=s.useRef(!1),B=s.useCallback(()=>o?new Date(o).getTime():r?Date.now()+r*e.MS_PER_SECOND:Date.now(),[o,r]),[_]=s.useState(B),[i,O]=s.useState(()=>y(_,Date.now()));if(s.useEffect(()=>{if(w)return;const t=()=>{const h=y(_,Date.now());O(h),u==null||u(h),h.isComplete&&!x.current&&(x.current=!0,d==null||d())};t();const g=setInterval(t,e.UPDATE_INTERVAL);return()=>clearInterval(g)},[_,w,d,u]),C)return a.jsx(a.Fragment,{children:C(i)});const A=e.SIZE_DIGIT_CLASSES[m]??e.SIZE_DIGIT_CLASSES.md,U=e.SIZE_LABEL_CLASSES[m]??e.SIZE_LABEL_CLASSES.md,G=e.SIZE_GAP_CLASSES[m]??e.SIZE_GAP_CLASSES.md,l=[];M&&l.push({value:S(i.days),label:c.days}),R&&l.push({value:S(i.hours),label:c.hours}),D&&l.push({value:S(i.minutes),label:c.minutes}),I&&l.push({value:S(i.seconds),label:c.seconds});const E=f==="card",T=f==="flip";return a.jsx("div",{className:b.cn("Bear-CountdownTimer","bear-flex bear-items-center",G,N),style:j,"data-testid":k,role:"timer","aria-label":"Countdown timer",children:l.map((t,g)=>a.jsxs("div",{className:"Bear-CountdownTimer__segment bear-flex bear-items-center",children:[g>0&&P&&!E&&a.jsx("span",{className:b.cn("Bear-CountdownTimer__separator",A,e.SEPARATOR_MARGIN,"bear-text-gray-400 dark:bear-text-gray-500"),"aria-hidden":"true",children:v}),a.jsxs("div",{className:"Bear-CountdownTimer__unit bear-flex bear-flex-col bear-items-center",children:[a.jsx("div",{className:b.cn("Bear-CountdownTimer__digit",A,"bear-tabular-nums bear-tracking-wider",E&&["bear-px-3 bear-py-2 bear-rounded-lg","bear-bg-gray-100 dark:bear-bg-gray-800","bear-border bear-border-gray-200 dark:bear-border-gray-700"],T&&["bear-px-3 bear-py-2 bear-rounded-lg","bear-bg-gray-900 dark:bear-bg-gray-100","bear-text-white dark:bear-text-gray-900","bear-shadow-lg"],!E&&!T&&"bear-text-[var(--bear-text-primary)]"),children:t.value}),L&&a.jsx("span",{className:b.cn("Bear-CountdownTimer__label",U,"bear-mt-1 bear-uppercase bear-tracking-widest","bear-text-gray-500 dark:bear-text-gray-400"),children:t.label})]})]},t.label))})};exports.CountdownTimer=Z;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=1e3,E=60*S,t=60*E,e=24*t,_={days:"Days",hours:"Hours",minutes:"Minutes",seconds:"Seconds"},A=":",s=2,o={sm:"bear-text-lg bear-font-bold",md:"bear-text-3xl bear-font-bold",lg:"bear-text-5xl bear-font-bold",xl:"bear-text-7xl bear-font-bold"},a={sm:"bear-text-[10px]",md:"bear-text-xs",lg:"bear-text-sm",xl:"bear-text-base"},b={sm:"bear-gap-2",md:"bear-gap-3",lg:"bear-gap-4",xl:"bear-gap-5"},r="bear-mx-1",n=1e3;exports.DEFAULT_LABELS=_;exports.DEFAULT_SEPARATOR=A;exports.MS_PER_DAY=e;exports.MS_PER_HOUR=t;exports.MS_PER_MINUTE=E;exports.MS_PER_SECOND=S;exports.PAD_LENGTH=s;exports.SEPARATOR_MARGIN=r;exports.SIZE_DIGIT_CLASSES=o;exports.SIZE_GAP_CLASSES=b;exports.SIZE_LABEL_CLASSES=a;exports.UPDATE_INTERVAL=n;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CountdownTimerSize } from './CountdownTimer.types';
|
|
2
|
+
/** Milliseconds in time units */
|
|
3
|
+
export declare const MS_PER_SECOND = 1000;
|
|
4
|
+
export declare const MS_PER_MINUTE: number;
|
|
5
|
+
export declare const MS_PER_HOUR: number;
|
|
6
|
+
export declare const MS_PER_DAY: number;
|
|
7
|
+
/** Default labels */
|
|
8
|
+
export declare const DEFAULT_LABELS: {
|
|
9
|
+
readonly days: "Days";
|
|
10
|
+
readonly hours: "Hours";
|
|
11
|
+
readonly minutes: "Minutes";
|
|
12
|
+
readonly seconds: "Seconds";
|
|
13
|
+
};
|
|
14
|
+
/** Default separator */
|
|
15
|
+
export declare const DEFAULT_SEPARATOR = ":";
|
|
16
|
+
/** Pad length for digits */
|
|
17
|
+
export declare const PAD_LENGTH = 2;
|
|
18
|
+
/** Digit classes per size */
|
|
19
|
+
export declare const SIZE_DIGIT_CLASSES: Record<CountdownTimerSize, string>;
|
|
20
|
+
/** Label classes per size */
|
|
21
|
+
export declare const SIZE_LABEL_CLASSES: Record<CountdownTimerSize, string>;
|
|
22
|
+
/** Gap classes per size */
|
|
23
|
+
export declare const SIZE_GAP_CLASSES: Record<CountdownTimerSize, string>;
|
|
24
|
+
/** Separator horizontal margin */
|
|
25
|
+
export declare const SEPARATOR_MARGIN = "bear-mx-1";
|
|
26
|
+
/** Update interval in ms */
|
|
27
|
+
export declare const UPDATE_INTERVAL = 1000;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const t = 1e3, e = 6e4, s = 36e5, E = 864e5, o = {
|
|
2
|
+
days: "Days",
|
|
3
|
+
hours: "Hours",
|
|
4
|
+
minutes: "Minutes",
|
|
5
|
+
seconds: "Seconds"
|
|
6
|
+
}, S = ":", _ = 2, a = {
|
|
7
|
+
sm: "bear-text-lg bear-font-bold",
|
|
8
|
+
md: "bear-text-3xl bear-font-bold",
|
|
9
|
+
lg: "bear-text-5xl bear-font-bold",
|
|
10
|
+
xl: "bear-text-7xl bear-font-bold"
|
|
11
|
+
}, b = {
|
|
12
|
+
sm: "bear-text-[10px]",
|
|
13
|
+
md: "bear-text-xs",
|
|
14
|
+
lg: "bear-text-sm",
|
|
15
|
+
xl: "bear-text-base"
|
|
16
|
+
}, n = {
|
|
17
|
+
sm: "bear-gap-2",
|
|
18
|
+
md: "bear-gap-3",
|
|
19
|
+
lg: "bear-gap-4",
|
|
20
|
+
xl: "bear-gap-5"
|
|
21
|
+
}, r = "bear-mx-1", x = 1e3;
|
|
22
|
+
export {
|
|
23
|
+
o as DEFAULT_LABELS,
|
|
24
|
+
S as DEFAULT_SEPARATOR,
|
|
25
|
+
E as MS_PER_DAY,
|
|
26
|
+
s as MS_PER_HOUR,
|
|
27
|
+
e as MS_PER_MINUTE,
|
|
28
|
+
t as MS_PER_SECOND,
|
|
29
|
+
_ as PAD_LENGTH,
|
|
30
|
+
r as SEPARATOR_MARGIN,
|
|
31
|
+
a as SIZE_DIGIT_CLASSES,
|
|
32
|
+
n as SIZE_GAP_CLASSES,
|
|
33
|
+
b as SIZE_LABEL_CLASSES,
|
|
34
|
+
x as UPDATE_INTERVAL
|
|
35
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CountdownTimerProps } from './CountdownTimer.types';
|
|
3
|
+
/**
|
|
4
|
+
* CountdownTimer - Visual countdown with days/hours/minutes/seconds.
|
|
5
|
+
* Multiple variants, sizes, and theming via BearProvider CSS variables.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CountdownTimer: FC<CountdownTimerProps>;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsx as o, Fragment as J, jsxs as T } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as K, useRef as Q, useCallback as W, useState as A, useEffect as X } from "react";
|
|
3
|
+
import { cn as u } from "../../utils/cn.js";
|
|
4
|
+
import { DEFAULT_SEPARATOR as $, DEFAULT_LABELS as ee, MS_PER_SECOND as h, UPDATE_INTERVAL as re, SEPARATOR_MARGIN as ae, SIZE_DIGIT_CLASSES as v, SIZE_LABEL_CLASSES as D, SIZE_GAP_CLASSES as M, MS_PER_MINUTE as R, MS_PER_HOUR as L, MS_PER_DAY as N, PAD_LENGTH as te } from "./CountdownTimer.const.js";
|
|
5
|
+
const b = (a) => String(a).padStart(te, "0"), I = (a, t) => {
|
|
6
|
+
const e = Math.max(0, a - t);
|
|
7
|
+
return {
|
|
8
|
+
days: Math.floor(e / N),
|
|
9
|
+
hours: Math.floor(e % N / L),
|
|
10
|
+
minutes: Math.floor(e % L / R),
|
|
11
|
+
seconds: Math.floor(e % R / h),
|
|
12
|
+
totalSeconds: Math.floor(e / h),
|
|
13
|
+
isComplete: e <= 0
|
|
14
|
+
};
|
|
15
|
+
}, ie = (a) => {
|
|
16
|
+
const {
|
|
17
|
+
targetDate: t,
|
|
18
|
+
duration: e,
|
|
19
|
+
variant: _ = "default",
|
|
20
|
+
size: c = "md",
|
|
21
|
+
showDays: P = !0,
|
|
22
|
+
showHours: k = !0,
|
|
23
|
+
showMinutes: B = !0,
|
|
24
|
+
showSeconds: F = !0,
|
|
25
|
+
showLabels: U = !0,
|
|
26
|
+
showSeparator: G = !0,
|
|
27
|
+
separator: O = $,
|
|
28
|
+
labels: S,
|
|
29
|
+
onComplete: l,
|
|
30
|
+
onTick: i,
|
|
31
|
+
paused: w = !1,
|
|
32
|
+
render: E,
|
|
33
|
+
className: H,
|
|
34
|
+
style: Z,
|
|
35
|
+
testId: j
|
|
36
|
+
} = a, d = K(() => ({ ...ee, ...S }), [S]), y = Q(!1), z = W(() => t ? new Date(t).getTime() : e ? Date.now() + e * h : Date.now(), [t, e]), [m] = A(z), [s, V] = A(() => I(m, Date.now()));
|
|
37
|
+
if (X(() => {
|
|
38
|
+
if (w) return;
|
|
39
|
+
const r = () => {
|
|
40
|
+
const p = I(m, Date.now());
|
|
41
|
+
V(p), i == null || i(p), p.isComplete && !y.current && (y.current = !0, l == null || l());
|
|
42
|
+
};
|
|
43
|
+
r();
|
|
44
|
+
const f = setInterval(r, re);
|
|
45
|
+
return () => clearInterval(f);
|
|
46
|
+
}, [m, w, l, i]), E) return /* @__PURE__ */ o(J, { children: E(s) });
|
|
47
|
+
const x = v[c] ?? v.md, Y = D[c] ?? D.md, q = M[c] ?? M.md, n = [];
|
|
48
|
+
P && n.push({ value: b(s.days), label: d.days }), k && n.push({ value: b(s.hours), label: d.hours }), B && n.push({ value: b(s.minutes), label: d.minutes }), F && n.push({ value: b(s.seconds), label: d.seconds });
|
|
49
|
+
const g = _ === "card", C = _ === "flip";
|
|
50
|
+
return /* @__PURE__ */ o(
|
|
51
|
+
"div",
|
|
52
|
+
{
|
|
53
|
+
className: u("Bear-CountdownTimer", "bear-flex bear-items-center", q, H),
|
|
54
|
+
style: Z,
|
|
55
|
+
"data-testid": j,
|
|
56
|
+
role: "timer",
|
|
57
|
+
"aria-label": "Countdown timer",
|
|
58
|
+
children: n.map((r, f) => /* @__PURE__ */ T("div", { className: "Bear-CountdownTimer__segment bear-flex bear-items-center", children: [
|
|
59
|
+
f > 0 && G && !g && /* @__PURE__ */ o(
|
|
60
|
+
"span",
|
|
61
|
+
{
|
|
62
|
+
className: u(
|
|
63
|
+
"Bear-CountdownTimer__separator",
|
|
64
|
+
x,
|
|
65
|
+
ae,
|
|
66
|
+
"bear-text-gray-400 dark:bear-text-gray-500"
|
|
67
|
+
),
|
|
68
|
+
"aria-hidden": "true",
|
|
69
|
+
children: O
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
/* @__PURE__ */ T("div", { className: "Bear-CountdownTimer__unit bear-flex bear-flex-col bear-items-center", children: [
|
|
73
|
+
/* @__PURE__ */ o(
|
|
74
|
+
"div",
|
|
75
|
+
{
|
|
76
|
+
className: u(
|
|
77
|
+
"Bear-CountdownTimer__digit",
|
|
78
|
+
x,
|
|
79
|
+
"bear-tabular-nums bear-tracking-wider",
|
|
80
|
+
g && [
|
|
81
|
+
"bear-px-3 bear-py-2 bear-rounded-lg",
|
|
82
|
+
"bear-bg-gray-100 dark:bear-bg-gray-800",
|
|
83
|
+
"bear-border bear-border-gray-200 dark:bear-border-gray-700"
|
|
84
|
+
],
|
|
85
|
+
C && [
|
|
86
|
+
"bear-px-3 bear-py-2 bear-rounded-lg",
|
|
87
|
+
"bear-bg-gray-900 dark:bear-bg-gray-100",
|
|
88
|
+
"bear-text-white dark:bear-text-gray-900",
|
|
89
|
+
"bear-shadow-lg"
|
|
90
|
+
],
|
|
91
|
+
!g && !C && "bear-text-[var(--bear-text-primary)]"
|
|
92
|
+
),
|
|
93
|
+
children: r.value
|
|
94
|
+
}
|
|
95
|
+
),
|
|
96
|
+
U && /* @__PURE__ */ o(
|
|
97
|
+
"span",
|
|
98
|
+
{
|
|
99
|
+
className: u(
|
|
100
|
+
"Bear-CountdownTimer__label",
|
|
101
|
+
Y,
|
|
102
|
+
"bear-mt-1 bear-uppercase bear-tracking-widest",
|
|
103
|
+
"bear-text-gray-500 dark:bear-text-gray-400"
|
|
104
|
+
),
|
|
105
|
+
children: r.label
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
] })
|
|
109
|
+
] }, r.label))
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
export {
|
|
114
|
+
ie as CountdownTimer
|
|
115
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type CountdownTimerVariant = 'default' | 'card' | 'minimal' | 'flip';
|
|
3
|
+
export type CountdownTimerSize = 'sm' | 'md' | 'lg' | 'xl';
|
|
4
|
+
export interface CountdownTimerProps {
|
|
5
|
+
/** Target date/time to count down to */
|
|
6
|
+
targetDate?: Date | string | number;
|
|
7
|
+
/** Duration in seconds (alternative to targetDate) */
|
|
8
|
+
duration?: number;
|
|
9
|
+
/** Visual variant */
|
|
10
|
+
variant?: CountdownTimerVariant | (string & {});
|
|
11
|
+
/** Size preset */
|
|
12
|
+
size?: CountdownTimerSize;
|
|
13
|
+
/** Whether to show days */
|
|
14
|
+
showDays?: boolean;
|
|
15
|
+
/** Whether to show hours */
|
|
16
|
+
showHours?: boolean;
|
|
17
|
+
/** Whether to show minutes */
|
|
18
|
+
showMinutes?: boolean;
|
|
19
|
+
/** Whether to show seconds */
|
|
20
|
+
showSeconds?: boolean;
|
|
21
|
+
/** Whether to show labels */
|
|
22
|
+
showLabels?: boolean;
|
|
23
|
+
/** Whether to show separator */
|
|
24
|
+
showSeparator?: boolean;
|
|
25
|
+
/** Separator character */
|
|
26
|
+
separator?: string;
|
|
27
|
+
/** Custom labels */
|
|
28
|
+
labels?: {
|
|
29
|
+
days?: string;
|
|
30
|
+
hours?: string;
|
|
31
|
+
minutes?: string;
|
|
32
|
+
seconds?: string;
|
|
33
|
+
};
|
|
34
|
+
/** Called when countdown reaches zero */
|
|
35
|
+
onComplete?: () => void;
|
|
36
|
+
/** Called every second */
|
|
37
|
+
onTick?: (remaining: CountdownTime) => void;
|
|
38
|
+
/** Whether countdown is paused */
|
|
39
|
+
paused?: boolean;
|
|
40
|
+
/** Custom renderer */
|
|
41
|
+
render?: (time: CountdownTime) => ReactNode;
|
|
42
|
+
/** Custom class name */
|
|
43
|
+
className?: string;
|
|
44
|
+
/** Custom style */
|
|
45
|
+
style?: React.CSSProperties;
|
|
46
|
+
/** Test ID */
|
|
47
|
+
testId?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface CountdownTime {
|
|
50
|
+
days: number;
|
|
51
|
+
hours: number;
|
|
52
|
+
minutes: number;
|
|
53
|
+
seconds: number;
|
|
54
|
+
totalSeconds: number;
|
|
55
|
+
isComplete: boolean;
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),i=require("react"),S=require("../../utils/cn.cjs"),n=require("./Cropper.const.cjs"),ue=({src:p,crop:O,onCropChange:y,onCropComplete:v,aspectRatio:M="free",shape:I="rectangle",zoom:_,onZoomChange:N,minZoom:j=n.MIN_ZOOM,maxZoom:E=n.MAX_ZOOM,rotation:D,onRotationChange:k,showZoomSlider:o=!1,showRotationSlider:g=!1,showGrid:X=!1,gridOpacity:Y=n.DEFAULT_GRID_OPACITY,overlayColor:q=n.OVERLAY_COLOR,borderColor:B=n.BORDER_COLOR,borderWidth:V=n.BORDER_WIDTH,width:J="100%",height:K=400,className:Q,style:C,testId:Z})=>{const L=i.useRef(null),H=i.useRef(null),$=i.useRef(null),[ee,te]=i.useState(n.DEFAULT_CROP),[ae,re]=i.useState(n.DEFAULT_ZOOM),[se,ne]=i.useState(0),[f,W]=i.useState("none"),[w,P]=i.useState(null),[ie,ce]=i.useState(!1),[,le]=i.useState({w:0,h:0}),a=O??ee,x=_??ae,A=D??se,h=i.useMemo(()=>typeof M=="number"?M:n.ASPECT_RATIO_VALUES[M]??null,[M]),z=i.useCallback(e=>{O||te(e),y==null||y(e)},[O,y]),T=i.useCallback(e=>{const t=Math.max(j,Math.min(E,e));_||re(t),N==null||N(t)},[_,N,j,E]),he=i.useCallback(e=>{const t=Math.max(n.MIN_ROTATION,Math.min(n.MAX_ROTATION,e));D||ne(t),k==null||k(t)},[D,k]);i.useEffect(()=>{const e=new Image;e.crossOrigin="anonymous",e.onload=()=>{$.current=e,le({w:e.naturalWidth,h:e.naturalHeight}),ce(!0)},e.src=p},[p]);const b=i.useCallback(e=>{const t=L.current;if(!t)return e;const c=t.clientWidth,r=t.clientHeight-(o||g?60:0);let{x:l,y:m,width:u,height:d}=e;return u=Math.max(n.MIN_CROP_SIZE,u),d=Math.max(n.MIN_CROP_SIZE,d),h&&(d=u/h),l=Math.max(0,Math.min(c-u,l)),m=Math.max(0,Math.min(r-d,m)),{x:l,y:m,width:u,height:d}},[h,o,g]),G=i.useCallback(()=>{const e=H.current,t=$.current,c=L.current;if(!e||!t||!c)return"";const r=c.clientWidth,l=c.clientHeight-(o||g?60:0),m=t.naturalWidth/(r*x),u=t.naturalHeight/(l*x);e.width=a.width*m,e.height=a.height*u;const d=e.getContext("2d");return d?(I==="circle"&&(d.beginPath(),d.arc(e.width/2,e.height/2,Math.min(e.width,e.height)/2,0,Math.PI*2),d.clip()),d.drawImage(t,a.x*m,a.y*u,a.width*m,a.height*u,0,0,e.width,e.height),e.toDataURL("image/png")):""},[a,x,I,o,g]),R=i.useCallback(e=>t=>{t.preventDefault(),t.stopPropagation(),W(e),P({x:t.clientX,y:t.clientY,crop:{...a}})},[a]),de=i.useCallback(e=>{if(f==="none"||!w)return;const t=e.clientX-w.x,c=e.clientY-w.y,{crop:r}=w;let l;switch(f){case"move":l=b({...r,x:r.x+t,y:r.y+c});break;case"se":l=b({...r,width:r.width+t,height:h?(r.width+t)/h:r.height+c});break;case"sw":l=b({...r,x:r.x+t,width:r.width-t,height:h?(r.width-t)/h:r.height+c});break;case"ne":l=b({...r,y:h?r.y:r.y+c,width:r.width+t,height:h?(r.width+t)/h:r.height-c});break;case"nw":l=b({x:r.x+t,y:r.y+c,width:r.width-t,height:h?(r.width-t)/h:r.height-c});break;case"n":l=b({...r,y:r.y+c,height:r.height-c});break;case"s":l=b({...r,height:r.height+c});break;case"e":l=b({...r,width:r.width+t});break;case"w":l=b({...r,x:r.x+t,width:r.width-t});break;default:return}z(l)},[f,w,b,z,h]),U=i.useCallback(()=>{if(f!=="none"){const e=G();v==null||v(a,e)}W("none"),P(null)},[f,a,G,v]),be=i.useCallback(e=>{e.preventDefault();const t=e.deltaY>0?-n.ZOOM_STEP:n.ZOOM_STEP;T(x+t)},[x,T]),F=o||g?60:0;return s.jsxs("div",{className:S.cn("bear-relative bear-overflow-hidden bear-rounded-lg","bear-bg-gray-900 bear-select-none",Q),style:{width:J,height:K,...C},"data-testid":Z,children:[s.jsx("canvas",{ref:H,className:"bear-hidden"}),s.jsxs("div",{ref:L,className:"bear-relative bear-overflow-hidden bear-cursor-crosshair",style:{height:`calc(100% - ${F}px)`},onMouseMove:de,onMouseUp:U,onMouseLeave:U,onWheel:be,children:[ie&&s.jsx("img",{src:p,alt:"",className:"bear-absolute bear-inset-0 bear-w-full bear-h-full bear-object-contain bear-pointer-events-none",style:{transform:`scale(${x}) rotate(${A}deg)`,transition:f!=="none"?"none":"transform 0.2s ease"},draggable:!1}),s.jsxs("svg",{className:"bear-absolute bear-inset-0 bear-w-full bear-h-full bear-pointer-events-none",children:[s.jsx("defs",{children:s.jsxs("mask",{id:"crop-mask",children:[s.jsx("rect",{width:"100%",height:"100%",fill:"white"}),I==="circle"?s.jsx("ellipse",{cx:a.x+a.width/2,cy:a.y+a.height/2,rx:a.width/2,ry:a.height/2,fill:"black"}):s.jsx("rect",{x:a.x,y:a.y,width:a.width,height:a.height,fill:"black"})]})}),s.jsx("rect",{width:"100%",height:"100%",fill:q,mask:"url(#crop-mask)"})]}),s.jsx("div",{className:"bear-absolute bear-pointer-events-none",style:{left:a.x,top:a.y,width:a.width,height:a.height,border:`${V}px solid ${B}`,borderRadius:I==="circle"?"50%":0,boxShadow:"0 0 0 9999px transparent"},children:X&&s.jsxs("svg",{className:"bear-absolute bear-inset-0 bear-w-full bear-h-full",style:{opacity:Y},children:[Array.from({length:n.GRID_LINES-1}).map((e,t)=>s.jsx("line",{x1:`${(t+1)/n.GRID_LINES*100}%`,y1:"0",x2:`${(t+1)/n.GRID_LINES*100}%`,y2:"100%",stroke:"white",strokeWidth:"0.5"},`v-${t}`)),Array.from({length:n.GRID_LINES-1}).map((e,t)=>s.jsx("line",{x1:"0",y1:`${(t+1)/n.GRID_LINES*100}%`,x2:"100%",y2:`${(t+1)/n.GRID_LINES*100}%`,stroke:"white",strokeWidth:"0.5"},`h-${t}`))]})}),s.jsx("div",{className:"bear-absolute bear-cursor-move",style:{left:a.x,top:a.y,width:a.width,height:a.height},onMouseDown:R("move")}),["nw","ne","sw","se"].map(e=>{const t=e.includes("w"),c=e.includes("n");return s.jsx("div",{className:S.cn("bear-absolute bear-bg-white bear-border-2 bear-rounded-sm","bear-shadow-md bear-z-10"),style:{width:n.HANDLE_SIZE,height:n.HANDLE_SIZE,left:(t?a.x:a.x+a.width)-n.HANDLE_SIZE/2,top:(c?a.y:a.y+a.height)-n.HANDLE_SIZE/2,borderColor:"var(--bear-primary-500)",cursor:`${e}-resize`},onMouseDown:R(e)},e)}),["n","s","e","w"].map(e=>{const t=e==="n"||e==="s";return s.jsx("div",{className:"bear-absolute bear-z-10",style:{left:e==="w"?a.x-4:e==="e"?a.x+a.width-4:a.x+a.width/2-12,top:e==="n"?a.y-4:e==="s"?a.y+a.height-4:a.y+a.height/2-12,width:t?24:8,height:t?8:24,cursor:t?`${e}-resize`:`${e}-resize`},onMouseDown:R(e)},e)})]}),(o||g)&&s.jsxs("div",{className:S.cn("bear-flex bear-items-center bear-gap-4 bear-px-4","bear-bg-gray-800/90 bear-backdrop-blur-sm"),style:{height:F},children:[o&&s.jsxs("div",{className:"bear-flex bear-items-center bear-gap-2 bear-flex-1",children:[s.jsx("svg",{className:"bear-w-4 bear-h-4 bear-text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0zM10 7v3m0 0v3m0-3h3m-3 0H7"})}),s.jsx("input",{type:"range",min:j,max:E,step:n.ZOOM_STEP,value:x,onChange:e=>T(parseFloat(e.target.value)),className:"bear-flex-1 bear-h-1 bear-accent-pink-500"}),s.jsxs("span",{className:"bear-text-xs bear-text-gray-400 bear-w-10 bear-text-right",children:[(x*100).toFixed(0),"%"]})]}),g&&s.jsxs("div",{className:"bear-flex bear-items-center bear-gap-2 bear-flex-1",children:[s.jsx("svg",{className:"bear-w-4 bear-h-4 bear-text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),s.jsx("input",{type:"range",min:n.MIN_ROTATION,max:n.MAX_ROTATION,step:n.ROTATION_STEP,value:A,onChange:e=>he(parseFloat(e.target.value)),className:"bear-flex-1 bear-h-1 bear-accent-pink-500"}),s.jsxs("span",{className:"bear-text-xs bear-text-gray-400 bear-w-10 bear-text-right",children:[A,"°"]})]})]})]})};exports.Cropper=ue;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O={x:50,y:50,width:200,height:200},_=20,T=1,R=.5,A=5,E=.1,I=-180,t=180,o=1,n="rgba(0, 0, 0, 0.6)",M="#ffffff",c=2,s=3,D=.4,L=12,N={free:null,"1:1":1,"4:3":4/3,"3:2":3/2,"16:9":16/9,"2:3":2/3,"3:4":3/4,"9:16":9/16};exports.ASPECT_RATIO_VALUES=N;exports.BORDER_COLOR=M;exports.BORDER_WIDTH=c;exports.DEFAULT_CROP=O;exports.DEFAULT_GRID_OPACITY=D;exports.DEFAULT_ZOOM=T;exports.GRID_LINES=s;exports.HANDLE_SIZE=L;exports.MAX_ROTATION=t;exports.MAX_ZOOM=A;exports.MIN_CROP_SIZE=_;exports.MIN_ROTATION=I;exports.MIN_ZOOM=R;exports.OVERLAY_COLOR=n;exports.ROTATION_STEP=o;exports.ZOOM_STEP=E;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { CropArea, AspectRatioPreset } from './Cropper.types';
|
|
2
|
+
/** Default crop area */
|
|
3
|
+
export declare const DEFAULT_CROP: CropArea;
|
|
4
|
+
/** Min crop dimensions */
|
|
5
|
+
export declare const MIN_CROP_SIZE = 20;
|
|
6
|
+
/** Default zoom */
|
|
7
|
+
export declare const DEFAULT_ZOOM = 1;
|
|
8
|
+
/** Zoom range */
|
|
9
|
+
export declare const MIN_ZOOM = 0.5;
|
|
10
|
+
export declare const MAX_ZOOM = 5;
|
|
11
|
+
/** Zoom step for slider */
|
|
12
|
+
export declare const ZOOM_STEP = 0.1;
|
|
13
|
+
/** Rotation range */
|
|
14
|
+
export declare const MIN_ROTATION = -180;
|
|
15
|
+
export declare const MAX_ROTATION = 180;
|
|
16
|
+
/** Rotation step for slider */
|
|
17
|
+
export declare const ROTATION_STEP = 1;
|
|
18
|
+
/** Default overlay color */
|
|
19
|
+
export declare const OVERLAY_COLOR = "rgba(0, 0, 0, 0.6)";
|
|
20
|
+
/** Default border color */
|
|
21
|
+
export declare const BORDER_COLOR = "#ffffff";
|
|
22
|
+
/** Default border width */
|
|
23
|
+
export declare const BORDER_WIDTH = 2;
|
|
24
|
+
/** Grid line count per axis */
|
|
25
|
+
export declare const GRID_LINES = 3;
|
|
26
|
+
/** Default grid opacity */
|
|
27
|
+
export declare const DEFAULT_GRID_OPACITY = 0.4;
|
|
28
|
+
/** Handle size in px */
|
|
29
|
+
export declare const HANDLE_SIZE = 12;
|
|
30
|
+
/** Aspect ratio numeric values */
|
|
31
|
+
export declare const ASPECT_RATIO_VALUES: Record<AspectRatioPreset, number | null>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const O = {
|
|
2
|
+
x: 50,
|
|
3
|
+
y: 50,
|
|
4
|
+
width: 200,
|
|
5
|
+
height: 200
|
|
6
|
+
}, t = 20, _ = 1, n = 0.5, o = 5, c = 0.1, s = -180, R = 180, T = 1, A = "rgba(0, 0, 0, 0.6)", E = "#ffffff", I = 2, D = 3, L = 0.4, M = 12, N = {
|
|
7
|
+
free: null,
|
|
8
|
+
"1:1": 1,
|
|
9
|
+
"4:3": 4 / 3,
|
|
10
|
+
"3:2": 3 / 2,
|
|
11
|
+
"16:9": 16 / 9,
|
|
12
|
+
"2:3": 2 / 3,
|
|
13
|
+
"3:4": 3 / 4,
|
|
14
|
+
"9:16": 9 / 16
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
N as ASPECT_RATIO_VALUES,
|
|
18
|
+
E as BORDER_COLOR,
|
|
19
|
+
I as BORDER_WIDTH,
|
|
20
|
+
O as DEFAULT_CROP,
|
|
21
|
+
L as DEFAULT_GRID_OPACITY,
|
|
22
|
+
_ as DEFAULT_ZOOM,
|
|
23
|
+
D as GRID_LINES,
|
|
24
|
+
M as HANDLE_SIZE,
|
|
25
|
+
R as MAX_ROTATION,
|
|
26
|
+
o as MAX_ZOOM,
|
|
27
|
+
t as MIN_CROP_SIZE,
|
|
28
|
+
s as MIN_ROTATION,
|
|
29
|
+
n as MIN_ZOOM,
|
|
30
|
+
A as OVERLAY_COLOR,
|
|
31
|
+
T as ROTATION_STEP,
|
|
32
|
+
c as ZOOM_STEP
|
|
33
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { CropperProps } from './Cropper.types';
|
|
3
|
+
/**
|
|
4
|
+
* Cropper - Image cropping component with zoom, rotate, and aspect ratio
|
|
5
|
+
*
|
|
6
|
+
* @description
|
|
7
|
+
* Interactive image cropper with handles, zoom, rotation, grid overlay,
|
|
8
|
+
* and aspect ratio presets. Outputs cropped image as data URL.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* <Cropper
|
|
13
|
+
* src="/photo.jpg"
|
|
14
|
+
* aspectRatio="16:9"
|
|
15
|
+
* showZoomSlider
|
|
16
|
+
* showGrid
|
|
17
|
+
* onCropComplete={(crop, url) => console.log(url)}
|
|
18
|
+
* />
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare const Cropper: FC<CropperProps>;
|