@hitachivantara/uikit-react-core 4.0.1-next.4 → 4.0.1-next.5
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/Controls/Controls.d.ts +2 -10
- package/dist/Controls/RightControl/RightControl.d.ts +1 -1
- package/dist/Provider/Provider.d.ts +5 -18
- package/dist/Provider/Provider.js +25 -38
- package/dist/Provider/Provider.js.map +1 -1
- package/dist/SimpleGrid/SimpleGrid.d.ts +7 -8
- package/dist/Table/TableBody/TableBody.d.ts +4 -0
- package/dist/legacy/Controls/Controls.d.ts +2 -10
- package/dist/legacy/Controls/RightControl/RightControl.d.ts +1 -1
- package/dist/legacy/Provider/Provider.d.ts +5 -18
- package/dist/legacy/Provider/Provider.js +29 -40
- package/dist/legacy/Provider/Provider.js.map +1 -1
- package/dist/legacy/SimpleGrid/SimpleGrid.d.ts +7 -8
- package/dist/legacy/Table/TableBody/TableBody.d.ts +4 -0
- package/dist/legacy/theme/index.d.ts +2 -1
- package/dist/modern/Controls/Controls.d.ts +2 -10
- package/dist/modern/Controls/RightControl/RightControl.d.ts +1 -1
- package/dist/modern/Provider/Provider.d.ts +5 -18
- package/dist/modern/Provider/Provider.js +28 -38
- package/dist/modern/Provider/Provider.js.map +1 -1
- package/dist/modern/SimpleGrid/SimpleGrid.d.ts +7 -8
- package/dist/modern/Table/TableBody/TableBody.d.ts +4 -0
- package/dist/modern/theme/index.d.ts +2 -1
- package/dist/theme/index.d.ts +2 -1
- package/package.json +2 -2
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
import { StandardProps } from "@mui/material";
|
|
2
|
+
import { HvTableInstance } from "../Table";
|
|
2
3
|
|
|
3
4
|
export type HvControlsClassKey = "root" | "rightSection" | "leftSection";
|
|
4
5
|
|
|
5
|
-
export interface HvControlsSortValue {
|
|
6
|
-
id: string;
|
|
7
|
-
desc: string;
|
|
8
|
-
}
|
|
9
6
|
export interface HvControlsViewConfiguration extends Record<string, unknown> {
|
|
10
7
|
id: string;
|
|
11
8
|
label: string;
|
|
12
9
|
icon: React.ReactNode;
|
|
13
10
|
}
|
|
14
11
|
|
|
15
|
-
export interface HvControlsCallbacks extends Record<string, unknown> {
|
|
16
|
-
setSortBy?: (v: HvControlsSortValue[]) => void;
|
|
17
|
-
setGlobalFilter?: (v: string) => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
12
|
export interface HvControlsProps
|
|
21
13
|
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, HvControlsClassKey> {
|
|
22
14
|
/** Children to be rendered. */
|
|
@@ -29,7 +21,7 @@ export interface HvControlsProps
|
|
|
29
21
|
* An instance of useHvTable or useTable used to manage the data
|
|
30
22
|
* if this is not provided data sorting and search must be handled externally
|
|
31
23
|
*/
|
|
32
|
-
callbacks?:
|
|
24
|
+
callbacks?: Pick<HvTableInstance, "setSortBy" | "setGlobalFilter">;
|
|
33
25
|
/**
|
|
34
26
|
* Views configuration required for the view buttons
|
|
35
27
|
*/
|
|
@@ -52,32 +52,19 @@ export interface HvProviderProps {
|
|
|
52
52
|
* Ignored if a custom `generateClassName` is provided.
|
|
53
53
|
*/
|
|
54
54
|
generateClassNameOptions?: GenerateClassNameOptions;
|
|
55
|
-
/**
|
|
56
|
-
* Injects the generated stylesheets at the top of the `<head>` element of the page.
|
|
57
|
-
* This can ease the override of UI Kit components styles.
|
|
58
|
-
*
|
|
59
|
-
* By default, the styles are injected last in the `<head>` element of the page.
|
|
60
|
-
*/
|
|
61
|
-
injectStylesFirst?: boolean;
|
|
62
55
|
/**
|
|
63
56
|
* Disables the generation of the styles.
|
|
64
57
|
*/
|
|
65
58
|
disableStylesGeneration?: boolean;
|
|
66
59
|
|
|
67
60
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* The application using UI Kit should be responsible for adding the baseline css styles, by
|
|
73
|
-
* either using the `<HvCssBaseline />` component, using the `<HvScopedCssBaseline />` component,
|
|
74
|
-
* or ensuring that the necessary base styles are applied.
|
|
75
|
-
*
|
|
76
|
-
* Defaults to `false`. Will be removed in the next major release.
|
|
61
|
+
* By default the baseline styles are applied globally to the application.
|
|
62
|
+
* If you need to scope the CSS to avoid styling conflicts, you can set this prop to `"scoped"`.
|
|
63
|
+
* If you are providing the baseline styles, you can set this prop to false.
|
|
77
64
|
*
|
|
78
|
-
* @see https://lumada-design.github.io/uikit/master/?path=/docs/
|
|
65
|
+
* @see https://lumada-design.github.io/uikit/master/?path=/docs/theme-css-baseline--page
|
|
79
66
|
*/
|
|
80
|
-
|
|
67
|
+
cssBaseline?: "global" | "scoped" | "none";
|
|
81
68
|
}
|
|
82
69
|
|
|
83
70
|
export default function HvProvider(props: HvProviderProps): JSX.Element | null;
|
|
@@ -53,13 +53,12 @@ var _context = _interopRequireDefault(require("./context"));
|
|
|
53
53
|
|
|
54
54
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
55
55
|
|
|
56
|
-
var _HvCssBaseline;
|
|
56
|
+
var _HvCssBaseline, _HvScopedCssBaseline;
|
|
57
57
|
|
|
58
58
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
59
59
|
|
|
60
60
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
61
61
|
|
|
62
|
-
var warnedOnce = false;
|
|
63
62
|
/**
|
|
64
63
|
* Augments the target theme with the differences found in the source theme.
|
|
65
64
|
*
|
|
@@ -67,7 +66,6 @@ var warnedOnce = false;
|
|
|
67
66
|
* @param {Object} InputSourceTheme - A material UI Theme to apply on top.
|
|
68
67
|
* @returns {Object} - A new modified material UI theme.
|
|
69
68
|
*/
|
|
70
|
-
|
|
71
69
|
var applyCustomTheme = function applyCustomTheme(InputTargetTheme, InputSourceTheme) {
|
|
72
70
|
var muiDefaultTheme = (0, _material.createTheme)();
|
|
73
71
|
var targetTheme = (0, _cloneDeep.default)(InputTargetTheme);
|
|
@@ -124,31 +122,21 @@ var HvProvider = function HvProvider(_ref) {
|
|
|
124
122
|
locale = _ref$locale === void 0 ? "en-US" : _ref$locale,
|
|
125
123
|
generateClassNameProp = _ref.generateClassName,
|
|
126
124
|
generateClassNameOptions = _ref.generateClassNameOptions,
|
|
127
|
-
_ref$injectStylesFirs = _ref.injectStylesFirst,
|
|
128
|
-
injectStylesFirst = _ref$injectStylesFirs === void 0 ? true : _ref$injectStylesFirs,
|
|
129
125
|
_ref$disableStylesGen = _ref.disableStylesGeneration,
|
|
130
126
|
disableStylesGeneration = _ref$disableStylesGen === void 0 ? false : _ref$disableStylesGen,
|
|
131
|
-
_ref$
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
if (process.env.NODE_ENV !== "production") {
|
|
135
|
-
if (!warnedOnce && !disableCssBaseline) {
|
|
136
|
-
warnedOnce = true; // eslint-disable-next-line no-console
|
|
137
|
-
|
|
138
|
-
console.warn("UI Kit HvProvider's automatic definition of a css styles baseline will be removed in the next major version.\n" + "You can use the `disableCssBaseline` property to disable it already.\n" + "See https://lumada-design.github.io/uikit/master/?path=/docs/foundation-css-baseline--main");
|
|
139
|
-
}
|
|
140
|
-
}
|
|
127
|
+
_ref$cssBaseline = _ref.cssBaseline,
|
|
128
|
+
cssBaseline = _ref$cssBaseline === void 0 ? "global" : _ref$cssBaseline;
|
|
141
129
|
|
|
142
130
|
var _useState = (0, _react.useState)(locale),
|
|
143
131
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
144
132
|
localeSetting = _useState2[0],
|
|
145
|
-
|
|
133
|
+
setLocaleSetting = _useState2[1];
|
|
146
134
|
|
|
147
135
|
(0, _react.useEffect)(function () {
|
|
148
136
|
var _navigator;
|
|
149
137
|
|
|
150
138
|
// ssr - only runs at the rendering phase, so it won't run on the server
|
|
151
|
-
|
|
139
|
+
setLocaleSetting(locale || ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.language));
|
|
152
140
|
}, [locale]);
|
|
153
141
|
var rawUiKitTheme = (0, _theme.getTheme)(uiKitTheme);
|
|
154
142
|
var customTheme = applyCustomTheme((0, _theme.themeBuilder)(rawUiKitTheme), theme);
|
|
@@ -159,14 +147,27 @@ var HvProvider = function HvProvider(_ref) {
|
|
|
159
147
|
locale: localeSetting
|
|
160
148
|
};
|
|
161
149
|
}, [changeTheme, localeSetting]);
|
|
150
|
+
|
|
151
|
+
var renderCssBaseline = function renderCssBaseline() {
|
|
152
|
+
if (cssBaseline === "global") {
|
|
153
|
+
return _HvCssBaseline || (_HvCssBaseline = /*#__PURE__*/(0, _jsxRuntime.jsx)(_theme.HvCssBaseline, {}));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (cssBaseline === "scoped") {
|
|
157
|
+
return _HvScopedCssBaseline || (_HvScopedCssBaseline = /*#__PURE__*/(0, _jsxRuntime.jsx)(_theme.HvScopedCssBaseline, {}));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return null;
|
|
161
|
+
};
|
|
162
|
+
|
|
162
163
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles2.StyledEngineProvider, {
|
|
163
|
-
injectFirst:
|
|
164
|
+
injectFirst: true,
|
|
164
165
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_styles.StylesProvider, {
|
|
165
166
|
generateClassName: generateClassName,
|
|
166
167
|
disableGeneration: disableStylesGeneration,
|
|
167
168
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.ThemeProvider, {
|
|
168
169
|
theme: customTheme,
|
|
169
|
-
children: [
|
|
170
|
+
children: [renderCssBaseline(), /*#__PURE__*/(0, _jsxRuntime.jsx)(_context.default.Provider, {
|
|
170
171
|
value: pConfig,
|
|
171
172
|
children: children
|
|
172
173
|
})]
|
|
@@ -237,33 +238,19 @@ process.env.NODE_ENV !== "production" ? HvProvider.propTypes = {
|
|
|
237
238
|
seed: _propTypes.default.string
|
|
238
239
|
}),
|
|
239
240
|
|
|
240
|
-
/**
|
|
241
|
-
* Injects the generated stylesheets at the top of the `<head>` element of the page.
|
|
242
|
-
* This can ease the override of UI Kit components styles.
|
|
243
|
-
*
|
|
244
|
-
* By default, the styles are injected last in the `<head>` element of the page.
|
|
245
|
-
*/
|
|
246
|
-
injectStylesFirst: _propTypes.default.bool,
|
|
247
|
-
|
|
248
241
|
/**
|
|
249
242
|
* Disables the generation of the styles.
|
|
250
243
|
*/
|
|
251
244
|
disableStylesGeneration: _propTypes.default.bool,
|
|
252
245
|
|
|
253
246
|
/**
|
|
254
|
-
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
* The application using UI Kit should be responsible for adding the baseline css styles, by
|
|
259
|
-
* either using the `<HvCssBaseline />` component, using the `<HvScopedCssBaseline />` component,
|
|
260
|
-
* or ensuring that the necessary base styles are applied.
|
|
261
|
-
*
|
|
262
|
-
* Defaults to `false`. Will be removed in the next major release.
|
|
247
|
+
* By default the baseline styles are applied globally to the application.
|
|
248
|
+
* If you need to scope the CSS to avoid styling conflicts, you can set this prop to `"scoped"`.
|
|
249
|
+
* If you are providing the baseline styles, you can set this prop to false.
|
|
263
250
|
*
|
|
264
|
-
* @see https://lumada-design.github.io/uikit/master/?path=/docs/
|
|
251
|
+
* @see https://lumada-design.github.io/uikit/master/?path=/docs/theme-css-baseline--page
|
|
265
252
|
*/
|
|
266
|
-
|
|
253
|
+
cssBaseline: _propTypes.default.oneOf(["global", "scoped", "none"])
|
|
267
254
|
} : void 0;
|
|
268
255
|
var _default = HvProvider;
|
|
269
256
|
exports.default = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","names":["warnedOnce","applyCustomTheme","InputTargetTheme","InputSourceTheme","muiDefaultTheme","createTheme","targetTheme","cloneDeep","sourceTheme","deleteDifference","isEmpty","diff","observableDiff","difference","partialCustomTheme","set","path","rhs","kind","merge","HvProvider","children","uiKitTheme","theme","changeTheme","locale","generateClassNameProp","generateClassName","generateClassNameOptions","injectStylesFirst","disableStylesGeneration","disableCssBaseline","process","env","NODE_ENV","console","warn","useState","localeSetting","setLocaleStting","useEffect","navigator","language","rawUiKitTheme","getTheme","customTheme","themeBuilder","createGenerateClassName","pConfig","useMemo","propTypes","PropTypes","node","isRequired","oneOf","instanceOf","Object","func","string","shape","disableGlobal","bool","productionPrefix","seed"],"sources":["../../src/Provider/Provider.js"],"sourcesContent":["import React, { useState, useEffect, useMemo } from \"react\";\nimport PropTypes from \"prop-types\";\n\nimport set from \"lodash/set\";\nimport merge from \"lodash/merge\";\nimport isEmpty from \"lodash/isEmpty\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport diff from \"deep-diff\";\n\nimport \"focus-within-polyfill\";\nimport \"focus-visible\";\n\nimport { createTheme, ThemeProvider } from \"@mui/material\";\nimport { StylesProvider } from \"@mui/styles\";\nimport { StyledEngineProvider } from \"@mui/material/styles\";\nimport { themeBuilder, createGenerateClassName, HvCssBaseline, getTheme } from \"../theme\";\n\nimport ConfigContext from \"./context\";\n\nlet warnedOnce = false;\n\n/**\n * Augments the target theme with the differences found in the source theme.\n *\n * @param {Object} InputTargetTheme - A material UI Theme to be changed.\n * @param {Object} InputSourceTheme - A material UI Theme to apply on top.\n * @returns {Object} - A new modified material UI theme.\n */\nconst applyCustomTheme = (InputTargetTheme, InputSourceTheme) => {\n const muiDefaultTheme = createTheme();\n const targetTheme = cloneDeep(InputTargetTheme);\n const sourceTheme = cloneDeep(InputSourceTheme);\n const deleteDifference = \"D\";\n if (!isEmpty(targetTheme) && !isEmpty(sourceTheme)) {\n diff.observableDiff(muiDefaultTheme, sourceTheme, (difference) => {\n const partialCustomTheme = set({}, difference.path, difference.rhs);\n if (difference.kind !== deleteDifference) {\n // Do not include the differences of type \"delete\"\n merge(targetTheme, partialCustomTheme);\n }\n });\n return targetTheme;\n }\n return targetTheme;\n};\n\n/**\n * This component makes cross-component properties, like the active `theme` and `locale`,\n * available down the React tree thanks to React context.\n *\n * This component should preferably be used at **the root of your component tree** and\n * be unique in the App in most cases.\n *\n * ```jsx\n * <HvProvider>\n * <MyApp />\n * <HvProvider/>\n * ```\n *\n * If several `HvProvider`'s are used, either nested or in parallel, the `generateClassNameOptions`\n * must be tweaked to avoid CSS classnames collision. Or a custom JSS's class name generator can\n * be provided via the `generateClassName` property.\n *\n * **UI Kit components will not work at all if the `HvProvider` is not configured correctly**,\n * as they will not be able to access the properties of the active theme..\n *\n */\nconst HvProvider = ({\n children,\n\n uiKitTheme = \"dawn\",\n theme = null,\n changeTheme = () => {},\n\n locale = \"en-US\",\n\n generateClassName: generateClassNameProp,\n generateClassNameOptions,\n injectStylesFirst = true,\n disableStylesGeneration = false,\n\n disableCssBaseline = false,\n}) => {\n if (process.env.NODE_ENV !== \"production\") {\n if (!warnedOnce && !disableCssBaseline) {\n warnedOnce = true;\n // eslint-disable-next-line no-console\n console.warn(\n \"UI Kit HvProvider's automatic definition of a css styles baseline will be removed in the next major version.\\n\" +\n \"You can use the `disableCssBaseline` property to disable it already.\\n\" +\n \"See https://lumada-design.github.io/uikit/master/?path=/docs/foundation-css-baseline--main\"\n );\n }\n }\n\n const [localeSetting, setLocaleStting] = useState(locale);\n\n useEffect(() => {\n // ssr - only runs at the rendering phase, so it won't run on the server\n setLocaleStting(locale || navigator?.language);\n }, [locale]);\n\n const rawUiKitTheme = getTheme(uiKitTheme);\n const customTheme = applyCustomTheme(themeBuilder(rawUiKitTheme), theme);\n\n const generateClassName =\n generateClassNameProp || createGenerateClassName(generateClassNameOptions);\n\n const pConfig = useMemo(\n () => ({ changeTheme, locale: localeSetting }),\n [changeTheme, localeSetting]\n );\n\n return (\n <StyledEngineProvider injectFirst={injectStylesFirst}>\n <StylesProvider\n generateClassName={generateClassName}\n disableGeneration={disableStylesGeneration}\n >\n <ThemeProvider theme={customTheme}>\n {!disableCssBaseline && <HvCssBaseline />}\n <ConfigContext.Provider value={pConfig}>{children}</ConfigContext.Provider>\n </ThemeProvider>\n </StylesProvider>\n </StyledEngineProvider>\n );\n};\n\nHvProvider.propTypes = {\n /**\n * Your component tree.\n */\n children: PropTypes.node.isRequired,\n\n /**\n * The Design System base theme in use. Defaults to `\"dawn\"`.\n */\n uiKitTheme: PropTypes.oneOf([\"dawn\", \"wicked\"]),\n /**\n * The UI Kit theme object to be applied on top of the base theme.\n */\n theme: PropTypes.instanceOf(Object),\n /**\n * Function stored in the provider's context to allow runtime switching of the active theme.\n * The implementation is up to each App.\n */\n changeTheme: PropTypes.func,\n\n /**\n * The locale to be used.\n * Defaults to the browser's configured locale or \"en-US\" if not available.\n */\n locale: PropTypes.string,\n\n /**\n * Custom JSS's class name generator.\n */\n generateClassName: PropTypes.func,\n /**\n * Built-in JSS's class name generator options.\n * Ignored if a custom `generateClassName` is provided.\n *\n * `disableGlobal`: Disable the generation of deterministic class names. Defaults to `false`.\n *\n * `productionPrefix`: The string used to prefix the class names in production. Defaults to `\"jss-uikit\"`.\n *\n * `seed`: The string used to uniquely identify the generator. Defaults to `\"\"`.\n * It can be used to avoid class name collisions when using multiple generators in the same document.\n */\n generateClassNameOptions: PropTypes.shape({\n /**\n * Disable the generation of deterministic class names. Defaults to `false`.\n */\n disableGlobal: PropTypes.bool,\n /**\n * The string used to prefix the class names in production. Defaults to `\"jss-uikit\"`.\n */\n productionPrefix: PropTypes.string,\n /**\n * The string used to uniquely identify the generator. Defaults to `\"\"`.\n * It can be used to avoid class name collisions when using multiple generators in the same document.\n */\n seed: PropTypes.string,\n }),\n /**\n * Injects the generated stylesheets at the top of the `<head>` element of the page.\n * This can ease the override of UI Kit components styles.\n *\n * By default, the styles are injected last in the `<head>` element of the page.\n */\n injectStylesFirst: PropTypes.bool,\n /**\n * Disables the generation of the styles.\n */\n disableStylesGeneration: PropTypes.bool,\n\n /**\n * Disables the generation of the baseline css styles.\n *\n * This will be the default behavior in the future.\n *\n * The application using UI Kit should be responsible for adding the baseline css styles, by\n * either using the `<HvCssBaseline />` component, using the `<HvScopedCssBaseline />` component,\n * or ensuring that the necessary base styles are applied.\n *\n * Defaults to `false`. Will be removed in the next major release.\n *\n * @see https://lumada-design.github.io/uikit/master/?path=/docs/foundation-css-baseline--main\n */\n disableCssBaseline: PropTypes.bool,\n};\n\nexport default HvProvider;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;AAEA,IAAIA,UAAU,GAAG,KAAjB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,gBAAD,EAAmBC,gBAAnB,EAAwC;EAC/D,IAAMC,eAAe,GAAG,IAAAC,qBAAA,GAAxB;EACA,IAAMC,WAAW,GAAG,IAAAC,kBAAA,EAAUL,gBAAV,CAApB;EACA,IAAMM,WAAW,GAAG,IAAAD,kBAAA,EAAUJ,gBAAV,CAApB;EACA,IAAMM,gBAAgB,GAAG,GAAzB;;EACA,IAAI,CAAC,IAAAC,gBAAA,EAAQJ,WAAR,CAAD,IAAyB,CAAC,IAAAI,gBAAA,EAAQF,WAAR,CAA9B,EAAoD;IA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CAAgB,CAAC,MAAD,EAAS,QAAT,CAAhB,CATS;;EAUrB;AACF;AACA;EACE/B,KAAK,EAAE4B,kBAAA,CAAUI,UAAV,CAAqBC,MAArB,CAbc;;EAcrB;AACF;AACA;AACA;EACEhC,WAAW,EAAE2B,kBAAA,CAAUM,IAlBF;;EAoBrB;AACF;AACA;AACA;EACEhC,MAAM,EAAE0B,kBAAA,CAAUO,MAxBG;;EA0BrB;AACF;AACA;EACE/B,iBAAiB,EAAEwB,kBAAA,CAAUM,IA7BR;;EA8BrB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE7B,wBAAwB,EAAEuB,kBAAA,CAAUQ,KAAV,CAAgB;IACxC;AACJ;AACA;IACIC,aAAa,EAAET,kBAAA,CAAUU,IAJe;;IAKxC;AACJ;AACA;IACIC,gBAAgB,EAAEX,kBAAA,CAAUO,MARY;;IASxC;AACJ;AACA;AACA;IACIK,IAAI,EAAEZ,kBAAA,CAAUO;EAbwB,CAAhB,CAzCL;;EAwDrB;AACF;AACA;AACA;AACA;AACA;EACE7B,iBAAiB,EAAEsB,kBAAA,CAAUU,IA9DR;;EA+DrB;AACF;AACA;EACE/B,uBAAuB,EAAEqB,kBAAA,CAAUU,IAlEd;;EAoErB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACE9B,kBAAkB,EAAEoB,kBAAA,CAAUU;AAjFT,CAAvB;eAoFezC,U"}
|
|
1
|
+
{"version":3,"file":"Provider.js","names":["applyCustomTheme","InputTargetTheme","InputSourceTheme","muiDefaultTheme","createTheme","targetTheme","cloneDeep","sourceTheme","deleteDifference","isEmpty","diff","observableDiff","difference","partialCustomTheme","set","path","rhs","kind","merge","HvProvider","children","uiKitTheme","theme","changeTheme","locale","generateClassNameProp","generateClassName","generateClassNameOptions","disableStylesGeneration","cssBaseline","useState","localeSetting","setLocaleSetting","useEffect","navigator","language","rawUiKitTheme","getTheme","customTheme","themeBuilder","createGenerateClassName","pConfig","useMemo","renderCssBaseline","propTypes","PropTypes","node","isRequired","oneOf","instanceOf","Object","func","string","shape","disableGlobal","bool","productionPrefix","seed"],"sources":["../../src/Provider/Provider.js"],"sourcesContent":["import React, { useState, useEffect, useMemo } from \"react\";\nimport PropTypes from \"prop-types\";\n\nimport set from \"lodash/set\";\nimport merge from \"lodash/merge\";\nimport isEmpty from \"lodash/isEmpty\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport diff from \"deep-diff\";\n\nimport \"focus-within-polyfill\";\nimport \"focus-visible\";\n\nimport { createTheme, ThemeProvider } from \"@mui/material\";\nimport { StylesProvider } from \"@mui/styles\";\nimport { StyledEngineProvider } from \"@mui/material/styles\";\nimport {\n themeBuilder,\n createGenerateClassName,\n HvCssBaseline,\n getTheme,\n HvScopedCssBaseline,\n} from \"../theme\";\n\nimport ConfigContext from \"./context\";\n\n/**\n * Augments the target theme with the differences found in the source theme.\n *\n * @param {Object} InputTargetTheme - A material UI Theme to be changed.\n * @param {Object} InputSourceTheme - A material UI Theme to apply on top.\n * @returns {Object} - A new modified material UI theme.\n */\nconst applyCustomTheme = (InputTargetTheme, InputSourceTheme) => {\n const muiDefaultTheme = createTheme();\n const targetTheme = cloneDeep(InputTargetTheme);\n const sourceTheme = cloneDeep(InputSourceTheme);\n const deleteDifference = \"D\";\n if (!isEmpty(targetTheme) && !isEmpty(sourceTheme)) {\n diff.observableDiff(muiDefaultTheme, sourceTheme, (difference) => {\n const partialCustomTheme = set({}, difference.path, difference.rhs);\n if (difference.kind !== deleteDifference) {\n // Do not include the differences of type \"delete\"\n merge(targetTheme, partialCustomTheme);\n }\n });\n return targetTheme;\n }\n return targetTheme;\n};\n\n/**\n * This component makes cross-component properties, like the active `theme` and `locale`,\n * available down the React tree thanks to React context.\n *\n * This component should preferably be used at **the root of your component tree** and\n * be unique in the App in most cases.\n *\n * ```jsx\n * <HvProvider>\n * <MyApp />\n * <HvProvider/>\n * ```\n *\n * If several `HvProvider`'s are used, either nested or in parallel, the `generateClassNameOptions`\n * must be tweaked to avoid CSS classnames collision. Or a custom JSS's class name generator can\n * be provided via the `generateClassName` property.\n *\n * **UI Kit components will not work at all if the `HvProvider` is not configured correctly**,\n * as they will not be able to access the properties of the active theme..\n *\n */\nconst HvProvider = ({\n children,\n\n uiKitTheme = \"dawn\",\n theme = null,\n changeTheme = () => {},\n\n locale = \"en-US\",\n\n generateClassName: generateClassNameProp,\n generateClassNameOptions,\n disableStylesGeneration = false,\n\n cssBaseline = \"global\",\n}) => {\n const [localeSetting, setLocaleSetting] = useState(locale);\n\n useEffect(() => {\n // ssr - only runs at the rendering phase, so it won't run on the server\n setLocaleSetting(locale || navigator?.language);\n }, [locale]);\n\n const rawUiKitTheme = getTheme(uiKitTheme);\n const customTheme = applyCustomTheme(themeBuilder(rawUiKitTheme), theme);\n\n const generateClassName =\n generateClassNameProp || createGenerateClassName(generateClassNameOptions);\n\n const pConfig = useMemo(\n () => ({ changeTheme, locale: localeSetting }),\n [changeTheme, localeSetting]\n );\n\n const renderCssBaseline = () => {\n if (cssBaseline === \"global\") {\n return <HvCssBaseline />;\n }\n if (cssBaseline === \"scoped\") {\n return <HvScopedCssBaseline />;\n }\n return null;\n };\n\n return (\n <StyledEngineProvider injectFirst>\n <StylesProvider\n generateClassName={generateClassName}\n disableGeneration={disableStylesGeneration}\n >\n <ThemeProvider theme={customTheme}>\n {renderCssBaseline()}\n <ConfigContext.Provider value={pConfig}>{children}</ConfigContext.Provider>\n </ThemeProvider>\n </StylesProvider>\n </StyledEngineProvider>\n );\n};\n\nHvProvider.propTypes = {\n /**\n * Your component tree.\n */\n children: PropTypes.node.isRequired,\n\n /**\n * The Design System base theme in use. Defaults to `\"dawn\"`.\n */\n uiKitTheme: PropTypes.oneOf([\"dawn\", \"wicked\"]),\n /**\n * The UI Kit theme object to be applied on top of the base theme.\n */\n theme: PropTypes.instanceOf(Object),\n /**\n * Function stored in the provider's context to allow runtime switching of the active theme.\n * The implementation is up to each App.\n */\n changeTheme: PropTypes.func,\n\n /**\n * The locale to be used.\n * Defaults to the browser's configured locale or \"en-US\" if not available.\n */\n locale: PropTypes.string,\n\n /**\n * Custom JSS's class name generator.\n */\n generateClassName: PropTypes.func,\n /**\n * Built-in JSS's class name generator options.\n * Ignored if a custom `generateClassName` is provided.\n *\n * `disableGlobal`: Disable the generation of deterministic class names. Defaults to `false`.\n *\n * `productionPrefix`: The string used to prefix the class names in production. Defaults to `\"jss-uikit\"`.\n *\n * `seed`: The string used to uniquely identify the generator. Defaults to `\"\"`.\n * It can be used to avoid class name collisions when using multiple generators in the same document.\n */\n generateClassNameOptions: PropTypes.shape({\n /**\n * Disable the generation of deterministic class names. Defaults to `false`.\n */\n disableGlobal: PropTypes.bool,\n /**\n * The string used to prefix the class names in production. Defaults to `\"jss-uikit\"`.\n */\n productionPrefix: PropTypes.string,\n /**\n * The string used to uniquely identify the generator. Defaults to `\"\"`.\n * It can be used to avoid class name collisions when using multiple generators in the same document.\n */\n seed: PropTypes.string,\n }),\n /**\n * Disables the generation of the styles.\n */\n disableStylesGeneration: PropTypes.bool,\n /**\n * By default the baseline styles are applied globally to the application.\n * If you need to scope the CSS to avoid styling conflicts, you can set this prop to `\"scoped\"`.\n * If you are providing the baseline styles, you can set this prop to false.\n *\n * @see https://lumada-design.github.io/uikit/master/?path=/docs/theme-css-baseline--page\n */\n cssBaseline: PropTypes.oneOf([\"global\", \"scoped\", \"none\"]),\n};\n\nexport default HvProvider;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAQA;;;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMA,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,gBAAD,EAAmBC,gBAAnB,EAAwC;EAC/D,IAAMC,eAAe,GAAG,IAAAC,qBAAA,GAAxB;EACA,IAAMC,WAAW,GAAG,IAA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EACrB;AACF;AACA;EACExB,QAAQ,EAAEyB,kBAAA,CAAUC,IAAV,CAAeC,UAJJ;;EAMrB;AACF;AACA;EACE1B,UAAU,EAAEwB,kBAAA,CAAUG,KAAV,CAAgB,CAAC,MAAD,EAAS,QAAT,CAAhB,CATS;;EAUrB;AACF;AACA;EACE1B,KAAK,EAAEuB,kBAAA,CAAUI,UAAV,CAAqBC,MAArB,CAbc;;EAcrB;AACF;AACA;AACA;EACE3B,WAAW,EAAEsB,kBAAA,CAAUM,IAlBF;;EAoBrB;AACF;AACA;AACA;EACE3B,MAAM,EAAEqB,kBAAA,CAAUO,MAxBG;;EA0BrB;AACF;AACA;EACE1B,iBAAiB,EAAEmB,kBAAA,CAAUM,IA7BR;;EA8BrB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACExB,wBAAwB,EAAEkB,kBAAA,CAAUQ,KAAV,CAAgB;IACxC;AACJ;AACA;IACIC,aAAa,EAAET,kBAAA,CAAUU,IAJe;;IAKxC;AACJ;AACA;IACIC,gBAAgB,EAAEX,kBAAA,CAAUO,MARY;;IASxC;AACJ;AACA;AACA;IACIK,IAAI,EAAEZ,kBAAA,CAAUO;EAbwB,CAAhB,CAzCL;;EAwDrB;AACF;AACA;EACExB,uBAAuB,EAAEiB,kBAAA,CAAUU,IA3Dd;;EA4DrB;AACF;AACA;AACA;AACA;AACA;AACA;EACE1B,WAAW,EAAEgB,kBAAA,CAAUG,KAAV,CAAgB,CAAC,QAAD,EAAW,QAAX,EAAqB,MAArB,CAAhB;AAnEQ,CAAvB;eAsEe7B,U"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type GridSpacing = "xs" | "sm" | "md" | "lg";
|
|
4
|
-
export type Breakpoints = {
|
|
1
|
+
export type Spacing = "xs" | "sm" | "md" | "lg";
|
|
2
|
+
export type Breakpoint = {
|
|
5
3
|
cols?: number;
|
|
6
4
|
maxWidth?: number;
|
|
7
5
|
minWidth?: number;
|
|
8
|
-
spacing?:
|
|
6
|
+
spacing?: Spacing;
|
|
9
7
|
};
|
|
10
8
|
|
|
11
|
-
export interface SimpleGridProps
|
|
12
|
-
|
|
9
|
+
export interface SimpleGridProps {
|
|
10
|
+
children?: JSX.Element | JSX.Element[];
|
|
11
|
+
spacing?: Spacing;
|
|
13
12
|
cols?: number;
|
|
14
|
-
breakpoints?:
|
|
13
|
+
breakpoints?: Breakpoint[];
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
export default function HvSimpleGrid(props: SimpleGridProps): JSX.Element | null;
|
|
@@ -9,6 +9,10 @@ export interface HvTableBodyProps
|
|
|
9
9
|
* Defaults to `thead`.
|
|
10
10
|
*/
|
|
11
11
|
component?: React.ElementType<React.HTMLAttributes<HTMLElement>>;
|
|
12
|
+
/**
|
|
13
|
+
* Sets whether or not there should be arrow navigation between the table rows
|
|
14
|
+
*/
|
|
15
|
+
withNavigation?: boolean;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
export default function HvTableBody(props: HvTableBodyProps): JSX.Element | null;
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
import { StandardProps } from "@mui/material";
|
|
2
|
+
import { HvTableInstance } from "../Table";
|
|
2
3
|
|
|
3
4
|
export type HvControlsClassKey = "root" | "rightSection" | "leftSection";
|
|
4
5
|
|
|
5
|
-
export interface HvControlsSortValue {
|
|
6
|
-
id: string;
|
|
7
|
-
desc: string;
|
|
8
|
-
}
|
|
9
6
|
export interface HvControlsViewConfiguration extends Record<string, unknown> {
|
|
10
7
|
id: string;
|
|
11
8
|
label: string;
|
|
12
9
|
icon: React.ReactNode;
|
|
13
10
|
}
|
|
14
11
|
|
|
15
|
-
export interface HvControlsCallbacks extends Record<string, unknown> {
|
|
16
|
-
setSortBy?: (v: HvControlsSortValue[]) => void;
|
|
17
|
-
setGlobalFilter?: (v: string) => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
12
|
export interface HvControlsProps
|
|
21
13
|
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, HvControlsClassKey> {
|
|
22
14
|
/** Children to be rendered. */
|
|
@@ -29,7 +21,7 @@ export interface HvControlsProps
|
|
|
29
21
|
* An instance of useHvTable or useTable used to manage the data
|
|
30
22
|
* if this is not provided data sorting and search must be handled externally
|
|
31
23
|
*/
|
|
32
|
-
callbacks?:
|
|
24
|
+
callbacks?: Pick<HvTableInstance, "setSortBy" | "setGlobalFilter">;
|
|
33
25
|
/**
|
|
34
26
|
* Views configuration required for the view buttons
|
|
35
27
|
*/
|
|
@@ -52,32 +52,19 @@ export interface HvProviderProps {
|
|
|
52
52
|
* Ignored if a custom `generateClassName` is provided.
|
|
53
53
|
*/
|
|
54
54
|
generateClassNameOptions?: GenerateClassNameOptions;
|
|
55
|
-
/**
|
|
56
|
-
* Injects the generated stylesheets at the top of the `<head>` element of the page.
|
|
57
|
-
* This can ease the override of UI Kit components styles.
|
|
58
|
-
*
|
|
59
|
-
* By default, the styles are injected last in the `<head>` element of the page.
|
|
60
|
-
*/
|
|
61
|
-
injectStylesFirst?: boolean;
|
|
62
55
|
/**
|
|
63
56
|
* Disables the generation of the styles.
|
|
64
57
|
*/
|
|
65
58
|
disableStylesGeneration?: boolean;
|
|
66
59
|
|
|
67
60
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* The application using UI Kit should be responsible for adding the baseline css styles, by
|
|
73
|
-
* either using the `<HvCssBaseline />` component, using the `<HvScopedCssBaseline />` component,
|
|
74
|
-
* or ensuring that the necessary base styles are applied.
|
|
75
|
-
*
|
|
76
|
-
* Defaults to `false`. Will be removed in the next major release.
|
|
61
|
+
* By default the baseline styles are applied globally to the application.
|
|
62
|
+
* If you need to scope the CSS to avoid styling conflicts, you can set this prop to `"scoped"`.
|
|
63
|
+
* If you are providing the baseline styles, you can set this prop to false.
|
|
77
64
|
*
|
|
78
|
-
* @see https://lumada-design.github.io/uikit/master/?path=/docs/
|
|
65
|
+
* @see https://lumada-design.github.io/uikit/master/?path=/docs/theme-css-baseline--page
|
|
79
66
|
*/
|
|
80
|
-
|
|
67
|
+
cssBaseline?: "global" | "scoped" | "none";
|
|
81
68
|
}
|
|
82
69
|
|
|
83
70
|
export default function HvProvider(props: HvProviderProps): JSX.Element | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
|
|
3
|
-
var _HvCssBaseline;
|
|
3
|
+
var _HvCssBaseline, _HvScopedCssBaseline;
|
|
4
4
|
|
|
5
5
|
import React, { useState, useEffect, useMemo } from "react";
|
|
6
6
|
import PropTypes from "prop-types";
|
|
@@ -14,11 +14,8 @@ import "focus-visible";
|
|
|
14
14
|
import { createTheme, ThemeProvider } from "@mui/material";
|
|
15
15
|
import { StylesProvider } from "@mui/styles";
|
|
16
16
|
import { StyledEngineProvider } from "@mui/material/styles";
|
|
17
|
-
import { themeBuilder, createGenerateClassName, HvCssBaseline, getTheme } from "../theme";
|
|
17
|
+
import { themeBuilder, createGenerateClassName, HvCssBaseline, getTheme, HvScopedCssBaseline } from "../theme";
|
|
18
18
|
import ConfigContext from "./context";
|
|
19
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
|
-
var warnedOnce = false;
|
|
22
19
|
/**
|
|
23
20
|
* Augments the target theme with the differences found in the source theme.
|
|
24
21
|
*
|
|
@@ -27,6 +24,9 @@ var warnedOnce = false;
|
|
|
27
24
|
* @returns {Object} - A new modified material UI theme.
|
|
28
25
|
*/
|
|
29
26
|
|
|
27
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
28
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
29
|
+
|
|
30
30
|
var applyCustomTheme = function applyCustomTheme(InputTargetTheme, InputSourceTheme) {
|
|
31
31
|
var muiDefaultTheme = createTheme();
|
|
32
32
|
var targetTheme = cloneDeep(InputTargetTheme);
|
|
@@ -82,31 +82,21 @@ var HvProvider = function HvProvider(_ref) {
|
|
|
82
82
|
locale = _ref$locale === void 0 ? "en-US" : _ref$locale,
|
|
83
83
|
generateClassNameProp = _ref.generateClassName,
|
|
84
84
|
generateClassNameOptions = _ref.generateClassNameOptions,
|
|
85
|
-
_ref$injectStylesFirs = _ref.injectStylesFirst,
|
|
86
|
-
injectStylesFirst = _ref$injectStylesFirs === void 0 ? true : _ref$injectStylesFirs,
|
|
87
85
|
_ref$disableStylesGen = _ref.disableStylesGeneration,
|
|
88
86
|
disableStylesGeneration = _ref$disableStylesGen === void 0 ? false : _ref$disableStylesGen,
|
|
89
|
-
_ref$
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
if (process.env.NODE_ENV !== "production") {
|
|
93
|
-
if (!warnedOnce && !disableCssBaseline) {
|
|
94
|
-
warnedOnce = true; // eslint-disable-next-line no-console
|
|
95
|
-
|
|
96
|
-
console.warn("UI Kit HvProvider's automatic definition of a css styles baseline will be removed in the next major version.\n" + "You can use the `disableCssBaseline` property to disable it already.\n" + "See https://lumada-design.github.io/uikit/master/?path=/docs/foundation-css-baseline--main");
|
|
97
|
-
}
|
|
98
|
-
}
|
|
87
|
+
_ref$cssBaseline = _ref.cssBaseline,
|
|
88
|
+
cssBaseline = _ref$cssBaseline === void 0 ? "global" : _ref$cssBaseline;
|
|
99
89
|
|
|
100
90
|
var _useState = useState(locale),
|
|
101
91
|
_useState2 = _slicedToArray(_useState, 2),
|
|
102
92
|
localeSetting = _useState2[0],
|
|
103
|
-
|
|
93
|
+
setLocaleSetting = _useState2[1];
|
|
104
94
|
|
|
105
95
|
useEffect(function () {
|
|
106
96
|
var _navigator;
|
|
107
97
|
|
|
108
98
|
// ssr - only runs at the rendering phase, so it won't run on the server
|
|
109
|
-
|
|
99
|
+
setLocaleSetting(locale || ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.language));
|
|
110
100
|
}, [locale]);
|
|
111
101
|
var rawUiKitTheme = getTheme(uiKitTheme);
|
|
112
102
|
var customTheme = applyCustomTheme(themeBuilder(rawUiKitTheme), theme);
|
|
@@ -117,14 +107,27 @@ var HvProvider = function HvProvider(_ref) {
|
|
|
117
107
|
locale: localeSetting
|
|
118
108
|
};
|
|
119
109
|
}, [changeTheme, localeSetting]);
|
|
110
|
+
|
|
111
|
+
var renderCssBaseline = function renderCssBaseline() {
|
|
112
|
+
if (cssBaseline === "global") {
|
|
113
|
+
return _HvCssBaseline || (_HvCssBaseline = /*#__PURE__*/_jsx(HvCssBaseline, {}));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (cssBaseline === "scoped") {
|
|
117
|
+
return _HvScopedCssBaseline || (_HvScopedCssBaseline = /*#__PURE__*/_jsx(HvScopedCssBaseline, {}));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return null;
|
|
121
|
+
};
|
|
122
|
+
|
|
120
123
|
return /*#__PURE__*/_jsx(StyledEngineProvider, {
|
|
121
|
-
injectFirst:
|
|
124
|
+
injectFirst: true,
|
|
122
125
|
children: /*#__PURE__*/_jsx(StylesProvider, {
|
|
123
126
|
generateClassName: generateClassName,
|
|
124
127
|
disableGeneration: disableStylesGeneration,
|
|
125
128
|
children: /*#__PURE__*/_jsxs(ThemeProvider, {
|
|
126
129
|
theme: customTheme,
|
|
127
|
-
children: [
|
|
130
|
+
children: [renderCssBaseline(), /*#__PURE__*/_jsx(ConfigContext.Provider, {
|
|
128
131
|
value: pConfig,
|
|
129
132
|
children: children
|
|
130
133
|
})]
|
|
@@ -195,33 +198,19 @@ process.env.NODE_ENV !== "production" ? HvProvider.propTypes = {
|
|
|
195
198
|
seed: PropTypes.string
|
|
196
199
|
}),
|
|
197
200
|
|
|
198
|
-
/**
|
|
199
|
-
* Injects the generated stylesheets at the top of the `<head>` element of the page.
|
|
200
|
-
* This can ease the override of UI Kit components styles.
|
|
201
|
-
*
|
|
202
|
-
* By default, the styles are injected last in the `<head>` element of the page.
|
|
203
|
-
*/
|
|
204
|
-
injectStylesFirst: PropTypes.bool,
|
|
205
|
-
|
|
206
201
|
/**
|
|
207
202
|
* Disables the generation of the styles.
|
|
208
203
|
*/
|
|
209
204
|
disableStylesGeneration: PropTypes.bool,
|
|
210
205
|
|
|
211
206
|
/**
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
216
|
-
* The application using UI Kit should be responsible for adding the baseline css styles, by
|
|
217
|
-
* either using the `<HvCssBaseline />` component, using the `<HvScopedCssBaseline />` component,
|
|
218
|
-
* or ensuring that the necessary base styles are applied.
|
|
219
|
-
*
|
|
220
|
-
* Defaults to `false`. Will be removed in the next major release.
|
|
207
|
+
* By default the baseline styles are applied globally to the application.
|
|
208
|
+
* If you need to scope the CSS to avoid styling conflicts, you can set this prop to `"scoped"`.
|
|
209
|
+
* If you are providing the baseline styles, you can set this prop to false.
|
|
221
210
|
*
|
|
222
|
-
* @see https://lumada-design.github.io/uikit/master/?path=/docs/
|
|
211
|
+
* @see https://lumada-design.github.io/uikit/master/?path=/docs/theme-css-baseline--page
|
|
223
212
|
*/
|
|
224
|
-
|
|
213
|
+
cssBaseline: PropTypes.oneOf(["global", "scoped", "none"])
|
|
225
214
|
} : void 0;
|
|
226
215
|
export default HvProvider;
|
|
227
216
|
//# sourceMappingURL=Provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","names":["React","useState","useEffect","useMemo","PropTypes","set","merge","isEmpty","cloneDeep","diff","createTheme","ThemeProvider","StylesProvider","StyledEngineProvider","themeBuilder","createGenerateClassName","HvCssBaseline","getTheme","ConfigContext","warnedOnce","applyCustomTheme","InputTargetTheme","InputSourceTheme","muiDefaultTheme","targetTheme","sourceTheme","deleteDifference","observableDiff","difference","partialCustomTheme","path","rhs","kind","HvProvider","children","uiKitTheme","theme","changeTheme","locale","generateClassNameProp","generateClassName","generateClassNameOptions","injectStylesFirst","disableStylesGeneration","disableCssBaseline","process","env","NODE_ENV","console","warn","localeSetting","setLocaleStting","navigator","language","rawUiKitTheme","customTheme","pConfig","propTypes","node","isRequired","oneOf","instanceOf","Object","func","string","shape","disableGlobal","bool","productionPrefix","seed"],"sources":["../../../src/Provider/Provider.js"],"sourcesContent":["import React, { useState, useEffect, useMemo } from \"react\";\nimport PropTypes from \"prop-types\";\n\nimport set from \"lodash/set\";\nimport merge from \"lodash/merge\";\nimport isEmpty from \"lodash/isEmpty\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport diff from \"deep-diff\";\n\nimport \"focus-within-polyfill\";\nimport \"focus-visible\";\n\nimport { createTheme, ThemeProvider } from \"@mui/material\";\nimport { StylesProvider } from \"@mui/styles\";\nimport { StyledEngineProvider } from \"@mui/material/styles\";\nimport { themeBuilder, createGenerateClassName, HvCssBaseline, getTheme } from \"../theme\";\n\nimport ConfigContext from \"./context\";\n\nlet warnedOnce = false;\n\n/**\n * Augments the target theme with the differences found in the source theme.\n *\n * @param {Object} InputTargetTheme - A material UI Theme to be changed.\n * @param {Object} InputSourceTheme - A material UI Theme to apply on top.\n * @returns {Object} - A new modified material UI theme.\n */\nconst applyCustomTheme = (InputTargetTheme, InputSourceTheme) => {\n const muiDefaultTheme = createTheme();\n const targetTheme = cloneDeep(InputTargetTheme);\n const sourceTheme = cloneDeep(InputSourceTheme);\n const deleteDifference = \"D\";\n if (!isEmpty(targetTheme) && !isEmpty(sourceTheme)) {\n diff.observableDiff(muiDefaultTheme, sourceTheme, (difference) => {\n const partialCustomTheme = set({}, difference.path, difference.rhs);\n if (difference.kind !== deleteDifference) {\n // Do not include the differences of type \"delete\"\n merge(targetTheme, partialCustomTheme);\n }\n });\n return targetTheme;\n }\n return targetTheme;\n};\n\n/**\n * This component makes cross-component properties, like the active `theme` and `locale`,\n * available down the React tree thanks to React context.\n *\n * This component should preferably be used at **the root of your component tree** and\n * be unique in the App in most cases.\n *\n * ```jsx\n * <HvProvider>\n * <MyApp />\n * <HvProvider/>\n * ```\n *\n * If several `HvProvider`'s are used, either nested or in parallel, the `generateClassNameOptions`\n * must be tweaked to avoid CSS classnames collision. Or a custom JSS's class name generator can\n * be provided via the `generateClassName` property.\n *\n * **UI Kit components will not work at all if the `HvProvider` is not configured correctly**,\n * as they will not be able to access the properties of the active theme..\n *\n */\nconst HvProvider = ({\n children,\n\n uiKitTheme = \"dawn\",\n theme = null,\n changeTheme = () => {},\n\n locale = \"en-US\",\n\n generateClassName: generateClassNameProp,\n generateClassNameOptions,\n injectStylesFirst = true,\n disableStylesGeneration = false,\n\n disableCssBaseline = false,\n}) => {\n if (process.env.NODE_ENV !== \"production\") {\n if (!warnedOnce && !disableCssBaseline) {\n warnedOnce = true;\n // eslint-disable-next-line no-console\n console.warn(\n \"UI Kit HvProvider's automatic definition of a css styles baseline will be removed in the next major version.\\n\" +\n \"You can use the `disableCssBaseline` property to disable it already.\\n\" +\n \"See https://lumada-design.github.io/uikit/master/?path=/docs/foundation-css-baseline--main\"\n );\n }\n }\n\n const [localeSetting, setLocaleStting] = useState(locale);\n\n useEffect(() => {\n // ssr - only runs at the rendering phase, so it won't run on the server\n setLocaleStting(locale || navigator?.language);\n }, [locale]);\n\n const rawUiKitTheme = getTheme(uiKitTheme);\n const customTheme = applyCustomTheme(themeBuilder(rawUiKitTheme), theme);\n\n const generateClassName =\n generateClassNameProp || createGenerateClassName(generateClassNameOptions);\n\n const pConfig = useMemo(\n () => ({ changeTheme, locale: localeSetting }),\n [changeTheme, localeSetting]\n );\n\n return (\n <StyledEngineProvider injectFirst={injectStylesFirst}>\n <StylesProvider\n generateClassName={generateClassName}\n disableGeneration={disableStylesGeneration}\n >\n <ThemeProvider theme={customTheme}>\n {!disableCssBaseline && <HvCssBaseline />}\n <ConfigContext.Provider value={pConfig}>{children}</ConfigContext.Provider>\n </ThemeProvider>\n </StylesProvider>\n </StyledEngineProvider>\n );\n};\n\nHvProvider.propTypes = {\n /**\n * Your component tree.\n */\n children: PropTypes.node.isRequired,\n\n /**\n * The Design System base theme in use. Defaults to `\"dawn\"`.\n */\n uiKitTheme: PropTypes.oneOf([\"dawn\", \"wicked\"]),\n /**\n * The UI Kit theme object to be applied on top of the base theme.\n */\n theme: PropTypes.instanceOf(Object),\n /**\n * Function stored in the provider's context to allow runtime switching of the active theme.\n * The implementation is up to each App.\n */\n changeTheme: PropTypes.func,\n\n /**\n * The locale to be used.\n * Defaults to the browser's configured locale or \"en-US\" if not available.\n */\n locale: PropTypes.string,\n\n /**\n * Custom JSS's class name generator.\n */\n generateClassName: PropTypes.func,\n /**\n * Built-in JSS's class name generator options.\n * Ignored if a custom `generateClassName` is provided.\n *\n * `disableGlobal`: Disable the generation of deterministic class names. Defaults to `false`.\n *\n * `productionPrefix`: The string used to prefix the class names in production. Defaults to `\"jss-uikit\"`.\n *\n * `seed`: The string used to uniquely identify the generator. Defaults to `\"\"`.\n * It can be used to avoid class name collisions when using multiple generators in the same document.\n */\n generateClassNameOptions: PropTypes.shape({\n /**\n * Disable the generation of deterministic class names. Defaults to `false`.\n */\n disableGlobal: PropTypes.bool,\n /**\n * The string used to prefix the class names in production. Defaults to `\"jss-uikit\"`.\n */\n productionPrefix: PropTypes.string,\n /**\n * The string used to uniquely identify the generator. Defaults to `\"\"`.\n * It can be used to avoid class name collisions when using multiple generators in the same document.\n */\n seed: PropTypes.string,\n }),\n /**\n * Injects the generated stylesheets at the top of the `<head>` element of the page.\n * This can ease the override of UI Kit components styles.\n *\n * By default, the styles are injected last in the `<head>` element of the page.\n */\n injectStylesFirst: PropTypes.bool,\n /**\n * Disables the generation of the styles.\n */\n disableStylesGeneration: PropTypes.bool,\n\n /**\n * Disables the generation of the baseline css styles.\n *\n * This will be the default behavior in the future.\n *\n * The application using UI Kit should be responsible for adding the baseline css styles, by\n * either using the `<HvCssBaseline />` component, using the `<HvScopedCssBaseline />` component,\n * or ensuring that the necessary base styles are applied.\n *\n * Defaults to `false`. Will be removed in the next major release.\n *\n * @see https://lumada-design.github.io/uikit/master/?path=/docs/foundation-css-baseline--main\n */\n disableCssBaseline: PropTypes.bool,\n};\n\nexport default HvProvider;\n"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,EAAqCC,OAArC,QAAoD,OAApD;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,GAAP,MAAgB,YAAhB;AACA,OAAOC,KAAP,MAAkB,cAAlB;AACA,OAAOC,OAAP,MAAoB,gBAApB;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAOC,IAAP,MAAiB,WAAjB;AAEA,OAAO,uBAAP;AACA,OAAO,eAAP;AAEA,SAASC,WAAT,EAAsBC,aAAtB,QAA2C,eAA3C;AACA,SAASC,cAAT,QAA+B,aAA/B;AACA,SAASC,oBAAT,QAAqC,sBAArC;AACA,SAASC,YAAT,EAAuBC,uBAAvB,EAAgDC,aAAhD,EAA+DC,QAA/D,QAA+E,UAA/E;AAEA,OAAOC,aAAP,MAA0B,WAA1B;;;AAEA,IAAIC,UAAU,GAAG,KAAjB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACC,gBAAD,EAAmBC,gBAAnB,EAAwC;EAC/D,IAAMC,eAAe,GAAGb,WAAW,EAAnC;EACA,IAAMc,WAAW,GAAGhB,SAAS,CAACa,gBAAD,CAA7B;EACA,IAAMI,WAAW,GAAGjB,SAAS,CAACc,gBAAD,CAA7B;EACA,IAAMI,gBAAgB,GAAG,GAAzB;;EACA,IAAI,CAACnB,OAAO,CAACiB,WAAD,CAAR,IAAyB,CAACjB,OAAO,CAACkB,WAAD,CAArC,EAAoD;IAClDhB,IAAI,CAACkB,cAAL,CAAoBJ,eAApB,EAAqCE,WAArC,EAAkD,UAACG,UAAD,EAAgB;MAChE,IAAMC,kBAAkB,GAAGxB,GAAG,CAAC,EAAD,EAAKuB,UAAU,CAACE,IAAhB,EAAsBF,UAAU,CAACG,GAAjC,CAA9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,MAxBG;;EA0BrB;AACF;AACA;EACExB,iBAAiB,EAAEpC,SAAS,CAAC2D,IA7BR;;EA8BrB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEtB,wBAAwB,EAAErC,SAAS,CAAC6D,KAAV,CAAgB;IACxC;AACJ;AACA;IACIC,aAAa,EAAE9D,SAAS,CAAC+D,IAJe;;IAKxC;AACJ;AACA;IACIC,gBAAgB,EAAEhE,SAAS,CAAC4D,MARY;;IASxC;AACJ;AACA;AACA;IACIK,IAAI,EAAEjE,SAAS,CAAC4D;EAbwB,CAAhB,CAzCL;;EAwDrB;AACF;AACA;AACA;AACA;AACA;EACEtB,iBAAiB,EAAEtC,SAAS,CAAC+D,IA9DR;;EA+DrB;AACF;AACA;EACExB,uBAAuB,EAAEvC,SAAS,CAAC+D,IAlEd;;EAoErB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEvB,kBAAkB,EAAExC,SAAS,CAAC+D;AAjFT,CAAvB;AAoFA,eAAelC,UAAf"}
|
|
1
|
+
{"version":3,"file":"Provider.js","names":["React","useState","useEffect","useMemo","PropTypes","set","merge","isEmpty","cloneDeep","diff","createTheme","ThemeProvider","StylesProvider","StyledEngineProvider","themeBuilder","createGenerateClassName","HvCssBaseline","getTheme","HvScopedCssBaseline","ConfigContext","applyCustomTheme","InputTargetTheme","InputSourceTheme","muiDefaultTheme","targetTheme","sourceTheme","deleteDifference","observableDiff","difference","partialCustomTheme","path","rhs","kind","HvProvider","children","uiKitTheme","theme","changeTheme","locale","generateClassNameProp","generateClassName","generateClassNameOptions","disableStylesGeneration","cssBaseline","localeSetting","setLocaleSetting","navigator","language","rawUiKitTheme","customTheme","pConfig","renderCssBaseline","propTypes","node","isRequired","oneOf","instanceOf","Object","func","string","shape","disableGlobal","bool","productionPrefix","seed"],"sources":["../../../src/Provider/Provider.js"],"sourcesContent":["import React, { useState, useEffect, useMemo } from \"react\";\nimport PropTypes from \"prop-types\";\n\nimport set from \"lodash/set\";\nimport merge from \"lodash/merge\";\nimport isEmpty from \"lodash/isEmpty\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport diff from \"deep-diff\";\n\nimport \"focus-within-polyfill\";\nimport \"focus-visible\";\n\nimport { createTheme, ThemeProvider } from \"@mui/material\";\nimport { StylesProvider } from \"@mui/styles\";\nimport { StyledEngineProvider } from \"@mui/material/styles\";\nimport {\n themeBuilder,\n createGenerateClassName,\n HvCssBaseline,\n getTheme,\n HvScopedCssBaseline,\n} from \"../theme\";\n\nimport ConfigContext from \"./context\";\n\n/**\n * Augments the target theme with the differences found in the source theme.\n *\n * @param {Object} InputTargetTheme - A material UI Theme to be changed.\n * @param {Object} InputSourceTheme - A material UI Theme to apply on top.\n * @returns {Object} - A new modified material UI theme.\n */\nconst applyCustomTheme = (InputTargetTheme, InputSourceTheme) => {\n const muiDefaultTheme = createTheme();\n const targetTheme = cloneDeep(InputTargetTheme);\n const sourceTheme = cloneDeep(InputSourceTheme);\n const deleteDifference = \"D\";\n if (!isEmpty(targetTheme) && !isEmpty(sourceTheme)) {\n diff.observableDiff(muiDefaultTheme, sourceTheme, (difference) => {\n const partialCustomTheme = set({}, difference.path, difference.rhs);\n if (difference.kind !== deleteDifference) {\n // Do not include the differences of type \"delete\"\n merge(targetTheme, partialCustomTheme);\n }\n });\n return targetTheme;\n }\n return targetTheme;\n};\n\n/**\n * This component makes cross-component properties, like the active `theme` and `locale`,\n * available down the React tree thanks to React context.\n *\n * This component should preferably be used at **the root of your component tree** and\n * be unique in the App in most cases.\n *\n * ```jsx\n * <HvProvider>\n * <MyApp />\n * <HvProvider/>\n * ```\n *\n * If several `HvProvider`'s are used, either nested or in parallel, the `generateClassNameOptions`\n * must be tweaked to avoid CSS classnames collision. Or a custom JSS's class name generator can\n * be provided via the `generateClassName` property.\n *\n * **UI Kit components will not work at all if the `HvProvider` is not configured correctly**,\n * as they will not be able to access the properties of the active theme..\n *\n */\nconst HvProvider = ({\n children,\n\n uiKitTheme = \"dawn\",\n theme = null,\n changeTheme = () => {},\n\n locale = \"en-US\",\n\n generateClassName: generateClassNameProp,\n generateClassNameOptions,\n disableStylesGeneration = false,\n\n cssBaseline = \"global\",\n}) => {\n const [localeSetting, setLocaleSetting] = useState(locale);\n\n useEffect(() => {\n // ssr - only runs at the rendering phase, so it won't run on the server\n setLocaleSetting(locale || navigator?.language);\n }, [locale]);\n\n const rawUiKitTheme = getTheme(uiKitTheme);\n const customTheme = applyCustomTheme(themeBuilder(rawUiKitTheme), theme);\n\n const generateClassName =\n generateClassNameProp || createGenerateClassName(generateClassNameOptions);\n\n const pConfig = useMemo(\n () => ({ changeTheme, locale: localeSetting }),\n [changeTheme, localeSetting]\n );\n\n const renderCssBaseline = () => {\n if (cssBaseline === \"global\") {\n return <HvCssBaseline />;\n }\n if (cssBaseline === \"scoped\") {\n return <HvScopedCssBaseline />;\n }\n return null;\n };\n\n return (\n <StyledEngineProvider injectFirst>\n <StylesProvider\n generateClassName={generateClassName}\n disableGeneration={disableStylesGeneration}\n >\n <ThemeProvider theme={customTheme}>\n {renderCssBaseline()}\n <ConfigContext.Provider value={pConfig}>{children}</ConfigContext.Provider>\n </ThemeProvider>\n </StylesProvider>\n </StyledEngineProvider>\n );\n};\n\nHvProvider.propTypes = {\n /**\n * Your component tree.\n */\n children: PropTypes.node.isRequired,\n\n /**\n * The Design System base theme in use. Defaults to `\"dawn\"`.\n */\n uiKitTheme: PropTypes.oneOf([\"dawn\", \"wicked\"]),\n /**\n * The UI Kit theme object to be applied on top of the base theme.\n */\n theme: PropTypes.instanceOf(Object),\n /**\n * Function stored in the provider's context to allow runtime switching of the active theme.\n * The implementation is up to each App.\n */\n changeTheme: PropTypes.func,\n\n /**\n * The locale to be used.\n * Defaults to the browser's configured locale or \"en-US\" if not available.\n */\n locale: PropTypes.string,\n\n /**\n * Custom JSS's class name generator.\n */\n generateClassName: PropTypes.func,\n /**\n * Built-in JSS's class name generator options.\n * Ignored if a custom `generateClassName` is provided.\n *\n * `disableGlobal`: Disable the generation of deterministic class names. Defaults to `false`.\n *\n * `productionPrefix`: The string used to prefix the class names in production. Defaults to `\"jss-uikit\"`.\n *\n * `seed`: The string used to uniquely identify the generator. Defaults to `\"\"`.\n * It can be used to avoid class name collisions when using multiple generators in the same document.\n */\n generateClassNameOptions: PropTypes.shape({\n /**\n * Disable the generation of deterministic class names. Defaults to `false`.\n */\n disableGlobal: PropTypes.bool,\n /**\n * The string used to prefix the class names in production. Defaults to `\"jss-uikit\"`.\n */\n productionPrefix: PropTypes.string,\n /**\n * The string used to uniquely identify the generator. Defaults to `\"\"`.\n * It can be used to avoid class name collisions when using multiple generators in the same document.\n */\n seed: PropTypes.string,\n }),\n /**\n * Disables the generation of the styles.\n */\n disableStylesGeneration: PropTypes.bool,\n /**\n * By default the baseline styles are applied globally to the application.\n * If you need to scope the CSS to avoid styling conflicts, you can set this prop to `\"scoped\"`.\n * If you are providing the baseline styles, you can set this prop to false.\n *\n * @see https://lumada-design.github.io/uikit/master/?path=/docs/theme-css-baseline--page\n */\n cssBaseline: PropTypes.oneOf([\"global\", \"scoped\", \"none\"]),\n};\n\nexport default HvProvider;\n"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,EAAqCC,OAArC,QAAoD,OAApD;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,GAAP,MAAgB,YAAhB;AACA,OAAOC,KAAP,MAAkB,cAAlB;AACA,OAAOC,OAAP,MAAoB,gBAApB;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAOC,IAAP,MAAiB,WAAjB;AAEA,OAAO,uBAAP;AACA,OAAO,eAAP;AAEA,SAASC,WAAT,EAAsBC,aAAtB,QAA2C,eAA3C;AACA,SAASC,cAAT,QAA+B,aAA/B;AACA,SAASC,oBAAT,QAAqC,sBAArC;AACA,SACEC,YADF,EAEEC,uBAFF,EAGEC,aAHF,EAIEC,QAJF,EAKEC,mBAL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| "md" | "lg";
|
|
4
|
-
export type Breakpoints = {
|
|
1
|
+
export type Spacing = "xs" | "sm" | "md" | "lg";
|
|
2
|
+
export type Breakpoint = {
|
|
5
3
|
cols?: number;
|
|
6
4
|
maxWidth?: number;
|
|
7
5
|
minWidth?: number;
|
|
8
|
-
spacing?:
|
|
6
|
+
spacing?: Spacing;
|
|
9
7
|
};
|
|
10
8
|
|
|
11
|
-
export interface SimpleGridProps
|
|
12
|
-
|
|
9
|
+
export interface SimpleGridProps {
|
|
10
|
+
children?: JSX.Element | JSX.Element[];
|
|
11
|
+
spacing?: Spacing;
|
|
13
12
|
cols?: number;
|
|
14
|
-
breakpoints?:
|
|
13
|
+
breakpoints?: Breakpoint[];
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
export default function HvSimpleGrid(props: SimpleGridProps): JSX.Element | null;
|
|
@@ -9,6 +9,10 @@ export interface HvTableBodyProps
|
|
|
9
9
|
* Defaults to `thead`.
|
|
10
10
|
*/
|
|
11
11
|
component?: React.ElementType<React.HTMLAttributes<HTMLElement>>;
|
|
12
|
+
/**
|
|
13
|
+
* Sets whether or not there should be arrow navigation between the table rows
|
|
14
|
+
*/
|
|
15
|
+
withNavigation?: boolean;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
export default function HvTableBody(props: HvTableBodyProps): JSX.Element | null;
|
|
@@ -139,8 +139,9 @@ export interface HvTheme {
|
|
|
139
139
|
type: string;
|
|
140
140
|
name: string;
|
|
141
141
|
palette: HvThemePalette;
|
|
142
|
-
|
|
142
|
+
shadows: string[];
|
|
143
143
|
spacing: HvThemeSpacing;
|
|
144
|
+
typography: HvThemeTypography;
|
|
144
145
|
viz: HvThemeVizPalette;
|
|
145
146
|
}
|
|
146
147
|
|
|
@@ -1,22 +1,14 @@
|
|
|
1
1
|
import { StandardProps } from "@mui/material";
|
|
2
|
+
import { HvTableInstance } from "../Table";
|
|
2
3
|
|
|
3
4
|
export type HvControlsClassKey = "root" | "rightSection" | "leftSection";
|
|
4
5
|
|
|
5
|
-
export interface HvControlsSortValue {
|
|
6
|
-
id: string;
|
|
7
|
-
desc: string;
|
|
8
|
-
}
|
|
9
6
|
export interface HvControlsViewConfiguration extends Record<string, unknown> {
|
|
10
7
|
id: string;
|
|
11
8
|
label: string;
|
|
12
9
|
icon: React.ReactNode;
|
|
13
10
|
}
|
|
14
11
|
|
|
15
|
-
export interface HvControlsCallbacks extends Record<string, unknown> {
|
|
16
|
-
setSortBy?: (v: HvControlsSortValue[]) => void;
|
|
17
|
-
setGlobalFilter?: (v: string) => void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
12
|
export interface HvControlsProps
|
|
21
13
|
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, HvControlsClassKey> {
|
|
22
14
|
/** Children to be rendered. */
|
|
@@ -29,7 +21,7 @@ export interface HvControlsProps
|
|
|
29
21
|
* An instance of useHvTable or useTable used to manage the data
|
|
30
22
|
* if this is not provided data sorting and search must be handled externally
|
|
31
23
|
*/
|
|
32
|
-
callbacks?:
|
|
24
|
+
callbacks?: Pick<HvTableInstance, "setSortBy" | "setGlobalFilter">;
|
|
33
25
|
/**
|
|
34
26
|
* Views configuration required for the view buttons
|
|
35
27
|
*/
|
|
@@ -52,32 +52,19 @@ export interface HvProviderProps {
|
|
|
52
52
|
* Ignored if a custom `generateClassName` is provided.
|
|
53
53
|
*/
|
|
54
54
|
generateClassNameOptions?: GenerateClassNameOptions;
|
|
55
|
-
/**
|
|
56
|
-
* Injects the generated stylesheets at the top of the `<head>` element of the page.
|
|
57
|
-
* This can ease the override of UI Kit components styles.
|
|
58
|
-
*
|
|
59
|
-
* By default, the styles are injected last in the `<head>` element of the page.
|
|
60
|
-
*/
|
|
61
|
-
injectStylesFirst?: boolean;
|
|
62
55
|
/**
|
|
63
56
|
* Disables the generation of the styles.
|
|
64
57
|
*/
|
|
65
58
|
disableStylesGeneration?: boolean;
|
|
66
59
|
|
|
67
60
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
* The application using UI Kit should be responsible for adding the baseline css styles, by
|
|
73
|
-
* either using the `<HvCssBaseline />` component, using the `<HvScopedCssBaseline />` component,
|
|
74
|
-
* or ensuring that the necessary base styles are applied.
|
|
75
|
-
*
|
|
76
|
-
* Defaults to `false`. Will be removed in the next major release.
|
|
61
|
+
* By default the baseline styles are applied globally to the application.
|
|
62
|
+
* If you need to scope the CSS to avoid styling conflicts, you can set this prop to `"scoped"`.
|
|
63
|
+
* If you are providing the baseline styles, you can set this prop to false.
|
|
77
64
|
*
|
|
78
|
-
* @see https://lumada-design.github.io/uikit/master/?path=/docs/
|
|
65
|
+
* @see https://lumada-design.github.io/uikit/master/?path=/docs/theme-css-baseline--page
|
|
79
66
|
*/
|
|
80
|
-
|
|
67
|
+
cssBaseline?: "global" | "scoped" | "none";
|
|
81
68
|
}
|
|
82
69
|
|
|
83
70
|
export default function HvProvider(props: HvProviderProps): JSX.Element | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _HvCssBaseline;
|
|
1
|
+
var _HvCssBaseline, _HvScopedCssBaseline;
|
|
2
2
|
|
|
3
3
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
4
4
|
import React, { useState, useEffect, useMemo } from "react";
|
|
@@ -13,11 +13,8 @@ import "focus-visible";
|
|
|
13
13
|
import { createTheme, ThemeProvider } from "@mui/material";
|
|
14
14
|
import { StylesProvider } from "@mui/styles";
|
|
15
15
|
import { StyledEngineProvider } from "@mui/material/styles";
|
|
16
|
-
import { themeBuilder, createGenerateClassName, HvCssBaseline, getTheme } from "../theme";
|
|
16
|
+
import { themeBuilder, createGenerateClassName, HvCssBaseline, getTheme, HvScopedCssBaseline } from "../theme";
|
|
17
17
|
import ConfigContext from "./context";
|
|
18
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
|
-
let warnedOnce = false;
|
|
21
18
|
/**
|
|
22
19
|
* Augments the target theme with the differences found in the source theme.
|
|
23
20
|
*
|
|
@@ -26,6 +23,9 @@ let warnedOnce = false;
|
|
|
26
23
|
* @returns {Object} - A new modified material UI theme.
|
|
27
24
|
*/
|
|
28
25
|
|
|
26
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
27
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
|
+
|
|
29
29
|
const applyCustomTheme = (InputTargetTheme, InputSourceTheme) => {
|
|
30
30
|
const muiDefaultTheme = createTheme();
|
|
31
31
|
const targetTheme = cloneDeep(InputTargetTheme);
|
|
@@ -77,24 +77,15 @@ const HvProvider = ({
|
|
|
77
77
|
locale = "en-US",
|
|
78
78
|
generateClassName: generateClassNameProp,
|
|
79
79
|
generateClassNameOptions,
|
|
80
|
-
injectStylesFirst = true,
|
|
81
80
|
disableStylesGeneration = false,
|
|
82
|
-
|
|
81
|
+
cssBaseline = "global"
|
|
83
82
|
}) => {
|
|
84
|
-
|
|
85
|
-
if (!warnedOnce && !disableCssBaseline) {
|
|
86
|
-
warnedOnce = true; // eslint-disable-next-line no-console
|
|
87
|
-
|
|
88
|
-
console.warn("UI Kit HvProvider's automatic definition of a css styles baseline will be removed in the next major version.\n" + "You can use the `disableCssBaseline` property to disable it already.\n" + "See https://lumada-design.github.io/uikit/master/?path=/docs/foundation-css-baseline--main");
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const [localeSetting, setLocaleStting] = useState(locale);
|
|
83
|
+
const [localeSetting, setLocaleSetting] = useState(locale);
|
|
93
84
|
useEffect(() => {
|
|
94
85
|
var _navigator;
|
|
95
86
|
|
|
96
87
|
// ssr - only runs at the rendering phase, so it won't run on the server
|
|
97
|
-
|
|
88
|
+
setLocaleSetting(locale || ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.language));
|
|
98
89
|
}, [locale]);
|
|
99
90
|
const rawUiKitTheme = getTheme(uiKitTheme);
|
|
100
91
|
const customTheme = applyCustomTheme(themeBuilder(rawUiKitTheme), theme);
|
|
@@ -103,14 +94,27 @@ const HvProvider = ({
|
|
|
103
94
|
changeTheme,
|
|
104
95
|
locale: localeSetting
|
|
105
96
|
}), [changeTheme, localeSetting]);
|
|
97
|
+
|
|
98
|
+
const renderCssBaseline = () => {
|
|
99
|
+
if (cssBaseline === "global") {
|
|
100
|
+
return _HvCssBaseline || (_HvCssBaseline = /*#__PURE__*/_jsx(HvCssBaseline, {}));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (cssBaseline === "scoped") {
|
|
104
|
+
return _HvScopedCssBaseline || (_HvScopedCssBaseline = /*#__PURE__*/_jsx(HvScopedCssBaseline, {}));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return null;
|
|
108
|
+
};
|
|
109
|
+
|
|
106
110
|
return /*#__PURE__*/_jsx(StyledEngineProvider, {
|
|
107
|
-
injectFirst:
|
|
111
|
+
injectFirst: true,
|
|
108
112
|
children: /*#__PURE__*/_jsx(StylesProvider, {
|
|
109
113
|
generateClassName: generateClassName,
|
|
110
114
|
disableGeneration: disableStylesGeneration,
|
|
111
115
|
children: /*#__PURE__*/_jsxs(ThemeProvider, {
|
|
112
116
|
theme: customTheme,
|
|
113
|
-
children: [
|
|
117
|
+
children: [renderCssBaseline(), /*#__PURE__*/_jsx(ConfigContext.Provider, {
|
|
114
118
|
value: pConfig,
|
|
115
119
|
children: children
|
|
116
120
|
})]
|
|
@@ -181,33 +185,19 @@ process.env.NODE_ENV !== "production" ? HvProvider.propTypes = {
|
|
|
181
185
|
seed: PropTypes.string
|
|
182
186
|
}),
|
|
183
187
|
|
|
184
|
-
/**
|
|
185
|
-
* Injects the generated stylesheets at the top of the `<head>` element of the page.
|
|
186
|
-
* This can ease the override of UI Kit components styles.
|
|
187
|
-
*
|
|
188
|
-
* By default, the styles are injected last in the `<head>` element of the page.
|
|
189
|
-
*/
|
|
190
|
-
injectStylesFirst: PropTypes.bool,
|
|
191
|
-
|
|
192
188
|
/**
|
|
193
189
|
* Disables the generation of the styles.
|
|
194
190
|
*/
|
|
195
191
|
disableStylesGeneration: PropTypes.bool,
|
|
196
192
|
|
|
197
193
|
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
* The application using UI Kit should be responsible for adding the baseline css styles, by
|
|
203
|
-
* either using the `<HvCssBaseline />` component, using the `<HvScopedCssBaseline />` component,
|
|
204
|
-
* or ensuring that the necessary base styles are applied.
|
|
205
|
-
*
|
|
206
|
-
* Defaults to `false`. Will be removed in the next major release.
|
|
194
|
+
* By default the baseline styles are applied globally to the application.
|
|
195
|
+
* If you need to scope the CSS to avoid styling conflicts, you can set this prop to `"scoped"`.
|
|
196
|
+
* If you are providing the baseline styles, you can set this prop to false.
|
|
207
197
|
*
|
|
208
|
-
* @see https://lumada-design.github.io/uikit/master/?path=/docs/
|
|
198
|
+
* @see https://lumada-design.github.io/uikit/master/?path=/docs/theme-css-baseline--page
|
|
209
199
|
*/
|
|
210
|
-
|
|
200
|
+
cssBaseline: PropTypes.oneOf(["global", "scoped", "none"])
|
|
211
201
|
} : void 0;
|
|
212
202
|
export default HvProvider;
|
|
213
203
|
//# sourceMappingURL=Provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","names":["React","useState","useEffect","useMemo","PropTypes","set","merge","isEmpty","cloneDeep","diff","createTheme","ThemeProvider","StylesProvider","StyledEngineProvider","themeBuilder","createGenerateClassName","HvCssBaseline","getTheme","ConfigContext","warnedOnce","applyCustomTheme","InputTargetTheme","InputSourceTheme","muiDefaultTheme","targetTheme","sourceTheme","deleteDifference","observableDiff","difference","partialCustomTheme","path","rhs","kind","HvProvider","children","uiKitTheme","theme","changeTheme","locale","generateClassName","generateClassNameProp","generateClassNameOptions","injectStylesFirst","disableStylesGeneration","disableCssBaseline","process","env","NODE_ENV","console","warn","localeSetting","setLocaleStting","navigator","language","rawUiKitTheme","customTheme","pConfig","propTypes","node","isRequired","oneOf","instanceOf","Object","func","string","shape","disableGlobal","bool","productionPrefix","seed"],"sources":["../../../src/Provider/Provider.js"],"sourcesContent":["import React, { useState, useEffect, useMemo } from \"react\";\nimport PropTypes from \"prop-types\";\n\nimport set from \"lodash/set\";\nimport merge from \"lodash/merge\";\nimport isEmpty from \"lodash/isEmpty\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport diff from \"deep-diff\";\n\nimport \"focus-within-polyfill\";\nimport \"focus-visible\";\n\nimport { createTheme, ThemeProvider } from \"@mui/material\";\nimport { StylesProvider } from \"@mui/styles\";\nimport { StyledEngineProvider } from \"@mui/material/styles\";\nimport { themeBuilder, createGenerateClassName, HvCssBaseline, getTheme } from \"../theme\";\n\nimport ConfigContext from \"./context\";\n\nlet warnedOnce = false;\n\n/**\n * Augments the target theme with the differences found in the source theme.\n *\n * @param {Object} InputTargetTheme - A material UI Theme to be changed.\n * @param {Object} InputSourceTheme - A material UI Theme to apply on top.\n * @returns {Object} - A new modified material UI theme.\n */\nconst applyCustomTheme = (InputTargetTheme, InputSourceTheme) => {\n const muiDefaultTheme = createTheme();\n const targetTheme = cloneDeep(InputTargetTheme);\n const sourceTheme = cloneDeep(InputSourceTheme);\n const deleteDifference = \"D\";\n if (!isEmpty(targetTheme) && !isEmpty(sourceTheme)) {\n diff.observableDiff(muiDefaultTheme, sourceTheme, (difference) => {\n const partialCustomTheme = set({}, difference.path, difference.rhs);\n if (difference.kind !== deleteDifference) {\n // Do not include the differences of type \"delete\"\n merge(targetTheme, partialCustomTheme);\n }\n });\n return targetTheme;\n }\n return targetTheme;\n};\n\n/**\n * This component makes cross-component properties, like the active `theme` and `locale`,\n * available down the React tree thanks to React context.\n *\n * This component should preferably be used at **the root of your component tree** and\n * be unique in the App in most cases.\n *\n * ```jsx\n * <HvProvider>\n * <MyApp />\n * <HvProvider/>\n * ```\n *\n * If several `HvProvider`'s are used, either nested or in parallel, the `generateClassNameOptions`\n * must be tweaked to avoid CSS classnames collision. Or a custom JSS's class name generator can\n * be provided via the `generateClassName` property.\n *\n * **UI Kit components will not work at all if the `HvProvider` is not configured correctly**,\n * as they will not be able to access the properties of the active theme..\n *\n */\nconst HvProvider = ({\n children,\n\n uiKitTheme = \"dawn\",\n theme = null,\n changeTheme = () => {},\n\n locale = \"en-US\",\n\n generateClassName: generateClassNameProp,\n generateClassNameOptions,\n injectStylesFirst = true,\n disableStylesGeneration = false,\n\n disableCssBaseline = false,\n}) => {\n if (process.env.NODE_ENV !== \"production\") {\n if (!warnedOnce && !disableCssBaseline) {\n warnedOnce = true;\n // eslint-disable-next-line no-console\n console.warn(\n \"UI Kit HvProvider's automatic definition of a css styles baseline will be removed in the next major version.\\n\" +\n \"You can use the `disableCssBaseline` property to disable it already.\\n\" +\n \"See https://lumada-design.github.io/uikit/master/?path=/docs/foundation-css-baseline--main\"\n );\n }\n }\n\n const [localeSetting, setLocaleStting] = useState(locale);\n\n useEffect(() => {\n // ssr - only runs at the rendering phase, so it won't run on the server\n setLocaleStting(locale || navigator?.language);\n }, [locale]);\n\n const rawUiKitTheme = getTheme(uiKitTheme);\n const customTheme = applyCustomTheme(themeBuilder(rawUiKitTheme), theme);\n\n const generateClassName =\n generateClassNameProp || createGenerateClassName(generateClassNameOptions);\n\n const pConfig = useMemo(\n () => ({ changeTheme, locale: localeSetting }),\n [changeTheme, localeSetting]\n );\n\n return (\n <StyledEngineProvider injectFirst={injectStylesFirst}>\n <StylesProvider\n generateClassName={generateClassName}\n disableGeneration={disableStylesGeneration}\n >\n <ThemeProvider theme={customTheme}>\n {!disableCssBaseline && <HvCssBaseline />}\n <ConfigContext.Provider value={pConfig}>{children}</ConfigContext.Provider>\n </ThemeProvider>\n </StylesProvider>\n </StyledEngineProvider>\n );\n};\n\nHvProvider.propTypes = {\n /**\n * Your component tree.\n */\n children: PropTypes.node.isRequired,\n\n /**\n * The Design System base theme in use. Defaults to `\"dawn\"`.\n */\n uiKitTheme: PropTypes.oneOf([\"dawn\", \"wicked\"]),\n /**\n * The UI Kit theme object to be applied on top of the base theme.\n */\n theme: PropTypes.instanceOf(Object),\n /**\n * Function stored in the provider's context to allow runtime switching of the active theme.\n * The implementation is up to each App.\n */\n changeTheme: PropTypes.func,\n\n /**\n * The locale to be used.\n * Defaults to the browser's configured locale or \"en-US\" if not available.\n */\n locale: PropTypes.string,\n\n /**\n * Custom JSS's class name generator.\n */\n generateClassName: PropTypes.func,\n /**\n * Built-in JSS's class name generator options.\n * Ignored if a custom `generateClassName` is provided.\n *\n * `disableGlobal`: Disable the generation of deterministic class names. Defaults to `false`.\n *\n * `productionPrefix`: The string used to prefix the class names in production. Defaults to `\"jss-uikit\"`.\n *\n * `seed`: The string used to uniquely identify the generator. Defaults to `\"\"`.\n * It can be used to avoid class name collisions when using multiple generators in the same document.\n */\n generateClassNameOptions: PropTypes.shape({\n /**\n * Disable the generation of deterministic class names. Defaults to `false`.\n */\n disableGlobal: PropTypes.bool,\n /**\n * The string used to prefix the class names in production. Defaults to `\"jss-uikit\"`.\n */\n productionPrefix: PropTypes.string,\n /**\n * The string used to uniquely identify the generator. Defaults to `\"\"`.\n * It can be used to avoid class name collisions when using multiple generators in the same document.\n */\n seed: PropTypes.string,\n }),\n /**\n * Injects the generated stylesheets at the top of the `<head>` element of the page.\n * This can ease the override of UI Kit components styles.\n *\n * By default, the styles are injected last in the `<head>` element of the page.\n */\n injectStylesFirst: PropTypes.bool,\n /**\n * Disables the generation of the styles.\n */\n disableStylesGeneration: PropTypes.bool,\n\n /**\n * Disables the generation of the baseline css styles.\n *\n * This will be the default behavior in the future.\n *\n * The application using UI Kit should be responsible for adding the baseline css styles, by\n * either using the `<HvCssBaseline />` component, using the `<HvScopedCssBaseline />` component,\n * or ensuring that the necessary base styles are applied.\n *\n * Defaults to `false`. Will be removed in the next major release.\n *\n * @see https://lumada-design.github.io/uikit/master/?path=/docs/foundation-css-baseline--main\n */\n disableCssBaseline: PropTypes.bool,\n};\n\nexport default HvProvider;\n"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D;EAbwB,CAAhB,CAzCL;;EAwDrB;AACF;AACA;AACA;AACA;AACA;EACEtB,iBAAiB,EAAEtC,SAAS,CAAC+D,IA9DR;;EA+DrB;AACF;AACA;EACExB,uBAAuB,EAAEvC,SAAS,CAAC+D,IAlEd;;EAoErB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEvB,kBAAkB,EAAExC,SAAS,CAAC+D;AAjFT,CAAvB;AAoFA,eAAelC,UAAf"}
|
|
1
|
+
{"version":3,"file":"Provider.js","names":["React","useState","useEffect","useMemo","PropTypes","set","merge","isEmpty","cloneDeep","diff","createTheme","ThemeProvider","StylesProvider","StyledEngineProvider","themeBuilder","createGenerateClassName","HvCssBaseline","getTheme","HvScopedCssBaseline","ConfigContext","applyCustomTheme","InputTargetTheme","InputSourceTheme","muiDefaultTheme","targetTheme","sourceTheme","deleteDifference","observableDiff","difference","partialCustomTheme","path","rhs","kind","HvProvider","children","uiKitTheme","theme","changeTheme","locale","generateClassName","generateClassNameProp","generateClassNameOptions","disableStylesGeneration","cssBaseline","localeSetting","setLocaleSetting","navigator","language","rawUiKitTheme","customTheme","pConfig","renderCssBaseline","propTypes","node","isRequired","oneOf","instanceOf","Object","func","string","shape","disableGlobal","bool","productionPrefix","seed"],"sources":["../../../src/Provider/Provider.js"],"sourcesContent":["import React, { useState, useEffect, useMemo } from \"react\";\nimport PropTypes from \"prop-types\";\n\nimport set from \"lodash/set\";\nimport merge from \"lodash/merge\";\nimport isEmpty from \"lodash/isEmpty\";\nimport cloneDeep from \"lodash/cloneDeep\";\nimport diff from \"deep-diff\";\n\nimport \"focus-within-polyfill\";\nimport \"focus-visible\";\n\nimport { createTheme, ThemeProvider } from \"@mui/material\";\nimport { StylesProvider } from \"@mui/styles\";\nimport { StyledEngineProvider } from \"@mui/material/styles\";\nimport {\n themeBuilder,\n createGenerateClassName,\n HvCssBaseline,\n getTheme,\n HvScopedCssBaseline,\n} from \"../theme\";\n\nimport ConfigContext from \"./context\";\n\n/**\n * Augments the target theme with the differences found in the source theme.\n *\n * @param {Object} InputTargetTheme - A material UI Theme to be changed.\n * @param {Object} InputSourceTheme - A material UI Theme to apply on top.\n * @returns {Object} - A new modified material UI theme.\n */\nconst applyCustomTheme = (InputTargetTheme, InputSourceTheme) => {\n const muiDefaultTheme = createTheme();\n const targetTheme = cloneDeep(InputTargetTheme);\n const sourceTheme = cloneDeep(InputSourceTheme);\n const deleteDifference = \"D\";\n if (!isEmpty(targetTheme) && !isEmpty(sourceTheme)) {\n diff.observableDiff(muiDefaultTheme, sourceTheme, (difference) => {\n const partialCustomTheme = set({}, difference.path, difference.rhs);\n if (difference.kind !== deleteDifference) {\n // Do not include the differences of type \"delete\"\n merge(targetTheme, partialCustomTheme);\n }\n });\n return targetTheme;\n }\n return targetTheme;\n};\n\n/**\n * This component makes cross-component properties, like the active `theme` and `locale`,\n * available down the React tree thanks to React context.\n *\n * This component should preferably be used at **the root of your component tree** and\n * be unique in the App in most cases.\n *\n * ```jsx\n * <HvProvider>\n * <MyApp />\n * <HvProvider/>\n * ```\n *\n * If several `HvProvider`'s are used, either nested or in parallel, the `generateClassNameOptions`\n * must be tweaked to avoid CSS classnames collision. Or a custom JSS's class name generator can\n * be provided via the `generateClassName` property.\n *\n * **UI Kit components will not work at all if the `HvProvider` is not configured correctly**,\n * as they will not be able to access the properties of the active theme..\n *\n */\nconst HvProvider = ({\n children,\n\n uiKitTheme = \"dawn\",\n theme = null,\n changeTheme = () => {},\n\n locale = \"en-US\",\n\n generateClassName: generateClassNameProp,\n generateClassNameOptions,\n disableStylesGeneration = false,\n\n cssBaseline = \"global\",\n}) => {\n const [localeSetting, setLocaleSetting] = useState(locale);\n\n useEffect(() => {\n // ssr - only runs at the rendering phase, so it won't run on the server\n setLocaleSetting(locale || navigator?.language);\n }, [locale]);\n\n const rawUiKitTheme = getTheme(uiKitTheme);\n const customTheme = applyCustomTheme(themeBuilder(rawUiKitTheme), theme);\n\n const generateClassName =\n generateClassNameProp || createGenerateClassName(generateClassNameOptions);\n\n const pConfig = useMemo(\n () => ({ changeTheme, locale: localeSetting }),\n [changeTheme, localeSetting]\n );\n\n const renderCssBaseline = () => {\n if (cssBaseline === \"global\") {\n return <HvCssBaseline />;\n }\n if (cssBaseline === \"scoped\") {\n return <HvScopedCssBaseline />;\n }\n return null;\n };\n\n return (\n <StyledEngineProvider injectFirst>\n <StylesProvider\n generateClassName={generateClassName}\n disableGeneration={disableStylesGeneration}\n >\n <ThemeProvider theme={customTheme}>\n {renderCssBaseline()}\n <ConfigContext.Provider value={pConfig}>{children}</ConfigContext.Provider>\n </ThemeProvider>\n </StylesProvider>\n </StyledEngineProvider>\n );\n};\n\nHvProvider.propTypes = {\n /**\n * Your component tree.\n */\n children: PropTypes.node.isRequired,\n\n /**\n * The Design System base theme in use. Defaults to `\"dawn\"`.\n */\n uiKitTheme: PropTypes.oneOf([\"dawn\", \"wicked\"]),\n /**\n * The UI Kit theme object to be applied on top of the base theme.\n */\n theme: PropTypes.instanceOf(Object),\n /**\n * Function stored in the provider's context to allow runtime switching of the active theme.\n * The implementation is up to each App.\n */\n changeTheme: PropTypes.func,\n\n /**\n * The locale to be used.\n * Defaults to the browser's configured locale or \"en-US\" if not available.\n */\n locale: PropTypes.string,\n\n /**\n * Custom JSS's class name generator.\n */\n generateClassName: PropTypes.func,\n /**\n * Built-in JSS's class name generator options.\n * Ignored if a custom `generateClassName` is provided.\n *\n * `disableGlobal`: Disable the generation of deterministic class names. Defaults to `false`.\n *\n * `productionPrefix`: The string used to prefix the class names in production. Defaults to `\"jss-uikit\"`.\n *\n * `seed`: The string used to uniquely identify the generator. Defaults to `\"\"`.\n * It can be used to avoid class name collisions when using multiple generators in the same document.\n */\n generateClassNameOptions: PropTypes.shape({\n /**\n * Disable the generation of deterministic class names. Defaults to `false`.\n */\n disableGlobal: PropTypes.bool,\n /**\n * The string used to prefix the class names in production. Defaults to `\"jss-uikit\"`.\n */\n productionPrefix: PropTypes.string,\n /**\n * The string used to uniquely identify the generator. Defaults to `\"\"`.\n * It can be used to avoid class name collisions when using multiple generators in the same document.\n */\n seed: PropTypes.string,\n }),\n /**\n * Disables the generation of the styles.\n */\n disableStylesGeneration: PropTypes.bool,\n /**\n * By default the baseline styles are applied globally to the application.\n * If you need to scope the CSS to avoid styling conflicts, you can set this prop to `\"scoped\"`.\n * If you are providing the baseline styles, you can set this prop to false.\n *\n * @see https://lumada-design.github.io/uikit/master/?path=/docs/theme-css-baseline--page\n */\n cssBaseline: PropTypes.oneOf([\"global\", \"scoped\", \"none\"]),\n};\n\nexport default HvProvider;\n"],"mappings":";;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,EAAqCC,OAArC,QAAoD,OAApD;AACA,OAAOC,SAAP,MAAsB,YAAtB;AAEA,OAAOC,GAAP,MAAgB,YAAhB;AACA,OAAOC,KAAP,MAAkB,cAAlB;AACA,OAAOC,OAAP,MAAoB,gBAApB;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAOC,IAAP,MAAiB,WAAjB;AAEA,OAAO,uBAAP;AACA,OAAO,eAAP;AAEA,SAASC,WAAT,EAAsBC,aAAtB,QAA2C,eAA3C;AACA,SAASC,cAAT,QAA+B,aAA/B;AACA,SAASC,oBAAT,QAAqC,sBAArC;AACA,SACEC,YADF,EAEEC,uBAFF,EAGEC,aAHF,EAIEC,QAJF,EAKEC,mBALF,QAMO,UANP;AAQA,OAAOC,aAAP,MAA0B,WAA1B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACA,MAAMC,gBAAgB,GAAG,CAACC,gBAAD,EAAmBC,gBAAnB,KAAwC;EAC/D,MAAMC,eAAe,GAAGb,WAAW,EAAnC;EACA,MAAMc,WAAW,GAAGhB,SAAS,CAACa,gBAAD,CAA7B;EACA,MAAMI,WAAW,GAAGjB,SAAS,CAACc,gBAAD,CAA7B;EACA,MAAMI,gBAAgB,GAAG,GAAzB;;EACA,IAAI,CAACnB,OAAO,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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEjB,wBAAwB,EAAErC,SAAS,CAACwD,KAAV,CAAgB;IACxC;AACJ;AACA;IACIC,aAAa,EAAEzD,SAAS,CAAC0D,IAJe;;IAKxC;AACJ;AACA;IACIC,gBAAgB,EAAE3D,SAAS,CAACuD,MARY;;IASxC;AACJ;AACA;AACA;IACIK,IAAI,EAAE5D,SAAS,CAACuD;EAbwB,CAAhB,CAzCL;;EAwDrB;AACF;AACA;EACEjB,uBAAuB,EAAEtC,SAAS,CAAC0D,IA3Dd;;EA4DrB;AACF;AACA;AACA;AACA;AACA;AACA;EACEnB,WAAW,EAAEvC,SAAS,CAACmD,KAAV,CAAgB,CAAC,QAAD,EAAW,QAAX,EAAqB,MAArB,CAAhB;AAnEQ,CAAvB;AAsEA,eAAetB,UAAf"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export type GridSpacing = "xs" | "sm" | "md" | "lg";
|
|
4
|
-
export type Breakpoints = {
|
|
1
|
+
export type Spacing = "xs" | "sm" | "md" | "lg";
|
|
2
|
+
export type Breakpoint = {
|
|
5
3
|
cols?: number;
|
|
6
4
|
maxWidth?: number;
|
|
7
5
|
minWidth?: number;
|
|
8
|
-
spacing?:
|
|
6
|
+
spacing?: Spacing;
|
|
9
7
|
};
|
|
10
8
|
|
|
11
|
-
export interface SimpleGridProps
|
|
12
|
-
|
|
9
|
+
export interface SimpleGridProps {
|
|
10
|
+
children?: JSX.Element | JSX.Element[];
|
|
11
|
+
spacing?: Spacing;
|
|
13
12
|
cols?: number;
|
|
14
|
-
breakpoints?:
|
|
13
|
+
breakpoints?: Breakpoint[];
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
export default function HvSimpleGrid(props: SimpleGridProps): JSX.Element | null;
|
|
@@ -9,6 +9,10 @@ export interface HvTableBodyProps
|
|
|
9
9
|
* Defaults to `thead`.
|
|
10
10
|
*/
|
|
11
11
|
component?: React.ElementType<React.HTMLAttributes<HTMLElement>>;
|
|
12
|
+
/**
|
|
13
|
+
* Sets whether or not there should be arrow navigation between the table rows
|
|
14
|
+
*/
|
|
15
|
+
withNavigation?: boolean;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
export default function HvTableBody(props: HvTableBodyProps): JSX.Element | null;
|
|
@@ -139,8 +139,9 @@ export interface HvTheme {
|
|
|
139
139
|
type: string;
|
|
140
140
|
name: string;
|
|
141
141
|
palette: HvThemePalette;
|
|
142
|
-
|
|
142
|
+
shadows: string[];
|
|
143
143
|
spacing: HvThemeSpacing;
|
|
144
|
+
typography: HvThemeTypography;
|
|
144
145
|
viz: HvThemeVizPalette;
|
|
145
146
|
}
|
|
146
147
|
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -139,8 +139,9 @@ export interface HvTheme {
|
|
|
139
139
|
type: string;
|
|
140
140
|
name: string;
|
|
141
141
|
palette: HvThemePalette;
|
|
142
|
-
|
|
142
|
+
shadows: string[];
|
|
143
143
|
spacing: HvThemeSpacing;
|
|
144
|
+
typography: HvThemeTypography;
|
|
144
145
|
viz: HvThemeVizPalette;
|
|
145
146
|
}
|
|
146
147
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/uikit-react-core",
|
|
3
|
-
"version": "4.0.1-next.
|
|
3
|
+
"version": "4.0.1-next.5",
|
|
4
4
|
"description": "A collection of React components for the Hitachi Vantara's Design System.",
|
|
5
5
|
"homepage": "https://github.com/lumada-design/hv-uikit-react",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"access": "public"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "fe888b15f863a60ee54f0ba4084568a3a44feed2"
|
|
87
87
|
}
|