kempo 4.2.38 → 4.2.39

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.
@@ -0,0 +1,2 @@
1
+ import s from"/kempo-ui/components/LightComponent.js";import{currentUserHasPermission as t,currentUserHasAllPermissions as i,currentUserHasSomePermissions as e}from"../sdk.js";export default class a extends s{static properties={has:{type:String},all:{type:String},some:{type:String},target:{type:String}};constructor(){super(),this.has="",this.all="",this.some="",this.target=""}async connectedCallback(){super.connectedCallback(),this.style.display="none",await this.applyPermission()}async applyPermission(){let s=!1;if(1===[this.has,this.all,this.some].filter(Boolean).length)try{if(this.has){const[i,e]=await t({permission:this.has});s=!i&&e.hasPermission}else if(this.all){const t=this.all.split(",").map(s=>s.trim()),[e,a]=await i({permissions:t});s=!e&&a.hasPermission}else{const t=this.some.split(",").map(s=>s.trim()),[i,a]=await e({permissions:t});s=!i&&a.hasPermission}}catch(t){s=!1}this.setTargetsVisible(s)}setTargetsVisible(s){if(this.target)for(const t of document.querySelectorAll(this.target))t.style.display=s?"":"none"}}window.customElements.define("k-permission-target",a);
2
+ //# sourceMappingURL=C:\Users\dusti\dev\kempo\dist\kempo\components\PermissionTarget.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src\\kempo\\components\\PermissionTarget.js","names":["LightComponent","currentUserHasPermission","currentUserHasAllPermissions","currentUserHasSomePermissions","PermissionTarget","static","has","type","String","all","some","target","constructor","super","this","connectedCallback","style","display","applyPermission","hasPermission","filter","Boolean","length","error","data","permission","permissions","split","map","p","trim","setTargetsVisible","visible","element","document","querySelectorAll","window","customElements","define"],"sources":["0"],"sourcesContent":["import LightComponent from '/kempo-ui/components/LightComponent.js';\nimport { currentUserHasPermission, currentUserHasAllPermissions, currentUserHasSomePermissions } from '../sdk.js';\n\n/*\n\tSame permission check as k-permission, aimed at other elements instead of its own children.\n\n\tk-permission works by wrapping content and toggling its own display — which only works when\n\twrapping is harmless. Some elements are load-bearing about their position in the DOM: kempo-ui's\n\t<k-tabs> finds its <k-tab>/<k-tab-content> children with a direct-child query, so introducing a\n\twrapper between them breaks tab selection entirely, not just the permission check. This targets\n\tarbitrary elements elsewhere in the document by selector, so the gated elements can stay exactly\n\twhere their own component expects them.\n\n\tRenders nothing itself and never appears in the layout — it is pure wiring, placed wherever is\n\tconvenient (its target does not need to be a descendant, or even nearby).\n*/\nexport default class PermissionTarget extends LightComponent {\n\tstatic properties = {\n\t\thas: { type: String },\n\t\tall: { type: String },\n\t\tsome: { type: String },\n\t\ttarget: { type: String }\n\t};\n\n\tconstructor() {\n\t\tsuper();\n\t\tthis.has = '';\n\t\tthis.all = '';\n\t\tthis.some = '';\n\t\tthis.target = '';\n\t}\n\n\tasync connectedCallback() {\n\t\tsuper.connectedCallback();\n\t\tthis.style.display = 'none';\n\t\tawait this.applyPermission();\n\t}\n\n\tasync applyPermission() {\n\t\tconst attributeCount = [this.has, this.all, this.some].filter(Boolean).length;\n\n\t\tlet hasPermission = false;\n\t\tif(attributeCount === 1) {\n\t\t\ttry {\n\t\t\t\tif(this.has) {\n\t\t\t\t\tconst [error, data] = await currentUserHasPermission({ permission: this.has });\n\t\t\t\t\thasPermission = error ? false : data.hasPermission;\n\t\t\t\t} else if(this.all) {\n\t\t\t\t\tconst permissions = this.all.split(',').map(p => p.trim());\n\t\t\t\t\tconst [error, data] = await currentUserHasAllPermissions({ permissions });\n\t\t\t\t\thasPermission = error ? false : data.hasPermission;\n\t\t\t\t} else {\n\t\t\t\t\tconst permissions = this.some.split(',').map(p => p.trim());\n\t\t\t\t\tconst [error, data] = await currentUserHasSomePermissions({ permissions });\n\t\t\t\t\thasPermission = error ? false : data.hasPermission;\n\t\t\t\t}\n\t\t\t} catch(error) {\n\t\t\t\thasPermission = false;\n\t\t\t}\n\t\t}\n\n\t\tthis.setTargetsVisible(hasPermission);\n\t}\n\n\tsetTargetsVisible(visible) {\n\t\tif(!this.target) return;\n\t\tfor(const element of document.querySelectorAll(this.target)) {\n\t\t\telement.style.display = visible ? '' : 'none';\n\t\t}\n\t}\n}\n\nwindow.customElements.define('k-permission-target', PermissionTarget);\n"],"mappings":"OAAOA,MAAoB,4EAClBC,kCAA0BC,mCAA8BC,MAAqC,2BAevF,MAAMC,UAAyBJ,EAC7CK,kBAAoB,CACnBC,IAAK,CAAEC,KAAMC,QACbC,IAAK,CAAEF,KAAMC,QACbE,KAAM,CAAEH,KAAMC,QACdG,OAAQ,CAAEJ,KAAMC,SAGjB,WAAAI,GACCC,QACAC,KAAKR,IAAM,GACXQ,KAAKL,IAAM,GACXK,KAAKJ,KAAO,GACZI,KAAKH,OAAS,EACf,CAEA,uBAAMI,GACLF,MAAME,oBACND,KAAKE,MAAMC,QAAU,aACfH,KAAKI,iBACZ,CAEA,qBAAMA,GAGL,IAAIC,GAAgB,EACpB,GAAsB,IAHC,CAACL,KAAKR,IAAKQ,KAAKL,IAAKK,KAAKJ,MAAMU,OAAOC,SAASC,OAItE,IACC,GAAGR,KAAKR,IAAK,CACZ,MAAOiB,EAAOC,SAAcvB,EAAyB,CAAEwB,WAAYX,KAAKR,MACxEa,GAAgBI,GAAgBC,EAAKL,aACtC,MAAO,GAAGL,KAAKL,IAAK,CACnB,MAAMiB,EAAcZ,KAAKL,IAAIkB,MAAM,KAAKC,IAAIC,GAAKA,EAAEC,SAC5CP,EAAOC,SAActB,EAA6B,CAAEwB,gBAC3DP,GAAgBI,GAAgBC,EAAKL,aACtC,KAAO,CACN,MAAMO,EAAcZ,KAAKJ,KAAKiB,MAAM,KAAKC,IAAIC,GAAKA,EAAEC,SAC7CP,EAAOC,SAAcrB,EAA8B,CAAEuB,gBAC5DP,GAAgBI,GAAgBC,EAAKL,aACtC,CACD,CAAE,MAAMI,GACPJ,GAAgB,CACjB,CAGDL,KAAKiB,kBAAkBZ,EACxB,CAEA,iBAAAY,CAAkBC,GACjB,GAAIlB,KAAKH,OACT,IAAI,MAAMsB,KAAWC,SAASC,iBAAiBrB,KAAKH,QACnDsB,EAAQjB,MAAMC,QAAUe,EAAU,GAAK,MAEzC,EAGDI,OAAOC,eAAeC,OAAO,sBAAuBlC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M560-320h80v-80h80v-80h-80v-80h-80v80h-80v80h80v80ZM160-160q-33 0-56.5-23.5T80-240v-480q0-33 23.5-56.5T160-800h240l80 80h320q33 0 56.5 23.5T880-640v400q0 33-23.5 56.5T800-160H160Zm0-80h640v-400H447l-80-80H160v480Zm0 0v-480 480Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path fill="currentColor" d="M440-320v-326L336-542l-56-58 200-200 200 200-56 58-104-104v326h-80ZM240-160q-33 0-56.5-23.5T160-240v-120h80v120h480v-120h80v120q0 33-23.5 56.5T720-160H240Z"/></svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kempo",
3
- "version": "4.2.38",
3
+ "version": "4.2.39",
4
4
  "type": "module",
5
5
  "description": "A fullstack CMS framework for creating websites with user authentication",
6
6
  "scripts": {