@limetech/lime-crm-building-blocks 1.99.0 → 1.100.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.
- package/CHANGELOG.md +7 -0
- package/dist/cjs/lime-crm-building-blocks.cjs.js +1 -1
- package/dist/cjs/limebb-lime-query-builder.cjs.entry.js +7 -38
- package/dist/cjs/{limebb-limetype-field_2.cjs.entry.js → limebb-lime-query-filter-builder_3.cjs.entry.js} +71 -0
- package/dist/cjs/{limebb-lime-query-filter-group_4.cjs.entry.js → limebb-lime-query-filter-comparison_5.cjs.entry.js} +102 -0
- package/dist/cjs/limebb-lime-query-filter-expression.cjs.entry.js +45 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-builder.css +5 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-builder.js +225 -0
- package/dist/collection/components/lime-query-builder/lime-query-builder.js +9 -39
- package/dist/components/lime-query-filter-builder.js +129 -0
- package/dist/components/limebb-lime-query-builder.js +15 -40
- package/dist/components/limebb-lime-query-filter-builder.d.ts +11 -0
- package/dist/components/limebb-lime-query-filter-builder.js +6 -0
- package/dist/esm/lime-crm-building-blocks.js +1 -1
- package/dist/esm/limebb-lime-query-builder.entry.js +8 -39
- package/dist/esm/{limebb-limetype-field_2.entry.js → limebb-lime-query-filter-builder_3.entry.js} +72 -2
- package/dist/esm/{limebb-lime-query-filter-group_4.entry.js → limebb-lime-query-filter-comparison_5.entry.js} +102 -1
- package/dist/esm/limebb-lime-query-filter-expression.entry.js +41 -0
- package/dist/esm/loader.js +1 -1
- package/dist/lime-crm-building-blocks/lime-crm-building-blocks.esm.js +1 -1
- package/dist/lime-crm-building-blocks/p-24aeb928.entry.js +1 -0
- package/dist/lime-crm-building-blocks/p-422f6d51.entry.js +1 -0
- package/dist/lime-crm-building-blocks/p-6d119dab.entry.js +1 -0
- package/dist/lime-crm-building-blocks/p-b198194a.entry.js +1 -0
- package/dist/types/components/lime-query-builder/expressions/lime-query-filter-builder.d.ts +50 -0
- package/dist/types/components/lime-query-builder/lime-query-builder.d.ts +1 -6
- package/dist/types/components.d.ts +116 -0
- package/package.json +1 -1
- package/dist/cjs/limebb-lime-query-filter-comparison_2.cjs.entry.js +0 -147
- package/dist/esm/limebb-lime-query-filter-comparison_2.entry.js +0 -142
- package/dist/lime-crm-building-blocks/p-03accd53.entry.js +0 -1
- package/dist/lime-crm-building-blocks/p-4715210d.entry.js +0 -1
- package/dist/lime-crm-building-blocks/p-5f7644b5.entry.js +0 -1
- package/dist/lime-crm-building-blocks/p-aa646df7.entry.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e,c as t,h as i}from"./p-1556b545.js";import{T as r,Z as o}from"./p-4838284a.js";import{g as n,a as s}from"./p-e0ab1554.js";const l=[{value:"=",label:"Equals",icon:"equals"},{value:"!=",label:"Not Equals",icon:"not-equal"},{value:">",label:"Greater Than",icon:"greater-than",applicableTypes:["integer","decimal","date","time"]},{value:">=",label:"Greater or Equal",icon:"greater-or-equal",applicableTypes:["integer","decimal","date","time"]},{value:"<",label:"Less Than",icon:"less-than",applicableTypes:["integer","decimal","date","time"]},{value:"<=",label:"Less or Equal",icon:"less-or-equal",applicableTypes:["integer","decimal","date","time"]},{value:"IN",label:"In List",icon:"list"},{value:"?",label:"Contains",icon:"-lime-filter-contain",applicableTypes:["string","text"]},{value:"=?",label:"Begins With",icon:"-lime-filter-begin",applicableTypes:["string","text"]},{value:"=$",label:"Ends With",icon:"-lime-filter-end",applicableTypes:["string","text"]}];function a(e){return e?"key"in e?function(e){if(!("op"in e)||!("exp"in e))throw new Error("Invalid filter: comparison must have key, op, and exp properties");if(!l.map((e=>e.value)).includes(e.op))throw new Error(`Unsupported filter operator: ${e.op}`);const t=new Set(["key","op","exp","type"]),i=Object.keys(e).filter((e=>!t.has(e)));if(i.length>0)throw new Error(`Unexpected properties in filter comparison: ${i.join(", ")}`);return{filter_type:"comparison",property:e.key,operator:e.op,value:e.exp}}(e):function(e){if(!("op"in e))throw new Error("Invalid filter: filter group must have op property");if(!("exp"in e))throw new Error("Invalid filter: filter group must have exp property");const t=new Set(["op","exp"]),i=Object.keys(e).filter((e=>!t.has(e)));if(i.length>0)throw new Error(`Unexpected properties in filter group: ${i.join(", ")}`);if("!"===e.op){if(Array.isArray(e.exp))throw new TypeError("Invalid NOT filter: exp should be a single expression, not an array");return{filter_type:"NOT",expression:a(e.exp)}}if("AND"===e.op){if(!Array.isArray(e.exp))throw new TypeError("Invalid AND filter: exp must be an array");return{filter_type:"AND",expressions:e.exp.map(a)}}if("OR"===e.op){if(!Array.isArray(e.exp))throw new TypeError("Invalid OR filter: exp must be an array");return{filter_type:"OR",expressions:e.exp.map(a)}}throw new Error(`Unsupported filter operator: ${e.op}`)}(e):{filter_type:"AND",expressions:[]}}const d=new Set(["$yesterday","$now","$today","$tomorrow","$this_week","$this_month","$this_quarter","$this_year"]),c=/^\$(previous|next)_(day|week|month|quarter|year)\(\d+\)$/,u=/^\$me(\.\w+)*$/;function p(e,t,i=!0){const r=Object.keys(e),o=[];if(i){const e=r.filter((e=>e.startsWith("#")&&"#description"!==e));e.length>0&&o.push(`Property '${t}' contains # properties not supported in GUI: ${e.join(", ")}`)}return{keys:r.filter((e=>"_alias"!==e&&!e.startsWith("#"))),guiLimitations:o}}function h(e,t,i,r,o,n=!0){if(""===e){if(n&&null!==t)throw new Error("Empty property name must have null value");return[]}const s=i[e];if(!s)throw new Error(`Property '${e}' does not exist on limetype '${o}'`);return s.relation?function(e,t,i,r,o=!0){if(null===t)return[];if("object"!=typeof t)throw new TypeError(`Relation property '${e}' must be null or an object`);const n=t,{keys:s,guiLimitations:l}=p(n,e,o);if(0===s.length)return l;const a=r.relation.getLimetype();if(!a)throw new Error(`Could not determine related limetype for property '${e}'`);const d={};for(const e of s)d[e]=n[e];const c=m(d,i,a.name,o);return[...l,...c]}(e,t,r,s,n):function(e,t,i=!0){if(null===t)return[];if("object"==typeof t){const{keys:r,guiLimitations:o}=p(t,e,i);if(0===r.length)return o;throw new Error(`Non-relation property '${e}' cannot have nested properties other than _alias or # properties (got: ${r.join(", ")})`)}throw new Error(`Non-relation property '${e}' must be null or an object (got ${typeof t})`)}(e,t,n)}function m(e,t,i,r=!0){const o=t[i];if(!o)throw new Error(`Unknown limetype: ${i}`);const s=n(o),l=[];for(const[o,n]of Object.entries(e)){if(o.startsWith("#"))continue;const e=h(o,n,s,t,i,r);l.push(...e)}return l}function f(e,t,i,r=!0){if(e)if("key"in e){const r=function(e,t,i){if(function(e){return"string"==typeof e&&(d.has(e)||c.test(e)||u.test(e))}(e))return{valid:!0};if("string"!=typeof e||!e.startsWith("%activeObject%"))return{valid:!0};if(!t)return{valid:!0};const r=e.replace(/^%activeObject%\.?/,"");if(!r)return{valid:!0};try{return s(i,t,r)?{valid:!0}:{valid:!1,error:`Property path '${r}' does not exist on limetype '${t}'`}}catch(e){return{valid:!1,error:`Invalid placeholder path: ${e.message}`}}}(e.exp,t,i);if(!r.valid)throw new Error(`Invalid placeholder in filter '${e.key}': ${r.error}`)}else if("exp"in e)if("!"===e.op)f(e.exp,t,i,r);else if("AND"===e.op||"OR"===e.op){const o=e.exp;for(const e of o)f(e,t,i,r)}}const y=class{constructor(i){e(this,i),this.change=t(this,"change",7),this.mode="gui",this.codeValue="",this.limetype="",this.filter={op:o.AND,exp:[]},this.handleLimetypeChange=e=>{e.stopPropagation(),this.limetype=e.detail,this.filter={op:o.AND,exp:[]},this.internalResponseFormat={object:{_id:null}},this.emitChange()},this.handleFilterChange=e=>{e.stopPropagation();const t=e.detail;this.filter=void 0===t?{op:o.AND,exp:[]}:t,this.emitChange()},this.handleResponseFormatChange=e=>{e.stopPropagation(),this.internalResponseFormat=e.detail,this.emitChange()},this.handleLimitChange=e=>{e.stopPropagation();const t=e.detail;this.limit=t?Number.parseInt(t,10):void 0,this.emitChange()},this.switchToGui=()=>{try{const e=JSON.parse(this.codeValue);if(!this.checkGuiSupport().guiSupported)return;this.limetype=e.limetype||"",this.filter=this.normalizeFilter(e.filter),this.internalResponseFormat=e.responseFormat,this.limit=e.limit,this.mode="gui",this.change.emit(e)}catch(e){}},this.switchToCode=()=>{this.updateCodeValue(),this.mode="code"},this.handleCodeChange=e=>{e.stopPropagation(),this.codeValue=e.detail;try{const e=JSON.parse(this.codeValue);this.change.emit(e)}catch(e){}}}get guiModeEnabled(){var e,t,i;return null!==(i=null===(t=null===(e=this.platform)||void 0===e?void 0:e.isFeatureEnabled)||void 0===t?void 0:t.call(e,"useLimeQueryBuilderGuiMode"))&&void 0!==i&&i}componentWillLoad(){if(!this.guiModeEnabled)return this.mode="code",void this.updateCodeValue();this.value&&(this.limetype=this.value.limetype||"",this.filter=this.normalizeFilter(this.value.filter),this.internalResponseFormat=this.value.responseFormat,this.limit=this.value.limit),this.updateCodeValue(),this.checkGuiSupport().guiSupported||(this.mode="code")}render(){const e=this.checkGuiSupport(),t=!this.guiModeEnabled||"code"===this.mode;return i("div",{key:"5ff70a352e3e57ff4c51d44627bd4b5ed367fff4",class:"lime-query-builder"},this.renderLabel(),this.renderModeControls(e),t?this.renderCodeMode(e):this.renderGuiMode())}normalizeFilter(e){return e?"op"in e&&e.op===o.AND?e:{op:o.AND,exp:[e]}:{op:o.AND,exp:[]}}emitChange(){if("code"===this.mode)return;if(!this.limetype)return;const e={limetype:this.limetype,responseFormat:this.internalResponseFormat||{object:{_id:null}},filter:this.filter};void 0!==this.limit&&this.limit>0&&(e.limit=this.limit),this.change.emit(e)}updateCodeValue(){if(!this.limetype)return void(this.codeValue=JSON.stringify(this.value||{},null,2));const e={limetype:this.limetype,responseFormat:this.internalResponseFormat||{object:{_id:null}},filter:this.filter};void 0!==this.limit&&this.limit>0&&(e.limit=this.limit),this.codeValue=JSON.stringify(e,null,2)}checkGuiSupport(){if(!this.limetypes)return{valid:!0,guiSupported:!0,validationErrors:[],guiLimitations:[]};let e;if("code"===this.mode&&this.codeValue)try{e=JSON.parse(this.codeValue)}catch(e){return{valid:!1,guiSupported:!1,validationErrors:["Invalid JSON"],guiLimitations:[]}}else{if(!this.limetype)return{valid:!0,guiSupported:!0,validationErrors:[],guiLimitations:[]};e={limetype:this.limetype,responseFormat:this.internalResponseFormat||{object:{_id:null}},filter:this.filter},void 0!==this.limit&&this.limit>0&&(e.limit=this.limit)}return function(e,t,i,r=!0){if(!e)return{valid:!0,guiSupported:!0,validationErrors:[],guiLimitations:[]};const o=[],n=[];if(e.limetype&&!t[e.limetype]&&o.push(`Unknown limetype: ${e.limetype}`),void 0===e.offset||e.orderBy||o.push("offset requires orderBy to be specified"),r&&(e.orderBy&&n.push("orderBy is not yet supported in GUI mode"),void 0!==e.offset&&n.push("offset is not yet supported in GUI mode")),e.filter){const n=function(e,t,i,r){const o=[];try{a(e),f(e,t,i,r)}catch(e){o.push(`Invalid filter: ${e.message}`)}return o}(e.filter,i,t,r);o.push(...n)}if(e.responseFormat){const{errors:i,limitations:s}=function(e,t,i,r){const o=[],n=[];try{const o=function(e,t,i,r=!0){const o=[];if(r&&e.aggregates&&o.push("responseFormat.aggregates is not yet supported in GUI mode"),e.object){const n=m(e.object,t,i,r);o.push(...n)}return o}(e,t,i,r);n.push(...o)}catch(e){o.push(`Invalid responseFormat: ${e.message}`)}return{errors:o,limitations:n}}(e.responseFormat,t,e.limetype,r);o.push(...i),n.push(...s)}return{valid:0===o.length,guiSupported:0===n.length,validationErrors:o,guiLimitations:n}}(e,this.limetypes,this.activeLimetype,this.guiModeEnabled)}renderModeSwitch(e){return i("div",{class:"mode-switch"},i("limel-button",{label:"GUI",primary:"gui"===this.mode,disabled:!e.guiSupported,onClick:this.switchToGui}),i("limel-button",{label:"Code",primary:"code"===this.mode,onClick:this.switchToCode}))}renderCodeEditor(e){return i("div",{class:"code-editor-container"},i("limel-code-editor",{value:this.codeValue,language:"json",lineNumbers:!0,fold:!0,lint:!0,onChange:this.handleCodeChange}),!e.valid&&e.validationErrors.length>0&&i("div",{class:"validation-errors"},i("strong",null,"Invalid Lime Query:"),i("ul",null,e.validationErrors.map((e=>i("li",null,e))))),this.guiModeEnabled&&e.valid&&!e.guiSupported&&e.guiLimitations.length>0&&i("div",{class:"gui-limitations"},i("strong",null,"Cannot switch to GUI mode:"),i("ul",null,e.guiLimitations.map((e=>i("li",null,e))))))}renderLimetypeSection(){return i("div",{class:"limetype-section"},i("limebb-limetype-field",{platform:this.platform,context:this.context,label:"Object Type",value:this.limetype,required:!0,fieldName:"limetype",helperText:"Select the type of object you want to query",onChange:this.handleLimetypeChange}))}renderResponseFormatSection(){if(this.limetype)return i("div",{class:"response-format-section"},i("limebb-response-format-editor",{platform:this.platform,context:this.context,limetype:this.limetype,value:this.internalResponseFormat,onChange:this.handleResponseFormatChange}))}renderFilterSection(){if(this.limetype)return i("div",{class:"filter-section"},i("h4",{class:"section-label"},"Filter Conditions"),i("limebb-lime-query-filter-expression",{platform:this.platform,context:this.context,limetype:this.limetype,activeLimetype:this.activeLimetype,expression:this.filter,onExpressionChange:this.handleFilterChange}))}renderQueryOptionsSection(){var e;if(this.limetype)return i("div",{class:"query-options-section"},i("h4",{class:"section-label"},"Query Options"),i("div",{class:"query-options-controls"},i("limel-input-field",{label:"Limit",type:"number",value:(null===(e=this.limit)||void 0===e?void 0:e.toString())||"",placeholder:"No limit",helperText:"Maximum number of results",onChange:this.handleLimitChange})))}renderGuiMode(){return i("div",{class:"gui-mode"},this.renderLimetypeSection(),this.renderResponseFormatSection(),this.renderFilterSection(),this.renderQueryOptionsSection())}renderLabel(){if(this.label)return i("h3",{class:"lime-query-builder-label"},this.label)}renderModeControls(e){if(this.guiModeEnabled)return i("div",{class:"mode-controls"},this.renderModeSwitch(e))}renderCodeMode(e){return i("div",{class:"code-mode"},this.renderCodeEditor(e))}};(function(e,t,i,r){var o,n=arguments.length,s=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var l=e.length-1;l>=0;l--)(o=e[l])&&(s=(n<3?o(s):n>3?o(t,i,s):o(t,i))||s);n>3&&s&&Object.defineProperty(t,i,s)})([r()],y.prototype,"limetypes",void 0),y.style=":host(limebb-lime-lime-query-builder){display:block;width:100%}.lime-query-builder{display:flex;flex-direction:column;gap:2rem}.mode-controls{display:flex;align-items:center;gap:0.5rem;padding:0.5rem}.mode-switch{display:flex;align-items:center;gap:0.5rem}.mode-switch limel-button{min-width:5rem}.mode-switch limel-helper-text{margin-left:1rem;color:rgb(var(--color-red-default))}.gui-mode,.code-mode{display:block}.code-editor-container{--code-editor-max-height:70vh;display:flex;flex-direction:column;gap:1rem}.code-editor-container .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-editor-container .validation-errors strong{display:block;margin-bottom:0.5rem;font-weight:600}.code-editor-container .validation-errors ul{margin:0;padding-left:1.5rem}.code-editor-container .validation-errors li{margin:0.25rem 0}.code-editor-container .gui-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-editor-container .gui-limitations strong{display:block;margin-bottom:0.5rem;font-weight:600}.code-editor-container .gui-limitations ul{margin:0;padding-left:1.5rem}.code-editor-container .gui-limitations li{margin:0.25rem 0}.lime-query-builder-label{margin:0;font-size:1.5rem;font-weight:600;color:rgb(var(--contrast-1100))}.limetype-section{display:flex;flex-direction:column}.filter-section,.query-options-section{display:flex;flex-direction:column;gap:1rem}.section-label{margin:0;font-size:1.125rem;font-weight:600;color:rgb(var(--contrast-1000))}.query-options-controls{display:grid;grid-template-columns:repeat(auto-fit, minmax(200px, 1fr));gap:1rem}@media (max-width: 768px){.lime-query-builder{gap:1.5rem}.query-options-controls{grid-template-columns:1fr}}";export{y as limebb_lime_query_builder}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e,c as t,h as i}from"./p-1556b545.js";import{Z as s,T as r}from"./p-4838284a.js";import{a as l,g as o}from"./p-e0ab1554.js";const n=class{constructor(r){e(this,r),this.expressionChange=t(this,"expressionChange",7),this.renderChildExpression=(e,t)=>i("li",null,i("limebb-lime-query-filter-expression",{platform:this.platform,context:this.context,limetype:this.limetype,activeLimetype:this.activeLimetype,expression:e,onExpressionChange:this.handleExpressionChange(t)})),this.handleToggleOperator=()=>{this.expressionChange.emit({op:this.expression.op===s.AND?s.OR:s.AND,exp:this.expression.exp})},this.handleAddChildExpression=()=>{this.expressionChange.emit({op:this.expression.op,exp:[...this.expression.exp,{key:"",op:s.EQUALS,exp:""}]})},this.handleAddChildGroup=()=>{this.expressionChange.emit({op:this.expression.op,exp:[...this.expression.exp,{op:this.expression.op===s.AND?s.OR:s.AND,exp:[{key:"",op:s.EQUALS,exp:""}]}]})},this.handleExpressionChange=e=>t=>{t.stopPropagation();const i=t.detail,s=[...this.expression.exp];if(void 0===i){if(s.splice(e,1),0===s.length)return void this.expressionChange.emit(void 0);if(1===s.length)return void this.expressionChange.emit(s[0])}else s[e]=i;this.expressionChange.emit({op:this.expression.op,exp:s})}}render(){const e=this.getSubheading();return i("div",{key:"43a1d99fd896e3ad49dd97594e54bccaf74c3aa0",class:"expression"},e&&i("limel-header",{key:"534eb0a3db2f0194e8a28e2fb071beb545f38458",subheading:e,onClick:this.handleToggleOperator,class:"clickable-header"}),i("ul",{key:"9d29d98ab034bf2878e7dc19828bc045dbdd492f"},this.expression.exp.map(this.renderChildExpression),i("li",{key:"44b266c8aeb390b8a68b3e08a51a0760a6421f93",class:"add-button"},this.renderAddButton(),this.renderAddGroupButton())))}getSubheading(){return this.expression.exp.length<=1?"":this.expression.op===s.AND?"All of these conditions are true":"Any of these conditions are true"}renderAddButton(){const e=this.getAddButtonLabel();return i("limel-button",{label:e,icon:"plus_math",onClick:this.handleAddChildExpression})}renderAddGroupButton(){const e=this.getAddGroupButtonLabel();return i("limel-button",{label:e,icon:"tree_structure",onClick:this.handleAddChildGroup})}getAddButtonLabel(){return 0===this.expression.exp.length?"Add a condition":this.expression.op===s.AND?"Add another condition":"Add alternative"}getAddGroupButtonLabel(){return 0===this.expression.exp.length?"Add a group":this.expression.op===s.AND?"Add another group":"Add alternative group"}};n.style='@charset "UTF-8";.expression{display:flex;flex-direction:column;margin-bottom:1rem;gap:0;background-color:rgb(var(--contrast-100));border:1px solid rgb(var(--contrast-500));border-radius:0.75rem}.expression .clickable-header{cursor:pointer;user-select:none}.expression .clickable-header:hover{background-color:rgb(var(--contrast-200))}.expression>ul{margin-top:0;margin-right:1rem;margin-bottom:1rem;margin-left:1rem;padding-left:1rem;list-style:disc}.expression>ul li{margin-top:1rem}.expression>ul li.add-button{list-style:none;display:flex;gap:0.5rem}';const a=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:"f1dfd7fd4ec7dc1873841d1c8b3d2bb6677634fd",class:"expression"},this.label&&i("limel-header",{key:"91e1b754f6e45c70f49bf2a770898a590defaf22",heading:this.label}),i("limebb-lime-query-filter-expression",{key:"bf42f3c71521a413e5ecc49a8e0d6401b34384a2",platform:this.platform,context:this.context,label:"Not",limetype:this.limetype,activeLimetype:this.activeLimetype,expression:this.expression.exp,onExpressionChange:this.handleExpressionChange}))}};a.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 h=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("div",{class:"value-input-container"},this.renderModeToggle(),"placeholder"===this.inputMode?this.renderPlaceholderInput():this.renderValueInputByType()):null}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.isPlaceholder(this.value)&&i("div",{class:"placeholder-preview"},i("limel-icon",{name:"info",size:"small"}),i("span",null,"Placeholder: ",this.value)))}renderValueInputByType(){if("IN"===this.operator)return this.renderMultiValueInput();const e=this.getProperty();if(!e)return this.renderTextInput();switch(e.type){case"integer":case"decimal":return this.renderNumberInput(e.type);case"yesno":return this.renderBooleanInput();case"option":return this.renderOptionInput(e);case"date":return this.renderDateInput();case"time":return this.renderTimeInput();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 s="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:s,onChange:this.handleTextChange})}renderBooleanInput(){const e=[{text:"True",value:"true"},{text:"False",value:"false"}],t=!0===this.value||"true"===this.value?"true":"false",s=e.find((e=>e.value===t));return i("limel-select",{label:this.label,options:e,value:s,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}))),s=t.find((e=>e.value===this.value));return i("limel-select",{label:this.label,options:t,value:s,onChange:this.handleSelectChange})}renderDateInput(){const e="string"==typeof this.value?new Date(this.value):this.value;return i("limel-date-picker",{label:this.label,value:e,onChange:this.handleDateChange})}renderTimeInput(){return i("limel-input-field",{label:this.label,type:"time",value:this.value||"",onChange:this.handleTextChange})}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 l(this.limetypes,this.limetype,this.propertyPath)}};(function(e,t,i,s){var r,l=arguments.length,o=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(r=e[n])&&(o=(l<3?r(o):l>3?r(t,i,o):r(t,i))||o);l>3&&o&&Object.defineProperty(t,i,o)})([r()],h.prototype,"limetypes",void 0),h.style=":host{display:block}.value-input-container{display:flex;flex-direction:row;align-items:flex-start;gap:0.5rem;width:100%}.mode-toggle{flex-shrink:0;margin-top:0.5rem;opacity:0.7;transition:opacity 0.2s ease}.mode-toggle:hover{opacity:1}.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}";const c=class{constructor(i){e(this,i),this.change=t(this,"change",7),this.label="Property",this.required=!1,this.isOpen=!1,this.navigationPath="",this.menuItems=[],this.handleChipSetWrapperClick=e=>{e.stopPropagation()},this.handleChipSetFocus=()=>{this.isOpen||(this.navigationPath=this.value||"",this.loadMenuItems(),this.isOpen=!0)},this.handleSelect=e=>{e.stopPropagation();const t=e.detail.value;if(!t)return;const i=l(this.limetypes,this.limetype,t);(null==i?void 0:i.relation)?this.navigationPath=t:(this.change.emit(t),this.isOpen=!1,this.navigationPath="")},this.handleNavigateMenu=e=>{var t;e.stopPropagation(),(null===(t=e.detail)||void 0===t?void 0:t.value)&&(this.navigationPath=e.detail.value)},this.handleCancel=()=>{this.isOpen=!1,this.navigationPath=""},this.handleChipSetChange=e=>{e.stopPropagation();const t=e.detail;if(!t)return this.change.emit(""),void(this.navigationPath="");const i=Array.isArray(t)?t:[t];if(0===i.length)this.change.emit(""),this.navigationPath="";else{const e=i.at(-1);e&&this.change.emit(e.value),this.navigationPath=""}}}render(){if(!this.limetype||!this.limetypes)return null;const e=this.getChipsForPath(this.navigationPath||this.value||"");return i("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},i("div",{slot:"trigger"},i("div",{onClick:this.handleChipSetWrapperClick},i("limel-chip-set",{type:"input",label:this.label,value:e,required:this.required,helperText:this.helperText,delimiter:"›",maxItems:1,onChange:this.handleChipSetChange,onFocus:this.handleChipSetFocus}))))}loadMenuItems(){const e=this.getCurrentLimetype();this.menuItems=e?this.createMenuItems(e,""):[]}getCurrentLimetype(){if(!this.navigationPath)return this.limetypes[this.limetype];const e=l(this.limetypes,this.limetype,this.navigationPath);return(null==e?void 0:e.relation)?e.relation.getLimetype():this.limetypes[this.limetype]}createMenuItems(e,t){const i=[];if(!e)return i;const s=o(e);for(const[e,r]of Object.entries(s)){if("hasmany"===r.type||"hasandbelongstomany"===r.type)continue;const s=t?`${t}.${e}`:e;let l;if(r.relation&&r.relation){const e=r.relation.getLimetype();e&&(l=async()=>this.createMenuItems(e,s))}i.push({text:r.localname||e,secondaryText:this.getSecondaryText(r),icon:this.getIconForProperty(r),value:s,items:l})}return 0===i.length?[{text:"No available properties",value:"",disabled:!0}]:i}getSecondaryText(e){var t;if(e.relation){const i=e.relation.getLimetype();return(null===(t=null==i?void 0:i.localname)||void 0===t?void 0:t.singular)||"Object"}return e.type.charAt(0).toUpperCase()+e.type.slice(1)}getIconForProperty(e){return e.relation?{name:"link",color:"rgb(var(--color-sky-default))"}:{name:"decision",color:"rgb(var(--color-gray-default))"}}getChipsForPath(e){if(!e)return[];const t=e.split("."),i=[];let s=this.limetypes[this.limetype],r="";for(const e of t){r=r?`${r}.${e}`:e;const t=o(s)[e];t&&(i.push({id:r,text:t.localname||e,icon:this.getIconForProperty(t),value:r}),t.relation&&(s=t.relation.getLimetype()))}return i}};(function(e,t,i,s){var r,l=arguments.length,o=l<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,s);else for(var n=e.length-1;n>=0;n--)(r=e[n])&&(o=(l<3?r(o):l>3?r(t,i,o):r(t,i))||o);l>3&&o&&Object.defineProperty(t,i,o)})([r()],c.prototype,"limetypes",void 0),c.style=":host(limebb-property-selector){display:block}limel-menu{display:block;width:100%}";export{n as limebb_lime_query_filter_group,a as limebb_lime_query_filter_not,h as limebb_lime_query_value_input,c as limebb_property_selector}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,c as e,h as i}from"./p-1556b545.js";import{c as s}from"./p-4838284a.js";import{b as o}from"./p-20bfca36.js";import{i as r}from"./p-1484e300.js";import{b as n}from"./p-a659d55a.js";import{i as a,a as l,b as c}from"./p-b31772c8.js";import"./p-35897ec3.js";import"./p-fe2b91d9.js";import"./p-5322fd19.js";function p(t){return"string"==typeof t||!a(t)&&l(t)&&"[object String]"==c(t)}const h=["string","text","phone","integer","decimal","percent","time","date","year","quarter","month","yesno","link","user","xml","option","set","file","system"],d=h.filter((t=>"system"!==t));d.push("belongsto","hasone","hasmany","hasandbelongstomany");const m=class{constructor(i){t(this,i),this.change=e(this,"change",7),this.propertyFields=[],this.fieldName="limetype",this.handleChange=t=>{t.stopPropagation();let e="";t.detail&&"value"in t.detail&&(e=t.detail.value),this.change.emit(e||void 0)}}componentWillLoad(){const t=this.platform.get(s.Application).getLanguage();this.collator=new Intl.Collator(t,{numeric:!0,sensitivity:"base"})}componentShouldUpdate(t,e,i){var s,o,r,a;return"formInfo"!==i||(r=null===(s=null==t?void 0:t.schema)||void 0===s?void 0:s.oneOf,a=null===(o=null==e?void 0:e.schema)||void 0===o?void 0:o.oneOf,!n(r,a))}render(){var t;const e=this.getLimeTypes().map(u);e.sort(((t,e)=>this.collator.compare(t.text,e.text)));let s=e.find((t=>t.value===this.value)),o=this.invalid;return this.value&&!s&&(o=!0,e.unshift({text:(null===(t=this.limeTypeRepository.getLimeType(this.value))||void 0===t?void 0:t.localname.singular)||this.value,value:this.value}),s=e[0]),e.unshift({text:"",value:""}),i("limel-select",{key:"cf27b83c4751838e85436af443a275b3d7c9dfee",label:this.label,options:e,value:s,required:this.required,helperText:this.helperText,invalid:o,disabled:this.disabled||this.readonly,onChange:this.handleChange})}componentWillRender(){this.updatePropertyFields(this.value||"")}getLimeTypes(){var t,e;let i=this.limetypes;return(null===(e=null===(t=this.formInfo)||void 0===t?void 0:t.schema)||void 0===e?void 0:e.oneOf)&&(i=this.formInfo.schema.oneOf.map((t=>t.const)).filter(p)),i?i.map((t=>this.limeTypeRepository.getLimeType(t))).filter(r):this.limeTypeRepository.getLimeTypes()}updatePropertyFields(t){for(const e of this.propertyFields)e.limetype=t,e.allowedPropertyTypes===h&&(e.allowedPropertyTypes=d)}get limeTypeRepository(){return this.platform.get(s.LimeTypeRepository)}},u=t=>({text:t.localname.singular,value:t.name,icon:o(t)});function f(t,e,i){if(null===i)return void t.push({path:e});const s=i,o="_alias"in s,r="#description"in s,n=Object.keys(s).filter((t=>"_alias"!==t&&"#description"!==t));if(0!==n.length)if(o||r){const i={};for(const t of n)i[t]=s[t];t.push(...b(i,e))}else t.push(...b(i,e));else{const i=s._alias,o=s["#description"];t.push(i||o?{path:e,alias:i,description:o}:{path:e})}}function b(t,e=""){if(!t)return[];const i=[];for(const[s,o]of Object.entries(t))"object"==typeof o&&f(i,e?`${e}.${s}`:s,o);return i}function v(t,e,i){const s=t[e];if(s&&"object"==typeof s&&!("_alias"in s)&&!("#description"in s))return;const o={};i.alias&&""!==i.alias.trim()&&(o._alias=i.alias),i.description&&""!==i.description.trim()&&(o["#description"]=i.description),t[e]=Object.keys(o).length>0?o:null}function y(t,e){const i=t[e];if(!i)return t[e]={},t[e];if("object"==typeof i){const t=i;return Object.keys(t).filter((t=>"_alias"!==t&&"#description"!==t)),t}return t[e]={},t[e]}const g=class{constructor(i){t(this,i),this.change=e(this,"change",7),this.label="Select Properties to Return",this.items=[{path:"_id"}],this.handleItemChange=t=>e=>{e.stopPropagation();const i=[...this.items];null===e.detail?i.splice(t,1):i[t]=e.detail,0===i.length&&i.push({path:"_id"}),this.items=i,this.emitChange()},this.handleAddProperty=()=>{this.items=[...this.items,{path:""}],this.emitChange()}}componentWillLoad(){var t;if(null===(t=this.value)||void 0===t?void 0:t.object){const t=b(this.value.object);t.length>0&&(this.items=t)}}componentWillUpdate(){var t;if(null===(t=this.value)||void 0===t?void 0:t.object){const t=b(this.value.object);(t.length!==this.items.length||!t.every(((t,e)=>{const i=this.items[e];return i&&t.path===i.path&&t.alias===i.alias&&t.description===i.description})))&&(this.items=t.length>0?t:[{path:"_id"}])}}render(){return this.limetype?i("div",{class:"response-format-editor"},i("div",{class:"header"},i("h4",null,this.label)),i("div",{class:"property-list"},this.items.map(((t,e)=>this.renderItem(t,e)))),i("div",{class:"actions"},i("limel-button",{label:"Add Property",icon:"plus_math",onClick:this.handleAddProperty})),i("div",{class:"summary"},i("span",{class:"count"},this.items.length," ",1===this.items.length?"property":"properties"," ","selected"))):i("div",{class:"empty-state"},i("p",null,"Select a limetype to choose properties"))}renderItem(t,e){return i("limebb-response-format-item",{key:`${t.path}-${e}`,class:"property-item",platform:this.platform,context:this.context,limetype:this.limetype,item:t,onItemChange:this.handleItemChange(e)})}emitChange(){const t=function(t){const e={};for(const i of t){const t=i.path.split(".");let s=e;for(let e=0;e<t.length;e++){const o=t[e];e===t.length-1?v(s,o,i):s=y(s,o)}}return e}(this.items);this.change.emit({object:t})}};g.style=":host(limebb-response-format-editor){display:block;width:100%}.response-format-editor{display:flex;flex-direction:column;gap:1rem;padding:1rem}.header{display:flex;justify-content:space-between;align-items:center;gap:1rem}.header h4{margin:0;font-size:1rem;font-weight:600;color:rgb(var(--contrast-1000))}.property-list{display:flex;flex-direction:column;gap:1rem;padding:0.5rem;border:1px solid rgb(var(--contrast-300));border-radius:0.25rem;background-color:rgb(var(--contrast-50));min-height:4rem}.property-item{padding:0.5rem;border-radius:0.25rem;transition:background-color 0.2s}.property-item:hover{background-color:rgb(var(--contrast-100))}.actions{display:flex;justify-content:flex-start}.summary{display:flex;justify-content:space-between;align-items:center;padding-top:0.5rem;border-top:1px solid rgb(var(--contrast-300))}.summary .count{font-size:0.875rem;font-weight:500;color:rgb(var(--contrast-900))}.empty-state{padding:2rem;text-align:center;color:rgb(var(--contrast-700));font-style:italic}.empty-state p{margin:0}";export{m as limebb_limetype_field,g as limebb_response_format_editor}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e,c as i,h as t}from"./p-1556b545.js";import{Z as s}from"./p-4838284a.js";const r=[{value:s.EQUALS,label:"Equals",icon:"equals"},{value:s.NOT_EQUALS,label:"Not Equals",icon:"not-equal"},{value:s.GREATER,label:"Greater Than",icon:"greater-than",applicableTypes:["integer","decimal","date","time"]},{value:s.GREATER_OR_EQUAL,label:"Greater or Equal",icon:"greater-or-equal",applicableTypes:["integer","decimal","date","time"]},{value:s.LESS,label:"Less Than",icon:"less-than",applicableTypes:["integer","decimal","date","time"]},{value:s.LESS_OR_EQUAL,label:"Less or Equal",icon:"less-or-equal",applicableTypes:["integer","decimal","date","time"]},{value:s.IN,label:"In List",icon:"list"},{value:s.LIKE,label:"Contains",icon:"-lime-filter-contain",applicableTypes:["string","text"]},{value:s.BEGINS,label:"Begins With",icon:"-lime-filter-begin",applicableTypes:["string","text"]},{value:s.ENDS,label:"Ends With",icon:"-lime-filter-end",applicableTypes:["string","text"]}],a=class{constructor(t){e(this,t),this.expressionChange=i(this,"expressionChange",7),this.handlePropertyChange=e=>{e.stopPropagation(),this.expressionChange.emit(Object.assign(Object.assign({},this.expression),{key:e.detail}))},this.handleOperatorChange=e=>{e.stopPropagation(),this.expressionChange.emit({key:this.expression.key,op:e.detail.value,exp:this.expression.exp})},this.handleValueChange=e=>{e.stopPropagation(),this.expressionChange.emit(Object.assign(Object.assign({},this.expression),{exp:e.detail}))},this.removeExpression=()=>{this.expressionChange.emit(void 0)}}render(){return t("div",{key:"668e0f05bdb1fb25ffd652ea650c34e5431a3332",class:"expression"},this.label&&t("limel-header",{key:"5034070b58afe31cf90699dd2a27f884e647f540",heading:this.label}),t("div",{key:"14a2b1270e5e6d7e158e29ebc5f61051e5670e80",class:"expression-container"},this.renderPropertySelector(),this.renderOperator(),this.renderValueInput(),t("limel-icon-button",{key:"b69bde6e88c40d2623ef015794db28cec3676c73",class:"remove",icon:"trash",label:"Remove condition",onClick:this.removeExpression})))}renderPropertySelector(){return t("limebb-property-selector",{platform:this.platform,context:this.context,label:"Property",limetype:this.limetype,value:this.expression.key,required:!0,onChange:this.handlePropertyChange})}renderOperator(){const e=!!this.expression.op,i=r.map((e=>({text:e.label,value:e.value,icon:e.icon?{name:e.icon}:void 0}))),s=i.find((e=>e.value===this.expression.op));return t("limel-select",{class:"operator",label:"Operator",value:s,options:i,disabled:!e&&!this.expression.key,onChange:this.handleOperatorChange})}renderValueInput(){return this.expression.op?t("limebb-lime-query-value-input",{platform:this.platform,context:this.context,limetype:this.limetype,activeLimetype:this.activeLimetype,propertyPath:this.expression.key,operator:this.expression.op,value:this.expression.exp,onChange:this.handleValueChange}):null}};a.style=".expression-container{display:flex;flex-direction:row;align-items:flex-start;gap:1rem;flex-wrap:wrap}.expression-container>*{flex-grow:2;width:30%;max-width:calc(100% - 3.25rem)}.expression-container>.operator{flex-grow:1;width:calc(30% + 1rem);min-width:4rem}.expression-container>.remove{flex-grow:0;width:auto;margin-left:auto}@media (max-width: 768px){.expression-container{flex-direction:column}.expression-container>*{width:100%;max-width:100%}.expression-container>.operator{width:100%}.expression-container>.remove{margin-left:0;align-self:flex-end}}";const l=class{constructor(t){e(this,t),this.expressionChange=i(this,"expressionChange",7),this.handleExpressionChange=e=>{e.stopPropagation(),this.expressionChange.emit(e.detail)}}render(){if(!this.expression)return;const e={platform:this.platform,context:this.context,label:this.label,limetype:this.limetype,activeLimetype:this.activeLimetype};return"key"in this.expression?t("limebb-lime-query-filter-comparison",Object.assign({},e,{expression:this.expression,onExpressionChange:this.handleExpressionChange})):this.expression.op===s.AND||this.expression.op===s.OR?t("limebb-lime-query-filter-group",Object.assign({},e,{expression:this.expression,onExpressionChange:this.handleExpressionChange})):this.expression.op===s.NOT?t("limebb-lime-query-filter-not",Object.assign({},e,{expression:this.expression,onExpressionChange:this.handleExpressionChange})):void 0}};l.style='@charset "UTF-8";.expression{display:flex;flex-direction:column;margin-bottom:1rem;gap:1rem}';export{a as limebb_lime_query_filter_comparison,l as limebb_lime_query_filter_expression}
|