@stenajs-webui/filter 17.13.2 → 17.13.3

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/index.es.js CHANGED
@@ -1,497 +1,493 @@
1
- (function(){ try {var elementStyle = document.createElement('style'); elementStyle.appendChild(document.createTextNode("")); document.head.appendChild(elementStyle);} catch(e) {console.error('vite-plugin-css-injected-by-js', e);} })();import { createContext, useContext, useCallback, useState, useReducer, useMemo } from "react";
2
- import { Drawer } from "@stenajs-webui/modal";
3
- import { cssColor } from "@stenajs-webui/theme";
4
- import { Row, Indent, Heading, Column, SeparatorLine, truthyKeysAsList, Text, Box } from "@stenajs-webui/core";
5
- import { Icon, SecondaryButton, stenaTimes, stenaSliders, Spinner, Banner, FlatButton, Chip } from "@stenajs-webui/elements";
6
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
7
- import { Collapsible, CollapsibleContent, CollapsibleClickableContent } from "@stenajs-webui/panels";
8
- import { upperFirst, lowerCase } from "lodash";
9
- import { combineReducers } from "redux";
10
- import { reducerIdGate, createValueByIdReducer, createEntityReducer, reducerIdGateAction, createEntityActions, createValueByIdActions } from "@stenajs-webui/redux";
11
- import styled from "@emotion/styled";
12
- import { Checkbox } from "@stenajs-webui/forms";
13
- import { ChipMultiSelect } from "@stenajs-webui/select";
14
- import { stringsToDateRange, dateRangeToStrings, DateRangeCalendar } from "@stenajs-webui/calendar";
15
- const SearchFilterPanelHeader = ({
16
- onRequestClose,
17
- header = "Filters",
18
- headerIcon = stenaSliders
19
- }) => {
20
- return /* @__PURE__ */ jsxs(Row, {
21
- height: "56px",
22
- justifyContent: "space-between",
1
+ (function(){"use strict";try{var e=document.createElement("style");e.appendChild(document.createTextNode("")),document.head.appendChild(e)}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
+ import { createContext as b, useContext as E, useCallback as u, useState as R, useReducer as U, useMemo as v } from "react";
3
+ import { Drawer as X } from "@stenajs-webui/modal";
4
+ import { cssColor as H } from "@stenajs-webui/theme";
5
+ import { Row as M, Indent as Z, Heading as _, Column as T, SeparatorLine as N, truthyKeysAsList as j, Text as ee, Box as A } from "@stenajs-webui/core";
6
+ import { Icon as te, SecondaryButton as $, stenaTimes as ne, stenaSliders as z, Spinner as re, Banner as oe, FlatButton as D, Chip as q } from "@stenajs-webui/elements";
7
+ import { jsxs as L, jsx as c, Fragment as ce } from "react/jsx-runtime";
8
+ import { Collapsible as se, CollapsibleContent as P, CollapsibleClickableContent as ie } from "@stenajs-webui/panels";
9
+ import { upperFirst as le, lowerCase as ae } from "lodash";
10
+ import { combineReducers as de } from "redux";
11
+ import { reducerIdGate as k, createValueByIdReducer as ue, createEntityReducer as V, reducerIdGateAction as C, createEntityActions as g, createValueByIdActions as w } from "@stenajs-webui/redux";
12
+ import he from "@emotion/styled";
13
+ import { Checkbox as pe } from "@stenajs-webui/forms";
14
+ import { ChipMultiSelect as Ce } from "@stenajs-webui/select";
15
+ import { stringsToDateRange as Se, dateRangeToStrings as fe, DateRangeCalendar as me } from "@stenajs-webui/calendar";
16
+ const Fe = ({
17
+ onRequestClose: e,
18
+ header: t = "Filters",
19
+ headerIcon: n = z
20
+ }) => /* @__PURE__ */ L(M, {
21
+ height: "56px",
22
+ justifyContent: "space-between",
23
+ alignItems: "center",
24
+ indent: 2,
25
+ children: [/* @__PURE__ */ L(M, {
23
26
  alignItems: "center",
24
- indent: 2,
25
- children: [/* @__PURE__ */ jsxs(Row, {
26
- alignItems: "center",
27
- children: [/* @__PURE__ */ jsx(Icon, {
28
- icon: headerIcon,
29
- color: cssColor("--lhds-color-ui-800"),
30
- size: 24
31
- }), /* @__PURE__ */ jsx(Indent, {}), /* @__PURE__ */ jsx(Heading, {
32
- variant: "h4",
33
- children: header
34
- })]
35
- }), /* @__PURE__ */ jsx(SecondaryButton, {
36
- leftIcon: stenaTimes,
37
- onClick: onRequestClose
27
+ children: [/* @__PURE__ */ c(te, {
28
+ icon: n,
29
+ color: H("--lhds-color-ui-800"),
30
+ size: 24
31
+ }), /* @__PURE__ */ c(Z, {}), /* @__PURE__ */ c(_, {
32
+ variant: "h4",
33
+ children: t
38
34
  })]
39
- });
40
- };
41
- const SearchFilterStateContext = createContext(null);
42
- const useSearchFilterState = () => {
43
- const c = useContext(SearchFilterStateContext);
44
- if (!c) {
45
- throw new Error("Missing search filter context, wrap components with SearchFilterContext component.");
46
- }
47
- return c;
48
- };
49
- const SearchFilterDispatchContext = createContext(null);
50
- const useSearchFilterDispatch = () => {
51
- const c = useContext(SearchFilterDispatchContext);
52
- if (!c) {
35
+ }), /* @__PURE__ */ c($, {
36
+ leftIcon: ne,
37
+ onClick: e
38
+ })]
39
+ }), G = b(null), I = () => {
40
+ const e = E(G);
41
+ if (!e)
42
+ throw new Error(
43
+ "Missing search filter context, wrap components with SearchFilterContext component."
44
+ );
45
+ return e;
46
+ }, K = b(null), f = () => {
47
+ const e = E(K);
48
+ if (!e)
53
49
  throw new Error("Missing search filter dispatch context.");
54
- }
55
- return c;
56
- };
57
- const SearchFilterActionsContext = createContext(null);
58
- const useSearchFilterActions = () => {
59
- const c = useContext(SearchFilterActionsContext);
60
- if (!c) {
50
+ return e;
51
+ }, W = b(null), m = () => {
52
+ const e = E(W);
53
+ if (!e)
61
54
  throw new Error("Missing search filter actions context.");
62
- }
63
- return c;
64
- };
65
- const SearchFilterDrawer = ({
66
- children,
67
- header,
68
- headerIcon,
69
- ...drawerProps
55
+ return e;
56
+ }, Ye = ({
57
+ children: e,
58
+ header: t,
59
+ headerIcon: n,
60
+ ...r
70
61
  }) => {
71
62
  const {
72
63
  settings: {
73
- open
64
+ open: o
74
65
  }
75
- } = useSearchFilterState();
76
- const dispatch = useSearchFilterDispatch();
77
- const actions = useSearchFilterActions();
78
- const closeDrawer = useCallback(() => {
79
- dispatch(actions.closeFilters());
80
- }, [actions, dispatch]);
81
- return /* @__PURE__ */ jsx(Drawer, {
82
- background: cssColor("--lhds-color-ui-50"),
66
+ } = I(), s = f(), i = m(), a = u(() => {
67
+ s(i.closeFilters());
68
+ }, [i, s]);
69
+ return /* @__PURE__ */ c(X, {
70
+ background: H("--lhds-color-ui-50"),
83
71
  width: "370px",
84
- isOpen: open,
85
- onRequestClose: closeDrawer,
86
- ...drawerProps,
87
- children: /* @__PURE__ */ jsxs(Column, {
88
- children: [/* @__PURE__ */ jsx(SearchFilterPanelHeader, {
89
- onRequestClose: closeDrawer,
90
- header,
91
- headerIcon
92
- }), /* @__PURE__ */ jsx(SeparatorLine, {}), children]
72
+ isOpen: o,
73
+ onRequestClose: a,
74
+ ...r,
75
+ children: /* @__PURE__ */ L(T, {
76
+ children: [/* @__PURE__ */ c(Fe, {
77
+ onRequestClose: a,
78
+ header: t,
79
+ headerIcon: n
80
+ }), /* @__PURE__ */ c(N, {}), e]
93
81
  })
94
82
  });
95
- };
96
- const SearchFilterButton = ({
97
- label = "Filters",
98
- leftIcon = stenaSliders
83
+ }, Je = ({
84
+ label: e = "Filters",
85
+ leftIcon: t = z
99
86
  }) => {
100
- const dispatch = useSearchFilterDispatch();
101
- const actions = useSearchFilterActions();
102
- const onClickButton = useCallback(() => {
103
- dispatch(actions.openFilters());
104
- }, [actions, dispatch]);
105
- return /* @__PURE__ */ jsx(SecondaryButton, {
106
- label,
107
- leftIcon,
108
- onClick: onClickButton
87
+ const n = f(), r = m(), o = u(() => {
88
+ n(r.openFilters());
89
+ }, [r, n]);
90
+ return /* @__PURE__ */ c($, {
91
+ label: e,
92
+ leftIcon: t,
93
+ onClick: o
109
94
  });
110
- };
111
- const SearchFilterSection = function SearchFilterSection2({
112
- sectionId,
113
- label,
114
- contentLeft,
115
- contentRight,
116
- loading,
117
- error,
118
- onRetry,
119
- disableContentPadding,
120
- children
95
+ }, y = function({
96
+ sectionId: t,
97
+ label: n,
98
+ contentLeft: r,
99
+ contentRight: o,
100
+ loading: s,
101
+ error: i,
102
+ onRetry: a,
103
+ disableContentPadding: S,
104
+ children: h
121
105
  }) {
122
- var _a;
123
- const state = useSearchFilterState();
124
- const dispatch = useSearchFilterDispatch();
125
- const actions = useSearchFilterActions();
126
- const expanded = (_a = state.expandedSections.values[sectionId]) != null ? _a : false;
127
- const onClickLabel = useCallback(() => {
128
- dispatch(actions.setSectionExpanded(sectionId, !expanded));
129
- }, [actions, dispatch, expanded, sectionId]);
130
- const activeLabel = label != null ? label : formatColumnIdToHeaderCellLabel(sectionId);
131
- return /* @__PURE__ */ jsx(Collapsible, {
132
- label: activeLabel,
133
- collapsed: !expanded,
134
- onClick: onClickLabel,
135
- contentLeft,
136
- contentRight,
137
- children: loading ? /* @__PURE__ */ jsx(CollapsibleContent, {
138
- children: /* @__PURE__ */ jsx(Row, {
139
- spacing: true,
106
+ var O;
107
+ const l = I(), p = f(), F = m(), x = (O = l.expandedSections.values[t]) != null ? O : !1, J = u(() => {
108
+ p(F.setSectionExpanded(t, !x));
109
+ }, [F, p, x, t]), Q = n != null ? n : xe(t);
110
+ return /* @__PURE__ */ c(se, {
111
+ label: Q,
112
+ collapsed: !x,
113
+ onClick: J,
114
+ contentLeft: r,
115
+ contentRight: o,
116
+ children: s ? /* @__PURE__ */ c(P, {
117
+ children: /* @__PURE__ */ c(M, {
118
+ spacing: !0,
140
119
  justifyContent: "center",
141
120
  flex: 1,
142
- children: /* @__PURE__ */ jsx(Spinner, {
121
+ children: /* @__PURE__ */ c(re, {
143
122
  size: "small"
144
123
  })
145
124
  })
146
- }) : error ? /* @__PURE__ */ jsx(Banner, {
125
+ }) : i ? /* @__PURE__ */ c(oe, {
147
126
  variant: "error",
148
- text: error,
149
- contentRight: onRetry ? /* @__PURE__ */ jsx(FlatButton, {
127
+ text: i,
128
+ contentRight: a ? /* @__PURE__ */ c(D, {
150
129
  label: "Retry",
151
- onClick: onRetry
130
+ onClick: a
152
131
  }) : null
153
- }) : disableContentPadding ? children : /* @__PURE__ */ jsx(CollapsibleContent, {
154
- children
132
+ }) : S ? h : /* @__PURE__ */ c(P, {
133
+ children: h
155
134
  })
156
135
  });
157
- };
158
- const formatColumnIdToHeaderCellLabel = (columnId) => upperFirst(lowerCase(columnId));
159
- const SearchFilterModelContext = createContext(null);
160
- const useSearchFilterModel = () => {
161
- const c = useContext(SearchFilterModelContext);
162
- if (!c) {
163
- throw new Error("Missing search filter context, wrap components with SearchFilterContext component.");
164
- }
165
- return c;
166
- };
167
- const SearchFilterContext = function SearchFilterScope({
168
- state,
169
- dispatch,
170
- actions,
171
- children
136
+ }, xe = (e) => le(ae(e)), Y = b(null), Qe = () => {
137
+ const e = E(Y);
138
+ if (!e)
139
+ throw new Error(
140
+ "Missing search filter context, wrap components with SearchFilterContext component."
141
+ );
142
+ return e;
143
+ }, ge = function({
144
+ state: t,
145
+ dispatch: n,
146
+ actions: r,
147
+ children: o
172
148
  }) {
173
- return /* @__PURE__ */ jsx(SearchFilterDispatchContext.Provider, {
174
- value: dispatch,
175
- children: /* @__PURE__ */ jsx(SearchFilterActionsContext.Provider, {
176
- value: actions,
177
- children: /* @__PURE__ */ jsx(SearchFilterStateContext.Provider, {
178
- value: state,
179
- children: /* @__PURE__ */ jsx(SearchFilterModelContext.Provider, {
180
- value: state.formModel,
181
- children
149
+ return /* @__PURE__ */ c(K.Provider, {
150
+ value: n,
151
+ children: /* @__PURE__ */ c(W.Provider, {
152
+ value: r,
153
+ children: /* @__PURE__ */ c(G.Provider, {
154
+ value: t,
155
+ children: /* @__PURE__ */ c(Y.Provider, {
156
+ value: t.formModel,
157
+ children: o
182
158
  })
183
159
  })
184
160
  })
185
161
  });
186
- };
187
- const createSearchFilterInitialState = (initialFormModel) => ({
162
+ }, we = (e) => ({
188
163
  settings: {
189
- open: false
164
+ open: !1
190
165
  },
191
- formModel: initialFormModel,
166
+ formModel: e,
192
167
  expandedSections: { values: {} }
193
- });
194
- const createSearchFilterReducer = (reducerId, initialState) => combineReducers({
195
- expandedSections: reducerIdGate(getReducerIdFor(reducerId, "expandedSections"), createValueByIdReducer(initialState.expandedSections)),
196
- formModel: reducerIdGate(getReducerIdFor(reducerId, "formModel"), createEntityReducer(initialState.formModel)),
197
- settings: reducerIdGate(getReducerIdFor(reducerId, "settings"), createEntityReducer(initialState.settings))
198
- });
199
- const createSearchFilterActions = (reducerId, initialFormModel) => ({
200
- openFilters: () => reducerIdGateAction(getReducerIdFor(reducerId, "settings"), createEntityActions().setEntityFields({
201
- open: true
202
- })),
203
- closeFilters: () => reducerIdGateAction(getReducerIdFor(reducerId, "settings"), createEntityActions().setEntityFields({
204
- open: false
205
- })),
206
- setFormModelFields: (fields) => reducerIdGateAction(getReducerIdFor(reducerId, "formModel"), createEntityActions().setEntityFields(fields)),
207
- clearFormModel: () => reducerIdGateAction(getReducerIdFor(reducerId, "formModel"), createEntityActions().setEntity(initialFormModel)),
208
- expandSection: (section) => reducerIdGateAction(getReducerIdFor(reducerId, "expandedSections"), createValueByIdActions().setValue(section, true)),
209
- collapseSection: (section) => reducerIdGateAction(getReducerIdFor(reducerId, "expandedSections"), createValueByIdActions().setValue(section, false)),
210
- setSectionExpanded: (section, expanded) => reducerIdGateAction(getReducerIdFor(reducerId, "expandedSections"), createValueByIdActions().setValue(section, expanded)),
211
- clearExpandedSections: () => reducerIdGateAction(getReducerIdFor(reducerId, "expandedSections"), createValueByIdActions().clearAllValues())
212
- });
213
- const getReducerIdFor = (reducerId, reducerIdSuffix) => `${reducerId}.${reducerIdSuffix}`;
214
- const useLocalSearchFilterState = (initialState) => {
215
- const [reducer] = useState(() => createSearchFilterReducer("local", initialState));
216
- const [actions] = useState(() => createSearchFilterActions("local", initialState.formModel));
217
- const [state, dispatch] = useReducer(reducer, initialState);
168
+ }), Re = (e, t) => de({
169
+ expandedSections: k(
170
+ d(e, "expandedSections"),
171
+ ue(t.expandedSections)
172
+ ),
173
+ formModel: k(
174
+ d(e, "formModel"),
175
+ V(t.formModel)
176
+ ),
177
+ settings: k(
178
+ d(e, "settings"),
179
+ V(t.settings)
180
+ )
181
+ }), ve = (e, t) => ({
182
+ openFilters: () => C(
183
+ d(e, "settings"),
184
+ g().setEntityFields({
185
+ open: !0
186
+ })
187
+ ),
188
+ closeFilters: () => C(
189
+ d(e, "settings"),
190
+ g().setEntityFields({
191
+ open: !1
192
+ })
193
+ ),
194
+ setFormModelFields: (n) => C(
195
+ d(e, "formModel"),
196
+ g().setEntityFields(n)
197
+ ),
198
+ clearFormModel: () => C(
199
+ d(e, "formModel"),
200
+ g().setEntity(t)
201
+ ),
202
+ expandSection: (n) => C(
203
+ d(e, "expandedSections"),
204
+ w().setValue(n, !0)
205
+ ),
206
+ collapseSection: (n) => C(
207
+ d(e, "expandedSections"),
208
+ w().setValue(n, !1)
209
+ ),
210
+ setSectionExpanded: (n, r) => C(
211
+ d(e, "expandedSections"),
212
+ w().setValue(n, r)
213
+ ),
214
+ clearExpandedSections: () => C(
215
+ d(e, "expandedSections"),
216
+ w().clearAllValues()
217
+ )
218
+ }), d = (e, t) => `${e}.${t}`, Me = (e) => {
219
+ const [t] = R(
220
+ () => Re("local", e)
221
+ ), [n] = R(
222
+ () => ve(
223
+ "local",
224
+ e.formModel
225
+ )
226
+ ), [r, o] = U(t, e);
218
227
  return {
219
- actions,
220
- state,
221
- dispatch
228
+ actions: n,
229
+ state: r,
230
+ dispatch: o
222
231
  };
223
- };
224
- const SearchFilterLocalStateContext = function SearchFilterLocalScope({
225
- initialFormModel,
226
- children
232
+ }, Ue = function({
233
+ initialFormModel: t,
234
+ children: n
227
235
  }) {
228
236
  const {
229
- state,
230
- actions,
231
- dispatch
232
- } = useLocalSearchFilterState(createSearchFilterInitialState(initialFormModel));
233
- return /* @__PURE__ */ jsx(SearchFilterContext, {
234
- state,
235
- actions,
236
- dispatch,
237
- children
237
+ state: r,
238
+ actions: o,
239
+ dispatch: s
240
+ } = Me(we(t));
241
+ return /* @__PURE__ */ c(ge, {
242
+ state: r,
243
+ actions: o,
244
+ dispatch: s,
245
+ children: n
238
246
  });
239
- };
240
- const ChipSpacer = styled.div`
247
+ }, B = he.div`
241
248
  padding: calc(var(--swui-metrics-spacing) / 2)
242
249
  calc(var(--swui-metrics-indent) / 2);
243
- `;
244
- const SearchFilterChips = ({
245
- children,
246
- disableClearAllButton = false
250
+ `, Xe = ({
251
+ children: e,
252
+ disableClearAllButton: t = !1
247
253
  }) => {
248
- const dispatch = useSearchFilterDispatch();
249
- const actions = useSearchFilterActions();
250
- const onClickClearAll = useCallback(() => dispatch(actions.clearFormModel()), [actions, dispatch]);
251
- return /* @__PURE__ */ jsxs(Row, {
254
+ const n = f(), r = m(), o = u(() => n(r.clearFormModel()), [r, n]);
255
+ return /* @__PURE__ */ L(M, {
252
256
  flexWrap: "wrap",
253
- children: [children, !disableClearAllButton && /* @__PURE__ */ jsx(ChipSpacer, {
254
- children: /* @__PURE__ */ jsx(FlatButton, {
257
+ children: [e, !t && /* @__PURE__ */ c(B, {
258
+ children: /* @__PURE__ */ c(D, {
255
259
  size: "small",
256
260
  label: "Clear all",
257
- onClick: onClickClearAll
261
+ onClick: o
258
262
  })
259
263
  })]
260
264
  });
261
- };
262
- const EmptyChip = function EmptyChip2({
263
- label,
264
- sectionId
265
+ }, Le = function({
266
+ label: t,
267
+ sectionId: n
265
268
  }) {
266
- const dispatch = useSearchFilterDispatch();
267
- const actions = useSearchFilterActions();
268
- const onClickLabel = useCallback(() => {
269
- dispatch(actions.clearExpandedSections());
270
- dispatch(actions.expandSection(sectionId));
271
- dispatch(actions.openFilters());
272
- }, [actions, dispatch, sectionId]);
273
- return /* @__PURE__ */ jsx(ChipSpacer, {
274
- children: /* @__PURE__ */ jsx(Chip, {
275
- label,
269
+ const r = f(), o = m(), s = u(() => {
270
+ r(o.clearExpandedSections()), r(o.expandSection(n)), r(o.openFilters());
271
+ }, [o, r, n]);
272
+ return /* @__PURE__ */ c(B, {
273
+ children: /* @__PURE__ */ c(q, {
274
+ label: t,
276
275
  variant: "secondary",
277
- onClick: onClickLabel
276
+ onClick: s
278
277
  })
279
278
  });
280
- };
281
- const SearchFilterChip = function SearchFilterChip2({
282
- sectionId,
283
- label,
284
- value,
285
- onClickRemove
279
+ }, be = function({
280
+ sectionId: t,
281
+ label: n,
282
+ value: r,
283
+ onClickRemove: o
286
284
  }) {
287
- const dispatch = useSearchFilterDispatch();
288
- const actions = useSearchFilterActions();
289
- const setFormModelFields = useCallback((fields) => dispatch(actions.setFormModelFields(fields)), [dispatch, actions]);
290
- const onClickRemoveHandler = useCallback(() => {
291
- onClickRemove == null ? void 0 : onClickRemove({
292
- value,
293
- setFormModelFields
285
+ const s = f(), i = m(), a = u((l) => s(i.setFormModelFields(l)), [s, i]), S = u(() => {
286
+ o == null || o({
287
+ value: r,
288
+ setFormModelFields: a
294
289
  });
295
- }, [onClickRemove, setFormModelFields, value]);
296
- const onClickLabel = useCallback(() => {
297
- dispatch(actions.clearExpandedSections());
298
- dispatch(actions.expandSection(sectionId));
299
- dispatch(actions.openFilters());
300
- }, [actions, dispatch, sectionId]);
301
- return /* @__PURE__ */ jsx(ChipSpacer, {
302
- children: /* @__PURE__ */ jsx(Chip, {
303
- label: label != null ? label : sectionId,
304
- onClick: onClickLabel,
305
- onClickRemove: onClickRemove ? onClickRemoveHandler : void 0
290
+ }, [o, a, r]), h = u(() => {
291
+ s(i.clearExpandedSections()), s(i.expandSection(t)), s(i.openFilters());
292
+ }, [i, s, t]);
293
+ return /* @__PURE__ */ c(B, {
294
+ children: /* @__PURE__ */ c(q, {
295
+ label: n != null ? n : t,
296
+ onClick: h,
297
+ onClickRemove: o ? S : void 0
306
298
  })
307
299
  });
308
- };
309
- const SectionChips = function SectionChips2({
310
- sectionId,
311
- chips,
312
- emptyChipLabel,
313
- onClickRemoveOnChip
300
+ }, Ze = function({
301
+ sectionId: t,
302
+ chips: n,
303
+ emptyChipLabel: r,
304
+ onClickRemoveOnChip: o
314
305
  }) {
315
- if (!(chips == null ? void 0 : chips.length)) {
316
- if (!emptyChipLabel) {
317
- return null;
318
- }
319
- return /* @__PURE__ */ jsx(EmptyChip, {
320
- sectionId,
321
- label: emptyChipLabel
322
- });
323
- }
324
- return /* @__PURE__ */ jsx(Fragment, {
325
- children: chips.map(({
326
- label,
327
- value
328
- }) => /* @__PURE__ */ jsx(SearchFilterChip, {
329
- label: label != null ? label : sectionId,
330
- sectionId,
331
- onClickRemove: onClickRemoveOnChip,
332
- value
333
- }, value))
306
+ return n != null && n.length ? /* @__PURE__ */ c(ce, {
307
+ children: n.map(({
308
+ label: s,
309
+ value: i
310
+ }) => /* @__PURE__ */ c(be, {
311
+ label: s != null ? s : t,
312
+ sectionId: t,
313
+ onClickRemove: o,
314
+ value: i
315
+ }, i))
316
+ }) : r ? /* @__PURE__ */ c(Le, {
317
+ sectionId: t,
318
+ label: r
319
+ }) : null;
320
+ }, _e = (e, t, n) => ({
321
+ chips: Ee(
322
+ e[t],
323
+ n
324
+ ),
325
+ onClickRemoveOnChip: ke(
326
+ e,
327
+ t
328
+ )
329
+ }), Ee = (e, t) => j(e).map((n) => {
330
+ var o;
331
+ const r = t == null ? void 0 : t.find((s) => s.value === n);
332
+ return { value: n, label: (o = r == null ? void 0 : r.label) != null ? o : n };
333
+ }), ke = (e, t) => ({ setFormModelFields: n, value: r }) => {
334
+ const o = { ...e[t] };
335
+ o[r] = !1, n({
336
+ [t]: o
334
337
  });
335
- };
336
- const createChipsPropsForBooleanRecord = (formModel, fieldName, options) => ({
337
- chips: createChipsForBooleanRecord(formModel[fieldName], options),
338
- onClickRemoveOnChip: createOnClickRemoveOnChipForBooleanRecord(formModel, fieldName)
339
- });
340
- const createChipsForBooleanRecord = (booleanRecord, options) => truthyKeysAsList(booleanRecord).map((key) => {
341
- var _a;
342
- const option = options == null ? void 0 : options.find((o) => o.value === key);
343
- return { value: key, label: (_a = option == null ? void 0 : option.label) != null ? _a : key };
344
- });
345
- const createOnClickRemoveOnChipForBooleanRecord = (formModel, fieldName) => {
346
- return ({ setFormModelFields, value }) => {
347
- const newRecord = { ...formModel[fieldName] };
348
- newRecord[value] = false;
349
- setFormModelFields({
350
- [fieldName]: newRecord
351
- });
352
- };
353
- };
354
- const SimpleCheckboxListSection = ({
355
- options,
356
- value,
357
- onValueChange,
358
- ...sectionProps
359
- }) => /* @__PURE__ */ jsx(SearchFilterSection, {
360
- disableContentPadding: true,
361
- ...sectionProps,
362
- children: /* @__PURE__ */ jsx(Column, {
338
+ }, Ne = ({
339
+ options: e,
340
+ value: t,
341
+ onValueChange: n,
342
+ ...r
343
+ }) => /* @__PURE__ */ c(y, {
344
+ disableContentPadding: !0,
345
+ ...r,
346
+ children: /* @__PURE__ */ c(T, {
363
347
  maxHeight: "400px",
364
348
  overflowY: "auto",
365
349
  flex: 1,
366
- children: options == null ? void 0 : options.map((d) => /* @__PURE__ */ jsx(CollapsibleClickableContent, {
350
+ children: e == null ? void 0 : e.map((o) => /* @__PURE__ */ c(ie, {
367
351
  onClick: () => {
368
- if (value && onValueChange) {
369
- const sel = !value[d.value];
370
- onValueChange({
371
- ...value,
372
- [d.value]: sel
352
+ if (t && n) {
353
+ const s = !t[o.value];
354
+ n({
355
+ ...t,
356
+ [o.value]: s
373
357
  });
374
358
  }
375
359
  },
376
- contentLeft: /* @__PURE__ */ jsx(Checkbox, {
360
+ contentLeft: /* @__PURE__ */ c(pe, {
377
361
  tabIndex: -1,
378
- value: value == null ? void 0 : value[d.value]
362
+ value: t == null ? void 0 : t[o.value]
379
363
  }),
380
- children: /* @__PURE__ */ jsx(Text, {
381
- children: d.label
364
+ children: /* @__PURE__ */ c(ee, {
365
+ children: o.label
382
366
  })
383
- }, d.value))
367
+ }, o.value))
384
368
  })
385
- });
386
- const ChipMultiSelectSection = ({
387
- options,
388
- value,
389
- noneSelectedLabel,
390
- onValueChange,
391
- ...sectionProps
369
+ }), et = ({
370
+ options: e,
371
+ value: t,
372
+ noneSelectedLabel: n,
373
+ onValueChange: r,
374
+ ...o
392
375
  }) => {
393
- const [text, setText] = useState("");
394
- const listValue = useMemo(() => value ? truthyKeysAsList(value).map((key) => {
395
- var _a;
396
- const option = options == null ? void 0 : options.find((o) => o.value === key);
376
+ const [s, i] = R(""), a = v(() => t ? j(t).map((l) => {
377
+ var F;
378
+ const p = e == null ? void 0 : e.find((x) => x.value === l);
397
379
  return {
398
- value: key,
399
- label: (_a = option == null ? void 0 : option.label) != null ? _a : key
380
+ value: l,
381
+ label: (F = p == null ? void 0 : p.label) != null ? F : l
400
382
  };
401
- }) : [], [options, value]);
402
- const filteredOptions = useMemo(() => {
403
- return options == null ? void 0 : options.filter((p) => p.value.toLocaleLowerCase().indexOf(text.toLocaleLowerCase()) > -1 || p.label.toLocaleLowerCase().indexOf(text.toLocaleLowerCase()) > -1);
404
- }, [options, text]);
405
- const onValueChangeInternal = useCallback((value2) => {
406
- onValueChange == null ? void 0 : onValueChange(createBooleanRecordFromValue(value2));
407
- }, [onValueChange]);
408
- return /* @__PURE__ */ jsx(SearchFilterSection, {
409
- ...sectionProps,
410
- children: /* @__PURE__ */ jsx(ChipMultiSelect, {
411
- options: filteredOptions,
412
- value: listValue,
413
- onValueChange: onValueChangeInternal,
414
- inputValue: text,
415
- noneSelectedLabel,
416
- onInputChange: setText,
417
- closeMenuOnSelect: false
383
+ }) : [], [e, t]), S = v(() => e == null ? void 0 : e.filter((l) => l.value.toLocaleLowerCase().indexOf(s.toLocaleLowerCase()) > -1 || l.label.toLocaleLowerCase().indexOf(s.toLocaleLowerCase()) > -1), [e, s]), h = u((l) => {
384
+ r == null || r(ye(l));
385
+ }, [r]);
386
+ return /* @__PURE__ */ c(y, {
387
+ ...o,
388
+ children: /* @__PURE__ */ c(Ce, {
389
+ options: S,
390
+ value: a,
391
+ onValueChange: h,
392
+ inputValue: s,
393
+ noneSelectedLabel: n,
394
+ onInputChange: i,
395
+ closeMenuOnSelect: !1
418
396
  })
419
397
  });
420
- };
421
- const createBooleanRecordFromValue = (value) => {
422
- return value.reduce((sum, item) => {
423
- sum[item.value] = true;
424
- return sum;
425
- }, {});
426
- };
427
- const createChipsPropsForDateRange = (formModel, startDateFieldName, endDateFieldName) => ({
428
- chips: createChipsForDateRange(formModel[startDateFieldName], formModel[endDateFieldName]),
429
- onClickRemoveOnChip: createOnClickRemoveOnChipForDateRange(startDateFieldName, endDateFieldName)
430
- });
431
- const createChipsForDateRange = (startDate, endDate) => {
432
- if (!startDate && !endDate) {
433
- return [];
434
- }
435
- return [
436
- { value: "dateRange", label: `${startDate != null ? startDate : ""} - ${endDate != null ? endDate : ""}` }
437
- ];
438
- };
439
- const createOnClickRemoveOnChipForDateRange = (startDateFieldName, endDateFieldName) => {
440
- return ({ setFormModelFields }) => {
441
- setFormModelFields({
442
- [startDateFieldName]: void 0,
443
- [endDateFieldName]: void 0
444
- });
445
- };
446
- };
447
- const createDateRangeSectionProps = (formModel, startDateFieldName, endDateFieldName) => ({
398
+ }, ye = (e) => e.reduce((t, n) => (t[n.value] = !0, t), {}), tt = (e, t, n) => ({
399
+ chips: Be(
400
+ e[t],
401
+ e[n]
402
+ ),
403
+ onClickRemoveOnChip: Oe(
404
+ t,
405
+ n
406
+ )
407
+ }), Be = (e, t) => !e && !t ? [] : [
408
+ { value: "dateRange", label: `${e != null ? e : ""} - ${t != null ? t : ""}` }
409
+ ], Oe = (e, t) => ({ setFormModelFields: n }) => {
410
+ n({
411
+ [e]: void 0,
412
+ [t]: void 0
413
+ });
414
+ }, nt = (e, t, n) => ({
448
415
  value: {
449
- startDate: formModel[startDateFieldName],
450
- endDate: formModel[endDateFieldName]
416
+ startDate: e[t],
417
+ endDate: e[n]
451
418
  },
452
- onValueChange: (value, { dispatch, actions }) => {
453
- const fields = {
454
- [startDateFieldName]: value.startDate,
455
- [endDateFieldName]: value.endDate
419
+ onValueChange: (r, { dispatch: o, actions: s }) => {
420
+ const i = {
421
+ [t]: r.startDate,
422
+ [n]: r.endDate
456
423
  };
457
- dispatch(actions.setFormModelFields(fields));
424
+ o(s.setFormModelFields(i));
458
425
  }
459
- });
460
- const DateRangeCalendarSection = ({
461
- value,
462
- onValueChange,
463
- sectionId,
464
- ...dateRangeCalendarProps
426
+ }), rt = ({
427
+ value: e,
428
+ onValueChange: t,
429
+ sectionId: n,
430
+ ...r
465
431
  }) => {
466
- const dispatch = useSearchFilterDispatch();
467
- const actions = useSearchFilterActions();
468
- const options = useMemo(() => ({
469
- dispatch,
470
- actions
471
- }), [actions, dispatch]);
472
- const [focusedInput, setFocusedInput] = useState("startDate");
473
- const dateRangeValue = useMemo(() => stringsToDateRange(value), [value]);
474
- const onValueChangeHandler = useCallback((value2) => {
475
- onValueChange(dateRangeToStrings(value2), options);
476
- }, [onValueChange, options]);
477
- return /* @__PURE__ */ jsx(SearchFilterSection, {
478
- sectionId,
479
- children: /* @__PURE__ */ jsx(Box, {
432
+ const o = f(), s = m(), i = v(() => ({
433
+ dispatch: o,
434
+ actions: s
435
+ }), [s, o]), [a, S] = R("startDate"), h = v(() => Se(e), [e]), l = u((p) => {
436
+ t(fe(p), i);
437
+ }, [t, i]);
438
+ return /* @__PURE__ */ c(y, {
439
+ sectionId: n,
440
+ children: /* @__PURE__ */ c(A, {
480
441
  flex: 1,
481
442
  alignItems: "center",
482
- children: /* @__PURE__ */ jsx(Box, {
443
+ children: /* @__PURE__ */ c(A, {
483
444
  background: "white",
484
- indent: true,
485
- children: /* @__PURE__ */ jsx(DateRangeCalendar, {
486
- setFocusedInput,
487
- focusedInput,
488
- value: dateRangeValue,
489
- onValueChange: onValueChangeHandler,
490
- ...dateRangeCalendarProps
445
+ indent: !0,
446
+ children: /* @__PURE__ */ c(me, {
447
+ setFocusedInput: S,
448
+ focusedInput: a,
449
+ value: h,
450
+ onValueChange: l,
451
+ ...r
491
452
  })
492
453
  })
493
454
  })
494
455
  });
495
456
  };
496
- export { ChipMultiSelectSection, DateRangeCalendarSection, EmptyChip, SearchFilterActionsContext, SearchFilterButton, SearchFilterChip, SearchFilterChips, SearchFilterContext, SearchFilterDispatchContext, SearchFilterDrawer, SearchFilterLocalStateContext, SearchFilterModelContext, SearchFilterPanelHeader, SearchFilterSection, SearchFilterStateContext, SectionChips, SimpleCheckboxListSection, createChipsForBooleanRecord, createChipsForDateRange, createChipsPropsForBooleanRecord, createChipsPropsForDateRange, createDateRangeSectionProps, createOnClickRemoveOnChipForBooleanRecord, createOnClickRemoveOnChipForDateRange, createSearchFilterActions, createSearchFilterInitialState, createSearchFilterReducer, formatColumnIdToHeaderCellLabel, getReducerIdFor, useLocalSearchFilterState, useSearchFilterActions, useSearchFilterDispatch, useSearchFilterModel, useSearchFilterState };
457
+ export {
458
+ et as ChipMultiSelectSection,
459
+ rt as DateRangeCalendarSection,
460
+ Le as EmptyChip,
461
+ W as SearchFilterActionsContext,
462
+ Je as SearchFilterButton,
463
+ be as SearchFilterChip,
464
+ Xe as SearchFilterChips,
465
+ ge as SearchFilterContext,
466
+ K as SearchFilterDispatchContext,
467
+ Ye as SearchFilterDrawer,
468
+ Ue as SearchFilterLocalStateContext,
469
+ Y as SearchFilterModelContext,
470
+ Fe as SearchFilterPanelHeader,
471
+ y as SearchFilterSection,
472
+ G as SearchFilterStateContext,
473
+ Ze as SectionChips,
474
+ Ne as SimpleCheckboxListSection,
475
+ Ee as createChipsForBooleanRecord,
476
+ Be as createChipsForDateRange,
477
+ _e as createChipsPropsForBooleanRecord,
478
+ tt as createChipsPropsForDateRange,
479
+ nt as createDateRangeSectionProps,
480
+ ke as createOnClickRemoveOnChipForBooleanRecord,
481
+ Oe as createOnClickRemoveOnChipForDateRange,
482
+ ve as createSearchFilterActions,
483
+ we as createSearchFilterInitialState,
484
+ Re as createSearchFilterReducer,
485
+ xe as formatColumnIdToHeaderCellLabel,
486
+ d as getReducerIdFor,
487
+ Me as useLocalSearchFilterState,
488
+ m as useSearchFilterActions,
489
+ f as useSearchFilterDispatch,
490
+ Qe as useSearchFilterModel,
491
+ I as useSearchFilterState
492
+ };
497
493
  //# sourceMappingURL=index.es.js.map