feat: Standalone reusable FilterPanel component with declarative FilterEditor children#93
feat: Standalone reusable FilterPanel component with declarative FilterEditor children#93Copilot wants to merge 6 commits into
Conversation
|
@copilot We're going to need documentation and specs and screenshots from the Storybook stories in the PR comments to verify if its ok |
Here's what was added in response to your request: 📄 DocumentationCreated
🧪 SpecsExtracted
All 9 new specs pass ( 🛠️ Storybook build fixFixed a pre-existing build failure in 📸 ScreenshotsThe sandboxed CI environment was unable to render the Storybook preview iframe in a headless browser (the iframe consistently showed "No Preview" regardless of wait time), so inline screenshots could not be attached here. You can run
|
|
@copilot let’s make the filter editors something we can have as declarative within the FilterPanel as children instead of the FilterDefinition thing. |
Done in commit <FilterPanel filters={filters} customValues={customValues} onCustomValueChange={handleCustomValueChange} {...rest}>
<FilterEditor filterKey="rating">
{({ value, onChange }) => <MyStarRatingWidget value={value as number} onChange={onChange} />}
</FilterEditor>
</FilterPanel>Changes:
|
|
@copilot Fix the build issue |
Fixed in the latest commit. The CI failure was an ESLint |
Extracts the filter UI from
PivotViewerinto a generic, standaloneFilterPanelcomponent that can be used independently of any data viewer.Added
Source/Filter/module: standaloneFilterPanel,FilterEditor,RangeHistogramFilter,useFilterStatehook, and full TypeScript type definitions (FilterDefinition,FilterEditorProps,FilterEditorSlotProps,FilterValues,RangeValues,CustomFilterValues) (#102)FilterEditorslot component — declares a custom editor for a specific filter group as a declarative child of<FilterPanel>; value tracked separately incustomValues(#102)type: 'custom'filter type as an explicit opt-in for fully custom filter editors (#102)FilterPanel: single-select, multi-select, numeric range/histogram, custom editor, and mixed filter types (#102)./Filtersubpath export inpackage.jsonfor direct imports via@cratis/components/Filter(#102)Documentation/Filter/index.md— full API reference covering all exported types,FilterPanelprops,FilterEditorprops,useFilterStatehook, and usage examples for every filter type (#102)Source/Filter/for_useFilterState/coveringbuildFilterValuesandbuildRangeValues— 9 tests across 4 spec files (#102)Source/Filter/utils.tsexportingbuildFilterValuesandbuildRangeValuesas pure, testable utility functions (#102)Changed
FilterPanelacceptschildren?: ReactNode— usesReact.Children+isValidElementto discover<FilterEditor>slots and render them in the matching filter group (#102)PivotViewer/components/FilterPanel.tsxis now a thin adapter: convertsPivotFilter<TItem>[]+ computed options intoFilterDefinition[], generates<FilterEditor>children from anyPivotFilter.renderEditor, and delegates all rendering to the new standalone component — no breaking changes to the public API (#102)PivotFilter<TItem>retainsrenderEditor?andtype: 'custom'so PivotViewer consumers can inject custom filter editors without any workarounds (#102)Source/Filter/useFilterState.tsnow importsbuildFilterValuesandbuildRangeValuesfrom./utils(#102)Documentation/toc.ymlupdated with Filter entries in both the Storybook section and Common Components section (#102)eslint.config.mjs— addedargsIgnorePattern: '^_'to the@typescript-eslint/no-unused-varsrule to honour the_-prefix convention for intentionally unused parameters (#102)Fixed
storybook build) now completes successfully — fixed a pre-existing[lightningcss minify] Invalid empty selectorcrash by addingcssMinify: falseto theviteFinalconfig inSource/.storybook/main.ts(#102)_propsinFilterEditor.tsxas unused — resolved by addingargsIgnorePattern: '^_'to the ESLint rule config (#102)Usage — custom editor in standalone context: