@fluentui-react-native/framework-base 0.1.4 → 0.2.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 (76) hide show
  1. package/CHANGELOG.json +31 -1
  2. package/CHANGELOG.md +18 -2
  3. package/README.md +10 -11
  4. package/babel.config.js +1 -1
  5. package/lib/component-patterns/render.d.ts +8 -0
  6. package/lib/component-patterns/render.d.ts.map +1 -0
  7. package/lib/component-patterns/render.js +42 -0
  8. package/lib/component-patterns/render.js.map +1 -0
  9. package/lib/component-patterns/render.types.d.ts +98 -0
  10. package/lib/component-patterns/render.types.d.ts.map +1 -0
  11. package/lib/component-patterns/render.types.js +2 -0
  12. package/lib/component-patterns/render.types.js.map +1 -0
  13. package/lib/component-patterns/stagedComponent.d.ts +7 -31
  14. package/lib/component-patterns/stagedComponent.d.ts.map +1 -1
  15. package/lib/component-patterns/stagedComponent.js +18 -0
  16. package/lib/component-patterns/stagedComponent.js.map +1 -1
  17. package/lib/component-patterns/withSlots.d.ts +2 -2
  18. package/lib/component-patterns/withSlots.d.ts.map +1 -1
  19. package/lib/component-patterns/withSlots.js +2 -2
  20. package/lib/component-patterns/withSlots.js.map +1 -1
  21. package/lib/index.d.ts +4 -4
  22. package/lib/index.d.ts.map +1 -1
  23. package/lib/index.js +3 -2
  24. package/lib/index.js.map +1 -1
  25. package/lib/jsx-runtime.d.ts +4 -0
  26. package/lib/jsx-runtime.d.ts.map +1 -0
  27. package/lib/jsx-runtime.js +9 -0
  28. package/lib/jsx-runtime.js.map +1 -0
  29. package/lib/merge-props/mergeStyles.test.js.map +1 -1
  30. package/lib-commonjs/component-patterns/render.d.ts +8 -0
  31. package/lib-commonjs/component-patterns/render.d.ts.map +1 -0
  32. package/lib-commonjs/component-patterns/render.js +73 -0
  33. package/lib-commonjs/component-patterns/render.js.map +1 -0
  34. package/lib-commonjs/component-patterns/render.types.d.ts +98 -0
  35. package/lib-commonjs/component-patterns/render.types.d.ts.map +1 -0
  36. package/lib-commonjs/component-patterns/render.types.js +3 -0
  37. package/lib-commonjs/component-patterns/render.types.js.map +1 -0
  38. package/lib-commonjs/component-patterns/stagedComponent.d.ts +7 -31
  39. package/lib-commonjs/component-patterns/stagedComponent.d.ts.map +1 -1
  40. package/lib-commonjs/component-patterns/stagedComponent.js +44 -3
  41. package/lib-commonjs/component-patterns/stagedComponent.js.map +1 -1
  42. package/lib-commonjs/component-patterns/withSlots.d.ts +2 -2
  43. package/lib-commonjs/component-patterns/withSlots.d.ts.map +1 -1
  44. package/lib-commonjs/component-patterns/withSlots.js +2 -2
  45. package/lib-commonjs/component-patterns/withSlots.js.map +1 -1
  46. package/lib-commonjs/index.d.ts +4 -4
  47. package/lib-commonjs/index.d.ts.map +1 -1
  48. package/lib-commonjs/index.js +9 -3
  49. package/lib-commonjs/index.js.map +1 -1
  50. package/lib-commonjs/jsx-runtime.d.ts +4 -0
  51. package/lib-commonjs/jsx-runtime.d.ts.map +1 -0
  52. package/lib-commonjs/jsx-runtime.js +37 -0
  53. package/lib-commonjs/jsx-runtime.js.map +1 -0
  54. package/lib-commonjs/merge-props/mergeStyles.test.js.map +1 -1
  55. package/package.json +12 -1
  56. package/src/component-patterns/README.md +39 -0
  57. package/src/component-patterns/render.ts +54 -0
  58. package/src/component-patterns/render.types.ts +114 -0
  59. package/src/component-patterns/stagedComponent.tsx +45 -0
  60. package/src/component-patterns/withSlots.tsx +4 -8
  61. package/src/immutable-merge/README.md +185 -0
  62. package/src/index.ts +17 -4
  63. package/src/jsx-runtime.ts +11 -0
  64. package/src/memo-cache/README.md +141 -0
  65. package/src/merge-props/README.md +43 -0
  66. package/src/merge-props/mergeStyles.test.ts +3 -2
  67. package/lib/component-patterns/renderSlot.d.ts +0 -21
  68. package/lib/component-patterns/renderSlot.d.ts.map +0 -1
  69. package/lib/component-patterns/renderSlot.js +0 -14
  70. package/lib/component-patterns/renderSlot.js.map +0 -1
  71. package/lib-commonjs/component-patterns/renderSlot.d.ts +0 -21
  72. package/lib-commonjs/component-patterns/renderSlot.d.ts.map +0 -1
  73. package/lib-commonjs/component-patterns/renderSlot.js +0 -19
  74. package/lib-commonjs/component-patterns/renderSlot.js.map +0 -1
  75. package/src/component-patterns/renderSlot.ts +0 -27
  76. package/src/component-patterns/stagedComponent.ts +0 -53
@@ -1,21 +0,0 @@
1
- import * as React from 'react';
2
- /**
3
- * Component slots have a marker which allows the slot render handler to know which ones are safe to call as a function.
4
- */
5
- export type SlotFn<TProps> = React.FunctionComponent<TProps> & {
6
- _canCompose?: boolean;
7
- };
8
- /**
9
- * The standard element type inputs for react and react-native. This might be View or Button, or it might be 'div' in web. Effectively
10
- * it is what react accepts for React.createElement
11
- */
12
- export type NativeReactType = React.ElementType<any> | string;
13
- /**
14
- * Renders a slot
15
- *
16
- * @param slot - native react type or slot function to render
17
- * @param extraProps - additional props to mixin
18
- * @param children - the children to pass down to the slot
19
- */
20
- export declare function renderSlot<TProps>(slot: NativeReactType | SlotFn<TProps>, extraProps: TProps, ...children: React.ReactNode[]): React.ReactElement<any, any>;
21
- //# sourceMappingURL=renderSlot.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderSlot.d.ts","sourceRoot":"","sources":["../../src/component-patterns/renderSlot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,MAAM,MAAM,MAAM,CAAC,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,GAAG;IAC7D,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;AAE9D;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,gCAI5H"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.renderSlot = void 0;
4
- const tslib_1 = require("tslib");
5
- const React = tslib_1.__importStar(require("react"));
6
- /**
7
- * Renders a slot
8
- *
9
- * @param slot - native react type or slot function to render
10
- * @param extraProps - additional props to mixin
11
- * @param children - the children to pass down to the slot
12
- */
13
- function renderSlot(slot, extraProps, ...children) {
14
- return typeof slot === 'function' && slot._canCompose
15
- ? slot(extraProps, ...children)
16
- : React.createElement(slot, extraProps, ...children);
17
- }
18
- exports.renderSlot = renderSlot;
19
- //# sourceMappingURL=renderSlot.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"renderSlot.js","sourceRoot":"","sources":["../../src/component-patterns/renderSlot.ts"],"names":[],"mappings":";;;;AAAA,qDAA+B;AAe/B;;;;;;GAMG;AACH,SAAgB,UAAU,CAAS,IAAsC,EAAE,UAAkB,EAAE,GAAG,QAA2B;IAC3H,OAAO,OAAO,IAAI,KAAK,UAAU,IAAK,IAAuB,CAAC,WAAW;QACvE,CAAC,CAAE,IAAuB,CAAC,UAAU,EAAE,GAAG,QAAQ,CAAC;QACnD,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC,CAAC;AACzD,CAAC;AAJD,gCAIC"}
@@ -1,27 +0,0 @@
1
- import * as React from 'react';
2
-
3
- /**
4
- * Component slots have a marker which allows the slot render handler to know which ones are safe to call as a function.
5
- */
6
- export type SlotFn<TProps> = React.FunctionComponent<TProps> & {
7
- _canCompose?: boolean;
8
- };
9
-
10
- /**
11
- * The standard element type inputs for react and react-native. This might be View or Button, or it might be 'div' in web. Effectively
12
- * it is what react accepts for React.createElement
13
- */
14
- export type NativeReactType = React.ElementType<any> | string;
15
-
16
- /**
17
- * Renders a slot
18
- *
19
- * @param slot - native react type or slot function to render
20
- * @param extraProps - additional props to mixin
21
- * @param children - the children to pass down to the slot
22
- */
23
- export function renderSlot<TProps>(slot: NativeReactType | SlotFn<TProps>, extraProps: TProps, ...children: React.ReactNode[]) {
24
- return typeof slot === 'function' && (slot as SlotFn<TProps>)._canCompose
25
- ? (slot as SlotFn<TProps>)(extraProps, ...children)
26
- : React.createElement(slot, extraProps, ...children);
27
- }
@@ -1,53 +0,0 @@
1
- import * as React from 'react';
2
-
3
- /**
4
- * The final rendering of the props in a staged render. This is the function component signature that matches that of
5
- * React.createElement, children (if present) will be part of the variable args at the end.
6
- */
7
- export type FinalRender<TProps> = (props: TProps, ...children: React.ReactNode[]) => JSX.Element | null;
8
-
9
- /**
10
- * This is a pattern of rendering where a functional component can be executed in two stages rather than in a single pass.
11
- *
12
- * The pattern looks like:
13
- * (props) => {
14
- * // handle props
15
- * // call hooks, remember these can't be conditional
16
- * // build styles and props to pass to child components
17
- *
18
- * return (additionalProps, ...children) => {
19
- * // return the actual element tree, this includes conditional branching or rendering
20
- * // mixin additional props, props which require logic should be required in phase 1.
21
- *
22
- * // NOTE: This is where children will show up
23
- * };
24
- * }
25
- */
26
-
27
- export type StagedRender<TProps> = (props: TProps, ...args: any[]) => FinalRender<TProps>;
28
-
29
- /**
30
- * A composable function may have a two stage render function as an attached property. This allows the function to work
31
- * in all the standard react flows, but allows for pulling out the staged render when components understand it.
32
- */
33
- export type ComposableFunction<TProps> = React.FunctionComponent<TProps> & { _staged?: StagedRender<TProps> };
34
-
35
- function asArray<T>(val: T | T[]): T[] {
36
- return Array.isArray(val) ? val : [val];
37
- }
38
-
39
- /**
40
- * Take a staged render function and make a real component out of it
41
- *
42
- * @param staged - staged render function to wrap into a staged component
43
- * @param memo - optional flag to enable wrapping the created component in a React.memo HOC
44
- */
45
- export function stagedComponent<TProps>(staged: StagedRender<TProps>, memo?: boolean): ComposableFunction<TProps> {
46
- const component = (props: React.PropsWithChildren<TProps>) => {
47
- const { children, ...rest } = props;
48
- return staged(rest as TProps)({} as React.PropsWithChildren<TProps>, asArray(children));
49
- };
50
- const stagedComponent = memo ? React.memo(component) : component;
51
- Object.assign(stagedComponent, { _staged: staged });
52
- return stagedComponent as ComposableFunction<TProps>;
53
- }