react-aria-components 3.0.0-nightly-9421c1409-240923 → 3.0.0-nightly-5ae234603-240925
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/Disclosure.main.js +60 -13
- package/dist/Disclosure.main.js.map +1 -1
- package/dist/Disclosure.mjs +61 -16
- package/dist/Disclosure.module.js +61 -16
- package/dist/Disclosure.module.js.map +1 -1
- package/dist/Tree.main.js +6 -2
- package/dist/Tree.main.js.map +1 -1
- package/dist/Tree.mjs +6 -2
- package/dist/Tree.module.js +6 -2
- package/dist/Tree.module.js.map +1 -1
- package/dist/import.mjs +2 -2
- package/dist/main.js +7 -5
- package/dist/main.js.map +1 -1
- package/dist/module.js +2 -2
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +157 -134
- package/dist/types.d.ts.map +1 -1
- package/package.json +30 -30
- package/src/Disclosure.tsx +98 -19
- package/src/Tree.tsx +9 -3
- package/src/index.ts +2 -2
package/dist/Disclosure.main.js
CHANGED
|
@@ -2,9 +2,9 @@ var $b856e6788a7ea5bf$exports = require("./Button.main.js");
|
|
|
2
2
|
var $c5ccf687772c0422$exports = require("./utils.main.js");
|
|
3
3
|
var $8afVX$reactariadisclosure = require("@react-aria/disclosure");
|
|
4
4
|
var $8afVX$reactstatelydisclosure = require("@react-stately/disclosure");
|
|
5
|
-
var $8afVX$reactaria = require("react-aria");
|
|
6
5
|
var $8afVX$reactariautils = require("@react-aria/utils");
|
|
7
6
|
var $8afVX$react = require("react");
|
|
7
|
+
var $8afVX$reactaria = require("react-aria");
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
function $parcel$interopDefault(a) {
|
|
@@ -15,6 +15,8 @@ function $parcel$export(e, n, v, s) {
|
|
|
15
15
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
$parcel$export(module.exports, "DisclosureGroupStateContext", () => $11c780105231f6ef$export$1d40e3e0cc4d5de);
|
|
19
|
+
$parcel$export(module.exports, "DisclosureGroup", () => $11c780105231f6ef$export$944aceb4f8c89f10);
|
|
18
20
|
$parcel$export(module.exports, "DisclosureContext", () => $11c780105231f6ef$export$d665dd135a51b28a);
|
|
19
21
|
$parcel$export(module.exports, "DisclosureStateContext", () => $11c780105231f6ef$export$dab3ea4a6ef094da);
|
|
20
22
|
$parcel$export(module.exports, "Disclosure", () => $11c780105231f6ef$export$74a362b31437ec83);
|
|
@@ -36,27 +38,72 @@ $parcel$export(module.exports, "DisclosurePanel", () => $11c780105231f6ef$export
|
|
|
36
38
|
|
|
37
39
|
|
|
38
40
|
|
|
41
|
+
const $11c780105231f6ef$export$1d40e3e0cc4d5de = /*#__PURE__*/ (0, $8afVX$react.createContext)(null);
|
|
42
|
+
function $11c780105231f6ef$var$DisclosureGroup(props, ref) {
|
|
43
|
+
let state = (0, $8afVX$reactstatelydisclosure.useDisclosureGroupState)(props);
|
|
44
|
+
let renderProps = (0, $c5ccf687772c0422$exports.useRenderProps)({
|
|
45
|
+
...props,
|
|
46
|
+
defaultClassName: 'react-aria-DisclosureGroup',
|
|
47
|
+
values: {
|
|
48
|
+
isDisabled: state.isDisabled,
|
|
49
|
+
state: state
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
let domProps = (0, $8afVX$reactariautils.filterDOMProps)(props);
|
|
53
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($8afVX$react))).createElement("div", {
|
|
54
|
+
...domProps,
|
|
55
|
+
...renderProps,
|
|
56
|
+
ref: ref,
|
|
57
|
+
"data-disabled": props.isDisabled || undefined
|
|
58
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($8afVX$react))).createElement($11c780105231f6ef$export$1d40e3e0cc4d5de.Provider, {
|
|
59
|
+
value: state
|
|
60
|
+
}, renderProps.children));
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A DisclosureGroup is a grouping of related disclosures, sometimes called an Accordion.
|
|
64
|
+
* It supports both single and multiple expanded items.
|
|
65
|
+
*/ const $11c780105231f6ef$export$944aceb4f8c89f10 = /*#__PURE__*/ (0, $8afVX$react.forwardRef)($11c780105231f6ef$var$DisclosureGroup);
|
|
39
66
|
const $11c780105231f6ef$export$d665dd135a51b28a = /*#__PURE__*/ (0, $8afVX$react.createContext)(null);
|
|
40
67
|
const $11c780105231f6ef$export$dab3ea4a6ef094da = /*#__PURE__*/ (0, $8afVX$react.createContext)(null);
|
|
41
68
|
const $11c780105231f6ef$var$InternalDisclosureContext = /*#__PURE__*/ (0, $8afVX$react.createContext)(null);
|
|
42
69
|
function $11c780105231f6ef$var$Disclosure(props, ref) {
|
|
43
70
|
[props, ref] = (0, $c5ccf687772c0422$exports.useContextProps)(props, ref, $11c780105231f6ef$export$d665dd135a51b28a);
|
|
44
|
-
let
|
|
45
|
-
let
|
|
46
|
-
|
|
71
|
+
let groupState = (0, $8afVX$react.useContext)($11c780105231f6ef$export$1d40e3e0cc4d5de);
|
|
72
|
+
let { id: id, ...otherProps } = props;
|
|
73
|
+
// Generate an id if one wasn't provided.
|
|
74
|
+
// (can't pass id into useId since it can also be a number)
|
|
75
|
+
let defaultId = (0, $8afVX$reactariautils.useId)();
|
|
76
|
+
id || (id = defaultId);
|
|
77
|
+
let state = (0, $8afVX$reactstatelydisclosure.useDisclosureState)({
|
|
78
|
+
...props,
|
|
79
|
+
isExpanded: groupState ? groupState.expandedKeys.has(id) : props.isExpanded,
|
|
80
|
+
onExpandedChange (isExpanded) {
|
|
81
|
+
var _props_onExpandedChange;
|
|
82
|
+
if (groupState) groupState.toggleKey(id);
|
|
83
|
+
(_props_onExpandedChange = props.onExpandedChange) === null || _props_onExpandedChange === void 0 ? void 0 : _props_onExpandedChange.call(props, isExpanded);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
let panelRef = (0, ($parcel$interopDefault($8afVX$react))).useRef(null);
|
|
87
|
+
let isDisabled = props.isDisabled || (groupState === null || groupState === void 0 ? void 0 : groupState.isDisabled) || false;
|
|
88
|
+
let { buttonProps: buttonProps, panelProps: panelProps } = (0, $8afVX$reactariadisclosure.useDisclosure)({
|
|
89
|
+
...props,
|
|
90
|
+
isDisabled: isDisabled
|
|
91
|
+
}, state, panelRef);
|
|
47
92
|
let { isFocusVisible: isFocusVisibleWithin, focusProps: focusWithinProps } = (0, $8afVX$reactaria.useFocusRing)({
|
|
48
93
|
within: true
|
|
49
94
|
});
|
|
50
95
|
let renderProps = (0, $c5ccf687772c0422$exports.useRenderProps)({
|
|
51
96
|
...props,
|
|
97
|
+
id: undefined,
|
|
52
98
|
defaultClassName: 'react-aria-Disclosure',
|
|
53
99
|
values: {
|
|
54
100
|
isExpanded: state.isExpanded,
|
|
55
|
-
isDisabled:
|
|
101
|
+
isDisabled: isDisabled,
|
|
56
102
|
isFocusVisibleWithin: isFocusVisibleWithin,
|
|
57
103
|
state: state
|
|
58
104
|
}
|
|
59
105
|
});
|
|
106
|
+
let domProps = (0, $8afVX$reactariautils.filterDOMProps)(otherProps);
|
|
60
107
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($8afVX$react))).createElement((0, $c5ccf687772c0422$exports.Provider), {
|
|
61
108
|
values: [
|
|
62
109
|
[
|
|
@@ -71,8 +118,8 @@ function $11c780105231f6ef$var$Disclosure(props, ref) {
|
|
|
71
118
|
[
|
|
72
119
|
$11c780105231f6ef$var$InternalDisclosureContext,
|
|
73
120
|
{
|
|
74
|
-
|
|
75
|
-
|
|
121
|
+
panelProps: panelProps,
|
|
122
|
+
panelRef: panelRef
|
|
76
123
|
}
|
|
77
124
|
],
|
|
78
125
|
[
|
|
@@ -83,15 +130,16 @@ function $11c780105231f6ef$var$Disclosure(props, ref) {
|
|
|
83
130
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($8afVX$react))).createElement("div", {
|
|
84
131
|
ref: ref,
|
|
85
132
|
"data-expanded": state.isExpanded || undefined,
|
|
86
|
-
"data-disabled":
|
|
133
|
+
"data-disabled": isDisabled || undefined,
|
|
87
134
|
"data-focus-visible-within": isFocusVisibleWithin || undefined,
|
|
135
|
+
...domProps,
|
|
88
136
|
...focusWithinProps,
|
|
89
137
|
...renderProps
|
|
90
138
|
}, renderProps.children));
|
|
91
139
|
}
|
|
92
140
|
function $11c780105231f6ef$var$DisclosurePanel(props, ref) {
|
|
93
141
|
let { role: role = 'group' } = props;
|
|
94
|
-
let {
|
|
142
|
+
let { panelProps: panelProps, panelRef: panelRef } = (0, $8afVX$react.useContext)($11c780105231f6ef$var$InternalDisclosureContext);
|
|
95
143
|
let { isFocusVisible: isFocusVisibleWithin, focusProps: focusWithinProps } = (0, $8afVX$reactaria.useFocusRing)({
|
|
96
144
|
within: true
|
|
97
145
|
});
|
|
@@ -103,11 +151,10 @@ function $11c780105231f6ef$var$DisclosurePanel(props, ref) {
|
|
|
103
151
|
}
|
|
104
152
|
});
|
|
105
153
|
return /*#__PURE__*/ (0, ($parcel$interopDefault($8afVX$react))).createElement("div", {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
ref: (0, $8afVX$reactariautils.mergeRefs)(ref, contentRef),
|
|
109
|
-
...(0, $8afVX$reactariautils.mergeProps)(contentProps, focusWithinProps),
|
|
154
|
+
ref: (0, $8afVX$reactariautils.mergeRefs)(ref, panelRef),
|
|
155
|
+
...(0, $8afVX$reactariautils.mergeProps)(panelProps, focusWithinProps),
|
|
110
156
|
...renderProps,
|
|
157
|
+
role: role,
|
|
111
158
|
"data-focus-visible-within": isFocusVisibleWithin || undefined
|
|
112
159
|
}, /*#__PURE__*/ (0, ($parcel$interopDefault($8afVX$react))).createElement((0, $c5ccf687772c0422$exports.Provider), {
|
|
113
160
|
values: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAmCM,MAAM,0DAAoB,CAAA,GAAA,0BAAY,EAAiD;AACvF,MAAM,0DAAyB,CAAA,GAAA,0BAAY,EAA0B;AA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,gBAAgB,oBAAoB,EACpC,YAAY,gBAAgB,EAC7B,GAAG,CAAA,GAAA,6BAAW,EAAE;QAAC,QAAQ;IAAI;IAC9B,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;kCACN;QACF;IACF;IACA,qBACE,0DAAC;QACC,MAAM;QACN,aAAa;QACb,KAAK,CAAA,GAAA,+BAAQ,EAAE,KAAK;QACnB,GAAG,CAAA,GAAA,gCAAS,EAAE,cAAc,iBAAiB;QAC7C,GAAG,WAAW;QACf,6BAA2B,wBAAwB;qBACnD,0DAAC,CAAA,GAAA,kCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,uCAAY;gBAAG;aAAK;SACtB;OACA,MAAM,QAAQ;AAIvB;AAEA;;CAEC,GACD,MAAM,4CAA4B,AAAd,WAAW,GAAI,CAAA,GAAA,uBAAS,EAAqB;AAGjE,MAAM,4CAAiC,AAAd,WAAW,GAAI,CAAA,GAAA,uBAAS,EAAqB","sources":["packages/react-aria-components/src/Disclosure.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaDisclosureProps, useDisclosure} from '@react-aria/disclosure';\nimport {ButtonContext} from './Button';\nimport {ContextValue, DEFAULT_SLOT, Provider, RenderProps, SlotProps, useContextProps, useRenderProps} from './utils';\nimport {DisclosureState, useDisclosureState} from '@react-stately/disclosure';\nimport {forwardRefType} from '@react-types/shared';\nimport {HoverEvents, useFocusRing} from 'react-aria';\nimport {mergeProps, mergeRefs} from '@react-aria/utils';\nimport React, {createContext, DOMAttributes, ForwardedRef, forwardRef, ReactNode, useContext} from 'react';\n\nexport interface DisclosureProps extends Omit<AriaDisclosureProps, 'children'>, HoverEvents, RenderProps<DisclosureRenderProps>, SlotProps {}\n\nexport interface DisclosureRenderProps {\n /**\n * Whether the disclosure is expanded.\n * @selector [data-expanded]\n */\n isExpanded: boolean,\n /**\n * Whether the disclosure has keyboard focus.\n * @selector [data-focus-visible-within]\n */\n isFocusVisibleWithin: boolean,\n /**\n * Whether the disclosure is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * State of the disclosure.\n */\n state: DisclosureState\n}\n\nexport const DisclosureContext = createContext<ContextValue<DisclosureProps, HTMLDivElement>>(null);\nexport const DisclosureStateContext = createContext<DisclosureState | null>(null);\n\ninterface InternalDisclosureContextValue {\n contentProps: DOMAttributes<HTMLElement>,\n contentRef: React.RefObject<HTMLElement | null>\n}\n\nconst InternalDisclosureContext = createContext<InternalDisclosureContextValue | null>(null);\n\nfunction Disclosure(props: DisclosureProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, DisclosureContext);\n let state = useDisclosureState(props);\n let contentRef = React.useRef<HTMLElement | null>(null);\n let {buttonProps, contentProps} = useDisclosure(props, state, contentRef);\n let {\n isFocusVisible: isFocusVisibleWithin,\n focusProps: focusWithinProps\n } = useFocusRing({within: true});\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-Disclosure',\n values: {\n isExpanded: state.isExpanded,\n isDisabled: props.isDisabled || false,\n isFocusVisibleWithin,\n state\n }\n });\n\n return (\n <Provider\n values={[\n [ButtonContext, {\n slots: {\n [DEFAULT_SLOT]: {},\n trigger: buttonProps\n }\n }],\n [InternalDisclosureContext, {contentProps, contentRef}],\n [DisclosureStateContext, state]\n ]}>\n <div\n ref={ref}\n data-expanded={state.isExpanded || undefined}\n data-disabled={props.isDisabled || undefined}\n data-focus-visible-within={isFocusVisibleWithin || undefined}\n {...focusWithinProps}\n {...renderProps}>\n {renderProps.children}\n </div>\n </Provider>\n );\n}\n\nexport interface DisclosurePanelProps extends RenderProps<{}> {\n /**\n * The accessibility role for the disclosure's panel.\n * @default 'group'\n */\n role?: 'group' | 'region',\n children: ReactNode\n}\n\nfunction DisclosurePanel(props: DisclosurePanelProps, ref: ForwardedRef<HTMLElement>) {\n let {role = 'group'} = props;\n let {contentProps, contentRef} = useContext(InternalDisclosureContext)!;\n let {\n isFocusVisible: isFocusVisibleWithin,\n focusProps: focusWithinProps\n } = useFocusRing({within: true});\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-DisclosurePanel',\n values: {\n isFocusVisibleWithin\n }\n });\n return (\n <div\n role={role}\n // @ts-ignore\n ref={mergeRefs(ref, contentRef)}\n {...mergeProps(contentProps, focusWithinProps)}\n {...renderProps}\n data-focus-visible-within={isFocusVisibleWithin || undefined}>\n <Provider\n values={[\n [ButtonContext, null]\n ]}>\n {props.children}\n </Provider>\n </div>\n );\n}\n\n/**\n * A disclosure is a collapsible section of content. It is composed of a a header with a heading and trigger button, and a panel that contains the content.\n */\nconst _Disclosure = /*#__PURE__*/ (forwardRef as forwardRefType)(Disclosure);\nexport {_Disclosure as Disclosure};\n\nconst _DisclosurePanel = /*#__PURE__*/ (forwardRef as forwardRefType)(DisclosurePanel);\nexport {_DisclosurePanel as DisclosurePanel};\n"],"names":[],"version":3,"file":"Disclosure.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAyBM,MAAM,yDAA8B,CAAA,GAAA,0BAAY,EAA+B;AAEtF,SAAS,sCAAgB,KAA2B,EAAE,GAAiC;IACrF,IAAI,QAAQ,CAAA,GAAA,qDAAsB,EAAE;IAEpC,IAAI,cAAc,CAAA,GAAA,wCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;YACN,YAAY,MAAM,UAAU;mBAC5B;QACF;IAC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AAW;QACf,MAAM;QACN,6BAA2B,wBAAwB;qBACnD,0DAAC,CAAA,GAAA,kCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,uCAAY;gBAAG;aAAK;SACtB;OACA,MAAM,QAAQ;AAIvB;AAEA;;CAEC,GACD,MAAM,4CAA4B,AAAd,WAAW,GAAI,CAAA,GAAA,uBAAS,EAAqB;AAGjE,MAAM,4CAAiC,AAAd,WAAW,GAAI,CAAA,GAAA,uBAAS,EAAqB","sources":["packages/react-aria-components/src/Disclosure.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaDisclosureProps, useDisclosure} from '@react-aria/disclosure';\nimport {ButtonContext} from './Button';\nimport {ContextValue, DEFAULT_SLOT, Provider, RenderProps, SlotProps, useContextProps, useRenderProps} from './utils';\nimport {DisclosureGroupState, DisclosureState, DisclosureGroupProps as StatelyDisclosureGroupProps, useDisclosureGroupState, useDisclosureState} from '@react-stately/disclosure';\nimport {DOMProps, forwardRefType, Key} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, mergeRefs, useId} from '@react-aria/utils';\nimport React, {createContext, DOMAttributes, ForwardedRef, forwardRef, ReactNode, useContext} from 'react';\nimport {useFocusRing} from 'react-aria';\n\nexport interface DisclosureGroupProps extends StatelyDisclosureGroupProps, RenderProps<DisclosureGroupRenderProps>, DOMProps {}\n\nexport interface DisclosureGroupRenderProps {\n /**\n * Whether the disclosure group is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * State of the disclosure group.\n */\n state: DisclosureGroupState\n}\n\nexport const DisclosureGroupStateContext = createContext<DisclosureGroupState | null>(null);\n\nfunction DisclosureGroup(props: DisclosureGroupProps, ref: ForwardedRef<HTMLDivElement>) {\n let state = useDisclosureGroupState(props);\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-DisclosureGroup',\n values: {\n isDisabled: state.isDisabled,\n state\n }\n });\n\n let domProps = filterDOMProps(props);\n\n return (\n <div\n {...domProps}\n {...renderProps}\n ref={ref}\n data-disabled={props.isDisabled || undefined}>\n <DisclosureGroupStateContext.Provider value={state}>\n {renderProps.children}\n </DisclosureGroupStateContext.Provider>\n </div>\n );\n}\n\n/**\n * A DisclosureGroup is a grouping of related disclosures, sometimes called an Accordion.\n * It supports both single and multiple expanded items.\n */\nconst _DisclosureGroup = forwardRef(DisclosureGroup);\nexport {_DisclosureGroup as DisclosureGroup};\n\nexport interface DisclosureProps extends Omit<AriaDisclosureProps, 'children'>, RenderProps<DisclosureRenderProps>, SlotProps {\n /** An id for the disclosure when used within a DisclosureGroup, matching the id used in `expandedKeys`. */\n id?: Key\n}\n\nexport interface DisclosureRenderProps {\n /**\n * Whether the disclosure is expanded.\n * @selector [data-expanded]\n */\n isExpanded: boolean,\n /**\n * Whether the disclosure has keyboard focus.\n * @selector [data-focus-visible-within]\n */\n isFocusVisibleWithin: boolean,\n /**\n * Whether the disclosure is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * State of the disclosure.\n */\n state: DisclosureState\n}\n\nexport const DisclosureContext = createContext<ContextValue<DisclosureProps, HTMLDivElement>>(null);\nexport const DisclosureStateContext = createContext<DisclosureState | null>(null);\n\ninterface InternalDisclosureContextValue {\n panelProps: DOMAttributes<HTMLElement>,\n panelRef: React.RefObject<HTMLDivElement | null>\n}\n\nconst InternalDisclosureContext = createContext<InternalDisclosureContextValue | null>(null);\n\nfunction Disclosure(props: DisclosureProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, DisclosureContext);\n let groupState = useContext(DisclosureGroupStateContext);\n let {id, ...otherProps} = props;\n\n // Generate an id if one wasn't provided.\n // (can't pass id into useId since it can also be a number)\n let defaultId = useId();\n id ||= defaultId;\n\n let state = useDisclosureState({\n ...props,\n isExpanded: groupState ? groupState.expandedKeys.has(id) : props.isExpanded,\n onExpandedChange(isExpanded) {\n if (groupState) {\n groupState.toggleKey(id);\n }\n\n props.onExpandedChange?.(isExpanded);\n }\n });\n\n let panelRef = React.useRef<HTMLDivElement | null>(null);\n let isDisabled = props.isDisabled || groupState?.isDisabled || false;\n let {buttonProps, panelProps} = useDisclosure({\n ...props,\n isDisabled\n }, state, panelRef);\n let {\n isFocusVisible: isFocusVisibleWithin,\n focusProps: focusWithinProps\n } = useFocusRing({within: true});\n\n let renderProps = useRenderProps({\n ...props,\n id: undefined,\n defaultClassName: 'react-aria-Disclosure',\n values: {\n isExpanded: state.isExpanded,\n isDisabled,\n isFocusVisibleWithin,\n state\n }\n });\n\n let domProps = filterDOMProps(otherProps as any);\n\n return (\n <Provider\n values={[\n [ButtonContext, {\n slots: {\n [DEFAULT_SLOT]: {},\n trigger: buttonProps\n }\n }],\n [InternalDisclosureContext, {panelProps, panelRef}],\n [DisclosureStateContext, state]\n ]}>\n <div\n ref={ref}\n data-expanded={state.isExpanded || undefined}\n data-disabled={isDisabled || undefined}\n data-focus-visible-within={isFocusVisibleWithin || undefined}\n {...domProps}\n {...focusWithinProps}\n {...renderProps}>\n {renderProps.children}\n </div>\n </Provider>\n );\n}\n\nexport interface DisclosurePanelProps extends RenderProps<{}> {\n /**\n * The accessibility role for the disclosure's panel.\n * @default 'group'\n */\n role?: 'group' | 'region',\n children: ReactNode\n}\n\nfunction DisclosurePanel(props: DisclosurePanelProps, ref: ForwardedRef<HTMLDivElement>) {\n let {role = 'group'} = props;\n let {panelProps, panelRef} = useContext(InternalDisclosureContext)!;\n let {\n isFocusVisible: isFocusVisibleWithin,\n focusProps: focusWithinProps\n } = useFocusRing({within: true});\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-DisclosurePanel',\n values: {\n isFocusVisibleWithin\n }\n });\n return (\n <div\n ref={mergeRefs(ref, panelRef)}\n {...mergeProps(panelProps, focusWithinProps)}\n {...renderProps}\n role={role}\n data-focus-visible-within={isFocusVisibleWithin || undefined}>\n <Provider\n values={[\n [ButtonContext, null]\n ]}>\n {props.children}\n </Provider>\n </div>\n );\n}\n\n/**\n * A disclosure is a collapsible section of content. It is composed of a a header with a heading and trigger button, and a panel that contains the content.\n */\nconst _Disclosure = /*#__PURE__*/ (forwardRef as forwardRefType)(Disclosure);\nexport {_Disclosure as Disclosure};\n\nconst _DisclosurePanel = /*#__PURE__*/ (forwardRef as forwardRefType)(DisclosurePanel);\nexport {_DisclosurePanel as DisclosurePanel};\n"],"names":[],"version":3,"file":"Disclosure.main.js.map"}
|
package/dist/Disclosure.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {ButtonContext as $d2b4bc8c273e7be6$export$24d547caef80ccd1} from "./Button.mjs";
|
|
2
2
|
import {DEFAULT_SLOT as $64fa3d84918910a7$export$c62b8e45d58ddad9, Provider as $64fa3d84918910a7$export$2881499e37b75b9a, useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415, useRenderProps as $64fa3d84918910a7$export$4d86445c2cf5e3} from "./utils.mjs";
|
|
3
3
|
import {useDisclosure as $hI1OT$useDisclosure} from "@react-aria/disclosure";
|
|
4
|
-
import {useDisclosureState as $hI1OT$useDisclosureState} from "@react-stately/disclosure";
|
|
4
|
+
import {useDisclosureGroupState as $hI1OT$useDisclosureGroupState, useDisclosureState as $hI1OT$useDisclosureState} from "@react-stately/disclosure";
|
|
5
|
+
import {filterDOMProps as $hI1OT$filterDOMProps, useId as $hI1OT$useId, mergeRefs as $hI1OT$mergeRefs, mergeProps as $hI1OT$mergeProps} from "@react-aria/utils";
|
|
6
|
+
import $hI1OT$react, {createContext as $hI1OT$createContext, forwardRef as $hI1OT$forwardRef, useContext as $hI1OT$useContext} from "react";
|
|
5
7
|
import {useFocusRing as $hI1OT$useFocusRing} from "react-aria";
|
|
6
|
-
import {mergeRefs as $hI1OT$mergeRefs, mergeProps as $hI1OT$mergeProps} from "@react-aria/utils";
|
|
7
|
-
import $hI1OT$react, {createContext as $hI1OT$createContext, useContext as $hI1OT$useContext, forwardRef as $hI1OT$forwardRef} from "react";
|
|
8
8
|
|
|
9
9
|
/*
|
|
10
10
|
* Copyright 2024 Adobe. All rights reserved.
|
|
@@ -23,27 +23,72 @@ import $hI1OT$react, {createContext as $hI1OT$createContext, useContext as $hI1O
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
const $28f4fd908f0de97f$export$1d40e3e0cc4d5de = /*#__PURE__*/ (0, $hI1OT$createContext)(null);
|
|
27
|
+
function $28f4fd908f0de97f$var$DisclosureGroup(props, ref) {
|
|
28
|
+
let state = (0, $hI1OT$useDisclosureGroupState)(props);
|
|
29
|
+
let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
|
|
30
|
+
...props,
|
|
31
|
+
defaultClassName: 'react-aria-DisclosureGroup',
|
|
32
|
+
values: {
|
|
33
|
+
isDisabled: state.isDisabled,
|
|
34
|
+
state: state
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
let domProps = (0, $hI1OT$filterDOMProps)(props);
|
|
38
|
+
return /*#__PURE__*/ (0, $hI1OT$react).createElement("div", {
|
|
39
|
+
...domProps,
|
|
40
|
+
...renderProps,
|
|
41
|
+
ref: ref,
|
|
42
|
+
"data-disabled": props.isDisabled || undefined
|
|
43
|
+
}, /*#__PURE__*/ (0, $hI1OT$react).createElement($28f4fd908f0de97f$export$1d40e3e0cc4d5de.Provider, {
|
|
44
|
+
value: state
|
|
45
|
+
}, renderProps.children));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A DisclosureGroup is a grouping of related disclosures, sometimes called an Accordion.
|
|
49
|
+
* It supports both single and multiple expanded items.
|
|
50
|
+
*/ const $28f4fd908f0de97f$export$944aceb4f8c89f10 = /*#__PURE__*/ (0, $hI1OT$forwardRef)($28f4fd908f0de97f$var$DisclosureGroup);
|
|
26
51
|
const $28f4fd908f0de97f$export$d665dd135a51b28a = /*#__PURE__*/ (0, $hI1OT$createContext)(null);
|
|
27
52
|
const $28f4fd908f0de97f$export$dab3ea4a6ef094da = /*#__PURE__*/ (0, $hI1OT$createContext)(null);
|
|
28
53
|
const $28f4fd908f0de97f$var$InternalDisclosureContext = /*#__PURE__*/ (0, $hI1OT$createContext)(null);
|
|
29
54
|
function $28f4fd908f0de97f$var$Disclosure(props, ref) {
|
|
30
55
|
[props, ref] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, ref, $28f4fd908f0de97f$export$d665dd135a51b28a);
|
|
31
|
-
let
|
|
32
|
-
let
|
|
33
|
-
|
|
56
|
+
let groupState = (0, $hI1OT$useContext)($28f4fd908f0de97f$export$1d40e3e0cc4d5de);
|
|
57
|
+
let { id: id, ...otherProps } = props;
|
|
58
|
+
// Generate an id if one wasn't provided.
|
|
59
|
+
// (can't pass id into useId since it can also be a number)
|
|
60
|
+
let defaultId = (0, $hI1OT$useId)();
|
|
61
|
+
id || (id = defaultId);
|
|
62
|
+
let state = (0, $hI1OT$useDisclosureState)({
|
|
63
|
+
...props,
|
|
64
|
+
isExpanded: groupState ? groupState.expandedKeys.has(id) : props.isExpanded,
|
|
65
|
+
onExpandedChange (isExpanded) {
|
|
66
|
+
var _props_onExpandedChange;
|
|
67
|
+
if (groupState) groupState.toggleKey(id);
|
|
68
|
+
(_props_onExpandedChange = props.onExpandedChange) === null || _props_onExpandedChange === void 0 ? void 0 : _props_onExpandedChange.call(props, isExpanded);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
let panelRef = (0, $hI1OT$react).useRef(null);
|
|
72
|
+
let isDisabled = props.isDisabled || (groupState === null || groupState === void 0 ? void 0 : groupState.isDisabled) || false;
|
|
73
|
+
let { buttonProps: buttonProps, panelProps: panelProps } = (0, $hI1OT$useDisclosure)({
|
|
74
|
+
...props,
|
|
75
|
+
isDisabled: isDisabled
|
|
76
|
+
}, state, panelRef);
|
|
34
77
|
let { isFocusVisible: isFocusVisibleWithin, focusProps: focusWithinProps } = (0, $hI1OT$useFocusRing)({
|
|
35
78
|
within: true
|
|
36
79
|
});
|
|
37
80
|
let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
|
|
38
81
|
...props,
|
|
82
|
+
id: undefined,
|
|
39
83
|
defaultClassName: 'react-aria-Disclosure',
|
|
40
84
|
values: {
|
|
41
85
|
isExpanded: state.isExpanded,
|
|
42
|
-
isDisabled:
|
|
86
|
+
isDisabled: isDisabled,
|
|
43
87
|
isFocusVisibleWithin: isFocusVisibleWithin,
|
|
44
88
|
state: state
|
|
45
89
|
}
|
|
46
90
|
});
|
|
91
|
+
let domProps = (0, $hI1OT$filterDOMProps)(otherProps);
|
|
47
92
|
return /*#__PURE__*/ (0, $hI1OT$react).createElement((0, $64fa3d84918910a7$export$2881499e37b75b9a), {
|
|
48
93
|
values: [
|
|
49
94
|
[
|
|
@@ -58,8 +103,8 @@ function $28f4fd908f0de97f$var$Disclosure(props, ref) {
|
|
|
58
103
|
[
|
|
59
104
|
$28f4fd908f0de97f$var$InternalDisclosureContext,
|
|
60
105
|
{
|
|
61
|
-
|
|
62
|
-
|
|
106
|
+
panelProps: panelProps,
|
|
107
|
+
panelRef: panelRef
|
|
63
108
|
}
|
|
64
109
|
],
|
|
65
110
|
[
|
|
@@ -70,15 +115,16 @@ function $28f4fd908f0de97f$var$Disclosure(props, ref) {
|
|
|
70
115
|
}, /*#__PURE__*/ (0, $hI1OT$react).createElement("div", {
|
|
71
116
|
ref: ref,
|
|
72
117
|
"data-expanded": state.isExpanded || undefined,
|
|
73
|
-
"data-disabled":
|
|
118
|
+
"data-disabled": isDisabled || undefined,
|
|
74
119
|
"data-focus-visible-within": isFocusVisibleWithin || undefined,
|
|
120
|
+
...domProps,
|
|
75
121
|
...focusWithinProps,
|
|
76
122
|
...renderProps
|
|
77
123
|
}, renderProps.children));
|
|
78
124
|
}
|
|
79
125
|
function $28f4fd908f0de97f$var$DisclosurePanel(props, ref) {
|
|
80
126
|
let { role: role = 'group' } = props;
|
|
81
|
-
let {
|
|
127
|
+
let { panelProps: panelProps, panelRef: panelRef } = (0, $hI1OT$useContext)($28f4fd908f0de97f$var$InternalDisclosureContext);
|
|
82
128
|
let { isFocusVisible: isFocusVisibleWithin, focusProps: focusWithinProps } = (0, $hI1OT$useFocusRing)({
|
|
83
129
|
within: true
|
|
84
130
|
});
|
|
@@ -90,11 +136,10 @@ function $28f4fd908f0de97f$var$DisclosurePanel(props, ref) {
|
|
|
90
136
|
}
|
|
91
137
|
});
|
|
92
138
|
return /*#__PURE__*/ (0, $hI1OT$react).createElement("div", {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
ref: (0, $hI1OT$mergeRefs)(ref, contentRef),
|
|
96
|
-
...(0, $hI1OT$mergeProps)(contentProps, focusWithinProps),
|
|
139
|
+
ref: (0, $hI1OT$mergeRefs)(ref, panelRef),
|
|
140
|
+
...(0, $hI1OT$mergeProps)(panelProps, focusWithinProps),
|
|
97
141
|
...renderProps,
|
|
142
|
+
role: role,
|
|
98
143
|
"data-focus-visible-within": isFocusVisibleWithin || undefined
|
|
99
144
|
}, /*#__PURE__*/ (0, $hI1OT$react).createElement((0, $64fa3d84918910a7$export$2881499e37b75b9a), {
|
|
100
145
|
values: [
|
|
@@ -111,5 +156,5 @@ function $28f4fd908f0de97f$var$DisclosurePanel(props, ref) {
|
|
|
111
156
|
const $28f4fd908f0de97f$export$feabaa331e1d464c = /*#__PURE__*/ (0, $hI1OT$forwardRef)($28f4fd908f0de97f$var$DisclosurePanel);
|
|
112
157
|
|
|
113
158
|
|
|
114
|
-
export {$28f4fd908f0de97f$export$d665dd135a51b28a as DisclosureContext, $28f4fd908f0de97f$export$dab3ea4a6ef094da as DisclosureStateContext, $28f4fd908f0de97f$export$74a362b31437ec83 as Disclosure, $28f4fd908f0de97f$export$feabaa331e1d464c as DisclosurePanel};
|
|
159
|
+
export {$28f4fd908f0de97f$export$1d40e3e0cc4d5de as DisclosureGroupStateContext, $28f4fd908f0de97f$export$944aceb4f8c89f10 as DisclosureGroup, $28f4fd908f0de97f$export$d665dd135a51b28a as DisclosureContext, $28f4fd908f0de97f$export$dab3ea4a6ef094da as DisclosureStateContext, $28f4fd908f0de97f$export$74a362b31437ec83 as Disclosure, $28f4fd908f0de97f$export$feabaa331e1d464c as DisclosurePanel};
|
|
115
160
|
//# sourceMappingURL=Disclosure.module.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {ButtonContext as $d2b4bc8c273e7be6$export$24d547caef80ccd1} from "./Button.module.js";
|
|
2
2
|
import {DEFAULT_SLOT as $64fa3d84918910a7$export$c62b8e45d58ddad9, Provider as $64fa3d84918910a7$export$2881499e37b75b9a, useContextProps as $64fa3d84918910a7$export$29f1550f4b0d4415, useRenderProps as $64fa3d84918910a7$export$4d86445c2cf5e3} from "./utils.module.js";
|
|
3
3
|
import {useDisclosure as $hI1OT$useDisclosure} from "@react-aria/disclosure";
|
|
4
|
-
import {useDisclosureState as $hI1OT$useDisclosureState} from "@react-stately/disclosure";
|
|
4
|
+
import {useDisclosureGroupState as $hI1OT$useDisclosureGroupState, useDisclosureState as $hI1OT$useDisclosureState} from "@react-stately/disclosure";
|
|
5
|
+
import {filterDOMProps as $hI1OT$filterDOMProps, useId as $hI1OT$useId, mergeRefs as $hI1OT$mergeRefs, mergeProps as $hI1OT$mergeProps} from "@react-aria/utils";
|
|
6
|
+
import $hI1OT$react, {createContext as $hI1OT$createContext, forwardRef as $hI1OT$forwardRef, useContext as $hI1OT$useContext} from "react";
|
|
5
7
|
import {useFocusRing as $hI1OT$useFocusRing} from "react-aria";
|
|
6
|
-
import {mergeRefs as $hI1OT$mergeRefs, mergeProps as $hI1OT$mergeProps} from "@react-aria/utils";
|
|
7
|
-
import $hI1OT$react, {createContext as $hI1OT$createContext, useContext as $hI1OT$useContext, forwardRef as $hI1OT$forwardRef} from "react";
|
|
8
8
|
|
|
9
9
|
/*
|
|
10
10
|
* Copyright 2024 Adobe. All rights reserved.
|
|
@@ -23,27 +23,72 @@ import $hI1OT$react, {createContext as $hI1OT$createContext, useContext as $hI1O
|
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
const $28f4fd908f0de97f$export$1d40e3e0cc4d5de = /*#__PURE__*/ (0, $hI1OT$createContext)(null);
|
|
27
|
+
function $28f4fd908f0de97f$var$DisclosureGroup(props, ref) {
|
|
28
|
+
let state = (0, $hI1OT$useDisclosureGroupState)(props);
|
|
29
|
+
let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
|
|
30
|
+
...props,
|
|
31
|
+
defaultClassName: 'react-aria-DisclosureGroup',
|
|
32
|
+
values: {
|
|
33
|
+
isDisabled: state.isDisabled,
|
|
34
|
+
state: state
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
let domProps = (0, $hI1OT$filterDOMProps)(props);
|
|
38
|
+
return /*#__PURE__*/ (0, $hI1OT$react).createElement("div", {
|
|
39
|
+
...domProps,
|
|
40
|
+
...renderProps,
|
|
41
|
+
ref: ref,
|
|
42
|
+
"data-disabled": props.isDisabled || undefined
|
|
43
|
+
}, /*#__PURE__*/ (0, $hI1OT$react).createElement($28f4fd908f0de97f$export$1d40e3e0cc4d5de.Provider, {
|
|
44
|
+
value: state
|
|
45
|
+
}, renderProps.children));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A DisclosureGroup is a grouping of related disclosures, sometimes called an Accordion.
|
|
49
|
+
* It supports both single and multiple expanded items.
|
|
50
|
+
*/ const $28f4fd908f0de97f$export$944aceb4f8c89f10 = /*#__PURE__*/ (0, $hI1OT$forwardRef)($28f4fd908f0de97f$var$DisclosureGroup);
|
|
26
51
|
const $28f4fd908f0de97f$export$d665dd135a51b28a = /*#__PURE__*/ (0, $hI1OT$createContext)(null);
|
|
27
52
|
const $28f4fd908f0de97f$export$dab3ea4a6ef094da = /*#__PURE__*/ (0, $hI1OT$createContext)(null);
|
|
28
53
|
const $28f4fd908f0de97f$var$InternalDisclosureContext = /*#__PURE__*/ (0, $hI1OT$createContext)(null);
|
|
29
54
|
function $28f4fd908f0de97f$var$Disclosure(props, ref) {
|
|
30
55
|
[props, ref] = (0, $64fa3d84918910a7$export$29f1550f4b0d4415)(props, ref, $28f4fd908f0de97f$export$d665dd135a51b28a);
|
|
31
|
-
let
|
|
32
|
-
let
|
|
33
|
-
|
|
56
|
+
let groupState = (0, $hI1OT$useContext)($28f4fd908f0de97f$export$1d40e3e0cc4d5de);
|
|
57
|
+
let { id: id, ...otherProps } = props;
|
|
58
|
+
// Generate an id if one wasn't provided.
|
|
59
|
+
// (can't pass id into useId since it can also be a number)
|
|
60
|
+
let defaultId = (0, $hI1OT$useId)();
|
|
61
|
+
id || (id = defaultId);
|
|
62
|
+
let state = (0, $hI1OT$useDisclosureState)({
|
|
63
|
+
...props,
|
|
64
|
+
isExpanded: groupState ? groupState.expandedKeys.has(id) : props.isExpanded,
|
|
65
|
+
onExpandedChange (isExpanded) {
|
|
66
|
+
var _props_onExpandedChange;
|
|
67
|
+
if (groupState) groupState.toggleKey(id);
|
|
68
|
+
(_props_onExpandedChange = props.onExpandedChange) === null || _props_onExpandedChange === void 0 ? void 0 : _props_onExpandedChange.call(props, isExpanded);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
let panelRef = (0, $hI1OT$react).useRef(null);
|
|
72
|
+
let isDisabled = props.isDisabled || (groupState === null || groupState === void 0 ? void 0 : groupState.isDisabled) || false;
|
|
73
|
+
let { buttonProps: buttonProps, panelProps: panelProps } = (0, $hI1OT$useDisclosure)({
|
|
74
|
+
...props,
|
|
75
|
+
isDisabled: isDisabled
|
|
76
|
+
}, state, panelRef);
|
|
34
77
|
let { isFocusVisible: isFocusVisibleWithin, focusProps: focusWithinProps } = (0, $hI1OT$useFocusRing)({
|
|
35
78
|
within: true
|
|
36
79
|
});
|
|
37
80
|
let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
|
|
38
81
|
...props,
|
|
82
|
+
id: undefined,
|
|
39
83
|
defaultClassName: 'react-aria-Disclosure',
|
|
40
84
|
values: {
|
|
41
85
|
isExpanded: state.isExpanded,
|
|
42
|
-
isDisabled:
|
|
86
|
+
isDisabled: isDisabled,
|
|
43
87
|
isFocusVisibleWithin: isFocusVisibleWithin,
|
|
44
88
|
state: state
|
|
45
89
|
}
|
|
46
90
|
});
|
|
91
|
+
let domProps = (0, $hI1OT$filterDOMProps)(otherProps);
|
|
47
92
|
return /*#__PURE__*/ (0, $hI1OT$react).createElement((0, $64fa3d84918910a7$export$2881499e37b75b9a), {
|
|
48
93
|
values: [
|
|
49
94
|
[
|
|
@@ -58,8 +103,8 @@ function $28f4fd908f0de97f$var$Disclosure(props, ref) {
|
|
|
58
103
|
[
|
|
59
104
|
$28f4fd908f0de97f$var$InternalDisclosureContext,
|
|
60
105
|
{
|
|
61
|
-
|
|
62
|
-
|
|
106
|
+
panelProps: panelProps,
|
|
107
|
+
panelRef: panelRef
|
|
63
108
|
}
|
|
64
109
|
],
|
|
65
110
|
[
|
|
@@ -70,15 +115,16 @@ function $28f4fd908f0de97f$var$Disclosure(props, ref) {
|
|
|
70
115
|
}, /*#__PURE__*/ (0, $hI1OT$react).createElement("div", {
|
|
71
116
|
ref: ref,
|
|
72
117
|
"data-expanded": state.isExpanded || undefined,
|
|
73
|
-
"data-disabled":
|
|
118
|
+
"data-disabled": isDisabled || undefined,
|
|
74
119
|
"data-focus-visible-within": isFocusVisibleWithin || undefined,
|
|
120
|
+
...domProps,
|
|
75
121
|
...focusWithinProps,
|
|
76
122
|
...renderProps
|
|
77
123
|
}, renderProps.children));
|
|
78
124
|
}
|
|
79
125
|
function $28f4fd908f0de97f$var$DisclosurePanel(props, ref) {
|
|
80
126
|
let { role: role = 'group' } = props;
|
|
81
|
-
let {
|
|
127
|
+
let { panelProps: panelProps, panelRef: panelRef } = (0, $hI1OT$useContext)($28f4fd908f0de97f$var$InternalDisclosureContext);
|
|
82
128
|
let { isFocusVisible: isFocusVisibleWithin, focusProps: focusWithinProps } = (0, $hI1OT$useFocusRing)({
|
|
83
129
|
within: true
|
|
84
130
|
});
|
|
@@ -90,11 +136,10 @@ function $28f4fd908f0de97f$var$DisclosurePanel(props, ref) {
|
|
|
90
136
|
}
|
|
91
137
|
});
|
|
92
138
|
return /*#__PURE__*/ (0, $hI1OT$react).createElement("div", {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
ref: (0, $hI1OT$mergeRefs)(ref, contentRef),
|
|
96
|
-
...(0, $hI1OT$mergeProps)(contentProps, focusWithinProps),
|
|
139
|
+
ref: (0, $hI1OT$mergeRefs)(ref, panelRef),
|
|
140
|
+
...(0, $hI1OT$mergeProps)(panelProps, focusWithinProps),
|
|
97
141
|
...renderProps,
|
|
142
|
+
role: role,
|
|
98
143
|
"data-focus-visible-within": isFocusVisibleWithin || undefined
|
|
99
144
|
}, /*#__PURE__*/ (0, $hI1OT$react).createElement((0, $64fa3d84918910a7$export$2881499e37b75b9a), {
|
|
100
145
|
values: [
|
|
@@ -111,5 +156,5 @@ function $28f4fd908f0de97f$var$DisclosurePanel(props, ref) {
|
|
|
111
156
|
const $28f4fd908f0de97f$export$feabaa331e1d464c = /*#__PURE__*/ (0, $hI1OT$forwardRef)($28f4fd908f0de97f$var$DisclosurePanel);
|
|
112
157
|
|
|
113
158
|
|
|
114
|
-
export {$28f4fd908f0de97f$export$d665dd135a51b28a as DisclosureContext, $28f4fd908f0de97f$export$dab3ea4a6ef094da as DisclosureStateContext, $28f4fd908f0de97f$export$74a362b31437ec83 as Disclosure, $28f4fd908f0de97f$export$feabaa331e1d464c as DisclosurePanel};
|
|
159
|
+
export {$28f4fd908f0de97f$export$1d40e3e0cc4d5de as DisclosureGroupStateContext, $28f4fd908f0de97f$export$944aceb4f8c89f10 as DisclosureGroup, $28f4fd908f0de97f$export$d665dd135a51b28a as DisclosureContext, $28f4fd908f0de97f$export$dab3ea4a6ef094da as DisclosureStateContext, $28f4fd908f0de97f$export$74a362b31437ec83 as Disclosure, $28f4fd908f0de97f$export$feabaa331e1d464c as DisclosurePanel};
|
|
115
160
|
//# sourceMappingURL=Disclosure.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;AAmCM,MAAM,0DAAoB,CAAA,GAAA,oBAAY,EAAiD;AACvF,MAAM,0DAAyB,CAAA,GAAA,oBAAY,EAA0B;AAO5E,MAAM,gEAA4B,CAAA,GAAA,oBAAY,EAAyC;AAEvF,SAAS,iCAAW,KAAsB,EAAE,GAAiC;IAC3E,CAAC,OAAO,IAAI,GAAG,CAAA,GAAA,yCAAc,EAAE,OAAO,KAAK;IAC3C,IAAI,QAAQ,CAAA,GAAA,yBAAiB,EAAE;IAC/B,IAAI,aAAa,CAAA,GAAA,YAAI,EAAE,MAAM,CAAqB;IAClD,IAAI,eAAC,WAAW,gBAAE,YAAY,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE,OAAO,OAAO;IAC9D,IAAI,EACF,gBAAgB,oBAAoB,EACpC,YAAY,gBAAgB,EAC7B,GAAG,CAAA,GAAA,mBAAW,EAAE;QAAC,QAAQ;IAAI;IAE9B,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;YACN,YAAY,MAAM,UAAU;YAC5B,YAAY,MAAM,UAAU,IAAI;kCAChC;mBACA;QACF;IACF;IAEA,qBACE,gCAAC,CAAA,GAAA,yCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,yCAAY;gBAAG;oBACd,OAAO;wBACL,CAAC,CAAA,GAAA,yCAAW,EAAE,EAAE,CAAC;wBACjB,SAAS;oBACX;gBACF;aAAE;YACF;gBAAC;gBAA2B;kCAAC;gCAAc;gBAAU;aAAE;YACvD;gBAAC;gBAAwB;aAAM;SAChC;qBACD,gCAAC;QACC,KAAK;QACL,iBAAe,MAAM,UAAU,IAAI;QACnC,iBAAe,MAAM,UAAU,IAAI;QACnC,6BAA2B,wBAAwB;QAClD,GAAG,gBAAgB;QACnB,GAAG,WAAW;OACd,YAAY,QAAQ;AAI7B;AAWA,SAAS,sCAAgB,KAA2B,EAAE,GAA8B;IAClF,IAAI,QAAC,OAAO,SAAQ,GAAG;IACvB,IAAI,gBAAC,YAAY,cAAE,UAAU,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE;IAC5C,IAAI,EACF,gBAAgB,oBAAoB,EACpC,YAAY,gBAAgB,EAC7B,GAAG,CAAA,GAAA,mBAAW,EAAE;QAAC,QAAQ;IAAI;IAC9B,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;kCACN;QACF;IACF;IACA,qBACE,gCAAC;QACC,MAAM;QACN,aAAa;QACb,KAAK,CAAA,GAAA,gBAAQ,EAAE,KAAK;QACnB,GAAG,CAAA,GAAA,iBAAS,EAAE,cAAc,iBAAiB;QAC7C,GAAG,WAAW;QACf,6BAA2B,wBAAwB;qBACnD,gCAAC,CAAA,GAAA,yCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,yCAAY;gBAAG;aAAK;SACtB;OACA,MAAM,QAAQ;AAIvB;AAEA;;CAEC,GACD,MAAM,4CAA4B,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB;AAGjE,MAAM,4CAAiC,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB","sources":["packages/react-aria-components/src/Disclosure.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaDisclosureProps, useDisclosure} from '@react-aria/disclosure';\nimport {ButtonContext} from './Button';\nimport {ContextValue, DEFAULT_SLOT, Provider, RenderProps, SlotProps, useContextProps, useRenderProps} from './utils';\nimport {DisclosureState, useDisclosureState} from '@react-stately/disclosure';\nimport {forwardRefType} from '@react-types/shared';\nimport {HoverEvents, useFocusRing} from 'react-aria';\nimport {mergeProps, mergeRefs} from '@react-aria/utils';\nimport React, {createContext, DOMAttributes, ForwardedRef, forwardRef, ReactNode, useContext} from 'react';\n\nexport interface DisclosureProps extends Omit<AriaDisclosureProps, 'children'>, HoverEvents, RenderProps<DisclosureRenderProps>, SlotProps {}\n\nexport interface DisclosureRenderProps {\n /**\n * Whether the disclosure is expanded.\n * @selector [data-expanded]\n */\n isExpanded: boolean,\n /**\n * Whether the disclosure has keyboard focus.\n * @selector [data-focus-visible-within]\n */\n isFocusVisibleWithin: boolean,\n /**\n * Whether the disclosure is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * State of the disclosure.\n */\n state: DisclosureState\n}\n\nexport const DisclosureContext = createContext<ContextValue<DisclosureProps, HTMLDivElement>>(null);\nexport const DisclosureStateContext = createContext<DisclosureState | null>(null);\n\ninterface InternalDisclosureContextValue {\n contentProps: DOMAttributes<HTMLElement>,\n contentRef: React.RefObject<HTMLElement | null>\n}\n\nconst InternalDisclosureContext = createContext<InternalDisclosureContextValue | null>(null);\n\nfunction Disclosure(props: DisclosureProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, DisclosureContext);\n let state = useDisclosureState(props);\n let contentRef = React.useRef<HTMLElement | null>(null);\n let {buttonProps, contentProps} = useDisclosure(props, state, contentRef);\n let {\n isFocusVisible: isFocusVisibleWithin,\n focusProps: focusWithinProps\n } = useFocusRing({within: true});\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-Disclosure',\n values: {\n isExpanded: state.isExpanded,\n isDisabled: props.isDisabled || false,\n isFocusVisibleWithin,\n state\n }\n });\n\n return (\n <Provider\n values={[\n [ButtonContext, {\n slots: {\n [DEFAULT_SLOT]: {},\n trigger: buttonProps\n }\n }],\n [InternalDisclosureContext, {contentProps, contentRef}],\n [DisclosureStateContext, state]\n ]}>\n <div\n ref={ref}\n data-expanded={state.isExpanded || undefined}\n data-disabled={props.isDisabled || undefined}\n data-focus-visible-within={isFocusVisibleWithin || undefined}\n {...focusWithinProps}\n {...renderProps}>\n {renderProps.children}\n </div>\n </Provider>\n );\n}\n\nexport interface DisclosurePanelProps extends RenderProps<{}> {\n /**\n * The accessibility role for the disclosure's panel.\n * @default 'group'\n */\n role?: 'group' | 'region',\n children: ReactNode\n}\n\nfunction DisclosurePanel(props: DisclosurePanelProps, ref: ForwardedRef<HTMLElement>) {\n let {role = 'group'} = props;\n let {contentProps, contentRef} = useContext(InternalDisclosureContext)!;\n let {\n isFocusVisible: isFocusVisibleWithin,\n focusProps: focusWithinProps\n } = useFocusRing({within: true});\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-DisclosurePanel',\n values: {\n isFocusVisibleWithin\n }\n });\n return (\n <div\n role={role}\n // @ts-ignore\n ref={mergeRefs(ref, contentRef)}\n {...mergeProps(contentProps, focusWithinProps)}\n {...renderProps}\n data-focus-visible-within={isFocusVisibleWithin || undefined}>\n <Provider\n values={[\n [ButtonContext, null]\n ]}>\n {props.children}\n </Provider>\n </div>\n );\n}\n\n/**\n * A disclosure is a collapsible section of content. It is composed of a a header with a heading and trigger button, and a panel that contains the content.\n */\nconst _Disclosure = /*#__PURE__*/ (forwardRef as forwardRefType)(Disclosure);\nexport {_Disclosure as Disclosure};\n\nconst _DisclosurePanel = /*#__PURE__*/ (forwardRef as forwardRefType)(DisclosurePanel);\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AQ,EAAC,GAAG,CAAA,GAAA,iBAAS,EAAE;IACxC,IAAI,EACF,gBAAgB,oBAAoB,EACpC,YAAY,gBAAgB,EAC7B,GAAG,CAAA,GAAA,mBAAW,EAAE;QAAC,QAAQ;IAAI;IAC9B,IAAI,cAAc,CAAA,GAAA,uCAAa,EAAE;QAC/B,GAAG,KAAK;QACR,kBAAkB;QAClB,QAAQ;kCACN;QACF;IACF;IACA,qBACE,gCAAC;QACC,KAAK,CAAA,GAAA,gBAAQ,EAAE,KAAK;QACnB,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY,iBAAiB;QAC3C,GAAG,WAAW;QACf,MAAM;QACN,6BAA2B,wBAAwB;qBACnD,gCAAC,CAAA,GAAA,yCAAO;QACN,QAAQ;YACN;gBAAC,CAAA,GAAA,yCAAY;gBAAG;aAAK;SACtB;OACA,MAAM,QAAQ;AAIvB;AAEA;;CAEC,GACD,MAAM,4CAA4B,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB;AAGjE,MAAM,4CAAiC,AAAd,WAAW,GAAI,CAAA,GAAA,iBAAS,EAAqB","sources":["packages/react-aria-components/src/Disclosure.tsx"],"sourcesContent":["/*\n * Copyright 2024 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 {AriaDisclosureProps, useDisclosure} from '@react-aria/disclosure';\nimport {ButtonContext} from './Button';\nimport {ContextValue, DEFAULT_SLOT, Provider, RenderProps, SlotProps, useContextProps, useRenderProps} from './utils';\nimport {DisclosureGroupState, DisclosureState, DisclosureGroupProps as StatelyDisclosureGroupProps, useDisclosureGroupState, useDisclosureState} from '@react-stately/disclosure';\nimport {DOMProps, forwardRefType, Key} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, mergeRefs, useId} from '@react-aria/utils';\nimport React, {createContext, DOMAttributes, ForwardedRef, forwardRef, ReactNode, useContext} from 'react';\nimport {useFocusRing} from 'react-aria';\n\nexport interface DisclosureGroupProps extends StatelyDisclosureGroupProps, RenderProps<DisclosureGroupRenderProps>, DOMProps {}\n\nexport interface DisclosureGroupRenderProps {\n /**\n * Whether the disclosure group is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * State of the disclosure group.\n */\n state: DisclosureGroupState\n}\n\nexport const DisclosureGroupStateContext = createContext<DisclosureGroupState | null>(null);\n\nfunction DisclosureGroup(props: DisclosureGroupProps, ref: ForwardedRef<HTMLDivElement>) {\n let state = useDisclosureGroupState(props);\n\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-DisclosureGroup',\n values: {\n isDisabled: state.isDisabled,\n state\n }\n });\n\n let domProps = filterDOMProps(props);\n\n return (\n <div\n {...domProps}\n {...renderProps}\n ref={ref}\n data-disabled={props.isDisabled || undefined}>\n <DisclosureGroupStateContext.Provider value={state}>\n {renderProps.children}\n </DisclosureGroupStateContext.Provider>\n </div>\n );\n}\n\n/**\n * A DisclosureGroup is a grouping of related disclosures, sometimes called an Accordion.\n * It supports both single and multiple expanded items.\n */\nconst _DisclosureGroup = forwardRef(DisclosureGroup);\nexport {_DisclosureGroup as DisclosureGroup};\n\nexport interface DisclosureProps extends Omit<AriaDisclosureProps, 'children'>, RenderProps<DisclosureRenderProps>, SlotProps {\n /** An id for the disclosure when used within a DisclosureGroup, matching the id used in `expandedKeys`. */\n id?: Key\n}\n\nexport interface DisclosureRenderProps {\n /**\n * Whether the disclosure is expanded.\n * @selector [data-expanded]\n */\n isExpanded: boolean,\n /**\n * Whether the disclosure has keyboard focus.\n * @selector [data-focus-visible-within]\n */\n isFocusVisibleWithin: boolean,\n /**\n * Whether the disclosure is disabled.\n * @selector [data-disabled]\n */\n isDisabled: boolean,\n /**\n * State of the disclosure.\n */\n state: DisclosureState\n}\n\nexport const DisclosureContext = createContext<ContextValue<DisclosureProps, HTMLDivElement>>(null);\nexport const DisclosureStateContext = createContext<DisclosureState | null>(null);\n\ninterface InternalDisclosureContextValue {\n panelProps: DOMAttributes<HTMLElement>,\n panelRef: React.RefObject<HTMLDivElement | null>\n}\n\nconst InternalDisclosureContext = createContext<InternalDisclosureContextValue | null>(null);\n\nfunction Disclosure(props: DisclosureProps, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, DisclosureContext);\n let groupState = useContext(DisclosureGroupStateContext);\n let {id, ...otherProps} = props;\n\n // Generate an id if one wasn't provided.\n // (can't pass id into useId since it can also be a number)\n let defaultId = useId();\n id ||= defaultId;\n\n let state = useDisclosureState({\n ...props,\n isExpanded: groupState ? groupState.expandedKeys.has(id) : props.isExpanded,\n onExpandedChange(isExpanded) {\n if (groupState) {\n groupState.toggleKey(id);\n }\n\n props.onExpandedChange?.(isExpanded);\n }\n });\n\n let panelRef = React.useRef<HTMLDivElement | null>(null);\n let isDisabled = props.isDisabled || groupState?.isDisabled || false;\n let {buttonProps, panelProps} = useDisclosure({\n ...props,\n isDisabled\n }, state, panelRef);\n let {\n isFocusVisible: isFocusVisibleWithin,\n focusProps: focusWithinProps\n } = useFocusRing({within: true});\n\n let renderProps = useRenderProps({\n ...props,\n id: undefined,\n defaultClassName: 'react-aria-Disclosure',\n values: {\n isExpanded: state.isExpanded,\n isDisabled,\n isFocusVisibleWithin,\n state\n }\n });\n\n let domProps = filterDOMProps(otherProps as any);\n\n return (\n <Provider\n values={[\n [ButtonContext, {\n slots: {\n [DEFAULT_SLOT]: {},\n trigger: buttonProps\n }\n }],\n [InternalDisclosureContext, {panelProps, panelRef}],\n [DisclosureStateContext, state]\n ]}>\n <div\n ref={ref}\n data-expanded={state.isExpanded || undefined}\n data-disabled={isDisabled || undefined}\n data-focus-visible-within={isFocusVisibleWithin || undefined}\n {...domProps}\n {...focusWithinProps}\n {...renderProps}>\n {renderProps.children}\n </div>\n </Provider>\n );\n}\n\nexport interface DisclosurePanelProps extends RenderProps<{}> {\n /**\n * The accessibility role for the disclosure's panel.\n * @default 'group'\n */\n role?: 'group' | 'region',\n children: ReactNode\n}\n\nfunction DisclosurePanel(props: DisclosurePanelProps, ref: ForwardedRef<HTMLDivElement>) {\n let {role = 'group'} = props;\n let {panelProps, panelRef} = useContext(InternalDisclosureContext)!;\n let {\n isFocusVisible: isFocusVisibleWithin,\n focusProps: focusWithinProps\n } = useFocusRing({within: true});\n let renderProps = useRenderProps({\n ...props,\n defaultClassName: 'react-aria-DisclosurePanel',\n values: {\n isFocusVisibleWithin\n }\n });\n return (\n <div\n ref={mergeRefs(ref, panelRef)}\n {...mergeProps(panelProps, focusWithinProps)}\n {...renderProps}\n role={role}\n data-focus-visible-within={isFocusVisibleWithin || undefined}>\n <Provider\n values={[\n [ButtonContext, null]\n ]}>\n {props.children}\n </Provider>\n </div>\n );\n}\n\n/**\n * A disclosure is a collapsible section of content. It is composed of a a header with a heading and trigger button, and a panel that contains the content.\n */\nconst _Disclosure = /*#__PURE__*/ (forwardRef as forwardRefType)(Disclosure);\nexport {_Disclosure as Disclosure};\n\nconst _DisclosurePanel = /*#__PURE__*/ (forwardRef as forwardRefType)(DisclosurePanel);\nexport {_DisclosurePanel as DisclosurePanel};\n"],"names":[],"version":3,"file":"Disclosure.module.js.map"}
|
package/dist/Tree.main.js
CHANGED
|
@@ -282,6 +282,10 @@ const $c6576bb58bfa084b$export$635b3358b7a3dfbb = /*#__PURE__*/ (0, $5SMu3$react
|
|
|
282
282
|
id: undefined,
|
|
283
283
|
children: item.rendered,
|
|
284
284
|
defaultClassName: 'react-aria-TreeItem',
|
|
285
|
+
defaultStyle: {
|
|
286
|
+
// @ts-ignore
|
|
287
|
+
'--tree-item-level': level
|
|
288
|
+
},
|
|
285
289
|
values: renderPropValues
|
|
286
290
|
});
|
|
287
291
|
(0, $5SMu3$react.useEffect)(()=>{
|
|
@@ -315,8 +319,8 @@ const $c6576bb58bfa084b$export$635b3358b7a3dfbb = /*#__PURE__*/ (0, $5SMu3$react
|
|
|
315
319
|
...renderProps,
|
|
316
320
|
ref: ref,
|
|
317
321
|
// TODO: missing selectionBehavior, hasAction and allowsSelection data attribute equivalents (available in renderProps). Do we want those?
|
|
318
|
-
"data-expanded": hasChildRows
|
|
319
|
-
"data-has-child-rows": hasChildRows,
|
|
322
|
+
"data-expanded": hasChildRows && isExpanded || undefined,
|
|
323
|
+
"data-has-child-rows": hasChildRows || undefined,
|
|
320
324
|
"data-level": level,
|
|
321
325
|
"data-selected": states.isSelected || undefined,
|
|
322
326
|
"data-disabled": states.isDisabled || undefined,
|