@decaf-ts/ui-decorators 0.20.8 → 0.20.9

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.
@@ -1,2 +1,2 @@
1
- var e,t;e=this,t=function(e,t,a,r,o){"use strict";var s;e.UIMediaBreakPoints=void 0,(s=e.UIMediaBreakPoints||(e.UIMediaBreakPoints={})).SMALL="small",s.MEDIUM="medium",s.LARGE="large",s.XLARGE="xlarge";const n={REFLECT:"ui",UIMODEL:"uimodel",RENDERED_BY:"rendered-by",ELEMENT:"uielement",PROP:"uiprop",CHILD:"uichild",NAME:"name",NAME_PREFIX:"input-",VALIDATION_MESSAGE:"validationMessage",UILISTMODEL:"uilistmodel",UILISTPROP:"uilistprop",UILAYOUT:"uilayout",UILAYOUTPROP:"uilayoutprop",HANDLERS:"handlers",TYPE:"type",SUB_TYPE:"subType",HIDDEN:"hidden",HIDE_FOR:"hide-for",SHOW_FOR:"show-for",RENDER_IF:"render-if",FORMAT:"format",ORDER:"order",PAGE:"page",EVENTS:"events",FIRST:"first",LAST:"last",READ_ONLY:"readonly",SEQUENCE:"sequence",REQUIRED:t.ValidationKeys.REQUIRED,MIN:t.ValidationKeys.MIN,MIN_LENGTH:t.ValidationKeys.MIN_LENGTH,MAX:t.ValidationKeys.MAX,MAX_LENGTH:t.ValidationKeys.MAX_LENGTH,PATTERN:t.ValidationKeys.PATTERN,URL:t.ValidationKeys.URL,STEP:t.ValidationKeys.STEP,DATE:t.ValidationKeys.DATE,EMAIL:t.ValidationKeys.EMAIL,PASSWORD:t.ValidationKeys.PASSWORD,EQUALS:t.ValidationKeys.EQUALS,DIFF:t.ValidationKeys.DIFF,LESS_THAN:t.ValidationKeys.LESS_THAN,LESS_THAN_OR_EQUAL:t.ValidationKeys.LESS_THAN_OR_EQUAL,GREATER_THAN:t.ValidationKeys.GREATER_THAN,GREATER_THAN_OR_EQUAL:t.ValidationKeys.GREATER_THAN_OR_EQUAL},i={[n.EMAIL]:t.EmailValidator,[n.URL]:t.URLValidator,[n.DATE]:t.DateValidator,[n.PASSWORD]:t.PasswordValidator},d={[n.REQUIRED]:t.RequiredValidator,[n.MIN]:t.MinValidator,[n.MAX]:t.MaxValidator,[n.STEP]:t.StepValidator,[n.MIN_LENGTH]:t.MinLengthValidator,[n.MAX_LENGTH]:t.MaxLengthValidator,[n.PATTERN]:t.PatternValidator,[n.EQUALS]:t.EqualsValidator,[n.DIFF]:t.DiffValidator,[n.LESS_THAN]:t.LessThanValidator,[n.LESS_THAN_OR_EQUAL]:t.LessThanOrEqualValidator,[n.GREATER_THAN]:t.GreaterThanValidator,[n.GREATER_THAN_OR_EQUAL]:t.GreaterThanOrEqualValidator},l="yyyy-MM-dd",c={BUTTON:"button",CHECKBOX:"checkbox",COLOR:"color",DATE:n.DATE,DATETIME_LOCAL:"datetime-local",EMAIL:n.EMAIL,FILE:"file",HIDDEN:"hidden",IMAGE:"image",MONTH:"month",NUMBER:"number",PASSWORD:n.PASSWORD,RADIO:"radio",RANGE:"range",RESET:"reset",SEARCH:"search",SUBMIT:"submit",TEL:"tel",TEXT:"text",TEXTAREA:"textarea",SELECT:"select",TIME:"time",URL:n.URL,WEEK:"week"},p=[c.CHECKBOX,c.RADIO],E={cancel:"cancel",confirm:"confirm",submit:"submit",clear:"clear",back:"back",[a.OperationKeys.CREATE]:a.OperationKeys.CREATE,[a.OperationKeys.READ]:a.OperationKeys.READ,[a.OperationKeys.UPDATE]:a.OperationKeys.UPDATE,[a.OperationKeys.DELETE]:a.OperationKeys.DELETE};class u extends a.InternalError{constructor(e){super(e,u.name)}}const f=e=>"function"==typeof e&&/^class\s/.test(e+"");function h(e,t){return r.Metadata.key(n.REFLECT,r.DecorationKeys.PROPERTIES,e,t)}function y(e,a,...r){if(e===n.DATE){if(!a)return"";const e=r.shift()||l;return t.formatDate(new Date(a),e)}return a}function m(e){if("number"==typeof e&&!isNaN(e))return e;const t=Number(e);return isNaN(t)?void 0:t}function M(e){if(!e)return e;const t={"&":"&amp;","<":"&lt;",">":"&gt;"};return(""+e).replace(/[&<>]/g,e=>t[e]||e)}function O(e){let a=Date.now();try{t.Model.pk(e.constructor)&&(a=e[t.Model.pk(e.constructor)])}catch(e){}return`${e.constructor.name}-${a}`}class T{static{this.cache={}}constructor(e){this.flavour=e,this.initialized=!1,T.register(this)}translate(e,a=!0){if(a)switch(e){case t.ReservedModels.STRING.name.toLowerCase():return c.TEXT;case t.ReservedModels.NUMBER.name.toLowerCase():case t.ReservedModels.BIGINT.name.toLowerCase():return c.NUMBER;case t.ReservedModels.BOOLEAN.name.toLowerCase():return c.CHECKBOX;case t.ReservedModels.DATE.name.toLowerCase():return c.DATE}else switch(e){case c.SELECT:case c.TEXT:case c.EMAIL:case c.COLOR:case c.PASSWORD:case c.TEL:case c.URL:case c.SEARCH:case c.HIDDEN:case c.TEXTAREA:case c.RADIO:return t.ReservedModels.STRING.name.toLowerCase();case c.NUMBER:return t.ReservedModels.NUMBER.name.toLowerCase();case c.CHECKBOX:return t.ReservedModels.BOOLEAN.name.toLowerCase();case c.DATE:case c.DATETIME_LOCAL:case c.TIME:return t.ReservedModels.DATE.name.toLowerCase()}return e}getClassDecoratorsMetadata(e){return[t.Model.uiModelOf(e.constructor),t.Model.uiListModelOf(e.constructor),t.Model.uiHandlersFor(e.constructor),t.Model.uiLayoutOf(e.constructor)].filter(Boolean)}sortChildrenByOrder(e=[]){return e.sort((a,r)=>{const o=a.props?.order??0,s=r.props?.order??0,i=a=>a===n.FIRST?0:typeof a===t.Primitives.NUMBER?1:a===n.LAST?e.length+e.indexOf(r):1,d=i(o),l=i(s);return d!==l?d-l:1===d&&typeof o===t.Primitives.NUMBER&&typeof s===t.Primitives.NUMBER?o-s:0})}isCustomValidator(e){return!Object.values(t.ValidationKeys).includes(e)&&!Object.values(n).includes(e)}isValidatableByType(e){return Object.keys(i).includes(e)}isValidatableByAttribute(e){return Object.keys(d).includes(e)}toAttributeValue(e,t){if(!Object.keys(d).includes(e))throw Error(`Invalid attribute key "${e}". Expected one of: ${Object.keys(d).join(", ")}.`);return e===n.REQUIRED||t[e]}toFieldDefinition(e,o={},s=!0){const{inheritProps:i,...d}=o;o=d;const p=this.getClassDecoratorsMetadata(e);if(!p.length)throw new u(`No ui definitions set for model ${e.constructor.name}. Did you use @uimodel?`);const E=Object.assign({},...p,i||{}),{tag:f,props:h,item:m,handlers:M}=E,T=t.Model.uiPropertiesOf(e.constructor);let R,g=m?.props||{},L={};const A=(e,t)=>e?[e,t].join("."):t;if(T){const s=r.Metadata.get(e.constructor,t.ValidationKeys.REFLECT)||{};for(const i of T){const d=t.Model.uiDecorationOf(e.constructor,i);let p;try{p=t.Model.uiTypeOf(e.constructor,i)}catch(e){if(!(e instanceof a.NotFoundError))throw e}if(t.Model.uiIsHidden(e.constructor,i)&&!t.Model.uiElementOf(e.constructor,i))throw new u(`@uielement no found in "${i}". It is required to use hiddenOn decorator.`);Object.entries(d).map(([e,t])=>({key:e,props:t})).sort(e=>[n.ELEMENT,n.CHILD].includes(e.key)?-1:1).forEach(a=>{if(!a)throw new u("No decorator found");switch(a.key){case n.PROP:g[i]=a.props;break;case n.CHILD:{const r=a.props?.props?.name||i;try{if(!t.Model.isModel(t.Model.build({},r))&&!t.Model.isPropertyModel(e,r))throw new u(`Child "${r}" must be a model.`)}catch(e){throw new u(`Child "${r}" must be a model.`)}let s;const n=e[i];if("object"!=typeof n||null===n||Array.isArray(n)){const e=a.props.props?.name;s=new(t.Model.get(e))}R=R||[];const d=Object.assign({},o||{},{model:s},{inheritProps:a.props,childOf:A(o?.childOf,i)}),l=this.toFieldDefinition(n||s,d,!1),{inheritProps:c}=d;c&&(l.props=Object.assign({},l.props,c.props||{})),R.push(l);break}case n.UILISTPROP:{L=L||{};const e=a.props;e.name&&(L[e.name]="object"==typeof e?.props&&n.SEQUENCE in e.props?e.props:i);const t=Object.assign({},E.props?.item||{},m?.props||{},e?.props||{},o);g={tag:m?.tag||t.render||"",props:Object.assign({},g?.props,{mapper:L},t)};break}case n.EVENTS:case n.HIDDEN:case n.HIDE_FOR:case n.SHOW_FOR:case n.PAGE:case n.ORDER:case n.UILAYOUTPROP:case n.ELEMENT:{R=R||[];const t=a.props,d=a.key===n.HIDE_FOR?{hideFor:a.props}:a.key===n.SHOW_FOR?{showFor:a.props}:{},p=Object.assign({},g?.props,t.props||{},d,t?.props?.name?{path:A(o?.childOf,t.props.name),childOf:void 0}:{},o,{name:t.props?.name||i});if(a.key===n.ELEMENT){const a={tag:t.tag||g?.tag||f||"",props:p},o=s[i];if(o)for(const e of Object.entries(o).map(([e,t])=>({key:e,props:t})))this.isValidatableByAttribute(e.key)?a.props[this.translate(e.key)]=this.toAttributeValue(e.key,e.props):this.isValidatableByType(e.key)?(e.key===c.DATE&&(a.props[n.FORMAT]=e.props.format||l),a.props[n.TYPE]=e.key):this.isCustomValidator(e.key)&&(p[n.SUB_TYPE]=e.key,e.props?.message&&(p[n.VALIDATION_MESSAGE]=e.props.message));if(!a.props[n.TYPE]){const t=r.Metadata.type(e.constructor,i).name;a.props[n.TYPE]=this.translate(t.toLowerCase(),!0)}a.props.value=y(a.props[n.TYPE],e[i],a.props[n.FORMAT]),R.push(a)}else{const e=R.find(e=>e.props?.name===i||[n.UILAYOUTPROP,n.PAGE,n.EVENTS].includes(a.key)&&(e.props?.childOf===i||e.props?.childOf?.endsWith("."+i)));if(e)if(a.key===n.HIDE_FOR||a.key===n.SHOW_FOR)e.props=Object.assign({},e.props,d);else if(a.key!==n.UILAYOUTPROP)e.props=Object.assign({},e.props,{[a.key]:t});else{const{row:t,col:r,props:o}=a.props;e.props=Object.assign({},o||{},e.props,t,r)}}break}default:throw new u("Invalid key: "+a.key)}})}}o=Object.assign({},h,o,{handlers:M||{}});const D=new Set([...Array.isArray(o?.namespaces)?o.namespaces:[],..."string"==typeof o?.namespace?[o.namespace]:[]].filter(Boolean)),N=o?.operation;R=this.sortChildrenByOrder(R).filter(e=>{const t=e?.props?.hidden||[];if(t.length>0&&t.includes(N))return!1;const a=e?.props?.hideFor||[],r=e?.props?.showFor||[];return!(a.length>0&&[...D].some(e=>a.includes(e))||r.length>0&&![...D].some(e=>r.includes(e)))});const I={tag:f,item:g,props:o,children:R?.length?R:void 0};return s&&(I.rendererId=O(e)),I}static register(e){if(e.flavour in this.cache)throw new a.InternalError(`Rendering engine under ${e.flavour} already exists`);this.cache[e.flavour]=e,this.current=e}static getOrBoot(e){if(e instanceof T)return e;const t=new e;return t.initialize(),t}static get(e){if(!e)return this.getOrBoot(this.current);if(!(e in this.cache))throw new a.InternalError(`Rendering engine under ${e} does not exist`);return this.getOrBoot(this.cache[e])}static render(e,...r){if(!t.Model.get(e.constructor.name)&&!t.Model.fromObject(e))throw new a.InternalError("No model registered found");const o=t.Model.renderedBy(e.constructor);return T.get(o).render(e,...r)}}function R(...e){return(t,a)=>r.propMetadata(h(a,n.HIDDEN),e)(t,a)}function g(...e){return(t,a)=>r.propMetadata(h(a,n.SHOW_FOR),e)(t,a)}function L(e,t){return(a,o)=>{r.propMetadata(h(o,n.EVENTS),{..."object"==typeof e?e:{[e]:t}})(a,o)}}class A extends t.Validator{getMessage(e,...t){return A.translateService?A.translateService.translate(e,...t):super.getMessage(e,...t)}}class D extends o.LoggedClass{constructor(){super(),this.enableDarkMode=!0,this.isDarkMode=!1,this.item={tag:""},this.props={},this.route="",this.borders=!1,this.OperationKeys=a.OperationKeys,this.initialized=!1,this.events={},this.handlers={}}get repository(){return this._repository}set repository(e){this._repository=e}async render(...e){this.log.for(this.render).info(`render for ${this.componentName} with ${JSON.stringify(e)}`)}async refresh(...e){this.log.for(this.refresh).info("Refresh called with args: "+e)}async initialize(...e){this.initialized=!0}async translate(...e){this.log.for(this.translate).info(`translate for ${this.componentName} with ${JSON.stringify(e)}`)}async preview(...e){this.log.for(this.preview).debug("Preview called with args: "+e)}async submit(...e){this.log.for(this.submit).info(`submit for ${this.componentName} with ${JSON.stringify(e)}`)}parseHandlers(e,t){const a={};return Object.entries(e).forEach(([e,r])=>{if(f(r)){const o=new r,s=e in o?o[e]:o.handle;a[e]=s,t.handlers[e]=s}else a[e]=r,t.handlers[e]=r}),a}parseEvents(e,t){const a={};return Object.entries(e).forEach(([e,r])=>{const o=e,s=r();if(f(s)){const r=(new s)[e];r&&(a[o]=r,t.events[o]=r)}else a[o]=r,t.events[o]=r}),a}}class N extends o.LoggedClass{translate(e,t){this.log.for(this.translate).info(`Must translate ${e} with params ${JSON.stringify(t||{})}`)}instant(e,t){this.log.for(this.instant).info(`Must translate ${e} with params ${JSON.stringify(t||{})}`)}}function I(e,t){return(a,o)=>{const s={tag:e||a.name,props:t};return r.metadata(r.Metadata.key(n.REFLECT,n.UIMODEL),s)(a)}}function C(e){return r.apply(r.metadata(r.Metadata.key(n.REFLECT,n.RENDERED_BY),e))}function S(e,t){return(a,o)=>{const s={item:{tag:e||a.name,props:t}};return r.metadata(r.Metadata.key(n.REFLECT,n.UILISTMODEL),s)(a)}}function b(e){return t=>{const a={handlers:e};return r.metadata(r.Metadata.key(n.REFLECT,n.HANDLERS),a)(t)}}function P(t,a=1,o=1,s={}){const i=Object.assign({..."boolean"==typeof a?{flexMode:a,cols:1}:{flexMode:!1,cols:a},rows:o,...Object.assign({breakpoint:e.UIMediaBreakPoints.LARGE},s)});return(e,a)=>(r.metadata(r.Metadata.key(n.REFLECT,n.UILAYOUT),i)(e),I(t,i)(e,a))}function k(e,t=1,a=!1,r={}){let o=[];return"object"==typeof t&&(o=t,t=o.length),I(e,{pages:t,paginated:a,pageTitles:o,props:r})}t.Model.prototype.render=function(...e){return T.render(this,...e)},t.Model.renderedBy=(e=>r.Metadata.get(e,r.Metadata.key(n.REFLECT,n.RENDERED_BY))).bind(t.Model),t.Model.uiPropertiesOf=(e=>{const t=r.Metadata.get(e,r.Metadata.key(n.REFLECT,r.DecorationKeys.PROPERTIES));if(t)return Object.keys(t)}).bind(t.Model),t.Model.uiDecorationOf=(e,t,a)=>{const o=r.Metadata.get(e,r.Metadata.key(n.REFLECT,r.DecorationKeys.PROPERTIES,t));if(o)return a?o[a]:o},t.Model.uiModelOf=e=>r.Metadata.get(e,r.Metadata.key(n.REFLECT,n.UIMODEL)),t.Model.uiElementOf=(e,t)=>r.Metadata.get(e,h(t,n.ELEMENT)),t.Model.uiListModelOf=e=>r.Metadata.get(e,r.Metadata.key(n.REFLECT,n.UILISTMODEL)),t.Model.uiHandlersFor=e=>r.Metadata.get(e,r.Metadata.key(n.REFLECT,n.HANDLERS)),t.Model.uiLayoutOf=e=>r.Metadata.get(e,r.Metadata.key(n.REFLECT,n.UILAYOUT)),t.Model.uiIsHidden=(e,t)=>!!r.Metadata.get(e,h(t,n.HIDDEN)),t.Model.uiIsHiddenOn=(e,t,a)=>{const o=r.Metadata.get(e,h(t,n.HIDDEN));return!!o&&(a?o.includes(a):o)},t.Model.uiTypeOf=(e,t)=>{const o=r.Metadata.get(e,r.Metadata.key(n.REFLECT,r.DecorationKeys.PROPERTIES,t));if(!o)throw new a.NotFoundError(`No metadata found for property '${t}' on model '${e.name}'`);const s=Object.keys(o).filter(e=>[n.PROP,n.ELEMENT,n.CHILD].includes(e));if(0===s.length)throw new a.NotFoundError(`No UI type metadata found for property '${t}' on model '${e.name}'`);if(s.length>1)throw new u("Only one type of decoration is allowed. Please choose between @uiprop, @uichild or @uielement");return o[s[0]]},t.Model.uiListItems=(e=>{const t=r.Metadata.get(e,r.Metadata.key(n.REFLECT,r.DecorationKeys.PROPERTIES));if(t)return Object.keys(t)}).bind(t.Model);const w=t.ModelBuilder.prototype;var U;w.decorateClass||(w.decorateClass=function(e){return this._classDecorators||(this._classDecorators=[]),this._classDecorators.push(e),this}),w.uimodel=function(e,t){return this.decorateClass(I(e,t))},w.renderedBy=function(e){return this.decorateClass(C(e))},w.uilistmodel=function(e,t){return this.decorateClass(S(e,t))},w.uihandlers=function(e){return this.decorateClass(b(e))},w.uilayout=function(e,t,a,r){return this.decorateClass(P(e,t,a,r))},w.uisteppedmodel=function(e,t,a,r){return this.decorateClass(k(e,t,a,r))},e.DashKeys=void 0,(U=e.DashKeys||(e.DashKeys={})).ROOT="dashboard",U.COMPONENT="dashboard.component";const v=new Set;function H(e){v.add(e)}function F(e){const t=r.Metadata.constr(e);if("function"==typeof t)return t;const a=e.constructor;return"function"==typeof a?a:e}function V(t){const a=F(t);return r.Metadata.get(a,e.DashKeys.COMPONENT)}const _="##VERSION##",B="##PACKAGE##";r.Metadata.registerLibrary(B,_),e.ActionRoles=E,e.COMMIT="d286514",e.ComponentEventNames={Render:"render",BackButtonClickEvent:"backButtonNavigationEndEvent",Refresh:"RefreshEvent",Click:"ClickEvent",Change:"ChangeEvent",Submit:"SubmitEvent",ValidationError:"validationErrorEvent",ThemeChange:"themeChangeEvent",FormGroupLoaded:"formGroupLoadedEvent"},e.DecafComponent=D,e.DecafEventHandler=class extends D{constructor(){super()}handle(...e){this.log.for(this.handle).info(`component ${this.componentName} handling ${JSON.stringify(e)}`)}handleClick(...e){this.log.for(this.handleClick).info(`component ${this.componentName} handling click ${JSON.stringify(e)}`)}handleAction(...e){this.log.for(this.handleAction).info(`component ${this.componentName} handling action ${JSON.stringify(e)}`)}},e.DecafTranslateService=N,e.ElementPositions={left:"left",center:"center",right:"right",top:"top",bottom:"bottom"},e.ElementSizes={xsmall:"xsmall",small:"small",medium:"medium",default:"default",large:"large",xLarge:"xlarge","2xLarge":"2xlarge",auto:"auto",expand:"expand",block:"block",half:"half",full:"full"},e.FULL_VERSION="0.20.7-d286514",e.HTML5CheckTypes=p,e.HTML5DateFormat=l,e.HTML5InputTypes=c,e.LayoutGridGaps={small:"small",medium:"medium",large:"large",collapse:"collapse",none:""},e.PACKAGE_NAME=B,e.RenderingEngine=T,e.RenderingError=u,e.TransactionHooks={BeforeRead:"beforeRead",AfterRead:"afterRead",BeforeCreate:"beforeCreate",AfterCreate:"afterCreate",BeforeUpdate:"beforeUpdate",AfterUpdate:"afterUpdate",BeforeDelete:"beforeDelete",AfterDelete:"afterDelete"},e.UIKeys=n,e.UIValidator=A,e.VERSION=_,e.ValidatableByAttribute=d,e.ValidatableByType=i,e.WindowColorSchemes={light:"light",dark:"dark",undefined:"undefined"},e.dashComponentDefinitionOf=e=>{const t=F(e),a=V(t)||{},r=a.tag||t.name;return{name:t.name,tag:r,label:a.label,defaultSize:a.defaultSize??{cols:1,rows:1},model:a.model,props:a.props,metadata:a.metadata}},e.dashComponentMetadataOf=V,e.dashComponents=()=>[...v],e.dashcomponent=(t,a,o)=>r.Decoration.for(e.DashKeys.COMPONENT).define({decorator:(t,a,o)=>{const s={tag:a?.tag||t,...a,defaultSize:a?.defaultSize??{cols:1,rows:1}};return a=>{const n=r.apply(I(t,o),r.metadata(e.DashKeys.COMPONENT,s))(a);return H(a),n}},args:[t,a,o]}).apply(),e.escapeHtml=M,e.formatByType=y,e.generateUIModelID=O,e.getUIAttributeKey=h,e.hidden=()=>R(a.OperationKeys.CREATE,a.OperationKeys.READ,a.OperationKeys.UPDATE,a.OperationKeys.DELETE),e.hideFor=(...e)=>(t,a)=>r.propMetadata(h(a,n.HIDE_FOR),e)(t,a),e.hideOn=R,e.isClassConstructor=f,e.parseToNumber=m,e.parseValueByType=function e(r,o,s){let n;switch(r){case Array.name:n=(Array.isArray(o)?o.map(a=>e(t.ReservedModels.STRING.name.toLowerCase(),a,s)):[o]).join(",");break;case c.NUMBER:n=m(o);break;case c.DATE:{const e=s.format;o&&(""+o).trim().length&&(n=typeof o===t.ReservedModels.NUMBER.name.toLowerCase()?new Date(o):o?e?t.parseDate(e,o):new Date(o):void 0);break}default:n=typeof o===t.ReservedModels.OBJECT.name.toLowerCase()?Array.isArray(o)?o.join(","):JSON.stringify(o):typeof o===t.ReservedModels.BOOLEAN.name.toLowerCase()?o:typeof o===t.ReservedModels.STRING.name.toLowerCase()?M(o):n}if(void 0===n)throw new a.InternalError(`Failed to parse value of type ${r} from ${typeof o} - ${o}`);return n},e.registerDashComponent=H,e.renderIf=(...e)=>g(...e),e.renderedBy=C,e.resetDashComponentRegistry=()=>{v.clear()},e.revertHtml=e=>{const t={"&amp;":"&","&lt;":"<","&gt;":">"};return(""+e).replace(/&lt;|&gt;|&amp;/g,e=>t[e]||e)},e.showFor=g,e.uichild=(e,t,a={},o=!1,s=!1)=>(i,d)=>{const l={tag:t,serialize:s,props:Object.assign({},a||{},{name:e||d},o?{customTypes:[Array.name],multiple:!0}:{multiple:a?.multiple||!1})};r.propMetadata(h(d,n.CHILD),l)(i,d)},e.uielement=(e,t,a=!1)=>(o,s)=>{"object"==typeof e&&(t=e,e="");const i={tag:e,serialize:a,props:Object.assign({},t||{},{name:s})};return r.propMetadata(h(s,n.ELEMENT),i)(o,s)},e.uihandlers=b,e.uilayout=P,e.uilayoutprop=(e=1,t=1)=>(a,o)=>{const s={name:o,props:Object.assign({},{row:t,col:e})};r.propMetadata(h(o,n.UILAYOUTPROP),s)(a,o)},e.uilistmodel=S,e.uilistprop=(e=void 0,t)=>(a,o)=>{const s={name:e||o,props:t||{}};r.propMetadata(h(o,n.UILISTPROP),s)(a,o)},e.uimodel=I,e.uion=L,e.uionclick=e=>L("handleClick",e),e.uionrender=e=>L("render",e),e.uiorder=(e=n.FIRST)=>(t,a)=>r.propMetadata(h(a,n.ORDER),e)(t,a),e.uipageprop=(e=1)=>(t,a)=>r.propMetadata(h(a,n.PAGE),e)(t,a),e.uiprop=(e=void 0,t=!1)=>(a,o)=>{const s={name:e||o,stringify:t};r.propMetadata(h(o,n.PROP),s)(a,o)},e.uisteppedmodel=k,e.uitablecol=(e=n.LAST,t)=>(a,o)=>{const s={name:o,props:{sequence:e,...t?{valueParserFn:t}:{}}};r.propMetadata(h(o,n.UILISTPROP),s)(a,o)}},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@decaf-ts/decorator-validation"),require("@decaf-ts/db-decorators"),require("@decaf-ts/decoration"),require("@decaf-ts/logging")):"function"==typeof define&&define.amd?define(["exports","@decaf-ts/decorator-validation","@decaf-ts/db-decorators","@decaf-ts/decoration","@decaf-ts/logging"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["ui-decorators"]={},e.decafTsDecoratorValidation,e.decafTsDbDecorators,e.decafTsDecoration,e.decafTsLogging);
1
+ var e,t;e=this,t=function(e,t,a,r,o){"use strict";var s;e.UIMediaBreakPoints=void 0,(s=e.UIMediaBreakPoints||(e.UIMediaBreakPoints={})).SMALL="small",s.MEDIUM="medium",s.LARGE="large",s.XLARGE="xlarge";const n={REFLECT:"ui",UIMODEL:"uimodel",RENDERED_BY:"rendered-by",ELEMENT:"uielement",PROP:"uiprop",CHILD:"uichild",NAME:"name",NAME_PREFIX:"input-",VALIDATION_MESSAGE:"validationMessage",UILISTMODEL:"uilistmodel",UILISTPROP:"uilistprop",UILAYOUT:"uilayout",UILAYOUTPROP:"uilayoutprop",HANDLERS:"handlers",TYPE:"type",SUB_TYPE:"subType",HIDDEN:"hidden",HIDE_FOR:"hide-for",SHOW_FOR:"show-for",RENDER_IF:"render-if",FORMAT:"format",ORDER:"order",PAGE:"page",EVENTS:"events",FIRST:"first",LAST:"last",READ_ONLY:"readonly",SEQUENCE:"sequence",REQUIRED:t.ValidationKeys.REQUIRED,MIN:t.ValidationKeys.MIN,MIN_LENGTH:t.ValidationKeys.MIN_LENGTH,MAX:t.ValidationKeys.MAX,MAX_LENGTH:t.ValidationKeys.MAX_LENGTH,PATTERN:t.ValidationKeys.PATTERN,URL:t.ValidationKeys.URL,STEP:t.ValidationKeys.STEP,DATE:t.ValidationKeys.DATE,EMAIL:t.ValidationKeys.EMAIL,PASSWORD:t.ValidationKeys.PASSWORD,EQUALS:t.ValidationKeys.EQUALS,DIFF:t.ValidationKeys.DIFF,LESS_THAN:t.ValidationKeys.LESS_THAN,LESS_THAN_OR_EQUAL:t.ValidationKeys.LESS_THAN_OR_EQUAL,GREATER_THAN:t.ValidationKeys.GREATER_THAN,GREATER_THAN_OR_EQUAL:t.ValidationKeys.GREATER_THAN_OR_EQUAL},i={[n.EMAIL]:t.EmailValidator,[n.URL]:t.URLValidator,[n.DATE]:t.DateValidator,[n.PASSWORD]:t.PasswordValidator},d={[n.REQUIRED]:t.RequiredValidator,[n.MIN]:t.MinValidator,[n.MAX]:t.MaxValidator,[n.STEP]:t.StepValidator,[n.MIN_LENGTH]:t.MinLengthValidator,[n.MAX_LENGTH]:t.MaxLengthValidator,[n.PATTERN]:t.PatternValidator,[n.EQUALS]:t.EqualsValidator,[n.DIFF]:t.DiffValidator,[n.LESS_THAN]:t.LessThanValidator,[n.LESS_THAN_OR_EQUAL]:t.LessThanOrEqualValidator,[n.GREATER_THAN]:t.GreaterThanValidator,[n.GREATER_THAN_OR_EQUAL]:t.GreaterThanOrEqualValidator},l="yyyy-MM-dd",c={BUTTON:"button",CHECKBOX:"checkbox",COLOR:"color",DATE:n.DATE,DATETIME_LOCAL:"datetime-local",EMAIL:n.EMAIL,FILE:"file",HIDDEN:"hidden",IMAGE:"image",MONTH:"month",NUMBER:"number",PASSWORD:n.PASSWORD,RADIO:"radio",RANGE:"range",RESET:"reset",SEARCH:"search",SUBMIT:"submit",TEL:"tel",TEXT:"text",TEXTAREA:"textarea",SELECT:"select",TIME:"time",URL:n.URL,WEEK:"week"},p=[c.CHECKBOX,c.RADIO],E={cancel:"cancel",confirm:"confirm",submit:"submit",clear:"clear",back:"back",[a.OperationKeys.CREATE]:a.OperationKeys.CREATE,[a.OperationKeys.READ]:a.OperationKeys.READ,[a.OperationKeys.UPDATE]:a.OperationKeys.UPDATE,[a.OperationKeys.DELETE]:a.OperationKeys.DELETE};class u extends a.InternalError{constructor(e){super(e,u.name)}}const f=e=>"function"==typeof e&&/^class\s/.test(e+"");function h(e,t){return r.Metadata.key(n.REFLECT,r.DecorationKeys.PROPERTIES,e,t)}function y(e,a,...r){if(e===n.DATE){if(!a)return"";const e=r.shift()||l;return t.formatDate(new Date(a),e)}return a}function m(e){if("number"==typeof e&&!isNaN(e))return e;const t=Number(e);return isNaN(t)?void 0:t}function M(e){if(!e)return e;const t={"&":"&amp;","<":"&lt;",">":"&gt;"};return(""+e).replace(/[&<>]/g,e=>t[e]||e)}function O(e){let a=Date.now();try{t.Model.pk(e.constructor)&&(a=e[t.Model.pk(e.constructor)])}catch(e){}return`${e.constructor.name}-${a}`}class T{static{this.cache={}}constructor(e){this.flavour=e,this.initialized=!1,T.register(this)}translate(e,a=!0){if(a)switch(e){case t.ReservedModels.STRING.name.toLowerCase():return c.TEXT;case t.ReservedModels.NUMBER.name.toLowerCase():case t.ReservedModels.BIGINT.name.toLowerCase():return c.NUMBER;case t.ReservedModels.BOOLEAN.name.toLowerCase():return c.CHECKBOX;case t.ReservedModels.DATE.name.toLowerCase():return c.DATE}else switch(e){case c.SELECT:case c.TEXT:case c.EMAIL:case c.COLOR:case c.PASSWORD:case c.TEL:case c.URL:case c.SEARCH:case c.HIDDEN:case c.TEXTAREA:case c.RADIO:return t.ReservedModels.STRING.name.toLowerCase();case c.NUMBER:return t.ReservedModels.NUMBER.name.toLowerCase();case c.CHECKBOX:return t.ReservedModels.BOOLEAN.name.toLowerCase();case c.DATE:case c.DATETIME_LOCAL:case c.TIME:return t.ReservedModels.DATE.name.toLowerCase()}return e}getClassDecoratorsMetadata(e){return[t.Model.uiModelOf(e.constructor),t.Model.uiListModelOf(e.constructor),t.Model.uiHandlersFor(e.constructor),t.Model.uiLayoutOf(e.constructor)].filter(Boolean)}sortChildrenByOrder(e=[]){return e.sort((a,r)=>{const o=a.props?.order??0,s=r.props?.order??0,i=a=>a===n.FIRST?0:typeof a===t.Primitives.NUMBER?1:a===n.LAST?e.length+e.indexOf(r):1,d=i(o),l=i(s);return d!==l?d-l:1===d&&typeof o===t.Primitives.NUMBER&&typeof s===t.Primitives.NUMBER?o-s:0})}isCustomValidator(e){return!Object.values(t.ValidationKeys).includes(e)&&!Object.values(n).includes(e)}isValidatableByType(e){return Object.keys(i).includes(e)}isValidatableByAttribute(e){return Object.keys(d).includes(e)}toAttributeValue(e,t){if(!Object.keys(d).includes(e))throw Error(`Invalid attribute key "${e}". Expected one of: ${Object.keys(d).join(", ")}.`);return e===n.REQUIRED||t[e]}toFieldDefinition(e,o={},s=!0){const{inheritProps:i,...d}=o;o=d;const p=this.getClassDecoratorsMetadata(e);if(!p.length)throw new u(`No ui definitions set for model ${e.constructor.name}. Did you use @uimodel?`);const E=Object.assign({},...p,i||{}),{tag:f,props:h,item:m,handlers:M}=E,T=t.Model.uiPropertiesOf(e.constructor);let R,g=m?.props||{},L={};const A=(e,t)=>e?[e,t].join("."):t;if(T){const s=r.Metadata.get(e.constructor,t.ValidationKeys.REFLECT)||{};for(const i of T){const d=t.Model.uiDecorationOf(e.constructor,i);let p;try{p=t.Model.uiTypeOf(e.constructor,i)}catch(e){if(!(e instanceof a.NotFoundError))throw e}if(t.Model.uiIsHidden(e.constructor,i)&&!t.Model.uiElementOf(e.constructor,i))throw new u(`@uielement no found in "${i}". It is required to use hiddenOn decorator.`);Object.entries(d).map(([e,t])=>({key:e,props:t})).sort(e=>[n.ELEMENT,n.CHILD].includes(e.key)?-1:1).forEach(a=>{if(!a)throw new u("No decorator found");switch(a.key){case n.PROP:g[i]=a.props;break;case n.CHILD:{const r=a.props?.props?.name||i;try{if(!t.Model.isModel(t.Model.build({},r))&&!t.Model.isPropertyModel(e,r))throw new u(`Child "${r}" must be a model.`)}catch(e){throw new u(`Child "${r}" must be a model.`)}let s;const n=e[i];if("object"!=typeof n||null===n||Array.isArray(n)){const e=a.props.props?.name;s=new(t.Model.get(e))}R=R||[];const d=Object.assign({},o||{},{model:s},{inheritProps:a.props,childOf:A(o?.childOf,i)}),l=this.toFieldDefinition(n||s,d,!1),{inheritProps:c}=d;c&&(l.props=Object.assign({},l.props,c.props||{})),R.push(l);break}case n.UILISTPROP:{L=L||{};const e=a.props;e.name&&(L[e.name]="object"==typeof e?.props&&n.SEQUENCE in e.props?e.props:i);const t=Object.assign({},E.props?.item||{},m?.props||{},e?.props||{},o);g={tag:m?.tag||t.render||"",props:Object.assign({},g?.props,{mapper:L},t)};break}case n.EVENTS:case n.HIDDEN:case n.HIDE_FOR:case n.SHOW_FOR:case n.PAGE:case n.ORDER:case n.UILAYOUTPROP:case n.ELEMENT:{R=R||[];const t=a.props,d=a.key===n.HIDE_FOR?{hideFor:a.props}:a.key===n.SHOW_FOR?{showFor:a.props}:{},p=Object.assign({},g?.props,t.props||{},d,t?.props?.name?{path:A(o?.childOf,t.props.name),childOf:void 0}:{},o,{name:t.props?.name||i});if(a.key===n.ELEMENT){const a={tag:t.tag||g?.tag||f||"",props:p},o=s[i];if(o)for(const e of Object.entries(o).map(([e,t])=>({key:e,props:t})))this.isValidatableByAttribute(e.key)?a.props[this.translate(e.key)]=this.toAttributeValue(e.key,e.props):this.isValidatableByType(e.key)?(e.key===c.DATE&&(a.props[n.FORMAT]=e.props.format||l),a.props[n.TYPE]=e.key):this.isCustomValidator(e.key)&&(p[n.SUB_TYPE]=e.key,e.props?.message&&(p[n.VALIDATION_MESSAGE]=e.props.message));if(!a.props[n.TYPE]){const t=r.Metadata.type(e.constructor,i).name;a.props[n.TYPE]=this.translate(t.toLowerCase(),!0)}a.props.value=y(a.props[n.TYPE],e[i],a.props[n.FORMAT]),R.push(a)}else{const e=R.find(e=>e.props?.name===i||[n.UILAYOUTPROP,n.PAGE,n.EVENTS].includes(a.key)&&(e.props?.childOf===i||e.props?.childOf?.endsWith("."+i)));if(e)if(a.key===n.HIDE_FOR||a.key===n.SHOW_FOR)e.props=Object.assign({},e.props,d);else if(a.key!==n.UILAYOUTPROP)e.props=Object.assign({},e.props,{[a.key]:t});else{const{row:t,col:r,props:o}=a.props;e.props=Object.assign({},o||{},e.props,t,r)}}break}default:throw new u("Invalid key: "+a.key)}})}}o=Object.assign({},h,o,{handlers:M||{}});const D=new Set([...Array.isArray(o?.namespaces)?o.namespaces:[],..."string"==typeof o?.namespace?[o.namespace]:[]].filter(Boolean)),N=o?.operation;R=this.sortChildrenByOrder(R).filter(e=>{const t=e?.props?.hidden||[];if(t.length>0&&t.includes(N))return!1;const a=e?.props?.hideFor||[],r=e?.props?.showFor||[];return!(a.length>0&&[...D].some(e=>a.includes(e))||r.length>0&&![...D].some(e=>r.includes(e)))});const I={tag:f,item:g,props:o,children:R?.length?R:void 0};return s&&(I.rendererId=O(e)),I}static register(e){if(e.flavour in this.cache)throw new a.InternalError(`Rendering engine under ${e.flavour} already exists`);this.cache[e.flavour]=e,this.current=e}static getOrBoot(e){if(e instanceof T)return e;const t=new e;return t.initialize(),t}static get(e){if(!e)return this.getOrBoot(this.current);if(!(e in this.cache))throw new a.InternalError(`Rendering engine under ${e} does not exist`);return this.getOrBoot(this.cache[e])}static render(e,...r){if(!t.Model.get(e.constructor.name)&&!t.Model.fromObject(e))throw new a.InternalError("No model registered found");const o=t.Model.renderedBy(e.constructor);return T.get(o).render(e,...r)}}function R(...e){return(t,a)=>r.propMetadata(h(a,n.HIDDEN),e)(t,a)}function g(...e){return(t,a)=>r.propMetadata(h(a,n.SHOW_FOR),e)(t,a)}function L(e,t){return(a,o)=>{r.propMetadata(h(o,n.EVENTS),{..."object"==typeof e?e:{[e]:t}})(a,o)}}class A extends t.Validator{getMessage(e,...t){return A.translateService?A.translateService.translate(e,...t):super.getMessage(e,...t)}}class D extends o.LoggedClass{constructor(){super(),this.enableDarkMode=!0,this.isDarkMode=!1,this.item={tag:""},this.props={},this.route="",this.borders=!1,this.OperationKeys=a.OperationKeys,this.initialized=!1,this.events={},this.handlers={}}get repository(){return this._repository}set repository(e){this._repository=e}async render(...e){this.log.for(this.render).info(`render for ${this.componentName} with ${JSON.stringify(e)}`)}async refresh(...e){this.log.for(this.refresh).info("Refresh called with args: "+e)}async initialize(...e){this.initialized=!0}async translate(...e){this.log.for(this.translate).info(`translate for ${this.componentName} with ${JSON.stringify(e)}`)}async preview(...e){this.log.for(this.preview).debug("Preview called with args: "+e)}async submit(...e){this.log.for(this.submit).info(`submit for ${this.componentName} with ${JSON.stringify(e)}`)}parseHandlers(e,t){const a={};return Object.entries(e).forEach(([e,r])=>{if(f(r)){const o=new r,s=e in o?o[e]:o.handle;a[e]=s,t.handlers[e]=s}else a[e]=r,t.handlers[e]=r}),a}parseEvents(e,t){const a={};return Object.entries(e).forEach(([e,r])=>{const o=e,s=r();if(f(s)){const r=(new s)[e];r&&(a[o]=r,t.events[o]=r)}else a[o]=r,t.events[o]=r}),a}}class N extends o.LoggedClass{translate(e,t){this.log.for(this.translate).info(`Must translate ${e} with params ${JSON.stringify(t||{})}`)}instant(e,t){this.log.for(this.instant).info(`Must translate ${e} with params ${JSON.stringify(t||{})}`)}}function I(e,t){return(a,o)=>{const s={tag:e||a.name,props:t};return r.metadata(r.Metadata.key(n.REFLECT,n.UIMODEL),s)(a)}}function C(e){return r.apply(r.metadata(r.Metadata.key(n.REFLECT,n.RENDERED_BY),e))}function S(e,t){return(a,o)=>{const s={item:{tag:e||a.name,props:t}};return r.metadata(r.Metadata.key(n.REFLECT,n.UILISTMODEL),s)(a)}}function b(e){return t=>{const a={handlers:e};return r.metadata(r.Metadata.key(n.REFLECT,n.HANDLERS),a)(t)}}function P(t,a=1,o=1,s={}){const i=Object.assign({..."boolean"==typeof a?{flexMode:a,cols:1}:{flexMode:!1,cols:a},rows:o,...Object.assign({breakpoint:e.UIMediaBreakPoints.LARGE},s)});return(e,a)=>(r.metadata(r.Metadata.key(n.REFLECT,n.UILAYOUT),i)(e),I(t,i)(e,a))}function k(e,t=1,a=!1,r={}){let o=[];return"object"==typeof t&&(o=t,t=o.length),I(e,{pages:t,paginated:a,pageTitles:o,props:r})}t.Model.prototype.render=function(...e){return T.render(this,...e)},t.Model.renderedBy=(e=>r.Metadata.get(e,r.Metadata.key(n.REFLECT,n.RENDERED_BY))).bind(t.Model),t.Model.uiPropertiesOf=(e=>{const t=r.Metadata.get(e,r.Metadata.key(n.REFLECT,r.DecorationKeys.PROPERTIES));if(t)return Object.keys(t)}).bind(t.Model),t.Model.uiDecorationOf=(e,t,a)=>{const o=r.Metadata.get(e,r.Metadata.key(n.REFLECT,r.DecorationKeys.PROPERTIES,t));if(o)return a?o[a]:o},t.Model.uiModelOf=e=>r.Metadata.get(e,r.Metadata.key(n.REFLECT,n.UIMODEL)),t.Model.uiElementOf=(e,t)=>r.Metadata.get(e,h(t,n.ELEMENT)),t.Model.uiListModelOf=e=>r.Metadata.get(e,r.Metadata.key(n.REFLECT,n.UILISTMODEL)),t.Model.uiHandlersFor=e=>r.Metadata.get(e,r.Metadata.key(n.REFLECT,n.HANDLERS)),t.Model.uiLayoutOf=e=>r.Metadata.get(e,r.Metadata.key(n.REFLECT,n.UILAYOUT)),t.Model.uiIsHidden=(e,t)=>!!r.Metadata.get(e,h(t,n.HIDDEN)),t.Model.uiIsHiddenOn=(e,t,a)=>{const o=r.Metadata.get(e,h(t,n.HIDDEN));return!!o&&(a?o.includes(a):o)},t.Model.uiTypeOf=(e,t)=>{const o=r.Metadata.get(e,r.Metadata.key(n.REFLECT,r.DecorationKeys.PROPERTIES,t));if(!o)throw new a.NotFoundError(`No metadata found for property '${t}' on model '${e.name}'`);const s=Object.keys(o).filter(e=>[n.PROP,n.ELEMENT,n.CHILD].includes(e));if(0===s.length)throw new a.NotFoundError(`No UI type metadata found for property '${t}' on model '${e.name}'`);if(s.length>1)throw new u("Only one type of decoration is allowed. Please choose between @uiprop, @uichild or @uielement");return o[s[0]]},t.Model.uiListItems=(e=>{const t=r.Metadata.get(e,r.Metadata.key(n.REFLECT,r.DecorationKeys.PROPERTIES));if(t)return Object.keys(t)}).bind(t.Model);const w=t.ModelBuilder.prototype;var U;w.decorateClass||(w.decorateClass=function(e){return this._classDecorators||(this._classDecorators=[]),this._classDecorators.push(e),this}),w.uimodel=function(e,t){return this.decorateClass(I(e,t))},w.renderedBy=function(e){return this.decorateClass(C(e))},w.uilistmodel=function(e,t){return this.decorateClass(S(e,t))},w.uihandlers=function(e){return this.decorateClass(b(e))},w.uilayout=function(e,t,a,r){return this.decorateClass(P(e,t,a,r))},w.uisteppedmodel=function(e,t,a,r){return this.decorateClass(k(e,t,a,r))},e.DashKeys=void 0,(U=e.DashKeys||(e.DashKeys={})).ROOT="dashboard",U.COMPONENT="dashboard.component";const v=new Set;function H(e){v.add(e)}function F(e){const t=r.Metadata.constr(e);if("function"==typeof t)return t;const a=e.constructor;return"function"==typeof a?a:e}function V(t){const a=F(t);return r.Metadata.get(a,e.DashKeys.COMPONENT)}const _="##VERSION##",B="##PACKAGE##";r.Metadata.registerLibrary(B,_),e.ActionRoles=E,e.COMMIT="0285f65",e.ComponentEventNames={Render:"render",BackButtonClickEvent:"backButtonNavigationEndEvent",Refresh:"RefreshEvent",Click:"ClickEvent",Change:"ChangeEvent",Submit:"SubmitEvent",ValidationError:"validationErrorEvent",ThemeChange:"themeChangeEvent",FormGroupLoaded:"formGroupLoadedEvent"},e.DecafComponent=D,e.DecafEventHandler=class extends D{constructor(){super()}handle(...e){this.log.for(this.handle).info(`component ${this.componentName} handling ${JSON.stringify(e)}`)}handleClick(...e){this.log.for(this.handleClick).info(`component ${this.componentName} handling click ${JSON.stringify(e)}`)}handleAction(...e){this.log.for(this.handleAction).info(`component ${this.componentName} handling action ${JSON.stringify(e)}`)}},e.DecafTranslateService=N,e.ElementPositions={left:"left",center:"center",right:"right",top:"top",bottom:"bottom"},e.ElementSizes={xsmall:"xsmall",small:"small",medium:"medium",default:"default",large:"large",xLarge:"xlarge","2xLarge":"2xlarge",auto:"auto",expand:"expand",block:"block",half:"half",full:"full"},e.FULL_VERSION="0.20.8-0285f65",e.HTML5CheckTypes=p,e.HTML5DateFormat=l,e.HTML5InputTypes=c,e.LayoutGridGaps={small:"small",medium:"medium",large:"large",collapse:"collapse",none:""},e.PACKAGE_NAME=B,e.RenderingEngine=T,e.RenderingError=u,e.TransactionHooks={BeforeRead:"beforeRead",AfterRead:"afterRead",BeforeCreate:"beforeCreate",AfterCreate:"afterCreate",BeforeUpdate:"beforeUpdate",AfterUpdate:"afterUpdate",BeforeDelete:"beforeDelete",AfterDelete:"afterDelete"},e.UIKeys=n,e.UIValidator=A,e.VERSION=_,e.ValidatableByAttribute=d,e.ValidatableByType=i,e.WindowColorSchemes={light:"light",dark:"dark",undefined:"undefined"},e.dashComponentDefinitionOf=e=>{const t=F(e),a=V(t)||{},r=a.tag||t.name;return{name:t.name,tag:r,label:a.label,defaultSize:a.defaultSize??{cols:1,rows:1},model:a.model,props:a.props,metadata:a.metadata}},e.dashComponentMetadataOf=V,e.dashComponents=()=>[...v],e.dashcomponent=(t,a,o)=>r.Decoration.for(e.DashKeys.COMPONENT).define({decorator:(t,a,o)=>{const s={tag:a?.tag||t,...a,defaultSize:a?.defaultSize??{cols:1,rows:1}};return a=>{const n=r.apply(I(t,o),r.metadata(e.DashKeys.COMPONENT,s))(a);return H(a),n}},args:[t,a,o]}).apply(),e.escapeHtml=M,e.formatByType=y,e.generateUIModelID=O,e.getUIAttributeKey=h,e.hidden=()=>R(a.OperationKeys.CREATE,a.OperationKeys.READ,a.OperationKeys.UPDATE,a.OperationKeys.DELETE),e.hideFor=(...e)=>(t,a)=>r.propMetadata(h(a,n.HIDE_FOR),e)(t,a),e.hideOn=R,e.isClassConstructor=f,e.parseToNumber=m,e.parseValueByType=function e(r,o,s){let n;switch(r){case Array.name:n=(Array.isArray(o)?o.map(a=>e(t.ReservedModels.STRING.name.toLowerCase(),a,s)):[o]).join(",");break;case c.NUMBER:n=m(o);break;case c.DATE:{const e=s.format;o&&(""+o).trim().length&&(n=typeof o===t.ReservedModels.NUMBER.name.toLowerCase()?new Date(o):o?e?t.parseDate(e,o):new Date(o):void 0);break}default:n=typeof o===t.ReservedModels.OBJECT.name.toLowerCase()?Array.isArray(o)?o.join(","):JSON.stringify(o):typeof o===t.ReservedModels.BOOLEAN.name.toLowerCase()?o:typeof o===t.ReservedModels.STRING.name.toLowerCase()?M(o):n}if(void 0===n)throw new a.InternalError(`Failed to parse value of type ${r} from ${typeof o} - ${o}`);return n},e.registerDashComponent=H,e.renderIf=(...e)=>g(...e),e.renderedBy=C,e.resetDashComponentRegistry=()=>{v.clear()},e.revertHtml=e=>{const t={"&amp;":"&","&lt;":"<","&gt;":">"};return(""+e).replace(/&lt;|&gt;|&amp;/g,e=>t[e]||e)},e.showFor=g,e.uichild=(e,t,a={},o=!1,s=!1)=>(i,d)=>{const l={tag:t,serialize:s,props:Object.assign({},a||{},{name:e||d},o?{customTypes:[Array.name],multiple:!0}:{multiple:a?.multiple||!1})};r.propMetadata(h(d,n.CHILD),l)(i,d)},e.uielement=(e,t,a=!1)=>(o,s)=>{"object"==typeof e&&(t=e,e="");const i={tag:e,serialize:a,props:Object.assign({},t||{},{name:s})};return r.propMetadata(h(s,n.ELEMENT),i)(o,s)},e.uihandlers=b,e.uilayout=P,e.uilayoutprop=(e=1,t=1)=>(a,o)=>{const s={name:o,props:Object.assign({},{row:t,col:e})};r.propMetadata(h(o,n.UILAYOUTPROP),s)(a,o)},e.uilistmodel=S,e.uilistprop=(e=void 0,t)=>(a,o)=>{const s={name:e||o,props:t||{}};r.propMetadata(h(o,n.UILISTPROP),s)(a,o)},e.uimodel=I,e.uion=L,e.uionclick=e=>L("handleClick",e),e.uionrender=e=>L("render",e),e.uiorder=(e=n.FIRST)=>(t,a)=>r.propMetadata(h(a,n.ORDER),e)(t,a),e.uipageprop=(e=1)=>(t,a)=>r.propMetadata(h(a,n.PAGE),e)(t,a),e.uiprop=(e=void 0,t=!1)=>(a,o)=>{const s={name:e||o,stringify:t};r.propMetadata(h(o,n.PROP),s)(a,o)},e.uisteppedmodel=k,e.uitablecol=(e=n.LAST,t)=>(a,o)=>{const s={name:o,props:{sequence:e,...t?{valueParserFn:t}:{}}};r.propMetadata(h(o,n.UILISTPROP),s)(a,o)}},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@decaf-ts/decorator-validation"),require("@decaf-ts/db-decorators"),require("@decaf-ts/decoration"),require("@decaf-ts/logging")):"function"==typeof define&&define.amd?define(["exports","@decaf-ts/decorator-validation","@decaf-ts/db-decorators","@decaf-ts/decoration","@decaf-ts/logging"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["ui-decorators"]={},e.decafTsDecoratorValidation,e.decafTsDbDecorators,e.decafTsDecoration,e.decafTsLogging);
2
2
  //# sourceMappingURL=ui-decorators.cjs.map
package/lib/cjs/index.cjs CHANGED
@@ -34,21 +34,21 @@ __exportStar(require("./dashboard/index.cjs"), exports);
34
34
  * @const VERSION
35
35
  * @memberOf module:ui-decorators
36
36
  */
37
- exports.VERSION = "0.20.7";
37
+ exports.VERSION = "0.20.8";
38
38
  /**
39
39
  * @description Represents the current commit hash of the module build.
40
40
  * @summary Stores the current git commit hash for the package. The build replaces
41
41
  * the placeholder with the actual commit hash at publish time.
42
42
  * @const COMMIT
43
43
  */
44
- exports.COMMIT = "d286514";
44
+ exports.COMMIT = "0285f65";
45
45
  /**
46
46
  * @description Represents the full version string of the module.
47
47
  * @summary Stores the semver version and commit hash for the package.
48
48
  * The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
49
49
  * @const FULL_VERSION
50
50
  */
51
- exports.FULL_VERSION = "0.20.7-d286514";
51
+ exports.FULL_VERSION = "0.20.8-0285f65";
52
52
  exports.PACKAGE_NAME = "@decaf-ts/ui-decorators";
53
53
  decoration_1.Metadata.registerLibrary(exports.PACKAGE_NAME, exports.VERSION);
54
54
  //# sourceMappingURL=index.js.map
package/lib/esm/index.js CHANGED
@@ -17,21 +17,21 @@ export * from "./dashboard/index.js";
17
17
  * @const VERSION
18
18
  * @memberOf module:ui-decorators
19
19
  */
20
- export const VERSION = "0.20.7";
20
+ export const VERSION = "0.20.8";
21
21
  /**
22
22
  * @description Represents the current commit hash of the module build.
23
23
  * @summary Stores the current git commit hash for the package. The build replaces
24
24
  * the placeholder with the actual commit hash at publish time.
25
25
  * @const COMMIT
26
26
  */
27
- export const COMMIT = "d286514";
27
+ export const COMMIT = "0285f65";
28
28
  /**
29
29
  * @description Represents the full version string of the module.
30
30
  * @summary Stores the semver version and commit hash for the package.
31
31
  * The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
32
32
  * @const FULL_VERSION
33
33
  */
34
- export const FULL_VERSION = "0.20.7-d286514";
34
+ export const FULL_VERSION = "0.20.8-0285f65";
35
35
  export const PACKAGE_NAME = "@decaf-ts/ui-decorators";
36
36
  Metadata.registerLibrary(PACKAGE_NAME, VERSION);
37
37
  //# sourceMappingURL=index.js.map
@@ -2,6 +2,21 @@ import type { GraphInputBinding, GraphOutputBinding } from "./GraphNodeBinding.d
2
2
  import type { GraphJsonValue } from "./GraphJsonValue.d.cts";
3
3
  import type { GraphLoopConfiguration } from "./GraphLoopConfiguration.d.cts";
4
4
  import type { GraphNodeUiState } from "./GraphWorkflowUiState.d.cts";
5
+ /**
6
+ * Document-carried UI data-pinning state (D4, DECAF-50 §4.22). Data pinning
7
+ * freezes the node's parameter values so downstream runs reuse them, and is a
8
+ * distinct concept from the engine's cache pinning (`GraphPinning`): this state is
9
+ * written into the canonical document and survives save/load round-trips.
10
+ */
11
+ export interface GraphNodePinState {
12
+ /**
13
+ * Parameter values frozen when the node was pinned. Downstream runs apply this
14
+ * snapshot on top of the node's live parameters.
15
+ */
16
+ parameters: Record<string, GraphJsonValue>;
17
+ /** ISO-8601 timestamp of when the pin was captured, when known. */
18
+ pinnedAt?: string;
19
+ }
5
20
  export interface GraphNodeInstance {
6
21
  id: string;
7
22
  kind: string;
@@ -13,4 +28,9 @@ export interface GraphNodeInstance {
13
28
  metadata?: Record<string, GraphJsonValue>;
14
29
  loop?: GraphLoopConfiguration;
15
30
  ui?: GraphNodeUiState;
31
+ /**
32
+ * UI data-pinning state (D4, DECAF-50 §4.22). Present iff the node is
33
+ * pinned; the frozen parameter snapshot is what downstream runs reuse.
34
+ */
35
+ pinned?: GraphNodePinState;
16
36
  }
@@ -2,6 +2,21 @@ import type { GraphInputBinding, GraphOutputBinding } from "./GraphNodeBinding.d
2
2
  import type { GraphJsonValue } from "./GraphJsonValue.d.mts";
3
3
  import type { GraphLoopConfiguration } from "./GraphLoopConfiguration.d.mts";
4
4
  import type { GraphNodeUiState } from "./GraphWorkflowUiState.d.mts";
5
+ /**
6
+ * Document-carried UI data-pinning state (D4, DECAF-50 §4.22). Data pinning
7
+ * freezes the node's parameter values so downstream runs reuse them, and is a
8
+ * distinct concept from the engine's cache pinning (`GraphPinning`): this state is
9
+ * written into the canonical document and survives save/load round-trips.
10
+ */
11
+ export interface GraphNodePinState {
12
+ /**
13
+ * Parameter values frozen when the node was pinned. Downstream runs apply this
14
+ * snapshot on top of the node's live parameters.
15
+ */
16
+ parameters: Record<string, GraphJsonValue>;
17
+ /** ISO-8601 timestamp of when the pin was captured, when known. */
18
+ pinnedAt?: string;
19
+ }
5
20
  export interface GraphNodeInstance {
6
21
  id: string;
7
22
  kind: string;
@@ -13,4 +28,9 @@ export interface GraphNodeInstance {
13
28
  metadata?: Record<string, GraphJsonValue>;
14
29
  loop?: GraphLoopConfiguration;
15
30
  ui?: GraphNodeUiState;
31
+ /**
32
+ * UI data-pinning state (D4, DECAF-50 §4.22). Present iff the node is
33
+ * pinned; the frozen parameter snapshot is what downstream runs reuse.
34
+ */
35
+ pinned?: GraphNodePinState;
16
36
  }
@@ -16,19 +16,19 @@ export * from "./dashboard/index.d.cts";
16
16
  * @const VERSION
17
17
  * @memberOf module:ui-decorators
18
18
  */
19
- export declare const VERSION = "0.20.7";
19
+ export declare const VERSION = "0.20.8";
20
20
  /**
21
21
  * @description Represents the current commit hash of the module build.
22
22
  * @summary Stores the current git commit hash for the package. The build replaces
23
23
  * the placeholder with the actual commit hash at publish time.
24
24
  * @const COMMIT
25
25
  */
26
- export declare const COMMIT = "d286514";
26
+ export declare const COMMIT = "0285f65";
27
27
  /**
28
28
  * @description Represents the full version string of the module.
29
29
  * @summary Stores the semver version and commit hash for the package.
30
30
  * The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
31
31
  * @const FULL_VERSION
32
32
  */
33
- export declare const FULL_VERSION = "0.20.7-d286514";
33
+ export declare const FULL_VERSION = "0.20.8-0285f65";
34
34
  export declare const PACKAGE_NAME = "@decaf-ts/ui-decorators";
@@ -16,19 +16,19 @@ export * from "./dashboard/index.d.mts";
16
16
  * @const VERSION
17
17
  * @memberOf module:ui-decorators
18
18
  */
19
- export declare const VERSION = "0.20.7";
19
+ export declare const VERSION = "0.20.8";
20
20
  /**
21
21
  * @description Represents the current commit hash of the module build.
22
22
  * @summary Stores the current git commit hash for the package. The build replaces
23
23
  * the placeholder with the actual commit hash at publish time.
24
24
  * @const COMMIT
25
25
  */
26
- export declare const COMMIT = "d286514";
26
+ export declare const COMMIT = "0285f65";
27
27
  /**
28
28
  * @description Represents the full version string of the module.
29
29
  * @summary Stores the semver version and commit hash for the package.
30
30
  * The build replaces the placeholder with the actual `<version>-<commit>` value at publish time.
31
31
  * @const FULL_VERSION
32
32
  */
33
- export declare const FULL_VERSION = "0.20.7-d286514";
33
+ export declare const FULL_VERSION = "0.20.8-0285f65";
34
34
  export declare const PACKAGE_NAME = "@decaf-ts/ui-decorators";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decaf-ts/ui-decorators",
3
- "version": "0.20.8",
3
+ "version": "0.20.9",
4
4
  "description": "Extension of decorator validation to ui elements to allow for web integration",
5
5
  "type": "module",
6
6
  "exports": {