Skip to content

Commit 991dc2c

Browse files
committed
Add types
1 parent 44f23d8 commit 991dc2c

9 files changed

Lines changed: 1305 additions & 4 deletions

File tree

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ type-only module erased by the bundler), and allows `./foo.jsx` under `dist/sour
113113
- `ReactNode``LabelNode` (`JSX.Element | string`); titles stay `string`.
114114
- `ComponentType<P>` → Solid's `Component<P>`.
115115
- Use `import type` for type-only imports (`verbatimModuleSyntax` is on).
116+
- `ReactMouseEvent` → the DOM `MouseEvent`.
117+
- `QueryBuilderProps` stays the **conditional type React writes**. Solid components are plain
118+
functions with no compile-time prop enumeration, so there is no `QueryBuilderPropsBase`, no
119+
`RuleTypeOf<RG>` helper, and no re-widening cast inside components (all of which Vue needed).
120+
- `src/types/types.test-d.ts` is compiled by `tsc` (`bun run check`), **not** run by Vitest. It is
121+
a **two-sided** gate: a failed assertion errors, and an `@ts-expect-error` that stops erroring
122+
(member quietly re-added) errors as `TS2578`. Both directions proven at step 2.
116123
- **TypeScript is pinned to `^5.9`.** Neither `vite-plugin-solid`'s babel preset nor the
117124
declaration pipeline is validated against TypeScript 7.
118125

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { Placeholder } from './components/Placeholder.jsx';
2+
export type * from './types/index.js';
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
import type { FullField } from '@react-querybuilder/core';
2+
import type { Component } from 'solid-js';
3+
import type {
4+
ActionProps,
5+
CombinatorSelectorProps,
6+
FieldSelectorProps,
7+
InlineCombinatorProps,
8+
MatchModeEditorProps,
9+
NotToggleProps,
10+
OperatorSelectorProps,
11+
RuleGroupProps,
12+
RuleProps,
13+
ShiftActionsProps,
14+
UndoRedoActionsProps,
15+
ValueEditorProps,
16+
ValueSelectorProps,
17+
ValueSourceSelectorProps,
18+
} from './props.js';
19+
20+
/**
21+
* Subcomponents.
22+
*
23+
* There is no `dragHandle` entry: drag-and-drop is a non-goal. There are no
24+
* `ruleGroupHeaderElements`/`ruleGroupBodyElements` entries either; to customize the contents
25+
* of a group's header or body, use a replacement `ruleGroup` component.
26+
*
27+
* @group Props
28+
*/
29+
export type ControlElementsProp<F extends FullField, O extends string> = Partial<{
30+
/**
31+
* Default component for all button-type controls.
32+
*
33+
* @default ActionElement
34+
*/
35+
actionElement: Component<ActionProps>;
36+
/**
37+
* Adds a sub-group to the current group.
38+
*
39+
* @default ActionElement
40+
*/
41+
addGroupAction: Component<ActionProps> | null;
42+
/**
43+
* Adds a rule to the current group.
44+
*
45+
* @default ActionElement
46+
*/
47+
addRuleAction: Component<ActionProps> | null;
48+
/**
49+
* Clones the current group.
50+
*
51+
* @default ActionElement
52+
*/
53+
cloneGroupAction: Component<ActionProps> | null;
54+
/**
55+
* Clones the current rule.
56+
*
57+
* @default ActionElement
58+
*/
59+
cloneRuleAction: Component<ActionProps> | null;
60+
/**
61+
* Selects the `combinator` property for the current group, or the current independent
62+
* combinator value.
63+
*
64+
* @default ValueSelector
65+
*/
66+
combinatorSelector: Component<CombinatorSelectorProps> | null;
67+
/**
68+
* Selects the `field` property for the current rule.
69+
*
70+
* @default ValueSelector
71+
*/
72+
fieldSelector: Component<FieldSelectorProps<F>> | null;
73+
/**
74+
* A small wrapper around the `combinatorSelector` component.
75+
*
76+
* @default InlineCombinator
77+
*/
78+
inlineCombinator: Component<InlineCombinatorProps> | null;
79+
/**
80+
* Locks the current group (sets the `disabled` property to `true`).
81+
*
82+
* @default ActionElement
83+
*/
84+
lockGroupAction: Component<ActionProps> | null;
85+
/**
86+
* Locks the current rule (sets the `disabled` property to `true`).
87+
*
88+
* @default ActionElement
89+
*/
90+
lockRuleAction: Component<ActionProps> | null;
91+
/**
92+
* Mutes the current group (sets the `muted` property to `true`).
93+
*
94+
* @default ActionElement
95+
*/
96+
muteGroupAction: Component<ActionProps> | null;
97+
/**
98+
* Mutes the current rule (sets the `muted` property to `true`).
99+
*
100+
* @default ActionElement
101+
*/
102+
muteRuleAction: Component<ActionProps> | null;
103+
/**
104+
* Selects the `match` property for the current rule.
105+
*
106+
* @default MatchModeEditor
107+
*/
108+
matchModeEditor: Component<MatchModeEditorProps> | null;
109+
/**
110+
* Toggles the `not` property of the current group between `true` and `false`.
111+
*
112+
* @default NotToggle
113+
*/
114+
notToggle: Component<NotToggleProps> | null;
115+
/**
116+
* Selects the `operator` property for the current rule.
117+
*
118+
* @default ValueSelector
119+
*/
120+
operatorSelector: Component<OperatorSelectorProps> | null;
121+
/**
122+
* Removes the current group from its parent group's `rules` array.
123+
*
124+
* @default ActionElement
125+
*/
126+
removeGroupAction: Component<ActionProps> | null;
127+
/**
128+
* Removes the current rule from its parent group's `rules` array.
129+
*
130+
* @default ActionElement
131+
*/
132+
removeRuleAction: Component<ActionProps> | null;
133+
/**
134+
* Rule layout component.
135+
*
136+
* @default Rule
137+
*/
138+
rule: Component<RuleProps>;
139+
/**
140+
* Rule group layout component.
141+
*
142+
* @default RuleGroup
143+
*/
144+
ruleGroup: Component<RuleGroupProps<F, O>>;
145+
/**
146+
* Shifts the current rule/group up or down in the query hierarchy.
147+
*
148+
* @default ShiftActions
149+
*/
150+
shiftActions: Component<ShiftActionsProps> | null;
151+
/**
152+
* Undo/redo buttons for the outermost group, rendered when the `showUndoRedo` prop is
153+
* `true`.
154+
*
155+
* @default UndoRedoActions
156+
*/
157+
undoRedoActions: Component<UndoRedoActionsProps> | null;
158+
/**
159+
* Updates the `value` property for the current rule.
160+
*
161+
* @default ValueEditor
162+
*/
163+
valueEditor: Component<ValueEditorProps<F, O>> | null;
164+
/**
165+
* Default component for all value selector controls.
166+
*
167+
* @default ValueSelector
168+
*/
169+
valueSelector: Component<ValueSelectorProps>;
170+
/**
171+
* Selects the `valueSource` property for the current rule.
172+
*
173+
* @default ValueSelector
174+
*/
175+
valueSourceSelector: Component<ValueSourceSelectorProps> | null;
176+
}>;
177+
178+
/**
179+
* All subcomponents, finalized: every key is present and non-nullable. `null` entries in
180+
* {@link ControlElementsProp} are replaced with a component that renders nothing, so no call
181+
* site needs a null check.
182+
*
183+
* Unlike React Query Builder, `undoRedoActions` is non-nullable: `QueryManager` owns the
184+
* history, so this package always ships a working implementation.
185+
*
186+
* @group Props
187+
*/
188+
export type Controls<F extends FullField, O extends string> = {
189+
[K in keyof Required<ControlElementsProp<F, O>>]-?: NonNullable<
190+
Required<ControlElementsProp<F, O>>[K]
191+
>;
192+
};
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Type definitions for `solid-querybuilder`.
3+
*
4+
* Everything not defined here is re-exported verbatim from `@react-querybuilder/core`, so
5+
* consumers never need a direct dependency on the core package.
6+
*/
7+
8+
export type * from './controls.js';
9+
export type * from './props.js';
10+
export type * from './schema.js';
11+
export type * from './translations.js';
12+
export type * from '@react-querybuilder/core';

0 commit comments

Comments
 (0)