@civicactions/cmsds-open-data-components 4.0.16-alpha.0 → 4.0.16-alpha.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.
package/dist/main.js CHANGED
@@ -3622,6 +3622,16 @@ const $eadd6431fddf4b6c$var$FilterItem = ({ id: id, condition: condition, index:
3622
3622
  }, [
3623
3623
  operator
3624
3624
  ]);
3625
+ // Clear value when switching to an empty operator
3626
+ const isEmptyOperator = operator === 'is_empty' || operator === 'not_empty';
3627
+ (0, $hgUW1$useEffect)(()=>{
3628
+ if (isEmptyOperator && value !== '') {
3629
+ setValue('');
3630
+ update(index, 'value', '');
3631
+ }
3632
+ }, [
3633
+ isEmptyOperator
3634
+ ]);
3625
3635
  (0, $hgUW1$useEffect)(()=>{
3626
3636
  if (value !== condition.value) {
3627
3637
  if (value) update(index, 'value', value);
@@ -3649,7 +3659,7 @@ const $eadd6431fddf4b6c$var$FilterItem = ({ id: id, condition: condition, index:
3649
3659
  name: `${condition.key}_operator`,
3650
3660
  onChange: (e)=>setOperator(e.target.value)
3651
3661
  }),
3652
- schema[id].fields[property].mysql_type === 'date' ? /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3662
+ isEmptyOperator ? /*#__PURE__*/ (0, $hgUW1$jsx)("div", {}) : schema[id].fields[property].mysql_type === 'date' ? /*#__PURE__*/ (0, $hgUW1$jsxs)("div", {
3653
3663
  children: [
3654
3664
  /*#__PURE__*/ (0, $hgUW1$jsx)("label", {
3655
3665
  className: "ds-c-label",
@@ -3723,16 +3733,6 @@ var $2eec38d4d0dbf714$export$2e2bcd8739ae039 = $2eec38d4d0dbf714$var$ClearFilter
3723
3733
  function $6f4318b1e14124e5$var$updateQueryForDatastore(condition) {
3724
3734
  let cond = condition;
3725
3735
  delete cond.key;
3726
- if (cond.operator === 'is_empty') {
3727
- cond.operator = '=';
3728
- cond.value = '';
3729
- return cond;
3730
- }
3731
- if (cond.operator === 'not_empty') {
3732
- cond.operator = '<>';
3733
- cond.value = '';
3734
- return cond;
3735
- }
3736
3736
  if (cond.operator === '=' || cond.operator === '<>') {
3737
3737
  if (Array.isArray(cond.value)) cond.value = cond.value.join();
3738
3738
  cond.value = cond.value.replace(/(^\%+|\%+$)/gm, '');
@@ -5317,11 +5317,24 @@ const $1d3d480a9cfaabe0$var$useDatastore = (resourceId, rootAPIUrl, options, add
5317
5317
  const datasetID = additionalParams.datasetID;
5318
5318
  // Remove datasetID from params to avoid sending it to the API
5319
5319
  const { datasetID: _, ...restAdditionalParams } = additionalParams;
5320
+ const apiConditions = conditions?.map((c)=>{
5321
+ if (c.operator === 'is_empty') return {
5322
+ ...c,
5323
+ operator: '=',
5324
+ value: ''
5325
+ };
5326
+ if (c.operator === 'not_empty') return {
5327
+ ...c,
5328
+ operator: '<>',
5329
+ value: ''
5330
+ };
5331
+ return c;
5332
+ });
5320
5333
  let params = {
5321
5334
  keys: keys,
5322
5335
  limit: limit,
5323
5336
  offset: offset,
5324
- conditions: conditions,
5337
+ conditions: apiConditions,
5325
5338
  sorts: sort,
5326
5339
  properties: properties,
5327
5340
  groupings: groupings,