@licklist/design 0.58.6-dev.4 → 0.58.6-dev.5

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 +1 @@
1
- {"version":3,"file":"ProductControl.d.ts","sourceRoot":"","sources":["../../../src/product-set/product/ProductControl.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,YAAY,EAMb,MAAM,kEAAkE,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,0DAA0D,CAAC;AAGvF,OAAO,EACL,mBAAmB,EACnB,UAAU,EACX,MAAM,8DAA8D,CAAC;AAEtE,OAAc,EACZ,WAAW,EAKZ,MAAM,OAAO,CAAC;AAgBf,OAAO,EACL,KAAK,EAEN,MAAM,sDAAsD,CAAC;AAO9D,OAAO,EAEL,oCAAoC,EACpC,qCAAqC,EACtC,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAEL,2BAA2B,EAC5B,MAAM,iCAAiC,CAAC;AAQzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAS5C,MAAM,WAAW,oBACf,SAAQ,UAAU,EAChB,2BAA2B,EAC3B,qCAAqC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG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I,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB,CAAC,CAAC,CACpC,SAAQ,gBAAgB,EACtB,mBAAmB,CAAC,CAAC,CAAC,EACtB,oCAAoC,CAAC,CAAC,CAAC;IACzC,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,aAAa,EAAE,OAAO,CAAC;IACvB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,mBAAmB,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAC;IAChE,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,UAAU,EAAE,EACnD,SAAiB,EACjB,eAAe,EACf,aAAqB,EACrB,oBAA4B,EAC5B,QAAa,EACb,MAAM,EACN,mBAAmB,EACnB,WAAW,EACX,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,WAAmB,GACpB,EAAE,mBAAmB,CAAC,CAAC,CAAC,eAwlBxB"}
@@ -1 +1 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),a=require("react"),n=e(a),r=require("react-i18next"),o=e(require("react-bootstrap/Row")),i=e(require("react-bootstrap/Col")),l=require("react-bootstrap"),c=require("../../static/Icon.js"),s=require("react-hook-form"),d=e(require("@licklist/plugins/dist/services/Form/HookFormService")),m=require("@react-aria/utils"),u=e(require("clsx")),p=require("../../static/switch/BooleanSwitch.js"),E=require("../../static/form-number-input/FormNumberInput.js");require("../../static/index.js");var g=require("../form/context.js"),f=require("@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper"),C=require("@licklist/core/dist/DataMapper/Product/ProductDataMapper"),v=require("./booking-management/ProductBookingManagementControl.js"),b=require("./deposit/ProductDepositControl.js"),h=require("./quantity/ProductQuantityControl.js"),P=require("./quantity/ProductQuantityConstantControl.js"),I=require("./quantity/ProductQuantityRechargingControl.js"),N=e(require("react-bootstrap/Collapse")),F=require("@licklist/plugins/dist/hooks/Media/useImages"),q=require("@licklist/core/dist/DataMapper/Media/ImageDataMapper"),T=require("../../file-upload/FileUpload.js");require("../../snippet/snippet-template/context/snippetTemplate.js"),require("../../snippet/snippet-template/context/snippetTemplateLoading.js"),require("../../snippet/snippet-template/context/snippetTemplateView.js");var y=require("../../snippet/snippet-template/control/PropertyControl.js");require("../../snippet/snippet-template/form/SnippetTemplateForm.js");var x=require("../../tiptap-editor/TipTapEditor.js");require("../../snippet/snippet-template/settings/SettingButton.js"),require("../../snippet/snippet-template/preview/Preview.js"),require("../../snippet/snippet-template/SnippetTemplate.js");var _=require("./fixed-duration-fields/FixedDurationOptions.js"),k=require("./duration/ProductDurationControl.js"),S=require("./price/ProductPriceControl.js"),D=require("./constants.js");exports.ProductControl=function(e){var j=e.isLoading,L=void 0!==j&&j,A=e.fieldNamePrefix,w=e.allowDeposits,R=void 0!==w&&w,M=e.hasBookingManagement,O=void 0!==M&&M,G=e.zoneList,U=void 0===G?[]:G,B=e.onCopy,Y=e.onProductNameChange,V=e.productName,Q=e.hasTicket,H=e.categoryType,X=e.zoneDuration,z=e.isOverrides,W=void 0!==z&&z,Z=s.useFormContext(),J=Z.register,K=Z.control,$=Z.formState.errors,ee=Z.setValue,te=Z.getValues,ae=Z.watch,ne=Z.trigger,re=Z.clearErrors,oe=a.useContext(g.ProductSetLoadingContext).setLoading,ie=r.useTranslation(["Design","Validation"]).t,le=t.__read(a.useState(!1),2),ce=le[0],se=le[1],de=t.__read(a.useState(null),2),me=de[0],ue=de[1],pe=Boolean(ae("".concat(A,".isUnlimited"))),Ee=ae("".concat(A,".capacity")),ge="0"===Ee||!Ee,fe=m.useId(),Ce=m.useId(),ve=m.useId(),be=m.useId(),he=m.useId(),Pe=m.useId(),Ie=m.useId(),Ne=m.useId(),Fe=m.useId(),qe=m.useId(),Te=m.useId(),ye=[{id:1,value:ie("quantitySelector")},{id:2,value:ie("stockControl")}],xe=a.useCallback((function(){return se((function(e){return!e}))}),[]),_e=s.useWatch({control:K,name:"".concat(A,".quantitySelector")}),ke=F.useImages(me),Se=ke.images,De=ke.handleImageRemove,je=ke.handleImageUploading,Le=ke.isLoading,Ae=a.useCallback((function(e){je(e,q.IMAGE_TYPE_IMAGE)}),[je]),we=a.useCallback((function(e,t){De(String(e),t)}),[De]),Re=function(e){return e.target.select()};a.useEffect((function(){oe(Le)}),[oe,Le]),a.useEffect((function(){var e=te("".concat(A,".images"));ue(e)}),[te,ue,A]),a.useEffect((function(){Array.isArray(Se)&&ee("".concat(A,".images"),Se)}),[Se,A,ee]),a.useEffect((function(){ge?(ee("".concat(A,".duration"),0),re("".concat(A,".duration"))):ne("".concat(A,".duration"))}),[ge]);var Me=null!=_e?_e:"1",Oe=f.QUANTITY_TYPE_LIST_DTO[Me];return n.createElement(n.Fragment,null,n.createElement(o,null,n.createElement(i,{lg:8,md:8},n.createElement(l.Form.Group,{controlId:Ce},n.createElement(l.Form.Label,null,ie("name")),n.createElement(l.Form.Control,t.__assign({},J("".concat(A,".name")),{value:V,onChange:Y,isInvalid:d.isInvalid("".concat(A,".name"),$),disabled:L||W,placeholder:ie("name")})),n.createElement(l.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(A,".name"),$))),n.createElement(l.Form.Group,{controlId:ve},n.createElement(l.Form.Label,null,ie("description")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange;return n.createElement(x.TipTapEditor,{withEmoji:!1,viewMode:!1,onUpdate:r,content:a,disabled:L||W})},rules:{maxLength:{value:D.MAX_PRODUCT_DESCRIPTION_CHARACTERS_LENGTH,message:ie("Validation:descriptionTooManyCharactersMessage",{max:D.MAX_PRODUCT_DESCRIPTION_CHARACTERS_LENGTH})}},control:K,name:"".concat(A,".description")})),n.createElement("div",{className:"invalid-feedback field-values-error d-block"},d.getErrors("".concat(A,".description"),$)),R?n.createElement(o,null,n.createElement(b.ProductDepositControl,{isLoading:L,fieldNamePrefix:A}),n.createElement(S.ProductPriceControl,{isLoading:L,fieldNamePrefix:"".concat(A,".price"),title:ie("totalPrice"),allowDeposits:R})):n.createElement(S.ProductPriceControl,{isLoading:L,fieldNamePrefix:"".concat(A,".price")}),n.createElement("div",null,n.createElement(h.ProductQuantityControl,{isLoading:L,fieldNamePrefix:A,isOverrides:W,onFocus:Re}),Oe===f.QUANTITY_TYPE_CONSTANT&&n.createElement(P.ProductQuantityConstantControl,{isLoading:L,fieldNamePrefix:A,onFocus:Re,disabled:pe}),Oe===f.QUANTITY_TYPE_RECHARGING&&n.createElement(I.ProductQuantityRechargingControl,{isLoading:L,fieldNamePrefix:A,onFocus:Re,disabled:pe}),n.createElement(l.Form.Group,{controlId:qe,className:"custom-checkbox"},n.createElement(l.Form.Check,t.__assign({custom:!0,type:"checkbox"},J("".concat(A,".isUnlimited")),{name:"".concat(A,".isUnlimited"),disabled:L})),n.createElement(l.Form.Check.Label,null,ie("isUnlimited")))),n.createElement(l.Form.Group,{controlId:Ne},n.createElement(l.Form.Label,null,ie("quantitySelectorType")),n.createElement(l.Form.Control,t.__assign({as:"select",defaultValue:Q?ye[0].id:void 0},J("".concat(A,".quantitySelector")),{isInvalid:d.isInvalid("".concat(A,".quantitySelector"),$),disabled:L||Q||W}),ye.map((function(e){return n.createElement("option",{value:e.id,key:e.id},e.value)}))),n.createElement(l.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(A,".quantitySelector"),$))),n.createElement(y.PropertyControl,{item:"".concat(A,".color"),label:"Select Color",isDisabled:W,defaultColors:C.PRODUCT_DEfAULT_COLORS}))),H===f.CATEGORY_TYPE_FIXED_DURATION&&n.createElement(o,{className:"align-items-start duration-capacity-container"},n.createElement(k.ProductDurationControl,{fieldNamePrefix:A,disabled:ge||W}),n.createElement(i,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(A,".capacity"),label:ie("capacity"),disabled:W,rules:{min:{value:0,message:ie("Validation:fieldMinNumber",{attribute:ie("capacity"),min:0})}}})),ge&&n.createElement("div",{className:"duration-hint duration-capacity-container"},ie("Design:forDurationEditing"))),H===f.CATEGORY_TYPE_GAME&&n.createElement(n.Fragment,null,n.createElement(o,{className:"align-items-start duration-capacity-container"},n.createElement(i,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(A,".capacity"),label:ie("capacity"),onChange:function(e){X&&ee("".concat(A,".duration"),e*X)},disabled:W,rules:{min:{value:0,message:ie("Validation:fieldMinNumber",{attribute:ie("capacity"),min:1})}}})),n.createElement(i,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(A,".duration"),label:ie("durationMinutes"),disabled:ge||W,rules:{min:{value:0,message:ie("Validation:fieldMinNumber",{attribute:ie("duration"),min:0})},validate:function(e){return!(!ge&&(!e||e<1))||ie("Validation:fieldRequired",{attribute:ie("duration")})}}}))),ge&&n.createElement("div",{className:"duration-hint pl-0"},ie("Design:forDurationEditing"))),n.createElement(o,{className:"mt-4"},n.createElement(i,{lg:8,md:8},n.createElement(l.Form.Group,{controlId:be},n.createElement(l.Form.Label,null,ie("productTermsConditions")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name,i=t.ref;return n.createElement(l.Form.Control,{ref:i,as:"textarea",rows:3,value:a,onChange:r,isInvalid:d.isInvalid("".concat(A,".termsAndConditions"),$),disabled:L||W,name:o})},control:K,name:"".concat(A,".termsAndConditions")}),n.createElement(l.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(A,".termsAndConditions"),$)))),n.createElement(i,{lg:4,md:4,className:u("licklist-file-upload-wrapper",W&&"opacity-50")},n.createElement(T.FileUpload,{onFilesChange:Ae,allowedExtensions:["jpeg","jpg","png"],subTitle:".jpeg .jpg .png",enablePreview:!0,onFileRemove:we,defaultFiles:Se,isLoading:Le,disabled:W,withIcon:!0,title:ie("addImage")}))),n.createElement(i,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(l.Form.Group,{controlId:he,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ie("isAvailable")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:L||W})},control:K,name:"".concat(A,".isAvailable")})),n.createElement(l.Form.Group,{controlId:Pe,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ie("isSoldOut")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:L})},control:K,name:"".concat(A,".isSoldOut")})),n.createElement(l.Form.Group,{controlId:fe,className:"custom-checkbox"},n.createElement(l.Form.Check,{custom:!0,type:"checkbox",name:fe,disabled:L||W},n.createElement(l.Form.Check.Input,{checked:ce,onChange:xe,type:"checkbox"}),n.createElement(l.Form.Check.Label,null,ie("showAdvancedOptions"))))),n.createElement(i,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(N,{in:ce},n.createElement("div",null,n.createElement(l.Form.Group,{controlId:Ie,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ie("isRequired")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:L||W})},control:K,name:"".concat(A,".isRequired")})),n.createElement(l.Form.Group,{controlId:Fe,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ie("hasSpecialNotes")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:L||W})},control:K,name:"".concat(A,".hasSpecialNotes")})),[f.CATEGORY_TYPE_GAME,f.CATEGORY_TYPE_FIXED_DURATION].includes(H)&&n.createElement(_.FixedDurationOptions,{fieldNamePrefix:A,isOverrides:W}),n.createElement(l.Form.Group,{controlId:Te,className:"advanced-switch-container"},n.createElement(S.ProductPriceControl,{title:ie("minSpend"),isRequired:!1,isMoreThanZero:!0,allowDeposits:!1,isLoading:L||W,fieldNamePrefix:"".concat(A,".minSpend")})))),n.createElement(o,null,n.createElement(i,{xs:12},O&&n.createElement(v.ProductBookingManagementControl,{isLoading:L,zoneList:U,fieldNamePrefix:A})))),n.createElement(o,null,n.createElement(i,{xs:!0},n.createElement("div",{className:"d-flex justify-content-end mt-4"},Boolean(B)&&n.createElement(l.Button,{onClick:B,variant:"link",className:"d-flex align-items-center"},n.createElement(c.default,{type:"clipboard",height:"1rem",className:"mr-2"})," ",ie("copy"))))))};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("tslib"),a=require("react"),n=e(a),r=require("react-i18next"),o=e(require("react-bootstrap/Row")),i=e(require("react-bootstrap/Col")),l=require("react-bootstrap"),c=require("../../static/Icon.js"),s=require("react-hook-form"),d=e(require("@licklist/plugins/dist/services/Form/HookFormService")),u=require("@react-aria/utils"),m=e(require("clsx")),p=require("../../static/switch/BooleanSwitch.js"),E=require("../../static/form-number-input/FormNumberInput.js");require("../../static/index.js");var g=require("../form/context.js"),f=require("@licklist/core/dist/DataMapper/Product/ProductCategoryDataMapper"),C=require("@licklist/core/dist/DataMapper/Product/ProductDataMapper"),v=require("./booking-management/ProductBookingManagementControl.js"),b=require("./deposit/ProductDepositControl.js"),h=require("./quantity/ProductQuantityControl.js"),P=require("./quantity/ProductQuantityConstantControl.js"),I=require("./quantity/ProductQuantityRechargingControl.js"),N=e(require("react-bootstrap/Collapse")),F=require("@licklist/plugins/dist/hooks/Media/useImages"),q=require("@licklist/core/dist/DataMapper/Media/ImageDataMapper"),T=require("../../file-upload/FileUpload.js");require("../../snippet/snippet-template/context/snippetTemplate.js"),require("../../snippet/snippet-template/context/snippetTemplateLoading.js"),require("../../snippet/snippet-template/context/snippetTemplateView.js");var y=require("../../snippet/snippet-template/control/PropertyControl.js");require("../../snippet/snippet-template/form/SnippetTemplateForm.js");var x=require("../../tiptap-editor/TipTapEditor.js");require("../../snippet/snippet-template/settings/SettingButton.js"),require("../../snippet/snippet-template/preview/Preview.js"),require("../../snippet/snippet-template/SnippetTemplate.js");var _=require("./fixed-duration-fields/FixedDurationOptions.js"),k=require("./duration/ProductDurationControl.js"),S=require("./price/ProductPriceControl.js"),D=require("./constants.js");exports.ProductControl=function(e){var j=e.isLoading,L=void 0!==j&&j,A=e.fieldNamePrefix,R=e.allowDeposits,w=void 0!==R&&R,M=e.hasBookingManagement,O=void 0!==M&&M,G=e.zoneList,U=void 0===G?[]:G,B=e.onCopy,Y=e.onProductNameChange,V=e.productName,Q=e.hasTicket,H=e.categoryType,X=e.zoneDuration,z=e.isOverrides,W=void 0!==z&&z,Z=s.useFormContext(),J=Z.register,K=Z.control,$=Z.formState.errors,ee=Z.setValue,te=Z.getValues,ae=Z.watch,ne=Z.trigger,re=Z.clearErrors,oe=a.useContext(g.ProductSetLoadingContext).setLoading,ie=r.useTranslation(["Design","Validation","ProductSet"]).t,le=t.__read(a.useState(!1),2),ce=le[0],se=le[1],de=t.__read(a.useState(null),2),ue=de[0],me=de[1],pe=Boolean(ae("".concat(A,".isUnlimited"))),Ee=ae("".concat(A,".capacity")),ge="0"===Ee||!Ee,fe=u.useId(),Ce=u.useId(),ve=u.useId(),be=u.useId(),he=u.useId(),Pe=u.useId(),Ie=u.useId(),Ne=u.useId(),Fe=u.useId(),qe=u.useId(),Te=u.useId(),ye=[{id:1,value:ie("quantitySelector")},{id:2,value:ie("stockControl")}],xe=a.useCallback((function(){return se((function(e){return!e}))}),[]),_e=s.useWatch({control:K,name:"".concat(A,".quantitySelector")}),ke=F.useImages(ue),Se=ke.images,De=ke.handleImageRemove,je=ke.handleImageUploading,Le=ke.isLoading,Ae=a.useCallback((function(e){je(e,q.IMAGE_TYPE_IMAGE)}),[je]),Re=a.useCallback((function(e,t){De(String(e),t)}),[De]),we=function(e){return e.target.select()};a.useEffect((function(){oe(Le)}),[oe,Le]),a.useEffect((function(){var e=te("".concat(A,".images"));me(e)}),[te,me,A]),a.useEffect((function(){Array.isArray(Se)&&ee("".concat(A,".images"),Se)}),[Se,A,ee]),a.useEffect((function(){ge?(ee("".concat(A,".duration"),0),re("".concat(A,".duration"))):ne("".concat(A,".duration"))}),[ge]);var Me=null!=_e?_e:"1",Oe=f.QUANTITY_TYPE_LIST_DTO[Me];return n.createElement(n.Fragment,null,n.createElement(o,null,n.createElement(i,{lg:8,md:8},n.createElement(l.Form.Group,{controlId:Ce},n.createElement(l.Form.Label,null,ie("name")),n.createElement(l.Form.Control,t.__assign({},J("".concat(A,".name")),{value:V,onChange:Y,isInvalid:d.isInvalid("".concat(A,".name"),$),disabled:L||W,placeholder:ie("name")})),n.createElement(l.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(A,".name"),$))),n.createElement(l.Form.Group,{controlId:ve},n.createElement(l.Form.Label,null,ie("description")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange;return n.createElement(x.TipTapEditor,{withEmoji:!1,viewMode:!1,onUpdate:r,content:a,disabled:L||W})},rules:{maxLength:{value:D.MAX_PRODUCT_DESCRIPTION_CHARACTERS_LENGTH,message:ie("Validation:descriptionTooManyCharactersMessage",{max:D.MAX_PRODUCT_DESCRIPTION_CHARACTERS_LENGTH})}},control:K,name:"".concat(A,".description")})),n.createElement("div",{className:"invalid-feedback field-values-error d-block"},d.getErrors("".concat(A,".description"),$)),w?n.createElement(o,null,n.createElement(b.ProductDepositControl,{isLoading:L,fieldNamePrefix:A}),n.createElement(S.ProductPriceControl,{isLoading:L,fieldNamePrefix:"".concat(A,".price"),title:ie("totalPrice"),allowDeposits:w})):n.createElement(S.ProductPriceControl,{isLoading:L,fieldNamePrefix:"".concat(A,".price")}),n.createElement("div",null,n.createElement(h.ProductQuantityControl,{isLoading:L,fieldNamePrefix:A,isOverrides:W,onFocus:we}),Oe===f.QUANTITY_TYPE_CONSTANT&&n.createElement(P.ProductQuantityConstantControl,{isLoading:L,fieldNamePrefix:A,onFocus:we,disabled:pe}),Oe===f.QUANTITY_TYPE_RECHARGING&&n.createElement(I.ProductQuantityRechargingControl,{isLoading:L,fieldNamePrefix:A,onFocus:we,disabled:pe}),n.createElement(l.Form.Group,{controlId:qe,className:"custom-checkbox"},n.createElement(l.Form.Check,t.__assign({custom:!0,type:"checkbox"},J("".concat(A,".isUnlimited")),{name:"".concat(A,".isUnlimited"),disabled:L})),n.createElement(l.Form.Check.Label,null,ie("isUnlimited")))),n.createElement(l.Form.Group,{controlId:Ne},n.createElement(l.Form.Label,null,ie("quantitySelectorType")),n.createElement(l.Form.Control,t.__assign({as:"select",defaultValue:Q?ye[0].id:void 0},J("".concat(A,".quantitySelector")),{isInvalid:d.isInvalid("".concat(A,".quantitySelector"),$),disabled:L||Q||W}),ye.map((function(e){return n.createElement("option",{value:e.id,key:e.id},e.value)}))),n.createElement(l.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(A,".quantitySelector"),$))),n.createElement(y.PropertyControl,{item:"".concat(A,".color"),label:ie("ProductSet:selectColor"),isDisabled:W,isRequired:!1,defaultColors:C.PRODUCT_DEfAULT_COLORS}))),H===f.CATEGORY_TYPE_FIXED_DURATION&&n.createElement(o,{className:"align-items-start duration-capacity-container"},n.createElement(k.ProductDurationControl,{fieldNamePrefix:A,disabled:ge||W}),n.createElement(i,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(A,".capacity"),label:ie("capacity"),disabled:W,rules:{min:{value:0,message:ie("Validation:fieldMinNumber",{attribute:ie("capacity"),min:0})}}})),ge&&n.createElement("div",{className:"duration-hint duration-capacity-container"},ie("Design:forDurationEditing"))),H===f.CATEGORY_TYPE_GAME&&n.createElement(n.Fragment,null,n.createElement(o,{className:"align-items-start duration-capacity-container"},n.createElement(i,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(A,".capacity"),label:ie("capacity"),onChange:function(e){X&&ee("".concat(A,".duration"),e*X)},disabled:W,rules:{min:{value:0,message:ie("Validation:fieldMinNumber",{attribute:ie("capacity"),min:1})}}})),n.createElement(i,{lg:4,md:4},n.createElement(E.FormNumberInput,{fieldName:"".concat(A,".duration"),label:ie("durationMinutes"),disabled:ge||W,rules:{min:{value:0,message:ie("Validation:fieldMinNumber",{attribute:ie("duration"),min:0})},validate:function(e){return!(!ge&&(!e||e<1))||ie("Validation:fieldRequired",{attribute:ie("duration")})}}}))),ge&&n.createElement("div",{className:"duration-hint pl-0"},ie("Design:forDurationEditing"))),n.createElement(o,{className:"mt-4"},n.createElement(i,{lg:8,md:8},n.createElement(l.Form.Group,{controlId:be},n.createElement(l.Form.Label,null,ie("productTermsConditions")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name,i=t.ref;return n.createElement(l.Form.Control,{ref:i,as:"textarea",rows:3,value:a,onChange:r,isInvalid:d.isInvalid("".concat(A,".termsAndConditions"),$),disabled:L||W,name:o})},control:K,name:"".concat(A,".termsAndConditions")}),n.createElement(l.Form.Control.Feedback,{type:"invalid"},d.getErrors("".concat(A,".termsAndConditions"),$)))),n.createElement(i,{lg:4,md:4,className:m("licklist-file-upload-wrapper",W&&"opacity-50")},n.createElement(T.FileUpload,{onFilesChange:Ae,allowedExtensions:["jpeg","jpg","png"],subTitle:".jpeg .jpg .png",enablePreview:!0,onFileRemove:Re,defaultFiles:Se,isLoading:Le,disabled:W,withIcon:!0,title:ie("addImage")}))),n.createElement(i,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(l.Form.Group,{controlId:he,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ie("isAvailable")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:L||W})},control:K,name:"".concat(A,".isAvailable")})),n.createElement(l.Form.Group,{controlId:Pe,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ie("isSoldOut")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:L})},control:K,name:"".concat(A,".isSoldOut")})),n.createElement(l.Form.Group,{controlId:fe,className:"custom-checkbox"},n.createElement(l.Form.Check,{custom:!0,type:"checkbox",name:fe,disabled:L||W},n.createElement(l.Form.Check.Input,{checked:ce,onChange:xe,type:"checkbox"}),n.createElement(l.Form.Check.Label,null,ie("showAdvancedOptions"))))),n.createElement(i,{lg:12,md:12,xl:!0,className:"p-0"},n.createElement(N,{in:ce},n.createElement("div",null,n.createElement(l.Form.Group,{controlId:Ie,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ie("isRequired")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:L||W})},control:K,name:"".concat(A,".isRequired")})),n.createElement(l.Form.Group,{controlId:Fe,className:"advanced-switch-container"},n.createElement(l.Form.Label,null,ie("hasSpecialNotes")),n.createElement(s.Controller,{render:function(e){var t=e.field,a=t.value,r=t.onChange,o=t.name;return n.createElement(p.BooleanSwitch,{name:o,value:Boolean(a),onChange:r,disabled:L||W})},control:K,name:"".concat(A,".hasSpecialNotes")})),[f.CATEGORY_TYPE_GAME,f.CATEGORY_TYPE_FIXED_DURATION].includes(H)&&n.createElement(_.FixedDurationOptions,{fieldNamePrefix:A,isOverrides:W}),n.createElement(l.Form.Group,{controlId:Te,className:"advanced-switch-container"},n.createElement(S.ProductPriceControl,{title:ie("minSpend"),isRequired:!1,isMoreThanZero:!0,allowDeposits:!1,isLoading:L||W,fieldNamePrefix:"".concat(A,".minSpend")})))),n.createElement(o,null,n.createElement(i,{xs:12},O&&n.createElement(v.ProductBookingManagementControl,{isLoading:L,zoneList:U,fieldNamePrefix:A})))),n.createElement(o,null,n.createElement(i,{xs:!0},n.createElement("div",{className:"d-flex justify-content-end mt-4"},Boolean(B)&&n.createElement(l.Button,{onClick:B,variant:"link",className:"d-flex align-items-center"},n.createElement(c.default,{type:"clipboard",height:"1rem",className:"mr-2"})," ",ie("copy"))))))};
@@ -5,6 +5,7 @@ export interface PropertyControlProps<T> {
5
5
  label: string;
6
6
  isDisabled?: boolean;
7
7
  defaultColors?: Array<string>;
8
+ isRequired?: boolean;
8
9
  }
9
- export declare function PropertyControl<T>({ item, label, isDisabled, defaultColors, }: PropertyControlProps<T>): JSX.Element;
10
+ export declare function PropertyControl<T>({ item, label, isDisabled, defaultColors, isRequired, }: PropertyControlProps<T>): JSX.Element;
10
11
  //# sourceMappingURL=PropertyControl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PropertyControl.d.ts","sourceRoot":"","sources":["../../../../src/snippet/snippet-template/control/PropertyControl.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAkB,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAmBvD,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAC/B;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,EACjC,IAAI,EACJ,KAAK,EACL,UAAkB,EAClB,aAAa,GACd,EAAE,oBAAoB,CAAC,CAAC,CAAC,eA0EzB"}
1
+ {"version":3,"file":"PropertyControl.d.ts","sourceRoot":"","sources":["../../../../src/snippet/snippet-template/control/PropertyControl.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAkB,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAmBvD,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,EACjC,IAAI,EACJ,KAAK,EACL,UAAkB,EAClB,aAAa,EACb,UAAiB,GAClB,EAAE,oBAAoB,CAAC,CAAC,CAAC,eA0EzB"}
@@ -1 +1 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("tslib"),t=require("react"),o=e(t),i=require("react-i18next"),a=require("react-bootstrap"),l=require("react-hook-form"),n=e(require("@licklist/plugins/dist/services/Form/HookFormService")),c=require("react-color"),s=["#FF6900","#FCB900","#7BDCB5","#00D084","#8ED1FC","#0693E3","#ABB8C3","#EB144C","#F78DA7","#9900EF","#FFFFFF","#000000"];exports.PropertyControl=function(e){var u,d=e.item,m=e.label,F=e.isDisabled,v=void 0!==F&&F,p=e.defaultColors,f=i.useTranslation(["Validation"]).t,C=r.__read(t.useState(!1),2),b=C[0],E=C[1],k=l.useFormContext(),_=k.watch,q=k.register,g=k.setValue,x=k.formState,y=k.formState.errors,B=_(d),N=t.useCallback((function(e){return n.isFieldValid(x,y,e)}),[x,y]),h=function(){E((function(e){return!e}))};return o.createElement(a.Form.Group,{className:"position-relative color-picker"},o.createElement(a.Form.Label,{className:"mt-2"},m),o.createElement("div",{className:"position-relative"},o.createElement(a.Form.Control,r.__assign({},q(d,{required:{value:!0,message:f("Validation:fieldRequired",{attribute:m})}}),{isValid:N(d),isInvalid:n.isInvalid(d,y),disabled:v,onFocus:h})),o.createElement("div",{className:"color-picker__color",style:{backgroundColor:null!==(u=String(B))&&void 0!==u?u:""}})),b&&o.createElement("div",{className:"color-picker__popover"},o.createElement("div",{className:"color-picker__cover vh-100 vw-100",onClick:h,onKeyPress:h,role:"button",tabIndex:0}),o.createElement(c.TwitterPicker,{color:null!=B?B:"",onChangeComplete:function(e){g(d,e.hex),h()},colors:p||s})),o.createElement(a.Form.Control.Feedback,{type:"invalid"},n.getErrors(d,y)))};
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var r=require("tslib"),t=require("react"),o=e(t),i=require("react-i18next"),a=require("react-bootstrap"),l=require("react-hook-form"),n=e(require("@licklist/plugins/dist/services/Form/HookFormService")),s=require("react-color"),c=["#FF6900","#FCB900","#7BDCB5","#00D084","#8ED1FC","#0693E3","#ABB8C3","#EB144C","#F78DA7","#9900EF","#FFFFFF","#000000"];exports.PropertyControl=function(e){var u,d=e.item,m=e.label,v=e.isDisabled,F=void 0!==v&&v,p=e.defaultColors,f=e.isRequired,C=void 0===f||f,b=i.useTranslation(["Validation"]).t,E=r.__read(t.useState(!1),2),k=E[0],_=E[1],q=l.useFormContext(),g=q.watch,x=q.register,y=q.setValue,B=q.formState,N=q.formState.errors,h=g(d),D=t.useCallback((function(e){return n.isFieldValid(B,N,e)}),[B,N]),S=function(){_((function(e){return!e}))};return o.createElement(a.Form.Group,{className:"position-relative color-picker"},o.createElement(a.Form.Label,{className:"mt-2"},m),o.createElement("div",{className:"position-relative"},o.createElement(a.Form.Control,r.__assign({},x(d,{required:{value:C,message:b("Validation:fieldRequired",{attribute:m})}}),{isValid:D(d),isInvalid:n.isInvalid(d,N),disabled:F,onFocus:S})),o.createElement("div",{className:"color-picker__color",style:{backgroundColor:null!==(u=String(h))&&void 0!==u?u:""}})),k&&o.createElement("div",{className:"color-picker__popover"},o.createElement("div",{className:"color-picker__cover vh-100 vw-100",onClick:S,onKeyPress:S,role:"button",tabIndex:0}),o.createElement(s.TwitterPicker,{color:null!=h?h:"",onChangeComplete:function(e){y(d,e.hex),S()},colors:p||c})),o.createElement(a.Form.Control.Feedback,{type:"invalid"},n.getErrors(d,N)))};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.58.6-dev.4",
3
+ "version": "0.58.6-dev.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -148,7 +148,7 @@ export function ProductControl<T extends FormValues>({
148
148
  } = useFormContext<T>();
149
149
 
150
150
  const { setLoading } = useContext(ProductSetLoadingContext);
151
- const { t } = useTranslation(["Design", "Validation"]);
151
+ const { t } = useTranslation(["Design", "Validation", "ProductSet"]);
152
152
  const [expanded, setExpanded] = useState(false);
153
153
  const [initialImages, setInitialImages] = useState<Image[] | null>(null);
154
154
  // @TODO: After checking "isUnlimited" checkbox need to reset field totalQuantity
@@ -396,8 +396,9 @@ export function ProductControl<T extends FormValues>({
396
396
 
397
397
  <PropertyControl<T>
398
398
  item={`${fieldNamePrefix}.color` as Path<T>}
399
- label={"Select Color"}
399
+ label={t("ProductSet:selectColor")}
400
400
  isDisabled={isOverrides}
401
+ isRequired={false}
401
402
  defaultColors={PRODUCT_DEfAULT_COLORS}
402
403
  />
403
404
  </Col>
@@ -25,6 +25,7 @@ export interface PropertyControlProps<T> {
25
25
  label: string;
26
26
  isDisabled?: boolean;
27
27
  defaultColors?: Array<string>;
28
+ isRequired?: boolean;
28
29
  }
29
30
 
30
31
  export function PropertyControl<T>({
@@ -32,6 +33,7 @@ export function PropertyControl<T>({
32
33
  label,
33
34
  isDisabled = false,
34
35
  defaultColors,
36
+ isRequired = true,
35
37
  }: PropertyControlProps<T>) {
36
38
  const { t } = useTranslation(["Validation"]);
37
39
 
@@ -64,7 +66,7 @@ export function PropertyControl<T>({
64
66
  <Form.Control
65
67
  {...register(item, {
66
68
  required: {
67
- value: true,
69
+ value: isRequired,
68
70
  message: t("Validation:fieldRequired", {
69
71
  attribute: label,
70
72
  }),