@flipdish/ui-library 0.4.3 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/providers/UIProvider/index.cjs +8 -16
- package/dist/providers/UIProvider/index.cjs.map +1 -1
- package/dist/providers/UIProvider/index.d.ts +13 -13
- package/dist/providers/UIProvider/index.d.ts.map +1 -1
- package/dist/providers/UIProvider/index.js +8 -16
- package/dist/providers/UIProvider/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,28 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var ErrorBoundary = require('@flipdish/ui-library/providers/ErrorBoundary');
|
|
4
5
|
var RouteProvider = require('@flipdish/ui-library/providers/RouteProvider');
|
|
5
6
|
var ThemeProvider = require('@flipdish/ui-library/providers/ThemeProvider');
|
|
6
7
|
var reactRouter = require('react-router');
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
|
-
* @summary single entry-point provider that composes
|
|
10
|
+
* @summary single entry-point provider that composes theme, routing, and an error boundary for consuming apps
|
|
10
11
|
*/
|
|
11
|
-
const UIProvider = ({ children, themeModeOverride,
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
if (withBrowserRouter) {
|
|
19
|
-
tree = jsxRuntime.jsx(reactRouter.BrowserRouter, { children: tree });
|
|
20
|
-
}
|
|
21
|
-
// TODO(i18n): wrap `tree` in <TranslationProvider> once the translation layer lands.
|
|
22
|
-
// It will likely expose an async `useLoadTranslations(languageOverride)` hook (see
|
|
23
|
-
// FlipdishUI's FlipdishUIProvider) and a `languageOverride` prop forwarded from here.
|
|
24
|
-
// Order: ThemeProvider > [BrowserRouter > RouteProvider] > TranslationProvider > children.
|
|
25
|
-
return jsxRuntime.jsx(ThemeProvider.ThemeProvider, { themeModeOverride: themeModeOverride, children: tree });
|
|
12
|
+
const UIProvider = ({ children, themeModeOverride, baseUrl, errorBoundary }) => {
|
|
13
|
+
// TODO(i18n): add an internal library translation context so ui-library components can
|
|
14
|
+
// source their own copy (e.g. ErrorBoundary's "Something went wrong") without the
|
|
15
|
+
// consuming app needing to pass text props. This is purely internal — consuming apps
|
|
16
|
+
// own their own translation layer and wrap their content inside UIProvider as usual.
|
|
17
|
+
return (jsxRuntime.jsx(ThemeProvider.ThemeProvider, { themeModeOverride: themeModeOverride, children: jsxRuntime.jsx(reactRouter.BrowserRouter, { basename: baseUrl, children: jsxRuntime.jsx(RouteProvider.RouteProvider, { children: jsxRuntime.jsx(ErrorBoundary.ErrorBoundary, { ...errorBoundary, children: children }) }) }) }));
|
|
26
18
|
};
|
|
27
19
|
|
|
28
20
|
exports.UIProvider = UIProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../src/providers/UIProvider/index.tsx"],"sourcesContent":[null],"names":["_jsx","
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../src/providers/UIProvider/index.tsx"],"sourcesContent":[null],"names":["_jsx","ThemeProvider","BrowserRouter","RouteProvider","ErrorBoundary"],"mappings":";;;;;;;;AA4BA;;AAEG;AACI,MAAM,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,aAAa,EAAsC,KAAI;;;;;AAKxH,IAAA,QACEA,cAAA,CAACC,2BAAa,EAAA,EAAC,iBAAiB,EAAE,iBAAiB,EAAA,QAAA,EACjDD,cAAA,CAACE,yBAAa,EAAA,EAAC,QAAQ,EAAE,OAAO,EAAA,QAAA,EAC9BF,cAAA,CAACG,2BAAa,EAAA,EAAA,QAAA,EACZH,cAAA,CAACI,2BAAa,EAAA,EAAA,GAAK,aAAa,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAiB,EAAA,CAC9C,EAAA,CACF,EAAA,CACF;AAEpB;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ErrorBoundaryProps } from '@flipdish/ui-library/providers/ErrorBoundary';
|
|
1
2
|
import type { PropsWithChildren } from 'react';
|
|
2
3
|
export interface UIProviderProps {
|
|
3
4
|
/**
|
|
@@ -6,23 +7,22 @@ export interface UIProviderProps {
|
|
|
6
7
|
*/
|
|
7
8
|
themeModeOverride?: 'light' | 'dark';
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* data APIs via `createBrowserRouter`) — a second router would fight over the URL.
|
|
12
|
-
* @default true
|
|
10
|
+
* Base URL for the internal router. Use for micro-frontends mounted at a sub-path
|
|
11
|
+
* (e.g. `getMicroFrontendAttribute('data-portal-base-url') || '/'`).
|
|
13
12
|
*/
|
|
14
|
-
|
|
13
|
+
baseUrl?: string;
|
|
15
14
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @
|
|
15
|
+
* Props for the app-level `ErrorBoundary` that wraps children.
|
|
16
|
+
* At minimum pass `identifier` (e.g. `'app'`) to label the boundary in error
|
|
17
|
+
* logs. Wire `onError` to your error reporter (Datadog RUM, fdlogger, etc.).
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* errorBoundary={{ identifier: 'app', onError: datadogReporter }}
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
errorBoundary: Omit<ErrorBoundaryProps, 'children'>;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* @summary single entry-point provider that composes
|
|
25
|
+
* @summary single entry-point provider that composes theme, routing, and an error boundary for consuming apps
|
|
26
26
|
*/
|
|
27
|
-
export declare const UIProvider: ({ children, themeModeOverride,
|
|
27
|
+
export declare const UIProvider: ({ children, themeModeOverride, baseUrl, errorBoundary }: PropsWithChildren<UIProviderProps>) => import("react").JSX.Element;
|
|
28
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/UIProvider/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/UIProvider/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,8CAA8C,CAAC;AAGtG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACrC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,aAAa,EAAE,IAAI,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;CACrD;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,GAAI,yDAAyD,iBAAiB,CAAC,eAAe,CAAC,gCAcrH,CAAC"}
|
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { ErrorBoundary } from '@flipdish/ui-library/providers/ErrorBoundary';
|
|
2
3
|
import { RouteProvider } from '@flipdish/ui-library/providers/RouteProvider';
|
|
3
4
|
import { ThemeProvider } from '@flipdish/ui-library/providers/ThemeProvider';
|
|
4
5
|
import { BrowserRouter } from 'react-router';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
|
-
* @summary single entry-point provider that composes
|
|
8
|
+
* @summary single entry-point provider that composes theme, routing, and an error boundary for consuming apps
|
|
8
9
|
*/
|
|
9
|
-
const UIProvider = ({ children, themeModeOverride,
|
|
10
|
-
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
if (withBrowserRouter) {
|
|
17
|
-
tree = jsx(BrowserRouter, { children: tree });
|
|
18
|
-
}
|
|
19
|
-
// TODO(i18n): wrap `tree` in <TranslationProvider> once the translation layer lands.
|
|
20
|
-
// It will likely expose an async `useLoadTranslations(languageOverride)` hook (see
|
|
21
|
-
// FlipdishUI's FlipdishUIProvider) and a `languageOverride` prop forwarded from here.
|
|
22
|
-
// Order: ThemeProvider > [BrowserRouter > RouteProvider] > TranslationProvider > children.
|
|
23
|
-
return jsx(ThemeProvider, { themeModeOverride: themeModeOverride, children: tree });
|
|
10
|
+
const UIProvider = ({ children, themeModeOverride, baseUrl, errorBoundary }) => {
|
|
11
|
+
// TODO(i18n): add an internal library translation context so ui-library components can
|
|
12
|
+
// source their own copy (e.g. ErrorBoundary's "Something went wrong") without the
|
|
13
|
+
// consuming app needing to pass text props. This is purely internal — consuming apps
|
|
14
|
+
// own their own translation layer and wrap their content inside UIProvider as usual.
|
|
15
|
+
return (jsx(ThemeProvider, { themeModeOverride: themeModeOverride, children: jsx(BrowserRouter, { basename: baseUrl, children: jsx(RouteProvider, { children: jsx(ErrorBoundary, { ...errorBoundary, children: children }) }) }) }));
|
|
24
16
|
};
|
|
25
17
|
|
|
26
18
|
export { UIProvider };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/providers/UIProvider/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/providers/UIProvider/index.tsx"],"sourcesContent":[null],"names":["_jsx"],"mappings":";;;;;;AA4BA;;AAEG;AACI,MAAM,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,OAAO,EAAE,aAAa,EAAsC,KAAI;;;;;AAKxH,IAAA,QACEA,GAAA,CAAC,aAAa,EAAA,EAAC,iBAAiB,EAAE,iBAAiB,EAAA,QAAA,EACjDA,GAAA,CAAC,aAAa,EAAA,EAAC,QAAQ,EAAE,OAAO,EAAA,QAAA,EAC9BA,GAAA,CAAC,aAAa,EAAA,EAAA,QAAA,EACZA,GAAA,CAAC,aAAa,EAAA,EAAA,GAAK,aAAa,EAAA,QAAA,EAAG,QAAQ,EAAA,CAAiB,EAAA,CAC9C,EAAA,CACF,EAAA,CACF;AAEpB;;;;"}
|