@fluentui-react-native/framework-base 0.2.1 → 0.3.0
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 +1 -1
- package/CHANGELOG.md +35 -2
- package/README.md +18 -1
- package/babel.config.js +1 -1
- package/jsx-runtime.js +1 -0
- package/lib/component-patterns/directComponent.d.ts +7 -0
- package/lib/component-patterns/directComponent.d.ts.map +1 -0
- package/lib/component-patterns/directComponent.js +8 -0
- package/lib/component-patterns/directComponent.js.map +1 -0
- package/lib/component-patterns/extract.d.ts +22 -0
- package/lib/component-patterns/extract.d.ts.map +1 -0
- package/lib/component-patterns/extract.js +25 -0
- package/lib/component-patterns/extract.js.map +1 -0
- package/lib/component-patterns/phasedComponent.d.ts +18 -0
- package/lib/component-patterns/phasedComponent.d.ts.map +1 -0
- package/lib/component-patterns/phasedComponent.js +51 -0
- package/lib/component-patterns/phasedComponent.js.map +1 -0
- package/lib/component-patterns/render.d.ts +9 -3
- package/lib/component-patterns/render.d.ts.map +1 -1
- package/lib/component-patterns/render.js +39 -32
- package/lib/component-patterns/render.js.map +1 -1
- package/lib/component-patterns/render.types.d.ts +60 -34
- package/lib/component-patterns/render.types.d.ts.map +1 -1
- package/lib/component-patterns/render.types.js +1 -1
- package/lib/component-patterns/stagedComponent.d.ts +3 -8
- package/lib/component-patterns/stagedComponent.d.ts.map +1 -1
- package/lib/component-patterns/stagedComponent.js +10 -27
- package/lib/component-patterns/stagedComponent.js.map +1 -1
- package/lib/component-patterns/withSlots.d.ts +6 -2
- package/lib/component-patterns/withSlots.d.ts.map +1 -1
- package/lib/component-patterns/withSlots.js +3 -3
- package/lib/component-patterns/withSlots.js.map +1 -1
- package/lib/immutable-merge/Merge.d.ts +6 -3
- package/lib/immutable-merge/Merge.js +79 -83
- package/lib/immutable-merge/Merge.js.map +1 -1
- package/lib/immutable-merge/Merge.test.d.ts +1 -1
- package/lib/immutable-merge/Merge.test.js +231 -219
- package/lib/immutable-merge/Merge.test.js.map +1 -1
- package/lib/index.d.ts +33 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +13 -4
- package/lib/index.js.map +1 -1
- package/lib/jsx-namespace.d.ts +65 -0
- package/lib/jsx-namespace.d.ts.map +1 -0
- package/lib/jsx-namespace.js +2 -0
- package/lib/jsx-namespace.js.map +1 -0
- package/lib/jsx-runtime.d.ts +6 -4
- package/lib/jsx-runtime.d.ts.map +1 -1
- package/lib/jsx-runtime.js +9 -7
- package/lib/jsx-runtime.js.map +1 -1
- package/lib/memo-cache/getCacheEntry.d.ts +13 -13
- package/lib/memo-cache/getCacheEntry.js +20 -22
- package/lib/memo-cache/getCacheEntry.js.map +1 -1
- package/lib/memo-cache/getCacheEntry.test.d.ts +1 -1
- package/lib/memo-cache/getCacheEntry.test.js +90 -90
- package/lib/memo-cache/getCacheEntry.test.js.map +1 -1
- package/lib/memo-cache/getMemoCache.d.ts +1 -1
- package/lib/memo-cache/getMemoCache.js +11 -11
- package/lib/memo-cache/getMemoCache.js.map +1 -1
- package/lib/memo-cache/getMemoCache.test.d.ts +1 -1
- package/lib/memo-cache/getMemoCache.test.js +73 -73
- package/lib/memo-cache/getMemoCache.test.js.map +1 -1
- package/lib/memo-cache/memoize.d.ts +1 -1
- package/lib/memo-cache/memoize.js +9 -9
- package/lib/memo-cache/memoize.js.map +1 -1
- package/lib/memo-cache/memoize.test.d.ts +1 -1
- package/lib/memo-cache/memoize.test.js +36 -38
- package/lib/memo-cache/memoize.test.js.map +1 -1
- package/lib/merge-props/index.d.ts +1 -1
- package/lib/merge-props/index.js +1 -1
- package/lib/merge-props/mergeProps.d.ts +1 -1
- package/lib/merge-props/mergeProps.js +4 -4
- package/lib/merge-props/mergeProps.js.map +1 -1
- package/lib/merge-props/mergeStyles.d.ts +33 -4
- package/lib/merge-props/mergeStyles.d.ts.map +1 -1
- package/lib/merge-props/mergeStyles.js +16 -17
- package/lib/merge-props/mergeStyles.js.map +1 -1
- package/lib/merge-props/mergeStyles.test.d.ts +1 -1
- package/lib/merge-props/mergeStyles.test.js +75 -75
- package/lib/merge-props/mergeStyles.test.js.map +1 -1
- package/lib/merge-props/mergeStyles.types.d.ts +4 -4
- package/lib/merge-props/mergeStyles.types.d.ts.map +1 -1
- package/lib/merge-props/mergeStyles.types.js +1 -1
- package/lib/utilities/filterProps.d.ts +3 -0
- package/lib/utilities/filterProps.d.ts.map +1 -0
- package/lib/utilities/filterProps.js +12 -0
- package/lib/utilities/filterProps.js.map +1 -0
- package/lib-commonjs/component-patterns/directComponent.d.ts +7 -0
- package/lib-commonjs/component-patterns/directComponent.d.ts.map +1 -0
- package/lib-commonjs/component-patterns/directComponent.js +11 -0
- package/lib-commonjs/component-patterns/directComponent.js.map +1 -0
- package/lib-commonjs/component-patterns/extract.d.ts +22 -0
- package/lib-commonjs/component-patterns/extract.d.ts.map +1 -0
- package/lib-commonjs/component-patterns/extract.js +30 -0
- package/lib-commonjs/component-patterns/extract.js.map +1 -0
- package/lib-commonjs/component-patterns/phasedComponent.d.ts +18 -0
- package/lib-commonjs/component-patterns/phasedComponent.d.ts.map +1 -0
- package/lib-commonjs/component-patterns/phasedComponent.js +60 -0
- package/lib-commonjs/component-patterns/phasedComponent.js.map +1 -0
- package/lib-commonjs/component-patterns/render.d.ts +9 -3
- package/lib-commonjs/component-patterns/render.d.ts.map +1 -1
- package/lib-commonjs/component-patterns/render.js +101 -64
- package/lib-commonjs/component-patterns/render.js.map +1 -1
- package/lib-commonjs/component-patterns/render.types.d.ts +60 -34
- package/lib-commonjs/component-patterns/render.types.d.ts.map +1 -1
- package/lib-commonjs/component-patterns/render.types.js +3 -3
- package/lib-commonjs/component-patterns/stagedComponent.d.ts +3 -8
- package/lib-commonjs/component-patterns/stagedComponent.d.ts.map +1 -1
- package/lib-commonjs/component-patterns/stagedComponent.js +64 -56
- package/lib-commonjs/component-patterns/stagedComponent.js.map +1 -1
- package/lib-commonjs/component-patterns/withSlots.d.ts +6 -2
- package/lib-commonjs/component-patterns/withSlots.d.ts.map +1 -1
- package/lib-commonjs/component-patterns/withSlots.js +7 -8
- package/lib-commonjs/component-patterns/withSlots.js.map +1 -1
- package/lib-commonjs/immutable-merge/Merge.d.ts +6 -3
- package/lib-commonjs/immutable-merge/Merge.js +85 -90
- package/lib-commonjs/immutable-merge/Merge.js.map +1 -1
- package/lib-commonjs/immutable-merge/Merge.test.d.ts +1 -1
- package/lib-commonjs/immutable-merge/Merge.test.js +234 -222
- package/lib-commonjs/immutable-merge/Merge.test.js.map +1 -1
- package/lib-commonjs/index.d.ts +33 -5
- package/lib-commonjs/index.d.ts.map +1 -1
- package/lib-commonjs/index.js +184 -31
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/jsx-namespace.d.ts +65 -0
- package/lib-commonjs/jsx-namespace.d.ts.map +1 -0
- package/lib-commonjs/jsx-namespace.js +3 -0
- package/lib-commonjs/jsx-namespace.js.map +1 -0
- package/lib-commonjs/jsx-runtime.d.ts +6 -4
- package/lib-commonjs/jsx-runtime.d.ts.map +1 -1
- package/lib-commonjs/jsx-runtime.js +69 -34
- package/lib-commonjs/jsx-runtime.js.map +1 -1
- package/lib-commonjs/memo-cache/getCacheEntry.d.ts +13 -13
- package/lib-commonjs/memo-cache/getCacheEntry.js +23 -26
- package/lib-commonjs/memo-cache/getCacheEntry.js.map +1 -1
- package/lib-commonjs/memo-cache/getCacheEntry.test.d.ts +1 -1
- package/lib-commonjs/memo-cache/getCacheEntry.test.js +93 -93
- package/lib-commonjs/memo-cache/getCacheEntry.test.js.map +1 -1
- package/lib-commonjs/memo-cache/getMemoCache.d.ts +1 -1
- package/lib-commonjs/memo-cache/getMemoCache.js +16 -17
- package/lib-commonjs/memo-cache/getMemoCache.js.map +1 -1
- package/lib-commonjs/memo-cache/getMemoCache.test.d.ts +1 -1
- package/lib-commonjs/memo-cache/getMemoCache.test.js +76 -76
- package/lib-commonjs/memo-cache/getMemoCache.test.js.map +1 -1
- package/lib-commonjs/memo-cache/memoize.d.ts +1 -1
- package/lib-commonjs/memo-cache/memoize.js +13 -14
- package/lib-commonjs/memo-cache/memoize.js.map +1 -1
- package/lib-commonjs/memo-cache/memoize.test.d.ts +1 -1
- package/lib-commonjs/memo-cache/memoize.test.js +39 -41
- package/lib-commonjs/memo-cache/memoize.test.js.map +1 -1
- package/lib-commonjs/merge-props/index.d.ts +1 -1
- package/lib-commonjs/merge-props/index.js +17 -7
- package/lib-commonjs/merge-props/index.js.map +1 -1
- package/lib-commonjs/merge-props/mergeProps.d.ts +1 -1
- package/lib-commonjs/merge-props/mergeProps.js +9 -10
- package/lib-commonjs/merge-props/mergeProps.js.map +1 -1
- package/lib-commonjs/merge-props/mergeStyles.d.ts +33 -4
- package/lib-commonjs/merge-props/mergeStyles.d.ts.map +1 -1
- package/lib-commonjs/merge-props/mergeStyles.js +23 -25
- package/lib-commonjs/merge-props/mergeStyles.js.map +1 -1
- package/lib-commonjs/merge-props/mergeStyles.test.d.ts +1 -1
- package/lib-commonjs/merge-props/mergeStyles.test.js +78 -78
- package/lib-commonjs/merge-props/mergeStyles.test.js.map +1 -1
- package/lib-commonjs/merge-props/mergeStyles.types.d.ts +4 -4
- package/lib-commonjs/merge-props/mergeStyles.types.d.ts.map +1 -1
- package/lib-commonjs/merge-props/mergeStyles.types.js +3 -3
- package/lib-commonjs/utilities/filterProps.d.ts +3 -0
- package/lib-commonjs/utilities/filterProps.d.ts.map +1 -0
- package/lib-commonjs/utilities/filterProps.js +15 -0
- package/lib-commonjs/utilities/filterProps.js.map +1 -0
- package/package.json +48 -26
- package/src/component-patterns/README.md +53 -16
- package/src/component-patterns/directComponent.ts +9 -0
- package/src/component-patterns/extract.ts +32 -0
- package/src/component-patterns/phasedComponent.ts +54 -0
- package/src/component-patterns/render.ts +21 -13
- package/src/component-patterns/render.types.ts +55 -30
- package/src/component-patterns/stagedComponent.ts +24 -0
- package/src/immutable-merge/Merge.test.ts +5 -1
- package/src/index.ts +27 -7
- package/src/jsx-namespace.ts +83 -0
- package/src/jsx-runtime.ts +8 -4
- package/src/memo-cache/README.md +1 -1
- package/src/merge-props/mergeStyles.ts +52 -4
- package/src/merge-props/mergeStyles.types.ts +2 -2
- package/src/utilities/filterProps.ts +14 -0
- package/src/component-patterns/stagedComponent.tsx +0 -45
|
@@ -1,94 +1,94 @@
|
|
|
1
1
|
import { flattenStyle, mergeAndFlattenStyles, mergeStyles } from './mergeStyles';
|
|
2
2
|
const s1 = [
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
{ backgroundColor: 'blue' },
|
|
4
|
+
[{ color: 'red', borderWidth: 1 }, { fontFamily: 'segoe' }, [{ backgroundColor: 'bodyBackground' }]],
|
|
5
5
|
];
|
|
6
6
|
const s1flatten = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
backgroundColor: 'bodyBackground',
|
|
8
|
+
color: 'red',
|
|
9
|
+
borderWidth: 1,
|
|
10
|
+
fontFamily: 'segoe',
|
|
11
11
|
};
|
|
12
12
|
const s2 = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
borderWidth: 2,
|
|
14
|
+
fontFamily: 'primary',
|
|
15
|
+
color: 'bodyText',
|
|
16
16
|
};
|
|
17
17
|
const sMerged = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
backgroundColor: 'bodyBackground',
|
|
19
|
+
borderWidth: 2,
|
|
20
|
+
fontFamily: 'primary',
|
|
21
|
+
color: 'bodyText',
|
|
22
22
|
};
|
|
23
23
|
const sSelector = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
borderWidth: 1,
|
|
25
|
+
':hover': {
|
|
26
|
+
borderWidth: 2,
|
|
27
|
+
fontFamily: 'primary',
|
|
28
|
+
},
|
|
29
29
|
};
|
|
30
30
|
const sSelector2 = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
backgroundColor: 'white',
|
|
32
|
+
':hover': {
|
|
33
|
+
backgroundColor: 'black',
|
|
34
|
+
borderWidth: 3,
|
|
35
|
+
},
|
|
36
36
|
};
|
|
37
37
|
const sArraySelector = [[sSelector]];
|
|
38
38
|
const sArraySelector2 = [sSelector2];
|
|
39
39
|
const sMergedSelectors = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
borderWidth: 1,
|
|
41
|
+
backgroundColor: 'white',
|
|
42
|
+
':hover': {
|
|
43
|
+
borderWidth: 3,
|
|
44
|
+
fontFamily: 'primary',
|
|
45
|
+
backgroundColor: 'black',
|
|
46
|
+
},
|
|
47
47
|
};
|
|
48
48
|
describe('Style flatten and merge tests', () => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
49
|
+
test('flatten recursive arrays', () => {
|
|
50
|
+
const flattened = flattenStyle(s1);
|
|
51
|
+
expect(flattened).toEqual(s1flatten);
|
|
52
|
+
expect(flattened).not.toBe(s1);
|
|
53
|
+
});
|
|
54
|
+
test('flatten flat style returns style', () => {
|
|
55
|
+
const flattened = flattenStyle(s2);
|
|
56
|
+
expect(flattened).toBe(s2);
|
|
57
|
+
});
|
|
58
|
+
test('merge also flattens', () => {
|
|
59
|
+
const merged = mergeAndFlattenStyles(undefined, undefined, s1, s2);
|
|
60
|
+
expect(merged).toEqual(sMerged);
|
|
61
|
+
});
|
|
62
|
+
test('merge with sub objects', () => {
|
|
63
|
+
const merged = mergeAndFlattenStyles(undefined, undefined, sSelector, sSelector2);
|
|
64
|
+
expect(merged).toEqual(sMergedSelectors);
|
|
65
|
+
});
|
|
66
|
+
test('merge sub objects in arrays', () => {
|
|
67
|
+
const merged = mergeAndFlattenStyles(undefined, undefined, sArraySelector, sArraySelector2);
|
|
68
|
+
expect(merged).toEqual(sMergedSelectors);
|
|
69
|
+
});
|
|
70
|
+
test('memo recursive arrays', () => {
|
|
71
|
+
const flattened = mergeStyles(s1);
|
|
72
|
+
const flattened2 = mergeStyles(s1);
|
|
73
|
+
expect(flattened).toEqual(s1flatten);
|
|
74
|
+
expect(flattened2).toBe(flattened);
|
|
75
|
+
});
|
|
76
|
+
test('memo flat style', () => {
|
|
77
|
+
const flattened = mergeStyles(s2);
|
|
78
|
+
const flattened2 = mergeStyles(s2);
|
|
79
|
+
expect(flattened).toBe(s2);
|
|
80
|
+
expect(flattened2).toBe(flattened);
|
|
81
|
+
});
|
|
82
|
+
test('memo and flatten multiple', () => {
|
|
83
|
+
const flattened = mergeStyles(s1, s2);
|
|
84
|
+
const flattened2 = mergeStyles(s1, s2);
|
|
85
|
+
expect(flattened).toEqual(sMerged);
|
|
86
|
+
expect(flattened2).toBe(flattened);
|
|
87
|
+
});
|
|
88
|
+
test('memo styles ignores undefined values', () => {
|
|
89
|
+
const result1 = mergeStyles(s1, s2, undefined, s1flatten);
|
|
90
|
+
const result2 = mergeStyles(s1, undefined, s2, s1flatten);
|
|
91
|
+
expect(result2).toBe(result1);
|
|
92
|
+
});
|
|
93
93
|
});
|
|
94
|
-
//# sourceMappingURL=mergeStyles.test.js.map
|
|
94
|
+
//# sourceMappingURL=mergeStyles.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeStyles.test.js","sourceRoot":"","sources":["../../src/merge-props/mergeStyles.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAgBjF,MAAM,EAAE,GAAmB;IACzB,EAAE,eAAe,EAAE,MAAM,EAAE;IAC3B,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC,EAAE,eAAe,EAAE,gBAAgB,EAAE,CAAC,CAAC;CACrG,CAAC;AAEF,MAAM,SAAS,GAAmB;IAChC,eAAe,EAAE,gBAAgB;IACjC,KAAK,EAAE,KAAK;IACZ,WAAW,EAAE,CAAC;IACd,UAAU,EAAE,OAAO;CACpB,CAAC;AAEF,MAAM,EAAE,GAAmB;IACzB,WAAW,EAAE,CAAC;IACd,UAAU,EAAE,SAAS;IACrB,KAAK,EAAE,UAAU;CAClB,CAAC;AAEF,MAAM,OAAO,GAAmB;IAC9B,eAAe,EAAE,gBAAgB;IACjC,WAAW,EAAE,CAAC;IACd,UAAU,EAAE,SAAS;IACrB,KAAK,EAAE,UAAU;CAClB,CAAC;AAEF,MAAM,SAAS,GAAmB;IAChC,WAAW,EAAE,CAAC;IACd,QAAQ,EAAE;QACR,WAAW,EAAE,CAAC;QACd,UAAU,EAAE,SAAS;KACtB;CACF,CAAC;AAEF,MAAM,UAAU,GAAmB;IACjC,eAAe,EAAE,OAAO;IACxB,QAAQ,EAAE;QACR,eAAe,EAAE,OAAO;QACxB,WAAW,EAAE,CAAC;KACf;CACF,CAAC;AAEF,MAAM,cAAc,GAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;AAErD,MAAM,eAAe,GAAmB,CAAC,UAAU,CAAC,CAAC;AAErD,MAAM,gB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,IAAI,CAAC,SAAS,CAAC,CAAC;IAAA,CACpC,CAAC,CAAC;IAEH,IAAI,CAAC,sCAAsC,EAAE,GAAG,EAAE,CAAC;QACjD,MAAM,OAAO,GAAG,WAAW,CAAC,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;QAC1D,MAAM,OAAO,GAAG,WAAW,CAAC,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,CAAC,CAAC;QAC1D,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAAA,CAC/B,CAAC,CAAC;AAAA,CACJ,CAAC,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This is a copy of the react-native style prop type, copied here to avoid RN dependencies for web clients
|
|
3
3
|
*/
|
|
4
|
-
type Falsy = undefined | null | false;
|
|
5
|
-
type RecursiveArray<T> = (T | RecursiveArray<T>)[];
|
|
4
|
+
type Falsy = undefined | null | false | '' | 0;
|
|
5
|
+
type RecursiveArray<T> = readonly (T | RecursiveArray<T>)[] | (T | RecursiveArray<T>)[];
|
|
6
6
|
/** Keep a brand of 'T' so that calls to `StyleSheet.flatten` can take `RegisteredStyle<T>` and return `T`. */
|
|
7
7
|
type RegisteredStyle<T> = number & {
|
|
8
|
-
|
|
8
|
+
__registeredStyleBrand: T;
|
|
9
9
|
};
|
|
10
10
|
export type StyleProp<T> = T | RegisteredStyle<T> | RecursiveArray<T | RegisteredStyle<T> | Falsy> | Falsy;
|
|
11
11
|
export {};
|
|
12
|
-
//# sourceMappingURL=mergeStyles.types.d.ts.map
|
|
12
|
+
//# sourceMappingURL=mergeStyles.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeStyles.types.d.ts","sourceRoot":"","sources":["../../src/merge-props/mergeStyles.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,KAAK,KAAK,GAAG,SAAS,GAAG,IAAI,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"mergeStyles.types.d.ts","sourceRoot":"","sources":["../../src/merge-props/mergeStyles.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,KAAK,KAAK,GAAG,SAAS,GAAG,IAAI,GAAG,KAAK,GAAG,EAAE,GAAG,CAAC,CAAC;AAC/C,KAAK,cAAc,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACxF,8GAA8G;AAC9G,KAAK,eAAe,CAAC,CAAC,IAAI,MAAM,GAAG;IAAE,sBAAsB,EAAE,CAAC,CAAA;CAAE,CAAC;AAEjE,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=mergeStyles.types.js.map
|
|
2
|
+
//# sourceMappingURL=mergeStyles.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterProps.d.ts","sourceRoot":"","sources":["../../src/utilities/filterProps.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;AAExD,wBAAgB,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAS/E"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { mergeProps } from '../merge-props/mergeProps';
|
|
2
|
+
export function filterProps(props, filter) {
|
|
3
|
+
if (filter && typeof props === 'object' && !Array.isArray(props)) {
|
|
4
|
+
const propsToRemove = filter ? Object.keys(props).filter((key) => !filter(key)) : undefined;
|
|
5
|
+
if (propsToRemove?.length > 0) {
|
|
6
|
+
const propsToRemoveObj = Object.fromEntries(propsToRemove.map((prop) => [prop, undefined]));
|
|
7
|
+
return mergeProps(props, propsToRemoveObj);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return props;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=filterProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filterProps.js","sourceRoot":"","sources":["../../src/utilities/filterProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAIvD,MAAM,UAAU,WAAW,CAAS,KAAa,EAAE,MAAoB,EAAU;IAC/E,IAAI,MAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjE,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC5F,IAAI,aAAa,EAAE,MAAM,GAAG,CAAC,EAAE,CAAC;YAC9B,MAAM,gBAAgB,GAAG,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAW,CAAC;YACtG,OAAO,UAAU,CAAS,KAAK,EAAE,gBAAgB,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AAAA,CACd"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { FunctionComponent } from './render.types';
|
|
2
|
+
/**
|
|
3
|
+
* @param component functional component, usually a closure, to make into a direct component
|
|
4
|
+
* @return the same component with the direct component flag set, return type is a pure function component
|
|
5
|
+
*/
|
|
6
|
+
export declare function directComponent<TProps>(component: FunctionComponent<TProps>): FunctionComponent<TProps>;
|
|
7
|
+
//# sourceMappingURL=directComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directComponent.d.ts","sourceRoot":"","sources":["../../src/component-patterns/directComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,iBAAiB,CAAC,MAAM,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAEvG"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.directComponent = directComponent;
|
|
4
|
+
/**
|
|
5
|
+
* @param component functional component, usually a closure, to make into a direct component
|
|
6
|
+
* @return the same component with the direct component flag set, return type is a pure function component
|
|
7
|
+
*/
|
|
8
|
+
function directComponent(component) {
|
|
9
|
+
return Object.assign(component, { _callDirect: true });
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=directComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"directComponent.js","sourceRoot":"","sources":["../../src/component-patterns/directComponent.ts"],"names":[],"mappings":";;;AAEA;;;GAGG;AACH,yBAAwC,SAAoC,EAA6B;IACvG,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;AAAA,CACxD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ViewStyle, TextStyle, ImageStyle } from 'react-native';
|
|
2
|
+
type StyleTypes = ViewStyle | TextStyle | ImageStyle;
|
|
3
|
+
/**
|
|
4
|
+
* Extract the props from a React element. If the element is undefined, undefined will be returned.
|
|
5
|
+
* @param element The React element from which to extract the props.
|
|
6
|
+
* @returns The extracted props or undefined if the element is undefined.
|
|
7
|
+
*/
|
|
8
|
+
export declare function extractProps<T extends object>(element?: React.ReactElement): T | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Extract the children from a React element. If the element is undefined, undefined will be returned.
|
|
11
|
+
* @param element The React element from which to extract the children.
|
|
12
|
+
* @returns The extracted children or undefined if the element is undefined.
|
|
13
|
+
*/
|
|
14
|
+
export declare function extractChildren(element?: React.ReactElement): React.ReactNode | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Extract a style object from a React element. If the element is undefined or does not have a style prop, an empty object will be returned.
|
|
17
|
+
* @param element The React element from which to extract the style.
|
|
18
|
+
* @returns The extracted style object or an empty object if not available.
|
|
19
|
+
*/
|
|
20
|
+
export declare function extractStyle<T extends StyleTypes = ViewStyle>(element?: React.ReactElement): T;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=extract.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../src/component-patterns/extract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAErE,KAAK,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;AAIrD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,CAAC,GAAG,SAAS,CAE1F;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,SAAS,GAAG,SAAS,CAEzF;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,UAAU,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,KAAK,CAAC,YAAY,GAAG,CAAC,CAE9F"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
exports.extractProps = extractProps;
|
|
4
|
+
exports.extractChildren = extractChildren;
|
|
5
|
+
exports.extractStyle = extractStyle;
|
|
6
|
+
/**
|
|
7
|
+
* Extract the props from a React element. If the element is undefined, undefined will be returned.
|
|
8
|
+
* @param element The React element from which to extract the props.
|
|
9
|
+
* @returns The extracted props or undefined if the element is undefined.
|
|
10
|
+
*/
|
|
11
|
+
function extractProps(element) {
|
|
12
|
+
return element ? element.props : undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Extract the children from a React element. If the element is undefined, undefined will be returned.
|
|
16
|
+
* @param element The React element from which to extract the children.
|
|
17
|
+
* @returns The extracted children or undefined if the element is undefined.
|
|
18
|
+
*/
|
|
19
|
+
function extractChildren(element) {
|
|
20
|
+
return extractProps(element)?.children;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Extract a style object from a React element. If the element is undefined or does not have a style prop, an empty object will be returned.
|
|
24
|
+
* @param element The React element from which to extract the style.
|
|
25
|
+
* @returns The extracted style object or an empty object if not available.
|
|
26
|
+
*/
|
|
27
|
+
function extractStyle(element) {
|
|
28
|
+
return extractProps(element)?.style ?? {};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=extract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/component-patterns/extract.ts"],"names":[],"mappings":";;;;;AAMA;;;;GAIG;AACH,sBAA+C,OAA4B,EAAiB;IAC1F,OAAO,OAAO,CAAC,CAAC,CAAE,OAAO,CAAC,KAAW,CAAC,CAAC,CAAC,SAAS,CAAC;AAAA,CACnD;AAED;;;;GAIG;AACH,yBAAgC,OAA4B,EAA+B;IACzF,OAAO,YAAY,CAAoB,OAAO,CAAC,EAAE,QAAQ,CAAC;AAAA,CAC3D;AAED;;;;GAIG;AACH,sBAA+D,OAA4B,EAAK;IAC9F,OAAQ,YAAY,CAAiB,OAAO,CAAC,EAAE,KAAW,IAAK,EAAQ,CAAC;AAAA,CACzE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { PhasedRender, FunctionComponent } from './render.types';
|
|
3
|
+
/**
|
|
4
|
+
* Extract the phased render function from a component, if it has one.
|
|
5
|
+
* Handles both the newer PhasedComponent pattern (_phasedRender) and the legacy
|
|
6
|
+
* ComposableFunction pattern (_staged) for backward compatibility.
|
|
7
|
+
*
|
|
8
|
+
* @param component - The component to extract the phased render from
|
|
9
|
+
* @returns The phased render function if present, undefined otherwise
|
|
10
|
+
*/
|
|
11
|
+
export declare function getPhasedRender<TProps>(component: React.ComponentType<TProps>): PhasedRender<TProps> | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Take a phased render function and make a real component out of it, attaching the phased render function
|
|
14
|
+
* so it can be split if used in that manner.
|
|
15
|
+
* @param getInnerPhase - phased render function to wrap into a staged component
|
|
16
|
+
*/
|
|
17
|
+
export declare function phasedComponent<TProps>(getInnerPhase: PhasedRender<TProps>): FunctionComponent<TProps>;
|
|
18
|
+
//# sourceMappingURL=phasedComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phasedComponent.d.ts","sourceRoot":"","sources":["../../src/component-patterns/phasedComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAuC,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAI3G;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,GAAG,SAAS,CAuBhH;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,aAAa,EAAE,YAAY,CAAC,MAAM,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAUtG"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
var __importDefault =
|
|
3
|
+
(this && this.__importDefault) ||
|
|
4
|
+
function (mod) {
|
|
5
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
8
|
+
exports.getPhasedRender = getPhasedRender;
|
|
9
|
+
exports.phasedComponent = phasedComponent;
|
|
10
|
+
const react_1 = __importDefault(require('react'));
|
|
11
|
+
const render_1 = require('./render');
|
|
12
|
+
/**
|
|
13
|
+
* Extract the phased render function from a component, if it has one.
|
|
14
|
+
* Handles both the newer PhasedComponent pattern (_phasedRender) and the legacy
|
|
15
|
+
* ComposableFunction pattern (_staged) for backward compatibility.
|
|
16
|
+
*
|
|
17
|
+
* @param component - The component to extract the phased render from
|
|
18
|
+
* @returns The phased render function if present, undefined otherwise
|
|
19
|
+
*/
|
|
20
|
+
function getPhasedRender(component) {
|
|
21
|
+
// only a function component can have a phased render
|
|
22
|
+
if (typeof component === 'function') {
|
|
23
|
+
// if this has a phased render function, return it
|
|
24
|
+
if (component._phasedRender) {
|
|
25
|
+
return component._phasedRender;
|
|
26
|
+
} else if (component._staged) {
|
|
27
|
+
// for backward compatibility check for staged render and return a wrapper that maps the signature
|
|
28
|
+
const staged = component._staged;
|
|
29
|
+
return (props) => {
|
|
30
|
+
const { children, ...rest } = props;
|
|
31
|
+
const inner = staged(rest, ...react_1.default.Children.toArray(children));
|
|
32
|
+
// staged render functions were not consistently marking contents as composable, though they were treated
|
|
33
|
+
// as such in useHook. To maintain compatibility we mark the returned function as composable here. This was
|
|
34
|
+
// dangerous, but this shim is necessary for backward compatibility. The newer pattern is explicit about this.
|
|
35
|
+
if (typeof inner === 'function' && !inner._canCompose) {
|
|
36
|
+
return Object.assign(inner, { _canCompose: true });
|
|
37
|
+
}
|
|
38
|
+
return inner;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Take a phased render function and make a real component out of it, attaching the phased render function
|
|
46
|
+
* so it can be split if used in that manner.
|
|
47
|
+
* @param getInnerPhase - phased render function to wrap into a staged component
|
|
48
|
+
*/
|
|
49
|
+
function phasedComponent(getInnerPhase) {
|
|
50
|
+
return Object.assign(
|
|
51
|
+
(props) => {
|
|
52
|
+
// pull out children from props
|
|
53
|
+
const { children, ...outerProps } = props;
|
|
54
|
+
const Inner = getInnerPhase(outerProps);
|
|
55
|
+
return (0, render_1.renderForJsxRuntime)(Inner, { children });
|
|
56
|
+
},
|
|
57
|
+
{ _phasedRender: getInnerPhase },
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=phasedComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"phasedComponent.js","sourceRoot":"","sources":["../../src/component-patterns/phasedComponent.ts"],"names":[],"mappings":";;;;;;;AAAA,kDAA0B;AAE1B,qCAA+C;AAG/C;;;;;;;GAOG;AACH,yBAAwC,SAAsC,EAAoC;IAChH,qDAAqD;IACrD,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,CAAC;QACpC,kDAAkD;QAClD,IAAK,SAAqC,CAAC,aAAa,EAAE,CAAC;YACzD,OAAQ,SAAqC,CAAC,aAAa,CAAC;QAC9D,CAAC;aAAM,IAAK,SAAwC,CAAC,OAAO,EAAE,CAAC;YAC7D,kGAAkG;YAClG,MAAM,MAAM,GAAI,SAAwC,CAAC,OAAO,CAAC;YACjE,OAAO,CAAC,KAAa,EAAE,EAAE,CAAC;gBACxB,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,KAAwC,CAAC;gBACvE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAc,EAAE,GAAG,eAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;gBAC1E,yGAAyG;gBACzG,2GAA2G;gBAC3G,8GAA8G;gBAC9G,IAAI,OAAO,KAAK,KAAK,UAAU,IAAI,CAAE,KAAuC,CAAC,WAAW,EAAE,CAAC;oBACzF,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;gBACrD,CAAC;gBACD,OAAO,KAAK,CAAC;YAAA,CACd,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AAAA,CAClB;AAED;;;;GAIG;AACH,yBAAwC,aAAmC,EAA6B;IACtG,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,KAAsC,EAAE,EAAE,CAAC;QAC1C,+BAA+B;QAC/B,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;QAC1C,MAAM,KAAK,GAAG,aAAa,CAAC,UAAoB,CAAC,CAAC;QAClD,OAAO,IAAA,4BAAmB,EAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IAAA,CACjD,EACD,EAAE,aAAa,EAAE,aAAa,EAAE,CACjC,CAAC;AAAA,CACH"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import * as ReactJSX from 'react/jsx-runtime';
|
|
3
|
-
import type { RenderType, RenderResult } from './render.types';
|
|
3
|
+
import type { RenderType, RenderResult, DirectComponent } from './render.types';
|
|
4
4
|
export type CustomRender = () => RenderResult;
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function asDirectComponent<TProps>(type: RenderType): DirectComponent<TProps> | undefined;
|
|
6
|
+
export declare function renderForJsxRuntime<TProps>(
|
|
7
|
+
type: React.ElementType,
|
|
8
|
+
props: React.PropsWithChildren<TProps>,
|
|
9
|
+
key?: React.Key,
|
|
10
|
+
jsxFn?: typeof ReactJSX.jsx,
|
|
11
|
+
): RenderResult;
|
|
6
12
|
export declare function renderForClassicRuntime<TProps>(type: RenderType, props: TProps, ...children: React.ReactNode[]): RenderResult;
|
|
7
13
|
export declare const renderSlot: typeof renderForClassicRuntime;
|
|
8
|
-
//# sourceMappingURL=render.d.ts.map
|
|
14
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/component-patterns/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/component-patterns/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAyB,MAAM,gBAAgB,CAAC;AAEvG,MAAM,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC;AAE9C,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC,GAAG,SAAS,CAK/F;AASD,wBAAgB,mBAAmB,CAAC,MAAM,EACxC,IAAI,EAAE,KAAK,CAAC,WAAW,EACvB,KAAK,EAAE,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,EACtC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,EACf,KAAK,GAAE,OAAO,QAAQ,CAAC,GAAe,GACrC,YAAY,CA4Bd;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,KAAK,CAAC,SAAS,EAAE,GAAG,YAAY,CAI7H;AAED,eAAO,MAAM,UAAU,gCAA0B,CAAC"}
|
|
@@ -1,73 +1,110 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return m[k];
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}
|
|
18
|
+
: function (o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
});
|
|
22
|
+
var __setModuleDefault =
|
|
23
|
+
(this && this.__setModuleDefault) ||
|
|
24
|
+
(Object.create
|
|
25
|
+
? function (o, v) {
|
|
26
|
+
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
27
|
+
}
|
|
28
|
+
: function (o, v) {
|
|
29
|
+
o['default'] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar =
|
|
32
|
+
(this && this.__importStar) ||
|
|
33
|
+
(function () {
|
|
34
|
+
var ownKeys = function (o) {
|
|
35
|
+
ownKeys =
|
|
36
|
+
Object.getOwnPropertyNames ||
|
|
37
|
+
function (o) {
|
|
38
|
+
var ar = [];
|
|
39
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
40
|
+
return ar;
|
|
41
|
+
};
|
|
42
|
+
return ownKeys(o);
|
|
43
|
+
};
|
|
44
|
+
return function (mod) {
|
|
45
|
+
if (mod && mod.__esModule) return mod;
|
|
46
|
+
var result = {};
|
|
47
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== 'default') __createBinding(result, mod, k[i]);
|
|
48
|
+
__setModuleDefault(result, mod);
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
})();
|
|
52
|
+
var __importDefault =
|
|
53
|
+
(this && this.__importDefault) ||
|
|
54
|
+
function (mod) {
|
|
55
|
+
return mod && mod.__esModule ? mod : { default: mod };
|
|
56
|
+
};
|
|
57
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
58
|
+
exports.renderSlot = void 0;
|
|
59
|
+
exports.asDirectComponent = asDirectComponent;
|
|
60
|
+
exports.renderForJsxRuntime = renderForJsxRuntime;
|
|
61
|
+
exports.renderForClassicRuntime = renderForClassicRuntime;
|
|
62
|
+
const react_1 = __importDefault(require('react'));
|
|
63
|
+
const ReactJSX = __importStar(require('react/jsx-runtime'));
|
|
32
64
|
function asDirectComponent(type) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
65
|
+
if (typeof type === 'function' && type._callDirect) {
|
|
66
|
+
return type;
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
37
69
|
}
|
|
38
70
|
function asLegacyDirectComponent(type) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
71
|
+
if (typeof type === 'function' && type._canCompose) {
|
|
72
|
+
return type;
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
43
75
|
}
|
|
44
|
-
function renderForJsxRuntime(type, props, key, jsxFn =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
76
|
+
function renderForJsxRuntime(type, props, key, jsxFn = undefined) {
|
|
77
|
+
const legacyDirect = asLegacyDirectComponent(type);
|
|
78
|
+
if (legacyDirect) {
|
|
79
|
+
const { children, ...rest } = props;
|
|
80
|
+
const newProps = { ...rest, key };
|
|
81
|
+
return legacyDirect(newProps, ...react_1.default.Children.toArray(children));
|
|
82
|
+
}
|
|
83
|
+
const directComponent = asDirectComponent(type);
|
|
84
|
+
if (directComponent) {
|
|
85
|
+
const newProps = { ...props, key };
|
|
86
|
+
return directComponent(newProps);
|
|
87
|
+
}
|
|
88
|
+
// auto-detect whether to use jsx or jsxs based on number of children, 0 or 1 = jsx, more than 1 = jsxs
|
|
89
|
+
if (!jsxFn) {
|
|
90
|
+
if (react_1.default.Children.count(props.children) > 1) {
|
|
91
|
+
jsxFn = ReactJSX.jsxs;
|
|
92
|
+
} else {
|
|
93
|
+
jsxFn = ReactJSX.jsx;
|
|
50
94
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
95
|
+
}
|
|
96
|
+
// Extract key from props to avoid React 19 warning about spreading key prop
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
98
|
+
const { key: propsKey, ...propsWithoutKey } = props;
|
|
99
|
+
// Use explicitly passed key, or fall back to key from props
|
|
100
|
+
const finalKey = key ?? propsKey;
|
|
101
|
+
// now call the appropriate jsx function to render the component
|
|
102
|
+
return jsxFn(type, propsWithoutKey, finalKey);
|
|
57
103
|
}
|
|
58
|
-
exports.renderForJsxRuntime = renderForJsxRuntime;
|
|
59
104
|
function renderForClassicRuntime(type, props, ...children) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
const directComponent = asDirectComponent(type);
|
|
65
|
-
if (directComponent) {
|
|
66
|
-
const newProps = { ...props, children };
|
|
67
|
-
return directComponent(newProps);
|
|
68
|
-
}
|
|
69
|
-
return react_1.default.createElement(type, props, ...children);
|
|
105
|
+
// if it is a non-string type with _canCompose set just call the function directly, otherwise call createElement as normal
|
|
106
|
+
const propsWithChildren = { children, ...props };
|
|
107
|
+
return renderForJsxRuntime(type, propsWithChildren);
|
|
70
108
|
}
|
|
71
|
-
exports.renderForClassicRuntime = renderForClassicRuntime;
|
|
72
109
|
exports.renderSlot = renderForClassicRuntime;
|
|
73
|
-
//# sourceMappingURL=render.js.map
|
|
110
|
+
//# sourceMappingURL=render.js.map
|