@forcecalendar/interface 1.0.60 → 1.0.61

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.
@@ -2,7 +2,7 @@ var H = Object.defineProperty;
2
2
  var L = (h, t, e) => t in h ? H(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e;
3
3
  var m = (h, t, e) => L(h, typeof t != "symbol" ? t + "" : t, e);
4
4
  import { Calendar as F, DateUtils as I } from "@forcecalendar/core";
5
- class M extends HTMLElement {
5
+ class $ extends HTMLElement {
6
6
  constructor() {
7
7
  super(), this.attachShadow({ mode: "open" }), this._listeners = [], this._state = null, this._props = /* @__PURE__ */ new Map(), this._initialized = !1;
8
8
  }
@@ -104,9 +104,11 @@ class M extends HTMLElement {
104
104
  * @param {Map<string, {top: number, left: number}>} positions
105
105
  */
106
106
  _restoreScrollPositions(t) {
107
- !this._contentWrapper || t.size === 0 || t.forEach((e, r) => {
108
- const i = this._contentWrapper.querySelector(`[id="${CSS.escape(r)}"]`);
109
- i && (i.scrollTop = e.top, i.scrollLeft = e.left);
107
+ if (!this._contentWrapper || t.size === 0) return;
108
+ const e = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape : (r) => String(r).replace(/["\\]/g, "\\$&");
109
+ t.forEach((r, i) => {
110
+ const s = this._contentWrapper.querySelector(`[id="${e(i)}"]`);
111
+ s && (s.scrollTop = r.top, s.scrollLeft = r.left);
110
112
  });
111
113
  }
112
114
  /**
@@ -149,7 +151,7 @@ class M extends HTMLElement {
149
151
  this.setProp(t, r), this._initialized && this.render();
150
152
  }
151
153
  }
152
- class T {
154
+ class S {
153
155
  constructor() {
154
156
  this.events = /* @__PURE__ */ new Map(), this.wildcardHandlers = /* @__PURE__ */ new Set();
155
157
  }
@@ -289,10 +291,10 @@ class T {
289
291
  return t;
290
292
  }
291
293
  }
292
- const U = new T();
293
- class V {
294
+ const j = new S();
295
+ class z {
294
296
  constructor(t = {}) {
295
- this.eventBus = new T(), this.calendar = new F({
297
+ this.eventBus = new S(), this.calendar = new F({
296
298
  view: t.view || "month",
297
299
  date: t.date || /* @__PURE__ */ new Date(),
298
300
  weekStartsOn: t.weekStartsOn ?? 0,
@@ -1470,18 +1472,18 @@ class D {
1470
1472
  * @returns {string} HTML string
1471
1473
  */
1472
1474
  renderTimedEvent(t, e = {}) {
1473
- const { compact: r = !0, overlapLayout: i = null } = e, s = new Date(t.start), n = new Date(t.end), a = s.getHours() * 60 + s.getMinutes(), o = Math.max((n - s) / (1e3 * 60), r ? 20 : 30), c = this.getEventColor(t), l = this.getContrastingTextColor(c), d = r ? "4px 8px" : "8px 12px", p = r ? "11px" : "13px", v = r ? 2 : 12, y = r ? 2 : 24, S = r ? "4px" : "6px";
1475
+ const { compact: r = !0, overlapLayout: i = null } = e, s = new Date(t.start), n = new Date(t.end), a = s.getHours() * 60 + s.getMinutes(), o = Math.max((n - s) / (1e3 * 60), r ? 20 : 30), c = this.getEventColor(t), l = this.getContrastingTextColor(c), d = r ? "4px 8px" : "8px 12px", p = r ? "11px" : "13px", v = r ? 2 : 12, y = r ? 2 : 24, T = r ? "4px" : "6px";
1474
1476
  let x, w;
1475
1477
  if (i && i.has(t.id)) {
1476
- const { column: C, totalColumns: k } = i.get(t.id), $ = `(100% - ${v + y}px)`;
1477
- x = `calc(${v}px + ${C} * ${$} / ${k})`, w = `calc(${$} / ${k})`;
1478
+ const { column: C, totalColumns: E } = i.get(t.id), M = `(100% - ${v + y}px)`;
1479
+ x = `calc(${v}px + ${C} * ${M} / ${E})`, w = `calc(${M} / ${E})`;
1478
1480
  } else
1479
1481
  x = `${v}px`, w = `calc(100% - ${v + y}px)`;
1480
1482
  return `
1481
1483
  <div class="fc-event fc-timed-event" data-event-id="${this.escapeHTML(t.id)}"
1482
1484
  style="position: absolute; top: ${a}px; height: ${o}px;
1483
1485
  left: ${x}; width: ${w};
1484
- background-color: ${c}; border-radius: ${S};
1486
+ background-color: ${c}; border-radius: ${T};
1485
1487
  padding: ${d}; font-size: ${p};
1486
1488
  font-weight: 500; color: ${l}; overflow: hidden;
1487
1489
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
@@ -1591,7 +1593,7 @@ class _ extends D {
1591
1593
  }), this.attachCommonEventHandlers();
1592
1594
  }
1593
1595
  }
1594
- class z extends D {
1596
+ class V extends D {
1595
1597
  constructor(t, e) {
1596
1598
  super(t, e), this.hourHeight = 60, this.totalHeight = 24 * this.hourHeight;
1597
1599
  }
@@ -1876,7 +1878,7 @@ class B extends D {
1876
1878
  t && (t.scrollTop = 8 * this.hourHeight - 50, this._scrolled = !0);
1877
1879
  }
1878
1880
  }
1879
- class A extends M {
1881
+ class A extends $ {
1880
1882
  constructor() {
1881
1883
  super(), this._isVisible = !1, this._cleanupFocusTrap = null, this.config = {
1882
1884
  title: "New Event",
@@ -2182,13 +2184,43 @@ class A extends M {
2182
2184
  }
2183
2185
  }
2184
2186
  customElements.get("forcecal-event-form") || customElements.define("forcecal-event-form", A);
2185
- const b = class b extends M {
2187
+ const b = class b extends $ {
2186
2188
  static get observedAttributes() {
2187
2189
  return ["view", "date", "locale", "timezone", "week-starts-on", "height"];
2188
2190
  }
2189
2191
  constructor() {
2190
2192
  super(), this.stateManager = null, this.currentView = null, this._hasRendered = !1, this._busUnsubscribers = [];
2191
2193
  }
2194
+ /**
2195
+ * Route observed-attribute changes into the StateManager.
2196
+ * Without this, attribute updates after mount (view, locale, timezone,
2197
+ * week-starts-on, date) only re-rendered from stale state and had no
2198
+ * visible effect. 'height' is presentational and picked up by render().
2199
+ */
2200
+ propChanged(t, e, r) {
2201
+ if (!(!this.stateManager || e === r))
2202
+ switch (t) {
2203
+ case "view":
2204
+ r && this.stateManager.setView(r);
2205
+ break;
2206
+ case "date": {
2207
+ const i = r ? new Date(r) : null;
2208
+ i && !isNaN(i.getTime()) && this.stateManager.setDate(i);
2209
+ break;
2210
+ }
2211
+ case "locale":
2212
+ r && this.stateManager.updateConfig({ locale: r });
2213
+ break;
2214
+ case "timezone":
2215
+ r && this.stateManager.updateConfig({ timeZone: r });
2216
+ break;
2217
+ case "week-starts-on": {
2218
+ const i = parseInt(r, 10);
2219
+ Number.isNaN(i) || this.stateManager.updateConfig({ weekStartsOn: i });
2220
+ break;
2221
+ }
2222
+ }
2223
+ }
2192
2224
  initialize() {
2193
2225
  const t = {
2194
2226
  view: this.getAttribute("view") || "month",
@@ -2197,7 +2229,7 @@ const b = class b extends M {
2197
2229
  timeZone: this.getAttribute("timezone") || Intl.DateTimeFormat().resolvedOptions().timeZone,
2198
2230
  weekStartsOn: parseInt(this.getAttribute("week-starts-on") || "0")
2199
2231
  };
2200
- this.stateManager = new V(t), this._stateUnsubscribe = this.stateManager.subscribe(this.handleStateChange.bind(this)), this.setupEventListeners();
2232
+ this.stateManager = new z(t), this._stateUnsubscribe = this.stateManager.subscribe(this.handleStateChange.bind(this)), this.setupEventListeners();
2201
2233
  }
2202
2234
  setupEventListeners() {
2203
2235
  this._busUnsubscribers.forEach((r) => r()), this._busUnsubscribers = [];
@@ -2883,23 +2915,23 @@ const b = class b extends M {
2883
2915
  };
2884
2916
  m(b, "RENDERERS", {
2885
2917
  month: _,
2886
- week: z,
2918
+ week: V,
2887
2919
  day: B
2888
2920
  });
2889
- let E = b;
2890
- customElements.get("forcecal-main") || customElements.define("forcecal-main", E);
2921
+ let k = b;
2922
+ customElements.get("forcecal-main") || customElements.define("forcecal-main", k);
2891
2923
  export {
2892
- M as BaseComponent,
2924
+ $ as BaseComponent,
2893
2925
  D as BaseViewRenderer,
2894
2926
  g as DOMUtils,
2895
2927
  u as DateUtils,
2896
2928
  B as DayViewRenderer,
2897
- T as EventBus,
2898
- E as ForceCalendar,
2929
+ S as EventBus,
2930
+ k as ForceCalendar,
2899
2931
  _ as MonthViewRenderer,
2900
- V as StateManager,
2932
+ z as StateManager,
2901
2933
  f as StyleUtils,
2902
- z as WeekViewRenderer,
2903
- U as eventBus
2934
+ V as WeekViewRenderer,
2935
+ j as eventBus
2904
2936
  };
2905
2937
  //# sourceMappingURL=force-calendar-interface.esm.js.map