@carbon/ibm-products-web-components
Version:
Carbon for IBM Products Web Components
55 lines (51 loc) • 2.58 kB
JavaScript
/**
* Copyright IBM Corp. 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import { __classPrivateFieldGet } from 'tslib';
import { signal } from '@lit-labs/signals';
/**
* Copyright IBM Corp. 2025, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
var _StepInstance_data;
class StepInstance {
constructor() {
_StepInstance_data.set(this, signal({
totalSteps: 0,
formState: {},
currentStep: 0,
}));
}
get data() {
return __classPrivateFieldGet(this, _StepInstance_data, "f").get();
}
set handleGoToStep(value) {
__classPrivateFieldGet(this, _StepInstance_data, "f").set(Object.assign(Object.assign({}, __classPrivateFieldGet(this, _StepInstance_data, "f").get()), { currentStep: value }));
}
set updateTotalStepCount(value) {
__classPrivateFieldGet(this, _StepInstance_data, "f").set(Object.assign(Object.assign({}, __classPrivateFieldGet(this, _StepInstance_data, "f").get()), { totalSteps: value }));
}
set updateFormState(newFormValue) {
__classPrivateFieldGet(this, _StepInstance_data, "f").set(Object.assign(Object.assign({}, __classPrivateFieldGet(this, _StepInstance_data, "f").get()), { formState: newFormValue }));
}
handleNext() {
const currentStep = __classPrivateFieldGet(this, _StepInstance_data, "f").get().currentStep + 1;
const totalSteps = __classPrivateFieldGet(this, _StepInstance_data, "f").get().totalSteps;
__classPrivateFieldGet(this, _StepInstance_data, "f").set(Object.assign(Object.assign({}, __classPrivateFieldGet(this, _StepInstance_data, "f").get()), { currentStep: currentStep < totalSteps ? currentStep : totalSteps }));
}
handlePrevious() {
const currentStep = __classPrivateFieldGet(this, _StepInstance_data, "f").get().currentStep;
__classPrivateFieldGet(this, _StepInstance_data, "f").set(Object.assign(Object.assign({}, __classPrivateFieldGet(this, _StepInstance_data, "f").get()), { currentStep: currentStep > 0 ? currentStep - 1 : 0 }));
}
reset() {
__classPrivateFieldGet(this, _StepInstance_data, "f").set(Object.assign(Object.assign({}, __classPrivateFieldGet(this, _StepInstance_data, "f").get()), { formState: {}, currentStep: 0 }));
}
}
_StepInstance_data = new WeakMap();
export { StepInstance };
//# sourceMappingURL=step-flow-signal.js.map