@fluentui/react-list 0.0.0-nightly-20250107-0406.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.
Files changed (113) hide show
  1. package/CHANGELOG.md +352 -0
  2. package/LICENSE +15 -0
  3. package/README.md +5 -0
  4. package/dist/index.d.ts +148 -0
  5. package/lib/List.js +1 -0
  6. package/lib/List.js.map +1 -0
  7. package/lib/ListItem.js +1 -0
  8. package/lib/ListItem.js.map +1 -0
  9. package/lib/components/List/List.js +14 -0
  10. package/lib/components/List/List.js.map +1 -0
  11. package/lib/components/List/List.types.js +1 -0
  12. package/lib/components/List/List.types.js.map +1 -0
  13. package/lib/components/List/index.js +4 -0
  14. package/lib/components/List/index.js.map +1 -0
  15. package/lib/components/List/listContext.js +11 -0
  16. package/lib/components/List/listContext.js.map +1 -0
  17. package/lib/components/List/renderList.js +12 -0
  18. package/lib/components/List/renderList.js.map +1 -0
  19. package/lib/components/List/useList.js +75 -0
  20. package/lib/components/List/useList.js.map +1 -0
  21. package/lib/components/List/useListContextValues.js +12 -0
  22. package/lib/components/List/useListContextValues.js.map +1 -0
  23. package/lib/components/List/useListStyles.styles.js +15 -0
  24. package/lib/components/List/useListStyles.styles.js.map +1 -0
  25. package/lib/components/ListItem/ListItem.js +12 -0
  26. package/lib/components/ListItem/ListItem.js.map +1 -0
  27. package/lib/components/ListItem/ListItem.types.js +3 -0
  28. package/lib/components/ListItem/ListItem.types.js.map +1 -0
  29. package/lib/components/ListItem/index.js +4 -0
  30. package/lib/components/ListItem/index.js.map +1 -0
  31. package/lib/components/ListItem/renderListItem.js +13 -0
  32. package/lib/components/ListItem/renderListItem.js.map +1 -0
  33. package/lib/components/ListItem/useListItem.js +185 -0
  34. package/lib/components/ListItem/useListItem.js.map +1 -0
  35. package/lib/components/ListItem/useListItemStyles.styles.js +48 -0
  36. package/lib/components/ListItem/useListItemStyles.styles.js.map +1 -0
  37. package/lib/events/ListItemActionEvent.js +9 -0
  38. package/lib/events/ListItemActionEvent.js.map +1 -0
  39. package/lib/hooks/index.js +1 -0
  40. package/lib/hooks/index.js.map +1 -0
  41. package/lib/hooks/types.js +1 -0
  42. package/lib/hooks/types.js.map +1 -0
  43. package/lib/hooks/useListSelection.js +41 -0
  44. package/lib/hooks/useListSelection.js.map +1 -0
  45. package/lib/index.js +2 -0
  46. package/lib/index.js.map +1 -0
  47. package/lib/utils/calculateListItemRoleForListRole.js +16 -0
  48. package/lib/utils/calculateListItemRoleForListRole.js.map +1 -0
  49. package/lib/utils/calculateListRole.js +14 -0
  50. package/lib/utils/calculateListRole.js.map +1 -0
  51. package/lib/utils/index.js +5 -0
  52. package/lib/utils/index.js.map +1 -0
  53. package/lib/utils/validateGridCellsArePresent.js +16 -0
  54. package/lib/utils/validateGridCellsArePresent.js.map +1 -0
  55. package/lib/utils/validateProperElementTypes.js +12 -0
  56. package/lib/utils/validateProperElementTypes.js.map +1 -0
  57. package/lib/utils/validateProperRolesAreUsed.js +36 -0
  58. package/lib/utils/validateProperRolesAreUsed.js.map +1 -0
  59. package/lib-commonjs/List.js +28 -0
  60. package/lib-commonjs/List.js.map +1 -0
  61. package/lib-commonjs/ListItem.js +28 -0
  62. package/lib-commonjs/ListItem.js.map +1 -0
  63. package/lib-commonjs/components/List/List.js +25 -0
  64. package/lib-commonjs/components/List/List.js.map +1 -0
  65. package/lib-commonjs/components/List/List.types.js +6 -0
  66. package/lib-commonjs/components/List/List.types.js.map +1 -0
  67. package/lib-commonjs/components/List/index.js +31 -0
  68. package/lib-commonjs/components/List/index.js.map +1 -0
  69. package/lib-commonjs/components/List/listContext.js +32 -0
  70. package/lib-commonjs/components/List/listContext.js.map +1 -0
  71. package/lib-commonjs/components/List/renderList.js +20 -0
  72. package/lib-commonjs/components/List/renderList.js.map +1 -0
  73. package/lib-commonjs/components/List/useList.js +78 -0
  74. package/lib-commonjs/components/List/useList.js.map +1 -0
  75. package/lib-commonjs/components/List/useListContextValues.js +22 -0
  76. package/lib-commonjs/components/List/useListContextValues.js.map +1 -0
  77. package/lib-commonjs/components/List/useListStyles.styles.js +31 -0
  78. package/lib-commonjs/components/List/useListStyles.styles.js.map +1 -0
  79. package/lib-commonjs/components/ListItem/ListItem.js +23 -0
  80. package/lib-commonjs/components/ListItem/ListItem.js.map +1 -0
  81. package/lib-commonjs/components/ListItem/ListItem.types.js +6 -0
  82. package/lib-commonjs/components/ListItem/ListItem.types.js.map +1 -0
  83. package/lib-commonjs/components/ListItem/index.js +31 -0
  84. package/lib-commonjs/components/ListItem/index.js.map +1 -0
  85. package/lib-commonjs/components/ListItem/renderListItem.js +21 -0
  86. package/lib-commonjs/components/ListItem/renderListItem.js.map +1 -0
  87. package/lib-commonjs/components/ListItem/useListItem.js +188 -0
  88. package/lib-commonjs/components/ListItem/useListItem.js.map +1 -0
  89. package/lib-commonjs/components/ListItem/useListItemStyles.styles.js +71 -0
  90. package/lib-commonjs/components/ListItem/useListItemStyles.styles.js.map +1 -0
  91. package/lib-commonjs/events/ListItemActionEvent.js +28 -0
  92. package/lib-commonjs/events/ListItemActionEvent.js.map +1 -0
  93. package/lib-commonjs/hooks/index.js +11 -0
  94. package/lib-commonjs/hooks/index.js.map +1 -0
  95. package/lib-commonjs/hooks/types.js +6 -0
  96. package/lib-commonjs/hooks/types.js.map +1 -0
  97. package/lib-commonjs/hooks/useListSelection.js +52 -0
  98. package/lib-commonjs/hooks/useListSelection.js.map +1 -0
  99. package/lib-commonjs/index.js +44 -0
  100. package/lib-commonjs/index.js.map +1 -0
  101. package/lib-commonjs/utils/calculateListItemRoleForListRole.js +26 -0
  102. package/lib-commonjs/utils/calculateListItemRoleForListRole.js.map +1 -0
  103. package/lib-commonjs/utils/calculateListRole.js +24 -0
  104. package/lib-commonjs/utils/calculateListRole.js.map +1 -0
  105. package/lib-commonjs/utils/index.js +32 -0
  106. package/lib-commonjs/utils/index.js.map +1 -0
  107. package/lib-commonjs/utils/validateGridCellsArePresent.js +26 -0
  108. package/lib-commonjs/utils/validateGridCellsArePresent.js.map +1 -0
  109. package/lib-commonjs/utils/validateProperElementTypes.js +22 -0
  110. package/lib-commonjs/utils/validateProperElementTypes.js.map +1 -0
  111. package/lib-commonjs/utils/validateProperRolesAreUsed.js +46 -0
  112. package/lib-commonjs/utils/validateProperRolesAreUsed.js.map +1 -0
  113. package/package.json +56 -0
@@ -0,0 +1,75 @@
1
+ import * as React from 'react';
2
+ import { getIntrinsicElementProps, slot, useControllableState, useEventCallback } from '@fluentui/react-utilities';
3
+ import { useArrowNavigationGroup, useFocusFinders } from '@fluentui/react-tabster';
4
+ import { useListSelection } from '../../hooks/useListSelection';
5
+ import { calculateListItemRoleForListRole, calculateListRole, validateGridCellsArePresent, validateProperElementTypes, validateProperRolesAreUsed } from '../../utils';
6
+ const DEFAULT_ROOT_EL_TYPE = 'ul';
7
+ /**
8
+ * Create the state required to render List.
9
+ *
10
+ * The returned state can be modified with hooks such as useListStyles_unstable,
11
+ * before being passed to renderList_unstable.
12
+ *
13
+ * @param props - props from this instance of List
14
+ * @param ref - reference to root HTMLElement of List
15
+ */ export const useList_unstable = (props, ref)=>{
16
+ const { navigationMode, selectionMode, selectedItems, defaultSelectedItems, onSelectionChange } = props;
17
+ const as = props.as || navigationMode === 'composite' ? 'div' : DEFAULT_ROOT_EL_TYPE;
18
+ const arrowNavigationAttributes = useArrowNavigationGroup({
19
+ axis: 'vertical',
20
+ memorizeCurrent: true
21
+ });
22
+ const [selectionState, setSelectionState] = useControllableState({
23
+ state: selectedItems,
24
+ defaultState: defaultSelectedItems,
25
+ initialState: []
26
+ });
27
+ const onChange = useEventCallback((e, data)=>{
28
+ const selectedItemsAsArray = Array.from(data.selectedItems);
29
+ setSelectionState(selectedItemsAsArray);
30
+ onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(e, {
31
+ event: e,
32
+ type: 'change',
33
+ selectedItems: selectedItemsAsArray
34
+ });
35
+ });
36
+ const selection = useListSelection({
37
+ onSelectionChange: onChange,
38
+ selectionMode: selectionMode || 'multiselect',
39
+ selectedItems: selectionState
40
+ });
41
+ const listRole = props.role || calculateListRole(navigationMode, !!selectionMode);
42
+ const listItemRole = calculateListItemRoleForListRole(listRole);
43
+ const { findAllFocusable } = useFocusFinders();
44
+ const validateListItem = useEventCallback((listItemEl)=>{
45
+ if (process.env.NODE_ENV === 'production') {
46
+ return;
47
+ }
48
+ const itemRole = listItemEl.getAttribute('role') || '';
49
+ const focusable = findAllFocusable(listItemEl);
50
+ validateProperElementTypes(as, listItemEl.tagName.toLocaleLowerCase());
51
+ validateProperRolesAreUsed(listRole, itemRole, !!selectionMode, focusable.length > 0);
52
+ validateGridCellsArePresent(listRole, listItemEl);
53
+ });
54
+ return {
55
+ components: {
56
+ root: as
57
+ },
58
+ root: slot.always(getIntrinsicElementProps(as, {
59
+ ref,
60
+ role: listRole,
61
+ ...selectionMode && {
62
+ 'aria-multiselectable': selectionMode === 'multiselect' ? true : undefined
63
+ },
64
+ ...arrowNavigationAttributes,
65
+ ...props
66
+ }), {
67
+ elementType: as
68
+ }),
69
+ listItemRole,
70
+ validateListItem,
71
+ navigationMode,
72
+ // only pass down selection state if its handled internally, otherwise just report the events
73
+ selection: selectionMode ? selection : undefined
74
+ };
75
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/List/useList.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n getIntrinsicElementProps,\n OnSelectionChangeData,\n slot,\n useControllableState,\n useEventCallback,\n} from '@fluentui/react-utilities';\nimport { useArrowNavigationGroup, useFocusFinders } from '@fluentui/react-tabster';\nimport { ListProps, ListState } from './List.types';\nimport { useListSelection } from '../../hooks/useListSelection';\nimport {\n calculateListItemRoleForListRole,\n calculateListRole,\n validateGridCellsArePresent,\n validateProperElementTypes,\n validateProperRolesAreUsed,\n} from '../../utils';\n\nconst DEFAULT_ROOT_EL_TYPE = 'ul';\n\n/**\n * Create the state required to render List.\n *\n * The returned state can be modified with hooks such as useListStyles_unstable,\n * before being passed to renderList_unstable.\n *\n * @param props - props from this instance of List\n * @param ref - reference to root HTMLElement of List\n */\nexport const useList_unstable = (\n props: ListProps,\n ref: React.Ref<HTMLDivElement | HTMLUListElement | HTMLOListElement>,\n): ListState => {\n const { navigationMode, selectionMode, selectedItems, defaultSelectedItems, onSelectionChange } = props;\n\n const as = props.as || navigationMode === 'composite' ? 'div' : DEFAULT_ROOT_EL_TYPE;\n\n const arrowNavigationAttributes = useArrowNavigationGroup({\n axis: 'vertical',\n memorizeCurrent: true,\n });\n\n const [selectionState, setSelectionState] = useControllableState({\n state: selectedItems,\n defaultState: defaultSelectedItems,\n initialState: [],\n });\n\n const onChange = useEventCallback((e: React.SyntheticEvent, data: OnSelectionChangeData) => {\n const selectedItemsAsArray = Array.from(data.selectedItems);\n setSelectionState(selectedItemsAsArray);\n onSelectionChange?.(e, { event: e, type: 'change', selectedItems: selectedItemsAsArray });\n });\n\n const selection = useListSelection({\n onSelectionChange: onChange,\n selectionMode: selectionMode || 'multiselect',\n selectedItems: selectionState,\n });\n\n const listRole = props.role || calculateListRole(navigationMode, !!selectionMode);\n const listItemRole = calculateListItemRoleForListRole(listRole);\n\n const { findAllFocusable } = useFocusFinders();\n\n const validateListItem = useEventCallback((listItemEl: HTMLElement) => {\n if (process.env.NODE_ENV === 'production') {\n return;\n }\n const itemRole = listItemEl.getAttribute('role') || '';\n const focusable = findAllFocusable(listItemEl);\n validateProperElementTypes(as, listItemEl.tagName.toLocaleLowerCase());\n validateProperRolesAreUsed(listRole, itemRole, !!selectionMode, focusable.length > 0);\n validateGridCellsArePresent(listRole, listItemEl);\n });\n\n return {\n components: {\n root: as,\n },\n root: slot.always(\n getIntrinsicElementProps(as, {\n ref,\n role: listRole,\n ...(selectionMode && {\n 'aria-multiselectable': selectionMode === 'multiselect' ? true : undefined,\n }),\n ...arrowNavigationAttributes,\n ...props,\n }),\n { elementType: as },\n ),\n listItemRole,\n validateListItem,\n navigationMode,\n // only pass down selection state if its handled internally, otherwise just report the events\n selection: selectionMode ? selection : undefined,\n };\n};\n"],"names":["React","getIntrinsicElementProps","slot","useControllableState","useEventCallback","useArrowNavigationGroup","useFocusFinders","useListSelection","calculateListItemRoleForListRole","calculateListRole","validateGridCellsArePresent","validateProperElementTypes","validateProperRolesAreUsed","DEFAULT_ROOT_EL_TYPE","useList_unstable","props","ref","navigationMode","selectionMode","selectedItems","defaultSelectedItems","onSelectionChange","as","arrowNavigationAttributes","axis","memorizeCurrent","selectionState","setSelectionState","state","defaultState","initialState","onChange","e","data","selectedItemsAsArray","Array","from","event","type","selection","listRole","role","listItemRole","findAllFocusable","validateListItem","listItemEl","process","env","NODE_ENV","itemRole","getAttribute","focusable","tagName","toLocaleLowerCase","length","components","root","always","undefined","elementType"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,wBAAwB,EAExBC,IAAI,EACJC,oBAAoB,EACpBC,gBAAgB,QACX,4BAA4B;AACnC,SAASC,uBAAuB,EAAEC,eAAe,QAAQ,0BAA0B;AAEnF,SAASC,gBAAgB,QAAQ,+BAA+B;AAChE,SACEC,gCAAgC,EAChCC,iBAAiB,EACjBC,2BAA2B,EAC3BC,0BAA0B,EAC1BC,0BAA0B,QACrB,cAAc;AAErB,MAAMC,uBAAuB;AAE7B;;;;;;;;CAQC,GACD,OAAO,MAAMC,mBAAmB,CAC9BC,OACAC;IAEA,MAAM,EAAEC,cAAc,EAAEC,aAAa,EAAEC,aAAa,EAAEC,oBAAoB,EAAEC,iBAAiB,EAAE,GAAGN;IAElG,MAAMO,KAAKP,MAAMO,EAAE,IAAIL,mBAAmB,cAAc,QAAQJ;IAEhE,MAAMU,4BAA4BlB,wBAAwB;QACxDmB,MAAM;QACNC,iBAAiB;IACnB;IAEA,MAAM,CAACC,gBAAgBC,kBAAkB,GAAGxB,qBAAqB;QAC/DyB,OAAOT;QACPU,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state) {
2
+ const { selection, navigationMode, listItemRole, validateListItem } = state;
3
+ const listContext = {
4
+ selection,
5
+ listItemRole,
6
+ navigationMode,
7
+ validateListItem
8
+ };
9
+ return {
10
+ listContext
11
+ };
12
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/List/useListContextValues.ts"],"sourcesContent":["import { ListContextValues, ListState } from './List.types';\n\nexport function useListContextValues_unstable(state: ListState): ListContextValues {\n const { selection, navigationMode, listItemRole, validateListItem } = state;\n\n const listContext = {\n selection,\n listItemRole,\n navigationMode,\n validateListItem,\n };\n\n return {\n listContext,\n };\n}\n"],"names":["useListContextValues_unstable","state","selection","navigationMode","listItemRole","validateListItem","listContext"],"rangeMappings":";;;;;;;;;;;","mappings":"AAEA,OAAO,SAASA,8BAA8BC,KAAgB;IAC5D,MAAM,EAAEC,SAAS,EAAEC,cAAc,EAAEC,YAAY,EAAEC,gBAAgB,EAAE,GAAGJ;IAEtE,MAAMK,cAAc;QAClBJ;QACAE;QACAD;QACAE;IACF;IAEA,OAAO;QACLC;IACF;AACF"}
@@ -0,0 +1,15 @@
1
+ import { __resetStyles, mergeClasses } from '@griffel/react';
2
+ export const listClassNames = {
3
+ root: 'fui-List'
4
+ };
5
+ const useRootBaseStyles = /*#__PURE__*/__resetStyles("r1m6yby2", null, [".r1m6yby2{padding:0;margin:0;text-indent:0;list-style-type:none;}"]);
6
+ /**
7
+ * Apply styling to the List slots based on the state
8
+ */
9
+ export const useListStyles_unstable = state => {
10
+ 'use no memo';
11
+
12
+ const rootStyles = useRootBaseStyles();
13
+ state.root.className = mergeClasses(listClassNames.root, rootStyles, state.root.className);
14
+ return state;
15
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__resetStyles","mergeClasses","listClassNames","root","useRootBaseStyles","useListStyles_unstable","state","rootStyles","className"],"sources":["useListStyles.styles.js"],"sourcesContent":["import { makeResetStyles, mergeClasses } from '@griffel/react';\nexport const listClassNames = {\n root: 'fui-List'\n};\nconst useRootBaseStyles = makeResetStyles({\n padding: 0,\n margin: 0,\n textIndent: 0,\n listStyleType: 'none'\n});\n/**\n * Apply styling to the List slots based on the state\n */ export const useListStyles_unstable = (state)=>{\n 'use no memo';\n const rootStyles = useRootBaseStyles();\n state.root.className = mergeClasses(listClassNames.root, rootStyles, state.root.className);\n return state;\n};\n"],"mappings":"AAAA,SAAAA,aAAA,EAA0BC,YAAY,QAAQ,gBAAgB;AAC9D,OAAO,MAAMC,cAAc,GAAG;EAC1BC,IAAI,EAAE;AACV,CAAC;AACD,MAAMC,iBAAiB,gBAAGJ,aAAA,wFAKzB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMK,sBAAsB,GAAIC,KAAK,IAAG;EAC/C,aAAa;;EACb,MAAMC,UAAU,GAAGH,iBAAiB,CAAC,CAAC;EACtCE,KAAK,CAACH,IAAI,CAACK,SAAS,GAAGP,YAAY,CAACC,cAAc,CAACC,IAAI,EAAEI,UAAU,EAAED,KAAK,CAACH,IAAI,CAACK,SAAS,CAAC;EAC1F,OAAOF,KAAK;AAChB,CAAC","ignoreList":[]}
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';
3
+ import { useListItem_unstable } from './useListItem';
4
+ import { renderListItem_unstable } from './renderListItem';
5
+ import { useListItemStyles_unstable } from './useListItemStyles.styles';
6
+ export const ListItem = /*#__PURE__*/ React.forwardRef((props, ref)=>{
7
+ const state = useListItem_unstable(props, ref);
8
+ useListItemStyles_unstable(state);
9
+ useCustomStyleHook_unstable('useListItemStyles_unstable')(state);
10
+ return renderListItem_unstable(state);
11
+ });
12
+ ListItem.displayName = 'ListItem';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ListItem/ListItem.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\nimport { useCustomStyleHook_unstable } from '@fluentui/react-shared-contexts';\nimport { useListItem_unstable } from './useListItem';\nimport { renderListItem_unstable } from './renderListItem';\nimport { useListItemStyles_unstable } from './useListItemStyles.styles';\nimport type { ListItemProps } from './ListItem.types';\n\nexport const ListItem: ForwardRefComponent<ListItemProps> = React.forwardRef<HTMLLIElement | HTMLDivElement>(\n (props, ref) => {\n const state = useListItem_unstable(props, ref);\n\n useListItemStyles_unstable(state);\n useCustomStyleHook_unstable('useListItemStyles_unstable')(state);\n return renderListItem_unstable(state);\n },\n);\n\nListItem.displayName = 'ListItem';\n"],"names":["React","useCustomStyleHook_unstable","useListItem_unstable","renderListItem_unstable","useListItemStyles_unstable","ListItem","forwardRef","props","ref","state","displayName"],"rangeMappings":";;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,SAASC,2BAA2B,QAAQ,kCAAkC;AAC9E,SAASC,oBAAoB,QAAQ,gBAAgB;AACrD,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SAASC,0BAA0B,QAAQ,6BAA6B;AAGxE,OAAO,MAAMC,yBAA+CL,MAAMM,UAAU,CAC1E,CAACC,OAAOC;IACN,MAAMC,QAAQP,qBAAqBK,OAAOC;IAE1CJ,2BAA2BK;IAC3BR,4BAA4B,8BAA8BQ;IAC1D,OAAON,wBAAwBM;AACjC,GACA;AAEFJ,SAASK,WAAW,GAAG"}
@@ -0,0 +1,3 @@
1
+ /**
2
+ * State used in rendering ListItem
3
+ */ export { };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ListItem/ListItem.types.ts"],"sourcesContent":["import { Checkbox } from '@fluentui/react-checkbox';\nimport type { ComponentProps, ComponentState, EventData, EventHandler, Slot } from '@fluentui/react-utilities';\nimport { ListItemActionEvent, ListItemActionEventName } from '../../events/ListItemActionEvent';\n\nexport type ListItemSlots = {\n root: NonNullable<Slot<'li', 'div'>>;\n checkmark?: Slot<typeof Checkbox>;\n};\n\nexport type ListItemValue = string | number;\n\nexport type ListItemActionEventData = EventData<typeof ListItemActionEventName, ListItemActionEvent> & {\n value: ListItemValue;\n};\n/**\n * ListItem Props\n */\nexport type ListItemProps = ComponentProps<ListItemSlots> & {\n value?: ListItemValue;\n onAction?: EventHandler<ListItemActionEventData>;\n};\n\n/**\n * State used in rendering ListItem\n */\nexport type ListItemState = ComponentState<ListItemSlots> & { selectable: boolean; navigable: boolean };\n"],"names":[],"rangeMappings":";;","mappings":"AAsBA;;CAEC,GACD,WAAwG"}
@@ -0,0 +1,4 @@
1
+ export { ListItem } from './ListItem';
2
+ export { renderListItem_unstable } from './renderListItem';
3
+ export { useListItem_unstable } from './useListItem';
4
+ export { listItemClassNames, useListItemStyles_unstable } from './useListItemStyles.styles';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ListItem/index.ts"],"sourcesContent":["export { ListItem } from './ListItem';\nexport type {\n ListItemActionEventData,\n ListItemProps,\n ListItemSlots,\n ListItemState,\n ListItemValue,\n} from './ListItem.types';\nexport { renderListItem_unstable } from './renderListItem';\nexport { useListItem_unstable } from './useListItem';\nexport { listItemClassNames, useListItemStyles_unstable } from './useListItemStyles.styles';\n"],"names":["ListItem","renderListItem_unstable","useListItem_unstable","listItemClassNames","useListItemStyles_unstable"],"rangeMappings":";;;","mappings":"AAAA,SAASA,QAAQ,QAAQ,aAAa;AAQtC,SAASC,uBAAuB,QAAQ,mBAAmB;AAC3D,SAASC,oBAAoB,QAAQ,gBAAgB;AACrD,SAASC,kBAAkB,EAAEC,0BAA0B,QAAQ,6BAA6B"}
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@fluentui/react-jsx-runtime/jsx-runtime";
2
+ import { assertSlots } from '@fluentui/react-utilities';
3
+ /**
4
+ * Render the final JSX of ListItem
5
+ */ export const renderListItem_unstable = (state)=>{
6
+ assertSlots(state);
7
+ return /*#__PURE__*/ _jsxs(state.root, {
8
+ children: [
9
+ state.checkmark && /*#__PURE__*/ _jsx(state.checkmark, {}),
10
+ state.root.children
11
+ ]
12
+ });
13
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ListItem/renderListItem.tsx"],"sourcesContent":["/** @jsxRuntime automatic */\n/** @jsxImportSource @fluentui/react-jsx-runtime */\n\nimport { assertSlots } from '@fluentui/react-utilities';\nimport type { ListItemState, ListItemSlots } from './ListItem.types';\n\n/**\n * Render the final JSX of ListItem\n */\nexport const renderListItem_unstable = (state: ListItemState) => {\n assertSlots<ListItemSlots>(state);\n\n return (\n <state.root>\n {state.checkmark && <state.checkmark />}\n {state.root.children}\n </state.root>\n );\n};\n"],"names":["assertSlots","renderListItem_unstable","state","root","checkmark","children"],"rangeMappings":";;;;;;;;;;;;","mappings":"AAAA,0BAA0B,GAC1B,iDAAiD;AAEjD,SAASA,WAAW,QAAQ,4BAA4B;AAGxD;;CAEC,GACD,OAAO,MAAMC,0BAA0B,CAACC;IACtCF,YAA2BE;IAE3B,qBACE,MAACA,MAAMC,IAAI;;YACRD,MAAME,SAAS,kBAAI,KAACF,MAAME,SAAS;YACnCF,MAAMC,IAAI,CAACE,QAAQ;;;AAG1B,EAAE"}
@@ -0,0 +1,185 @@
1
+ import * as React from 'react';
2
+ import { GroupperMoveFocusEvent, MoverMoveFocusEvent, GroupperMoveFocusActions, MoverKeys, useArrowNavigationGroup, useFocusableGroup, useMergedTabsterAttributes_unstable } from '@fluentui/react-tabster';
3
+ import { elementContains, getIntrinsicElementProps, mergeCallbacks, slot, useEventCallback, useId, useMergedRefs } from '@fluentui/react-utilities';
4
+ import { useListContext_unstable } from '../List/listContext';
5
+ import { Enter, Space, ArrowUp, ArrowDown, ArrowRight, ArrowLeft } from '@fluentui/keyboard-keys';
6
+ import { Checkbox } from '@fluentui/react-checkbox';
7
+ import { createListItemActionEvent, ListItemActionEventName } from '../../events/ListItemActionEvent';
8
+ const DEFAULT_ROOT_EL_TYPE = 'li';
9
+ /**
10
+ * Create the state required to render ListItem.
11
+ *
12
+ * The returned state can be modified with hooks such as useListItemStyles_unstable,
13
+ * before being passed to renderListItem_unstable.
14
+ *
15
+ * @param props - props from this instance of ListItem
16
+ * @param ref - reference to root HTMLLIElement | HTMLDivElementof ListItem
17
+ */ export const useListItem_unstable = (props, ref)=>{
18
+ const id = useId('listItem');
19
+ const { value = id, onKeyDown, onClick, tabIndex, role, onAction } = props;
20
+ const toggleItem = useListContext_unstable((ctx)=>{
21
+ var _ctx_selection;
22
+ return (_ctx_selection = ctx.selection) === null || _ctx_selection === void 0 ? void 0 : _ctx_selection.toggleItem;
23
+ });
24
+ const navigationMode = useListContext_unstable((ctx)=>ctx.navigationMode);
25
+ const isSelectionEnabled = useListContext_unstable((ctx)=>!!ctx.selection);
26
+ const isSelected = useListContext_unstable((ctx)=>{
27
+ var _ctx_selection;
28
+ return (_ctx_selection = ctx.selection) === null || _ctx_selection === void 0 ? void 0 : _ctx_selection.isSelected(value);
29
+ });
30
+ const listItemRole = useListContext_unstable((ctx)=>ctx.listItemRole);
31
+ const validateListItem = useListContext_unstable((ctx)=>ctx.validateListItem);
32
+ const as = props.as || navigationMode === 'composite' ? 'div' : DEFAULT_ROOT_EL_TYPE;
33
+ const finalListItemRole = role || listItemRole;
34
+ const focusableItems = Boolean(isSelectionEnabled || navigationMode || tabIndex === 0);
35
+ const rootRef = React.useRef(null);
36
+ const checkmarkRef = React.useRef(null);
37
+ const handleAction = useEventCallback((event)=>{
38
+ onAction === null || onAction === void 0 ? void 0 : onAction(event, {
39
+ event,
40
+ value,
41
+ type: ListItemActionEventName
42
+ });
43
+ if (event.defaultPrevented) {
44
+ return;
45
+ }
46
+ if (isSelectionEnabled) {
47
+ toggleItem === null || toggleItem === void 0 ? void 0 : toggleItem(event.detail.originalEvent, value);
48
+ }
49
+ });
50
+ React.useEffect(()=>{
51
+ if (rootRef.current) {
52
+ validateListItem(rootRef.current);
53
+ }
54
+ }, [
55
+ validateListItem
56
+ ]);
57
+ const triggerAction = (e)=>{
58
+ const actionEvent = createListItemActionEvent(e);
59
+ handleAction(actionEvent);
60
+ e.target.dispatchEvent(actionEvent);
61
+ };
62
+ const focusableGroupAttrs = useFocusableGroup({
63
+ ignoreDefaultKeydown: {
64
+ Enter: true
65
+ },
66
+ tabBehavior: 'limited-trap-focus'
67
+ });
68
+ const handleClick = useEventCallback((e)=>{
69
+ onClick === null || onClick === void 0 ? void 0 : onClick(e);
70
+ if (e.defaultPrevented) {
71
+ return;
72
+ }
73
+ const isFromCheckbox = elementContains(checkmarkRef.current, e.target);
74
+ if (isFromCheckbox) {
75
+ return;
76
+ }
77
+ triggerAction(e);
78
+ });
79
+ const handleKeyDown = useEventCallback((e)=>{
80
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
81
+ if (e.defaultPrevented) {
82
+ return;
83
+ }
84
+ // If the event is fired from an element inside the list item
85
+ if (e.target !== e.currentTarget) {
86
+ if (focusableItems) {
87
+ // If the items are focusable, we need to handle the arrow keys to move focus to them
88
+ switch(e.key){
89
+ // If it's one of the Arrows defined, jump out of the list item to focus on the ListItem itself
90
+ // The ArrowLeft will only trigger if the target element is the leftmost, otherwise the
91
+ // arrowNavigationAttributes handles it and prevents it from bubbling here.
92
+ case ArrowLeft:
93
+ e.target.dispatchEvent(new GroupperMoveFocusEvent({
94
+ action: GroupperMoveFocusActions.Escape
95
+ }));
96
+ break;
97
+ case ArrowDown:
98
+ case ArrowUp:
99
+ e.preventDefault();
100
+ // Press ESC on the original target to get focus to the parent group (List)
101
+ e.target.dispatchEvent(new GroupperMoveFocusEvent({
102
+ action: GroupperMoveFocusActions.Escape
103
+ }));
104
+ // Now dispatch the original key to move up or down in the list
105
+ e.currentTarget.dispatchEvent(new MoverMoveFocusEvent({
106
+ key: MoverKeys[e.key]
107
+ }));
108
+ }
109
+ return;
110
+ }
111
+ return;
112
+ }
113
+ switch(e.key){
114
+ case Space:
115
+ // we have to prevent default here otherwise the space key will scroll the page
116
+ e.preventDefault();
117
+ // Space always toggles selection (if enabled)
118
+ if (isSelectionEnabled) {
119
+ toggleItem === null || toggleItem === void 0 ? void 0 : toggleItem(e, value);
120
+ } else {
121
+ triggerAction(e);
122
+ }
123
+ break;
124
+ case Enter:
125
+ triggerAction(e);
126
+ break;
127
+ case ArrowRight:
128
+ if (navigationMode === 'composite') {
129
+ e.target.dispatchEvent(new GroupperMoveFocusEvent({
130
+ action: GroupperMoveFocusActions.Enter
131
+ }));
132
+ }
133
+ break;
134
+ }
135
+ });
136
+ const onCheckboxChange = useEventCallback((e, data)=>{
137
+ if (!isSelectionEnabled || e.defaultPrevented) {
138
+ return;
139
+ }
140
+ toggleItem === null || toggleItem === void 0 ? void 0 : toggleItem(e, value);
141
+ });
142
+ const arrowNavigationAttributes = useArrowNavigationGroup({
143
+ axis: 'horizontal'
144
+ });
145
+ const tabsterAttributes = useMergedTabsterAttributes_unstable(focusableItems ? arrowNavigationAttributes : {}, focusableGroupAttrs);
146
+ const root = slot.always(getIntrinsicElementProps(as, {
147
+ ref: useMergedRefs(rootRef, ref),
148
+ tabIndex: focusableItems ? 0 : undefined,
149
+ role: finalListItemRole,
150
+ id: String(value),
151
+ ...isSelectionEnabled && {
152
+ 'aria-selected': isSelected
153
+ },
154
+ ...tabsterAttributes,
155
+ ...props,
156
+ onKeyDown: handleKeyDown,
157
+ onClick: isSelectionEnabled || onClick || onAction ? handleClick : undefined
158
+ }), {
159
+ elementType: as
160
+ });
161
+ const checkmark = slot.optional(props.checkmark, {
162
+ defaultProps: {
163
+ checked: isSelected,
164
+ tabIndex: -1
165
+ },
166
+ renderByDefault: isSelectionEnabled,
167
+ elementType: Checkbox
168
+ });
169
+ const mergedCheckmarkRef = useMergedRefs(checkmark === null || checkmark === void 0 ? void 0 : checkmark.ref, checkmarkRef);
170
+ if (checkmark) {
171
+ checkmark.onChange = mergeCallbacks(checkmark.onChange, onCheckboxChange);
172
+ checkmark.ref = mergedCheckmarkRef;
173
+ }
174
+ const state = {
175
+ components: {
176
+ root: as,
177
+ checkmark: Checkbox
178
+ },
179
+ root,
180
+ checkmark,
181
+ selectable: isSelectionEnabled,
182
+ navigable: focusableItems
183
+ };
184
+ return state;
185
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/components/ListItem/useListItem.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n GroupperMoveFocusEvent,\n MoverMoveFocusEvent,\n GroupperMoveFocusActions,\n MoverKeys,\n useArrowNavigationGroup,\n useFocusableGroup,\n useMergedTabsterAttributes_unstable,\n} from '@fluentui/react-tabster';\nimport {\n elementContains,\n getIntrinsicElementProps,\n mergeCallbacks,\n slot,\n useEventCallback,\n useId,\n useMergedRefs,\n} from '@fluentui/react-utilities';\nimport type { ListItemProps, ListItemState } from './ListItem.types';\nimport { useListContext_unstable } from '../List/listContext';\nimport { Enter, Space, ArrowUp, ArrowDown, ArrowRight, ArrowLeft } from '@fluentui/keyboard-keys';\nimport { Checkbox, CheckboxOnChangeData } from '@fluentui/react-checkbox';\nimport {\n createListItemActionEvent,\n ListItemActionEvent,\n ListItemActionEventName,\n} from '../../events/ListItemActionEvent';\n\nconst DEFAULT_ROOT_EL_TYPE = 'li';\n\n/**\n * Create the state required to render ListItem.\n *\n * The returned state can be modified with hooks such as useListItemStyles_unstable,\n * before being passed to renderListItem_unstable.\n *\n * @param props - props from this instance of ListItem\n * @param ref - reference to root HTMLLIElement | HTMLDivElementof ListItem\n */\nexport const useListItem_unstable = (\n props: ListItemProps,\n ref: React.Ref<HTMLLIElement | HTMLDivElement>,\n): ListItemState => {\n const id = useId('listItem');\n const { value = id, onKeyDown, onClick, tabIndex, role, onAction } = props;\n\n const toggleItem = useListContext_unstable(ctx => ctx.selection?.toggleItem);\n const navigationMode = useListContext_unstable(ctx => ctx.navigationMode);\n const isSelectionEnabled = useListContext_unstable(ctx => !!ctx.selection);\n const isSelected = useListContext_unstable(ctx => ctx.selection?.isSelected(value));\n const listItemRole = useListContext_unstable(ctx => ctx.listItemRole);\n const validateListItem = useListContext_unstable(ctx => ctx.validateListItem);\n\n const as = props.as || navigationMode === 'composite' ? 'div' : DEFAULT_ROOT_EL_TYPE;\n\n const finalListItemRole = role || listItemRole;\n\n const focusableItems = Boolean(isSelectionEnabled || navigationMode || tabIndex === 0);\n\n const rootRef = React.useRef<HTMLLIElement | HTMLDivElement>(null);\n const checkmarkRef = React.useRef<HTMLInputElement | null>(null);\n\n const handleAction: (event: ListItemActionEvent) => void = useEventCallback(event => {\n onAction?.(event, { event, value, type: ListItemActionEventName });\n\n if (event.defaultPrevented) {\n return;\n }\n\n if (isSelectionEnabled) {\n toggleItem?.(event.detail.originalEvent, value);\n }\n });\n\n React.useEffect(() => {\n if (rootRef.current) {\n validateListItem(rootRef.current);\n }\n }, [validateListItem]);\n\n const triggerAction = (e: React.MouseEvent | React.KeyboardEvent) => {\n const actionEvent = createListItemActionEvent(e);\n handleAction(actionEvent);\n e.target.dispatchEvent(actionEvent);\n };\n\n const focusableGroupAttrs = useFocusableGroup({\n ignoreDefaultKeydown: { Enter: true },\n tabBehavior: 'limited-trap-focus',\n });\n\n const handleClick: React.MouseEventHandler<HTMLLIElement & HTMLDivElement> = useEventCallback(e => {\n onClick?.(e);\n\n if (e.defaultPrevented) {\n return;\n }\n\n const isFromCheckbox = elementContains(checkmarkRef.current, e.target as Node);\n if (isFromCheckbox) {\n return;\n }\n\n triggerAction(e);\n });\n\n const handleKeyDown: React.KeyboardEventHandler<HTMLLIElement & HTMLDivElement> = useEventCallback(e => {\n onKeyDown?.(e);\n\n if (e.defaultPrevented) {\n return;\n }\n\n // If the event is fired from an element inside the list item\n if (e.target !== e.currentTarget) {\n if (focusableItems) {\n // If the items are focusable, we need to handle the arrow keys to move focus to them\n switch (e.key) {\n // If it's one of the Arrows defined, jump out of the list item to focus on the ListItem itself\n // The ArrowLeft will only trigger if the target element is the leftmost, otherwise the\n // arrowNavigationAttributes handles it and prevents it from bubbling here.\n case ArrowLeft:\n e.target.dispatchEvent(new GroupperMoveFocusEvent({ action: GroupperMoveFocusActions.Escape }));\n break;\n\n case ArrowDown:\n case ArrowUp:\n e.preventDefault();\n // Press ESC on the original target to get focus to the parent group (List)\n e.target.dispatchEvent(new GroupperMoveFocusEvent({ action: GroupperMoveFocusActions.Escape }));\n // Now dispatch the original key to move up or down in the list\n e.currentTarget.dispatchEvent(new MoverMoveFocusEvent({ key: MoverKeys[e.key] }));\n }\n return;\n }\n return;\n }\n\n switch (e.key) {\n case Space:\n // we have to prevent default here otherwise the space key will scroll the page\n e.preventDefault();\n\n // Space always toggles selection (if enabled)\n if (isSelectionEnabled) {\n toggleItem?.(e, value);\n } else {\n triggerAction(e);\n }\n\n break;\n\n case Enter:\n triggerAction(e);\n break;\n\n case ArrowRight:\n if (navigationMode === 'composite') {\n e.target.dispatchEvent(new GroupperMoveFocusEvent({ action: GroupperMoveFocusActions.Enter }));\n }\n\n break;\n }\n });\n\n const onCheckboxChange = useEventCallback((e: React.ChangeEvent<HTMLInputElement>, data: CheckboxOnChangeData) => {\n if (!isSelectionEnabled || e.defaultPrevented) {\n return;\n }\n\n toggleItem?.(e, value);\n });\n\n const arrowNavigationAttributes = useArrowNavigationGroup({\n axis: 'horizontal',\n });\n\n const tabsterAttributes = useMergedTabsterAttributes_unstable(\n focusableItems ? arrowNavigationAttributes : {},\n focusableGroupAttrs,\n );\n\n const root = slot.always(\n getIntrinsicElementProps(as, {\n ref: useMergedRefs(rootRef, ref) as React.Ref<HTMLLIElement & HTMLDivElement>,\n tabIndex: focusableItems ? 0 : undefined,\n role: finalListItemRole,\n id: String(value),\n ...(isSelectionEnabled && {\n 'aria-selected': isSelected,\n }),\n ...tabsterAttributes,\n ...props,\n onKeyDown: handleKeyDown,\n onClick: isSelectionEnabled || onClick || onAction ? handleClick : undefined,\n }),\n { elementType: as },\n );\n\n const checkmark = slot.optional(props.checkmark, {\n defaultProps: {\n checked: isSelected,\n tabIndex: -1,\n },\n renderByDefault: isSelectionEnabled,\n elementType: Checkbox,\n });\n\n const mergedCheckmarkRef = useMergedRefs(checkmark?.ref, checkmarkRef);\n if (checkmark) {\n checkmark.onChange = mergeCallbacks(checkmark.onChange, onCheckboxChange);\n checkmark.ref = mergedCheckmarkRef;\n }\n\n const state: ListItemState = {\n components: {\n root: as,\n checkmark: Checkbox,\n },\n root,\n checkmark,\n selectable: isSelectionEnabled,\n navigable: focusableItems,\n };\n\n return state;\n};\n"],"names":["React","GroupperMoveFocusEvent","MoverMoveFocusEvent","GroupperMoveFocusActions","MoverKeys","useArrowNavigationGroup","useFocusableGroup","useMergedTabsterAttributes_unstable","elementContains","getIntrinsicElementProps","mergeCallbacks","slot","useEventCallback","useId","useMergedRefs","useListContext_unstable","Enter","Space","ArrowUp","ArrowDown","ArrowRight","ArrowLeft","Checkbox","createListItemActionEvent","ListItemActionEventName","DEFAULT_ROOT_EL_TYPE","useListItem_unstable","props","ref","id","value","onKeyDown","onClick","tabIndex","role","onAction","toggleItem","ctx","selection","navigationMode","isSelectionEnabled","isSelected","listItemRole","validateListItem","as","finalListItemRole","focusableItems","Boolean","rootRef","useRef","checkmarkRef","handleAction","event","type","defaultPrevented","detail","originalEvent","useEffect","current","triggerAction","e","actionEvent","target","dispatchEvent","focusableGroupAttrs","ignoreDefaultKeydown","tabBehavior","handleClick","isFromCheckbox","handleKeyDown","currentTarget","key","action","Escape","preventDefault","onCheckboxChange","data","arrowNavigationAttributes","axis","tabsterAttributes","root","always","undefined","String","elementType","checkmark","optional","defaultProps","checked","renderByDefault","mergedCheckmarkRef","onChange","state","components","selectable","navigable"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,sBAAsB,EACtBC,mBAAmB,EACnBC,wBAAwB,EACxBC,SAAS,EACTC,uBAAuB,EACvBC,iBAAiB,EACjBC,mCAAmC,QAC9B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,iBAAiB,IAAIoC;QAC/BhD,MAAMW;QACNhB,IAAIsD,OAAOrD;QACX,GAAIU,sBAAsB;YACxB,iBAAiBC;QACnB,CAAC;QACD,GAAGsC,iBAAiB;QACpB,GAAGpD,KAAK;QACRI,WAAWsC;QACXrC,SAASQ,sBAAsBR,WAAWG,WAAWgC,cAAce;IACrE,IACA;QAAEE,aAAaxC;IAAG;IAGpB,MAAMyC,YAAY1E,KAAK2E,QAAQ,CAAC3D,MAAM0D,SAAS,EAAE;QAC/CE,cAAc;YACZC,SAAS/C;YACTR,UAAU,CAAC;QACb;QACAwD,iBAAiBjD;QACjB4C,aAAa9D;IACf;IAEA,MAAMoE,qBAAqB5E,cAAcuE,sBAAAA,gCAAAA,UAAWzD,GAAG,EAAEsB;IACzD,IAAImC,WAAW;QACbA,UAAUM,QAAQ,GAAGjF,eAAe2E,UAAUM,QAAQ,EAAEhB;QACxDU,UAAUzD,GAAG,GAAG8D;IAClB;IAEA,MAAME,QAAuB;QAC3BC,YAAY;YACVb,MAAMpC;YACNyC,WAAW/D;QACb;QACA0D;QACAK;QACAS,YAAYtD;QACZuD,WAAWjD;IACb;IAEA,OAAO8C;AACT,EAAE"}
@@ -0,0 +1,48 @@
1
+ import { __styles, __resetStyles, mergeClasses } from '@griffel/react';
2
+ import { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster';
3
+ import { tokens } from '@fluentui/react-theme';
4
+ export const listItemClassNames = {
5
+ root: 'fui-ListItem',
6
+ checkmark: 'fui-ListItem__checkmark'
7
+ };
8
+ const useRootBaseStyles = /*#__PURE__*/__resetStyles("rikgcmv", null, [".rikgcmv{padding:0;margin:0;text-indent:0;list-style-type:none;}", ".rikgcmv[data-fui-focus-visible]{outline:var(--strokeWidthThick) solid var(--colorStrokeFocus2);border-radius:var(--borderRadiusMedium);}"]);
9
+ const useCheckmarkBaseStyles = /*#__PURE__*/__styles({
10
+ root: {
11
+ qb2dma: "f7nlbp4",
12
+ Bpb5tq4: 0,
13
+ Biccaaf: 0,
14
+ Gaeyjg: 0,
15
+ ldoezw: 0,
16
+ B6gmeee: "f1bgo3o3"
17
+ }
18
+ }, {
19
+ d: [".f7nlbp4{align-self:center;}", [".f1bgo3o3 .fui-Checkbox__indicator{margin:4px;}", {
20
+ p: -1
21
+ }]]
22
+ });
23
+ /**
24
+ * Styles for the root slot
25
+ */
26
+ const useStyles = /*#__PURE__*/__styles({
27
+ rootClickableOrSelectable: {
28
+ mc9l5x: "f22iagw",
29
+ Bceei9c: "f1k6fduh"
30
+ }
31
+ }, {
32
+ d: [".f22iagw{display:flex;}", ".f1k6fduh{cursor:pointer;}"]
33
+ });
34
+ /**
35
+ * Apply styling to the ListItem slots based on the state
36
+ */
37
+ export const useListItemStyles_unstable = state => {
38
+ 'use no memo';
39
+
40
+ const rootBaseStyles = useRootBaseStyles();
41
+ const checkmarkBaseStyles = useCheckmarkBaseStyles();
42
+ const styles = useStyles();
43
+ state.root.className = mergeClasses(listItemClassNames.root, rootBaseStyles, (state.selectable || state.navigable) && styles.rootClickableOrSelectable, state.root.className);
44
+ if (state.checkmark) {
45
+ state.checkmark.className = mergeClasses(listItemClassNames.checkmark, checkmarkBaseStyles.root, state.checkmark.className);
46
+ }
47
+ return state;
48
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__styles","__resetStyles","mergeClasses","createCustomFocusIndicatorStyle","tokens","listItemClassNames","root","checkmark","useRootBaseStyles","useCheckmarkBaseStyles","qb2dma","Bpb5tq4","Biccaaf","Gaeyjg","ldoezw","B6gmeee","d","p","useStyles","rootClickableOrSelectable","mc9l5x","Bceei9c","useListItemStyles_unstable","state","rootBaseStyles","checkmarkBaseStyles","styles","className","selectable","navigable"],"sources":["useListItemStyles.styles.js"],"sourcesContent":["import { makeStyles, makeResetStyles, mergeClasses } from '@griffel/react';\nimport { createCustomFocusIndicatorStyle } from '@fluentui/react-tabster';\nimport { tokens } from '@fluentui/react-theme';\nexport const listItemClassNames = {\n root: 'fui-ListItem',\n checkmark: 'fui-ListItem__checkmark'\n};\nconst useRootBaseStyles = makeResetStyles({\n padding: 0,\n margin: 0,\n textIndent: 0,\n listStyleType: 'none',\n ...createCustomFocusIndicatorStyle({\n outline: `${tokens.strokeWidthThick} solid ${tokens.colorStrokeFocus2}`,\n borderRadius: tokens.borderRadiusMedium\n }, {\n selector: 'focus'\n })\n});\nconst useCheckmarkBaseStyles = makeStyles({\n root: {\n alignSelf: 'center',\n '& .fui-Checkbox__indicator': {\n margin: '4px'\n }\n }\n});\n/**\n * Styles for the root slot\n */ const useStyles = makeStyles({\n rootClickableOrSelectable: {\n display: 'flex',\n cursor: 'pointer'\n }\n});\n/**\n * Apply styling to the ListItem slots based on the state\n */ export const useListItemStyles_unstable = (state)=>{\n 'use no memo';\n const rootBaseStyles = useRootBaseStyles();\n const checkmarkBaseStyles = useCheckmarkBaseStyles();\n const styles = useStyles();\n state.root.className = mergeClasses(listItemClassNames.root, rootBaseStyles, (state.selectable || state.navigable) && styles.rootClickableOrSelectable, state.root.className);\n if (state.checkmark) {\n state.checkmark.className = mergeClasses(listItemClassNames.checkmark, checkmarkBaseStyles.root, state.checkmark.className);\n }\n return state;\n};\n"],"mappings":"AAAA,SAAAA,QAAA,EAAAC,aAAA,EAAsCC,YAAY,QAAQ,gBAAgB;AAC1E,SAASC,+BAA+B,QAAQ,yBAAyB;AACzE,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,OAAO,MAAMC,kBAAkB,GAAG;EAC9BC,IAAI,EAAE,cAAc;EACpBC,SAAS,EAAE;AACf,CAAC;AACD,MAAMC,iBAAiB,gBAAGP,aAAA,mOAWzB,CAAC;AACF,MAAMQ,sBAAsB,gBAAGT,QAAA;EAAAM,IAAA;IAAAI,MAAA;IAAAC,OAAA;IAAAC,OAAA;IAAAC,MAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;AAAA;EAAAC,CAAA;IAAAC,CAAA;EAAA;AAAA,CAO9B,CAAC;AACF;AACA;AACA;AAAI,MAAMC,SAAS,gBAAGlB,QAAA;EAAAmB,yBAAA;IAAAC,MAAA;IAAAC,OAAA;EAAA;AAAA;EAAAL,CAAA;AAAA,CAKrB,CAAC;AACF;AACA;AACA;AAAI,OAAO,MAAMM,0BAA0B,GAAIC,KAAK,IAAG;EACnD,aAAa;;EACb,MAAMC,cAAc,GAAGhB,iBAAiB,CAAC,CAAC;EAC1C,MAAMiB,mBAAmB,GAAGhB,sBAAsB,CAAC,CAAC;EACpD,MAAMiB,MAAM,GAAGR,SAAS,CAAC,CAAC;EAC1BK,KAAK,CAACjB,IAAI,CAACqB,SAAS,GAAGzB,YAAY,CAACG,kBAAkB,CAACC,IAAI,EAAEkB,cAAc,EAAE,CAACD,KAAK,CAACK,UAAU,IAAIL,KAAK,CAACM,SAAS,KAAKH,MAAM,CAACP,yBAAyB,EAAEI,KAAK,CAACjB,IAAI,CAACqB,SAAS,CAAC;EAC7K,IAAIJ,KAAK,CAAChB,SAAS,EAAE;IACjBgB,KAAK,CAAChB,SAAS,CAACoB,SAAS,GAAGzB,YAAY,CAACG,kBAAkB,CAACE,SAAS,EAAEkB,mBAAmB,CAACnB,IAAI,EAAEiB,KAAK,CAAChB,SAAS,CAACoB,SAAS,CAAC;EAC/H;EACA,OAAOJ,KAAK;AAChB,CAAC","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+ export const ListItemActionEventName = 'ListItemAction';
3
+ export const createListItemActionEvent = (originalEvent)=>new CustomEvent(ListItemActionEventName, {
4
+ cancelable: true,
5
+ bubbles: true,
6
+ detail: {
7
+ originalEvent
8
+ }
9
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/events/ListItemActionEvent.ts"],"sourcesContent":["import * as React from 'react';\n\nexport const ListItemActionEventName = 'ListItemAction';\n\nexport interface ListItemActionEventDetail {\n originalEvent: React.MouseEvent | React.KeyboardEvent;\n}\n\nexport type ListItemActionEvent = CustomEvent<ListItemActionEventDetail>;\n\nexport const createListItemActionEvent = (\n originalEvent: React.MouseEvent | React.KeyboardEvent,\n): CustomEvent<ListItemActionEventDetail> =>\n new CustomEvent<ListItemActionEventDetail>(ListItemActionEventName, {\n cancelable: true,\n bubbles: true,\n detail: { originalEvent },\n });\n"],"names":["React","ListItemActionEventName","createListItemActionEvent","originalEvent","CustomEvent","cancelable","bubbles","detail"],"rangeMappings":";;;;;;;;","mappings":"AAAA,YAAYA,WAAW,QAAQ;AAE/B,OAAO,MAAMC,0BAA0B,iBAAiB;AAQxD,OAAO,MAAMC,4BAA4B,CACvCC,gBAEA,IAAIC,YAAuCH,yBAAyB;QAClEI,YAAY;QACZC,SAAS;QACTC,QAAQ;YAAEJ;QAAc;IAC1B,GAAG"}
@@ -0,0 +1 @@
1
+ export { useListSelection } from './useListSelection';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/index.ts"],"sourcesContent":["export { useListSelection } from './useListSelection';\n"],"names":["useListSelection"],"rangeMappings":"","mappings":"AAAA,SAASA,gBAAgB,QAAQ,qBAAqB"}
@@ -0,0 +1 @@
1
+ import * as React from 'react';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/types.ts"],"sourcesContent":["import { SelectionItemId } from '@fluentui/react-utilities';\nimport * as React from 'react';\n\nexport type ListSelectionState = {\n isSelected: (item: string | number) => boolean;\n toggleItem: (e: React.SyntheticEvent, id: string | number) => void;\n deselectItem: (e: React.SyntheticEvent, id: string | number) => void;\n selectItem: (e: React.SyntheticEvent, id: string | number) => void;\n clearSelection: (e: React.SyntheticEvent) => void;\n toggleAllItems: (e: React.SyntheticEvent, itemIds: string[] | number[]) => void;\n setSelectedItems: React.Dispatch<React.SetStateAction<Iterable<SelectionItemId>>>;\n selectedItems: SelectionItemId[];\n};\n"],"names":["React"],"rangeMappings":"","mappings":"AACA,YAAYA,WAAW,QAAQ"}
@@ -0,0 +1,41 @@
1
+ import { useControllableState, useEventCallback, useSelection } from '@fluentui/react-utilities';
2
+ import * as React from 'react';
3
+ export function useListSelection(options = {
4
+ selectionMode: 'multiselect'
5
+ }) {
6
+ const { selectionMode, defaultSelectedItems, onSelectionChange } = options;
7
+ const [selectedItems, setSelectedItems] = useControllableState({
8
+ state: options.selectedItems,
9
+ defaultState: defaultSelectedItems,
10
+ initialState: []
11
+ });
12
+ const [selected, selectionMethods] = useSelection({
13
+ selectionMode,
14
+ defaultSelectedItems,
15
+ selectedItems,
16
+ onSelectionChange: (e, data)=>{
17
+ setSelectedItems(data.selectedItems);
18
+ onSelectionChange === null || onSelectionChange === void 0 ? void 0 : onSelectionChange(e, data);
19
+ }
20
+ });
21
+ const toggleItem = useEventCallback((e, itemId)=>selectionMethods.toggleItem(e, itemId));
22
+ const toggleAllItems = useEventCallback((e, itemIds)=>{
23
+ selectionMethods.toggleAllItems(e, itemIds);
24
+ });
25
+ const deselectItem = useEventCallback((e, itemId)=>selectionMethods.deselectItem(e, itemId));
26
+ const selectItem = useEventCallback((e, itemId)=>selectionMethods.selectItem(e, itemId));
27
+ const clearSelection = useEventCallback((e)=>selectionMethods.clearItems(e));
28
+ const selectedArray = React.useMemo(()=>Array.from(selected), [
29
+ selected
30
+ ]);
31
+ return {
32
+ selectedItems: selectedArray,
33
+ toggleItem,
34
+ toggleAllItems,
35
+ deselectItem,
36
+ selectItem,
37
+ setSelectedItems,
38
+ isSelected: (id)=>selectionMethods.isSelected(id),
39
+ clearSelection
40
+ };
41
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/useListSelection.tsx"],"sourcesContent":["import { SelectionHookParams, useControllableState, useEventCallback, useSelection } from '@fluentui/react-utilities';\nimport * as React from 'react';\nimport type { ListSelectionState } from './types';\n\nexport function useListSelection(options: SelectionHookParams = { selectionMode: 'multiselect' }): ListSelectionState {\n const { selectionMode, defaultSelectedItems, onSelectionChange } = options;\n\n const [selectedItems, setSelectedItems] = useControllableState({\n state: options.selectedItems,\n defaultState: defaultSelectedItems,\n initialState: [],\n });\n\n const [selected, selectionMethods] = useSelection({\n selectionMode,\n defaultSelectedItems,\n selectedItems,\n onSelectionChange: (e, data) => {\n setSelectedItems(data.selectedItems);\n onSelectionChange?.(e, data);\n },\n });\n\n const toggleItem: ListSelectionState['toggleItem'] = useEventCallback((e, itemId) =>\n selectionMethods.toggleItem(e, itemId),\n );\n\n const toggleAllItems: ListSelectionState['toggleAllItems'] = useEventCallback((e, itemIds) => {\n selectionMethods.toggleAllItems(e, itemIds);\n });\n\n const deselectItem: ListSelectionState['deselectItem'] = useEventCallback((e, itemId: string | number) =>\n selectionMethods.deselectItem(e, itemId),\n );\n\n const selectItem: ListSelectionState['selectItem'] = useEventCallback((e, itemId: string | number) =>\n selectionMethods.selectItem(e, itemId),\n );\n\n const clearSelection: ListSelectionState['clearSelection'] = useEventCallback(e => selectionMethods.clearItems(e));\n\n const selectedArray = React.useMemo(() => Array.from(selected), [selected]);\n\n return {\n selectedItems: selectedArray,\n toggleItem,\n toggleAllItems,\n deselectItem,\n selectItem,\n setSelectedItems,\n isSelected: (id: string | number) => selectionMethods.isSelected(id),\n clearSelection,\n };\n}\n"],"names":["useControllableState","useEventCallback","useSelection","React","useListSelection","options","selectionMode","defaultSelectedItems","onSelectionChange","selectedItems","setSelectedItems","state","defaultState","initialState","selected","selectionMethods","e","data","toggleItem","itemId","toggleAllItems","itemIds","deselectItem","selectItem","clearSelection","clearItems","selectedArray","useMemo","Array","from","isSelected","id"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SAA8BA,oBAAoB,EAAEC,gBAAgB,EAAEC,YAAY,QAAQ,4BAA4B;AACtH,YAAYC,WAAW,QAAQ;AAG/B,OAAO,SAASC,iBAAiBC,UAA+B;IAAEC,eAAe;AAAc,CAAC;IAC9F,MAAM,EAAEA,aAAa,EAAEC,oBAAoB,EAAEC,iBAAiB,EAAE,GAAGH;IAEnE,MAAM,CAACI,eAAeC,iBAAiB,GAAGV,qBAAqB;QAC7DW,OAAON,QAAQI,aAAa;QAC5BG,cAAcL;QACdM,cAAc,EAAE;IAClB;IAEA,MAAM,CAACC,UAAUC,iBAAiB,GAAGb,aAAa;QAChDI;QACAC;QACAE;QACAD,mBAAmB,CAACQ,GAAGC;YACrBP,iBAAiBO,KAAKR,aAAa;YACnCD,8BAAAA,wCAAAA,kBAAoBQ,GAAGC;QACzB;IACF;IAEA,MAAMC,aAA+CjB,iBAAiB,CAACe,GAAGG,SACxEJ,iBAAiBG,UAAU,CAACF,GAAGG;IAGjC,MAAMC,iBAAuDnB,iBAAiB,CAACe,GAAGK;QAChFN,iBAAiBK,cAAc,CAACJ,GAAGK;IACrC;IAEA,MAAMC,eAAmDrB,iBAAiB,CAACe,GAAGG,SAC5EJ,iBAAiBO,YAAY,CAACN,GAAGG;IAGnC,MAAMI,aAA+CtB,iBAAiB,CAACe,GAAGG,SACxEJ,iBAAiBQ,UAAU,CAACP,GAAGG;IAGjC,MAAMK,iBAAuDvB,iBAAiBe,CAAAA,IAAKD,iBAAiBU,UAAU,CAACT;IAE/G,MAAMU,gBAAgBvB,MAAMwB,OAAO,CAAC,IAAMC,MAAMC,IAAI,CAACf,WAAW;QAACA;KAAS;IAE1E,OAAO;QACLL,eAAeiB;QACfR;QACAE;QACAE;QACAC;QACAb;QACAoB,YAAY,CAACC,KAAwBhB,iBAAiBe,UAAU,CAACC;QACjEP;IACF;AACF"}
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { List, listClassNames, renderList_unstable, useListStyles_unstable, useList_unstable } from './List';
2
+ export { ListItem, listItemClassNames, renderListItem_unstable, useListItemStyles_unstable, useListItem_unstable } from './ListItem';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { List, listClassNames, renderList_unstable, useListStyles_unstable, useList_unstable } from './List';\n\nexport type { ListProps, ListSlots, ListState } from './List';\nexport {\n ListItem,\n listItemClassNames,\n renderListItem_unstable,\n useListItemStyles_unstable,\n useListItem_unstable,\n} from './ListItem';\nexport type { ListItemProps, ListItemSlots, ListItemState } from './ListItem';\n"],"names":["List","listClassNames","renderList_unstable","useListStyles_unstable","useList_unstable","ListItem","listItemClassNames","renderListItem_unstable","useListItemStyles_unstable","useListItem_unstable"],"rangeMappings":";","mappings":"AAAA,SAASA,IAAI,EAAEC,cAAc,EAAEC,mBAAmB,EAAEC,sBAAsB,EAAEC,gBAAgB,QAAQ,SAAS;AAG7G,SACEC,QAAQ,EACRC,kBAAkB,EAClBC,uBAAuB,EACvBC,0BAA0B,EAC1BC,oBAAoB,QACf,aAAa"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Calculate the role for the list item based on the list role.
3
+ * @param listRole - the role of the list
4
+ * @returns proper role for the list item
5
+ */ export const calculateListItemRoleForListRole = (listRole)=>{
6
+ switch(listRole){
7
+ case 'list':
8
+ return 'listitem';
9
+ case 'listbox':
10
+ return 'option';
11
+ case 'grid':
12
+ return 'row';
13
+ default:
14
+ return 'listitem';
15
+ }
16
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/calculateListItemRoleForListRole.ts"],"sourcesContent":["/**\n * Calculate the role for the list item based on the list role.\n * @param listRole - the role of the list\n * @returns proper role for the list item\n */\nexport const calculateListItemRoleForListRole = (listRole: string): string => {\n switch (listRole) {\n case 'list':\n return 'listitem';\n case 'listbox':\n return 'option';\n case 'grid':\n return 'row';\n default:\n return 'listitem';\n }\n};\n"],"names":["calculateListItemRoleForListRole","listRole"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAAA;;;;CAIC,GACD,OAAO,MAAMA,mCAAmC,CAACC;IAC/C,OAAQA;QACN,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT,KAAK;YACH,OAAO;QACT;YACE,OAAO;IACX;AACF,EAAE"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Calculate the role for the list based on the navigation mode and selectable state
3
+ * @param navigationMode - the navigation mode of the list
4
+ * @param selectable - whether the list is selectable
5
+ * @returns 'grid' if navigationMode is 'composite', otherwise 'listbox' if selectable or 'list' if not
6
+ */ export const calculateListRole = (navigationMode, selectable)=>{
7
+ if (navigationMode === 'composite') {
8
+ return 'grid';
9
+ } else if (selectable) {
10
+ return 'listbox';
11
+ } else {
12
+ return 'list';
13
+ }
14
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/calculateListRole.ts"],"sourcesContent":["import { ListNavigationMode } from '../List';\n\n/**\n * Calculate the role for the list based on the navigation mode and selectable state\n * @param navigationMode - the navigation mode of the list\n * @param selectable - whether the list is selectable\n * @returns 'grid' if navigationMode is 'composite', otherwise 'listbox' if selectable or 'list' if not\n */\n\nexport const calculateListRole = (navigationMode: ListNavigationMode | undefined, selectable: boolean) => {\n if (navigationMode === 'composite') {\n return 'grid';\n } else if (selectable) {\n return 'listbox';\n } else {\n return 'list';\n }\n};\n"],"names":["calculateListRole","navigationMode","selectable"],"rangeMappings":";;;;;;;;;;;;;","mappings":"AAEA;;;;;CAKC,GAED,OAAO,MAAMA,oBAAoB,CAACC,gBAAgDC;IAChF,IAAID,mBAAmB,aAAa;QAClC,OAAO;IACT,OAAO,IAAIC,YAAY;QACrB,OAAO;IACT,OAAO;QACL,OAAO;IACT;AACF,EAAE"}
@@ -0,0 +1,5 @@
1
+ export { calculateListRole } from './calculateListRole';
2
+ export { validateProperElementTypes } from './validateProperElementTypes';
3
+ export { validateProperRolesAreUsed } from './validateProperRolesAreUsed';
4
+ export { calculateListItemRoleForListRole } from './calculateListItemRoleForListRole';
5
+ export { validateGridCellsArePresent } from './validateGridCellsArePresent';
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utils/index.ts"],"sourcesContent":["export { calculateListRole } from './calculateListRole';\nexport { validateProperElementTypes } from './validateProperElementTypes';\nexport { validateProperRolesAreUsed } from './validateProperRolesAreUsed';\nexport { calculateListItemRoleForListRole } from './calculateListItemRoleForListRole';\nexport { validateGridCellsArePresent } from './validateGridCellsArePresent';\n"],"names":["calculateListRole","validateProperElementTypes","validateProperRolesAreUsed","calculateListItemRoleForListRole","validateGridCellsArePresent"],"rangeMappings":";;;;","mappings":"AAAA,SAASA,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,0BAA0B,QAAQ,+BAA+B;AAC1E,SAASC,0BAA0B,QAAQ,+BAA+B;AAC1E,SAASC,gCAAgC,QAAQ,qCAAqC;AACtF,SAASC,2BAA2B,QAAQ,gCAAgC"}