dsh-calendar-lite 0.1.0 → 0.1.1

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 (2) hide show
  1. package/client.js +254 -33
  2. package/package.json +1 -1
package/client.js CHANGED
@@ -15,6 +15,7 @@
15
15
  var h = null;
16
16
  var useState = null;
17
17
  var useEffect = null;
18
+ var useLayoutEffect = null;
18
19
  var useMemo = null;
19
20
  var useRef = null;
20
21
 
@@ -417,9 +418,17 @@
417
418
  header: { height: 52, flex: '0 0 52px', display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '0 12px 0 16px', gap: 8 },
418
419
  headerLeft: { display: 'flex', alignItems: 'center', gap: 6 },
419
420
  monthTitle: { fontSize: 18, fontWeight: 600, letterSpacing: 0.2, minWidth: 108 },
421
+ monthCaret: { fontSize: 10, color: '#8A9099', opacity: 0, transition: 'opacity .15s ease' },
422
+ monthCaretOn: { opacity: 1 },
423
+ yearPicker: { position: 'fixed', zIndex: 80, background: '#fff', borderRadius: 10, border: '1px solid #EDEFF2', boxShadow: '0 10px 30px rgba(0,0,0,0.14)', padding: '10px 12px 12px', width: 292 },
424
+ yearPickerHead: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 8 },
425
+ yearPickerTitle: { fontSize: 15, fontWeight: 700, color: INK },
426
+ yearPickerGrid: { display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 4 },
427
+ yearPickerCell: { height: 40, borderRadius: 20, display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 13, color: '#2D3036', cursor: 'pointer', userSelect: 'none' },
428
+ yearPickerCellOn: { width: 40, height: 40, borderRadius: '50%', background: '#4A4F57', color: '#fff', fontWeight: 600, display: 'flex', alignItems: 'center', justifyContent: 'center' },
420
429
  iconBtn: { width: 28, height: 28, border: '1px solid #E3E6EA', background: '#fff', borderRadius: 6, cursor: 'pointer', color: '#4B5563', fontSize: 16, padding: 0, lineHeight: '24px' },
421
430
  todayBtn: { height: 28, padding: '0 12px', border: '1px solid #E3E6EA', background: '#fff', borderRadius: 6, cursor: 'pointer', fontSize: 13, color: '#374151' },
422
- monthFloat: { position: 'absolute', top: 2, left: 8, fontSize: 24, fontWeight: 700, color: '#2D3036', pointerEvents: 'none', transition: 'opacity .2s ease', zIndex: 2 },
431
+ monthFloat: { position: 'absolute', top: 2, left: 8, fontSize: 24, fontWeight: 700, color: '#2D3036', pointerEvents: 'none', transition: 'opacity .7s ease', zIndex: 2 },
423
432
  scroll: { flex: 1, minHeight: 0, overflowY: 'auto', overflowX: 'hidden', position: 'relative' },
424
433
  weekBar: { position: 'sticky', top: 0, zIndex: 3, height: WEEK_H, display: 'grid', gridTemplateColumns: 'repeat(7,1fr)', background: 'var(--dsw-alias-bg-primary,#fff)', borderBottom: '1px solid #EDEFF2' },
425
434
  weekCell: { display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 12, color: '#9AA0A8' },
@@ -2029,7 +2038,12 @@
2029
2038
  const [tags, setTags] = useState(SEED_TAGS);
2030
2039
  const [currentSection, setCurrentSection] = useState(MONTH_SPAN);
2031
2040
  const [scrolling, setScrolling] = useState(false);
2041
+ // 0 = hidden, 1 = shown, 2 = fading out (dates stay hidden while fading).
2042
+ const [monthPhase, setMonthPhase] = useState(0);
2032
2043
  const [addDraft, setAddDraft] = useState(null);
2044
+ const [yearPicker, setYearPicker] = useState(null);
2045
+ const [monthHover, setMonthHover] = useState(false);
2046
+ const pendingJumpRef = useRef(null);
2033
2047
  const [detailId, setDetailId] = useState(null);
2034
2048
  const [detailPos, setDetailPos] = useState(null);
2035
2049
  const [contextMenu, setContextMenu] = useState(null);
@@ -2055,6 +2069,12 @@
2055
2069
  const suppressClickRef = useRef(0);
2056
2070
  const [drag, setDrag] = useState(null);
2057
2071
  const sectionRefs = useRef({});
2072
+
2073
+ // Section DOM nodes are keyed by year-month: month ranges grow by prepending
2074
+ // sections, so index-based refs would silently point at the wrong month.
2075
+ function sectionNode(sec) {
2076
+ return sec ? sectionRefs.current[sec.year + '-' + sec.month] || null : null;
2077
+ }
2058
2078
  const timerRef = useRef(null);
2059
2079
  const programmaticRef = useRef(false);
2060
2080
 
@@ -2134,17 +2154,36 @@
2134
2154
  // Search is a transient destination: leaving from it should land back on the calendar.
2135
2155
  useEffect(function () { writeUi({ view: view === 'search' ? 'calendar' : view }); }, [view]);
2136
2156
 
2157
+ const restoringRef = useRef(false);
2158
+ // Restore the saved scroll offset once per view entry, not on every sections
2159
+ // change (month-range extension must keep the user's position).
2160
+ const didRestoreRef = useRef(false);
2161
+
2162
+ useEffect(function () {
2163
+ didRestoreRef.current = false;
2164
+ }, [view]);
2165
+
2137
2166
  useEffect(function () {
2138
2167
  if (view !== 'calendar') return undefined;
2139
2168
  const el = scrollRef.current;
2140
2169
  if (!el) return undefined;
2141
- // Coming back from another view: restore where the user was; first mount: today.
2142
- if (calendarScrollRef.current > 0) {
2143
- el.scrollTop = calendarScrollRef.current;
2144
- } else {
2145
- scrollToSection(todayIndex, false);
2170
+ let restoreTimer = null;
2171
+ if (!didRestoreRef.current) {
2172
+ didRestoreRef.current = true;
2173
+ // Coming back from another view: restore where the user was; first mount: today.
2174
+ if (calendarScrollRef.current > 0) {
2175
+ // Restoring must not look like a scroll: no month label, no scroll state.
2176
+ restoringRef.current = true;
2177
+ el.scrollTop = calendarScrollRef.current;
2178
+ setScrolling(false);
2179
+ setMonthPhase(0);
2180
+ restoreTimer = setTimeout(function () { restoringRef.current = false; }, 120);
2181
+ } else {
2182
+ scrollToSection(todayIndex, false);
2183
+ }
2146
2184
  }
2147
2185
  function onScroll() {
2186
+ if (restoringRef.current) return;
2148
2187
  const userScroll = !programmaticRef.current;
2149
2188
  if (userScroll) snapAnimRef.current += 1; // a real scroll cancels a wheel animation
2150
2189
  calendarScrollRef.current = el.scrollTop;
@@ -2160,7 +2199,7 @@
2160
2199
  let best = currentSection;
2161
2200
  let bestHeight = -1;
2162
2201
  for (let i = 0; i < sections.length; i += 1) {
2163
- const node = sectionRefs.current[i];
2202
+ const node = sectionNode(sections[i]);
2164
2203
  if (!node) continue;
2165
2204
  const top = node.offsetTop;
2166
2205
  const bottom = top + node.offsetHeight;
@@ -2171,11 +2210,11 @@
2171
2210
  }
2172
2211
  }
2173
2212
  setCurrentSection(best);
2174
- if (userScroll) {
2175
- // Endless canvas: extend the month range when nearing either edge.
2176
- if (el.scrollTop < 240) extendMonths('up');
2177
- else if (el.scrollTop > el.scrollHeight - el.clientHeight - 240) extendMonths('down');
2178
- }
2213
+ // Endless canvas: extend when nearing either edge. This must also run for
2214
+ // programmatic (wheel-animation) scrolling, otherwise the wheel never
2215
+ // triggers the next month batch.
2216
+ if (el.scrollTop < 240) extendMonths('up');
2217
+ else if (el.scrollTop > el.scrollHeight - el.clientHeight - 240) extendMonths('down');
2179
2218
  }
2180
2219
  el.addEventListener('scroll', onScroll, { passive: true });
2181
2220
 
@@ -2183,6 +2222,14 @@
2183
2222
  // stop exactly there (no extra snap). Touchpads keep native scrolling.
2184
2223
  function onWheel(event) {
2185
2224
  const touchpad = event.deltaMode === 0 && Math.abs(event.deltaY) < 50;
2225
+ // At an edge the scroll offset cannot change, so no scroll event would
2226
+ // fire to trigger month extension — ask for it from the wheel itself.
2227
+ const maxNow = el.scrollHeight - el.clientHeight;
2228
+ if (event.deltaY < 0 && el.scrollTop <= ROW_H) {
2229
+ if (extendMonths('up')) { event.preventDefault(); return; }
2230
+ } else if (event.deltaY > 0 && el.scrollTop >= maxNow - ROW_H) {
2231
+ if (extendMonths('down')) { event.preventDefault(); return; }
2232
+ }
2186
2233
  if (touchpad) {
2187
2234
  // Touchpad: keep native scrolling, but once the gesture goes quiet
2188
2235
  // (fingers lifted, no wheel events) glide to the nearest whole row.
@@ -2198,8 +2245,13 @@
2198
2245
  }
2199
2246
  event.preventDefault();
2200
2247
  const max = el.scrollHeight - el.clientHeight;
2201
- const base = wheelTargetRef.current === null ? el.scrollTop : wheelTargetRef.current;
2202
- const next = Math.max(0, Math.min(max, base + (event.deltaY > 0 ? ROW_H : -ROW_H)));
2248
+ const current = el.scrollTop;
2249
+ const dir = event.deltaY > 0 ? 1 : -1;
2250
+ const pending = wheelTargetRef.current;
2251
+ // Direction reversal: if the pending target lies behind us, restart from the
2252
+ // real position — otherwise the page jumps backward before moving forward.
2253
+ const from = pending === null || (pending - current) * dir < 0 ? current : pending;
2254
+ const next = Math.max(0, Math.min(max, from + dir * ROW_H));
2203
2255
  wheelTargetRef.current = next;
2204
2256
  animateScrollTo(el, next, 200);
2205
2257
  }
@@ -2209,6 +2261,8 @@
2209
2261
  el.removeEventListener('wheel', onWheel);
2210
2262
  if (timerRef.current) clearTimeout(timerRef.current);
2211
2263
  if (touchpadSnapRef.current) clearTimeout(touchpadSnapRef.current);
2264
+ if (restoreTimer) clearTimeout(restoreTimer);
2265
+ restoringRef.current = false;
2212
2266
  };
2213
2267
  }, [sections, view]);
2214
2268
 
@@ -2352,16 +2406,65 @@
2352
2406
 
2353
2407
  function scrollToSection(index, smooth) {
2354
2408
  const el = scrollRef.current;
2355
- const node = sectionRefs.current[index];
2409
+ const node = sectionNode(sections[index]);
2356
2410
  if (!el || !node) return;
2357
- el.scrollTo({ top: Math.max(0, node.offsetTop), behavior: smooth ? 'smooth' : 'auto' });
2411
+ // Leave room for the sticky weekday bar, otherwise the section's first row
2412
+ // is cut in half under it.
2413
+ const elRect = el.getBoundingClientRect();
2414
+ const nodeRect = node.getBoundingClientRect();
2415
+ const top = el.scrollTop + (nodeRect.top - elRect.top) - WEEK_H;
2416
+ el.scrollTo({ top: Math.max(0, top), behavior: smooth ? 'smooth' : 'auto' });
2358
2417
  setCurrentSection(index);
2359
2418
  }
2360
2419
 
2420
+ function jumpToMonth(year, month) {
2421
+ const idx = sections.findIndex(function (s) { return s.year === year && s.month === month; });
2422
+ if (idx >= 0) {
2423
+ // Like Dida's GotoCalDate: jump straight there, no long smooth scroll.
2424
+ scrollToSection(idx, false);
2425
+ return;
2426
+ }
2427
+ // Target month sits outside the loaded range: widen the range, then scroll
2428
+ // once the new sections exist.
2429
+ pendingJumpRef.current = { year: year, month: month };
2430
+ const target = new Date(year, month, 1);
2431
+ setMonthRange(function (prev) {
2432
+ return {
2433
+ from: target < prev.from ? target : prev.from,
2434
+ to: target > prev.to ? target : prev.to,
2435
+ };
2436
+ });
2437
+ }
2438
+
2361
2439
  function goToday() {
2362
2440
  scrollToSection(todayIndex, true);
2363
2441
  }
2364
2442
 
2443
+ // Close the year/month picker on any outside pointerdown.
2444
+ useEffect(function () {
2445
+ if (!yearPicker) return undefined;
2446
+ function onDown(event) {
2447
+ const target = event.target;
2448
+ if (target && target.closest && (target.closest('[data-yearpicker]') || target.closest('[data-monthtoggle]'))) return;
2449
+ setYearPicker(null);
2450
+ }
2451
+ document.addEventListener('pointerdown', onDown, true);
2452
+ return function () {
2453
+ document.removeEventListener('pointerdown', onDown, true);
2454
+ };
2455
+ }, [yearPicker]);
2456
+
2457
+ // A jump requested for a month outside the loaded range runs after the new
2458
+ // sections have been rendered.
2459
+ useEffect(function () {
2460
+ const pending = pendingJumpRef.current;
2461
+ if (!pending) return;
2462
+ const idx = sections.findIndex(function (s) { return s.year === pending.year && s.month === pending.month; });
2463
+ if (idx < 0) return;
2464
+ pendingJumpRef.current = null;
2465
+ scrollToSection(idx, false);
2466
+ }, [sections]);
2467
+
2365
2468
  async function reorderDay(date, ids) {
2366
2469
  try {
2367
2470
  await apiPost('/mutate', { op: 'reorder', date: date, ids: ids });
@@ -2693,30 +2796,44 @@
2693
2796
 
2694
2797
  function extendMonths(dir) {
2695
2798
  const now = Date.now();
2696
- if (now - extendGuardRef.current < 400) return;
2799
+ if (now - extendGuardRef.current < 400) return false;
2697
2800
  extendGuardRef.current = now;
2801
+ // Prepend/append changes the scroll offset: cancel any running wheel
2802
+ // animation so it cannot drag the position back to the old target.
2803
+ snapAnimRef.current += 1;
2804
+ wheelTargetRef.current = null;
2805
+ programmaticRef.current = false;
2698
2806
  const el = scrollRef.current;
2699
2807
  const sec = sections[currentSection];
2700
- const node = sectionRefs.current[currentSection];
2808
+ const node = sectionNode(sections[currentSection]);
2701
2809
  if (el && sec && node) {
2702
- anchorRef.current = { year: sec.year, month: sec.month, delta: el.scrollTop - node.offsetTop };
2810
+ // Remember the anchor section's viewport offset, not offsetTop: offsetTop
2811
+ // depends on offsetParent and breaks when the container is not positioned.
2812
+ anchorRef.current = {
2813
+ year: sec.year,
2814
+ month: sec.month,
2815
+ viewTop: node.getBoundingClientRect().top - el.getBoundingClientRect().top,
2816
+ };
2703
2817
  }
2704
2818
  setMonthRange(function (prev) {
2705
2819
  if (dir === 'up') return { from: new Date(prev.from.getFullYear(), prev.from.getMonth() - 2, 1), to: prev.to };
2706
2820
  return { from: prev.from, to: new Date(prev.to.getFullYear(), prev.to.getMonth() + 2, 1) };
2707
2821
  });
2822
+ return true;
2708
2823
  }
2709
2824
 
2710
- // After months are prepended, keep the visible rows anchored.
2711
- useEffect(function () {
2825
+ // After months are prepended, keep the anchor section at the same viewport offset.
2826
+ // useLayoutEffect runs before paint, so the user never sees the shifted frame.
2827
+ useLayoutEffect(function () {
2712
2828
  const anchor = anchorRef.current;
2713
2829
  if (!anchor) return;
2714
2830
  anchorRef.current = null;
2715
2831
  const idx = sections.findIndex(function (s) { return s.year === anchor.year && s.month === anchor.month; });
2716
- const node = sectionRefs.current[idx];
2832
+ const node = sectionNode(sections[idx]);
2717
2833
  const el = scrollRef.current;
2718
2834
  if (idx >= 0 && node && el) {
2719
- el.scrollTop = node.offsetTop + anchor.delta;
2835
+ const currentTop = node.getBoundingClientRect().top - el.getBoundingClientRect().top;
2836
+ el.scrollTop = el.scrollTop + currentTop - anchor.viewTop;
2720
2837
  setCurrentSection(idx);
2721
2838
  }
2722
2839
  }, [sections]);
@@ -2753,6 +2870,21 @@
2753
2870
  const wheelTargetRef = useRef(null);
2754
2871
  const touchpadSnapRef = useRef(null);
2755
2872
 
2873
+ // Month label lingers and fades slowly (like Dida); the date/lunar under it
2874
+ // stays hidden until the fade finishes.
2875
+ useEffect(function () {
2876
+ if (scrolling) {
2877
+ setMonthPhase(1);
2878
+ return undefined;
2879
+ }
2880
+ const fadeTimer = setTimeout(function () { setMonthPhase(2); }, 650);
2881
+ const hideTimer = setTimeout(function () { setMonthPhase(0); }, 1400);
2882
+ return function () {
2883
+ clearTimeout(fadeTimer);
2884
+ clearTimeout(hideTimer);
2885
+ };
2886
+ }, [scrolling]);
2887
+
2756
2888
  /** Ease the scroll container to `target` over `duration` ms (cancellable). */
2757
2889
  function animateScrollTo(el, target, duration) {
2758
2890
  const start = el.scrollTop;
@@ -2829,9 +2961,20 @@
2829
2961
  const isFirst = day.getDate() === 1;
2830
2962
  const weekend = day.getDay() === 0 || day.getDay() === 6;
2831
2963
  const hideDate = outside && uiSettings.hideOtherMonths;
2832
- // While scrolling, the floating month label sits over the section's first
2833
- // cell — hide that cell's day number and lunar date so they don't collide.
2834
- const hideUnderMonth = scrolling && isSectionHead === true;
2964
+ // While scrolling (and while the month label fades out), the floating month
2965
+ // sits over the section's first row — hide the day/lunar cells it covers.
2966
+ // The label is wider than one cell on narrow windows, so measure how many
2967
+ // columns it spans instead of always hiding just the first one.
2968
+ let monthCover = 1;
2969
+ const scrollEl = scrollRef.current;
2970
+ if (scrollEl && scrollEl.clientWidth > 0) {
2971
+ const cellWidth = scrollEl.clientWidth / 7;
2972
+ const label = cellSection.year + '年' + (cellSection.month + 1) + '月';
2973
+ let labelWidth = 16; // padding
2974
+ for (const ch of label) labelWidth += /[0-9]/.test(ch) ? 13 : 24;
2975
+ monthCover = Math.max(1, Math.min(7, Math.ceil(labelWidth / cellWidth)));
2976
+ }
2977
+ const hideUnderMonth = monthPhase !== 0 && isSectionHead === true && column < monthCover;
2835
2978
  const holiday = allHolidays[key] || null;
2836
2979
  const badge = uiSettings.showHolidayBadge && holiday && holiday.state >= 0 ? holiday.state : null;
2837
2980
  // Dida rule: 调休补班日只出红「班」标;同名的连续假期只有第一天出蓝条。
@@ -2954,29 +3097,106 @@
2954
3097
  const calendarView = h('div', { style: S.calendar },
2955
3098
  h('div', { style: S.header },
2956
3099
  h('div', { style: S.headerLeft },
2957
- h('button', { style: S.iconBtn, onClick: function () { scrollToSection(currentSection - 1, true); } }, '‹'),
2958
- h('div', { style: S.monthTitle }, activeSection.year + '年' + (activeSection.month + 1) + '月'),
2959
- h('button', { style: S.iconBtn, onClick: function () { scrollToSection(currentSection + 1, true); } }, '›')
3100
+ h('button', {
3101
+ 'data-monthtoggle': true,
3102
+ style: Object.assign({}, S.monthTitle, {
3103
+ background: monthHover ? '#F1F3F6' : 'transparent',
3104
+ border: 'none',
3105
+ padding: '4px 8px',
3106
+ cursor: 'pointer',
3107
+ borderRadius: 6,
3108
+ textAlign: 'left',
3109
+ fontFamily: 'inherit',
3110
+ display: 'inline-flex',
3111
+ alignItems: 'center',
3112
+ gap: 2,
3113
+ transition: 'background .15s ease',
3114
+ }),
3115
+ onMouseEnter: function () { setMonthHover(true); },
3116
+ onMouseLeave: function () { setMonthHover(false); },
3117
+ onClick: function (event) {
3118
+ const rect = event.currentTarget.getBoundingClientRect();
3119
+ setYearPicker({ year: activeSection.year, x: rect.left, y: rect.bottom + 6 });
3120
+ },
3121
+ },
3122
+ activeSection.year + '年' + (activeSection.month + 1) + '月',
3123
+ h('span', { style: Object.assign({}, S.monthCaret, monthHover ? S.monthCaretOn : null) }, '▾')
3124
+ )
2960
3125
  ),
2961
3126
  h('div', { style: S.headerLeft },
2962
3127
  h('button', { style: S.todayBtn, onClick: goToday }, '今天')
2963
3128
  )
2964
3129
  ),
3130
+ yearPicker
3131
+ ? h('div', {
3132
+ 'data-yearpicker': true,
3133
+ style: Object.assign({}, S.yearPicker, {
3134
+ left: Math.max(8, Math.min(yearPicker.x, window.innerWidth - 300)),
3135
+ top: yearPicker.y,
3136
+ }),
3137
+ },
3138
+ h('div', { style: S.yearPickerHead },
3139
+ h('div', { style: S.yearPickerTitle }, yearPicker.year + '年'),
3140
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: 2 } },
3141
+ h('button', { style: S.iconBtn, onClick: function () { setYearPicker(function (p) { return p ? { year: p.year - 1, x: p.x, y: p.y } : p; }); } }, '‹'),
3142
+ h('button', {
3143
+ style: S.iconBtn,
3144
+ title: '回到当前月',
3145
+ onClick: function () {
3146
+ setYearPicker(null);
3147
+ scrollToSection(todayIndex, true);
3148
+ },
3149
+ }, '○'),
3150
+ h('button', { style: S.iconBtn, onClick: function () { setYearPicker(function (p) { return p ? { year: p.year + 1, x: p.x, y: p.y } : p; }); } }, '›')
3151
+ )
3152
+ ),
3153
+ h('div', { style: S.yearPickerGrid },
3154
+ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11].map(function (m) {
3155
+ const on = yearPicker.year === activeSection.year && m === activeSection.month;
3156
+ return h('div', {
3157
+ key: m,
3158
+ style: S.yearPickerCell,
3159
+ onClick: function () {
3160
+ const year = yearPicker.year;
3161
+ setYearPicker(null);
3162
+ jumpToMonth(year, m);
3163
+ },
3164
+ }, on
3165
+ ? h('svg', { width: 40, height: 40, viewBox: '0 0 40 40', style: { display: 'block' } },
3166
+ h('circle', { cx: 20, cy: 20, r: 20, fill: '#4A4F57' }),
3167
+ h('text', {
3168
+ x: 20,
3169
+ y: 25,
3170
+ textAnchor: 'middle',
3171
+ fill: '#fff',
3172
+ fontSize: 11.5,
3173
+ fontWeight: 600,
3174
+ }, (m + 1) + '月')
3175
+ )
3176
+ : (m + 1) + '月');
3177
+ })
3178
+ )
3179
+ )
3180
+ : null,
2965
3181
  h('div', { ref: scrollRef, style: S.scroll },
2966
3182
  h('div', { style: S.weekBar }, weekBarLabels(uiSettings.weekStart).map(function (name) {
2967
3183
  return h('div', { key: name, style: S.weekCell }, name);
2968
3184
  })),
2969
3185
  sections.map(function (sec, index) {
2970
3186
  return h('div', {
2971
- key: index,
3187
+ key: sec.year + '-' + sec.month,
2972
3188
  'data-month': index,
2973
- ref: function (node) { sectionRefs.current[index] = node; },
3189
+ ref: function (node) {
3190
+ const key = sec.year + '-' + sec.month;
3191
+ if (node) sectionRefs.current[key] = node;
3192
+ else delete sectionRefs.current[key];
3193
+ },
2974
3194
  style: S.section,
2975
3195
  },
2976
- h('div', { style: Object.assign({}, S.monthFloat, { opacity: scrolling ? 1 : 0 }) }, sec.year + '年' + (sec.month + 1) + '月'),
3196
+ h('div', { style: Object.assign({}, S.monthFloat, { opacity: monthPhase === 1 ? 1 : 0 }) }, sec.year + '年' + (sec.month + 1) + '月'),
2977
3197
  sec.weeks.map(function (week, weekIndex) {
2978
3198
  return h('div', { key: weekIndex, style: S.row }, week.map(function (day, column) {
2979
- return renderCell(day, column, sec, weekIndex === 0 && column === 0);
3199
+ return renderCell(day, column, sec, weekIndex === 0);
2980
3200
  }));
2981
3201
  })
2982
3202
  );
@@ -3130,6 +3350,7 @@
3130
3350
  h = React.createElement;
3131
3351
  useState = React.useState;
3132
3352
  useEffect = React.useEffect;
3353
+ useLayoutEffect = React.useLayoutEffect || React.useEffect;
3133
3354
  useMemo = React.useMemo;
3134
3355
  useRef = React.useRef;
3135
3356
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-calendar-lite",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "description": "轻量月历 for DeepSeek Harness:连续多月滚动、点格新建、点选完成、标签,数据只存本机。",
6
6
  "exports": {