DmQuery
DmQuery documents the DmQuery export from duskmoon.
@duskmoon-dev/components/dm-query Usage
When to use
- Use it in DuskMoon application screens that need a packaged, opinionated workflow component.
- Reach for the lower-level standard component when the screen needs custom composition.
Implementation notes
Features
Wraps lower-level primitives into a higher-level DuskMoon-prefixed workflow API.
Examples show the defaults and composition points expected by internal DuskMoon app screens.
DmQuery is most often configured through `queryItem`, `fastFilterItem`, `collapsed`, `form`.
Maps queryItem to Dm search items and exposes retractChange
Feature Demos
Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.
Basic usage
Import the component stylesheet and DmQuery from its package subpath, then render it with the core props.
import "@duskmoon-dev/components/styles.css";
import { DmQuery } from "@duskmoon-dev/components/dm-query";
export function Example() {
return (<DmQuery
queryItem={[{
key: "name",
type: "input",
label: "Name",
name: "name"
}]}
onSearch={(values) => console.log(values)}
/>);
} Maps queryItem to Dm search items and exposes retractChange
test-backedDmQuery scenario from the component test coverage: maps queryitem to dm search items and exposes retractchange.
import "@duskmoon-dev/components/styles.css";
import { DmQuery } from "@duskmoon-dev/components/dm-query";
export function DmQueryMapsQueryItemToDmDemo() {
return (<DmQuery
queryItem={[{
key: "name",
type: "input",
label: "Name",
name: "name"
}]}
onSearch={(values) => console.log(values)}
/>);
} Theme aware
Docs previews inherit the DuskMoon data-theme value. Use the header switch to compare light and dark rendering.
<div data-theme="sunshine">
<DmQuery
queryItem={[{
key: "name",
type: "input",
label: "Name",
name: "name"
}]}
onSearch={(values) => console.log(values)}
/>
</div>
<div data-theme="moonlight">
<DmQuery
queryItem={[{
key: "name",
type: "input",
label: "Name",
name: "name"
}]}
onSearch={(values) => console.log(values)}
/>
</div> API
The API reference below lists every parsed exported type or interface for DmQuery. Start with `queryItem`, `fastFilterItem`, `collapsed`, `form` for common usage.
packages/components/src/components/dm-query/DmQuery.types.ts
Scenarios: packages/components/src/components/dm-query/DmQuery.test.tsx | Prop | Type | Required | Description |
|---|---|---|---|
queryItem | DmQueryItem[] | Yes | queryItem configures DmQuery. |
fastFilterItem | DmQueryItem | No | fastFilterItem configures DmQuery. |
collapsed | boolean | No | collapsed configures DmQuery. |
form | unknown | No | form configures DmQuery. |
onReset | () => void | No | onReset configures DmQuery. |
| Prop | Type | Required | Description |
|---|---|---|---|
retractChange | (value: string, data?: DmQueryItem[]) => void | Yes | retractChange configures DmQuery. |
{ key: string