@muraldevkit/ui-toolkit 4.81.0 → 4.83.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/cjs/components/grid/MrlCol/MrlCol.js +61 -55
- package/dist/cjs/components/grid/MrlCol/MrlCol.js.map +1 -1
- package/dist/cjs/components/grid/MrlGrid/MrlGrid.js +8 -5
- package/dist/cjs/components/grid/MrlGrid/MrlGrid.js.map +1 -1
- package/dist/cjs/components/grid/MrlRow/MrlRow.js +10 -8
- package/dist/cjs/components/grid/MrlRow/MrlRow.js.map +1 -1
- package/dist/cjs/components/grid/constants.js +47 -9
- package/dist/cjs/components/grid/constants.js.map +1 -1
- package/dist/cjs/components/multi-filter/MrlMultiFilter/MrlMultiFilter.js +232 -0
- package/dist/cjs/components/multi-filter/MrlMultiFilter/MrlMultiFilter.js.map +1 -0
- package/dist/cjs/components/multi-filter/MrlMultiFilter/MrlMultiFilter.module.scss.js +8 -0
- package/dist/cjs/components/multi-filter/MrlMultiFilter/MrlMultiFilter.module.scss.js.map +1 -0
- package/dist/cjs/components/multi-filter/MrlMultiFilterContext/MrlMultiFilterContext.js +302 -0
- package/dist/cjs/components/multi-filter/MrlMultiFilterContext/MrlMultiFilterContext.js.map +1 -0
- package/dist/cjs/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.js +122 -0
- package/dist/cjs/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.js.map +1 -0
- package/dist/cjs/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.module.scss.js +8 -0
- package/dist/cjs/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.module.scss.js.map +1 -0
- package/dist/cjs/components/multi-filter/MrlMultiFilterTrigger/MrlMultiFilterTrigger.js +83 -0
- package/dist/cjs/components/multi-filter/MrlMultiFilterTrigger/MrlMultiFilterTrigger.js.map +1 -0
- package/dist/cjs/components/multi-filter/utils.js +30 -0
- package/dist/cjs/components/multi-filter/utils.js.map +1 -0
- package/dist/cjs/components/popover/MrlPopover/MrlPopover.js +16 -5
- package/dist/cjs/components/popover/MrlPopover/MrlPopover.js.map +1 -1
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/components/grid/MrlCol/MrlCol.js +62 -56
- package/dist/esm/components/grid/MrlCol/MrlCol.js.map +1 -1
- package/dist/esm/components/grid/MrlGrid/MrlGrid.js +8 -5
- package/dist/esm/components/grid/MrlGrid/MrlGrid.js.map +1 -1
- package/dist/esm/components/grid/MrlRow/MrlRow.js +10 -8
- package/dist/esm/components/grid/MrlRow/MrlRow.js.map +1 -1
- package/dist/esm/components/grid/constants.js +46 -9
- package/dist/esm/components/grid/constants.js.map +1 -1
- package/dist/esm/components/multi-filter/MrlMultiFilter/MrlMultiFilter.js +207 -0
- package/dist/esm/components/multi-filter/MrlMultiFilter/MrlMultiFilter.js.map +1 -0
- package/dist/esm/components/multi-filter/MrlMultiFilter/MrlMultiFilter.module.scss.js +4 -0
- package/dist/esm/components/multi-filter/MrlMultiFilter/MrlMultiFilter.module.scss.js.map +1 -0
- package/dist/esm/components/multi-filter/MrlMultiFilterContext/MrlMultiFilterContext.js +276 -0
- package/dist/esm/components/multi-filter/MrlMultiFilterContext/MrlMultiFilterContext.js.map +1 -0
- package/dist/esm/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.js +97 -0
- package/dist/esm/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.js.map +1 -0
- package/dist/esm/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.module.scss.js +4 -0
- package/dist/esm/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.module.scss.js.map +1 -0
- package/dist/esm/components/multi-filter/MrlMultiFilterTrigger/MrlMultiFilterTrigger.js +58 -0
- package/dist/esm/components/multi-filter/MrlMultiFilterTrigger/MrlMultiFilterTrigger.js.map +1 -0
- package/dist/esm/components/multi-filter/utils.js +28 -0
- package/dist/esm/components/multi-filter/utils.js.map +1 -0
- package/dist/esm/components/popover/MrlPopover/MrlPopover.js +16 -5
- package/dist/esm/components/popover/MrlPopover/MrlPopover.js.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/dist/styles/MrlMultiFilter/module.scss +30 -0
- package/dist/styles/MrlMultiFilterField/module.scss +7 -0
- package/dist/styles/MrlSidebar/module.scss +2 -2
- package/dist/styles/grid/global.scss +97 -2
- package/dist/styles.css +3 -7
- package/dist/types/components/grid/MrlCol/MrlCol.d.ts +4 -6
- package/dist/types/components/grid/MrlCol/index.d.ts +1 -1
- package/dist/types/components/grid/MrlGrid/MrlGrid.d.ts +9 -4
- package/dist/types/components/grid/MrlGrid/index.d.ts +1 -1
- package/dist/types/components/grid/MrlRow/MrlRow.d.ts +7 -7
- package/dist/types/components/grid/MrlRow/index.d.ts +1 -1
- package/dist/types/components/grid/constants.d.ts +56 -13
- package/dist/types/components/grid/index.d.ts +1 -1
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/multi-filter/MrlMultiFilter/MrlMultiFilter.d.ts +166 -0
- package/dist/types/components/multi-filter/MrlMultiFilter/index.d.ts +1 -0
- package/dist/types/components/multi-filter/MrlMultiFilterContext/MrlMultiFilterContext.d.ts +141 -0
- package/dist/types/components/multi-filter/MrlMultiFilterContext/index.d.ts +1 -0
- package/dist/types/components/multi-filter/MrlMultiFilterField/MrlMultiFilterField.d.ts +121 -0
- package/dist/types/components/multi-filter/MrlMultiFilterField/index.d.ts +1 -0
- package/dist/types/components/multi-filter/MrlMultiFilterTrigger/MrlMultiFilterTrigger.d.ts +52 -0
- package/dist/types/components/multi-filter/MrlMultiFilterTrigger/index.d.ts +1 -0
- package/dist/types/components/multi-filter/index.d.ts +4 -0
- package/dist/types/components/multi-filter/utils.d.ts +8 -0
- package/dist/types/components/popover/MrlPopover/MrlPopover.d.ts +7 -1
- package/package.json +1 -1
- package/dist/styles/grid/variables.scss +0 -26
|
@@ -28,39 +28,58 @@ function _interopNamespace(e) {
|
|
|
28
28
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
29
29
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
30
30
|
|
|
31
|
-
var _excluded = ["children", "className"];
|
|
32
|
-
|
|
31
|
+
var _excluded = ["children", "className", "col", "lg", "md", "sm", "xl", "xs", "xxl"];
|
|
32
|
+
/**
|
|
33
|
+
* Builds a single grid class. The base tier (`col`) and the deprecated `xs`
|
|
34
|
+
* alias are un-prefixed; every other breakpoint carries its infix.
|
|
35
|
+
* @param size - breakpoint key
|
|
36
|
+
* @param type - `col` or `offset`
|
|
37
|
+
* @param val - column count, or `auto`
|
|
38
|
+
* @returns the grid class name
|
|
39
|
+
*/
|
|
40
|
+
var getGridClass = (size, type, val) => size === 'col' || size === 'xs' ? "".concat(type, "-").concat(val) : "".concat(type, "-").concat(size, "-").concat(val);
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
* There is no `col-0` class, so a zero span produces nothing. `ColSpan` already
|
|
44
|
+
* rules it out, but this is a published component and JavaScript consumers are
|
|
45
|
+
* not held to that — hence a runtime check rather than a type-level one.
|
|
46
|
+
*/
|
|
47
|
+
var isZeroSpan = val => val === 0;
|
|
33
48
|
|
|
34
49
|
/**
|
|
35
50
|
* Creates the size classes for the grid.
|
|
51
|
+
*
|
|
52
|
+
* `offset: 0` is kept, because `offset-<size>-0` is how a breakpoint cancels an
|
|
53
|
+
* offset set on a smaller one. `col: 0` is dropped, because there is no
|
|
54
|
+
* `col-0` class — a column always spans at least one track.
|
|
36
55
|
* @param props - component props
|
|
37
|
-
* @returns an array of size classes
|
|
56
|
+
* @returns an array of size classes
|
|
38
57
|
*/
|
|
39
58
|
var createSizeClasses = props => {
|
|
40
59
|
var classes = [];
|
|
41
|
-
for (var size of constants.
|
|
60
|
+
for (var size of constants.GRID_SIZE_KEYS) {
|
|
42
61
|
// get the value based on the prop key from the component props
|
|
43
62
|
var value = props[size];
|
|
44
63
|
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
64
|
+
// `null` is not a valid value either, but an untyped caller can still pass
|
|
65
|
+
// it, and `Object.entries(null)` below would throw.
|
|
66
|
+
if (value === undefined || value === null) continue;
|
|
67
|
+
|
|
68
|
+
// if the value is a number or `auto`, then it is a column size
|
|
69
|
+
if (typeof value === 'number' || typeof value === 'string') {
|
|
70
|
+
if (!isZeroSpan(value)) classes.push(getGridClass(size, 'col', value));
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
52
73
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
}
|
|
74
|
+
// if the value is an object, then we need to compose multiple classes
|
|
75
|
+
// based on the keyvalue pairings
|
|
76
|
+
for (var _ref3 of Object.entries(value)) {
|
|
77
|
+
var _ref2 = _rollupPluginBabelHelpers.slicedToArray(_ref3, 2);
|
|
78
|
+
var key = _ref2[0];
|
|
79
|
+
var val = _ref2[1];
|
|
80
|
+
if (val === undefined) continue;
|
|
81
|
+
if (key === 'col' && isZeroSpan(val)) continue;
|
|
82
|
+
classes.push(getGridClass(size, key, val));
|
|
64
83
|
}
|
|
65
84
|
}
|
|
66
85
|
if (classes.length === 0) classes.push('col');
|
|
@@ -68,44 +87,31 @@ var createSizeClasses = props => {
|
|
|
68
87
|
};
|
|
69
88
|
|
|
70
89
|
/**
|
|
71
|
-
*
|
|
72
|
-
* @param props
|
|
73
|
-
* @returns
|
|
90
|
+
* MrlCol React component. Creates a grid column.
|
|
91
|
+
* @param props - component props
|
|
92
|
+
* @returns a MrlCol React component.
|
|
74
93
|
*/
|
|
75
|
-
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
94
|
+
function MrlCol(_ref4) {
|
|
95
|
+
var children = _ref4.children,
|
|
96
|
+
className = _ref4.className,
|
|
97
|
+
col = _ref4.col,
|
|
98
|
+
lg = _ref4.lg,
|
|
99
|
+
md = _ref4.md,
|
|
100
|
+
sm = _ref4.sm,
|
|
101
|
+
xl = _ref4.xl,
|
|
102
|
+
xs = _ref4.xs,
|
|
103
|
+
xxl = _ref4.xxl,
|
|
104
|
+
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref4, _excluded);
|
|
105
|
+
var columnClasses = createSizeClasses({
|
|
86
106
|
col,
|
|
87
|
-
xs,
|
|
88
|
-
sm,
|
|
89
|
-
md,
|
|
90
107
|
lg,
|
|
108
|
+
md,
|
|
109
|
+
sm,
|
|
91
110
|
xl,
|
|
111
|
+
xs,
|
|
92
112
|
xxl
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* MrlCol React component.
|
|
98
|
-
* @param props - component props
|
|
99
|
-
* @returns a MrlCol React component.
|
|
100
|
-
*/
|
|
101
|
-
function MrlCol(props) {
|
|
102
|
-
var children = props.children,
|
|
103
|
-
_props$className = props.className,
|
|
104
|
-
className = _props$className === void 0 ? '' : _props$className,
|
|
105
|
-
rest = _rollupPluginBabelHelpers.objectWithoutProperties(props, _excluded);
|
|
106
|
-
var gridProps = getGridProps(props);
|
|
107
|
-
var columnClasses = React__namespace.useMemo(() => createSizeClasses(gridProps), [gridProps]);
|
|
108
|
-
var allClasses = classnames__default.default(className, columnClasses);
|
|
113
|
+
});
|
|
114
|
+
var allClasses = classnames__default.default('MrlCol', className, columnClasses);
|
|
109
115
|
return /*#__PURE__*/React__namespace.createElement("div", _rollupPluginBabelHelpers.extends({}, rest, {
|
|
110
116
|
className: allClasses
|
|
111
117
|
}), children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlCol.js","sources":["../../../../../src/components/grid/MrlCol/MrlCol.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {
|
|
1
|
+
{"version":3,"file":"MrlCol.js","sources":["../../../../../src/components/grid/MrlCol/MrlCol.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { GRID_SIZE_KEYS, GridBaseProps, GridColumns } from '../constants';\n\nexport type MrlColProps = GridColumns & GridBaseProps;\n\n/**\n * Builds a single grid class. The base tier (`col`) and the deprecated `xs`\n * alias are un-prefixed; every other breakpoint carries its infix.\n * @param size - breakpoint key\n * @param type - `col` or `offset`\n * @param val - column count, or `auto`\n * @returns the grid class name\n */\nconst getGridClass = (size: string, type: string, val: number | string): string =>\n\tsize === 'col' || size === 'xs' ? `${type}-${val}` : `${type}-${size}-${val}`;\n\n/*\n * There is no `col-0` class, so a zero span produces nothing. `ColSpan` already\n * rules it out, but this is a published component and JavaScript consumers are\n * not held to that — hence a runtime check rather than a type-level one.\n */\nconst isZeroSpan = (val: unknown): boolean => val === 0;\n\n/**\n * Creates the size classes for the grid.\n *\n * `offset: 0` is kept, because `offset-<size>-0` is how a breakpoint cancels an\n * offset set on a smaller one. `col: 0` is dropped, because there is no\n * `col-0` class — a column always spans at least one track.\n * @param props - component props\n * @returns an array of size classes\n */\nconst createSizeClasses = (props: GridColumns): string[] => {\n\tconst classes: string[] = [];\n\n\tfor (const size of GRID_SIZE_KEYS) {\n\t\t// get the value based on the prop key from the component props\n\t\tconst value = props[size];\n\n\t\t// `null` is not a valid value either, but an untyped caller can still pass\n\t\t// it, and `Object.entries(null)` below would throw.\n\t\tif (value === undefined || value === null) continue;\n\n\t\t// if the value is a number or `auto`, then it is a column size\n\t\tif (typeof value === 'number' || typeof value === 'string') {\n\t\t\tif (!isZeroSpan(value)) classes.push(getGridClass(size, 'col', value));\n\t\t\tcontinue;\n\t\t}\n\n\t\t// if the value is an object, then we need to compose multiple classes\n\t\t// based on the keyvalue pairings\n\t\tfor (const [key, val] of Object.entries(value)) {\n\t\t\tif (val === undefined) continue;\n\t\t\tif (key === 'col' && isZeroSpan(val)) continue;\n\t\t\tclasses.push(getGridClass(size, key, val));\n\t\t}\n\t}\n\n\tif (classes.length === 0) classes.push('col');\n\n\treturn classes;\n};\n\n/**\n * MrlCol React component. Creates a grid column.\n * @param props - component props\n * @returns a MrlCol React component.\n */\nexport function MrlCol({\n\tchildren,\n\tclassName,\n\tcol,\n\tlg,\n\tmd,\n\tsm,\n\txl,\n\txs,\n\txxl,\n\t...rest\n}: MrlColProps): JSX.Element {\n\tconst columnClasses = createSizeClasses({ col, lg, md, sm, xl, xs, xxl });\n\tconst allClasses = classnames('MrlCol', className, columnClasses);\n\n\treturn (\n\t\t<div {...rest} className={allClasses}>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n"],"names":["getGridClass","size","type","val","concat","isZeroSpan","createSizeClasses","props","classes","GRID_SIZE_KEYS","value","undefined","push","_ref3","Object","entries","_ref2","_slicedToArray","key","length","MrlCol","_ref4","children","className","col","lg","md","sm","xl","xs","xxl","rest","_objectWithoutProperties","_excluded","columnClasses","allClasses","classnames","React","createElement","_extends"],"mappings":"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"}
|
|
@@ -28,18 +28,21 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
|
28
28
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
29
29
|
|
|
30
30
|
var _excluded = ["children", "className"];
|
|
31
|
-
|
|
32
31
|
/**
|
|
33
|
-
* MrlGrid React component.
|
|
32
|
+
* MrlGrid React component. Primary container of a 12-column grid built from
|
|
33
|
+
* MrlRow and MrlCol.
|
|
34
|
+
*
|
|
35
|
+
* Breakpoints come from the foundation tokens: sm 600px, md 834px, lg 1024px,
|
|
36
|
+
* xl 1280px and xxl 1440px. The gutter defaults to `--mrl-spacing-07` and can
|
|
37
|
+
* be overridden by setting `--mrl-grid-gutter` on any ancestor.
|
|
34
38
|
* @param props - component props
|
|
35
39
|
* @returns a MrlGrid React component.
|
|
36
40
|
*/
|
|
37
41
|
function MrlGrid(_ref) {
|
|
38
42
|
var children = _ref.children,
|
|
39
|
-
|
|
40
|
-
className = _ref$className === void 0 ? '' : _ref$className,
|
|
43
|
+
className = _ref.className,
|
|
41
44
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
42
|
-
var allClasses = classnames__default.default('container', className);
|
|
45
|
+
var allClasses = classnames__default.default('container', 'MrlGrid', className);
|
|
43
46
|
return /*#__PURE__*/React__namespace.createElement("div", _rollupPluginBabelHelpers.extends({}, rest, {
|
|
44
47
|
className: allClasses
|
|
45
48
|
}), children);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlGrid.js","sources":["../../../../../src/components/grid/MrlGrid/MrlGrid.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {
|
|
1
|
+
{"version":3,"file":"MrlGrid.js","sources":["../../../../../src/components/grid/MrlGrid/MrlGrid.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport { GridBaseProps } from '../constants';\nimport '../grid.global.scss';\n\nexport type MrlGridProps = GridBaseProps;\n\n/**\n * MrlGrid React component. Primary container of a 12-column grid built from\n * MrlRow and MrlCol.\n *\n * Breakpoints come from the foundation tokens: sm 600px, md 834px, lg 1024px,\n * xl 1280px and xxl 1440px. The gutter defaults to `--mrl-spacing-07` and can\n * be overridden by setting `--mrl-grid-gutter` on any ancestor.\n * @param props - component props\n * @returns a MrlGrid React component.\n */\nexport function MrlGrid({ children, className, ...rest }: MrlGridProps): JSX.Element {\n\tconst allClasses = classnames('container', 'MrlGrid', className);\n\n\treturn (\n\t\t<div {...rest} className={allClasses}>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n"],"names":["MrlGrid","_ref","children","className","rest","_objectWithoutProperties","_excluded","allClasses","classnames","React","createElement","_extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,OAAOA,CAAAC,IAAA,EAA8D;AAAA,EAAA,IAA3DC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAEC,SAAS,GAAAF,IAAA,CAATE,SAAS;AAAKC,IAAAA,IAAI,GAAAC,iDAAA,CAAAJ,IAAA,EAAAK,SAAA,CAAA;EACrD,IAAMC,UAAU,GAAGC,2BAAU,CAAC,WAAW,EAAE,SAAS,EAAEL,SAAS,CAAC;AAEhE,EAAA,oBACCM,gBAAA,CAAAC,aAAA,CAAA,KAAA,EAAAC,iCAAA,KAASP,IAAI,EAAA;AAAED,IAAAA,SAAS,EAAEI;AAAW,GAAA,CAAA,EACnCL,QACG,CAAC;AAER;;;;"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var classnames = require('classnames');
|
|
6
|
+
var constants = require('../constants.js');
|
|
6
7
|
|
|
7
8
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
9
|
|
|
@@ -27,25 +28,26 @@ function _interopNamespace(e) {
|
|
|
27
28
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
28
29
|
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
29
30
|
|
|
30
|
-
var _excluded = ["align", "children", "className", "justify"];
|
|
31
|
+
var _excluded = ["align", "children", "className", "gutter", "justify"];
|
|
31
32
|
/**
|
|
32
|
-
* MrlRow React component.
|
|
33
|
+
* MrlRow React component. Creates a grid row.
|
|
33
34
|
* @param props - component props
|
|
34
35
|
* @returns a MrlRow React component.
|
|
35
36
|
*/
|
|
36
37
|
function MrlRow(_ref) {
|
|
37
38
|
var align = _ref.align,
|
|
38
39
|
children = _ref.children,
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
className = _ref.className,
|
|
41
|
+
_ref$gutter = _ref.gutter,
|
|
42
|
+
gutter = _ref$gutter === void 0 ? 1 : _ref$gutter,
|
|
41
43
|
justify = _ref.justify,
|
|
42
44
|
rest = _rollupPluginBabelHelpers.objectWithoutProperties(_ref, _excluded);
|
|
43
|
-
var alignClass = align
|
|
45
|
+
var alignClass = align && "align-items-".concat(align);
|
|
44
46
|
var justifyClass = justify && "justify-content-".concat(justify);
|
|
45
|
-
var allClasses = classnames__default.default('row', className, alignClass, justifyClass);
|
|
46
|
-
return /*#__PURE__*/React__namespace.createElement("div", _rollupPluginBabelHelpers.extends({
|
|
47
|
+
var allClasses = classnames__default.default('row', 'MrlRow', className, alignClass, justifyClass, constants.GUTTER_CLASS[gutter]);
|
|
48
|
+
return /*#__PURE__*/React__namespace.createElement("div", _rollupPluginBabelHelpers.extends({}, rest, {
|
|
47
49
|
className: allClasses
|
|
48
|
-
}
|
|
50
|
+
}), children);
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
exports.MrlRow = MrlRow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MrlRow.js","sources":["../../../../../src/components/grid/MrlRow/MrlRow.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {
|
|
1
|
+
{"version":3,"file":"MrlRow.js","sources":["../../../../../src/components/grid/MrlRow/MrlRow.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport {\n\tAlignOptions,\n\tGridBaseProps,\n\tGUTTER_CLASS,\n\tGutterSizes,\n\tJustifyOptions\n} from '../constants';\n\nexport interface MrlRowProps extends GridBaseProps {\n\t/**\n\t * Flex alignment of the children within the component.\n\t */\n\talign?: AlignOptions;\n\n\t/**\n\t * Gutter size for columns within the row.\n\t *\n\t * @default 1\n\t */\n\tgutter?: GutterSizes;\n\n\t/**\n\t * Justify content of the children within the component.\n\t */\n\tjustify?: JustifyOptions;\n}\n\n/**\n * MrlRow React component. Creates a grid row.\n * @param props - component props\n * @returns a MrlRow React component.\n */\nexport function MrlRow({\n\talign,\n\tchildren,\n\tclassName,\n\tgutter = 1,\n\tjustify,\n\t...rest\n}: MrlRowProps): JSX.Element {\n\tconst alignClass = align && `align-items-${align}`;\n\tconst justifyClass = justify && `justify-content-${justify}`;\n\n\tconst allClasses = classnames(\n\t\t'row',\n\t\t'MrlRow',\n\t\tclassName,\n\t\talignClass,\n\t\tjustifyClass,\n\t\tGUTTER_CLASS[gutter]\n\t);\n\n\treturn (\n\t\t<div {...rest} className={allClasses}>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n"],"names":["MrlRow","_ref","align","children","className","_ref$gutter","gutter","justify","rest","_objectWithoutProperties","_excluded","alignClass","concat","justifyClass","allClasses","classnames","GUTTER_CLASS","React","createElement","_extends"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA;AACA;AACA;AACA;AACA;AACO,SAASA,MAAMA,CAAAC,IAAA,EAOO;AAAA,EAAA,IAN5BC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;IACRC,SAAS,GAAAH,IAAA,CAATG,SAAS;IAAAC,WAAA,GAAAJ,IAAA,CACTK,MAAM;AAANA,IAAAA,MAAM,GAAAD,WAAA,KAAA,MAAA,GAAG,CAAC,GAAAA,WAAA;IACVE,OAAO,GAAAN,IAAA,CAAPM,OAAO;AACJC,IAAAA,IAAI,GAAAC,iDAAA,CAAAR,IAAA,EAAAS,SAAA,CAAA;AAEP,EAAA,IAAMC,UAAU,GAAGT,KAAK,mBAAAU,MAAA,CAAmBV,KAAK,CAAE;AAClD,EAAA,IAAMW,YAAY,GAAGN,OAAO,uBAAAK,MAAA,CAAuBL,OAAO,CAAE;AAE5D,EAAA,IAAMO,UAAU,GAAGC,2BAAU,CAC5B,KAAK,EACL,QAAQ,EACRX,SAAS,EACTO,UAAU,EACVE,YAAY,EACZG,sBAAY,CAACV,MAAM,CACpB,CAAC;AAED,EAAA,oBACCW,gBAAA,CAAAC,aAAA,CAAA,KAAA,EAAAC,iCAAA,KAASX,IAAI,EAAA;AAAEJ,IAAAA,SAAS,EAAEU;AAAW,GAAA,CAAA,EACnCX,QACG,CAAC;AAER;;;;"}
|
|
@@ -5,23 +5,22 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Number of columns a `col` can span. There is no `col-0` class — a column
|
|
9
|
+
* always occupies at least one of the twelve tracks.
|
|
9
10
|
*/
|
|
10
|
-
var GridSizes = ['col', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* Number of columns
|
|
13
|
+
* Number of columns an `offset` can skip. `0` is meaningful here: it is how a
|
|
14
|
+
* larger breakpoint cancels an offset inherited from a smaller one.
|
|
14
15
|
*/
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* - columns "col-<size>-<number>"
|
|
20
|
-
* - offsets "offset-<size>-<number>""
|
|
18
|
+
* @deprecated Use `ColSpan` for spans or `OffsetSpan` for offsets. This union
|
|
19
|
+
* allowed `col={0}`, which never produced a class.
|
|
21
20
|
*/
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
|
-
* Interface of available class selectors
|
|
23
|
+
* Interface of available class selectors per breakpoint.
|
|
25
24
|
*
|
|
26
25
|
* Example interface:
|
|
27
26
|
* {
|
|
@@ -34,9 +33,48 @@ var GridSizes = ['col', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
|
|
34
33
|
* Options to configure the number of columns to span on different screen sizes.
|
|
35
34
|
*/
|
|
36
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Breakpoint keys in ascending order. Drives both class generation and the
|
|
38
|
+
* filtering that keeps grid props from reaching the DOM.
|
|
39
|
+
*/
|
|
40
|
+
var GRID_SIZE_KEYS = ['col', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'];
|
|
41
|
+
|
|
37
42
|
/**
|
|
38
43
|
* Available gutter sizes for customizing the grid
|
|
39
44
|
*/
|
|
40
45
|
|
|
41
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Gutter size to modifier class. `1` is the default declared on `.row`, so it
|
|
48
|
+
* needs no class.
|
|
49
|
+
*/
|
|
50
|
+
var GUTTER_CLASS = {
|
|
51
|
+
0: 'MrlRow-gutter--none',
|
|
52
|
+
1: undefined,
|
|
53
|
+
2: 'MrlRow-gutter--double'
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Roles a generic layout wrapper may safely carry.
|
|
58
|
+
*
|
|
59
|
+
* Composite widget roles (`grid`, `row`, `gridcell`, `listbox`, `tablist`, …)
|
|
60
|
+
* are deliberately excluded: they promise an APG keyboard contract — roving
|
|
61
|
+
* tabindex or `aria-activedescendant`, arrow-key navigation, selection state —
|
|
62
|
+
* that these divs do not implement. The roles below are structural only and
|
|
63
|
+
* carry no interaction contract, so they are safe to forward.
|
|
64
|
+
*
|
|
65
|
+
* `list`/`listitem` in particular is how a row of columns is announced as
|
|
66
|
+
* "list, N items", and is the standard workaround for Safari/VoiceOver
|
|
67
|
+
* dropping implicit list semantics. `region` needs an accessible name to be
|
|
68
|
+
* exposed as a landmark; the type cannot enforce that.
|
|
69
|
+
*
|
|
70
|
+
* Page landmarks belong to the layout components (MrlMain, MrlPage).
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Shared props for the grid components: every `div` attribute, with `role`
|
|
75
|
+
* narrowed to {@link SafeLayoutRole}.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
exports.GRID_SIZE_KEYS = GRID_SIZE_KEYS;
|
|
79
|
+
exports.GUTTER_CLASS = GUTTER_CLASS;
|
|
42
80
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../../src/components/grid/constants.ts"],"sourcesContent":["/**\n * Alignment & justification options for grid containers\n */\nexport type AlignOptions = 'start' | 'center' | 'end';\nexport type JustifyOptions = 'start' | 'center' | 'end' | 'between' | 'around';\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/components/grid/constants.ts"],"sourcesContent":["import { DataQa } from '../../utils/dataQa';\n\n/**\n * Alignment & justification options for grid containers\n */\nexport type AlignOptions = 'start' | 'center' | 'end';\nexport type JustifyOptions = 'start' | 'center' | 'end' | 'between' | 'around';\n\n/**\n * Number of columns a `col` can span. There is no `col-0` class — a column\n * always occupies at least one of the twelve tracks.\n */\nexport type ColSpan = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;\n\n/**\n * Number of columns an `offset` can skip. `0` is meaningful here: it is how a\n * larger breakpoint cancels an offset inherited from a smaller one.\n */\nexport type OffsetSpan = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11;\n\n/**\n * @deprecated Use `ColSpan` for spans or `OffsetSpan` for offsets. This union\n * allowed `col={0}`, which never produced a class.\n */\nexport type NumCols = 0 | ColSpan;\n\n/**\n * Interface of available class selectors per breakpoint.\n *\n * Example interface:\n * {\n * col?: number,\n * offset?: number\n * }\n */\ntype GridClassConfig = {\n\tcol?: ColSpan;\n\toffset?: OffsetSpan;\n};\n\n/**\n * Options to configure the number of columns to span on different screen sizes.\n */\ntype ColumnConfig = ColSpan | 'auto' | GridClassConfig | undefined;\n\nexport interface GridColumns {\n\t/**\n\t * Columns that are the same from the smallest of devices to the largest.\n\t */\n\tcol?: ColumnConfig;\n\n\t/**\n\t * @deprecated Alias of `col`, kept for backwards compatibility. It resolves\n\t * to the same un-prefixed tier, so passing both `col` and `xs` emits two\n\t * competing classes and the larger span wins on CSS source order rather\n\t * than the one you wrote last. Pass only one.\n\t */\n\txs?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span from the sm breakpoint up.\n\t */\n\tsm?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span from the md breakpoint up.\n\t */\n\tmd?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span from the lg breakpoint up.\n\t */\n\tlg?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span from the xl breakpoint up.\n\t */\n\txl?: ColumnConfig;\n\n\t/**\n\t * The number of columns to span from the xxl breakpoint up.\n\t */\n\txxl?: ColumnConfig;\n}\n\n/**\n * Breakpoint keys in ascending order. Drives both class generation and the\n * filtering that keeps grid props from reaching the DOM.\n */\nexport const GRID_SIZE_KEYS = ['col', 'xs', 'sm', 'md', 'lg', 'xl', 'xxl'] as const;\n\n/**\n * Available gutter sizes for customizing the grid\n */\nexport type GutterSizes = 0 | 1 | 2;\n\n/**\n * Gutter size to modifier class. `1` is the default declared on `.row`, so it\n * needs no class.\n */\nexport const GUTTER_CLASS: Record<GutterSizes, string | undefined> = {\n\t0: 'MrlRow-gutter--none',\n\t1: undefined,\n\t2: 'MrlRow-gutter--double'\n};\n\n/**\n * Roles a generic layout wrapper may safely carry.\n *\n * Composite widget roles (`grid`, `row`, `gridcell`, `listbox`, `tablist`, …)\n * are deliberately excluded: they promise an APG keyboard contract — roving\n * tabindex or `aria-activedescendant`, arrow-key navigation, selection state —\n * that these divs do not implement. The roles below are structural only and\n * carry no interaction contract, so they are safe to forward.\n *\n * `list`/`listitem` in particular is how a row of columns is announced as\n * \"list, N items\", and is the standard workaround for Safari/VoiceOver\n * dropping implicit list semantics. `region` needs an accessible name to be\n * exposed as a landmark; the type cannot enforce that.\n *\n * Page landmarks belong to the layout components (MrlMain, MrlPage).\n */\nexport type SafeLayoutRole = 'group' | 'list' | 'listitem' | 'none' | 'presentation' | 'region';\n\n/**\n * Shared props for the grid components: every `div` attribute, with `role`\n * narrowed to {@link SafeLayoutRole}.\n */\nexport type GridBaseProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'role'> &\n\tDataQa & {\n\t\t/**\n\t\t * Structural role for the wrapper. Composite widget roles are not\n\t\t * accepted — see {@link SafeLayoutRole}.\n\t\t */\n\t\trole?: SafeLayoutRole;\n\t};\n"],"names":["GRID_SIZE_KEYS","GUTTER_CLASS","undefined"],"mappings":";;AAEA;AACA;AACA;;AAIA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;;AA2CA;AACA;AACA;AACA;IACaA,cAAc,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK;;AAEzE;AACA;AACA;;AAGA;AACA;AACA;AACA;AACO,IAAMC,YAAqD,GAAG;AACpE,EAAA,CAAC,EAAE,qBAAqB;AACxB,EAAA,CAAC,EAAEC,SAAS;AACZ,EAAA,CAAC,EAAE;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;;;;"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var classnames = require('classnames');
|
|
5
|
+
var MrlMultiFilter_module = require('./MrlMultiFilter.module.scss.js');
|
|
6
|
+
var MrlPopover = require('../../popover/MrlPopover/MrlPopover.js');
|
|
7
|
+
var MrlMultiFilterTrigger = require('../MrlMultiFilterTrigger/MrlMultiFilterTrigger.js');
|
|
8
|
+
var MrlMultiFilterContext = require('../MrlMultiFilterContext/MrlMultiFilterContext.js');
|
|
9
|
+
var MrlButton = require('../../button/MrlButton/MrlButton.js');
|
|
10
|
+
var MrlTextHeading = require('../../text/MrlTextHeading/MrlTextHeading.js');
|
|
11
|
+
var setAttributes = require('../../../utils/setAttributes/setAttributes.js');
|
|
12
|
+
|
|
13
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
|
|
15
|
+
function _interopNamespace(e) {
|
|
16
|
+
if (e && e.__esModule) return e;
|
|
17
|
+
var n = Object.create(null);
|
|
18
|
+
if (e) {
|
|
19
|
+
Object.keys(e).forEach(function (k) {
|
|
20
|
+
if (k !== 'default') {
|
|
21
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
22
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return e[k]; }
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
n.default = e;
|
|
30
|
+
return Object.freeze(n);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
34
|
+
var classnames__default = /*#__PURE__*/_interopDefault(classnames);
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Without `transform`, `onApply` receives the draft.
|
|
38
|
+
*
|
|
39
|
+
* Docgen merges the JSDoc of both union members (this one first), so each comment below is
|
|
40
|
+
* written to read on its own and as the first half of the merged description.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* With `transform`, `onApply` receives its result.
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Counts the fields with a value set: not empty and not `false`.
|
|
49
|
+
*
|
|
50
|
+
* @param draft - The draft.
|
|
51
|
+
* @returns The number of fields with a value set.
|
|
52
|
+
*/
|
|
53
|
+
var countFieldsWithValue = draft => Object.values(draft).filter(field => field.value !== false && !MrlMultiFilterContext.isMrlMultiFilterValueEmpty(field.value)).length;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* MrlMultiFilter component.
|
|
57
|
+
*
|
|
58
|
+
* A MrlMultiFilterTrigger that opens a MrlPopover holding a heading and several filter
|
|
59
|
+
* fields, followed by a Reset / Cancel / Apply footer. Changes only take effect on Apply: the
|
|
60
|
+
* fields edit a draft, which starts from the applied filters each time the popover opens, so
|
|
61
|
+
* closing without Apply drops unapplied edits, and the trigger badge counts the applied
|
|
62
|
+
* filters. Apply hands the draft to `onApply` (through `transform`, if given) and makes it the
|
|
63
|
+
* applied one; Cancel sets it back to the applied filters; Reset sets it to `resetDraft` and
|
|
64
|
+
* keeps the popover open. Apply is blocked, and the first empty required field focused, while
|
|
65
|
+
* a required field is empty.
|
|
66
|
+
*
|
|
67
|
+
* Uncontrolled by default: the component keeps the applied draft. Pass `appliedDraft` and
|
|
68
|
+
* update it in `onApply` to control it, e.g. to clear or restore the filters from outside.
|
|
69
|
+
*
|
|
70
|
+
* Bind each field with `field={getField('name')}` from the render prop. The popover is a
|
|
71
|
+
* non-modal dialog named by the heading through `aria-labelledby`. It sets
|
|
72
|
+
* `aria-haspopup="dialog"` and `aria-expanded` on the trigger; the latter drives its toggle style. Cancel and Apply return focus to the trigger. Checkboxes inside the
|
|
73
|
+
* fields drop their default checkbox-group spacing.
|
|
74
|
+
*
|
|
75
|
+
* @param props - The component props.
|
|
76
|
+
* @returns The MrlMultiFilter component.
|
|
77
|
+
*/
|
|
78
|
+
function MrlMultiFilter(props) {
|
|
79
|
+
return /*#__PURE__*/React__namespace.createElement(MrlMultiFilterContext.MrlMultiFilterContextProvider, {
|
|
80
|
+
appliedDraft: props.appliedDraft,
|
|
81
|
+
initialDraft: props.initialDraft
|
|
82
|
+
}, /*#__PURE__*/React__namespace.createElement(MrlMultiFilterContent, props));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Trigger and popover of the MrlMultiFilter. A component of its own so it can read the draft
|
|
87
|
+
* from the context.
|
|
88
|
+
*
|
|
89
|
+
* @param props - The MrlMultiFilter props.
|
|
90
|
+
* @returns The trigger and the popover.
|
|
91
|
+
*/
|
|
92
|
+
function MrlMultiFilterContent(props) {
|
|
93
|
+
var _props$alignment = props.alignment,
|
|
94
|
+
alignment = _props$alignment === void 0 ? 'start' : _props$alignment,
|
|
95
|
+
_props$applyText = props.applyText,
|
|
96
|
+
applyText = _props$applyText === void 0 ? 'Apply' : _props$applyText,
|
|
97
|
+
_props$cancelText = props.cancelText,
|
|
98
|
+
cancelText = _props$cancelText === void 0 ? 'Cancel' : _props$cancelText,
|
|
99
|
+
children = props.children,
|
|
100
|
+
className = props.className,
|
|
101
|
+
_props$countActiveFil = props.countActiveFilters,
|
|
102
|
+
countActiveFilters = _props$countActiveFil === void 0 ? countFieldsWithValue : _props$countActiveFil,
|
|
103
|
+
dataQa = props['data-qa'],
|
|
104
|
+
heading = props.heading,
|
|
105
|
+
_props$headingLevel = props.headingLevel,
|
|
106
|
+
headingLevel = _props$headingLevel === void 0 ? '2' : _props$headingLevel,
|
|
107
|
+
initialDraft = props.initialDraft,
|
|
108
|
+
notificationText = props.notificationText,
|
|
109
|
+
_props$offset = props.offset,
|
|
110
|
+
offset = _props$offset === void 0 ? 4 : _props$offset,
|
|
111
|
+
onApply = props.onApply,
|
|
112
|
+
onCancel = props.onCancel,
|
|
113
|
+
_props$position = props.position,
|
|
114
|
+
position = _props$position === void 0 ? 'bottom' : _props$position,
|
|
115
|
+
_props$requiredMessag = props.requiredMessage,
|
|
116
|
+
requiredMessage = _props$requiredMessag === void 0 ? 'This field is required' : _props$requiredMessag,
|
|
117
|
+
resetDraft = props.resetDraft,
|
|
118
|
+
_props$resetText = props.resetText,
|
|
119
|
+
resetText = _props$resetText === void 0 ? 'Reset' : _props$resetText,
|
|
120
|
+
transform = props.transform,
|
|
121
|
+
triggerSize = props.triggerSize,
|
|
122
|
+
triggerState = props.triggerState,
|
|
123
|
+
triggerText = props.triggerText;
|
|
124
|
+
var context = MrlMultiFilterContext.useMrlMultiFilterContext();
|
|
125
|
+
var applied = context.applied,
|
|
126
|
+
draft = context.draft,
|
|
127
|
+
errors = context.errors;
|
|
128
|
+
var triggerRef = React__namespace.useRef(null);
|
|
129
|
+
var headingIdRef = React__namespace.useRef(setAttributes.getUniqueId('mrl-multi-filter-heading'));
|
|
130
|
+
// Like the context, ignore later changes to initialDraft.
|
|
131
|
+
var initialDraftRef = React__namespace.useRef(initialDraft);
|
|
132
|
+
var reset = () => {
|
|
133
|
+
var nextDraft = resetDraft !== null && resetDraft !== void 0 ? resetDraft : initialDraftRef.current;
|
|
134
|
+
// The latest draft, so a reset after an edit in the same handler sees the edit.
|
|
135
|
+
context.reset(typeof nextDraft === 'function' ? nextDraft(context.getDraft()) : nextDraft);
|
|
136
|
+
};
|
|
137
|
+
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(MrlMultiFilterTrigger.MrlMultiFilterTrigger, {
|
|
138
|
+
activeFiltersCount: countActiveFilters(applied),
|
|
139
|
+
"data-qa": dataQa,
|
|
140
|
+
notificationText: notificationText,
|
|
141
|
+
ref: triggerRef,
|
|
142
|
+
size: triggerSize,
|
|
143
|
+
state: triggerState,
|
|
144
|
+
text: triggerText
|
|
145
|
+
}), /*#__PURE__*/React__namespace.createElement(MrlPopover.MrlPopover, {
|
|
146
|
+
alignment: alignment,
|
|
147
|
+
ariaLabelledBy: headingIdRef.current,
|
|
148
|
+
className: classnames__default.default(MrlMultiFilter_module.default['MrlMultiFilter'], 'MrlMultiFilter', className),
|
|
149
|
+
"data-qa": dataQa ? "".concat(dataQa, "-popover") : undefined,
|
|
150
|
+
offset: offset,
|
|
151
|
+
point: false,
|
|
152
|
+
position: position,
|
|
153
|
+
role: "dialog",
|
|
154
|
+
onOpen: context.discard,
|
|
155
|
+
triggerRef: triggerRef
|
|
156
|
+
}, _ref => {
|
|
157
|
+
var closePopover = _ref.closeMenu;
|
|
158
|
+
/**
|
|
159
|
+
* MrlPopover only returns focus to the trigger on Escape. Return it here too, so
|
|
160
|
+
* focus is not lost when the popover content unmounts.
|
|
161
|
+
*/
|
|
162
|
+
var closeMenu = () => {
|
|
163
|
+
var _triggerRef$current;
|
|
164
|
+
closePopover();
|
|
165
|
+
(_triggerRef$current = triggerRef.current) === null || _triggerRef$current === void 0 ? void 0 : _triggerRef$current.focus();
|
|
166
|
+
};
|
|
167
|
+
var apply = () => {
|
|
168
|
+
if (!context.validate()) return;
|
|
169
|
+
// The latest draft, not this render's: a render-prop handler may have edited it
|
|
170
|
+
// just before calling apply, e.g. `reset(); apply();`.
|
|
171
|
+
var latestDraft = context.getDraft();
|
|
172
|
+
context.commit();
|
|
173
|
+
if (transform) {
|
|
174
|
+
onApply(transform(latestDraft));
|
|
175
|
+
} else {
|
|
176
|
+
onApply(latestDraft);
|
|
177
|
+
}
|
|
178
|
+
closeMenu();
|
|
179
|
+
};
|
|
180
|
+
var cancel = () => {
|
|
181
|
+
context.discard();
|
|
182
|
+
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
183
|
+
closeMenu();
|
|
184
|
+
};
|
|
185
|
+
var getField = name => ({
|
|
186
|
+
error: errors[name] ? requiredMessage : undefined,
|
|
187
|
+
name: String(name),
|
|
188
|
+
required: Boolean(draft[name].required),
|
|
189
|
+
setValue: value => context.setFieldValue(name, value),
|
|
190
|
+
value: draft[name].value
|
|
191
|
+
});
|
|
192
|
+
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(MrlTextHeading.MrlTextHeading, {
|
|
193
|
+
className: classnames__default.default(MrlMultiFilter_module.default['MrlMultiFilter-title'], 'MrlMultiFilter-title'),
|
|
194
|
+
id: headingIdRef.current,
|
|
195
|
+
level: headingLevel,
|
|
196
|
+
kind: "title",
|
|
197
|
+
size: "medium",
|
|
198
|
+
text: heading
|
|
199
|
+
}), /*#__PURE__*/React__namespace.createElement("div", {
|
|
200
|
+
className: classnames__default.default(MrlMultiFilter_module.default['MrlMultiFilter-fields'], 'MrlMultiFilter-fields')
|
|
201
|
+
}, typeof children === 'function' ? children({
|
|
202
|
+
apply,
|
|
203
|
+
closeMenu,
|
|
204
|
+
draft,
|
|
205
|
+
getField,
|
|
206
|
+
reset,
|
|
207
|
+
setFieldValue: context.setFieldValue,
|
|
208
|
+
setRequired: context.setRequired
|
|
209
|
+
}) : children), /*#__PURE__*/React__namespace.createElement("div", {
|
|
210
|
+
className: classnames__default.default(MrlMultiFilter_module.default['MrlMultiFilter-actions'], 'MrlMultiFilter-actions')
|
|
211
|
+
}, /*#__PURE__*/React__namespace.createElement(MrlButton.MrlButton, {
|
|
212
|
+
className: MrlMultiFilter_module.default['MrlMultiFilter-reset'],
|
|
213
|
+
kind: "ghost",
|
|
214
|
+
onClick: reset,
|
|
215
|
+
size: "small",
|
|
216
|
+
text: resetText
|
|
217
|
+
}), /*#__PURE__*/React__namespace.createElement(MrlButton.MrlButton, {
|
|
218
|
+
kind: "ghost",
|
|
219
|
+
onClick: cancel,
|
|
220
|
+
size: "small",
|
|
221
|
+
text: cancelText
|
|
222
|
+
}), /*#__PURE__*/React__namespace.createElement(MrlButton.MrlButton, {
|
|
223
|
+
kind: "primary",
|
|
224
|
+
onClick: apply,
|
|
225
|
+
size: "small",
|
|
226
|
+
text: applyText
|
|
227
|
+
})));
|
|
228
|
+
}));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
exports.MrlMultiFilter = MrlMultiFilter;
|
|
232
|
+
//# sourceMappingURL=MrlMultiFilter.js.map
|