@lemonadejs/calendar 5.9.0 → 5.9.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.
package/dist/react.d.ts CHANGED
@@ -41,15 +41,33 @@ declare namespace CalendarReact {
41
41
  style?: React.CSSProperties;
42
42
  children?: React.ReactNode;
43
43
  }
44
+
45
+ /**
46
+ * Re-export the underlying type namespace so consumers can write
47
+ * import { Calendar } from '@lemonadejs/calendar/react';
48
+ * import type { Calendar as CalendarNS } from '@lemonadejs/calendar/react';
49
+ * and get `CalendarNS.Options`, `CalendarNS.Instance`, etc. The same
50
+ * applies through the `@calendarjs/react` aggregate.
51
+ */
52
+ export type Options = Calendar.Options;
53
+ export type Instance = Calendar.Instance;
54
+ export type ValidRange = Calendar.ValidRange;
55
+ export type ValidRangeItem = Calendar.ValidRangeItem;
56
+ export type CloseOptions = Calendar.CloseOptions;
44
57
  }
45
58
 
46
- declare const CalendarReact: React.MemoExoticComponent<
59
+ // Interface (not const) so the value type declaration-merges with the
60
+ // namespace above. That merge carries the type members along with the
61
+ // React component value when the default export is re-exported.
62
+ interface CalendarReact extends React.MemoExoticComponent<
47
63
  React.ForwardRefExoticComponent<
48
64
  Omit<Calendar.Options, 'onchange' | 'onupdate' | 'onclose' | 'onopen' | 'onChange'>
49
65
  & CalendarReact.ReactCallbacks
50
66
  & CalendarReact.DOMProps
51
67
  & React.RefAttributes<Calendar.Instance>
52
68
  >
53
- >;
69
+ > {}
70
+
71
+ declare const CalendarReact: CalendarReact;
54
72
 
55
73
  export default CalendarReact;
package/dist/react.js CHANGED
@@ -38,6 +38,12 @@ const REACT_TO_LEMONADE = {
38
38
 
39
39
  const RESERVED_REACT_PROPS = new Set(['children', 'className', 'style', 'key']);
40
40
 
41
+ // HTML pass-through props (data-*, aria-*, role) are spread onto the
42
+ // wrapper div for testing/accessibility. They are NOT forwarded to the
43
+ // lemonadejs instance as options.
44
+ const isHtmlPassThroughProp = (key) =>
45
+ key.startsWith('data-') || key.startsWith('aria-') || key === 'role';
46
+
41
47
  const Calendar = memo(React.forwardRef((props, mainReference) => {
42
48
  const containerRef = useRef(null);
43
49
  const instanceRef = useRef(null);
@@ -49,13 +55,18 @@ const Calendar = memo(React.forwardRef((props, mainReference) => {
49
55
  // rerenders).
50
56
  propsRef.current = props;
51
57
 
52
- // Single-mount effect, StrictMode-safe via the `instance` guard.
58
+ // Single-mount effect. Guard via `instanceRef` (a ref, not the
59
+ // `instance` state) — under React StrictMode the mount effect runs
60
+ // twice and closures capture stale state, so checking `instance` here
61
+ // would mount the component twice into the same container. Refs are
62
+ // mutable and survive the re-run.
53
63
  useEffect(() => {
54
- if (!containerRef.current || instance) return;
64
+ if (!containerRef.current || instanceRef.current) return;
55
65
 
56
66
  const options = {};
57
67
  for (const key in props) {
58
68
  if (RESERVED_REACT_PROPS.has(key)) continue;
69
+ if (isHtmlPassThroughProp(key)) continue;
59
70
  const lemonadeKey = REACT_TO_LEMONADE[key] || key;
60
71
  const isReactCallback = key in REACT_TO_LEMONADE;
61
72
  const value = props[key];
@@ -87,6 +98,7 @@ const Calendar = memo(React.forwardRef((props, mainReference) => {
87
98
  if (!inst) return;
88
99
  for (const key in props) {
89
100
  if (RESERVED_REACT_PROPS.has(key)) continue;
101
+ if (isHtmlPassThroughProp(key)) continue;
90
102
  if (typeof props[key] === 'function') continue;
91
103
  const lemonadeKey = REACT_TO_LEMONADE[key] || key;
92
104
  if (Object.prototype.hasOwnProperty.call(inst, lemonadeKey)
@@ -99,11 +111,17 @@ const Calendar = memo(React.forwardRef((props, mainReference) => {
99
111
  // Expose the lemonadejs instance through the forwarded ref.
100
112
  useImperativeHandle(mainReference, () => instance, [instance]);
101
113
 
114
+ const htmlAttrs = {};
115
+ for (const key in props) {
116
+ if (isHtmlPassThroughProp(key)) htmlAttrs[key] = props[key];
117
+ }
118
+
102
119
  return React.createElement(React.Fragment, null,
103
120
  React.createElement('div', {
104
121
  ref: containerRef,
105
122
  className: props.className,
106
123
  style: { width: '100%', height: '100%', ...props.style },
124
+ ...htmlAttrs,
107
125
  }),
108
126
  props.children,
109
127
  );
package/package.json CHANGED
@@ -36,5 +36,5 @@
36
36
  "./style.css": "./dist/style.css",
37
37
  "./dist/*": "./dist/*"
38
38
  },
39
- "version": "5.9.0"
39
+ "version": "5.9.2"
40
40
  }