@fuf-stack/megapixels 0.14.3 → 0.15.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.
Files changed (66) hide show
  1. package/dist/DataTable/{index.d.cts → index.d.mts} +1 -1
  2. package/dist/DataTable/{index.js → index.mjs} +1 -1
  3. package/dist/{DataTable-BVFkEua6.js → DataTable-Dxha1_X9.mjs} +2 -2
  4. package/dist/DataTable-Dxha1_X9.mjs.map +1 -0
  5. package/dist/Filter/{index.d.cts → index.d.mts} +1 -1
  6. package/dist/Filter/{index.js → index.mjs} +1 -1
  7. package/dist/{Filter-DNfu6KwS.js → Filter-DNfu6KwS.mjs} +1 -1
  8. package/dist/Filter-DNfu6KwS.mjs.map +1 -0
  9. package/dist/Notification/{index.d.cts → index.d.mts} +1 -1
  10. package/dist/Notification/{index.js → index.mjs} +1 -1
  11. package/dist/{Notification-Bgw2MtBQ.js → Notification-Bgw2MtBQ.mjs} +1 -1
  12. package/dist/Notification-Bgw2MtBQ.mjs.map +1 -0
  13. package/dist/VirtualList/{index.d.cts → index.d.mts} +1 -1
  14. package/dist/VirtualList/{index.js → index.mjs} +1 -1
  15. package/dist/{VirtualList-C4ylipy_.js → VirtualList-BRWFBEWK.mjs} +2 -2
  16. package/dist/VirtualList-BRWFBEWK.mjs.map +1 -0
  17. package/dist/{index-oeUH2qWd.d.ts → index-C8qpzima.d.mts} +4 -6
  18. package/dist/index-C8qpzima.d.mts.map +1 -0
  19. package/dist/{index-DCiYTnRL.d.ts → index-CWO6WrN7.d.mts} +490 -493
  20. package/dist/index-CWO6WrN7.d.mts.map +1 -0
  21. package/dist/{index-CzUDgCXS.d.cts → index-CeBjB8ML.d.mts} +1363 -1366
  22. package/dist/{index-SE4suk-2.d.ts.map → index-CeBjB8ML.d.mts.map} +1 -1
  23. package/dist/{index-DTHVZwVC.d.cts → index-DsTgtkjk.d.mts} +292 -302
  24. package/dist/index-DsTgtkjk.d.mts.map +1 -0
  25. package/dist/{index.d.cts → index.d.mts} +4 -4
  26. package/dist/{index.js → index.mjs} +5 -5
  27. package/dist/{index.cjs.map → index.mjs.map} +1 -1
  28. package/dist/{useInfiniteVirtualizer-BBgVBqJa.js → useInfiniteVirtualizer-BBgVBqJa.mjs} +1 -1
  29. package/dist/{useInfiniteVirtualizer-vIWKOBNt.cjs.map → useInfiniteVirtualizer-BBgVBqJa.mjs.map} +1 -1
  30. package/package.json +15 -32
  31. package/dist/DataTable/index.cjs +0 -8
  32. package/dist/DataTable/index.d.ts +0 -2
  33. package/dist/DataTable-BVFkEua6.js.map +0 -1
  34. package/dist/DataTable-CDKQh9m0.cjs +0 -1162
  35. package/dist/DataTable-CDKQh9m0.cjs.map +0 -1
  36. package/dist/Filter/index.cjs +0 -9
  37. package/dist/Filter/index.d.ts +0 -2
  38. package/dist/Filter-DNfu6KwS.js.map +0 -1
  39. package/dist/Filter-DvKXl2aZ.cjs +0 -791
  40. package/dist/Filter-DvKXl2aZ.cjs.map +0 -1
  41. package/dist/Notification/index.cjs +0 -8
  42. package/dist/Notification/index.d.ts +0 -2
  43. package/dist/Notification-Bg3_1P1x.cjs +0 -154
  44. package/dist/Notification-Bg3_1P1x.cjs.map +0 -1
  45. package/dist/Notification-Bgw2MtBQ.js.map +0 -1
  46. package/dist/VirtualList/index.cjs +0 -8
  47. package/dist/VirtualList/index.d.ts +0 -2
  48. package/dist/VirtualList-C4ylipy_.js.map +0 -1
  49. package/dist/VirtualList-CmG2C3B2.cjs +0 -170
  50. package/dist/VirtualList-CmG2C3B2.cjs.map +0 -1
  51. package/dist/index-CzUDgCXS.d.cts.map +0 -1
  52. package/dist/index-DCiYTnRL.d.ts.map +0 -1
  53. package/dist/index-DTHVZwVC.d.cts.map +0 -1
  54. package/dist/index-Ds212A8D.d.ts +0 -1141
  55. package/dist/index-Ds212A8D.d.ts.map +0 -1
  56. package/dist/index-FDKfDW98.d.cts +0 -2070
  57. package/dist/index-FDKfDW98.d.cts.map +0 -1
  58. package/dist/index-SE4suk-2.d.ts +0 -5192
  59. package/dist/index-oeUH2qWd.d.cts +0 -103
  60. package/dist/index-oeUH2qWd.d.cts.map +0 -1
  61. package/dist/index-oeUH2qWd.d.ts.map +0 -1
  62. package/dist/index.cjs +0 -19
  63. package/dist/index.d.ts +0 -5
  64. package/dist/index.js.map +0 -1
  65. package/dist/useInfiniteVirtualizer-BBgVBqJa.js.map +0 -1
  66. package/dist/useInfiniteVirtualizer-vIWKOBNt.cjs +0 -176
@@ -1,791 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
- //#endregion
23
- let react = require("react");
24
- let _fuf_stack_pixel_utils = require("@fuf-stack/pixel-utils");
25
- let _fuf_stack_pixels_Button = require("@fuf-stack/pixels/Button");
26
- _fuf_stack_pixels_Button = __toESM(_fuf_stack_pixels_Button, 1);
27
- let react_jsx_runtime = require("react/jsx-runtime");
28
- let _fuf_stack_pixels_Menu = require("@fuf-stack/pixels/Menu");
29
- _fuf_stack_pixels_Menu = __toESM(_fuf_stack_pixels_Menu, 1);
30
- let debug = require("debug");
31
- debug = __toESM(debug, 1);
32
- let _fuf_stack_uniform_Form = require("@fuf-stack/uniform/Form");
33
- _fuf_stack_uniform_Form = __toESM(_fuf_stack_uniform_Form, 1);
34
- let _fuf_stack_veto = require("@fuf-stack/veto");
35
- let _fuf_stack_pixels_Label = require("@fuf-stack/pixels/Label");
36
- let _fuf_stack_uniform_hooks_useFormContext = require("@fuf-stack/uniform/hooks/useFormContext");
37
- let react_icons_fa6 = require("react-icons/fa6");
38
- let react_icons_pi = require("react-icons/pi");
39
- let _fuf_stack_pixels_Modal = require("@fuf-stack/pixels/Modal");
40
- _fuf_stack_pixels_Modal = __toESM(_fuf_stack_pixels_Modal, 1);
41
- let _fuf_stack_uniform_SubmitButton = require("@fuf-stack/uniform/SubmitButton");
42
- _fuf_stack_uniform_SubmitButton = __toESM(_fuf_stack_uniform_SubmitButton, 1);
43
- let react_icons_fa = require("react-icons/fa");
44
- let _fuf_stack_pixel_motion = require("@fuf-stack/pixel-motion");
45
- let _fuf_stack_uniform_Input = require("@fuf-stack/uniform/Input");
46
- _fuf_stack_uniform_Input = __toESM(_fuf_stack_uniform_Input, 1);
47
- let _fuf_stack_uniform_Switch = require("@fuf-stack/uniform/Switch");
48
- _fuf_stack_uniform_Switch = __toESM(_fuf_stack_uniform_Switch, 1);
49
- let _fuf_stack_uniform_Checkboxes = require("@fuf-stack/uniform/Checkboxes");
50
- _fuf_stack_uniform_Checkboxes = __toESM(_fuf_stack_uniform_Checkboxes, 1);
51
- //#region src/Filter/hooks/useFilterValidation.ts
52
- /**
53
- * useFilterValidation
54
- *
55
- * Builds a composite validation schema from all provided filter definitions
56
- * under "filter" and optionally includes a "search" string field.
57
- * Memoized by inputs.
58
- */
59
- const useFilterValidation = (filters, withSearch) => {
60
- return (0, react.useMemo)(() => {
61
- let filterSchema = {};
62
- filters.forEach((f) => {
63
- filterSchema = {
64
- ...filterSchema,
65
- [f.name]: f.validation(f.config)
66
- };
67
- });
68
- return (0, _fuf_stack_veto.veto)({
69
- filter: (0, _fuf_stack_veto.stringToJSON)().pipe((0, _fuf_stack_veto.object)(filterSchema)).or((0, _fuf_stack_veto.object)(filterSchema)).optional().nullable().transform((val) => {
70
- return val ?? void 0;
71
- }),
72
- ...withSearch ? { search: (0, _fuf_stack_veto.string)({ min: 0 }).nullable().optional() } : {}
73
- });
74
- }, [filters, withSearch]);
75
- };
76
- //#endregion
77
- //#region src/Filter/Subcomponents/FiltersContext.tsx
78
- /**
79
- * FiltersContext
80
- *
81
- * Central state for the filter UI with a clear boundary:
82
- * - The parent component controls committed filter values (via value/onChange)
83
- * - The form acts as an edit buffer (used by the modal)
84
- *
85
- * Design:
86
- * - activeFilters/unusedFilters are names-only and derived from the controlled
87
- * form state
88
- * - getFilterInstanceByName gives access to the concrete registry entry to
89
- * retrieve the correct Form/Display components
90
- * - add seeds defaults in the form and opens the modal
91
- * - remove un-registers the form field; if the removed filter is currently
92
- * open in the modal, the modal is closed without rollback
93
- * - on a new successful form submit (Apply), the modal closes without rollback
94
- * by subscribing to ex-forms submit state
95
- */
96
- const FiltersContext = (0, react.createContext)(void 0);
97
- const FiltersContextProvider = ({ children, config }) => {
98
- const { formState, getFieldState, setValue, triggerSubmit, unregister, watch } = (0, _fuf_stack_uniform_hooks_useFormContext.useFormContext)();
99
- /**
100
- * currentModalFilter
101
- *
102
- * Single source of truth for the filter edit modal and its rollback snapshot.
103
- * - name: which filter's modal is currently open (null when closed)
104
- * - hadValue/previousValue: snapshot of the controlled value taken when the
105
- * modal is opened; used to restore state if the user cancels/closes without
106
- * applying.
107
- *
108
- * Lifecycle semantics:
109
- * - showFilterModal(name): capture snapshot (current controlled value) and open
110
- * the modal for that filter.
111
- * - closeFilterModal(): if a snapshot exists, roll back un-applied edits by
112
- * restoring the previous value (setValue) or removing the field (unregister)
113
- * when it did not exist before; then clear currentModalFilter.
114
- * - On successful submit (Apply): close and clear currentModalFilter WITHOUT rollback
115
- * so edits remain committed.
116
- * - removeFilter(name): unregisters the field; when removing the filter that is
117
- * currently open, close the modal WITHOUT rollback (since removal is explicit).
118
- */
119
- const [currentModalFilter, setCurrentModalFilter] = (0, react.useState)(null);
120
- const filterValue = watch("filter", {});
121
- /**
122
- * getFilterFormFieldName
123
- *
124
- * Returns the fully-qualified field path for a given filter name,
125
- * e.g., `${filterUrlParam}.status`.
126
- */
127
- const getFilterFormFieldName = (0, react.useCallback)((name) => {
128
- return `filter.${name}`;
129
- }, []);
130
- /**
131
- * getFilterValueByName
132
- *
133
- * Returns the committed value for a filter from the controlled state.
134
- */
135
- const getFilterValueByName = (0, react.useCallback)((name) => {
136
- return filterValue[name];
137
- }, [filterValue]);
138
- /** Open the filter edit modal for the given filter name. */
139
- const showFilterModal = (0, react.useCallback)((name) => {
140
- const prev = getFilterValueByName(name);
141
- setCurrentModalFilter({
142
- name,
143
- hadValue: typeof prev !== "undefined",
144
- previousValue: prev
145
- });
146
- }, [getFilterValueByName]);
147
- /** Close the filter edit modal. Rollback un-applied edits to controlled state. */
148
- const closeFilterModal = (0, react.useCallback)(() => {
149
- if (currentModalFilter?.name) {
150
- const fieldName = getFilterFormFieldName(currentModalFilter.name);
151
- if (currentModalFilter.hadValue) setValue(fieldName, currentModalFilter.previousValue);
152
- else unregister(fieldName);
153
- }
154
- setCurrentModalFilter(null);
155
- }, [
156
- getFilterFormFieldName,
157
- currentModalFilter,
158
- setValue,
159
- unregister
160
- ]);
161
- /**
162
- * Auto-close on submit success
163
- *
164
- * Close the modal only on new successful submissions. We track the last
165
- * submitCount and only react when it changes AND the form reports a
166
- * successful submit. This prevents closing when `isSubmitSuccessful` remains
167
- * true without a new submit event.
168
- */
169
- const lastSubmitCountRef = (0, react.useRef)(0);
170
- (0, react.useEffect)(() => {
171
- if (formState.submitCount !== lastSubmitCountRef.current && formState.isSubmitSuccessful) setCurrentModalFilter(null);
172
- lastSubmitCountRef.current = formState.submitCount;
173
- }, [
174
- formState.submitCount,
175
- formState.isSubmitSuccessful,
176
- setCurrentModalFilter
177
- ]);
178
- /**
179
- * activeFilters
180
- *
181
- * Filter names derived from the controlled form state. A filter is considered
182
- * active when a field exists at `filter.<name>`. Newly added filters become
183
- * active immediately (seeded default), and will be rolled back on cancel.
184
- */
185
- const activeFilters = (0, react.useMemo)(() => {
186
- return config.filter((f) => {
187
- return Object.hasOwn(filterValue ?? {}, f.name);
188
- }).map((f) => {
189
- return f.name;
190
- });
191
- }, [config, filterValue]);
192
- /**
193
- * unusedFilters
194
- *
195
- * Complement of activeFilters (names without a corresponding `filter.<name>`
196
- * field in the controlled form state).
197
- */
198
- const unusedFilters = (0, react.useMemo)(() => {
199
- return config.filter((f) => {
200
- return !Object.hasOwn(filterValue ?? {}, f.name);
201
- }).map((f) => {
202
- return f.name;
203
- });
204
- }, [config, filterValue]);
205
- /**
206
- * getRegistryFilterByName
207
- *
208
- * Looks up the concrete registry entry for a filter by name, enabling access
209
- * to typed Form/Display components and other registry-level metadata.
210
- */
211
- const getFilterInstanceByName = (0, react.useCallback)((name) => {
212
- return config.find((f) => {
213
- return f.name === name;
214
- });
215
- }, [config]);
216
- /**
217
- * addFilter
218
- *
219
- * Seeds the filter with its registry default value inside the form and opens
220
- * the modal for immediate editing. No URL writes happen here.
221
- */
222
- const addFilter = (0, react.useCallback)((name) => {
223
- const inst = getFilterInstanceByName(name);
224
- showFilterModal(name);
225
- setValue(getFilterFormFieldName(name), inst.defaultValue);
226
- }, [
227
- getFilterFormFieldName,
228
- getFilterInstanceByName,
229
- setValue,
230
- showFilterModal
231
- ]);
232
- /**
233
- * removeFilter
234
- *
235
- * Unregisters the filter field from the form. This immediately removes the
236
- * filter from the active list since derived state watches the form. It
237
- * closes the modal without rollback if the removed filter is currently open.
238
- */
239
- const removeFilter = (0, react.useCallback)((name) => {
240
- unregister(getFilterFormFieldName(name));
241
- if (currentModalFilter?.name === name) setCurrentModalFilter(null);
242
- triggerSubmit();
243
- }, [
244
- getFilterFormFieldName,
245
- currentModalFilter,
246
- setCurrentModalFilter,
247
- triggerSubmit,
248
- unregister
249
- ]);
250
- /**
251
- * hasError
252
- *
253
- * Helper that checks the ex-forms field state for a specific filter and
254
- * reports whether the field is currently invalid.
255
- */
256
- const hasError = (0, react.useCallback)((name) => {
257
- return getFieldState(getFilterFormFieldName(name)).invalid;
258
- }, [getFieldState, getFilterFormFieldName]);
259
- const contextValue = (0, react.useMemo)(() => {
260
- return {
261
- activeFilters,
262
- addFilter,
263
- closeFilterModal,
264
- getFilterFormFieldName,
265
- getFilterValueByName,
266
- getFilterInstanceByName,
267
- hasError,
268
- modalFilterName: currentModalFilter?.name,
269
- removeFilter,
270
- showFilterModal,
271
- unusedFilters
272
- };
273
- }, [
274
- activeFilters,
275
- addFilter,
276
- closeFilterModal,
277
- getFilterFormFieldName,
278
- getFilterValueByName,
279
- getFilterInstanceByName,
280
- hasError,
281
- currentModalFilter,
282
- removeFilter,
283
- showFilterModal,
284
- unusedFilters
285
- ]);
286
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FiltersContext.Provider, {
287
- value: contextValue,
288
- children
289
- });
290
- };
291
- /**
292
- * useFilters
293
- *
294
- * Convenience hook to consume the FiltersContext. Throws a descriptive error
295
- * when used outside of a FiltersContextProvider to make integration mistakes
296
- * obvious during development.
297
- */
298
- const useFilters = () => {
299
- const ctx = (0, react.useContext)(FiltersContext);
300
- if (!ctx) throw new Error("useFilters must be used within FiltersContextProvider");
301
- return ctx;
302
- };
303
- //#endregion
304
- //#region src/Filter/Subcomponents/ActiveFilters.tsx
305
- const ActiveFilters = ({ className = void 0 }) => {
306
- const { activeFilters, getFilterValueByName, getFilterInstanceByName, hasError, removeFilter, showFilterModal } = useFilters();
307
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: activeFilters.map((name) => {
308
- const instance = getFilterInstanceByName(name);
309
- const value = getFilterValueByName(name);
310
- const DisplayComponent = instance.components.Display;
311
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
312
- "aria-label": `Open ${name} filter`,
313
- onClick: () => {
314
- showFilterModal(name);
315
- },
316
- type: "button",
317
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_fuf_stack_pixels_Label.Label, {
318
- className,
319
- color: hasError(name) ? "danger" : "primary",
320
- onClose: () => {
321
- removeFilter(name);
322
- },
323
- variant: "flat",
324
- children: [instance.icon, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DisplayComponent, {
325
- config: instance.config,
326
- value
327
- })]
328
- })
329
- }, name);
330
- }) });
331
- };
332
- //#endregion
333
- //#region src/Filter/Subcomponents/AddFilterMenu.tsx
334
- /**
335
- * AddFilterMenu
336
- *
337
- * Renders a menu trigger that opens a list of addable filters. Selecting an
338
- * item triggers the parent to seed a default value and open the modal.
339
- */
340
- const AddFilterMenu = ({ classNames = {}, disableAnimation = false, portalContainer = void 0 }) => {
341
- const { unusedFilters, addFilter, getFilterInstanceByName } = useFilters();
342
- const menuItems = unusedFilters.map((name) => {
343
- const instance = getFilterInstanceByName(name);
344
- const label = instance.config?.text ?? name;
345
- return {
346
- key: name,
347
- icon: instance.icon,
348
- label,
349
- onClick: () => {
350
- addFilter(name);
351
- }
352
- };
353
- });
354
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_fuf_stack_pixels_Menu.default, {
355
- className: {
356
- item: classNames.addFilterMenuItem,
357
- trigger: classNames.addFilterMenuButton
358
- },
359
- disableAnimation,
360
- isDisabled: !menuItems.length,
361
- items: menuItems,
362
- placement: "bottom-start",
363
- portalContainer,
364
- triggerButtonProps: {
365
- "aria-label": "Add Filter",
366
- "data-testid": "add_filter_button",
367
- disableRipple: true,
368
- size: "sm",
369
- variant: "bordered"
370
- },
371
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_icons_fa6.FaSliders, {}), "Filter"]
372
- });
373
- };
374
- //#endregion
375
- //#region src/Filter/Subcomponents/FilterModal.tsx
376
- const FilterModal = ({ classNames = {}, disableAnimation = false, portalContainer = void 0 }) => {
377
- const { closeFilterModal, getFilterFormFieldName, getFilterInstanceByName, modalFilterName, removeFilter } = useFilters();
378
- if (!modalFilterName) return null;
379
- const instance = getFilterInstanceByName(modalFilterName);
380
- const config = instance.config;
381
- const FormComponent = instance.components.Form;
382
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_pixels_Modal.default, {
383
- className: {
384
- body: classNames.body,
385
- footer: classNames.footer,
386
- header: classNames.header
387
- },
388
- disableAnimation,
389
- footer: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_pixels_Button.default, {
390
- ariaLabel: "Remove filter",
391
- color: "danger",
392
- onClick: () => {
393
- removeFilter(modalFilterName);
394
- },
395
- testId: "remove_filter_button",
396
- variant: "flat",
397
- children: "Remove"
398
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_uniform_SubmitButton.default, {
399
- ariaLabel: "Apply filter",
400
- testId: "apply_filter_button",
401
- children: "Apply Filter"
402
- })] }),
403
- header: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [instance.icon ?? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_icons_pi.PiSlidersHorizontalBold, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: `${config?.text ?? modalFilterName} Filter` })] }),
404
- isOpen: true,
405
- onClose: closeFilterModal,
406
- portalContainer,
407
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Suspense, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FormComponent, {
408
- config,
409
- fieldName: getFilterFormFieldName(modalFilterName)
410
- }) })
411
- });
412
- };
413
- //#endregion
414
- //#region src/Filter/Subcomponents/SearchInput.tsx
415
- /**
416
- * SearchInput
417
- *
418
- * By default renders only a search button. When clicked, the text input animates in
419
- * and a trailing submit button is shown.
420
- */
421
- const SearchInput = ({ classNames = {}, config }) => {
422
- const { formState, setFocus, triggerSubmit } = (0, _fuf_stack_uniform_hooks_useFormContext.useFormContext)();
423
- const isInitiallyVisible = !!formState?.defaultValues?.search;
424
- const [isVisible, setIsVisible] = (0, react.useState)(isInitiallyVisible);
425
- const placeholder = typeof config === "object" ? config.placeholder : void 0;
426
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
427
- className: classNames.searchWrapper,
428
- children: [!isVisible && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_pixels_Button.Button, {
429
- ariaLabel: "Show search input",
430
- className: classNames.searchShowButton,
431
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_icons_fa.FaSearch, {}),
432
- onClick: () => {
433
- setIsVisible(true);
434
- },
435
- size: "sm",
436
- testId: "show_search_input_button",
437
- variant: "bordered"
438
- }), isVisible ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_fuf_stack_pixel_motion.motion.div, {
439
- animate: { opacity: 1 },
440
- className: classNames.searchMotionDiv,
441
- initial: !isInitiallyVisible ? { opacity: .5 } : false,
442
- onAnimationComplete: () => {
443
- if (!isInitiallyVisible) setFocus("search");
444
- },
445
- transition: {
446
- duration: .3,
447
- ease: "circOut"
448
- },
449
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_uniform_Input.default, {
450
- className: {
451
- input: classNames.searchInput,
452
- inputWrapper: classNames.searchInputWrapper
453
- },
454
- clearable: true,
455
- debounceDelay: 0,
456
- placeholder,
457
- size: "sm",
458
- name: "search",
459
- onClear: () => {
460
- triggerSubmit();
461
- }
462
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_uniform_SubmitButton.default, {
463
- className: classNames.searchSubmitButton,
464
- color: "primary",
465
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_icons_fa.FaSearch, {}),
466
- size: "sm",
467
- testId: "submit_search_button",
468
- ariaLabel: "Submit search",
469
- children: null
470
- })]
471
- }, "search-input") : null]
472
- });
473
- };
474
- //#endregion
475
- //#region src/Filter/Filter.tsx
476
- const debug$1 = (0, debug.default)("megapixels:Filter");
477
- const filterVariants = (0, _fuf_stack_pixel_utils.tv)({ slots: {
478
- base: "flex flex-auto flex-col",
479
- addFilterMenuButton: "",
480
- addFilterMenuItem: "",
481
- activeFilterLabel: "h-8 cursor-pointer rounded-md dark:text-foreground",
482
- filterModalBody: "",
483
- filterModalHeader: "flex items-center gap-3 text-default-700",
484
- filterModalFooter: "justify-between",
485
- form: "mb-3 flex flex-wrap gap-3",
486
- searchInput: "",
487
- searchInputWrapper: "",
488
- searchMotionDiv: "flex w-72 gap-2",
489
- searchShowButton: "",
490
- searchSubmitButton: "",
491
- searchWrapper: "flex items-center"
492
- } });
493
- /**
494
- * Renders the filter UI bound to a single ex-forms `Form`.
495
- * The form is the source of truth during user interaction; the committed
496
- * state is controlled by the parent via `values`/`onChange`.
497
- */
498
- const Filter = ({ children = void 0, className = void 0, config, disableAnimation = false, formName = "filterComponentForm", onChange, portalContainer = void 0, values }) => {
499
- const handleSubmit = (nextValues) => {
500
- debug$1("handleSubmit", { nextValues });
501
- onChange(nextValues);
502
- };
503
- const validation = useFilterValidation(config.filters, Boolean(config.search));
504
- const { data: valuesValidated, errors, success } = validation.validate(values);
505
- const classNames = (0, _fuf_stack_pixel_utils.variantsToClassNames)(filterVariants(), className, "base");
506
- debug$1("render", {
507
- props: {
508
- config,
509
- values
510
- },
511
- validation: {
512
- errors,
513
- success,
514
- valuesValidated
515
- }
516
- });
517
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
518
- className: classNames.base,
519
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_fuf_stack_uniform_Form.default, {
520
- className: classNames.form,
521
- debug: { disable: true },
522
- initialValues: valuesValidated ?? {},
523
- name: formName,
524
- onSubmit: handleSubmit,
525
- validation,
526
- children: [config.search ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SearchInput, {
527
- classNames: {
528
- searchInput: classNames.searchInput,
529
- searchInputWrapper: classNames.searchInputWrapper,
530
- searchMotionDiv: classNames.searchMotionDiv,
531
- searchShowButton: classNames.searchShowButton,
532
- searchSubmitButton: classNames.searchSubmitButton,
533
- searchWrapper: classNames.searchWrapper
534
- },
535
- config: config.search
536
- }) : null, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(FiltersContextProvider, {
537
- config: config.filters,
538
- children: [
539
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ActiveFilters, { className: classNames.activeFilterLabel }),
540
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AddFilterMenu, {
541
- classNames: {
542
- addFilterMenuButton: classNames.addFilterMenuButton,
543
- addFilterMenuItem: classNames.addFilterMenuItem
544
- },
545
- disableAnimation,
546
- portalContainer
547
- }),
548
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FilterModal, {
549
- classNames: {
550
- body: classNames.filterModalBody,
551
- footer: classNames.filterModalFooter,
552
- header: classNames.filterModalHeader
553
- },
554
- disableAnimation,
555
- portalContainer
556
- })
557
- ]
558
- })]
559
- }), children?.(valuesValidated ?? {})]
560
- });
561
- };
562
- //#endregion
563
- //#region src/Filter/filters/createFilter.ts
564
- /**
565
- * createFilter
566
- *
567
- * Builds a filter factory from a static FilterDefinition. The returned factory
568
- * accepts a usage descriptor (name/icon and optional partial config) and
569
- * produces a concrete FilterInstance with:
570
- * - merged config (shallow: definition.defaults.config overlaid by overrides)
571
- * - Form/Display components
572
- * - validate function (forwarded from the definition)
573
- * - defaultValue (forwarded from the definition)
574
- * - name and icon for UI integration
575
- *
576
- * @typeParam Config - Configuration object shape for the filter
577
- * @typeParam Value - Runtime value type for the filter
578
- * @param definition - Static description of the filter (components, defaults, validate)
579
- * @returns FilterFactory that creates FilterInstance<Config, Value>
580
- */
581
- const createFilter = (definition) => {
582
- return ({ name, icon, config }) => {
583
- return {
584
- components: definition.components,
585
- config: {
586
- ...definition.defaults.config,
587
- ...config ?? {}
588
- },
589
- defaultValue: definition.defaults.value,
590
- icon,
591
- name,
592
- validation: definition.validation
593
- };
594
- };
595
- };
596
- //#endregion
597
- //#region src/Filter/filters/boolean/Display.tsx
598
- /**
599
- * Read-only presentation for the boolean filter.
600
- * Displays human-readable text based on the current boolean `value`
601
- * and the provided `config` strings.
602
- */
603
- const Display$1 = ({ value, config: { text, textPrefix, textNoWord } }) => {
604
- if (typeof value === "boolean") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: `${value ? textPrefix : `${textPrefix} ${textNoWord ?? "no"}`} ${text}` });
605
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: `${text}...` });
606
- };
607
- //#endregion
608
- //#region src/Filter/filters/boolean/Form.tsx
609
- /**
610
- * Renders the form control for the boolean filter.
611
- * Uses a `Switch` to toggle the boolean value and composes
612
- * the label from the provided `config` and `fieldName`.
613
- */
614
- const Form$1 = ({ fieldName, config: { text, textPrefix } }) => {
615
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_uniform_Switch.default, {
616
- label: `${textPrefix} ${text}`,
617
- name: fieldName
618
- });
619
- };
620
- (0, _fuf_stack_veto.object)({
621
- /**
622
- * Human‑readable label used in the UI (e.g. in the chip and modal header).
623
- * Examples: "Magical", "Haunted"
624
- */
625
- text: (0, _fuf_stack_veto.string)(),
626
- /**
627
- * Optional word shown before the label when building sentence‑like chips.
628
- * Examples: "is" → "is Magical"
629
- */
630
- textPrefix: (0, _fuf_stack_veto.string)().optional(),
631
- /**
632
- * Optional negation word used when a boolean value is false.
633
- * Examples: "not" → "is not Magical"
634
- */
635
- textNoWord: (0, _fuf_stack_veto.string)().optional()
636
- });
637
- /** validate the filter value */
638
- const validate$1 = (_config) => {
639
- return (0, _fuf_stack_veto.boolean)().optional();
640
- };
641
- //#endregion
642
- //#region src/Filter/filters/boolean/boolean.ts
643
- /**
644
- * Boolean filter definition for the Filter system.
645
- * Provides Display and Form components, default value/config, and validation.
646
- *
647
- * Defaults:
648
- * - value: true
649
- * - config: { text: 'Active', textPrefix: 'is', textNoWord: 'no' }
650
- *
651
- * @see Display
652
- * @see Form
653
- * @see validate
654
- */
655
- const boolean = createFilter({
656
- components: {
657
- Display: Display$1,
658
- Form: Form$1
659
- },
660
- defaults: {
661
- value: true,
662
- config: {
663
- text: "Active",
664
- textPrefix: "is",
665
- textNoWord: "no"
666
- }
667
- },
668
- validation: validate$1
669
- });
670
- //#endregion
671
- //#region src/Filter/filters/checkboxes/Display.tsx
672
- /**
673
- * Read-only presentation for the checkboxes filter.
674
- * Resolves and displays selected option labels based on `value` and `config`.
675
- * Supports string, ReactNode, and function labels (mode: 'display').
676
- */
677
- const Display = ({ value, config: { text, options } }) => {
678
- if (value && value.length > 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
679
- className: "flex items-center gap-1",
680
- children: [
681
- text,
682
- " is",
683
- value.map((val) => {
684
- const label = options.find((op) => {
685
- return op.value === val;
686
- })?.label ?? val;
687
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: typeof label === "function" ? label("display") : label }, val);
688
- })
689
- ]
690
- });
691
- return `${text} is ...`;
692
- };
693
- //#endregion
694
- //#region src/Filter/filters/checkboxes/Form.tsx
695
- /**
696
- * Renders the form control for the checkboxes filter.
697
- * Uses a `Checkboxes` to select multiple options.
698
- * Resolves function labels with 'form' mode.
699
- */
700
- const Form = ({ fieldName, config }) => {
701
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_fuf_stack_uniform_Checkboxes.default, {
702
- name: fieldName,
703
- options: config.options.map((option) => {
704
- return {
705
- ...option,
706
- label: typeof option.label === "function" ? option.label("form") : option.label
707
- };
708
- })
709
- });
710
- };
711
- (0, _fuf_stack_veto.object)({
712
- /**
713
- * Human‑readable label used in the UI (e.g. label and modal header).
714
- * Example: "Snacks", "Mood"
715
- */
716
- text: (0, _fuf_stack_veto.string)(),
717
- /**
718
- * Options rendered as multiple checkboxes. Each option needs a `label`
719
- * (what the user sees) and a `value` (what is written into the form state).
720
- * Label can be a string, React node, or a function that receives mode
721
- * ('form' or 'display') and returns a React node.
722
- */
723
- options: (0, _fuf_stack_veto.array)((0, _fuf_stack_veto.object)({
724
- label: (0, _fuf_stack_veto.any)(),
725
- value: (0, _fuf_stack_veto.string)()
726
- }))
727
- });
728
- /** validate the filter value */
729
- const validate = (cfg) => {
730
- return (0, _fuf_stack_veto.refineArray)((0, _fuf_stack_veto.array)((0, _fuf_stack_veto.string)()).optional())({
731
- unique: true,
732
- custom: (values, ctx) => {
733
- if (!cfg) return;
734
- values.forEach((value) => {
735
- if (!cfg.options.find((option) => {
736
- return option?.value === value;
737
- })) ctx.addIssue({
738
- code: "custom",
739
- message: `Invalid value: ${value}`
740
- });
741
- });
742
- }
743
- });
744
- };
745
- //#endregion
746
- //#region src/Filter/index.ts
747
- const filters = {
748
- boolean,
749
- checkboxes: createFilter({
750
- components: {
751
- Display,
752
- Form
753
- },
754
- defaults: {
755
- value: [],
756
- config: {
757
- text: "Options",
758
- options: []
759
- }
760
- },
761
- validation: validate
762
- })
763
- };
764
- var Filter_default = Filter;
765
- //#endregion
766
- Object.defineProperty(exports, "Filter_default", {
767
- enumerable: true,
768
- get: function() {
769
- return Filter_default;
770
- }
771
- });
772
- Object.defineProperty(exports, "createFilter", {
773
- enumerable: true,
774
- get: function() {
775
- return createFilter;
776
- }
777
- });
778
- Object.defineProperty(exports, "filterVariants", {
779
- enumerable: true,
780
- get: function() {
781
- return filterVariants;
782
- }
783
- });
784
- Object.defineProperty(exports, "filters", {
785
- enumerable: true,
786
- get: function() {
787
- return filters;
788
- }
789
- });
790
-
791
- //# sourceMappingURL=Filter-DvKXl2aZ.cjs.map