@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.
- package/CHANGELOG.json +31 -1
- package/CHANGELOG.md +18 -2
- package/README.md +10 -11
- package/babel.config.js +1 -1
- package/lib/component-patterns/render.d.ts +8 -0
- package/lib/component-patterns/render.d.ts.map +1 -0
- package/lib/component-patterns/render.js +42 -0
- package/lib/component-patterns/render.js.map +1 -0
- package/lib/component-patterns/render.types.d.ts +98 -0
- package/lib/component-patterns/render.types.d.ts.map +1 -0
- package/lib/component-patterns/render.types.js +2 -0
- package/lib/component-patterns/render.types.js.map +1 -0
- package/lib/component-patterns/stagedComponent.d.ts +7 -31
- package/lib/component-patterns/stagedComponent.d.ts.map +1 -1
- package/lib/component-patterns/stagedComponent.js +18 -0
- package/lib/component-patterns/stagedComponent.js.map +1 -1
- package/lib/component-patterns/withSlots.d.ts +2 -2
- package/lib/component-patterns/withSlots.d.ts.map +1 -1
- package/lib/component-patterns/withSlots.js +2 -2
- package/lib/component-patterns/withSlots.js.map +1 -1
- package/lib/index.d.ts +4 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -2
- package/lib/index.js.map +1 -1
- package/lib/jsx-runtime.d.ts +4 -0
- package/lib/jsx-runtime.d.ts.map +1 -0
- package/lib/jsx-runtime.js +9 -0
- package/lib/jsx-runtime.js.map +1 -0
- package/lib/merge-props/mergeStyles.test.js.map +1 -1
- package/lib-commonjs/component-patterns/render.d.ts +8 -0
- package/lib-commonjs/component-patterns/render.d.ts.map +1 -0
- package/lib-commonjs/component-patterns/render.js +73 -0
- package/lib-commonjs/component-patterns/render.js.map +1 -0
- package/lib-commonjs/component-patterns/render.types.d.ts +98 -0
- package/lib-commonjs/component-patterns/render.types.d.ts.map +1 -0
- package/lib-commonjs/component-patterns/render.types.js +3 -0
- package/lib-commonjs/component-patterns/render.types.js.map +1 -0
- package/lib-commonjs/component-patterns/stagedComponent.d.ts +7 -31
- package/lib-commonjs/component-patterns/stagedComponent.d.ts.map +1 -1
- package/lib-commonjs/component-patterns/stagedComponent.js +44 -3
- package/lib-commonjs/component-patterns/stagedComponent.js.map +1 -1
- package/lib-commonjs/component-patterns/withSlots.d.ts +2 -2
- package/lib-commonjs/component-patterns/withSlots.d.ts.map +1 -1
- package/lib-commonjs/component-patterns/withSlots.js +2 -2
- package/lib-commonjs/component-patterns/withSlots.js.map +1 -1
- package/lib-commonjs/index.d.ts +4 -4
- package/lib-commonjs/index.d.ts.map +1 -1
- package/lib-commonjs/index.js +9 -3
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/jsx-runtime.d.ts +4 -0
- package/lib-commonjs/jsx-runtime.d.ts.map +1 -0
- package/lib-commonjs/jsx-runtime.js +37 -0
- package/lib-commonjs/jsx-runtime.js.map +1 -0
- package/lib-commonjs/merge-props/mergeStyles.test.js.map +1 -1
- package/package.json +12 -1
- package/src/component-patterns/README.md +39 -0
- package/src/component-patterns/render.ts +54 -0
- package/src/component-patterns/render.types.ts +114 -0
- package/src/component-patterns/stagedComponent.tsx +45 -0
- package/src/component-patterns/withSlots.tsx +4 -8
- package/src/immutable-merge/README.md +185 -0
- package/src/index.ts +17 -4
- package/src/jsx-runtime.ts +11 -0
- package/src/memo-cache/README.md +141 -0
- package/src/merge-props/README.md +43 -0
- package/src/merge-props/mergeStyles.test.ts +3 -2
- package/lib/component-patterns/renderSlot.d.ts +0 -21
- package/lib/component-patterns/renderSlot.d.ts.map +0 -1
- package/lib/component-patterns/renderSlot.js +0 -14
- package/lib/component-patterns/renderSlot.js.map +0 -1
- package/lib-commonjs/component-patterns/renderSlot.d.ts +0 -21
- package/lib-commonjs/component-patterns/renderSlot.d.ts.map +0 -1
- package/lib-commonjs/component-patterns/renderSlot.js +0 -19
- package/lib-commonjs/component-patterns/renderSlot.js.map +0 -1
- package/src/component-patterns/renderSlot.ts +0 -27
- 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
|
-
}
|