@savvycal/calendar 0.12.1 → 0.13.0

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/README.md CHANGED
@@ -775,7 +775,7 @@ The calendar includes built-in ARIA support for screen readers:
775
775
 
776
776
  ### Custom renderers
777
777
 
778
- When using `renderEvent`, the library does **not** add `aria-label` or `role` attributes to the wrapper `<div>`. Your custom renderer is responsible for providing its own accessible markup.
778
+ An interactive event drawn by `renderEvent` gets the same wrapper behavior as a default chip: `role="button"`, `tabIndex`, an `aria-label`, and `onEventClick` on click, Enter, or Space. Return non-interactive content from `renderEvent`, without your own button, to avoid nesting interactive elements.
779
779
 
780
780
  ## License
781
781
 
@@ -1,114 +1,118 @@
1
- import { jsx as o, jsxs as x, Fragment as B } from "react/jsx-runtime";
1
+ import { jsx as i, jsxs as x, Fragment as B } from "react/jsx-runtime";
2
2
  import { memo as K } from "react";
3
3
  import { cn as q } from "../../lib/utils.js";
4
4
  import { formatEventStartTime as A } from "../../lib/time.js";
5
5
  import { describeEvent as G } from "../../lib/accessibility.js";
6
6
  const W = K(function({
7
- positioned: m,
8
- fallbackColor: E,
7
+ positioned: s,
8
+ fallbackColor: I,
9
9
  timeZone: y,
10
10
  cls: n,
11
11
  onClick: N,
12
- renderEvent: b,
13
- interactive: I = !0,
14
- eventGap: D = 2,
15
- eventLayout: F = "columns",
16
- stackOffset: g = 8,
17
- isSelected: $,
12
+ renderEvent: g,
13
+ interactive: D = !0,
14
+ eventGap: F = 2,
15
+ eventLayout: O = "columns",
16
+ stackOffset: $ = 8,
17
+ isSelected: b,
18
18
  selectedEventRef: C
19
19
  }) {
20
- const { event: e, top: T, height: v, subColumn: a, totalSubColumns: i } = m, r = I && e.interactive !== !1, S = m.colSpan ?? 1, c = e.color ?? E;
21
- let d, p, l;
22
- if (F === "stacked") {
23
- const t = (i - 1) * g;
24
- d = a > 0 ? `${a * g}px` : "0", p = t > 0 ? `calc(100% - ${t}px)` : "100%", l = a + 1;
20
+ const { event: t, top: T, height: m, subColumn: a, totalSubColumns: o } = s, v = D && t.interactive !== !1, S = s.colSpan ?? 1, r = t.color ?? I;
21
+ let p, d, c;
22
+ if (O === "stacked") {
23
+ const e = (o - 1) * $;
24
+ p = a > 0 ? `${a * $}px` : "0", d = e > 0 ? `calc(100% - ${e}px)` : "100%", c = a + 1;
25
25
  } else {
26
- const t = a / i * 100, k = S / i * 100, w = D, z = a * w / i, h = (i - S) * w / i;
27
- d = h ? `calc(${t}% + ${z}px)` : `${t}%`, p = h ? `calc(${k}% - ${h}px)` : `${k}%`;
26
+ const e = a / o * 100, w = S / o * 100, E = F, z = a * E / o, h = (o - S) * E / o;
27
+ p = h ? `calc(${e}% + ${z}px)` : `${e}%`, d = h ? `calc(${w}% - ${h}px)` : `${w}%`;
28
28
  }
29
- m.overlay && (l = 8), $ && (l = 20);
30
- const L = v >= 36, O = v >= 52, j = e.status === "canceled", u = e.appearance === "outline", s = u ? { color: "inherit" } : void 0;
31
- if (b) {
32
- const t = b({ event: e, position: m });
33
- if (t)
34
- return /* @__PURE__ */ o(
29
+ s.overlay && (c = 8), b && (c = 20);
30
+ const P = m >= 36, j = m >= 52, L = t.status === "canceled", u = t.appearance === "outline", l = u ? { color: "inherit" } : void 0, k = v ? {
31
+ role: "button",
32
+ tabIndex: 0,
33
+ "aria-label": G(t, y, { includeStatus: !0 }),
34
+ onClick: () => N?.(t),
35
+ onKeyDown: (e) => {
36
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), N?.(t));
37
+ }
38
+ } : {};
39
+ if (g) {
40
+ const e = g({ event: t, position: s });
41
+ if (e)
42
+ return /* @__PURE__ */ i(
35
43
  "div",
36
44
  {
37
45
  ref: C,
46
+ ...k,
38
47
  style: {
39
48
  position: "absolute",
49
+ cursor: v ? "pointer" : void 0,
40
50
  top: T,
41
- height: v,
42
- left: d,
43
- width: p,
44
- zIndex: l,
45
- pointerEvents: r ? "auto" : "none"
51
+ height: m,
52
+ left: p,
53
+ width: d,
54
+ zIndex: c,
55
+ pointerEvents: v ? "auto" : "none"
46
56
  },
47
- children: t
57
+ children: e
48
58
  }
49
59
  );
50
60
  }
51
- const f = A(e.startTime, y), P = r ? G(e, y, { includeStatus: !0 }) : void 0;
61
+ const f = A(t.startTime, y);
52
62
  return /* @__PURE__ */ x(
53
63
  "div",
54
64
  {
55
65
  ref: C,
56
- ...r ? { role: "button", tabIndex: 0, "aria-label": P } : {},
66
+ ...k,
57
67
  className: q(
58
68
  n("event"),
59
- $ && n("eventSelected"),
69
+ b && n("eventSelected"),
60
70
  u && n("eventOutline")
61
71
  ),
62
72
  style: {
63
- ...u && { "--cal-event-color": c },
73
+ ...u && { "--cal-event-color": r },
64
74
  top: T,
65
- height: v,
66
- left: d,
67
- width: p,
68
- zIndex: l,
69
- pointerEvents: r ? "auto" : "none"
75
+ height: m,
76
+ left: p,
77
+ width: d,
78
+ zIndex: c,
79
+ pointerEvents: v ? "auto" : "none"
70
80
  },
71
- ...r ? {
72
- onClick: () => N?.(e),
73
- onKeyDown: (t) => {
74
- (t.key === "Enter" || t.key === " ") && (t.preventDefault(), N?.(e));
75
- }
76
- } : {},
77
81
  children: [
78
- c && !u && /* @__PURE__ */ o(
82
+ r && !u && /* @__PURE__ */ i(
79
83
  "div",
80
84
  {
81
85
  className: n("eventColorBar"),
82
- style: e.status === "tentative" ? {
86
+ style: t.status === "tentative" ? {
83
87
  backgroundImage: `repeating-linear-gradient(
84
88
  -45deg,
85
- ${c},
86
- ${c} 3px,
89
+ ${r},
90
+ ${r} 3px,
87
91
  transparent 3px,
88
92
  transparent 6px
89
93
  )`
90
- } : { backgroundColor: c }
94
+ } : { backgroundColor: r }
91
95
  }
92
96
  ),
93
- /* @__PURE__ */ o(
97
+ /* @__PURE__ */ i(
94
98
  "div",
95
99
  {
96
100
  className: n("eventTitle"),
97
101
  style: {
98
- ...s,
99
- ...j ? { textDecoration: "line-through" } : {}
102
+ ...l,
103
+ ...L ? { textDecoration: "line-through" } : {}
100
104
  },
101
- children: e.title
105
+ children: t.title
102
106
  }
103
107
  ),
104
- L && (O ? /* @__PURE__ */ x(B, { children: [
105
- /* @__PURE__ */ o("div", { className: n("eventTime"), style: s, children: f }),
106
- e.clientName && /* @__PURE__ */ o("div", { className: n("eventClientName"), style: s, children: e.clientName })
107
- ] }) : e.clientName ? /* @__PURE__ */ x("div", { className: n("eventTime"), style: s, children: [
108
+ P && (j ? /* @__PURE__ */ x(B, { children: [
109
+ /* @__PURE__ */ i("div", { className: n("eventTime"), style: l, children: f }),
110
+ t.clientName && /* @__PURE__ */ i("div", { className: n("eventClientName"), style: l, children: t.clientName })
111
+ ] }) : t.clientName ? /* @__PURE__ */ x("div", { className: n("eventTime"), style: l, children: [
108
112
  f,
109
113
  ", ",
110
- e.clientName
111
- ] }) : /* @__PURE__ */ o("div", { className: n("eventTime"), style: s, children: f }))
114
+ t.clientName
115
+ ] }) : /* @__PURE__ */ i("div", { className: n("eventTime"), style: l, children: f }))
112
116
  ]
113
117
  }
114
118
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@savvycal/calendar",
3
- "version": "0.12.1",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {