@rpg-engine/long-bow 0.7.85 → 0.7.87
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/components/Item/Inventory/ItemQuantitySelectorModal.d.ts +2 -6
- package/dist/components/QuantitySelector/QuantitySelector.d.ts +9 -0
- package/dist/components/QuantitySelector/QuantitySelectorModal.d.ts +14 -0
- package/dist/long-bow.cjs.development.js +75 -60
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +75 -60
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Item/Inventory/ItemQuantitySelectorModal.tsx +7 -45
- package/src/components/QuantitySelector/QuantitySelector.tsx +143 -0
- package/src/components/QuantitySelector/QuantitySelectorModal.tsx +79 -0
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
isOpen: boolean;
|
|
4
|
-
maxQuantity: number;
|
|
5
|
-
callback: (_quantity: number) => void;
|
|
6
|
-
}
|
|
2
|
+
import { IQuantitySelect } from '../../QuantitySelector/QuantitySelectorModal';
|
|
7
3
|
interface IProps {
|
|
8
4
|
quantitySelect: IQuantitySelect;
|
|
9
5
|
setQuantitySelect: React.Dispatch<React.SetStateAction<IQuantitySelect>>;
|
|
10
6
|
}
|
|
11
7
|
export declare const ItemQuantitySelectorModal: ({ quantitySelect, setQuantitySelect, }: IProps) => JSX.Element;
|
|
12
|
-
export {};
|
|
8
|
+
export type { IQuantitySelect };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IQuantitySelectorProps {
|
|
3
|
+
maxQuantity: number;
|
|
4
|
+
initialQuantity?: number;
|
|
5
|
+
title?: string;
|
|
6
|
+
onConfirm: (quantity: number) => void;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const QuantitySelector: React.FC<IQuantitySelectorProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface IQuantitySelect {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
maxQuantity: number;
|
|
5
|
+
callback: (quantity: number) => void;
|
|
6
|
+
title?: string;
|
|
7
|
+
initialQuantity?: number;
|
|
8
|
+
}
|
|
9
|
+
interface IProps {
|
|
10
|
+
quantitySelect: IQuantitySelect;
|
|
11
|
+
setQuantitySelect: React.Dispatch<React.SetStateAction<IQuantitySelect>>;
|
|
12
|
+
}
|
|
13
|
+
export declare const QuantitySelectorModal: ({ quantitySelect, setQuantitySelect, }: IProps) => JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -30500,71 +30500,68 @@ var Input$1 = /*#__PURE__*/styled__default.input.withConfig({
|
|
|
30500
30500
|
componentId: "sc-v8mte9-0"
|
|
30501
30501
|
})(["opacity:0;position:absolute;width:100%;height:100%;top:0;left:0;margin-top:-5px;"]);
|
|
30502
30502
|
|
|
30503
|
-
var
|
|
30504
|
-
var
|
|
30503
|
+
var QuantitySelector = function QuantitySelector(_ref) {
|
|
30504
|
+
var maxQuantity = _ref.maxQuantity,
|
|
30505
|
+
initialQuantity = _ref.initialQuantity,
|
|
30506
|
+
_ref$title = _ref.title,
|
|
30507
|
+
title = _ref$title === void 0 ? 'Select quantity' : _ref$title,
|
|
30505
30508
|
onConfirm = _ref.onConfirm,
|
|
30506
30509
|
onClose = _ref.onClose;
|
|
30507
|
-
var _useState = React.useState(
|
|
30510
|
+
var _useState = React.useState(initialQuantity != null ? initialQuantity : maxQuantity),
|
|
30508
30511
|
value = _useState[0],
|
|
30509
30512
|
setValue = _useState[1];
|
|
30510
30513
|
var inputRef = React.useRef(null);
|
|
30511
30514
|
React.useEffect(function () {
|
|
30515
|
+
var closeSelector = function closeSelector(e) {
|
|
30516
|
+
if (e.key === 'Escape') {
|
|
30517
|
+
onClose();
|
|
30518
|
+
}
|
|
30519
|
+
};
|
|
30512
30520
|
if (inputRef.current) {
|
|
30513
30521
|
inputRef.current.focus();
|
|
30514
30522
|
inputRef.current.select();
|
|
30515
|
-
var closeSelector = function closeSelector(e) {
|
|
30516
|
-
if (e.key === 'Escape') {
|
|
30517
|
-
onClose();
|
|
30518
|
-
}
|
|
30519
|
-
};
|
|
30520
|
-
document.addEventListener('keydown', closeSelector);
|
|
30521
|
-
return function () {
|
|
30522
|
-
document.removeEventListener('keydown', closeSelector);
|
|
30523
|
-
};
|
|
30524
30523
|
}
|
|
30525
|
-
|
|
30526
|
-
|
|
30524
|
+
document.addEventListener('keydown', closeSelector);
|
|
30525
|
+
return function () {
|
|
30526
|
+
return document.removeEventListener('keydown', closeSelector);
|
|
30527
|
+
};
|
|
30528
|
+
}, [onClose]);
|
|
30527
30529
|
return React__default.createElement(StyledContainer, {
|
|
30528
30530
|
type: exports.RPGUIContainerTypes.Framed,
|
|
30529
30531
|
width: "25rem"
|
|
30530
30532
|
}, React__default.createElement(CloseButton$5, {
|
|
30531
30533
|
className: "container-close",
|
|
30532
30534
|
onPointerDown: onClose
|
|
30533
|
-
}, "X"), React__default.createElement("h2", null,
|
|
30534
|
-
style: {
|
|
30535
|
-
width: '100%'
|
|
30536
|
-
},
|
|
30535
|
+
}, "X"), React__default.createElement("h2", null, title), React__default.createElement(StyledForm, {
|
|
30537
30536
|
onSubmit: function onSubmit(e) {
|
|
30538
30537
|
e.preventDefault();
|
|
30539
30538
|
var numberValue = Number(value);
|
|
30540
|
-
if (Number.isNaN(numberValue)) {
|
|
30541
|
-
|
|
30539
|
+
if (!Number.isNaN(numberValue)) {
|
|
30540
|
+
onConfirm(Math.max(1, Math.min(maxQuantity, numberValue)));
|
|
30542
30541
|
}
|
|
30543
|
-
onConfirm(Math.max(1, Math.min(quantity, numberValue)));
|
|
30544
30542
|
},
|
|
30545
30543
|
noValidate: true
|
|
30546
30544
|
}, React__default.createElement(StyledInput, {
|
|
30547
|
-
|
|
30545
|
+
ref: inputRef,
|
|
30548
30546
|
placeholder: "Enter quantity",
|
|
30549
30547
|
type: "number",
|
|
30550
30548
|
min: 1,
|
|
30551
|
-
max:
|
|
30549
|
+
max: maxQuantity,
|
|
30552
30550
|
value: value,
|
|
30553
30551
|
onChange: function onChange(e) {
|
|
30554
|
-
if (Number(e.target.value) >=
|
|
30555
|
-
setValue(
|
|
30552
|
+
if (Number(e.target.value) >= maxQuantity) {
|
|
30553
|
+
setValue(maxQuantity);
|
|
30556
30554
|
return;
|
|
30557
30555
|
}
|
|
30558
|
-
setValue(e.target.value);
|
|
30556
|
+
setValue(Number(e.target.value));
|
|
30559
30557
|
},
|
|
30560
30558
|
onBlur: function onBlur(e) {
|
|
30561
|
-
|
|
30562
|
-
setValue(newValue);
|
|
30559
|
+
setValue(Math.max(1, Math.min(maxQuantity, Number(e.target.value))));
|
|
30563
30560
|
}
|
|
30564
30561
|
}), React__default.createElement(RangeSlider, {
|
|
30565
30562
|
type: exports.RangeSliderType.Slider,
|
|
30566
30563
|
valueMin: 1,
|
|
30567
|
-
valueMax:
|
|
30564
|
+
valueMax: maxQuantity,
|
|
30568
30565
|
width: "100%",
|
|
30569
30566
|
onChange: setValue,
|
|
30570
30567
|
value: value
|
|
@@ -30574,50 +30571,68 @@ var ItemQuantitySelector = function ItemQuantitySelector(_ref) {
|
|
|
30574
30571
|
}, "Confirm")));
|
|
30575
30572
|
};
|
|
30576
30573
|
var StyledContainer = /*#__PURE__*/styled__default(RPGUIContainer).withConfig({
|
|
30577
|
-
displayName: "
|
|
30578
|
-
componentId: "sc-
|
|
30579
|
-
})(["display:flex;flex-direction:column;align-items:center;"]);
|
|
30580
|
-
var StyledForm = /*#__PURE__*/styled__default.form.withConfig({
|
|
30581
|
-
displayName: "ItemQuantitySelector__StyledForm",
|
|
30582
|
-
componentId: "sc-yfdtpn-1"
|
|
30583
|
-
})(["display:flex;flex-direction:column;align-items:center;width:100%;"]);
|
|
30584
|
-
var StyledInput = /*#__PURE__*/styled__default(Input).withConfig({
|
|
30585
|
-
displayName: "ItemQuantitySelector__StyledInput",
|
|
30586
|
-
componentId: "sc-yfdtpn-2"
|
|
30587
|
-
})(["text-align:center;&::-webkit-outer-spin-button,&::-webkit-inner-spin-button{-webkit-appearance:none;margin:0;}&[type='number']{-moz-appearance:textfield;}"]);
|
|
30574
|
+
displayName: "QuantitySelector__StyledContainer",
|
|
30575
|
+
componentId: "sc-z4ut57-0"
|
|
30576
|
+
})(["position:relative;display:flex;flex-direction:column;align-items:center;padding:1rem;h2{margin:0;margin-bottom:1rem;font-size:1rem;}"]);
|
|
30588
30577
|
var CloseButton$5 = /*#__PURE__*/styled__default.div.withConfig({
|
|
30589
|
-
displayName: "
|
|
30590
|
-
componentId: "sc-
|
|
30591
|
-
})(["position:absolute;top:3px;right:0px;color:white;z-index:22;font-size:
|
|
30578
|
+
displayName: "QuantitySelector__CloseButton",
|
|
30579
|
+
componentId: "sc-z4ut57-1"
|
|
30580
|
+
})(["position:absolute;top:3px;right:0px;color:white;z-index:22;font-size:1.5rem;cursor:pointer;"]);
|
|
30581
|
+
var StyledForm = /*#__PURE__*/styled__default.form.withConfig({
|
|
30582
|
+
displayName: "QuantitySelector__StyledForm",
|
|
30583
|
+
componentId: "sc-z4ut57-2"
|
|
30584
|
+
})(["display:flex;flex-direction:column;align-items:center;gap:1rem;width:100%;"]);
|
|
30585
|
+
var StyledInput = /*#__PURE__*/styled__default.input.withConfig({
|
|
30586
|
+
displayName: "QuantitySelector__StyledInput",
|
|
30587
|
+
componentId: "sc-z4ut57-3"
|
|
30588
|
+
})(["width:100%;padding:0.5rem;background-color:rgba(0,0,0,0.25);border:none;color:white;font-size:1rem;text-align:center;&::-webkit-inner-spin-button,&::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}&[type='number']{-moz-appearance:textfield;}"]);
|
|
30592
30589
|
|
|
30593
|
-
var
|
|
30590
|
+
var validateQuantitySelect = function validateQuantitySelect(quantitySelect) {
|
|
30591
|
+
return _extends({}, quantitySelect, {
|
|
30592
|
+
maxQuantity: Math.max(1, quantitySelect.maxQuantity),
|
|
30593
|
+
initialQuantity: quantitySelect.initialQuantity ? Math.max(1, Math.min(quantitySelect.maxQuantity, quantitySelect.initialQuantity)) : undefined
|
|
30594
|
+
});
|
|
30595
|
+
};
|
|
30596
|
+
var QuantitySelectorModal = function QuantitySelectorModal(_ref) {
|
|
30594
30597
|
var quantitySelect = _ref.quantitySelect,
|
|
30595
30598
|
setQuantitySelect = _ref.setQuantitySelect;
|
|
30596
|
-
|
|
30597
|
-
|
|
30599
|
+
var resetQuantitySelect = function resetQuantitySelect() {
|
|
30600
|
+
setQuantitySelect({
|
|
30601
|
+
isOpen: false,
|
|
30602
|
+
maxQuantity: 1,
|
|
30603
|
+
callback: function callback() {}
|
|
30604
|
+
});
|
|
30605
|
+
};
|
|
30606
|
+
// Validate the input values
|
|
30607
|
+
var validatedQuantitySelect = validateQuantitySelect(quantitySelect);
|
|
30608
|
+
return React__default.createElement(ModalPortal, null, React__default.createElement(QuantitySelectorContainer, null, React__default.createElement(QuantitySelector, {
|
|
30609
|
+
maxQuantity: validatedQuantitySelect.maxQuantity,
|
|
30610
|
+
initialQuantity: validatedQuantitySelect.initialQuantity,
|
|
30611
|
+
title: validatedQuantitySelect.title,
|
|
30598
30612
|
onConfirm: function onConfirm(quantity) {
|
|
30599
|
-
|
|
30600
|
-
|
|
30601
|
-
isOpen: false,
|
|
30602
|
-
maxQuantity: 1,
|
|
30603
|
-
callback: function callback() {}
|
|
30604
|
-
});
|
|
30613
|
+
validatedQuantitySelect.callback(quantity);
|
|
30614
|
+
resetQuantitySelect();
|
|
30605
30615
|
},
|
|
30606
30616
|
onClose: function onClose() {
|
|
30607
|
-
|
|
30608
|
-
|
|
30609
|
-
isOpen: false,
|
|
30610
|
-
maxQuantity: 1,
|
|
30611
|
-
callback: function callback() {}
|
|
30612
|
-
});
|
|
30617
|
+
validatedQuantitySelect.callback(-1);
|
|
30618
|
+
resetQuantitySelect();
|
|
30613
30619
|
}
|
|
30614
30620
|
})));
|
|
30615
30621
|
};
|
|
30616
30622
|
var QuantitySelectorContainer = /*#__PURE__*/styled__default.div.withConfig({
|
|
30617
|
-
displayName: "
|
|
30618
|
-
componentId: "sc-
|
|
30623
|
+
displayName: "QuantitySelectorModal__QuantitySelectorContainer",
|
|
30624
|
+
componentId: "sc-aye686-0"
|
|
30619
30625
|
})(["position:absolute;top:0;left:0;width:100vw;height:100vh;z-index:100;display:flex;justify-content:center;align-items:center;background-color:rgba(0,0,0,0.5);"]);
|
|
30620
30626
|
|
|
30627
|
+
var ItemQuantitySelectorModal = function ItemQuantitySelectorModal(_ref) {
|
|
30628
|
+
var quantitySelect = _ref.quantitySelect,
|
|
30629
|
+
setQuantitySelect = _ref.setQuantitySelect;
|
|
30630
|
+
return React__default.createElement(QuantitySelectorModal, {
|
|
30631
|
+
quantitySelect: quantitySelect,
|
|
30632
|
+
setQuantitySelect: setQuantitySelect
|
|
30633
|
+
});
|
|
30634
|
+
};
|
|
30635
|
+
|
|
30621
30636
|
var MIN_SLOTS_FOR_SCROLL = 20;
|
|
30622
30637
|
var ItemContainer$1 = /*#__PURE__*/React__default.memo(function (_ref) {
|
|
30623
30638
|
var itemContainer = _ref.itemContainer,
|