@fluentui-react-native/framework 0.15.0 → 0.15.3
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.md +50 -0
- package/lib/compose.d.ts +12 -27
- package/lib/compose.js +2 -2
- package/lib/compressible.d.ts +2 -5
- package/lib/compressible.js +8 -8
- package/lib/compressible.test.d.ts +1 -1
- package/lib/compressible.test.js +61 -66
- package/lib/index.d.ts +6 -76
- package/lib/index.js +2 -16
- package/lib/themeHelper.d.ts +1 -1
- package/lib/themeHelper.js +6 -6
- package/lib/useFluentTheme.d.ts +1 -1
- package/lib/useFluentTheme.js +2 -2
- package/lib/useStyling.d.ts +4 -15
- package/lib/useStyling.js +4 -4
- package/lib/useTokens.d.ts +1 -1
- package/lib/useTokens.js +2 -2
- package/lib-commonjs/compose.d.ts +12 -27
- package/lib-commonjs/compose.js +6 -6
- package/lib-commonjs/compressible.d.ts +2 -5
- package/lib-commonjs/compressible.js +11 -11
- package/lib-commonjs/compressible.test.d.ts +1 -1
- package/lib-commonjs/compressible.test.js +100 -130
- package/lib-commonjs/index.d.ts +6 -76
- package/lib-commonjs/index.js +55 -283
- package/lib-commonjs/themeHelper.d.ts +1 -1
- package/lib-commonjs/themeHelper.js +9 -9
- package/lib-commonjs/useFluentTheme.d.ts +1 -1
- package/lib-commonjs/useFluentTheme.js +6 -6
- package/lib-commonjs/useStyling.d.ts +4 -15
- package/lib-commonjs/useStyling.js +8 -8
- package/lib-commonjs/useTokens.d.ts +1 -1
- package/lib-commonjs/useTokens.js +11 -31
- package/package.json +31 -30
- package/eslint.config.js +0 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.compressible = compressible;
|
|
4
|
-
const framework_base_1 = require(
|
|
4
|
+
const framework_base_1 = require("@fluentui-react-native/framework-base");
|
|
5
5
|
/**
|
|
6
6
|
* Utility function which can create function components that can be tree compressed (using the stagedRender pattern),
|
|
7
7
|
* and also have customize functionality.
|
|
@@ -10,12 +10,12 @@ const framework_base_1 = require('@fluentui-react-native/framework-base');
|
|
|
10
10
|
* @returns A tree compressed function component with the `.customize` method exposed to it
|
|
11
11
|
*/
|
|
12
12
|
function compressible(fn, useTokens) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
const injectedWrapper = (props) => fn(props, useTokens);
|
|
14
|
+
const component = (0, framework_base_1.stagedComponent)(injectedWrapper);
|
|
15
|
+
component.customize = (...tokens) => {
|
|
16
|
+
const useTokensNew = useTokens.customize(...tokens);
|
|
17
|
+
return compressible(fn, useTokensNew);
|
|
18
|
+
};
|
|
19
|
+
return component;
|
|
20
20
|
}
|
|
21
|
-
//# sourceMappingURL=compressible.js.map
|
|
21
|
+
//# sourceMappingURL=compressible.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=compressible.test.d.ts.map
|
|
2
|
+
//# sourceMappingURL=compressible.test.d.ts.map
|
|
@@ -1,147 +1,117 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var
|
|
23
|
-
|
|
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;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
41
24
|
};
|
|
42
|
-
|
|
25
|
+
return ownKeys(o);
|
|
43
26
|
};
|
|
44
27
|
return function (mod) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
50
33
|
};
|
|
51
|
-
|
|
52
|
-
Object.defineProperty(exports,
|
|
53
|
-
const jsx_runtime_1 = require(
|
|
54
|
-
const react_1 = require(
|
|
55
|
-
const react_native_1 = require(
|
|
56
|
-
const framework_base_1 = require(
|
|
57
|
-
const use_slot_1 = require(
|
|
58
|
-
const use_tokens_1 = require(
|
|
59
|
-
const renderer = __importStar(require(
|
|
60
|
-
const compressible_1 = require(
|
|
61
|
-
const useTokens_1 = require(
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const jsx_runtime_1 = require("@fluentui-react-native/framework-base/jsx-runtime");
|
|
37
|
+
const react_1 = require("react");
|
|
38
|
+
const react_native_1 = require("react-native");
|
|
39
|
+
const framework_base_1 = require("@fluentui-react-native/framework-base");
|
|
40
|
+
const use_slot_1 = require("@fluentui-react-native/use-slot");
|
|
41
|
+
const use_tokens_1 = require("@fluentui-react-native/use-tokens");
|
|
42
|
+
const renderer = __importStar(require("react-test-renderer"));
|
|
43
|
+
const compressible_1 = require("./compressible");
|
|
44
|
+
const useTokens_1 = require("./useTokens");
|
|
62
45
|
const useVariantTokens = (0, useTokens_1.buildUseTokens)({
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
46
|
+
color: 'black',
|
|
47
|
+
fontSize: 12,
|
|
48
|
+
fontWeight: '500',
|
|
49
|
+
defaultType: 'normal',
|
|
50
|
+
header: {
|
|
51
|
+
color: 'blue',
|
|
52
|
+
fontSize: 16,
|
|
53
|
+
fontWeight: '700',
|
|
54
|
+
},
|
|
55
|
+
caption: {
|
|
56
|
+
color: 'gray',
|
|
57
|
+
fontWeight: '300',
|
|
58
|
+
},
|
|
76
59
|
});
|
|
77
60
|
const VariantText = (0, compressible_1.compressible)((props, useTokens) => {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
style
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return (extra, children) => {
|
|
94
|
-
return jsx_runtime_1.jsx(InnerText, { ...extra, children: children });
|
|
95
|
-
};
|
|
61
|
+
// fake theme here
|
|
62
|
+
const theme = {};
|
|
63
|
+
// get the tokens
|
|
64
|
+
let [tokens, cache] = useTokens(theme);
|
|
65
|
+
// split the props, defaulting the variant type to the default type from the tokens
|
|
66
|
+
const { variant = tokens.defaultType, style, ...rest } = props;
|
|
67
|
+
// now apply the alternate layer tokens as appropriate
|
|
68
|
+
[tokens, cache] = (0, use_tokens_1.applyTokenLayers)(tokens, ['normal', 'header', 'caption'], cache, (layer) => layer === variant);
|
|
69
|
+
// merge styles together with what is passed in
|
|
70
|
+
const mergedStyle = (0, framework_base_1.mergeStyles)({ color: tokens.color, fontSize: tokens.fontSize, fontWeight: tokens.fontWeight }, style);
|
|
71
|
+
// now get the slot
|
|
72
|
+
const InnerText = (0, use_slot_1.useSlot)(react_native_1.Text, { ...rest, style: mergedStyle });
|
|
73
|
+
return (extra, children) => {
|
|
74
|
+
return jsx_runtime_1.jsx(InnerText, { ...extra, children: children });
|
|
75
|
+
};
|
|
96
76
|
}, useVariantTokens);
|
|
97
77
|
const SuperHeader = VariantText.customize({ header: { fontSize: 24, color: 'purple' } });
|
|
98
78
|
const useLabelTokens = (0, useTokens_1.buildUseTokens)({
|
|
99
|
-
|
|
100
|
-
|
|
79
|
+
headerVariant: 'header',
|
|
80
|
+
captionVariant: 'caption',
|
|
101
81
|
});
|
|
102
82
|
const Label = (0, compressible_1.compressible)((props, useTokens) => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
83
|
+
const theme = {};
|
|
84
|
+
const [tokens] = useTokens(theme);
|
|
85
|
+
const { headerText, captionText, headerSlot, captionSlot } = props;
|
|
86
|
+
const Header = (0, use_slot_1.useSlot)(headerSlot || VariantText, { variant: tokens.headerVariant });
|
|
87
|
+
const Caption = (0, use_slot_1.useSlot)(captionSlot || VariantText, { variant: tokens.captionVariant });
|
|
88
|
+
return () => {
|
|
89
|
+
if (captionText) {
|
|
90
|
+
return (jsx_runtime_1.jsxs(react_native_1.View, { children: [
|
|
91
|
+
jsx_runtime_1.jsx(Header, { children: headerText }), jsx_runtime_1.jsx(Caption, { children: captionText })
|
|
92
|
+
] }));
|
|
93
|
+
}
|
|
94
|
+
return jsx_runtime_1.jsx(Header, { children: headerText });
|
|
95
|
+
};
|
|
116
96
|
}, useLabelTokens);
|
|
117
97
|
describe('compressible tests', () => {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
],
|
|
127
|
-
}),
|
|
128
|
-
);
|
|
98
|
+
it('Two labels, one with caption and one without', () => {
|
|
99
|
+
let component;
|
|
100
|
+
(0, react_1.act)(() => {
|
|
101
|
+
component = renderer.create(jsx_runtime_1.jsxs(react_native_1.View, { children: [
|
|
102
|
+
jsx_runtime_1.jsx(Label, { headerText: "Header1" }), jsx_runtime_1.jsx(Label, { headerText: "Header2", captionText: "Caption2" })
|
|
103
|
+
] }));
|
|
104
|
+
});
|
|
105
|
+
expect(component.toJSON()).toMatchSnapshot();
|
|
129
106
|
});
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
jsx_runtime_1.jsx(Label, { headerText: 'Super Header', headerSlot: SuperHeader, captionText: 'Normal caption' }),
|
|
139
|
-
jsx_runtime_1.jsx(Label, { headerText: 'Normal Header', captionText: 'Another normal caption' }),
|
|
140
|
-
],
|
|
141
|
-
}),
|
|
142
|
-
);
|
|
107
|
+
it('Two labels, one plugging in SuperHeader instead', () => {
|
|
108
|
+
let component;
|
|
109
|
+
(0, react_1.act)(() => {
|
|
110
|
+
component = renderer.create(jsx_runtime_1.jsxs(react_native_1.View, { children: [
|
|
111
|
+
jsx_runtime_1.jsx(Label, { headerText: "Super Header", headerSlot: SuperHeader, captionText: "Normal caption" }), jsx_runtime_1.jsx(Label, { headerText: "Normal Header", captionText: "Another normal caption" })
|
|
112
|
+
] }));
|
|
113
|
+
});
|
|
114
|
+
expect(component.toJSON()).toMatchSnapshot();
|
|
143
115
|
});
|
|
144
|
-
expect(component.toJSON()).toMatchSnapshot();
|
|
145
|
-
});
|
|
146
116
|
});
|
|
147
|
-
//# sourceMappingURL=compressible.test.js.map
|
|
117
|
+
//# sourceMappingURL=compressible.test.js.map
|
package/lib-commonjs/index.d.ts
CHANGED
|
@@ -2,89 +2,19 @@ export type { GetMemoValue, GetTypedMemoValue } from '@fluentui-react-native/fra
|
|
|
2
2
|
export { getMemoCache, getTypedMemoCache, memoize } from '@fluentui-react-native/framework-base';
|
|
3
3
|
export type { StyleProp } from '@fluentui-react-native/framework-base';
|
|
4
4
|
export { mergeProps, mergeStyles } from '@fluentui-react-native/framework-base';
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
borderStyles,
|
|
8
|
-
borderTokens,
|
|
9
|
-
colorTokens,
|
|
10
|
-
fontStyles,
|
|
11
|
-
foregroundColorTokens,
|
|
12
|
-
getPaletteFromTheme,
|
|
13
|
-
layoutStyles,
|
|
14
|
-
layoutTokens,
|
|
15
|
-
shadowStyles,
|
|
16
|
-
shadowTokens,
|
|
17
|
-
textTokens,
|
|
18
|
-
tokenBuilder,
|
|
19
|
-
} from '@fluentui-react-native/tokens';
|
|
20
|
-
export type {
|
|
21
|
-
FontStyleTokens,
|
|
22
|
-
FontTokens,
|
|
23
|
-
FontVariantTokens,
|
|
24
|
-
IBackgroundColorTokens,
|
|
25
|
-
IBorderTokens,
|
|
26
|
-
IColorTokens,
|
|
27
|
-
IForegroundColorTokens,
|
|
28
|
-
IShadowTokens,
|
|
29
|
-
LayoutTokens,
|
|
30
|
-
TokenBuilder,
|
|
31
|
-
} from '@fluentui-react-native/tokens';
|
|
5
|
+
export { backgroundColorTokens, borderStyles, borderTokens, colorTokens, fontStyles, foregroundColorTokens, getPaletteFromTheme, layoutStyles, layoutTokens, shadowStyles, shadowTokens, textTokens, tokenBuilder, } from '@fluentui-react-native/tokens';
|
|
6
|
+
export type { FontStyleTokens, FontTokens, FontVariantTokens, IBackgroundColorTokens, IBorderTokens, IColorTokens, IForegroundColorTokens, IShadowTokens, LayoutTokens, TokenBuilder, } from '@fluentui-react-native/tokens';
|
|
32
7
|
export { useSlot } from '@fluentui-react-native/use-slot';
|
|
33
8
|
export { renderSlot, stagedComponent, withSlots } from '@fluentui-react-native/framework-base';
|
|
34
9
|
export type { ComposableFunction, FinalRender, NativeReactType, SlotFn, StagedRender } from '@fluentui-react-native/framework-base';
|
|
35
10
|
export { buildUseSlots } from '@fluentui-react-native/use-slots';
|
|
36
11
|
export type { GetSlotProps, Slots, UseSlotOptions, UseSlotsBase } from '@fluentui-react-native/use-slots';
|
|
37
12
|
export { immutableMerge, immutableMergeCore, processImmutable } from '@fluentui-react-native/framework-base';
|
|
38
|
-
export type {
|
|
39
|
-
BuiltinRecursionHandlers,
|
|
40
|
-
CustomRecursionHandler,
|
|
41
|
-
MergeOptions,
|
|
42
|
-
ObjectBase,
|
|
43
|
-
RecursionHandler,
|
|
44
|
-
RecursionOption,
|
|
45
|
-
} from '@fluentui-react-native/framework-base';
|
|
13
|
+
export type { BuiltinRecursionHandlers, CustomRecursionHandler, MergeOptions, ObjectBase, RecursionHandler, RecursionOption, } from '@fluentui-react-native/framework-base';
|
|
46
14
|
export { ThemeContext, useTheme } from '@fluentui-react-native/theme-types';
|
|
47
|
-
export type {
|
|
48
|
-
AliasColorTokens,
|
|
49
|
-
AppearanceOptions,
|
|
50
|
-
Color,
|
|
51
|
-
FontFamilies,
|
|
52
|
-
FontFamily,
|
|
53
|
-
FontFamilyValue,
|
|
54
|
-
FontSize,
|
|
55
|
-
FontSizeValuePoints,
|
|
56
|
-
FontSizes,
|
|
57
|
-
FontWeight,
|
|
58
|
-
FontWeightValue,
|
|
59
|
-
FontWeights,
|
|
60
|
-
OfficePalette,
|
|
61
|
-
Palette,
|
|
62
|
-
PaletteBackgroundColors,
|
|
63
|
-
PaletteTextColors,
|
|
64
|
-
PartialPalette,
|
|
65
|
-
PartialTheme,
|
|
66
|
-
PartialTypography,
|
|
67
|
-
Spacing,
|
|
68
|
-
TextStyling,
|
|
69
|
-
Theme,
|
|
70
|
-
ThemeColorDefinition,
|
|
71
|
-
ThemeOptions,
|
|
72
|
-
Typography,
|
|
73
|
-
Variant,
|
|
74
|
-
VariantValue,
|
|
75
|
-
Variants,
|
|
76
|
-
} from '@fluentui-react-native/theme-types';
|
|
15
|
+
export type { AliasColorTokens, AppearanceOptions, Color, FontFamilies, FontFamily, FontFamilyValue, FontSize, FontSizeValuePoints, FontSizes, FontWeight, FontWeightValue, FontWeights, OfficePalette, Palette, PaletteBackgroundColors, PaletteTextColors, PartialPalette, PartialTheme, PartialTypography, Spacing, TextStyling, Theme, ThemeColorDefinition, ThemeOptions, Typography, Variant, VariantValue, Variants, } from '@fluentui-react-native/theme-types';
|
|
77
16
|
export { compose } from './compose';
|
|
78
|
-
export type {
|
|
79
|
-
ComposableComponent,
|
|
80
|
-
ComposeOptions,
|
|
81
|
-
ComposeType,
|
|
82
|
-
ExtractProps,
|
|
83
|
-
ExtractSlotProps,
|
|
84
|
-
ExtractStatics,
|
|
85
|
-
ExtractTokens,
|
|
86
|
-
UseSlots,
|
|
87
|
-
} from './compose';
|
|
17
|
+
export type { ComposableComponent, ComposeOptions, ComposeType, ExtractProps, ExtractSlotProps, ExtractStatics, ExtractTokens, UseSlots, } from './compose';
|
|
88
18
|
export { compressible } from './compressible';
|
|
89
19
|
export { useFluentTheme } from './useFluentTheme';
|
|
90
20
|
export type { HasLayer, TokensThatAreAlsoProps, UseStyling } from './useStyling';
|
|
@@ -92,4 +22,4 @@ export { buildProps, buildUseStyling } from './useStyling';
|
|
|
92
22
|
export type { BuildProps, TokenSettings, TokensFromTheme, UseStylingOptions } from './useStyling';
|
|
93
23
|
export { applyPropsToTokens, applyTokenLayers, buildUseTokens, customizable, patchTokens } from './useTokens';
|
|
94
24
|
export type { UseTokens, CustomizableComponent } from './useTokens';
|
|
95
|
-
//# sourceMappingURL=index.d.ts.map
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|