@lemonadejs/calendar 5.9.1 → 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.js +20 -2
- package/package.json +1 -1
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
|
|
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 ||
|
|
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