@limetech/lime-crm-building-blocks 1.102.0 → 1.102.1
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/limebb-lime-query-filter-group_3.cjs.entry.js +164 -70
- package/dist/collection/components/lime-query-builder/expressions/filter-group-logic.js +150 -0
- package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-group.js +15 -71
- package/dist/components/lime-query-filter-expression.js +164 -70
- package/dist/esm/limebb-lime-query-filter-group_3.entry.js +164 -70
- package/dist/lime-crm-building-blocks/lime-crm-building-blocks.esm.js +1 -1
- package/dist/lime-crm-building-blocks/p-7731e1b0.entry.js +1 -0
- package/dist/types/components/lime-query-builder/expressions/filter-group-logic.d.ts +89 -0
- package/package.json +1 -1
- package/dist/lime-crm-building-blocks/p-6579412e.entry.js +0 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { AndOrExpression, Expression, Operator } from '@limetech/lime-web-components';
|
|
2
|
+
/**
|
|
3
|
+
* Result of updating a child expression in a group
|
|
4
|
+
*/
|
|
5
|
+
export interface UpdateChildExpressionResult {
|
|
6
|
+
/**
|
|
7
|
+
* Type of update that occurred:
|
|
8
|
+
* - 'updated': Child was updated, group continues to exist
|
|
9
|
+
* - 'removed': Last child was deleted, group should be removed
|
|
10
|
+
* - 'unwrapped': One child remains, should unwrap to that child
|
|
11
|
+
*/
|
|
12
|
+
type: 'updated' | 'removed' | 'unwrapped';
|
|
13
|
+
/**
|
|
14
|
+
* The resulting expression:
|
|
15
|
+
* - For 'updated': The updated group
|
|
16
|
+
* - For 'removed': undefined
|
|
17
|
+
* - For 'unwrapped': The single remaining child
|
|
18
|
+
*/
|
|
19
|
+
expression?: Expression;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Get the subheading text for a filter group based on its operator and expression count
|
|
23
|
+
*
|
|
24
|
+
* @param operator - The group's operator (AND or OR)
|
|
25
|
+
* @param expressionCount - Number of child expressions
|
|
26
|
+
* @returns Subheading text, or empty string if 0 or 1 expressions
|
|
27
|
+
*/
|
|
28
|
+
export declare function getFilterGroupSubheading(operator: Operator.AND | Operator.OR, expressionCount: number): string;
|
|
29
|
+
/**
|
|
30
|
+
* Get the label for the "Add condition" button
|
|
31
|
+
*
|
|
32
|
+
* @param operator - The group's operator (AND or OR)
|
|
33
|
+
* @param expressionCount - Number of child expressions
|
|
34
|
+
* @returns Appropriate button label based on context
|
|
35
|
+
*/
|
|
36
|
+
export declare function getAddConditionButtonLabel(operator: Operator.AND | Operator.OR, expressionCount: number): string;
|
|
37
|
+
/**
|
|
38
|
+
* Get the label for the "Add group" button
|
|
39
|
+
*
|
|
40
|
+
* @param operator - The group's operator (AND or OR)
|
|
41
|
+
* @param expressionCount - Number of child expressions
|
|
42
|
+
* @returns Appropriate button label based on context
|
|
43
|
+
*/
|
|
44
|
+
export declare function getAddGroupButtonLabel(operator: Operator.AND | Operator.OR, expressionCount: number): string;
|
|
45
|
+
/**
|
|
46
|
+
* Create a new empty comparison expression
|
|
47
|
+
*
|
|
48
|
+
* @returns A new comparison expression with empty key and value
|
|
49
|
+
*/
|
|
50
|
+
export declare function createEmptyComparison(): Expression;
|
|
51
|
+
/**
|
|
52
|
+
* Create a new nested group with the opposite operator from the parent
|
|
53
|
+
*
|
|
54
|
+
* @param parentOperator - The parent group's operator
|
|
55
|
+
* @returns A new group with the opposite operator and one empty comparison
|
|
56
|
+
*/
|
|
57
|
+
export declare function createNestedGroup(parentOperator: Operator.AND | Operator.OR): AndOrExpression;
|
|
58
|
+
/**
|
|
59
|
+
* Add a new expression to a group immutably
|
|
60
|
+
*
|
|
61
|
+
* @param group - The existing group
|
|
62
|
+
* @param newExpression - The expression to add
|
|
63
|
+
* @returns A new group with the expression added to the end
|
|
64
|
+
*/
|
|
65
|
+
export declare function addExpressionToGroup(group: AndOrExpression, newExpression: Expression): AndOrExpression;
|
|
66
|
+
/**
|
|
67
|
+
* Toggle a group's operator between AND and OR
|
|
68
|
+
*
|
|
69
|
+
* @param group - The group to toggle
|
|
70
|
+
* @returns A new group with the toggled operator
|
|
71
|
+
*/
|
|
72
|
+
export declare function toggleGroupOperator(group: AndOrExpression): AndOrExpression;
|
|
73
|
+
/**
|
|
74
|
+
* Update a child expression in a group, handling deletion and unwrapping
|
|
75
|
+
*
|
|
76
|
+
* This function handles three scenarios:
|
|
77
|
+
* 1. Update: Replace a child expression with a new one
|
|
78
|
+
* 2. Delete: Remove a child (when updatedChild is undefined)
|
|
79
|
+
* - If last child is deleted, return 'removed' (group should be deleted)
|
|
80
|
+
* - If deletion leaves one child, return 'unwrapped' (unwrap to that child)
|
|
81
|
+
* - Otherwise, return 'updated' with the remaining children
|
|
82
|
+
*
|
|
83
|
+
* @param group - The group containing the child
|
|
84
|
+
* @param childIndex - Index of the child to update
|
|
85
|
+
* @param updatedChild - The new child expression, or undefined to delete
|
|
86
|
+
* @returns Result object with type and resulting expression
|
|
87
|
+
*/
|
|
88
|
+
export declare function updateChildExpression(group: AndOrExpression, childIndex: number, updatedChild: Expression | undefined): UpdateChildExpressionResult;
|
|
89
|
+
//# sourceMappingURL=filter-group-logic.d.ts.map
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e,c as t,h as i}from"./p-1556b545.js";import{Z as r,T as s}from"./p-4838284a.js";import{g as l}from"./p-b748c770.js";const o=class{constructor(s){e(this,s),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===r.AND?r.OR:r.AND,exp:this.expression.exp})},this.handleAddChildExpression=()=>{this.expressionChange.emit({op:this.expression.op,exp:[...this.expression.exp,{key:"",op:r.EQUALS,exp:""}]})},this.handleAddChildGroup=()=>{this.expressionChange.emit({op:this.expression.op,exp:[...this.expression.exp,{op:this.expression.op===r.AND?r.OR:r.AND,exp:[{key:"",op:r.EQUALS,exp:""}]}]})},this.handleExpressionChange=e=>t=>{t.stopPropagation();const i=t.detail,r=[...this.expression.exp];if(void 0===i){if(r.splice(e,1),0===r.length)return void this.expressionChange.emit(void 0);if(1===r.length)return void this.expressionChange.emit(r[0])}else r[e]=i;this.expressionChange.emit({op:this.expression.op,exp:r})}}render(){const e=this.getSubheading();return i("div",{key:"52195908487144bda718eada4e379e7ad3e413a0",class:"expression"},e&&i("limel-header",{key:"71f29d49c8d071822a30990eb48fde1af579bec5",subheading:e,onClick:this.handleToggleOperator,class:"clickable-header"}),i("ul",{key:"39d798c1424755a8cd0c57ca26d3744ba299b7ad"},this.expression.exp.map(this.renderChildExpression),i("li",{key:"0394f3ec7d63e195f184b081cb1a8179f586cedf",class:"add-button"},this.renderAddButton(),this.renderAddGroupButton())))}getSubheading(){return this.expression.exp.length<=1?"":this.expression.op===r.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===r.AND?"Add another condition":"Add alternative"}getAddGroupButtonLabel(){return 0===this.expression.exp.length?"Add a group":this.expression.op===r.AND?"Add another group":"Add alternative group"}};o.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 n=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:r.NOT,exp:i}:void 0)}}render(){return i("div",{key:"29770b10d0b892750ad2aab3520cec5a82063774",class:"expression"},this.label&&i("limel-header",{key:"9e47d14c6cb526c9c31d67e11a5ed5ec665c7f62",heading:this.label}),i("limebb-lime-query-filter-expression",{key:"943c1529057aa6cc918dc935f1a5782b149351ae",platform:this.platform,context:this.context,label:"Not",limetype:this.limetype,activeLimetype:this.activeLimetype,expression:this.expression.exp,onExpressionChange:this.handleExpressionChange}))}};n.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 a=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(this.operator===r.IN)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 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})}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,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)})([s()],a.prototype,"limetypes",void 0),a.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}";export{o as limebb_lime_query_filter_group,n as limebb_lime_query_filter_not,a as limebb_lime_query_value_input}
|