![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@stenajs-webui/filter
Advanced tools
This package contains components and functionality that makes it easy to create custom filters in a drawer, and an overview row containing chips.
This package is alpha. API:s will most likely change, and more features added. If you use it, be ready for breaking changes.
A section is one expandable part of the filter. The filter can consist of many sections. Each section can how none, one or many chips.
The filter components access state, dispatch and actions. These are fetched from context, so any filter components must be wrapped with
<SearchFilterContext actions={actions} state={state} dispatch={dispatch}>
<SearchFilterButton/>
<SearchFilterChips>
<SectionChips {...stuff} />
</SearchFilterChips>
<SearchFilterDrawer>
... sections
</SearchFilterDrawer>
If you are only using local state (no Redux, persistence, etc),
you can use SearchFilterLocalStateContext
.
It will automatically setup actions, state and dispatch.
<SearchFilterLocalStateContext<FormModel>
initialFormModel={{ startDate: undefined, endDate: undefined }}
>
... same as above
</SearchFilterLocalStateContext>
If you use SearchFilterLocalStateContext
, you can use this to access filter state.
const state = useSearchFilterState();
You can create custom sections easily.
const MySection = (...props) => (
<SearchFilterSection sectionId={sectionId} loading={loading} error={error}>
<ChipMultiSelect
options={filteredOptions}
value={listValue}
onValueChange={onValueChangeInternal}
inputValue={text}
onInputChange={setText}
/>
</SearchFilterSection>
);
See source code for examples.
There are sections available ready to use.
More will be made available as the filter
package matures.
Add the section to the drawer.
<DateRangeCalendarSection
sectionId={"comparisonDate"}
{...createDateRangeSectionProps(state.formModel, "startDate", "endDate")}
/>
And add the chips.
<SectionChips
sectionId={"comparisonDate"}
emptyChipLabel={"No dates"}
{...createChipsPropsForDateRange(state.formModel, "startDate", "endDate")}
/>
Add the section to the drawer. This section does not have a helper method for creating props.
They must be specified manually. This might change.
<ChipMultiSelectSection
sectionId={"divisions"}
loading={false}
options={divisionOptions}
value={state.formModel.divisions}
onValueChange={(divisions) =>
dispatch(actions.setFormModelFields({ divisions }))
}
/>
And add the chips.
<SectionChips
sectionId={"divisions"}
emptyChipLabel={"All division"}
{...createChipsPropsForBooleanRecord(
state.formModel,
"divisions",
divisionOptions
)}
/>
In this example, state.formModel.divisions
must be a BooleanRecord
.
Another section for BooleanRecord
is SimpleCheckboxListSection
.
They are API compatible and are interchangeable.
<SimpleCheckboxListSection
sectionId={"divisions"}
loading={false}
options={divisionOptions}
value={state.formModel.divisions}
onValueChange={(divisions) =>
dispatch(actions.setFormModelFields({ divisions }))
}
/>
You can add all chips for a section using the SectionChips
component.
<SectionChips
sectionId={"divisions"}
emptyChipLabel={"All division"}
{...createChipsPropsForBooleanRecord(
state.formModel,
"divisions",
divisionOptions
)}
/>
If you need more manual control over each chip, you can add them individually.
{
myList.map(({ value, label }) => (
<SearchFilterChip
key={value}
label={label ?? sectionId}
sectionId={sectionId}
onClickRemove={onClickRemoveOnChip}
value={value}
/>
));
}
If you need a chip to indicate no selection, you can use EmptyChip
.
<EmptyChip sectionId={sectionId} label={emptyChipLabel} />
FAQs
Unknown package
We found that @stenajs-webui/filter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.