@dotss/tictoccroc 0.0.2 → 0.0.3

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 (72) hide show
  1. package/dist/LessonNotesSection-Bg1DHFxg.js +208 -0
  2. package/dist/index.mjs +102 -100
  3. package/dist/shared/components/Carousel/Carousel.mjs +87 -82
  4. package/dist/shared/components/Masonry/Masonry.mjs +157 -139
  5. package/dist/shared/components/Masonry/Masonry.utils.d.ts +5 -1
  6. package/dist/shared/components/Masonry/Masonry.utils.mjs +53 -52
  7. package/dist/shared/components/Masonry/MasonryBlock/MasonryBlock.d.ts +5 -0
  8. package/dist/shared/components/Masonry/MasonryBlock/MasonryBlock.mjs +93 -59
  9. package/dist/shared/components/MediaDialog/MediaBlock/MediaBlock.d.ts +9 -0
  10. package/dist/shared/components/MediaDialog/MediaBlock/MediaBlock.mjs +70 -0
  11. package/dist/shared/components/MediaDialog/MediaBlock/index.d.ts +2 -0
  12. package/dist/shared/components/MediaDialog/MediaBlock/index.mjs +4 -0
  13. package/dist/shared/components/MediaDialog/MediaDialog.d.ts +13 -0
  14. package/dist/shared/components/MediaDialog/MediaDialog.mjs +327 -0
  15. package/dist/shared/components/MediaDialog/MediaDialogContent/MediaDialogContent.d.ts +3 -0
  16. package/dist/shared/components/{ImageZoomDialog/ImageZoomDialogContent/ImageZoomDialogContent.mjs → MediaDialog/MediaDialogContent/MediaDialogContent.mjs} +2 -2
  17. package/dist/shared/components/MediaDialog/MediaDialogContent/index.d.ts +2 -0
  18. package/dist/shared/components/MediaDialog/MediaDialogContent/index.mjs +4 -0
  19. package/dist/shared/components/MediaDialog/MediaDialogFooter/MediaDialogFooter.d.ts +3 -0
  20. package/dist/shared/components/MediaDialog/MediaDialogFooter/index.d.ts +2 -0
  21. package/dist/shared/components/MediaDialog/MediaDialogFooter/index.mjs +4 -0
  22. package/dist/shared/components/MediaDialog/MediaDialogToolbar/MediaDialogToolbar.d.ts +3 -0
  23. package/dist/shared/components/{ImageZoomDialog/ImageZoomDialogToolbar/ImageZoomDialogToolbar.mjs → MediaDialog/MediaDialogToolbar/MediaDialogToolbar.mjs} +6 -6
  24. package/dist/shared/components/MediaDialog/MediaDialogToolbar/index.d.ts +2 -0
  25. package/dist/shared/components/MediaDialog/MediaDialogToolbar/index.mjs +4 -0
  26. package/dist/shared/components/MediaDialog/index.d.ts +7 -0
  27. package/dist/shared/components/MediaDialog/index.mjs +12 -0
  28. package/dist/shared/components/Roller/Roller.d.ts +1 -1
  29. package/dist/shared/components/Roller/Roller.mjs +1 -1
  30. package/dist/shared/components/Roller/index.mjs +1 -1
  31. package/dist/shared/components/Scheduler/ScheduleEvent/ScheduleEvent.mjs +1 -1
  32. package/dist/shared/components/Scheduler/Scheduler.d.ts +2 -1
  33. package/dist/shared/components/Scheduler/Scheduler.mjs +224 -220
  34. package/dist/shared/components/Swiper/Swiper.mjs +53 -62
  35. package/dist/shared/components/index.d.ts +2 -2
  36. package/dist/shared/components/index.mjs +36 -34
  37. package/dist/teacher/profile/components/AbilityCollection/AbilityBadge/AbilityBadge.mjs +49 -47
  38. package/dist/teacher/profile/components/AbilityCollection/AbilityCollection.mjs +27 -28
  39. package/dist/teacher/profile/components/AbilityCollection/AbilityCollection.utils.mjs +2 -2
  40. package/dist/teacher/profile/components/ActivityGallery/ActivityGallery.mjs +52 -47
  41. package/dist/teacher/profile/components/ActivityGallery/ActivityGalleryItem/ActivityGalleryItem.d.ts +3 -2
  42. package/dist/teacher/profile/components/ActivityGallery/ActivityGalleryItem/ActivityGalleryItem.mjs +33 -61
  43. package/dist/teacher/profile/components/AvailableScheduleSection/AvailableScheduleSection.mjs +38 -24
  44. package/dist/teacher/profile/components/CareerSection/CareerSection.d.ts +2 -2
  45. package/dist/teacher/profile/components/CareerSection/CareerSection.mjs +2 -2
  46. package/dist/teacher/profile/components/CertificationSection/CertificationSection.d.ts +2 -2
  47. package/dist/teacher/profile/components/CertificationSection/CertificationSection.mjs +2 -2
  48. package/dist/teacher/profile/components/EducationSection/EducationSection.d.ts +2 -2
  49. package/dist/teacher/profile/components/EducationSection/EducationSection.mjs +2 -2
  50. package/dist/teacher/profile/components/LessonNotesSection/LessonNotesSection.mjs +1 -1
  51. package/dist/teacher/profile/components/LessonNotesSection/index.mjs +1 -1
  52. package/dist/teacher/profile/components/index.mjs +1 -1
  53. package/package.json +1 -1
  54. package/dist/LessonNotesSection-a2QNdQtj.js +0 -196
  55. package/dist/shared/components/ImageZoomDialog/ImageBlock/ImageBlock.d.ts +0 -8
  56. package/dist/shared/components/ImageZoomDialog/ImageBlock/ImageBlock.mjs +0 -36
  57. package/dist/shared/components/ImageZoomDialog/ImageBlock/index.d.ts +0 -2
  58. package/dist/shared/components/ImageZoomDialog/ImageBlock/index.mjs +0 -4
  59. package/dist/shared/components/ImageZoomDialog/ImageZoomDialog.d.ts +0 -16
  60. package/dist/shared/components/ImageZoomDialog/ImageZoomDialog.mjs +0 -323
  61. package/dist/shared/components/ImageZoomDialog/ImageZoomDialogContent/ImageZoomDialogContent.d.ts +0 -3
  62. package/dist/shared/components/ImageZoomDialog/ImageZoomDialogContent/index.d.ts +0 -2
  63. package/dist/shared/components/ImageZoomDialog/ImageZoomDialogContent/index.mjs +0 -4
  64. package/dist/shared/components/ImageZoomDialog/ImageZoomDialogFooter/ImageZoomDialogFooter.d.ts +0 -3
  65. package/dist/shared/components/ImageZoomDialog/ImageZoomDialogFooter/index.d.ts +0 -2
  66. package/dist/shared/components/ImageZoomDialog/ImageZoomDialogFooter/index.mjs +0 -4
  67. package/dist/shared/components/ImageZoomDialog/ImageZoomDialogToolbar/ImageZoomDialogToolbar.d.ts +0 -3
  68. package/dist/shared/components/ImageZoomDialog/ImageZoomDialogToolbar/index.d.ts +0 -2
  69. package/dist/shared/components/ImageZoomDialog/ImageZoomDialogToolbar/index.mjs +0 -4
  70. package/dist/shared/components/ImageZoomDialog/index.d.ts +0 -6
  71. package/dist/shared/components/ImageZoomDialog/index.mjs +0 -10
  72. /package/dist/shared/components/{ImageZoomDialog/ImageZoomDialogFooter/ImageZoomDialogFooter.mjs → MediaDialog/MediaDialogFooter/MediaDialogFooter.mjs} +0 -0
@@ -1,134 +1,149 @@
1
- import { jsx as D } from "react/jsx-runtime";
2
- import { useState as m, useRef as u, Children as T, isValidElement as G, useEffect as l, cloneElement as x } from "react";
3
- import { Box as j, Flexbox as st } from "@dotss/ui";
4
- import at from "@dotss/ui/core/useTheme";
5
- import { findImageInChildren as ut, getHorizontalLayoutRows as it, getNextIndexHorizontalFromRows as ct, findNextFocusableElement as M } from "./Masonry.utils.mjs";
6
- import q from "./MasonryBlock/MasonryBlock.mjs";
7
- import V from "../../../teacher/profile/components/ActivityGallery/ActivityGalleryItem/ActivityGalleryItem.mjs";
8
- function wt({
9
- children: h,
10
- columnCount: z = 2,
11
- rowCount: S = 2,
12
- spacing: c = 2,
13
- edgeSpacing: v = 0,
14
- direction: w = "vertical",
15
- defaultContainerWidth: $ = 0,
16
- defaultContainerHeight: J = 0,
17
- ...d
1
+ import { jsx as T } from "react/jsx-runtime";
2
+ import { useState as p, useRef as i, Children as x, isValidElement as G, useEffect as g, cloneElement as j } from "react";
3
+ import { Box as q, Flexbox as ct } from "@dotss/ui";
4
+ import ut from "@dotss/ui/core/useTheme";
5
+ import { findImageInChildren as z, getHorizontalLayoutRows as lt, getNextIndexHorizontalFromRows as ft, findNextFocusableElement as L } from "./Masonry.utils.mjs";
6
+ import V from "./MasonryBlock/MasonryBlock.mjs";
7
+ import $ from "../../../teacher/profile/components/ActivityGallery/ActivityGalleryItem/ActivityGalleryItem.mjs";
8
+ function bt({
9
+ children: y,
10
+ columnCount: S = 2,
11
+ rowCount: F = 2,
12
+ spacing: u = 2,
13
+ edgeSpacing: d = 0,
14
+ direction: v = "vertical",
15
+ defaultContainerWidth: J = 360,
16
+ defaultContainerHeight: Q = 0,
17
+ ...a
18
18
  }) {
19
- const { spacing: y } = at(), [Q, Y] = m($), [Z, _] = m(J), [F, K] = m(0), o = u(null), i = u([]), b = u([]), A = u(!1), R = u(!0), H = u(0), E = u(0), f = u(0), k = 4 / 3, p = (Q - c) / z, g = w === "horizontal" ? (Z - c) / S : p * k, [I, B] = m(
20
- T.toArray(h).filter(G).filter((t) => t.type === q || t.type === V)
21
- ), [W, O] = m([]), N = I.length, P = (t) => {
22
- var r, e;
23
- A.current = !0, H.current = t.clientX - (((r = o.current) == null ? void 0 : r.offsetLeft) || 0), E.current = ((e = o.current) == null ? void 0 : e.scrollLeft) || 0;
24
- }, U = (t) => {
25
- A.current && (t.currentTarget.style.cursor = "grabbing", o.current && (o.current.scrollLeft = E.current - (t.clientX - o.current.offsetLeft - H.current)));
26
- }, L = (t) => {
27
- var e;
28
- A.current = !1, E.current !== ((e = o.current) == null ? void 0 : e.scrollLeft) ? (t.currentTarget.style.cursor = "grab", R.current = !1, f.current && cancelAnimationFrame(f.current), f.current = requestAnimationFrame(() => {
29
- R.current = !0;
30
- })) : R.current = !0;
31
- }, tt = (t) => (r) => {
32
- r.stopPropagation();
33
- let e = null;
34
- switch (r.key) {
19
+ const { spacing: A } = ut(), [Y, Z] = p(J), [_, K] = p(Q), [H, O] = p(0), w = 4 / 3, l = (Y - u) / S, f = v === "horizontal" ? (_ - u) / F : l * w, o = i(null), c = i([]), b = i([]), E = i(!1), k = i(!0), B = i(0), I = i(0), m = i(0), [h, tt] = p(
20
+ x.toArray(y).filter(G).filter((e) => e.type === V || e.type === $)
21
+ ), [W, et] = p(
22
+ h.map((e) => {
23
+ var t;
24
+ return ((t = z(e.props.children)) == null ? void 0 : t.props.src) ?? "";
25
+ })
26
+ ), [C, rt] = p(
27
+ h.map((e) => {
28
+ var t;
29
+ return {
30
+ src: ((t = z(e.props.children)) == null ? void 0 : t.props.src) ?? "",
31
+ width: e.props.width ?? l,
32
+ height: e.props.height ?? f
33
+ };
34
+ })
35
+ ), N = h.length, P = (e) => {
36
+ var t, r;
37
+ E.current = !0, B.current = e.clientX - (((t = o.current) == null ? void 0 : t.offsetLeft) || 0), I.current = ((r = o.current) == null ? void 0 : r.scrollLeft) || 0;
38
+ }, U = (e) => {
39
+ E.current && (e.currentTarget.style.cursor = "grabbing", o.current && (o.current.scrollLeft = I.current - (e.clientX - o.current.offsetLeft - B.current)));
40
+ }, M = (e) => {
41
+ var r;
42
+ E.current = !1, I.current !== ((r = o.current) == null ? void 0 : r.scrollLeft) ? (e.currentTarget.style.cursor = "grab", k.current = !1, m.current && cancelAnimationFrame(m.current), m.current = requestAnimationFrame(() => {
43
+ k.current = !0;
44
+ })) : k.current = !0;
45
+ }, nt = (e) => (t) => {
46
+ t.stopPropagation();
47
+ let r = null;
48
+ switch (t.key) {
35
49
  case "ArrowRight":
36
- r.preventDefault(), e = M(r.currentTarget, "right", i.current);
50
+ t.preventDefault(), r = L(t.currentTarget, "right", c.current);
37
51
  break;
38
52
  case "ArrowLeft":
39
- r.preventDefault(), e = M(r.currentTarget, "left", i.current);
53
+ t.preventDefault(), r = L(t.currentTarget, "left", c.current);
40
54
  break;
41
55
  case "ArrowDown":
42
- r.preventDefault(), e = M(r.currentTarget, "down", i.current);
56
+ t.preventDefault(), r = L(t.currentTarget, "down", c.current);
43
57
  break;
44
58
  case "ArrowUp":
45
- r.preventDefault(), e = M(r.currentTarget, "up", i.current);
59
+ t.preventDefault(), r = L(t.currentTarget, "up", c.current);
46
60
  break;
47
61
  case "Enter":
48
62
  case " ": {
49
- r.preventDefault(), r.currentTarget.click();
63
+ t.preventDefault(), t.currentTarget.click();
50
64
  return;
51
65
  }
52
66
  default:
53
67
  return;
54
68
  }
55
- e == null || e.focus(), t == null || t(r);
56
- }, rt = (t) => (r) => {
57
- if (r.stopPropagation(), r.key === "Enter" || r.key === " ") {
58
- r.preventDefault(), r.currentTarget.click();
69
+ r == null || r.focus(), e == null || e(t);
70
+ }, ot = (e) => (t) => {
71
+ if (t.stopPropagation(), t.key === "Enter" || t.key === " ") {
72
+ t.preventDefault(), t.currentTarget.click();
59
73
  return;
60
74
  }
61
- const e = Number(r.currentTarget.getAttribute("aria-posinset")) - 1, n = r.key.replace("Arrow", "").toLowerCase();
75
+ const r = Number(t.currentTarget.getAttribute("aria-posinset")) - 1, n = t.key.replace("Arrow", "").toLowerCase();
62
76
  if (!["left", "right", "up", "down"].includes(n)) {
63
- t == null || t(r);
77
+ e == null || e(t);
64
78
  return;
65
79
  }
66
- r.preventDefault();
67
- const a = ct(
80
+ t.preventDefault();
81
+ const R = ft(
68
82
  b.current,
69
- e,
83
+ r,
70
84
  n
71
- ), s = i.current[a ?? -1];
72
- s == null || s.focus(), t == null || t(r);
73
- }, et = (t) => (r) => {
74
- i.current[t] = r;
75
- }, nt = (t, r, e) => (n) => {
76
- b.current[r] || (b.current[r] = []), i.current[t] = n, b.current[r][e] = n;
77
- }, X = (t) => (r) => {
78
- K(Number(r.currentTarget.getAttribute("aria-posinset")) - 1), t == null || t(r);
85
+ ), s = c.current[R ?? -1];
86
+ s == null || s.focus(), e == null || e(t);
87
+ }, st = (e) => (t) => {
88
+ c.current[e] = t;
89
+ }, at = (e, t, r) => (n) => {
90
+ b.current[t] || (b.current[t] = []), c.current[e] = n, b.current[t][r] = n;
91
+ }, X = (e) => (t) => {
92
+ O(Number(t.currentTarget.getAttribute("aria-posinset")) - 1), e == null || e(t);
79
93
  };
80
- if (l(() => {
81
- const t = o.current, r = (e) => {
82
- R.current || e.stopPropagation();
94
+ if (g(() => {
95
+ const e = o.current, t = (r) => {
96
+ k.current || r.stopPropagation();
83
97
  };
84
- return t == null || t.addEventListener("click", r), () => {
85
- t == null || t.removeEventListener("click", r);
98
+ return e == null || e.addEventListener("click", t), () => {
99
+ e == null || e.removeEventListener("click", t);
86
100
  };
87
- }, []), l(() => {
88
- const t = o.current, r = (e) => {
89
- e.stopPropagation();
101
+ }, []), g(() => {
102
+ const e = o.current, t = (r) => {
103
+ r.stopPropagation();
90
104
  };
91
- return t == null || t.addEventListener("touchmove", r), () => {
92
- t == null || t.removeEventListener("touchmove", r);
105
+ return e == null || e.addEventListener("touchmove", t), () => {
106
+ e == null || e.removeEventListener("touchmove", t);
93
107
  };
94
- }, []), l(() => {
95
- const t = T.toArray(h).filter(G).filter((e) => e.type === q || e.type === V), r = t.map((e) => {
108
+ }, []), g(() => {
109
+ const e = x.toArray(y).filter(G).filter((r) => r.type === V || r.type === $), t = e.map((r) => {
96
110
  var n;
97
- return ((n = ut(e.props.children)) == null ? void 0 : n.props.src) ?? "";
111
+ return ((n = z(r.props.children)) == null ? void 0 : n.props.src) ?? "";
98
112
  }).filter(Boolean);
99
- B(t), O(r);
100
- }, [h]), l(() => {
101
- g <= 0 || W.forEach((t, r) => {
102
- const e = new window.Image();
103
- e.src = t, e.onload = () => {
104
- B(
105
- (n) => n.map((a, s) => s === r ? x(a, {
106
- ...a.props,
107
- width: a.props.width ?? e.width / e.height * (a.props.height ?? g),
108
- height: a.props.height ?? g
109
- }) : a)
110
- ), e.onload = null;
111
- }, e.onerror = () => {
112
- e.onload = null;
113
+ tt(e), et(t);
114
+ }, [y]), g(() => {
115
+ f <= 0 || W.forEach((e) => {
116
+ const t = new window.Image();
117
+ t.src = e, t.onload = () => {
118
+ rt(
119
+ (r) => r.map((n) => (n.src === e && (n.width = t.width / t.height * (n.height ?? f), n.height = n.height ?? f), n))
120
+ ), t.onload = null;
121
+ }, t.onerror = () => {
122
+ t.onload = null;
113
123
  };
114
124
  });
115
- }, [h, W, g]), l(() => {
116
- const t = () => {
117
- var r, e, n;
118
- Y(((e = (r = o.current) == null ? void 0 : r.parentElement) == null ? void 0 : e.offsetWidth) ?? 0), _(((n = o.current) == null ? void 0 : n.offsetHeight) ?? 0);
125
+ }, [W, f]), g(() => {
126
+ const e = () => {
127
+ var t, r, n;
128
+ Z(((r = (t = o.current) == null ? void 0 : t.parentElement) == null ? void 0 : r.offsetWidth) ?? 0), K(((n = o.current) == null ? void 0 : n.offsetHeight) ?? 0);
119
129
  };
120
- return t(), window.addEventListener("resize", t), () => {
121
- window.removeEventListener("resize", t);
130
+ return e(), window.addEventListener("resize", e), () => {
131
+ window.removeEventListener("resize", e);
122
132
  };
123
- }, []), l(() => () => {
124
- f.current && cancelAnimationFrame(f.current);
125
- }, []), w === "horizontal") {
126
- const t = it(I, S, p * k / 2);
127
- let r = p * k / 2;
128
- r = r < 0 ? 120 : r;
129
- let e = 0;
130
- return /* @__PURE__ */ D(
131
- j,
133
+ }, []), g(() => () => {
134
+ m.current && cancelAnimationFrame(m.current);
135
+ }, []), v === "horizontal") {
136
+ const e = lt(
137
+ C,
138
+ h,
139
+ F,
140
+ l * w / 2
141
+ );
142
+ let t = l * w / 2;
143
+ t = t <= 0 ? 120 : t;
144
+ let r = 0;
145
+ return /* @__PURE__ */ T(
146
+ q,
132
147
  {
133
148
  ref: o,
134
149
  role: "list",
@@ -136,11 +151,13 @@ function wt({
136
151
  "aria-orientation": "horizontal",
137
152
  onMouseDown: P,
138
153
  onMouseMove: U,
139
- onMouseUp: L,
140
- onMouseLeave: L,
141
- pl: v,
142
- pr: v,
154
+ onMouseUp: M,
155
+ onMouseLeave: M,
156
+ pl: d,
157
+ pr: d,
158
+ ...a,
143
159
  inlineCSS: {
160
+ display: "grid",
144
161
  position: "relative",
145
162
  width: "100%",
146
163
  height: "100%",
@@ -151,31 +168,31 @@ function wt({
151
168
  "&::-webkit-scrollbar": {
152
169
  display: "none"
153
170
  },
154
- ...d.inlineCSS
171
+ ...a == null ? void 0 : a.inlineCSS
155
172
  },
156
- ...d,
157
- children: t.map((n, a) => /* @__PURE__ */ D(st, { gap: c, children: n.map((s, ot) => {
158
- const C = e++;
159
- return x(s, {
160
- setInnerRef: nt(C, a, ot),
161
- tabIndex: C === F ? 0 : -1,
173
+ children: e.map((n, R) => /* @__PURE__ */ T(ct, { gap: u, children: n.map((s, it) => {
174
+ const D = r++;
175
+ return j(s, {
176
+ setInnerRef: at(D, R, it),
177
+ tabIndex: D === H ? 0 : -1,
162
178
  role: "listitem",
163
- "aria-posinset": C + 1,
179
+ "aria-posinset": D + 1,
164
180
  "aria-setsize": N,
165
- width: s.props.width ?? r,
166
- height: s.props.height ?? g,
167
- spacing: y.content(c),
168
- direction: w,
169
- onKeyDown: rt(s.props.onKeyDown),
181
+ width: s.props.width ?? t,
182
+ height: s.props.height ?? f,
183
+ spacing: A.content(u),
184
+ direction: v,
185
+ sourceMetadata: C,
186
+ onKeyDown: ot(s.props.onKeyDown),
170
187
  onFocus: X(s.props.onFocus),
171
188
  ...s.props
172
189
  });
173
- }) }, `masonry-row-${a}`))
190
+ }) }, `masonry-row-${R}`))
174
191
  }
175
192
  );
176
193
  }
177
- return /* @__PURE__ */ D(
178
- j,
194
+ return /* @__PURE__ */ T(
195
+ q,
179
196
  {
180
197
  ref: o,
181
198
  role: "list",
@@ -183,38 +200,39 @@ function wt({
183
200
  "aria-orientation": "vertical",
184
201
  onMouseDown: P,
185
202
  onMouseMove: U,
186
- onMouseUp: L,
187
- onMouseLeave: L,
188
- pt: v,
189
- pb: v,
203
+ onMouseUp: M,
204
+ onMouseLeave: M,
205
+ pt: d,
206
+ pb: d,
207
+ ...a,
190
208
  inlineCSS: {
191
209
  width: "100%",
192
210
  position: "relative",
193
- columnCount: z,
194
- columnGap: y.content(c),
195
- ...d.inlineCSS
211
+ columnCount: S,
212
+ columnGap: A.content(u),
213
+ ...a == null ? void 0 : a.inlineCSS
196
214
  },
197
- ...d,
198
- children: T.map(
199
- I,
200
- (t, r) => x(t, {
201
- setInnerRef: et(r),
215
+ children: x.map(
216
+ h,
217
+ (e, t) => j(e, {
218
+ setInnerRef: st(t),
202
219
  role: "listitem",
203
- tabIndex: r === F ? 0 : -1,
204
- "aria-posinset": r + 1,
220
+ tabIndex: t === H ? 0 : -1,
221
+ "aria-posinset": t + 1,
205
222
  "aria-setsize": N,
206
- width: t.props.width ?? p,
207
- height: t.props.height ?? p * k / 2,
208
- spacing: y.content(c),
209
- direction: w,
210
- onKeyDown: tt(t.props.onKeyDown),
211
- onFocus: X(t.props.onFocus),
212
- ...t.props
223
+ width: e.props.width ?? l,
224
+ height: e.props.height ?? l * w / 2,
225
+ spacing: A.content(u),
226
+ direction: v,
227
+ sourceMetadata: C,
228
+ onKeyDown: nt(e.props.onKeyDown),
229
+ onFocus: X(e.props.onFocus),
230
+ ...e.props
213
231
  })
214
232
  )
215
233
  }
216
234
  );
217
235
  }
218
236
  export {
219
- wt as default
237
+ bt as default
220
238
  };
@@ -1,7 +1,11 @@
1
1
  import { ReactElement, ReactNode } from 'react';
2
2
  import { ImageProps } from '../Image';
3
3
  import { MasonryBlockProps } from './MasonryBlock';
4
- export declare function getHorizontalLayoutRows(blocks: ReactElement<MasonryBlockProps>[], rowCount: number, fallbackWidth: number): ReactElement<MasonryBlockProps, string | import('react').JSXElementConstructor<any>>[][];
4
+ export declare function getHorizontalLayoutRows(images: {
5
+ src: string;
6
+ width: number;
7
+ height: number;
8
+ }[], blocks: ReactElement<MasonryBlockProps>[], rowCount: number, fallbackWidth: number): ReactElement<MasonryBlockProps, string | import('react').JSXElementConstructor<any>>[][];
5
9
  export declare function findNextFocusableElement(currentElement: HTMLDivElement, keyDirection: 'left' | 'right' | 'up' | 'down', candidates: (HTMLDivElement | null)[]): HTMLDivElement | null;
6
10
  export declare function getNextIndexHorizontalFromRows(rows: HTMLDivElement[][], currentIndex: number, keyDirection: 'up' | 'down' | 'left' | 'right'): number | null;
7
11
  export declare function findImageInChildren(children: ReactNode): ReactElement<ImageProps> | null;
@@ -1,76 +1,77 @@
1
1
  import { Children as M, isValidElement as y } from "react";
2
2
  import E from "../Image/Image.mjs";
3
- function X(n, r, e) {
4
- const o = Array.from({ length: r }, () => []), t = Array(r).fill(0);
5
- return n.forEach((c) => {
6
- const g = t.indexOf(Math.min(...t));
7
- o[g].push(c), t[g] += c.props.width ?? e;
8
- }), o;
3
+ function B(n, c, e, s) {
4
+ const t = Array.from({ length: e }, () => []), o = Array(e).fill(0);
5
+ return c.forEach((h) => {
6
+ var g;
7
+ const a = ((g = I(h.props.children)) == null ? void 0 : g.props.src) ?? "", u = n.find((m) => m.src === a), l = o.indexOf(Math.min(...o));
8
+ t[l].push(h), o[l] += (u == null ? void 0 : u.width) ?? s;
9
+ }), t;
9
10
  }
10
- function B(n, r, e) {
11
- const o = n.getBoundingClientRect(), t = (o.left + o.right) / 2, c = (o.top + o.bottom) / 2;
12
- let g = null, h = 1 / 0;
11
+ function w(n, c, e) {
12
+ const s = n.getBoundingClientRect(), t = (s.left + s.right) / 2, o = (s.top + s.bottom) / 2;
13
+ let h = null, a = 1 / 0;
13
14
  for (const u of e) {
14
15
  if (!u || u === n) continue;
15
- const s = u.getBoundingClientRect(), R = (s.left + s.right) / 2, C = (s.top + s.bottom) / 2, a = R - t, i = C - c, l = Math.abs(i) < s.height * 0.75, f = Math.abs(a) < s.width * 0.75, m = r === "right" && a > 0 && l || r === "left" && a < 0 && l || r === "down" && i > 0 && f || r === "up" && i < 0 && f, d = Math.hypot(a, i);
16
- m && d < h && (h = d, g = u);
16
+ const l = u.getBoundingClientRect(), g = (l.left + l.right) / 2, m = (l.top + l.bottom) / 2, d = g - t, r = m - o, i = Math.abs(r) < l.height * 0.75, f = Math.abs(d) < l.width * 0.75, p = c === "right" && d > 0 && i || c === "left" && d < 0 && i || c === "down" && r > 0 && f || c === "up" && r < 0 && f, b = Math.hypot(d, r);
17
+ p && b < a && (a = b, h = u);
17
18
  }
18
- return g;
19
+ return h;
19
20
  }
20
- function w(n, r, e) {
21
- var s, R, C, a;
22
- if (!n.length || r < 0) return null;
23
- const o = n.length;
24
- let t = -1, c = -1;
25
- for (let i = 0; i < o; i++) {
26
- for (let l = 0; l < n[i].length; l++) {
27
- const f = n[i][l];
28
- if (Number(f == null ? void 0 : f.getAttribute("aria-posinset")) - 1 === r) {
29
- t = i, c = l;
21
+ function x(n, c, e) {
22
+ var l, g, m, d;
23
+ if (!n.length || c < 0) return null;
24
+ const s = n.length;
25
+ let t = -1, o = -1;
26
+ for (let r = 0; r < s; r++) {
27
+ for (let i = 0; i < n[r].length; i++) {
28
+ const f = n[r][i];
29
+ if (Number(f == null ? void 0 : f.getAttribute("aria-posinset")) - 1 === c) {
30
+ t = r, o = i;
30
31
  break;
31
32
  }
32
33
  }
33
34
  if (t !== -1) break;
34
35
  }
35
- if (t === -1 || c === -1) return null;
36
- const h = n[t][c].getBoundingClientRect(), u = (h.left + h.right) / 2;
37
- if (e === "left" && c > 0)
38
- return Number((s = n[t][c - 1]) == null ? void 0 : s.getAttribute("aria-posinset")) - 1;
39
- if (e === "right" && c < n[t].length - 1)
40
- return Number((R = n[t][c + 1]) == null ? void 0 : R.getAttribute("aria-posinset")) - 1;
36
+ if (t === -1 || o === -1) return null;
37
+ const a = n[t][o].getBoundingClientRect(), u = (a.left + a.right) / 2;
38
+ if (e === "left" && o > 0)
39
+ return Number((l = n[t][o - 1]) == null ? void 0 : l.getAttribute("aria-posinset")) - 1;
40
+ if (e === "right" && o < n[t].length - 1)
41
+ return Number((g = n[t][o + 1]) == null ? void 0 : g.getAttribute("aria-posinset")) - 1;
41
42
  if (e === "up" && t > 0) {
42
- const i = n[t - 1];
43
- let l = 0, f = 1 / 0;
44
- return i.forEach((m, d) => {
45
- const p = m.getBoundingClientRect(), A = (p.left + p.right) / 2, b = Math.abs(u - A);
46
- b < f && (f = b, l = d);
47
- }), Number((C = i[l]) == null ? void 0 : C.getAttribute("aria-posinset")) - 1;
43
+ const r = n[t - 1];
44
+ let i = 0, f = 1 / 0;
45
+ return r.forEach((p, b) => {
46
+ const R = p.getBoundingClientRect(), A = (R.left + R.right) / 2, C = Math.abs(u - A);
47
+ C < f && (f = C, i = b);
48
+ }), Number((m = r[i]) == null ? void 0 : m.getAttribute("aria-posinset")) - 1;
48
49
  }
49
- if (e === "down" && t < o - 1) {
50
- const i = n[t + 1];
51
- let l = 0, f = 1 / 0;
52
- return i.forEach((m, d) => {
53
- const p = m.getBoundingClientRect(), A = (p.left + p.right) / 2, b = Math.abs(u - A);
54
- b < f && (f = b, l = d);
55
- }), Number((a = i[l]) == null ? void 0 : a.getAttribute("aria-posinset")) - 1;
50
+ if (e === "down" && t < s - 1) {
51
+ const r = n[t + 1];
52
+ let i = 0, f = 1 / 0;
53
+ return r.forEach((p, b) => {
54
+ const R = p.getBoundingClientRect(), A = (R.left + R.right) / 2, C = Math.abs(u - A);
55
+ C < f && (f = C, i = b);
56
+ }), Number((d = r[i]) == null ? void 0 : d.getAttribute("aria-posinset")) - 1;
56
57
  }
57
58
  return null;
58
59
  }
59
- function x(n) {
60
- const r = M.toArray(n).filter(y).find((e) => e.type === E || e.type === "img");
61
- if (r)
62
- return r;
60
+ function I(n) {
61
+ const c = M.toArray(n).filter(y).find((e) => e.type === E || e.type === "img");
62
+ if (c)
63
+ return c;
63
64
  for (const e of M.toArray(n))
64
65
  if (y(e) && e.props && e.props.children) {
65
- const o = M.toArray(e.props.children).filter(y).find((t) => t.type === E || t.type === "img");
66
- if (o)
67
- return o;
66
+ const s = M.toArray(e.props.children).filter(y).find((t) => t.type === E || t.type === "img");
67
+ if (s)
68
+ return s;
68
69
  }
69
70
  return null;
70
71
  }
71
72
  export {
72
- x as findImageInChildren,
73
- B as findNextFocusableElement,
74
- X as getHorizontalLayoutRows,
75
- w as getNextIndexHorizontalFromRows
73
+ I as findImageInChildren,
74
+ w as findNextFocusableElement,
75
+ B as getHorizontalLayoutRows,
76
+ x as getNextIndexHorizontalFromRows
76
77
  };
@@ -5,6 +5,11 @@ export interface MasonryBlockProps extends FlexboxProps {
5
5
  height?: number;
6
6
  borderRadius?: number | string;
7
7
  direction?: 'horizontal' | 'vertical';
8
+ sourceMetadata?: {
9
+ src: string;
10
+ width: number;
11
+ height: number;
12
+ }[];
8
13
  setInnerRef?: (ref: HTMLDivElement | null) => void;
9
14
  }
10
15
  declare const MasonryBlock: import('react').ForwardRefExoticComponent<Omit<MasonryBlockProps, "ref"> & import('react').RefAttributes<HTMLDivElement>>;