@react-querybuilder/core 8.22.1 → 8.22.2

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.
@@ -5671,6 +5671,14 @@ interface QueryManagerOptions<F extends FullField = FullField, O extends FullOpe
5671
5671
  autoSelectOperator?: boolean;
5672
5672
  /** When `false`, an empty placeholder option is prepended to each value list. */
5673
5673
  autoSelectValue?: boolean;
5674
+ /**
5675
+ * Translations, accepting the same shape as the `translations` prop. Only the placeholder
5676
+ * properties of `fields`, `operators`, and `values` are used, and only when the corresponding
5677
+ * `autoSelect*` option is `false`; the remaining keys describe UI elements that have no
5678
+ * meaning outside the `QueryBuilder` component. Labels are typed as `unknown` so the React
5679
+ * `Translations` type, whose labels are `ReactNode`, can be passed as-is.
5680
+ */
5681
+ translations?: Partial<BaseTranslations<unknown>>;
5674
5682
  /** The default `field` for rules created by {@link QueryManager.createRule}. */
5675
5683
  getDefaultField?: string | ((fieldsData: FullOptionList<F>) => string);
5676
5684
  /** The default `operator` for a given field. */
@@ -5671,6 +5671,14 @@ interface QueryManagerOptions<F extends FullField = FullField, O extends FullOpe
5671
5671
  autoSelectOperator?: boolean;
5672
5672
  /** When `false`, an empty placeholder option is prepended to each value list. */
5673
5673
  autoSelectValue?: boolean;
5674
+ /**
5675
+ * Translations, accepting the same shape as the `translations` prop. Only the placeholder
5676
+ * properties of `fields`, `operators`, and `values` are used, and only when the corresponding
5677
+ * `autoSelect*` option is `false`; the remaining keys describe UI elements that have no
5678
+ * meaning outside the `QueryBuilder` component. Labels are typed as `unknown` so the React
5679
+ * `Translations` type, whose labels are `ReactNode`, can be passed as-is.
5680
+ */
5681
+ translations?: Partial<BaseTranslations<unknown>>;
5674
5682
  /** The default `field` for rules created by {@link QueryManager.createRule}. */
5675
5683
  getDefaultField?: string | ((fieldsData: FullOptionList<F>) => string);
5676
5684
  /** The default `operator` for a given field. */
@@ -6928,7 +6928,7 @@ _Symbol$iterator = Symbol.iterator;
6928
6928
  */
6929
6929
  var QueryManager = class QueryManager {
6930
6930
  constructor(query, options = {}) {
6931
- var _options$idGenerator, _options$validator, _options$strict, _options$respectDisab, _options$history, _historyOptions$maxHi, _historyOptions$coale, _options$now, _options$operators, _options$combinators;
6931
+ var _options$idGenerator, _options$validator, _options$strict, _options$respectDisab, _options$history, _historyOptions$maxHi, _historyOptions$coale, _options$now, _options$translations, _options$operators, _options$translations2, _options$combinators;
6932
6932
  _classPrivateMethodInitSpec(this, _QueryManager_brand);
6933
6933
  _classPrivateFieldInitSpec(this, _query, void 0);
6934
6934
  _classPrivateFieldInitSpec(this, _options, void 0);
@@ -7008,7 +7008,8 @@ var QueryManager = class QueryManager {
7008
7008
  const { optionList: fields, optionsMap: fieldMap } = prepareOptionList({
7009
7009
  optionList: options.fields,
7010
7010
  baseOption: options.baseField,
7011
- autoSelectOption: options.autoSelectField
7011
+ autoSelectOption: options.autoSelectField,
7012
+ placeholder: (_options$translations = options.translations) === null || _options$translations === void 0 ? void 0 : _options$translations.fields
7012
7013
  });
7013
7014
  _classPrivateFieldSet2(_fields, this, freeze(fields, true));
7014
7015
  _classPrivateFieldSet2(_fieldMap, this, freeze(fieldMap, true));
@@ -7016,7 +7017,8 @@ var QueryManager = class QueryManager {
7016
7017
  optionList: (_options$operators = options.operators) !== null && _options$operators !== void 0 ? _options$operators : defaultOperators,
7017
7018
  baseOption: options.baseOperator,
7018
7019
  labelMap: defaultOperatorLabelMap,
7019
- autoSelectOption: options.autoSelectOperator
7020
+ autoSelectOption: options.autoSelectOperator,
7021
+ placeholder: (_options$translations2 = options.translations) === null || _options$translations2 === void 0 ? void 0 : _options$translations2.operators
7020
7022
  }).optionList);
7021
7023
  _classPrivateFieldSet2(_combinators, this, freeze(prepareOptionList({
7022
7024
  optionList: (_options$combinators = options.combinators) !== null && _options$combinators !== void 0 ? _options$combinators : defaultCombinators,
@@ -7245,9 +7247,9 @@ var QueryManager = class QueryManager {
7245
7247
  * one that depends on anything other than the query) may run fewer times than expected.
7246
7248
  */
7247
7249
  validate() {
7248
- var _classPrivateFieldGet4;
7250
+ var _classPrivateFieldGet6;
7249
7251
  _assertClassBrand(_QueryManager_brand, this, _ensureCache).call(this);
7250
- (_classPrivateFieldGet4 = _classPrivateFieldGet2(_validation, this)) !== null && _classPrivateFieldGet4 !== void 0 || _classPrivateFieldSet2(_validation, this, _classPrivateFieldGet2(_validator, this).call(this, _classPrivateFieldGet2(_query, this)));
7252
+ (_classPrivateFieldGet6 = _classPrivateFieldGet2(_validation, this)) !== null && _classPrivateFieldGet6 !== void 0 || _classPrivateFieldSet2(_validation, this, _classPrivateFieldGet2(_validator, this).call(this, _classPrivateFieldGet2(_query, this)));
7251
7253
  return _classPrivateFieldGet2(_validation, this);
7252
7254
  }
7253
7255
  format(options) {
@@ -7437,8 +7439,8 @@ var QueryManager = class QueryManager {
7437
7439
  fields: _classPrivateFieldGet2(_fields, this),
7438
7440
  fieldMap: _classPrivateFieldGet2(_fieldMap, this),
7439
7441
  getInputType: (f, o, misc) => {
7440
- var _this$options$getInpu, _classPrivateFieldGet5, _classPrivateFieldGet6;
7441
- return (_this$options$getInpu = (_classPrivateFieldGet5 = (_classPrivateFieldGet6 = _classPrivateFieldGet2(_options, this)).getInputType) === null || _classPrivateFieldGet5 === void 0 ? void 0 : _classPrivateFieldGet5.call(_classPrivateFieldGet6, f, o, misc)) !== null && _this$options$getInpu !== void 0 ? _this$options$getInpu : null;
7442
+ var _this$options$getInpu, _classPrivateFieldGet7, _classPrivateFieldGet8;
7443
+ return (_this$options$getInpu = (_classPrivateFieldGet7 = (_classPrivateFieldGet8 = _classPrivateFieldGet2(_options, this)).getInputType) === null || _classPrivateFieldGet7 === void 0 ? void 0 : _classPrivateFieldGet7.call(_classPrivateFieldGet8, f, o, misc)) !== null && _this$options$getInpu !== void 0 ? _this$options$getInpu : null;
7442
7444
  },
7443
7445
  getMatchModes: (f) => _assertClassBrand(_QueryManager_brand, this, _matchModesFor).call(this, f),
7444
7446
  getOperators: (f) => _assertClassBrand(_QueryManager_brand, this, _operatorsFor).call(this, f),
@@ -7447,8 +7449,8 @@ var QueryManager = class QueryManager {
7447
7449
  getValues: (f, o) => _assertClassBrand(_QueryManager_brand, this, _valuesFor).call(this, f, o),
7448
7450
  getValueSources: (f, o) => this.getValueSources(f, o),
7449
7451
  getSubQueryBuilderProps: (f, misc) => {
7450
- var _this$options$getSubQ, _classPrivateFieldGet7, _classPrivateFieldGet8;
7451
- return (_this$options$getSubQ = (_classPrivateFieldGet7 = (_classPrivateFieldGet8 = _classPrivateFieldGet2(_options, this)).getSubQueryBuilderProps) === null || _classPrivateFieldGet7 === void 0 ? void 0 : _classPrivateFieldGet7.call(_classPrivateFieldGet8, f, misc)) !== null && _this$options$getSubQ !== void 0 ? _this$options$getSubQ : {};
7452
+ var _this$options$getSubQ, _classPrivateFieldGet9, _classPrivateFieldGet10;
7453
+ return (_this$options$getSubQ = (_classPrivateFieldGet9 = (_classPrivateFieldGet10 = _classPrivateFieldGet2(_options, this)).getSubQueryBuilderProps) === null || _classPrivateFieldGet9 === void 0 ? void 0 : _classPrivateFieldGet9.call(_classPrivateFieldGet10, f, misc)) !== null && _this$options$getSubQ !== void 0 ? _this$options$getSubQ : {};
7452
7454
  }
7453
7455
  }, {
7454
7456
  validationMap: typeof validation === "boolean" ? {} : validation,
@@ -7526,13 +7528,15 @@ function _fieldData(field) {
7526
7528
  }
7527
7529
  /** Resolves the operator list for a field, mirroring `QueryBuilder`'s precedence. */
7528
7530
  function _operatorsFor(field) {
7531
+ var _classPrivateFieldGet2$1;
7529
7532
  return resolveOperatorList({
7530
7533
  field,
7531
7534
  fieldData: _assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, field),
7532
7535
  getOperators: _classPrivateFieldGet2(_options, this).getOperators,
7533
7536
  operators: _classPrivateFieldGet2(_operators, this),
7534
7537
  baseOption: _classPrivateFieldGet2(_options, this).baseOperator,
7535
- autoSelectOption: _classPrivateFieldGet2(_options, this).autoSelectOperator
7538
+ autoSelectOption: _classPrivateFieldGet2(_options, this).autoSelectOperator,
7539
+ placeholder: (_classPrivateFieldGet2$1 = _classPrivateFieldGet2(_options, this).translations) === null || _classPrivateFieldGet2$1 === void 0 ? void 0 : _classPrivateFieldGet2$1.operators
7536
7540
  });
7537
7541
  }
7538
7542
  /** Resolves the default operator for a field, mirroring `QueryBuilder`'s precedence. */
@@ -7551,12 +7555,14 @@ function _matchModesFor(field) {
7551
7555
  return getMatchModesUtil(_assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, field), _classPrivateFieldGet2(_options, this).getMatchModes);
7552
7556
  }
7553
7557
  function _valuesFor(field, operator) {
7558
+ var _classPrivateFieldGet3;
7554
7559
  return resolveValueList({
7555
7560
  field,
7556
7561
  operator,
7557
7562
  fieldData: _assertClassBrand(_QueryManager_brand, this, _fieldData).call(this, field),
7558
7563
  getValues: _classPrivateFieldGet2(_options, this).getValues,
7559
- autoSelectOption: _classPrivateFieldGet2(_options, this).autoSelectValue
7564
+ autoSelectOption: _classPrivateFieldGet2(_options, this).autoSelectValue,
7565
+ placeholder: (_classPrivateFieldGet3 = _classPrivateFieldGet2(_options, this).translations) === null || _classPrivateFieldGet3 === void 0 ? void 0 : _classPrivateFieldGet3.values
7560
7566
  });
7561
7567
  }
7562
7568
  function _valueEditorTypeFor(field, operator) {
@@ -7586,9 +7592,9 @@ function _defaultValue(rule) {
7586
7592
  * {@link QueryManager.getRuleContext} so both see the same shape.
7587
7593
  */
7588
7594
  function _parametersFor(field, operator, misc) {
7589
- var _this$options$getPara, _classPrivateFieldGet2$1, _classPrivateFieldGet3;
7595
+ var _this$options$getPara, _classPrivateFieldGet4, _classPrivateFieldGet5;
7590
7596
  return prepareOptionList({
7591
- optionList: (_this$options$getPara = (_classPrivateFieldGet2$1 = (_classPrivateFieldGet3 = _classPrivateFieldGet2(_options, this)).getParameters) === null || _classPrivateFieldGet2$1 === void 0 ? void 0 : _classPrivateFieldGet2$1.call(_classPrivateFieldGet3, field, operator, misc)) !== null && _this$options$getPara !== void 0 ? _this$options$getPara : [],
7597
+ optionList: (_this$options$getPara = (_classPrivateFieldGet4 = (_classPrivateFieldGet5 = _classPrivateFieldGet2(_options, this)).getParameters) === null || _classPrivateFieldGet4 === void 0 ? void 0 : _classPrivateFieldGet4.call(_classPrivateFieldGet5, field, operator, misc)) !== null && _this$options$getPara !== void 0 ? _this$options$getPara : [],
7592
7598
  autoSelectOption: _classPrivateFieldGet2(_options, this).autoSelectValue
7593
7599
  }).optionList;
7594
7600
  }