@fluentui/react-tree 0.0.0-nightly-20230310-0421.1
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/CHANGELOG.json +86 -0
- package/CHANGELOG.md +24 -0
- package/LICENSE +15 -0
- package/README.md +5 -0
- package/dist/index.d.ts +469 -0
- package/lib/Tree.js +2 -0
- package/lib/Tree.js.map +1 -0
- package/lib/TreeItem.js +2 -0
- package/lib/TreeItem.js.map +1 -0
- package/lib/TreeItemLayout.js +2 -0
- package/lib/TreeItemLayout.js.map +1 -0
- package/lib/TreeItemPersonaLayout.js +2 -0
- package/lib/TreeItemPersonaLayout.js.map +1 -0
- package/lib/components/Tree/Tree.js +21 -0
- package/lib/components/Tree/Tree.js.map +1 -0
- package/lib/components/Tree/Tree.types.js +2 -0
- package/lib/components/Tree/Tree.types.js.map +1 -0
- package/lib/components/Tree/index.js +7 -0
- package/lib/components/Tree/index.js.map +1 -0
- package/lib/components/Tree/renderTree.js +15 -0
- package/lib/components/Tree/renderTree.js.map +1 -0
- package/lib/components/Tree/useTree.js +113 -0
- package/lib/components/Tree/useTree.js.map +1 -0
- package/lib/components/Tree/useTreeContextValues.js +26 -0
- package/lib/components/Tree/useTreeContextValues.js.map +1 -0
- package/lib/components/Tree/useTreeStyles.js +20 -0
- package/lib/components/Tree/useTreeStyles.js.map +1 -0
- package/lib/components/TreeItem/TreeItem.js +16 -0
- package/lib/components/TreeItem/TreeItem.js.map +1 -0
- package/lib/components/TreeItem/TreeItem.types.js +2 -0
- package/lib/components/TreeItem/TreeItem.types.js.map +1 -0
- package/lib/components/TreeItem/index.js +6 -0
- package/lib/components/TreeItem/index.js.map +1 -0
- package/lib/components/TreeItem/renderTreeItem.js +29 -0
- package/lib/components/TreeItem/renderTreeItem.js.map +1 -0
- package/lib/components/TreeItem/useTreeItem.js +250 -0
- package/lib/components/TreeItem/useTreeItem.js.map +1 -0
- package/lib/components/TreeItem/useTreeItemContextValues.js +18 -0
- package/lib/components/TreeItem/useTreeItemContextValues.js.map +1 -0
- package/lib/components/TreeItem/useTreeItemStyles.js +203 -0
- package/lib/components/TreeItem/useTreeItemStyles.js.map +1 -0
- package/lib/components/TreeItemLayout/TreeItemLayout.js +14 -0
- package/lib/components/TreeItemLayout/TreeItemLayout.js.map +1 -0
- package/lib/components/TreeItemLayout/TreeItemLayout.types.js +2 -0
- package/lib/components/TreeItemLayout/TreeItemLayout.types.js.map +1 -0
- package/lib/components/TreeItemLayout/index.js +6 -0
- package/lib/components/TreeItemLayout/index.js.map +1 -0
- package/lib/components/TreeItemLayout/renderTreeItemLayout.js +24 -0
- package/lib/components/TreeItemLayout/renderTreeItemLayout.js.map +1 -0
- package/lib/components/TreeItemLayout/useTreeItemLayout.js +49 -0
- package/lib/components/TreeItemLayout/useTreeItemLayout.js.map +1 -0
- package/lib/components/TreeItemLayout/useTreeItemLayoutStyles.js +98 -0
- package/lib/components/TreeItemLayout/useTreeItemLayoutStyles.js.map +1 -0
- package/lib/components/TreeItemPersonaLayout/TreeItemPersonaLayout.js +16 -0
- package/lib/components/TreeItemPersonaLayout/TreeItemPersonaLayout.js.map +1 -0
- package/lib/components/TreeItemPersonaLayout/TreeItemPersonaLayout.types.js +2 -0
- package/lib/components/TreeItemPersonaLayout/TreeItemPersonaLayout.types.js.map +1 -0
- package/lib/components/TreeItemPersonaLayout/index.js +6 -0
- package/lib/components/TreeItemPersonaLayout/index.js.map +1 -0
- package/lib/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.js +31 -0
- package/lib/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.js.map +1 -0
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayout.js +58 -0
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayout.js.map +1 -0
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutContextValues.js +13 -0
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutContextValues.js.map +1 -0
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.js +115 -0
- package/lib/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.js.map +1 -0
- package/lib/contexts/index.js +3 -0
- package/lib/contexts/index.js.map +1 -0
- package/lib/contexts/treeContext.js +19 -0
- package/lib/contexts/treeContext.js.map +1 -0
- package/lib/contexts/treeItemContext.js +13 -0
- package/lib/contexts/treeItemContext.js.map +1 -0
- package/lib/hooks/index.js +4 -0
- package/lib/hooks/index.js.map +1 -0
- package/lib/hooks/useFlatTreeItems.js +134 -0
- package/lib/hooks/useFlatTreeItems.js.map +1 -0
- package/lib/hooks/useFlatTreeNavigation.js +74 -0
- package/lib/hooks/useFlatTreeNavigation.js.map +1 -0
- package/lib/hooks/useHTMLElementWalker.js +80 -0
- package/lib/hooks/useHTMLElementWalker.js.map +1 -0
- package/lib/hooks/useNestedTreeNavigation.js +59 -0
- package/lib/hooks/useNestedTreeNavigation.js.map +1 -0
- package/lib/hooks/useOpenItemsState.js +22 -0
- package/lib/hooks/useOpenItemsState.js.map +1 -0
- package/lib/hooks/useRovingTabIndexes.js +53 -0
- package/lib/hooks/useRovingTabIndexes.js.map +1 -0
- package/lib/index.js +9 -0
- package/lib/index.js.map +1 -0
- package/lib/utils/ImmutableSet.js +37 -0
- package/lib/utils/ImmutableSet.js.map +1 -0
- package/lib/utils/assert.js +7 -0
- package/lib/utils/assert.js.map +1 -0
- package/lib/utils/flattenTree.js +32 -0
- package/lib/utils/flattenTree.js.map +1 -0
- package/lib/utils/nextTypeAheadElement.js +14 -0
- package/lib/utils/nextTypeAheadElement.js.map +1 -0
- package/lib/utils/normalizeOpenItems.js +7 -0
- package/lib/utils/normalizeOpenItems.js.map +1 -0
- package/lib/utils/tokens.js +19 -0
- package/lib/utils/tokens.js.map +1 -0
- package/lib/utils/treeItemFilter.js +4 -0
- package/lib/utils/treeItemFilter.js.map +1 -0
- package/lib-commonjs/Tree.js +8 -0
- package/lib-commonjs/Tree.js.map +1 -0
- package/lib-commonjs/TreeItem.js +8 -0
- package/lib-commonjs/TreeItem.js.map +1 -0
- package/lib-commonjs/TreeItemLayout.js +8 -0
- package/lib-commonjs/TreeItemLayout.js.map +1 -0
- package/lib-commonjs/TreeItemPersonaLayout.js +8 -0
- package/lib-commonjs/TreeItemPersonaLayout.js.map +1 -0
- package/lib-commonjs/components/Tree/Tree.js +27 -0
- package/lib-commonjs/components/Tree/Tree.js.map +1 -0
- package/lib-commonjs/components/Tree/Tree.types.js +6 -0
- package/lib-commonjs/components/Tree/Tree.types.js.map +1 -0
- package/lib-commonjs/components/Tree/index.js +13 -0
- package/lib-commonjs/components/Tree/index.js.map +1 -0
- package/lib-commonjs/components/Tree/renderTree.js +22 -0
- package/lib-commonjs/components/Tree/renderTree.js.map +1 -0
- package/lib-commonjs/components/Tree/useTree.js +120 -0
- package/lib-commonjs/components/Tree/useTree.js.map +1 -0
- package/lib-commonjs/components/Tree/useTreeContextValues.js +33 -0
- package/lib-commonjs/components/Tree/useTreeContextValues.js.map +1 -0
- package/lib-commonjs/components/Tree/useTreeStyles.js +27 -0
- package/lib-commonjs/components/Tree/useTreeStyles.js.map +1 -0
- package/lib-commonjs/components/TreeItem/TreeItem.js +22 -0
- package/lib-commonjs/components/TreeItem/TreeItem.js.map +1 -0
- package/lib-commonjs/components/TreeItem/TreeItem.types.js +7 -0
- package/lib-commonjs/components/TreeItem/TreeItem.types.js.map +1 -0
- package/lib-commonjs/components/TreeItem/index.js +12 -0
- package/lib-commonjs/components/TreeItem/index.js.map +1 -0
- package/lib-commonjs/components/TreeItem/renderTreeItem.js +36 -0
- package/lib-commonjs/components/TreeItem/renderTreeItem.js.map +1 -0
- package/lib-commonjs/components/TreeItem/useTreeItem.js +257 -0
- package/lib-commonjs/components/TreeItem/useTreeItem.js.map +1 -0
- package/lib-commonjs/components/TreeItem/useTreeItemContextValues.js +25 -0
- package/lib-commonjs/components/TreeItem/useTreeItemContextValues.js.map +1 -0
- package/lib-commonjs/components/TreeItem/useTreeItemStyles.js +210 -0
- package/lib-commonjs/components/TreeItem/useTreeItemStyles.js.map +1 -0
- package/lib-commonjs/components/TreeItemLayout/TreeItemLayout.js +20 -0
- package/lib-commonjs/components/TreeItemLayout/TreeItemLayout.js.map +1 -0
- package/lib-commonjs/components/TreeItemLayout/TreeItemLayout.types.js +6 -0
- package/lib-commonjs/components/TreeItemLayout/TreeItemLayout.types.js.map +1 -0
- package/lib-commonjs/components/TreeItemLayout/index.js +12 -0
- package/lib-commonjs/components/TreeItemLayout/index.js.map +1 -0
- package/lib-commonjs/components/TreeItemLayout/renderTreeItemLayout.js +31 -0
- package/lib-commonjs/components/TreeItemLayout/renderTreeItemLayout.js.map +1 -0
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayout.js +56 -0
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayout.js.map +1 -0
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayoutStyles.js +105 -0
- package/lib-commonjs/components/TreeItemLayout/useTreeItemLayoutStyles.js.map +1 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/TreeItemPersonaLayout.js +22 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/TreeItemPersonaLayout.js.map +1 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/TreeItemPersonaLayout.types.js +6 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/TreeItemPersonaLayout.types.js.map +1 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/index.js +12 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/index.js.map +1 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.js +38 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/renderTreeItemPersonaLayout.js.map +1 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayout.js +65 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayout.js.map +1 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutContextValues.js +20 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutContextValues.js.map +1 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.js +122 -0
- package/lib-commonjs/components/TreeItemPersonaLayout/useTreeItemPersonaLayoutStyles.js.map +1 -0
- package/lib-commonjs/contexts/index.js +9 -0
- package/lib-commonjs/contexts/index.js.map +1 -0
- package/lib-commonjs/contexts/treeContext.js +24 -0
- package/lib-commonjs/contexts/treeContext.js.map +1 -0
- package/lib-commonjs/contexts/treeItemContext.js +18 -0
- package/lib-commonjs/contexts/treeItemContext.js.map +1 -0
- package/lib-commonjs/hooks/index.js +10 -0
- package/lib-commonjs/hooks/index.js.map +1 -0
- package/lib-commonjs/hooks/useFlatTreeItems.js +141 -0
- package/lib-commonjs/hooks/useFlatTreeItems.js.map +1 -0
- package/lib-commonjs/hooks/useFlatTreeNavigation.js +81 -0
- package/lib-commonjs/hooks/useFlatTreeNavigation.js.map +1 -0
- package/lib-commonjs/hooks/useHTMLElementWalker.js +88 -0
- package/lib-commonjs/hooks/useHTMLElementWalker.js.map +1 -0
- package/lib-commonjs/hooks/useNestedTreeNavigation.js +66 -0
- package/lib-commonjs/hooks/useNestedTreeNavigation.js.map +1 -0
- package/lib-commonjs/hooks/useOpenItemsState.js +29 -0
- package/lib-commonjs/hooks/useOpenItemsState.js.map +1 -0
- package/lib-commonjs/hooks/useRovingTabIndexes.js +60 -0
- package/lib-commonjs/hooks/useRovingTabIndexes.js.map +1 -0
- package/lib-commonjs/index.js +183 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/utils/ImmutableSet.js +45 -0
- package/lib-commonjs/utils/ImmutableSet.js.map +1 -0
- package/lib-commonjs/utils/assert.js +14 -0
- package/lib-commonjs/utils/assert.js.map +1 -0
- package/lib-commonjs/utils/flattenTree.js +38 -0
- package/lib-commonjs/utils/flattenTree.js.map +1 -0
- package/lib-commonjs/utils/nextTypeAheadElement.js +21 -0
- package/lib-commonjs/utils/nextTypeAheadElement.js.map +1 -0
- package/lib-commonjs/utils/normalizeOpenItems.js +14 -0
- package/lib-commonjs/utils/normalizeOpenItems.js.map +1 -0
- package/lib-commonjs/utils/tokens.js +25 -0
- package/lib-commonjs/utils/tokens.js.map +1 -0
- package/lib-commonjs/utils/treeItemFilter.js +11 -0
- package/lib-commonjs/utils/treeItemFilter.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useTreeContextValues_unstable = void 0;
|
|
7
|
+
function useTreeContextValues_unstable(state) {
|
|
8
|
+
const {
|
|
9
|
+
openItems,
|
|
10
|
+
level,
|
|
11
|
+
appearance,
|
|
12
|
+
size,
|
|
13
|
+
requestOpenChange,
|
|
14
|
+
requestNavigation
|
|
15
|
+
} = state;
|
|
16
|
+
/**
|
|
17
|
+
* This context is created with "@fluentui/react-context-selector",
|
|
18
|
+
* there is no sense to memoize it
|
|
19
|
+
*/
|
|
20
|
+
const tree = {
|
|
21
|
+
appearance,
|
|
22
|
+
size,
|
|
23
|
+
level,
|
|
24
|
+
openItems,
|
|
25
|
+
requestOpenChange,
|
|
26
|
+
requestNavigation
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
tree
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.useTreeContextValues_unstable = useTreeContextValues_unstable;
|
|
33
|
+
//# sourceMappingURL=useTreeContextValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useTreeContextValues_unstable","state","openItems","level","appearance","size","requestOpenChange","requestNavigation","tree","exports"],"sources":["../../../../../../../../../packages/react-components/react-tree/src/components/Tree/useTreeContextValues.ts"],"sourcesContent":["import { TreeContextValue } from '../../contexts';\nimport type { TreeContextValues, TreeState } from './Tree.types';\n\nexport function useTreeContextValues_unstable(state: TreeState): TreeContextValues {\n const { openItems, level, appearance, size, requestOpenChange, requestNavigation } = state;\n /**\n * This context is created with \"@fluentui/react-context-selector\",\n * there is no sense to memoize it\n */\n const tree: TreeContextValue = {\n appearance,\n size,\n level,\n openItems,\n requestOpenChange,\n requestNavigation,\n };\n\n return { tree };\n}\n"],"mappings":";;;;;;AAGA,SAAgBA,6BAA6BA,CAACC,KAAgB;EAC5D,MAAM;IAAEC,SAAS;IAAEC,KAAK;IAAEC,UAAU;IAAEC,IAAI;IAAEC,iBAAiB;IAAEC;EAAiB,CAAE,GAAGN,KAAK;EAC1F;;;;EAIA,MAAMO,IAAI,GAAqB;IAC7BJ,UAAU;IACVC,IAAI;IACJF,KAAK;IACLD,SAAS;IACTI,iBAAiB;IACjBC;GACD;EAED,OAAO;IAAEC;EAAI,CAAE;AACjB;AAhBAC,OAAA,CAAAT,6BAAA,GAAAA,6BAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useTreeStyles_unstable = exports.treeClassNames = void 0;
|
|
7
|
+
const react_1 = /*#__PURE__*/require("@griffel/react");
|
|
8
|
+
const react_theme_1 = /*#__PURE__*/require("@fluentui/react-theme");
|
|
9
|
+
exports.treeClassNames = {
|
|
10
|
+
root: 'fui-Tree'
|
|
11
|
+
};
|
|
12
|
+
const useStyles = /*#__PURE__*/react_1.__styles({
|
|
13
|
+
root: {
|
|
14
|
+
mc9l5x: "f22iagw",
|
|
15
|
+
Beiy3e4: "f1vx9l62",
|
|
16
|
+
Belr9w4: "f1j0q4x9"
|
|
17
|
+
}
|
|
18
|
+
}, {
|
|
19
|
+
d: [".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".f1vx9l62{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}", ".f1j0q4x9{row-gap:var(--spacingVerticalXXS);}"]
|
|
20
|
+
});
|
|
21
|
+
const useTreeStyles_unstable = state => {
|
|
22
|
+
const styles = useStyles();
|
|
23
|
+
state.root.className = react_1.mergeClasses(exports.treeClassNames.root, styles.root, state.root.className);
|
|
24
|
+
return state;
|
|
25
|
+
};
|
|
26
|
+
exports.useTreeStyles_unstable = useTreeStyles_unstable;
|
|
27
|
+
//# sourceMappingURL=useTreeStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["react_1","require","react_theme_1","exports","treeClassNames","root","useStyles","__styles","mc9l5x","Beiy3e4","Belr9w4","d","useTreeStyles_unstable","state","styles","className","mergeClasses"],"sources":["../../../../../../../../../packages/react-components/react-tree/src/components/Tree/useTreeStyles.ts"],"sourcesContent":["import { makeStyles, mergeClasses } from '@griffel/react';\nimport type { TreeSlots, TreeState } from './Tree.types';\nimport type { SlotClassNames } from '@fluentui/react-utilities';\nimport { tokens } from '@fluentui/react-theme';\n\nexport const treeClassNames: SlotClassNames<TreeSlots> = {\n root: 'fui-Tree',\n};\n\nconst useStyles = makeStyles({\n root: {\n display: 'flex',\n flexDirection: 'column',\n rowGap: tokens.spacingVerticalXXS,\n },\n});\n\nexport const useTreeStyles_unstable = (state: TreeState): TreeState => {\n const styles = useStyles();\n state.root.className = mergeClasses(treeClassNames.root, styles.root, state.root.className);\n\n return state;\n};\n"],"mappings":";;;;;;AAAA,MAAAA,OAAA,gBAAAC,OAAA;AAGA,MAAAC,aAAA,gBAAAD,OAAA;AAEaE,OAAA,CAAAC,cAAc,GAA8B;EACvDC,IAAI,EAAE;CACP;AAED,MAAMC,SAAS,gBAAGN,OAAA,CAAAO,QAAU;EAAAF,IAAA;IAAAG,MAAA;IAAAC,OAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;AAAA,EAM1B;AAEK,MAAMC,sBAAsB,GAAIC,KAAgB,IAAe;EACpE,MAAMC,MAAM,GAAGR,SAAS,EAAE;EAC1BO,KAAK,CAACR,IAAI,CAACU,SAAS,GAAGf,OAAA,CAAAgB,YAAY,CAACb,OAAA,CAAAC,cAAc,CAACC,IAAI,EAAES,MAAM,CAACT,IAAI,EAAEQ,KAAK,CAACR,IAAI,CAACU,SAAS,CAAC;EAE3F,OAAOF,KAAK;AACd,CAAC;AALYV,OAAA,CAAAS,sBAAsB,GAAAA,sBAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TreeItem = void 0;
|
|
7
|
+
const React = /*#__PURE__*/require("react");
|
|
8
|
+
const useTreeItem_1 = /*#__PURE__*/require("./useTreeItem");
|
|
9
|
+
const renderTreeItem_1 = /*#__PURE__*/require("./renderTreeItem");
|
|
10
|
+
const useTreeItemStyles_1 = /*#__PURE__*/require("./useTreeItemStyles");
|
|
11
|
+
const useTreeItemContextValues_1 = /*#__PURE__*/require("./useTreeItemContextValues");
|
|
12
|
+
/**
|
|
13
|
+
* TreeItem component - TODO: add more docs
|
|
14
|
+
*/
|
|
15
|
+
exports.TreeItem = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
16
|
+
const state = useTreeItem_1.useTreeItem_unstable(props, ref);
|
|
17
|
+
useTreeItemStyles_1.useTreeItemStyles_unstable(state);
|
|
18
|
+
const contextValues = useTreeItemContextValues_1.useTreeItemContextValues_unstable(state);
|
|
19
|
+
return renderTreeItem_1.renderTreeItem_unstable(state, contextValues);
|
|
20
|
+
});
|
|
21
|
+
exports.TreeItem.displayName = 'TreeItem';
|
|
22
|
+
//# sourceMappingURL=TreeItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","require","useTreeItem_1","renderTreeItem_1","useTreeItemStyles_1","useTreeItemContextValues_1","exports","TreeItem","forwardRef","props","ref","state","useTreeItem_unstable","useTreeItemStyles_unstable","contextValues","useTreeItemContextValues_unstable","renderTreeItem_unstable","displayName"],"sources":["../../../../../../../../../packages/react-components/react-tree/src/components/TreeItem/TreeItem.tsx"],"sourcesContent":["import * as React from 'react';\nimport { useTreeItem_unstable } from './useTreeItem';\nimport { renderTreeItem_unstable } from './renderTreeItem';\nimport { useTreeItemStyles_unstable } from './useTreeItemStyles';\nimport type { TreeItemProps } from './TreeItem.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useTreeItemContextValues_unstable } from './useTreeItemContextValues';\n\n/**\n * TreeItem component - TODO: add more docs\n */\nexport const TreeItem: ForwardRefComponent<TreeItemProps> = React.forwardRef((props, ref) => {\n const state = useTreeItem_unstable(props, ref);\n\n useTreeItemStyles_unstable(state);\n const contextValues = useTreeItemContextValues_unstable(state);\n return renderTreeItem_unstable(state, contextValues);\n});\n\nTreeItem.displayName = 'TreeItem';\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,aAAA,gBAAAD,OAAA;AACA,MAAAE,gBAAA,gBAAAF,OAAA;AACA,MAAAG,mBAAA,gBAAAH,OAAA;AAGA,MAAAI,0BAAA,gBAAAJ,OAAA;AAEA;;;AAGaK,OAAA,CAAAC,QAAQ,gBAAuCP,KAAK,CAACQ,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EAC1F,MAAMC,KAAK,GAAGT,aAAA,CAAAU,oBAAoB,CAACH,KAAK,EAAEC,GAAG,CAAC;EAE9CN,mBAAA,CAAAS,0BAA0B,CAACF,KAAK,CAAC;EACjC,MAAMG,aAAa,GAAGT,0BAAA,CAAAU,iCAAiC,CAACJ,KAAK,CAAC;EAC9D,OAAOR,gBAAA,CAAAa,uBAAuB,CAACL,KAAK,EAAEG,aAAa,CAAC;AACtD,CAAC,CAAC;AAEFR,OAAA,CAAAC,QAAQ,CAACU,WAAW,GAAG,UAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["tokens_1","require"],"sources":["../../../../../../../../../packages/react-components/react-tree/src/components/TreeItem/TreeItem.types.ts"],"sourcesContent":["import type { ComponentProps, ComponentState, ExtractSlotProps, Slot } from '@fluentui/react-utilities';\nimport type { ButtonContextValue } from '@fluentui/react-button';\nimport type { TreeItemContextValue } from '../../contexts';\nimport { treeItemLevelToken } from '../../utils/tokens';\nimport * as React from 'react';\n\nexport type TreeItemCSSProperties = React.CSSProperties & { [treeItemLevelToken]?: string | number };\n\nexport type TreeItemSlots = {\n root: Slot<ExtractSlotProps<Slot<'div'> & { style?: TreeItemCSSProperties }>>;\n content: NonNullable<Slot<'div'>>;\n subtree?: Slot<'span'>;\n /**\n * Expand icon slot,\n * by default renders a chevron icon to indicate opening and closing\n */\n expandIcon?: Slot<'span'>;\n /**\n * Actions slot that renders on the end of tree item\n * when the item is hovered/focused\n */\n actions?: Slot<'span'>;\n};\n\nexport type TreeItemContextValues = {\n treeItem: TreeItemContextValue;\n button: ButtonContextValue;\n};\n\n/**\n * TreeItem Props\n */\nexport type TreeItemProps = ComponentProps<Partial<TreeItemSlots>> & {\n /**\n * If a TreeItem is a leaf, it'll not present the `expandIcon` slot by default.\n * This attribute is used to force the decision if a TreeItem is a leaf or not. By not providing this property\n * this will be inferred by the presence of a subtree as part of the TreeItem children.\n */\n leaf?: boolean;\n};\n\n/**\n * State used in rendering TreeItem\n */\nexport type TreeItemState = ComponentState<TreeItemSlots> & {\n open: boolean;\n isLeaf: boolean;\n level: number;\n /**\n * By design, a button included on the actions slot should be small\n */\n buttonSize: 'small';\n isActionsVisible: boolean;\n};\n"],"mappings":";;;;;AAGA,MAAAA,QAAA,gBAAAC,OAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
|
7
|
+
tslib_1.__exportStar(require("./TreeItem"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./TreeItem.types"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./renderTreeItem"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./useTreeItem"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./useTreeItemStyles"), exports);
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["tslib_1","__exportStar","require","exports"],"sources":["../../../../../../../../../packages/react-components/react-tree/src/components/TreeItem/index.ts"],"sourcesContent":["export * from './TreeItem';\nexport * from './TreeItem.types';\nexport * from './renderTreeItem';\nexport * from './useTreeItem';\nexport * from './useTreeItemStyles';\n"],"mappings":";;;;;;AAAAA,OAAA,CAAAC,YAAA,CAAAC,OAAA,gBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,sBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,sBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,mBAAAC,OAAA;AACAH,OAAA,CAAAC,YAAA,CAAAC,OAAA,yBAAAC,OAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.renderTreeItem_unstable = void 0;
|
|
7
|
+
const React = /*#__PURE__*/require("react");
|
|
8
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
9
|
+
const contexts_1 = /*#__PURE__*/require("../../contexts");
|
|
10
|
+
const react_button_1 = /*#__PURE__*/require("@fluentui/react-button");
|
|
11
|
+
/**
|
|
12
|
+
* Render the final JSX of TreeItem
|
|
13
|
+
*/
|
|
14
|
+
const renderTreeItem_unstable = (state, contextValues) => {
|
|
15
|
+
const {
|
|
16
|
+
slots,
|
|
17
|
+
slotProps
|
|
18
|
+
} = react_utilities_1.getSlots(state);
|
|
19
|
+
return React.createElement(contexts_1.TreeItemProvider, {
|
|
20
|
+
value: contextValues.treeItem
|
|
21
|
+
}, React.createElement(slots.root, {
|
|
22
|
+
...slotProps.root
|
|
23
|
+
}, React.createElement(slots.content, {
|
|
24
|
+
...slotProps.content
|
|
25
|
+
}, slots.expandIcon && React.createElement(slots.expandIcon, {
|
|
26
|
+
...slotProps.expandIcon
|
|
27
|
+
}), slotProps.content.children, React.createElement(react_button_1.ButtonContextProvider, {
|
|
28
|
+
value: contextValues.button
|
|
29
|
+
}, slots.actions && React.createElement(slots.actions, {
|
|
30
|
+
...slotProps.actions
|
|
31
|
+
}))), state.open && slots.subtree && React.createElement(slots.subtree, {
|
|
32
|
+
...slotProps.subtree
|
|
33
|
+
})));
|
|
34
|
+
};
|
|
35
|
+
exports.renderTreeItem_unstable = renderTreeItem_unstable;
|
|
36
|
+
//# sourceMappingURL=renderTreeItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","require","react_utilities_1","contexts_1","react_button_1","renderTreeItem_unstable","state","contextValues","slots","slotProps","getSlots","createElement","TreeItemProvider","value","treeItem","root","content","expandIcon","children","ButtonContextProvider","button","actions","open","subtree","exports"],"sources":["../../../../../../../../../packages/react-components/react-tree/src/components/TreeItem/renderTreeItem.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { TreeItemState, TreeItemSlots, TreeItemContextValues } from './TreeItem.types';\nimport { TreeItemProvider } from '../../contexts';\nimport { ButtonContextProvider } from '@fluentui/react-button';\n\n/**\n * Render the final JSX of TreeItem\n */\nexport const renderTreeItem_unstable = (state: TreeItemState, contextValues: TreeItemContextValues) => {\n const { slots, slotProps } = getSlots<TreeItemSlots>(state);\n\n return (\n <TreeItemProvider value={contextValues.treeItem}>\n <slots.root {...slotProps.root}>\n <slots.content {...slotProps.content}>\n {slots.expandIcon && <slots.expandIcon {...slotProps.expandIcon} />}\n {slotProps.content.children}\n <ButtonContextProvider value={contextValues.button}>\n {slots.actions && <slots.actions {...slotProps.actions} />}\n </ButtonContextProvider>\n </slots.content>\n {state.open && slots.subtree && <slots.subtree {...slotProps.subtree} />}\n </slots.root>\n </TreeItemProvider>\n );\n};\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,iBAAA,gBAAAD,OAAA;AAEA,MAAAE,UAAA,gBAAAF,OAAA;AACA,MAAAG,cAAA,gBAAAH,OAAA;AAEA;;;AAGO,MAAMI,uBAAuB,GAAGA,CAACC,KAAoB,EAAEC,aAAoC,KAAI;EACpG,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGP,iBAAA,CAAAQ,QAAQ,CAAgBJ,KAAK,CAAC;EAE3D,OACEN,KAAA,CAAAW,aAAA,CAACR,UAAA,CAAAS,gBAAgB;IAACC,KAAK,EAAEN,aAAa,CAACO;EAAQ,GAC7Cd,KAAA,CAAAW,aAAA,CAACH,KAAK,CAACO,IAAI;IAAA,GAAKN,SAAS,CAACM;EAAI,GAC5Bf,KAAA,CAAAW,aAAA,CAACH,KAAK,CAACQ,OAAO;IAAA,GAAKP,SAAS,CAACO;EAAO,GACjCR,KAAK,CAACS,UAAU,IAAIjB,KAAA,CAAAW,aAAA,CAACH,KAAK,CAACS,UAAU;IAAA,GAAKR,SAAS,CAACQ;EAAU,EAAI,EAClER,SAAS,CAACO,OAAO,CAACE,QAAQ,EAC3BlB,KAAA,CAAAW,aAAA,CAACP,cAAA,CAAAe,qBAAqB;IAACN,KAAK,EAAEN,aAAa,CAACa;EAAM,GAC/CZ,KAAK,CAACa,OAAO,IAAIrB,KAAA,CAAAW,aAAA,CAACH,KAAK,CAACa,OAAO;IAAA,GAAKZ,SAAS,CAACY;EAAO,EAAI,CACpC,CACV,EACff,KAAK,CAACgB,IAAI,IAAId,KAAK,CAACe,OAAO,IAAIvB,KAAA,CAAAW,aAAA,CAACH,KAAK,CAACe,OAAO;IAAA,GAAKd,SAAS,CAACc;EAAO,EAAI,CAC7D,CACI;AAEvB,CAAC;AAjBYC,OAAA,CAAAnB,uBAAuB,GAAAA,uBAAA"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useTreeItem_unstable = void 0;
|
|
7
|
+
const React = /*#__PURE__*/require("react");
|
|
8
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
9
|
+
const react_icons_1 = /*#__PURE__*/require("@fluentui/react-icons");
|
|
10
|
+
const react_shared_contexts_1 = /*#__PURE__*/require("@fluentui/react-shared-contexts");
|
|
11
|
+
const react_utilities_2 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
12
|
+
const useTreeItemStyles_1 = /*#__PURE__*/require("./useTreeItemStyles");
|
|
13
|
+
const keyboard_keys_1 = /*#__PURE__*/require("@fluentui/keyboard-keys");
|
|
14
|
+
const react_utilities_3 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
15
|
+
const react_portal_1 = /*#__PURE__*/require("@fluentui/react-portal");
|
|
16
|
+
const index_1 = /*#__PURE__*/require("../../contexts/index");
|
|
17
|
+
const tokens_1 = /*#__PURE__*/require("../../utils/tokens");
|
|
18
|
+
/**
|
|
19
|
+
* Create the state required to render TreeItem.
|
|
20
|
+
*
|
|
21
|
+
* The returned state can be modified with hooks such as useTreeItemStyles_unstable,
|
|
22
|
+
* before being passed to renderTreeItem_unstable.
|
|
23
|
+
*
|
|
24
|
+
* @param props - props from this instance of TreeItem
|
|
25
|
+
* @param ref - reference to root HTMLElement of TreeItem
|
|
26
|
+
*/
|
|
27
|
+
const useTreeItem_unstable = (props, ref) => {
|
|
28
|
+
const [children, subtreeChildren] = React.Children.toArray(props.children);
|
|
29
|
+
const contextLevel = index_1.useTreeContext_unstable(ctx => ctx.level);
|
|
30
|
+
const {
|
|
31
|
+
content,
|
|
32
|
+
subtree,
|
|
33
|
+
expandIcon,
|
|
34
|
+
leaf: isLeaf = subtreeChildren === undefined,
|
|
35
|
+
actions,
|
|
36
|
+
as = 'div',
|
|
37
|
+
onClick,
|
|
38
|
+
onKeyDown,
|
|
39
|
+
['aria-level']: level = contextLevel,
|
|
40
|
+
...rest
|
|
41
|
+
} = props;
|
|
42
|
+
const requestOpenChange = index_1.useTreeContext_unstable(ctx => ctx.requestOpenChange);
|
|
43
|
+
const requestNavigation = index_1.useTreeContext_unstable(ctx => ctx.requestNavigation);
|
|
44
|
+
const id = react_utilities_1.useId('fui-TreeItem-', props.id);
|
|
45
|
+
const isBranch = !isLeaf;
|
|
46
|
+
const open = index_1.useTreeContext_unstable(ctx => isBranch && ctx.openItems.has(id));
|
|
47
|
+
const {
|
|
48
|
+
dir,
|
|
49
|
+
targetDocument
|
|
50
|
+
} = react_shared_contexts_1.useFluent_unstable();
|
|
51
|
+
const expandIconRotation = open ? 90 : dir !== 'rtl' ? 0 : 180;
|
|
52
|
+
const actionsRef = React.useRef(null);
|
|
53
|
+
const expandIconRef = React.useRef(null);
|
|
54
|
+
const subtreeRef = React.useRef(null);
|
|
55
|
+
const handleArrowRight = event => {
|
|
56
|
+
if (!open && isBranch) {
|
|
57
|
+
return requestOpenChange({
|
|
58
|
+
event,
|
|
59
|
+
open: true,
|
|
60
|
+
type: tokens_1.treeDataTypes.arrowRight,
|
|
61
|
+
target: event.currentTarget
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (open && isBranch) {
|
|
65
|
+
return requestNavigation({
|
|
66
|
+
event,
|
|
67
|
+
type: tokens_1.treeDataTypes.arrowRight,
|
|
68
|
+
target: event.currentTarget
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const handleArrowLeft = event => {
|
|
73
|
+
if (open && isBranch) {
|
|
74
|
+
return requestOpenChange({
|
|
75
|
+
event,
|
|
76
|
+
open: false,
|
|
77
|
+
type: tokens_1.treeDataTypes.arrowLeft,
|
|
78
|
+
target: event.currentTarget
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (!open && level > 1) {
|
|
82
|
+
return requestNavigation({
|
|
83
|
+
event,
|
|
84
|
+
target: event.currentTarget,
|
|
85
|
+
type: tokens_1.treeDataTypes.arrowLeft
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const handleEnter = event => {
|
|
90
|
+
requestOpenChange({
|
|
91
|
+
event,
|
|
92
|
+
open: isLeaf ? open : !open,
|
|
93
|
+
type: tokens_1.treeDataTypes.enter,
|
|
94
|
+
target: event.currentTarget
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
const handleClick = react_utilities_2.useEventCallback(event => {
|
|
98
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
99
|
+
const isEventFromActions = actionsRef.current && react_portal_1.elementContains(actionsRef.current, event.target);
|
|
100
|
+
if (isEventFromActions) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const isEventFromSubtree = subtreeRef.current && react_portal_1.elementContains(subtreeRef.current, event.target);
|
|
104
|
+
if (isEventFromSubtree) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const isFromExpandIcon = expandIconRef.current && react_portal_1.elementContains(expandIconRef.current, event.target);
|
|
108
|
+
requestOpenChange({
|
|
109
|
+
event,
|
|
110
|
+
open: isLeaf ? open : !open,
|
|
111
|
+
type: isFromExpandIcon ? tokens_1.treeDataTypes.expandIconClick : tokens_1.treeDataTypes.click,
|
|
112
|
+
target: event.currentTarget
|
|
113
|
+
});
|
|
114
|
+
requestNavigation({
|
|
115
|
+
event,
|
|
116
|
+
target: event.currentTarget,
|
|
117
|
+
type: tokens_1.treeDataTypes.click
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
const handleKeyDown = react_utilities_2.useEventCallback(event => {
|
|
121
|
+
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event);
|
|
122
|
+
if (event.currentTarget !== event.target) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (event.isDefaultPrevented()) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
switch (event.key) {
|
|
129
|
+
case keyboard_keys_1.Enter:
|
|
130
|
+
return handleEnter(event);
|
|
131
|
+
case keyboard_keys_1.ArrowRight:
|
|
132
|
+
return handleArrowRight(event);
|
|
133
|
+
case keyboard_keys_1.ArrowLeft:
|
|
134
|
+
return handleArrowLeft(event);
|
|
135
|
+
case keyboard_keys_1.End:
|
|
136
|
+
return requestNavigation({
|
|
137
|
+
event,
|
|
138
|
+
type: tokens_1.treeDataTypes.end,
|
|
139
|
+
target: event.currentTarget
|
|
140
|
+
});
|
|
141
|
+
case keyboard_keys_1.Home:
|
|
142
|
+
return requestNavigation({
|
|
143
|
+
event,
|
|
144
|
+
type: tokens_1.treeDataTypes.home,
|
|
145
|
+
target: event.currentTarget
|
|
146
|
+
});
|
|
147
|
+
case keyboard_keys_1.ArrowUp:
|
|
148
|
+
return requestNavigation({
|
|
149
|
+
event,
|
|
150
|
+
type: tokens_1.treeDataTypes.arrowUp,
|
|
151
|
+
target: event.currentTarget
|
|
152
|
+
});
|
|
153
|
+
case keyboard_keys_1.ArrowDown:
|
|
154
|
+
return requestNavigation({
|
|
155
|
+
event,
|
|
156
|
+
type: tokens_1.treeDataTypes.arrowDown,
|
|
157
|
+
target: event.currentTarget
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
const isTypeAheadCharacter = event.key.length === 1 && event.key.match(/\w/) && !event.altKey && !event.ctrlKey && !event.metaKey;
|
|
161
|
+
if (isTypeAheadCharacter) {
|
|
162
|
+
return requestNavigation({
|
|
163
|
+
event,
|
|
164
|
+
target: event.currentTarget,
|
|
165
|
+
type: tokens_1.treeDataTypes.typeAhead
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
const [isActionsVisible, setActionsVisible] = React.useState(false);
|
|
170
|
+
const showActions = react_utilities_2.useEventCallback(event => {
|
|
171
|
+
const isEventFromSubtree = subtreeRef.current && react_portal_1.elementContains(subtreeRef.current, event.target);
|
|
172
|
+
if (!isEventFromSubtree) {
|
|
173
|
+
setActionsVisible(true);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
const hideActions = react_utilities_2.useEventCallback(event => {
|
|
177
|
+
const isEventFromSubtree = subtreeRef.current && react_portal_1.elementContains(subtreeRef.current, event.target);
|
|
178
|
+
if (!isEventFromSubtree) {
|
|
179
|
+
setActionsVisible(false);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
// Listens to focusout event on the document to ensure treeitem actions visibility on portal scenarios
|
|
183
|
+
// TODO: find a better way to ensure this behavior
|
|
184
|
+
React.useEffect(() => {
|
|
185
|
+
if (actionsRef.current) {
|
|
186
|
+
const handleFocusOut = event => {
|
|
187
|
+
setActionsVisible(react_portal_1.elementContains(actionsRef.current, event.relatedTarget));
|
|
188
|
+
};
|
|
189
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.addEventListener('focusout', handleFocusOut, {
|
|
190
|
+
passive: true
|
|
191
|
+
});
|
|
192
|
+
return () => {
|
|
193
|
+
targetDocument === null || targetDocument === void 0 ? void 0 : targetDocument.removeEventListener('focusout', handleFocusOut);
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}, [targetDocument]);
|
|
197
|
+
return {
|
|
198
|
+
isLeaf,
|
|
199
|
+
open,
|
|
200
|
+
level,
|
|
201
|
+
buttonSize: 'small',
|
|
202
|
+
isActionsVisible: actions ? isActionsVisible : false,
|
|
203
|
+
components: {
|
|
204
|
+
content: 'div',
|
|
205
|
+
root: 'div',
|
|
206
|
+
expandIcon: 'span',
|
|
207
|
+
actions: 'span',
|
|
208
|
+
subtree: 'span'
|
|
209
|
+
},
|
|
210
|
+
subtree: react_utilities_1.resolveShorthand(subtree, {
|
|
211
|
+
required: Boolean(subtreeChildren),
|
|
212
|
+
defaultProps: {
|
|
213
|
+
children: subtreeChildren,
|
|
214
|
+
ref: react_utilities_3.useMergedRefs(subtreeRef, react_utilities_1.isResolvedShorthand(subtree) ? subtree.ref : undefined)
|
|
215
|
+
}
|
|
216
|
+
}),
|
|
217
|
+
content: react_utilities_1.resolveShorthand(content, {
|
|
218
|
+
required: true,
|
|
219
|
+
defaultProps: {
|
|
220
|
+
children
|
|
221
|
+
}
|
|
222
|
+
}),
|
|
223
|
+
root: react_utilities_1.getNativeElementProps(as, {
|
|
224
|
+
tabIndex: -1,
|
|
225
|
+
...rest,
|
|
226
|
+
id,
|
|
227
|
+
ref,
|
|
228
|
+
children: null,
|
|
229
|
+
'aria-level': level,
|
|
230
|
+
'aria-expanded': isBranch ? open : undefined,
|
|
231
|
+
role: 'treeitem',
|
|
232
|
+
onClick: handleClick,
|
|
233
|
+
onKeyDown: handleKeyDown,
|
|
234
|
+
onMouseOver: actions ? showActions : undefined,
|
|
235
|
+
onFocus: actions ? showActions : undefined,
|
|
236
|
+
onMouseOut: actions ? hideActions : undefined,
|
|
237
|
+
onBlur: actions ? hideActions : undefined
|
|
238
|
+
}),
|
|
239
|
+
expandIcon: react_utilities_1.resolveShorthand(expandIcon, {
|
|
240
|
+
required: isBranch,
|
|
241
|
+
defaultProps: {
|
|
242
|
+
children: React.createElement(react_icons_1.ChevronRight12Regular, {
|
|
243
|
+
style: useTreeItemStyles_1.expandIconInlineStyles[expandIconRotation]
|
|
244
|
+
}),
|
|
245
|
+
'aria-hidden': true,
|
|
246
|
+
ref: react_utilities_3.useMergedRefs(react_utilities_1.isResolvedShorthand(expandIcon) ? expandIcon.ref : undefined, expandIconRef)
|
|
247
|
+
}
|
|
248
|
+
}),
|
|
249
|
+
actions: react_utilities_1.resolveShorthand(actions, {
|
|
250
|
+
defaultProps: {
|
|
251
|
+
ref: react_utilities_3.useMergedRefs(react_utilities_1.isResolvedShorthand(actions) ? actions.ref : undefined, actionsRef)
|
|
252
|
+
}
|
|
253
|
+
})
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
exports.useTreeItem_unstable = useTreeItem_unstable;
|
|
257
|
+
//# sourceMappingURL=useTreeItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","require","react_utilities_1","react_icons_1","react_shared_contexts_1","react_utilities_2","useTreeItemStyles_1","keyboard_keys_1","react_utilities_3","react_portal_1","index_1","tokens_1","useTreeItem_unstable","props","ref","children","subtreeChildren","Children","toArray","contextLevel","useTreeContext_unstable","ctx","level","content","subtree","expandIcon","leaf","isLeaf","undefined","actions","as","onClick","onKeyDown","rest","requestOpenChange","requestNavigation","id","useId","isBranch","open","openItems","has","dir","targetDocument","useFluent_unstable","expandIconRotation","actionsRef","useRef","expandIconRef","subtreeRef","handleArrowRight","event","type","treeDataTypes","arrowRight","target","currentTarget","handleArrowLeft","arrowLeft","handleEnter","enter","handleClick","useEventCallback","isEventFromActions","current","elementContains","isEventFromSubtree","isFromExpandIcon","expandIconClick","click","handleKeyDown","isDefaultPrevented","key","Enter","ArrowRight","ArrowLeft","End","end","Home","home","ArrowUp","arrowUp","ArrowDown","arrowDown","isTypeAheadCharacter","length","match","altKey","ctrlKey","metaKey","typeAhead","isActionsVisible","setActionsVisible","useState","showActions","hideActions","useEffect","handleFocusOut","relatedTarget","addEventListener","passive","removeEventListener","buttonSize","components","root","resolveShorthand","required","Boolean","defaultProps","useMergedRefs","isResolvedShorthand","getNativeElementProps","tabIndex","role","onMouseOver","onFocus","onMouseOut","onBlur","createElement","ChevronRight12Regular","style","expandIconInlineStyles","exports"],"sources":["../../../../../../../../../packages/react-components/react-tree/src/components/TreeItem/useTreeItem.tsx"],"sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, isResolvedShorthand, resolveShorthand, useId } from '@fluentui/react-utilities';\nimport { ChevronRight12Regular } from '@fluentui/react-icons';\nimport { useFluent_unstable } from '@fluentui/react-shared-contexts';\nimport { useEventCallback } from '@fluentui/react-utilities';\nimport { expandIconInlineStyles } from './useTreeItemStyles';\nimport { ArrowDown, ArrowLeft, ArrowRight, ArrowUp, End, Enter, Home } from '@fluentui/keyboard-keys';\nimport { useMergedRefs } from '@fluentui/react-utilities';\nimport { elementContains } from '@fluentui/react-portal';\nimport type { TreeItemProps, TreeItemState } from './TreeItem.types';\nimport { useTreeContext_unstable } from '../../contexts/index';\nimport { treeDataTypes } from '../../utils/tokens';\n\n/**\n * Create the state required to render TreeItem.\n *\n * The returned state can be modified with hooks such as useTreeItemStyles_unstable,\n * before being passed to renderTreeItem_unstable.\n *\n * @param props - props from this instance of TreeItem\n * @param ref - reference to root HTMLElement of TreeItem\n */\nexport const useTreeItem_unstable = (props: TreeItemProps, ref: React.Ref<HTMLDivElement>): TreeItemState => {\n const [children, subtreeChildren] = React.Children.toArray(props.children);\n\n const contextLevel = useTreeContext_unstable(ctx => ctx.level);\n const {\n content,\n subtree,\n expandIcon,\n leaf: isLeaf = subtreeChildren === undefined,\n actions,\n as = 'div',\n onClick,\n onKeyDown,\n ['aria-level']: level = contextLevel,\n ...rest\n } = props;\n\n const requestOpenChange = useTreeContext_unstable(ctx => ctx.requestOpenChange);\n const requestNavigation = useTreeContext_unstable(ctx => ctx.requestNavigation);\n\n const id = useId('fui-TreeItem-', props.id);\n\n const isBranch = !isLeaf;\n\n const open = useTreeContext_unstable(ctx => isBranch && ctx.openItems.has(id));\n const { dir, targetDocument } = useFluent_unstable();\n const expandIconRotation = open ? 90 : dir !== 'rtl' ? 0 : 180;\n\n const actionsRef = React.useRef<HTMLElement>(null);\n const expandIconRef = React.useRef<HTMLElement>(null);\n const subtreeRef = React.useRef<HTMLElement>(null);\n\n const handleArrowRight = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (!open && isBranch) {\n return requestOpenChange({ event, open: true, type: treeDataTypes.arrowRight, target: event.currentTarget });\n }\n if (open && isBranch) {\n return requestNavigation({ event, type: treeDataTypes.arrowRight, target: event.currentTarget });\n }\n };\n const handleArrowLeft = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (open && isBranch) {\n return requestOpenChange({ event, open: false, type: treeDataTypes.arrowLeft, target: event.currentTarget });\n }\n if (!open && level > 1) {\n return requestNavigation({ event, target: event.currentTarget, type: treeDataTypes.arrowLeft });\n }\n };\n const handleEnter = (event: React.KeyboardEvent<HTMLDivElement>) => {\n requestOpenChange({ event, open: isLeaf ? open : !open, type: treeDataTypes.enter, target: event.currentTarget });\n };\n\n const handleClick = useEventCallback((event: React.MouseEvent<HTMLDivElement>) => {\n onClick?.(event);\n\n const isEventFromActions = actionsRef.current && elementContains(actionsRef.current, event.target as Node);\n if (isEventFromActions) {\n return;\n }\n const isEventFromSubtree = subtreeRef.current && elementContains(subtreeRef.current, event.target as Node);\n if (isEventFromSubtree) {\n return;\n }\n const isFromExpandIcon = expandIconRef.current && elementContains(expandIconRef.current, event.target as Node);\n requestOpenChange({\n event,\n open: isLeaf ? open : !open,\n type: isFromExpandIcon ? treeDataTypes.expandIconClick : treeDataTypes.click,\n target: event.currentTarget,\n });\n requestNavigation({ event, target: event.currentTarget, type: treeDataTypes.click });\n });\n\n const handleKeyDown = useEventCallback((event: React.KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n if (event.currentTarget !== event.target) {\n return;\n }\n if (event.isDefaultPrevented()) {\n return;\n }\n switch (event.key) {\n case Enter:\n return handleEnter(event);\n case ArrowRight:\n return handleArrowRight(event);\n case ArrowLeft:\n return handleArrowLeft(event);\n case End:\n return requestNavigation({ event, type: treeDataTypes.end, target: event.currentTarget });\n case Home:\n return requestNavigation({ event, type: treeDataTypes.home, target: event.currentTarget });\n case ArrowUp:\n return requestNavigation({ event, type: treeDataTypes.arrowUp, target: event.currentTarget });\n case ArrowDown:\n return requestNavigation({ event, type: treeDataTypes.arrowDown, target: event.currentTarget });\n }\n const isTypeAheadCharacter =\n event.key.length === 1 && event.key.match(/\\w/) && !event.altKey && !event.ctrlKey && !event.metaKey;\n if (isTypeAheadCharacter) {\n return requestNavigation({ event, target: event.currentTarget, type: treeDataTypes.typeAhead });\n }\n });\n\n const [isActionsVisible, setActionsVisible] = React.useState(false);\n const showActions = useEventCallback((event: React.SyntheticEvent) => {\n const isEventFromSubtree = subtreeRef.current && elementContains(subtreeRef.current, event.target as Node);\n if (!isEventFromSubtree) {\n setActionsVisible(true);\n }\n });\n const hideActions = useEventCallback((event: React.SyntheticEvent) => {\n const isEventFromSubtree = subtreeRef.current && elementContains(subtreeRef.current, event.target as Node);\n if (!isEventFromSubtree) {\n setActionsVisible(false);\n }\n });\n\n // Listens to focusout event on the document to ensure treeitem actions visibility on portal scenarios\n // TODO: find a better way to ensure this behavior\n React.useEffect(() => {\n if (actionsRef.current) {\n const handleFocusOut = (event: FocusEvent) => {\n setActionsVisible(elementContains(actionsRef.current, event.relatedTarget as Node));\n };\n targetDocument?.addEventListener('focusout', handleFocusOut, { passive: true });\n return () => {\n targetDocument?.removeEventListener('focusout', handleFocusOut);\n };\n }\n }, [targetDocument]);\n\n return {\n isLeaf,\n open,\n level,\n buttonSize: 'small',\n isActionsVisible: actions ? isActionsVisible : false,\n components: {\n content: 'div',\n root: 'div',\n expandIcon: 'span',\n actions: 'span',\n subtree: 'span',\n },\n subtree: resolveShorthand(subtree, {\n required: Boolean(subtreeChildren),\n defaultProps: {\n children: subtreeChildren,\n ref: useMergedRefs(subtreeRef, isResolvedShorthand(subtree) ? subtree.ref : undefined),\n },\n }),\n content: resolveShorthand(content, {\n required: true,\n defaultProps: {\n children,\n },\n }),\n root: getNativeElementProps(as, {\n tabIndex: -1,\n ...rest,\n id,\n ref,\n children: null,\n 'aria-level': level,\n 'aria-expanded': isBranch ? open : undefined,\n role: 'treeitem',\n onClick: handleClick,\n onKeyDown: handleKeyDown,\n onMouseOver: actions ? showActions : undefined,\n onFocus: actions ? showActions : undefined,\n onMouseOut: actions ? hideActions : undefined,\n onBlur: actions ? hideActions : undefined,\n }),\n expandIcon: resolveShorthand(expandIcon, {\n required: isBranch,\n defaultProps: {\n children: <ChevronRight12Regular style={expandIconInlineStyles[expandIconRotation]} />,\n 'aria-hidden': true,\n ref: useMergedRefs(isResolvedShorthand(expandIcon) ? expandIcon.ref : undefined, expandIconRef),\n },\n }),\n actions: resolveShorthand(actions, {\n defaultProps: {\n ref: useMergedRefs(isResolvedShorthand(actions) ? actions.ref : undefined, actionsRef),\n },\n }),\n };\n};\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AACA,MAAAC,iBAAA,gBAAAD,OAAA;AACA,MAAAE,aAAA,gBAAAF,OAAA;AACA,MAAAG,uBAAA,gBAAAH,OAAA;AACA,MAAAI,iBAAA,gBAAAJ,OAAA;AACA,MAAAK,mBAAA,gBAAAL,OAAA;AACA,MAAAM,eAAA,gBAAAN,OAAA;AACA,MAAAO,iBAAA,gBAAAP,OAAA;AACA,MAAAQ,cAAA,gBAAAR,OAAA;AAEA,MAAAS,OAAA,gBAAAT,OAAA;AACA,MAAAU,QAAA,gBAAAV,OAAA;AAEA;;;;;;;;;AASO,MAAMW,oBAAoB,GAAGA,CAACC,KAAoB,EAAEC,GAA8B,KAAmB;EAC1G,MAAM,CAACC,QAAQ,EAAEC,eAAe,CAAC,GAAGhB,KAAK,CAACiB,QAAQ,CAACC,OAAO,CAACL,KAAK,CAACE,QAAQ,CAAC;EAE1E,MAAMI,YAAY,GAAGT,OAAA,CAAAU,uBAAuB,CAACC,GAAG,IAAIA,GAAG,CAACC,KAAK,CAAC;EAC9D,MAAM;IACJC,OAAO;IACPC,OAAO;IACPC,UAAU;IACVC,IAAI,EAAEC,MAAM,GAAGX,eAAe,KAAKY,SAAS;IAC5CC,OAAO;IACPC,EAAE,GAAG,KAAK;IACVC,OAAO;IACPC,SAAS;IACT,CAAC,YAAY,GAAGV,KAAK,GAAGH,YAAY;IACpC,GAAGc;EAAI,CACR,GAAGpB,KAAK;EAET,MAAMqB,iBAAiB,GAAGxB,OAAA,CAAAU,uBAAuB,CA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Q,EAAEf,KAAA,CAAAsH,aAAA,CAACnH,aAAA,CAAAoH,qBAAqB;UAACC,KAAK,EAAElH,mBAAA,CAAAmH,sBAAsB,CAAC5E,kBAAkB;QAAC,EAAI;QACtF,aAAa,EAAE,IAAI;QACnB/B,GAAG,EAAEN,iBAAA,CAAAqG,aAAa,CAAC3G,iBAAA,CAAA4G,mBAAmB,CAACrF,UAAU,CAAC,GAAGA,UAAU,CAACX,GAAG,GAAGc,SAAS,EAAEoB,aAAa;;KAEjG,CAAC;IACFnB,OAAO,EAAE3B,iBAAA,CAAAuG,gBAAgB,CAAC5E,OAAO,EAAE;MACjC+E,YAAY,EAAE;QACZ9F,GAAG,EAAEN,iBAAA,CAAAqG,aAAa,CAAC3G,iBAAA,CAAA4G,mBAAmB,CAACjF,OAAO,CAAC,GAAGA,OAAO,CAACf,GAAG,GAAGc,SAAS,EAAEkB,UAAU;;KAExF;GACF;AACH,CAAC;AA5LY4E,OAAA,CAAA9G,oBAAoB,GAAAA,oBAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useTreeItemContextValues_unstable = void 0;
|
|
7
|
+
const React = /*#__PURE__*/require("react");
|
|
8
|
+
function useTreeItemContextValues_unstable(state) {
|
|
9
|
+
const {
|
|
10
|
+
buttonSize,
|
|
11
|
+
isActionsVisible
|
|
12
|
+
} = state;
|
|
13
|
+
const treeItem = React.useMemo(() => ({
|
|
14
|
+
isActionsVisible
|
|
15
|
+
}), [isActionsVisible]);
|
|
16
|
+
const button = React.useMemo(() => ({
|
|
17
|
+
size: buttonSize
|
|
18
|
+
}), [buttonSize]);
|
|
19
|
+
return {
|
|
20
|
+
treeItem,
|
|
21
|
+
button
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.useTreeItemContextValues_unstable = useTreeItemContextValues_unstable;
|
|
25
|
+
//# sourceMappingURL=useTreeItemContextValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["React","require","useTreeItemContextValues_unstable","state","buttonSize","isActionsVisible","treeItem","useMemo","button","size","exports"],"sources":["../../../../../../../../../packages/react-components/react-tree/src/components/TreeItem/useTreeItemContextValues.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ButtonContextValue } from '@fluentui/react-button';\nimport type { TreeItemContextValue } from '../../contexts';\nimport type { TreeItemContextValues, TreeItemState } from './TreeItem.types';\n\nexport function useTreeItemContextValues_unstable(\n state: Pick<TreeItemState, 'buttonSize' | 'isActionsVisible'>,\n): TreeItemContextValues {\n const { buttonSize, isActionsVisible } = state;\n\n const treeItem = React.useMemo<TreeItemContextValue>(() => ({ isActionsVisible }), [isActionsVisible]);\n const button = React.useMemo<ButtonContextValue>(() => ({ size: buttonSize }), [buttonSize]);\n\n return { treeItem, button };\n}\n"],"mappings":";;;;;;AAAA,MAAAA,KAAA,gBAAAC,OAAA;AAKA,SAAgBC,iCAAiCA,CAC/CC,KAA6D;EAE7D,MAAM;IAAEC,UAAU;IAAEC;EAAgB,CAAE,GAAGF,KAAK;EAE9C,MAAMG,QAAQ,GAAGN,KAAK,CAACO,OAAO,CAAuB,OAAO;IAAEF;EAAgB,CAAE,CAAC,EAAE,CAACA,gBAAgB,CAAC,CAAC;EACtG,MAAMG,MAAM,GAAGR,KAAK,CAACO,OAAO,CAAqB,OAAO;IAAEE,IAAI,EAAEL;EAAU,CAAE,CAAC,EAAE,CAACA,UAAU,CAAC,CAAC;EAE5F,OAAO;IAAEE,QAAQ;IAAEE;EAAM,CAAE;AAC7B;AATAE,OAAA,CAAAR,iCAAA,GAAAA,iCAAA"}
|