@react-querybuilder/antd 4.0.0-beta.7 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +117 -47
- package/dist/types/AntDActionElement.d.ts +1 -1
- package/dist/types/AntDDragHandle.d.ts +2 -2
- package/dist/types/AntDNotToggle.d.ts +1 -1
- package/dist/types/AntDValueEditor.d.ts +1 -1
- package/dist/types/AntDValueSelector.d.ts +1 -1
- package/dist/types/utils.d.ts +4 -0
- package/package.json +5 -4
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var
|
|
1
|
+
"use strict";var q=Object.defineProperty,B=Object.defineProperties;var I=Object.getOwnPropertyDescriptors;var m=Object.getOwnPropertySymbols;var g=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var k=(e,t,n)=>t in e?q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,b=(e,t)=>{for(var n in t||(t={}))g.call(t,n)&&k(e,n,t[n]);if(m)for(var n of m(t))D.call(t,n)&&k(e,n,t[n]);return e},h=(e,t)=>B(e,I(t));var S=(e,t)=>{var n={};for(var l in e)g.call(e,l)&&t.indexOf(l)<0&&(n[l]=e[l]);if(e!=null&&m)for(var l of m(e))t.indexOf(l)<0&&D.call(e,l)&&(n[l]=e[l]);return n};Object.defineProperty(exports,"__esModule",{value:!0});exports[Symbol.toStringTag]="Module";var f=require("react"),u=require("antd"),j=require("@ant-design/icons");function G(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var a=G(f);const w=({className:e,handleOnClick:t,label:n,title:l,disabled:c})=>a.default.createElement(u.Button,{type:"primary",className:e,title:l,onClick:r=>t(r),disabled:c},n);w.displayName="AntDActionElement";const x=f.forwardRef(({className:e,title:t},n)=>a.default.createElement("span",{ref:n,className:e,title:t},a.default.createElement(j.HolderOutlined,null)));x.displayName="AntDDragHandle";const C=({className:e,handleOnChange:t,label:n,checked:l,title:c,disabled:r})=>a.default.createElement(u.Switch,{title:c,className:e,onChange:d=>t(d),checked:!!l,disabled:r,checkedChildren:n,unCheckedChildren:"="});C.displayName="AntDNotToggle";const{OptGroup:M,Option:N}=u.Select,L=e=>Array.isArray(e)&&e.length>0&&"options"in e[0],O=e=>L(e)?e.map(t=>a.default.createElement(M,{key:t.label,label:t.label},t.options.map(n=>a.default.createElement(N,{key:n.name,value:n.name},n.label)))):Array.isArray(e)?e.map(t=>a.default.createElement(N,{key:t.name,value:t.name},t.label)):null,p=({className:e,handleOnChange:t,options:n,value:l,title:c,disabled:r})=>a.default.createElement("span",{title:c,className:e},a.default.createElement(u.Select,{disabled:r,value:l,onChange:d=>t(d)},O(n)));p.displayName="AntDValueSelector";const V=P=>{var y=P,{fieldData:e,operator:t,value:n,handleOnChange:l,title:c,className:r,type:d,inputType:s,values:A,disabled:i}=y,H=S(y,["fieldData","operator","value","handleOnChange","title","className","type","inputType","values","disabled"]);var E;if(f.useEffect(()=>{s==="number"&&!["between","notBetween","in","notIn"].includes(t)&&typeof n=="string"&&n.includes(",")&&l("")},[s,t,n,l]),t==="null"||t==="notNull")return null;const _=(E=e==null?void 0:e.placeholder)!=null?E:"",R=["between","notBetween","in","notIn"].includes(t)?"text":s||"text";switch(d){case"select":return a.default.createElement(p,h(b({},H),{className:r,handleOnChange:l,options:A,value:n,title:c,disabled:i}));case"checkbox":return a.default.createElement("span",{title:c},a.default.createElement(u.Checkbox,{type:"checkbox",className:r,disabled:i,onChange:o=>l(o.target.checked),checked:!!n}));case"radio":return a.default.createElement("span",{className:r,title:c},A.map(o=>a.default.createElement(u.Radio,{key:o.name,value:o.name,checked:n===o.name,disabled:i,onChange:T=>l(T.target.value)},o.label)));default:return a.default.createElement(u.Input,{type:R,value:n,title:c,className:r,disabled:i,placeholder:_,onChange:o=>l(o.target.value)})}};V.displayName="AntDValueEditor";exports.AntDActionElement=w;exports.AntDDragHandle=x;exports.AntDNotToggle=C;exports.AntDValueEditor=V;exports.AntDValueSelector=p;
|
package/dist/index.es.js
CHANGED
|
@@ -1,42 +1,121 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
1
32
|
import React, { forwardRef, useEffect } from "react";
|
|
2
|
-
import { Button, Switch, Input, Radio, Checkbox
|
|
33
|
+
import { Button, Switch, Select, Input, Radio, Checkbox } from "antd";
|
|
3
34
|
import { HolderOutlined } from "@ant-design/icons";
|
|
4
|
-
const AntDActionElement = ({ className, handleOnClick, label, title }) => /* @__PURE__ */ React.createElement(Button, {
|
|
35
|
+
const AntDActionElement = ({ className, handleOnClick, label, title, disabled }) => /* @__PURE__ */ React.createElement(Button, {
|
|
5
36
|
type: "primary",
|
|
6
37
|
className,
|
|
7
38
|
title,
|
|
8
|
-
onClick: (e) => handleOnClick(e)
|
|
39
|
+
onClick: (e) => handleOnClick(e),
|
|
40
|
+
disabled
|
|
9
41
|
}, label);
|
|
10
42
|
AntDActionElement.displayName = "AntDActionElement";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
43
|
+
const AntDDragHandle = forwardRef(({ className, title }, dragRef) => /* @__PURE__ */ React.createElement("span", {
|
|
44
|
+
ref: dragRef,
|
|
45
|
+
className,
|
|
46
|
+
title
|
|
47
|
+
}, /* @__PURE__ */ React.createElement(HolderOutlined, null)));
|
|
48
|
+
AntDDragHandle.displayName = "AntDDragHandle";
|
|
49
|
+
const AntDNotToggle = ({
|
|
50
|
+
className,
|
|
51
|
+
handleOnChange,
|
|
52
|
+
label,
|
|
53
|
+
checked,
|
|
54
|
+
title,
|
|
55
|
+
disabled
|
|
56
|
+
}) => /* @__PURE__ */ React.createElement(Switch, {
|
|
19
57
|
title,
|
|
20
58
|
className,
|
|
21
|
-
onChange: (
|
|
59
|
+
onChange: (v) => handleOnChange(v),
|
|
22
60
|
checked: !!checked,
|
|
61
|
+
disabled,
|
|
23
62
|
checkedChildren: label,
|
|
24
63
|
unCheckedChildren: "="
|
|
25
64
|
});
|
|
26
65
|
AntDNotToggle.displayName = "AntDNotToggle";
|
|
27
|
-
const {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
66
|
+
const { OptGroup, Option } = Select;
|
|
67
|
+
const isOptionGroupArray = (arr) => Array.isArray(arr) && arr.length > 0 && "options" in arr[0];
|
|
68
|
+
const toOptions = (arr) => isOptionGroupArray(arr) ? arr.map((og) => /* @__PURE__ */ React.createElement(OptGroup, {
|
|
69
|
+
key: og.label,
|
|
70
|
+
label: og.label
|
|
71
|
+
}, og.options.map((opt) => /* @__PURE__ */ React.createElement(Option, {
|
|
72
|
+
key: opt.name,
|
|
73
|
+
value: opt.name
|
|
74
|
+
}, opt.label)))) : Array.isArray(arr) ? arr.map((opt) => /* @__PURE__ */ React.createElement(Option, {
|
|
75
|
+
key: opt.name,
|
|
76
|
+
value: opt.name
|
|
77
|
+
}, opt.label)) : null;
|
|
78
|
+
const AntDValueSelector = ({
|
|
79
|
+
className,
|
|
32
80
|
handleOnChange,
|
|
81
|
+
options,
|
|
82
|
+
value,
|
|
33
83
|
title,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
84
|
+
disabled
|
|
85
|
+
}) => /* @__PURE__ */ React.createElement("span", {
|
|
86
|
+
title,
|
|
87
|
+
className
|
|
88
|
+
}, /* @__PURE__ */ React.createElement(Select, {
|
|
89
|
+
disabled,
|
|
90
|
+
value,
|
|
91
|
+
onChange: (v) => handleOnChange(v)
|
|
92
|
+
}, toOptions(options)));
|
|
93
|
+
AntDValueSelector.displayName = "AntDValueSelector";
|
|
94
|
+
const AntDValueEditor = (_a) => {
|
|
95
|
+
var _b = _a, {
|
|
96
|
+
fieldData,
|
|
97
|
+
operator,
|
|
98
|
+
value,
|
|
99
|
+
handleOnChange,
|
|
100
|
+
title,
|
|
101
|
+
className,
|
|
102
|
+
type,
|
|
103
|
+
inputType,
|
|
104
|
+
values,
|
|
105
|
+
disabled
|
|
106
|
+
} = _b, props = __objRest(_b, [
|
|
107
|
+
"fieldData",
|
|
108
|
+
"operator",
|
|
109
|
+
"value",
|
|
110
|
+
"handleOnChange",
|
|
111
|
+
"title",
|
|
112
|
+
"className",
|
|
113
|
+
"type",
|
|
114
|
+
"inputType",
|
|
115
|
+
"values",
|
|
116
|
+
"disabled"
|
|
117
|
+
]);
|
|
118
|
+
var _a2;
|
|
40
119
|
useEffect(() => {
|
|
41
120
|
if (inputType === "number" && !["between", "notBetween", "in", "notIn"].includes(operator) && typeof value === "string" && value.includes(",")) {
|
|
42
121
|
handleOnChange("");
|
|
@@ -45,25 +124,28 @@ const AntDValueEditor = ({
|
|
|
45
124
|
if (operator === "null" || operator === "notNull") {
|
|
46
125
|
return null;
|
|
47
126
|
}
|
|
48
|
-
const placeHolderText = (
|
|
127
|
+
const placeHolderText = (_a2 = fieldData == null ? void 0 : fieldData.placeholder) != null ? _a2 : "";
|
|
49
128
|
const inputTypeCoerced = ["between", "notBetween", "in", "notIn"].includes(operator) ? "text" : inputType || "text";
|
|
50
129
|
switch (type) {
|
|
51
130
|
case "select":
|
|
52
|
-
return /* @__PURE__ */ React.createElement(
|
|
131
|
+
return /* @__PURE__ */ React.createElement(AntDValueSelector, __spreadProps(__spreadValues({}, props), {
|
|
53
132
|
className,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
133
|
+
handleOnChange,
|
|
134
|
+
options: values,
|
|
135
|
+
value,
|
|
136
|
+
title,
|
|
137
|
+
disabled
|
|
138
|
+
}));
|
|
60
139
|
case "checkbox":
|
|
61
|
-
return /* @__PURE__ */ React.createElement(
|
|
140
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
141
|
+
title
|
|
142
|
+
}, /* @__PURE__ */ React.createElement(Checkbox, {
|
|
62
143
|
type: "checkbox",
|
|
63
144
|
className,
|
|
145
|
+
disabled,
|
|
64
146
|
onChange: (e) => handleOnChange(e.target.checked),
|
|
65
147
|
checked: !!value
|
|
66
|
-
});
|
|
148
|
+
}));
|
|
67
149
|
case "radio":
|
|
68
150
|
return /* @__PURE__ */ React.createElement("span", {
|
|
69
151
|
className,
|
|
@@ -72,6 +154,7 @@ const AntDValueEditor = ({
|
|
|
72
154
|
key: v.name,
|
|
73
155
|
value: v.name,
|
|
74
156
|
checked: value === v.name,
|
|
157
|
+
disabled,
|
|
75
158
|
onChange: (e) => handleOnChange(e.target.value)
|
|
76
159
|
}, v.label)));
|
|
77
160
|
default:
|
|
@@ -80,24 +163,11 @@ const AntDValueEditor = ({
|
|
|
80
163
|
value,
|
|
81
164
|
title,
|
|
82
165
|
className,
|
|
166
|
+
disabled,
|
|
83
167
|
placeholder: placeHolderText,
|
|
84
168
|
onChange: (e) => handleOnChange(e.target.value)
|
|
85
169
|
});
|
|
86
170
|
}
|
|
87
171
|
};
|
|
88
172
|
AntDValueEditor.displayName = "AntDValueEditor";
|
|
89
|
-
const { Option } = Select;
|
|
90
|
-
const AntDValueSelector = ({ className, handleOnChange, options, value }) => /* @__PURE__ */ React.createElement(Select, {
|
|
91
|
-
className,
|
|
92
|
-
value,
|
|
93
|
-
onChange: (v) => handleOnChange(v)
|
|
94
|
-
}, options.map((option) => {
|
|
95
|
-
var _a;
|
|
96
|
-
const key = `key-${(_a = option.id) != null ? _a : option.name}`;
|
|
97
|
-
return /* @__PURE__ */ React.createElement(Option, {
|
|
98
|
-
key,
|
|
99
|
-
value: option.name
|
|
100
|
-
}, option.label);
|
|
101
|
-
}));
|
|
102
|
-
AntDValueSelector.displayName = "AntDValueSelector";
|
|
103
173
|
export { AntDActionElement, AntDDragHandle, AntDNotToggle, AntDValueEditor, AntDValueSelector };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ActionProps } from 'react-querybuilder';
|
|
3
3
|
declare const AntDActionElement: {
|
|
4
|
-
({ className, handleOnClick, label, title }: ActionProps): JSX.Element;
|
|
4
|
+
({ className, handleOnClick, label, title, disabled }: ActionProps): JSX.Element;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
7
7
|
export default AntDActionElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { DragHandleProps } from 'react-querybuilder';
|
|
3
|
-
declare const
|
|
4
|
-
export default
|
|
3
|
+
declare const AntDDragHandle: import("react").ForwardRefExoticComponent<DragHandleProps & import("react").RefAttributes<HTMLSpanElement>>;
|
|
4
|
+
export default AntDDragHandle;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { NotToggleProps } from 'react-querybuilder';
|
|
3
3
|
declare const AntDNotToggle: {
|
|
4
|
-
({ className, handleOnChange, label, checked, title }: NotToggleProps): JSX.Element;
|
|
4
|
+
({ className, handleOnChange, label, checked, title, disabled, }: NotToggleProps): JSX.Element;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
7
7
|
export default AntDNotToggle;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ValueEditorProps } from 'react-querybuilder';
|
|
3
3
|
declare const AntDValueEditor: {
|
|
4
|
-
({ fieldData, operator, value, handleOnChange, title, className, type, inputType, values }: ValueEditorProps): JSX.Element | null;
|
|
4
|
+
({ fieldData, operator, value, handleOnChange, title, className, type, inputType, values, disabled, ...props }: ValueEditorProps): JSX.Element | null;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
7
7
|
export default AntDValueEditor;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ValueSelectorProps } from 'react-querybuilder';
|
|
3
3
|
declare const AntDValueSelector: {
|
|
4
|
-
({ className, handleOnChange, options, value }: ValueSelectorProps): JSX.Element;
|
|
4
|
+
({ className, handleOnChange, options, value, title, disabled, }: ValueSelectorProps): JSX.Element;
|
|
5
5
|
displayName: string;
|
|
6
6
|
};
|
|
7
7
|
export default AntDValueSelector;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { Field, NameLabelPair, OptionGroup } from 'react-querybuilder';
|
|
3
|
+
export declare const isOptionGroupArray: (arr: Field['values']) => arr is OptionGroup<NameLabelPair>[];
|
|
4
|
+
export declare const toOptions: (arr?: NameLabelPair[] | OptionGroup<NameLabelPair>[] | undefined) => JSX.Element[] | null;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-querybuilder/antd",
|
|
3
3
|
"description": "Custom Ant Design components for react-querybuilder",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.1.1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -22,17 +22,18 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@ant-design/icons": "^4.7.0",
|
|
25
|
+
"@react-querybuilder/compat": "^4.1.1",
|
|
25
26
|
"@types/react": "^17.0.0",
|
|
26
27
|
"antd": "^4.10.3",
|
|
27
28
|
"react": "^17.0.1",
|
|
28
|
-
"react-querybuilder": "^4.
|
|
29
|
+
"react-querybuilder": "^4.1.1",
|
|
29
30
|
"typescript": "^4.5.0"
|
|
30
31
|
},
|
|
31
32
|
"peerDependencies": {
|
|
32
33
|
"@ant-design/icons": ">=4.7.0",
|
|
33
34
|
"antd": ">=4.10.0",
|
|
34
35
|
"react": ">=16.8.0",
|
|
35
|
-
"react-querybuilder": "4
|
|
36
|
+
"react-querybuilder": ">=4"
|
|
36
37
|
},
|
|
37
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "f482fa65b4808a573ece7d2eeeb5831f69df58f2"
|
|
38
39
|
}
|