@crombolo/backoffice-dist 0.44.0 → 0.46.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/dist/apps/app/app.element.js +1 -1
- package/dist/apps/app/index.js +1 -1
- package/dist/chunks/{app-error.element-hw0a8n7j.js → app-error.element-qa6kwp0g.js} +1 -1
- package/dist/chunks/{app.element-v27kntj6.js → app.element-0jxrqq8z.js} +1 -1
- package/dist/chunks/{app.element-8xkwc7w0.js → app.element-hr4cxy7y.js} +1 -1
- package/dist/chunks/{app.element-hjasdz6n.js → app.element-s5bgm7a4.js} +2 -2
- package/dist/chunks/{backoffice.element-t058wdbd.js → backoffice.element-1dwaezfc.js} +1 -1
- package/dist/chunks/block-workspace.context-6wyddg6d.js +41 -0
- package/dist/chunks/{search-modal.element-v11qb5a3.js → search-modal.element-b3rvxczh.js} +1 -1
- package/dist/chunks/{sysinfo.element-r0pgn34t.js → sysinfo.element-9qr7kp0f.js} +1 -1
- package/dist/chunks/{umbraco-package-9k7v74tw.js → umbraco-package-7tr429sv.js} +1 -1
- package/dist/chunks/{umbraco-package-f9ka02qt.js → umbraco-package-7wgzpwh3.js} +1 -1
- package/dist/packages/block/block/workspace/block-alias.function.d.ts +9 -0
- package/dist/packages/block/block/workspace/block-alias.function.js +17 -0
- package/dist/packages/block/block/workspace/block-workspace-editor.element.d.ts +3 -0
- package/dist/packages/block/block/workspace/block-workspace-editor.element.js +40 -0
- package/dist/packages/block/block/workspace/block-workspace.context.d.ts +5 -0
- package/dist/packages/block/block/workspace/block-workspace.context.js +13 -0
- package/dist/packages/sysinfo/index.js +1 -1
- package/dist/packages/sysinfo/repository/sysinfo.repository.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/block-workspace.context-7g11tm08.js +0 -24
|
@@ -436,6 +436,19 @@ export class UmbBlockWorkspaceContext extends UmbSubmittableWorkspaceContextBase
|
|
|
436
436
|
async propertyValueByAlias(propertyAlias) {
|
|
437
437
|
return this.#layout.asObservablePart((layout) => layout?.[propertyAlias]);
|
|
438
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* Crombolo (story 253): the aliases the other blocks of this block's list have.
|
|
441
|
+
* @returns {Array<string>} their aliases
|
|
442
|
+
*/
|
|
443
|
+
getOtherBlockAliases() {
|
|
444
|
+
const contentKey = this.#layout.getValue()?.contentKey;
|
|
445
|
+
return (this.#blockEntries?.getLayouts() ?? [])
|
|
446
|
+
.filter((layout) => layout.contentKey !== contentKey)
|
|
447
|
+
.flatMap((layout) => {
|
|
448
|
+
const alias = layout.alias;
|
|
449
|
+
return typeof alias === 'string' && alias ? [alias] : [];
|
|
450
|
+
});
|
|
451
|
+
}
|
|
439
452
|
getPropertyValue(propertyAlias) {
|
|
440
453
|
// TODO: Should be using Content, then we need a toggle or another method for getting settings.
|
|
441
454
|
return this.#layout.getValue()?.[propertyAlias];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{nM}from"../../chunks/app.element-t52vdxz1.js";import{Nh}from"../../chunks/app.element-
|
|
1
|
+
import{nM}from"../../chunks/app.element-t52vdxz1.js";import{Nh}from"../../chunks/app.element-0jxrqq8z.js";import"../../chunks/app.element-24wj3svp.js";import"../../chunks/app.element-77gzpawp.js";import"../../chunks/app.element-f3j3kge4.js";import"../../chunks/app.element-ytjz2a4d.js";import"../../chunks/app.element-cqgtdtst.js";import"../../chunks/app.element-2w5fhqht.js";import"../../chunks/app.element-wnh4xgv8.js";import"../../chunks/app.element-rqyta8jv.js";import"../../chunks/app.element-52n4j0e1.js";import"../../chunks/app.element-628afer9.js";import"../../chunks/app.element-m7ak5dt7.js";import"../../chunks/app.element-0g1w9h5z.js";import"../../chunks/app.element-9xtz5gph.js";import"../../chunks/app.element-wq0yt6tm.js";import"../../chunks/app.element-1y6a3nxg.js";import"../../chunks/app.element-gxz004dr.js";import"../../chunks/app.element-v6hmw8m4.js";import{u}from"../../chunks/app.element-pm61zrdq.js";import"../../chunks/app.element-bmybjrsv.js";import"../../chunks/app.element-ae0qtn7c.js";import"../../chunks/app.element-99h05p0d.js";import"../../chunks/app.element-ybstaxs1.js";import"../../chunks/app.element-24wk4csv.js";import"../../chunks/app.element-gf2wyrb5.js";import"../../chunks/app.element-6c83ssfn.js";import"../../chunks/app.element-mfaddkz2.js";import"../../chunks/app.element-0rg25qzq.js";import"../../chunks/app.element-1fcz6x5m.js";import"../../chunks/app.element-k2q5cknn.js";u(import.meta.url,["d8at24tr","t52vdxz1","0jxrqq8z","24wj3svp","77gzpawp","f3j3kge4","ytjz2a4d","cqgtdtst","2w5fhqht","wnh4xgv8","rqyta8jv","52n4j0e1","628afer9","m7ak5dt7","0g1w9h5z","9xtz5gph","wq0yt6tm","1y6a3nxg","gxz004dr","v6hmw8m4","pm61zrdq","bmybjrsv","ae0qtn7c","99h05p0d","ybstaxs1","24wk4csv","gf2wyrb5","6c83ssfn","mfaddkz2","0rg25qzq","1fcz6x5m","k2q5cknn","s3zgsphv"],[["./index.js",1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],["../../chunks/app.element-t52vdxz1.js",20,9],["../../chunks/app.element-0jxrqq8z.js",3,22,20],["../../chunks/app.element-24wj3svp.js",29,28,25,18,20,16,8,4],["../../chunks/app.element-77gzpawp.js",30,6,31,29,28,24,25,26,17,8,18,20,16,9,5],["../../chunks/app.element-f3j3kge4.js",25,30,29,28,13,14,17,12,20,9],["../../chunks/app.element-ytjz2a4d.js",30,29,28,7],["../../chunks/app.element-cqgtdtst.js",30,29,28],["../../chunks/app.element-2w5fhqht.js",30,28],["../../chunks/app.element-wnh4xgv8.js",30,12,25,29,28,17,18,20,16,13,14,27,10],["../../chunks/app.element-rqyta8jv.js",25,30,29,28,11,15,24],["../../chunks/app.element-52n4j0e1.js",30,29,28],["../../chunks/app.element-628afer9.js",30,13,25,29,28,17,14,20,16],["../../chunks/app.element-m7ak5dt7.js"],["../../chunks/app.element-0g1w9h5z.js"],["../../chunks/app.element-9xtz5gph.js",30,29,28],["../../chunks/app.element-wq0yt6tm.js",28,18,20,23,17],["../../chunks/app.element-1y6a3nxg.js",23],["../../chunks/app.element-gxz004dr.js",29,28,22,20,19],["../../chunks/app.element-v6hmw8m4.js",30,29,28,22,20],["../../chunks/app.element-pm61zrdq.js",22,30,29,28,25],["../../chunks/app.element-bmybjrsv.js",22],["../../chunks/app.element-ae0qtn7c.js"],["../../chunks/app.element-99h05p0d.js",24,31,30,29],["../../chunks/app.element-ybstaxs1.js",25],["../../chunks/app.element-24wk4csv.js",29,28,26],["../../chunks/app.element-gf2wyrb5.js"],["../../chunks/app.element-6c83ssfn.js",30,28],["../../chunks/app.element-mfaddkz2.js",31,30,29],["../../chunks/app.element-0rg25qzq.js"],["../../chunks/app.element-1fcz6x5m.js"],["../../chunks/app.element-k2q5cknn.js"],["../core/notification/index.js",5,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]],0);
|
|
2
2
|
export{nM as UMB_SYSINFO_MODAL,Nh as UmbSysinfoRepository};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const packageJson = {"name":"@crombolo/backoffice-dist","version":"0.
|
|
1
|
+
const packageJson = {"name":"@crombolo/backoffice-dist","version":"0.46.1","description":"Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. The Crombolo backoffice, built to run in a browser. Versioned with the rest of crombolo; dist/VERSION names the @umbraco-cms/backoffice release vendored here. Regenerate with `bun run vendor:backoffice`.","license":"MIT","author":"Crombolo","homepage":"https://github.com/kineco-au/crombolo-cms#readme","repository":{"type":"git","url":"git+https://github.com/kineco-au/crombolo-cms.git","directory":"packages/backoffice-dist"},"bugs":{"url":"https://github.com/kineco-au/crombolo-cms/issues"},"engines":{"bun":">=1.3.0"},"type":"module","files":["dist","upstream-static","NOTICE"],"publishConfig":{"access":"public"}};
|
|
2
2
|
import { UmbRepositoryBase } from '../../core/repository/index.js';
|
|
3
3
|
import { tryExecute } from '../../core/resources/index.js';
|
|
4
4
|
import { ServerService } from '../../core/backend-api/index.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/backoffice-dist",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.46.1",
|
|
4
4
|
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. The Umbraco backoffice, built to run in a browser. Versioned with the rest of crombolo; dist/VERSION names the @umbraco-cms/backoffice release vendored here. Regenerate with `bun run vendor:backoffice`.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import"./app.element-1fcz6x5m.js";import{Y0,vn,Dt,Jy,ev}from"./app.element-hr8wgyf7.js";import"./app.element-k2q5cknn.js";import{Y,C,R,Ai,U,Mt,oe,L}from"./app.element-0rg25qzq.js";import{r}from"./app.element-mfaddkz2.js";import{ya,k2}from"./app.element-24wk4csv.js";import"./app.element-gf2wyrb5.js";import{Si,Q}from"./app.element-628afer9.js";import"./app.element-ybstaxs1.js";import"./app.element-99h05p0d.js";import{t}from"./app.element-1y6a3nxg.js";import"./app.element-gxz004dr.js";import"./app.element-ae0qtn7c.js";import"./app.element-pm61zrdq.js";import"./app.element-bmybjrsv.js";import"./app.element-v6hmw8m4.js";import"./app.element-wq0yt6tm.js";import"./app.element-m7ak5dt7.js";import"./app.element-0g1w9h5z.js";import"./app.element-6c83ssfn.js";import{cm}from"./app.element-wnh4xgv8.js";import{jo}from"./app.element-rqyta8jv.js";import"./app.element-52n4j0e1.js";import"./app.element-9xtz5gph.js";import{v}from"./app.element-rtzv1k4q.js";import{Hg}from"./app.element-p0q78ewt.js";import"./app.element-qqff9xjj.js";import{lt}from"./app.element-ng9z6334.js";import"./app.element-b8ygzyh6.js";import"./app.element-24wj3svp.js";import"./app.element-2w5fhqht.js";import"./app.element-ytjz2a4d.js";import"./app.element-cqgtdtst.js";import"./app.element-77gzpawp.js";import"./app.element-f3j3kge4.js";import"./app.element-k8nha5kd.js";import{lm}from"./app.element-fpbymb7g.js";import"./app.element-7bwz3mk4.js";import"./app.element-4ncybypa.js";import{Go,AT,pt,ve}from"./app.element-5pzxzhkp.js";import{am}from"./app.element-8hnxpehs.js";import"./app.element-97gzj1hz.js";import"./app.element-aywhmr2c.js";import"./app.element-yc1fkn22.js";import"./app.element-h5mv1qzs.js";import"./app.element-cd8gn3ay.js";import"./app.element-ekrqc172.js";import{qs}from"./app.element-ekkqgwwz.js";import"./app.element-55z4v1kb.js";import{Vp}from"./app.element-jpvpf8xy.js";import"./app.element-qqamkxqf.js";import{G}from"./app.element-34bant6r.js";import"./app.element-rp7r7hdk.js";import"./app.element-td0ywwqq.js";import"./app.element-zmnyjx6f.js";import"./app.element-p1gnn2m8.js";import"./app.element-50f65g3c.js";import"./app.element-1qkdmfcd.js";import"./app.element-t9nj9sd2.js";import"./app.element-thamx8hz.js";import{jv,qw,Vv,qv}from"./app.element-f38q3eka.js";import"./app.element-9fm9shb8.js";import{lr}from"./app.element-8enbwvgy.js";import"./app.element-03hy00jm.js";import"./app.element-rdqh2886.js";import{css as E,customElement as T,html as y,nothing as V,state as b}from"@umbraco-cms/backoffice/external/lit";var c=function(i,e,n,s){var a=arguments.length,o=a<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,n):s,h;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")o=Reflect.decorate(i,e,n,s);else for(var l=i.length-1;l>=0;l--)if(h=i[l])o=(a<3?h(o):a>3?h(e,n,o):h(e,n))||o;return a>3&&o&&Object.defineProperty(e,n,o),o},u=class extends t{constructor(){super();this._headline="",this.consumeContext(Dt,(e)=>{this.observe(e?.name,(n)=>{if(n)this._headline=this.localize.string(n)},"observeOwnerContentElementTypeName"),this.observe(e?.readOnlyGuard.isPermittedForObservableVariant(e.variantId),(n)=>{this._readOnly=n},"observeIsReadOnly")})}render(){return y`<umb-workspace-editor
|
|
2
|
-
><div slot="header">
|
|
3
|
-
<h3 id="headline" title="${this._headline}" data-mark="layout-headline">${this._headline}</h3>
|
|
4
|
-
${this._readOnly?y`<uui-tag look="secondary">${this.localize.term("general_readOnly")}</uui-tag>`:V}
|
|
5
|
-
</div></umb-workspace-editor
|
|
6
|
-
>`}static{this.styles=[E`
|
|
7
|
-
:host {
|
|
8
|
-
display: block;
|
|
9
|
-
width: 100%;
|
|
10
|
-
height: 100%;
|
|
11
|
-
}
|
|
12
|
-
div {
|
|
13
|
-
display: flex;
|
|
14
|
-
align-items: center;
|
|
15
|
-
gap: var(--uui-size-3);
|
|
16
|
-
}
|
|
17
|
-
#headline {
|
|
18
|
-
display: block;
|
|
19
|
-
white-space: nowrap;
|
|
20
|
-
overflow: hidden;
|
|
21
|
-
text-overflow: ellipsis;
|
|
22
|
-
min-width: 0;
|
|
23
|
-
}
|
|
24
|
-
`]}};c([b()],u.prototype,"_headline",void 0);c([b()],u.prototype,"_readOnly",void 0);u=c([T("umb-block-workspace-editor")],u);class m extends Vv{constructor(i,e,n){super(i,e,n);this.name=e.name,this.getName=e.getName,this.culture=Y(e.variantId,(s)=>s?.culture),this.segment=Y(e.variantId,(s)=>s?.segment)}}class d extends r{#t;#a;#s;#n;getValues(){return this.#t.getCurrent()?.values}#e;#r;getVariantValues(){return this.#r}constructor(i,e,n){super(i);this.#t=new jv(this),this.data=this.#t.current,this.#a=new Promise((s)=>{this.#s=s}),this.readOnlyGuard=new ya(this),this.#n=new Ai(void 0),this.variantId=this.#n.asObservable(),this.unique=this.#t.createObservablePartOfCurrent((s)=>s?.key),this.contentTypeId=this.#t.createObservablePartOfCurrent((s)=>s?.contentTypeKey),this.values=this.#t.createObservablePartOfCurrent((s)=>s?.values),this.#e=new Vp(this),this.structure=new qs(this,new lt(this)),this.variantValues=oe([this.structure.contentTypeProperties,this.values,this.variantId],([s,a,o])=>{if(!o)return[];let h=s.map((l)=>({alias:l.alias,variantId:this.#o(l,o)}));return qw(h,a)}),this.#r=[],this.propertyViewGuard=new am(this),this.propertyWriteGuard=new am(this),this.validation=new lm(this),this.finishPropertyValueChange=()=>{this.#t.finishPropertyValueChange()},this.view=new jo(this,n),new qv(this,this.structure,this.validation,this.view.hints,[]),this.name=i.name,this.getName=()=>{let s=this.structure.getOwnerContentType()?.name,a=i.getName();return s?`${s} ${a}`:a},this.propertyViewGuard.fallbackToPermitted(),this.propertyWriteGuard.fallbackToPermitted(),this.observe(this.contentTypeId,(s)=>{if(s)this.structure.loadType(s)},null),this.observe(this.unique,(s)=>{if(s)this.validation.setDataPath("$."+e+`[?(@.key == '${s}')]`)},null),this.observe(this.structure.contentTypeDataTypeUniques,(s)=>{this.#e.setUniques(s)},null),this.observe(this.variantValues,(s)=>{this.#r=s},null)}isLoaded(){return this.#a}resetState(){this.#t.clear(),this.propertyViewGuard.clearRules(),this.propertyWriteGuard.clearRules(),this.propertyViewGuard.fallbackToPermitted(),this.propertyWriteGuard.fallbackToPermitted()}setVariantId(i){this.#n.setValue(i)}getVariantId(){return this.#n.getValue()??v.CreateInvariant()}setData(i){this.#t.setPersisted(i),this.#t.setCurrent(i),this.#s()}getData(){return this.#t.getCurrent()}setPersistedData(i){this.#t.setPersisted(i)}getHasUnpersistedChanges(){return this.#t.getHasUnpersistedChanges()}getUnique(){return this.getData()?.key}getEntityType(){return"element"}getContentTypeId(){return this.getData()?.contentTypeKey}#o(i,e){return e.toVariant(i.variesByCulture,i.variesBySegment)}async propertyVariantId(i){return oe([await this.structure.propertyStructureByAlias(i),this.variantId],([e,n])=>e&&n?this.#o(e,n):void 0)}async propertyValueByAlias(i,e){return this.#t.createObservablePartOfCurrent((n)=>n?.values?.find((s)=>s?.alias===i&&(e?e.compare(s):!0))?.value)}getPropertyValue(i,e){let n=this.#t.getCurrent();if(n)return n.values?.find((a)=>a.alias===i&&(e?e.compare(a):!0))?.value;return}async setPropertyValue(i,e,n){this.initiatePropertyValueChange(),n??=v.CreateInvariant();let s=await this.structure.getPropertyStructureByAlias(i);if(!s)throw Error(`Property alias "${i}" not found.`);let o=(await this.#e.getItemByUnique(s.dataType.unique))?.propertyEditorSchemaAlias;if(!o)throw Error(`Editor Alias of "${s.dataType.unique}" not found.`);let h={editorAlias:o,...n.toObject(),alias:i,value:e},l=this.getData();if(l){let w=Mt(l.values??[],h,(f)=>f.alias===i&&n.compare(f));this.#t.updateCurrent({values:w})}this.finishPropertyValueChange()}initiatePropertyValueChange(){this.#t.initiatePropertyValueChange()}createPropertyDatasetContext(i,e){return new m(i,this,e)}setup(i,e){this.createPropertyDatasetContext(i,e),this.validation.provideAt(i),this.view.provideAt(i)}destroy(){this.structure.destroy(),super.destroy()}}var I="UMB_LANGUAGE_PERMISSION_";class p extends r{#t;#a;#s;#n;#e;#r;constructor(i){super(i);this.consumeContext(Dt,(e)=>{this.#t=e,this.#t?.readOnlyGuard.fallbackToNotPermitted(),this.#t?.content.readOnlyGuard.fallbackToNotPermitted(),this.#t?.settings.readOnlyGuard.fallbackToNotPermitted(),this.observe(e?.variantId,(n)=>{this.#a=n,this.#o(n),this.#h()},"observeBlockVariantId")}),this.consumeContext(G,(e)=>{this.observe(e?.languages,(n)=>{this.#s=n,this.#h()},"observeCurrentUserLanguages"),this.observe(e?.hasAccessToAllLanguages,(n)=>{this.#n=n,this.#h()},"observeCurrentUserHasAccessToAllLanguages")})}#o(i){if(i?.isCultureInvariant())this.#e?.destroy(),this.#e=this.consumeContext(vn,(n)=>{this.observe(n?.readOnlyState.permitted,(s)=>{if(s===void 0)return;if(s){let a={unique:"UMB_BLOCK_MANAGER_CONTEXT",permitted:!0};this.#t?.readOnlyGuard.addRule(a),this.#t?.content.readOnlyGuard.addRule(a),this.#t?.settings.readOnlyGuard.addRule(a)}else this.#t?.readOnlyGuard.removeRule("UMB_BLOCK_MANAGER_CONTEXT"),this.#t?.content.readOnlyGuard.removeRule("UMB_BLOCK_MANAGER_CONTEXT"),this.#t?.settings.readOnlyGuard.removeRule("UMB_BLOCK_MANAGER_CONTEXT")},"observeManagerReadOnly")});else this.#t?.readOnlyGuard.removeRule("UMB_BLOCK_MANAGER_CONTEXT"),this.#t?.content.readOnlyGuard.removeRule("UMB_BLOCK_MANAGER_CONTEXT"),this.#t?.settings.readOnlyGuard.removeRule("UMB_BLOCK_MANAGER_CONTEXT"),this.#e?.destroy(),this.#e=void 0,this.removeUmbControllerByAlias("observeManagerReadOnly")}#h(){if(!this.#t||this.#n==null||this.#s==null)return;let i=this.#a?.culture??void 0,e=!i||this.#n===!0?!0:this.#s?.includes(i)??!1;if(this.#r)this.#t.readOnlyGuard.removeRule(this.#r),this.#t.content.readOnlyGuard.removeRule(this.#r),this.#t.settings.readOnlyGuard.removeRule(this.#r),this.#r=void 0;if(e||!i||!this.#a)return;let n=this.#a,s=I+i,a={unique:s,variantId:n,permitted:!0};this.#t.readOnlyGuard.addRule(a),this.#t.content.readOnlyGuard.addRule(a),this.#t.settings.readOnlyGuard.addRule(a),this.#r=s}}function g(i,e,n){if(i!==void 0)return i;if(!e||!("index"in e))return;let s=e.index;if(typeof s!=="number")return;if(s===-1)return n;return s}function O(i,e,n){let s={};if(i)for(let a of i)s[a.alias]=a.value;if(e){let a={};for(let o of e)a[o.alias]=o.value;s.$settings=a}if(n!==void 0)s.$index=n;return s}import{distinctUntilChanged as k,map as _}from"@umbraco-cms/backoffice/external/rxjs";class B extends Go{#t;#a;#s;#n;#e;setOriginData(i){this.#e=i}#r;#o;#h;#O;#u;#m;#d;#c;#i;#l;#p;#f;#b;constructor(i,e){super(i,e.manifest.alias);this.IS_BLOCK_WORKSPACE_CONTEXT=!0,this.#i=new U(void 0),this.layout=this.#i.asObservable(),this.unique=this.#i.asObservablePart((s)=>s?.contentKey),this.contentKey=this.#i.asObservablePart((s)=>s?.contentKey),this.content=new d(this,"contentData",Jy),this.settings=new d(this,"settingsData",ev),this.#l=new R(void 0),this.name=this.#l.asObservable(),this.#p=new Hg(this),this.#f=new Ai(void 0),this.variantId=this.#f.asObservable(),this.#b=new C(void 0),this.exposed=this.#b.asObservable(),this.readOnlyGuard=new ya(this),this.#y=!1,this.#v=async(s)=>{let a=s.detail.url;if(this.#y)return!0;if(this._checkWillNavigateAway(a)&&this.getHasUnpersistedChanges()){s.preventDefault();let h=(await this.getContext(Q).catch(()=>{return}))?.open(this,cm);if(h)try{return await h.onSubmit(),this.#y=!0,history.pushState({},"",s.detail.url),!0}catch{return!1}else console.error("No modal manager found!")}return!0},this.#E=()=>{if(this.#u)if(this.getIsNew()===!0){let s=this.#i.value?.contentKey;if(s)this.#s?.delete(s)}else{if(this.#m)this.#t?.setOneLayout(this.#m,this.#e);if(this.#d)this.#t?.setOneContent(this.#d);if(this.#c)this.#t?.setOneSettings(this.#c)}};let n=e.manifest;this.#O=n.meta?.entityType,window.addEventListener("willchangestate",this.#v),new p(this),this.content.view.inheritFrom(this.view),this.settings.view.inheritFrom(this.view),this.addValidationContext(this.content.validation),this.addValidationContext(this.settings.validation),this.#h=this.consumeContext(Si,(s)=>{this.#o=s,this.#e=s?.data.originData,s?.onSubmit().catch(this.#E)}),this.#a=this.consumeContext(vn,(s)=>{this.#t=s,this.#T()}),this.#n=this.consumeContext(Y0,(s)=>{if(this.#s=s,s)this.observe(L([s.layoutEntries,this.contentKey]).pipe(_(([a,o])=>{let h=o?a.findIndex((l)=>l.contentKey===o):-1;return h!==-1?h:void 0}),k()),(a)=>{this.#r=a,this.#g(this.content.getVariantValues(),this.settings.getVariantValues())},"observeLayoutIndex");else this.#r=void 0,this.removeUmbControllerByAlias("observeLayoutIndex")}).asPromise({preventTimeout:!0}),this.consumeContext(lr,(s)=>{this.observe(s?.isTrashed,(a)=>{let o=a===!0,h="UMB_PREVENT_EDIT_TRASHED_ITEM";if(o){let l={unique:"UMB_PREVENT_EDIT_TRASHED_ITEM",permitted:!0};this.readOnlyGuard.addRule(l),this.content.readOnlyGuard.addRule(l),this.settings.readOnlyGuard.addRule(l)}else this.readOnlyGuard.removeRule("UMB_PREVENT_EDIT_TRASHED_ITEM"),this.content.readOnlyGuard.removeRule("UMB_PREVENT_EDIT_TRASHED_ITEM"),this.settings.readOnlyGuard.removeRule("UMB_PREVENT_EDIT_TRASHED_ITEM")},"observeIsTrashed")}).skipHost(),this.observe(this.variantId,(s)=>{this.content.setVariantId(s),this.settings.setVariantId(s)},null),this.observe(L([this.content.variantValues,this.settings.variantValues]),async([s,a])=>{this.#g(s,a)},null),this.routes.setRoutes([{path:"create/:elementTypeKey",component:u,setup:async(s,a)=>{let o=a.match.params.elementTypeKey;await this.create(o),new ve(this,this,this.getHostElement().shadowRoot.querySelector("umb-router-slot"))}},{path:"edit/:key",component:u,setup:(s,a)=>{let o=k2(a.match.params.key);this.load(o)}}])}#T(){if(!this.#t)return;let i=this.#t;this.observe(i.liveEditingMode,(e)=>{this.#u=e??!1},"observeLiveEditingMode"),this.observe(L([i.variantId,this.content.structure.variesByCulture,this.content.structure.variesBySegment]),([e,n,s])=>{if(!e||n===void 0||s===void 0)return;if(!s&&!n)e=v.CreateInvariant();else if(!s)e=e.toSegmentInvariant();else if(!n)e=e.toCultureInvariant();this.#f.setValue(e)},"observeVariantIds"),this.removeUmbControllerByAlias("observeHasExpose"),this.observe(L([this.contentKey,this.variantId]),([e,n])=>{if(!e||!n)return;this.observe(i.hasExposeOf(e,n),(s)=>{this.#b.setValue(s??!1)},"observeHasExpose")},"observeContentKeyAndVariantId"),this.observe(this.content.contentTypeId,(e)=>{this.observe(e?i.blockTypeOf(e):void 0,async(n)=>{if(n?.editorSize){if(!i.getEditorConfiguration()?.find((o)=>o.alias==="useInlineEditingAsDefault")?.value)this.setEditorSize(n.editorSize)}if(await this.content.structure.whenLoaded(),!this.#t)return;this.#U(n?.label??this.content.structure.getOwnerContentTypeName())},"observeBlockType")},"observeContentTypeId")}#U(i){if(i)this.#p.markdown=i,this.#g(this.content.getVariantValues(),this.settings.getVariantValues())}async#g(i,e){let n=g(this.#r,this.#e,this.#s?.getLayouts().length);if(this.#p.value=O(i,e,n),await new Promise((h)=>requestAnimationFrame(()=>h(!0))),!this.#t)return;let s=this.getIsNew()===!0?"#general_add":"#general_edit",a=this.#p.toString(),o=`${s} ${a}`;if(this.#l.setValue(o),this.#o)this.view.setTitle(o)}#y;#v;_checkWillNavigateAway(i){return AT(this.routes,this.getUnique(),i)}setEditorSize(i){this.#o?.setModalSize(i)}resetState(){super.resetState(),this.#l.setValue(void 0),this.#i.setValue(void 0),this.#m=void 0,this.#d=void 0,this.#c=void 0,this.content.resetState(),this.settings.resetState(),this.#y=!1,this.removeUmbControllerByAlias(pt)}async load(i){if(await this.#a,await this.#n,!this.#t||!this.#s)throw Error("Block manager not found");if(this.observe(this.#s.layoutOf(i),(e)=>{this.#m??=e,this.removeUmbControllerByAlias("observeLayoutInitially")},"observeLayoutInitially"),this.#w(i),this.#u)this.establishLiveSync()}async create(i){if(await this.#n,await this.#h,!this.#s)throw Error("Block Entries not found");if(!this.#e)throw Error("Origin data not defined");this.setIsNew(!0);let e=await this.#s.create(i,{},this.#e);if(!e)throw Error("Block Entries could not create block");if(this.#u){if(!await this.#s.insert(e.layout,e.content,e.settings,this.#e))throw Error("Block Entries could not insert block");let s=e.layout.contentKey;this.#w(s),this.establishLiveSync()}else if(this.#i.setValue(e.layout),this.content.setData(e.content),e.settings)this.settings.setData(e.settings)}#w(i){if(!this.#s)throw Error("Block Entries not found");this.observe(this.#s.layoutOf(i),(e)=>{this.#i.setValue(e);let n=e?.contentKey;if(!n)return;if(this.observe(this.#t.contentOf(n),(a)=>{this.content.setData(a)},"observeContent"),!this.#d)this.observe(this.#t.contentOf(n),(a)=>{this.#d??=a,this.removeUmbControllerByAlias("observeContentInitially")},"observeContentInitially");let s=e?.settingsKey;if(s){if(this.observe(this.#t.settingsOf(s),(a)=>{this.settings.setData(a)},"observeSettings"),!this.#c)this.observe(this.#t.settingsOf(s),(a)=>{this.#c??=a,this.removeUmbControllerByAlias("observeSettingsInitially")},"observeSettingsInitially")}},"observeLayout")}establishLiveSync(){let i=!0;this.observe(this.layout,(e)=>{if(e){if(i){i=!1;return}this.#t?.setOneLayout(e,this.#e)}},"observeThisLayout"),this.observe(this.content.data,(e)=>{if(e)this.#t?.setOneContent(e)},"observeThisContent"),this.observe(this.settings.data,(e)=>{if(e)this.#t?.setOneSettings(e)},"observeThisSettings")}getData(){return this.#i.getValue()}getUnique(){return this.getData().contentKey}getEntityType(){return this.#O}getName(){return""}getHasUnpersistedChanges(){return this.content.getHasUnpersistedChanges()||this.settings.getHasUnpersistedChanges()}async propertyValueByAlias(i){return this.#i.asObservablePart((e)=>e?.[i])}getPropertyValue(i){return this.#i.getValue()?.[i]}async setPropertyValue(i,e){let n=this.#i.value;if(n)this.#i.update({...n,[i]:await e})}async submit(){let i=this.#i.value,e=this.content.getData();if(!i||!this.#t||!this.#s||!e||!this.#e)throw Error("Missing data");let n=this.settings.getData();if(this.content.setPersistedData(e),n)this.settings.setPersistedData(n);if(!this.#u)if(this.getIsNew()===!0){if(!await this.#s.insert(i,e,n,this.#e))throw Error("Block Entries could not insert block")}else{if(this.#t.setOneLayout(i,this.#e),e)this.#t.setOneContent(e);if(n)this.#t.setOneSettings(n)}this.#C(i.contentKey),this.setIsNew(!1),this.#V()}#V(){this.content.validation.report(),this.settings.validation.report()}autoReportValidation(){this.content.validation.autoReport(),this.settings.validation.autoReport()}expose(){let i=this.#i.value?.contentKey;if(!i)throw Error("Failed to expose block, missing content key.");this.#C(i)}#C(i){let e=this.#f.getValue();if(!e)throw Error("Failed to expose block, missing variant id.");this.#t?.setOneExpose(i,e)}#E;destroy(){super.destroy(),window.removeEventListener("willchangestate",this.#v),this.#i?.destroy(),this.#l?.destroy(),this.#i=void 0,this.#l=void 0,this.#t=void 0,this.#e=void 0}}export{B as UmbBlockWorkspaceContext,B as api};
|