@revolist/revogrid 3.0.99 → 3.1.0

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.
Files changed (40) hide show
  1. package/custom-element/index.js +475 -300
  2. package/dist/cjs/debounce-e9b040d9.js +575 -0
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/revo-grid.cjs.js +1 -1
  5. package/dist/cjs/revo-grid_11.cjs.entry.js +159 -634
  6. package/dist/cjs/revogr-filter-panel.cjs.entry.js +158 -43
  7. package/dist/collection/components/revo-grid/revo-grid.js +1 -1
  8. package/dist/collection/plugins/filter/conditions/equal.js +5 -1
  9. package/dist/collection/plugins/filter/filter.button.js +10 -0
  10. package/dist/collection/plugins/filter/filter.plugin.js +93 -47
  11. package/dist/collection/plugins/filter/filter.pop.js +196 -47
  12. package/dist/collection/plugins/filter/filter.style.css +51 -4
  13. package/dist/esm/debounce-8dadcda7.js +558 -0
  14. package/dist/esm/loader.js +1 -1
  15. package/dist/esm/revo-grid.js +1 -1
  16. package/dist/esm/revo-grid_11.entry.js +113 -588
  17. package/dist/esm/revogr-filter-panel.entry.js +157 -42
  18. package/dist/esm-es5/debounce-8dadcda7.js +1 -0
  19. package/dist/esm-es5/loader.js +1 -1
  20. package/dist/esm-es5/revo-grid.js +1 -1
  21. package/dist/esm-es5/revo-grid_11.entry.js +1 -1
  22. package/dist/esm-es5/revogr-filter-panel.entry.js +1 -1
  23. package/dist/revo-grid/debounce-d097578d.js +1 -0
  24. package/dist/revo-grid/debounce-f40a88f6.system.js +1 -0
  25. package/dist/revo-grid/revo-grid.esm.js +1 -1
  26. package/dist/revo-grid/revo-grid.system.js +1 -1
  27. package/dist/revo-grid/revo-grid_11.entry.js +1 -1
  28. package/dist/revo-grid/revo-grid_11.system.entry.js +1 -1
  29. package/dist/revo-grid/revogr-filter-panel.entry.js +1 -1
  30. package/dist/revo-grid/revogr-filter-panel.system.entry.js +1 -1
  31. package/dist/types/components.d.ts +4 -2
  32. package/dist/types/plugins/filter/filter.button.d.ts +4 -0
  33. package/dist/types/plugins/filter/filter.plugin.d.ts +5 -8
  34. package/dist/types/plugins/filter/filter.pop.d.ts +26 -7
  35. package/package.json +1 -1
  36. package/dist/cjs/filter.button-2396a488.js +0 -27
  37. package/dist/esm/filter.button-53ebca66.js +0 -23
  38. package/dist/esm-es5/filter.button-53ebca66.js +0 -1
  39. package/dist/revo-grid/filter.button-1509c206.js +0 -1
  40. package/dist/revo-grid/filter.button-4bd87101.system.js +0 -1
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d3f67f2e.js');
6
- const filter_button = require('./filter.button-2396a488.js');
6
+ const debounce = require('./debounce-e9b040d9.js');
7
7
 
8
8
  const RevoButton = (props, children) => {
9
9
  return (index.h("button", Object.assign({}, props, { class: Object.assign(Object.assign({}, (typeof props.class === 'object' ? props.class : props.class ? { [props.class]: true } : '')), { ['revo-button']: true }) }), children));
@@ -28,27 +28,37 @@ const RevoButton = (props, children) => {
28
28
  }
29
29
  })();
30
30
 
31
- const filterStyleCss = ".revo-drag-icon{-webkit-mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 438 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M421.875,70.40625 C426.432292,70.40625 430.175781,68.9414062 433.105469,66.0117188 C436.035156,63.0820312 437.5,59.3385417 437.5,54.78125 L437.5,54.78125 L437.5,15.71875 C437.5,11.1614583 436.035156,7.41796875 433.105469,4.48828125 C430.175781,1.55859375 426.432292,0.09375 421.875,0.09375 L421.875,0.09375 L15.625,0.09375 C11.0677083,0.09375 7.32421875,1.55859375 4.39453125,4.48828125 C1.46484375,7.41796875 0,11.1614583 0,15.71875 L0,15.71875 L0,54.78125 C0,59.3385417 1.46484375,63.0820312 4.39453125,66.0117188 C7.32421875,68.9414062 11.0677083,70.40625 15.625,70.40625 L15.625,70.40625 L421.875,70.40625 Z M421.875,226.65625 C426.432292,226.65625 430.175781,225.191406 433.105469,222.261719 C436.035156,219.332031 437.5,215.588542 437.5,211.03125 L437.5,211.03125 L437.5,171.96875 C437.5,167.411458 436.035156,163.667969 433.105469,160.738281 C430.175781,157.808594 426.432292,156.34375 421.875,156.34375 L421.875,156.34375 L15.625,156.34375 C11.0677083,156.34375 7.32421875,157.808594 4.39453125,160.738281 C1.46484375,163.667969 0,167.411458 0,171.96875 L0,171.96875 L0,211.03125 C0,215.588542 1.46484375,219.332031 4.39453125,222.261719 C7.32421875,225.191406 11.0677083,226.65625 15.625,226.65625 L15.625,226.65625 L421.875,226.65625 Z M421.875,382.90625 C426.432292,382.90625 430.175781,381.441406 433.105469,378.511719 C436.035156,375.582031 437.5,371.838542 437.5,367.28125 L437.5,367.28125 L437.5,328.21875 C437.5,323.661458 436.035156,319.917969 433.105469,316.988281 C430.175781,314.058594 426.432292,312.59375 421.875,312.59375 L421.875,312.59375 L15.625,312.59375 C11.0677083,312.59375 7.32421875,314.058594 4.39453125,316.988281 C1.46484375,319.917969 0,323.661458 0,328.21875 L0,328.21875 L0,367.28125 C0,371.838542 1.46484375,375.582031 4.39453125,378.511719 C7.32421875,381.441406 11.0677083,382.90625 15.625,382.90625 L15.625,382.90625 L421.875,382.90625 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 438 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M421.875,70.40625 C426.432292,70.40625 430.175781,68.9414062 433.105469,66.0117188 C436.035156,63.0820312 437.5,59.3385417 437.5,54.78125 L437.5,54.78125 L437.5,15.71875 C437.5,11.1614583 436.035156,7.41796875 433.105469,4.48828125 C430.175781,1.55859375 426.432292,0.09375 421.875,0.09375 L421.875,0.09375 L15.625,0.09375 C11.0677083,0.09375 7.32421875,1.55859375 4.39453125,4.48828125 C1.46484375,7.41796875 0,11.1614583 0,15.71875 L0,15.71875 L0,54.78125 C0,59.3385417 1.46484375,63.0820312 4.39453125,66.0117188 C7.32421875,68.9414062 11.0677083,70.40625 15.625,70.40625 L15.625,70.40625 L421.875,70.40625 Z M421.875,226.65625 C426.432292,226.65625 430.175781,225.191406 433.105469,222.261719 C436.035156,219.332031 437.5,215.588542 437.5,211.03125 L437.5,211.03125 L437.5,171.96875 C437.5,167.411458 436.035156,163.667969 433.105469,160.738281 C430.175781,157.808594 426.432292,156.34375 421.875,156.34375 L421.875,156.34375 L15.625,156.34375 C11.0677083,156.34375 7.32421875,157.808594 4.39453125,160.738281 C1.46484375,163.667969 0,167.411458 0,171.96875 L0,171.96875 L0,211.03125 C0,215.588542 1.46484375,219.332031 4.39453125,222.261719 C7.32421875,225.191406 11.0677083,226.65625 15.625,226.65625 L15.625,226.65625 L421.875,226.65625 Z M421.875,382.90625 C426.432292,382.90625 430.175781,381.441406 433.105469,378.511719 C436.035156,375.582031 437.5,371.838542 437.5,367.28125 L437.5,367.28125 L437.5,328.21875 C437.5,323.661458 436.035156,319.917969 433.105469,316.988281 C430.175781,314.058594 426.432292,312.59375 421.875,312.59375 L421.875,312.59375 L15.625,312.59375 C11.0677083,312.59375 7.32421875,314.058594 4.39453125,316.988281 C1.46484375,319.917969 0,323.661458 0,328.21875 L0,328.21875 L0,367.28125 C0,371.838542 1.46484375,375.582031 4.39453125,378.511719 C7.32421875,381.441406 11.0677083,382.90625 15.625,382.90625 L15.625,382.90625 L421.875,382.90625 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");width:11px;height:7px;background-size:cover;background-repeat:no-repeat}.revo-alt-icon{-webkit-mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 384 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M192.4375,383 C197.424479,383 201.663411,381.254557 205.154297,377.763672 L205.154297,377.763672 L264.25,318.667969 C270.234375,312.683594 271.605794,306.075846 268.364258,298.844727 C265.122721,291.613607 259.51237,287.998047 251.533203,287.998047 L251.533203,287.998047 L213.382812,287.998047 L213.382812,212.445312 L288.935547,212.445312 L288.935547,250.595703 C288.935547,258.57487 292.551107,264.185221 299.782227,267.426758 C307.013346,270.668294 313.621094,269.296875 319.605469,263.3125 L319.605469,263.3125 L378.701172,204.216797 C382.192057,200.725911 383.9375,196.486979 383.9375,191.5 C383.9375,186.513021 382.192057,182.274089 378.701172,178.783203 L378.701172,178.783203 L319.605469,119.6875 C313.621094,114.201823 307.013346,112.955078 299.782227,115.947266 C292.551107,118.939453 288.935547,124.42513 288.935547,132.404297 L288.935547,132.404297 L288.935547,170.554688 L213.382812,170.554688 L213.382812,95.0019531 L251.533203,95.0019531 C259.51237,95.0019531 264.998047,91.3863932 267.990234,84.1552734 C270.982422,76.9241536 269.735677,70.3164062 264.25,64.3320312 L264.25,64.3320312 L205.154297,5.23632812 C201.663411,1.74544271 197.424479,0 192.4375,0 C187.450521,0 183.211589,1.74544271 179.720703,5.23632812 L179.720703,5.23632812 L120.625,64.3320312 C114.640625,70.3164062 113.269206,76.9241536 116.510742,84.1552734 C119.752279,91.3863932 125.36263,95.0019531 133.341797,95.0019531 L133.341797,95.0019531 L171.492188,95.0019531 L171.492188,170.554688 L95.9394531,170.554688 L95.9394531,132.404297 C95.9394531,124.42513 92.3238932,118.814779 85.0927734,115.573242 C77.8616536,112.331706 71.2539062,113.703125 65.2695312,119.6875 L65.2695312,119.6875 L6.17382812,178.783203 C2.68294271,182.274089 0.9375,186.513021 0.9375,191.5 C0.9375,196.486979 2.68294271,200.725911 6.17382812,204.216797 L6.17382812,204.216797 L65.2695312,263.3125 C71.2539062,268.798177 77.8616536,270.044922 85.0927734,267.052734 C92.3238932,264.060547 95.9394531,258.57487 95.9394531,250.595703 L95.9394531,250.595703 L95.9394531,212.445312 L171.492188,212.445312 L171.492188,287.998047 L133.341797,287.998047 C125.36263,287.998047 119.876953,291.613607 116.884766,298.844727 C113.892578,306.075846 115.139323,312.683594 120.625,318.667969 L120.625,318.667969 L179.720703,377.763672 C183.211589,381.254557 187.450521,383 192.4375,383 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 384 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M192.4375,383 C197.424479,383 201.663411,381.254557 205.154297,377.763672 L205.154297,377.763672 L264.25,318.667969 C270.234375,312.683594 271.605794,306.075846 268.364258,298.844727 C265.122721,291.613607 259.51237,287.998047 251.533203,287.998047 L251.533203,287.998047 L213.382812,287.998047 L213.382812,212.445312 L288.935547,212.445312 L288.935547,250.595703 C288.935547,258.57487 292.551107,264.185221 299.782227,267.426758 C307.013346,270.668294 313.621094,269.296875 319.605469,263.3125 L319.605469,263.3125 L378.701172,204.216797 C382.192057,200.725911 383.9375,196.486979 383.9375,191.5 C383.9375,186.513021 382.192057,182.274089 378.701172,178.783203 L378.701172,178.783203 L319.605469,119.6875 C313.621094,114.201823 307.013346,112.955078 299.782227,115.947266 C292.551107,118.939453 288.935547,124.42513 288.935547,132.404297 L288.935547,132.404297 L288.935547,170.554688 L213.382812,170.554688 L213.382812,95.0019531 L251.533203,95.0019531 C259.51237,95.0019531 264.998047,91.3863932 267.990234,84.1552734 C270.982422,76.9241536 269.735677,70.3164062 264.25,64.3320312 L264.25,64.3320312 L205.154297,5.23632812 C201.663411,1.74544271 197.424479,0 192.4375,0 C187.450521,0 183.211589,1.74544271 179.720703,5.23632812 L179.720703,5.23632812 L120.625,64.3320312 C114.640625,70.3164062 113.269206,76.9241536 116.510742,84.1552734 C119.752279,91.3863932 125.36263,95.0019531 133.341797,95.0019531 L133.341797,95.0019531 L171.492188,95.0019531 L171.492188,170.554688 L95.9394531,170.554688 L95.9394531,132.404297 C95.9394531,124.42513 92.3238932,118.814779 85.0927734,115.573242 C77.8616536,112.331706 71.2539062,113.703125 65.2695312,119.6875 L65.2695312,119.6875 L6.17382812,178.783203 C2.68294271,182.274089 0.9375,186.513021 0.9375,191.5 C0.9375,196.486979 2.68294271,200.725911 6.17382812,204.216797 L6.17382812,204.216797 L65.2695312,263.3125 C71.2539062,268.798177 77.8616536,270.044922 85.0927734,267.052734 C92.3238932,264.060547 95.9394531,258.57487 95.9394531,250.595703 L95.9394531,250.595703 L95.9394531,212.445312 L171.492188,212.445312 L171.492188,287.998047 L133.341797,287.998047 C125.36263,287.998047 119.876953,291.613607 116.884766,298.844727 C113.892578,306.075846 115.139323,312.683594 120.625,318.667969 L120.625,318.667969 L179.720703,377.763672 C183.211589,381.254557 187.450521,383 192.4375,383 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");width:11px;height:11px;background-size:cover;background-repeat:no-repeat}.arrow-down{position:absolute;right:5px;top:0}.arrow-down svg{width:8px;margin-top:5px;margin-left:5px;opacity:0.4}.cell-value-wrapper{margin-right:10px;overflow:hidden;text-overflow:ellipsis}.revo-button{position:relative;overflow:hidden;color:#fff;background-color:#6200ee;height:34px;line-height:34px;padding:0 15px;outline:0;border:0;border-radius:7px;box-sizing:border-box;cursor:pointer}.revo-button.green{background-color:#2ee072;border:1px solid #20d565}.revo-button.red{background-color:#E0662E;border:1px solid #d55920}.revo-button:disabled,.revo-button[disabled]{cursor:not-allowed !important;filter:opacity(0.35) !important}.revo-button.light{border:2px solid #cedefa;line-height:32px;background:none;color:#4876ca;box-shadow:none}revogr-filter-panel{position:absolute;display:block;top:0;left:0;z-index:100;opacity:1;transform:none;background-color:#fff;transform-origin:62px 0px;box-shadow:0 5px 18px -2px rgba(0, 0, 0, 0.2);padding:10px;border-radius:4px;min-width:220px;text-align:left}revogr-filter-panel label{color:gray;font-size:13px;font-weight:600;display:block;padding:8px 0}revogr-filter-panel select{width:100%}revogr-filter-panel input[type=text]{border:0;min-height:34px;margin:5px 0;background:#f3f3f3;border-radius:5px;padding:0 10px;box-sizing:border-box;width:100%}revogr-filter-panel button{margin-top:10px;margin-right:5px}.rgHeaderCell:hover .rv-filter{transition:opacity 267ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 178ms cubic-bezier(0.4, 0, 0.2, 1) 0ms}.rgHeaderCell:hover .rv-filter,.rgHeaderCell .rv-filter.active{opacity:1}.rgHeaderCell .rv-filter{height:24px;width:24px;background:none;border:0;opacity:0;visibility:visible;cursor:pointer;border-radius:4px}.rgHeaderCell .rv-filter.active{color:#10224a}.rgHeaderCell .rv-filter .filter-img{color:gray;width:11px}.center{text-align:center}.select-css{display:block;font-family:sans-serif;font-weight:600;color:#444;line-height:1.3;padding:0.6em 1.4em 0.5em 0.8em;width:100%;max-width:100%;box-sizing:border-box;margin:0;border:1px solid #f1f1f1;box-shadow:transparent;border-radius:0.5em;appearance:none;background-color:#fff;background-image:url(\"data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E\"), linear-gradient(to bottom, #ffffff 0%, #ffffff 100%);background-repeat:no-repeat, repeat;background-position:right 0.7em top 50%, 0 0;background-size:0.65em auto, 100%;}.select-css::-ms-expand{display:none}.select-css:hover{border-color:#c5c5c5}.select-css:focus{border-color:#f1f1f1;box-shadow:0 0 1px 3px rgba(59, 153, 252, 0.7);box-shadow:0 0 0 3px -moz-mac-focusring;color:#222;outline:none}.select-css option{font-weight:normal}.select-css:disabled,.select-css[aria-disabled=true]{color:gray;background-image:url(\"data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22graytext%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E\"), linear-gradient(to bottom, #ffffff 0%, #ffffff 100%)}.select-css:disabled:hover,.select-css[aria-disabled=true]{border-color:#f1f1f1}";
31
+ const filterStyleCss = ".revo-drag-icon{-webkit-mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 438 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M421.875,70.40625 C426.432292,70.40625 430.175781,68.9414062 433.105469,66.0117188 C436.035156,63.0820312 437.5,59.3385417 437.5,54.78125 L437.5,54.78125 L437.5,15.71875 C437.5,11.1614583 436.035156,7.41796875 433.105469,4.48828125 C430.175781,1.55859375 426.432292,0.09375 421.875,0.09375 L421.875,0.09375 L15.625,0.09375 C11.0677083,0.09375 7.32421875,1.55859375 4.39453125,4.48828125 C1.46484375,7.41796875 0,11.1614583 0,15.71875 L0,15.71875 L0,54.78125 C0,59.3385417 1.46484375,63.0820312 4.39453125,66.0117188 C7.32421875,68.9414062 11.0677083,70.40625 15.625,70.40625 L15.625,70.40625 L421.875,70.40625 Z M421.875,226.65625 C426.432292,226.65625 430.175781,225.191406 433.105469,222.261719 C436.035156,219.332031 437.5,215.588542 437.5,211.03125 L437.5,211.03125 L437.5,171.96875 C437.5,167.411458 436.035156,163.667969 433.105469,160.738281 C430.175781,157.808594 426.432292,156.34375 421.875,156.34375 L421.875,156.34375 L15.625,156.34375 C11.0677083,156.34375 7.32421875,157.808594 4.39453125,160.738281 C1.46484375,163.667969 0,167.411458 0,171.96875 L0,171.96875 L0,211.03125 C0,215.588542 1.46484375,219.332031 4.39453125,222.261719 C7.32421875,225.191406 11.0677083,226.65625 15.625,226.65625 L15.625,226.65625 L421.875,226.65625 Z M421.875,382.90625 C426.432292,382.90625 430.175781,381.441406 433.105469,378.511719 C436.035156,375.582031 437.5,371.838542 437.5,367.28125 L437.5,367.28125 L437.5,328.21875 C437.5,323.661458 436.035156,319.917969 433.105469,316.988281 C430.175781,314.058594 426.432292,312.59375 421.875,312.59375 L421.875,312.59375 L15.625,312.59375 C11.0677083,312.59375 7.32421875,314.058594 4.39453125,316.988281 C1.46484375,319.917969 0,323.661458 0,328.21875 L0,328.21875 L0,367.28125 C0,371.838542 1.46484375,375.582031 4.39453125,378.511719 C7.32421875,381.441406 11.0677083,382.90625 15.625,382.90625 L15.625,382.90625 L421.875,382.90625 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 438 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M421.875,70.40625 C426.432292,70.40625 430.175781,68.9414062 433.105469,66.0117188 C436.035156,63.0820312 437.5,59.3385417 437.5,54.78125 L437.5,54.78125 L437.5,15.71875 C437.5,11.1614583 436.035156,7.41796875 433.105469,4.48828125 C430.175781,1.55859375 426.432292,0.09375 421.875,0.09375 L421.875,0.09375 L15.625,0.09375 C11.0677083,0.09375 7.32421875,1.55859375 4.39453125,4.48828125 C1.46484375,7.41796875 0,11.1614583 0,15.71875 L0,15.71875 L0,54.78125 C0,59.3385417 1.46484375,63.0820312 4.39453125,66.0117188 C7.32421875,68.9414062 11.0677083,70.40625 15.625,70.40625 L15.625,70.40625 L421.875,70.40625 Z M421.875,226.65625 C426.432292,226.65625 430.175781,225.191406 433.105469,222.261719 C436.035156,219.332031 437.5,215.588542 437.5,211.03125 L437.5,211.03125 L437.5,171.96875 C437.5,167.411458 436.035156,163.667969 433.105469,160.738281 C430.175781,157.808594 426.432292,156.34375 421.875,156.34375 L421.875,156.34375 L15.625,156.34375 C11.0677083,156.34375 7.32421875,157.808594 4.39453125,160.738281 C1.46484375,163.667969 0,167.411458 0,171.96875 L0,171.96875 L0,211.03125 C0,215.588542 1.46484375,219.332031 4.39453125,222.261719 C7.32421875,225.191406 11.0677083,226.65625 15.625,226.65625 L15.625,226.65625 L421.875,226.65625 Z M421.875,382.90625 C426.432292,382.90625 430.175781,381.441406 433.105469,378.511719 C436.035156,375.582031 437.5,371.838542 437.5,367.28125 L437.5,367.28125 L437.5,328.21875 C437.5,323.661458 436.035156,319.917969 433.105469,316.988281 C430.175781,314.058594 426.432292,312.59375 421.875,312.59375 L421.875,312.59375 L15.625,312.59375 C11.0677083,312.59375 7.32421875,314.058594 4.39453125,316.988281 C1.46484375,319.917969 0,323.661458 0,328.21875 L0,328.21875 L0,367.28125 C0,371.838542 1.46484375,375.582031 4.39453125,378.511719 C7.32421875,381.441406 11.0677083,382.90625 15.625,382.90625 L15.625,382.90625 L421.875,382.90625 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");width:11px;height:7px;background-size:cover;background-repeat:no-repeat}.revo-alt-icon{-webkit-mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 384 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M192.4375,383 C197.424479,383 201.663411,381.254557 205.154297,377.763672 L205.154297,377.763672 L264.25,318.667969 C270.234375,312.683594 271.605794,306.075846 268.364258,298.844727 C265.122721,291.613607 259.51237,287.998047 251.533203,287.998047 L251.533203,287.998047 L213.382812,287.998047 L213.382812,212.445312 L288.935547,212.445312 L288.935547,250.595703 C288.935547,258.57487 292.551107,264.185221 299.782227,267.426758 C307.013346,270.668294 313.621094,269.296875 319.605469,263.3125 L319.605469,263.3125 L378.701172,204.216797 C382.192057,200.725911 383.9375,196.486979 383.9375,191.5 C383.9375,186.513021 382.192057,182.274089 378.701172,178.783203 L378.701172,178.783203 L319.605469,119.6875 C313.621094,114.201823 307.013346,112.955078 299.782227,115.947266 C292.551107,118.939453 288.935547,124.42513 288.935547,132.404297 L288.935547,132.404297 L288.935547,170.554688 L213.382812,170.554688 L213.382812,95.0019531 L251.533203,95.0019531 C259.51237,95.0019531 264.998047,91.3863932 267.990234,84.1552734 C270.982422,76.9241536 269.735677,70.3164062 264.25,64.3320312 L264.25,64.3320312 L205.154297,5.23632812 C201.663411,1.74544271 197.424479,0 192.4375,0 C187.450521,0 183.211589,1.74544271 179.720703,5.23632812 L179.720703,5.23632812 L120.625,64.3320312 C114.640625,70.3164062 113.269206,76.9241536 116.510742,84.1552734 C119.752279,91.3863932 125.36263,95.0019531 133.341797,95.0019531 L133.341797,95.0019531 L171.492188,95.0019531 L171.492188,170.554688 L95.9394531,170.554688 L95.9394531,132.404297 C95.9394531,124.42513 92.3238932,118.814779 85.0927734,115.573242 C77.8616536,112.331706 71.2539062,113.703125 65.2695312,119.6875 L65.2695312,119.6875 L6.17382812,178.783203 C2.68294271,182.274089 0.9375,186.513021 0.9375,191.5 C0.9375,196.486979 2.68294271,200.725911 6.17382812,204.216797 L6.17382812,204.216797 L65.2695312,263.3125 C71.2539062,268.798177 77.8616536,270.044922 85.0927734,267.052734 C92.3238932,264.060547 95.9394531,258.57487 95.9394531,250.595703 L95.9394531,250.595703 L95.9394531,212.445312 L171.492188,212.445312 L171.492188,287.998047 L133.341797,287.998047 C125.36263,287.998047 119.876953,291.613607 116.884766,298.844727 C113.892578,306.075846 115.139323,312.683594 120.625,318.667969 L120.625,318.667969 L179.720703,377.763672 C183.211589,381.254557 187.450521,383 192.4375,383 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");mask-image:url(\"data:image/svg+xml,%3C%3Fxml version='1.0' encoding='UTF-8'%3F%3E%3Csvg viewBox='0 0 384 383' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Cg%3E%3Cpath d='M192.4375,383 C197.424479,383 201.663411,381.254557 205.154297,377.763672 L205.154297,377.763672 L264.25,318.667969 C270.234375,312.683594 271.605794,306.075846 268.364258,298.844727 C265.122721,291.613607 259.51237,287.998047 251.533203,287.998047 L251.533203,287.998047 L213.382812,287.998047 L213.382812,212.445312 L288.935547,212.445312 L288.935547,250.595703 C288.935547,258.57487 292.551107,264.185221 299.782227,267.426758 C307.013346,270.668294 313.621094,269.296875 319.605469,263.3125 L319.605469,263.3125 L378.701172,204.216797 C382.192057,200.725911 383.9375,196.486979 383.9375,191.5 C383.9375,186.513021 382.192057,182.274089 378.701172,178.783203 L378.701172,178.783203 L319.605469,119.6875 C313.621094,114.201823 307.013346,112.955078 299.782227,115.947266 C292.551107,118.939453 288.935547,124.42513 288.935547,132.404297 L288.935547,132.404297 L288.935547,170.554688 L213.382812,170.554688 L213.382812,95.0019531 L251.533203,95.0019531 C259.51237,95.0019531 264.998047,91.3863932 267.990234,84.1552734 C270.982422,76.9241536 269.735677,70.3164062 264.25,64.3320312 L264.25,64.3320312 L205.154297,5.23632812 C201.663411,1.74544271 197.424479,0 192.4375,0 C187.450521,0 183.211589,1.74544271 179.720703,5.23632812 L179.720703,5.23632812 L120.625,64.3320312 C114.640625,70.3164062 113.269206,76.9241536 116.510742,84.1552734 C119.752279,91.3863932 125.36263,95.0019531 133.341797,95.0019531 L133.341797,95.0019531 L171.492188,95.0019531 L171.492188,170.554688 L95.9394531,170.554688 L95.9394531,132.404297 C95.9394531,124.42513 92.3238932,118.814779 85.0927734,115.573242 C77.8616536,112.331706 71.2539062,113.703125 65.2695312,119.6875 L65.2695312,119.6875 L6.17382812,178.783203 C2.68294271,182.274089 0.9375,186.513021 0.9375,191.5 C0.9375,196.486979 2.68294271,200.725911 6.17382812,204.216797 L6.17382812,204.216797 L65.2695312,263.3125 C71.2539062,268.798177 77.8616536,270.044922 85.0927734,267.052734 C92.3238932,264.060547 95.9394531,258.57487 95.9394531,250.595703 L95.9394531,250.595703 L95.9394531,212.445312 L171.492188,212.445312 L171.492188,287.998047 L133.341797,287.998047 C125.36263,287.998047 119.876953,291.613607 116.884766,298.844727 C113.892578,306.075846 115.139323,312.683594 120.625,318.667969 L120.625,318.667969 L179.720703,377.763672 C183.211589,381.254557 187.450521,383 192.4375,383 Z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E\");width:11px;height:11px;background-size:cover;background-repeat:no-repeat}.arrow-down{position:absolute;right:5px;top:0}.arrow-down svg{width:8px;margin-top:5px;margin-left:5px;opacity:0.4}.cell-value-wrapper{margin-right:10px;overflow:hidden;text-overflow:ellipsis}.revo-button{position:relative;overflow:hidden;color:#fff;background-color:#6200ee;height:34px;line-height:34px;padding:0 15px;outline:0;border:0;border-radius:7px;box-sizing:border-box;cursor:pointer}.revo-button.green{background-color:#2ee072;border:1px solid #20d565}.revo-button.red{background-color:#E0662E;border:1px solid #d55920}.revo-button:disabled,.revo-button[disabled]{cursor:not-allowed !important;filter:opacity(0.35) !important}.revo-button.light{border:2px solid #cedefa;line-height:32px;background:none;color:#4876ca;box-shadow:none}revogr-filter-panel{position:absolute;display:block;top:0;left:0;z-index:100;opacity:1;transform:none;background-color:#fff;transform-origin:62px 0px;box-shadow:0 5px 18px -2px rgba(0, 0, 0, 0.2);padding:10px;border-radius:4px;min-width:220px;text-align:left}revogr-filter-panel .filter-holder>div{display:flex;flex-direction:column}revogr-filter-panel label{color:gray;font-size:13px;font-weight:600;display:block;padding:8px 0}revogr-filter-panel select{width:100%}revogr-filter-panel input[type=text]{border:0;min-height:34px;margin:5px 0;background:#f3f3f3;border-radius:5px;padding:0 10px;box-sizing:border-box;width:100%}revogr-filter-panel button{margin-top:10px;margin-right:5px}revogr-filter-panel .filter-actions{text-align:right;margin-right:-5px}.rgHeaderCell:hover .rv-filter{transition:opacity 267ms cubic-bezier(0.4, 0, 0.2, 1) 0ms, transform 178ms cubic-bezier(0.4, 0, 0.2, 1) 0ms}.rgHeaderCell:hover .rv-filter,.rgHeaderCell .rv-filter.active{opacity:1}.rgHeaderCell .rv-filter{height:24px;width:24px;background:none;border:0;opacity:0;visibility:visible;cursor:pointer;border-radius:4px}.rgHeaderCell .rv-filter.active{color:#10224a}.rgHeaderCell .rv-filter .filter-img{color:gray;width:11px}.select-css{display:block;font-family:sans-serif;font-weight:600;color:#444;line-height:1.3;padding:0.6em 1.4em 0.5em 0.8em;width:100%;max-width:100%;box-sizing:border-box;margin:0;border:1px solid #f1f1f1;box-shadow:transparent;border-radius:0.5em;appearance:none;background-color:#fff;background-image:url(\"data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E\"), linear-gradient(to bottom, #ffffff 0%, #ffffff 100%);background-repeat:no-repeat, repeat;background-position:right 0.7em top 50%, 0 0;background-size:0.65em auto, 100%;}.select-css::-ms-expand{display:none}.select-css:hover{border-color:#c5c5c5}.select-css:focus{border-color:#f1f1f1;box-shadow:0 0 1px 3px rgba(59, 153, 252, 0.7);box-shadow:0 0 0 3px -moz-mac-focusring;color:#222;outline:none}.select-css option{font-weight:normal}.select-css:disabled,.select-css[aria-disabled=true]{color:gray;background-image:url(\"data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22graytext%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E\"), linear-gradient(to bottom, #ffffff 0%, #ffffff 100%)}.select-css:disabled:hover,.select-css[aria-disabled=true]{border-color:#f1f1f1}.multi-filter-list{margin-top:5px;margin-bottom:5px}.multi-filter-list div{white-space:nowrap}.multi-filter-list .multi-filter-list-action{display:flex;justify-content:space-between;align-items:center}.multi-filter-list .and-or-button{margin:0 0 0 10px;min-width:58px;cursor:pointer}.multi-filter-list .trash-button{margin:0 0 -2px 6px;cursor:pointer;width:22px;height:22px;color:gray;font-size:18px}.multi-filter-list .trash-button .trash-img{width:1em}.add-filter-divider{display:block;margin:0 -10px 10px -10px;border-bottom:1px solid #d9d9d9;height:10px;box-shadow:0 4px 5px rgba(0, 0, 0, 0.05)}.select-input{display:flex;justify-content:space-between;align-items:center}";
32
32
 
33
33
  const defaultType = 'none';
34
+ const FILTER_LIST_CLASS = 'multi-filter-list';
35
+ const FILTER_LIST_CLASS_ACTION = 'multi-filter-list-action';
34
36
  const FilterPanel = class {
35
37
  constructor(hostRef) {
36
38
  index.registerInstance(this, hostRef);
37
39
  this.filterChange = index.createEvent(this, "filterChange", 7);
38
40
  this.filterCaptionsInternal = {
39
- title: "Filter by condition",
40
- save: "Save",
41
- reset: "Reset",
42
- cancel: "Cancel",
41
+ title: 'Filter by condition',
42
+ save: 'Save',
43
+ reset: 'Reset',
44
+ cancel: 'Close',
43
45
  };
46
+ this.isFilterIdSet = false;
47
+ this.filterId = 0;
48
+ this.currentFilterId = -1;
49
+ this.currentFilterType = defaultType;
50
+ this.filterItems = {};
44
51
  this.filterTypes = {};
45
52
  this.filterNames = {};
46
53
  this.filterEntities = {};
54
+ this.debouncedApplyFilter = debounce.debounce_1(() => {
55
+ this.filterChange.emit(this.filterItems);
56
+ }, 400);
47
57
  }
48
58
  onMouseDown(e) {
49
59
  if (this.changes && !e.defaultPrevented) {
50
60
  const el = e.target;
51
- if (this.isOutside(el) && !filter_button.isFilterBtn(el)) {
61
+ if (this.isOutside(el) && !debounce.isFilterBtn(el)) {
52
62
  this.changes = undefined;
53
63
  }
54
64
  }
@@ -62,26 +72,54 @@ const FilterPanel = class {
62
72
  async getChanges() {
63
73
  return this.changes;
64
74
  }
65
- renderConditions(type) {
75
+ componentWillRender() {
76
+ if (!this.isFilterIdSet) {
77
+ this.isFilterIdSet = true;
78
+ const filterItems = Object.keys(this.filterItems);
79
+ for (const prop of filterItems) {
80
+ // we set the proper filterId so there won't be any conflict when removing filters
81
+ this.filterId += this.filterItems[prop].length;
82
+ }
83
+ }
84
+ }
85
+ renderSelectOptions(type, isDefaultTypeRemoved = false) {
86
+ var _a;
66
87
  const options = [];
88
+ const prop = (_a = this.changes) === null || _a === void 0 ? void 0 : _a.prop;
89
+ if (!isDefaultTypeRemoved) {
90
+ options.push(index.h("option", { selected: this.currentFilterType === defaultType, value: defaultType }, prop && this.filterItems[prop] && this.filterItems[prop].length > 0 ? 'Add more condition...' : this.filterNames[defaultType]));
91
+ }
67
92
  for (let gIndex in this.filterTypes) {
68
- options.push(index.h("option", { value: defaultType }, this.filterNames[defaultType]));
69
93
  options.push(...this.filterTypes[gIndex].map(k => (index.h("option", { value: k, selected: type === k }, this.filterNames[k]))));
70
94
  options.push(index.h("option", { disabled: true }));
71
95
  }
72
96
  return options;
73
97
  }
74
- renderExtra(extra, value) {
75
- this.extraElement = undefined;
76
- switch (extra) {
77
- case 'input':
78
- return (index.h("input", { type: "text", value: value, onInput: (e) => this.onInput(e), onKeyDown: e => this.onKeyDown(e), ref: e => (this.extraElement = e) }));
79
- default:
80
- return '';
81
- }
98
+ renderExtra(prop, index$1) {
99
+ const currentFilter = this.filterItems[prop];
100
+ if (!currentFilter)
101
+ return '';
102
+ if (this.filterEntities[currentFilter[index$1].type].extra !== 'input')
103
+ return '';
104
+ return (index.h("input", { id: `filter-input-${currentFilter[index$1].id}`, placeholder: "Enter value...", type: "text", value: currentFilter[index$1].value, onInput: this.onUserInput.bind(this, index$1, prop), onKeyDown: e => this.onKeyDown(e) }));
105
+ }
106
+ getFilterItemsList() {
107
+ var _a;
108
+ const prop = (_a = this.changes) === null || _a === void 0 ? void 0 : _a.prop;
109
+ if (!(prop || prop === 0))
110
+ return '';
111
+ const propFilters = this.filterItems[prop] || [];
112
+ return (index.h("div", { key: this.filterId }, propFilters.map((d, index$1) => {
113
+ let andOrButton;
114
+ // hide toggle button if there is only one filter and the last one
115
+ if (index$1 !== this.filterItems[prop].length - 1) {
116
+ andOrButton = (index.h("div", { onClick: () => this.toggleFilterAndOr(d.id) }, index.h(debounce.AndOrButton, { isAnd: d.relation === 'and' })));
117
+ }
118
+ return (index.h("div", { key: d.id, class: FILTER_LIST_CLASS }, index.h("div", { class: { 'select-input': true } }, index.h("select", { class: "select-css select-filter", onChange: e => this.onFilterTypeChange(e, prop, index$1) }, this.renderSelectOptions(this.filterItems[prop][index$1].type, true)), index.h("div", { class: FILTER_LIST_CLASS_ACTION }, andOrButton), index.h("div", { onClick: () => this.onRemoveFilter(d.id) }, index.h(debounce.TrashButton, null))), index.h("div", null, this.renderExtra(prop, index$1))));
119
+ }), propFilters.length > 0 ? index.h("div", { class: "add-filter-divider" }) : ''));
82
120
  }
83
121
  render() {
84
- if (!this.changes || !this.changes) {
122
+ if (!this.changes) {
85
123
  return index.h(index.Host, { style: { display: 'none' } });
86
124
  }
87
125
  const style = {
@@ -90,24 +128,75 @@ const FilterPanel = class {
90
128
  top: `${this.changes.y}px`,
91
129
  };
92
130
  const capts = Object.assign(this.filterCaptionsInternal, this.filterCaptions);
93
- return (index.h(index.Host, { style: style }, index.h("label", null, capts.title), index.h("select", { class: "select-css", onChange: e => this.onFilterChange(e) }, this.renderConditions(this.changes.type)), index.h("div", null, this.renderExtra(this.filterEntities[this.changes.type].extra, this.changes.value)), index.h("div", { class: "center" }, index.h(RevoButton, { class: { green: true }, onClick: () => this.onSave() }, capts.save), index.h(RevoButton, { class: { red: true }, onClick: () => this.onReset() }, capts.reset), index.h(RevoButton, { class: { light: true }, onClick: () => this.onCancel() }, capts.cancel))));
131
+ return (index.h(index.Host, { style: style }, index.h("label", null, capts.title), index.h("div", { class: "filter-holder" }, this.getFilterItemsList()), index.h("div", { class: "add-filter" }, index.h("select", { id: "add-filter", class: "select-css", onChange: e => this.onAddNewFilter(e) }, this.renderSelectOptions(this.currentFilterType))), index.h("div", { class: "filter-actions" }, index.h(RevoButton, { class: { red: true }, onClick: () => this.onReset() }, capts.reset), index.h(RevoButton, { class: { light: true }, onClick: () => this.onCancel() }, capts.cancel))));
94
132
  }
95
- onFilterChange(e) {
96
- if (!this.changes) {
97
- throw new Error('Changes required per edit');
98
- }
133
+ onFilterTypeChange(e, prop, index) {
134
+ const el = e.target;
135
+ const type = el.value;
136
+ this.filterItems[prop][index].type = type;
137
+ // this re-renders the input to know if we need extra input
138
+ this.filterId++;
139
+ // adding setTimeout will wait for the next tick DOM update then focus on input
140
+ setTimeout(() => {
141
+ const input = document.getElementById('filter-input-' + this.filterItems[prop][index].id);
142
+ if (input)
143
+ input.focus();
144
+ }, 0);
145
+ this.debouncedApplyFilter();
146
+ }
147
+ onAddNewFilter(e) {
99
148
  const el = e.target;
100
149
  const type = el.value;
101
- this.changes = Object.assign(Object.assign({}, this.changes), { type });
150
+ this.currentFilterType = type;
151
+ this.addNewFilterToProp();
152
+ // reset value after adding new filter
153
+ const select = document.getElementById('add-filter');
154
+ if (select) {
155
+ select.value = defaultType;
156
+ this.currentFilterType = defaultType;
157
+ }
158
+ this.debouncedApplyFilter();
102
159
  }
103
- onInput(e) {
104
- this.changes.value = e.target.value;
105
- // prevent grid focus and other unexpected events
106
- e.preventDefault();
160
+ addNewFilterToProp() {
161
+ var _a;
162
+ const prop = (_a = this.changes) === null || _a === void 0 ? void 0 : _a.prop;
163
+ if (!(prop || prop === 0))
164
+ return;
165
+ if (!this.filterItems[prop]) {
166
+ this.filterItems[prop] = [];
167
+ }
168
+ if (this.currentFilterType === 'none')
169
+ return;
170
+ this.filterId++;
171
+ this.currentFilterId = this.filterId;
172
+ this.filterItems[prop].push({
173
+ id: this.currentFilterId,
174
+ type: this.currentFilterType,
175
+ value: '',
176
+ relation: 'and',
177
+ });
178
+ // adding setTimeout will wait for the next tick DOM update then focus on input
179
+ setTimeout(() => {
180
+ const input = document.getElementById('filter-input-' + this.currentFilterId);
181
+ if (input)
182
+ input.focus();
183
+ }, 0);
184
+ }
185
+ onUserInput(index, prop, event) {
186
+ // update the value of the filter item
187
+ this.filterItems[prop][index].value = event.target.value;
188
+ this.debouncedApplyFilter();
107
189
  }
108
190
  onKeyDown(e) {
109
191
  if (e.key.toLowerCase() === 'enter') {
110
- this.onSave();
192
+ const select = document.getElementById('add-filter');
193
+ if (select) {
194
+ select.value = defaultType;
195
+ this.currentFilterType = defaultType;
196
+ this.addNewFilterToProp();
197
+ select.focus();
198
+ }
199
+ return;
111
200
  }
112
201
  // keep event local, don't escalate farther to dom
113
202
  e.stopPropagation();
@@ -115,23 +204,43 @@ const FilterPanel = class {
115
204
  onCancel() {
116
205
  this.changes = undefined;
117
206
  }
118
- onSave() {
119
- var _a, _b;
207
+ onReset() {
120
208
  this.assertChanges();
121
- this.filterChange.emit({
122
- prop: this.changes.prop,
123
- type: this.changes.type,
124
- value: (_b = (_a = this.extraElement) === null || _a === void 0 ? void 0 : _a.value) === null || _b === void 0 ? void 0 : _b.trim(),
125
- });
126
- this.changes = undefined;
209
+ delete this.filterItems[this.changes.prop];
210
+ // this updates the DOM which is used by getFilterItemsList() key
211
+ this.filterId++;
212
+ this.filterChange.emit(this.filterItems);
127
213
  }
128
- onReset() {
214
+ onRemoveFilter(id) {
129
215
  this.assertChanges();
130
- this.filterChange.emit({
131
- prop: this.changes.prop,
132
- type: "none",
133
- });
134
- this.changes = void 0;
216
+ // this is for reactivity issues for getFilterItemsList()
217
+ this.filterId++;
218
+ const prop = this.changes.prop;
219
+ const items = this.filterItems[prop];
220
+ if (!items)
221
+ return;
222
+ const index = items.findIndex(d => d.id === id);
223
+ if (index === -1)
224
+ return;
225
+ items.splice(index, 1);
226
+ // let's remove the prop if no more filters so the filter icon will be removed
227
+ if (items.length === 0)
228
+ delete this.filterItems[prop];
229
+ this.debouncedApplyFilter();
230
+ }
231
+ toggleFilterAndOr(id) {
232
+ this.assertChanges();
233
+ // this is for reactivity issues for getFilterItemsList()
234
+ this.filterId++;
235
+ const prop = this.changes.prop;
236
+ const items = this.filterItems[prop];
237
+ if (!items)
238
+ return;
239
+ const index = items.findIndex(d => d.id === id);
240
+ if (index === -1)
241
+ return;
242
+ items[index].relation = items[index].relation === 'and' ? 'or' : 'and';
243
+ this.debouncedApplyFilter();
135
244
  }
136
245
  assertChanges() {
137
246
  if (!this.changes) {
@@ -139,6 +248,12 @@ const FilterPanel = class {
139
248
  }
140
249
  }
141
250
  isOutside(e) {
251
+ const select = document.getElementById('add-filter');
252
+ if (select)
253
+ select.value = defaultType;
254
+ this.currentFilterType = defaultType;
255
+ this.changes.type = defaultType;
256
+ this.currentFilterId = -1;
142
257
  if (e.classList.contains(`[uuid="${this.uuid}"]`)) {
143
258
  return false;
144
259
  }
@@ -972,7 +972,7 @@ export class RevoGridComponent {
972
972
  "mutable": false,
973
973
  "complexType": {
974
974
  "original": "boolean | ColumnFilterConfig",
975
- "resolved": "boolean | { collection?: FilterCollection; include?: string[]; customFilters?: Record<string, CustomFilter>; localization?: FilterLocalization; }",
975
+ "resolved": "boolean | { collection?: FilterCollection; include?: string[]; customFilters?: Record<string, CustomFilter>; localization?: FilterLocalization; multiFilterItems?: MultiFilterItem; }",
976
976
  "references": {
977
977
  "ColumnFilterConfig": {
978
978
  "location": "import",
@@ -5,7 +5,11 @@ const eq = (value, extra) => {
5
5
  if (typeof value !== 'string') {
6
6
  value = JSON.stringify(value);
7
7
  }
8
- return value.toLocaleLowerCase() === extra.toString().toLocaleLowerCase();
8
+ const filterVal = extra.toString().toLocaleLowerCase();
9
+ if (filterVal.length === 0) {
10
+ return true;
11
+ }
12
+ return value.toLocaleLowerCase() === filterVal;
9
13
  };
10
14
  export const notEq = (value, extra) => !eq(value, extra);
11
15
  notEq.extra = 'input';
@@ -2,6 +2,8 @@ import { h } from '@stencil/core';
2
2
  export const FILTER_BUTTON_CLASS = 'rv-filter';
3
3
  export const FILTER_BUTTON_ACTIVE = 'active';
4
4
  export const FILTER_PROP = 'hasFilter';
5
+ export const AND_OR_BUTTON = 'and-or-button';
6
+ export const TRASH_BUTTON = 'trash-button';
5
7
  export const FilterButton = ({ column }) => {
6
8
  return (h("span", null,
7
9
  h("button", { class: {
@@ -12,6 +14,14 @@ export const FilterButton = ({ column }) => {
12
14
  h("g", { stroke: "none", "stroke-width": "1", fill: "none", "fill-rule": "evenodd" },
13
15
  h("path", { d: "M43,48 L43,56 L21,56 L21,48 L43,48 Z M53,28 L53,36 L12,36 L12,28 L53,28 Z M64,8 L64,16 L0,16 L0,8 L64,8 Z", fill: "currentColor" }))))));
14
16
  };
17
+ export const TrashButton = () => {
18
+ return (h("div", { class: { [TRASH_BUTTON]: true } },
19
+ h("svg", { class: "trash-img", viewBox: "0 0 24 24" },
20
+ h("path", { fill: "currentColor", d: "M9,3V4H4V6H5V19A2,2 0 0,0 7,21H17A2,2 0 0,0 19,19V6H20V4H15V3H9M7,6H17V19H7V6M9,8V17H11V8H9M13,8V17H15V8H13Z" }))));
21
+ };
22
+ export const AndOrButton = ({ isAnd }) => {
23
+ return h("button", { class: { [AND_OR_BUTTON]: true, 'light revo-button': true } }, isAnd ? 'and' : 'or');
24
+ };
15
25
  export function isFilterBtn(e) {
16
26
  if (e.classList.contains(FILTER_BUTTON_CLASS)) {
17
27
  return true;
@@ -9,6 +9,7 @@ export default class FilterPlugin extends BasePlugin {
9
9
  super(revogrid);
10
10
  this.revogrid = revogrid;
11
11
  this.filterCollection = {};
12
+ this.multiFilterItems = {};
12
13
  this.possibleFilters = Object.assign({}, filterTypes);
13
14
  this.possibleFilterNames = Object.assign({}, filterNames);
14
15
  this.possibleFilterEntities = Object.assign({}, filterEntities);
@@ -16,21 +17,38 @@ export default class FilterPlugin extends BasePlugin {
16
17
  this.initConfig(config);
17
18
  }
18
19
  const headerclick = (e) => this.headerclick(e);
19
- const aftersourceset = () => {
20
- if (Object.keys(this.filterCollection).length) {
21
- this.filterByProps(this.filterCollection);
20
+ const aftersourceset = async () => {
21
+ const filterCollectionProps = Object.keys(this.filterCollection);
22
+ if (filterCollectionProps.length > 0) {
23
+ // handle old way of filtering by reworking FilterCollection to new MultiFilterItem
24
+ filterCollectionProps.forEach((prop, index) => {
25
+ if (!this.multiFilterItems[prop]) {
26
+ this.multiFilterItems[prop] = [
27
+ {
28
+ id: index,
29
+ type: this.filterCollection[prop].type,
30
+ value: this.filterCollection[prop].value,
31
+ relation: 'and',
32
+ },
33
+ ];
34
+ }
35
+ });
22
36
  }
37
+ await this.runFiltering();
23
38
  };
24
39
  this.addEventListener('headerclick', headerclick);
25
40
  this.addEventListener('aftersourceset', aftersourceset);
26
41
  this.revogrid.registerVNode([
27
- h("revogr-filter-panel", { uuid: `filter-${uiid}`, filterNames: this.possibleFilterNames, filterEntities: this.possibleFilterEntities, filterCaptions: (_a = config.localization) === null || _a === void 0 ? void 0 : _a.captions, onFilterChange: e => this.onFilterChange(e.detail), ref: e => (this.pop = e) }),
42
+ h("revogr-filter-panel", { uuid: `filter-${uiid}`, filterItems: this.multiFilterItems, filterNames: this.possibleFilterNames, filterEntities: this.possibleFilterEntities, filterCaptions: (_a = config === null || config === void 0 ? void 0 : config.localization) === null || _a === void 0 ? void 0 : _a.captions, onFilterChange: e => this.onFilterChange(e.detail), ref: e => (this.pop = e) }),
28
43
  ]);
29
44
  }
30
45
  initConfig(config) {
31
46
  if (config.collection) {
32
47
  this.filterCollection = Object.assign({}, config.collection);
33
48
  }
49
+ if (config.multiFilterItems) {
50
+ this.multiFilterItems = Object.assign({}, config.multiFilterItems);
51
+ }
34
52
  if (config.customFilters) {
35
53
  for (let cType in config.customFilters) {
36
54
  const cFilter = config.customFilters[cType];
@@ -114,43 +132,18 @@ export default class FilterPlugin extends BasePlugin {
114
132
  return !!(typeof type === 'string' && this.possibleFilters[type]);
115
133
  }
116
134
  // called on internal component change
117
- async onFilterChange(filterItem) {
118
- this.filterByProps({ [filterItem.prop]: filterItem });
119
- }
120
- /**
121
- * Apply filters collection to extend existing one or override
122
- * @method
123
- * @param conditions - list of filters to apply
124
- */
125
- async filterByProps(conditions, override = false) {
126
- if (override) {
127
- this.filterCollection = {};
128
- }
129
- for (const prop in conditions) {
130
- const { type, value } = conditions[prop];
131
- if (type === 'none') {
132
- delete this.filterCollection[prop];
133
- }
134
- else {
135
- const filter = this.possibleFilterEntities[type];
136
- this.filterCollection[prop] = {
137
- filter,
138
- value,
139
- type,
140
- };
141
- }
142
- }
143
- await this.runFiltering();
135
+ async onFilterChange(filterItems) {
136
+ this.multiFilterItems = filterItems;
137
+ this.runFiltering();
144
138
  }
145
139
  /**
146
140
  * Triggers grid filtering
147
141
  */
148
- async doFiltering(collection, items, columns) {
142
+ async doFiltering(collection, items, columns, filterItems) {
149
143
  const columnsToUpdate = [];
150
- // todo improvement: loop through collection of props
151
144
  columns.forEach(rgCol => {
152
145
  const column = Object.assign({}, rgCol);
153
- const hasFilter = collection[column.prop];
146
+ const hasFilter = filterItems[column.prop];
154
147
  if (column[FILTER_PROP] && !hasFilter) {
155
148
  delete column[FILTER_PROP];
156
149
  columnsToUpdate.push(column);
@@ -160,9 +153,9 @@ export default class FilterPlugin extends BasePlugin {
160
153
  column[FILTER_PROP] = true;
161
154
  }
162
155
  });
163
- const itemsToFilter = this.getRowFilter(items, collection);
156
+ const itemsToFilter = this.getRowFilter(items, filterItems);
164
157
  // check is filter event prevented
165
- const { defaultPrevented, detail } = this.emit('beforefiltertrimmed', { collection, itemsToFilter, source: items });
158
+ const { defaultPrevented, detail } = this.emit('beforefiltertrimmed', { collection, itemsToFilter, source: items, filterItems });
166
159
  if (defaultPrevented) {
167
160
  return;
168
161
  }
@@ -171,39 +164,92 @@ export default class FilterPlugin extends BasePlugin {
171
164
  if (isAddedEvent.defaultPrevented) {
172
165
  return;
173
166
  }
167
+ // applies the hasFilter to the columns to show filter icon
174
168
  await this.revogrid.updateColumns(columnsToUpdate);
175
169
  this.emit('afterFilterApply');
176
170
  }
177
171
  async clearFiltering() {
178
- this.filterCollection = {};
172
+ this.multiFilterItems = {};
179
173
  await this.runFiltering();
180
174
  }
181
175
  async runFiltering() {
176
+ const collection = {};
177
+ // handle old filterCollection to return the first filter only (if any) from multiFilterItems
178
+ const filterProps = Object.keys(this.multiFilterItems);
179
+ for (const prop of filterProps) {
180
+ // check if we have any filter for a column
181
+ if (this.multiFilterItems[prop].length > 0) {
182
+ const firstFilterItem = this.multiFilterItems[prop][0];
183
+ collection[prop] = {
184
+ filter: filterEntities[firstFilterItem.type],
185
+ type: firstFilterItem.type,
186
+ value: firstFilterItem.value,
187
+ };
188
+ }
189
+ }
190
+ this.filterCollection = collection;
182
191
  const { source, columns } = await this.getData();
183
- const { defaultPrevented, detail } = this.emit('beforefilterapply', { collection: this.filterCollection, source, columns });
192
+ const { defaultPrevented, detail } = this.emit('beforefilterapply', { collection: this.filterCollection, source, columns, filterItems: this.multiFilterItems });
184
193
  if (defaultPrevented) {
185
194
  return;
186
195
  }
187
- this.doFiltering(detail.collection, detail.source, detail.columns);
196
+ this.doFiltering(detail.collection, detail.source, detail.columns, detail.filterItems);
188
197
  }
189
198
  async getData() {
190
199
  const source = await this.revogrid.getSource();
191
200
  const columns = await this.revogrid.getColumns();
192
201
  return {
193
202
  source,
194
- columns
203
+ columns,
195
204
  };
196
205
  }
197
- getRowFilter(rows, collection) {
206
+ getRowFilter(rows, filterItems) {
207
+ const propKeys = Object.keys(filterItems);
198
208
  const trimmed = {};
209
+ let propFilterSatisfiedCount = 0;
210
+ let lastFilterResults = [];
211
+ // each rows
199
212
  rows.forEach((model, rowIndex) => {
200
- for (const prop in collection) {
201
- const filterItem = collection[prop];
202
- const filter = filterItem.filter;
203
- if (!filter(model[prop], filterItem.value)) {
213
+ // working on all props
214
+ for (const prop of propKeys) {
215
+ const propFilters = filterItems[prop];
216
+ propFilterSatisfiedCount = 0;
217
+ lastFilterResults = [];
218
+ // testing each filter for a prop
219
+ for (const [filterIndex, filterData] of propFilters.entries()) {
220
+ // the filter LogicFunction based on the type
221
+ const filter = filterEntities[filterData.type];
222
+ // THE MAGIC OF FILTERING IS HERE
223
+ if (filterData.relation === 'or') {
224
+ lastFilterResults = [];
225
+ if (filter(model[prop], filterData.value)) {
226
+ continue;
227
+ }
228
+ propFilterSatisfiedCount++;
229
+ }
230
+ else {
231
+ // 'and' relation will need to know the next filter
232
+ // so we save this current filter to include it in the next filter
233
+ lastFilterResults.push(!filter(model[prop], filterData.value));
234
+ // check first if we have a filter on the next index to pair it with this current filter
235
+ const nextFilterData = propFilters[filterIndex + 1];
236
+ // stop the sequence if there is no next filter or if the next filter is not an 'and' relation
237
+ if (!nextFilterData || nextFilterData.relation !== 'and') {
238
+ // let's just continue since for sure propFilterSatisfiedCount cannot be satisfied
239
+ if (lastFilterResults.indexOf(true) === -1) {
240
+ lastFilterResults = [];
241
+ continue;
242
+ }
243
+ // we need to add all of the lastFilterResults since we need to satisfy all
244
+ propFilterSatisfiedCount += lastFilterResults.length;
245
+ lastFilterResults = [];
246
+ }
247
+ }
248
+ } // end of propFilters forEach
249
+ // add to the list of removed/trimmed rows of filter condition is satisfied
250
+ if (propFilterSatisfiedCount === propFilters.length)
204
251
  trimmed[rowIndex] = true;
205
- }
206
- }
252
+ } // end of for-of propKeys
207
253
  });
208
254
  return trimmed;
209
255
  }