Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ jobs:
- run: bun run build
- run: bun run lint --format=github
- run: bun run fmt --check
- run: bun run are-the-types-wrong
23 changes: 22 additions & 1 deletion .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"$schema": "./node_modules/oxfmt/configuration_schema.json",
"ignorePatterns": [],
"printWidth": 100,
"tabWidth": 2,
"useTabs": false,
Expand All @@ -15,6 +14,28 @@
"sortImports": {
"newlinesBetween": false
},
"ignorePatterns": [
// Hidden(ish) files
"**/.*",
// Generated
"*Parser.js",
// Binaries
"*.jpeg",
"*.jpg",
"*.png",
"*.svg",
"bun.lockb",
// Unsupported
"*.jison",
"*.toml",
"CNAME",
"*.go",
"go.mod",
"go.sum",
// Misc
"lerna.json",
"bun.lock"
],
"overrides": [{
"files": ["example/**/*.ts{,x}"],
"options": {
Expand Down
24 changes: 0 additions & 24 deletions .prettierignore

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Official [react-querybuilder](https://npmjs.com/package/react-querybuilder) comp
## Installation

```bash
npm i react-querybuilder @react-querybuilder/chakra @chakra-ui/icons@2 @chakra-ui/react@2 @chakra-ui/system@2 @emotion/react @emotion/styled framer-motion
npm i react-querybuilder @react-querybuilder/chakra2 @chakra-ui/icons@2 @chakra-ui/react@2 @chakra-ui/system@2 @emotion/react @emotion/styled framer-motion
# OR yarn add / pnpm add / bun add
```

Expand All @@ -27,7 +27,7 @@ To configure the query builder to use Chakra-compatible components, place `Query

```tsx
import { ChakraProvider, extendTheme } from '@chakra-ui/react';
import { QueryBuilderChakra } from '@react-querybuilder/chakra';
import { QueryBuilderChakra } from '@react-querybuilder/chakra2';
import { useState } from 'react';
import { type Field, QueryBuilder, type RuleGroupType } from 'react-querybuilder';

Expand Down Expand Up @@ -83,6 +83,7 @@ export function App() {
| `ChakraActionElement` | `controlElements.actionElement` |
| `ChakraDragHandle` | `controlElements.dragHandle` |
| `ChakraNotToggle` | `controlElements.notToggle` |
| `ChakraShiftActions` | `controlElements.shiftActions` |
| `ChakraValueEditor` | `controlElements.valueEditor` |
| `ChakraValueSelector` | `controlElements.valueSelector` |

Expand Down
4 changes: 0 additions & 4 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
"dependencies": {
"@chakra-ui/icons": "^2",
"@chakra-ui/react": "^2",
"@chakra-ui/system": "^2",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@react-querybuilder/chakra2": "8.24.0",
"framer-motion": "^11",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-querybuilder": "8.24.0"
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@
"peerDependencies": {
"@chakra-ui/icons": "^2",
"@chakra-ui/react": "^2",
"@chakra-ui/system": "^2",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"framer-motion": "^11",
"react": ">=18",
"react-querybuilder": "^8"
}
Expand Down
20 changes: 0 additions & 20 deletions prettier.config.mjs

This file was deleted.

3 changes: 2 additions & 1 deletion src/ChakraActionElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export const ChakraActionElement = ({
title,
disabled,
disabledTranslation,
testID,
// Props that should not be in extraProps
testID: _testID,
rules: _rules,
level: _level,
path: _path,
Expand All @@ -24,6 +24,7 @@ export const ChakraActionElement = ({
...extraProps
}: ChakraActionProps): React.JSX.Element => (
<Button
data-testid={testID}
className={className}
title={disabledTranslation && disabled ? disabledTranslation.title : title}
onClick={e => handleOnClick(e)}
Expand Down
12 changes: 6 additions & 6 deletions src/ChakraDragHandle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import * as React from 'react';
import { forwardRef } from 'react';
import type { DragHandleProps } from 'react-querybuilder';

type IBP = ComponentPropsWithRef<typeof IconButton>;
type IconButtonProps = ComponentPropsWithRef<typeof IconButton>;

export type ChakraDragHandleProps = DragHandleProps &
Omit<IBP, 'aria-label'> &
Partial<Pick<IBP, 'aria-label'>>;
Omit<IconButtonProps, 'aria-label'> &
Partial<Pick<IconButtonProps, 'aria-label'>>;

export const ChakraDragHandle: React.ForwardRefExoticComponent<
Omit<ChakraDragHandleProps, 'ref'> & React.RefAttributes<HTMLSpanElement>
Expand All @@ -19,8 +19,8 @@ export const ChakraDragHandle: React.ForwardRefExoticComponent<
className,
title,
disabled,
testID,
// Props that should not be in extraProps
testID: _testID,
level: _level,
path: _path,
label: _label,
Expand All @@ -32,11 +32,11 @@ export const ChakraDragHandle: React.ForwardRefExoticComponent<
},
dragRef
) => (
<span ref={dragRef} className={className} title={title}>
<span data-testid={testID} ref={dragRef} className={className} title={title}>
<IconButton
isDisabled={disabled}
icon={<DragHandleIcon />}
aria-label={title ?? /* istanbul ignore next */ ''}
aria-label={title ?? ''}
{...extraProps}
/>
</span>
Expand Down
3 changes: 2 additions & 1 deletion src/ChakraNotToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export const ChakraNotToggle = ({
checked,
title,
disabled,
testID,
// Props that should not be in extraProps
path: _path,
context: _context,
validation: _validation,
testID: _testID,
schema: _schema,
ruleGroup: _ruleGroup,
...extraProps
Expand All @@ -27,6 +27,7 @@ export const ChakraNotToggle = ({
return (
<div style={{ display: 'inline-block' }}>
<FormControl
data-testid={testID}
display="flex"
alignItems="center"
className={className}
Expand Down
18 changes: 12 additions & 6 deletions src/ChakraValueEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { ValueEditorProps } from 'react-querybuilder';
import { ValueEditor, useValueEditor } from 'react-querybuilder';

// oxlint-disable-next-line no-explicit-any
type ChakraValueEditorProps = ValueEditorProps & { extraProps?: Record<string, any> };
export type ChakraValueEditorProps = ValueEditorProps & { extraProps?: Record<string, any> };

export const ChakraValueEditor = (allProps: ChakraValueEditorProps): React.JSX.Element | null => {
const {
Expand All @@ -19,7 +19,7 @@ export const ChakraValueEditor = (allProps: ChakraValueEditorProps): React.JSX.E
values = [],
listsAsArrays: _listsAsArrays,
separator,
valueSource: _vs,
valueSource: _valueSource,
testID,
disabled,
selectorComponent: SelectorComponent = allProps.schema.controls.valueSelector,
Expand All @@ -34,7 +34,7 @@ export const ChakraValueEditor = (allProps: ChakraValueEditorProps): React.JSX.E
return null;
}

const placeHolderText = fieldData?.placeholder ?? '';
const placeholderText = fieldData?.placeholder ?? '';
const inputTypeCoerced = ['in', 'notIn'].includes(operator) ? 'text' : inputType || 'text';

if (
Expand All @@ -50,7 +50,7 @@ export const ChakraValueEditor = (allProps: ChakraValueEditorProps): React.JSX.E
value={valueAsArray[i] ?? ''}
isDisabled={disabled}
className={valueListItemClassName}
placeholder={placeHolderText}
placeholder={placeholderText}
onChange={e => multiValueHandler(e.target.value, i)}
{...extraProps}
/>
Expand All @@ -72,6 +72,7 @@ export const ChakraValueEditor = (allProps: ChakraValueEditorProps): React.JSX.E
return (
<SelectorComponent
{...propsForValueSelector}
data-testid={testID}
className={className}
title={title}
value={value}
Expand All @@ -87,11 +88,12 @@ export const ChakraValueEditor = (allProps: ChakraValueEditorProps): React.JSX.E
case 'textarea':
return (
<Textarea
data-testid={testID}
value={value}
title={title}
isDisabled={disabled}
className={className}
placeholder={placeHolderText}
placeholder={placeholderText}
onChange={e => handleOnChange(e.target.value)}
{...extraProps}
/>
Expand All @@ -100,6 +102,7 @@ export const ChakraValueEditor = (allProps: ChakraValueEditorProps): React.JSX.E
case 'switch':
return (
<Switch
data-testid={testID}
className={className}
isChecked={!!value}
title={title}
Expand All @@ -112,6 +115,7 @@ export const ChakraValueEditor = (allProps: ChakraValueEditorProps): React.JSX.E
case 'checkbox':
return (
<Checkbox
data-testid={testID}
className={className}
title={title}
isDisabled={disabled}
Expand All @@ -124,6 +128,7 @@ export const ChakraValueEditor = (allProps: ChakraValueEditorProps): React.JSX.E
case 'radio':
return (
<RadioGroup
data-testid={testID}
className={className}
title={title}
value={value}
Expand All @@ -143,12 +148,13 @@ export const ChakraValueEditor = (allProps: ChakraValueEditorProps): React.JSX.E

return (
<Input
data-testid={testID}
type={inputTypeCoerced}
value={value}
title={title}
isDisabled={disabled}
className={className}
placeholder={placeHolderText}
placeholder={placeholderText}
onChange={e => handleOnChange(e.target.value)}
{...extraProps}
/>
Expand Down
Loading