@react-stately/disclosure 3.0.3 → 3.0.5
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/types.d.ts.map +1 -1
- package/dist/useDisclosureGroupState.main.js +6 -3
- package/dist/useDisclosureGroupState.main.js.map +1 -1
- package/dist/useDisclosureGroupState.mjs +6 -3
- package/dist/useDisclosureGroupState.module.js +6 -3
- package/dist/useDisclosureGroupState.module.js.map +1 -1
- package/package.json +9 -5
- package/src/useDisclosureGroupState.ts +7 -4
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";AAeA;IACE,uDAAuD;IACvD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,oEAAoE;IACpE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,yEAAyE;IACzE,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAA;CACjD;AAGD;IACE,oDAAoD;IACpD,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,+CAA+C;IAC/C,WAAW,CAAC,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;IACvC,6BAA6B;IAC7B,MAAM,IAAI,IAAI,CAAC;IACf,+BAA+B;IAC/B,QAAQ,IAAI,IAAI,CAAC;IACjB,2CAA2C;IAC3C,MAAM,IAAI,IAAI,CAAA;CACf;AAED;;;GAGG;AACH,mCAAmC,KAAK,EAAE,eAAe,GAAG,eAAe,CAsB1E;AChDD;IACE,+DAA+D;IAC/D,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,sCAAsC;IACtC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,6DAA6D;IAC7D,YAAY,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC7B,6DAA6D;IAC7D,mBAAmB,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IACpC,mEAAmE;IACnE,gBAAgB,CAAC,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CAAC;IAC7B,6DAA6D;IAC7D,mBAAmB,CAAC,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;IACpC,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,KAAK,GAAG,CAAA;CAC3C;AAED;IACE,+DAA+D;IAC/D,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAC;IAEzC,sCAAsC;IACtC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAE7B,iDAAiD;IACjD,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAEhC,yDAAyD;IACzD,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;IAE1B,yCAAyC;IACzC,eAAe,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;CACtC;AAED;;;GAGG;AACH,wCAAwC,KAAK,EAAE,oBAAoB,GAAG,oBAAoB,CAuCzF","sources":["packages/@react-stately/disclosure/src/packages/@react-stately/disclosure/src/useDisclosureState.ts","packages/@react-stately/disclosure/src/packages/@react-stately/disclosure/src/useDisclosureGroupState.ts","packages/@react-stately/disclosure/src/packages/@react-stately/disclosure/src/index.ts","packages/@react-stately/disclosure/src/index.ts"],"sourcesContent":[null,null,null,"/*\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\nexport {useDisclosureState} from './useDisclosureState';\nexport {useDisclosureGroupState} from './useDisclosureGroupState';\n\nexport type {DisclosureState, DisclosureProps} from './useDisclosureState';\nexport type {DisclosureGroupState, DisclosureGroupProps} from './useDisclosureGroupState';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -28,9 +28,12 @@ function $8654db152d40114d$export$f36461af0ef4707d(props) {
|
|
|
28
28
|
]), props.onExpandedChange);
|
|
29
29
|
(0, $eOP8W$react.useEffect)(()=>{
|
|
30
30
|
// Ensure only one item is expanded if allowsMultipleExpanded is false.
|
|
31
|
-
if (!allowsMultipleExpanded && expandedKeys.size > 1)
|
|
32
|
-
expandedKeys.values().next().value
|
|
33
|
-
|
|
31
|
+
if (!allowsMultipleExpanded && expandedKeys.size > 1) {
|
|
32
|
+
let firstKey = expandedKeys.values().next().value;
|
|
33
|
+
if (firstKey != null) setExpandedKeys(new Set([
|
|
34
|
+
firstKey
|
|
35
|
+
]));
|
|
36
|
+
}
|
|
34
37
|
});
|
|
35
38
|
return {
|
|
36
39
|
allowsMultipleExpanded: allowsMultipleExpanded,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAwCM,SAAS,0CAAwB,KAA2B;IACjE,IAAI,0BAAC,yBAAyB,mBAAO,aAAa,OAAM,GAAG;IAC3D,IAAI,CAAC,cAAc,gBAAgB,GAAG,CAAA,GAAA,2CAAiB,EACrD,CAAA,GAAA,oBAAM,EAAE,IAAM,MAAM,YAAY,GAAG,IAAI,IAAI,MAAM,YAAY,IAAI,WAAW;QAAC,MAAM,YAAY;KAAC,GAChG,CAAA,GAAA,oBAAM,EAAE,IAAM,MAAM,mBAAmB,GAAG,IAAI,IAAI,MAAM,mBAAmB,IAAI,IAAI,OAAO;QAAC,MAAM,mBAAmB;KAAC,GACrH,MAAM,gBAAgB;IAGxB,CAAA,GAAA,sBAAQ,EAAE;QACR,uEAAuE;QACvE,IAAI,CAAC,0BAA0B,aAAa,IAAI,GAAG,
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAwCM,SAAS,0CAAwB,KAA2B;IACjE,IAAI,0BAAC,yBAAyB,mBAAO,aAAa,OAAM,GAAG;IAC3D,IAAI,CAAC,cAAc,gBAAgB,GAAG,CAAA,GAAA,2CAAiB,EACrD,CAAA,GAAA,oBAAM,EAAE,IAAM,MAAM,YAAY,GAAG,IAAI,IAAI,MAAM,YAAY,IAAI,WAAW;QAAC,MAAM,YAAY;KAAC,GAChG,CAAA,GAAA,oBAAM,EAAE,IAAM,MAAM,mBAAmB,GAAG,IAAI,IAAI,MAAM,mBAAmB,IAAI,IAAI,OAAO;QAAC,MAAM,mBAAmB;KAAC,GACrH,MAAM,gBAAgB;IAGxB,CAAA,GAAA,sBAAQ,EAAE;QACR,uEAAuE;QACvE,IAAI,CAAC,0BAA0B,aAAa,IAAI,GAAG,GAAG;YACpD,IAAI,WAAW,aAAa,MAAM,GAAG,IAAI,GAAG,KAAK;YACjD,IAAI,YAAY,MACd,gBAAgB,IAAI,IAAI;gBAAC;aAAS;QAEtC;IACF;IAEA,OAAO;gCACL;oBACA;sBACA;yBACA;QACA,WAAU,GAAG;YACX,IAAI;YACJ,IAAI,wBAAwB;gBAC1B,OAAO,IAAI,IAAI;gBACf,IAAI,KAAK,GAAG,CAAC,MACX,KAAK,MAAM,CAAC;qBAEZ,KAAK,GAAG,CAAC;YAEb,OACE,OAAO,IAAI,IAAI,aAAa,GAAG,CAAC,OAAO,EAAE,GAAG;gBAAC;aAAI;YAGnD,gBAAgB;QAClB;IACF;AACF","sources":["packages/@react-stately/disclosure/src/useDisclosureGroupState.ts"],"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 {Key} from '@react-types/shared';\nimport {useControlledState} from '@react-stately/utils';\nimport {useEffect, useMemo} from 'react';\n\nexport interface DisclosureGroupProps {\n /** Whether multiple items can be expanded at the same time. */\n allowsMultipleExpanded?: boolean,\n /** Whether all items are disabled. */\n isDisabled?: boolean,\n /** The currently expanded keys in the group (controlled). */\n expandedKeys?: Iterable<Key>,\n /** The initial expanded keys in the group (uncontrolled). */\n defaultExpandedKeys?: Iterable<Key>,\n /** Handler that is called when items are expanded or collapsed. */\n onExpandedChange?: (keys: Set<Key>) => any\n}\n\nexport interface DisclosureGroupState {\n /** Whether multiple items can be expanded at the same time. */\n readonly allowsMultipleExpanded: boolean,\n\n /** Whether all items are disabled. */\n readonly isDisabled: boolean,\n\n /** A set of keys for items that are expanded. */\n readonly expandedKeys: Set<Key>,\n\n /** Toggles the expanded state for an item by its key. */\n toggleKey(key: Key): void,\n\n /** Replaces the set of expanded keys. */\n setExpandedKeys(keys: Set<Key>): void\n}\n\n/**\n * Manages state for a group of disclosures, e.g. an accordion.\n * It supports both single and multiple expanded items.\n */\nexport function useDisclosureGroupState(props: DisclosureGroupProps): DisclosureGroupState {\n let {allowsMultipleExpanded = false, isDisabled = false} = props;\n let [expandedKeys, setExpandedKeys] = useControlledState(\n useMemo(() => props.expandedKeys ? new Set(props.expandedKeys) : undefined, [props.expandedKeys]),\n useMemo(() => props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set(), [props.defaultExpandedKeys]),\n props.onExpandedChange\n );\n\n useEffect(() => {\n // Ensure only one item is expanded if allowsMultipleExpanded is false.\n if (!allowsMultipleExpanded && expandedKeys.size > 1) {\n let firstKey = expandedKeys.values().next().value;\n if (firstKey != null) {\n setExpandedKeys(new Set([firstKey]));\n }\n }\n });\n\n return {\n allowsMultipleExpanded,\n isDisabled,\n expandedKeys,\n setExpandedKeys,\n toggleKey(key) {\n let keys: Set<Key>;\n if (allowsMultipleExpanded) {\n keys = new Set(expandedKeys);\n if (keys.has(key)) {\n keys.delete(key);\n } else {\n keys.add(key);\n }\n } else {\n keys = new Set(expandedKeys.has(key) ? [] : [key]);\n }\n\n setExpandedKeys(keys);\n }\n };\n}\n"],"names":[],"version":3,"file":"useDisclosureGroupState.main.js.map"}
|
|
@@ -22,9 +22,12 @@ function $9385b3affbdec831$export$f36461af0ef4707d(props) {
|
|
|
22
22
|
]), props.onExpandedChange);
|
|
23
23
|
(0, $j4gLc$useEffect)(()=>{
|
|
24
24
|
// Ensure only one item is expanded if allowsMultipleExpanded is false.
|
|
25
|
-
if (!allowsMultipleExpanded && expandedKeys.size > 1)
|
|
26
|
-
expandedKeys.values().next().value
|
|
27
|
-
|
|
25
|
+
if (!allowsMultipleExpanded && expandedKeys.size > 1) {
|
|
26
|
+
let firstKey = expandedKeys.values().next().value;
|
|
27
|
+
if (firstKey != null) setExpandedKeys(new Set([
|
|
28
|
+
firstKey
|
|
29
|
+
]));
|
|
30
|
+
}
|
|
28
31
|
});
|
|
29
32
|
return {
|
|
30
33
|
allowsMultipleExpanded: allowsMultipleExpanded,
|
|
@@ -22,9 +22,12 @@ function $9385b3affbdec831$export$f36461af0ef4707d(props) {
|
|
|
22
22
|
]), props.onExpandedChange);
|
|
23
23
|
(0, $j4gLc$useEffect)(()=>{
|
|
24
24
|
// Ensure only one item is expanded if allowsMultipleExpanded is false.
|
|
25
|
-
if (!allowsMultipleExpanded && expandedKeys.size > 1)
|
|
26
|
-
expandedKeys.values().next().value
|
|
27
|
-
|
|
25
|
+
if (!allowsMultipleExpanded && expandedKeys.size > 1) {
|
|
26
|
+
let firstKey = expandedKeys.values().next().value;
|
|
27
|
+
if (firstKey != null) setExpandedKeys(new Set([
|
|
28
|
+
firstKey
|
|
29
|
+
]));
|
|
30
|
+
}
|
|
28
31
|
});
|
|
29
32
|
return {
|
|
30
33
|
allowsMultipleExpanded: allowsMultipleExpanded,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAwCM,SAAS,0CAAw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;gBAC1B,OAAO,IAAI,IAAI;gBACf,IAAI,KAAK,GAAG,CAAC,MACX,KAAK,MAAM,CAAC;qBAEZ,KAAK,GAAG,CAAC;YAEb,OACE,OAAO,IAAI,IAAI,aAAa,GAAG,CAAC,OAAO,EAAE,GAAG;gBAAC;aAAI;YAGnD,gBAAgB;QAClB;IACF;AACF","sources":["packages/@react-stately/disclosure/src/useDisclosureGroupState.ts"],"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 {Key} from '@react-types/shared';\nimport {useControlledState} from '@react-stately/utils';\nimport {useEffect, useMemo} from 'react';\n\nexport interface DisclosureGroupProps {\n /** Whether multiple items can be expanded at the same time. */\n allowsMultipleExpanded?: boolean,\n /** Whether all items are disabled. */\n isDisabled?: boolean,\n /** The currently expanded keys in the group (controlled). */\n expandedKeys?: Iterable<Key>,\n /** The initial expanded keys in the group (uncontrolled). */\n defaultExpandedKeys?: Iterable<Key>,\n /** Handler that is called when items are expanded or collapsed. */\n onExpandedChange?: (keys: Set<Key>) => any\n}\n\nexport interface DisclosureGroupState {\n /** Whether multiple items can be expanded at the same time. */\n readonly allowsMultipleExpanded: boolean,\n\n /** Whether all items are disabled. */\n readonly isDisabled: boolean,\n\n /** A set of keys for items that are expanded. */\n readonly expandedKeys: Set<Key>,\n\n /** Toggles the expanded state for an item by its key. */\n toggleKey(key: Key): void,\n\n /** Replaces the set of expanded keys. */\n setExpandedKeys(keys: Set<Key>): void\n}\n\n/**\n * Manages state for a group of disclosures, e.g. an accordion.\n * It supports both single and multiple expanded items.\n */\nexport function useDisclosureGroupState(props: DisclosureGroupProps): DisclosureGroupState {\n let {allowsMultipleExpanded = false, isDisabled = false} = props;\n let [expandedKeys, setExpandedKeys] = useControlledState(\n useMemo(() => props.expandedKeys ? new Set(props.expandedKeys) : undefined, [props.expandedKeys]),\n useMemo(() => props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set(), [props.defaultExpandedKeys]),\n props.onExpandedChange\n );\n\n useEffect(() => {\n // Ensure only one item is expanded if allowsMultipleExpanded is false.\n if (!allowsMultipleExpanded && expandedKeys.size > 1) {\n let firstKey = expandedKeys.values().next().value;\n if (firstKey != null) {\n setExpandedKeys(new Set([firstKey]));\n }\n }\n });\n\n return {\n allowsMultipleExpanded,\n isDisabled,\n expandedKeys,\n setExpandedKeys,\n toggleKey(key) {\n let keys: Set<Key>;\n if (allowsMultipleExpanded) {\n keys = new Set(expandedKeys);\n if (keys.has(key)) {\n keys.delete(key);\n } else {\n keys.add(key);\n }\n } else {\n keys = new Set(expandedKeys.has(key) ? [] : [key]);\n }\n\n setExpandedKeys(keys);\n }\n };\n}\n"],"names":[],"version":3,"file":"useDisclosureGroupState.module.js.map"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/disclosure",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.5",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/module.js",
|
|
8
8
|
"exports": {
|
|
9
|
-
"
|
|
9
|
+
"source": "./src/index.ts",
|
|
10
|
+
"types": [
|
|
11
|
+
"./dist/types.d.ts",
|
|
12
|
+
"./src/index.ts"
|
|
13
|
+
],
|
|
10
14
|
"import": "./dist/import.mjs",
|
|
11
15
|
"require": "./dist/main.js"
|
|
12
16
|
},
|
|
@@ -22,8 +26,8 @@
|
|
|
22
26
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
27
|
},
|
|
24
28
|
"dependencies": {
|
|
25
|
-
"@react-stately/utils": "^3.10.
|
|
26
|
-
"@react-types/shared": "^3.
|
|
29
|
+
"@react-stately/utils": "^3.10.7",
|
|
30
|
+
"@react-types/shared": "^3.30.0",
|
|
27
31
|
"@swc/helpers": "^0.5.0"
|
|
28
32
|
},
|
|
29
33
|
"peerDependencies": {
|
|
@@ -32,5 +36,5 @@
|
|
|
32
36
|
"publishConfig": {
|
|
33
37
|
"access": "public"
|
|
34
38
|
},
|
|
35
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "265b4d7f107905ee1c6e87a8af1613ab440a6849"
|
|
36
40
|
}
|
|
@@ -33,7 +33,7 @@ export interface DisclosureGroupState {
|
|
|
33
33
|
|
|
34
34
|
/** Whether all items are disabled. */
|
|
35
35
|
readonly isDisabled: boolean,
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
/** A set of keys for items that are expanded. */
|
|
38
38
|
readonly expandedKeys: Set<Key>,
|
|
39
39
|
|
|
@@ -55,11 +55,14 @@ export function useDisclosureGroupState(props: DisclosureGroupProps): Disclosure
|
|
|
55
55
|
useMemo(() => props.defaultExpandedKeys ? new Set(props.defaultExpandedKeys) : new Set(), [props.defaultExpandedKeys]),
|
|
56
56
|
props.onExpandedChange
|
|
57
57
|
);
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
useEffect(() => {
|
|
60
60
|
// Ensure only one item is expanded if allowsMultipleExpanded is false.
|
|
61
61
|
if (!allowsMultipleExpanded && expandedKeys.size > 1) {
|
|
62
|
-
|
|
62
|
+
let firstKey = expandedKeys.values().next().value;
|
|
63
|
+
if (firstKey != null) {
|
|
64
|
+
setExpandedKeys(new Set([firstKey]));
|
|
65
|
+
}
|
|
63
66
|
}
|
|
64
67
|
});
|
|
65
68
|
|
|
@@ -80,7 +83,7 @@ export function useDisclosureGroupState(props: DisclosureGroupProps): Disclosure
|
|
|
80
83
|
} else {
|
|
81
84
|
keys = new Set(expandedKeys.has(key) ? [] : [key]);
|
|
82
85
|
}
|
|
83
|
-
|
|
86
|
+
|
|
84
87
|
setExpandedKeys(keys);
|
|
85
88
|
}
|
|
86
89
|
};
|