@forgedevstack/bear 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/README.md +0 -4
  2. package/dist/components/AnimatedCounter/AnimatedCounter.cjs +1 -0
  3. package/dist/components/AnimatedCounter/AnimatedCounter.const.cjs +1 -0
  4. package/dist/components/AnimatedCounter/AnimatedCounter.const.d.ts +5 -0
  5. package/dist/components/AnimatedCounter/AnimatedCounter.const.js +7 -0
  6. package/dist/components/AnimatedCounter/AnimatedCounter.d.ts +3 -0
  7. package/dist/components/AnimatedCounter/AnimatedCounter.js +59 -0
  8. package/dist/components/AnimatedCounter/AnimatedCounter.types.d.ts +26 -0
  9. package/dist/components/AnimatedCounter/AnimatedCounter.utils.cjs +1 -0
  10. package/dist/components/AnimatedCounter/AnimatedCounter.utils.d.ts +6 -0
  11. package/dist/components/AnimatedCounter/AnimatedCounter.utils.js +13 -0
  12. package/dist/components/AnimatedCounter/index.d.ts +2 -0
  13. package/dist/components/CurrencyInput/CurrencyInput.cjs +1 -0
  14. package/dist/components/CurrencyInput/CurrencyInput.const.cjs +1 -0
  15. package/dist/components/CurrencyInput/CurrencyInput.const.d.ts +4 -0
  16. package/dist/components/CurrencyInput/CurrencyInput.const.js +19 -0
  17. package/dist/components/CurrencyInput/CurrencyInput.d.ts +3 -0
  18. package/dist/components/CurrencyInput/CurrencyInput.js +60 -0
  19. package/dist/components/CurrencyInput/CurrencyInput.types.d.ts +22 -0
  20. package/dist/components/CurrencyInput/CurrencyInput.utils.cjs +1 -0
  21. package/dist/components/CurrencyInput/CurrencyInput.utils.d.ts +2 -0
  22. package/dist/components/CurrencyInput/CurrencyInput.utils.js +14 -0
  23. package/dist/components/CurrencyInput/index.d.ts +2 -0
  24. package/dist/components/DiffViewer/DiffViewer.cjs +1 -1
  25. package/dist/components/DiffViewer/DiffViewer.const.cjs +1 -1
  26. package/dist/components/DiffViewer/DiffViewer.const.d.ts +6 -0
  27. package/dist/components/DiffViewer/DiffViewer.const.js +17 -4
  28. package/dist/components/DiffViewer/DiffViewer.d.ts +0 -14
  29. package/dist/components/DiffViewer/DiffViewer.js +97 -105
  30. package/dist/components/DiffViewer/DiffViewer.types.d.ts +5 -0
  31. package/dist/components/DiffViewer/index.d.ts +1 -1
  32. package/dist/components/GlowCard/GlowCard.cjs +1 -0
  33. package/dist/components/GlowCard/GlowCard.const.cjs +1 -0
  34. package/dist/components/GlowCard/GlowCard.const.d.ts +11 -0
  35. package/dist/components/GlowCard/GlowCard.const.js +13 -0
  36. package/dist/components/GlowCard/GlowCard.d.ts +3 -0
  37. package/dist/components/GlowCard/GlowCard.js +185 -0
  38. package/dist/components/GlowCard/GlowCard.types.d.ts +21 -0
  39. package/dist/components/GlowCard/index.d.ts +2 -0
  40. package/dist/components/Heatmap/Heatmap.cjs +1 -0
  41. package/dist/components/Heatmap/Heatmap.const.cjs +1 -0
  42. package/dist/components/Heatmap/Heatmap.const.d.ts +8 -0
  43. package/dist/components/Heatmap/Heatmap.const.js +11 -0
  44. package/dist/components/Heatmap/Heatmap.d.ts +3 -0
  45. package/dist/components/Heatmap/Heatmap.js +103 -0
  46. package/dist/components/Heatmap/Heatmap.types.d.ts +34 -0
  47. package/dist/components/Heatmap/Heatmap.utils.cjs +1 -0
  48. package/dist/components/Heatmap/Heatmap.utils.d.ts +2 -0
  49. package/dist/components/Heatmap/Heatmap.utils.js +18 -0
  50. package/dist/components/Heatmap/index.d.ts +2 -0
  51. package/dist/components/ImageAnnotation/ImageAnnotation.cjs +1 -0
  52. package/dist/components/ImageAnnotation/ImageAnnotation.const.cjs +1 -0
  53. package/dist/components/ImageAnnotation/ImageAnnotation.const.d.ts +3 -0
  54. package/dist/components/ImageAnnotation/ImageAnnotation.const.js +6 -0
  55. package/dist/components/ImageAnnotation/ImageAnnotation.d.ts +3 -0
  56. package/dist/components/ImageAnnotation/ImageAnnotation.js +113 -0
  57. package/dist/components/ImageAnnotation/ImageAnnotation.types.d.ts +28 -0
  58. package/dist/components/ImageAnnotation/index.d.ts +2 -0
  59. package/dist/components/MediaPlayer/MediaPlayer.cjs +1 -0
  60. package/dist/components/MediaPlayer/MediaPlayer.const.cjs +1 -0
  61. package/dist/components/MediaPlayer/MediaPlayer.const.d.ts +36 -0
  62. package/dist/components/MediaPlayer/MediaPlayer.const.js +11 -0
  63. package/dist/components/MediaPlayer/MediaPlayer.d.ts +3 -0
  64. package/dist/components/MediaPlayer/MediaPlayer.js +279 -0
  65. package/dist/components/MediaPlayer/MediaPlayer.types.d.ts +69 -0
  66. package/dist/components/MediaPlayer/MediaPlayer.utils.cjs +1 -0
  67. package/dist/components/MediaPlayer/MediaPlayer.utils.d.ts +1 -0
  68. package/dist/components/MediaPlayer/MediaPlayer.utils.js +7 -0
  69. package/dist/components/MediaPlayer/index.d.ts +2 -0
  70. package/dist/components/Stepper/Stepper.cjs +1 -1
  71. package/dist/components/Stepper/Stepper.const.cjs +1 -1
  72. package/dist/components/Stepper/Stepper.const.d.ts +25 -4
  73. package/dist/components/Stepper/Stepper.const.js +39 -21
  74. package/dist/components/Stepper/Stepper.d.ts +3 -3
  75. package/dist/components/Stepper/Stepper.js +168 -156
  76. package/dist/components/Stepper/Stepper.types.d.ts +12 -1
  77. package/dist/components/Stepper/Stepper.utils.cjs +1 -0
  78. package/dist/components/Stepper/Stepper.utils.d.ts +12 -0
  79. package/dist/components/Stepper/Stepper.utils.js +19 -0
  80. package/dist/components/Stepper/components/StepperControls.cjs +1 -0
  81. package/dist/components/Stepper/components/StepperControls.d.ts +2 -0
  82. package/dist/components/Stepper/components/StepperControls.js +32 -0
  83. package/dist/components/Stepper/index.d.ts +2 -1
  84. package/dist/components/TagCloud/TagCloud.cjs +1 -0
  85. package/dist/components/TagCloud/TagCloud.const.cjs +1 -0
  86. package/dist/components/TagCloud/TagCloud.const.d.ts +5 -0
  87. package/dist/components/TagCloud/TagCloud.const.js +8 -0
  88. package/dist/components/TagCloud/TagCloud.d.ts +3 -0
  89. package/dist/components/TagCloud/TagCloud.js +76 -0
  90. package/dist/components/TagCloud/TagCloud.types.d.ts +26 -0
  91. package/dist/components/TagCloud/index.d.ts +2 -0
  92. package/dist/components/TimelineChart/TimelineChart.cjs +1 -0
  93. package/dist/components/TimelineChart/TimelineChart.const.cjs +1 -0
  94. package/dist/components/TimelineChart/TimelineChart.const.d.ts +6 -0
  95. package/dist/components/TimelineChart/TimelineChart.const.js +9 -0
  96. package/dist/components/TimelineChart/TimelineChart.d.ts +3 -0
  97. package/dist/components/TimelineChart/TimelineChart.js +65 -0
  98. package/dist/components/TimelineChart/TimelineChart.types.d.ts +31 -0
  99. package/dist/components/TimelineChart/index.d.ts +2 -0
  100. package/dist/components/index.cjs +1 -1
  101. package/dist/components/index.d.ts +17 -1
  102. package/dist/components/index.js +286 -269
  103. package/dist/index.cjs +1 -1
  104. package/dist/index.js +361 -344
  105. package/dist/styles/_effects.css +15 -0
  106. package/dist/styles.css +1 -1
  107. package/package.json +1 -1
@@ -0,0 +1,103 @@
1
+ import { jsxs as N, jsx as s } from "react/jsx-runtime";
2
+ import { useState as D, useRef as I, useMemo as K, useCallback as g } from "react";
3
+ import { cn as V } from "../../utils/cn.js";
4
+ import { Popover as $ } from "../Popover/Popover.js";
5
+ import { Typography as k } from "../Typography/Typography.js";
6
+ import { DEFAULT_EMPTY_COLOR as Z, DEFAULT_COLOR_SCALE as q, DAYS_IN_WEEK as J, MONTH_LABELS as Q, DEFAULT_CELL_SIZE as S, DEFAULT_CELL_GAP as X, DAY_LABELS as G, LABEL_PAD as z } from "./Heatmap.const.js";
7
+ import { getWeeks as ee, toKey as te } from "./Heatmap.utils.js";
8
+ const le = ({
9
+ data: x,
10
+ startDate: p,
11
+ endDate: d,
12
+ colorScale: i = q,
13
+ cellSize: l = S,
14
+ cellGap: c = X,
15
+ showDayLabels: v = !0,
16
+ showMonthLabels: O = !0,
17
+ emptyColor: L,
18
+ tooltipFormat: y,
19
+ onCellClick: f,
20
+ renderTooltip: m,
21
+ testId: b,
22
+ className: P,
23
+ ...F
24
+ }) => {
25
+ const [h, E] = D(null), [R, u] = D(!1), U = I(/* @__PURE__ */ new Map()), { weeks: w, dataMap: Y, maxValue: _ } = K(() => {
26
+ const e = d ? new Date(d) : /* @__PURE__ */ new Date(), a = p ? new Date(p) : new Date(e.getFullYear() - 1, e.getMonth(), e.getDate()), o = /* @__PURE__ */ new Map();
27
+ let n = 0;
28
+ for (const r of x)
29
+ o.set(r.date, r), r.value > n && (n = r.value);
30
+ return { weeks: ee(a, e), dataMap: o, maxValue: n };
31
+ }, [x, p, d]), j = g(
32
+ (e) => {
33
+ if (e === 0 || _ === 0) return L ?? Z;
34
+ const a = Math.min(Math.floor(e / _ * (i.length - 1)), i.length - 1);
35
+ return i[a];
36
+ },
37
+ [_, L, i]
38
+ ), A = v ? 28 : 0, C = g((e) => {
39
+ !e || !m || (E(e), u(!0));
40
+ }, [m]), T = g(() => {
41
+ u(!1), E(null);
42
+ }, []);
43
+ return /* @__PURE__ */ N("div", { className: V("Bear-Heatmap relative inline-block", P), "data-testid": b, ...F, children: [
44
+ O && /* @__PURE__ */ s("div", { className: "Bear-Heatmap__months flex mb-1", style: { paddingLeft: A }, children: w.map((e, a) => {
45
+ const o = e[0], n = a === 0 || o.getDate() <= J;
46
+ return /* @__PURE__ */ s(
47
+ k,
48
+ {
49
+ variant: "caption",
50
+ className: "Bear-Heatmap__month text-gray-400 dark:text-gray-500 text-[10px]",
51
+ style: { width: l + c, textAlign: "left" },
52
+ children: n ? Q[o.getMonth()] : ""
53
+ },
54
+ a
55
+ );
56
+ }) }),
57
+ /* @__PURE__ */ N("div", { className: "Bear-Heatmap__grid flex", children: [
58
+ v && /* @__PURE__ */ s("div", { className: "Bear-Heatmap__days flex flex-col mr-1", style: { gap: c }, children: G.map((e, a) => /* @__PURE__ */ s(
59
+ k,
60
+ {
61
+ variant: "caption",
62
+ className: "Bear-Heatmap__day text-gray-400 dark:text-gray-500 text-[10px] flex items-center justify-end",
63
+ style: { height: l, width: A - z },
64
+ children: e
65
+ },
66
+ a
67
+ )) }),
68
+ /* @__PURE__ */ s("div", { className: "Bear-Heatmap__weeks flex", style: { gap: c }, children: w.map((e, a) => /* @__PURE__ */ s("div", { className: "Bear-Heatmap__week flex flex-col", style: { gap: c }, children: e.map((o, n) => {
69
+ const r = te(o), t = Y.get(r), M = (t == null ? void 0 : t.value) ?? 0, W = j(M), B = /* @__PURE__ */ s(
70
+ "div",
71
+ {
72
+ ref: (H) => {
73
+ H && U.current.set(r, H);
74
+ },
75
+ className: "Bear-Heatmap__cell rounded-sm cursor-pointer transition-transform hover:scale-125",
76
+ style: { width: l, height: l, backgroundColor: W },
77
+ title: m ? void 0 : t ? y ? y(t) : `${r}: ${M}` : r,
78
+ onClick: () => t && (f == null ? void 0 : f(t)),
79
+ onMouseEnter: () => C(t),
80
+ onMouseLeave: T
81
+ },
82
+ n
83
+ );
84
+ return m && t && (h == null ? void 0 : h.date) === t.date ? /* @__PURE__ */ s(
85
+ $,
86
+ {
87
+ content: m(t),
88
+ trigger: "hover",
89
+ placement: "top",
90
+ open: R,
91
+ onOpenChange: u,
92
+ arrow: !1,
93
+ children: B
94
+ },
95
+ n
96
+ ) : B;
97
+ }) }, a)) })
98
+ ] })
99
+ ] });
100
+ };
101
+ export {
102
+ le as Heatmap
103
+ };
@@ -0,0 +1,34 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ export interface HeatmapCell {
3
+ date: string;
4
+ value: number;
5
+ label?: string;
6
+ }
7
+ export interface HeatmapProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
8
+ /** Data points with date strings (YYYY-MM-DD) and values */
9
+ data: HeatmapCell[];
10
+ /** Start date (defaults to 1 year ago) */
11
+ startDate?: string;
12
+ /** End date (defaults to today) */
13
+ endDate?: string;
14
+ /** Color scale: array of colors from low to high */
15
+ colorScale?: string[];
16
+ /** Cell size in px */
17
+ cellSize?: number;
18
+ /** Gap between cells in px */
19
+ cellGap?: number;
20
+ /** Show day-of-week labels */
21
+ showDayLabels?: boolean;
22
+ /** Show month labels */
23
+ showMonthLabels?: boolean;
24
+ /** Empty cell color */
25
+ emptyColor?: string;
26
+ /** Tooltip formatter */
27
+ tooltipFormat?: (cell: HeatmapCell) => string;
28
+ /** Callback when a cell is clicked */
29
+ onCellClick?: (cell: HeatmapCell) => void;
30
+ /** Render custom hover content per cell */
31
+ renderTooltip?: (cell: HeatmapCell) => ReactNode;
32
+ /** Test ID */
33
+ testId?: string;
34
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./Heatmap.const.cjs");function c(t,r){const n=[],e=new Date(t);for(e.setDate(e.getDate()-e.getDay());e<=r;){const o=[];for(let s=0;s<a.DAYS_IN_WEEK;s++)o.push(new Date(e)),e.setDate(e.getDate()+1);n.push(o)}return n}function u(t){return t.toISOString().slice(0,10)}exports.getWeeks=c;exports.toKey=u;
@@ -0,0 +1,2 @@
1
+ export declare function getWeeks(start: Date, end: Date): Date[][];
2
+ export declare function toKey(d: Date): string;
@@ -0,0 +1,18 @@
1
+ import { DAYS_IN_WEEK as D } from "./Heatmap.const.js";
2
+ function c(t, s) {
3
+ const n = [], e = new Date(t);
4
+ for (e.setDate(e.getDate() - e.getDay()); e <= s; ) {
5
+ const o = [];
6
+ for (let r = 0; r < D; r++)
7
+ o.push(new Date(e)), e.setDate(e.getDate() + 1);
8
+ n.push(o);
9
+ }
10
+ return n;
11
+ }
12
+ function u(t) {
13
+ return t.toISOString().slice(0, 10);
14
+ }
15
+ export {
16
+ c as getWeeks,
17
+ u as toKey
18
+ };
@@ -0,0 +1,2 @@
1
+ export { Heatmap } from './Heatmap';
2
+ export type { HeatmapProps, HeatmapCell } from './Heatmap.types';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),n=require("react"),q=require("../../utils/cn.cjs"),k=require("../Icon/index.cjs"),P=require("../Popover/Popover.cjs"),R=require("../Input/Input.cjs"),_=require("./ImageAnnotation.const.cjs");let T=1;function L(o,a,r,t){return c.jsx("div",{className:"Bear-ImageAnnotation__edit min-w-[160px]",children:c.jsx(R.Input,{autoFocus:!0,size:"sm",value:o,onChange:s=>a(s.target.value),onKeyDown:s=>{s.key==="Enter"&&r(),s.key==="Escape"&&t()},placeholder:"Add note..."})})}function O(o,a,r,t){return c.jsxs("div",{className:"Bear-ImageAnnotation__label text-xs text-gray-700 dark:text-gray-200 whitespace-nowrap flex items-center gap-1",children:[t??o.text,a&&c.jsx("button",{type:"button",className:"text-red-400 hover:text-red-600 ml-1",onClick:s=>{s.stopPropagation(),r(o.id)},children:c.jsx(k.BearIcons.XIcon,{size:12})})]})}const D=({src:o,alt:a="",annotations:r,onChange:t,editable:s=!0,pinColor:A=_.DEFAULT_PIN_COLOR,pinSize:x=_.DEFAULT_PIN_SIZE,renderPopover:f,testId:j,className:y,...b})=>{const p=n.useRef(null),[i,u]=n.useState(null),[d,v]=n.useState(""),h=n.useCallback(e=>{if(!s||!t||!p.current||e.target.closest(".Bear-ImageAnnotation__pin"))return;const l=p.current.getBoundingClientRect(),I=(e.clientX-l.left)/l.width*100,g=(e.clientY-l.top)/l.height*100,m=`ann-${T++}`,B={id:m,x:I,y:g,text:""};t([...r,B]),u(m),v("")},[s,t,r]),N=n.useCallback(()=>{!i||!t||(d.trim()?t(r.map(e=>e.id===i?{...e,text:d}:e)):t(r.filter(e=>e.id!==i)),u(null))},[i,d,t,r]),w=n.useCallback(()=>u(null),[]),E=n.useCallback(e=>{t==null||t(r.filter(l=>l.id!==e)),i===e&&u(null)},[t,r,i]);return c.jsxs("div",{ref:p,className:q.cn("Bear-ImageAnnotation relative inline-block select-none",s&&"cursor-crosshair",y),onClick:h,"data-testid":j,...b,children:[c.jsx("img",{src:o,alt:a,className:"w-full h-auto block rounded-lg",draggable:!1}),r.map(e=>{const l=i===e.id,I=!!e.text,g=f==null?void 0:f(e),m=l?L(d,v,N,w):I?O(e,s,E,g):null;return c.jsx("div",{className:"Bear-ImageAnnotation__pin absolute transform -translate-x-1/2 -translate-y-full z-10",style:{left:`${e.x}%`,top:`${e.y}%`},children:c.jsx(P.Popover,{content:m,trigger:l?"click":"hover",placement:"top",open:l||void 0,arrow:!1,children:c.jsx("div",{className:"Bear-ImageAnnotation__marker flex items-center justify-center rounded-full shadow-lg cursor-pointer transition-transform hover:scale-110",style:{width:x,height:x,backgroundColor:e.color??A},children:c.jsx(k.BearIcons.MapPinIcon,{size:x*_.PIN_ICON_RATIO,className:"text-white"})})})},e.id)})]})};exports.ImageAnnotation=D;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I="#ec4899",_=24,t=.6;exports.DEFAULT_PIN_COLOR=I;exports.DEFAULT_PIN_SIZE=_;exports.PIN_ICON_RATIO=t;
@@ -0,0 +1,3 @@
1
+ export declare const DEFAULT_PIN_COLOR = "#ec4899";
2
+ export declare const DEFAULT_PIN_SIZE = 24;
3
+ export declare const PIN_ICON_RATIO = 0.6;
@@ -0,0 +1,6 @@
1
+ const I = "#ec4899", _ = 24, c = 0.6;
2
+ export {
3
+ I as DEFAULT_PIN_COLOR,
4
+ _ as DEFAULT_PIN_SIZE,
5
+ c as PIN_ICON_RATIO
6
+ };
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { ImageAnnotationProps } from './ImageAnnotation.types';
3
+ export declare const ImageAnnotation: FC<ImageAnnotationProps>;
@@ -0,0 +1,113 @@
1
+ import { jsxs as h, jsx as l } from "react/jsx-runtime";
2
+ import { useRef as R, useState as v, useCallback as u } from "react";
3
+ import { cn as T } from "../../utils/cn.js";
4
+ import { BearIcons as A } from "../Icon/index.js";
5
+ import { Popover as O } from "../Popover/Popover.js";
6
+ import { Input as j } from "../Input/Input.js";
7
+ import { DEFAULT_PIN_COLOR as D, DEFAULT_PIN_SIZE as F, PIN_ICON_RATIO as $ } from "./ImageAnnotation.const.js";
8
+ let z = 1;
9
+ function U(s, n, r, e) {
10
+ return /* @__PURE__ */ l("div", { className: "Bear-ImageAnnotation__edit min-w-[160px]", children: /* @__PURE__ */ l(
11
+ j,
12
+ {
13
+ autoFocus: !0,
14
+ size: "sm",
15
+ value: s,
16
+ onChange: (o) => n(o.target.value),
17
+ onKeyDown: (o) => {
18
+ o.key === "Enter" && r(), o.key === "Escape" && e();
19
+ },
20
+ placeholder: "Add note..."
21
+ }
22
+ ) });
23
+ }
24
+ function X(s, n, r, e) {
25
+ return /* @__PURE__ */ h("div", { className: "Bear-ImageAnnotation__label text-xs text-gray-700 dark:text-gray-200 whitespace-nowrap flex items-center gap-1", children: [
26
+ e ?? s.text,
27
+ n && /* @__PURE__ */ l(
28
+ "button",
29
+ {
30
+ type: "button",
31
+ className: "text-red-400 hover:text-red-600 ml-1",
32
+ onClick: (o) => {
33
+ o.stopPropagation(), r(s.id);
34
+ },
35
+ children: /* @__PURE__ */ l(A.XIcon, { size: 12 })
36
+ }
37
+ )
38
+ ] });
39
+ }
40
+ const J = ({
41
+ src: s,
42
+ alt: n = "",
43
+ annotations: r,
44
+ onChange: e,
45
+ editable: o = !0,
46
+ pinColor: k = D,
47
+ pinSize: f = F,
48
+ renderPopover: p,
49
+ testId: y,
50
+ className: N,
51
+ ...w
52
+ }) => {
53
+ const x = R(null), [c, a] = v(null), [d, _] = v(""), E = u(
54
+ (t) => {
55
+ if (!o || !e || !x.current || t.target.closest(".Bear-ImageAnnotation__pin")) return;
56
+ const i = x.current.getBoundingClientRect(), I = (t.clientX - i.left) / i.width * 100, g = (t.clientY - i.top) / i.height * 100, m = `ann-${z++}`, P = { id: m, x: I, y: g, text: "" };
57
+ e([...r, P]), a(m), _("");
58
+ },
59
+ [o, e, r]
60
+ ), B = u(() => {
61
+ !c || !e || (d.trim() ? e(r.map((t) => t.id === c ? { ...t, text: d } : t)) : e(r.filter((t) => t.id !== c)), a(null));
62
+ }, [c, d, e, r]), b = u(() => a(null), []), L = u(
63
+ (t) => {
64
+ e == null || e(r.filter((i) => i.id !== t)), c === t && a(null);
65
+ },
66
+ [e, r, c]
67
+ );
68
+ return /* @__PURE__ */ h(
69
+ "div",
70
+ {
71
+ ref: x,
72
+ className: T("Bear-ImageAnnotation relative inline-block select-none", o && "cursor-crosshair", N),
73
+ onClick: E,
74
+ "data-testid": y,
75
+ ...w,
76
+ children: [
77
+ /* @__PURE__ */ l("img", { src: s, alt: n, className: "w-full h-auto block rounded-lg", draggable: !1 }),
78
+ r.map((t) => {
79
+ const i = c === t.id, I = !!t.text, g = p == null ? void 0 : p(t), m = i ? U(d, _, B, b) : I ? X(t, o, L, g) : null;
80
+ return /* @__PURE__ */ l(
81
+ "div",
82
+ {
83
+ className: "Bear-ImageAnnotation__pin absolute transform -translate-x-1/2 -translate-y-full z-10",
84
+ style: { left: `${t.x}%`, top: `${t.y}%` },
85
+ children: /* @__PURE__ */ l(
86
+ O,
87
+ {
88
+ content: m,
89
+ trigger: i ? "click" : "hover",
90
+ placement: "top",
91
+ open: i || void 0,
92
+ arrow: !1,
93
+ children: /* @__PURE__ */ l(
94
+ "div",
95
+ {
96
+ className: "Bear-ImageAnnotation__marker flex items-center justify-center rounded-full shadow-lg cursor-pointer transition-transform hover:scale-110",
97
+ style: { width: f, height: f, backgroundColor: t.color ?? k },
98
+ children: /* @__PURE__ */ l(A.MapPinIcon, { size: f * $, className: "text-white" })
99
+ }
100
+ )
101
+ }
102
+ )
103
+ },
104
+ t.id
105
+ );
106
+ })
107
+ ]
108
+ }
109
+ );
110
+ };
111
+ export {
112
+ J as ImageAnnotation
113
+ };
@@ -0,0 +1,28 @@
1
+ import { HTMLAttributes, ReactNode } from 'react';
2
+ export interface Annotation {
3
+ id: string;
4
+ x: number;
5
+ y: number;
6
+ text: string;
7
+ color?: string;
8
+ }
9
+ export interface ImageAnnotationProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onChange'> {
10
+ /** Image source URL */
11
+ src: string;
12
+ /** Alt text */
13
+ alt?: string;
14
+ /** Current annotations */
15
+ annotations: Annotation[];
16
+ /** Called when annotations change (add/edit/delete) */
17
+ onChange?: (annotations: Annotation[]) => void;
18
+ /** Whether the user can add new annotations by clicking */
19
+ editable?: boolean;
20
+ /** Pin color */
21
+ pinColor?: string;
22
+ /** Pin size in px */
23
+ pinSize?: number;
24
+ /** Render custom popover content for each annotation */
25
+ renderPopover?: (annotation: Annotation) => ReactNode;
26
+ /** Test ID */
27
+ testId?: string;
28
+ }
@@ -0,0 +1,2 @@
1
+ export { ImageAnnotation } from './ImageAnnotation';
2
+ export type { ImageAnnotationProps, Annotation } from './ImageAnnotation.types';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),m=require("../../utils/cn.cjs"),r=require("../Icon/index.cjs"),j=require("./MediaPlayer.const.cjs"),C=require("./MediaPlayer.utils.cjs"),Te=require("../../hooks/useBearStyles.cjs"),Re=320,le=16,ze=({src:D,type:T="video",poster:R,autoPlay:z=!1,loop:L=!1,muted:G=!1,nativeControls:k=!1,width:A,height:H,size:ce="md",accentColor:u=j.DEFAULT_ACCENT,playIcon:Y,pauseIcon:Z,muteIcon:de,unmuteIcon:ue,fullscreenIcon:xe,centerOverlay:me=!1,sticky:q=!1,stickyPosition:$="right",stickySize:U=Re,airPlay:he=!1,playlist:w,onTrackChange:I,bis:fe,testId:ye,className:ge,style:ve,...pe})=>{const h=s.useRef(null),W=s.useRef(null),K=s.useRef(null),[b,F]=s.useState(z),[N,V]=s.useState(0),[g,X]=s.useState(0),[S,be]=s.useState(G),[f,J]=s.useState(L),[M,je]=s.useState(!1),[Q,ke]=s.useState(0),[Ne,_]=s.useState(!z),[l,we]=s.useState(0),O=Te.useBearStyles(fe,ve),x=s.useMemo(()=>w&&w.length>0?w:[{src:D,poster:R,type:T,title:void 0,artist:void 0}],[w,D,R,T]),o=x[l],Ie=o.src,B=o.poster??R,c=o.type??T,d=x.length>1,i=j.SIZE_MAP[ce];s.useEffect(()=>{J(L)},[L]),s.useEffect(()=>{const t=h.current;if(!t)return;const n=()=>V(t.currentTime),a=()=>X(t.duration),p=()=>{d&&l<x.length-1?v(l+1):f?d&&v(0):(F(!1),_(!0))};return t.addEventListener("timeupdate",n),t.addEventListener("loadedmetadata",a),t.addEventListener("ended",p),()=>{t.removeEventListener("timeupdate",n),t.removeEventListener("loadedmetadata",a),t.removeEventListener("ended",p)}},[f,d,l,x.length]),s.useEffect(()=>{if(!q||c!=="video")return;const t=K.current;if(!t)return;const n=()=>{const p=t.getBoundingClientRect().bottom<0;je(p),p&&ke(le)};return window.addEventListener("scroll",n,{passive:!0}),n(),()=>window.removeEventListener("scroll",n)},[q,c]);const v=s.useCallback(t=>{const n=Math.max(0,Math.min(x.length-1,t));we(n),V(0),X(0),_(!1),I==null||I(n,x[n]),setTimeout(()=>{const a=h.current;a&&(a.load(),a.play().catch(()=>{}),F(!0))},50)},[x,I]),E=s.useCallback(()=>{const t=h.current;t&&(b?(t.pause(),_(!0)):(t.play().catch(()=>{}),_(!1)),F(!b))},[b]),ee=s.useCallback(t=>{const n=h.current;if(!n||!g)return;const a=t.currentTarget.getBoundingClientRect(),p=Math.max(0,Math.min(1,(t.clientX-a.left)/a.width));n.currentTime=p*g},[g]),te=s.useCallback(()=>{const t=h.current;t&&(t.muted=!S,be(!S))},[S]),se=s.useCallback(()=>{const t=!f;J(t);const n=h.current;n&&(n.loop=t)},[f]),Se=s.useCallback(()=>{var n;const t=W.current;t&&(document.fullscreenElement?document.exitFullscreen():(n=t.requestFullscreen)==null||n.call(t))},[]),Me=s.useCallback(()=>{const t=h.current;t!=null&&t.webkitShowPlaybackTargetPicker&&t.webkitShowPlaybackTargetPicker()},[]),ne=s.useCallback(()=>{if(N>3){const t=h.current;t&&(t.currentTime=0)}else l>0&&v(l-1)},[N,l,v]),ae=s.useCallback(()=>{l<x.length-1&&v(l+1)},[l,x.length,v]),re=g?N/g*100:0,y=i.iconSm,P=i.iconMd,ie=b?Z??e.jsx(r.BearIcons.PauseIcon,{size:P}):Y??e.jsx(r.BearIcons.PlayIcon,{size:P}),oe=S?de??e.jsx(r.BearIcons.VolumeOffIcon,{size:y}):ue??e.jsx(r.BearIcons.VolumeUpIcon,{size:y}),_e=xe??e.jsx(r.BearIcons.MaximizeIcon,{size:y}),Be=c==="video"?"video":"audio",Ee=s.useMemo(()=>M&&c==="video"?{...O,position:"fixed",top:Q,[$==="left"?"left":"right"]:le,width:U,zIndex:50,boxShadow:"0 8px 32px rgba(0,0,0,0.45)",borderRadius:12,transition:"top 0.15s ease-out"}:{...O,width:A??"100%",height:H,maxWidth:A?void 0:i.maxWidth},[M,c,O,A,H,i.maxWidth,Q,$,U]),Pe=s.useMemo(()=>{if(!M)return{aspectRatio:i.aspectRatio}},[M,i.aspectRatio]),Ce=`${u}20`;return e.jsxs(e.Fragment,{children:[q&&e.jsx("div",{ref:K,style:{height:1}}),e.jsxs("div",{ref:W,className:m.cn("Bear-MediaPlayer relative rounded-xl overflow-hidden bg-black",ge),style:Ee,"data-testid":ye,...pe,children:[e.jsx(Be,{ref:h,src:Ie,poster:B,autoPlay:z,loop:f&&!d,muted:G,controls:k,playsInline:!0,className:m.cn(c==="video"?"Bear-MediaPlayer__video w-full object-cover":"hidden"),style:c==="video"?Pe:void 0,onClick:c==="video"?E:void 0}),me&&c==="video"&&Ne&&!k&&e.jsx("button",{type:"button",onClick:E,className:"Bear-MediaPlayer__overlay absolute inset-0 flex items-center justify-center bg-black/30 transition-opacity",children:e.jsx("div",{className:"w-16 h-16 rounded-full bg-white/90 flex items-center justify-center shadow-lg",children:b?Z??e.jsx(r.BearIcons.PauseIcon,{size:j.CENTER_ICON_SIZE,className:"text-gray-900"}):Y??e.jsx(r.BearIcons.PlayIcon,{size:j.CENTER_ICON_SIZE,className:"text-gray-900"})})}),!k&&c==="video"&&e.jsxs("div",{className:m.cn("Bear-MediaPlayer__controls absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/80 to-transparent pt-8",i.padding),children:[e.jsx("div",{className:"Bear-MediaPlayer__progress w-full cursor-pointer mb-2 group",style:{height:j.PROGRESS_HEIGHT},onClick:ee,children:e.jsx("div",{className:"w-full h-full bg-white/30 rounded-full relative overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${re}%`,backgroundColor:u}})})}),e.jsxs("div",{className:m.cn("Bear-MediaPlayer__bar flex items-center",i.gap),children:[d&&e.jsx("button",{type:"button",onClick:ne,className:"text-white hover:text-pink-400 transition-colors",children:e.jsx(r.BearIcons.SkipBackIcon,{size:y})}),e.jsx("button",{type:"button",onClick:E,className:"text-white hover:text-pink-400 transition-colors",children:ie}),d&&e.jsx("button",{type:"button",onClick:ae,className:"text-white hover:text-pink-400 transition-colors",children:e.jsx(r.BearIcons.SkipForwardIcon,{size:y})}),e.jsx("button",{type:"button",onClick:te,className:"text-white hover:text-pink-400 transition-colors",children:oe}),e.jsxs("span",{className:m.cn("Bear-MediaPlayer__time text-white font-mono",i.text),children:[C.formatTime(N)," / ",C.formatTime(g)]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{type:"button",onClick:se,className:"transition-colors",style:{color:f?u:void 0},title:"Loop",children:e.jsx(r.BearIcons.RepeatIcon,{size:y,className:f?void 0:"text-white/60 hover:text-white"})}),he&&e.jsx("button",{type:"button",onClick:Me,className:"text-white hover:text-pink-400 transition-colors",title:"AirPlay",children:e.jsx(r.BearIcons.CastIcon,{size:y})}),e.jsx("button",{type:"button",onClick:Se,className:"text-white hover:text-pink-400 transition-colors",children:_e})]}),d&&o.title&&e.jsxs("div",{className:"mt-1 flex items-center gap-2 truncate",children:[e.jsx("span",{className:"text-white text-xs font-medium truncate",children:o.title}),o.artist&&e.jsxs("span",{className:"text-white/50 text-xs truncate",children:["— ",o.artist]})]})]}),c==="audio"&&!k&&e.jsxs("div",{className:m.cn("Bear-MediaPlayer__audio bg-gray-100 dark:bg-zinc-800 rounded-xl",i.padding),children:[d&&(B||o.title)&&e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[B&&e.jsx("img",{src:B,alt:"",className:"w-12 h-12 rounded-lg object-cover shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[o.title&&e.jsx("p",{className:"text-sm font-semibold text-gray-900 dark:text-white truncate",children:o.title}),o.artist&&e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400 truncate",children:o.artist})]})]}),e.jsx("div",{className:"Bear-MediaPlayer__progress w-full cursor-pointer mb-1",style:{height:j.PROGRESS_HEIGHT},onClick:ee,children:e.jsx("div",{className:"w-full h-full bg-gray-300 dark:bg-zinc-600 rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${re}%`,backgroundColor:u}})})}),e.jsxs("div",{className:"flex justify-between mb-2",children:[e.jsx("span",{className:m.cn("text-gray-500 font-mono",i.text),children:C.formatTime(N)}),e.jsx("span",{className:m.cn("text-gray-500 font-mono",i.text),children:C.formatTime(g)})]}),e.jsxs("div",{className:m.cn("flex items-center justify-center",i.gap),children:[e.jsx("button",{type:"button",onClick:se,className:"transition-colors",style:{color:f?u:void 0},title:"Loop",children:e.jsx(r.BearIcons.RepeatIcon,{size:y,className:f?void 0:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"})}),d&&e.jsx("button",{type:"button",onClick:ne,className:"text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white transition-colors",children:e.jsx(r.BearIcons.SkipBackIcon,{size:P})}),e.jsx("button",{type:"button",onClick:E,className:"Bear-MediaPlayer__play w-10 h-10 rounded-full flex items-center justify-center text-white transition-colors",style:{backgroundColor:u},children:ie}),d&&e.jsx("button",{type:"button",onClick:ae,className:"text-gray-600 dark:text-gray-300 hover:text-gray-900 dark:hover:text-white transition-colors",children:e.jsx(r.BearIcons.SkipForwardIcon,{size:P})}),e.jsx("button",{type:"button",onClick:te,className:"text-gray-500 hover:text-gray-700 dark:hover:text-gray-300",children:oe})]})]}),d&&!k&&e.jsx("div",{className:"Bear-MediaPlayer__playlist bg-gray-50 dark:bg-zinc-900 border-t border-gray-200 dark:border-zinc-700 max-h-48 overflow-y-auto",children:x.map((t,n)=>{const a=n===l;return e.jsxs("button",{type:"button",onClick:()=>v(n),className:m.cn("w-full flex items-center gap-3 px-3 py-2 text-left transition-colors",!a&&"hover:bg-gray-100 dark:hover:bg-zinc-800"),style:a?{backgroundColor:Ce}:void 0,children:[t.poster&&e.jsx("img",{src:t.poster,alt:"",className:"w-8 h-8 rounded object-cover shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-medium truncate",style:a?{color:u}:void 0,children:t.title??`Track ${n+1}`}),t.artist&&e.jsx("p",{className:"text-[10px] text-gray-400 truncate",children:t.artist})]}),a&&b&&e.jsxs("div",{className:"flex items-end gap-0.5 h-3",children:[e.jsx("span",{className:"w-0.5 rounded-full animate-pulse",style:{height:"60%",backgroundColor:u}}),e.jsx("span",{className:"w-0.5 rounded-full animate-pulse",style:{height:"100%",backgroundColor:u,animationDelay:"0.2s"}}),e.jsx("span",{className:"w-0.5 rounded-full animate-pulse",style:{height:"40%",backgroundColor:u,animationDelay:"0.4s"}})]}),e.jsx("span",{className:"text-[10px] text-gray-400 tabular-nums shrink-0",children:n+1})]},n)})})]})]})};exports.MediaPlayer=ze;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t="#ec4899",a=4,i=48,e={sm:{maxWidth:360,aspectRatio:"4 / 3",padding:"p-2",gap:"gap-2",text:"text-[10px]",iconSm:14,iconMd:16},md:{maxWidth:640,aspectRatio:"16 / 9",padding:"p-3",gap:"gap-3",text:"text-xs",iconSm:18,iconMd:20},lg:{maxWidth:960,aspectRatio:"21 / 9",padding:"p-4",gap:"gap-4",text:"text-sm",iconSm:20,iconMd:24}};exports.CENTER_ICON_SIZE=i;exports.DEFAULT_ACCENT=t;exports.PROGRESS_HEIGHT=a;exports.SIZE_MAP=e;
@@ -0,0 +1,36 @@
1
+ export declare const DEFAULT_ACCENT = "#ec4899";
2
+ export declare const PROGRESS_HEIGHT = 4;
3
+ export declare const ICON_SM = 18;
4
+ export declare const ICON_MD = 20;
5
+ export declare const STICKY_WIDTH = 340;
6
+ export declare const STICKY_OFFSET = 16;
7
+ export declare const CENTER_ICON_SIZE = 48;
8
+ export declare const SIZE_MAP: {
9
+ readonly sm: {
10
+ readonly maxWidth: 360;
11
+ readonly aspectRatio: "4 / 3";
12
+ readonly padding: "p-2";
13
+ readonly gap: "gap-2";
14
+ readonly text: "text-[10px]";
15
+ readonly iconSm: 14;
16
+ readonly iconMd: 16;
17
+ };
18
+ readonly md: {
19
+ readonly maxWidth: 640;
20
+ readonly aspectRatio: "16 / 9";
21
+ readonly padding: "p-3";
22
+ readonly gap: "gap-3";
23
+ readonly text: "text-xs";
24
+ readonly iconSm: 18;
25
+ readonly iconMd: 20;
26
+ };
27
+ readonly lg: {
28
+ readonly maxWidth: 960;
29
+ readonly aspectRatio: "21 / 9";
30
+ readonly padding: "p-4";
31
+ readonly gap: "gap-4";
32
+ readonly text: "text-sm";
33
+ readonly iconSm: 20;
34
+ readonly iconMd: 24;
35
+ };
36
+ };
@@ -0,0 +1,11 @@
1
+ const t = "#ec4899", a = 4, p = 48, i = {
2
+ sm: { maxWidth: 360, aspectRatio: "4 / 3", padding: "p-2", gap: "gap-2", text: "text-[10px]", iconSm: 14, iconMd: 16 },
3
+ md: { maxWidth: 640, aspectRatio: "16 / 9", padding: "p-3", gap: "gap-3", text: "text-xs", iconSm: 18, iconMd: 20 },
4
+ lg: { maxWidth: 960, aspectRatio: "21 / 9", padding: "p-4", gap: "gap-4", text: "text-sm", iconSm: 20, iconMd: 24 }
5
+ };
6
+ export {
7
+ p as CENTER_ICON_SIZE,
8
+ t as DEFAULT_ACCENT,
9
+ a as PROGRESS_HEIGHT,
10
+ i as SIZE_MAP
11
+ };
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { MediaPlayerProps } from './MediaPlayer.types';
3
+ export declare const MediaPlayer: FC<MediaPlayerProps>;