@licklist/design 0.55.1 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/events/edit-event-modal/IntervalInput.d.ts.map +1 -1
- package/dist/events/edit-event-modal/IntervalInput.js +1 -1
- package/dist/events/edit-event-modal/hooks/index.d.ts +3 -0
- package/dist/events/edit-event-modal/hooks/index.d.ts.map +1 -0
- package/dist/events/edit-event-modal/hooks/useFormattedDuration.d.ts +2 -0
- package/dist/events/edit-event-modal/hooks/useFormattedDuration.d.ts.map +1 -0
- package/dist/events/edit-event-modal/hooks/useFormattedDuration.js +1 -0
- package/dist/events/edit-event-modal/hooks/useValidationOptions.d.ts +11 -0
- package/dist/events/edit-event-modal/hooks/useValidationOptions.d.ts.map +1 -0
- package/dist/events/edit-event-modal/hooks/useValidationOptions.js +1 -0
- package/dist/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.js +1 -1
- package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.d.ts.map +1 -1
- package/dist/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.js +1 -1
- package/dist/styles/snippet-templates/SnippetTemplate.scss +17 -11
- package/package.json +1 -1
- package/src/events/edit-event-modal/IntervalInput.tsx +8 -80
- package/src/events/edit-event-modal/hooks/index.ts +2 -0
- package/src/events/edit-event-modal/hooks/useFormattedDuration.tsx +40 -0
- package/src/events/edit-event-modal/hooks/useValidationOptions.tsx +36 -0
- package/src/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.tsx +10 -3
- package/src/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.tsx +6 -1
- package/src/styles/snippet-templates/SnippetTemplate.scss +17 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntervalInput.d.ts","sourceRoot":"","sources":["../../../src/events/edit-event-modal/IntervalInput.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"IntervalInput.d.ts","sourceRoot":"","sources":["../../../src/events/edit-event-modal/IntervalInput.tsx"],"names":[],"mappings":";AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,6DAA6D,CAAC;AAIzF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,UAAU,kBAAkB;IAC1B,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;IACxC,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,wBAAgB,aAAa,CAAC,EAC5B,QAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,WAAW,GACZ,EAAE,kBAAkB,eAqJpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("tslib"),r=require("react"),n=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,a=require("react-i18next"),o=require("react-bootstrap"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("tslib"),r=require("react"),n=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,a=require("react-i18next"),o=require("react-bootstrap"),l=require("react-hook-form"),i=require("@react-aria/utils"),u=require("../../static/WarningMessage.js"),c=require("luxon");require("../../static/index.js");var d=require("../../recurrence-input/RecurrenceInput.js"),s=require("./hooks/useFormattedDuration.js"),m=require("./hooks/useValidationOptions.js");exports.IntervalInput=function(e){var v,f,p=e.disabled,g=void 0!==p&&p,F=e.editedProductSet,E=e.productSetId,h=e.productSets,C=a.useTranslation(["Design","Validation"]).t,I=l.useFormContext(),b=I.register,q=I.formState.errors,k=I.control,y=I.trigger,_=I.setValue,S=s.useFormattedDuration(),x=m.useValidationOptions(),D=l.useWatch({control:k,name:"rrule"}),j=l.useWatch({control:k,name:"start"}),O=l.useWatch({control:k,name:"end"}),B=t.__read(r.useState(Boolean(D)),2),M=B[0],R=B[1],T=t.__read(r.useState(!1),2),W=T[0],G=T[1],P=i.useId(),V=r.useRef(null),w=r.useRef(null);return r.useEffect((function(){F&&R(!1)}),[F]),r.useEffect((function(){if(h){var e=h.find((function(e){return F&&(null==e?void 0:e.id)===(null==F?void 0:F.id)||Boolean(null==e?void 0:e.parentMenuId)&&(null==e?void 0:e.id)===E}));G(Boolean(e))}}),[h,E,G,F]),n.createElement(n.Fragment,null,n.createElement(o.Form.Row,{className:"interval-container"},n.createElement(o.Form.Group,{as:o.Col,controlId:"start"},n.createElement(o.Form.Label,null,C("start")),n.createElement(o.Form.Control,t.__assign({type:"datetime-local"},b("start",x.start),{value:j,name:"start",required:!0,isInvalid:Boolean(q.start),onChange:function(e){var t=e.target.value;R(!1),_("start",t),c.DateTime.fromISO(O).diff(c.DateTime.fromISO(t)).toMillis()<0&&_("end",t)},onClick:function(){var e;return null===(e=null==V?void 0:V.current)||void 0===e?void 0:e.showPicker()},ref:V,disabled:g})),n.createElement(o.Form.Control.Feedback,{type:"invalid"},null===(v=q.start)||void 0===v?void 0:v.message)),n.createElement(o.Form.Group,{as:o.Col,controlId:"end"},n.createElement(o.Form.Label,null,C("end")),n.createElement(o.Form.Control,t.__assign({type:"datetime-local"},b("end",x.end),{value:O,name:"end",onChange:function(e){return function(e){_("end",e),y("end")}(e.target.value)},min:j,required:!0,isInvalid:Boolean(q.end),onClick:function(){var e;return null===(e=null==w?void 0:w.current)||void 0===e?void 0:e.showPicker()},ref:w,disabled:g})),n.createElement(o.Form.Control.Feedback,{type:"invalid"},null===(f=q.end)||void 0===f?void 0:f.message),n.createElement(o.Form.Text,{muted:!0},S&&"lasts ".concat(S)))),j&&n.createElement(o.Form.Group,{controlId:P},n.createElement(o.Form.Check,{label:"Recurrent",custom:!0,checked:M,onChange:function(e){var t=e.target.checked;R(t)},disabled:g||Boolean(F)}),!M&&n.createElement(o.Form.Text,{muted:!0},C("reccurentDescription",{item:C("event")}))),W&&n.createElement(u.default,{message:C("recurrentOverridesWarining")}),M&&j&&n.createElement(o.Form.Group,null,n.createElement(l.Controller,{control:k,name:"rrule",render:function(e){var t=e.field,r=t.value,a=t.onChange;return n.createElement(d.RecurrenceInput,{value:r,onChange:a,date:j,minDate:c.DateTime.fromISO(j).plus({day:1}).toFormat("yyyy-MM-dd"),disabled:g})}})))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/events/edit-event-modal/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFormattedDuration.d.ts","sourceRoot":"","sources":["../../../../src/events/edit-event-modal/hooks/useFormattedDuration.tsx"],"names":[],"mappings":"AAMA,eAAO,MAAM,oBAAoB,cAiChC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("tslib"),r=require("react"),u=((e=r)&&"object"==typeof e&&"default"in e&&e.default,require("react-hook-form")),n=require("luxon"),o=require("react-intl");exports.useFormattedDuration=function(){var e=u.useFormContext().control,a=u.useWatch({control:e,name:"start"}),i=u.useWatch({control:e,name:"end"}),s=o.useIntl(),l=s.formatList,m=s.formatNumber,f=r.useMemo((function(){var e=n.Interval.fromDateTimes(n.DateTime.fromISO(a),n.DateTime.fromISO(i)).toDuration(["days","hours","minutes"]);if(e.isValid){var r=function(e,t){return m(e,{style:"unit",unit:t,unitDisplay:"long"})},u=[[e.days,"day"],[e.hours,"hour"],[e.minutes,"minute"]].filter((function(e){return t.__read(e,1)[0]}));return l(u.map((function(e){return r.apply(void 0,t.__spreadArray([],t.__read(e),!1))})),{style:"long",type:"unit"})}}),[a,i]);return f};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const useValidationOptions: () => {
|
|
2
|
+
start: {
|
|
3
|
+
required: string;
|
|
4
|
+
validate: (value: any) => string | true;
|
|
5
|
+
};
|
|
6
|
+
end: {
|
|
7
|
+
required: string;
|
|
8
|
+
validate: (value: any) => string | true;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=useValidationOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useValidationOptions.d.ts","sourceRoot":"","sources":["../../../../src/events/edit-event-modal/hooks/useValidationOptions.tsx"],"names":[],"mappings":"AAIA,eAAO,MAAM,oBAAoB;;;;;;;;;CA+BhC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react-i18next"),t=require("react-hook-form"),i=require("luxon");exports.useValidationOptions=function(){var r=t.useFormContext().control,a=e.useTranslation(["Design","Validation"]).t,n=t.useWatch({control:r,name:"start"});return{start:{required:a("Validation:fieldRequired",{attribute:a("start")}),validate:function(e){return i.DateTime.fromISO(e).diffNow().toMillis()>0||a("Validation:fieldValidEventStart")}},end:{required:a("Validation:fieldRequired",{attribute:a("end")}),validate:function(e){return!e||(i.DateTime.fromISO(e).diff(i.DateTime.fromISO(n)).toMillis()>0||a("Validation:fieldValidEventEnd"))}}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../../../../src/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAI1C,UAAU,gBAAgB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../../../../src/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAqB,MAAM,OAAO,CAAC;AAI1C,UAAU,gBAAgB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,WAAW,2FA4EvB,CAAC"}
|
package/dist/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.js
CHANGED
|
@@ -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("react"),n=e(t),
|
|
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("react"),n=e(t),a=require("react-bootstrap"),r=e(require("clsx")),u=t.forwardRef((function(e,t){var u=e.className,o=void 0===u?"":u,i=e.value,l=e.onChange,d=e.onArrowDown,c=e.onArrowUp,m=e.min,b=e.max,p=e.placeholder,s=e.defaultValue,f=e.disabled,v=!i,y=void 0!==b&&i===b,N=r("payment-number-input",o);return n.createElement("div",{className:N},n.createElement("button",{type:"button",onClick:function(){void 0!==m&&i>m&&d(i-1),void 0===m&&c(i-1)},className:"payment-number-input__btn-down ".concat(v&&"disabled-number-input-button"),disabled:f},"−"),n.createElement(a.FormControl,{type:"number",onChange:function(e){return l(Number(e.target.value))},value:i,min:m,max:b,defaultValue:s,placeholder:p,height:"5rem",disabled:f,ref:t}),n.createElement("button",{type:"button",onClick:function(){void 0!==b&&(i||0)<b&&c(i+1),void 0===b&&c(i+1)},className:"payment-number-input__btn-up ".concat(y&&"disabled-number-input-button"),disabled:f},"+"))}));u.displayName="NumberInput",exports.NumberInput=u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductQuantityInput.d.ts","sourceRoot":"","sources":["../../../../../../src/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,wDAAwD,CAAC;AAC9E,OAAO,EACL,OAAO,EACP,eAAe,EAChB,MAAM,qDAAqD,CAAC;AAG7D,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,UAAU,yBAAyB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,WAAW,EAAE,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAC7C,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,aAAa,CAAC;CAC5B;AAED,eAAO,MAAM,oBAAoB,gGAQ9B,yBAAyB,
|
|
1
|
+
{"version":3,"file":"ProductQuantityInput.d.ts","sourceRoot":"","sources":["../../../../../../src/iframe/order-process/components/CategoryProduct/components/ProductQuantityInput/ProductQuantityInput.tsx"],"names":[],"mappings":";AAIA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,IAAI,EAAE,MAAM,wDAAwD,CAAC;AAC9E,OAAO,EACL,OAAO,EACP,eAAe,EAChB,MAAM,qDAAqD,CAAC;AAG7D,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,UAAU,yBAAyB;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,eAAe,CAAC;IAC1B,WAAW,EAAE,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAC7C,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,aAAa,CAAC;CAC5B;AAED,eAAO,MAAM,oBAAoB,gGAQ9B,yBAAyB,gBAsE3B,CAAC"}
|
|
@@ -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=e(require("react")),n=require("react-i18next"),o=require("react-bootstrap"),
|
|
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=e(require("react")),n=require("react-i18next"),o=require("react-bootstrap"),u=e(require("clsx")),i=require("../NumberInput/NumberInput.js");exports.ProductQuantityInput=function(e){var r=e.product,l=e.category,a=e.onChange,c=e.clearErrors,d=e.refCallback,s=e.productInfo,m=e.invalid,v=n.useTranslation("Design").t,p=function(e){var t,n=e;(null==r?void 0:r.maxAmount)&&e>(null==r?void 0:r.maxAmount)&&(n=null==r?void 0:r.maxAmount),a({id:r.id,name:r.name,deposit:null==r?void 0:r.deposit,hasDeposit:l.allowDeposits,price:r.price,productCategoryId:l.id,zoneId:null===(t=l.zone)||void 0===t?void 0:t.id,quantity:n,capacity:null==r?void 0:r.capacity})};return r.isSoldOut?t.createElement("div",{className:"iframe-event__sold-out-wrapper"},v("Design:soldOut")):1===(null==r?void 0:r.maxAmount)?t.createElement(o.Button,{ref:d,disabled:r.isSoldOut,className:u("iframe-event__".concat((null==s?void 0:s.quantity)?"unselect-product":"select-product"),m&&"error"),onClick:function(){return p((null==s?void 0:s.quantity)?0:1)}},v("Design:".concat((null==s?void 0:s.quantity)?"unselect":"select"))):t.createElement(i.NumberInput,{ref:d,onChange:function(e){p(e||null),c("".concat(r.id))},onArrowDown:function(){p((null==s?void 0:s.quantity)-1||0),c("".concat(r.id))},onArrowUp:function(){var e;p((null!==(e=null==s?void 0:s.quantity)&&void 0!==e?e:0)+1),c("".concat(r.id))},min:0,max:(null==r?void 0:r.maxAmount)?Number(null==r?void 0:r.maxAmount):void 0,placeholder:"0",disabled:r.isSoldOut,value:null==s?void 0:s.quantity,className:u(m&&"error")})};
|
|
@@ -59,7 +59,8 @@
|
|
|
59
59
|
color: $snippet-elements-button-color;
|
|
60
60
|
border: none;
|
|
61
61
|
background-color: $snippet-elements-button-background-color;
|
|
62
|
-
box-shadow: 0 0 0 $input-btn-focus-width
|
|
62
|
+
box-shadow: 0 0 0 $input-btn-focus-width
|
|
63
|
+
$snippet-elements-button-background-color;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
&:disabled {
|
|
@@ -72,14 +73,14 @@
|
|
|
72
73
|
&:focus,
|
|
73
74
|
&.focus {
|
|
74
75
|
&:not(:disabled) {
|
|
75
|
-
opacity: .7;
|
|
76
|
+
opacity: 0.7;
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
&:active,
|
|
80
81
|
&.active {
|
|
81
82
|
&:not(:disabled) {
|
|
82
|
-
opacity: .8;
|
|
83
|
+
opacity: 0.8;
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
}
|
|
@@ -90,7 +91,7 @@
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
&__label {
|
|
93
|
-
font-size: .8rem;
|
|
94
|
+
font-size: 0.8rem;
|
|
94
95
|
margin-top: 1rem;
|
|
95
96
|
margin-bottom: 0.2rem;
|
|
96
97
|
}
|
|
@@ -103,8 +104,8 @@
|
|
|
103
104
|
position: absolute;
|
|
104
105
|
top: 0;
|
|
105
106
|
right: 0;
|
|
106
|
-
margin-right: .5rem;
|
|
107
|
-
margin-top: .5rem;
|
|
107
|
+
margin-right: 0.5rem;
|
|
108
|
+
margin-top: 0.5rem;
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
.form-label {
|
|
@@ -181,7 +182,8 @@
|
|
|
181
182
|
color: $snippet-elements-button-color;
|
|
182
183
|
border: none;
|
|
183
184
|
background-color: $snippet-elements-button-background-color;
|
|
184
|
-
box-shadow: 0 0 0 $input-btn-focus-width
|
|
185
|
+
box-shadow: 0 0 0 $input-btn-focus-width
|
|
186
|
+
$snippet-elements-button-background-color;
|
|
185
187
|
}
|
|
186
188
|
|
|
187
189
|
&:disabled {
|
|
@@ -194,14 +196,14 @@
|
|
|
194
196
|
&:focus,
|
|
195
197
|
&.focus {
|
|
196
198
|
&:not(:disabled) {
|
|
197
|
-
opacity:
|
|
199
|
+
opacity: 0.7;
|
|
198
200
|
}
|
|
199
201
|
}
|
|
200
202
|
|
|
201
203
|
&:active,
|
|
202
204
|
&.active {
|
|
203
205
|
&:not(:disabled) {
|
|
204
|
-
opacity: .8;
|
|
206
|
+
opacity: 0.8;
|
|
205
207
|
}
|
|
206
208
|
}
|
|
207
209
|
}
|
|
@@ -336,7 +338,8 @@
|
|
|
336
338
|
}
|
|
337
339
|
}
|
|
338
340
|
|
|
339
|
-
.bottom-wrapper,
|
|
341
|
+
.bottom-wrapper,
|
|
342
|
+
.snippet-template__form {
|
|
340
343
|
.btn {
|
|
341
344
|
border-radius: 0.25rem;
|
|
342
345
|
width: 100%;
|
|
@@ -381,6 +384,10 @@
|
|
|
381
384
|
}
|
|
382
385
|
}
|
|
383
386
|
|
|
387
|
+
.disabled-number-input-button {
|
|
388
|
+
background-color: $snippet-calendar-disabled-button-font-color !important;
|
|
389
|
+
border-color: $snippet-calendar-disabled-button-font-color !important;
|
|
390
|
+
}
|
|
384
391
|
.color-picker {
|
|
385
392
|
&__color {
|
|
386
393
|
position: absolute;
|
|
@@ -442,7 +449,6 @@
|
|
|
442
449
|
}
|
|
443
450
|
}
|
|
444
451
|
}
|
|
445
|
-
|
|
446
452
|
}
|
|
447
453
|
|
|
448
454
|
@include media-breakpoint-down(xs) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import { DateTime
|
|
1
|
+
import React, { useState, useRef, useEffect } from "react";
|
|
2
|
+
import { DateTime } from "luxon";
|
|
3
3
|
import { Col, Form } from "react-bootstrap";
|
|
4
|
-
import { Controller,
|
|
4
|
+
import { Controller, useFormContext, useWatch } from "react-hook-form";
|
|
5
5
|
import { useTranslation } from "react-i18next";
|
|
6
|
-
import { useIntl } from "react-intl";
|
|
7
6
|
|
|
8
7
|
import { useId } from "@react-aria/utils";
|
|
9
8
|
import { ProductSet } from "@licklist/core/dist/DataMapper/Product/ProductSetDataMapper";
|
|
@@ -11,6 +10,7 @@ import HTMLInputDateElement from "../../types/static/HTMLInputDateElement";
|
|
|
11
10
|
import { RecurrenceInput } from "../../recurrence-input";
|
|
12
11
|
import { WarningMessage } from "../../static";
|
|
13
12
|
import { ProductSetFormValues } from "../../product-set/form";
|
|
13
|
+
import { useFormattedDuration, useValidationOptions } from "./hooks";
|
|
14
14
|
|
|
15
15
|
interface IntervalInputProps {
|
|
16
16
|
editedProductSet?: ProductSetFormValues;
|
|
@@ -35,7 +35,6 @@ export function IntervalInput({
|
|
|
35
35
|
const {
|
|
36
36
|
register,
|
|
37
37
|
formState: { errors },
|
|
38
|
-
watch,
|
|
39
38
|
control,
|
|
40
39
|
trigger,
|
|
41
40
|
setValue,
|
|
@@ -44,9 +43,9 @@ export function IntervalInput({
|
|
|
44
43
|
const formattedDuration = useFormattedDuration();
|
|
45
44
|
const validationOptions = useValidationOptions();
|
|
46
45
|
|
|
47
|
-
const rrule =
|
|
48
|
-
const start =
|
|
49
|
-
const end =
|
|
46
|
+
const rrule = useWatch({ control, name: "rrule" });
|
|
47
|
+
const start = useWatch({ control, name: "start" });
|
|
48
|
+
const end = useWatch({ control, name: "end" });
|
|
50
49
|
const [recurrent, setRecurrent] = useState(Boolean(rrule));
|
|
51
50
|
const [isOverriden, setIsOverriden] = useState(false);
|
|
52
51
|
const recurrentId = useId();
|
|
@@ -123,6 +122,7 @@ export function IntervalInput({
|
|
|
123
122
|
onChangeEndDate(nextEndtDate)
|
|
124
123
|
}
|
|
125
124
|
min={start}
|
|
125
|
+
required
|
|
126
126
|
isInvalid={Boolean(errors.end)}
|
|
127
127
|
onClick={() => endDateInput?.current?.showPicker()}
|
|
128
128
|
ref={endDateInput}
|
|
@@ -180,75 +180,3 @@ export function IntervalInput({
|
|
|
180
180
|
</>
|
|
181
181
|
);
|
|
182
182
|
}
|
|
183
|
-
|
|
184
|
-
const useFormattedDuration = () => {
|
|
185
|
-
const { watch } = useFormContext<IntervalInputValues>();
|
|
186
|
-
const start = watch("start");
|
|
187
|
-
const end = watch("end");
|
|
188
|
-
const { formatList, formatNumber } = useIntl();
|
|
189
|
-
|
|
190
|
-
return useMemo(() => {
|
|
191
|
-
const interval = Interval.fromDateTimes(
|
|
192
|
-
DateTime.fromISO(start),
|
|
193
|
-
DateTime.fromISO(end)
|
|
194
|
-
).toDuration(["days", "hours", "minutes"]);
|
|
195
|
-
|
|
196
|
-
if (!interval.isValid) return undefined;
|
|
197
|
-
|
|
198
|
-
const formatUnit = (value: number, unit: string) =>
|
|
199
|
-
formatNumber(value, { style: "unit", unit, unitDisplay: "long" });
|
|
200
|
-
|
|
201
|
-
const units = (
|
|
202
|
-
[
|
|
203
|
-
[interval.days, "day"],
|
|
204
|
-
[interval.hours, "hour"],
|
|
205
|
-
[interval.minutes, "minute"],
|
|
206
|
-
] as Parameters<typeof formatUnit>[]
|
|
207
|
-
).filter(([value]) => value);
|
|
208
|
-
|
|
209
|
-
return formatList(
|
|
210
|
-
units.map((args) => formatUnit(...args)),
|
|
211
|
-
{ style: "long", type: "unit" }
|
|
212
|
-
);
|
|
213
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
214
|
-
}, [start, end]);
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
const useValidationOptions = () => {
|
|
218
|
-
const { watch } = useFormContext();
|
|
219
|
-
const { t } = useTranslation(["Design", "Validation"]);
|
|
220
|
-
const start = watch("start");
|
|
221
|
-
const end = watch("end");
|
|
222
|
-
|
|
223
|
-
return {
|
|
224
|
-
start: useMemo<RegisterOptions>(
|
|
225
|
-
() => ({
|
|
226
|
-
required: t("Validation:fieldRequired", {
|
|
227
|
-
attribute: t("start"),
|
|
228
|
-
}) as string,
|
|
229
|
-
// TODO: uncomment when event splitting is implemented
|
|
230
|
-
// and extract into plugins
|
|
231
|
-
validate: (value) =>
|
|
232
|
-
DateTime.fromISO(value).diffNow().toMillis() > 0 ||
|
|
233
|
-
(t("Validation:fieldValidEventStart") as string),
|
|
234
|
-
}),
|
|
235
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
236
|
-
[]
|
|
237
|
-
),
|
|
238
|
-
|
|
239
|
-
end: useMemo<RegisterOptions>(
|
|
240
|
-
() => ({
|
|
241
|
-
// TODO: uncomment when event splitting is implemented
|
|
242
|
-
// and extract into plugins
|
|
243
|
-
validate: (value) =>
|
|
244
|
-
// endAt not required
|
|
245
|
-
value
|
|
246
|
-
? DateTime.fromISO(value).diff(DateTime.fromISO(start)).toMillis() >
|
|
247
|
-
0 || (t("Validation:fieldValidEventEnd") as string)
|
|
248
|
-
: true,
|
|
249
|
-
}),
|
|
250
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
251
|
-
[start, end]
|
|
252
|
-
),
|
|
253
|
-
};
|
|
254
|
-
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useFormContext, useWatch } from "react-hook-form";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import { DateTime, Interval } from "luxon";
|
|
5
|
+
import { IntervalInputValues } from "../IntervalInput";
|
|
6
|
+
|
|
7
|
+
export const useFormattedDuration = () => {
|
|
8
|
+
const { control } = useFormContext<IntervalInputValues>();
|
|
9
|
+
const start = useWatch({ control, name: "start" });
|
|
10
|
+
const end = useWatch({ control, name: "end" });
|
|
11
|
+
const { formatList, formatNumber } = useIntl();
|
|
12
|
+
|
|
13
|
+
const duration = useMemo(() => {
|
|
14
|
+
const interval = Interval.fromDateTimes(
|
|
15
|
+
DateTime.fromISO(start),
|
|
16
|
+
DateTime.fromISO(end)
|
|
17
|
+
).toDuration(["days", "hours", "minutes"]);
|
|
18
|
+
|
|
19
|
+
if (!interval.isValid) return undefined;
|
|
20
|
+
|
|
21
|
+
const formatUnit = (value: number, unit: string) =>
|
|
22
|
+
formatNumber(value, { style: "unit", unit, unitDisplay: "long" });
|
|
23
|
+
|
|
24
|
+
const units = (
|
|
25
|
+
[
|
|
26
|
+
[interval.days, "day"],
|
|
27
|
+
[interval.hours, "hour"],
|
|
28
|
+
[interval.minutes, "minute"],
|
|
29
|
+
] as Parameters<typeof formatUnit>[]
|
|
30
|
+
).filter(([value]) => value);
|
|
31
|
+
|
|
32
|
+
return formatList(
|
|
33
|
+
units.map((args) => formatUnit(...args)),
|
|
34
|
+
{ style: "long", type: "unit" }
|
|
35
|
+
);
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
}, [start, end]);
|
|
38
|
+
|
|
39
|
+
return duration;
|
|
40
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DateTime } from "luxon";
|
|
2
|
+
import { useFormContext, useWatch } from "react-hook-form";
|
|
3
|
+
import { useTranslation } from "react-i18next";
|
|
4
|
+
|
|
5
|
+
export const useValidationOptions = () => {
|
|
6
|
+
const { control } = useFormContext();
|
|
7
|
+
const { t } = useTranslation(["Design", "Validation"]);
|
|
8
|
+
const start = useWatch({ control, name: "start" });
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
start: {
|
|
12
|
+
required: t("Validation:fieldRequired", {
|
|
13
|
+
attribute: t("start"),
|
|
14
|
+
}) as string,
|
|
15
|
+
// TODO: uncomment when event splitting is implemented
|
|
16
|
+
// and extract into plugins
|
|
17
|
+
validate: (value) =>
|
|
18
|
+
DateTime.fromISO(value).diffNow().toMillis() > 0 ||
|
|
19
|
+
(t("Validation:fieldValidEventStart") as string),
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
end: {
|
|
23
|
+
required: t("Validation:fieldRequired", {
|
|
24
|
+
attribute: t("end"),
|
|
25
|
+
}) as string,
|
|
26
|
+
// TODO: uncomment when event splitting is implemented
|
|
27
|
+
// and extract into plugins
|
|
28
|
+
validate: (value) =>
|
|
29
|
+
// endAt not required
|
|
30
|
+
value
|
|
31
|
+
? DateTime.fromISO(value).diff(DateTime.fromISO(start)).toMillis() >
|
|
32
|
+
0 || (t("Validation:fieldValidEventEnd") as string)
|
|
33
|
+
: true,
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
};
|
package/src/iframe/order-process/components/CategoryProduct/components/NumberInput/NumberInput.tsx
CHANGED
|
@@ -31,8 +31,11 @@ export const NumberInput = forwardRef<HTMLInputElement, NumberInputProps>(
|
|
|
31
31
|
},
|
|
32
32
|
ref
|
|
33
33
|
) => {
|
|
34
|
+
const minusButtonGreyedOut = !value;
|
|
35
|
+
const plusButtonGreyedOut = max !== undefined && value === max;
|
|
36
|
+
|
|
34
37
|
const handleArrowUpClick = () => {
|
|
35
|
-
if (max !== undefined && value < max) {
|
|
38
|
+
if (max !== undefined && (value || 0) < max) {
|
|
36
39
|
onArrowUp(value + 1);
|
|
37
40
|
}
|
|
38
41
|
if (max === undefined) {
|
|
@@ -56,7 +59,9 @@ export const NumberInput = forwardRef<HTMLInputElement, NumberInputProps>(
|
|
|
56
59
|
<button
|
|
57
60
|
type="button"
|
|
58
61
|
onClick={handleArrowDownClick}
|
|
59
|
-
className=
|
|
62
|
+
className={`payment-number-input__btn-down ${
|
|
63
|
+
minusButtonGreyedOut && "disabled-number-input-button"
|
|
64
|
+
}`}
|
|
60
65
|
disabled={disabled}
|
|
61
66
|
>
|
|
62
67
|
−
|
|
@@ -76,7 +81,9 @@ export const NumberInput = forwardRef<HTMLInputElement, NumberInputProps>(
|
|
|
76
81
|
<button
|
|
77
82
|
type="button"
|
|
78
83
|
onClick={handleArrowUpClick}
|
|
79
|
-
className=
|
|
84
|
+
className={`payment-number-input__btn-up ${
|
|
85
|
+
plusButtonGreyedOut && "disabled-number-input-button"
|
|
86
|
+
}`}
|
|
80
87
|
disabled={disabled}
|
|
81
88
|
>
|
|
82
89
|
+
|
|
@@ -45,6 +45,10 @@ export const ProductQuantityInput = ({
|
|
|
45
45
|
const { t } = useTranslation("Design");
|
|
46
46
|
|
|
47
47
|
const onChange = (quantity: number | null) => {
|
|
48
|
+
let productQuantity = quantity;
|
|
49
|
+
if (product?.maxAmount && quantity > product?.maxAmount) {
|
|
50
|
+
productQuantity = product?.maxAmount;
|
|
51
|
+
}
|
|
48
52
|
_onChange({
|
|
49
53
|
id: product.id,
|
|
50
54
|
name: product.name,
|
|
@@ -53,7 +57,7 @@ export const ProductQuantityInput = ({
|
|
|
53
57
|
price: product.price,
|
|
54
58
|
productCategoryId: category.id,
|
|
55
59
|
zoneId: category.zone?.id,
|
|
56
|
-
quantity,
|
|
60
|
+
quantity: productQuantity,
|
|
57
61
|
capacity: product?.capacity,
|
|
58
62
|
});
|
|
59
63
|
};
|
|
@@ -100,6 +104,7 @@ export const ProductQuantityInput = ({
|
|
|
100
104
|
clearErrors(`${product.id}` as const);
|
|
101
105
|
}}
|
|
102
106
|
min={0}
|
|
107
|
+
max={product?.maxAmount ? Number(product?.maxAmount) : undefined}
|
|
103
108
|
placeholder="0"
|
|
104
109
|
disabled={product.isSoldOut}
|
|
105
110
|
value={productInfo?.quantity}
|
|
@@ -59,7 +59,8 @@
|
|
|
59
59
|
color: $snippet-elements-button-color;
|
|
60
60
|
border: none;
|
|
61
61
|
background-color: $snippet-elements-button-background-color;
|
|
62
|
-
box-shadow: 0 0 0 $input-btn-focus-width
|
|
62
|
+
box-shadow: 0 0 0 $input-btn-focus-width
|
|
63
|
+
$snippet-elements-button-background-color;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
&:disabled {
|
|
@@ -72,14 +73,14 @@
|
|
|
72
73
|
&:focus,
|
|
73
74
|
&.focus {
|
|
74
75
|
&:not(:disabled) {
|
|
75
|
-
opacity: .7;
|
|
76
|
+
opacity: 0.7;
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
&:active,
|
|
80
81
|
&.active {
|
|
81
82
|
&:not(:disabled) {
|
|
82
|
-
opacity: .8;
|
|
83
|
+
opacity: 0.8;
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
}
|
|
@@ -90,7 +91,7 @@
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
&__label {
|
|
93
|
-
font-size: .8rem;
|
|
94
|
+
font-size: 0.8rem;
|
|
94
95
|
margin-top: 1rem;
|
|
95
96
|
margin-bottom: 0.2rem;
|
|
96
97
|
}
|
|
@@ -103,8 +104,8 @@
|
|
|
103
104
|
position: absolute;
|
|
104
105
|
top: 0;
|
|
105
106
|
right: 0;
|
|
106
|
-
margin-right: .5rem;
|
|
107
|
-
margin-top: .5rem;
|
|
107
|
+
margin-right: 0.5rem;
|
|
108
|
+
margin-top: 0.5rem;
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
.form-label {
|
|
@@ -181,7 +182,8 @@
|
|
|
181
182
|
color: $snippet-elements-button-color;
|
|
182
183
|
border: none;
|
|
183
184
|
background-color: $snippet-elements-button-background-color;
|
|
184
|
-
box-shadow: 0 0 0 $input-btn-focus-width
|
|
185
|
+
box-shadow: 0 0 0 $input-btn-focus-width
|
|
186
|
+
$snippet-elements-button-background-color;
|
|
185
187
|
}
|
|
186
188
|
|
|
187
189
|
&:disabled {
|
|
@@ -194,14 +196,14 @@
|
|
|
194
196
|
&:focus,
|
|
195
197
|
&.focus {
|
|
196
198
|
&:not(:disabled) {
|
|
197
|
-
opacity:
|
|
199
|
+
opacity: 0.7;
|
|
198
200
|
}
|
|
199
201
|
}
|
|
200
202
|
|
|
201
203
|
&:active,
|
|
202
204
|
&.active {
|
|
203
205
|
&:not(:disabled) {
|
|
204
|
-
opacity: .8;
|
|
206
|
+
opacity: 0.8;
|
|
205
207
|
}
|
|
206
208
|
}
|
|
207
209
|
}
|
|
@@ -336,7 +338,8 @@
|
|
|
336
338
|
}
|
|
337
339
|
}
|
|
338
340
|
|
|
339
|
-
.bottom-wrapper,
|
|
341
|
+
.bottom-wrapper,
|
|
342
|
+
.snippet-template__form {
|
|
340
343
|
.btn {
|
|
341
344
|
border-radius: 0.25rem;
|
|
342
345
|
width: 100%;
|
|
@@ -381,6 +384,10 @@
|
|
|
381
384
|
}
|
|
382
385
|
}
|
|
383
386
|
|
|
387
|
+
.disabled-number-input-button {
|
|
388
|
+
background-color: $snippet-calendar-disabled-button-font-color !important;
|
|
389
|
+
border-color: $snippet-calendar-disabled-button-font-color !important;
|
|
390
|
+
}
|
|
384
391
|
.color-picker {
|
|
385
392
|
&__color {
|
|
386
393
|
position: absolute;
|
|
@@ -442,7 +449,6 @@
|
|
|
442
449
|
}
|
|
443
450
|
}
|
|
444
451
|
}
|
|
445
|
-
|
|
446
452
|
}
|
|
447
453
|
|
|
448
454
|
@include media-breakpoint-down(xs) {
|