react-aria-components 1.12.1 → 1.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/dist/Autocomplete.main.js +3 -3
- package/dist/Autocomplete.main.js.map +1 -1
- package/dist/Autocomplete.mjs +3 -3
- package/dist/Autocomplete.module.js +3 -3
- package/dist/Autocomplete.module.js.map +1 -1
- package/dist/Button.main.js +5 -11
- package/dist/Button.main.js.map +1 -1
- package/dist/Button.mjs +5 -11
- package/dist/Button.module.js +5 -11
- package/dist/Button.module.js.map +1 -1
- package/dist/DateField.main.js +12 -8
- package/dist/DateField.main.js.map +1 -1
- package/dist/DateField.mjs +12 -8
- package/dist/DateField.module.js +12 -8
- package/dist/DateField.module.js.map +1 -1
- package/dist/DatePicker.main.js +6 -2
- package/dist/DatePicker.main.js.map +1 -1
- package/dist/DatePicker.mjs +6 -2
- package/dist/DatePicker.module.js +6 -2
- package/dist/DatePicker.module.js.map +1 -1
- package/dist/GridList.main.js +24 -21
- package/dist/GridList.main.js.map +1 -1
- package/dist/GridList.mjs +25 -23
- package/dist/GridList.module.js +25 -23
- package/dist/GridList.module.js.map +1 -1
- package/dist/Group.main.js +3 -2
- package/dist/Group.main.js.map +1 -1
- package/dist/Group.mjs +3 -2
- package/dist/Group.module.js +3 -2
- package/dist/Group.module.js.map +1 -1
- package/dist/Input.main.js.map +1 -1
- package/dist/Input.module.js.map +1 -1
- package/dist/ListBox.main.js +14 -4
- package/dist/ListBox.main.js.map +1 -1
- package/dist/ListBox.mjs +14 -4
- package/dist/ListBox.module.js +14 -4
- package/dist/ListBox.module.js.map +1 -1
- package/dist/Menu.main.js +16 -6
- package/dist/Menu.main.js.map +1 -1
- package/dist/Menu.mjs +16 -6
- package/dist/Menu.module.js +16 -6
- package/dist/Menu.module.js.map +1 -1
- package/dist/Modal.main.js +9 -1
- package/dist/Modal.main.js.map +1 -1
- package/dist/Modal.mjs +10 -2
- package/dist/Modal.module.js +10 -2
- package/dist/Modal.module.js.map +1 -1
- package/dist/NumberField.main.js +2 -1
- package/dist/NumberField.main.js.map +1 -1
- package/dist/NumberField.mjs +2 -1
- package/dist/NumberField.module.js +2 -1
- package/dist/NumberField.module.js.map +1 -1
- package/dist/ProgressBar.main.js.map +1 -1
- package/dist/ProgressBar.module.js.map +1 -1
- package/dist/RSPContexts.main.js +4 -0
- package/dist/RSPContexts.main.js.map +1 -1
- package/dist/RSPContexts.mjs +3 -1
- package/dist/RSPContexts.module.js +3 -1
- package/dist/RSPContexts.module.js.map +1 -1
- package/dist/RadioGroup.main.js +10 -2
- package/dist/RadioGroup.main.js.map +1 -1
- package/dist/RadioGroup.mjs +10 -2
- package/dist/RadioGroup.module.js +10 -2
- package/dist/RadioGroup.module.js.map +1 -1
- package/dist/SearchField.main.js +2 -2
- package/dist/SearchField.main.js.map +1 -1
- package/dist/SearchField.mjs +2 -2
- package/dist/SearchField.module.js +2 -2
- package/dist/SearchField.module.js.map +1 -1
- package/dist/Select.main.js +62 -22
- package/dist/Select.main.js.map +1 -1
- package/dist/Select.mjs +65 -25
- package/dist/Select.module.js +65 -25
- package/dist/Select.module.js.map +1 -1
- package/dist/SelectionIndicator.main.js +45 -0
- package/dist/SelectionIndicator.main.js.map +1 -0
- package/dist/SelectionIndicator.mjs +35 -0
- package/dist/SelectionIndicator.module.js +35 -0
- package/dist/SelectionIndicator.module.js.map +1 -0
- package/dist/SharedElementTransition.main.js +139 -0
- package/dist/SharedElementTransition.main.js.map +1 -0
- package/dist/SharedElementTransition.mjs +129 -0
- package/dist/SharedElementTransition.module.js +129 -0
- package/dist/SharedElementTransition.module.js.map +1 -0
- package/dist/Table.main.js +16 -11
- package/dist/Table.main.js.map +1 -1
- package/dist/Table.mjs +17 -12
- package/dist/Table.module.js +17 -12
- package/dist/Table.module.js.map +1 -1
- package/dist/Tabs.main.js +11 -3
- package/dist/Tabs.main.js.map +1 -1
- package/dist/Tabs.mjs +11 -3
- package/dist/Tabs.module.js +11 -3
- package/dist/Tabs.module.js.map +1 -1
- package/dist/TagGroup.main.js +28 -16
- package/dist/TagGroup.main.js.map +1 -1
- package/dist/TagGroup.mjs +28 -16
- package/dist/TagGroup.module.js +28 -16
- package/dist/TagGroup.module.js.map +1 -1
- package/dist/TextField.main.js +2 -2
- package/dist/TextField.main.js.map +1 -1
- package/dist/TextField.mjs +2 -2
- package/dist/TextField.module.js +2 -2
- package/dist/TextField.module.js.map +1 -1
- package/dist/ToggleButton.main.js +7 -1
- package/dist/ToggleButton.main.js.map +1 -1
- package/dist/ToggleButton.mjs +7 -1
- package/dist/ToggleButton.module.js +7 -1
- package/dist/ToggleButton.module.js.map +1 -1
- package/dist/ToggleButtonGroup.main.js +3 -1
- package/dist/ToggleButtonGroup.main.js.map +1 -1
- package/dist/ToggleButtonGroup.mjs +3 -1
- package/dist/ToggleButtonGroup.module.js +3 -1
- package/dist/ToggleButtonGroup.module.js.map +1 -1
- package/dist/Tree.main.js +16 -4
- package/dist/Tree.main.js.map +1 -1
- package/dist/Tree.mjs +16 -4
- package/dist/Tree.module.js +16 -4
- package/dist/Tree.module.js.map +1 -1
- package/dist/import.mjs +10 -4
- package/dist/main.js +18 -3
- package/dist/main.js.map +1 -1
- package/dist/module.js +10 -4
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +99 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.main.js.map +1 -1
- package/dist/utils.module.js.map +1 -1
- package/package.json +23 -23
- package/src/Autocomplete.tsx +1 -1
- package/src/Button.tsx +9 -11
- package/src/DateField.tsx +21 -12
- package/src/DatePicker.tsx +11 -2
- package/src/GridList.tsx +32 -33
- package/src/Group.tsx +5 -2
- package/src/Input.tsx +7 -1
- package/src/ListBox.tsx +12 -7
- package/src/Menu.tsx +11 -6
- package/src/Modal.tsx +11 -2
- package/src/NumberField.tsx +1 -1
- package/src/ProgressBar.tsx +1 -1
- package/src/RSPContexts.ts +19 -0
- package/src/RadioGroup.tsx +8 -2
- package/src/SearchField.tsx +1 -1
- package/src/Select.tsx +75 -34
- package/src/SelectionIndicator.tsx +40 -0
- package/src/SharedElementTransition.tsx +185 -0
- package/src/Table.tsx +17 -16
- package/src/Tabs.tsx +8 -2
- package/src/TagGroup.tsx +31 -24
- package/src/TextField.tsx +1 -1
- package/src/ToggleButton.tsx +6 -1
- package/src/ToggleButtonGroup.tsx +4 -1
- package/src/Tree.tsx +16 -9
- package/src/index.ts +10 -3
- package/src/utils.tsx +1 -1
- package/dist/context.main.js +0 -25
- package/dist/context.main.js.map +0 -1
- package/dist/context.mjs +0 -19
- package/dist/context.module.js +0 -19
- package/dist/context.module.js.map +0 -1
- package/src/context.tsx +0 -34
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
var $c5ccf687772c0422$exports = require("./utils.main.js");
|
|
2
|
+
var $aakJU$reactdom = require("react-dom");
|
|
3
|
+
var $aakJU$react = require("react");
|
|
4
|
+
var $aakJU$reactariautils = require("@react-aria/utils");
|
|
5
|
+
var $aakJU$reactaria = require("react-aria");
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function $parcel$interopDefault(a) {
|
|
9
|
+
return a && a.__esModule ? a.default : a;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function $parcel$export(e, n, v, s) {
|
|
13
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
$parcel$export(module.exports, "SharedElementTransition", () => $2d10bc562fea46b3$export$758399f318e6385a);
|
|
17
|
+
$parcel$export(module.exports, "SharedElement", () => $2d10bc562fea46b3$export$c34620ff8881d89f);
|
|
18
|
+
/*
|
|
19
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
20
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
21
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
22
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
23
|
+
*
|
|
24
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
25
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
26
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
27
|
+
* governing permissions and limitations under the License.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
const $2d10bc562fea46b3$var$SharedElementContext = /*#__PURE__*/ (0, $aakJU$react.createContext)(null);
|
|
34
|
+
function $2d10bc562fea46b3$export$758399f318e6385a(props) {
|
|
35
|
+
let ref = (0, $aakJU$react.useRef)({});
|
|
36
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($aakJU$react))).createElement($2d10bc562fea46b3$var$SharedElementContext.Provider, {
|
|
37
|
+
value: ref
|
|
38
|
+
}, props.children);
|
|
39
|
+
}
|
|
40
|
+
const $2d10bc562fea46b3$export$c34620ff8881d89f = /*#__PURE__*/ (0, $aakJU$react.forwardRef)(function SharedElement(props, ref) {
|
|
41
|
+
let { name: name, isVisible: isVisible = true, children: children, className: className, style: style, ...divProps } = props;
|
|
42
|
+
let [state, setState] = (0, $aakJU$react.useState)(isVisible ? 'visible' : 'hidden');
|
|
43
|
+
let scopeRef = (0, $aakJU$react.useContext)($2d10bc562fea46b3$var$SharedElementContext);
|
|
44
|
+
if (!scopeRef) throw new Error('<SharedElement> must be rendered inside a <SharedElementTransition>');
|
|
45
|
+
if (isVisible && state === 'hidden') setState('visible');
|
|
46
|
+
ref = (0, $aakJU$reactaria.useObjectRef)(ref);
|
|
47
|
+
(0, $aakJU$reactariautils.useLayoutEffect)(()=>{
|
|
48
|
+
let element = ref.current;
|
|
49
|
+
let scope = scopeRef.current;
|
|
50
|
+
let prevSnapshot = scope[name];
|
|
51
|
+
let frame = null;
|
|
52
|
+
if (element && isVisible && prevSnapshot) {
|
|
53
|
+
// Element is transitioning from a previous instance.
|
|
54
|
+
setState('visible');
|
|
55
|
+
let animations = element.getAnimations();
|
|
56
|
+
// Set properties to animate from.
|
|
57
|
+
let values = prevSnapshot.style.map(([property, prevValue])=>{
|
|
58
|
+
let value = element.style[property];
|
|
59
|
+
if (property === 'translate') {
|
|
60
|
+
let prevRect = prevSnapshot.rect;
|
|
61
|
+
let currentItem = element.getBoundingClientRect();
|
|
62
|
+
let deltaX = prevRect.left - (currentItem === null || currentItem === void 0 ? void 0 : currentItem.left);
|
|
63
|
+
let deltaY = prevRect.top - (currentItem === null || currentItem === void 0 ? void 0 : currentItem.top);
|
|
64
|
+
element.style.translate = `${deltaX}px ${deltaY}px`;
|
|
65
|
+
} else element.style[property] = prevValue;
|
|
66
|
+
return [
|
|
67
|
+
property,
|
|
68
|
+
value
|
|
69
|
+
];
|
|
70
|
+
});
|
|
71
|
+
// Cancel any new animations triggered by these properties.
|
|
72
|
+
for (let a of element.getAnimations())if (!animations.includes(a)) a.cancel();
|
|
73
|
+
// Remove overrides after one frame to animate to the current values.
|
|
74
|
+
frame = requestAnimationFrame(()=>{
|
|
75
|
+
frame = null;
|
|
76
|
+
for (let [property, value] of values)element.style[property] = value;
|
|
77
|
+
});
|
|
78
|
+
delete scope[name];
|
|
79
|
+
} else if (element && isVisible && !prevSnapshot) {
|
|
80
|
+
// No previous instance exists, apply the entering state.
|
|
81
|
+
queueMicrotask(()=>(0, $aakJU$reactdom.flushSync)(()=>setState('entering')));
|
|
82
|
+
frame = requestAnimationFrame(()=>{
|
|
83
|
+
frame = null;
|
|
84
|
+
setState('visible');
|
|
85
|
+
});
|
|
86
|
+
} else if (element && !isVisible) // Wait until layout effects finish, and check if a snapshot still exists.
|
|
87
|
+
// If so, no new SharedElement consumed it, so enter the exiting state.
|
|
88
|
+
queueMicrotask(()=>{
|
|
89
|
+
if (scope[name]) {
|
|
90
|
+
delete scope[name];
|
|
91
|
+
(0, $aakJU$reactdom.flushSync)(()=>setState('exiting'));
|
|
92
|
+
Promise.all(element.getAnimations().map((a)=>a.finished)).then(()=>setState('hidden')).catch(()=>{});
|
|
93
|
+
} else // Snapshot was consumed by another instance, unmount.
|
|
94
|
+
setState('hidden');
|
|
95
|
+
});
|
|
96
|
+
return ()=>{
|
|
97
|
+
if (frame != null) cancelAnimationFrame(frame);
|
|
98
|
+
if (element && element.isConnected && !element.hasAttribute('data-exiting')) {
|
|
99
|
+
// On unmount, store a snapshot of the rectangle and computed style for transitioning properties.
|
|
100
|
+
let style = window.getComputedStyle(element);
|
|
101
|
+
if (style.transitionProperty !== 'none') {
|
|
102
|
+
let transitionProperty = style.transitionProperty.split(/\s*,\s*/);
|
|
103
|
+
scope[name] = {
|
|
104
|
+
rect: element.getBoundingClientRect(),
|
|
105
|
+
style: transitionProperty.map((p)=>[
|
|
106
|
+
p,
|
|
107
|
+
style[p]
|
|
108
|
+
])
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}, [
|
|
114
|
+
ref,
|
|
115
|
+
scopeRef,
|
|
116
|
+
name,
|
|
117
|
+
isVisible
|
|
118
|
+
]);
|
|
119
|
+
let renderProps = (0, $c5ccf687772c0422$exports.useRenderProps)({
|
|
120
|
+
children: children,
|
|
121
|
+
className: className,
|
|
122
|
+
style: style,
|
|
123
|
+
values: {
|
|
124
|
+
isEntering: state === 'entering',
|
|
125
|
+
isExiting: state === 'exiting'
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
if (state === 'hidden') return null;
|
|
129
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($aakJU$react))).createElement("div", {
|
|
130
|
+
...divProps,
|
|
131
|
+
...renderProps,
|
|
132
|
+
ref: ref,
|
|
133
|
+
"data-entering": state === 'entering' || undefined,
|
|
134
|
+
"data-exiting": state === 'exiting' || undefined
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
//# sourceMappingURL=SharedElementTransition.main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CA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AAC,KAAK,GAAG;wBACZ,MAAM,QAAQ,qBAAqB;wBACnC,OAAO,mBAAmB,GAAG,CAAC,CAAA,IAAK;gCAAC;gCAAG,KAAK,CAAC,EAAE;6BAAC;oBAClD;gBACF;YACF;QACF;IACF,GAAG;QAAC;QAAK;QAAU;QAAM;KAAU;IAEnC,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;kBAC/B;mBACA;eACA;QACA,QAAQ;YACN,YAAY,UAAU;YACtB,WAAW,UAAU;QACvB;IACF;IAEA,IAAI,UAAU,UACZ,OAAO;IAGT,qBACE,0DAAC;QACE,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,KAAK;QACL,iBAAe,UAAU,cAAc;QACvC,gBAAc,UAAU,aAAa;;AAE3C","sources":["packages/react-aria-components/src/SharedElementTransition.tsx"],"sourcesContent":["/*\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {flushSync} from 'react-dom';\nimport React, {createContext, ForwardedRef, forwardRef, HTMLAttributes, ReactNode, RefObject, useContext, useRef, useState} from 'react';\nimport {RenderProps, useRenderProps} from './utils';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useObjectRef} from 'react-aria';\n\ninterface Snapshot {\n rect: DOMRect,\n style: [string, string][]\n}\n\nconst SharedElementContext = createContext<RefObject<{[name: string]: Snapshot}> | null>(null);\n\nexport interface SharedElementTransitionProps {\n children: ReactNode\n}\n\n/**\n * A scope for SharedElements, which animate between parents.\n */\nexport function SharedElementTransition(props: SharedElementTransitionProps) {\n let ref = useRef({});\n return (\n <SharedElementContext.Provider value={ref}>\n {props.children}\n </SharedElementContext.Provider>\n );\n}\n\nexport interface SharedElementRenderProps {\n /**\n * Whether the element is currently entering.\n * @selector [data-entering]\n */\n isEntering: boolean,\n /**\n * Whether the element is currently exiting.\n * @selector [data-exiting]\n */\n isExiting: boolean\n}\n\nexport interface SharedElementPropsBase extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'className' | 'style'>, RenderProps<SharedElementRenderProps> {}\n\nexport interface SharedElementProps extends SharedElementPropsBase {\n name: string,\n isVisible?: boolean\n}\n\n/**\n * An element that animates between its old and new position when moving between parents.\n */\nexport const SharedElement = forwardRef(function SharedElement(props: SharedElementProps, ref: ForwardedRef<HTMLDivElement>) {\n let {name, isVisible = true, children, className, style, ...divProps} = props;\n let [state, setState] = useState(isVisible ? 'visible' : 'hidden');\n let scopeRef = useContext(SharedElementContext);\n if (!scopeRef) {\n throw new Error('<SharedElement> must be rendered inside a <SharedElementTransition>');\n }\n\n if (isVisible && state === 'hidden') {\n setState('visible');\n }\n\n ref = useObjectRef(ref);\n useLayoutEffect(() => {\n let element = ref.current;\n let scope = scopeRef.current;\n let prevSnapshot = scope[name];\n let frame: number | null = null;\n\n if (element && isVisible && prevSnapshot) {\n // Element is transitioning from a previous instance.\n setState('visible');\n let animations = element.getAnimations();\n\n // Set properties to animate from.\n let values = prevSnapshot.style.map(([property, prevValue]) => {\n let value = element.style[property];\n if (property === 'translate') {\n let prevRect = prevSnapshot.rect;\n let currentItem = element.getBoundingClientRect();\n let deltaX = prevRect.left - currentItem?.left;\n let deltaY = prevRect.top - currentItem?.top;\n element.style.translate = `${deltaX}px ${deltaY}px`;\n } else {\n element.style[property] = prevValue;\n }\n return [property, value];\n });\n\n // Cancel any new animations triggered by these properties.\n for (let a of element.getAnimations()) {\n if (!animations.includes(a)) {\n a.cancel();\n }\n }\n\n // Remove overrides after one frame to animate to the current values.\n frame = requestAnimationFrame(() => {\n frame = null;\n for (let [property, value] of values) {\n element.style[property] = value;\n }\n });\n\n delete scope[name];\n } else if (element && isVisible && !prevSnapshot) {\n // No previous instance exists, apply the entering state.\n queueMicrotask(() => flushSync(() => setState('entering')));\n frame = requestAnimationFrame(() => {\n frame = null;\n setState('visible');\n });\n } else if (element && !isVisible) {\n // Wait until layout effects finish, and check if a snapshot still exists.\n // If so, no new SharedElement consumed it, so enter the exiting state.\n queueMicrotask(() => {\n if (scope[name]) {\n delete scope[name];\n flushSync(() => setState('exiting'));\n Promise.all(element.getAnimations().map(a => a.finished))\n .then(() => setState('hidden'))\n .catch(() => {});\n } else {\n // Snapshot was consumed by another instance, unmount.\n setState('hidden');\n }\n });\n }\n\n return () => {\n if (frame != null) {\n cancelAnimationFrame(frame);\n }\n\n if (element && element.isConnected && !element.hasAttribute('data-exiting')) {\n // On unmount, store a snapshot of the rectangle and computed style for transitioning properties.\n let style = window.getComputedStyle(element);\n if (style.transitionProperty !== 'none') {\n let transitionProperty = style.transitionProperty.split(/\\s*,\\s*/);\n scope[name] = {\n rect: element.getBoundingClientRect(),\n style: transitionProperty.map(p => [p, style[p]])\n };\n }\n }\n };\n }, [ref, scopeRef, name, isVisible]);\n\n let renderProps = useRenderProps({\n children,\n className,\n style,\n values: {\n isEntering: state === 'entering',\n isExiting: state === 'exiting'\n }\n });\n\n if (state === 'hidden') {\n return null;\n }\n\n return (\n <div\n {...divProps}\n {...renderProps}\n ref={ref}\n data-entering={state === 'entering' || undefined}\n data-exiting={state === 'exiting' || undefined} />\n );\n});\n"],"names":[],"version":3,"file":"SharedElementTransition.main.js.map"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {useRenderProps as $64fa3d84918910a7$export$4d86445c2cf5e3} from "./utils.mjs";
|
|
2
|
+
import {flushSync as $I3GNx$flushSync} from "react-dom";
|
|
3
|
+
import $I3GNx$react, {createContext as $I3GNx$createContext, useRef as $I3GNx$useRef, forwardRef as $I3GNx$forwardRef, useState as $I3GNx$useState, useContext as $I3GNx$useContext} from "react";
|
|
4
|
+
import {useLayoutEffect as $I3GNx$useLayoutEffect} from "@react-aria/utils";
|
|
5
|
+
import {useObjectRef as $I3GNx$useObjectRef} from "react-aria";
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
9
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
* governing permissions and limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const $c8a5a149f625efcf$var$SharedElementContext = /*#__PURE__*/ (0, $I3GNx$createContext)(null);
|
|
23
|
+
function $c8a5a149f625efcf$export$758399f318e6385a(props) {
|
|
24
|
+
let ref = (0, $I3GNx$useRef)({});
|
|
25
|
+
return /*#__PURE__*/ (0, $I3GNx$react).createElement($c8a5a149f625efcf$var$SharedElementContext.Provider, {
|
|
26
|
+
value: ref
|
|
27
|
+
}, props.children);
|
|
28
|
+
}
|
|
29
|
+
const $c8a5a149f625efcf$export$c34620ff8881d89f = /*#__PURE__*/ (0, $I3GNx$forwardRef)(function SharedElement(props, ref) {
|
|
30
|
+
let { name: name, isVisible: isVisible = true, children: children, className: className, style: style, ...divProps } = props;
|
|
31
|
+
let [state, setState] = (0, $I3GNx$useState)(isVisible ? 'visible' : 'hidden');
|
|
32
|
+
let scopeRef = (0, $I3GNx$useContext)($c8a5a149f625efcf$var$SharedElementContext);
|
|
33
|
+
if (!scopeRef) throw new Error('<SharedElement> must be rendered inside a <SharedElementTransition>');
|
|
34
|
+
if (isVisible && state === 'hidden') setState('visible');
|
|
35
|
+
ref = (0, $I3GNx$useObjectRef)(ref);
|
|
36
|
+
(0, $I3GNx$useLayoutEffect)(()=>{
|
|
37
|
+
let element = ref.current;
|
|
38
|
+
let scope = scopeRef.current;
|
|
39
|
+
let prevSnapshot = scope[name];
|
|
40
|
+
let frame = null;
|
|
41
|
+
if (element && isVisible && prevSnapshot) {
|
|
42
|
+
// Element is transitioning from a previous instance.
|
|
43
|
+
setState('visible');
|
|
44
|
+
let animations = element.getAnimations();
|
|
45
|
+
// Set properties to animate from.
|
|
46
|
+
let values = prevSnapshot.style.map(([property, prevValue])=>{
|
|
47
|
+
let value = element.style[property];
|
|
48
|
+
if (property === 'translate') {
|
|
49
|
+
let prevRect = prevSnapshot.rect;
|
|
50
|
+
let currentItem = element.getBoundingClientRect();
|
|
51
|
+
let deltaX = prevRect.left - (currentItem === null || currentItem === void 0 ? void 0 : currentItem.left);
|
|
52
|
+
let deltaY = prevRect.top - (currentItem === null || currentItem === void 0 ? void 0 : currentItem.top);
|
|
53
|
+
element.style.translate = `${deltaX}px ${deltaY}px`;
|
|
54
|
+
} else element.style[property] = prevValue;
|
|
55
|
+
return [
|
|
56
|
+
property,
|
|
57
|
+
value
|
|
58
|
+
];
|
|
59
|
+
});
|
|
60
|
+
// Cancel any new animations triggered by these properties.
|
|
61
|
+
for (let a of element.getAnimations())if (!animations.includes(a)) a.cancel();
|
|
62
|
+
// Remove overrides after one frame to animate to the current values.
|
|
63
|
+
frame = requestAnimationFrame(()=>{
|
|
64
|
+
frame = null;
|
|
65
|
+
for (let [property, value] of values)element.style[property] = value;
|
|
66
|
+
});
|
|
67
|
+
delete scope[name];
|
|
68
|
+
} else if (element && isVisible && !prevSnapshot) {
|
|
69
|
+
// No previous instance exists, apply the entering state.
|
|
70
|
+
queueMicrotask(()=>(0, $I3GNx$flushSync)(()=>setState('entering')));
|
|
71
|
+
frame = requestAnimationFrame(()=>{
|
|
72
|
+
frame = null;
|
|
73
|
+
setState('visible');
|
|
74
|
+
});
|
|
75
|
+
} else if (element && !isVisible) // Wait until layout effects finish, and check if a snapshot still exists.
|
|
76
|
+
// If so, no new SharedElement consumed it, so enter the exiting state.
|
|
77
|
+
queueMicrotask(()=>{
|
|
78
|
+
if (scope[name]) {
|
|
79
|
+
delete scope[name];
|
|
80
|
+
(0, $I3GNx$flushSync)(()=>setState('exiting'));
|
|
81
|
+
Promise.all(element.getAnimations().map((a)=>a.finished)).then(()=>setState('hidden')).catch(()=>{});
|
|
82
|
+
} else // Snapshot was consumed by another instance, unmount.
|
|
83
|
+
setState('hidden');
|
|
84
|
+
});
|
|
85
|
+
return ()=>{
|
|
86
|
+
if (frame != null) cancelAnimationFrame(frame);
|
|
87
|
+
if (element && element.isConnected && !element.hasAttribute('data-exiting')) {
|
|
88
|
+
// On unmount, store a snapshot of the rectangle and computed style for transitioning properties.
|
|
89
|
+
let style = window.getComputedStyle(element);
|
|
90
|
+
if (style.transitionProperty !== 'none') {
|
|
91
|
+
let transitionProperty = style.transitionProperty.split(/\s*,\s*/);
|
|
92
|
+
scope[name] = {
|
|
93
|
+
rect: element.getBoundingClientRect(),
|
|
94
|
+
style: transitionProperty.map((p)=>[
|
|
95
|
+
p,
|
|
96
|
+
style[p]
|
|
97
|
+
])
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}, [
|
|
103
|
+
ref,
|
|
104
|
+
scopeRef,
|
|
105
|
+
name,
|
|
106
|
+
isVisible
|
|
107
|
+
]);
|
|
108
|
+
let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
|
|
109
|
+
children: children,
|
|
110
|
+
className: className,
|
|
111
|
+
style: style,
|
|
112
|
+
values: {
|
|
113
|
+
isEntering: state === 'entering',
|
|
114
|
+
isExiting: state === 'exiting'
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
if (state === 'hidden') return null;
|
|
118
|
+
return /*#__PURE__*/ (0, $I3GNx$react).createElement("div", {
|
|
119
|
+
...divProps,
|
|
120
|
+
...renderProps,
|
|
121
|
+
ref: ref,
|
|
122
|
+
"data-entering": state === 'entering' || undefined,
|
|
123
|
+
"data-exiting": state === 'exiting' || undefined
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
export {$c8a5a149f625efcf$export$758399f318e6385a as SharedElementTransition, $c8a5a149f625efcf$export$c34620ff8881d89f as SharedElement};
|
|
129
|
+
//# sourceMappingURL=SharedElementTransition.module.js.map
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import {useRenderProps as $64fa3d84918910a7$export$4d86445c2cf5e3} from "./utils.module.js";
|
|
2
|
+
import {flushSync as $I3GNx$flushSync} from "react-dom";
|
|
3
|
+
import $I3GNx$react, {createContext as $I3GNx$createContext, useRef as $I3GNx$useRef, forwardRef as $I3GNx$forwardRef, useState as $I3GNx$useState, useContext as $I3GNx$useContext} from "react";
|
|
4
|
+
import {useLayoutEffect as $I3GNx$useLayoutEffect} from "@react-aria/utils";
|
|
5
|
+
import {useObjectRef as $I3GNx$useObjectRef} from "react-aria";
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Copyright 2025 Adobe. All rights reserved.
|
|
9
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
+
* governing permissions and limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
const $c8a5a149f625efcf$var$SharedElementContext = /*#__PURE__*/ (0, $I3GNx$createContext)(null);
|
|
23
|
+
function $c8a5a149f625efcf$export$758399f318e6385a(props) {
|
|
24
|
+
let ref = (0, $I3GNx$useRef)({});
|
|
25
|
+
return /*#__PURE__*/ (0, $I3GNx$react).createElement($c8a5a149f625efcf$var$SharedElementContext.Provider, {
|
|
26
|
+
value: ref
|
|
27
|
+
}, props.children);
|
|
28
|
+
}
|
|
29
|
+
const $c8a5a149f625efcf$export$c34620ff8881d89f = /*#__PURE__*/ (0, $I3GNx$forwardRef)(function SharedElement(props, ref) {
|
|
30
|
+
let { name: name, isVisible: isVisible = true, children: children, className: className, style: style, ...divProps } = props;
|
|
31
|
+
let [state, setState] = (0, $I3GNx$useState)(isVisible ? 'visible' : 'hidden');
|
|
32
|
+
let scopeRef = (0, $I3GNx$useContext)($c8a5a149f625efcf$var$SharedElementContext);
|
|
33
|
+
if (!scopeRef) throw new Error('<SharedElement> must be rendered inside a <SharedElementTransition>');
|
|
34
|
+
if (isVisible && state === 'hidden') setState('visible');
|
|
35
|
+
ref = (0, $I3GNx$useObjectRef)(ref);
|
|
36
|
+
(0, $I3GNx$useLayoutEffect)(()=>{
|
|
37
|
+
let element = ref.current;
|
|
38
|
+
let scope = scopeRef.current;
|
|
39
|
+
let prevSnapshot = scope[name];
|
|
40
|
+
let frame = null;
|
|
41
|
+
if (element && isVisible && prevSnapshot) {
|
|
42
|
+
// Element is transitioning from a previous instance.
|
|
43
|
+
setState('visible');
|
|
44
|
+
let animations = element.getAnimations();
|
|
45
|
+
// Set properties to animate from.
|
|
46
|
+
let values = prevSnapshot.style.map(([property, prevValue])=>{
|
|
47
|
+
let value = element.style[property];
|
|
48
|
+
if (property === 'translate') {
|
|
49
|
+
let prevRect = prevSnapshot.rect;
|
|
50
|
+
let currentItem = element.getBoundingClientRect();
|
|
51
|
+
let deltaX = prevRect.left - (currentItem === null || currentItem === void 0 ? void 0 : currentItem.left);
|
|
52
|
+
let deltaY = prevRect.top - (currentItem === null || currentItem === void 0 ? void 0 : currentItem.top);
|
|
53
|
+
element.style.translate = `${deltaX}px ${deltaY}px`;
|
|
54
|
+
} else element.style[property] = prevValue;
|
|
55
|
+
return [
|
|
56
|
+
property,
|
|
57
|
+
value
|
|
58
|
+
];
|
|
59
|
+
});
|
|
60
|
+
// Cancel any new animations triggered by these properties.
|
|
61
|
+
for (let a of element.getAnimations())if (!animations.includes(a)) a.cancel();
|
|
62
|
+
// Remove overrides after one frame to animate to the current values.
|
|
63
|
+
frame = requestAnimationFrame(()=>{
|
|
64
|
+
frame = null;
|
|
65
|
+
for (let [property, value] of values)element.style[property] = value;
|
|
66
|
+
});
|
|
67
|
+
delete scope[name];
|
|
68
|
+
} else if (element && isVisible && !prevSnapshot) {
|
|
69
|
+
// No previous instance exists, apply the entering state.
|
|
70
|
+
queueMicrotask(()=>(0, $I3GNx$flushSync)(()=>setState('entering')));
|
|
71
|
+
frame = requestAnimationFrame(()=>{
|
|
72
|
+
frame = null;
|
|
73
|
+
setState('visible');
|
|
74
|
+
});
|
|
75
|
+
} else if (element && !isVisible) // Wait until layout effects finish, and check if a snapshot still exists.
|
|
76
|
+
// If so, no new SharedElement consumed it, so enter the exiting state.
|
|
77
|
+
queueMicrotask(()=>{
|
|
78
|
+
if (scope[name]) {
|
|
79
|
+
delete scope[name];
|
|
80
|
+
(0, $I3GNx$flushSync)(()=>setState('exiting'));
|
|
81
|
+
Promise.all(element.getAnimations().map((a)=>a.finished)).then(()=>setState('hidden')).catch(()=>{});
|
|
82
|
+
} else // Snapshot was consumed by another instance, unmount.
|
|
83
|
+
setState('hidden');
|
|
84
|
+
});
|
|
85
|
+
return ()=>{
|
|
86
|
+
if (frame != null) cancelAnimationFrame(frame);
|
|
87
|
+
if (element && element.isConnected && !element.hasAttribute('data-exiting')) {
|
|
88
|
+
// On unmount, store a snapshot of the rectangle and computed style for transitioning properties.
|
|
89
|
+
let style = window.getComputedStyle(element);
|
|
90
|
+
if (style.transitionProperty !== 'none') {
|
|
91
|
+
let transitionProperty = style.transitionProperty.split(/\s*,\s*/);
|
|
92
|
+
scope[name] = {
|
|
93
|
+
rect: element.getBoundingClientRect(),
|
|
94
|
+
style: transitionProperty.map((p)=>[
|
|
95
|
+
p,
|
|
96
|
+
style[p]
|
|
97
|
+
])
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}, [
|
|
103
|
+
ref,
|
|
104
|
+
scopeRef,
|
|
105
|
+
name,
|
|
106
|
+
isVisible
|
|
107
|
+
]);
|
|
108
|
+
let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
|
|
109
|
+
children: children,
|
|
110
|
+
className: className,
|
|
111
|
+
style: style,
|
|
112
|
+
values: {
|
|
113
|
+
isEntering: state === 'entering',
|
|
114
|
+
isExiting: state === 'exiting'
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
if (state === 'hidden') return null;
|
|
118
|
+
return /*#__PURE__*/ (0, $I3GNx$react).createElement("div", {
|
|
119
|
+
...divProps,
|
|
120
|
+
...renderProps,
|
|
121
|
+
ref: ref,
|
|
122
|
+
"data-entering": state === 'entering' || undefined,
|
|
123
|
+
"data-exiting": state === 'exiting' || undefined
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
export {$c8a5a149f625efcf$export$758399f318e6385a as SharedElementTransition, $c8a5a149f625efcf$export$c34620ff8881d89f as SharedElement};
|
|
129
|
+
//# sourceMappingURL=SharedElementTransition.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAaD,MAAM,2DAAuB,CAAA,GAAA,oBAAY,EAAgD;AASlF,SAAS,0CAAwB,KAAmC;IACzE,IAAI,MAAM,CAAA,GAAA,aAAK,EAAE,CAAC;IAClB,qBACE,gCAAC,2CAAqB,QAAQ;QAAC,OAAO;OACnC,MAAM,QAAQ;AAGrB;AAyBO,MAAM,0DAAgB,CAAA,GAAA,iBAAS,EAAE,SAAS,cAAc,KAAyB,EAAE,GAAiC;IACzH,IAAI,Q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UAAU;QACvB;IACF;IAEA,IAAI,UAAU,UACZ,OAAO;IAGT,qBACE,gCAAC;QACE,GAAG,QAAQ;QACX,GAAG,WAAW;QACf,KAAK;QACL,iBAAe,UAAU,cAAc;QACvC,gBAAc,UAAU,aAAa;;AAE3C","sources":["packages/react-aria-components/src/SharedElementTransition.tsx"],"sourcesContent":["/*\n * Copyright 2025 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {flushSync} from 'react-dom';\nimport React, {createContext, ForwardedRef, forwardRef, HTMLAttributes, ReactNode, RefObject, useContext, useRef, useState} from 'react';\nimport {RenderProps, useRenderProps} from './utils';\nimport {useLayoutEffect} from '@react-aria/utils';\nimport {useObjectRef} from 'react-aria';\n\ninterface Snapshot {\n rect: DOMRect,\n style: [string, string][]\n}\n\nconst SharedElementContext = createContext<RefObject<{[name: string]: Snapshot}> | null>(null);\n\nexport interface SharedElementTransitionProps {\n children: ReactNode\n}\n\n/**\n * A scope for SharedElements, which animate between parents.\n */\nexport function SharedElementTransition(props: SharedElementTransitionProps) {\n let ref = useRef({});\n return (\n <SharedElementContext.Provider value={ref}>\n {props.children}\n </SharedElementContext.Provider>\n );\n}\n\nexport interface SharedElementRenderProps {\n /**\n * Whether the element is currently entering.\n * @selector [data-entering]\n */\n isEntering: boolean,\n /**\n * Whether the element is currently exiting.\n * @selector [data-exiting]\n */\n isExiting: boolean\n}\n\nexport interface SharedElementPropsBase extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'className' | 'style'>, RenderProps<SharedElementRenderProps> {}\n\nexport interface SharedElementProps extends SharedElementPropsBase {\n name: string,\n isVisible?: boolean\n}\n\n/**\n * An element that animates between its old and new position when moving between parents.\n */\nexport const SharedElement = forwardRef(function SharedElement(props: SharedElementProps, ref: ForwardedRef<HTMLDivElement>) {\n let {name, isVisible = true, children, className, style, ...divProps} = props;\n let [state, setState] = useState(isVisible ? 'visible' : 'hidden');\n let scopeRef = useContext(SharedElementContext);\n if (!scopeRef) {\n throw new Error('<SharedElement> must be rendered inside a <SharedElementTransition>');\n }\n\n if (isVisible && state === 'hidden') {\n setState('visible');\n }\n\n ref = useObjectRef(ref);\n useLayoutEffect(() => {\n let element = ref.current;\n let scope = scopeRef.current;\n let prevSnapshot = scope[name];\n let frame: number | null = null;\n\n if (element && isVisible && prevSnapshot) {\n // Element is transitioning from a previous instance.\n setState('visible');\n let animations = element.getAnimations();\n\n // Set properties to animate from.\n let values = prevSnapshot.style.map(([property, prevValue]) => {\n let value = element.style[property];\n if (property === 'translate') {\n let prevRect = prevSnapshot.rect;\n let currentItem = element.getBoundingClientRect();\n let deltaX = prevRect.left - currentItem?.left;\n let deltaY = prevRect.top - currentItem?.top;\n element.style.translate = `${deltaX}px ${deltaY}px`;\n } else {\n element.style[property] = prevValue;\n }\n return [property, value];\n });\n\n // Cancel any new animations triggered by these properties.\n for (let a of element.getAnimations()) {\n if (!animations.includes(a)) {\n a.cancel();\n }\n }\n\n // Remove overrides after one frame to animate to the current values.\n frame = requestAnimationFrame(() => {\n frame = null;\n for (let [property, value] of values) {\n element.style[property] = value;\n }\n });\n\n delete scope[name];\n } else if (element && isVisible && !prevSnapshot) {\n // No previous instance exists, apply the entering state.\n queueMicrotask(() => flushSync(() => setState('entering')));\n frame = requestAnimationFrame(() => {\n frame = null;\n setState('visible');\n });\n } else if (element && !isVisible) {\n // Wait until layout effects finish, and check if a snapshot still exists.\n // If so, no new SharedElement consumed it, so enter the exiting state.\n queueMicrotask(() => {\n if (scope[name]) {\n delete scope[name];\n flushSync(() => setState('exiting'));\n Promise.all(element.getAnimations().map(a => a.finished))\n .then(() => setState('hidden'))\n .catch(() => {});\n } else {\n // Snapshot was consumed by another instance, unmount.\n setState('hidden');\n }\n });\n }\n\n return () => {\n if (frame != null) {\n cancelAnimationFrame(frame);\n }\n\n if (element && element.isConnected && !element.hasAttribute('data-exiting')) {\n // On unmount, store a snapshot of the rectangle and computed style for transitioning properties.\n let style = window.getComputedStyle(element);\n if (style.transitionProperty !== 'none') {\n let transitionProperty = style.transitionProperty.split(/\\s*,\\s*/);\n scope[name] = {\n rect: element.getBoundingClientRect(),\n style: transitionProperty.map(p => [p, style[p]])\n };\n }\n }\n };\n }, [ref, scopeRef, name, isVisible]);\n\n let renderProps = useRenderProps({\n children,\n className,\n style,\n values: {\n isEntering: state === 'entering',\n isExiting: state === 'exiting'\n }\n });\n\n if (state === 'hidden') {\n return null;\n }\n\n return (\n <div\n {...divProps}\n {...renderProps}\n ref={ref}\n data-entering={state === 'entering' || undefined}\n data-exiting={state === 'exiting' || undefined} />\n );\n});\n"],"names":[],"version":3,"file":"SharedElementTransition.module.js.map"}
|
package/dist/Table.main.js
CHANGED
|
@@ -3,8 +3,9 @@ var $525402dfec7da5bc$exports = require("./RSPContexts.main.js");
|
|
|
3
3
|
var $3114c2382242bdc0$exports = require("./Collection.main.js");
|
|
4
4
|
var $c5ccf687772c0422$exports = require("./utils.main.js");
|
|
5
5
|
var $0c2289d253cb4544$exports = require("./DragAndDrop.main.js");
|
|
6
|
-
var $09cb5ee89bb327e1$exports = require("./context.main.js");
|
|
7
6
|
var $d72d752ea1c67b9a$exports = require("./intlStrings.main.js");
|
|
7
|
+
var $54e872c96e6d295b$exports = require("./SelectionIndicator.main.js");
|
|
8
|
+
var $2d10bc562fea46b3$exports = require("./SharedElementTransition.main.js");
|
|
8
9
|
var $5VUTk$reactariacollections = require("@react-aria/collections");
|
|
9
10
|
var $5VUTk$reactstatelytable = require("@react-stately/table");
|
|
10
11
|
var $5VUTk$reactstately = require("react-stately");
|
|
@@ -49,6 +50,7 @@ $parcel$export(module.exports, "TableLoadMoreItem", () => $37b9a5d4bd0d4ded$expo
|
|
|
49
50
|
|
|
50
51
|
|
|
51
52
|
|
|
53
|
+
|
|
52
54
|
class $37b9a5d4bd0d4ded$var$TableCollection extends (0, $5VUTk$reactariacollections.BaseCollection) {
|
|
53
55
|
addNode(node) {
|
|
54
56
|
super.addNode(node);
|
|
@@ -252,18 +254,16 @@ const $37b9a5d4bd0d4ded$export$54ec01a60f47d33d = /*#__PURE__*/ (0, $5VUTk$react
|
|
|
252
254
|
}));
|
|
253
255
|
});
|
|
254
256
|
function $37b9a5d4bd0d4ded$var$TableInner({ props: props, forwardedRef: ref, selectionState: selectionState, collection: collection }) {
|
|
255
|
-
|
|
256
|
-
[contextProps] = (0, $c5ccf687772c0422$exports.useContextProps)({}, null, (0, $09cb5ee89bb327e1$exports.SelectableCollectionContext));
|
|
257
|
-
let { filter: filter, ...collectionProps } = contextProps;
|
|
257
|
+
[props, ref] = (0, $c5ccf687772c0422$exports.useContextProps)(props, ref, (0, $525402dfec7da5bc$exports.SelectableCollectionContext));
|
|
258
258
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
259
|
-
let { shouldUseVirtualFocus: shouldUseVirtualFocus, disallowTypeAhead: disallowTypeAhead, ...DOMCollectionProps } =
|
|
259
|
+
let { shouldUseVirtualFocus: shouldUseVirtualFocus, disallowTypeAhead: disallowTypeAhead, filter: filter, ...DOMCollectionProps } = props;
|
|
260
260
|
let tableContainerContext = (0, $5VUTk$react.useContext)($37b9a5d4bd0d4ded$var$ResizableTableContainerContext);
|
|
261
261
|
ref = (0, $5VUTk$reactariautils.useObjectRef)((0, $5VUTk$react.useMemo)(()=>(0, $5VUTk$reactariautils.mergeRefs)(ref, tableContainerContext === null || tableContainerContext === void 0 ? void 0 : tableContainerContext.tableRef), [
|
|
262
262
|
ref,
|
|
263
263
|
tableContainerContext === null || tableContainerContext === void 0 ? void 0 : tableContainerContext.tableRef
|
|
264
264
|
]));
|
|
265
265
|
let tableState = (0, $5VUTk$reactstately.useTableState)({
|
|
266
|
-
...
|
|
266
|
+
...DOMCollectionProps,
|
|
267
267
|
collection: collection,
|
|
268
268
|
children: undefined,
|
|
269
269
|
UNSAFE_selectionState: selectionState
|
|
@@ -272,7 +272,6 @@ function $37b9a5d4bd0d4ded$var$TableInner({ props: props, forwardedRef: ref, sel
|
|
|
272
272
|
let { isVirtualized: isVirtualized, layoutDelegate: layoutDelegate, dropTargetDelegate: ctxDropTargetDelegate, CollectionRoot: CollectionRoot } = (0, $5VUTk$react.useContext)((0, $3114c2382242bdc0$exports.CollectionRendererContext));
|
|
273
273
|
let { dragAndDropHooks: dragAndDropHooks } = props;
|
|
274
274
|
let { gridProps: gridProps } = (0, $5VUTk$reactaria.useTable)({
|
|
275
|
-
...props,
|
|
276
275
|
...DOMCollectionProps,
|
|
277
276
|
layoutDelegate: layoutDelegate,
|
|
278
277
|
isVirtualized: isVirtualized
|
|
@@ -384,11 +383,11 @@ function $37b9a5d4bd0d4ded$var$TableInner({ props: props, forwardedRef: ref, sel
|
|
|
384
383
|
}
|
|
385
384
|
],
|
|
386
385
|
[
|
|
387
|
-
(0, $
|
|
386
|
+
(0, $525402dfec7da5bc$exports.SelectableCollectionContext),
|
|
388
387
|
null
|
|
389
388
|
],
|
|
390
389
|
[
|
|
391
|
-
(0, $
|
|
390
|
+
(0, $525402dfec7da5bc$exports.FieldInputContext),
|
|
392
391
|
null
|
|
393
392
|
]
|
|
394
393
|
]
|
|
@@ -402,11 +401,11 @@ function $37b9a5d4bd0d4ded$var$TableInner({ props: props, forwardedRef: ref, sel
|
|
|
402
401
|
"data-drop-target": isRootDropTarget || undefined,
|
|
403
402
|
"data-focused": isFocused || undefined,
|
|
404
403
|
"data-focus-visible": isFocusVisible || undefined
|
|
405
|
-
}, /*#__PURE__*/ (0, ($parcel$interopDefault($5VUTk$react))).createElement(CollectionRoot, {
|
|
404
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($5VUTk$react))).createElement((0, $2d10bc562fea46b3$exports.SharedElementTransition), null, /*#__PURE__*/ (0, ($parcel$interopDefault($5VUTk$react))).createElement(CollectionRoot, {
|
|
406
405
|
collection: filteredState.collection,
|
|
407
406
|
scrollRef: (_tableContainerContext_scrollRef = tableContainerContext === null || tableContainerContext === void 0 ? void 0 : tableContainerContext.scrollRef) !== null && _tableContainerContext_scrollRef !== void 0 ? _tableContainerContext_scrollRef : ref,
|
|
408
407
|
persistedKeys: (0, $0c2289d253cb4544$exports.useDndPersistedKeys)(selectionManager, dragAndDropHooks, dropState)
|
|
409
|
-
}))), dragPreview);
|
|
408
|
+
})))), dragPreview);
|
|
410
409
|
}
|
|
411
410
|
function $37b9a5d4bd0d4ded$var$useElementType(element) {
|
|
412
411
|
let { isVirtualized: isVirtualized } = (0, $5VUTk$react.useContext)((0, $3114c2382242bdc0$exports.CollectionRendererContext));
|
|
@@ -859,6 +858,12 @@ const $37b9a5d4bd0d4ded$export$b59bdbef9ce70de2 = /*#__PURE__*/ (0, $5VUTk$react
|
|
|
859
858
|
}
|
|
860
859
|
}
|
|
861
860
|
}
|
|
861
|
+
],
|
|
862
|
+
[
|
|
863
|
+
(0, $54e872c96e6d295b$exports.SelectionIndicatorContext),
|
|
864
|
+
{
|
|
865
|
+
isSelected: states.isSelected
|
|
866
|
+
}
|
|
862
867
|
]
|
|
863
868
|
]
|
|
864
869
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($5VUTk$react))).createElement(CollectionBranch, {
|