diff --git a/docs/ng-signal-demo/404.html b/docs/ng-signal-demo/404.html index 1169189..f647426 100644 --- a/docs/ng-signal-demo/404.html +++ b/docs/ng-signal-demo/404.html @@ -10,5 +10,5 @@ - + diff --git a/docs/ng-signal-demo/chunk-732D6KLU.js b/docs/ng-signal-demo/chunk-732D6KLU.js new file mode 100644 index 0000000..c86075c --- /dev/null +++ b/docs/ng-signal-demo/chunk-732D6KLU.js @@ -0,0 +1 @@ +import{$ as P,Aa as u,Ca as G,Fa as Z,Ha as h,Na as K,Pa as X,Q as m,R as y,S as O,U as f,X as N,Xa as j,Z as b,a as l,aa as c,b as d,db as v,ga as x,ja as A,lb as Y,m as W,pa as k,qa as M,qb as J,s as q,sb as Q,tb as _,x as z,xb as T}from"./chunk-E2VPYGYD.js";var de=(()=>{let e=class e{constructor(i,r){this._renderer=i,this._elementRef=r,this.onChange=s=>{},this.onTouched=()=>{}}setProperty(i,r){this._renderer.setProperty(this._elementRef.nativeElement,i,r)}registerOnTouched(i){this.onTouched=i}registerOnChange(i){this.onChange=i}setDisabledState(i){this.setProperty("disabled",i)}};e.\u0275fac=function(r){return new(r||e)(u(G),u(k))},e.\u0275dir=c({type:e});let t=e;return t})(),ce=(()=>{let e=class e extends de{};e.\u0275fac=(()=>{let i;return function(s){return(i||(i=A(e)))(s||e)}})(),e.\u0275dir=c({type:e,features:[h]});let t=e;return t})(),L=new f("");var Me={provide:L,useExisting:m(()=>he),multi:!0};function Ee(){let t=T()?T().getUserAgent():"";return/android (\d+)/.test(t.toLowerCase())}var Fe=new f(""),he=(()=>{let e=class e extends de{constructor(i,r,s){super(i,r),this._compositionMode=s,this._composing=!1,this._compositionMode==null&&(this._compositionMode=!Ee())}writeValue(i){let r=i??"";this.setProperty("value",r)}_handleInput(i){(!this._compositionMode||this._compositionMode&&!this._composing)&&this.onChange(i)}_compositionStart(){this._composing=!0}_compositionEnd(i){this._composing=!1,this._compositionMode&&this.onChange(i)}};e.\u0275fac=function(r){return new(r||e)(u(G),u(k),u(Fe,8))},e.\u0275dir=c({type:e,selectors:[["input","formControlName","",3,"type","checkbox"],["textarea","formControlName",""],["input","formControl","",3,"type","checkbox"],["textarea","formControl",""],["input","ngModel","",3,"type","checkbox"],["textarea","ngModel",""],["","ngDefaultControl",""]],hostBindings:function(r,s){r&1&&j("input",function(a){return s._handleInput(a.target.value)})("blur",function(){return s.onTouched()})("compositionstart",function(){return s._compositionStart()})("compositionend",function(a){return s._compositionEnd(a.target.value)})},features:[v([Me]),h]});let t=e;return t})();function ee(t){return t==null||(typeof t=="string"||Array.isArray(t))&&t.length===0}var fe=new f(""),we=new f("");function Ie(t){return e=>{if(ee(e.value)||ee(t))return null;let n=parseFloat(e.value);return!isNaN(n)&&n{e=n!=null?l(l({},e),n):e}),Object.keys(e).length===0?null:e}function ye(t,e){return e.map(n=>n(t))}function Se(t){return!t.validate}function ve(t){return t.map(e=>Se(e)?e:n=>e.validate(n))}function Oe(t){if(!t)return null;let e=t.filter(pe);return e.length==0?null:function(n){return me(ye(n,e))}}function _e(t){return t!=null?Oe(ve(t)):null}function Ne(t){if(!t)return null;let e=t.filter(pe);return e.length==0?null:function(n){let i=ye(n,e).map(ge);return z(i).pipe(q(me))}}function Ce(t){return t!=null?Ne(ve(t)):null}function ie(t,e){return t===null?[e]:Array.isArray(t)?[...t,e]:[t,e]}function Pe(t){return t._rawValidators}function xe(t){return t._rawAsyncValidators}function U(t){return t?Array.isArray(t)?t:[t]:[]}function F(t,e){return Array.isArray(t)?t.includes(e):t===e}function ne(t,e){let n=U(e);return U(t).forEach(r=>{F(n,r)||n.push(r)}),n}function re(t,e){return U(e).filter(n=>!F(t,n))}var w=class{constructor(){this._rawValidators=[],this._rawAsyncValidators=[],this._onDestroyCallbacks=[]}get value(){return this.control?this.control.value:null}get valid(){return this.control?this.control.valid:null}get invalid(){return this.control?this.control.invalid:null}get pending(){return this.control?this.control.pending:null}get disabled(){return this.control?this.control.disabled:null}get enabled(){return this.control?this.control.enabled:null}get errors(){return this.control?this.control.errors:null}get pristine(){return this.control?this.control.pristine:null}get dirty(){return this.control?this.control.dirty:null}get touched(){return this.control?this.control.touched:null}get status(){return this.control?this.control.status:null}get untouched(){return this.control?this.control.untouched:null}get statusChanges(){return this.control?this.control.statusChanges:null}get valueChanges(){return this.control?this.control.valueChanges:null}get path(){return null}_setValidators(e){this._rawValidators=e||[],this._composedValidatorFn=_e(this._rawValidators)}_setAsyncValidators(e){this._rawAsyncValidators=e||[],this._composedAsyncValidatorFn=Ce(this._rawAsyncValidators)}get validator(){return this._composedValidatorFn||null}get asyncValidator(){return this._composedAsyncValidatorFn||null}_registerOnDestroy(e){this._onDestroyCallbacks.push(e)}_invokeOnDestroyCallbacks(){this._onDestroyCallbacks.forEach(e=>e()),this._onDestroyCallbacks=[]}reset(e=void 0){this.control&&this.control.reset(e)}hasError(e,n){return this.control?this.control.hasError(e,n):!1}getError(e,n){return this.control?this.control.getError(e,n):null}},B=class extends w{get formDirective(){return null}get path(){return null}},D=class extends w{constructor(){super(...arguments),this._parent=null,this.name=null,this.valueAccessor=null}},R=class{constructor(e){this._cd=e}get isTouched(){return!!this._cd?.control?.touched}get isUntouched(){return!!this._cd?.control?.untouched}get isPristine(){return!!this._cd?.control?.pristine}get isDirty(){return!!this._cd?.control?.dirty}get isValid(){return!!this._cd?.control?.valid}get isInvalid(){return!!this._cd?.control?.invalid}get isPending(){return!!this._cd?.control?.pending}get isSubmitted(){return!!this._cd?.submitted}},ke={"[class.ng-untouched]":"isUntouched","[class.ng-touched]":"isTouched","[class.ng-pristine]":"isPristine","[class.ng-dirty]":"isDirty","[class.ng-valid]":"isValid","[class.ng-invalid]":"isInvalid","[class.ng-pending]":"isPending"},Ft=d(l({},ke),{"[class.ng-submitted]":"isSubmitted"}),wt=(()=>{let e=class e extends R{constructor(i){super(i)}};e.\u0275fac=function(r){return new(r||e)(u(D,2))},e.\u0275dir=c({type:e,selectors:[["","formControlName",""],["","ngModel",""],["","formControl",""]],hostVars:14,hostBindings:function(r,s){r&2&&X("ng-untouched",s.isUntouched)("ng-touched",s.isTouched)("ng-pristine",s.isPristine)("ng-dirty",s.isDirty)("ng-valid",s.isValid)("ng-invalid",s.isInvalid)("ng-pending",s.isPending)},features:[h]});let t=e;return t})();var C="VALID",E="INVALID",p="PENDING",V="DISABLED";function Ge(t){return(I(t)?t.validators:t)||null}function je(t){return Array.isArray(t)?_e(t):t||null}function Te(t,e){return(I(e)?e.asyncValidators:t)||null}function Ue(t){return Array.isArray(t)?Ce(t):t||null}function I(t){return t!=null&&!Array.isArray(t)&&typeof t=="object"}var H=class{constructor(e,n){this._pendingDirty=!1,this._hasOwnPendingAsyncValidator=!1,this._pendingTouched=!1,this._onCollectionChange=()=>{},this._parent=null,this.pristine=!0,this.touched=!1,this._onDisabledChange=[],this._assignValidators(e),this._assignAsyncValidators(n)}get validator(){return this._composedValidatorFn}set validator(e){this._rawValidators=this._composedValidatorFn=e}get asyncValidator(){return this._composedAsyncValidatorFn}set asyncValidator(e){this._rawAsyncValidators=this._composedAsyncValidatorFn=e}get parent(){return this._parent}get valid(){return this.status===C}get invalid(){return this.status===E}get pending(){return this.status==p}get disabled(){return this.status===V}get enabled(){return this.status!==V}get dirty(){return!this.pristine}get untouched(){return!this.touched}get updateOn(){return this._updateOn?this._updateOn:this.parent?this.parent.updateOn:"change"}setValidators(e){this._assignValidators(e)}setAsyncValidators(e){this._assignAsyncValidators(e)}addValidators(e){this.setValidators(ne(e,this._rawValidators))}addAsyncValidators(e){this.setAsyncValidators(ne(e,this._rawAsyncValidators))}removeValidators(e){this.setValidators(re(e,this._rawValidators))}removeAsyncValidators(e){this.setAsyncValidators(re(e,this._rawAsyncValidators))}hasValidator(e){return F(this._rawValidators,e)}hasAsyncValidator(e){return F(this._rawAsyncValidators,e)}clearValidators(){this.validator=null}clearAsyncValidators(){this.asyncValidator=null}markAsTouched(e={}){this.touched=!0,this._parent&&!e.onlySelf&&this._parent.markAsTouched(e)}markAllAsTouched(){this.markAsTouched({onlySelf:!0}),this._forEachChild(e=>e.markAllAsTouched())}markAsUntouched(e={}){this.touched=!1,this._pendingTouched=!1,this._forEachChild(n=>{n.markAsUntouched({onlySelf:!0})}),this._parent&&!e.onlySelf&&this._parent._updateTouched(e)}markAsDirty(e={}){this.pristine=!1,this._parent&&!e.onlySelf&&this._parent.markAsDirty(e)}markAsPristine(e={}){this.pristine=!0,this._pendingDirty=!1,this._forEachChild(n=>{n.markAsPristine({onlySelf:!0})}),this._parent&&!e.onlySelf&&this._parent._updatePristine(e)}markAsPending(e={}){this.status=p,e.emitEvent!==!1&&this.statusChanges.emit(this.status),this._parent&&!e.onlySelf&&this._parent.markAsPending(e)}disable(e={}){let n=this._parentMarkedDirty(e.onlySelf);this.status=V,this.errors=null,this._forEachChild(i=>{i.disable(d(l({},e),{onlySelf:!0}))}),this._updateValue(),e.emitEvent!==!1&&(this.valueChanges.emit(this.value),this.statusChanges.emit(this.status)),this._updateAncestors(d(l({},e),{skipPristineCheck:n})),this._onDisabledChange.forEach(i=>i(!0))}enable(e={}){let n=this._parentMarkedDirty(e.onlySelf);this.status=C,this._forEachChild(i=>{i.enable(d(l({},e),{onlySelf:!0}))}),this.updateValueAndValidity({onlySelf:!0,emitEvent:e.emitEvent}),this._updateAncestors(d(l({},e),{skipPristineCheck:n})),this._onDisabledChange.forEach(i=>i(!1))}_updateAncestors(e){this._parent&&!e.onlySelf&&(this._parent.updateValueAndValidity(e),e.skipPristineCheck||this._parent._updatePristine(),this._parent._updateTouched())}setParent(e){this._parent=e}getRawValue(){return this.value}updateValueAndValidity(e={}){this._setInitialStatus(),this._updateValue(),this.enabled&&(this._cancelExistingSubscription(),this.errors=this._runValidator(),this.status=this._calculateStatus(),(this.status===C||this.status===p)&&this._runAsyncValidator(e.emitEvent)),e.emitEvent!==!1&&(this.valueChanges.emit(this.value),this.statusChanges.emit(this.status)),this._parent&&!e.onlySelf&&this._parent.updateValueAndValidity(e)}_updateTreeValidity(e={emitEvent:!0}){this._forEachChild(n=>n._updateTreeValidity(e)),this.updateValueAndValidity({onlySelf:!0,emitEvent:e.emitEvent})}_setInitialStatus(){this.status=this._allControlsDisabled()?V:C}_runValidator(){return this.validator?this.validator(this):null}_runAsyncValidator(e){if(this.asyncValidator){this.status=p,this._hasOwnPendingAsyncValidator=!0;let n=ge(this.asyncValidator(this));this._asyncValidationSubscription=n.subscribe(i=>{this._hasOwnPendingAsyncValidator=!1,this.setErrors(i,{emitEvent:e})})}}_cancelExistingSubscription(){this._asyncValidationSubscription&&(this._asyncValidationSubscription.unsubscribe(),this._hasOwnPendingAsyncValidator=!1)}setErrors(e,n={}){this.errors=e,this._updateControlsErrors(n.emitEvent!==!1)}get(e){let n=e;return n==null||(Array.isArray(n)||(n=n.split(".")),n.length===0)?null:n.reduce((i,r)=>i&&i._find(r),this)}getError(e,n){let i=n?this.get(n):this;return i&&i.errors?i.errors[e]:null}hasError(e,n){return!!this.getError(e,n)}get root(){let e=this;for(;e._parent;)e=e._parent;return e}_updateControlsErrors(e){this.status=this._calculateStatus(),e&&this.statusChanges.emit(this.status),this._parent&&this._parent._updateControlsErrors(e)}_initObservables(){this.valueChanges=new M,this.statusChanges=new M}_calculateStatus(){return this._allControlsDisabled()?V:this.errors?E:this._hasOwnPendingAsyncValidator||this._anyControlsHaveStatus(p)?p:this._anyControlsHaveStatus(E)?E:C}_anyControlsHaveStatus(e){return this._anyControls(n=>n.status===e)}_anyControlsDirty(){return this._anyControls(e=>e.dirty)}_anyControlsTouched(){return this._anyControls(e=>e.touched)}_updatePristine(e={}){this.pristine=!this._anyControlsDirty(),this._parent&&!e.onlySelf&&this._parent._updatePristine(e)}_updateTouched(e={}){this.touched=this._anyControlsTouched(),this._parent&&!e.onlySelf&&this._parent._updateTouched(e)}_registerOnCollectionChange(e){this._onCollectionChange=e}_setUpdateStrategy(e){I(e)&&e.updateOn!=null&&(this._updateOn=e.updateOn)}_parentMarkedDirty(e){let n=this._parent&&this._parent.dirty;return!e&&!!n&&!this._parent._anyControlsDirty()}_find(e){return null}_assignValidators(e){this._rawValidators=Array.isArray(e)?e.slice():e,this._composedValidatorFn=je(this._rawValidators)}_assignAsyncValidators(e){this._rawAsyncValidators=Array.isArray(e)?e.slice():e,this._composedAsyncValidatorFn=Ue(this._rawAsyncValidators)}};var Ve=new f("CallSetDisabledState",{providedIn:"root",factory:()=>$}),$="always";function Be(t,e){return[...e.path,t]}function Re(t,e,n=$){Le(t,e),e.valueAccessor.writeValue(t.value),(t.disabled||n==="always")&&e.valueAccessor.setDisabledState?.(t.disabled),$e(t,e),qe(t,e),We(t,e),He(t,e)}function se(t,e){t.forEach(n=>{n.registerOnValidatorChange&&n.registerOnValidatorChange(e)})}function He(t,e){if(e.valueAccessor.setDisabledState){let n=i=>{e.valueAccessor.setDisabledState(i)};t.registerOnDisabledChange(n),e._registerOnDestroy(()=>{t._unregisterOnDisabledChange(n)})}}function Le(t,e){let n=Pe(t);e.validator!==null?t.setValidators(ie(n,e.validator)):typeof n=="function"&&t.setValidators([n]);let i=xe(t);e.asyncValidator!==null?t.setAsyncValidators(ie(i,e.asyncValidator)):typeof i=="function"&&t.setAsyncValidators([i]);let r=()=>t.updateValueAndValidity();se(e._rawValidators,r),se(e._rawAsyncValidators,r)}function $e(t,e){e.valueAccessor.registerOnChange(n=>{t._pendingValue=n,t._pendingChange=!0,t._pendingDirty=!0,t.updateOn==="change"&&De(t,e)})}function We(t,e){e.valueAccessor.registerOnTouched(()=>{t._pendingTouched=!0,t.updateOn==="blur"&&t._pendingChange&&De(t,e),t.updateOn!=="submit"&&t.markAsTouched()})}function De(t,e){t._pendingDirty&&t.markAsDirty(),t.setValue(t._pendingValue,{emitModelToViewChange:!1}),e.viewToModelUpdate(t._pendingValue),t._pendingChange=!1}function qe(t,e){let n=(i,r)=>{e.valueAccessor.writeValue(i),r&&e.viewToModelUpdate(i)};t.registerOnChange(n),e._registerOnDestroy(()=>{t._unregisterOnChange(n)})}function ze(t,e){if(!t.hasOwnProperty("model"))return!1;let n=t.model;return n.isFirstChange()?!0:!Object.is(e,n.currentValue)}function Ze(t){return Object.getPrototypeOf(t.constructor)===ce}function Ke(t,e){if(!e)return null;Array.isArray(e);let n,i,r;return e.forEach(s=>{s.constructor===he?n=s:Ze(s)?i=s:r=s}),r||i||n||null}function oe(t,e){let n=t.indexOf(e);n>-1&&t.splice(n,1)}function ae(t){return typeof t=="object"&&t!==null&&Object.keys(t).length===2&&"value"in t&&"disabled"in t}var Xe=class extends H{constructor(e=null,n,i){super(Ge(n),Te(i,n)),this.defaultValue=null,this._onChange=[],this._pendingChange=!1,this._applyFormState(e),this._setUpdateStrategy(n),this._initObservables(),this.updateValueAndValidity({onlySelf:!0,emitEvent:!!this.asyncValidator}),I(n)&&(n.nonNullable||n.initialValueIsDefault)&&(ae(e)?this.defaultValue=e.value:this.defaultValue=e)}setValue(e,n={}){this.value=this._pendingValue=e,this._onChange.length&&n.emitModelToViewChange!==!1&&this._onChange.forEach(i=>i(this.value,n.emitViewToModelChange!==!1)),this.updateValueAndValidity(n)}patchValue(e,n={}){this.setValue(e,n)}reset(e=this.defaultValue,n={}){this._applyFormState(e),this.markAsPristine(n),this.markAsUntouched(n),this.setValue(this.value,n),this._pendingChange=!1}_updateValue(){}_anyControls(e){return!1}_allControlsDisabled(){return this.disabled}registerOnChange(e){this._onChange.push(e)}_unregisterOnChange(e){oe(this._onChange,e)}registerOnDisabledChange(e){this._onDisabledChange.push(e)}_unregisterOnDisabledChange(e){oe(this._onDisabledChange,e)}_forEachChild(e){}_syncPendingControls(){return this.updateOn==="submit"&&(this._pendingDirty&&this.markAsDirty(),this._pendingTouched&&this.markAsTouched(),this._pendingChange)?(this.setValue(this._pendingValue,{onlySelf:!0,emitModelToViewChange:!1}),!0):!1}_applyFormState(e){ae(e)?(this.value=this._pendingValue=e.value,e.disabled?this.disable({onlySelf:!0,emitEvent:!1}):this.enable({onlySelf:!0,emitEvent:!1})):this.value=this._pendingValue=e}};var Ye={provide:D,useExisting:m(()=>Je)},le=Promise.resolve(),Je=(()=>{let e=class e extends D{constructor(i,r,s,o,a,g){super(),this._changeDetectorRef=a,this.callSetDisabledState=g,this.control=new Xe,this._registered=!1,this.name="",this.update=new M,this._parent=i,this._setValidators(r),this._setAsyncValidators(s),this.valueAccessor=Ke(this,o)}ngOnChanges(i){if(this._checkForErrors(),!this._registered||"name"in i){if(this._registered&&(this._checkName(),this.formDirective)){let r=i.name.previousValue;this.formDirective.removeControl({name:r,path:this._getPath(r)})}this._setUpControl()}"isDisabled"in i&&this._updateDisabled(i),ze(i,this.viewModel)&&(this._updateValue(this.model),this.viewModel=this.model)}ngOnDestroy(){this.formDirective&&this.formDirective.removeControl(this)}get path(){return this._getPath(this.name)}get formDirective(){return this._parent?this._parent.formDirective:null}viewToModelUpdate(i){this.viewModel=i,this.update.emit(i)}_setUpControl(){this._setUpdateStrategy(),this._isStandalone()?this._setUpStandalone():this.formDirective.addControl(this),this._registered=!0}_setUpdateStrategy(){this.options&&this.options.updateOn!=null&&(this.control._updateOn=this.options.updateOn)}_isStandalone(){return!this._parent||!!(this.options&&this.options.standalone)}_setUpStandalone(){Re(this.control,this,this.callSetDisabledState),this.control.updateValueAndValidity({emitEvent:!1})}_checkForErrors(){this._isStandalone()||this._checkParentType(),this._checkName()}_checkParentType(){}_checkName(){this.options&&this.options.name&&(this.name=this.options.name),!this._isStandalone()&&this.name}_updateValue(i){le.then(()=>{this.control.setValue(i,{emitViewToModelChange:!1}),this._changeDetectorRef?.markForCheck()})}_updateDisabled(i){let r=i.isDisabled.currentValue,s=r!==0&&Q(r);le.then(()=>{s&&!this.control.disabled?this.control.disable():!s&&this.control.disabled&&this.control.enable(),this._changeDetectorRef?.markForCheck()})}_getPath(i){return this._parent?Be(i,this._parent):[i]}};e.\u0275fac=function(r){return new(r||e)(u(B,9),u(fe,10),u(we,10),u(L,10),u(J,8),u(Ve,8))},e.\u0275dir=c({type:e,selectors:[["","ngModel","",3,"formControlName","",3,"formControl",""]],inputs:{name:"name",isDisabled:[b.None,"disabled","isDisabled"],model:[b.None,"ngModel","model"],options:[b.None,"ngModelOptions","options"]},outputs:{update:"ngModelChange"},exportAs:["ngModel"],features:[v([Ye]),h,x]});let t=e;return t})();var Qe={provide:L,useExisting:m(()=>et),multi:!0},et=(()=>{let e=class e extends ce{writeValue(i){let r=i??"";this.setProperty("value",r)}registerOnChange(i){this.onChange=r=>{i(r==""?null:parseFloat(r))}}};e.\u0275fac=(()=>{let i;return function(s){return(i||(i=A(e)))(s||e)}})(),e.\u0275dir=c({type:e,selectors:[["input","type","number","formControlName",""],["input","type","number","formControl",""],["input","type","number","ngModel",""]],hostBindings:function(r,s){r&1&&j("input",function(a){return s.onChange(a.target.value)})("blur",function(){return s.onTouched()})},features:[v([Qe]),h]});let t=e;return t})();function tt(t){return typeof t=="number"?t:parseFloat(t)}var it=(()=>{let e=class e{constructor(){this._validator=te}ngOnChanges(i){if(this.inputName in i){let r=this.normalizeInput(i[this.inputName].currentValue);this._enabled=this.enabled(r),this._validator=this._enabled?this.createValidator(r):te,this._onChange&&this._onChange()}}validate(i){return this._validator(i)}registerOnValidatorChange(i){this._onChange=i}enabled(i){return i!=null}};e.\u0275fac=function(r){return new(r||e)},e.\u0275dir=c({type:e,features:[x]});let t=e;return t})();var nt={provide:fe,useExisting:m(()=>rt),multi:!0},rt=(()=>{let e=class e extends it{constructor(){super(...arguments),this.inputName="min",this.normalizeInput=i=>tt(i),this.createValidator=i=>Ie(i)}};e.\u0275fac=(()=>{let i;return function(s){return(i||(i=A(e)))(s||e)}})(),e.\u0275dir=c({type:e,selectors:[["input","type","number","min","","formControlName",""],["input","type","number","min","","formControl",""],["input","type","number","min","","ngModel",""]],hostVars:1,hostBindings:function(r,s){r&2&&K("min",s._enabled?s.min:null)},inputs:{min:"min"},features:[v([nt]),h]});let t=e;return t})();var st=(()=>{let e=class e{};e.\u0275fac=function(r){return new(r||e)},e.\u0275mod=P({type:e}),e.\u0275inj=O({});let t=e;return t})();var St=(()=>{let e=class e{static withConfig(i){return{ngModule:e,providers:[{provide:Ve,useValue:i.callSetDisabledState??$}]}}};e.\u0275fac=function(r){return new(r||e)},e.\u0275mod=P({type:e}),e.\u0275inj=O({imports:[st]});let t=e;return t})();var ot={promoCode:"",cart:[]};function at(t,e,n){return n<=0?t.filter(i=>i.id!==e):t.map(i=>i.id===e?d(l({},i),{quantity:n}):i)}function lt(t,e,n,i){return e>=0?t.map((r,s)=>s===e?d(l({},r),{quantity:r.quantity+i}):r):[...t,d(l({},n),{quantity:i})]}var be=(()=>{let e=class e{constructor(){this.state=Z(ot),this.cart=_(()=>this.state().cart),this.promoCode=_(()=>this.state().promoCode),this.discountPercent=_(()=>this.promoCode()==="DEVFESTHK2023"?.1:this.promoCode()==="ANGULARNATION"?.2:0),this.summary=_(()=>{let i=this.state().cart.reduce(({quantity:g,subtotal:Ae},S)=>({quantity:g+S.quantity,subtotal:Ae+S.price*S.quantity}),{quantity:0,subtotal:0}),{subtotal:r,quantity:s}=i,o=r*this.discountPercent(),a=r-o;return{quantity:s,subtotal:r.toFixed(2),discount:o.toFixed(2),total:a.toFixed(2)}})}updatePromoCode(i){this.state.update(r=>d(l({},r),{promoCode:i}))}buy(i,r,s){this.state.update(({cart:o,promoCode:a})=>{let g=lt(o,i,r,s);return{promoCode:a,cart:g}})}update(i,r){this.state.update(({promoCode:s,cart:o})=>{let a=at(o,i,r);return{promoCode:s,cart:a}})}};e.\u0275fac=function(r){return new(r||e)},e.\u0275prov=y({token:e,factory:e.\u0275fac,providedIn:"root"});let t=e;return t})();var Bt=(()=>{let e=class e{constructor(){this.store=N(be)}get cart(){return this.store.cart}get discountPercent(){return this.store.discountPercent}get summary(){return this.store.summary}get promoCode(){return this.store.promoCode}updatePromoCode(i){this.store.updatePromoCode(i)}addCart(i,r,s){this.store.buy(i,r,s)}deleteCart(i){this.store.update(i,0)}updateCart(i,r){this.store.update(i,r)}};e.\u0275fac=function(r){return new(r||e)},e.\u0275prov=y({token:e,factory:e.\u0275fac,providedIn:"root"});let t=e;return t})();export{he as a,wt as b,Je as c,et as d,rt as e,St as f,Bt as g}; diff --git a/docs/ng-signal-demo/chunk-AWFTDC7C.js b/docs/ng-signal-demo/chunk-AWFTDC7C.js deleted file mode 100644 index 1726a91..0000000 --- a/docs/ng-signal-demo/chunk-AWFTDC7C.js +++ /dev/null @@ -1 +0,0 @@ -import{a as M,b as w,c as F,d as Q,e as X,f as P,g}from"./chunk-TSULXMNV.js";import{$a as u,Fa as O,Ga as V,Gb as L,Ma as _,Oa as A,Qa as h,Ra as W,Sa as B,Ta as e,Ua as n,Va as I,Wa as N,X as c,Xa as f,Ya as s,Z as b,Za as i,_ as p,_a as y,ab as x,bb as v,cb as S,eb as C,ha as T,hb as j,ia as D,jb as U,oa as k,za as l}from"./chunk-E2VPYGYD.js";var z=(()=>{let t=class t{constructor(){this.cartFacade=c(g),this.item=k.required(),this.quantity=V(0)}delete(m){return this.cartFacade.deleteCart(m)}update(m,o){return this.cartFacade.updateCart(m,o)}};t.\u0275fac=function(o){return new(o||t)},t.\u0275cmp=p({type:t,selectors:[["app-cart-item"]],inputs:{item:[b.SignalBased,"item"],quantity:[b.SignalBased,"quantity"]},outputs:{quantity:"quantityChange"},standalone:!0,features:[C],decls:16,vars:5,consts:[[1,"row"],[2,"width","10%"],[2,"width","20%"],[2,"width","40%"],["type","number","min","1",2,"width","50px",3,"ngModelChange","ngModel"],[1,"btnUpdate",3,"click"],[3,"click"]],template:function(o,r){o&1&&(e(0,"div",0)(1,"p",1),i(2),n(),e(3,"p",2),i(4),n(),e(5,"p",3),i(6),n(),e(7,"p",1),i(8),n(),e(9,"p",1)(10,"input",4),S("ngModelChange",function(E){return v(r.quantity,E)||(r.quantity=E),E}),n()(),e(11,"p",1)(12,"button",5),f("click",function(){return r.update(r.item().id,r.quantity())}),i(13,"Update"),n(),e(14,"button",6),f("click",function(){return r.delete(r.item().id)}),i(15,"X"),n()()()),o&2&&(l(2),y(r.item().id),l(2),y(r.item().title),l(2),y(r.item().description),l(2),y(r.item().price),l(2),x("ngModel",r.quantity))},dependencies:[P,M,Q,w,X,F],styles:[".row[_ngcontent-%COMP%]{display:flex}.row[_ngcontent-%COMP%] > p[_ngcontent-%COMP%]{border:1px solid black}.btnUpdate[_ngcontent-%COMP%]{margin-right:.25rem}"],changeDetection:0});let a=t;return a})();function J(a,t){if(a&1&&(e(0,"div",1)(1,"div",2),i(2),j(3,"percent"),n(),e(4,"div",2),i(5),n()()),a&2){let d=s();l(2),u("Minus ",U(3,2,d.discountPercent(),"2.2-2"),""),l(3),u("Discount: ",d.summary().discount,"")}}var G=(()=>{let t=class t{constructor(){this.cartFacade=c(g),this.discountPercent=this.cartFacade.discountPercent,this.summary=this.cartFacade.summary}};t.\u0275fac=function(o){return new(o||t)},t.\u0275cmp=p({type:t,selectors:[["app-cart-total"]],standalone:!0,features:[C],decls:12,vars:4,consts:[[1,"summary"],[1,"row"],[1,"col"]],template:function(o,r){o&1&&(e(0,"div",0)(1,"div",1)(2,"div",2),i(3),n(),e(4,"div",2),i(5),n()(),_(6,J,6,5,"div",1),e(7,"div",1)(8,"div",2),i(9,"\xA0"),n(),e(10,"div",2),i(11),n()()()),o&2&&(l(3),u("Qty: ",r.summary().quantity,""),l(2),u("Subtotal: ",r.summary().subtotal,""),l(),h(6,r.discountPercent()>0?6:-1),l(5),u("Total: ",r.summary().total,""))},dependencies:[L],styles:[".summary[_ngcontent-%COMP%]{border:1px solid black;margin-bottom:1rem}.row[_ngcontent-%COMP%]{display:flex;justify-content:flex-end}.col[_ngcontent-%COMP%]{width:20%}"],changeDetection:0});let a=t;return a})();var K=(a,t)=>t.id;function R(a,t){if(a&1&&I(0,"app-cart-item",5),a&2){let d=t.$implicit;A("item",d)("quantity",d.quantity)}}function Z(a,t){if(a&1){let d=N();e(0,"div",0)(1,"div",1)(2,"p",2),i(3,"Id"),n(),e(4,"p",3),i(5,"Title"),n(),e(6,"p",4),i(7,"Description"),n(),e(8,"p",2),i(9,"Price"),n(),e(10,"p",2),i(11,"Qty"),n(),e(12,"p",2),i(13,"\xA0"),n()(),W(14,R,1,2,"app-cart-item",5,K),I(16,"app-cart-total"),e(17,"span"),i(18,"Promotion code: "),n(),e(19,"input",6),S("ngModelChange",function(o){T(d);let r=s();return v(r.promoCode,o)||(r.promoCode=o),D(o)}),n(),e(20,"button",7),f("click",function(){T(d);let o=s();return D(o.updatePromoCode())}),i(21,"Apply"),n()()}if(a&2){let d=s();l(14),B(d.cart()),l(5),x("ngModel",d.promoCode)}}function $(a,t){a&1&&(e(0,"p"),i(1,"Your cart is empty, please buy something."),n())}var ht=(()=>{let t=class t{constructor(){this.cartFacade=c(g),this.promoCode=O(this.cartFacade.promoCode()),this.cart=this.cartFacade.cart}updatePromoCode(){return this.cartFacade.updatePromoCode(this.promoCode())}};t.\u0275fac=function(o){return new(o||t)},t.\u0275cmp=p({type:t,selectors:[["app-cart"]],standalone:!0,features:[C],decls:2,vars:1,consts:[[1,"cart"],[1,"row"],[2,"width","10%"],[2,"width","20%"],[2,"width","40%"],[3,"item","quantity"],[3,"ngModelChange","ngModel"],[3,"click"]],template:function(o,r){o&1&&_(0,Z,22,1,"div",0)(1,$,2,0),o&2&&h(0,r.cart().length>0?0:1)},dependencies:[z,G,P,M,w,F],styles:[".row[_ngcontent-%COMP%]{display:flex}.row[_ngcontent-%COMP%] > p[_ngcontent-%COMP%]{border:1px solid black}input[_ngcontent-%COMP%]{margin-right:.25rem}"],changeDetection:0});let a=t;return a})();export{ht as CartComponent}; diff --git a/docs/ng-signal-demo/chunk-CNGSGSY7.js b/docs/ng-signal-demo/chunk-M63LLZBS.js similarity index 97% rename from docs/ng-signal-demo/chunk-CNGSGSY7.js rename to docs/ng-signal-demo/chunk-M63LLZBS.js index ab52dcf..4a2c873 100644 --- a/docs/ng-signal-demo/chunk-CNGSGSY7.js +++ b/docs/ng-signal-demo/chunk-M63LLZBS.js @@ -1 +1 @@ -import{b as N,c as W}from"./chunk-PT7YKKZE.js";import{a as z,b as R,c as U,d as G,e as H,f as J,g as K}from"./chunk-TSULXMNV.js";import{i as B,l as j}from"./chunk-KYWB336G.js";import{Fa as S,Fb as A,M as y,Ma as _,Na as b,Oa as f,Qa as C,Ta as i,Ua as n,Va as E,Wa as F,X as m,Xa as D,Ya as l,Z as M,Za as r,_ as v,_a as p,ab as I,bb as O,c as x,cb as V,eb as k,gb as T,ha as u,hb as q,ia as g,ib as L,oa as w,wa as P,za as c}from"./chunk-E2VPYGYD.js";var Q=o=>["/categories",o];function X(o,d){if(o&1){let a=F();i(0,"div",0)(1,"div",1),E(2,"img",2),n(),i(3,"div",1)(4,"span"),r(5,"Id:"),n(),i(6,"span"),r(7),n()(),i(8,"div",1)(9,"span"),r(10,"Category: "),n(),i(11,"a",3),r(12),q(13,"titlecase"),n()(),i(14,"div",1)(15,"span"),r(16,"Description: "),n(),i(17,"span"),r(18),n()(),i(19,"div",1)(20,"span"),r(21,"Price: "),n(),i(22,"span"),r(23),n()()(),i(24,"div",4)(25,"input",5),V("ngModelChange",function(e){u(a);let s=l(2);return O(s.quantity,e)||(s.quantity=e),g(e)}),n(),i(26,"button",6),D("click",function(){u(a);let e=l(),s=l();return g(s.addItem(e))}),r(27,"Add"),n()()}if(o&2){let a=l(),t=l();c(2),f("src",a.image,P),b("alt",a.title||"product image"),c(5),p(a.id),c(4),f("routerLink",T(10,Q,a.category)),c(),p(L(13,8,a.category)),c(6),p(a.description),c(5),p(a.price),c(2),I("ngModel",t.quantity)}}function Y(o,d){o&1&&_(0,X,28,12),o&2&&C(0,d?0:-1)}var lt=(()=>{let d=class d{constructor(){this.id=w(void 0,{transform:t=>typeof t<"u"?+t:void 0}),this.cartFacade=m(K),this.categoryFacade=m(j),this.quantity=S(1),this.products=this.categoryFacade.products,this.cart=this.cartFacade.cart,this.product=W(N(this.id).pipe(y(t=>this.getProduct(t))),{initialValue:void 0})}getProduct(t){return x(this,null,function*(){try{return t?this.products().find(e=>e.id===t):void 0}catch{return}})}addItem(t){let e=this.cart().findIndex(s=>s.id===t.id);console.log("addItem",e),this.cartFacade.addCart(e,t,this.quantity())}};d.\u0275fac=function(e){return new(e||d)},d.\u0275cmp=v({type:d,selectors:[["app-product-details"]],inputs:{id:[M.SignalBased,"id"]},standalone:!0,features:[k],decls:2,vars:1,consts:[[1,"product"],[1,"row"],["width","200","height","200",3,"src"],[3,"routerLink"],[1,"buttons"],["type","number","min","1",1,"order",3,"ngModelChange","ngModel"],[3,"click"]],template:function(e,s){if(e&1&&(i(0,"div"),_(1,Y,1,1),n()),e&2){let h;c(),C(1,(h=s.product())?1:-1,h)}},dependencies:[A,J,z,G,R,H,U,B],styles:[".product[_ngcontent-%COMP%], .buttons[_ngcontent-%COMP%]{margin-bottom:1rem}.row[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{display:inline-block;margin-bottom:.25rem}.row[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]:first-of-type{color:#aaa;width:20%}.row[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]:nth-of-type(2){width:80%}input.order[_ngcontent-%COMP%]{width:100px;height:30px;margin-right:.5rem}"],changeDetection:0});let o=d;return o})();export{lt as ProductDetailsComponent}; +import{b as N,c as W}from"./chunk-PT7YKKZE.js";import{a as z,b as R,c as U,d as G,e as H,f as J,g as K}from"./chunk-732D6KLU.js";import{i as B,l as j}from"./chunk-KYWB336G.js";import{Fa as S,Fb as A,M as y,Ma as _,Na as b,Oa as f,Qa as C,Ta as i,Ua as n,Va as E,Wa as F,X as m,Xa as D,Ya as l,Z as M,Za as r,_ as v,_a as p,ab as I,bb as O,c as x,cb as V,eb as k,gb as T,ha as u,hb as q,ia as g,ib as L,oa as w,wa as P,za as c}from"./chunk-E2VPYGYD.js";var Q=o=>["/categories",o];function X(o,d){if(o&1){let a=F();i(0,"div",0)(1,"div",1),E(2,"img",2),n(),i(3,"div",1)(4,"span"),r(5,"Id:"),n(),i(6,"span"),r(7),n()(),i(8,"div",1)(9,"span"),r(10,"Category: "),n(),i(11,"a",3),r(12),q(13,"titlecase"),n()(),i(14,"div",1)(15,"span"),r(16,"Description: "),n(),i(17,"span"),r(18),n()(),i(19,"div",1)(20,"span"),r(21,"Price: "),n(),i(22,"span"),r(23),n()()(),i(24,"div",4)(25,"input",5),V("ngModelChange",function(e){u(a);let s=l(2);return O(s.quantity,e)||(s.quantity=e),g(e)}),n(),i(26,"button",6),D("click",function(){u(a);let e=l(),s=l();return g(s.addItem(e))}),r(27,"Add"),n()()}if(o&2){let a=l(),t=l();c(2),f("src",a.image,P),b("alt",a.title||"product image"),c(5),p(a.id),c(4),f("routerLink",T(10,Q,a.category)),c(),p(L(13,8,a.category)),c(6),p(a.description),c(5),p(a.price),c(2),I("ngModel",t.quantity)}}function Y(o,d){o&1&&_(0,X,28,12),o&2&&C(0,d?0:-1)}var lt=(()=>{let d=class d{constructor(){this.id=w(void 0,{transform:t=>typeof t<"u"?+t:void 0}),this.cartFacade=m(K),this.categoryFacade=m(j),this.quantity=S(1),this.products=this.categoryFacade.products,this.cart=this.cartFacade.cart,this.product=W(N(this.id).pipe(y(t=>this.getProduct(t))),{initialValue:void 0})}getProduct(t){return x(this,null,function*(){try{return t?this.products().find(e=>e.id===t):void 0}catch{return}})}addItem(t){let e=this.cart().findIndex(s=>s.id===t.id);console.log("addItem",e),this.cartFacade.addCart(e,t,this.quantity())}};d.\u0275fac=function(e){return new(e||d)},d.\u0275cmp=v({type:d,selectors:[["app-product-details"]],inputs:{id:[M.SignalBased,"id"]},standalone:!0,features:[k],decls:2,vars:1,consts:[[1,"product"],[1,"row"],["width","200","height","200",3,"src"],[3,"routerLink"],[1,"buttons"],["type","number","min","1",1,"order",3,"ngModelChange","ngModel"],[3,"click"]],template:function(e,s){if(e&1&&(i(0,"div"),_(1,Y,1,1),n()),e&2){let h;c(),C(1,(h=s.product())?1:-1,h)}},dependencies:[A,J,z,G,R,H,U,B],styles:[".product[_ngcontent-%COMP%], .buttons[_ngcontent-%COMP%]{margin-bottom:1rem}.row[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]{display:inline-block;margin-bottom:.25rem}.row[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]:first-of-type{color:#aaa;width:20%}.row[_ngcontent-%COMP%] > span[_ngcontent-%COMP%]:nth-of-type(2){width:80%}input.order[_ngcontent-%COMP%]{width:100px;height:30px;margin-right:.5rem}"],changeDetection:0});let o=d;return o})();export{lt as ProductDetailsComponent}; diff --git a/docs/ng-signal-demo/chunk-TSULXMNV.js b/docs/ng-signal-demo/chunk-TSULXMNV.js deleted file mode 100644 index 892a22e..0000000 --- a/docs/ng-signal-demo/chunk-TSULXMNV.js +++ /dev/null @@ -1 +0,0 @@ -import{$ as x,Aa as d,Ca as j,Fa as K,Ha as f,Na as X,Pa as Y,Q as m,R as y,S as N,U as p,X as P,Xa as T,Z as b,a as o,aa as c,b as l,db as v,ga as k,ja as A,lb as J,m as q,pa as G,qa as M,qb as Q,s as z,sb as ee,tb as _,x as Z,xb as U}from"./chunk-E2VPYGYD.js";var ce=(()=>{let e=class e{constructor(i,r){this._renderer=i,this._elementRef=r,this.onChange=s=>{},this.onTouched=()=>{}}setProperty(i,r){this._renderer.setProperty(this._elementRef.nativeElement,i,r)}registerOnTouched(i){this.onTouched=i}registerOnChange(i){this.onChange=i}setDisabledState(i){this.setProperty("disabled",i)}};e.\u0275fac=function(r){return new(r||e)(d(j),d(G))},e.\u0275dir=c({type:e});let t=e;return t})(),he=(()=>{let e=class e extends ce{};e.\u0275fac=(()=>{let i;return function(s){return(i||(i=A(e)))(s||e)}})(),e.\u0275dir=c({type:e,features:[f]});let t=e;return t})(),$=new p("");var we={provide:$,useExisting:m(()=>fe),multi:!0};function Ie(){let t=U()?U().getUserAgent():"";return/android (\d+)/.test(t.toLowerCase())}var Se=new p(""),fe=(()=>{let e=class e extends ce{constructor(i,r,s){super(i,r),this._compositionMode=s,this._composing=!1,this._compositionMode==null&&(this._compositionMode=!Ie())}writeValue(i){let r=i??"";this.setProperty("value",r)}_handleInput(i){(!this._compositionMode||this._compositionMode&&!this._composing)&&this.onChange(i)}_compositionStart(){this._composing=!0}_compositionEnd(i){this._composing=!1,this._compositionMode&&this.onChange(i)}};e.\u0275fac=function(r){return new(r||e)(d(j),d(G),d(Se,8))},e.\u0275dir=c({type:e,selectors:[["input","formControlName","",3,"type","checkbox"],["textarea","formControlName",""],["input","formControl","",3,"type","checkbox"],["textarea","formControl",""],["input","ngModel","",3,"type","checkbox"],["textarea","ngModel",""],["","ngDefaultControl",""]],hostBindings:function(r,s){r&1&&T("input",function(u){return s._handleInput(u.target.value)})("blur",function(){return s.onTouched()})("compositionstart",function(){return s._compositionStart()})("compositionend",function(u){return s._compositionEnd(u.target.value)})},features:[v([we]),f]});let t=e;return t})();function te(t){return t==null||(typeof t=="string"||Array.isArray(t))&&t.length===0}var pe=new p(""),Oe=new p("");function Ne(t){return e=>{if(te(e.value)||te(t))return null;let n=parseFloat(e.value);return!isNaN(n)&&n{e=n!=null?o(o({},e),n):e}),Object.keys(e).length===0?null:e}function ve(t,e){return e.map(n=>n(t))}function Pe(t){return!t.validate}function _e(t){return t.map(e=>Pe(e)?e:n=>e.validate(n))}function xe(t){if(!t)return null;let e=t.filter(ge);return e.length==0?null:function(n){return ye(ve(n,e))}}function Ce(t){return t!=null?xe(_e(t)):null}function ke(t){if(!t)return null;let e=t.filter(ge);return e.length==0?null:function(n){let i=ve(n,e).map(me);return Z(i).pipe(z(ye))}}function Ve(t){return t!=null?ke(_e(t)):null}function ne(t,e){return t===null?[e]:Array.isArray(t)?[...t,e]:[t,e]}function Ge(t){return t._rawValidators}function je(t){return t._rawAsyncValidators}function B(t){return t?Array.isArray(t)?t:[t]:[]}function F(t,e){return Array.isArray(t)?t.includes(e):t===e}function re(t,e){let n=B(e);return B(t).forEach(r=>{F(n,r)||n.push(r)}),n}function se(t,e){return B(e).filter(n=>!F(t,n))}var w=class{constructor(){this._rawValidators=[],this._rawAsyncValidators=[],this._onDestroyCallbacks=[]}get value(){return this.control?this.control.value:null}get valid(){return this.control?this.control.valid:null}get invalid(){return this.control?this.control.invalid:null}get pending(){return this.control?this.control.pending:null}get disabled(){return this.control?this.control.disabled:null}get enabled(){return this.control?this.control.enabled:null}get errors(){return this.control?this.control.errors:null}get pristine(){return this.control?this.control.pristine:null}get dirty(){return this.control?this.control.dirty:null}get touched(){return this.control?this.control.touched:null}get status(){return this.control?this.control.status:null}get untouched(){return this.control?this.control.untouched:null}get statusChanges(){return this.control?this.control.statusChanges:null}get valueChanges(){return this.control?this.control.valueChanges:null}get path(){return null}_setValidators(e){this._rawValidators=e||[],this._composedValidatorFn=Ce(this._rawValidators)}_setAsyncValidators(e){this._rawAsyncValidators=e||[],this._composedAsyncValidatorFn=Ve(this._rawAsyncValidators)}get validator(){return this._composedValidatorFn||null}get asyncValidator(){return this._composedAsyncValidatorFn||null}_registerOnDestroy(e){this._onDestroyCallbacks.push(e)}_invokeOnDestroyCallbacks(){this._onDestroyCallbacks.forEach(e=>e()),this._onDestroyCallbacks=[]}reset(e=void 0){this.control&&this.control.reset(e)}hasError(e,n){return this.control?this.control.hasError(e,n):!1}getError(e,n){return this.control?this.control.getError(e,n):null}},R=class extends w{get formDirective(){return null}get path(){return null}},D=class extends w{constructor(){super(...arguments),this._parent=null,this.name=null,this.valueAccessor=null}},H=class{constructor(e){this._cd=e}get isTouched(){return!!this._cd?.control?.touched}get isUntouched(){return!!this._cd?.control?.untouched}get isPristine(){return!!this._cd?.control?.pristine}get isDirty(){return!!this._cd?.control?.dirty}get isValid(){return!!this._cd?.control?.valid}get isInvalid(){return!!this._cd?.control?.invalid}get isPending(){return!!this._cd?.control?.pending}get isSubmitted(){return!!this._cd?.submitted}},Te={"[class.ng-untouched]":"isUntouched","[class.ng-touched]":"isTouched","[class.ng-pristine]":"isPristine","[class.ng-dirty]":"isDirty","[class.ng-valid]":"isValid","[class.ng-invalid]":"isInvalid","[class.ng-pending]":"isPending"},wt=l(o({},Te),{"[class.ng-submitted]":"isSubmitted"}),It=(()=>{let e=class e extends H{constructor(i){super(i)}};e.\u0275fac=function(r){return new(r||e)(d(D,2))},e.\u0275dir=c({type:e,selectors:[["","formControlName",""],["","ngModel",""],["","formControl",""]],hostVars:14,hostBindings:function(r,s){r&2&&Y("ng-untouched",s.isUntouched)("ng-touched",s.isTouched)("ng-pristine",s.isPristine)("ng-dirty",s.isDirty)("ng-valid",s.isValid)("ng-invalid",s.isInvalid)("ng-pending",s.isPending)},features:[f]});let t=e;return t})();var C="VALID",E="INVALID",g="PENDING",V="DISABLED";function Ue(t){return(I(t)?t.validators:t)||null}function Be(t){return Array.isArray(t)?Ce(t):t||null}function Re(t,e){return(I(e)?e.asyncValidators:t)||null}function He(t){return Array.isArray(t)?Ve(t):t||null}function I(t){return t!=null&&!Array.isArray(t)&&typeof t=="object"}var L=class{constructor(e,n){this._pendingDirty=!1,this._hasOwnPendingAsyncValidator=!1,this._pendingTouched=!1,this._onCollectionChange=()=>{},this._parent=null,this.pristine=!0,this.touched=!1,this._onDisabledChange=[],this._assignValidators(e),this._assignAsyncValidators(n)}get validator(){return this._composedValidatorFn}set validator(e){this._rawValidators=this._composedValidatorFn=e}get asyncValidator(){return this._composedAsyncValidatorFn}set asyncValidator(e){this._rawAsyncValidators=this._composedAsyncValidatorFn=e}get parent(){return this._parent}get valid(){return this.status===C}get invalid(){return this.status===E}get pending(){return this.status==g}get disabled(){return this.status===V}get enabled(){return this.status!==V}get dirty(){return!this.pristine}get untouched(){return!this.touched}get updateOn(){return this._updateOn?this._updateOn:this.parent?this.parent.updateOn:"change"}setValidators(e){this._assignValidators(e)}setAsyncValidators(e){this._assignAsyncValidators(e)}addValidators(e){this.setValidators(re(e,this._rawValidators))}addAsyncValidators(e){this.setAsyncValidators(re(e,this._rawAsyncValidators))}removeValidators(e){this.setValidators(se(e,this._rawValidators))}removeAsyncValidators(e){this.setAsyncValidators(se(e,this._rawAsyncValidators))}hasValidator(e){return F(this._rawValidators,e)}hasAsyncValidator(e){return F(this._rawAsyncValidators,e)}clearValidators(){this.validator=null}clearAsyncValidators(){this.asyncValidator=null}markAsTouched(e={}){this.touched=!0,this._parent&&!e.onlySelf&&this._parent.markAsTouched(e)}markAllAsTouched(){this.markAsTouched({onlySelf:!0}),this._forEachChild(e=>e.markAllAsTouched())}markAsUntouched(e={}){this.touched=!1,this._pendingTouched=!1,this._forEachChild(n=>{n.markAsUntouched({onlySelf:!0})}),this._parent&&!e.onlySelf&&this._parent._updateTouched(e)}markAsDirty(e={}){this.pristine=!1,this._parent&&!e.onlySelf&&this._parent.markAsDirty(e)}markAsPristine(e={}){this.pristine=!0,this._pendingDirty=!1,this._forEachChild(n=>{n.markAsPristine({onlySelf:!0})}),this._parent&&!e.onlySelf&&this._parent._updatePristine(e)}markAsPending(e={}){this.status=g,e.emitEvent!==!1&&this.statusChanges.emit(this.status),this._parent&&!e.onlySelf&&this._parent.markAsPending(e)}disable(e={}){let n=this._parentMarkedDirty(e.onlySelf);this.status=V,this.errors=null,this._forEachChild(i=>{i.disable(l(o({},e),{onlySelf:!0}))}),this._updateValue(),e.emitEvent!==!1&&(this.valueChanges.emit(this.value),this.statusChanges.emit(this.status)),this._updateAncestors(l(o({},e),{skipPristineCheck:n})),this._onDisabledChange.forEach(i=>i(!0))}enable(e={}){let n=this._parentMarkedDirty(e.onlySelf);this.status=C,this._forEachChild(i=>{i.enable(l(o({},e),{onlySelf:!0}))}),this.updateValueAndValidity({onlySelf:!0,emitEvent:e.emitEvent}),this._updateAncestors(l(o({},e),{skipPristineCheck:n})),this._onDisabledChange.forEach(i=>i(!1))}_updateAncestors(e){this._parent&&!e.onlySelf&&(this._parent.updateValueAndValidity(e),e.skipPristineCheck||this._parent._updatePristine(),this._parent._updateTouched())}setParent(e){this._parent=e}getRawValue(){return this.value}updateValueAndValidity(e={}){this._setInitialStatus(),this._updateValue(),this.enabled&&(this._cancelExistingSubscription(),this.errors=this._runValidator(),this.status=this._calculateStatus(),(this.status===C||this.status===g)&&this._runAsyncValidator(e.emitEvent)),e.emitEvent!==!1&&(this.valueChanges.emit(this.value),this.statusChanges.emit(this.status)),this._parent&&!e.onlySelf&&this._parent.updateValueAndValidity(e)}_updateTreeValidity(e={emitEvent:!0}){this._forEachChild(n=>n._updateTreeValidity(e)),this.updateValueAndValidity({onlySelf:!0,emitEvent:e.emitEvent})}_setInitialStatus(){this.status=this._allControlsDisabled()?V:C}_runValidator(){return this.validator?this.validator(this):null}_runAsyncValidator(e){if(this.asyncValidator){this.status=g,this._hasOwnPendingAsyncValidator=!0;let n=me(this.asyncValidator(this));this._asyncValidationSubscription=n.subscribe(i=>{this._hasOwnPendingAsyncValidator=!1,this.setErrors(i,{emitEvent:e})})}}_cancelExistingSubscription(){this._asyncValidationSubscription&&(this._asyncValidationSubscription.unsubscribe(),this._hasOwnPendingAsyncValidator=!1)}setErrors(e,n={}){this.errors=e,this._updateControlsErrors(n.emitEvent!==!1)}get(e){let n=e;return n==null||(Array.isArray(n)||(n=n.split(".")),n.length===0)?null:n.reduce((i,r)=>i&&i._find(r),this)}getError(e,n){let i=n?this.get(n):this;return i&&i.errors?i.errors[e]:null}hasError(e,n){return!!this.getError(e,n)}get root(){let e=this;for(;e._parent;)e=e._parent;return e}_updateControlsErrors(e){this.status=this._calculateStatus(),e&&this.statusChanges.emit(this.status),this._parent&&this._parent._updateControlsErrors(e)}_initObservables(){this.valueChanges=new M,this.statusChanges=new M}_calculateStatus(){return this._allControlsDisabled()?V:this.errors?E:this._hasOwnPendingAsyncValidator||this._anyControlsHaveStatus(g)?g:this._anyControlsHaveStatus(E)?E:C}_anyControlsHaveStatus(e){return this._anyControls(n=>n.status===e)}_anyControlsDirty(){return this._anyControls(e=>e.dirty)}_anyControlsTouched(){return this._anyControls(e=>e.touched)}_updatePristine(e={}){this.pristine=!this._anyControlsDirty(),this._parent&&!e.onlySelf&&this._parent._updatePristine(e)}_updateTouched(e={}){this.touched=this._anyControlsTouched(),this._parent&&!e.onlySelf&&this._parent._updateTouched(e)}_registerOnCollectionChange(e){this._onCollectionChange=e}_setUpdateStrategy(e){I(e)&&e.updateOn!=null&&(this._updateOn=e.updateOn)}_parentMarkedDirty(e){let n=this._parent&&this._parent.dirty;return!e&&!!n&&!this._parent._anyControlsDirty()}_find(e){return null}_assignValidators(e){this._rawValidators=Array.isArray(e)?e.slice():e,this._composedValidatorFn=Be(this._rawValidators)}_assignAsyncValidators(e){this._rawAsyncValidators=Array.isArray(e)?e.slice():e,this._composedAsyncValidatorFn=He(this._rawAsyncValidators)}};var De=new p("CallSetDisabledState",{providedIn:"root",factory:()=>W}),W="always";function Le(t,e){return[...e.path,t]}function $e(t,e,n=W){qe(t,e),e.valueAccessor.writeValue(t.value),(t.disabled||n==="always")&&e.valueAccessor.setDisabledState?.(t.disabled),ze(t,e),Ke(t,e),Ze(t,e),We(t,e)}function oe(t,e){t.forEach(n=>{n.registerOnValidatorChange&&n.registerOnValidatorChange(e)})}function We(t,e){if(e.valueAccessor.setDisabledState){let n=i=>{e.valueAccessor.setDisabledState(i)};t.registerOnDisabledChange(n),e._registerOnDestroy(()=>{t._unregisterOnDisabledChange(n)})}}function qe(t,e){let n=Ge(t);e.validator!==null?t.setValidators(ne(n,e.validator)):typeof n=="function"&&t.setValidators([n]);let i=je(t);e.asyncValidator!==null?t.setAsyncValidators(ne(i,e.asyncValidator)):typeof i=="function"&&t.setAsyncValidators([i]);let r=()=>t.updateValueAndValidity();oe(e._rawValidators,r),oe(e._rawAsyncValidators,r)}function ze(t,e){e.valueAccessor.registerOnChange(n=>{t._pendingValue=n,t._pendingChange=!0,t._pendingDirty=!0,t.updateOn==="change"&&be(t,e)})}function Ze(t,e){e.valueAccessor.registerOnTouched(()=>{t._pendingTouched=!0,t.updateOn==="blur"&&t._pendingChange&&be(t,e),t.updateOn!=="submit"&&t.markAsTouched()})}function be(t,e){t._pendingDirty&&t.markAsDirty(),t.setValue(t._pendingValue,{emitModelToViewChange:!1}),e.viewToModelUpdate(t._pendingValue),t._pendingChange=!1}function Ke(t,e){let n=(i,r)=>{e.valueAccessor.writeValue(i),r&&e.viewToModelUpdate(i)};t.registerOnChange(n),e._registerOnDestroy(()=>{t._unregisterOnChange(n)})}function Xe(t,e){if(!t.hasOwnProperty("model"))return!1;let n=t.model;return n.isFirstChange()?!0:!Object.is(e,n.currentValue)}function Ye(t){return Object.getPrototypeOf(t.constructor)===he}function Je(t,e){if(!e)return null;Array.isArray(e);let n,i,r;return e.forEach(s=>{s.constructor===fe?n=s:Ye(s)?i=s:r=s}),r||i||n||null}function ae(t,e){let n=t.indexOf(e);n>-1&&t.splice(n,1)}function le(t){return typeof t=="object"&&t!==null&&Object.keys(t).length===2&&"value"in t&&"disabled"in t}var Qe=class extends L{constructor(e=null,n,i){super(Ue(n),Re(i,n)),this.defaultValue=null,this._onChange=[],this._pendingChange=!1,this._applyFormState(e),this._setUpdateStrategy(n),this._initObservables(),this.updateValueAndValidity({onlySelf:!0,emitEvent:!!this.asyncValidator}),I(n)&&(n.nonNullable||n.initialValueIsDefault)&&(le(e)?this.defaultValue=e.value:this.defaultValue=e)}setValue(e,n={}){this.value=this._pendingValue=e,this._onChange.length&&n.emitModelToViewChange!==!1&&this._onChange.forEach(i=>i(this.value,n.emitViewToModelChange!==!1)),this.updateValueAndValidity(n)}patchValue(e,n={}){this.setValue(e,n)}reset(e=this.defaultValue,n={}){this._applyFormState(e),this.markAsPristine(n),this.markAsUntouched(n),this.setValue(this.value,n),this._pendingChange=!1}_updateValue(){}_anyControls(e){return!1}_allControlsDisabled(){return this.disabled}registerOnChange(e){this._onChange.push(e)}_unregisterOnChange(e){ae(this._onChange,e)}registerOnDisabledChange(e){this._onDisabledChange.push(e)}_unregisterOnDisabledChange(e){ae(this._onDisabledChange,e)}_forEachChild(e){}_syncPendingControls(){return this.updateOn==="submit"&&(this._pendingDirty&&this.markAsDirty(),this._pendingTouched&&this.markAsTouched(),this._pendingChange)?(this.setValue(this._pendingValue,{onlySelf:!0,emitModelToViewChange:!1}),!0):!1}_applyFormState(e){le(e)?(this.value=this._pendingValue=e.value,e.disabled?this.disable({onlySelf:!0,emitEvent:!1}):this.enable({onlySelf:!0,emitEvent:!1})):this.value=this._pendingValue=e}};var et={provide:D,useExisting:m(()=>tt)},ue=Promise.resolve(),tt=(()=>{let e=class e extends D{constructor(i,r,s,a,u,h){super(),this._changeDetectorRef=u,this.callSetDisabledState=h,this.control=new Qe,this._registered=!1,this.name="",this.update=new M,this._parent=i,this._setValidators(r),this._setAsyncValidators(s),this.valueAccessor=Je(this,a)}ngOnChanges(i){if(this._checkForErrors(),!this._registered||"name"in i){if(this._registered&&(this._checkName(),this.formDirective)){let r=i.name.previousValue;this.formDirective.removeControl({name:r,path:this._getPath(r)})}this._setUpControl()}"isDisabled"in i&&this._updateDisabled(i),Xe(i,this.viewModel)&&(this._updateValue(this.model),this.viewModel=this.model)}ngOnDestroy(){this.formDirective&&this.formDirective.removeControl(this)}get path(){return this._getPath(this.name)}get formDirective(){return this._parent?this._parent.formDirective:null}viewToModelUpdate(i){this.viewModel=i,this.update.emit(i)}_setUpControl(){this._setUpdateStrategy(),this._isStandalone()?this._setUpStandalone():this.formDirective.addControl(this),this._registered=!0}_setUpdateStrategy(){this.options&&this.options.updateOn!=null&&(this.control._updateOn=this.options.updateOn)}_isStandalone(){return!this._parent||!!(this.options&&this.options.standalone)}_setUpStandalone(){$e(this.control,this,this.callSetDisabledState),this.control.updateValueAndValidity({emitEvent:!1})}_checkForErrors(){this._isStandalone()||this._checkParentType(),this._checkName()}_checkParentType(){}_checkName(){this.options&&this.options.name&&(this.name=this.options.name),!this._isStandalone()&&this.name}_updateValue(i){ue.then(()=>{this.control.setValue(i,{emitViewToModelChange:!1}),this._changeDetectorRef?.markForCheck()})}_updateDisabled(i){let r=i.isDisabled.currentValue,s=r!==0&&ee(r);ue.then(()=>{s&&!this.control.disabled?this.control.disable():!s&&this.control.disabled&&this.control.enable(),this._changeDetectorRef?.markForCheck()})}_getPath(i){return this._parent?Le(i,this._parent):[i]}};e.\u0275fac=function(r){return new(r||e)(d(R,9),d(pe,10),d(Oe,10),d($,10),d(Q,8),d(De,8))},e.\u0275dir=c({type:e,selectors:[["","ngModel","",3,"formControlName","",3,"formControl",""]],inputs:{name:"name",isDisabled:[b.None,"disabled","isDisabled"],model:[b.None,"ngModel","model"],options:[b.None,"ngModelOptions","options"]},outputs:{update:"ngModelChange"},exportAs:["ngModel"],features:[v([et]),f,k]});let t=e;return t})();var it={provide:$,useExisting:m(()=>nt),multi:!0},nt=(()=>{let e=class e extends he{writeValue(i){let r=i??"";this.setProperty("value",r)}registerOnChange(i){this.onChange=r=>{i(r==""?null:parseFloat(r))}}};e.\u0275fac=(()=>{let i;return function(s){return(i||(i=A(e)))(s||e)}})(),e.\u0275dir=c({type:e,selectors:[["input","type","number","formControlName",""],["input","type","number","formControl",""],["input","type","number","ngModel",""]],hostBindings:function(r,s){r&1&&T("input",function(u){return s.onChange(u.target.value)})("blur",function(){return s.onTouched()})},features:[v([it]),f]});let t=e;return t})();function rt(t){return typeof t=="number"?t:parseFloat(t)}var st=(()=>{let e=class e{constructor(){this._validator=ie}ngOnChanges(i){if(this.inputName in i){let r=this.normalizeInput(i[this.inputName].currentValue);this._enabled=this.enabled(r),this._validator=this._enabled?this.createValidator(r):ie,this._onChange&&this._onChange()}}validate(i){return this._validator(i)}registerOnValidatorChange(i){this._onChange=i}enabled(i){return i!=null}};e.\u0275fac=function(r){return new(r||e)},e.\u0275dir=c({type:e,features:[k]});let t=e;return t})();var ot={provide:pe,useExisting:m(()=>at),multi:!0},at=(()=>{let e=class e extends st{constructor(){super(...arguments),this.inputName="min",this.normalizeInput=i=>rt(i),this.createValidator=i=>Ne(i)}};e.\u0275fac=(()=>{let i;return function(s){return(i||(i=A(e)))(s||e)}})(),e.\u0275dir=c({type:e,selectors:[["input","type","number","min","","formControlName",""],["input","type","number","min","","formControl",""],["input","type","number","min","","ngModel",""]],hostVars:1,hostBindings:function(r,s){r&2&&X("min",s._enabled?s.min:null)},inputs:{min:"min"},features:[v([ot]),f]});let t=e;return t})();var lt=(()=>{let e=class e{};e.\u0275fac=function(r){return new(r||e)},e.\u0275mod=x({type:e}),e.\u0275inj=N({});let t=e;return t})();var Ot=(()=>{let e=class e{static withConfig(i){return{ngModule:e,providers:[{provide:De,useValue:i.callSetDisabledState??W}]}}};e.\u0275fac=function(r){return new(r||e)},e.\u0275mod=x({type:e}),e.\u0275inj=N({imports:[lt]});let t=e;return t})();var ut={promoCode:"",cart:[]};function Ae(t,e,n){return n<=0?t.filter(i=>i.id!==e):t.map(i=>i.id===e?l(o({},i),{quantity:n}):i)}var Me=(()=>{let e=class e{constructor(){this.state=K(ut),this.cart=_(()=>this.state().cart),this.promoCode=_(()=>this.state().promoCode),this.discountPercent=_(()=>this.promoCode()==="DEVFESTHK2023"?.1:this.promoCode()==="ANGULARNATION"?.2:0),this.summary=_(()=>{let i=this.state().cart.reduce(({quantity:h,subtotal:S},O)=>{let Ee=h+O.quantity,Fe=S+O.price*O.quantity;return{quantity:Ee,subtotal:Fe}},{quantity:0,subtotal:0}),{subtotal:r,quantity:s}=i,a=r*this.discountPercent(),u=r-a;return{quantity:s,subtotal:r.toFixed(2),discount:a.toFixed(2),total:u.toFixed(2)}})}updatePromoCode(i){this.state.update(r=>l(o({},r),{promoCode:i}))}buy(i,r,s){this.state.update(a=>{let u=[];return i>=0?u=a.cart.map((h,S)=>S===i?l(o({},h),{quantity:h.quantity+s}):h):u=[...this.state().cart,l(o({},r),{quantity:s})],l(o({},a),{cart:u})})}remove(i){this.state.update(r=>{let s=Ae(r.cart,i,0);return l(o({},r),{cart:s})})}update(i,r){this.state.update(s=>{let a=Ae(s.cart,i,r);return l(o({},s),{cart:a})})}};e.\u0275fac=function(r){return new(r||e)},e.\u0275prov=y({token:e,factory:e.\u0275fac,providedIn:"root"});let t=e;return t})();var Rt=(()=>{let e=class e{constructor(){this.store=P(Me)}get cart(){return this.store.cart}get discountPercent(){return this.store.discountPercent}get summary(){return this.store.summary}get promoCode(){return this.store.promoCode}updatePromoCode(i){this.store.updatePromoCode(i)}addCart(i,r,s){this.store.buy(i,r,s)}deleteCart(i){this.store.remove(i)}updateCart(i,r){this.store.update(i,r)}};e.\u0275fac=function(r){return new(r||e)},e.\u0275prov=y({token:e,factory:e.\u0275fac,providedIn:"root"});let t=e;return t})();export{fe as a,It as b,tt as c,nt as d,at as e,Ot as f,Rt as g}; diff --git a/docs/ng-signal-demo/chunk-UC2RG3ZV.js b/docs/ng-signal-demo/chunk-UC2RG3ZV.js new file mode 100644 index 0000000..8adba6b --- /dev/null +++ b/docs/ng-signal-demo/chunk-UC2RG3ZV.js @@ -0,0 +1 @@ +import{a as M,b as w,c as F,d as Q,e as X,f as P,g}from"./chunk-732D6KLU.js";import{$a as u,Fa as O,Ga as V,Gb as L,Ma as _,Oa as A,Qa as h,Ra as W,Sa as B,Ta as e,Ua as i,Va as I,Wa as N,X as c,Xa as f,Ya as s,Z as b,Za as n,_ as p,_a as y,ab as x,bb as v,cb as S,eb as C,ha as T,hb as j,ia as D,jb as U,oa as k,za as l}from"./chunk-E2VPYGYD.js";var z=(()=>{let t=class t{constructor(){this.cartFacade=c(g),this.item=k.required(),this.quantity=V(0)}delete(){return this.cartFacade.deleteCart(this.item().id)}update(){return this.cartFacade.updateCart(this.item().id,this.quantity())}};t.\u0275fac=function(o){return new(o||t)},t.\u0275cmp=p({type:t,selectors:[["app-cart-item"]],inputs:{item:[b.SignalBased,"item"],quantity:[b.SignalBased,"quantity"]},outputs:{quantity:"quantityChange"},standalone:!0,features:[C],decls:16,vars:5,consts:[[1,"row"],[2,"width","10%"],[2,"width","20%"],[2,"width","40%"],["type","number","min","1",2,"width","50px",3,"ngModelChange","ngModel"],[1,"btnUpdate",3,"click"],[3,"click"]],template:function(o,r){o&1&&(e(0,"div",0)(1,"p",1),n(2),i(),e(3,"p",2),n(4),i(),e(5,"p",3),n(6),i(),e(7,"p",1),n(8),i(),e(9,"p",1)(10,"input",4),S("ngModelChange",function(E){return v(r.quantity,E)||(r.quantity=E),E}),i()(),e(11,"p",1)(12,"button",5),f("click",function(){return r.update()}),n(13,"Update"),i(),e(14,"button",6),f("click",function(){return r.delete()}),n(15,"X"),i()()()),o&2&&(l(2),y(r.item().id),l(2),y(r.item().title),l(2),y(r.item().description),l(2),y(r.item().price),l(2),x("ngModel",r.quantity))},dependencies:[P,M,Q,w,X,F],styles:[".row[_ngcontent-%COMP%]{display:flex}.row[_ngcontent-%COMP%] > p[_ngcontent-%COMP%]{border:1px solid black}.btnUpdate[_ngcontent-%COMP%]{margin-right:.25rem}"],changeDetection:0});let a=t;return a})();function J(a,t){if(a&1&&(e(0,"div",1)(1,"div",2),n(2),j(3,"percent"),i(),e(4,"div",2),n(5),i()()),a&2){let d=s();l(2),u("Minus ",U(3,2,d.discountPercent(),"2.2-2"),""),l(3),u("Discount: ",d.summary().discount,"")}}var G=(()=>{let t=class t{constructor(){this.cartFacade=c(g),this.discountPercent=this.cartFacade.discountPercent,this.summary=this.cartFacade.summary}};t.\u0275fac=function(o){return new(o||t)},t.\u0275cmp=p({type:t,selectors:[["app-cart-total"]],standalone:!0,features:[C],decls:12,vars:4,consts:[[1,"summary"],[1,"row"],[1,"col"]],template:function(o,r){o&1&&(e(0,"div",0)(1,"div",1)(2,"div",2),n(3),i(),e(4,"div",2),n(5),i()(),_(6,J,6,5,"div",1),e(7,"div",1)(8,"div",2),n(9,"\xA0"),i(),e(10,"div",2),n(11),i()()()),o&2&&(l(3),u("Qty: ",r.summary().quantity,""),l(2),u("Subtotal: ",r.summary().subtotal,""),l(),h(6,r.discountPercent()>0?6:-1),l(5),u("Total: ",r.summary().total,""))},dependencies:[L],styles:[".summary[_ngcontent-%COMP%]{border:1px solid black;margin-bottom:1rem}.row[_ngcontent-%COMP%]{display:flex;justify-content:flex-end}.col[_ngcontent-%COMP%]{width:20%}"],changeDetection:0});let a=t;return a})();var K=(a,t)=>t.id;function R(a,t){if(a&1&&I(0,"app-cart-item",5),a&2){let d=t.$implicit;A("item",d)("quantity",d.quantity)}}function Z(a,t){if(a&1){let d=N();e(0,"div",0)(1,"div",1)(2,"p",2),n(3,"Id"),i(),e(4,"p",3),n(5,"Title"),i(),e(6,"p",4),n(7,"Description"),i(),e(8,"p",2),n(9,"Price"),i(),e(10,"p",2),n(11,"Qty"),i(),e(12,"p",2),n(13,"\xA0"),i()(),W(14,R,1,2,"app-cart-item",5,K),I(16,"app-cart-total"),e(17,"span"),n(18,"Promotion code: "),i(),e(19,"input",6),S("ngModelChange",function(o){T(d);let r=s();return v(r.promoCode,o)||(r.promoCode=o),D(o)}),i(),e(20,"button",7),f("click",function(){T(d);let o=s();return D(o.updatePromoCode())}),n(21,"Apply"),i()()}if(a&2){let d=s();l(14),B(d.cart()),l(5),x("ngModel",d.promoCode)}}function $(a,t){a&1&&(e(0,"p"),n(1,"Your cart is empty, please buy something."),i())}var ht=(()=>{let t=class t{constructor(){this.cartFacade=c(g),this.promoCode=O(this.cartFacade.promoCode()),this.cart=this.cartFacade.cart}updatePromoCode(){return this.cartFacade.updatePromoCode(this.promoCode())}};t.\u0275fac=function(o){return new(o||t)},t.\u0275cmp=p({type:t,selectors:[["app-cart"]],standalone:!0,features:[C],decls:2,vars:1,consts:[[1,"cart"],[1,"row"],[2,"width","10%"],[2,"width","20%"],[2,"width","40%"],[3,"item","quantity"],[3,"ngModelChange","ngModel"],[3,"click"]],template:function(o,r){o&1&&_(0,Z,22,1,"div",0)(1,$,2,0),o&2&&h(0,r.cart().length>0?0:1)},dependencies:[z,G,P,M,w,F],styles:[".row[_ngcontent-%COMP%]{display:flex}.row[_ngcontent-%COMP%] > p[_ngcontent-%COMP%]{border:1px solid black}input[_ngcontent-%COMP%]{margin-right:.25rem}"],changeDetection:0});let a=t;return a})();export{ht as CartComponent}; diff --git a/docs/ng-signal-demo/index.html b/docs/ng-signal-demo/index.html index 1169189..f647426 100644 --- a/docs/ng-signal-demo/index.html +++ b/docs/ng-signal-demo/index.html @@ -10,5 +10,5 @@ - + diff --git a/docs/ng-signal-demo/main-KDOCW5SU.js b/docs/ng-signal-demo/main-OY53Y4EN.js similarity index 97% rename from docs/ng-signal-demo/main-KDOCW5SU.js rename to docs/ng-signal-demo/main-OY53Y4EN.js index a56d79e..79e7610 100644 --- a/docs/ng-signal-demo/main-KDOCW5SU.js +++ b/docs/ng-signal-demo/main-OY53Y4EN.js @@ -1 +1 @@ -import{a as X}from"./chunk-PT7YKKZE.js";import{a as b,b as Q,c as G,d as W,e as Y,f as Z,g as P,h as q,i as z,j as J,k as K,l as tt}from"./chunk-KYWB336G.js";import{A as M,Eb as V,J as d,Ma as y,O as h,Oa as U,Qa as E,R as C,Ta as p,Ua as n,Va as _,X as a,Za as c,_ as g,eb as v,fa as j,fb as N,hb as F,ib as $,ja as A,l as B,mb as O,n as f,na as L,qb as H,r as R,s as u,y as k,z as m,za as D}from"./chunk-E2VPYGYD.js";function et(t,e,s,o){let r="https://fakestoreapi.com/products/categories";return()=>{t.get(r).pipe(d(3),M(o.products$,o.featuredProductIds$),h(([l,I,x])=>s.updateCategoryInfo({categories:l,products:I,featuredProductIds:x})),X(e),m(l=>(s.updateCategoryInfo({categories:[],products:[],featuredProductIds:[]}),console.error(l),B))).subscribe()}}var ot=[{path:"products",loadComponent:()=>import("./chunk-4BMJCRPK.js").then(t=>t.ProductCatalogueComponent),title:"Product list"},{path:"products/:id",loadComponent:()=>import("./chunk-CNGSGSY7.js").then(t=>t.ProductDetailsComponent),title:"Product"},{path:"my-cart",loadComponent:()=>import("./chunk-AWFTDC7C.js").then(t=>t.CartComponent),title:"My shopping cart"},{path:"categories/:category",loadComponent:()=>import("./chunk-Q2IPAXOY.js").then(t=>t.CategoryProductsComponent),title:"Category"},{path:"",pathMatch:"full",redirectTo:"products"},{path:"**",redirectTo:"products"}];var rt="https://fakestoreapi.com/products",ct="https://gist.githubusercontent.com/railsstudent/ae150ae2b14abb207f131596e8b283c3/raw/131a6b3a51dfb4d848b75980bfe3443b1665704b/featured-products.json",S=(()=>{let e=class e{constructor(){this.httpClient=a(b),this.featuredProductIds$=this.httpClient.get(ct).pipe(d(3),u(({ids:o})=>o),m(o=>(console.error(o),f([])))),this.products$=this.httpClient.get(rt).pipe(d(3),m(o=>(console.error(o),f([]))))}getProduct(o){if(!o)return Promise.resolve(null);let r=this.httpClient.get(`${rt}/${o}`).pipe(d(3),m(i=>(console.error(i),f(null))));return R(r)}};e.\u0275fac=function(r){return new(r||e)},e.\u0275prov=C({token:e,factory:e.\u0275fac,providedIn:"root"});let t=e;return t})();var it=(()=>{let e=class e extends P{constructor(){super(...arguments),this.title=a(W),this.productService=a(S)}updateTitle(o){let r=this.buildTitle(o)||"",i=o.root.firstChild?.params.id||"";i?this.productService.getProduct(i).then(I=>{let x=I?.title||"";this.title.setTitle(`Product - ${x}`)}):this.title.setTitle(r)}};e.\u0275fac=(()=>{let o;return function(i){return(o||(o=A(e)))(i||e)}})(),e.\u0275prov=C({token:e,factory:e.\u0275fac});let t=e;return t})();var nt={providers:[Q(),J(ot,K()),{provide:P,useClass:it},{provide:O,multi:!0,deps:[b,L,tt,S],useFactory:(t,e,s,o)=>et(t,e,s,o)}]};var T=(...t)=>{j(T);let e=a(q),s=a(H);return e.events.pipe(k(o=>o instanceof Y),u(o=>o),u(({url:o,urlAfterRedirects:r})=>!t.includes(o)&&!t.includes(r)),h(()=>s.markForCheck()))};var st=()=>["my-cart"];function mt(t,e){t&1&&(p(0,"a",0),c(1,"Home"),n())}function dt(t,e){t&1&&(p(0,"span"),c(1,"\xA0"),n())}function ut(t,e){t&1&&(p(0,"a",1),c(1,"View Cart"),n()),t&2&&U("routerLink",N(1,st))}function lt(t,e){t&1&&(p(0,"span"),c(1,"\xA0"),n())}var at=(()=>{let e=class e{constructor(){this.isShowHomeButton$=T("/","/products"),this.isShowViewCartButton$=T("/my-cart")}};e.\u0275fac=function(r){return new(r||e)},e.\u0275cmp=g({type:e,selectors:[["app-nav-bar"]],standalone:!0,features:[v],decls:7,vars:6,consts:[["routerLink","/"],[3,"routerLink"]],template:function(r,i){r&1&&(p(0,"div"),y(1,mt,2,0,"a",0),F(2,"async"),y(3,dt,2,0)(4,ut,2,2,"a",1),F(5,"async"),y(6,lt,2,0),n()),r&2&&(D(),E(1,$(2,2,i.isShowHomeButton$)?1:3),D(3),E(4,$(5,4,i.isShowViewCartButton$)?4:6))},dependencies:[z,V],styles:["div[_ngcontent-%COMP%]{background:#daa520;height:50px;padding:.25rem;margin-bottom:1rem;display:flex;justify-content:space-between;align-items:center}"],changeDetection:0});let t=e;return t})();var pt=(()=>{let e=class e{};e.\u0275fac=function(r){return new(r||e)},e.\u0275cmp=g({type:e,selectors:[["app-root"]],standalone:!0,features:[v],decls:5,vars:0,template:function(r,i){r&1&&(p(0,"div")(1,"h2"),c(2,"State Management using Angular Signal Demo"),n(),_(3,"app-nav-bar")(4,"router-outlet"),n())},dependencies:[Z,at],styles:["div[_ngcontent-%COMP%]{padding:.75rem}h2[_ngcontent-%COMP%]{margin-bottom:.75rem}"],changeDetection:0});let t=e;return t})();G(pt,nt).catch(t=>console.error(t)); +import{a as X}from"./chunk-PT7YKKZE.js";import{a as b,b as Q,c as G,d as W,e as Y,f as Z,g as P,h as q,i as z,j as J,k as K,l as tt}from"./chunk-KYWB336G.js";import{A as M,Eb as V,J as d,Ma as y,O as h,Oa as U,Qa as E,R as C,Ta as p,Ua as n,Va as _,X as a,Za as c,_ as g,eb as v,fa as j,fb as N,hb as F,ib as $,ja as A,l as B,mb as O,n as f,na as L,qb as H,r as R,s as u,y as k,z as m,za as D}from"./chunk-E2VPYGYD.js";function et(t,e,s,o){let r="https://fakestoreapi.com/products/categories";return()=>{t.get(r).pipe(d(3),M(o.products$,o.featuredProductIds$),h(([l,I,x])=>s.updateCategoryInfo({categories:l,products:I,featuredProductIds:x})),X(e),m(l=>(s.updateCategoryInfo({categories:[],products:[],featuredProductIds:[]}),console.error(l),B))).subscribe()}}var ot=[{path:"products",loadComponent:()=>import("./chunk-4BMJCRPK.js").then(t=>t.ProductCatalogueComponent),title:"Product list"},{path:"products/:id",loadComponent:()=>import("./chunk-M63LLZBS.js").then(t=>t.ProductDetailsComponent),title:"Product"},{path:"my-cart",loadComponent:()=>import("./chunk-UC2RG3ZV.js").then(t=>t.CartComponent),title:"My shopping cart"},{path:"categories/:category",loadComponent:()=>import("./chunk-Q2IPAXOY.js").then(t=>t.CategoryProductsComponent),title:"Category"},{path:"",pathMatch:"full",redirectTo:"products"},{path:"**",redirectTo:"products"}];var rt="https://fakestoreapi.com/products",ct="https://gist.githubusercontent.com/railsstudent/ae150ae2b14abb207f131596e8b283c3/raw/131a6b3a51dfb4d848b75980bfe3443b1665704b/featured-products.json",S=(()=>{let e=class e{constructor(){this.httpClient=a(b),this.featuredProductIds$=this.httpClient.get(ct).pipe(d(3),u(({ids:o})=>o),m(o=>(console.error(o),f([])))),this.products$=this.httpClient.get(rt).pipe(d(3),m(o=>(console.error(o),f([]))))}getProduct(o){if(!o)return Promise.resolve(null);let r=this.httpClient.get(`${rt}/${o}`).pipe(d(3),m(i=>(console.error(i),f(null))));return R(r)}};e.\u0275fac=function(r){return new(r||e)},e.\u0275prov=C({token:e,factory:e.\u0275fac,providedIn:"root"});let t=e;return t})();var it=(()=>{let e=class e extends P{constructor(){super(...arguments),this.title=a(W),this.productService=a(S)}updateTitle(o){let r=this.buildTitle(o)||"",i=o.root.firstChild?.params.id||"";i?this.productService.getProduct(i).then(I=>{let x=I?.title||"";this.title.setTitle(`Product - ${x}`)}):this.title.setTitle(r)}};e.\u0275fac=(()=>{let o;return function(i){return(o||(o=A(e)))(i||e)}})(),e.\u0275prov=C({token:e,factory:e.\u0275fac});let t=e;return t})();var nt={providers:[Q(),J(ot,K()),{provide:P,useClass:it},{provide:O,multi:!0,deps:[b,L,tt,S],useFactory:(t,e,s,o)=>et(t,e,s,o)}]};var T=(...t)=>{j(T);let e=a(q),s=a(H);return e.events.pipe(k(o=>o instanceof Y),u(o=>o),u(({url:o,urlAfterRedirects:r})=>!t.includes(o)&&!t.includes(r)),h(()=>s.markForCheck()))};var st=()=>["my-cart"];function mt(t,e){t&1&&(p(0,"a",0),c(1,"Home"),n())}function dt(t,e){t&1&&(p(0,"span"),c(1,"\xA0"),n())}function ut(t,e){t&1&&(p(0,"a",1),c(1,"View Cart"),n()),t&2&&U("routerLink",N(1,st))}function lt(t,e){t&1&&(p(0,"span"),c(1,"\xA0"),n())}var at=(()=>{let e=class e{constructor(){this.isShowHomeButton$=T("/","/products"),this.isShowViewCartButton$=T("/my-cart")}};e.\u0275fac=function(r){return new(r||e)},e.\u0275cmp=g({type:e,selectors:[["app-nav-bar"]],standalone:!0,features:[v],decls:7,vars:6,consts:[["routerLink","/"],[3,"routerLink"]],template:function(r,i){r&1&&(p(0,"div"),y(1,mt,2,0,"a",0),F(2,"async"),y(3,dt,2,0)(4,ut,2,2,"a",1),F(5,"async"),y(6,lt,2,0),n()),r&2&&(D(),E(1,$(2,2,i.isShowHomeButton$)?1:3),D(3),E(4,$(5,4,i.isShowViewCartButton$)?4:6))},dependencies:[z,V],styles:["div[_ngcontent-%COMP%]{background:#daa520;height:50px;padding:.25rem;margin-bottom:1rem;display:flex;justify-content:space-between;align-items:center}"],changeDetection:0});let t=e;return t})();var pt=(()=>{let e=class e{};e.\u0275fac=function(r){return new(r||e)},e.\u0275cmp=g({type:e,selectors:[["app-root"]],standalone:!0,features:[v],decls:5,vars:0,template:function(r,i){r&1&&(p(0,"div")(1,"h2"),c(2,"State Management using Angular Signal Demo"),n(),_(3,"app-nav-bar")(4,"router-outlet"),n())},dependencies:[Z,at],styles:["div[_ngcontent-%COMP%]{padding:.75rem}h2[_ngcontent-%COMP%]{margin-bottom:.75rem}"],changeDetection:0});let t=e;return t})();G(pt,nt).catch(t=>console.error(t));