@plexui/vue 0.42.5 → 0.42.7
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.
|
@@ -143,7 +143,20 @@ export const OTPInput = defineComponent({
|
|
|
143
143
|
const handleChange = (index, evt) => {
|
|
144
144
|
if (props.disabled)
|
|
145
145
|
return;
|
|
146
|
-
|
|
146
|
+
let typedDigits = evt.currentTarget.value.replace(/\D/g, "");
|
|
147
|
+
// The first cell takes a whole code (its autofill) and, while it holds a digit, what is typed into it
|
|
148
|
+
const typed = evt;
|
|
149
|
+
if (index === 0 && digits.value[0] && typed.inputType === "insertText" && typed.data != null) {
|
|
150
|
+
// What was typed, not what the cell now holds: one digit replaces the cell's, a whole code spreads; with no
|
|
151
|
+
// digit in it, it is turned away, as a one-character cell would, and the cell keeps its digit
|
|
152
|
+
const inserted = typed.data.replace(/\D/g, "");
|
|
153
|
+
if (!inserted) {
|
|
154
|
+
;
|
|
155
|
+
evt.currentTarget.value = digits.value[0];
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
typedDigits = inserted;
|
|
159
|
+
}
|
|
147
160
|
if (!typedDigits) {
|
|
148
161
|
const nextDigits = [...digits.value];
|
|
149
162
|
nextDigits[index] = "";
|
|
@@ -238,7 +251,9 @@ export const OTPInput = defineComponent({
|
|
|
238
251
|
"type": "text",
|
|
239
252
|
"inputmode": "numeric",
|
|
240
253
|
"pattern": "[0-9]",
|
|
241
|
-
|
|
254
|
+
// A browser keeps an autofilled code to maxlength: the first cell, which takes the one-time
|
|
255
|
+
// code, holds a whole one, and the change spreads it over the cells as a paste
|
|
256
|
+
"maxlength": index === 0 ? length.value : 1,
|
|
242
257
|
"value": digits.value[index],
|
|
243
258
|
"disabled": props.disabled,
|
|
244
259
|
"class": s.CellInput,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OTPInput.js","sourceRoot":"","sources":["../../../../src/components/OTPInput/OTPInput.ts"],"names":[],"mappings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AE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC,YAAY,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC;gBAC9F,CAAC,CAAC,IAAI;SACT,CAAC,CAAA;IACN,CAAC;CACF,CAAC,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport { computed, defineComponent, h, nextTick, onMounted, onUpdated, ref, shallowRef, useId, watch, type PropType } from \"vue\"\nimport { FieldError } from \"../FieldError/index.js\"\nimport s from \"@plexui/styles/components/OTPInput/OTPInput.module.css\"\n\nfunction sanitizeDigits(value: string, length: number): string {\n return value.replace(/\\D/g, \"\").slice(0, length)\n}\n\n// One entry per cell, \"\" when empty\nfunction toCells(value: string, length: number): string[] {\n return Array.from({ length }, (_, index) => value[index] ?? \"\")\n}\n\nfunction shouldShowGap(index: number, grouping: number[]): boolean {\n let pos = 0\n for (const groupSize of grouping) {\n pos += groupSize\n if (index === pos) return true\n }\n return false\n}\n\n/**\n * Port of packages/ui/src/components/OTPInput/OTPInput.tsx. Controlled with\n * `value` (`v-model:value`); emits `update:value` and `change` when the\n * digits change and `complete` when every cell is filled.\n */\nexport const OTPInput = defineComponent({\n name: \"OTPInput\",\n inheritAttrs: false,\n props: {\n /** Number of digit cells. @default 6 */\n length: { type: Number, default: 6 },\n value: String,\n /** Group sizes, e.g. [3, 3] puts a gap after the third cell */\n grouping: Array as PropType<number[]>,\n invalid: { type: Boolean, default: false },\n errorMessage: String,\n disabled: { type: Boolean, default: false },\n autoFocus: { type: Boolean, default: false },\n },\n emits: {\n \"update:value\": (value: string) => typeof value === \"string\",\n \"change\": (value: string) => typeof value === \"string\",\n \"complete\": (value: string) => typeof value === \"string\",\n },\n setup(props, { attrs, emit, expose }) {\n const length = computed(() => Math.max(1, Math.floor(props.length)))\n const controlledValue = computed(() => sanitizeDigits(props.value ?? \"\", length.value))\n const isControlled = computed(() => props.value !== undefined)\n\n // The digit of every cell, so clearing or filling one cell never moves the\n // others; the value is the filled cells' digits in order\n const cells = shallowRef(toCells(controlledValue.value, length.value))\n const focusedIndex = ref(-1)\n\n const rootRef = ref<HTMLDivElement | null>(null)\n const inputRefs: Array<HTMLInputElement | null> = []\n\n expose({ root: rootRef })\n\n const ownCells = computed(() => Array.from({ length: length.value }, (_, index) => cells.value[index] ?? \"\"))\n const currentValue = computed(() => (isControlled.value ? controlledValue.value : ownCells.value.join(\"\")))\n // The cells keep their gaps while they spell the value; any other value\n // (set by the parent) fills the cells from the start\n const digits = computed(() =>\n ownCells.value.join(\"\") === currentValue.value ? ownCells.value : toCells(currentValue.value, length.value),\n )\n\n const errorId = `otp-input-${useId()}-error`\n\n // Inputs mirror `digits` like React's controlled inputs, which undo any\n // typing the state did not take\n const syncInputs = () => {\n digits.value.forEach((digit, index) => {\n const input = inputRefs[index]\n if (input && input.value !== digit) input.value = digit\n })\n }\n onUpdated(syncInputs)\n\n // React's effect on [autoFocus, disabled]: on mount and on either change\n const runAutoFocus = () => {\n if (!props.autoFocus || props.disabled) return\n inputRefs[0]?.focus()\n }\n onMounted(runAutoFocus)\n watch([() => props.autoFocus, () => props.disabled], runAutoFocus, { flush: \"post\" })\n\n // The value the field's own last edit produced, until the value changes:\n // a field the user empties keeps the caret where it is\n let ownValue: string | null = null\n\n const commitDigits = (nextDigits: string[]) => {\n const previous = currentValue.value\n // Kept when controlled too: the parent's value then keeps these gaps\n cells.value = nextDigits\n const nextValue = nextDigits.join(\"\")\n ownValue = nextValue\n if (nextValue !== previous) {\n emit(\"update:value\", nextValue)\n emit(\"change\", nextValue)\n }\n if (nextValue.length === length.value) {\n emit(\"complete\", nextValue)\n }\n void nextTick(syncInputs)\n }\n\n const focusCell = (index: number) => {\n const clampedIndex = Math.max(0, Math.min(index, length.value - 1))\n const input = inputRefs[clampedIndex]\n if (!input) return\n input.focus({ preventScroll: true })\n input.setSelectionRange(1, 1)\n }\n\n // A field cleared from outside (a wrong code wiped by the form) puts the\n // caret back in the first cell, when the focus was in the field already\n let hadValue = currentValue.value.length > 0\n watch(\n [currentValue, () => props.disabled],\n () => {\n const filled = currentValue.value.length > 0\n const fromOutside = ownValue !== currentValue.value\n ownValue = null\n const root = rootRef.value\n if (!filled && hadValue && fromOutside && !props.disabled && root?.contains(document.activeElement)) {\n focusCell(0)\n }\n hadValue = filled\n },\n { flush: \"post\" },\n )\n\n const handleCellClick = (index: number) => {\n if (props.disabled) return\n focusCell(index)\n }\n\n const handlePaste = (index: number, evt: ClipboardEvent) => {\n if (props.disabled) return\n evt.preventDefault()\n const pastedDigits = sanitizeDigits(evt.clipboardData?.getData(\"text\") ?? \"\", length.value)\n if (!pastedDigits) return\n\n const nextDigits = [...digits.value]\n let writeIndex = index\n\n for (const digit of pastedDigits) {\n if (writeIndex >= length.value) break\n nextDigits[writeIndex] = digit\n writeIndex += 1\n }\n\n commitDigits(nextDigits)\n // The cell after the pasted digits\n focusCell(Math.min(writeIndex, length.value - 1))\n }\n\n const handleChange = (index: number, evt: Event) => {\n if (props.disabled) return\n const typedDigits = (evt.currentTarget as HTMLInputElement).value.replace(/\\D/g, \"\")\n\n if (!typedDigits) {\n const nextDigits = [...digits.value]\n nextDigits[index] = \"\"\n commitDigits(nextDigits)\n return\n }\n\n const nextDigits = [...digits.value]\n\n if (typedDigits.length === 1) {\n nextDigits[index] = typedDigits[0]!\n commitDigits(nextDigits)\n if (index < length.value - 1) {\n focusCell(index + 1)\n }\n return\n }\n\n let writeIndex = index\n for (const digit of typedDigits) {\n if (writeIndex >= length.value) break\n nextDigits[writeIndex] = digit\n writeIndex += 1\n }\n\n commitDigits(nextDigits)\n // The cell after the typed digits\n focusCell(Math.min(writeIndex, length.value - 1))\n }\n\n const handleKeyDown = (index: number, evt: KeyboardEvent) => {\n // Candidate editing belongs to the IME, including Safari's 229 key.\n if (evt.isComposing || evt.keyCode === 229) return\n if (props.disabled) return\n\n if (evt.key === \"Backspace\") {\n evt.preventDefault()\n const nextDigits = [...digits.value]\n\n if (nextDigits[index]) {\n nextDigits[index] = \"\"\n commitDigits(nextDigits)\n return\n }\n\n if (index > 0) {\n nextDigits[index - 1] = \"\"\n commitDigits(nextDigits)\n focusCell(index - 1)\n }\n return\n }\n\n if (evt.key === \"Delete\") {\n evt.preventDefault()\n const nextDigits = [...digits.value]\n nextDigits[index] = \"\"\n commitDigits(nextDigits)\n return\n }\n\n if (evt.key === \"ArrowLeft\") {\n evt.preventDefault()\n focusCell(index - 1)\n return\n }\n\n if (evt.key === \"ArrowRight\") {\n evt.preventDefault()\n focusCell(index + 1)\n }\n }\n\n const handleBlur = () => {\n requestAnimationFrame(() => {\n const activeElement = document.activeElement\n const isAnyCellFocused = inputRefs.some((input) => input === activeElement)\n if (!isAnyCellFocused) {\n focusedIndex.value = -1\n }\n })\n }\n\n return () =>\n h(\"div\", { ref: rootRef, class: clsx(s.Root, attrs.class as string | undefined) }, [\n h(\n \"div\",\n { class: s.Cells },\n Array.from({ length: length.value }, (_, index) => {\n const isGroupGap = props.grouping ? shouldShowGap(index, props.grouping) : false\n return [\n isGroupGap ? h(\"div\", { \"class\": s.GroupGap, \"aria-hidden\": \"true\" }) : null,\n h(\n \"div\",\n {\n \"class\": clsx(s.Cell, {\n [s.CellFocused!]: focusedIndex.value === index,\n [s.CellFilled!]: !!digits.value[index],\n }),\n \"data-invalid\": props.invalid ? \"\" : undefined,\n \"data-disabled\": props.disabled ? \"\" : undefined,\n \"onClick\": () => handleCellClick(index),\n },\n [\n h(\"input\", {\n \"ref\": (element: unknown) => {\n inputRefs[index] = element as HTMLInputElement | null\n },\n \"type\": \"text\",\n \"inputmode\": \"numeric\",\n \"pattern\": \"[0-9]\",\n \"maxlength\": 1,\n \"value\": digits.value[index],\n \"disabled\": props.disabled,\n \"class\": s.CellInput,\n \"onInput\": (evt: Event) => handleChange(index, evt),\n \"onKeydown\": (evt: KeyboardEvent) => handleKeyDown(index, evt),\n \"onFocus\": () => (focusedIndex.value = index),\n \"onBlur\": handleBlur,\n \"onPaste\": (evt: ClipboardEvent) => handlePaste(index, evt),\n \"aria-label\": `Digit ${index + 1}`,\n \"aria-invalid\": props.invalid ? true : undefined,\n \"aria-describedby\": props.errorMessage ? errorId : undefined,\n \"autocomplete\": index === 0 ? \"one-time-code\" : \"off\",\n }),\n !digits.value[index] && focusedIndex.value !== index ? h(\"div\", { class: s.DotPlaceholder }) : null,\n ],\n ),\n ]\n }).flat(),\n ),\n props.errorMessage\n ? h(FieldError, { id: errorId, class: s.ErrorMessage }, { default: () => props.errorMessage })\n : null,\n ])\n },\n})\n\nexport type OTPInputProps = InstanceType<typeof OTPInput>[\"$props\"]\n"]}
|
|
1
|
+
{"version":3,"file":"OTPInput.js","sourceRoot":"","sources":["../../../../src/components/OTPInput/OTPInput.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAiB,MAAM,KAAK,CAAA;AAChI,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,CAAC,MAAM,wDAAwD,CAAA;AAEtE,SAAS,cAAc,CAAC,KAAa,EAAE,MAAc;IACnD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;AAClD,CAAC;AAED,oCAAoC;AACpC,SAAS,OAAO,CAAC,KAAa,EAAE,MAAc;IAC5C,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;AACjE,CAAC;AAED,SAAS,aAAa,CAAC,KAAa,EAAE,QAAkB;IACtD,IAAI,GAAG,GAAG,CAAC,CAAA;IACX,KAAK,MA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YAAY,EAAE,CAAC;gBAC9F,CAAC,CAAC,IAAI;SACT,CAAC,CAAA;IACN,CAAC;CACF,CAAC,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport { computed, defineComponent, h, nextTick, onMounted, onUpdated, ref, shallowRef, useId, watch, type PropType } from \"vue\"\nimport { FieldError } from \"../FieldError/index.js\"\nimport s from \"@plexui/styles/components/OTPInput/OTPInput.module.css\"\n\nfunction sanitizeDigits(value: string, length: number): string {\n return value.replace(/\\D/g, \"\").slice(0, length)\n}\n\n// One entry per cell, \"\" when empty\nfunction toCells(value: string, length: number): string[] {\n return Array.from({ length }, (_, index) => value[index] ?? \"\")\n}\n\nfunction shouldShowGap(index: number, grouping: number[]): boolean {\n let pos = 0\n for (const groupSize of grouping) {\n pos += groupSize\n if (index === pos) return true\n }\n return false\n}\n\n/**\n * Port of packages/ui/src/components/OTPInput/OTPInput.tsx. Controlled with\n * `value` (`v-model:value`); emits `update:value` and `change` when the\n * digits change and `complete` when every cell is filled.\n */\nexport const OTPInput = defineComponent({\n name: \"OTPInput\",\n inheritAttrs: false,\n props: {\n /** Number of digit cells. @default 6 */\n length: { type: Number, default: 6 },\n value: String,\n /** Group sizes, e.g. [3, 3] puts a gap after the third cell */\n grouping: Array as PropType<number[]>,\n invalid: { type: Boolean, default: false },\n errorMessage: String,\n disabled: { type: Boolean, default: false },\n autoFocus: { type: Boolean, default: false },\n },\n emits: {\n \"update:value\": (value: string) => typeof value === \"string\",\n \"change\": (value: string) => typeof value === \"string\",\n \"complete\": (value: string) => typeof value === \"string\",\n },\n setup(props, { attrs, emit, expose }) {\n const length = computed(() => Math.max(1, Math.floor(props.length)))\n const controlledValue = computed(() => sanitizeDigits(props.value ?? \"\", length.value))\n const isControlled = computed(() => props.value !== undefined)\n\n // The digit of every cell, so clearing or filling one cell never moves the\n // others; the value is the filled cells' digits in order\n const cells = shallowRef(toCells(controlledValue.value, length.value))\n const focusedIndex = ref(-1)\n\n const rootRef = ref<HTMLDivElement | null>(null)\n const inputRefs: Array<HTMLInputElement | null> = []\n\n expose({ root: rootRef })\n\n const ownCells = computed(() => Array.from({ length: length.value }, (_, index) => cells.value[index] ?? \"\"))\n const currentValue = computed(() => (isControlled.value ? controlledValue.value : ownCells.value.join(\"\")))\n // The cells keep their gaps while they spell the value; any other value\n // (set by the parent) fills the cells from the start\n const digits = computed(() =>\n ownCells.value.join(\"\") === currentValue.value ? ownCells.value : toCells(currentValue.value, length.value),\n )\n\n const errorId = `otp-input-${useId()}-error`\n\n // Inputs mirror `digits` like React's controlled inputs, which undo any\n // typing the state did not take\n const syncInputs = () => {\n digits.value.forEach((digit, index) => {\n const input = inputRefs[index]\n if (input && input.value !== digit) input.value = digit\n })\n }\n onUpdated(syncInputs)\n\n // React's effect on [autoFocus, disabled]: on mount and on either change\n const runAutoFocus = () => {\n if (!props.autoFocus || props.disabled) return\n inputRefs[0]?.focus()\n }\n onMounted(runAutoFocus)\n watch([() => props.autoFocus, () => props.disabled], runAutoFocus, { flush: \"post\" })\n\n // The value the field's own last edit produced, until the value changes:\n // a field the user empties keeps the caret where it is\n let ownValue: string | null = null\n\n const commitDigits = (nextDigits: string[]) => {\n const previous = currentValue.value\n // Kept when controlled too: the parent's value then keeps these gaps\n cells.value = nextDigits\n const nextValue = nextDigits.join(\"\")\n ownValue = nextValue\n if (nextValue !== previous) {\n emit(\"update:value\", nextValue)\n emit(\"change\", nextValue)\n }\n if (nextValue.length === length.value) {\n emit(\"complete\", nextValue)\n }\n void nextTick(syncInputs)\n }\n\n const focusCell = (index: number) => {\n const clampedIndex = Math.max(0, Math.min(index, length.value - 1))\n const input = inputRefs[clampedIndex]\n if (!input) return\n input.focus({ preventScroll: true })\n input.setSelectionRange(1, 1)\n }\n\n // A field cleared from outside (a wrong code wiped by the form) puts the\n // caret back in the first cell, when the focus was in the field already\n let hadValue = currentValue.value.length > 0\n watch(\n [currentValue, () => props.disabled],\n () => {\n const filled = currentValue.value.length > 0\n const fromOutside = ownValue !== currentValue.value\n ownValue = null\n const root = rootRef.value\n if (!filled && hadValue && fromOutside && !props.disabled && root?.contains(document.activeElement)) {\n focusCell(0)\n }\n hadValue = filled\n },\n { flush: \"post\" },\n )\n\n const handleCellClick = (index: number) => {\n if (props.disabled) return\n focusCell(index)\n }\n\n const handlePaste = (index: number, evt: ClipboardEvent) => {\n if (props.disabled) return\n evt.preventDefault()\n const pastedDigits = sanitizeDigits(evt.clipboardData?.getData(\"text\") ?? \"\", length.value)\n if (!pastedDigits) return\n\n const nextDigits = [...digits.value]\n let writeIndex = index\n\n for (const digit of pastedDigits) {\n if (writeIndex >= length.value) break\n nextDigits[writeIndex] = digit\n writeIndex += 1\n }\n\n commitDigits(nextDigits)\n // The cell after the pasted digits\n focusCell(Math.min(writeIndex, length.value - 1))\n }\n\n const handleChange = (index: number, evt: Event) => {\n if (props.disabled) return\n let typedDigits = (evt.currentTarget as HTMLInputElement).value.replace(/\\D/g, \"\")\n // The first cell takes a whole code (its autofill) and, while it holds a digit, what is typed into it\n const typed = evt as InputEvent\n if (index === 0 && digits.value[0] && typed.inputType === \"insertText\" && typed.data != null) {\n // What was typed, not what the cell now holds: one digit replaces the cell's, a whole code spreads; with no\n // digit in it, it is turned away, as a one-character cell would, and the cell keeps its digit\n const inserted = typed.data.replace(/\\D/g, \"\")\n if (!inserted) {\n ;(evt.currentTarget as HTMLInputElement).value = digits.value[0]\n return\n }\n typedDigits = inserted\n }\n\n if (!typedDigits) {\n const nextDigits = [...digits.value]\n nextDigits[index] = \"\"\n commitDigits(nextDigits)\n return\n }\n\n const nextDigits = [...digits.value]\n\n if (typedDigits.length === 1) {\n nextDigits[index] = typedDigits[0]!\n commitDigits(nextDigits)\n if (index < length.value - 1) {\n focusCell(index + 1)\n }\n return\n }\n\n let writeIndex = index\n for (const digit of typedDigits) {\n if (writeIndex >= length.value) break\n nextDigits[writeIndex] = digit\n writeIndex += 1\n }\n\n commitDigits(nextDigits)\n // The cell after the typed digits\n focusCell(Math.min(writeIndex, length.value - 1))\n }\n\n const handleKeyDown = (index: number, evt: KeyboardEvent) => {\n // Candidate editing belongs to the IME, including Safari's 229 key.\n if (evt.isComposing || evt.keyCode === 229) return\n if (props.disabled) return\n\n if (evt.key === \"Backspace\") {\n evt.preventDefault()\n const nextDigits = [...digits.value]\n\n if (nextDigits[index]) {\n nextDigits[index] = \"\"\n commitDigits(nextDigits)\n return\n }\n\n if (index > 0) {\n nextDigits[index - 1] = \"\"\n commitDigits(nextDigits)\n focusCell(index - 1)\n }\n return\n }\n\n if (evt.key === \"Delete\") {\n evt.preventDefault()\n const nextDigits = [...digits.value]\n nextDigits[index] = \"\"\n commitDigits(nextDigits)\n return\n }\n\n if (evt.key === \"ArrowLeft\") {\n evt.preventDefault()\n focusCell(index - 1)\n return\n }\n\n if (evt.key === \"ArrowRight\") {\n evt.preventDefault()\n focusCell(index + 1)\n }\n }\n\n const handleBlur = () => {\n requestAnimationFrame(() => {\n const activeElement = document.activeElement\n const isAnyCellFocused = inputRefs.some((input) => input === activeElement)\n if (!isAnyCellFocused) {\n focusedIndex.value = -1\n }\n })\n }\n\n return () =>\n h(\"div\", { ref: rootRef, class: clsx(s.Root, attrs.class as string | undefined) }, [\n h(\n \"div\",\n { class: s.Cells },\n Array.from({ length: length.value }, (_, index) => {\n const isGroupGap = props.grouping ? shouldShowGap(index, props.grouping) : false\n return [\n isGroupGap ? h(\"div\", { \"class\": s.GroupGap, \"aria-hidden\": \"true\" }) : null,\n h(\n \"div\",\n {\n \"class\": clsx(s.Cell, {\n [s.CellFocused!]: focusedIndex.value === index,\n [s.CellFilled!]: !!digits.value[index],\n }),\n \"data-invalid\": props.invalid ? \"\" : undefined,\n \"data-disabled\": props.disabled ? \"\" : undefined,\n \"onClick\": () => handleCellClick(index),\n },\n [\n h(\"input\", {\n \"ref\": (element: unknown) => {\n inputRefs[index] = element as HTMLInputElement | null\n },\n \"type\": \"text\",\n \"inputmode\": \"numeric\",\n \"pattern\": \"[0-9]\",\n // A browser keeps an autofilled code to maxlength: the first cell, which takes the one-time\n // code, holds a whole one, and the change spreads it over the cells as a paste\n \"maxlength\": index === 0 ? length.value : 1,\n \"value\": digits.value[index],\n \"disabled\": props.disabled,\n \"class\": s.CellInput,\n \"onInput\": (evt: Event) => handleChange(index, evt),\n \"onKeydown\": (evt: KeyboardEvent) => handleKeyDown(index, evt),\n \"onFocus\": () => (focusedIndex.value = index),\n \"onBlur\": handleBlur,\n \"onPaste\": (evt: ClipboardEvent) => handlePaste(index, evt),\n \"aria-label\": `Digit ${index + 1}`,\n \"aria-invalid\": props.invalid ? true : undefined,\n \"aria-describedby\": props.errorMessage ? errorId : undefined,\n \"autocomplete\": index === 0 ? \"one-time-code\" : \"off\",\n }),\n !digits.value[index] && focusedIndex.value !== index ? h(\"div\", { class: s.DotPlaceholder }) : null,\n ],\n ),\n ]\n }).flat(),\n ),\n props.errorMessage\n ? h(FieldError, { id: errorId, class: s.ErrorMessage }, { default: () => props.errorMessage })\n : null,\n ])\n },\n})\n\nexport type OTPInputProps = InstanceType<typeof OTPInput>[\"$props\"]\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plexui/vue",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.7",
|
|
4
4
|
"description": "Plex UI components for Vue 3, built on Reka UI and the shared @plexui/styles CSS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@maskito/core": "5.2.2",
|
|
78
78
|
"@maskito/kit": "5.2.2",
|
|
79
79
|
"@maskito/vue": "5.2.2",
|
|
80
|
-
"@plexui/styles": "^0.17.
|
|
80
|
+
"@plexui/styles": "^0.17.6",
|
|
81
81
|
"@tanstack/table-core": "8.21.3",
|
|
82
82
|
"@tanstack/vue-table": "8.21.3",
|
|
83
83
|
"@tiptap/core": "3.21.0",
|