@fluentui-react-native/composition 0.12.0 → 0.12.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 CHANGED
@@ -1,5 +1,37 @@
1
1
  # Change Log - @fluentui-react-native/composition
2
2
 
3
+ ## 0.12.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 9cf4444: Migrate from ESLint to oxlint
8
+ - Updated dependencies [9cf4444]
9
+ - @fluentui-react-native/use-styling@0.14.3
10
+ - @fluentui-react-native/use-slots@0.11.3
11
+ - @fluentui-react-native/framework-base@0.3.3
12
+
13
+ ## 0.12.2
14
+
15
+ ### Patch Changes
16
+
17
+ - 8a7b549: Update to the latest rnx-kit versions, fix some typing issues, and correct the vscode settings
18
+ - Updated dependencies [8a7b549]
19
+ - @fluentui-react-native/use-styling@0.14.2
20
+ - @fluentui-react-native/use-slots@0.11.2
21
+ - @fluentui-react-native/framework-base@0.3.2
22
+
23
+ ## 0.12.1
24
+
25
+ ### Patch Changes
26
+
27
+ - 0d6e9c1: chore: migrate to `oxfmt`
28
+ - ac6e7af: Ensure packages have a default export that references the typescript entrypoint and clean up build dependency ordering
29
+ - Updated dependencies [0d6e9c1]
30
+ - Updated dependencies [ac6e7af]
31
+ - @fluentui-react-native/use-styling@0.14.1
32
+ - @fluentui-react-native/use-slots@0.11.1
33
+ - @fluentui-react-native/framework-base@0.3.1
34
+
3
35
  ## 0.12.0
4
36
 
5
37
  ### Minor Changes
@@ -2,13 +2,7 @@ import type { ComposableFunction, FinalRender } from '@fluentui-react-native/fra
2
2
  import type { UseSlotOptions, Slots } from '@fluentui-react-native/use-slots';
3
3
  import type { UseStylingOptions, TokenSettings, ThemeHelper, HasLayer } from '@fluentui-react-native/use-styling';
4
4
  export type UseStyledSlots<TProps, TSlotProps> = (props: TProps, lookup?: HasLayer) => Slots<TSlotProps>;
5
- export type ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object> = UseStylingOptions<
6
- TProps,
7
- TSlotProps,
8
- TTokens,
9
- TTheme
10
- > &
11
- UseSlotOptions<TSlotProps> & {
5
+ export type ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object> = UseStylingOptions<TProps, TSlotProps, TTokens, TTheme> & UseSlotOptions<TSlotProps> & {
12
6
  /**
13
7
  * Includes from UseStylingOptions:
14
8
  *
@@ -22,17 +16,11 @@ export type ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics
22
16
  * optional statics to attach to the component
23
17
  */
24
18
  statics?: TStatics;
25
- };
19
+ };
26
20
  export type ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object> = ComposableFunction<TProps> & {
27
- __options: ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics>;
28
- customize: (...tokens: TokenSettings<TTokens, TTheme>[]) => ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>;
29
- compose<TOverrideSlotProps = TSlotProps>(
30
- options: Partial<ComposeFactoryOptions<TProps, TOverrideSlotProps, TTokens, TTheme, TStatics>>,
31
- ): ComposeFactoryComponent<TProps, TOverrideSlotProps, TTokens, TTheme, TStatics>;
21
+ __options: ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics>;
22
+ customize: (...tokens: TokenSettings<TTokens, TTheme>[]) => ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>;
23
+ compose<TOverrideSlotProps = TSlotProps>(options: Partial<ComposeFactoryOptions<TProps, TOverrideSlotProps, TTokens, TTheme, TStatics>>): ComposeFactoryComponent<TProps, TOverrideSlotProps, TTokens, TTheme, TStatics>;
32
24
  } & TStatics;
33
- export declare function composeFactory<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object>(
34
- options: ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics>,
35
- themeHelper: ThemeHelper<TTheme>,
36
- base?: ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>,
37
- ): ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>;
38
- //# sourceMappingURL=composeFactory.d.ts.map
25
+ export declare function composeFactory<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object>(options: ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics>, themeHelper: ThemeHelper<TTheme>, base?: ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>): ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>;
26
+ //# sourceMappingURL=composeFactory.d.ts.map
@@ -6,28 +6,28 @@ import { buildUseStyling } from '@fluentui-react-native/use-styling';
6
6
  * options get deep merged except the tokens array gets appended
7
7
  */
8
8
  const mergeOptions = {
9
- tokens: 'appendArray',
10
- object: true,
9
+ tokens: 'appendArray',
10
+ object: true,
11
11
  };
12
12
  export function composeFactory(options, themeHelper, base) {
13
- // merge options together if a base is specified
14
- const baseOptions = base?.__options;
15
- options = baseOptions ? immutableMergeCore(mergeOptions, baseOptions, options) : { ...options };
16
- // build styling if styling options are specified
17
- options.useStyling = options.slotProps || options.tokens ? buildUseStyling(options, themeHelper) : () => ({});
18
- // build the slots hook, which will use the styling hook if it has been built
19
- const useSlots = buildUseSlots(options);
20
- // build the staged component
21
- const component = stagedComponent((props) => options.useRender(props, useSlots));
22
- // attach additional props to the returned component
23
- component.displayName = options.displayName;
24
- component.__options = options;
25
- component.customize = (...tokens) => composeFactory(immutableMergeCore(mergeOptions, options, { tokens: tokens }), themeHelper);
26
- component.compose = (customOptions) => composeFactory(immutableMergeCore(mergeOptions, options, customOptions), themeHelper);
27
- // attach statics if specified
28
- if (options.statics) {
29
- Object.assign(component, options.statics);
30
- }
31
- return component;
13
+ // merge options together if a base is specified
14
+ const baseOptions = base?.__options;
15
+ options = baseOptions ? immutableMergeCore(mergeOptions, baseOptions, options) : { ...options };
16
+ // build styling if styling options are specified
17
+ options.useStyling = options.slotProps || options.tokens ? buildUseStyling(options, themeHelper) : () => ({});
18
+ // build the slots hook, which will use the styling hook if it has been built
19
+ const useSlots = buildUseSlots(options);
20
+ // build the staged component
21
+ const component = stagedComponent((props) => options.useRender(props, useSlots));
22
+ // attach additional props to the returned component
23
+ component.displayName = options.displayName;
24
+ component.__options = options;
25
+ component.customize = (...tokens) => composeFactory(immutableMergeCore(mergeOptions, options, { tokens: tokens }), themeHelper);
26
+ component.compose = (customOptions) => composeFactory(immutableMergeCore(mergeOptions, options, customOptions), themeHelper);
27
+ // attach statics if specified
28
+ if (options.statics) {
29
+ Object.assign(component, options.statics);
30
+ }
31
+ return component;
32
32
  }
33
- //# sourceMappingURL=composeFactory.js.map
33
+ //# sourceMappingURL=composeFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"composeFactory.js","sourceRoot":"","sources":["../src/composeFactory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAqCrE;;GAEG;AACH,MAAM,YAAY,GAAiB;IACjC,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,MAAM,UAAU,cAAc,CAC5B,OAA6E,EAC7E,WAAgC,EAChC,IAA6E,EACL;IAIxE,gDAAgD;IAChD,MAAM,WAAW,GAAiB,IAAI,EAAE,SAAyB,CAAC;IAClE,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,kBAAkB,CAAe,YAAY,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;IAE9G,iDAAiD;IACjD,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,eAAe,CAA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C9B,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,SAAS,CAAC;AAAA,CAClB"}
@@ -1,2 +1,2 @@
1
1
  export {};
2
- //# sourceMappingURL=composeFactory.test.d.ts.map
2
+ //# sourceMappingURL=composeFactory.test.d.ts.map
@@ -1,69 +1,66 @@
1
- import { jsx as _jsx } from '@fluentui-react-native/framework-base/jsx-runtime';
1
+ import { jsx as _jsx } from "@fluentui-react-native/framework-base/jsx-runtime";
2
2
  /** @jsxImportSource @fluentui-react-native/framework-base */
3
3
  import { act } from 'react';
4
4
  import { View, Text } from 'react-native';
5
5
  import * as renderer from 'react-test-renderer';
6
6
  import { composeFactory } from './composeFactory';
7
7
  const theme = {
8
- values: {
9
- backgroundColor: 'black',
10
- color: 'white',
11
- },
12
- components: {},
8
+ values: {
9
+ backgroundColor: 'black',
10
+ color: 'white',
11
+ },
12
+ components: {},
13
13
  };
14
14
  const themeHelper = {
15
- useTheme: () => theme,
16
- getComponentInfo: (theme, name) => {
17
- return theme?.components ?? theme.components[name];
18
- },
15
+ useTheme: () => theme,
16
+ getComponentInfo: (theme, name) => {
17
+ return theme?.components ?? theme.components[name];
18
+ },
19
19
  };
20
20
  function mergeProps(p1, p2) {
21
- return { ...p1, ...p2 };
21
+ return { ...p1, ...p2 };
22
22
  }
23
- const Base = composeFactory(
24
- {
23
+ const Base = composeFactory({
25
24
  tokens: [
26
- (t) => ({
27
- backgroundColor: t.values.backgroundColor,
28
- color: t.values.color,
29
- }),
25
+ (t) => ({
26
+ backgroundColor: t.values.backgroundColor,
27
+ color: t.values.color,
28
+ }),
30
29
  ],
31
30
  slotProps: {
32
- outer: (tokens) => ({ style: { backgroundColor: tokens.backgroundColor } }),
33
- content: (tokens) => ({ style: { color: tokens.color } }),
31
+ outer: (tokens) => ({ style: { backgroundColor: tokens.backgroundColor } }),
32
+ content: (tokens) => ({ style: { color: tokens.color } }),
34
33
  },
35
34
  slots: {
36
- outer: View,
37
- content: Text,
35
+ outer: View,
36
+ content: Text,
38
37
  },
39
38
  useRender: (props, useSlots) => {
40
- const Slots = useSlots(props);
41
- return (extra) => _jsx(Slots.outer, { ...mergeProps(props, extra), children: _jsx(Slots.content, { children: 'Hello' }) });
39
+ const Slots = useSlots(props);
40
+ return (extra) => (_jsx(Slots.outer, { ...mergeProps(props, extra), children: _jsx(Slots.content, { children: "Hello" }) }));
42
41
  },
43
- },
44
- themeHelper,
45
- );
42
+ }, themeHelper);
46
43
  const Customized = Base.customize({ backgroundColor: 'pink' });
47
44
  const mixinStyle = {
48
- width: 30,
49
- height: 20,
50
- borderColor: 'green',
51
- borderWidth: 1,
45
+ width: 30,
46
+ height: 20,
47
+ borderColor: 'green',
48
+ borderWidth: 1,
52
49
  };
53
50
  describe('composeFactory test suite', () => {
54
- it('Base component render', () => {
55
- let component;
56
- act(() => {
57
- component = renderer.create(_jsx(Base, { style: mixinStyle }));
51
+ it('Base component render', () => {
52
+ let component;
53
+ act(() => {
54
+ component = renderer.create(_jsx(Base, { style: mixinStyle }));
55
+ });
56
+ expect(component.toJSON()).toMatchSnapshot();
58
57
  });
59
- expect(component.toJSON()).toMatchSnapshot();
60
- });
61
- it('Customized component render', () => {
62
- let component;
63
- act(() => {
64
- component = renderer.create(_jsx(Customized, { style: mixinStyle }));
58
+ it('Customized component render', () => {
59
+ let component;
60
+ act(() => {
61
+ component = renderer.create(_jsx(Customized, { style: mixinStyle }));
62
+ });
63
+ expect(component.toJSON()).toMatchSnapshot();
65
64
  });
66
- expect(component.toJSON()).toMatchSnapshot();
67
- });
68
65
  });
69
- //# sourceMappingURL=composeFactory.test.js.map
66
+ //# sourceMappingURL=composeFactory.test.js.map
package/lib/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { composeFactory } from './composeFactory';
2
2
  export type { ComposeFactoryComponent, ComposeFactoryOptions, UseStyledSlots } from './composeFactory';
3
- //# sourceMappingURL=index.d.ts.map
3
+ //# sourceMappingURL=index.d.ts.map
package/lib/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export { composeFactory } from './composeFactory';
2
- //# sourceMappingURL=index.js.map
2
+ //# sourceMappingURL=index.js.map
@@ -2,13 +2,7 @@ import type { ComposableFunction, FinalRender } from '@fluentui-react-native/fra
2
2
  import type { UseSlotOptions, Slots } from '@fluentui-react-native/use-slots';
3
3
  import type { UseStylingOptions, TokenSettings, ThemeHelper, HasLayer } from '@fluentui-react-native/use-styling';
4
4
  export type UseStyledSlots<TProps, TSlotProps> = (props: TProps, lookup?: HasLayer) => Slots<TSlotProps>;
5
- export type ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object> = UseStylingOptions<
6
- TProps,
7
- TSlotProps,
8
- TTokens,
9
- TTheme
10
- > &
11
- UseSlotOptions<TSlotProps> & {
5
+ export type ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object> = UseStylingOptions<TProps, TSlotProps, TTokens, TTheme> & UseSlotOptions<TSlotProps> & {
12
6
  /**
13
7
  * Includes from UseStylingOptions:
14
8
  *
@@ -22,17 +16,11 @@ export type ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics
22
16
  * optional statics to attach to the component
23
17
  */
24
18
  statics?: TStatics;
25
- };
19
+ };
26
20
  export type ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object> = ComposableFunction<TProps> & {
27
- __options: ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics>;
28
- customize: (...tokens: TokenSettings<TTokens, TTheme>[]) => ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>;
29
- compose<TOverrideSlotProps = TSlotProps>(
30
- options: Partial<ComposeFactoryOptions<TProps, TOverrideSlotProps, TTokens, TTheme, TStatics>>,
31
- ): ComposeFactoryComponent<TProps, TOverrideSlotProps, TTokens, TTheme, TStatics>;
21
+ __options: ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics>;
22
+ customize: (...tokens: TokenSettings<TTokens, TTheme>[]) => ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>;
23
+ compose<TOverrideSlotProps = TSlotProps>(options: Partial<ComposeFactoryOptions<TProps, TOverrideSlotProps, TTokens, TTheme, TStatics>>): ComposeFactoryComponent<TProps, TOverrideSlotProps, TTokens, TTheme, TStatics>;
32
24
  } & TStatics;
33
- export declare function composeFactory<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object>(
34
- options: ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics>,
35
- themeHelper: ThemeHelper<TTheme>,
36
- base?: ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>,
37
- ): ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>;
38
- //# sourceMappingURL=composeFactory.d.ts.map
25
+ export declare function composeFactory<TProps, TSlotProps, TTokens, TTheme, TStatics extends object = object>(options: ComposeFactoryOptions<TProps, TSlotProps, TTokens, TTheme, TStatics>, themeHelper: ThemeHelper<TTheme>, base?: ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>): ComposeFactoryComponent<TProps, TSlotProps, TTokens, TTheme, TStatics>;
26
+ //# sourceMappingURL=composeFactory.d.ts.map
@@ -1,38 +1,36 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.composeFactory = composeFactory;
4
- const framework_base_1 = require('@fluentui-react-native/framework-base');
5
- const framework_base_2 = require('@fluentui-react-native/framework-base');
6
- const use_slots_1 = require('@fluentui-react-native/use-slots');
7
- const use_styling_1 = require('@fluentui-react-native/use-styling');
4
+ const framework_base_1 = require("@fluentui-react-native/framework-base");
5
+ const framework_base_2 = require("@fluentui-react-native/framework-base");
6
+ const use_slots_1 = require("@fluentui-react-native/use-slots");
7
+ const use_styling_1 = require("@fluentui-react-native/use-styling");
8
8
  /**
9
9
  * options get deep merged except the tokens array gets appended
10
10
  */
11
11
  const mergeOptions = {
12
- tokens: 'appendArray',
13
- object: true,
12
+ tokens: 'appendArray',
13
+ object: true,
14
14
  };
15
15
  function composeFactory(options, themeHelper, base) {
16
- // merge options together if a base is specified
17
- const baseOptions = base?.__options;
18
- options = baseOptions ? (0, framework_base_1.immutableMergeCore)(mergeOptions, baseOptions, options) : { ...options };
19
- // build styling if styling options are specified
20
- options.useStyling = options.slotProps || options.tokens ? (0, use_styling_1.buildUseStyling)(options, themeHelper) : () => ({});
21
- // build the slots hook, which will use the styling hook if it has been built
22
- const useSlots = (0, use_slots_1.buildUseSlots)(options);
23
- // build the staged component
24
- const component = (0, framework_base_2.stagedComponent)((props) => options.useRender(props, useSlots));
25
- // attach additional props to the returned component
26
- component.displayName = options.displayName;
27
- component.__options = options;
28
- component.customize = (...tokens) =>
29
- composeFactory((0, framework_base_1.immutableMergeCore)(mergeOptions, options, { tokens: tokens }), themeHelper);
30
- component.compose = (customOptions) =>
31
- composeFactory((0, framework_base_1.immutableMergeCore)(mergeOptions, options, customOptions), themeHelper);
32
- // attach statics if specified
33
- if (options.statics) {
34
- Object.assign(component, options.statics);
35
- }
36
- return component;
16
+ // merge options together if a base is specified
17
+ const baseOptions = base?.__options;
18
+ options = baseOptions ? (0, framework_base_1.immutableMergeCore)(mergeOptions, baseOptions, options) : { ...options };
19
+ // build styling if styling options are specified
20
+ options.useStyling = options.slotProps || options.tokens ? (0, use_styling_1.buildUseStyling)(options, themeHelper) : () => ({});
21
+ // build the slots hook, which will use the styling hook if it has been built
22
+ const useSlots = (0, use_slots_1.buildUseSlots)(options);
23
+ // build the staged component
24
+ const component = (0, framework_base_2.stagedComponent)((props) => options.useRender(props, useSlots));
25
+ // attach additional props to the returned component
26
+ component.displayName = options.displayName;
27
+ component.__options = options;
28
+ component.customize = (...tokens) => composeFactory((0, framework_base_1.immutableMergeCore)(mergeOptions, options, { tokens: tokens }), themeHelper);
29
+ component.compose = (customOptions) => composeFactory((0, framework_base_1.immutableMergeCore)(mergeOptions, options, customOptions), themeHelper);
30
+ // attach statics if specified
31
+ if (options.statics) {
32
+ Object.assign(component, options.statics);
33
+ }
34
+ return component;
37
35
  }
38
- //# sourceMappingURL=composeFactory.js.map
36
+ //# sourceMappingURL=composeFactory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"composeFactory.js","sourceRoot":"","sources":["../src/composeFactory.ts"],"names":[],"mappings":";;;AACA,0EAA2E;AAE3E,0EAAwE;AAExE,gEAAiE;AACjE,oEAAqE;AAqCrE;;GAEG;AACH,MAAM,YAAY,GAAiB;IACjC,MAAM,EAAE,aAAa;IACrB,MAAM,EAAE,IAAI;CACb,CAAC;AAEF,wBACE,OAA6E,EAC7E,WAAgC,EAChC,IAA6E,EACL;IAIxE,gDAAgD;IAChD,MAAM,WAAW,GAAiB,IAAI,EAAE,SAAyB,CAAC;IAClE,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,IAAA,mCAAkB,EAAe,YAAY,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC;IAE9G,iDAAiD;IACjD,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAA,6BAAe,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,EAAiB,CAAA,CAAC;IAE5H,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,IAAA,yBAAa,EAAC,OAAO,CAAuC,CAAC;IAE9E,6BAA6B;IAC7B,MAAM,SAAS,GAAG,IAAA,gCAAe,EAAS,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAmB,CAAC;IAE3G,oDAAoD;IACpD,SAAS,CAAC,W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AE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAe,CAAC;IAE5H,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,IAAA,yBAAa,EAAC,OAAO,CAAuC,CAAC;IAE9E,6BAA6B;IAC7B,MAAM,SAAS,GAAG,IAAA,gCAAe,EAAS,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAmB,CAAC;IAE3G,oDAAoD;IACpD,SAAS,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;IAC5C,SAAS,CAAC,SAAS,GAAG,OAAO,CAAC;IAC9B,SAAS,CAAC,SAAS,GAAG,CAAC,GAAG,MAA8B,EAAE,EAAE,CAC1D,cAAc,CACZ,IAAA,mCAAkB,EAAC,YAAY,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,EAAkB,CAAC,EAC7E,WAAW,CACZ,CAAC;IAEJ,SAAS,CAAC,OAAO,GAAG,CAClB,aAAoG,EACpG,EAAE,CACF,cAAc,CACZ,IAAA,mCAAkB,EAAC,YAAY,EAAE,OAAO,EAAE,aAAuB,CAMhE,EACD,WAAW,CACZ,CAAC;IAEJ,8BAA8B;IAC9B,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,SAAS,CAAC;AAAA,CAClB"}
@@ -1,2 +1,2 @@
1
1
  export {};
2
- //# sourceMappingURL=composeFactory.test.d.ts.map
2
+ //# sourceMappingURL=composeFactory.test.d.ts.map
@@ -1,122 +1,101 @@
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;
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
- return ownKeys(o);
25
+ return ownKeys(o);
43
26
  };
44
27
  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;
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, '__esModule', { value: true });
53
- const jsx_runtime_1 = require('@fluentui-react-native/framework-base/jsx-runtime');
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const jsx_runtime_1 = require("@fluentui-react-native/framework-base/jsx-runtime");
54
37
  /** @jsxImportSource @fluentui-react-native/framework-base */
55
- const react_1 = require('react');
56
- const react_native_1 = require('react-native');
57
- const renderer = __importStar(require('react-test-renderer'));
58
- const composeFactory_1 = require('./composeFactory');
38
+ const react_1 = require("react");
39
+ const react_native_1 = require("react-native");
40
+ const renderer = __importStar(require("react-test-renderer"));
41
+ const composeFactory_1 = require("./composeFactory");
59
42
  const theme = {
60
- values: {
61
- backgroundColor: 'black',
62
- color: 'white',
63
- },
64
- components: {},
43
+ values: {
44
+ backgroundColor: 'black',
45
+ color: 'white',
46
+ },
47
+ components: {},
65
48
  };
66
49
  const themeHelper = {
67
- useTheme: () => theme,
68
- getComponentInfo: (theme, name) => {
69
- return theme?.components ?? theme.components[name];
70
- },
50
+ useTheme: () => theme,
51
+ getComponentInfo: (theme, name) => {
52
+ return theme?.components ?? theme.components[name];
53
+ },
71
54
  };
72
55
  function mergeProps(p1, p2) {
73
- return { ...p1, ...p2 };
56
+ return { ...p1, ...p2 };
74
57
  }
75
- const Base = (0, composeFactory_1.composeFactory)(
76
- {
58
+ const Base = (0, composeFactory_1.composeFactory)({
77
59
  tokens: [
78
- (t) => ({
79
- backgroundColor: t.values.backgroundColor,
80
- color: t.values.color,
81
- }),
60
+ (t) => ({
61
+ backgroundColor: t.values.backgroundColor,
62
+ color: t.values.color,
63
+ }),
82
64
  ],
83
65
  slotProps: {
84
- outer: (tokens) => ({ style: { backgroundColor: tokens.backgroundColor } }),
85
- content: (tokens) => ({ style: { color: tokens.color } }),
66
+ outer: (tokens) => ({ style: { backgroundColor: tokens.backgroundColor } }),
67
+ content: (tokens) => ({ style: { color: tokens.color } }),
86
68
  },
87
69
  slots: {
88
- outer: react_native_1.View,
89
- content: react_native_1.Text,
70
+ outer: react_native_1.View,
71
+ content: react_native_1.Text,
90
72
  },
91
73
  useRender: (props, useSlots) => {
92
- const Slots = useSlots(props);
93
- return (extra) =>
94
- jsx_runtime_1.jsx(Slots.outer, { ...mergeProps(props, extra), children: jsx_runtime_1.jsx(Slots.content, { children: 'Hello' }) });
74
+ const Slots = useSlots(props);
75
+ return (extra) => (jsx_runtime_1.jsx(Slots.outer, { ...mergeProps(props, extra), children: jsx_runtime_1.jsx(Slots.content, { children: "Hello" }) }));
95
76
  },
96
- },
97
- themeHelper,
98
- );
77
+ }, themeHelper);
99
78
  const Customized = Base.customize({ backgroundColor: 'pink' });
100
79
  const mixinStyle = {
101
- width: 30,
102
- height: 20,
103
- borderColor: 'green',
104
- borderWidth: 1,
80
+ width: 30,
81
+ height: 20,
82
+ borderColor: 'green',
83
+ borderWidth: 1,
105
84
  };
106
85
  describe('composeFactory test suite', () => {
107
- it('Base component render', () => {
108
- let component;
109
- (0, react_1.act)(() => {
110
- component = renderer.create(jsx_runtime_1.jsx(Base, { style: mixinStyle }));
86
+ it('Base component render', () => {
87
+ let component;
88
+ (0, react_1.act)(() => {
89
+ component = renderer.create(jsx_runtime_1.jsx(Base, { style: mixinStyle }));
90
+ });
91
+ expect(component.toJSON()).toMatchSnapshot();
111
92
  });
112
- expect(component.toJSON()).toMatchSnapshot();
113
- });
114
- it('Customized component render', () => {
115
- let component;
116
- (0, react_1.act)(() => {
117
- component = renderer.create(jsx_runtime_1.jsx(Customized, { style: mixinStyle }));
93
+ it('Customized component render', () => {
94
+ let component;
95
+ (0, react_1.act)(() => {
96
+ component = renderer.create(jsx_runtime_1.jsx(Customized, { style: mixinStyle }));
97
+ });
98
+ expect(component.toJSON()).toMatchSnapshot();
118
99
  });
119
- expect(component.toJSON()).toMatchSnapshot();
120
- });
121
100
  });
122
- //# sourceMappingURL=composeFactory.test.js.map
101
+ //# sourceMappingURL=composeFactory.test.js.map
@@ -1,3 +1,3 @@
1
1
  export { composeFactory } from './composeFactory';
2
2
  export type { ComposeFactoryComponent, ComposeFactoryOptions, UseStyledSlots } from './composeFactory';
3
- //# sourceMappingURL=index.d.ts.map
3
+ //# sourceMappingURL=index.d.ts.map
@@ -1,11 +1,6 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.composeFactory = void 0;
4
- const composeFactory_1 = require('./composeFactory');
5
- Object.defineProperty(exports, 'composeFactory', {
6
- enumerable: true,
7
- get: function () {
8
- return composeFactory_1.composeFactory;
9
- },
10
- });
11
- //# sourceMappingURL=index.js.map
4
+ const composeFactory_1 = require("./composeFactory");
5
+ Object.defineProperty(exports, "composeFactory", { enumerable: true, get: function () { return composeFactory_1.composeFactory; } });
6
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,61 +1,62 @@
1
1
  {
2
2
  "name": "@fluentui-react-native/composition",
3
- "version": "0.12.0",
3
+ "version": "0.12.3",
4
4
  "description": "Composition factories for building HOCs",
5
5
  "keywords": [],
6
+ "license": "MIT",
7
+ "author": "",
6
8
  "repository": {
7
9
  "type": "git",
8
10
  "url": "https://github.com/microsoft/fluentui-react-native",
9
11
  "directory": "packages/framework/composition"
10
12
  },
11
- "license": "MIT",
12
- "author": "",
13
+ "main": "lib-commonjs/index.js",
14
+ "module": "lib/index.js",
15
+ "types": "lib/index.d.ts",
13
16
  "exports": {
14
17
  ".": {
15
18
  "types": "./lib/index.d.ts",
16
19
  "import": "./lib/index.js",
17
- "require": "./lib-commonjs/index.js"
20
+ "require": "./lib-commonjs/index.js",
21
+ "default": "./src/index.ts"
18
22
  }
19
23
  },
20
- "main": "lib-commonjs/index.js",
21
- "module": "lib/index.js",
22
- "types": "lib/index.d.ts",
23
24
  "scripts": {
24
25
  "build": "fluentui-scripts build",
25
26
  "build-cjs": "tsgo --outDir lib-commonjs",
26
- "build-esm": "tsgo --outDir lib --module esnext --moduleResolution bundler",
27
+ "build-core": "tsgo --outDir lib --module esnext --moduleResolution bundler",
27
28
  "clean": "fluentui-scripts clean",
28
29
  "depcheck": "fluentui-scripts depcheck",
29
- "lint": "fluentui-scripts eslint",
30
+ "format": "fluentui-scripts format",
31
+ "lint": "fluentui-scripts lint",
30
32
  "lint-package": "fluentui-scripts lint-package",
31
- "prettier": "fluentui-scripts prettier",
32
33
  "start": "fluentui-scripts dev",
33
34
  "start-test": "fluentui-scripts jest-watch",
34
35
  "test": "fluentui-scripts jest",
35
36
  "update-snapshots": "fluentui-scripts jest -u"
36
37
  },
37
38
  "dependencies": {
38
- "@fluentui-react-native/framework-base": "0.3.0",
39
- "@fluentui-react-native/use-slots": "0.11.0",
40
- "@fluentui-react-native/use-styling": "0.14.0"
39
+ "@fluentui-react-native/framework-base": "0.3.3",
40
+ "@fluentui-react-native/use-slots": "0.11.3",
41
+ "@fluentui-react-native/use-styling": "0.14.3"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@babel/core": "^7.20.0",
44
45
  "@fluentui-react-native/babel-config": "0.1.1",
45
- "@fluentui-react-native/eslint-config-rules": "0.1.1",
46
- "@fluentui-react-native/jest-config": "0.1.1",
46
+ "@fluentui-react-native/jest-config": "0.1.0",
47
47
  "@fluentui-react-native/kit-config": "0.1.2",
48
- "@fluentui-react-native/scripts": "0.1.2",
48
+ "@fluentui-react-native/lint-config-rules": "0.1.3",
49
+ "@fluentui-react-native/scripts": "0.1.0",
49
50
  "@react-native/babel-preset": "^0.81.0",
50
- "@types/react": "~19.1.0",
51
+ "@types/react": "~19.1.4",
51
52
  "@types/react-test-renderer": "^19.1.0",
52
- "react": "19.1.0",
53
- "react-native": "^0.81.0",
54
- "react-test-renderer": "19.1.0"
53
+ "react": "19.1.4",
54
+ "react-native": "^0.81.6",
55
+ "react-test-renderer": "19.1.4"
55
56
  },
56
57
  "peerDependencies": {
57
- "@types/react": "~18.2.0 || ~19.0.0 || ~19.1.0",
58
- "react": "18.2.0 || 19.0.0 || 19.1.0"
58
+ "@types/react": "~18.2.0 || ~19.0.0 || ~19.1.4",
59
+ "react": "18.2.0 || 19.0.0 || 19.1.4"
59
60
  },
60
61
  "peerDependenciesMeta": {
61
62
  "@types/react": {
@@ -62,7 +62,7 @@ export function composeFactory<TProps, TSlotProps, TTokens, TTheme, TStatics ext
62
62
  options = baseOptions ? immutableMergeCore<LocalOptions>(mergeOptions, baseOptions, options) : { ...options };
63
63
 
64
64
  // build styling if styling options are specified
65
- options.useStyling = options.slotProps || options.tokens ? buildUseStyling(options, themeHelper) : () => ({} as TSlotProps);
65
+ options.useStyling = options.slotProps || options.tokens ? buildUseStyling(options, themeHelper) : () => ({}) as TSlotProps;
66
66
 
67
67
  // build the slots hook, which will use the styling hook if it has been built
68
68
  const useSlots = buildUseSlots(options) as UseStyledSlots<TProps, TSlotProps>;
package/eslint.config.js DELETED
@@ -1,3 +0,0 @@
1
- const baseConfig = require('@fluentui-react-native/eslint-config-rules');
2
-
3
- module.exports = baseConfig;