@fuf-stack/megapixels 0.8.0 → 0.9.1

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.
@@ -1,368 +1,2 @@
1
- import { vInfer } from '@fuf-stack/veto';
2
- import * as _fuf_stack_veto_dist_types_d_BDYR8HZ3 from '@fuf-stack/veto/dist/types.d-BDYR8HZ3';
3
- import { ReactNode } from 'react';
4
- import * as react_jsx_runtime from 'react/jsx-runtime';
5
- import * as tailwind_variants from 'tailwind-variants';
6
- import { TVClassName } from '@fuf-stack/pixel-utils';
7
-
8
- /** configuration of the filter */
9
- declare const config: _fuf_stack_veto_dist_types_d_BDYR8HZ3.q<{
10
- /**
11
- * Human‑readable label used in the UI (e.g. label and modal header).
12
- * Example: "Snacks", "Mood"
13
- */
14
- text: _fuf_stack_veto_dist_types_d_BDYR8HZ3.h;
15
- /**
16
- * Options rendered as multiple checkboxes. Each option needs a `label`
17
- * (what the user sees) and a `value` (what is written into the form state).
18
- * Label can be a string, React node, or a function that receives mode
19
- * ('form' or 'display') and returns a React node.
20
- */
21
- options: _fuf_stack_veto_dist_types_d_BDYR8HZ3.c<_fuf_stack_veto_dist_types_d_BDYR8HZ3.q<{
22
- label: _fuf_stack_veto_dist_types_d_BDYR8HZ3.Z;
23
- value: _fuf_stack_veto_dist_types_d_BDYR8HZ3.h;
24
- }, "strict", _fuf_stack_veto_dist_types_d_BDYR8HZ3.a, {
25
- value: string;
26
- label?: any;
27
- }, {
28
- value: string;
29
- label?: any;
30
- }>, "many">;
31
- }, "strict", _fuf_stack_veto_dist_types_d_BDYR8HZ3.a, {
32
- text: string;
33
- options: {
34
- value: string;
35
- label?: any;
36
- }[];
37
- }, {
38
- text: string;
39
- options: {
40
- value: string;
41
- label?: any;
42
- }[];
43
- }>;
44
- /** Type-safe Config that overrides label to support ReactNode or function */
45
- type Config = Omit<vInfer<typeof config>, 'options'> & {
46
- options: {
47
- label: ReactNode | ((mode: 'form' | 'display') => ReactNode);
48
- value: string;
49
- }[];
50
- };
51
-
52
- /**
53
- * FilterDefinition
54
- *
55
- * Declarative description of a filter. A FilterDefinition is not used
56
- * directly by the UI. Instead, it is passed to `createFilter` to produce a
57
- * concrete, runtime `FilterInstance` for a specific usage (with name/icon and
58
- * optional config overrides).
59
- *
60
- * @typeParam Config - The configuration object shape for this filter
61
- * @typeParam Value - The runtime value type produced/consumed by this filter
62
- */
63
- interface FilterDefinition<Config, Value> {
64
- components: {
65
- /**
66
- * Display component rendered inside the filter chip. Receives the current
67
- * filter `value` and the merged `config`.
68
- */
69
- Display: (props: {
70
- value: Value;
71
- config: Config;
72
- }) => ReactNode;
73
- /**
74
- * Form component rendered inside the modal. Receives the fully-qualified
75
- * field name and the merged, validated `config`.
76
- */
77
- Form: (props: {
78
- fieldName: string;
79
- config: Config;
80
- }) => ReactNode;
81
- };
82
- defaults: {
83
- /** Baseline configuration for the filter; can be overridden per usage */
84
- config: Config;
85
- /** Initial form value seeded when a filter is added */
86
- value: Value;
87
- };
88
- /**
89
- * Validation factory returning an ex-validator schema for the value shape.
90
- * Receives the (merged) `config` so the schema can depend on configuration.
91
- */
92
- validation: (config?: Config) => unknown;
93
- }
94
- /**
95
- * FilterFactory
96
- *
97
- * A filter exports a factory that, given name/icon and optional config
98
- * overrides, returns a concrete FilterInstance with merged config and a
99
- * computed defaultValue.
100
- *
101
- * @typeParam Config - Configuration object shape for the filter
102
- * @typeParam Value - Runtime value type for the filter
103
- */
104
- type FilterFactory<Config, Value> = (args: {
105
- /** Per-usage configuration overrides merged with `defaults.config` */
106
- config?: Partial<Config>;
107
- /** Optional icon element shown in menus/labels */
108
- icon?: ReactNode;
109
- /** Logical field name under `filter.{name}` */
110
- name: string;
111
- }) => FilterInstance<Config, Value>;
112
- /**
113
- * FilterInstance
114
- *
115
- * Runtime instance created by merging a filter's defaults with usage
116
- * overrides and attaching name/icon for UI.
117
- *
118
- * This is the only shape used by the rendering layer and context.
119
- *
120
- * @typeParam Config - Effective configuration object shape
121
- * @typeParam Value - Effective value type for the filter
122
- */
123
- interface FilterInstance<Config, Value> {
124
- /** UI components (Form/Display) provided by the filter */
125
- components: FilterDefinition<Config, Value>['components'];
126
- /** Merged configuration (`defaults.config` overlaid with per-usage overrides) */
127
- config: Config;
128
- /** Initial form value to seed when adding this filter */
129
- defaultValue: Value;
130
- /** Optional icon element used in menus/labels */
131
- icon?: ReactNode;
132
- /** Logical field name under `filter.{name}` */
133
- name: string;
134
- /** ex-validator schema factory for the value; typically closure over config */
135
- validation: (config?: Config) => unknown;
136
- }
137
- /**
138
- * FiltersConfiguration
139
- *
140
- * Top-level collection of instantiated filters used by the Filter component
141
- * and FiltersContext. Each entry is a concrete FilterInstance (already created
142
- * via a filter factory), carrying its merged config, default value, UI
143
- * components, and validate function.
144
- */
145
- type FiltersConfiguration = FilterInstance<any, any>[];
146
- /**
147
- * FilterDisplayProps
148
- *
149
- * Props provided to a filter's Display component. Derived from an active
150
- * FilterInstance at runtime.
151
- *
152
- * @typeParam Config - Effective configuration type for the instance
153
- * @typeParam Value - Effective value type for the instance
154
- */
155
- interface FilterDisplayProps<Config, Value> {
156
- /** Merged configuration for the filter instance */
157
- config: Config;
158
- /** Current (possibly partial) value for the filter instance */
159
- value: Value;
160
- }
161
- /**
162
- * FilterFormProps
163
- *
164
- * Props provided to a filter's Form component. The `fieldName` is the
165
- * fully-qualified path in the host form, and the `config` is the instance's
166
- * merged configuration.
167
- *
168
- * @typeParam Config - Effective configuration type for the instance
169
- */
170
- interface FilterFormProps<Config> {
171
- /** Merged configuration for the filter instance */
172
- config: Config;
173
- /** Fully-qualified form field path (e.g., `filter.status`) */
174
- fieldName: string;
175
- }
176
-
177
- type SearchConfiguration = boolean | {
178
- /** Placeholder shown in the search input */
179
- placeholder?: string;
180
- };
181
-
182
- declare const filterVariants: tailwind_variants.TVReturnType<{
183
- [key: string]: {
184
- [key: string]: tailwind_variants.ClassValue | {
185
- base?: tailwind_variants.ClassValue;
186
- form?: tailwind_variants.ClassValue;
187
- searchWrapper?: tailwind_variants.ClassValue;
188
- searchShowButton?: tailwind_variants.ClassValue;
189
- searchMotionDiv?: tailwind_variants.ClassValue;
190
- searchInput?: tailwind_variants.ClassValue;
191
- searchInputWrapper?: tailwind_variants.ClassValue;
192
- searchSubmitButton?: tailwind_variants.ClassValue;
193
- addFilterMenuItem?: tailwind_variants.ClassValue;
194
- addFilterMenuButton?: tailwind_variants.ClassValue;
195
- activeFilterLabel?: tailwind_variants.ClassValue;
196
- filterModalBody?: tailwind_variants.ClassValue;
197
- filterModalHeader?: tailwind_variants.ClassValue;
198
- filterModalFooter?: tailwind_variants.ClassValue;
199
- };
200
- };
201
- } | {
202
- [x: string]: {
203
- [x: string]: tailwind_variants.ClassValue | {
204
- base?: tailwind_variants.ClassValue;
205
- form?: tailwind_variants.ClassValue;
206
- searchWrapper?: tailwind_variants.ClassValue;
207
- searchShowButton?: tailwind_variants.ClassValue;
208
- searchMotionDiv?: tailwind_variants.ClassValue;
209
- searchInput?: tailwind_variants.ClassValue;
210
- searchInputWrapper?: tailwind_variants.ClassValue;
211
- searchSubmitButton?: tailwind_variants.ClassValue;
212
- addFilterMenuItem?: tailwind_variants.ClassValue;
213
- addFilterMenuButton?: tailwind_variants.ClassValue;
214
- activeFilterLabel?: tailwind_variants.ClassValue;
215
- filterModalBody?: tailwind_variants.ClassValue;
216
- filterModalHeader?: tailwind_variants.ClassValue;
217
- filterModalFooter?: tailwind_variants.ClassValue;
218
- };
219
- };
220
- } | {}, {
221
- base: string;
222
- addFilterMenuButton: string;
223
- addFilterMenuItem: string;
224
- activeFilterLabel: string;
225
- filterModalBody: string;
226
- filterModalHeader: string;
227
- filterModalFooter: string;
228
- form: string;
229
- searchInput: string;
230
- searchInputWrapper: string;
231
- searchMotionDiv: string;
232
- searchShowButton: string;
233
- searchSubmitButton: string;
234
- searchWrapper: string;
235
- }, undefined, {
236
- [key: string]: {
237
- [key: string]: tailwind_variants.ClassValue | {
238
- base?: tailwind_variants.ClassValue;
239
- form?: tailwind_variants.ClassValue;
240
- searchWrapper?: tailwind_variants.ClassValue;
241
- searchShowButton?: tailwind_variants.ClassValue;
242
- searchMotionDiv?: tailwind_variants.ClassValue;
243
- searchInput?: tailwind_variants.ClassValue;
244
- searchInputWrapper?: tailwind_variants.ClassValue;
245
- searchSubmitButton?: tailwind_variants.ClassValue;
246
- addFilterMenuItem?: tailwind_variants.ClassValue;
247
- addFilterMenuButton?: tailwind_variants.ClassValue;
248
- activeFilterLabel?: tailwind_variants.ClassValue;
249
- filterModalBody?: tailwind_variants.ClassValue;
250
- filterModalHeader?: tailwind_variants.ClassValue;
251
- filterModalFooter?: tailwind_variants.ClassValue;
252
- };
253
- };
254
- } | {}, {
255
- base: string;
256
- addFilterMenuButton: string;
257
- addFilterMenuItem: string;
258
- activeFilterLabel: string;
259
- filterModalBody: string;
260
- filterModalHeader: string;
261
- filterModalFooter: string;
262
- form: string;
263
- searchInput: string;
264
- searchInputWrapper: string;
265
- searchMotionDiv: string;
266
- searchShowButton: string;
267
- searchSubmitButton: string;
268
- searchWrapper: string;
269
- }, tailwind_variants.TVReturnType<unknown, {
270
- base: string;
271
- addFilterMenuButton: string;
272
- addFilterMenuItem: string;
273
- activeFilterLabel: string;
274
- filterModalBody: string;
275
- filterModalHeader: string;
276
- filterModalFooter: string;
277
- form: string;
278
- searchInput: string;
279
- searchInputWrapper: string;
280
- searchMotionDiv: string;
281
- searchShowButton: string;
282
- searchSubmitButton: string;
283
- searchWrapper: string;
284
- }, undefined, unknown, unknown, undefined>>;
285
- type ClassName = TVClassName<typeof filterVariants>;
286
- interface FilterValues {
287
- search?: string;
288
- filter?: string | Record<string, unknown> | null;
289
- }
290
- type FilterChildRenderFn = (values: {
291
- search?: string;
292
- filter?: Record<string, unknown>;
293
- }) => ReactNode;
294
- /**
295
- * Filter
296
- *
297
- * Controlled, form-driven filter UI.
298
- *
299
- * Responsibilities
300
- * - Derives initial form values from the controlled `values` prop
301
- * - Builds a composite validation schema from the filter registry (and optional search)
302
- * - Exposes ergonomic UI: active filters list, add/remove actions, and per-filter modal
303
- * - Commits changes by invoking the controlled `onChange` callback on submit
304
- *
305
- * Structure
306
- * - Owns an ex-forms `Form` that wraps the entire filter experience
307
- * - Optionally renders a search input bound to the `search` field
308
- * - Renders ActiveFilters, AddFilterMenu, and FilterModal inside a shared context
309
- * - Optionally renders children as a render-prop with the resolved `values`
310
- */
311
- interface FilterProps {
312
- /** Optional render-prop that receives the resolved, controlled values */
313
- children?: FilterChildRenderFn;
314
- /** CSS class name */
315
- className?: ClassName;
316
- /** Configuration of the filter */
317
- config: {
318
- /**
319
- * Declarative filter configuration. Each entry ties a logical name to a
320
- * registry filter type and (optionally) per-usage config overrides.
321
- */
322
- filters: FiltersConfiguration;
323
- /** Optional configuration for search field */
324
- search?: SearchConfiguration;
325
- };
326
- /** ex-forms form instance name. Defaults to "filterComponentForm". */
327
- formName?: string;
328
- /** Controlled setter invoked on submit with the next canonical values */
329
- onChange: (nextValues: FilterValues) => void;
330
- /** Controlled committed state: the canonical `search` and `filter` values */
331
- values: FilterValues;
332
- }
333
- /**
334
- * Renders the filter UI bound to a single ex-forms `Form`.
335
- * The form is the source of truth during user interaction; the committed
336
- * state is controlled by the parent via `values`/`onChange`.
337
- */
338
- declare const Filter: ({ children, className, config, formName, onChange, values, }: FilterProps) => react_jsx_runtime.JSX.Element;
339
-
340
- /**
341
- * createFilter
342
- *
343
- * Builds a filter factory from a static FilterDefinition. The returned factory
344
- * accepts a usage descriptor (name/icon and optional partial config) and
345
- * produces a concrete FilterInstance with:
346
- * - merged config (shallow: definition.defaults.config overlaid by overrides)
347
- * - Form/Display components
348
- * - validate function (forwarded from the definition)
349
- * - defaultValue (forwarded from the definition)
350
- * - name and icon for UI integration
351
- *
352
- * @typeParam Config - Configuration object shape for the filter
353
- * @typeParam Value - Runtime value type for the filter
354
- * @param definition - Static description of the filter (components, defaults, validate)
355
- * @returns FilterFactory that creates FilterInstance<Config, Value>
356
- */
357
- declare const createFilter: <Config, Value>(definition: FilterDefinition<Config, Value>) => FilterFactory<Config, Value>;
358
-
359
- declare const filters: {
360
- boolean: FilterFactory<{
361
- text: string;
362
- textPrefix?: string | undefined;
363
- textNoWord?: string | undefined;
364
- }, boolean | undefined>;
365
- checkboxes: FilterFactory<Config, string[]>;
366
- };
367
-
368
- export { type FilterChildRenderFn, type FilterDefinition, type FilterDisplayProps, type FilterFactory, type FilterFormProps, type FilterInstance, type FilterProps, type FilterValues, type FiltersConfiguration, createFilter, Filter as default, filterVariants, filters };
1
+ import { a as FilterProps, c as FilterDefinition, d as FilterFormProps, f as FilterInstance, i as FilterChildRenderFn, l as FilterDisplayProps, n as createFilter, o as FilterValues, p as FiltersConfiguration, r as Filter, s as filterVariants, t as filters, u as FilterFactory } from "../index-OWKeKysC.js";
2
+ export { FilterChildRenderFn, FilterDefinition, FilterDisplayProps, FilterFactory, FilterFormProps, FilterInstance, FilterProps, FilterValues, FiltersConfiguration, createFilter, Filter as default, filterVariants, filters };
@@ -1,13 +1,3 @@
1
- import {
2
- Filter_default,
3
- createFilter_default,
4
- filterVariants,
5
- filters
6
- } from "../chunk-NQHJXFFH.js";
7
- export {
8
- createFilter_default as createFilter,
9
- Filter_default as default,
10
- filterVariants,
11
- filters
12
- };
13
- //# sourceMappingURL=index.js.map
1
+ import { i as filterVariants, n as filters, r as createFilter_default, t as Filter_default } from "../Filter-nSuQco2t.js";
2
+
3
+ export { createFilter_default as createFilter, Filter_default as default, filterVariants, filters };