@carbon/ibm-products-web-components
Version:
Carbon for IBM Products Web Components
69 lines (67 loc) • 1.53 kB
JavaScript
/**
* Copyright IBM Corp. 2020, 2026
*
* 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 { signal } from "@lit-labs/signals";
//#region src/utilities/step-flow/step-flow-signal.ts
/**
* 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 = class {
#data = signal({
totalSteps: 0,
formState: {},
currentStep: 0
});
get data() {
return this.#data.get();
}
set handleGoToStep(value) {
this.#data.set({
...this.#data.get(),
currentStep: value
});
}
set updateTotalStepCount(value) {
this.#data.set({
...this.#data.get(),
totalSteps: value
});
}
set updateFormState(newFormValue) {
this.#data.set({
...this.#data.get(),
formState: newFormValue
});
}
handleNext() {
const currentStep = this.#data.get().currentStep + 1;
const totalSteps = this.#data.get().totalSteps;
this.#data.set({
...this.#data.get(),
currentStep: currentStep < totalSteps ? currentStep : totalSteps
});
}
handlePrevious() {
const currentStep = this.#data.get().currentStep;
this.#data.set({
...this.#data.get(),
currentStep: currentStep > 0 ? currentStep - 1 : 0
});
}
reset() {
this.#data.set({
...this.#data.get(),
formState: {},
currentStep: 0
});
}
};
//#endregion
export { StepInstance };
//# sourceMappingURL=step-flow-signal.js.map