@shoper/phoenix_design_system 1.2.13-16 → 1.2.13-17
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/build/cjs/packages/phoenix/src/components/form/input_stepper/input_stepper.js +27 -14
- package/build/cjs/packages/phoenix/src/components/form/input_stepper/input_stepper.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/input_stepper/input_stepper.d.ts +1 -0
- package/build/esm/packages/phoenix/src/components/form/input_stepper/input_stepper.js +28 -15
- package/build/esm/packages/phoenix/src/components/form/input_stepper/input_stepper.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/input_stepper/input_stepper_constants.d.ts +3 -3
- package/build/esm/packages/phoenix/src/components/form/input_stepper/input_stepper_types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -18,7 +18,19 @@ exports.HInputStepper = class HInputStepper extends phoenix_light_lit_element.Ph
|
|
|
18
18
|
this.step = 1;
|
|
19
19
|
this.stepperValue = '0';
|
|
20
20
|
this.inputReference = null;
|
|
21
|
-
this.
|
|
21
|
+
this._inputChange = () => {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
if (!this.inputReference)
|
|
24
|
+
return;
|
|
25
|
+
let { value: inputValue } = (_c = (_b = (_a = this.inputReference) === null || _a === void 0 ? void 0 : _a.inputRef) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : {};
|
|
26
|
+
if (inputValue === null)
|
|
27
|
+
return;
|
|
28
|
+
if (!this.allowFractions)
|
|
29
|
+
inputValue = this._roundToStepSize(this.step, Number(inputValue));
|
|
30
|
+
this._setValue(`${inputValue}`);
|
|
31
|
+
};
|
|
32
|
+
this._buttonClick = (event) => {
|
|
33
|
+
const buttonElement = event.target.closest('h-button-stepper');
|
|
22
34
|
const step = Number(buttonElement.getAttribute('step'));
|
|
23
35
|
if (isNaN(step))
|
|
24
36
|
return;
|
|
@@ -32,6 +44,16 @@ exports.HInputStepper = class HInputStepper extends phoenix_light_lit_element.Ph
|
|
|
32
44
|
this._subscribeToInput();
|
|
33
45
|
this._attemptSetInputValue();
|
|
34
46
|
}
|
|
47
|
+
disconnectedCallback() {
|
|
48
|
+
super.disconnectedCallback();
|
|
49
|
+
this.inputReference && this.inputReference.removeEventListener(input_stepper_constants.INPUT_STEPPER_EVENT_NAMES.change, this._inputChange);
|
|
50
|
+
const stepperButtons = Array.from(this.querySelectorAll(input_stepper_constants.INPUT_STEPPER_COMPONENT_NAMES.button));
|
|
51
|
+
if (stepperButtons.length === 0)
|
|
52
|
+
return;
|
|
53
|
+
stepperButtons.forEach((button) => {
|
|
54
|
+
button.removeEventListener(input_stepper_constants.INPUT_STEPPER_EVENT_NAMES.click, this._buttonClick);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
35
57
|
_registerInputRef() {
|
|
36
58
|
this.inputReference = this.querySelector(input_stepper_constants.INPUT_STEPPER_COMPONENT_NAMES.input);
|
|
37
59
|
}
|
|
@@ -40,26 +62,17 @@ exports.HInputStepper = class HInputStepper extends phoenix_light_lit_element.Ph
|
|
|
40
62
|
if (stepperButtons.length === 0)
|
|
41
63
|
return;
|
|
42
64
|
stepperButtons.forEach((button) => {
|
|
43
|
-
button.addEventListener(input_stepper_constants.INPUT_STEPPER_EVENT_NAMES.click,
|
|
65
|
+
button.addEventListener(input_stepper_constants.INPUT_STEPPER_EVENT_NAMES.click, this._buttonClick);
|
|
44
66
|
});
|
|
45
67
|
}
|
|
46
68
|
_subscribeToInput() {
|
|
47
69
|
if (!this.inputReference)
|
|
48
70
|
return;
|
|
49
|
-
this.inputReference.addEventListener(input_stepper_constants.INPUT_STEPPER_EVENT_NAMES.change,
|
|
50
|
-
}
|
|
51
|
-
_inputChange(input) {
|
|
52
|
-
var _a, _b;
|
|
53
|
-
let { value: inputValue } = (_b = (_a = input === null || input === void 0 ? void 0 : input.inputRef) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : {};
|
|
54
|
-
if (inputValue === null)
|
|
55
|
-
return;
|
|
56
|
-
if (!this.allowFractions)
|
|
57
|
-
inputValue = this._roundToStepSize(this.step, Number(inputValue));
|
|
58
|
-
this._setValue(`${inputValue}`);
|
|
71
|
+
this.inputReference.addEventListener(input_stepper_constants.INPUT_STEPPER_EVENT_NAMES.change, this._inputChange);
|
|
59
72
|
}
|
|
60
73
|
_setValueByButton(value) {
|
|
61
|
-
const
|
|
62
|
-
this._setValue(`${this._roundToStepSize(value,
|
|
74
|
+
const newInputValue = Number(this.stepperValue) + value;
|
|
75
|
+
this._setValue(`${this._roundToStepSize(value, newInputValue)}`);
|
|
63
76
|
}
|
|
64
77
|
_setValue(newValue) {
|
|
65
78
|
const newValueNumber = Number(newValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -9,6 +9,7 @@ export declare class HInputStepper extends PhoenixLightLitElement {
|
|
|
9
9
|
stepperValue: string;
|
|
10
10
|
private inputReference;
|
|
11
11
|
connectedCallback(): void;
|
|
12
|
+
disconnectedCallback(): void;
|
|
12
13
|
private _registerInputRef;
|
|
13
14
|
private _subscribeToButtons;
|
|
14
15
|
private _subscribeToInput;
|
|
@@ -2,7 +2,7 @@ import { __decorate, __metadata } from '../../../../../../external/tslib/tslib.e
|
|
|
2
2
|
import { property, state } from 'lit/decorators';
|
|
3
3
|
import { PhoenixLightLitElement } from '../../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
|
|
4
4
|
import { phoenixCustomElement } from '../../../core/decorators/phoenix_custom_element.js';
|
|
5
|
-
import {
|
|
5
|
+
import { INPUT_STEPPER_EVENT_NAMES, INPUT_STEPPER_COMPONENT_NAMES, INPUT_STEPPER_CUSTOM_EVENT_NAMES } from './input_stepper_constants.js';
|
|
6
6
|
|
|
7
7
|
let HInputStepper = class HInputStepper extends PhoenixLightLitElement {
|
|
8
8
|
constructor() {
|
|
@@ -14,7 +14,19 @@ let HInputStepper = class HInputStepper extends PhoenixLightLitElement {
|
|
|
14
14
|
this.step = 1;
|
|
15
15
|
this.stepperValue = '0';
|
|
16
16
|
this.inputReference = null;
|
|
17
|
-
this.
|
|
17
|
+
this._inputChange = () => {
|
|
18
|
+
var _a, _b, _c;
|
|
19
|
+
if (!this.inputReference)
|
|
20
|
+
return;
|
|
21
|
+
let { value: inputValue } = (_c = (_b = (_a = this.inputReference) === null || _a === void 0 ? void 0 : _a.inputRef) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : {};
|
|
22
|
+
if (inputValue === null)
|
|
23
|
+
return;
|
|
24
|
+
if (!this.allowFractions)
|
|
25
|
+
inputValue = this._roundToStepSize(this.step, Number(inputValue));
|
|
26
|
+
this._setValue(`${inputValue}`);
|
|
27
|
+
};
|
|
28
|
+
this._buttonClick = (event) => {
|
|
29
|
+
const buttonElement = event.target.closest('h-button-stepper');
|
|
18
30
|
const step = Number(buttonElement.getAttribute('step'));
|
|
19
31
|
if (isNaN(step))
|
|
20
32
|
return;
|
|
@@ -28,6 +40,16 @@ let HInputStepper = class HInputStepper extends PhoenixLightLitElement {
|
|
|
28
40
|
this._subscribeToInput();
|
|
29
41
|
this._attemptSetInputValue();
|
|
30
42
|
}
|
|
43
|
+
disconnectedCallback() {
|
|
44
|
+
super.disconnectedCallback();
|
|
45
|
+
this.inputReference && this.inputReference.removeEventListener(INPUT_STEPPER_EVENT_NAMES.change, this._inputChange);
|
|
46
|
+
const stepperButtons = Array.from(this.querySelectorAll(INPUT_STEPPER_COMPONENT_NAMES.button));
|
|
47
|
+
if (stepperButtons.length === 0)
|
|
48
|
+
return;
|
|
49
|
+
stepperButtons.forEach((button) => {
|
|
50
|
+
button.removeEventListener(INPUT_STEPPER_EVENT_NAMES.click, this._buttonClick);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
31
53
|
_registerInputRef() {
|
|
32
54
|
this.inputReference = this.querySelector(INPUT_STEPPER_COMPONENT_NAMES.input);
|
|
33
55
|
}
|
|
@@ -36,26 +58,17 @@ let HInputStepper = class HInputStepper extends PhoenixLightLitElement {
|
|
|
36
58
|
if (stepperButtons.length === 0)
|
|
37
59
|
return;
|
|
38
60
|
stepperButtons.forEach((button) => {
|
|
39
|
-
button.addEventListener(INPUT_STEPPER_EVENT_NAMES.click,
|
|
61
|
+
button.addEventListener(INPUT_STEPPER_EVENT_NAMES.click, this._buttonClick);
|
|
40
62
|
});
|
|
41
63
|
}
|
|
42
64
|
_subscribeToInput() {
|
|
43
65
|
if (!this.inputReference)
|
|
44
66
|
return;
|
|
45
|
-
this.inputReference.addEventListener(INPUT_STEPPER_EVENT_NAMES.change,
|
|
46
|
-
}
|
|
47
|
-
_inputChange(input) {
|
|
48
|
-
var _a, _b;
|
|
49
|
-
let { value: inputValue } = (_b = (_a = input === null || input === void 0 ? void 0 : input.inputRef) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : {};
|
|
50
|
-
if (inputValue === null)
|
|
51
|
-
return;
|
|
52
|
-
if (!this.allowFractions)
|
|
53
|
-
inputValue = this._roundToStepSize(this.step, Number(inputValue));
|
|
54
|
-
this._setValue(`${inputValue}`);
|
|
67
|
+
this.inputReference.addEventListener(INPUT_STEPPER_EVENT_NAMES.change, this._inputChange);
|
|
55
68
|
}
|
|
56
69
|
_setValueByButton(value) {
|
|
57
|
-
const
|
|
58
|
-
this._setValue(`${this._roundToStepSize(value,
|
|
70
|
+
const newInputValue = Number(this.stepperValue) + value;
|
|
71
|
+
this._setValue(`${this._roundToStepSize(value, newInputValue)}`);
|
|
59
72
|
}
|
|
60
73
|
_setValue(newValue) {
|
|
61
74
|
const newValueNumber = Number(newValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
package/build/esm/packages/phoenix/src/components/form/input_stepper/input_stepper_constants.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const INPUT_STEPPER_CLASS_NAMES: {
|
|
|
9
9
|
readonly displayInput: "input-stepper__value_input";
|
|
10
10
|
};
|
|
11
11
|
export declare const INPUT_STEPPER_COMPONENT_NAMES: {
|
|
12
|
-
control:
|
|
13
|
-
input:
|
|
14
|
-
button:
|
|
12
|
+
readonly control: "h-input-stepper";
|
|
13
|
+
readonly input: "h-display-stepper";
|
|
14
|
+
readonly button: "h-button-stepper";
|
|
15
15
|
};
|