@limetech/lime-crm-building-blocks 1.105.1 → 1.105.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.
Files changed (29) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/{lime-query-validation-82aa2855.js → lime-query-validation-6d419d03.js} +78 -16
  3. package/dist/cjs/limebb-lime-query-builder.cjs.entry.js +2 -2
  4. package/dist/cjs/limebb-lime-query-filter-group_3.cjs.entry.js +1 -1
  5. package/dist/cjs/limebb-lime-query-response-format-builder.cjs.entry.js +2 -2
  6. package/dist/cjs/limebb-property-selector.cjs.entry.js +1 -1
  7. package/dist/cjs/{property-resolution-fb42a46b.js → property-resolution-5f798b03.js} +47 -0
  8. package/dist/collection/components/lime-query-builder/lime-query-validation.js +78 -17
  9. package/dist/collection/components/lime-query-builder/property-resolution.js +46 -0
  10. package/dist/components/lime-query-validation.js +78 -16
  11. package/dist/components/property-selector.js +47 -1
  12. package/dist/esm/{lime-query-validation-9e386da8.js → lime-query-validation-237ee440.js} +78 -16
  13. package/dist/esm/limebb-lime-query-builder.entry.js +2 -2
  14. package/dist/esm/limebb-lime-query-filter-group_3.entry.js +1 -1
  15. package/dist/esm/limebb-lime-query-response-format-builder.entry.js +2 -2
  16. package/dist/esm/limebb-property-selector.entry.js +1 -1
  17. package/dist/esm/{property-resolution-c21a1369.js → property-resolution-e4e8dcf7.js} +47 -1
  18. package/dist/lime-crm-building-blocks/lime-crm-building-blocks.esm.js +1 -1
  19. package/dist/lime-crm-building-blocks/{p-ac9e81c9.entry.js → p-09ce8be4.entry.js} +1 -1
  20. package/dist/lime-crm-building-blocks/p-11aa4103.js +1 -0
  21. package/dist/lime-crm-building-blocks/{p-d8696b23.entry.js → p-9c2062bc.entry.js} +1 -1
  22. package/dist/lime-crm-building-blocks/p-b02c99d5.js +1 -0
  23. package/dist/lime-crm-building-blocks/{p-908dd7d5.entry.js → p-ee0e42dd.entry.js} +1 -1
  24. package/dist/lime-crm-building-blocks/{p-1421e1f8.entry.js → p-f7ea292d.entry.js} +1 -1
  25. package/dist/types/components/lime-query-builder/lime-query-validation.d.ts +14 -0
  26. package/dist/types/components/lime-query-builder/property-resolution.d.ts +12 -0
  27. package/package.json +2 -2
  28. package/dist/lime-crm-building-blocks/p-b748c770.js +0 -1
  29. package/dist/lime-crm-building-blocks/p-efa5bcd4.js +0 -1
@@ -1 +1 @@
1
- import{r as t,c as i,h as s}from"./p-1556b545.js";import{T as e,c as o}from"./p-4838284a.js";import{g as r,a as n}from"./p-b748c770.js";import{b as h}from"./p-20bfca36.js";const l=class{constructor(s){t(this,s),this.change=i(this,"change",7),this.label="Property",this.required=!1,this.isOpen=!1,this.navigationPath="",this.menuItems=[],this.handleChipSetWrapperClick=t=>{t.stopPropagation()},this.handleChipSetFocus=()=>{this.isOpen||(this.navigationPath=this.value||"",this.loadMenuItems(),this.isOpen=!0)},this.handleSelect=t=>{t.stopPropagation();const i=t.detail.value;if(!i)return;const s=r(this.limetypes,this.limetype,i);(null==s?void 0:s.relation)?this.navigationPath=i:(this.change.emit(i),this.isOpen=!1,this.navigationPath="")},this.handleNavigateMenu=t=>{var i;t.stopPropagation(),(null===(i=t.detail)||void 0===i?void 0:i.value)&&(this.navigationPath=t.detail.value)},this.handleCancel=()=>{this.isOpen=!1,this.navigationPath=""},this.handleChipSetChange=t=>{t.stopPropagation();const i=t.detail;if(!i)return this.change.emit(""),void(this.navigationPath="");const s=Array.isArray(i)?i:[i];if(0===s.length)this.change.emit(""),this.navigationPath="";else{const t=s.at(-1);t&&this.change.emit(t.value),this.navigationPath=""}}}componentWillLoad(){const t=this.platform.get(o.Application).getLanguage();this.collator=new Intl.Collator(t,{numeric:!0,sensitivity:"base"})}render(){if(!this.limetype||!this.limetypes)return null;const t=this.getChipsForPath(this.navigationPath||this.value||"");return s("limel-menu",{items:this.menuItems,open:this.isOpen,emptyResultMessage:"No available properties",surfaceWidth:"inherit-from-trigger",openDirection:"bottom-end",onSelect:this.handleSelect,onNavigateMenu:this.handleNavigateMenu,onCancel:this.handleCancel},s("div",{slot:"trigger"},s("div",{onClick:this.handleChipSetWrapperClick},s("limel-chip-set",{type:"input",label:this.label,value:t,required:this.required,helperText:this.helperText,delimiter:"›",maxItems:1,onChange:this.handleChipSetChange,onFocus:this.handleChipSetFocus}))))}loadMenuItems(){const t=this.getCurrentLimetype();this.menuItems=t?this.createMenuItems(t,""):[]}getCurrentLimetype(){if(!this.navigationPath)return this.limetypes[this.limetype];const t=r(this.limetypes,this.limetype,this.navigationPath);return(null==t?void 0:t.relation)?t.relation.getLimetype():this.limetypes[this.limetype]}createMenuItems(t,i){const s=[];if(!t)return s;const e=n(t);for(const[t,o]of Object.entries(e)){if("hasmany"===o.type||"hasandbelongstomany"===o.type)continue;const e=i?`${i}.${t}`:t;let r;if(o.relation&&o.relation){const t=o.relation.getLimetype();t&&(r=async()=>this.createMenuItems(t,e))}s.push({text:o.localname||t,secondaryText:this.getSecondaryText(o),icon:this.getIconForProperty(o),value:e,items:r})}return s.sort(((t,i)=>{var s,e;return this.collator.compare(null!==(s=t.text)&&void 0!==s?s:"",null!==(e=i.text)&&void 0!==e?e:"")})),0===s.length?[{text:"No available properties",value:"",disabled:!0}]:s}getSecondaryText(t){var i;if(t.relation){const s=t.relation.getLimetype();return(null===(i=null==s?void 0:s.localname)||void 0===i?void 0:i.singular)||"Object"}return t.type.charAt(0).toUpperCase()+t.type.slice(1)}getIconForProperty(t){return t.relation?h(t.relation.getLimetype()):{name:"dot_circle",color:"rgb(var(--color-gray-default))"}}getChipsForPath(t){if(!t)return[];const i=t.split("."),s=[];let e=this.limetypes[this.limetype],o="";for(const t of i){o=o?`${o}.${t}`:t;const i=n(e)[t];i&&(s.push({id:o,text:i.localname||t,icon:this.getIconForProperty(i),value:o}),i.relation&&(e=i.relation.getLimetype()))}return s}};(function(t,i,s,e){var o,r=arguments.length,n=r<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,i,s,e);else for(var h=t.length-1;h>=0;h--)(o=t[h])&&(n=(r<3?o(n):r>3?o(i,s,n):o(i,s))||n);r>3&&n&&Object.defineProperty(i,s,n)})([e()],l.prototype,"limetypes",void 0),l.style=":host(limebb-property-selector){display:block}limel-menu{display:block;width:100%}";export{l as limebb_property_selector}
1
+ import{r as t,c as i,h as s}from"./p-1556b545.js";import{T as e,c as o}from"./p-4838284a.js";import{g as r,a as n}from"./p-b02c99d5.js";import{b as h}from"./p-20bfca36.js";const l=class{constructor(s){t(this,s),this.change=i(this,"change",7),this.label="Property",this.required=!1,this.isOpen=!1,this.navigationPath="",this.menuItems=[],this.handleChipSetWrapperClick=t=>{t.stopPropagation()},this.handleChipSetFocus=()=>{this.isOpen||(this.navigationPath=this.value||"",this.loadMenuItems(),this.isOpen=!0)},this.handleSelect=t=>{t.stopPropagation();const i=t.detail.value;if(!i)return;const s=r(this.limetypes,this.limetype,i);(null==s?void 0:s.relation)?this.navigationPath=i:(this.change.emit(i),this.isOpen=!1,this.navigationPath="")},this.handleNavigateMenu=t=>{var i;t.stopPropagation(),(null===(i=t.detail)||void 0===i?void 0:i.value)&&(this.navigationPath=t.detail.value)},this.handleCancel=()=>{this.isOpen=!1,this.navigationPath=""},this.handleChipSetChange=t=>{t.stopPropagation();const i=t.detail;if(!i)return this.change.emit(""),void(this.navigationPath="");const s=Array.isArray(i)?i:[i];if(0===s.length)this.change.emit(""),this.navigationPath="";else{const t=s.at(-1);t&&this.change.emit(t.value),this.navigationPath=""}}}componentWillLoad(){const t=this.platform.get(o.Application).getLanguage();this.collator=new Intl.Collator(t,{numeric:!0,sensitivity:"base"})}render(){if(!this.limetype||!this.limetypes)return null;const t=this.getChipsForPath(this.navigationPath||this.value||"");return s("limel-menu",{items:this.menuItems,open:this.isOpen,emptyResultMessage:"No available properties",surfaceWidth:"inherit-from-trigger",openDirection:"bottom-end",onSelect:this.handleSelect,onNavigateMenu:this.handleNavigateMenu,onCancel:this.handleCancel},s("div",{slot:"trigger"},s("div",{onClick:this.handleChipSetWrapperClick},s("limel-chip-set",{type:"input",label:this.label,value:t,required:this.required,helperText:this.helperText,delimiter:"›",maxItems:1,onChange:this.handleChipSetChange,onFocus:this.handleChipSetFocus}))))}loadMenuItems(){const t=this.getCurrentLimetype();this.menuItems=t?this.createMenuItems(t,""):[]}getCurrentLimetype(){if(!this.navigationPath)return this.limetypes[this.limetype];const t=r(this.limetypes,this.limetype,this.navigationPath);return(null==t?void 0:t.relation)?t.relation.getLimetype():this.limetypes[this.limetype]}createMenuItems(t,i){const s=[];if(!t)return s;const e=n(t);for(const[t,o]of Object.entries(e)){if("hasmany"===o.type||"hasandbelongstomany"===o.type)continue;const e=i?`${i}.${t}`:t;let r;if(o.relation&&o.relation){const t=o.relation.getLimetype();t&&(r=async()=>this.createMenuItems(t,e))}s.push({text:o.localname||t,secondaryText:this.getSecondaryText(o),icon:this.getIconForProperty(o),value:e,items:r})}return s.sort(((t,i)=>{var s,e;return this.collator.compare(null!==(s=t.text)&&void 0!==s?s:"",null!==(e=i.text)&&void 0!==e?e:"")})),0===s.length?[{text:"No available properties",value:"",disabled:!0}]:s}getSecondaryText(t){var i;if(t.relation){const s=t.relation.getLimetype();return(null===(i=null==s?void 0:s.localname)||void 0===i?void 0:i.singular)||"Object"}return t.type.charAt(0).toUpperCase()+t.type.slice(1)}getIconForProperty(t){return t.relation?h(t.relation.getLimetype()):{name:"dot_circle",color:"rgb(var(--color-gray-default))"}}getChipsForPath(t){if(!t)return[];const i=t.split("."),s=[];let e=this.limetypes[this.limetype],o="";for(const t of i){o=o?`${o}.${t}`:t;const i=n(e)[t];i&&(s.push({id:o,text:i.localname||t,icon:this.getIconForProperty(i),value:o}),i.relation&&(e=i.relation.getLimetype()))}return s}};(function(t,i,s,e){var o,r=arguments.length,n=r<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,i,s,e);else for(var h=t.length-1;h>=0;h--)(o=t[h])&&(n=(r<3?o(n):r>3?o(i,s,n):o(i,s))||n);r>3&&n&&Object.defineProperty(i,s,n)})([e()],l.prototype,"limetypes",void 0),l.style=":host(limebb-property-selector){display:block}limel-menu{display:block;width:100%}";export{l as limebb_property_selector}
@@ -0,0 +1 @@
1
+ function e(e){if(!(null==e?void 0:e.properties))return{};const t=Object.assign({},e.properties),r={id:"_id",timestamp:"_timestamp",descriptive:"_descriptive",createduser:"_createduser",createdtime:"_createdtime",updateduser:"_updateduser"};for(const[e,n]of Object.entries(r)){const r=t[e];r&&(t[n]=r,delete t[e])}return t}function t(t,r,n){if(!n||!r||!t)return;const o=n.split(".");let i,s=t[r];for(const t of o){if(!s)return;if(i=e(s)[t],!i)return;i.relation&&(s=i.relation.getLimetype())}return i}function r(t,r,n){if(!n||!r||!t)return{property:void 0};const o=n.split(".");let i,s=t[r];for(let t=0;t<o.length;t++){const r=o[t];if(!s)return{property:void 0};if(i=e(s)[r],!i)return{property:void 0,error:`Property '${r}' does not exist on limetype '${s.name}'`};if("hasmany"===i.type||"hasandbelongstomany"===i.type)return{property:void 0,error:`Cannot filter on many-relation '${o.slice(0,t+1).join(".")}'. Use a related limetype's filter instead.`};i.relation&&(s=i.relation.getLimetype())}return{property:i}}export{e as a,t as g,r as v}
@@ -1 +1 @@
1
- import{r as e,c as t,h as i,H as r}from"./p-1556b545.js";import{Z as s,T as l}from"./p-4838284a.js";import{g as o}from"./p-b748c770.js";function n(){return{key:"",op:s.EQUALS,exp:""}}function a(e,t){return{op:e.op,exp:[...e.exp,t]}}const h=class{constructor(r){e(this,r),this.expressionChange=t(this,"expressionChange",7),this.options=[{text:"All",secondaryText:"AND operator",value:"and"},{text:"Any",secondaryText:"OR operator",value:"or"}],this.renderChildExpression=(e,t)=>i("limebb-lime-query-filter-expression",{role:"listitem",platform:this.platform,context:this.context,limetype:this.limetype,activeLimetype:this.activeLimetype,expression:e,onExpressionChange:this.handleExpressionChange(t)}),this.handleDeleteGroup=()=>{this.expressionChange.emit()},this.handleToggleOperator=e=>{const t=Array.isArray(e.detail)?e.detail[0]:e.detail;if(this.value=t,("and"===t.value?s.AND:s.OR)!==this.expression.op){const e={op:(i=this.expression).op===s.AND?s.OR:s.AND,exp:[...i.exp]};this.expressionChange.emit(e)}var i},this.handleAddChildExpression=()=>{const e=n(),t=a(this.expression,e);this.expressionChange.emit(t)},this.handleAddChildGroup=()=>{const e={op:this.expression.op===s.AND?s.OR:s.AND,exp:[n()]},t=a(this.expression,e);this.expressionChange.emit(t)},this.handleExpressionChange=e=>t=>{t.stopPropagation();const i=function(e,t,i){const r=[...e.exp];return i?(r[t]=i,{type:"updated",expression:{op:e.op,exp:r}}):(r.splice(t,1),0===r.length?{type:"removed",expression:void 0}:1===r.length?{type:"unwrapped",expression:r[0]}:{type:"updated",expression:{op:e.op,exp:r}})}(this.expression,e,t.detail);this.expressionChange.emit(i.expression)}}componentWillLoad(){this.value=this.options.find((e=>e.value===(this.expression.op===s.AND?"and":"or")))||this.options[0]}render(){return i(r,{key:"324805229eab509d12b6d41a99a54c1a4d8560a1",style:{"--limebb-lime-query-filter-group-operator":`"${this.expression.op===s.AND?"AND":"OR"}"`}},i("div",{key:"948dda71aac51cbfd8b93bc657a79c00a6bd6f68",class:"expression"},this.renderHeader(),i("ul",{key:"b1dbce8f4f20f72e00567d431eed0fe5900f4fbf"},this.expression.exp.map(this.renderChildExpression),this.renderAddButton()),this.renderAddGroupButton()))}renderHeader(){const e=this.getSubheading();return e?i("limel-header",{subheading:e},this.renderOperators(),this.renderDeleteGroupButton()):null}renderOperators(){return i("limel-select",{class:"operator-select",slot:"actions",value:this.value,options:this.options,onChange:this.handleToggleOperator})}renderDeleteGroupButton(){return i("limel-icon-button",{class:"delete-group",slot:"actions",icon:"trash",label:"Delete This Group",onClick:this.handleDeleteGroup})}getSubheading(){return this.expression.exp.length<=1?"":this.expression.op===s.AND?"All of these conditions are met":"Any of these conditions are met"}renderAddButton(){return i("limel-button",{role:"listitem",label:"Condition",icon:{name:"plus_math",title:"Add"},onClick:this.handleAddChildExpression})}renderAddGroupButton(){return i("limel-button",{class:"add-group",label:"Group",icon:{name:"plus_math",title:"Add"},onClick:this.handleAddChildGroup})}};h.style='@charset "UTF-8";*,*::before,*::after{box-sizing:border-box}limebb-lime-query-filter-expression{position:relative;isolation:isolate}limebb-lime-query-filter-expression:not(:first-of-type):after{content:"";position:absolute;top:-0.5rem;left:0.75rem;display:block;border-radius:1rem;height:2rem;width:0.125rem;background-color:var(--limebb-lime-query-builder-group-color)}limebb-lime-query-filter-expression:not(:first-of-type):before{position:relative;z-index:1;display:flex;justify-content:center;align-items:center;height:1rem;content:var(--limebb-lime-query-filter-group-operator);display:inline-block;margin:0 auto 0.5rem auto;transform:translateY(-50%);font-size:0.625rem;padding:0 0.5rem;color:rgb(var(--color-blue-dark));background-color:var(--limebb-lime-query-builder-group-color);border-radius:2rem}.expression{display:flex;flex-direction:column;margin-bottom:1rem;gap:0;background-color:rgb(var(--contrast-100));border-radius:0.75rem;border:1px solid var(--limebb-lime-query-builder-group-color)}.expression ul{list-style:none;margin:0;padding:0.5rem;display:flex;flex-direction:column;align-items:center;gap:1rem}.expression ul [role=listitem]{list-style:none;width:100%}limel-button.add-group{width:fit-content;margin:0.5rem}limel-icon-button.delete-group{margin-left:0.5rem}limel-select.operator-select{min-width:8rem}';const c=class{constructor(i){e(this,i),this.expressionChange=t(this,"expressionChange",7),this.handleExpressionChange=e=>{var t;e.stopPropagation();const i=null!==(t=e.detail)&&void 0!==t?t:void 0;this.expressionChange.emit(void 0!==i?{op:s.NOT,exp:i}:void 0)}}render(){return i("div",{key:"8f234a17a56f899640f503dcc58e6ef7d8e6a998",class:"expression"},this.label&&i("limel-header",{key:"1e71be2c56690aa3c603c88028860093b54a2a84",heading:this.label}),i("limebb-lime-query-filter-expression",{key:"1fde4344ca12d9ced489ee8e4f1b9de806da1dc4",platform:this.platform,context:this.context,label:"Not",limetype:this.limetype,activeLimetype:this.activeLimetype,expression:this.expression.exp,onExpressionChange:this.handleExpressionChange}))}};c.style='@charset "UTF-8";.expression{display:flex;flex-direction:column;margin-bottom:1rem;gap:1rem;padding:1rem;border-left:0.25rem solid rgb(var(--contrast-400));background-color:rgb(var(--contrast-100))}';const d={timestamp:"time",createdtime:"time",updatedtime:"time",id:"integer",createduser:"integer",updateduser:"integer",descriptive:"string"},u={date:"date",time:"datetime",timeofday:"time",month:"month",quarter:"quarter",year:"year"};const p=class{constructor(i){e(this,i),this.change=t(this,"change",7),this.label="Value",this.inputMode="value",this.handleTextChange=e=>{e.stopPropagation();const t=e.detail,i=Number(t);Number.isNaN(i)||""===t?this.change.emit(t):this.change.emit(i)},this.handleSelectChange=e=>{e.stopPropagation();const t=e.detail;Array.isArray(t)?this.change.emit(t.map((e=>e.value))):this.change.emit(null==t?void 0:t.value)},this.handleBooleanChange=e=>{e.stopPropagation();const t=e.detail;Array.isArray(t)||this.change.emit("true"===(null==t?void 0:t.value))},this.handleDateChange=e=>{e.stopPropagation();const t=e.detail;this.change.emit(t?t.toISOString():null)},this.handleMultiValueChange=e=>{e.stopPropagation();const t=e.detail.split(",").map((e=>e.trim())).filter((e=>e.length>0));this.change.emit(t)},this.handleModeToggle=()=>{"value"===this.inputMode?(this.inputMode="placeholder",this.change.emit("%activeObject%")):(this.inputMode="value",this.change.emit(""))},this.handlePlaceholderPropertyChange=e=>{e.stopPropagation();const t=this.buildPlaceholderValue(e.detail);this.change.emit(t)}}componentWillLoad(){this.isPlaceholder(this.value)&&(this.inputMode="placeholder")}componentWillUpdate(){this.isPlaceholder(this.value)&&"placeholder"!==this.inputMode?this.inputMode="placeholder":this.isPlaceholder(this.value)||"placeholder"!==this.inputMode||(this.inputMode="value")}isPlaceholder(e){return"string"==typeof e&&e.startsWith("%activeObject%")}parsePlaceholderPath(e){return this.isPlaceholder(e)?e.replace(/^%activeObject%\.?/,""):""}buildPlaceholderValue(e){return e?`%activeObject%.${e}`:"%activeObject%"}render(){return this.operator?i(r,null,this.renderModeToggle(),this.renderInputByMode()):null}renderInputByMode(){return"placeholder"===this.inputMode?this.renderPlaceholderInput():this.renderValueInputByType()}renderModeToggle(){if(!this.activeLimetype)return null;const e="placeholder"===this.inputMode;return i("limel-icon-button",{class:"mode-toggle",icon:e?"text":"link",label:e?"Use Value":"Use Placeholder",onClick:this.handleModeToggle})}renderPlaceholderInput(){const e=this.parsePlaceholderPath(this.value);return i("div",{class:"placeholder-input"},i("limebb-property-selector",{platform:this.platform,context:this.context,limetype:this.activeLimetype,label:"Active Object Property",value:e,required:!1,helperText:"Select property from the active object",onChange:this.handlePlaceholderPropertyChange}),this.renderPlaceholderPreview())}renderPlaceholderPreview(){if(this.isPlaceholder(this.value))return i("div",{class:"placeholder-preview"},i("limel-icon",{name:"info",size:"small"}),i("span",null,"Placeholder: ",this.value))}renderValueInputByType(){if(this.operator===s.IN)return this.renderMultiValueInput();const e=this.getProperty();if(!e)return this.renderTextInput();const t=function(e){return"system"===e.type?function(e){const t=e.replace(/^_/,"");return d[t]||"string"}(e.name):e.type}(e);switch(t){case"integer":case"decimal":return this.renderNumberInput(t);case"yesno":return this.renderBooleanInput();case"option":return this.renderOptionInput(e);case"date":case"time":case"timeofday":case"year":case"month":case"quarter":return this.renderDateTimeInput(t);default:return this.renderTextInput()}}renderTextInput(){var e;return i("limel-input-field",{label:this.label,value:(null===(e=this.value)||void 0===e?void 0:e.toString())||"",placeholder:"Enter value",onChange:this.handleTextChange})}renderNumberInput(e){var t;const r="integer"===e?1:.01;return i("limel-input-field",{label:this.label,type:"number",value:(null===(t=this.value)||void 0===t?void 0:t.toString())||"",step:r,onChange:this.handleTextChange})}renderBooleanInput(){const e=[{text:"True",value:"true"},{text:"False",value:"false"}],t=!0===this.value||"true"===this.value?"true":"false",r=e.find((e=>e.value===t));return i("limel-select",{label:this.label,options:e,value:r,onChange:this.handleBooleanChange})}renderOptionInput(e){if(!e.options||0===e.options.length)return this.renderTextInput();const t=e.options.map((e=>({text:e.text||e.key,value:e.key}))),r=t.find((e=>e.value===this.value));return i("limel-select",{label:this.label,options:t,value:r,onChange:this.handleSelectChange})}renderDateTimeInput(e){const t="string"==typeof this.value?new Date(this.value):this.value;return i("limel-date-picker",{label:this.label,value:t,type:u[e]||"date",onChange:this.handleDateChange})}renderMultiValueInput(){const e=Array.isArray(this.value)?this.value.join(", "):this.value||"";return i("limel-input-field",{label:this.label+" (comma-separated)",value:e,placeholder:"e.g., won, lost, tender",onChange:this.handleMultiValueChange})}getProperty(){if(this.limetypes&&this.limetype&&this.propertyPath)return o(this.limetypes,this.limetype,this.propertyPath)}};(function(e,t,i,r){var s,l=arguments.length,o=l<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,r);else for(var n=e.length-1;n>=0;n--)(s=e[n])&&(o=(l<3?s(o):l>3?s(t,i,o):s(t,i))||o);l>3&&o&&Object.defineProperty(t,i,o)})([l()],p.prototype,"limetypes",void 0),p.style=":host{display:flex;gap:0.5rem}:host>*{flex-grow:1}*{box-sizing:border-box}.value-input-container{display:flex;flex-direction:row;align-items:flex-start;gap:0.5rem;width:100%}.mode-toggle{flex-shrink:0;flex-grow:0}.placeholder-input{flex-grow:1;display:flex;flex-direction:column;gap:0.5rem}.placeholder-preview{display:flex;align-items:center;gap:0.5rem;padding:0.5rem;background-color:rgba(var(--color-blue-light), 0.1);border-radius:var(--border-radius-small);font-size:0.875rem;color:rgb(var(--color-blue-default));border-left:3px solid rgb(var(--color-blue-default))}.placeholder-preview limel-icon{flex-shrink:0;color:rgb(var(--color-blue-default))}.placeholder-preview span{font-family:var(--font-monospace);word-break:break-all}";export{h as limebb_lime_query_filter_group,c as limebb_lime_query_filter_not,p as limebb_lime_query_value_input}
1
+ import{r as e,c as t,h as i,H as r}from"./p-1556b545.js";import{Z as s,T as l}from"./p-4838284a.js";import{g as o}from"./p-b02c99d5.js";function n(){return{key:"",op:s.EQUALS,exp:""}}function a(e,t){return{op:e.op,exp:[...e.exp,t]}}const h=class{constructor(r){e(this,r),this.expressionChange=t(this,"expressionChange",7),this.options=[{text:"All",secondaryText:"AND operator",value:"and"},{text:"Any",secondaryText:"OR operator",value:"or"}],this.renderChildExpression=(e,t)=>i("limebb-lime-query-filter-expression",{role:"listitem",platform:this.platform,context:this.context,limetype:this.limetype,activeLimetype:this.activeLimetype,expression:e,onExpressionChange:this.handleExpressionChange(t)}),this.handleDeleteGroup=()=>{this.expressionChange.emit()},this.handleToggleOperator=e=>{const t=Array.isArray(e.detail)?e.detail[0]:e.detail;if(this.value=t,("and"===t.value?s.AND:s.OR)!==this.expression.op){const e={op:(i=this.expression).op===s.AND?s.OR:s.AND,exp:[...i.exp]};this.expressionChange.emit(e)}var i},this.handleAddChildExpression=()=>{const e=n(),t=a(this.expression,e);this.expressionChange.emit(t)},this.handleAddChildGroup=()=>{const e={op:this.expression.op===s.AND?s.OR:s.AND,exp:[n()]},t=a(this.expression,e);this.expressionChange.emit(t)},this.handleExpressionChange=e=>t=>{t.stopPropagation();const i=function(e,t,i){const r=[...e.exp];return i?(r[t]=i,{type:"updated",expression:{op:e.op,exp:r}}):(r.splice(t,1),0===r.length?{type:"removed",expression:void 0}:1===r.length?{type:"unwrapped",expression:r[0]}:{type:"updated",expression:{op:e.op,exp:r}})}(this.expression,e,t.detail);this.expressionChange.emit(i.expression)}}componentWillLoad(){this.value=this.options.find((e=>e.value===(this.expression.op===s.AND?"and":"or")))||this.options[0]}render(){return i(r,{key:"324805229eab509d12b6d41a99a54c1a4d8560a1",style:{"--limebb-lime-query-filter-group-operator":`"${this.expression.op===s.AND?"AND":"OR"}"`}},i("div",{key:"948dda71aac51cbfd8b93bc657a79c00a6bd6f68",class:"expression"},this.renderHeader(),i("ul",{key:"b1dbce8f4f20f72e00567d431eed0fe5900f4fbf"},this.expression.exp.map(this.renderChildExpression),this.renderAddButton()),this.renderAddGroupButton()))}renderHeader(){const e=this.getSubheading();return e?i("limel-header",{subheading:e},this.renderOperators(),this.renderDeleteGroupButton()):null}renderOperators(){return i("limel-select",{class:"operator-select",slot:"actions",value:this.value,options:this.options,onChange:this.handleToggleOperator})}renderDeleteGroupButton(){return i("limel-icon-button",{class:"delete-group",slot:"actions",icon:"trash",label:"Delete This Group",onClick:this.handleDeleteGroup})}getSubheading(){return this.expression.exp.length<=1?"":this.expression.op===s.AND?"All of these conditions are met":"Any of these conditions are met"}renderAddButton(){return i("limel-button",{role:"listitem",label:"Condition",icon:{name:"plus_math",title:"Add"},onClick:this.handleAddChildExpression})}renderAddGroupButton(){return i("limel-button",{class:"add-group",label:"Group",icon:{name:"plus_math",title:"Add"},onClick:this.handleAddChildGroup})}};h.style='@charset "UTF-8";*,*::before,*::after{box-sizing:border-box}limebb-lime-query-filter-expression{position:relative;isolation:isolate}limebb-lime-query-filter-expression:not(:first-of-type):after{content:"";position:absolute;top:-0.5rem;left:0.75rem;display:block;border-radius:1rem;height:2rem;width:0.125rem;background-color:var(--limebb-lime-query-builder-group-color)}limebb-lime-query-filter-expression:not(:first-of-type):before{position:relative;z-index:1;display:flex;justify-content:center;align-items:center;height:1rem;content:var(--limebb-lime-query-filter-group-operator);display:inline-block;margin:0 auto 0.5rem auto;transform:translateY(-50%);font-size:0.625rem;padding:0 0.5rem;color:rgb(var(--color-blue-dark));background-color:var(--limebb-lime-query-builder-group-color);border-radius:2rem}.expression{display:flex;flex-direction:column;margin-bottom:1rem;gap:0;background-color:rgb(var(--contrast-100));border-radius:0.75rem;border:1px solid var(--limebb-lime-query-builder-group-color)}.expression ul{list-style:none;margin:0;padding:0.5rem;display:flex;flex-direction:column;align-items:center;gap:1rem}.expression ul [role=listitem]{list-style:none;width:100%}limel-button.add-group{width:fit-content;margin:0.5rem}limel-icon-button.delete-group{margin-left:0.5rem}limel-select.operator-select{min-width:8rem}';const c=class{constructor(i){e(this,i),this.expressionChange=t(this,"expressionChange",7),this.handleExpressionChange=e=>{var t;e.stopPropagation();const i=null!==(t=e.detail)&&void 0!==t?t:void 0;this.expressionChange.emit(void 0!==i?{op:s.NOT,exp:i}:void 0)}}render(){return i("div",{key:"8f234a17a56f899640f503dcc58e6ef7d8e6a998",class:"expression"},this.label&&i("limel-header",{key:"1e71be2c56690aa3c603c88028860093b54a2a84",heading:this.label}),i("limebb-lime-query-filter-expression",{key:"1fde4344ca12d9ced489ee8e4f1b9de806da1dc4",platform:this.platform,context:this.context,label:"Not",limetype:this.limetype,activeLimetype:this.activeLimetype,expression:this.expression.exp,onExpressionChange:this.handleExpressionChange}))}};c.style='@charset "UTF-8";.expression{display:flex;flex-direction:column;margin-bottom:1rem;gap:1rem;padding:1rem;border-left:0.25rem solid rgb(var(--contrast-400));background-color:rgb(var(--contrast-100))}';const d={timestamp:"time",createdtime:"time",updatedtime:"time",id:"integer",createduser:"integer",updateduser:"integer",descriptive:"string"},u={date:"date",time:"datetime",timeofday:"time",month:"month",quarter:"quarter",year:"year"};const p=class{constructor(i){e(this,i),this.change=t(this,"change",7),this.label="Value",this.inputMode="value",this.handleTextChange=e=>{e.stopPropagation();const t=e.detail,i=Number(t);Number.isNaN(i)||""===t?this.change.emit(t):this.change.emit(i)},this.handleSelectChange=e=>{e.stopPropagation();const t=e.detail;Array.isArray(t)?this.change.emit(t.map((e=>e.value))):this.change.emit(null==t?void 0:t.value)},this.handleBooleanChange=e=>{e.stopPropagation();const t=e.detail;Array.isArray(t)||this.change.emit("true"===(null==t?void 0:t.value))},this.handleDateChange=e=>{e.stopPropagation();const t=e.detail;this.change.emit(t?t.toISOString():null)},this.handleMultiValueChange=e=>{e.stopPropagation();const t=e.detail.split(",").map((e=>e.trim())).filter((e=>e.length>0));this.change.emit(t)},this.handleModeToggle=()=>{"value"===this.inputMode?(this.inputMode="placeholder",this.change.emit("%activeObject%")):(this.inputMode="value",this.change.emit(""))},this.handlePlaceholderPropertyChange=e=>{e.stopPropagation();const t=this.buildPlaceholderValue(e.detail);this.change.emit(t)}}componentWillLoad(){this.isPlaceholder(this.value)&&(this.inputMode="placeholder")}componentWillUpdate(){this.isPlaceholder(this.value)&&"placeholder"!==this.inputMode?this.inputMode="placeholder":this.isPlaceholder(this.value)||"placeholder"!==this.inputMode||(this.inputMode="value")}isPlaceholder(e){return"string"==typeof e&&e.startsWith("%activeObject%")}parsePlaceholderPath(e){return this.isPlaceholder(e)?e.replace(/^%activeObject%\.?/,""):""}buildPlaceholderValue(e){return e?`%activeObject%.${e}`:"%activeObject%"}render(){return this.operator?i(r,null,this.renderModeToggle(),this.renderInputByMode()):null}renderInputByMode(){return"placeholder"===this.inputMode?this.renderPlaceholderInput():this.renderValueInputByType()}renderModeToggle(){if(!this.activeLimetype)return null;const e="placeholder"===this.inputMode;return i("limel-icon-button",{class:"mode-toggle",icon:e?"text":"link",label:e?"Use Value":"Use Placeholder",onClick:this.handleModeToggle})}renderPlaceholderInput(){const e=this.parsePlaceholderPath(this.value);return i("div",{class:"placeholder-input"},i("limebb-property-selector",{platform:this.platform,context:this.context,limetype:this.activeLimetype,label:"Active Object Property",value:e,required:!1,helperText:"Select property from the active object",onChange:this.handlePlaceholderPropertyChange}),this.renderPlaceholderPreview())}renderPlaceholderPreview(){if(this.isPlaceholder(this.value))return i("div",{class:"placeholder-preview"},i("limel-icon",{name:"info",size:"small"}),i("span",null,"Placeholder: ",this.value))}renderValueInputByType(){if(this.operator===s.IN)return this.renderMultiValueInput();const e=this.getProperty();if(!e)return this.renderTextInput();const t=function(e){return"system"===e.type?function(e){const t=e.replace(/^_/,"");return d[t]||"string"}(e.name):e.type}(e);switch(t){case"integer":case"decimal":return this.renderNumberInput(t);case"yesno":return this.renderBooleanInput();case"option":return this.renderOptionInput(e);case"date":case"time":case"timeofday":case"year":case"month":case"quarter":return this.renderDateTimeInput(t);default:return this.renderTextInput()}}renderTextInput(){var e;return i("limel-input-field",{label:this.label,value:(null===(e=this.value)||void 0===e?void 0:e.toString())||"",placeholder:"Enter value",onChange:this.handleTextChange})}renderNumberInput(e){var t;const r="integer"===e?1:.01;return i("limel-input-field",{label:this.label,type:"number",value:(null===(t=this.value)||void 0===t?void 0:t.toString())||"",step:r,onChange:this.handleTextChange})}renderBooleanInput(){const e=[{text:"True",value:"true"},{text:"False",value:"false"}],t=!0===this.value||"true"===this.value?"true":"false",r=e.find((e=>e.value===t));return i("limel-select",{label:this.label,options:e,value:r,onChange:this.handleBooleanChange})}renderOptionInput(e){if(!e.options||0===e.options.length)return this.renderTextInput();const t=e.options.map((e=>({text:e.text||e.key,value:e.key}))),r=t.find((e=>e.value===this.value));return i("limel-select",{label:this.label,options:t,value:r,onChange:this.handleSelectChange})}renderDateTimeInput(e){const t="string"==typeof this.value?new Date(this.value):this.value;return i("limel-date-picker",{label:this.label,value:t,type:u[e]||"date",onChange:this.handleDateChange})}renderMultiValueInput(){const e=Array.isArray(this.value)?this.value.join(", "):this.value||"";return i("limel-input-field",{label:this.label+" (comma-separated)",value:e,placeholder:"e.g., won, lost, tender",onChange:this.handleMultiValueChange})}getProperty(){if(this.limetypes&&this.limetype&&this.propertyPath)return o(this.limetypes,this.limetype,this.propertyPath)}};(function(e,t,i,r){var s,l=arguments.length,o=l<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,r);else for(var n=e.length-1;n>=0;n--)(s=e[n])&&(o=(l<3?s(o):l>3?s(t,i,o):s(t,i))||o);l>3&&o&&Object.defineProperty(t,i,o)})([l()],p.prototype,"limetypes",void 0),p.style=":host{display:flex;gap:0.5rem}:host>*{flex-grow:1}*{box-sizing:border-box}.value-input-container{display:flex;flex-direction:row;align-items:flex-start;gap:0.5rem;width:100%}.mode-toggle{flex-shrink:0;flex-grow:0}.placeholder-input{flex-grow:1;display:flex;flex-direction:column;gap:0.5rem}.placeholder-preview{display:flex;align-items:center;gap:0.5rem;padding:0.5rem;background-color:rgba(var(--color-blue-light), 0.1);border-radius:var(--border-radius-small);font-size:0.875rem;color:rgb(var(--color-blue-default));border-left:3px solid rgb(var(--color-blue-default))}.placeholder-preview limel-icon{flex-shrink:0;color:rgb(var(--color-blue-default))}.placeholder-preview span{font-family:var(--font-monospace);word-break:break-all}";export{h as limebb_lime_query_filter_group,c as limebb_lime_query_filter_not,p as limebb_lime_query_value_input}
@@ -1 +1 @@
1
- import{r as i,c as e,h as t,H as r}from"./p-1556b545.js";import{T as s}from"./p-4838284a.js";import{i as o}from"./p-efa5bcd4.js";import"./p-b748c770.js";const l=class{constructor(t){i(this,t),this.change=e(this,"change",7),this.mode="visual",this.codeValue="",this.limetype="",this.handleLimetypeChange=i=>{i.stopPropagation(),this.limetype=i.detail,this.filter=void 0,this.internalResponseFormat={object:{}},this.emitChange()},this.handleFilterChange=i=>{var e;i.stopPropagation(),this.filter=null!==(e=i.detail)&&void 0!==e?e:void 0,this.emitChange()},this.handleResponseFormatChange=i=>{i.stopPropagation(),this.internalResponseFormat=i.detail,this.emitChange()},this.handleLimitChange=i=>{i.stopPropagation();const e=i.detail;this.limit=e?Number.parseInt(e,10):void 0,this.emitChange()},this.handleOrderByChange=i=>{i.stopPropagation(),this.orderBy=i.detail,this.emitChange()},this.handleDescriptionChange=i=>{i.stopPropagation(),this.description=i.detail||void 0,this.emitChange()},this.handleDescriptionBlur=()=>{if(this.description){const i=this.description.trim();i!==this.description&&(this.description=i||void 0,this.emitChange())}},this.handleChange=i=>{i.stopPropagation();const e=i.detail.id;if("visual"===e)try{const i=JSON.parse(this.codeValue);if(!this.checkVisualModeSupport().visualModeSupported)return;this.limetype=i.limetype||"",this.filter=i.filter,this.internalResponseFormat=i.responseFormat,this.limit=i.limit,this.orderBy=i.orderBy,this.description=i["#description"],this.mode="visual",this.change.emit(i)}catch(i){}else"code"===e&&(this.updateCodeValue(),this.mode="code")},this.handleCodeChange=i=>{i.stopPropagation(),this.codeValue=i.detail;try{const i=JSON.parse(this.codeValue);this.change.emit(i)}catch(i){}}}getButtons(){return[{id:"visual",title:"Visual"},{id:"code",title:"Code"}]}get visualModeEnabled(){var i,e,t;return null!==(t=null===(e=null===(i=this.platform)||void 0===i?void 0:i.isFeatureEnabled)||void 0===e?void 0:e.call(i,"useLimeQueryBuilderGuiMode"))&&void 0!==t&&t}componentWillLoad(){if(!this.visualModeEnabled)return this.mode="code",void this.updateCodeValue();this.value&&(this.limetype=this.value.limetype||"",this.filter=this.value.filter,this.internalResponseFormat=this.value.responseFormat,this.limit=this.value.limit,this.orderBy=this.value.orderBy,this.description=this.value["#description"]),this.updateCodeValue(),this.checkVisualModeSupport().visualModeSupported||(this.mode="code")}render(){return t(r,{key:"72ad0a52788c07a8369ee28535d9a05be92f5144"},this.renderHeader(),this.renderContent())}renderContent(){const i=this.checkVisualModeSupport();return this.visualModeEnabled&&"code"!==this.mode?this.renderVisualMode():this.renderCodeMode(i)}emitChange(){"code"!==this.mode&&this.limetype&&this.change.emit(this.buildLimeQuery())}updateCodeValue(){this.codeValue=this.limetype?JSON.stringify(this.buildLimeQuery(),null,2):JSON.stringify(this.value||{},null,2)}buildLimeQuery(){const i={limetype:this.limetype,responseFormat:this.internalResponseFormat||{object:{_id:null}},filter:this.filter};return this.description&&(i["#description"]=this.description),void 0!==this.limit&&this.limit>0&&(i.limit=this.limit),this.orderBy&&this.orderBy.length>0&&(i.orderBy=this.orderBy),i}checkVisualModeSupport(){if(!this.limetypes)return{valid:!0,visualModeSupported:!0,validationErrors:[],visualModeLimitations:[]};let i;if("code"===this.mode&&this.codeValue)try{i=JSON.parse(this.codeValue)}catch(i){return{valid:!1,visualModeSupported:!1,validationErrors:["Invalid JSON"],visualModeLimitations:[]}}else{if(!this.limetype)return{valid:!0,visualModeSupported:!0,validationErrors:[],visualModeLimitations:[]};i={limetype:this.limetype,responseFormat:this.internalResponseFormat||{object:{_id:null}},filter:this.filter},void 0!==this.limit&&this.limit>0&&(i.limit=this.limit)}return o(i,this.limetypes,this.activeLimetype,this.visualModeEnabled)}renderModeSwitch(i){const e=!i.visualModeSupported,r=this.getButtons().map((i=>Object.assign(Object.assign({},i),{selected:i.id===this.mode})));return t("limel-button-group",{slot:"actions",onChange:this.handleChange,value:r,disabled:e})}renderCodeEditor(i){return[t("limel-code-editor",{value:this.codeValue,language:"json",lineNumbers:!0,fold:!0,lint:!0,onChange:this.handleCodeChange}),!i.valid&&i.validationErrors.length>0&&t("div",{class:"validation-errors"},t("strong",null,"Invalid Lime Query:"),t("ul",null,i.validationErrors.map((i=>t("li",null,i))))),this.visualModeEnabled&&i.valid&&!i.visualModeSupported&&i.visualModeLimitations.length>0&&t("div",{class:"visual-mode-limitations"},t("strong",null,"Cannot switch to visual mode:"),t("ul",null,i.visualModeLimitations.map((i=>t("li",null,i)))))]}renderLimetypeSection(){return t("limebb-limetype-field",{platform:this.platform,context:this.context,label:"Limetype",value:this.limetype,required:!0,fieldName:"limetype",onChange:this.handleLimetypeChange})}renderDescriptionSection(){if(this.limetype)return t("section",{class:"description"},t("limel-input-field",{label:"Description",type:"textarea",value:this.description||"",placeholder:"Describe what data this query retrieves...",helperText:"Optional: Help AI agents and humans understand the query purpose",onChange:this.handleDescriptionChange,onBlur:this.handleDescriptionBlur}))}renderResponseFormatSection(){if(this.limetype)return t("section",{class:"response-format"},t("limebb-lime-query-response-format-editor",{platform:this.platform,context:this.context,limetype:this.limetype,value:this.internalResponseFormat,onChange:this.handleResponseFormatChange}))}renderFilterSection(){if(this.limetype)return t("section",{class:"filter"},t("limel-header",{class:"is-narrow",heading:"Filter Conditions",icon:"-lime-filter"}),t("limebb-lime-query-filter-builder",{platform:this.platform,context:this.context,limetype:this.limetype,activeLimetype:this.activeLimetype,expression:this.filter,onExpressionChange:this.handleFilterChange}))}renderQueryOptionsSection(){var i;if(this.limetype)return t("section",{class:"query-options"},t("limel-header",{class:"is-narrow",heading:"Query Options",icon:"ask_question"}),t("div",{class:"query-options-controls"},t("limel-input-field",{label:"Limit",type:"number",value:(null===(i=this.limit)||void 0===i?void 0:i.toString())||"",placeholder:"No limit",helperText:"Maximum number of results",onChange:this.handleLimitChange}),t("limebb-lime-query-order-by-editor",{platform:this.platform,context:this.context,limetype:this.limetype,value:this.orderBy,onChange:this.handleOrderByChange})))}renderVisualMode(){return t("div",{class:"visual-mode"},this.renderLimetypeSection(),this.renderDescriptionSection(),this.renderResponseFormatSection(),this.renderFilterSection(),this.renderQueryOptionsSection())}renderHeader(){const i=this.checkVisualModeSupport();return t("limel-header",{heading:this.label},this.renderModeControls(i))}renderModeControls(i){if(this.visualModeEnabled)return this.renderModeSwitch(i)}renderCodeMode(i){return t("div",{class:"code-mode"},this.renderCodeEditor(i))}};(function(i,e,t,r){var s,o=arguments.length,l=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,t):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(i,e,t,r);else for(var d=i.length-1;d>=0;d--)(s=i[d])&&(l=(o<3?s(l):o>3?s(e,t,l):s(e,t))||l);o>3&&l&&Object.defineProperty(e,t,l)})([s()],l.prototype,"limetypes",void 0),l.style="*,*:before,*:after{box-sizing:border-box}:host(limebb-lime-query-builder){--header-background-color:rgb(var(--contrast-500));--limebb-lime-query-builder-background-color:rgb(var(--contrast-100));--limebb-lime-query-builder-border-radius:0.75rem;--limebb-lime-query-builder-visual-mode-padding:1rem;--limebb-lime-query-builder-group-color:rgb(var(--color-sky-lighter));box-sizing:border-box;width:calc(100% - 1.5rem);margin:0.75rem auto;display:flex;flex-direction:column;border-radius:var(--limebb-lime-query-builder-border-radius);background-color:var(--limebb-lime-query-builder-background-color);box-shadow:var(--shadow-inflated-16)}.visual-mode{display:flex;flex-direction:column;gap:1rem;padding:var(--limebb-lime-query-builder-visual-mode-padding);border:1px solid var(--header-background-color);border-radius:0 0 var(--limebb-lime-query-builder-border-radius) var(--limebb-lime-query-builder-border-radius)}.code-mode{--code-editor-max-height:70vh;display:flex;flex-direction:column;gap:1rem}.code-mode .validation-errors{padding:0.75rem 1rem;color:rgb(var(--color-red-default));background-color:rgb(var(--color-red-lighter));border-left:0.25rem solid rgb(var(--color-red-default));border-radius:0.25rem;font-size:0.875rem}.code-mode .validation-errors strong{display:block;margin-bottom:0.5rem;font-weight:600}.code-mode .validation-errors ul{margin:0;padding-left:1.5rem}.code-mode .validation-errors li{margin:0.25rem 0}.code-mode .visual-mode-limitations{padding:0.75rem 1rem;color:rgb(var(--color-blue-dark));background-color:rgb(var(--color-blue-lighter));border-left:0.25rem solid rgb(var(--color-blue-default));border-radius:0.25rem;font-size:0.875rem}.code-mode .visual-mode-limitations strong{display:block;margin-bottom:0.5rem;font-weight:600}.code-mode .visual-mode-limitations ul{margin:0;padding-left:1.5rem}.code-mode .visual-mode-limitations li{margin:0.25rem 0}section.description,section.filter,section.query-options{display:flex;flex-direction:column;gap:1rem}section h4{margin:0;font-size:1.125rem;font-weight:600;color:rgb(var(--contrast-1000))}limel-header.is-narrow{--header-top-right-left-border-radius:0;width:calc(100% + var(--limebb-lime-query-builder-visual-mode-padding) * 2);margin-left:calc(var(--limebb-lime-query-builder-visual-mode-padding) * -1)}.query-options-controls{display:flex;flex-direction:column;gap:1rem}";export{l as limebb_lime_query_builder}
1
+ import{r as i,c as e,h as t,H as r}from"./p-1556b545.js";import{T as s}from"./p-4838284a.js";import{i as o}from"./p-11aa4103.js";import"./p-b02c99d5.js";const l=class{constructor(t){i(this,t),this.change=e(this,"change",7),this.mode="visual",this.codeValue="",this.limetype="",this.handleLimetypeChange=i=>{i.stopPropagation(),this.limetype=i.detail,this.filter=void 0,this.internalResponseFormat={object:{}},this.emitChange()},this.handleFilterChange=i=>{var e;i.stopPropagation(),this.filter=null!==(e=i.detail)&&void 0!==e?e:void 0,this.emitChange()},this.handleResponseFormatChange=i=>{i.stopPropagation(),this.internalResponseFormat=i.detail,this.emitChange()},this.handleLimitChange=i=>{i.stopPropagation();const e=i.detail;this.limit=e?Number.parseInt(e,10):void 0,this.emitChange()},this.handleOrderByChange=i=>{i.stopPropagation(),this.orderBy=i.detail,this.emitChange()},this.handleDescriptionChange=i=>{i.stopPropagation(),this.description=i.detail||void 0,this.emitChange()},this.handleDescriptionBlur=()=>{if(this.description){const i=this.description.trim();i!==this.description&&(this.description=i||void 0,this.emitChange())}},this.handleChange=i=>{i.stopPropagation();const e=i.detail.id;if("visual"===e)try{const i=JSON.parse(this.codeValue);if(!this.checkVisualModeSupport().visualModeSupported)return;this.limetype=i.limetype||"",this.filter=i.filter,this.internalResponseFormat=i.responseFormat,this.limit=i.limit,this.orderBy=i.orderBy,this.description=i["#description"],this.mode="visual",this.change.emit(i)}catch(i){}else"code"===e&&(this.updateCodeValue(),this.mode="code")},this.handleCodeChange=i=>{i.stopPropagation(),this.codeValue=i.detail;try{const i=JSON.parse(this.codeValue);this.change.emit(i)}catch(i){}}}getButtons(){return[{id:"visual",title:"Visual"},{id:"code",title:"Code"}]}get visualModeEnabled(){var i,e,t;return null!==(t=null===(e=null===(i=this.platform)||void 0===i?void 0:i.isFeatureEnabled)||void 0===e?void 0:e.call(i,"useLimeQueryBuilderGuiMode"))&&void 0!==t&&t}componentWillLoad(){if(!this.visualModeEnabled)return this.mode="code",void this.updateCodeValue();this.value&&(this.limetype=this.value.limetype||"",this.filter=this.value.filter,this.internalResponseFormat=this.value.responseFormat,this.limit=this.value.limit,this.orderBy=this.value.orderBy,this.description=this.value["#description"]),this.updateCodeValue(),this.checkVisualModeSupport().visualModeSupported||(this.mode="code")}render(){return t(r,{key:"72ad0a52788c07a8369ee28535d9a05be92f5144"},this.renderHeader(),this.renderContent())}renderContent(){const i=this.checkVisualModeSupport();return this.visualModeEnabled&&"code"!==this.mode?this.renderVisualMode():this.renderCodeMode(i)}emitChange(){"code"!==this.mode&&this.limetype&&this.change.emit(this.buildLimeQuery())}updateCodeValue(){this.codeValue=this.limetype?JSON.stringify(this.buildLimeQuery(),null,2):JSON.stringify(this.value||{},null,2)}buildLimeQuery(){const i={limetype:this.limetype,responseFormat:this.internalResponseFormat||{object:{_id:null}},filter:this.filter};return this.description&&(i["#description"]=this.description),void 0!==this.limit&&this.limit>0&&(i.limit=this.limit),this.orderBy&&this.orderBy.length>0&&(i.orderBy=this.orderBy),i}checkVisualModeSupport(){if(!this.limetypes)return{valid:!0,visualModeSupported:!0,validationErrors:[],visualModeLimitations:[]};let i;if("code"===this.mode&&this.codeValue)try{i=JSON.parse(this.codeValue)}catch(i){return{valid:!1,visualModeSupported:!1,validationErrors:["Invalid JSON"],visualModeLimitations:[]}}else{if(!this.limetype)return{valid:!0,visualModeSupported:!0,validationErrors:[],visualModeLimitations:[]};i={limetype:this.limetype,responseFormat:this.internalResponseFormat||{object:{_id:null}},filter:this.filter},void 0!==this.limit&&this.limit>0&&(i.limit=this.limit)}return o(i,this.limetypes,this.activeLimetype,this.visualModeEnabled)}renderModeSwitch(i){const e=!i.visualModeSupported,r=this.getButtons().map((i=>Object.assign(Object.assign({},i),{selected:i.id===this.mode})));return t("limel-button-group",{slot:"actions",onChange:this.handleChange,value:r,disabled:e})}renderCodeEditor(i){return[t("limel-code-editor",{value:this.codeValue,language:"json",lineNumbers:!0,fold:!0,lint:!0,onChange:this.handleCodeChange}),!i.valid&&i.validationErrors.length>0&&t("div",{class:"validation-errors"},t("strong",null,"Invalid Lime Query:"),t("ul",null,i.validationErrors.map((i=>t("li",null,i))))),this.visualModeEnabled&&i.valid&&!i.visualModeSupported&&i.visualModeLimitations.length>0&&t("div",{class:"visual-mode-limitations"},t("strong",null,"Cannot switch to visual mode:"),t("ul",null,i.visualModeLimitations.map((i=>t("li",null,i)))))]}renderLimetypeSection(){return t("limebb-limetype-field",{platform:this.platform,context:this.context,label:"Limetype",value:this.limetype,required:!0,fieldName:"limetype",onChange:this.handleLimetypeChange})}renderDescriptionSection(){if(this.limetype)return t("section",{class:"description"},t("limel-input-field",{label:"Description",type:"textarea",value:this.description||"",placeholder:"Describe what data this query retrieves...",helperText:"Optional: Help AI agents and humans understand the query purpose",onChange:this.handleDescriptionChange,onBlur:this.handleDescriptionBlur}))}renderResponseFormatSection(){if(this.limetype)return t("section",{class:"response-format"},t("limebb-lime-query-response-format-editor",{platform:this.platform,context:this.context,limetype:this.limetype,value:this.internalResponseFormat,onChange:this.handleResponseFormatChange}))}renderFilterSection(){if(this.limetype)return t("section",{class:"filter"},t("limel-header",{class:"is-narrow",heading:"Filter Conditions",icon:"-lime-filter"}),t("limebb-lime-query-filter-builder",{platform:this.platform,context:this.context,limetype:this.limetype,activeLimetype:this.activeLimetype,expression:this.filter,onExpressionChange:this.handleFilterChange}))}renderQueryOptionsSection(){var i;if(this.limetype)return t("section",{class:"query-options"},t("limel-header",{class:"is-narrow",heading:"Query Options",icon:"ask_question"}),t("div",{class:"query-options-controls"},t("limel-input-field",{label:"Limit",type:"number",value:(null===(i=this.limit)||void 0===i?void 0:i.toString())||"",placeholder:"No limit",helperText:"Maximum number of results",onChange:this.handleLimitChange}),t("limebb-lime-query-order-by-editor",{platform:this.platform,context:this.context,limetype:this.limetype,value:this.orderBy,onChange:this.handleOrderByChange})))}renderVisualMode(){return t("div",{class:"visual-mode"},this.renderLimetypeSection(),this.renderDescriptionSection(),this.renderResponseFormatSection(),this.renderFilterSection(),this.renderQueryOptionsSection())}renderHeader(){const i=this.checkVisualModeSupport();return t("limel-header",{heading:this.label},this.renderModeControls(i))}renderModeControls(i){if(this.visualModeEnabled)return this.renderModeSwitch(i)}renderCodeMode(i){return t("div",{class:"code-mode"},this.renderCodeEditor(i))}};(function(i,e,t,r){var s,o=arguments.length,l=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,t):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(i,e,t,r);else for(var d=i.length-1;d>=0;d--)(s=i[d])&&(l=(o<3?s(l):o>3?s(e,t,l):s(e,t))||l);o>3&&l&&Object.defineProperty(e,t,l)})([s()],l.prototype,"limetypes",void 0),l.style="*,*:before,*:after{box-sizing:border-box}:host(limebb-lime-query-builder){--header-background-color:rgb(var(--contrast-500));--limebb-lime-query-builder-background-color:rgb(var(--contrast-100));--limebb-lime-query-builder-border-radius:0.75rem;--limebb-lime-query-builder-visual-mode-padding:1rem;--limebb-lime-query-builder-group-color:rgb(var(--color-sky-lighter));box-sizing:border-box;width:calc(100% - 1.5rem);margin:0.75rem auto;display:flex;flex-direction:column;border-radius:var(--limebb-lime-query-builder-border-radius);background-color:var(--limebb-lime-query-builder-background-color);box-shadow:var(--shadow-inflated-16)}.visual-mode{display:flex;flex-direction:column;gap:1rem;padding:var(--limebb-lime-query-builder-visual-mode-padding);border:1px solid var(--header-background-color);border-radius:0 0 var(--limebb-lime-query-builder-border-radius) var(--limebb-lime-query-builder-border-radius)}.code-mode{--code-editor-max-height:70vh;display:flex;flex-direction:column;gap:1rem}.code-mode .validation-errors{padding:0.75rem 1rem;color:rgb(var(--color-red-default));background-color:rgb(var(--color-red-lighter));border-left:0.25rem solid rgb(var(--color-red-default));border-radius:0.25rem;font-size:0.875rem}.code-mode .validation-errors strong{display:block;margin-bottom:0.5rem;font-weight:600}.code-mode .validation-errors ul{margin:0;padding-left:1.5rem}.code-mode .validation-errors li{margin:0.25rem 0}.code-mode .visual-mode-limitations{padding:0.75rem 1rem;color:rgb(var(--color-blue-dark));background-color:rgb(var(--color-blue-lighter));border-left:0.25rem solid rgb(var(--color-blue-default));border-radius:0.25rem;font-size:0.875rem}.code-mode .visual-mode-limitations strong{display:block;margin-bottom:0.5rem;font-weight:600}.code-mode .visual-mode-limitations ul{margin:0;padding-left:1.5rem}.code-mode .visual-mode-limitations li{margin:0.25rem 0}section.description,section.filter,section.query-options{display:flex;flex-direction:column;gap:1rem}section h4{margin:0;font-size:1.125rem;font-weight:600;color:rgb(var(--contrast-1000))}limel-header.is-narrow{--header-top-right-left-border-radius:0;width:calc(100% + var(--limebb-lime-query-builder-visual-mode-padding) * 2);margin-left:calc(var(--limebb-lime-query-builder-visual-mode-padding) * -1)}.query-options-controls{display:flex;flex-direction:column;gap:1rem}";export{l as limebb_lime_query_builder}
@@ -24,6 +24,20 @@ export declare function validatePlaceholder(value: any, activeLimetype: string |
24
24
  valid: boolean;
25
25
  error?: string;
26
26
  };
27
+ /**
28
+ * Validates a filter expression key (property path).
29
+ * Supports both regular property paths and placeholders.
30
+ *
31
+ * @param key - Property path to validate (e.g., "name", "company.name", "%activeObject%.name")
32
+ * @param limetypes - All limetype definitions
33
+ * @param limetype - The limetype being filtered
34
+ * @param activeLimetype - Active limetype for placeholder resolution
35
+ * @returns Validation result with error message if invalid
36
+ */
37
+ export declare function validateFilterKey(key: string, limetypes: Record<string, LimeType>, limetype: string, activeLimetype?: string): {
38
+ valid: boolean;
39
+ error?: string;
40
+ };
27
41
  /**
28
42
  * Validate a response format against limetype schemas
29
43
  * Throws errors for invalid property references
@@ -14,4 +14,16 @@ export declare function getNormalizedProperties(limetype: LimeType): Record<stri
14
14
  * @param path
15
15
  */
16
16
  export declare function getPropertyFromPath(limetypes: Record<string, LimeType>, limetype: string, path: string): LimeProperty | undefined;
17
+ /**
18
+ * Validates a property path to ensure no intermediate properties are hasMany or hasAndBelongsToMany relations.
19
+ * These relation types cannot be traversed in filter expressions.
20
+ * @param limetypes All limetype definitions
21
+ * @param limetype The starting limetype
22
+ * @param path The property path to validate (e.g., "company.name")
23
+ * @returns The property at the end of the path if valid, or undefined with error if invalid
24
+ */
25
+ export declare function validatePropertyPath(limetypes: Record<string, LimeType>, limetype: string, path: string): {
26
+ property: LimeProperty | undefined;
27
+ error?: string;
28
+ };
17
29
  //# sourceMappingURL=property-resolution.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@limetech/lime-crm-building-blocks",
3
- "version": "1.105.1",
3
+ "version": "1.105.2",
4
4
  "description": "A home for shared components meant for use with Lime CRM",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@limetech/eslint-config": "^3.0.1",
38
- "@limetech/lime-elements": "^38.31.0",
38
+ "@limetech/lime-elements": "^38.31.1",
39
39
  "@limetech/lime-web-components": "^6.5.0",
40
40
  "@limetech/lime-web-components-testing": "^1.0.0",
41
41
  "@lundalogik/lime-icons8": "^2.37.0",
@@ -1 +0,0 @@
1
- function e(e){if(!(null==e?void 0:e.properties))return{};const t=Object.assign({},e.properties),r={id:"_id",timestamp:"_timestamp",descriptive:"_descriptive",createduser:"_createduser",createdtime:"_createdtime",updateduser:"_updateduser"};for(const[e,i]of Object.entries(r)){const r=t[e];r&&(t[i]=r,delete t[e])}return t}function t(t,r,i){if(!i||!r||!t)return;const n=i.split(".");let c,s=t[r];for(const t of n){if(!s)return;if(c=e(s)[t],!c)return;c.relation&&(s=c.relation.getLimetype())}return c}export{e as a,t as g}
@@ -1 +0,0 @@
1
- import{Z as t}from"./p-4838284a.js";import{g as r,a as o}from"./p-b748c770.js";const e=new Set(["$yesterday","$now","$today","$tomorrow","$this_week","$this_month","$this_quarter","$this_year"]),n=/^\$(previous|next)_(day|week|month|quarter|year)\(\d+\)$/,i=/^\$me(\.\w+)*$/;function s(t,r,o=!0){const e=Object.keys(t),n=[];if(o){const t=e.filter((t=>t.startsWith("#")&&"#description"!==t));t.length>0&&n.push(`Property '${r}' contains # properties not supported in visual mode: ${t.join(", ")}`)}return{keys:e.filter((t=>"_alias"!==t&&!t.startsWith("#"))),visualModeLimitations:n}}function u(t,r,o,e,n,i=!0){if(""===t){if(i&&null!==r)throw new Error("Empty property name must have null value");return[]}const u=o[t];if(!u)throw new Error(`Property '${t}' does not exist on limetype '${n}'`);return u.relation?function(t,r,o,e,n=!0){if(null===r)return[];if("object"!=typeof r)throw new TypeError(`Relation property '${t}' must be null or an object`);const i=r,{keys:u,visualModeLimitations:c}=s(i,t,n);if(0===u.length)return c;const l=e.relation.getLimetype();if(!l)throw new Error(`Could not determine related limetype for property '${t}'`);const f={};for(const t of u)f[t]=i[t];const p=a(f,o,l.name,n);return[...c,...p]}(t,r,e,u,i):function(t,r,o=!0){if(null===r)return[];if("object"==typeof r){const{keys:e,visualModeLimitations:n}=s(r,t,o);if(0===e.length)return n;throw new Error(`Non-relation property '${t}' cannot have nested properties other than _alias or # properties (got: ${e.join(", ")})`)}throw new Error(`Non-relation property '${t}' must be null or an object (got ${typeof r})`)}(t,r,i)}function a(t,r,e,n=!0){const i=r[e];if(!i)throw new Error(`Unknown limetype: ${e}`);const s=o(i),a=[];for(const[o,i]of Object.entries(t)){if(o.startsWith("#"))continue;const t=u(o,i,s,r,e,n);a.push(...t)}return a}function c(o,s,u,a=!0){o&&("key"in o?function(o,s,u){if(!Object.values(t).includes(o.op))throw new Error(`Unsupported filter operator: ${o.op}`);const a=function(t,o,s){if(function(t){return"string"==typeof t&&(e.has(t)||n.test(t)||i.test(t))}(t))return{valid:!0};if("string"!=typeof t||!t.startsWith("%activeObject%"))return{valid:!0};if(!o)return{valid:!0};const u=t.replace(/^%activeObject%\.?/,"");if(!u)return{valid:!0};try{return r(s,o,u)?{valid:!0}:{valid:!1,error:`Property path '${u}' does not exist on limetype '${o}'`}}catch(t){return{valid:!1,error:`Invalid placeholder path: ${t.message}`}}}(o.exp,s,u);if(!a.valid)throw new Error(`Invalid placeholder in filter '${o.key}': ${a.error}`)}(o,s,u):"exp"in o&&function(r,o,e,n){if(r.op!==t.AND&&r.op!==t.OR&&r.op!==t.NOT)throw new Error(`Unsupported group operator: ${r.op}`);if(r.op===t.NOT)c(r.exp,o,e,n);else if(r.op===t.AND||r.op===t.OR){const t=r.exp;for(const r of t)c(r,o,e,n)}}(o,s,u,a))}function l(t,o,e,n){const i=[],s=function(t,r){return"object"!=typeof t||null===t?`orderBy[${r}] must be an object`:null}(t,o);if(s)return[s];const u=Object.keys(t),a=function(t,r){return 0===t.length?`orderBy[${r}] must have a property path`:t.length>1?`orderBy[${r}] must have exactly one property, got ${t.length}`:null}(u,o);if(a)return[a];const c=u[0],l=function(t,r){return"ASC"!==t&&"DESC"!==t?`orderBy[${r}]: direction must be 'ASC' or 'DESC', got '${t}'`:null}(t[c],o);l&&i.push(l);const f=function(t,o,e,n){if(!t||""===t)return null;return r(o,e,t)?null:`orderBy[${n}]: property path '${t}' does not exist on limetype '${e}'`}(c,e,n,o);return f&&i.push(f),i}function f(t,r,o,e){const n=[],i=[];try{const n=function(t,r,o,e=!0){const n=[];if(e&&t.aggregates&&n.push("responseFormat.aggregates is not yet supported in visual mode"),t.object){const i=a(t.object,r,o,e);n.push(...i)}return n}(t,r,o,e);i.push(...n)}catch(t){n.push(`Invalid responseFormat: ${t.message}`)}return{errors:n,limitations:i}}function p(t,r,o,e=!0){if(!t)return{valid:!0,visualModeSupported:!0,validationErrors:[],visualModeLimitations:[]};const n=[],i=[];if(t.limetype&&!r[t.limetype]&&n.push(`Unknown limetype: ${t.limetype}`),void 0===t.offset||t.orderBy||n.push("offset requires orderBy to be specified"),t.orderBy){const o=function(t,r,o){const e=[];if(!Array.isArray(t))return e.push("orderBy must be an array"),e;if(!o||!r[o])return e;for(const[n,i]of t.entries()){const t=l(i,n,r,o);e.push(...t)}return e}(t.orderBy,r,t.limetype);n.push(...o)}if(e&&void 0!==t.offset&&i.push("offset is not yet supported in visual mode"),t.filter){const i=function(t,r,o,e){const n=[];try{c(t,r,o,e)}catch(t){n.push(`Invalid filter: ${t.message}`)}return n}(t.filter,o,r,e);n.push(...i)}if(t.responseFormat){const{errors:o,limitations:s}=f(t.responseFormat,r,t.limetype,e);n.push(...o),i.push(...s)}return{valid:0===n.length,visualModeSupported:0===i.length,validationErrors:n,visualModeLimitations:i}}function d(t,r,o,e=!0){const n=[],i=[];if(!r[o])return n.push(`Unknown limetype: ${o}`),{valid:!1,visualModeSupported:!1,validationErrors:n,visualModeLimitations:i};const{errors:s,limitations:u}=f(t,r,o,e);return n.push(...s),i.push(...u),{valid:0===n.length,visualModeSupported:0===i.length,validationErrors:n,visualModeLimitations:i}}export{p as i,d as v}