@muraldevkit/ui-toolkit 4.82.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/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/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.css +2 -0
- 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
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MrlMultiFilter.js","sources":["../../../../../src/components/multi-filter/MrlMultiFilter/MrlMultiFilter.tsx"],"sourcesContent":["import * as React from 'react';\nimport classnames from 'classnames';\nimport styles from './MrlMultiFilter.module.scss';\nimport { MrlPopover, MrlPopoverProps } from '../../popover/MrlPopover/MrlPopover';\nimport {\n\tMrlMultiFilterTrigger,\n\tMrlMultiFilterTriggerProps\n} from '../MrlMultiFilterTrigger/MrlMultiFilterTrigger';\nimport {\n\tisMrlMultiFilterValueEmpty,\n\tMrlMultiFilterContextProvider,\n\tMrlMultiFilterDraft,\n\tMrlMultiFilterValues,\n\tuseMrlMultiFilterContext\n} from '../MrlMultiFilterContext/MrlMultiFilterContext';\nimport { MrlMultiFilterFieldBinding } from '../MrlMultiFilterField/MrlMultiFilterField';\nimport { MrlButton } from '../../button/MrlButton/MrlButton';\nimport { MrlTextHeading } from '../../text/MrlTextHeading/MrlTextHeading';\nimport { LevelType } from '../../text/constants';\nimport { DataQa } from '../../../utils/dataQa';\nimport { getUniqueId } from '../../../utils/setAttributes/setAttributes';\n\nexport type MrlMultiFilterRenderProps<T extends MrlMultiFilterValues> = {\n\t/**\n\t * Validates the draft, then does what the Apply button does. Required fields cannot be\n\t * skipped.\n\t */\n\tapply: () => void;\n\t/**\n\t * Closes the popover and returns focus to the trigger. Unapplied edits are dropped.\n\t */\n\tcloseMenu: () => void;\n\t/**\n\t * The draft being edited.\n\t */\n\tdraft: MrlMultiFilterDraft<T>;\n\t/**\n\t * Returns the binding of one field, to pass to MrlMultiFilterField's `field`. Its value is\n\t * typed from the field name.\n\t */\n\tgetField: <K extends keyof T>(name: K) => MrlMultiFilterFieldBinding<T[K]>;\n\t/**\n\t * Does what the Reset button does.\n\t */\n\treset: () => void;\n\t/**\n\t * Updates one field's value in the draft. Call it from event handlers, not during render.\n\t */\n\tsetFieldValue: <K extends keyof T>(name: K, value: T[K]) => void;\n\t/**\n\t * Marks one field as required or not. Call it from event handlers, not during render.\n\t */\n\tsetRequired: (name: keyof T, required: boolean) => void;\n};\n\n/**\n * Without `transform`, `onApply` receives the draft.\n *\n * Docgen merges the JSDoc of both union members (this one first), so each comment below is\n * written to read on its own and as the first half of the merged description.\n */\ntype MrlMultiFilterApplyDraftProps<T extends MrlMultiFilterValues> = {\n\t/**\n\t * Called when Apply is pressed and every required field has a value, before the popover\n\t * closes. Receives the draft, which becomes the applied draft.\n\t */\n\tonApply: (draft: MrlMultiFilterDraft<T>) => void;\n\t/**\n\t * Reshapes the draft before it is passed to `onApply`, e.g. `getDraftValues`.\n\t */\n\ttransform?: undefined;\n};\n\n/**\n * With `transform`, `onApply` receives its result.\n */\ntype MrlMultiFilterApplyTransformedProps<T extends MrlMultiFilterValues, R> = {\n\t/**\n\t * With `transform`, it receives the transformed draft instead.\n\t */\n\tonApply: (result: R) => void;\n\t/**\n\t * Its result is what `onApply` receives.\n\t */\n\ttransform: (draft: MrlMultiFilterDraft<T>) => R;\n};\n\nexport type MrlMultiFilterProps<T extends MrlMultiFilterValues, R = MrlMultiFilterDraft<T>> = {\n\t/**\n\t * Makes the applied filters controlled: pass the applied draft and store the draft that\n\t * `onApply` receives (so leave out `transform`). When it changes, e.g. when the filters are\n\t * cleared from outside the popover, the draft and the badge follow it. When omitted, the\n\t * component keeps the applied draft itself.\n\t */\n\tappliedDraft?: MrlMultiFilterDraft<T>;\n\t/**\n\t * Label of the Apply button.\n\t */\n\tapplyText?: string;\n\t/**\n\t * Label of the Cancel button.\n\t */\n\tcancelText?: string;\n\t/**\n\t * Content of the popover, usually MrlMultiFilterField elements. Pass a function to read and\n\t * edit the draft: it receives `getField` to bind the fields, plus `draft`, `setFieldValue`,\n\t * `setRequired`, `apply`, `reset` and `closeMenu`. It only runs while the popover is open.\n\t */\n\tchildren: React.ReactNode | ((renderProps: MrlMultiFilterRenderProps<T>) => React.ReactNode);\n\t/**\n\t * Counts the filters shown on the trigger badge. It runs on the applied draft, so the count\n\t * only changes on Apply. Defaults to the fields with a value set (not empty and not `false`).\n\t */\n\tcountActiveFilters?: (applied: MrlMultiFilterDraft<T>) => number;\n\t/**\n\t * Heading shown at the top of the popover. It is also the popover's accessible name.\n\t */\n\theading: string;\n\t/**\n\t * Semantic level of the heading, based on where the filter sits in the page hierarchy.\n\t */\n\theadingLevel?: LevelType;\n\t/**\n\t * The filters the component starts from, unless `appliedDraft` is given: a `value` and an\n\t * optional `required` flag per field. The filter values type is inferred from it. Later\n\t * changes are ignored. Also what Reset goes back to, unless `resetDraft` is given.\n\t */\n\tinitialDraft: MrlMultiFilterDraft<T>;\n\t/**\n\t * Called when the Cancel button is pressed, after the draft is set back to the applied\n\t * draft and before the popover closes.\n\t */\n\tonCancel?: () => void;\n\t/**\n\t * Draft set by the Reset button, or a function that returns it from the current draft.\n\t * Defaults to `initialDraft`. The popover stays open and nothing is applied until Apply.\n\t */\n\tresetDraft?: MrlMultiFilterDraft<T> | ((draft: MrlMultiFilterDraft<T>) => MrlMultiFilterDraft<T>);\n\t/**\n\t * Label of the Reset button.\n\t */\n\tresetText?: string;\n\t/**\n\t * Message shown below a required field left empty on Apply. A field can override it.\n\t */\n\trequiredMessage?: string;\n\t/**\n\t * Size of the trigger button.\n\t */\n\ttriggerSize?: MrlMultiFilterTriggerProps['size'];\n\t/**\n\t * Interaction state of the trigger button. Only `default` and `disabled` apply.\n\t */\n\ttriggerState?: MrlMultiFilterTriggerProps['state'];\n\t/**\n\t * Visible label of the trigger button.\n\t */\n\ttriggerText: MrlMultiFilterTriggerProps['text'];\n} & (MrlMultiFilterApplyDraftProps<T> | MrlMultiFilterApplyTransformedProps<T, R>) &\n\tPick<MrlPopoverProps, 'alignment' | 'className' | 'offset' | 'position'> &\n\tPick<MrlMultiFilterTriggerProps, 'notificationText'> &\n\tDataQa;\n\n/**\n * Counts the fields with a value set: not empty and not `false`.\n *\n * @param draft - The draft.\n * @returns The number of fields with a value set.\n */\nconst countFieldsWithValue = (draft: MrlMultiFilterDraft<MrlMultiFilterValues>): number =>\n\tObject.values(draft).filter(\n\t\t(field) => field.value !== false && !isMrlMultiFilterValueEmpty(field.value)\n\t).length;\n\n/**\n * MrlMultiFilter component.\n *\n * A MrlMultiFilterTrigger that opens a MrlPopover holding a heading and several filter\n * fields, followed by a Reset / Cancel / Apply footer. Changes only take effect on Apply: the\n * fields edit a draft, which starts from the applied filters each time the popover opens, so\n * closing without Apply drops unapplied edits, and the trigger badge counts the applied\n * filters. Apply hands the draft to `onApply` (through `transform`, if given) and makes it the\n * applied one; Cancel sets it back to the applied filters; Reset sets it to `resetDraft` and\n * keeps the popover open. Apply is blocked, and the first empty required field focused, while\n * a required field is empty.\n *\n * Uncontrolled by default: the component keeps the applied draft. Pass `appliedDraft` and\n * update it in `onApply` to control it, e.g. to clear or restore the filters from outside.\n *\n * Bind each field with `field={getField('name')}` from the render prop. The popover is a\n * non-modal dialog named by the heading through `aria-labelledby`. It sets\n * `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\n * fields drop their default checkbox-group spacing.\n *\n * @param props - The component props.\n * @returns The MrlMultiFilter component.\n */\nexport function MrlMultiFilter<T extends MrlMultiFilterValues, R = MrlMultiFilterDraft<T>>(\n\tprops: MrlMultiFilterProps<T, R>\n): React.ReactElement {\n\treturn (\n\t\t<MrlMultiFilterContextProvider<T>\n\t\t\tappliedDraft={props.appliedDraft}\n\t\t\tinitialDraft={props.initialDraft}\n\t\t>\n\t\t\t<MrlMultiFilterContent<T, R> {...props} />\n\t\t</MrlMultiFilterContextProvider>\n\t);\n}\n\n/**\n * Trigger and popover of the MrlMultiFilter. A component of its own so it can read the draft\n * from the context.\n *\n * @param props - The MrlMultiFilter props.\n * @returns The trigger and the popover.\n */\nfunction MrlMultiFilterContent<T extends MrlMultiFilterValues, R>(\n\tprops: MrlMultiFilterProps<T, R>\n): React.ReactElement {\n\tconst {\n\t\talignment = 'start',\n\t\tapplyText = 'Apply',\n\t\tcancelText = 'Cancel',\n\t\tchildren,\n\t\tclassName,\n\t\tcountActiveFilters = countFieldsWithValue,\n\t\t['data-qa']: dataQa,\n\t\theading,\n\t\theadingLevel = '2',\n\t\tinitialDraft,\n\t\tnotificationText,\n\t\toffset = 4,\n\t\tonApply,\n\t\tonCancel,\n\t\tposition = 'bottom',\n\t\trequiredMessage = 'This field is required',\n\t\tresetDraft,\n\t\tresetText = 'Reset',\n\t\ttransform,\n\t\ttriggerSize,\n\t\ttriggerState,\n\t\ttriggerText\n\t} = props;\n\n\tconst context = useMrlMultiFilterContext<T>();\n\tconst { applied, draft, errors } = context;\n\n\tconst triggerRef = React.useRef<HTMLButtonElement>(null);\n\tconst headingIdRef = React.useRef<string>(getUniqueId('mrl-multi-filter-heading'));\n\t// Like the context, ignore later changes to initialDraft.\n\tconst initialDraftRef = React.useRef(initialDraft);\n\n\tconst reset = () => {\n\t\tconst nextDraft = resetDraft ?? initialDraftRef.current;\n\t\t// The latest draft, so a reset after an edit in the same handler sees the edit.\n\t\tcontext.reset(typeof nextDraft === 'function' ? nextDraft(context.getDraft()) : nextDraft);\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<MrlMultiFilterTrigger\n\t\t\t\tactiveFiltersCount={countActiveFilters(applied)}\n\t\t\t\tdata-qa={dataQa}\n\t\t\t\tnotificationText={notificationText}\n\t\t\t\tref={triggerRef}\n\t\t\t\tsize={triggerSize}\n\t\t\t\tstate={triggerState}\n\t\t\t\ttext={triggerText}\n\t\t\t/>\n\t\t\t<MrlPopover\n\t\t\t\talignment={alignment}\n\t\t\t\tariaLabelledBy={headingIdRef.current}\n\t\t\t\tclassName={classnames(styles['MrlMultiFilter'], 'MrlMultiFilter', className)}\n\t\t\t\tdata-qa={dataQa ? `${dataQa}-popover` : undefined}\n\t\t\t\toffset={offset}\n\t\t\t\tpoint={false}\n\t\t\t\tposition={position}\n\t\t\t\trole=\"dialog\"\n\t\t\t\tonOpen={context.discard}\n\t\t\t\ttriggerRef={triggerRef}\n\t\t\t>\n\t\t\t\t{({ closeMenu: closePopover }) => {\n\t\t\t\t\t/**\n\t\t\t\t\t * MrlPopover only returns focus to the trigger on Escape. Return it here too, so\n\t\t\t\t\t * focus is not lost when the popover content unmounts.\n\t\t\t\t\t */\n\t\t\t\t\tconst closeMenu = () => {\n\t\t\t\t\t\tclosePopover();\n\t\t\t\t\t\ttriggerRef.current?.focus();\n\t\t\t\t\t};\n\n\t\t\t\t\tconst apply = () => {\n\t\t\t\t\t\tif (!context.validate()) return;\n\t\t\t\t\t\t// The latest draft, not this render's: a render-prop handler may have edited it\n\t\t\t\t\t\t// just before calling apply, e.g. `reset(); apply();`.\n\t\t\t\t\t\tconst latestDraft = context.getDraft();\n\t\t\t\t\t\tcontext.commit();\n\t\t\t\t\t\tif (transform) {\n\t\t\t\t\t\t\t(onApply as (result: R) => void)(transform(latestDraft));\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t(onApply as (draft: MrlMultiFilterDraft<T>) => void)(latestDraft);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcloseMenu();\n\t\t\t\t\t};\n\n\t\t\t\t\tconst cancel = () => {\n\t\t\t\t\t\tcontext.discard();\n\t\t\t\t\t\tonCancel?.();\n\t\t\t\t\t\tcloseMenu();\n\t\t\t\t\t};\n\n\t\t\t\t\tconst getField = <K extends keyof T>(name: K): MrlMultiFilterFieldBinding<T[K]> => ({\n\t\t\t\t\t\terror: errors[name] ? requiredMessage : undefined,\n\t\t\t\t\t\tname: String(name),\n\t\t\t\t\t\trequired: Boolean(draft[name].required),\n\t\t\t\t\t\tsetValue: (value) => context.setFieldValue(name, value),\n\t\t\t\t\t\tvalue: draft[name].value\n\t\t\t\t\t});\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<MrlTextHeading\n\t\t\t\t\t\t\t\tclassName={classnames(styles['MrlMultiFilter-title'], 'MrlMultiFilter-title')}\n\t\t\t\t\t\t\t\tid={headingIdRef.current}\n\t\t\t\t\t\t\t\tlevel={headingLevel}\n\t\t\t\t\t\t\t\tkind=\"title\"\n\t\t\t\t\t\t\t\tsize=\"medium\"\n\t\t\t\t\t\t\t\ttext={heading}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<div className={classnames(styles['MrlMultiFilter-fields'], 'MrlMultiFilter-fields')}>\n\t\t\t\t\t\t\t\t{typeof children === 'function'\n\t\t\t\t\t\t\t\t\t? children({\n\t\t\t\t\t\t\t\t\t\t\tapply,\n\t\t\t\t\t\t\t\t\t\t\tcloseMenu,\n\t\t\t\t\t\t\t\t\t\t\tdraft,\n\t\t\t\t\t\t\t\t\t\t\tgetField,\n\t\t\t\t\t\t\t\t\t\t\treset,\n\t\t\t\t\t\t\t\t\t\t\tsetFieldValue: context.setFieldValue,\n\t\t\t\t\t\t\t\t\t\t\tsetRequired: context.setRequired\n\t\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t: children}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName={classnames(styles['MrlMultiFilter-actions'], 'MrlMultiFilter-actions')}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<MrlButton\n\t\t\t\t\t\t\t\t\tclassName={styles['MrlMultiFilter-reset']}\n\t\t\t\t\t\t\t\t\tkind=\"ghost\"\n\t\t\t\t\t\t\t\t\tonClick={reset}\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t\ttext={resetText}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<MrlButton kind=\"ghost\" onClick={cancel} size=\"small\" text={cancelText} />\n\t\t\t\t\t\t\t\t<MrlButton kind=\"primary\" onClick={apply} size=\"small\" text={applyText} />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</>\n\t\t\t\t\t);\n\t\t\t\t}}\n\t\t\t</MrlPopover>\n\t\t</>\n\t);\n}\n"],"names":["countFieldsWithValue","draft","Object","values","filter","field","value","isMrlMultiFilterValueEmpty","length","MrlMultiFilter","props","React","createElement","MrlMultiFilterContextProvider","appliedDraft","initialDraft","MrlMultiFilterContent","_props$alignment","alignment","_props$applyText","applyText","_props$cancelText","cancelText","children","className","_props$countActiveFil","countActiveFilters","dataQa","heading","_props$headingLevel","headingLevel","notificationText","_props$offset","offset","onApply","onCancel","_props$position","position","_props$requiredMessag","requiredMessage","resetDraft","_props$resetText","resetText","transform","triggerSize","triggerState","triggerText","context","useMrlMultiFilterContext","applied","errors","triggerRef","useRef","headingIdRef","getUniqueId","initialDraftRef","reset","nextDraft","current","getDraft","Fragment","MrlMultiFilterTrigger","activeFiltersCount","ref","size","state","text","MrlPopover","ariaLabelledBy","classnames","styles","concat","undefined","point","role","onOpen","discard","_ref","closePopover","closeMenu","_triggerRef$current","focus","apply","validate","latestDraft","commit","cancel","getField","name","error","String","required","Boolean","setValue","setFieldValue","MrlTextHeading","id","level","kind","setRequired","MrlButton","onClick"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA;AACA;AACA;AACA;AACA;AACA;;AAaA;AACA;AACA;;AAwFA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMA,oBAAoB,GAAIC,KAAgD,IAC7EC,MAAM,CAACC,MAAM,CAACF,KAAK,CAAC,CAACG,MAAM,CACzBC,KAAK,IAAKA,KAAK,CAACC,KAAK,KAAK,KAAK,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I,EAAC,OAAO;AACZG,MAAAA,OAAO,EAAE7C,KAAM;AACfQ,MAAAA,IAAI,EAAC,OAAO;AACZE,MAAAA,IAAI,EAAExB;AAAU,KAChB,CAAC,eACF/B,gBAAA,CAAAC,aAAA,CAACwF,mBAAS,EAAA;AAACF,MAAAA,IAAI,EAAC,OAAO;AAACG,MAAAA,OAAO,EAAEf,MAAO;AAACtB,MAAAA,IAAI,EAAC,OAAO;AAACE,MAAAA,IAAI,EAAE5C;AAAW,KAAE,CAAC,eAC1EX,gBAAA,CAAAC,aAAA,CAACwF,mBAAS,EAAA;AAACF,MAAAA,IAAI,EAAC,SAAS;AAACG,MAAAA,OAAO,EAAEnB,KAAM;AAAClB,MAAAA,IAAI,EAAC,OAAO;AAACE,MAAAA,IAAI,EAAE9C;KAAY,CACrE,CACJ,CAAC;AAEL,EAAA,CACW,CACX,CAAC;AAEL;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var styles = {"MrlMultiFilter":"MrlMultiFilter--zqSCS","MrlMultiFilter-title":"MrlMultiFilter-title--ogr0l","MrlMultiFilter-fields":"MrlMultiFilter-fields--T--TL","MrlMultiFilter-actions":"MrlMultiFilter-actions--vFqBP","MrlMultiFilter-reset":"MrlMultiFilter-reset--tnh1T"};
|
|
6
|
+
|
|
7
|
+
exports.default = styles;
|
|
8
|
+
//# sourceMappingURL=MrlMultiFilter.module.scss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MrlMultiFilter.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var utils = require('../utils.js');
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n.default = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Values of the filters, keyed by field name.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* One field of the draft.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Filters as a value and a required flag per field. Used for the draft being edited and for
|
|
37
|
+
* the applied filters.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Fields that failed validation, keyed by field name.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Whether a value counts as empty. `false` is a value, so it is not empty.
|
|
46
|
+
*
|
|
47
|
+
* @param value - The field value.
|
|
48
|
+
* @returns Whether the value is empty.
|
|
49
|
+
*/
|
|
50
|
+
var isMrlMultiFilterValueEmpty = value => value === null || value === undefined || value === '' || Array.isArray(value) && value.length === 0;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Returns the plain values of a draft, without the required flags. A common `transform`.
|
|
54
|
+
*
|
|
55
|
+
* @param draft - The draft.
|
|
56
|
+
* @returns The values, keyed by field name.
|
|
57
|
+
*/
|
|
58
|
+
var getDraftValues = draft => Object.fromEntries(Object.entries(draft).map(_ref => {
|
|
59
|
+
var _ref2 = _rollupPluginBabelHelpers.slicedToArray(_ref, 2),
|
|
60
|
+
name = _ref2[0],
|
|
61
|
+
field = _ref2[1];
|
|
62
|
+
return [name, field.value];
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Removes one field's error.
|
|
67
|
+
*
|
|
68
|
+
* @param errors - The current errors.
|
|
69
|
+
* @param name - The field name.
|
|
70
|
+
* @returns The errors without that field.
|
|
71
|
+
*/
|
|
72
|
+
var withoutError = (errors, name) => {
|
|
73
|
+
if (!errors[name]) return errors;
|
|
74
|
+
var next = _rollupPluginBabelHelpers.objectSpread2({}, errors);
|
|
75
|
+
delete next[name];
|
|
76
|
+
return next;
|
|
77
|
+
};
|
|
78
|
+
var mrlMultiFilterReducer = (state, action) => {
|
|
79
|
+
switch (action.type) {
|
|
80
|
+
case 'SET_FIELD_VALUE':
|
|
81
|
+
{
|
|
82
|
+
// Editing a field clears its error.
|
|
83
|
+
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, state), {}, {
|
|
84
|
+
draft: _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, state.draft), {}, {
|
|
85
|
+
[action.name]: _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, state.draft[action.name]), {}, {
|
|
86
|
+
value: action.value
|
|
87
|
+
})
|
|
88
|
+
}),
|
|
89
|
+
errors: withoutError(state.errors, action.name)
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
case 'SET_REQUIRED':
|
|
93
|
+
{
|
|
94
|
+
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, state), {}, {
|
|
95
|
+
draft: _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, state.draft), {}, {
|
|
96
|
+
[action.name]: _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, state.draft[action.name]), {}, {
|
|
97
|
+
required: action.required
|
|
98
|
+
})
|
|
99
|
+
}),
|
|
100
|
+
errors: action.required ? state.errors : withoutError(state.errors, action.name)
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
case 'SET_ERRORS':
|
|
104
|
+
{
|
|
105
|
+
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, state), {}, {
|
|
106
|
+
errors: action.errors
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
case 'APPLY':
|
|
110
|
+
{
|
|
111
|
+
// Controlled: the applied draft only changes when the consumer passes a new one.
|
|
112
|
+
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, state), {}, {
|
|
113
|
+
applied: action.controlled ? state.applied : state.draft,
|
|
114
|
+
errors: {}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
case 'CANCEL':
|
|
118
|
+
{
|
|
119
|
+
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, state), {}, {
|
|
120
|
+
draft: state.applied,
|
|
121
|
+
errors: {}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
case 'RESET':
|
|
125
|
+
{
|
|
126
|
+
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, state), {}, {
|
|
127
|
+
draft: action.draft,
|
|
128
|
+
errors: {}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
case 'SYNC_APPLIED':
|
|
132
|
+
{
|
|
133
|
+
return {
|
|
134
|
+
applied: action.applied,
|
|
135
|
+
draft: action.applied,
|
|
136
|
+
errors: {}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
default:
|
|
140
|
+
return state;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The context value. Every function keeps its identity across renders, so it can be passed to
|
|
146
|
+
* effects and callbacks without changing on each draft edit. `getDraft` and `validate` read the
|
|
147
|
+
* latest draft, including edits made earlier in the same event handler.
|
|
148
|
+
*/
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Context for the MrlMultiFilter component.
|
|
152
|
+
*
|
|
153
|
+
* Holds the draft (the filters being edited), the last applied draft and the validation
|
|
154
|
+
* errors. The provider wraps the trigger and the popover, outside the popover content, so the
|
|
155
|
+
* applied draft survives the popover content unmounting. It is used internally by the
|
|
156
|
+
* MrlMultiFilterContextProvider and can be accessed via the useMrlMultiFilterContext hook.
|
|
157
|
+
*/
|
|
158
|
+
var MrlMultiFilterContext = /*#__PURE__*/React__namespace.createContext(undefined);
|
|
159
|
+
/**
|
|
160
|
+
* MrlMultiFilterContextProvider component.
|
|
161
|
+
*
|
|
162
|
+
* @param props - The component props.
|
|
163
|
+
* @returns The MrlMultiFilterContextProvider component.
|
|
164
|
+
*/
|
|
165
|
+
function MrlMultiFilterContextProvider(props) {
|
|
166
|
+
var appliedDraft = props.appliedDraft,
|
|
167
|
+
children = props.children,
|
|
168
|
+
initialDraft = props.initialDraft;
|
|
169
|
+
var startDraft = appliedDraft !== null && appliedDraft !== void 0 ? appliedDraft : initialDraft;
|
|
170
|
+
/**
|
|
171
|
+
* The latest state lives in a ref, updated as soon as an action runs, and is mirrored into
|
|
172
|
+
* React state to re-render. Reading the ref lets `getDraft` and `validate` see edits made
|
|
173
|
+
* earlier in the same event handler, e.g. `setFieldValue(...); apply();`. React state alone
|
|
174
|
+
* only updates on the next render.
|
|
175
|
+
*/
|
|
176
|
+
var stateRef = React__namespace.useRef({
|
|
177
|
+
applied: startDraft,
|
|
178
|
+
draft: startDraft,
|
|
179
|
+
errors: {}
|
|
180
|
+
});
|
|
181
|
+
var _React$useState = React__namespace.useState(stateRef.current),
|
|
182
|
+
_React$useState2 = _rollupPluginBabelHelpers.slicedToArray(_React$useState, 2),
|
|
183
|
+
state = _React$useState2[0],
|
|
184
|
+
setState = _React$useState2[1];
|
|
185
|
+
var dispatch = React__namespace.useCallback(action => {
|
|
186
|
+
stateRef.current = mrlMultiFilterReducer(stateRef.current, action);
|
|
187
|
+
setState(stateRef.current);
|
|
188
|
+
}, []);
|
|
189
|
+
var fieldsRef = React__namespace.useRef(new Map());
|
|
190
|
+
|
|
191
|
+
// Controlled: the applied draft comes from the prop. Read it from the prop, not the state,
|
|
192
|
+
// so the badge does not wait for the sync below.
|
|
193
|
+
var applied = appliedDraft !== null && appliedDraft !== void 0 ? appliedDraft : state.applied;
|
|
194
|
+
|
|
195
|
+
// Controlled: a new applied draft replaces the applied draft in the state and the draft,
|
|
196
|
+
// e.g. when filters are cleared from outside the popover. Keeping it in the state lets
|
|
197
|
+
// Cancel go back to it without depending on the prop.
|
|
198
|
+
var previousAppliedDraftRef = React__namespace.useRef(appliedDraft);
|
|
199
|
+
React__namespace.useEffect(() => {
|
|
200
|
+
if (appliedDraft === previousAppliedDraftRef.current) return;
|
|
201
|
+
previousAppliedDraftRef.current = appliedDraft;
|
|
202
|
+
if (appliedDraft) dispatch({
|
|
203
|
+
applied: appliedDraft,
|
|
204
|
+
type: 'SYNC_APPLIED'
|
|
205
|
+
});
|
|
206
|
+
}, [appliedDraft, dispatch]);
|
|
207
|
+
|
|
208
|
+
// Stable: they only dispatch or read the ref. `commit` only changes when switching between controlled and
|
|
209
|
+
// uncontrolled.
|
|
210
|
+
// Same check as `applied` above, so a `null` from untyped code counts as uncontrolled.
|
|
211
|
+
var controlled = appliedDraft != null;
|
|
212
|
+
var commit = React__namespace.useCallback(() => dispatch({
|
|
213
|
+
controlled,
|
|
214
|
+
type: 'APPLY'
|
|
215
|
+
}), [controlled, dispatch]);
|
|
216
|
+
var discard = React__namespace.useCallback(() => dispatch({
|
|
217
|
+
type: 'CANCEL'
|
|
218
|
+
}), [dispatch]);
|
|
219
|
+
var getDraft = React__namespace.useCallback(() => stateRef.current.draft, []);
|
|
220
|
+
var reset = React__namespace.useCallback(draft => dispatch({
|
|
221
|
+
draft,
|
|
222
|
+
type: 'RESET'
|
|
223
|
+
}), [dispatch]);
|
|
224
|
+
var setFieldValue = React__namespace.useCallback((name, value) => dispatch({
|
|
225
|
+
name,
|
|
226
|
+
type: 'SET_FIELD_VALUE',
|
|
227
|
+
value
|
|
228
|
+
}), [dispatch]);
|
|
229
|
+
var setRequired = React__namespace.useCallback((name, required) => dispatch({
|
|
230
|
+
name,
|
|
231
|
+
required,
|
|
232
|
+
type: 'SET_REQUIRED'
|
|
233
|
+
}), [dispatch]);
|
|
234
|
+
|
|
235
|
+
// Stable, so fields do not re-register on every draft change.
|
|
236
|
+
var registerField = React__namespace.useCallback((name, element) => {
|
|
237
|
+
fieldsRef.current.set(name, element);
|
|
238
|
+
return () => {
|
|
239
|
+
if (fieldsRef.current.get(name) === element) fieldsRef.current.delete(name);
|
|
240
|
+
};
|
|
241
|
+
}, []);
|
|
242
|
+
var validate = React__namespace.useCallback(() => {
|
|
243
|
+
var draft = stateRef.current.draft;
|
|
244
|
+
var errors = {};
|
|
245
|
+
Object.keys(draft).forEach(name => {
|
|
246
|
+
var field = draft[name];
|
|
247
|
+
if (field.required && isMrlMultiFilterValueEmpty(field.value)) errors[name] = true;
|
|
248
|
+
});
|
|
249
|
+
dispatch({
|
|
250
|
+
errors,
|
|
251
|
+
type: 'SET_ERRORS'
|
|
252
|
+
});
|
|
253
|
+
utils.focusFirstInvalidField(fieldsRef.current, errors);
|
|
254
|
+
return Object.keys(errors).length === 0;
|
|
255
|
+
}, [dispatch]);
|
|
256
|
+
var contextValue = React__namespace.useMemo(() => _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, state), {}, {
|
|
257
|
+
applied,
|
|
258
|
+
commit,
|
|
259
|
+
discard,
|
|
260
|
+
getDraft,
|
|
261
|
+
registerField,
|
|
262
|
+
reset,
|
|
263
|
+
setFieldValue,
|
|
264
|
+
setRequired,
|
|
265
|
+
validate
|
|
266
|
+
}), [applied, commit, discard, getDraft, registerField, reset, setFieldValue, setRequired, state, validate]);
|
|
267
|
+
return /*#__PURE__*/React__namespace.createElement(MrlMultiFilterContext.Provider, {
|
|
268
|
+
value: contextValue
|
|
269
|
+
}, children);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Custom hook to use the MrlMultiFilterContext.
|
|
274
|
+
*
|
|
275
|
+
* This hook provides access to the MrlMultiFilterContext value. React context cannot be
|
|
276
|
+
* generic, so pass the filter values type to get a typed draft.
|
|
277
|
+
*
|
|
278
|
+
* @returns The MrlMultiFilterContext value.
|
|
279
|
+
* @throws Will throw an error if used outside of a MrlMultiFilterContextProvider.
|
|
280
|
+
*/
|
|
281
|
+
var useMrlMultiFilterContext = () => {
|
|
282
|
+
var context = React__namespace.useContext(MrlMultiFilterContext);
|
|
283
|
+
if (!context) {
|
|
284
|
+
throw new Error('useMrlMultiFilterContext must be used within a MrlMultiFilterContextProvider');
|
|
285
|
+
}
|
|
286
|
+
return context;
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Same as useMrlMultiFilterContext, but returns `undefined` outside a provider, so
|
|
291
|
+
* MrlMultiFilterField also works on its own.
|
|
292
|
+
*
|
|
293
|
+
* @returns The MrlMultiFilterContext value, or `undefined`.
|
|
294
|
+
*/
|
|
295
|
+
var useOptionalMrlMultiFilterContext = () => React__namespace.useContext(MrlMultiFilterContext);
|
|
296
|
+
|
|
297
|
+
exports.MrlMultiFilterContextProvider = MrlMultiFilterContextProvider;
|
|
298
|
+
exports.getDraftValues = getDraftValues;
|
|
299
|
+
exports.isMrlMultiFilterValueEmpty = isMrlMultiFilterValueEmpty;
|
|
300
|
+
exports.useMrlMultiFilterContext = useMrlMultiFilterContext;
|
|
301
|
+
exports.useOptionalMrlMultiFilterContext = useOptionalMrlMultiFilterContext;
|
|
302
|
+
//# sourceMappingURL=MrlMultiFilterContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MrlMultiFilterContext.js","sources":["../../../../../src/components/multi-filter/MrlMultiFilterContext/MrlMultiFilterContext.tsx"],"sourcesContent":["import * as React from 'react';\nimport { focusFirstInvalidField } from '../utils';\n\n/**\n * Values of the filters, keyed by field name.\n */\nexport type MrlMultiFilterValues = Record<string, unknown>;\n\n/**\n * One field of the draft.\n */\nexport type MrlMultiFilterDraftField<V> = {\n\t/**\n\t * Whether Apply is blocked while the value is empty (`null`, `undefined`, `''` or `[]`;\n\t * `false` is not empty). Defaults to `false`. Change it at runtime with `setRequired`.\n\t */\n\trequired?: boolean;\n\t/**\n\t * The field's value.\n\t */\n\tvalue: V;\n};\n\n/**\n * Filters as a value and a required flag per field. Used for the draft being edited and for\n * the applied filters.\n */\nexport type MrlMultiFilterDraft<T extends MrlMultiFilterValues> = {\n\t[K in keyof T]: MrlMultiFilterDraftField<T[K]>;\n};\n\n/**\n * Fields that failed validation, keyed by field name.\n */\nexport type MrlMultiFilterErrors<T extends MrlMultiFilterValues> = Partial<Record<keyof T, true>>;\n\ntype MrlMultiFilterState<T extends MrlMultiFilterValues> = {\n\t/**\n\t * The last applied draft. Cancel sets the draft back to it. When controlled, it follows\n\t * `appliedDraft`.\n\t */\n\tapplied: MrlMultiFilterDraft<T>;\n\t/**\n\t * The draft being edited. MrlMultiFilter sets it back to the applied draft on each open.\n\t */\n\tdraft: MrlMultiFilterDraft<T>;\n\t/**\n\t * Fields that failed validation.\n\t */\n\terrors: MrlMultiFilterErrors<T>;\n};\n\ntype MrlMultiFilterAction<T extends MrlMultiFilterValues> =\n\t| { name: keyof T; type: 'SET_FIELD_VALUE'; value: T[keyof T] }\n\t| { name: keyof T; required: boolean; type: 'SET_REQUIRED' }\n\t| { errors: MrlMultiFilterErrors<T>; type: 'SET_ERRORS' }\n\t| { controlled: boolean; type: 'APPLY' }\n\t| { type: 'CANCEL' }\n\t| { draft: MrlMultiFilterDraft<T>; type: 'RESET' }\n\t| { applied: MrlMultiFilterDraft<T>; type: 'SYNC_APPLIED' };\n\n/**\n * Whether a value counts as empty. `false` is a value, so it is not empty.\n *\n * @param value - The field value.\n * @returns Whether the value is empty.\n */\nexport const isMrlMultiFilterValueEmpty = (value: unknown): boolean =>\n\tvalue === null ||\n\tvalue === undefined ||\n\tvalue === '' ||\n\t(Array.isArray(value) && value.length === 0);\n\n/**\n * Returns the plain values of a draft, without the required flags. A common `transform`.\n *\n * @param draft - The draft.\n * @returns The values, keyed by field name.\n */\nexport const getDraftValues = <T extends MrlMultiFilterValues>(draft: MrlMultiFilterDraft<T>): T =>\n\tObject.fromEntries(\n\t\tObject.entries(draft).map(([name, field]) => [\n\t\t\tname,\n\t\t\t(field as MrlMultiFilterDraftField<unknown>).value\n\t\t])\n\t) as T;\n\n/**\n * Removes one field's error.\n *\n * @param errors - The current errors.\n * @param name - The field name.\n * @returns The errors without that field.\n */\nconst withoutError = <T extends MrlMultiFilterValues>(\n\terrors: MrlMultiFilterErrors<T>,\n\tname: keyof T\n): MrlMultiFilterErrors<T> => {\n\tif (!errors[name]) return errors;\n\tconst next = { ...errors };\n\tdelete next[name];\n\treturn next;\n};\n\nconst mrlMultiFilterReducer = <T extends MrlMultiFilterValues>(\n\tstate: MrlMultiFilterState<T>,\n\taction: MrlMultiFilterAction<T>\n): MrlMultiFilterState<T> => {\n\tswitch (action.type) {\n\t\tcase 'SET_FIELD_VALUE': {\n\t\t\t// Editing a field clears its error.\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tdraft: {\n\t\t\t\t\t...state.draft,\n\t\t\t\t\t[action.name]: { ...state.draft[action.name], value: action.value }\n\t\t\t\t},\n\t\t\t\terrors: withoutError(state.errors, action.name)\n\t\t\t};\n\t\t}\n\t\tcase 'SET_REQUIRED': {\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tdraft: {\n\t\t\t\t\t...state.draft,\n\t\t\t\t\t[action.name]: { ...state.draft[action.name], required: action.required }\n\t\t\t\t},\n\t\t\t\terrors: action.required ? state.errors : withoutError(state.errors, action.name)\n\t\t\t};\n\t\t}\n\t\tcase 'SET_ERRORS': {\n\t\t\treturn { ...state, errors: action.errors };\n\t\t}\n\t\tcase 'APPLY': {\n\t\t\t// Controlled: the applied draft only changes when the consumer passes a new one.\n\t\t\treturn { ...state, applied: action.controlled ? state.applied : state.draft, errors: {} };\n\t\t}\n\t\tcase 'CANCEL': {\n\t\t\treturn { ...state, draft: state.applied, errors: {} };\n\t\t}\n\t\tcase 'RESET': {\n\t\t\treturn { ...state, draft: action.draft, errors: {} };\n\t\t}\n\t\tcase 'SYNC_APPLIED': {\n\t\t\treturn { applied: action.applied, draft: action.applied, errors: {} };\n\t\t}\n\t\tdefault:\n\t\t\treturn state;\n\t}\n};\n\n/**\n * The context value. Every function keeps its identity across renders, so it can be passed to\n * effects and callbacks without changing on each draft edit. `getDraft` and `validate` read the\n * latest draft, including edits made earlier in the same event handler.\n */\nexport type MrlMultiFilterContextValue<T extends MrlMultiFilterValues> = MrlMultiFilterState<T> & {\n\t/**\n\t * Saves the draft as the applied one and clears the errors. Call `validate` first.\n\t */\n\tcommit: () => void;\n\t/**\n\t * Sets the draft back to the last applied draft and clears the errors.\n\t */\n\tdiscard: () => void;\n\t/**\n\t * Returns the latest draft. Unlike `draft`, it includes edits made earlier in the same event\n\t * handler, before React re-renders.\n\t */\n\tgetDraft: () => MrlMultiFilterDraft<T>;\n\t/**\n\t * Registers a field's element, so validation can focus it. Returns a function that\n\t * unregisters it.\n\t */\n\tregisterField: (name: keyof T, element: HTMLElement) => () => void;\n\t/**\n\t * Replaces the draft and clears the errors.\n\t */\n\treset: (draft: MrlMultiFilterDraft<T>) => void;\n\t/**\n\t * Updates one field's value in the draft and clears its error.\n\t */\n\tsetFieldValue: <K extends keyof T>(name: K, value: T[K]) => void;\n\t/**\n\t * Updates one field's required flag in the draft. Turning it off clears the field's error.\n\t */\n\tsetRequired: (name: keyof T, required: boolean) => void;\n\t/**\n\t * Checks the required fields of the latest draft. Marks the empty ones and focuses the first\n\t * of them.\n\t *\n\t * @returns Whether the draft is valid.\n\t */\n\tvalidate: () => boolean;\n};\n\n/**\n * Context for the MrlMultiFilter component.\n *\n * Holds the draft (the filters being edited), the last applied draft and the validation\n * errors. The provider wraps the trigger and the popover, outside the popover content, so the\n * applied draft survives the popover content unmounting. It is used internally by the\n * MrlMultiFilterContextProvider and can be accessed via the useMrlMultiFilterContext hook.\n */\nconst MrlMultiFilterContext = React.createContext<\n\tMrlMultiFilterContextValue<MrlMultiFilterValues> | undefined\n>(undefined);\n\ntype MrlMultiFilterContextProviderProps<T extends MrlMultiFilterValues> = {\n\t/**\n\t * Controls the applied draft. When it changes, the draft is replaced by it, dropping any\n\t * unapplied edits. When omitted, the provider keeps the applied draft itself.\n\t */\n\tappliedDraft?: MrlMultiFilterDraft<T>;\n\tchildren: React.ReactNode;\n\t/**\n\t * The draft and the applied draft start from it, unless `appliedDraft` is given. Later\n\t * changes are ignored.\n\t */\n\tinitialDraft: MrlMultiFilterDraft<T>;\n};\n\n/**\n * MrlMultiFilterContextProvider component.\n *\n * @param props - The component props.\n * @returns The MrlMultiFilterContextProvider component.\n */\nexport function MrlMultiFilterContextProvider<T extends MrlMultiFilterValues>(\n\tprops: MrlMultiFilterContextProviderProps<T>\n): JSX.Element {\n\tconst { appliedDraft, children, initialDraft } = props;\n\n\tconst startDraft = appliedDraft ?? initialDraft;\n\t/**\n\t * The latest state lives in a ref, updated as soon as an action runs, and is mirrored into\n\t * React state to re-render. Reading the ref lets `getDraft` and `validate` see edits made\n\t * earlier in the same event handler, e.g. `setFieldValue(...); apply();`. React state alone\n\t * only updates on the next render.\n\t */\n\tconst stateRef = React.useRef<MrlMultiFilterState<T>>({\n\t\tapplied: startDraft,\n\t\tdraft: startDraft,\n\t\terrors: {}\n\t});\n\tconst [state, setState] = React.useState(stateRef.current);\n\tconst dispatch = React.useCallback((action: MrlMultiFilterAction<T>) => {\n\t\tstateRef.current = mrlMultiFilterReducer(stateRef.current, action);\n\t\tsetState(stateRef.current);\n\t}, []);\n\tconst fieldsRef = React.useRef(new Map<keyof T, HTMLElement>());\n\n\t// Controlled: the applied draft comes from the prop. Read it from the prop, not the state,\n\t// so the badge does not wait for the sync below.\n\tconst applied = appliedDraft ?? state.applied;\n\n\t// Controlled: a new applied draft replaces the applied draft in the state and the draft,\n\t// e.g. when filters are cleared from outside the popover. Keeping it in the state lets\n\t// Cancel go back to it without depending on the prop.\n\tconst previousAppliedDraftRef = React.useRef(appliedDraft);\n\tReact.useEffect(() => {\n\t\tif (appliedDraft === previousAppliedDraftRef.current) return;\n\t\tpreviousAppliedDraftRef.current = appliedDraft;\n\t\tif (appliedDraft) dispatch({ applied: appliedDraft, type: 'SYNC_APPLIED' });\n\t}, [appliedDraft, dispatch]);\n\n\t// Stable: they only dispatch or read the ref. `commit` only changes when switching between controlled and\n\t// uncontrolled.\n\t// Same check as `applied` above, so a `null` from untyped code counts as uncontrolled.\n\tconst controlled = appliedDraft != null;\n\tconst commit = React.useCallback(\n\t\t() => dispatch({ controlled, type: 'APPLY' }),\n\t\t[controlled, dispatch]\n\t);\n\tconst discard = React.useCallback(() => dispatch({ type: 'CANCEL' }), [dispatch]);\n\tconst getDraft = React.useCallback(() => stateRef.current.draft, []);\n\tconst reset = React.useCallback(\n\t\t(draft: MrlMultiFilterDraft<T>) => dispatch({ draft, type: 'RESET' }),\n\t\t[dispatch]\n\t);\n\tconst setFieldValue = React.useCallback(\n\t\t<K extends keyof T>(name: K, value: T[K]) => dispatch({ name, type: 'SET_FIELD_VALUE', value }),\n\t\t[dispatch]\n\t);\n\tconst setRequired = React.useCallback(\n\t\t(name: keyof T, required: boolean) => dispatch({ name, required, type: 'SET_REQUIRED' }),\n\t\t[dispatch]\n\t);\n\n\t// Stable, so fields do not re-register on every draft change.\n\tconst registerField = React.useCallback((name: keyof T, element: HTMLElement) => {\n\t\tfieldsRef.current.set(name, element);\n\t\treturn () => {\n\t\t\tif (fieldsRef.current.get(name) === element) fieldsRef.current.delete(name);\n\t\t};\n\t}, []);\n\n\tconst validate = React.useCallback(() => {\n\t\tconst { draft } = stateRef.current;\n\t\tconst errors: MrlMultiFilterErrors<T> = {};\n\t\t(Object.keys(draft) as (keyof T)[]).forEach((name) => {\n\t\t\tconst field = draft[name];\n\t\t\tif (field.required && isMrlMultiFilterValueEmpty(field.value)) errors[name] = true;\n\t\t});\n\t\tdispatch({ errors, type: 'SET_ERRORS' });\n\n\t\tfocusFirstInvalidField(fieldsRef.current, errors);\n\n\t\treturn Object.keys(errors).length === 0;\n\t}, [dispatch]);\n\n\tconst contextValue = React.useMemo<MrlMultiFilterContextValue<T>>(\n\t\t() => ({\n\t\t\t...state,\n\t\t\tapplied,\n\t\t\tcommit,\n\t\t\tdiscard,\n\t\t\tgetDraft,\n\t\t\tregisterField,\n\t\t\treset,\n\t\t\tsetFieldValue,\n\t\t\tsetRequired,\n\t\t\tvalidate\n\t\t}),\n\t\t[\n\t\t\tapplied,\n\t\t\tcommit,\n\t\t\tdiscard,\n\t\t\tgetDraft,\n\t\t\tregisterField,\n\t\t\treset,\n\t\t\tsetFieldValue,\n\t\t\tsetRequired,\n\t\t\tstate,\n\t\t\tvalidate\n\t\t]\n\t);\n\n\treturn (\n\t\t<MrlMultiFilterContext.Provider\n\t\t\tvalue={contextValue as unknown as MrlMultiFilterContextValue<MrlMultiFilterValues>}\n\t\t>\n\t\t\t{children}\n\t\t</MrlMultiFilterContext.Provider>\n\t);\n}\n\n/**\n * Custom hook to use the MrlMultiFilterContext.\n *\n * This hook provides access to the MrlMultiFilterContext value. React context cannot be\n * generic, so pass the filter values type to get a typed draft.\n *\n * @returns The MrlMultiFilterContext value.\n * @throws Will throw an error if used outside of a MrlMultiFilterContextProvider.\n */\nexport const useMrlMultiFilterContext = <\n\tT extends MrlMultiFilterValues = MrlMultiFilterValues\n>(): MrlMultiFilterContextValue<T> => {\n\tconst context = React.useContext(MrlMultiFilterContext);\n\tif (!context) {\n\t\tthrow new Error('useMrlMultiFilterContext must be used within a MrlMultiFilterContextProvider');\n\t}\n\treturn context as unknown as MrlMultiFilterContextValue<T>;\n};\n\n/**\n * Same as useMrlMultiFilterContext, but returns `undefined` outside a provider, so\n * MrlMultiFilterField also works on its own.\n *\n * @returns The MrlMultiFilterContext value, or `undefined`.\n */\nexport const useOptionalMrlMultiFilterContext = ():\n\t| MrlMultiFilterContextValue<MrlMultiFilterValues>\n\t| undefined => React.useContext(MrlMultiFilterContext);\n"],"names":["isMrlMultiFilterValueEmpty","value","undefined","Array","isArray","length","getDraftValues","draft","Object","fromEntries","entries","map","_ref","_ref2","_slicedToArray","name","field","withoutError","errors","next","_objectSpread","mrlMultiFilterReducer","state","action","type","required","applied","controlled","MrlMultiFilterContext","React","createContext","MrlMultiFilterContextProvider","props","appliedDraft","children","initialDraft","startDraft","stateRef","useRef","_React$useState","useState","current","_React$useState2","setState","dispatch","useCallback","fieldsRef","Map","previousAppliedDraftRef","useEffect","commit","discard","getDraft","reset","setFieldValue","setRequired","registerField","element","set","get","delete","validate","keys","forEach","focusFirstInvalidField","contextValue","useMemo","createElement","Provider","useMrlMultiFilterContext","context","useContext","Error","useOptionalMrlMultiFilterContext"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AACA;;AAKA;AACA;AACA;;AA4BA;AACA;AACA;AACA;AACA;AACA;AACO,IAAMA,0BAA0B,GAAIC,KAAc,IACxDA,KAAK,KAAK,IAAI,IACdA,KAAK,KAAKC,SAAS,IACnBD,KAAK,KAAK,EAAE,IACXE,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAIA,KAAK,CAACI,MAAM,KAAK;;AAE3C;AACA;AACA;AACA;AACA;AACA;IACaC,cAAc,GAAoCC,KAA6B,IAC3FC,MAAM,CAACC,WAAW,CACjBD,MAAM,CAACE,OAAO,CAACH,KAAK,CAAC,CAACI,GAAG,CAACC,IAAA,IAAA;AAAA,EAAA,IAAAC,KAAA,GAAAC,uCAA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