react-chain-of-responsibility 0.3.1-main.abcc3b5 → 0.4.0-main.6548dd9

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/README.md CHANGED
@@ -356,12 +356,14 @@ function createChainOfResponsibility<Request = undefined, Props = { children?: n
356
356
 
357
357
  ### Options
358
358
 
359
+ #### `passModifiedRequest`
360
+
359
361
  > `passModifiedRequest` is not supported by `asMiddleware`.
360
362
 
361
363
  ```ts
362
364
  type Options = {
363
365
  /** Allows a middleware to pass another request object to its next middleware. Default is false. */
364
- passModifiedRequest?: boolean;
366
+ passModifiedRequest?: boolean | undefined;
365
367
  };
366
368
  ```
367
369
 
@@ -431,6 +433,14 @@ type UseBuildRenderFunction<Props> = (options?: UseBuildRenderFunctionOptions<Pr
431
433
 
432
434
  When rendering the element, `getKey` is called to compute the `key` attribute. This is required for some `onRenderXXX` props. These props are usually used to render more than one elements, such as [`DetailsList.onRenderField`](https://developer.microsoft.com/en-us/fluentui#/controls/web/detailslist#implementation), which renders every field (a.k.a. cell) in the [`<DetailsList>`](https://developer.microsoft.com/en-us/fluentui#/controls/web/detailslist).
433
435
 
436
+ ### `withBuildProps` higher-order helper function
437
+
438
+ `withBuildProps` is a higher-order function that extends the chain-of-responsibility with props transformation capability. It modified the `<Proxy>` and `useBuildComponentCallback` hook so that request can be hoisted and accessible in props.
439
+
440
+ However, this should be used with care. Given an identical request, the returning component from the `useBuildComponentCallback()` hook will never be stable. Explicit memoization is required for stabilizing the result.
441
+
442
+ For `<Proxy>`, memoization is provided automatically through React `memo()` function. No explicity memoization is required.
443
+
434
444
  ## Designs
435
445
 
436
446
  ### How can I choose between request and props?
@@ -450,6 +460,8 @@ For example:
450
460
  - Request: text input, number input, password input
451
461
  - Props: label, value, instruction
452
462
 
463
+ In some cases, you may want to have request accessible via props. The `withBuildProps` higher-order helper function can be used to hoist the request object in props. However, currently, `withBuildProps` does not honor the `passModifiedRequest` option.
464
+
453
465
  ### Why the type of request and props can be different?
454
466
 
455
467
  This is to support advanced scenarios where props are not ready until all rendering components are built.
@@ -1,3 +1,7 @@
1
+ import {
2
+ applyMiddleware
3
+ } from "./chunk-TNTIZJJ5.mjs";
4
+
1
5
  // src/createChainOfResponsibility.tsx
2
6
  import React, {
3
7
  createContext,
@@ -9,6 +13,7 @@ import React, {
9
13
  } from "react";
10
14
 
11
15
  // src/isReactComponent.ts
16
+ import { custom } from "valibot";
12
17
  function isConsumer(component) {
13
18
  return component?.$$typeof?.toString() === "Symbol(react.context)";
14
19
  }
@@ -33,19 +38,7 @@ function isComponentClass(component) {
33
38
  function isReactComponent(component) {
34
39
  return isFunctionComponent(component) || isComponentClass(component) || isFragment(component) || isConsumer(component) || isProvider(component);
35
40
  }
36
-
37
- // src/private/compose.ts
38
- function compose(...fns) {
39
- return (fn) => fns.reduce((chain, fn2) => fn2(chain), fn);
40
- }
41
-
42
- // src/private/applyMiddleware.ts
43
- function applyMiddleware(...arrayOfMiddleware) {
44
- return (...init) => {
45
- const chain = arrayOfMiddleware.map((middleware) => middleware(...init));
46
- return compose(...chain);
47
- };
48
- }
41
+ var isReactComponent_default = isReactComponent;
49
42
 
50
43
  // src/createChainOfResponsibility.tsx
51
44
  function createChainOfResponsibility(options = {}) {
@@ -53,11 +46,11 @@ function createChainOfResponsibility(options = {}) {
53
46
  get enhancer() {
54
47
  return void 0;
55
48
  },
56
- useBuildComponentCallback(_, options2) {
57
- if (options2?.fallbackComponent) {
58
- return options2.fallbackComponent;
49
+ useBuildComponentCallback(_request, options2) {
50
+ if (!options2?.fallbackComponent) {
51
+ throw new Error("This component/hook cannot be used outside of its corresponding <Provider>");
59
52
  }
60
- throw new Error("This component/hook cannot be used outside of its corresponding <Provider>");
53
+ return options2.fallbackComponent;
61
54
  }
62
55
  };
63
56
  const context = createContext(defaultUseBuildComponentCallback);
@@ -82,7 +75,7 @@ function createChainOfResponsibility(options = {}) {
82
75
  hasReturned = true;
83
76
  if (isValidElement(returnValue)) {
84
77
  throw new Error("middleware must not return React element directly");
85
- } else if (returnValue !== false && returnValue !== null && typeof returnValue !== "undefined" && !isReactComponent(returnValue)) {
78
+ } else if (returnValue !== false && returnValue !== null && typeof returnValue !== "undefined" && !isReactComponent_default(returnValue)) {
86
79
  throw new Error(
87
80
  "middleware must return false, null, undefined, function component, or class component"
88
81
  );
@@ -114,10 +107,10 @@ function createChainOfResponsibility(options = {}) {
114
107
  return /* @__PURE__ */ React.createElement(context.Provider, { value: contextValue }, children);
115
108
  }
116
109
  const useBuildComponentCallback = () => useContext(context).useBuildComponentCallback;
117
- function Proxy({ children, fallbackComponent, request, ...props }) {
110
+ function Proxy({ fallbackComponent, request, ...props }) {
118
111
  const enhancer = useBuildComponentCallback();
119
112
  const Component = enhancer(request, { fallbackComponent });
120
- return Component ? /* @__PURE__ */ React.createElement(Component, { ...props }, children) : null;
113
+ return Component ? /* @__PURE__ */ React.createElement(Component, { ...props }) : null;
121
114
  }
122
115
  const asMiddleware = (MiddlewareComponent) => (init) => (next) => (request) => {
123
116
  const RawNextComponent = next(request);
@@ -137,22 +130,24 @@ function createChainOfResponsibility(options = {}) {
137
130
  MiddlewareOf.displayName = `MiddlewareOf<${MiddlewareComponent.displayName || ""}>`;
138
131
  return memo(MiddlewareOf);
139
132
  };
140
- return {
133
+ return Object.freeze({
141
134
  asMiddleware,
142
135
  Provider: memo(ChainOfResponsibilityProvider),
143
136
  Proxy: memo(Proxy),
144
- types: {
137
+ types: Object.freeze({
145
138
  middlewareComponentProps: void 0,
146
139
  init: void 0,
147
140
  middleware: void 0,
148
141
  props: void 0,
142
+ proxyProps: void 0,
149
143
  request: void 0
150
- },
144
+ }),
151
145
  useBuildComponentCallback
152
- };
146
+ });
153
147
  }
148
+ var createChainOfResponsibility_default = createChainOfResponsibility;
154
149
 
155
150
  export {
156
- createChainOfResponsibility
151
+ createChainOfResponsibility_default
157
152
  };
158
- //# sourceMappingURL=chunk-LPY4PJSC.mjs.map
153
+ //# sourceMappingURL=chunk-3IVASMVM.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/createChainOfResponsibility.tsx","../src/isReactComponent.ts"],"sourcesContent":["import React, {\n createContext,\n isValidElement,\n memo,\n useCallback,\n useContext,\n useMemo,\n type ComponentType,\n type PropsWithChildren\n} from 'react';\n\nimport isReactComponent from './isReactComponent.ts';\nimport applyMiddleware, { type Enhancer } from './private/applyMiddleware.ts';\nimport { type ComponentMiddleware } from './types.ts';\n\n// TODO: Simplify to ComponentType<Props> | undefined.\ntype ResultComponent<Props> = ComponentType<Props> | false | null | undefined;\n\ntype UseBuildComponentCallbackOptions<Props> = {\n fallbackComponent?: ResultComponent<Props> | undefined;\n};\n\ninterface UseBuildComponentCallback<Request, Props> {\n (request: Request, options?: undefined | UseBuildComponentCallbackOptions<Props>): ComponentType<Props> | undefined;\n}\n\ntype ProviderContext<Request, Props> = {\n get enhancer(): Enhancer<[Request], ResultComponent<Props>> | undefined;\n useBuildComponentCallback: UseBuildComponentCallback<Request, Props>;\n};\n\ntype ProviderProps<Request, Props, Init> = PropsWithChildren<{\n middleware: readonly ComponentMiddleware<Request, Props, Init>[];\n}> &\n (Init extends never | void\n ? { readonly init?: undefined }\n : Init extends undefined | void\n ? { readonly init?: Init }\n : { readonly init: Init });\n\ntype ProxyProps<Request, Props extends object> = Props & {\n readonly fallbackComponent?: ComponentType<Props> | undefined;\n readonly request: Request;\n};\n\ntype CreateChainOfResponsibilityOptions = {\n /**\n * Allows a middleware to pass another request object when calling its next middleware. Default is false.\n *\n * However, middleware could modify the request object before calling its next middleware. It is recommended\n * to use Object.freeze() to prevent middleware from modifying the request object.\n */\n readonly passModifiedRequest?: boolean | undefined;\n};\n\ntype AsMiddlewareProps<Request, Props, Init> = {\n readonly init: Init;\n readonly Next: ComponentType<Partial<Props>>;\n readonly request: Request;\n};\n\ntype AsMiddlewareComponentProps<Request, Props, Init> = Props & {\n readonly middleware: AsMiddlewareProps<Request, Props, Init>;\n};\n\ntype ChainOfResponsibility<Request, Props extends object, Init> = {\n readonly asMiddleware: (\n middlewareComponent: ComponentType<AsMiddlewareComponentProps<Request, Props, Init>>\n ) => ComponentMiddleware<Request, Props, Init>;\n readonly Provider: ComponentType<ProviderProps<Request, Props, Init>>;\n readonly Proxy: ComponentType<ProxyProps<Request, Props>>;\n readonly types: {\n readonly init: Init;\n readonly middleware: ComponentMiddleware<Request, Props, Init>;\n readonly middlewareComponentProps: AsMiddlewareComponentProps<Request, Props, Init>;\n readonly props: Props;\n readonly proxyProps: ProxyProps<Request, Props>;\n readonly request: Request;\n };\n readonly useBuildComponentCallback: () => UseBuildComponentCallback<Request, Props>;\n};\n\nfunction createChainOfResponsibility<Request = void, Props extends object = { readonly children?: never }, Init = void>(\n options: CreateChainOfResponsibilityOptions = {}\n): ChainOfResponsibility<Request, Props, Init> {\n const defaultUseBuildComponentCallback: ProviderContext<Request, Props> = {\n get enhancer() {\n return undefined;\n },\n useBuildComponentCallback(_request, options): ComponentType<Props> {\n if (!options?.fallbackComponent) {\n throw new Error('This component/hook cannot be used outside of its corresponding <Provider>');\n }\n\n return options.fallbackComponent;\n }\n };\n\n const context = createContext<ProviderContext<Request, Props>>(defaultUseBuildComponentCallback);\n\n function ChainOfResponsibilityProvider({ children, init, middleware }: ProviderProps<Request, Props, Init>) {\n // TODO: Related to https://github.com/microsoft/TypeScript/issues/17002.\n // typescript@5.2.2 has a bug, Array.isArray() is a type predicate but only works with mutable array, not readonly array.\n // After removing \"as unknown\", `middleware` on the next line become `any[]`.\n if (!Array.isArray(middleware as unknown) || middleware.some(middleware => typeof middleware !== 'function')) {\n throw new Error('middleware prop must be an array of functions');\n }\n\n const patchedMiddleware: readonly ComponentMiddleware<Request, Props, Init>[] = Object.freeze(\n middleware\n ? middleware.map(fn => (init: Init) => {\n const enhancer = fn(init);\n\n return (next: (request: Request) => ComponentType<Props> | false | null | undefined) =>\n (originalRequest: Request) => {\n // False positive: although we did not re-assign the variable from true, it was initialized as undefined.\n // eslint-disable-next-line prefer-const\n let hasReturned: boolean;\n\n const returnValue = enhancer(nextRequest => {\n if (hasReturned) {\n throw new Error('next() cannot be called after the function had returned synchronously');\n }\n\n !options.passModifiedRequest &&\n nextRequest !== originalRequest &&\n console.warn(\n 'react-chain-of-responsibility: \"options.passModifiedRequest\" must be set to true to pass a different request object to next().'\n );\n\n return next(options.passModifiedRequest ? nextRequest : originalRequest);\n })(originalRequest);\n\n hasReturned = true;\n\n if (isValidElement(returnValue)) {\n throw new Error('middleware must not return React element directly');\n } else if (\n returnValue !== false &&\n returnValue !== null &&\n typeof returnValue !== 'undefined' &&\n !isReactComponent(returnValue)\n ) {\n throw new Error(\n 'middleware must return false, null, undefined, function component, or class component'\n );\n }\n\n return returnValue;\n };\n })\n : []\n );\n\n const { enhancer: parentEnhancer } = useContext(context);\n\n const enhancer = useMemo(\n () =>\n // We are reversing because it is easier to read:\n // - With reverse, [a, b, c] will become a(b(c(fn)))\n // - Without reverse, [a, b, c] will become c(b(a(fn)))\n applyMiddleware<[Request], ResultComponent<Props>, [Init]>(\n ...[...patchedMiddleware, ...(parentEnhancer ? [() => parentEnhancer] : [])].reverse()\n )(init as Init),\n [init, middleware, parentEnhancer]\n );\n\n const useBuildComponentCallback = useCallback<UseBuildComponentCallback<Request, Props>>(\n (request, options = {}) => enhancer(() => options.fallbackComponent)(request) || undefined,\n [enhancer]\n );\n\n const contextValue = useMemo<ProviderContext<Request, Props>>(\n () => ({ enhancer, useBuildComponentCallback }),\n [enhancer, useBuildComponentCallback]\n );\n\n return <context.Provider value={contextValue}>{children}</context.Provider>;\n }\n\n const useBuildComponentCallback = () => useContext(context).useBuildComponentCallback;\n\n function Proxy({ fallbackComponent, request, ...props }: ProxyProps<Request, Props>) {\n const enhancer = useBuildComponentCallback();\n\n const Component = enhancer(request as Request, { fallbackComponent });\n\n return Component ? <Component {...(props as Props)} /> : null;\n }\n\n const asMiddleware: (\n middlewareComponent: ComponentType<AsMiddlewareComponentProps<Request, Props, Init>>\n ) => ComponentMiddleware<Request, Props, Init> =\n (\n MiddlewareComponent: ComponentType<AsMiddlewareComponentProps<Request, Props, Init>>\n ): ComponentMiddleware<Request, Props, Init> =>\n init =>\n next =>\n request => {\n const RawNextComponent = next(request);\n\n // TODO: Can we pre-build this component during init?\n const MiddlewareOf = (props: Props) => {\n const middleware = useMemo(\n () =>\n Object.freeze({\n init,\n Next: memo<Partial<Props>>(\n RawNextComponent\n ? (overridingProps: Partial<Props>) => <RawNextComponent {...props} {...overridingProps} />\n : () => null\n ),\n request\n }),\n []\n );\n\n return <MiddlewareComponent {...props} middleware={middleware} />;\n };\n\n MiddlewareOf.displayName = `MiddlewareOf<${MiddlewareComponent.displayName || ''}>`;\n\n return memo<Props>(MiddlewareOf);\n };\n\n return Object.freeze({\n asMiddleware,\n Provider: memo<ProviderProps<Request, Props, Init>>(ChainOfResponsibilityProvider),\n Proxy: memo<ProxyProps<Request, Props>>(Proxy),\n types: Object.freeze({\n middlewareComponentProps: undefined as unknown as AsMiddlewareComponentProps<Request, Props, Init>,\n init: undefined as unknown as Init,\n middleware: undefined as unknown as ComponentMiddleware<Request, Props, Init>,\n props: undefined as unknown as Props,\n proxyProps: undefined as unknown as ProxyProps<Request, Props>,\n request: undefined as unknown as Request\n }),\n useBuildComponentCallback\n });\n}\n\nexport default createChainOfResponsibility;\nexport {\n type ChainOfResponsibility,\n type CreateChainOfResponsibilityOptions,\n type ProxyProps,\n type UseBuildComponentCallback\n};\n","import {\n type ComponentClass,\n type ComponentType,\n type Consumer,\n type Fragment,\n type FunctionComponent,\n type Provider\n} from 'react';\nimport { custom } from 'valibot';\n\nfunction isConsumer(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n component: any\n): component is Consumer<unknown> {\n return component?.$$typeof?.toString() === 'Symbol(react.context)';\n}\n\nfunction isProvider(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n component: any\n): component is Provider<unknown> {\n return component?.$$typeof?.toString() === 'Symbol(react.provider)';\n}\n\nfunction isFragment(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n component: any\n): component is typeof Fragment {\n return component?.toString() === 'Symbol(react.fragment)';\n}\n\nfunction isFunctionComponent(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n component: any\n): component is FunctionComponent {\n if (typeof component === 'function') {\n return true;\n }\n\n return isPureFunctionComponent(component);\n}\n\nfunction isPureFunctionComponent(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n component: any\n): component is FunctionComponent {\n return component?.$$typeof?.toString() === 'Symbol(react.memo)' && isFunctionComponent(component.type);\n}\n\nfunction isComponentClass(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n component: any\n): component is ComponentClass {\n return typeof component === 'object' && typeof component?.['render'] === 'function';\n}\n\n// There are no definitive ways to check if an object is a React component or not.\n// We are checking if the object has a render function (classic component).\n// Note: \"forwardRef()\" returns plain object, not class instance.\nfunction isReactComponent(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n component: any\n): component is ComponentType {\n return (\n isFunctionComponent(component) ||\n isComponentClass(component) ||\n isFragment(component) ||\n isConsumer(component) ||\n isProvider(component)\n );\n}\n\nconst reactComponent = () =>\n custom<ComponentType<unknown>>(value => isReactComponent(value), 'not a valid React component');\n\nexport default isReactComponent;\nexport { reactComponent };\n"],"mappings":"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","names":["options","middleware","init","enhancer","useBuildComponentCallback"]}
@@ -0,0 +1,17 @@
1
+ // src/private/compose.ts
2
+ function compose(...fns) {
3
+ return (fn) => fns.reduce((chain, fn2) => fn2(chain), fn);
4
+ }
5
+
6
+ // src/private/applyMiddleware.ts
7
+ function applyMiddleware(...arrayOfMiddleware) {
8
+ return (...init) => {
9
+ const chain = arrayOfMiddleware.map((middleware) => middleware(...init));
10
+ return compose(...chain);
11
+ };
12
+ }
13
+
14
+ export {
15
+ applyMiddleware
16
+ };
17
+ //# sourceMappingURL=chunk-TNTIZJJ5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/private/compose.ts","../src/private/applyMiddleware.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Fn<P extends any[], R> = (...args: P) => R;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Enhancer<P extends any[], R> = (next: Fn<P, R>) => Fn<P, R>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport default function compose<P extends any[], R>(...fns: Enhancer<P, R>[]): Enhancer<P, R> {\n return (fn: Fn<P, R>): Fn<P, R> => fns.reduce((chain, fn) => fn(chain), fn);\n}\n","import compose from './compose.ts';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype Fn<P extends any[], R> = (...args: P) => R;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Enhancer<P extends any[], R> = (next: Fn<P, R>) => Fn<P, R>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Middleware<P extends any[], R, S extends any[]> = (...init: S) => Enhancer<P, R>;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport default function applyMiddleware<P extends any[], R, S extends any[]>(\n ...arrayOfMiddleware: Middleware<P, R, S>[]\n) {\n return (...init: S) => {\n const chain = arrayOfMiddleware.map(middleware => middleware(...init));\n\n return compose(...chain);\n };\n}\n"],"mappings":";AAOe,SAAR,WAAgD,KAAuC;AAC5F,SAAO,CAAC,OAA2B,IAAI,OAAO,CAAC,OAAOA,QAAOA,IAAG,KAAK,GAAG,EAAE;AAC5E;;;ACGe,SAAR,mBACF,mBACH;AACA,SAAO,IAAI,SAAY;AACrB,UAAM,QAAQ,kBAAkB,IAAI,gBAAc,WAAW,GAAG,IAAI,CAAC;AAErE,WAAO,QAAQ,GAAG,KAAK;AAAA,EACzB;AACF;","names":["fn"]}
@@ -0,0 +1,70 @@
1
+ import { ComponentType, PropsWithChildren } from 'react';
2
+
3
+ type Fn<P extends any[], R> = (...args: P) => R;
4
+ type Enhancer<P extends any[], R> = (next: Fn<P, R>) => Fn<P, R>;
5
+ type Middleware<P extends any[], R, S extends any[]> = (...init: S) => Enhancer<P, R>;
6
+
7
+ type ComponentMiddleware<Request, Props = {
8
+ children?: never;
9
+ }, Init = undefined> = Middleware<[
10
+ Request
11
+ ], ComponentType<Props> | false | null | undefined, [
12
+ Init
13
+ ]>;
14
+
15
+ type ResultComponent<Props> = ComponentType<Props> | false | null | undefined;
16
+ type UseBuildComponentCallbackOptions<Props> = {
17
+ fallbackComponent?: ResultComponent<Props> | undefined;
18
+ };
19
+ interface UseBuildComponentCallback<Request, Props> {
20
+ (request: Request, options?: undefined | UseBuildComponentCallbackOptions<Props>): ComponentType<Props> | undefined;
21
+ }
22
+ type ProviderProps<Request, Props, Init> = PropsWithChildren<{
23
+ middleware: readonly ComponentMiddleware<Request, Props, Init>[];
24
+ }> & (Init extends never | void ? {
25
+ readonly init?: undefined;
26
+ } : Init extends undefined | void ? {
27
+ readonly init?: Init;
28
+ } : {
29
+ readonly init: Init;
30
+ });
31
+ type ProxyProps<Request, Props extends object> = Props & {
32
+ readonly fallbackComponent?: ComponentType<Props> | undefined;
33
+ readonly request: Request;
34
+ };
35
+ type CreateChainOfResponsibilityOptions = {
36
+ /**
37
+ * Allows a middleware to pass another request object when calling its next middleware. Default is false.
38
+ *
39
+ * However, middleware could modify the request object before calling its next middleware. It is recommended
40
+ * to use Object.freeze() to prevent middleware from modifying the request object.
41
+ */
42
+ readonly passModifiedRequest?: boolean | undefined;
43
+ };
44
+ type AsMiddlewareProps<Request, Props, Init> = {
45
+ readonly init: Init;
46
+ readonly Next: ComponentType<Partial<Props>>;
47
+ readonly request: Request;
48
+ };
49
+ type AsMiddlewareComponentProps<Request, Props, Init> = Props & {
50
+ readonly middleware: AsMiddlewareProps<Request, Props, Init>;
51
+ };
52
+ type ChainOfResponsibility<Request, Props extends object, Init> = {
53
+ readonly asMiddleware: (middlewareComponent: ComponentType<AsMiddlewareComponentProps<Request, Props, Init>>) => ComponentMiddleware<Request, Props, Init>;
54
+ readonly Provider: ComponentType<ProviderProps<Request, Props, Init>>;
55
+ readonly Proxy: ComponentType<ProxyProps<Request, Props>>;
56
+ readonly types: {
57
+ readonly init: Init;
58
+ readonly middleware: ComponentMiddleware<Request, Props, Init>;
59
+ readonly middlewareComponentProps: AsMiddlewareComponentProps<Request, Props, Init>;
60
+ readonly props: Props;
61
+ readonly proxyProps: ProxyProps<Request, Props>;
62
+ readonly request: Request;
63
+ };
64
+ readonly useBuildComponentCallback: () => UseBuildComponentCallback<Request, Props>;
65
+ };
66
+ declare function createChainOfResponsibility<Request = void, Props extends object = {
67
+ readonly children?: never;
68
+ }, Init = void>(options?: CreateChainOfResponsibilityOptions): ChainOfResponsibility<Request, Props, Init>;
69
+
70
+ export { type CreateChainOfResponsibilityOptions as C, type ComponentMiddleware as a, createChainOfResponsibility as c };
@@ -0,0 +1,70 @@
1
+ import { ComponentType, PropsWithChildren } from 'react';
2
+
3
+ type Fn<P extends any[], R> = (...args: P) => R;
4
+ type Enhancer<P extends any[], R> = (next: Fn<P, R>) => Fn<P, R>;
5
+ type Middleware<P extends any[], R, S extends any[]> = (...init: S) => Enhancer<P, R>;
6
+
7
+ type ComponentMiddleware<Request, Props = {
8
+ children?: never;
9
+ }, Init = undefined> = Middleware<[
10
+ Request
11
+ ], ComponentType<Props> | false | null | undefined, [
12
+ Init
13
+ ]>;
14
+
15
+ type ResultComponent<Props> = ComponentType<Props> | false | null | undefined;
16
+ type UseBuildComponentCallbackOptions<Props> = {
17
+ fallbackComponent?: ResultComponent<Props> | undefined;
18
+ };
19
+ interface UseBuildComponentCallback<Request, Props> {
20
+ (request: Request, options?: undefined | UseBuildComponentCallbackOptions<Props>): ComponentType<Props> | undefined;
21
+ }
22
+ type ProviderProps<Request, Props, Init> = PropsWithChildren<{
23
+ middleware: readonly ComponentMiddleware<Request, Props, Init>[];
24
+ }> & (Init extends never | void ? {
25
+ readonly init?: undefined;
26
+ } : Init extends undefined | void ? {
27
+ readonly init?: Init;
28
+ } : {
29
+ readonly init: Init;
30
+ });
31
+ type ProxyProps<Request, Props extends object> = Props & {
32
+ readonly fallbackComponent?: ComponentType<Props> | undefined;
33
+ readonly request: Request;
34
+ };
35
+ type CreateChainOfResponsibilityOptions = {
36
+ /**
37
+ * Allows a middleware to pass another request object when calling its next middleware. Default is false.
38
+ *
39
+ * However, middleware could modify the request object before calling its next middleware. It is recommended
40
+ * to use Object.freeze() to prevent middleware from modifying the request object.
41
+ */
42
+ readonly passModifiedRequest?: boolean | undefined;
43
+ };
44
+ type AsMiddlewareProps<Request, Props, Init> = {
45
+ readonly init: Init;
46
+ readonly Next: ComponentType<Partial<Props>>;
47
+ readonly request: Request;
48
+ };
49
+ type AsMiddlewareComponentProps<Request, Props, Init> = Props & {
50
+ readonly middleware: AsMiddlewareProps<Request, Props, Init>;
51
+ };
52
+ type ChainOfResponsibility<Request, Props extends object, Init> = {
53
+ readonly asMiddleware: (middlewareComponent: ComponentType<AsMiddlewareComponentProps<Request, Props, Init>>) => ComponentMiddleware<Request, Props, Init>;
54
+ readonly Provider: ComponentType<ProviderProps<Request, Props, Init>>;
55
+ readonly Proxy: ComponentType<ProxyProps<Request, Props>>;
56
+ readonly types: {
57
+ readonly init: Init;
58
+ readonly middleware: ComponentMiddleware<Request, Props, Init>;
59
+ readonly middlewareComponentProps: AsMiddlewareComponentProps<Request, Props, Init>;
60
+ readonly props: Props;
61
+ readonly proxyProps: ProxyProps<Request, Props>;
62
+ readonly request: Request;
63
+ };
64
+ readonly useBuildComponentCallback: () => UseBuildComponentCallback<Request, Props>;
65
+ };
66
+ declare function createChainOfResponsibility<Request = void, Props extends object = {
67
+ readonly children?: never;
68
+ }, Init = void>(options?: CreateChainOfResponsibilityOptions): ChainOfResponsibility<Request, Props, Init>;
69
+
70
+ export { type CreateChainOfResponsibilityOptions as C, type ComponentMiddleware as a, createChainOfResponsibility as c };
@@ -1,72 +1,2 @@
1
- import { ComponentType, PropsWithChildren } from 'react';
2
-
3
- type Fn<P extends any[], R> = (...args: P) => R;
4
- type Enhancer<P extends any[], R> = (next: Fn<P, R>) => Fn<P, R>;
5
- type Middleware<P extends any[], R, S extends any[]> = (...init: S) => Enhancer<P, R>;
6
-
7
- type ComponentMiddleware<Request, Props = {
8
- children?: never;
9
- }, Init = undefined> = Middleware<[
10
- Request
11
- ], ComponentType<Props> | false | null | undefined, [
12
- Init
13
- ]>;
14
-
15
- type ResultComponent<Props> = ComponentType<Props> | false | null | undefined;
16
- type UseBuildComponentCallbackOptions<Props> = {
17
- fallbackComponent?: ResultComponent<Props>;
18
- };
19
- type UseBuildComponentCallback<Request, Props> = (request: Request, options?: UseBuildComponentCallbackOptions<Props>) => ComponentType<Props> | undefined;
20
- type ProviderProps<Request, Props, Init> = PropsWithChildren<{
21
- middleware: readonly ComponentMiddleware<Request, Props, Init>[];
22
- }> & (Init extends never | void ? {
23
- init?: undefined;
24
- } : Init extends undefined ? {
25
- init?: Init;
26
- } : {
27
- init: Init;
28
- });
29
- type ProxyProps<Request, Props extends object> = PropsWithChildren<Request extends never | void ? Props & {
30
- fallbackComponent?: ComponentType<Props>;
31
- request?: undefined;
32
- } : Request extends undefined ? Props & {
33
- fallbackComponent?: ComponentType<Props>;
34
- request?: Request;
35
- } : Props & {
36
- fallbackComponent?: ComponentType<Props>;
37
- request: Request;
38
- }>;
39
- type Options = {
40
- /**
41
- * Allows a middleware to pass another request object when calling its next middleware. Default is false.
42
- *
43
- * However, middleware could modify the request object before calling its next middleware. It is recommended
44
- * to use Object.freeze() to prevent middleware from modifying the request object.
45
- */
46
- passModifiedRequest?: boolean;
47
- };
48
- type MiddlewareProps<Request, Props, Init> = Readonly<{
49
- init: Init;
50
- Next: ComponentType<Partial<Props>>;
51
- request: Request;
52
- }>;
53
- type MiddlewareComponentProps<Request, Props, Init> = Props & Readonly<{
54
- middleware: MiddlewareProps<Request, Props, Init>;
55
- }>;
56
- declare function createChainOfResponsibility<Request = undefined, Props extends object = Readonly<{
57
- children?: never;
58
- }>, Init = undefined>(options?: Options): {
59
- asMiddleware: (middlewareComponent: ComponentType<MiddlewareComponentProps<Request, Props, Init>>) => ComponentMiddleware<Request, Props, Init>;
60
- Provider: ComponentType<ProviderProps<Request, Props, Init>>;
61
- Proxy: ComponentType<ProxyProps<Request, Props>>;
62
- types: {
63
- init: Init;
64
- middleware: ComponentMiddleware<Request, Props, Init>;
65
- middlewareComponentProps: MiddlewareComponentProps<Request, Props, Init>;
66
- props: Props;
67
- request: Request;
68
- };
69
- useBuildComponentCallback: () => UseBuildComponentCallback<Request, Props>;
70
- };
71
-
72
- export { type ComponentMiddleware, createChainOfResponsibility };
1
+ export { a as ComponentMiddleware, c as createChainOfResponsibility } from './index-Cx9W9BxD.mjs';
2
+ import 'react';
@@ -1,72 +1,2 @@
1
- import { ComponentType, PropsWithChildren } from 'react';
2
-
3
- type Fn<P extends any[], R> = (...args: P) => R;
4
- type Enhancer<P extends any[], R> = (next: Fn<P, R>) => Fn<P, R>;
5
- type Middleware<P extends any[], R, S extends any[]> = (...init: S) => Enhancer<P, R>;
6
-
7
- type ComponentMiddleware<Request, Props = {
8
- children?: never;
9
- }, Init = undefined> = Middleware<[
10
- Request
11
- ], ComponentType<Props> | false | null | undefined, [
12
- Init
13
- ]>;
14
-
15
- type ResultComponent<Props> = ComponentType<Props> | false | null | undefined;
16
- type UseBuildComponentCallbackOptions<Props> = {
17
- fallbackComponent?: ResultComponent<Props>;
18
- };
19
- type UseBuildComponentCallback<Request, Props> = (request: Request, options?: UseBuildComponentCallbackOptions<Props>) => ComponentType<Props> | undefined;
20
- type ProviderProps<Request, Props, Init> = PropsWithChildren<{
21
- middleware: readonly ComponentMiddleware<Request, Props, Init>[];
22
- }> & (Init extends never | void ? {
23
- init?: undefined;
24
- } : Init extends undefined ? {
25
- init?: Init;
26
- } : {
27
- init: Init;
28
- });
29
- type ProxyProps<Request, Props extends object> = PropsWithChildren<Request extends never | void ? Props & {
30
- fallbackComponent?: ComponentType<Props>;
31
- request?: undefined;
32
- } : Request extends undefined ? Props & {
33
- fallbackComponent?: ComponentType<Props>;
34
- request?: Request;
35
- } : Props & {
36
- fallbackComponent?: ComponentType<Props>;
37
- request: Request;
38
- }>;
39
- type Options = {
40
- /**
41
- * Allows a middleware to pass another request object when calling its next middleware. Default is false.
42
- *
43
- * However, middleware could modify the request object before calling its next middleware. It is recommended
44
- * to use Object.freeze() to prevent middleware from modifying the request object.
45
- */
46
- passModifiedRequest?: boolean;
47
- };
48
- type MiddlewareProps<Request, Props, Init> = Readonly<{
49
- init: Init;
50
- Next: ComponentType<Partial<Props>>;
51
- request: Request;
52
- }>;
53
- type MiddlewareComponentProps<Request, Props, Init> = Props & Readonly<{
54
- middleware: MiddlewareProps<Request, Props, Init>;
55
- }>;
56
- declare function createChainOfResponsibility<Request = undefined, Props extends object = Readonly<{
57
- children?: never;
58
- }>, Init = undefined>(options?: Options): {
59
- asMiddleware: (middlewareComponent: ComponentType<MiddlewareComponentProps<Request, Props, Init>>) => ComponentMiddleware<Request, Props, Init>;
60
- Provider: ComponentType<ProviderProps<Request, Props, Init>>;
61
- Proxy: ComponentType<ProxyProps<Request, Props>>;
62
- types: {
63
- init: Init;
64
- middleware: ComponentMiddleware<Request, Props, Init>;
65
- middlewareComponentProps: MiddlewareComponentProps<Request, Props, Init>;
66
- props: Props;
67
- request: Request;
68
- };
69
- useBuildComponentCallback: () => UseBuildComponentCallback<Request, Props>;
70
- };
71
-
72
- export { type ComponentMiddleware, createChainOfResponsibility };
1
+ export { a as ComponentMiddleware, c as createChainOfResponsibility } from './index-Cx9W9BxD.js';
2
+ import 'react';
@@ -1,12 +1,15 @@
1
1
  import { IRenderFunction } from '@fluentui/react';
2
2
  import { Key } from 'react';
3
- import { createChainOfResponsibility } from './react-chain-of-responsibility.mjs';
3
+ import { C as CreateChainOfResponsibilityOptions, c as createChainOfResponsibility } from './index-Cx9W9BxD.mjs';
4
4
 
5
5
  type UseBuildRenderFunctionOptions<Props> = {
6
6
  getKey?: (props: Props | undefined) => Key;
7
7
  };
8
8
  type UseBuildRenderFunction<Props> = (options?: UseBuildRenderFunctionOptions<Props>) => IRenderFunction<Props>;
9
- declare function createChainOfResponsibilityForFluentUI<Props extends object, Init = undefined>(options?: Parameters<typeof createChainOfResponsibility>[0]): ReturnType<typeof createChainOfResponsibility<Props | undefined, Props, Init>> & {
9
+ /**
10
+ * @deprecated Fluent UI v9 no longer use `IRenderFunction` for custom render. We no longer validate the correctness of this function.
11
+ */
12
+ declare function createChainOfResponsibilityForFluentUI<Props extends object, Init = undefined>(options?: CreateChainOfResponsibilityOptions): ReturnType<typeof createChainOfResponsibility<Props | undefined, Props, Init>> & {
10
13
  useBuildRenderFunction: UseBuildRenderFunction<Props>;
11
14
  };
12
15
 
@@ -1,12 +1,15 @@
1
1
  import { IRenderFunction } from '@fluentui/react';
2
2
  import { Key } from 'react';
3
- import { createChainOfResponsibility } from './react-chain-of-responsibility.js';
3
+ import { C as CreateChainOfResponsibilityOptions, c as createChainOfResponsibility } from './index-Cx9W9BxD.js';
4
4
 
5
5
  type UseBuildRenderFunctionOptions<Props> = {
6
6
  getKey?: (props: Props | undefined) => Key;
7
7
  };
8
8
  type UseBuildRenderFunction<Props> = (options?: UseBuildRenderFunctionOptions<Props>) => IRenderFunction<Props>;
9
- declare function createChainOfResponsibilityForFluentUI<Props extends object, Init = undefined>(options?: Parameters<typeof createChainOfResponsibility>[0]): ReturnType<typeof createChainOfResponsibility<Props | undefined, Props, Init>> & {
9
+ /**
10
+ * @deprecated Fluent UI v9 no longer use `IRenderFunction` for custom render. We no longer validate the correctness of this function.
11
+ */
12
+ declare function createChainOfResponsibilityForFluentUI<Props extends object, Init = undefined>(options?: CreateChainOfResponsibilityOptions): ReturnType<typeof createChainOfResponsibility<Props | undefined, Props, Init>> & {
10
13
  useBuildRenderFunction: UseBuildRenderFunction<Props>;
11
14
  };
12
15
 
@@ -41,6 +41,7 @@ var import_react2 = __toESM(require("react"));
41
41
  var import_react = __toESM(require("react"));
42
42
 
43
43
  // src/isReactComponent.ts
44
+ var import_valibot = require("valibot");
44
45
  function isConsumer(component) {
45
46
  return component?.$$typeof?.toString() === "Symbol(react.context)";
46
47
  }
@@ -65,6 +66,7 @@ function isComponentClass(component) {
65
66
  function isReactComponent(component) {
66
67
  return isFunctionComponent(component) || isComponentClass(component) || isFragment(component) || isConsumer(component) || isProvider(component);
67
68
  }
69
+ var isReactComponent_default = isReactComponent;
68
70
 
69
71
  // src/private/compose.ts
70
72
  function compose(...fns) {
@@ -85,11 +87,11 @@ function createChainOfResponsibility(options = {}) {
85
87
  get enhancer() {
86
88
  return void 0;
87
89
  },
88
- useBuildComponentCallback(_, options2) {
89
- if (options2?.fallbackComponent) {
90
- return options2.fallbackComponent;
90
+ useBuildComponentCallback(_request, options2) {
91
+ if (!options2?.fallbackComponent) {
92
+ throw new Error("This component/hook cannot be used outside of its corresponding <Provider>");
91
93
  }
92
- throw new Error("This component/hook cannot be used outside of its corresponding <Provider>");
94
+ return options2.fallbackComponent;
93
95
  }
94
96
  };
95
97
  const context = (0, import_react.createContext)(defaultUseBuildComponentCallback);
@@ -114,7 +116,7 @@ function createChainOfResponsibility(options = {}) {
114
116
  hasReturned = true;
115
117
  if ((0, import_react.isValidElement)(returnValue)) {
116
118
  throw new Error("middleware must not return React element directly");
117
- } else if (returnValue !== false && returnValue !== null && typeof returnValue !== "undefined" && !isReactComponent(returnValue)) {
119
+ } else if (returnValue !== false && returnValue !== null && typeof returnValue !== "undefined" && !isReactComponent_default(returnValue)) {
118
120
  throw new Error(
119
121
  "middleware must return false, null, undefined, function component, or class component"
120
122
  );
@@ -146,10 +148,10 @@ function createChainOfResponsibility(options = {}) {
146
148
  return /* @__PURE__ */ import_react.default.createElement(context.Provider, { value: contextValue }, children);
147
149
  }
148
150
  const useBuildComponentCallback = () => (0, import_react.useContext)(context).useBuildComponentCallback;
149
- function Proxy2({ children, fallbackComponent, request, ...props }) {
151
+ function Proxy2({ fallbackComponent, request, ...props }) {
150
152
  const enhancer = useBuildComponentCallback();
151
153
  const Component = enhancer(request, { fallbackComponent });
152
- return Component ? /* @__PURE__ */ import_react.default.createElement(Component, { ...props }, children) : null;
154
+ return Component ? /* @__PURE__ */ import_react.default.createElement(Component, { ...props }) : null;
153
155
  }
154
156
  const asMiddleware = (MiddlewareComponent) => (init) => (next) => (request) => {
155
157
  const RawNextComponent = next(request);
@@ -169,29 +171,35 @@ function createChainOfResponsibility(options = {}) {
169
171
  MiddlewareOf.displayName = `MiddlewareOf<${MiddlewareComponent.displayName || ""}>`;
170
172
  return (0, import_react.memo)(MiddlewareOf);
171
173
  };
172
- return {
174
+ return Object.freeze({
173
175
  asMiddleware,
174
176
  Provider: (0, import_react.memo)(ChainOfResponsibilityProvider),
175
177
  Proxy: (0, import_react.memo)(Proxy2),
176
- types: {
178
+ types: Object.freeze({
177
179
  middlewareComponentProps: void 0,
178
180
  init: void 0,
179
181
  middleware: void 0,
180
182
  props: void 0,
183
+ proxyProps: void 0,
181
184
  request: void 0
182
- },
185
+ }),
183
186
  useBuildComponentCallback
184
- };
187
+ });
185
188
  }
189
+ var createChainOfResponsibility_default = createChainOfResponsibility;
186
190
 
187
191
  // src/createChainOfResponsibilityForFluentUI.tsx
188
192
  function createChainOfResponsibilityForFluentUI(options) {
189
- const returnValue = createChainOfResponsibility(options);
193
+ const returnValue = createChainOfResponsibility_default(options);
190
194
  const { Proxy: Proxy2 } = returnValue;
191
195
  const useBuildRenderFunction = (options2 = {}) => {
192
196
  const { getKey } = options2;
193
197
  return (0, import_react2.useCallback)(
194
- (props, defaultRender) => /* @__PURE__ */ import_react2.default.createElement(Proxy2, { ...props, fallbackComponent: defaultRender, key: getKey?.(props), request: props }),
198
+ (props, defaultRender) => (
199
+ // We no longer validate the correctness of this function.
200
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
201
+ /* @__PURE__ */ import_react2.default.createElement(Proxy2, { ...props, fallbackComponent: defaultRender, key: getKey?.(props), request: props })
202
+ ),
195
203
  [getKey]
196
204
  );
197
205
  };