@fluentui-react-native/use-styling 0.13.12 → 0.14.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.
Files changed (41) hide show
  1. package/CHANGELOG.json +1 -1
  2. package/CHANGELOG.md +39 -2
  3. package/README.md +1 -1
  4. package/lib/buildProps.d.ts +14 -6
  5. package/lib/buildProps.js +28 -24
  6. package/lib/buildProps.js.map +1 -1
  7. package/lib/buildProps.test.d.ts +1 -1
  8. package/lib/buildProps.test.js +28 -28
  9. package/lib/buildProps.test.js.map +1 -1
  10. package/lib/buildUseStyling.d.ts +30 -27
  11. package/lib/buildUseStyling.js +30 -31
  12. package/lib/buildUseStyling.js.map +1 -1
  13. package/lib/buildUseStyling.test.d.ts +1 -1
  14. package/lib/buildUseStyling.test.js +67 -64
  15. package/lib/buildUseStyling.test.js.map +1 -1
  16. package/lib/index.d.ts +1 -1
  17. package/lib/index.js +1 -1
  18. package/lib/useStyling.samples.test.d.ts +1 -1
  19. package/lib/useStyling.samples.test.js +171 -148
  20. package/lib/useStyling.samples.test.js.map +1 -1
  21. package/lib-commonjs/buildProps.d.ts +14 -6
  22. package/lib-commonjs/buildProps.js +32 -29
  23. package/lib-commonjs/buildProps.js.map +1 -1
  24. package/lib-commonjs/buildProps.test.d.ts +1 -1
  25. package/lib-commonjs/buildProps.test.js +32 -32
  26. package/lib-commonjs/buildProps.test.js.map +1 -1
  27. package/lib-commonjs/buildUseStyling.d.ts +30 -27
  28. package/lib-commonjs/buildUseStyling.js +35 -37
  29. package/lib-commonjs/buildUseStyling.js.map +1 -1
  30. package/lib-commonjs/buildUseStyling.test.d.ts +1 -1
  31. package/lib-commonjs/buildUseStyling.test.js +72 -69
  32. package/lib-commonjs/buildUseStyling.test.js.map +1 -1
  33. package/lib-commonjs/index.d.ts +1 -1
  34. package/lib-commonjs/index.js +30 -10
  35. package/lib-commonjs/index.js.map +1 -1
  36. package/lib-commonjs/useStyling.samples.test.d.ts +1 -1
  37. package/lib-commonjs/useStyling.samples.test.js +227 -177
  38. package/lib-commonjs/useStyling.samples.test.js.map +1 -1
  39. package/package.json +46 -46
  40. package/src/buildProps.ts +2 -2
  41. package/src/useStyling.samples.test.tsx +23 -14
@@ -1,45 +1,73 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const React = __importStar(require("react"));
27
- const react_native_1 = require("react-native");
28
- const renderer = __importStar(require("react-test-renderer"));
29
- const buildProps_1 = require("./buildProps");
30
- const buildUseStyling_1 = require("./buildUseStyling");
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
+ Object.defineProperty(exports, '__esModule', { value: true });
53
+ const jsx_runtime_1 = require('react/jsx-runtime');
54
+ const react_1 = require('react');
55
+ const react_native_1 = require('react-native');
56
+ const renderer = __importStar(require('react-test-renderer'));
57
+ const buildProps_1 = require('./buildProps');
58
+ const buildUseStyling_1 = require('./buildUseStyling');
31
59
  /**
32
60
  * The default/base theme just contains base values
33
61
  */
34
62
  const baseTheme = {
35
- globals: {
36
- backgroundColor: 'white',
37
- color: 'black',
38
- borderColor: 'blue',
39
- fontFamily: 'Arial',
40
- fontSize: 12,
41
- },
42
- components: {},
63
+ globals: {
64
+ backgroundColor: 'white',
65
+ color: 'black',
66
+ borderColor: 'blue',
67
+ fontFamily: 'Arial',
68
+ fontSize: 12,
69
+ },
70
+ components: {},
43
71
  };
44
72
  const current = { theme: baseTheme };
45
73
  /**
@@ -48,156 +76,178 @@ const current = { theme: baseTheme };
48
76
  * whatever system they desire
49
77
  */
50
78
  const themeHelper = {
51
- useTheme: () => current.theme,
52
- getComponentInfo: (theme, name) => theme.components[name],
53
- setActive: (theme) => {
54
- current.theme = theme ? { ...baseTheme, ...theme } : baseTheme;
55
- },
79
+ useTheme: () => current.theme,
80
+ getComponentInfo: (theme, name) => theme.components[name],
81
+ setActive: (theme) => {
82
+ current.theme = theme ? { ...baseTheme, ...theme } : baseTheme;
83
+ },
56
84
  };
57
85
  describe('useStyling samples', () => {
86
+ /**
87
+ * Sample #1 - Themeable text element
88
+ *
89
+ * This adds some default opinions for how a text element should be styled but only allows for customization
90
+ * via theming
91
+ */
92
+ // now create the styling hook, first the options so they can be reused later
93
+ const sample1StylingOptions = {
58
94
  /**
59
- * Sample #1 - Themeable text element
60
- *
61
- * This adds some default opinions for how a text element should be styled but only allows for customization
62
- * via theming
95
+ * tell the styling hook how to build up the tokens
63
96
  */
64
- // now create the styling hook, first the options so they can be reused later
65
- const sample1StylingOptions = {
97
+ tokens: [
98
+ /** first the default values should come from the global theme section */
99
+ (t) => ({
100
+ color: t.globals.color,
101
+ fontFamily: t.globals.fontFamily,
102
+ fontSize: t.globals.fontSize,
103
+ }),
104
+ /** next we should look for a component reference to overlay */
105
+ 'Sample1',
106
+ ],
107
+ /**
108
+ * Now provide the recipe for how to build props for the sub-components given the tokens
109
+ */
110
+ slotProps: {
111
+ /** only one sub-component, a Text element called content, as a result this needs to build up TextProps */
112
+ content: (0, buildProps_1.buildProps)(
66
113
  /**
67
- * tell the styling hook how to build up the tokens
114
+ * first input for buildProps is a function which takes tokens and a theme and returns props
68
115
  */
69
- tokens: [
70
- /** first the default values should come from the global theme section */
71
- (t) => ({
72
- color: t.globals.color,
73
- fontFamily: t.globals.fontFamily,
74
- fontSize: t.globals.fontSize,
75
- }),
76
- /** next we should look for a component reference to overlay */
77
- 'Sample1',
78
- ],
116
+ (tokens /*, theme: Theme */) => {
117
+ return {
118
+ style: { ...tokens },
119
+ };
120
+ },
79
121
  /**
80
- * Now provide the recipe for how to build props for the sub-components given the tokens
122
+ * The second input are the tokens used as inputs for the above function. This is similar to the way the useEffect hook
123
+ * works in react.
81
124
  */
82
- slotProps: {
83
- /** only one sub-component, a Text element called content, as a result this needs to build up TextProps */
84
- content: (0, buildProps_1.buildProps)(
85
- /**
86
- * first input for buildProps is a function which takes tokens and a theme and returns props
87
- */
88
- (tokens /*, theme: Theme */) => {
89
- return {
90
- style: { ...tokens },
91
- };
92
- },
93
- /**
94
- * The second input are the tokens used as inputs for the above function. This is similar to the way the useEffect hook
95
- * works in react.
96
- */
97
- ['color', 'fontFamily', 'fontSize']),
125
+ ['color', 'fontFamily', 'fontSize'],
126
+ ),
127
+ },
128
+ };
129
+ // now build the actual hook from the options and theme helper
130
+ const useStylingSample1 = (0, buildUseStyling_1.buildUseStyling)(sample1StylingOptions, themeHelper);
131
+ // now the sample 1 component becomes simple to build, just merge the styled props with the input props
132
+ const Sample1Text = (props) => {
133
+ const styledProps = useStylingSample1(props).content;
134
+ const merged = { ...props, ...styledProps };
135
+ return jsx_runtime_1.jsx(react_native_1.Text, { ...merged, children: props.children });
136
+ };
137
+ /** first render the component with no updates */
138
+ it('Sample1Text rendering with no overrides', () => {
139
+ let component;
140
+ (0, react_1.act)(() => {
141
+ component = renderer.create(jsx_runtime_1.jsx(Sample1Text, { children: 'Sample1a' }));
142
+ });
143
+ expect(component.toJSON()).toMatchSnapshot();
144
+ });
145
+ /** now re-theme the component via the components in the theme */
146
+ it('Sample1Text rendering with some custom settings in the theme', () => {
147
+ themeHelper.setActive({
148
+ components: {
149
+ Sample1: {
150
+ color: 'pink',
151
+ fontSize: 24,
98
152
  },
99
- };
100
- // now build the actual hook from the options and theme helper
101
- const useStylingSample1 = (0, buildUseStyling_1.buildUseStyling)(sample1StylingOptions, themeHelper);
102
- // now the sample 1 component becomes simple to build, just merge the styled props with the input props
103
- const Sample1Text = (props) => {
104
- const styledProps = useStylingSample1(props).content;
105
- const merged = { ...props, ...styledProps };
106
- return React.createElement(react_native_1.Text, { ...merged }, props.children);
107
- };
108
- /** first render the component with no updates */
109
- it('Sample1Text rendering with no overrides', () => {
110
- const tree = renderer.create(React.createElement(Sample1Text, null, "Sample1a")).toJSON();
111
- expect(tree).toMatchSnapshot();
153
+ },
112
154
  });
113
- /** now re-theme the component via the components in the theme */
114
- it('Sample1Text rendering with some custom settings in the theme', () => {
115
- themeHelper.setActive({
116
- components: {
117
- Sample1: {
118
- color: 'pink',
119
- fontSize: 24,
120
- },
121
- },
122
- });
123
- const tree = renderer.create(React.createElement(Sample1Text, null, "Sample1b")).toJSON();
124
- expect(tree).toMatchSnapshot();
155
+ let component;
156
+ (0, react_1.act)(() => {
157
+ component = renderer.create(jsx_runtime_1.jsx(Sample1Text, { children: 'Sample1b' }));
125
158
  });
126
- /**
127
- * Build the styling hook for sample2. Because this isn't being recombined this is being specified inline rather
128
- * than using a separate options object. Both are fine.
129
- */
130
- const useStylingSample2 = (0, buildUseStyling_1.buildUseStyling)({
131
- /**
132
- * This just starts with the baseline styling from sample1, in particular we are using the recipes of how to turn
133
- * token values into the props for the internal sub-components. While this example is not super complex, for real-world
134
- * components, re-using these can be extremely valuable.
135
- *
136
- * With that in mind, this copies over the recipes for how to turn tokens into props, the customizations that
137
- * will be made are about how to ensure the tokens are set up correctly.
138
- */
139
- ...sample1StylingOptions,
140
- /**
141
- * In sample1 tokens are set to defaults from the global theme section, then patched with any values looked up with
142
- * the string 'Sample1'
143
- *
144
- * We want to maintain the logic of setting up the globals, but add an additional lookup for 'Sample2'. This might correspond
145
- * to saying that if we were making a variant of a 'Text' component called 'HeaderText', we might want to look up
146
- * customizations from 'Text' first, then override those customizations with those from 'HeaderText'
147
- *
148
- * If we didn't want to add the extra 'Sample2' lookup this line would be omitted. If we didn't want to look up 'Sample1' first
149
- * that could be filtered out of the array that is being copied
150
- */
151
- tokens: [...sample1StylingOptions.tokens, 'Sample2'],
152
- /**
153
- * This is the final bit of magic. The tokens will already have values set from the global theme, they will then be patched with
154
- * any customizations set into Sample1 and/or Sample2.
155
- *
156
- * If this value was omitted then the tokens would be passed to the slotProps recipies as is. To have those values patched from
157
- * the component props we add a list of the props which need to be passed into tokens. If all props should be spread into the
158
- * tokens then this value can be set to 'all'. If none should be passed it can be omitted or set to 'none'
159
- */
160
- tokensThatAreAlsoProps: ['color'],
161
- }, themeHelper);
162
- // the Sample2Text component is built the same way as sample1, just using the new hook that has been created
163
- const Sample2Text = (props) => {
164
- const styledProps = useStylingSample2(props).content;
165
- const merged = { ...props, ...styledProps };
166
- // delete the color key to not pass it through to the text props, could be done via destructuring, filtering, or any number of ways
167
- delete merged.color;
168
- // render the text
169
- return React.createElement(react_native_1.Text, { ...merged }, props.children);
170
- };
171
- /** rendering the Sample2 component with the base theme */
172
- it('Sample2Text rendering with defaults and a color override', () => {
173
- themeHelper.setActive();
174
- const tree = renderer
175
- .create(React.createElement(react_native_1.View, null,
176
- React.createElement(Sample2Text, null, "Sample2 with defaults"),
177
- React.createElement(Sample2Text, { color: "green" }, "Sample2 with color override via prop")))
178
- .toJSON();
179
- expect(tree).toMatchSnapshot();
159
+ expect(component.toJSON()).toMatchSnapshot();
160
+ });
161
+ /**
162
+ * Build the styling hook for sample2. Because this isn't being recombined this is being specified inline rather
163
+ * than using a separate options object. Both are fine.
164
+ */
165
+ const useStylingSample2 = (0, buildUseStyling_1.buildUseStyling)(
166
+ {
167
+ /**
168
+ * This just starts with the baseline styling from sample1, in particular we are using the recipes of how to turn
169
+ * token values into the props for the internal sub-components. While this example is not super complex, for real-world
170
+ * components, re-using these can be extremely valuable.
171
+ *
172
+ * With that in mind, this copies over the recipes for how to turn tokens into props, the customizations that
173
+ * will be made are about how to ensure the tokens are set up correctly.
174
+ */
175
+ ...sample1StylingOptions,
176
+ /**
177
+ * In sample1 tokens are set to defaults from the global theme section, then patched with any values looked up with
178
+ * the string 'Sample1'
179
+ *
180
+ * We want to maintain the logic of setting up the globals, but add an additional lookup for 'Sample2'. This might correspond
181
+ * to saying that if we were making a variant of a 'Text' component called 'HeaderText', we might want to look up
182
+ * customizations from 'Text' first, then override those customizations with those from 'HeaderText'
183
+ *
184
+ * If we didn't want to add the extra 'Sample2' lookup this line would be omitted. If we didn't want to look up 'Sample1' first
185
+ * that could be filtered out of the array that is being copied
186
+ */
187
+ tokens: [...sample1StylingOptions.tokens, 'Sample2'],
188
+ /**
189
+ * This is the final bit of magic. The tokens will already have values set from the global theme, they will then be patched with
190
+ * any customizations set into Sample1 and/or Sample2.
191
+ *
192
+ * If this value was omitted then the tokens would be passed to the slotProps recipies as is. To have those values patched from
193
+ * the component props we add a list of the props which need to be passed into tokens. If all props should be spread into the
194
+ * tokens then this value can be set to 'all'. If none should be passed it can be omitted or set to 'none'
195
+ */
196
+ tokensThatAreAlsoProps: ['color'],
197
+ },
198
+ themeHelper,
199
+ );
200
+ // the Sample2Text component is built the same way as sample1, just using the new hook that has been created
201
+ const Sample2Text = (props) => {
202
+ const styledProps = useStylingSample2(props).content;
203
+ const merged = { ...props, ...styledProps };
204
+ // delete the color key to not pass it through to the text props, could be done via destructuring, filtering, or any number of ways
205
+ delete merged.color;
206
+ // render the text
207
+ return jsx_runtime_1.jsx(react_native_1.Text, { ...merged, children: props.children });
208
+ };
209
+ /** rendering the Sample2 component with the base theme */
210
+ it('Sample2Text rendering with defaults and a color override', () => {
211
+ themeHelper.setActive();
212
+ let component;
213
+ (0, react_1.act)(() => {
214
+ component = renderer.create(
215
+ jsx_runtime_1.jsxs(react_native_1.View, {
216
+ children: [
217
+ jsx_runtime_1.jsx(Sample2Text, { children: 'Sample2 with defaults' }),
218
+ jsx_runtime_1.jsx(Sample2Text, { color: 'green', children: 'Sample2 with color override via prop' }),
219
+ ],
220
+ }),
221
+ );
180
222
  });
181
- /** now re-theme the component via the components in the theme */
182
- it('Sample2Text rendering with some custom settings in the theme', () => {
183
- themeHelper.setActive({
184
- components: {
185
- Sample1: {
186
- color: 'pink',
187
- fontSize: 24,
188
- },
189
- Sample2: {
190
- fontSize: 18,
191
- fontFamily: 'Helvetica',
192
- },
193
- },
194
- });
195
- const tree = renderer
196
- .create(React.createElement(react_native_1.View, null,
197
- React.createElement(Sample2Text, null, "Sample2 with theme overrides set"),
198
- React.createElement(Sample2Text, { color: "purple" }, "Sample2 with theme and color prop override")))
199
- .toJSON();
200
- expect(tree).toMatchSnapshot();
223
+ expect(component.toJSON()).toMatchSnapshot();
224
+ });
225
+ /** now re-theme the component via the components in the theme */
226
+ it('Sample2Text rendering with some custom settings in the theme', () => {
227
+ themeHelper.setActive({
228
+ components: {
229
+ Sample1: {
230
+ color: 'pink',
231
+ fontSize: 24,
232
+ },
233
+ Sample2: {
234
+ fontSize: 18,
235
+ fontFamily: 'Helvetica',
236
+ },
237
+ },
238
+ });
239
+ let component;
240
+ (0, react_1.act)(() => {
241
+ component = renderer.create(
242
+ jsx_runtime_1.jsxs(react_native_1.View, {
243
+ children: [
244
+ jsx_runtime_1.jsx(Sample2Text, { children: 'Sample2 with theme overrides set' }),
245
+ jsx_runtime_1.jsx(Sample2Text, { color: 'purple', children: 'Sample2 with theme and color prop override' }),
246
+ ],
247
+ }),
248
+ );
201
249
  });
250
+ expect(component.toJSON()).toMatchSnapshot();
251
+ });
202
252
  });
203
- //# sourceMappingURL=useStyling.samples.test.js.map
253
+ //# sourceMappingURL=useStyling.samples.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useStyling.samples.test.js","sourceRoot":"","sources":["../src/useStyling.samples.test.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAE/B,+CAA0C;AAE1C,8DAAgD;AAEhD,6CAA0C;AAE1C,uDAAoD;AAuBpD;;GAEG;AACH,MAAM,SAAS,GAAU;IACvB,OAAO,EAAE;QACP,eAAe,EAAE,OAAO;QACxB,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,MAAM;QACnB,UAAU,EAAE,OAAO;QACnB,QAAQ,EAAE,EAAE;KACb;IACD,UAAU,EAAE,EAAE;CACf,CAAC;AAEF,MAAM,OA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OAAO,qDAAmD;oBACxE,CACR,CAAC;QAAA,CACH,CAAC,CAAC;QACH,MAAM,CAAC,SAAU,CAAC,MAAM,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC;IAAA,CAC/C,CAAC,CAAC;IAEH,iEAAiE;IACjE,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE,CAAC;QACvE,WAAW,CAAC,SAAS,CAAC;YACpB,UAAU,EAAE;gBACV,OAAO,EAAE;oBACP,KAAK,EAAE,MAAM;oBACb,QAAQ,EAAE,EAAE;iBACb;gBACD,OAAO,EAAE;oBACP,QAAQ,EAAE,EAAE;oBACZ,UAAU,EAAE,WAAW;iBACxB;aACF;SACF,CAAC,CAAC;QACH,IAAI,SAAqC,CAAC;QAC1C,IAAA,WAAG,EAAC,GAAG,EAAE,CAAC;YACR,SAAS,GAAG,QAAQ,CAAC,MAAM,CACzB,mBAAC,mBAAI;oBACH,kBAAC,WAAW,mDAA+C,EAC3D,kBAAC,WAAW,IAAC,KAAK,EAAC,QAAQ,2DAAyD;oBAC/E,CACR,CAAC;QAAA,CACH,CAAC,CAAC;QACH,MAAM,CAAC,SAAU,CAAC,MAAM,EAAE,CAAC,CAAC,eAAe,EAAE,CAAC;IAAA,CAC/C,CAAC,CAAC;AAAA,CACJ,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,84 +1,84 @@
1
1
  {
2
2
  "name": "@fluentui-react-native/use-styling",
3
- "version": "0.13.12",
3
+ "version": "0.14.0",
4
4
  "description": "Opinionated use styling hook implementation",
5
+ "keywords": [],
5
6
  "repository": {
6
7
  "type": "git",
7
8
  "url": "https://github.com/microsoft/fluentui-react-native",
8
9
  "directory": "packages/framework/use-styling"
9
10
  },
10
- "main": "lib-commonjs/index.js",
11
- "module": "lib/index.js",
12
- "react-native": "src/index.ts",
11
+ "license": "MIT",
12
+ "author": "",
13
13
  "exports": {
14
14
  ".": {
15
+ "types": "./lib/index.d.ts",
15
16
  "import": "./lib/index.js",
16
- "require": "./lib-commonjs/index.js",
17
- "types": "./lib/index.d.ts"
17
+ "require": "./lib-commonjs/index.js"
18
18
  }
19
19
  },
20
- "typings": "lib/index.d.ts",
20
+ "main": "lib-commonjs/index.js",
21
+ "module": "lib/index.js",
22
+ "types": "lib/index.d.ts",
21
23
  "scripts": {
22
24
  "build": "fluentui-scripts build",
25
+ "build-cjs": "tsgo --outDir lib-commonjs",
26
+ "build-esm": "tsgo --outDir lib --module esnext --moduleResolution bundler",
23
27
  "clean": "fluentui-scripts clean",
24
28
  "depcheck": "fluentui-scripts depcheck",
25
- "just": "fluentui-scripts",
26
29
  "lint": "fluentui-scripts eslint",
30
+ "lint-package": "fluentui-scripts lint-package",
31
+ "prettier": "fluentui-scripts prettier",
27
32
  "start": "fluentui-scripts dev",
28
33
  "start-test": "fluentui-scripts jest-watch",
29
34
  "test": "fluentui-scripts jest",
30
- "update-snapshots": "fluentui-scripts jest -u",
31
- "prettier": "fluentui-scripts prettier",
32
- "prettier-fix": "fluentui-scripts prettier --fix true"
35
+ "update-snapshots": "fluentui-scripts jest -u"
33
36
  },
34
- "keywords": [],
35
- "author": "",
36
- "license": "MIT",
37
37
  "dependencies": {
38
- "@fluentui-react-native/framework-base": "0.2.1",
39
- "@fluentui-react-native/use-tokens": "0.6.12"
38
+ "@fluentui-react-native/framework-base": "0.3.0",
39
+ "@fluentui-react-native/use-tokens": "0.7.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@babel/core": "^7.20.0",
43
43
  "@fluentui-react-native/babel-config": "0.1.1",
44
44
  "@fluentui-react-native/eslint-config-rules": "0.1.1",
45
45
  "@fluentui-react-native/jest-config": "0.1.1",
46
- "@fluentui-react-native/scripts": "0.1.1",
47
- "@react-native/babel-preset": "^0.74.0",
48
- "@react-native/metro-config": "^0.74.0",
46
+ "@fluentui-react-native/kit-config": "0.1.2",
47
+ "@fluentui-react-native/scripts": "0.1.2",
48
+ "@react-native-community/cli": "^20.0.0",
49
+ "@react-native-community/cli-platform-android": "^20.0.0",
50
+ "@react-native-community/cli-platform-ios": "^20.0.0",
51
+ "@react-native/babel-preset": "^0.81.0",
52
+ "@react-native/metro-config": "^0.81.0",
49
53
  "@types/jest": "^29.0.0",
50
- "@types/react": "18.2.0",
51
- "@types/react-test-renderer": "^18.2.0",
52
- "react": "18.2.0",
53
- "react-native": "^0.74.0",
54
- "react-test-renderer": "18.2.0"
54
+ "@types/react": "~19.1.0",
55
+ "@types/react-test-renderer": "^19.1.0",
56
+ "react": "19.1.0",
57
+ "react-native": "^0.81.0",
58
+ "react-test-renderer": "19.1.0"
59
+ },
60
+ "peerDependencies": {
61
+ "@types/react": "~18.2.0 || ~19.0.0 || ~19.1.0",
62
+ "react": "18.2.0 || 19.0.0 || 19.1.0"
63
+ },
64
+ "peerDependenciesMeta": {
65
+ "@types/react": {
66
+ "optional": true
67
+ }
55
68
  },
56
69
  "rnx-kit": {
57
70
  "kitType": "library",
58
71
  "alignDeps": {
59
- "presets": [
60
- "microsoft/react-native"
61
- ],
62
- "requirements": {
63
- "development": [
64
- "react-native@0.74"
65
- ],
66
- "production": [
67
- "react-native@0.73 || 0.74"
68
- ]
69
- },
70
72
  "capabilities": [
71
- "babel-preset-react-native",
72
- "core",
73
- "core-android",
74
- "core-ios",
73
+ "core-android-dev-only",
74
+ "core-dev-only",
75
+ "core-ios-dev-only",
75
76
  "react",
76
- "react-test-renderer"
77
+ "react-test-renderer",
78
+ "tools-core",
79
+ "tools-jest"
77
80
  ]
78
- }
79
- },
80
- "peerDependencies": {
81
- "react": "18.2.0",
82
- "react-native": "^0.73.0 || ^0.74.0"
81
+ },
82
+ "extends": "@fluentui-react-native/kit-config"
83
83
  }
84
- }
84
+ }
package/src/buildProps.ts CHANGED
@@ -97,10 +97,10 @@ export function refinePropsFunctions<TSlotProps, TTokens, TTheme>(
97
97
  mask: TokensThatAreAlsoProps<TTokens>,
98
98
  ): BuildSlotProps<TSlotProps, TTokens, TTheme> {
99
99
  const result = {};
100
- Object.keys(styles).forEach((key) => {
100
+ for (const key of Object.keys(styles)) {
101
101
  const refine =
102
102
  typeof styles[key] === 'function' && (styles[key] as RefinableBuildPropsBase<TSlotProps[keyof TSlotProps], TTokens, TTheme>).refine;
103
103
  result[key] = refine ? refine(mask) : styles[key];
104
- });
104
+ }
105
105
  return result;
106
106
  }