@limetech/lime-crm-building-blocks 1.132.0 → 1.134.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 +20 -0
- package/dist/cjs/lime-crm-building-blocks.cjs.js +1 -1
- package/dist/cjs/limebb-loader.cjs.entry.js +10 -0
- package/dist/cjs/limebb-rule-chip-popover.cjs.entry.js +10 -2
- package/dist/cjs/limebb-rule-editor.cjs.entry.js +101 -4
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/rule-editor/chip-picker-view.js +9 -2
- package/dist/collection/components/rule-editor/rule-arg-filter-editor/rule-arg-filter-editor-metadata.js +10 -0
- package/dist/collection/components/rule-editor/rule-chip-popover/rule-chip-popover.js +30 -2
- package/dist/collection/components/rule-editor/rule-editor.js +90 -5
- package/dist/collection/components/rule-editor/rule-operations.js +15 -2
- package/dist/components/limebb-loader.js +1 -1
- package/dist/components/limebb-rule-editor.js +1 -1
- package/dist/components/rule-chip-popover.js +1 -1
- package/dist/esm/lime-crm-building-blocks.js +1 -1
- package/dist/esm/limebb-loader.entry.js +10 -0
- package/dist/esm/limebb-rule-chip-popover.entry.js +10 -2
- package/dist/esm/limebb-rule-editor.entry.js +102 -5
- 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-49bc396e.entry.js +1 -0
- package/dist/lime-crm-building-blocks/p-6cf0a1cd.entry.js +1 -0
- package/dist/lime-crm-building-blocks/p-6fc4e731.entry.js +1 -0
- package/dist/types/components/rule-editor/chip-picker-view.d.ts +8 -0
- package/dist/types/components/rule-editor/rule-arg-filter-editor/rule-arg-filter-editor-metadata.d.ts +4 -0
- package/dist/types/components/rule-editor/rule-chip-popover/rule-chip-popover.d.ts +8 -0
- package/dist/types/components/rule-editor/rule-editor-views.d.ts +6 -0
- package/dist/types/components/rule-editor/rule-editor.d.ts +27 -0
- package/dist/types/components/rule-editor/rule-operations.d.ts +8 -0
- package/dist/types/components.d.ts +33 -2
- package/package.json +2 -2
- package/dist/lime-crm-building-blocks/p-4e0d077b.entry.js +0 -1
- package/dist/lime-crm-building-blocks/p-55692241.entry.js +0 -1
- package/dist/lime-crm-building-blocks/p-b95b94b6.entry.js +0 -1
|
@@ -2258,6 +2258,11 @@ export namespace Components {
|
|
|
2258
2258
|
* @default false
|
|
2259
2259
|
*/
|
|
2260
2260
|
"disabled": boolean;
|
|
2261
|
+
/**
|
|
2262
|
+
* Forwarded to the embedded config component so it can pull focus when this popover opens. The rule editor sets it only when the chip was just added via the picker, so clicking an existing chip does not steal focus. The component decides when it is ready to receive focus (e.g. after loading its own data).
|
|
2263
|
+
* @default false
|
|
2264
|
+
*/
|
|
2265
|
+
"focusOnOpen": boolean;
|
|
2261
2266
|
/**
|
|
2262
2267
|
* @default true
|
|
2263
2268
|
*/
|
|
@@ -2293,6 +2298,11 @@ export namespace Components {
|
|
|
2293
2298
|
* aren't all reachable are hidden from the add palette, so an author
|
|
2294
2299
|
* can't pick a primitive that would silently fail closed at evaluation
|
|
2295
2300
|
* time.
|
|
2301
|
+
* `context` may be passed explicitly as a Prop; when it isn't — or when
|
|
2302
|
+
* it carries no `limetype` — it resolves from the nearest DOM ancestor
|
|
2303
|
+
* that provides it. An explicit Prop with a `limetype` wins, so an empty
|
|
2304
|
+
* default (e.g. an admin form's "no selection" context) doesn't shadow a
|
|
2305
|
+
* DOM-provided one.
|
|
2296
2306
|
* @exampleComponent limebb-example-rule-editor
|
|
2297
2307
|
* @alpha
|
|
2298
2308
|
* @private
|
|
@@ -2303,7 +2313,7 @@ export namespace Components {
|
|
|
2303
2313
|
*/
|
|
2304
2314
|
"availableContexts"?: (keyof ContextMap)[];
|
|
2305
2315
|
/**
|
|
2306
|
-
*
|
|
2316
|
+
* Evaluation context for the rule. Optional — when omitted, or when it carries no `limetype`, it resolves from the nearest DOM ancestor that provides it.
|
|
2307
2317
|
*/
|
|
2308
2318
|
"context": LimeWebComponentContext;
|
|
2309
2319
|
/**
|
|
@@ -4453,6 +4463,11 @@ declare global {
|
|
|
4453
4463
|
* aren't all reachable are hidden from the add palette, so an author
|
|
4454
4464
|
* can't pick a primitive that would silently fail closed at evaluation
|
|
4455
4465
|
* time.
|
|
4466
|
+
* `context` may be passed explicitly as a Prop; when it isn't — or when
|
|
4467
|
+
* it carries no `limetype` — it resolves from the nearest DOM ancestor
|
|
4468
|
+
* that provides it. An explicit Prop with a `limetype` wins, so an empty
|
|
4469
|
+
* default (e.g. an admin form's "no selection" context) doesn't shadow a
|
|
4470
|
+
* DOM-provided one.
|
|
4456
4471
|
* @exampleComponent limebb-example-rule-editor
|
|
4457
4472
|
* @alpha
|
|
4458
4473
|
* @private
|
|
@@ -7117,6 +7132,11 @@ declare namespace LocalJSX {
|
|
|
7117
7132
|
* @default false
|
|
7118
7133
|
*/
|
|
7119
7134
|
"disabled"?: boolean;
|
|
7135
|
+
/**
|
|
7136
|
+
* Forwarded to the embedded config component so it can pull focus when this popover opens. The rule editor sets it only when the chip was just added via the picker, so clicking an existing chip does not steal focus. The component decides when it is ready to receive focus (e.g. after loading its own data).
|
|
7137
|
+
* @default false
|
|
7138
|
+
*/
|
|
7139
|
+
"focusOnOpen"?: boolean;
|
|
7120
7140
|
/**
|
|
7121
7141
|
* @default true
|
|
7122
7142
|
*/
|
|
@@ -7155,6 +7175,11 @@ declare namespace LocalJSX {
|
|
|
7155
7175
|
* aren't all reachable are hidden from the add palette, so an author
|
|
7156
7176
|
* can't pick a primitive that would silently fail closed at evaluation
|
|
7157
7177
|
* time.
|
|
7178
|
+
* `context` may be passed explicitly as a Prop; when it isn't — or when
|
|
7179
|
+
* it carries no `limetype` — it resolves from the nearest DOM ancestor
|
|
7180
|
+
* that provides it. An explicit Prop with a `limetype` wins, so an empty
|
|
7181
|
+
* default (e.g. an admin form's "no selection" context) doesn't shadow a
|
|
7182
|
+
* DOM-provided one.
|
|
7158
7183
|
* @exampleComponent limebb-example-rule-editor
|
|
7159
7184
|
* @alpha
|
|
7160
7185
|
* @private
|
|
@@ -7165,7 +7190,7 @@ declare namespace LocalJSX {
|
|
|
7165
7190
|
*/
|
|
7166
7191
|
"availableContexts"?: (keyof ContextMap)[];
|
|
7167
7192
|
/**
|
|
7168
|
-
*
|
|
7193
|
+
* Evaluation context for the rule. Optional — when omitted, or when it carries no `limetype`, it resolves from the nearest DOM ancestor that provides it.
|
|
7169
7194
|
*/
|
|
7170
7195
|
"context"?: LimeWebComponentContext;
|
|
7171
7196
|
/**
|
|
@@ -7848,6 +7873,7 @@ declare namespace LocalJSX {
|
|
|
7848
7873
|
"readonly": boolean;
|
|
7849
7874
|
"disabled": boolean;
|
|
7850
7875
|
"isMutable": boolean;
|
|
7876
|
+
"focusOnOpen": boolean;
|
|
7851
7877
|
}
|
|
7852
7878
|
interface LimebbRuleEditorAttributes {
|
|
7853
7879
|
"required": boolean;
|
|
@@ -8755,6 +8781,11 @@ declare module "@stencil/core" {
|
|
|
8755
8781
|
* aren't all reachable are hidden from the add palette, so an author
|
|
8756
8782
|
* can't pick a primitive that would silently fail closed at evaluation
|
|
8757
8783
|
* time.
|
|
8784
|
+
* `context` may be passed explicitly as a Prop; when it isn't — or when
|
|
8785
|
+
* it carries no `limetype` — it resolves from the nearest DOM ancestor
|
|
8786
|
+
* that provides it. An explicit Prop with a `limetype` wins, so an empty
|
|
8787
|
+
* default (e.g. an admin form's "no selection" context) doesn't shadow a
|
|
8788
|
+
* DOM-provided one.
|
|
8758
8789
|
* @exampleComponent limebb-example-rule-editor
|
|
8759
8790
|
* @alpha
|
|
8760
8791
|
* @private
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@limetech/lime-crm-building-blocks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.134.0",
|
|
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": "^4.0.1",
|
|
38
|
-
"@limetech/lime-elements": "^39.
|
|
38
|
+
"@limetech/lime-elements": "^39.32.1",
|
|
39
39
|
"@limetech/lime-web-components": "^6.24.0",
|
|
40
40
|
"@lundalogik/lime-icons8": "^2.41.0",
|
|
41
41
|
"@lundalogik/limeclient.js": "^1.105.1",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e,c as t,h as o}from"./p-DYpn0EkA.js";import{T as r,b as i}from"./p-CqRNpSRV.js";import{L as s}from"./p-BKtEmDNs.js";const a=class{constructor(o){e(this,o),this.negate=t(this,"negate"),this.updateArgs=t(this,"updateArgs"),this.deleteChip=t(this,"deleteChip"),this.isNegated=!1,this.readonly=!1,this.disabled=!1,this.isMutable=!0,this.handleNegateChange=e=>{e.stopPropagation(),this.negate.emit(e.detail)},this.handleArgsChange=e=>{e.stopPropagation(),this.updateArgs.emit(e.detail)},this.handleDelete=()=>{this.deleteChip.emit()}}render(){return o("div",{key:"ca7901be2a99590faddea0c678d149b13b5d564f",class:"popover"},this.renderHeader(),this.renderBody())}renderHeader(){var e,t,r,i;const s=(null===(e=this.metadata)||void 0===e?void 0:e.title)?this.translator.get(this.metadata.title):null!==(r=null===(t=this.refNode)||void 0===t?void 0:t.id)&&void 0!==r?r:"";return o("limel-header",{class:"popover__header is-narrow",heading:s,icon:null===(i=this.metadata)||void 0===i?void 0:i.icon},this.renderHeaderActions())}renderHeaderActions(){return this.isMutable?o("div",{slot:"actions",class:"popover__header-actions"},o("limel-switch",{class:"popover__negate-switch",label:this.translator.get("webclient.rule-editor.negate"),value:this.isNegated,onChange:this.handleNegateChange}),o("limel-icon-button",{class:"popover__delete-button",icon:"trash",label:this.translator.get("webclient.rule-editor.delete"),onClick:this.handleDelete})):null}get translator(){return this.platform.get(i.Translate)}renderBody(){var e,t;const r=null===(e=this.metadata)||void 0===e?void 0:e.configComponent;return r?o("div",{class:"popover__body"},o(s,{platform:this.platform,context:this.context,name:r.name,props:Object.assign(Object.assign({},r.props),{value:null===(t=this.refNode)||void 0===t?void 0:t.args,readonly:this.readonly,disabled:this.disabled,onChange:this.handleArgsChange})})):null}};(function(e,t,o,r){var i,s=arguments.length,a=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(a=(s<3?i(a):s>3?i(t,o,a):i(t,o))||a);s>3&&a&&Object.defineProperty(t,o,a)})([r("context")],a.prototype,"context",void 0),a.style=":host{display:block}.popover{display:flex;flex-direction:column;min-width:24rem;background-color:rgb(var(--contrast-100));border:1px solid rgb(var(--contrast-700));border-radius:0.5rem;box-shadow:0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);overflow:hidden}.popover__header{--header-background-color:rgba(var(--contrast-300));padding-right:0.5rem;gap:1rem}.popover__header-actions{display:grid;grid-auto-flow:column;grid-gap:0.75rem;padding:0.25rem;align-items:center}.popover__delete-button{color:rgb(var(--contrast-1100))}.popover__body{padding:1rem}";export{a as limebb_rule_chip_popover}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,c as e}from"./p-DYpn0EkA.js";import{H as o,b as c}from"./p-CqRNpSRV.js";import{H as i}from"./p-BWMpG2bS.js";let s=class{constructor(t){this.itemId=t}};s=function(t,e,o,c){var i,s=arguments.length,l=s<3?e:null===c?c=Object.getOwnPropertyDescriptor(e,o):c;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(t,e,o,c);else for(var n=t.length-1;n>=0;n--)(i=t[n])&&(l=(s<3?i(l):s>3?i(e,o,l):i(e,o))||l);return s>3&&l&&Object.defineProperty(e,o,l),l}([o({id:"limebb-feed.highlight-item"})],s);const l=class{constructor(o){t(this,o),this.loaded=e(this,"loaded")}connectedCallback(){}async componentWillLoad(){const t=new i;this.platform.register(i.SERVICE_NAME,t),this.commandBus.register(s,t),this.platform.get(c.RuleRegistry).attachMetadata("limetech.limeobject-matches-filter",{configComponent:{name:"limebb-rule-arg-filter-editor"}}),this.loaded.emit()}componentWillUpdate(){}disconnectedCallback(){}get commandBus(){return this.platform.get(c.CommandBus)}};export{l as limebb_loader}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as e,r as t,c as r,g as n}from"./p-DYpn0EkA.js";import{b as i}from"./p-CqRNpSRV.js";function l(e,t){return t?{type:"not",rule:e}:e}function o(e,t){return e.length===t.length&&e.every(((e,r)=>e===t[r]))}function s(e,t){return e.filter((e=>o(e.path,t)))}function a(e,t){let r=e;for(const e of t)r=c(r,e);return r}function u(e,t,r){if(0===t.length)return r;const[n,...i]=t;if("not"===e.type&&"rule"===n)return Object.assign(Object.assign({},e),{rule:u(e.rule,i,r)});if(("all"===e.type||"any"===e.type)&&"rules"===n){if(0===i.length)return r;const[t,...n]=i;if("number"!=typeof t)return e;const l=[...e.rules];return l[t]=u(l[t],n,r),Object.assign(Object.assign({},e),{rules:l})}return e}function c(e,t){return"not"===e.type&&"rule"===t?e.rule:"all"!==e.type&&"any"!==e.type||"rules"!==t?"all"!==e.type&&"any"!==e.type||"number"!=typeof t?e:e.rules[t]:e}const d={name:"question",color:"rgb(var(--color-glaucous-light))"};function h(e,t){return[...e.values()].map((e=>({value:e.id,text:e.title?t.get(e.title):e.id,secondaryText:e.description?t.get(e.description):"",icon:e.icon}))).sort(((e,t)=>e.text.localeCompare(t.text)))}function p(e,t){return e.reads.every((e=>t.has(e)))}function f(e){return`__chip__:${e}`}function b(e){return"ref"===e.type?{ref:e,isNegated:!1}:"not"===e.type&&"ref"===e.rule.type?{ref:e.rule,isNegated:!0}:null}const v=({groupNode:t,groupPath:r,chipChildren:n,ctx:i})=>{const l=new Map,o=n.map((e=>{const t=f(e.index);l.set(t,e);const r=(n=e.ref.id,null!==(o=i.allPrimitiveOptions.find((e=>e.value===n)))&&void 0!==o?o:{value:n,text:n,icon:d});var n,o;return Object.assign(Object.assign({},r),{text:e.isNegated?`¬ ${r.text}`:r.text,value:t})})),s=(a=i.availablePrimitiveOptions,e=>Promise.resolve(function(e,t){if(!t)return e;const r=t.toLocaleLowerCase().split(/\s+/);return e.filter((e=>r.every((t=>{var r,n;return e.text.toLocaleLowerCase().includes(t)||(null===(r=e.secondaryText)||void 0===r?void 0:r.toLocaleLowerCase().includes(t))||(null===(n=e.value)||void 0===n?void 0:n.toLocaleLowerCase().includes(t))}))))}(a,e)));var a;const u=function(e,t,r){var n;const i=w(t,r);return null===i?null:null!==(n=e.find((e=>e.index===i)))&&void 0!==n?n:null}(n,r,i.openChipPath),c="all"===t.type?"&":"|";return e("limel-popover",{class:"rule-node__chips-popover",open:null!==u,openDirection:"bottom-start",onClose:i.onPopoverClose},e("div",{slot:"trigger",class:"rule-node__chips"},e("limel-picker",{multiple:!0,label:i.translator.get("webclient.rule-editor.rules-label"),value:o,searcher:s,delimiter:c,readonly:i.readonly,disabled:i.disabled,onChange:m(t,r,l,i),onInteract:g(r,l,i)})),e("div",null,function(t,r,n){if(!t)return null;const i=function(e,t){return[...e,"rules",t]}(r,t.index);return e("limebb-rule-chip-popover",{platform:n.platform,context:n.context,refNode:t.ref,isNegated:t.isNegated,metadata:n.metadataById.get(t.ref.id),readonly:n.readonly,disabled:n.disabled,isMutable:n.isMutable,onNegate:_(t,i,n),onUpdateArgs:y(t,i,n),onDeleteChip:x(i,n)})}(u,r,i)))},m=(e,t,r,n)=>i=>{i.stopPropagation();const l=Array.isArray(i.detail)?i.detail:[],o=w(t,n.openChipPath);if(null!==o){const e=f(o);l.every((t=>t.value!==e))&&n.onPopoverClose()}const s=l.flatMap((e=>{if("string"!=typeof e.value)return[];const t=r.get(e.value);return t?[t.isNegated?{type:"not",rule:t.ref}:t.ref]:[{type:"ref",id:e.value}]})),a=e.rules.filter((e=>null===b(e)));n.onReplaceNode(t,Object.assign(Object.assign({},e),{rules:[...s,...a]}))},g=(e,t,r)=>n=>{n.stopPropagation();const i=function(e){if("string"==typeof e)return e;if(e&&"object"==typeof e&&"value"in e){const t=e.value;return"string"==typeof t?t:void 0}}(n.detail),l=i?t.get(i):void 0;l&&r.onChipInteract([...e,"rules",l.index])},_=(e,t,r)=>n=>{n.stopPropagation(),r.onReplaceNode(t,n.detail?{type:"not",rule:e.ref}:e.ref)},y=(e,t,r)=>n=>{n.stopPropagation();const i=e.isNegated?[...t,"rule"]:t;r.onUpdateArgs(i,n.detail)},x=(e,t)=>()=>{t.onDelete(e)};function w(e,t){if(!t||t.length<2)return null;if(!o((r=t,r.slice(0,-2)),e))return null;var r;const n=t.at(-1);return"number"==typeof n?n:null}const C=({node:t,path:r,isNegated:n,ctx:i})=>{const l=n?[...r,"rule"]:r,o=n?[...s(i.issues,r),...s(i.issues,l)]:s(i.issues,r),a=[],u=[];for(const[e,r]of t.rules.entries()){const t=b(r);t?a.push(Object.assign(Object.assign({},t),{index:e})):u.push({child:r,index:e})}const c=function(e){return[{value:"all",text:e.translator.get("webclient.rule-editor.combinator.all")},{value:"any",text:e.translator.get("webclient.rule-editor.combinator.any")}]}(i),d=c.find((e=>e.value===t.type));return e("div",{class:(h=t.type,p=o,{"rule-node":!0,[`rule-node--${h}`]:!0,"rule-node--invalid":p.length>0}),key:j(r)},e("div",{class:"rule-node__header"},e("limel-select",{class:"rule-node__combinator-select",value:d,options:c,disabled:!i.isMutable,onChange:N(t,r,n,i)}),function(t,r,n,i){return i.isMutable?e("div",{class:"rule-node__header-actions"},e("limel-switch",{class:"rule-node__negate-switch",label:i.translator.get("webclient.rule-editor.negate"),value:n,onChange:M(t,r,i)}),e("limel-icon-button",{icon:"trash",label:i.translator.get("webclient.rule-editor.delete"),onClick:()=>i.onDelete(r)})):null}(t,r,n,i)),e("div",{class:"rule-node__body"},e(z,{issues:o}),e(v,{groupNode:t,groupPath:l,chipChildren:a,ctx:i}),function(t,r,n){return 0===t.length?null:e("div",{class:"rule-node__children"},t.map((t=>e(P,{node:t.child,path:[...r,"rules",t.index],ctx:n}))))}(u,l,i),function(t,r,n,i){return i.isMutable?e("div",{class:"rule-node__footer"},e("limel-button",{icon:"add",label:i.translator.get("webclient.rule-editor.add-nested-group"),onClick:k(t,r,n,i)})):null}(t,r,n,i)));var h,p};function j(e){return 0===e.length?"root":e.join("/")}function O(e,t,r,n){n.onReplaceNode(t,l(e,r))}const N=(e,t,r,n)=>i=>{i.stopPropagation();const l=i.detail.value;l!==e.type&&O(Object.assign(Object.assign({},e),{type:l}),t,r,n)},k=(e,t,r,n)=>()=>{var i,l;O((i=e,l={type:"all",rules:[]},Object.assign(Object.assign({},i),{rules:[...i.rules,l]})),t,r,n)},M=(e,t,r)=>n=>{n.stopPropagation(),r.onReplaceNode(t,l(e,n.detail))},P=t=>{const{node:r,path:n,ctx:i}=t,l=A(r);return l?e(C,{node:l.node,path:n,isNegated:l.isNegated,ctx:i}):null},R=e=>"not"===e.type&&("all"===e.rule.type||"any"===e.rule.type);function A(e){if("all"===e.type||"any"===e.type)return{node:e,isNegated:!1};if(R(e))return{node:e.rule,isNegated:!0};if("not"===e.type){const t=A(e.rule);if(t)return{node:t.node,isNegated:!t.isNegated}}return null}const z=({issues:t})=>0===t.length?null:t.map((t=>e("div",{class:"rule-node__issue"},t.message))),D=class{constructor(e){t(this,e),this.change=r(this,"change"),this.issues=[],this.openChipPath=null,this.metadataById=new Map,this.allPrimitiveOptions=[],this.availablePrimitiveOptions=[],this.reachableSlots=new Set,this.normalizedCache=null,this.hasLoaded=!1,this.handleDelete=e=>{this.openChipPath=null,this.emitIfChanged(function(e,t){if(0===t.length)return{type:"all",rules:[]};const r=t.slice(0,-1),n=t.at(-1),i=a(e,r);if(("all"===i.type||"any"===i.type)&&"number"==typeof n){const t=[...i.rules];return t.splice(n,1),u(e,r,Object.assign(Object.assign({},i),{rules:t}))}return"not"===i.type&&"rule"===n?u(e,r,{type:"all",rules:[]}):e}(this.normalizedValue,e))},this.handleUpdateArgs=(e,t)=>{this.emitIfChanged(function(e,t,r){const n=a(e,t);return"ref"!==n.type?e:u(e,t,Object.assign(Object.assign({},n),{args:r}))}(this.normalizedValue,e,t))},this.handleReplaceNode=(e,t)=>{this.emitIfChanged(function(e,t,r){return u(e,t,r)}(this.normalizedValue,e,t))},this.handleChipInteract=e=>{this.openChipPath=e},this.handlePopoverClose=()=>{this.openChipPath=null}}componentWillLoad(){this.rebuildFromRegistries()}rebuildFromRegistries(){this.computeReachableSlots(),this.indexMetadata(),this.rebuildAvailableOptions(),this.runValidation()}connectedCallback(){this.hasLoaded&&(this.computeReachableSlots(),this.rebuildAvailableOptions(),this.runValidation())}componentDidLoad(){this.hasLoaded=!0,this.emitNormalization()}onValueChange(){this.emitNormalization()||this.runValidation()}onAvailableContextsChange(){this.rebuildFromRegistries()}render(){return e("div",{key:"f1479b58e37918312e4e47031e6fd3e7d6129449",class:{"rule-editor":!0,"rule-editor--disabled":this.disabled}},this.renderLabel(),e(P,{key:"3c49ff3c08a6f0b51a4ab6608521d571a2ec1625",node:this.normalizedValue,path:[],ctx:this.createRenderContext()}),this.renderHelperText())}renderLabel(){return this.label?e("div",{class:"rule-editor__label"},this.label):null}renderHelperText(){return this.helperText?e("div",{class:"rule-editor__helper-text"},this.helperText):null}createRenderContext(){return{issues:this.issues,metadataById:this.metadataById,allPrimitiveOptions:this.allPrimitiveOptions,availablePrimitiveOptions:this.availablePrimitiveOptions,isMutable:!this.readonly&&!this.disabled,readonly:this.readonly,disabled:this.disabled,platform:this.platform,context:this.context,translator:this.translator,openChipPath:this.openChipPath,onDelete:this.handleDelete,onUpdateArgs:this.handleUpdateArgs,onReplaceNode:this.handleReplaceNode,onChipInteract:this.handleChipInteract,onPopoverClose:this.handlePopoverClose}}indexMetadata(){var e,t,r;const n=null!==(r=null===(t=(e=this.ruleRegistry).listMetadata)||void 0===t?void 0:t.call(e))&&void 0!==r?r:[];this.metadataById=new Map(n.map((e=>[e.id,e]))),this.allPrimitiveOptions=h(this.metadataById,this.translator)}rebuildAvailableOptions(){this.availablePrimitiveOptions=h(this.availablePrimitiveMetadata(),this.translator)}availablePrimitiveMetadata(){const e=new Map;for(const[t,r]of this.metadataById)p(r,this.reachableSlots)&&e.set(t,r);return e}computeReachableSlots(){var e;const t=this.contextRegistry,r=t.list().map((e=>e.id)).filter((e=>void 0!==t.get(e,this.host)));this.reachableSlots=new Set([...r,...null!==(e=this.availableContexts)&&void 0!==e?e:[]])}runValidation(){if(!this.value)return void(this.issues=[]);const e=this.ruleRegistry.validate(this.normalizedValue,[...this.reachableSlots]);this.issues=e.ok?[]:e.issues}emitIfChanged(e){var t;e!==this.normalizedValue&&this.change.emit("all"!==(t=e).type&&"any"!==t.type?t:0===t.rules.length?void 0:t)}get normalizedValue(){if(null!==this.normalizedCache&&this.normalizedCache.source===this.value)return this.normalizedCache.normalized;const e=(t=this.value)?A(t)?t:{type:"all",rules:[t]}:{type:"all",rules:[]};var t;return this.normalizedCache={source:this.value,normalized:e},e}emitNormalization(){if(!this.value)return!1;const e=this.normalizedValue;return e!==this.value&&(this.change.emit(e),!0)}get ruleRegistry(){return this.platform.get(i.RuleRegistry)}get translator(){return this.platform.get(i.Translate)}get contextRegistry(){return this.platform.get(i.ContextRegistry)}get host(){return n(this)}static get watchers(){return{value:[{onValueChange:0}],availableContexts:[{onAvailableContextsChange:0}]}}};D.style=":host{display:block}.rule-editor--disabled{opacity:0.6;pointer-events:none}.rule-editor__label{font-size:0.75rem;font-weight:600;color:rgb(var(--contrast-1500));margin-bottom:0.25rem}.rule-editor__helper-text{font-size:0.75rem;color:rgb(var(--contrast-1300));margin-top:0.25rem}.rule-node{border:1px solid rgb(var(--contrast-500));border-radius:0.5rem;margin:0.25rem 0;overflow:hidden;background-color:rgb(var(--contrast-100))}.rule-node--invalid{border-color:rgb(var(--color-red-default))}.rule-node--all>.rule-node__header,.rule-node--any>.rule-node__header{background-color:rgb(var(--contrast-300));padding:0.375rem 0.75rem;border-bottom:1px solid rgb(var(--contrast-500))}.rule-node__header{display:flex;align-items:center;gap:0.5rem}.rule-node__header-actions{margin-left:auto;display:grid;grid-auto-flow:column;grid-gap:0.5rem;padding:0.125rem;align-items:center}.rule-node__combinator-select{min-width:6rem}.rule-node__body{padding:0.75rem;display:flex;flex-direction:column;gap:0.75rem}limel-popover.rule-node__chips-popover{display:contents;--popover-surface-width:min(calc(100vw - 4rem), 50rem)}.rule-node__chips{display:block;width:100%}.rule-node__chips limel-picker{display:block;width:100%}.rule-node__children{display:flex;flex-direction:column;gap:0.5rem}.rule-node__footer{display:flex;justify-content:center}.rule-node__issue{color:rgb(var(--color-red-default));font-size:0.875rem}";export{D as limebb_rule_editor}
|