@react-querybuilder/antd 7.0.0-alpha.0 → 7.0.0-alpha.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.
@@ -1,18 +1,9 @@
1
- import * as react_querybuilder from 'react-querybuilder';
2
- import { ActionWithRulesProps, DragHandleProps, NotToggleProps, ShiftActionsProps, ValueEditorProps, VersatileSelectorProps, Controls } from 'react-querybuilder';
3
- import { Button, Switch, Select } from 'antd';
4
- import * as React from 'react';
5
- import { ComponentPropsWithoutRef, ComponentPropsWithRef } from 'react';
6
1
  import { HolderOutlined } from '@ant-design/icons';
7
-
8
- type RemoveDataIndexKeys<T> = {
9
- [K in keyof T as `data-${string}` extends K ? never : K]: T[K];
10
- };
11
- type AntDActionProps = ActionWithRulesProps & RemoveDataIndexKeys<ComponentPropsWithoutRef<typeof Button>>;
12
- declare const AntDActionElement: {
13
- ({ className, handleOnClick, label, title, disabled, disabledTranslation, testID: _testID, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, ruleOrGroup: _ruleOrGroup, schema: _schema, ...extraProps }: AntDActionProps): React.JSX.Element;
14
- displayName: string;
15
- };
2
+ import * as React from 'react';
3
+ import { ComponentPropsWithRef, ComponentPropsWithoutRef } from 'react';
4
+ import * as react_querybuilder from 'react-querybuilder';
5
+ import { DragHandleProps, NotToggleProps, VersatileSelectorProps, ActionWithRulesProps, ShiftActionsProps, ValueEditorProps } from 'react-querybuilder';
6
+ import { Switch, Select, Button } from 'antd';
16
7
 
17
8
  type AntDDragHandleProps = DragHandleProps & {
18
9
  label?: any;
@@ -25,8 +16,23 @@ declare const AntDNotToggle: {
25
16
  displayName: string;
26
17
  };
27
18
 
19
+ type AntDValueSelectorProps = VersatileSelectorProps & Omit<ComponentPropsWithoutRef<typeof Select>, 'onChange' | 'defaultValue'>;
20
+ declare const AntDValueSelector: {
21
+ ({ className, handleOnChange, options, value, title, disabled, multiple, listsAsArrays, testID: _testID, rule: _rule, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, operator: _operator, field: _field, fieldData: _fieldData, schema: _schema, ...extraProps }: AntDValueSelectorProps): React.JSX.Element;
22
+ displayName: string;
23
+ };
24
+
25
+ type RemoveDataIndexKeys<T> = {
26
+ [K in keyof T as `data-${string}` extends K ? never : K]: T[K];
27
+ };
28
+ type AntDActionProps = ActionWithRulesProps & RemoveDataIndexKeys<ComponentPropsWithoutRef<typeof Button>>;
29
+ declare const AntDActionElement: {
30
+ ({ className, handleOnClick, label, title, disabled, disabledTranslation, testID: _testID, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, ruleOrGroup: _ruleOrGroup, schema: _schema, ...extraProps }: AntDActionProps): React.JSX.Element;
31
+ displayName: string;
32
+ };
33
+
28
34
  declare const AntDShiftActions: {
29
- ({ path, disabled, className, titles, testID, lastInGroup, schema: { combinators, dispatchQuery, getQuery }, }: ShiftActionsProps): React.JSX.Element;
35
+ ({ path, disabled, className, labels, titles, testID, lastInGroup, schema: { combinators, dispatchQuery, getQuery }, }: ShiftActionsProps): React.JSX.Element;
30
36
  displayName: string;
31
37
  };
32
38
 
@@ -35,13 +41,101 @@ declare const AntDValueEditor: {
35
41
  displayName: string;
36
42
  };
37
43
 
38
- type AntDValueSelectorProps = VersatileSelectorProps & Omit<ComponentPropsWithoutRef<typeof Select>, 'onChange' | 'defaultValue'>;
39
- declare const AntDValueSelector: {
40
- ({ className, handleOnChange, options, value, title, disabled, multiple, listsAsArrays, testID: _testID, rule: _rule, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, operator: _operator, field: _field, fieldData: _fieldData, schema: _schema, ...extraProps }: AntDValueSelectorProps): React.JSX.Element;
41
- displayName: string;
44
+ declare const antdControlElements: {
45
+ addGroupAction: {
46
+ ({ className, handleOnClick, label, title, disabled, disabledTranslation, testID: _testID, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, ruleOrGroup: _ruleOrGroup, schema: _schema, ...extraProps }: AntDActionProps): React.JSX.Element;
47
+ displayName: string;
48
+ };
49
+ addRuleAction: {
50
+ ({ className, handleOnClick, label, title, disabled, disabledTranslation, testID: _testID, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, ruleOrGroup: _ruleOrGroup, schema: _schema, ...extraProps }: AntDActionProps): React.JSX.Element;
51
+ displayName: string;
52
+ };
53
+ cloneGroupAction: {
54
+ ({ className, handleOnClick, label, title, disabled, disabledTranslation, testID: _testID, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, ruleOrGroup: _ruleOrGroup, schema: _schema, ...extraProps }: AntDActionProps): React.JSX.Element;
55
+ displayName: string;
56
+ };
57
+ cloneRuleAction: {
58
+ ({ className, handleOnClick, label, title, disabled, disabledTranslation, testID: _testID, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, ruleOrGroup: _ruleOrGroup, schema: _schema, ...extraProps }: AntDActionProps): React.JSX.Element;
59
+ displayName: string;
60
+ };
61
+ lockGroupAction: {
62
+ ({ className, handleOnClick, label, title, disabled, disabledTranslation, testID: _testID, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, ruleOrGroup: _ruleOrGroup, schema: _schema, ...extraProps }: AntDActionProps): React.JSX.Element;
63
+ displayName: string;
64
+ };
65
+ lockRuleAction: {
66
+ ({ className, handleOnClick, label, title, disabled, disabledTranslation, testID: _testID, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, ruleOrGroup: _ruleOrGroup, schema: _schema, ...extraProps }: AntDActionProps): React.JSX.Element;
67
+ displayName: string;
68
+ };
69
+ combinatorSelector: {
70
+ ({ className, handleOnChange, options, value, title, disabled, multiple, listsAsArrays, testID: _testID, rule: _rule, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, operator: _operator, field: _field, fieldData: _fieldData, schema: _schema, ...extraProps }: AntDValueSelectorProps): React.JSX.Element;
71
+ displayName: string;
72
+ };
73
+ fieldSelector: {
74
+ ({ className, handleOnChange, options, value, title, disabled, multiple, listsAsArrays, testID: _testID, rule: _rule, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, operator: _operator, field: _field, fieldData: _fieldData, schema: _schema, ...extraProps }: AntDValueSelectorProps): React.JSX.Element;
75
+ displayName: string;
76
+ };
77
+ notToggle: {
78
+ ({ className, handleOnChange, label, checked, title, disabled, path: _path, context: _context, validation: _validation, testID: _testID, schema: _schema, ruleGroup: _ruleGroup, ...extraProps }: AntDNotToggleProps): React.JSX.Element;
79
+ displayName: string;
80
+ };
81
+ operatorSelector: {
82
+ ({ className, handleOnChange, options, value, title, disabled, multiple, listsAsArrays, testID: _testID, rule: _rule, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, operator: _operator, field: _field, fieldData: _fieldData, schema: _schema, ...extraProps }: AntDValueSelectorProps): React.JSX.Element;
83
+ displayName: string;
84
+ };
85
+ removeGroupAction: {
86
+ ({ className, handleOnClick, label, title, disabled, disabledTranslation, testID: _testID, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, ruleOrGroup: _ruleOrGroup, schema: _schema, ...extraProps }: AntDActionProps): React.JSX.Element;
87
+ displayName: string;
88
+ };
89
+ removeRuleAction: {
90
+ ({ className, handleOnClick, label, title, disabled, disabledTranslation, testID: _testID, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, ruleOrGroup: _ruleOrGroup, schema: _schema, ...extraProps }: AntDActionProps): React.JSX.Element;
91
+ displayName: string;
92
+ };
93
+ valueEditor: {
94
+ ({ fieldData, operator, value, handleOnChange, title, className, type, inputType, values, listsAsArrays, parseNumbers, separator, valueSource: _vs, disabled, testID, selectorComponent: SelectorComponent, ...props }: react_querybuilder.ValueEditorProps<react_querybuilder.Field<string, string, string, react_querybuilder.Option<string>, react_querybuilder.Option<string>>, string>): React.JSX.Element | null;
95
+ displayName: string;
96
+ };
97
+ dragHandle: React.ForwardRefExoticComponent<Omit<AntDDragHandleProps, "ref"> & React.RefAttributes<HTMLSpanElement>>;
98
+ valueSourceSelector: {
99
+ ({ className, handleOnChange, options, value, title, disabled, multiple, listsAsArrays, testID: _testID, rule: _rule, rules: _rules, level: _level, path: _path, context: _context, validation: _validation, operator: _operator, field: _field, fieldData: _fieldData, schema: _schema, ...extraProps }: AntDValueSelectorProps): React.JSX.Element;
100
+ displayName: string;
101
+ };
102
+ shiftActions: {
103
+ ({ path, disabled, className, labels, titles, testID, lastInGroup, schema: { combinators, dispatchQuery, getQuery }, }: react_querybuilder.ShiftActionsProps): React.JSX.Element;
104
+ displayName: string;
105
+ };
106
+ };
107
+ declare const antdTranslations: {
108
+ removeGroup: {
109
+ label: React.JSX.Element;
110
+ };
111
+ removeRule: {
112
+ label: React.JSX.Element;
113
+ };
114
+ cloneRule: {
115
+ label: React.JSX.Element;
116
+ };
117
+ cloneRuleGroup: {
118
+ label: React.JSX.Element;
119
+ };
120
+ lockGroup: {
121
+ label: React.JSX.Element;
122
+ };
123
+ lockRule: {
124
+ label: React.JSX.Element;
125
+ };
126
+ lockGroupDisabled: {
127
+ label: React.JSX.Element;
128
+ };
129
+ lockRuleDisabled: {
130
+ label: React.JSX.Element;
131
+ };
132
+ shiftActionUp: {
133
+ label: React.JSX.Element;
134
+ };
135
+ shiftActionDown: {
136
+ label: React.JSX.Element;
137
+ };
42
138
  };
43
-
44
- declare const antdControlElements: Partial<Controls>;
45
139
  declare const QueryBuilderAntD: react_querybuilder.QueryBuilderContextProvider<Record<string, any>>;
46
140
 
47
- export { AntDActionElement, AntDActionProps, AntDDragHandle, AntDDragHandleProps, AntDNotToggle, AntDNotToggleProps, AntDShiftActions, AntDValueEditor, AntDValueSelector, AntDValueSelectorProps, QueryBuilderAntD, antdControlElements };
141
+ export { AntDActionElement, AntDActionProps, AntDDragHandle, AntDDragHandleProps, AntDNotToggle, AntDNotToggleProps, AntDShiftActions, AntDValueEditor, AntDValueSelector, AntDValueSelectorProps, QueryBuilderAntD, antdControlElements, antdTranslations };
@@ -965,12 +965,11 @@ var require_dayjs = __commonJS({
965
965
  }
966
966
  }
967
967
  };
968
- var _default = generateConfig;
969
- exports.default = _default;
968
+ var _default = exports.default = generateConfig;
970
969
  }
971
970
  });
972
971
 
973
- // src/index.ts
972
+ // src/index.tsx
974
973
  var src_exports = {};
975
974
  __export(src_exports, {
976
975
  AntDActionElement: () => AntDActionElement,
@@ -980,9 +979,12 @@ __export(src_exports, {
980
979
  AntDValueEditor: () => AntDValueEditor,
981
980
  AntDValueSelector: () => AntDValueSelector,
982
981
  QueryBuilderAntD: () => QueryBuilderAntD,
983
- antdControlElements: () => antdControlElements
982
+ antdControlElements: () => antdControlElements,
983
+ antdTranslations: () => antdTranslations
984
984
  });
985
985
  module.exports = __toCommonJS(src_exports);
986
+ var import_icons2 = require("@ant-design/icons");
987
+ var React8 = __toESM(require("react"));
986
988
  var import_react_querybuilder5 = require("react-querybuilder");
987
989
 
988
990
  // src/AntDActionElement.tsx
@@ -1076,7 +1078,6 @@ var AntDNotToggle = ({
1076
1078
  AntDNotToggle.displayName = "AntDNotToggle";
1077
1079
 
1078
1080
  // src/AntDShiftActions.tsx
1079
- var import_icons2 = require("@ant-design/icons");
1080
1081
  var import_antd3 = require("antd");
1081
1082
  var React4 = __toESM(require("react"));
1082
1083
  var import_react_querybuilder = require("react-querybuilder");
@@ -1084,7 +1085,7 @@ var AntDShiftActions = ({
1084
1085
  path,
1085
1086
  disabled,
1086
1087
  className,
1087
- // labels, // Labels are hard-coded in this component
1088
+ labels,
1088
1089
  titles,
1089
1090
  testID,
1090
1091
  lastInGroup,
@@ -1107,7 +1108,7 @@ var AntDShiftActions = ({
1107
1108
  onClick: shiftUp,
1108
1109
  disabled: shiftUpDisabled
1109
1110
  },
1110
- /* @__PURE__ */ React4.createElement(import_icons2.CaretUpOutlined, null)
1111
+ labels?.shiftUp
1111
1112
  ), /* @__PURE__ */ React4.createElement(
1112
1113
  import_antd3.Button,
1113
1114
  {
@@ -1117,13 +1118,14 @@ var AntDShiftActions = ({
1117
1118
  onClick: shiftDown,
1118
1119
  disabled: shiftDownDisabled
1119
1120
  },
1120
- /* @__PURE__ */ React4.createElement(import_icons2.CaretDownOutlined, null)
1121
+ labels?.shiftDown
1121
1122
  ));
1122
1123
  };
1123
1124
  AntDShiftActions.displayName = "AntDShiftActions";
1124
1125
 
1125
1126
  // src/AntDValueEditor.tsx
1126
1127
  var import_antd6 = require("antd");
1128
+ var import_generatePicker = __toESM(require("antd/es/date-picker/generatePicker/index.js"));
1127
1129
  var import_dayjs = __toESM(require_dayjs_min());
1128
1130
  var import_dayjs2 = __toESM(require_dayjs());
1129
1131
  var React7 = __toESM(require("react"));
@@ -1186,7 +1188,7 @@ var AntDValueSelector = ({
1186
1188
  AntDValueSelector.displayName = "AntDValueSelector";
1187
1189
 
1188
1190
  // src/AntDValueEditor.tsx
1189
- var DatePicker = import_antd6.DatePicker.generatePicker(import_dayjs2.default);
1191
+ var DatePicker = (0, import_generatePicker.default)(import_dayjs2.default);
1190
1192
  var AntDValueEditor = ({
1191
1193
  fieldData,
1192
1194
  operator,
@@ -1227,7 +1229,7 @@ var AntDValueEditor = ({
1227
1229
  if (type === "text") {
1228
1230
  if (inputTypeCoerced === "time") {
1229
1231
  return /* @__PURE__ */ React7.createElement(
1230
- import_antd6.TimePicker,
1232
+ DatePicker.TimePicker,
1231
1233
  {
1232
1234
  key,
1233
1235
  value: valueAsArray[i] ? (0, import_dayjs.default)(valueAsArray[i], "HH:mm:ss") : null,
@@ -1332,28 +1334,36 @@ var AntDValueEditor = ({
1332
1334
  }
1333
1335
  switch (inputTypeCoerced) {
1334
1336
  case "date":
1335
- case "datetime-local":
1336
- return operator === "between" || operator === "notBetween" ? /* @__PURE__ */ React7.createElement(
1337
- DatePicker.RangePicker,
1338
- {
1339
- value: (0, import_react_querybuilder4.toArray)(value)?.length >= 2 ? (0, import_react_querybuilder4.toArray)(value).map((v) => (0, import_dayjs.default)(v)) : void 0,
1340
- showTime: inputTypeCoerced === "datetime-local",
1341
- className,
1342
- disabled,
1343
- placeholder: [placeHolderText, placeHolderText],
1344
- onChange: (
1345
- /* istanbul ignore next */
1346
- (dates) => {
1347
- const format = `YYYY-MM-DD${inputTypeCoerced === "datetime-local" ? "THH:mm:ss" : ""}`;
1348
- const dateArray = dates?.map((d) => d?.format(format));
1349
- handleOnChange(dateArray ? listsAsArrays ? dateArray : dateArray.join(",") : dates);
1350
- }
1351
- )
1352
- }
1353
- ) : /* @__PURE__ */ React7.createElement(
1337
+ case "datetime-local": {
1338
+ if (operator === "between" || operator === "notBetween") {
1339
+ const dayjsArray = valueAsArray.slice(0, 2).map(import_dayjs.default);
1340
+ return /* @__PURE__ */ React7.createElement(
1341
+ DatePicker.RangePicker,
1342
+ {
1343
+ value: dayjsArray.every((d) => d.isValid()) ? dayjsArray : void 0,
1344
+ showTime: inputTypeCoerced === "datetime-local",
1345
+ className,
1346
+ disabled,
1347
+ placeholder: [placeHolderText, placeHolderText],
1348
+ onChange: (
1349
+ /* istanbul ignore next */
1350
+ (dates) => {
1351
+ const timeFormat = inputTypeCoerced === "datetime-local" ? "THH:mm:ss" : "";
1352
+ const format = `YYYY-MM-DD${timeFormat}`;
1353
+ const dateArray = dates?.map((d) => d?.isValid() ? d.format(format) : void 0);
1354
+ handleOnChange(
1355
+ dateArray ? listsAsArrays ? dateArray : (0, import_react_querybuilder4.joinWith)(dateArray, ",") : dates
1356
+ );
1357
+ }
1358
+ )
1359
+ }
1360
+ );
1361
+ }
1362
+ const dateValue = (0, import_dayjs.default)(value);
1363
+ return /* @__PURE__ */ React7.createElement(
1354
1364
  DatePicker,
1355
1365
  {
1356
- value: value ? (0, import_dayjs.default)(value) : null,
1366
+ value: dateValue.isValid() ? dateValue : void 0,
1357
1367
  showTime: inputTypeCoerced === "datetime-local",
1358
1368
  className,
1359
1369
  disabled,
@@ -1361,17 +1371,20 @@ var AntDValueEditor = ({
1361
1371
  onChange: (_d, dateString) => handleOnChange(dateString)
1362
1372
  }
1363
1373
  );
1364
- case "time":
1374
+ }
1375
+ case "time": {
1376
+ const dateValue = (0, import_dayjs.default)(value, "HH:mm:ss");
1365
1377
  return /* @__PURE__ */ React7.createElement(
1366
- import_antd6.TimePicker,
1378
+ DatePicker.TimePicker,
1367
1379
  {
1368
- value: value ? (0, import_dayjs.default)(value, "HH:mm:ss") : null,
1380
+ value: dateValue.isValid() ? dateValue : void 0,
1369
1381
  className,
1370
1382
  disabled,
1371
1383
  placeholder: placeHolderText,
1372
1384
  onChange: (d) => handleOnChange(d?.format("HH:mm:ss") ?? "")
1373
1385
  }
1374
1386
  );
1387
+ }
1375
1388
  }
1376
1389
  return /* @__PURE__ */ React7.createElement(
1377
1390
  import_antd6.Input,
@@ -1388,7 +1401,7 @@ var AntDValueEditor = ({
1388
1401
  };
1389
1402
  AntDValueEditor.displayName = "AntDValueEditor";
1390
1403
 
1391
- // src/index.ts
1404
+ // src/index.tsx
1392
1405
  var antdControlElements = {
1393
1406
  addGroupAction: AntDActionElement,
1394
1407
  addRuleAction: AntDActionElement,
@@ -1407,9 +1420,22 @@ var antdControlElements = {
1407
1420
  valueSourceSelector: AntDValueSelector,
1408
1421
  shiftActions: AntDShiftActions
1409
1422
  };
1423
+ var antdTranslations = {
1424
+ removeGroup: { label: /* @__PURE__ */ React8.createElement(import_icons2.CloseOutlined, null) },
1425
+ removeRule: { label: /* @__PURE__ */ React8.createElement(import_icons2.CloseOutlined, null) },
1426
+ cloneRule: { label: /* @__PURE__ */ React8.createElement(import_icons2.CopyOutlined, null) },
1427
+ cloneRuleGroup: { label: /* @__PURE__ */ React8.createElement(import_icons2.CopyOutlined, null) },
1428
+ lockGroup: { label: /* @__PURE__ */ React8.createElement(import_icons2.UnlockOutlined, null) },
1429
+ lockRule: { label: /* @__PURE__ */ React8.createElement(import_icons2.UnlockOutlined, null) },
1430
+ lockGroupDisabled: { label: /* @__PURE__ */ React8.createElement(import_icons2.LockOutlined, null) },
1431
+ lockRuleDisabled: { label: /* @__PURE__ */ React8.createElement(import_icons2.LockOutlined, null) },
1432
+ shiftActionUp: { label: /* @__PURE__ */ React8.createElement(import_icons2.UpOutlined, null) },
1433
+ shiftActionDown: { label: /* @__PURE__ */ React8.createElement(import_icons2.DownOutlined, null) }
1434
+ };
1410
1435
  var QueryBuilderAntD = (0, import_react_querybuilder5.getCompatContextProvider)({
1411
1436
  key: "antd",
1412
- controlElements: antdControlElements
1437
+ controlElements: antdControlElements,
1438
+ translations: antdTranslations
1413
1439
  });
1414
1440
  // Annotate the CommonJS export names for ESM import in node:
1415
1441
  0 && (module.exports = {
@@ -1420,6 +1446,7 @@ var QueryBuilderAntD = (0, import_react_querybuilder5.getCompatContextProvider)(
1420
1446
  AntDValueEditor,
1421
1447
  AntDValueSelector,
1422
1448
  QueryBuilderAntD,
1423
- antdControlElements
1449
+ antdControlElements,
1450
+ antdTranslations
1424
1451
  });
1425
1452
  //# sourceMappingURL=react-querybuilder_antd.cjs.development.js.map