@hitachivantara/uikit-react-core 3.63.0 → 3.66.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/AssetInventory/ListView/ListView.js +1 -1
- package/dist/AssetInventory/ListView/ListView.js.map +1 -1
- package/dist/Chart/Plot/Plot.d.ts +3 -3
- package/dist/SimpleGrid/SimpleGrid.d.ts +17 -0
- package/dist/SimpleGrid/SimpleGrid.js +73 -0
- package/dist/SimpleGrid/SimpleGrid.js.map +1 -0
- package/dist/SimpleGrid/index.d.ts +2 -0
- package/dist/SimpleGrid/index.js +16 -0
- package/dist/SimpleGrid/index.js.map +1 -0
- package/dist/SimpleGrid/styles.js +99 -0
- package/dist/SimpleGrid/styles.js.map +1 -0
- package/dist/Stack/Stack.d.ts +46 -0
- package/dist/Stack/Stack.js +195 -0
- package/dist/Stack/Stack.js.map +1 -0
- package/dist/Stack/index.d.ts +2 -0
- package/dist/Stack/index.js +16 -0
- package/dist/Stack/index.js.map +1 -0
- package/dist/Stack/styles.js +39 -0
- package/dist/Stack/styles.js.map +1 -0
- package/dist/TimePicker/PeriodPicker/PeriodPicker.js +112 -0
- package/dist/TimePicker/PeriodPicker/PeriodPicker.js.map +1 -0
- package/dist/TimePicker/PeriodPicker/index.js +21 -0
- package/dist/TimePicker/PeriodPicker/index.js.map +1 -0
- package/dist/TimePicker/PeriodPicker/styles.js +32 -0
- package/dist/TimePicker/PeriodPicker/styles.js.map +1 -0
- package/dist/TimePicker/TimePicker.d.ts +140 -0
- package/dist/TimePicker/TimePicker.js +748 -0
- package/dist/TimePicker/TimePicker.js.map +1 -0
- package/dist/TimePicker/UnitTimePicker/UnitTimePicker.js +243 -0
- package/dist/TimePicker/UnitTimePicker/UnitTimePicker.js.map +1 -0
- package/dist/TimePicker/UnitTimePicker/index.js +21 -0
- package/dist/TimePicker/UnitTimePicker/index.js.map +1 -0
- package/dist/TimePicker/UnitTimePicker/styles.js +75 -0
- package/dist/TimePicker/UnitTimePicker/styles.js.map +1 -0
- package/dist/TimePicker/enums.js +43 -0
- package/dist/TimePicker/enums.js.map +1 -0
- package/dist/TimePicker/index.d.ts +2 -0
- package/dist/TimePicker/index.js +16 -0
- package/dist/TimePicker/index.js.map +1 -0
- package/dist/TimePicker/styles.js +134 -0
- package/dist/TimePicker/styles.js.map +1 -0
- package/dist/TimePicker/timePickerConverter.js +90 -0
- package/dist/TimePicker/timePickerConverter.js.map +1 -0
- package/dist/TimePicker/timePickerFormatter.js +81 -0
- package/dist/TimePicker/timePickerFormatter.js.map +1 -0
- package/dist/TimePicker/timePickerUtils.js +36 -0
- package/dist/TimePicker/timePickerUtils.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/legacy/AssetInventory/ListView/ListView.js +1 -1
- package/dist/legacy/AssetInventory/ListView/ListView.js.map +1 -1
- package/dist/legacy/Chart/Plot/Plot.d.ts +3 -3
- package/dist/legacy/SimpleGrid/SimpleGrid.d.ts +17 -0
- package/dist/legacy/SimpleGrid/SimpleGrid.js +59 -0
- package/dist/legacy/SimpleGrid/SimpleGrid.js.map +1 -0
- package/dist/legacy/SimpleGrid/index.d.ts +2 -0
- package/dist/legacy/SimpleGrid/index.js +2 -0
- package/dist/legacy/SimpleGrid/index.js.map +1 -0
- package/dist/legacy/SimpleGrid/styles.js +81 -0
- package/dist/legacy/SimpleGrid/styles.js.map +1 -0
- package/dist/legacy/Stack/Stack.d.ts +46 -0
- package/dist/legacy/Stack/Stack.js +156 -0
- package/dist/legacy/Stack/Stack.js.map +1 -0
- package/dist/legacy/Stack/index.d.ts +2 -0
- package/dist/legacy/Stack/index.js +2 -0
- package/dist/legacy/Stack/index.js.map +1 -0
- package/dist/legacy/Stack/styles.js +31 -0
- package/dist/legacy/Stack/styles.js.map +1 -0
- package/dist/legacy/TimePicker/PeriodPicker/PeriodPicker.js +78 -0
- package/dist/legacy/TimePicker/PeriodPicker/PeriodPicker.js.map +1 -0
- package/dist/legacy/TimePicker/PeriodPicker/index.js +7 -0
- package/dist/legacy/TimePicker/PeriodPicker/index.js.map +1 -0
- package/dist/legacy/TimePicker/PeriodPicker/styles.js +24 -0
- package/dist/legacy/TimePicker/PeriodPicker/styles.js.map +1 -0
- package/dist/legacy/TimePicker/TimePicker.d.ts +140 -0
- package/dist/legacy/TimePicker/TimePicker.js +696 -0
- package/dist/legacy/TimePicker/TimePicker.js.map +1 -0
- package/dist/legacy/TimePicker/UnitTimePicker/UnitTimePicker.js +206 -0
- package/dist/legacy/TimePicker/UnitTimePicker/UnitTimePicker.js.map +1 -0
- package/dist/legacy/TimePicker/UnitTimePicker/index.js +7 -0
- package/dist/legacy/TimePicker/UnitTimePicker/index.js.map +1 -0
- package/dist/legacy/TimePicker/UnitTimePicker/styles.js +58 -0
- package/dist/legacy/TimePicker/UnitTimePicker/styles.js.map +1 -0
- package/dist/legacy/TimePicker/enums.js +33 -0
- package/dist/legacy/TimePicker/enums.js.map +1 -0
- package/dist/legacy/TimePicker/index.d.ts +2 -0
- package/dist/legacy/TimePicker/index.js +2 -0
- package/dist/legacy/TimePicker/index.js.map +1 -0
- package/dist/legacy/TimePicker/styles.js +117 -0
- package/dist/legacy/TimePicker/styles.js.map +1 -0
- package/dist/legacy/TimePicker/timePickerConverter.js +71 -0
- package/dist/legacy/TimePicker/timePickerConverter.js.map +1 -0
- package/dist/legacy/TimePicker/timePickerFormatter.js +66 -0
- package/dist/legacy/TimePicker/timePickerFormatter.js.map +1 -0
- package/dist/legacy/TimePicker/timePickerUtils.js +27 -0
- package/dist/legacy/TimePicker/timePickerUtils.js.map +1 -0
- package/dist/legacy/index.d.ts +3 -0
- package/dist/legacy/index.js +1 -0
- package/dist/legacy/index.js.map +1 -1
- package/dist/modern/AssetInventory/AssetInventory.js +1 -0
- package/dist/modern/AssetInventory/AssetInventory.js.map +1 -1
- package/dist/modern/AssetInventory/ListView/ListView.js +2 -1
- package/dist/modern/AssetInventory/ListView/ListView.js.map +1 -1
- package/dist/modern/AssetInventory/Search/Search.js +1 -0
- package/dist/modern/AssetInventory/Search/Search.js.map +1 -1
- package/dist/modern/BaseDropdown/BaseDropdown.js +1 -0
- package/dist/modern/BaseDropdown/BaseDropdown.js.map +1 -1
- package/dist/modern/BreadCrumb/utils.js +1 -0
- package/dist/modern/BreadCrumb/utils.js.map +1 -1
- package/dist/modern/Chart/Plot/Plot.d.ts +3 -3
- package/dist/modern/FilterGroup/RightPanel/RightPanel.js +1 -0
- package/dist/modern/FilterGroup/RightPanel/RightPanel.js.map +1 -1
- package/dist/modern/Focus/Focus.js +1 -0
- package/dist/modern/Focus/Focus.js.map +1 -1
- package/dist/modern/List/List.js +5 -2
- package/dist/modern/List/List.js.map +1 -1
- package/dist/modern/SimpleGrid/SimpleGrid.d.ts +17 -0
- package/dist/modern/SimpleGrid/SimpleGrid.js +60 -0
- package/dist/modern/SimpleGrid/SimpleGrid.js.map +1 -0
- package/dist/modern/SimpleGrid/index.d.ts +2 -0
- package/dist/modern/SimpleGrid/index.js +2 -0
- package/dist/modern/SimpleGrid/index.js.map +1 -0
- package/dist/modern/SimpleGrid/styles.js +68 -0
- package/dist/modern/SimpleGrid/styles.js.map +1 -0
- package/dist/modern/Stack/Stack.d.ts +46 -0
- package/dist/modern/Stack/Stack.js +145 -0
- package/dist/modern/Stack/Stack.js.map +1 -0
- package/dist/modern/Stack/index.d.ts +2 -0
- package/dist/modern/Stack/index.js +2 -0
- package/dist/modern/Stack/index.js.map +1 -0
- package/dist/modern/Stack/styles.js +29 -0
- package/dist/modern/Stack/styles.js.map +1 -0
- package/dist/modern/Table/Table.js +1 -0
- package/dist/modern/Table/Table.js.map +1 -1
- package/dist/modern/Table/checkBoxUtils.js +1 -0
- package/dist/modern/Table/checkBoxUtils.js.map +1 -1
- package/dist/modern/TagsInput/TagsInput.js +1 -0
- package/dist/modern/TagsInput/TagsInput.js.map +1 -1
- package/dist/modern/TimePicker/PeriodPicker/PeriodPicker.js +75 -0
- package/dist/modern/TimePicker/PeriodPicker/PeriodPicker.js.map +1 -0
- package/dist/modern/TimePicker/PeriodPicker/index.js +7 -0
- package/dist/modern/TimePicker/PeriodPicker/index.js.map +1 -0
- package/dist/modern/TimePicker/PeriodPicker/styles.js +22 -0
- package/dist/modern/TimePicker/PeriodPicker/styles.js.map +1 -0
- package/dist/modern/TimePicker/TimePicker.d.ts +140 -0
- package/dist/modern/TimePicker/TimePicker.js +659 -0
- package/dist/modern/TimePicker/TimePicker.js.map +1 -0
- package/dist/modern/TimePicker/UnitTimePicker/UnitTimePicker.js +191 -0
- package/dist/modern/TimePicker/UnitTimePicker/UnitTimePicker.js.map +1 -0
- package/dist/modern/TimePicker/UnitTimePicker/index.js +7 -0
- package/dist/modern/TimePicker/UnitTimePicker/index.js.map +1 -0
- package/dist/modern/TimePicker/UnitTimePicker/styles.js +49 -0
- package/dist/modern/TimePicker/UnitTimePicker/styles.js.map +1 -0
- package/dist/modern/TimePicker/enums.js +32 -0
- package/dist/modern/TimePicker/enums.js.map +1 -0
- package/dist/modern/TimePicker/index.d.ts +2 -0
- package/dist/modern/TimePicker/index.js +2 -0
- package/dist/modern/TimePicker/index.js.map +1 -0
- package/dist/modern/TimePicker/styles.js +108 -0
- package/dist/modern/TimePicker/styles.js.map +1 -0
- package/dist/modern/TimePicker/timePickerConverter.js +66 -0
- package/dist/modern/TimePicker/timePickerConverter.js.map +1 -0
- package/dist/modern/TimePicker/timePickerFormatter.js +65 -0
- package/dist/modern/TimePicker/timePickerFormatter.js.map +1 -0
- package/dist/modern/TimePicker/timePickerUtils.js +26 -0
- package/dist/modern/TimePicker/timePickerUtils.js.map +1 -0
- package/dist/modern/index.d.ts +3 -0
- package/dist/modern/index.js +1 -0
- package/dist/modern/index.js.map +1 -1
- package/package.json +19 -20
- package/CHANGELOG.md +0 -4480
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FunctionComponent } from "react";
|
|
2
|
+
|
|
3
|
+
export type Spacing = "xs" | "sm" | "md" | "lg";
|
|
4
|
+
export type Breakpoints = {
|
|
5
|
+
cols?: number;
|
|
6
|
+
maxWidth?: number;
|
|
7
|
+
minWidth?: number;
|
|
8
|
+
spacing?: Spacing;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export interface SimpleGridProps extends FunctionComponent {
|
|
12
|
+
spacing?: Spacing;
|
|
13
|
+
cols?: number;
|
|
14
|
+
breakpoints?: Breakpoints;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default function HvSimpleGrid(props: SimpleGridProps): JSX.Element | null;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
const _excluded = ["children", "breakpoints", "spacing", "cols"];
|
|
4
|
+
import React from "react";
|
|
5
|
+
import PropTypes from "prop-types";
|
|
6
|
+
import useStyles from "./styles";
|
|
7
|
+
|
|
8
|
+
const SimpleGrid = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
children,
|
|
11
|
+
breakpoints,
|
|
12
|
+
spacing = "sm",
|
|
13
|
+
cols
|
|
14
|
+
} = _ref,
|
|
15
|
+
others = _objectWithoutProperties(_ref, _excluded);
|
|
16
|
+
|
|
17
|
+
const classes = useStyles({
|
|
18
|
+
breakpoints,
|
|
19
|
+
cols,
|
|
20
|
+
spacing
|
|
21
|
+
})();
|
|
22
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
23
|
+
className: classes.container
|
|
24
|
+
}, others), children);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
process.env.NODE_ENV !== "production" ? SimpleGrid.propTypes = {
|
|
28
|
+
/**
|
|
29
|
+
* -
|
|
30
|
+
*/
|
|
31
|
+
children: PropTypes.node,
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Spacing with pre-defined values according the values defined in the theme
|
|
35
|
+
*/
|
|
36
|
+
spacing: PropTypes.oneOf(["sm", "md", "lg", "xl"]),
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Provide an array to define responsive behavior:
|
|
40
|
+
*
|
|
41
|
+
* maxWidth or minWidth: max-width or min-width at which media query will work
|
|
42
|
+
*
|
|
43
|
+
* cols: number of columns per row at given max-width
|
|
44
|
+
*
|
|
45
|
+
* spacing: optional spacing at given max-width, if not provided spacing from component prop will be used instead
|
|
46
|
+
*/
|
|
47
|
+
breakpoints: PropTypes.arrayOf(PropTypes.shape({
|
|
48
|
+
maxWidth: PropTypes.number,
|
|
49
|
+
minWidth: PropTypes.number,
|
|
50
|
+
cols: PropTypes.number,
|
|
51
|
+
spacing: PropTypes.oneOf(["sm", "md", "lg", "xl"])
|
|
52
|
+
})),
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Number of how many columns the content will be displayed
|
|
56
|
+
*/
|
|
57
|
+
cols: PropTypes.number
|
|
58
|
+
} : void 0;
|
|
59
|
+
export default SimpleGrid;
|
|
60
|
+
//# sourceMappingURL=SimpleGrid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/SimpleGrid/SimpleGrid.js"],"names":["React","PropTypes","useStyles","SimpleGrid","children","breakpoints","spacing","cols","others","classes","container","propTypes","node","oneOf","arrayOf","shape","maxWidth","number","minWidth"],"mappings":";;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,SAAP,MAAsB,UAAtB;;AAEA,MAAMC,UAAU,GAAG,QAAgE;AAAA,MAA/D;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,WAAZ;AAAyBC,IAAAA,OAAO,GAAG,IAAnC;AAAyCC,IAAAA;AAAzC,GAA+D;AAAA,MAAbC,MAAa;;AACjF,QAAMC,OAAO,GAAGP,SAAS,CAAC;AAAEG,IAAAA,WAAF;AAAeE,IAAAA,IAAf;AAAqBD,IAAAA;AAArB,GAAD,CAAT,EAAhB;AACA,sBACE;AAAK,IAAA,SAAS,EAAEG,OAAO,CAACC;AAAxB,KAAuCF,MAAvC,GACGJ,QADH,CADF;AAKD,CAPD;;AASA,wCAAAD,UAAU,CAACQ,SAAX,GAAuB;AACrB;AACF;AACA;AACEP,EAAAA,QAAQ,EAAEH,SAAS,CAACW,IAJC;;AAKrB;AACF;AACA;AACEN,EAAAA,OAAO,EAAEL,SAAS,CAACY,KAAV,CAAgB,CAAC,IAAD,EAAO,IAAP,EAAa,IAAb,EAAmB,IAAnB,CAAhB,CARY;;AASrB;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACER,EAAAA,WAAW,EAAEJ,SAAS,CAACa,OAAV,CACXb,SAAS,CAACc,KAAV,CAAgB;AACdC,IAAAA,QAAQ,EAAEf,SAAS,CAACgB,MADN;AAEdC,IAAAA,QAAQ,EAAEjB,SAAS,CAACgB,MAFN;AAGdV,IAAAA,IAAI,EAAEN,SAAS,CAACgB,MAHF;AAIdX,IAAAA,OAAO,EAAEL,SAAS,CAACY,KAAV,CAAgB,CAAC,IAAD,EAAO,IAAP,EAAa,IAAb,EAAmB,IAAnB,CAAhB;AAJK,GAAhB,CADW,CAlBQ;;AA0BrB;AACF;AACA;AACEN,EAAAA,IAAI,EAAEN,SAAS,CAACgB;AA7BK,CAAvB;AAgCA,eAAed,UAAf","sourcesContent":["import React from \"react\";\nimport PropTypes from \"prop-types\";\nimport useStyles from \"./styles\";\n\nconst SimpleGrid = ({ children, breakpoints, spacing = \"sm\", cols, ...others }) => {\n const classes = useStyles({ breakpoints, cols, spacing })();\n return (\n <div className={classes.container} {...others}>\n {children}\n </div>\n );\n};\n\nSimpleGrid.propTypes = {\n /**\n * -\n */\n children: PropTypes.node,\n /**\n * Spacing with pre-defined values according the values defined in the theme\n */\n spacing: PropTypes.oneOf([\"sm\", \"md\", \"lg\", \"xl\"]),\n /**\n * Provide an array to define responsive behavior:\n *\n * maxWidth or minWidth: max-width or min-width at which media query will work\n *\n * cols: number of columns per row at given max-width\n *\n * spacing: optional spacing at given max-width, if not provided spacing from component prop will be used instead\n */\n breakpoints: PropTypes.arrayOf(\n PropTypes.shape({\n maxWidth: PropTypes.number,\n minWidth: PropTypes.number,\n cols: PropTypes.number,\n spacing: PropTypes.oneOf([\"sm\", \"md\", \"lg\", \"xl\"]),\n })\n ),\n /**\n * Number of how many columns the content will be displayed\n */\n cols: PropTypes.number,\n};\n\nexport default SimpleGrid;\n"],"file":"SimpleGrid.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/SimpleGrid/index.js"],"names":["default"],"mappings":"AAAA,SAASA,OAAT,QAAwB,cAAxB","sourcesContent":["export { default } from \"./SimpleGrid\";\n"],"file":"index.js"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
+
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
|
|
7
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
8
|
+
import { makeStyles } from "@material-ui/core";
|
|
9
|
+
|
|
10
|
+
function size(props) {
|
|
11
|
+
if (typeof props.size === "number") {
|
|
12
|
+
return props.size;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return props.sizes[props.size] || props.size || props.sizes.md;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function getSortedBreakpoints(theme, breakpoints) {
|
|
19
|
+
if (breakpoints.length === 0) {
|
|
20
|
+
return breakpoints;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const property = "maxWidth" in breakpoints[0] ? "maxWidth" : "minWidth";
|
|
24
|
+
const sorted = [...breakpoints].sort((a, b) => size({
|
|
25
|
+
size: b[property],
|
|
26
|
+
sizes: theme.breakpoints
|
|
27
|
+
}) - size({
|
|
28
|
+
size: a[property],
|
|
29
|
+
sizes: theme.breakpoints
|
|
30
|
+
}));
|
|
31
|
+
return property === "minWidth" ? sorted.reverse() : sorted;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const styles = props => makeStyles(theme => {
|
|
35
|
+
const {
|
|
36
|
+
breakpoints,
|
|
37
|
+
spacing,
|
|
38
|
+
cols
|
|
39
|
+
} = props;
|
|
40
|
+
let gridBreakpoints = null;
|
|
41
|
+
|
|
42
|
+
if (breakpoints) {
|
|
43
|
+
gridBreakpoints = getSortedBreakpoints(theme, breakpoints).reduce((acc, breakpoint) => {
|
|
44
|
+
const property = "maxWidth" in breakpoint ? "max-width" : "min-width";
|
|
45
|
+
const breakpointSize = size({
|
|
46
|
+
size: property === "max-width" ? breakpoint.maxWidth : breakpoint.minWidth,
|
|
47
|
+
sizes: theme.breakpoints
|
|
48
|
+
});
|
|
49
|
+
acc[`@media (${property}: ${breakpointSize + (property === "max-width" ? 0 : 1)}px)`] = {
|
|
50
|
+
gridTemplateColumns: `repeat(${breakpoint.cols}, minmax(0, 1fr))`,
|
|
51
|
+
gap: theme.hv.spacing[spacing]
|
|
52
|
+
};
|
|
53
|
+
return acc;
|
|
54
|
+
}, {});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
container: _objectSpread({
|
|
59
|
+
boxSizing: "border-box",
|
|
60
|
+
display: "grid",
|
|
61
|
+
gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))`,
|
|
62
|
+
gap: theme.hv.spacing[spacing]
|
|
63
|
+
}, gridBreakpoints)
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
export default styles;
|
|
68
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/SimpleGrid/styles.js"],"names":["makeStyles","size","props","sizes","md","getSortedBreakpoints","theme","breakpoints","length","property","sorted","sort","a","b","reverse","styles","spacing","cols","gridBreakpoints","reduce","acc","breakpoint","breakpointSize","maxWidth","minWidth","gridTemplateColumns","gap","hv","container","boxSizing","display"],"mappings":";;;;;;;AAAA,SAASA,UAAT,QAA2B,mBAA3B;;AAEA,SAASC,IAAT,CAAcC,KAAd,EAAqB;AACnB,MAAI,OAAOA,KAAK,CAACD,IAAb,KAAsB,QAA1B,EAAoC;AAClC,WAAOC,KAAK,CAACD,IAAb;AACD;;AAED,SAAOC,KAAK,CAACC,KAAN,CAAYD,KAAK,CAACD,IAAlB,KAA2BC,KAAK,CAACD,IAAjC,IAAyCC,KAAK,CAACC,KAAN,CAAYC,EAA5D;AACD;;AAED,SAASC,oBAAT,CAA8BC,KAA9B,EAAqCC,WAArC,EAAkD;AAChD,MAAIA,WAAW,CAACC,MAAZ,KAAuB,CAA3B,EAA8B;AAC5B,WAAOD,WAAP;AACD;;AAED,QAAME,QAAQ,GAAG,cAAcF,WAAW,CAAC,CAAD,CAAzB,GAA+B,UAA/B,GAA4C,UAA7D;AACA,QAAMG,MAAM,GAAG,CAAC,GAAGH,WAAJ,EAAiBI,IAAjB,CACb,CAACC,CAAD,EAAIC,CAAJ,KACEZ,IAAI,CAAC;AAAEA,IAAAA,IAAI,EAAEY,CAAC,CAACJ,QAAD,CAAT;AAAqBN,IAAAA,KAAK,EAAEG,KAAK,CAACC;AAAlC,GAAD,CAAJ,GACAN,IAAI,CAAC;AAAEA,IAAAA,IAAI,EA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FF;AAGPL,MAAAA,mBAAmB,EAAG,UAASR,IAAK,mBAH7B;AAIPS,MAAAA,GAAG,EAAEpB,KAAK,CAACqB,EAAN,CAASX,OAAT,CAAiBA,OAAjB;AAJE,OAKJE,eALI;AADJ,GAAP;AASD,CA7BS,CADZ;;AAgCA,eAAeH,MAAf","sourcesContent":["import { makeStyles } from \"@material-ui/core\";\n\nfunction size(props) {\n if (typeof props.size === \"number\") {\n return props.size;\n }\n\n return props.sizes[props.size] || props.size || props.sizes.md;\n}\n\nfunction getSortedBreakpoints(theme, breakpoints) {\n if (breakpoints.length === 0) {\n return breakpoints;\n }\n\n const property = \"maxWidth\" in breakpoints[0] ? \"maxWidth\" : \"minWidth\";\n const sorted = [...breakpoints].sort(\n (a, b) =>\n size({ size: b[property], sizes: theme.breakpoints }) -\n size({ size: a[property], sizes: theme.breakpoints })\n );\n\n return property === \"minWidth\" ? sorted.reverse() : sorted;\n}\n\nconst styles = (props) =>\n makeStyles((theme) => {\n const { breakpoints, spacing, cols } = props;\n let gridBreakpoints = null;\n if (breakpoints) {\n gridBreakpoints = getSortedBreakpoints(theme, breakpoints).reduce((acc, breakpoint) => {\n const property = \"maxWidth\" in breakpoint ? \"max-width\" : \"min-width\";\n const breakpointSize = size({\n size: property === \"max-width\" ? breakpoint.maxWidth : breakpoint.minWidth,\n sizes: theme.breakpoints,\n });\n\n acc[`@media (${property}: ${breakpointSize + (property === \"max-width\" ? 0 : 1)}px)`] = {\n gridTemplateColumns: `repeat(${breakpoint.cols}, minmax(0, 1fr))`,\n gap: theme.hv.spacing[spacing],\n };\n\n return acc;\n }, {});\n }\n\n return {\n container: {\n boxSizing: \"border-box\",\n display: \"grid\",\n gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))`,\n gap: theme.hv.spacing[spacing],\n ...gridBreakpoints,\n },\n };\n });\n\nexport default styles;\n"],"file":"styles.js"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { StandardProps, DividerProps } from "@material-ui/core";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { HvThemeSpacing } from "../theme";
|
|
4
|
+
|
|
5
|
+
export type HvStackClassKey = "root";
|
|
6
|
+
|
|
7
|
+
export type StackDirection = {
|
|
8
|
+
xs: string;
|
|
9
|
+
sm: string;
|
|
10
|
+
md: string;
|
|
11
|
+
lg: string;
|
|
12
|
+
xl: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export interface HvStackProps
|
|
16
|
+
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, HvStackClassKey> {
|
|
17
|
+
/**
|
|
18
|
+
* Children of the stack component.
|
|
19
|
+
*/
|
|
20
|
+
children: React.ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* The direction of the stack.
|
|
23
|
+
* Can be either a string or an object that states the direction for each breakpoint.
|
|
24
|
+
*/
|
|
25
|
+
direction?: string | StackDirection;
|
|
26
|
+
/**
|
|
27
|
+
* Indicates that the form element is disabled.
|
|
28
|
+
*/
|
|
29
|
+
spacing?: HvThemeSpacing;
|
|
30
|
+
/**
|
|
31
|
+
* The divider component to be used between the stack elements.
|
|
32
|
+
* - If `true` the Material-UI Divider component will be used.
|
|
33
|
+
* - If a React node is passed then the custom divider will be used.
|
|
34
|
+
*/
|
|
35
|
+
divider?: boolean | React.ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* The properties to pass on to the Material-UI component.
|
|
38
|
+
*/
|
|
39
|
+
dividerProps: DividerProps;
|
|
40
|
+
/**
|
|
41
|
+
* Sets whether or not there should be arrow navigation between the stack elements
|
|
42
|
+
*/
|
|
43
|
+
withNavigation: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default function HvStack(props: HvStackProps): JSX.Element | null;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
const _excluded = ["classes", "children", "direction", "spacing", "divider", "withNavigation", "dividerProps"];
|
|
4
|
+
import "core-js/modules/web.dom-collections.iterator.js";
|
|
5
|
+
import React, { useMemo, useCallback, useRef } from "react";
|
|
6
|
+
import PropTypes from "prop-types";
|
|
7
|
+
import clsx from "clsx";
|
|
8
|
+
import { withStyles, Divider, useTheme } from "@material-ui/core";
|
|
9
|
+
import isString from "lodash/isString";
|
|
10
|
+
import isBoolean from "lodash/isBoolean";
|
|
11
|
+
import styles from "./styles";
|
|
12
|
+
import useWidth from "../utils/useWidth";
|
|
13
|
+
import Focus from "../Focus";
|
|
14
|
+
/**
|
|
15
|
+
* @returns {string} - Returns a direction for the stack: column or row. If the
|
|
16
|
+
* `direction` property is a string and a valid direction then we
|
|
17
|
+
* use it. If it's an object with multiple directions by breakpoint
|
|
18
|
+
* we use the appropriate one or search for the nearest breakpoint
|
|
19
|
+
* smaller than the current one to use.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const getDirection = (direction, width, breakpoints) => {
|
|
23
|
+
if (isString(direction)) return direction;
|
|
24
|
+
|
|
25
|
+
for (let i = breakpoints.indexOf(width); i >= 0; i -= 1) {
|
|
26
|
+
if (direction[breakpoints[i]] !== undefined) {
|
|
27
|
+
return direction[breakpoints[i]];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return "column";
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* A Stack component allows the organization of its children in a vertical or horizontal layout.
|
|
35
|
+
*
|
|
36
|
+
* It also allows the specification of the spacing between the stack elements and the adition of a divider between the elements.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const HvStack = props => {
|
|
41
|
+
const {
|
|
42
|
+
classes,
|
|
43
|
+
children,
|
|
44
|
+
direction = "column",
|
|
45
|
+
spacing = "sm",
|
|
46
|
+
divider = false,
|
|
47
|
+
withNavigation = false,
|
|
48
|
+
dividerProps = {}
|
|
49
|
+
} = props,
|
|
50
|
+
others = _objectWithoutProperties(props, _excluded);
|
|
51
|
+
|
|
52
|
+
const width = useWidth();
|
|
53
|
+
const theme = useTheme();
|
|
54
|
+
const containerRef = useRef(null);
|
|
55
|
+
const breakpoints = useMemo(() => [...theme.breakpoints.keys], [theme]);
|
|
56
|
+
const processedDirection = useMemo(() => getDirection(direction, width, breakpoints), [direction, width, breakpoints]);
|
|
57
|
+
/**
|
|
58
|
+
* @returns {node} - The divider component to use. If the property `divider` is
|
|
59
|
+
* set to `true` then the Material-UI divider is used, otherwise
|
|
60
|
+
* we use the custom divider the user passed.
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
const getDividerComponent = useCallback(() => {
|
|
64
|
+
if (isBoolean(divider) && divider) {
|
|
65
|
+
return /*#__PURE__*/React.createElement(Divider, _extends({
|
|
66
|
+
orientation: processedDirection === "column" ? "horizontal" : "vertical",
|
|
67
|
+
flexItem: processedDirection === "row",
|
|
68
|
+
role: "separator"
|
|
69
|
+
}, dividerProps));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return divider;
|
|
73
|
+
}, [divider, dividerProps, processedDirection]);
|
|
74
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
75
|
+
ref: containerRef,
|
|
76
|
+
className: clsx(classes.root, classes[processedDirection], classes[spacing])
|
|
77
|
+
}, others), React.Children.map(children, (child, i) => {
|
|
78
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, divider && i !== 0 && getDividerComponent(divider, processedDirection), withNavigation ? /*#__PURE__*/React.createElement(Focus, {
|
|
79
|
+
rootRef: containerRef,
|
|
80
|
+
focusDisabled: false,
|
|
81
|
+
strategy: "grid",
|
|
82
|
+
navigationJump: processedDirection === "column" ? 1 : children.length,
|
|
83
|
+
filterClass: "child"
|
|
84
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
85
|
+
className: "child"
|
|
86
|
+
}, child)) : child);
|
|
87
|
+
}));
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
process.env.NODE_ENV !== "production" ? HvStack.propTypes = {
|
|
91
|
+
/**
|
|
92
|
+
* A Jss Object used to override or extend the styles applied to the radio button.
|
|
93
|
+
*/
|
|
94
|
+
classes: PropTypes.shape({
|
|
95
|
+
/**
|
|
96
|
+
* Styles applied to the component.
|
|
97
|
+
*/
|
|
98
|
+
root: PropTypes.string
|
|
99
|
+
}).isRequired,
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Children of the stack component.
|
|
103
|
+
*/
|
|
104
|
+
children: PropTypes.node,
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The direction of the stack.
|
|
108
|
+
* Can be either a string or an object that states the direction for each breakpoint.
|
|
109
|
+
*/
|
|
110
|
+
direction: PropTypes.oneOfType([PropTypes.oneOf(["column", "row"]), PropTypes.shape({
|
|
111
|
+
xs: PropTypes.string,
|
|
112
|
+
sm: PropTypes.string,
|
|
113
|
+
md: PropTypes.string,
|
|
114
|
+
lg: PropTypes.string,
|
|
115
|
+
xl: PropTypes.string
|
|
116
|
+
})]),
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The spacing between elements of the stack.
|
|
120
|
+
*/
|
|
121
|
+
spacing: PropTypes.oneOf(["xs", "sm", "md", "lg", "xl"]),
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The divider component to be used between the stack elements.
|
|
125
|
+
*
|
|
126
|
+
* - If `true` the Material-UI Divider component will be used.
|
|
127
|
+
*
|
|
128
|
+
* - If a React node is passed then the custom divider will be used.
|
|
129
|
+
*/
|
|
130
|
+
divider: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* The properties to pass on to the Material-UI component.
|
|
134
|
+
*/
|
|
135
|
+
dividerProps: PropTypes.object,
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Sets whether or not there should be arrow navigation between the stack elements
|
|
139
|
+
*/
|
|
140
|
+
withNavigation: PropTypes.bool
|
|
141
|
+
} : void 0;
|
|
142
|
+
export default withStyles(styles, {
|
|
143
|
+
name: "HvStack"
|
|
144
|
+
})(HvStack);
|
|
145
|
+
//# sourceMappingURL=Stack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/Stack/Stack.js"],"names":["React","useMemo","useCallback","useRef","PropTypes","clsx","withStyles","Divider","useTheme","isString","isBoolean","styles","useWidth","Focus","getDirection","direction","width","breakpoints","i","indexOf","undefined","HvStack","props","classes","children","spacing","divider","withNavigation","dividerProps","others","theme","containerRef","keys","processedDirection","getDividerComponent","root","Children","map","child","length","propTypes","shape","string","isRequired","node","oneOfType","oneOf","xs","sm","md","lg","xl","bool","object","name"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAgBC,OAAhB,EAAyBC,WAAzB,EAAsCC,MAAtC,QAAoD,OAApD;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,IAAP,MAAiB,MAAjB;AACA,SAASC,UAAT,EAAqBC,OAArB,EAA8BC,QAA9B,QAA8C,mBAA9C;AACA,OAAOC,QAAP,MAAqB,iBAArB;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AACA,OAAOC,QAAP,MAAqB,mBAArB;AACA,OAAOC,KAAP,MAAkB,UAAlB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,YAAY,GAAG,CAACC,SAAD,EAAYC,KAAZ,EAAmBC,WAAnB,KAAmC;AACtD,MAAIR,QAAQ,CAACM,SAAD,CAAZ,EAAyB,OAAOA,SAAP;;AAEzB,OAAK,IAAIG,CAAC,GAAGD,WAAW,CAACE,OAAZ,CAAoBH,KAApB,CAAb,EAAyCE,CAAC,IAAI,CAA9C,EAAiDA,CAAC,IAAI,CAAtD,EAAyD;AACvD,QAAIH,SAAS,CAACE,WAAW,CAACC,CAAD,CAAZ,CAAT,KAA8BE,SAAlC,EAA6C;AAC3C,aAAOL,SAAS,CAACE,WAAW,CAAC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AA,EAAE,EAAE3C,SAAS,CAACsC,MADA;AAEdM,IAAAA,EAAE,EAAE5C,SAAS,CAACsC,MAFA;AAGdO,IAAAA,EAAE,EAAE7C,SAAS,CAACsC,MAHA;AAIdQ,IAAAA,EAAE,EAAE9C,SAAS,CAACsC,MAJA;AAKdS,IAAAA,EAAE,EAAE/C,SAAS,CAACsC;AALA,GAAhB,CAF6B,CAApB,CAlBO;;AA4BlB;AACF;AACA;AACEjB,EAAAA,OAAO,EAAErB,SAAS,CAAC0C,KAAV,CAAgB,CAAC,IAAD,EAAO,IAAP,EAAa,IAAb,EAAmB,IAAnB,EAAyB,IAAzB,CAAhB,CA/BS;;AAgClB;AACF;AACA;AACA;AACA;AACA;AACA;AACEpB,EAAAA,OAAO,EAAEtB,SAAS,CAACyC,SAAV,CAAoB,CAACzC,SAAS,CAACgD,IAAX,EAAiBhD,SAAS,CAACwC,IAA3B,CAApB,CAvCS;;AAwClB;AACF;AACA;AACEhB,EAAAA,YAAY,EAAExB,SAAS,CAACiD,MA3CN;;AA4ClB;AACF;AACA;AACE1B,EAAAA,cAAc,EAAEvB,SAAS,CAACgD;AA/CR,CAApB;AAkDA,eAAe9C,UAAU,CAACK,MAAD,EAAS;AAAE2C,EAAAA,IAAI,EAAE;AAAR,CAAT,CAAV,CAAwCjC,OAAxC,CAAf","sourcesContent":["import React, { useMemo, useCallback, useRef } from \"react\";\nimport PropTypes from \"prop-types\";\nimport clsx from \"clsx\";\nimport { withStyles, Divider, useTheme } from \"@material-ui/core\";\nimport isString from \"lodash/isString\";\nimport isBoolean from \"lodash/isBoolean\";\nimport styles from \"./styles\";\nimport useWidth from \"../utils/useWidth\";\nimport Focus from \"../Focus\";\n\n/**\n * @returns {string} - Returns a direction for the stack: column or row. If the\n * `direction` property is a string and a valid direction then we\n * use it. If it's an object with multiple directions by breakpoint\n * we use the appropriate one or search for the nearest breakpoint\n * smaller than the current one to use.\n */\nconst getDirection = (direction, width, breakpoints) => {\n if (isString(direction)) return direction;\n\n for (let i = breakpoints.indexOf(width); i >= 0; i -= 1) {\n if (direction[breakpoints[i]] !== undefined) {\n return direction[breakpoints[i]];\n }\n }\n return \"column\";\n};\n\n/**\n * A Stack component allows the organization of its children in a vertical or horizontal layout.\n *\n * It also allows the specification of the spacing between the stack elements and the adition of a divider between the elements.\n */\nconst HvStack = (props) => {\n const {\n classes,\n children,\n direction = \"column\",\n spacing = \"sm\",\n divider = false,\n withNavigation = false,\n dividerProps = {},\n ...others\n } = props;\n const width = useWidth();\n const theme = useTheme();\n const containerRef = useRef(null);\n\n const breakpoints = useMemo(() => [...theme.breakpoints.keys], [theme]);\n\n const processedDirection = useMemo(\n () => getDirection(direction, width, breakpoints),\n [direction, width, breakpoints]\n );\n\n /**\n * @returns {node} - The divider component to use. If the property `divider` is\n * set to `true` then the Material-UI divider is used, otherwise\n * we use the custom divider the user passed.\n */\n const getDividerComponent = useCallback(() => {\n if (isBoolean(divider) && divider) {\n return (\n <Divider\n orientation={processedDirection === \"column\" ? \"horizontal\" : \"vertical\"}\n flexItem={processedDirection === \"row\"}\n role=\"separator\"\n {...dividerProps}\n />\n );\n }\n return divider;\n }, [divider, dividerProps, processedDirection]);\n\n return (\n <div\n ref={containerRef}\n className={clsx(classes.root, classes[processedDirection], classes[spacing])}\n {...others}\n >\n {React.Children.map(children, (child, i) => {\n return (\n <>\n {divider && i !== 0 && getDividerComponent(divider, processedDirection)}\n {withNavigation ? (\n <Focus\n rootRef={containerRef}\n focusDisabled={false}\n strategy=\"grid\"\n navigationJump={processedDirection === \"column\" ? 1 : children.length}\n filterClass=\"child\"\n >\n <div className=\"child\">{child}</div>\n </Focus>\n ) : (\n child\n )}\n </>\n );\n })}\n </div>\n );\n};\n\nHvStack.propTypes = {\n /**\n * A Jss Object used to override or extend the styles applied to the radio button.\n */\n classes: PropTypes.shape({\n /**\n * Styles applied to the component.\n */\n root: PropTypes.string,\n }).isRequired,\n /**\n * Children of the stack component.\n */\n children: PropTypes.node,\n /**\n * The direction of the stack.\n * Can be either a string or an object that states the direction for each breakpoint.\n */\n direction: PropTypes.oneOfType([\n PropTypes.oneOf([\"column\", \"row\"]),\n PropTypes.shape({\n xs: PropTypes.string,\n sm: PropTypes.string,\n md: PropTypes.string,\n lg: PropTypes.string,\n xl: PropTypes.string,\n }),\n ]),\n /**\n * The spacing between elements of the stack.\n */\n spacing: PropTypes.oneOf([\"xs\", \"sm\", \"md\", \"lg\", \"xl\"]),\n /**\n * The divider component to be used between the stack elements.\n *\n * - If `true` the Material-UI Divider component will be used.\n *\n * - If a React node is passed then the custom divider will be used.\n */\n divider: PropTypes.oneOfType([PropTypes.bool, PropTypes.node]),\n /**\n * The properties to pass on to the Material-UI component.\n */\n dividerProps: PropTypes.object,\n /**\n * Sets whether or not there should be arrow navigation between the stack elements\n */\n withNavigation: PropTypes.bool,\n};\n\nexport default withStyles(styles, { name: \"HvStack\" })(HvStack);\n"],"file":"Stack.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/Stack/index.js"],"names":["default"],"mappings":"AAAA,SAASA,OAAT,QAAwB,SAAxB","sourcesContent":["export { default } from \"./Stack\";\n"],"file":"index.js"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const styles = theme => ({
|
|
2
|
+
root: {
|
|
3
|
+
display: "flex"
|
|
4
|
+
},
|
|
5
|
+
column: {
|
|
6
|
+
flexDirection: "column"
|
|
7
|
+
},
|
|
8
|
+
row: {
|
|
9
|
+
flexDirection: "row"
|
|
10
|
+
},
|
|
11
|
+
xs: {
|
|
12
|
+
gap: theme.hvSpacing("xs")
|
|
13
|
+
},
|
|
14
|
+
sm: {
|
|
15
|
+
gap: theme.hvSpacing("sm")
|
|
16
|
+
},
|
|
17
|
+
md: {
|
|
18
|
+
gap: theme.hvSpacing("md")
|
|
19
|
+
},
|
|
20
|
+
lg: {
|
|
21
|
+
gap: theme.hvSpacing("lg")
|
|
22
|
+
},
|
|
23
|
+
xl: {
|
|
24
|
+
gap: theme.hvSpacing("xl")
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export default styles;
|
|
29
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/Stack/styles.js"],"names":["styles","theme","root","display","column","flexDirection","row","xs","gap","hvSpacing","sm","md","lg","xl"],"mappings":"AAAA,MAAMA,MAAM,GAAIC,KAAD,KAAY;AACzBC,EAAAA,IAAI,EAAE;AACJC,IAAAA,OAAO,EAAE;AADL,GADmB;AAIzBC,EAAAA,MAAM,EAAE;AACNC,IAAAA,aAAa,EAAE;AADT,GAJiB;AAOzBC,EAAAA,GAAG,EAAE;AACHD,IAAAA,aAAa,EAAE;AADZ,GAPoB;AAUzBE,EAAAA,EAAE,EAAE;AACFC,IAAAA,GAAG,EAAEP,KAAK,CAACQ,SAAN,CAAgB,IAAhB;AADH,GAVqB;AAazBC,EAAAA,EAAE,EAAE;AACFF,IAAAA,GAAG,EAAEP,KAAK,CAACQ,SAAN,CAAgB,IAAhB;AADH,GAbqB;AAgBzBE,EAAAA,EAAE,EAAE;AACFH,IAAAA,GAAG,EAAEP,KAAK,CAACQ,SAAN,CAAgB,IAAhB;AADH,GAhBqB;AAmBzBG,EAAAA,EAAE,EAAE;AACFJ,IAAAA,GAAG,EAAEP,KAAK,CAACQ,SAAN,CAAgB,IAAhB;AADH,GAnBqB;AAsBzBI,EAAAA,EAAE,EAAE;AACFL,IAAAA,GAAG,EAAEP,KAAK,CAACQ,SAAN,CAAgB,IAAhB;AADH;AAtBqB,CAAZ,CAAf;;AA2BA,eAAeT,MAAf","sourcesContent":["const styles = (theme) => ({\n root: {\n display: \"flex\",\n },\n column: {\n flexDirection: \"column\",\n },\n row: {\n flexDirection: \"row\",\n },\n xs: {\n gap: theme.hvSpacing(\"xs\"),\n },\n sm: {\n gap: theme.hvSpacing(\"sm\"),\n },\n md: {\n gap: theme.hvSpacing(\"md\"),\n },\n lg: {\n gap: theme.hvSpacing(\"lg\"),\n },\n xl: {\n gap: theme.hvSpacing(\"xl\"),\n },\n});\n\nexport default styles;\n"],"file":"styles.js"}
|
|
@@ -8,6 +8,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
8
8
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
9
|
|
|
10
10
|
import "core-js/modules/web.dom-collections.iterator.js";
|
|
11
|
+
import "core-js/modules/es.array.includes.js";
|
|
11
12
|
import clsx from "clsx";
|
|
12
13
|
import isNil from "lodash/isNil";
|
|
13
14
|
import PropTypes from "prop-types";
|