@licklist/design 0.58.4 → 0.58.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":"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"}
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,2FAgGvB,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=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
+ "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,l=e.value,i=e.onChange,c=e.onArrowDown,m=e.onArrowUp,b=e.min,d=e.max,p=e.placeholder,s=e.defaultValue,f=e.disabled,v=!l,y=d>0&&l===d,N=r("payment-number-input",o);return n.createElement("div",{className:N},n.createElement("button",{type:"button",onClick:function(){l&&(b>0&&(l||0)===b?c(0):m(l-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 t=Number(e.target.value),void i(d>0&&t>d?d:b>0&&t&&t<b?b:t);var t},value:l,min:b,max:d,defaultValue:s,placeholder:p,height:"5rem",disabled:f,ref:t}),n.createElement("button",{type:"button",onClick:function(){d>0&&l===d||m(b>0&&(l||0)<b?b:(l||0)+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,gBAsE3B,CAAC"}
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,gBAkE3B,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"),i=e(require("clsx")),u=require("../NumberInput/NumberInput.js");exports.ProductQuantityInput=function(e){var r=e.product,l=e.category,a=e.onChange,d=e.clearErrors,c=e.refCallback,s=e.productInfo,v=e.invalid,m=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&&(null==r?void 0:r.deposit)<r.price,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"},m("Design:soldOut")):1===(null==r?void 0:r.maxAmount)?t.createElement(o.Button,{ref:c,disabled:r.isSoldOut,className:i("iframe-event__".concat((null==s?void 0:s.quantity)?"unselect-product":"select-product"),v&&"error"),onClick:function(){return p((null==s?void 0:s.quantity)?0:1)}},m("Design:".concat((null==s?void 0:s.quantity)?"unselect":"select"))):t.createElement(u.NumberInput,{ref:c,onChange:function(e){p(e||null),d("".concat(r.id))},onArrowDown:function(){p((null==s?void 0:s.quantity)-1||0),d("".concat(r.id))},onArrowUp:function(){var e;p((null!==(e=null==s?void 0:s.quantity)&&void 0!==e?e:0)+1),d("".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:i(v&&"error")})};
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"),i=e(require("clsx")),r=require("../NumberInput/NumberInput.js");exports.ProductQuantityInput=function(e){var u=e.product,a=e.category,l=e.onChange,c=e.clearErrors,d=e.refCallback,s=e.productInfo,p=e.invalid,m=n.useTranslation("Design").t,v=function(e){var t;l({id:u.id,name:u.name,deposit:null==u?void 0:u.deposit,hasDeposit:a.allowDeposits&&(null==u?void 0:u.deposit)<u.price,price:u.price,productCategoryId:a.id,zoneId:null===(t=a.zone)||void 0===t?void 0:t.id,quantity:e,capacity:null==u?void 0:u.capacity})};return u.isSoldOut?t.createElement("div",{className:"iframe-event__sold-out-wrapper"},m("Design:soldOut")):1===(null==u?void 0:u.maxAmount)?t.createElement(o.Button,{ref:d,disabled:u.isSoldOut,className:i("iframe-event__".concat((null==s?void 0:s.quantity)?"unselect-product":"select-product"),p&&"error"),onClick:function(){return v((null==s?void 0:s.quantity)?0:1)}},m("Design:".concat((null==s?void 0:s.quantity)?"unselect":"select"))):t.createElement(r.NumberInput,{ref:d,onChange:function(e){v(e),c("".concat(u.id))},onArrowDown:function(e){v(e||0),c("".concat(u.id))},onArrowUp:function(e){v(e||0),c("".concat(u.id))},min:(null==u?void 0:u.minAmount)?Number(u.minAmount):0,max:(null==u?void 0:u.maxAmount)?Number(u.maxAmount):void 0,placeholder:"0",disabled:u.isSoldOut,value:null==s?void 0:s.quantity,className:i(p&&"error")})};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@licklist/design",
3
- "version": "0.58.4",
3
+ "version": "0.58.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+ssh://git@bitbucket.org/artelogicsoft/licklist_design.git"
@@ -32,24 +32,44 @@ export const NumberInput = forwardRef<HTMLInputElement, NumberInputProps>(
32
32
  ref
33
33
  ) => {
34
34
  const minusButtonGreyedOut = !value;
35
- const plusButtonGreyedOut = max !== undefined && value === max;
35
+ const plusButtonGreyedOut = max > 0 && value === max;
36
+
37
+ const handleChangeValue = (val: number) => {
38
+ if (max > 0 && val > max) {
39
+ onChange(max);
40
+ return;
41
+ }
42
+
43
+ if (min > 0 && val && val < min) {
44
+ onChange(min);
45
+ return;
46
+ }
47
+ onChange(val);
48
+ };
36
49
 
37
50
  const handleArrowUpClick = () => {
38
- if (max !== undefined && (value || 0) < max) {
39
- onArrowUp(value + 1);
51
+ if (max > 0 && value === max) {
52
+ return;
40
53
  }
41
- if (max === undefined) {
42
- onArrowUp(value + 1);
54
+
55
+ if (min > 0 && (value || 0) < min) {
56
+ onArrowUp(min);
57
+ return;
43
58
  }
59
+
60
+ onArrowUp((value || 0) + 1);
44
61
  };
45
62
 
46
63
  const handleArrowDownClick = () => {
47
- if (min !== undefined && value > min) {
48
- onArrowDown(value - 1);
64
+ if (!value) {
65
+ return;
49
66
  }
50
- if (min === undefined) {
51
- onArrowUp(value - 1);
67
+ if (min > 0 && (value || 0) === min) {
68
+ onArrowDown(0);
69
+ return;
52
70
  }
71
+
72
+ onArrowUp(value - 1);
53
73
  };
54
74
 
55
75
  const inputWrapperClasses = clsx("payment-number-input", className);
@@ -68,7 +88,7 @@ export const NumberInput = forwardRef<HTMLInputElement, NumberInputProps>(
68
88
  </button>
69
89
  <FormControl
70
90
  type="number"
71
- onChange={(e) => onChange(Number(e.target.value))}
91
+ onChange={(e) => handleChangeValue(Number(e.target.value))}
72
92
  value={value}
73
93
  min={min}
74
94
  max={max}
@@ -45,10 +45,6 @@ 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
- }
52
48
  _onChange({
53
49
  id: product.id,
54
50
  name: product.name,
@@ -57,7 +53,7 @@ export const ProductQuantityInput = ({
57
53
  price: product.price,
58
54
  productCategoryId: category.id,
59
55
  zoneId: category.zone?.id,
60
- quantity: productQuantity,
56
+ quantity,
61
57
  capacity: product?.capacity,
62
58
  });
63
59
  };
@@ -92,19 +88,19 @@ export const ProductQuantityInput = ({
92
88
  <NumberInput
93
89
  ref={refCallback}
94
90
  onChange={(val) => {
95
- onChange(val || null);
91
+ onChange(val);
96
92
  clearErrors(`${product.id}` as const);
97
93
  }}
98
- onArrowDown={() => {
99
- onChange(productInfo?.quantity - 1 || 0);
94
+ onArrowDown={(val) => {
95
+ onChange(val || 0);
100
96
  clearErrors(`${product.id}` as const);
101
97
  }}
102
- onArrowUp={() => {
103
- onChange((productInfo?.quantity ?? 0) + 1);
98
+ onArrowUp={(val) => {
99
+ onChange(val || 0);
104
100
  clearErrors(`${product.id}` as const);
105
101
  }}
106
- min={0}
107
- max={product?.maxAmount ? Number(product?.maxAmount) : undefined}
102
+ min={product?.minAmount ? Number(product.minAmount) : 0}
103
+ max={product?.maxAmount ? Number(product.maxAmount) : undefined}
108
104
  placeholder="0"
109
105
  disabled={product.isSoldOut}
110
106
  value={productInfo?.quantity}