Skip to content

A platform for community discussion. Free, open, simple.

DEV: documents DOTP component public API (#35988)

Joffrey JAFFEUXb41848111691
diff --git a/frontend/discourse/app/components/d-otp/index.gjs b/frontend/discourse/app/components/d-otp/index.gjs
index 76824a4cebd..c4f4707bb7f 100644
--- a/frontend/discourse/app/components/d-otp/index.gjs
+++ b/frontend/discourse/app/components/d-otp/index.gjs
@@ -1,3 +1,4 @@
+// @ts-check
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { on } from "@ember/modifier";
@@ -11,6 +12,19 @@ import Slot from "./slot";
const DEFAULT_SLOTS = 6;
+/**
+ * @typedef DOTPSignature
+ *
+ * @property {object} Args
+ *
+ * @property {number} [Args.slots] - Number of OTP input slots to display (defaults to 6)
+ * @property {boolean} [Args.autofocus] - Whether to autofocus the input on mount (defaults to true)
+ * @property {function(string): void} [Args.onChange] - Callback invoked whenever the OTP value changes
+ * @property {function(string): void} [Args.onFill] - Callback invoked when all OTP slots are filled
+ *
+ */
+
+/** @extends {Component<DOTPSignature>} */
export default class DOTP extends Component {
@tracked isFocused = false;
@tracked isAllSelected = false;