@fluentui/react-utilities 0.0.0-nightlycc44f3625c20211220.1 → 0.0.0-nightlyd80c90385320220216.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 (84) hide show
  1. package/CHANGELOG.json +93 -6
  2. package/CHANGELOG.md +25 -6
  3. package/dist/react-utilities.d.ts +193 -78
  4. package/lib/compose/getSlots.d.ts +7 -8
  5. package/lib/compose/getSlots.js +3 -4
  6. package/lib/compose/getSlots.js.map +1 -1
  7. package/lib/compose/index.d.ts +0 -1
  8. package/lib/compose/index.js +0 -1
  9. package/lib/compose/index.js.map +1 -1
  10. package/lib/compose/resolveShorthand.d.ts +10 -6
  11. package/lib/compose/resolveShorthand.js +5 -5
  12. package/lib/compose/resolveShorthand.js.map +1 -1
  13. package/lib/compose/types.d.ts +86 -34
  14. package/lib/compose/types.js.map +1 -1
  15. package/lib/hooks/index.d.ts +1 -0
  16. package/lib/hooks/index.js +1 -0
  17. package/lib/hooks/index.js.map +1 -1
  18. package/lib/hooks/useMergedEventCallbacks.d.ts +18 -0
  19. package/lib/hooks/useMergedEventCallbacks.js +26 -0
  20. package/lib/hooks/useMergedEventCallbacks.js.map +1 -0
  21. package/lib/utils/applyTriggerPropsToChildren.d.ts +1 -1
  22. package/lib/utils/applyTriggerPropsToChildren.js +23 -3
  23. package/lib/utils/applyTriggerPropsToChildren.js.map +1 -1
  24. package/lib/utils/getNativeElementProps.d.ts +4 -4
  25. package/lib/utils/getNativeElementProps.js.map +1 -1
  26. package/lib/utils/getReactCallbackName.d.ts +25 -0
  27. package/lib/utils/getReactCallbackName.js +26 -0
  28. package/lib/utils/getReactCallbackName.js.map +1 -0
  29. package/lib/utils/getTriggerChild.d.ts +22 -0
  30. package/lib/utils/getTriggerChild.js +26 -0
  31. package/lib/utils/getTriggerChild.js.map +1 -0
  32. package/lib/utils/index.d.ts +2 -1
  33. package/lib/utils/index.js +2 -1
  34. package/lib/utils/index.js.map +1 -1
  35. package/lib/utils/isFluentTrigger.d.ts +22 -0
  36. package/lib/utils/isFluentTrigger.js +8 -0
  37. package/lib/utils/isFluentTrigger.js.map +1 -0
  38. package/lib-commonjs/compose/getSlots.d.ts +7 -8
  39. package/lib-commonjs/compose/getSlots.js +3 -5
  40. package/lib-commonjs/compose/getSlots.js.map +1 -1
  41. package/lib-commonjs/compose/index.d.ts +0 -1
  42. package/lib-commonjs/compose/index.js +0 -2
  43. package/lib-commonjs/compose/index.js.map +1 -1
  44. package/lib-commonjs/compose/resolveShorthand.d.ts +10 -6
  45. package/lib-commonjs/compose/resolveShorthand.js +5 -5
  46. package/lib-commonjs/compose/resolveShorthand.js.map +1 -1
  47. package/lib-commonjs/compose/types.d.ts +86 -34
  48. package/lib-commonjs/compose/types.js.map +1 -1
  49. package/lib-commonjs/hooks/index.d.ts +1 -0
  50. package/lib-commonjs/hooks/index.js +2 -0
  51. package/lib-commonjs/hooks/index.js.map +1 -1
  52. package/lib-commonjs/hooks/useMergedEventCallbacks.d.ts +18 -0
  53. package/lib-commonjs/hooks/useMergedEventCallbacks.js +36 -0
  54. package/lib-commonjs/hooks/useMergedEventCallbacks.js.map +1 -0
  55. package/lib-commonjs/utils/applyTriggerPropsToChildren.d.ts +1 -1
  56. package/lib-commonjs/utils/applyTriggerPropsToChildren.js +24 -4
  57. package/lib-commonjs/utils/applyTriggerPropsToChildren.js.map +1 -1
  58. package/lib-commonjs/utils/getNativeElementProps.d.ts +4 -4
  59. package/lib-commonjs/utils/getNativeElementProps.js.map +1 -1
  60. package/lib-commonjs/utils/getReactCallbackName.d.ts +25 -0
  61. package/lib-commonjs/utils/getReactCallbackName.js +35 -0
  62. package/lib-commonjs/utils/getReactCallbackName.js.map +1 -0
  63. package/lib-commonjs/utils/getTriggerChild.d.ts +22 -0
  64. package/lib-commonjs/utils/getTriggerChild.js +37 -0
  65. package/lib-commonjs/utils/getTriggerChild.js.map +1 -0
  66. package/lib-commonjs/utils/index.d.ts +2 -1
  67. package/lib-commonjs/utils/index.js +4 -2
  68. package/lib-commonjs/utils/index.js.map +1 -1
  69. package/lib-commonjs/utils/isFluentTrigger.d.ts +22 -0
  70. package/lib-commonjs/utils/isFluentTrigger.js +17 -0
  71. package/lib-commonjs/utils/isFluentTrigger.js.map +1 -0
  72. package/package.json +3 -3
  73. package/lib/compose/nullRender.d.ts +0 -4
  74. package/lib/compose/nullRender.js +0 -5
  75. package/lib/compose/nullRender.js.map +0 -1
  76. package/lib/utils/onlyChild.d.ts +0 -5
  77. package/lib/utils/onlyChild.js +0 -13
  78. package/lib/utils/onlyChild.js.map +0 -1
  79. package/lib-commonjs/compose/nullRender.d.ts +0 -4
  80. package/lib-commonjs/compose/nullRender.js +0 -14
  81. package/lib-commonjs/compose/nullRender.js.map +0 -1
  82. package/lib-commonjs/utils/onlyChild.d.ts +0 -5
  83. package/lib-commonjs/utils/onlyChild.js +0 -23
  84. package/lib-commonjs/utils/onlyChild.js.map +0 -1
@@ -14,9 +14,11 @@ tslib_1.__exportStar(require("./getNativeElementProps"), exports);
14
14
 
15
15
  tslib_1.__exportStar(require("./getRTLSafeKey"), exports);
16
16
 
17
- tslib_1.__exportStar(require("./omit"), exports);
17
+ tslib_1.__exportStar(require("./getTriggerChild"), exports);
18
+
19
+ tslib_1.__exportStar(require("./isFluentTrigger"), exports);
18
20
 
19
- tslib_1.__exportStar(require("./onlyChild"), exports);
21
+ tslib_1.__exportStar(require("./omit"), exports);
20
22
 
21
23
  tslib_1.__exportStar(require("./properties"), exports);
22
24
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,+BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,yBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,QAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,cAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iCAAA,CAAA,EAAA,OAAA","sourceRoot":""}
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,+BAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,SAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,yBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,mBAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,QAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,cAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,iCAAA,CAAA,EAAA,OAAA","sourceRoot":""}
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+ /**
3
+ * Allows a component to be tagged as a FluentUI trigger component.
4
+ *
5
+ * Triggers are special-case components: they attach event listeners and other props on their child,
6
+ * and use them to trigger another component to show. Examples include `MenuTrigger` and `Tooltip`.
7
+ *
8
+ * A component can be tagged as a trigger as follows:
9
+ * ```ts
10
+ * const MyComponent: React.FC<MyComponentProps> & FluentTriggerComponent = ...;
11
+ *
12
+ * MyComponent.isFluentTriggerComponent = true; // MUST also set this to true
13
+ * ```
14
+ */
15
+ export declare type FluentTriggerComponent = {
16
+ isFluentTriggerComponent?: boolean;
17
+ };
18
+ /**
19
+ * Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).
20
+ * See the {@link FluentTriggerComponent} type for more info.
21
+ */
22
+ export declare const isFluentTrigger: (element: React.ReactElement) => boolean | undefined;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isFluentTrigger = void 0;
7
+ /**
8
+ * Checks if a given element is a FluentUI trigger (e.g. `MenuTrigger` or `Tooltip`).
9
+ * See the {@link FluentTriggerComponent} type for more info.
10
+ */
11
+
12
+ const isFluentTrigger = element => {
13
+ return element.type.isFluentTriggerComponent;
14
+ };
15
+
16
+ exports.isFluentTrigger = isFluentTrigger;
17
+ //# sourceMappingURL=isFluentTrigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/isFluentTrigger.ts"],"names":[],"mappings":";;;;;;AAmBA;;;AAGG;;AACI,MAAM,eAAe,GAAI,OAAD,IAAgC;AAC7D,SAAQ,OAAO,CAAC,IAAR,CAAwC,wBAAhD;AACD,CAFM;;AAAM,OAAA,CAAA,eAAA,GAAe,eAAf","sourceRoot":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluentui/react-utilities",
3
- "version": "0.0.0-nightlycc44f3625c20211220.1",
3
+ "version": "0.0.0-nightlyd80c90385320220216.1",
4
4
  "description": "A set of general React-specific utilities.",
5
5
  "main": "lib-commonjs/index.js",
6
6
  "module": "lib/index.js",
@@ -18,7 +18,7 @@
18
18
  "code-style": "just-scripts code-style",
19
19
  "just": "just-scripts",
20
20
  "lint": "just-scripts lint",
21
- "test": "jest",
21
+ "test": "jest --passWithNoTests",
22
22
  "docs": "api-extractor run --config=config/api-extractor.local.json --local",
23
23
  "build:local": "tsc -p ./tsconfig.lib.json --module esnext --emitDeclarationOnly && node ../../scripts/typescript/normalize-import --output ./dist/packages/react-utilities/src && yarn docs",
24
24
  "start": "yarn storybook",
@@ -33,7 +33,7 @@
33
33
  "react-test-renderer": "^16.3.0"
34
34
  },
35
35
  "dependencies": {
36
- "@fluentui/keyboard-keys": "0.0.0-nightlycc44f3625c20211220.1",
36
+ "@fluentui/keyboard-keys": "0.0.0-nightlyd80c90385320220216.1",
37
37
  "tslib": "^2.1.0"
38
38
  },
39
39
  "peerDependencies": {
@@ -1,4 +0,0 @@
1
- /**
2
- * Simple constant function for returning null, used to render empty templates in JSX.
3
- */
4
- export declare const nullRender: () => null;
@@ -1,5 +0,0 @@
1
- /**
2
- * Simple constant function for returning null, used to render empty templates in JSX.
3
- */
4
- export const nullRender = () => null;
5
- //# sourceMappingURL=nullRender.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"nullRender.js","sourceRoot":"","sources":["../../src/compose/nullRender.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC"}
@@ -1,5 +0,0 @@
1
- import * as React from 'react';
2
- /**
3
- * Similar to React.Children.only, but drills into fragments rather than treating them as a single child
4
- */
5
- export declare const onlyChild: <P>(child: boolean | React.ReactText | React.ReactFragment | React.ReactPortal | React.ReactElement<P, string | React.JSXElementConstructor<any>> | null | undefined) => React.ReactElement<P, string | React.JSXElementConstructor<any>>;
@@ -1,13 +0,0 @@
1
- import * as React from 'react';
2
- /**
3
- * Similar to React.Children.only, but drills into fragments rather than treating them as a single child
4
- */
5
-
6
- export const onlyChild = child => {
7
- if (! /*#__PURE__*/React.isValidElement(child)) {
8
- throw new Error(`Component's child must be a single element`);
9
- }
10
-
11
- return child.type === React.Fragment ? onlyChild(child.props.children) : child;
12
- };
13
- //# sourceMappingURL=onlyChild.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/onlyChild.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AAEA;;AAEG;;AACH,OAAO,MAAM,SAAS,GACpB,KADuB,IAEE;AACzB,MAAI,eAAC,KAAK,CAAC,cAAN,CAAqB,KAArB,CAAL,EAAkC;AAChC,UAAM,IAAI,KAAJ,CAAU,4CAAV,CAAN;AACD;;AAED,SAAO,KAAK,CAAC,IAAN,KAAe,KAAK,CAAC,QAArB,GAAgC,SAAS,CAAC,KAAK,CAAC,KAAN,CAAY,QAAb,CAAzC,GAAkE,KAAzE;AACD,CARM","sourceRoot":""}
@@ -1,4 +0,0 @@
1
- /**
2
- * Simple constant function for returning null, used to render empty templates in JSX.
3
- */
4
- export declare const nullRender: () => null;
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.nullRender = void 0;
7
- /**
8
- * Simple constant function for returning null, used to render empty templates in JSX.
9
- */
10
-
11
- const nullRender = () => null;
12
-
13
- exports.nullRender = nullRender;
14
- //# sourceMappingURL=nullRender.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/compose/nullRender.tsx"],"names":[],"mappings":";;;;;;AAAA;;AAEG;;AACI,MAAM,UAAU,GAAG,MAAM,IAAzB;;AAAM,OAAA,CAAA,UAAA,GAAU,UAAV","sourceRoot":""}
@@ -1,5 +0,0 @@
1
- import * as React from 'react';
2
- /**
3
- * Similar to React.Children.only, but drills into fragments rather than treating them as a single child
4
- */
5
- export declare const onlyChild: <P>(child: boolean | React.ReactText | React.ReactFragment | React.ReactPortal | React.ReactElement<P, string | React.JSXElementConstructor<any>> | null | undefined) => React.ReactElement<P, string | React.JSXElementConstructor<any>>;
@@ -1,23 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.onlyChild = void 0;
7
-
8
- const React = /*#__PURE__*/require("react");
9
- /**
10
- * Similar to React.Children.only, but drills into fragments rather than treating them as a single child
11
- */
12
-
13
-
14
- const onlyChild = child => {
15
- if (!React.isValidElement(child)) {
16
- throw new Error(`Component's child must be a single element`);
17
- }
18
-
19
- return child.type === React.Fragment ? exports.onlyChild(child.props.children) : child;
20
- };
21
-
22
- exports.onlyChild = onlyChild;
23
- //# sourceMappingURL=onlyChild.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/utils/onlyChild.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;AAEA;;AAEG;;;AACI,MAAM,SAAS,GACpB,KADuB,IAEE;AACzB,MAAI,CAAC,KAAK,CAAC,cAAN,CAAqB,KAArB,CAAL,EAAkC;AAChC,UAAM,IAAI,KAAJ,CAAU,4CAAV,CAAN;AACD;;AAED,SAAO,KAAK,CAAC,IAAN,KAAe,KAAK,CAAC,QAArB,GAAgC,OAAA,CAAA,SAAA,CAAU,KAAK,CAAC,KAAN,CAAY,QAAtB,CAAhC,GAAkE,KAAzE;AACD,CARM;;AAAM,OAAA,CAAA,SAAA,GAAS,SAAT","sourceRoot":""}